# This is a BitKeeper generated patch for the following project: # Project Name: Linux kernel tree # This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas: # ChangeSet v2.5.65 -> 1.1012 # arch/i386/kernel/process.c 1.47 -> 1.48 # drivers/video/fbmem.c 1.53.1.6 -> 1.63 # drivers/char/rio/riointr.c 1.5 -> 1.6 # fs/xfs/linux/xfs_lrw.c 1.16 -> 1.17 # sound/pci/ice1712/amp.h 1.1 -> 1.2 # fs/xfs/xfs_dir2_node.c 1.3 -> 1.7 # drivers/parport/parport_arc.c 1.2 -> 1.3 # arch/m68k/vmlinux-sun3.lds 1.12 -> 1.13 # net/ipv4/netfilter/ip_conntrack_core.c 1.20 -> 1.21 # drivers/char/drm/drm_agpsupport.h 1.14 -> 1.15 # sound/pci/trident/trident.c 1.8 -> 1.9 # drivers/char/drm/drm_context.h 1.9 -> 1.10 # drivers/video/sis/vgatypes.h 1.2 -> 1.3 # include/asm-m68k/siginfo.h 1.4 -> 1.5 # arch/sparc64/kernel/smp.c 1.49 -> 1.52 # Documentation/DocBook/kernel-api.tmpl 1.23 -> 1.24 # include/linux/file.h 1.7 -> 1.8 # drivers/net/e100/e100_phy.c 1.11 -> 1.13 # net/ipv4/netfilter/ipt_pkttype.c 1.1 -> 1.2 # include/pcmcia/ds.h 1.2 -> 1.5 # drivers/i2c/chips/lm75.c 1.6 -> 1.7 # include/linux/rtc.h 1.5 -> 1.6 # drivers/video/aty/mach64_ct.c 1.5 -> 1.7 # include/asm-um/linux_logo.h 1.1 -> (deleted) # drivers/video/sis/oem310.h 1.2 -> 1.4 # include/linux/swapops.h 1.2 -> 1.3 # drivers/ide/pci/via82cxxx.c 1.10 -> 1.11 # arch/ppc/syslib/ppc4xx_setup.c 1.10 -> 1.11 # fs/intermezzo/kml.c 1.3 -> 1.4 # include/asm-ppc/mpc8260.h 1.4 -> 1.5 # drivers/video/sis/osdef.h 1.2 -> 1.3 # arch/parisc/kernel/pci.c 1.8 -> 1.9 # arch/s390x/kernel/exec32.c 1.7 -> 1.8 # drivers/media/video/saa7134/saa7134-tvaudio.c 1.4 -> 1.5 # arch/ppc/8260_io/enet.c 1.6 -> 1.7 # include/asm-ia64/linux_logo.h 1.2 -> (deleted) # sound/oss/opl3sa2.c 1.18 -> 1.19 # fs/xfs/linux/xfs_sysctl.h 1.5 -> 1.6 # sound/core/seq/oss/seq_oss_midi.c 1.6 -> 1.7 # include/asm-parisc/unistd.h 1.7 -> 1.8 # arch/i386/lib/usercopy.c 1.9 -> 1.10 # sound/oss/cs46xx.c 1.23 -> 1.24 # fs/xfs/linux/xfs_linux.h 1.13 -> 1.16 # include/asm-i386/system.h 1.24 -> 1.25 # include/linux/console_struct.h 1.4 -> 1.5 # fs/dcookies.c 1.3 -> 1.4 # drivers/net/3c501.c 1.16 -> 1.17 # include/sound/initval.h 1.6 -> 1.7 # drivers/video/aty/mach64_accel.c 1.8 -> 1.10 # net/ipv4/ip_forward.c 1.7 -> 1.8 # drivers/ide/ide-taskfile.c 1.12 -> 1.13 # drivers/char/vme_scc.c 1.11 -> 1.12 # sound/pci/emu10k1/emupcm.c 1.12 -> 1.13 # arch/x86_64/kernel/traps.c 1.16 -> 1.17 # drivers/media/video/cpia_pp.c 1.9 -> 1.10 # drivers/media/video/cpia_usb.c 1.19 -> 1.20 # include/linux/pagemap.h 1.33 -> 1.34 # include/asm-ppc/rtc.h 1.5 -> 1.6 # drivers/media/video/saa7134/saa7134-ts.c 1.3 -> 1.4 # kernel/ksyms.c 1.184 -> 1.186 # drivers/char/n_tty.c 1.11 -> 1.13 # sound/pci/korg1212/korg1212.c 1.17 -> 1.18 # drivers/net/e1000/e1000.h 1.23 -> 1.28 # include/linux/ioctl32.h 1.1 -> 1.2 # net/ipv6/netfilter/ip6t_eui64.c 1.1 -> 1.2 # include/asm-mips64/linux_logo.h 1.3 -> (deleted) # include/net/sctp/user.h 1.8 -> 1.9 # arch/m68k/kernel/entry.S 1.10 -> 1.11 # fs/xfs/linux/xfs_vfs.h 1.2 -> 1.4 # include/asm-mips64/elf.h 1.4 -> 1.5 # mm/fremap.c 1.4 -> 1.6 # drivers/i2c/chips/adm1021.c 1.6 -> 1.7 # sound/core/seq/oss/seq_oss_synth.c 1.9 -> 1.10 # arch/parisc/kernel/ioctl32.c 1.4 -> 1.5 # fs/intermezzo/inode.c 1.7 -> 1.8 # Documentation/fb/clgenfb.txt 1.3 -> 1.4 Documentation/fb/cirrusfb.txt (moved) # fs/xfs/xfs_buf_item.c 1.8 -> 1.9 # include/asm-arm/proc-armv/system.h 1.8 -> 1.9 # arch/m68k/amiga/config.c 1.13 -> 1.14 # fs/select.c 1.16 -> 1.17 # drivers/video/Kconfig 1.11.1.8 -> 1.22 # drivers/serial/8250_pnp.c 1.10 -> 1.11 # include/linux/buffer_head.h 1.38 -> 1.39 # drivers/char/ftape/zftape/zftape_syms.c 1.2 -> 1.3 # drivers/message/fusion/mptctl.c 1.13 -> 1.14 # drivers/pnp/pnpbios/core.c 1.25 -> 1.27 # Documentation/sound/alsa/CMIPCI.txt 1.3 -> 1.4 # arch/x86_64/ia32/ia32_binfmt.c 1.9 -> 1.10 # include/asm-sparc/linux_logo.h 1.3 -> (deleted) # net/ipv6/netfilter/ip6t_dst.c 1.2 -> 1.4 # drivers/mtd/devices/blkmtd.c 1.28 -> 1.29 # drivers/net/3c509.c 1.33 -> 1.34 # fs/xfs/pagebuf/page_buf.c 1.44 -> 1.45 # net/sctp/associola.c 1.32 -> 1.35 # drivers/message/i2o/Kconfig 1.3 -> 1.4 # drivers/usb/net/cdc-ether.c 1.26 -> 1.27 # fs/xfs/xfs_qm.c 1.8 -> 1.9 # fs/xfs/linux/xfs_fs_subr.c 1.2 -> 1.3 # arch/sh/kernel/traps.c 1.6 -> 1.7 # include/linux/mm.h 1.110 -> 1.113 # include/asm-i386/processor.h 1.43 -> 1.44 # fs/file_table.c 1.18 -> 1.22 # drivers/telephony/ixj.c 1.21 -> 1.22 # fs/sysfs/file.c 1.2 -> 1.3 # fs/xfs/xfs_dir2_block.c 1.2 -> 1.5 # drivers/video/sis/init301.c 1.2 -> 1.4 # drivers/scsi/aha152x.c 1.24 -> 1.25 # include/video/sgivw.h 1.3.1.1 -> 1.6 # net/ipv4/ipconfig.c 1.22 -> 1.23 # include/asm-x86_64/page.h 1.8 -> 1.9 # sound/pci/ice1712/ice1712.h 1.6 -> 1.7 # include/asm-parisc/linux_logo.h 1.3 -> (deleted) # net/core/neighbour.c 1.9 -> 1.10 # arch/i386/kernel/cpu/cpufreq/longhaul.c 1.14 -> 1.15 # net/ipv4/netfilter/ipt_TOS.c 1.6 -> 1.7 # net/ipv4/netfilter/ipt_limit.c 1.2 -> 1.3 # arch/ppc/Makefile 1.37 -> 1.38 # sound/arm/sa11xx-uda1341.c 1.10 -> 1.11 # sound/core/hwdep.c 1.11 -> 1.12 # sound/core/memory.c 1.16 -> 1.17 # drivers/scsi/cpqfcTSinit.c 1.32 -> 1.33 # drivers/ide/pci/serverworks.c 1.14 -> 1.16 # drivers/input/serio/Makefile 1.7 -> 1.8 # mm/mlock.c 1.4 -> 1.5 # drivers/ide/pci/piix.c 1.12 -> 1.14 # fs/xfs/linux/xfs_lrw.h 1.9 -> 1.10 # sound/oss/emu10k1/efxmgr.c 1.3 -> 1.4 # arch/i386/kernel/irq.c 1.28 -> 1.29 # drivers/char/decserial.c 1.3 -> 1.4 # net/sctp/sm_statefuns.c 1.37 -> 1.38 # arch/ppc/syslib/Makefile 1.4 -> 1.5 # sound/oss/emu10k1/timer.h 1.3 -> 1.4 # drivers/scsi/mac53c94.c 1.3 -> 1.4 # drivers/i2c/busses/Makefile 1.5 -> 1.6 # drivers/char/watchdog/pcwd.c 1.20 -> 1.21 # arch/ppc/8260_io/uart.c 1.11 -> 1.12 # mm/page_alloc.c 1.148 -> 1.149 # sound/core/seq/oss/seq_oss_init.c 1.5 -> 1.6 # arch/ppc/syslib/prom.c 1.18 -> 1.19 # arch/i386/pci/pcbios.c 1.11 -> 1.12 # arch/ppc/boot/images/Makefile 1.6 -> 1.7 # sound/pci/cs46xx/cs46xx_lib.c 1.24.1.1 -> 1.28 # net/ipv6/ipv6_sockglue.c 1.13 -> 1.14 # drivers/scsi/sun3_scsi.h 1.5 -> 1.6 # include/linux/pmu.h 1.4 -> 1.5 # drivers/scsi/sun3_scsi.c 1.13 -> 1.15 # drivers/ide/pci/cs5520.c 1.4 -> 1.5 # include/asm-m68k/kmap_types.h 1.1 -> 1.2 # include/linux/ext3_jbd.h 1.9 -> 1.10 # drivers/char/drm/i830_dma.c 1.10 -> 1.12 # Documentation/sound/alsa/ALSA-Configuration.txt 1.4 -> 1.5 # sound/drivers/opl3/opl3_oss.c 1.5 -> 1.6 # drivers/macintosh/via-cuda.c 1.6 -> 1.7 # arch/m68k/ifpsp060/iskeleton.S 1.4 -> 1.5 # drivers/scsi/sun3_NCR5380.c 1.11 -> 1.15 # drivers/char/drm/drm_proc.h 1.7 -> 1.8 # include/linux/serialP.h 1.7 -> 1.8 # fs/xfs/xfs_dfrag.c 1.1 -> 1.2 # sound/oss/emu10k1/audio.c 1.13 -> 1.14 # net/ipv4/netfilter/ipt_mac.c 1.3 -> 1.4 # kernel/fork.c 1.114 -> 1.115 # drivers/ide/ppc/pmac.c 1.8 -> 1.9 # drivers/video/i810/i810_accel.c 1.2 -> 1.4 # sound/pci/ice1712/delta.c 1.7 -> 1.8 # drivers/block/ll_rw_blk.c 1.157 -> 1.159 # kernel/sys.c 1.41 -> 1.42 # fs/xfs/support/debug.c 1.10 -> 1.12 # drivers/net/Space.c 1.18 -> 1.19 # drivers/video/sstfb.h 1.5 -> 1.6 include/video/sstfb.h (moved) # drivers/video/hitfb.c 1.19 -> 1.20 # Makefile 1.398 -> 1.399 # drivers/net/wireless/airo.c 1.36 -> 1.37 # drivers/parport/parport_sunbpp.c 1.6 -> 1.7 # drivers/mtd/nftlmount.c 1.6 -> 1.7 # net/ipv4/netfilter/ipt_tcpmss.c 1.2 -> 1.3 # drivers/media/video/bttv-if.c 1.9 -> 1.10 # drivers/video/Makefile 1.70.1.8 -> 1.83 # fs/xfs/xfs_log_priv.h 1.3 -> 1.4 # include/linux/serial_core.h 1.20 -> 1.21 # include/net/tcp.h 1.32 -> 1.33 # arch/ppc/boot/simple/embed_config.c 1.6 -> 1.7 # include/linux/mman.h 1.2 -> 1.3 # include/asm-sparc64/timer.h 1.1 -> 1.2 # fs/dcache.c 1.41 -> 1.43 # net/sctp/endpointola.c 1.16 -> 1.18 # fs/attr.c 1.14 -> 1.15 # fs/xfs/xfs_macros.h 1.1 -> 1.2 # arch/arm/boot/compressed/Makefile 1.14 -> 1.15 # arch/i386/kernel/cpu/cpufreq/powernow-k6.c 1.13 -> 1.14 # net/ipv4/af_inet.c 1.40 -> 1.41 # net/ipv6/netfilter/ip6t_ah.c 1.2 -> 1.4 # sound/pci/rme9652/hammerfall_mem.c 1.12 -> 1.13 # Documentation/filesystems/sysfs.txt 1.9 -> 1.10 # fs/proc/proc_misc.c 1.68 -> 1.71 # sound/isa/cmi8330.c 1.12 -> 1.13 # drivers/acorn/scsi/scsi.h 1.4 -> 1.5 # net/sctp/sm_make_chunk.c 1.28 -> 1.32 # sound/oss/midi_syms.c 1.2 -> 1.3 # drivers/i2c/i2c-core.c 1.23 -> 1.24 # sound/pci/cs46xx/cs46xx_lib.h 1.7 -> 1.8 # arch/i386/Kconfig 1.48 -> 1.49 # drivers/block/floppy.c 1.69 -> 1.70 # drivers/cdrom/cdrom.c 1.36 -> 1.37 # include/asm-i386/uaccess.h 1.19 -> 1.20 # sound/core/rawmidi.c 1.22 -> 1.23 # drivers/ide/legacy/Makefile 1.5 -> 1.6 # drivers/net/e100/e100_config.h 1.5 -> 1.7 # drivers/media/video/saa7134/saa7134-i2c.c 1.5 -> 1.6 # sound/core/control.c 1.18 -> 1.19 # Documentation/sound/alsa/DocBook/alsa-driver-api.tmpl 1.2 -> 1.3 # drivers/message/i2o/i2o_pci.c 1.10 -> (deleted) # drivers/video/aty/mach64_gx.c 1.6 -> 1.7 # drivers/net/e100/e100_phy.h 1.5 -> 1.7 # drivers/media/video/saa7134/saa7134-video.c 1.4 -> 1.5 # fs/jbd/journal.c 1.28 -> 1.29 # sound/isa/opti9xx/opti92x-ad1848.c 1.10 -> 1.12 # drivers/media/dvb/dvb-core/dvb_demux.c 1.2 -> 1.3 # drivers/video/sis/300vtbl.h 1.2 -> 1.4 # fs/devfs/base.c 1.74 -> 1.78 # arch/i386/kernel/traps.c 1.47 -> 1.48 # drivers/ide/pci/cy82c693.c 1.12 -> 1.13 # net/ipv4/netfilter/ipt_multiport.c 1.3 -> 1.4 # fs/intermezzo/sysctl.c 1.7 -> 1.8 # drivers/char/drm/drm_memory.h 1.5 -> 1.6 # arch/arm/boot/compressed/head-netwinder.S 1.2 -> (deleted) # include/linux/i2c.h 1.15 -> 1.16 # arch/m68k/atari/ataints.c 1.9 -> 1.10 # sound/core/wrappers.c 1.5 -> 1.6 # sound/core/init.c 1.15 -> 1.16 # sound/oss/audio_syms.c 1.2 -> 1.3 # drivers/char/watchdog/machzwd.c 1.16 -> 1.17 # drivers/ide/legacy/qd65xx.c 1.4 -> 1.5 # drivers/ide/legacy/umc8672.c 1.5 -> 1.6 # drivers/video/skeletonfb.c 1.20.1.2 -> 1.22 # fs/xfs/xfs_btree.h 1.1 -> 1.2 # include/asm-alpha/linux_logo.h 1.2 -> (deleted) # include/asm-arm/linux_logo.h 1.3 -> (deleted) # drivers/ide/legacy/ali14xx.c 1.4 -> 1.5 # fs/partitions/sgi.c 1.5 -> 1.6 # drivers/char/console_macros.h 1.1 -> 1.2 # include/linux/ioport.h 1.8 -> 1.9 # net/sctp/transport.c 1.15 -> 1.16 # fs/xfs/xfs_vfsops.c 1.24 -> 1.25 # drivers/parport/parport_atari.c 1.4 -> 1.5 # sound/oss/emu10k1/timer.c 1.2 -> 1.3 # drivers/net/tulip/winbond-840.c 1.29 -> 1.30 # mm/swapfile.c 1.67 -> 1.69 # drivers/media/dvb/dvb-core/dvbdev.c 1.3 -> 1.4 # drivers/video/maxinefb.h 1.1 -> 1.2 include/video/maxinefb.h (moved) # drivers/video/controlfb.c 1.23 -> 1.24 # net/sctp/output.c 1.18 -> 1.21 # arch/ppc/kernel/traps.c 1.17 -> 1.18 # drivers/input/mouse/Makefile 1.5 -> 1.6 # drivers/ide/pci/piix.h 1.5 -> 1.6 # kernel/cpufreq.c 1.27 -> 1.28 # arch/parisc/kernel/entry.S 1.9 -> 1.10 # include/asm-mips/linux_logo_sgi.h 1.1 -> (deleted) # net/ipv6/netfilter/ip6t_frag.c 1.2 -> 1.4 # drivers/scsi/NCR53C9x.c 1.19 -> 1.20 # drivers/video/pm3fb.c 1.4.1.1 -> 1.7 # drivers/char/drm/drm_bufs.h 1.8 -> 1.9 # include/linux/i2o.h 1.9 -> 1.10 # drivers/block/nbd.c 1.51 -> 1.52 # fs/xfs/xfs_dir.c 1.5 -> 1.7 # drivers/scsi/mesh.h 1.4 -> 1.5 # include/asm-sparc64/linux_logo.h 1.3 -> (deleted) # drivers/scsi/3w-xxxx.h 1.18 -> 1.20 # drivers/video/console/Kconfig 1.16 -> 1.17 # sound/pci/ice1712/ews.c 1.7 -> 1.8 # drivers/net/e1000/e1000_osdep.h 1.10 -> 1.12 # drivers/char/drm/drm_ioctl.h 1.7 -> 1.8 # sound/isa/ad1816a/ad1816a.c 1.6 -> 1.7 # include/asm-arm/mach/dma.h 1.1 -> 1.2 # include/asm-m68k/elf.h 1.1 -> 1.2 # drivers/usb/core/message.c 1.22 -> 1.23 # net/ipv4/netfilter/ip_tables.c 1.11 -> 1.13 # drivers/media/video/w9966.c 1.8 -> 1.9 # include/linux/major.h 1.7 -> 1.8 # drivers/macintosh/mediabay.c 1.6 -> 1.7 # net/ipv6/netfilter/ip6t_limit.c 1.3 -> 1.4 # drivers/cdrom/optcd.c 1.25 -> 1.26 # arch/m68k/kernel/time.c 1.7 -> 1.8 # drivers/char/rio/rioboot.c 1.6 -> 1.7 # net/key/af_key.c 1.25 -> 1.26 # fs/xfs/xfs_types.h 1.5 -> 1.6 # include/asm-sh/elf.h 1.2 -> 1.3 # kernel/suspend.c 1.35 -> 1.37 # net/irda/irlan/irlan_eth.c 1.4 -> 1.5 # include/linux/fs.h 1.218 -> 1.222 # fs/intermezzo/dir.c 1.12 -> 1.13 # drivers/pcmcia/cs.c 1.16 -> 1.17 # drivers/usb/misc/atmsar.c 1.10 -> (deleted) # fs/xfs/xfs_alloc.c 1.8 -> 1.9 # drivers/video/sis/sis_main.h 1.7 -> 1.9 # drivers/char/watchdog/mixcomwd.c 1.13 -> 1.14 # include/sound/emu10k1.h 1.11 -> 1.12 # drivers/video/vga16fb.c 1.27 -> 1.30 # drivers/video/maxinefb.c 1.17 -> 1.18 # arch/m68k/math-emu/fp_arith.c 1.1 -> 1.2 # arch/i386/kernel/entry.S 1.59 -> 1.60 # drivers/pcmcia/cardbus.c 1.23 -> 1.24 # drivers/video/tdfxfb.c 1.37 -> 1.40 # arch/m68k/mm/sun3mmu.c 1.5 -> 1.6 # include/linux/linux_logo.h 1.2 -> 1.3 # drivers/usb/image/scanner.c 1.53 -> 1.54 # drivers/oprofile/buffer_sync.c 1.9 -> 1.10 # net/ipv6/netfilter/ip6t_rt.c 1.2 -> 1.4 # drivers/video/q40fb.c 1.21 -> 1.22 # include/net/sctp/sctp.h 1.22 -> 1.25 # drivers/char/mwave/mwavedd.c 1.6 -> 1.8 # net/ipv4/tcp.c 1.35 -> 1.36 # sound/core/misc.c 1.7 -> 1.8 # drivers/char/ip2/ip2.h 1.2 -> 1.3 # drivers/eisa/eisa-bus.c 1.4 -> 1.5 # drivers/video/cg6.c 1.1.1.3 -> 1.3 # net/ipv6/netfilter/ip6_queue.c 1.7 -> 1.8 # drivers/pci/pci.c 1.52 -> 1.53 # include/asm-sparc64/spitfire.h 1.8 -> 1.9 # drivers/video/sis/init.c 1.2 -> 1.4 # drivers/net/Makefile 1.56 -> 1.57 # fs/reiserfs/procfs.c 1.15 -> 1.16 # drivers/video/sis/oem300.h 1.2 -> 1.3 # drivers/md/md.c 1.156 -> 1.157 # arch/mips64/Kconfig 1.9.1.1 -> 1.11 # drivers/char/rio/rioinit.c 1.5 -> 1.6 # drivers/ide/ide.c 1.51 -> 1.54 # net/ipv4/netfilter/ipt_physdev.c 1.2 -> 1.3 # include/linux/ip.h 1.5 -> 1.6 # drivers/ide/legacy/dtc2278.c 1.4 -> 1.5 # drivers/scsi/advansys.c 1.27 -> 1.28 # arch/i386/kernel/reboot.c 1.6 -> 1.7 # drivers/i2c/busses/i2c-piix4.c 1.4 -> 1.7 # Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl 1.4.1.1 -> 1.7 # net/ipv6/icmp.c 1.18 -> 1.19 # include/net/sctp/ulpqueue.h 1.7.1.1 -> 1.9 # drivers/net/e100/e100.h 1.22 -> 1.27 # drivers/char/watchdog/shwdt.c 1.12 -> 1.13 # sound/usb/usbmixer.c 1.11 -> 1.12 # include/linux/fb.h 1.37 -> 1.46 # include/linux/backing-dev.h 1.4 -> 1.5 # drivers/char/rio/riocmd.c 1.7 -> 1.8 # include/asm-i386/timex.h 1.3 -> 1.4 # arch/parisc/kernel/Makefile 1.11 -> 1.12 # drivers/pcmcia/cistpl.c 1.8 -> 1.9 # include/sound/sndmagic.h 1.10 -> 1.11 # drivers/video/riva/rivafb.h 1.11 -> 1.12 # drivers/video/aty/Makefile 1.7 -> 1.9 # sound/oss/emu10k1/hwaccess.c 1.3 -> 1.4 # Documentation/sound/alsa/ControlNames.txt 1.1 -> 1.2 # net/sctp/outqueue.c 1.19.1.1 -> 1.23 # drivers/video/i810/i810_main.c 1.3 -> 1.5 # sound/oss/sequencer_syms.c 1.2 -> 1.3 # net/ipv4/tcp_ipv4.c 1.44 -> 1.47 # fs/intermezzo/vfs.c 1.17 -> 1.18 # arch/ppc/boot/openfirmware/Makefile 1.15 -> 1.16 # fs/char_dev.c 1.8 -> 1.10 # arch/i386/kernel/io_apic.c 1.55 -> 1.58 # fs/xfs/linux/xfs_iops.c 1.17 -> 1.20 # drivers/ide/ide-tape.c 1.17 -> 1.19 # fs/ext3/acl.c 1.6 -> 1.7 # drivers/net/e100/e100_config.c 1.10 -> 1.12 # sound/pci/rme9652/hdsp.c 1.14 -> 1.15 # sound/core/pcm_native.c 1.27 -> 1.29 # sound/pci/ice1712/ice1712.c 1.8 -> 1.9 # include/net/sctp/constants.h 1.9 -> 1.11 # fs/xfs/linux/xfs_vnode.c 1.10 -> 1.11 # net/ipv4/netfilter/ipt_REDIRECT.c 1.3 -> 1.4 # mm/filemap.c 1.182 -> 1.185 # drivers/char/ftape/lowlevel/ftape_syms.c 1.3 -> 1.4 # drivers/parport/parport_mfc3.c 1.6 -> 1.7 # drivers/char/drm/i810_dma.c 1.19 -> 1.20 # drivers/ide/ide-iops.c 1.8 -> 1.13 # arch/s390/kernel/traps.c 1.14 -> 1.15 # net/ipv4/netfilter/ipt_ULOG.c 1.6 -> 1.7 # drivers/usb/serial/whiteheat.c 1.34 -> 1.35 # fs/xfs/xfs_mount.c 1.18 -> 1.20 # drivers/scsi/mac53c94.h 1.3 -> 1.4 # sound/pci/Kconfig 1.4 -> 1.5 # sound/pci/emu10k1/emuproc.c 1.7 -> 1.8 # include/asm-parisc/ide.h 1.9 -> 1.10 # arch/m68k/ifpsp060/fskeleton.S 1.3 -> 1.4 # drivers/scsi/gdth.h 1.10 -> 1.11 # drivers/ide/pci/alim15x3.c 1.10 -> 1.11 # drivers/char/ftape/zftape/zftape-ctl.c 1.7 -> 1.8 # include/asm-m68k/rtc.h 1.5 -> 1.6 # drivers/ide/pci/siimage.c 1.10 -> 1.11 # drivers/net/macmace.c 1.7 -> 1.8 # sound/pci/ac97/ac97_codec.c 1.29.1.1 -> 1.33 # drivers/net/e100/e100_eeprom.c 1.9 -> 1.10 # drivers/net/e1000/e1000_main.c 1.47 -> 1.61 # include/sound/version.h 1.51 -> 1.53 # sound/oss/emu10k1/hwaccess.h 1.6 -> 1.7 # arch/i386/kernel/dmi_scan.c 1.30 -> 1.31 # net/sctp/sysctl.c 1.7 -> 1.8 # sound/drivers/mpu401/mpu401_uart.c 1.12 -> 1.14 # drivers/scsi/fastlane.c 1.9 -> 1.10 # drivers/scsi/amiga7xx.c 1.4 -> 1.5 # drivers/char/rio/riotty.c 1.6 -> 1.7 # init/do_mounts.c 1.47 -> 1.48 # fs/exec.c 1.72 -> 1.73 # drivers/ide/pci/hpt34x.c 1.11 -> 1.13 # include/linux/ide.h 1.39 -> 1.42 # arch/sparc64/kernel/head.S 1.14 -> 1.15 # include/sound/driver.h 1.4 -> 1.5 # drivers/ide/pci/opti621.c 1.10 -> 1.11 # sound/pci/ice1712/Makefile 1.4 -> 1.5 # drivers/video/platinumfb.c 1.17 -> 1.18 # include/asm-m68knommu/linux_logo.h 1.1 -> (deleted) # arch/sparc64/kernel/trampoline.S 1.11 -> 1.12 # fs/nfsd/vfs.c 1.57 -> 1.58 # include/asm-ppc64/linux_logo.h 1.2 -> (deleted) # fs/ext3/ioctl.c 1.7 -> 1.8 # arch/arm/kernel/bios32.c 1.21 -> 1.22 # mm/swap.c 1.48 -> 1.49 # arch/parisc/kernel/binfmt_elf32.c 1.3 -> 1.4 # drivers/net/at1700.c 1.16 -> 1.17 # include/asm-cris/elf.h 1.3 -> 1.4 # kernel/signal.c 1.77 -> 1.78 # drivers/usb/image/scanner.h 1.30 -> 1.31 # drivers/serial/uart00.c 1.13 -> 1.14 # drivers/char/rtc.c 1.23 -> 1.24 # sound/oss/awe_wave.c 1.10 -> 1.11 # drivers/net/irda/ali-ircc.c 1.13 -> 1.14 # drivers/input/keyboard/Makefile 1.5 -> 1.6 # sound/isa/dt019x.c 1.9 -> 1.11 # arch/i386/pci/common.c 1.36 -> 1.37 # net/netsyms.c 1.52 -> 1.53 # net/ipv4/netfilter/ipfwadm_core.c 1.11 -> 1.12 # fs/ufs/util.c 1.9 -> 1.10 # include/linux/pci_ids.h 1.85 -> 1.86 # drivers/ide/ide-disk.c 1.33 -> 1.35 # fs/intermezzo/cache.c 1.9 -> 1.10 # drivers/char/rio/rioctrl.c 1.8 -> 1.9 # sound/core/pcm_lib.c 1.16 -> 1.18 # sound/synth/emux/emux_seq.c 1.7 -> 1.8 # sound/pci/trident/trident_synth.c 1.4 -> 1.5 # fs/partitions/Makefile 1.10 -> 1.11 # drivers/macintosh/macserial.h 1.5 -> 1.6 # drivers/md/linear.c 1.25 -> 1.26 # sound/usb/usbquirks.h 1.11 -> 1.12 # sound/isa/gus/gus_pcm.c 1.7 -> 1.8 # sound/isa/es18xx.c 1.13 -> 1.14 # arch/arm/kernel/traps.c 1.23 -> 1.25 # arch/parisc/kernel/hardware.c 1.3 -> 1.4 # net/Makefile 1.20 -> 1.21 # drivers/char/watchdog/softdog.c 1.15 -> 1.16 # arch/mips/kernel/traps.c 1.6 -> 1.7 # mm/shmem.c 1.105 -> 1.106 # include/sound/hwdep.h 1.1 -> 1.2 # arch/x86_64/ia32/sys_ia32.c 1.23 -> 1.24 # arch/x86_64/kernel/irq.c 1.10 -> 1.11 # net/bridge/netfilter/ebt_ip.c 1.3 -> 1.4 # include/asm-mips/elf.h 1.3 -> 1.4 # drivers/char/serial167.c 1.15 -> 1.16 # arch/parisc/kernel/cache.c 1.3 -> 1.4 # drivers/char/drm/mga_warp.c 1.5 -> 1.6 # sound/isa/sb/sb8_main.c 1.4 -> 1.5 # drivers/net/e100/e100_test.c 1.7 -> 1.9 # sound/oss/nm256_audio.c 1.8 -> 1.9 # drivers/video/console/vgacon.c 1.12 -> 1.15 # fs/super.c 1.97 -> 1.99 # drivers/ide/ide-cd.c 1.39 -> 1.40 # drivers/usb/misc/atmsar.h 1.6 -> (deleted) # sound/pci/rme9652/rme9652.c 1.15 -> 1.16 # fs/fat/inode.c 1.60 -> 1.61 # include/asm-parisc/ptrace.h 1.2 -> 1.3 # fs/binfmt_elf.c 1.41 -> 1.42 # include/net/sctp/sm.h 1.19 -> 1.20 # drivers/scsi/blz2060.c 1.8 -> 1.9 # mm/memory.c 1.115 -> 1.117 # include/asm-arm/arch-pxa/time.h 1.3 -> 1.4 # net/sched/sch_atm.c 1.7 -> 1.8 # arch/ppc/8260_io/fcc_enet.c 1.7 -> 1.8 # drivers/usb/usb-skeleton.c 1.27 -> 1.28 # drivers/net/e1000/e1000_ethtool.c 1.19 -> 1.23 # fs/xfs/xfs_dir2_leaf.c 1.2 -> 1.4 # Documentation/fb/pvr2fb.txt 1.1 -> 1.2 # arch/ppc/kernel/pci.c 1.25 -> 1.26 # drivers/usb/core/hub.c 1.58 -> 1.59 # drivers/block/amiflop.c 1.36 -> 1.37 # drivers/video/modedb.c 1.8 -> 1.9 # sound/oss/emu10k1/passthrough.c 1.5 -> 1.6 # drivers/net/e100/e100_main.c 1.45 -> 1.59 # drivers/block/genhd.c 1.74 -> 1.78 # fs/xfs/xfs_attr_leaf.c 1.4 -> 1.5 # net/irda/irda_device.c 1.14 -> 1.15 # fs/readdir.c 1.18 -> 1.19 # fs/cifs/cifs_debug.c 1.6 -> 1.7 # drivers/char/watchdog/sc520_wdt.c 1.7 -> 1.8 # drivers/md/dm-stripe.c 1.4 -> 1.5 # include/linux/tcp.h 1.8 -> 1.9 # include/asm-m68k/unistd.h 1.7 -> 1.8 # fs/partitions/amiga.c 1.4 -> 1.5 # drivers/media/video/bttv-cards.c 1.15 -> 1.16 # arch/i386/kernel/smpboot.c 1.53 -> 1.54 # include/sound/pcm.h 1.12 -> 1.14 # drivers/scsi/gdth_proc.c 1.11 -> 1.12 # drivers/video/aty128fb.c 1.31 -> 1.35 drivers/video/aty/aty128fb.c (moved) # drivers/atm/idt77252.c 1.8 -> 1.9 # net/ipv4/netfilter/ipt_ecn.c 1.1 -> 1.2 # arch/um/drivers/ubd_kern.c 1.27 -> 1.28 # net/ipv4/ipmr.c 1.15 -> 1.17 # drivers/video/sgivwfb.c 1.24.1.1 -> 1.27 # drivers/media/video/saa7134/saa7134-oss.c 1.3 -> 1.4 # Documentation/sysrq.txt 1.7 -> 1.8 # drivers/video/imsttfb.c 1.23 -> 1.24 # drivers/video/sis/init301.h 1.2 -> 1.4 # fs/xfs/xfs_rename.c 1.6 -> 1.7 # fs/intermezzo/kml_setup.c 1.2 -> 1.3 # sound/isa/sb/es968.c 1.7 -> 1.9 # arch/ppc/platforms/tqm8260.h 1.1 -> 1.2 # drivers/i2c/busses/i2c-i801.c 1.3 -> 1.7 # drivers/ide/pci/sis5513.c 1.12 -> 1.14 # drivers/media/video/bttv-risc.c 1.4 -> 1.5 # fs/xfs/support/kmem.c 1.1 -> 1.2 # Documentation/fb/sa1100fb.txt 1.1 -> 1.2 # arch/sparc64/kernel/time.c 1.22 -> 1.35 # include/asm-arm/mach/pci.h 1.7 -> 1.8 # include/asm-alpha/elf.h 1.3 -> 1.4 # drivers/video/tridentfb.c 1.4 -> 1.6 # fs/xfs/xfs_bmap_btree.h 1.4 -> 1.5 # arch/ppc/syslib/m8260_setup.c 1.16 -> 1.17 # drivers/parport/share.c 1.10 -> 1.11 # drivers/ide/ide-dma.c 1.12 -> 1.13 # drivers/ide/Makefile 1.11 -> 1.12 # net/ipv4/xfrm_policy.c 1.17 -> 1.20 # net/core/dev.c 1.57 -> 1.59 # drivers/ide/legacy/pdc4030.c 1.6 -> 1.7 # drivers/i2c/busses/i2c-ali15x3.c 1.3 -> 1.6 # arch/ppc64/kernel/traps.c 1.13 -> 1.14 # drivers/video/pmag-ba-fb.h 1.1 -> 1.2 include/video/pmag-ba-fb.h (moved) # kernel/posix-timers.c 1.5 -> 1.7 # net/ipv4/netfilter/ipt_esp.c 1.4 -> 1.5 # net/ipv4/netfilter/ipt_TCPMSS.c 1.7 -> 1.8 # drivers/i2c/i2c-proc.c 1.17 -> 1.18 # drivers/scsi/atari_scsi.h 1.4 -> 1.5 # drivers/video/softcursor.c 1.28 -> 1.34 # arch/sparc/kernel/traps.c 1.3 -> 1.4 # include/asm-m68k/sun3-head.h 1.1 -> 1.2 # drivers/scsi/aha1542.c 1.22 -> 1.23 # fs/xfs/linux/xfs_iomap.c 1.5 -> 1.6 # drivers/acorn/scsi/acornscsi.c 1.24 -> 1.25 # sound/pci/emu10k1/emufx.c 1.16 -> 1.17 # drivers/char/serial_tx3912.c 1.8 -> 1.9 # include/asm-s390x/elf.h 1.4 -> 1.5 # Documentation/DocBook/kernel-hacking.tmpl 1.13 -> 1.14 # sound/isa/gus/gus_synth.c 1.5 -> 1.6 # fs/xfs/linux/xfs_file.c 1.6 -> 1.10 # drivers/video/hpfb.c 1.18 -> 1.19 # include/asm-parisc/kmap_types.h 1.1 -> 1.2 # net/ipv4/netfilter/ipt_MARK.c 1.2 -> 1.3 # scripts/Makefile 1.25.1.11 -> 1.34 # fs/ext3/dir.c 1.9 -> 1.10 # include/asm-sparc64/irq.h 1.12 -> 1.13 # include/asm-alpha/core_cia.h 1.6 -> 1.7 # mm/oom_kill.c 1.20 -> 1.21 # include/asm-parisc/assembly.h 1.4 -> 1.5 # include/sound/ac97_codec.h 1.15 -> 1.17 # fs/jffs/jffs_fm.c 1.7 -> 1.8 # arch/arm/Kconfig 1.12 -> 1.13 # include/asm-i386/pgtable-2level.h 1.7 -> 1.8 # drivers/ide/ide-proc.c 1.8 -> 1.9 # include/sound/timer.h 1.4 -> 1.5 # drivers/scsi/a2091.c 1.7 -> 1.8 # fs/xfs/xfs_bmap_btree.c 1.6 -> 1.7 # sound/oss/emu10k1/irqmgr.c 1.3 -> 1.4 # drivers/md/raid1.c 1.56 -> 1.57 # fs/ext2/dir.c 1.20 -> 1.21 # drivers/video/cfbimgblt.c 1.19.1.1 -> 1.24 # fs/xfs/xfs_log_recover.c 1.10 -> 1.14 # sound/isa/gus/interwave.c 1.10 -> 1.11 # drivers/input/serio/Kconfig 1.6 -> 1.7 # drivers/video/cfbfillrect.c 1.11 -> 1.12 # drivers/usb/misc/Makefile 1.12 -> 1.13 # arch/ppc/platforms/lopec_setup.c 1.16 -> 1.17 # drivers/md/dm-linear.c 1.3 -> 1.4 # arch/parisc/kernel/init_task.c 1.4 -> 1.5 # drivers/char/drm/drm_fops.h 1.7 -> 1.8 # fs/xfs/linux/xfs_iops.h 1.2 -> 1.3 # drivers/char/rio/rioroute.c 1.7 -> 1.8 # drivers/net/tg3.c 1.63 -> 1.64 # include/linux/list.h 1.24 -> 1.25 # net/ipv4/raw.c 1.28 -> 1.29 # drivers/pcmcia/tcic.c 1.16 -> 1.17 # net/ipv6/af_inet6.c 1.21 -> 1.22 # sound/pci/ice1712/ak4524.c 1.7 -> 1.8 # fs/lockd/lockd_syms.c 1.4 -> 1.5 # fs/ext3/xattr.c 1.11 -> 1.13 # fs/intermezzo/replicator.c 1.4 -> 1.5 # fs/Kconfig 1.20 -> 1.21 # net/ipv4/xfrm_user.c 1.12 -> 1.13 # drivers/ide/pci/hpt366.c 1.14 -> 1.16 # fs/xfs/xfs_ialloc.c 1.3 -> 1.4 # include/asm-x86_64/linux_logo.h 1.1 -> (deleted) # drivers/char/mwave/mwavedd.h 1.1 -> 1.2 # fs/buffer.c 1.189 -> 1.191 # fs/xfs/linux/xfs_behavior.h 1.1 -> 1.2 # arch/arm/mach-clps7500/core.c 1.2 -> 1.3 # drivers/usb/input/hid-core.c 1.51 -> 1.52 # drivers/ide/ide-probe.c 1.33 -> 1.35 # net/ipv4/esp.c 1.15 -> 1.18 # drivers/scsi/atari_NCR5380.c 1.10 -> 1.12 # fs/jffs/intrep.c 1.22 -> 1.23 # include/sound/trident.h 1.5 -> 1.6 # drivers/parport/init.c 1.5 -> 1.6 # fs/ext3/namei.c 1.36 -> 1.37 # drivers/net/sk98lin/skvpd.c 1.5 -> 1.6 # fs/xfs/pagebuf/page_buf.h 1.24 -> 1.25 # include/linux/skbuff.h 1.20 -> 1.21 # drivers/video/pmagb-b-fb.c 1.14 -> 1.15 # fs/xfs/xfs_attr.c 1.3 -> 1.4 # sound/oss/emu10k1/voicemgr.c 1.3 -> 1.4 # sound/oss/emu10k1/voicemgr.h 1.3 -> 1.4 # drivers/char/tty_io.c 1.65 -> 1.67 # arch/m68k/Kconfig 1.10 -> 1.11 # drivers/video/pmagb-b-fb.h 1.2 -> 1.3 include/video/pmagb-b-fb.h (moved) # net/ipv6/ndisc.c 1.24 -> 1.26 # sound/pci/maestro3.c 1.16 -> 1.17 # arch/parisc/kernel/sys32.h 1.3 -> 1.4 # arch/ppc/boot/Makefile 1.14 -> 1.15 # fs/reiserfs/journal.c 1.66 -> 1.67 # MAINTAINERS 1.127 -> 1.131 # sound/pci/intel8x0.c 1.26.1.1 -> 1.30 # net/sctp/ipv6.c 1.21.1.1 -> 1.25 # net/sctp/protocol.c 1.33 -> 1.37 # drivers/video/sis/310vtbl.h 1.2 -> 1.4 # net/ipv6/netfilter/ip6t_esp.c 1.2 -> 1.4 # drivers/ide/pci/sc1200.c 1.5 -> 1.6 # drivers/pcmcia/rsrc_mgr.c 1.9 -> 1.10 # net/core/dst.c 1.7 -> 1.8 # net/ipv4/netfilter/ipt_unclean.c 1.8 -> 1.9 # net/compat.c 1.1 -> 1.2 # include/linux/in6.h 1.3 -> 1.4 # drivers/char/drm/drm_scatter.h 1.9 -> 1.10 # fs/reiserfs/prints.c 1.20 -> 1.21 # net/core/datagram.c 1.7 -> 1.8 # drivers/video/sis/initdef.h 1.3 -> 1.4 # arch/m68k/amiga/chipram.c 1.2 -> 1.3 # drivers/char/raw.c 1.29 -> 1.31 # arch/arm/mach-sa1100/ssp.c 1.1 -> 1.2 # fs/intermezzo/ext_attr.c 1.6 -> 1.7 # drivers/video/neofb.c 1.25 -> 1.28 # net/ipv4/netfilter/ipt_MASQUERADE.c 1.6 -> 1.7 # drivers/message/i2o/i2o_proc.c 1.8 -> 1.9 # Documentation/sound/alsa/serial-u16550.txt 1.2 -> 1.3 # mm/mmap.c 1.74 -> 1.75 # sound/usb/usbaudio.h 1.13 -> 1.14 # drivers/video/i810/i810_main.h 1.2 -> 1.4 # include/asm-m68k/apollohw.h 1.1 -> 1.2 # fs/ext2/xattr.c 1.10 -> 1.11 # drivers/char/watchdog/acquirewdt.c 1.19 -> 1.20 # include/asm-m68k/io.h 1.6 -> 1.7 # fs/xfs/linux/xfs_globals.c 1.7 -> 1.8 # drivers/scsi/gdth.c 1.21 -> 1.22 # sound/core/timer.c 1.15 -> 1.16 # sound/drivers/opl3/opl3_seq.c 1.9 -> 1.10 # mm/highmem.c 1.40 -> 1.41 # net/unix/af_unix.c 1.37 -> 1.38 # drivers/message/i2o/i2o_core.c 1.17 -> 1.18 # drivers/video/sstfb.c 1.18.1.2 -> 1.24 # drivers/video/sis/325vtbl.h 1.2 -> (deleted) # net/ipv6/esp6.c 1.2 -> 1.4 # drivers/char/watchdog/wdt_pci.c 1.20 -> 1.21 # net/ipv4/netfilter/ipt_ah.c 1.4 -> 1.5 # drivers/char/drm/drm_dma.h 1.9 -> 1.10 # include/video/mach64.h 1.4 -> 1.6 # fs/intermezzo/file.c 1.9 -> 1.10 # sound/pci/trident/trident_main.c 1.14 -> 1.15 # fs/xfs/xfs_dir2_sf.c 1.2 -> 1.3 # sound/oss/emu10k1/cardwi.c 1.6 -> 1.7 # arch/mips64/kernel/traps.c 1.5 -> 1.6 # drivers/video/clgenfb.h 1.2 -> 1.3 include/video/cirrus.h (moved) # sound/isa/sb/sb8.c 1.7 -> 1.8 # drivers/video/aty/atyfb.h 1.10 -> 1.13 # fs/ext2/super.c 1.46 -> 1.47 # drivers/usb/host/ehci-hcd.c 1.45 -> 1.46 # include/sound/asound.h 1.12 -> 1.14 # arch/m68k/mm/memory.c 1.9 -> 1.10 # drivers/char/drm/drm_lock.h 1.5 -> 1.6 # drivers/scsi/mesh.c 1.6 -> 1.7 # net/sctp/sm_sideeffect.c 1.28 -> 1.33 # arch/ppc/platforms/pmac_setup.c 1.24 -> 1.25 # net/atm/pppoatm.c 1.4 -> 1.5 # fs/ext3/inode.c 1.63 -> 1.64 # arch/ppc/platforms/k2_setup.c 1.7 -> 1.8 # drivers/char/drm/sis_mm.c 1.3 -> 1.4 # net/ipv6/netfilter/ip6t_hl.c 1.1 -> 1.2 # arch/i386/kernel/timers/timer_tsc.c 1.13 -> 1.14 # fs/xfs/linux/xfs_fs_subr.h 1.1 -> 1.2 # drivers/video/sis/vstruct.h 1.2 -> 1.4 # drivers/scsi/wd33c93.c 1.10 -> 1.12 # arch/ppc/platforms/mcpn765_setup.c 1.8 -> 1.9 # sound/core/sound.c 1.20 -> 1.22 # drivers/scsi/blz1230.c 1.8 -> 1.9 # fs/affs/super.c 1.34 -> 1.35 # net/ipv6/ah6.c 1.2 -> 1.4 # net/ipv4/tcp_output.c 1.24 -> 1.25 # drivers/acpi/processor.c 1.35 -> 1.36 # sound/core/pcm_memory.c 1.9 -> 1.10 # sound/pci/trident/trident_memory.c 1.5 -> 1.6 # include/asm-i386/elf.h 1.5 -> 1.6 # drivers/char/ite_gpio.c 1.4 -> 1.5 # drivers/video/sis/sis_main.c 1.17 -> 1.20 # include/asm-ia64/elf.h 1.7 -> 1.8 # net/ipv4/netfilter/ipt_dscp.c 1.1 -> 1.2 # sound/core/seq/seq_ports.h 1.1 -> 1.2 # drivers/cdrom/cdu31a.c 1.33 -> 1.34 # drivers/char/watchdog/sbc60xxwdt.c 1.22 -> 1.23 # drivers/video/console/fbcon.c 1.68 -> 1.91 # include/video/vga.h 1.5 -> 1.7 # include/sound/uda1341.h 1.2 -> 1.3 # drivers/message/i2o/Makefile 1.7 -> 1.8 # sound/core/Makefile 1.23 -> 1.24 # drivers/video/aty/atyfb_base.c 1.50 -> 1.53 # include/linux/page-flags.h 1.36 -> 1.37 # drivers/scsi/sun3x_esp.c 1.9 -> 1.10 # arch/m68k/mac/baboon.c 1.4 -> 1.5 # drivers/video/sis/sisfb.h 1.1 -> (deleted) # drivers/scsi/gdth_proc.h 1.3 -> 1.4 # arch/arm/kernel/time.c 1.15 -> 1.16 # include/linux/ipv6.h 1.4 -> 1.5 # sound/pci/es1968.c 1.19 -> 1.20 # sound/core/seq/seq_ports.c 1.8 -> 1.9 # drivers/media/video/cpia.c 1.21 -> 1.22 # drivers/char/vt_ioctl.c 1.19 -> 1.22 # drivers/net/8390.h 1.7 -> 1.8 # arch/m68k/kernel/signal.c 1.11 -> 1.13 # sound/pci/sonicvibes.c 1.12 -> 1.13 # drivers/video/riva/fbdev.c 1.32.1.1 -> 1.40 # drivers/net/82596.c 1.12 -> 1.13 # drivers/net/e1000/e1000_param.c 1.16 -> 1.20 # drivers/video/tgafb.c 1.20 -> 1.22 # include/linux/sisfb.h 1.3 -> (deleted) # sound/oss/emu10k1/mixer.c 1.5 -> 1.6 # drivers/message/i2o/i2o_block.c 1.52 -> 1.53 # include/asm-sparc64/thread_info.h 1.9 -> 1.10 # arch/i386/kernel/cpu/cpufreq/longrun.c 1.12 -> 1.13 # include/asm-m68k/system.h 1.8 -> 1.9 # drivers/video/console/fbcon.h 1.22 -> 1.29 # Documentation/fb/vesafb.txt 1.1 -> 1.2 # arch/ppc64/kernel/prom.c 1.18.1.1 -> 1.21 # arch/sparc64/mm/ultra.S 1.22 -> 1.23 # fs/xfs/xfs_error.h 1.3 -> 1.5 # include/asm-x86_64/pgtable.h 1.15 -> 1.16 # net/ipv4/xfrm_state.c 1.11 -> 1.12 # net/core/skbuff.c 1.20 -> 1.21 # include/asm-parisc/bug.h 1.2 -> 1.3 # sound/usb/usbaudio.c 1.32 -> 1.34 # include/asm-ppc64/elf.h 1.8 -> 1.9 # include/asm-ppc/pci.h 1.14 -> 1.15 # net/core/sock.c 1.18 -> 1.19 # include/asm-parisc/elf.h 1.2 -> 1.4 # include/linux/devfs_fs_kernel.h 1.30 -> 1.32 # drivers/ide/pci/pdc202xx_new.c 1.13 -> 1.14 # arch/s390x/kernel/traps.c 1.12 -> 1.13 # include/asm-arm/arch-cl7500/io.h 1.4 -> 1.5 # drivers/scsi/a3000.c 1.6 -> 1.7 # drivers/parport/parport_amiga.c 1.4 -> 1.5 # fs/autofs4/inode.c 1.10 -> 1.11 # net/ipv4/netfilter/ipt_helper.c 1.2 -> 1.3 # arch/m68k/sun3/sun3dvma.c 1.3 -> 1.4 # include/asm-i386/pgtable.h 1.30 -> 1.32 # net/ipv4/ip_gre.c 1.18 -> 1.20 # fs/autofs/inode.c 1.13 -> 1.14 # fs/xfs/xfs_btree.c 1.2 -> 1.3 # arch/ppc/platforms/est8260.h 1.4 -> 1.5 # sound/oss/emu10k1/cardwo.h 1.3 -> 1.4 # include/asm-v850/elf.h 1.3 -> 1.4 # drivers/scsi/sym53c416.h 1.5 -> 1.6 # net/ipv4/netfilter/ipt_length.c 1.1 -> 1.2 # arch/m68k/atari/stram.c 1.22 -> 1.23 # net/ipv6/Makefile 1.10 -> 1.11 # drivers/ide/pci/slc90e66.c 1.10 -> 1.11 # sound/oss/i810_audio.c 1.32 -> 1.33 # drivers/pcmcia/ds.c 1.16 -> 1.19 # include/asm-m68k/linux_logo.h 1.3 -> (deleted) # arch/arm/kernel/ecard.c 1.21 -> 1.22 # sound/core/seq/seq_timer.c 1.9 -> 1.10 # drivers/video/riva/nv_driver.c 1.1 -> 1.2 # fs/xfs/linux/xfs_ioctl.c 1.9 -> 1.11 # drivers/i2c/i2c-algo-pcf.c 1.9 -> 1.10 # fs/xfs/xfs_da_btree.c 1.4 -> 1.5 # sound/core/pcm_misc.c 1.7 -> 1.8 # mm/slab.c 1.69 -> 1.71 # net/ipv4/netfilter/arp_tables.c 1.3 -> 1.5 # include/linux/module.h 1.52 -> 1.53 # include/sound/pcm_sgbuf.h 1.6 -> 1.7 # fs/nfs/inode.c 1.72 -> 1.73 # include/net/addrconf.h 1.6 -> 1.7 # fs/xfs/xfsidbg.c 1.19 -> 1.20 # drivers/message/i2o/i2o_scsi.c 1.17 -> 1.18 # drivers/scsi/cyberstorm.c 1.8 -> 1.9 # include/asm-m68knommu/elf.h 1.2 -> 1.3 # kernel/sched.c 1.172 -> 1.173 # drivers/scsi/mac_NCR5380.c 1.7 -> 1.8 # sound/drivers/mtpav.c 1.14.1.1 -> 1.16 # sound/isa/sb/sb16.c 1.12 -> 1.13 # drivers/video/console/newport_con.c 1.9 -> 1.10 # drivers/video/hgafb.c 1.22 -> 1.24 # net/8021q/vlan.c 1.10 -> 1.11 # drivers/char/drm/drm_drawable.h 1.4 -> 1.5 # net/ipv6/netfilter/ip6t_owner.c 1.2 -> 1.3 # drivers/char/watchdog/wdt977.c 1.14 -> 1.15 # drivers/usb/host/ehci-dbg.c 1.18 -> 1.19 # drivers/ide/legacy/ht6560b.c 1.4 -> 1.5 # Documentation/fb/matroxfb.txt 1.4 -> 1.5 # include/asm-i386/pgtable-3level.h 1.11 -> 1.12 # drivers/ide/pci/aec62xx.c 1.11 -> 1.12 # include/linux/jbd.h 1.16 -> 1.17 # include/asm-um/archparam-i386.h 1.2 -> 1.3 # include/asm-x86_64/elf.h 1.4 -> 1.5 # drivers/char/drm/drm_stub.h 1.6 -> 1.7 # sound/oss/emu10k1/cardwo.c 1.7 -> 1.8 # include/asm-m68k/amigahw.h 1.2 -> 1.3 # Documentation/networking/e1000.txt 1.5 -> 1.7 # drivers/ide/ide-io.c 1.4 -> 1.5 # net/ipv6/netfilter/ip6t_hbh.c 1.2 -> 1.4 # fs/exportfs/expfs.c 1.10 -> 1.11 # drivers/fc4/fc_syms.c 1.2 -> 1.3 # arch/m68k/apollo/dma.c 1.1 -> 1.2 # drivers/i2c/busses/i2c-amd8111.c 1.4 -> 1.6 # drivers/scsi/cyberstormII.c 1.8 -> 1.9 # arch/sparc64/kernel/sparc64_ksyms.c 1.40 -> 1.41 # sound/oss/Kconfig 1.5 -> 1.6 # drivers/input/mouse/Kconfig 1.4 -> 1.5 # net/ipv4/netfilter/ipt_REJECT.c 1.11 -> 1.12 # drivers/ide/ide-geometry.c 1.5 -> 1.6 # drivers/char/drm/drm_lists.h 1.5 -> 1.6 # include/net/xfrm.h 1.16 -> 1.18 # kernel/timer.c 1.43 -> 1.48 # sound/pci/via82xx.c 1.26 -> 1.28 # drivers/video/dnfb.c 1.20 -> 1.22 # drivers/video/sis/init.h 1.2 -> 1.4 # drivers/net/Makefile.lib 1.5 -> 1.6 # sound/core/seq/seq_midi.c 1.8 -> 1.10 # sound/pci/cs46xx/dsp_spos.c 1.12 -> 1.13 # arch/m68k/mac/macints.c 1.8 -> 1.9 # drivers/video/fbcmap.c 1.7 -> 1.8 # drivers/macintosh/mac_hid.c 1.8 -> 1.9 # drivers/net/e100/e100_vendor.h 1.4 -> (deleted) # drivers/char/ipmi/ipmi_devintf.c 1.1 -> 1.2 # drivers/net/pcmcia/pcnet_cs.c 1.14 -> 1.15 # net/sctp/bind_addr.c 1.12 -> 1.13 # include/asm-parisc/posix_types.h 1.3 -> 1.4 # include/linux/parport_pc.h 1.5 -> 1.6 # drivers/i2c/busses/i2c-amd756.c 1.4 -> 1.5 # drivers/char/vt.c 1.29.1.6 -> 1.37 # arch/ppc/platforms/menf1_setup.c 1.7 -> 1.8 # arch/m68k/kernel/m68k_ksyms.c 1.9 -> 1.10 # fs/intermezzo/dcache.c 1.8 -> 1.9 # drivers/video/pm3fb.h 1.3 -> 1.4 include/video/pm3fb.h (moved) # drivers/i2c/busses/Kconfig 1.7 -> 1.8 # drivers/net/Kconfig 1.19 -> 1.21 # drivers/char/drm/drm_init.h 1.4 -> 1.5 # drivers/net/e1000/e1000_hw.h 1.10 -> 1.13 # drivers/pci/setup-res.c 1.15 -> 1.16 # drivers/video/amifb.c 1.21 -> 1.24 # sound/core/oss/pcm_oss.c 1.20 -> 1.21 # net/ipv4/arp.c 1.18 -> 1.19 # include/sound/mpu401.h 1.6 -> 1.7 # include/linux/vt_kern.h 1.8 -> 1.9 # sound/pci/ice1712/ews.h 1.1 -> 1.2 # arch/parisc/kernel/sys_parisc.c 1.7 -> 1.8 # arch/ppc/platforms/prep_setup.c 1.35 -> 1.36 # fs/intermezzo/kml_reint.c 1.7 -> 1.8 # mm/nommu.c 1.1 -> 1.2 # Documentation/networking/e100.txt 1.2 -> 1.3 # arch/m68k/apollo/config.c 1.7 -> 1.8 # net/ipv4/netfilter/ipt_LOG.c 1.5 -> 1.6 # net/ipv4/ah.c 1.13 -> 1.15 # sound/oss/maestro.c 1.23 -> 1.24 # drivers/parport/parport_gsc.c 1.8 -> 1.9 # arch/m68k/q40/q40ints.c 1.7 -> 1.10 # drivers/video/clgenfb.c 1.20 -> 1.21 drivers/video/cirrusfb.c (moved) # drivers/video/fbmon.c 1.5 -> 1.7 # net/ipv6/netfilter/ip6_tables.c 1.14 -> 1.16 # fs/xfs/xfs_dir_leaf.c 1.5 -> 1.6 # fs/partitions/Kconfig 1.1 -> 1.2 # include/asm-i386/linux_logo.h 1.2 -> (deleted) # drivers/pcmcia/i82365.c 1.24 -> 1.25 # sound/pci/emu10k1/memory.c 1.7 -> 1.8 # sound/usb/usbmidi.c 1.21 -> 1.22 # include/asm-arm/mach/arch.h 1.6 -> 1.7 # arch/ppc/kernel/Makefile 1.34 -> 1.35 # drivers/video/cfbcopyarea.c 1.15.1.1 -> 1.19 # fs/proc/inode.c 1.20 -> 1.21 # drivers/char/drm/drm_auth.h 1.5 -> 1.6 # drivers/char/drm/ati_pcigart.h 1.8 -> 1.9 # drivers/char/drm/sis_ds.c 1.4 -> 1.5 # fs/ext3/super.c 1.53 -> 1.56 # drivers/media/radio/miropcm20-rds-core.c 1.6 -> 1.7 # fs/xfs/linux/xfs_aops.c 1.24 -> 1.27 # drivers/media/video/cpia.h 1.9 -> 1.10 # arch/ppc/boot/prep/Makefile 1.15 -> 1.16 # net/ipv6/netfilter/ip6t_mac.c 1.4 -> 1.5 # arch/parisc/Makefile 1.18 -> 1.19 # drivers/macintosh/via-pmu.c 1.16 -> 1.18 # include/asm-ppc/ide.h 1.18 -> 1.19 # sound/drivers/dummy.c 1.13 -> 1.14 # fs/partitions/sun.c 1.6 -> 1.7 # include/asm-arm/elf.h 1.3 -> 1.4 # include/asm-s390/elf.h 1.3 -> 1.4 # arch/i386/kernel/cpu/cpufreq/p4-clockmod.c 1.14 -> 1.15 # net/ipv4/netfilter/ipt_conntrack.c 1.2 -> 1.3 # drivers/message/i2o/i2o_config.c 1.14 -> 1.15 # arch/ppc/kernel/ppc_ksyms.c 1.36 -> 1.37 # net/8021q/vlan_dev.c 1.7 -> 1.8 # fs/partitions/check.c 1.96 -> 1.98 # drivers/char/watchdog/ib700wdt.c 1.12 -> 1.13 # drivers/char/drm/drm_os_linux.h 1.6 -> 1.7 # fs/xfs/linux/xfs_super.c 1.28 -> 1.30 # drivers/video/i810/i810.h 1.2 -> 1.4 # drivers/char/mwave/smapi.c 1.1 -> 1.2 # drivers/scsi/gdth_ioctl.h 1.3 -> 1.4 # sound/pci/cs46xx/dsp_spos_scb_lib.c 1.14 -> 1.15 # drivers/char/genrtc.c 1.6 -> 1.7 # sound/pci/ac97/ac97_patch.c 1.8 -> 1.9 # drivers/scsi/gvp11.c 1.7 -> 1.8 # drivers/char/drm/gamma_dma.c 1.7 -> 1.8 # include/net/dst.h 1.11 -> 1.12 # net/ipv6/sit.c 1.19 -> 1.21 # drivers/ide/pci/cmd640.c 1.5 -> 1.6 # fs/xfs/xfs_bmap.c 1.6 -> 1.8 # mm/rmap.c 1.20 -> 1.21 # sound/oss/mpu401.c 1.9 -> 1.10 # sound/oss/emu10k1/cardwi.h 1.3 -> 1.4 # fs/intermezzo/methods.c 1.7 -> 1.8 # arch/sparc64/kernel/irq.c 1.24 -> 1.26 # fs/intermezzo/kml_decode.c 1.2 -> 1.3 # drivers/media/dvb/dvb-core/Kconfig 1.1 -> 1.2 # sound/core/ioctl32/hwdep32.c 1.4 -> 1.6 # net/ipv6/addrconf.c 1.26 -> 1.28 # drivers/scsi/3w-xxxx.c 1.24 -> 1.26 # arch/m68k/mac/iop.c 1.5 -> 1.6 # include/linux/parport.h 1.10 -> 1.11 # net/ipv4/netfilter/ipt_owner.c 1.4 -> 1.5 # fs/locks.c 1.39 -> 1.40 # net/sctp/ulpqueue.c 1.12.2.2 -> 1.17 # drivers/char/watchdog/indydog.c 1.4 -> 1.5 # sound/core/pcm_sgbuf.c 1.10 -> 1.11 # drivers/net/ppp_generic.c 1.22 -> 1.23 # drivers/media/video/saa7134/saa7134-vbi.c 1.3 -> 1.4 # fs/xfs/xfs_error.c 1.4 -> 1.7 # include/linux/netdevice.h 1.28 -> 1.31 # sound/isa/azt2320.c 1.7 -> 1.8 # drivers/net/e100/e100_ucode.h 1.3 -> 1.4 # drivers/char/rio/riotable.c 1.8 -> 1.9 # include/asm-s390x/bitops.h 1.7 -> 1.8 # drivers/video/aty/mach64_cursor.c 1.8 -> 1.9 # drivers/char/Makefile 1.56 -> 1.57 # include/asm-ppc64/pgtable.h 1.17 -> 1.18 # arch/ppc/platforms/pplus_setup.c 1.12 -> 1.13 # drivers/input/keyboard/Kconfig 1.4 -> 1.5 # drivers/video/pmag-ba-fb.c 1.15 -> 1.16 # drivers/pnp/pnpbios/proc.c 1.6 -> 1.7 # net/ipv4/netfilter/ipt_DSCP.c 1.1 -> 1.2 # include/linux/netfilter_ipv6/ip6_tables.h 1.3 -> 1.4 # net/ipv4/netfilter/ipt_tos.c 1.2 -> 1.3 # drivers/char/sh-sci.c 1.13 -> 1.14 # sound/core/info.c 1.22 -> 1.23 # arch/ia64/kernel/traps.c 1.26 -> 1.27 # include/sound/seq_kernel.h 1.4 -> 1.5 # fs/xfs/linux/xfs_behavior.c 1.1 -> 1.2 # drivers/ide/ide-lib.c 1.7 -> 1.8 # include/asm-parisc/signal.h 1.2 -> 1.3 # sound/oss/emu10k1/audio.h 1.2 -> 1.3 # drivers/block/cciss.c 1.76 -> 1.77 # include/asm-parisc/cacheflush.h 1.2 -> 1.3 # fs/xfs/xfs_buf.h 1.9 -> 1.10 # include/net/if_inet6.h 1.2 -> 1.3 # drivers/video/radeonfb.c 1.19 -> 1.20 # sound/pci/ac97/ac97_id.h 1.5 -> 1.6 # sound/oss/emu10k1/recmgr.h 1.2 -> 1.3 # drivers/macintosh/macserial.c 1.13 -> 1.14 # drivers/parport/parport_pc.c 1.35 -> 1.36 # fs/xfs/xfs_inode.c 1.13 -> 1.15 # fs/xfs/xfs_iget.c 1.8 -> 1.9 # net/sctp/tsnmap.c 1.7 -> 1.8 # sound/pci/emu10k1/emu10k1_main.c 1.11 -> 1.12 # drivers/net/e1000/e1000_hw.c 1.12 -> 1.16 # sound/oss/emu10k1/main.c 1.12 -> 1.13 # drivers/pci/setup-bus.c 1.16 -> 1.17 # net/ipv6/netfilter/ip6t_length.c 1.1 -> 1.2 # Documentation/fb/tgafb.txt 1.1 -> 1.2 # drivers/ide/pci/pdc202xx_old.c 1.12 -> 1.13 # arch/parisc/kernel/signal.c 1.8 -> 1.9 # sound/isa/sb/sb16_csp.c 1.6 -> 1.7 # sound/oss/emu10k1/efxmgr.h 1.4 -> 1.5 # net/ipv4/igmp.c 1.15 -> 1.16 # arch/sparc64/kernel/traps.c 1.22 -> 1.24 # net/ipv4/ip_output.c 1.27 -> 1.29 # net/ipv4/netfilter/ipt_ECN.c 1.3 -> 1.4 # drivers/usb/net/pegasus.c 1.41 -> 1.42 # arch/ppc/syslib/prom_init.c 1.5 -> 1.6 # fs/xfs/support/uuid.h 1.3 -> 1.4 # include/asm-arm/cache.h 1.3 -> 1.4 # drivers/scsi/wd7000.c 1.19 -> 1.20 # include/linux/adb.h 1.1 -> 1.2 # fs/inode.c 1.85 -> 1.89 # include/asm-i386/hw_irq.h 1.20 -> 1.21 # include/net/sctp/command.h 1.11 -> 1.12 # include/asm-ia64/ia32.h 1.17 -> 1.18 # fs/intermezzo/super.c 1.12 -> 1.13 # net/ipv4/route.c 1.42 -> 1.43 # arch/parisc/kernel/process.c 1.8 -> 1.9 # sound/oss/gus_midi.c 1.4 -> 1.5 # include/net/sctp/structs.h 1.38.1.1 -> 1.44 # include/linux/thread_info.h 1.4 -> 1.5 # net/ipv6/netfilter/ip6t_multiport.c 1.2 -> 1.3 # include/asm-mips/linux_logo_dec.h 1.1 -> (deleted) # include/sound/core.h 1.21 -> 1.22 # fs/xfs/support/time.h 1.5 -> 1.6 # arch/parisc/kernel/syscall.S 1.8 -> 1.9 # drivers/net/apne.c 1.6 -> 1.7 # arch/m68k/amiga/amisound.c 1.5 -> 1.6 # net/ipv4/netfilter/ipt_MIRROR.c 1.4 -> 1.5 # drivers/video/pm2fb.h 1.1 -> (deleted) # drivers/ide/pci/amd74xx.c 1.15 -> 1.16 # arch/m68k/kernel/head.S 1.12 -> 1.13 # arch/s390x/kernel/binfmt_elf32.c 1.7 -> 1.8 # include/asm-sh/linux_logo.h 1.3 -> (deleted) # drivers/char/amiserial.c 1.13 -> 1.15 # arch/ppc/platforms/sandpoint_setup.c 1.10 -> 1.11 # net/ipv4/netfilter/ipt_ttl.c 1.1 -> 1.2 # include/asm-mips/linux_logo.h 1.3 -> (deleted) # drivers/usb/misc/speedtouch.c 1.68 -> 1.70 drivers/usb/misc/speedtch.c (moved) # net/ipv4/netfilter/ipt_state.c 1.3 -> 1.4 # drivers/char/drm/drm_vm.h 1.21 -> 1.22 # sound/core/pcm.c 1.12 -> 1.13 # fs/xfs/linux/xfs_vnode.h 1.13 -> 1.14 # drivers/scsi/atari_scsi.c 1.6 -> 1.8 # sound/oss/emu10k1/midi.c 1.9 -> 1.10 # drivers/char/nwflash.c 1.12 -> 1.13 # include/asm-m68k/page.h 1.7 -> 1.9 # fs/xfs/xfs_log.c 1.10 -> 1.11 # drivers/macintosh/adb.c 1.16 -> 1.17 # arch/ppc/platforms/Makefile 1.13 -> 1.15 # kernel/ptrace.c 1.27 -> 1.28 # drivers/video/pm2fb.c 1.16 -> 1.17 # net/ipv6/netfilter/ip6t_ipv6header.c 1.2 -> 1.4 # sound/core/isadma.c 1.7 -> 1.8 # arch/m68k/kernel/traps.c 1.10 -> 1.11 # arch/m68k/kernel/process.c 1.13 -> 1.14 # fs/befs/debug.c 1.1 -> 1.2 # drivers/char/mwave/mwavepub.h 1.1 -> 1.2 # fs/xfs/xfs_vnodeops.c 1.19 -> 1.22 # sound/pci/ice1712/envy24ht.h 1.1 -> 1.2 # drivers/video/sis/sis_accel.c 1.2 -> 1.5 # net/ipv4/ipip.c 1.21 -> 1.23 # arch/parisc/kernel/traps.c 1.7 -> 1.8 # sound/oss/emu10k1/recmgr.c 1.3 -> 1.4 # Documentation/kernel-parameters.txt 1.16 -> 1.17 # drivers/scsi/53c7xx.c 1.14 -> 1.16 # net/ipv4/netfilter/ip_queue.c 1.10 -> 1.11 # arch/parisc/kernel/module.c 1.2 -> 1.3 # drivers/scsi/sun3_scsi_vme.c 1.3 -> 1.4 # drivers/pcmcia/bulkmem.c 1.6 -> 1.7 # net/ipv6/netfilter/ip6t_mark.c 1.3 -> 1.4 # include/asm-parisc/compat.h 1.3 -> 1.4 # drivers/char/rio/rioparam.c 1.4 -> 1.5 # drivers/video/ffb.c 1.1.1.3 -> 1.3 # fs/xfs/linux/xfs_sysctl.c 1.5 -> 1.7 # net/sctp/socket.c 1.41 -> 1.46 # sound/isa/sgalaxy.c 1.10 -> 1.11 # net/ipv4/netfilter/ipt_mark.c 1.2 -> 1.3 # (new) -> 1.2 scripts/pnmtologo.c # (new) -> 1.1 include/linux/upd4990a.h # (new) -> 1.1 arch/i386/mach-pc9800/setup.c # (new) -> 1.1 drivers/input/serio/98kbd-io.c # (new) -> 1.1 net/ipv6/anycast.c # (new) -> 1.1 drivers/video/c2p.h # (new) -> 1.1 include/sound/memalloc.h # (new) -> 1.1 arch/ppc/platforms/est8260_setup.c # (new) -> 1.1 arch/i386/boot98/bootsect.S # (new) -> 1.1 drivers/net/ne2k_cbus.h # (new) -> 1.1 arch/i386/boot98/setup.S # (new) -> 1.1 fs/partitions/nec98.c # (new) -> 1.1 include/asm-i386/mach-pc9800/setup_arch_post.h # (new) -> 1.2 drivers/video/logo/logo_dec_clut224.ppm # (new) -> 1.1 include/asm-i386/pc9800_sca.h # (new) -> 1.1 arch/i386/boot98/compressed/misc.c # (new) -> 1.2 drivers/video/logo/logo_linux_mono.pbm # (new) -> 1.2 drivers/video/logo/logo_sun_clut224.ppm # (new) -> 1.1 drivers/net/ne2k_cbus.c # (new) -> 1.1 drivers/char/upd4990a.c # (new) -> 1.2 drivers/video/logo/logo_parisc_clut224.ppm # (new) -> 1.1 drivers/char/lp_old98.c # (new) -> 1.1 arch/ppc/platforms/tqm8260_setup.c # (new) -> 1.1 arch/ppc/platforms/mpc82xx.h # (new) -> 1.1 drivers/video/logo/clut_vga16.ppm # (new) -> 1.1 drivers/input/keyboard/98kbd.c # (new) -> 1.1 include/asm-i386/mach-default/mach_reboot.h # (new) -> 1.1 sound/isa/cs423x/pc98.c # (new) -> 1.1 arch/i386/boot98/compressed/Makefile # (new) -> 1.1 sound/pci/cs46xx/imgs/cwcdma.h # (new) -> 1.1 include/video/sisfb.h # (new) -> 1.2 drivers/video/logo/logo_linux_clut224.ppm # (new) -> 1.1 include/asm-i386/upd4990a.h # (new) -> 1.3 drivers/video/sis/sis_accel.h # (new) -> 1.2 drivers/video/logo/Kconfig # (new) -> 1.1 arch/i386/boot98/compressed/vmlinux.scr # (new) -> 1.1 sound/pci/ice1712/ice1724.c # (new) -> 1.2 drivers/video/aty/xlinit.c # (new) -> 1.1 arch/i386/boot98/Makefile # (new) -> 1.1 include/asm-arm/hardware/ssp.h # (new) -> 1.1 include/asm-i386/mach-pc9800/setup_arch_pre.h # (new) -> 1.2 drivers/video/logo/logo_linux_vga16.ppm # (new) -> 1.2 drivers/ide/legacy/pc9800.c # (new) -> 1.1 drivers/i2c/busses/i2c-isa.c # (new) -> 1.2 drivers/video/logo/logo_sgi_clut224.ppm # (new) -> 1.1 drivers/video/logo/logo.c # (new) -> 1.1 include/asm-i386/mach-default/pci-functions.h # (new) -> 1.1 sound/pci/ice1712/revo.c # (new) -> 1.1 arch/i386/boot98/install.sh # (new) -> 1.1 sound/pci/cs46xx/imgs/cwcdma.asp # (new) -> 1.1 sound/isa/cs423x/pc9801_118_magic.h # (new) -> 1.1 sound/pci/ice1712/revo.h # (new) -> 1.1 drivers/serial/serial98.c # (new) -> 1.1 drivers/video/sis/sis.h # (new) -> 1.1 sound/core/sgbuf.c # (new) -> 1.1 arch/i386/boot98/tools/build.c # (new) -> 1.2 drivers/video/logo/logo_superh_clut224.ppm # (new) -> 1.1 drivers/ide/legacy/hd98.c # (new) -> 1.1 drivers/video/logo/Makefile # (new) -> 1.1 sound/isa/cs423x/sound_pc9800.h # (new) -> 1.2 drivers/video/logo/logo_mac_clut224.ppm # (new) -> 1.1 arch/i386/boot98/video.S # (new) -> 1.1 arch/i386/mach-pc9800/Makefile # (new) -> 1.1 arch/i386/boot98/compressed/head.S # (new) -> 1.1 sound/core/memory_wrapper.c # (new) -> 1.1 include/asm-i386/mach-pc9800/mach_reboot.h # (new) -> 1.1 drivers/input/mouse/98busmouse.c # (new) -> 1.1 arch/i386/mach-pc9800/topology.c # (new) -> 1.2 drivers/video/logo/logo_superh_mono.pbm # (new) -> 1.1 include/asm-i386/mach-pc9800/pci-functions.h # (new) -> 1.1 sound/core/memalloc.c # (new) -> 1.1 drivers/video/c2p.c # (new) -> 1.2 drivers/video/logo/logo_superh_vga16.ppm # (new) -> 1.1 drivers/ide/ide-default.c # (new) -> 1.1 net/nonet.c # (new) -> 1.1 fs/partitions/nec98.h # # The following is the BitKeeper ChangeSet Log # -------------------------------------------- # 03/03/17 torvalds@penguin.transmeta.com 1.889.341.7 # Linux 2.5.65 # -------------------------------------------- # 03/03/17 nathans@sgi.com 1.889.342.30 # [XFS] Implement support for unwritten extents in XFS. # # SGI Modid: 2.5.x-xfs:slinx:141508a # -------------------------------------------- # 03/03/17 lord@sgi.com 1.889.342.31 # [XFS] remove some unbounded loops from the unwritten and unmapped page # processing code. As files get larger, these code paths have the # potential to hog the cpu for long periods of time. Just cap the # unmapped page case, and the unwritten one is supposed to be # stopping at the end of the extent anyway. # # SGI Modid: 2.5.x-xfs:slinx:141609a # -------------------------------------------- # 03/03/17 hch@sgi.com 1.889.342.32 # [XFS] time_after takes an unsigned long # # SGI Modid: 2.5.x-xfs:slinx:141237a # -------------------------------------------- # 03/03/17 roehrich@sgi.com 1.889.342.33 # [XFS] linvfs_file_mmap was updating the linux inode's atime twice. # # SGI Modid: 2.5.x-xfs:slinx:141360a # -------------------------------------------- # 03/03/17 sandeen@sgi.com 1.889.342.34 # [XFS] Bump the reporting threshold on calls to XFS_ERROR_REPORT # which are most likely due to a simple user error. # # SGI Modid: 2.5.x-xfs:slinx:141751a # -------------------------------------------- # 03/03/17 nathans@sgi.com 1.889.342.35 # [XFS] Find more appropriate homes for uuid_t, timespec_t and xfs_dirent_t defs. # # SGI Modid: 2.5.x-xfs:slinx:141837a # -------------------------------------------- # 03/03/17 nathans@sgi.com 1.889.342.36 # [XFS] Remove unneeded initialisations to zero, formatting cleanups, remove # a no-longer-correct-comment, fix up symlink error path code, several # minor changes to help keep this code more in sync with 2.4. # # SGI Modid: 2.5.x-xfs:slinx:141838a # -------------------------------------------- # 03/03/17 davem@nuts.ninka.net 1.889.343.1 # Merge nuts.ninka.net:/home/davem/src/BK/sparcwork-2.5 # into nuts.ninka.net:/home/davem/src/BK/sparc-2.5 # -------------------------------------------- # 03/03/17 hch@sgi.com 1.889.342.37 # [XFS] Minor header shuffling, removing a bunch of already-included files and # allowing 2.4/2.5 to be slightly more in sync. # # SGI Modid: 2.5.x-xfs:slinx:141841a # -------------------------------------------- # 03/03/17 nathans@sgi.com 1.889.342.38 # [XFS] Fix permission checks for some ioctls. Its now possible for ordinary # users to use the preallocation calls if unwritten extents are enabled, # and a couple of places where we were allowing operations if unwritten # extents are enabled, but shouldn't have been, have been closed up. # # SGI Modid: 2.5.x-xfs:slinx:141842a # -------------------------------------------- # 03/03/17 hch@hera.kernel.org 1.889.341.8 # Merge # -------------------------------------------- # 03/03/17 jsimmons@kozmo.(none) 1.960 # [FBCON]More optimizations. Removed moving struct display around. # -------------------------------------------- # 03/03/17 davem@nuts.ninka.net 1.889.344.1 # Merge nuts.ninka.net:/home/davem/src/BK/linus-2.5 # into nuts.ninka.net:/home/davem/src/BK/sparc-2.5 # -------------------------------------------- # 03/03/17 jsimmons@kozmo.(none) 1.961 # Merge # -------------------------------------------- # 03/03/17 jsimmons@maxwell.earthlink.net 1.956.1.3 # Merge # -------------------------------------------- # 03/03/17 davem@nuts.ninka.net 1.889.344.2 # [SPARC64]: Fix __hbird_read_stick signedness, also hbird softint_mask. # -------------------------------------------- # 03/03/18 jsimmons@maxwell.earthlink.net 1.962 # Merge bk://fbdev.bkbits.net/fbdev-2.5 # into maxwell.earthlink.net:/usr/src/fbdev-2.5 # -------------------------------------------- # 03/03/18 jsimmons@maxwell.earthlink.net 1.963 # [FBDEV] If a colormap contains no transparency information, fb_set_cmap() calls # fb_setcolreg() with trans = 0. This causes all CLUT entries to be fully # transparent on hardware that does have transparency information in the CLUT # registers. # # The following patch solves this problem by changing the default transparency # from 0 (full transparent) to 0xffff (full opaque). # -------------------------------------------- # 03/03/18 jsimmons@maxwell.earthlink.net 1.964 # [FBDEV] Ug!!! For some reason BK keeps removing this change. I hope this is the last time I have to add it. # -------------------------------------------- # 03/03/18 willy@debian.org 1.889.345.1 # [PATCH] PARISC update # # PA-RISC patches for 2.5.65: # # - Only remove palo.conf on a `make mrproper' # - Add a \ continuation to kernel/Makefile # - Reindent cache.c # - Always call schedule_tail # - Fix some typos in the hardware database # - Signal handling changes # - RAID, Device Mapper & BLKSZGET ioctl32 translations # - Clean up pci host bridge handling a bit. # - Make IDE link again # - Fix up compat changes # - Improve stack dumping code # -------------------------------------------- # 03/03/18 akpm@digeo.com 1.889.345.2 # [PATCH] Fix noirqbalance # # Patch from Zwane Mwaikambo # # This patch fixes what seems to have been a longstanding bug. Ever since we # moved cpu bringup later into the boot process, we end up programming the # ioapics before we have any of our possible cpus in the cpu_online_map. # Therefore leading to the following current situation; # # For walmart-smp, bigsmp and summit we set the logical destination for cpu # to TARGET_CPUS which can depend on the cpu_online_map, so what you would # normally see with noirqbalance would be all interrupts handled on cpu0 # since at that stage no other cpu apart from the BSP is online. # # You can check for this by looking at the ioredtbls at boottime for a two # way system; # # .... IRQ redirection table: # NR Log Phy Mask Trig IRR Pol Stat Dest Deli Vect: # 00 000 00 1 0 0 0 0 0 0 00 # 01 001 01 0 0 0 0 0 1 1 39 # 02 001 01 0 0 0 0 0 1 1 31 # 03 001 01 0 0 0 0 0 1 1 41 # 04 001 01 0 0 0 0 0 1 1 49 # 05 001 01 0 0 0 0 0 1 1 51 # 06 001 01 0 0 0 0 0 1 1 59 # # Notice that 'Log' is set to 1 instead of 3. # # This patch will simply reprogram all the ioredtbls to handle the other # online cpus. # # Patch tested on my 2way P2-400 and a 16way NUMAQ both with noirqbalance. # It will not affect the irqbalance case because we are simply setting # TARGET_CPUS which is done anyway. # # before: # CPU0 CPU1 # 0: 1495632 0 IO-APIC-edge timer # 1: 4270 0 IO-APIC-edge i8042 # 2: 0 0 XT-PIC cascade # 8: 1 0 IO-APIC-edge rtc # 12: 83592 0 IO-APIC-edge i8042 # 14: 93791 0 IO-APIC-edge ide0 # 15: 103167 0 IO-APIC-edge ide1 # 17: 1396088 0 IO-APIC-level EMU10K1, eth0 # 18: 56125 0 IO-APIC-level aic7xxx, aic7xxx # 19: 2258 0 IO-APIC-level uhci-hcd, eth1, serial # NMI: 0 0 # LOC: 1495566 1497133 # # after: # CPU0 CPU1 # 0: 1046157 1015670 IO-APIC-edge timer # 1: 4923 4173 IO-APIC-edge i8042 # 2: 0 0 XT-PIC cascade # 8: 1 0 IO-APIC-edge rtc # 12: 48596 48968 IO-APIC-edge i8042 # 14: 4238 3416 IO-APIC-edge ide0 # 15: 25362 31525 IO-APIC-edge ide1 # 17: 3757 4014 IO-APIC-level EMU10K1, eth0 # 18: 335 366 IO-APIC-level aic7xxx, aic7xxx # 19: 1052 908 IO-APIC-level uhci-hcd, eth1 # NMI: 0 0 # LOC: 2061856 2061893 # -------------------------------------------- # 03/03/18 akpm@digeo.com 1.889.345.3 # [PATCH] Pass the load address into ELF_PLAT_INIT() # # Patch from Anton Blanchard # # With ppc64 64bit dynamic executables we have to relocate the contents of the # function descriptor. Passing in the load address to ELF_PLAT_INIT allows us # to do this. # # The patch allows ppc64 to run 64-bit executables and is a no-op for other # architectures. # -------------------------------------------- # 03/03/18 akpm@digeo.com 1.889.345.4 # [PATCH] remove unused block congestion code # # Patch from: Hugh Dickins # # Removes a ton of dead code from ll_rw_blk.c. I don't expect we'll be using # this now. # -------------------------------------------- # 03/03/18 akpm@digeo.com 1.889.345.5 # [PATCH] timer code cleanup # # - Use list_head functions rather than open-coding them # # - Use time comparison macros rather than open-coding them # # - Hide some ifdefs # # - uninline internal_add_timer(). Saves half a kilobyte of text. # -------------------------------------------- # 03/03/18 akpm@digeo.com 1.889.345.6 # [PATCH] timer re-addition lockup fix # # This is a forward-port of Andrea's fix in 2.4. # # If a timer handler re-adds a timer to go off right now, __run_timers() will # never terminate. (I wrote a test. It happens.) # # Fix that up by teaching internal_add_timer() to detect when it is being # called from within the context of __run_timers() and to park newly-added # timers onto a temp list instead. These timers are then added for real by # __run_timers(), after it has finished processing all pending timers. # -------------------------------------------- # 03/03/18 akpm@digeo.com 1.889.345.7 # [PATCH] use set_current_state in fs # # Patch from Robert Love # # This patch is by Inaky Perez-Gonzalez. # # There are a couple uses of 'p->state=foo' in fs/ which are open coded. # This patch converts them to the proper [__]set_current_state() function. # -------------------------------------------- # 03/03/18 akpm@digeo.com 1.889.345.8 # [PATCH] use set_current_state in mm # # Patch from Robert Love # # There are a couple uses of 'p->state=foo' in mm/ which are open coded. # This patch converts them to the proper [__]set_current_state() function. # -------------------------------------------- # 03/03/18 akpm@digeo.com 1.889.345.9 # [PATCH] Fix memory leak in copy_thread # # Patch from Andi Kleen # # copy_thread could leak memory if you had a io bitmap and passed wrong # arguments to the new clone flags. # -------------------------------------------- # 03/03/18 akpm@digeo.com 1.889.345.10 # [PATCH] file_list_lock contention fixes # # Patch from Manfred Spraul # # Fixes the lock contention over file_list_lock by simply removing the unneeded # anon_list. So filp allocation does not need to take a global lock any more. # # The use of a spinlock to protect files_stat.nr_files is a bit awkward, but # the alternative is a custom sysctl handler, and isn't much more efficient # anyway. # -------------------------------------------- # 03/03/18 akpm@digeo.com 1.889.345.11 # [PATCH] file->f_list locking in tty_io.c # # release_mem() is altering the file->f_list lists without taking the # appropriate spinlock. # -------------------------------------------- # 03/03/18 akpm@digeo.com 1.889.345.12 # [PATCH] file_list cleanup # # Replace the odd handling of f_list.next = NULL with list_emptiness. # -------------------------------------------- # 03/03/18 akpm@digeo.com 1.889.345.13 # [PATCH] file_table: remove the private freelist # # - Remove the private freelist. There's no point in special-casing file # structure allocations in this way. # # - Hence the freeing of files can be moved outside file_list_lock() # # - Replace euid test with capable(CAP_SYS_ADMIN). # # - Tidy various other things up. # -------------------------------------------- # 03/03/18 akpm@digeo.com 1.889.345.14 # [PATCH] file_list: less locking # # - optimise file_kill() to not take the global lock if the file is not on a # list. # # - Use optimised file_kill() in a few places rather than open-coding the # list removal. # -------------------------------------------- # 03/03/18 akpm@digeo.com 1.889.345.15 # [PATCH] stack reduction in drivers/char/vt_ioctl.c # # Patch from "Randy.Dunlap" # # This patch (to 2.5.64) reduces the stack usage in vt_ioctl() # from 0x334 bytes to 0xec bytes (P4, UP, gcc 2.96). # -------------------------------------------- # 03/03/18 akpm@digeo.com 1.889.345.16 # [PATCH] a few missing stubs for !CONFIG_MMU # # Patch from Christoph Hellwig # # This is from the uClinux patches - there are a few more stubs needed # in nommu.c to get the mmuless plattforms working. # -------------------------------------------- # 03/03/18 akpm@digeo.com 1.889.345.17 # [PATCH] slab changes for !CONFIG_MMU # # Patch from Christoph Hellwig # # It extends the maximum amount of memory which may be kmalloced on nommu # machines. This is needed because these machines cannot perform vmalloc(). # # We couldn't really find a way of doing this which avoided the ifdef tangle. # -------------------------------------------- # 03/03/18 akpm@digeo.com 1.889.345.18 # [PATCH] memleak in fs/nfs/inode.c::nfs_get_sb() # # Patch from Oleg Drokin # # There is trivial memleak on error exit path in nfs get_sb function. # -------------------------------------------- # 03/03/18 akpm@digeo.com 1.889.345.19 # [PATCH] Memleak in fs/ufs/util.c # # Patch from Oleg Drokin # # There is trivial memleak on error exit path in # fs/ufs/util.c::_ubh_bread_() # -------------------------------------------- # 03/03/18 akpm@digeo.com 1.889.345.20 # [PATCH] posix timers update # # Patch from george anzinger # # Fix the "large sleep returns EINVAL" problem, and clean a few things up. # -------------------------------------------- # 03/03/18 akpm@digeo.com 1.889.345.21 # [PATCH] OOPS instance counters # # Patch from "Randy.Dunlap" # # Adds an oops counter to the oops messages, such as: # # Oops: 0002 [#2] # # So we can tell whether oops reports refer to the first oops, or to some # less-interesting followon oops. # -------------------------------------------- # 03/03/18 akpm@digeo.com 1.889.345.22 # [PATCH] io-apic.c: DO_ACTION cleanup # # Patch from "Martin J. Bligh" # # This removes the DO_ACTION stuff. The downside is that we add some boring # and repetive code. The upside is that it's simple, and mere mortals can read # it without screwing their brains into a small piece of silly putty and # bouncing it off the wall. I think that's more important than pure source # code size. # -------------------------------------------- # 03/03/18 akpm@digeo.com 1.889.345.23 # [PATCH] fix oprofile timer race # # Patch from John Levon # # wli got an oops from this. The callbacks call mod_timer so the timer had # better be setup by then # -------------------------------------------- # 03/03/18 akpm@digeo.com 1.889.345.24 # [PATCH] pgd_index/pmd_index/pte_index commentary # # Patch from Dave Hansen # # Adds some commentary to these newly-introduced macros. # -------------------------------------------- # 03/03/18 akpm@digeo.com 1.889.345.25 # [PATCH] /proc/sysrq-trigger: trigger sysrq functions via # # This makes sysrq facilities available to remote users. # # Writing a 'C' to /proc/sysrq-trigger receives the same treatment as typing # sysrq-C on the local keyboard. # -------------------------------------------- # 03/03/18 akpm@digeo.com 1.889.345.26 # [PATCH] Tighten CONFIG_NUMA preconditions # # Patch from Martin J. Bligh and Dave Hansen # # People with ordinary PCs are accidentally turning on NUMA support, and people # with NUMA machines are finding the NUMA option mysteriously disappearing. # This patch sets the defaults to sane things for everyone, and only allows you # to turn on NUMA with both SMP and 64Gb support on (it's useful for the # distros on non-Summit boxes, but not on their UP kernels ;-)). # # I've also moved it below the highmem options, as it logically depends on # them, so this makes more sense. For those searching for NUMA support on # *real* NUMA machine, Dave has provided some guiding comments to show them # what they messed up (it's totally non-obvious). Hopefully this will stop # people's recent unfortunate foot-wounds (I think UP machines were defaulting # to NUMA on ... oops). # -------------------------------------------- # 03/03/18 akpm@digeo.com 1.889.345.27 # [PATCH] Fix nfsd_symlink() failure path # # Patch from Andreas Gruenbacher # # In both 2.5 and 2.4, the fs/nfsd/vfs.c:nfsd_symlink() function calls down to # notify_change(). If notify_change fails for some reason, the error code is # not converted to an nfs no-the-wire error code as is should. The attached # patches fix that (one for 2.4, the other for 2.5). # -------------------------------------------- # 03/03/18 akpm@digeo.com 1.889.345.28 # [PATCH] Add error checking get_disk() # # Patch from Bob Miller # # The get_disk() function should check the return value from kobject_get() # before passing it to to_disk(). This patch fixes this error. # # (Acked by Pat) # -------------------------------------------- # 03/03/18 rmk@flint.arm.linux.org.uk 1.889.346.1 # [ARM] Minor updates/fixes to ARM PCI support code. # # Fixup functions need to be __devinit, not __init for cardbus to work. # Convert ARM to setup bridge windows and resources on a per-bus basis, # and call pci_bus_add_devices() once everything is setup. # -------------------------------------------- # 03/03/18 rmk@flint.arm.linux.org.uk 1.889.346.2 # [ARM] Fix timeouts to use the correct type. # -------------------------------------------- # 03/03/18 rmk@flint.arm.linux.org.uk 1.889.346.3 # [ARM] Remove explicit IRQ disable/enable in PXA timer IRQ # # Timer interrupts run with IRQs disabled, so this is # unnecessary. # -------------------------------------------- # 03/03/18 greg@kroah.com 1.889.347.1 # [PATCH] i2c i2c-i801.c: remove #ifdefs and fix all printk() to use dev_*(). # -------------------------------------------- # 03/03/18 greg@kroah.com 1.889.347.2 # [PATCH] i2c i2c-i801.c: remove check_region() usage. # -------------------------------------------- # 03/03/18 greg@kroah.com 1.889.347.3 # [PATCH] i2c i2c-i801.c: fix up the pci id matching, and change to use proper pci ids. # -------------------------------------------- # 03/03/18 greg@kroah.com 1.889.347.4 # [PATCH] i2c i2c-i801.c: fix up formatting and whitespace issues. # # Also made everything static, no global functions are needed here. # -------------------------------------------- # 03/03/18 rmk@flint.arm.linux.org.uk 1.889.346.4 # [ARM] Add typechecking to local_irq_save() # -------------------------------------------- # 03/03/18 rmk@flint.arm.linux.org.uk 1.889.346.5 # [ARM] Update CLPS7500 support. # # CLPS7500 had lacked behind slightly; this cset brings it back up to # date. # -------------------------------------------- # 03/03/18 rmk@flint.arm.linux.org.uk 1.889.346.6 # [ARM] Distinguish between the various oops messages better. # -------------------------------------------- # 03/03/18 rmk@flint.arm.linux.org.uk 1.889.346.7 # [ARM] Ensure transmitter starts before leaving ssp_write_word() # # Wait for BSY bit to be asserted before returning from # ssp_write_word(). This ensures that ssp_flush() will wait for # the transmitter to empty before returning. # # Add ssp.h header. # -------------------------------------------- # 03/03/18 davem@nuts.ninka.net 1.889.344.3 # [SPARC64]: In __hbird_write_compare, write high then low part. # -------------------------------------------- # 03/03/18 greg@kroah.com 1.889.347.5 # [PATCH] i2c i2c-piix4.c: remove check_region() call. # -------------------------------------------- # 03/03/18 davem@nuts.ninka.net 1.889.344.4 # [SPARC64]: Make TICK comparisons wrap-around safe by using jiffies macros. # -------------------------------------------- # 03/03/18 greg@kroah.com 1.889.347.6 # [PATCH] i2c i2c-piix4: remove #ifdefs and fix all printk() to use dev_*(). # -------------------------------------------- # 03/03/18 greg@kroah.com 1.889.347.7 # [PATCH] i2c i2c-piix4.c: fix up formatting and whitespace issues. # -------------------------------------------- # 03/03/18 davem@nuts.ninka.net 1.889.344.5 # [SPARC64]: Ignore bit 63 of Hummingbird STICK when computing COMPARE register values. # -------------------------------------------- # 03/03/18 davem@nuts.ninka.net 1.889.344.6 # [SPARC64]: Do a dummy write to STICK in hbird_init_tick. # -------------------------------------------- # 03/03/18 davem@nuts.ninka.net 1.889.344.7 # [FB ATY]: CONFIG_FB_ATY needs cfbcopyarea.o # -------------------------------------------- # 03/03/18 davem@nuts.ninka.net 1.889.344.8 # [SPARC64]: Sanitize all TICK privileged bit handling in tick drivers. # -------------------------------------------- # 03/03/18 davem@nuts.ninka.net 1.889.344.9 # [SPARC64]: Clear tick_cmpr ints properly in bootup assembly. # -------------------------------------------- # 03/03/19 rmk@flint.arm.linux.org.uk 1.889.346.8 # [ARM] Fix more timeouts to use correct type. # -------------------------------------------- # 03/03/19 rmk@flint.arm.linux.org.uk 1.889.346.9 # [ARM] Add L1_CACHE_SHIFT to asm-arm/cache.h # # In addition, remove some unnecessary definitions from cache.h # -------------------------------------------- # 03/03/19 rmk@flint.arm.linux.org.uk 1.889.346.10 # [ARM] Update Acorn SCSI drivers. # # Update acornscsi.c for host/device structure changes. # Clean up scsi_pointer initialisation. # -------------------------------------------- # 03/03/19 perex@suse.cz 1.889.345.29 # Merge suse.cz:/home/perex/bk/linux-sound/linux-sound # into suse.cz:/home/perex/bk/linux-sound/work # -------------------------------------------- # 03/03/19 jsimmons@maxwell.earthlink.net 1.965 # Merge # -------------------------------------------- # 03/03/19 jsimmons@kozmo.(none) 1.966 # [FBDEV] Killed of a static buffer in the generic software cursor. We didn't need it and it is a bad idea to have a static buffer is we have more than one framebuffer. # # [FBCON] More optimzations in accel_cursor in attempts to eliminate more static buffers. # -------------------------------------------- # 03/03/19 davej@tetrachloride.(none) 1.889.325.40 # Merge tetrachloride.(none):/mnt/raid/src/kernel/2.5/bk-linus # into tetrachloride.(none):/mnt/raid/src/kernel/2.5/cpufreq # -------------------------------------------- # 03/03/19 oliver@neukum.name 1.889.348.1 # [PATCH] USB: fix to synchronous API regarding memory allocation # # some part of the synchronous API is used in the block io error handling # code paths. Therefore it may use only GFP_NOIO, not GFP_KERNEL. # - avoid deadlock due to wrong memory allocation in block io path # -------------------------------------------- # 03/03/19 baldrick@wanadoo.fr 1.889.348.2 # [PATCH] USB speedtouch: cosmetic comment changes # -------------------------------------------- # 03/03/19 davej@codemonkey.org.uk 1.889.325.41 # [CPUFREQ] No need to export cpufreq_governor_list, so it can be static. # From Dominik Brodowski # -------------------------------------------- # 03/03/19 baldrick@wanadoo.fr 1.889.348.3 # [PATCH] USB speedtouch: get rid of atmsar # # There are really only two patches: add atmsar stuff into # speedtouch.c; and update the Makefile. The other changes # are: delete atmsar.c and atmsar.h, rename speedtouch.c to # speedtch.c. # -------------------------------------------- # 03/03/19 elenstev@mesatop.com 1.889.347.8 # [PATCH] i2c: spelling corrections for drivers/i2c # # Here are some spelling and typo fixes for drivers/i2c. # -------------------------------------------- # 03/03/19 hch@hera.kernel.org 1.889.341.9 # Merge hera.kernel.org:/home/torvalds/BK/linux-2.5 # into hera.kernel.org:/home/hch/BK/xfs/linux-2.5 # -------------------------------------------- # 03/03/19 david-b@pacbell.net 1.889.348.4 # [PATCH] USB: ehci-hcd, prink tweaks # # A not-very interesting patch, it just cleans up # some debug output. # -------------------------------------------- # 03/03/19 green@linuxhacker.ru 1.889.348.5 # [PATCH] USB: Memleak in drivers/usb/hub.c::usb_reset_device # # Hello! # # On Fri, Mar 14, 2003 at 11:37:19AM -0800, Greg KH wrote: # > > There seems to be a memleak in drivers/usb/hub.c::usb_reset_device() # > > on error exit path. See the patch. # > > Found with help of smatch + enhanced unfree script. # > And yes, as David said, there is another kind of error in this area for # > 2.5. Patches to clean that up would be appreciated. # # Ok, I guess something like that should work: # -------------------------------------------- # 03/03/19 randy.dunlap@verizon.net 1.889.348.6 # [PATCH] USB: reduce stack usage in cdc-ether # # This patch to 2.5.64 reduces the large stack usage in # log_device_info() [and makes it static to boot]. # -------------------------------------------- # 03/03/19 dlstevens@us.ibm.com 1.889.1.215 # [IPV6]: Add anycast support. # -------------------------------------------- # 03/03/19 davem@nuts.ninka.net 1.889.1.216 # [IPV6]: ndisc_recv_ns returns void. # -------------------------------------------- # 03/03/20 paulus@samba.org 1.889.349.1 # PPC32: Make a ppc32 version of pcibios_resource_to_bus, which adds # an offset where needed. # -------------------------------------------- # 03/03/19 davem@nuts.ninka.net 1.889.1.217 # [IPV6]: Undo __constant_{n,h}to{n,h}l from anycast patch. # -------------------------------------------- # 03/03/19 kuznet@ms2.inr.ac.ru 1.889.1.218 # [NET]: hard_header reservation. # 1. Fix bad reservation in xfrm_state_check_space() # 2. Macroize formula for reservation, use the macro over all the places # in IP. # -------------------------------------------- # 03/03/19 kuznet@ms2.inr.ac.ru 1.889.1.219 # [NET]: miscellaneous fixes. # 1. Fix illegal dereference of potentially freed memory in xfrm_policy.c # 2. Complete wildcard flow addresses to real ones in xfrm_lookup(). # 3. Respect optional flag when chacking for input policy. # 4. Delete orphaned comments in ip.h. # 5. Fix mistakedly freed route in tcp connect. # -------------------------------------------- # 03/03/19 kuznet@ms2.inr.ac.ru 1.889.1.220 # [IPSEC]: fragmentation & tcp mss calculation. # 1. Add local_df field to struct sk_buff to mark packets which # are to be fragmented locally despite of their IPv6ness of IP DF flag # 2. Add ext2_header_len to tcp_opt to keep memory of part of header length # depending on route # 3. Add trailer_len to struct dst_entry and xfrm_state to know how # much of space should be reserved at tail of frame for subsequent # transformations. # 4. [BUG] icv_trun_len must be used while mss claculation, not # icv_full_length. # -------------------------------------------- # 03/03/20 paulus@samba.org 1.889.349.2 # PPC32: Makefile tidy-up, mostly from Sam Ravnborg # -------------------------------------------- # 03/03/19 davem@nuts.ninka.net 1.889.1.221 # [NET]: Kill NETIF_F_DYNALLOC, based upon ideas from Adam J. Richter # -------------------------------------------- # 03/03/19 davem@nuts.ninka.net 1.889.344.10 # Merge nuts.ninka.net:/home/davem/src/BK/sparcwork-2.5 # into nuts.ninka.net:/home/davem/src/BK/sparc-2.5 # -------------------------------------------- # 03/03/19 davem@nuts.ninka.net 1.889.344.11 # [SPARC]: Add die_counter changes. # -------------------------------------------- # 03/03/19 davem@nuts.ninka.net 1.889.344.12 # [SPARC64]: Fix thread_info offsets to match restart_block layout changes. # -------------------------------------------- # 03/03/19 davem@nuts.ninka.net 1.889.1.222 # Merge nuts.ninka.net:/home/davem/src/BK/network-2.5 # into nuts.ninka.net:/home/davem/src/BK/net-2.5 # -------------------------------------------- # 03/03/20 bdschuym@pandora.be 1.889.1.223 # [ebtables] bugfix in ebt_ip.c # -------------------------------------------- # 03/03/20 davem@nuts.ninka.net 1.889.1.224 # Merge http://linux-lksctp.bkbits.net/lksctp-2.5 # into nuts.ninka.net:/home/davem/src/BK/net-2.5 # -------------------------------------------- # 03/03/20 thomas@bender.thinknerd.de 1.889.1.225 # [IPSEC]: Fix null authentication/encryption. # -------------------------------------------- # 03/03/20 jmorris@intercode.com.au 1.889.1.226 # [IPSEC]: fix skb leak in ah and esp. # -------------------------------------------- # 03/03/20 jmorris@intercode.com.au 1.889.1.227 # [IPSEC]: return error when no dst in ah & esp output. # -------------------------------------------- # 03/03/20 ahaas@airmail.net 1.889.1.228 # [PATCH] Add C99 initializers to net/ipv4/netfilter. # -------------------------------------------- # 03/03/20 ahaas@airmail.net 1.889.1.229 # [PATCH] Add C99 initializers for net/ipv6/netfilter code. # -------------------------------------------- # 03/03/20 chas@locutus.cmf.nrl.navy.mil 1.889.1.230 # [ATM]: Fix idt77252/sch_atm/pppoatm compilation. # -------------------------------------------- # 03/03/20 bunk@fs.tum.de 1.889.1.231 # [NF/IPV6]: Remove all ipv6_ext_hdrs from ip6tables. # -------------------------------------------- # 03/03/20 willy@debian.org 1.889.1.232 # [NET]: Optimize handling of CONFIG_NET=n. # -------------------------------------------- # 03/03/20 jsimmons@kozmo.(none) 1.967 # [AMIGA FBDEV] Ported over to new api. # -------------------------------------------- # 03/03/20 jsimmons@kozmo.(none) 1.968 # [CONTROL/PLATNIUM FBDEV] Small cleanups to latest changes. # [AMIGA FBDEV] Removed console.h file. # [CONSOLE] Nuked gloabl variables video_scan_line and freinds. This makes working with VCs of different resolutions possible. # -------------------------------------------- # 03/03/20 perex@suse.cz 1.889.345.30 # ALSA update (0.9.2) # - created snd-page-alloc module # - moved all page allocation code there # - preserves preallocated DMA buffers for devices # - USB audio driver updated # - AC'97 - better modem initialization code # - timer API - enhanced (added pause and more event notifications) # - splitted ice1724 code from ice1712 to own module # - general # - timerstamp cleanups (timeval -> timespec) # - C99-like cleanups # - trident driver # - more workaround for wrong IRQ acks # - OSS sequencer emulation # - fixed OOPS (wrong free order) # - more compatible with level 1 of sequencer (/dev/sequencer) # - CS46xx driver updated # - intel8x0 driver updated # - emu10k1 driver updated # -------------------------------------------- # 03/03/20 greg@kroah.com 1.889.347.9 # [PATCH] i2c i2c-ali15x3.c: remove #ifdefs and fix all printk() to use dev_*(). # -------------------------------------------- # 03/03/20 greg@kroah.com 1.889.347.10 # [PATCH] i2c i2c-ali15x3.c: remove check_region() call. # -------------------------------------------- # 03/03/20 greg@kroah.com 1.889.347.11 # [PATCH] i2c i2c-ali15x3.c: fix up formatting and whitespace issues. # -------------------------------------------- # 03/03/20 greg@kroah.com 1.889.347.12 # [PATCH] i2c i2c-amd756.c: remove some #ifdefs and fix all printk() to use dev_*(). # # Also some minor whitespace cleanups. # -------------------------------------------- # 03/03/20 greg@kroah.com 1.889.347.13 # [PATCH] i2c i2c-amd8111.c: change a few printk() to dev_warn() # -------------------------------------------- # 03/03/20 rmk@flint.arm.linux.org.uk 1.889.346.11 # [ARM] Fix CONFIG_CPU_FREQ_GOV_USERSPACE warning. # -------------------------------------------- # 03/03/20 greg@kroah.com 1.889.347.14 # i2c i2c-amd8111.c: change the pci driver name to have "2" in it based on previous comments. # -------------------------------------------- # 03/03/20 greg@kroah.com 1.889.347.15 # i2c: added i2c-isa bus controller driver. # # Based on the i2c cvs version of this driver. # -------------------------------------------- # 03/03/20 greg@kroah.com 1.889.347.16 # i2c: add initial driver model support for i2c drivers. # -------------------------------------------- # 03/03/20 greg@kroah.com 1.889.350.1 # Merge kroah.com:/home/greg/linux/BK/bleed-2.5 # into kroah.com:/home/greg/linux/BK/i2c-2.5 # -------------------------------------------- # 03/03/20 greg@kroah.com 1.889.348.7 # [PATCH] USB: whiteheat bugfix (bugzilla.kernel.org #314) # -------------------------------------------- # 03/03/20 greg@kroah.com 1.889.348.8 # [PATCH] USB: pegasus: fix up GFP_DMA usages. (bugzilla.kernel.org #418) # -------------------------------------------- # 03/03/20 stern@rowland.harvard.edu 1.889.348.9 # [PATCH] USB: Update for usb-skeleton # # My update for usb-skeleton seems to have gotten lost in the shuffle, so # here it is again -- all wrapped up in one nice little patch. It's been # tested by three different people and passed with flying colors. Please # apply. # -------------------------------------------- # 03/03/20 jmcmullan@linuxcare.com 1.889.348.10 # [PATCH] USB HID: Ignore P5 Data Glove (2.4 and 2.5 patches) # # As requested, here are the 2.4 (latest BK tree) and 2.5 (latest bk # tree) patches to ignore the non-HID Essential Reality Data Glove # # (again, user-space lib to access this device via /proc/bus/usb # is available at http://www.evillabs.net/~jmcc/p5) # -------------------------------------------- # 03/03/20 henning@meier-geinitz.de 1.889.348.11 # [PATCH] USB: new ids for scanner driver # # This patch adds new vendor/product ids for various scanners. # -------------------------------------------- # 03/03/20 greg@kroah.com 1.889.351.1 # Merge kroah.com:/home/greg/linux/BK/bleed-2.5 # into kroah.com:/home/greg/linux/BK/gregkh-2.5 # -------------------------------------------- # 03/03/20 scott.feldman@intel.com 1.889.352.1 # [E100] back out memleak patch cuz it messed up following # # On Thu, 20 Mar 2003, Scott Feldman wrote: # # # * Back this patch out - we'll add it later. I was working against # 2.5.64 when this was checked into 2.5.65, so it messed up # my patches. # -------------------------------------------- # 03/03/20 scott.feldman@intel.com 1.889.352.2 # [E100] Update Documentation/networking/e100.txt # # On Thu, 20 Mar 2003, Scott Feldman wrote: # # # * Update Documentation/networking/e100.txt # -------------------------------------------- # 03/03/20 scott.feldman@intel.com 1.889.352.3 # [E100] update version, copyright year, changelog # # On Thu, 20 Mar 2003, Scott Feldman wrote: # # # * Update version, copyright year, changelog # -------------------------------------------- # 03/03/20 scott.feldman@intel.com 1.889.352.4 # [E100] Spelling mistakes # # On Thu, 20 Mar 2003, Scott Feldman wrote: # # # * Spelling mistakes # -------------------------------------------- # 03/03/20 scott.feldman@intel.com 1.889.352.5 # [E100] Add support for VLAN hw offload # # On Thu, 20 Mar 2003, Scott Feldman wrote: # # # * Add support for VLAN hw offload # -------------------------------------------- # 03/03/20 scott.feldman@intel.com 1.889.352.6 # [E100] Clean up #include order # # On Thu, 20 Mar 2003, Scott Feldman wrote: # # # * clean up #includes # -------------------------------------------- # 03/03/20 scott.feldman@intel.com 1.889.352.7 # [E100] Bug fix on setting up Tx csum # # On Thu, 20 Mar 2003, Scott Feldman wrote: # # # * Bug fix on setting up Tx csum # -------------------------------------------- # 03/03/20 scott.feldman@intel.com 1.889.352.8 # [E100] Banish strong branding marketing strings # # On Thu, 20 Mar 2003, Scott Feldman wrote: # # # * Get rid of all of the strong marketing brand strings # and replace with simple pci_device_id table. pci.ids # should be the master list for device ID/strings. # -------------------------------------------- # 03/03/20 scott.feldman@intel.com 1.889.352.9 # [E100] forced speed/duplex link recover # # On Thu, 20 Mar 2003, Scott Feldman wrote: # # # * Bug fix when changing to non-autoneg, device may lose # link with some switches, so try to recover link by # forcing PHY. # -------------------------------------------- # 03/03/20 scott.feldman@intel.com 1.889.352.10 # [E100] ICH5 support added # # On Thu, 20 Mar 2003, Scott Feldman wrote: # # # * ICH5 support: chipset integrated LAN (8255x) # * PHY loopback diags is broken on all ICHs # -------------------------------------------- # 03/03/20 scott.feldman@intel.com 1.889.352.11 # [E100] Honor WOL settings in EEPROM # # On Thu, 20 Mar 2003, Scott Feldman wrote: # # # * Honor WOL settings in EEPROM: only advertise WOL magic # packet if in EEPROM. # -------------------------------------------- # 03/03/20 scott.feldman@intel.com 1.889.352.12 # [E100] interrupt handler free fix # # On Thu, 20 Mar 2003, Scott Feldman wrote: # # # * Bug fix on e100_close when repeating hot remove/hot add # from team. Basically need to disable interurpts and # unregister handler before shutting h/w down. # * Need to mask only the relevant bits in the interrupt # status register # -------------------------------------------- # 03/03/20 scott.feldman@intel.com 1.889.352.13 # [E100] Validate updates to MAC address # # On Thu, 20 Mar 2003, Scott Feldman wrote: # # # * Validate updates to MAC address as valid ethernet address. # -------------------------------------------- # 03/03/20 scott.feldman@intel.com 1.889.352.14 # [E100] ethtool EEPROM and GSTRING fixes # # On Thu, 20 Mar 2003, Scott Feldman wrote: # # # * Bug fix: read wrong byte in EEPROM when offset is odd number # * Bug fix: memory leak in ETHTOOL_GSTRINGS # [Oleg Drokin # # The NMI watchdog has two different "modes": NMI_IO_APIC, which delivers NMI's # through the IO-APIC, and NMI_LOCAL_APIC, which uses the local APIC vector # table (LVT) to deliver the periodic NMI's. # # Only NMI_IO_APIC requires being able to set up the PIT so it can deliver # NMI's through the IO-APIC, and so NMI_LOCAL_APIC has no dependency on the # timer being set up through the IO-APIC and is unjustifiably disabled by # check_timer() when the PIT cannot deliver interrupts through the IO-APIC. # # This is important because one of the most important uses of NMI_LOCAL_APIC is # to get the NMI watchdog going when NMI_IO_APIC doesn't work. # # So what this patch does to repair the situation is instead of checking to see # if the NMI watchdog is enabled at all, it instead checks whether the NMI # watchdog is being used in NMI_IO_APIC mode when a failure to set up the NMI # timer interrupt through the IO-APIC occurs. # -------------------------------------------- # 03/03/20 akpm@digeo.com 1.889.1.236 # [PATCH] fix nanosleep() granularity bumps # # From: Tim Schmielau # # Fixes the problem wherein nanosleep() is sleeping for the wrong duration. # # When starting out with timer_jiffies=0, the timer cascade is (unneccessarily) # triggered on the first timer interrupt, incrementing all the higher indices. # When starting with any other initial jiffies value, we miss that and end up # with all higher indices being off by one. # -------------------------------------------- # 03/03/20 akpm@digeo.com 1.889.1.237 # [PATCH] add write_seqlock to cpufreq change notifier for TSC # # From: Stephen Hemminger # # The CPU frequency change detection code can change the values used to compute # time of day with TSC; but there was no locking around it. # -------------------------------------------- # 03/03/20 akpm@digeo.com 1.889.1.238 # [PATCH] cs46xx minor fixes # # - jiffies signedness fix # # - Fix compile warning # -------------------------------------------- # 03/03/20 akpm@digeo.com 1.889.1.239 # [PATCH] Add missing put_user checks in n_tty # # From: Steven Rostedt # # The n_tty driver is missing some put_user checks. # -------------------------------------------- # 03/03/20 akpm@digeo.com 1.889.1.240 # [PATCH] Fail setup_irq for unconfigured IRQs # # From: Zwane Mwaikambo # # This patch makes us bail out in case we may have an interrupt which couldn't # be associated with an interrupt controller. Without this we allow # unconfigured interrupts to be assigned and then later on we get "unexpected # IRQ trap at vector xx" during the ack phase. # # scenario: This can occur if we fail irq setup during setup_IO_APIC_irqs for # some reason or other and then miss getting assigned a vector. Later on we # then get assigned no_irq_type as our handler. # # Patch for i386 and x86_64 # -------------------------------------------- # 03/03/20 akpm@digeo.com 1.889.1.241 # [PATCH] raw driver: rewrite i_mapping only on final close # # The recent fix to the raw driver wasn't quite right: it rewrites the # character-special inode's i_mapping to point back to itself on each close. # So any other currently-open handles against /dev/raw/rawN get a nasty # surprise. # # Change it to only rewrite i_mapping on the final close. # # Also, change it so that it only redirects its i_mapping on the initial open. # This is not necessary, but is neater. # -------------------------------------------- # 03/03/20 akpm@digeo.com 1.889.1.242 # [PATCH] raw driver: cleanups and small fixes # # - There was an unchecked bdget(). bdget can fail due to ENOMEM. # # - rework the error handling implementation in raw_ctl_ioctl(). # # - Replace MOD_INC_USE_COUNT with try_module_get(THIS_MODULE). This allows # the raw module to be unloaded again. # # The core kernel has already taken a ref on the module prior to entering # the ioctl, so try_module_get() cannot fail. # -------------------------------------------- # 03/03/20 akpm@digeo.com 1.889.1.243 # [PATCH] slab: tune batchcounts for large objects # # From: Manfred Spraul # # Now that slab supports monster objects (up to 32MB) for !CONFIG_MMU we really # don't want to keep spare instances of them in the slab head arrays. # # - limit head array sizes for huge slab caches to one object per cpu. # # - round the batch count up for default head array sizing - batch count 0 is # illegal. # -------------------------------------------- # 03/03/20 akpm@digeo.com 1.889.1.244 # [PATCH] Fix floppy oops on forced unload # # From: Angus Sawyer # # Prevent OOPS on removing floppy driver with "rmmod -f floppy". # # floppy.c would attempt to unregister resources for nonexistent device. # # Patch stops the driver attempting to register and unregister the nonexistent # device by removing the drive from the allowed drives mask (defaults to # present). # -------------------------------------------- # 03/03/20 torvalds@home.transmeta.com 1.889.1.245 # Merge bk://kernel.bkbits.net/gregkh/linux/i2c-2.5 # into home.transmeta.com:/home/torvalds/v2.5/linux # -------------------------------------------- # 03/03/20 torvalds@home.transmeta.com 1.889.1.246 # Merge bk://linuxusb.bkbits.net/linus-2.5 # into home.transmeta.com:/home/torvalds/v2.5/linux # -------------------------------------------- # 03/03/20 torvalds@home.transmeta.com 1.889.1.247 # Merge http://linux-sound.bkbits.net/linux-sound # into home.transmeta.com:/home/torvalds/v2.5/linux # -------------------------------------------- # 03/03/20 torvalds@home.transmeta.com 1.889.1.248 # Merge bk://linux-dj.bkbits.net/cpufreq # into home.transmeta.com:/home/torvalds/v2.5/linux # -------------------------------------------- # 03/03/20 davej@codemonkey.org.uk 1.889.1.249 # [PATCH] fix obvious thinko # -------------------------------------------- # 03/03/20 davej@codemonkey.org.uk 1.889.1.250 # [PATCH] cciss unregister cleanup # # From Herbert Xu # # The following patches against 2.4 and 2.5 makes cciss unregister properly # if initialisation fails. # -------------------------------------------- # 03/03/20 davej@codemonkey.org.uk 1.889.1.251 # [PATCH] 3ware vendor update # -------------------------------------------- # 03/03/20 davej@codemonkey.org.uk 1.889.1.252 # [PATCH] Remove old DRM4.0 code. # # Old patch from John Kim to remove old DRM 4.0 code in 2.5.59. # -------------------------------------------- # 03/03/20 davej@codemonkey.org.uk 1.889.1.253 # [PATCH] piix compile fix for CONFIG_PROC_FS=n # # Fix by Randy Dunlap # # Here's a patch to build ide/pci/piix.c with CONFIG_PROC_FS=n. # -------------------------------------------- # 03/03/20 davej@codemonkey.org.uk 1.889.1.254 # [PATCH] documentation for userspace access. # # From: Jon Foster # # This patch against 2.5.63 adds kerneldoc comments to the public API in these files: # - include/asm-i386/uaccess.h # - arch/i386/lib/usercopy.c # # This patch only changes comments and one of the templates used by "make htmldocs", # it does not change any code. # -------------------------------------------- # 03/03/20 davej@codemonkey.org.uk 1.889.1.255 # [PATCH] fix acpi write throttle seq file breakage. # # From Pavel Machek # -------------------------------------------- # 03/03/20 davej@codemonkey.org.uk 1.889.1.256 # [PATCH] Sysfs not handling show errors # # Originally by Rusty Lynch, munged by me, acked # by Mochel. # # Attempting to cat a sysfs file that returns an error will result in an # endless dump of garbage to the screen because the result of the specific # show operation was being saved to a size_t (unsigned) and then later # checked for a negative value. # -------------------------------------------- # 03/03/20 davej@codemonkey.org.uk 1.889.1.257 # [PATCH] make nbd working in 2.5.x # # From Petr Vandrovec # # we use nbd for our diskless systems, and it looks to me like that # it has some serious problems in 2.5.x... Can you apply this patch # and forward it to Linus? # # There were: # * Missing disk's queue initialization # * Driver should use list_del_init: put_request now verifies # that req->queuelist is empty, and list_del was incompatible # with this. # * I converted nbd_end_request back to end_that_request_{first,last} # as I saw no reason why driver should do it itself... and # blk_put_request has no place under queue_lock, so apparently when # semantic changed nobody went through drivers... # -------------------------------------------- # 03/03/20 davej@codemonkey.org.uk 1.889.1.258 # [PATCH] Several logic bugs. # # Lots of patches from Norbert Kiesel that fix up several silly # | vs. || and & vs. && bugs found with # find ${1:-.} -name \*.c | xargs grep -En \ # '![a-zA-Z0-9_ ]+(\|[^|]|\&[^&])|([^|]\||[^&]\&) *!' # -------------------------------------------- # 03/03/20 axboe@suse.de 1.889.1.259 # [PATCH] cdrom buffer too small # # dvd_read_physical() uses a 20 char buffer to read in the dvd structure, # however the size is really 4 bytes header + 17 bytes body so layer->bca # ends up containing garbage. Kudos to the nice folks who made it a non # multiple of 4 bytes. # -------------------------------------------- # 03/03/20 geert@linux-m68k.org 1.889.1.260 # [PATCH] M68k exported symbols # # M68k: Export missing symbols: # - mach_beep (for m68k beeper) # - strpbrk (for SCSI) # -------------------------------------------- # 03/03/20 geert@linux-m68k.org 1.889.1.261 # [PATCH] M68k ISA memory for Amiga PCMCIA # # M68k ISA: Fix ISA memory space mapping for Amiga PCMCIA (from Kars de Jong) # -------------------------------------------- # 03/03/20 geert@linux-m68k.org 1.889.1.262 # [PATCH] M68k POSIX timers # # M68k: Update POSIX timers in struct siginfo (cfr. asm-generic/siginfo.h in # 2.5.63) # -------------------------------------------- # 03/03/20 geert@linux-m68k.org 1.889.1.263 # [PATCH] M68k: Add new kmap types # # M68k: Add new kmap types for 2.5.60. # -------------------------------------------- # 03/03/20 geert@linux-m68k.org 1.889.1.264 # [PATCH] Amiga PCMCIA Ethernet clean up # # Amiga PCMCIA Ethernet: Use le16_to_cpus() instead of hardcoded byteswap (from # Kars de Jong) # -------------------------------------------- # 03/03/20 geert@linux-m68k.org 1.889.1.265 # [PATCH] M68k ifpsp060 updates # # M68k: Remove .global for local labels that are used to subtract (needed for # recent binutils, from Andreas Schwab) # -------------------------------------------- # 03/03/20 geert@linux-m68k.org 1.889.1.266 # [PATCH] M68k syscall updates # # M68k syscalls: NR_syscalls updates for 2.5.63 # -------------------------------------------- # 03/03/20 geert@linux-m68k.org 1.889.1.267 # [PATCH] M68k: Signal updates # # M68k: Update for signal changes in 2.5.60 (from Roman Zippel). # -------------------------------------------- # 03/03/20 geert@linux-m68k.org 1.889.1.268 # [PATCH] M68k heartbeat update # # M68k: Heartbeat is also available on Apollo and Mac # -------------------------------------------- # 03/03/20 geert@linux-m68k.org 1.889.1.269 # [PATCH] M68k PAGE_SIZE warnings # # M68k: Make PAGE_SIZE unsigned long to kill more warnings (cfr. other # architectures), except for asm, since gas cannot cope with the UL. # -------------------------------------------- # 03/03/20 geert@linux-m68k.org 1.889.1.270 # [PATCH] Q40: local_irq*() update # # Q40: Replace sti() by local_irq_enable() in comment # -------------------------------------------- # 03/03/20 geert@linux-m68k.org 1.889.1.271 # [PATCH] ADB: Fix spelling of sigprocmask # # ADB: Fix spelling of sigprocmask # -------------------------------------------- # 03/03/20 geert@linux-m68k.org 1.889.1.272 # [PATCH] M68k Apollo I/O updates # # M68k Apollo I/O updates for MMIO and pseudo-MMIO (ISA I/O after translation): # - Use out_8() and out_be16() instead of outb() and outw() # - Remove conflicting definitions of {in,out}[bw]() # -------------------------------------------- # 03/03/20 geert@linux-m68k.org 1.889.1.273 # [PATCH] M68k gcc-3.2 warnings # # M68k: Kill warnings generated by gcc-3.2: # - Add missing include # - Move unused static data inside usage area # - Kill deprecated multi-line string literals # - Add semicolons to empty cases in switch() constructs # - Comment out unused labels # - Fix extra tokens at end of #endif directives # - a3000_release() may not be optimized away # - Kill uninitialized variable warning # -------------------------------------------- # 03/03/20 geert@linux-m68k.org 1.889.1.274 # [PATCH] M68k struct page fix # # M68k: Fix for changes to struct page -- access list member of structure # correctly (and allocate page tables sanely as a result) (from Sam Creasey) # -------------------------------------------- # 03/03/20 geert@linux-m68k.org 1.889.1.275 # [PATCH] IDE_ARCH_ACK_INTR duplicate # # ide_ack_intr is defined in asm-*/ide.h, if IDE_ARCH_ACK_INTR is set. # -------------------------------------------- # 03/03/20 geert@linux-m68k.org 1.889.1.276 # [PATCH] WD33c93 missing export # # Wd33c93 SCSI: Export wd33c93_proc_info (needed for Amiga A3000, A2091, and GVP # II SCSI, and for MVME147 SCSI). # -------------------------------------------- # 03/03/20 geert@linux-m68k.org 1.889.1.277 # [PATCH] M68k net warnings # # M68k net drivers: Kill warnings caused by implicit conversions from volatile * # -------------------------------------------- # 03/03/20 geert@linux-m68k.org 1.889.1.278 # [PATCH] M68k SCSI warnings # # M68k SCSI drivers: Kill warnings caused by implicit conversions from volatile * # and remove some unneeded casts # -------------------------------------------- # 03/03/20 geert@linux-m68k.org 1.889.1.279 # [PATCH] M68k NCR5380 SCSI updates # # M68k NCR5380 SCSI updates for changes in SCSI and NCR5380 SCSI layers: # - Sun-3/3x (from Sam Creasey) # - Atari (ported updates from Sun-3) # - Mac (ported updates from Sun-3) # -------------------------------------------- # 03/03/20 geert@linux-m68k.org 1.889.1.280 # [PATCH] Amiga serial updates # # Convert Amiga serial driver to use tasklets (from Roman Zippel) # -------------------------------------------- # 03/03/20 geert@linux-m68k.org 1.889.1.281 # [PATCH] Genrtc updates # # Genrtc: Sync generic RTC driver with 2.4.x. # -------------------------------------------- # 03/03/20 geert@linux-m68k.org 1.889.1.282 # [PATCH] M68k SCSI driver updates # # M68k SCSI drivers: update for the changes in 2.5.60: # o Replace `->lun' by `->device->lun' # o Replace `->target' by `->device->id' # o Replace `->host' by `->device->host' # -------------------------------------------- # 03/03/20 geert@linux-m68k.org 1.889.1.283 # [PATCH] Sun-3 linkfile fix # # Sun-3 linkfile: Fix vmlinux-sun3.lds to make it compile (this version also # loads properly through the 11/24/2001 bootloader) (from Sam Creasey) # -------------------------------------------- # 03/03/20 geert@linux-m68k.org 1.889.1.284 # [PATCH] Sun-3 memory zones # # Sun-3 memory zones: Mark all pages in zone 0, rather than splitting memory # evenly between zones (from Sam Creasey) # -------------------------------------------- # 03/03/20 geert@linux-m68k.org 1.889.1.285 # [PATCH] Sun-3 first page # # Sun-3: Properly calculate the physical address of the first virtual page # (0x0e000000) (from Sam Creasey) # -------------------------------------------- # 03/03/20 geert@linux-m68k.org 1.889.1.286 # [PATCH] Sun-3 NCR5380 SCSI warning # # Sun-3 NCR5380 SCSI: Kill warning. # -------------------------------------------- # 03/03/20 geert@linux-m68k.org 1.889.1.287 # [PATCH] Amiga NCR53c7xx SCSI: use z_ioremap() # # Amiga NCR53c7xx SCSI: Use z_ioremap() to map Zorro space # -------------------------------------------- # 03/03/20 geert@linux-m68k.org 1.889.1.288 # [PATCH] Amifb wrong interrupt # # Amiga frame buffer device: request the correct interrupt, so we no longer get # spurious interrupts. The old code worked only by accident. # # To avoid flicker when updating the display parameters, we do not use the real # vertical blank interrupt, but instead ask the Copper to generate an interrupt # after the bitplane and sprite pointers have been set up at the beginning of # each frame. # -------------------------------------------- # 03/03/20 geert@linux-m68k.org 1.889.1.289 # [PATCH] Amiga RTC updates # # Amiga RTC updates from Kars de Jong : # - Implement mach_get_ss() on Amiga # - Use OKI recommendations for locking the A2000 clock # - Streamline clock structure declarations # -------------------------------------------- # 03/03/20 geert@linux-m68k.org 1.889.1.290 # [PATCH] wd33c93 SCSI merge error # # Wd33c93 SCSI: Fix 2.5.64 merge error # -------------------------------------------- # 03/03/20 geert@linux-m68k.org 1.889.1.291 # [PATCH] Sun-3 NCR5380 SCSI printk tags # # Sun-3 NCR5380 SCSI: Re-add accidentally deleted KERN_DEBUG tags. # -------------------------------------------- # 03/03/20 geert@linux-m68k.org 1.889.1.292 # [PATCH] M68k core spelling fixes # # M68k core spelling fixes from Steven Cole # -------------------------------------------- # 03/03/20 geert@linux-m68k.org 1.889.1.293 # [PATCH] Affs sizeof() # # Affs: Make sure the sizeof() is always correct (from Roman Zippel) # -------------------------------------------- # 03/03/20 geert@linux-m68k.org 1.889.1.294 # [PATCH] M68k timekeeping update # # M68k timekeeping: Do not update the RTC every 11 minutes, since this confuses # NTP (the actual code has been commented out since a while). # -------------------------------------------- # 03/03/20 geert@linux-m68k.org 1.889.1.295 # [PATCH] console_initcall() return type # # Fix return type (must be int, not void) of *_console_init() after introduction # of console_initcall() in 2.5.x. # -------------------------------------------- # 03/03/20 geert@linux-m68k.org 1.889.1.296 # [PATCH] Port amifb to new fbdev API # # Amiga frame buffer device: Port to the new fbdev API # -------------------------------------------- # 03/03/20 geert@linux-m68k.org 1.889.1.297 # [PATCH] Amiflop mod_timer() # # Amiga floppy driver: Convert {del,add}_timer() sequences to mod_timer(). # -------------------------------------------- # 03/03/20 neilb@cse.unsw.edu.au 1.889.1.298 # [PATCH] Fix a few MD bugs # # 1/ set new MD_RECOVERY_INTR flag instead of old 'err = -EINTR' # when a resync thread is signaled - get rid of 'err' altogether in # md_do_sync # 2/ raid1 determines if resync is needed based on recovery_cp # rather than mddev->in_sync (which now has a very different meaning) # 3/ Don't update superblock when switching to writable mode. The # first write will update the superblock instead. # -------------------------------------------- # 03/03/21 paulus@samba.org 1.889.1.299 # Merge samba.org:/home/paulus/kernel/linux-2.5 # into samba.org:/home/paulus/kernel/for-linus-ppc # -------------------------------------------- # 03/03/21 hch@hera.kernel.org 1.889.354.1 # Merge hera.kernel.org:/home/torvalds/BK/linux-2.5 # into hera.kernel.org:/home/hch/BK/xfs/linux-2.5 # -------------------------------------------- # 03/03/21 torvalds@home.transmeta.com 1.889.355.1 # Fix sound driver timeout types. Again. # -------------------------------------------- # 03/03/21 jsimmons@kozmo.(none) 1.969 # [FBCON] Nuked the final gloabl variables for the cursor code. # # {GENERIC CURSOR] Wrongly using the size of the passed in cursor instead of the local cursor in struct fb_info. # -------------------------------------------- # 03/03/21 jsimmons@kozmo.(none) 1.970 # Merge # -------------------------------------------- # 03/03/21 alan@hraefn.swansea.linux.org.uk 1.889.355.2 # [PATCH] Remove NO_VERSION from S390x exec32 # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.3 # [PATCH] __NO_VERSION_ for ati_pcigart # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.4 # [PATCH] __NO_VERSION__ for used bits of dri # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.5 # [PATCH] __NO_VERSION__ for ftape # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.6 # [PATCH] Move ipmi to new struct stuff # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.7 # [PATCH] fix bogus C in ite_gpio # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.8 # [PATCH] merge lp driver for PC98xx systems # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.9 # [PATCH] remove ifs from ancient backcompat in mwave driver # # Also add warning about a broken spinlock/sleep someone still has to fix # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.10 # [PATCH] rio __NO_VERSION__ # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.11 # [PATCH] newer boards put other hw at rtc + 0x08 # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.12 # [PATCH] real time clock support for PC9800 systems # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.13 # [PATCH] unbreak the acquirewdt # # This puts back a MOD_INC_USE which leaves a warning but means that the # driver doesnt now load/unload and disable the watchdog on a close # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.14 # [PATCH] fc4 doesnt need __NO_VERSION__ any more # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.15 # [PATCH] fix all the other watchdogs Dave's changes broke the same # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.16 # [PATCH] fix ide-geometry bogus printk level # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.17 # [PATCH] remove legacy probe code # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.18 # [PATCH] add hd98 driver (equivalent to hd.c for old PC9800) # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.19 # [PATCH] clean up ht6560 legacy ide driver # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.20 # [PATCH] module for legacy PC9800 ide # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.21 # [PATCH] remove old style probe from other legacy ide # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.22 # [PATCH] Update ide/legacy makefile to match changes # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.23 # [PATCH] fix proc handling in serverworks and sc1200 ide # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.24 # [PATCH] fix proc handling in sis, siimageand slc90e66 # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.25 # [PATCH] fix /proc handling in via82cxxx # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.26 # [PATCH] move mac-hid to C99 # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.27 # [PATCH] remove __NO_VERSION__ from radio drivers # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.28 # [PATCH] remove __NO_VERSION__ from saa7134 driver # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.29 # [PATCH] fix GTUNER on w9966 # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.30 # [PATCH] Fix i2o_scsi hang # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.31 # [PATCH] fix 3c501 typo # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.32 # [PATCH] remove unused ali-ircc variable # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.33 # [PATCH] sk98 typo fix # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.34 # [PATCH] typo fix for tulip # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.35 # [PATCH] fix pcmcia crash with hostap # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.36 # [PATCH] fix pcmcia __NO_VERSION__ # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.37 # [PATCH] pnpbios doesnt want __NO_VERSION__ # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.38 # [PATCH] fix bogus if in advansys driver # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.39 # [PATCH] fix time types in aha152x # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.40 # [PATCH] fix buffer overrun in aha1542 # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.41 # [PATCH] fix leak in cpqfc # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.42 # [PATCH] gdth update from Intel # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.43 # [PATCH] junkfilter sym53c41 # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.44 # [PATCH] PC9800 has a slight funny on 8250_pnp # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.45 # [PATCH] serial driver for PC9800 systems # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.46 # [PATCH] xjack memory leak fixes # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.47 # [PATCH] __NO_VERSION__ for autofs # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.48 # [PATCH] typo fix for befs # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.49 # [PATCH] remove __NO_VERSION__ in cifs # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.50 # [PATCH] typo fix for expfs # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.51 # [PATCH] fix fat handling of some weirder variants # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.52 # [PATCH] remove __NO_VERSION__ from intermezzo # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.53 # [PATCH] remove __NO_VERSION__ from intermezzo #2 # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.54 # [PATCH] remove __NO_VERSION__ from jffs # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.55 # [PATCH] remove __NO_VERSION__ from lockd # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.56 # [PATCH] Add NEC PC9800 partition tables # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.57 # [PATCH] remove __NO_VERSION__ from procfs # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.58 # [PATCH] Alpha folks said my change was wrong, revert it and note the funny # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.59 # [PATCH] add a new dmi flag for broken pnpbios # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.60 # [PATCH] add another clock tick rate variant # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.61 # [PATCH] add headers for upd4990a rtc/clock driver # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.62 # [PATCH] S/390 typo fixes # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.63 # [PATCH] Remove i2o pci abstractions # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.64 # [PATCH] update i2o build rules for change # # [Please also rm i2o_pci.c] # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.65 # [PATCH] remove __NO_VERSION__ in mtd # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.66 # [PATCH] kill off IDE_DEBUG, add pc9800 ide type # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.67 # [PATCH] update compaq idents, correct and update intel idents # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.68 # [PATCH] add pc9800 port types # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.69 # [PATCH] no arch specific headers for upd4990a # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.70 # [PATCH] update Achim's address # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.71 # [PATCH] fix typo in oom_kill # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.72 # [PATCH] tidy up make rpm # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.73 # [PATCH] fix typo in net/core/neighbour # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.74 # [PATCH] unless this is a backward spanish inquisition joke.. # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.75 # [PATCH] pc9800 CS4232 driver # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.76 # [PATCH] fix up opti92x-ad1848 # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.77 # [PATCH] clean up es968, fix build # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.78 # [PATCH] fix __NO_VERSION__ in audio_syms # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.79 # [PATCH] fix ";" in cs46xx # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.80 # [PATCH] fix i810 ifs # # [There are a ton of updates to pull from 2.4, but not yet merged] # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.81 # [PATCH] fix incorrect bracketing in maestro # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.82 # [PATCH] __NO_VERSION__ for midi_syms # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.83 # [PATCH] mpu401 uses __init vars during __exit # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.84 # [PATCH] more __NO_VERSION__ in audio # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.85 # [PATCH] update emu10k1 driver (SB Live, Audigy etc) # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.86 # [PATCH] update emu10k1 config help # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.87 # [PATCH] boot code for PC9800 systems # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.88 # [PATCH] handle exploding pnpbios # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.89 # [PATCH] add pc9800 setup and topology code # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.90 # [PATCH] Make pci-bios function ids per machine type # # Yes NEC use *different* function numbers!! # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.91 # [PATCH] arch pre/post setup for pc9800 # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.92 # [PATCH] PC9800 system common area definition # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.93 # [PATCH] sysfs typo fix # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.94 # [PATCH] remove odd blank line and add noacpi # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.95 # [PATCH] ide-default driver # # This is the first of a set of changes to make DRIVER(drive)!=NULL an # invariant # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.96 # [PATCH] __NO_VERSION__ for ide-lib # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.97 # [PATCH] ide-probe update # # Make drive->id not NULL an invariant # Clean up a few things from that # hwif specific queue length # initialisation/IRQ cleanups # # Note: this changes the default blocks limit per I/O to 256. I've still seen # no credible evidence that its a problem and "other OS's" do it. # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.98 # [PATCH] FOr efficient non posted I/O people need to know the target # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.99 # [PATCH] add __ide_set_handler to fix abort race # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.100 # [PATCH] use new outbsync when sending commands # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.101 # [PATCH] rework the reset code to fix posting and races # # This isnt perfect, there is a race left somewhere still but its closer. # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.102 # [PATCH] remove special cases from ide_proc # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.103 # [PATCH] update ide-tape to match changes # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.104 # [PATCH] printk, version etc for ide-taskfile # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.105 # [PATCH] ide should check dma_on # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.106 # [PATCH] update ide core # # - New style ide-default driver # - Don't attach non existant drives # - DRIVER()==NULL checks can go # - Ioctl checks that were missing are now in # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.107 # [PATCH] update ide-cd to new changes, add abort() handlers # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.108 # [PATCH] update ide-disk to changes, remove all the driver ifs # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.109 # [PATCH] update ide-dma support # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.110 # [PATCH] fix tuning of alim15x3 # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.111 # [PATCH] fix /proc for amd ide # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.112 # [PATCH] fix cmd640 ide locking # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.113 # [PATCH] fix more proc and other oddments # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.114 # [PATCH] add ICH5 and Centrino to PIIX4 # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.115 # [PATCH] add ide-default to the build # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.116 # [PATCH] fix aec proc handling # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.117 # [PATCH] remove __NO_VERSION__ from bttv # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.118 # [PATCH] remove lots of now dead code (no features though!) # # Also add abort functionality # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.119 # [PATCH] cpia -maintainers update # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.120 # [PATCH] remove __NO_VERSION__ from drm # -------------------------------------------- # 03/03/21 alan@lxorguk.ukuu.org.uk 1.889.355.121 # [PATCH] update ide headers to match changes # -------------------------------------------- # 03/03/21 torvalds@home.transmeta.com 1.889.354.2 # Merge ssh://master.kernel.org//home/hch/BK/xfs/linux-2.5/ # into home.transmeta.com:/home/torvalds/v2.5/linux # -------------------------------------------- # 03/03/21 mingo@elte.hu 1.889.354.3 # [PATCH] mm/swapfile.c manual reschedule # # fix yet another manual reschedule point # -------------------------------------------- # 03/03/21 hch@lst.de 1.889.354.4 # [PATCH] fix waitqueue leak in devfs_d_revalidate_wait # # devfs_d_revalidate_wait adds to a waitqueue but never removes from it # again so we there's one entry full of reused stack space added on # each call (I wonder how this ever worked). # # The function has a few more bugs (it effectivly does a sleep_on instead # of checking for the actual even and can't deal with negative dentries # at all), but I just had breakfast and don't want to poke into devfs # internals deeper - I still hope Adam's smalldevfs will get merged # anyway.. # -------------------------------------------- # 03/03/21 hch@lst.de 1.889.354.5 # [PATCH] rempove CONFIG_DVB_DEVFS_ONLY # # Adrian Bunk noticed that there's an exposed config option to use the # now gone DEVFS_FL_AUTO_DEVNUM in the dvb code - remove it. # -------------------------------------------- # 03/03/21 hch@lst.de 1.889.354.6 # [PATCH] make devfs_put() static to fs/devfs/base.c # # Not use anywhere else nor should it. # -------------------------------------------- # 03/03/21 hch@lst.de 1.889.354.7 # [PATCH] remove DEVFS_FL_REMOVABLE # # Devfs tries to be super smart and rereads partition tables at all # kinds of wierd points. This breaks a bunch of stuff were you # can't get the right disk changed information (i.e. CompactFlash). # # If people actually need this kind of stuff they should just call partx # from devfsd instead of relying on the kernel doing something like this. # # Cleans up the devfs code significatnly (aka removes tons of junk) # -------------------------------------------- # 03/03/21 hch@lst.de 1.889.354.8 # [PATCH] get rid of __MOD_INC_USE_COUNT/__MOD_DEC_USE_COUNT # # As the netfilter folks don't seem to have any interest in 2.5 currently # I decided to fix their last uses of those old module interfaces myself. # The implementation (get a reference first and release it again when # not actually needed) might be slightly suboptimial but the netfilter # team should just fix it if/when they get any interest in Linux 2.5/2.6. # # Also fix the MOD_INC_USE_COUNT/MOD_DEC_USE_COUNT to give more accurate # deprecation warnings. # -------------------------------------------- # 03/03/21 torvalds@home.transmeta.com 1.889.354.9 # Avoid warning with modern gcc's in xfrm_policy.c # -------------------------------------------- # 03/03/21 vandrove@vc.cvut.cz 1.889.354.10 # [PATCH] Fix ncpfs and rpcgss order in fs/Kconfig # # RPCSEC_GSS options are related to (only) nfs/nfsd, so it is # more logical to ask RPCSEC_GSS questions immediately after # nfs/nfsd, not after half of screen more questions. # # NCPFS related options should appear immediately below # ncpfs question, not after Coda and RPCSEC... # -------------------------------------------- # 03/03/22 paulus@samba.org 1.889.1.300 # Merge samba.org:/home/paulus/kernel/linux-2.5 # into samba.org:/home/paulus/kernel/for-linus-ppc # -------------------------------------------- # 03/03/22 ink@undisclosed.(none) 1.889.339.11 # [PCI] Don't call pci_update_resource() for bridge resources. # # Minor cleanup: don't call pci_update_resource() for bridges, # get rid of bogus "trying to set non-standard region" messages thus. # -------------------------------------------- # 03/03/22 ink@ru.rmk.(none) 1.889.339.12 # [PCI] Make setup-bus.c aware of cardbus bridges. # # Comments from rmk: # # Make setup-bus.c properly aware of cardbus bridges. We treat the # bus behind a cardbus bridge more or less like any other bus, except # we don't explicitly descend below. We do, however, explicitly # reserve IO and memory space as we have done in the past. Memory # space is doubed to 32MB as a measure to allow the Mobility # cardbus-pci stuff to work. The amount of space reserved is now # specified by a couple of #defines at the top of the file. # # This allows pci_bus_assign_resources() and pci_bus_size_bridges() # to be called for both root buses as well as cardbus secondary buses. # # Comments from Ivan follows: # # This patch combines your(rmk) cardbus changes (formerly pci-11) # and my "arbitrary resource layout" stuff. This + current bk works # on nautilus. # # Most interesting feature: this can be used on partially # allocated PCI tree. For instance, i386 PCI code has always been # absolutely helpless wrt incorrectly initialized p2p bridges. # Now it can just call pci_assign_unassigned_resources() in the # end of PCI init and it would fix following problems: # - completely uninitialized bridge windows (with base and limit 0); # - erroneously "closed" windows; # - windows overlapping with something else. # -------------------------------------------- # 03/03/22 ink@ru.rmk.(none) 1.889.339.13 # [PCI] Fix incorrect PCI cache line size assumptions. # # Fix incorrect PCI cache line size assumptions on i386 and thus # avoid potential memory corruption with Memory Write-and-Invalidate. # -------------------------------------------- # 03/03/22 jsimmons@maxwell.earthlink.net 1.971 # Merge maxwell.earthlink.net:/usr/src/linus-2.5 # into maxwell.earthlink.net:/usr/src/fbdev-2.5 # -------------------------------------------- # 03/03/22 randy.dunlap@verizon.net 1.889.354.11 # [PATCH] reduce stack in cdrom/optcd.c # # This reduces stack usage in drivers/cdrom/optcd.c by # dynamically allocating a large (> 2 KB) buffer. # -------------------------------------------- # 03/03/22 randy.dunlap@verizon.net 1.889.354.12 # [PATCH] reduce stack in wireless/airo.c # # This reduces stack usage in drivers/net/wireless/airo.c by # dynamically allocating 2KB buffers in 2 places. # -------------------------------------------- # 03/03/22 rmk@flint.arm.linux.org.uk 1.889.346.12 # [ARM] Remove head-netwinder.S # # head-netwinder.S was a work around for old Netwinder NeTTrom # firmware. It is no longer required. # -------------------------------------------- # 03/03/22 scott.feldman@intel.com 1.889.354.13 # [E1000] Increase default Rx descriptors to 256 # # * Increase default Rx descriptors from 80 to 256 to give # better Rx buffering capability in the case of heavy # Rx load with small packets. # -------------------------------------------- # 03/03/22 jgarzik@redhat.com 1.889.354.14 # [via-rhine] note that Roger is maintainer, in MAINTAINERS # -------------------------------------------- # 03/03/23 paulus@samba.org 1.889.1.301 # Merge samba.org:/home/paulus/kernel/linux-2.5 # into samba.org:/home/paulus/kernel/for-linus-ppc # -------------------------------------------- # 03/03/23 paulus@samba.org 1.889.1.302 # PPC32: Fix asm/rtc.h so drivers/char/genrtc.c compiles. # -------------------------------------------- # 03/03/23 paulus@samba.org 1.889.1.303 # PPC32: Convert uses of ide_ioreg_t to unsigned long. # -------------------------------------------- # 03/03/23 acurtis@onz.com 1.889.1.304 # PPC32: Updates for the 8260 embedded processor and the EST and TQM boards # -------------------------------------------- # 03/03/23 paulus@samba.org 1.889.1.305 # PPC32: Fix ide_init_hwif_ports for powermac. # -------------------------------------------- # 03/03/22 torvalds@home.transmeta.com 1.889.356.1 # Merge bk://bk.arm.linux.org.uk/linux-2.5-rmk # into home.transmeta.com:/home/torvalds/v2.5/linux # -------------------------------------------- # 03/03/22 torvalds@home.transmeta.com 1.889.356.2 # Merge bk://bk.arm.linux.org.uk/linux-2.5-pci # into home.transmeta.com:/home/torvalds/v2.5/linux # -------------------------------------------- # 03/03/22 torvalds@home.transmeta.com 1.889.354.15 # Merge bk://kernel.bkbits.net/jgarzik/net-drivers-2.5 # into home.transmeta.com:/home/torvalds/v2.5/linux # -------------------------------------------- # 03/03/22 alan@lxorguk.ukuu.org.uk 1.889.354.16 # [PATCH] redo the n_tty fix # # Two problems with the original change # # 1. We should return bytes actually processed on an error according to # SuS/POSIX. Technically the EFAULT path is outside the spec but its best # we follow # # 2. We need to fix most of this anyway because the final section of the # change was wrong. If retval was set we retried and got an efault again # in some cases # # I think this way of doing it is right but it could do with further # review # -------------------------------------------- # 03/03/22 alan@lxorguk.ukuu.org.uk 1.889.354.17 # [PATCH] make opl3sa2 build again # -------------------------------------------- # 03/03/22 alan@lxorguk.ukuu.org.uk 1.889.354.18 # [PATCH] clean up the mess someone merged into 3wxxx scsi # # - Redo the timing stuff using jiffies properly # - Clean up the exit paths # - Make the ioctl use a semaphore # - Fix broken locking on the AEN list # -------------------------------------------- # 03/03/22 alan@lxorguk.ukuu.org.uk 1.889.354.19 # [PATCH] abstract out mach_reboot for x86 platforms # -------------------------------------------- # 03/03/22 alan@lxorguk.ukuu.org.uk 1.889.354.20 # [PATCH] use right object for i2o_config - kernel not user copy # -------------------------------------------- # 03/03/22 alan@lxorguk.ukuu.org.uk 1.889.354.21 # [PATCH] add checks to pc9800 ide reserve # -------------------------------------------- # 03/03/22 alan@lxorguk.ukuu.org.uk 1.889.354.22 # [PATCH] ide typo fixes #3 # # I'm looking into the other IDE problem from the merge - several people # see hangs. Bartolomiej has found one suspicious looking candidate. I'll # try and pin it down ASAP. # -------------------------------------------- # 03/03/22 alan@lxorguk.ukuu.org.uk 1.889.354.23 # [PATCH] Merge PC9800 keyboard driver # -------------------------------------------- # 03/03/22 alan@lxorguk.ukuu.org.uk 1.889.354.24 # [PATCH] ide typo fixes #2 # -------------------------------------------- # 03/03/22 alan@lxorguk.ukuu.org.uk 1.889.354.25 # [PATCH] i2o_pci is dead # -------------------------------------------- # 03/03/22 alan@lxorguk.ukuu.org.uk 1.889.354.26 # [PATCH] parallel port # -------------------------------------------- # 03/03/22 alan@lxorguk.ukuu.org.uk 1.889.354.27 # [PATCH] merge PC9800 keyboard controller chip support # -------------------------------------------- # 03/03/22 alan@lxorguk.ukuu.org.uk 1.889.354.28 # [PATCH] merge PC9800 mouse driver # -------------------------------------------- # 03/03/22 alan@lxorguk.ukuu.org.uk 1.889.354.29 # [PATCH] ide typo fixes # -------------------------------------------- # 03/03/22 alan@lxorguk.ukuu.org.uk 1.889.354.30 # [PATCH] eisa reports "0 device" not "0 devices" # # Since it gets 1 device right it wasnt hard to fix 8) # -------------------------------------------- # 03/03/22 torvalds@home.transmeta.com 1.889.354.31 # Alan broke the build. Fix it thusly. # -------------------------------------------- # 03/03/22 torvalds@penguin.transmeta.com 1.972 # Merge http://fbdev.bkbits.net/fbdev-2.5 # into penguin.transmeta.com:/home/penguin/torvalds/repositories/kernel/linux # -------------------------------------------- # 03/03/22 linux@brodo.de 1.973 # [PATCH] pcmcia: check return values of driver_register # -------------------------------------------- # 03/03/22 linux@brodo.de 1.974 # [PATCH] pcmcia: add bus_type pcmcia_bus_type # # Register a bus_type pcmcia_bus_type. This means the initialization of # the ds module needs to be done in two levels: one quite early # (subsys_initcall) so that drivers may use the bus_type; the other one # must stay that late (late_initcall). As only one initcall can be # specified within one module, some tweaking is needed. # -------------------------------------------- # 03/03/22 linux@brodo.de 1.975 # [PATCH] pcmcia: register drivers with bus # # Register all pcmcia drivers with the pcmcia bus within the old # register_pccard_driver() function. Alternatively, a new # registration function "pcmcia_register_driver()" (and its # counterpart, "pcmcia_unregister_driver()") can be used. # -------------------------------------------- # 03/03/22 linux@brodo.de 1.976 # [PATCH] pcmcia: remove single linked list of drivers # # Remove the linked list of pcmcia_drivers. It didn't even handle removal of a # driver properly, so it won't be missed all that much. # -------------------------------------------- # 03/03/22 linux@brodo.de 1.977 # [PATCH] pcmcia: convert pccard_cs driver to new registration interface # # Convert the pcnet_cs driver to use the new registration call. # -------------------------------------------- # 03/03/23 acurtis@onz.com 1.889.1.306 # PPC32: Further 8260 update; one file was missed in the previous commit. # -------------------------------------------- # 03/03/22 torvalds@home.transmeta.com 1.978 # Merge bk://ppc.bkbits.net/for-linus-ppc # into home.transmeta.com:/home/torvalds/v2.5/linux # -------------------------------------------- # 03/03/22 paulus@samba.org 1.979 # [PATCH] update macintosh-specific headers # # This patch updates include/linux/adb.h and include/linux/pmu.h with # some additional definitions that we need on powermacs and powerbooks. # -------------------------------------------- # 03/03/22 paulus@samba.org 1.980 # [PATCH] update via-cuda driver # # This patch updates the CUDA driver (the power/reset/ADB controller on # older powermacs) to fix some SMP issues and to match the 2.4 version # of the driver. # # From Ben Herrenschmidt. # -------------------------------------------- # 03/03/22 paulus@samba.org 1.981 # [PATCH] SMP-safe macserial driver # # The patch below removes the uses of save_flags/restore_flags/cli # etc. from the macserial driver and replaces them with a spinlock. # -------------------------------------------- # 03/03/22 paulus@samba.org 1.982 # [PATCH] update via-pmu driver # # This patch forward-ports various fixes to the driver for the PMU # (power manager unit) on powermacs and powerbooks from 2.4, and in # particular, some improvements to the battery charge calculations. # # From Ben Herrenschmidt. # -------------------------------------------- # 03/03/22 paulus@samba.org 1.983 # [PATCH] update MESH scsi driver # # This patch updates the `mesh' scsi driver used on older powermacs to # correspond with recent changes in the scsi subsystem (things like # using cmd->device->id instead of cmd->target). # -------------------------------------------- # 03/03/22 paulus@samba.org 1.984 # [PATCH] update mac53c94 scsi driver # # This patch updates the mac53c94 scsi HBA driver, used on older # powermacs, to correspond with the recent scsi subsystem changes, to # use the PCI DMA API, to not panic, and to use a spinlock instead of # save_flags/restore_flags/cli/sti. # -------------------------------------------- # 03/03/22 paulus@samba.org 1.985 # [PATCH] fix powerbook media bay # # This patch fixes a couple of bugs and compile errors in the powerbook # media bay driver. It was getting initialized after the IDE subsystem, # whereas it needs to be initialized before so that the IDE subsystem # can see the CD-ROM drive in the bay. # -------------------------------------------- # 03/03/22 akpm@digeo.com 1.986 # [PATCH] Make nonlinear mappings fully pageable # # This patch requires arch support. I have patches for ia32, ppc64 and x86_64. # Other architectures will break. It is a five-minute fix. See # # http://mail.nl.linux.org/linux-mm/2003-03/msg00174.html # # for implementation details. # # # Patch from: Ingo Molnar # # the attached patch, against BK-curr, is a preparation to make # remap_file_pages() usable on swappable vmas as well. When 'swapping out' # shared-named mappings the page offset is written into the pte. # # it takes one bit from the swap-type bits, otherwise it does not change the # pte layout - so it should be easy to adapt any other architecture to this # change as well. (this patch does not introduce the protection-bits-in-pte # approach used in my previous patch.) # # On 32-bit pte sizes with an effective usable pte range of 29 bits, this # limits mmap()-able file size to 4096 * 2^29 == 2 TBs. If the usable range is # smaller, then the maximum mmap() size is reduced as well. The worst-case i # found (PPC) was 2 hw-reserved bits in the swap-case, which limits us to 1 TB # filesize. Is there any other hw that has an even worse ratio of sw-usable # pte bits? # # this mmap() limit can be eliminated by simply not converting the swapped out # pte to a file-pte, but clearning it and falling back to the linear mapping # upon swapin. This puts the limit into remap_file_pages() alone, but i really # hope no-one wants to use remap_file_pages() on a 32-bit platform, on a larger # than 1-2 TB file. # # sys_remap_file_pages() is now enforcing the 'prot' parameter to be zero. # This restriction might be lifted in the future - i really hope we can have # more flexible remapping once 64-bit platforms are commonplace - eg. things # like memory debuggers could just use the permission bits directly, instead of # creating many small vmas. # # i've tested swappable nonlinear ptes and they are swapped out/in # correctly. # # some other changes in -A0 relative to 2.5.63-BK: # # - slightly smarter TLB flushing in install_page(). This is still only a # stupid helper functions - a more efficient 'walk the pagecache tree # and pagetable at once and use TLB-gather' implementation is preferred. # # - cleanup: pass on pgprot_t instead of unsigned long prot. # # - some sanity checks to make sure file_pte() rules are followed. # # - do not reduce the vma's default protection to PROT_NONE when using # remap_file_pages() on it. With swappable ptes this is now safe. # -------------------------------------------- # 03/03/22 akpm@digeo.com 1.987 # [PATCH] filemap_populate speedup # # filemap_populate() is currently doing page-at-a-time synchronous I/O. Add a # call to do_page_cache_readahead() in there so we do a big slurp of IO first. # # This is minimal - a lot of the filemap_populate() code can be # rationalised yet. # -------------------------------------------- # 03/03/22 akpm@digeo.com 1.988 # [PATCH] x86_64: support for file offsets in pte's # # Path from Andi Kleen # # Add x86_64 support for file offsets in pte's. # -------------------------------------------- # 03/03/22 akpm@digeo.com 1.989 # [PATCH] ppc64 support for file file-offset-in-pte # # ppc64 support for file file-offset-in-pte # -------------------------------------------- # 03/03/22 akpm@digeo.com 1.990 # [PATCH] inode a/c/mtime modification speedup # # For some filesystems (ext3, reiserfs at least), ->dirty_inode() is very # expensive. The kernel is currently calling mark_inode_dirty() at up to 1000 # times/sec/inode. But there is no need to do this if the filesystem cannot # store high-resolution times on-disk. # # This patch restores the optimisation of only dirtying the filesystem inode # when its on-disk representation has actually changed. # # The filesystem will set the MS_ONE_SECOND flag in sb->s_flags to indicate # that it wishes to receive this treatment. # # The patch does reduce the call rate to ext3_mark_inode_dirty() from 1000/sec # to 1/sec, but it doesn't make much difference at all to performance because # we're calling ext3_mark_inode_dirty() from other callsites as well. Those # can be optimised too. # -------------------------------------------- # 03/03/22 akpm@digeo.com 1.991 # [PATCH] Implement a/c/time speedup in ext2 & ext3 # # Turn on MS_ONE_SECOND in ext2 and ext3. # -------------------------------------------- # 03/03/22 akpm@digeo.com 1.992 # [PATCH] remove lock_kernel() from inode_setattr's # # vmtruncate() does not need lock_kernel(). And lock_kernel() is not taken by # other vmtruncate() callers. # -------------------------------------------- # 03/03/22 akpm@digeo.com 1.993 # [PATCH] speed up vm_enough_memory() # # This function is called a lot. Every brk(). The atomic_add() against a # global counter hurts on large SMP machines. # # The patch simply reduces the rate at which that atomic operation is # performed, by accumulating a per-cpu count which is spilled into the global # counter when the local counter overflows. # # It trades off efficiency for a little inaccuracy. # # I tried various implementations involving kmalloc_percpu() and open-coded # per-cpu arrays in a generic "per-cpu counter" thing. They all were # surprisingly sucky - the additional cache misses involved in walking the more # complex data structures really showed up. # -------------------------------------------- # 03/03/22 akpm@digeo.com 1.994 # [PATCH] remove lock_kernel() from readdir implementations. # # Filesystems which are using generic_file_llseek() do not need lock_kernel() # in their readir implementations. All operations (including llseek) are # serialised by the directory's i_sem. # # Just fix ext2 and ext3 for now. Others may need locking between readdir and # who-knows-what. # -------------------------------------------- # 03/03/22 akpm@digeo.com 1.995 # [PATCH] __bdevname atomicity fix # # This function was recently converted to use rwsem locking. But it is called # from interrupts in (at least) buffer_io_error(). # # And we do want a function like this to be robust and atomic. So convert it # to use spinlocking. # -------------------------------------------- # 03/03/22 akpm@digeo.com 1.996 # [PATCH] register_blkdev() fixes # # - It was racy, if two threads try to register a blockdev with major=0 they # could both choose the same major for different devices. # # Fix that by extending the coverage of the rwsem. # # - kmalloced local variable `p' was leaking on an error path. # -------------------------------------------- # 03/03/22 akpm@digeo.com 1.997 # [PATCH] make the bdevname() API sane # # bdevname returns a pointer to a static string. Change it so that the caller # passes in the buffer. # -------------------------------------------- # 03/03/22 akpm@digeo.com 1.998 # [PATCH] mwave oops fixes # # The mwave driver oopses if you do not have the hardware installed. It is # running device_unregister() and device_remove_file() against things whch were # never created. # -------------------------------------------- # 03/03/22 akpm@digeo.com 1.999 # [PATCH] dev_t [1/3]: kill cdev # # Patch from Andries.Brouwer@cwi.nl # # Now that 2.5.65 is out, the next dev_t patch. It was a bit large and # unreadable, so I split it into three clean pieces. Afterwards, since many # people ask for this, a fourth patch that actually changes the type of dev_t # (not to be applied yet, that is just for playing). # # The first patch is the cdev-kill patch that I sent out earlier. It is no use # having two forms of chardev registration in the source, and my version of the # path of small modifications does not pass through this version, although the # final result will not be that different. So, kill cdev_cachep, # cdev_cache_init, cdfind, cdget, cdput, inode->i_cdev, struct char_device. # All of this is dead code today. # # The second patch removes MAX_CHRDEV. # # The third patch polishes linux/major.h. # -------------------------------------------- # 03/03/22 akpm@digeo.com 1.1000 # [PATCH] dev_t [2/3] - remove MAX_CHRDEV # # Patch from Andries.Brouwer@cwi.nl # # The actual patch for today is this part. I already quoted most of this on # the list earlier this week. # # In order not to have to change all drivers, I did # # +int register_chrdev(unsigned int major, const char *name, # + struct file_operations *fops) # +{ # + return register_chrdev_region(major, 0, 256, name, fops); # +} # # so that the old register_chrdev registers a single major and 256 minors. # Later this can be changed (but see my letter to Al last week). # # The only driver that is tricky is the tty driver. Here some major cleanup # happened - all tty specific stuff disappeared from char_dev.c, and tty uses # the actual register_chrdev_region() call. # # There is a race in register_chrdev_region() that I did not worry about: when # two dynamic majors 0 are registered simultaneously, one of them will be first # and the other one gets -EBUSY. If this is a problem, the code there will # have to be uglified a little. I didn't do that because it disappears again # in a subsequent patch. # -------------------------------------------- # 03/03/22 akpm@digeo.com 1.1001 # [PATCH] dev_t [3/3]: major.h cleanups # # Patch from Andries.Brouwer@cwi.nl # # The third patch removes the last occurrences of MAX_BLKDEV and MAX_CHRDEV and # sorts the majors in major.h. It also updates the definition of # SCSI_DISK_MAJOR. # -------------------------------------------- # 03/03/22 akpm@digeo.com 1.1002 # [PATCH] timer simplification # # From: george anzinger # # Remove the `index' field from the timer structures. It contains the same # info as the timer_jiffies field. # # So just use the base->timer_jiffies field directly. # -------------------------------------------- # 03/03/22 akpm@digeo.com 1.1003 # [PATCH] simplify the timer lockup avoidance code # # From: george anzinger # # The recently-added code which avoids a lockup when a timer handler re-adds # the timer right now can be simplified. # # If we change __run_timers() to increment base->timer_jiffies _before_ running # the timers, then any re-additions will not be inserted in the list which # __run_timers is presently walking. # -------------------------------------------- # 03/03/22 akpm@digeo.com 1.1004 # [PATCH] pagecache accounting speedup # # From: Alex Tomas # # This is the second half of the vm_enough_memory() speedup. # # When overcommit_memory != 1, vm_enough_memory() calls get_page_state() to # calculate the amount of used pagecache. It does this on every call to # sys_brk(). # # get_page_state() is really expensive on SMP. # # So the patch arranges for pagecache accounting to be in a global atomic_t, # with per-cpu batching and approximate accounting to amortise the cost of the # global atomic. # # The nr_pagecache field of /proc/vmstat is removed. # -------------------------------------------- # 03/03/22 akpm@digeo.com 1.1005 # [PATCH] ext3: fix use-after-free bug # # ext3_writepage() calls ext3_journal_stop(), which dereferences the affected # inode. # # It does this _after_ writing the page out, which is illegal. The IO can # complete, the page can be repeased from the inode and the inode can be freed # up. # # It's a long-standing bug. It has been reported happening on preemptible # kernels, where the timing window is larger. # # Fix that up by teaching ext3_journal_stop to locate the superblock via the # journal structure, not via the inode. # # This means that ext3_journal_stop() does not need the inode argument at all. # # Also uninline the affected functions. It saves 5.5 kbytes. # # Also remove the setting of sb->s_dirt in ext3_journal_stop(). That was an # awkward way of telling sys_sync() that the filesystem needs a commit, and # with the ext3_sync_fs() that is no longer needed. # -------------------------------------------- # 03/03/22 akpm@digeo.com 1.1006 # [PATCH] make list.h barriers smp-only # # From: Dipankar Sarma # # This patch makes the list macros use smp-only version of the barriers, # no need to hurt UP performance. # -------------------------------------------- # 03/03/22 akpm@digeo.com 1.1007 # [PATCH] sync_filesystems commentary and latency fix # # - Add some commentary to this function # # - Add a mutex to prevent new callers of sync_filesytems() from DoSing # currently-running caller. # -------------------------------------------- # 03/03/22 akpm@digeo.com 1.1008 # [PATCH] fix .text.exit error in OSS awe_wave.c # # From: Adrian Bunk # # I got a .exit.text error in 2.5.65. # # The problem is that in sound/oss/awe_wave.c the __init function # _attach_awe calls the __exit function awe_release_region. # # The following patch that removes the __exit from awe_release_region # fixes it. # -------------------------------------------- # 03/03/22 akpm@digeo.com 1.1009 # [PATCH] Make arch-independent syscalls return long # # From: "Randy.Dunlap" # # Fix up various syscalls to return longs, as x86_64 and ia64 (at least) # require. # -------------------------------------------- # 03/03/22 akpm@digeo.com 1.1010 # [PATCH] More syscalls-returning-long # # From: Robert Love # # Additional work to make syscalls return longs. # -------------------------------------------- # 03/03/22 akpm@digeo.com 1.1011 # [PATCH] remove the "half of memory" limit on mlock() and # # It seems pretty pointless and people do complain about it occasionally. # -------------------------------------------- # 03/03/22 akpm@digeo.com 1.1012 # [PATCH] ptrace_notify() locking # # Spotted by Dawson Engler. # # recalc_signpending() needs tsk->sighand->siglock. # -------------------------------------------- # diff -Nru a/Documentation/DocBook/kernel-api.tmpl b/Documentation/DocBook/kernel-api.tmpl --- a/Documentation/DocBook/kernel-api.tmpl Sun Mar 23 00:22:49 2003 +++ b/Documentation/DocBook/kernel-api.tmpl Sun Mar 23 00:22:49 2003 @@ -89,7 +89,11 @@ Memory Management in Linux The Slab Cache !Emm/slab.c - + + User Space Memory Access +!Iinclude/asm-i386/uaccess.h +!Iarch/i386/lib/usercopy.c + diff -Nru a/Documentation/DocBook/kernel-hacking.tmpl b/Documentation/DocBook/kernel-hacking.tmpl --- a/Documentation/DocBook/kernel-hacking.tmpl Sun Mar 23 00:22:53 2003 +++ b/Documentation/DocBook/kernel-hacking.tmpl Sun Mar 23 00:22:53 2003 @@ -319,7 +319,7 @@ -asmlinkage int sys_mycall(int arg) +asmlinkage long sys_mycall(int arg) { return 0; } diff -Nru a/Documentation/fb/cirrusfb.txt b/Documentation/fb/cirrusfb.txt --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/Documentation/fb/cirrusfb.txt Sun Mar 23 00:22:50 2003 @@ -0,0 +1,97 @@ + + Framebuffer driver for Cirrus Logic chipsets + Copyright 1999 Jeff Garzik + + + +{ just a little something to get people going; contributors welcome! } + + + +Chip families supported: + SD64 + Piccolo + Picasso + Spectrum + Alpine (GD-543x/4x) + Picasso4 (GD-5446) + GD-5480 + Laguna (GD-546x) + +Bus's supported: + PCI + Zorro + +Architectures supported: + i386 + Alpha + PPC (Motorola Powerstack) + m68k (Amiga) + + + +Default video modes +------------------- +At the moment, there are two kernel command line arguments supported: + +mode:640x480 +mode:800x600 + or +mode:1024x768 + +Full support for startup video modes (modedb) will be integrated soon. + +Version 1.9.9.1 +--------------- +* Fix memory detection for 512kB case +* 800x600 mode +* Fixed timings +* Hint for AXP: Use -accel false -vyres -1 when changing resolution + + +Version 1.9.4.4 +--------------- +* Preliminary Laguna support +* Overhaul color register routines. +* Associated with the above, console colors are now obtained from a LUT + called 'palette' instead of from the VGA registers. This code was + modeled after that in atyfb and matroxfb. +* Code cleanup, add comments. +* Overhaul SR07 handling. +* Bug fixes. + + +Version 1.9.4.3 +--------------- +* Correctly set default startup video mode. +* Do not override ram size setting. Define + CLGEN_USE_HARDCODED_RAM_SETTINGS if you _do_ want to override the RAM + setting. +* Compile fixes related to new 2.3.x IORESOURCE_IO[PORT] symbol changes. +* Use new 2.3.x resource allocation. +* Some code cleanup. + + +Version 1.9.4.2 +--------------- +* Casting fixes. +* Assertions no longer cause an oops on purpose. +* Bug fixes. + + +Version 1.9.4.1 +--------------- +* Add compatibility support. Now requires a 2.1.x, 2.2.x or 2.3.x kernel. + + +Version 1.9.4 +------------- +* Several enhancements, smaller memory footprint, a few bugfixes. +* Requires kernel 2.3.14-pre1 or later. + + +Version 1.9.3 +------------- +* Bundled with kernel 2.3.14-pre1 or later. + + diff -Nru a/Documentation/fb/clgenfb.txt b/Documentation/fb/clgenfb.txt --- a/Documentation/fb/clgenfb.txt Sun Mar 23 00:22:50 2003 +++ /dev/null Wed Dec 31 16:00:00 1969 @@ -1,97 +0,0 @@ - - Framebuffer driver for Cirrus Logic chipsets - Copyright 1999 Jeff Garzik - - - -{ just a little something to get people going; contributors welcome! } - - - -Chip families supported: - SD64 - Piccolo - Picasso - Spectrum - Alpine (GD-543x/4x) - Picasso4 (GD-5446) - GD-5480 - Laguna (GD-546x) - -Bus's supported: - PCI - Zorro - -Architectures supported: - i386 - Alpha - PPC (Motorola Powerstack) - m68k (Amiga) - - - -Default video modes -------------------- -At the moment, there are two kernel command line arguments supported: - -mode:640x480 -mode:800x600 - or -mode:1024x768 - -Full support for startup video modes (modedb) will be integrated soon. - -Version 1.9.9.1 ---------------- -* Fix memory detection for 512kB case -* 800x600 mode -* Fixed timings -* Hint for AXP: Use -accel false -vyres -1 when changing resolution - - -Version 1.9.4.4 ---------------- -* Preliminary Laguna support -* Overhaul color register routines. -* Associated with the above, console colors are now obtained from a LUT - called 'palette' instead of from the VGA registers. This code was - modeled after that in atyfb and matroxfb. -* Code cleanup, add comments. -* Overhaul SR07 handling. -* Bug fixes. - - -Version 1.9.4.3 ---------------- -* Correctly set default startup video mode. -* Do not override ram size setting. Define - CLGEN_USE_HARDCODED_RAM_SETTINGS if you _do_ want to override the RAM - setting. -* Compile fixes related to new 2.3.x IORESOURCE_IO[PORT] symbol changes. -* Use new 2.3.x resource allocation. -* Some code cleanup. - - -Version 1.9.4.2 ---------------- -* Casting fixes. -* Assertions no longer cause an oops on purpose. -* Bug fixes. - - -Version 1.9.4.1 ---------------- -* Add compatibility support. Now requires a 2.1.x, 2.2.x or 2.3.x kernel. - - -Version 1.9.4 -------------- -* Several enhancements, smaller memory footprint, a few bugfixes. -* Requires kernel 2.3.14-pre1 or later. - - -Version 1.9.3 -------------- -* Bundled with kernel 2.3.14-pre1 or later. - - diff -Nru a/Documentation/fb/matroxfb.txt b/Documentation/fb/matroxfb.txt --- a/Documentation/fb/matroxfb.txt Sun Mar 23 00:22:55 2003 +++ b/Documentation/fb/matroxfb.txt Sun Mar 23 00:22:55 2003 @@ -22,11 +22,11 @@ How to use it? ============== -Switching modes is done using the video=matrox:vesa:... boot parameter +Switching modes is done using the video=matroxfb:vesa:... boot parameter or using `fbset' program. If you want, for example, enable a resolution of 1280x1024x24bpp you should -pass to the kernel this command line: "video=matrox:vesa:0x1BB". +pass to the kernel this command line: "video=matroxfb:vesa:0x1BB". You should compile in both vgacon (to boot if you remove you Matrox from box) and matroxfb (for graphics mode). You should not compile-in vesafb @@ -73,7 +73,7 @@ with your old number passed to vesafb. Non-listed number can be achieved by more complicated command-line, for -example 1600x1200x32bpp can be specified by `video=matrox:vesa:0x11C,depth:32'. +example 1600x1200x32bpp can be specified by `video=matroxfb:vesa:0x11C,depth:32'. X11 @@ -106,7 +106,7 @@ ============= You can pass kernel command line options to matroxfb with -`video=matrox:option1,option2:value2,option3' (multiple options should be +`video=matroxfb:option1,option2:value2,option3' (multiple options should be separated by comma, values are separated from options by `:'). Accepted options: @@ -116,7 +116,7 @@ memory usable for on-screen display (i.e. max. 8 MB). disabled - do not load driver; you can use also `off', but `disabled' is here too. -enabled - load driver, if you have `video=matrox:disabled' in LILO +enabled - load driver, if you have `video=matroxfb:disabled' in LILO configuration, you can override it by this (you cannot override `off'). It is default. noaccel - do not use acceleration engine. It does not work on Alphas. @@ -380,7 +380,7 @@ XFree when secondary head used to use acceleration. + secondary head always powerups in 640x480@60-32 videomode. You have to use fbset to change this mode. - + secondary head always powerups in monitor mode. You have to use matroxset + + secondary head always powerups in monitor mode. You have to use fbmatroxset to change it to TV mode. Also, you must select at least 525 lines for NTSC output and 625 lines for PAL output. + kernel is not fully multihead ready. So some things are impossible to do. diff -Nru a/Documentation/fb/pvr2fb.txt b/Documentation/fb/pvr2fb.txt --- a/Documentation/fb/pvr2fb.txt Sun Mar 23 00:22:52 2003 +++ b/Documentation/fb/pvr2fb.txt Sun Mar 23 00:22:52 2003 @@ -22,7 +22,7 @@ ============= You can pass kernel command line options to pvr2fb with -`video=pvr2:option1,option2:value2,option3' (multiple options should be +`video=pvr2fb:option1,option2:value2,option3' (multiple options should be separated by comma, values are separated from options by `:'). Accepted options: diff -Nru a/Documentation/fb/sa1100fb.txt b/Documentation/fb/sa1100fb.txt --- a/Documentation/fb/sa1100fb.txt Sun Mar 23 00:22:53 2003 +++ b/Documentation/fb/sa1100fb.txt Sun Mar 23 00:22:53 2003 @@ -11,7 +11,7 @@ For most common passive displays, giving the option -video=sa1100:bpp:,lccr0:,lccr1:,lccr2:,lccr3: +video=sa1100fb:bpp:,lccr0:,lccr1:,lccr2:,lccr3: on the kernel command line should be enough to configure the controller. The bits per pixel (bpp) value should be 4, 8, 12, or diff -Nru a/Documentation/fb/tgafb.txt b/Documentation/fb/tgafb.txt --- a/Documentation/fb/tgafb.txt Sun Mar 23 00:22:56 2003 +++ b/Documentation/fb/tgafb.txt Sun Mar 23 00:22:56 2003 @@ -36,7 +36,7 @@ ============= You can pass kernel command line options to tgafb with -`video=tga:option1,option2:value2,option3' (multiple options should be +`video=tgafb:option1,option2:value2,option3' (multiple options should be separated by comma, values are separated from options by `:'). Accepted options: diff -Nru a/Documentation/fb/vesafb.txt b/Documentation/fb/vesafb.txt --- a/Documentation/fb/vesafb.txt Sun Mar 23 00:22:54 2003 +++ b/Documentation/fb/vesafb.txt Sun Mar 23 00:22:54 2003 @@ -112,9 +112,9 @@ seems not to work with some BIOS versions, but there are options to turn it on. -You can pass options to vesafb using "video=vesa:option" on +You can pass options to vesafb using "video=vesafb:option" on the kernel command line. Multiple options should be separated -by comma, like this: "video=vesa:ypan,invers" +by comma, like this: "video=vesafb:ypan,invers" Accepted options: diff -Nru a/Documentation/filesystems/sysfs.txt b/Documentation/filesystems/sysfs.txt --- a/Documentation/filesystems/sysfs.txt Sun Mar 23 00:22:50 2003 +++ b/Documentation/filesystems/sysfs.txt Sun Mar 23 00:22:50 2003 @@ -60,7 +60,7 @@ you publically humiliated and your code rewritten without notice. -An attriubte definition is simply: +An attribute definition is simply: struct attribute { char * name; @@ -261,7 +261,7 @@ that point to the device's directory under root/. drivers/ contains a directory for each device driver that is loaded -for devices on that particular bus (this assmumes that drivers do not +for devices on that particular bus (this assumes that drivers do not span multiple bus types). diff -Nru a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt --- a/Documentation/kernel-parameters.txt Sun Mar 23 00:22:56 2003 +++ b/Documentation/kernel-parameters.txt Sun Mar 23 00:22:56 2003 @@ -713,7 +713,6 @@ numbers ourselves, overriding whatever the firmware may have done. - usepirqmask [IA-32] Honor the possible IRQ mask stored in the BIOS $PIR table. This is needed on some systems with broken @@ -721,6 +720,7 @@ and Omnibook XE3 notebooks. This will have no effect if ACPI IRQ routing is enabled. + noacpi [IA-32] Do not use ACPI for IRQ routing. pcmv= [HW,PCMCIA] BadgePAD 4 diff -Nru a/Documentation/networking/e100.txt b/Documentation/networking/e100.txt --- a/Documentation/networking/e100.txt Sun Mar 23 00:22:55 2003 +++ b/Documentation/networking/e100.txt Sun Mar 23 00:22:55 2003 @@ -1,7 +1,7 @@ Linux* Base Driver for the Intel(R) PRO/100 Family of Adapters ============================================================== -September 16, 2002 +November 19, 2002 Contents @@ -19,7 +19,7 @@ =============== This file describes the Linux* Base Driver for the Intel(R) PRO/100 Family of -Adapters, version 2.1.x. This driver includes support for Itanium(TM)-based +Adapters, version 2.2.x. This driver includes support for Itanium(TM)-based systems. @@ -94,8 +94,9 @@ Command Line Parameters ======================= -The following optional parameters are used by entering them on the command -line with the modprobe or insmod command using this syntax: +If the driver is built as a module, the following optional parameters are +used by entering them on the command line with the modprobe or insmod command +using this syntax: modprobe e100 [ PCM API @@ -61,9 +63,6 @@ PCM Memory Managment !Esound/core/pcm_memory.c - - SG-Buffer Helpers -!Esound/core/pcm_sgbuf.c Control/Mixer API diff -Nru a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl --- a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl Sun Mar 23 00:22:52 2003 +++ b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl Sun Mar 23 00:22:52 2003 @@ -437,7 +437,7 @@ // (see "Management of Cards and Components") static int __devinit snd_mychip_create(snd_card_t *card, struct pci_device *pci, - mychip_t *rchip) + mychip_t **rchip) { mychip_t *chip; int err; @@ -1377,6 +1377,8 @@ module_init(alsa_card_mychip_init) module_exit(alsa_card_mychip_exit) + + EXPORT_NO_SYMBOLS; /* for old kernels only */ ]]> @@ -1664,7 +1666,7 @@ chip->iobase_phys = pci_resource_start(pci, 0); chip->iobase_virt = (unsigned long) ioremap_nocache(chip->iobase_phys, 512); - if ((chip->res_port = request_mem_region(chip->port, 512, + if ((chip->res_port = request_mem_region(chip->iobase_phys, 512, "My Chip")) == NULL) { printk(KERN_ERR "cannot allocate the memory region\n"); snd_mychip_free(chip); @@ -2758,6 +2760,17 @@ +
+ ack callback + + This callback is also not mandatory. This callback is called + when the appl_ptr is updated in read or write operations. + Some drivers like emu10k1-fx and cs46xx need to track the + current appl_ptr for the internal buffer, and this callback + is useful only for such a purpose. + +
+
page callback @@ -2807,7 +2820,7 @@ - If you acquire a spinlock in the interrupt handler, and the + If you aquire a spinlock in the interrupt handler, and the lock is used in other pcm callbacks, too, then you have to release the lock before calling snd_pcm_period_elapsed(), because @@ -4467,8 +4480,7 @@ dma_private, return -EINVAL); + snd_pcm_sgbuf_t *sgbuf = (snd_pcm_sgbuf_t*)substream->dma_private; ]]> diff -Nru a/Documentation/sound/alsa/serial-u16550.txt b/Documentation/sound/alsa/serial-u16550.txt --- a/Documentation/sound/alsa/serial-u16550.txt Sun Mar 23 00:22:54 2003 +++ b/Documentation/sound/alsa/serial-u16550.txt Sun Mar 23 00:22:54 2003 @@ -2,7 +2,7 @@ Serial UART 16450/16550 MIDI driver =================================== -The snd_adaptor module parameter allows you to select either: +The adaptor module parameter allows you to select either: 0 - Roland Soundcanvas support (default) 1 - Midiator MS-124T support (1) @@ -24,37 +24,35 @@ Usage example for simple serial converter: /sbin/setserial /dev/ttyS0 none - /sbin/modprobe snd-serial-u16550 snd_port=0x3f8 snd_irq=4 \ - snd_speed=115200 + /sbin/modprobe snd-serial-u16550 port=0x3f8 irq=4 speed=115200 Usage example for Roland SoundCanvas with 4 MIDI ports: /sbin/setserial /dev/ttyS0 none - /sbin/modprobe snd-serial-u16550 snd_port=0x3f8 snd_irq=4 snd_outs=4 + /sbin/modprobe snd-serial-u16550 port=0x3f8 irq=4 outs=4 -In MS-124T mode, one raw MIDI substream is supported (midiCnD0); the snd_outs +In MS-124T mode, one raw MIDI substream is supported (midiCnD0); the outs module parameter is automatically set to 1. The driver sends the same data to -all four MIDI Out connectors. Set the A-B switch and the snd_speed module +all four MIDI Out connectors. Set the A-B switch and the speed module parameter to match (A=19200, B=9600). Usage example for MS-124T, with A-B switch in A position: /sbin/setserial /dev/ttyS0 none - /sbin/modprobe snd-serial-u16550 snd_port=0x3f8 snd_irq=4 \ - snd_adaptor=1 snd_speed=19200 + /sbin/modprobe snd-serial-u16550 port=0x3f8 irq=4 adaptor=1 \ + speed=19200 In MS-124W S/A mode, one raw MIDI substream is supported (midiCnD0); -the snd_outs module parameter is automatically set to 1. The driver sends +the outs module parameter is automatically set to 1. The driver sends the same data to all four MIDI Out connectors at full MIDI speed. Usage example for S/A mode: /sbin/setserial /dev/ttyS0 none - /sbin/modprobe snd-serial-u16550 snd_port=0x3f8 snd_irq=4 \ - snd_adaptor=2 + /sbin/modprobe snd-serial-u16550 port=0x3f8 irq=4 adaptor=2 In MS-124W M/B mode, the driver supports 16 ALSA raw MIDI substreams; -the snd_outs module parameter is automatically set to 16. The substream +the outs module parameter is automatically set to 16. The substream number gives a bitmask of which MIDI Out connectors the data should be sent to, with midiCnD1 sending to Out 1, midiCnD2 to Out 2, midiCnD4 to Out 3, and midiCnD8 to Out 4. Thus midiCnD15 sends the data to all 4 ports. @@ -67,8 +65,7 @@ Usage example for M/B mode: /sbin/setserial /dev/ttyS0 none - /sbin/modprobe snd-serial-u16550 snd_port=0x3f8 snd_irq=4 \ - snd_adaptor=3 + /sbin/modprobe snd-serial-u16550 port=0x3f8 irq=4 adaptor=3 The MS-124W hardware's M/A mode is currently not supported. This mode allows the MIDI Outs to act independently at double the aggregate throughput of M/B, @@ -88,4 +85,4 @@ serial port. Similar to Roland Soundcanvas mode, F5 NN is used to select the appropriate input or output stream (depending on the data direction). Additionally, the CTS signal is used to regulate the data flow. The number of -inputs is specified by the snd_ins parameter. +inputs is specified by the ins parameter. diff -Nru a/Documentation/sysrq.txt b/Documentation/sysrq.txt --- a/Documentation/sysrq.txt Sun Mar 23 00:22:53 2003 +++ b/Documentation/sysrq.txt Sun Mar 23 00:22:53 2003 @@ -36,6 +36,10 @@ On other - If you know of the key combos for other architectures, please let me know so I can add them to this section. +On all - write a character to /proc/sysrq-trigger. eg: + + echo t > /proc/sysrq-trigger + * What are the 'command' keys? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 'r' - Turns off keyboard raw mode and sets it to XLATE. diff -Nru a/MAINTAINERS b/MAINTAINERS --- a/MAINTAINERS Sun Mar 23 00:22:53 2003 +++ b/MAINTAINERS Sun Mar 23 00:22:53 2003 @@ -728,7 +728,7 @@ GDT SCSI DISK ARRAY CONTROLLER DRIVER P: Achim Leubner -M: achim@vortex.de +M: achim.leubner@intel.com L: linux-scsi@vger.kernel.org W: http://www.icp-vortex.com/ S: Supported @@ -923,10 +923,11 @@ S: Supported INTEL PRO/1000 GIGABIT ETHERNET SUPPORT -P: Chris Leech -M: christopher.leech@intel.com +P: Jeb Cramer +M: cramerj@intel.com P: Scott Feldman M: scott.feldman@intel.com +W: http://sourceforge.net/projects/e1000/ S: Supported INTERMEZZO FILE SYSTEM @@ -1610,6 +1611,12 @@ L: linux-net@vger.kernel.org S: Supported +SIS FRAMEBUFFER DRIVER +P: Thomas Winischhofer +M: thomas@winischhofer.net +W: http://www.winischhofer.net/linuxsisvga.shtml +S: Maintained + SMB FILESYSTEM P: Urban Widmark M: urban@teststation.com @@ -2056,6 +2063,11 @@ P: Jeff Garzik L: linux-via@gtf.org S: Odd fixes + +VIA RHINE NETWORK DRIVER +P: Roger Luethi +M: rl@hellgate.ch +S: Maintained UCLINUX P: Greg Ungerer diff -Nru a/Makefile b/Makefile --- a/Makefile Sun Mar 23 00:22:50 2003 +++ b/Makefile Sun Mar 23 00:22:50 2003 @@ -164,6 +164,8 @@ OBJCOPY = $(CROSS_COMPILE)objcopy OBJDUMP = $(CROSS_COMPILE)objdump AWK = awk +RPM := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ + else echo rpm; fi) GENKSYMS = scripts/genksyms/genksyms DEPMOD = /sbin/depmod KALLSYMS = scripts/kallsyms @@ -768,9 +770,7 @@ rm $(KERNELPATH) ; \ cd $(TOPDIR) ; \ $(CONFIG_SHELL) $(srctree)/scripts/mkversion > .version ; \ - RPM=`which rpmbuild`; \ - if [ -z "$$RPM" ]; then RPM=rpm; fi; \ - $$RPM -ta $(TOPDIR)/../$(KERNELPATH).tar.gz ; \ + $(RPM) -ta $(TOPDIR)/../$(KERNELPATH).tar.gz ; \ rm $(TOPDIR)/../$(KERNELPATH).tar.gz # Brief documentation of the typical targets used diff -Nru a/arch/arm/Kconfig b/arch/arm/Kconfig --- a/arch/arm/Kconfig Sun Mar 23 00:22:53 2003 +++ b/arch/arm/Kconfig Sun Mar 23 00:22:53 2003 @@ -546,9 +546,9 @@ if (CPU_FREQ_SA1100 || CPU_FREQ_SA1110) config CPU_FREQ_GOV_USERSPACE - bool - depends on CPU_FREQ - default y + tristate + depends on CPU_FREQ + default y config CPU_FREQ_24_API bool @@ -1027,9 +1027,6 @@ endmenu -#if [ "$CONFIG_ARCH_CLPS711X" = "y" ]; then -# source drivers/ssi/Config.in -#fi source "drivers/ieee1394/Kconfig" source "drivers/message/i2o/Kconfig" diff -Nru a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile --- a/arch/arm/boot/compressed/Makefile Sun Mar 23 00:22:50 2003 +++ b/arch/arm/boot/compressed/Makefile Sun Mar 23 00:22:50 2003 @@ -19,10 +19,6 @@ CFLAGS_misc.o := -DPARAMS_PHYS=$(PARAMS_PHYS) endif -ifeq ($(CONFIG_ARCH_NETWINDER),y) -OBJS += head-netwinder.o -endif - ifeq ($(CONFIG_ARCH_SHARK),y) OBJS += head-shark.o ofw-shark.o endif diff -Nru a/arch/arm/boot/compressed/head-netwinder.S b/arch/arm/boot/compressed/head-netwinder.S --- a/arch/arm/boot/compressed/head-netwinder.S Sun Mar 23 00:22:51 2003 +++ /dev/null Wed Dec 31 16:00:00 1969 @@ -1,13 +0,0 @@ -/* - * linux/arch/arm/boot/compressed/head-netwinder.S - * - * Copyright (C) 2000-2002 Russell King - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ - .section ".start", "ax" - - mov r7, #5 - mov r8, #0 diff -Nru a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c --- a/arch/arm/kernel/bios32.c Sun Mar 23 00:22:52 2003 +++ b/arch/arm/kernel/bios32.c Sun Mar 23 00:22:52 2003 @@ -6,6 +6,7 @@ * Bits taken from various places. */ #include +#include #include #include #include @@ -61,7 +62,7 @@ * Bug 3 is responsible for the sound DMA grinding to a halt. We now * live with bug 2. */ -static void __init pci_fixup_83c553(struct pci_dev *dev) +static void __devinit pci_fixup_83c553(struct pci_dev *dev) { /* * Set memory region to start at address 0, and enable IO @@ -112,7 +113,7 @@ outb(0x08, 0x4d1); } -static void __init pci_fixup_unassign(struct pci_dev *dev) +static void __devinit pci_fixup_unassign(struct pci_dev *dev) { dev->resource[0].end -= dev->resource[0].start; dev->resource[0].start = 0; @@ -123,7 +124,7 @@ * if it is the host bridge by marking it as such. These resources are of * no consequence to the PCI layer (they are handled elsewhere). */ -static void __init pci_fixup_dec21285(struct pci_dev *dev) +static void __devinit pci_fixup_dec21285(struct pci_dev *dev) { int i; @@ -141,7 +142,7 @@ /* * PCI IDE controllers use non-standard I/O port decoding, respect it. */ -static void __init pci_fixup_ide_bases(struct pci_dev *dev) +static void __devinit pci_fixup_ide_bases(struct pci_dev *dev) { struct resource *r; int i; @@ -161,7 +162,7 @@ /* * Put the DEC21142 to sleep */ -static void __init pci_fixup_dec21142(struct pci_dev *dev) +static void __devinit pci_fixup_dec21142(struct pci_dev *dev) { pci_write_config_dword(dev, 0x40, 0x80000000); } @@ -182,7 +183,7 @@ * functional. However, The CY82C693U _does not work_ in bus * master mode without locking the PCI bus solid. */ -static void __init pci_fixup_cy82c693(struct pci_dev *dev) +static void __devinit pci_fixup_cy82c693(struct pci_dev *dev) { if ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE) { u32 base0, base1; @@ -511,6 +512,8 @@ panic("PCI: unable to scan bus!"); busnr = sys->bus->subordinate + 1; + + list_add(&sys->node, &hw->buses); } else { kfree(sys); if (ret < 0) @@ -521,17 +524,36 @@ void __init pci_common_init(struct hw_pci *hw) { + struct pci_sys_data *sys; + + INIT_LIST_HEAD(&hw->buses); + if (hw->preinit) hw->preinit(); pcibios_init_hw(hw); if (hw->postinit) hw->postinit(); - /* - * Assign any unassigned resources. - */ - pci_assign_unassigned_resources(); pci_fixup_irqs(pcibios_swizzle, pcibios_map_irq); + + list_for_each_entry(sys, &hw->buses, node) { + struct pci_bus *bus = sys->bus; + + /* + * Size the bridge windows. + */ + pci_bus_size_bridges(bus); + + /* + * Assign resources. + */ + pci_bus_assign_resources(bus); + + /* + * Tell drivers about devices found. + */ + pci_bus_add_devices(bus); + } } char * __init pcibios_setup(char *str) diff -Nru a/arch/arm/kernel/ecard.c b/arch/arm/kernel/ecard.c --- a/arch/arm/kernel/ecard.c Sun Mar 23 00:22:55 2003 +++ b/arch/arm/kernel/ecard.c Sun Mar 23 00:22:55 2003 @@ -562,7 +562,8 @@ static void ecard_check_lockup(struct irqdesc *desc) { - static int last, lockup; + static unsigned long last; + static int lockup; ecard_t *ec; /* diff -Nru a/arch/arm/kernel/time.c b/arch/arm/kernel/time.c --- a/arch/arm/kernel/time.c Sun Mar 23 00:22:54 2003 +++ b/arch/arm/kernel/time.c Sun Mar 23 00:22:54 2003 @@ -89,7 +89,7 @@ } } -static long next_rtc_update; +static unsigned long next_rtc_update; /* * If we have an externally synchronized linux clock, then update diff -Nru a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c --- a/arch/arm/kernel/traps.c Sun Mar 23 00:22:52 2003 +++ b/arch/arm/kernel/traps.c Sun Mar 23 00:22:52 2003 @@ -208,12 +208,13 @@ NORET_TYPE void die(const char *str, struct pt_regs *regs, int err) { struct task_struct *tsk = current; + static int die_counter; console_verbose(); spin_lock_irq(&die_lock); bust_spinlocks(1); - printk("Internal error: %s: %x\n", str, err); + printk("Internal error: %s: %x [#%d]\n", str, err, ++die_counter); print_modules(); printk("CPU: %d\n", smp_processor_id()); show_regs(regs); @@ -325,7 +326,7 @@ dump_mem(KERN_CRIT "Vectors: ", vectors, vectors + 0x40); dump_mem(KERN_CRIT "Stubs: ", vectors + 0x200, vectors + 0x4b8); - die("Oops", regs, 0); + die("Oops - bad mode", regs, 0); local_irq_disable(); panic("bad mode"); } @@ -353,7 +354,7 @@ (thumb_mode(regs) ? 2 : 4); force_sig_info(SIGILL, &info, current); - die_if_kernel("Oops", regs, n); + die_if_kernel("Oops - bad syscall", regs, n); return regs->ARM_r0; } @@ -471,7 +472,7 @@ (thumb_mode(regs) ? 2 : 4); force_sig_info(SIGILL, &info, current); - die_if_kernel("Oops", regs, no); + die_if_kernel("Oops - bad syscall(2)", regs, no); return 0; } diff -Nru a/arch/arm/mach-clps7500/core.c b/arch/arm/mach-clps7500/core.c --- a/arch/arm/mach-clps7500/core.c Sun Mar 23 00:22:53 2003 +++ b/arch/arm/mach-clps7500/core.c Sun Mar 23 00:22:53 2003 @@ -8,19 +8,22 @@ */ #include #include +#include +#include +#include #include +#include #include +#include #include #include #include -#include -#include -#include +#include #include -static void cl7500_mask_irq_ack_a(unsigned int irq) +static void cl7500_ack_irq_a(unsigned int irq) { unsigned int val, mask; @@ -48,6 +51,12 @@ iomd_writeb(val | mask, IOMD_IRQMASKA); } +static struct irqchip clps7500_a_chip = { + .ack = cl7500_ack_irq_a, + .mask = cl7500_mask_irq_a, + .unmask = cl7500_unmask_irq_a, +}; + static void cl7500_mask_irq_b(unsigned int irq) { unsigned int val, mask; @@ -66,6 +75,12 @@ iomd_writeb(val | mask, IOMD_IRQMASKB); } +static struct irqchip clps7500_b_chip = { + .ack = cl7500_mask_irq_b, + .mask = cl7500_mask_irq_b, + .unmask = cl7500_unmask_irq_b, +}; + static void cl7500_mask_irq_c(unsigned int irq) { unsigned int val, mask; @@ -84,6 +99,11 @@ iomd_writeb(val | mask, IOMD_IRQMASKC); } +static struct irqchip clps7500_c_chip = { + .ack = cl7500_mask_irq_c, + .mask = cl7500_mask_irq_c, + .unmask = cl7500_unmask_irq_c, +}; static void cl7500_mask_irq_d(unsigned int irq) { @@ -103,6 +123,12 @@ iomd_writeb(val | mask, IOMD_IRQMASKD); } +static struct irqchip clps7500_d_chip = { + .ack = cl7500_mask_irq_d, + .mask = cl7500_mask_irq_d, + .unmask = cl7500_unmask_irq_d, +}; + static void cl7500_mask_irq_dma(unsigned int irq) { unsigned int val, mask; @@ -121,6 +147,12 @@ iomd_writeb(val | mask, IOMD_DMAMASK); } +static struct irqchip clps7500_dma_chip = { + .ack = cl7500_mask_irq_dma, + .mask = cl7500_mask_irq_dma, + .unmask = cl7500_unmask_irq_dma, +}; + static void cl7500_mask_irq_fiq(unsigned int irq) { unsigned int val, mask; @@ -139,6 +171,22 @@ iomd_writeb(val | mask, IOMD_FIQMASK); } +static struct irqchip clps7500_fiq_chip = { + .ack = cl7500_mask_irq_fiq, + .mask = cl7500_mask_irq_fiq, + .unmask = cl7500_unmask_irq_fiq, +}; + +static void cl7500_no_action(unsigned int irq) +{ +} + +static struct irqchip clps7500_no_chip = { + .ack = cl7500_no_action, + .mask = cl7500_no_action, + .unmask = cl7500_no_action, +}; + static void no_action(int cpl, void *dev_id, struct pt_regs *regs) { } @@ -147,7 +195,7 @@ static void __init clps7500_init_irq(void) { - int irq; + unsigned int irq, flags; iomd_writeb(0, IOMD_IRQMASKA); iomd_writeb(0, IOMD_IRQMASKB); @@ -155,64 +203,58 @@ iomd_writeb(0, IOMD_DMAMASK); for (irq = 0; irq < NR_IRQS; irq++) { + flags = IRQF_VALID; + + if (irq <= 6 || (irq >= 9 && irq <= 15) || + (irq >= 48 && irq <= 55)) + flags |= IRQF_PROBE; + switch (irq) { - case 0 ... 6: - irq_desc[irq].probe_ok = 1; - case 7: - irq_desc[irq].valid = 1; - irq_desc[irq].mask_ack = cl7500_mask_irq_ack_a; - irq_desc[irq].mask = cl7500_mask_irq_a; - irq_desc[irq].unmask = cl7500_unmask_irq_a; - break; - - case 9 ... 15: - irq_desc[irq].probe_ok = 1; - case 8: - irq_desc[irq].valid = 1; - irq_desc[irq].mask_ack = cl7500_mask_irq_b; - irq_desc[irq].mask = cl7500_mask_irq_b; - irq_desc[irq].unmask = cl7500_unmask_irq_b; + case 0 ... 7: + set_irq_chip(irq, &clps7500_a_chip); + set_irq_handler(irq, do_level_IRQ); + set_irq_flags(irq, flags); + break; + + case 8 ... 15: + set_irq_chip(irq, &clps7500_b_chip); + set_irq_handler(irq, do_level_IRQ); + set_irq_flags(irq, flags); break; case 16 ... 22: - irq_desc[irq].valid = 1; - irq_desc[irq].mask_ack = cl7500_mask_irq_dma; - irq_desc[irq].mask = cl7500_mask_irq_dma; - irq_desc[irq].unmask = cl7500_unmask_irq_dma; + set_irq_chip(irq, &clps7500_dma_chip); + set_irq_handler(irq, do_level_IRQ); + set_irq_flags(irq, flags); break; case 24 ... 31: - irq_desc[irq].valid = 1; - irq_desc[irq].mask_ack = cl7500_mask_irq_c; - irq_desc[irq].mask = cl7500_mask_irq_c; - irq_desc[irq].unmask = cl7500_unmask_irq_c; + set_irq_chip(irq, &clps7500_c_chip); + set_irq_handler(irq, do_level_IRQ); + set_irq_flags(irq, flags); break; case 40 ... 47: - irq_desc[irq].valid = 1; - irq_desc[irq].mask_ack = cl7500_mask_irq_d; - irq_desc[irq].mask = cl7500_mask_irq_d; - irq_desc[irq].unmask = cl7500_unmask_irq_d; + set_irq_chip(irq, &clps7500_d_chip); + set_irq_handler(irq, do_level_IRQ); + set_irq_flags(irq, flags); break; case 48 ... 55: - irq_desc[irq].valid = 1; - irq_desc[irq].probe_ok = 1; - irq_desc[irq].mask_ack = no_action; - irq_desc[irq].mask = no_action; - irq_desc[irq].unmask = no_action; + set_irq_chip(irq, &clps7500_no_chip); + set_irq_handler(irq, do_level_IRQ); + set_irq_flags(irq, flags); break; case 64 ... 72: - irq_desc[irq].valid = 1; - irq_desc[irq].mask_ack = cl7500_mask_irq_fiq; - irq_desc[irq].mask = cl7500_mask_irq_fiq; - irq_desc[irq].unmask = cl7500_unmask_irq_fiq; + set_irq_chip(irq, &clps7500_fiq_chip); + set_irq_handler(irq, do_level_IRQ); + set_irq_flags(irq, flags); break; } } - setup_arm_irq(IRQ_ISA, &irq_isa); + setup_irq(IRQ_ISA, &irq_isa); } static struct map_desc cl7500_io_desc[] __initdata = { diff -Nru a/arch/arm/mach-sa1100/ssp.c b/arch/arm/mach-sa1100/ssp.c --- a/arch/arm/mach-sa1100/ssp.c Sun Mar 23 00:22:54 2003 +++ b/arch/arm/mach-sa1100/ssp.c Sun Mar 23 00:22:54 2003 @@ -39,7 +39,8 @@ * @data: 16-bit, MSB justified data to write. * * Wait for a free entry in the SSP transmit FIFO, and write a data - * word to the SSP port. + * word to the SSP port. Wait for the SSP port to start sending + * the data. * * The caller is expected to perform the necessary locking. * @@ -53,6 +54,9 @@ cpu_relax(); Ser4SSDR = data; + + while (!(Ser4SSSR & SSSR_BSY)) + cpu_relax(); return 0; } diff -Nru a/arch/i386/Kconfig b/arch/i386/Kconfig --- a/arch/i386/Kconfig Sun Mar 23 00:22:50 2003 +++ b/arch/i386/Kconfig Sun Mar 23 00:22:50 2003 @@ -476,21 +476,6 @@ This is purely to save memory - each supported CPU adds approximately eight kilobytes to the kernel image. -# Common NUMA Features -config NUMA - bool "Numa Memory Allocation Support" - depends on (HIGHMEM64G && (X86_NUMAQ || (X86_SUMMIT && ACPI && !ACPI_HT_ONLY))) || X86_PC - -config DISCONTIGMEM - bool - depends on NUMA - default y - -config HAVE_ARCH_BOOTMEM_NODE - bool - depends on NUMA - default y - config X86_TSC bool depends on (MWINCHIP3D || MWINCHIP2 || MCRUSOE || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || MK8 || MVIAC3_2) && !X86_NUMAQ @@ -678,6 +663,30 @@ config X86_PAE bool depends on HIGHMEM64G + default y + +# Common NUMA Features +config NUMA + bool "Numa Memory Allocation Support" + depends on SMP && HIGHMEM64G && (X86_PC || X86_NUMAQ || (X86_SUMMIT && ACPI && !ACPI_HT_ONLY)) + default n if X86_PC + default y if (X86_NUMAQ || X86_SUMMIT) + +# Need comments to help the hapless user trying to turn on NUMA support +comment "NUMA (NUMA-Q) requires SMP, 64GB highmem support" + depends on X86_NUMAQ && (!HIGHMEM64G || !SMP) + +comment "NUMA (Summit) requires SMP, 64GB highmem support, full ACPI" + depends on X86_SUMMIT && (!HIGHMEM64G || !ACPI || ACPI_HT_ONLY) + +config DISCONTIGMEM + bool + depends on NUMA + default y + +config HAVE_ARCH_BOOTMEM_NODE + bool + depends on NUMA default y config HIGHPTE diff -Nru a/arch/i386/boot98/Makefile b/arch/i386/boot98/Makefile --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/arch/i386/boot98/Makefile Sun Mar 23 00:22:57 2003 @@ -0,0 +1,76 @@ +# +# arch/i386/boot/Makefile +# +# This file is subject to the terms and conditions of the GNU General Public +# License. See the file "COPYING" in the main directory of this archive +# for more details. +# +# Copyright (C) 1994 by Linus Torvalds +# + +# ROOT_DEV specifies the default root-device when making the image. +# This can be either FLOPPY, CURRENT, /dev/xxxx or empty, in which case +# the default of FLOPPY is used by 'build'. + +ROOT_DEV := CURRENT + +# If you want to preset the SVGA mode, uncomment the next line and +# set SVGA_MODE to whatever number you want. +# Set it to -DSVGA_MODE=NORMAL_VGA if you just want the EGA/VGA mode. +# The number is the same as you would ordinarily press at bootup. + +SVGA_MODE := -DSVGA_MODE=NORMAL_VGA + +# If you want the RAM disk device, define this to be the size in blocks. + +#RAMDISK := -DRAMDISK=512 + +EXTRA_TARGETS := vmlinux.bin bootsect bootsect.o \ + setup setup.o zImage bzImage + +subdir- := compressed + +host-progs := tools/build + +# --------------------------------------------------------------------------- + +$(obj)/zImage: IMAGE_OFFSET := 0x1000 +$(obj)/zImage: EXTRA_AFLAGS := -traditional $(SVGA_MODE) $(RAMDISK) +$(obj)/bzImage: IMAGE_OFFSET := 0x100000 +$(obj)/bzImage: EXTRA_AFLAGS := -traditional $(SVGA_MODE) $(RAMDISK) -D__BIG_KERNEL__ +$(obj)/bzImage: BUILDFLAGS := -b + +quiet_cmd_image = BUILD $@ +cmd_image = $(obj)/tools/build $(BUILDFLAGS) $(obj)/bootsect $(obj)/setup \ + $(obj)/vmlinux.bin $(ROOT_DEV) > $@ + +$(obj)/zImage $(obj)/bzImage: $(obj)/bootsect $(obj)/setup \ + $(obj)/vmlinux.bin $(obj)/tools/build FORCE + $(call if_changed,image) + @echo 'Kernel: $@ is ready' + +$(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE + $(call if_changed,objcopy) + +LDFLAGS_bootsect := -Ttext 0x0 -s --oformat binary +LDFLAGS_setup := -Ttext 0x0 -s --oformat binary -e begtext + +$(obj)/setup $(obj)/bootsect: %: %.o FORCE + $(call if_changed,ld) + +$(obj)/compressed/vmlinux: FORCE + $(Q)$(MAKE) -f scripts/Makefile.build obj=$(obj)/compressed \ + IMAGE_OFFSET=$(IMAGE_OFFSET) $@ + +zdisk: $(BOOTIMAGE) + dd bs=8192 if=$(BOOTIMAGE) of=/dev/fd0 + +zlilo: $(BOOTIMAGE) + if [ -f $(INSTALL_PATH)/vmlinuz ]; then mv $(INSTALL_PATH)/vmlinuz $(INSTALL_PATH)/vmlinuz.old; fi + if [ -f $(INSTALL_PATH)/System.map ]; then mv $(INSTALL_PATH)/System.map $(INSTALL_PATH)/System.old; fi + cat $(BOOTIMAGE) > $(INSTALL_PATH)/vmlinuz + cp System.map $(INSTALL_PATH)/ + if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi + +install: $(BOOTIMAGE) + sh $(src)/install.sh $(KERNELRELEASE) $(BOOTIMAGE) System.map "$(INSTALL_PATH)" diff -Nru a/arch/i386/boot98/bootsect.S b/arch/i386/boot98/bootsect.S --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/arch/i386/boot98/bootsect.S Sun Mar 23 00:22:57 2003 @@ -0,0 +1,397 @@ +/* + * bootsect.S - boot sector for NEC PC-9800 series + * + * Linux/98 project at Kyoto University Microcomputer Club (KMC) + * FUJITA Norimasa, TAKAI Kousuke 1997-1998 + * rewritten by TAKAI Kousuke (as86 -> gas), Nov 1999 + * + * Based on: + * bootsect.S Copyright (C) 1991, 1992 Linus Torvalds + * modified by Drew Eckhardt + * modified by Bruce Evans (bde) + * + * bootsect.S is loaded at 0x1FC00 or 0x1FE00 by the bios-startup routines, + * and moves itself out of the way to address 0x90000, and jumps there. + * + * It then loads 'setup' directly after itself (0x90200), and the system + * at 0x10000, using BIOS interrupts. + * + * NOTE! currently system is at most (8*65536-4096) bytes long. This should + * be no problem, even in the future. I want to keep it simple. This 508 kB + * kernel size should be enough, especially as this doesn't contain the + * buffer cache as in minix (and especially now that the kernel is + * compressed :-) + * + * The loader has been made as simple as possible, and continuous + * read errors will result in a unbreakable loop. Reboot by hand. It + * loads pretty fast by getting whole tracks at a time whenever possible. + */ + +#include /* for CONFIG_ROOT_RDONLY */ +#include + +SETUPSECTS = 4 /* default nr of setup-sectors */ +BOOTSEG = 0x1FC0 /* original address of boot-sector */ +INITSEG = DEF_INITSEG /* we move boot here - out of the way */ +SETUPSEG = DEF_SETUPSEG /* setup starts here */ +SYSSEG = DEF_SYSSEG /* system loaded at 0x10000 (65536) */ +SYSSIZE = DEF_SYSSIZE /* system size: # of 16-byte clicks */ + /* to be loaded */ +ROOT_DEV = 0 /* ROOT_DEV is now written by "build" */ +SWAP_DEV = 0 /* SWAP_DEV is now written by "build" */ + +#ifndef SVGA_MODE +#define SVGA_MODE ASK_VGA +#endif + +#ifndef RAMDISK +#define RAMDISK 0 +#endif + +#ifndef ROOT_RDONLY +#define ROOT_RDONLY 1 +#endif + +/* normal/hireso text VRAM segments */ +#define NORMAL_TEXT 0xa000 +#define HIRESO_TEXT 0xe000 + +/* bios work area addresses */ +#define EXPMMSZ 0x0401 +#define BIOS_FLAG 0x0501 +#define DISK_BOOT 0x0584 + +.code16 +.text + +.global _start +_start: + +#if 0 /* hook for debugger, harmless unless BIOS is fussy (old HP) */ + int $0x3 +#endif + jmp real_start + .ascii "Linux 98" + .word 0 +real_start: + xorw %di, %di /* %di = 0 */ + movw %di, %ss /* %ss = 0 */ + movw $0x03F0, %sp + pushw %cx /* for hint */ + + movw $0x0A00, %ax /* normal mode defaults (80x25) */ + + testb $0x08, %ss:BIOS_FLAG /* check hi-reso bit */ + jnz set_crt_mode +/* + * Hi-Reso (high-resolution) machine. + * + * Some hi-reso machines have no RAMs on bank 8/A (0x080000 - 0x0BFFFF). + * On such machines we get two RAM banks from top of protect menory and + * map them on bank 8/A. + * These work-around must be done before moving myself on INITSEG (0x090000-). + */ + movw $(HIRESO_TEXT >> 8), %cs:(vram + 1) /* text VRAM segment */ + + /* set memory window */ + movb $0x08, %al + outb %al, $0x91 /* map native RAM (if any) */ + movb $0x0A, %al + outb %al, $0x93 + + /* check bank ram A */ + pushw $0xA500 + popw %ds + movw (%di), %cx /* %si == 0 from entry */ + notw %cx + movw %cx, (%di) + + movw $0x43F, %dx /* cache flush for 486 and up. */ + movb $0xA0, %al + outb %al, %dx + + cmpw %cx, (%di) + je hireso_done + + /* + * Write test failed; we have no native RAM on 080000h - 0BFFFFh. + * Take 256KB of RAM from top of protected memory. + */ + movb %ss:EXPMMSZ, %al + subb $2, %al /* reduce 2 x 128KB */ + movb %al, %ss:EXPMMSZ + addb %al, %al + addb $0x10, %al + outb %al, $0x91 + addb $2, %al + outb %al, $0x93 + +hireso_done: + movb $0x10, %al /* CRT mode 80x31, %ah still 0Ah */ + +set_crt_mode: + int $0x18 /* set CRT mode */ + + movb $0x0C, %ah /* turn on text displaying */ + int $0x18 + + xorw %dx, %dx /* position cursor to home */ + movb $0x13, %ah + int $0x18 + + movb $0x11, %ah /* turn cursor displaying on */ + int $0x18 + + /* move 1 kilobytes from [BOOTSEG:0000h] to [INITSEG:0000h] */ + cld + xorw %si, %si + pushw $INITSEG + popw %es + movw $512, %cx /* %di == 0 from entry */ + rep + cs + movsw + + ljmp $INITSEG, $go + +go: + pushw %cs + popw %ds /* %ds = %cs */ + + popw %dx /* %dh = saved %ch passed from BIOS */ + movb %ss:DISK_BOOT, %al + andb $0xf0, %al /* %al = Device Address */ + movb $18, %ch /* 18 secs/track, 512 b/sec (1440 KB) */ + cmpb $0x30, %al + je try512 + cmpb $0x90, %al /* 1 MB I/F, 1 MB floppy */ + je try1.2M + cmpb $0xf0, %al /* 640 KB I/F, 1 MB floppy */ + je try1.2M + movb $9, %ch /* 9 secs/track, 512 b/sec ( 720 KB) */ + cmpb $0x10, %al /* 1 MB I/F, 640 KB floppy */ + je try512 + cmpb $0x70, %al /* 640 KB I/F, 640 KB floppy */ + jne error /* unknown device? */ + + /* XXX: Does it make sense to support 8 secs/track, 512 b/sec + (640 KB) floppy? */ + +try512: movb $2, %cl /* 512 b/sec */ +lasttry:call tryload +/* + * Display error message and halt + */ +error: movw $error_msg, %si + call print +wait_reboot: + movb $0x0, %ah + int $0x18 /* wait keyboard input */ +1: movb $0, %al + outb %al, $0xF0 /* reset CPU */ + jmp 1b /* just in case... */ + +try1.2M:cmpb $2, %dh + je try2HC + movw $0x0803, %cx /* 8 secs/track, 1024 b/sec (1232 KB) */ + call tryload + movb $15, %ch /* 15 secs/track, 512 b/sec (1200 KB) */ + jmp try512 +try2HC: movw $0x0F02, %cx /* 15 secs/track, 512 b/sec (1200 KB) */ + call tryload + movw $0x0803, %cx /* 8 secs/track, 1024 b/sec (1232 KB) */ + jmp lasttry + +/* + * Try to load SETUP and SYSTEM provided geometry information in %cx. + * This routine *will not* return on successful load... + */ +tryload: + movw %cx, sectlen + movb %ss:DISK_BOOT, %al + movb $0x7, %ah /* recalibrate the drive */ + int $0x1b + jc error /* recalibration should succeed */ + + /* + * Load SETUP into memory. It is assumed that SETUP fits into + * first cylinder (2 tracks, 9KB on 2DD, 15-18KB on 2HD). + */ + movb $0, %bl + movb setup_sects, %bh + incb %bh + shlw %bx /* %bx = (setup_sects + 1) * 512 */ + movw $128, %bp + shlw %cl, %bp /* %bp = */ + subw %bp, %bx /* length to load */ + movw $0x0002, %dx /* head 0, sector 2 */ + movb %cl, %ch /* `N' for sector address */ + movb $0, %cl /* cylinder 0 */ + pushw %cs + popw %es /* %es = %cs (= INITSEG) */ + movb $0xd6, %ah /* read, multi-track, MFM */ + int $0x1b /* load it! */ + jc read_error + + movw $loading_msg, %si + call print + + movw $SYSSEG, %ax + movw %ax, %es /* %es = SYSSEG */ + +/* + * This routine loads the system at address 0x10000, making sure + * no 64kB boundaries are crossed. We try to load it as fast as + * possible, loading whole tracks whenever we can. + * + * in: es - starting address segment (normally 0x1000) + */ + movb %ch, %cl + addb $7, %cl /* %cl = log2 */ + shrw %cl, %bx /* %bx = # of phys. sectors in SETUP */ + addb %bl, %dl /* %dl = start sector # of SYSTEM */ + decb %dl /* %dl is 0-based in below loop */ + +rp_read_newseg: + xorw %bp, %bp /* = starting address within segment */ +#ifdef __BIG_KERNEL__ + bootsect_kludge = 0x220 /* 0x200 (size of bootsector) + 0x20 (offset */ + lcall *bootsect_kludge /* of bootsect_kludge in setup.S */ +#else + movw %es, %ax + subw $SYSSEG, %ax +#endif + cmpw syssize, %ax + ja boot /* done! */ + +rp_read: + movb sectors, %al + addb %al, %al + movb %al, %ch /* # of sectors on both surface */ + subb %dl, %al /* # of sectors left on this track */ + movb $0, %ah + shlw %cl, %ax /* # of bytes left on this track */ + movw %ax, %bx /* transfer length */ + addw %bp, %ax /* cross 64K boundary? */ + jnc 1f /* ok. */ + jz 1f /* also ok. */ + /* + * Oops, we are crossing 64K boundary... + * Adjust transfer length to make transfer fit in the boundary. + * + * Note: sector size is assumed to be a measure of 65536. + */ + xorw %bx, %bx + subw %bp, %bx +1: pushw %dx + movw $dot_msg, %si /* give progress message */ + call print + xchgw %ax, %dx + movb $0, %ah + divb sectors + xchgb %al, %ah + xchgw %ax, %dx /* %dh = head # / %dl = sector # */ + incb %dl /* fix %dl to 1-based */ + pushw %cx + movw cylinder, %cx + movb $0xd6, %ah /* read, multi-track, seek, MFM */ + movb %ss:DISK_BOOT, %al + int $0x1b + popw %cx + popw %dx + jc read_error + movw %bx, %ax /* # of bytes just read */ + shrw %cl, %ax /* %ax = # of sectors just read */ + addb %al, %dl /* advance sector # */ + cmpb %ch, %dl /* %ch = # of sectors/cylinder */ + jb 2f + incb cylinder /* next cylinder */ + xorb %dl, %dl /* sector 0 */ +2: addw %bx, %bp /* advance offset pointer */ + jnc rp_read + /* offset pointer wrapped; advance segment pointer. */ + movw %es, %ax + addw $0x1000, %ax + movw %ax, %es + jmp rp_read_newseg + +read_error: + ret + +boot: movw %cs, %ax /* = INITSEG */ + /* movw %ax, %ds */ + movw %ax, %ss + movw $0x4000, %sp /* 0x4000 is arbitrary value >= + * length of bootsect + length of + * setup + room for stack; + * PC-9800 never have BIOS workareas + * on high memory. + */ +/* + * After that we check which root-device to use. If the device is + * not defined, /dev/fd0 (2, 0) will be used. + */ + cmpw $0, root_dev + jne 3f + movb $2, root_dev+1 +3: + +/* + * After that (everything loaded), we jump to the setup-routine + * loaded directly after the bootblock: + */ + ljmp $SETUPSEG, $0 + +/* + * Subroutine for print string on console. + * %cs:%si - pointer to message + */ +print: + pushaw + pushw %ds + pushw %es + pushw %cs + popw %ds + lesw curpos, %di /* %es:%di = current text VRAM addr. */ +1: xorw %ax, %ax + lodsb + testb %al, %al + jz 2f /* end of string */ + stosw /* character code */ + movb $0xE1, %es:0x2000-2(%di) /* character attribute */ + jmp 1b +2: movw %di, %dx + movb $0x13, %ah + int $0x18 /* move cursor to current point */ + popw %es + popw %ds + popaw + ret + +loading_msg: + .string "Loading" +dot_msg: + .string "." +error_msg: + .string "Read Error!" + + .org 490 + +curpos: .word 160 /* current cursor position */ +vram: .word NORMAL_TEXT /* text VRAM segment */ + +cylinder: .byte 0 /* current cylinder (lower byte) */ +sectlen: .byte 0 /* (log2 of ) - 7 */ +sectors: .byte 0x0F /* default is 2HD (15 sector/track) */ + +# XXX: This is a fairly snug fit. + +.org 497 +setup_sects: .byte SETUPSECTS +root_flags: .word ROOT_RDONLY +syssize: .word SYSSIZE +swap_dev: .word SWAP_DEV +ram_size: .word RAMDISK +vid_mode: .word SVGA_MODE +root_dev: .word ROOT_DEV +boot_flag: .word 0xAA55 diff -Nru a/arch/i386/boot98/compressed/Makefile b/arch/i386/boot98/compressed/Makefile --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/arch/i386/boot98/compressed/Makefile Sun Mar 23 00:22:57 2003 @@ -0,0 +1,25 @@ +# +# linux/arch/i386/boot/compressed/Makefile +# +# create a compressed vmlinux image from the original vmlinux +# + +EXTRA_TARGETS := vmlinux vmlinux.bin vmlinux.bin.gz head.o misc.o piggy.o +EXTRA_AFLAGS := -traditional + +LDFLAGS_vmlinux := -Ttext $(IMAGE_OFFSET) -e startup_32 + +$(obj)/vmlinux: $(obj)/head.o $(obj)/misc.o $(obj)/piggy.o FORCE + $(call if_changed,ld) + @: + +$(obj)/vmlinux.bin: vmlinux FORCE + $(call if_changed,objcopy) + +$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE + $(call if_changed,gzip) + +LDFLAGS_piggy.o := -r --format binary --oformat elf32-i386 -T + +$(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.gz FORCE + $(call if_changed,ld) diff -Nru a/arch/i386/boot98/compressed/head.S b/arch/i386/boot98/compressed/head.S --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/arch/i386/boot98/compressed/head.S Sun Mar 23 00:22:57 2003 @@ -0,0 +1,128 @@ +/* + * linux/boot/head.S + * + * Copyright (C) 1991, 1992, 1993 Linus Torvalds + */ + +/* + * head.S contains the 32-bit startup code. + * + * NOTE!!! Startup happens at absolute address 0x00001000, which is also where + * the page directory will exist. The startup code will be overwritten by + * the page directory. [According to comments etc elsewhere on a compressed + * kernel it will end up at 0x1000 + 1Mb I hope so as I assume this. - AC] + * + * Page 0 is deliberately kept safe, since System Management Mode code in + * laptops may need to access the BIOS data stored there. This is also + * useful for future device drivers that either access the BIOS via VM86 + * mode. + */ + +/* + * High loaded stuff by Hans Lermen & Werner Almesberger, Feb. 1996 + */ +.text + +#include +#include + + .globl startup_32 + +startup_32: + cld + cli + movl $(__BOOT_DS),%eax + movl %eax,%ds + movl %eax,%es + movl %eax,%fs + movl %eax,%gs + + lss stack_start,%esp + xorl %eax,%eax +1: incl %eax # check that A20 really IS enabled + movl %eax,0x000000 # loop forever if it isn't + cmpl %eax,0x100000 + je 1b + +/* + * Initialize eflags. Some BIOS's leave bits like NT set. This would + * confuse the debugger if this code is traced. + * XXX - best to initialize before switching to protected mode. + */ + pushl $0 + popfl +/* + * Clear BSS + */ + xorl %eax,%eax + movl $_edata,%edi + movl $_end,%ecx + subl %edi,%ecx + cld + rep + stosb +/* + * Do the decompression, and jump to the new kernel.. + */ + subl $16,%esp # place for structure on the stack + movl %esp,%eax + pushl %esi # real mode pointer as second arg + pushl %eax # address of structure as first arg + call decompress_kernel + orl %eax,%eax + jnz 3f + popl %esi # discard address + popl %esi # real mode pointer + xorl %ebx,%ebx + ljmp $(__BOOT_CS), $0x100000 + +/* + * We come here, if we were loaded high. + * We need to move the move-in-place routine down to 0x1000 + * and then start it with the buffer addresses in registers, + * which we got from the stack. + */ +3: + movl $move_routine_start,%esi + movl $0x1000,%edi + movl $move_routine_end,%ecx + subl %esi,%ecx + addl $3,%ecx + shrl $2,%ecx + cld + rep + movsl + + popl %esi # discard the address + popl %ebx # real mode pointer + popl %esi # low_buffer_start + popl %ecx # lcount + popl %edx # high_buffer_start + popl %eax # hcount + movl $0x100000,%edi + cli # make sure we don't get interrupted + ljmp $(__BOOT_CS), $0x1000 # and jump to the move routine + +/* + * Routine (template) for moving the decompressed kernel in place, + * if we were high loaded. This _must_ PIC-code ! + */ +move_routine_start: + movl %ecx,%ebp + shrl $2,%ecx + rep + movsl + movl %ebp,%ecx + andl $3,%ecx + rep + movsb + movl %edx,%esi + movl %eax,%ecx # NOTE: rep movsb won't move if %ecx == 0 + addl $3,%ecx + shrl $2,%ecx + rep + movsl + movl %ebx,%esi # Restore setup pointer + xorl %ebx,%ebx + ljmp $(__BOOT_CS), $0x100000 +move_routine_end: diff -Nru a/arch/i386/boot98/compressed/misc.c b/arch/i386/boot98/compressed/misc.c --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/arch/i386/boot98/compressed/misc.c Sun Mar 23 00:22:57 2003 @@ -0,0 +1,379 @@ +/* + * misc.c + * + * This is a collection of several routines from gzip-1.0.3 + * adapted for Linux. + * + * malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994 + * puts by Nick Holloway 1993, better puts by Martin Mares 1995 + * High loaded stuff by Hans Lermen & Werner Almesberger, Feb. 1996 + */ + +#include +#include +#include +#include +#ifdef STANDARD_MEMORY_BIOS_CALL +#undef STANDARD_MEMORY_BIOS_CALL +#endif + +/* + * gzip declarations + */ + +#define OF(args) args +#define STATIC static + +#undef memset +#undef memcpy + +/* + * Why do we do this? Don't ask me.. + * + * Incomprehensible are the ways of bootloaders. + */ +static void* memset(void *, int, size_t); +static void* memcpy(void *, __const void *, size_t); +#define memzero(s, n) memset ((s), 0, (n)) + +typedef unsigned char uch; +typedef unsigned short ush; +typedef unsigned long ulg; + +#define WSIZE 0x8000 /* Window size must be at least 32k, */ + /* and a power of two */ + +static uch *inbuf; /* input buffer */ +static uch window[WSIZE]; /* Sliding window buffer */ + +static unsigned insize = 0; /* valid bytes in inbuf */ +static unsigned inptr = 0; /* index of next byte to be processed in inbuf */ +static unsigned outcnt = 0; /* bytes in output buffer */ + +/* gzip flag byte */ +#define ASCII_FLAG 0x01 /* bit 0 set: file probably ASCII text */ +#define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */ +#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */ +#define ORIG_NAME 0x08 /* bit 3 set: original file name present */ +#define COMMENT 0x10 /* bit 4 set: file comment present */ +#define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */ +#define RESERVED 0xC0 /* bit 6,7: reserved */ + +#define get_byte() (inptr < insize ? inbuf[inptr++] : fill_inbuf()) + +/* Diagnostic functions */ +#ifdef DEBUG +# define Assert(cond,msg) {if(!(cond)) error(msg);} +# define Trace(x) fprintf x +# define Tracev(x) {if (verbose) fprintf x ;} +# define Tracevv(x) {if (verbose>1) fprintf x ;} +# define Tracec(c,x) {if (verbose && (c)) fprintf x ;} +# define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;} +#else +# define Assert(cond,msg) +# define Trace(x) +# define Tracev(x) +# define Tracevv(x) +# define Tracec(c,x) +# define Tracecv(c,x) +#endif + +static int fill_inbuf(void); +static void flush_window(void); +static void error(char *m); +static void gzip_mark(void **); +static void gzip_release(void **); + +/* + * This is set up by the setup-routine at boot-time + */ +static unsigned char *real_mode; /* Pointer to real-mode data */ + +#define EXT_MEM_K (*(unsigned short *)(real_mode + 0x2)) +#ifndef STANDARD_MEMORY_BIOS_CALL +#define ALT_MEM_K (*(unsigned long *)(real_mode + 0x1e0)) +#endif +#define SCREEN_INFO (*(struct screen_info *)(real_mode+0)) + +extern char input_data[]; +extern int input_len; + +static long bytes_out = 0; +static uch *output_data; +static unsigned long output_ptr = 0; + +static void *malloc(int size); +static void free(void *where); + +static void puts(const char *); + +extern int end; +static long free_mem_ptr = (long)&end; +static long free_mem_end_ptr; + +#define INPLACE_MOVE_ROUTINE 0x1000 +#define LOW_BUFFER_START 0x2000 +#define LOW_BUFFER_MAX 0x90000 +#define HEAP_SIZE 0x3000 +static unsigned int low_buffer_end, low_buffer_size; +static int high_loaded =0; +static uch *high_buffer_start /* = (uch *)(((ulg)&end) + HEAP_SIZE)*/; + +static char *vidmem = (char *)0xa0000; +static int lines, cols; + +#ifdef CONFIG_X86_NUMAQ +static void * xquad_portio = NULL; +#endif + +#include "../../../../lib/inflate.c" + +static void *malloc(int size) +{ + void *p; + + if (size <0) error("Malloc error\n"); + if (free_mem_ptr <= 0) error("Memory error\n"); + + free_mem_ptr = (free_mem_ptr + 3) & ~3; /* Align */ + + p = (void *)free_mem_ptr; + free_mem_ptr += size; + + if (free_mem_ptr >= free_mem_end_ptr) + error("\nOut of memory\n"); + + return p; +} + +static void free(void *where) +{ /* Don't care */ +} + +static void gzip_mark(void **ptr) +{ + *ptr = (void *) free_mem_ptr; +} + +static void gzip_release(void **ptr) +{ + free_mem_ptr = (long) *ptr; +} + +static void scroll(void) +{ + int i; + + memcpy ( vidmem, vidmem + cols * 2, ( lines - 1 ) * cols * 2 ); + for ( i = ( lines - 1 ) * cols * 2; i < lines * cols * 2; i += 2 ) + vidmem[i] = ' '; +} + +static void puts(const char *s) +{ + int x,y,pos; + char c; + + x = SCREEN_INFO.orig_x; + y = SCREEN_INFO.orig_y; + + while ( ( c = *s++ ) != '\0' ) { + if ( c == '\n' ) { + x = 0; + if ( ++y >= lines ) { + scroll(); + y--; + } + } else { + vidmem [ ( x + cols * y ) * 2 ] = c; + if ( ++x >= cols ) { + x = 0; + if ( ++y >= lines ) { + scroll(); + y--; + } + } + } + } + + SCREEN_INFO.orig_x = x; + SCREEN_INFO.orig_y = y; + + pos = x + cols * y; /* Update cursor position */ + while (!(inb_p(0x60) & 4)); + outb_p(0x49, 0x62); + outb_p(pos & 0xff, 0x60); + outb_p((pos >> 8) & 0xff, 0x60); +} + +static void* memset(void* s, int c, size_t n) +{ + int i; + char *ss = (char*)s; + + for (i=0;i> 8); + } + crc = c; + bytes_out += (ulg)outcnt; + output_ptr += (ulg)outcnt; + outcnt = 0; +} + +static void flush_window_high(void) +{ + ulg c = crc; /* temporary variable */ + unsigned n; + uch *in, ch; + in = window; + for (n = 0; n < outcnt; n++) { + ch = *output_data++ = *in++; + if ((ulg)output_data == low_buffer_end) output_data=high_buffer_start; + c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8); + } + crc = c; + bytes_out += (ulg)outcnt; + outcnt = 0; +} + +static void flush_window(void) +{ + if (high_loaded) flush_window_high(); + else flush_window_low(); +} + +static void error(char *x) +{ + puts("\n\n"); + puts(x); + puts("\n\n -- System halted"); + + while(1); /* Halt */ +} + +#define STACK_SIZE (4096) + +long user_stack [STACK_SIZE]; + +struct { + long * a; + short b; + } stack_start = { & user_stack [STACK_SIZE] , __BOOT_DS }; + +static void setup_normal_output_buffer(void) +{ +#ifdef STANDARD_MEMORY_BIOS_CALL + if (EXT_MEM_K < 1024) error("Less than 2MB of memory.\n"); +#else + if ((ALT_MEM_K > EXT_MEM_K ? ALT_MEM_K : EXT_MEM_K) < 1024) error("Less than 2MB of memory.\n"); +#endif + output_data = (char *)0x100000; /* Points to 1M */ + free_mem_end_ptr = (long)real_mode; +} + +struct moveparams { + uch *low_buffer_start; int lcount; + uch *high_buffer_start; int hcount; +}; + +static void setup_output_buffer_if_we_run_high(struct moveparams *mv) +{ + high_buffer_start = (uch *)(((ulg)&end) + HEAP_SIZE); +#ifdef STANDARD_MEMORY_BIOS_CALL + if (EXT_MEM_K < (3*1024)) error("Less than 4MB of memory.\n"); +#else + if ((ALT_MEM_K > EXT_MEM_K ? ALT_MEM_K : EXT_MEM_K) < (3*1024)) error("Less than 4MB of memory.\n"); +#endif + mv->low_buffer_start = output_data = (char *)LOW_BUFFER_START; + low_buffer_end = ((unsigned int)real_mode > LOW_BUFFER_MAX + ? LOW_BUFFER_MAX : (unsigned int)real_mode) & ~0xfff; + low_buffer_size = low_buffer_end - LOW_BUFFER_START; + high_loaded = 1; + free_mem_end_ptr = (long)high_buffer_start; + if ( (0x100000 + low_buffer_size) > ((ulg)high_buffer_start)) { + high_buffer_start = (uch *)(0x100000 + low_buffer_size); + mv->hcount = 0; /* say: we need not to move high_buffer */ + } + else mv->hcount = -1; + mv->high_buffer_start = high_buffer_start; +} + +static void close_output_buffer_if_we_run_high(struct moveparams *mv) +{ + if (bytes_out > low_buffer_size) { + mv->lcount = low_buffer_size; + if (mv->hcount) + mv->hcount = bytes_out - low_buffer_size; + } else { + mv->lcount = bytes_out; + mv->hcount = 0; + } +} + + +asmlinkage int decompress_kernel(struct moveparams *mv, void *rmode) +{ + real_mode = rmode; + + vidmem = (char *)(((unsigned int)SCREEN_INFO.orig_video_page) << 4); + + lines = SCREEN_INFO.orig_video_lines; + cols = SCREEN_INFO.orig_video_cols; + + if (free_mem_ptr < 0x100000) setup_normal_output_buffer(); + else setup_output_buffer_if_we_run_high(mv); + + makecrc(); + puts("Uncompressing Linux... "); + gunzip(); + puts("Ok, booting the kernel.\n"); + if (high_loaded) close_output_buffer_if_we_run_high(mv); + return high_loaded; +} + +/* We don't actually check for stack overflows this early. */ +__asm__(".globl mcount ; mcount: ret\n"); + diff -Nru a/arch/i386/boot98/compressed/vmlinux.scr b/arch/i386/boot98/compressed/vmlinux.scr --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/arch/i386/boot98/compressed/vmlinux.scr Sun Mar 23 00:22:57 2003 @@ -0,0 +1,9 @@ +SECTIONS +{ + .data : { + input_len = .; + LONG(input_data_end - input_data) input_data = .; + *(.data) + input_data_end = .; + } +} diff -Nru a/arch/i386/boot98/install.sh b/arch/i386/boot98/install.sh --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/arch/i386/boot98/install.sh Sun Mar 23 00:22:57 2003 @@ -0,0 +1,40 @@ +#!/bin/sh +# +# arch/i386/boot/install.sh +# +# This file is subject to the terms and conditions of the GNU General Public +# License. See the file "COPYING" in the main directory of this archive +# for more details. +# +# Copyright (C) 1995 by Linus Torvalds +# +# Adapted from code in arch/i386/boot/Makefile by H. Peter Anvin +# +# "make install" script for i386 architecture +# +# Arguments: +# $1 - kernel version +# $2 - kernel image file +# $3 - kernel map file +# $4 - default install path (blank if root directory) +# + +# User may have a custom install script + +if [ -x ~/bin/installkernel ]; then exec ~/bin/installkernel "$@"; fi +if [ -x /sbin/installkernel ]; then exec /sbin/installkernel "$@"; fi + +# Default install - same as make zlilo + +if [ -f $4/vmlinuz ]; then + mv $4/vmlinuz $4/vmlinuz.old +fi + +if [ -f $4/System.map ]; then + mv $4/System.map $4/System.old +fi + +cat $2 > $4/vmlinuz +cp $3 $4/System.map + +if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi diff -Nru a/arch/i386/boot98/setup.S b/arch/i386/boot98/setup.S --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/arch/i386/boot98/setup.S Sun Mar 23 00:22:57 2003 @@ -0,0 +1,961 @@ +/* + * setup.S Copyright (C) 1991, 1992 Linus Torvalds + * + * setup.s is responsible for getting the system data from the BIOS, + * and putting them into the appropriate places in system memory. + * both setup.s and system has been loaded by the bootblock. + * + * This code asks the bios for memory/disk/other parameters, and + * puts them in a "safe" place: 0x90000-0x901FF, ie where the + * boot-block used to be. It is then up to the protected mode + * system to read them from there before the area is overwritten + * for buffer-blocks. + * + * Move PS/2 aux init code to psaux.c + * (troyer@saifr00.cfsat.Honeywell.COM) 03Oct92 + * + * some changes and additional features by Christoph Niemann, + * March 1993/June 1994 (Christoph.Niemann@linux.org) + * + * add APM BIOS checking by Stephen Rothwell, May 1994 + * (sfr@canb.auug.org.au) + * + * High load stuff, initrd support and position independency + * by Hans Lermen & Werner Almesberger, February 1996 + * , + * + * Video handling moved to video.S by Martin Mares, March 1996 + * + * + * Extended memory detection scheme retwiddled by orc@pell.chi.il.us (david + * parsons) to avoid loadlin confusion, July 1997 + * + * Transcribed from Intel (as86) -> AT&T (gas) by Chris Noe, May 1999. + * + * + * Fix to work around buggy BIOSes which dont use carry bit correctly + * and/or report extended memory in CX/DX for e801h memory size detection + * call. As a result the kernel got wrong figures. The int15/e801h docs + * from Ralf Brown interrupt list seem to indicate AX/BX should be used + * anyway. So to avoid breaking many machines (presumably there was a reason + * to orginally use CX/DX instead of AX/BX), we do a kludge to see + * if CX/DX have been changed in the e801 call and if so use AX/BX . + * Michael Miller, April 2001 + * + * New A20 code ported from SYSLINUX by H. Peter Anvin. AMD Elan bugfixes + * by Robert Schwebel, December 2001 + * + * Heavily modified for NEC PC-9800 series by Kyoto University Microcomputer + * Club (KMC) Linux/98 project , 1997-1999 + */ + +#include +#include +#include +#include +#include +#include +#include + +/* Signature words to ensure LILO loaded us right */ +#define SIG1 0xAA55 +#define SIG2 0x5A5A + +#define HIRESO_TEXT 0xe000 +#define NORMAL_TEXT 0xa000 + +#define BIOS_FLAG2 0x0400 +#define BIOS_FLAG5 0x0458 +#define RDISK_EQUIP 0x0488 +#define BIOS_FLAG 0x0501 +#define KB_SHFT_STS 0x053a +#define DISK_EQUIP 0x055c + +INITSEG = DEF_INITSEG # 0x9000, we move boot here, out of the way +SYSSEG = DEF_SYSSEG # 0x1000, system loaded at 0x10000 (65536). +SETUPSEG = DEF_SETUPSEG # 0x9020, this is the current segment + # ... and the former contents of CS + +DELTA_INITSEG = SETUPSEG - INITSEG # 0x0020 + +.code16 +.globl begtext, begdata, begbss, endtext, enddata, endbss + +.text +begtext: +.data +begdata: +.bss +begbss: +.text + +start: + jmp trampoline + +# This is the setup header, and it must start at %cs:2 (old 0x9020:2) + + .ascii "HdrS" # header signature + .word 0x0203 # header version number (>= 0x0105) + # or else old loadlin-1.5 will fail) +realmode_swtch: .word 0, 0 # default_switch, SETUPSEG +start_sys_seg: .word SYSSEG + .word kernel_version # pointing to kernel version string + # above section of header is compatible + # with loadlin-1.5 (header v1.5). Don't + # change it. + +type_of_loader: .byte 0 # = 0, old one (LILO, Loadlin, + # Bootlin, SYSLX, bootsect...) + # See Documentation/i386/boot.txt for + # assigned ids + +# flags, unused bits must be zero (RFU) bit within loadflags +loadflags: +LOADED_HIGH = 1 # If set, the kernel is loaded high +CAN_USE_HEAP = 0x80 # If set, the loader also has set + # heap_end_ptr to tell how much + # space behind setup.S can be used for + # heap purposes. + # Only the loader knows what is free +#ifndef __BIG_KERNEL__ + .byte 0 +#else + .byte LOADED_HIGH +#endif + +setup_move_size: .word 0x8000 # size to move, when setup is not + # loaded at 0x90000. We will move setup + # to 0x90000 then just before jumping + # into the kernel. However, only the + # loader knows how much data behind + # us also needs to be loaded. + +code32_start: # here loaders can put a different + # start address for 32-bit code. +#ifndef __BIG_KERNEL__ + .long 0x1000 # 0x1000 = default for zImage +#else + .long 0x100000 # 0x100000 = default for big kernel +#endif + +ramdisk_image: .long 0 # address of loaded ramdisk image + # Here the loader puts the 32-bit + # address where it loaded the image. + # This only will be read by the kernel. + +ramdisk_size: .long 0 # its size in bytes + +bootsect_kludge: + .word bootsect_helper, SETUPSEG + +heap_end_ptr: .word modelist+1024 # (Header version 0x0201 or later) + # space from here (exclusive) down to + # end of setup code can be used by setup + # for local heap purposes. + +pad1: .word 0 +cmd_line_ptr: .long 0 # (Header version 0x0202 or later) + # If nonzero, a 32-bit pointer + # to the kernel command line. + # The command line should be + # located between the start of + # setup and the end of low + # memory (0xa0000), or it may + # get overwritten before it + # gets read. If this field is + # used, there is no longer + # anything magical about the + # 0x90000 segment; the setup + # can be located anywhere in + # low memory 0x10000 or higher. + +ramdisk_max: .long __MAXMEM-1 # (Header version 0x0203 or later) + # The highest safe address for + # the contents of an initrd + +trampoline: call start_of_setup + .space 1024 +# End of setup header ##################################################### + +start_of_setup: +# Set %ds = %cs, we know that SETUPSEG = %cs at this point + movw %cs, %ax # aka SETUPSEG + movw %ax, %ds +# Check signature at end of setup + cmpw $SIG1, setup_sig1 + jne bad_sig + + cmpw $SIG2, setup_sig2 + jne bad_sig + + jmp good_sig1 + +# Routine to print asciiz string at ds:si +prtstr: + lodsb + andb %al, %al + jz fin + + call prtchr + jmp prtstr + +fin: ret + +no_sig_mess: .string "No setup signature found ..." + +good_sig1: + jmp good_sig + +# We now have to find the rest of the setup code/data +bad_sig: + movw %cs, %ax # SETUPSEG + subw $DELTA_INITSEG, %ax # INITSEG + movw %ax, %ds + xorb %bh, %bh + movb (497), %bl # get setup sect from bootsect + subw $4, %bx # LILO loads 4 sectors of setup + shlw $8, %bx # convert to words (1sect=2^8 words) + movw %bx, %cx + shrw $3, %bx # convert to segment + addw $SYSSEG, %bx + movw %bx, %cs:start_sys_seg +# Move rest of setup code/data to here + movw $2048, %di # four sectors loaded by LILO + subw %si, %si + pushw %cs + popw %es + movw $SYSSEG, %ax + movw %ax, %ds + rep + movsw + movw %cs, %ax # aka SETUPSEG + movw %ax, %ds + cmpw $SIG1, setup_sig1 + jne no_sig + + cmpw $SIG2, setup_sig2 + jne no_sig + + jmp good_sig + +no_sig: + lea no_sig_mess, %si + call prtstr + +no_sig_loop: + hlt + jmp no_sig_loop + +good_sig: + movw %cs, %ax # aka SETUPSEG + subw $DELTA_INITSEG, %ax # aka INITSEG + movw %ax, %ds +# Check if an old loader tries to load a big-kernel + testb $LOADED_HIGH, %cs:loadflags # Do we have a big kernel? + jz loader_ok # No, no danger for old loaders. + + cmpb $0, %cs:type_of_loader # Do we have a loader that + # can deal with us? + jnz loader_ok # Yes, continue. + + pushw %cs # No, we have an old loader, + popw %ds # die. + lea loader_panic_mess, %si + call prtstr + + jmp no_sig_loop + +loader_panic_mess: .string "Wrong loader, giving up..." + +loader_ok: +# Get memory size (extended mem, kB) + +# On PC-9800, memory size detection is done completely in 32-bit +# kernel initialize code (kernel/setup.c). + pushw %es + xorl %eax, %eax + movw %ax, %es + movb %al, (E820NR) # PC-9800 has no E820 + movb %es:(0x401), %al + shll $7, %eax + addw $1024, %ax + movw %ax, (2) + movl %eax, (0x1e0) + movw %es:(0x594), %ax + shll $10, %eax + addl %eax, (0x1e0) + popw %es + +# Check for video adapter and its parameters and allow the +# user to browse video modes. + call video # NOTE: we need %ds pointing + # to bootsector + +# Get text video mode + movb $0x0B, %ah + int $0x18 # CRT mode sense + movw $(20 << 8) + 40, %cx + testb $0x10, %al + jnz 3f + movb $20, %ch + testb $0x01, %al + jnz 1f + movb $25, %ch + jmp 1f +3: # If bit 4 was 1, it means either 1) 31 lines for hi-reso mode, + # or 2) 30 lines for PC-9821. + movb $31, %ch # hireso mode value + pushw $0 + popw %es + testb $0x08, %es:BIOS_FLAG + jnz 1f + movb $30, %ch +1: # Now we got # of rows in %ch + movb %ch, (14) + + testb $0x02, %al + jnz 2f + movb $80, %cl +2: # Now we got # of columns in %cl + movb %cl, (7) + + # Next, get horizontal frequency if supported + movw $0x3100, %ax + int $0x18 # Call CRT bios + movb %al, (6) # If 31h is unsupported, %al remains 0 + +# Get hd0-3 data... + pushw %ds # aka INITSEG + popw %es + xorw %ax, %ax + movw %ax, %ds + cld + movw $0x0080, %di + movb DISK_EQUIP+1, %ah + movb $0x80, %al + +get_hd_info: + shrb %ah + pushw %ax + jnc 1f + movb $0x84, %ah + int $0x1b + jnc 2f # Success +1: xorw %cx, %cx # `0 cylinders' means no drive +2: # Attention! Work area (drive_info) is arranged for PC-9800. + movw %cx, %ax # # of cylinders + stosw + movw %dx, %ax # # of sectors / # of heads + stosw + movw %bx, %ax # sector size in bytes + stosw + popw %ax + incb %al + cmpb $0x84, %al + jb get_hd_info + +# Get fd data... + movw DISK_EQUIP, %ax + andw $0xf00f, %ax + orb %al, %ah + movb RDISK_EQUIP, %al + notb %al + andb %al, %ah # ignore all `RAM drive' + + movb $0x30, %al + +get_fd_info: + shrb %ah + pushw %ax + jnc 1f + movb $0xc4, %ah + int $0x1b + movb %ah, %al + andb $4, %al # 1.44MB support flag + shrb %al + addb $2, %al # %al = 2 (1.2MB) or 4 (1.44MB) + jmp 2f +1: movb $0, %al # no drive +2: stosb + popw %ax + incb %al + testb $0x04, %al + jz get_fd_info + + addb $(0xb0 - 0x34), %al + jnc get_fd_info # check FDs on 640KB I/F + + pushw %es + popw %ds # %ds got bootsector again +#if 0 + mov $0, (0x1ff) # default is no pointing device +#endif + +#if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE) +# Then check for an APM BIOS... + # %ds points to the bootsector + movw $0, 0x40 # version = 0 means no APM BIOS + movw $0x09a00, %ax # APM BIOS installation check + xorw %bx, %bx + int $0x1f + jc done_apm_bios # Nope, no APM BIOS + + cmpw $0x0504d, %bx # Check for "PM" signature + jne done_apm_bios # No signature, no APM BIOS + + testb $0x02, %cl # Is 32 bit supported? + je done_apm_bios # No 32-bit, no (good) APM BIOS + + movw $0x09a04, %ax # Disconnect first just in case + xorw %bx, %bx + int $0x1f # ignore return code + movw $0x09a03, %ax # 32 bit connect + xorl %ebx, %ebx + int $0x1f + jc no_32_apm_bios # Ack, error. + + movw %ax, (66) # BIOS code segment + movl %ebx, (68) # BIOS entry point offset + movw %cx, (72) # BIOS 16 bit code segment + movw %dx, (74) # BIOS data segment + movl %esi, (78) # BIOS code segment length + movw %di, (82) # BIOS data segment length +# Redo the installation check as the 32 bit connect +# modifies the flags returned on some BIOSs + movw $0x09a00, %ax # APM BIOS installation check + xorw %bx, %bx + int $0x1f + jc apm_disconnect # error -> shouldn't happen + + cmpw $0x0504d, %bx # check for "PM" signature + jne apm_disconnect # no sig -> shouldn't happen + + movw %ax, (64) # record the APM BIOS version + movw %cx, (76) # and flags + jmp done_apm_bios + +apm_disconnect: # Tidy up + movw $0x09a04, %ax # Disconnect + xorw %bx, %bx + int $0x1f # ignore return code + + jmp done_apm_bios + +no_32_apm_bios: + andw $0xfffd, (76) # remove 32 bit support bit +done_apm_bios: +#endif + +# Pass cursor position to kernel... + movw %cs:cursor_address, %ax + shrw %ax # cursor_address is 2 bytes unit + movb $80, %cl + divb %cl + xchgb %al, %ah # (0) = %al = X, (1) = %ah = Y + movw %ax, (0) + +#if 0 + movw $msg_cpos, %si + call prtstr_cs + call prthex + call prtstr_cs + movw %ds, %ax + call prthex + call prtstr_cs + movb $0x11, %ah + int $0x18 + movb $0, %ah + int $0x18 + .section .rodata, "a" +msg_cpos: .string "Cursor position: 0x" + .string ", %ds:0x" + .string "\r\n" + .previous +#endif + +# Now we want to move to protected mode ... + cmpw $0, %cs:realmode_swtch + jz rmodeswtch_normal + + lcall *%cs:realmode_swtch + + jmp rmodeswtch_end + +rmodeswtch_normal: + pushw %cs + call default_switch + +rmodeswtch_end: +# we get the code32 start address and modify the below 'jmpi' +# (loader may have changed it) + movl %cs:code32_start, %eax + movl %eax, %cs:code32 + +# Now we move the system to its rightful place ... but we check if we have a +# big-kernel. In that case we *must* not move it ... + testb $LOADED_HIGH, %cs:loadflags + jz do_move0 # .. then we have a normal low + # loaded zImage + # .. or else we have a high + # loaded bzImage + jmp end_move # ... and we skip moving + +do_move0: + movw $0x100, %ax # start of destination segment + movw %cs, %bp # aka SETUPSEG + subw $DELTA_INITSEG, %bp # aka INITSEG + movw %cs:start_sys_seg, %bx # start of source segment + cld +do_move: + movw %ax, %es # destination segment + incb %ah # instead of add ax,#0x100 + movw %bx, %ds # source segment + addw $0x100, %bx + subw %di, %di + subw %si, %si + movw $0x800, %cx + rep + movsw + cmpw %bp, %bx # assume start_sys_seg > 0x200, + # so we will perhaps read one + # page more than needed, but + # never overwrite INITSEG + # because destination is a + # minimum one page below source + jb do_move + +end_move: +# then we load the segment descriptors + movw %cs, %ax # aka SETUPSEG + movw %ax, %ds + +# Check whether we need to be downward compatible with version <=201 + cmpl $0, cmd_line_ptr + jne end_move_self # loader uses version >=202 features + cmpb $0x20, type_of_loader + je end_move_self # bootsect loader, we know of it + +# Boot loader does not support boot protocol version 2.02. +# If we have our code not at 0x90000, we need to move it there now. +# We also then need to move the params behind it (commandline) +# Because we would overwrite the code on the current IP, we move +# it in two steps, jumping high after the first one. + movw %cs, %ax + cmpw $SETUPSEG, %ax + je end_move_self + + cli # make sure we really have + # interrupts disabled ! + # because after this the stack + # should not be used + subw $DELTA_INITSEG, %ax # aka INITSEG + movw %ss, %dx + cmpw %ax, %dx + jb move_self_1 + + addw $INITSEG, %dx + subw %ax, %dx # this will go into %ss after + # the move +move_self_1: + movw %ax, %ds + movw $INITSEG, %ax # real INITSEG + movw %ax, %es + movw %cs:setup_move_size, %cx + std # we have to move up, so we use + # direction down because the + # areas may overlap + movw %cx, %di + decw %di + movw %di, %si + subw $move_self_here+0x200, %cx + rep + movsb + ljmp $SETUPSEG, $move_self_here + +move_self_here: + movw $move_self_here+0x200, %cx + rep + movsb + movw $SETUPSEG, %ax + movw %ax, %ds + movw %dx, %ss + +end_move_self: # now we are at the right place + lidt idt_48 # load idt with 0,0 + xorl %eax, %eax # Compute gdt_base + movw %ds, %ax # (Convert %ds:gdt to a linear ptr) + shll $4, %eax + addl $gdt, %eax + movl %eax, (gdt_48+2) + lgdt gdt_48 # load gdt with whatever is + # appropriate + +# that was painless, now we enable A20 + + outb %al, $0xf2 # A20 on + movb $0x02, %al + outb %al, $0xf6 # also A20 on; making ITF's + # way our model + + # PC-9800 seems to enable A20 at the moment of `outb'; + # so we don't wait unlike IBM PCs (see ../setup.S). + +# enable DMA to access memory over 0x100000 (1MB). + + movw $0x439, %dx + inb %dx, %al + andb $(~4), %al + outb %al, %dx + +# Set DMA to increment its bank address automatically at 16MB boundary. +# Initial setting is 64KB boundary mode so that we can't run DMA crossing +# physical address 0xXXXXFFFF. + + movb $0x0c, %al + outb %al, $0x29 # ch. 0 + movb $0x0d, %al + outb %al, $0x29 # ch. 1 + movb $0x0e, %al + outb %al, $0x29 # ch. 2 + movb $0x0f, %al + outb %al, $0x29 # ch. 3 + movb $0x50, %al + outb %al, $0x11 # reinitialize DMAC + +# make sure any possible coprocessor is properly reset.. + movb $0, %al + outb %al, $0xf8 + outb %al, $0x5f # delay + +# well, that went ok, I hope. Now we mask all interrupts - the rest +# is done in init_IRQ(). + movb $0xFF, %al # mask all interrupts for now + outb %al, $0x0A + outb %al, $0x5f # delay + + movb $0x7F, %al # mask all irq's but irq7 which + outb %al, $0x02 # is cascaded + +# Well, that certainly wasn't fun :-(. Hopefully it works, and we don't +# need no steenking BIOS anyway (except for the initial loading :-). +# The BIOS-routine wants lots of unnecessary data, and it's less +# "interesting" anyway. This is how REAL programmers do it. +# +# Well, now's the time to actually move into protected mode. To make +# things as simple as possible, we do no register set-up or anything, +# we let the gnu-compiled 32-bit programs do that. We just jump to +# absolute address 0x1000 (or the loader supplied one), +# in 32-bit protected mode. +# +# Note that the short jump isn't strictly needed, although there are +# reasons why it might be a good idea. It won't hurt in any case. + movw $1, %ax # protected mode (PE) bit + lmsw %ax # This is it! + jmp flush_instr + +flush_instr: + xorw %bx, %bx # Flag to indicate a boot + xorl %esi, %esi # Pointer to real-mode code + movw %cs, %si + subw $DELTA_INITSEG, %si + shll $4, %esi # Convert to 32-bit pointer +# NOTE: For high loaded big kernels we need a +# jmpi 0x100000,__BOOT_CS +# +# but we yet haven't reloaded the CS register, so the default size +# of the target offset still is 16 bit. +# However, using an operand prefix (0x66), the CPU will properly +# take our 48 bit far pointer. (INTeL 80386 Programmer's Reference +# Manual, Mixing 16-bit and 32-bit code, page 16-6) + + .byte 0x66, 0xea # prefix + jmpi-opcode +code32: .long 0x1000 # will be set to 0x100000 + # for big kernels + .word __BOOT_CS + +# Here's a bunch of information about your current kernel.. +kernel_version: .ascii UTS_RELEASE + .ascii " (" + .ascii LINUX_COMPILE_BY + .ascii "@" + .ascii LINUX_COMPILE_HOST + .ascii ") " + .ascii UTS_VERSION + .byte 0 + +# This is the default real mode switch routine. +# to be called just before protected mode transition +default_switch: + cli # no interrupts allowed ! + outb %al, $0x50 # disable NMI for bootup + # sequence + lret + +# This routine only gets called, if we get loaded by the simple +# bootsect loader _and_ have a bzImage to load. +# Because there is no place left in the 512 bytes of the boot sector, +# we must emigrate to code space here. +bootsect_helper: + cmpw $0, %cs:bootsect_es + jnz bootsect_second + + movb $0x20, %cs:type_of_loader + movw %es, %ax + shrw $4, %ax + movb %ah, %cs:bootsect_src_base+2 + movw %es, %ax + movw %ax, %cs:bootsect_es + subw $SYSSEG, %ax + lret # nothing else to do for now + +bootsect_second: + pushw %bx + pushw %cx + pushw %si + pushw %di + testw %bp, %bp # 64K full ? + jne bootsect_ex + + xorw %cx, %cx # zero means full 64K + pushw %cs + popw %es + movw $bootsect_gdt, %bx + xorw %si, %si # source address + xorw %di, %di # destination address + movb $0x90, %ah + int $0x1f + jc bootsect_panic # this, if INT1F fails + + movw %cs:bootsect_es, %es # we reset %es to always point + incb %cs:bootsect_dst_base+2 # to 0x10000 +bootsect_ex: + movb %cs:bootsect_dst_base+2, %ah + shlb $4, %ah # we now have the number of + # moved frames in %ax + xorb %al, %al + popw %di + popw %si + popw %cx + popw %bx + lret + +bootsect_gdt: + .word 0, 0, 0, 0 + .word 0, 0, 0, 0 + +bootsect_src: + .word 0xffff + +bootsect_src_base: + .byte 0x00, 0x00, 0x01 # base = 0x010000 + .byte 0x93 # typbyte + .word 0 # limit16,base24 =0 + +bootsect_dst: + .word 0xffff + +bootsect_dst_base: + .byte 0x00, 0x00, 0x10 # base = 0x100000 + .byte 0x93 # typbyte + .word 0 # limit16,base24 =0 + .word 0, 0, 0, 0 # BIOS CS + .word 0, 0, 0, 0 # BIOS DS + +bootsect_es: + .word 0 + +bootsect_panic: + pushw %cs + popw %ds + cld + leaw bootsect_panic_mess, %si + call prtstr + +bootsect_panic_loop: + jmp bootsect_panic_loop + +bootsect_panic_mess: + .string "INT1F refuses to access high mem, giving up." + +# This routine prints one character (in %al) on console. +# PC-9800 doesn't have BIOS-function to do it like IBM PC's INT 10h - 0Eh, +# so we hardcode `prtchr' subroutine here. +prtchr: + pushaw + pushw %es + cmpb $0, %cs:prtchr_initialized + jnz prtchr_ok + xorw %cx, %cx + movw %cx, %es + testb $0x8, %es:BIOS_FLAG + jz 1f + movb $(HIRESO_TEXT >> 8), %cs:cursor_address+3 + movw $(80 * 31 * 2), %cs:max_cursor_offset +1: pushw %ax + call get_cursor_position + movw %ax, %cs:cursor_address + popw %ax + movb $1, %cs:prtchr_initialized +prtchr_ok: + lesw %cs:cursor_address, %di + movw $160, %bx + movb $0, %ah + cmpb $13, %al + je do_cr + cmpb $10, %al + je do_lf + + # normal (printable) character + stosw + movb $0xe1, %es:0x2000-2(%di) + jmp 1f + +do_cr: movw %di, %ax + divb %bl # %al = Y, %ah = X * 2 + mulb %bl + movw %ax, %dx + jmp 2f + +do_lf: addw %bx, %di +1: movw %cs:max_cursor_offset, %cx + cmpw %cx, %di + movw %di, %dx + jb 2f + # cursor reaches bottom of screen; scroll it + subw %bx, %dx + xorw %di, %di + movw %bx, %si + cld + subw %bx, %cx + shrw %cx + pushw %cx + rep; es; movsw + movb $32, %al # clear bottom line characters + movb $80, %cl + rep; stosw + movw $0x2000, %di + popw %cx + leaw (%bx,%di), %si + rep; es; movsw + movb $0xe1, %al # clear bottom line attributes + movb $80, %cl + rep; stosw +2: movw %dx, %cs:cursor_address + movb $0x13, %ah # move cursor to right position + int $0x18 + popw %es + popaw + ret + +cursor_address: + .word 0 + .word NORMAL_TEXT +max_cursor_offset: + .word 80 * 25 * 2 # for normal 80x25 mode + +# putstr may called without running through start_of_setup (via bootsect_panic) +# so we should initialize ourselves on demand. +prtchr_initialized: + .byte 0 + +# This routine queries GDC (graphic display controller) for current cursor +# position. Cursor position is returned in %ax (CPU offset address). +get_cursor_position: +1: inb $0x60, %al + outb %al, $0x5f # delay + outb %al, $0x5f # delay + testb $0x04, %al # Is FIFO empty? + jz 1b # no -> wait until empty + + movb $0xe0, %al # CSRR command + outb %al, $0x62 # command write + outb %al, $0x5f # delay + outb %al, $0x5f # delay + +2: inb $0x60, %al + outb %al, $0x5f # delay + outb %al, $0x5f # delay + testb $0x01, %al # Is DATA READY? + jz 2b # no -> wait until ready + + inb $0x62, %al # read xAD (L) + outb %al, $0x5f # delay + outb %al, $0x5f # delay + movb %al, %ah + inb $0x62, %al # read xAD (H) + outb %al, $0x5f # delay + outb %al, $0x5f # delay + xchgb %al, %ah # correct byte order + pushw %ax + inb $0x62, %al # read yAD (L) + outb %al, $0x5f # delay + outb %al, $0x5f # delay + inb $0x62, %al # read yAD (M) + outb %al, $0x5f # delay + outb %al, $0x5f # delay + inb $0x62, %al # read yAD (H) + # yAD is not our interest, + # so discard it. + popw %ax + addw %ax, %ax # convert to CPU address + ret + +# Descriptor tables +# +# NOTE: The intel manual says gdt should be sixteen bytes aligned for +# efficiency reasons. However, there are machines which are known not +# to boot with misaligned GDTs, so alter this at your peril! If you alter +# GDT_ENTRY_BOOT_CS (in asm/segment.h) remember to leave at least two +# empty GDT entries (one for NULL and one reserved). +# +# NOTE: On some CPUs, the GDT must be 8 byte aligned. This is +# true for the Voyager Quad CPU card which will not boot without +# This directive. 16 byte aligment is recommended by intel. +# + .align 16 +gdt: + .fill GDT_ENTRY_BOOT_CS,8,0 + + .word 0xFFFF # 4Gb - (0x100000*0x1000 = 4Gb) + .word 0 # base address = 0 + .word 0x9A00 # code read/exec + .word 0x00CF # granularity = 4096, 386 + # (+5th nibble of limit) + + .word 0xFFFF # 4Gb - (0x100000*0x1000 = 4Gb) + .word 0 # base address = 0 + .word 0x9200 # data read/write + .word 0x00CF # granularity = 4096, 386 + # (+5th nibble of limit) +gdt_end: + .align 4 + + .word 0 # alignment byte +idt_48: + .word 0 # idt limit = 0 + .word 0, 0 # idt base = 0L + + .word 0 # alignment byte +gdt_48: + .word gdt_end - gdt - 1 # gdt limit + .word 0, 0 # gdt base (filled in later) + +# Include video setup & detection code + +#include "video.S" + +# Setup signature -- must be last +setup_sig1: .word SIG1 +setup_sig2: .word SIG2 + +# After this point, there is some free space which is used by the video mode +# handling code to store the temporary mode table (not used by the kernel). + +modelist: + +.text +endtext: +.data +enddata: +.bss +endbss: diff -Nru a/arch/i386/boot98/tools/build.c b/arch/i386/boot98/tools/build.c --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/arch/i386/boot98/tools/build.c Sun Mar 23 00:22:57 2003 @@ -0,0 +1,188 @@ +/* + * $Id: build.c,v 1.5 1997/05/19 12:29:58 mj Exp $ + * + * Copyright (C) 1991, 1992 Linus Torvalds + * Copyright (C) 1997 Martin Mares + */ + +/* + * This file builds a disk-image from three different files: + * + * - bootsect: exactly 512 bytes of 8086 machine code, loads the rest + * - setup: 8086 machine code, sets up system parm + * - system: 80386 code for actual system + * + * It does some checking that all files are of the correct type, and + * just writes the result to stdout, removing headers and padding to + * the right amount. It also writes some system data to stderr. + */ + +/* + * Changes by tytso to allow root device specification + * High loaded stuff by Hans Lermen & Werner Almesberger, Feb. 1996 + * Cross compiling fixes by Gertjan van Wingerde, July 1996 + * Rewritten by Martin Mares, April 1997 + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef unsigned char byte; +typedef unsigned short word; +typedef unsigned long u32; + +#define DEFAULT_MAJOR_ROOT 0 +#define DEFAULT_MINOR_ROOT 0 + +/* Minimal number of setup sectors (see also bootsect.S) */ +#define SETUP_SECTS 4 + +byte buf[1024]; +int fd; +int is_big_kernel; + +void die(const char * str, ...) +{ + va_list args; + va_start(args, str); + vfprintf(stderr, str, args); + fputc('\n', stderr); + exit(1); +} + +void file_open(const char *name) +{ + if ((fd = open(name, O_RDONLY, 0)) < 0) + die("Unable to open `%s': %m", name); +} + +void usage(void) +{ + die("Usage: build [-b] bootsect setup system [rootdev] [> image]"); +} + +int main(int argc, char ** argv) +{ + unsigned int i, c, sz, setup_sectors; + u32 sys_size; + byte major_root, minor_root; + struct stat sb; + + if (argc > 2 && !strcmp(argv[1], "-b")) + { + is_big_kernel = 1; + argc--, argv++; + } + if ((argc < 4) || (argc > 5)) + usage(); + if (argc > 4) { + if (!strcmp(argv[4], "CURRENT")) { + if (stat("/", &sb)) { + perror("/"); + die("Couldn't stat /"); + } + major_root = major(sb.st_dev); + minor_root = minor(sb.st_dev); + } else if (strcmp(argv[4], "FLOPPY")) { + if (stat(argv[4], &sb)) { + perror(argv[4]); + die("Couldn't stat root device."); + } + major_root = major(sb.st_rdev); + minor_root = minor(sb.st_rdev); + } else { + major_root = 0; + minor_root = 0; + } + } else { + major_root = DEFAULT_MAJOR_ROOT; + minor_root = DEFAULT_MINOR_ROOT; + } + fprintf(stderr, "Root device is (%d, %d)\n", major_root, minor_root); + + file_open(argv[1]); + i = read(fd, buf, sizeof(buf)); + fprintf(stderr,"Boot sector %d bytes.\n",i); + if (i != 512) + die("Boot block must be exactly 512 bytes"); + if (buf[510] != 0x55 || buf[511] != 0xaa) + die("Boot block hasn't got boot flag (0xAA55)"); + buf[508] = minor_root; + buf[509] = major_root; + if (write(1, buf, 512) != 512) + die("Write call failed"); + close (fd); + + file_open(argv[2]); /* Copy the setup code */ + for (i=0 ; (c=read(fd, buf, sizeof(buf)))>0 ; i+=c ) + if (write(1, buf, c) != c) + die("Write call failed"); + if (c != 0) + die("read-error on `setup'"); + close (fd); + + setup_sectors = (i + 511) / 512; /* Pad unused space with zeros */ + if (!(setup_sectors & 1)) + setup_sectors++; /* setup_sectors must be odd on NEC PC-9800 */ + fprintf(stderr, "Setup is %d bytes.\n", i); + memset(buf, 0, sizeof(buf)); + while (i < setup_sectors * 512) { + c = setup_sectors * 512 - i; + if (c > sizeof(buf)) + c = sizeof(buf); + if (write(1, buf, c) != c) + die("Write call failed"); + i += c; + } + + file_open(argv[3]); + if (fstat (fd, &sb)) + die("Unable to stat `%s': %m", argv[3]); + sz = sb.st_size; + fprintf (stderr, "System is %d kB\n", sz/1024); + sys_size = (sz + 15) / 16; + /* 0x28000*16 = 2.5 MB, conservative estimate for the current maximum */ + if (sys_size > (is_big_kernel ? 0x28000 : DEF_SYSSIZE)) + die("System is too big. Try using %smodules.", + is_big_kernel ? "" : "bzImage or "); + if (sys_size > 0xefff) + fprintf(stderr,"warning: kernel is too big for standalone boot " + "from floppy\n"); + while (sz > 0) { + int l, n; + + l = (sz > sizeof(buf)) ? sizeof(buf) : sz; + if ((n=read(fd, buf, l)) != l) { + if (n < 0) + die("Error reading %s: %m", argv[3]); + else + die("%s: Unexpected EOF", argv[3]); + } + if (write(1, buf, l) != l) + die("Write failed"); + sz -= l; + } + close(fd); + + if (lseek(1, 497, SEEK_SET) != 497) /* Write sizes to the bootsector */ + die("Output: seek failed"); + buf[0] = setup_sectors; + if (write(1, buf, 1) != 1) + die("Write of setup sector count failed"); + if (lseek(1, 500, SEEK_SET) != 500) + die("Output: seek failed"); + buf[0] = (sys_size & 0xff); + buf[1] = ((sys_size >> 8) & 0xff); + if (write(1, buf, 2) != 2) + die("Write of image length failed"); + + return 0; /* Everything is OK */ +} diff -Nru a/arch/i386/boot98/video.S b/arch/i386/boot98/video.S --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/arch/i386/boot98/video.S Sun Mar 23 00:22:57 2003 @@ -0,0 +1,262 @@ +/* video.S + * + * Video mode setup, etc. for NEC PC-9800 series. + * + * Copyright (C) 1997,98,99 Linux/98 project + * + * Based on the video.S for IBM PC: + * copyright (C) Martin Mares + */ + +/* Positions of various video parameters passed to the kernel */ +/* (see also include/linux/tty.h) */ +#define PARAM_CURSOR_POS 0x00 +#define PARAM_VIDEO_PAGE 0x04 +#define PARAM_VIDEO_MODE 0x06 +#define PARAM_VIDEO_COLS 0x07 +#define PARAM_VIDEO_EGA_BX 0x0a +#define PARAM_VIDEO_LINES 0x0e +#define PARAM_HAVE_VGA 0x0f +#define PARAM_FONT_POINTS 0x10 + +#define PARAM_VIDEO98_COMPAT 0x0a +#define PARAM_VIDEO98_HIRESO 0x0b +#define PARAM_VIDEO98_MACHTYPE 0x0c +#define PARAM_VIDEO98_LINES 0x0e +#define PARAM_VIDEO98_COLS 0x0f + +# PARAM_LFB_* and PARAM_VESAPM_* are unused on PC-9800. + +# This is the main entry point called by setup.S +# %ds *must* be pointing to the bootsector +video: xorw %ax, %ax + movw %ax, %es # %es = 0 + + movb %es:BIOS_FLAG, %al + movb %al, PARAM_VIDEO_MODE + + movb $0, PARAM_VIDEO98_HIRESO # 0 = normal + movw $NORMAL_TEXT, PARAM_VIDEO_PAGE + testb $0x8, %al + movw $(80 * 256 + 25), %ax + jz 1f + # hireso machine. + movb $1, PARAM_VIDEO98_HIRESO # !0 = hi-reso + movb $(HIRESO_TEXT >> 8), PARAM_VIDEO_PAGE + 1 + movw $(80 * 256 + 31), %ax +1: movw %ax, PARAM_VIDEO98_LINES # also sets VIDEO98_COLS + + movb $0xc0, %ch # 400-line graphic mode + movb $0x42, %ah + int $0x18 + + movw $80, PARAM_VIDEO_COLS + + movw $msg_probing, %si + call prtstr_cs + +# Check vendor from font pattern of `A'... + +1: inb $0x60, %al # wait V-sync + testb $0x20, %al + jnz 1b +2: inb $0x60, %al + testb $0x20, %al + jz 2b + + movb $0x00, %al # select font of `A' + outb %al, $0xa1 + movb $0x41, %al + outb %al, $0xa3 + + movw $8, %cx + movw PARAM_VIDEO_PAGE, %ax + cmpw $NORMAL_TEXT, %ax + je 3f + movb $24, %cl # for hi-reso machine +3: addw $0x400, %ax # %ax = CG window segment + pushw %ds + movw %ax, %ds + xorw %dx, %dx # get sum of `A' pattern... + xorw %si, %si +4: lodsw + addw %ax, %dx + loop 4b + popw %ds + + movw %dx, %ax + movw $msg_nec, %si + xorw %bx, %bx # vendor info will go into %bx + testb $8, %es:BIOS_FLAG + jnz check_hireso_vendor + cmpw $0xc7f8, %ax + je 5f + jmp 6f +check_hireso_vendor: + cmpw $0x9639, %ax # XXX: NOT VERIFIED!!! + je 5f +6: incw %bx # compatible machine + movw $msg_compat, %si +5: movb %bl, PARAM_VIDEO98_COMPAT + call prtstr_cs + + movw $msg_fontdata, %si + call prtstr_cs # " (CG sum of A = 0x" + movw %dx, %ax + call prthex + call prtstr_cs # ") PC-98" + + movb $'0', %al + pushw %ds + pushw $0xf8e8 + popw %ds + cmpw $0x2198, (0) + popw %ds + jne 7f + movb $'2', %al +7: call prtchr + call prtstr_cs # "1 " + + movb $0, PARAM_VIDEO98_MACHTYPE +#if 0 /* XXX - This check is bogus? [0000:BIOS_FLAG2]-bit7 does NOT + indicate whether it is a note machine, but merely indicates + whether it has ``RAM drive''. */ +# check note machine + testb $0x80, %es:BIOS_FLAG2 + jnz is_note + pushw %ds + pushw $0xfd80 + popw %ds + movb (4), %al + popw %ds + cmpb $0x20, %al # EPSON note A + je epson_note + cmpb $0x22, %al # EPSON note W + je epson_note + cmpb $0x27, %al # EPSON note AE + je epson_note + cmpb $0x2a, %al # EPSON note WR + jne note_done +epson_note: + movb $1, PARAM_VIDEO98_MACHTYPE + movw $msg_note, %si + call prtstr_cs +note_done: +#endif + +# print h98 ? (only NEC) + cmpb $0, PARAM_VIDEO98_COMPAT + jnz 8f # not NEC -> not H98 + + testb $0x80, %es:BIOS_FLAG5 + jz 8f # have NESA bus -> H98 + movw $msg_h98, %si + call prtstr_cs + orb $2, PARAM_VIDEO98_MACHTYPE +8: testb $0x40, %es:BIOS_FLAG5 + jz 9f + movw $msg_gs, %si + call prtstr_cs # only prints it :-) +9: + movw $msg_normal, %si # "normal" + testb $0x8, %es:BIOS_FLAG + jz 1f + movw $msg_hireso, %si +1: call prtstr_cs + + movw $msg_sysclk, %si + call prtstr_cs + movb $'5', %al + testb $0x80, %es:BIOS_FLAG + jz 2f + movb $'8', %al +2: call prtchr + call prtstr_cs + +#if 0 + testb $0x40, %es:(0x45c) + jz no_30line # no 30-line support + + movb %es:KB_SHFT_STS, %al + testb $0x01, %al # is SHIFT key pressed? + jz no_30line + + testb $0x10, %al # is CTRL key pressed? + jnz line40 + + # switch to 30-line mode + movb $30, PARAM_VIDEO98_LINES + movw $msg_30line, %si + jmp 3f + +line40: + movb $37, PARAM_VIDEO98_LINES + movw $40, PARAM_VIDEO_LINES + movw $msg_40line, %si +3: call prtstr_cs + + movb $0x32, %bh + movw $0x300c, %ax + int $0x18 # switch video mode + movb $0x0c, %ah + int $0x18 # turn on text plane + movw %cs:cursor_address, %dx + movb $0x13, %ah + int $0x18 # move cursor to correct place + mov $0x11, %ah + int $0x18 # turn on text plane + + call prtstr_cs # "Ok.\r\n" +no_30line: +#endif + ret + +prtstr_cs: + pushw %ds + pushw %cs + popw %ds + call prtstr + popw %ds + ret + +# prthex is for debugging purposes, and prints %ax in hexadecimal. +prthex: pushw %cx + movw $4, %cx +1: rolw $4, %ax + pushw %ax + andb $0xf, %al + cmpb $10, %al + sbbb $0x69, %al + das + call prtchr + popw %ax + loop 1b + popw %cx + ret + +msg_probing: .string "Probing machine: " + +msg_nec: .string "NEC" +msg_compat: .string "compatible" + +msg_fontdata: .string " (CG sum of A = 0x" + .string ") PC-98" + .string "1 " + +msg_gs: .string "(GS) " +msg_h98: .string "(H98) " + +msg_normal: .string "normal" +msg_hireso: .string "Hi-reso" + +msg_sysclk: .string " mode, system clock " + .string "MHz\r\n" + +#if 0 +msg_40line: # cpp will concat following lines, so the assembler can deal. + .ascii "\ +Video mode will be adjusted to 37-line (so-called ``40-line'') mode later.\r\n\ +THIS MODE MAY DAMAGE YOUR MONITOR PHYSICALLY. USE AT YOUR OWN RISK.\r\n" +msg_30line: .string "Switching video mode to 30-line (640x480) mode... " + .string "Ok.\r\n" +#endif diff -Nru a/arch/i386/kernel/cpu/cpufreq/longhaul.c b/arch/i386/kernel/cpu/cpufreq/longhaul.c --- a/arch/i386/kernel/cpu/cpufreq/longhaul.c Sun Mar 23 00:22:50 2003 +++ b/arch/i386/kernel/cpu/cpufreq/longhaul.c Sun Mar 23 00:22:50 2003 @@ -525,9 +525,6 @@ { struct cpuinfo_x86 *c = cpu_data; - if ((c->x86_vendor != X86_VENDOR_CENTAUR) || (c->x86 !=6) ) - return -ENODEV; - switch (c->x86_model) { case 6: /* VIA C3 Samuel C5A */ longhaul=1; diff -Nru a/arch/i386/kernel/cpu/cpufreq/longrun.c b/arch/i386/kernel/cpu/cpufreq/longrun.c --- a/arch/i386/kernel/cpu/cpufreq/longrun.c Sun Mar 23 00:22:54 2003 +++ b/arch/i386/kernel/cpu/cpufreq/longrun.c Sun Mar 23 00:22:54 2003 @@ -229,9 +229,6 @@ /* capability check */ if (policy->cpu != 0) return -ENODEV; - if (c->x86_vendor != X86_VENDOR_TRANSMETA || - !cpu_has(c, X86_FEATURE_LONGRUN)) - return -ENODEV; /* detect low and high frequency */ result = longrun_determine_freqs(&longrun_low_freq, &longrun_high_freq); diff -Nru a/arch/i386/kernel/cpu/cpufreq/p4-clockmod.c b/arch/i386/kernel/cpu/cpufreq/p4-clockmod.c --- a/arch/i386/kernel/cpu/cpufreq/p4-clockmod.c Sun Mar 23 00:22:55 2003 +++ b/arch/i386/kernel/cpu/cpufreq/p4-clockmod.c Sun Mar 23 00:22:55 2003 @@ -180,13 +180,6 @@ int cpuid = 0; unsigned int i; - /* capability check */ - if (c->x86_vendor != X86_VENDOR_INTEL) - return -ENODEV; - if (!test_bit(X86_FEATURE_ACPI, c->x86_capability) || - !test_bit(X86_FEATURE_ACC, c->x86_capability)) - return -ENODEV; - /* Errata workaround */ cpuid = (c->x86 << 8) | (c->x86_model << 4) | c->x86_mask; switch (cpuid) { diff -Nru a/arch/i386/kernel/cpu/cpufreq/powernow-k6.c b/arch/i386/kernel/cpu/cpufreq/powernow-k6.c --- a/arch/i386/kernel/cpu/cpufreq/powernow-k6.c Sun Mar 23 00:22:50 2003 +++ b/arch/i386/kernel/cpu/cpufreq/powernow-k6.c Sun Mar 23 00:22:50 2003 @@ -145,10 +145,6 @@ struct cpuinfo_x86 *c = cpu_data; unsigned int i; - /* capability check */ - if ((c->x86_vendor != X86_VENDOR_AMD) || (c->x86 != 5) || - ((c->x86_model != 12) && (c->x86_model != 13))) - return -ENODEV; if (policy->cpu != 0) return -ENODEV; diff -Nru a/arch/i386/kernel/dmi_scan.c b/arch/i386/kernel/dmi_scan.c --- a/arch/i386/kernel/dmi_scan.c Sun Mar 23 00:22:52 2003 +++ b/arch/i386/kernel/dmi_scan.c Sun Mar 23 00:22:52 2003 @@ -499,6 +499,19 @@ return 0; } +/* + * Exploding PnPBIOS. Don't yet know if its the BIOS or us for + * some entries + */ + +static __init int exploding_pnp_bios(struct dmi_blacklist *d) +{ + printk(KERN_WARNING "%s detected. Disabling PnPBIOS\n", d->ident); + dmi_broken |= BROKEN_PNP_BIOS; + return 0; +} + + /* * Simple "print if true" callback @@ -686,6 +699,13 @@ MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"), MATCH(DMI_BIOS_VERSION, "WXPO1Z3"), MATCH(DMI_BIOS_DATE, "10/26/01"), NO_MATCH + } }, + + { exploding_pnp_bios, "Higraded P14H", { /* BIOSPnP problem */ + MATCH(DMI_BIOS_VENDOR, "American Megatrends Inc."), + MATCH(DMI_BIOS_VERSION, "07.00T"), + MATCH(DMI_SYS_VENDOR, "Higraded"), + MATCH(DMI_PRODUCT_NAME, "P14H") } }, /* Machines which have problems handling enabled local APICs */ diff -Nru a/arch/i386/kernel/entry.S b/arch/i386/kernel/entry.S --- a/arch/i386/kernel/entry.S Sun Mar 23 00:22:51 2003 +++ b/arch/i386/kernel/entry.S Sun Mar 23 00:22:51 2003 @@ -73,10 +73,10 @@ VM_MASK = 0x00020000 /* - * ESP0 is at offset 4. 0x100 is the size of the TSS, and + * ESP0 is at offset 4. 0x200 is the size of the TSS, and * also thus the top-of-stack pointer offset of SYSENTER_ESP */ -TSS_ESP0_OFFSET = (4 - 0x100) +TSS_ESP0_OFFSET = (4 - 0x200) #ifdef CONFIG_PREEMPT #define preempt_stop cli @@ -479,23 +479,32 @@ * by hand onto the new stack - while updating the return eip past * the instruction that would have done it for sysenter. */ -#define CHECK_SYSENTER_EIP \ - cmpl $sysenter_entry,(%esp); \ - jne 1f; \ - movl TSS_ESP0_OFFSET+12(%esp),%esp; \ +#define FIX_STACK(offset, ok, label) \ + cmpw $__KERNEL_CS,4(%esp); \ + jne ok; \ +label: \ + movl TSS_ESP0_OFFSET+offset(%esp),%esp; \ pushfl; \ pushl $__KERNEL_CS; \ - pushl $sysenter_past_esp; \ -1: + pushl $sysenter_past_esp ENTRY(debug) - CHECK_SYSENTER_EIP + cmpl $sysenter_entry,(%esp) + jne debug_stack_correct + FIX_STACK(12, debug_stack_correct, debug_esp_fix_insn) +debug_stack_correct: pushl $0 pushl $do_debug jmp error_code ENTRY(nmi) - CHECK_SYSENTER_EIP + cmpl $sysenter_entry,(%esp) + je nmi_stack_fixup + cmpl $debug - 1,(%esp) + jle nmi_stack_correct + cmpl $debug_esp_fix_insn,(%esp) + jle nmi_debug_stack_fixup +nmi_stack_correct: pushl %eax SAVE_ALL movl %esp, %edx @@ -504,6 +513,13 @@ call do_nmi addl $8, %esp RESTORE_ALL + +nmi_stack_fixup: + FIX_STACK(12,nmi_stack_correct, 1) + jmp nmi_stack_correct +nmi_debug_stack_fixup: + FIX_STACK(24,nmi_stack_correct, 1) + jmp nmi_stack_correct ENTRY(int3) pushl $0 diff -Nru a/arch/i386/kernel/io_apic.c b/arch/i386/kernel/io_apic.c --- a/arch/i386/kernel/io_apic.c Sun Mar 23 00:22:52 2003 +++ b/arch/i386/kernel/io_apic.c Sun Mar 23 00:22:52 2003 @@ -116,40 +116,84 @@ } } -#define __DO_ACTION(R, ACTION, FINAL) \ - \ -{ \ - int pin; \ - struct irq_pin_list *entry = irq_2_pin + irq; \ - \ - for (;;) { \ - unsigned int reg; \ - pin = entry->pin; \ - if (pin == -1) \ - break; \ - reg = io_apic_read(entry->apic, 0x10 + R + pin*2); \ - reg ACTION; \ - io_apic_modify(entry->apic, 0x10 + R + pin*2, reg); \ - if (!entry->next) \ - break; \ - entry = irq_2_pin + entry->next; \ - } \ - FINAL; \ -} - -#define DO_ACTION(name,R,ACTION, FINAL) \ - \ - static void name##_IO_APIC_irq (unsigned int irq) \ - __DO_ACTION(R, ACTION, FINAL) - -DO_ACTION( __mask, 0, |= 0x00010000, io_apic_sync(entry->apic) ) - /* mask = 1 */ -DO_ACTION( __unmask, 0, &= 0xfffeffff, ) - /* mask = 0 */ -DO_ACTION( __mask_and_edge, 0, = (reg & 0xffff7fff) | 0x00010000, ) - /* mask = 1, trigger = 0 */ -DO_ACTION( __unmask_and_level, 0, = (reg & 0xfffeffff) | 0x00008000, ) - /* mask = 0, trigger = 1 */ +/* mask = 1 */ +static void __mask_IO_APIC_irq (unsigned int irq) +{ + int pin; + struct irq_pin_list *entry = irq_2_pin + irq; + + for (;;) { + unsigned int reg; + pin = entry->pin; + if (pin == -1) + break; + reg = io_apic_read(entry->apic, 0x10 + pin*2); + io_apic_modify(entry->apic, 0x10 + pin*2, reg |= 0x00010000); + if (!entry->next) + break; + entry = irq_2_pin + entry->next; + } + io_apic_sync(entry->apic); +} + +/* mask = 0 */ +static void __unmask_IO_APIC_irq (unsigned int irq) +{ + int pin; + struct irq_pin_list *entry = irq_2_pin + irq; + + for (;;) { + unsigned int reg; + pin = entry->pin; + if (pin == -1) + break; + reg = io_apic_read(entry->apic, 0x10 + pin*2); + io_apic_modify(entry->apic, 0x10 + pin*2, reg &= 0xfffeffff); + if (!entry->next) + break; + entry = irq_2_pin + entry->next; + } +} + +/* mask = 1, trigger = 0 */ +static void __mask_and_edge_IO_APIC_irq (unsigned int irq) +{ + int pin; + struct irq_pin_list *entry = irq_2_pin + irq; + + for (;;) { + unsigned int reg; + pin = entry->pin; + if (pin == -1) + break; + reg = io_apic_read(entry->apic, 0x10 + pin*2); + reg = (reg & 0xffff7fff) | 0x00010000; + io_apic_modify(entry->apic, 0x10 + pin*2, reg); + if (!entry->next) + break; + entry = irq_2_pin + entry->next; + } +} + +/* mask = 0, trigger = 1 */ +static void __unmask_and_level_IO_APIC_irq (unsigned int irq) +{ + int pin; + struct irq_pin_list *entry = irq_2_pin + irq; + + for (;;) { + unsigned int reg; + pin = entry->pin; + if (pin == -1) + break; + reg = io_apic_read(entry->apic, 0x10 + pin*2); + reg = (reg & 0xfffeffff) | 0x00008000; + io_apic_modify(entry->apic, 0x10 + pin*2, reg); + if (!entry->next) + break; + entry = irq_2_pin + entry->next; + } +} static void mask_IO_APIC_irq (unsigned int irq) { @@ -197,13 +241,23 @@ static void set_ioapic_affinity (unsigned int irq, unsigned long mask) { unsigned long flags; + int pin; + struct irq_pin_list *entry = irq_2_pin + irq; /* * Only the first 8 bits are valid. */ mask = mask << 24; spin_lock_irqsave(&ioapic_lock, flags); - __DO_ACTION(1, = mask, ) + for (;;) { + pin = entry->pin; + if (pin == -1) + break; + io_apic_write(entry->apic, 0x10 + 1 + pin*2, mask); + if (!entry->next) + break; + entry = irq_2_pin + entry->next; + } spin_unlock_irqrestore(&ioapic_lock, flags); } @@ -743,6 +797,30 @@ } /* + * This function currently is only a helper for the i386 smp boot process where + * we need to reprogram the ioredtbls to cater for the cpus which have come online + * so mask in all cases should simply be TARGET_CPUS + */ +void __init setup_ioapic_dest (unsigned long mask) +{ + int pin, ioapic, irq, irq_entry; + + if (skip_ioapic_setup == 1) + return; + + for (ioapic = 0; ioapic < nr_ioapics; ioapic++) { + for (pin = 0; pin < nr_ioapic_registers[ioapic]; pin++) { + irq_entry = find_irq_entry(ioapic, pin, mp_INT); + if (irq_entry == -1) + continue; + irq = pin_2_irq(irq_entry, ioapic, pin); + set_ioapic_affinity(irq, mask); + } + + } +} + +/* * EISA Edge/Level control register, ELCR */ static int __init EISA_ELCR(unsigned int irq) @@ -2003,7 +2081,7 @@ } printk(" failed.\n"); - if (nmi_watchdog) { + if (nmi_watchdog == NMI_IO_APIC) { printk(KERN_WARNING "timer doesn't work through the IO-APIC - disabling NMI Watchdog!\n"); nmi_watchdog = 0; } diff -Nru a/arch/i386/kernel/irq.c b/arch/i386/kernel/irq.c --- a/arch/i386/kernel/irq.c Sun Mar 23 00:22:50 2003 +++ b/arch/i386/kernel/irq.c Sun Mar 23 00:22:50 2003 @@ -744,6 +744,8 @@ struct irqaction *old, **p; irq_desc_t *desc = irq_desc + irq; + if (desc->handler == &no_irq_type) + return -ENOSYS; /* * Some drivers like serial.c use request_irq() heavily, * so we have to be careful not to interfere with a diff -Nru a/arch/i386/kernel/process.c b/arch/i386/kernel/process.c --- a/arch/i386/kernel/process.c Sun Mar 23 00:22:49 2003 +++ b/arch/i386/kernel/process.c Sun Mar 23 00:22:49 2003 @@ -290,6 +290,7 @@ { struct pt_regs * childregs; struct task_struct *tsk; + int err; childregs = ((struct pt_regs *) (THREAD_SIZE + (unsigned long) p->thread_info)) - 1; struct_cpy(childregs, regs); @@ -322,20 +323,27 @@ struct user_desc info; int idx; + err = -EFAULT; if (copy_from_user(&info, (void *)childregs->esi, sizeof(info))) - return -EFAULT; + goto out; + err = -EINVAL; if (LDT_empty(&info)) - return -EINVAL; + goto out; idx = info.entry_number; if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX) - return -EINVAL; + goto out; desc = p->thread.tls_array + idx - GDT_ENTRY_TLS_MIN; desc->a = LDT_entry_a(&info); desc->b = LDT_entry_b(&info); } - return 0; + + err = 0; + out: + if (err && p->thread.ts_io_bitmap) + kfree(p->thread.ts_io_bitmap); + return err; } /* diff -Nru a/arch/i386/kernel/reboot.c b/arch/i386/kernel/reboot.c --- a/arch/i386/kernel/reboot.c Sun Mar 23 00:22:51 2003 +++ b/arch/i386/kernel/reboot.c Sun Mar 23 00:22:51 2003 @@ -8,6 +8,7 @@ #include #include #include +#include "mach_reboot.h" /* * Power off function, if any @@ -125,15 +126,6 @@ 0xea, 0x00, 0x00, 0xff, 0xff /* ljmp $0xffff,$0x0000 */ }; -static inline void kb_wait(void) -{ - int i; - - for (i=0; i<0x10000; i++) - if ((inb_p(0x64) & 0x02) == 0) - break; -} - /* * Switch to real mode and then execute the code * specified by the code and length parameters. @@ -264,13 +256,7 @@ /* rebooting needs to touch the page at absolute addr 0 */ *((unsigned short *)__va(0x472)) = reboot_mode; for (;;) { - int i; - for (i=0; i<100; i++) { - kb_wait(); - udelay(50); - outb(0xfe,0x64); /* pulse reset low */ - udelay(50); - } + mach_reboot(); /* That didn't work - force a triple fault.. */ __asm__ __volatile__("lidt %0": :"m" (no_idt)); __asm__ __volatile__("int3"); diff -Nru a/arch/i386/kernel/smpboot.c b/arch/i386/kernel/smpboot.c --- a/arch/i386/kernel/smpboot.c Sun Mar 23 00:22:53 2003 +++ b/arch/i386/kernel/smpboot.c Sun Mar 23 00:22:53 2003 @@ -1155,6 +1155,7 @@ void __init smp_cpus_done(unsigned int max_cpus) { + setup_ioapic_dest(TARGET_CPUS); zap_low_mappings(); } diff -Nru a/arch/i386/kernel/timers/timer_tsc.c b/arch/i386/kernel/timers/timer_tsc.c --- a/arch/i386/kernel/timers/timer_tsc.c Sun Mar 23 00:22:54 2003 +++ b/arch/i386/kernel/timers/timer_tsc.c Sun Mar 23 00:22:54 2003 @@ -213,6 +213,7 @@ { struct cpufreq_freqs *freq = data; + write_seqlock(&xtime_lock); if (!ref_freq) { ref_freq = freq->old; loops_per_jiffy_ref = cpu_data[freq->cpu].loops_per_jiffy; @@ -232,6 +233,7 @@ } #endif } + write_sequnlock(&xtime_lock); return 0; } diff -Nru a/arch/i386/kernel/traps.c b/arch/i386/kernel/traps.c --- a/arch/i386/kernel/traps.c Sun Mar 23 00:22:51 2003 +++ b/arch/i386/kernel/traps.c Sun Mar 23 00:22:51 2003 @@ -247,11 +247,13 @@ void die(const char * str, struct pt_regs * regs, long err) { + static int die_counter; + console_verbose(); spin_lock_irq(&die_lock); bust_spinlocks(1); handle_BUG(regs); - printk("%s: %04lx\n", str, err & 0xffff); + printk("%s: %04lx [#%d]\n", str, err & 0xffff, ++die_counter); show_registers(regs); bust_spinlocks(0); spin_unlock_irq(&die_lock); diff -Nru a/arch/i386/lib/usercopy.c b/arch/i386/lib/usercopy.c --- a/arch/i386/lib/usercopy.c Sun Mar 23 00:22:49 2003 +++ b/arch/i386/lib/usercopy.c Sun Mar 23 00:22:49 2003 @@ -50,6 +50,26 @@ : "memory"); \ } while (0) +/** + * __strncpy_from_user: - Copy a NULL terminated string from userspace, with less checking. + * @dst: Destination address, in kernel space. This buffer must be at + * least @count bytes long. + * @src: Source address, in user space. + * @count: Maximum number of bytes to copy, including the trailing NULL. + * + * Copies a NULL-terminated string from userspace to kernel space. + * Caller must check the specified block with access_ok() before calling + * this function. + * + * On success, returns the length of the string (not including the trailing + * NULL). + * + * If access to userspace fails, returns -EFAULT (some data may have been + * copied). + * + * If @count is smaller than the length of the string, copies @count bytes + * and returns @count. + */ long __strncpy_from_user(char *dst, const char *src, long count) { @@ -58,6 +78,24 @@ return res; } +/** + * strncpy_from_user: - Copy a NULL terminated string from userspace. + * @dst: Destination address, in kernel space. This buffer must be at + * least @count bytes long. + * @src: Source address, in user space. + * @count: Maximum number of bytes to copy, including the trailing NULL. + * + * Copies a NULL-terminated string from userspace to kernel space. + * + * On success, returns the length of the string (not including the trailing + * NULL). + * + * If access to userspace fails, returns -EFAULT (some data may have been + * copied). + * + * If @count is smaller than the length of the string, copies @count bytes + * and returns @count. + */ long strncpy_from_user(char *dst, const char *src, long count) { @@ -93,6 +131,16 @@ : "r"(size & 3), "0"(size / 4), "1"(addr), "a"(0)); \ } while (0) +/** + * clear_user: - Zero a block of memory in user space. + * @to: Destination address, in user space. + * @n: Number of bytes to zero. + * + * Zero a block of memory in user space. + * + * Returns number of bytes that could not be cleared. + * On success, this will be zero. + */ unsigned long clear_user(void *to, unsigned long n) { @@ -101,6 +149,17 @@ return n; } +/** + * __clear_user: - Zero a block of memory in user space, with less checking. + * @to: Destination address, in user space. + * @n: Number of bytes to zero. + * + * Zero a block of memory in user space. Caller must check + * the specified block with access_ok() before calling this function. + * + * Returns number of bytes that could not be cleared. + * On success, this will be zero. + */ unsigned long __clear_user(void *to, unsigned long n) { @@ -108,12 +167,17 @@ return n; } -/* - * Return the size of a string (including the ending 0) +/** + * strlen_user: - Get the size of a string in user space. + * @s: The string to measure. + * @n: The maximum valid length * - * Return 0 on exception, a value greater than N if too long + * Get the size of a NULL-terminated string in user space. + * + * Returns the size of the string INCLUDING the terminating NULL. + * On exception, returns 0. + * If the string is too long, returns a value greater than @n. */ - long strnlen_user(const char *s, long n) { unsigned long mask = -__addr_ok(s); diff -Nru a/arch/i386/mach-pc9800/Makefile b/arch/i386/mach-pc9800/Makefile --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/arch/i386/mach-pc9800/Makefile Sun Mar 23 00:22:57 2003 @@ -0,0 +1,7 @@ +# +# Makefile for the linux kernel. +# + +EXTRA_CFLAGS += -I../kernel + +obj-y := setup.o topology.o diff -Nru a/arch/i386/mach-pc9800/setup.c b/arch/i386/mach-pc9800/setup.c --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/arch/i386/mach-pc9800/setup.c Sun Mar 23 00:22:57 2003 @@ -0,0 +1,117 @@ +/* + * Machine specific setup for pc9800 + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct sys_desc_table_struct { + unsigned short length; + unsigned char table[0]; +}; + +/** + * pre_intr_init_hook - initialisation prior to setting up interrupt vectors + * + * Description: + * Perform any necessary interrupt initialisation prior to setting up + * the "ordinary" interrupt call gates. For legacy reasons, the ISA + * interrupts should be initialised here if the machine emulates a PC + * in any way. + **/ +void __init pre_intr_init_hook(void) +{ + init_ISA_irqs(); +} + +/* + * IRQ7 is cascade interrupt to second interrupt controller + */ +static struct irqaction irq7 = { no_action, 0, 0, "cascade", NULL, NULL}; + +/** + * intr_init_hook - post gate setup interrupt initialisation + * + * Description: + * Fill in any interrupts that may have been left out by the general + * init_IRQ() routine. interrupts having to do with the machine rather + * than the devices on the I/O bus (like APIC interrupts in intel MP + * systems) are started here. + **/ +void __init intr_init_hook(void) +{ +#ifdef CONFIG_X86_LOCAL_APIC + apic_intr_init(); +#endif + + setup_irq(7, &irq7); +} + +/** + * pre_setup_arch_hook - hook called prior to any setup_arch() execution + * + * Description: + * generally used to activate any machine specific identification + * routines that may be needed before setup_arch() runs. On VISWS + * this is used to get the board revision and type. + **/ +void __init pre_setup_arch_hook(void) +{ + SYS_DESC_TABLE.length = 0; + MCA_bus = 0; + /* In PC-9800, APM BIOS version is written in BCD...?? */ + APM_BIOS_INFO.version = (APM_BIOS_INFO.version & 0xff00) + | ((APM_BIOS_INFO.version & 0x00f0) >> 4); +} + +/** + * trap_init_hook - initialise system specific traps + * + * Description: + * Called as the final act of trap_init(). Used in VISWS to initialise + * the various board specific APIC traps. + **/ +void __init trap_init_hook(void) +{ +} + +static struct irqaction irq0 = { timer_interrupt, SA_INTERRUPT, 0, "timer", NULL, NULL}; + +/** + * time_init_hook - do any specific initialisations for the system timer. + * + * Description: + * Must plug the system timer interrupt source at HZ into the IRQ listed + * in irq_vectors.h:TIMER_IRQ + **/ +void __init time_init_hook(void) +{ + setup_irq(0, &irq0); +} + +#ifdef CONFIG_MCA +/** + * mca_nmi_hook - hook into MCA specific NMI chain + * + * Description: + * The MCA (Microchannel Architecture) has an NMI chain for NMI sources + * along the MCA bus. Use this to hook into that chain if you will need + * it. + **/ +void __init mca_nmi_hook(void) +{ + /* If I recall correctly, there's a whole bunch of other things that + * we can do to check for NMI problems, but that's all I know about + * at the moment. + */ + + printk("NMI generated from unknown source!\n"); +} +#endif diff -Nru a/arch/i386/mach-pc9800/topology.c b/arch/i386/mach-pc9800/topology.c --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/arch/i386/mach-pc9800/topology.c Sun Mar 23 00:22:57 2003 @@ -0,0 +1,44 @@ +/* + * arch/i386/mach-pc9800/topology.c - Populate driverfs with topology information + * + * Written by: Matthew Dobson, IBM Corporation + * Original Code: Paul Dorwin, IBM Corporation, Patrick Mochel, OSDL + * + * Copyright (C) 2002, IBM Corp. + * + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or + * NON INFRINGEMENT. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Modify for PC-9800 by Osamu Tomita + * + */ +#include +#include +#include + +struct i386_cpu cpu_devices[NR_CPUS]; + +static int __init topology_init(void) +{ + int i; + + for (i = 0; i < NR_CPUS; i++) + if (cpu_possible(i)) arch_register_cpu(i); + return 0; +} + +subsys_initcall(topology_init); diff -Nru a/arch/i386/pci/common.c b/arch/i386/pci/common.c --- a/arch/i386/pci/common.c Sun Mar 23 00:22:52 2003 +++ b/arch/i386/pci/common.c Sun Mar 23 00:22:52 2003 @@ -120,12 +120,27 @@ return pci_scan_bus(busnum, pci_root_ops, NULL); } +extern u8 pci_cache_line_size; + static int __init pcibios_init(void) { + struct cpuinfo_x86 *c = &boot_cpu_data; + if (!pci_root_ops) { printk("PCI: System does not support PCI\n"); return 0; } + + /* + * Assume PCI cacheline size of 32 bytes for all x86s except K7/K8 + * and P4. It's also good for 386/486s (which actually have 16) + * as quite a few PCI devices do not support smaller values. + */ + pci_cache_line_size = 32 >> 2; + if (c->x86 >= 6 && c->x86_vendor == X86_VENDOR_AMD) + pci_cache_line_size = 64 >> 2; /* K7 & K8 */ + else if (c->x86 > 6) + pci_cache_line_size = 128 >> 2; /* P4 */ pcibios_resource_survey(); diff -Nru a/arch/i386/pci/pcbios.c b/arch/i386/pci/pcbios.c --- a/arch/i386/pci/pcbios.c Sun Mar 23 00:22:50 2003 +++ b/arch/i386/pci/pcbios.c Sun Mar 23 00:22:50 2003 @@ -5,21 +5,8 @@ #include #include #include "pci.h" +#include "pci-functions.h" - -#define PCIBIOS_PCI_FUNCTION_ID 0xb1XX -#define PCIBIOS_PCI_BIOS_PRESENT 0xb101 -#define PCIBIOS_FIND_PCI_DEVICE 0xb102 -#define PCIBIOS_FIND_PCI_CLASS_CODE 0xb103 -#define PCIBIOS_GENERATE_SPECIAL_CYCLE 0xb106 -#define PCIBIOS_READ_CONFIG_BYTE 0xb108 -#define PCIBIOS_READ_CONFIG_WORD 0xb109 -#define PCIBIOS_READ_CONFIG_DWORD 0xb10a -#define PCIBIOS_WRITE_CONFIG_BYTE 0xb10b -#define PCIBIOS_WRITE_CONFIG_WORD 0xb10c -#define PCIBIOS_WRITE_CONFIG_DWORD 0xb10d -#define PCIBIOS_GET_ROUTING_OPTIONS 0xb10e -#define PCIBIOS_SET_PCI_HW_INT 0xb10f /* BIOS32 signature: "_32_" */ #define BIOS32_SIGNATURE (('_' << 0) + ('3' << 8) + ('2' << 16) + ('_' << 24)) diff -Nru a/arch/ia64/kernel/traps.c b/arch/ia64/kernel/traps.c --- a/arch/ia64/kernel/traps.c Sun Mar 23 00:22:56 2003 +++ b/arch/ia64/kernel/traps.c Sun Mar 23 00:22:56 2003 @@ -101,6 +101,7 @@ .lock_owner = -1, .lock_owner_depth = 0 }; + static int die_counter; if (die.lock_owner != smp_processor_id()) { console_verbose(); @@ -111,7 +112,8 @@ } if (++die.lock_owner_depth < 3) { - printk("%s[%d]: %s %ld\n", current->comm, current->pid, str, err); + printk("%s[%d]: %s %ld [%d]\n", + current->comm, current->pid, str, err, ++die_counter); show_regs(regs); } else printk(KERN_ERR "Recursive die() failure, output suppressed\n"); diff -Nru a/arch/m68k/Kconfig b/arch/m68k/Kconfig --- a/arch/m68k/Kconfig Sun Mar 23 00:22:53 2003 +++ b/arch/m68k/Kconfig Sun Mar 23 00:22:53 2003 @@ -499,8 +499,8 @@ uses. config HEARTBEAT - bool "Use power LED as a heartbeat" if AMIGA || ATARI || Q40 - default y if !AMIGA && !ATARI && !Q40 && HP300 + bool "Use power LED as a heartbeat" if AMIGA || APOLLO || ATARI || MAC ||Q40 + default y if !AMIGA && !APOLLO && !ATARI && !MAC && !Q40 && HP300 help Use the power-on LED on your machine as a load meter. The exact behavior is platform-dependent, but normally the flash frequency is diff -Nru a/arch/m68k/amiga/amisound.c b/arch/m68k/amiga/amisound.c --- a/arch/m68k/amiga/amisound.c Sun Mar 23 00:22:56 2003 +++ b/arch/m68k/amiga/amisound.c Sun Mar 23 00:22:56 2003 @@ -12,6 +12,7 @@ #include #include #include +#include #include #include diff -Nru a/arch/m68k/amiga/chipram.c b/arch/m68k/amiga/chipram.c --- a/arch/m68k/amiga/chipram.c Sun Mar 23 00:22:54 2003 +++ b/arch/m68k/amiga/chipram.c Sun Mar 23 00:22:54 2003 @@ -13,6 +13,7 @@ #include #include #include +#include #include #include diff -Nru a/arch/m68k/amiga/config.c b/arch/m68k/amiga/config.c --- a/arch/m68k/amiga/config.c Sun Mar 23 00:22:50 2003 +++ b/arch/m68k/amiga/config.c Sun Mar 23 00:22:50 2003 @@ -21,6 +21,7 @@ #include #include #include +#include #include #ifdef CONFIG_ZORRO #include @@ -89,6 +90,7 @@ static int a3000_hwclk (int, struct rtc_time *); static int a2000_hwclk (int, struct rtc_time *); static int amiga_set_clock_mmss (unsigned long); +static unsigned int amiga_get_ss (void); extern void amiga_mksound( unsigned int count, unsigned int ticks ); #ifdef CONFIG_AMIGA_FLOPPY extern void amiga_floppy_setup(char *, int *); @@ -403,6 +405,7 @@ */ mach_set_clock_mmss = amiga_set_clock_mmss; + mach_get_ss = amiga_get_ss; #ifdef CONFIG_AMIGA_FLOPPY mach_floppy_setup = amiga_floppy_setup; #endif @@ -545,96 +548,101 @@ static int a3000_hwclk(int op, struct rtc_time *t) { - volatile struct tod3000 *tod = TOD_3000; - - tod->cntrl1 = TOD3000_CNTRL1_HOLD; + tod_3000.cntrl1 = TOD3000_CNTRL1_HOLD; if (!op) { /* read */ - t->tm_sec = tod->second1 * 10 + tod->second2; - t->tm_min = tod->minute1 * 10 + tod->minute2; - t->tm_hour = tod->hour1 * 10 + tod->hour2; - t->tm_mday = tod->day1 * 10 + tod->day2; - t->tm_wday = tod->weekday; - t->tm_mon = tod->month1 * 10 + tod->month2 - 1; - t->tm_year = tod->year1 * 10 + tod->year2; + t->tm_sec = tod_3000.second1 * 10 + tod_3000.second2; + t->tm_min = tod_3000.minute1 * 10 + tod_3000.minute2; + t->tm_hour = tod_3000.hour1 * 10 + tod_3000.hour2; + t->tm_mday = tod_3000.day1 * 10 + tod_3000.day2; + t->tm_wday = tod_3000.weekday; + t->tm_mon = tod_3000.month1 * 10 + tod_3000.month2 - 1; + t->tm_year = tod_3000.year1 * 10 + tod_3000.year2; if (t->tm_year <= 69) t->tm_year += 100; } else { - tod->second1 = t->tm_sec / 10; - tod->second2 = t->tm_sec % 10; - tod->minute1 = t->tm_min / 10; - tod->minute2 = t->tm_min % 10; - tod->hour1 = t->tm_hour / 10; - tod->hour2 = t->tm_hour % 10; - tod->day1 = t->tm_mday / 10; - tod->day2 = t->tm_mday % 10; + tod_3000.second1 = t->tm_sec / 10; + tod_3000.second2 = t->tm_sec % 10; + tod_3000.minute1 = t->tm_min / 10; + tod_3000.minute2 = t->tm_min % 10; + tod_3000.hour1 = t->tm_hour / 10; + tod_3000.hour2 = t->tm_hour % 10; + tod_3000.day1 = t->tm_mday / 10; + tod_3000.day2 = t->tm_mday % 10; if (t->tm_wday != -1) - tod->weekday = t->tm_wday; - tod->month1 = (t->tm_mon + 1) / 10; - tod->month2 = (t->tm_mon + 1) % 10; + tod_3000.weekday = t->tm_wday; + tod_3000.month1 = (t->tm_mon + 1) / 10; + tod_3000.month2 = (t->tm_mon + 1) % 10; if (t->tm_year >= 100) t->tm_year -= 100; - tod->year1 = t->tm_year / 10; - tod->year2 = t->tm_year % 10; + tod_3000.year1 = t->tm_year / 10; + tod_3000.year2 = t->tm_year % 10; } - tod->cntrl1 = TOD3000_CNTRL1_FREE; + tod_3000.cntrl1 = TOD3000_CNTRL1_FREE; return 0; } static int a2000_hwclk(int op, struct rtc_time *t) { - volatile struct tod2000 *tod = TOD_2000; + int cnt = 5; + + tod_2000.cntrl1 = TOD2000_CNTRL1_HOLD; - tod->cntrl1 = TOD2000_CNTRL1_HOLD; + while ((tod_2000.cntrl1 & TOD2000_CNTRL1_BUSY) && cnt--) + { + tod_2000.cntrl1 &= ~TOD2000_CNTRL1_HOLD; + udelay(70); + tod_2000.cntrl1 |= TOD2000_CNTRL1_HOLD; + } - while (tod->cntrl1 & TOD2000_CNTRL1_BUSY) - ; + if (!cnt) + printk(KERN_INFO "hwclk: timed out waiting for RTC (0x%x)\n", tod_2000.cntrl1); if (!op) { /* read */ - t->tm_sec = tod->second1 * 10 + tod->second2; - t->tm_min = tod->minute1 * 10 + tod->minute2; - t->tm_hour = (tod->hour1 & 3) * 10 + tod->hour2; - t->tm_mday = tod->day1 * 10 + tod->day2; - t->tm_wday = tod->weekday; - t->tm_mon = tod->month1 * 10 + tod->month2 - 1; - t->tm_year = tod->year1 * 10 + tod->year2; + t->tm_sec = tod_2000.second1 * 10 + tod_2000.second2; + t->tm_min = tod_2000.minute1 * 10 + tod_2000.minute2; + t->tm_hour = (tod_2000.hour1 & 3) * 10 + tod_2000.hour2; + t->tm_mday = tod_2000.day1 * 10 + tod_2000.day2; + t->tm_wday = tod_2000.weekday; + t->tm_mon = tod_2000.month1 * 10 + tod_2000.month2 - 1; + t->tm_year = tod_2000.year1 * 10 + tod_2000.year2; if (t->tm_year <= 69) t->tm_year += 100; - if (!(tod->cntrl3 & TOD2000_CNTRL3_24HMODE)){ - if (!(tod->hour1 & TOD2000_HOUR1_PM) && t->tm_hour == 12) + if (!(tod_2000.cntrl3 & TOD2000_CNTRL3_24HMODE)){ + if (!(tod_2000.hour1 & TOD2000_HOUR1_PM) && t->tm_hour == 12) t->tm_hour = 0; - else if ((tod->hour1 & TOD2000_HOUR1_PM) && t->tm_hour != 12) + else if ((tod_2000.hour1 & TOD2000_HOUR1_PM) && t->tm_hour != 12) t->tm_hour += 12; } } else { - tod->second1 = t->tm_sec / 10; - tod->second2 = t->tm_sec % 10; - tod->minute1 = t->tm_min / 10; - tod->minute2 = t->tm_min % 10; - if (tod->cntrl3 & TOD2000_CNTRL3_24HMODE) - tod->hour1 = t->tm_hour / 10; + tod_2000.second1 = t->tm_sec / 10; + tod_2000.second2 = t->tm_sec % 10; + tod_2000.minute1 = t->tm_min / 10; + tod_2000.minute2 = t->tm_min % 10; + if (tod_2000.cntrl3 & TOD2000_CNTRL3_24HMODE) + tod_2000.hour1 = t->tm_hour / 10; else if (t->tm_hour >= 12) - tod->hour1 = TOD2000_HOUR1_PM + + tod_2000.hour1 = TOD2000_HOUR1_PM + (t->tm_hour - 12) / 10; else - tod->hour1 = t->tm_hour / 10; - tod->hour2 = t->tm_hour % 10; - tod->day1 = t->tm_mday / 10; - tod->day2 = t->tm_mday % 10; + tod_2000.hour1 = t->tm_hour / 10; + tod_2000.hour2 = t->tm_hour % 10; + tod_2000.day1 = t->tm_mday / 10; + tod_2000.day2 = t->tm_mday % 10; if (t->tm_wday != -1) - tod->weekday = t->tm_wday; - tod->month1 = (t->tm_mon + 1) / 10; - tod->month2 = (t->tm_mon + 1) % 10; + tod_2000.weekday = t->tm_wday; + tod_2000.month1 = (t->tm_mon + 1) / 10; + tod_2000.month2 = (t->tm_mon + 1) % 10; if (t->tm_year >= 100) t->tm_year -= 100; - tod->year1 = t->tm_year / 10; - tod->year2 = t->tm_year % 10; + tod_2000.year1 = t->tm_year / 10; + tod_2000.year2 = t->tm_year % 10; } - tod->cntrl1 &= ~TOD2000_CNTRL1_HOLD; + tod_2000.cntrl1 &= ~TOD2000_CNTRL1_HOLD; return 0; } @@ -644,33 +652,52 @@ short real_seconds = nowtime % 60, real_minutes = (nowtime / 60) % 60; if (AMIGAHW_PRESENT(A3000_CLK)) { - volatile struct tod3000 *tod = TOD_3000; - - tod->cntrl1 = TOD3000_CNTRL1_HOLD; + tod_3000.cntrl1 = TOD3000_CNTRL1_HOLD; - tod->second1 = real_seconds / 10; - tod->second2 = real_seconds % 10; - tod->minute1 = real_minutes / 10; - tod->minute2 = real_minutes % 10; + tod_3000.second1 = real_seconds / 10; + tod_3000.second2 = real_seconds % 10; + tod_3000.minute1 = real_minutes / 10; + tod_3000.minute2 = real_minutes % 10; - tod->cntrl1 = TOD3000_CNTRL1_FREE; + tod_3000.cntrl1 = TOD3000_CNTRL1_FREE; } else /* if (AMIGAHW_PRESENT(A2000_CLK)) */ { - volatile struct tod2000 *tod = TOD_2000; + int cnt = 5; + + tod_2000.cntrl1 |= TOD2000_CNTRL1_HOLD; + + while ((tod_2000.cntrl1 & TOD2000_CNTRL1_BUSY) && cnt--) + { + tod_2000.cntrl1 &= ~TOD2000_CNTRL1_HOLD; + udelay(70); + tod_2000.cntrl1 |= TOD2000_CNTRL1_HOLD; + } - tod->cntrl1 = TOD2000_CNTRL1_HOLD; - - while (tod->cntrl1 & TOD2000_CNTRL1_BUSY) - ; - - tod->second1 = real_seconds / 10; - tod->second2 = real_seconds % 10; - tod->minute1 = real_minutes / 10; - tod->minute2 = real_minutes % 10; + if (!cnt) + printk(KERN_INFO "set_clock_mmss: timed out waiting for RTC (0x%x)\n", tod_2000.cntrl1); - tod->cntrl1 &= ~TOD2000_CNTRL1_HOLD; + tod_2000.second1 = real_seconds / 10; + tod_2000.second2 = real_seconds % 10; + tod_2000.minute1 = real_minutes / 10; + tod_2000.minute2 = real_minutes % 10; + + tod_2000.cntrl1 &= ~TOD2000_CNTRL1_HOLD; } return 0; +} + +static unsigned int amiga_get_ss( void ) +{ + unsigned int s; + + if (AMIGAHW_PRESENT(A3000_CLK)) { + tod_3000.cntrl1 = TOD3000_CNTRL1_HOLD; + s = tod_3000.second1 * 10 + tod_3000.second2; + tod_3000.cntrl1 = TOD3000_CNTRL1_FREE; + } else /* if (AMIGAHW_PRESENT(A2000_CLK)) */ { + s = tod_2000.second1 * 10 + tod_2000.second2; + } + return s; } static NORET_TYPE void amiga_reset( void ) diff -Nru a/arch/m68k/apollo/config.c b/arch/m68k/apollo/config.c --- a/arch/m68k/apollo/config.c Sun Mar 23 00:22:55 2003 +++ b/arch/m68k/apollo/config.c Sun Mar 23 00:22:55 2003 @@ -48,7 +48,6 @@ static void dn_timer_int(int irq,void *, struct pt_regs *); static void (*sched_timer_handler)(int, void *, struct pt_regs *)=NULL; static void dn_get_model(char *model); -static int dn_cpuctrl=0xff00; static const char *apollo_models[] = { "DN3000 (Otter)", "DN3010 (Otter)", @@ -290,6 +289,8 @@ } #ifdef CONFIG_HEARTBEAT +static int dn_cpuctrl=0xff00; + static void dn_heartbeat(int on) { if(on) { diff -Nru a/arch/m68k/apollo/dma.c b/arch/m68k/apollo/dma.c --- a/arch/m68k/apollo/dma.c Sun Mar 23 00:22:55 2003 +++ b/arch/m68k/apollo/dma.c Sun Mar 23 00:22:55 2003 @@ -10,6 +10,7 @@ #include #include #include +#include /* note only works for 16 Bit 1 page DMA's */ @@ -27,7 +28,7 @@ #if 0 printk("phys_addr: %x, page_aligned_addr: %x, start_map_addr: %x\n",phys_addr,page_aligned_addr,start_map_addr+i); #endif - outw(start_map_addr+i, xlat_map_entry); + out_be16(xlat_map_entry, start_map_addr+i); } next_free_xlat_entry+=2; diff -Nru a/arch/m68k/atari/ataints.c b/arch/m68k/atari/ataints.c --- a/arch/m68k/atari/ataints.c Sun Mar 23 00:22:51 2003 +++ b/arch/m68k/atari/ataints.c Sun Mar 23 00:22:51 2003 @@ -273,29 +273,29 @@ /* Dummy function to allow asm with operands. */ void atari_fast_prio_irq_dummy (void) { __asm__ (__ALIGN_STR "\n" -"atari_fast_irq_handler: - orw #0x700,%%sr /* disable all interrupts */ -atari_prio_irq_handler:\t - addl %3,%2\n" /* preempt_count() += HARDIRQ_OFFSET */ - SAVE_ALL_INT "\n" - GET_CURRENT(%%d0) " +"atari_fast_irq_handler:\n\t" + "orw #0x700,%%sr\n" /* disable all interrupts */ +"atari_prio_irq_handler:\n\t" + "addl %3,%2\n\t" /* preempt_count() += HARDIRQ_OFFSET */ + SAVE_ALL_INT "\n\t" + GET_CURRENT(%%d0) "\n\t" /* get vector number from stack frame and convert to source */ - bfextu %%sp@(%c1){#4,#10},%%d0 - subw #(0x40-8),%%d0 - jpl 1f - addw #(0x40-8-0x18),%%d0 -1: lea %a0,%%a0 - addql #1,%%a0@(%%d0:l:4) - lea irq_handler,%%a0 - lea %%a0@(%%d0:l:8),%%a0 - pea %%sp@ /* push frame address */ - movel %%a0@(4),%%sp@- /* push handler data */ - movel %%d0,%%sp@- /* push int number */ - movel %%a0@,%%a0 - jsr %%a0@ /* and call the handler */ - addql #8,%%sp - addql #4,%%sp - jbra ret_from_interrupt" + "bfextu %%sp@(%c1){#4,#10},%%d0\n\t" + "subw #(0x40-8),%%d0\n\t" + "jpl 1f\n\t" + "addw #(0x40-8-0x18),%%d0\n" + "1:\tlea %a0,%%a0\n\t" + "addql #1,%%a0@(%%d0:l:4)\n\t" + "lea irq_handler,%%a0\n\t" + "lea %%a0@(%%d0:l:8),%%a0\n\t" + "pea %%sp@\n\t" /* push frame address */ + "movel %%a0@(4),%%sp@-\n\t" /* push handler data */ + "movel %%d0,%%sp@-\n\t" /* push int number */ + "movel %%a0@,%%a0\n\t" + "jsr %%a0@\n\t" /* and call the handler */ + "addql #8,%%sp\n\t" + "addql #4,%%sp\n\t" + "jbra ret_from_interrupt" : : "i" (&kstat_cpu(0).irqs), "n" (PT_OFF_FORMATVEC), "m" (preempt_count()), "di" (HARDIRQ_OFFSET) ); @@ -308,10 +308,10 @@ */ asmlinkage void falcon_hblhandler(void); asm(".text\n" -__ALIGN_STR "\n" -"falcon_hblhandler: - orw #0x200,%sp@ /* set saved ipl to 2 */ - rte"); +__ALIGN_STR "\n\t" +"falcon_hblhandler:\n\t" + "orw #0x200,%sp@\n\t" /* set saved ipl to 2 */ + "rte"); /* Defined in entry.S; only increments 'num_spurious' */ asmlinkage void bad_interrupt(void); diff -Nru a/arch/m68k/atari/stram.c b/arch/m68k/atari/stram.c --- a/arch/m68k/atari/stram.c Sun Mar 23 00:22:54 2003 +++ b/arch/m68k/atari/stram.c Sun Mar 23 00:22:54 2003 @@ -146,7 +146,7 @@ /* The following two numbers define the maximum fraction of ST-RAM in total * memory, below that the kernel would automatically use ST-RAM as swap - * space. This decision can be overriden with stram_swap= */ + * space. This decision can be overridden with stram_swap= */ #define MAX_STRAM_FRACTION_NOM 1 #define MAX_STRAM_FRACTION_DENOM 3 @@ -347,7 +347,7 @@ /* * If the whole ST-RAM is used for swapping, there are no allocatable * dma pages left. But unfortunately, some shared parts of the kernel - * (particularily the SCSI mid-level) call __get_dma_pages() + * (particularly the SCSI mid-level) call __get_dma_pages() * unconditionally :-( These calls then fail, and scsi.c even doesn't * check for NULL return values and just crashes. The quick fix for * this (instead of doing much clean up work in the SCSI code) is to diff -Nru a/arch/m68k/ifpsp060/fskeleton.S b/arch/m68k/ifpsp060/fskeleton.S --- a/arch/m68k/ifpsp060/fskeleton.S Sun Mar 23 00:22:52 2003 +++ b/arch/m68k/ifpsp060/fskeleton.S Sun Mar 23 00:22:52 2003 @@ -302,7 +302,6 @@ | The size of this section MUST be 128 bytes!!! - .global _FP_CALL_TOP _FP_CALL_TOP: .long _060_real_bsun - _FP_CALL_TOP .long _060_real_snan - _FP_CALL_TOP diff -Nru a/arch/m68k/ifpsp060/iskeleton.S b/arch/m68k/ifpsp060/iskeleton.S --- a/arch/m68k/ifpsp060/iskeleton.S Sun Mar 23 00:22:50 2003 +++ b/arch/m68k/ifpsp060/iskeleton.S Sun Mar 23 00:22:50 2003 @@ -270,7 +270,6 @@ | The size of this section MUST be 128 bytes!!! - .global _I_CALL_TOP _I_CALL_TOP: .long _060_real_chk - _I_CALL_TOP .long _060_real_divbyzero - _I_CALL_TOP diff -Nru a/arch/m68k/kernel/entry.S b/arch/m68k/kernel/entry.S --- a/arch/m68k/kernel/entry.S Sun Mar 23 00:22:49 2003 +++ b/arch/m68k/kernel/entry.S Sun Mar 23 00:22:49 2003 @@ -33,7 +33,6 @@ * for 68040 */ -#include #include #include #include @@ -41,6 +40,7 @@ #include #include #include +#include #include "m68k_defs.h" @@ -661,7 +661,3 @@ .long sys_lremovexattr .long sys_fremovexattr .long sys_futex /* 235 */ - - .rept NR_syscalls-(.-sys_call_table)/4 - .long sys_ni_syscall - .endr diff -Nru a/arch/m68k/kernel/head.S b/arch/m68k/kernel/head.S --- a/arch/m68k/kernel/head.S Sun Mar 23 00:22:56 2003 +++ b/arch/m68k/kernel/head.S Sun Mar 23 00:22:56 2003 @@ -190,7 +190,7 @@ * * options * ------- - * There are many options availble in a build of this file. I've + * There are many options available in a build of this file. I've * taken the time to describe them here to save you the time of searching * for them and trying to understand what they mean. * diff -Nru a/arch/m68k/kernel/m68k_ksyms.c b/arch/m68k/kernel/m68k_ksyms.c --- a/arch/m68k/kernel/m68k_ksyms.c Sun Mar 23 00:22:55 2003 +++ b/arch/m68k/kernel/m68k_ksyms.c Sun Mar 23 00:22:55 2003 @@ -53,11 +53,15 @@ EXPORT_SYMBOL(mach_get_ss); EXPORT_SYMBOL(mach_get_rtc_pll); EXPORT_SYMBOL(mach_set_rtc_pll); +#ifdef CONFIG_INPUT_M68K_BEEP_MODULE +EXPORT_SYMBOL(mach_beep); +#endif EXPORT_SYMBOL(dump_fpu); EXPORT_SYMBOL(dump_thread); EXPORT_SYMBOL(strnlen); EXPORT_SYMBOL(strrchr); EXPORT_SYMBOL(strstr); +EXPORT_SYMBOL(strpbrk); EXPORT_SYMBOL(enable_irq); EXPORT_SYMBOL(disable_irq); EXPORT_SYMBOL(kernel_thread); diff -Nru a/arch/m68k/kernel/process.c b/arch/m68k/kernel/process.c --- a/arch/m68k/kernel/process.c Sun Mar 23 00:22:56 2003 +++ b/arch/m68k/kernel/process.c Sun Mar 23 00:22:56 2003 @@ -42,6 +42,7 @@ static struct fs_struct init_fs = INIT_FS; static struct files_struct init_files = INIT_FILES; static struct signal_struct init_signals = INIT_SIGNALS(init_signals); +static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); struct mm_struct init_mm = INIT_MM(init_mm); union thread_union init_thread_union diff -Nru a/arch/m68k/kernel/signal.c b/arch/m68k/kernel/signal.c --- a/arch/m68k/kernel/signal.c Sun Mar 23 00:22:54 2003 +++ b/arch/m68k/kernel/signal.c Sun Mar 23 00:22:54 2003 @@ -16,7 +16,7 @@ * 1997-12-01 Modified for POSIX.1b signals by Andreas Schwab * * mathemu support by Roman Zippel - * (Note: fpstate in the signal context is completly ignored for the emulator + * (Note: fpstate in the signal context is completely ignored for the emulator * and the internal floating point format is put on stack) */ @@ -1019,7 +1019,7 @@ /* Restart the system call the same way as if the process were not traced. */ struct k_sigaction *ka = - ¤t->sig->action[signr-1]; + ¤t->sighand->action[signr-1]; int has_handler = (ka->sa.sa_handler != SIG_IGN && ka->sa.sa_handler != SIG_DFL); @@ -1060,7 +1060,7 @@ } } - ka = ¤t->sig->action[signr-1]; + ka = ¤t->sighand->action[signr-1]; if (ka->sa.sa_handler == SIG_IGN) { if (signr != SIGCHLD) continue; @@ -1087,11 +1087,11 @@ /* FALLTHRU */ case SIGSTOP: { - struct signal_struct *sig; + struct sighand_struct *sighand; current->state = TASK_STOPPED; current->exit_code = signr; - sig = current->parent->sig; - if (sig && !(sig->action[SIGCHLD-1].sa.sa_flags + sighand = current->parent->sighand; + if (sighand && !(sighand->action[SIGCHLD-1].sa.sa_flags & SA_NOCLDSTOP)) notify_parent(current, SIGCHLD); schedule(); @@ -1106,7 +1106,7 @@ /* FALLTHRU */ default: - sig_exit(signr, exit_code, &info); + do_group_exit(signr); /* NOTREACHED */ } } diff -Nru a/arch/m68k/kernel/time.c b/arch/m68k/kernel/time.c --- a/arch/m68k/kernel/time.c Sun Mar 23 00:22:51 2003 +++ b/arch/m68k/kernel/time.c Sun Mar 23 00:22:51 2003 @@ -59,35 +59,11 @@ */ static void timer_interrupt(int irq, void *dummy, struct pt_regs * regs) { - /* last time the cmos clock got updated */ - static long last_rtc_update=0; - do_timer(regs); if (!user_mode(regs)) do_profile(regs->pc); - /* - * If we have an externally synchronized Linux clock, then update - * CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be - * called as close as possible to 500 ms before the new second starts. - */ - /* - * This code hopefully becomes obsolete in 2.5 or earlier - * Should it ever be reenabled it must be serialized with - * genrtc.c operation - */ -#if 0 - if ((time_status & STA_UNSYNC) == 0 && - xtime.tv_sec > last_rtc_update + 660 && - (xtime.tv_nsec / 1000) >= 500000 - ((unsigned) tick) / 2 && - (xtime.tv_nsec / 1000) <= 500000 + ((unsigned) tick) / 2) { - if (set_rtc_mmss(xtime.tv_sec) == 0) - last_rtc_update = xtime.tv_sec; - else - last_rtc_update = xtime.tv_sec - 600; /* do it again in 60 s */ - } -#endif #ifdef CONFIG_HEARTBEAT /* use power LED as a heartbeat instead -- much more useful for debugging -- based on the version for PReP by Cort */ diff -Nru a/arch/m68k/kernel/traps.c b/arch/m68k/kernel/traps.c --- a/arch/m68k/kernel/traps.c Sun Mar 23 00:22:56 2003 +++ b/arch/m68k/kernel/traps.c Sun Mar 23 00:22:56 2003 @@ -303,7 +303,7 @@ return res; } -/* after an exception in a writeback the stack frame coresponding +/* after an exception in a writeback the stack frame corresponding * to that exception is discarded, set a few bits in the old frame * to simulate what it should look like */ @@ -333,7 +333,7 @@ fp->un.fmt7.wb2s = 0; } - /* do the 2nd wb only if the first one was succesful (except for a kernel wb) */ + /* do the 2nd wb only if the first one was successful (except for a kernel wb) */ if (fp->un.fmt7.wb3s & WBV_040 && (!res || fp->un.fmt7.wb3s & 4)) { res = do_040writeback1(fp->un.fmt7.wb3s, fp->un.fmt7.wb3a, fp->un.fmt7.wb3d); diff -Nru a/arch/m68k/mac/baboon.c b/arch/m68k/mac/baboon.c --- a/arch/m68k/mac/baboon.c Sun Mar 23 00:22:54 2003 +++ b/arch/m68k/mac/baboon.c Sun Mar 23 00:22:54 2003 @@ -1,5 +1,5 @@ /* - * Baboon Custom IC Managment + * Baboon Custom IC Management * * The Baboon custom IC controls the IDE, PCMCIA and media bay on the * PowerBook 190. It multiplexes multiple interrupt sources onto the diff -Nru a/arch/m68k/mac/iop.c b/arch/m68k/mac/iop.c --- a/arch/m68k/mac/iop.c Sun Mar 23 00:22:55 2003 +++ b/arch/m68k/mac/iop.c Sun Mar 23 00:22:55 2003 @@ -236,7 +236,7 @@ /* * This is called by the startup code before anything else. Its purpose - * is to find and initalize the IOPs early in the boot sequence, so that + * is to find and initialize the IOPs early in the boot sequence, so that * the serial IOP can be placed into bypass mode _before_ we try to * initialize the serial console. */ diff -Nru a/arch/m68k/mac/macints.c b/arch/m68k/mac/macints.c --- a/arch/m68k/mac/macints.c Sun Mar 23 00:22:55 2003 +++ b/arch/m68k/mac/macints.c Sun Mar 23 00:22:55 2003 @@ -30,7 +30,7 @@ * - slot 0: SCSI interrupt * - slot 1: Sound interrupt * - * Levels 3-6 vary by machine type. For VIA or RBV Macintohes: + * Levels 3-6 vary by machine type. For VIA or RBV Macintoshes: * * 3 - unused (?) * @@ -494,7 +494,7 @@ * Add an interrupt service routine to an interrupt source. * Returns 0 on success. * - * FIXME: You can register interrupts on nonexistant source (ie PSC4 on a + * FIXME: You can register interrupts on nonexistent source (ie PSC4 on a * non-PSC machine). We should return -EINVAL in those cases. */ diff -Nru a/arch/m68k/math-emu/fp_arith.c b/arch/m68k/math-emu/fp_arith.c --- a/arch/m68k/math-emu/fp_arith.c Sun Mar 23 00:22:51 2003 +++ b/arch/m68k/math-emu/fp_arith.c Sun Mar 23 00:22:51 2003 @@ -113,7 +113,7 @@ return dest; } -/* fp_fsub: Implementes the kernel of the FSUB, FSSUB, and FDSUB +/* fp_fsub: Implements the kernel of the FSUB, FSSUB, and FDSUB instructions. Remember that the arguments are in assembler-syntax order! */ diff -Nru a/arch/m68k/mm/memory.c b/arch/m68k/mm/memory.c --- a/arch/m68k/mm/memory.c Sun Mar 23 00:22:54 2003 +++ b/arch/m68k/mm/memory.c Sun Mar 23 00:22:54 2003 @@ -33,7 +33,7 @@ typedef struct list_head ptable_desc; static LIST_HEAD(ptable_list); -#define PD_PTABLE(page) ((ptable_desc *)virt_to_page(page)) +#define PD_PTABLE(page) ((ptable_desc *)&(virt_to_page(page)->list)) #define PD_PAGE(ptable) (list_entry(ptable, struct page, list)) #define PD_MARKBITS(dp) (*(unsigned char *)&PD_PAGE(dp)->index) diff -Nru a/arch/m68k/mm/sun3mmu.c b/arch/m68k/mm/sun3mmu.c --- a/arch/m68k/mm/sun3mmu.c Sun Mar 23 00:22:51 2003 +++ b/arch/m68k/mm/sun3mmu.c Sun Mar 23 00:22:51 2003 @@ -92,13 +92,12 @@ } mmu_emu_init(bootmem_end); - + current->mm = NULL; /* memory sizing is a hack stolen from motorola.c.. hope it works for us */ - zones_size[1] = ((unsigned long)high_memory - PAGE_OFFSET) >> PAGE_SHIFT; - zones_size[0] = zones_size[1]/2; - zones_size[1] -= zones_size[0]; + zones_size[0] = ((unsigned long)high_memory - PAGE_OFFSET) >> PAGE_SHIFT; + zones_size[1] = 0; free_area_init(zones_size); diff -Nru a/arch/m68k/q40/q40ints.c b/arch/m68k/q40/q40ints.c --- a/arch/m68k/q40/q40ints.c Sun Mar 23 00:22:55 2003 +++ b/arch/m68k/q40/q40ints.c Sun Mar 23 00:22:55 2003 @@ -7,7 +7,7 @@ * License. See the file COPYING in the main directory of this archive * for more details. * - * .. used to be losely based on bvme6000ints.c + * .. used to be loosely based on bvme6000ints.c * */ @@ -127,6 +127,7 @@ printk("warning IRQ 10 and 11 not distinguishable\n"); irq=10; default: + ; } if (irq=5 && irq<=15 ) { diff -Nru a/arch/m68k/sun3/sun3dvma.c b/arch/m68k/sun3/sun3dvma.c --- a/arch/m68k/sun3/sun3dvma.c Sun Mar 23 00:22:54 2003 +++ b/arch/m68k/sun3/sun3dvma.c Sun Mar 23 00:22:54 2003 @@ -97,7 +97,7 @@ printk("end of hole listing...\n"); } -#endif DVMA_DEBUG +#endif /* DVMA_DEBUG */ static inline int refill(void) { diff -Nru a/arch/m68k/vmlinux-sun3.lds b/arch/m68k/vmlinux-sun3.lds --- a/arch/m68k/vmlinux-sun3.lds Sun Mar 23 00:22:49 2003 +++ b/arch/m68k/vmlinux-sun3.lds Sun Mar 23 00:22:49 2003 @@ -16,11 +16,12 @@ *(.fixup) *(.gnu.warning) } = 0x4e75 + RODATA _etext = .; /* End of text section */ .data : { /* Data */ - RODATA + *(.data) CONSTRUCTORS . = ALIGN(16); /* Exception table */ __start___ex_table = .; diff -Nru a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c --- a/arch/mips/kernel/traps.c Sun Mar 23 00:22:52 2003 +++ b/arch/mips/kernel/traps.c Sun Mar 23 00:22:52 2003 @@ -191,12 +191,13 @@ extern void __die(const char * str, struct pt_regs * regs, const char *where, unsigned long line) { + static int die_counter; console_verbose(); spin_lock_irq(&die_lock); printk("%s", str); if (where) printk(" in %s, line %ld", where, line); - printk(":\n"); + printk("[#%d]:\n", ++die_counter); show_regs(regs); printk("Process %s (pid: %d, stackpage=%08lx)\n", current->comm, current->pid, (unsigned long) current); diff -Nru a/arch/mips64/Kconfig b/arch/mips64/Kconfig --- a/arch/mips64/Kconfig Sun Mar 23 00:22:51 2003 +++ b/arch/mips64/Kconfig Sun Mar 23 00:22:51 2003 @@ -5,6 +5,10 @@ mainmenu "Linux Kernel Configuration" +config MIPS64 + bool + default y + config MMU bool default y diff -Nru a/arch/mips64/kernel/traps.c b/arch/mips64/kernel/traps.c --- a/arch/mips64/kernel/traps.c Sun Mar 23 00:22:54 2003 +++ b/arch/mips64/kernel/traps.c Sun Mar 23 00:22:54 2003 @@ -161,12 +161,13 @@ void die(const char * str, struct pt_regs * regs, unsigned long err) { + static int die_counter; if (user_mode(regs)) /* Just return if in user mode. */ return; console_verbose(); spin_lock_irq(&die_lock); - printk("%s: %04lx\n", str, err & 0xffff); + printk("%s: %04lx [#%d]\n", str, err & 0xffff, ++die_counter); show_regs(regs); printk("Process %s (pid: %d, stackpage=%08lx)\n", current->comm, current->pid, (unsigned long) current); diff -Nru a/arch/parisc/Makefile b/arch/parisc/Makefile --- a/arch/parisc/Makefile Sun Mar 23 00:22:55 2003 +++ b/arch/parisc/Makefile Sun Mar 23 00:22:55 2003 @@ -93,7 +93,8 @@ include/asm-parisc/offsets.h: arch/parisc/kernel/asm-offsets.s $(call filechk,gen-asm-offsets) -CLEAN_FILES += palo.conf lifimage include/asm-parisc/offsets.h +CLEAN_FILES += lifimage include/asm-parisc/offsets.h +MRPROPER_FILES += palo.conf define archhelp @echo '* vmlinux - Uncompressed kernel image (./vmlinux)' diff -Nru a/arch/parisc/kernel/Makefile b/arch/parisc/kernel/Makefile --- a/arch/parisc/kernel/Makefile Sun Mar 23 00:22:52 2003 +++ b/arch/parisc/kernel/Makefile Sun Mar 23 00:22:52 2003 @@ -4,7 +4,7 @@ head-y := head.o head-$(CONFIG_PARISC64) := head64.o -extra-y := init_task.o pdc_cons.o process.o +extra-y := init_task.o pdc_cons.o process.o \ unaligned.o $(head-y) AFLAGS_entry.o := -traditional diff -Nru a/arch/parisc/kernel/binfmt_elf32.c b/arch/parisc/kernel/binfmt_elf32.c --- a/arch/parisc/kernel/binfmt_elf32.c Sun Mar 23 00:22:52 2003 +++ b/arch/parisc/kernel/binfmt_elf32.c Sun Mar 23 00:22:52 2003 @@ -12,6 +12,26 @@ #define ELF_CLASS ELFCLASS32 +#define ELF_CORE_COPY_REGS(dst, pt) \ + memset(dst, 0, sizeof(dst)); /* don't leak any "random" bits */ \ + { int i; \ + for (i = 0; i < 32; i++) dst[i] = (elf_greg_t) pt->gr[i]; \ + for (i = 0; i < 8; i++) dst[32 + i] = (elf_greg_t) pt->sr[i]; \ + } \ + dst[40] = (elf_greg_t) pt->iaoq[0]; dst[41] = (elf_greg_t) pt->iaoq[1]; \ + dst[42] = (elf_greg_t) pt->iasq[0]; dst[43] = (elf_greg_t) pt->iasq[1]; \ + dst[44] = (elf_greg_t) pt->sar; dst[45] = (elf_greg_t) pt->iir; \ + dst[46] = (elf_greg_t) pt->isr; dst[47] = (elf_greg_t) pt->ior; \ + dst[48] = (elf_greg_t) mfctl(22); dst[49] = (elf_greg_t) mfctl(0); \ + dst[50] = (elf_greg_t) mfctl(24); dst[51] = (elf_greg_t) mfctl(25); \ + dst[52] = (elf_greg_t) mfctl(26); dst[53] = (elf_greg_t) mfctl(27); \ + dst[54] = (elf_greg_t) mfctl(28); dst[55] = (elf_greg_t) mfctl(29); \ + dst[56] = (elf_greg_t) mfctl(30); dst[57] = (elf_greg_t) mfctl(31); \ + dst[58] = (elf_greg_t) mfctl( 8); dst[59] = (elf_greg_t) mfctl( 9); \ + dst[60] = (elf_greg_t) mfctl(12); dst[61] = (elf_greg_t) mfctl(13); \ + dst[62] = (elf_greg_t) mfctl(10); dst[63] = (elf_greg_t) mfctl(15); + + typedef unsigned int elf_greg_t; #include @@ -60,25 +80,6 @@ #define init_elf_binfmt init_elf32_binfmt #define ELF_PLATFORM ("PARISC32\0") - -#define ELF_CORE_COPY_REGS(dst, pt) \ - memset(dst, 0, sizeof(dst)); /* don't leak any "random" bits */ \ - { int i; \ - for (i = 0; i < 32; i++) dst[i] = (elf_greg_t) pt->gr[i]; \ - for (i = 0; i < 8; i++) dst[32 + i] = (elf_greg_t) pt->sr[i]; \ - } \ - dst[40] = (elf_greg_t) pt->iaoq[0]; dst[41] = (elf_greg_t) pt->iaoq[1]; \ - dst[42] = (elf_greg_t) pt->iasq[0]; dst[43] = (elf_greg_t) pt->iasq[1]; \ - dst[44] = (elf_greg_t) pt->sar; dst[45] = (elf_greg_t) pt->iir; \ - dst[46] = (elf_greg_t) pt->isr; dst[47] = (elf_greg_t) pt->ior; \ - dst[48] = (elf_greg_t) mfctl(22); dst[49] = (elf_greg_t) mfctl(0); \ - dst[50] = (elf_greg_t) mfctl(24); dst[51] = (elf_greg_t) mfctl(25); \ - dst[52] = (elf_greg_t) mfctl(26); dst[53] = (elf_greg_t) mfctl(27); \ - dst[54] = (elf_greg_t) mfctl(28); dst[55] = (elf_greg_t) mfctl(29); \ - dst[56] = (elf_greg_t) mfctl(30); dst[57] = (elf_greg_t) mfctl(31); \ - dst[58] = (elf_greg_t) mfctl( 8); dst[59] = (elf_greg_t) mfctl( 9); \ - dst[60] = (elf_greg_t) mfctl(12); dst[61] = (elf_greg_t) mfctl(13); \ - dst[62] = (elf_greg_t) mfctl(10); dst[63] = (elf_greg_t) mfctl(15); /* * We should probably use this macro to set a flag somewhere to indicate diff -Nru a/arch/parisc/kernel/cache.c b/arch/parisc/kernel/cache.c --- a/arch/parisc/kernel/cache.c Sun Mar 23 00:22:52 2003 +++ b/arch/parisc/kernel/cache.c Sun Mar 23 00:22:52 2003 @@ -114,7 +114,7 @@ void __init parisc_cache_init(void) { - if(pdc_cache_info(&cache_info)<0) + if (pdc_cache_info(&cache_info) < 0) panic("parisc_cache_init: pdc_cache_info failed"); #if 0 @@ -167,25 +167,25 @@ split_tlb = 0; if (cache_info.dt_conf.tc_sh == 0 || cache_info.dt_conf.tc_sh == 2) { - - if (cache_info.dt_conf.tc_sh == 2) - printk(KERN_WARNING "Unexpected TLB configuration. " + if (cache_info.dt_conf.tc_sh == 2) + printk(KERN_WARNING "Unexpected TLB configuration. " "Will flush I/D separately (could be optimized).\n"); - split_tlb = 1; + split_tlb = 1; } - dcache_stride = ( (1<<(cache_info.dc_conf.cc_block+3)) * - cache_info.dc_conf.cc_line ); - icache_stride = ( (1<<(cache_info.ic_conf.cc_block+3)) * - cache_info.ic_conf.cc_line ); + dcache_stride = (1 << (cache_info.dc_conf.cc_block + 3)) * + cache_info.dc_conf.cc_line; + icache_stride = (1 << (cache_info.ic_conf.cc_block + 3)) * + cache_info.ic_conf.cc_line; #ifndef CONFIG_PA20 - if(pdc_btlb_info(&btlb_info)<0) { + if (pdc_btlb_info(&btlb_info) < 0) { memset(&btlb_info, 0, sizeof btlb_info); } #endif - if ((boot_cpu_data.pdc.capabilities & PDC_MODEL_NVA_MASK) == PDC_MODEL_NVA_UNSUPPORTED) { + if ((boot_cpu_data.pdc.capabilities & PDC_MODEL_NVA_MASK) == + PDC_MODEL_NVA_UNSUPPORTED) { printk(KERN_WARNING "Only equivalent aliasing supported\n"); #ifndef CONFIG_SMP panic("SMP kernel required to avoid non-equivalent aliasing"); @@ -195,31 +195,69 @@ void disable_sr_hashing(void) { - int srhash_type; + int srhash_type; + + switch (boot_cpu_data.cpu_type) { + case pcx: /* We shouldn't get this far. setup.c should prevent it. */ + BUG(); + return; + + case pcxs: + case pcxt: + case pcxt_: + srhash_type = SRHASH_PCXST; + break; + + case pcxl: + srhash_type = SRHASH_PCXL; + break; + + case pcxl2: /* pcxl2 doesn't support space register hashing */ + return; + + default: /* Currently all PA2.0 machines use the same ins. sequence */ + srhash_type = SRHASH_PA20; + break; + } - if (boot_cpu_data.cpu_type == pcxl2) - return; /* pcxl2 doesn't support space register hashing */ + disable_sr_hashing_asm(srhash_type); +} + +void __flush_dcache_page(struct page *page) +{ + struct mm_struct *mm = current->active_mm; + struct list_head *l; - switch (boot_cpu_data.cpu_type) { + flush_kernel_dcache_page(page_address(page)); - case pcx: - BUG(); /* We shouldn't get here. code in setup.c should prevent it */ - return; + if (!page->mapping) + return; - case pcxs: - case pcxt: - case pcxt_: - srhash_type = SRHASH_PCXST; - break; + list_for_each(l, &page->mapping->i_mmap_shared) { + struct vm_area_struct *mpnt; + unsigned long off; - case pcxl: - srhash_type = SRHASH_PCXL; - break; + mpnt = list_entry(l, struct vm_area_struct, shared); - default: /* Currently all PA2.0 machines use the same ins. sequence */ - srhash_type = SRHASH_PA20; - break; - } + /* + * If this VMA is not in our MM, we can ignore it. + */ + if (mpnt->vm_mm != mm) + continue; - disable_sr_hashing_asm(srhash_type); + if (page->index < mpnt->vm_pgoff) + continue; + + off = page->index - mpnt->vm_pgoff; + if (off >= (mpnt->vm_end - mpnt->vm_start) >> PAGE_SHIFT) + continue; + + flush_cache_page(mpnt, mpnt->vm_start + (off << PAGE_SHIFT)); + + /* All user shared mappings should be equivalently mapped, + * so once we've flushed one we should be ok + */ + break; + } } + diff -Nru a/arch/parisc/kernel/entry.S b/arch/parisc/kernel/entry.S --- a/arch/parisc/kernel/entry.S Sun Mar 23 00:22:51 2003 +++ b/arch/parisc/kernel/entry.S Sun Mar 23 00:22:51 2003 @@ -558,11 +558,9 @@ .export ret_from_kernel_thread ret_from_kernel_thread: -#if CONFIG_PREEMPT || CONFIG_SMP /* Call schedule_tail first though */ bl schedule_tail, %r2 nop -#endif LDREG TI_TASK-THREAD_SZ_ALGN(%r30), %r1 LDREG TASK_PT_GR25(%r1), %r26 @@ -2014,10 +2012,8 @@ /* Set the return value for the child */ child_return: -#if CONFIG_SMP || CONFIG_PREEMPT bl schedule_tail, %r2 nop -#endif LDREG TI_TASK-THREAD_SZ_ALGN-FRAME_SIZE-FRAME_SIZE(%r30), %r1 LDREG TASK_PT_GR19(%r1),%r2 diff -Nru a/arch/parisc/kernel/hardware.c b/arch/parisc/kernel/hardware.c --- a/arch/parisc/kernel/hardware.c Sun Mar 23 00:22:52 2003 +++ b/arch/parisc/kernel/hardware.c Sun Mar 23 00:22:52 2003 @@ -99,8 +99,8 @@ {HPHW_NPROC,0x481,0x4,0x81,"Wilbur (E25)"}, {HPHW_NPROC,0x482,0x4,0x81,"WB-80 (E35)"}, {HPHW_NPROC,0x483,0x4,0x81,"WB-96 (E45)"}, - {HPHW_NPROC,0x48,0x4,0x81,"UL Proc L-100 (811/D210,D310)"}, - {HPHW_NPROC,0x48,0x4,0x81,"UL Proc L-75 (801/D200)"}, + {HPHW_NPROC,0x484,0x4,0x81,"UL Proc L-100 (811/D210,D310)"}, + {HPHW_NPROC,0x485,0x4,0x81,"UL Proc L-75 (801/D200)"}, {HPHW_NPROC,0x501,0x4,0x81,"Merlin L2 132 (9000/778/B132L)"}, {HPHW_NPROC,0x502,0x4,0x81,"Merlin L2 160 (9000/778/B160L)"}, {HPHW_NPROC,0x503,0x4,0x81,"Merlin L2+ 132 (9000/778/B132L)"}, diff -Nru a/arch/parisc/kernel/init_task.c b/arch/parisc/kernel/init_task.c --- a/arch/parisc/kernel/init_task.c Sun Mar 23 00:22:53 2003 +++ b/arch/parisc/kernel/init_task.c Sun Mar 23 00:22:53 2003 @@ -10,6 +10,7 @@ static struct fs_struct init_fs = INIT_FS; static struct files_struct init_files = INIT_FILES; static struct signal_struct init_signals = INIT_SIGNALS(init_signals); +static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); struct mm_struct init_mm = INIT_MM(init_mm); /* diff -Nru a/arch/parisc/kernel/ioctl32.c b/arch/parisc/kernel/ioctl32.c --- a/arch/parisc/kernel/ioctl32.c Sun Mar 23 00:22:50 2003 +++ b/arch/parisc/kernel/ioctl32.c Sun Mar 23 00:22:50 2003 @@ -1,4 +1,4 @@ -/* $Id: ioctl32.c,v 1.6 2002/10/21 16:13:22 varenet Exp $ +/* $Id: ioctl32.c,v 1.5 2002/10/18 00:21:43 varenet Exp $ * ioctl32.c: Conversion between 32bit and 64bit native ioctls. * * Copyright (C) 1997-2000 Jakub Jelinek (jakub@redhat.com) @@ -66,6 +66,9 @@ #define __KERNEL__ #include +#include +#include + #include #include #include @@ -2824,6 +2827,27 @@ return err; } +/* Fix sizeof(sizeof()) breakage */ +#define BLKBSZGET_32 _IOR(0x12,112,int) +#define BLKBSZSET_32 _IOW(0x12,113,int) +#define BLKGETSIZE64_32 _IOR(0x12,114,int) + +static int do_blkbszget(unsigned int fd, unsigned int cmd, unsigned long arg) +{ + return sys_ioctl(fd, BLKBSZGET, arg); +} + +static int do_blkbszset(unsigned int fd, unsigned int cmd, unsigned long arg) +{ + return sys_ioctl(fd, BLKBSZSET, arg); +} + +static int do_blkgetsize64(unsigned int fd, unsigned int cmd, + unsigned long arg) +{ + return sys_ioctl(fd, BLKGETSIZE64, arg); +} + static int ioc_settimeout(unsigned int fd, unsigned int cmd, unsigned long arg) { return rw_long(fd, AUTOFS_IOC_SETTIMEOUT, arg); @@ -2997,14 +3021,13 @@ COMPATIBLE_IOCTL(BLKRRPART) COMPATIBLE_IOCTL(BLKFLSBUF) COMPATIBLE_IOCTL(BLKSECTSET) -COMPATIBLE_IOCTL(BLKSSZGET) -COMPATIBLE_IOCTL(BLKBSZGET) /* RAID */ COMPATIBLE_IOCTL(RAID_VERSION) COMPATIBLE_IOCTL(GET_ARRAY_INFO) COMPATIBLE_IOCTL(GET_DISK_INFO) COMPATIBLE_IOCTL(PRINT_RAID_DEBUG) +COMPATIBLE_IOCTL(RAID_AUTORUN) COMPATIBLE_IOCTL(CLEAR_ARRAY) COMPATIBLE_IOCTL(ADD_NEW_DISK) COMPATIBLE_IOCTL(HOT_REMOVE_DISK) @@ -3015,12 +3038,26 @@ COMPATIBLE_IOCTL(PROTECT_ARRAY) COMPATIBLE_IOCTL(HOT_ADD_DISK) COMPATIBLE_IOCTL(SET_DISK_FAULTY) +COMPATIBLE_IOCTL(HOT_GENERATE_ERROR) COMPATIBLE_IOCTL(RUN_ARRAY) COMPATIBLE_IOCTL(START_ARRAY) COMPATIBLE_IOCTL(STOP_ARRAY) COMPATIBLE_IOCTL(STOP_ARRAY_RO) COMPATIBLE_IOCTL(RESTART_ARRAY_RW) +/* DM */ +COMPATIBLE_IOCTL(DM_VERSION) +COMPATIBLE_IOCTL(DM_REMOVE_ALL) +COMPATIBLE_IOCTL(DM_DEV_CREATE) +COMPATIBLE_IOCTL(DM_DEV_REMOVE) +COMPATIBLE_IOCTL(DM_DEV_RELOAD) +COMPATIBLE_IOCTL(DM_DEV_SUSPEND) +COMPATIBLE_IOCTL(DM_DEV_RENAME) +COMPATIBLE_IOCTL(DM_DEV_DEPS) +COMPATIBLE_IOCTL(DM_DEV_STATUS) +COMPATIBLE_IOCTL(DM_TARGET_STATUS) +COMPATIBLE_IOCTL(DM_TARGET_WAIT) + /* Big K */ COMPATIBLE_IOCTL(PIO_FONT) COMPATIBLE_IOCTL(GIO_FONT) @@ -3570,6 +3607,11 @@ HANDLE_IOCTL(0x1260, broken_blkgetsize) HANDLE_IOCTL(BLKSECTGET, w_long) HANDLE_IOCTL(BLKPG, blkpg_ioctl_trans) +/* take care of sizeof(sizeof()) breakage */ +/* block stuff */ +HANDLE_IOCTL(BLKBSZGET_32, do_blkbszget) +HANDLE_IOCTL(BLKBSZSET_32, do_blkbszset) +HANDLE_IOCTL(BLKGETSIZE64_32, do_blkgetsize64) HANDLE_IOCTL(FBIOGET_FSCREENINFO, fb_ioctl_trans) HANDLE_IOCTL(FBIOGETCMAP, fb_ioctl_trans) diff -Nru a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c --- a/arch/parisc/kernel/module.c Sun Mar 23 00:22:56 2003 +++ b/arch/parisc/kernel/module.c Sun Mar 23 00:22:56 2003 @@ -562,10 +562,8 @@ #ifdef __LP64__ me->init = (void *)get_fdesc(me, (Elf_Addr)me->init); #ifdef CONFIG_MODULE_UNLOAD - if (me->cleanup) - me->cleanup = (void *)get_fdesc(me, (Elf_Addr)me->cleanup); - if (me->destroy) - me->destroy = (void *)get_fdesc(me, (Elf_Addr)me->destroy); + if (me->exit) + me->exit = (void *)get_fdesc(me, (Elf_Addr)me->exit); #endif #endif return 0; diff -Nru a/arch/parisc/kernel/pci.c b/arch/parisc/kernel/pci.c --- a/arch/parisc/kernel/pci.c Sun Mar 23 00:22:49 2003 +++ b/arch/parisc/kernel/pci.c Sun Mar 23 00:22:49 2003 @@ -83,16 +83,9 @@ u##size in##type (int addr) \ { \ int b = PCI_PORT_HBA(addr); \ - u##size d = (u##size) -1; \ EISA_IN(size); \ - ASSERT(pci_port); /* make sure services are defined */ \ - ASSERT(parisc_pci_hba[b]); /* make sure ioaddr are "fixed up" */ \ - if (parisc_pci_hba[b] == NULL) { \ - printk(KERN_WARNING "\nPCI or EISA Host Bus Adapter %d not registered. in" #size "(0x%x) returning -1\n", b, addr); \ - } else { \ - d = pci_port->in##type(parisc_pci_hba[b], PCI_PORT_ADDR(addr)); \ - } \ - return d; \ + if (!parisc_pci_hba[b]) return (u##size) -1; \ + return pci_port->in##type(parisc_pci_hba[b], PCI_PORT_ADDR(addr)); \ } PCI_PORT_IN(b, 8) @@ -105,7 +98,7 @@ { \ int b = PCI_PORT_HBA(addr); \ EISA_OUT(size); \ - ASSERT(pci_port); \ + if (!parisc_pci_hba[b]) return; \ pci_port->out##type(parisc_pci_hba[b], PCI_PORT_ADDR(addr), d); \ } @@ -318,9 +311,6 @@ EXPORT_SYMBOL(pcibios_resource_to_bus); #endif -#define MAX(val1, val2) ((val1) > (val2) ? (val1) : (val2)) - - /* ** pcibios align resources() is called everytime generic PCI code ** wants to generate a new address. The process of looking for @@ -349,7 +339,7 @@ align = (res->flags & IORESOURCE_IO) ? PCIBIOS_MIN_IO : PCIBIOS_MIN_MEM; /* Align to largest of MIN or input size */ - mask = MAX(alignment, align) - 1; + mask = max(alignment, align) - 1; res->start += mask; res->start &= ~mask; diff -Nru a/arch/parisc/kernel/process.c b/arch/parisc/kernel/process.c --- a/arch/parisc/kernel/process.c Sun Mar 23 00:22:56 2003 +++ b/arch/parisc/kernel/process.c Sun Mar 23 00:22:56 2003 @@ -205,7 +205,16 @@ int dump_fpu (struct pt_regs * regs, elf_fpregset_t *r) { + if (regs == NULL) + return 0; + memcpy(r, regs->fr, sizeof *r); + return 1; +} + +int dump_task_fpu (struct task_struct *tsk, elf_fpregset_t *r) +{ + memcpy(r, tsk->thread.regs.fr, sizeof(*r)); return 1; } diff -Nru a/arch/parisc/kernel/signal.c b/arch/parisc/kernel/signal.c --- a/arch/parisc/kernel/signal.c Sun Mar 23 00:22:56 2003 +++ b/arch/parisc/kernel/signal.c Sun Mar 23 00:22:56 2003 @@ -310,7 +310,7 @@ #endif #if CACHE_FLUSHING_IS_NOT_BROKEN - flush_icache_range((unsigned long) &frame->tramp[0], + flush_user_icache_range((unsigned long) &frame->tramp[0], (unsigned long) &frame->tramp[4]); #else /* It should *always* be cache line-aligned, but the compiler @@ -395,7 +395,7 @@ handle_signal(unsigned long sig, siginfo_t *info, sigset_t *oldset, struct pt_regs *regs, int in_syscall) { - struct k_sigaction *ka = ¤t->sig->action[sig-1]; + struct k_sigaction *ka = ¤t->sighand->action[sig-1]; DBG(("handle_signal(sig=%ld, ka=%p, info=%p, oldset=%p, regs=%p)\n", sig, ka, info, oldset, regs)); @@ -451,7 +451,7 @@ oldset->sig[0], oldset->sig[1])); - signr = get_signal_to_deliver(&info, regs); + signr = get_signal_to_deliver(&info, regs, NULL); if (signr > 0) { /* Restart a system call if necessary. */ if (in_syscall) { @@ -463,7 +463,7 @@ break; case -ERESTARTSYS: - ka = ¤t->sig->action[signr-1]; + ka = ¤t->sighand->action[signr-1]; if (!(ka->sa.sa_flags & SA_RESTART)) { DBG(("ERESTARTSYS: putting -EINTR\n")); regs->gr[28] = -EINTR; diff -Nru a/arch/parisc/kernel/sys32.h b/arch/parisc/kernel/sys32.h --- a/arch/parisc/kernel/sys32.h Sun Mar 23 00:22:53 2003 +++ b/arch/parisc/kernel/sys32.h Sun Mar 23 00:22:53 2003 @@ -1,6 +1,8 @@ #ifndef _PARISC64_KERNEL_SYS32_H #define _PARISC64_KERNEL_SYS32_H +#include + /* Call a kernel syscall which will use kernel space instead of user * space for its copy_to/from_user. */ @@ -12,6 +14,8 @@ set_fs (old_fs); \ } +#ifdef CONFIG_COMPAT + typedef __u32 __sighandler_t32; struct sigaction32 { @@ -19,5 +23,7 @@ unsigned int sa_flags; compat_sigset_t sa_mask; /* mask last for extensibility */ }; + +#endif #endif diff -Nru a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c --- a/arch/parisc/kernel/sys_parisc.c Sun Mar 23 00:22:55 2003 +++ b/arch/parisc/kernel/sys_parisc.c Sun Mar 23 00:22:55 2003 @@ -309,25 +309,6 @@ return -ENOSYS; } -/* - * Set a given TLS descriptor: - */ -asmlinkage int sys_set_thread_area(struct user_desc *u_info) -{ - return -ENOSYS; -} - - -/* - * Get the current Thread-Local Storage area: - */ - -asmlinkage int sys_get_thread_area(struct user_desc *u_info) -{ - return -ENOSYS; -} - - asmlinkage unsigned long sys_alloc_hugepages(int key, unsigned long addr, unsigned long len, int prot, int flag) { return -ENOMEM; diff -Nru a/arch/parisc/kernel/syscall.S b/arch/parisc/kernel/syscall.S --- a/arch/parisc/kernel/syscall.S Sun Mar 23 00:22:56 2003 +++ b/arch/parisc/kernel/syscall.S Sun Mar 23 00:22:56 2003 @@ -567,10 +567,10 @@ ENTRY_SAME(rt_sigsuspend_wrapper) /* not really SAME -- see the code */ ENTRY_SAME(chown) /* 180 */ /* setsockopt() used by iptables: SO_SET_REPLACE/SO_SET_ADD_COUNTERS */ - ENTRY_DIFF(setsockopt) + ENTRY_COMP(setsockopt) ENTRY_SAME(getsockopt) - ENTRY_DIFF(sendmsg) - ENTRY_DIFF(recvmsg) + ENTRY_COMP(sendmsg) + ENTRY_COMP(recvmsg) ENTRY_SAME(semop) /* 185 */ ENTRY_SAME(semget) ENTRY_DIFF(semctl_broken) @@ -600,8 +600,8 @@ ENTRY_COMP(futex) /* 210 */ ENTRY_SAME(sched_setaffinity) ENTRY_SAME(sched_getaffinity) - ENTRY_SAME(set_thread_area) - ENTRY_SAME(get_thread_area) + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) ENTRY_SAME(io_setup) /* 215 */ ENTRY_SAME(io_destroy) ENTRY_SAME(io_getevents) diff -Nru a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c --- a/arch/parisc/kernel/traps.c Sun Mar 23 00:22:56 2003 +++ b/arch/parisc/kernel/traps.c Sun Mar 23 00:22:56 2003 @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -165,9 +166,11 @@ startstack = (unsigned long *)((unsigned long)stack & ~(THREAD_SIZE - 1)); i = 1; + stack = (long *)((long)(stack + 32) &~ (FRAME_SIZE-1)); /* Align */ printk("Kernel addresses on the stack:\n"); - while (stack >= startstack) { - addr = *stack--; + while (stack > startstack) { + stack -= 16; /* Stack frames are a multiple of 16 words */ + addr = stack[16 - RP_OFFSET / sizeof(long)]; /* * If the address is either in the text segment of the * kernel, or in the region which contains vmalloc'ed diff -Nru a/arch/ppc/8260_io/enet.c b/arch/ppc/8260_io/enet.c --- a/arch/ppc/8260_io/enet.c Sun Mar 23 00:22:49 2003 +++ b/arch/ppc/8260_io/enet.c Sun Mar 23 00:22:49 2003 @@ -807,7 +807,7 @@ /* Install our interrupt handler. */ - request_8xxirq(SIU_INT_ENET, scc_enet_interrupt, 0, "enet", dev); + request_irq(SIU_INT_ENET, scc_enet_interrupt, 0, "enet", dev); /* Set GSMR_H to enable all normal operating modes. * Set GSMR_L to enable Ethernet to MC68160. diff -Nru a/arch/ppc/8260_io/fcc_enet.c b/arch/ppc/8260_io/fcc_enet.c --- a/arch/ppc/8260_io/fcc_enet.c Sun Mar 23 00:22:52 2003 +++ b/arch/ppc/8260_io/fcc_enet.c Sun Mar 23 00:22:52 2003 @@ -1705,12 +1705,12 @@ /* Install our interrupt handler. */ - if (request_8xxirq(fip->fc_interrupt, fcc_enet_interrupt, 0, + if (request_irq(fip->fc_interrupt, fcc_enet_interrupt, 0, "fenet", dev) < 0) printk("Can't get FCC IRQ %d\n", fip->fc_interrupt); #ifdef CONFIG_USE_MDIO - if (request_8xxirq(PHY_INTERRUPT, mii_link_interrupt, 0, + if (request_irq(PHY_INTERRUPT, mii_link_interrupt, 0, "mii", dev) < 0) printk("Can't get MII IRQ %d\n", fip->fc_interrupt); #endif /* CONFIG_USE_MDIO */ diff -Nru a/arch/ppc/8260_io/uart.c b/arch/ppc/8260_io/uart.c --- a/arch/ppc/8260_io/uart.c Sun Mar 23 00:22:50 2003 +++ b/arch/ppc/8260_io/uart.c Sun Mar 23 00:22:50 2003 @@ -3,6 +3,8 @@ * Copyright (c) 1999 Dan Malek (dmalek@jlc.net) * Copyright (c) 2000 MontaVista Software, Inc. (source@mvista.com) * 2.3.99 updates + * Copyright (c) 2002 Allen Curtis, Ones and Zeros, Inc. (acurtis@onz.com) + * 2.5.50 updates * * I used the 8xx uart.c driver as the framework for this driver. * The original code was written for the EST8260 board. I tried to make @@ -28,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -69,9 +72,7 @@ #define TX_WAKEUP ASYNC_SHARE_IRQ static char *serial_name = "CPM UART driver"; -static char *serial_version = "0.01"; - -static DECLARE_TASK_QUEUE(tq_serial); +static char *serial_version = "0.02"; static struct tty_driver serial_driver, callout_driver; static int serial_refcount; @@ -201,8 +202,8 @@ int blocked_open; /* # of blocked opens */ long session; /* Session of opening process */ long pgrp; /* pgrp of opening process */ - struct tq_struct tqueue; - struct tq_struct tqueue_hangup; + struct work_struct tqueue; + struct work_struct tqueue_hangup; wait_queue_head_t open_wait; wait_queue_head_t close_wait; @@ -331,8 +332,7 @@ int event) { info->event |= 1 << event; - queue_task(&info->tqueue, &tq_serial); - mark_bh(SERIAL_BH); + schedule_work(&info->tqueue); } static _INLINE_ void receive_chars(ser_info_t *info) @@ -479,7 +479,7 @@ info->rx_cur = (cbd_t *)bdp; - queue_task(&tty->flip.tqueue, &tq_timer); + schedule_delayed_work(&tty->flip.work, 1); } static _INLINE_ void transmit_chars(ser_info_t *info) @@ -537,7 +537,7 @@ printk("scheduling hangup..."); #endif MOD_INC_USE_COUNT; - if (schedule_task(&info->tqueue_hangup) == 0) + if (schedule_work(&info->tqueue_hangup) == 0) MOD_DEC_USE_COUNT; } } @@ -628,11 +628,6 @@ * interrupt driver proper are done; the interrupt driver schedules * them using rs_sched_event(), and they get done here. */ -static void do_serial_bh(void) -{ - run_task_queue(&tq_serial); -} - static void do_softint(void *private_) { ser_info_t *info = (ser_info_t *) private_; @@ -651,7 +646,7 @@ } /* - * This routine is called from the scheduler tqueue when the interrupt + * This routine is called from the scheduler work queue when the interrupt * routine has signalled that a hangup has occurred. The path of * hangup processing is: * @@ -1308,7 +1303,7 @@ { volatile cpm8260_t *cp; uint page, sblock; - ushort num; + int num; cp = cpmp; @@ -1352,7 +1347,7 @@ { volatile cpm8260_t *cp; uint page, sblock; - ushort num; + int num; cp = cpmp; @@ -1756,7 +1751,7 @@ */ char_time = 1; if (timeout) - char_time = min(char_time, timeout); + char_time = min(char_time, (unsigned long)timeout); #ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT printk("In rs_wait_until_sent(%d) check=%lu...", timeout, char_time); printk("jiff=%lu...", jiffies); @@ -1980,7 +1975,7 @@ ser_info_t *info; int retval, line; - line = MINOR(tty->device) - tty->driver.minor_start; + line = minor(tty->device) - tty->driver.minor_start; if ((line < 0) || (line >= NR_PORTS)) return -ENODEV; retval = get_async_struct(line, &info); @@ -2455,7 +2450,7 @@ static kdev_t serial_console_device(struct console *c) { - return MKDEV(TTY_MAJOR, 64 + c->index); + return mk_kdev(TTY_MAJOR, 64 + c->index); } @@ -2503,8 +2498,6 @@ volatile immap_t *immap; volatile iop8260_t *io; - init_bh(SERIAL_BH, do_serial_bh); - show_serial_version(); /* Initialize the tty_driver structure */ @@ -2680,10 +2673,8 @@ init_waitqueue_head(&info->close_wait); info->magic = SERIAL_MAGIC; info->flags = state->flags; - info->tqueue.routine = do_softint; - info->tqueue.data = info; - info->tqueue_hangup.routine = do_serial_hangup; - info->tqueue_hangup.data = info; + INIT_WORK(&info->tqueue, do_softint, info); + INIT_WORK(&info->tqueue_hangup, do_serial_hangup, info); info->line = i; info->state = state; state->info = (struct async_struct *)info; @@ -2874,7 +2865,7 @@ /* Install interrupt handler. */ - request_8xxirq(state->irq, rs_8xx_interrupt, 0, "uart", info); + request_irq(state->irq, rs_8xx_interrupt, 0, "uart", info); /* Set up the baud rate generator. */ diff -Nru a/arch/ppc/Makefile b/arch/ppc/Makefile --- a/arch/ppc/Makefile Sun Mar 23 00:22:50 2003 +++ b/arch/ppc/Makefile Sun Mar 23 00:22:50 2003 @@ -1,7 +1,5 @@ # This file is included by the global makefile so that you can add your own -# architecture-specific flags and dependencies. Remember to do have actions -# for "archclean" and "archdep" for cleaning up and making dependencies for -# this architecture +# architecture-specific flags and dependencies. # # This file is subject to the terms and conditions of the GNU General Public # License. See the file "COPYING" in the main directory of this archive @@ -17,24 +15,20 @@ LDFLAGS_BLOB := --format binary --oformat elf32-powerpc LDFLAGS_vmlinux = -Ttext $(KERNELLOAD) -Bstatic -CPPFLAGS := $(CPPFLAGS) -I$(TOPDIR)/arch/$(ARCH) -AFLAGS := $(AFLAGS) -I$(TOPDIR)/arch/$(ARCH) -CFLAGS := $(CFLAGS) -I$(TOPDIR)/arch/$(ARCH) -msoft-float -pipe \ +CPPFLAGS += -Iarch/$(ARCH) +AFLAGS += -Iarch/$(ARCH) +cflags-y += -Iarch/$(ARCH) -msoft-float -pipe \ -ffixed-r2 -Wno-uninitialized -mmultiple -mstring CPP = $(CC) -E $(CFLAGS) -ifdef CONFIG_4xx -CFLAGS := $(CFLAGS) -Wa,-m405 -endif +cflags-$(CONFIG_4xx) += -Wa,-m405 +cflags-$(CONFIG_PPC64BRIDGE) += -Wa,-mppc64bridge +# Use sed to remove the quotes. +cflags-$(CONFIG_MORE_COMPILE_OPTIONS) += \ + $(shell echo $(CONFIG_COMPILE_OPTIONS) | sed -e 's/"//g') -ifdef CONFIG_PPC64BRIDGE -CFLAGS := $(CFLAGS) -Wa,-mppc64bridge -endif +CFLAGS += $(cflags-y) -ifdef CONFIG_MORE_COMPILE_OPTIONS -# Use sed to remove the quotes. - CFLAGS += $(shell echo $(CONFIG_COMPILE_OPTIONS) | sed -e 's/"//g') -endif head-y := arch/ppc/kernel/head.o head-$(CONFIG_8xx) := arch/ppc/kernel/head_8xx.o diff -Nru a/arch/ppc/boot/Makefile b/arch/ppc/boot/Makefile --- a/arch/ppc/boot/Makefile Sun Mar 23 00:22:53 2003 +++ b/arch/ppc/boot/Makefile Sun Mar 23 00:22:53 2003 @@ -10,8 +10,8 @@ # modified by Cort (cort@cs.nmt.edu) # -CFLAGS += -fno-builtin -D__BOOTER__ -Iarch/$(ARCH)/boot/include -HOSTCFLAGS += -I$(TOPDIR)/arch/$(ARCH)/boot/include +CFLAGS += -fno-builtin -D__BOOTER__ -Iarch/$(ARCH)/boot/include +HOSTCFLAGS += -Iarch/$(ARCH)/boot/include BOOT_TARGETS = zImage zImage.initrd znetboot znetboot.initrd @@ -21,7 +21,7 @@ subdir-$(CONFIG_ALL_PPC) += of1275 # for cleaning -subdir- += simple openfirmware prep +subdir- += simple/ openfirmware/ prep/ tools-$(CONFIG_ALL_PPC) := addnote mknote hack-coff mkprep tools-$(CONFIG_PPLUS) := mkbugboot mkprep @@ -33,8 +33,6 @@ tools-$(CONFIG_PRPMC750) := mkbugboot mkprep tools-$(CONFIG_PRPMC800) := mkbugboot mkprep tools-$(CONFIG_SPRUCE) := mktree - -all-tools := addnote mknote hack-coff mkprep mkbugboot mktree host-progs := $(addprefix utils/,$(tools-y)) diff -Nru a/arch/ppc/boot/images/Makefile b/arch/ppc/boot/images/Makefile --- a/arch/ppc/boot/images/Makefile Sun Mar 23 00:22:50 2003 +++ b/arch/ppc/boot/images/Makefile Sun Mar 23 00:22:50 2003 @@ -2,7 +2,7 @@ # This dir holds all of the images for PPC machines. # Tom Rini January 2001 -targets := vmlinux.gz +extra-y := vmlinux.gz GZIP_FLAGS := -v9f $(obj)/vmlinux.gz: vmlinux diff -Nru a/arch/ppc/boot/openfirmware/Makefile b/arch/ppc/boot/openfirmware/Makefile --- a/arch/ppc/boot/openfirmware/Makefile Sun Mar 23 00:22:52 2003 +++ b/arch/ppc/boot/openfirmware/Makefile Sun Mar 23 00:22:52 2003 @@ -26,10 +26,15 @@ CHRP_LD_ARGS = -T $(boot)/ld.script -e _start -Ttext 0x00800000 NEWWORLD_LD_ARGS = -T $(boot)/ld.script -e _start -Ttext 0x01000000 -COMMONOBJS = $(obj)/start.o $(obj)/misc.o $(obj)/common.o -COFFOBJS = $(obj)/coffcrt0.o $(COMMONOBJS) $(obj)/coffmain.o -CHRPOBJS = $(obj)/crt0.o $(COMMONOBJS) $(obj)/chrpmain.o -NEWWORLDOBJS = $(obj)/crt0.o $(COMMONOBJS) $(obj)/newworldmain.o +COMMONOBJS := start.o misc.o common.o +COFFOBJS := coffcrt0.o $(COMMONOBJS) coffmain.o +CHRPOBJS := crt0.o $(COMMONOBJS) chrpmain.o +NEWWORLDOBJS := crt0.o $(COMMONOBJS) newworldmain.o + +EXTRA_TARGETS := $(COFFOBJS) $(CHRPOBJS) $(NEWWORLDOBJS) +COFFOBJS := $(addprefix $(obj)/, $(COFFOBJS)) +CHRPOBJS := $(addprefix $(obj)/, $(CHRPOBJS)) +NEWWORLDOBJS := $(addprefix $(obj)/, $(NEWWORLDOBJS)) LIBS = lib/lib.a $(bootlib)/lib.a $(of1275)/lib.a $(common)/lib.a diff -Nru a/arch/ppc/boot/prep/Makefile b/arch/ppc/boot/prep/Makefile --- a/arch/ppc/boot/prep/Makefile Sun Mar 23 00:22:55 2003 +++ b/arch/ppc/boot/prep/Makefile Sun Mar 23 00:22:55 2003 @@ -35,7 +35,8 @@ images := $(boot)/images simple := $(boot)/simple -OBJS := $(addprefix $(obj)/,$(boot-y)) $(simple)/legacy.o +EXTRA_TARGETS := $(boot-y) ../simple/legacy.o +OBJS := $(addprefix $(obj)/,$(boot-y)) $(simple)/legacy.o # Tools MKPREP := $(utils)/mkprep diff -Nru a/arch/ppc/boot/simple/embed_config.c b/arch/ppc/boot/simple/embed_config.c --- a/arch/ppc/boot/simple/embed_config.c Sun Mar 23 00:22:50 2003 +++ b/arch/ppc/boot/simple/embed_config.c Sun Mar 23 00:22:50 2003 @@ -431,7 +431,7 @@ } #endif -#ifdef CONFIG_EST8260 +#if defined(CONFIG_EST8260) || defined(CONFIG_TQM8260) void embed_config(bd_t **bdp) { diff -Nru a/arch/ppc/kernel/Makefile b/arch/ppc/kernel/Makefile --- a/arch/ppc/kernel/Makefile Sun Mar 23 00:22:55 2003 +++ b/arch/ppc/kernel/Makefile Sun Mar 23 00:22:55 2003 @@ -28,11 +28,8 @@ obj-$(CONFIG_KGDB) += ppc-stub.o obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_TAU) += temp.o -ifeq ($(CONFIG_8xx),y) -ifneq ($(CONFIG_MATH_EMULATION),n) -obj-y += softemu8xx.o -endif + +ifdef CONFIG_MATH_EMULATION +obj-$(CONFIG_8xx) += softemu8xx.o endif -find_name : find_name.c - $(HOSTCC) $(HOSTCFLAGS) -o find_name find_name.c diff -Nru a/arch/ppc/kernel/pci.c b/arch/ppc/kernel/pci.c --- a/arch/ppc/kernel/pci.c Sun Mar 23 00:22:53 2003 +++ b/arch/ppc/kernel/pci.c Sun Mar 23 00:22:53 2003 @@ -176,6 +176,21 @@ } #endif /* CONFIG_ALL_PPC */ +void +pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, + struct resource *res) +{ + unsigned long offset = 0; + struct pci_controller *hose = dev->sysdata; + + if (hose && res->flags & IORESOURCE_IO) + offset = (unsigned long)hose->io_base_virt - isa_io_base; + else if (hose && res->flags & IORESOURCE_MEM) + offset = hose->pci_mem_offset; + region->start = res->start - offset; + region->end = res->end - offset; +} + /* * We need to avoid collisions with `mirrored' VGA ports * and other strange ISA hardware, so we always want the @@ -579,8 +594,10 @@ */ if ((r->flags & IORESOURCE_UNSET) && r->end && (!ppc_md.pcibios_enable_device_hook || - !ppc_md.pcibios_enable_device_hook(dev, 1))) + !ppc_md.pcibios_enable_device_hook(dev, 1))) { + r->flags &= ~IORESOURCE_UNSET; pci_assign_resource(dev, idx); + } } #if 0 /* don't assign ROMs */ diff -Nru a/arch/ppc/kernel/ppc_ksyms.c b/arch/ppc/kernel/ppc_ksyms.c --- a/arch/ppc/kernel/ppc_ksyms.c Sun Mar 23 00:22:55 2003 +++ b/arch/ppc/kernel/ppc_ksyms.c Sun Mar 23 00:22:55 2003 @@ -337,7 +337,7 @@ #if defined(CONFIG_8xx) || defined(CONFIG_4xx) EXPORT_SYMBOL(__res); #endif -#if defined(CONFIG_8xx) || defined(CONFIG_8260) +#if defined(CONFIG_8xx) EXPORT_SYMBOL(request_8xxirq); #endif diff -Nru a/arch/ppc/kernel/traps.c b/arch/ppc/kernel/traps.c --- a/arch/ppc/kernel/traps.c Sun Mar 23 00:22:51 2003 +++ b/arch/ppc/kernel/traps.c Sun Mar 23 00:22:51 2003 @@ -86,13 +86,14 @@ void die(const char * str, struct pt_regs * fp, long err) { + static int die_counter; console_verbose(); spin_lock_irq(&die_lock); #ifdef CONFIG_PMAC_BACKLIGHT set_backlight_enable(1); set_backlight_level(BACKLIGHT_MAX); #endif - printk("Oops: %s, sig: %ld\n", str, err); + printk("Oops: %s, sig: %ld [#%d]\n", str, err, ++die_counter); show_regs(fp); spin_unlock_irq(&die_lock); /* do_exit() should take care of panic'ing from an interrupt diff -Nru a/arch/ppc/platforms/Makefile b/arch/ppc/platforms/Makefile --- a/arch/ppc/platforms/Makefile Sun Mar 23 00:22:56 2003 +++ b/arch/ppc/platforms/Makefile Sun Mar 23 00:22:56 2003 @@ -10,7 +10,7 @@ endif # Extra CFLAGS so we don't have to do relative includes -CFLAGS_pmac_setup.o += -I$(TOPDIR)/arch/$(ARCH)/mm +CFLAGS_pmac_setup.o += -Iarch/$(ARCH)/mm obj-$(CONFIG_APUS) += apus_setup.o ifeq ($(CONFIG_APUS),y) @@ -28,6 +28,8 @@ obj-$(CONFIG_PPC_RTAS) += error_log.o proc_rtas.o obj-$(CONFIG_PREP_RESIDUAL) += residual.o obj-$(CONFIG_ADIR) += adir_setup.o adir_pic.o adir_pci.o +obj-$(CONFIG_EST8260) += est8260_setup.o +obj-$(CONFIG_TQM8260) += tqm8260_setup.o obj-$(CONFIG_EV64260) += ev64260_setup.o obj-$(CONFIG_GEMINI) += gemini_pci.o gemini_setup.o gemini_prom.o obj-$(CONFIG_K2) += k2_setup.o k2_pci.o diff -Nru a/arch/ppc/platforms/est8260.h b/arch/ppc/platforms/est8260.h --- a/arch/ppc/platforms/est8260.h Sun Mar 23 00:22:54 2003 +++ b/arch/ppc/platforms/est8260.h Sun Mar 23 00:22:54 2003 @@ -3,8 +3,12 @@ * will soon be removed. All of the clock values are computed from * the configuration SCMR and the Power-On-Reset word. */ +#ifndef __EST8260_PLATFORM +#define __EST8260_PLATFORM -#define IMAP_ADDR ((uint)0xf0000000) +#define IMAP_ADDR ((uint)0xf0000000) + +#define BOOTROM_RESTART_ADDR ((uint)0xff000104) /* A Board Information structure that is given to a program when @@ -25,3 +29,4 @@ extern bd_t m8xx_board_info; +#endif /* __EST8260_PLATFORM */ diff -Nru a/arch/ppc/platforms/est8260_setup.c b/arch/ppc/platforms/est8260_setup.c --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/arch/ppc/platforms/est8260_setup.c Sun Mar 23 00:22:57 2003 @@ -0,0 +1,65 @@ +/* + * arch/ppc/platforms/est8260_setup.c + * + * EST8260 platform support + * + * Author: Allen Curtis + * Derived from: m8260_setup.c by Dan Malek, MVista + * + * Copyright 2002 Ones and Zeros, Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#include +#include + +#include +#include + +static void (*callback_setup_arch)(void); + +extern unsigned char __res[sizeof(bd_t)]; + +extern void m8260_init(unsigned long r3, unsigned long r4, + unsigned long r5, unsigned long r6, unsigned long r7); + +static int +est8260_show_cpuinfo(struct seq_file *m) +{ + bd_t *binfo = (bd_t *)__res; + + seq_printf(m, "vendor\t\t: EST Corporation\n" + "machine\t\t: SBC8260 PowerPC\n" + "\n" + "mem size\t\t: 0x%08x\n" + "console baud\t\t: %d\n" + "\n", + binfo->bi_memsize, + binfo->bi_baudrate); + return 0; +} + +static void __init +est8260_setup_arch(void) +{ + printk("EST SBC8260 Port\n"); + callback_setup_arch(); +} + +void __init +platform_init(unsigned long r3, unsigned long r4, unsigned long r5, + unsigned long r6, unsigned long r7) +{ + /* Generic 8260 platform initialization */ + m8260_init(r3, r4, r5, r6, r7); + + /* Anything special for this platform */ + ppc_md.show_cpuinfo = est8260_show_cpuinfo; + + callback_setup_arch = ppc_md.setup_arch; + ppc_md.setup_arch = est8260_setup_arch; +} diff -Nru a/arch/ppc/platforms/k2_setup.c b/arch/ppc/platforms/k2_setup.c --- a/arch/ppc/platforms/k2_setup.c Sun Mar 23 00:22:54 2003 +++ b/arch/ppc/platforms/k2_setup.c Sun Mar 23 00:22:54 2003 @@ -56,10 +56,10 @@ /* IDE functions */ static void __init -k2_ide_init_hwif_ports (hw_regs_t *hw, ide_ioreg_t data_port, - ide_ioreg_t ctrl_port, int *irq) +k2_ide_init_hwif_ports (hw_regs_t *hw, unsigned long data_port, + unsigned long ctrl_port, int *irq) { - ide_ioreg_t reg = data_port; + unsigned long reg = data_port; int i = 8; for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) { diff -Nru a/arch/ppc/platforms/lopec_setup.c b/arch/ppc/platforms/lopec_setup.c --- a/arch/ppc/platforms/lopec_setup.c Sun Mar 23 00:22:53 2003 +++ b/arch/ppc/platforms/lopec_setup.c Sun Mar 23 00:22:53 2003 @@ -104,9 +104,9 @@ #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE) int lopec_ide_ports_known = 0; -static ide_ioreg_t lopec_ide_regbase[MAX_HWIFS]; -static ide_ioreg_t lopec_ide_ctl_regbase[MAX_HWIFS]; -static ide_ioreg_t lopec_idedma_regbase; +static unsigned long lopec_ide_regbase[MAX_HWIFS]; +static unsigned long lopec_ide_ctl_regbase[MAX_HWIFS]; +static unsigned long lopec_idedma_regbase; static void lopec_ide_probe(void) @@ -126,7 +126,7 @@ } static int -lopec_ide_default_irq(ide_ioreg_t base) +lopec_ide_default_irq(unsigned long base) { if (lopec_ide_ports_known == 0) lopec_ide_probe(); @@ -139,7 +139,7 @@ return 0; } -static ide_ioreg_t +static unsigned long lopec_ide_default_io_base(int index) { if (lopec_ide_ports_known == 0) @@ -148,10 +148,10 @@ } static void __init -lopec_ide_init_hwif_ports(hw_regs_t *hw, ide_ioreg_t data, - ide_ioreg_t ctl, int *irq) +lopec_ide_init_hwif_ports(hw_regs_t *hw, unsigned long data, + unsigned long ctl, int *irq) { - ide_ioreg_t reg = data; + unsigned long reg = data; uint alt_status_base; int i; diff -Nru a/arch/ppc/platforms/mcpn765_setup.c b/arch/ppc/platforms/mcpn765_setup.c --- a/arch/ppc/platforms/mcpn765_setup.c Sun Mar 23 00:22:54 2003 +++ b/arch/ppc/platforms/mcpn765_setup.c Sun Mar 23 00:22:54 2003 @@ -274,9 +274,9 @@ * IDE support. */ static int mcpn765_ide_ports_known = 0; -static ide_ioreg_t mcpn765_ide_regbase[MAX_HWIFS]; -static ide_ioreg_t mcpn765_ide_ctl_regbase[MAX_HWIFS]; -static ide_ioreg_t mcpn765_idedma_regbase; +static unsigned long mcpn765_ide_regbase[MAX_HWIFS]; +static unsigned long mcpn765_ide_ctl_regbase[MAX_HWIFS]; +static unsigned long mcpn765_idedma_regbase; static void mcpn765_ide_probe(void) @@ -298,7 +298,7 @@ } static int -mcpn765_ide_default_irq(ide_ioreg_t base) +mcpn765_ide_default_irq(unsigned long base) { if (mcpn765_ide_ports_known == 0) mcpn765_ide_probe(); @@ -311,7 +311,7 @@ return 0; } -static ide_ioreg_t +static unsigned long mcpn765_ide_default_io_base(int index) { if (mcpn765_ide_ports_known == 0) @@ -321,10 +321,10 @@ } static void __init -mcpn765_ide_init_hwif_ports(hw_regs_t *hw, ide_ioreg_t data_port, - ide_ioreg_t ctrl_port, int *irq) +mcpn765_ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port, + unsigned long ctrl_port, int *irq) { - ide_ioreg_t reg = data_port; + unsigned long reg = data_port; uint alt_status_base; int i; diff -Nru a/arch/ppc/platforms/menf1_setup.c b/arch/ppc/platforms/menf1_setup.c --- a/arch/ppc/platforms/menf1_setup.c Sun Mar 23 00:22:55 2003 +++ b/arch/ppc/platforms/menf1_setup.c Sun Mar 23 00:22:55 2003 @@ -194,10 +194,10 @@ /* IDE functions */ static void __init -menf1_ide_init_hwif_ports (hw_regs_t *hw, ide_ioreg_t data_port, - ide_ioreg_t ctrl_port, int *irq) +menf1_ide_init_hwif_ports (hw_regs_t *hw, unsigned long data_port, + unsigned long ctrl_port, int *irq) { - ide_ioreg_t reg = data_port; + unsigned long reg = data_port; int i = 8; for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) { @@ -215,7 +215,7 @@ } static int -menf1_ide_default_irq(ide_ioreg_t base) +menf1_ide_default_irq(unsigned long base) { if (base == MENF1_IDE0_BASE_ADDR) return 14; @@ -225,7 +225,7 @@ return 0; } -static ide_ioreg_t +static unsigned long menf1_ide_default_io_base(int index) { if (index == 0) diff -Nru a/arch/ppc/platforms/mpc82xx.h b/arch/ppc/platforms/mpc82xx.h --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/arch/ppc/platforms/mpc82xx.h Sun Mar 23 00:22:57 2003 @@ -0,0 +1,42 @@ +/* + * arch/ppc/platforms/mpc82xx.h + * + * Board specific support for various 82xx platforms. + * + * Author: Allen Curtis + * + * Copyright 2002 Ones and Zeros, Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ +#ifndef __CONFIG_82XX_PLATFORMS +#define __CONFIG_82XX_PLATFORMS + +#ifdef CONFIG_8260 + +#ifdef CONFIG_EST8260 +#include +#endif + +#ifdef CONFIG_SBS8260 +#include +#endif + +#ifdef CONFIG_RPX6 +#include +#endif + +#ifdef CONFIG_WILLOW +#include +#endif + +#ifdef CONFIG_TQM8260 +#include +#endif + +#endif /* CONFIG_8260 */ + +#endif diff -Nru a/arch/ppc/platforms/pmac_setup.c b/arch/ppc/platforms/pmac_setup.c --- a/arch/ppc/platforms/pmac_setup.c Sun Mar 23 00:22:54 2003 +++ b/arch/ppc/platforms/pmac_setup.c Sun Mar 23 00:22:54 2003 @@ -81,8 +81,9 @@ extern void pmac_calibrate_decr(void); extern void pmac_pcibios_fixup(void); extern void pmac_find_bridges(void); -extern int pmac_ide_check_base(ide_ioreg_t base); -extern ide_ioreg_t pmac_ide_get_base(int index); +extern unsigned long pmac_ide_get_base(int index); +extern void pmac_ide_init_hwif_ports(hw_regs_t *hw, + unsigned long data_port, unsigned long ctrl_port, int *irq); extern void pmac_nvram_update(void); extern unsigned char pmac_nvram_read_byte(int addr); @@ -629,6 +630,13 @@ ppc_md.find_end_of_memory = pmac_find_end_of_memory; ppc_md.feature_call = pmac_do_feature_call; + +#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE) +#ifdef CONFIG_BLK_DEV_IDE_PMAC + ppc_ide_md.ide_init_hwif = pmac_ide_init_hwif_ports; + ppc_ide_md.default_io_base = pmac_ide_get_base; +#endif /* CONFIG_BLK_DEV_IDE_PMAC */ +#endif /* defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE) */ #ifdef CONFIG_BOOTX_TEXT ppc_md.progress = pmac_progress; diff -Nru a/arch/ppc/platforms/pplus_setup.c b/arch/ppc/platforms/pplus_setup.c --- a/arch/ppc/platforms/pplus_setup.c Sun Mar 23 00:22:55 2003 +++ b/arch/ppc/platforms/pplus_setup.c Sun Mar 23 00:22:55 2003 @@ -235,7 +235,7 @@ * IDE stuff. */ static int -pplus_ide_default_irq(ide_ioreg_t base) +pplus_ide_default_irq(unsigned long base) { switch (base) { case 0x1f0: return 14; @@ -244,7 +244,7 @@ } } -static ide_ioreg_t +static unsigned long pplus_ide_default_io_base(int index) { switch (index) { @@ -256,9 +256,9 @@ } static void __init -pplus_ide_init_hwif_ports (hw_regs_t *hw, ide_ioreg_t data_port, ide_ioreg_t ctrl_port, int *irq) +pplus_ide_init_hwif_ports (hw_regs_t *hw, unsigned long data_port, unsigned long ctrl_port, int *irq) { - ide_ioreg_t reg = data_port; + unsigned long reg = data_port; int i; for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) { diff -Nru a/arch/ppc/platforms/prep_setup.c b/arch/ppc/platforms/prep_setup.c --- a/arch/ppc/platforms/prep_setup.c Sun Mar 23 00:22:55 2003 +++ b/arch/ppc/platforms/prep_setup.c Sun Mar 23 00:22:55 2003 @@ -1017,7 +1017,7 @@ * IDE stuff. */ static int __prep -prep_ide_default_irq(ide_ioreg_t base) +prep_ide_default_irq(unsigned long base) { switch (base) { case 0x1f0: return 13; @@ -1030,7 +1030,7 @@ } } -static ide_ioreg_t __prep +static unsigned long __prep prep_ide_default_io_base(int index) { switch (index) { diff -Nru a/arch/ppc/platforms/sandpoint_setup.c b/arch/ppc/platforms/sandpoint_setup.c --- a/arch/ppc/platforms/sandpoint_setup.c Sun Mar 23 00:22:56 2003 +++ b/arch/ppc/platforms/sandpoint_setup.c Sun Mar 23 00:22:56 2003 @@ -433,9 +433,9 @@ * IDE support. */ static int sandpoint_ide_ports_known = 0; -static ide_ioreg_t sandpoint_ide_regbase[MAX_HWIFS]; -static ide_ioreg_t sandpoint_ide_ctl_regbase[MAX_HWIFS]; -static ide_ioreg_t sandpoint_idedma_regbase; +static unsigned long sandpoint_ide_regbase[MAX_HWIFS]; +static unsigned long sandpoint_ide_ctl_regbase[MAX_HWIFS]; +static unsigned long sandpoint_idedma_regbase; static void sandpoint_ide_probe(void) @@ -457,7 +457,7 @@ } static int -sandpoint_ide_default_irq(ide_ioreg_t base) +sandpoint_ide_default_irq(unsigned long base) { if (sandpoint_ide_ports_known == 0) sandpoint_ide_probe(); @@ -470,7 +470,7 @@ return 0; } -static ide_ioreg_t +static unsigned long sandpoint_ide_default_io_base(int index) { if (sandpoint_ide_ports_known == 0) @@ -480,10 +480,10 @@ } static void __init -sandpoint_ide_init_hwif_ports(hw_regs_t *hw, ide_ioreg_t data_port, - ide_ioreg_t ctrl_port, int *irq) +sandpoint_ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port, + unsigned long ctrl_port, int *irq) { - ide_ioreg_t reg = data_port; + unsigned long reg = data_port; uint alt_status_base; int i; diff -Nru a/arch/ppc/platforms/tqm8260.h b/arch/ppc/platforms/tqm8260.h --- a/arch/ppc/platforms/tqm8260.h Sun Mar 23 00:22:53 2003 +++ b/arch/ppc/platforms/tqm8260.h Sun Mar 23 00:22:53 2003 @@ -4,8 +4,8 @@ * Copyright (c) 2001 Wolfgang Denk (wd@denx.de) */ -#ifndef __MACH_TQM8260_H -#define __MACH_TQM8260_H +#ifndef __TQM8260_PLATFORM +#define __TQM8260_PLATFORM #include @@ -14,4 +14,6 @@ #define IMAP_ADDR ((uint)0xFFF00000) #define PHY_INTERRUPT 25 -#endif /* __MACH_TQM8260_H */ +#define BOOTROM_RESTART_ADDR ((uint)0x40000104) + +#endif /* __TQM8260_PLATFORM */ diff -Nru a/arch/ppc/platforms/tqm8260_setup.c b/arch/ppc/platforms/tqm8260_setup.c --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/arch/ppc/platforms/tqm8260_setup.c Sun Mar 23 00:22:57 2003 @@ -0,0 +1,79 @@ +/* + * arch/ppc/platforms/tqm8260_setup.c + * + * TQM8260 platform support + * + * Author: Allen Curtis + * Derived from: m8260_setup.c by Dan Malek, MVista + * + * Copyright 2002 Ones and Zeros, Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#include +#include + +#include +#include +#include + +static void (*callback_setup_arch)(void); + +extern unsigned char __res[sizeof(bd_t)]; + +extern void m8260_init(unsigned long r3, unsigned long r4, + unsigned long r5, unsigned long r6, unsigned long r7); + +static int +tqm8260_show_cpuinfo(struct seq_file *m) +{ + bd_t *binfo = (bd_t *)__res; + + seq_printf(m, "vendor\t\t: IN2 Systems\n" + "machine\t\t: TQM8260 PowerPC\n" + "mem size\t\t: 0x%08x\n" + "\n", + binfo->bi_memsize); + return 0; +} + +static int +tqm8260_set_rtc_time(unsigned long time) +{ + ((immap_t *)IMAP_ADDR)->im_sit.sit_tmcnt = time; + ((immap_t *)IMAP_ADDR)->im_sit.sit_tmcntsc = 0x3; + + return(0); +} + +static unsigned long +tqm8260_get_rtc_time(void) +{ + return ((immap_t *)IMAP_ADDR)->im_sit.sit_tmcnt; +} + +static void __init +tqm8260_setup_arch(void) +{ + printk("IN2 Systems TQM8260 port\n"); + callback_setup_arch(); +} + +void __init +platform_init(unsigned long r3, unsigned long r4, unsigned long r5, + unsigned long r6, unsigned long r7) +{ + /* Generic 8260 platform initialization */ + m8260_init(r3, r4, r5, r6, r7); + + /* Anything special for this platform */ + ppc_md.show_cpuinfo = tqm8260_show_cpuinfo; + ppc_md.set_rtc_time = tqm8260_set_rtc_time; + ppc_md.get_rtc_time = tqm8260_get_rtc_time; + + callback_setup_arch = ppc_md.setup_arch; + ppc_md.setup_arch = tqm8260_setup_arch; diff -Nru a/arch/ppc/syslib/Makefile b/arch/ppc/syslib/Makefile --- a/arch/ppc/syslib/Makefile Sun Mar 23 00:22:50 2003 +++ b/arch/ppc/syslib/Makefile Sun Mar 23 00:22:50 2003 @@ -64,5 +64,3 @@ obj-$(CONFIG_8260) += m8260_setup.o ppc8260_pic.o obj-$(CONFIG_BOOTX_TEXT) += btext.o -find_name : find_name.c - $(HOSTCC) $(HOSTCFLAGS) -o find_name find_name.c diff -Nru a/arch/ppc/syslib/m8260_setup.c b/arch/ppc/syslib/m8260_setup.c --- a/arch/ppc/syslib/m8260_setup.c Sun Mar 23 00:22:53 2003 +++ b/arch/ppc/syslib/m8260_setup.c Sun Mar 23 00:22:53 2003 @@ -63,16 +63,6 @@ m8260_cpm_reset(); } -static void -abort(void) -{ -#ifdef CONFIG_XMON - extern void xmon(void *); - xmon(0); -#endif - machine_restart(NULL); -} - /* The decrementer counts at the system (internal) clock frequency * divided by four. */ @@ -93,30 +83,27 @@ */ static uint rtc_time; -static static int +static int m8260_set_rtc_time(unsigned long time) { -#ifdef CONFIG_TQM8260 - ((immap_t *)IMAP_ADDR)->im_sit.sit_tmcnt = time; - ((immap_t *)IMAP_ADDR)->im_sit.sit_tmcntsc = 0x3; -#else rtc_time = time; -#endif + return(0); } static unsigned long m8260_get_rtc_time(void) { -#ifdef CONFIG_TQM8260 - return ((immap_t *)IMAP_ADDR)->im_sit.sit_tmcnt; -#else /* Get time from the RTC. */ return((unsigned long)rtc_time); -#endif } +#ifndef BOOTROM_RESTART_ADDR +#warning "Using default BOOTROM_RESTART_ADDR!" +#define BOOTROM_RESTART_ADDR 0xff000104 +#endif + static void m8260_restart(char *cmd) { @@ -127,32 +114,28 @@ * of the reset vector. If that doesn't work for you, change this * or the reboot program to send a proper address. */ -#ifdef CONFIG_TQM8260 - startaddr = 0x40000104; -#else - startaddr = 0xff000104; -#endif + startaddr = BOOTROM_RESTART_ADDR; if (cmd != NULL) { if (!strncmp(cmd, "startaddr=", 10)) startaddr = simple_strtoul(&cmd[10], NULL, 0); } - m8260_gorom((unsigned int)__pa(__res), startaddr); + m8260_gorom((void*)__pa(__res), startaddr); } static void -m8260_power_off(void) +m8260_halt(void) { - m8260_restart(NULL); + local_irq_disable(); + while (1); } static void -m8260_halt(void) +m8260_power_off(void) { - m8260_restart(NULL); + m8260_halt(); } - static int m8260_show_percpuinfo(struct seq_file *m, int i) { @@ -181,9 +164,6 @@ int i; void cpm_interrupt_init(void); -#if 0 - ppc8260_pic.irq_offset = 0; -#endif for ( i = 0 ; i < NR_SIU_INTS ; i++ ) irq_desc[i].handler = &ppc8260_pic; @@ -194,7 +174,6 @@ immr->im_intctl.ic_siprr = 0x05309770; immr->im_intctl.ic_scprrh = 0x05309770; immr->im_intctl.ic_scprrl = 0x05309770; - } /* @@ -219,12 +198,29 @@ static void __init m8260_map_io(void) { - io_block_mapping(0xf0000000, 0xf0000000, 0x10000000, _PAGE_IO); - io_block_mapping(0xe0000000, 0xe0000000, 0x10000000, _PAGE_IO); -} + uint addr; + /* Map IMMR region to a 256MB BAT */ + addr = (immr != NULL) ? (uint)immr : IMAP_ADDR; + io_block_mapping(addr, addr, 0x10000000, _PAGE_IO); + + /* Map I/O region to a 256MB BAT */ + io_block_mapping(IO_VIRT_ADDR, IO_PHYS_ADDR, 0x10000000, _PAGE_IO); +} + +/* Inputs: + * r3 - Optional pointer to a board information structure. + * r4 - Optional pointer to the physical starting address of the init RAM + * disk. + * r5 - Optional pointer to the physical ending address of the init RAM + * disk. + * r6 - Optional pointer to the physical starting address of any kernel + * command-line parameters. + * r7 - Optional pointer to the physical ending address of any kernel + * command-line parameters. + */ void __init -platform_init(unsigned long r3, unsigned long r4, unsigned long r5, +m8260_init(unsigned long r3, unsigned long r4, unsigned long r5, unsigned long r6, unsigned long r7) { parse_bootinfo(find_bootinfo()); @@ -265,11 +261,3 @@ ppc_md.setup_io_mappings = m8260_map_io; } -/* Mainly for ksyms. -*/ -int -request_irq(unsigned int irq, void (*handler)(int, void *, struct pt_regs *), - unsigned long flag, const char *naem, void *dev) -{ - panic("request IRQ\n"); -} diff -Nru a/arch/ppc/syslib/ppc4xx_setup.c b/arch/ppc/syslib/ppc4xx_setup.c --- a/arch/ppc/syslib/ppc4xx_setup.c Sun Mar 23 00:22:49 2003 +++ b/arch/ppc/syslib/ppc4xx_setup.c Sun Mar 23 00:22:49 2003 @@ -228,8 +228,8 @@ */ #if defined(CONFIG_PCI) && defined(CONFIG_IDE) static void -ppc4xx_ide_init_hwif_ports(hw_regs_t * hw, ide_ioreg_t data_port, - ide_ioreg_t ctrl_port, int *irq) +ppc4xx_ide_init_hwif_ports(hw_regs_t * hw, unsigned long data_port, + unsigned long ctrl_port, int *irq) { int i; diff -Nru a/arch/ppc/syslib/prom.c b/arch/ppc/syslib/prom.c --- a/arch/ppc/syslib/prom.c Sun Mar 23 00:22:50 2003 +++ b/arch/ppc/syslib/prom.c Sun Mar 23 00:22:50 2003 @@ -37,9 +37,6 @@ #include #include -#ifdef CONFIG_FB -#include -#endif struct pci_address { unsigned a_hi; diff -Nru a/arch/ppc/syslib/prom_init.c b/arch/ppc/syslib/prom_init.c --- a/arch/ppc/syslib/prom_init.c Sun Mar 23 00:22:56 2003 +++ b/arch/ppc/syslib/prom_init.c Sun Mar 23 00:22:56 2003 @@ -34,8 +34,9 @@ #include #include -#ifdef CONFIG_FB -#include +#ifdef CONFIG_LOGO_LINUX_CLUT224 +#include +extern const struct linux_logo logo_linux_clut224; #endif /* @@ -294,6 +295,7 @@ 0xff, 0xff, 0x55, 0xff, 0xff, 0xff }; + const unsigned char *clut; prom_disp_node = 0; @@ -360,20 +362,20 @@ * method is available. * Should update this to use set-colors. */ - for (i = 0; i < 32; i++) - if (prom_set_color(ih, i, default_colors[i*3], - default_colors[i*3+1], - default_colors[i*3+2]) != 0) + clut = default_colors; + for (i = 0; i < 32; i++, clut += 3) + if (prom_set_color(ih, i, clut[0], clut[1], + clut[2]) != 0) break; -#ifdef CONFIG_FRAMEBUFFER_CONSOLE - for (i = 0; i < LINUX_LOGO_COLORS; i++) - if (prom_set_color(ih, i + 32, - linux_logo_red[i], - linux_logo_green[i], - linux_logo_blue[i]) != 0) +#ifdef CONFIG_LOGO_LINUX_CLUT224 + clut = logo_linux_clut224.clut; + for (i = 0; i < logo_linux_clut224.clutsize; + i++, clut += 3) + if (prom_set_color(ih, i + 32, clut[0], + clut[1], clut[2]) != 0) break; -#endif /* CONFIG_FRAMEBUFFER_CONSOLE */ +#endif /* CONFIG_LOGO_LINUX_CLUT224 */ } } diff -Nru a/arch/ppc64/kernel/prom.c b/arch/ppc64/kernel/prom.c --- a/arch/ppc64/kernel/prom.c Sun Mar 23 00:22:54 2003 +++ b/arch/ppc64/kernel/prom.c Sun Mar 23 00:22:54 2003 @@ -49,8 +49,9 @@ #include #include "open_pic.h" -#ifdef CONFIG_FB -#include +#ifdef CONFIG_LOGO_LINUX_CLUT224 +#include +extern const struct linux_logo logo_linux_clut224; #endif /* @@ -1232,6 +1233,7 @@ 0xff, 0xff, 0x55, 0xff, 0xff, 0xff }; + const unsigned char *clut; _prom->disp_node = 0; @@ -1261,20 +1263,19 @@ /* Setup a useable color table when the appropriate * method is available. Should update this to set-colors */ - for (i = 0; i < 32; i++) - if (prom_set_color(ih, i, RELOC(default_colors)[i*3], - RELOC(default_colors)[i*3+1], - RELOC(default_colors)[i*3+2]) != 0) + clut = RELOC(default_colors); + for (i = 0; i < 32; i++, clut += 3) + if (prom_set_color(ih, i, clut[0], clut[1], + clut[2]) != 0) break; -#ifdef CONFIG_FRAMEBUFFER_CONSOLE - for (i = 0; i < LINUX_LOGO_COLORS; i++) - if (prom_set_color(ih, i + 32, - RELOC(linux_logo_red)[i], - RELOC(linux_logo_green)[i], - RELOC(linux_logo_blue)[i]) != 0) +#ifdef CONFIG_LOGO_LINUX_CLUT224 + clut = RELOC(RELOC(&logo_linux_clut224)->clut); + for (i = 0; i < logo_linux_clut224.clutsize; i++, clut += 3) + if (prom_set_color(ih, i + 32, clut[0], clut[1], + clut[2]) != 0) break; -#endif /* CONFIG_FRAMEBUFFER_CONSOLE */ +#endif /* CONFIG_LOGO_LINUX_CLUT224 */ /* * If this display is the device that OF is using for stdout, diff -Nru a/arch/ppc64/kernel/traps.c b/arch/ppc64/kernel/traps.c --- a/arch/ppc64/kernel/traps.c Sun Mar 23 00:22:53 2003 +++ b/arch/ppc64/kernel/traps.c Sun Mar 23 00:22:53 2003 @@ -62,10 +62,11 @@ void die(const char *str, struct pt_regs *regs, long err) { + static int die_counter; console_verbose(); spin_lock_irq(&die_lock); bust_spinlocks(1); - printk("Oops: %s, sig: %ld\n", str, err); + printk("Oops: %s, sig: %ld [#%d]\n", str, err, ++die_counter); show_regs(regs); bust_spinlocks(0); spin_unlock_irq(&die_lock); diff -Nru a/arch/s390/kernel/traps.c b/arch/s390/kernel/traps.c --- a/arch/s390/kernel/traps.c Sun Mar 23 00:22:52 2003 +++ b/arch/s390/kernel/traps.c Sun Mar 23 00:22:52 2003 @@ -226,10 +226,11 @@ void die(const char * str, struct pt_regs * regs, long err) { + static int die_counter; console_verbose(); spin_lock_irq(&die_lock); bust_spinlocks(1); - printk("%s: %04lx\n", str, err & 0xffff); + printk("%s: %04lx [#%d]\n", str, err & 0xffff, ++die_counter); show_regs(regs); bust_spinlocks(0); spin_unlock_irq(&die_lock); diff -Nru a/arch/s390x/kernel/binfmt_elf32.c b/arch/s390x/kernel/binfmt_elf32.c --- a/arch/s390x/kernel/binfmt_elf32.c Sun Mar 23 00:22:56 2003 +++ b/arch/s390x/kernel/binfmt_elf32.c Sun Mar 23 00:22:56 2003 @@ -36,7 +36,7 @@ /* For SVR4/S390 the function pointer to be registered with `atexit` is passed in R14. */ -#define ELF_PLAT_INIT(_r) \ +#define ELF_PLAT_INIT(_r, load_addr) \ do { \ _r->gprs[14] = 0; \ set_thread_flag(TIF_31BIT); \ diff -Nru a/arch/s390x/kernel/exec32.c b/arch/s390x/kernel/exec32.c --- a/arch/s390x/kernel/exec32.c Sun Mar 23 00:22:49 2003 +++ b/arch/s390x/kernel/exec32.c Sun Mar 23 00:22:49 2003 @@ -21,7 +21,6 @@ #include #include #include -#define __NO_VERSION__ #include #include diff -Nru a/arch/s390x/kernel/traps.c b/arch/s390x/kernel/traps.c --- a/arch/s390x/kernel/traps.c Sun Mar 23 00:22:54 2003 +++ b/arch/s390x/kernel/traps.c Sun Mar 23 00:22:54 2003 @@ -228,10 +228,11 @@ void die(const char * str, struct pt_regs * regs, long err) { + static int die_counter; console_verbose(); spin_lock_irq(&die_lock); bust_spinlocks(1); - printk("%s: %04lx\n", str, err & 0xffff); + printk("%s: %04lx [#%d]\n", str, err & 0xffff, ++die_counter); show_regs(regs); bust_spinlocks(0); spin_unlock_irq(&die_lock); diff -Nru a/arch/sh/kernel/traps.c b/arch/sh/kernel/traps.c --- a/arch/sh/kernel/traps.c Sun Mar 23 00:22:50 2003 +++ b/arch/sh/kernel/traps.c Sun Mar 23 00:22:50 2003 @@ -58,9 +58,10 @@ void die(const char * str, struct pt_regs * regs, long err) { + static int die_counter; console_verbose(); spin_lock_irq(&die_lock); - printk("%s: %04lx\n", str, err & 0xffff); + printk("%s: %04lx [#%d]\n", str, err & 0xffff, ++die_counter); show_regs(regs); spin_unlock_irq(&die_lock); do_exit(SIGSEGV); diff -Nru a/arch/sparc/kernel/traps.c b/arch/sparc/kernel/traps.c --- a/arch/sparc/kernel/traps.c Sun Mar 23 00:22:53 2003 +++ b/arch/sparc/kernel/traps.c Sun Mar 23 00:22:53 2003 @@ -89,6 +89,7 @@ void die_if_kernel(char *str, struct pt_regs *regs) { + static int die_counter; int count = 0; /* Amuse the user. */ @@ -98,7 +99,7 @@ " /_| \\__/ |_\\\n" " \\__U_/\n"); - printk("%s(%d): %s\n", current->comm, current->pid, str); + printk("%s(%d): %s [#%d]\n", current->comm, current->pid, str, ++die_counter); show_regs(regs); __SAVE; __SAVE; __SAVE; __SAVE; diff -Nru a/arch/sparc64/kernel/head.S b/arch/sparc64/kernel/head.S --- a/arch/sparc64/kernel/head.S Sun Mar 23 00:22:52 2003 +++ b/arch/sparc64/kernel/head.S Sun Mar 23 00:22:52 2003 @@ -671,7 +671,9 @@ #endif /* Kill PROM timer */ - wr %g0, 0, %tick_cmpr + sethi %hi(0x80000000), %g1 + sllx %g1, 32, %g1 + wr %g1, 0, %tick_cmpr BRANCH_IF_ANY_CHEETAH(g1,g5,1f) diff -Nru a/arch/sparc64/kernel/irq.c b/arch/sparc64/kernel/irq.c --- a/arch/sparc64/kernel/irq.c Sun Mar 23 00:22:55 2003 +++ b/arch/sparc64/kernel/irq.c Sun Mar 23 00:22:55 2003 @@ -719,12 +719,8 @@ */ { unsigned long clr_mask = 1 << irq; - unsigned long tick_mask; + unsigned long tick_mask = tick_ops->softint_mask; - if (SPARC64_USE_STICK) - tick_mask = (1UL << 16); - else - tick_mask = (1UL << 0); if ((irq == 14) && (get_softint() & tick_mask)) { irq = 0; clr_mask = tick_mask; @@ -944,113 +940,6 @@ int probe_irq_off(unsigned long mask) { return 0; -} - -/* This is gets the master TICK_INT timer going. */ -void sparc64_init_timers(void (*cfunc)(int, void *, struct pt_regs *), - unsigned long *clock) -{ - unsigned long pstate; - extern unsigned long timer_tick_offset; - int node, err; -#ifdef CONFIG_SMP - extern void smp_tick_init(void); -#endif - - if (!SPARC64_USE_STICK) { - node = linux_cpus[0].prom_node; - *clock = prom_getint(node, "clock-frequency"); - } else { - node = prom_root_node; - *clock = prom_getint(node, "stick-frequency"); - } - timer_tick_offset = *clock / HZ; -#ifdef CONFIG_SMP - smp_tick_init(); -#endif - - /* Register IRQ handler. */ - err = request_irq(build_irq(0, 0, 0UL, 0UL), cfunc, SA_STATIC_ALLOC, - "timer", NULL); - - if (err) { - prom_printf("Serious problem, cannot register TICK_INT\n"); - prom_halt(); - } - - /* Guarentee that the following sequences execute - * uninterrupted. - */ - __asm__ __volatile__("rdpr %%pstate, %0\n\t" - "wrpr %0, %1, %%pstate" - : "=r" (pstate) - : "i" (PSTATE_IE)); - - /* Set things up so user can access tick register for profiling - * purposes. Also workaround BB_ERRATA_1 by doing a dummy - * read back of %tick after writing it. - */ - __asm__ __volatile__( - " sethi %%hi(0x80000000), %%g1\n" - " ba,pt %%xcc, 1f\n" - " sllx %%g1, 32, %%g1\n" - " .align 64\n" - "1: rd %%tick, %%g2\n" - " add %%g2, 6, %%g2\n" - " andn %%g2, %%g1, %%g2\n" - " wrpr %%g2, 0, %%tick\n" - " rdpr %%tick, %%g0" - : /* no outputs */ - : /* no inputs */ - : "g1", "g2"); - - /* Workaround for Spitfire Errata (#54 I think??), I discovered - * this via Sun BugID 4008234, mentioned in Solaris-2.5.1 patch - * number 103640. - * - * On Blackbird writes to %tick_cmpr can fail, the - * workaround seems to be to execute the wr instruction - * at the start of an I-cache line, and perform a dummy - * read back from %tick_cmpr right after writing to it. -DaveM - */ - if (!SPARC64_USE_STICK) { - __asm__ __volatile__( - " rd %%tick, %%g1\n" - " ba,pt %%xcc, 1f\n" - " add %%g1, %0, %%g1\n" - " .align 64\n" - "1: wr %%g1, 0x0, %%tick_cmpr\n" - " rd %%tick_cmpr, %%g0" - : /* no outputs */ - : "r" (timer_tick_offset) - : "g1"); - } else { - /* Let the user get at STICK too. */ - __asm__ __volatile__( - " sethi %%hi(0x80000000), %%g1\n" - " sllx %%g1, 32, %%g1\n" - " rd %%asr24, %%g2\n" - " andn %%g2, %%g1, %%g2\n" - " wr %%g2, 0, %%asr24" - : /* no outputs */ - : /* no inputs */ - : "g1", "g2"); - - __asm__ __volatile__( - " rd %%asr24, %%g1\n" - " add %%g1, %0, %%g1\n" - " wr %%g1, 0x0, %%asr25" - : /* no outputs */ - : "r" (timer_tick_offset) - : "g1"); - } - - /* Restore PSTATE_IE. */ - __asm__ __volatile__("wrpr %0, 0x0, %%pstate" - : /* no outputs */ - : "r" (pstate)); - - local_irq_enable(); } #ifdef CONFIG_SMP diff -Nru a/arch/sparc64/kernel/smp.c b/arch/sparc64/kernel/smp.c --- a/arch/sparc64/kernel/smp.c Sun Mar 23 00:22:49 2003 +++ b/arch/sparc64/kernel/smp.c Sun Mar 23 00:22:49 2003 @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -115,7 +116,6 @@ void __init smp_callin(void) { int cpuid = hard_smp_processor_id(); - unsigned long pstate; extern int bigkernel; extern unsigned long kern_locked_tte_data; @@ -133,50 +133,6 @@ cpu_probe(); - /* Guarentee that the following sequences execute - * uninterrupted. - */ - __asm__ __volatile__("rdpr %%pstate, %0\n\t" - "wrpr %0, %1, %%pstate" - : "=r" (pstate) - : "i" (PSTATE_IE)); - - /* Set things up so user can access tick register for profiling - * purposes. Also workaround BB_ERRATA_1 by doing a dummy - * read back of %tick after writing it. - */ - __asm__ __volatile__( - "sethi %%hi(0x80000000), %%g1\n\t" - "ba,pt %%xcc, 1f\n\t" - " sllx %%g1, 32, %%g1\n\t" - ".align 64\n" -"1: rd %%tick, %%g2\n\t" - "add %%g2, 6, %%g2\n\t" - "andn %%g2, %%g1, %%g2\n\t" - "wrpr %%g2, 0, %%tick\n\t" - "rdpr %%tick, %%g0" - : /* no outputs */ - : /* no inputs */ - : "g1", "g2"); - - if (SPARC64_USE_STICK) { - /* Let the user get at STICK too. */ - __asm__ __volatile__( - "sethi %%hi(0x80000000), %%g1\n\t" - "sllx %%g1, 32, %%g1\n\t" - "rd %%asr24, %%g2\n\t" - "andn %%g2, %%g1, %%g2\n\t" - "wr %%g2, 0, %%asr24" - : /* no outputs */ - : /* no inputs */ - : "g1", "g2"); - } - - /* Restore PSTATE_IE. */ - __asm__ __volatile__("wrpr %0, 0x0, %%pstate" - : /* no outputs */ - : "r" (pstate)); - smp_setup_percpu_timer(); local_irq_enable(); @@ -211,7 +167,7 @@ static unsigned long current_tick_offset; -/* This stick register synchronization scheme is taken entirely from +/* This tick register synchronization scheme is taken entirely from * the ia64 port, see arch/ia64/kernel/smpboot.c for details and credit. * * The only change I've made is to rework it so that the master @@ -227,16 +183,7 @@ static spinlock_t itc_sync_lock = SPIN_LOCK_UNLOCKED; static unsigned long go[SLAVE + 1]; -#define DEBUG_STICK_SYNC 0 - -static inline unsigned long get_stick(void) -{ - unsigned long val; - - __asm__ __volatile__("rd %%asr24, %0" - : "=r" (val)); - return val; -} +#define DEBUG_TICK_SYNC 0 static inline long get_delta (long *rt, long *master) { @@ -245,14 +192,14 @@ unsigned long i; for (i = 0; i < NUM_ITERS; i++) { - t0 = get_stick(); + t0 = tick_ops->get_tick(); go[MASTER] = 1; membar("#StoreLoad"); while (!(tm = go[SLAVE])) membar("#LoadLoad"); go[SLAVE] = 0; membar("#StoreStore"); - t1 = get_stick(); + t1 = tick_ops->get_tick(); if (t1 - t0 < best_t1 - best_t0) best_t0 = t0, best_t1 = t1, best_tm = tm; @@ -268,32 +215,11 @@ return tcenter - best_tm; } -static void adjust_stick(long adj) -{ - unsigned long tmp, pstate; - - __asm__ __volatile__( - "rdpr %%pstate, %0\n\t" - "ba,pt %%xcc, 1f\n\t" - " wrpr %0, %4, %%pstate\n\t" - ".align 16\n\t" - "1:nop\n\t" - "rd %%asr24, %1\n\t" - "add %1, %2, %1\n\t" - "wr %1, 0x0, %%asr24\n\t" - "add %1, %3, %1\n\t" - "wr %1, 0x0, %%asr25\n\t" - "wrpr %0, 0x0, %%pstate" - : "=&r" (pstate), "=&r" (tmp) - : "r" (adj), "r" (current_tick_offset), - "i" (PSTATE_IE)); -} - -void smp_synchronize_stick_client(void) +void smp_synchronize_tick_client(void) { long i, delta, adj, adjust_latency = 0, done = 0; unsigned long flags, rt, master_time_stamp, bound; -#if DEBUG_STICK_SYNC +#if DEBUG_TICK_SYNC struct { long rt; /* roundtrip time */ long master; /* master's timestamp */ @@ -323,9 +249,9 @@ } else adj = -delta; - adjust_stick(adj); + tick_ops->add_tick(adj, current_tick_offset); } -#if DEBUG_STICK_SYNC +#if DEBUG_TICK_SYNC t[i].rt = rt; t[i].master = master_time_stamp; t[i].diff = delta; @@ -335,25 +261,25 @@ } local_irq_restore(flags); -#if DEBUG_STICK_SYNC +#if DEBUG_TICK_SYNC for (i = 0; i < NUM_ROUNDS; i++) printk("rt=%5ld master=%5ld diff=%5ld adjlat=%5ld\n", t[i].rt, t[i].master, t[i].diff, t[i].lat); #endif - printk(KERN_INFO "CPU %d: synchronized STICK with master CPU (last diff %ld cycles," + printk(KERN_INFO "CPU %d: synchronized TICK with master CPU (last diff %ld cycles," "maxerr %lu cycles)\n", smp_processor_id(), delta, rt); } -static void smp_start_sync_stick_client(int cpu); +static void smp_start_sync_tick_client(int cpu); -static void smp_synchronize_one_stick(int cpu) +static void smp_synchronize_one_tick(int cpu) { unsigned long flags, i; go[MASTER] = 0; - smp_start_sync_stick_client(cpu); + smp_start_sync_tick_client(cpu); /* wait for client to be ready */ while (!go[MASTER]) @@ -370,7 +296,7 @@ membar("#LoadLoad"); go[MASTER] = 0; membar("#StoreStore"); - go[SLAVE] = get_stick(); + go[SLAVE] = tick_ops->get_tick(); membar("#StoreLoad"); } } @@ -638,11 +564,11 @@ /* NOTE: Caller runs local copy on master. */ } -extern unsigned long xcall_sync_stick; +extern unsigned long xcall_sync_tick; -static void smp_start_sync_stick_client(int cpu) +static void smp_start_sync_tick_client(int cpu) { - smp_cross_call_masked(&xcall_sync_stick, + smp_cross_call_masked(&xcall_sync_tick, 0, 0, 0, (1UL << cpu)); } @@ -1118,12 +1044,7 @@ * Check for level 14 softint. */ { - unsigned long tick_mask; - - if (SPARC64_USE_STICK) - tick_mask = (1UL << 16); - else - tick_mask = (1UL << 0); + unsigned long tick_mask = tick_ops->softint_mask; if (!(get_softint() & tick_mask)) { extern void handler_irq(int, struct pt_regs *); @@ -1159,47 +1080,14 @@ : "=r" (pstate) : "i" (PSTATE_IE)); - /* Workaround for Spitfire Errata (#54 I think??), I discovered - * this via Sun BugID 4008234, mentioned in Solaris-2.5.1 patch - * number 103640. - * - * On Blackbird writes to %tick_cmpr can fail, the - * workaround seems to be to execute the wr instruction - * at the start of an I-cache line, and perform a dummy - * read back from %tick_cmpr right after writing to it. -DaveM - * - * Just to be anal we add a workaround for Spitfire - * Errata 50 by preventing pipeline bypasses on the - * final read of the %tick register into a compare - * instruction. The Errata 50 description states - * that %tick is not prone to this bug, but I am not - * taking any chances. - */ - if (!SPARC64_USE_STICK) { - __asm__ __volatile__("rd %%tick_cmpr, %0\n\t" - "ba,pt %%xcc, 1f\n\t" - " add %0, %2, %0\n\t" - ".align 64\n" - "1: wr %0, 0x0, %%tick_cmpr\n\t" - "rd %%tick_cmpr, %%g0\n\t" - "rd %%tick, %1\n\t" - "mov %1, %1" - : "=&r" (compare), "=r" (tick) - : "r" (current_tick_offset)); - } else { - __asm__ __volatile__("rd %%asr25, %0\n\t" - "add %0, %2, %0\n\t" - "wr %0, 0x0, %%asr25\n\t" - "rd %%asr24, %1\n\t" - : "=&r" (compare), "=r" (tick) - : "r" (current_tick_offset)); - } + compare = tick_ops->add_compare(current_tick_offset); + tick = tick_ops->get_tick(); /* Restore PSTATE_IE. */ __asm__ __volatile__("wrpr %0, 0x0, %%pstate" : /* no outputs */ : "r" (pstate)); - } while (tick >= compare); + } while (time_after_eq(tick, compare)); } static void __init smp_setup_percpu_timer(void) @@ -1217,35 +1105,7 @@ : "=r" (pstate) : "i" (PSTATE_IE)); - /* Workaround for Spitfire Errata (#54 I think??), I discovered - * this via Sun BugID 4008234, mentioned in Solaris-2.5.1 patch - * number 103640. - * - * On Blackbird writes to %tick_cmpr can fail, the - * workaround seems to be to execute the wr instruction - * at the start of an I-cache line, and perform a dummy - * read back from %tick_cmpr right after writing to it. -DaveM - */ - if (!SPARC64_USE_STICK) { - __asm__ __volatile__( - "rd %%tick, %%g1\n\t" - "ba,pt %%xcc, 1f\n\t" - " add %%g1, %0, %%g1\n\t" - ".align 64\n" - "1: wr %%g1, 0x0, %%tick_cmpr\n\t" - "rd %%tick_cmpr, %%g0" - : /* no outputs */ - : "r" (current_tick_offset) - : "g1"); - } else { - __asm__ __volatile__( - "rd %%asr24, %%g1\n\t" - "add %%g1, %0, %%g1\n\t" - "wr %%g1, 0x0, %%asr25" - : /* no outputs */ - : "r" (current_tick_offset) - : "g1"); - } + tick_ops->init_tick(current_tick_offset); /* Restore PSTATE_IE. */ __asm__ __volatile__("wrpr %0, 0x0, %%pstate" @@ -1314,44 +1174,23 @@ p += (64 / sizeof(unsigned long))) *((volatile unsigned long *)p); - /* Now the real measurement. */ - if (!SPARC64_USE_STICK) { - __asm__ __volatile__("b,pt %%xcc, 1f\n\t" - " rd %%tick, %0\n\t" - ".align 64\n" - "1:\tldx [%2 + 0x000], %%g1\n\t" - "ldx [%2 + 0x040], %%g2\n\t" - "ldx [%2 + 0x080], %%g3\n\t" - "ldx [%2 + 0x0c0], %%g5\n\t" - "add %2, 0x100, %2\n\t" - "cmp %2, %4\n\t" - "bne,pt %%xcc, 1b\n\t" - " nop\n\t" - "rd %%tick, %1\n\t" - : "=&r" (tick1), "=&r" (tick2), - "=&r" (flush_base) - : "2" (flush_base), - "r" (flush_base + ecache_size) - : "g1", "g2", "g3", "g5"); - } else { - __asm__ __volatile__("b,pt %%xcc, 1f\n\t" - " rd %%asr24, %0\n\t" - ".align 64\n" - "1:\tldx [%2 + 0x000], %%g1\n\t" - "ldx [%2 + 0x040], %%g2\n\t" - "ldx [%2 + 0x080], %%g3\n\t" - "ldx [%2 + 0x0c0], %%g5\n\t" - "add %2, 0x100, %2\n\t" - "cmp %2, %4\n\t" + tick1 = tick_ops->get_tick(); + + __asm__ __volatile__("1:\n\t" + "ldx [%0 + 0x000], %%g1\n\t" + "ldx [%0 + 0x040], %%g2\n\t" + "ldx [%0 + 0x080], %%g3\n\t" + "ldx [%0 + 0x0c0], %%g5\n\t" + "add %0, 0x100, %0\n\t" + "cmp %0, %2\n\t" "bne,pt %%xcc, 1b\n\t" - " nop\n\t" - "rd %%asr24, %1\n\t" - : "=&r" (tick1), "=&r" (tick2), - "=&r" (flush_base) - : "2" (flush_base), + " nop" + : "=&r" (flush_base) + : "0" (flush_base), "r" (flush_base + ecache_size) : "g1", "g2", "g3", "g5"); - } + + tick2 = tick_ops->get_tick(); local_irq_restore(flags); @@ -1370,6 +1209,8 @@ report: /* Convert ticks/sticks to jiffies. */ cache_decay_ticks = cacheflush_time / timer_tick_offset; + if (cache_decay_ticks < 1) + cache_decay_ticks = 1; printk("Using heuristic of %ld cycles, %ld ticks.\n", cacheflush_time, cache_decay_ticks); @@ -1438,8 +1279,7 @@ if (!test_bit(cpu, &cpu_online_map)) { ret = -ENODEV; } else { - if (SPARC64_USE_STICK) - smp_synchronize_one_stick(cpu); + smp_synchronize_one_tick(cpu); } } return ret; diff -Nru a/arch/sparc64/kernel/sparc64_ksyms.c b/arch/sparc64/kernel/sparc64_ksyms.c --- a/arch/sparc64/kernel/sparc64_ksyms.c Sun Mar 23 00:22:55 2003 +++ b/arch/sparc64/kernel/sparc64_ksyms.c Sun Mar 23 00:22:55 2003 @@ -128,20 +128,13 @@ #endif /* Hard IRQ locking */ -#ifdef CONFIG_SMP EXPORT_SYMBOL(synchronize_irq); -#endif #if defined(CONFIG_MCOUNT) extern void mcount(void); EXPORT_SYMBOL_NOVERS(mcount); #endif -/* Uniprocessor clock frequency */ -#ifndef CONFIG_SMP -EXPORT_SYMBOL(up_clock_tick); -#endif - /* Per-CPU information table */ EXPORT_SYMBOL(cpu_data); @@ -162,10 +155,13 @@ EXPORT_SYMBOL(_do_write_unlock); #endif -#ifdef CONFIG_SMP EXPORT_SYMBOL(smp_call_function); -#endif +#endif /* CONFIG_SMP */ +/* Uniprocessor clock frequency */ +#ifndef CONFIG_SMP +extern unsigned long up_clock_tick; +EXPORT_SYMBOL(up_clock_tick); #endif /* semaphores */ diff -Nru a/arch/sparc64/kernel/time.c b/arch/sparc64/kernel/time.c --- a/arch/sparc64/kernel/time.c Sun Mar 23 00:22:53 2003 +++ b/arch/sparc64/kernel/time.c Sun Mar 23 00:22:53 2003 @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -37,6 +38,7 @@ #include #include #include +#include spinlock_t mostek_lock = SPIN_LOCK_UNLOCKED; spinlock_t rtc_lock = SPIN_LOCK_UNLOCKED; @@ -54,6 +56,352 @@ static int set_rtc_mmss(unsigned long); +struct sparc64_tick_ops *tick_ops; + +#define TICK_PRIV_BIT (1UL << 63) + +static void tick_disable_protection(void) +{ + /* Set things up so user can access tick register for profiling + * purposes. Also workaround BB_ERRATA_1 by doing a dummy + * read back of %tick after writing it. + */ + __asm__ __volatile__( + " ba,pt %%xcc, 1f\n" + " nop\n" + " .align 64\n" + "1: rd %%tick, %%g2\n" + " add %%g2, 6, %%g2\n" + " andn %%g2, %0, %%g2\n" + " wrpr %%g2, 0, %%tick\n" + " rdpr %%tick, %%g0" + : /* no outputs */ + : "r" (TICK_PRIV_BIT) + : "g2"); +} + +static void tick_init_tick(unsigned long offset) +{ + tick_disable_protection(); + + __asm__ __volatile__( + " rd %%tick, %%g1\n" + " andn %%g1, %1, %%g1\n" + " ba,pt %%xcc, 1f\n" + " add %%g1, %0, %%g1\n" + " .align 64\n" + "1: wr %%g1, 0x0, %%tick_cmpr\n" + " rd %%tick_cmpr, %%g0" + : /* no outputs */ + : "r" (offset), "r" (TICK_PRIV_BIT) + : "g1"); +} + +static unsigned long tick_get_tick(void) +{ + unsigned long ret; + + __asm__ __volatile__("rd %%tick, %0\n\t" + "mov %0, %0" + : "=r" (ret)); + + return ret & ~TICK_PRIV_BIT; +} + +static unsigned long tick_get_compare(void) +{ + unsigned long ret; + + __asm__ __volatile__("rd %%tick_cmpr, %0\n\t" + "mov %0, %0" + : "=r" (ret)); + + return ret; +} + +static unsigned long tick_add_compare(unsigned long adj) +{ + unsigned long new_compare; + + /* Workaround for Spitfire Errata (#54 I think??), I discovered + * this via Sun BugID 4008234, mentioned in Solaris-2.5.1 patch + * number 103640. + * + * On Blackbird writes to %tick_cmpr can fail, the + * workaround seems to be to execute the wr instruction + * at the start of an I-cache line, and perform a dummy + * read back from %tick_cmpr right after writing to it. -DaveM + */ + __asm__ __volatile__("rd %%tick_cmpr, %0\n\t" + "ba,pt %%xcc, 1f\n\t" + " add %0, %1, %0\n\t" + ".align 64\n" + "1:\n\t" + "wr %0, 0, %%tick_cmpr\n\t" + "rd %%tick_cmpr, %%g0" + : "=&r" (new_compare) + : "r" (adj)); + + return new_compare; +} + +static unsigned long tick_add_tick(unsigned long adj, unsigned long offset) +{ + unsigned long new_tick, tmp; + + /* Also need to handle Blackbird bug here too. */ + __asm__ __volatile__("rd %%tick, %0\n\t" + "add %0, %2, %0\n\t" + "wrpr %0, 0, %%tick\n\t" + "andn %0, %4, %1\n\t" + "ba,pt %%xcc, 1f\n\t" + " add %1, %3, %1\n\t" + ".align 64\n" + "1:\n\t" + "wr %1, 0, %%tick_cmpr\n\t" + "rd %%tick_cmpr, %%g0" + : "=&r" (new_tick), "=&r" (tmp) + : "r" (adj), "r" (offset), "r" (TICK_PRIV_BIT)); + + return new_tick; +} + +static struct sparc64_tick_ops tick_operations = { + .init_tick = tick_init_tick, + .get_tick = tick_get_tick, + .get_compare = tick_get_compare, + .add_tick = tick_add_tick, + .add_compare = tick_add_compare, + .softint_mask = 1UL << 0, +}; + +static void stick_init_tick(unsigned long offset) +{ + tick_disable_protection(); + + /* Let the user get at STICK too. */ + __asm__ __volatile__( + " rd %%asr24, %%g2\n" + " andn %%g2, %0, %%g2\n" + " wr %%g2, 0, %%asr24" + : /* no outputs */ + : "r" (TICK_PRIV_BIT) + : "g1", "g2"); + + __asm__ __volatile__( + " rd %%asr24, %%g1\n" + " andn %%g1, %1, %%g1\n" + " add %%g1, %0, %%g1\n" + " wr %%g1, 0x0, %%asr25" + : /* no outputs */ + : "r" (offset), "r" (TICK_PRIV_BIT) + : "g1"); +} + +static unsigned long stick_get_tick(void) +{ + unsigned long ret; + + __asm__ __volatile__("rd %%asr24, %0" + : "=r" (ret)); + + return ret & ~TICK_PRIV_BIT; +} + +static unsigned long stick_get_compare(void) +{ + unsigned long ret; + + __asm__ __volatile__("rd %%asr25, %0" + : "=r" (ret)); + + return ret; +} + +static unsigned long stick_add_tick(unsigned long adj, unsigned long offset) +{ + unsigned long new_tick, tmp; + + __asm__ __volatile__("rd %%asr24, %0\n\t" + "add %0, %2, %0\n\t" + "wr %0, 0, %%asr24\n\t" + "andn %0, %4, %1\n\t" + "add %1, %3, %1\n\t" + "wr %1, 0, %%asr25" + : "=&r" (new_tick), "=&r" (tmp) + : "r" (adj), "r" (offset), "r" (TICK_PRIV_BIT)); + + return new_tick; +} + +static unsigned long stick_add_compare(unsigned long adj) +{ + unsigned long new_compare; + + __asm__ __volatile__("rd %%asr25, %0\n\t" + "add %0, %1, %0\n\t" + "wr %0, 0, %%asr25" + : "=&r" (new_compare) + : "r" (adj)); + + return new_compare; +} + +static struct sparc64_tick_ops stick_operations = { + .init_tick = stick_init_tick, + .get_tick = stick_get_tick, + .get_compare = stick_get_compare, + .add_tick = stick_add_tick, + .add_compare = stick_add_compare, + .softint_mask = 1UL << 16, +}; + +/* On Hummingbird the STICK/STICK_CMPR register is implemented + * in I/O space. There are two 64-bit registers each, the + * first holds the low 32-bits of the value and the second holds + * the high 32-bits. + * + * Since STICK is constantly updating, we have to access it carefully. + * + * The sequence we use to read is: + * 1) read low + * 2) read high + * 3) read low again, if it rolled over increment high by 1 + * + * Writing STICK safely is also tricky: + * 1) write low to zero + * 2) write high + * 3) write low + */ +#define HBIRD_STICKCMP_ADDR 0x1fe0000f060UL +#define HBIRD_STICK_ADDR 0x1fe0000f070UL + +static unsigned long __hbird_read_stick(void) +{ + unsigned long ret, tmp1, tmp2, tmp3; + unsigned long addr = HBIRD_STICK_ADDR; + + __asm__ __volatile__("ldxa [%1] %5, %2\n\t" + "add %1, 0x8, %1\n\t" + "ldxa [%1] %5, %3\n\t" + "sub %1, 0x8, %1\n\t" + "ldxa [%1] %5, %4\n\t" + "cmp %4, %2\n\t" + "blu,a,pn %%xcc, 1f\n\t" + " add %3, 1, %3\n" + "1:\n\t" + "sllx %3, 32, %3\n\t" + "or %3, %4, %0\n\t" + : "=&r" (ret), "=&r" (addr), + "=&r" (tmp1), "=&r" (tmp2), "=&r" (tmp3) + : "i" (ASI_PHYS_BYPASS_EC_E), "1" (addr)); + + return ret; +} + +static unsigned long __hbird_read_compare(void) +{ + unsigned long low, high; + unsigned long addr = HBIRD_STICKCMP_ADDR; + + __asm__ __volatile__("ldxa [%2] %3, %0\n\t" + "add %2, 0x8, %2\n\t" + "ldxa [%2] %3, %1" + : "=&r" (low), "=&r" (high), "=&r" (addr) + : "i" (ASI_PHYS_BYPASS_EC_E), "2" (addr)); + + return (high << 32UL) | low; +} + +static void __hbird_write_stick(unsigned long val) +{ + unsigned long low = (val & 0xffffffffUL); + unsigned long high = (val >> 32UL); + unsigned long addr = HBIRD_STICK_ADDR; + + __asm__ __volatile__("stxa %%g0, [%0] %4\n\t" + "add %0, 0x8, %0\n\t" + "stxa %3, [%0] %4\n\t" + "sub %0, 0x8, %0\n\t" + "stxa %2, [%0] %4" + : "=&r" (addr) + : "0" (addr), "r" (low), "r" (high), + "i" (ASI_PHYS_BYPASS_EC_E)); +} + +static void __hbird_write_compare(unsigned long val) +{ + unsigned long low = (val & 0xffffffffUL); + unsigned long high = (val >> 32UL); + unsigned long addr = HBIRD_STICKCMP_ADDR + 0x8UL; + + __asm__ __volatile__("stxa %3, [%0] %4\n\t" + "sub %0, 0x8, %0\n\t" + "stxa %2, [%0] %4" + : "=&r" (addr) + : "0" (addr), "r" (low), "r" (high), + "i" (ASI_PHYS_BYPASS_EC_E)); +} + +static void hbtick_init_tick(unsigned long offset) +{ + unsigned long val; + + tick_disable_protection(); + + /* XXX This seems to be necessary to 'jumpstart' Hummingbird + * XXX into actually sending STICK interrupts. I think because + * XXX of how we store %tick_cmpr in head.S this somehow resets the + * XXX {TICK + STICK} interrupt mux. -DaveM + */ + __hbird_write_stick(__hbird_read_stick()); + + val = __hbird_read_stick() & ~TICK_PRIV_BIT; + __hbird_write_compare(val + offset); +} + +static unsigned long hbtick_get_tick(void) +{ + return __hbird_read_stick() & ~TICK_PRIV_BIT; +} + +static unsigned long hbtick_get_compare(void) +{ + return __hbird_read_compare(); +} + +static unsigned long hbtick_add_tick(unsigned long adj, unsigned long offset) +{ + unsigned long val; + + val = __hbird_read_stick() + adj; + __hbird_write_stick(val); + + val &= ~TICK_PRIV_BIT; + __hbird_write_compare(val + offset); + + return val; +} + +static unsigned long hbtick_add_compare(unsigned long adj) +{ + unsigned long val = __hbird_read_compare() + adj; + + val &= ~TICK_PRIV_BIT; + __hbird_write_compare(val); + + return val; +} + +static struct sparc64_tick_ops hbtick_operations = { + .init_tick = hbtick_init_tick, + .get_tick = hbtick_get_tick, + .get_compare = hbtick_get_compare, + .add_tick = hbtick_add_tick, + .add_compare = hbtick_add_compare, + .softint_mask = 1UL << 0, +}; + /* timer_interrupt() needs to keep up the real-time clock, * as well as call the "do_timer()" routine every clocktick * @@ -62,7 +410,8 @@ */ unsigned long timer_tick_offset; unsigned long timer_tick_compare; -unsigned long timer_ticks_per_usec_quotient; + +static unsigned long timer_ticks_per_usec_quotient; #define TICK_SIZE (tick_nsec / 1000) @@ -146,49 +495,14 @@ : "=r" (pstate) : "i" (PSTATE_IE)); - /* Workaround for Spitfire Errata (#54 I think??), I discovered - * this via Sun BugID 4008234, mentioned in Solaris-2.5.1 patch - * number 103640. - * - * On Blackbird writes to %tick_cmpr can fail, the - * workaround seems to be to execute the wr instruction - * at the start of an I-cache line, and perform a dummy - * read back from %tick_cmpr right after writing to it. -DaveM - * - * Just to be anal we add a workaround for Spitfire - * Errata 50 by preventing pipeline bypasses on the - * final read of the %tick register into a compare - * instruction. The Errata 50 description states - * that %tick is not prone to this bug, but I am not - * taking any chances. - */ - if (!SPARC64_USE_STICK) { - __asm__ __volatile__( - " rd %%tick_cmpr, %0\n" - " ba,pt %%xcc, 1f\n" - " add %0, %2, %0\n" - " .align 64\n" - "1: wr %0, 0, %%tick_cmpr\n" - " rd %%tick_cmpr, %%g0\n" - " rd %%tick, %1\n" - " mov %1, %1" - : "=&r" (timer_tick_compare), "=r" (ticks) - : "r" (timer_tick_offset)); - } else { - __asm__ __volatile__( - " rd %%asr25, %0\n" - " add %0, %2, %0\n" - " wr %0, 0, %%asr25\n" - " rd %%asr24, %1" - : "=&r" (timer_tick_compare), "=r" (ticks) - : "r" (timer_tick_offset)); - } + timer_tick_compare = tick_ops->add_compare(timer_tick_offset); + ticks = tick_ops->get_tick(); /* Restore PSTATE_IE. */ __asm__ __volatile__("wrpr %0, 0x0, %%pstate" : /* no outputs */ : "r" (pstate)); - } while (ticks >= timer_tick_compare); + } while (time_after_eq(ticks, timer_tick_compare)); timer_check_rtc(); @@ -205,19 +519,7 @@ /* * Only keep timer_tick_offset uptodate, but don't set TICK_CMPR. */ - if (!SPARC64_USE_STICK) { - __asm__ __volatile__( - " rd %%tick_cmpr, %0\n" - " add %0, %1, %0" - : "=&r" (timer_tick_compare) - : "r" (timer_tick_offset)); - } else { - __asm__ __volatile__( - " rd %%asr25, %0\n" - " add %0, %1, %0" - : "=&r" (timer_tick_compare) - : "r" (timer_tick_offset)); - } + timer_tick_compare = tick_ops->get_compare() + timer_tick_offset; timer_check_rtc(); @@ -620,40 +922,90 @@ local_irq_restore(flags); } -void __init time_init(void) +/* This is gets the master TICK_INT timer going. */ +static unsigned long sparc64_init_timers(void (*cfunc)(int, void *, struct pt_regs *)) { - /* clock_probe() is now done at end of [se]bus_init on sparc64 - * so that sbus, fhc and ebus bus information is probed and - * available. + unsigned long pstate, clock; + int node, err; +#ifdef CONFIG_SMP + extern void smp_tick_init(void); +#endif + + if (tlb_type == spitfire) { + unsigned long ver, manuf, impl; + + __asm__ __volatile__ ("rdpr %%ver, %0" + : "=&r" (ver)); + manuf = ((ver >> 48) & 0xffff); + impl = ((ver >> 32) & 0xffff); + if (manuf == 0x17 && impl == 0x13) { + /* Hummingbird, aka Ultra-IIe */ + tick_ops = &hbtick_operations; + node = prom_root_node; + clock = prom_getint(node, "stick-frequency"); + } else { + tick_ops = &tick_operations; + node = linux_cpus[0].prom_node; + clock = prom_getint(node, "clock-frequency"); + } + } else { + tick_ops = &stick_operations; + node = prom_root_node; + clock = prom_getint(node, "stick-frequency"); + } + timer_tick_offset = clock / HZ; + +#ifdef CONFIG_SMP + smp_tick_init(); +#endif + + /* Register IRQ handler. */ + err = request_irq(build_irq(0, 0, 0UL, 0UL), cfunc, SA_STATIC_ALLOC, + "timer", NULL); + + if (err) { + prom_printf("Serious problem, cannot register TICK_INT\n"); + prom_halt(); + } + + /* Guarentee that the following sequences execute + * uninterrupted. */ - unsigned long clock; + __asm__ __volatile__("rdpr %%pstate, %0\n\t" + "wrpr %0, %1, %%pstate" + : "=r" (pstate) + : "i" (PSTATE_IE)); + + tick_ops->init_tick(timer_tick_offset); + + /* Restore PSTATE_IE. */ + __asm__ __volatile__("wrpr %0, 0x0, %%pstate" + : /* no outputs */ + : "r" (pstate)); + + local_irq_enable(); - sparc64_init_timers(timer_interrupt, &clock); - timer_ticks_per_usec_quotient = ((1UL<<32) / (clock / 1000020)); + return clock; +} + +/* The quotient formula is taken from the IA64 port. */ +void __init time_init(void) +{ + unsigned long clock = sparc64_init_timers(timer_interrupt); + + timer_ticks_per_usec_quotient = + (((1000000UL << 30) + + (clock / 2)) / clock); } static __inline__ unsigned long do_gettimeoffset(void) { - unsigned long ticks; + unsigned long ticks = tick_ops->get_tick(); - if (!SPARC64_USE_STICK) { - __asm__ __volatile__( - " rd %%tick, %%g1\n" - " add %1, %%g1, %0\n" - " sub %0, %2, %0\n" - : "=r" (ticks) - : "r" (timer_tick_offset), "r" (timer_tick_compare) - : "g1", "g2"); - } else { - __asm__ __volatile__("rd %%asr24, %%g1\n\t" - "add %1, %%g1, %0\n\t" - "sub %0, %2, %0\n\t" - : "=&r" (ticks) - : "r" (timer_tick_offset), "r" (timer_tick_compare) - : "g1"); - } + ticks += timer_tick_offset; + ticks -= timer_tick_compare; - return (ticks * timer_ticks_per_usec_quotient) >> 32UL; + return (ticks * timer_ticks_per_usec_quotient) >> 30UL; } void do_settimeofday(struct timeval *tv) diff -Nru a/arch/sparc64/kernel/trampoline.S b/arch/sparc64/kernel/trampoline.S --- a/arch/sparc64/kernel/trampoline.S Sun Mar 23 00:22:52 2003 +++ b/arch/sparc64/kernel/trampoline.S Sun Mar 23 00:22:52 2003 @@ -85,7 +85,10 @@ startup_continue: wrpr %g0, 15, %pil - wr %g0, 0, %tick_cmpr + + sethi %hi(0x80000000), %g2 + sllx %g2, 32, %g2 + wr %g2, 0, %tick_cmpr /* Call OBP by hand to lock KERNBASE into i/d tlbs. */ mov %o0, %l0 diff -Nru a/arch/sparc64/kernel/traps.c b/arch/sparc64/kernel/traps.c --- a/arch/sparc64/kernel/traps.c Sun Mar 23 00:22:56 2003 +++ b/arch/sparc64/kernel/traps.c Sun Mar 23 00:22:56 2003 @@ -33,6 +33,7 @@ #include #include #include +#include #ifdef CONFIG_KMOD #include #endif @@ -588,7 +589,7 @@ flush_linesize = ecache_flush_linesize; flush_size = ecache_flush_size >> 1; - __asm__ __volatile__("rd %%tick, %0" : "=r" (tick1)); + tick1 = tick_ops->get_tick(); __asm__ __volatile__("1: subcc %0, %4, %0\n\t" " bne,pt %%xcc, 1b\n\t" @@ -597,7 +598,7 @@ : "0" (flush_size), "r" (flush_base), "i" (ASI_PHYS_USE_EC), "r" (flush_linesize)); - __asm__ __volatile__("rd %%tick, %0" : "=r" (tick2)); + tick2 = tick_ops->get_tick(); raw = (tick2 - tick1); @@ -1598,6 +1599,7 @@ void die_if_kernel(char *str, struct pt_regs *regs) { + static int die_counter; extern void __show_regs(struct pt_regs * regs); extern void smp_report_regs(void); int count = 0; @@ -1610,7 +1612,7 @@ " /_| \\__/ |_\\\n" " \\__U_/\n"); - printk("%s(%d): %s\n", current->comm, current->pid, str); + printk("%s(%d): %s [#%d]\n", current->comm, current->pid, str, ++die_counter); __asm__ __volatile__("flushw"); __show_regs(regs); if (regs->tstate & TSTATE_PRIV) { diff -Nru a/arch/sparc64/mm/ultra.S b/arch/sparc64/mm/ultra.S --- a/arch/sparc64/mm/ultra.S Sun Mar 23 00:22:54 2003 +++ b/arch/sparc64/mm/ultra.S Sun Mar 23 00:22:54 2003 @@ -560,8 +560,8 @@ /* This runs in a very controlled environment, so we do * not need to worry about BH races etc. */ - .globl xcall_sync_stick -xcall_sync_stick: + .globl xcall_sync_tick +xcall_sync_tick: rdpr %pstate, %g2 wrpr %g2, PSTATE_IG | PSTATE_AG, %pstate rdpr %pil, %g2 @@ -569,7 +569,7 @@ sethi %hi(109f), %g7 b,pt %xcc, etrap_irq 109: or %g7, %lo(109b), %g7 - call smp_synchronize_stick_client + call smp_synchronize_tick_client nop clr %l6 b rtrap_xcall diff -Nru a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c --- a/arch/um/drivers/ubd_kern.c Sun Mar 23 00:22:53 2003 +++ b/arch/um/drivers/ubd_kern.c Sun Mar 23 00:22:53 2003 @@ -507,7 +507,7 @@ /* /dev/ubd/N style names */ sprintf(devfs_name, "%d", unit); *handle_out = devfs_register(dir_handle, devfs_name, - DEVFS_FL_REMOVABLE, major, minor, + 0, major, minor, S_IFBLK | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP, &ubd_blops, NULL); disk->private_data = &ubd_dev[unit]; diff -Nru a/arch/x86_64/ia32/ia32_binfmt.c b/arch/x86_64/ia32/ia32_binfmt.c --- a/arch/x86_64/ia32/ia32_binfmt.c Sun Mar 23 00:22:50 2003 +++ b/arch/x86_64/ia32/ia32_binfmt.c Sun Mar 23 00:22:50 2003 @@ -217,7 +217,7 @@ # define CONFIG_BINFMT_ELF_MODULE CONFIG_BINFMT_ELF32_MODULE #endif -#define ELF_PLAT_INIT(r) elf32_init(r) +#define ELF_PLAT_INIT(r, load_addr) elf32_init(r) #define setup_arg_pages(bprm) ia32_setup_arg_pages(bprm) int ia32_setup_arg_pages(struct linux_binprm *bprm); diff -Nru a/arch/x86_64/ia32/sys_ia32.c b/arch/x86_64/ia32/sys_ia32.c --- a/arch/x86_64/ia32/sys_ia32.c Sun Mar 23 00:22:52 2003 +++ b/arch/x86_64/ia32/sys_ia32.c Sun Mar 23 00:22:52 2003 @@ -2071,8 +2071,8 @@ return -ENOSYS ; } -int sys_sched_getaffinity(pid_t pid, unsigned int len, unsigned long *new_mask_ptr); -int sys_sched_setaffinity(pid_t pid, unsigned int len, unsigned long *new_mask_ptr); +long sys_sched_getaffinity(pid_t pid, unsigned int len, unsigned long *new_mask_ptr); +long sys_sched_setaffinity(pid_t pid, unsigned int len, unsigned long *new_mask_ptr); /* only works on LE */ long sys32_sched_setaffinity(pid_t pid, unsigned int len, diff -Nru a/arch/x86_64/kernel/irq.c b/arch/x86_64/kernel/irq.c --- a/arch/x86_64/kernel/irq.c Sun Mar 23 00:22:52 2003 +++ b/arch/x86_64/kernel/irq.c Sun Mar 23 00:22:52 2003 @@ -732,6 +732,9 @@ struct irqaction *old, **p; irq_desc_t *desc = irq_desc + irq; + if (desc->handler == &no_irq_type) + return -ENOSYS; + /* * Some drivers like serial.c use request_irq() heavily, * so we have to be careful not to interfere with a diff -Nru a/arch/x86_64/kernel/traps.c b/arch/x86_64/kernel/traps.c --- a/arch/x86_64/kernel/traps.c Sun Mar 23 00:22:49 2003 +++ b/arch/x86_64/kernel/traps.c Sun Mar 23 00:22:49 2003 @@ -325,11 +325,12 @@ { int cpu; struct die_args args = { regs, str, err }; + static int die_counter; console_verbose(); notifier_call_chain(&die_chain, DIE_DIE, &args); bust_spinlocks(1); handle_BUG(regs); - printk("%s: %04lx\n", str, err & 0xffff); + printk("%s: %04lx [#%d]\n", str, err & 0xffff, ++die_counter); cpu = safe_smp_processor_id(); /* racy, but better than risking deadlock. */ local_irq_disable(); diff -Nru a/drivers/acorn/scsi/acornscsi.c b/drivers/acorn/scsi/acornscsi.c --- a/drivers/acorn/scsi/acornscsi.c Sun Mar 23 00:22:53 2003 +++ b/drivers/acorn/scsi/acornscsi.c Sun Mar 23 00:22:53 2003 @@ -2521,19 +2521,19 @@ */ int acornscsi_queuecmd(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)) { - AS_Host *host = (AS_Host *)SCpnt->host->hostdata; + AS_Host *host = (AS_Host *)SCpnt->device->host->hostdata; if (!done) { /* there should be some way of rejecting errors like this without panicing... */ panic("scsi%d: queuecommand called with NULL done function [cmd=%p]", - SCpnt->host->host_no, SCpnt); + host->host->host_no, SCpnt); return -EINVAL; } #if (DEBUG & DEBUG_NO_WRITE) if (acornscsi_cmdtype(SCpnt->cmnd[0]) == CMD_WRITE && (NO_WRITE & (1 << SCpnt->device->id))) { printk(KERN_CRIT "scsi%d.%c: WRITE attempted with NO_WRITE flag set\n", - SCpnt->host->host_no, '0' + SCpnt->device->id); + host->host->host_no, '0' + SCpnt->device->id); SCpnt->result = DID_NO_CONNECT << 16; done(SCpnt); return 0; @@ -2695,7 +2695,7 @@ */ int acornscsi_abort(Scsi_Cmnd *SCpnt) { - AS_Host *host = (AS_Host *) SCpnt->host->hostdata; + AS_Host *host = (AS_Host *) SCpnt->device->host->hostdata; int result; host->stats.aborts += 1; @@ -2782,7 +2782,7 @@ */ int acornscsi_reset(Scsi_Cmnd *SCpnt, unsigned int reset_flags) { - AS_Host *host = (AS_Host *)SCpnt->host->hostdata; + AS_Host *host = (AS_Host *)SCpnt->device->host->hostdata; Scsi_Cmnd *SCptr; host->stats.resets += 1; diff -Nru a/drivers/acorn/scsi/scsi.h b/drivers/acorn/scsi/scsi.h --- a/drivers/acorn/scsi/scsi.h Sun Mar 23 00:22:50 2003 +++ b/drivers/acorn/scsi/scsi.h Sun Mar 23 00:22:50 2003 @@ -68,8 +68,7 @@ static inline void init_SCp(Scsi_Cmnd *SCpnt) { - SCpnt->SCp.Message = 0; - SCpnt->SCp.Status = 0; + memset(&SCpnt->SCp, 0, sizeof(struct scsi_pointer)); if (SCpnt->use_sg) { unsigned long len = 0; @@ -97,8 +96,6 @@ SCpnt->request_bufflen = len; #endif } else { - SCpnt->SCp.buffer = NULL; - SCpnt->SCp.buffers_residual = 0; SCpnt->SCp.ptr = (unsigned char *)SCpnt->request_buffer; SCpnt->SCp.this_residual = SCpnt->request_bufflen; } diff -Nru a/drivers/acpi/processor.c b/drivers/acpi/processor.c --- a/drivers/acpi/processor.c Sun Mar 23 00:22:54 2003 +++ b/drivers/acpi/processor.c Sun Mar 23 00:22:54 2003 @@ -1356,7 +1356,8 @@ loff_t *data) { int result = 0; - struct acpi_processor *pr = (struct acpi_processor *) data; + struct seq_file *m = (struct seq_file *)file->private_data; + struct acpi_processor *pr = (struct acpi_processor *)m->private; char state_string[12] = {'\0'}; ACPI_FUNCTION_TRACE("acpi_processor_write_throttling"); @@ -1418,7 +1419,8 @@ loff_t *data) { int result = 0; - struct acpi_processor *pr = (struct acpi_processor *) data; + struct seq_file *m = (struct seq_file *)file->private_data; + struct acpi_processor *pr = (struct acpi_processor *)m->private; char limit_string[25] = {'\0'}; int px = 0; int tx = 0; diff -Nru a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c --- a/drivers/atm/idt77252.c Sun Mar 23 00:22:53 2003 +++ b/drivers/atm/idt77252.c Sun Mar 23 00:22:53 2003 @@ -730,7 +730,7 @@ struct atm_vcc *vcc = vc->tx_vcc; vc->estimator->cells += (skb->len + 47) / 48; - if (atomic_read(&vcc->tx_inuse) > (vcc->sk->sndbuf >> 1)) { + if (atomic_read(&vcc->sk->wmem_alloc) > (vcc->sk->sndbuf >> 1)) { u32 cps = vc->estimator->maxcps; vc->estimator->cps = cps; @@ -2025,7 +2025,7 @@ atomic_inc(&vcc->stats->tx_err); return -ENOMEM; } - atomic_add(skb->truesize + ATM_PDU_OVHD, &vcc->tx_inuse); + atomic_add(skb->truesize + ATM_PDU_OVHD, &vcc->sk->wmem_alloc); ATM_SKB(skb)->iovcnt = 0; memcpy(skb_put(skb, 52), cell, 52); diff -Nru a/drivers/block/amiflop.c b/drivers/block/amiflop.c --- a/drivers/block/amiflop.c Sun Mar 23 00:22:53 2003 +++ b/drivers/block/amiflop.c Sun Mar 23 00:22:53 2003 @@ -353,10 +353,8 @@ unit[nr].motor = 1; fd_select(nr); - del_timer(&motor_on_timer); motor_on_timer.data = nr; - motor_on_timer.expires = jiffies + HZ/2; - add_timer(&motor_on_timer); + mod_timer(&motor_on_timer, jiffies + HZ/2); on_attempts = 10; sleep_on (&motor_wait); @@ -414,11 +412,9 @@ int drive; drive = nr & 3; - del_timer(motor_off_timer + drive); - motor_off_timer[drive].expires = jiffies + 3*HZ; /* called this way it is always from interrupt */ motor_off_timer[drive].data = nr | 0x80000000; - add_timer(motor_off_timer + nr); + mod_timer(motor_off_timer + drive, jiffies + 3*HZ); } static int fd_calibrate(int drive) @@ -1429,10 +1425,7 @@ floppy->dirty = 1; /* reset the timer */ - del_timer (flush_track_timer + drive); - - flush_track_timer[drive].expires = jiffies + 1; - add_timer (flush_track_timer + drive); + mod_timer (flush_track_timer + drive, jiffies + 1); local_irq_restore(flags); break; } diff -Nru a/drivers/block/cciss.c b/drivers/block/cciss.c --- a/drivers/block/cciss.c Sun Mar 23 00:22:56 2003 +++ b/drivers/block/cciss.c Sun Mar 23 00:22:56 2003 @@ -2623,12 +2623,8 @@ { printk(KERN_INFO DRIVER_NAME "\n"); - /* Register for out PCI devices */ - if (pci_register_driver(&cciss_pci_driver) > 0 ) - return 0; - else - return -ENODEV; - + /* Register for our PCI devices */ + return pci_register_driver(&cciss_pci_driver); } static int __init init_cciss_module(void) diff -Nru a/drivers/block/floppy.c b/drivers/block/floppy.c --- a/drivers/block/floppy.c Sun Mar 23 00:22:50 2003 +++ b/drivers/block/floppy.c Sun Mar 23 00:22:50 2003 @@ -3649,6 +3649,8 @@ name = default_drive_params[type].name; allowed_drive_mask |= 1 << drive; } + else + allowed_drive_mask &= ~(1 << drive); } else { params = &default_drive_params[0].params; sprintf(temparea, "unknown type %d (usb?)", type); diff -Nru a/drivers/block/genhd.c b/drivers/block/genhd.c --- a/drivers/block/genhd.c Sun Mar 23 00:22:53 2003 +++ b/drivers/block/genhd.c Sun Mar 23 00:22:53 2003 @@ -18,13 +18,19 @@ static struct subsystem block_subsys; -/* Can be merged with blk_probe or deleted altogether. Later. */ +/* + * Can be merged with blk_probe or deleted altogether. Later. + * + * Modified under both block_subsys.rwsem and major_names_lock. + */ static struct blk_major_name { struct blk_major_name *next; int major; char name[16]; } *major_names[MAX_PROBE_HASH]; +static spinlock_t major_names_lock = SPIN_LOCK_UNLOCKED; + static struct blk_probe { struct blk_probe *next; dev_t dev; @@ -46,23 +52,26 @@ return major_to_index(MAJOR(dev)); } -const char *__bdevname(dev_t dev) +/* + * __bdevname may be called from interrupts, and must be atomic + */ +const char *__bdevname(dev_t dev, char *buffer) { - static char buffer[40]; char *name = "unknown-block"; unsigned int major = MAJOR(dev); unsigned int minor = MINOR(dev); int index = major_to_index(major); struct blk_major_name *n; + unsigned long flags; - down_read(&block_subsys.rwsem); + spin_lock_irqsave(&major_names_lock, flags); for (n = major_names[index]; n; n = n->next) if (n->major == major) break; if (n) name = &(n->name[0]); - sprintf(buffer, "%s(%u,%u)", name, major, minor); - up_read(&block_subsys.rwsem); + snprintf(buffer, BDEVNAME_SIZE, "%s(%u,%u)", name, major, minor); + spin_unlock_irqrestore(&major_names_lock, flags); return buffer; } @@ -90,26 +99,32 @@ { struct blk_major_name **n, *p; int index, ret = 0; + unsigned long flags; + + down_write(&block_subsys.rwsem); /* temporary */ if (major == 0) { - down_read(&block_subsys.rwsem); - for (index = ARRAY_SIZE(major_names)-1; index > 0; index--) + for (index = ARRAY_SIZE(major_names)-1; index > 0; index--) { if (major_names[index] == NULL) break; - up_read(&block_subsys.rwsem); + } if (index == 0) { printk("register_blkdev: failed to get major for %s\n", name); - return -EBUSY; + ret = -EBUSY; + goto out; } - ret = major = index; + major = index; + ret = major; } p = kmalloc(sizeof(struct blk_major_name), GFP_KERNEL); - if (p == NULL) - return -ENOMEM; + if (p == NULL) { + ret = -ENOMEM; + goto out; + } p->major = major; strncpy(p->name, name, sizeof(p->name)-1); @@ -117,31 +132,38 @@ p->next = 0; index = major_to_index(major); - down_write(&block_subsys.rwsem); - for (n = &major_names[index]; *n; n = &(*n)->next) + spin_lock_irqsave(&major_names_lock, flags); + for (n = &major_names[index]; *n; n = &(*n)->next) { if ((*n)->major == major) break; + } if (!*n) *n = p; else ret = -EBUSY; - up_write(&block_subsys.rwsem); + spin_unlock_irqrestore(&major_names_lock, flags); - if (ret < 0) + if (ret < 0) { printk("register_blkdev: cannot get major %d for %s\n", major, name); - + kfree(p); + } +out: + up_write(&block_subsys.rwsem); return ret; } /* todo: make void - error printk here */ int unregister_blkdev(unsigned int major, const char *name) { - struct blk_major_name **n, *p; + struct blk_major_name **n; + struct blk_major_name *p = NULL; int index = major_to_index(major); + unsigned long flags; int ret = 0; down_write(&block_subsys.rwsem); + spin_lock_irqsave(&major_names_lock, flags); for (n = &major_names[index]; *n; n = &(*n)->next) if ((*n)->major == major) break; @@ -150,9 +172,10 @@ else { p = *n; *n = p->next; - kfree(p); } + spin_unlock_irqrestore(&major_names_lock, flags); up_write(&block_subsys.rwsem); + kfree(p); return ret; } @@ -538,12 +561,20 @@ struct gendisk *get_disk(struct gendisk *disk) { struct module *owner; + struct kobject *kobj; + if (!disk->fops) return NULL; owner = disk->fops->owner; if (owner && !try_module_get(owner)) return NULL; - return to_disk(kobject_get(&disk->kobj)); + kobj = kobject_get(&disk->kobj); + if (kobj == NULL) { + module_put(owner); + return NULL; + } + return to_disk(kobj); + } void put_disk(struct gendisk *disk) diff -Nru a/drivers/block/ll_rw_blk.c b/drivers/block/ll_rw_blk.c --- a/drivers/block/ll_rw_blk.c Sun Mar 23 00:22:50 2003 +++ b/drivers/block/ll_rw_blk.c Sun Mar 23 00:22:50 2003 @@ -56,11 +56,7 @@ unsigned long blk_max_low_pfn, blk_max_pfn; int blk_nohighio = 0; -static struct congestion_state { - wait_queue_head_t wqh; - atomic_t nr_congested_queues; - atomic_t nr_active_queues; -} congestion_states[2]; +static wait_queue_head_t congestion_wqh[2]; /* * Return the threshold (number of free requests) at which the queue is @@ -98,14 +94,12 @@ static void clear_queue_congested(request_queue_t *q, int rw) { enum bdi_state bit; - struct congestion_state *cs = &congestion_states[rw]; + wait_queue_head_t *wqh = &congestion_wqh[rw]; bit = (rw == WRITE) ? BDI_write_congested : BDI_read_congested; - - if (test_and_clear_bit(bit, &q->backing_dev_info.state)) - atomic_dec(&cs->nr_congested_queues); - if (waitqueue_active(&cs->wqh)) - wake_up(&cs->wqh); + clear_bit(bit, &q->backing_dev_info.state); + if (waitqueue_active(wqh)) + wake_up(wqh); } /* @@ -117,37 +111,7 @@ enum bdi_state bit; bit = (rw == WRITE) ? BDI_write_congested : BDI_read_congested; - - if (!test_and_set_bit(bit, &q->backing_dev_info.state)) - atomic_inc(&congestion_states[rw].nr_congested_queues); -} - -/* - * A queue has just put back its last read or write request and has fallen - * idle. - */ -static void clear_queue_active(request_queue_t *q, int rw) -{ - enum bdi_state bit; - - bit = (rw == WRITE) ? BDI_write_active : BDI_read_active; - - if (test_and_clear_bit(bit, &q->backing_dev_info.state)) - atomic_dec(&congestion_states[rw].nr_active_queues); -} - -/* - * A queue has just taken its first read or write request and has become - * active. - */ -static void set_queue_active(request_queue_t *q, int rw) -{ - enum bdi_state bit; - - bit = (rw == WRITE) ? BDI_write_active : BDI_read_active; - - if (!test_and_set_bit(bit, &q->backing_dev_info.state)) - atomic_inc(&congestion_states[rw].nr_active_queues); + set_bit(bit, &q->backing_dev_info.state); } /** @@ -1325,8 +1289,6 @@ rq = blkdev_free_rq(&rl->free); list_del_init(&rq->queuelist); rq->ref_count = 1; - if (rl->count == queue_nr_requests) - set_queue_active(q, rw); rl->count--; if (rl->count < queue_congestion_on_threshold()) set_queue_congested(q, rw); @@ -1569,8 +1531,6 @@ rl->count++; if (rl->count >= queue_congestion_off_threshold()) clear_queue_congested(q, rw); - if (rl->count == queue_nr_requests) - clear_queue_active(q, rw); if (rl->count >= batch_requests && waitqueue_active(&rl->wait)) wake_up(&rl->wait); } @@ -1605,12 +1565,12 @@ void blk_congestion_wait(int rw, long timeout) { DEFINE_WAIT(wait); - struct congestion_state *cs = &congestion_states[rw]; + wait_queue_head_t *wqh = &congestion_wqh[rw]; blk_run_queues(); - prepare_to_wait(&cs->wqh, &wait, TASK_UNINTERRUPTIBLE); + prepare_to_wait(wqh, &wait, TASK_UNINTERRUPTIBLE); io_schedule_timeout(timeout); - finish_wait(&cs->wqh, &wait); + finish_wait(wqh, &wait); } /* @@ -1932,13 +1892,14 @@ if (maxsector < nr_sectors || maxsector - nr_sectors < sector) { + char b[BDEVNAME_SIZE]; /* This may well happen - the kernel calls * bread() without checking the size of the * device, e.g., when mounting a device. */ printk(KERN_INFO "attempt to access beyond end of device\n"); printk(KERN_INFO "%s: rw=%ld, want=%Lu, limit=%Lu\n", - bdevname(bio->bi_bdev), + bdevname(bio->bi_bdev, b), bio->bi_rw, (unsigned long long) sector + nr_sectors, (long long) maxsector); @@ -1957,12 +1918,15 @@ * Stacking drivers are expected to know what they are doing. */ do { + char b[BDEVNAME_SIZE]; + q = bdev_get_queue(bio->bi_bdev); if (!q) { printk(KERN_ERR - "generic_make_request: Trying to access nonexistent block-device %s (%Lu)\n", - bdevname(bio->bi_bdev), - (long long) bio->bi_sector); + "generic_make_request: Trying to access " + "nonexistent block-device %s (%Lu)\n", + bdevname(bio->bi_bdev, b), + (long long) bio->bi_sector); end_io: bio_endio(bio, bio->bi_size, -EIO); break; @@ -1970,9 +1934,9 @@ if (unlikely(bio_sectors(bio) > q->max_sectors)) { printk("bio too big device %s (%u > %u)\n", - bdevname(bio->bi_bdev), - bio_sectors(bio), - q->max_sectors); + bdevname(bio->bi_bdev, b), + bio_sectors(bio), + q->max_sectors); goto end_io; } @@ -2249,11 +2213,8 @@ blk_max_low_pfn = max_low_pfn; blk_max_pfn = max_pfn; - for (i = 0; i < ARRAY_SIZE(congestion_states); i++) { - init_waitqueue_head(&congestion_states[i].wqh); - atomic_set(&congestion_states[i].nr_congested_queues, 0); - atomic_set(&congestion_states[i].nr_active_queues, 0); - } + for (i = 0; i < ARRAY_SIZE(congestion_wqh); i++) + init_waitqueue_head(&congestion_wqh[i]); return 0; }; diff -Nru a/drivers/block/nbd.c b/drivers/block/nbd.c --- a/drivers/block/nbd.c Sun Mar 23 00:22:51 2003 +++ b/drivers/block/nbd.c Sun Mar 23 00:22:51 2003 @@ -76,22 +76,15 @@ { int uptodate = (req->errors == 0) ? 1 : 0; request_queue_t *q = req->q; - struct bio *bio; - unsigned nsect; unsigned long flags; #ifdef PARANOIA requests_out++; #endif spin_lock_irqsave(q->queue_lock, flags); - while((bio = req->bio) != NULL) { - nsect = bio_sectors(bio); - blk_finished_io(nsect); - req->bio = bio->bi_next; - bio->bi_next = NULL; - bio_endio(bio, nsect << 9, uptodate ? 0 : -EIO); + if (!end_that_request_first(req, uptodate, req->nr_sectors)) { + end_that_request_last(req); } - blk_put_request(req); spin_unlock_irqrestore(q->queue_lock, flags); } @@ -243,7 +236,7 @@ req = list_entry(tmp, struct request, queuelist); if (req != xreq) continue; - list_del(&req->queuelist); + list_del_init(&req->queuelist); spin_unlock(&lo->queue_lock); return req; } @@ -322,7 +315,7 @@ spin_lock(&lo->queue_lock); if (!list_empty(&lo->queue_head)) { req = list_entry(lo->queue_head.next, struct request, queuelist); - list_del(&req->queuelist); + list_del_init(&req->queuelist); } spin_unlock(&lo->queue_lock); if (req) { @@ -387,7 +380,7 @@ if (req->errors) { printk(KERN_ERR "nbd: nbd_send_req failed\n"); spin_lock(&lo->queue_lock); - list_del(&req->queuelist); + list_del_init(&req->queuelist); spin_unlock(&lo->queue_lock); nbd_end_request(req); spin_lock_irq(q->queue_lock); @@ -590,6 +583,7 @@ disk->first_minor = i; disk->fops = &nbd_fops; disk->private_data = &nbd_dev[i]; + disk->queue = &nbd_queue; sprintf(disk->disk_name, "nbd%d", i); set_capacity(disk, 0x3ffffe); add_disk(disk); diff -Nru a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c --- a/drivers/cdrom/cdrom.c Sun Mar 23 00:22:50 2003 +++ b/drivers/cdrom/cdrom.c Sun Mar 23 00:22:51 2003 @@ -1125,7 +1125,7 @@ static int dvd_read_physical(struct cdrom_device_info *cdi, dvd_struct *s) { - unsigned char buf[20], *base; + unsigned char buf[21], *base; struct dvd_layer *layer; struct cdrom_generic_command cgc; struct cdrom_device_ops *cdo = cdi->ops; diff -Nru a/drivers/cdrom/cdu31a.c b/drivers/cdrom/cdu31a.c --- a/drivers/cdrom/cdu31a.c Sun Mar 23 00:22:54 2003 +++ b/drivers/cdrom/cdu31a.c Sun Mar 23 00:22:54 2003 @@ -1375,9 +1375,9 @@ readahead_buffer + (2048 - readahead_dataleft), readahead_dataleft); - readahead_dataleft = 0; bytesleft -= readahead_dataleft; offset += readahead_dataleft; + readahead_dataleft = 0; } else { /* The readahead will fill the whole buffer, get the data and return. */ diff -Nru a/drivers/cdrom/optcd.c b/drivers/cdrom/optcd.c --- a/drivers/cdrom/optcd.c Sun Mar 23 00:22:51 2003 +++ b/drivers/cdrom/optcd.c Sun Mar 23 00:22:51 2003 @@ -1600,13 +1600,17 @@ static int cdromread(unsigned long arg, int blocksize, int cmd) { - int status; + int status, ret = 0; struct cdrom_msf msf; - char buf[CD_FRAMESIZE_RAWER]; + char *buf; if (copy_from_user(&msf, (void *) arg, sizeof msf)) return -EFAULT; + buf = kmalloc(CD_FRAMESIZE_RAWER, GFP_KERNEL); + if (!buf) + return -ENOMEM; + bin2bcd(&msf); msf.cdmsf_min1 = 0; msf.cdmsf_sec1 = 0; @@ -1615,11 +1619,19 @@ DEBUG((DEBUG_VFS, "read cmd status 0x%x", status)); - if (!sleep_flag_low(FL_DTEN, SLEEP_TIMEOUT)) - return -EIO; + if (!sleep_flag_low(FL_DTEN, SLEEP_TIMEOUT)) { + ret = -EIO; + goto cdr_free; + } + fetch_data(buf, blocksize); - return copy_to_user((void *)arg, &buf, blocksize) ? -EFAULT : 0; + if (copy_to_user((void *)arg, &buf, blocksize)) + ret = -EFAULT; + +cdr_free: + kfree(buf); + return ret; } diff -Nru a/drivers/char/Makefile b/drivers/char/Makefile --- a/drivers/char/Makefile Sun Mar 23 00:22:55 2003 +++ b/drivers/char/Makefile Sun Mar 23 00:22:55 2003 @@ -44,6 +44,7 @@ obj-$(CONFIG_PRINTER) += lp.o obj-$(CONFIG_TIPAR) += tipar.o +obj-$(CONFIG_PC9800_OLDLP) += lp_old98.o obj-$(CONFIG_BUSMOUSE) += busmouse.o obj-$(CONFIG_DTLK) += dtlk.o diff -Nru a/drivers/char/amiserial.c b/drivers/char/amiserial.c --- a/drivers/char/amiserial.c Sun Mar 23 00:22:56 2003 +++ b/drivers/char/amiserial.c Sun Mar 23 00:22:56 2003 @@ -102,8 +102,6 @@ static char *serial_name = "Amiga-builtin serial driver"; -static DECLARE_TASK_QUEUE(tq_serial); - static struct tty_driver serial_driver, callout_driver; static int serial_refcount; @@ -276,8 +274,7 @@ int event) { info->event |= 1 << event; - queue_task(&info->tqueue, &tq_serial); - mark_bh(SERIAL_BH); + tasklet_schedule(&info->tlet); } static _INLINE_ void receive_chars(struct async_struct *info) @@ -560,12 +557,8 @@ * interrupt driver proper are done; the interrupt driver schedules * them using rs_sched_event(), and they get done here. */ -static void do_serial_bh(void) -{ - run_task_queue(&tq_serial); -} -static void do_softint(void *private_) +static void do_softint(unsigned long private_) { struct async_struct *info = (struct async_struct *) private_; struct tty_struct *tty; @@ -1878,8 +1871,7 @@ info->flags = sstate->flags; info->xmit_fifo_size = sstate->xmit_fifo_size; info->line = line; - info->tqueue.routine = do_softint; - info->tqueue.data = info; + tasklet_init(&info->tlet, do_softint, (unsigned long)info); info->state = sstate; if (sstate->info) { kfree(info); @@ -2117,8 +2109,6 @@ if (!request_mem_region(CUSTOM_PHYSADDR+0x30, 4, "amiserial [Paula]")) return -EBUSY; - init_bh(SERIAL_BH, do_serial_bh); - IRQ_ports = NULL; show_serial_version(); @@ -2234,23 +2224,18 @@ static __exit void rs_exit(void) { - unsigned long flags; int e1, e2; - struct async_struct *info; + struct async_struct *info = rs_table[0].info; /* printk("Unloading %s: version %s\n", serial_name, serial_version); */ - save_flags(flags); - cli(); - remove_bh(SERIAL_BH); + tasklet_kill(&info->tlet); if ((e1 = tty_unregister_driver(&serial_driver))) printk("SERIAL: failed to unregister serial driver (%d)\n", e1); if ((e2 = tty_unregister_driver(&callout_driver))) printk("SERIAL: failed to unregister callout driver (%d)\n", e2); - restore_flags(flags); - info = rs_table[0].info; if (info) { rs_table[0].info = NULL; kfree(info); @@ -2320,9 +2305,10 @@ /* * Register console. */ -static void __init amiserial_console_init(void) +static int __init amiserial_console_init(void) { register_console(&sercons); + return 0; } console_initcall(amiserial_console_init); #endif diff -Nru a/drivers/char/console_macros.h b/drivers/char/console_macros.h --- a/drivers/char/console_macros.h Sun Mar 23 00:22:51 2003 +++ b/drivers/char/console_macros.h Sun Mar 23 00:22:51 2003 @@ -1,4 +1,5 @@ #define cons_num (vc_cons[currcons].d->vc_num) +#define video_scan_lines (vc_cons[currcons].d->vc_scan_lines) #define sw (vc_cons[currcons].d->vc_sw) #define screenbuf (vc_cons[currcons].d->vc_screenbuf) #define screenbuf_size (vc_cons[currcons].d->vc_screenbuf_size) diff -Nru a/drivers/char/decserial.c b/drivers/char/decserial.c --- a/drivers/char/decserial.c Sun Mar 23 00:22:50 2003 +++ b/drivers/char/decserial.c Sun Mar 23 00:22:50 2003 @@ -75,7 +75,7 @@ /* serial_console_init handles the special case of starting * up the console on the serial port */ -static void __init decserial_console_init(void) +static int __init decserial_console_init(void) { #if defined(CONFIG_ZS) && defined(CONFIG_DZ) if (IOASIC) @@ -93,6 +93,7 @@ #endif #endif + return 0; } console_initcall(decserial_console_init); diff -Nru a/drivers/char/drm/ati_pcigart.h b/drivers/char/drm/ati_pcigart.h --- a/drivers/char/drm/ati_pcigart.h Sun Mar 23 00:22:55 2003 +++ b/drivers/char/drm/ati_pcigart.h Sun Mar 23 00:22:55 2003 @@ -27,7 +27,6 @@ * Gareth Hughes */ -#define __NO_VERSION__ #include "drmP.h" #if PAGE_SIZE == 65536 diff -Nru a/drivers/char/drm/drm_agpsupport.h b/drivers/char/drm/drm_agpsupport.h --- a/drivers/char/drm/drm_agpsupport.h Sun Mar 23 00:22:49 2003 +++ b/drivers/char/drm/drm_agpsupport.h Sun Mar 23 00:22:49 2003 @@ -29,7 +29,6 @@ * Gareth Hughes */ -#define __NO_VERSION__ #include "drmP.h" #include diff -Nru a/drivers/char/drm/drm_auth.h b/drivers/char/drm/drm_auth.h --- a/drivers/char/drm/drm_auth.h Sun Mar 23 00:22:55 2003 +++ b/drivers/char/drm/drm_auth.h Sun Mar 23 00:22:55 2003 @@ -29,7 +29,6 @@ * Gareth Hughes */ -#define __NO_VERSION__ #include "drmP.h" static int DRM(hash_magic)(drm_magic_t magic) diff -Nru a/drivers/char/drm/drm_bufs.h b/drivers/char/drm/drm_bufs.h --- a/drivers/char/drm/drm_bufs.h Sun Mar 23 00:22:51 2003 +++ b/drivers/char/drm/drm_bufs.h Sun Mar 23 00:22:51 2003 @@ -29,7 +29,6 @@ * Gareth Hughes */ -#define __NO_VERSION__ #include #include "drmP.h" diff -Nru a/drivers/char/drm/drm_context.h b/drivers/char/drm/drm_context.h --- a/drivers/char/drm/drm_context.h Sun Mar 23 00:22:49 2003 +++ b/drivers/char/drm/drm_context.h Sun Mar 23 00:22:49 2003 @@ -33,7 +33,6 @@ * needed by SiS driver's memory management. */ -#define __NO_VERSION__ #include "drmP.h" #if __HAVE_CTX_BITMAP diff -Nru a/drivers/char/drm/drm_dma.h b/drivers/char/drm/drm_dma.h --- a/drivers/char/drm/drm_dma.h Sun Mar 23 00:22:54 2003 +++ b/drivers/char/drm/drm_dma.h Sun Mar 23 00:22:54 2003 @@ -29,7 +29,6 @@ * Gareth Hughes */ -#define __NO_VERSION__ #include "drmP.h" #include /* For task queue support */ diff -Nru a/drivers/char/drm/drm_drawable.h b/drivers/char/drm/drm_drawable.h --- a/drivers/char/drm/drm_drawable.h Sun Mar 23 00:22:55 2003 +++ b/drivers/char/drm/drm_drawable.h Sun Mar 23 00:22:55 2003 @@ -29,7 +29,6 @@ * Gareth Hughes */ -#define __NO_VERSION__ #include "drmP.h" int DRM(adddraw)(struct inode *inode, struct file *filp, diff -Nru a/drivers/char/drm/drm_fops.h b/drivers/char/drm/drm_fops.h --- a/drivers/char/drm/drm_fops.h Sun Mar 23 00:22:53 2003 +++ b/drivers/char/drm/drm_fops.h Sun Mar 23 00:22:53 2003 @@ -30,7 +30,6 @@ * Gareth Hughes */ -#define __NO_VERSION__ #include "drmP.h" #include diff -Nru a/drivers/char/drm/drm_init.h b/drivers/char/drm/drm_init.h --- a/drivers/char/drm/drm_init.h Sun Mar 23 00:22:55 2003 +++ b/drivers/char/drm/drm_init.h Sun Mar 23 00:22:55 2003 @@ -29,7 +29,6 @@ * Gareth Hughes */ -#define __NO_VERSION__ #include "drmP.h" #if 0 diff -Nru a/drivers/char/drm/drm_ioctl.h b/drivers/char/drm/drm_ioctl.h --- a/drivers/char/drm/drm_ioctl.h Sun Mar 23 00:22:51 2003 +++ b/drivers/char/drm/drm_ioctl.h Sun Mar 23 00:22:51 2003 @@ -29,7 +29,6 @@ * Gareth Hughes */ -#define __NO_VERSION__ #include "drmP.h" diff -Nru a/drivers/char/drm/drm_lists.h b/drivers/char/drm/drm_lists.h --- a/drivers/char/drm/drm_lists.h Sun Mar 23 00:22:55 2003 +++ b/drivers/char/drm/drm_lists.h Sun Mar 23 00:22:55 2003 @@ -29,7 +29,6 @@ * Gareth Hughes */ -#define __NO_VERSION__ #include "drmP.h" #if __HAVE_DMA_WAITLIST diff -Nru a/drivers/char/drm/drm_lock.h b/drivers/char/drm/drm_lock.h --- a/drivers/char/drm/drm_lock.h Sun Mar 23 00:22:54 2003 +++ b/drivers/char/drm/drm_lock.h Sun Mar 23 00:22:54 2003 @@ -29,7 +29,6 @@ * Gareth Hughes */ -#define __NO_VERSION__ #include "drmP.h" int DRM(block)(struct inode *inode, struct file *filp, unsigned int cmd, diff -Nru a/drivers/char/drm/drm_memory.h b/drivers/char/drm/drm_memory.h --- a/drivers/char/drm/drm_memory.h Sun Mar 23 00:22:51 2003 +++ b/drivers/char/drm/drm_memory.h Sun Mar 23 00:22:51 2003 @@ -29,7 +29,6 @@ * Gareth Hughes */ -#define __NO_VERSION__ #include #include "drmP.h" #include diff -Nru a/drivers/char/drm/drm_os_linux.h b/drivers/char/drm/drm_os_linux.h --- a/drivers/char/drm/drm_os_linux.h Sun Mar 23 00:22:55 2003 +++ b/drivers/char/drm/drm_os_linux.h Sun Mar 23 00:22:55 2003 @@ -1,4 +1,3 @@ -#define __NO_VERSION__ #include /* For task queue support */ #include diff -Nru a/drivers/char/drm/drm_proc.h b/drivers/char/drm/drm_proc.h --- a/drivers/char/drm/drm_proc.h Sun Mar 23 00:22:50 2003 +++ b/drivers/char/drm/drm_proc.h Sun Mar 23 00:22:50 2003 @@ -33,7 +33,6 @@ * the problem with the proc files not outputting all their information. */ -#define __NO_VERSION__ #include "drmP.h" static int DRM(name_info)(char *buf, char **start, off_t offset, diff -Nru a/drivers/char/drm/drm_scatter.h b/drivers/char/drm/drm_scatter.h --- a/drivers/char/drm/drm_scatter.h Sun Mar 23 00:22:54 2003 +++ b/drivers/char/drm/drm_scatter.h Sun Mar 23 00:22:54 2003 @@ -27,7 +27,6 @@ * Gareth Hughes */ -#define __NO_VERSION__ #include #include #include "drmP.h" diff -Nru a/drivers/char/drm/drm_stub.h b/drivers/char/drm/drm_stub.h --- a/drivers/char/drm/drm_stub.h Sun Mar 23 00:22:55 2003 +++ b/drivers/char/drm/drm_stub.h Sun Mar 23 00:22:55 2003 @@ -28,7 +28,6 @@ * */ -#define __NO_VERSION__ #include "drmP.h" #define DRM_STUB_MAXCARDS 16 /* Enough for one machine */ diff -Nru a/drivers/char/drm/drm_vm.h b/drivers/char/drm/drm_vm.h --- a/drivers/char/drm/drm_vm.h Sun Mar 23 00:22:56 2003 +++ b/drivers/char/drm/drm_vm.h Sun Mar 23 00:22:56 2003 @@ -29,7 +29,6 @@ * Gareth Hughes */ -#define __NO_VERSION__ #include "drmP.h" struct vm_operations_struct DRM(vm_ops) = { diff -Nru a/drivers/char/drm/gamma_dma.c b/drivers/char/drm/gamma_dma.c --- a/drivers/char/drm/gamma_dma.c Sun Mar 23 00:22:55 2003 +++ b/drivers/char/drm/gamma_dma.c Sun Mar 23 00:22:55 2003 @@ -29,7 +29,6 @@ * */ -#define __NO_VERSION__ #include "gamma.h" #include "drmP.h" #include "drm.h" diff -Nru a/drivers/char/drm/i810_dma.c b/drivers/char/drm/i810_dma.c --- a/drivers/char/drm/i810_dma.c Sun Mar 23 00:22:52 2003 +++ b/drivers/char/drm/i810_dma.c Sun Mar 23 00:22:52 2003 @@ -30,7 +30,6 @@ * */ -#define __NO_VERSION__ #include "i810.h" #include "drmP.h" #include "drm.h" diff -Nru a/drivers/char/drm/i830_dma.c b/drivers/char/drm/i830_dma.c --- a/drivers/char/drm/i830_dma.c Sun Mar 23 00:22:50 2003 +++ b/drivers/char/drm/i830_dma.c Sun Mar 23 00:22:50 2003 @@ -31,7 +31,6 @@ * */ -#define __NO_VERSION__ #include "i830.h" #include "drmP.h" #include "drm.h" @@ -40,12 +39,6 @@ #include /* For task queue support */ #include -#ifdef DO_MUNMAP_4_ARGS -#define DO_MUNMAP(m, a, l) do_munmap(m, a, l, 1) -#else -#define DO_MUNMAP(m, a, l) do_munmap(m, a, l) -#endif - #define I830_BUF_FREE 2 #define I830_BUF_CLIENT 1 #define I830_BUF_HARDWARE 0 @@ -230,7 +223,7 @@ return -EINVAL; down_write(¤t->mm->mmap_sem); - retcode = DO_MUNMAP(current->mm, + retcode = do_munmap(current->mm, (unsigned long)buf_priv->virtual, (size_t) buf->total); up_write(¤t->mm->mmap_sem); diff -Nru a/drivers/char/drm/mga_warp.c b/drivers/char/drm/mga_warp.c --- a/drivers/char/drm/mga_warp.c Sun Mar 23 00:22:52 2003 +++ b/drivers/char/drm/mga_warp.c Sun Mar 23 00:22:52 2003 @@ -27,7 +27,6 @@ * Gareth Hughes */ -#define __NO_VERSION__ #include "mga.h" #include "drmP.h" #include "drm.h" diff -Nru a/drivers/char/drm/sis_ds.c b/drivers/char/drm/sis_ds.c --- a/drivers/char/drm/sis_ds.c Sun Mar 23 00:22:55 2003 +++ b/drivers/char/drm/sis_ds.c Sun Mar 23 00:22:55 2003 @@ -28,7 +28,6 @@ * */ -#define __NO_VERSION__ #include #include #include diff -Nru a/drivers/char/drm/sis_mm.c b/drivers/char/drm/sis_mm.c --- a/drivers/char/drm/sis_mm.c Sun Mar 23 00:22:54 2003 +++ b/drivers/char/drm/sis_mm.c Sun Mar 23 00:22:54 2003 @@ -28,7 +28,6 @@ * */ -#define __NO_VERSION__ #include "sis.h" #include #include "drmP.h" diff -Nru a/drivers/char/ftape/lowlevel/ftape_syms.c b/drivers/char/ftape/lowlevel/ftape_syms.c --- a/drivers/char/ftape/lowlevel/ftape_syms.c Sun Mar 23 00:22:52 2003 +++ b/drivers/char/ftape/lowlevel/ftape_syms.c Sun Mar 23 00:22:52 2003 @@ -26,7 +26,6 @@ */ #include -#define __NO_VERSION__ #include #include diff -Nru a/drivers/char/ftape/zftape/zftape-ctl.c b/drivers/char/ftape/zftape/zftape-ctl.c --- a/drivers/char/ftape/zftape/zftape-ctl.c Sun Mar 23 00:22:52 2003 +++ b/drivers/char/ftape/zftape/zftape-ctl.c Sun Mar 23 00:22:52 2003 @@ -27,7 +27,6 @@ #include #include #include -#define __NO_VERSION__ #include #include diff -Nru a/drivers/char/ftape/zftape/zftape_syms.c b/drivers/char/ftape/zftape/zftape_syms.c --- a/drivers/char/ftape/zftape/zftape_syms.c Sun Mar 23 00:22:50 2003 +++ b/drivers/char/ftape/zftape/zftape_syms.c Sun Mar 23 00:22:50 2003 @@ -24,7 +24,6 @@ * the ftape floppy tape driver exports */ -#define __NO_VERSION__ #include #include diff -Nru a/drivers/char/genrtc.c b/drivers/char/genrtc.c --- a/drivers/char/genrtc.c Sun Mar 23 00:22:55 2003 +++ b/drivers/char/genrtc.c Sun Mar 23 00:22:55 2003 @@ -1,5 +1,8 @@ /* - * Real Time Clock interface for q40 and other m68k machines + * Real Time Clock interface for + * - q40 and other m68k machines, + * - HP PARISC machines + * - PowerPC machines * emulate some RTC irq capabilities in software * * Copyright (C) 1999 Richard Zidlicky @@ -13,7 +16,7 @@ * pseudo-file for status information. * * The ioctls can be used to set the interrupt behaviour where - * supported. + * supported. * * The /dev/rtc interface will block on reads until an interrupt * has been received. If a RTC interrupt has already happened, @@ -34,9 +37,10 @@ * 1.04 removed useless timer code rz@linux-m68k.org * 1.05 portable RTC_UIE emulation rz@linux-m68k.org * 1.06 set_rtc_time can return an error trini@kernel.crashing.org + * 1.07 ported to HP PARISC (hppa) Helge Deller */ -#define RTC_VERSION "1.06" +#define RTC_VERSION "1.07" #include #include @@ -63,20 +67,17 @@ static DECLARE_WAIT_QUEUE_HEAD(gen_rtc_wait); -static int gen_rtc_ioctl(struct inode *inode, struct file *file, - unsigned int cmd, unsigned long arg); - /* * Bits in gen_rtc_status. */ #define RTC_IS_OPEN 0x01 /* means /dev/rtc is in use */ -unsigned char gen_rtc_status; /* bitmapped status byte. */ -unsigned long gen_rtc_irq_data; /* our output to the world */ +static unsigned char gen_rtc_status; /* bitmapped status byte. */ +static unsigned long gen_rtc_irq_data; /* our output to the world */ /* months start at 0 now */ -unsigned char days_in_mo[] = +static unsigned char days_in_mo[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; static int irq_active; @@ -89,18 +90,20 @@ static int lostint; static int tt_exp; -void gen_rtc_timer(unsigned long data); +static void gen_rtc_timer(unsigned long data); static volatile int stask_active; /* schedule_work */ static volatile int ttask_active; /* timer_task */ static int stop_rtc_timers; /* don't requeue tasks */ static spinlock_t gen_rtc_lock = SPIN_LOCK_UNLOCKED; +static void gen_rtc_interrupt(unsigned long arg); + /* * Routine to poll RTC seconds field for change as often as possible, * after first RTC_UIE use timer to reduce polling */ -void genrtc_troutine(void *data) +static void genrtc_troutine(void *data) { unsigned int tmp = get_rtc_ss(); @@ -124,7 +127,7 @@ stask_active = 0; } -void gen_rtc_timer(unsigned long data) +static void gen_rtc_timer(unsigned long data) { lostint = get_rtc_ss() - oldsecs ; if (lostint<0) @@ -145,7 +148,7 @@ * from some routine that periodically (eg 100HZ) monitors * whether RTC_SECS changed */ -void gen_rtc_interrupt(unsigned long arg) +static void gen_rtc_interrupt(unsigned long arg) { /* We store the status in the low byte and the number of * interrupts received since the last read in the remainder @@ -175,7 +178,7 @@ unsigned long data; ssize_t retval; - if (count != sizeof (unsigned int) && count != sizeof (unsigned long)) + if (count != sizeof (unsigned int) && count != sizeof (unsigned long)) return -EINVAL; if (file->f_flags & O_NONBLOCK && !gen_rtc_irq_data) @@ -385,24 +388,24 @@ */ static struct file_operations gen_rtc_fops = { - .owner = THIS_MODULE, + .owner = THIS_MODULE, #ifdef CONFIG_GEN_RTC_X - .read = gen_rtc_read, - .poll = gen_rtc_poll, + .read = gen_rtc_read, + .poll = gen_rtc_poll, #endif - .ioctl = gen_rtc_ioctl, - .open = gen_rtc_open, - .release = gen_rtc_release + .ioctl = gen_rtc_ioctl, + .open = gen_rtc_open, + .release = gen_rtc_release, }; static struct miscdevice rtc_gen_dev = { - RTC_MINOR, - "rtc", - &gen_rtc_fops + .minor = RTC_MINOR, + .name = "rtc", + .fops = &gen_rtc_fops, }; -int __init rtc_generic_init(void) +static int __init rtc_generic_init(void) { int retval; @@ -436,16 +439,18 @@ * Info exported via "/proc/rtc". */ -int gen_rtc_proc_output(char *buf) +#ifdef CONFIG_PROC_FS + +static int gen_rtc_proc_output(char *buf) { char *p; struct rtc_time tm; - unsigned tmp; + unsigned int flags; struct rtc_pll_info pll; p = buf; - get_rtc_time(&tm); + flags = get_rtc_time(&tm); p += sprintf(p, "rtc_time\t: %02d:%02d:%02d\n" @@ -454,7 +459,7 @@ tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, 1900); - tm.tm_hour=0;tm.tm_min=0;tm.tm_sec=0; + tm.tm_hour = tm.tm_min = tm.tm_sec = 0; p += sprintf(p, "alarm\t\t: "); if (tm.tm_hour <= 24) @@ -472,7 +477,6 @@ else p += sprintf(p, "**\n"); - tmp= RTC_24H ; p += sprintf(p, "DST_enable\t: %s\n" "BCD\t\t: %s\n" @@ -483,15 +487,15 @@ "periodic_IRQ\t: %s\n" "periodic_freq\t: %ld\n" "batt_status\t: %s\n", - (tmp & RTC_DST_EN) ? "yes" : "no", - (tmp & RTC_DM_BINARY) ? "no" : "yes", - (tmp & RTC_24H) ? "yes" : "no", - (tmp & RTC_SQWE) ? "yes" : "no", - (tmp & RTC_AIE) ? "yes" : "no", + (flags & RTC_DST_EN) ? "yes" : "no", + (flags & RTC_DM_BINARY) ? "no" : "yes", + (flags & RTC_24H) ? "yes" : "no", + (flags & RTC_SQWE) ? "yes" : "no", + (flags & RTC_AIE) ? "yes" : "no", irq_active ? "yes" : "no", - (tmp & RTC_PIE) ? "yes" : "no", + (flags & RTC_PIE) ? "yes" : "no", 0L /* freq */, - "okay" ); + (flags & RTC_BATT_BAD) ? "bad" : "okay"); if (!get_rtc_pll(&pll)) p += sprintf(p, "PLL adjustment\t: %d\n" @@ -506,7 +510,7 @@ pll.pll_posmult, pll.pll_negmult, pll.pll_clock); - return p - buf; + return p - buf; } static int gen_rtc_read_proc(char *page, char **start, off_t off, @@ -521,6 +525,9 @@ return len; } +#endif /* CONFIG_PROC_FS */ + MODULE_AUTHOR("Richard Zidlicky"); MODULE_LICENSE("GPL"); + diff -Nru a/drivers/char/ip2/ip2.h b/drivers/char/ip2/ip2.h --- a/drivers/char/ip2/ip2.h Sun Mar 23 00:22:51 2003 +++ b/drivers/char/ip2/ip2.h Sun Mar 23 00:22:51 2003 @@ -23,21 +23,10 @@ /* Constants */ /*************/ -/* Device major numbers - * The first set are the major numbers allocated from the Linux Device Registry. - * This was expanded from 64 to 128 with version 2.0.26. If this code is built - * under earlier versions we use majors from the LOCAL/EXPERIMENTAL range. - */ -#if MAX_CHRDEV > 64 -# define IP2_TTY_MAJOR 71 -# define IP2_CALLOUT_MAJOR 72 -# define IP2_IPL_MAJOR 73 -#else -# define IP2_TTY_MAJOR 60 -# define IP2_CALLOUT_MAJOR 61 -# define IP2_IPL_MAJOR 62 -#endif - +/* Device major numbers - since version 2.0.26. */ +#define IP2_TTY_MAJOR 71 +#define IP2_CALLOUT_MAJOR 72 +#define IP2_IPL_MAJOR 73 /* Board configuration array. * This array defines the hardware irq and address for up to IP2_MAX_BOARDS diff -Nru a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c --- a/drivers/char/ipmi/ipmi_devintf.c Sun Mar 23 00:22:55 2003 +++ b/drivers/char/ipmi/ipmi_devintf.c Sun Mar 23 00:22:55 2003 @@ -105,7 +105,7 @@ static struct ipmi_user_hndl ipmi_hndlrs = { - ipmi_recv_hndl : file_receive_handler + .ipmi_recv_hndl = file_receive_handler, }; static int ipmi_open(struct inode *inode, struct file *file) @@ -424,12 +424,12 @@ static struct file_operations ipmi_fops = { - owner: THIS_MODULE, - ioctl: ipmi_ioctl, - open: ipmi_open, - release: ipmi_release, - fasync: ipmi_fasync, - poll: ipmi_poll + .owner = THIS_MODULE, + .ioctl = ipmi_ioctl, + .open = ipmi_open, + .release = ipmi_release, + .fasync = ipmi_fasync, + .poll = ipmi_poll, }; #define DEVICE_NAME "ipmidev" @@ -468,8 +468,8 @@ static struct ipmi_smi_watcher smi_watcher = { - new_smi : ipmi_new_smi, - smi_gone : ipmi_smi_gone + .new_smi = ipmi_new_smi, + .smi_gone = ipmi_smi_gone, }; static __init int init_ipmi_devintf(void) diff -Nru a/drivers/char/ite_gpio.c b/drivers/char/ite_gpio.c --- a/drivers/char/ite_gpio.c Sun Mar 23 00:22:54 2003 +++ b/drivers/char/ite_gpio.c Sun Mar 23 00:22:54 2003 @@ -140,7 +140,7 @@ { int ret=-1; - if (MAX_GPIO_LINE > *data >= 0) + if ((MAX_GPIO_LINE > *data) && (*data >= 0)) ret=ite_gpio_irq_pending[*data]; DEB(printk("ite_gpio_in_status %d ret=%d\n",*data, ret)); diff -Nru a/drivers/char/lp_old98.c b/drivers/char/lp_old98.c --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/drivers/char/lp_old98.c Sun Mar 23 00:22:57 2003 @@ -0,0 +1,544 @@ +/* + * linux/drivers/char/lp_old98.c + * + * printer port driver for ancient PC-9800s with no bidirectional port support + * + * Copyright (C) 1998,99 Kousuke Takai , + * Kyoto University Microcomputer Club + * + * This driver is based on and has compatibility with `lp.c', + * generic PC printer port driver. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +/* + * I/O port numbers + */ +#define LP_PORT_DATA 0x40 +#define LP_PORT_STATUS (LP_PORT_DATA + 2) +#define LP_PORT_STROBE (LP_PORT_DATA + 4) +#define LP_PORT_CONTROL (LP_PORT_DATA + 6) + +#define LP_PORT_H98MODE 0x0448 +#define LP_PORT_EXTMODE 0x0149 + +/* + * bit mask for I/O + */ +#define LP_MASK_nBUSY (1 << 2) +#define LP_MASK_nSTROBE (1 << 7) + +#define LP_CONTROL_ASSERT_STROBE (0x0e) +#define LP_CONTROL_NEGATE_STROBE (0x0f) + +/* + * Acceptable maximum value for non-privileged user for LPCHARS ioctl. + */ +#define LP_CHARS_NOPRIV_MAX 65535 + +#define DC1 '\x11' +#define DC3 '\x13' + +/* PC-9800s have at least and at most one old-style printer port. */ +static struct lp_struct lp = { + .flags = LP_EXIST | LP_ABORTOPEN, + .chars = LP_INIT_CHAR, + .time = LP_INIT_TIME, + .wait = LP_INIT_WAIT, +}; + +static int dc1_check; +static spinlock_t lp_old98_lock = SPIN_LOCK_UNLOCKED; + + +#undef LP_OLD98_DEBUG + +#ifdef CONFIG_PC9800_OLDLP_CONSOLE +static struct console lp_old98_console; /* defined later */ +static short saved_console_flags; +#endif + +static DECLARE_WAIT_QUEUE_HEAD (lp_old98_waitq); + +static void lp_old98_timer_function(unsigned long data) +{ + if (inb(LP_PORT_STATUS) & LP_MASK_nBUSY) + wake_up_interruptible(&lp_old98_waitq); + else { + struct timer_list *t = (struct timer_list *) data; + + t->expires = jiffies + 1; + add_timer(t); + } +} + +static inline int lp_old98_wait_ready(void) +{ + struct timer_list timer; + + init_timer(&timer); + timer.function = lp_old98_timer_function; + timer.expires = jiffies + 1; + timer.data = (unsigned long)&timer; + add_timer(&timer); + interruptible_sleep_on(&lp_old98_waitq); + del_timer(&timer); + return signal_pending(current); +} + +static inline int lp_old98_char(char lpchar) +{ + unsigned long count = 0; +#ifdef LP_STATS + int tmp; +#endif + + while (!(inb(LP_PORT_STATUS) & LP_MASK_nBUSY)) { + count++; + if (count >= lp.chars) + return 0; + } + + outb(lpchar, LP_PORT_DATA); + +#ifdef LP_STATS + /* + * Update lp statsistics here (and between next two outb()'s). + * Time to compute it is part of storobe delay. + */ + if (count > lp.stats.maxwait) { +#ifdef LP_OLD98_DEBUG + printk(KERN_DEBUG "lp_old98: success after %d counts.\n", + count); +#endif + lp.stats.maxwait = count; + } + count *= 256; + tmp = count - lp.stats.meanwait; + if (tmp < 0) + tmp = -tmp; +#endif + ndelay(lp.wait); + + /* negate PSTB# (activate strobe) */ + outb(LP_CONTROL_ASSERT_STROBE, LP_PORT_CONTROL); + +#ifdef LP_STATS + lp.stats.meanwait = (255 * lp.stats.meanwait + count + 128) / 256; + lp.stats.mdev = (127 * lp.stats.mdev + tmp + 64) / 128; + lp.stats.chars ++; +#endif + + ndelay(lp.wait); + + /* assert PSTB# (deactivate strobe) */ + outb(LP_CONTROL_NEGATE_STROBE, LP_PORT_CONTROL); + + return 1; +} + +static ssize_t lp_old98_write(struct file * file, + const char * buf, size_t count, + loff_t *dummy) +{ + unsigned long total_bytes_written = 0; + + if (!access_ok(VERIFY_READ, buf, count)) + return -EFAULT; + +#ifdef LP_STATS + if (jiffies - lp.lastcall > lp.time) + lp.runchars = 0; + lp.lastcall = jiffies; +#endif + + do { + unsigned long bytes_written = 0; + unsigned long copy_size + = (count < LP_BUFFER_SIZE ? count : LP_BUFFER_SIZE); + + if (__copy_from_user(lp.lp_buffer, buf, copy_size)) + return -EFAULT; + + while (bytes_written < copy_size) { + if (lp_old98_char(lp.lp_buffer[bytes_written])) + bytes_written ++; + else { +#ifdef LP_STATS + int rc = lp.runchars + bytes_written; + + if (rc > lp.stats.maxrun) + lp.stats.maxrun = rc; + + lp.stats.sleeps ++; +#endif +#ifdef LP_OLD98_DEBUG + printk(KERN_DEBUG + "lp_old98: sleeping at %d characters" + " for %d jiffies\n", + lp.runchars, lp.time); + lp.runchars = 0; +#endif + if (lp_old98_wait_ready()) + return ((total_bytes_written + + bytes_written) + ? : -EINTR); + } + } + total_bytes_written += bytes_written; + buf += bytes_written; +#ifdef LP_STATS + lp.runchars += bytes_written; +#endif + count -= bytes_written; + } while (count > 0); + + return total_bytes_written; +} + +static int lp_old98_open(struct inode * inode, struct file * file) +{ + if (minor(inode->i_rdev) != 0) + return -ENXIO; + + if (lp.flags & LP_BUSY) + return -EBUSY; + + if (dc1_check && (lp.flags & LP_ABORTOPEN) + && !(file->f_flags & O_NONBLOCK)) { + /* + * Check whether printer is on-line. + * PC-9800's old style port have only BUSY# as status input, + * so that it is impossible to distinguish that the printer is + * ready and that the printer is off-line or not connected + * (in both case BUSY# is in the same state). So: + * + * (1) output DC1 (0x11) to printer port and do strobe. + * (2) watch BUSY# line for a while. If BUSY# is pulled + * down, the printer will be ready. Otherwise, + * it will be off-line (or not connected, or power-off, + * ...). + * + * The source of this procedure: + * Terumasa KODAKA, Kazufumi SHIMIZU, Yu HAYAMI: + * `PC-9801 Super Technique', Ascii, 1992. + */ + int count; + unsigned long flags; + + /* interrupts while check is fairly bad */ + spin_lock_irqsave(&lp_old98_lock, flags); + + if (!lp_old98_char(DC1)) { + spin_unlock_irqrestore(&lp_old98_lock, flags); + return -EBUSY; + } + count = (unsigned int)dc1_check > 10000 ? 10000 : dc1_check; + while (inb(LP_PORT_STATUS) & LP_MASK_nBUSY) { + if (--count == 0) { + spin_unlock_irqrestore(&lp_old98_lock, flags); + return -ENODEV; + } + } + spin_unlock_irqrestore(&lp_old98_lock, flags); + } + + if ((lp.lp_buffer = kmalloc(LP_BUFFER_SIZE, GFP_KERNEL)) == NULL) + return -ENOMEM; + + lp.flags |= LP_BUSY; + +#ifdef CONFIG_PC9800_OLDLP_CONSOLE + saved_console_flags = lp_old98_console.flags; + lp_old98_console.flags &= ~CON_ENABLED; +#endif + return 0; +} + +static int lp_old98_release(struct inode * inode, struct file * file) +{ + kfree(lp.lp_buffer); + lp.lp_buffer = NULL; + lp.flags &= ~LP_BUSY; +#ifdef CONFIG_PC9800_OLDLP_CONSOLE + lp_old98_console.flags = saved_console_flags; +#endif + return 0; +} + +static int lp_old98_init_device(void) +{ + unsigned char data; + + if ((data = inb(LP_PORT_EXTMODE)) != 0xFF && (data & 0x10)) { + printk(KERN_INFO + "lp_old98: shutting down extended parallel port mode...\n"); + outb(data & ~0x10, LP_PORT_EXTMODE); + } +#ifdef PC98_HW_H98 + if ((pc98_hw_flags & PC98_HW_H98) + && ((data = inb(LP_PORT_H98MODE)) & 0x01)) { + printk(KERN_INFO + "lp_old98: shutting down H98 full centronics mode...\n"); + outb(data & ~0x01, LP_PORT_H98MODE); + } +#endif + return 0; +} + +static int lp_old98_ioctl(struct inode *inode, struct file *file, + unsigned int command, unsigned long arg) +{ + int retval = 0; + + switch (command) { + case LPTIME: + lp.time = arg * HZ/100; + break; + case LPCHAR: + lp.chars = arg; + break; + case LPABORT: + if (arg) + lp.flags |= LP_ABORT; + else + lp.flags &= ~LP_ABORT; + break; + case LPABORTOPEN: + if (arg) + lp.flags |= LP_ABORTOPEN; + else + lp.flags &= ~LP_ABORTOPEN; + break; + case LPCAREFUL: + /* do nothing */ + break; + case LPWAIT: + lp.wait = arg; + break; + case LPGETIRQ: + retval = put_user(0, (int *)arg); + break; + case LPGETSTATUS: + /* + * convert PC-9800's status to IBM PC's one, so that tunelp(8) + * works in the same way on this driver. + */ + retval = put_user((inb(LP_PORT_STATUS) & LP_MASK_nBUSY) + ? (LP_PBUSY | LP_PERRORP) : LP_PERRORP, + (int *)arg); + break; + case LPRESET: + retval = lp_old98_init_device(); + break; +#ifdef LP_STATS + case LPGETSTATS: + if (copy_to_user((struct lp_stats *)arg, &lp.stats, + sizeof(struct lp_stats))) + retval = -EFAULT; + else if (suser()) + memset(&lp.stats, 0, sizeof(struct lp_stats)); + break; +#endif + case LPGETFLAGS: + retval = put_user(lp.flags, (int *)arg); + break; + case LPSETIRQ: + default: + retval = -EINVAL; + } + return retval; +} + +static struct file_operations lp_old98_fops = { + .owner = THIS_MODULE, + .write = lp_old98_write, + .ioctl = lp_old98_ioctl, + .open = lp_old98_open, + .release = lp_old98_release, +}; + +/* + * Support for console on lp_old98 + */ +#ifdef CONFIG_PC9800_OLDLP_CONSOLE + +static inline void io_delay(void) +{ + unsigned char dummy; /* actually not output */ + + asm volatile ("out%B0 %0,%1" : "=a"(dummy) : "N"(0x5f)); +} + +static void lp_old98_console_write(struct console *console, + const char *s, unsigned int count) +{ + int i; + static unsigned int timeout_run = 0; + + while (count) { + /* wait approx 1.2 seconds */ + for (i = 2000000; !(inb(LP_PORT_STATUS) & LP_MASK_nBUSY); + io_delay()) + if (!--i) { + if (++timeout_run >= 10) + /* disable forever... */ + console->flags &= ~CON_ENABLED; + return; + } + + timeout_run = 0; + + if (*s == '\n') { + outb('\r', LP_PORT_DATA); + io_delay(); + io_delay(); + outb(LP_CONTROL_ASSERT_STROBE, LP_PORT_CONTROL); + io_delay(); + io_delay(); + outb(LP_CONTROL_NEGATE_STROBE, LP_PORT_CONTROL); + io_delay(); + io_delay(); + for (i = 1000000; + !(inb(LP_PORT_STATUS) & LP_MASK_nBUSY); + io_delay()) + if (!--i) + return; + } + + outb(*s++, LP_PORT_DATA); + io_delay(); + io_delay(); + outb(LP_CONTROL_ASSERT_STROBE, LP_PORT_CONTROL); + io_delay(); + io_delay(); + outb(LP_CONTROL_NEGATE_STROBE, LP_PORT_CONTROL); + io_delay(); + io_delay(); + + --count; + } +} + +static kdev_t lp_old98_console_device(struct console *console) +{ + return mk_kdev(LP_MAJOR, 0); +} + +static struct console lp_old98_console = { + .name = "lp_old98", + .write = lp_old98_console_write, + .device = lp_old98_console_device, + .flags = CON_PRINTBUFFER, + .index = -1, +}; + +#endif /* console on lp_old98 */ + +static int __init lp_old98_init(void) +{ + char *errmsg = "I/O ports already occupied, giving up."; + +#ifdef PC98_HW_H98 + if (pc98_hw_flags & PC98_HW_H98) + if (!request_region(LP_PORT_H98MODE, 1, "lp_old98") + goto err1; +#endif + if (!request_region(LP_PORT_DATA, 1, "lp_old98")) + goto err2; + if (!request_region(LP_PORT_STATUS, 1, "lp_old98")) + goto err3; + if (!request_region(LP_PORT_STROBE, 1, "lp_old98")) + goto err4; + if (!request_region(LP_PORT_EXTMODE, 1, "lp_old98")) + goto err5; + if (!register_chrdev(LP_MAJOR, "lp", &lp_old98_fops)) { +#ifdef CONFIG_PC9800_OLDLP_CONSOLE + register_console(&lp_old98_console); + printk(KERN_INFO "lp_old98: console ready\n"); +#endif + /* + * rest are not needed by this driver, + * but for locking out other printer drivers... + */ + lp_old98_init_device(); + return 0; + } else + errmsg = "unable to register device"; + + release_region(LP_PORT_EXTMODE, 1); +err5: + release_region(LP_PORT_STROBE, 1); +err4: + release_region(LP_PORT_STATUS, 1); +err3: + release_region(LP_PORT_DATA, 1); +err2: +#ifdef PC98_HW_H98 + if (pc98_hw_flags & PC98_HW_H98) + release_region(LP_PORT_H98MODE, 1); + +err1: +#endif + printk(KERN_ERR "lp_old98: %s\n", errmsg); + return -EBUSY; +} + +static void __exit lp_old98_exit(void) +{ +#ifdef CONFIG_PC9800_OLDLP_CONSOLE + unregister_console(&lp_old98_console); +#endif + unregister_chrdev(LP_MAJOR, "lp"); + + release_region(LP_PORT_DATA, 1); + release_region(LP_PORT_STATUS, 1); + release_region(LP_PORT_STROBE, 1); +#ifdef PC98_HW_H98 + if (pc98_hw_flags & PC98_HW_H98) + release_region(LP_PORT_H98MODE, 1); +#endif + release_region(LP_PORT_EXTMODE, 1); +} + +#ifndef MODULE +static int __init lp_old98_setup(char *str) +{ + int ints[4]; + + str = get_options(str, ARRAY_SIZE(ints), ints); + if (ints[0] > 0) + dc1_check = ints[1]; + return 1; +} +__setup("lp_old98_dc1_check=", lp_old98_setup); +#endif + +MODULE_PARM(dc1_check, "i"); +MODULE_AUTHOR("Kousuke Takai "); +MODULE_DESCRIPTION("PC-9800 old printer port driver"); +MODULE_LICENSE("GPL"); + +module_init(lp_old98_init); +module_exit(lp_old98_exit); diff -Nru a/drivers/char/mwave/mwavedd.c b/drivers/char/mwave/mwavedd.c --- a/drivers/char/mwave/mwavedd.c Sun Mar 23 00:22:51 2003 +++ b/drivers/char/mwave/mwavedd.c Sun Mar 23 00:22:51 2003 @@ -53,46 +53,20 @@ #include #include #include -#include +#include #include #include -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) #include -#else -#include -#endif #include #include "smapi.h" #include "mwavedd.h" #include "3780i.h" #include "tp3780i.h" -#ifndef __exit -#define __exit -#endif - MODULE_DESCRIPTION("3780i Advanced Communications Processor (Mwave) driver"); MODULE_AUTHOR("Mike Sullivan and Paul Schroeder"); MODULE_LICENSE("GPL"); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) -static int mwave_get_info(char *buf, char **start, off_t offset, int len); -#else -static int mwave_read_proc(char *buf, char **start, off_t offset, int xlen, int unused); -static struct proc_dir_entry mwave_proc = { - 0, /* unsigned short low_ino */ - 5, /* unsigned short namelen */ - "mwave", /* const char *name */ - S_IFREG | S_IRUGO, /* mode_t mode */ - 1, /* nlink_t nlink */ - 0, /* uid_t uid */ - 0, /* gid_t gid */ - 0, /* unsigned long size */ - NULL, /* struct inode_operations *ops */ - &mwave_read_proc /* int (*get_info) (...) */ -}; -#endif - /* * These parameters support the setting of MWave resources. Note that no * checks are made against other devices (ie. superio) for conflicts. @@ -157,19 +131,23 @@ case IOCTL_MW_RESET: PRINTK_1(TRACE_MWAVE, - "mwavedd::mwave_ioctl, IOCTL_MW_RESET calling tp3780I_ResetDSP\n"); + "mwavedd::mwave_ioctl, IOCTL_MW_RESET" + " calling tp3780I_ResetDSP\n"); retval = tp3780I_ResetDSP(&pDrvData->rBDData); PRINTK_2(TRACE_MWAVE, - "mwavedd::mwave_ioctl, IOCTL_MW_RESET retval %x from tp3780I_ResetDSP\n", + "mwavedd::mwave_ioctl, IOCTL_MW_RESET" + " retval %x from tp3780I_ResetDSP\n", retval); break; case IOCTL_MW_RUN: PRINTK_1(TRACE_MWAVE, - "mwavedd::mwave_ioctl, IOCTL_MW_RUN calling tp3780I_StartDSP\n"); + "mwavedd::mwave_ioctl, IOCTL_MW_RUN" + " calling tp3780I_StartDSP\n"); retval = tp3780I_StartDSP(&pDrvData->rBDData); PRINTK_2(TRACE_MWAVE, - "mwavedd::mwave_ioctl, IOCTL_MW_RUN retval %x from tp3780I_StartDSP\n", + "mwavedd::mwave_ioctl, IOCTL_MW_RUN" + " retval %x from tp3780I_StartDSP\n", retval); break; @@ -177,17 +155,24 @@ MW_ABILITIES rAbilities; PRINTK_1(TRACE_MWAVE, - "mwavedd::mwave_ioctl, IOCTL_MW_DSP_ABILITIES calling tp3780I_QueryAbilities\n"); - retval = tp3780I_QueryAbilities(&pDrvData->rBDData, &rAbilities); + "mwavedd::mwave_ioctl," + " IOCTL_MW_DSP_ABILITIES calling" + " tp3780I_QueryAbilities\n"); + retval = tp3780I_QueryAbilities(&pDrvData->rBDData, + &rAbilities); PRINTK_2(TRACE_MWAVE, - "mwavedd::mwave_ioctl, IOCTL_MW_DSP_ABILITIES retval %x from tp3780I_QueryAbilities\n", + "mwavedd::mwave_ioctl, IOCTL_MW_DSP_ABILITIES" + " retval %x from tp3780I_QueryAbilities\n", retval); if (retval == 0) { - if( copy_to_user((char *) ioarg, (char *) &rAbilities, sizeof(MW_ABILITIES)) ) + if( copy_to_user((char *) ioarg, + (char *) &rAbilities, + sizeof(MW_ABILITIES)) ) return -EFAULT; } PRINTK_2(TRACE_MWAVE, - "mwavedd::mwave_ioctl, IOCTL_MW_DSP_ABILITIES exit retval %x\n", + "mwavedd::mwave_ioctl, IOCTL_MW_DSP_ABILITIES" + " exit retval %x\n", retval); } break; @@ -197,15 +182,21 @@ MW_READWRITE rReadData; unsigned short *pusBuffer = 0; - if( copy_from_user((char *) &rReadData, (char *) ioarg, sizeof(MW_READWRITE)) ) + if( copy_from_user((char *) &rReadData, + (char *) ioarg, + sizeof(MW_READWRITE)) ) return -EFAULT; pusBuffer = (unsigned short *) (rReadData.pBuf); PRINTK_4(TRACE_MWAVE, - "mwavedd::mwave_ioctl IOCTL_MW_READ_DATA, size %lx, ioarg %lx pusBuffer %p\n", + "mwavedd::mwave_ioctl IOCTL_MW_READ_DATA," + " size %lx, ioarg %lx pusBuffer %p\n", rReadData.ulDataLength, ioarg, pusBuffer); - retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData, iocmd, - (void *) pusBuffer, rReadData.ulDataLength, rReadData.usDspAddress); + retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData, + iocmd, + (void *) pusBuffer, + rReadData.ulDataLength, + rReadData.usDspAddress); } break; @@ -213,12 +204,14 @@ MW_READWRITE rReadData; unsigned short *pusBuffer = 0; - if( copy_from_user((char *) &rReadData, (char *) ioarg, sizeof(MW_READWRITE)) ) + if( copy_from_user((char *) &rReadData, (char *) ioarg, + sizeof(MW_READWRITE)) ) return -EFAULT; pusBuffer = (unsigned short *) (rReadData.pBuf); PRINTK_4(TRACE_MWAVE, - "mwavedd::mwave_ioctl IOCTL_MW_READ_INST, size %lx, ioarg %lx pusBuffer %p\n", + "mwavedd::mwave_ioctl IOCTL_MW_READ_INST," + " size %lx, ioarg %lx pusBuffer %p\n", rReadData.ulDataLength / 2, ioarg, pusBuffer); retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData, @@ -232,16 +225,21 @@ MW_READWRITE rWriteData; unsigned short *pusBuffer = 0; - if( copy_from_user((char *) &rWriteData, (char *) ioarg, sizeof(MW_READWRITE)) ) + if( copy_from_user((char *) &rWriteData, + (char *) ioarg, + sizeof(MW_READWRITE)) ) return -EFAULT; pusBuffer = (unsigned short *) (rWriteData.pBuf); PRINTK_4(TRACE_MWAVE, - "mwavedd::mwave_ioctl IOCTL_MW_WRITE_DATA, size %lx, ioarg %lx pusBuffer %p\n", + "mwavedd::mwave_ioctl IOCTL_MW_WRITE_DATA," + " size %lx, ioarg %lx pusBuffer %p\n", rWriteData.ulDataLength, ioarg, pusBuffer); - retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData, iocmd, - pusBuffer, rWriteData.ulDataLength, rWriteData.usDspAddress); + retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData, + iocmd, pusBuffer, + rWriteData.ulDataLength, + rWriteData.usDspAddress); } break; @@ -249,16 +247,21 @@ MW_READWRITE rWriteData; unsigned short *pusBuffer = 0; - if( copy_from_user((char *) &rWriteData, (char *) ioarg, sizeof(MW_READWRITE)) ) + if( copy_from_user((char *) &rWriteData, + (char *) ioarg, + sizeof(MW_READWRITE)) ) return -EFAULT; pusBuffer = (unsigned short *) (rWriteData.pBuf); PRINTK_4(TRACE_MWAVE, - "mwavedd::mwave_ioctl IOCTL_MW_WRITE_INST, size %lx, ioarg %lx pusBuffer %p\n", + "mwavedd::mwave_ioctl IOCTL_MW_WRITE_INST," + " size %lx, ioarg %lx pusBuffer %p\n", rWriteData.ulDataLength, ioarg, pusBuffer); - retval = tp3780I_ReadWriteDspIStore(&pDrvData->rBDData, iocmd, - pusBuffer, rWriteData.ulDataLength, rWriteData.usDspAddress); + retval = tp3780I_ReadWriteDspIStore(&pDrvData->rBDData, + iocmd, pusBuffer, + rWriteData.ulDataLength, + rWriteData.usDspAddress); } break; @@ -266,23 +269,25 @@ unsigned int ipcnum = (unsigned int) ioarg; PRINTK_3(TRACE_MWAVE, - "mwavedd::mwave_ioctl IOCTL_MW_REGISTER_IPC ipcnum %x entry usIntCount %x\n", + "mwavedd::mwave_ioctl IOCTL_MW_REGISTER_IPC" + " ipcnum %x entry usIntCount %x\n", ipcnum, pDrvData->IPCs[ipcnum].usIntCount); - if (ipcnum > 16) { - PRINTK_ERROR(KERN_ERR_MWAVE "mwavedd::mwave_ioctl: IOCTL_MW_REGISTER_IPC: Error: Invalid ipcnum %x\n", ipcnum); + if (ipcnum > ARRAY_SIZE(pDrvData->IPCs)) { + PRINTK_ERROR(KERN_ERR_MWAVE + "mwavedd::mwave_ioctl:" + " IOCTL_MW_REGISTER_IPC:" + " Error: Invalid ipcnum %x\n", + ipcnum); return -EINVAL; } pDrvData->IPCs[ipcnum].bIsHere = FALSE; pDrvData->IPCs[ipcnum].bIsEnabled = TRUE; - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) - #else - current->priority = 0x28; /* boost to provide priority timing */ - #endif PRINTK_2(TRACE_MWAVE, - "mwavedd::mwave_ioctl IOCTL_MW_REGISTER_IPC ipcnum %x exit\n", + "mwavedd::mwave_ioctl IOCTL_MW_REGISTER_IPC" + " ipcnum %x exit\n", ipcnum); } break; @@ -293,17 +298,22 @@ unsigned long flags; PRINTK_3(TRACE_MWAVE, - "mwavedd::mwave_ioctl IOCTL_MW_GET_IPC ipcnum %x, usIntCount %x\n", + "mwavedd::mwave_ioctl IOCTL_MW_GET_IPC" + " ipcnum %x, usIntCount %x\n", ipcnum, pDrvData->IPCs[ipcnum].usIntCount); - if (ipcnum > 16) { - PRINTK_ERROR(KERN_ERR_MWAVE "mwavedd::mwave_ioctl: IOCTL_MW_GET_IPC: Error: Invalid ipcnum %x\n", ipcnum); + if (ipcnum > ARRAY_SIZE(pDrvData->IPCs)) { + PRINTK_ERROR(KERN_ERR_MWAVE + "mwavedd::mwave_ioctl:" + " IOCTL_MW_GET_IPC: Error:" + " Invalid ipcnum %x\n", ipcnum); return -EINVAL; } if (pDrvData->IPCs[ipcnum].bIsEnabled == TRUE) { PRINTK_2(TRACE_MWAVE, - "mwavedd::mwave_ioctl, thread for ipc %x going to sleep\n", + "mwavedd::mwave_ioctl, thread for" + " ipc %x going to sleep\n", ipcnum); spin_lock_irqsave(&ipc_lock, flags); @@ -313,10 +323,13 @@ pDrvData->IPCs[ipcnum].usIntCount = 2; /* first int has been handled */ spin_unlock_irqrestore(&ipc_lock, flags); PRINTK_2(TRACE_MWAVE, - "mwavedd::mwave_ioctl IOCTL_MW_GET_IPC ipcnum %x handling first int\n", + "mwavedd::mwave_ioctl" + " IOCTL_MW_GET_IPC ipcnum %x" + " handling first int\n", ipcnum); } else { /* either 1st int has not yet occurred, or we have already handled the first int */ pDrvData->IPCs[ipcnum].bIsHere = TRUE; +#warning "Sleeping on spinlock" interruptible_sleep_on(&pDrvData->IPCs[ipcnum].ipc_wait_queue); pDrvData->IPCs[ipcnum].bIsHere = FALSE; if (pDrvData->IPCs[ipcnum].usIntCount == 1) { @@ -325,11 +338,16 @@ } spin_unlock_irqrestore(&ipc_lock, flags); PRINTK_2(TRACE_MWAVE, - "mwavedd::mwave_ioctl IOCTL_MW_GET_IPC ipcnum %x woke up and returning to application\n", + "mwavedd::mwave_ioctl" + " IOCTL_MW_GET_IPC ipcnum %x" + " woke up and returning to" + " application\n", ipcnum); } PRINTK_2(TRACE_MWAVE, - "mwavedd::mwave_ioctl IOCTL_MW_GET_IPC, returning thread for ipc %x processing\n", + "mwavedd::mwave_ioctl IOCTL_MW_GET_IPC," + " returning thread for ipc %x" + " processing\n", ipcnum); } } @@ -339,10 +357,15 @@ unsigned int ipcnum = (unsigned int) ioarg; PRINTK_2(TRACE_MWAVE, - "mwavedd::mwave_ioctl IOCTL_MW_UNREGISTER_IPC ipcnum %x\n", + "mwavedd::mwave_ioctl IOCTL_MW_UNREGISTER_IPC" + " ipcnum %x\n", ipcnum); - if (ipcnum > 16) { - PRINTK_ERROR(KERN_ERR_MWAVE "mwavedd::mwave_ioctl: IOCTL_MW_UNREGISTER_IPC: Error: Invalid ipcnum %x\n", ipcnum); + if (ipcnum > ARRAY_SIZE(pDrvData->IPCs)) { + PRINTK_ERROR(KERN_ERR_MWAVE + "mwavedd::mwave_ioctl:" + " IOCTL_MW_UNREGISTER_IPC:" + " Error: Invalid ipcnum %x\n", + ipcnum); return -EINVAL; } if (pDrvData->IPCs[ipcnum].bIsEnabled == TRUE) { @@ -355,7 +378,9 @@ break; default: - PRINTK_ERROR(KERN_ERR_MWAVE "mwavedd::mwave_ioctl: Error: Unrecognized iocmd %x\n", iocmd); + PRINTK_ERROR(KERN_ERR_MWAVE "mwavedd::mwave_ioctl:" + " Error: Unrecognized iocmd %x\n", + iocmd); return -ENOTTY; break; } /* switch */ @@ -381,7 +406,8 @@ size_t count, loff_t * ppos) { PRINTK_5(TRACE_MWAVE, - "mwavedd::mwave_write entry file %p, buf %p, count %x ppos %p\n", + "mwavedd::mwave_write entry file %p, buf %p," + " count %x ppos %p\n", file, buf, count, ppos); return -EINVAL; @@ -400,7 +426,9 @@ /* OK */ break; default: - PRINTK_ERROR(KERN_ERR_MWAVE "mwavedd::register_serial_portandirq: Error: Illegal port %x\n", port ); + PRINTK_ERROR(KERN_ERR_MWAVE + "mwavedd::register_serial_portandirq:" + " Error: Illegal port %x\n", port ); return -1; } /* switch */ /* port is okay */ @@ -413,7 +441,9 @@ /* OK */ break; default: - PRINTK_ERROR(KERN_ERR_MWAVE "mwavedd::register_serial_portandirq: Error: Illegal irq %x\n", irq ); + PRINTK_ERROR(KERN_ERR_MWAVE + "mwavedd::register_serial_portandirq:" + " Error: Illegal irq %x\n", irq ); return -1; } /* switch */ /* irq is okay */ @@ -427,7 +457,6 @@ } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) static struct file_operations mwave_fops = { .owner = THIS_MODULE, .read = mwave_read, @@ -436,24 +465,47 @@ .open = mwave_open, .release = mwave_close }; -#else -static struct file_operations mwave_fops = { - NULL, /* lseek */ - mwave_read, /* read */ - mwave_write, /* write */ - NULL, /* readdir */ - NULL, /* poll */ - mwave_ioctl, /* ioctl */ - NULL, /* mmap */ - mwave_open, /* open */ - NULL, /* flush */ - mwave_close /* release */ -}; -#endif + static struct miscdevice mwave_misc_dev = { MWAVE_MINOR, "mwave", &mwave_fops }; /* + * sysfs support + */ + +struct device mwave_device; + +/* Prevent code redundancy, create a macro for mwave_show_* functions. */ +#define mwave_show_function(attr_name, format_string, field) \ +static ssize_t mwave_show_##attr_name(struct device *dev, char *buf) \ +{ \ + DSP_3780I_CONFIG_SETTINGS *pSettings = \ + &mwave_s_mdd.rBDData.rDspSettings; \ + return sprintf(buf, format_string, pSettings->field); \ +} + +/* All of our attributes are read attributes. */ +#define mwave_dev_rd_attr(attr_name, format_string, field) \ + mwave_show_function(attr_name, format_string, field) \ +static DEVICE_ATTR(attr_name, S_IRUGO, mwave_show_##attr_name, NULL) + +mwave_dev_rd_attr (3780i_dma, "%i\n", usDspDma); +mwave_dev_rd_attr (3780i_irq, "%i\n", usDspIrq); +mwave_dev_rd_attr (3780i_io, "%#.4x\n", usDspBaseIO); +mwave_dev_rd_attr (uart_irq, "%i\n", usUartIrq); +mwave_dev_rd_attr (uart_io, "%#.4x\n", usUartBaseIO); + +static struct device_attribute * const mwave_dev_attrs[] = { + &dev_attr_3780i_dma, + &dev_attr_3780i_irq, + &dev_attr_3780i_io, + &dev_attr_uart_irq, + &dev_attr_uart_io, +}; +static int nr_registered_attrs; +static int device_registered; + +/* * mwave_init is called on module load * * mwave_exit is called on module unload @@ -461,17 +513,20 @@ */ static void mwave_exit(void) { + int i; pMWAVE_DEVICE_DATA pDrvData = &mwave_s_mdd; PRINTK_1(TRACE_MWAVE, "mwavedd::mwave_exit entry\n"); - if (pDrvData->bProcEntryCreated) { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) - remove_proc_entry("mwave", NULL); -#else - proc_unregister(&proc_root, mwave_proc.low_ino); -#endif + for (i = 0; i < nr_registered_attrs; i++) + device_remove_file(&mwave_device, mwave_dev_attrs[i]); + nr_registered_attrs = 0; + + if (device_registered) { + device_unregister(&mwave_device); + device_registered = 0; } + if ( pDrvData->sLine >= 0 ) { unregister_serial(pDrvData->sLine); } @@ -497,72 +552,81 @@ { int i; int retval = 0; - unsigned int resultMiscRegister; pMWAVE_DEVICE_DATA pDrvData = &mwave_s_mdd; - memset(&mwave_s_mdd, 0, sizeof(MWAVE_DEVICE_DATA)); - PRINTK_1(TRACE_MWAVE, "mwavedd::mwave_init entry\n"); + memset(&mwave_s_mdd, 0, sizeof(MWAVE_DEVICE_DATA)); + pDrvData->bBDInitialized = FALSE; pDrvData->bResourcesClaimed = FALSE; pDrvData->bDSPEnabled = FALSE; pDrvData->bDSPReset = FALSE; pDrvData->bMwaveDevRegistered = FALSE; pDrvData->sLine = -1; - pDrvData->bProcEntryCreated = FALSE; - for (i = 0; i < 16; i++) { + for (i = 0; i < ARRAY_SIZE(pDrvData->IPCs); i++) { pDrvData->IPCs[i].bIsEnabled = FALSE; pDrvData->IPCs[i].bIsHere = FALSE; pDrvData->IPCs[i].usIntCount = 0; /* no ints received yet */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) init_waitqueue_head(&pDrvData->IPCs[i].ipc_wait_queue); -#endif } retval = tp3780I_InitializeBoardData(&pDrvData->rBDData); PRINTK_2(TRACE_MWAVE, - "mwavedd::mwave_init, return from tp3780I_InitializeBoardData retval %x\n", + "mwavedd::mwave_init, return from tp3780I_InitializeBoardData" + " retval %x\n", retval); if (retval) { - PRINTK_ERROR(KERN_ERR_MWAVE "mwavedd::mwave_init: Error: Failed to initialize board data\n"); + PRINTK_ERROR(KERN_ERR_MWAVE + "mwavedd::mwave_init: Error:" + " Failed to initialize board data\n"); goto cleanup_error; } pDrvData->bBDInitialized = TRUE; retval = tp3780I_CalcResources(&pDrvData->rBDData); PRINTK_2(TRACE_MWAVE, - "mwavedd::mwave_init, return from tp3780I_CalcResources retval %x\n", + "mwavedd::mwave_init, return from tp3780I_CalcResources" + " retval %x\n", retval); if (retval) { - PRINTK_ERROR(KERN_ERR_MWAVE "mwavedd:mwave_init: Error: Failed to calculate resources\n"); + PRINTK_ERROR(KERN_ERR_MWAVE + "mwavedd:mwave_init: Error:" + " Failed to calculate resources\n"); goto cleanup_error; } retval = tp3780I_ClaimResources(&pDrvData->rBDData); PRINTK_2(TRACE_MWAVE, - "mwavedd::mwave_init, return from tp3780I_ClaimResources retval %x\n", + "mwavedd::mwave_init, return from tp3780I_ClaimResources" + " retval %x\n", retval); if (retval) { - PRINTK_ERROR(KERN_ERR_MWAVE "mwavedd:mwave_init: Error: Failed to claim resources\n"); + PRINTK_ERROR(KERN_ERR_MWAVE + "mwavedd:mwave_init: Error:" + " Failed to claim resources\n"); goto cleanup_error; } pDrvData->bResourcesClaimed = TRUE; retval = tp3780I_EnableDSP(&pDrvData->rBDData); PRINTK_2(TRACE_MWAVE, - "mwavedd::mwave_init, return from tp3780I_EnableDSP retval %x\n", + "mwavedd::mwave_init, return from tp3780I_EnableDSP" + " retval %x\n", retval); if (retval) { - PRINTK_ERROR(KERN_ERR_MWAVE "mwavedd:mwave_init: Error: Failed to enable DSP\n"); + PRINTK_ERROR(KERN_ERR_MWAVE + "mwavedd:mwave_init: Error:" + " Failed to enable DSP\n"); goto cleanup_error; } pDrvData->bDSPEnabled = TRUE; - resultMiscRegister = misc_register(&mwave_misc_dev); - if (resultMiscRegister < 0) { - PRINTK_ERROR(KERN_ERR_MWAVE "mwavedd:mwave_init: Error: Failed to register misc device\n"); + if (misc_register(&mwave_misc_dev) < 0) { + PRINTK_ERROR(KERN_ERR_MWAVE + "mwavedd:mwave_init: Error:" + " Failed to register misc device\n"); goto cleanup_error; } pDrvData->bMwaveDevRegistered = TRUE; @@ -572,28 +636,39 @@ pDrvData->rBDData.rDspSettings.usUartIrq ); if (pDrvData->sLine < 0) { - PRINTK_ERROR(KERN_ERR_MWAVE "mwavedd:mwave_init: Error: Failed to register serial driver\n"); + PRINTK_ERROR(KERN_ERR_MWAVE + "mwavedd:mwave_init: Error:" + " Failed to register serial driver\n"); goto cleanup_error; } /* uart is registered */ - if ( -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) - !create_proc_info_entry("mwave", 0, NULL, mwave_get_info) -#else - proc_register(&proc_root, &mwave_proc) -#endif - ) { - PRINTK_ERROR(KERN_ERR_MWAVE "mwavedd::mwave_init: Error: Failed to register /proc/mwave\n"); + /* sysfs */ + memset(&mwave_device, 0, sizeof (struct device)); + snprintf(mwave_device.name, DEVICE_NAME_SIZE, "mwave"); + snprintf(mwave_device.bus_id, BUS_ID_SIZE, "mwave"); + + if (device_register(&mwave_device)) goto cleanup_error; + device_registered = 1; + for (i = 0; i < ARRAY_SIZE(mwave_dev_attrs); i++) { + if(device_create_file(&mwave_device, mwave_dev_attrs[i])) { + PRINTK_ERROR(KERN_ERR_MWAVE + "mwavedd:mwave_init: Error:" + " Failed to create sysfs file %s\n", + mwave_dev_attrs[i]->attr.name); + goto cleanup_error; + } + nr_registered_attrs++; } - pDrvData->bProcEntryCreated = TRUE; /* SUCCESS! */ return 0; - cleanup_error: - PRINTK_ERROR(KERN_ERR_MWAVE "mwavedd::mwave_init: Error: Failed to initialize\n"); +cleanup_error: + PRINTK_ERROR(KERN_ERR_MWAVE + "mwavedd::mwave_init: Error:" + " Failed to initialize\n"); mwave_exit(); /* clean up */ return -EIO; @@ -601,39 +676,3 @@ module_init(mwave_init); - -/* -* proc entry stuff added by Ian Pilcher -*/ - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) -static int mwave_get_info(char *buf, char **start, off_t offset, int len) -{ - DSP_3780I_CONFIG_SETTINGS *pSettings = &mwave_s_mdd.rBDData.rDspSettings; - - char *out = buf; - - out += sprintf(out, "3780i_IRQ %i\n", pSettings->usDspIrq); - out += sprintf(out, "3780i_DMA %i\n", pSettings->usDspDma); - out += sprintf(out, "3780i_IO %#.4x\n", pSettings->usDspBaseIO); - out += sprintf(out, "UART_IRQ %i\n", pSettings->usUartIrq); - out += sprintf(out, "UART_IO %#.4x\n", pSettings->usUartBaseIO); - - return out - buf; -} -#else /* kernel version < 2.4.0 */ -static int mwave_read_proc(char *buf, char **start, off_t offset, - int xlen, int unused) -{ - DSP_3780I_CONFIG_SETTINGS *pSettings = &mwave_s_mdd.rBDData.rDspSettings; - int len; - - len = sprintf(buf, "3780i_IRQ %i\n", pSettings->usDspIrq); - len += sprintf(&buf[len], "3780i_DMA %i\n", pSettings->usDspDma); - len += sprintf(&buf[len], "3780i_IO %#.4x\n", pSettings->usDspBaseIO); - len += sprintf(&buf[len], "UART_IRQ %i\n", pSettings->usUartIrq); - len += sprintf(&buf[len], "UART_IO %#.4x\n", pSettings->usUartBaseIO); - - return len; -} -#endif diff -Nru a/drivers/char/mwave/mwavedd.h b/drivers/char/mwave/mwavedd.h --- a/drivers/char/mwave/mwavedd.h Sun Mar 23 00:22:53 2003 +++ b/drivers/char/mwave/mwavedd.h Sun Mar 23 00:22:53 2003 @@ -126,11 +126,7 @@ BOOLEAN bIsEnabled; BOOLEAN bIsHere; /* entry spin lock */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) wait_queue_head_t ipc_wait_queue; -#else - struct wait_queue *ipc_wait_queue; -#endif } MWAVE_IPC; typedef struct _MWAVE_DEVICE_DATA { @@ -143,7 +139,6 @@ BOOLEAN bDSPReset; MWAVE_IPC IPCs[16]; BOOLEAN bMwaveDevRegistered; - BOOLEAN bProcEntryCreated; short sLine; } MWAVE_DEVICE_DATA, *pMWAVE_DEVICE_DATA; diff -Nru a/drivers/char/mwave/mwavepub.h b/drivers/char/mwave/mwavepub.h --- a/drivers/char/mwave/mwavepub.h Sun Mar 23 00:22:56 2003 +++ b/drivers/char/mwave/mwavepub.h Sun Mar 23 00:22:56 2003 @@ -50,13 +50,8 @@ #ifndef _LINUX_MWAVEPUB_H #define _LINUX_MWAVEPUB_H -#ifndef MWAVEM_APP_DIST #include -#endif -#ifdef MWAVEM_APP_DIST -#define MWAVE_MINOR 219 -#endif typedef struct _MW_ABILITIES { unsigned long instr_per_sec; diff -Nru a/drivers/char/mwave/smapi.c b/drivers/char/mwave/smapi.c --- a/drivers/char/mwave/smapi.c Sun Mar 23 00:22:55 2003 +++ b/drivers/char/mwave/smapi.c Sun Mar 23 00:22:55 2003 @@ -280,10 +280,11 @@ if ((usSI & 0xFF) == mwave_uart_irq) { #ifndef MWAVE_FUTZ_WITH_OTHER_DEVICES PRINTK_ERROR(KERN_ERR_MWAVE + "smapi::smapi_set_DSP_cfg: Serial port A irq %x conflicts with mwave_uart_irq %x\n", usSI & 0xFF, mwave_uart_irq); #else PRINTK_3(TRACE_SMAPI, + "smapi::smapi_set_DSP_cfg: Serial port A irq %x conflicts with mwave_uart_irq %x\n", usSI & 0xFF, mwave_uart_irq); #endif - "smapi::smapi_set_DSP_cfg: Serial port A irq %x conflicts with mwave_uart_irq %x\n", usSI, mwave_uart_irq); #ifdef MWAVE_FUTZ_WITH_OTHER_DEVICES PRINTK_1(TRACE_SMAPI, "smapi::smapi_set_DSP_cfg Disabling conflicting serial port\n"); @@ -300,13 +301,14 @@ if ((usSI >> 8) == uartio_index) { #ifndef MWAVE_FUTZ_WITH_OTHER_DEVICES PRINTK_ERROR(KERN_ERR_MWAVE + "smapi::smapi_set_DSP_cfg: Serial port A base I/O address %x conflicts with mwave uart I/O %x\n", ausUartBases[usSI >> 8], ausUartBases[uartio_index]); #else PRINTK_3(TRACE_SMAPI, + "smapi::smapi_set_DSP_cfg: Serial port A base I/O address %x conflicts with mwave uart I/O %x\n", ausUartBases[usSI >> 8], ausUartBases[uartio_index]); #endif - "smapi::smapi_set_DSP_cfg: Serial port A base I/O address index %x conflicts with uartio_index %x\n", usSI >> 8, uartio_index); #ifdef MWAVE_FUTZ_WITH_OTHER_DEVICES PRINTK_1(TRACE_SMAPI, - "smapi::smapi_set_DSP_cfg Disabling conflicting serial port\n"); + "smapi::smapi_set_DSP_cfg Disabling conflicting serial port A\n"); bRC = smapi_request (0x1403, 0x0100, 0, usSI, &usAX, &usBX, &usCX, &usDX, &usDI, &usSI); if (bRC) goto exit_smapi_request_error; @@ -331,13 +333,14 @@ if ((usSI & 0xFF) == mwave_uart_irq) { #ifndef MWAVE_FUTZ_WITH_OTHER_DEVICES PRINTK_ERROR(KERN_ERR_MWAVE + "smapi::smapi_set_DSP_cfg: Serial port B irq %x conflicts with mwave_uart_irq %x\n", usSI & 0xFF, mwave_uart_irq); #else PRINTK_3(TRACE_SMAPI, + "smapi::smapi_set_DSP_cfg: Serial port B irq %x conflicts with mwave_uart_irq %x\n", usSI & 0xFF, mwave_uart_irq); #endif - "smapi::smapi_set_DSP_cfg: Serial port B irq %x conflicts with mwave_uart_irq %x\n", usSI, mwave_uart_irq); #ifdef MWAVE_FUTZ_WITH_OTHER_DEVICES PRINTK_1(TRACE_SMAPI, - "smapi::smapi_set_DSP_cfg Disabling conflicting serial port\n"); + "smapi::smapi_set_DSP_cfg Disabling conflicting serial port B\n"); bRC = smapi_request(0x1405, 0x0100, 0, usSI, &usAX, &usBX, &usCX, &usDX, &usDI, &usSI); if (bRC) goto exit_smapi_request_error; @@ -351,13 +354,14 @@ if ((usSI >> 8) == uartio_index) { #ifndef MWAVE_FUTZ_WITH_OTHER_DEVICES PRINTK_ERROR(KERN_ERR_MWAVE + "smapi::smapi_set_DSP_cfg: Serial port B base I/O address %x conflicts with mwave uart I/O %x\n", ausUartBases[usSI >> 8], ausUartBases[uartio_index]); #else PRINTK_3(TRACE_SMAPI, + "smapi::smapi_set_DSP_cfg: Serial port B base I/O address %x conflicts with mwave uart I/O %x\n", ausUartBases[usSI >> 8], ausUartBases[uartio_index]); #endif - "smapi::smapi_set_DSP_cfg: Serial port B base I/O address index %x conflicts with uartio_index %x\n", usSI >> 8, uartio_index); #ifdef MWAVE_FUTZ_WITH_OTHER_DEVICES PRINTK_1 (TRACE_SMAPI, - "smapi::smapi_set_DSP_cfg Disabling conflicting serial port\n"); + "smapi::smapi_set_DSP_cfg Disabling conflicting serial port B\n"); bRC = smapi_request (0x1405, 0x0100, 0, usSI, &usAX, &usBX, &usCX, &usDX, &usDI, &usSI); if (bRC) goto exit_smapi_request_error; @@ -380,39 +384,15 @@ &usAX, &usBX, &usCX, &usDX, &usDI, &usSI); if (bRC) goto exit_smapi_request_error; /* bRC == 0 */ - if ((usCX & 0xff) == mwave_uart_irq) { /* serial port is enabled */ -#ifndef MWAVE_FUTZ_WITH_OTHER_DEVICES - PRINTK_ERROR(KERN_ERR_MWAVE -#else - PRINTK_3(TRACE_SMAPI, -#endif - "smapi::smapi_set_DSP_cfg: IR port irq %x conflicts with mwave_uart_irq %x\n", usSI, mwave_uart_irq); -#ifdef MWAVE_FUTZ_WITH_OTHER_DEVICES - PRINTK_1(TRACE_SMAPI, - "smapi::smapi_set_DSP_cfg Disabling conflicting IR port\n"); - bRC = smapi_request(0x1701, 0x0100, 0, 0, - &usAX, &usBX, &usCX, &usDX, &usDI, &usSI); - if (bRC) goto exit_smapi_request_error; - bRC = smapi_request(0x1700, 0, 0, 0, - &usAX, &usBX, &usCX, &usDX, &usDI, &usSI); - if (bRC) goto exit_smapi_request_error; - bRC = smapi_request(0x1705, 0x01ff, 0, usSI, - &usAX, &usBX, &usCX, &usDX, &usDI, &usSI); - if (bRC) goto exit_smapi_request_error; - bRC = smapi_request(0x1704, 0x0000, 0, 0, - &usAX, &usBX, &usCX, &usDX, &usDI, &usSI); - if (bRC) goto exit_smapi_request_error; -#else - goto exit_conflict; -#endif - } else { - if ((usSI & 0xff) == uartio_index) { + if ((usCX & 0xff) != 0xff) { /* IR port not disabled */ + if ((usCX & 0xff) == mwave_uart_irq) { #ifndef MWAVE_FUTZ_WITH_OTHER_DEVICES PRINTK_ERROR(KERN_ERR_MWAVE + "smapi::smapi_set_DSP_cfg: IR port irq %x conflicts with mwave_uart_irq %x\n", usCX & 0xff, mwave_uart_irq); #else PRINTK_3(TRACE_SMAPI, + "smapi::smapi_set_DSP_cfg: IR port irq %x conflicts with mwave_uart_irq %x\n", usCX & 0xff, mwave_uart_irq); #endif - "smapi::smapi_set_DSP_cfg: IR port base I/O address index %x conflicts with uartio_index %x\n", usSI & 0xff, uartio_index); #ifdef MWAVE_FUTZ_WITH_OTHER_DEVICES PRINTK_1(TRACE_SMAPI, "smapi::smapi_set_DSP_cfg Disabling conflicting IR port\n"); @@ -431,6 +411,34 @@ #else goto exit_conflict; #endif + } else { + if ((usSI & 0xff) == uartio_index) { +#ifndef MWAVE_FUTZ_WITH_OTHER_DEVICES + PRINTK_ERROR(KERN_ERR_MWAVE + "smapi::smapi_set_DSP_cfg: IR port base I/O address %x conflicts with mwave uart I/O %x\n", ausUartBases[usSI & 0xff], ausUartBases[uartio_index]); +#else + PRINTK_3(TRACE_SMAPI, + "smapi::smapi_set_DSP_cfg: IR port base I/O address %x conflicts with mwave uart I/O %x\n", ausUartBases[usSI & 0xff], ausUartBases[uartio_index]); +#endif +#ifdef MWAVE_FUTZ_WITH_OTHER_DEVICES + PRINTK_1(TRACE_SMAPI, + "smapi::smapi_set_DSP_cfg Disabling conflicting IR port\n"); + bRC = smapi_request(0x1701, 0x0100, 0, 0, + &usAX, &usBX, &usCX, &usDX, &usDI, &usSI); + if (bRC) goto exit_smapi_request_error; + bRC = smapi_request(0x1700, 0, 0, 0, + &usAX, &usBX, &usCX, &usDX, &usDI, &usSI); + if (bRC) goto exit_smapi_request_error; + bRC = smapi_request(0x1705, 0x01ff, 0, usSI, + &usAX, &usBX, &usCX, &usDX, &usDI, &usSI); + if (bRC) goto exit_smapi_request_error; + bRC = smapi_request(0x1704, 0x0000, 0, 0, + &usAX, &usBX, &usCX, &usDX, &usDI, &usSI); + if (bRC) goto exit_smapi_request_error; +#else + goto exit_conflict; +#endif + } } } } diff -Nru a/drivers/char/n_tty.c b/drivers/char/n_tty.c --- a/drivers/char/n_tty.c Sun Mar 23 00:22:49 2003 +++ b/drivers/char/n_tty.c Sun Mar 23 00:22:49 2003 @@ -1029,7 +1029,11 @@ break; cs = tty->link->ctrl_status; tty->link->ctrl_status = 0; - put_user(cs, b++); + if (put_user(cs, b++)) { + retval = -EFAULT; + b--; + break; + } nr--; break; } @@ -1068,7 +1072,11 @@ /* Deal with packet mode. */ if (tty->packet && b == buf) { - put_user(TIOCPKT_DATA, b++); + if (put_user(TIOCPKT_DATA, b++)) { + retval = -EFAULT; + b--; + break; + } nr--; } @@ -1095,12 +1103,18 @@ spin_unlock_irqrestore(&tty->read_lock, flags); if (!eol || (c != __DISABLED_CHAR)) { - put_user(c, b++); + if (put_user(c, b++)) { + retval = -EFAULT; + b--; + break; + } nr--; } if (eol) break; } + if (retval) + break; } else { int uncopied; uncopied = copy_from_read_buf(tty, &b, &nr); diff -Nru a/drivers/char/nwflash.c b/drivers/char/nwflash.c --- a/drivers/char/nwflash.c Sun Mar 23 00:22:56 2003 +++ b/drivers/char/nwflash.c Sun Mar 23 00:22:56 2003 @@ -354,6 +354,7 @@ { volatile unsigned int c1; volatile unsigned char *pWritePtr; + unsigned long timeout; int temp, temp1; /* @@ -406,9 +407,9 @@ /* * wait while erasing in process (up to 10 sec) */ - temp = jiffies + 10 * HZ; + timeout = jiffies + 10 * HZ; c1 = 0; - while (!(c1 & 0x80) && time_before(jiffies, temp)) { + while (!(c1 & 0x80) && time_before(jiffies, timeout)) { flash_wait(HZ / 100); /* * read any address @@ -466,8 +467,8 @@ unsigned char *pWritePtr; unsigned int uAddress; unsigned int offset; - unsigned int timeout; - unsigned int timeout1; + unsigned long timeout; + unsigned long timeout1; /* * red LED == write diff -Nru a/drivers/char/raw.c b/drivers/char/raw.c --- a/drivers/char/raw.c Sun Mar 23 00:22:54 2003 +++ b/drivers/char/raw.c Sun Mar 23 00:22:54 2003 @@ -50,7 +50,7 @@ filp->f_op = &raw_ctl_fops; return 0; } - + down(&raw_mutex); /* @@ -70,10 +70,10 @@ } else { err = set_blocksize(bdev, bdev_hardsect_size(bdev)); if (err == 0) { - raw_devices[minor].inuse++; - filp->f_dentry->d_inode->i_mapping = - bdev->bd_inode->i_mapping; filp->f_flags |= O_DIRECT; + if (++raw_devices[minor].inuse == 1) + filp->f_dentry->d_inode->i_mapping = + bdev->bd_inode->i_mapping; } } } @@ -83,6 +83,10 @@ return err; } +/* + * When the final fd which refers to this character-special node is closed, we + * make its ->mapping point back at its own i_data. + */ static int raw_release(struct inode *inode, struct file *filp) { const int minor= minor(inode->i_rdev); @@ -90,13 +94,13 @@ down(&raw_mutex); bdev = raw_devices[minor].binding; - raw_devices[minor].inuse--; + if (--raw_devices[minor].inuse == 0) { + /* Here inode->i_mapping == bdev->bd_inode->i_mapping */ + inode->i_mapping = &inode->i_data; + inode->i_mapping->backing_dev_info = &default_backing_dev_info; + } up(&raw_mutex); - /* Here inode->i_mapping == bdev->bd_inode->i_mapping */ - inode->i_mapping = &inode->i_data; - inode->i_mapping->backing_dev_info = &default_backing_dev_info; - bd_release(bdev); blkdev_put(bdev, BDEV_RAW); return 0; @@ -118,27 +122,28 @@ * Deal with ioctls against the raw-device control interface, to bind * and unbind other raw devices. */ -static int -raw_ctl_ioctl(struct inode *inode, struct file *filp, - unsigned int command, unsigned long arg) +static int raw_ctl_ioctl(struct inode *inode, struct file *filp, + unsigned int command, unsigned long arg) { struct raw_config_request rq; struct raw_device_data *rawdev; - int err; - + int err = 0; + switch (command) { case RAW_SETBIND: case RAW_GETBIND: /* First, find out which raw minor we want */ - err = -EFAULT; - if (copy_from_user(&rq, (void *) arg, sizeof(rq))) + if (copy_from_user(&rq, (void *) arg, sizeof(rq))) { + err = -EFAULT; goto out; - - err = -EINVAL; - if (rq.raw_minor < 0 || rq.raw_minor >= MAX_RAW_MINORS) + } + + if (rq.raw_minor < 0 || rq.raw_minor >= MAX_RAW_MINORS) { + err = -EINVAL; goto out; + } rawdev = &raw_devices[rq.raw_minor]; if (command == RAW_SETBIND) { @@ -148,9 +153,10 @@ * This is like making block devices, so demand the * same capability */ - err = -EPERM; - if (!capable(CAP_SYS_ADMIN)) + if (!capable(CAP_SYS_ADMIN)) { + err = -EPERM; goto out; + } /* * For now, we don't need to check that the underlying @@ -159,17 +165,18 @@ * major/minor numbers make sense. */ - err = -EINVAL; dev = MKDEV(rq.block_major, rq.block_minor); if ((rq.block_major == 0 && rq.block_minor != 0) || - MAJOR(dev) != rq.block_major || - MINOR(dev) != rq.block_minor) + MAJOR(dev) != rq.block_major || + MINOR(dev) != rq.block_minor) { + err = -EINVAL; goto out; - + } + down(&raw_mutex); - err = -EBUSY; if (rawdev->inuse) { up(&raw_mutex); + err = -EBUSY; goto out; } if (rawdev->binding) { @@ -181,7 +188,10 @@ rawdev->binding = NULL; } else { rawdev->binding = bdget(dev); - MOD_INC_USE_COUNT; + if (rawdev->binding == NULL) + err = -ENOMEM; + else + try_module_get(THIS_MODULE); } up(&raw_mutex); } else { @@ -196,13 +206,12 @@ rq.block_major = rq.block_minor = 0; } up(&raw_mutex); - err = -EFAULT; - if (copy_to_user((void *)arg, &rq, sizeof(rq))) + if (copy_to_user((void *)arg, &rq, sizeof(rq))) { + err = -EFAULT; goto out; + } } - err = 0; break; - default: err = -EINVAL; break; diff -Nru a/drivers/char/rio/rioboot.c b/drivers/char/rio/rioboot.c --- a/drivers/char/rio/rioboot.c Sun Mar 23 00:22:51 2003 +++ b/drivers/char/rio/rioboot.c Sun Mar 23 00:22:51 2003 @@ -34,7 +34,6 @@ static char *_rioboot_c_sccs_ = "@(#)rioboot.c 1.3"; #endif -#define __NO_VERSION__ #include #include #include diff -Nru a/drivers/char/rio/riocmd.c b/drivers/char/rio/riocmd.c --- a/drivers/char/rio/riocmd.c Sun Mar 23 00:22:52 2003 +++ b/drivers/char/rio/riocmd.c Sun Mar 23 00:22:52 2003 @@ -34,7 +34,6 @@ static char *_riocmd_c_sccs_ = "@(#)riocmd.c 1.2"; #endif -#define __NO_VERSION__ #include #include #include diff -Nru a/drivers/char/rio/rioctrl.c b/drivers/char/rio/rioctrl.c --- a/drivers/char/rio/rioctrl.c Sun Mar 23 00:22:52 2003 +++ b/drivers/char/rio/rioctrl.c Sun Mar 23 00:22:52 2003 @@ -34,7 +34,6 @@ #endif -#define __NO_VERSION__ #include #include #include diff -Nru a/drivers/char/rio/rioinit.c b/drivers/char/rio/rioinit.c --- a/drivers/char/rio/rioinit.c Sun Mar 23 00:22:51 2003 +++ b/drivers/char/rio/rioinit.c Sun Mar 23 00:22:51 2003 @@ -33,7 +33,6 @@ static char *_rioinit_c_sccs_ = "@(#)rioinit.c 1.3"; #endif -#define __NO_VERSION__ #include #include #include diff -Nru a/drivers/char/rio/riointr.c b/drivers/char/rio/riointr.c --- a/drivers/char/rio/riointr.c Sun Mar 23 00:22:49 2003 +++ b/drivers/char/rio/riointr.c Sun Mar 23 00:22:49 2003 @@ -34,7 +34,6 @@ #endif -#define __NO_VERSION__ #include #include #include diff -Nru a/drivers/char/rio/rioparam.c b/drivers/char/rio/rioparam.c --- a/drivers/char/rio/rioparam.c Sun Mar 23 00:22:57 2003 +++ b/drivers/char/rio/rioparam.c Sun Mar 23 00:22:57 2003 @@ -34,7 +34,6 @@ static char *_rioparam_c_sccs_ = "@(#)rioparam.c 1.3"; #endif -#define __NO_VERSION__ #include #include #include diff -Nru a/drivers/char/rio/rioroute.c b/drivers/char/rio/rioroute.c --- a/drivers/char/rio/rioroute.c Sun Mar 23 00:22:53 2003 +++ b/drivers/char/rio/rioroute.c Sun Mar 23 00:22:53 2003 @@ -33,7 +33,6 @@ static char *_rioroute_c_sccs_ = "@(#)rioroute.c 1.3"; #endif -#define __NO_VERSION__ #include #include #include diff -Nru a/drivers/char/rio/riotable.c b/drivers/char/rio/riotable.c --- a/drivers/char/rio/riotable.c Sun Mar 23 00:22:55 2003 +++ b/drivers/char/rio/riotable.c Sun Mar 23 00:22:55 2003 @@ -33,7 +33,6 @@ static char *_riotable_c_sccs_ = "@(#)riotable.c 1.2"; #endif -#define __NO_VERSION__ #include #include #include diff -Nru a/drivers/char/rio/riotty.c b/drivers/char/rio/riotty.c --- a/drivers/char/rio/riotty.c Sun Mar 23 00:22:52 2003 +++ b/drivers/char/rio/riotty.c Sun Mar 23 00:22:52 2003 @@ -36,7 +36,6 @@ #define __EXPLICIT_DEF_H__ -#define __NO_VERSION__ #include #include #include diff -Nru a/drivers/char/rtc.c b/drivers/char/rtc.c --- a/drivers/char/rtc.c Sun Mar 23 00:22:52 2003 +++ b/drivers/char/rtc.c Sun Mar 23 00:22:52 2003 @@ -47,7 +47,7 @@ #define RTC_VERSION "1.11" -#define RTC_IO_EXTENT 0x10 /* Only really two ports, but... */ +#define RTC_IO_EXTENT 0x8 /* * Note that *all* calls to CMOS_READ and CMOS_WRITE are done with diff -Nru a/drivers/char/serial167.c b/drivers/char/serial167.c --- a/drivers/char/serial167.c Sun Mar 23 00:22:52 2003 +++ b/drivers/char/serial167.c Sun Mar 23 00:22:52 2003 @@ -2836,7 +2836,7 @@ }; -static void __init serial167_console_init(void) +static int __init serial167_console_init(void) { if (vme_brdtype == VME_TYPE_MVME166 || vme_brdtype == VME_TYPE_MVME167 || @@ -2844,6 +2844,7 @@ mvme167_serial_console_setup(0); register_console(&sercons); } + return 0; } console_initcall(serial167_console_init); diff -Nru a/drivers/char/serial_tx3912.c b/drivers/char/serial_tx3912.c --- a/drivers/char/serial_tx3912.c Sun Mar 23 00:22:53 2003 +++ b/drivers/char/serial_tx3912.c Sun Mar 23 00:22:53 2003 @@ -1054,9 +1054,10 @@ .index = -1 }; -static void __init tx3912_console_init(void) +static int __init tx3912_console_init(void) { register_console(&sercons); + return 0; } console_initcall(tx3912_console_init); diff -Nru a/drivers/char/sh-sci.c b/drivers/char/sh-sci.c --- a/drivers/char/sh-sci.c Sun Mar 23 00:22:56 2003 +++ b/drivers/char/sh-sci.c Sun Mar 23 00:22:56 2003 @@ -1275,7 +1275,7 @@ extern void sh_console_unregister (void); #endif -static void __init sci_console_init(void) +static int __init sci_console_init(void) { register_console(&sercons); #ifdef CONFIG_SH_EARLY_PRINTK @@ -1284,6 +1284,7 @@ */ sh_console_unregister(); #endif + return 0; } console_initcall(sci_console_init); diff -Nru a/drivers/char/tty_io.c b/drivers/char/tty_io.c --- a/drivers/char/tty_io.c Sun Mar 23 00:22:53 2003 +++ b/drivers/char/tty_io.c Sun Mar 23 00:22:53 2003 @@ -1034,7 +1034,9 @@ } o_tty->magic = 0; (*o_tty->driver.refcount)--; + file_list_lock(); list_del(&o_tty->tty_files); + file_list_unlock(); free_tty_struct(o_tty); } @@ -1046,7 +1048,9 @@ } tty->magic = 0; (*tty->driver.refcount)--; + file_list_lock(); list_del(&tty->tty_files); + file_list_unlock(); module_put(tty->driver.owner); free_tty_struct(tty); } @@ -2114,7 +2118,8 @@ if (driver->flags & TTY_DRIVER_INSTALLED) return 0; - error = register_chrdev(driver->major, driver->name, &tty_fops); + error = register_chrdev_region(driver->major, driver->minor_start, + driver->num, driver->name, &tty_fops); if (error < 0) return error; else if(driver->major == 0) diff -Nru a/drivers/char/upd4990a.c b/drivers/char/upd4990a.c --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/drivers/char/upd4990a.c Sun Mar 23 00:22:57 2003 @@ -0,0 +1,423 @@ +/* + * NEC PC-9800 Real Time Clock interface for Linux + * + * Copyright (C) 1997-2001 Linux/98 project, + * Kyoto University Microcomputer Club. + * + * Based on: + * drivers/char/rtc.c by Paul Gortmaker + * + * Changes: + * 2001-02-09 Call check_region on rtc_init and do not request I/O 0033h. + * Call del_timer and release_region on rtc_exit. -- tak + * 2001-07-14 Rewrite and split to + * and . + * Introduce a lot of spin_lock/unlock (&rtc_lock). + */ + +#define RTC98_VERSION "1.2" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +/* + * We sponge a minor off of the misc major. No need slurping + * up another valuable major dev number for this. If you add + * an ioctl, make sure you don't conflict with SPARC's RTC + * ioctls. + */ + +static struct fasync_struct *rtc_async_queue; + +static DECLARE_WAIT_QUEUE_HEAD(rtc_wait); + +static struct timer_list rtc_uie_timer; +static u8 old_refclk; + +static int rtc_ioctl(struct inode *inode, struct file *file, + unsigned int cmd, unsigned long arg); + +static int rtc_read_proc(char *page, char **start, off_t off, + int count, int *eof, void *data); + +/* + * Bits in rtc_status. (5 bits of room for future expansion) + */ + +#define RTC_IS_OPEN 0x01 /* means /dev/rtc is in use */ +#define RTC_TIMER_ON 0x02 /* not used */ +#define RTC_UIE_TIMER_ON 0x04 /* UIE emulation timer is active */ + +/* + * rtc_status is never changed by rtc_interrupt, and ioctl/open/close is + * protected by the big kernel lock. However, ioctl can still disable the timer + * in rtc_status and then with del_timer after the interrupt has read + * rtc_status but before mod_timer is called, which would then reenable the + * timer (but you would need to have an awful timing before you'd trip on it) + */ +static unsigned char rtc_status; /* bitmapped status byte. */ +static unsigned long rtc_irq_data; /* our output to the world */ + +static const unsigned char days_in_mo[] = +{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + +extern spinlock_t rtc_lock; /* defined in arch/i386/kernel/time.c */ + +static void rtc_uie_intr(unsigned long data) +{ + u8 refclk, tmp; + + /* Kernel timer does del_timer internally before calling + each timer entry, so this is unnecessary. + del_timer(&rtc_uie_timer); */ + spin_lock(&rtc_lock); + + /* Detect rising edge of 1Hz reference clock. */ + refclk = UPD4990A_READ_DATA(); + tmp = old_refclk & refclk; + old_refclk = ~refclk; + if (!(tmp & 1)) + rtc_irq_data += 0x100; + + spin_unlock(&rtc_lock); + + if (!(tmp & 1)) { + /* Now do the rest of the actions */ + wake_up_interruptible(&rtc_wait); + kill_fasync(&rtc_async_queue, SIGIO, POLL_IN); + } + + rtc_uie_timer.expires = jiffies + 1; + add_timer(&rtc_uie_timer); +} + +/* + * Now all the various file operations that we export. + */ + +static ssize_t rtc_read(struct file *file, char *buf, + size_t count, loff_t *ppos) +{ + DECLARE_WAITQUEUE(wait, current); + unsigned long data; + ssize_t retval = 0; + + if (count < sizeof(unsigned long)) + return -EINVAL; + + add_wait_queue(&rtc_wait, &wait); + + set_current_state(TASK_INTERRUPTIBLE); + + do { + /* First make it right. Then make it fast. Putting this whole + * block within the parentheses of a while would be too + * confusing. And no, xchg() is not the answer. */ + spin_lock_irq(&rtc_lock); + data = rtc_irq_data; + rtc_irq_data = 0; + spin_unlock_irq(&rtc_lock); + + if (data != 0) + break; + if (file->f_flags & O_NONBLOCK) { + retval = -EAGAIN; + goto out; + } + if (signal_pending(current)) { + retval = -ERESTARTSYS; + goto out; + } + schedule(); + } while (1); + + retval = put_user(data, (unsigned long *)buf); + if (!retval) + retval = sizeof(unsigned long); + out: + set_current_state(TASK_RUNNING); + remove_wait_queue(&rtc_wait, &wait); + + return retval; +} + +static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, + unsigned long arg) +{ + struct rtc_time wtime; + struct upd4990a_raw_data raw; + + switch (cmd) { + case RTC_UIE_OFF: /* Mask ints from RTC updates. */ + spin_lock_irq(&rtc_lock); + if (rtc_status & RTC_UIE_TIMER_ON) { + rtc_status &= ~RTC_UIE_TIMER_ON; + del_timer(&rtc_uie_timer); + } + spin_unlock_irq(&rtc_lock); + return 0; + + case RTC_UIE_ON: /* Allow ints for RTC updates. */ + spin_lock_irq(&rtc_lock); + rtc_irq_data = 0; + if (!(rtc_status & RTC_UIE_TIMER_ON)) { + rtc_status |= RTC_UIE_TIMER_ON; + rtc_uie_timer.expires = jiffies + 1; + add_timer(&rtc_uie_timer); + } + /* Just in case... */ + upd4990a_serial_command(UPD4990A_REGISTER_HOLD); + old_refclk = ~UPD4990A_READ_DATA(); + spin_unlock_irq(&rtc_lock); + return 0; + + case RTC_RD_TIME: /* Read the time/date from RTC */ + spin_lock_irq(&rtc_lock); + upd4990a_get_time(&raw, 0); + spin_unlock_irq(&rtc_lock); + + wtime.tm_sec = BCD2BIN(raw.sec); + wtime.tm_min = BCD2BIN(raw.min); + wtime.tm_hour = BCD2BIN(raw.hour); + wtime.tm_mday = BCD2BIN(raw.mday); + wtime.tm_mon = raw.mon - 1; /* convert to 0-base */ + wtime.tm_wday = raw.wday; + + /* + * Account for differences between how the RTC uses the values + * and how they are defined in a struct rtc_time; + */ + if ((wtime.tm_year = BCD2BIN(raw.year)) < 95) + wtime.tm_year += 100; + + wtime.tm_isdst = 0; + break; + + case RTC_SET_TIME: /* Set the RTC */ + { + int leap_yr; + + if (!capable(CAP_SYS_TIME)) + return -EACCES; + + if (copy_from_user(&wtime, (struct rtc_time *) arg, + sizeof (struct rtc_time))) + return -EFAULT; + + /* Valid year is 1995 - 2094, inclusive. */ + if (wtime.tm_year < 95 || wtime.tm_year > 194) + return -EINVAL; + + if (wtime.tm_mon > 11 || wtime.tm_mday == 0) + return -EINVAL; + + /* For acceptable year domain (1995 - 2094), + this IS sufficient. */ + leap_yr = !(wtime.tm_year % 4); + + if (wtime.tm_mday > (days_in_mo[wtime.tm_mon] + + (wtime.tm_mon == 2 && leap_yr))) + return -EINVAL; + + if (wtime.tm_hour >= 24 + || wtime.tm_min >= 60 || wtime.tm_sec >= 60) + return -EINVAL; + + if (wtime.tm_wday > 6) + return -EINVAL; + + raw.sec = BIN2BCD(wtime.tm_sec); + raw.min = BIN2BCD(wtime.tm_min); + raw.hour = BIN2BCD(wtime.tm_hour); + raw.mday = BIN2BCD(wtime.tm_mday); + raw.mon = wtime.tm_mon + 1; + raw.wday = wtime.tm_wday; + raw.year = BIN2BCD(wtime.tm_year % 100); + + spin_lock_irq(&rtc_lock); + upd4990a_set_time(&raw, 0); + spin_unlock_irq(&rtc_lock); + + return 0; + } + default: + return -EINVAL; + } + return copy_to_user((void *)arg, &wtime, sizeof wtime) ? -EFAULT : 0; +} + +/* + * We enforce only one user at a time here with the open/close. + * Also clear the previous interrupt data on an open, and clean + * up things on a close. + */ + +static int rtc_open(struct inode *inode, struct file *file) +{ + spin_lock_irq(&rtc_lock); + + if(rtc_status & RTC_IS_OPEN) + goto out_busy; + + rtc_status |= RTC_IS_OPEN; + + rtc_irq_data = 0; + spin_unlock_irq(&rtc_lock); + return 0; + + out_busy: + spin_unlock_irq(&rtc_lock); + return -EBUSY; +} + +static int rtc_fasync(int fd, struct file *filp, int on) +{ + return fasync_helper(fd, filp, on, &rtc_async_queue); +} + +static int rtc_release(struct inode *inode, struct file *file) +{ + del_timer(&rtc_uie_timer); + + if (file->f_flags & FASYNC) + rtc_fasync(-1, file, 0); + + rtc_irq_data = 0; + + /* No need for locking -- nobody else can do anything until this rmw is + * committed, and no timer is running. */ + rtc_status &= ~(RTC_IS_OPEN | RTC_UIE_TIMER_ON); + return 0; +} + +static unsigned int rtc_poll(struct file *file, poll_table *wait) +{ + unsigned long l; + + poll_wait(file, &rtc_wait, wait); + + spin_lock_irq(&rtc_lock); + l = rtc_irq_data; + spin_unlock_irq(&rtc_lock); + + if (l != 0) + return POLLIN | POLLRDNORM; + return 0; +} + +/* + * The various file operations we support. + */ + +static struct file_operations rtc_fops = { + .owner = THIS_MODULE, + .read = rtc_read, + .poll = rtc_poll, + .ioctl = rtc_ioctl, + .open = rtc_open, + .release = rtc_release, + .fasync = rtc_fasync, +}; + +static struct miscdevice rtc_dev= +{ + .minor = RTC_MINOR, + .name = "rtc", + .fops = &rtc_fops, +}; + +static int __init rtc_init(void) +{ + if (!request_region(UPD4990A_IO, 1, "rtc")) { + printk(KERN_ERR "upd4990a: could not acquire I/O port %#x\n", + UPD4990A_IO); + return -EBUSY; + } + +#if 0 + printk(KERN_INFO "\xB6\xDA\xDD\xC0\xDE \xC4\xDE\xB9\xB2 Driver\n"); /* Calender Clock Driver */ +#else + printk(KERN_INFO + "Real Time Clock driver for NEC PC-9800 v" RTC98_VERSION "\n"); +#endif + misc_register(&rtc_dev); + create_proc_read_entry("driver/rtc", 0, NULL, rtc_read_proc, NULL); + + init_timer(&rtc_uie_timer); + rtc_uie_timer.function = rtc_uie_intr; + + return 0; +} + +module_init (rtc_init); + +static void __exit rtc_exit(void) +{ + del_timer(&rtc_uie_timer); + release_region(UPD4990A_IO, 1); + remove_proc_entry("driver/rtc", NULL); + misc_deregister(&rtc_dev); +} + +module_exit (rtc_exit); + +/* + * Info exported via "/proc/driver/rtc". + */ + +static inline int rtc_get_status(char *buf) +{ + char *p; + unsigned int year; + struct upd4990a_raw_data data; + + p = buf; + + upd4990a_get_time(&data, 0); + + /* + * There is no way to tell if the luser has the RTC set for local + * time or for Universal Standard Time (GMT). Probably local though. + */ + if ((year = BCD2BIN(data.year) + 1900) < 1995) + year += 100; + p += sprintf(p, + "rtc_time\t: %02d:%02d:%02d\n" + "rtc_date\t: %04d-%02d-%02d\n", + BCD2BIN(data.hour), BCD2BIN(data.min), + BCD2BIN(data.sec), + year, data.mon, BCD2BIN(data.mday)); + + return p - buf; +} + +static int rtc_read_proc(char *page, char **start, off_t off, + int count, int *eof, void *data) +{ + int len = rtc_get_status(page); + + if (len <= off + count) + *eof = 1; + *start = page + off; + len -= off; + if (len > count) + len = count; + if (len < 0) + len = 0; + return len; +} diff -Nru a/drivers/char/vme_scc.c b/drivers/char/vme_scc.c --- a/drivers/char/vme_scc.c Sun Mar 23 00:22:49 2003 +++ b/drivers/char/vme_scc.c Sun Mar 23 00:22:49 2003 @@ -1091,7 +1091,7 @@ }; -static void __init vme_scc_console_init(void) +static int __init vme_scc_console_init(void) { if (vme_brdtype == VME_TYPE_MVME147 || vme_brdtype == VME_TYPE_MVME162 || @@ -1099,5 +1099,6 @@ vme_brdtype == VME_TYPE_BVME4000 || vme_brdtype == VME_TYPE_BVME6000) register_console(&sercons); + return 0; } console_initcall(vme_scc_console_init); diff -Nru a/drivers/char/vt.c b/drivers/char/vt.c --- a/drivers/char/vt.c Sun Mar 23 00:22:55 2003 +++ b/drivers/char/vt.c Sun Mar 23 00:22:55 2003 @@ -792,6 +792,7 @@ memset(&ws, 0, sizeof(ws)); ws.ws_row = video_num_lines; ws.ws_col = video_num_columns; + ws.ws_ypixel = video_scan_lines; if ((ws.ws_row != cws->ws_row || ws.ws_col != cws->ws_col) && vc_cons[currcons].d->vc_tty->pgrp > 0) kill_pg(vc_cons[currcons].d->vc_tty->pgrp, SIGWINCH, 1); @@ -3040,8 +3041,6 @@ EXPORT_SYMBOL(default_red); EXPORT_SYMBOL(default_grn); EXPORT_SYMBOL(default_blu); -EXPORT_SYMBOL(video_font_height); -EXPORT_SYMBOL(video_scan_lines); EXPORT_SYMBOL(vc_cons_allocated); EXPORT_SYMBOL(update_region); EXPORT_SYMBOL(redraw_screen); diff -Nru a/drivers/char/vt_ioctl.c b/drivers/char/vt_ioctl.c --- a/drivers/char/vt_ioctl.c Sun Mar 23 00:22:54 2003 +++ b/drivers/char/vt_ioctl.c Sun Mar 23 00:22:54 2003 @@ -63,10 +63,6 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int on); #endif -unsigned int video_font_height; -unsigned int default_font_height; -unsigned int video_scan_lines; - /* * these are the valid i/o ports we're allowed to change. they map all the * video ports @@ -191,38 +187,56 @@ static inline int do_kdgkb_ioctl(int cmd, struct kbsentry *user_kdgkb, int perm) { - struct kbsentry tmp; + struct kbsentry *kbs; char *p; u_char *q; int sz; int delta; char *first_free, *fj, *fnw; int i, j, k; + int ret; + + kbs = kmalloc(sizeof(*kbs), GFP_KERNEL); + if (!kbs) { + ret = -ENOMEM; + goto reterr; + } /* we mostly copy too much here (512bytes), but who cares ;) */ - if (copy_from_user(&tmp, user_kdgkb, sizeof(struct kbsentry))) - return -EFAULT; - tmp.kb_string[sizeof(tmp.kb_string)-1] = '\0'; - if (tmp.kb_func >= MAX_NR_FUNC) - return -EINVAL; - i = tmp.kb_func; + if (copy_from_user(kbs, user_kdgkb, sizeof(struct kbsentry))) { + ret = -EFAULT; + goto reterr; + } + kbs->kb_string[sizeof(kbs->kb_string)-1] = '\0'; + if (kbs->kb_func >= MAX_NR_FUNC) { + ret = -EINVAL; + goto reterr; + } + i = kbs->kb_func; switch (cmd) { case KDGKBSENT: - sz = sizeof(tmp.kb_string) - 1; /* sz should have been + sz = sizeof(kbs->kb_string) - 1; /* sz should have been a struct member */ q = user_kdgkb->kb_string; p = func_table[i]; if(p) for ( ; *p && sz; p++, sz--) - if (put_user(*p, q++)) - return -EFAULT; - if (put_user('\0', q)) - return -EFAULT; + if (put_user(*p, q++)) { + ret = -EFAULT; + goto reterr; + } + if (put_user('\0', q)) { + ret = -EFAULT; + goto reterr; + } + kfree(kbs); return ((p && *p) ? -EOVERFLOW : 0); case KDSKBSENT: - if (!perm) - return -EPERM; + if (!perm) { + ret = -EPERM; + goto reterr; + } q = func_table[i]; first_free = funcbufptr + (funcbufsize - funcbufleft); @@ -233,7 +247,7 @@ else fj = first_free; - delta = (q ? -strlen(q) : 1) + strlen(tmp.kb_string); + delta = (q ? -strlen(q) : 1) + strlen(kbs->kb_string); if (delta <= funcbufleft) { /* it fits in current buf */ if (j < MAX_NR_FUNC) { memmove(fj + delta, fj, first_free - fj); @@ -249,8 +263,10 @@ while (sz < funcbufsize - funcbufleft + delta) sz <<= 1; fnw = (char *) kmalloc(sz, GFP_KERNEL); - if(!fnw) - return -ENOMEM; + if(!fnw) { + ret = -ENOMEM; + goto reterr; + } if (!q) func_table[i] = fj; @@ -272,17 +288,19 @@ funcbufleft = funcbufleft - delta + sz - funcbufsize; funcbufsize = sz; } - strcpy(func_table[i], tmp.kb_string); + strcpy(func_table[i], kbs->kb_string); break; } - return 0; + ret = 0; +reterr: + kfree(kbs); + return ret; } static inline int -do_fontx_ioctl(int cmd, struct consolefontdesc *user_cfd, int perm) +do_fontx_ioctl(int cmd, struct consolefontdesc *user_cfd, int perm, struct console_font_op *op) { struct consolefontdesc cfdarg; - struct console_font_op op; int i; if (copy_from_user(&cfdarg, user_cfd, sizeof(struct consolefontdesc))) @@ -292,25 +310,25 @@ case PIO_FONTX: if (!perm) return -EPERM; - op.op = KD_FONT_OP_SET; - op.flags = KD_FONT_FLAG_OLD; - op.width = 8; - op.height = cfdarg.charheight; - op.charcount = cfdarg.charcount; - op.data = cfdarg.chardata; - return con_font_op(fg_console, &op); + op->op = KD_FONT_OP_SET; + op->flags = KD_FONT_FLAG_OLD; + op->width = 8; + op->height = cfdarg.charheight; + op->charcount = cfdarg.charcount; + op->data = cfdarg.chardata; + return con_font_op(fg_console, op); case GIO_FONTX: { - op.op = KD_FONT_OP_GET; - op.flags = KD_FONT_FLAG_OLD; - op.width = 8; - op.height = cfdarg.charheight; - op.charcount = cfdarg.charcount; - op.data = cfdarg.chardata; - i = con_font_op(fg_console, &op); + op->op = KD_FONT_OP_GET; + op->flags = KD_FONT_FLAG_OLD; + op->width = 8; + op->height = cfdarg.charheight; + op->charcount = cfdarg.charcount; + op->data = cfdarg.chardata; + i = con_font_op(fg_console, op); if (i) return i; - cfdarg.charheight = op.height; - cfdarg.charcount = op.charcount; + cfdarg.charheight = op->height; + cfdarg.charcount = op->charcount; if (copy_to_user(user_cfd, &cfdarg, sizeof(struct consolefontdesc))) return -EFAULT; return 0; @@ -350,12 +368,14 @@ int vt_ioctl(struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg) { - int i, perm; + struct vt_struct *vt = (struct vt_struct *)tty->driver_data; + struct vc_data *vc = vc_cons[vt->vc_num].d; + struct console_font_op op; /* used in multiple places here */ + struct kbd_struct * kbd; unsigned int console; unsigned char ucval; - struct kbd_struct * kbd; - struct vt_struct *vt = (struct vt_struct *)tty->driver_data; - + int i, perm; + console = vt->vc_num; if (!vc_cons_allocated(console)) /* impossible? */ @@ -830,7 +850,7 @@ __get_user(clin, &vtconsize->v_clin); __get_user(vcol, &vtconsize->v_vcol); __get_user(ccol, &vtconsize->v_ccol); - vlin = vlin ? vlin : video_scan_lines; + vlin = vlin ? vlin : vc->vc_scan_lines; if (clin) { if (ll) { if (ll != vlin/clin) @@ -850,9 +870,9 @@ return -EINVAL; if (vlin) - video_scan_lines = vlin; + vc->vc_scan_lines = vlin; if (clin) - video_font_height = clin; + vc->vc_font.height = clin; for (i = 0; i < MAX_NR_CONSOLES; i++) vc_resize(i, cc, ll); @@ -860,7 +880,6 @@ } case PIO_FONT: { - struct console_font_op op; if (!perm) return -EPERM; op.op = KD_FONT_OP_SET; @@ -873,7 +892,6 @@ } case GIO_FONT: { - struct console_font_op op; op.op = KD_FONT_OP_GET; op.flags = KD_FONT_FLAG_OLD; op.width = 8; @@ -893,7 +911,7 @@ case PIO_FONTX: case GIO_FONTX: - return do_fontx_ioctl(cmd, (struct consolefontdesc *)arg, perm); + return do_fontx_ioctl(cmd, (struct consolefontdesc *)arg, perm, &op); case PIO_FONTRESET: { @@ -906,7 +924,6 @@ return -ENOSYS; #else { - struct console_font_op op; op.op = KD_FONT_OP_SET_DEFAULT; op.data = NULL; i = con_font_op(fg_console, &op); @@ -918,7 +935,6 @@ } case KDFONTOP: { - struct console_font_op op; if (copy_from_user(&op, (void *) arg, sizeof(op))) return -EFAULT; if (!perm && op.op != KD_FONT_OP_GET) diff -Nru a/drivers/char/watchdog/acquirewdt.c b/drivers/char/watchdog/acquirewdt.c --- a/drivers/char/watchdog/acquirewdt.c Sun Mar 23 00:22:54 2003 +++ b/drivers/char/watchdog/acquirewdt.c Sun Mar 23 00:22:54 2003 @@ -141,6 +141,8 @@ spin_unlock(&acq_lock); return -EBUSY; } + if (nowayout) + MOD_INC_USE_COUNT; /* Activate */ acq_is_open=1; diff -Nru a/drivers/char/watchdog/ib700wdt.c b/drivers/char/watchdog/ib700wdt.c --- a/drivers/char/watchdog/ib700wdt.c Sun Mar 23 00:22:55 2003 +++ b/drivers/char/watchdog/ib700wdt.c Sun Mar 23 00:22:55 2003 @@ -228,6 +228,8 @@ spin_unlock(&ibwdt_lock); return -EBUSY; } + if (nowayout) + MOD_INC_USE_COUNT; /* Activate */ ibwdt_is_open = 1; diff -Nru a/drivers/char/watchdog/indydog.c b/drivers/char/watchdog/indydog.c --- a/drivers/char/watchdog/indydog.c Sun Mar 23 00:22:55 2003 +++ b/drivers/char/watchdog/indydog.c Sun Mar 23 00:22:55 2003 @@ -53,6 +53,9 @@ if( test_and_set_bit(0,&indydog_alive) ) return -EBUSY; + if (nowayout) + MOD_INC_USE_COUNT; + /* * Activate timer */ diff -Nru a/drivers/char/watchdog/machzwd.c b/drivers/char/watchdog/machzwd.c --- a/drivers/char/watchdog/machzwd.c Sun Mar 23 00:22:51 2003 +++ b/drivers/char/watchdog/machzwd.c Sun Mar 23 00:22:51 2003 @@ -390,6 +390,9 @@ return -EBUSY; } + if (nowayout) + MOD_INC_USE_COUNT; + zf_is_open = 1; spin_unlock(&zf_lock); diff -Nru a/drivers/char/watchdog/mixcomwd.c b/drivers/char/watchdog/mixcomwd.c --- a/drivers/char/watchdog/mixcomwd.c Sun Mar 23 00:22:51 2003 +++ b/drivers/char/watchdog/mixcomwd.c Sun Mar 23 00:22:51 2003 @@ -93,7 +93,9 @@ } mixcomwd_ping(); - if (!nowayout) { + if (nowayout) { + MOD_INC_USE_COUNT; + } else { if(mixcomwd_timer_alive) { del_timer(&mixcomwd_timer); mixcomwd_timer_alive=0; diff -Nru a/drivers/char/watchdog/pcwd.c b/drivers/char/watchdog/pcwd.c --- a/drivers/char/watchdog/pcwd.c Sun Mar 23 00:22:50 2003 +++ b/drivers/char/watchdog/pcwd.c Sun Mar 23 00:22:50 2003 @@ -430,7 +430,7 @@ atomic_inc( &open_allowed ); return -EBUSY; } - + MOD_INC_USE_COUNT; /* Enable the port */ if (revision == PCWD_REVISION_C) { spin_lock(&io_lock); diff -Nru a/drivers/char/watchdog/sbc60xxwdt.c b/drivers/char/watchdog/sbc60xxwdt.c --- a/drivers/char/watchdog/sbc60xxwdt.c Sun Mar 23 00:22:54 2003 +++ b/drivers/char/watchdog/sbc60xxwdt.c Sun Mar 23 00:22:54 2003 @@ -206,7 +206,9 @@ /* Just in case we're already talking to someone... */ if(wdt_is_open) return -EBUSY; - + if (nowayout) { + MOD_INC_USE_COUNT; + } /* Good, fire up the show */ wdt_is_open = 1; wdt_startup(); diff -Nru a/drivers/char/watchdog/sc520_wdt.c b/drivers/char/watchdog/sc520_wdt.c --- a/drivers/char/watchdog/sc520_wdt.c Sun Mar 23 00:22:53 2003 +++ b/drivers/char/watchdog/sc520_wdt.c Sun Mar 23 00:22:53 2003 @@ -229,6 +229,8 @@ return -EBUSY; /* Good, fire up the show */ wdt_startup(); + if (nowayout) + MOD_INC_USE_COUNT; return 0; default: diff -Nru a/drivers/char/watchdog/shwdt.c b/drivers/char/watchdog/shwdt.c --- a/drivers/char/watchdog/shwdt.c Sun Mar 23 00:22:52 2003 +++ b/drivers/char/watchdog/shwdt.c Sun Mar 23 00:22:52 2003 @@ -189,6 +189,10 @@ if (test_and_set_bit(0, &sh_is_open)) return -EBUSY; + if (nowayout) { + MOD_INC_USE_COUNT; + } + sh_wdt_start(); break; diff -Nru a/drivers/char/watchdog/softdog.c b/drivers/char/watchdog/softdog.c --- a/drivers/char/watchdog/softdog.c Sun Mar 23 00:22:52 2003 +++ b/drivers/char/watchdog/softdog.c Sun Mar 23 00:22:52 2003 @@ -103,7 +103,9 @@ { if(test_and_set_bit(0, &timer_alive)) return -EBUSY; - + if (nowayout) { + MOD_INC_USE_COUNT; + } /* * Activate timer */ diff -Nru a/drivers/char/watchdog/wdt977.c b/drivers/char/watchdog/wdt977.c --- a/drivers/char/watchdog/wdt977.c Sun Mar 23 00:22:55 2003 +++ b/drivers/char/watchdog/wdt977.c Sun Mar 23 00:22:55 2003 @@ -99,6 +99,8 @@ if (nowayout) { + MOD_INC_USE_COUNT; + /* do not permit disabling the watchdog by writing 0 to reg. 0xF2 */ if (!timeoutM) timeoutM = DEFAULT_TIMEOUT; } diff -Nru a/drivers/char/watchdog/wdt_pci.c b/drivers/char/watchdog/wdt_pci.c --- a/drivers/char/watchdog/wdt_pci.c Sun Mar 23 00:22:54 2003 +++ b/drivers/char/watchdog/wdt_pci.c Sun Mar 23 00:22:54 2003 @@ -365,6 +365,9 @@ if (down_trylock(&open_sem)) return -EBUSY; + if (nowayout) { + MOD_INC_USE_COUNT; + } /* * Activate */ diff -Nru a/drivers/eisa/eisa-bus.c b/drivers/eisa/eisa-bus.c --- a/drivers/eisa/eisa-bus.c Sun Mar 23 00:22:51 2003 +++ b/drivers/eisa/eisa-bus.c Sun Mar 23 00:22:51 2003 @@ -191,7 +191,7 @@ eisa_register_device (root, str, i); } } - printk (KERN_INFO "EISA: Detected %d card%s.\n", c, c < 2 ? "" : "s"); + printk (KERN_INFO "EISA: Detected %d card%s.\n", c, c == 1 ? "" : "s"); return 0; } diff -Nru a/drivers/fc4/fc_syms.c b/drivers/fc4/fc_syms.c --- a/drivers/fc4/fc_syms.c Sun Mar 23 00:22:55 2003 +++ b/drivers/fc4/fc_syms.c Sun Mar 23 00:22:55 2003 @@ -2,7 +2,6 @@ * We should not even be trying to compile this if we are not doing * a module. */ -#define __NO_VERSION__ #include #include diff -Nru a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig --- a/drivers/i2c/busses/Kconfig Sun Mar 23 00:22:55 2003 +++ b/drivers/i2c/busses/Kconfig Sun Mar 23 00:22:55 2003 @@ -76,6 +76,24 @@ in the lm_sensors package, which you can download at http://www.lm-sensors.nu +config I2C_ISA + tristate " ISA Bus support" + depends on I2C && I2C_PROC && ISA && EXPERIMENTAL + help + If you say yes to this option, support will be included for i2c + interfaces that are on the ISA bus. + + This can also be built as a module which can be inserted and removed + while the kernel is running. If you want to compile it as a module, + say M here and read . + + The module will be called i2c-isa. + + You will also need the latest user-space utilties: you can find them + in the lm_sensors package, which you can download at + http://www.lm-sensors.nu + + config I2C_PIIX4 tristate " Intel PIIX4" depends on I2C && I2C_PROC && PCI && EXPERIMENTAL diff -Nru a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile --- a/drivers/i2c/busses/Makefile Sun Mar 23 00:22:50 2003 +++ b/drivers/i2c/busses/Makefile Sun Mar 23 00:22:50 2003 @@ -6,4 +6,5 @@ obj-$(CONFIG_I2C_AMD756) += i2c-amd756.o obj-$(CONFIG_I2C_AMD8111) += i2c-amd8111.o obj-$(CONFIG_I2C_I801) += i2c-i801.o +obj-$(CONFIG_I2C_ISA) += i2c-isa.o obj-$(CONFIG_I2C_PIIX4) += i2c-piix4.o diff -Nru a/drivers/i2c/busses/i2c-ali15x3.c b/drivers/i2c/busses/i2c-ali15x3.c --- a/drivers/i2c/busses/i2c-ali15x3.c Sun Mar 23 00:22:53 2003 +++ b/drivers/i2c/busses/i2c-ali15x3.c Sun Mar 23 00:22:53 2003 @@ -60,6 +60,8 @@ /* Note: we assume there can only be one ALI15X3, with one SMBus interface */ +/* #define DEBUG 1 */ + #include #include #include @@ -71,46 +73,46 @@ #include /* ALI15X3 SMBus address offsets */ -#define SMBHSTSTS (0 + ali15x3_smba) -#define SMBHSTCNT (1 + ali15x3_smba) -#define SMBHSTSTART (2 + ali15x3_smba) -#define SMBHSTCMD (7 + ali15x3_smba) -#define SMBHSTADD (3 + ali15x3_smba) -#define SMBHSTDAT0 (4 + ali15x3_smba) -#define SMBHSTDAT1 (5 + ali15x3_smba) -#define SMBBLKDAT (6 + ali15x3_smba) +#define SMBHSTSTS (0 + ali15x3_smba) +#define SMBHSTCNT (1 + ali15x3_smba) +#define SMBHSTSTART (2 + ali15x3_smba) +#define SMBHSTCMD (7 + ali15x3_smba) +#define SMBHSTADD (3 + ali15x3_smba) +#define SMBHSTDAT0 (4 + ali15x3_smba) +#define SMBHSTDAT1 (5 + ali15x3_smba) +#define SMBBLKDAT (6 + ali15x3_smba) /* PCI Address Constants */ -#define SMBCOM 0x004 -#define SMBBA 0x014 -#define SMBATPC 0x05B /* used to unlock xxxBA registers */ -#define SMBHSTCFG 0x0E0 -#define SMBSLVC 0x0E1 -#define SMBCLK 0x0E2 -#define SMBREV 0x008 +#define SMBCOM 0x004 +#define SMBBA 0x014 +#define SMBATPC 0x05B /* used to unlock xxxBA registers */ +#define SMBHSTCFG 0x0E0 +#define SMBSLVC 0x0E1 +#define SMBCLK 0x0E2 +#define SMBREV 0x008 /* Other settings */ -#define MAX_TIMEOUT 200 /* times 1/100 sec */ -#define ALI15X3_SMB_IOSIZE 32 +#define MAX_TIMEOUT 200 /* times 1/100 sec */ +#define ALI15X3_SMB_IOSIZE 32 /* this is what the Award 1004 BIOS sets them to on a ASUS P5A MB. We don't use these here. If the bases aren't set to some value we tell user to upgrade BIOS and we fail. */ -#define ALI15X3_SMB_DEFAULTBASE 0xE800 +#define ALI15X3_SMB_DEFAULTBASE 0xE800 /* ALI15X3 address lock bits */ -#define ALI15X3_LOCK 0x06 +#define ALI15X3_LOCK 0x06 /* ALI15X3 command constants */ -#define ALI15X3_ABORT 0x02 -#define ALI15X3_T_OUT 0x04 -#define ALI15X3_QUICK 0x00 -#define ALI15X3_BYTE 0x10 -#define ALI15X3_BYTE_DATA 0x20 -#define ALI15X3_WORD_DATA 0x30 -#define ALI15X3_BLOCK_DATA 0x40 -#define ALI15X3_BLOCK_CLR 0x80 +#define ALI15X3_ABORT 0x02 +#define ALI15X3_T_OUT 0x04 +#define ALI15X3_QUICK 0x00 +#define ALI15X3_BYTE 0x10 +#define ALI15X3_BYTE_DATA 0x20 +#define ALI15X3_WORD_DATA 0x30 +#define ALI15X3_BLOCK_DATA 0x40 +#define ALI15X3_BLOCK_CLR 0x80 /* ALI15X3 status register bits */ #define ALI15X3_STS_IDLE 0x04 @@ -129,55 +131,52 @@ MODULE_PARM_DESC(force_addr, "Initialize the base address of the i2c controller"); - -static void ali15x3_do_pause(unsigned int amount); -static int ali15x3_transaction(void); - static unsigned short ali15x3_smba = 0; -int ali15x3_setup(struct pci_dev *ALI15X3_dev) +static int ali15x3_setup(struct pci_dev *ALI15X3_dev) { u16 a; unsigned char temp; -/* Check the following things: - - SMB I/O address is initialized - - Device is enabled - - We can use the addresses -*/ - -/* Unlock the register. - The data sheet says that the address registers are read-only - if the lock bits are 1, but in fact the address registers - are zero unless you clear the lock bits. -*/ + /* Check the following things: + - SMB I/O address is initialized + - Device is enabled + - We can use the addresses + */ + + /* Unlock the register. + The data sheet says that the address registers are read-only + if the lock bits are 1, but in fact the address registers + are zero unless you clear the lock bits. + */ pci_read_config_byte(ALI15X3_dev, SMBATPC, &temp); if (temp & ALI15X3_LOCK) { temp &= ~ALI15X3_LOCK; pci_write_config_byte(ALI15X3_dev, SMBATPC, temp); } -/* Determine the address of the SMBus area */ + /* Determine the address of the SMBus area */ pci_read_config_word(ALI15X3_dev, SMBBA, &ali15x3_smba); ali15x3_smba &= (0xffff & ~(ALI15X3_SMB_IOSIZE - 1)); if (ali15x3_smba == 0 && force_addr == 0) { - printk - ("i2c-ali15x3.o: ALI15X3_smb region uninitialized - upgrade BIOS or use force_addr=0xaddr\n"); + dev_err(&ALI15X3_dev->dev, "ALI15X3_smb region uninitialized " + "- upgrade BIOS or use force_addr=0xaddr\n"); return -ENODEV; } if(force_addr) ali15x3_smba = force_addr & ~(ALI15X3_SMB_IOSIZE - 1); - if (check_region(ali15x3_smba, ALI15X3_SMB_IOSIZE)) { - printk - ("i2c-ali15x3.o: ALI15X3_smb region 0x%x already in use!\n", - ali15x3_smba); + if (!request_region(ali15x3_smba, ALI15X3_SMB_IOSIZE, "ali15x3-smb")) { + dev_err(&ALI15X3_dev->dev, + "ALI15X3_smb region 0x%x already in use!\n", + ali15x3_smba); return -ENODEV; } if(force_addr) { - printk("i2c-ali15x3.o: forcing ISA address 0x%04X\n", ali15x3_smba); + dev_info(&ALI15X3_dev->dev, "forcing ISA address 0x%04X\n", + ali15x3_smba); if (PCIBIOS_SUCCESSFUL != pci_write_config_word(ALI15X3_dev, SMBBA, ali15x3_smba)) return -ENODEV; @@ -186,68 +185,60 @@ return -ENODEV; if ((a & ~(ALI15X3_SMB_IOSIZE - 1)) != ali15x3_smba) { /* make sure it works */ - printk("i2c-ali15x3.o: force address failed - not supported?\n"); + dev_err(&ALI15X3_dev->dev, + "force address failed - not supported?\n"); return -ENODEV; } } -/* check if whole device is enabled */ + /* check if whole device is enabled */ pci_read_config_byte(ALI15X3_dev, SMBCOM, &temp); if ((temp & 1) == 0) { - printk("i2c-ali15x3: enabling SMBus device\n"); + dev_info(&ALI15X3_dev->dev, "enabling SMBus device\n"); pci_write_config_byte(ALI15X3_dev, SMBCOM, temp | 0x01); } -/* Is SMB Host controller enabled? */ + /* Is SMB Host controller enabled? */ pci_read_config_byte(ALI15X3_dev, SMBHSTCFG, &temp); if ((temp & 1) == 0) { - printk("i2c-ali15x3: enabling SMBus controller\n"); + dev_info(&ALI15X3_dev->dev, "enabling SMBus controller\n"); pci_write_config_byte(ALI15X3_dev, SMBHSTCFG, temp | 0x01); } -/* set SMB clock to 74KHz as recommended in data sheet */ + /* set SMB clock to 74KHz as recommended in data sheet */ pci_write_config_byte(ALI15X3_dev, SMBCLK, 0x20); - /* Everything is happy, let's grab the memory and set things up. */ - request_region(ali15x3_smba, ALI15X3_SMB_IOSIZE, "ali15x3-smb"); - -#ifdef DEBUG -/* - The interrupt routing for SMB is set up in register 0x77 in the - 1533 ISA Bridge device, NOT in the 7101 device. - Don't bother with finding the 1533 device and reading the register. - if ((....... & 0x0F) == 1) - printk("i2c-ali15x3.o: ALI15X3 using Interrupt 9 for SMBus.\n"); -*/ + /* + The interrupt routing for SMB is set up in register 0x77 in the + 1533 ISA Bridge device, NOT in the 7101 device. + Don't bother with finding the 1533 device and reading the register. + if ((....... & 0x0F) == 1) + dev_dbg(&ALI15X3_dev->dev, "ALI15X3 using Interrupt 9 for SMBus.\n"); + */ pci_read_config_byte(ALI15X3_dev, SMBREV, &temp); - printk("i2c-ali15x3.o: SMBREV = 0x%X\n", temp); - printk("i2c-ali15x3.o: ALI15X3_smba = 0x%X\n", ali15x3_smba); -#endif /* DEBUG */ + dev_dbg(&ALI15X3_dev->dev, "SMBREV = 0x%X\n", temp); + dev_dbg(&ALI15X3_dev->dev, "iALI15X3_smba = 0x%X\n", ali15x3_smba); return 0; } - /* Internally used pause function */ -void ali15x3_do_pause(unsigned int amount) +static void ali15x3_do_pause(unsigned int amount) { current->state = TASK_INTERRUPTIBLE; schedule_timeout(amount); } /* Another internally used function */ -int ali15x3_transaction(void) +static int ali15x3_transaction(struct i2c_adapter *adap) { int temp; int result = 0; int timeout = 0; -#ifdef DEBUG - printk - ("i2c-ali15x3.o: Transaction (pre): STS=%02x, CNT=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, " - "DAT1=%02x\n", inb_p(SMBHSTSTS), inb_p(SMBHSTCNT), - inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), - inb_p(SMBHSTDAT1)); -#endif + dev_dbg(&adap->dev, "Transaction (pre): STS=%02x, CNT=%02x, CMD=%02x, " + "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTSTS), + inb_p(SMBHSTCNT), inb_p(SMBHSTCMD), inb_p(SMBHSTADD), + inb_p(SMBHSTDAT0), inb_p(SMBHSTDAT1)); /* get status */ temp = inb_p(SMBHSTSTS); @@ -255,43 +246,32 @@ /* Make sure the SMBus host is ready to start transmitting */ /* Check the busy bit first */ if (temp & ALI15X3_STS_BUSY) { -/* - If the host controller is still busy, it may have timed out in the previous transaction, - resulting in a "SMBus Timeout" printk. - I've tried the following to reset a stuck busy bit. - 1. Reset the controller with an ABORT command. - (this doesn't seem to clear the controller if an external device is hung) - 2. Reset the controller and the other SMBus devices with a T_OUT command. - (this clears the host busy bit if an external device is hung, - but it comes back upon a new access to a device) - 3. Disable and reenable the controller in SMBHSTCFG - Worst case, nothing seems to work except power reset. -*/ -/* Abort - reset the host controller */ -/* -#ifdef DEBUG - printk("i2c-ali15x3.o: Resetting host controller to clear busy condition\n",temp); -#endif - outb_p(ALI15X3_ABORT, SMBHSTCNT); - temp = inb_p(SMBHSTSTS); - if (temp & ALI15X3_STS_BUSY) { -*/ - -/* - Try resetting entire SMB bus, including other devices - - This may not work either - it clears the BUSY bit but - then the BUSY bit may come back on when you try and use the chip again. - If that's the case you are stuck. -*/ - printk - ("i2c-ali15x3.o: Resetting entire SMB Bus to clear busy condition (%02x)\n", - temp); + /* + If the host controller is still busy, it may have timed out in the + previous transaction, resulting in a "SMBus Timeout" Dev. + I've tried the following to reset a stuck busy bit. + 1. Reset the controller with an ABORT command. + (this doesn't seem to clear the controller if an external + device is hung) + 2. Reset the controller and the other SMBus devices with a + T_OUT command. (this clears the host busy bit if an + external device is hung, but it comes back upon a new access + to a device) + 3. Disable and reenable the controller in SMBHSTCFG + Worst case, nothing seems to work except power reset. + */ + /* Abort - reset the host controller */ + /* + Try resetting entire SMB bus, including other devices - + This may not work either - it clears the BUSY bit but + then the BUSY bit may come back on when you try and use the chip again. + If that's the case you are stuck. + */ + dev_info(&adap->dev, "Resetting entire SMB Bus to " + "clear busy condition (%02x)\n", temp); outb_p(ALI15X3_T_OUT, SMBHSTCNT); temp = inb_p(SMBHSTSTS); } -/* - } -*/ /* now check the error bits and the busy bit */ if (temp & (ALI15X3_STS_ERR | ALI15X3_STS_BUSY)) { @@ -302,9 +282,9 @@ /* this is probably going to be correctable only by a power reset as one of the bits now appears to be stuck */ /* This may be a bus or device with electrical problems. */ - printk - ("i2c-ali15x3.o: SMBus reset failed! (0x%02x) - controller or device on bus is probably hung\n", - temp); + dev_err(&adap->dev, "SMBus reset failed! (0x%02x) - " + "controller or device on bus is probably hung\n", + temp); return -1; } } else { @@ -328,48 +308,41 @@ /* If the SMBus is still busy, we give up */ if (timeout >= MAX_TIMEOUT) { result = -1; - printk("i2c-ali15x3.o: SMBus Timeout!\n"); + dev_err(&adap->dev, "SMBus Timeout!\n"); } if (temp & ALI15X3_STS_TERM) { result = -1; -#ifdef DEBUG - printk("i2c-ali15x3.o: Error: Failed bus transaction\n"); -#endif + dev_dbg(&adap->dev, "Error: Failed bus transaction\n"); } -/* - Unfortunately the ALI SMB controller maps "no response" and "bus collision" - into a single bit. No reponse is the usual case so don't - do a printk. - This means that bus collisions go unreported. -*/ + /* + Unfortunately the ALI SMB controller maps "no response" and "bus + collision" into a single bit. No reponse is the usual case so don't + do a printk. + This means that bus collisions go unreported. + */ if (temp & ALI15X3_STS_COLL) { result = -1; -#ifdef DEBUG - printk - ("i2c-ali15x3.o: Error: no response or bus collision ADD=%02x\n", - inb_p(SMBHSTADD)); -#endif + dev_dbg(&adap->dev, + "Error: no response or bus collision ADD=%02x\n", + inb_p(SMBHSTADD)); } -/* haven't ever seen this */ + /* haven't ever seen this */ if (temp & ALI15X3_STS_DEV) { result = -1; - printk("i2c-ali15x3.o: Error: device error\n"); + dev_err(&adap->dev, "Error: device error\n"); } -#ifdef DEBUG - printk - ("i2c-ali15x3.o: Transaction (post): STS=%02x, CNT=%02x, CMD=%02x, ADD=%02x, " - "DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTSTS), inb_p(SMBHSTCNT), - inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), - inb_p(SMBHSTDAT1)); -#endif + dev_dbg(&adap->dev, "Transaction (post): STS=%02x, CNT=%02x, CMD=%02x, " + "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTSTS), + inb_p(SMBHSTCNT), inb_p(SMBHSTCMD), inb_p(SMBHSTADD), + inb_p(SMBHSTDAT0), inb_p(SMBHSTDAT1)); return result; } /* Return -1 on error. */ -s32 ali15x3_access(struct i2c_adapter * adap, u16 addr, +static s32 ali15x3_access(struct i2c_adapter * adap, u16 addr, unsigned short flags, char read_write, u8 command, int size, union i2c_smbus_data * data) { @@ -377,9 +350,9 @@ int temp; int timeout; -/* clear all the bits (clear-on-write) */ + /* clear all the bits (clear-on-write) */ outb_p(0xFF, SMBHSTSTS); -/* make sure SMBus is idle */ + /* make sure SMBus is idle */ temp = inb_p(SMBHSTSTS); for (timeout = 0; (timeout < MAX_TIMEOUT) && !(temp & ALI15X3_STS_IDLE); @@ -388,14 +361,12 @@ temp = inb_p(SMBHSTSTS); } if (timeout >= MAX_TIMEOUT) { - printk("i2c-ali15x3.o: Idle wait Timeout! STS=0x%02x\n", - temp); + dev_err(&adap->dev, "Idle wait Timeout! STS=0x%02x\n", temp); } switch (size) { case I2C_SMBUS_PROC_CALL: - printk - ("i2c-ali15x3.o: I2C_SMBUS_PROC_CALL not supported!\n"); + dev_err(&adap->dev, "I2C_SMBUS_PROC_CALL not supported!\n"); return -1; case I2C_SMBUS_QUICK: outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), @@ -442,7 +413,8 @@ data->block[0] = len; } outb_p(len, SMBHSTDAT0); - outb_p(inb_p(SMBHSTCNT) | ALI15X3_BLOCK_CLR, SMBHSTCNT); /* Reset SMBBLKDAT */ + /* Reset SMBBLKDAT */ + outb_p(inb_p(SMBHSTCNT) | ALI15X3_BLOCK_CLR, SMBHSTCNT); for (i = 1; i <= len; i++) outb_p(data->block[i], SMBBLKDAT); } @@ -452,7 +424,7 @@ outb_p(size, SMBHSTCNT); /* output command */ - if (ali15x3_transaction()) /* Error in transaction */ + if (ali15x3_transaction(adap)) /* Error in transaction */ return -1; if ((read_write == I2C_SMBUS_WRITE) || (size == ALI15X3_QUICK)) @@ -474,22 +446,19 @@ if (len > 32) len = 32; data->block[0] = len; - outb_p(inb_p(SMBHSTCNT) | ALI15X3_BLOCK_CLR, SMBHSTCNT); /* Reset SMBBLKDAT */ + /* Reset SMBBLKDAT */ + outb_p(inb_p(SMBHSTCNT) | ALI15X3_BLOCK_CLR, SMBHSTCNT); for (i = 1; i <= data->block[0]; i++) { data->block[i] = inb_p(SMBBLKDAT); -#ifdef DEBUG - printk - ("i2c-ali15x3.o: Blk: len=%d, i=%d, data=%02x\n", - len, i, data->block[i]); -#endif /* DEBUG */ + dev_dbg(&adap->dev, "Blk: len=%d, i=%d, data=%02x\n", + len, i, data->block[i]); } break; } return 0; } - -u32 ali15x3_func(struct i2c_adapter *adapter) +static u32 ali15x3_func(struct i2c_adapter *adapter) { return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | @@ -510,8 +479,6 @@ .algo = &smbus_algorithm, }; - - static struct pci_device_id ali15x3_ids[] __devinitdata = { { .vendor = PCI_VENDOR_ID_AL, @@ -525,9 +492,8 @@ static int __devinit ali15x3_probe(struct pci_dev *dev, const struct pci_device_id *id) { if (ali15x3_setup(dev)) { - printk - ("i2c-ali15x3.o: ALI15X3 not detected, module not inserted.\n"); - + dev_err(&dev->dev, + "ALI15X3 not detected, module not inserted.\n"); return -ENODEV; } @@ -557,17 +523,15 @@ return pci_module_init(&ali15x3_driver); } - static void __exit i2c_ali15x3_exit(void) { pci_unregister_driver(&ali15x3_driver); release_region(ali15x3_smba, ALI15X3_SMB_IOSIZE); } - - -MODULE_AUTHOR - ("Frodo Looijaard , Philip Edelbrock , and Mark D. Studebaker "); +MODULE_AUTHOR ("Frodo Looijaard , " + "Philip Edelbrock , " + "and Mark D. Studebaker "); MODULE_DESCRIPTION("ALI15X3 SMBus driver"); MODULE_LICENSE("GPL"); diff -Nru a/drivers/i2c/busses/i2c-amd756.c b/drivers/i2c/busses/i2c-amd756.c --- a/drivers/i2c/busses/i2c-amd756.c Sun Mar 23 00:22:55 2003 +++ b/drivers/i2c/busses/i2c-amd756.c Sun Mar 23 00:22:55 2003 @@ -35,6 +35,8 @@ Note: we assume there can only be one device, with one SMBus interface. */ +/* #define DEBUG 1 */ + #include #include #include @@ -46,44 +48,42 @@ #include #include -#define DRV_NAME "i2c-amd756" - /* AMD756 SMBus address offsets */ -#define SMB_ADDR_OFFSET 0xE0 -#define SMB_IOSIZE 16 -#define SMB_GLOBAL_STATUS (0x0 + amd756_ioport) -#define SMB_GLOBAL_ENABLE (0x2 + amd756_ioport) -#define SMB_HOST_ADDRESS (0x4 + amd756_ioport) -#define SMB_HOST_DATA (0x6 + amd756_ioport) -#define SMB_HOST_COMMAND (0x8 + amd756_ioport) -#define SMB_HOST_BLOCK_DATA (0x9 + amd756_ioport) -#define SMB_HAS_DATA (0xA + amd756_ioport) -#define SMB_HAS_DEVICE_ADDRESS (0xC + amd756_ioport) -#define SMB_HAS_HOST_ADDRESS (0xE + amd756_ioport) -#define SMB_SNOOP_ADDRESS (0xF + amd756_ioport) +#define SMB_ADDR_OFFSET 0xE0 +#define SMB_IOSIZE 16 +#define SMB_GLOBAL_STATUS (0x0 + amd756_ioport) +#define SMB_GLOBAL_ENABLE (0x2 + amd756_ioport) +#define SMB_HOST_ADDRESS (0x4 + amd756_ioport) +#define SMB_HOST_DATA (0x6 + amd756_ioport) +#define SMB_HOST_COMMAND (0x8 + amd756_ioport) +#define SMB_HOST_BLOCK_DATA (0x9 + amd756_ioport) +#define SMB_HAS_DATA (0xA + amd756_ioport) +#define SMB_HAS_DEVICE_ADDRESS (0xC + amd756_ioport) +#define SMB_HAS_HOST_ADDRESS (0xE + amd756_ioport) +#define SMB_SNOOP_ADDRESS (0xF + amd756_ioport) /* PCI Address Constants */ /* address of I/O space */ -#define SMBBA 0x058 /* mh */ -#define SMBBANFORCE 0x014 +#define SMBBA 0x058 /* mh */ +#define SMBBANFORCE 0x014 /* general configuration */ -#define SMBGCFG 0x041 /* mh */ +#define SMBGCFG 0x041 /* mh */ /* silicon revision code */ -#define SMBREV 0x008 +#define SMBREV 0x008 /* Other settings */ -#define MAX_TIMEOUT 500 +#define MAX_TIMEOUT 500 /* AMD756 constants */ -#define AMD756_QUICK 0x00 -#define AMD756_BYTE 0x01 -#define AMD756_BYTE_DATA 0x02 -#define AMD756_WORD_DATA 0x03 -#define AMD756_PROCESS_CALL 0x04 -#define AMD756_BLOCK_DATA 0x05 +#define AMD756_QUICK 0x00 +#define AMD756_BYTE 0x01 +#define AMD756_BYTE_DATA 0x02 +#define AMD756_WORD_DATA 0x03 +#define AMD756_PROCESS_CALL 0x04 +#define AMD756_BLOCK_DATA 0x05 static unsigned short amd756_ioport = 0; @@ -101,36 +101,36 @@ schedule_timeout(amount); } -#define GS_ABRT_STS (1 << 0) -#define GS_COL_STS (1 << 1) -#define GS_PRERR_STS (1 << 2) -#define GS_HST_STS (1 << 3) -#define GS_HCYC_STS (1 << 4) -#define GS_TO_STS (1 << 5) -#define GS_SMB_STS (1 << 11) - -#define GS_CLEAR_STS (GS_ABRT_STS | GS_COL_STS | GS_PRERR_STS | \ - GS_HCYC_STS | GS_TO_STS ) - -#define GE_CYC_TYPE_MASK (7) -#define GE_HOST_STC (1 << 3) -#define GE_ABORT (1 << 5) +#define GS_ABRT_STS (1 << 0) +#define GS_COL_STS (1 << 1) +#define GS_PRERR_STS (1 << 2) +#define GS_HST_STS (1 << 3) +#define GS_HCYC_STS (1 << 4) +#define GS_TO_STS (1 << 5) +#define GS_SMB_STS (1 << 11) + +#define GS_CLEAR_STS (GS_ABRT_STS | GS_COL_STS | GS_PRERR_STS | \ + GS_HCYC_STS | GS_TO_STS ) + +#define GE_CYC_TYPE_MASK (7) +#define GE_HOST_STC (1 << 3) +#define GE_ABORT (1 << 5) -static int amd756_transaction(void) +static int amd756_transaction(struct i2c_adapter *adap) { int temp; int result = 0; int timeout = 0; - pr_debug(DRV_NAME - ": Transaction (pre): GS=%04x, GE=%04x, ADD=%04x, DAT=%04x\n", - inw_p(SMB_GLOBAL_STATUS), inw_p(SMB_GLOBAL_ENABLE), - inw_p(SMB_HOST_ADDRESS), inb_p(SMB_HOST_DATA)); + dev_dbg(&adap->dev, ": Transaction (pre): GS=%04x, GE=%04x, ADD=%04x, " + "DAT=%04x\n", inw_p(SMB_GLOBAL_STATUS), + inw_p(SMB_GLOBAL_ENABLE), inw_p(SMB_HOST_ADDRESS), + inb_p(SMB_HOST_DATA)); /* Make sure the SMBus host is ready to start transmitting */ if ((temp = inw_p(SMB_GLOBAL_STATUS)) & (GS_HST_STS | GS_SMB_STS)) { - pr_debug(DRV_NAME ": SMBus busy (%04x). Waiting... \n", temp); + dev_dbg(&adap->dev, ": SMBus busy (%04x). Waiting... \n", temp); do { amd756_do_pause(1); temp = inw_p(SMB_GLOBAL_STATUS); @@ -138,7 +138,7 @@ (timeout++ < MAX_TIMEOUT)); /* If the SMBus is still busy, we give up */ if (timeout >= MAX_TIMEOUT) { - pr_debug(DRV_NAME ": Busy wait timeout (%04x)\n", temp); + dev_dbg(&adap->dev, ": Busy wait timeout (%04x)\n", temp); goto abort; } timeout = 0; @@ -155,46 +155,46 @@ /* If the SMBus is still busy, we give up */ if (timeout >= MAX_TIMEOUT) { - pr_debug(DRV_NAME ": Completion timeout!\n"); + dev_dbg(&adap->dev, ": Completion timeout!\n"); goto abort; } if (temp & GS_PRERR_STS) { result = -1; - pr_debug(DRV_NAME ": SMBus Protocol error (no response)!\n"); + dev_dbg(&adap->dev, ": SMBus Protocol error (no response)!\n"); } if (temp & GS_COL_STS) { result = -1; - printk(KERN_WARNING DRV_NAME " SMBus collision!\n"); + dev_warn(&adap->dev, " SMBus collision!\n"); } if (temp & GS_TO_STS) { result = -1; - pr_debug(DRV_NAME ": SMBus protocol timeout!\n"); + dev_dbg(&adap->dev, ": SMBus protocol timeout!\n"); } if (temp & GS_HCYC_STS) - pr_debug(DRV_NAME " SMBus protocol success!\n"); + dev_dbg(&adap->dev, " SMBus protocol success!\n"); outw_p(GS_CLEAR_STS, SMB_GLOBAL_STATUS); #ifdef DEBUG if (((temp = inw_p(SMB_GLOBAL_STATUS)) & GS_CLEAR_STS) != 0x00) { - pr_debug(DRV_NAME - ": Failed reset at end of transaction (%04x)\n", temp); + dev_dbg(&adap->dev, + ": Failed reset at end of transaction (%04x)\n", temp); } - - pr_debug(DRV_NAME - ": Transaction (post): GS=%04x, GE=%04x, ADD=%04x, DAT=%04x\n", - inw_p(SMB_GLOBAL_STATUS), inw_p(SMB_GLOBAL_ENABLE), - inw_p(SMB_HOST_ADDRESS), inb_p(SMB_HOST_DATA)); #endif + dev_dbg(&adap->dev, + ": Transaction (post): GS=%04x, GE=%04x, ADD=%04x, DAT=%04x\n", + inw_p(SMB_GLOBAL_STATUS), inw_p(SMB_GLOBAL_ENABLE), + inw_p(SMB_HOST_ADDRESS), inb_p(SMB_HOST_DATA)); + return result; abort: - printk(KERN_WARNING DRV_NAME ": Sending abort.\n"); + dev_warn(&adap->dev, ": Sending abort.\n"); outw_p(inw(SMB_GLOBAL_ENABLE) | GE_ABORT, SMB_GLOBAL_ENABLE); amd756_do_pause(100); outw_p(GS_CLEAR_STS, SMB_GLOBAL_STATUS); @@ -211,7 +211,7 @@ /** TODO: Should I supporte the 10-bit transfers? */ switch (size) { case I2C_SMBUS_PROC_CALL: - pr_debug(DRV_NAME ": I2C_SMBUS_PROC_CALL not supported!\n"); + dev_dbg(&adap->dev, ": I2C_SMBUS_PROC_CALL not supported!\n"); /* TODO: Well... It is supported, I'm just not sure what to do here... */ return -1; case I2C_SMBUS_QUICK: @@ -266,7 +266,7 @@ /* How about enabling interrupts... */ outw_p(size & GE_CYC_TYPE_MASK, SMB_GLOBAL_ENABLE); - if (amd756_transaction()) /* Error in transaction */ + if (amd756_transaction(adap)) /* Error in transaction */ return -1; if ((read_write == I2C_SMBUS_WRITE) || (size == AMD756_QUICK)) @@ -334,7 +334,7 @@ u8 temp; if (amd756_ioport) { - printk(KERN_ERR DRV_NAME ": Only one device supported. " + dev_err(&pdev->dev, ": Only one device supported. " "(you have a strange motherboard, btw..)\n"); return -ENODEV; } @@ -351,8 +351,8 @@ pci_read_config_byte(pdev, SMBGCFG, &temp); if ((temp & 128) == 0) { - printk(KERN_ERR DRV_NAME - ": Error: SMBus controller I/O not enabled!\n"); + dev_err(&pdev->dev, + ": Error: SMBus controller I/O not enabled!\n"); return -ENODEV; } @@ -364,16 +364,14 @@ } if (!request_region(amd756_ioport, SMB_IOSIZE, "amd756-smbus")) { - printk(KERN_ERR DRV_NAME - ": SMB region 0x%x already in use!\n", amd756_ioport); + dev_err(&pdev->dev, ": SMB region 0x%x already in use!\n", + amd756_ioport); return -ENODEV; } -#ifdef DEBUG pci_read_config_byte(pdev, SMBREV, &temp); - printk(KERN_DEBUG DRV_NAME ": SMBREV = 0x%X\n", temp); - printk(KERN_DEBUG DRV_NAME ": AMD756_smba = 0x%X\n", amd756_ioport); -#endif + dev_dbg(&pdev->dev, ": SMBREV = 0x%X\n", temp); + dev_dbg(&pdev->dev, ": AMD756_smba = 0x%X\n", amd756_ioport); /* set up the driverfs linkage to our parent device */ amd756_adapter.dev.parent = &pdev->dev; @@ -383,8 +381,8 @@ error = i2c_add_adapter(&amd756_adapter); if (error) { - printk(KERN_ERR DRV_NAME - ": Adapter registration failed, module not inserted.\n"); + dev_err(&pdev->dev, + ": Adapter registration failed, module not inserted.\n"); goto out_err; } diff -Nru a/drivers/i2c/busses/i2c-amd8111.c b/drivers/i2c/busses/i2c-amd8111.c --- a/drivers/i2c/busses/i2c-amd8111.c Sun Mar 23 00:22:55 2003 +++ b/drivers/i2c/busses/i2c-amd8111.c Sun Mar 23 00:22:55 2003 @@ -74,7 +74,7 @@ udelay(1); if (!timeout) { - printk(KERN_WARNING "i2c-amd8111.c: Timeout while waiting for IBF to clear\n"); + dev_warn(&smbus->dev->dev, "Timeout while waiting for IBF to clear\n"); return -1; } @@ -89,7 +89,7 @@ udelay(1); if (!timeout) { - printk(KERN_WARNING "i2c-amd8111.c: Timeout while waiting for OBF to set\n"); + dev_warn(&smbus->dev->dev, "Timeout while waiting for OBF to set\n"); return -1; } @@ -256,11 +256,11 @@ case I2C_SMBUS_BLOCK_DATA_PEC: case I2C_SMBUS_PROC_CALL_PEC: case I2C_SMBUS_BLOCK_PROC_CALL_PEC: - printk(KERN_WARNING "i2c-amd8111.c: Unexpected software PEC transaction %d\n.", size); + dev_warn(&adap->dev, "Unexpected software PEC transaction %d\n.", size); return -1; default: - printk(KERN_WARNING "i2c-amd8111.c: Unsupported transaction %d\n", size); + dev_warn(&adap->dev, "Unsupported transaction %d\n", size); return -1; } @@ -392,7 +392,7 @@ } static struct pci_driver amd8111_driver = { - .name = "amd8111 smbus", + .name = "amd8111 smbus 2", .id_table = amd8111_ids, .probe = amd8111_probe, .remove = __devexit_p(amd8111_remove), diff -Nru a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c --- a/drivers/i2c/busses/i2c-i801.c Sun Mar 23 00:22:53 2003 +++ b/drivers/i2c/busses/i2c-i801.c Sun Mar 23 00:22:53 2003 @@ -49,65 +49,48 @@ #include #include -MODULE_LICENSE("GPL"); - #ifdef I2C_FUNC_SMBUS_BLOCK_DATA_PEC #define HAVE_PEC #endif -#ifndef PCI_DEVICE_ID_INTEL_82801CA_SMBUS -#define PCI_DEVICE_ID_INTEL_82801CA_SMBUS 0x2483 -#endif - -#ifndef PCI_DEVICE_ID_INTEL_82801DB_SMBUS -#define PCI_DEVICE_ID_INTEL_82801DB_SMBUS 0x24C3 -#endif - -static int supported[] = {PCI_DEVICE_ID_INTEL_82801AA_3, - PCI_DEVICE_ID_INTEL_82801AB_3, - PCI_DEVICE_ID_INTEL_82801BA_2, - PCI_DEVICE_ID_INTEL_82801CA_SMBUS, - PCI_DEVICE_ID_INTEL_82801DB_SMBUS, - 0 }; - /* I801 SMBus address offsets */ -#define SMBHSTSTS (0 + i801_smba) -#define SMBHSTCNT (2 + i801_smba) -#define SMBHSTCMD (3 + i801_smba) -#define SMBHSTADD (4 + i801_smba) -#define SMBHSTDAT0 (5 + i801_smba) -#define SMBHSTDAT1 (6 + i801_smba) -#define SMBBLKDAT (7 + i801_smba) -#define SMBPEC (8 + i801_smba) /* ICH4 only */ -#define SMBAUXSTS (12 + i801_smba) /* ICH4 only */ -#define SMBAUXCTL (13 + i801_smba) /* ICH4 only */ +#define SMBHSTSTS (0 + i801_smba) +#define SMBHSTCNT (2 + i801_smba) +#define SMBHSTCMD (3 + i801_smba) +#define SMBHSTADD (4 + i801_smba) +#define SMBHSTDAT0 (5 + i801_smba) +#define SMBHSTDAT1 (6 + i801_smba) +#define SMBBLKDAT (7 + i801_smba) +#define SMBPEC (8 + i801_smba) /* ICH4 only */ +#define SMBAUXSTS (12 + i801_smba) /* ICH4 only */ +#define SMBAUXCTL (13 + i801_smba) /* ICH4 only */ /* PCI Address Constants */ -#define SMBBA 0x020 -#define SMBHSTCFG 0x040 -#define SMBREV 0x008 +#define SMBBA 0x020 +#define SMBHSTCFG 0x040 +#define SMBREV 0x008 /* Host configuration bits for SMBHSTCFG */ -#define SMBHSTCFG_HST_EN 1 -#define SMBHSTCFG_SMB_SMI_EN 2 -#define SMBHSTCFG_I2C_EN 4 +#define SMBHSTCFG_HST_EN 1 +#define SMBHSTCFG_SMB_SMI_EN 2 +#define SMBHSTCFG_I2C_EN 4 /* Other settings */ -#define MAX_TIMEOUT 100 -#define ENABLE_INT9 0 /* set to 0x01 to enable - untested */ +#define MAX_TIMEOUT 100 +#define ENABLE_INT9 0 /* set to 0x01 to enable - untested */ /* I801 command constants */ -#define I801_QUICK 0x00 -#define I801_BYTE 0x04 -#define I801_BYTE_DATA 0x08 -#define I801_WORD_DATA 0x0C -#define I801_PROC_CALL 0x10 /* later chips only, unimplemented */ -#define I801_BLOCK_DATA 0x14 -#define I801_I2C_BLOCK_DATA 0x18 /* unimplemented */ -#define I801_BLOCK_LAST 0x34 -#define I801_I2C_BLOCK_LAST 0x38 /* unimplemented */ -#define I801_START 0x40 -#define I801_PEC_EN 0x80 /* ICH4 only */ +#define I801_QUICK 0x00 +#define I801_BYTE 0x04 +#define I801_BYTE_DATA 0x08 +#define I801_WORD_DATA 0x0C +#define I801_PROC_CALL 0x10 /* later chips only, unimplemented */ +#define I801_BLOCK_DATA 0x14 +#define I801_I2C_BLOCK_DATA 0x18 /* unimplemented */ +#define I801_BLOCK_LAST 0x34 +#define I801_I2C_BLOCK_LAST 0x38 /* unimplemented */ +#define I801_START 0x40 +#define I801_PEC_EN 0x80 /* ICH4 only */ /* insmod parameters */ @@ -119,10 +102,6 @@ "Forcibly enable the I801 at the given address. " "EXTREMELY DANGEROUS!"); - - - - static void i801_do_pause(unsigned int amount); static int i801_transaction(void); static int i801_block_transaction(union i2c_smbus_data *data, @@ -135,7 +114,6 @@ static int i801_setup(struct pci_dev *dev) { int error_return = 0; - int *num = supported; unsigned char temp; /* Note: we keep on searching until we have found 'function 3' */ @@ -143,101 +121,90 @@ return -ENODEV; I801_dev = dev; - isich4 = *num == PCI_DEVICE_ID_INTEL_82801DB_SMBUS; + if (dev->device == PCI_DEVICE_ID_INTEL_82801DB_3) + isich4 = 1; + else + isich4 = 0; -/* Determine the address of the SMBus areas */ + /* Determine the address of the SMBus areas */ if (force_addr) { i801_smba = force_addr & 0xfff0; } else { pci_read_config_word(I801_dev, SMBBA, &i801_smba); i801_smba &= 0xfff0; if(i801_smba == 0) { - printk(KERN_ERR "i2c-i801.o: SMB base address uninitialized - upgrade BIOS or use force_addr=0xaddr\n"); + dev_err(&dev->dev, "SMB base address uninitialized" + "- upgrade BIOS or use force_addr=0xaddr\n"); return -ENODEV; } } - if (check_region(i801_smba, (isich4 ? 16 : 8))) { - printk - (KERN_ERR "i2c-i801.o: I801_smb region 0x%x already in use!\n", - i801_smba); - error_return = -ENODEV; + if (!request_region(i801_smba, (isich4 ? 16 : 8), "i801-smbus")) { + dev_err(&dev->dev, "I801_smb region 0x%x already in use!\n", + i801_smba); + error_return = -EBUSY; goto END; } pci_read_config_byte(I801_dev, SMBHSTCFG, &temp); temp &= ~SMBHSTCFG_I2C_EN; /* SMBus timing */ pci_write_config_byte(I801_dev, SMBHSTCFG, temp); -/* If force_addr is set, we program the new address here. Just to make - sure, we disable the device first. */ + + /* If force_addr is set, we program the new address here. Just to make + sure, we disable the device first. */ if (force_addr) { pci_write_config_byte(I801_dev, SMBHSTCFG, temp & 0xfe); pci_write_config_word(I801_dev, SMBBA, i801_smba); pci_write_config_byte(I801_dev, SMBHSTCFG, temp | 0x01); - printk - (KERN_WARNING "i2c-i801.o: WARNING: I801 SMBus interface set to new " - "address %04x!\n", i801_smba); + dev_warn(&dev->dev, "WARNING: I801 SMBus interface set to " + "new address %04x!\n", i801_smba); } else if ((temp & 1) == 0) { pci_write_config_byte(I801_dev, SMBHSTCFG, temp | 1); - printk(KERN_WARNING "i2c-i801.o: enabling SMBus device\n"); + dev_warn(&dev->dev, "enabling SMBus device\n"); } - request_region(i801_smba, (isich4 ? 16 : 8), "i801-smbus"); - -#ifdef DEBUG if (temp & 0x02) - printk - (KERN_DEBUG "i2c-i801.o: I801 using Interrupt SMI# for SMBus.\n"); + dev_dbg(&dev->dev, "I801 using Interrupt SMI# for SMBus.\n"); else - printk - (KERN_DEBUG "i2c-i801.o: I801 using PCI Interrupt for SMBus.\n"); + dev_dbg(&dev->dev, "I801 using PCI Interrupt for SMBus.\n"); pci_read_config_byte(I801_dev, SMBREV, &temp); - printk(KERN_DEBUG "i2c-i801.o: SMBREV = 0x%X\n", temp); - printk(KERN_DEBUG "i2c-i801.o: I801_smba = 0x%X\n", i801_smba); -#endif /* DEBUG */ + dev_dbg(&dev->dev, "SMBREV = 0x%X\n", temp); + dev_dbg(&dev->dev, "I801_smba = 0x%X\n", i801_smba); - END: +END: return error_return; } -void i801_do_pause(unsigned int amount) +static void i801_do_pause(unsigned int amount) { current->state = TASK_INTERRUPTIBLE; schedule_timeout(amount); } -int i801_transaction(void) +static int i801_transaction(void) { int temp; int result = 0; int timeout = 0; -#ifdef DEBUG - printk - (KERN_DEBUG "i2c-i801.o: Transaction (pre): CNT=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, " - "DAT1=%02x\n", inb_p(SMBHSTCNT), inb_p(SMBHSTCMD), - inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), inb_p(SMBHSTDAT1)); -#endif + dev_dbg(&I801_dev->dev, "Transaction (pre): CNT=%02x, CMD=%02x," + "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT), + inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), + inb_p(SMBHSTDAT1)); /* Make sure the SMBus host is ready to start transmitting */ /* 0x1f = Failed, Bus_Err, Dev_Err, Intr, Host_Busy */ if ((temp = (0x1f & inb_p(SMBHSTSTS))) != 0x00) { -#ifdef DEBUG - printk(KERN_DEBUG "i2c-i801.o: SMBus busy (%02x). Resetting... \n", - temp); -#endif + dev_dbg(&I801_dev->dev, "SMBus busy (%02x). Resetting... \n", + temp); outb_p(temp, SMBHSTSTS); if ((temp = (0x1f & inb_p(SMBHSTSTS))) != 0x00) { -#ifdef DEBUG - printk(KERN_DEBUG "i2c-i801.o: Failed! (%02x)\n", temp); -#endif + dev_dbg(&I801_dev->dev, "Failed! (%02x)\n", temp); return -1; } else { -#ifdef DEBUG - printk(KERN_DEBUG "i2c-i801.o: Successfull!\n"); -#endif + dev_dbg(&I801_dev->dev, "Successfull!\n"); } } @@ -251,76 +218,64 @@ /* If the SMBus is still busy, we give up */ if (timeout >= MAX_TIMEOUT) { -#ifdef DEBUG - printk(KERN_DEBUG "i2c-i801.o: SMBus Timeout!\n"); + dev_dbg(&I801_dev->dev, "SMBus Timeout!\n"); result = -1; -#endif } if (temp & 0x10) { result = -1; -#ifdef DEBUG - printk(KERN_DEBUG "i2c-i801.o: Error: Failed bus transaction\n"); -#endif + dev_dbg(&I801_dev->dev, "Error: Failed bus transaction\n"); } if (temp & 0x08) { result = -1; - printk - (KERN_ERR "i2c-i801.o: Bus collision! SMBus may be locked until next hard\n" - "reset. (sorry!)\n"); + dev_err(&I801_dev->dev, "Bus collision! SMBus may be locked " + "until next hard reset. (sorry!)\n"); /* Clock stops and slave is stuck in mid-transmission */ } if (temp & 0x04) { result = -1; -#ifdef DEBUG - printk(KERN_DEBUG "i2c-i801.o: Error: no response!\n"); -#endif + dev_dbg(&I801_dev->dev, "Error: no response!\n"); } if ((inb_p(SMBHSTSTS) & 0x1f) != 0x00) outb_p(inb(SMBHSTSTS), SMBHSTSTS); if ((temp = (0x1f & inb_p(SMBHSTSTS))) != 0x00) { -#ifdef DEBUG - printk - (KERN_DEBUG "i2c-i801.o: Failed reset at end of transaction (%02x)\n", - temp); -#endif + dev_dbg(&I801_dev->dev, "Failed reset at end of transaction" + "(%02x)\n", temp); } -#ifdef DEBUG - printk - (KERN_DEBUG "i2c-i801.o: Transaction (post): CNT=%02x, CMD=%02x, ADD=%02x, " - "DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT), inb_p(SMBHSTCMD), - inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), inb_p(SMBHSTDAT1)); -#endif + dev_dbg(&I801_dev->dev, "Transaction (post): CNT=%02x, CMD=%02x, " + "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT), + inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), + inb_p(SMBHSTDAT1)); return result; } /* All-inclusive block transaction function */ -int i801_block_transaction(union i2c_smbus_data *data, char read_write, - int command) +static int i801_block_transaction(union i2c_smbus_data *data, char read_write, + int command) { int i, len; int smbcmd; int temp; int result = 0; int timeout; - unsigned char hostc, errmask; + unsigned char hostc, errmask; - if (command == I2C_SMBUS_I2C_BLOCK_DATA) { - if (read_write == I2C_SMBUS_WRITE) { - /* set I2C_EN bit in configuration register */ - pci_read_config_byte(I801_dev, SMBHSTCFG, &hostc); - pci_write_config_byte(I801_dev, SMBHSTCFG, - hostc | SMBHSTCFG_I2C_EN); - } else { - printk("i2c-i801.o: " - "I2C_SMBUS_I2C_BLOCK_READ not supported!\n"); - return -1; - } - } + if (command == I2C_SMBUS_I2C_BLOCK_DATA) { + if (read_write == I2C_SMBUS_WRITE) { + /* set I2C_EN bit in configuration register */ + pci_read_config_byte(I801_dev, SMBHSTCFG, &hostc); + pci_write_config_byte(I801_dev, SMBHSTCFG, + hostc | SMBHSTCFG_I2C_EN); + } else { + dev_err(&I801_dev->dev, + "I2C_SMBUS_I2C_BLOCK_READ not DB!\n"); + return -1; + } + } if (read_write == I2C_SMBUS_WRITE) { len = data->block[0]; @@ -343,60 +298,43 @@ smbcmd = I801_BLOCK_LAST; else smbcmd = I801_BLOCK_DATA; -#if 0 /* now using HW PEC */ - if(isich4 && command == I2C_SMBUS_BLOCK_DATA_PEC) - smbcmd |= I801_PEC_EN; -#endif outb_p(smbcmd | ENABLE_INT9, SMBHSTCNT); -#ifdef DEBUG - printk - (KERN_DEBUG "i2c-i801.o: Block (pre %d): CNT=%02x, CMD=%02x, ADD=%02x, " - "DAT0=%02x, BLKDAT=%02x\n", i, inb_p(SMBHSTCNT), - inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), - inb_p(SMBBLKDAT)); -#endif + dev_dbg(&I801_dev->dev, "Block (pre %d): CNT=%02x, CMD=%02x, " + "ADD=%02x, DAT0=%02x, BLKDAT=%02x\n", i, + inb_p(SMBHSTCNT), inb_p(SMBHSTCMD), inb_p(SMBHSTADD), + inb_p(SMBHSTDAT0), inb_p(SMBBLKDAT)); /* Make sure the SMBus host is ready to start transmitting */ temp = inb_p(SMBHSTSTS); - if (i == 1) { - /* Erronenous conditions before transaction: - * Byte_Done, Failed, Bus_Err, Dev_Err, Intr, Host_Busy */ - errmask=0x9f; - } else { - /* Erronenous conditions during transaction: - * Failed, Bus_Err, Dev_Err, Intr */ - errmask=0x1e; - } + if (i == 1) { + /* Erronenous conditions before transaction: + * Byte_Done, Failed, Bus_Err, Dev_Err, Intr, Host_Busy */ + errmask=0x9f; + } else { + /* Erronenous conditions during transaction: + * Failed, Bus_Err, Dev_Err, Intr */ + errmask=0x1e; + } if (temp & errmask) { -#ifdef DEBUG - printk - (KERN_DEBUG "i2c-i801.o: SMBus busy (%02x). Resetting... \n", - temp); -#endif + dev_dbg(&I801_dev->dev, "SMBus busy (%02x). " + "Resetting... \n", temp); outb_p(temp, SMBHSTSTS); if (((temp = inb_p(SMBHSTSTS)) & errmask) != 0x00) { - printk - (KERN_ERR "i2c-i801.o: Reset failed! (%02x)\n", - temp); + dev_err(&I801_dev->dev, + "Reset failed! (%02x)\n", temp); result = -1; goto END; } if (i != 1) { - result = -1; /* if die in middle of block transaction, fail */ - goto END; - } + /* if die in middle of block transaction, fail */ + result = -1; + goto END; + } } - if (i == 1) { -#if 0 /* #ifdef HAVE_PEC (now using HW PEC) */ - if(isich4 && command == I2C_SMBUS_BLOCK_DATA_PEC) { - if(read_write == I2C_SMBUS_WRITE) - outb_p(data->block[len + 1], SMBPEC); - } -#endif + if (i == 1) outb_p(inb(SMBHSTCNT) | I801_START, SMBHSTCNT); - } /* We will always wait for a fraction of a second! */ timeout = 0; @@ -410,25 +348,19 @@ /* If the SMBus is still busy, we give up */ if (timeout >= MAX_TIMEOUT) { result = -1; -#ifdef DEBUG - printk(KERN_DEBUG "i2c-i801.o: SMBus Timeout!\n"); -#endif + dev_dbg(&I801_dev->dev, "SMBus Timeout!\n"); } if (temp & 0x10) { result = -1; -#ifdef DEBUG - printk - (KERN_DEBUG "i2c-i801.o: Error: Failed bus transaction\n"); -#endif + dev_dbg(&I801_dev->dev, + "Error: Failed bus transaction\n"); } else if (temp & 0x08) { result = -1; - printk(KERN_ERR "i2c-i801.o: Bus collision!\n"); + dev_err(&I801_dev->dev, "Bus collision!\n"); } else if (temp & 0x04) { result = -1; -#ifdef DEBUG - printk(KERN_DEBUG "i2c-i801.o: Error: no response!\n"); -#endif + dev_dbg(&I801_dev->dev, "Error: no response!\n"); } if (i == 1 && read_write == I2C_SMBUS_READ) { @@ -440,7 +372,7 @@ data->block[0] = len; } - /* Retrieve/store value in SMBBLKDAT */ + /* Retrieve/store value in SMBBLKDAT */ if (read_write == I2C_SMBUS_READ) data->block[i] = inb_p(SMBBLKDAT); if (read_write == I2C_SMBUS_WRITE && i+1 <= len) @@ -448,18 +380,15 @@ if ((temp & 0x9e) != 0x00) outb_p(temp, SMBHSTSTS); /* signals SMBBLKDAT ready */ -#ifdef DEBUG if ((temp = (0x1e & inb_p(SMBHSTSTS))) != 0x00) { - printk - (KERN_DEBUG "i2c-i801.o: Bad status (%02x) at end of transaction\n", - temp); - } - printk - (KERN_DEBUG "i2c-i801.o: Block (post %d): CNT=%02x, CMD=%02x, ADD=%02x, " - "DAT0=%02x, BLKDAT=%02x\n", i, inb_p(SMBHSTCNT), - inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), - inb_p(SMBBLKDAT)); -#endif + dev_dbg(&I801_dev->dev, + "Bad status (%02x) at end of transaction\n", + temp); + } + dev_dbg(&I801_dev->dev, "Block (post %d): CNT=%02x, CMD=%02x, " + "ADD=%02x, DAT0=%02x, BLKDAT=%02x\n", i, + inb_p(SMBHSTCNT), inb_p(SMBHSTCMD), inb_p(SMBHSTADD), + inb_p(SMBHSTDAT0), inb_p(SMBBLKDAT)); if (result < 0) goto END; @@ -476,29 +405,24 @@ && (timeout++ < MAX_TIMEOUT)); if (timeout >= MAX_TIMEOUT) { - printk(KERN_DEBUG "i2c-i801.o: PEC Timeout!\n"); + dev_dbg(&I801_dev->dev, "PEC Timeout!\n"); } -#if 0 /* now using HW PEC */ - if(read_write == I2C_SMBUS_READ) { - data->block[len + 1] = inb_p(SMBPEC); - } -#endif outb_p(temp, SMBHSTSTS); } #endif - result = 0; + result = 0; END: - if (command == I2C_SMBUS_I2C_BLOCK_DATA) { - /* restore saved configuration register value */ + if (command == I2C_SMBUS_I2C_BLOCK_DATA) { + /* restore saved configuration register value */ pci_write_config_byte(I801_dev, SMBHSTCFG, hostc); - } + } return result; } /* Return -1 on error. */ -s32 i801_access(struct i2c_adapter * adap, u16 addr, unsigned short flags, - char read_write, u8 command, int size, - union i2c_smbus_data * data) +static s32 i801_access(struct i2c_adapter * adap, u16 addr, + unsigned short flags, char read_write, u8 command, + int size, union i2c_smbus_data * data) { int hwpec = 0; int block = 0; @@ -554,7 +478,7 @@ break; case I2C_SMBUS_PROC_CALL: default: - printk(KERN_ERR "i2c-i801.o: Unsupported transaction %d\n", size); + dev_err(&I801_dev->dev, "Unsupported transaction %d\n", size); return -1; } @@ -600,7 +524,7 @@ } -u32 i801_func(struct i2c_adapter *adapter) +static u32 i801_func(struct i2c_adapter *adapter) { return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | @@ -627,8 +551,6 @@ .algo = &smbus_algorithm, }; - - static struct pci_device_id i801_ids[] __devinitdata = { { .vendor = PCI_VENDOR_ID_INTEL, @@ -650,13 +572,13 @@ }, { .vendor = PCI_VENDOR_ID_INTEL, - .device = PCI_DEVICE_ID_INTEL_82801CA_SMBUS, + .device = PCI_DEVICE_ID_INTEL_82801CA_3, .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, }, { .vendor = PCI_VENDOR_ID_INTEL, - .device = PCI_DEVICE_ID_INTEL_82801DB_SMBUS, + .device = PCI_DEVICE_ID_INTEL_82801DB_3, .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, }, @@ -667,8 +589,8 @@ { if (i801_setup(dev)) { - printk - (KERN_WARNING "i2c-i801.o: I801 not detected, module not inserted.\n"); + dev_warn(&dev->dev, + "I801 not detected, module not inserted.\n"); return -ENODEV; } @@ -694,22 +616,21 @@ static int __init i2c_i801_init(void) { - printk(KERN_INFO "i2c-i801.o version %s (%s)\n", I2C_VERSION, I2C_DATE); + printk(KERN_INFO "i2c-i801 version %s (%s)\n", I2C_VERSION, I2C_DATE); return pci_module_init(&i801_driver); } - static void __exit i2c_i801_exit(void) { pci_unregister_driver(&i801_driver); release_region(i801_smba, (isich4 ? 16 : 8)); } - - -MODULE_AUTHOR - ("Frodo Looijaard , Philip Edelbrock , and Mark D. Studebaker "); +MODULE_AUTHOR ("Frodo Looijaard , " + "Philip Edelbrock , " + "and Mark D. Studebaker "); MODULE_DESCRIPTION("I801 SMBus driver"); +MODULE_LICENSE("GPL"); module_init(i2c_i801_init); module_exit(i2c_i801_exit); diff -Nru a/drivers/i2c/busses/i2c-isa.c b/drivers/i2c/busses/i2c-isa.c --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/drivers/i2c/busses/i2c-isa.c Sun Mar 23 00:22:57 2003 @@ -0,0 +1,62 @@ +/* + i2c-isa.c - Part of lm_sensors, Linux kernel modules for hardware + monitoring + Copyright (c) 1998, 1999 Frodo Looijaard + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/* This implements an i2c algorithm/adapter for ISA bus. Not that this is + on first sight very useful; almost no functionality is preserved. + Except that it makes writing drivers for chips which can be on both + the SMBus and the ISA bus very much easier. See lm78.c for an example + of this. */ + +#include +#include +#include +#include +#include + +/* This is the actual algorithm we define */ +static struct i2c_algorithm isa_algorithm = { + .name = "ISA bus algorithm", + .id = I2C_ALGO_ISA, +}; + +/* There can only be one... */ +static struct i2c_adapter isa_adapter = { + .owner = THIS_MODULE, + .name = "ISA main adapter", + .id = I2C_ALGO_ISA | I2C_HW_ISA, + .algo = &isa_algorithm, +}; + +static int __init i2c_isa_init(void) +{ + return i2c_add_adapter(&isa_adapter); +} + +static void __exit i2c_isa_exit(void) +{ + i2c_del_adapter(&isa_adapter); +} + +MODULE_AUTHOR("Frodo Looijaard "); +MODULE_DESCRIPTION("ISA bus access through i2c"); +MODULE_LICENSE("GPL"); + +module_init(i2c_isa_init); +module_exit(i2c_isa_exit); diff -Nru a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c --- a/drivers/i2c/busses/i2c-piix4.c Sun Mar 23 00:22:51 2003 +++ b/drivers/i2c/busses/i2c-piix4.c Sun Mar 23 00:22:51 2003 @@ -28,6 +28,8 @@ Note: we assume there can only be one device, with one SMBus interface. */ +/* #define DEBUG 1 */ + #include #include #include @@ -49,37 +51,37 @@ }; /* PIIX4 SMBus address offsets */ -#define SMBHSTSTS (0 + piix4_smba) -#define SMBHSLVSTS (1 + piix4_smba) -#define SMBHSTCNT (2 + piix4_smba) -#define SMBHSTCMD (3 + piix4_smba) -#define SMBHSTADD (4 + piix4_smba) -#define SMBHSTDAT0 (5 + piix4_smba) -#define SMBHSTDAT1 (6 + piix4_smba) -#define SMBBLKDAT (7 + piix4_smba) -#define SMBSLVCNT (8 + piix4_smba) -#define SMBSHDWCMD (9 + piix4_smba) -#define SMBSLVEVT (0xA + piix4_smba) -#define SMBSLVDAT (0xC + piix4_smba) +#define SMBHSTSTS (0 + piix4_smba) +#define SMBHSLVSTS (1 + piix4_smba) +#define SMBHSTCNT (2 + piix4_smba) +#define SMBHSTCMD (3 + piix4_smba) +#define SMBHSTADD (4 + piix4_smba) +#define SMBHSTDAT0 (5 + piix4_smba) +#define SMBHSTDAT1 (6 + piix4_smba) +#define SMBBLKDAT (7 + piix4_smba) +#define SMBSLVCNT (8 + piix4_smba) +#define SMBSHDWCMD (9 + piix4_smba) +#define SMBSLVEVT (0xA + piix4_smba) +#define SMBSLVDAT (0xC + piix4_smba) /* PCI Address Constants */ -#define SMBBA 0x090 -#define SMBHSTCFG 0x0D2 -#define SMBSLVC 0x0D3 -#define SMBSHDW1 0x0D4 -#define SMBSHDW2 0x0D5 -#define SMBREV 0x0D6 +#define SMBBA 0x090 +#define SMBHSTCFG 0x0D2 +#define SMBSLVC 0x0D3 +#define SMBSHDW1 0x0D4 +#define SMBSHDW2 0x0D5 +#define SMBREV 0x0D6 /* Other settings */ -#define MAX_TIMEOUT 500 -#define ENABLE_INT9 0 +#define MAX_TIMEOUT 500 +#define ENABLE_INT9 0 /* PIIX4 constants */ -#define PIIX4_QUICK 0x00 -#define PIIX4_BYTE 0x04 -#define PIIX4_BYTE_DATA 0x08 -#define PIIX4_WORD_DATA 0x0C -#define PIIX4_BLOCK_DATA 0x14 +#define PIIX4_QUICK 0x00 +#define PIIX4_BYTE 0x04 +#define PIIX4_BYTE_DATA 0x08 +#define PIIX4_WORD_DATA 0x0C +#define PIIX4_BLOCK_DATA 0x14 /* insmod parameters */ @@ -102,6 +104,7 @@ static unsigned short piix4_smba = 0; +static struct i2c_adapter piix4_adapter; /* * Get DMI information. @@ -125,18 +128,17 @@ if (PCI_FUNC(PIIX4_dev->devfn) != id->driver_data) return -ENODEV; - printk(KERN_INFO "i2c-piix4.o: Found %s device\n", PIIX4_dev->dev.name); + dev_info(&PIIX4_dev->dev, "Found %s device\n", PIIX4_dev->dev.name); if(ibm_dmi_probe()) { - printk - (KERN_ERR "i2c-piix4.o: IBM Laptop detected; this module may corrupt\n"); - printk - (KERN_ERR " your serial eeprom! Refusing to load module!\n"); - error_return = -EPERM; - goto END; + dev_err(&PIIX4_dev->dev, "IBM Laptop detected; this module " + "may corrupt your serial eeprom! Refusing to load " + "module!\n"); + error_return = -EPERM; + goto END; } -/* Determine the address of the SMBus areas */ + /* Determine the address of the SMBus areas */ if (force_addr) { piix4_smba = force_addr & 0xfff0; force = 0; @@ -144,75 +146,68 @@ pci_read_config_word(PIIX4_dev, SMBBA, &piix4_smba); piix4_smba &= 0xfff0; if(piix4_smba == 0) { - printk(KERN_ERR "i2c-piix4.o: SMB base address uninitialized - upgrade BIOS or use force_addr=0xaddr\n"); + dev_err(&PIIX4_dev->dev, "SMB base address " + "uninitialized - upgrade BIOS or use " + "force_addr=0xaddr\n"); return -ENODEV; } } - if (check_region(piix4_smba, 8)) { - printk - (KERN_ERR "i2c-piix4.o: SMB region 0x%x already in use!\n", - piix4_smba); + if (!request_region(piix4_smba, 8, "piix4-smbus")) { + dev_err(&PIIX4_dev->dev, "SMB region 0x%x already in use!\n", + piix4_smba); error_return = -ENODEV; goto END; } pci_read_config_byte(PIIX4_dev, SMBHSTCFG, &temp); -/* If force_addr is set, we program the new address here. Just to make - sure, we disable the PIIX4 first. */ + /* If force_addr is set, we program the new address here. Just to make + sure, we disable the PIIX4 first. */ if (force_addr) { pci_write_config_byte(PIIX4_dev, SMBHSTCFG, temp & 0xfe); pci_write_config_word(PIIX4_dev, SMBBA, piix4_smba); pci_write_config_byte(PIIX4_dev, SMBHSTCFG, temp | 0x01); - printk - (KERN_INFO "i2c-piix4.o: WARNING: SMBus interface set to new " - "address %04x!\n", piix4_smba); + dev_info(&PIIX4_dev->dev, "WARNING: SMBus interface set to " + "new address %04x!\n", piix4_smba); } else if ((temp & 1) == 0) { if (force) { -/* This should never need to be done, but has been noted that - many Dell machines have the SMBus interface on the PIIX4 - disabled!? NOTE: This assumes I/O space and other allocations WERE - done by the Bios! Don't complain if your hardware does weird - things after enabling this. :') Check for Bios updates before - resorting to this. */ + /* This should never need to be done, but has been + * noted that many Dell machines have the SMBus + * interface on the PIIX4 disabled!? NOTE: This assumes + * I/O space and other allocations WERE done by the + * Bios! Don't complain if your hardware does weird + * things after enabling this. :') Check for Bios + * updates before resorting to this. + */ pci_write_config_byte(PIIX4_dev, SMBHSTCFG, temp | 1); - printk - (KERN_NOTICE "i2c-piix4.o: WARNING: SMBus interface has been FORCEFULLY " - "ENABLED!\n"); + dev_printk(KERN_NOTICE, &PIIX4_dev->dev, + "WARNING: SMBus interface has been " + "FORCEFULLY ENABLED!\n"); } else { - printk - (KERN_ERR "i2c-piix4.o: Host SMBus controller not enabled!\n"); + dev_err(&PIIX4_dev->dev, + "Host SMBus controller not enabled!\n"); error_return = -ENODEV; goto END; } } - /* Everything is happy, let's grab the memory and set things up. */ - request_region(piix4_smba, 8, "piix4-smbus"); - -#ifdef DEBUG if ((temp & 0x0E) == 8) - printk - (KERN_DEBUG "i2c-piix4.o: Using Interrupt 9 for SMBus.\n"); + dev_dbg(&PIIX4_dev->dev, "Using Interrupt 9 for SMBus.\n"); else if ((temp & 0x0E) == 0) - printk - (KERN_DEBUG "i2c-piix4.o: Using Interrupt SMI# for SMBus.\n"); + dev_dbg(&PIIX4_dev->dev, "Using Interrupt SMI# for SMBus.\n"); else - printk - (KERN_ERR "i2c-piix4.o: Illegal Interrupt configuration (or code out " - "of date)!\n"); + dev_err(&PIIX4_dev->dev, "Illegal Interrupt configuration " + "(or code out of date)!\n"); pci_read_config_byte(PIIX4_dev, SMBREV, &temp); - printk(KERN_DEBUG "i2c-piix4.o: SMBREV = 0x%X\n", temp); - printk(KERN_DEBUG "i2c-piix4.o: SMBA = 0x%X\n", piix4_smba); -#endif /* DEBUG */ + dev_dbg(&PIIX4_dev->dev, "SMBREV = 0x%X\n", temp); + dev_dbg(&PIIX4_dev->dev, "SMBA = 0x%X\n", piix4_smba); - END: +END: return error_return; } - /* Internally used pause function */ static void piix4_do_pause(unsigned int amount) { @@ -227,29 +222,21 @@ int result = 0; int timeout = 0; -#ifdef DEBUG - printk - (KERN_DEBUG "i2c-piix4.o: Transaction (pre): CNT=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, " - "DAT1=%02x\n", inb_p(SMBHSTCNT), inb_p(SMBHSTCMD), - inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), inb_p(SMBHSTDAT1)); -#endif + dev_dbg(&piix4_adapter.dev, "Transaction (pre): CNT=%02x, CMD=%02x, " + "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT), + inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), + inb_p(SMBHSTDAT1)); /* Make sure the SMBus host is ready to start transmitting */ if ((temp = inb_p(SMBHSTSTS)) != 0x00) { -#ifdef DEBUG - printk(KERN_DEBUG "i2c-piix4.o: SMBus busy (%02x). Resetting... \n", - temp); -#endif + dev_dbg(&piix4_adapter.dev, "SMBus busy (%02x). " + "Resetting... \n", temp); outb_p(temp, SMBHSTSTS); if ((temp = inb_p(SMBHSTSTS)) != 0x00) { -#ifdef DEBUG - printk(KERN_ERR "i2c-piix4.o: Failed! (%02x)\n", temp); -#endif + dev_err(&piix4_adapter.dev, "Failed! (%02x)\n", temp); return -1; } else { -#ifdef DEBUG - printk(KERN_DEBUG "i2c-piix4.o: Successfull!\n"); -#endif + dev_dbg(&piix4_adapter.dev, "Successfull!\n"); } } @@ -262,50 +249,40 @@ temp = inb_p(SMBHSTSTS); } while ((temp & 0x01) && (timeout++ < MAX_TIMEOUT)); -#ifdef DEBUG /* If the SMBus is still busy, we give up */ if (timeout >= MAX_TIMEOUT) { - printk(KERN_ERR "i2c-piix4.o: SMBus Timeout!\n"); + dev_err(&piix4_adapter.dev, "SMBus Timeout!\n"); result = -1; } -#endif if (temp & 0x10) { result = -1; -#ifdef DEBUG - printk(KERN_ERR "i2c-piix4.o: Error: Failed bus transaction\n"); -#endif + dev_err(&piix4_adapter.dev, "Error: Failed bus transaction\n"); } if (temp & 0x08) { result = -1; - printk - (KERN_ERR "i2c-piix4.o: Bus collision! SMBus may be locked until next hard\n" - "reset. (sorry!)\n"); + dev_dbg(&piix4_adapter.dev, "Bus collision! SMBus may be " + "locked until next hard reset. (sorry!)\n"); /* Clock stops and slave is stuck in mid-transmission */ } if (temp & 0x04) { result = -1; -#ifdef DEBUG - printk(KERN_ERR "i2c-piix4.o: Error: no response!\n"); -#endif + dev_err(&piix4_adapter.dev, "Error: no response!\n"); } if (inb_p(SMBHSTSTS) != 0x00) outb_p(inb(SMBHSTSTS), SMBHSTSTS); -#ifdef DEBUG if ((temp = inb_p(SMBHSTSTS)) != 0x00) { - printk - (KERN_ERR "i2c-piix4.o: Failed reset at end of transaction (%02x)\n", - temp); - } - printk - (KERN_DEBUG "i2c-piix4.o: Transaction (post): CNT=%02x, CMD=%02x, ADD=%02x, " - "DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT), inb_p(SMBHSTCMD), - inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), inb_p(SMBHSTDAT1)); -#endif + dev_err(&piix4_adapter.dev, "Failed reset at end of " + "transaction (%02x)\n", temp); + } + dev_dbg(&piix4_adapter.dev, "Transaction (post): CNT=%02x, CMD=%02x, " + "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT), + inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), + inb_p(SMBHSTDAT1)); return result; } @@ -318,8 +295,7 @@ switch (size) { case I2C_SMBUS_PROC_CALL: - printk - (KERN_ERR "i2c-piix4.o: I2C_SMBUS_PROC_CALL not supported!\n"); + dev_err(&adap->dev, "I2C_SMBUS_PROC_CALL not supported!\n"); return -1; case I2C_SMBUS_QUICK: outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), @@ -402,7 +378,6 @@ return 0; } - static u32 piix4_func(struct i2c_adapter *adapter) { return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | @@ -424,8 +399,6 @@ .algo = &smbus_algorithm, }; - - static struct pci_device_id piix4_ids[] __devinitdata = { { .vendor = PCI_VENDOR_ID_INTEL, @@ -468,7 +441,7 @@ static int __devinit piix4_probe(struct pci_dev *dev, const struct pci_device_id *id) { int retval; - + retval = piix4_setup(dev, id); if (retval) return retval; @@ -499,7 +472,7 @@ static int __init i2c_piix4_init(void) { - printk("i2c-piix4.o version %s (%s)\n", I2C_VERSION, I2C_DATE); + printk(KERN_INFO "i2c-piix4 version %s (%s)\n", I2C_VERSION, I2C_DATE); return pci_module_init(&piix4_driver); } @@ -509,8 +482,6 @@ pci_unregister_driver(&piix4_driver); release_region(piix4_smba, 8); } - - MODULE_AUTHOR ("Frodo Looijaard and Philip Edelbrock "); diff -Nru a/drivers/i2c/chips/adm1021.c b/drivers/i2c/chips/adm1021.c --- a/drivers/i2c/chips/adm1021.c Sun Mar 23 00:22:49 2003 +++ b/drivers/i2c/chips/adm1021.c Sun Mar 23 00:22:50 2003 @@ -93,9 +93,9 @@ /* Initial values */ -/* Note: Eventhough I left the low and high limits named os and hyst, +/* Note: Even though I left the low and high limits named os and hyst, they don't quite work like a thermostat the way the LM75 does. I.e., -a lower temp than THYST actuall triggers an alarm instead of +a lower temp than THYST actually triggers an alarm instead of clearing it. Weird, ey? --Phil */ #define adm1021_INIT_TOS 60 #define adm1021_INIT_THYST 20 diff -Nru a/drivers/i2c/chips/lm75.c b/drivers/i2c/chips/lm75.c --- a/drivers/i2c/chips/lm75.c Sun Mar 23 00:22:49 2003 +++ b/drivers/i2c/chips/lm75.c Sun Mar 23 00:22:49 2003 @@ -25,7 +25,7 @@ #include -#define LM75_SYSCTL_TEMP 1200 /* Degrees Celcius * 10 */ +#define LM75_SYSCTL_TEMP 1200 /* Degrees Celsius * 10 */ /* Addresses to scan */ static unsigned short normal_i2c[] = { SENSORS_I2C_END }; diff -Nru a/drivers/i2c/i2c-algo-pcf.c b/drivers/i2c/i2c-algo-pcf.c --- a/drivers/i2c/i2c-algo-pcf.c Sun Mar 23 00:22:55 2003 +++ b/drivers/i2c/i2c-algo-pcf.c Sun Mar 23 00:22:55 2003 @@ -152,7 +152,7 @@ /* load own address in S0, effective address is (own << 1) */ i2c_outb(adap, get_own(adap)); - /* check it's realy writen */ + /* check it's really written */ if ((temp = i2c_inb(adap)) != get_own(adap)) { DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't set S0 (0x%02x).\n", temp)); return -ENXIO; @@ -168,7 +168,7 @@ /* load clock register S2 */ i2c_outb(adap, get_clock(adap)); - /* check it's realy writen, the only 5 lowest bits does matter */ + /* check it's really written, the only 5 lowest bits does matter */ if (((temp = i2c_inb(adap)) & 0x1f) != get_clock(adap)) { DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't set S2 (0x%02x).\n", temp)); return -ENXIO; @@ -177,7 +177,7 @@ /* Enable serial interface, idle, S0 selected */ set_pcf(adap, 1, I2C_PCF_IDLE); - /* check to see PCF is realy idled and we can access status register */ + /* check to see PCF is really idled and we can access status register */ if ((temp = get_pcf(adap, 1)) != (I2C_PCF_PIN | I2C_PCF_BB)) { DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S1` (0x%02x).\n", temp)); return -ENXIO; diff -Nru a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c --- a/drivers/i2c/i2c-core.c Sun Mar 23 00:22:50 2003 +++ b/drivers/i2c/i2c-core.c Sun Mar 23 00:22:50 2003 @@ -53,6 +53,16 @@ #endif /* CONFIG_PROC_FS */ +int i2c_device_probe(struct device *dev) +{ + return -ENODEV; +} + +int i2c_device_remove(struct device *dev) +{ + return 0; +} + /* --------------------------------------------------- * registering functions * --------------------------------------------------- @@ -204,6 +214,16 @@ drivers[i] = driver; DEB(printk(KERN_DEBUG "i2c-core.o: driver %s registered.\n",driver->name)); + + /* add the driver to the list of i2c drivers in the driver core */ + driver->driver.name = driver->name; + driver->driver.bus = &i2c_bus_type; + driver->driver.probe = i2c_device_probe; + driver->driver.remove = i2c_device_remove; + + res = driver_register(&driver->driver); + if (res) + goto out_unlock; /* now look for instances of driver on our adapters */ @@ -235,6 +255,8 @@ res = -ENODEV; goto out_unlock; } + + driver_unregister(&driver->driver); /* Have a look at each adapter, if clients of this driver are still * attached. If so, detach them to be able to kill the driver diff -Nru a/drivers/i2c/i2c-proc.c b/drivers/i2c/i2c-proc.c --- a/drivers/i2c/i2c-proc.c Sun Mar 23 00:22:53 2003 +++ b/drivers/i2c/i2c-proc.c Sun Mar 23 00:22:53 2003 @@ -270,7 +270,7 @@ } -/* This funcion reads or writes a 'real' value (encoded by the combination +/* This function reads or writes a 'real' value (encoded by the combination of an integer and a magnitude, the last is the power of ten the value should be divided with) to a /proc/sys directory. To use this function, you must (before registering the ctl_table) set the extra2 field to the diff -Nru a/drivers/ide/Makefile b/drivers/ide/Makefile --- a/drivers/ide/Makefile Sun Mar 23 00:22:53 2003 +++ b/drivers/ide/Makefile Sun Mar 23 00:22:53 2003 @@ -12,7 +12,7 @@ # Core IDE code - must come before legacy -obj-$(CONFIG_BLK_DEV_IDE) += ide-io.o ide-probe.o ide-geometry.o ide-iops.o ide-taskfile.o ide.o ide-lib.o +obj-$(CONFIG_BLK_DEV_IDE) += ide-io.o ide-probe.o ide-geometry.o ide-iops.o ide-taskfile.o ide.o ide-lib.o ide-default.o obj-$(CONFIG_BLK_DEV_IDEDISK) += ide-disk.o obj-$(CONFIG_BLK_DEV_IDECD) += ide-cd.o obj-$(CONFIG_BLK_DEV_IDETAPE) += ide-tape.o diff -Nru a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c --- a/drivers/ide/ide-cd.c Sun Mar 23 00:22:52 2003 +++ b/drivers/ide/ide-cd.c Sun Mar 23 00:22:52 2003 @@ -294,7 +294,7 @@ * *************************************************************************/ -#define IDECD_VERSION "4.59" +#define IDECD_VERSION "4.59-ac1" #include #include @@ -635,6 +635,23 @@ return ide_stopped; } +ide_startstop_t ide_cdrom_abort (ide_drive_t *drive, const char *msg) +{ + struct request *rq; + + if (drive == NULL || (rq = HWGROUP(drive)->rq) == NULL) + return ide_stopped; + /* retry only "normal" I/O: */ + if (rq->flags & (REQ_DRIVE_CMD | REQ_DRIVE_TASK)) { + rq->errors = 1; + ide_end_drive_cmd(drive, BUSY_STAT, 0); + return ide_stopped; + } + rq->errors |= ERROR_RESET; + DRIVER(drive)->end_request(drive, 0, 0); + return ide_stopped; +} + static void cdrom_end_request (ide_drive_t *drive, int uptodate) { struct request *rq = HWGROUP(drive)->rq; @@ -899,9 +916,6 @@ return startstop; } - if (HWGROUP(drive)->handler != NULL) /* paranoia check */ - BUG(); - /* Arm the interrupt handler. */ ide_set_handler(drive, handler, rq->timeout, cdrom_timer_expiry); @@ -1133,9 +1147,6 @@ } } - if (HWGROUP(drive)->handler != NULL) /* paranoia check */ - BUG(); - /* Done moving data! Wait for another interrupt. */ ide_set_handler(drive, &cdrom_read_intr, WAIT_CMD, NULL); return ide_started; @@ -1470,9 +1481,6 @@ rq->flags |= REQ_FAILED; } - if (HWGROUP(drive)->handler != NULL) - BUG(); - /* Now we wait for another interrupt. */ ide_set_handler(drive, &cdrom_pc_intr, WAIT_CMD, cdrom_timer_expiry); return ide_started; @@ -1863,9 +1871,6 @@ cdrom_end_request(drive, 1); } - if (HWGROUP(drive)->handler != NULL) /* paranoia check */ - BUG(); - /* re-arm handler */ ide_set_handler(drive, &cdrom_write_intr, 5 * WAIT_CMD, NULL); return ide_started; @@ -2837,11 +2842,9 @@ * ACER50 (and others?) require the full spec length mode sense * page capabilities size, but older drives break. */ - if (drive->id) { - if (!(!strcmp(drive->id->model, "ATAPI CD ROM DRIVE 50X MAX") || - !strcmp(drive->id->model, "WPI CDS-32X"))) - size -= sizeof(cap->pad); - } + if (!(!strcmp(drive->id->model, "ATAPI CD ROM DRIVE 50X MAX") || + !strcmp(drive->id->model, "WPI CDS-32X"))) + size -= sizeof(cap->pad); /* we have to cheat a little here. the packet will eventually * be queued with ide_cdrom_packet(), which extracts the @@ -2924,7 +2927,7 @@ } /* The ACER/AOpen 24X cdrom has the speed fields byte-swapped */ - if (drive->id && !drive->id->model[0] && + if (!drive->id->model[0] && !strncmp(drive->id->fw_rev, "241N", 4)) { CDROM_STATE_FLAGS(drive)->current_speed = (((unsigned int)cap.curspeed) + (176/2)) / 176; @@ -3089,12 +3092,7 @@ CDROM_CONFIG_FLAGS(drive)->no_doorlock = 0; #endif - if (drive->id != NULL) - CDROM_CONFIG_FLAGS(drive)->drq_interrupt = - ((drive->id->config & 0x0060) == 0x20); - else - CDROM_CONFIG_FLAGS(drive)->drq_interrupt = 0; - + CDROM_CONFIG_FLAGS(drive)->drq_interrupt = ((drive->id->config & 0x0060) == 0x20); CDROM_CONFIG_FLAGS(drive)->is_changer = 0; CDROM_CONFIG_FLAGS(drive)->cd_r = 0; CDROM_CONFIG_FLAGS(drive)->cd_rw = 0; @@ -3109,16 +3107,14 @@ /* limit transfer size per interrupt. */ CDROM_CONFIG_FLAGS(drive)->limit_nframes = 0; - if (drive->id != NULL) { - /* a testament to the nice quality of Samsung drives... */ - if (!strcmp(drive->id->model, "SAMSUNG CD-ROM SCR-2430")) - CDROM_CONFIG_FLAGS(drive)->limit_nframes = 1; - else if (!strcmp(drive->id->model, "SAMSUNG CD-ROM SCR-2432")) - CDROM_CONFIG_FLAGS(drive)->limit_nframes = 1; - /* the 3231 model does not support the SET_CD_SPEED command */ - else if (!strcmp(drive->id->model, "SAMSUNG CD-ROM SCR-3231")) - cdi->mask |= CDC_SELECT_SPEED; - } + /* a testament to the nice quality of Samsung drives... */ + if (!strcmp(drive->id->model, "SAMSUNG CD-ROM SCR-2430")) + CDROM_CONFIG_FLAGS(drive)->limit_nframes = 1; + else if (!strcmp(drive->id->model, "SAMSUNG CD-ROM SCR-2432")) + CDROM_CONFIG_FLAGS(drive)->limit_nframes = 1; + /* the 3231 model does not support the SET_CD_SPEED command */ + else if (!strcmp(drive->id->model, "SAMSUNG CD-ROM SCR-3231")) + cdi->mask |= CDC_SELECT_SPEED; #if ! STANDARD_ATAPI /* by default Sanyo 3 CD changer support is turned off and @@ -3131,55 +3127,47 @@ CDROM_CONFIG_FLAGS(drive)->playmsf_as_bcd = 0; CDROM_CONFIG_FLAGS(drive)->subchan_as_bcd = 0; - if (drive->id != NULL) { - if (strcmp (drive->id->model, "V003S0DS") == 0 && - drive->id->fw_rev[4] == '1' && - drive->id->fw_rev[6] <= '2') { - /* Vertos 300. - Some versions of this drive like to talk BCD. */ - CDROM_CONFIG_FLAGS(drive)->toctracks_as_bcd = 1; - CDROM_CONFIG_FLAGS(drive)->tocaddr_as_bcd = 1; - CDROM_CONFIG_FLAGS(drive)->playmsf_as_bcd = 1; - CDROM_CONFIG_FLAGS(drive)->subchan_as_bcd = 1; - } - - else if (strcmp (drive->id->model, "V006E0DS") == 0 && - drive->id->fw_rev[4] == '1' && - drive->id->fw_rev[6] <= '2') { - /* Vertos 600 ESD. */ - CDROM_CONFIG_FLAGS(drive)->toctracks_as_bcd = 1; - } - - else if (strcmp(drive->id->model, - "NEC CD-ROM DRIVE:260") == 0 && - strncmp(drive->id->fw_rev, "1.01", 4) == 0) { /* FIXME */ - /* Old NEC260 (not R). - This drive was released before the 1.2 version - of the spec. */ - CDROM_CONFIG_FLAGS(drive)->tocaddr_as_bcd = 1; - CDROM_CONFIG_FLAGS(drive)->playmsf_as_bcd = 1; - CDROM_CONFIG_FLAGS(drive)->subchan_as_bcd = 1; - CDROM_CONFIG_FLAGS(drive)->nec260 = 1; - } - - else if (strcmp(drive->id->model, "WEARNES CDD-120") == 0 && - strncmp(drive->id->fw_rev, "A1.1", 4) == 0) { /* FIXME */ - /* Wearnes */ - CDROM_CONFIG_FLAGS(drive)->playmsf_as_bcd = 1; - CDROM_CONFIG_FLAGS(drive)->subchan_as_bcd = 1; - } - - /* Sanyo 3 CD changer uses a non-standard command - for CD changing */ - else if ((strcmp(drive->id->model, "CD-ROM CDR-C3 G") == 0) || - (strcmp(drive->id->model, "CD-ROM CDR-C3G") == 0) || - (strcmp(drive->id->model, "CD-ROM CDR_C36") == 0)) { - /* uses CD in slot 0 when value is set to 3 */ - cdi->sanyo_slot = 3; - } - - - } + if (strcmp (drive->id->model, "V003S0DS") == 0 && + drive->id->fw_rev[4] == '1' && + drive->id->fw_rev[6] <= '2') { + /* Vertos 300. + Some versions of this drive like to talk BCD. */ + CDROM_CONFIG_FLAGS(drive)->toctracks_as_bcd = 1; + CDROM_CONFIG_FLAGS(drive)->tocaddr_as_bcd = 1; + CDROM_CONFIG_FLAGS(drive)->playmsf_as_bcd = 1; + CDROM_CONFIG_FLAGS(drive)->subchan_as_bcd = 1; + } + + else if (strcmp (drive->id->model, "V006E0DS") == 0 && + drive->id->fw_rev[4] == '1' && + drive->id->fw_rev[6] <= '2') { + /* Vertos 600 ESD. */ + CDROM_CONFIG_FLAGS(drive)->toctracks_as_bcd = 1; + } + else if (strcmp(drive->id->model, "NEC CD-ROM DRIVE:260") == 0 && + strncmp(drive->id->fw_rev, "1.01", 4) == 0) { /* FIXME */ + /* Old NEC260 (not R). + This drive was released before the 1.2 version + of the spec. */ + CDROM_CONFIG_FLAGS(drive)->tocaddr_as_bcd = 1; + CDROM_CONFIG_FLAGS(drive)->playmsf_as_bcd = 1; + CDROM_CONFIG_FLAGS(drive)->subchan_as_bcd = 1; + CDROM_CONFIG_FLAGS(drive)->nec260 = 1; + } + else if (strcmp(drive->id->model, "WEARNES CDD-120") == 0 && + strncmp(drive->id->fw_rev, "A1.1", 4) == 0) { /* FIXME */ + /* Wearnes */ + CDROM_CONFIG_FLAGS(drive)->playmsf_as_bcd = 1; + CDROM_CONFIG_FLAGS(drive)->subchan_as_bcd = 1; + } + /* Sanyo 3 CD changer uses a non-standard command + for CD changing */ + else if ((strcmp(drive->id->model, "CD-ROM CDR-C3 G") == 0) || + (strcmp(drive->id->model, "CD-ROM CDR-C3G") == 0) || + (strcmp(drive->id->model, "CD-ROM CDR_C36") == 0)) { + /* uses CD in slot 0 when value is set to 3 */ + cdi->sanyo_slot = 3; + } #endif /* not STANDARD_ATAPI */ info->toc = NULL; @@ -3246,6 +3234,7 @@ printk("%s: ide_cdrom_cleanup failed to unregister device from the cdrom driver.\n", drive->name); kfree(info); drive->driver_data = NULL; + blk_queue_prep_rq(&drive->queue, NULL); del_gendisk(g); g->fops = ide_fops; return 0; @@ -3265,6 +3254,7 @@ .do_request = ide_do_rw_cdrom, .sense = ide_cdrom_dump_status, .error = ide_cdrom_error, + .abort = ide_cdrom_abort, .capacity = ide_cdrom_capacity, .attach = ide_cdrom_attach, .drives = LIST_HEAD_INIT(ide_cdrom_driver.drives), diff -Nru a/drivers/ide/ide-default.c b/drivers/ide/ide-default.c --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/drivers/ide/ide-default.c Sun Mar 23 00:22:57 2003 @@ -0,0 +1,71 @@ +/* + * ide-default - Driver for unbound ide devices + * + * This provides a clean way to bind a device to default operations + * by having an actual driver class that rather than special casing + * "no driver" all over the IDE code + * + * Copyright (C) 2003, Red Hat + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#define IDEDEFAULT_VERSION "0.9.newide" +/* + * Driver initialization. + */ + +static int idedefault_attach(ide_drive_t *drive); + +/* + * IDE subdriver functions, registered with ide.c + * + * idedefault *must* support DMA because it will be + * attached before the other drivers are loaded and + * we don't want to lose the DMA status at probe + * time. + */ + +ide_driver_t idedefault_driver = { + .name = "ide-default", + .version = IDEDEFAULT_VERSION, + .attach = idedefault_attach, + .supports_dma = 1, + .drives = LIST_HEAD_INIT(idedefault_driver.drives) +}; + +static int idedefault_attach (ide_drive_t *drive) +{ + if (ide_register_subdriver(drive, + &idedefault_driver, IDE_SUBDRIVER_VERSION)) { + printk(KERN_ERR "ide-default: %s: Failed to register the " + "driver with ide.c\n", drive->name); + return 1; + } + return 0; +} + +MODULE_DESCRIPTION("IDE Default Driver"); + +MODULE_LICENSE("GPL"); diff -Nru a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c --- a/drivers/ide/ide-disk.c Sun Mar 23 00:22:52 2003 +++ b/drivers/ide/ide-disk.c Sun Mar 23 00:22:52 2003 @@ -1,11 +1,10 @@ /* - * linux/drivers/ide/ide-disk.c Version 1.16 April 7, 2002 - * - * Copyright (C) 1998-2002 Linux ATA Developemt - * Andre Hedrick - * + * linux/drivers/ide/ide-disk.c Version 1.18 Mar 05, 2003 * * Copyright (C) 1994-1998 Linus Torvalds & authors (see below) + * Copyright (C) 1998-2002 Linux ATA Development + * Andre Hedrick + * Copyright (C) 2003 Red Hat */ /* @@ -42,7 +41,7 @@ * fix wcache setup. */ -#define IDEDISK_VERSION "1.17" +#define IDEDISK_VERSION "1.18" #undef REALLY_SLOW_IO /* most systems can safely undef this */ @@ -70,7 +69,7 @@ #include #include -/* FIXME: some day we shouldnt need to look in here! */ +/* FIXME: some day we shouldn't need to look in here! */ #include "legacy/pdc4030.h" @@ -154,8 +153,6 @@ return DRIVER(drive)->error(drive, "read_intr", stat); } /* no data yet, so wait for another interrupt */ - if (HWGROUP(drive)->handler != NULL) - BUG(); ide_set_handler(drive, &read_intr, WAIT_CMD, NULL); return ide_started; } @@ -182,15 +179,13 @@ if (((long)(rq->current_nr_sectors -= nsect)) <= 0) ide_end_request(drive, 1, rq->hard_cur_sectors); /* - * Another BH Page walker and DATA INTERGRITY Questioned on ERROR. + * Another BH Page walker and DATA INTEGRITY Questioned on ERROR. * If passed back up on multimode read, BAD DATA could be ACKED * to FILE SYSTEMS above ... */ if (i > 0) { if (msect) goto read_next; - if (HWGROUP(drive)->handler != NULL) - BUG(); ide_set_handler(drive, &read_intr, WAIT_CMD, NULL); return ide_started; } @@ -230,8 +225,6 @@ char *to = ide_map_buffer(rq, &flags); taskfile_output_data(drive, to, SECTOR_WORDS); ide_unmap_buffer(rq, to, &flags); - if (HWGROUP(drive)->handler != NULL) - BUG(); ide_set_handler(drive, &write_intr, WAIT_CMD, NULL); return ide_started; } @@ -332,8 +325,6 @@ if (rq->nr_sectors) { if (ide_multwrite(drive, drive->mult_count)) return ide_stopped; - if (HWGROUP(drive)->handler != NULL) - BUG(); ide_set_handler(drive, &multwrite_intr, WAIT_CMD, NULL); return ide_started; } @@ -550,8 +541,6 @@ * MAJOR DATA INTEGRITY BUG !!! only if we error */ hwgroup->wrq = *rq; /* scratchpad */ - if (HWGROUP(drive)->handler != NULL) - BUG(); ide_set_handler(drive, &multwrite_intr, WAIT_CMD, NULL); if (ide_multwrite(drive, drive->mult_count)) { unsigned long flags; @@ -564,8 +553,6 @@ } else { unsigned long flags; char *to = ide_map_buffer(rq, &flags); - if (HWGROUP(drive)->handler != NULL) - BUG(); ide_set_handler(drive, &write_intr, WAIT_CMD, NULL); taskfile_output_data(drive, to, SECTOR_WORDS); ide_unmap_buffer(rq, to, &flags); @@ -941,6 +928,26 @@ return ide_stopped; } +ide_startstop_t idedisk_abort(ide_drive_t *drive, const char *msg) +{ + ide_hwif_t *hwif; + struct request *rq; + + if (drive == NULL || (rq = HWGROUP(drive)->rq) == NULL) + return ide_stopped; + + hwif = HWIF(drive); + + if (rq->flags & (REQ_DRIVE_CMD | REQ_DRIVE_TASK | REQ_DRIVE_TASKFILE)) { + rq->errors = 1; + ide_end_drive_cmd(drive, BUSY_STAT, 0); + return ide_stopped; + } + + DRIVER(drive)->end_request(drive, 0, 0); + return ide_stopped; +} + /* * Queries for true maximum capacity of the drive. * Returns maximum LBA address (> 0) of the drive, 0 if failed. @@ -1073,7 +1080,7 @@ { int flag = (drive->id->cfs_enable_1 & 0x0400) ? 1 : 0; if (flag) - printk("%s: host protected area => %d\n", drive->name, flag); + printk(KERN_INFO "%s: host protected area => %d\n", drive->name, flag); return flag; } @@ -1201,7 +1208,7 @@ } } else if (s->b.set_multmode) { s->b.set_multmode = 0; - if (drive->id && drive->mult_req > drive->id->max_multsect) + if (drive->mult_req > drive->id->max_multsect) drive->mult_req = drive->id->max_multsect; if (!IS_PDC4030_DRIVE) { ide_task_t args; @@ -1286,7 +1293,7 @@ char *out = page; int len; - if (drive->id) + if (drive->id_read) len = sprintf(out,"%i\n", drive->id->buf_size / 2); else len = sprintf(out,"(none)\n"); @@ -1549,7 +1556,7 @@ idedisk_add_settings(drive); - if (id == NULL) + if (drive->id_read == 0) return; /* @@ -1666,6 +1673,7 @@ .do_request = do_rw_disk, .sense = idedisk_dump_status, .error = idedisk_error, + .abort = idedisk_abort, .pre_reset = idedisk_pre_reset, .capacity = idedisk_capacity, .special = idedisk_special, diff -Nru a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c --- a/drivers/ide/ide-dma.c Sun Mar 23 00:22:53 2003 +++ b/drivers/ide/ide-dma.c Sun Mar 23 00:22:53 2003 @@ -75,7 +75,6 @@ */ #include -#define __NO_VERSION__ #include #include #include @@ -419,7 +418,7 @@ struct hd_driveid *id = drive->id; ide_hwif_t *hwif = HWIF(drive); - if (id && (id->capability & 1) && hwif->autodma) { + if ((id->capability & 1) && hwif->autodma) { /* Consult the list of known "bad" drives */ if (hwif->ide_dma_bad_drive(drive)) return hwif->ide_dma_off(drive); @@ -977,14 +976,12 @@ { printk(KERN_INFO " %s: MMIO-DMA at 0x%08lx-0x%08lx", hwif->name, base, base + ports - 1); - if (check_mem_region(base, ports)) { - printk(" -- Error, MMIO ports already in use.\n"); - return 1; - } - request_mem_region(base, ports, hwif->name); + if (!request_mem_region(base, ports, hwif->name)) + goto fail; hwif->dma_base = base; if ((hwif->cds->extra) && (hwif->channel == 0)) { - request_region(base+16, hwif->cds->extra, hwif->cds->name); + if (!request_region(base+16, hwif->cds->extra, hwif->cds->name)) + goto release_mem; hwif->dma_extra = hwif->cds->extra; } @@ -993,10 +990,18 @@ else hwif->dma_master = base; if (hwif->dma_base2) { - if (!check_mem_region(hwif->dma_base2, ports)) - request_mem_region(hwif->dma_base2, ports, hwif->name); + if (!request_mem_region(hwif->dma_base2, ports, hwif->name)) + goto release_io; } return 0; + +release_mem: + release_mem_region(base, ports); +release_io: + release_region(base+16, hwif->cds->extra); +fail: + printk(" -- Error, MMIO ports already in use.\n"); + return 1; } int ide_iomio_dma (ide_hwif_t *hwif, unsigned long base, unsigned int ports) diff -Nru a/drivers/ide/ide-geometry.c b/drivers/ide/ide-geometry.c --- a/drivers/ide/ide-geometry.c Sun Mar 23 00:22:55 2003 +++ b/drivers/ide/ide-geometry.c Sun Mar 23 00:22:55 2003 @@ -129,7 +129,7 @@ set_capacity(drive->disk, current_capacity(drive)); if (ret) - printk(KERN_INFO "%s%s [%d/%d/%d]", msg, msg1, + printk("%s%s [%d/%d/%d]", msg, msg1, drive->bios_cyl, drive->bios_head, drive->bios_sect); return ret; } diff -Nru a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c --- a/drivers/ide/ide-io.c Sun Mar 23 00:22:55 2003 +++ b/drivers/ide/ide-io.c Sun Mar 23 00:22:55 2003 @@ -330,10 +330,7 @@ hwif->OUTB(WIN_IDLEIMMEDIATE,IDE_COMMAND_REG); } if (rq->errors >= ERROR_MAX) { - if (drive->driver != NULL) - DRIVER(drive)->end_request(drive, 0, 0); - else - ide_end_request(drive, 0, 0); + DRIVER(drive)->end_request(drive, 0, 0); } else { if ((rq->errors & ERROR_RESET) == ERROR_RESET) { ++rq->errors; @@ -349,6 +346,49 @@ EXPORT_SYMBOL(ide_error); /** + * ide_abort - abort pending IDE operatins + * @drive: drive the error occurred on + * @msg: message to report + * + * ide_abort kills and cleans up when we are about to do a + * host initiated reset on active commands. Longer term we + * want handlers to have sensible abort handling themselves + * + * This differs fundamentally from ide_error because in + * this case the command is doing just fine when we + * blow it away. + */ + +ide_startstop_t ide_abort(ide_drive_t *drive, const char *msg) +{ + ide_hwif_t *hwif; + struct request *rq; + + if (drive == NULL || (rq = HWGROUP(drive)->rq) == NULL) + return ide_stopped; + + hwif = HWIF(drive); + /* retry only "normal" I/O: */ + if (rq->flags & (REQ_DRIVE_CMD | REQ_DRIVE_TASK)) { + rq->errors = 1; + ide_end_drive_cmd(drive, BUSY_STAT, 0); + return ide_stopped; + } + if (rq->flags & REQ_DRIVE_TASKFILE) { + rq->errors = 1; + ide_end_drive_cmd(drive, BUSY_STAT, 0); +// ide_end_taskfile(drive, BUSY_STAT, 0); + return ide_stopped; + } + + rq->errors |= ERROR_RESET; + DRIVER(drive)->end_request(drive, 0, 0); + return ide_stopped; +} + +EXPORT_SYMBOL(ide_abort); + +/** * ide_cmd - issue a simple drive command * @drive: drive the command is for * @cmd: command byte @@ -399,7 +439,7 @@ udelay(100); } - if (!OK_STAT(stat, READY_STAT, BAD_STAT)) + if (!OK_STAT(stat, READY_STAT, BAD_STAT) && DRIVER(drive) != NULL) return DRIVER(drive)->error(drive, "drive_cmd", stat); /* calls ide_end_drive_cmd */ ide_end_drive_cmd(drive, stat, hwif->INB(IDE_ERROR_REG)); @@ -428,13 +468,10 @@ s->b.set_tune = 0; if (HWIF(drive)->tuneproc != NULL) HWIF(drive)->tuneproc(drive, drive->tune_req); - } else if (drive->driver != NULL) { - return DRIVER(drive)->special(drive); - } else if (s->all) { - printk(KERN_ERR "%s: bad special flag: 0x%02x\n", drive->name, s->all); - s->all = 0; + return ide_stopped; } - return ide_stopped; + else + return DRIVER(drive)->special(drive); } EXPORT_SYMBOL(do_special); @@ -589,42 +626,17 @@ return execute_drive_cmd(drive, rq); else if (rq->flags & REQ_DRIVE_TASKFILE) return execute_drive_cmd(drive, rq); - - if (drive->driver != NULL) { - return (DRIVER(drive)->do_request(drive, rq, block)); - } - printk(KERN_ERR "%s: media type %d not supported\n", drive->name, drive->media); - goto kill_rq; + return (DRIVER(drive)->do_request(drive, rq, block)); } return do_special(drive); kill_rq: - if (drive->driver != NULL) - DRIVER(drive)->end_request(drive, 0, 0); - else - ide_end_request(drive, 0, 0); + DRIVER(drive)->end_request(drive, 0, 0); return ide_stopped; } EXPORT_SYMBOL(start_request); /** - * restart_request - reissue an IDE request - * @drive: drive for request - * @rq: request to reissue - * - * Reissue a request. See start_request for details and for - * FIXME - */ - -int restart_request (ide_drive_t *drive, struct request *rq) -{ - (void) start_request(drive, rq); - return 0; -} - -EXPORT_SYMBOL(restart_request); - -/** * ide_stall_queue - pause an IDE device * @drive: drive to stall * @timeout: time to stall for (jiffies) @@ -742,8 +754,8 @@ /* for atari only: POSSIBLY BROKEN HERE(?) */ ide_get_lock(ide_intr, hwgroup); - /* necessary paranoia: ensure IRQs are masked on local CPU */ - local_irq_disable(); + /* caller must own ide_lock */ + BUG_ON(!irqs_disabled()); while (!hwgroup->busy) { hwgroup->busy = 1; diff -Nru a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c --- a/drivers/ide/ide-iops.c Sun Mar 23 00:22:52 2003 +++ b/drivers/ide/ide-iops.c Sun Mar 23 00:22:52 2003 @@ -1,13 +1,12 @@ /* - * linux/drivers/ide/ide-iops.c Version 0.33 April 11, 2002 + * linux/drivers/ide/ide-iops.c Version 0.37 Mar 05, 2003 * * Copyright (C) 2000-2002 Andre Hedrick - * + * Copyright (C) 2003 Red Hat * */ #include -#define __NO_VERSION__ #include #include #include @@ -63,6 +62,10 @@ { } +static void ide_unplugged_outbsync (ide_drive_t *drive, u8 addr, unsigned long port) +{ +} + static void ide_unplugged_outw (u16 val, unsigned long port) { } @@ -82,7 +85,7 @@ void unplugged_hwif_iops (ide_hwif_t *hwif) { hwif->OUTB = ide_unplugged_outb; - hwif->OUTBSYNC = ide_unplugged_outb; + hwif->OUTBSYNC = ide_unplugged_outbsync; hwif->OUTW = ide_unplugged_outw; hwif->OUTL = ide_unplugged_outl; hwif->OUTSW = ide_unplugged_outsw; @@ -130,6 +133,11 @@ outb(val, port); } +static void ide_outbsync (ide_drive_t *drive, u8 addr, unsigned long port) +{ + outb(addr, port); +} + static void ide_outw (u16 val, unsigned long port) { outw(val, port); @@ -153,7 +161,7 @@ void default_hwif_iops (ide_hwif_t *hwif) { hwif->OUTB = ide_outb; - hwif->OUTBSYNC = ide_outb; + hwif->OUTBSYNC = ide_outbsync; hwif->OUTW = ide_outw; hwif->OUTL = ide_outl; hwif->OUTSW = ide_outsw; @@ -201,6 +209,11 @@ writeb(value, port); } +static void ide_mm_outbsync (ide_drive_t *drive, u8 value, unsigned long port) +{ + writeb(value, port); +} + static void ide_mm_outw (u16 value, unsigned long port) { writew(value, port); @@ -226,7 +239,7 @@ hwif->OUTB = ide_mm_outb; /* Most systems will need to override OUTBSYNC, alas however this one is controller specific! */ - hwif->OUTBSYNC = ide_mm_outb; + hwif->OUTBSYNC = ide_mm_outbsync; hwif->OUTW = ide_mm_outw; hwif->OUTL = ide_mm_outl; hwif->OUTSW = ide_mm_outsw; @@ -673,7 +686,7 @@ int hssbd = 0; int i; /* - * Determime highest Supported SPEC + * Determine highest Supported SPEC */ for (i=1; i<=15; i++) if (drive->id->major_rev_num & (1<handler != NULL) { printk(KERN_CRIT "%s: ide_set_handler: handler not null; " "old=%p, new=%p\n", @@ -1002,11 +1013,21 @@ hwgroup->expiry = expiry; hwgroup->timer.expires = jiffies + timeout; add_timer(&hwgroup->timer); +} + +EXPORT_SYMBOL(__ide_set_handler); + +void ide_set_handler (ide_drive_t *drive, ide_handler_t *handler, + unsigned int timeout, ide_expiry_t *expiry) +{ + unsigned long flags; + spin_lock_irqsave(&ide_lock, flags); + __ide_set_handler(drive, handler, timeout, expiry); spin_unlock_irqrestore(&ide_lock, flags); } EXPORT_SYMBOL(ide_set_handler); - + /** * ide_execute_command - execute an IDE command * @drive: IDE drive to issue the command against @@ -1035,7 +1056,7 @@ hwgroup->expiry = expiry; hwgroup->timer.expires = jiffies + timeout; add_timer(&hwgroup->timer); - hwif->OUTBSYNC(cmd, IDE_COMMAND_REG); + hwif->OUTBSYNC(drive, cmd, IDE_COMMAND_REG); /* Drive takes 400nS to respond, we must avoid the IRQ being serviced before that. @@ -1050,7 +1071,7 @@ /* needed below */ -ide_startstop_t do_reset1 (ide_drive_t *, int); +static ide_startstop_t do_reset1 (ide_drive_t *, int); /* * atapi_reset_pollfunc() gets invoked to poll the interface for completion every 50ms @@ -1167,8 +1188,7 @@ void pre_reset (ide_drive_t *drive) { - if (drive->driver != NULL) - DRIVER(drive)->pre_reset(drive); + DRIVER(drive)->pre_reset(drive); if (!drive->keep_settings) { if (drive->using_dma) { @@ -1202,14 +1222,20 @@ * (up to 30 seconds worstcase). So, instead of busy-waiting here for it, * we set a timer to poll at 50ms intervals. */ -ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi) +static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi) { unsigned int unit; unsigned long flags; - ide_hwif_t *hwif = HWIF(drive); - ide_hwgroup_t *hwgroup = HWGROUP(drive); + ide_hwif_t *hwif; + ide_hwgroup_t *hwgroup; + + spin_lock_irqsave(&ide_lock, flags); + hwif = HWIF(drive); + hwgroup = HWGROUP(drive); - local_irq_save(flags); + /* We must not reset with running handlers */ + if(hwgroup->handler != NULL) + BUG(); /* For an ATAPI device, first try an ATAPI SRST. */ if (drive->media != ide_disk && !do_not_try_atapi) { @@ -1218,10 +1244,8 @@ udelay (20); hwif->OUTB(WIN_SRST, IDE_COMMAND_REG); hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE; - if (HWGROUP(drive)->handler != NULL) - BUG(); - ide_set_handler(drive, &atapi_reset_pollfunc, HZ/20, NULL); - local_irq_restore(flags); + __ide_set_handler(drive, &atapi_reset_pollfunc, HZ/20, NULL); + spin_unlock_irqrestore(&ide_lock, flags); return ide_started; } @@ -1234,20 +1258,10 @@ #if OK_TO_RESET_CONTROLLER if (!IDE_CONTROL_REG) { - local_irq_restore(flags); + spin_unlock_irqrestore(&ide_lock, flags); return ide_stopped; } -# if 0 - { - u8 control = hwif->INB(IDE_CONTROL_REG); - control |= 0x04; - hwif->OUTB(control,IDE_CONTROL_REG); - udelay(30); - control &= 0xFB; - hwif->OUTB(control, IDE_CONTROL_REG); - } -# else /* * Note that we also set nIEN while resetting the device, * to mask unwanted interrupts from the interface during the reset. @@ -1257,23 +1271,21 @@ * recover from reset very quickly, saving us the first 50ms wait time. */ /* set SRST and nIEN */ - hwif->OUTB(drive->ctl|6,IDE_CONTROL_REG); + hwif->OUTBSYNC(drive, drive->ctl|6,IDE_CONTROL_REG); /* more than enough time */ udelay(10); if (drive->quirk_list == 2) { /* clear SRST and nIEN */ - hwif->OUTB(drive->ctl, IDE_CONTROL_REG); + hwif->OUTBSYNC(drive, drive->ctl, IDE_CONTROL_REG); } else { /* clear SRST, leave nIEN */ - hwif->OUTB(drive->ctl|2, IDE_CONTROL_REG); + hwif->OUTBSYNC(drive, drive->ctl|2, IDE_CONTROL_REG); } /* more than enough time */ udelay(10); hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE; - if (HWGROUP(drive)->handler != NULL) - BUG(); - ide_set_handler(drive, &reset_pollfunc, HZ/20, NULL); -# endif + __ide_set_handler(drive, &reset_pollfunc, HZ/20, NULL); + /* * Some weird controller like resetting themselves to a strange * state when the disks are reset this way. At least, the Winbond @@ -1281,71 +1293,22 @@ */ if (hwif->resetproc != NULL) { hwif->resetproc(drive); - -# if 0 - if (drive->failures) { - local_irq_restore(flags); - return ide_stopped; - } -# endif } - + #endif /* OK_TO_RESET_CONTROLLER */ - local_irq_restore(flags); + spin_unlock_irqrestore(&ide_lock, flags); return ide_started; } -#if 0 /* * ide_do_reset() is the entry point to the drive/interface reset code. */ + ide_startstop_t ide_do_reset (ide_drive_t *drive) { return do_reset1(drive, 0); } -#else -/* - * ide_do_reset() is the entry point to the drive/interface reset code. - */ -ide_startstop_t ide_do_reset (ide_drive_t *drive) -{ - ide_startstop_t start_stop = ide_started; -# if 0 - u8 tmp_dma = drive->using_dma; - u8 cspeed = drive->current_speed; - u8 unmask = drive->unmask; -# endif - - if (HWGROUP(drive)->handler != NULL) { - unsigned long flags; - spin_lock_irqsave(&ide_lock, flags); - HWGROUP(drive)->handler = NULL; - del_timer(&HWGROUP(drive)->timer); - spin_unlock_irqrestore(&ide_lock, flags); - } - - start_stop = do_reset1(drive, 0); -# if 0 - /* - * check for suspend-spindown flag, - * to attempt a restart or spinup of device. - */ - if (drive->suspend_reset) { - /* - * APM WAKE UP todo !! - * int nogoodpower = 1; - * while(nogoodpower) { - * check_power1() or check_power2() - * nogoodpower = 0; - * } - * HWIF(drive)->multiproc(drive); - */ -# endif - - return start_stop; -} -#endif EXPORT_SYMBOL(ide_do_reset); diff -Nru a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c --- a/drivers/ide/ide-lib.c Sun Mar 23 00:22:56 2003 +++ b/drivers/ide/ide-lib.c Sun Mar 23 00:22:56 2003 @@ -1,5 +1,4 @@ #include -#define __NO_VERSION__ #include #include #include diff -Nru a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c --- a/drivers/ide/ide-probe.c Sun Mar 23 00:22:53 2003 +++ b/drivers/ide/ide-probe.c Sun Mar 23 00:22:53 2003 @@ -1,5 +1,5 @@ /* - * linux/drivers/ide/ide-probe.c Version 1.10 Feb 11, 2003 + * linux/drivers/ide/ide-probe.c Version 1.11 Mar 05, 2003 * * Copyright (C) 1994-1998 Linus Torvalds & authors (see below) */ @@ -65,23 +65,14 @@ * and make drive properties unconditional outside of this file */ -static int generic_id(ide_drive_t *drive) +static void generic_id(ide_drive_t *drive) { - drive->id = kmalloc(SECTOR_WORDS *4, GFP_KERNEL); - if(drive->id == NULL) - { - printk(KERN_ERR "ide: out of memory for id data.\n"); - return -ENOMEM; - } - memset(drive->id, 0, SECTOR_WORDS * 4); drive->id->cyls = drive->cyl; drive->id->heads = drive->head; drive->id->sectors = drive->sect; drive->id->cur_cyls = drive->cyl; drive->id->cur_heads = drive->head; drive->id->cur_sectors = drive->sect; - strcpy(drive->id->model, "UNKNOWN"); - return 0; } /** @@ -107,7 +98,7 @@ { struct hd_driveid *id = drive->id; - if (drive->removable && id != NULL) { + if (drive->removable) { if (id->config == 0x848a) return 1; /* CompactFlash */ if (!strncmp(id->model, "KODAK ATA_FLASH", 15) /* Kodak */ || !strncmp(id->model, "Hitachi CV", 10) /* Hitachi */ @@ -138,16 +129,11 @@ int bswap = 1; struct hd_driveid *id; - /* called with interrupts disabled! */ - id = drive->id = kmalloc(SECTOR_WORDS*4, GFP_ATOMIC); - if (!id) { - printk(KERN_WARNING "(ide-probe::do_identify) " - "Out of memory.\n"); - goto err_kmalloc; - } + id = drive->id; /* read 512 bytes of id info */ hwif->ata_input_data(drive, id, SECTOR_WORDS); + drive->id_read = 1; local_irq_enable(); ide_fix_driveid(id); @@ -290,7 +276,6 @@ err_misc: kfree(id); -err_kmalloc: drive->present = 0; return; } @@ -298,7 +283,7 @@ /** * actual_try_to_identify - send ata/atapi identify * @drive: drive to identify - * @cmd: comamnd to use + * @cmd: command to use * * try_to_identify() sends an ATA(PI) IDENTIFY request to a drive * and waits for a response. It also monitors irqs while this is @@ -386,7 +371,7 @@ /** * try_to_identify - try to identify a drive * @drive: drive to probe - * @cmd: comamnd to use + * @cmd: command to use * * Issue the identify command and then do IRQ probing to * complete the identification when needed by finding the @@ -592,6 +577,25 @@ static inline u8 probe_for_drive (ide_drive_t *drive) { + /* + * In order to keep things simple we have an id + * block for all drives at all times. If the device + * is pre ATA or refuses ATA/ATAPI identify we + * will add faked data to this. + * + * Also note that 0 everywhere means "can't do X" + */ + + drive->id = kmalloc(SECTOR_WORDS *4, GFP_KERNEL); + drive->id_read = 0; + if(drive->id == NULL) + { + printk(KERN_ERR "ide: out of memory for id data.\n"); + return 0; + } + memset(drive->id, 0, SECTOR_WORDS * 4); + strcpy(drive->id->model, "UNKNOWN"); + /* skip probing? */ if (!drive->noprobe) { @@ -600,14 +604,14 @@ /* look for ATAPI device */ (void) do_probe(drive, WIN_PIDENTIFY); } - if (drive->id && strstr(drive->id->model, "E X A B Y T E N E S T")) + if (strstr(drive->id->model, "E X A B Y T E N E S T")) enable_nest(drive); if (!drive->present) /* drive not found */ return 0; /* identification failed? */ - if (drive->id == NULL) { + if (!drive->id_read) { if (drive->media == ide_disk) { printk(KERN_INFO "%s: non-IDE drive, CHS=%d/%d/%d\n", drive->name, drive->cyl, @@ -616,6 +620,7 @@ printk(KERN_INFO "%s: ATAPI cdrom (?)\n", drive->name); } else { /* nuke it */ + printk(KERN_WARNING "%s: Unknown device on bus refused identification. Ignoring.\n", drive->name); drive->present = 0; } } @@ -623,9 +628,9 @@ } if(!drive->present) return 0; - if(drive->id == NULL) - if(generic_id(drive) < 0) - drive->present = 0; + /* The drive wasn't being helpful. Add generic info only */ + if(!drive->id_read) + generic_id(drive); return drive->present; } @@ -945,6 +950,9 @@ u16 unit = 0; for (unit = 0; unit < MAX_DRIVES; ++unit) { ide_drive_t *drive = &hwif->drives[unit]; + /* For now don't attach absent drives, we may + want them on default or a new "empty" class + for hotplug reprobing ? */ if (drive->present) { ata_attach(drive); } @@ -990,18 +998,23 @@ static void ide_init_queue(ide_drive_t *drive) { request_queue_t *q = &drive->queue; - int max_sectors; + int max_sectors = 256; + /* + * Our default set up assumes the normal IDE case, + * that is 64K segmenting, standard PRD setup + * and LBA28. Some drivers then impose their own + * limits and LBA48 we could raise it but as yet + * do not. + */ + q->queuedata = HWGROUP(drive); blk_init_queue(q, do_ide_request, &ide_lock); drive->queue_setup = 1; blk_queue_segment_boundary(q, 0xffff); -#ifdef CONFIG_BLK_DEV_PDC4030 - max_sectors = 127; -#else - max_sectors = 255; -#endif + if (HWIF(drive)->rqsize) + max_sectors = HWIF(drive)->rqsize; blk_queue_max_sectors(q, max_sectors); /* IDE DMA can do PRD_ENTRIES number of segments. */ @@ -1009,7 +1022,13 @@ /* This is a driver limit and could be eliminated. */ blk_queue_max_phys_segments(q, PRD_ENTRIES); +} +/* + * Setup the drive for request handling. + */ +static void ide_init_drive(ide_drive_t *drive) +{ ide_toggle_bounce(drive, 1); #ifdef CONFIG_BLK_DEV_IDE_TCQ_DEFAULT @@ -1032,16 +1051,14 @@ */ static int init_irq (ide_hwif_t *hwif) { - unsigned long flags; unsigned int index; - ide_hwgroup_t *hwgroup, *new_hwgroup; + ide_hwgroup_t *hwgroup; ide_hwif_t *match = NULL; - /* Allocate the buffer and potentially sleep first */ - new_hwgroup = kmalloc(sizeof(ide_hwgroup_t),GFP_KERNEL); - - spin_lock_irqsave(&ide_lock, flags); + BUG_ON(in_interrupt()); + BUG_ON(irqs_disabled()); + down(&ide_cfg_sem); hwif->hwgroup = NULL; #if MAX_HWIFS > 1 /* @@ -1073,14 +1090,28 @@ */ if (match) { hwgroup = match->hwgroup; - if(new_hwgroup) - kfree(new_hwgroup); + hwif->hwgroup = hwgroup; + /* + * Link us into the hwgroup. + * This must be done early, do ensure that unexpected_intr + * can find the hwif and prevent irq storms. + * No drives are attached to the new hwif, choose_drive + * can't do anything stupid (yet). + * Add ourself as the 2nd entry to the hwgroup->hwif + * linked list, the first entry is the hwif that owns + * hwgroup->handler - do not change that. + */ + spin_lock_irq(&ide_lock); + hwif->next = hwgroup->hwif->next; + hwgroup->hwif->next = hwif; + spin_unlock_irq(&ide_lock); } else { - hwgroup = new_hwgroup; - if (!hwgroup) { - spin_unlock_irqrestore(&ide_lock, flags); - return 1; - } + hwgroup = kmalloc(sizeof(ide_hwgroup_t),GFP_KERNEL); + if (!hwgroup) + goto out_up; + + hwif->hwgroup = hwgroup; + memset(hwgroup, 0, sizeof(ide_hwgroup_t)); hwgroup->hwif = hwif->next = hwif; hwgroup->rq = NULL; @@ -1112,44 +1143,35 @@ /* clear nIEN */ hwif->OUTB(0x08, hwif->io_ports[IDE_CONTROL_OFFSET]); - if (request_irq(hwif->irq,&ide_intr,sa,hwif->name,hwgroup)) { - if (!match) - kfree(hwgroup); - spin_unlock_irqrestore(&ide_lock, flags); - return 1; - } + if (request_irq(hwif->irq,&ide_intr,sa,hwif->name,hwgroup)) + goto out_unlink; } /* - * Everything is okay, so link us into the hwgroup + * Link any new drives into the hwgroup, allocate + * the block device queue and initialize the drive. + * Note that ide_init_drive sends commands to the new + * drive. */ - hwif->hwgroup = hwgroup; - hwif->next = hwgroup->hwif->next; - hwgroup->hwif->next = hwif; - for (index = 0; index < MAX_DRIVES; ++index) { ide_drive_t *drive = &hwif->drives[index]; if (!drive->present) continue; - if (!hwgroup->drive) - hwgroup->drive = drive; - drive->next = hwgroup->drive->next; - hwgroup->drive->next = drive; - spin_unlock_irqrestore(&ide_lock, flags); ide_init_queue(drive); - spin_lock_irqsave(&ide_lock, flags); - } - - if (!hwgroup->hwif) { - hwgroup->hwif = HWIF(hwgroup->drive); -#ifdef DEBUG - printk("%s : Adding missed hwif to hwgroup!!\n", hwif->name); -#endif + spin_lock_irq(&ide_lock); + if (!hwgroup->drive) { + /* first drive for hwgroup. */ + drive->next = drive; + hwgroup->drive = drive; + hwgroup->hwif = HWIF(hwgroup->drive); + } else { + drive->next = hwgroup->drive->next; + hwgroup->drive->next = drive; + } + spin_unlock_irq(&ide_lock); + ide_init_drive(drive); } - /* all CPUs; safe now that hwif->hwgroup is set up */ - spin_unlock_irqrestore(&ide_lock, flags); - #if !defined(__mc68000__) && !defined(CONFIG_APUS) && !defined(__sparc__) printk("%s at 0x%03lx-0x%03lx,0x%03lx on irq %d", hwif->name, hwif->io_ports[IDE_DATA_OFFSET], @@ -1168,6 +1190,30 @@ printk(" (%sed with %s)", hwif->sharing_irq ? "shar" : "serializ", match->name); printk("\n"); + up(&ide_cfg_sem); + return 0; +out_unlink: + spin_lock_irq(&ide_lock); + if (hwif->next == hwif) { + BUG_ON(match); + BUG_ON(hwgroup->hwif != hwif); + kfree(hwgroup); + } else { + ide_hwif_t *g; + g = hwgroup->hwif; + while (g->next != hwif) + g = g->next; + g->next = hwif->next; + if (hwgroup->hwif == hwif) { + /* Impossible. */ + printk(KERN_ERR "Duh. Uninitialized hwif listed as active hwif.\n"); + hwgroup->hwif = g; + } + BUG_ON(hwgroup->hwif == hwif); + } + spin_unlock_irq(&ide_lock); +out_up: + up(&ide_cfg_sem); return 0; } @@ -1340,6 +1386,7 @@ void export_ide_init_queue (ide_drive_t *drive) { ide_init_queue(drive); + ide_init_drive(drive); } EXPORT_SYMBOL(export_ide_init_queue); @@ -1384,7 +1431,8 @@ if (!hwif->present) continue; for (unit = 0; unit < MAX_DRIVES; ++unit) - ata_attach(&hwif->drives[unit]); + if (hwif->drives[unit].present) + ata_attach(&hwif->drives[unit]); } } if (!ide_probe) diff -Nru a/drivers/ide/ide-proc.c b/drivers/ide/ide-proc.c --- a/drivers/ide/ide-proc.c Sun Mar 23 00:22:53 2003 +++ b/drivers/ide/ide-proc.c Sun Mar 23 00:22:53 2003 @@ -1,7 +1,8 @@ /* - * linux/drivers/ide/ide-proc.c Version 1.03 January 2, 1998 + * linux/drivers/ide/ide-proc.c Version 1.05 Mar 05, 2003 * * Copyright (C) 1997-1998 Mark Lord + * Copyright (C) 2003 Red Hat */ /* @@ -57,7 +58,6 @@ */ #include -#define __NO_VERSION__ #include #include @@ -365,6 +365,7 @@ case ide_cy82c693: name = "cy82c693"; break; case ide_4drives: name = "4drives"; break; case ide_pmac: name = "mac-io"; break; + case ide_pc9800: name = "pc9800"; break; default: name = "(unknown)"; break; } len = sprintf(page, "%s\n", name); @@ -568,14 +569,10 @@ (char *page, char **start, off_t off, int count, int *eof, void *data) { ide_drive_t *drive = (ide_drive_t *) data; - ide_driver_t *driver = (ide_driver_t *) drive->driver; int len; - if (!driver) - len = sprintf(page, "(none)\n"); - else - len = sprintf(page,"%llu\n", - (long long) ((ide_driver_t *)drive->driver)->capacity(drive)); + len = sprintf(page,"%llu\n", + (long long) (DRIVER(drive)->capacity(drive))); PROC_IDE_READ_RETURN(page,start,off,count,eof,len); } @@ -620,10 +617,7 @@ ide_driver_t *driver = drive->driver; int len; - if (!driver) - len = sprintf(page, "(none)\n"); - else - len = sprintf(page, "%s version %s\n", + len = sprintf(page, "%s version %s\n", driver->name, driver->version); PROC_IDE_READ_RETURN(page,start,off,count,eof,len); } @@ -775,8 +769,7 @@ ide_driver_t *driver = drive->driver; if (drive->proc) { - if (driver) - ide_remove_proc_entries(drive->proc, driver->proc); + ide_remove_proc_entries(drive->proc, driver->proc); ide_remove_proc_entries(drive->proc, generic_drive_entries); remove_proc_entry(drive->name, proc_ide_root); remove_proc_entry(drive->name, hwif->proc); diff -Nru a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c --- a/drivers/ide/ide-tape.c Sun Mar 23 00:22:52 2003 +++ b/drivers/ide/ide-tape.c Sun Mar 23 00:22:52 2003 @@ -280,7 +280,7 @@ * - Add idetape_onstream_mode_sense_tape_parameter_page * function to get tape capacity in frames: tape->capacity. * - Add support for DI-50 drives( or any DI- drive). - * - 'workaround' for read error/blank block arround block 3000. + * - 'workaround' for read error/blank block around block 3000. * - Implement Early warning for end of media for Onstream. * - Cosmetic code changes for readability. * - Idetape_position_tape should not use SKIP bit during @@ -422,7 +422,7 @@ * sharing a (fast) ATA-2 disk with any (slow) new ATAPI device. */ -#define IDETAPE_VERSION "1.17b" +#define IDETAPE_VERSION "1.17b-ac1" #include #include @@ -514,7 +514,7 @@ * AUX */ typedef struct os_aux_s { - __u32 format_id; /* hardware compability AUX is based on */ + __u32 format_id; /* hardware compatibility AUX is based on */ char application_sig[4]; /* driver used to write this media */ __u32 hdwr; /* reserved */ __u32 update_frame_cntr; /* for configuration frame */ @@ -1005,7 +1005,7 @@ struct completion *waiting; int onstream_write_error; /* write error recovery active */ int header_ok; /* header frame verified ok */ - int linux_media; /* reading linux-specifc media */ + int linux_media; /* reading linux-specific media */ int linux_media_version; char application_sig[5]; /* application signature */ int filemark_cnt; @@ -2128,8 +2128,6 @@ if (temp > pc->buffer_size) { printk(KERN_ERR "ide-tape: The tape wants to send us more data than expected - discarding data\n"); idetape_discard_data(drive, bcount.all); - if (HWGROUP(drive)->handler != NULL) /* paranoia check */ - BUG(); ide_set_handler(drive, &idetape_pc_intr, IDETAPE_WAIT_CMD, NULL); return ide_started; } @@ -2156,8 +2154,6 @@ if (tape->debug_level >= 2) printk(KERN_INFO "ide-tape: [cmd %x] transferred %d bytes on that interrupt\n", pc->c[0], bcount.all); #endif - if (HWGROUP(drive)->handler != NULL) /* paranoia check */ - BUG(); ide_set_handler(drive, &idetape_pc_intr, IDETAPE_WAIT_CMD, NULL); /* And set the interrupt handler again */ return ide_started; } @@ -2235,8 +2231,6 @@ return ide_do_reset(drive); } tape->cmd_start_time = jiffies; - if (HWGROUP(drive)->handler != NULL) /* paranoia check */ - BUG(); /* Set the interrupt routine */ ide_set_handler(drive, &idetape_pc_intr, IDETAPE_WAIT_CMD, NULL); #ifdef CONFIG_BLK_DEV_IDEDMA @@ -2325,8 +2319,6 @@ if (dma_ok) /* Will begin DMA later */ set_bit(PC_DMA_IN_PROGRESS, &pc->flags); if (test_bit(IDETAPE_DRQ_INTERRUPT, &tape->flags)) { - if (HWGROUP(drive)->handler != NULL) /* paranoia check */ - BUG(); ide_set_handler(drive, &idetape_transfer_pc, IDETAPE_WAIT_CMD, NULL); OUT_BYTE(WIN_PACKETCMD, IDE_COMMAND_REG); return ide_started; @@ -5605,15 +5597,16 @@ * * 0 If this tape driver is not currently supported by us. */ -static int idetape_identify_device (ide_drive_t *drive,struct hd_driveid *id) +static int idetape_identify_device (ide_drive_t *drive) { struct idetape_id_gcw gcw; + struct hd_driveid *id = drive->id; #if IDETAPE_DEBUG_INFO unsigned short mask,i; #endif /* IDETAPE_DEBUG_INFO */ - if (!id) - return 0; + if (drive->id_read == 0) + return 1; *((unsigned short *) &gcw) = id->config; @@ -6287,7 +6280,7 @@ goto failed; if (drive->media != ide_tape) goto failed; - if (!idetape_identify_device (drive, drive->id)) { + if (!idetape_identify_device (drive)) { printk(KERN_ERR "ide-tape: %s: not supported by this version of ide-tape\n", drive->name); goto failed; } diff -Nru a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c --- a/drivers/ide/ide-taskfile.c Sun Mar 23 00:22:49 2003 +++ b/drivers/ide/ide-taskfile.c Sun Mar 23 00:22:49 2003 @@ -1,5 +1,5 @@ /* - * linux/drivers/ide/ide-taskfile.c Version 0.33 April 11, 2002 + * linux/drivers/ide/ide-taskfile.c Version 0.38 March 05, 2003 * * Copyright (C) 2000-2002 Michael Cornwell * Copyright (C) 2000-2002 Andre Hedrick @@ -27,7 +27,6 @@ */ #include -#define __NO_VERSION__ #include #include #include @@ -642,7 +641,7 @@ * NOTE: could rewind beyond beginning :-/ */ } else { - printk("%s: MULTI-READ assume all data " \ + printk(KERN_ERR "%s: MULTI-READ assume all data " \ "transfered is bad status=0x%02x\n", drive->name, stat); } @@ -810,11 +809,6 @@ rq->errors = 0; return ide_started; #else /* ! ALTERNATE_STATE_DIAGRAM_MULTI_OUT */ - -#if 0 - if (wait_for_ready(drive, 100)) - IDE_DEBUG(__LINE__); //BUG(); -#else if (!(drive_is_ready(drive))) { int i; for (i=0; i<100; i++) { @@ -822,7 +816,7 @@ break; } } -#endif + /* * WARNING :: if the drive as not acked good status we may not * move the DATA-TRANSFER T-Bar as BSY != 0. @@ -864,7 +858,7 @@ * NOTE: could rewind beyond beginning :-/ */ } else { - printk("%s: MULTI-WRITE assume all data " \ + printk(KERN_ERR "%s: MULTI-WRITE assume all data " \ "transfered is bad status=0x%02x\n", drive->name, stat); } @@ -1497,7 +1491,7 @@ case TASKFILE_MULTI_OUT: if (!drive->mult_count) { /* (hs): give up if multcount is not set */ - printk("%s: %s Multimode Write " \ + printk(KERN_ERR "%s: %s Multimode Write " \ "multcount is not set\n", drive->name, __FUNCTION__); err = -EPERM; @@ -1525,7 +1519,7 @@ case TASKFILE_MULTI_IN: if (!drive->mult_count) { /* (hs): give up if multcount is not set */ - printk("%s: %s Multimode Read failure " \ + printk(KERN_ERR "%s: %s Multimode Read failure " \ "multcount is not set\n", drive->name, __FUNCTION__); err = -EPERM; diff -Nru a/drivers/ide/ide.c b/drivers/ide/ide.c --- a/drivers/ide/ide.c Sun Mar 23 00:22:51 2003 +++ b/drivers/ide/ide.c Sun Mar 23 00:22:51 2003 @@ -1,5 +1,5 @@ /* - * linux/drivers/ide/ide.c Version 7.00alpha1 August 19 2002 + * linux/drivers/ide/ide.c Version 7.00beta2 Mar 05 2003 * * Copyright (C) 1994-1998 Linus Torvalds & authors (see below) */ @@ -177,6 +177,7 @@ static int system_bus_speed; /* holds what we think is VESA/PCI bus speed */ static int initializing; /* set while initializing built-in drivers */ +DECLARE_MUTEX(ide_cfg_sem); spinlock_t ide_lock __cacheline_aligned_in_smp = SPIN_LOCK_UNLOCKED; static int ide_scan_direction; /* THIS was formerly 2.2.x pci=reverse */ @@ -214,6 +215,8 @@ EXPORT_SYMBOL(idetape); EXPORT_SYMBOL(idescsi); +extern ide_driver_t idedefault_driver; +static void setup_driver_defaults (ide_drive_t *drive); /* * Do not even *think* about calling this! @@ -271,6 +274,8 @@ drive->max_failures = IDE_DEFAULT_MAX_FAILURES; drive->using_dma = 0; drive->is_flash = 0; + drive->driver = &idedefault_driver; + setup_driver_defaults(drive); drive->vdma = 0; INIT_LIST_HEAD(&drive->list); } @@ -349,9 +354,7 @@ { if (!drive->present) return 0; - if (drive->driver != NULL) - return DRIVER(drive)->capacity(drive); - return 0; + return DRIVER(drive)->capacity(drive); } EXPORT_SYMBOL(current_capacity); @@ -580,17 +583,19 @@ void ide_unregister (unsigned int index) { - ide_drive_t *drive, *d; + ide_drive_t *drive; ide_hwif_t *hwif, *g; ide_hwgroup_t *hwgroup; int irq_count = 0, unit, i; - unsigned long flags; ide_hwif_t old_hwif; if (index >= MAX_HWIFS) BUG(); - spin_lock_irqsave(&ide_lock, flags); + BUG_ON(in_interrupt()); + BUG_ON(irqs_disabled()); + down(&ide_cfg_sem); + spin_lock_irq(&ide_lock); hwif = &ide_hwifs[index]; if (!hwif->present) goto abort; @@ -600,25 +605,23 @@ continue; if (drive->usage) goto abort; - if (drive->driver != NULL && DRIVER(drive)->shutdown(drive)) + if (DRIVER(drive)->shutdown(drive)) goto abort; } hwif->present = 0; - spin_unlock_irqrestore(&ide_lock, flags); + spin_unlock_irq(&ide_lock); for (unit = 0; unit < MAX_DRIVES; ++unit) { drive = &hwif->drives[unit]; if (!drive->present) continue; - if (drive->driver != NULL) - DRIVER(drive)->cleanup(drive); + DRIVER(drive)->cleanup(drive); } #ifdef CONFIG_PROC_FS destroy_proc_ide_drives(hwif); #endif - spin_lock_irqsave(&ide_lock, flags); hwgroup = hwif->hwgroup; /* @@ -633,6 +636,7 @@ if (irq_count == 1) free_irq(hwif->irq, hwgroup); + spin_lock_irq(&ide_lock); /* * Note that we only release the standard ports, * and do not even try to handle any extra ports @@ -644,7 +648,6 @@ * Remove us from the hwgroup, and free * the hwgroup if we were the only member */ - d = hwgroup->drive; for (i = 0; i < MAX_DRIVES; ++i) { drive = &hwif->drives[i]; if (drive->de) { @@ -653,11 +656,23 @@ } if (!drive->present) continue; - while (hwgroup->drive->next != drive) - hwgroup->drive = hwgroup->drive->next; - hwgroup->drive->next = drive->next; - if (hwgroup->drive == drive) + if (drive == drive->next) { + /* special case: last drive from hwgroup. */ + BUG_ON(hwgroup->drive != drive); hwgroup->drive = NULL; + } else { + ide_drive_t *walk; + + walk = hwgroup->drive; + while (walk->next != drive) + walk = walk->next; + walk->next = drive->next; + if (hwgroup->drive == drive) { + hwgroup->drive = drive->next; + hwgroup->hwif = HWIF(hwgroup->drive); + } + } + BUG_ON(hwgroup->drive == drive); if (drive->id != NULL) { kfree(drive->id); drive->id = NULL; @@ -665,15 +680,28 @@ drive->present = 0; blk_cleanup_queue(&drive->queue); } - if (d->present) - hwgroup->drive = d; - while (hwgroup->hwif->next != hwif) - hwgroup->hwif = hwgroup->hwif->next; - hwgroup->hwif->next = hwif->next; - if (hwgroup->hwif == hwif) + if (hwif->next == hwif) { kfree(hwgroup); - else - hwgroup->hwif = HWIF(hwgroup->drive); + BUG_ON(hwgroup->hwif != hwif); + } else { + /* There is another interface in hwgroup. + * Unlink us, and set hwgroup->drive and ->hwif to + * something sane. + */ + g = hwgroup->hwif; + while (g->next != hwif) + g = g->next; + g->next = hwif->next; + if (hwgroup->hwif == hwif) { + /* Chose a random hwif for hwgroup->hwif. + * It's guaranteed that there are no drives + * left in the hwgroup. + */ + BUG_ON(hwgroup->drive != NULL); + hwgroup->hwif = g; + } + BUG_ON(hwgroup->hwif == hwif); + } #if !defined(CONFIG_DMA_NONPCI) if (hwif->dma_base) { @@ -813,7 +841,8 @@ hwif->hwif_data = old_hwif.hwif_data; abort: - spin_unlock_irqrestore(&ide_lock, flags); + spin_unlock_irq(&ide_lock); + up(&ide_cfg_sem); } EXPORT_SYMBOL(ide_unregister); @@ -875,7 +904,7 @@ EXPORT_SYMBOL(ide_setup_ports); /* - * Register an IDE interface, specifing exactly the registers etc + * Register an IDE interface, specifying exactly the registers etc * Set init=1 iff calling before probes have taken place. */ int ide_register_hw (hw_regs_t *hw, ide_hwif_t **hwifp) @@ -926,7 +955,7 @@ EXPORT_SYMBOL(ide_register_hw); /* - * Compatability function with existing drivers. If you want + * Compatibility function with existing drivers. If you want * something different, use the function above. */ int ide_register (int arg1, int arg2, int irq) @@ -998,7 +1027,7 @@ setting->set = set; setting->next = *p; - if (drive->driver) + if (drive->driver != &idedefault_driver) setting->auto_remove = 1; *p = setting; up(&ide_setting_sem); @@ -1255,13 +1284,14 @@ static int set_using_dma (ide_drive_t *drive, int arg) { - if (!drive->driver || !DRIVER(drive)->supports_dma) + if (!DRIVER(drive)->supports_dma) return -EPERM; if (!drive->id || !(drive->id->capability & 1)) return -EPERM; if (HWIF(drive)->ide_dma_check == NULL) return -EPERM; if (arg) { + if (HWIF(drive)->ide_dma_check(drive)) return -EIO; if (HWIF(drive)->ide_dma_on(drive)) return -EIO; } else { if (HWIF(drive)->ide_dma_off(drive)) return -EIO; @@ -1304,15 +1334,9 @@ return 0; } - if (drive->driver != NULL) { -#if 0 - ide_unregister_subdriver(drive); -#else - if (DRIVER(drive)->cleanup(drive)) { - drive->scsi = 0; - return 0; - } -#endif + if (DRIVER(drive)->cleanup(drive)) { + drive->scsi = 0; + return 0; } drive->scsi = (u8) arg; @@ -1353,7 +1377,7 @@ mdelay(50); #else __set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(HZ/20); + schedule_timeout(1+HZ/20); #endif /* CONFIG_BLK_DEV_IDECS */ } @@ -1375,7 +1399,7 @@ { if (!drive->present || drive->usage || drive->dead) goto abort; - if (drive->driver != NULL && DRIVER(drive)->cleanup(drive)) + if (DRIVER(drive)->cleanup(drive)) goto abort; strncpy(drive->driver_req, driver, 9); if (ata_attach(drive)) { @@ -1387,7 +1411,7 @@ } else { drive->driver_req[0] = 0; } - if (DRIVER(drive) && !strcmp(DRIVER(drive)->name, driver)) + if (DRIVER(drive)!= &idedefault_driver && !strcmp(DRIVER(drive)->name, driver)) return 0; abort: return 1; @@ -1412,10 +1436,12 @@ spin_lock(&drivers_lock); module_put(driver->owner); } + drive->gendev.driver = &idedefault_driver.gen_driver; spin_unlock(&drivers_lock); + if(idedefault_driver.attach(drive) != 0) + panic("ide: default attach failed"); spin_lock(&drives_lock); list_add_tail(&drive->list, &ata_unused); - drive->gendev.driver = NULL; spin_unlock(&drives_lock); return 1; } @@ -1476,7 +1502,7 @@ case HDIO_GET_IDENTITY: if (bdev != bdev->bd_contains) return -EINVAL; - if (drive->id == NULL) + if (drive->id_read == 0) return -ENOMSG; if (copy_to_user((char *)arg, (char *)drive->id, (cmd == HDIO_GET_IDENTITY) ? sizeof(*drive->id) : 142)) return -EFAULT; @@ -1521,7 +1547,7 @@ case HDIO_SCAN_HWIF: { int args[3]; - if (!capable(CAP_SYS_ADMIN)) return -EACCES; + if (!capable(CAP_SYS_RAWIO)) return -EACCES; if (copy_from_user(args, (void *)arg, 3 * sizeof(int))) return -EFAULT; if (ide_register(args[0], args[1], args[2]) == -1) @@ -1529,14 +1555,12 @@ return 0; } case HDIO_UNREGISTER_HWIF: - if (!capable(CAP_SYS_ADMIN)) return -EACCES; + if (!capable(CAP_SYS_RAWIO)) return -EACCES; /* (arg > MAX_HWIFS) checked in function */ ide_unregister(arg); return 0; case HDIO_SET_NICE: if (!capable(CAP_SYS_ADMIN)) return -EACCES; - if (drive->driver == NULL) - return -EPERM; if (arg != (arg & ((1 << IDE_NICE_DSC_OVERLAP) | (1 << IDE_NICE_1)))) return -EPERM; drive->dsc_overlap = (arg >> IDE_NICE_DSC_OVERLAP) & 1; @@ -1550,18 +1574,26 @@ { unsigned long flags; if (!capable(CAP_SYS_ADMIN)) return -EACCES; -#if 1 + + /* + * Abort the current command on the + * group if there is one, taking + * care not to allow anything else + * to be queued and to die on the + * spot if we miss one somehow + */ + spin_lock_irqsave(&ide_lock, flags); - if ( HWGROUP(drive)->handler != NULL) { - printk(KERN_ERR "%s: ide_set_handler: handler not null; %p\n", drive->name, HWGROUP(drive)->handler); - (void) HWGROUP(drive)->handler(drive); -// HWGROUP(drive)->handler = NULL; - HWGROUP(drive)->expiry = NULL; - del_timer(&HWGROUP(drive)->timer); - } + + DRIVER(drive)->abort(drive, "drive reset"); + if(HWGROUP(drive)->handler) + BUG(); + + /* Ensure nothing gets queued after we + drop the lock. Reset will clear the busy */ + + HWGROUP(drive)->busy = 1; spin_unlock_irqrestore(&ide_lock, flags); - -#endif (void) ide_do_reset(drive); if (drive->suspend_reset) { /* @@ -1593,9 +1625,8 @@ if (!capable(CAP_SYS_ADMIN)) return -EACCES; if (HWIF(drive)->busproc) - HWIF(drive)->busproc(drive, (int)arg); - return 0; - + return HWIF(drive)->busproc(drive, (int)arg); + return -EOPNOTSUPP; default: return -EINVAL; } @@ -2193,7 +2224,7 @@ static int default_shutdown(ide_drive_t *drive) { - if (drive->usage || drive->driver == NULL || DRIVER(drive)->busy) { + if (drive->usage || DRIVER(drive)->busy) { return 1; } drive->dead = 1; @@ -2261,6 +2292,11 @@ return 0; } +static ide_startstop_t default_abort (ide_drive_t *drive, const char *msg) +{ + return ide_abort(drive, msg); +} + static void setup_driver_defaults (ide_drive_t *drive) { ide_driver_t *d = drive->driver; @@ -2272,6 +2308,7 @@ if (d->end_request == NULL) d->end_request = default_end_request; if (d->sense == NULL) d->sense = default_sense; if (d->error == NULL) d->error = default_error; + if (d->abort == NULL) d->abort = default_abort; if (d->pre_reset == NULL) d->pre_reset = default_pre_reset; if (d->capacity == NULL) d->capacity = default_capacity; if (d->special == NULL) d->special = default_special; @@ -2282,9 +2319,11 @@ { unsigned long flags; + BUG_ON(drive->driver == NULL); + spin_lock_irqsave(&ide_lock, flags); if (version != IDE_SUBDRIVER_VERSION || !drive->present || - drive->driver != NULL || drive->usage || drive->dead) { + drive->driver != &idedefault_driver || drive->usage || drive->dead) { spin_unlock_irqrestore(&ide_lock, flags); return 1; } @@ -2294,6 +2333,7 @@ spin_lock(&drives_lock); list_add(&drive->list, &driver->drives); spin_unlock(&drives_lock); +// printk(KERN_INFO "%s: attached %s driver.\n", drive->name, driver->name); if ((drive->autotune == IDE_TUNE_DEFAULT) || (drive->autotune == IDE_TUNE_AUTO)) { /* DMA timings and setup moved to ide-probe.c */ @@ -2318,7 +2358,7 @@ unsigned long flags; spin_lock_irqsave(&ide_lock, flags); - if (drive->usage || drive->driver == NULL || DRIVER(drive)->busy) { + if (drive->usage || drive->driver == &idedefault_driver || DRIVER(drive)->busy) { spin_unlock_irqrestore(&ide_lock, flags); return 1; } @@ -2330,10 +2370,12 @@ ide_remove_proc_entries(drive->proc, generic_subdriver_entries); #endif auto_remove_settings(drive); - drive->driver = NULL; + drive->driver = &idedefault_driver; + setup_driver_defaults(drive); spin_unlock_irqrestore(&ide_lock, flags); spin_lock(&drives_lock); list_del_init(&drive->list); + list_add(&drive->list, &drive->driver->drives); spin_unlock(&drives_lock); return 0; } @@ -2343,10 +2385,7 @@ static int ide_drive_remove(struct device * dev) { ide_drive_t * drive = container_of(dev,ide_drive_t,gendev); - ide_driver_t * driver = drive->driver; - - if (driver && driver->cleanup) - driver->cleanup(drive); + DRIVER(drive)->cleanup(drive); return 0; } @@ -2366,7 +2405,8 @@ while (!list_empty(&list)) { ide_drive_t *drive = list_entry(list.next, ide_drive_t, list); list_del_init(&drive->list); - ata_attach(drive); + if (drive->present) + ata_attach(drive); } driver->gen_driver.name = (char *) driver->name; driver->gen_driver.bus = &ide_bus_type; diff -Nru a/drivers/ide/legacy/Makefile b/drivers/ide/legacy/Makefile --- a/drivers/ide/legacy/Makefile Sun Mar 23 00:22:51 2003 +++ b/drivers/ide/legacy/Makefile Sun Mar 23 00:22:51 2003 @@ -2,6 +2,7 @@ obj-$(CONFIG_BLK_DEV_ALI14XX) += ali14xx.o obj-$(CONFIG_BLK_DEV_DTC2278) += dtc2278.o obj-$(CONFIG_BLK_DEV_HT6560B) += ht6560b.o +obj-$(CONFIG_BLK_DEV_IDE_PC9800) += pc9800.o obj-$(CONFIG_BLK_DEV_PDC4030) += pdc4030.o obj-$(CONFIG_BLK_DEV_QD65XX) += qd65xx.o obj-$(CONFIG_BLK_DEV_UMC8672) += umc8672.o @@ -15,6 +16,10 @@ obj-$(CONFIG_BLK_DEV_IDECS) += ide-cs.o # Last of all +ifneq ($(CONFIG_X86_PC9800),y) obj-$(CONFIG_BLK_DEV_HD) += hd.o +else +obj-$(CONFIG_BLK_DEV_HD) += hd98.o +endif EXTRA_CFLAGS := -Idrivers/ide diff -Nru a/drivers/ide/legacy/ali14xx.c b/drivers/ide/legacy/ali14xx.c --- a/drivers/ide/legacy/ali14xx.c Sun Mar 23 00:22:51 2003 +++ b/drivers/ide/legacy/ali14xx.c Sun Mar 23 00:22:51 2003 @@ -229,10 +229,8 @@ return 1; } -#ifndef HWIF_PROBE_CLASSIC_METHOD probe_hwif_init(&ide_hwifs[0]); probe_hwif_init(&ide_hwifs[1]); -#endif /* HWIF_PROBE_CLASSIC_METHOD */ return 0; } diff -Nru a/drivers/ide/legacy/dtc2278.c b/drivers/ide/legacy/dtc2278.c --- a/drivers/ide/legacy/dtc2278.c Sun Mar 23 00:22:51 2003 +++ b/drivers/ide/legacy/dtc2278.c Sun Mar 23 00:22:51 2003 @@ -138,11 +138,8 @@ ide_hwifs[1].mate = &ide_hwifs[0]; ide_hwifs[1].channel = 1; -#ifndef HWIF_PROBE_CLASSIC_METHOD probe_hwif_init(&ide_hwifs[0]); probe_hwif_init(&ide_hwifs[1]); -#endif /* HWIF_PROBE_CLASSIC_METHOD */ - } void __init dtc2278_release (void) diff -Nru a/drivers/ide/legacy/hd98.c b/drivers/ide/legacy/hd98.c --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/drivers/ide/legacy/hd98.c Sun Mar 23 00:22:57 2003 @@ -0,0 +1,904 @@ +/* + * Copyright (C) 1991, 1992 Linus Torvalds + * + * This is the low-level hd interrupt support. It traverses the + * request-list, using interrupts to jump between functions. As + * all the functions are called within interrupts, we may not + * sleep. Special care is recommended. + * + * modified by Drew Eckhardt to check nr of hd's from the CMOS. + * + * Thanks to Branko Lankester, lankeste@fwi.uva.nl, who found a bug + * in the early extended-partition checks and added DM partitions + * + * IRQ-unmask, drive-id, multiple-mode, support for ">16 heads", + * and general streamlining by Mark Lord. + * + * Removed 99% of above. Use Mark's ide driver for those options. + * This is now a lightweight ST-506 driver. (Paul Gortmaker) + * + * Modified 1995 Russell King for ARM processor. + * + * Bugfix: max_sectors must be <= 255 or the wheels tend to come + * off in a hurry once you queue things up - Paul G. 02/2001 + */ + +/* Uncomment the following if you want verbose error reports. */ +/* #define VERBOSE_ERRORS */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /* CMOS defines */ +#include +#include +#include + +#define REALLY_SLOW_IO +#include +#include +#include + +#define MAJOR_NR HD_MAJOR +#define DEVICE_NR(device) (minor(device)>>6) +#include + +#include "io_ports.h" + +#ifdef __arm__ +#undef HD_IRQ +#endif +#include +#ifdef __arm__ +#define HD_IRQ IRQ_HARDDISK +#endif + +/* Hd controller regster ports */ + +#define HD_DATA 0x640 /* _CTL when writing */ +#define HD_ERROR 0x642 /* see err-bits */ +#define HD_NSECTOR 0x644 /* nr of sectors to read/write */ +#define HD_SECTOR 0x646 /* starting sector */ +#define HD_LCYL 0x648 /* starting cylinder */ +#define HD_HCYL 0x64a /* high byte of starting cyl */ +#define HD_CURRENT 0x64c /* 101dhhhh , d=drive, hhhh=head */ +#define HD_STATUS 0x64e /* see status-bits */ +#define HD_FEATURE HD_ERROR /* same io address, read=error, write=feature */ +#define HD_PRECOMP HD_FEATURE /* obsolete use of this port - predates IDE */ +#define HD_COMMAND HD_STATUS /* same io address, read=status, write=cmd */ + +#define HD_CMD 0x74c /* used for resets */ +#define HD_ALTSTATUS 0x74c /* same as HD_STATUS but doesn't clear irq */ + +/* Bits of HD_STATUS */ +#define ERR_STAT 0x01 +#define INDEX_STAT 0x02 +#define ECC_STAT 0x04 /* Corrected error */ +#define DRQ_STAT 0x08 +#define SEEK_STAT 0x10 +#define SERVICE_STAT SEEK_STAT +#define WRERR_STAT 0x20 +#define READY_STAT 0x40 +#define BUSY_STAT 0x80 + +/* Bits for HD_ERROR */ +#define MARK_ERR 0x01 /* Bad address mark */ +#define TRK0_ERR 0x02 /* couldn't find track 0 */ +#define ABRT_ERR 0x04 /* Command aborted */ +#define MCR_ERR 0x08 /* media change request */ +#define ID_ERR 0x10 /* ID field not found */ +#define MC_ERR 0x20 /* media changed */ +#define ECC_ERR 0x40 /* Uncorrectable ECC error */ +#define BBD_ERR 0x80 /* pre-EIDE meaning: block marked bad */ +#define ICRC_ERR 0x80 /* new meaning: CRC error during transfer */ + +static spinlock_t hd_lock = SPIN_LOCK_UNLOCKED; + +#define TIMEOUT_VALUE (6*HZ) +#define HD_DELAY 0 + +#define MAX_ERRORS 16 /* Max read/write errors/sector */ +#define RESET_FREQ 8 /* Reset controller every 8th retry */ +#define RECAL_FREQ 4 /* Recalibrate every 4th retry */ +#define MAX_HD 2 + +#define STAT_OK (READY_STAT|SEEK_STAT) +#define OK_STATUS(s) (((s)&(STAT_OK|(BUSY_STAT|WRERR_STAT|ERR_STAT)))==STAT_OK) + +static void recal_intr(void); +static void bad_rw_intr(void); + +static char recalibrate[MAX_HD]; +static char special_op[MAX_HD]; + +static int reset; +static int hd_error; + +#define SUBSECTOR(block) (CURRENT->current_nr_sectors > 0) + +/* + * This struct defines the HD's and their types. + */ +struct hd_i_struct { + unsigned int head,sect,cyl,wpcom,lzone,ctl; +}; + +#ifdef HD_TYPE +struct hd_i_struct hd_info[] = { HD_TYPE }; +static int NR_HD = ((sizeof (hd_info))/(sizeof (struct hd_i_struct))); +#else +struct hd_i_struct hd_info[MAX_HD]; +static int NR_HD; +#endif + +static struct gendisk *hd_gendisk[MAX_HD]; + +static struct timer_list device_timer; + +#define TIMEOUT_VALUE (6*HZ) + +#define SET_TIMER \ + do { \ + mod_timer(&device_timer, jiffies + TIMEOUT_VALUE); \ + } while (0) + +static void (*do_hd)(void) = NULL; +#define SET_HANDLER(x) \ +if ((do_hd = (x)) != NULL) \ + SET_TIMER; \ +else \ + del_timer(&device_timer); + + +#if (HD_DELAY > 0) +unsigned long last_req; + +unsigned long read_timer(void) +{ + extern spinlock_t i8253_lock; + unsigned long t, flags; + int i; + + spin_lock_irqsave(&i8253_lock, flags); + t = jiffies * 11932; + outb_p(0, PIT_MODE); + i = inb_p(PIT_CH0); + i |= inb(PIT_CH0) << 8; + spin_unlock_irqrestore(&i8253_lock, flags); + return(t - i); +} +#endif + +void __init hd_setup(char *str, int *ints) +{ + int hdind = 0; + + if (ints[0] != 3) + return; + if (hd_info[0].head != 0) + hdind=1; + hd_info[hdind].head = ints[2]; + hd_info[hdind].sect = ints[3]; + hd_info[hdind].cyl = ints[1]; + hd_info[hdind].wpcom = 0; + hd_info[hdind].lzone = ints[1]; + hd_info[hdind].ctl = (ints[2] > 8 ? 8 : 0); + NR_HD = hdind+1; +} + +static void dump_status (const char *msg, unsigned int stat) +{ + char devc; + + devc = !blk_queue_empty(QUEUE) ? 'a' + DEVICE_NR(CURRENT->rq_dev) : '?'; +#ifdef VERBOSE_ERRORS + printk("hd%c: %s: status=0x%02x { ", devc, msg, stat & 0xff); + if (stat & BUSY_STAT) printk("Busy "); + if (stat & READY_STAT) printk("DriveReady "); + if (stat & WRERR_STAT) printk("WriteFault "); + if (stat & SEEK_STAT) printk("SeekComplete "); + if (stat & DRQ_STAT) printk("DataRequest "); + if (stat & ECC_STAT) printk("CorrectedError "); + if (stat & INDEX_STAT) printk("Index "); + if (stat & ERR_STAT) printk("Error "); + printk("}\n"); + if ((stat & ERR_STAT) == 0) { + hd_error = 0; + } else { + hd_error = inb(HD_ERROR); + printk("hd%c: %s: error=0x%02x { ", devc, msg, hd_error & 0xff); + if (hd_error & BBD_ERR) printk("BadSector "); + if (hd_error & ECC_ERR) printk("UncorrectableError "); + if (hd_error & ID_ERR) printk("SectorIdNotFound "); + if (hd_error & ABRT_ERR) printk("DriveStatusError "); + if (hd_error & TRK0_ERR) printk("TrackZeroNotFound "); + if (hd_error & MARK_ERR) printk("AddrMarkNotFound "); + printk("}"); + if (hd_error & (BBD_ERR|ECC_ERR|ID_ERR|MARK_ERR)) { + printk(", CHS=%d/%d/%d", (inb(HD_HCYL)<<8) + inb(HD_LCYL), + inb(HD_CURRENT) & 0xf, inb(HD_SECTOR)); + if (!blk_queue_empty(QUEUE)) + printk(", sector=%ld", CURRENT->sector); + } + printk("\n"); + } +#else + printk("hd%c: %s: status=0x%02x.\n", devc, msg, stat & 0xff); + if ((stat & ERR_STAT) == 0) { + hd_error = 0; + } else { + hd_error = inb(HD_ERROR); + printk("hd%c: %s: error=0x%02x.\n", devc, msg, hd_error & 0xff); + } +#endif +} + +void check_status(void) +{ + int i = inb(HD_STATUS); + + if (!OK_STATUS(i)) { + dump_status("check_status", i); + bad_rw_intr(); + } +} + +static int controller_busy(void) +{ + int retries = 100000; + unsigned char status; + + do { + status = inb(HD_STATUS); + } while ((status & BUSY_STAT) && --retries); + return status; +} + +static int status_ok(void) +{ + unsigned char status = inb(HD_STATUS); + + if (status & BUSY_STAT) + return 1; /* Ancient, but does it make sense??? */ + if (status & WRERR_STAT) + return 0; + if (!(status & READY_STAT)) + return 0; + if (!(status & SEEK_STAT)) + return 0; + return 1; +} + +static int controller_ready(unsigned int drive, unsigned int head) +{ + int retry = 100; + + do { + if (controller_busy() & BUSY_STAT) + return 0; + outb(0xA0 | (drive<<4) | head, HD_CURRENT); + if (status_ok()) + return 1; + } while (--retry); + return 0; +} + +static void hd_out(unsigned int drive,unsigned int nsect,unsigned int sect, + unsigned int head,unsigned int cyl,unsigned int cmd, + void (*intr_addr)(void)) +{ + unsigned short port; + +#if (HD_DELAY > 0) + while (read_timer() - last_req < HD_DELAY) + /* nothing */; +#endif + if (reset) + return; + if (!controller_ready(drive, head)) { + reset = 1; + return; + } + SET_HANDLER(intr_addr); + outb(hd_info[drive].ctl,HD_CMD); + port=HD_DATA + 2; + outb(hd_info[drive].wpcom>>2, port); port += 2; + outb(nsect, port); port += 2; + outb(sect, port); port += 2; + outb(cyl, port); port += 2; + outb(cyl>>8, port); port += 2; + outb(0xA0|(drive<<4)|head, port); port += 2; + outb(cmd, port); +} + +static void hd_request (void); + +static int drive_busy(void) +{ + unsigned int i; + unsigned char c; + + for (i = 0; i < 500000 ; i++) { + c = inb(HD_STATUS); + if ((c & (BUSY_STAT | READY_STAT | SEEK_STAT)) == STAT_OK) + return 0; + } + dump_status("reset timed out", c); + return 1; +} + +static void reset_controller(void) +{ + int i; + + outb(4,HD_CMD); + for(i = 0; i < 1000; i++) barrier(); + outb(hd_info[0].ctl & 0x0f,HD_CMD); + for(i = 0; i < 1000; i++) barrier(); + if (drive_busy()) + printk("hd: controller still busy\n"); + else if ((hd_error = inb(HD_ERROR)) != 1) + printk("hd: controller reset failed: %02x\n",hd_error); +} + +static void reset_hd(void) +{ + static int i; + +repeat: + if (reset) { + reset = 0; + i = -1; + reset_controller(); + } else { + check_status(); + if (reset) + goto repeat; + } + if (++i < NR_HD) { + special_op[i] = recalibrate[i] = 1; + hd_out(i,hd_info[i].sect,hd_info[i].sect,hd_info[i].head-1, + hd_info[i].cyl,WIN_SPECIFY,&reset_hd); + if (reset) + goto repeat; + } else + hd_request(); +} + +/* + * Ok, don't know what to do with the unexpected interrupts: on some machines + * doing a reset and a retry seems to result in an eternal loop. Right now I + * ignore it, and just set the timeout. + * + * On laptops (and "green" PCs), an unexpected interrupt occurs whenever the + * drive enters "idle", "standby", or "sleep" mode, so if the status looks + * "good", we just ignore the interrupt completely. + */ +void unexpected_hd_interrupt(void) +{ + unsigned int stat = inb(HD_STATUS); + + if (stat & (BUSY_STAT|DRQ_STAT|ECC_STAT|ERR_STAT)) { + dump_status ("unexpected interrupt", stat); + SET_TIMER; + } +} + +/* + * bad_rw_intr() now tries to be a bit smarter and does things + * according to the error returned by the controller. + * -Mika Liljeberg (liljeber@cs.Helsinki.FI) + */ +static void bad_rw_intr(void) +{ + int dev; + + if (blk_queue_empty(QUEUE)) + return; + dev = DEVICE_NR(CURRENT->rq_dev); + if (++CURRENT->errors >= MAX_ERRORS || (hd_error & BBD_ERR)) { + end_request(CURRENT, 0); + special_op[dev] = recalibrate[dev] = 1; + } else if (CURRENT->errors % RESET_FREQ == 0) + reset = 1; + else if ((hd_error & TRK0_ERR) || CURRENT->errors % RECAL_FREQ == 0) + special_op[dev] = recalibrate[dev] = 1; + /* Otherwise just retry */ +} + +static inline int wait_DRQ(void) +{ + int retries = 100000, stat; + + while (--retries > 0) + if ((stat = inb(HD_STATUS)) & DRQ_STAT) + return 0; + dump_status("wait_DRQ", stat); + return -1; +} + +static void read_intr(void) +{ + int i, retries = 100000; + + do { + i = (unsigned) inb(HD_STATUS); + if (i & BUSY_STAT) + continue; + if (!OK_STATUS(i)) + break; + if (i & DRQ_STAT) + goto ok_to_read; + } while (--retries > 0); + dump_status("read_intr", i); + bad_rw_intr(); + hd_request(); + return; +ok_to_read: + insw(HD_DATA,CURRENT->buffer,256); + CURRENT->sector++; + CURRENT->buffer += 512; + CURRENT->errors = 0; + i = --CURRENT->nr_sectors; + --CURRENT->current_nr_sectors; +#ifdef DEBUG + printk("hd%c: read: sector %ld, remaining = %ld, buffer=0x%08lx\n", + dev+'a', CURRENT->sector, CURRENT->nr_sectors, + (unsigned long) CURRENT->buffer+512); +#endif + if (CURRENT->current_nr_sectors <= 0) + end_request(CURRENT, 1); + if (i > 0) { + SET_HANDLER(&read_intr); + return; + } + (void) inb(HD_STATUS); +#if (HD_DELAY > 0) + last_req = read_timer(); +#endif + if (!blk_queue_empty(QUEUE)) + hd_request(); + return; +} + +static void write_intr(void) +{ + int i; + int retries = 100000; + + do { + i = (unsigned) inb(HD_STATUS); + if (i & BUSY_STAT) + continue; + if (!OK_STATUS(i)) + break; + if ((CURRENT->nr_sectors <= 1) || (i & DRQ_STAT)) + goto ok_to_write; + } while (--retries > 0); + dump_status("write_intr", i); + bad_rw_intr(); + hd_request(); + return; +ok_to_write: + CURRENT->sector++; + i = --CURRENT->nr_sectors; + --CURRENT->current_nr_sectors; + CURRENT->buffer += 512; + if (!i || (CURRENT->bio && !SUBSECTOR(i))) + end_request(CURRENT, 1); + if (i > 0) { + SET_HANDLER(&write_intr); + outsw(HD_DATA,CURRENT->buffer,256); + local_irq_enable(); + } else { +#if (HD_DELAY > 0) + last_req = read_timer(); +#endif + hd_request(); + } + return; +} + +static void recal_intr(void) +{ + check_status(); +#if (HD_DELAY > 0) + last_req = read_timer(); +#endif + hd_request(); +} + +/* + * This is another of the error-routines I don't know what to do with. The + * best idea seems to just set reset, and start all over again. + */ +static void hd_times_out(unsigned long dummy) +{ + unsigned int dev; + + do_hd = NULL; + + if (blk_queue_empty(QUEUE)) + return; + + disable_irq(HD_IRQ); + local_irq_enable(); + reset = 1; + dev = DEVICE_NR(CURRENT->rq_dev); + printk("hd%c: timeout\n", dev+'a'); + if (++CURRENT->errors >= MAX_ERRORS) { +#ifdef DEBUG + printk("hd%c: too many errors\n", dev+'a'); +#endif + end_request(CURRENT, 0); + } + local_irq_disable(); + hd_request(); + enable_irq(HD_IRQ); +} + +int do_special_op (unsigned int dev) +{ + if (recalibrate[dev]) { + recalibrate[dev] = 0; + hd_out(dev,hd_info[dev].sect,0,0,0,WIN_RESTORE,&recal_intr); + return reset; + } + if (hd_info[dev].head > 16) { + printk ("hd%c: cannot handle device with more than 16 heads - giving up\n", dev+'a'); + end_request(CURRENT, 0); + } + special_op[dev] = 0; + return 1; +} + +/* + * The driver enables interrupts as much as possible. In order to do this, + * (a) the device-interrupt is disabled before entering hd_request(), + * and (b) the timeout-interrupt is disabled before the sti(). + * + * Interrupts are still masked (by default) whenever we are exchanging + * data/cmds with a drive, because some drives seem to have very poor + * tolerance for latency during I/O. The IDE driver has support to unmask + * interrupts for non-broken hardware, so use that driver if required. + */ +static void hd_request(void) +{ + unsigned int dev, block, nsect, sec, track, head, cyl; + + if (do_hd) + return; +repeat: + del_timer(&device_timer); + local_irq_enable(); + + if (blk_queue_empty(QUEUE)) { + do_hd = NULL; + return; + } + + if (reset) { + local_irq_disable(); + reset_hd(); + return; + } + dev = DEVICE_NR(CURRENT->rq_dev); + block = CURRENT->sector; + nsect = CURRENT->nr_sectors; + if (dev >= NR_HD) { + printk("hd: bad disk number: %d\n", dev); + end_request(CURRENT, 0); + goto repeat; + } + if (block >= get_capacity(hd_gendisk[dev]) || + ((block+nsect) > get_capacity(hd_gendisk[dev]))) { + printk("%s: bad access: block=%d, count=%d\n", + hd_gendisk[dev]->disk_name, block, nsect); + end_request(CURRENT, 0); + goto repeat; + } + + if (special_op[dev]) { + if (do_special_op(dev)) + goto repeat; + return; + } + sec = block % hd_info[dev].sect + 1; + track = block / hd_info[dev].sect; + head = track % hd_info[dev].head; + cyl = track / hd_info[dev].head; +#ifdef DEBUG + printk("hd%c: %sing: CHS=%d/%d/%d, sectors=%d, buffer=0x%08lx\n", + dev+'a', (CURRENT->cmd == READ)?"read":"writ", + cyl, head, sec, nsect, (unsigned long) CURRENT->buffer); +#endif + if(CURRENT->flags & REQ_CMD) { + switch (rq_data_dir(CURRENT)) { + case READ: + hd_out(dev,nsect,sec,head,cyl,WIN_READ,&read_intr); + if (reset) + goto repeat; + break; + case WRITE: + hd_out(dev,nsect,sec,head,cyl,WIN_WRITE,&write_intr); + if (reset) + goto repeat; + if (wait_DRQ()) { + bad_rw_intr(); + goto repeat; + } + outsw(HD_DATA,CURRENT->buffer,256); + break; + default: + printk("unknown hd-command\n"); + end_request(CURRENT, 0); + break; + } + } +} + +static void do_hd_request (request_queue_t * q) +{ + disable_irq(HD_IRQ); + hd_request(); + enable_irq(HD_IRQ); +} + +static int hd_ioctl(struct inode * inode, struct file * file, + unsigned int cmd, unsigned long arg) +{ + struct hd_geometry *loc = (struct hd_geometry *) arg; + int dev; + + if ((!inode) || kdev_none(inode->i_rdev)) + return -EINVAL; + dev = DEVICE_NR(inode->i_rdev); + if (dev >= NR_HD) + return -EINVAL; + switch (cmd) { + case HDIO_GETGEO: + { + struct hd_geometry g; + if (!loc) return -EINVAL; + g.heads = hd_info[dev].head; + g.sectors = hd_info[dev].sect; + g.cylinders = hd_info[dev].cyl; + g.start = get_start_sect(inode->i_bdev); + return copy_to_user(loc, &g, sizeof g) ? -EFAULT : 0; + } + + default: + return -EINVAL; + } +} + +static int hd_open(struct inode * inode, struct file * filp) +{ + int target = DEVICE_NR(inode->i_rdev); + if (target >= NR_HD) + return -ENODEV; + return 0; +} + +/* + * Releasing a block device means we sync() it, so that it can safely + * be forgotten about... + */ + +extern struct block_device_operations hd_fops; + +static void hd_interrupt(int irq, void *dev_id, struct pt_regs *regs) +{ + void (*handler)(void) = do_hd; + + do_hd = NULL; + del_timer(&device_timer); + if (!handler) + handler = unexpected_hd_interrupt; + handler(); + local_irq_enable(); +} + +static struct block_device_operations hd_fops = { + .open = hd_open, + .ioctl = hd_ioctl, +}; + +/* + * This is the hard disk IRQ description. The SA_INTERRUPT in sa_flags + * means we run the IRQ-handler with interrupts disabled: this is bad for + * interrupt latency, but anything else has led to problems on some + * machines. + * + * We enable interrupts in some of the routines after making sure it's + * safe. + */ + +static int __init hd_init(void) +{ + int drive; + if (register_blkdev(MAJOR_NR,"hd",&hd_fops)) { + printk("hd: unable to get major %d for hard disk\n",MAJOR_NR); + return -1; + } + blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), do_hd_request, &hd_lock); + blk_queue_max_sectors(BLK_DEFAULT_QUEUE(MAJOR_NR), 255); + init_timer(&device_timer); + device_timer.function = hd_times_out; + blk_queue_hardsect_size(QUEUE, 512); + +#ifdef __i386__ + if (!NR_HD) { + extern struct drive_info drive_info; + unsigned char *BIOS = (unsigned char *) &drive_info; + unsigned long flags; +#ifndef CONFIG_X86_PC9800 + int cmos_disks; +#endif + + for (drive=0 ; drive<2 ; drive++) { + hd_info[drive].cyl = *(unsigned short *) BIOS; + hd_info[drive].head = *(3+BIOS); + hd_info[drive].sect = *(2+BIOS); + hd_info[drive].wpcom = 0; + hd_info[drive].ctl = *(3+BIOS) > 8 ? 8 : 0; + hd_info[drive].lzone = *(unsigned short *) BIOS; + if (hd_info[drive].cyl && NR_HD == drive) + NR_HD++; + BIOS += 6; + } + + } +#endif /* __i386__ */ +#ifdef __arm__ + if (!NR_HD) { + /* We don't know anything about the drive. This means + * that you *MUST* specify the drive parameters to the + * kernel yourself. + */ + printk("hd: no drives specified - use hd=cyl,head,sectors" + " on kernel command line\n"); + } +#endif + if (!NR_HD) + goto out; + + for (drive=0 ; drive < NR_HD ; drive++) { + struct gendisk *disk = alloc_disk(); + if (!disk) + goto Enomem; + disk->major = MAJOR_NR; + disk->first_minor = drive << 6; + disk->minor_shift = 6; + disk->fops = &hd_fops; + sprintf(disk->disk_name, "hd%c", 'a'+drive); + hd_gendisk[drive] = disk; + } + for (drive=0 ; drive < NR_HD ; drive++) { + sector_t size = hd_info[drive].head * + hd_info[drive].sect * hd_info[drive].cyl; + set_capacity(hd_gendisk[drive], size); + printk ("%s: %ldMB, CHS=%d/%d/%d\n", + hd_gendisk[drive]->disk_name, + size / 2048, hd_info[drive].cyl, + hd_info[drive].head, hd_info[drive].sect); + } + + if (request_irq(HD_IRQ, hd_interrupt, SA_INTERRUPT, "hd", NULL)) { + printk("hd: unable to get IRQ%d for the hard disk driver\n", + HD_IRQ); + goto out1; + } + + if (!request_region(HD_DATA, 2, "hd(data)")) { + printk(KERN_WARNING "hd: port 0x%x busy\n", HD_DATA); + NR_HD = 0; + free_irq(HD_IRQ, NULL); + return; + } + + if (!request_region(HD_DATA + 2, 1, "hd")) + { + printk(KERN_WARNING "hd: port 0x%x busy\n", HD_DATA); + goto out2; + } + + if (!request_region(HD_DATA + 4, 1, "hd")) + { + printk(KERN_WARNING "hd: port 0x%x busy\n", HD_DATA); + goto out3; + } + + if (!request_region(HD_DATA + 6, 1, "hd")) + { + printk(KERN_WARNING "hd: port 0x%x busy\n", HD_DATA); + goto out4; + } + + if (!request_region(HD_DATA + 8, 1, "hd")) + { + printk(KERN_WARNING "hd: port 0x%x busy\n", HD_DATA); + goto out5; + } + + if (!request_region(HD_DATA + 10, 1, "hd")) + { + printk(KERN_WARNING "hd: port 0x%x busy\n", HD_DATA); + goto out6; + } + + if (!request_region(HD_DATA + 12, 1, "hd")) + { + printk(KERN_WARNING "hd: port 0x%x busy\n", HD_DATA); + goto out7; + } + + if (!request_region(HD_CMD, 1, "hd(cmd)")) + { + printk(KERN_WARNING "hd: port 0x%x busy\n", HD_CMD); + goto out8; + } + + if (!request_region(HD_CMD + 2, 1, "hd(cmd)")) + { + printk(KERN_WARNING "hd: port 0x%x busy\n", HD_CMD); + goto out9; + } + + for(drive=0; drive < NR_HD; drive++) { + struct hd_i_struct *p = hd_info + drive; + set_capacity(hd_gendisk[drive], p->head * p->sect * p->cyl); + add_disk(hd_gendisk[drive]); + } + return 0; + +out9: + release_region(HD_CMD, 1); +out8: + release_region(HD_DATA + 12, 1); +out7: + release_region(HD_DATA + 10, 1); +out6: + release_region(HD_DATA + 8, 1); +out5: + release_region(HD_DATA + 6, 1); +out4: + release_region(HD_DATA + 4, 1); +out3: + release_region(HD_DATA + 2, 1); +out2: + release_region(HD_DATA, 2); + free_irq(HD_IRQ, NULL); +out1: + for (drive = 0; drive < NR_HD; drive++) + put_disk(hd_gendisk[drive]); + NR_HD = 0; +out: + del_timer(&device_timer); + unregister_blkdev(MAJOR_NR,"hd"); + blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR)); + return -1; +Enomem: + while (drive--) + put_disk(hd_gendisk[drive]); + goto out; +} + +static int parse_hd_setup (char *line) { + int ints[6]; + + (void) get_options(line, ARRAY_SIZE(ints), ints); + hd_setup(NULL, ints); + + return 1; +} +__setup("hd=", parse_hd_setup); + +module_init(hd_init); diff -Nru a/drivers/ide/legacy/ht6560b.c b/drivers/ide/legacy/ht6560b.c --- a/drivers/ide/legacy/ht6560b.c Sun Mar 23 00:22:55 2003 +++ b/drivers/ide/legacy/ht6560b.c Sun Mar 23 00:22:55 2003 @@ -312,42 +312,7 @@ #endif } -void __init probe_ht6560b (void) -{ - int t; - - request_region(HT_CONFIG_PORT, 1, ide_hwifs[0].name); - ide_hwifs[0].chipset = ide_ht6560b; - ide_hwifs[1].chipset = ide_ht6560b; - ide_hwifs[0].selectproc = &ht6560b_selectproc; - ide_hwifs[1].selectproc = &ht6560b_selectproc; - ide_hwifs[0].tuneproc = &tune_ht6560b; - ide_hwifs[1].tuneproc = &tune_ht6560b; - ide_hwifs[0].serialized = 1; /* is this needed? */ - ide_hwifs[1].serialized = 1; /* is this needed? */ - ide_hwifs[0].mate = &ide_hwifs[1]; - ide_hwifs[1].mate = &ide_hwifs[0]; - ide_hwifs[1].channel = 1; - - /* - * Setting default configurations for drives - */ - t = (HT_CONFIG_DEFAULT << 8); - t |= HT_TIMING_DEFAULT; - ide_hwifs[0].drives[0].drive_data = t; - ide_hwifs[0].drives[1].drive_data = t; - t |= (HT_SECONDARY_IF << 8); - ide_hwifs[1].drives[0].drive_data = t; - ide_hwifs[1].drives[1].drive_data = t; - -#ifndef HWIF_PROBE_CLASSIC_METHOD - probe_hwif_init(&ide_hwifs[0]); - probe_hwif_init(&ide_hwifs[1]); -#endif /* HWIF_PROBE_CLASSIC_METHOD */ - -} - -void __init ht6560b_release (void) +void ht6560b_release (void) { if (ide_hwifs[0].chipset != ide_ht6560b && ide_hwifs[1].chipset != ide_ht6560b) @@ -371,60 +336,80 @@ release_region(HT_CONFIG_PORT, 1); } -#ifndef MODULE -/* - * init_ht6560b: - * - * called by ide.c when parsing command line - */ - -void __init init_ht6560b (void) +int __init ht6560b_mod_init(void) { - if (check_region(HT_CONFIG_PORT,1)) { + int t; + + if (!request_region(HT_CONFIG_PORT, 1, ide_hwifs[0].name)) { printk(KERN_NOTICE "%s: HT_CONFIG_PORT not found\n", __FUNCTION__); - return; + return -ENODEV; } + if (!try_to_init_ht6560b()) { - printk(KERN_NOTICE "%s: HBA not found\n", __FUNCTION__); - return; + printk(KERN_NOTICE "%s: HBA not found\n", __FUNCTION__); + goto release_region; } - probe_ht6560b(); -} -#else + ide_hwifs[0].chipset = ide_ht6560b; + ide_hwifs[1].chipset = ide_ht6560b; + ide_hwifs[0].selectproc = &ht6560b_selectproc; + ide_hwifs[1].selectproc = &ht6560b_selectproc; + ide_hwifs[0].tuneproc = &tune_ht6560b; + ide_hwifs[1].tuneproc = &tune_ht6560b; + ide_hwifs[0].serialized = 1; /* is this needed? */ + ide_hwifs[1].serialized = 1; /* is this needed? */ + ide_hwifs[0].mate = &ide_hwifs[1]; + ide_hwifs[1].mate = &ide_hwifs[0]; + ide_hwifs[1].channel = 1; -MODULE_AUTHOR("See Local File"); -MODULE_DESCRIPTION("HT-6560B EIDE-controller support"); -MODULE_LICENSE("GPL"); + /* + * Setting default configurations for drives + */ + t = (HT_CONFIG_DEFAULT << 8); + t |= HT_TIMING_DEFAULT; + ide_hwifs[0].drives[0].drive_data = t; + ide_hwifs[0].drives[1].drive_data = t; + t |= (HT_SECONDARY_IF << 8); + ide_hwifs[1].drives[0].drive_data = t; + ide_hwifs[1].drives[1].drive_data = t; -int __init ht6560b_mod_init(void) -{ - if (check_region(HT_CONFIG_PORT,1)) { - printk(KERN_NOTICE "%s: HT_CONFIG_PORT not found\n", - __FUNCTION__); - return -ENODEV; - } + probe_hwif_init(&ide_hwifs[0]); + probe_hwif_init(&ide_hwifs[1]); - if (!try_to_init_ht6560b()) { - printk(KERN_NOTICE "%s: HBA not found\n", __FUNCTION__); +#ifdef MODULE + if (ide_hwifs[0].chipset != ide_ht6560b && + ide_hwifs[1].chipset != ide_ht6560b) { + ht6560b_release(); return -ENODEV; } +#endif - probe_ht6560b(); - if (ide_hwifs[0].chipset != ide_ht6560b && - ide_hwifs[1].chipset != ide_ht6560b) { - ht6560b_release(); - return -ENODEV; - } - return 0; + return 0; + +release_region: + release_region(HT_CONFIG_PORT, 1); + return -ENODEV; } -module_init(ht6560b_mod_init); +MODULE_AUTHOR("See Local File"); +MODULE_DESCRIPTION("HT-6560B EIDE-controller support"); +MODULE_LICENSE("GPL"); + +#ifdef MODULE void __init ht6560b_mod_exit(void) { ht6560b_release(); } + +module_init(ht6560b_mod_init); module_exit(ht6560b_mod_exit); +#else +/* + * called by ide.c when parsing command line + */ +void __init init_ht6560b (void) +{ + ht6560b_mod_init(); /* ignore return value */ +} #endif - diff -Nru a/drivers/ide/legacy/pc9800.c b/drivers/ide/legacy/pc9800.c --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/drivers/ide/legacy/pc9800.c Sun Mar 23 00:22:57 2003 @@ -0,0 +1,84 @@ +/* + * ide_pc9800.c + * + * Copyright (C) 1997-2000 Linux/98 project, + * Kyoto University Microcomputer Club. + */ + +#include +#include +#include +#include +#include + +#include +#include + +#define PC9800_IDE_BANKSELECT 0x432 + +#undef PC9800_IDE_DEBUG + +static void pc9800_select(ide_drive_t *drive) +{ +#ifdef PC9800_IDE_DEBUG + byte old; + + /* Too noisy: */ + /* printk(KERN_DEBUG "pc9800_select(%s)\n", drive->name); */ + + outb(0x80, PC9800_IDE_BANKSELECT); + old = inb(PC9800_IDE_BANKSELECT); + if (old != HWIF(drive)->index) + printk(KERN_DEBUG "ide-pc9800: switching bank #%d -> #%d\n", + old, HWIF(drive)->index); +#endif + outb(HWIF(drive)->index, PC9800_IDE_BANKSELECT); +} + +void __init ide_probe_for_pc9800(void) +{ + u8 saved_bank; + + if (!PC9800_9821_P() /* || !PC9821_IDEIF_DOUBLE_P() */) + return; + + if (!request_region(PC9800_IDE_BANKSELECT, 1, "ide0/1 bank")) { + printk(KERN_ERR + "ide: bank select port (%#x) is already occupied!\n", + PC9800_IDE_BANKSELECT); + return; + } + + /* Do actual probing. */ + if ((saved_bank = inb(PC9800_IDE_BANKSELECT)) == (u8) ~0 + || (outb(saved_bank ^ 1, PC9800_IDE_BANKSELECT), + /* Next outb is dummy for reading status. */ + outb(0x80, PC9800_IDE_BANKSELECT), + inb(PC9800_IDE_BANKSELECT) != (saved_bank ^ 1))) { + printk(KERN_INFO + "ide: pc9800 type bank selecting port not found\n"); + release_region(PC9800_IDE_BANKSELECT, 1); + return; + } + + /* Restore original value, just in case. */ + outb(saved_bank, PC9800_IDE_BANKSELECT); + + /* These ports are reseved by IDE I/F. */ + if (!request_region(0x430, 1, "ide") || + !request_region(0x435, 1, "ide")) { + printk(KERN_WARNING + "ide: IO port 0x430 and 0x435 are reserved for IDE" + " the card using these ports may not work\n"); + } + + if (ide_hwifs[0].io_ports[IDE_DATA_OFFSET] == HD_DATA && + ide_hwifs[1].io_ports[IDE_DATA_OFFSET] == HD_DATA) { + ide_hwifs[0].chipset = ide_pc9800; + ide_hwifs[0].mate = &ide_hwifs[1]; + ide_hwifs[0].selectproc = pc9800_select; + ide_hwifs[1].chipset = ide_pc9800; + ide_hwifs[1].mate = &ide_hwifs[0]; + ide_hwifs[1].selectproc = pc9800_select; + } +} diff -Nru a/drivers/ide/legacy/pdc4030.c b/drivers/ide/legacy/pdc4030.c --- a/drivers/ide/legacy/pdc4030.c Sun Mar 23 00:22:53 2003 +++ b/drivers/ide/legacy/pdc4030.c Sun Mar 23 00:22:53 2003 @@ -256,12 +256,11 @@ if (!ident.current_tm[i+2].cyl) hwif2->drives[i].noprobe = 1; } -#ifndef HWIF_PROBE_CLASSIC_METHOD + probe_hwif_init(&ide_hwifs[hwif->index]); probe_hwif_init(&ide_hwifs[hwif2->index]); -#endif /* HWIF_PROBE_CLASSIC_METHOD */ - return 1; + return 1; } /* diff -Nru a/drivers/ide/legacy/qd65xx.c b/drivers/ide/legacy/qd65xx.c --- a/drivers/ide/legacy/qd65xx.c Sun Mar 23 00:22:51 2003 +++ b/drivers/ide/legacy/qd65xx.c Sun Mar 23 00:22:51 2003 @@ -359,9 +359,7 @@ hwif->drives[0].io_32bit = hwif->drives[1].io_32bit = 1; hwif->tuneproc = tuneproc; -#ifndef HWIF_PROBE_CLASSIC_METHOD probe_hwif_init(hwif); -#endif /* HWIF_PROBE_CLASSIC_METHOD */ } /* diff -Nru a/drivers/ide/legacy/umc8672.c b/drivers/ide/legacy/umc8672.c --- a/drivers/ide/legacy/umc8672.c Sun Mar 23 00:22:51 2003 +++ b/drivers/ide/legacy/umc8672.c Sun Mar 23 00:22:51 2003 @@ -162,10 +162,8 @@ ide_hwifs[1].mate = &ide_hwifs[0]; ide_hwifs[1].channel = 1; -#ifndef HWIF_PROBE_CLASSIC_METHOD probe_hwif_init(&ide_hwifs[0]); probe_hwif_init(&ide_hwifs[1]); -#endif /* HWIF_PROBE_CLASSIC_METHOD */ return 0; } diff -Nru a/drivers/ide/pci/aec62xx.c b/drivers/ide/pci/aec62xx.c --- a/drivers/ide/pci/aec62xx.c Sun Mar 23 00:22:55 2003 +++ b/drivers/ide/pci/aec62xx.c Sun Mar 23 00:22:55 2003 @@ -38,6 +38,7 @@ char *chipset_nums[] = {"error", "error", "error", "error", "error", "error", "850UF", "860", "860R", "865", "865R", "error" }; + int len; int i; for (i = 0; i < n_aec_devs; i++) { @@ -170,7 +171,11 @@ #endif /* DEBUG_AEC_REGS */ } } - return p-buffer;/* => must be less than 4k! */ + /* p - buffer must be less than 4k! */ + len = (p - buffer) - offset; + *addr = buffer + offset; + + return len > count ? count : len; } #endif /* defined(DISPLAY_AEC62xx_TIMINGS) && defined(CONFIG_PROC_FS) */ @@ -324,7 +329,7 @@ ide_hwif_t *hwif = HWIF(drive); struct hd_driveid *id = drive->id; - if (id && (id->capability & 1) && drive->autodma) { + if ((id->capability & 1) && drive->autodma) { /* Consult the list of known "bad" drives */ if (hwif->ide_dma_bad_drive(drive)) goto fast_ata_pio; diff -Nru a/drivers/ide/pci/alim15x3.c b/drivers/ide/pci/alim15x3.c --- a/drivers/ide/pci/alim15x3.c Sun Mar 23 00:22:52 2003 +++ b/drivers/ide/pci/alim15x3.c Sun Mar 23 00:22:52 2003 @@ -518,7 +518,7 @@ if ((id != NULL) && ((id->capability & 1) != 0) && drive->autodma) { /* Consult the list of known "bad" drives */ if (hwif->ide_dma_bad_drive(drive)) - goto fast_ata_pio; + goto ata_pio; if ((id->field_valid & 4) && (m5229_revision >= 0xC2)) { if (id->dma_ultra & hwif->ultra_mask) { /* Force if Capable UltraDMA */ @@ -540,12 +540,12 @@ if (!config_chipset_for_dma(drive)) goto no_dma_set; } else { - goto fast_ata_pio; + goto ata_pio; } - } else if ((id->capability & 8) || (id->field_valid & 2)) { -fast_ata_pio: + } else { +ata_pio: + hwif->tuneproc(drive, 255); no_dma_set: - hwif->tuneproc(drive, 5); return hwif->ide_dma_off_quietly(drive); } return hwif->ide_dma_on(drive); @@ -752,6 +752,8 @@ hwif->drives[1].autotune = 1; return; } + + hwif->atapi_dma = 1; if (m5229_revision > 0x20) hwif->ultra_mask = 0x3f; diff -Nru a/drivers/ide/pci/amd74xx.c b/drivers/ide/pci/amd74xx.c --- a/drivers/ide/pci/amd74xx.c Sun Mar 23 00:22:56 2003 +++ b/drivers/ide/pci/amd74xx.c Sun Mar 23 00:22:56 2003 @@ -98,6 +98,7 @@ unsigned int v, u, i; unsigned short c, w; unsigned char t; + int len; char *p = buffer; amd_print("----------AMD BusMastering IDE Configuration----------------"); @@ -167,7 +168,11 @@ amd_print_drive("Cycle Time: ", "%8dns", cycle[i]); amd_print_drive("Transfer Rate: ", "%4d.%dMB/s", speed[i] / 1000, speed[i] / 100 % 10); - return p - buffer; /* hoping it is less than 4K... */ + /* hoping p - buffer is less than 4K... */ + len = (p - buffer) - offset; + *addr = buffer + offset; + + return len > count ? count : len; } #endif diff -Nru a/drivers/ide/pci/cmd640.c b/drivers/ide/pci/cmd640.c --- a/drivers/ide/pci/cmd640.c Sun Mar 23 00:22:55 2003 +++ b/drivers/ide/pci/cmd640.c Sun Mar 23 00:22:55 2003 @@ -197,8 +197,8 @@ * Interface to access cmd640x registers */ static unsigned int cmd640_key; -static void (*put_cmd640_reg)(u16 reg, u8 val); -static u8 (*get_cmd640_reg)(u16 reg); +static void (*__put_cmd640_reg)(u16 reg, u8 val); +static u8 (*__get_cmd640_reg)(u16 reg); /* * This is read from the CFR reg, and is used in several places. @@ -215,49 +215,32 @@ static void put_cmd640_reg_pci1 (u16 reg, u8 val) { - unsigned long flags; - - spin_lock_irqsave(&ide_lock, flags); outb_p((reg & 0xfc) | cmd640_key, 0xcf8); outb_p(val, (reg & 3) | 0xcfc); - spin_unlock_irqrestore(&ide_lock, flags); } static u8 get_cmd640_reg_pci1 (u16 reg) { - u8 b; - unsigned long flags; - - spin_lock_irqsave(&ide_lock, flags); outb_p((reg & 0xfc) | cmd640_key, 0xcf8); - b = inb_p((reg & 3) | 0xcfc); - spin_unlock_irqrestore(&ide_lock, flags); - return b; + return inb_p((reg & 3) | 0xcfc); } /* PCI method 2 access (from CMD datasheet) */ static void put_cmd640_reg_pci2 (u16 reg, u8 val) { - unsigned long flags; - - spin_lock_irqsave(&ide_lock, flags); outb_p(0x10, 0xcf8); outb_p(val, cmd640_key + reg); outb_p(0, 0xcf8); - spin_unlock_irqrestore(&ide_lock, flags); } static u8 get_cmd640_reg_pci2 (u16 reg) { u8 b; - unsigned long flags; - spin_lock_irqsave(&ide_lock, flags); outb_p(0x10, 0xcf8); b = inb_p(cmd640_key + reg); outb_p(0, 0xcf8); - spin_unlock_irqrestore(&ide_lock, flags); return b; } @@ -265,26 +248,36 @@ static void put_cmd640_reg_vlb (u16 reg, u8 val) { - unsigned long flags; - - spin_lock_irqsave(&ide_lock, flags); outb_p(reg, cmd640_key); outb_p(val, cmd640_key + 4); - spin_unlock_irqrestore(&ide_lock, flags); } static u8 get_cmd640_reg_vlb (u16 reg) { + outb_p(reg, cmd640_key); + return inb_p(cmd640_key + 4); +} + +static u8 get_cmd640_reg(u16 reg) +{ u8 b; unsigned long flags; spin_lock_irqsave(&ide_lock, flags); - outb_p(reg, cmd640_key); - b = inb_p(cmd640_key + 4); + b = __get_cmd640_reg(reg); spin_unlock_irqrestore(&ide_lock, flags); return b; } +static void put_cmd640_reg(u16 reg, u8 val) +{ + unsigned long flags; + + spin_lock_irqsave(&ide_lock, flags); + __put_cmd640_reg(reg,val); + spin_unlock_irqrestore(&ide_lock, flags); +} + static int __init match_pci_cmd640_device (void) { const u8 ven_dev[4] = {0x95, 0x10, 0x40, 0x06}; @@ -307,8 +300,8 @@ */ static int __init probe_for_cmd640_pci1 (void) { - get_cmd640_reg = get_cmd640_reg_pci1; - put_cmd640_reg = put_cmd640_reg_pci1; + __get_cmd640_reg = get_cmd640_reg_pci1; + __put_cmd640_reg = put_cmd640_reg_pci1; for (cmd640_key = 0x80000000; cmd640_key <= 0x8000f800; cmd640_key += 0x800) { @@ -323,8 +316,8 @@ */ static int __init probe_for_cmd640_pci2 (void) { - get_cmd640_reg = get_cmd640_reg_pci2; - put_cmd640_reg = put_cmd640_reg_pci2; + __get_cmd640_reg = get_cmd640_reg_pci2; + __put_cmd640_reg = put_cmd640_reg_pci2; for (cmd640_key = 0xc000; cmd640_key <= 0xcf00; cmd640_key += 0x100) { if (match_pci_cmd640_device()) return 1; /* success */ @@ -339,8 +332,8 @@ { u8 b; - get_cmd640_reg = get_cmd640_reg_vlb; - put_cmd640_reg = put_cmd640_reg_vlb; + __get_cmd640_reg = get_cmd640_reg_vlb; + __put_cmd640_reg = put_cmd640_reg_vlb; cmd640_key = 0x178; b = get_cmd640_reg(CFR); if (b == 0xff || b == 0x00 || (b & CFR_AT_VESA_078h)) { @@ -454,7 +447,7 @@ unsigned long flags; spin_lock_irqsave(&ide_lock, flags); - b = get_cmd640_reg(reg); + b = __get_cmd640_reg(reg); if (mode) { /* want prefetch on? */ #if CMD640_PREFETCH_MASKS drive->no_unmask = 1; @@ -468,7 +461,7 @@ drive->io_32bit = 0; b |= prefetch_masks[index]; /* disable prefetch */ } - put_cmd640_reg(reg, b); + __put_cmd640_reg(reg, b); spin_unlock_irqrestore(&ide_lock, flags); } @@ -576,9 +569,9 @@ * and then the active/recovery counts into the DRWTIM reg * (this converts counts of 16 into counts of zero -- okay). */ - setup_count |= get_cmd640_reg(arttim_regs[index]) & 0x3f; - put_cmd640_reg(arttim_regs[index], setup_count); - put_cmd640_reg(drwtim_regs[index], pack_nibbles(active_count, recovery_count)); + setup_count |= __get_cmd640_reg(arttim_regs[index]) & 0x3f; + __put_cmd640_reg(arttim_regs[index], setup_count); + __put_cmd640_reg(drwtim_regs[index], pack_nibbles(active_count, recovery_count)); spin_unlock_irqrestore(&ide_lock, flags); } diff -Nru a/drivers/ide/pci/cs5520.c b/drivers/ide/pci/cs5520.c --- a/drivers/ide/pci/cs5520.c Sun Mar 23 00:22:50 2003 +++ b/drivers/ide/pci/cs5520.c Sun Mar 23 00:22:50 2003 @@ -65,6 +65,7 @@ { char *p = buffer; unsigned long bmiba = pci_resource_start(bmide_dev, 2); + int len; u8 c0 = 0, c1 = 0; u16 reg16; u32 reg32; @@ -94,7 +95,10 @@ pci_read_config_dword(bmide_dev, 0x68, ®32); p += sprintf(p, "16bit Secondary: %08x\n", reg32); - return p-buffer; + len = (p - buffer) - offset; + *addr = buffer + offset; + + return len > count ? count : len; } #endif @@ -259,9 +263,9 @@ { ata_index_t index; ide_pci_device_t *d = &cyrix_chipsets[id->driver_data]; - - ide_setup_pci_noise(dev, d); - + + ide_setup_pci_noise(dev, d); + /* We must not grab the entire device, it has 'ISA' space in its BARS too and we will freak out other bits of the kernel */ if(pci_enable_device_bars(dev, 1<<2)) @@ -271,15 +275,15 @@ } pci_set_master(dev); pci_set_dma_mask(dev, 0xFFFFFFFF); - init_chipset_cs5520(dev, d->name); - + init_chipset_cs5520(dev, d->name); + index.all = 0xf0f0; /* * Now the chipset is configured we can let the core * do all the device setup for us */ - + ide_pci_setup_ports(dev, d, 1, 14, &index); printk("Index.b %d %d\n", index.b.low, index.b.high); @@ -288,7 +292,7 @@ probe_hwif_init(&ide_hwifs[index.b.low]); if((index.b.high & 0xf0) != 0xf0) probe_hwif_init(&ide_hwifs[index.b.high]); - + MOD_INC_USE_COUNT; return 0; } diff -Nru a/drivers/ide/pci/cy82c693.c b/drivers/ide/pci/cy82c693.c --- a/drivers/ide/pci/cy82c693.c Sun Mar 23 00:22:51 2003 +++ b/drivers/ide/pci/cy82c693.c Sun Mar 23 00:22:51 2003 @@ -2,12 +2,12 @@ * linux/drivers/ide/pci/cy82c693.c Version 0.40 Sep. 10, 2002 * * Copyright (C) 1998-2000 Andreas S. Krebs (akrebs@altavista.net), Maintainer - * Copyright (C) 1998-2002 Andre Hedrick , Integrater + * Copyright (C) 1998-2002 Andre Hedrick , Integrator * * CYPRESS CY82C693 chipset IDE controller * * The CY82C693 chipset is used on Digital's PC-Alpha 164SX boards. - * Writting the driver was quite simple, since most of the job is + * Writing the driver was quite simple, since most of the job is * done by the generic pci-ide support. * The hard part was finding the CY82C693's datasheet on Cypress's * web page :-(. But Altavista solved this problem :-). diff -Nru a/drivers/ide/pci/hpt34x.c b/drivers/ide/pci/hpt34x.c --- a/drivers/ide/pci/hpt34x.c Sun Mar 23 00:22:52 2003 +++ b/drivers/ide/pci/hpt34x.c Sun Mar 23 00:22:52 2003 @@ -58,7 +58,7 @@ static int hpt34x_get_info (char *buffer, char **addr, off_t offset, int count) { char *p = buffer; - int i; + int i, len; p += sprintf(p, "\n " "HPT34X Chipset.\n"); @@ -96,7 +96,11 @@ } p += sprintf(p, "\n"); - return p-buffer; /* => must be less than 4k! */ + /* p - buffer must be less than 4k! */ + len = (p - buffer) - offset; + *addr = buffer + offset; + + return len > count ? count : len; } #endif /* defined(DISPLAY_HPT34X_TIMINGS) && defined(CONFIG_PROC_FS) */ @@ -162,7 +166,7 @@ /* * This allows the configuration of ide_pci chipset registers * for cards that learn about the drive's UDMA, DMA, PIO capabilities - * after the drive is reported by the OS. Initally for designed for + * after the drive is reported by the OS. Initially for designed for * HPT343 UDMA chipset by HighPoint|Triones Technologies, Inc. */ diff -Nru a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c --- a/drivers/ide/pci/hpt366.c Sun Mar 23 00:22:53 2003 +++ b/drivers/ide/pci/hpt366.c Sun Mar 23 00:22:53 2003 @@ -85,7 +85,7 @@ char *chipset_nums[] = {"366", "366", "368", "370", "370A", "372", "302", "371", "374" }; - int i; + int i, len; p += sprintf(p, "\n " "HighPoint HPT366/368/370/372/374\n"); @@ -153,8 +153,12 @@ } } p += sprintf(p, "\n"); + + /* p - buffer must be less than 4k! */ + len = (p - buffer) - offset; + *addr = buffer + offset; - return p-buffer;/* => must be less than 4k! */ + return len > count ? count : len; } #endif /* defined(DISPLAY_HPT366_TIMINGS) && defined(CONFIG_PROC_FS) */ @@ -443,7 +447,7 @@ /* * This allows the configuration of ide_pci chipset registers * for cards that learn about the drive's UDMA, DMA, PIO capabilities - * after the drive is reported by the OS. Initally for designed for + * after the drive is reported by the OS. Initially for designed for * HPT366 UDMA chipset by HighPoint|Triones Technologies, Inc. * * check_in_drive_lists(drive, bad_ata66_4) diff -Nru a/drivers/ide/pci/opti621.c b/drivers/ide/pci/opti621.c --- a/drivers/ide/pci/opti621.c Sun Mar 23 00:22:52 2003 +++ b/drivers/ide/pci/opti621.c Sun Mar 23 00:22:52 2003 @@ -118,7 +118,7 @@ */ /* #define READ_PREFETCH 0 */ -/* Uncommnent for disable read prefetch. +/* Uncomment for disable read prefetch. * There is some readprefetch capatibility in hdparm, * but when I type hdparm -P 1 /dev/hda, I got errors * and till reset drive is inaccessible. diff -Nru a/drivers/ide/pci/pdc202xx_new.c b/drivers/ide/pci/pdc202xx_new.c --- a/drivers/ide/pci/pdc202xx_new.c Sun Mar 23 00:22:54 2003 +++ b/drivers/ide/pci/pdc202xx_new.c Sun Mar 23 00:22:54 2003 @@ -77,13 +77,17 @@ static int pdcnew_get_info (char *buffer, char **addr, off_t offset, int count) { char *p = buffer; - int i; + int i, len; for (i = 0; i < n_pdc202_devs; i++) { struct pci_dev *dev = pdc202_devs[i]; p = pdcnew_info(buffer, dev); } - return p-buffer; /* => must be less than 4k! */ + /* p - buffer must be less than 4k! */ + len = (p - buffer) - offset; + *addr = buffer + offset; + + return len > count ? count : len; } #endif /* defined(DISPLAY_PDC202XX_TIMINGS) && defined(CONFIG_PROC_FS) */ diff -Nru a/drivers/ide/pci/pdc202xx_old.c b/drivers/ide/pci/pdc202xx_old.c --- a/drivers/ide/pci/pdc202xx_old.c Sun Mar 23 00:22:56 2003 +++ b/drivers/ide/pci/pdc202xx_old.c Sun Mar 23 00:22:56 2003 @@ -177,13 +177,17 @@ static int pdc202xx_get_info (char *buffer, char **addr, off_t offset, int count) { char *p = buffer; - int i; + int i, len; for (i = 0; i < n_pdc202_devs; i++) { struct pci_dev *dev = pdc202_devs[i]; p = pdc202xx_info(buffer, dev); } - return p-buffer; /* => must be less than 4k! */ + /* p - buffer must be less than 4k! */ + len = (p - buffer) - offset; + *addr = buffer + offset; + + return len > count ? count : len; } #endif /* defined(DISPLAY_PDC202XX_TIMINGS) && defined(CONFIG_PROC_FS) */ diff -Nru a/drivers/ide/pci/piix.c b/drivers/ide/pci/piix.c --- a/drivers/ide/pci/piix.c Sun Mar 23 00:22:50 2003 +++ b/drivers/ide/pci/piix.c Sun Mar 23 00:22:50 2003 @@ -1,5 +1,5 @@ /* - * linux/drivers/ide/pci/piix.c Version 0.42 January 11, 2003 + * linux/drivers/ide/pci/piix.c Version 0.44 March 20, 2003 * * Copyright (C) 1998-1999 Andrzej Krzysztofowicz, Author and Maintainer * Copyright (C) 1998-2000 Andre Hedrick @@ -106,6 +106,7 @@ #include "ide_modes.h" #include "piix.h" +static int no_piix_dma; #if defined(DISPLAY_PIIX_TIMINGS) && defined(CONFIG_PROC_FS) #include #include @@ -114,7 +115,6 @@ #define PIIX_MAX_DEVS 5 static struct pci_dev *piix_devs[PIIX_MAX_DEVS]; static int n_piix_devs; -static int no_piix_dma = 0; /** * piix_get_info - fill in /proc for PIIX ide @@ -146,7 +146,9 @@ case PCI_DEVICE_ID_INTEL_82801BA_9: case PCI_DEVICE_ID_INTEL_82801CA_10: case PCI_DEVICE_ID_INTEL_82801CA_11: + case PCI_DEVICE_ID_INTEL_82801DB_10: case PCI_DEVICE_ID_INTEL_82801DB_11: + case PCI_DEVICE_ID_INTEL_82801EB_11: case PCI_DEVICE_ID_INTEL_82801E_11: p += sprintf(p, "PIIX4 Ultra 100 "); break; @@ -279,7 +281,9 @@ case PCI_DEVICE_ID_INTEL_82801CA_10: case PCI_DEVICE_ID_INTEL_82801CA_11: case PCI_DEVICE_ID_INTEL_82801E_11: + case PCI_DEVICE_ID_INTEL_82801DB_10: case PCI_DEVICE_ID_INTEL_82801DB_11: + case PCI_DEVICE_ID_INTEL_82801EB_11: mode = 3; break; /* UDMA 66 capable */ @@ -551,7 +555,7 @@ drive->init_speed = 0; - if (id && (id->capability & 1) && drive->autodma) { + if ((id->capability & 1) && drive->autodma) { /* Consult the list of known "bad" drives */ if (hwif->ide_dma_bad_drive(drive)) goto fast_ata_pio; @@ -605,7 +609,9 @@ case PCI_DEVICE_ID_INTEL_82801BA_9: case PCI_DEVICE_ID_INTEL_82801CA_10: case PCI_DEVICE_ID_INTEL_82801CA_11: + case PCI_DEVICE_ID_INTEL_82801DB_10: case PCI_DEVICE_ID_INTEL_82801DB_11: + case PCI_DEVICE_ID_INTEL_82801EB_11: case PCI_DEVICE_ID_INTEL_82801E_11: { unsigned int extra = 0; @@ -794,7 +800,9 @@ { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_10,PCI_ANY_ID, PCI_ANY_ID, 0, 0, 12}, { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_11,PCI_ANY_ID, PCI_ANY_ID, 0, 0, 13}, { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_11,PCI_ANY_ID, PCI_ANY_ID, 0, 0, 14}, - { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801E_11, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 15}, + { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_11,PCI_ANY_ID, PCI_ANY_ID, 0, 0, 15}, + { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801E_11, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 16}, + { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_10,PCI_ANY_ID, PCI_ANY_ID, 0, 0, 17}, { 0, }, }; diff -Nru a/drivers/ide/pci/piix.h b/drivers/ide/pci/piix.h --- a/drivers/ide/pci/piix.h Sun Mar 23 00:22:51 2003 +++ b/drivers/ide/pci/piix.h Sun Mar 23 00:22:51 2003 @@ -251,8 +251,50 @@ .extra = 0, },{ /* 15 */ .vendor = PCI_VENDOR_ID_INTEL, + .device = PCI_DEVICE_ID_INTEL_82801EB_11, + .name = "ICH5", + .init_setup = init_setup_piix, + .init_chipset = init_chipset_piix, + .init_iops = NULL, + .init_hwif = init_hwif_piix, + .init_dma = init_dma_piix, + .channels = 2, + .autodma = AUTODMA, + .enablebits = {{0x41,0x80,0x80}, {0x43,0x80,0x80}}, + .bootable = ON_BOARD, + .extra = 0, + },{ /* 16 */ + .vendor = PCI_VENDOR_ID_INTEL, .device = PCI_DEVICE_ID_INTEL_82801E_11, .name = "C-ICH", + .init_setup = init_setup_piix, + .init_chipset = init_chipset_piix, + .init_iops = NULL, + .init_hwif = init_hwif_piix, + .init_dma = init_dma_piix, + .channels = 2, + .autodma = AUTODMA, + .enablebits = {{0x41,0x80,0x80}, {0x43,0x80,0x80}}, + .bootable = ON_BOARD, + .extra = 0, + },{ /* 17 */ + .vendor = PCI_VENDOR_ID_INTEL, + .device = PCI_DEVICE_ID_INTEL_82801DB_10, + .name = "ICH4", + .init_setup = init_setup_piix, + .init_chipset = init_chipset_piix, + .init_iops = NULL, + .init_hwif = init_hwif_piix, + .init_dma = init_dma_piix, + .channels = 2, + .autodma = AUTODMA, + .enablebits = {{0x41,0x80,0x80}, {0x43,0x80,0x80}}, + .bootable = ON_BOARD, + .extra = 0, + },{ /* 17 */ + .vendor = PCI_VENDOR_ID_INTEL, + .device = PCI_DEVICE_ID_INTEL_82801DB_10, + .name = "ICH4", .init_setup = init_setup_piix, .init_chipset = init_chipset_piix, .init_iops = NULL, diff -Nru a/drivers/ide/pci/sc1200.c b/drivers/ide/pci/sc1200.c --- a/drivers/ide/pci/sc1200.c Sun Mar 23 00:22:54 2003 +++ b/drivers/ide/pci/sc1200.c Sun Mar 23 00:22:54 2003 @@ -87,6 +87,7 @@ { char *p = buffer; unsigned long bibma = pci_resource_start(bmide_dev, 4); + int len; u8 c0 = 0, c1 = 0; /* @@ -111,7 +112,10 @@ p += sprintf(p, "DMA\n"); p += sprintf(p, "PIO\n"); - return p-buffer; + len = (p - buffer) - offset; + *addr = buffer + offset; + + return len > count ? count : len; } #endif /* DISPLAY_SC1200_TIMINGS && CONFIG_PROC_FS */ diff -Nru a/drivers/ide/pci/serverworks.c b/drivers/ide/pci/serverworks.c --- a/drivers/ide/pci/serverworks.c Sun Mar 23 00:22:50 2003 +++ b/drivers/ide/pci/serverworks.c Sun Mar 23 00:22:50 2003 @@ -57,7 +57,7 @@ static int svwks_get_info (char *buffer, char **addr, off_t offset, int count) { char *p = buffer; - int i; + int i, len; p += sprintf(p, "\n " "ServerWorks OSB4/CSB5/CSB6\n"); @@ -195,7 +195,11 @@ } p += sprintf(p, "\n"); - return p-buffer; /* => must be less than 4k! */ + /* p - buffer must be less than 4k! */ + len = (p - buffer) - offset; + *addr = buffer + offset; + + return len > count ? count : len; } #endif /* defined(DISPLAY_SVWKS_TIMINGS) && defined(CONFIG_PROC_FS) */ @@ -578,7 +582,7 @@ * This is a device pin issue on CSB6. * Since there will be a future raid mode, * early versions of the chipset require the - * interrupt pin to be set, and it is a compatiblity + * interrupt pin to be set, and it is a compatibility * mode issue. */ dev->irq = 0; diff -Nru a/drivers/ide/pci/siimage.c b/drivers/ide/pci/siimage.c --- a/drivers/ide/pci/siimage.c Sun Mar 23 00:22:52 2003 +++ b/drivers/ide/pci/siimage.c Sun Mar 23 00:22:52 2003 @@ -55,6 +55,7 @@ static int siimage_get_info (char *buffer, char **addr, off_t offset, int count) { char *p = buffer; + int len; u16 i; p += sprintf(p, "\n"); @@ -62,7 +63,11 @@ struct pci_dev *dev = siimage_devs[i]; p = print_siimage_get_info(p, dev, i); } - return p-buffer; /* => must be less than 4k! */ + /* p - buffer must be less than 4k! */ + len = (p - buffer) - offset; + *addr = buffer + offset; + + return len > count ? count : len; } #endif /* defined(DISPLAY_SIIMAGE_TIMINGS) && defined(CONFIG_PROC_FS) */ diff -Nru a/drivers/ide/pci/sis5513.c b/drivers/ide/pci/sis5513.c --- a/drivers/ide/pci/sis5513.c Sun Mar 23 00:22:53 2003 +++ b/drivers/ide/pci/sis5513.c Sun Mar 23 00:22:53 2003 @@ -70,7 +70,7 @@ at boot time to its value */ // #define BROKEN_LEVEL XFER_SW_DMA_0 -/* Miscellaneaous flags */ +/* Miscellaneous flags */ #define SIS5513_LATENCY 0x01 /* registers layout and init values are chipset family dependant */ @@ -185,7 +185,7 @@ { "SiS5511", PCI_DEVICE_ID_SI_5511, ATA_16, 0}, }; -/* Cycle time bits and values vary accross chip dma capabilities +/* Cycle time bits and values vary across chip dma capabilities These three arrays hold the register layout and the values to set. Indexed by chipset_family and (dma_mode - XFER_UDMA_0) */ @@ -202,7 +202,7 @@ {15,10,7,5,3,2,1}, /* ATA_133a (earliest 691 southbridges) */ {15,10,7,5,3,2,1}, /* ATA_133 */ }; -/* CRC Valid Setup Time vary accross IDE clock setting 33/66/100/133 +/* CRC Valid Setup Time vary across IDE clock setting 33/66/100/133 See SiS962 data sheet for more detail */ static u8 cvs_time_value[][XFER_UDMA_6 - XFER_UDMA_0 + 1] = { {0,0,0,0,0,0,0}, /* no udma */ @@ -214,7 +214,7 @@ {9,6,4,2,2,2,2}, {9,6,4,2,2,2,2}, }; -/* Initialize time, Active time, Recovery time vary accross +/* Initialize time, Active time, Recovery time vary across IDE clock settings. These 3 arrays hold the register value for PIO0/1/2/3/4 and DMA0/1/2 mode in order */ static u8 ini_time_value[][8] = { @@ -424,6 +424,7 @@ static int sis_get_info (char *buffer, char **addr, off_t offset, int count) { char *p = buffer; + int len; u8 reg; u16 reg2, reg3; @@ -494,7 +495,10 @@ p = get_masters_info(p); p = get_slaves_info(p); - return p-buffer; + len = (p - buffer) - offset; + *addr = buffer + offset; + + return len > count ? count : len; } #endif /* defined(DISPLAY_SIS_TIMINGS) && defined(CONFIG_PROC_FS) */ @@ -923,7 +927,7 @@ } /* Make general config ops here - 1/ tell IDE channels to operate in Compabitility mode only + 1/ tell IDE channels to operate in Compatibility mode only 2/ tell old chips to allow per drive IDE timings */ if (host_dev) { u8 reg; diff -Nru a/drivers/ide/pci/slc90e66.c b/drivers/ide/pci/slc90e66.c --- a/drivers/ide/pci/slc90e66.c Sun Mar 23 00:22:54 2003 +++ b/drivers/ide/pci/slc90e66.c Sun Mar 23 00:22:54 2003 @@ -34,8 +34,9 @@ static int slc90e66_get_info (char *buffer, char **addr, off_t offset, int count) { char *p = buffer; + int len; unsigned long bibma = pci_resource_start(bmide_dev, 4); - u16 reg40 = 0, psitre = 0, reg42 = 0, ssitre = 0; + u16 reg40 = 0, psitre = 0, reg42 = 0, ssitre = 0; u8 c0 = 0, c1 = 0; u8 reg44 = 0, reg47 = 0, reg48 = 0, reg4a = 0, reg4b = 0; @@ -110,7 +111,11 @@ * FIXME.... Add configuration junk data....blah blah...... */ - return p-buffer; /* => must be less than 4k! */ + /* p - buffer must be less than 4k! */ + len = (p - buffer) - offset; + *addr = buffer + offset; + + return len > count ? count : len; } #endif /* defined(DISPLAY_SLC90E66_TIMINGS) && defined(CONFIG_PROC_FS) */ diff -Nru a/drivers/ide/pci/via82cxxx.c b/drivers/ide/pci/via82cxxx.c --- a/drivers/ide/pci/via82cxxx.c Sun Mar 23 00:22:49 2003 +++ b/drivers/ide/pci/via82cxxx.c Sun Mar 23 00:22:49 2003 @@ -140,6 +140,7 @@ uen[4], udma[4], umul[4], active8b[4], recover8b[4]; struct pci_dev *dev = bmide_dev; unsigned int v, u, i; + int len; u16 c, w; u8 t, x; char *p = buffer; @@ -269,7 +270,10 @@ speed[i] / 1000, speed[i] / 100 % 10); /* hoping it is less than 4K... */ - return p - buffer; + len = (p - buffer) - offset; + *addr = buffer + offset; + + return len > count ? count : len; } #endif /* DISPLAY_VIA_TIMINGS && CONFIG_PROC_FS */ diff -Nru a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c --- a/drivers/ide/ppc/pmac.c Sun Mar 23 00:22:50 2003 +++ b/drivers/ide/ppc/pmac.c Sun Mar 23 00:22:50 2003 @@ -61,7 +61,7 @@ #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC /* Those fields are duplicating what is in hwif. We currently * can't use the hwif ones because of some assumptions that are - * beeing done by the generic code about the kind of dma controller + * being done by the generic code about the kind of dma controller * and format of the dma table. This will have to be fixed though. */ volatile struct dbdma_regs* dma_regs; @@ -1392,7 +1392,7 @@ /* We have to things to deal with here: * * - The dbdma won't stop if the command was started - * but completed with an error without transfering all + * but completed with an error without transferring all * datas. This happens when bad blocks are met during * a multi-block transfer. * diff -Nru a/drivers/input/keyboard/98kbd.c b/drivers/input/keyboard/98kbd.c --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/drivers/input/keyboard/98kbd.c Sun Mar 23 00:22:57 2003 @@ -0,0 +1,380 @@ +/* + * drivers/input/keyboard/98kbd.c + * + * PC-9801 keyboard driver for Linux + * + * Based on atkbd.c and xtkbd.c written by Vojtech Pavlik + * + * Copyright (c) 2002 Osamu Tomita + * Copyright (c) 1999-2001 Vojtech Pavlik + */ + +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include +#include +#include +#include +#include +#include + +#include +#include + +MODULE_AUTHOR("Osamu Tomita "); +MODULE_DESCRIPTION("PC-9801 keyboard driver"); +MODULE_LICENSE("GPL"); + +#define KBD98_KEY 0x7f +#define KBD98_RELEASE 0x80 + +static unsigned char kbd98_keycode[256] = { + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 43, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 41, 26, 28, 30, 31, 32, + 33, 34, 35, 36, 37, 38, 39, 40, 27, 44, 45, 46, 47, 48, 49, 50, + 51, 52, 53, 12, 57,184,109,104,110,111,103,105,106,108,102,107, + 74, 98, 71, 72, 73, 55, 75, 76, 77, 78, 79, 80, 81,117, 82,124, + 83,185, 87, 88, 85, 89, 90, 0, 0, 0, 0, 0, 0, 0,102, 0, + 99,133, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 0, 0, 0, 0, + 54, 58, 42, 56, 29 +}; + +struct jis_kbd_conv { + unsigned char scancode; + struct { + unsigned char shift; + unsigned char keycode; + } emul[2]; +}; + +static struct jis_kbd_conv kbd98_jis[] = { + {0x02, {{0, 3}, {1, 40}}}, + {0x06, {{0, 7}, {1, 8}}}, + {0x07, {{0, 8}, {0, 40}}}, + {0x08, {{0, 9}, {1, 10}}}, + {0x09, {{0, 10}, {1, 11}}}, + {0x0a, {{0, 11}, {1, 255}}}, + {0x0b, {{0, 12}, {0, 13}}}, + {0x0c, {{1, 7}, {0, 41}}}, + {0x1a, {{1, 3}, {1, 41}}}, + {0x26, {{0, 39}, {1, 13}}}, + {0x27, {{1, 39}, {1, 9}}}, + {0x33, {{0, 255}, {1, 12}}}, + {0xff, {{0, 255}, {1, 255}}} /* terminater */ +}; + +#define KBD98_CMD_SETEXKEY 0x1095 /* Enable/Disable Windows, Appli key */ +#define KBD98_CMD_SETRATE 0x109c /* Set typematic rate */ +#define KBD98_CMD_SETLEDS 0x109d /* Set keyboard leds */ +#define KBD98_CMD_GETLEDS 0x119d /* Get keyboard leds */ +#define KBD98_CMD_GETID 0x019f + +#define KBD98_RET_ACK 0xfa +#define KBD98_RET_NAK 0xfc /* Command NACK, send the cmd again */ + +#define KBD98_KEY_JIS_EMUL 253 +#define KBD98_KEY_UNKNOWN 254 +#define KBD98_KEY_NULL 255 + +static char *kbd98_name = "PC-9801 Keyboard"; + +struct kbd98 { + unsigned char keycode[256]; + struct input_dev dev; + struct serio *serio; + char phys[32]; + unsigned char cmdbuf[4]; + unsigned char cmdcnt; + signed char ack; + unsigned char shift; + struct { + unsigned char scancode; + unsigned char keycode; + } emul; + struct jis_kbd_conv jis[16]; +}; + +void kbd98_interrupt(struct serio *serio, unsigned char data, + unsigned int flags, struct pt_regs *regs) +{ + struct kbd98 *kbd98 = serio->private; + unsigned char scancode, keycode; + int press, i; + + switch (data) { + case KBD98_RET_ACK: + kbd98->ack = 1; + return; + case KBD98_RET_NAK: + kbd98->ack = -1; + return; + } + + if (kbd98->cmdcnt) { + kbd98->cmdbuf[--kbd98->cmdcnt] = data; + return; + } + + scancode = data & KBD98_KEY; + keycode = kbd98->keycode[scancode]; + press = !(data & KBD98_RELEASE); + if (kbd98->emul.scancode != KBD98_KEY_UNKNOWN + && scancode != kbd98->emul.scancode) { + input_report_key(&kbd98->dev, kbd98->emul.keycode, 0); + kbd98->emul.scancode = KBD98_KEY_UNKNOWN; + } + + if (keycode == KEY_RIGHTSHIFT) + kbd98->shift = press; + + switch (keycode) { + case KEY_2: + case KEY_6: + case KEY_7: + case KEY_8: + case KEY_9: + case KEY_0: + case KEY_MINUS: + case KEY_EQUAL: + case KEY_GRAVE: + case KEY_SEMICOLON: + case KEY_APOSTROPHE: + /* emulation: JIS keyboard to US101 keyboard */ + i = 0; + while (kbd98->jis[i].scancode != 0xff) { + if (scancode == kbd98->jis[i].scancode) + break; + i ++; + } + + keycode = kbd98->jis[i].emul[kbd98->shift].keycode; + if (keycode == KBD98_KEY_NULL) + return; + + if (press) { + kbd98->emul.scancode = scancode; + kbd98->emul.keycode = keycode; + if (kbd98->jis[i].emul[kbd98->shift].shift + != kbd98->shift) + input_report_key(&kbd98->dev, + KEY_RIGHTSHIFT, + !(kbd98->shift)); + } + + input_report_key(&kbd98->dev, keycode, press); + if (!press) { + if (kbd98->jis[i].emul[kbd98->shift].shift + != kbd98->shift) + input_report_key(&kbd98->dev, + KEY_RIGHTSHIFT, + kbd98->shift); + kbd98->emul.scancode = KBD98_KEY_UNKNOWN; + } + + input_sync(&kbd98->dev); + return; + + case KBD98_KEY_NULL: + return; + + case 0: + printk(KERN_WARNING "kbd98.c: Unknown key (scancode %#x) %s.\n", + data & KBD98_KEY, data & KBD98_RELEASE ? "released" : "pressed"); + return; + + default: + input_report_key(&kbd98->dev, keycode, press); + input_sync(&kbd98->dev); + } +} + +/* + * kbd98_sendbyte() sends a byte to the keyboard, and waits for + * acknowledge. It doesn't handle resends according to the keyboard + * protocol specs, because if these are needed, the keyboard needs + * replacement anyway, and they only make a mess in the protocol. + */ + +static int kbd98_sendbyte(struct kbd98 *kbd98, unsigned char byte) +{ + int timeout = 10000; /* 100 msec */ + kbd98->ack = 0; + + if (serio_write(kbd98->serio, byte)) + return -1; + + while (!kbd98->ack && timeout--) udelay(10); + + return -(kbd98->ack <= 0); +} + +/* + * kbd98_command() sends a command, and its parameters to the keyboard, + * then waits for the response and puts it in the param array. + */ + +static int kbd98_command(struct kbd98 *kbd98, unsigned char *param, int command) +{ + int timeout = 50000; /* 500 msec */ + int send = (command >> 12) & 0xf; + int receive = (command >> 8) & 0xf; + int i; + + kbd98->cmdcnt = receive; + + if (command & 0xff) + if (kbd98_sendbyte(kbd98, command & 0xff)) + return (kbd98->cmdcnt = 0) - 1; + + for (i = 0; i < send; i++) + if (kbd98_sendbyte(kbd98, param[i])) + return (kbd98->cmdcnt = 0) - 1; + + while (kbd98->cmdcnt && timeout--) udelay(10); + + if (param) + for (i = 0; i < receive; i++) + param[i] = kbd98->cmdbuf[(receive - 1) - i]; + + if (kbd98->cmdcnt) + return (kbd98->cmdcnt = 0) - 1; + + return 0; +} + +/* + * Event callback from the input module. Events that change the state of + * the hardware are processed here. + */ + +static int kbd98_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) +{ + struct kbd98 *kbd98 = dev->private; + char param[2]; + + switch (type) { + + case EV_LED: + + if (__PC9800SCA_TEST_BIT(0x481, 3)) { + /* 98note with Num Lock key */ + /* keep Num Lock status */ + *param = 0x60; + if (kbd98_command(kbd98, param, + KBD98_CMD_GETLEDS)) + printk(KERN_DEBUG + "kbd98: Get keyboard LED" + " status Error\n"); + + *param &= 1; + } else { + /* desktop PC-9801 */ + *param = 1; /* Always set Num Lock */ + } + + *param |= 0x70 + | (test_bit(LED_CAPSL, dev->led) ? 4 : 0) + | (test_bit(LED_KANA, dev->led) ? 8 : 0); + kbd98_command(kbd98, param, KBD98_CMD_SETLEDS); + + return 0; + } + + return -1; +} + +void kbd98_connect(struct serio *serio, struct serio_dev *dev) +{ + struct kbd98 *kbd98; + int i; + + if ((serio->type & SERIO_TYPE) != SERIO_PC9800) + return; + + if (!(kbd98 = kmalloc(sizeof(struct kbd98), GFP_KERNEL))) + return; + + memset(kbd98, 0, sizeof(struct kbd98)); + kbd98->emul.scancode = KBD98_KEY_UNKNOWN; + + kbd98->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_REP); + kbd98->dev.ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_KANA); + + kbd98->serio = serio; + + init_input_dev(&kbd98->dev); + kbd98->dev.keycode = kbd98->keycode; + kbd98->dev.keycodesize = sizeof(unsigned char); + kbd98->dev.keycodemax = ARRAY_SIZE(kbd98_keycode); + kbd98->dev.event = kbd98_event; + kbd98->dev.private = kbd98; + + serio->private = kbd98; + + if (serio_open(serio, dev)) { + kfree(kbd98); + return; + } + + memcpy(kbd98->jis, kbd98_jis, sizeof(kbd98_jis)); + memcpy(kbd98->keycode, kbd98_keycode, sizeof(kbd98->keycode)); + for (i = 0; i < 255; i++) + set_bit(kbd98->keycode[i], kbd98->dev.keybit); + clear_bit(0, kbd98->dev.keybit); + + sprintf(kbd98->phys, "%s/input0", serio->phys); + + kbd98->dev.name = kbd98_name; + kbd98->dev.phys = kbd98->phys; + kbd98->dev.id.bustype = BUS_XTKBD; + kbd98->dev.id.vendor = 0x0002; + kbd98->dev.id.product = 0x0001; + kbd98->dev.id.version = 0x0100; + + input_register_device(&kbd98->dev); + + printk(KERN_INFO "input: %s on %s\n", kbd98_name, serio->phys); +} + +void kbd98_disconnect(struct serio *serio) +{ + struct kbd98 *kbd98 = serio->private; + input_unregister_device(&kbd98->dev); + serio_close(serio); + kfree(kbd98); +} + +struct serio_dev kbd98_dev = { + .interrupt = kbd98_interrupt, + .connect = kbd98_connect, + .disconnect = kbd98_disconnect +}; + +int __init kbd98_init(void) +{ + serio_register_device(&kbd98_dev); + return 0; +} + +void __exit kbd98_exit(void) +{ + serio_unregister_device(&kbd98_dev); +} + +module_init(kbd98_init); +module_exit(kbd98_exit); diff -Nru a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig --- a/drivers/input/keyboard/Kconfig Sun Mar 23 00:22:55 2003 +++ b/drivers/input/keyboard/Kconfig Sun Mar 23 00:22:55 2003 @@ -90,3 +90,15 @@ The module will be called amikbd. If you want to compile it as a module, say M here and read . +config KEYBOARD_98KBD + tristate "NEC PC-9800 Keyboard support" + depends on X86_PC9800 && INPUT && INPUT_KEYBOARD && SERIO + help + Say Y here if you want to use the NEC PC-9801/PC-9821 keyboard (or + compatible) on your system. + + This driver is also available as a module ( = code which can be + inserted in and removed from the running kernel whenever you want). + The module will be called xtkbd.o. If you want to compile it as a + module, say M here and read . + diff -Nru a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile --- a/drivers/input/keyboard/Makefile Sun Mar 23 00:22:52 2003 +++ b/drivers/input/keyboard/Makefile Sun Mar 23 00:22:52 2003 @@ -10,3 +10,4 @@ obj-$(CONFIG_KEYBOARD_XTKBD) += xtkbd.o obj-$(CONFIG_KEYBOARD_AMIGA) += amikbd.o obj-$(CONFIG_KEYBOARD_NEWTON) += newtonkbd.o +obj-$(CONFIG_KEYBOARD_98KBD) += 98kbd.o diff -Nru a/drivers/input/mouse/98busmouse.c b/drivers/input/mouse/98busmouse.c --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/drivers/input/mouse/98busmouse.c Sun Mar 23 00:22:57 2003 @@ -0,0 +1,202 @@ +/* + * + * Copyright (c) 2002 Osamu Tomita + * + * Based on the work of: + * James Banks Matthew Dillon + * David Giller Nathan Laredo + * Linus Torvalds Johan Myreen + * Cliff Matthews Philip Blundell + * Russell King Vojtech Pavlik + */ + +/* + * NEC PC-9801 Bus Mouse Driver for Linux + */ + +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +MODULE_AUTHOR("Osamu Tomita "); +MODULE_DESCRIPTION("PC-9801 busmouse driver"); +MODULE_LICENSE("GPL"); + +#define PC98BM_BASE 0x7fd9 +#define PC98BM_DATA_PORT PC98BM_BASE + 0 +/* PC98BM_SIGNATURE_PORT does not exist */ +#define PC98BM_CONTROL_PORT PC98BM_BASE + 4 +/* PC98BM_INTERRUPT_PORT does not exist */ +#define PC98BM_CONFIG_PORT PC98BM_BASE + 6 + +#define PC98BM_ENABLE_IRQ 0x00 +#define PC98BM_DISABLE_IRQ 0x10 +#define PC98BM_READ_X_LOW 0x80 +#define PC98BM_READ_X_HIGH 0xa0 +#define PC98BM_READ_Y_LOW 0xc0 +#define PC98BM_READ_Y_HIGH 0xe0 + +#define PC98BM_DEFAULT_MODE 0x93 +/* PC98BM_CONFIG_BYTE is not used */ +/* PC98BM_SIGNATURE_BYTE is not used */ + +#define PC98BM_TIMER_PORT 0xbfdb +#define PC98BM_DEFAULT_TIMER_VAL 0x00 + +#define PC98BM_IRQ 13 + +MODULE_PARM(pc98bm_irq, "i"); + +static int pc98bm_irq = PC98BM_IRQ; +static int pc98bm_used = 0; + +static void pc98bm_interrupt(int irq, void *dev_id, struct pt_regs *regs); + +static int pc98bm_open(struct input_dev *dev) +{ + if (pc98bm_used++) + return 0; + if (request_irq(pc98bm_irq, pc98bm_interrupt, 0, "98busmouse", NULL)) { + pc98bm_used--; + printk(KERN_ERR "98busmouse.c: Can't allocate irq %d\n", pc98bm_irq); + return -EBUSY; + } + outb(PC98BM_ENABLE_IRQ, PC98BM_CONTROL_PORT); + return 0; +} + +static void pc98bm_close(struct input_dev *dev) +{ + if (--pc98bm_used) + return; + outb(PC98BM_DISABLE_IRQ, PC98BM_CONTROL_PORT); + free_irq(pc98bm_irq, NULL); +} + +static struct input_dev pc98bm_dev = { + .evbit = { BIT(EV_KEY) | BIT(EV_REL) }, + .keybit = { [LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT) }, + .relbit = { BIT(REL_X) | BIT(REL_Y) }, + .open = pc98bm_open, + .close = pc98bm_close, + .name = "PC-9801 bus mouse", + .phys = "isa7fd9/input0", + .id = { + .bustype = BUS_ISA, + .vendor = 0x0004, + .product = 0x0001, + .version = 0x0100, + }, +}; + +static void pc98bm_interrupt(int irq, void *dev_id, struct pt_regs *regs) +{ + char dx, dy; + unsigned char buttons; + + outb(PC98BM_READ_X_LOW, PC98BM_CONTROL_PORT); + dx = (inb(PC98BM_DATA_PORT) & 0xf); + outb(PC98BM_READ_X_HIGH, PC98BM_CONTROL_PORT); + dx |= (inb(PC98BM_DATA_PORT) & 0xf) << 4; + outb(PC98BM_READ_Y_LOW, PC98BM_CONTROL_PORT); + dy = (inb(PC98BM_DATA_PORT) & 0xf); + outb(PC98BM_READ_Y_HIGH, PC98BM_CONTROL_PORT); + buttons = inb(PC98BM_DATA_PORT); + dy |= (buttons & 0xf) << 4; + buttons = ~buttons >> 5; + + input_report_rel(&pc98bm_dev, REL_X, dx); + input_report_rel(&pc98bm_dev, REL_Y, dy); + input_report_key(&pc98bm_dev, BTN_RIGHT, buttons & 1); + input_report_key(&pc98bm_dev, BTN_MIDDLE, buttons & 2); + input_report_key(&pc98bm_dev, BTN_LEFT, buttons & 4); + input_sync(&pc98bm_dev); + + outb(PC98BM_ENABLE_IRQ, PC98BM_CONTROL_PORT); +} + +#ifndef MODULE +static int __init pc98bm_setup(char *str) +{ + int ints[4]; + str = get_options(str, ARRAY_SIZE(ints), ints); + if (ints[0] > 0) pc98bm_irq = ints[1]; + return 1; +} +__setup("pc98bm_irq=", pc98bm_setup); +#endif + +static int __init pc98bm_init(void) +{ + int i; + + for (i = 0; i <= 6; i += 2) { + if (!request_region(PC98BM_BASE + i, 1, "98busmouse")) { + printk(KERN_ERR "98busmouse.c: Can't allocate ports at %#x\n", PC98BM_BASE + i); + while (i > 0) { + i -= 2; + release_region(PC98BM_BASE + i, 1); + } + + return -EBUSY; + } + + } + + if (!request_region(PC98BM_TIMER_PORT, 1, "98busmouse")) { + printk(KERN_ERR "98busmouse.c: Can't allocate ports at %#x\n", PC98BM_TIMER_PORT); + for (i = 0; i <= 6; i += 2) + release_region(PC98BM_BASE + i, 1); + + return -EBUSY; + } + + outb(PC98BM_DEFAULT_MODE, PC98BM_CONFIG_PORT); + outb(PC98BM_DISABLE_IRQ, PC98BM_CONTROL_PORT); + + outb(PC98BM_DEFAULT_TIMER_VAL, PC98BM_TIMER_PORT); + + input_register_device(&pc98bm_dev); + + printk(KERN_INFO "input: PC-9801 bus mouse at %#x irq %d\n", PC98BM_BASE, pc98bm_irq); + + return 0; +} + +static void __exit pc98bm_exit(void) +{ + int i; + + input_unregister_device(&pc98bm_dev); + for (i = 0; i <= 6; i += 2) + release_region(PC98BM_BASE + i, 1); + + release_region(PC98BM_TIMER_PORT, 1); +} + +module_init(pc98bm_init); +module_exit(pc98bm_exit); diff -Nru a/drivers/input/mouse/Kconfig b/drivers/input/mouse/Kconfig --- a/drivers/input/mouse/Kconfig Sun Mar 23 00:22:55 2003 +++ b/drivers/input/mouse/Kconfig Sun Mar 23 00:22:55 2003 @@ -121,3 +121,15 @@ The module will be called rpcmouse. If you want to compile it as a module, say M here and read . +config MOUSE_PC9800 + tristate "NEC PC-9800 busmouse" + depends on X86_PC9800 && INPUT && INPUT_MOUSE && ISA + help + Say Y here if you have NEC PC-9801/PC-9821 computer and want its + native mouse supported. + + This driver is also available as a module ( = code which can be + inserted in and removed from the running kernel whenever you want). + The module will be called logibm.o. If you want to compile it as a + module, say M here and read . + diff -Nru a/drivers/input/mouse/Makefile b/drivers/input/mouse/Makefile --- a/drivers/input/mouse/Makefile Sun Mar 23 00:22:51 2003 +++ b/drivers/input/mouse/Makefile Sun Mar 23 00:22:51 2003 @@ -10,5 +10,6 @@ obj-$(CONFIG_MOUSE_LOGIBM) += logibm.o obj-$(CONFIG_MOUSE_MAPLE) += maplemouse.o obj-$(CONFIG_MOUSE_PC110PAD) += pc110pad.o +obj-$(CONFIG_MOUSE_PC9800) += 98busmouse.o obj-$(CONFIG_MOUSE_PS2) += psmouse.o obj-$(CONFIG_MOUSE_SERIAL) += sermouse.o diff -Nru a/drivers/input/serio/98kbd-io.c b/drivers/input/serio/98kbd-io.c --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/drivers/input/serio/98kbd-io.c Sun Mar 23 00:22:57 2003 @@ -0,0 +1,178 @@ +/* + * NEC PC-9801 keyboard controller driver for Linux + * + * Copyright (c) 1999-2002 Osamu Tomita + * Based on i8042.c written by Vojtech Pavlik + */ + +/* + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by + * the Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +MODULE_AUTHOR("Osamu Tomita "); +MODULE_DESCRIPTION("NEC PC-9801 keyboard controller driver"); +MODULE_LICENSE("GPL"); + +/* + * Names. + */ + +#define KBD98_PHYS_DESC "isa0041/serio0" + +/* + * IRQs. + */ + +#define KBD98_IRQ 1 + +/* + * Register numbers. + */ + +#define KBD98_COMMAND_REG 0x43 +#define KBD98_STATUS_REG 0x43 +#define KBD98_DATA_REG 0x41 + +spinlock_t kbd98io_lock = SPIN_LOCK_UNLOCKED; + +static struct serio kbd98_port; +extern struct pt_regs *kbd_pt_regs; + +static void kbd98io_interrupt(int irq, void *dev_id, struct pt_regs *regs); + +/* + * kbd98_flush() flushes all data that may be in the keyboard buffers + */ + +static int kbd98_flush(void) +{ + unsigned long flags; + + spin_lock_irqsave(&kbd98io_lock, flags); + + while (inb(KBD98_STATUS_REG) & 0x02) /* RxRDY */ + inb(KBD98_DATA_REG); + + if (inb(KBD98_STATUS_REG) & 0x38) + printk("98kbd-io: Keyboard error!\n"); + + spin_unlock_irqrestore(&kbd98io_lock, flags); + + return 0; +} + +/* + * kbd98_write() sends a byte out through the keyboard interface. + */ + +static int kbd98_write(struct serio *port, unsigned char c) +{ + unsigned long flags; + + spin_lock_irqsave(&kbd98io_lock, flags); + + outb(0, 0x5f); /* wait */ + outb(0x17, KBD98_COMMAND_REG); /* enable send command */ + outb(0, 0x5f); /* wait */ + outb(c, KBD98_DATA_REG); + outb(0, 0x5f); /* wait */ + outb(0x16, KBD98_COMMAND_REG); /* disable send command */ + outb(0, 0x5f); /* wait */ + + spin_unlock_irqrestore(&kbd98io_lock, flags); + + return 0; +} + +/* + * kbd98_open() is called when a port is open by the higher layer. + * It allocates the interrupt and enables in in the chip. + */ + +static int kbd98_open(struct serio *port) +{ + kbd98_flush(); + + if (request_irq(KBD98_IRQ, kbd98io_interrupt, 0, "kbd98", NULL)) { + printk(KERN_ERR "98kbd-io.c: Can't get irq %d for %s, unregistering the port.\n", KBD98_IRQ, "KBD"); + serio_unregister_port(port); + return -1; + } + + return 0; +} + +static void kbd98_close(struct serio *port) +{ + free_irq(KBD98_IRQ, NULL); + + kbd98_flush(); +} + +/* + * Structures for registering the devices in the serio.c module. + */ + +static struct serio kbd98_port = +{ + .type = SERIO_PC9800, + .write = kbd98_write, + .open = kbd98_open, + .close = kbd98_close, + .driver = NULL, + .name = "PC-9801 Kbd Port", + .phys = KBD98_PHYS_DESC, +}; + +/* + * kbd98io_interrupt() is the most important function in this driver - + * it handles the interrupts from keyboard, and sends incoming bytes + * to the upper layers. + */ + +static void kbd98io_interrupt(int irq, void *dev_id, struct pt_regs *regs) +{ + unsigned long flags; + unsigned char data; + + spin_lock_irqsave(&kbd98io_lock, flags); + + data = inb(KBD98_DATA_REG); + spin_unlock_irqrestore(&kbd98io_lock, flags); + serio_interrupt(&kbd98_port, data, 0, regs); + +} + +int __init kbd98io_init(void) +{ + serio_register_port(&kbd98_port); + + printk(KERN_INFO "serio: PC-9801 %s port at %#lx,%#lx irq %d\n", + "KBD", + (unsigned long) KBD98_DATA_REG, + (unsigned long) KBD98_COMMAND_REG, + KBD98_IRQ); + + return 0; +} + +void __exit kbd98io_exit(void) +{ + serio_unregister_port(&kbd98_port); +} + +module_init(kbd98io_init); +module_exit(kbd98io_exit); diff -Nru a/drivers/input/serio/Kconfig b/drivers/input/serio/Kconfig --- a/drivers/input/serio/Kconfig Sun Mar 23 00:22:53 2003 +++ b/drivers/input/serio/Kconfig Sun Mar 23 00:22:53 2003 @@ -107,3 +107,15 @@ tristate "Intel SA1111 keyboard controller" depends on SA1111 && SERIO +config SERIO_98KBD + tristate "NEC PC-9800 keyboard controller" + depends on X86_PC9800 && SERIO + help + Say Y here if you have the NEC PC-9801/PC-9821 and want to use its + standard keyboard connected to its keyboard controller. + + This driver is also available as a module ( = code which can be + inserted in and removed from the running kernel whenever you want). + The module will be called rpckbd.o. If you want to compile it as a + module, say M here and read . + diff -Nru a/drivers/input/serio/Makefile b/drivers/input/serio/Makefile --- a/drivers/input/serio/Makefile Sun Mar 23 00:22:50 2003 +++ b/drivers/input/serio/Makefile Sun Mar 23 00:22:50 2003 @@ -13,3 +13,4 @@ obj-$(CONFIG_SERIO_SA1111) += sa1111ps2.o obj-$(CONFIG_SERIO_AMBAKMI) += ambakmi.o obj-$(CONFIG_SERIO_Q40KBD) += q40kbd.o +obj-$(CONFIG_SERIO_98KBD) += 98kbd-io.o diff -Nru a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c --- a/drivers/macintosh/adb.c Sun Mar 23 00:22:56 2003 +++ b/drivers/macintosh/adb.c Sun Mar 23 00:22:56 2003 @@ -249,7 +249,7 @@ strcpy(current->comm, "kadbprobe"); sigfillset(&blocked); - sicprocmask(SIG_BLOCK, &blocked, NULL); + sigprocmask(SIG_BLOCK, &blocked, NULL); flush_signals(current); printk(KERN_INFO "adb: starting probe task...\n"); diff -Nru a/drivers/macintosh/mac_hid.c b/drivers/macintosh/mac_hid.c --- a/drivers/macintosh/mac_hid.c Sun Mar 23 00:22:55 2003 +++ b/drivers/macintosh/mac_hid.c Sun Mar 23 00:22:55 2003 @@ -25,38 +25,56 @@ #if defined(CONFIG_SYSCTL) /* file(s) in /proc/sys/dev/mac_hid */ -ctl_table mac_hid_files[] = -{ - { - DEV_MAC_HID_MOUSE_BUTTON_EMULATION, - "mouse_button_emulation", &mouse_emulate_buttons, sizeof(int), - 0644, NULL, &proc_dointvec - }, - { - DEV_MAC_HID_MOUSE_BUTTON2_KEYCODE, - "mouse_button2_keycode", &mouse_button2_keycode, sizeof(int), - 0644, NULL, &proc_dointvec - }, - { - DEV_MAC_HID_MOUSE_BUTTON3_KEYCODE, - "mouse_button3_keycode", &mouse_button3_keycode, sizeof(int), - 0644, NULL, &proc_dointvec - }, - { 0 } +ctl_table mac_hid_files[] = { + { + .ctl_name = DEV_MAC_HID_MOUSE_BUTTON_EMULATION, + .procname = "mouse_button_emulation", + .data = &mouse_emulate_buttons, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = &proc_dointvec, + }, + { + .ctl_name = DEV_MAC_HID_MOUSE_BUTTON2_KEYCODE, + .procname = "mouse_button2_keycode", + .data = &mouse_button2_keycode, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = &proc_dointvec, + }, + { + .ctl_name = DEV_MAC_HID_MOUSE_BUTTON3_KEYCODE, + .procname = "mouse_button3_keycode", + .data = &mouse_button3_keycode, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = &proc_dointvec, + }, + { .ctl_name = 0 } }; /* dir in /proc/sys/dev */ -ctl_table mac_hid_dir[] = -{ - { DEV_MAC_HID, "mac_hid", NULL, 0, 0555, mac_hid_files }, - { 0 } +ctl_table mac_hid_dir[] = { + { + .ctl_name = DEV_MAC_HID, + .procname = "mac_hid", + .maxlen = 0, + .mode = 0555, + .child = mac_hid_files, + }, + { .ctl_name = 0 } }; /* /proc/sys/dev itself, in case that is not there yet */ -ctl_table mac_hid_root_dir[] = -{ - { CTL_DEV, "dev", NULL, 0, 0555, mac_hid_dir }, - { 0 } +ctl_table mac_hid_root_dir[] = { + { + .ctl_name = CTL_DEV, + .procname = "dev", + .maxlen = 0, + .mode = 0555, + .child = mac_hid_dir, + }, + { .ctl_name = 0 } }; static struct ctl_table_header *mac_hid_sysctl_header; diff -Nru a/drivers/macintosh/macserial.c b/drivers/macintosh/macserial.c --- a/drivers/macintosh/macserial.c Sun Mar 23 00:22:56 2003 +++ b/drivers/macintosh/macserial.c Sun Mar 23 00:22:56 2003 @@ -441,12 +441,8 @@ static void transmit_chars(struct mac_serial *info) { - unsigned long flags; - - save_flags(flags); - cli(); if ((read_zsreg(info->zs_channel, 0) & Tx_BUF_EMP) == 0) - goto out; + return; info->tx_active = 0; if (info->x_char && !info->power_wait) { @@ -454,13 +450,13 @@ write_zsdata(info->zs_channel, info->x_char); info->x_char = 0; info->tx_active = 1; - goto out; + return; } if ((info->xmit_cnt <= 0) || info->tty->stopped || info->tx_stopped || info->power_wait) { write_zsreg(info->zs_channel, 0, RES_Tx_P); - goto out; + return; } /* Send char */ @@ -471,17 +467,17 @@ if (info->xmit_cnt < WAKEUP_CHARS) rs_sched_event(info, RS_EVENT_WRITE_WAKEUP); - - out: - restore_flags(flags); } static void powerup_done(unsigned long data) { struct mac_serial *info = (struct mac_serial *) data; + unsigned long flags; + spin_lock_irqsave(&info->lock, flags); info->power_wait = 0; transmit_chars(info); + spin_unlock_irqrestore(&info->lock, flags); } static _INLINE_ void status_handle(struct mac_serial *info) @@ -567,6 +563,7 @@ struct mac_serial *info = (struct mac_serial *) dev_id; unsigned char zs_intreg; int shift; + unsigned long flags; if (!(info->flags & ZILOG_INITIALIZED)) { printk(KERN_WARNING "rs_interrupt: irq %d, port not " @@ -588,6 +585,7 @@ else shift = 0; /* Channel B */ + spin_lock_irqsave(&info->lock, flags); for (;;) { zs_intreg = read_zsreg(info->zs_chan_a, 3) >> shift; #ifdef SERIAL_DEBUG_INTR @@ -611,6 +609,7 @@ if (zs_intreg & CHBEXT) status_handle(info); } + spin_unlock_irqrestore(&info->lock, flags); } /* Transmit DMA interrupt - not used at present */ @@ -672,13 +671,13 @@ return; #if 0 - save_flags(flags); cli(); + spin_lock_irqsave(&info->lock, flags); if (info->curregs[5] & TxENAB) { info->curregs[5] &= ~TxENAB; info->pendregs[5] &= ~TxENAB; write_zsreg(info->zs_channel, 5, info->curregs[5]); } - restore_flags(flags); + spin_unlock_irqrestore(&info->lock, flags); #endif } @@ -695,7 +694,7 @@ if (serial_paranoia_check(info, tty->device, "rs_start")) return; - save_flags(flags); cli(); + spin_lock_irqsave(&info->lock, flags); #if 0 if (info->xmit_cnt && info->xmit_buf && !(info->curregs[5] & TxENAB)) { info->curregs[5] |= TxENAB; @@ -707,7 +706,7 @@ transmit_chars(info); } #endif - restore_flags(flags); + spin_unlock_irqrestore(&info->lock, flags); } static void do_softint(void *private_) @@ -754,12 +753,11 @@ unsigned long flags; /* delay is in ms */ - save_flags(flags); - cli(); + spin_lock_irqsave(&info->lock, flags); info->power_wait = 1; mod_timer(&info->powerup_timer, jiffies + (delay * HZ + 999) / 1000); - restore_flags(flags); + spin_unlock_irqrestore(&info->lock, flags); } OPNDBG("enabling IRQ on ttyS%d (irq %d)...\n", info->line, info->irq); @@ -1019,7 +1017,7 @@ OPNDBG("setting up ttyS%d SCC...\n", info->line); - save_flags(flags); cli(); /* Disable interrupts */ + spin_lock_irqsave(&info->lock, flags); /* Nice buggy HW ... */ fix_zero_bug_scc(info); @@ -1091,6 +1089,8 @@ clear_bit(TTY_IO_ERROR, &info->tty->flags); info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; + spin_unlock_irqrestore(&info->lock, flags); + /* * Set the speed of the serial port */ @@ -1099,8 +1099,6 @@ /* Save the current value of RR0 */ info->read_reg_zero = read_zsreg(info->zs_channel, 0); - restore_flags(flags); - if (info->dma_initted) { spin_lock_irqsave(&info->rx_dma_lock, flags); rxdma_start(info, 0); @@ -1214,10 +1212,7 @@ static void irda_rts_pulses(struct mac_serial *info, int w) { - unsigned long flags; - udelay(w); - save_flags(flags); cli(); write_zsreg(info->zs_channel, 5, Tx8 | TxENAB); udelay(2); write_zsreg(info->zs_channel, 5, Tx8 | TxENAB | RTS); @@ -1225,7 +1220,6 @@ write_zsreg(info->zs_channel, 5, Tx8 | TxENAB); udelay(4); write_zsreg(info->zs_channel, 5, Tx8 | TxENAB | RTS); - restore_flags(flags); } /* @@ -1234,7 +1228,6 @@ static void irda_setup(struct mac_serial *info) { int code, speed, t; - unsigned long flags; speed = info->tty->termios->c_cflag & CBAUD; if (speed < B2400 || speed > B115200) @@ -1268,10 +1261,8 @@ /* set TxD low for ~104us and pulse RTS */ udelay(1000); - save_flags(flags); cli(); write_zsdata(info->zs_channel, 0xfe); irda_rts_pulses(info, 150); - restore_flags(flags); irda_rts_pulses(info, 180); irda_rts_pulses(info, 50); udelay(100); @@ -1351,7 +1342,7 @@ else if (baud == 0) baud = 38400; - save_flags(flags); cli(); + spin_lock_irqsave(&info->lock, flags); info->zs_baud = baud; info->clk_divisor = 16; @@ -1460,22 +1451,23 @@ /* Load up the new values */ load_zsregs(info->zs_channel, info->curregs); - restore_flags(flags); + spin_unlock_irqrestore(&info->lock, flags); } static void rs_flush_chars(struct tty_struct *tty) { struct mac_serial *info = (struct mac_serial *)tty->driver_data; + unsigned long flags; if (serial_paranoia_check(info, tty->device, "rs_flush_chars")) return; - if (info->xmit_cnt <= 0 || tty->stopped || info->tx_stopped || - !info->xmit_buf) - return; - - /* Enable transmitter */ - transmit_chars(info); + spin_lock_irqsave(&info->lock, flags); + if (!(info->xmit_cnt <= 0 || tty->stopped || info->tx_stopped || + !info->xmit_buf)) + /* Enable transmitter */ + transmit_chars(info); + spin_unlock_irqrestore(&info->lock, flags); } static int rs_write(struct tty_struct * tty, int from_user, @@ -1506,15 +1498,14 @@ ret = -EFAULT; break; } - save_flags(flags); - cli(); + spin_lock_irqsave(&info->lock, flags); c = MIN(c, MIN(SERIAL_XMIT_SIZE - info->xmit_cnt - 1, SERIAL_XMIT_SIZE - info->xmit_head)); memcpy(info->xmit_buf + info->xmit_head, tmp_buf, c); info->xmit_head = ((info->xmit_head + c) & (SERIAL_XMIT_SIZE-1)); info->xmit_cnt += c; - restore_flags(flags); + spin_unlock_irqrestore(&info->lock, flags); buf += c; count -= c; ret += c; @@ -1522,28 +1513,29 @@ up(&tmp_buf_sem); } else { while (1) { - save_flags(flags); - cli(); + spin_lock_irqsave(&info->lock, flags); c = MIN(count, MIN(SERIAL_XMIT_SIZE - info->xmit_cnt - 1, SERIAL_XMIT_SIZE - info->xmit_head)); if (c <= 0) { - restore_flags(flags); + spin_unlock_irqrestore(&info->lock, flags); break; } memcpy(info->xmit_buf + info->xmit_head, buf, c); info->xmit_head = ((info->xmit_head + c) & (SERIAL_XMIT_SIZE-1)); info->xmit_cnt += c; - restore_flags(flags); + spin_unlock_irqrestore(&info->lock, flags); buf += c; count -= c; ret += c; } } + spin_lock_irqsave(&info->lock, flags); if (info->xmit_cnt && !tty->stopped && !info->tx_stopped && !info->tx_active) transmit_chars(info); + spin_unlock_irqrestore(&info->lock, flags); return ret; } @@ -1576,9 +1568,9 @@ if (serial_paranoia_check(info, tty->device, "rs_flush_buffer")) return; - save_flags(flags); cli(); + spin_lock_irqsave(&info->lock, flags); info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; - restore_flags(flags); + spin_unlock_irqrestore(&info->lock, flags); wake_up_interruptible(&tty->write_wait); if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && tty->ldisc.write_wakeup) @@ -1605,11 +1597,11 @@ return; if (I_IXOFF(tty)) { - save_flags(flags); cli(); + spin_lock_irqsave(&info->lock, flags); info->x_char = STOP_CHAR(tty); if (!info->tx_active) transmit_chars(info); - restore_flags(flags); + spin_unlock_irqrestore(&info->lock, flags); } if (C_CRTSCTS(tty)) { @@ -1627,21 +1619,21 @@ * drop RTS. */ if (info->is_internal_modem) { - save_flags(flags); cli(); + spin_lock_irqsave(&info->lock, flags); info->curregs[5] &= ~RTS; info->pendregs[5] &= ~RTS; write_zsreg(info->zs_channel, 5, info->curregs[5]); - restore_flags(flags); + spin_unlock_irqrestore(&info->lock, flags); } } #ifdef CDTRCTS if (tty->termios->c_cflag & CDTRCTS) { - save_flags(flags); cli(); + spin_lock_irqsave(&info->lock, flags); info->curregs[5] &= ~DTR; info->pendregs[5] &= ~DTR; write_zsreg(info->zs_channel, 5, info->curregs[5]); - restore_flags(flags); + spin_unlock_irqrestore(&info->lock, flags); } #endif /* CDTRCTS */ } @@ -1659,7 +1651,7 @@ return; if (I_IXOFF(tty)) { - save_flags(flags); cli(); + spin_lock_irqsave(&info->lock, flags); if (info->x_char) info->x_char = 0; else { @@ -1667,26 +1659,26 @@ if (!info->tx_active) transmit_chars(info); } - restore_flags(flags); + spin_unlock_irqrestore(&info->lock, flags); } if (C_CRTSCTS(tty) && info->is_internal_modem) { /* Assert RTS line */ - save_flags(flags); cli(); + spin_lock_irqsave(&info->lock, flags); info->curregs[5] |= RTS; info->pendregs[5] |= RTS; write_zsreg(info->zs_channel, 5, info->curregs[5]); - restore_flags(flags); + spin_unlock_irqrestore(&info->lock, flags); } #ifdef CDTRCTS if (tty->termios->c_cflag & CDTRCTS) { /* Assert DTR line */ - save_flags(flags); cli(); + spin_lock_irqsave(&info->lock, flags); info->curregs[5] |= DTR; info->pendregs[5] |= DTR; write_zsreg(info->zs_channel, 5, info->curregs[5]); - restore_flags(flags); + spin_unlock_irqrestore(&info->lock, flags); } #endif } @@ -1779,9 +1771,9 @@ unsigned char status; unsigned long flags; - save_flags(flags); cli(); + spin_lock_irqsave(&info->lock, flags); status = read_zsreg(info->zs_channel, 0); - restore_flags(flags); + spin_unlock_irqrestore(&info->lock, flags); status = (status & Tx_BUF_EMP)? TIOCSER_TEMT: 0; return put_user(status,value); } @@ -1792,10 +1784,10 @@ unsigned int result; unsigned long flags; - save_flags(flags); cli(); + spin_lock_irqsave(&info->lock, flags); control = info->curregs[5]; status = read_zsreg(info->zs_channel, 0); - restore_flags(flags); + spin_unlock_irqrestore(&info->lock, flags); result = ((control & RTS) ? TIOCM_RTS: 0) | ((control & DTR) ? TIOCM_DTR: 0) | ((status & DCD) ? TIOCM_CAR: 0) @@ -1812,7 +1804,7 @@ if (get_user(arg, value)) return -EFAULT; bits = (arg & TIOCM_RTS? RTS: 0) + (arg & TIOCM_DTR? DTR: 0); - save_flags(flags); cli(); + spin_lock_irqsave(&info->lock, flags); switch (cmd) { case TIOCMBIS: info->curregs[5] |= bits; @@ -1824,12 +1816,12 @@ info->curregs[5] = (info->curregs[5] & ~(DTR | RTS)) | bits; break; default: - restore_flags(flags); + spin_unlock_irqrestore(&info->lock, flags); return -EINVAL; } info->pendregs[5] = info->curregs[5]; write_zsreg(info->zs_channel, 5, info->curregs[5]); - restore_flags(flags); + spin_unlock_irqrestore(&info->lock, flags); return 0; } @@ -1844,13 +1836,13 @@ if (serial_paranoia_check(info, tty->device, "rs_break")) return; - save_flags(flags); cli(); + spin_lock_irqsave(&info->lock, flags); if (break_state == -1) info->curregs[5] |= SND_BRK; else info->curregs[5] &= ~SND_BRK; write_zsreg(info->zs_channel, 5, info->curregs[5]); - restore_flags(flags); + spin_unlock_irqrestore(&info->lock, flags); } static int rs_ioctl(struct tty_struct *tty, struct file * file, @@ -1932,11 +1924,11 @@ if (!info || serial_paranoia_check(info, tty->device, "rs_close")) return; - save_flags(flags); cli(); + spin_lock_irqsave(&info->lock, flags); if (tty_hung_up_p(filp)) { MOD_DEC_USE_COUNT; - restore_flags(flags); + spin_unlock_irqrestore(&info->lock, flags); return; } @@ -1960,7 +1952,7 @@ } if (info->count) { MOD_DEC_USE_COUNT; - restore_flags(flags); + spin_unlock_irqrestore(&info->lock, flags); return; } info->flags |= ZILOG_CLOSING; @@ -1979,9 +1971,9 @@ OPNDBG("waiting end of Tx... (timeout:%d)\n", info->closing_wait); tty->closing = 1; if (info->closing_wait != ZILOG_CLOSING_WAIT_NONE) { - restore_flags(flags); + spin_unlock_irqrestore(&info->lock, flags); tty_wait_until_sent(tty, info->closing_wait); - save_flags(flags); cli(); + spin_lock_irqsave(&info->lock, flags); } /* @@ -2001,15 +1993,15 @@ * has completely drained. */ OPNDBG("waiting end of Rx...\n"); - restore_flags(flags); + spin_unlock_irqrestore(&info->lock, flags); rs_wait_until_sent(tty, info->timeout); - save_flags(flags); cli(); + spin_lock_irqsave(&info->lock, flags); } shutdown(info); /* restore flags now since shutdown() will have disabled this port's specific irqs */ - restore_flags(flags); + spin_unlock_irqrestore(&info->lock, flags); if (tty->driver.flush_buffer) tty->driver.flush_buffer(tty); @@ -2174,18 +2166,18 @@ add_wait_queue(&info->open_wait, &wait); OPNDBG("block_til_ready before block: ttyS%d, count = %d\n", info->line, info->count); - cli(); + spin_lock_irq(&info->lock); if (!tty_hung_up_p(filp)) info->count--; - sti(); + spin_unlock_irq(&info->lock); info->blocked_open++; while (1) { - cli(); + spin_lock_irq(&info->lock); if (!(info->flags & ZILOG_CALLOUT_ACTIVE) && (tty->termios->c_cflag & CBAUD) && !info->is_irda) zs_rtsdtr(info, 1); - sti(); + spin_unlock_irq(&info->lock); set_current_state(TASK_INTERRUPTIBLE); if (tty_hung_up_p(filp) || !(info->flags & ZILOG_INITIALIZED)) { @@ -2553,7 +2545,6 @@ int macserial_init(void) { int channel, i; - unsigned long flags; struct mac_serial *info; /* Find out how many Z8530 SCCs we have */ @@ -2570,7 +2561,6 @@ * We also request the OF resources here as probe_sccs() * might be called too early for that */ - save_flags(flags); cli(); for (i = 0; i < zs_channels_found; ++i) { struct device_node* ch = zs_soft[i].dev_node; if (!request_OF_resource(ch, 0, NULL)) { @@ -2607,7 +2597,6 @@ zs_soft[i].irq); disable_irq(zs_soft[i].irq); } - restore_flags(flags); show_serial_version(); @@ -2723,6 +2712,7 @@ info->count = 0; info->blocked_open = 0; INIT_WORK(&info->tqueue, do_softint, info); + spin_lock_init(&info->lock); info->callout_termios = callout_driver.init_termios; info->normal_termios = serial_driver.init_termios; init_waitqueue_head(&info->open_wait); @@ -2753,7 +2743,7 @@ for (info = zs_chain, i = 0; info; info = info->zs_next, i++) set_scc_power(info, 0); - save_flags(flags); cli(); + spin_lock_irqsave(&info->lock, flags); for (i = 0; i < zs_channels_found; ++i) { free_irq(zs_soft[i].irq, &zs_soft[i]); if (zs_soft[i].has_dma) { @@ -2767,7 +2757,7 @@ release_OF_resource(ch, ch->n_addrs - 1); } } - restore_flags(flags); + spin_unlock_irqrestore(&info->lock, flags); tty_unregister_driver(&callout_driver); tty_unregister_driver(&serial_driver); @@ -2944,7 +2934,7 @@ } co->cflag = cflag; - save_flags(flags); cli(); + spin_lock_irqsave(&info->lock, flags); memset(info->curregs, 0, sizeof(info->curregs)); info->zs_baud = baud; @@ -3026,7 +3016,7 @@ /* Load up the new values */ load_zsregs(info->zs_channel, info->curregs); - restore_flags(flags); + spin_unlock_irqrestore(&info->lock, flags); return 0; } diff -Nru a/drivers/macintosh/macserial.h b/drivers/macintosh/macserial.h --- a/drivers/macintosh/macserial.h Sun Mar 23 00:22:52 2003 +++ b/drivers/macintosh/macserial.h Sun Mar 23 00:22:52 2003 @@ -9,6 +9,8 @@ #ifndef _MACSERIAL_H #define _MACSERIAL_H +#include + #define NUM_ZSREGS 16 struct serial_struct { @@ -105,6 +107,7 @@ struct mac_zschannel *zs_chan_a; /* A side registers */ unsigned char read_reg_zero; struct device_node* dev_node; + spinlock_t lock; char soft_carrier; /* Use soft carrier on this channel */ char break_abort; /* Is serial console in, so process brk/abrt */ diff -Nru a/drivers/macintosh/mediabay.c b/drivers/macintosh/mediabay.c --- a/drivers/macintosh/mediabay.c Sun Mar 23 00:22:51 2003 +++ b/drivers/macintosh/mediabay.c Sun Mar 23 00:22:51 2003 @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -493,7 +494,7 @@ } while(--timeout); printk(KERN_DEBUG "Timeount waiting IDE in bay %d\n", i); return -ENODEV; - } + } #endif return -ENODEV; @@ -567,9 +568,10 @@ hw_regs_t hw; pmu_suspend(); - ide_init_hwif_ports(&hw, (ide_ioreg_t) bay->cd_base, (ide_ioreg_t) 0, NULL); + ide_init_hwif_ports(&hw, (unsigned long) bay->cd_base, (unsigned long) 0, NULL); hw.irq = bay->cd_irq; - bay->cd_index = ide_register_hw(&hw); + hw.chipset = ide_pmac; + bay->cd_index = ide_register_hw(&hw, NULL); pmu_resume(); } if (bay->cd_index == -1) { @@ -834,4 +836,4 @@ return 0; } -device_initcall(media_bay_init); +subsys_initcall(media_bay_init); diff -Nru a/drivers/macintosh/via-cuda.c b/drivers/macintosh/via-cuda.c --- a/drivers/macintosh/via-cuda.c Sun Mar 23 00:22:50 2003 +++ b/drivers/macintosh/via-cuda.c Sun Mar 23 00:22:50 2003 @@ -176,8 +176,8 @@ /* for us by the main VIA driver in arch/m68k/mac/via.c */ #ifndef CONFIG_MAC - via[IFR] = 0x7f; eieio(); /* clear interrupts by writing 1s */ - via[IER] = IER_SET|SR_INT; eieio(); /* enable interrupt from SR */ + out_8(&via[IFR], 0x7f); /* clear interrupts by writing 1s */ + out_8(&via[IER], IER_SET|SR_INT); /* enable interrupt from SR */ #endif /* enable autopoll */ @@ -246,7 +246,8 @@ #endif /* CONFIG_ADB */ #define WAIT_FOR(cond, what) \ - do { \ + do { \ + int x; \ for (x = 1000; !(cond); --x) { \ if (x == 0) { \ printk("Timeout waiting for " what "\n"); \ @@ -259,40 +260,40 @@ static int cuda_init_via() { - int x; - - via[DIRB] = (via[DIRB] | TACK | TIP) & ~TREQ; /* TACK & TIP out */ - via[B] |= TACK | TIP; /* negate them */ - via[ACR] = (via[ACR] & ~SR_CTRL) | SR_EXT; /* SR data in */ - eieio(); - x = via[SR]; eieio(); /* clear any left-over data */ + out_8(&via[DIRB], (in_8(&via[DIRB]) | TACK | TIP) & ~TREQ); /* TACK & TIP out */ + out_8(&via[B], in_8(&via[B]) | TACK | TIP); /* negate them */ + out_8(&via[ACR] ,(in_8(&via[ACR]) & ~SR_CTRL) | SR_EXT); /* SR data in */ + (void)in_8(&via[SR]); /* clear any left-over data */ #ifndef CONFIG_MAC - via[IER] = 0x7f; eieio(); /* disable interrupts from VIA */ + out_8(&via[IER], 0x7f); /* disable interrupts from VIA */ + (void)in_8(&via[IER]); #endif - eieio(); /* delay 4ms and then clear any pending interrupt */ mdelay(4); - x = via[SR]; eieio(); + (void)in_8(&via[SR]); + out_8(&via[IFR], in_8(&via[IFR]) & 0x7f); /* sync with the CUDA - assert TACK without TIP */ - via[B] &= ~TACK; eieio(); + out_8(&via[B], in_8(&via[B]) & ~TACK); /* wait for the CUDA to assert TREQ in response */ - WAIT_FOR((via[B] & TREQ) == 0, "CUDA response to sync"); + WAIT_FOR((in_8(&via[B]) & TREQ) == 0, "CUDA response to sync"); /* wait for the interrupt and then clear it */ - WAIT_FOR(via[IFR] & SR_INT, "CUDA response to sync (2)"); - x = via[SR]; eieio(); + WAIT_FOR(in_8(&via[IFR]) & SR_INT, "CUDA response to sync (2)"); + (void)in_8(&via[SR]); + out_8(&via[IFR], in_8(&via[IFR]) & 0x7f); /* finish the sync by negating TACK */ - via[B] |= TACK; eieio(); + out_8(&via[B], in_8(&via[B]) | TACK); /* wait for the CUDA to negate TREQ and the corresponding interrupt */ - WAIT_FOR(via[B] & TREQ, "CUDA response to sync (3)"); - WAIT_FOR(via[IFR] & SR_INT, "CUDA response to sync (4)"); - x = via[SR]; eieio(); - via[B] |= TIP; eieio(); /* should be unnecessary */ + WAIT_FOR(in_8(&via[B]) & TREQ, "CUDA response to sync (3)"); + WAIT_FOR(in_8(&via[IFR]) & SR_INT, "CUDA response to sync (4)"); + (void)in_8(&via[SR]); + out_8(&via[IFR], in_8(&via[IFR]) & 0x7f); + out_8(&via[B], in_8(&via[B]) | TIP); /* should be unnecessary */ return 0; } @@ -415,55 +416,59 @@ req = current_req; if (req == 0) return; - if ((via[B] & TREQ) == 0) + if ((in_8(&via[B]) & TREQ) == 0) return; /* a byte is coming in from the CUDA */ /* set the shift register to shift out and send a byte */ - via[ACR] |= SR_OUT; eieio(); - via[SR] = req->data[0]; eieio(); - via[B] &= ~TIP; + out_8(&via[ACR], in_8(&via[ACR]) | SR_OUT); + out_8(&via[SR], req->data[0]); + out_8(&via[B], in_8(&via[B]) & ~TIP); cuda_state = sent_first_byte; } void cuda_poll() { - if (via[IFR] & SR_INT) { - unsigned long flags; + unsigned long flags; - /* cuda_interrupt only takes a normal lock, we disable - * interrupts here to avoid re-entering and thus deadlocking. - * An option would be to disable only the IRQ source with - * disable_irq(), would that work on m68k ? --BenH - */ - local_irq_save(flags); - cuda_interrupt(0, 0, 0); - local_irq_restore(flags); - } + /* cuda_interrupt only takes a normal lock, we disable + * interrupts here to avoid re-entering and thus deadlocking. + * An option would be to disable only the IRQ source with + * disable_irq(), would that work on m68k ? --BenH + */ + local_irq_save(flags); + cuda_interrupt(0, 0, 0); + local_irq_restore(flags); } static void cuda_interrupt(int irq, void *arg, struct pt_regs *regs) { - int x, status; + int status; struct adb_request *req = NULL; unsigned char ibuf[16]; int ibuf_len = 0; int complete = 0; + unsigned char virq; - if ((via[IFR] & SR_INT) == 0) - return; - spin_lock(&cuda_lock); - status = (~via[B] & (TIP|TREQ)) | (via[ACR] & SR_OUT); eieio(); + + virq = in_8(&via[IFR]) & 0x7f; + out_8(&via[IFR], virq); + if ((virq & SR_INT) == 0) { + spin_unlock(&cuda_lock); + return; + } + + status = (~in_8(&via[B]) & (TIP|TREQ)) | (in_8(&via[ACR]) & SR_OUT); /* printk("cuda_interrupt: state=%d status=%x\n", cuda_state, status); */ switch (cuda_state) { case idle: /* CUDA has sent us the first byte of data - unsolicited */ if (status != TREQ) printk("cuda: state=idle, status=%x\n", status); - x = via[SR]; eieio(); - via[B] &= ~TIP; eieio(); + (void)in_8(&via[SR]); + out_8(&via[B], in_8(&via[B]) & ~TIP); cuda_state = reading; reply_ptr = cuda_rbuf; reading_reply = 0; @@ -473,8 +478,8 @@ /* CUDA has sent us the first byte of data of a reply */ if (status != TREQ) printk("cuda: state=awaiting_reply, status=%x\n", status); - x = via[SR]; eieio(); - via[B] &= ~TIP; eieio(); + (void)in_8(&via[SR]); + out_8(&via[B], in_8(&via[B]) & ~TIP); cuda_state = reading; reply_ptr = current_req->reply; reading_reply = 1; @@ -483,16 +488,16 @@ case sent_first_byte: if (status == TREQ + TIP + SR_OUT) { /* collision */ - via[ACR] &= ~SR_OUT; eieio(); - x = via[SR]; eieio(); - via[B] |= TIP | TACK; eieio(); + out_8(&via[ACR], in_8(&via[ACR]) & ~SR_OUT); + (void)in_8(&via[SR]); + out_8(&via[B], in_8(&via[B]) | TIP | TACK); cuda_state = idle; } else { /* assert status == TIP + SR_OUT */ if (status != TIP + SR_OUT) printk("cuda: state=sent_first_byte status=%x\n", status); - via[SR] = current_req->data[1]; eieio(); - via[B] ^= TACK; eieio(); + out_8(&via[SR], current_req->data[1]); + out_8(&via[B], in_8(&via[B]) ^ TACK); data_index = 2; cuda_state = sending; } @@ -501,9 +506,9 @@ case sending: req = current_req; if (data_index >= req->nbytes) { - via[ACR] &= ~SR_OUT; eieio(); - x = via[SR]; eieio(); - via[B] |= TACK | TIP; eieio(); + out_8(&via[ACR], in_8(&via[ACR]) & ~SR_OUT); + (void)in_8(&via[SR]); + out_8(&via[B], in_8(&via[B]) | TACK | TIP); req->sent = 1; if (req->reply_expected) { cuda_state = awaiting_reply; @@ -515,27 +520,27 @@ cuda_start(); } } else { - via[SR] = req->data[data_index++]; eieio(); - via[B] ^= TACK; eieio(); + out_8(&via[SR], req->data[data_index++]); + out_8(&via[B], in_8(&via[B]) ^ TACK); } break; case reading: - *reply_ptr++ = via[SR]; eieio(); + *reply_ptr++ = in_8(&via[SR]); if (status == TIP) { /* that's all folks */ - via[B] |= TACK | TIP; eieio(); + out_8(&via[B], in_8(&via[B]) | TACK | TIP); cuda_state = read_done; } else { /* assert status == TIP | TREQ */ if (status != TIP + TREQ) printk("cuda: state=reading status=%x\n", status); - via[B] ^= TACK; eieio(); + out_8(&via[B], in_8(&via[B]) ^ TACK); } break; case read_done: - x = via[SR]; eieio(); + (void)in_8(&via[SR]); if (reading_reply) { req = current_req; req->reply_len = reply_ptr - req->reply; @@ -564,7 +569,7 @@ memcpy(ibuf, cuda_rbuf, ibuf_len); } if (status == TREQ) { - via[B] &= ~TIP; eieio(); + out_8(&via[B], in_8(&via[B]) & ~TIP); cuda_state = reading; reply_ptr = cuda_rbuf; reading_reply = 0; diff -Nru a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c --- a/drivers/macintosh/via-pmu.c Sun Mar 23 00:22:55 2003 +++ b/drivers/macintosh/via-pmu.c Sun Mar 23 00:22:55 2003 @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -343,10 +344,6 @@ } else pmu_kind = PMU_UNKNOWN; -#ifdef CONFIG_PMAC_PBOOK - if (pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,-1) >= 0) - can_sleep = 1; -#endif /* CONFIG_PMAC_PBOOK */ via = (volatile unsigned char *) ioremap(vias->addrs->address, 0x2000); out_8(&via[IER], IER_CLR | 0x7f); /* disable all intrs */ @@ -405,6 +402,8 @@ bright_req_3.complete = 1; #ifdef CONFIG_PMAC_PBOOK batt_req.complete = 1; + if (pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,-1) >= 0) + can_sleep = 1; #endif if (request_irq(vias->intrs[0].line, via_pmu_interrupt, 0, "VIA-PMU", @@ -457,12 +456,20 @@ #ifdef CONFIG_PMAC_PBOOK if (machine_is_compatible("AAPL,3400/2400") || - machine_is_compatible("AAPL,3500")) + machine_is_compatible("AAPL,3500")) { + int mb = pmac_call_feature(PMAC_FTR_GET_MB_INFO, + NULL, PMAC_MB_INFO_MODEL, 0); pmu_battery_count = 1; - else if (machine_is_compatible("AAPL,PowerBook1998") || - machine_is_compatible("PowerBook1,1")) + if (mb == PMAC_TYPE_COMET) + pmu_batteries[0].flags |= PMU_BATT_TYPE_COMET; + else + pmu_batteries[0].flags |= PMU_BATT_TYPE_HOOPER; + } else if (machine_is_compatible("AAPL,PowerBook1998") || + machine_is_compatible("PowerBook1,1")) { pmu_battery_count = 2; - else { + pmu_batteries[0].flags |= PMU_BATT_TYPE_SMART; + pmu_batteries[1].flags |= PMU_BATT_TYPE_SMART; + } else { struct device_node* prim = find_devices("power-mgt"); u32 *prim_info = NULL; if (prim) @@ -470,6 +477,9 @@ if (prim_info) { /* Other stuffs here yet unknown */ pmu_battery_count = (prim_info[6] >> 16) & 0xff; + pmu_batteries[0].flags |= PMU_BATT_TYPE_SMART; + if (pmu_battery_count > 1) + pmu_batteries[1].flags |= PMU_BATT_TYPE_SMART; } } #endif /* CONFIG_PMAC_PBOOK */ @@ -550,156 +560,30 @@ return 1; } -int +int __pmac pmu_get_model(void) { return pmu_kind; } -#ifdef CONFIG_PMAC_PBOOK - -/* - * WARNING ! This code probably needs some debugging... -- BenH. - */ -#ifdef NEW_OHARE_CODE -static void __pmac -done_battery_state_ohare(struct adb_request* req) +static inline void wakeup_decrementer(void) { - unsigned int bat_flags = 0; - int current = 0; - unsigned int capa, max, voltage, time; - int lrange[] = { 0, 275, 850, 1680, 2325, - 2765, 3160, 3500, 3830, 4115, - 4360, 4585, 4795, 4990, 5170, - 5340, 5510, 5710, 5930, 6150, - 6370, 6500 - }; - - if (req->reply[0] & 0x01) - pmu_power_flags |= PMU_PWR_AC_PRESENT; - else - pmu_power_flags &= ~PMU_PWR_AC_PRESENT; + set_dec(tb_ticks_per_jiffy); + /* No currently-supported powerbook has a 601, + * so use get_tbl, not native + */ + last_jiffy_stamp(0) = tb_last_stamp = get_tbl(); +} - if (req->reply[0] & 0x04) { - int vb, i, j, k, charge, pcharge; - bat_flags |= PMU_BATT_PRESENT; - vb = (req->reply[1] << 8) | req->reply[2]; - voltage = ((vb * 2650) + 726650)/100; - vb *= 100; - current = req->reply[5]; - if ((req->reply[0] & 0x01) == 0 && (current > 200)) - vb += (current - 200) * 15; - else if (req->reply[0] & 0x02) - vb = (vb - 2000); - i = (33000 - vb) / 10; - j = i - (i % 100); - k = j/100; - if (k <= 0) - charge = 0; - else if (k >= 21) - charge = 650000; - else - charge = (lrange[k + 1] - lrange[k]) * (i - j) + (lrange[k] * 100); - charge = (1000 - charge / 650) / 10; - if (req->reply[0] & 0x40) { - pcharge = (req->reply[6] << 8) + req->reply[7]; - if (pcharge > 6500) - pcharge = 6500; - pcharge *= 100; - pcharge = (1000 - pcharge / 650) / 10; - if (pcharge < charge) - charge = pcharge; - } - capa = charge; - max = 100; - time = (charge * 16440) / current; - current = -current; - - } else - capa = max = current = voltage = time = 0; - if (req->reply[0] & 0x02) - bat_flags |= PMU_BATT_CHARGING; +#ifdef CONFIG_PMAC_PBOOK - pmu_batteries[pmu_cur_battery].flags = bat_flags; - pmu_batteries[pmu_cur_battery].charge = capa; - pmu_batteries[pmu_cur_battery].max_charge = max; - pmu_batteries[pmu_cur_battery].current = current; - pmu_batteries[pmu_cur_battery].voltage = voltage; - pmu_batteries[pmu_cur_battery].time_remaining = time; -} -#else /* NEW_OHARE_CODE */ +/* This new version of the code for 2400/3400/3500 powerbooks + * is inspired from the implementation in gkrellm-pmu + */ static void __pmac done_battery_state_ohare(struct adb_request* req) { - unsigned int bat_flags = 0; - int current = 0; - unsigned int capa, max, voltage, time; - int lrange[] = { 0, 275, 850, 1680, 2325, - 2765, 3160, 3500, 3830, 4115, - 4360, 4585, 4795, 4990, 5170, - 5340, 5510, 5710, 5930, 6150, - 6370, 6500 - }; - - if (req->reply[0] & 0x01) - pmu_power_flags |= PMU_PWR_AC_PRESENT; - else - pmu_power_flags &= ~PMU_PWR_AC_PRESENT; - - if (req->reply[0] & 0x04) { - int vb, i, j, charge, pcharge; - bat_flags |= PMU_BATT_PRESENT; - vb = (req->reply[1] << 8) | req->reply[2]; - voltage = ((vb * 2650) + 726650)/100; - current = *((signed char *)&req->reply[5]); - if ((req->reply[0] & 0x01) == 0 && (current > 200)) - vb += (current - 200) * 15; - else if (req->reply[0] & 0x02) - vb = (vb - 10) * 100; - i = (33000 - vb) / 10; - j = i - (i % 100); - if (j <= 0) - charge = 0; - else if (j >= 21) - charge = 650000; - else - charge = (lrange[j + 1] - lrange[j]) * (i - j) + (lrange[j] * 100); - charge = (1000 - charge / 650) / 10; - if (req->reply[0] & 0x40) { - pcharge = (req->reply[6] << 8) + req->reply[7]; - if (pcharge > 6500) - pcharge = 6500; - pcharge *= 100; - pcharge = (1000 - pcharge / 650) / 10; - if (pcharge < charge) - charge = pcharge; - } - capa = charge; - max = 100; - time = (charge * 274) / current; - current = -current; - - } else - capa = max = current = voltage = time = 0; - - if ((req->reply[0] & 0x02) && (current > 0)) - bat_flags |= PMU_BATT_CHARGING; - if (req->reply[0] & 0x04) /* CHECK THIS ONE */ - bat_flags |= PMU_BATT_PRESENT; - - pmu_batteries[pmu_cur_battery].flags = bat_flags; - pmu_batteries[pmu_cur_battery].charge = capa; - pmu_batteries[pmu_cur_battery].max_charge = max; - pmu_batteries[pmu_cur_battery].current = current; - pmu_batteries[pmu_cur_battery].voltage = voltage; - pmu_batteries[pmu_cur_battery].time_remaining = time; -} -#endif /* NEW_OHARE_CODE */ - - static void __pmac -done_battery_state_comet(struct adb_request* req) -{ /* format: * [0] : flags * 0x01 : AC indicator @@ -718,57 +602,62 @@ * [6][7] : pcharge * --tkoba */ + unsigned int bat_flags = PMU_BATT_TYPE_HOOPER; + long pcharge, charge, vb, vmax, lmax; + long vmax_charging, vmax_charged; + long current, voltage, time, max; + int mb = pmac_call_feature(PMAC_FTR_GET_MB_INFO, + NULL, PMAC_MB_INFO_MODEL, 0); - unsigned int bat_flags = 0; - int current = 0; - unsigned int max = 100; - unsigned int charge, voltage, time; - int lrange[] = { 0, 600, 750, 900, 1000, 1080, - 1180, 1250, 1300, 1340, 1360, - 1390, 1420, 1440, 1470, 1490, - 1520, 1550, 1580, 1610, 1650, - 1700 - }; - if (req->reply[0] & 0x01) pmu_power_flags |= PMU_PWR_AC_PRESENT; else pmu_power_flags &= ~PMU_PWR_AC_PRESENT; + + if (mb == PMAC_TYPE_COMET) { + vmax_charged = 189; + vmax_charging = 213; + lmax = 6500; + } else { + vmax_charged = 330; + vmax_charging = 330; + lmax = 6500; + } + vmax = vmax_charged; - if (req->reply[0] & 0x04) { /* battery exist */ - int vb, i; + /* If battery installed */ + if (req->reply[0] & 0x04) { bat_flags |= PMU_BATT_PRESENT; + if (req->reply[0] & 0x02) + bat_flags |= PMU_BATT_CHARGING; vb = (req->reply[1] << 8) | req->reply[2]; - voltage = ((vb * 2650) + 726650)/100; - vb *= 10; + voltage = (vb * 265 + 72665) / 10; current = req->reply[5]; - if ((req->reply[0] & 0x01) == 0 && (current > 200)) - vb += ((current - 200) * 3); /* vb = 500<->1800 */ - else if (req->reply[0] & 0x02) - vb = ((vb - 800) * 1700/13)/100; /* in charging vb = 1300<->2130 */ - - if (req->reply[0] & 0x20) { /* full charged */ - charge = max; - } else { - if (lrange[21] < vb) - charge = max; - else { - if (vb < lrange[1]) - charge = 0; - else { - for (i=21; vb < lrange[i]; --i); - charge = (i * 100)/21; - } - } - if (charge > max) charge = max; + if ((req->reply[0] & 0x01) == 0) { + if (current > 200) + vb += ((current - 200) * 15)/100; + } else if (req->reply[0] & 0x02) { + vb = (vb * 97) / 100; + vmax = vmax_charging; + } + charge = (100 * vb) / vmax; + if (req->reply[0] & 0x40) { + pcharge = (req->reply[6] << 8) + req->reply[7]; + if (pcharge > lmax) + pcharge = lmax; + pcharge *= 100; + pcharge = 100 - pcharge / lmax; + if (pcharge < charge) + charge = pcharge; } - time = (charge * 72); + if (current > 0) + time = (charge * 16440) / current; + else + time = 0; + max = 100; current = -current; } else - max = current = voltage = time = 0; - - if (req->reply[0] & 0x02) - bat_flags |= PMU_BATT_CHARGING; + charge = max = current = voltage = time = 0; pmu_batteries[pmu_cur_battery].flags = bat_flags; pmu_batteries[pmu_cur_battery].charge = charge; @@ -800,7 +689,7 @@ * [8][9] : voltage */ - unsigned int bat_flags = 0; + unsigned int bat_flags = PMU_BATT_TYPE_SMART; int current; unsigned int capa, max, voltage; @@ -858,24 +747,17 @@ { if (!batt_req.complete) return; - if (pmu_kind == PMU_OHARE_BASED) { - int mb = pmac_call_feature(PMAC_FTR_GET_MB_INFO, - NULL, PMAC_MB_INFO_MODEL, 0); - - if (mb == PMAC_TYPE_COMET) - pmu_request(&batt_req, done_battery_state_comet, - 1, PMU_BATTERY_STATE); - else - pmu_request(&batt_req, done_battery_state_ohare, - 1, PMU_BATTERY_STATE); - } else + if (pmu_kind == PMU_OHARE_BASED) + pmu_request(&batt_req, done_battery_state_ohare, + 1, PMU_BATTERY_STATE); + else pmu_request(&batt_req, done_battery_state_smart, 2, PMU_SMART_BATTERY_STATE, pmu_cur_battery+1); } #endif /* CONFIG_PMAC_PBOOK */ -static int +static int __pmac proc_get_info(char *page, char **start, off_t off, int count, int *eof, void *data) { @@ -893,7 +775,7 @@ } #ifdef CONFIG_PMAC_PBOOK -static int +static int __pmac proc_get_batt(char *page, char **start, off_t off, int count, int *eof, void *data) { @@ -918,7 +800,7 @@ } #endif /* CONFIG_PMAC_PBOOK */ -static int +static int __pmac proc_read_options(char *page, char **start, off_t off, int count, int *eof, void *data) { @@ -932,7 +814,7 @@ return p - page; } -static int +static int __pmac proc_write_options(struct file *file, const char *buffer, unsigned long count, void *data) { @@ -972,7 +854,7 @@ #ifdef CONFIG_ADB /* Send an ADB command */ -static int __openfirmware +static int __pmac pmu_send_request(struct adb_request *req, int sync) { int i, ret; @@ -1052,7 +934,7 @@ } /* Enable/disable autopolling */ -static int __openfirmware +static int __pmac pmu_adb_autopoll(int devs) { struct adb_request req; @@ -1075,7 +957,7 @@ } /* Reset the ADB bus */ -static int __openfirmware +static int __pmac pmu_adb_reset_bus(void) { struct adb_request req; @@ -1137,7 +1019,7 @@ return pmu_queue_request(req); } -int __openfirmware +int __pmac pmu_queue_request(struct adb_request *req) { unsigned long flags; @@ -1229,7 +1111,7 @@ (*done)(req); } -static void __openfirmware +static void __pmac pmu_start() { struct adb_request *req; @@ -1342,7 +1224,7 @@ } /* Interrupt data could be the result data from an ADB cmd */ -static void __openfirmware +static void __pmac pmu_handle_data(unsigned char *data, int len, struct pt_regs *regs) { asleep = 0; @@ -1417,7 +1299,7 @@ } } -static struct adb_request* __openfirmware +static struct adb_request* __pmac pmu_sr_intr(struct pt_regs *regs) { struct adb_request *req; @@ -1511,7 +1393,7 @@ return NULL; } -static void __openfirmware +static void __pmac via_pmu_interrupt(int irq, void *arg, struct pt_regs *regs) { unsigned long flags; @@ -1561,10 +1443,10 @@ wait_for_ack(); send_byte(PMU_INT_ACK); adb_int_pending = 0; -no_free_slot: } else if (current_req) pmu_start(); } +no_free_slot: /* Mark the oldest buffer for flushing */ if (int_data_state[!int_data_last] == int_data_ready) { int_data_state[!int_data_last] = int_data_flush; @@ -1593,7 +1475,7 @@ } } -static void __openfirmware +static void __pmac gpio1_interrupt(int irq, void *arg, struct pt_regs *regs) { if ((in_8(gpio_reg + 0x9) & 0x02) == 0) { @@ -1603,7 +1485,7 @@ } #ifdef CONFIG_PMAC_BACKLIGHT -static int backlight_to_bright[] = { +static int backlight_to_bright[] __pmacdata = { 0x7f, 0x46, 0x42, 0x3e, 0x3a, 0x36, 0x32, 0x2e, 0x2a, 0x26, 0x22, 0x1e, 0x1a, 0x16, 0x12, 0x0e }; @@ -1649,7 +1531,7 @@ } #endif /* CONFIG_PMAC_BACKLIGHT */ -void __openfirmware +void __pmac pmu_enable_irled(int on) { struct adb_request req; @@ -1665,7 +1547,7 @@ pmu_poll(); } -void __openfirmware +void __pmac pmu_restart(void) { struct adb_request req; @@ -1688,7 +1570,7 @@ ; } -void __openfirmware +void __pmac pmu_shutdown(void) { struct adb_request req; @@ -1723,7 +1605,7 @@ static LIST_HEAD(sleep_notifiers); #ifdef CONFIG_PM -static int +static int __pmac generic_notify_sleep(struct pmu_sleep_notifier *self, int when) { switch (when) { @@ -1765,7 +1647,7 @@ } /* Sleep is broadcast last-to-first */ -static int +static int __pmac broadcast_sleep(int when, int fallback) { int ret = PBOOK_SLEEP_OK; @@ -1790,7 +1672,7 @@ } /* Wake is broadcast first-to-last */ -static int +static int __pmac broadcast_wake(void) { int ret = PBOOK_SLEEP_OK; @@ -1821,7 +1703,7 @@ } *pbook_pci_saves; static int pbook_npci_saves; -static void __openfirmware +static void __pmac pbook_alloc_pci_save(void) { int npci; @@ -1838,7 +1720,7 @@ pbook_npci_saves = npci; } -static void __openfirmware +static void __pmac pbook_free_pci_save(void) { if (pbook_pci_saves == NULL) @@ -1848,7 +1730,7 @@ pbook_npci_saves = 0; } -static void __openfirmware +static void __pmac pbook_pci_save(void) { struct pci_save *ps = pbook_pci_saves; @@ -1879,7 +1761,7 @@ * during boot, it will be in the pci dev list. If it's disabled at this point * (and it will probably be), then you can't access it's config space. */ -static void __openfirmware +static void __pmac pbook_pci_restore(void) { u16 cmd; @@ -1927,7 +1809,7 @@ #ifdef DEBUG_SLEEP /* N.B. This doesn't work on the 3400 */ -void +void __pmac pmu_blink(int n) { struct adb_request req; @@ -1966,8 +1848,10 @@ * Put the powerbook to sleep. */ -static u32 save_via[8]; -static void save_via_state(void) +static u32 save_via[8] __pmacdata; + +static void __pmac +save_via_state(void) { save_via[0] = in_8(&via[ANH]); save_via[1] = in_8(&via[DIRA]); @@ -1978,7 +1862,8 @@ save_via[6] = in_8(&via[T1CL]); save_via[7] = in_8(&via[T1CH]); } -static void restore_via_state(void) +static void __pmac +restore_via_state(void) { out_8(&via[ANH], save_via[0]); out_8(&via[DIRA], save_via[1]); @@ -1993,23 +1878,15 @@ out_8(&via[IER], IER_SET | SR_INT | CB1_INT); } -static inline void wakeup_decrementer(void) -{ - set_dec(tb_ticks_per_jiffy); - /* No currently-supported powerbook has a 601, - * so use get_tbl, not native - */ - last_jiffy_stamp(0) = tb_last_stamp = get_tbl(); -} - -extern int sys_sync(void); +extern long sys_sync(void); #define GRACKLE_PM (1<<7) #define GRACKLE_DOZE (1<<5) #define GRACKLE_NAP (1<<4) #define GRACKLE_SLEEP (1<<3) -int __openfirmware powerbook_sleep_G3(void) +int __pmac +powerbook_sleep_G3(void) { unsigned long save_l2cr; unsigned short pmcr1; @@ -2152,7 +2029,8 @@ return 0; } -int __openfirmware powerbook_sleep_Core99(void) +static int __pmac +powerbook_sleep_Core99(void) { unsigned long save_l2cr; unsigned long save_l3cr; @@ -2322,7 +2200,8 @@ #define PB3400_MEM_CTRL 0xf8000000 #define PB3400_MEM_CTRL_SLEEP 0x70 -int __openfirmware powerbook_sleep_3400(void) +static int __pmac +powerbook_sleep_3400(void) { int ret, i, x; unsigned int hid0; @@ -2463,9 +2342,10 @@ }; static LIST_HEAD(all_pmu_pvt); -static spinlock_t all_pvt_lock = SPIN_LOCK_UNLOCKED; +static spinlock_t all_pvt_lock __pmacdata = SPIN_LOCK_UNLOCKED; -static void pmu_pass_intr(unsigned char *data, int len) +static void __pmac +pmu_pass_intr(unsigned char *data, int len) { struct pmu_private *pp; struct list_head *list; @@ -2493,7 +2373,8 @@ spin_unlock_irqrestore(&all_pvt_lock, flags); } -static int __openfirmware pmu_open(struct inode *inode, struct file *file) +static int __pmac +pmu_open(struct inode *inode, struct file *file) { struct pmu_private *pp; unsigned long flags; @@ -2514,7 +2395,8 @@ return 0; } -static ssize_t __openfirmware pmu_read(struct file *file, char *buf, +static ssize_t __pmac +pmu_read(struct file *file, char *buf, size_t count, loff_t *ppos) { struct pmu_private *pp = file->private_data; @@ -2566,13 +2448,15 @@ return ret; } -static ssize_t __openfirmware pmu_write(struct file *file, const char *buf, +static ssize_t __pmac +pmu_write(struct file *file, const char *buf, size_t count, loff_t *ppos) { return 0; } -static unsigned int pmu_fpoll(struct file *filp, poll_table *wait) +static unsigned int __pmac +pmu_fpoll(struct file *filp, poll_table *wait) { struct pmu_private *pp = filp->private_data; unsigned int mask = 0; @@ -2588,7 +2472,8 @@ return mask; } -static int pmu_release(struct inode *inode, struct file *file) +static int __pmac +pmu_release(struct inode *inode, struct file *file) { struct pmu_private *pp = file->private_data; unsigned long flags; @@ -2613,7 +2498,8 @@ } /* Note: removed __openfirmware here since it causes link errors */ -static int pmu_ioctl(struct inode * inode, struct file *filp, +static int __pmac +pmu_ioctl(struct inode * inode, struct file *filp, u_int cmd, u_long arg) { struct pmu_private *pp = filp->private_data; @@ -2687,7 +2573,7 @@ return -EINVAL; } -static struct file_operations pmu_device_fops = { +static struct file_operations pmu_device_fops __pmacdata = { .read = pmu_read, .write = pmu_write, .poll = pmu_fpoll, @@ -2696,7 +2582,7 @@ .release = pmu_release, }; -static struct miscdevice pmu_device = { +static struct miscdevice pmu_device __pmacdata = { PMU_MINOR, "pmu", &pmu_device_fops }; @@ -2710,7 +2596,8 @@ #endif /* CONFIG_PMAC_PBOOK */ #ifdef DEBUG_SLEEP -static inline void polled_handshake(volatile unsigned char *via) +static inline void __pmac +polled_handshake(volatile unsigned char *via) { via[B] &= ~TREQ; eieio(); while ((via[B] & TACK) != 0) @@ -2720,14 +2607,16 @@ ; } -static inline void polled_send_byte(volatile unsigned char *via, int x) +static inline void __pmac +polled_send_byte(volatile unsigned char *via, int x) { via[ACR] |= SR_OUT | SR_EXT; eieio(); via[SR] = x; eieio(); polled_handshake(via); } -static inline int polled_recv_byte(volatile unsigned char *via) +static inline int __pmac +polled_recv_byte(volatile unsigned char *via) { int x; @@ -2738,7 +2627,7 @@ return x; } -int +int __pmac pmu_polled_request(struct adb_request *req) { unsigned long flags; diff -Nru a/drivers/md/dm-linear.c b/drivers/md/dm-linear.c --- a/drivers/md/dm-linear.c Sun Mar 23 00:22:53 2003 +++ b/drivers/md/dm-linear.c Sun Mar 23 00:22:53 2003 @@ -79,6 +79,7 @@ char *result, int maxlen) { struct linear_c *lc = (struct linear_c *) ti->private; + char b[BDEVNAME_SIZE]; switch (type) { case STATUSTYPE_INFO: @@ -87,7 +88,7 @@ case STATUSTYPE_TABLE: snprintf(result, maxlen, "%s " SECTOR_FORMAT, - bdevname(lc->dev->bdev), lc->start); + bdevname(lc->dev->bdev, b), lc->start); break; } return 0; diff -Nru a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c --- a/drivers/md/dm-stripe.c Sun Mar 23 00:22:53 2003 +++ b/drivers/md/dm-stripe.c Sun Mar 23 00:22:53 2003 @@ -209,6 +209,7 @@ struct stripe_c *sc = (struct stripe_c *) ti->private; int offset; int i; + char b[BDEVNAME_SIZE]; switch (type) { case STATUSTYPE_INFO: @@ -222,7 +223,7 @@ offset += snprintf(result + offset, maxlen - offset, " %s " SECTOR_FORMAT, - bdevname(sc->stripe[i].dev->bdev), + bdevname(sc->stripe[i].dev->bdev, b), sc->stripe[i].physical_start); } break; diff -Nru a/drivers/md/linear.c b/drivers/md/linear.c --- a/drivers/md/linear.c Sun Mar 23 00:22:52 2003 +++ b/drivers/md/linear.c Sun Mar 23 00:22:52 2003 @@ -197,8 +197,13 @@ if (unlikely(block >= (tmp_dev->size + tmp_dev->offset) || block < tmp_dev->offset)) { - printk ("linear_make_request: Block %llu out of bounds on dev %s size %ld offset %ld\n", - (unsigned long long)block, bdevname(tmp_dev->rdev->bdev), tmp_dev->size, tmp_dev->offset); + char b[BDEVNAME_SIZE]; + + printk ("linear_make_request: Block %llu out of bounds on " + "dev %s size %ld offset %ld\n", + (unsigned long long)block, + bdevname(tmp_dev->rdev->bdev, b), + tmp_dev->size, tmp_dev->offset); bio_io_error(bio, bio->bi_size); return 0; } diff -Nru a/drivers/md/md.c b/drivers/md/md.c --- a/drivers/md/md.c Sun Mar 23 00:22:51 2003 +++ b/drivers/md/md.c Sun Mar 23 00:22:51 2003 @@ -1735,7 +1735,6 @@ mddev->safemode_delay = (20 * HZ)/1000 +1; /* 20 msec delay */ mddev->in_sync = 1; - md_update_sb(mddev); set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); md_wakeup_thread(mddev->thread); set_capacity(disk, md_size[mdidx(mddev)]<<1); @@ -1763,7 +1762,6 @@ goto out; mddev->safemode = 0; - md_update_sb(mddev); mddev->ro = 0; set_disk_ro(disk, 0); @@ -3247,7 +3245,7 @@ { mddev_t *mddev2; unsigned int max_sectors, currspeed = 0, - j, window, err; + j, window; unsigned long mark[SYNC_MARKS]; unsigned long mark_cnt[SYNC_MARKS]; int last_mark,m; @@ -3283,7 +3281,6 @@ if (wait_event_interruptible(resync_wait, mddev2->curr_resync < mddev->curr_resync)) { flush_signals(current); - err = -EINTR; mddev_put(mddev2); goto skip; } @@ -3335,7 +3332,7 @@ sectors = mddev->pers->sync_request(mddev, j, currspeed < sysctl_speed_limit_min); if (sectors < 0) { - err = sectors; + set_bit(MD_RECOVERY_ERR, &mddev->recovery); goto out; } atomic_add(sectors, &mddev->recovery_active); @@ -3372,7 +3369,7 @@ */ printk(KERN_INFO "md: md_do_sync() got signal ... exiting\n"); flush_signals(current); - err = -EINTR; + set_bit(MD_RECOVERY_INTR, &mddev->recovery); goto out; } @@ -3398,7 +3395,6 @@ } } printk(KERN_INFO "md: md%d: sync done.\n",mdidx(mddev)); - err = 0; /* * this also signals 'finished resyncing' to md_stop */ @@ -3408,8 +3404,6 @@ /* tell personality that we are finished */ mddev->pers->sync_request(mddev, max_sectors, 1); - if (err) - set_bit(MD_RECOVERY_ERR, &mddev->recovery); if (!test_bit(MD_RECOVERY_ERR, &mddev->recovery) && mddev->curr_resync > 2 && mddev->curr_resync > mddev->recovery_cp) { diff -Nru a/drivers/md/raid1.c b/drivers/md/raid1.c --- a/drivers/md/raid1.c Sun Mar 23 00:22:53 2003 +++ b/drivers/md/raid1.c Sun Mar 23 00:22:53 2003 @@ -840,7 +840,8 @@ * we read from here, no need to write */ continue; - if (conf->mirrors[i].rdev->in_sync && mddev->in_sync) + if (conf->mirrors[i].rdev->in_sync && + r1_bio->sector + (bio->bi_size>>9) <= mddev->recovery_cp) /* * don't need to write this we are just rebuilding */ diff -Nru a/drivers/media/dvb/dvb-core/Kconfig b/drivers/media/dvb/dvb-core/Kconfig --- a/drivers/media/dvb/dvb-core/Kconfig Sun Mar 23 00:22:55 2003 +++ b/drivers/media/dvb/dvb-core/Kconfig Sun Mar 23 00:22:55 2003 @@ -5,13 +5,3 @@ DVB core utility functions for device handling, software fallbacks etc. Say Y when you have a DVB card and want to use it. If unsure say N. - -config DVB_DEVFS_ONLY - bool "devfs only" - depends on DVB_CORE=y && DEVFS_FS - help - Drop support for old major/minor device scheme and support only devfs - systems. This saves some code. - - If unsure say N. - diff -Nru a/drivers/media/dvb/dvb-core/dvb_demux.c b/drivers/media/dvb/dvb-core/dvb_demux.c --- a/drivers/media/dvb/dvb-core/dvb_demux.c Sun Mar 23 00:22:51 2003 +++ b/drivers/media/dvb/dvb-core/dvb_demux.c Sun Mar 23 00:22:51 2003 @@ -221,7 +221,7 @@ return 0; neq|=f->maskandnotmode[i]&xor; } - if (f->doneq & !neq) + if (f->doneq && !neq) return 0; return dvbdmxfeed->cb.sec(dvbdmxfeed->secbuf, dvbdmxfeed->seclen, diff -Nru a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c --- a/drivers/media/dvb/dvb-core/dvbdev.c Sun Mar 23 00:22:51 2003 +++ b/drivers/media/dvb/dvb-core/dvbdev.c Sun Mar 23 00:22:51 2003 @@ -21,8 +21,6 @@ * */ -/*#define CONFIG_DVB_DEVFS_ONLY 1*/ - #include #include #include @@ -56,17 +54,8 @@ }; -#ifdef CONFIG_DVB_DEVFS_ONLY - - #define DVB_MAX_IDS ~0 - #define nums2minor(num,type,id) 0 - #define DVB_DEVFS_FLAGS (DEVFS_FL_DEFAULT|DEVFS_FL_AUTO_DEVNUM) - -#else - - #define DVB_MAX_IDS 4 - #define nums2minor(num,type,id) ((num << 6) | (id << 4) | type) - #define DVB_DEVFS_FLAGS (DEVFS_FL_DEFAULT) +#define DVB_MAX_IDS 4 +#define nums2minor(num,type,id) ((num << 6) | (id << 4) | type) static @@ -234,8 +223,7 @@ sprintf(name, "%s%d", dnames[type], id); dvbdev->devfs_handle = devfs_register(adap->devfs_handle, name, - DVB_DEVFS_FLAGS, - DVB_MAJOR, + 0, DVB_MAJOR, nums2minor(adap->num, type, id), S_IFCHR | S_IRUSR | S_IWUSR, dvbdev->fops, dvbdev); diff -Nru a/drivers/media/radio/miropcm20-rds-core.c b/drivers/media/radio/miropcm20-rds-core.c --- a/drivers/media/radio/miropcm20-rds-core.c Sun Mar 23 00:22:55 2003 +++ b/drivers/media/radio/miropcm20-rds-core.c Sun Mar 23 00:22:55 2003 @@ -13,8 +13,6 @@ * RDS support for MiroSound PCM20 radio */ -#define _NO_VERSION_ - #include #include #include diff -Nru a/drivers/media/video/bttv-cards.c b/drivers/media/video/bttv-cards.c --- a/drivers/media/video/bttv-cards.c Sun Mar 23 00:22:53 2003 +++ b/drivers/media/video/bttv-cards.c Sun Mar 23 00:22:53 2003 @@ -24,8 +24,6 @@ */ -#define __NO_VERSION__ 1 - #include #include #include diff -Nru a/drivers/media/video/bttv-if.c b/drivers/media/video/bttv-if.c --- a/drivers/media/video/bttv-if.c Sun Mar 23 00:22:50 2003 +++ b/drivers/media/video/bttv-if.c Sun Mar 23 00:22:50 2003 @@ -25,8 +25,6 @@ */ -#define __NO_VERSION__ 1 - #include #include #include diff -Nru a/drivers/media/video/bttv-risc.c b/drivers/media/video/bttv-risc.c --- a/drivers/media/video/bttv-risc.c Sun Mar 23 00:22:53 2003 +++ b/drivers/media/video/bttv-risc.c Sun Mar 23 00:22:53 2003 @@ -23,8 +23,6 @@ */ -#define __NO_VERSION__ 1 - #include #include #include diff -Nru a/drivers/media/video/cpia.c b/drivers/media/video/cpia.c --- a/drivers/media/video/cpia.c Sun Mar 23 00:22:54 2003 +++ b/drivers/media/video/cpia.c Sun Mar 23 00:22:54 2003 @@ -23,7 +23,9 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* #define _CPIA_DEBUG_ define for verbose debug output */ +/* define _CPIA_DEBUG_ for verbose debug output (see cpia.h) */ +/* #define _CPIA_DEBUG_ 1 */ + #include #include @@ -1796,7 +1798,7 @@ retval = cam->ops->transferCmd(cam->lowlevel_data, cmd, data); if (retval) - LOG("%x - failed\n", command); + DBG("%x - failed\n", command); return retval; } @@ -2174,7 +2176,7 @@ } if (ll == 1) { if (*ibuf != EOL) { - LOG("EOL not found giving up after %d/%d" + DBG("EOL not found giving up after %d/%d" " bytes\n", origsize-size, origsize); return -1; } @@ -3158,7 +3160,8 @@ static void put_cam(struct cpia_camera_ops* ops) { - module_put(ops->owner); + if (ops->owner) + module_put(ops->owner); } /* ------------------------- V4L interface --------------------- */ @@ -3173,16 +3176,15 @@ return -ENODEV; } + if (cam->open_count > 0) { + DBG("Camera already open\n"); + return -EBUSY; + } + if (!try_module_get(cam->ops->owner)) return -ENODEV; down(&cam->busy_lock); - err = -EBUSY; - if (cam->open_count > 0) { - DBG("Camera already open\n"); - goto oops; - } - err = -ENOMEM; if (!cam->raw_image) { cam->raw_image = rvmalloc(CPIA_MAX_IMAGE_SIZE); @@ -3206,10 +3208,11 @@ cam->ops->close(cam->lowlevel_data); goto oops; } - - if(signal_pending(current)) - return -EINTR; + err = -EINTR; + if(signal_pending(current)) + goto oops; + /* Set ownership of /proc/cpia/videoX to current user */ if(cam->proc_entry) cam->proc_entry->uid = current->uid; @@ -3451,6 +3454,14 @@ cam->params.colourParams.contrast = 80; } + /* Adjust flicker control if necessary */ + if(cam->params.flickerControl.allowableOverExposure < 0) + cam->params.flickerControl.allowableOverExposure = + -find_over_exposure(cam->params.colourParams.brightness); + if(cam->params.flickerControl.flickerMode != 0) + cam->cmd_queue |= COMMAND_SETFLICKERCTRL; + + /* queue command to update camera */ cam->cmd_queue |= COMMAND_SETCOLOURPARAMS; up(&cam->param_lock); @@ -3600,7 +3611,7 @@ { int *frame = arg; - //DBG("VIDIOCSYNC: %d\n", frame); + //DBG("VIDIOCSYNC: %d\n", *frame); if (*frame<0 || *frame >= FRAME_NUM) { retval = -EINVAL; @@ -3628,52 +3639,53 @@ } case VIDIOCGCAPTURE: + { + struct video_capture *vc = arg; + DBG("VIDIOCGCAPTURE\n"); - if (copy_to_user(arg, &cam->vc, sizeof(struct video_capture))) - retval = -EFAULT; + + *vc = cam->vc; + break; + } case VIDIOCSCAPTURE: { - struct video_capture vc; + struct video_capture *vc = arg; DBG("VIDIOCSCAPTURE\n"); - if (copy_from_user(&vc, arg, sizeof(vc))) { - retval = -EFAULT; - break; - } - if (vc.decimation != 0) { /* How should this be used? */ + if (vc->decimation != 0) { /* How should this be used? */ retval = -EINVAL; break; } - if (vc.flags != 0) { /* Even/odd grab not supported */ + if (vc->flags != 0) { /* Even/odd grab not supported */ retval = -EINVAL; break; } /* Clip to the resolution we can set for the ROI (every 8 columns and 4 rows) */ - vc.x = vc.x & ~(__u32)7; - vc.y = vc.y & ~(__u32)3; - vc.width = vc.width & ~(__u32)7; - vc.height = vc.height & ~(__u32)3; - - if(vc.width == 0 || vc.height == 0 || - vc.x + vc.width > cam->vw.width || - vc.y + vc.height > cam->vw.height) { + vc->x = vc->x & ~(__u32)7; + vc->y = vc->y & ~(__u32)3; + vc->width = vc->width & ~(__u32)7; + vc->height = vc->height & ~(__u32)3; + + if(vc->width == 0 || vc->height == 0 || + vc->x + vc->width > cam->vw.width || + vc->y + vc->height > cam->vw.height) { retval = -EINVAL; break; } - DBG("%d,%d/%dx%d\n", vc.x,vc.y,vc.width, vc.height); + DBG("%d,%d/%dx%d\n", vc->x,vc->y,vc->width, vc->height); down(&cam->param_lock); - cam->vc.x = vc.x; - cam->vc.y = vc.y; - cam->vc.width = vc.width; - cam->vc.height = vc.height; + cam->vc.x = vc->x; + cam->vc.y = vc->y; + cam->vc.width = vc->width; + cam->vc.height = vc->height; set_vw_size(cam); cam->cmd_queue |= COMMAND_SETFORMAT; @@ -3688,16 +3700,20 @@ case VIDIOCGUNIT: { - struct video_unit vu; - vu.video = cam->vdev.minor; - vu.vbi = VIDEO_NO_UNIT; - vu.radio = VIDEO_NO_UNIT; - vu.audio = VIDEO_NO_UNIT; - vu.teletext = VIDEO_NO_UNIT; + struct video_unit *vu = arg; + + DBG("VIDIOCGUNIT\n"); + + vu->video = cam->vdev.minor; + vu->vbi = VIDEO_NO_UNIT; + vu->radio = VIDEO_NO_UNIT; + vu->audio = VIDEO_NO_UNIT; + vu->teletext = VIDEO_NO_UNIT; + break; } - + /* pointless to implement overlay with this camera */ case VIDIOCCAPTURE: case VIDIOCGFBUF: @@ -3728,12 +3744,13 @@ return video_usercopy(inode, file, cmd, arg, cpia_do_ioctl); } + /* FIXME */ static int cpia_mmap(struct file *file, struct vm_area_struct *vma) { struct video_device *dev = file->private_data; unsigned long start = vma->vm_start; - unsigned long size = vma->vm_end-vma->vm_start; + unsigned long size = vma->vm_end - vma->vm_start; unsigned long page, pos; struct cam_data *cam = dev->priv; int retval; @@ -3956,9 +3973,6 @@ printk(KERN_DEBUG "video_register_device failed\n"); return NULL; } -#ifdef CONFIG_PROC_FS - create_proc_cpia_cam(camera); -#endif /* get version information from camera: open/reset/close */ @@ -3975,6 +3989,10 @@ /* close cpia */ camera->ops->close(camera->lowlevel_data); +#ifdef CONFIG_PROC_FS + create_proc_cpia_cam(camera); +#endif + printk(KERN_INFO " CPiA Version: %d.%02d (%d.%d)\n", camera->params.version.firmwareVersion, camera->params.version.firmwareRevision, @@ -3997,6 +4015,7 @@ DBG("unregistering video\n"); video_unregister_device(&cam->vdev); if (cam->open_count) { + put_cam(cam->ops); DBG("camera open -- setting ops to NULL\n"); cam->ops = NULL; } @@ -4019,9 +4038,6 @@ proc_cpia_create(); #endif -#ifdef CONFIG_VIDEO_CPIA_PP - cpia_pp_init(); -#endif #ifdef CONFIG_KMOD #ifdef CONFIG_VIDEO_CPIA_PP_MODULE request_module("cpia_pp"); @@ -4031,6 +4047,10 @@ request_module("cpia_usb"); #endif #endif /* CONFIG_KMOD */ + +#ifdef CONFIG_VIDEO_CPIA_PP + cpia_pp_init(); +#endif #ifdef CONFIG_VIDEO_CPIA_USB cpia_usb_init(); #endif diff -Nru a/drivers/media/video/cpia.h b/drivers/media/video/cpia.h --- a/drivers/media/video/cpia.h Sun Mar 23 00:22:55 2003 +++ b/drivers/media/video/cpia.h Sun Mar 23 00:22:55 2003 @@ -27,12 +27,16 @@ */ #define CPIA_MAJ_VER 1 -#define CPIA_MIN_VER 2 -#define CPIA_PATCH_VER 2 +#define CPIA_MIN_VER 2 +#define CPIA_PATCH_VER 3 -#define CPIA_PP_MAJ_VER 1 -#define CPIA_PP_MIN_VER 2 -#define CPIA_PP_PATCH_VER 2 +#define CPIA_PP_MAJ_VER CPIA_MAJ_VER +#define CPIA_PP_MIN_VER CPIA_MIN_VER +#define CPIA_PP_PATCH_VER CPIA_PATCH_VER + +#define CPIA_USB_MAJ_VER CPIA_MAJ_VER +#define CPIA_USB_MIN_VER CPIA_MIN_VER +#define CPIA_USB_PATCH_VER CPIA_PATCH_VER #define CPIA_MAX_FRAME_SIZE_UNALIGNED (352 * 288 * 4) /* CIF at RGB32 */ #define CPIA_MAX_FRAME_SIZE ((CPIA_MAX_FRAME_SIZE_UNALIGNED + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1)) /* align above to PAGE_SIZE */ diff -Nru a/drivers/media/video/cpia_pp.c b/drivers/media/video/cpia_pp.c --- a/drivers/media/video/cpia_pp.c Sun Mar 23 00:22:49 2003 +++ b/drivers/media/video/cpia_pp.c Sun Mar 23 00:22:49 2003 @@ -22,6 +22,9 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +/* define _CPIA_DEBUG_ for verbose debug output (see cpia.h) */ +/* #define _CPIA_DEBUG_ 1 */ + #include #include @@ -34,6 +37,7 @@ #include #include #include +#include #include @@ -49,68 +53,10 @@ static int cpia_pp_streamRead(void *privdata, u8 *buffer, int noblock); static int cpia_pp_close(void *privdata); -#define ABOUT "Parallel port driver for Vision CPiA based cameras" -/* IEEE 1284 Compatiblity Mode signal names */ -#define nStrobe PARPORT_CONTROL_STROBE /* inverted */ -#define nAutoFd PARPORT_CONTROL_AUTOFD /* inverted */ -#define nInit PARPORT_CONTROL_INIT -#define nSelectIn PARPORT_CONTROL_SELECT -#define IntrEnable PARPORT_CONTROL_INTEN /* normally zero for no IRQ */ -#define DirBit PARPORT_CONTROL_DIRECTION /* 0 = Forward, 1 = Reverse */ - -#define nFault PARPORT_STATUS_ERROR -#define Select PARPORT_STATUS_SELECT -#define PError PARPORT_STATUS_PAPEROUT -#define nAck PARPORT_STATUS_ACK -#define Busy PARPORT_STATUS_BUSY /* inverted */ - -/* some more */ -#define HostClk nStrobe -#define HostAck nAutoFd -#define nReverseRequest nInit -#define Active_1284 nSelectIn -#define nPeriphRequest nFault -#define XFlag Select -#define nAckReverse PError -#define PeriphClk nAck -#define PeriphAck Busy - -/* these can be used to correct for the inversion on some bits */ -#define STATUS_INVERSION_MASK (Busy) -#define CONTROL_INVERSION_MASK (nStrobe|nAutoFd|nSelectIn) - -#define ECR_empty 0x01 -#define ECR_full 0x02 -#define ECR_serviceIntr 0x04 -#define ECR_dmaEn 0x08 -#define ECR_nErrIntrEn 0x10 - -#define ECR_mode_mask 0xE0 -#define ECR_SPP_mode 0x00 -#define ECR_PS2_mode 0x20 -#define ECR_FIFO_mode 0x40 -#define ECR_ECP_mode 0x60 - -#define ECP_FIFO_SIZE 16 -#define DMA_BUFFER_SIZE PAGE_SIZE - /* for 16bit DMA make sure DMA_BUFFER_SIZE is 16 bit aligned */ -#define PARPORT_CHUNK_SIZE PAGE_SIZE/* >=2.3.x */ - /* we read this many bytes at once */ - -#define GetECRMasked(port,mask) (parport_read_econtrol(port) & (mask)) -#define GetStatus(port) ((parport_read_status(port)^STATUS_INVERSION_MASK)&(0xf8)) -#define SetStatus(port,val) parport_write_status(port,(val)^STATUS_INVERSION_MASK) -#define GetControl(port) ((parport_read_control(port)^CONTROL_INVERSION_MASK)&(0x3f)) -#define SetControl(port,val) parport_write_control(port,(val)^CONTROL_INVERSION_MASK) - -#define GetStatusMasked(port,mask) (GetStatus(port) & (mask)) -#define GetControlMasked(port,mask) (GetControl(port) & (mask)) -#define SetControlMasked(port,mask) SetControl(port,GetControl(port) | (mask)); -#define ClearControlMasked(port,mask) SetControl(port,GetControl(port)&~(mask)); -#define FrobControlBit(port,mask,value) SetControl(port,(GetControl(port)&~(mask))|((value)&(mask))); +#define ABOUT "Parallel port driver for Vision CPiA based cameras" -#define PACKET_LENGTH 8 +#define PACKET_LENGTH 8 /* Magic numbers for defining port-device mappings */ #define PPCPIA_PARPORT_UNSPEC -4 @@ -162,30 +108,7 @@ }; static LIST_HEAD(cam_list); -static spinlock_t cam_list_lock_pp = SPIN_LOCK_UNLOCKED; - -#ifdef _CPIA_DEBUG_ -#define DEB_PORT(port) { \ -u8 controll = GetControl(port); \ -u8 statusss = GetStatus(port); \ -DBG("nsel %c per %c naut %c nstrob %c nak %c busy %c nfaul %c sel %c init %c dir %c\n",\ -((controll & nSelectIn) ? 'U' : 'D'), \ -((statusss & PError) ? 'U' : 'D'), \ -((controll & nAutoFd) ? 'U' : 'D'), \ -((controll & nStrobe) ? 'U' : 'D'), \ -((statusss & nAck) ? 'U' : 'D'), \ -((statusss & Busy) ? 'U' : 'D'), \ -((statusss & nFault) ? 'U' : 'D'), \ -((statusss & Select) ? 'U' : 'D'), \ -((controll & nInit) ? 'U' : 'D'), \ -((controll & DirBit) ? 'R' : 'F') \ -); } -#else -#define DEB_PORT(port) {} -#endif - -#define WHILE_OUT_TIMEOUT (HZ/10) -#define DMA_TIMEOUT 10*HZ +static spinlock_t cam_list_lock_pp; /* FIXME */ static void cpia_parport_enable_irq( struct parport *port ) { @@ -200,6 +123,205 @@ return; } +/* Special CPiA PPC modes: These are invoked by using the 1284 Extensibility + * Link Flag during negotiation */ +#define UPLOAD_FLAG 0x08 +#define NIBBLE_TRANSFER 0x01 +#define ECP_TRANSFER 0x03 + +#define PARPORT_CHUNK_SIZE PAGE_SIZE + + +/**************************************************************************** + * + * CPiA-specific low-level parport functions for nibble uploads + * + ***************************************************************************/ +/* CPiA nonstandard "Nibble" mode (no nDataAvail signal after each byte). */ +/* The standard kernel parport_ieee1284_read_nibble() fails with the CPiA... */ + +static size_t cpia_read_nibble (struct parport *port, + void *buffer, size_t len, + int flags) +{ + /* adapted verbatim, with one change, from + parport_ieee1284_read_nibble() in drivers/parport/ieee1284-ops.c */ + + unsigned char *buf = buffer; + int i; + unsigned char byte = 0; + + len *= 2; /* in nibbles */ + for (i=0; i < len; i++) { + unsigned char nibble; + + /* The CPiA firmware suppresses the use of nDataAvail (nFault LO) + * after every second nibble to signal that more + * data is available. (the total number of Bytes that + * should be sent is known; if too few are received, an error + * will be recorded after a timeout). + * This is incompatible with parport_ieee1284_read_nibble(), + * which expects to find nFault LO after every second nibble. + */ + + /* Solution: modify cpia_read_nibble to only check for + * nDataAvail before the first nibble is sent. + */ + + /* Does the error line indicate end of data? */ + if (((i /*& 1*/) == 0) && + (parport_read_status(port) & PARPORT_STATUS_ERROR)) { + port->physport->ieee1284.phase = IEEE1284_PH_HBUSY_DNA; + DBG("%s: No more nibble data (%d bytes)\n", + port->name, i/2); + + /* Go to reverse idle phase. */ + parport_frob_control (port, + PARPORT_CONTROL_AUTOFD, + PARPORT_CONTROL_AUTOFD); + port->physport->ieee1284.phase = IEEE1284_PH_REV_IDLE; + break; + } + + /* Event 7: Set nAutoFd low. */ + parport_frob_control (port, + PARPORT_CONTROL_AUTOFD, + PARPORT_CONTROL_AUTOFD); + + /* Event 9: nAck goes low. */ + port->ieee1284.phase = IEEE1284_PH_REV_DATA; + if (parport_wait_peripheral (port, + PARPORT_STATUS_ACK, 0)) { + /* Timeout -- no more data? */ + DBG("%s: Nibble timeout at event 9 (%d bytes)\n", + port->name, i/2); + parport_frob_control (port, PARPORT_CONTROL_AUTOFD, 0); + break; + } + + + /* Read a nibble. */ + nibble = parport_read_status (port) >> 3; + nibble &= ~8; + if ((nibble & 0x10) == 0) + nibble |= 8; + nibble &= 0xf; + + /* Event 10: Set nAutoFd high. */ + parport_frob_control (port, PARPORT_CONTROL_AUTOFD, 0); + + /* Event 11: nAck goes high. */ + if (parport_wait_peripheral (port, + PARPORT_STATUS_ACK, + PARPORT_STATUS_ACK)) { + /* Timeout -- no more data? */ + DBG("%s: Nibble timeout at event 11\n", + port->name); + break; + } + + if (i & 1) { + /* Second nibble */ + byte |= nibble << 4; + *buf++ = byte; + } else + byte = nibble; + } + + i /= 2; /* i is now in bytes */ + + if (i == len) { + /* Read the last nibble without checking data avail. */ + port = port->physport; + if (parport_read_status (port) & PARPORT_STATUS_ERROR) + port->ieee1284.phase = IEEE1284_PH_HBUSY_DNA; + else + port->ieee1284.phase = IEEE1284_PH_HBUSY_DAVAIL; + } + + return i; +} + +/* CPiA nonstandard "Nibble Stream" mode (2 nibbles per cycle, instead of 1) + * (See CPiA Data sheet p. 31) + * + * "Nibble Stream" mode used by CPiA for uploads to non-ECP ports is a + * nonstandard variant of nibble mode which allows the same (mediocre) + * data flow of 8 bits per cycle as software-enabled ECP by TRISTATE-capable + * parallel ports, but works also for non-TRISTATE-capable ports. + * (Standard nibble mode only send 4 bits per cycle) + * + */ + +static size_t cpia_read_nibble_stream(struct parport *port, + void *buffer, size_t len, + int flags) +{ + int i; + unsigned char *buf = buffer; + int endseen = 0; + + for (i=0; i < len; i++) { + unsigned char nibble[2], byte = 0; + int j; + + /* Image Data is complete when 4 consecutive EOI bytes (0xff) are seen */ + if (endseen > 3 ) + break; + + /* Event 7: Set nAutoFd low. */ + parport_frob_control (port, + PARPORT_CONTROL_AUTOFD, + PARPORT_CONTROL_AUTOFD); + + /* Event 9: nAck goes low. */ + port->ieee1284.phase = IEEE1284_PH_REV_DATA; + if (parport_wait_peripheral (port, + PARPORT_STATUS_ACK, 0)) { + /* Timeout -- no more data? */ + DBG("%s: Nibble timeout at event 9 (%d bytes)\n", + port->name, i/2); + parport_frob_control (port, PARPORT_CONTROL_AUTOFD, 0); + break; + } + + /* Read lower nibble */ + nibble[0] = parport_read_status (port) >>3; + + /* Event 10: Set nAutoFd high. */ + parport_frob_control (port, PARPORT_CONTROL_AUTOFD, 0); + + /* Event 11: nAck goes high. */ + if (parport_wait_peripheral (port, + PARPORT_STATUS_ACK, + PARPORT_STATUS_ACK)) { + /* Timeout -- no more data? */ + DBG("%s: Nibble timeout at event 11\n", + port->name); + break; + } + + /* Read upper nibble */ + nibble[1] = parport_read_status (port) >>3; + + /* reassemble the byte */ + for (j = 0; j < 2 ; j++ ) { + nibble[j] &= ~8; + if ((nibble[j] & 0x10) == 0) + nibble[j] |= 8; + nibble[j] &= 0xf; + } + byte = (nibble[0] |(nibble[1] << 4)); + *buf++ = byte; + + if(byte == EOI) + endseen++; + else + endseen = 0; + } + return i; +} + /**************************************************************************** * * EndTransferMode @@ -219,20 +341,25 @@ { int retry; - /* After some commands the camera needs extra time before - * it will respond again, so we try up to 3 times */ - for(retry=0; retry<3; ++retry) { + /* The CPiA uses ECP protocol for Downloads from the Host to the camera. + * This will be software-emulated if ECP hardware is not present + */ + + /* the usual camera maximum response time is 10ms, but after receiving + * some commands, it needs up to 40ms. (Data Sheet p. 32)*/ + + for(retry = 0; retry < 4; ++retry) { if(!parport_negotiate(cam->port, IEEE1284_MODE_ECP)) { break; } + mdelay(10); } - if(retry == 3) { - DBG("Unable to negotiate ECP mode\n"); + if(retry == 4) { + DBG("Unable to negotiate IEEE1284 ECP Download mode\n"); return -1; } return 0; } - /**************************************************************************** * * ReverseSetup @@ -241,24 +368,35 @@ static int ReverseSetup(struct pp_cam_entry *cam, int extensibility) { int retry; - int mode = IEEE1284_MODE_ECP; - if(extensibility) mode = 8|3|IEEE1284_EXT_LINK; + int upload_mode, mode = IEEE1284_MODE_ECP; + int transfer_mode = ECP_TRANSFER; + + if (!(cam->port->modes & PARPORT_MODE_ECP) && + !(cam->port->modes & PARPORT_MODE_TRISTATE)) { + mode = IEEE1284_MODE_NIBBLE; + transfer_mode = NIBBLE_TRANSFER; + } - /* After some commands the camera needs extra time before - * it will respond again, so we try up to 3 times */ - for(retry=0; retry<3; ++retry) { + upload_mode = mode; + if(extensibility) mode = UPLOAD_FLAG|transfer_mode|IEEE1284_EXT_LINK; + + /* the usual camera maximum response time is 10ms, but after + * receiving some commands, it needs up to 40ms. */ + + for(retry = 0; retry < 4; ++retry) { if(!parport_negotiate(cam->port, mode)) { break; } + mdelay(10); } - if(retry == 3) { + if(retry == 4) { if(extensibility) - DBG("Unable to negotiate extensibility mode\n"); + DBG("Unable to negotiate upload extensibility mode\n"); else - DBG("Unable to negotiate ECP mode\n"); + DBG("Unable to negotiate upload mode\n"); return -1; } - if(extensibility) cam->port->ieee1284.mode = IEEE1284_MODE_ECP; + if(extensibility) cam->port->ieee1284.mode = upload_mode; return 0; } @@ -296,14 +434,21 @@ static int ReadPacket(struct pp_cam_entry *cam, u8 *packet, size_t size) { int retval=0; + if (packet == NULL) { return -EINVAL; } if (ReverseSetup(cam, 0)) { return -EIO; } - if(parport_read(cam->port, packet, size) != size) { - retval = -EIO; + + /* support for CPiA variant nibble reads */ + if(cam->port->ieee1284.mode == IEEE1284_MODE_NIBBLE) { + if(cpia_read_nibble(cam->port, packet, size, 0) != size) + retval = -EIO; + } else { + if(parport_read(cam->port, packet, size) != size) + retval = -EIO; } EndTransferMode(cam); return retval; @@ -347,11 +492,29 @@ * cpia_pp_streamRead * ***************************************************************************/ +static int cpia_pp_read(struct parport *port, u8 *buffer, int len) +{ + int bytes_read; + + /* support for CPiA variant "nibble stream" reads */ + if(port->ieee1284.mode == IEEE1284_MODE_NIBBLE) + bytes_read = cpia_read_nibble_stream(port,buffer,len,0); + else { + int new_bytes; + for(bytes_read=0; bytes_readport, buffer, CPIA_MAX_IMAGE_SIZE ); - - EndTransferMode(cam); - DBG("read %d bytes\n", read_bytes); - if( read_bytes<0) return -EIO; endseen = 0; - for( i=0; i3 ) { - cam->image_complete=1; - DBG("endseen at %d bytes\n", i); - } + block_size = PARPORT_CHUNK_SIZE; + while( !cam->image_complete ) { + cond_resched(); + + new_bytes = cpia_pp_read(cam->port, buffer, block_size ); + if( new_bytes <= 0 ) { + break; + } + i=-1; + while(++iimage_complete=1; + break; + } + if( CPIA_MAX_IMAGE_SIZE-read_bytes <= PARPORT_CHUNK_SIZE ) { + block_size=CPIA_MAX_IMAGE_SIZE-read_bytes; + } + } + EndTransferMode(cam); return cam->image_complete ? read_bytes : -EIO; } - /**************************************************************************** * * cpia_pp_transferCmd @@ -530,9 +702,8 @@ struct pp_cam_entry *cam; struct cam_data *cpia; - if (!(port->modes & PARPORT_MODE_ECP) && - !(port->modes & PARPORT_MODE_TRISTATE)) { - LOG("port is not ECP capable\n"); + if (!(port->modes & PARPORT_MODE_PCSPP)) { + LOG("port is not supported by CPiA driver\n"); return -ENXIO; } @@ -575,29 +746,33 @@ static void cpia_pp_detach (struct parport *port) { struct list_head *tmp; - struct cam_data *cpia; + struct cam_data *cpia = NULL; struct pp_cam_entry *cam; spin_lock( &cam_list_lock_pp ); list_for_each (tmp, &cam_list) { cpia = list_entry(tmp, struct cam_data, cam_data_list); - cam = cpia->lowlevel_data; + cam = (struct pp_cam_entry *) cpia->lowlevel_data; if (cam && cam->port->number == port->number) { list_del(&cpia->cam_data_list); - cpia_unregister_camera(cpia); - - if(cam->open_count > 0) { - cpia_pp_close(cam); - } - - parport_unregister_device(cam->pdev); - - kfree(cam); - cpia->lowlevel_data = NULL; break; } + cpia = NULL; } spin_unlock( &cam_list_lock_pp ); + + if (!cpia) { + DBG("cpia_pp_detach failed to find cam_data in cam_list\n"); + return; + } + + cam = (struct pp_cam_entry *) cpia->lowlevel_data; + cpia_unregister_camera(cpia); + if(cam->open_count > 0) + cpia_pp_close(cam); + parport_unregister_device(cam->pdev); + cpia->lowlevel_data = NULL; + kfree(cam); } static void cpia_pp_attach (struct parport *port) @@ -645,11 +820,12 @@ return 0; } + spin_lock_init( &cam_list_lock_pp ); + if (parport_register_driver (&cpia_pp_driver)) { LOG ("unable to register with parport\n"); return -EIO; } - return 0; } diff -Nru a/drivers/media/video/cpia_usb.c b/drivers/media/video/cpia_usb.c --- a/drivers/media/video/cpia_usb.c Sun Mar 23 00:22:49 2003 +++ b/drivers/media/video/cpia_usb.c Sun Mar 23 00:22:49 2003 @@ -21,11 +21,13 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +/* define _CPIA_DEBUG_ for verbose debug output (see cpia.h) */ +/* #define _CPIA_DEBUG_ 1 */ + #include #include #include #include -#include #include #include #include @@ -105,7 +107,7 @@ }; static LIST_HEAD(cam_list); -static spinlock_t cam_list_lock_usb = SPIN_LOCK_UNLOCKED; +static spinlock_t cam_list_lock_usb; static void cpia_usb_complete(struct urb *urb, struct pt_regs *regs) { @@ -464,12 +466,14 @@ { struct usb_cpia *ucpia = (struct usb_cpia *) privdata; - ucpia->open = 0; + if(!ucpia) + return -ENODEV; - cpia_usb_free_resources(ucpia, 1); + ucpia->open = 0; - if (!ucpia->present) - kfree(ucpia); + /* ucpia->present = 0 protects against trying to reset the + * alt setting if camera is physically disconnected while open */ + cpia_usb_free_resources(ucpia, ucpia->present); return 0; } @@ -565,7 +569,7 @@ vfree(ucpia->buffers[0]); ucpia->buffers[0] = NULL; fail_alloc_0: - + kfree(ucpia); return -EIO; } @@ -588,9 +592,6 @@ .id_table = cpia_id_table, }; -/* don't use dev, it may be NULL! (see usb_cpia_cleanup) */ -/* _disconnect from usb_cpia_cleanup is not necessary since usb_deregister */ -/* will do it for us as well as passing a udev structure - jerdfelt */ static void cpia_disconnect(struct usb_interface *intf) { struct cam_data *cam = usb_get_intfdata(intf); @@ -606,12 +607,11 @@ list_del(&cam->cam_data_list); spin_unlock( &cam_list_lock_usb ); - /* Don't even try to reset the altsetting if we're disconnected */ - cpia_usb_free_resources(ucpia, 0); - ucpia->present = 0; cpia_unregister_camera(cam); + if(ucpia->open) + cpia_usb_close(cam->lowlevel_data); ucpia->curbuff->status = FRAME_ERROR; @@ -639,29 +639,25 @@ ucpia->buffers[0] = NULL; } - if (!ucpia->open) { - kfree(ucpia); - cam->lowlevel_data = NULL; - } + cam->lowlevel_data = NULL; + kfree(ucpia); } static int __init usb_cpia_init(void) { + printk(KERN_INFO "%s v%d.%d.%d\n",ABOUT, + CPIA_USB_MAJ_VER,CPIA_USB_MIN_VER,CPIA_USB_PATCH_VER); + + spin_lock_init(&cam_list_lock_usb); return usb_register(&cpia_driver); } static void __exit usb_cpia_cleanup(void) { -/* - struct cam_data *cam; - - while ((cam = cam_list) != NULL) - cpia_disconnect(NULL, cam); -*/ - usb_deregister(&cpia_driver); } module_init (usb_cpia_init); module_exit (usb_cpia_cleanup); + diff -Nru a/drivers/media/video/saa7134/saa7134-i2c.c b/drivers/media/video/saa7134/saa7134-i2c.c --- a/drivers/media/video/saa7134/saa7134-i2c.c Sun Mar 23 00:22:51 2003 +++ b/drivers/media/video/saa7134/saa7134-i2c.c Sun Mar 23 00:22:51 2003 @@ -19,8 +19,6 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#define __NO_VERSION__ 1 - #include #include #include diff -Nru a/drivers/media/video/saa7134/saa7134-oss.c b/drivers/media/video/saa7134/saa7134-oss.c --- a/drivers/media/video/saa7134/saa7134-oss.c Sun Mar 23 00:22:53 2003 +++ b/drivers/media/video/saa7134/saa7134-oss.c Sun Mar 23 00:22:53 2003 @@ -19,8 +19,6 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#define __NO_VERSION__ 1 - #include #include #include diff -Nru a/drivers/media/video/saa7134/saa7134-ts.c b/drivers/media/video/saa7134/saa7134-ts.c --- a/drivers/media/video/saa7134/saa7134-ts.c Sun Mar 23 00:22:49 2003 +++ b/drivers/media/video/saa7134/saa7134-ts.c Sun Mar 23 00:22:49 2003 @@ -19,8 +19,6 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#define __NO_VERSION__ 1 - #include #include #include diff -Nru a/drivers/media/video/saa7134/saa7134-tvaudio.c b/drivers/media/video/saa7134/saa7134-tvaudio.c --- a/drivers/media/video/saa7134/saa7134-tvaudio.c Sun Mar 23 00:22:49 2003 +++ b/drivers/media/video/saa7134/saa7134-tvaudio.c Sun Mar 23 00:22:49 2003 @@ -19,8 +19,6 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#define __NO_VERSION__ 1 - #include #include #include diff -Nru a/drivers/media/video/saa7134/saa7134-vbi.c b/drivers/media/video/saa7134/saa7134-vbi.c --- a/drivers/media/video/saa7134/saa7134-vbi.c Sun Mar 23 00:22:55 2003 +++ b/drivers/media/video/saa7134/saa7134-vbi.c Sun Mar 23 00:22:55 2003 @@ -19,8 +19,6 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#define __NO_VERSION__ 1 - #include #include #include diff -Nru a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c --- a/drivers/media/video/saa7134/saa7134-video.c Sun Mar 23 00:22:51 2003 +++ b/drivers/media/video/saa7134/saa7134-video.c Sun Mar 23 00:22:51 2003 @@ -19,8 +19,6 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#define __NO_VERSION__ 1 - #include #include #include diff -Nru a/drivers/media/video/w9966.c b/drivers/media/video/w9966.c --- a/drivers/media/video/w9966.c Sun Mar 23 00:22:51 2003 +++ b/drivers/media/video/w9966.c Sun Mar 23 00:22:51 2003 @@ -742,7 +742,7 @@ case VIDIOCGTUNER: { struct video_tuner *vtune = arg; - if(vtune->tuner != 0); + if(vtune->tuner != 0) return -EINVAL; strcpy(vtune->name, "no tuner"); vtune->rangelow = 0; diff -Nru a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c --- a/drivers/message/fusion/mptctl.c Sun Mar 23 00:22:50 2003 +++ b/drivers/message/fusion/mptctl.c Sun Mar 23 00:22:50 2003 @@ -2743,7 +2743,8 @@ unsigned long, struct file *)); int unregister_ioctl32_conversion(unsigned int cmd); -extern asmlinkage int sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg); +extern asmlinkage long sys_ioctl(unsigned int fd, unsigned int cmd, + unsigned long arg); /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ /* sparc32_XXX functions are used to provide a conversion between diff -Nru a/drivers/message/i2o/Kconfig b/drivers/message/i2o/Kconfig --- a/drivers/message/i2o/Kconfig Sun Mar 23 00:22:50 2003 +++ b/drivers/message/i2o/Kconfig Sun Mar 23 00:22:50 2003 @@ -3,6 +3,7 @@ config I2O tristate "I2O support" + depends on PCI ---help--- The Intelligent Input/Output (I2O) architecture allows hardware drivers to be split into two parts: an operating system specific diff -Nru a/drivers/message/i2o/Makefile b/drivers/message/i2o/Makefile --- a/drivers/message/i2o/Makefile Sun Mar 23 00:22:54 2003 +++ b/drivers/message/i2o/Makefile Sun Mar 23 00:22:54 2003 @@ -5,7 +5,6 @@ # In the future, some of these should be built conditionally. # -obj-$(CONFIG_I2O_PCI) += i2o_pci.o obj-$(CONFIG_I2O) += i2o_core.o i2o_config.o obj-$(CONFIG_I2O_BLOCK) += i2o_block.o obj-$(CONFIG_I2O_SCSI) += i2o_scsi.o diff -Nru a/drivers/message/i2o/i2o_block.c b/drivers/message/i2o/i2o_block.c --- a/drivers/message/i2o/i2o_block.c Sun Mar 23 00:22:54 2003 +++ b/drivers/message/i2o/i2o_block.c Sun Mar 23 00:22:54 2003 @@ -754,7 +754,7 @@ * hit the fan big time. The card seems to recover but loses * the pending writes. Deeply ungood except for testing fsck */ - if(i2ob_dev[unit].i2odev->controller->bus.pci.promise) + if(i2ob_dev[unit].i2odev->controller->promise) panic("I2O controller firmware failed. Reboot and force a filesystem check.\n"); default: printk(KERN_INFO "%s: Received event 0x%X we didn't register for\n" @@ -1140,10 +1140,10 @@ if(d->controller->battery == 0) i2ob_dev[i].wcache = CACHE_WRITETHROUGH; - if(d->controller->type == I2O_TYPE_PCI && d->controller->bus.pci.promise) + if(d->controller->promise) i2ob_dev[i].wcache = CACHE_WRITETHROUGH; - if(d->controller->type == I2O_TYPE_PCI && d->controller->bus.pci.short_req) + if(d->controller->short_req) { blk_queue_max_sectors(q, 8); blk_queue_max_phys_segments(q, 8); diff -Nru a/drivers/message/i2o/i2o_config.c b/drivers/message/i2o/i2o_config.c --- a/drivers/message/i2o/i2o_config.c Sun Mar 23 00:22:55 2003 +++ b/drivers/message/i2o/i2o_config.c Sun Mar 23 00:22:55 2003 @@ -437,7 +437,7 @@ put_user(len, kcmd.reslen); if(len > reslen) ret = -ENOBUFS; - else if(copy_to_user(cmd->resbuf, res, len)) + else if(copy_to_user(kcmd.resbuf, res, len)) ret = -EFAULT; kfree(res); diff -Nru a/drivers/message/i2o/i2o_core.c b/drivers/message/i2o/i2o_core.c --- a/drivers/message/i2o/i2o_core.c Sun Mar 23 00:22:54 2003 +++ b/drivers/message/i2o/i2o_core.c Sun Mar 23 00:22:54 2003 @@ -50,6 +50,9 @@ #include #include +#ifdef CONFIG_MTRR +#include +#endif // CONFIG_MTRR #include "i2o_lan.h" @@ -103,6 +106,8 @@ void i2o_report_controller_unit(struct i2o_controller *, struct i2o_device *); +static void i2o_pci_dispose(struct i2o_controller *c); + /* * I2O System Table. Contains information about * all the IOPs in the system. Used to inform IOPs @@ -206,7 +211,6 @@ */ static int verbose; -MODULE_PARM(verbose, "i"); /* * I2O Core reply handler @@ -549,7 +553,8 @@ if(__i2o_delete_device(c->devices)<0) { /* Shouldnt happen */ - c->bus_disable(c); + I2O_IRQ_WRITE32(c, 0xFFFFFFFF); + c->enabled = 0; up(&i2o_configuration_lock); return -EBUSY; } @@ -584,7 +589,7 @@ i2o_reset_controller(c); /* Release IRQ */ - c->destructor(c); + i2o_pci_dispose(c); *p=c->next; up(&i2o_configuration_lock); @@ -1651,7 +1656,7 @@ for (iop = i2o_controller_chain; iop; iop = iop->next) { - if(iop->type != I2O_TYPE_PCI || !iop->bus.pci.dpt) + if(!iop->dpt) i2o_quiesce_controller(iop); } @@ -1911,65 +1916,62 @@ u32 msg[12]; dma_addr_t sys_tbl_phys; int ret; + struct resource *root; u32 *privbuf = kmalloc(16, GFP_KERNEL); if(privbuf == NULL) return -ENOMEM; - if(iop->type == I2O_TYPE_PCI) - { - struct resource *root; - if(iop->status_block->current_mem_size < iop->status_block->desired_mem_size) - { - struct resource *res = &iop->mem_resource; - res->name = iop->pdev->bus->name; - res->flags = IORESOURCE_MEM; - res->start = 0; - res->end = 0; - printk("%s: requires private memory resources.\n", iop->name); - root = pci_find_parent_resource(iop->pdev, res); - if(root==NULL) - printk("Can't find parent resource!\n"); - if(root && allocate_resource(root, res, - iop->status_block->desired_mem_size, - iop->status_block->desired_mem_size, - iop->status_block->desired_mem_size, - 1<<20, /* Unspecified, so use 1Mb and play safe */ - NULL, - NULL)>=0) - { - iop->mem_alloc = 1; - iop->status_block->current_mem_size = 1 + res->end - res->start; - iop->status_block->current_mem_base = res->start; - printk(KERN_INFO "%s: allocated %ld bytes of PCI memory at 0x%08lX.\n", - iop->name, 1+res->end-res->start, res->start); - } - } - if(iop->status_block->current_io_size < iop->status_block->desired_io_size) - { - struct resource *res = &iop->io_resource; - res->name = iop->pdev->bus->name; - res->flags = IORESOURCE_IO; - res->start = 0; - res->end = 0; - printk("%s: requires private memory resources.\n", iop->name); - root = pci_find_parent_resource(iop->pdev, res); - if(root==NULL) - printk("Can't find parent resource!\n"); - if(root && allocate_resource(root, res, - iop->status_block->desired_io_size, - iop->status_block->desired_io_size, - iop->status_block->desired_io_size, - 1<<20, /* Unspecified, so use 1Mb and play safe */ - NULL, - NULL)>=0) - { - iop->io_alloc = 1; - iop->status_block->current_io_size = 1 + res->end - res->start; - iop->status_block->current_mem_base = res->start; - printk(KERN_INFO "%s: allocated %ld bytes of PCI I/O at 0x%08lX.\n", - iop->name, 1+res->end-res->start, res->start); - } + if(iop->status_block->current_mem_size < iop->status_block->desired_mem_size) + { + struct resource *res = &iop->mem_resource; + res->name = iop->pdev->bus->name; + res->flags = IORESOURCE_MEM; + res->start = 0; + res->end = 0; + printk("%s: requires private memory resources.\n", iop->name); + root = pci_find_parent_resource(iop->pdev, res); + if(root==NULL) + printk("Can't find parent resource!\n"); + if(root && allocate_resource(root, res, + iop->status_block->desired_mem_size, + iop->status_block->desired_mem_size, + iop->status_block->desired_mem_size, + 1<<20, /* Unspecified, so use 1Mb and play safe */ + NULL, + NULL)>=0) + { + iop->mem_alloc = 1; + iop->status_block->current_mem_size = 1 + res->end - res->start; + iop->status_block->current_mem_base = res->start; + printk(KERN_INFO "%s: allocated %ld bytes of PCI memory at 0x%08lX.\n", + iop->name, 1+res->end-res->start, res->start); + } + } + if(iop->status_block->current_io_size < iop->status_block->desired_io_size) + { + struct resource *res = &iop->io_resource; + res->name = iop->pdev->bus->name; + res->flags = IORESOURCE_IO; + res->start = 0; + res->end = 0; + printk("%s: requires private memory resources.\n", iop->name); + root = pci_find_parent_resource(iop->pdev, res); + if(root==NULL) + printk("Can't find parent resource!\n"); + if(root && allocate_resource(root, res, + iop->status_block->desired_io_size, + iop->status_block->desired_io_size, + iop->status_block->desired_io_size, + 1<<20, /* Unspecified, so use 1Mb and play safe */ + NULL, + NULL)>=0) + { + iop->io_alloc = 1; + iop->status_block->current_io_size = 1 + res->end - res->start; + iop->status_block->current_mem_base = res->start; + printk(KERN_INFO "%s: allocated %ld bytes of PCI I/O at 0x%08lX.\n", + iop->name, 1+res->end-res->start, res->start); } } else @@ -3427,48 +3429,256 @@ } -EXPORT_SYMBOL(i2o_controller_chain); -EXPORT_SYMBOL(i2o_num_controllers); -EXPORT_SYMBOL(i2o_find_controller); -EXPORT_SYMBOL(i2o_unlock_controller); -EXPORT_SYMBOL(i2o_status_get); -EXPORT_SYMBOL(i2o_install_handler); -EXPORT_SYMBOL(i2o_remove_handler); -EXPORT_SYMBOL(i2o_install_controller); -EXPORT_SYMBOL(i2o_delete_controller); -EXPORT_SYMBOL(i2o_run_queue); +/** + * i2o_pci_dispose - Free bus specific resources + * @c: I2O controller + * + * Disable interrupts and then free interrupt, I/O and mtrr resources + * used by this controller. Called by the I2O core on unload. + */ + +static void i2o_pci_dispose(struct i2o_controller *c) +{ + I2O_IRQ_WRITE32(c,0xFFFFFFFF); + if(c->irq > 0) + free_irq(c->irq, c); + iounmap(((u8 *)c->post_port)-0x40); -EXPORT_SYMBOL(i2o_claim_device); -EXPORT_SYMBOL(i2o_release_device); -EXPORT_SYMBOL(i2o_device_notify_on); -EXPORT_SYMBOL(i2o_device_notify_off); +#ifdef CONFIG_MTRR + if(c->mtrr_reg0 > 0) + mtrr_del(c->mtrr_reg0, 0, 0); + if(c->mtrr_reg1 > 0) + mtrr_del(c->mtrr_reg1, 0, 0); +#endif +} -EXPORT_SYMBOL(i2o_post_this); -EXPORT_SYMBOL(i2o_post_wait); -EXPORT_SYMBOL(i2o_post_wait_mem); +/** + * i2o_pci_interrupt - Bus specific interrupt handler + * @irq: interrupt line + * @dev_id: cookie + * + * Handle an interrupt from a PCI based I2O controller. This turns out + * to be rather simple. We keep the controller pointer in the cookie. + */ + +static void i2o_pci_interrupt(int irq, void *dev_id, struct pt_regs *r) +{ + struct i2o_controller *c = dev_id; + i2o_run_queue(c); +} -EXPORT_SYMBOL(i2o_query_scalar); -EXPORT_SYMBOL(i2o_set_scalar); -EXPORT_SYMBOL(i2o_query_table); -EXPORT_SYMBOL(i2o_clear_table); -EXPORT_SYMBOL(i2o_row_add_table); -EXPORT_SYMBOL(i2o_issue_params); +/** + * i2o_pci_install - Install a PCI i2o controller + * @dev: PCI device of the I2O controller + * + * Install a PCI (or in theory AGP) i2o controller. Devices are + * initialized, configured and registered with the i2o core subsystem. Be + * very careful with ordering. There may be pending interrupts. + * + * To Do: Add support for polled controllers + */ -EXPORT_SYMBOL(i2o_event_register); -EXPORT_SYMBOL(i2o_event_ack); +int __init i2o_pci_install(struct pci_dev *dev) +{ + struct i2o_controller *c=kmalloc(sizeof(struct i2o_controller), + GFP_KERNEL); + unsigned long mem; + u32 memptr = 0; + u32 size; + + int i; -EXPORT_SYMBOL(i2o_report_status); -EXPORT_SYMBOL(i2o_dump_message); + if(c==NULL) + { + printk(KERN_ERR "i2o: Insufficient memory to add controller.\n"); + return -ENOMEM; + } + memset(c, 0, sizeof(*c)); -EXPORT_SYMBOL(i2o_get_class_name); + for(i=0; i<6; i++) + { + /* Skip I/O spaces */ + if(!(pci_resource_flags(dev, i) & IORESOURCE_IO)) + { + memptr = pci_resource_start(dev, i); + break; + } + } + + if(i==6) + { + printk(KERN_ERR "i2o: I2O controller has no memory regions defined.\n"); + kfree(c); + return -EINVAL; + } + + size = dev->resource[i].end-dev->resource[i].start+1; + /* Map the I2O controller */ + + printk(KERN_INFO "i2o: PCI I2O controller at 0x%08X size=%d\n", memptr, size); + mem = (unsigned long)ioremap(memptr, size); + if(mem==0) + { + printk(KERN_ERR "i2o: Unable to map controller.\n"); + kfree(c); + return -EINVAL; + } -EXPORT_SYMBOL_GPL(i2o_sys_init); + c->irq = -1; + c->dpt = 0; + c->short_req = 0; + c->pdev = dev; + + c->irq_mask = mem+0x34; + c->post_port = mem+0x40; + c->reply_port = mem+0x44; -MODULE_AUTHOR("Red Hat Software"); -MODULE_DESCRIPTION("I2O Core"); -MODULE_LICENSE("GPL"); + c->mem_phys = memptr; + c->mem_offset = mem; + + /* + * Cards that fall apart if you hit them with large I/O + * loads... + */ + + if(dev->vendor == PCI_VENDOR_ID_NCR && dev->device == 0x0630) + { + c->short_req = 1; + printk(KERN_INFO "I2O: Symbios FC920 workarounds activated.\n"); + } + if(dev->subsystem_vendor == PCI_VENDOR_ID_PROMISE) + { + c->promise = 1; + printk(KERN_INFO "I2O: Promise workarounds activated.\n"); + } + + /* + * Cards that go bananas if you quiesce them before you reset + * them + */ + + if(dev->vendor == PCI_VENDOR_ID_DPT) + c->dpt=1; + + /* + * Enable Write Combining MTRR for IOP's memory region + */ +#ifdef CONFIG_MTRR + c->mtrr_reg0 = + mtrr_add(c->mem_phys, size, MTRR_TYPE_WRCOMB, 1); + /* + * If it is an INTEL i960 I/O processor then set the first 64K to + * Uncacheable since the region contains the Messaging unit which + * shouldn't be cached. + */ + c->mtrr_reg1 = -1; + if(dev->vendor == PCI_VENDOR_ID_INTEL || dev->vendor == PCI_VENDOR_ID_DPT) + { + printk(KERN_INFO "I2O: MTRR workaround for Intel i960 processor\n"); + c->mtrr_reg1 = mtrr_add(c->mem_phys, 65536, MTRR_TYPE_UNCACHABLE, 1); + if(c->mtrr_reg1< 0) + { + printk(KERN_INFO "i2o_pci: Error in setting MTRR_TYPE_UNCACHABLE\n"); + mtrr_del(c->mtrr_reg0, c->mem_phys, size); + c->mtrr_reg0 = -1; + } + } + +#endif + + I2O_IRQ_WRITE32(c,0xFFFFFFFF); + + i = i2o_install_controller(c); + + if(i<0) + { + printk(KERN_ERR "i2o: Unable to install controller.\n"); + kfree(c); + iounmap((void *)mem); + return i; + } + + c->irq = dev->irq; + if(c->irq) + { + i=request_irq(dev->irq, i2o_pci_interrupt, SA_SHIRQ, + c->name, c); + if(i<0) + { + printk(KERN_ERR "%s: unable to allocate interrupt %d.\n", + c->name, dev->irq); + c->irq = -1; + i2o_delete_controller(c); + iounmap((void *)mem); + return -EBUSY; + } + } + + printk(KERN_INFO "%s: Installed at IRQ%d\n", c->name, dev->irq); + I2O_IRQ_WRITE32(c,0x0); + c->enabled = 1; + return 0; +} + +static int dpt; + +/** + * i2o_pci_scan - Scan the pci bus for controllers + * + * Scan the PCI devices on the system looking for any device which is a + * memory of the Intelligent, I2O class. We attempt to set up each such device + * and register it with the core. + * + * Returns the number of controllers registered + * + * Note; Do not change this to a hot plug interface. I2O 1.5 itself + * does not support hot plugging. + */ + +int __init i2o_pci_scan(void) +{ + struct pci_dev *dev; + int count=0; + + printk(KERN_INFO "i2o: Checking for PCI I2O controllers...\n"); + + pci_for_each_dev(dev) + { + if((dev->class>>8)!=PCI_CLASS_INTELLIGENT_I2O) + continue; + if(dev->vendor == PCI_VENDOR_ID_DPT && !dpt) + { + if(dev->device == 0xA501 || dev->device == 0xA511) + { + printk(KERN_INFO "i2o: Skipping Adaptec/DPT I2O raid with preferred native driver.\n"); + continue; + } + } + if((dev->class&0xFF)>1) + { + printk(KERN_INFO "i2o: I2O Controller found but does not support I2O 1.5 (skipping).\n"); + continue; + } + if (pci_enable_device(dev)) + continue; + printk(KERN_INFO "i2o: I2O controller on bus %d at %d.\n", + dev->bus->number, dev->devfn); + if(pci_set_dma_mask(dev, 0xffffffff)) + { + printk(KERN_WARNING "I2O controller on bus %d at %d : No suitable DMA available\n", dev->bus->number, dev->devfn); + continue; + } + pci_set_master(dev); + if(i2o_pci_install(dev)==0) + count++; + } + if(count) + printk(KERN_INFO "i2o: %d I2O controller%s found and installed.\n", count, + count==1?"":"s"); + return count?count:-ENODEV; +} static int i2o_core_init(void) { @@ -3496,6 +3706,7 @@ else printk(KERN_INFO "I2O: Event thread created as pid %d\n", evt_pid); + i2o_pci_scan(); if(i2o_num_controllers) i2o_sys_init(); @@ -3532,3 +3743,40 @@ module_init(i2o_core_init); module_exit(i2o_core_exit); +MODULE_PARM(dpt, "i"); +MODULE_PARM_DESC(dpt, "Set this if you want to drive DPT cards normally handled by dpt_i2o"); +MODULE_PARM(verbose, "i"); +MODULE_PARM_DESC(verbose, "Verbose diagnostics"); + +MODULE_AUTHOR("Red Hat Software"); +MODULE_DESCRIPTION("I2O Core"); +MODULE_LICENSE("GPL"); + +EXPORT_SYMBOL(i2o_controller_chain); +EXPORT_SYMBOL(i2o_num_controllers); +EXPORT_SYMBOL(i2o_find_controller); +EXPORT_SYMBOL(i2o_unlock_controller); +EXPORT_SYMBOL(i2o_status_get); +EXPORT_SYMBOL(i2o_install_handler); +EXPORT_SYMBOL(i2o_remove_handler); +EXPORT_SYMBOL(i2o_install_controller); +EXPORT_SYMBOL(i2o_delete_controller); +EXPORT_SYMBOL(i2o_run_queue); +EXPORT_SYMBOL(i2o_claim_device); +EXPORT_SYMBOL(i2o_release_device); +EXPORT_SYMBOL(i2o_device_notify_on); +EXPORT_SYMBOL(i2o_device_notify_off); +EXPORT_SYMBOL(i2o_post_this); +EXPORT_SYMBOL(i2o_post_wait); +EXPORT_SYMBOL(i2o_post_wait_mem); +EXPORT_SYMBOL(i2o_query_scalar); +EXPORT_SYMBOL(i2o_set_scalar); +EXPORT_SYMBOL(i2o_query_table); +EXPORT_SYMBOL(i2o_clear_table); +EXPORT_SYMBOL(i2o_row_add_table); +EXPORT_SYMBOL(i2o_issue_params); +EXPORT_SYMBOL(i2o_event_register); +EXPORT_SYMBOL(i2o_event_ack); +EXPORT_SYMBOL(i2o_report_status); +EXPORT_SYMBOL(i2o_dump_message); +EXPORT_SYMBOL(i2o_get_class_name); diff -Nru a/drivers/message/i2o/i2o_pci.c b/drivers/message/i2o/i2o_pci.c --- a/drivers/message/i2o/i2o_pci.c Sun Mar 23 00:22:51 2003 +++ /dev/null Wed Dec 31 16:00:00 1969 @@ -1,397 +0,0 @@ -/* - * Find I2O capable controllers on the PCI bus, and register/install - * them with the I2O layer - * - * (C) Copyright 1999-2002 Red Hat Software - * - * Written by Alan Cox, Building Number Three Ltd - * Modified by Deepak Saxena - * Modified by Boji T Kannanthanam - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version - * 2 of the License, or (at your option) any later version. - * - * Ported to Linux 2.5 by Alan Cox - * - * TODO: - * Support polled I2O PCI controllers. - * Finish verifying 64bit/bigendian clean - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#ifdef CONFIG_MTRR -#include -#endif // CONFIG_MTRR - -static int dpt; - - -/** - * i2o_pci_dispose - Free bus specific resources - * @c: I2O controller - * - * Disable interrupts and then free interrupt, I/O and mtrr resources - * used by this controller. Called by the I2O core on unload. - */ - -static void i2o_pci_dispose(struct i2o_controller *c) -{ - I2O_IRQ_WRITE32(c,0xFFFFFFFF); - if(c->bus.pci.irq > 0) - free_irq(c->bus.pci.irq, c); - iounmap(((u8 *)c->post_port)-0x40); - -#ifdef CONFIG_MTRR - if(c->bus.pci.mtrr_reg0 > 0) - mtrr_del(c->bus.pci.mtrr_reg0, 0, 0); - if(c->bus.pci.mtrr_reg1 > 0) - mtrr_del(c->bus.pci.mtrr_reg1, 0, 0); -#endif -} - -/** - * i2o_pci_bind - Bind controller and devices - * @c: i2o controller - * @dev: i2o device - * - * Bind a device driver to a controller. In the case of PCI all we need to do - * is module housekeeping. - */ - -static int i2o_pci_bind(struct i2o_controller *c, struct i2o_device *dev) -{ - MOD_INC_USE_COUNT; - return 0; -} - -/** - * i2o_pci_unbind - Bind controller and devices - * @c: i2o controller - * @dev: i2o device - * - * Unbind a device driver from a controller. In the case of PCI all we need to do - * is module housekeeping. - */ - - -static int i2o_pci_unbind(struct i2o_controller *c, struct i2o_device *dev) -{ - MOD_DEC_USE_COUNT; - return 0; -} - -/** - * i2o_pci_enable - Enable controller - * @c: controller - * - * Called by the I2O core code in order to enable bus specific - * resources for this controller. In our case that means unmasking the - * interrupt line. - */ - -static void i2o_pci_enable(struct i2o_controller *c) -{ - I2O_IRQ_WRITE32(c, 0); - c->enabled = 1; -} - -/** - * i2o_pci_disable - Enable controller - * @c: controller - * - * Called by the I2O core code in order to enable bus specific - * resources for this controller. In our case that means masking the - * interrupt line. - */ - -static void i2o_pci_disable(struct i2o_controller *c) -{ - I2O_IRQ_WRITE32(c, 0xFFFFFFFF); - c->enabled = 0; -} - -/** - * i2o_pci_interrupt - Bus specific interrupt handler - * @irq: interrupt line - * @dev_id: cookie - * - * Handle an interrupt from a PCI based I2O controller. This turns out - * to be rather simple. We keep the controller pointer in the cookie. - */ - -static void i2o_pci_interrupt(int irq, void *dev_id, struct pt_regs *r) -{ - struct i2o_controller *c = dev_id; - i2o_run_queue(c); -} - -/** - * i2o_pci_install - Install a PCI i2o controller - * @dev: PCI device of the I2O controller - * - * Install a PCI (or in theory AGP) i2o controller. Devices are - * initialized, configured and registered with the i2o core subsystem. Be - * very careful with ordering. There may be pending interrupts. - * - * To Do: Add support for polled controllers - */ - -int __init i2o_pci_install(struct pci_dev *dev) -{ - struct i2o_controller *c=kmalloc(sizeof(struct i2o_controller), - GFP_KERNEL); - unsigned long mem; - u32 memptr = 0; - u32 size; - - int i; - - if(c==NULL) - { - printk(KERN_ERR "i2o: Insufficient memory to add controller.\n"); - return -ENOMEM; - } - memset(c, 0, sizeof(*c)); - - for(i=0; i<6; i++) - { - /* Skip I/O spaces */ - if(!(pci_resource_flags(dev, i) & IORESOURCE_IO)) - { - memptr = pci_resource_start(dev, i); - break; - } - } - - if(i==6) - { - printk(KERN_ERR "i2o: I2O controller has no memory regions defined.\n"); - kfree(c); - return -EINVAL; - } - - size = dev->resource[i].end-dev->resource[i].start+1; - /* Map the I2O controller */ - - printk(KERN_INFO "i2o: PCI I2O controller at 0x%08X size=%d\n", memptr, size); - mem = (unsigned long)ioremap(memptr, size); - if(mem==0) - { - printk(KERN_ERR "i2o: Unable to map controller.\n"); - kfree(c); - return -EINVAL; - } - - c->bus.pci.irq = -1; - c->bus.pci.dpt = 0; - c->bus.pci.short_req = 0; - c->pdev = dev; - - c->irq_mask = mem+0x34; - c->post_port = mem+0x40; - c->reply_port = mem+0x44; - - c->mem_phys = memptr; - c->mem_offset = mem; - c->destructor = i2o_pci_dispose; - - c->bind = i2o_pci_bind; - c->unbind = i2o_pci_unbind; - c->bus_enable = i2o_pci_enable; - c->bus_disable = i2o_pci_disable; - - c->type = I2O_TYPE_PCI; - - /* - * Cards that fall apart if you hit them with large I/O - * loads... - */ - - if(dev->vendor == PCI_VENDOR_ID_NCR && dev->device == 0x0630) - { - c->bus.pci.short_req = 1; - printk(KERN_INFO "I2O: Symbios FC920 workarounds activated.\n"); - } - if(dev->subsystem_vendor == PCI_VENDOR_ID_PROMISE) - { - c->bus.pci.promise = 1; - printk(KERN_INFO "I2O: Promise workarounds activated.\n"); - } - - /* - * Cards that go bananas if you quiesce them before you reset - * them - */ - - if(dev->vendor == PCI_VENDOR_ID_DPT) - c->bus.pci.dpt=1; - - /* - * Enable Write Combining MTRR for IOP's memory region - */ -#ifdef CONFIG_MTRR - c->bus.pci.mtrr_reg0 = - mtrr_add(c->mem_phys, size, MTRR_TYPE_WRCOMB, 1); - /* - * If it is an INTEL i960 I/O processor then set the first 64K to - * Uncacheable since the region contains the Messaging unit which - * shouldn't be cached. - */ - c->bus.pci.mtrr_reg1 = -1; - if(dev->vendor == PCI_VENDOR_ID_INTEL || dev->vendor == PCI_VENDOR_ID_DPT) - { - printk(KERN_INFO "I2O: MTRR workaround for Intel i960 processor\n"); - c->bus.pci.mtrr_reg1 = mtrr_add(c->mem_phys, 65536, MTRR_TYPE_UNCACHABLE, 1); - if(c->bus.pci.mtrr_reg1< 0) - { - printk(KERN_INFO "i2o_pci: Error in setting MTRR_TYPE_UNCACHABLE\n"); - mtrr_del(c->bus.pci.mtrr_reg0, c->mem_phys, size); - c->bus.pci.mtrr_reg0 = -1; - } - } - -#endif - - I2O_IRQ_WRITE32(c,0xFFFFFFFF); - - i = i2o_install_controller(c); - - if(i<0) - { - printk(KERN_ERR "i2o: Unable to install controller.\n"); - kfree(c); - iounmap((void *)mem); - return i; - } - - c->bus.pci.irq = dev->irq; - if(c->bus.pci.irq) - { - i=request_irq(dev->irq, i2o_pci_interrupt, SA_SHIRQ, - c->name, c); - if(i<0) - { - printk(KERN_ERR "%s: unable to allocate interrupt %d.\n", - c->name, dev->irq); - c->bus.pci.irq = -1; - i2o_delete_controller(c); - iounmap((void *)mem); - return -EBUSY; - } - } - - printk(KERN_INFO "%s: Installed at IRQ%d\n", c->name, dev->irq); - I2O_IRQ_WRITE32(c,0x0); - c->enabled = 1; - return 0; -} - -/** - * i2o_pci_scan - Scan the pci bus for controllers - * - * Scan the PCI devices on the system looking for any device which is a - * memory of the Intelligent, I2O class. We attempt to set up each such device - * and register it with the core. - * - * Returns the number of controllers registered - * - * Note; Do not change this to a hot plug interface. I2O 1.5 itself - * does not support hot plugging. - */ - -int __init i2o_pci_scan(void) -{ - struct pci_dev *dev; - int count=0; - - printk(KERN_INFO "i2o: Checking for PCI I2O controllers...\n"); - - pci_for_each_dev(dev) - { - if((dev->class>>8)!=PCI_CLASS_INTELLIGENT_I2O) - continue; - if(dev->vendor == PCI_VENDOR_ID_DPT && !dpt) - { - if(dev->device == 0xA501 || dev->device == 0xA511) - { - printk(KERN_INFO "i2o: Skipping Adaptec/DPT I2O raid with preferred native driver.\n"); - continue; - } - } - if((dev->class&0xFF)>1) - { - printk(KERN_INFO "i2o: I2O Controller found but does not support I2O 1.5 (skipping).\n"); - continue; - } - if (pci_enable_device(dev)) - continue; - printk(KERN_INFO "i2o: I2O controller on bus %d at %d.\n", - dev->bus->number, dev->devfn); - if(pci_set_dma_mask(dev, 0xffffffff)) - { - printk(KERN_WARNING "I2O controller on bus %d at %d : No suitable DMA available\n", dev->bus->number, dev->devfn); - continue; - } - pci_set_master(dev); - if(i2o_pci_install(dev)==0) - count++; - } - if(count) - printk(KERN_INFO "i2o: %d I2O controller%s found and installed.\n", count, - count==1?"":"s"); - return count?count:-ENODEV; -} - - -/** - * i2o_pci_core_attach - PCI initialisation for I2O - * - * Find any I2O controllers and if present initialise them and bring up - * the I2O subsystem. - * - * Returns 0 on success or an error code - */ - -static int i2o_pci_core_attach(void) -{ - printk(KERN_INFO "Linux I2O PCI support (c) 1999-2002 Red Hat.\n"); - if(i2o_pci_scan()>0) - { - i2o_sys_init(); - return 0; - } - return -ENODEV; -} - -/** - * i2o_pci_core_detach - PCI unload for I2O - * - * Free up any resources not released when the controllers themselves were - * shutdown and unbound from the bus and drivers - */ - -static void i2o_pci_core_detach(void) -{ -} - -MODULE_AUTHOR("Red Hat"); -MODULE_DESCRIPTION("I2O PCI Interface"); -MODULE_LICENSE("GPL"); - -MODULE_PARM(dpt, "i"); -MODULE_PARM_DESC(dpt, "Set this if you want to drive DPT cards normally handled by dpt_i2o"); -module_init(i2o_pci_core_attach); -module_exit(i2o_pci_core_detach); diff -Nru a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c --- a/drivers/message/i2o/i2o_proc.c Sun Mar 23 00:22:54 2003 +++ b/drivers/message/i2o/i2o_proc.c Sun Mar 23 00:22:54 2003 @@ -836,10 +836,14 @@ u16 row_count; u16 more_flag; i2o_exec_execute_ddm_table ddm_table[MAX_I2O_MODULES]; - } result; + } *result; i2o_exec_execute_ddm_table ddm_table; + result = kmalloc(sizeof(*result), GFP_KERNEL); + if(!result) + return -ENOMEM; + spin_lock(&i2o_proc_lock); len = 0; @@ -847,18 +851,17 @@ c, ADAPTER_TID, 0x0003, -1, NULL, 0, - &result, sizeof(result)); + result, sizeof(*result)); if (token < 0) { len += i2o_report_query_status(buf+len, token,"0x0003 Executing DDM List"); - spin_unlock(&i2o_proc_lock); - return len; + goto out; } len += sprintf(buf+len, "Tid Module_type Vendor Mod_id Module_name Vrs Data_size Code_size\n"); - ddm_table=result.ddm_table[0]; + ddm_table=result->ddm_table[0]; - for(i=0; i < result.row_count; ddm_table=result.ddm_table[++i]) + for(i=0; i < result->row_count; ddm_table=result->ddm_table[++i]) { len += sprintf(buf+len, "0x%03x ", ddm_table.ddm_tid & 0xFFF); @@ -882,9 +885,9 @@ len += sprintf(buf+len, "\n"); } - +out: spin_unlock(&i2o_proc_lock); - + kfree(result); return len; } @@ -1047,7 +1050,11 @@ u16 row_count; u16 more_flag; i2o_group_info group[256]; - } result; + } *result; + + result = kmalloc(sizeof(*result), GFP_KERNEL); + if(!result) + return -ENOMEM; spin_lock(&i2o_proc_lock); @@ -1055,24 +1062,23 @@ token = i2o_query_table(I2O_PARAMS_TABLE_GET, d->controller, d->lct_data.tid, 0xF000, -1, NULL, 0, - &result, sizeof(result)); + result, sizeof(*result)); if (token < 0) { len = i2o_report_query_status(buf+len, token, "0xF000 Params Descriptor"); - spin_unlock(&i2o_proc_lock); - return len; + goto out; } len += sprintf(buf+len, "# Group FieldCount RowCount Type Add Del Clear\n"); - for (i=0; i < result.row_count; i++) + for (i=0; i < result->row_count; i++) { len += sprintf(buf+len, "%-3d", i); - len += sprintf(buf+len, "0x%04X ", result.group[i].group_number); - len += sprintf(buf+len, "%10d ", result.group[i].field_count); - len += sprintf(buf+len, "%8d ", result.group[i].row_count); + len += sprintf(buf+len, "0x%04X ", result->group[i].group_number); + len += sprintf(buf+len, "%10d ", result->group[i].field_count); + len += sprintf(buf+len, "%8d ", result->group[i].row_count); - properties = result.group[i].properties; + properties = result->group[i].properties; if (properties & 0x1) len += sprintf(buf+len, "Table "); else len += sprintf(buf+len, "Scalar "); if (properties & 0x2) len += sprintf(buf+len, " + "); @@ -1085,11 +1091,11 @@ len += sprintf(buf+len, "\n"); } - if (result.more_flag) + if (result->more_flag) len += sprintf(buf+len, "There is more...\n"); - +out: spin_unlock(&i2o_proc_lock); - + kfree(result); return len; } @@ -1220,7 +1226,11 @@ u16 row_count; u16 more_flag; i2o_user_table user[64]; - } result; + } *result; + + result = kmalloc(sizeof(*result), GFP_KERNEL); + if(!result) + return -ENOMEM; spin_lock(&i2o_proc_lock); len = 0; @@ -1228,28 +1238,28 @@ token = i2o_query_table(I2O_PARAMS_TABLE_GET, d->controller, d->lct_data.tid, 0xF003, -1, NULL, 0, - &result, sizeof(result)); + result, sizeof(*result)); if (token < 0) { len += i2o_report_query_status(buf+len, token,"0xF003 User Table"); - spin_unlock(&i2o_proc_lock); - return len; + goto out; } len += sprintf(buf+len, "# Instance UserTid ClaimType\n"); - for(i=0; i < result.row_count; i++) + for(i=0; i < result->row_count; i++) { len += sprintf(buf+len, "%-3d", i); - len += sprintf(buf+len, "%#8x ", result.user[i].instance); - len += sprintf(buf+len, "%#7x ", result.user[i].user_tid); - len += sprintf(buf+len, "%#9x\n", result.user[i].claim_type); + len += sprintf(buf+len, "%#8x ", result->user[i].instance); + len += sprintf(buf+len, "%#7x ", result->user[i].user_tid); + len += sprintf(buf+len, "%#9x\n", result->user[i].claim_type); } - if (result.more_flag) + if (result->more_flag) len += sprintf(buf+len, "There is more...\n"); - +out: spin_unlock(&i2o_proc_lock); + kfree(result); return len; } @@ -2264,24 +2274,27 @@ u16 row_count; u16 more_flag; u8 mc_addr[256][8]; - } result; + } *result; + + result = kmalloc(sizeof(*result), GFP_KERNEL); + if(!result) + return -ENOMEM; spin_lock(&i2o_proc_lock); len = 0; token = i2o_query_table(I2O_PARAMS_TABLE_GET, d->controller, d->lct_data.tid, 0x0002, -1, - NULL, 0, &result, sizeof(result)); + NULL, 0, result, sizeof(*result)); if (token < 0) { len += i2o_report_query_status(buf+len, token,"0x002 LAN Multicast MAC Address"); - spin_unlock(&i2o_proc_lock); - return len; + goto out; } - for (i = 0; i < result.row_count; i++) + for (i = 0; i < result->row_count; i++) { - memcpy(mc_addr, result.mc_addr[i], 8); + memcpy(mc_addr, result->mc_addr[i], 8); len += sprintf(buf+len, "MC MAC address[%d]: " "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n", @@ -2289,8 +2302,9 @@ mc_addr[3], mc_addr[4], mc_addr[5], mc_addr[6], mc_addr[7]); } - +out: spin_unlock(&i2o_proc_lock); + kfree(result); return len; } @@ -2495,32 +2509,36 @@ u16 row_count; u16 more_flag; u8 alt_addr[256][8]; - } result; + } *result; + + result = kmalloc(sizeof(*result), GFP_KERNEL); + if(!result) + return -ENOMEM; spin_lock(&i2o_proc_lock); len = 0; token = i2o_query_table(I2O_PARAMS_TABLE_GET, d->controller, d->lct_data.tid, - 0x0006, -1, NULL, 0, &result, sizeof(result)); + 0x0006, -1, NULL, 0, result, sizeof(*result)); if (token < 0) { len += i2o_report_query_status(buf+len, token, "0x0006 LAN Alternate Address (optional)"); - spin_unlock(&i2o_proc_lock); - return len; + goto out; } - for (i=0; i < result.row_count; i++) + for (i=0; i < result->row_count; i++) { - memcpy(alt_addr,result.alt_addr[i],8); + memcpy(alt_addr,result->alt_addr[i],8); len += sprintf(buf+len, "Alternate address[%d]: " "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n", i, alt_addr[0], alt_addr[1], alt_addr[2], alt_addr[3], alt_addr[4], alt_addr[5], alt_addr[6], alt_addr[7]); } - +out: spin_unlock(&i2o_proc_lock); + kfree(result); return len; } diff -Nru a/drivers/message/i2o/i2o_scsi.c b/drivers/message/i2o/i2o_scsi.c --- a/drivers/message/i2o/i2o_scsi.c Sun Mar 23 00:22:55 2003 +++ b/drivers/message/i2o/i2o_scsi.c Sun Mar 23 00:22:55 2003 @@ -85,7 +85,7 @@ static u32 *retry[32]; static struct i2o_controller *retry_ctrl[32]; static struct timer_list retry_timer; -static spinlock_t retry_lock; +static spinlock_t retry_lock = SPIN_LOCK_UNLOCKED; static int retry_ct = 0; static atomic_t queue_depth; diff -Nru a/drivers/mtd/devices/blkmtd.c b/drivers/mtd/devices/blkmtd.c --- a/drivers/mtd/devices/blkmtd.c Sun Mar 23 00:22:50 2003 +++ b/drivers/mtd/devices/blkmtd.c Sun Mar 23 00:22:50 2003 @@ -166,6 +166,7 @@ int sectornr, sectors, i; struct kiobuf *iobuf; sector_t *blocks; + char b[BDEVNAME_SIZE]; if(!rawdevice) { printk("blkmtd: readpage: PANIC file->private_data == NULL\n"); @@ -173,7 +174,7 @@ } DEBUG(2, "blkmtd: readpage called, dev = `%s' page = %p index = %ld\n", - bdevname(rawdevice->binding), page, page->index); + bdevname(rawdevice->binding, b), page, page->index); if(PageUptodate(page)) { DEBUG(2, "blkmtd: readpage page %ld is already upto date\n", page->index); @@ -523,6 +524,7 @@ size_t from; u_long len; int err = 0; + char b[BDEVNAME_SIZE]; /* check readonly */ if(rawdevice->readonly) { @@ -537,7 +539,7 @@ /* check erase region has valid start and length */ DEBUG(2, "blkmtd: erase: dev = `%s' from = 0x%x len = 0x%lx\n", - bdevname(rawdevice->binding), from, len); + bdevname(rawdevice->binding, b), from, len); while(numregions) { DEBUG(3, "blkmtd: checking erase region = 0x%08X size = 0x%X num = 0x%x\n", einfo->offset, einfo->erasesize, einfo->numblocks); @@ -635,11 +637,12 @@ int err = 0; int offset; int pagenr, pages; + char b[BDEVNAME_SIZE]; *retlen = 0; DEBUG(2, "blkmtd: read: dev = `%s' from = %ld len = %d buf = %p\n", - bdevname(rawdevice->binding), (long int)from, len, buf); + bdevname(rawdevice->binding, b), (long int)from, len, buf); pagenr = from >> PAGE_SHIFT; offset = from - (pagenr << PAGE_SHIFT); @@ -706,10 +709,11 @@ size_t len1 = 0, len2 = 0, len3 = 0; struct page **pages; int pagecnt = 0; - + char b[BDEVNAME_SIZE]; +21 e3 *retlen = 0; DEBUG(2, "blkmtd: write: dev = `%s' to = %ld len = %d buf = %p\n", - bdevname(rawdevice->binding), (long int)to, len, buf); + bdevname(rawdevice->binding, b), (long int)to, len, buf); /* handle readonly and out of range numbers */ @@ -1060,6 +1064,7 @@ int err; int mode; int regions; + char b[BDEVNAME_SIZE]; /* Check args */ if(device == 0) { @@ -1128,7 +1133,7 @@ if (err) return 1; - DEBUG(1, "blkmtd: devname = %s\n", bdevname(bdev)); + DEBUG(1, "blkmtd: devname = %s\n", bdevname(bdev, b)); blocksize = BLOCK_SIZE; blocksize = bs ? bs : block_size(bdev); diff -Nru a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c --- a/drivers/mtd/nftlmount.c Sun Mar 23 00:22:50 2003 +++ b/drivers/mtd/nftlmount.c Sun Mar 23 00:22:50 2003 @@ -21,7 +21,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#define __NO_VERSION__ #include #include #include diff -Nru a/drivers/net/3c501.c b/drivers/net/3c501.c --- a/drivers/net/3c501.c Sun Mar 23 00:22:49 2003 +++ b/drivers/net/3c501.c Sun Mar 23 00:22:49 2003 @@ -955,7 +955,7 @@ * init_module: * * When the driver is loaded as a module this function is called. We fake up - * a device structure with the base I/O and interrupt set as if it was being + * a device structure with the base I/O and interrupt set as if it were being * called from Space.c. This minimises the extra code that would otherwise * be required. * diff -Nru a/drivers/net/3c509.c b/drivers/net/3c509.c --- a/drivers/net/3c509.c Sun Mar 23 00:22:50 2003 +++ b/drivers/net/3c509.c Sun Mar 23 00:22:50 2003 @@ -56,6 +56,10 @@ v1.19b 08Nov2002 Marc Zyngier - Introduce driver model for EISA cards. */ +/* + FIXES for PC-9800: + Shu Iwanaga: 3c569B(PC-9801 C-bus) support +*/ #define DRV_NAME "3c509" #define DRV_VERSION "1.19b" @@ -257,7 +261,7 @@ }; #endif /* CONFIG_MCA */ -#ifdef __ISAPNP__ +#if defined(__ISAPNP__) && !defined(CONFIG_X86_PC9800) static struct isapnp_device_id el3_isapnp_adapters[] __initdata = { { ISAPNP_ANY_ID, ISAPNP_ANY_ID, ISAPNP_VENDOR('T', 'C', 'M'), ISAPNP_FUNCTION(0x5090), @@ -350,7 +354,7 @@ if (lp->pmdev) pm_unregister(lp->pmdev); #endif -#ifdef __ISAPNP__ +#if defined(__ISAPNP__) && !defined(CONFIG_X86_PC9800) if (lp->type == EL3_PNP) pnp_device_detach(to_pnp_dev(lp->dev)); #endif @@ -368,12 +372,12 @@ int ioaddr, irq, if_port; u16 phys_addr[3]; static int current_tag; -#ifdef __ISAPNP__ +#if defined(__ISAPNP__) && !defined(CONFIG_X86_PC9800) static int pnp_cards; struct pnp_dev *idev = NULL; #endif /* __ISAPNP__ */ -#ifdef __ISAPNP__ +#if defined(__ISAPNP__) && !defined(CONFIG_X86_PC9800) if (nopnp == 1) goto no_pnp; @@ -421,6 +425,9 @@ no_pnp: #endif /* __ISAPNP__ */ +#ifdef CONFIG_X86_PC9800 + id_port = 0x71d0; +#else /* Select an open I/O location at 0x1*0 to do contention select. */ for ( ; id_port < 0x200; id_port += 0x10) { if (check_region(id_port, 1)) @@ -435,6 +442,7 @@ printk(" WARNING: No I/O port available for 3c509 activation.\n"); return -ENODEV; } +#endif /* CONFIG_X86_PC9800 */ /* Next check for all ISA bus boards by sending the ID sequence to the ID_PORT. We find cards past the first by setting the 'current_tag' on cards as they are found. Cards with their tag set will not @@ -465,7 +473,7 @@ phys_addr[i] = htons(id_read_eeprom(i)); } -#ifdef __ISAPNP__ +#if defined(__ISAPNP__) && !defined(CONFIG_X86_PC9800) if (nopnp == 0) { /* The ISA PnP 3c509 cards respond to the ID sequence. This check is needed in order not to register them twice. */ @@ -490,9 +498,19 @@ { unsigned int iobase = id_read_eeprom(8); if_port = iobase >> 14; +#ifdef CONFIG_X86_PC9800 + ioaddr = 0x40d0 + ((iobase & 0x1f) << 8); +#else ioaddr = 0x200 + ((iobase & 0x1f) << 4); +#endif } irq = id_read_eeprom(9) >> 12; +#ifdef CONFIG_X86_PC9800 + if (irq == 7) + irq = 6; + else if (irq == 15) + irq = 13; +#endif if (!(dev = init_etherdev(NULL, sizeof(struct el3_private)))) return -ENOMEM; @@ -522,7 +540,11 @@ outb(0xd0 + ++current_tag, id_port); /* Activate the adaptor at the EEPROM location. */ +#ifdef CONFIG_X86_PC9800 + outb((ioaddr >> 8) | 0xe0, id_port); +#else outb((ioaddr >> 4) | 0xe0, id_port); +#endif EL3WINDOW(0); if (inw(ioaddr) != 0x6d50) { @@ -534,7 +556,7 @@ /* Free the interrupt so that some other card can use it. */ outw(0x0f00, ioaddr + WN0_IRQ); -#ifdef __ISAPNP__ +#if defined(__ISAPNP__) && !defined(CONFIG_X86_PC9800) found: /* PNP jumps here... */ #endif /* __ISAPNP__ */ @@ -543,7 +565,7 @@ dev->irq = irq; dev->if_port = if_port; lp = dev->priv; -#ifdef __ISAPNP__ +#if defined(__ISAPNP__) && !defined(CONFIG_X86_PC9800) lp->dev = &idev->dev; #endif @@ -1388,6 +1410,12 @@ outw(0x0001, ioaddr + 4); /* Set the IRQ line. */ +#ifdef CONFIG_X86_PC9800 + if (dev->irq == 6) + dev->irq = 7; + else if (dev->irq == 13) + dev->irq = 15; +#endif outw((dev->irq << 12) | 0x0f00, ioaddr + WN0_IRQ); /* Set the station address in window 2 each time opened. */ @@ -1550,7 +1578,7 @@ MODULE_PARM_DESC(irq, "IRQ number(s) (assigned)"); MODULE_PARM_DESC(xcvr,"transceiver(s) (0=internal, 1=external)"); MODULE_PARM_DESC(max_interrupt_work, "maximum events handled per interrupt"); -#ifdef __ISAPNP__ +#if defined(__ISAPNP__) && !defined(CONFIG_X86_PC9800) MODULE_PARM(nopnp, "i"); MODULE_PARM_DESC(nopnp, "disable ISA PnP support (0-1)"); MODULE_DEVICE_TABLE(isapnp, el3_isapnp_adapters); diff -Nru a/drivers/net/82596.c b/drivers/net/82596.c --- a/drivers/net/82596.c Sun Mar 23 00:22:54 2003 +++ b/drivers/net/82596.c Sun Mar 23 00:22:54 2003 @@ -646,7 +646,7 @@ /* change the scp address */ - MPU_PORT(dev, PORT_ALTSCP, (void *)virt_to_bus(&lp->scp)); + MPU_PORT(dev, PORT_ALTSCP, (void *)virt_to_bus((void *)&lp->scp)); #elif defined(ENABLE_APRICOT) @@ -677,8 +677,8 @@ lp->scp.sysbus = 0x00440000; #endif - lp->scp.iscp = WSWAPiscp(virt_to_bus(&(lp->iscp))); - lp->iscp.scb = WSWAPscb(virt_to_bus(&(lp->scb))); + lp->scp.iscp = WSWAPiscp(virt_to_bus((void *)&lp->iscp)); + lp->iscp.scb = WSWAPscb(virt_to_bus((void *)&lp->scb)); lp->iscp.stat = ISCP_BUSY; lp->cmd_backlog = 0; diff -Nru a/drivers/net/8390.h b/drivers/net/8390.h --- a/drivers/net/8390.h Sun Mar 23 00:22:54 2003 +++ b/drivers/net/8390.h Sun Mar 23 00:22:54 2003 @@ -123,7 +123,8 @@ #define inb_p(port) in_8(port) #define outb_p(val,port) out_8(port,val) -#elif defined(CONFIG_ARM_ETHERH) || defined(CONFIG_ARM_ETHERH_MODULE) +#elif defined(CONFIG_ARM_ETHERH) || defined(CONFIG_ARM_ETHERH_MODULE) || \ + defined(CONFIG_NET_CBUS) #define EI_SHIFT(x) (ei_local->reg_offset[x]) #else #define EI_SHIFT(x) (x) diff -Nru a/drivers/net/Kconfig b/drivers/net/Kconfig --- a/drivers/net/Kconfig Sun Mar 23 00:22:55 2003 +++ b/drivers/net/Kconfig Sun Mar 23 00:22:55 2003 @@ -663,7 +663,7 @@ as . config EL3 - tristate "3c509/3c529 (MCA)/3c579 \"EtherLink III\" support" + tristate "3c509/3c529 (MCA)/3c569B (98)/3c579 \"EtherLink III\" support" depends on NET_VENDOR_3COM && (ISA || EISA || MCA) ---help--- If you have a network (Ethernet) card belonging to the 3Com @@ -932,7 +932,7 @@ source "drivers/net/tulip/Kconfig" config AT1700 - tristate "AT1700/1720 support (EXPERIMENTAL)" + tristate "AT1700/1720/RE1000Plus(C-Bus) support (EXPERIMENTAL)" depends on NET_ETHERNET && (ISA || MCA) && EXPERIMENTAL ---help--- If you have a network (Ethernet) card of this type, say Y and read @@ -978,7 +978,7 @@ config NET_ISA bool "Other ISA cards" - depends on NET_ETHERNET && ISA + depends on NET_ETHERNET && ISA && !X86_PC9800 ---help--- If your network (Ethernet) card hasn't been mentioned yet and its bus system (that's the way the cards talks to the other components @@ -1176,6 +1176,55 @@ the Ethernet-HOWTO, available from . +config NET_CBUS + bool "NEC PC-9800 C-bus cards" + depends on NET_ETHERNET && ISA && X86_PC9800 + ---help--- + If your network (Ethernet) card hasn't been mentioned yet and its + bus system (that's the way the cards talks to the other components + of your computer) is NEC PC-9800 C-Bus, say Y. + +config NE2K_CBUS + tristate "Most NE2000-based Ethernet support" + depends on NET_CBUS + +config NE2K_CBUS_EGY98 + bool "Melco EGY-98 support" + depends on NE2K_CBUS + +config NE2K_CBUS_LGY98 + bool "Melco LGY-98 support" + depends on NE2K_CBUS + +config NE2K_CBUS_ICM + bool "ICM IF-27xxET support" + depends on NE2K_CBUS + +config NE2K_CBUS_IOLA98 + bool "I-O DATA LA-98 support" + depends on NE2K_CBUS + +config NE2K_CBUS_CNET98EL + bool "Contec C-NET(98)E/L support" + depends on NE2K_CBUS + +config NE2K_CBUS_CNET98EL_IO_BASE + hex "C-NET(98)E/L I/O base address (0xaaed or 0x55ed)" + depends on NE2K_CBUS_CNET98EL + default "0xaaed" + +config NE2K_CBUS_ATLA98 + bool "Allied Telesis LA-98 Support" + depends on NE2K_CBUS + +config NE2K_CBUS_BDN + bool "ELECOM Laneed LD-BDN[123]A Support" + depends on NE2K_CBUS + +config NE2K_CBUS_NEC108 + bool "NEC PC-9801-108 Support" + depends on NE2K_CBUS + config SKMC tristate "SKnet MCA support" depends on NET_ETHERNET && MCA @@ -1904,6 +1953,7 @@ 82544 PRO/1000 XF Server Adapter A50484-xxx 82544 PRO/1000 T Desktop Adapter A62947-xxx 82540 PRO/1000 MT Desktop Adapter A78408-xxx + 82541 PRO/1000 MT Desktop Adapter C91016-xxx 82545 PRO/1000 MT Server Adapter A92165-xxx 82546 PRO/1000 MT Dual Port Server Adapter A92111-xxx 82545 PRO/1000 MF Server Adapter A91622-xxx diff -Nru a/drivers/net/Makefile b/drivers/net/Makefile --- a/drivers/net/Makefile Sun Mar 23 00:22:51 2003 +++ b/drivers/net/Makefile Sun Mar 23 00:22:51 2003 @@ -81,6 +81,7 @@ obj-$(CONFIG_WD80x3) += wd.o 8390.o obj-$(CONFIG_EL2) += 3c503.o 8390.o obj-$(CONFIG_NE2000) += ne.o 8390.o +obj-$(CONFIG_NE2K_CBUS) += ne2k_cbus.o 8390.o obj-$(CONFIG_NE2_MCA) += ne2.o 8390.o obj-$(CONFIG_HPLAN) += hp.o 8390.o obj-$(CONFIG_HPLAN_PLUS) += hp-plus.o 8390.o diff -Nru a/drivers/net/Makefile.lib b/drivers/net/Makefile.lib --- a/drivers/net/Makefile.lib Sun Mar 23 00:22:55 2003 +++ b/drivers/net/Makefile.lib Sun Mar 23 00:22:55 2003 @@ -19,6 +19,7 @@ obj-$(CONFIG_MACMACE) += crc32.o obj-$(CONFIG_MIPS_AU1000_ENET) += crc32.o obj-$(CONFIG_NATSEMI) += crc32.o +obj-$(CONFIG_NE2K_CBUS) += crc32.o obj-$(CONFIG_PCMCIA_FMVJ18X) += crc32.o obj-$(CONFIG_PCMCIA_SMC91C92) += crc32.o obj-$(CONFIG_PCMCIA_XIRTULIP) += crc32.o diff -Nru a/drivers/net/Space.c b/drivers/net/Space.c --- a/drivers/net/Space.c Sun Mar 23 00:22:50 2003 +++ b/drivers/net/Space.c Sun Mar 23 00:22:50 2003 @@ -233,7 +233,7 @@ #ifdef CONFIG_E2100 /* Cabletron E21xx series. */ {e2100_probe, 0}, #endif -#ifdef CONFIG_NE2000 /* ISA (use ne2k-pci for PCI cards) */ +#if defined(CONFIG_NE2000) || defined(CONFIG_NE2K_CBUS) /* ISA & PC-9800 CBUS (use ne2k-pci for PCI cards) */ {ne_probe, 0}, #endif #ifdef CONFIG_LANCE /* ISA/VLB (use pcnet32 for PCI cards) */ diff -Nru a/drivers/net/apne.c b/drivers/net/apne.c --- a/drivers/net/apne.c Sun Mar 23 00:22:56 2003 +++ b/drivers/net/apne.c Sun Mar 23 00:22:56 2003 @@ -111,9 +111,6 @@ #define MANUAL_HWADDR5 0x9a */ -#define WORDSWAP(a) ( (((a)>>8)&0xff) | ((a)<<8) ) - - static const char version[] = "apne.c:v1.1 7/10/98 Alain Malek (Alain.Malek@cryogen.ch)\n"; @@ -402,10 +399,9 @@ } outb(ENISR_RDC, nic_base + NE_EN0_ISR); /* Ack intr. */ - - hdr->count = WORDSWAP(hdr->count); - ei_status.dmaing &= ~0x01; + + le16_to_cpus(&hdr->count); } /* Block input and output, similar to the Crynwr packet driver. If you diff -Nru a/drivers/net/at1700.c b/drivers/net/at1700.c --- a/drivers/net/at1700.c Sun Mar 23 00:22:52 2003 +++ b/drivers/net/at1700.c Sun Mar 23 00:22:52 2003 @@ -34,6 +34,10 @@ only is it difficult to detect, it also moves around in I/O space in response to inb()s from other device probes! */ +/* + 99/03/03 Allied Telesis RE1000 Plus support by T.Hagawa + 99/12/30 port to 2.3.35 by K.Takai +*/ #include #include @@ -76,10 +80,17 @@ * ISA */ +#ifndef CONFIG_X86_PC9800 static int at1700_probe_list[] __initdata = { 0x260, 0x280, 0x2a0, 0x240, 0x340, 0x320, 0x380, 0x300, 0 }; +#else /* CONFIG_X86_PC9800 */ +static int at1700_probe_list[] __initdata = { + 0x1d6, 0x1d8, 0x1da, 0x1d4, 0xd4, 0xd2, 0xd8, 0xd0, 0 +}; + +#endif /* CONFIG_X86_PC9800 */ /* * MCA */ @@ -122,6 +133,7 @@ /* Offsets from the base address. */ +#ifndef CONFIG_X86_PC9800 #define STATUS 0 #define TX_STATUS 0 #define RX_STATUS 1 @@ -136,6 +148,7 @@ #define TX_START 10 #define COL16CNTL 11 /* Controll Reg for 16 collisions */ #define MODE13 13 +#define RX_CTRL 14 /* Configuration registers only on the '865A/B chips. */ #define EEPROM_Ctrl 16 #define EEPROM_Data 17 @@ -144,8 +157,39 @@ #define IOCONFIG 18 /* Either read the jumper, or move the I/O. */ #define IOCONFIG1 19 #define SAPROM 20 /* The station address PROM, if no EEPROM. */ +#define MODE24 24 #define RESET 31 /* Write to reset some parts of the chip. */ #define AT1700_IO_EXTENT 32 +#define PORT_OFFSET(o) (o) +#else /* CONFIG_X86_PC9800 */ +#define STATUS (0x0000) +#define TX_STATUS (0x0000) +#define RX_STATUS (0x0001) +#define TX_INTR (0x0200)/* Bit-mapped interrupt enable registers. */ +#define RX_INTR (0x0201) +#define TX_MODE (0x0400) +#define RX_MODE (0x0401) +#define CONFIG_0 (0x0600)/* Misc. configuration settings. */ +#define CONFIG_1 (0x0601) +/* Run-time register bank 2 definitions. */ +#define DATAPORT (0x0800)/* Word-wide DMA or programmed-I/O dataport. */ +#define TX_START (0x0a00) +#define COL16CNTL (0x0a01)/* Controll Reg for 16 collisions */ +#define MODE13 (0x0c01) +#define RX_CTRL (0x0e00) +/* Configuration registers only on the '865A/B chips. */ +#define EEPROM_Ctrl (0x1000) +#define EEPROM_Data (0x1200) +#define CARDSTATUS 16 /* FMV-18x Card Status */ +#define CARDSTATUS1 17 /* FMV-18x Card Status */ +#define IOCONFIG (0x1400)/* Either read the jumper, or move the I/O. */ +#define IOCONFIG1 (0x1600) +#define SAPROM 20 /* The station address PROM, if no EEPROM. */ +#define MODE24 (0x1800)/* The station address PROM, if no EEPROM. */ +#define RESET (0x1e01)/* Write to reset some parts of the chip. */ +#define PORT_OFFSET(o) ({ int _o_ = (o); (_o_ & ~1) * 0x100 + (_o_ & 1); }) +#endif /* CONFIG_X86_PC9800 */ + #define TX_TIMEOUT 10 @@ -225,8 +269,20 @@ int slot, ret = -ENODEV; struct net_local *lp; +#ifndef CONFIG_X86_PC9800 if (!request_region(ioaddr, AT1700_IO_EXTENT, dev->name)) return -EBUSY; +#else + for (i = 0; i < 0x2000; i += 0x0200) { + if (!request_region(ioaddr + i, 2, dev->name)) { + while (i > 0) { + i -= 0x0200; + release_region(ioaddr + i, 2); + } + return -EBUSY; + } + } +#endif /* Resetting the chip doesn't reset the ISA interface, so don't bother. That means we have to be careful with the register values we probe for. @@ -317,10 +373,17 @@ /* Reset the internal state machines. */ outb(0, ioaddr + RESET); - if (is_at1700) + if (is_at1700) { +#ifndef CONFIG_X86_PC9800 irq = at1700_irqmap[(read_eeprom(ioaddr, 12)&0x04) | (read_eeprom(ioaddr, 0)>>14)]; - else { +#else + { + char re1000plus_irqmap[4] = {3, 5, 6, 12}; + irq = re1000plus_irqmap[inb(ioaddr + IOCONFIG1) >> 6]; + } +#endif + } else { /* Check PnP mode for FMV-183/184/183A/184A. */ /* This PnP routine is very poor. IO and IRQ should be known. */ if (inb(ioaddr + CARDSTATUS1) & 0x20) { @@ -392,18 +455,22 @@ /* Set the station address in bank zero. */ outb(0x00, ioaddr + CONFIG_1); for (i = 0; i < 6; i++) - outb(dev->dev_addr[i], ioaddr + 8 + i); + outb(dev->dev_addr[i], ioaddr + PORT_OFFSET(8 + i)); /* Switch to bank 1 and set the multicast table to accept none. */ outb(0x04, ioaddr + CONFIG_1); for (i = 0; i < 8; i++) - outb(0x00, ioaddr + 8 + i); + outb(0x00, ioaddr + PORT_OFFSET(8 + i)); /* Switch to bank 2 */ /* Lock our I/O address, and set manual processing mode for 16 collisions. */ outb(0x08, ioaddr + CONFIG_1); +#ifndef CONFIG_X86_PC9800 outb(dev->if_port, ioaddr + MODE13); +#else + outb(0, ioaddr + MODE13); +#endif outb(0x00, ioaddr + COL16CNTL); if (net_debug) @@ -447,7 +514,12 @@ kfree(dev->priv); dev->priv = NULL; err_out: +#ifndef CONFIG_X86_PC9800 release_region(ioaddr, AT1700_IO_EXTENT); +#else + for (i = 0; i < 0x2000; i += 0x0200) + release_region(ioaddr + i, 2); +#endif return ret; } @@ -459,7 +531,11 @@ #define EE_DATA_READ 0x80 /* EEPROM chip data out, in reg. 17. */ /* Delay between EEPROM clock transitions. */ +#ifndef CONFIG_X86_PC9800 #define eeprom_delay() do { } while (0) +#else +#define eeprom_delay() __asm__ ("out%B0 %%al,%0" :: "N"(0x5f)) +#endif /* The EEPROM commands include the alway-set leading bit. */ #define EE_WRITE_CMD (5 << 6) @@ -542,12 +618,12 @@ inw (ioaddr + STATUS), inb (ioaddr + TX_STATUS) & 0x80 ? "IRQ conflict" : "network cable problem"); printk ("%s: timeout registers: %04x %04x %04x %04x %04x %04x %04x %04x.\n", - dev->name, inw (ioaddr + 0), inw (ioaddr + 2), inw (ioaddr + 4), - inw (ioaddr + 6), inw (ioaddr + 8), inw (ioaddr + 10), - inw (ioaddr + 12), inw (ioaddr + 14)); + dev->name, inw(ioaddr + TX_STATUS), inw(ioaddr + TX_INTR), inw(ioaddr + TX_MODE), + inw(ioaddr + CONFIG_0), inw(ioaddr + DATAPORT), inw(ioaddr + TX_START), + inw(ioaddr + MODE13 - 1), inw(ioaddr + RX_CTRL)); lp->stats.tx_errors++; /* ToDo: We should try to restart the adaptor... */ - outw (0xffff, ioaddr + 24); + outw(0xffff, ioaddr + MODE24); outw (0xffff, ioaddr + TX_STATUS); outb (0x5a, ioaddr + CONFIG_0); outb (0xe8, ioaddr + CONFIG_1); @@ -704,7 +780,7 @@ dev->name, inb(ioaddr + RX_MODE), status); #ifndef final_version if (status == 0) { - outb(0x05, ioaddr + 14); + outb(0x05, ioaddr + RX_CTRL); break; } #endif @@ -724,7 +800,7 @@ dev->name, pkt_len); /* Prime the FIFO and then flush the packet. */ inw(ioaddr + DATAPORT); inw(ioaddr + DATAPORT); - outb(0x05, ioaddr + 14); + outb(0x05, ioaddr + RX_CTRL); lp->stats.rx_errors++; break; } @@ -734,7 +810,7 @@ dev->name, pkt_len); /* Prime the FIFO and then flush the packet. */ inw(ioaddr + DATAPORT); inw(ioaddr + DATAPORT); - outb(0x05, ioaddr + 14); + outb(0x05, ioaddr + RX_CTRL); lp->stats.rx_dropped++; break; } @@ -761,7 +837,7 @@ if ((inb(ioaddr + RX_MODE) & 0x40) == 0x40) break; inw(ioaddr + DATAPORT); /* dummy status read */ - outb(0x05, ioaddr + 14); + outb(0x05, ioaddr + RX_CTRL); } if (net_debug > 5) @@ -844,24 +920,28 @@ outb(0x02, ioaddr + RX_MODE); /* Use normal mode. */ } - save_flags(flags); - cli(); + spin_lock_irqsave (&lp->lock, flags); if (memcmp(mc_filter, lp->mc_filter, sizeof(mc_filter))) { int saved_bank = inw(ioaddr + CONFIG_0); /* Switch to bank 1 and set the multicast table. */ outw((saved_bank & ~0x0C00) | 0x0480, ioaddr + CONFIG_0); for (i = 0; i < 8; i++) - outb(mc_filter[i], ioaddr + 8 + i); + outb(mc_filter[i], ioaddr + PORT_OFFSET(8 + i)); memcpy(lp->mc_filter, mc_filter, sizeof(mc_filter)); outw(saved_bank, ioaddr + CONFIG_0); } - restore_flags(flags); + spin_unlock_irqrestore (&lp->lock, flags); return; } #ifdef MODULE static struct net_device dev_at1700; +#ifndef CONFIG_X86_PC9800 static int io = 0x260; +#else +static int io = 0xd0; +#endif + static int irq; MODULE_PARM(io, "i"); @@ -901,7 +981,15 @@ /* If we don't do this, we can't re-insmod it later. */ free_irq(dev_at1700.irq, NULL); +#ifndef CONFIG_X86_PC9800 release_region(dev_at1700.base_addr, AT1700_IO_EXTENT); +#else + { + int i; + for (i = 0; i < 0x2000; i += 0x200) + release_region(dev_at1700.base_addr + i, 2); + } +#endif } #endif /* MODULE */ MODULE_LICENSE("GPL"); diff -Nru a/drivers/net/e100/e100.h b/drivers/net/e100/e100.h --- a/drivers/net/e100/e100.h Sun Mar 23 00:22:52 2003 +++ b/drivers/net/e100/e100.h Sun Mar 23 00:22:52 2003 @@ -1,7 +1,7 @@ /******************************************************************************* - Copyright(c) 1999 - 2002 Intel Corporation. All rights reserved. + Copyright(c) 1999 - 2003 Intel Corporation. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -57,6 +57,8 @@ #include #include #include +#include +#include #define E100_REGS_LEN 1 /* @@ -301,6 +303,9 @@ /* EEPROM bit definitions */ /*- EEPROM control register bits */ +#define EEPROM_FLAG_ASF 0x8000 +#define EEPROM_FLAG_GCL 0x4000 + #define EN_TRNF 0x10 /* Enable turnoff */ #define EEDO 0x08 /* EEPROM data out */ #define EEDI 0x04 /* EEPROM data in (set for writing data) */ @@ -319,6 +324,8 @@ #define EEPROM_COMPATIBILITY_WORD 3 #define EEPROM_PWA_NO 8 #define EEPROM_ID_WORD 0x0A +#define EEPROM_CONFIG_ASF 0x0D +#define EEPROM_SMBUS_ADDR 0x90 #define EEPROM_SUM 0xbaba @@ -358,7 +365,7 @@ #define CB_STATUS_MASK BIT_12_15 /* CB Status Mask (4-bits) */ #define CB_STATUS_COMPLETE BIT_15 /* CB Complete Bit */ #define CB_STATUS_OK BIT_13 /* CB OK Bit */ -#define CB_STATUS_UNDERRUN BIT_12 /* CB A Bit */ +#define CB_STATUS_VLAN BIT_12 /* CB Valn detected Bit */ #define CB_STATUS_FAIL BIT_11 /* CB Fail (F) Bit */ /*misc command bits */ @@ -851,6 +858,7 @@ }; struct e100_private { + struct vlan_group *vlgrp; u32 flags; /* board management flags */ u32 tx_per_underrun; /* number of good tx frames per underrun */ unsigned int tx_count; /* count of tx frames, so we can request an interrupt */ @@ -886,7 +894,6 @@ struct driver_stats drv_stats; u8 rev_id; /* adapter PCI revision ID */ - unsigned long device_type; /* device type from e100_vendor.h */ unsigned int phy_addr; /* address of PHY component */ unsigned int PhyId; /* ID of PHY component */ @@ -922,8 +929,6 @@ u8 ifs_value; struct cfg_params params; /* adapter's command line parameters */ - - char *id_string; u32 speed_duplex_caps; /* adapter's speed/duplex capabilities */ diff -Nru a/drivers/net/e100/e100_config.c b/drivers/net/e100/e100_config.c --- a/drivers/net/e100/e100_config.c Sun Mar 23 00:22:52 2003 +++ b/drivers/net/e100/e100_config.c Sun Mar 23 00:22:52 2003 @@ -1,7 +1,7 @@ /******************************************************************************* - Copyright(c) 1999 - 2002 Intel Corporation. All rights reserved. + Copyright(c) 1999 - 2003 Intel Corporation. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -518,6 +518,25 @@ } E100_CONFIG(bdp, 19); + spin_unlock_bh(&(bdp->config_lock)); +} + +void +e100_config_vlan_drop(struct e100_private *bdp, unsigned char enable) +{ + spin_lock_bh(&(bdp->config_lock)); + if (enable) { + if (!(bdp->config[22] & CB_CFIG_VLAN_DROP_ENABLE)) { + bdp->config[22] |= CB_CFIG_VLAN_DROP_ENABLE; + E100_CONFIG(bdp, 22); + } + + } else { + if ((bdp->config[22] & CB_CFIG_VLAN_DROP_ENABLE)) { + bdp->config[22] &= ~CB_CFIG_VLAN_DROP_ENABLE; + E100_CONFIG(bdp, 22); + } + } spin_unlock_bh(&(bdp->config_lock)); } diff -Nru a/drivers/net/e100/e100_config.h b/drivers/net/e100/e100_config.h --- a/drivers/net/e100/e100_config.h Sun Mar 23 00:22:51 2003 +++ b/drivers/net/e100/e100_config.h Sun Mar 23 00:22:51 2003 @@ -1,7 +1,7 @@ /******************************************************************************* - Copyright(c) 1999 - 2002 Intel Corporation. All rights reserved. + Copyright(c) 1999 - 2003 Intel Corporation. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -163,5 +163,5 @@ extern u8 e100_config_loopback_mode(struct e100_private *bdp, u8 mode); extern u8 e100_config_dynamic_tbd(struct e100_private *bdp, u8 enable); extern u8 e100_config_tcb_ext_enable(struct e100_private *bdp, u8 enable); - +extern void e100_config_vlan_drop(struct e100_private *bdp, unsigned char enable); #endif /* _E100_CONFIG_INC_ */ diff -Nru a/drivers/net/e100/e100_eeprom.c b/drivers/net/e100/e100_eeprom.c --- a/drivers/net/e100/e100_eeprom.c Sun Mar 23 00:22:52 2003 +++ b/drivers/net/e100/e100_eeprom.c Sun Mar 23 00:22:52 2003 @@ -1,7 +1,7 @@ /******************************************************************************* - Copyright(c) 1999 - 2002 Intel Corporation. All rights reserved. + Copyright(c) 1999 - 2003 Intel Corporation. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free diff -Nru a/drivers/net/e100/e100_main.c b/drivers/net/e100/e100_main.c --- a/drivers/net/e100/e100_main.c Sun Mar 23 00:22:53 2003 +++ b/drivers/net/e100/e100_main.c Sun Mar 23 00:22:53 2003 @@ -1,7 +1,7 @@ /******************************************************************************* - Copyright(c) 1999 - 2002 Intel Corporation. All rights reserved. + Copyright(c) 1999 - 2003 Intel Corporation. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -45,8 +45,22 @@ **********************************************************************/ /* Change Log - * - * 2.1.29 12/20/02 + * + * 2.2.21 02/11/03 + * o Removed marketing brand strings. Instead, Using generic string + * "Intel(R) PRO/100 Network Connection" for all adapters. + * o Implemented ethtool -S option + * o Strip /proc/net/PRO_LAN_Adapters files for kernel driver + * o Bug fix: Read wrong byte in EEPROM when offset is odd number + * o Bug fix: PHY loopback test fails on ICH devices + * o Bug fix: System panic on e100_close when repeating Hot Remove and + * Add in a team + * o Bug fix: Linux Bonding driver claims adapter's link loss because of + * not updating last_rx field + * o Bug fix: e100 does not check validity of MAC address + * o New feature: added ICH5 support + * + * 2.1.27 11/20/02 * o Bug fix: Device command timeout due to SMBus processing during init * o Bug fix: Not setting/clearing I (Interrupt) bit in tcb correctly * o Bug fix: Not using EEPROM WoL setting as default in ethtool @@ -62,15 +76,6 @@ * ifconfig down, rmmod and insmod * * 2.1.24 10/7/02 - * o Bug fix: Wrong files under /proc/net/PRO_LAN_Adapters/ when interface - * name is changed - * o Bug fix: Rx skb corruption when Rx polling code and Rx interrupt code - * are executing during stress traffic at shared interrupt system. - * Removed Rx polling code - * o Added detailed printk if selftest failed when insmod - * o Removed misleading printks - * - * 2.1.12 8/2/02 */ #include @@ -81,7 +86,8 @@ #include "e100_ucode.h" #include "e100_config.h" #include "e100_phy.h" -#include "e100_vendor.h" + +extern void e100_force_speed_duplex_to_phy(struct e100_private *bdp); static char e100_gstrings_stats[][ETH_GSTRING_LEN] = { "rx_packets", "tx_packets", "rx_bytes", "tx_bytes", "rx_errors", @@ -127,7 +133,6 @@ static int e100_ethtool_led_blink(struct net_device *, struct ifreq *); -#include static int e100_mii_ioctl(struct net_device *, struct ifreq *, int); static unsigned char e100_delayed_exec_non_cu_cmd(struct e100_private *, @@ -136,11 +141,15 @@ static void e100_non_tx_background(unsigned long); /* Global Data structures and variables */ -char e100_copyright[] __devinitdata = "Copyright (c) 2002 Intel Corporation"; -char e100_driver_version[]="2.1.29-k4"; +char e100_copyright[] __devinitdata = "Copyright (c) 2003 Intel Corporation"; +char e100_driver_version[]="2.2.21-k1"; const char *e100_full_driver_name = "Intel(R) PRO/100 Network Driver"; char e100_short_driver_name[] = "e100"; static int e100nics = 0; +static void e100_vlan_rx_register(struct net_device *netdev, struct vlan_group + *grp); +static void e100_vlan_rx_add_vid(struct net_device *netdev, u16 vid); +static void e100_vlan_rx_kill_vid(struct net_device *netdev, u16 vid); #ifdef CONFIG_PM static int e100_notify_reboot(struct notifier_block *, unsigned long event, void *ptr); @@ -186,7 +195,6 @@ static void e100_set_multi(struct net_device *); void e100_set_speed_duplex(struct e100_private *); -char *e100_get_brand_msg(struct e100_private *); static u8 e100_pci_setup(struct pci_dev *, struct e100_private *); static u8 e100_sw_init(struct e100_private *); static void e100_tco_workaround(struct e100_private *); @@ -220,6 +228,7 @@ char *); unsigned char e100_wait_exec_cmplx(struct e100_private *, u32, u8, u8); void e100_exec_cmplx(struct e100_private *, u32, u8); +static unsigned char e100_asf_enabled(struct e100_private *bdp); /** * e100_get_rx_struct - retrieve cell to hold skb buff from the pool @@ -607,7 +616,9 @@ } if (((bdp->pdev->device > 0x1030) - && (bdp->pdev->device < 0x103F)) + && (bdp->pdev->device < 0x103F)) + || ((bdp->pdev->device >= 0x1050) + && (bdp->pdev->device <= 0x1057)) || (bdp->pdev->device == 0x2449) || (bdp->pdev->device == 0x2459) || (bdp->pdev->device == 0x245D)) { @@ -646,6 +657,9 @@ goto err_pci; } + dev->vlan_rx_register = e100_vlan_rx_register; + dev->vlan_rx_add_vid = e100_vlan_rx_add_vid; + dev->vlan_rx_kill_vid = e100_vlan_rx_kill_vid; dev->irq = pcid->irq; dev->open = &e100_open; dev->hard_start_xmit = &e100_xmit_frame; @@ -655,9 +669,11 @@ dev->set_multicast_list = &e100_set_multi; dev->set_mac_address = &e100_set_mac; dev->do_ioctl = &e100_ioctl; - if (bdp->flags & USE_IPCB) { - dev->features |= NETIF_F_SG | NETIF_F_IP_CSUM; - } + + if (bdp->flags & USE_IPCB) + dev->features = NETIF_F_SG | NETIF_F_HW_CSUM | + NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX; + e100nics++; e100_get_speed_duplex_caps(bdp); @@ -668,25 +684,24 @@ memcpy(bdp->ifname, dev->name, IFNAMSIZ); bdp->ifname[IFNAMSIZ-1] = 0; - bdp->device_type = ent->driver_data; printk(KERN_NOTICE "e100: %s: %s\n", - bdp->device->name, e100_get_brand_msg(bdp)); + bdp->device->name, "Intel(R) PRO/100 Network Connection"); e100_print_brd_conf(bdp); - bdp->id_string = e100_get_brand_msg(bdp); bdp->wolsupported = 0; bdp->wolopts = 0; /* Check if WoL is enabled on EEPROM */ if (e100_eeprom_read(bdp, EEPROM_ID_WORD) & BIT_5) { + /* Magic Packet WoL is enabled on device by default */ + /* if EEPROM WoL bit is TRUE */ + bdp->wolsupported = WAKE_MAGIC; + bdp->wolopts = WAKE_MAGIC; if (bdp->rev_id >= D101A4_REV_ID) bdp->wolsupported = WAKE_PHY | WAKE_MAGIC; if (bdp->rev_id >= D101MA_REV_ID) bdp->wolsupported |= WAKE_UCAST | WAKE_ARP; - /* Magic Packet WoL is enabled on device by default */ - /* if EEPROM WoL bit is TRUE */ - bdp->wolopts = WAKE_MAGIC; } printk(KERN_NOTICE "\n"); @@ -752,6 +767,34 @@ --e100nics; } +static struct pci_device_id e100_id_table[] __devinitdata = { + {0x8086, 0x1229, PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, + {0x8086, 0x2449, PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, + {0x8086, 0x1059, PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, + {0x8086, 0x1209, PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, + {0x8086, 0x1029, PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, + {0x8086, 0x1030, PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, + {0x8086, 0x1031, PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, + {0x8086, 0x1032, PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, + {0x8086, 0x1033, PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, + {0x8086, 0x1034, PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, + {0x8086, 0x1038, PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, + {0x8086, 0x1039, PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, + {0x8086, 0x103A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, + {0x8086, 0x103B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, + {0x8086, 0x103C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, + {0x8086, 0x103D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, + {0x8086, 0x103E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, + {0x8086, 0x1050, PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, + {0x8086, 0x1051, PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, + {0x8086, 0x1052, PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, + {0x8086, 0x1053, PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, + {0x8086, 0x1054, PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, + {0x8086, 0x1055, PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, + {0x8086, 0x2459, PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, + {0x8086, 0x245D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, + {0,} /* This has to be the last entry*/ +}; MODULE_DEVICE_TABLE(pci, e100_id_table); static struct pci_driver e100_driver = { @@ -994,13 +1037,14 @@ { struct e100_private *bdp = dev->priv; + e100_disable_clear_intr(bdp); + free_irq(dev->irq, dev); bdp->intr_mask = SCB_INT_MASK; e100_isolate_driver(bdp); netif_carrier_off(bdp->device); bdp->cur_line_speed = 0; bdp->cur_dplx_mode = 0; - free_irq(dev->irq, dev); e100_clear_pools(bdp); return 0; @@ -1097,6 +1141,8 @@ int rc = -1; struct sockaddr *p_sockaddr = (struct sockaddr *) addr; + if (!is_valid_ether_addr(p_sockaddr->sa_data)) + return -EADDRNOTAVAIL; bdp = dev->priv; if (e100_setup_iaaddr(bdp, (u8 *) (p_sockaddr->sa_data))) { @@ -1231,6 +1277,10 @@ /* read the MAC address from the eprom */ e100_rd_eaddr(bdp); + if (!is_valid_ether_addr(bdp->device->dev_addr)) { + printk(KERN_ERR "e100: Invalid Ethernet address\n"); + return false; + } /* read NIC's part number */ e100_rd_pwa_no(bdp); @@ -1670,6 +1720,11 @@ } else { if (netif_running(dev)) netif_stop_queue(dev); + /* When changing to non-autoneg, device may lose */ + /* link with some switches. e100 will try to */ + /* revover link by sending command to PHY layer */ + if (bdp->params.e100_speed_duplex != E100_AUTONEG) + e100_force_speed_duplex_to_phy(bdp); } rmb(); @@ -1793,7 +1848,8 @@ bdp = dev->priv; intr_status = readw(&bdp->scb->scb_status); - if (!intr_status || (intr_status == 0xffff)) { + /* If not my interrupt, just return */ + if (!(intr_status & SCB_STATUS_ACK_MASK) || (intr_status == 0xffff)) { return; } @@ -1993,17 +2049,15 @@ } else { skb->ip_summed = CHECKSUM_NONE; } - switch (netif_rx(skb)) { - case NET_RX_BAD: - case NET_RX_DROP: - case NET_RX_CN_MOD: - case NET_RX_CN_HIGH: - break; - default: - bdp->drv_stats.net_stats.rx_bytes += skb->len; - break; - } + if(bdp->vlgrp && (rfd_status & CB_STATUS_VLAN)) { + vlan_hwaccel_rx(skb, bdp->vlgrp, be16_to_cpu(rfd->vlanid)); + } else { + netif_rx(skb); + } + dev->last_rx = jiffies; + bdp->drv_stats.net_stats.rx_bytes += skb->len; + rfd_cnt++; } /* end of rfd loop */ @@ -2096,6 +2150,11 @@ tcb->tcbu.ipcb.ip_schedule &= ~IPCB_TCPUDP_CHECKSUM_ENABLE; } + if(bdp->vlgrp && vlan_tx_tag_present(skb)) { + (tcb->tcbu).ipcb.ip_activation_high |= IPCB_INSERTVLAN_ENABLE; + (tcb->tcbu).ipcb.vlan = cpu_to_be16(vlan_tx_tag_get(skb)); + } + tcb->tcb_hdr.cb_status = 0; tcb->tcb_thrshld = bdp->tx_thld; tcb->tcb_hdr.cb_cmd |= __constant_cpu_to_le16(CB_S_BIT); @@ -2114,7 +2173,8 @@ if ((ip->protocol == IPPROTO_TCP) || (ip->protocol == IPPROTO_UDP)) { - tcb->tcbu.ipcb.ip_activation_high = + + tcb->tcbu.ipcb.ip_activation_high |= IPCB_HARDWAREPARSING_ENABLE; tcb->tcbu.ipcb.ip_schedule |= IPCB_TCPUDP_CHECKSUM_ENABLE; @@ -2682,13 +2742,12 @@ udelay(20); } - /* Mask off our interrupt line -- its unmasked after reset */ + /* Mask off our interrupt line -- it is unmasked after reset */ e100_disable_clear_intr(bdp); #ifdef E100_CU_DEBUG bdp->last_cmd = 0; bdp->last_sub_cmd = 0; #endif - } /** @@ -2901,27 +2960,6 @@ } /** - * e100_get_brand_msg - * @bdp: atapter's private data struct - * - * This routine checks if there is specified branding message for a given board - * type and returns a pointer to the string containing the branding message. - */ -char * -e100_get_brand_msg(struct e100_private *bdp) -{ - int i; - - for (i = 0; e100_vendor_info_array[i].idstr != NULL; i++) { - if (e100_vendor_info_array[i].device_type == bdp->device_type) { - return e100_vendor_info_array[i].idstr; - } - } - - return e100_vendor_info_array[E100_ALL_BOARDS].idstr; -} - -/** * e100_pci_setup - setup the adapter's PCI information * @pcid: adapter's pci_dev struct * @bdp: atapter's private data struct @@ -3004,12 +3042,17 @@ void e100_set_speed_duplex(struct e100_private *bdp) { - if (netif_carrier_ok(bdp->device)) + int carrier_ok; + /* Device may lose link with some siwtches when */ + /* changing speed/duplex to non-autoneg. e100 */ + /* needs to remember carrier state in order to */ + /* start watchdog timer for recovering link */ + if ((carrier_ok = netif_carrier_ok(bdp->device))) e100_isolate_driver(bdp); e100_phy_set_speed_duplex(bdp, true); e100_config_fc(bdp); /* re-config flow-control if necessary */ e100_config(bdp); - if (netif_carrier_ok(bdp->device)) + if (carrier_ok) e100_deisolate_driver(bdp, false); } @@ -3426,6 +3469,7 @@ u16 first_word, last_word; int i, max_len; void *ptr; + u8 *eeprom_data_bytes = (u8 *)eeprom_data; if (!capable(CAP_NET_ADMIN)) return -EPERM; @@ -3461,7 +3505,9 @@ if (copy_to_user(ifr->ifr_data, &ecmd, sizeof (ecmd))) return -EFAULT; - if (copy_to_user(usr_eeprom_ptr, eeprom_data, ecmd.len)) + if(ecmd.offset & 1) + eeprom_data_bytes++; + if (copy_to_user(usr_eeprom_ptr, eeprom_data_bytes, ecmd.len)) return -EFAULT; } else { if (ecmd.magic != E100_EEPROM_MAGIC) @@ -3754,7 +3800,8 @@ return -EFAULT; switch (info.string_set) { - case ETH_SS_TEST: + case ETH_SS_TEST: { + int ret = 0; if (info.len > E100_MAX_TEST_RES) info.len = E100_MAX_TEST_RES; strings = kmalloc(info.len * ETH_GSTRING_LEN, GFP_ATOMIC); @@ -3766,7 +3813,13 @@ sprintf(strings + i * ETH_GSTRING_LEN, "%-31s", test_strings[i]); } - break; + if (copy_to_user(ifr->ifr_data, &info, sizeof (info))) + ret = -EFAULT; + if (copy_to_user(usr_strings, strings, info.len * ETH_GSTRING_LEN)) + ret = -EFAULT; + kfree(strings); + return ret; + } case ETH_SS_STATS: { char *strings = NULL; void *addr = ifr->ifr_data; @@ -3783,19 +3836,6 @@ default: return -EOPNOTSUPP; } - - if (copy_to_user(ifr->ifr_data, &info, sizeof (info))) { - kfree(strings); - return -EFAULT; - } - - if (copy_to_user(usr_strings, strings, info.len * ETH_GSTRING_LEN)) { - kfree(strings); - return -EFAULT; - } - - kfree(strings); - return 0; } static int @@ -4022,6 +4062,45 @@ spin_unlock_bh(&(bdp->bd_non_tx_lock)); } +static void +e100_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp) +{ + struct e100_private *bdp = netdev->priv; + + e100_disable_clear_intr(bdp); + bdp->vlgrp = grp; + + if(grp) { + /* enable VLAN tag insert/strip */ + e100_config_vlan_drop(bdp, true); + + } else { + /* disable VLAN tag insert/strip */ + e100_config_vlan_drop(bdp, false); + } + + e100_config(bdp); + e100_set_intr_mask(bdp); +} + +static void +e100_vlan_rx_add_vid(struct net_device *netdev, u16 vid) +{ + /* We don't do Vlan filtering */ + return; +} + +static void +e100_vlan_rx_kill_vid(struct net_device *netdev, u16 vid) +{ + struct e100_private *bdp = netdev->priv; + + if(bdp->vlgrp) + bdp->vlgrp->vlan_devices[vid] = NULL; + /* We don't do Vlan filtering */ + return; +} + #ifdef CONFIG_PM static int e100_notify_reboot(struct notifier_block *nb, unsigned long event, void *p) @@ -4057,7 +4136,7 @@ e100_do_wol(pcid, bdp); /* If wol is enabled */ - if (bdp->wolopts) { + if (bdp->wolopts || e100_asf_enabled(bdp)) { pci_enable_wake(pcid, 3, 1); /* Enable PME for power state D3 */ pci_set_power_state(pcid, 3); /* Set power state to D3. */ } else { @@ -4084,6 +4163,31 @@ return 0; } #endif /* CONFIG_PM */ + +/** + * e100_asf_enabled - checks if ASF is configured on the current adaper + * by reading registers 0xD and 0x90 in the EEPROM + * @bdp: atapter's private data struct + * + * Returns: true if ASF is enabled + */ +static unsigned char +e100_asf_enabled(struct e100_private *bdp) +{ + u16 asf_reg; + u16 smbus_addr_reg; + if ((bdp->pdev->device >= 0x1050) && (bdp->pdev->device <= 0x1055)) { + asf_reg = e100_eeprom_read(bdp, EEPROM_CONFIG_ASF); + if ((asf_reg & EEPROM_FLAG_ASF) + && !(asf_reg & EEPROM_FLAG_GCL)) { + smbus_addr_reg = + e100_eeprom_read(bdp, EEPROM_SMBUS_ADDR); + if ((smbus_addr_reg & 0xFF) != 0xFE) + return true; + } + } + return false; +} #ifdef E100_CU_DEBUG unsigned char diff -Nru a/drivers/net/e100/e100_phy.c b/drivers/net/e100/e100_phy.c --- a/drivers/net/e100/e100_phy.c Sun Mar 23 00:22:49 2003 +++ b/drivers/net/e100/e100_phy.c Sun Mar 23 00:22:49 2003 @@ -1,7 +1,7 @@ /******************************************************************************* - Copyright(c) 1999 - 2002 Intel Corporation. All rights reserved. + Copyright(c) 1999 - 2003 Intel Corporation. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -636,7 +636,6 @@ control &= ~BMCR_ANENABLE; control &= ~BMCR_LOOPBACK; - /* Check e100.c values */ switch (bdp->params.e100_speed_duplex) { case E100_SPEED_10_HALF: control &= ~BMCR_SPEED100; @@ -680,6 +679,41 @@ } } while (true); +} + +void +e100_force_speed_duplex_to_phy(struct e100_private *bdp) +{ + u16 control; + + e100_mdi_read(bdp, MII_BMCR, bdp->phy_addr, &control); + control &= ~BMCR_ANENABLE; + control &= ~BMCR_LOOPBACK; + + switch (bdp->params.e100_speed_duplex) { + case E100_SPEED_10_HALF: + control &= ~BMCR_SPEED100; + control &= ~BMCR_FULLDPLX; + break; + + case E100_SPEED_10_FULL: + control &= ~BMCR_SPEED100; + control |= BMCR_FULLDPLX; + break; + + case E100_SPEED_100_HALF: + control |= BMCR_SPEED100; + control &= ~BMCR_FULLDPLX; + break; + + case E100_SPEED_100_FULL: + control |= BMCR_SPEED100; + control |= BMCR_FULLDPLX; + break; + } + + /* Send speed/duplex command to PHY layer. */ + e100_mdi_write(bdp, MII_BMCR, bdp->phy_addr, control); } /* diff -Nru a/drivers/net/e100/e100_phy.h b/drivers/net/e100/e100_phy.h --- a/drivers/net/e100/e100_phy.h Sun Mar 23 00:22:51 2003 +++ b/drivers/net/e100/e100_phy.h Sun Mar 23 00:22:51 2003 @@ -1,7 +1,7 @@ /******************************************************************************* - Copyright(c) 1999 - 2002 Intel Corporation. All rights reserved. + Copyright(c) 1999 - 2003 Intel Corporation. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -29,8 +29,6 @@ #define _E100_PHY_INC_ #include "e100.h" - -#include /* * Auto-polarity enable/disable diff -Nru a/drivers/net/e100/e100_test.c b/drivers/net/e100/e100_test.c --- a/drivers/net/e100/e100_test.c Sun Mar 23 00:22:52 2003 +++ b/drivers/net/e100/e100_test.c Sun Mar 23 00:22:52 2003 @@ -1,7 +1,7 @@ /******************************************************************************* - Copyright(c) 1999 - 2002 Intel Corporation. All rights reserved. + Copyright(c) 1999 - 2003 Intel Corporation. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -242,6 +242,9 @@ *dynamic_tbd = e100_config_dynamic_tbd(bdp,*dynamic_tbd); if (set_loopback) { + /* ICH PHY loopback is broken */ + if (bdp->flags & IS_ICH && loopback_mode == PHY_LOOPBACK) + loopback_mode = MAC_LOOPBACK; /* Configure loopback on MAC */ e100_config_loopback_mode(bdp,loopback_mode); } else { diff -Nru a/drivers/net/e100/e100_ucode.h b/drivers/net/e100/e100_ucode.h --- a/drivers/net/e100/e100_ucode.h Sun Mar 23 00:22:55 2003 +++ b/drivers/net/e100/e100_ucode.h Sun Mar 23 00:22:55 2003 @@ -1,7 +1,7 @@ /******************************************************************************* - Copyright(c) 1999 - 2002 Intel Corporation. All rights reserved. + Copyright(c) 1999 - 2003 Intel Corporation. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free diff -Nru a/drivers/net/e100/e100_vendor.h b/drivers/net/e100/e100_vendor.h --- a/drivers/net/e100/e100_vendor.h Sun Mar 23 00:22:55 2003 +++ /dev/null Wed Dec 31 16:00:00 1969 @@ -1,311 +0,0 @@ -/******************************************************************************* - - - Copyright(c) 1999 - 2002 Intel Corporation. All rights reserved. - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along with - this program; if not, write to the Free Software Foundation, Inc., 59 - Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The full GNU General Public License is included in this distribution in the - file called LICENSE. - - Contact Information: - Linux NICS - Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 -*******************************************************************************/ - -#ifndef E100_VENDOR_ID_INFO -#define E100_VENDOR_ID_INFO -/* ====================================================================== */ -/* vendor_info */ -/* ====================================================================== */ - -struct e100_vendor_info { - unsigned long device_type; - char *idstr; -}; - -enum e100_device_type { - E100_BRD_100TX = 1, - E100_BRD_100T4, - E100_BRD_10T, - E100_BRD_100WFM, - E100_BRD_82557, - E100_BRD_82557_WOL, - E100_BRD_82558, - E100_BRD_82558_WOL, - E100_BRD_100, - E100_BRD_100M, - E100_BRD_AOL2, - E100_BRD_AOL, - E100_PROS_M, - E100_PROS_AM, - E100_PROS_AM_AOL, - E100_PROS_DT, - E100_PRO_DT, - E100_PROM_DT, - E100_PRO_SRV, - E100_PRO_SRVP, - E100_PROS_SRV, - E100_PRO_DUAL, - E100_PROS_DUAL, - E100_PROP_DUAL, - E100_PROP_WOL, - E100_PROS_MOB, - E100_PRO_CB, - E100_PRO_CB_M, - E100_PROSR_MOB, - E100_PROS_MC, - E100_PROSR_MC, - E100_PROP_MC, - E100_PROSP_MC, - E100_PROP_MOB, - E100_PROSP_MOB, - E100_PRO_MINI, - E100_PRO_NET, - E100_PROS_NET, - E100_PROVM_NET, - E100_PROVE_D, - E100_82559_LOM, - E100_82559_LOM_AOL, - E100_82559_LOM_AOL2, - E100_82559_LOM_DELL, - E100_IBM_MDS, - E100_CMPQ_S, - E100_PROVE_DA, - E100_PROVM_DA, - E100_PROVE_LOM, - E100_PROVE_NET, - E100_82562, - E100_82551QM, - E100_ALL_BOARDS -}; - -struct e100_vendor_info e100_vendor_info_array[] = { - { E100_BRD_100TX, "Intel(R) PRO/100B PCI Adapter (TX)"}, - { E100_BRD_100T4, "Intel(R) PRO/100B PCI Adapter (T4)"}, - { E100_BRD_10T, "Intel(R) PRO/10+ PCI Adapter"}, - { E100_BRD_100WFM, "Intel(R) PRO/100 WfM PCI Adapter"}, - { E100_BRD_82557, "Intel(R) 82557-based Integrated Ethernet PCI (10/100)"}, - { E100_BRD_82557_WOL, "Intel(R) 82557-based Integrated Ethernet with Wake on LAN*"}, - { E100_BRD_82558, "Intel(R) 82558-based Integrated Ethernet"}, - { E100_BRD_82558_WOL, "Intel(R) 82558-based Integrated Ethernet with Wake on LAN*"}, - { E100_BRD_100, "Intel(R) PRO/100+ PCI Adapter"}, - { E100_BRD_100M, "Intel(R) PRO/100+ Management Adapter"}, - { E100_BRD_AOL2, "Intel(R) PRO/100+ Alert on LAN* 2 Management Adapter"}, - { E100_82559_LOM_DELL, "Intel(R) 8255x Based Network Connection"}, - { E100_BRD_AOL, "Intel(R) PRO/100+ Alert on LAN* Management Adapter"}, - { E100_PROS_M, "Intel(R) PRO/100 S Management Adapter"}, - { E100_PROS_AM, "Intel(R) PRO/100 S Advanced Management Adapter"}, - { E100_PROS_AM_AOL, "Intel(R) PRO/100+ Management Adapter with Alert On LAN* GC"}, - { E100_PROS_DT, "Intel(R) PRO/100 S Desktop Adapter"}, - { E100_PRO_DT, "Intel(R) PRO/100 Desktop Adapter"}, - { E100_PROM_DT, "Intel(R) PRO/100 M Desktop Adapter"}, - { E100_PRO_SRV, "Intel(R) PRO/100+ Server Adapter"}, - { E100_PRO_SRVP, "Intel(R) PRO/100+ Server Adapter (PILA8470B)"}, - { E100_PROS_SRV, "Intel(R) PRO/100 S Server Adapter"}, - { E100_PRO_DUAL, "Intel(R) PRO/100 Dual Port Server Adapter"}, - { E100_PROS_DUAL, "Intel(R) PRO/100 S Dual Port Server Adapter"}, - { E100_PROP_DUAL, "Intel(R) PRO/100+ Dual Port Server Adapter"}, - { E100_PROP_WOL, "Intel(R) PRO/100+ Management Adapter with Alert On LAN* G Server"}, - { E100_PROS_MOB, "Intel(R) PRO/100 S Mobile Adapter"}, - { E100_PRO_CB, "Intel(R) PRO/100 CardBus II"}, - { E100_PRO_CB_M, "Intel(R) PRO/100 LAN+Modem56 CardBus II"}, - { E100_PROSR_MOB, "Intel(R) PRO/100 SR Mobile Adapter"}, - { E100_PROS_MC, "Intel(R) PRO/100 S Mobile Combo Adapter"}, - { E100_PROSR_MC, "Intel(R) PRO/100 SR Mobile Combo Adapter"}, - { E100_PROP_MC, "Intel(R) PRO/100 P Mobile Combo Adapter"}, - { E100_PROSP_MC, "Intel(R) PRO/100 SP Mobile Combo Adapter"}, - { E100_PROP_MOB, "Intel(R) PRO/100 P Mobile Adapter"}, - { E100_PROSP_MOB, "Intel(R) PRO/100 SP Mobile Adapter"}, - { E100_PRO_MINI, "Intel(R) PRO/100+ Mini PCI"}, - { E100_PRO_NET, "Intel(R) PRO/100 Network Connection" }, - { E100_PROS_NET, "Intel(R) PRO/100 S Network Connection" }, - { E100_PROVM_NET, "Intel(R) PRO/100 VM Network Connection"}, - { E100_PROVE_D, "Intel(R) PRO/100 VE Desktop Connection"}, - { E100_82559_LOM, "Intel(R) 82559 Fast Ethernet LAN on Motherboard"}, - { E100_82559_LOM_AOL, "Intel(R) 82559 Fast Ethernet LOM with Alert on LAN*" }, - { E100_82559_LOM_AOL2, "Intel(R) 82559 Fast Ethernet LOM with Alert on LAN* 2" }, - { E100_IBM_MDS, "IBM Mobile, Desktop & Server Adapters"}, - { E100_CMPQ_S, "Compaq Fast Ethernet Server Adapter" }, - { E100_PROVE_DA, "Intel(R) PRO/100 VE Desktop Adapter"}, - { E100_PROVM_DA, "Intel(R) PRO/100 VM Desktop Adapter"}, - { E100_PROVE_LOM, "Intel(R) PRO/100 VE Network ConnectionPLC LOM" }, - { E100_PROVE_NET, "Intel(R) PRO/100 VE Network Connection"}, - { E100_82562, "Intel(R)82562 based Fast Ethernet Connection"}, - { E100_82551QM, "Intel(R) PRO/100 M Mobile Connection"}, - { E100_ALL_BOARDS, "Intel(R) 8255x-based Ethernet Adapter"}, - {0,NULL} -}; - -static struct pci_device_id e100_id_table[] __devinitdata = { - {0x8086, 0x1229, 0x8086, 0x0001, 0, 0, E100_BRD_100TX}, - {0x8086, 0x1229, 0x8086, 0x0002, 0, 0, E100_BRD_100T4}, - {0x8086, 0x1229, 0x8086, 0x0003, 0, 0, E100_BRD_10T}, - {0x8086, 0x1229, 0x8086, 0x0004, 0, 0, E100_BRD_100WFM}, - {0x8086, 0x1229, 0x8086, 0x0005, 0, 0, E100_BRD_82557}, - {0x8086, 0x1229, 0x8086, 0x0006, 0, 0, E100_BRD_82557_WOL}, - {0x8086, 0x1229, 0x8086, 0x0002, 0, 0, E100_BRD_100T4}, - {0x8086, 0x1229, 0x8086, 0x0003, 0, 0, E100_BRD_10T}, - {0x8086, 0x1229, 0x8086, 0x0004, 0, 0, E100_BRD_100WFM}, - {0x8086, 0x1229, 0x8086, 0x0005, 0, 0, E100_BRD_82557}, - {0x8086, 0x1229, 0x8086, 0x0006, 0, 0, E100_BRD_82557_WOL}, - {0x8086, 0x1229, 0x8086, 0x0007, 0, 0, E100_BRD_82558}, - {0x8086, 0x1229, 0x8086, 0x0008, 0, 0, E100_BRD_82558_WOL}, - {0x8086, 0x1229, 0x8086, 0x0009, 0, 0, E100_BRD_100}, - {0x8086, 0x1229, 0x8086, 0x000A, 0, 0, E100_BRD_100M}, - {0x8086, 0x1229, 0x8086, 0x000B, 0, 0, E100_BRD_100}, - {0x8086, 0x1229, 0x8086, 0x000C, 0, 0, E100_BRD_100M}, - {0x8086, 0x1229, 0x8086, 0x000D, 0, 0, E100_BRD_AOL2}, - {0x8086, 0x1229, 0x8086, 0x000E, 0, 0, E100_BRD_AOL}, - {0x8086, 0x1229, 0x8086, 0x0010, 0, 0, E100_PROS_M}, - {0x8086, 0x1229, 0x8086, 0x0011, 0, 0, E100_PROS_M}, - {0x8086, 0x1229, 0x8086, 0x0012, 0, 0, E100_PROS_AM}, - {0x8086, 0x1229, 0x8086, 0x0013, 0, 0, E100_PROS_AM}, - {0x8086, 0x1229, 0x8086, 0x0030, 0, 0, E100_PROS_AM_AOL}, - {0x8086, 0x1229, 0x8086, 0x0040, 0, 0, E100_PROS_DT}, - {0x8086, 0x1229, 0x8086, 0x0041, 0, 0, E100_PROS_DT}, - {0x8086, 0x1229, 0x8086, 0x0042, 0, 0, E100_PRO_DT}, - {0x8086, 0x1229, 0x8086, 0x0050, 0, 0, E100_PROS_DT}, - {0x8086, 0x1229, 0x8086, 0x0070, 0, 0, E100_PROM_DT}, - {0x8086, 0x1229, 0x8086, 0x1009, 0, 0, E100_PRO_SRV}, - {0x8086, 0x1229, 0x8086, 0x100C, 0, 0, E100_PRO_SRVP}, - {0x8086, 0x1229, 0x8086, 0x1012, 0, 0, E100_PROS_SRV}, - {0x8086, 0x1229, 0x8086, 0x1013, 0, 0, E100_PROS_SRV}, - {0x8086, 0x1229, 0x8086, 0x1014, 0, 0, E100_PRO_DUAL}, - {0x8086, 0x1229, 0x8086, 0x1015, 0, 0, E100_PROS_DUAL}, - {0x8086, 0x1229, 0x8086, 0x1016, 0, 0, E100_PROS_DUAL}, - {0x8086, 0x1229, 0x8086, 0x1017, 0, 0, E100_PROP_DUAL}, - {0x8086, 0x1229, 0x8086, 0x1030, 0, 0, E100_PROP_WOL}, - {0x8086, 0x1229, 0x8086, 0x1040, 0, 0, E100_PROS_SRV}, - {0x8086, 0x1229, 0x8086, 0x1041, 0, 0, E100_PROS_SRV}, - {0x8086, 0x1229, 0x8086, 0x1042, 0, 0, E100_PRO_SRV}, - {0x8086, 0x1229, 0x8086, 0x1050, 0, 0, E100_PROS_SRV}, - {0x8086, 0x1229, 0x8086, 0x10F0, 0, 0, E100_PROP_DUAL}, - {0x8086, 0x1229, 0x8086, 0x10F0, 0, 0, E100_PROP_DUAL}, - {0x8086, 0x1229, 0x8086, 0x2009, 0, 0, E100_PROS_MOB}, - {0x8086, 0x1229, 0x8086, 0x200D, 0, 0, E100_PRO_CB}, - {0x8086, 0x1229, 0x8086, 0x200E, 0, 0, E100_PRO_CB_M}, - {0x8086, 0x1229, 0x8086, 0x200F, 0, 0, E100_PROSR_MOB}, - {0x8086, 0x1229, 0x8086, 0x2010, 0, 0, E100_PROS_MC}, - {0x8086, 0x1229, 0x8086, 0x2013, 0, 0, E100_PROSR_MC}, - {0x8086, 0x1229, 0x8086, 0x2016, 0, 0, E100_PROS_MOB}, - {0x8086, 0x1229, 0x8086, 0x2017, 0, 0, E100_PROS_MC}, - {0x8086, 0x1229, 0x8086, 0x2018, 0, 0, E100_PROSR_MOB}, - {0x8086, 0x1229, 0x8086, 0x2019, 0, 0, E100_PROSR_MC}, - {0x8086, 0x1229, 0x8086, 0x2101, 0, 0, E100_PROP_MOB}, - {0x8086, 0x1229, 0x8086, 0x2102, 0, 0, E100_PROSP_MOB}, - {0x8086, 0x1229, 0x8086, 0x2103, 0, 0, E100_PROSP_MOB}, - {0x8086, 0x1229, 0x8086, 0x2104, 0, 0, E100_PROSP_MOB}, - {0x8086, 0x1229, 0x8086, 0x2105, 0, 0, E100_PROSP_MOB}, - {0x8086, 0x1229, 0x8086, 0x2106, 0, 0, E100_PROP_MOB}, - {0x8086, 0x1229, 0x8086, 0x2107, 0, 0, E100_PRO_NET}, - {0x8086, 0x1229, 0x8086, 0x2108, 0, 0, E100_PRO_NET}, - {0x8086, 0x1229, 0x8086, 0x2200, 0, 0, E100_PROP_MC}, - {0x8086, 0x1229, 0x8086, 0x2201, 0, 0, E100_PROP_MC}, - {0x8086, 0x1229, 0x8086, 0x2202, 0, 0, E100_PROSP_MC}, - {0x8086, 0x1229, 0x8086, 0x2203, 0, 0, E100_PRO_MINI}, - {0x8086, 0x1229, 0x8086, 0x2204, 0, 0, E100_PRO_MINI}, - {0x8086, 0x1229, 0x8086, 0x2205, 0, 0, E100_PROSP_MC}, - {0x8086, 0x1229, 0x8086, 0x2206, 0, 0, E100_PROSP_MC}, - {0x8086, 0x1229, 0x8086, 0x2207, 0, 0, E100_PROSP_MC}, - {0x8086, 0x1229, 0x8086, 0x2208, 0, 0, E100_PROP_MC}, - {0x8086, 0x1229, 0x8086, 0x2408, 0, 0, E100_PRO_MINI}, - {0x8086, 0x1229, 0x8086, 0x240F, 0, 0, E100_PRO_MINI}, - {0x8086, 0x1229, 0x8086, 0x2411, 0, 0, E100_PRO_MINI}, - {0x8086, 0x1229, 0x8086, 0x3400, 0, 0, E100_82559_LOM}, - {0x8086, 0x1229, 0x8086, 0x3000, 0, 0, E100_82559_LOM}, - {0x8086, 0x1229, 0x8086, 0x3001, 0, 0, E100_82559_LOM_AOL}, - {0x8086, 0x1229, 0x8086, 0x3002, 0, 0, E100_82559_LOM_AOL2}, - {0x8086, 0x1229, 0x8086, 0x3006, 0, 0, E100_PROS_NET}, - {0x8086, 0x1229, 0x8086, 0x3007, 0, 0, E100_PROS_NET}, - {0x8086, 0x1229, 0x8086, 0x3008, 0, 0, E100_PRO_NET}, - {0x8086, 0x1229, 0x8086, 0x3010, 0, 0, E100_PROS_NET}, - {0x8086, 0x1229, 0x8086, 0x3011, 0, 0, E100_PROS_NET}, - {0x8086, 0x1229, 0x8086, 0x3012, 0, 0, E100_PRO_NET}, - {0x8086, 0x1229, 0x1014, 0x005C, 0, 0, E100_IBM_MDS}, - {0x8086, 0x1229, 0x1014, 0x305C, 0, 0, E100_IBM_MDS}, - {0x8086, 0x1229, 0x1014, 0x405C, 0, 0, E100_IBM_MDS}, - {0x8086, 0x1229, 0x1014, 0x605C, 0, 0, E100_IBM_MDS}, - {0x8086, 0x1229, 0x1014, 0x505C, 0, 0, E100_IBM_MDS}, - {0x8086, 0x1229, 0x1014, 0x105C, 0, 0, E100_IBM_MDS}, - {0x8086, 0x1229, 0x1014, 0x805C, 0, 0, E100_IBM_MDS}, - {0x8086, 0x1229, 0x1014, 0x705C, 0, 0, E100_IBM_MDS}, - {0x8086, 0x1229, 0x1014, 0x01F1, 0, 0, E100_IBM_MDS}, - {0x8086, 0x1229, 0x1014, 0x0232, 0, 0, E100_IBM_MDS}, - {0x8086, 0x1229, 0x1014, 0x0207, 0, 0, E100_PRO_NET}, - {0x8086, 0x1229, 0x1014, 0x023F, 0, 0, E100_PRO_NET}, - {0x8086, 0x1229, 0x1014, 0x01BC, 0, 0, E100_PRO_NET}, - {0x8086, 0x1229, 0x1014, 0x01CE, 0, 0, E100_PRO_NET}, - {0x8086, 0x1229, 0x1014, 0x01DC, 0, 0, E100_PRO_NET}, - {0x8086, 0x1229, 0x1014, 0x01EB, 0, 0, E100_PRO_NET}, - {0x8086, 0x1229, 0x1014, 0x01EC, 0, 0, E100_PRO_NET}, - {0x8086, 0x1229, 0x1014, 0x0202, 0, 0, E100_PRO_NET}, - {0x8086, 0x1229, 0x1014, 0x0205, 0, 0, E100_PRO_NET}, - {0x8086, 0x1229, 0x1014, 0x0217, 0, 0, E100_PRO_NET}, - {0x8086, 0x1229, 0x0E11, 0xB01E, 0, 0, E100_CMPQ_S}, - {0x8086, 0x1229, 0x0E11, 0xB02F, 0, 0, E100_CMPQ_S}, - {0x8086, 0x1229, 0x0E11, 0xB04A, 0, 0, E100_CMPQ_S}, - {0x8086, 0x1229, 0x0E11, 0xB0C6, 0, 0, E100_CMPQ_S}, - {0x8086, 0x1229, 0x0E11, 0xB0C7, 0, 0, E100_CMPQ_S}, - {0x8086, 0x1229, 0x0E11, 0xB0D7, 0, 0, E100_CMPQ_S}, - {0x8086, 0x1229, 0x0E11, 0xB0DD, 0, 0, E100_CMPQ_S}, - {0x8086, 0x1229, 0x0E11, 0xB0DE, 0, 0, E100_CMPQ_S}, - {0x8086, 0x1229, 0x0E11, 0xB0E1, 0, 0, E100_CMPQ_S}, - {0x8086, 0x1229, 0x0E11, 0xB134, 0, 0, E100_CMPQ_S}, - {0x8086, 0x1229, 0x0E11, 0xB13C, 0, 0, E100_CMPQ_S}, - {0x8086, 0x1229, 0x0E11, 0xB144, 0, 0, E100_CMPQ_S}, - {0x8086, 0x1229, 0x0E11, 0xB163, 0, 0, E100_CMPQ_S}, - {0x8086, 0x1229, 0x0E11, 0xB164, 0, 0, E100_CMPQ_S}, - {0x8086, 0x1229, 0x1028, PCI_ANY_ID, 0, 0, E100_82559_LOM_DELL}, - {0x8086, 0x1229, PCI_ANY_ID, PCI_ANY_ID, 0, 0, E100_ALL_BOARDS}, - - {0x8086, 0x2449, 0x1014, 0x0265, 0, 0, E100_PROVE_D}, - {0x8086, 0x2449, 0x1014, 0x0267, 0, 0, E100_PROVE_D}, - {0x8086, 0x2449, 0x1014, 0x026A, 0, 0, E100_PROVE_D}, - {0x8086, 0x2449, 0x8086, 0x3010, 0, 0, E100_PROVE_DA}, - {0x8086, 0x2449, 0x8086, 0x3011, 0, 0, E100_PROVM_DA}, - {0x8086, 0x2449, 0x8086, 0x3013, 0, 0, E100_PROVE_NET}, - {0x8086, 0x2449, 0x8086, 0x3014, 0, 0, E100_PROVM_NET}, - {0x8086, 0x2449, 0x8086, 0x3016, 0, 0, E100_PROP_MC}, - {0x8086, 0x2449, 0x8086, 0x3017, 0, 0, E100_PROP_MOB}, - {0x8086, 0x2449, 0x8086, 0x3018, 0, 0, E100_PRO_NET}, - {0x8086, 0x2449, 0x0E11, PCI_ANY_ID, 0, 0, E100_PROVM_NET}, - {0x8086, 0x2449, 0x1014, PCI_ANY_ID, 0, 0, E100_PROVE_D}, - {0x8086, 0x2449, PCI_ANY_ID, PCI_ANY_ID, 0, 0, E100_ALL_BOARDS}, - - {0x8086, 0x1059, 0x1179, 0x0005, 0, 0, E100_82551QM}, - {0x8086, 0x1059, 0x1033, 0x8191, 0, 0, E100_82551QM}, - {0x8086, 0x1059, PCI_ANY_ID, PCI_ANY_ID, 0, 0, E100_82551QM}, - - {0x8086, 0x1209, PCI_ANY_ID, PCI_ANY_ID, 0, 0, E100_ALL_BOARDS}, - {0x8086, 0x1029, PCI_ANY_ID, PCI_ANY_ID, 0, 0, E100_ALL_BOARDS}, - {0x8086, 0x1030, PCI_ANY_ID, PCI_ANY_ID, 0, 0, E100_ALL_BOARDS}, - {0x8086, 0x1031, PCI_ANY_ID, PCI_ANY_ID, 0, 0, E100_PROVE_NET}, - {0x8086, 0x1032, PCI_ANY_ID, PCI_ANY_ID, 0, 0, E100_PROVE_NET}, - {0x8086, 0x1033, PCI_ANY_ID, PCI_ANY_ID, 0, 0, E100_PROVM_NET}, - {0x8086, 0x1034, PCI_ANY_ID, PCI_ANY_ID, 0, 0, E100_PROVM_NET}, - {0x8086, 0x1038, PCI_ANY_ID, PCI_ANY_ID, 0, 0, E100_PROVM_NET}, - {0x8086, 0x1039, PCI_ANY_ID, PCI_ANY_ID, 0, 0, E100_PROVE_NET}, - {0x8086, 0x103A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, E100_PROVE_NET}, - {0x8086, 0x103B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, E100_PROVM_NET}, - {0x8086, 0x103C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, E100_PROVM_NET}, - {0x8086, 0x103D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, E100_PROVE_NET}, - {0x8086, 0x103E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, E100_PROVM_NET}, - {0x8086, 0x2459, PCI_ANY_ID, PCI_ANY_ID, 0, 0, E100_82562}, - {0x8086, 0x245D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, E100_82562}, - {0,} /* This has to be the last entry*/ -}; - -#endif /* E100_VENDOR_ID_INFO */ diff -Nru a/drivers/net/e1000/e1000.h b/drivers/net/e1000/e1000.h --- a/drivers/net/e1000/e1000.h Sun Mar 23 00:22:49 2003 +++ b/drivers/net/e1000/e1000.h Sun Mar 23 00:22:49 2003 @@ -1,7 +1,7 @@ /******************************************************************************* - Copyright(c) 1999 - 2002 Intel Corporation. All rights reserved. + Copyright(c) 1999 - 2003 Intel Corporation. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -65,6 +65,7 @@ #include #include #include +#include #include #include @@ -95,6 +96,15 @@ #define E1000_RXBUFFER_8192 8192 #define E1000_RXBUFFER_16384 16384 +/* SmartSpeed delimiters */ +#define E1000_SMARTSPEED_DOWNSHIFT 3 +#define E1000_SMARTSPEED_MAX 15 + +/* Packet Buffer allocations */ +#define E1000_TX_FIFO_SIZE_SHIFT 0xA +#define E1000_TX_HEAD_ADDR_SHIFT 7 +#define E1000_PBA_TX_MASK 0xFFFF0000 + /* Flow Control High-Watermark: 43464 bytes */ #define E1000_FC_HIGH_THRESH 0xA9C8 @@ -107,10 +117,7 @@ /* How many Tx Descriptors do we need to call netif_wake_queue ? */ #define E1000_TX_QUEUE_WAKE 16 /* How many Rx Buffers do we bundle into one write to the hardware ? */ -#define E1000_RX_BUFFER_WRITE 16 - -#define E1000_JUMBO_PBA 0x00000028 -#define E1000_DEFAULT_PBA 0x00000030 +#define E1000_RX_BUFFER_WRITE 16 /* Must be power of 2 */ #define AUTO_ALL_MODES 0 #define E1000_EEPROM_APME 4 @@ -145,7 +152,8 @@ }; #define E1000_DESC_UNUSED(R) \ -((((R)->next_to_clean + (R)->count) - ((R)->next_to_use + 1)) % ((R)->count)) + ((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \ + (R)->next_to_clean - (R)->next_to_use - 1) #define E1000_GET_DESC(R, i, type) (&(((struct type *)((R).desc))[i])) #define E1000_RX_DESC(R, i) E1000_GET_DESC(R, i, e1000_rx_desc) @@ -155,6 +163,7 @@ /* board specific private data structure */ struct e1000_adapter { + struct timer_list tx_fifo_stall_timer; struct timer_list watchdog_timer; struct timer_list phy_info_timer; struct vlan_group *vlgrp; @@ -163,6 +172,7 @@ uint32_t rx_buffer_len; uint32_t part_num; uint32_t wol; + uint32_t smartspeed; uint16_t link_speed; uint16_t link_duplex; spinlock_t stats_lock; @@ -177,7 +187,11 @@ uint32_t txd_cmd; uint32_t tx_int_delay; uint32_t tx_abs_int_delay; - int max_data_per_txd; + uint32_t gotcl; + uint32_t tx_fifo_head; + uint32_t tx_head_addr; + uint32_t tx_fifo_size; + atomic_t tx_fifo_stall; /* RX */ struct e1000_desc_ring rx_ring; @@ -186,6 +200,10 @@ uint32_t rx_int_delay; uint32_t rx_abs_int_delay; boolean_t rx_csum; + uint32_t gorcl; + + /* Interrupt Throttle Rate */ + uint32_t itr; /* OS defined structs */ struct net_device *netdev; diff -Nru a/drivers/net/e1000/e1000_ethtool.c b/drivers/net/e1000/e1000_ethtool.c --- a/drivers/net/e1000/e1000_ethtool.c Sun Mar 23 00:22:52 2003 +++ b/drivers/net/e1000/e1000_ethtool.c Sun Mar 23 00:22:52 2003 @@ -1,7 +1,7 @@ /******************************************************************************* - Copyright(c) 1999 - 2002 Intel Corporation. All rights reserved. + Copyright(c) 1999 - 2003 Intel Corporation. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -38,6 +38,7 @@ extern int e1000_up(struct e1000_adapter *adapter); extern void e1000_down(struct e1000_adapter *adapter); extern void e1000_reset(struct e1000_adapter *adapter); +extern int e1000_set_spd_dplx(struct e1000_adapter *adapter, uint16_t spddplx); static char e1000_gstrings_stats[][ETH_GSTRING_LEN] = { "rx_packets", "tx_packets", "rx_bytes", "tx_bytes", "rx_errors", @@ -129,30 +130,9 @@ hw->autoneg = 1; hw->autoneg_advertised = 0x002F; ecmd->advertising = 0x002F; - } else { - hw->autoneg = 0; - switch(ecmd->speed + ecmd->duplex) { - case SPEED_10 + DUPLEX_HALF: - hw->forced_speed_duplex = e1000_10_half; - break; - case SPEED_10 + DUPLEX_FULL: - hw->forced_speed_duplex = e1000_10_full; - break; - case SPEED_100 + DUPLEX_HALF: - hw->forced_speed_duplex = e1000_100_half; - break; - case SPEED_100 + DUPLEX_FULL: - hw->forced_speed_duplex = e1000_100_full; - break; - case SPEED_1000 + DUPLEX_FULL: - hw->autoneg = 1; - hw->autoneg_advertised = ADVERTISE_1000_FULL; - break; - case SPEED_1000 + DUPLEX_HALF: /* not supported */ - default: + } else + if(e1000_set_spd_dplx(adapter, ecmd->speed + ecmd->duplex)) return -EINVAL; - } - } /* reset the link */ @@ -165,16 +145,6 @@ return 0; } -static inline int -e1000_eeprom_size(struct e1000_hw *hw) -{ - if((hw->mac_type > e1000_82544) && - (E1000_READ_REG(hw, EECD) & E1000_EECD_SIZE)) - return 512; - else - return 128; -} - static void e1000_ethtool_gdrvinfo(struct e1000_adapter *adapter, struct ethtool_drvinfo *drvinfo) @@ -186,7 +156,7 @@ drvinfo->n_stats = E1000_STATS_LEN; #define E1000_REGS_LEN 32 drvinfo->regdump_len = E1000_REGS_LEN * sizeof(uint32_t); - drvinfo->eedump_len = e1000_eeprom_size(&adapter->hw); + drvinfo->eedump_len = adapter->hw.eeprom.word_size * 2; } static void @@ -220,9 +190,8 @@ struct ethtool_eeprom *eeprom, uint16_t *eeprom_buff) { struct e1000_hw *hw = &adapter->hw; - int max_len, first_word, last_word; + int first_word, last_word; int ret_val = 0; - int i; if(eeprom->len == 0) { ret_val = -EINVAL; @@ -231,22 +200,28 @@ eeprom->magic = hw->vendor_id | (hw->device_id << 16); - max_len = e1000_eeprom_size(hw); - if(eeprom->offset > eeprom->offset + eeprom->len) { ret_val = -EINVAL; goto geeprom_error; } - if((eeprom->offset + eeprom->len) > max_len) - eeprom->len = (max_len - eeprom->offset); + if((eeprom->offset + eeprom->len) > (hw->eeprom.word_size * 2)) + eeprom->len = ((hw->eeprom.word_size * 2) - eeprom->offset); first_word = eeprom->offset >> 1; last_word = (eeprom->offset + eeprom->len - 1) >> 1; - for(i = 0; i <= (last_word - first_word); i++) - e1000_read_eeprom(hw, first_word + i, &eeprom_buff[i]); - + if(hw->eeprom.type == e1000_eeprom_spi) + ret_val = e1000_read_eeprom(hw, first_word, + last_word - first_word + 1, + eeprom_buff); + else { + uint16_t i; + for (i = 0; i < last_word - first_word + 1; i++) + if((ret_val = e1000_read_eeprom(hw, first_word + i, 1, + &eeprom_buff[i]))) + break; + } geeprom_error: return ret_val; } @@ -257,9 +232,8 @@ { struct e1000_hw *hw = &adapter->hw; uint16_t *eeprom_buff; - int max_len, first_word, last_word; void *ptr; - int i; + int max_len, first_word, last_word, ret_val = 0; if(eeprom->len == 0) return -EOPNOTSUPP; @@ -267,7 +241,7 @@ if(eeprom->magic != (hw->vendor_id | (hw->device_id << 16))) return -EFAULT; - max_len = e1000_eeprom_size(hw); + max_len = hw->eeprom.word_size * 2; if((eeprom->offset + eeprom->len) > max_len) eeprom->len = (max_len - eeprom->offset); @@ -283,30 +257,31 @@ if(eeprom->offset & 1) { /* need read/modify/write of first changed EEPROM word */ /* only the second byte of the word is being modified */ - e1000_read_eeprom(hw, first_word, &eeprom_buff[0]); + ret_val = e1000_read_eeprom(hw, first_word, 1, + &eeprom_buff[0]); ptr++; } - if((eeprom->offset + eeprom->len) & 1) { + if(((eeprom->offset + eeprom->len) & 1) && (ret_val == 0)) { /* need read/modify/write of last changed EEPROM word */ /* only the first byte of the word is being modified */ - e1000_read_eeprom(hw, last_word, + ret_val = e1000_read_eeprom(hw, last_word, 1, &eeprom_buff[last_word - first_word]); } - if(copy_from_user(ptr, user_data, eeprom->len)) { - kfree(eeprom_buff); - return -EFAULT; + if((ret_val != 0) || copy_from_user(ptr, user_data, eeprom->len)) { + ret_val = -EFAULT; + goto seeprom_error; } - for(i = 0; i <= (last_word - first_word); i++) - e1000_write_eeprom(hw, first_word + i, eeprom_buff[i]); + ret_val = e1000_write_eeprom(hw, first_word, + last_word - first_word + 1, eeprom_buff); /* Update the checksum over the first part of the EEPROM if needed */ - if(first_word <= EEPROM_CHECKSUM_REG) + if((ret_val == 0) && first_word <= EEPROM_CHECKSUM_REG) e1000_update_eeprom_checksum(hw); +seeprom_error: kfree(eeprom_buff); - - return 0; + return ret_val; } static void @@ -333,8 +308,8 @@ /* Fall Through */ default: - wol->supported = WAKE_UCAST | WAKE_MCAST - | WAKE_BCAST | WAKE_MAGIC; + wol->supported = WAKE_UCAST | WAKE_MCAST | + WAKE_BCAST | WAKE_MAGIC; wol->wolopts = 0; if(adapter->wol & E1000_WUFC_EX) @@ -368,7 +343,7 @@ /* Fall Through */ default: - if(wol->wolopts & (WAKE_ARP | WAKE_MAGICSECURE | WAKE_PHY)) + if(wol->wolopts & (WAKE_PHY | WAKE_ARP | WAKE_MAGICSECURE)) return -EOPNOTSUPP; adapter->wol = 0; @@ -542,13 +517,12 @@ } case ETHTOOL_GEEPROM: { struct ethtool_eeprom eeprom = {ETHTOOL_GEEPROM}; + struct e1000_hw *hw = &adapter->hw; uint16_t *eeprom_buff; void *ptr; - int max_len, err = 0; - - max_len = e1000_eeprom_size(&adapter->hw); + int err = 0; - eeprom_buff = kmalloc(max_len, GFP_KERNEL); + eeprom_buff = kmalloc(hw->eeprom.word_size * 2, GFP_KERNEL); if(eeprom_buff == NULL) return -ENOMEM; diff -Nru a/drivers/net/e1000/e1000_hw.c b/drivers/net/e1000/e1000_hw.c --- a/drivers/net/e1000/e1000_hw.c Sun Mar 23 00:22:56 2003 +++ b/drivers/net/e1000/e1000_hw.c Sun Mar 23 00:22:56 2003 @@ -1,7 +1,7 @@ /******************************************************************************* - Copyright(c) 1999 - 2002 Intel Corporation. All rights reserved. + Copyright(c) 1999 - 2003 Intel Corporation. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -32,6 +32,8 @@ #include "e1000_hw.h" +static int32_t e1000_set_phy_type(struct e1000_hw *hw); +static void e1000_phy_init_script(struct e1000_hw *hw); static int32_t e1000_setup_fiber_link(struct e1000_hw *hw); static int32_t e1000_setup_copper_link(struct e1000_hw *hw); static int32_t e1000_phy_force_speed_duplex(struct e1000_hw *hw); @@ -42,19 +44,103 @@ static void e1000_shift_out_mdi_bits(struct e1000_hw *hw, uint32_t data, uint16_t count); static uint16_t e1000_shift_in_mdi_bits(struct e1000_hw *hw); static int32_t e1000_phy_reset_dsp(struct e1000_hw *hw); +static int32_t e1000_write_eeprom_spi(struct e1000_hw *hw, uint16_t offset, + uint16_t words, uint16_t *data); +static int32_t e1000_write_eeprom_microwire(struct e1000_hw *hw, + uint16_t offset, uint16_t words, + uint16_t *data); +static int32_t e1000_spi_eeprom_ready(struct e1000_hw *hw); static void e1000_raise_ee_clk(struct e1000_hw *hw, uint32_t *eecd); static void e1000_lower_ee_clk(struct e1000_hw *hw, uint32_t *eecd); static void e1000_shift_out_ee_bits(struct e1000_hw *hw, uint16_t data, uint16_t count); -static uint16_t e1000_shift_in_ee_bits(struct e1000_hw *hw); -static void e1000_setup_eeprom(struct e1000_hw *hw); -static void e1000_clock_eeprom(struct e1000_hw *hw); -static void e1000_cleanup_eeprom(struct e1000_hw *hw); +static uint16_t e1000_shift_in_ee_bits(struct e1000_hw *hw, uint16_t count); +static int32_t e1000_acquire_eeprom(struct e1000_hw *hw); +static void e1000_release_eeprom(struct e1000_hw *hw); static void e1000_standby_eeprom(struct e1000_hw *hw); static int32_t e1000_id_led_init(struct e1000_hw * hw); + + +/****************************************************************************** + * Set the phy type member in the hw struct. + * + * hw - Struct containing variables accessed by shared code + *****************************************************************************/ +int32_t +e1000_set_phy_type(struct e1000_hw *hw) +{ + DEBUGFUNC("e1000_set_phy_type"); + + switch(hw->phy_id) { + case M88E1000_E_PHY_ID: + case M88E1000_I_PHY_ID: + case M88E1011_I_PHY_ID: + hw->phy_type = e1000_phy_m88; + break; + case IGP01E1000_I_PHY_ID: + hw->phy_type = e1000_phy_igp; + break; + default: + /* Should never have loaded on this device */ + hw->phy_type = e1000_phy_undefined; + return -E1000_ERR_PHY_TYPE; + } + + return E1000_SUCCESS; +} + +/****************************************************************************** + * IGP phy init script - initializes the GbE PHY + * + * hw - Struct containing variables accessed by shared code + *****************************************************************************/ +static void +e1000_phy_init_script(struct e1000_hw *hw) +{ + DEBUGFUNC("e1000_phy_init_script"); + + if(hw->phy_init_script) { + msec_delay(10); + + e1000_write_phy_reg(hw,IGP01E1000_PHY_PAGE_SELECT,0x0000); + e1000_write_phy_reg(hw,0x0000,0x0140); + + msec_delay(5); + e1000_write_phy_reg(hw,IGP01E1000_PHY_PAGE_SELECT,0x1F95); + e1000_write_phy_reg(hw,0x0015,0x0001); + + e1000_write_phy_reg(hw,IGP01E1000_PHY_PAGE_SELECT,0x1F71); + e1000_write_phy_reg(hw,0x0011,0xBD21); + + e1000_write_phy_reg(hw,IGP01E1000_PHY_PAGE_SELECT,0x1F79); + e1000_write_phy_reg(hw,0x0019,0x0018); + + e1000_write_phy_reg(hw,IGP01E1000_PHY_PAGE_SELECT,0x1F30); + e1000_write_phy_reg(hw,0x0010,0x1600); + + e1000_write_phy_reg(hw,IGP01E1000_PHY_PAGE_SELECT,0x1F31); + e1000_write_phy_reg(hw,0x0011,0x0014); + + e1000_write_phy_reg(hw,IGP01E1000_PHY_PAGE_SELECT,0x1F32); + e1000_write_phy_reg(hw,0x0012,0x161C); + + e1000_write_phy_reg(hw,IGP01E1000_PHY_PAGE_SELECT,0x1F94); + e1000_write_phy_reg(hw,0x0014,0x0003); + + e1000_write_phy_reg(hw,IGP01E1000_PHY_PAGE_SELECT,0x1F96); + e1000_write_phy_reg(hw,0x0016,0x003F); + + e1000_write_phy_reg(hw,IGP01E1000_PHY_PAGE_SELECT,0x2010); + e1000_write_phy_reg(hw,0x0010,0x0008); + + e1000_write_phy_reg(hw,IGP01E1000_PHY_PAGE_SELECT,0x0000); + e1000_write_phy_reg(hw,0x0000,0x3300); + } +} + /****************************************************************************** * Set the mac type member in the hw struct. - * + * * hw - Struct containing variables accessed by shared code *****************************************************************************/ int32_t @@ -101,10 +187,19 @@ case E1000_DEV_ID_82546EB_FIBER: hw->mac_type = e1000_82546; break; + case E1000_DEV_ID_82541EI: + case E1000_DEV_ID_82541EP: + hw->mac_type = e1000_82541; + break; + case E1000_DEV_ID_82547EI: + hw->mac_type = e1000_82547; + break; default: /* Should never have loaded on this device */ return -E1000_ERR_MAC_TYPE; } + + return E1000_SUCCESS; } /****************************************************************************** @@ -119,9 +214,10 @@ uint32_t ctrl_ext; uint32_t icr; uint32_t manc; + uint32_t led_ctrl; DEBUGFUNC("e1000_reset_hw"); - + /* For 82542 (rev 2.0), disable MWI before issuing a device reset */ if(hw->mac_type == e1000_82542_rev2_0) { DEBUGOUT("Disabling MWI on 82542 rev 2.0\n"); @@ -145,7 +241,7 @@ /* Delay to allow any outstanding PCI transactions to complete before * resetting the device - */ + */ msec_delay(10); /* Issue a global reset to the MAC. This will reset the chip's @@ -156,6 +252,12 @@ DEBUGOUT("Issuing a global reset to MAC\n"); ctrl = E1000_READ_REG(hw, CTRL); + /* Must reset the PHY before resetting the MAC */ + if((hw->mac_type == e1000_82541) || (hw->mac_type == e1000_82547)) { + E1000_WRITE_REG_IO(hw, CTRL, (ctrl | E1000_CTRL_PHY_RST)); + msec_delay(5); + } + if(hw->mac_type > e1000_82543) E1000_WRITE_REG_IO(hw, CTRL, (ctrl | E1000_CTRL_RST)); else @@ -173,13 +275,25 @@ msec_delay(2); } else { /* Wait for EEPROM reload (it happens automatically) */ - msec_delay(4); + msec_delay(5); /* Dissable HW ARPs on ASF enabled adapters */ manc = E1000_READ_REG(hw, MANC); manc &= ~(E1000_MANC_ARP_EN); E1000_WRITE_REG(hw, MANC, manc); } - + + if((hw->mac_type == e1000_82541) || (hw->mac_type == e1000_82547)) { + e1000_phy_init_script(hw); + + /* Configure activity LED after PHY reset */ + led_ctrl = E1000_READ_REG(hw, LEDCTL); + led_ctrl &= IGP_ACTIVITY_LED_MASK; + led_ctrl |= IGP_ACTIVITY_LED_ENABLE; + if(hw->mac_type == e1000_82547) + led_ctrl |= IGP_LED3_MODE; + E1000_WRITE_REG(hw, LEDCTL, led_ctrl); + } + /* Clear interrupt mask to stop board from generating interrupts */ DEBUGOUT("Masking off all interrupts\n"); E1000_WRITE_REG(hw, IMC, 0xffffffff); @@ -198,8 +312,8 @@ * Performs basic configuration of the adapter. * * hw - Struct containing variables accessed by shared code - * - * Assumes that the controller has previously been reset and is in a + * + * Assumes that the controller has previously been reset and is in a * post-reset uninitialized state. Initializes the receive address registers, * multicast table, and VLAN filter table. Calls routines to setup link * configuration and flow control settings. Clears all on-chip counters. Leaves @@ -224,7 +338,7 @@ DEBUGOUT("Error Initializing Identification LED\n"); return ret_val; } - + /* Set the Media Type and exit with error if it is not valid. */ if(hw->mac_type != e1000_82543) { /* tbi_compatibility is only valid on 82543 */ @@ -327,13 +441,13 @@ /****************************************************************************** * Configures flow control and link settings. - * + * * hw - Struct containing variables accessed by shared code - * + * * Determines which flow control settings to use. Calls the apropriate media- * specific link configuration function. Configures the flow control settings. * Assuming the adapter has a valid link partner, a valid link should be - * established. Assumes the hardware has previously been reset and the + * established. Assumes the hardware has previously been reset and the * transmitter and receiver are not enabled. *****************************************************************************/ int32_t @@ -353,7 +467,7 @@ * control setting, then the variable hw->fc will * be initialized based on a value in the EEPROM. */ - if(e1000_read_eeprom(hw, EEPROM_INIT_CONTROL2_REG, &eeprom_data) < 0) { + if(e1000_read_eeprom(hw, EEPROM_INIT_CONTROL2_REG, 1, &eeprom_data) < 0) { DEBUGOUT("EEPROM Read Error\n"); return -E1000_ERR_EEPROM; } @@ -361,7 +475,7 @@ if(hw->fc == e1000_fc_default) { if((eeprom_data & EEPROM_WORD0F_PAUSE_MASK) == 0) hw->fc = e1000_fc_none; - else if((eeprom_data & EEPROM_WORD0F_PAUSE_MASK) == + else if((eeprom_data & EEPROM_WORD0F_PAUSE_MASK) == EEPROM_WORD0F_ASM_DIR) hw->fc = e1000_fc_tx_pause; else @@ -390,7 +504,7 @@ * or e1000_phy_setup() is called. */ if(hw->mac_type == e1000_82543) { - ctrl_ext = ((eeprom_data & EEPROM_WORD0F_SWPDIO_EXT) << + ctrl_ext = ((eeprom_data & EEPROM_WORD0F_SWPDIO_EXT) << SWDPIO__EXT_SHIFT); E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext); } @@ -416,7 +530,7 @@ * these registers will be set to a default threshold that may be * adjusted later by the driver's runtime code. However, if the * ability to transmit pause frames in not enabled, then these - * registers will be set to 0. + * registers will be set to 0. */ if(!(hw->fc & e1000_fc_tx_pause)) { E1000_WRITE_REG(hw, FCRTL, 0); @@ -445,7 +559,7 @@ * link. Assumes the hardware has been previously reset and the transmitter * and receiver are not enabled. *****************************************************************************/ -static int32_t +static int32_t e1000_setup_fiber_link(struct e1000_hw *hw) { uint32_t ctrl; @@ -457,29 +571,29 @@ DEBUGFUNC("e1000_setup_fiber_link"); - /* On adapters with a MAC newer that 82544, SW Defineable pin 1 will be - * set when the optics detect a signal. On older adapters, it will be + /* On adapters with a MAC newer that 82544, SW Defineable pin 1 will be + * set when the optics detect a signal. On older adapters, it will be * cleared when there is a signal */ ctrl = E1000_READ_REG(hw, CTRL); if(hw->mac_type > e1000_82544) signal = E1000_CTRL_SWDPIN1; else signal = 0; - + /* Take the link out of reset */ ctrl &= ~(E1000_CTRL_LRST); - + e1000_config_collision_dist(hw); /* Check for a software override of the flow control settings, and setup * the device accordingly. If auto-negotiation is enabled, then software * will have to set the "PAUSE" bits to the correct value in the Tranmsit * Config Word Register (TXCW) and re-start auto-negotiation. However, if - * auto-negotiation is disabled, then software will have to manually + * auto-negotiation is disabled, then software will have to manually * configure the two flow control enable bits in the CTRL register. * * The possible values of the "fc" parameter are: * 0: Flow control is completely disabled - * 1: Rx flow control is enabled (we can receive pause frames, but + * 1: Rx flow control is enabled (we can receive pause frames, but * not send pause frames). * 2: Tx flow control is enabled (we can send pause frames but we do * not support receiving pause frames). @@ -491,8 +605,8 @@ txcw = (E1000_TXCW_ANE | E1000_TXCW_FD); break; case e1000_fc_rx_pause: - /* RX Flow control is enabled and TX Flow control is disabled by a - * software over-ride. Since there really isn't a way to advertise + /* RX Flow control is enabled and TX Flow control is disabled by a + * software over-ride. Since there really isn't a way to advertise * that we are capable of RX Pause ONLY, we will advertise that we * support both symmetric and asymmetric RX PAUSE. Later, we will * disable the adapter's ability to send PAUSE frames. @@ -500,7 +614,7 @@ txcw = (E1000_TXCW_ANE | E1000_TXCW_FD | E1000_TXCW_PAUSE_MASK); break; case e1000_fc_tx_pause: - /* TX Flow control is enabled, and RX Flow control is disabled, by a + /* TX Flow control is enabled, and RX Flow control is disabled, by a * software over-ride. */ txcw = (E1000_TXCW_ANE | E1000_TXCW_FD | E1000_TXCW_ASM_DIR); @@ -531,8 +645,8 @@ msec_delay(1); /* If we have a signal (the cable is plugged in) then poll for a "Link-Up" - * indication in the Device Status Register. Time-out if a link isn't - * seen in 500 milliseconds seconds (Auto-negotiation should complete in + * indication in the Device Status Register. Time-out if a link isn't + * seen in 500 milliseconds seconds (Auto-negotiation should complete in * less than 500 milliseconds even if the other end is doing it in SW). */ if((E1000_READ_REG(hw, CTRL) & E1000_CTRL_SWDPIN1) == signal) { @@ -543,7 +657,7 @@ if(status & E1000_STATUS_LU) break; } if(i == (LINK_UP_TIMEOUT / 10)) { - /* AutoNeg failed to achieve a link, so we'll call + /* AutoNeg failed to achieve a link, so we'll call * e1000_check_for_link. This routine will force the link up if we * detect a signal. This will allow us to communicate with * non-autonegotiating link partners. @@ -571,10 +685,10 @@ * * hw - Struct containing variables accessed by shared code ******************************************************************************/ -static int32_t +static int32_t e1000_setup_copper_link(struct e1000_hw *hw) { - uint32_t ctrl; + uint32_t ctrl, led_ctrl; int32_t ret_val; uint16_t i; uint16_t phy_data; @@ -604,80 +718,148 @@ } DEBUGOUT1("Phy ID = %x \n", hw->phy_id); - /* Enable CRS on TX. This must be set for half-duplex operation. */ - if(e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data) < 0) { - DEBUGOUT("PHY Read Error\n"); - return -E1000_ERR_PHY; - } - phy_data |= M88E1000_PSCR_ASSERT_CRS_ON_TX; + if (hw->phy_type == e1000_phy_igp) { - /* Options: - * MDI/MDI-X = 0 (default) - * 0 - Auto for all speeds - * 1 - MDI mode - * 2 - MDI-X mode - * 3 - Auto for 1000Base-T only (MDI-X for 10/100Base-T modes) - */ - phy_data &= ~M88E1000_PSCR_AUTO_X_MODE; + ret_val = e1000_phy_reset(hw); + if(ret_val < 0) { + DEBUGOUT("Error Resetting the PHY\n"); + return ret_val; + } - switch (hw->mdix) { - case 1: - phy_data |= M88E1000_PSCR_MDI_MANUAL_MODE; - break; - case 2: - phy_data |= M88E1000_PSCR_MDIX_MANUAL_MODE; - break; - case 3: - phy_data |= M88E1000_PSCR_AUTO_X_1000T; - break; - case 0: - default: - phy_data |= M88E1000_PSCR_AUTO_X_MODE; - break; - } + /* Wait 10ms for MAC to configure PHY from eeprom settings */ + msec_delay(15); - /* Options: - * disable_polarity_correction = 0 (default) - * Automatic Correction for Reversed Cable Polarity - * 0 - Disabled - * 1 - Enabled - */ - phy_data &= ~M88E1000_PSCR_POLARITY_REVERSAL; - if(hw->disable_polarity_correction == 1) - phy_data |= M88E1000_PSCR_POLARITY_REVERSAL; - if(e1000_write_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_data) < 0) { - DEBUGOUT("PHY Write Error\n"); - return -E1000_ERR_PHY; - } + if(e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT, 0x0000) < 0) { + DEBUGOUT("PHY Write Error\n"); + return -E1000_ERR_PHY; + } - /* Force TX_CLK in the Extended PHY Specific Control Register - * to 25MHz clock. - */ - if(e1000_read_phy_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_data) < 0) { - DEBUGOUT("PHY Read Error\n"); - return -E1000_ERR_PHY; - } - phy_data |= M88E1000_EPSCR_TX_CLK_25; + /* Configure activity LED after PHY reset */ + led_ctrl = E1000_READ_REG(hw, LEDCTL); + led_ctrl &= IGP_ACTIVITY_LED_MASK; + led_ctrl |= IGP_ACTIVITY_LED_ENABLE; + if(hw->mac_type == e1000_82547) + led_ctrl |= IGP_LED3_MODE; + E1000_WRITE_REG(hw, LEDCTL, led_ctrl); + + if(hw->autoneg_advertised == ADVERTISE_1000_FULL) { + /* Disable SmartSpeed */ + if(e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG, + &phy_data) < 0) { + DEBUGOUT("PHY Read Error\n"); + return -E1000_ERR_PHY; + } + phy_data &= ~IGP01E1000_PSCFR_SMART_SPEED; + if(e1000_write_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG, + phy_data) < 0) { + DEBUGOUT("PHY Write Error\n"); + return -E1000_ERR_PHY; + } + /* Set auto Master/Slave resolution process */ + if(e1000_read_phy_reg(hw, PHY_1000T_CTRL, &phy_data) < 0) { + DEBUGOUT("PHY Read Error\n"); + return -E1000_ERR_PHY; + } + phy_data &= ~CR_1000T_MS_ENABLE; + if(e1000_write_phy_reg(hw, PHY_1000T_CTRL, phy_data) < 0) { + DEBUGOUT("PHY Write Error\n"); + return -E1000_ERR_PHY; + } + } - if (hw->phy_revision < M88E1011_I_REV_4) { - /* Configure Master and Slave downshift values */ - phy_data &= ~(M88E1000_EPSCR_MASTER_DOWNSHIFT_MASK | - M88E1000_EPSCR_SLAVE_DOWNSHIFT_MASK); - phy_data |= (M88E1000_EPSCR_MASTER_DOWNSHIFT_1X | - M88E1000_EPSCR_SLAVE_DOWNSHIFT_1X); - if(e1000_write_phy_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, phy_data) < 0) { + if(e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CTRL, &phy_data) < 0) { + DEBUGOUT("PHY Read Error\n"); + return -E1000_ERR_PHY; + } + + /* Force MDI for IGP PHY */ + phy_data &= ~(IGP01E1000_PSCR_AUTO_MDIX | + IGP01E1000_PSCR_FORCE_MDI_MDIX); + + hw->mdix = 1; + + if(e1000_write_phy_reg(hw, IGP01E1000_PHY_PORT_CTRL, phy_data) < 0) { DEBUGOUT("PHY Write Error\n"); return -E1000_ERR_PHY; } - } - /* SW Reset the PHY so all changes take effect */ - ret_val = e1000_phy_reset(hw); - if(ret_val < 0) { - DEBUGOUT("Error Resetting the PHY\n"); - return ret_val; + } else { + /* Enable CRS on TX. This must be set for half-duplex operation. */ + if(e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data) < 0) { + DEBUGOUT("PHY Read Error\n"); + return -E1000_ERR_PHY; + } + phy_data |= M88E1000_PSCR_ASSERT_CRS_ON_TX; + + /* Options: + * MDI/MDI-X = 0 (default) + * 0 - Auto for all speeds + * 1 - MDI mode + * 2 - MDI-X mode + * 3 - Auto for 1000Base-T only (MDI-X for 10/100Base-T modes) + */ + phy_data &= ~M88E1000_PSCR_AUTO_X_MODE; + + switch (hw->mdix) { + case 1: + phy_data |= M88E1000_PSCR_MDI_MANUAL_MODE; + break; + case 2: + phy_data |= M88E1000_PSCR_MDIX_MANUAL_MODE; + break; + case 3: + phy_data |= M88E1000_PSCR_AUTO_X_1000T; + break; + case 0: + default: + phy_data |= M88E1000_PSCR_AUTO_X_MODE; + break; + } + + /* Options: + * disable_polarity_correction = 0 (default) + * Automatic Correction for Reversed Cable Polarity + * 0 - Disabled + * 1 - Enabled + */ + phy_data &= ~M88E1000_PSCR_POLARITY_REVERSAL; + if(hw->disable_polarity_correction == 1) + phy_data |= M88E1000_PSCR_POLARITY_REVERSAL; + if(e1000_write_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_data) < 0) { + DEBUGOUT("PHY Write Error\n"); + return -E1000_ERR_PHY; + } + + /* Force TX_CLK in the Extended PHY Specific Control Register + * to 25MHz clock. + */ + if(e1000_read_phy_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_data) < 0) { + DEBUGOUT("PHY Read Error\n"); + return -E1000_ERR_PHY; + } + phy_data |= M88E1000_EPSCR_TX_CLK_25; + + if (hw->phy_revision < M88E1011_I_REV_4) { + /* Configure Master and Slave downshift values */ + phy_data &= ~(M88E1000_EPSCR_MASTER_DOWNSHIFT_MASK | + M88E1000_EPSCR_SLAVE_DOWNSHIFT_MASK); + phy_data |= (M88E1000_EPSCR_MASTER_DOWNSHIFT_1X | + M88E1000_EPSCR_SLAVE_DOWNSHIFT_1X); + if(e1000_write_phy_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, + phy_data) < 0) { + DEBUGOUT("PHY Write Error\n"); + return -E1000_ERR_PHY; + } + } + + /* SW Reset the PHY so all changes take effect */ + ret_val = e1000_phy_reset(hw); + if(ret_val < 0) { + DEBUGOUT("Error Resetting the PHY\n"); + return ret_val; + } } - + /* Options: * autoneg = 1 (default) * PHY will advertise value(s) parsed from @@ -736,6 +918,7 @@ return ret_val; } } + hw->get_link_status = TRUE; } else { DEBUGOUT("Forcing speed and duplex\n"); ret_val = e1000_phy_force_speed_duplex(hw); @@ -1014,23 +1197,41 @@ /* Write the configured values back to the Device Control Reg. */ E1000_WRITE_REG(hw, CTRL, ctrl); - if(e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data) < 0) { - DEBUGOUT("PHY Read Error\n"); - return -E1000_ERR_PHY; - } + if (hw->phy_type == e1000_phy_m88) { + if(e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data) < 0) { + DEBUGOUT("PHY Read Error\n"); + return -E1000_ERR_PHY; + } - /* Clear Auto-Crossover to force MDI manually. M88E1000 requires MDI - * forced whenever speed are duplex are forced. - */ - phy_data &= ~M88E1000_PSCR_AUTO_X_MODE; - if(e1000_write_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_data) < 0) { - DEBUGOUT("PHY Write Error\n"); - return -E1000_ERR_PHY; - } - DEBUGOUT1("M88E1000 PSCR: %x \n", phy_data); + /* Clear Auto-Crossover to force MDI manually. M88E1000 requires MDI + * forced whenever speed are duplex are forced. + */ + phy_data &= ~M88E1000_PSCR_AUTO_X_MODE; + if(e1000_write_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_data) < 0) { + DEBUGOUT("PHY Write Error\n"); + return -E1000_ERR_PHY; + } + DEBUGOUT1("M88E1000 PSCR: %x \n", phy_data); + + /* Need to reset the PHY or these changes will be ignored */ + mii_ctrl_reg |= MII_CR_RESET; + } else { + /* Clear Auto-Crossover to force MDI manually. IGP requires MDI + * forced whenever speed or duplex are forced. + */ + if(e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CTRL, &phy_data) < 0) { + DEBUGOUT("PHY Read Error\n"); + return -E1000_ERR_PHY; + } - /* Need to reset the PHY or these changes will be ignored */ - mii_ctrl_reg |= MII_CR_RESET; + phy_data &= ~IGP01E1000_PSCR_AUTO_MDIX; + phy_data &= ~IGP01E1000_PSCR_FORCE_MDI_MDIX; + + if(e1000_write_phy_reg(hw, IGP01E1000_PHY_PORT_CTRL, phy_data) < 0) { + DEBUGOUT("PHY Write Error\n"); + return -E1000_ERR_PHY; + } + } /* Write back the modified PHY MII control register. */ if(e1000_write_phy_reg(hw, PHY_CTRL, mii_ctrl_reg) < 0) { @@ -1069,7 +1270,7 @@ } if(i == 0) { /* We didn't get link */ /* Reset the DSP and wait again for link. */ - + ret_val = e1000_phy_reset_dsp(hw); if(ret_val < 0) { DEBUGOUT("Error Resetting PHY DSP\n"); @@ -1093,32 +1294,34 @@ } } } - - /* Because we reset the PHY above, we need to re-force TX_CLK in the - * Extended PHY Specific Control Register to 25MHz clock. This value - * defaults back to a 2.5MHz clock when the PHY is reset. - */ - if(e1000_read_phy_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_data) < 0) { - DEBUGOUT("PHY Read Error\n"); - return -E1000_ERR_PHY; - } - phy_data |= M88E1000_EPSCR_TX_CLK_25; - if(e1000_write_phy_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, phy_data) < 0) { - DEBUGOUT("PHY Write Error\n"); - return -E1000_ERR_PHY; - } - /* In addition, because of the s/w reset above, we need to enable CRS on - * TX. This must be set for both full and half duplex operation. - */ - if(e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data) < 0) { - DEBUGOUT("PHY Read Error\n"); - return -E1000_ERR_PHY; - } - phy_data |= M88E1000_PSCR_ASSERT_CRS_ON_TX; - if(e1000_write_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_data) < 0) { - DEBUGOUT("PHY Write Error\n"); - return -E1000_ERR_PHY; + if (hw->phy_type == e1000_phy_m88) { + /* Because we reset the PHY above, we need to re-force TX_CLK in the + * Extended PHY Specific Control Register to 25MHz clock. This value + * defaults back to a 2.5MHz clock when the PHY is reset. + */ + if(e1000_read_phy_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_data) < 0) { + DEBUGOUT("PHY Read Error\n"); + return -E1000_ERR_PHY; + } + phy_data |= M88E1000_EPSCR_TX_CLK_25; + if(e1000_write_phy_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, phy_data) < 0) { + DEBUGOUT("PHY Write Error\n"); + return -E1000_ERR_PHY; + } + + /* In addition, because of the s/w reset above, we need to enable CRS on + * TX. This must be set for both full and half duplex operation. + */ + if(e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data) < 0) { + DEBUGOUT("PHY Read Error\n"); + return -E1000_ERR_PHY; + } + phy_data |= M88E1000_PSCR_ASSERT_CRS_ON_TX; + if(e1000_write_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_data) < 0) { + DEBUGOUT("PHY Write Error\n"); + return -E1000_ERR_PHY; + } } return 0; } @@ -1136,6 +1339,8 @@ { uint32_t tctl; + DEBUGFUNC("e1000_config_collision_dist"); + tctl = E1000_READ_REG(hw, TCTL); tctl &= ~E1000_TCTL_COLD; @@ -1172,22 +1377,43 @@ /* Set up duplex in the Device Control and Transmit Control * registers depending on negotiated values. */ - if(e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS, &phy_data) < 0) { - DEBUGOUT("PHY Read Error\n"); - return -E1000_ERR_PHY; - } - if(phy_data & M88E1000_PSSR_DPLX) ctrl |= E1000_CTRL_FD; - else ctrl &= ~E1000_CTRL_FD; + if (hw->phy_type == e1000_phy_igp) { + if(e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_STATUS, &phy_data) < 0) { + DEBUGOUT("PHY Read Error\n"); + return -E1000_ERR_PHY; + } + if(phy_data & IGP01E1000_PSSR_FULL_DUPLEX) ctrl |= E1000_CTRL_FD; + else ctrl &= ~E1000_CTRL_FD; - e1000_config_collision_dist(hw); + e1000_config_collision_dist(hw); - /* Set up speed in the Device Control register depending on - * negotiated values. - */ - if((phy_data & M88E1000_PSSR_SPEED) == M88E1000_PSSR_1000MBS) - ctrl |= E1000_CTRL_SPD_1000; - else if((phy_data & M88E1000_PSSR_SPEED) == M88E1000_PSSR_100MBS) - ctrl |= E1000_CTRL_SPD_100; + /* Set up speed in the Device Control register depending on + * negotiated values. + */ + if((phy_data & IGP01E1000_PSSR_SPEED_MASK) == + IGP01E1000_PSSR_SPEED_1000MBPS) + ctrl |= E1000_CTRL_SPD_1000; + else if((phy_data & IGP01E1000_PSSR_SPEED_MASK) == + IGP01E1000_PSSR_SPEED_100MBPS) + ctrl |= E1000_CTRL_SPD_100; + } else { + if(e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS, &phy_data) < 0) { + DEBUGOUT("PHY Read Error\n"); + return -E1000_ERR_PHY; + } + if(phy_data & M88E1000_PSSR_DPLX) ctrl |= E1000_CTRL_FD; + else ctrl &= ~E1000_CTRL_FD; + + e1000_config_collision_dist(hw); + + /* Set up speed in the Device Control register depending on + * negotiated values. + */ + if((phy_data & M88E1000_PSSR_SPEED) == M88E1000_PSSR_1000MBS) + ctrl |= E1000_CTRL_SPD_1000; + else if((phy_data & M88E1000_PSSR_SPEED) == M88E1000_PSSR_100MBS) + ctrl |= E1000_CTRL_SPD_100; + } /* Write the configured values back to the Device Control Reg. */ E1000_WRITE_REG(hw, CTRL, ctrl); return 0; @@ -1195,7 +1421,7 @@ /****************************************************************************** * Forces the MAC's flow control settings. - * + * * hw - Struct containing variables accessed by shared code * * Sets the TFCE and RFCE bits in the device control register to reflect @@ -1262,7 +1488,7 @@ /****************************************************************************** * Configures flow control settings after link is established - * + * * hw - Struct containing variables accessed by shared code * * Should be called immediately after a valid link has been established. @@ -1484,9 +1710,9 @@ uint16_t lp_capability; DEBUGFUNC("e1000_check_for_link"); - - /* On adapters with a MAC newer that 82544, SW Defineable pin 1 will be - * set when the optics detect a signal. On older adapters, it will be + + /* On adapters with a MAC newer that 82544, SW Defineable pin 1 will be + * set when the optics detect a signal. On older adapters, it will be * cleared when there is a signal */ if(hw->mac_type > e1000_82544) signal = E1000_CTRL_SWDPIN1; @@ -1519,6 +1745,10 @@ if(phy_data & MII_SR_LINK_STATUS) { hw->get_link_status = FALSE; + /* Check if there was DownShift, must be checked immediately after + * link-up */ + e1000_check_downshift(hw); + } else { /* No link detected */ return 0; @@ -1547,7 +1777,7 @@ } } - /* Configure Flow Control now that Auto-Neg has completed. First, we + /* Configure Flow Control now that Auto-Neg has completed. First, we * need to restore the desired flow control settings because we may * have had to re-autoneg with a different link partner. */ @@ -1576,7 +1806,7 @@ NWAY_LPAR_100TX_HD_CAPS | NWAY_LPAR_100TX_FD_CAPS | NWAY_LPAR_100T4_CAPS)) { - /* If our link partner advertises anything in addition to + /* If our link partner advertises anything in addition to * gigabit, we do not need to enable TBI compatibility. */ if(hw->tbi_compatibility_on) { @@ -1780,7 +2010,7 @@ uint32_t mask; /* We need to shift "count" number of bits out to the PHY. So, the value - * in the "data" parameter will be shifted out to the PHY one bit at a + * in the "data" parameter will be shifted out to the PHY one bit at a * time. In order to do this, "data" must be broken down into bits. */ mask = 0x01; @@ -1817,7 +2047,7 @@ * * hw - Struct containing variables accessed by shared code * -* Bits are shifted in in MSB to LSB order. +* Bits are shifted in in MSB to LSB order. ******************************************************************************/ static uint16_t e1000_shift_in_mdi_bits(struct e1000_hw *hw) @@ -1832,7 +2062,7 @@ * These two bits are ignored by us and thrown away. Bits are "shifted in" * by raising the input to the Management Data Clock (setting the MDC bit), * and then reading the value of the MDIO bit. - */ + */ ctrl = E1000_READ_REG(hw, CTRL); /* Clear MDIO_DIR (SWDPIO1) to indicate this bit is to be used as input. */ @@ -1892,7 +2122,7 @@ * PHY to retrieve the desired data. */ mdic = ((reg_addr << E1000_MDIC_REG_SHIFT) | - (phy_addr << E1000_MDIC_PHY_SHIFT) | + (phy_addr << E1000_MDIC_PHY_SHIFT) | (E1000_MDIC_OP_READ)); E1000_WRITE_REG(hw, MDIC, mdic); @@ -1930,7 +2160,7 @@ * READ operation is performed. These two bits are thrown away * followed by a shift in of 16 bits which contains the desired data. */ - mdic = ((reg_addr) | (phy_addr << 5) | + mdic = ((reg_addr) | (phy_addr << 5) | (PHY_OP_READ << 10) | (PHY_SOF << 12)); e1000_shift_out_mdi_bits(hw, mdic, 14); @@ -1974,7 +2204,7 @@ */ mdic = (((uint32_t) phy_data) | (reg_addr << E1000_MDIC_REG_SHIFT) | - (phy_addr << E1000_MDIC_PHY_SHIFT) | + (phy_addr << E1000_MDIC_PHY_SHIFT) | (E1000_MDIC_OP_WRITE)); E1000_WRITE_REG(hw, MDIC, mdic); @@ -1992,12 +2222,12 @@ } else { /* We'll need to use the SW defined pins to shift the write command * out to the PHY. We first send a preamble to the PHY to signal the - * beginning of the MII instruction. This is done by sending 32 + * beginning of the MII instruction. This is done by sending 32 * consecutive "1" bits. */ e1000_shift_out_mdi_bits(hw, PHY_PREAMBLE, PHY_PREAMBLE_SIZE); - /* Now combine the remaining required fields that will indicate a + /* Now combine the remaining required fields that will indicate a * write operation. We use this method instead of calling the * e1000_shift_out_mdi_bits routine for each field in the command. The * format of a MII write instruction is as follows: @@ -2010,6 +2240,7 @@ e1000_shift_out_mdi_bits(hw, mdic, 32); } + return 0; } @@ -2021,8 +2252,7 @@ void e1000_phy_hw_reset(struct e1000_hw *hw) { - uint32_t ctrl; - uint32_t ctrl_ext; + uint32_t ctrl, ctrl_ext, led_ctrl; DEBUGFUNC("e1000_phy_hw_reset"); @@ -2053,6 +2283,21 @@ E1000_WRITE_FLUSH(hw); } udelay(150); + + if((hw->mac_type == e1000_82541) || (hw->mac_type == e1000_82547)) { + if(e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT, 0x0000) < 0) { + DEBUGOUT("PHY Write Error\n"); + return; + } + + /* Configure activity LED after PHY reset */ + led_ctrl = E1000_READ_REG(hw, LEDCTL); + led_ctrl &= IGP_ACTIVITY_LED_MASK; + led_ctrl |= IGP_ACTIVITY_LED_ENABLE; + if(hw->mac_type == e1000_82547) + led_ctrl |= IGP_LED3_MODE; + E1000_WRITE_REG(hw, LEDCTL, led_ctrl); + } } /****************************************************************************** @@ -2079,6 +2324,9 @@ return -E1000_ERR_PHY; } udelay(1); + if (hw->phy_type == e1000_phy_igp) { + e1000_phy_init_script(hw); + } return 0; } @@ -2092,6 +2340,7 @@ { uint16_t phy_id_high, phy_id_low; boolean_t match = FALSE; + int32_t phy_init_status; DEBUGFUNC("e1000_detect_gig_phy"); @@ -2101,7 +2350,7 @@ return -E1000_ERR_PHY; } hw->phy_id = (uint32_t) (phy_id_high << 16); - udelay(2); + udelay(20); if(e1000_read_phy_reg(hw, PHY_ID2, &phy_id_low) < 0) { DEBUGOUT("PHY Read Error\n"); return -E1000_ERR_PHY; @@ -2121,11 +2370,17 @@ case e1000_82546: if(hw->phy_id == M88E1011_I_PHY_ID) match = TRUE; break; + case e1000_82541: + case e1000_82547: + if(hw->phy_id == IGP01E1000_I_PHY_ID) match = TRUE; + break; default: DEBUGOUT1("Invalid MAC type %d\n", hw->mac_type); return -E1000_ERR_CONFIG; } - if(match) { + phy_init_status = e1000_set_phy_type(hw); + + if ((match) && (phy_init_status == E1000_SUCCESS)) { DEBUGOUT1("PHY ID 0x%X detected\n", hw->phy_id); return 0; } @@ -2143,7 +2398,7 @@ { int32_t ret_val = -E1000_ERR_PHY; DEBUGFUNC("e1000_phy_reset_dsp"); - + do { if(e1000_write_phy_reg(hw, 29, 0x001d) < 0) break; if(e1000_write_phy_reg(hw, 30, 0x00c1) < 0) break; @@ -2156,6 +2411,133 @@ } /****************************************************************************** +* Get PHY information from various PHY registers for igp PHY only. +* +* hw - Struct containing variables accessed by shared code +* phy_info - PHY information structure +******************************************************************************/ +int32_t +e1000_phy_igp_get_info(struct e1000_hw *hw, struct e1000_phy_info *phy_info) +{ + uint16_t phy_data, polarity, min_length, max_length, average; + + DEBUGFUNC("e1000_phy_igp_get_info"); + + /* The downshift status is checked only once, after link is established, + * and it stored in the hw->speed_downgraded parameter. */ + phy_info->downshift = hw->speed_downgraded; + + /* IGP01E1000 does not need to support it. */ + phy_info->extended_10bt_distance = e1000_10bt_ext_dist_enable_normal; + + /* IGP01E1000 always correct polarity reversal */ + phy_info->polarity_correction = e1000_polarity_reversal_enabled; + + /* Check polarity status */ + if(e1000_check_polarity(hw, &polarity) < 0) + return -E1000_ERR_PHY; + + phy_info->cable_polarity = polarity; + + if(e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_STATUS, &phy_data) < 0) + return -E1000_ERR_PHY; + + phy_info->mdix_mode = (phy_data & IGP01E1000_PSSR_MDIX) >> + IGP01E1000_PSSR_MDIX_SHIFT; + + if((phy_data & IGP01E1000_PSSR_SPEED_MASK) == + IGP01E1000_PSSR_SPEED_1000MBPS) { + /* Local/Remote Receiver Information are only valid at 1000 Mbps */ + if(e1000_read_phy_reg(hw, PHY_1000T_STATUS, &phy_data) < 0) + return -E1000_ERR_PHY; + + phy_info->local_rx = (phy_data & SR_1000T_LOCAL_RX_STATUS) >> + SR_1000T_LOCAL_RX_STATUS_SHIFT; + phy_info->remote_rx = (phy_data & SR_1000T_REMOTE_RX_STATUS) >> + SR_1000T_REMOTE_RX_STATUS_SHIFT; + + /* Get cable length */ + if(e1000_get_cable_length(hw, &min_length, &max_length) < 0) + return -E1000_ERR_PHY; + + /* transalte to old method */ + average = (max_length + min_length) / 2; + + if(average <= e1000_igp_cable_length_50) + phy_info->cable_length = e1000_cable_length_50; + else if(average <= e1000_igp_cable_length_80) + phy_info->cable_length = e1000_cable_length_50_80; + else if(average <= e1000_igp_cable_length_110) + phy_info->cable_length = e1000_cable_length_80_110; + else if(average <= e1000_igp_cable_length_140) + phy_info->cable_length = e1000_cable_length_110_140; + else + phy_info->cable_length = e1000_cable_length_140; + } + + return E1000_SUCCESS; +} + +/****************************************************************************** +* Get PHY information from various PHY registers fot m88 PHY only. +* +* hw - Struct containing variables accessed by shared code +* phy_info - PHY information structure +******************************************************************************/ +int32_t +e1000_phy_m88_get_info(struct e1000_hw *hw, struct e1000_phy_info *phy_info) +{ + uint16_t phy_data, polarity; + + DEBUGFUNC("e1000_phy_m88_get_info"); + + /* The downshift status is checked only once, after link is established, + * and it stored in the hw->speed_downgraded parameter. */ + phy_info->downshift = hw->speed_downgraded; + + if(e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data) < 0) + return -E1000_ERR_PHY; + + phy_info->extended_10bt_distance = + (phy_data & M88E1000_PSCR_10BT_EXT_DIST_ENABLE) >> + M88E1000_PSCR_10BT_EXT_DIST_ENABLE_SHIFT; + phy_info->polarity_correction = + (phy_data & M88E1000_PSCR_POLARITY_REVERSAL) >> + M88E1000_PSCR_POLARITY_REVERSAL_SHIFT; + + /* Check polarity status */ + if(e1000_check_polarity(hw, &polarity) < 0) + return -E1000_ERR_PHY; + + phy_info->cable_polarity = polarity; + + if(e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS, &phy_data) < 0) + return -E1000_ERR_PHY; + + phy_info->mdix_mode = (phy_data & M88E1000_PSSR_MDIX) >> + M88E1000_PSSR_MDIX_SHIFT; + + if(phy_data & M88E1000_PSSR_1000MBS) { + /* Cable Length Estimation and Local/Remote Receiver Informatoion + * are only valid at 1000 Mbps + */ + phy_info->cable_length = ((phy_data & M88E1000_PSSR_CABLE_LENGTH) >> + M88E1000_PSSR_CABLE_LENGTH_SHIFT); + + if(e1000_read_phy_reg(hw, PHY_1000T_STATUS, &phy_data) < 0) + return -E1000_ERR_PHY; + + phy_info->local_rx = (phy_data & SR_1000T_LOCAL_RX_STATUS) >> + SR_1000T_LOCAL_RX_STATUS_SHIFT; + + phy_info->remote_rx = (phy_data & SR_1000T_REMOTE_RX_STATUS) >> + SR_1000T_REMOTE_RX_STATUS_SHIFT; + } + + return E1000_SUCCESS; +} + +/****************************************************************************** * Get PHY information from various PHY registers * * hw - Struct containing variables accessed by shared code @@ -2165,7 +2547,6 @@ e1000_phy_get_info(struct e1000_hw *hw, struct e1000_phy_info *phy_info) { - int32_t ret_val = -E1000_ERR_PHY; uint16_t phy_data; DEBUGFUNC("e1000_phy_get_info"); @@ -2173,6 +2554,7 @@ phy_info->cable_length = e1000_cable_length_undefined; phy_info->extended_10bt_distance = e1000_10bt_ext_dist_enable_undefined; phy_info->cable_polarity = e1000_rev_polarity_undefined; + phy_info->downshift = e1000_downshift_undefined; phy_info->polarity_correction = e1000_polarity_reversal_undefined; phy_info->mdix_mode = e1000_auto_x_mode_undefined; phy_info->local_rx = e1000_1000t_rx_status_undefined; @@ -2183,47 +2565,23 @@ return -E1000_ERR_CONFIG; } - do { - if(e1000_read_phy_reg(hw, PHY_STATUS, &phy_data) < 0) break; - if(e1000_read_phy_reg(hw, PHY_STATUS, &phy_data) < 0) break; - if((phy_data & MII_SR_LINK_STATUS) != MII_SR_LINK_STATUS) { - DEBUGOUT("PHY info is only valid if link is up\n"); - return -E1000_ERR_CONFIG; - } - - if(e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data) < 0) - break; - phy_info->extended_10bt_distance = - (phy_data & M88E1000_PSCR_10BT_EXT_DIST_ENABLE) >> - M88E1000_PSCR_10BT_EXT_DIST_ENABLE_SHIFT; - phy_info->polarity_correction = - (phy_data & M88E1000_PSCR_POLARITY_REVERSAL) >> - M88E1000_PSCR_POLARITY_REVERSAL_SHIFT; - - if(e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS, &phy_data) < 0) - break; - phy_info->cable_polarity = (phy_data & M88E1000_PSSR_REV_POLARITY) >> - M88E1000_PSSR_REV_POLARITY_SHIFT; - phy_info->mdix_mode = (phy_data & M88E1000_PSSR_MDIX) >> - M88E1000_PSSR_MDIX_SHIFT; - if(phy_data & M88E1000_PSSR_1000MBS) { - /* Cable Length Estimation and Local/Remote Receiver Informatoion - * are only valid at 1000 Mbps - */ - phy_info->cable_length = ((phy_data & M88E1000_PSSR_CABLE_LENGTH) >> - M88E1000_PSSR_CABLE_LENGTH_SHIFT); - if(e1000_read_phy_reg(hw, PHY_1000T_STATUS, &phy_data) < 0) - break; - phy_info->local_rx = (phy_data & SR_1000T_LOCAL_RX_STATUS) >> - SR_1000T_LOCAL_RX_STATUS_SHIFT; - phy_info->remote_rx = (phy_data & SR_1000T_REMOTE_RX_STATUS) >> - SR_1000T_REMOTE_RX_STATUS_SHIFT; - } - ret_val = 0; - } while(0); + if(e1000_read_phy_reg(hw, PHY_STATUS, &phy_data) < 0) { + DEBUGOUT("PHY Read Error\n"); + return -E1000_ERR_PHY; + } + if(e1000_read_phy_reg(hw, PHY_STATUS, &phy_data) < 0) { + DEBUGOUT("PHY Read Error\n"); + return -E1000_ERR_PHY; + } + if((phy_data & MII_SR_LINK_STATUS) != MII_SR_LINK_STATUS) { + DEBUGOUT("PHY info is only valid if link is up\n"); + return -E1000_ERR_CONFIG; + } - if(ret_val < 0) DEBUGOUT("PHY Read Error\n"); - return ret_val; + if (hw->phy_type == e1000_phy_igp) + return e1000_phy_igp_get_info(hw, phy_info); + else + return e1000_phy_m88_get_info(hw, phy_info); } int32_t @@ -2239,6 +2597,109 @@ return 0; } + +/****************************************************************************** + * Sets up eeprom variables in the hw struct. Must be called after mac_type + * is configured. + * + * hw - Struct containing variables accessed by shared code + *****************************************************************************/ +void +e1000_init_eeprom_params(struct e1000_hw *hw) +{ + struct e1000_eeprom_info *eeprom = &hw->eeprom; + uint32_t eecd = E1000_READ_REG(hw, EECD); + uint16_t eeprom_size; + + DEBUGFUNC("e1000_init_eeprom_params"); + + switch (hw->mac_type) { + case e1000_82542_rev2_0: + case e1000_82542_rev2_1: + case e1000_82543: + case e1000_82544: + eeprom->type = e1000_eeprom_microwire; + eeprom->word_size = 64; + eeprom->opcode_bits = 3; + eeprom->address_bits = 6; + eeprom->delay_usec = 50; + break; + case e1000_82540: + case e1000_82545: + case e1000_82546: + eeprom->type = e1000_eeprom_microwire; + eeprom->opcode_bits = 3; + eeprom->delay_usec = 50; + if(eecd & E1000_EECD_SIZE) { + eeprom->word_size = 256; + eeprom->address_bits = 8; + } else { + eeprom->word_size = 64; + eeprom->address_bits = 6; + } + break; + case e1000_82541: + case e1000_82547: + default: + if (eecd & E1000_EECD_TYPE) { + eeprom->type = e1000_eeprom_spi; + eeprom->opcode_bits = 8; + eeprom->delay_usec = 1; + if (eecd & E1000_EECD_ADDR_BITS) { + eeprom->page_size = 32; + eeprom->address_bits = 16; + } else { + eeprom->page_size = 8; + eeprom->address_bits = 8; + } + } else { + eeprom->type = e1000_eeprom_microwire; + eeprom->opcode_bits = 3; + eeprom->delay_usec = 50; + if (eecd & E1000_EECD_ADDR_BITS) { + eeprom->word_size = 256; + eeprom->address_bits = 8; + } else { + eeprom->word_size = 64; + eeprom->address_bits = 6; + } + } + break; + } + + if (eeprom->type == e1000_eeprom_spi) { + eeprom->word_size = 64; + if (e1000_read_eeprom(hw, EEPROM_CFG, 1, &eeprom_size) == 0) { + eeprom_size &= EEPROM_SIZE_MASK; + + switch (eeprom_size) { + case EEPROM_SIZE_16KB: + eeprom->word_size = 8192; + break; + case EEPROM_SIZE_8KB: + eeprom->word_size = 4096; + break; + case EEPROM_SIZE_4KB: + eeprom->word_size = 2048; + break; + case EEPROM_SIZE_2KB: + eeprom->word_size = 1024; + break; + case EEPROM_SIZE_1KB: + eeprom->word_size = 512; + break; + case EEPROM_SIZE_512B: + eeprom->word_size = 256; + break; + case EEPROM_SIZE_128B: + default: + eeprom->word_size = 64; + break; + } + } + } +} + /****************************************************************************** * Raises the EEPROM's clock input. * @@ -2255,26 +2716,26 @@ *eecd = *eecd | E1000_EECD_SK; E1000_WRITE_REG(hw, EECD, *eecd); E1000_WRITE_FLUSH(hw); - udelay(50); + udelay(hw->eeprom.delay_usec); } /****************************************************************************** * Lowers the EEPROM's clock input. * - * hw - Struct containing variables accessed by shared code + * hw - Struct containing variables accessed by shared code * eecd - EECD's current value *****************************************************************************/ static void e1000_lower_ee_clk(struct e1000_hw *hw, uint32_t *eecd) { - /* Lower the clock input to the EEPROM (by clearing the SK bit), and then - * wait 50 microseconds. + /* Lower the clock input to the EEPROM (by clearing the SK bit), and then + * wait 50 microseconds. */ *eecd = *eecd & ~E1000_EECD_SK; E1000_WRITE_REG(hw, EECD, *eecd); E1000_WRITE_FLUSH(hw); - udelay(50); + udelay(hw->eeprom.delay_usec); } /****************************************************************************** @@ -2289,16 +2750,21 @@ uint16_t data, uint16_t count) { + struct e1000_eeprom_info *eeprom = &hw->eeprom; uint32_t eecd; uint32_t mask; /* We need to shift "count" bits out to the EEPROM. So, value in the * "data" parameter will be shifted out to the EEPROM one bit at a time. - * In order to do this, "data" must be broken down into bits. + * In order to do this, "data" must be broken down into bits. */ mask = 0x01 << (count - 1); eecd = E1000_READ_REG(hw, EECD); - eecd &= ~(E1000_EECD_DO | E1000_EECD_DI); + if (eeprom->type == e1000_eeprom_microwire) { + eecd &= ~E1000_EECD_DO; + } else if (eeprom->type == e1000_eeprom_spi) { + eecd |= E1000_EECD_DO; + } do { /* A "1" is shifted out to the EEPROM by setting bit "DI" to a "1", * and then raising and then lowering the clock (the SK bit controls @@ -2313,7 +2779,7 @@ E1000_WRITE_REG(hw, EECD, eecd); E1000_WRITE_FLUSH(hw); - udelay(50); + udelay(eeprom->delay_usec); e1000_raise_ee_clk(hw, &eecd); e1000_lower_ee_clk(hw, &eecd); @@ -2333,7 +2799,7 @@ * hw - Struct containing variables accessed by shared code *****************************************************************************/ static uint16_t -e1000_shift_in_ee_bits(struct e1000_hw *hw) +e1000_shift_in_ee_bits(struct e1000_hw *hw, uint16_t count) { uint32_t eecd; uint32_t i; @@ -2351,7 +2817,7 @@ eecd &= ~(E1000_EECD_DO | E1000_EECD_DI); data = 0; - for(i = 0; i < 16; i++) { + for(i = 0; i < count; i++) { data = data << 1; e1000_raise_ee_clk(hw, &eecd); @@ -2372,104 +2838,196 @@ * * hw - Struct containing variables accessed by shared code * - * Lowers EEPROM clock. Clears input pin. Sets the chip select pin. This + * Lowers EEPROM clock. Clears input pin. Sets the chip select pin. This * function should be called before issuing a command to the EEPROM. *****************************************************************************/ -static void -e1000_setup_eeprom(struct e1000_hw *hw) +static int32_t +e1000_acquire_eeprom(struct e1000_hw *hw) { - uint32_t eecd; + struct e1000_eeprom_info *eeprom = &hw->eeprom; + uint32_t eecd, i=0; + + DEBUGFUNC("e1000_acquire_eeprom"); eecd = E1000_READ_REG(hw, EECD); - /* Clear SK and DI */ - eecd &= ~(E1000_EECD_SK | E1000_EECD_DI); - E1000_WRITE_REG(hw, EECD, eecd); + /* Request EEPROM Access */ + if(hw->mac_type > e1000_82544) { + eecd |= E1000_EECD_REQ; + E1000_WRITE_REG(hw, EECD, eecd); + eecd = E1000_READ_REG(hw, EECD); + while((!(eecd & E1000_EECD_GNT)) && + (i < E1000_EEPROM_GRANT_ATTEMPTS)) { + i++; + udelay(5); + eecd = E1000_READ_REG(hw, EECD); + } + if(!(eecd & E1000_EECD_GNT)) { + eecd &= ~E1000_EECD_REQ; + E1000_WRITE_REG(hw, EECD, eecd); + DEBUGOUT("Could not acquire EEPROM grant\n"); + return -E1000_ERR_EEPROM; + } + } - /* Set CS */ - eecd |= E1000_EECD_CS; - E1000_WRITE_REG(hw, EECD, eecd); + /* Setup EEPROM for Read/Write */ + + if (eeprom->type == e1000_eeprom_microwire) { + /* Clear SK and DI */ + eecd &= ~(E1000_EECD_DI | E1000_EECD_SK); + E1000_WRITE_REG(hw, EECD, eecd); + + /* Set CS */ + eecd |= E1000_EECD_CS; + E1000_WRITE_REG(hw, EECD, eecd); + } else if (eeprom->type == e1000_eeprom_spi) { + /* Clear SK and CS */ + eecd &= ~(E1000_EECD_CS | E1000_EECD_SK); + E1000_WRITE_REG(hw, EECD, eecd); + udelay(1); + } + + return E1000_SUCCESS; } /****************************************************************************** * Returns EEPROM to a "standby" state - * + * * hw - Struct containing variables accessed by shared code *****************************************************************************/ static void e1000_standby_eeprom(struct e1000_hw *hw) { + struct e1000_eeprom_info *eeprom = &hw->eeprom; uint32_t eecd; eecd = E1000_READ_REG(hw, EECD); - /* Deselct EEPROM */ - eecd &= ~(E1000_EECD_CS | E1000_EECD_SK); - E1000_WRITE_REG(hw, EECD, eecd); - E1000_WRITE_FLUSH(hw); - udelay(50); + if(eeprom->type == e1000_eeprom_microwire) { + eecd &= ~(E1000_EECD_CS | E1000_EECD_SK); + E1000_WRITE_REG(hw, EECD, eecd); + E1000_WRITE_FLUSH(hw); + udelay(eeprom->delay_usec); - /* Clock high */ - eecd |= E1000_EECD_SK; - E1000_WRITE_REG(hw, EECD, eecd); - E1000_WRITE_FLUSH(hw); - udelay(50); + /* Clock high */ + eecd |= E1000_EECD_SK; + E1000_WRITE_REG(hw, EECD, eecd); + E1000_WRITE_FLUSH(hw); + udelay(eeprom->delay_usec); - /* Select EEPROM */ - eecd |= E1000_EECD_CS; - E1000_WRITE_REG(hw, EECD, eecd); - E1000_WRITE_FLUSH(hw); - udelay(50); + /* Select EEPROM */ + eecd |= E1000_EECD_CS; + E1000_WRITE_REG(hw, EECD, eecd); + E1000_WRITE_FLUSH(hw); + udelay(eeprom->delay_usec); - /* Clock low */ - eecd &= ~E1000_EECD_SK; - E1000_WRITE_REG(hw, EECD, eecd); - E1000_WRITE_FLUSH(hw); - udelay(50); + /* Clock low */ + eecd &= ~E1000_EECD_SK; + E1000_WRITE_REG(hw, EECD, eecd); + E1000_WRITE_FLUSH(hw); + udelay(eeprom->delay_usec); + } else if(eeprom->type == e1000_eeprom_spi) { + /* Toggle CS to flush commands */ + eecd |= E1000_EECD_CS; + E1000_WRITE_REG(hw, EECD, eecd); + E1000_WRITE_FLUSH(hw); + udelay(eeprom->delay_usec); + eecd &= ~E1000_EECD_CS; + E1000_WRITE_REG(hw, EECD, eecd); + E1000_WRITE_FLUSH(hw); + udelay(eeprom->delay_usec); + } } /****************************************************************************** - * Raises then lowers the EEPROM's clock pin + * Terminates a command by inverting the EEPROM's chip select pin * * hw - Struct containing variables accessed by shared code *****************************************************************************/ static void -e1000_clock_eeprom(struct e1000_hw *hw) +e1000_release_eeprom(struct e1000_hw *hw) { uint32_t eecd; + DEBUGFUNC("e1000_release_eeprom"); + eecd = E1000_READ_REG(hw, EECD); - /* Rising edge of clock */ - eecd |= E1000_EECD_SK; - E1000_WRITE_REG(hw, EECD, eecd); - E1000_WRITE_FLUSH(hw); - udelay(50); + if (hw->eeprom.type == e1000_eeprom_spi) { + eecd |= E1000_EECD_CS; /* Pull CS high */ + eecd &= ~E1000_EECD_SK; /* Lower SCK */ - /* Falling edge of clock */ - eecd &= ~E1000_EECD_SK; - E1000_WRITE_REG(hw, EECD, eecd); - E1000_WRITE_FLUSH(hw); - udelay(50); + E1000_WRITE_REG(hw, EECD, eecd); + + udelay(hw->eeprom.delay_usec); + } else if(hw->eeprom.type == e1000_eeprom_microwire) { + /* cleanup eeprom */ + + /* CS on Microwire is active-high */ + eecd &= ~(E1000_EECD_CS | E1000_EECD_DI); + + E1000_WRITE_REG(hw, EECD, eecd); + + /* Rising edge of clock */ + eecd |= E1000_EECD_SK; + E1000_WRITE_REG(hw, EECD, eecd); + E1000_WRITE_FLUSH(hw); + udelay(hw->eeprom.delay_usec); + + /* Falling edge of clock */ + eecd &= ~E1000_EECD_SK; + E1000_WRITE_REG(hw, EECD, eecd); + E1000_WRITE_FLUSH(hw); + udelay(hw->eeprom.delay_usec); + } + + /* Stop requesting EEPROM access */ + if(hw->mac_type > e1000_82544) { + eecd &= ~E1000_EECD_REQ; + E1000_WRITE_REG(hw, EECD, eecd); + } } /****************************************************************************** - * Terminates a command by lowering the EEPROM's chip select pin + * Reads a 16 bit word from the EEPROM. * * hw - Struct containing variables accessed by shared code *****************************************************************************/ -static void -e1000_cleanup_eeprom(struct e1000_hw *hw) +int32_t +e1000_spi_eeprom_ready(struct e1000_hw *hw) { - uint32_t eecd; + uint16_t retry_count = 0; + uint8_t spi_stat_reg; - eecd = E1000_READ_REG(hw, EECD); + DEBUGFUNC("e1000_spi_eeprom_ready"); + + /* Read "Status Register" repeatedly until the LSB is cleared. The + * EEPROM will signal that the command has been completed by clearing + * bit 0 of the internal status register. If it's not cleared within + * 5 milliseconds, then error out. + */ + retry_count = 0; + do { + e1000_shift_out_ee_bits(hw, EEPROM_RDSR_OPCODE_SPI, + hw->eeprom.opcode_bits); + spi_stat_reg = (uint8_t)e1000_shift_in_ee_bits(hw, 8); + if (!(spi_stat_reg & EEPROM_STATUS_RDY_SPI)) + break; - eecd &= ~(E1000_EECD_CS | E1000_EECD_DI); + udelay(5); + retry_count += 5; - E1000_WRITE_REG(hw, EECD, eecd); + } while(retry_count < EEPROM_MAX_RETRY_SPI); + + /* ATMEL SPI write time could vary from 0-20mSec on 3.3V devices (and + * only 0-5mSec on 5V devices) + */ + if(retry_count >= EEPROM_MAX_RETRY_SPI) { + DEBUGOUT("SPI EEPROM Status error\n"); + return -E1000_ERR_EEPROM; + } - e1000_clock_eeprom(hw); + return E1000_SUCCESS; } /****************************************************************************** @@ -2477,71 +3035,76 @@ * * hw - Struct containing variables accessed by shared code * offset - offset of word in the EEPROM to read - * data - word read from the EEPROM + * data - word read from the EEPROM + * words - number of words to read *****************************************************************************/ int32_t e1000_read_eeprom(struct e1000_hw *hw, uint16_t offset, + uint16_t words, uint16_t *data) { - uint32_t eecd; + struct e1000_eeprom_info *eeprom = &hw->eeprom; uint32_t i = 0; - boolean_t large_eeprom = FALSE; DEBUGFUNC("e1000_read_eeprom"); - /* Request EEPROM Access */ - if(hw->mac_type > e1000_82544) { - eecd = E1000_READ_REG(hw, EECD); - if(eecd & E1000_EECD_SIZE) large_eeprom = TRUE; - eecd |= E1000_EECD_REQ; - E1000_WRITE_REG(hw, EECD, eecd); - eecd = E1000_READ_REG(hw, EECD); - while((!(eecd & E1000_EECD_GNT)) && (i < 100)) { - i++; - udelay(5); - eecd = E1000_READ_REG(hw, EECD); - } - if(!(eecd & E1000_EECD_GNT)) { - eecd &= ~E1000_EECD_REQ; - E1000_WRITE_REG(hw, EECD, eecd); - DEBUGOUT("Could not acquire EEPROM grant\n"); - return -E1000_ERR_EEPROM; - } + /* A check for invalid values: offset too large, too many words, and not + * enough words. + */ + if((offset > eeprom->word_size) || (words > eeprom->word_size - offset) || + (words == 0)) { + DEBUGOUT("\"words\" parameter out of bounds\n"); + return -E1000_ERR_EEPROM; } - /* Prepare the EEPROM for reading */ - e1000_setup_eeprom(hw); + /* Prepare the EEPROM for reading */ + if (e1000_acquire_eeprom(hw) != E1000_SUCCESS) + return -E1000_ERR_EEPROM; - /* Send the READ command (opcode + addr) */ - e1000_shift_out_ee_bits(hw, EEPROM_READ_OPCODE, 3); - if(large_eeprom) { - /* If we have a 256 word EEPROM, there are 8 address bits */ - e1000_shift_out_ee_bits(hw, offset, 8); - } else { - /* If we have a 64 word EEPROM, there are 6 address bits */ - e1000_shift_out_ee_bits(hw, offset, 6); - } + if(eeprom->type == e1000_eeprom_spi) { + uint8_t read_opcode = EEPROM_READ_OPCODE_SPI; - /* Read the data */ - *data = e1000_shift_in_ee_bits(hw); + if(e1000_spi_eeprom_ready(hw)) return -E1000_ERR_EEPROM; - /* End this read operation */ - e1000_standby_eeprom(hw); + e1000_standby_eeprom(hw); - /* Stop requesting EEPROM access */ - if(hw->mac_type > e1000_82544) { - eecd = E1000_READ_REG(hw, EECD); - eecd &= ~E1000_EECD_REQ; - E1000_WRITE_REG(hw, EECD, eecd); + /* Some SPI eeproms use the 8th address bit embedded in the opcode */ + if((eeprom->address_bits == 8) && (offset >= 128)) + read_opcode |= EEPROM_A8_OPCODE_SPI; + + /* Send the READ command (opcode + addr) */ + e1000_shift_out_ee_bits(hw, read_opcode, eeprom->opcode_bits); + e1000_shift_out_ee_bits(hw, (uint16_t)(offset*2), eeprom->address_bits); + } + else if(eeprom->type == e1000_eeprom_microwire) { + /* Send the READ command (opcode + addr) */ + e1000_shift_out_ee_bits(hw, EEPROM_READ_OPCODE_MICROWIRE, + eeprom->opcode_bits); + e1000_shift_out_ee_bits(hw, offset, eeprom->address_bits); + } + + /* Read the data. The address of the eeprom internally increments with + * each word (microwire) or byte (spi) being read, saving on the overhead + * of eeprom setup and tear-down. The address counter will roll over if + * reading beyond the size of the eeprom, thus allowing the entire memory + * to be read starting from any offset. */ + for (i = 0; i < words; i++) { + uint16_t word_in = e1000_shift_in_ee_bits(hw, 16); + if (eeprom->type == e1000_eeprom_spi) + word_in = (word_in >> 8) | (word_in << 8); + data[i] = word_in; } + /* End this read operation */ + e1000_release_eeprom(hw); + return 0; } /****************************************************************************** * Verifies that the EEPROM has a valid checksum - * + * * hw - Struct containing variables accessed by shared code * * Reads the first 64 16 bit words of the EEPROM and sums the values read. @@ -2557,7 +3120,7 @@ DEBUGFUNC("e1000_validate_eeprom_checksum"); for(i = 0; i < (EEPROM_CHECKSUM_REG + 1); i++) { - if(e1000_read_eeprom(hw, i, &eeprom_data) < 0) { + if(e1000_read_eeprom(hw, i, 1, &eeprom_data) < 0) { DEBUGOUT("EEPROM Read Error\n"); return -E1000_ERR_EEPROM; } @@ -2567,7 +3130,7 @@ if(checksum == (uint16_t) EEPROM_SUM) { return 0; } else { - DEBUGOUT("EEPROM Checksum Invalid\n"); + DEBUGOUT("EEPROM Checksum Invalid\n"); return -E1000_ERR_EEPROM; } } @@ -2589,14 +3152,14 @@ DEBUGFUNC("e1000_update_eeprom_checksum"); for(i = 0; i < EEPROM_CHECKSUM_REG; i++) { - if(e1000_read_eeprom(hw, i, &eeprom_data) < 0) { + if(e1000_read_eeprom(hw, i, 1, &eeprom_data) < 0) { DEBUGOUT("EEPROM Read Error\n"); return -E1000_ERR_EEPROM; } checksum += eeprom_data; } checksum = (uint16_t) EEPROM_SUM - checksum; - if(e1000_write_eeprom(hw, EEPROM_CHECKSUM_REG, checksum) < 0) { + if(e1000_write_eeprom(hw, EEPROM_CHECKSUM_REG, 1, &checksum) < 0) { DEBUGOUT("EEPROM Write Error\n"); return -E1000_ERR_EEPROM; } @@ -2604,118 +3167,201 @@ } /****************************************************************************** - * Writes a 16 bit word to a given offset in the EEPROM. + * Parent function for writing words to the different EEPROM types. * * hw - Struct containing variables accessed by shared code * offset - offset within the EEPROM to be written to - * data - 16 bit word to be writen to the EEPROM + * words - number of words to write + * data - 16 bit word to be written to the EEPROM * - * If e1000_update_eeprom_checksum is not called after this function, the + * If e1000_update_eeprom_checksum is not called after this function, the * EEPROM will most likely contain an invalid checksum. *****************************************************************************/ int32_t e1000_write_eeprom(struct e1000_hw *hw, uint16_t offset, - uint16_t data) + uint16_t words, + uint16_t *data) { - uint32_t eecd; - uint32_t i = 0; + struct e1000_eeprom_info *eeprom = &hw->eeprom; int32_t status = 0; - boolean_t large_eeprom = FALSE; DEBUGFUNC("e1000_write_eeprom"); - /* Request EEPROM Access */ - if(hw->mac_type > e1000_82544) { - eecd = E1000_READ_REG(hw, EECD); - if(eecd & E1000_EECD_SIZE) large_eeprom = TRUE; - eecd |= E1000_EECD_REQ; - E1000_WRITE_REG(hw, EECD, eecd); - eecd = E1000_READ_REG(hw, EECD); - while((!(eecd & E1000_EECD_GNT)) && (i < 100)) { - i++; - udelay(5); - eecd = E1000_READ_REG(hw, EECD); - } - if(!(eecd & E1000_EECD_GNT)) { - eecd &= ~E1000_EECD_REQ; - E1000_WRITE_REG(hw, EECD, eecd); - DEBUGOUT("Could not acquire EEPROM grant\n"); - return -E1000_ERR_EEPROM; - } + /* A check for invalid values: offset too large, too many words, and not + * enough words. + */ + if((offset > eeprom->word_size) || (words > eeprom->word_size - offset) || + (words == 0)) { + DEBUGOUT("\"words\" parameter out of bounds\n"); + return -E1000_ERR_EEPROM; } /* Prepare the EEPROM for writing */ - e1000_setup_eeprom(hw); + if (e1000_acquire_eeprom(hw) != E1000_SUCCESS) + return -E1000_ERR_EEPROM; - /* Send the 9-bit (or 11-bit on large EEPROM) EWEN (write enable) command - * to the EEPROM (5-bit opcode plus 4/6-bit dummy). This puts the EEPROM - * into write/erase mode. - */ - e1000_shift_out_ee_bits(hw, EEPROM_EWEN_OPCODE, 5); - if(large_eeprom) - e1000_shift_out_ee_bits(hw, 0, 6); + if(eeprom->type == e1000_eeprom_microwire) + status = e1000_write_eeprom_microwire(hw, offset, words, data); else - e1000_shift_out_ee_bits(hw, 0, 4); + status = e1000_write_eeprom_spi(hw, offset, words, data); - /* Prepare the EEPROM */ - e1000_standby_eeprom(hw); + /* Done with writing */ + e1000_release_eeprom(hw); - /* Send the Write command (3-bit opcode + addr) */ - e1000_shift_out_ee_bits(hw, EEPROM_WRITE_OPCODE, 3); - if(large_eeprom) - /* If we have a 256 word EEPROM, there are 8 address bits */ - e1000_shift_out_ee_bits(hw, offset, 8); - else - /* If we have a 64 word EEPROM, there are 6 address bits */ - e1000_shift_out_ee_bits(hw, offset, 6); + return status; +} - /* Send the data */ - e1000_shift_out_ee_bits(hw, data, 16); +/****************************************************************************** + * Writes a 16 bit word to a given offset in an SPI EEPROM. + * + * hw - Struct containing variables accessed by shared code + * offset - offset within the EEPROM to be written to + * words - number of words to write + * data - pointer to array of 8 bit words to be written to the EEPROM + * + *****************************************************************************/ +int32_t +e1000_write_eeprom_spi(struct e1000_hw *hw, + uint16_t offset, + uint16_t words, + uint16_t *data) +{ + struct e1000_eeprom_info *eeprom = &hw->eeprom; + uint16_t widx = 0; - /* Toggle the CS line. This in effect tells to EEPROM to actually execute - * the command in question. - */ - e1000_standby_eeprom(hw); + DEBUGFUNC("e1000_write_eeprom_spi"); - /* Now read DO repeatedly until is high (equal to '1'). The EEEPROM will - * signal that the command has been completed by raising the DO signal. - * If DO does not go high in 10 milliseconds, then error out. - */ - for(i = 0; i < 200; i++) { - eecd = E1000_READ_REG(hw, EECD); - if(eecd & E1000_EECD_DO) break; - udelay(50); - } - if(i == 200) { - DEBUGOUT("EEPROM Write did not complete\n"); - status = -E1000_ERR_EEPROM; + while (widx < words) { + uint8_t write_opcode = EEPROM_WRITE_OPCODE_SPI; + + if(e1000_spi_eeprom_ready(hw)) return -E1000_ERR_EEPROM; + + e1000_standby_eeprom(hw); + + /* Send the WRITE ENABLE command (8 bit opcode ) */ + e1000_shift_out_ee_bits(hw, EEPROM_WREN_OPCODE_SPI, + eeprom->opcode_bits); + + e1000_standby_eeprom(hw); + + /* Some SPI eeproms use the 8th address bit embedded in the opcode */ + if((eeprom->address_bits == 8) && (offset >= 128)) + write_opcode |= EEPROM_A8_OPCODE_SPI; + + /* Send the Write command (8-bit opcode + addr) */ + e1000_shift_out_ee_bits(hw, write_opcode, eeprom->opcode_bits); + + e1000_shift_out_ee_bits(hw, (uint16_t)((offset + widx)*2), + eeprom->address_bits); + + /* Send the data */ + + /* Loop to allow for up to whole page write (32 bytes) of eeprom */ + while (widx < words) { + uint16_t word_out = data[widx]; + word_out = (word_out >> 8) | (word_out << 8); + e1000_shift_out_ee_bits(hw, word_out, 16); + widx++; + + /* Some larger eeprom sizes are capable of a 32-byte PAGE WRITE + * operation, while the smaller eeproms are capable of an 8-byte + * PAGE WRITE operation. Break the inner loop to pass new address + */ + if((((offset + widx)*2) % eeprom->page_size) == 0) { + e1000_standby_eeprom(hw); + break; + } + } } - /* Recover from write */ + return E1000_SUCCESS; +} + +/****************************************************************************** + * Writes a 16 bit word to a given offset in a Microwire EEPROM. + * + * hw - Struct containing variables accessed by shared code + * offset - offset within the EEPROM to be written to + * words - number of words to write + * data - pointer to array of 16 bit words to be written to the EEPROM + * + *****************************************************************************/ +int32_t +e1000_write_eeprom_microwire(struct e1000_hw *hw, + uint16_t offset, + uint16_t words, + uint16_t *data) +{ + struct e1000_eeprom_info *eeprom = &hw->eeprom; + uint32_t eecd; + uint16_t words_written = 0; + uint16_t i = 0; + + DEBUGFUNC("e1000_write_eeprom_microwire"); + + /* Send the write enable command to the EEPROM (3-bit opcode plus + * 6/8-bit dummy address beginning with 11). It's less work to include + * the 11 of the dummy address as part of the opcode than it is to shift + * it over the correct number of bits for the address. This puts the + * EEPROM into write/erase mode. + */ + e1000_shift_out_ee_bits(hw, EEPROM_EWEN_OPCODE_MICROWIRE, + (uint16_t)(eeprom->opcode_bits + 2)); + + e1000_shift_out_ee_bits(hw, 0, (uint16_t)(eeprom->address_bits - 2)); + + /* Prepare the EEPROM */ e1000_standby_eeprom(hw); - /* Send the 9-bit (or 11-bit on large EEPROM) EWDS (write disable) command - * to the EEPROM (5-bit opcode plus 4/6-bit dummy). This takes the EEPROM - * out of write/erase mode. - */ - e1000_shift_out_ee_bits(hw, EEPROM_EWDS_OPCODE, 5); - if(large_eeprom) - e1000_shift_out_ee_bits(hw, 0, 6); - else - e1000_shift_out_ee_bits(hw, 0, 4); + while (words_written < words) { + /* Send the Write command (3-bit opcode + addr) */ + e1000_shift_out_ee_bits(hw, EEPROM_WRITE_OPCODE_MICROWIRE, + eeprom->opcode_bits); - /* Done with writing */ - e1000_cleanup_eeprom(hw); + e1000_shift_out_ee_bits(hw, (uint16_t)(offset + words_written), + eeprom->address_bits); - /* Stop requesting EEPROM access */ - if(hw->mac_type > e1000_82544) { - eecd = E1000_READ_REG(hw, EECD); - eecd &= ~E1000_EECD_REQ; - E1000_WRITE_REG(hw, EECD, eecd); + /* Send the data */ + e1000_shift_out_ee_bits(hw, data[words_written], 16); + + /* Toggle the CS line. This in effect tells the EEPROM to execute + * the previous command. + */ + e1000_standby_eeprom(hw); + + /* Read DO repeatedly until it is high (equal to '1'). The EEPROM will + * signal that the command has been completed by raising the DO signal. + * If DO does not go high in 10 milliseconds, then error out. + */ + for(i = 0; i < 200; i++) { + eecd = E1000_READ_REG(hw, EECD); + if(eecd & E1000_EECD_DO) break; + udelay(50); + } + if(i == 200) { + DEBUGOUT("EEPROM Write did not complete\n"); + return -E1000_ERR_EEPROM; + } + + /* Recover from write */ + e1000_standby_eeprom(hw); + + words_written++; } - return status; + /* Send the write disable command to the EEPROM (3-bit opcode plus + * 6/8-bit dummy address beginning with 10). It's less work to include + * the 10 of the dummy address as part of the opcode than it is to shift + * it over the correct number of bits for the address. This takes the + * EEPROM out of write/erase mode. + */ + e1000_shift_out_ee_bits(hw, EEPROM_EWDS_OPCODE_MICROWIRE, + (uint16_t)(eeprom->opcode_bits + 2)); + + e1000_shift_out_ee_bits(hw, 0, (uint16_t)(eeprom->address_bits - 2)); + + return 0; } /****************************************************************************** @@ -2734,7 +3380,7 @@ DEBUGFUNC("e1000_read_part_num"); /* Get word 0 from EEPROM */ - if(e1000_read_eeprom(hw, offset, &eeprom_data) < 0) { + if(e1000_read_eeprom(hw, offset, 1, &eeprom_data) < 0) { DEBUGOUT("EEPROM Read Error\n"); return -E1000_ERR_EEPROM; } @@ -2742,7 +3388,7 @@ *part_num = (uint32_t) (eeprom_data << 16); /* Get word 1 from EEPROM */ - if(e1000_read_eeprom(hw, ++offset, &eeprom_data) < 0) { + if(e1000_read_eeprom(hw, ++offset, 1, &eeprom_data) < 0) { DEBUGOUT("EEPROM Read Error\n"); return -E1000_ERR_EEPROM; } @@ -2768,7 +3414,7 @@ for(i = 0; i < NODE_ADDRESS_SIZE; i += 2) { offset = i >> 1; - if(e1000_read_eeprom(hw, offset, &eeprom_data) < 0) { + if(e1000_read_eeprom(hw, offset, 1, &eeprom_data) < 0) { DEBUGOUT("EEPROM Read Error\n"); return -E1000_ERR_EEPROM; } @@ -2790,7 +3436,7 @@ /****************************************************************************** * Initializes receive address filters. * - * hw - Struct containing variables accessed by shared code + * hw - Struct containing variables accessed by shared code * * Places the MAC address in receive address register 0 and clears the rest * of the receive addresss registers. Clears the multicast table. Assumes @@ -2835,7 +3481,7 @@ * * The given list replaces any existing list. Clears the last 15 receive * address registers and the multicast table. Uses receive address registers - * for the first 15 multicast addresses, and hashes the rest into the + * for the first 15 multicast addresses, and hashes the rest into the * multicast table. *****************************************************************************/ void @@ -2884,7 +3530,7 @@ DEBUGOUT1(" Hash value = 0x%03X\n", hash_value); /* Place this multicast address in the RAR if there is room, * - * else put it in the MTA + * else put it in the MTA */ if(rar_used_count < E1000_RAR_ENTRIES) { e1000_rar_set(hw, @@ -2902,7 +3548,7 @@ * Hashes an address to determine its location in the multicast table * * hw - Struct containing variables accessed by shared code - * mc_addr - the multicast address to hash + * mc_addr - the multicast address to hash *****************************************************************************/ uint32_t e1000_hash_mc_addr(struct e1000_hw *hw, @@ -2911,7 +3557,7 @@ uint32_t hash_value = 0; /* The portion of the address that is used for the hash table is - * determined by the mc_filter_type setting. + * determined by the mc_filter_type setting. */ switch (hw->mc_filter_type) { /* [0] [1] [2] [3] [4] [5] @@ -2954,12 +3600,12 @@ uint32_t mta; uint32_t temp; - /* The MTA is a register array of 128 32-bit registers. - * It is treated like an array of 4096 bits. We want to set + /* The MTA is a register array of 128 32-bit registers. + * It is treated like an array of 4096 bits. We want to set * bit BitArray[hash_value]. So we figure out what register * the bit is in, read it, OR in the new bit, then write - * back the new value. The register is determined by the - * upper 7 bits of the hash value and the bit within that + * back the new value. The register is determined by the + * upper 7 bits of the hash value and the bit within that * register are determined by the lower 5 bits of the value. */ hash_reg = (hash_value >> 5) & 0x7F; @@ -2997,7 +3643,7 @@ uint32_t rar_low, rar_high; /* HW expects these in little endian so we reverse the byte order - * from network order (big endian) to little endian + * from network order (big endian) to little endian */ rar_low = ((uint32_t) addr[0] | ((uint32_t) addr[1] << 8) | @@ -3055,24 +3701,24 @@ const uint32_t ledctl_off = E1000_LEDCTL_MODE_LED_OFF; uint16_t eeprom_data, i, temp; const uint16_t led_mask = 0x0F; - + DEBUGFUNC("e1000_id_led_init"); - + if(hw->mac_type < e1000_82540) { /* Nothing to do */ return 0; } - + ledctl = E1000_READ_REG(hw, LEDCTL); hw->ledctl_default = ledctl; hw->ledctl_mode1 = hw->ledctl_default; hw->ledctl_mode2 = hw->ledctl_default; - - if(e1000_read_eeprom(hw, EEPROM_ID_LED_SETTINGS, &eeprom_data) < 0) { + + if(e1000_read_eeprom(hw, EEPROM_ID_LED_SETTINGS, 1, &eeprom_data) < 0) { DEBUGOUT("EEPROM Read Error\n"); return -E1000_ERR_EEPROM; } - if((eeprom_data== ID_LED_RESERVED_0000) || + if((eeprom_data== ID_LED_RESERVED_0000) || (eeprom_data == ID_LED_RESERVED_FFFF)) eeprom_data = ID_LED_DEFAULT; for(i = 0; i < 4; i++) { temp = (eeprom_data >> (i << 2)) & led_mask; @@ -3123,9 +3769,9 @@ e1000_setup_led(struct e1000_hw *hw) { uint32_t ledctl; - + DEBUGFUNC("e1000_setup_led"); - + switch(hw->device_id) { case E1000_DEV_ID_82542: case E1000_DEV_ID_82543GC_FIBER: @@ -3143,7 +3789,7 @@ hw->ledctl_default = ledctl; /* Turn off LED0 */ ledctl &= ~(E1000_LEDCTL_LED0_IVRT | - E1000_LEDCTL_LED0_BLINK | + E1000_LEDCTL_LED0_BLINK | E1000_LEDCTL_LED0_MODE_MASK); ledctl |= (E1000_LEDCTL_MODE_LED_OFF << E1000_LEDCTL_LED0_MODE_SHIFT); E1000_WRITE_REG(hw, LEDCTL, ledctl); @@ -3155,6 +3801,9 @@ case E1000_DEV_ID_82540EM_LOM: case E1000_DEV_ID_82545EM_COPPER: case E1000_DEV_ID_82546EB_COPPER: + case E1000_DEV_ID_82541EI: + case E1000_DEV_ID_82541EP: + case E1000_DEV_ID_82547EI: E1000_WRITE_REG(hw, LEDCTL, hw->ledctl_mode1); break; default: @@ -3193,6 +3842,9 @@ case E1000_DEV_ID_82545EM_FIBER: case E1000_DEV_ID_82546EB_COPPER: case E1000_DEV_ID_82546EB_FIBER: + case E1000_DEV_ID_82541EI: + case E1000_DEV_ID_82541EP: + case E1000_DEV_ID_82547EI: /* Restore LEDCTL settings */ E1000_WRITE_REG(hw, LEDCTL, hw->ledctl_default); break; @@ -3202,7 +3854,7 @@ } return 0; } - + /****************************************************************************** * Turns on the software controllable LED * @@ -3244,6 +3896,9 @@ case E1000_DEV_ID_82540EM_LOM: case E1000_DEV_ID_82545EM_COPPER: case E1000_DEV_ID_82546EB_COPPER: + case E1000_DEV_ID_82541EI: + case E1000_DEV_ID_82541EP: + case E1000_DEV_ID_82547EI: E1000_WRITE_REG(hw, LEDCTL, hw->ledctl_mode2); break; default: @@ -3294,6 +3949,9 @@ case E1000_DEV_ID_82540EM_LOM: case E1000_DEV_ID_82545EM_COPPER: case E1000_DEV_ID_82546EB_COPPER: + case E1000_DEV_ID_82541EI: + case E1000_DEV_ID_82541EP: + case E1000_DEV_ID_82547EI: E1000_WRITE_REG(hw, LEDCTL, hw->ledctl_mode1); break; default: @@ -3304,7 +3962,7 @@ } /****************************************************************************** - * Clears all hardware statistics counters. + * Clears all hardware statistics counters. * * hw - Struct containing variables accessed by shared code *****************************************************************************/ @@ -3423,7 +4081,7 @@ DEBUGFUNC("e1000_update_adaptive"); if(hw->adaptive_ifs) { - if((hw->collision_delta * hw->ifs_ratio) > + if((hw->collision_delta * hw->ifs_ratio) > hw->tx_packet_delta) { if(hw->tx_packet_delta > MIN_NUM_XMITS) { hw->in_ifs_mode = TRUE; @@ -3436,7 +4094,7 @@ } } } else { - if((hw->in_ifs_mode == TRUE) && + if((hw->in_ifs_mode == TRUE) && (hw->tx_packet_delta <= MIN_NUM_XMITS)) { hw->current_ifs_val = 0; hw->in_ifs_mode = FALSE; @@ -3450,7 +4108,7 @@ /****************************************************************************** * Adjusts the statistic counters when a frame is accepted by TBI_ACCEPT - * + * * hw - Struct containing variables accessed by shared code * frame_len - The length of the frame in question * mac_addr - The Ethernet destination address of the frame in question @@ -3478,16 +4136,16 @@ carry_bit = 0x80000000 & stats->gorcl; stats->gorcl += frame_len; /* If the high bit of Gorcl (the low 32 bits of the Good Octets - * Received Count) was one before the addition, - * AND it is zero after, then we lost the carry out, + * Received Count) was one before the addition, + * AND it is zero after, then we lost the carry out, * need to add one to Gorch (Good Octets Received Count High). - * This could be simplified if all environments supported + * This could be simplified if all environments supported * 64-bit integers. */ if(carry_bit && ((stats->gorcl & 0x80000000) == 0)) stats->gorch++; /* Is this a broadcast or multicast? Check broadcast first, - * since the test for a multicast frame will test positive on + * since the test for a multicast frame will test positive on * a broadcast frame. */ if((mac_addr[0] == (uint8_t) 0xff) && (mac_addr[1] == (uint8_t) 0xff)) @@ -3606,5 +4264,223 @@ e1000_io_write(hw, io_addr, offset); e1000_io_write(hw, io_data, value); +} + + +/****************************************************************************** + * Estimates the cable length. + * + * hw - Struct containing variables accessed by shared code + * min_length - The estimated minimum length + * max_length - The estimated maximum length + * + * returns: E1000_SUCCESS / -E1000_ERR_XXX + * + * This function always returns a ranged length (minimum & maximum). + * So for M88 phy's, this function interprets the one value returned from the + * register to the minimum and maximum range. + * For IGP phy's, the function calculates the range by the AGC registers. + *****************************************************************************/ +int32_t +e1000_get_cable_length(struct e1000_hw *hw, uint16_t *min_length, + uint16_t *max_length) +{ + uint16_t agc_value = 0; + uint16_t cur_agc, min_agc = IGP01E1000_AGC_LENGTH_TABLE_SIZE; + uint16_t i, phy_data; + + DEBUGFUNC("e1000_get_cable_length"); + + *min_length = *max_length = 0; + + /* Use old method for Phy older than IGP */ + if(hw->phy_type == e1000_phy_m88) { + if(e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS, &phy_data) < 0) + return -E1000_ERR_PHY; + + /* Convert the enum value to ranged values */ + switch((phy_data & M88E1000_PSSR_CABLE_LENGTH) >> + M88E1000_PSSR_CABLE_LENGTH_SHIFT) { + case e1000_cable_length_50: + *min_length = 0; + *max_length = e1000_igp_cable_length_50; + break; + case e1000_cable_length_50_80: + *min_length = e1000_igp_cable_length_50; + *max_length = e1000_igp_cable_length_80; + break; + case e1000_cable_length_80_110: + *min_length = e1000_igp_cable_length_80; + *max_length = e1000_igp_cable_length_110; + break; + case e1000_cable_length_110_140: + *min_length = e1000_igp_cable_length_110; + *max_length = e1000_igp_cable_length_140; + break; + case e1000_cable_length_140: + *min_length = e1000_igp_cable_length_140; + *max_length = e1000_igp_cable_length_170; + break; + default: + return -E1000_ERR_PHY; + break; + } + } else if(hw->phy_type == e1000_phy_igp) { /* For IGP PHY */ + uint16_t agc_reg_array[IGP01E1000_PHY_AGC_NUM] = {IGP01E1000_PHY_AGC_A, + IGP01E1000_PHY_AGC_B, + IGP01E1000_PHY_AGC_C, + IGP01E1000_PHY_AGC_D}; + /* Read the AGC registers for all channels */ + for(i = 0; i < IGP01E1000_PHY_AGC_NUM; i++) { + if(e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT, + agc_reg_array[i]) != E1000_SUCCESS) + return -E1000_ERR_PHY; + if(e1000_read_phy_reg(hw, agc_reg_array[i] & + IGP01E1000_PHY_PAGE_SELECT, &phy_data) != + E1000_SUCCESS) + return -E1000_ERR_PHY; + + cur_agc = phy_data >> IGP01E1000_AGC_LENGTH_SHIFT; + + /* Array bound check. */ + if((cur_agc >= IGP01E1000_AGC_LENGTH_TABLE_SIZE - 1) || + (cur_agc == 0)) + return -E1000_ERR_PHY; + + agc_value += cur_agc; + + /* Update minimal AGC value. */ + if(min_agc > cur_agc) + min_agc = cur_agc; + } + + /* Return to page 0 */ + if(e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT, 0x0) != + E1000_SUCCESS) + return -E1000_ERR_PHY; + + /* Remove the minimal AGC result for length < 50m */ + if(agc_value < IGP01E1000_PHY_AGC_NUM * e1000_igp_cable_length_50) { + agc_value -= min_agc; + + /* Get the average length of the remaining 3 channels */ + agc_value /= (IGP01E1000_PHY_AGC_NUM - 1); + } else { + /* Get the average length of all the 4 channels. */ + agc_value /= IGP01E1000_PHY_AGC_NUM; + } + + /* Set the range of the calculated length. */ + *min_length = ((e1000_igp_cable_length_table[agc_value] - + IGP01E1000_AGC_RANGE) > 0) ? + (e1000_igp_cable_length_table[agc_value] - + IGP01E1000_AGC_RANGE) : 0; + *max_length = e1000_igp_cable_length_table[agc_value] + + IGP01E1000_AGC_RANGE; + } + + return E1000_SUCCESS; +} + +/****************************************************************************** + * Check the cable polarity + * + * hw - Struct containing variables accessed by shared code + * polarity - output parameter : 0 - Polarity is not reversed + * 1 - Polarity is reversed. + * + * returns: E1000_SUCCESS / -E1000_ERR_XXX + * + * For phy's older then IGP, this function simply reads the polarity bit in the + * Phy Status register. For IGP phy's, this bit is valid only if link speed is + * 10 Mbps. If the link speed is 100 Mbps there is no polarity so this bit will + * return 0. If the link speed is 1000 Mbps the polarity status is in the + * IGP01E1000_PHY_PCS_INIT_REG. + *****************************************************************************/ +int32_t +e1000_check_polarity(struct e1000_hw *hw, uint16_t *polarity) +{ + uint16_t phy_data; + + DEBUGFUNC("e1000_check_polarity"); + + if(hw->phy_type == e1000_phy_m88) { + /* return the Polarity bit in the Status register. */ + if(e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS, &phy_data) < 0) + return -E1000_ERR_PHY; + *polarity = (phy_data & M88E1000_PSSR_REV_POLARITY) >> + M88E1000_PSSR_REV_POLARITY_SHIFT; + } else if(hw->phy_type == e1000_phy_igp) { + /* Read the Status register to check the speed */ + if(e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_STATUS, &phy_data) < 0) + return -E1000_ERR_PHY; + + /* If speed is 1000 Mbps, must read the IGP01E1000_PHY_PCS_INIT_REG to + * find the polarity status */ + if((phy_data & IGP01E1000_PSSR_SPEED_MASK) == + IGP01E1000_PSSR_SPEED_1000MBPS) { + + /* Read the GIG initialization PCS register (0x00B4) */ + if(e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT, + IGP01E1000_PHY_PCS_INIT_REG) < 0) + return -E1000_ERR_PHY; + + if(e1000_read_phy_reg(hw, IGP01E1000_PHY_PCS_INIT_REG & + IGP01E1000_PHY_PAGE_SELECT, &phy_data) < 0) + return -E1000_ERR_PHY; + + /* Return to page 0 */ + if(e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT, 0x0) != + E1000_SUCCESS) + return -E1000_ERR_PHY; + + /* Check the polarity bits */ + *polarity = (phy_data & IGP01E1000_PHY_POLARITY_MASK) ? 1 : 0; + } else { + /* For 10 Mbps, read the polarity bit in the status register. (for + * 100 Mbps this bit is always 0) */ + *polarity = phy_data & IGP01E1000_PSSR_POLARITY_REVERSED; + } + } + return E1000_SUCCESS; +} + +/****************************************************************************** + * Check if Downshift occured + * + * hw - Struct containing variables accessed by shared code + * downshift - output parameter : 0 - No Downshift ocured. + * 1 - Downshift ocured. + * + * returns: E1000_SUCCESS / -E1000_ERR_XXX + * + * For phy's older then IGP, this function reads the Downshift bit in the Phy + * Specific Status register. For IGP phy's, it reads the Downgrade bit in the + * Link Health register. In IGP this bit is latched high, so the driver must + * read it immediately after link is established. + *****************************************************************************/ +int32_t +e1000_check_downshift(struct e1000_hw *hw) +{ + uint16_t phy_data; + + DEBUGFUNC("e1000_check_downshift"); + + if(hw->phy_type == e1000_phy_igp) { + if(e1000_read_phy_reg(hw, IGP01E1000_PHY_LINK_HEALTH, &phy_data) < 0) { + DEBUGOUT("PHY Read Error\n"); + return -E1000_ERR_PHY; + } + hw->speed_downgraded = (phy_data & IGP01E1000_PLHR_SS_DOWNGRADE) ? 1 : 0; + } + else if(hw->phy_type == e1000_phy_m88) { + if(e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS, &phy_data) < 0) { + DEBUGOUT("PHY Read Error\n"); + return -E1000_ERR_PHY; + } + hw->speed_downgraded = (phy_data & M88E1000_PSSR_DOWNSHIFT) >> + M88E1000_PSSR_DOWNSHIFT_SHIFT; + } + return E1000_SUCCESS; } diff -Nru a/drivers/net/e1000/e1000_hw.h b/drivers/net/e1000/e1000_hw.h --- a/drivers/net/e1000/e1000_hw.h Sun Mar 23 00:22:55 2003 +++ b/drivers/net/e1000/e1000_hw.h Sun Mar 23 00:22:55 2003 @@ -1,7 +1,7 @@ /******************************************************************************* - Copyright(c) 1999 - 2002 Intel Corporation. All rights reserved. + Copyright(c) 1999 - 2003 Intel Corporation. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -33,6 +33,7 @@ #ifndef _E1000_HW_H_ #define _E1000_HW_H_ + #include "e1000_osdep.h" /* Forward declarations of structures used by the shared code */ @@ -50,9 +51,18 @@ e1000_82540, e1000_82545, e1000_82546, + e1000_82541, + e1000_82547, e1000_num_macs } e1000_mac_type; +typedef enum { + e1000_eeprom_uninitialized = 0, + e1000_eeprom_spi, + e1000_eeprom_microwire, + e1000_num_eeprom_types +} e1000_eeprom_type; + /* Media Types */ typedef enum { e1000_media_type_copper = 0, @@ -111,6 +121,27 @@ } e1000_cable_length; typedef enum { + e1000_igp_cable_length_10 = 10, + e1000_igp_cable_length_20 = 20, + e1000_igp_cable_length_30 = 30, + e1000_igp_cable_length_40 = 40, + e1000_igp_cable_length_50 = 50, + e1000_igp_cable_length_60 = 60, + e1000_igp_cable_length_70 = 70, + e1000_igp_cable_length_80 = 80, + e1000_igp_cable_length_90 = 90, + e1000_igp_cable_length_100 = 100, + e1000_igp_cable_length_110 = 110, + e1000_igp_cable_length_120 = 120, + e1000_igp_cable_length_130 = 130, + e1000_igp_cable_length_140 = 140, + e1000_igp_cable_length_150 = 150, + e1000_igp_cable_length_160 = 160, + e1000_igp_cable_length_170 = 170, + e1000_igp_cable_length_180 = 180 +} e1000_igp_cable_length; + +typedef enum { e1000_10bt_ext_dist_enable_normal = 0, e1000_10bt_ext_dist_enable_lower, e1000_10bt_ext_dist_enable_undefined = 0xFF @@ -123,6 +154,12 @@ } e1000_rev_polarity; typedef enum { + e1000_downshift_normal = 0, + e1000_downshift_activated, + e1000_downshift_undefined = 0xFF +} e1000_downshift; + +typedef enum { e1000_polarity_reversal_enabled = 0, e1000_polarity_reversal_disabled, e1000_polarity_reversal_undefined = 0xFF @@ -142,10 +179,17 @@ e1000_1000t_rx_status_undefined = 0xFF } e1000_1000t_rx_status; +typedef enum { + e1000_phy_m88 = 0, + e1000_phy_igp, + e1000_phy_undefined = 0xFF +} e1000_phy_type; + struct e1000_phy_info { e1000_cable_length cable_length; e1000_10bt_ext_dist_enable extended_10bt_distance; e1000_rev_polarity cable_polarity; + e1000_downshift downshift; e1000_polarity_reversal polarity_correction; e1000_auto_x_mode mdix_mode; e1000_1000t_rx_status local_rx; @@ -157,6 +201,15 @@ uint32_t receive_errors; }; +struct e1000_eeprom_info { + e1000_eeprom_type type; + uint16_t word_size; + uint16_t opcode_bits; + uint16_t address_bits; + uint16_t delay_usec; + uint16_t page_size; +}; + /* Error Codes */ @@ -166,6 +219,7 @@ #define E1000_ERR_CONFIG 3 #define E1000_ERR_PARAM 4 #define E1000_ERR_MAC_TYPE 5 +#define E1000_ERR_PHY_TYPE 6 /* Function prototypes */ /* Initialization */ @@ -189,13 +243,19 @@ int32_t e1000_phy_reset(struct e1000_hw *hw); int32_t e1000_detect_gig_phy(struct e1000_hw *hw); int32_t e1000_phy_get_info(struct e1000_hw *hw, struct e1000_phy_info *phy_info); +int32_t e1000_phy_m88_get_info(struct e1000_hw *hw, struct e1000_phy_info *phy_info); +int32_t e1000_phy_igp_get_info(struct e1000_hw *hw, struct e1000_phy_info *phy_info); +int32_t e1000_get_cable_length(struct e1000_hw *hw, uint16_t *min_length, uint16_t *max_length); +int32_t e1000_check_polarity(struct e1000_hw *hw, uint16_t *polarity); +int32_t e1000_check_downshift(struct e1000_hw *hw); int32_t e1000_validate_mdi_setting(struct e1000_hw *hw); /* EEPROM Functions */ -int32_t e1000_read_eeprom(struct e1000_hw *hw, uint16_t reg, uint16_t *data); +void e1000_init_eeprom_params(struct e1000_hw *hw); +int32_t e1000_read_eeprom(struct e1000_hw *hw, uint16_t reg, uint16_t words, uint16_t *data); int32_t e1000_validate_eeprom_checksum(struct e1000_hw *hw); int32_t e1000_update_eeprom_checksum(struct e1000_hw *hw); -int32_t e1000_write_eeprom(struct e1000_hw *hw, uint16_t reg, uint16_t data); +int32_t e1000_write_eeprom(struct e1000_hw *hw, uint16_t reg, uint16_t words, uint16_t *data); int32_t e1000_read_part_num(struct e1000_hw *hw, uint32_t * part_num); int32_t e1000_read_mac_addr(struct e1000_hw * hw); @@ -231,6 +291,7 @@ uint32_t e1000_read_reg_io(struct e1000_hw *hw, uint32_t offset); void e1000_io_write(struct e1000_hw *hw, uint32_t port, uint32_t value); void e1000_write_reg_io(struct e1000_hw *hw, uint32_t offset, uint32_t value); + #define E1000_READ_REG_IO(a, reg) \ e1000_read_reg_io((a), E1000_##reg) #define E1000_WRITE_REG_IO(a, reg, val) \ @@ -253,7 +314,10 @@ #define E1000_DEV_ID_82545EM_FIBER 0x1011 #define E1000_DEV_ID_82546EB_COPPER 0x1010 #define E1000_DEV_ID_82546EB_FIBER 0x1012 -#define NUM_DEV_IDS 16 +#define E1000_DEV_ID_82541EI 0x1013 +#define E1000_DEV_ID_82541EP 0x1018 +#define E1000_DEV_ID_82547EI 0x1019 +#define NUM_DEV_IDS 19 #define NODE_ADDRESS_SIZE 6 #define ETH_LENGTH_OF_ADDRESS 6 @@ -298,7 +362,7 @@ /* This defines the bits that are set in the Interrupt Mask * Set/Read Register. Each bit is documented below: * o RXDMT0 = Receive Descriptor Minimum Threshold hit (ring 0) - * o RXSEQ = Receive Sequence Error + * o RXSEQ = Receive Sequence Error */ #define POLL_IMS_ENABLE_MASK ( \ E1000_IMS_RXDMT0 | \ @@ -322,9 +386,9 @@ /* The number of high/low register pairs in the RAR. The RAR (Receive Address * Registers) holds the directed and multicast addresses that we monitor. We * reserve one of these spots for our directed address, allowing us room for - * E1000_RAR_ENTRIES - 1 multicast addresses. + * E1000_RAR_ENTRIES - 1 multicast addresses. */ -#define E1000_RAR_ENTRIES 16 +#define E1000_RAR_ENTRIES 15 #define MIN_NUMBER_OF_DESCRIPTORS 8 #define MAX_NUMBER_OF_DESCRIPTORS 0xFFF8 @@ -523,7 +587,7 @@ /* Register Set. (82543, 82544) * * Registers are defined to be 32 bits and should be accessed as 32 bit values. - * These registers are physically located on the NIC, but are mapped into the + * These registers are physically located on the NIC, but are mapped into the * host memory address space. * * RW - register is both readable and writable @@ -537,6 +601,7 @@ #define E1000_EECD 0x00010 /* EEPROM/Flash Control - RW */ #define E1000_EERD 0x00014 /* EEPROM Read - RW */ #define E1000_CTRL_EXT 0x00018 /* Extended Device Control - RW */ +#define E1000_FLA 0x0001C /* Flash Access Register - RW */ #define E1000_MDIC 0x00020 /* MDI Control - RW */ #define E1000_FCAL 0x00028 /* Flow Control Address Low - RW */ #define E1000_FCAH 0x0002C /* Flow Control Address High -RW */ @@ -569,6 +634,11 @@ #define E1000_RADV 0x0282C /* RX Interrupt Absolute Delay Timer - RW */ #define E1000_RSRPD 0x02C00 /* RX Small Packet Detect - RW */ #define E1000_TXDMAC 0x03000 /* TX DMA Control - RW */ +#define E1000_TDFH 0x03410 /* TX Data FIFO Head - RW */ +#define E1000_TDFT 0x03418 /* TX Data FIFO Tail - RW */ +#define E1000_TDFHS 0x03420 /* TX Data FIFO Head Saved - RW */ +#define E1000_TDFTS 0x03428 /* TX Data FIFO Tail Saved - RW */ +#define E1000_TDFPC 0x03430 /* TX Data FIFO Packet Count - RW */ #define E1000_TDBAL 0x03800 /* TX Descriptor Base Address Low - RW */ #define E1000_TDBAH 0x03804 /* TX Descriptor Base Address High - RW */ #define E1000_TDLEN 0x03808 /* TX Descriptor Length - RW */ @@ -664,6 +734,7 @@ #define E1000_82542_EECD E1000_EECD #define E1000_82542_EERD E1000_EERD #define E1000_82542_CTRL_EXT E1000_CTRL_EXT +#define E1000_82542_FLA E1000_FLA #define E1000_82542_MDIC E1000_MDIC #define E1000_82542_FCAL E1000_FCAL #define E1000_82542_FCAH E1000_FCAH @@ -705,6 +776,9 @@ #define E1000_82542_RADV E1000_RADV #define E1000_82542_RSRPD E1000_RSRPD #define E1000_82542_TXDMAC E1000_TXDMAC +#define E1000_82542_TDFHS E1000_TDFHS +#define E1000_82542_TDFTS E1000_TDFTS +#define E1000_82542_TDFPC E1000_TDFPC #define E1000_82542_TXDCTL E1000_TXDCTL #define E1000_82542_TADV E1000_TADV #define E1000_82542_TSPMT E1000_TSPMT @@ -777,6 +851,8 @@ #define E1000_82542_WUPL E1000_WUPL #define E1000_82542_WUPM E1000_WUPM #define E1000_82542_FFLT E1000_FFLT +#define E1000_82542_TDFH 0x08010 +#define E1000_82542_TDFT 0x08018 #define E1000_82542_FFMT E1000_FFMT #define E1000_82542_FFVT E1000_FFVT @@ -846,12 +922,15 @@ struct e1000_hw { uint8_t *hw_addr; e1000_mac_type mac_type; + e1000_phy_type phy_type; + uint32_t phy_init_script; e1000_media_type media_type; void *back; e1000_fc_type fc; e1000_bus_speed bus_speed; e1000_bus_width bus_width; e1000_bus_type bus_type; + struct e1000_eeprom_info eeprom; uint32_t io_base; uint32_t phy_id; uint32_t phy_revision; @@ -891,6 +970,7 @@ uint8_t mac_addr[NODE_ADDRESS_SIZE]; uint8_t perm_mac_addr[NODE_ADDRESS_SIZE]; boolean_t disable_polarity_correction; + boolean_t speed_downgraded; boolean_t get_link_status; boolean_t tbi_compatibility_en; boolean_t tbi_compatibility_on; @@ -967,14 +1047,20 @@ #define E1000_EECD_CS 0x00000002 /* EEPROM Chip Select */ #define E1000_EECD_DI 0x00000004 /* EEPROM Data In */ #define E1000_EECD_DO 0x00000008 /* EEPROM Data Out */ -#define E1000_EECD_FWE_MASK 0x00000030 +#define E1000_EECD_FWE_MASK 0x00000030 #define E1000_EECD_FWE_DIS 0x00000010 /* Disable FLASH writes */ #define E1000_EECD_FWE_EN 0x00000020 /* Enable FLASH writes */ #define E1000_EECD_FWE_SHIFT 4 -#define E1000_EECD_SIZE 0x00000200 /* EEPROM Size (0=64 word 1=256 word) */ #define E1000_EECD_REQ 0x00000040 /* EEPROM Access Request */ #define E1000_EECD_GNT 0x00000080 /* EEPROM Access Grant */ #define E1000_EECD_PRES 0x00000100 /* EEPROM Present */ +#define E1000_EECD_SIZE 0x00000200 /* EEPROM Size (0=64 word 1=256 word) */ +#define E1000_EECD_ADDR_BITS 0x00000400 /* EEPROM Addressing bits based on type + * (0-small, 1-large) */ +#define E1000_EECD_TYPE 0x00002000 /* EEPROM Type (1-SPI, 0-Microwire) */ +#ifndef E1000_EEPROM_GRANT_ATTEMPTS +#define E1000_EEPROM_GRANT_ATTEMPTS 1000 /* EEPROM # attempts to gain grant */ +#endif /* EEPROM Read */ #define E1000_EERD_START 0x00000001 /* Start Read */ @@ -984,8 +1070,15 @@ #define E1000_EERD_DATA_SHIFT 16 #define E1000_EERD_DATA_MASK 0xFFFF0000 /* Read Data */ +/* SPI EEPROM Status Register */ +#define EEPROM_STATUS_RDY_SPI 0x01 +#define EEPROM_STATUS_WEN_SPI 0x02 +#define EEPROM_STATUS_BP0_SPI 0x04 +#define EEPROM_STATUS_BP1_SPI 0x08 +#define EEPROM_STATUS_WPEN_SPI 0x80 + /* Extended Device Control */ -#define E1000_CTRL_EXT_GPI0_EN 0x00000001 /* Maps SDP4 to GPI0 */ +#define E1000_CTRL_EXT_GPI0_EN 0x00000001 /* Maps SDP4 to GPI0 */ #define E1000_CTRL_EXT_GPI1_EN 0x00000002 /* Maps SDP5 to GPI1 */ #define E1000_CTRL_EXT_PHYINT_EN E1000_CTRL_EXT_GPI1_EN #define E1000_CTRL_EXT_GPI2_EN 0x00000004 /* Maps SDP6 to GPI2 */ @@ -1239,6 +1332,7 @@ #define E1000_WUC_PME_EN 0x00000002 /* PME Enable */ #define E1000_WUC_PME_STATUS 0x00000004 /* PME Status */ #define E1000_WUC_APMPME 0x00000008 /* Assert PME on APM Wakeup */ +#define E1000_WUC_SPM 0x80000000 /* Enable SPM */ /* Wake Up Filter Control */ #define E1000_WUFC_LNKC 0x00000001 /* Link Status Change Wakeup Enable */ @@ -1282,7 +1376,7 @@ #define E1000_MANC_IPV6_EN 0x00000800 /* Enable IPv6 */ #define E1000_MANC_SNAP_EN 0x00001000 /* Accept LLC/SNAP */ #define E1000_MANC_ARP_EN 0x00002000 /* Enable ARP Request Filtering */ -#define E1000_MANC_NEIGHBOR_EN 0x00004000 /* Enable Neighbor Discovery +#define E1000_MANC_NEIGHBOR_EN 0x00004000 /* Enable Neighbor Discovery * Filtering */ #define E1000_MANC_TCO_RESET 0x00010000 /* TCO Reset Occurred */ #define E1000_MANC_RCV_TCO_EN 0x00020000 /* Receive TCO Packets Enabled */ @@ -1302,18 +1396,40 @@ #define E1000_MDALIGN 4096 -/* EEPROM Commands */ -#define EEPROM_READ_OPCODE 0x6 /* EERPOM read opcode */ -#define EEPROM_WRITE_OPCODE 0x5 /* EERPOM write opcode */ -#define EEPROM_ERASE_OPCODE 0x7 /* EERPOM erase opcode */ -#define EEPROM_EWEN_OPCODE 0x13 /* EERPOM erase/write enable */ -#define EEPROM_EWDS_OPCODE 0x10 /* EERPOM erast/write disable */ +/* EEPROM Commands - Microwire */ +#define EEPROM_READ_OPCODE_MICROWIRE 0x6 /* EEPROM read opcode */ +#define EEPROM_WRITE_OPCODE_MICROWIRE 0x5 /* EEPROM write opcode */ +#define EEPROM_ERASE_OPCODE_MICROWIRE 0x7 /* EEPROM erase opcode */ +#define EEPROM_EWEN_OPCODE_MICROWIRE 0x13 /* EEPROM erase/write enable */ +#define EEPROM_EWDS_OPCODE_MICROWIRE 0x10 /* EEPROM erast/write disable */ + +/* EEPROM Commands - SPI */ +#define EEPROM_MAX_RETRY_SPI 5000 /* Max wait of 5ms, for RDY signal */ +#define EEPROM_READ_OPCODE_SPI 0x3 /* EEPROM read opcode */ +#define EEPROM_WRITE_OPCODE_SPI 0x2 /* EEPROM write opcode */ +#define EEPROM_A8_OPCODE_SPI 0x8 /* opcode bit-3 = address bit-8 */ +#define EEPROM_WREN_OPCODE_SPI 0x6 /* EEPROM set Write Enable latch */ +#define EEPROM_WRDI_OPCODE_SPI 0x4 /* EEPROM reset Write Enable latch */ +#define EEPROM_RDSR_OPCODE_SPI 0x5 /* EEPROM read Status register */ +#define EEPROM_WRSR_OPCODE_SPI 0x1 /* EEPROM write Status register */ + +/* EEPROM Size definitions */ +#define EEPROM_SIZE_16KB 0x1800 +#define EEPROM_SIZE_8KB 0x1400 +#define EEPROM_SIZE_4KB 0x1000 +#define EEPROM_SIZE_2KB 0x0C00 +#define EEPROM_SIZE_1KB 0x0800 +#define EEPROM_SIZE_512B 0x0400 +#define EEPROM_SIZE_128B 0x0000 +#define EEPROM_SIZE_MASK 0x1C00 + /* EEPROM Word Offsets */ #define EEPROM_COMPAT 0x0003 #define EEPROM_ID_LED_SETTINGS 0x0004 #define EEPROM_INIT_CONTROL1_REG 0x000A #define EEPROM_INIT_CONTROL2_REG 0x000F +#define EEPROM_CFG 0x0012 #define EEPROM_FLASH_VERSION 0x0032 #define EEPROM_CHECKSUM_REG 0x003F @@ -1334,9 +1450,10 @@ #define ID_LED_OFF1_ON2 0x8 #define ID_LED_OFF1_OFF2 0x9 -/* Mask bits for fields in Word 0x03 of the EEPROM */ -#define EEPROM_COMPAT_SERVER 0x0400 -#define EEPROM_COMPAT_CLIENT 0x0200 +#define IGP_ACTIVITY_LED_MASK 0xFFFFF0FF +#define IGP_ACTIVITY_LED_ENABLE 0x0300 +#define IGP_LED3_MODE 0x07000000 + /* Mask bits for fields in Word 0x0a of the EEPROM */ #define EEPROM_WORD0A_ILOS 0x0010 @@ -1409,7 +1526,9 @@ /* PBA constants */ #define E1000_PBA_16K 0x0010 /* 16KB, default TX allocation */ +#define E1000_PBA_22K 0x0016 #define E1000_PBA_24K 0x0018 +#define E1000_PBA_30K 0x001E #define E1000_PBA_40K 0x0028 #define E1000_PBA_48K 0x0030 /* 48KB, default RX allocation */ @@ -1438,26 +1557,26 @@ /* The number of bits that we need to shift right to move the "pause" * bits from the EEPROM (bits 13:12) to the "pause" (bits 8:7) field - * in the TXCW register + * in the TXCW register */ #define PAUSE_SHIFT 5 /* The number of bits that we need to shift left to move the "SWDPIO" * bits from the EEPROM (bits 8:5) to the "SWDPIO" (bits 25:22) field - * in the CTRL register + * in the CTRL register */ #define SWDPIO_SHIFT 17 /* The number of bits that we need to shift left to move the "SWDPIO_EXT" * bits from the EEPROM word F (bits 7:4) to the bits 11:8 of The * Extended CTRL register. - * in the CTRL register + * in the CTRL register */ #define SWDPIO__EXT_SHIFT 4 /* The number of bits that we need to shift left to move the "ILOS" * bit from the EEPROM (bit 4) to the "ILOS" (bit 7) field - * in the CTRL register + * in the CTRL register */ #define ILOS_SHIFT 3 @@ -1475,7 +1594,7 @@ /* TBI_ACCEPT macro definition: * * This macro requires: - * adapter = a pointer to struct e1000_hw + * adapter = a pointer to struct e1000_hw * status = the 8 bit status field of the RX descriptor with EOP set * error = the 8 bit error field of the RX descriptor with EOP set * length = the sum of all the length fields of the RX descriptors that @@ -1484,7 +1603,7 @@ * max_frame_length = the maximum frame length we want to accept. * min_frame_length = the minimum frame length we want to accept. * - * This macro is a conditional that should be used in the interrupt + * This macro is a conditional that should be used in the interrupt * handler's Rx processing routine when RxErrors have been detected. * * Typical use: @@ -1547,6 +1666,29 @@ #define M88E1000_EXT_PHY_SPEC_CTRL 0x14 /* Extended PHY Specific Control */ #define M88E1000_RX_ERR_CNTR 0x15 /* Receive Error Counter */ +/* IGP01E1000 Specific Registers */ +#define IGP01E1000_PHY_PORT_CONFIG 0x10 /* PHY Specific Port Config Register */ +#define IGP01E1000_PHY_PORT_STATUS 0x11 /* PHY Specific Status Register */ +#define IGP01E1000_PHY_PORT_CTRL 0x12 /* PHY Specific Control Register */ +#define IGP01E1000_PHY_LINK_HEALTH 0x13 /* PHY Link Health Register */ +#define IGP01E1000_GMII_FIFO 0x14 /* GMII FIFO Register */ +#define IGP01E1000_PHY_CHANNEL_QUALITY 0x15 /* PHY Channel Quality Register */ +#define IGP01E1000_PHY_PAGE_SELECT 0x1F /* PHY Page Select Core Register */ + +/* IGP01E1000 AGC Registers - stores the cable length values*/ +#define IGP01E1000_PHY_AGC_A 0x1172 +#define IGP01E1000_PHY_AGC_B 0x1272 +#define IGP01E1000_PHY_AGC_C 0x1472 +#define IGP01E1000_PHY_AGC_D 0x1872 + +/* Number of AGC registers */ +#define IGP01E1000_PHY_AGC_NUM 4 + +/* IGP01E1000 PCS Initialization register - stores the polarity status when + * speed = 1000 Mbps. */ +#define IGP01E1000_PHY_PCS_INIT_REG 0x00B4 + + #define MAX_PHY_REG_ADDRESS 0x1F /* 5 bit address bus (0-0x1F) */ /* PHY Control Register */ @@ -1608,7 +1750,7 @@ #define NWAY_ER_PAGE_RXD 0x0002 /* LP is 10T Half Duplex Capable */ #define NWAY_ER_NEXT_PAGE_CAPS 0x0004 /* LP is 10T Full Duplex Capable */ #define NWAY_ER_LP_NEXT_PAGE_CAPS 0x0008 /* LP is 100TX Half Duplex Capable */ -#define NWAY_ER_PAR_DETECT_FAULT 0x0100 /* LP is 100TX Full Duplex Capable */ +#define NWAY_ER_PAR_DETECT_FAULT 0x0010 /* LP is 100TX Full Duplex Capable */ /* Next Page TX Register */ #define NPTX_MSG_CODE_FIELD 0x0001 /* NP msg code or unformatted data */ @@ -1619,7 +1761,7 @@ * 0 = cannot comply with msg */ #define NPTX_MSG_PAGE 0x2000 /* formatted(1)/unformatted(0) pg */ -#define NPTX_NEXT_PAGE 0x8000 /* 1 = addition NP will follow +#define NPTX_NEXT_PAGE 0x8000 /* 1 = addition NP will follow * 0 = sending last NP */ @@ -1628,13 +1770,13 @@ #define LP_RNPR_TOGGLE 0x0800 /* Toggles between exchanges * of different NP */ -#define LP_RNPR_ACKNOWLDGE2 0x1000 /* 1 = will comply with msg +#define LP_RNPR_ACKNOWLDGE2 0x1000 /* 1 = will comply with msg * 0 = cannot comply with msg */ #define LP_RNPR_MSG_PAGE 0x2000 /* formatted(1)/unformatted(0) pg */ #define LP_RNPR_ACKNOWLDGE 0x4000 /* 1 = ACK / 0 = NO ACK */ #define LP_RNPR_NEXT_PAGE 0x8000 /* 1 = addition NP will follow - * 0 = sending last NP + * 0 = sending last NP */ /* 1000BASE-T Control Register */ @@ -1681,20 +1823,20 @@ #define M88E1000_PSCR_JABBER_DISABLE 0x0001 /* 1=Jabber Function disabled */ #define M88E1000_PSCR_POLARITY_REVERSAL 0x0002 /* 1=Polarity Reversal enabled */ #define M88E1000_PSCR_SQE_TEST 0x0004 /* 1=SQE Test enabled */ -#define M88E1000_PSCR_CLK125_DISABLE 0x0010 /* 1=CLK125 low, +#define M88E1000_PSCR_CLK125_DISABLE 0x0010 /* 1=CLK125 low, * 0=CLK125 toggling */ #define M88E1000_PSCR_MDI_MANUAL_MODE 0x0000 /* MDI Crossover Mode bits 6:5 */ /* Manual MDI configuration */ #define M88E1000_PSCR_MDIX_MANUAL_MODE 0x0020 /* Manual MDIX configuration */ #define M88E1000_PSCR_AUTO_X_1000T 0x0040 /* 1000BASE-T: Auto crossover, - * 100BASE-TX/10BASE-T: + * 100BASE-TX/10BASE-T: * MDI Mode */ -#define M88E1000_PSCR_AUTO_X_MODE 0x0060 /* Auto crossover enabled - * all speeds. +#define M88E1000_PSCR_AUTO_X_MODE 0x0060 /* Auto crossover enabled + * all speeds. */ -#define M88E1000_PSCR_10BT_EXT_DIST_ENABLE 0x0080 +#define M88E1000_PSCR_10BT_EXT_DIST_ENABLE 0x0080 /* 1=Enable Extended 10BASE-T distance * (Lower 10BASE-T RX Threshold) * 0=Normal 10BASE-T RX Threshold */ @@ -1712,6 +1854,7 @@ /* M88E1000 PHY Specific Status Register */ #define M88E1000_PSSR_JABBER 0x0001 /* 1=Jabber */ #define M88E1000_PSSR_REV_POLARITY 0x0002 /* 1=Polarity reversed */ +#define M88E1000_PSSR_DOWNSHIFT 0x0020 /* 1=Downshifted */ #define M88E1000_PSSR_MDIX 0x0040 /* 1=MDIX; 0=MDI */ #define M88E1000_PSSR_CABLE_LENGTH 0x0380 /* 0=<50M;1=50-80M;2=80-110M; * 3=110-140M;4=>140M */ @@ -1725,6 +1868,7 @@ #define M88E1000_PSSR_1000MBS 0x8000 /* 10=1000Mbs */ #define M88E1000_PSSR_REV_POLARITY_SHIFT 1 +#define M88E1000_PSSR_DOWNSHIFT_SHIFT 5 #define M88E1000_PSSR_MDIX_SHIFT 6 #define M88E1000_PSSR_CABLE_LENGTH_SHIFT 7 @@ -1733,12 +1877,12 @@ #define M88E1000_EPSCR_DOWN_NO_IDLE 0x8000 /* 1=Lost lock detect enabled. * Will assert lost lock and bring * link down if idle not seen - * within 1ms in 1000BASE-T + * within 1ms in 1000BASE-T */ /* Number of times we will attempt to autonegotiate before downshifting if we * are the master */ #define M88E1000_EPSCR_MASTER_DOWNSHIFT_MASK 0x0C00 -#define M88E1000_EPSCR_MASTER_DOWNSHIFT_1X 0x0000 +#define M88E1000_EPSCR_MASTER_DOWNSHIFT_1X 0x0000 #define M88E1000_EPSCR_MASTER_DOWNSHIFT_2X 0x0400 #define M88E1000_EPSCR_MASTER_DOWNSHIFT_3X 0x0800 #define M88E1000_EPSCR_MASTER_DOWNSHIFT_4X 0x0C00 @@ -1753,10 +1897,93 @@ #define M88E1000_EPSCR_TX_CLK_25 0x0070 /* 25 MHz TX_CLK */ #define M88E1000_EPSCR_TX_CLK_0 0x0000 /* NO TX_CLK */ + +/* IGP01E1000 Specific Port Config Register - R/W */ +#define IGP01E1000_PSCFR_AUTO_MDIX_PAR_DETECT 0x0010 +#define IGP01E1000_PSCFR_PRE_EN 0x0020 +#define IGP01E1000_PSCFR_SMART_SPEED 0x0080 +#define IGP01E1000_PSCFR_DISABLE_TPLOOPBACK 0x0100 +#define IGP01E1000_PSCFR_DISABLE_JABBER 0x0400 +#define IGP01E1000_PSCFR_DISABLE_TRANSMIT 0x2000 + +/* IGP01E1000 Specific Port Status Register - R/O */ +#define IGP01E1000_PSSR_AUTONEG_FAILED 0x0001 /* RO LH SC */ +#define IGP01E1000_PSSR_POLARITY_REVERSED 0x0002 +#define IGP01E1000_PSSR_CABLE_LENGTH 0x007C +#define IGP01E1000_PSSR_FULL_DUPLEX 0x0200 +#define IGP01E1000_PSSR_LINK_UP 0x0400 +#define IGP01E1000_PSSR_MDIX 0x0800 +#define IGP01E1000_PSSR_SPEED_MASK 0xC000 /* speed bits mask */ +#define IGP01E1000_PSSR_SPEED_10MBPS 0x4000 +#define IGP01E1000_PSSR_SPEED_100MBPS 0x8000 +#define IGP01E1000_PSSR_SPEED_1000MBPS 0xC000 +#define IGP01E1000_PSSR_CABLE_LENGTH_SHIFT 0x0002 /* shift right 2 */ +#define IGP01E1000_PSSR_MDIX_SHIFT 0x000B /* shift right 11 */ + +/* IGP01E1000 Specific Port Control Register - R/W */ +#define IGP01E1000_PSCR_TP_LOOPBACK 0x0001 +#define IGP01E1000_PSCR_CORRECT_NC_SCMBLR 0x0200 +#define IGP01E1000_PSCR_TEN_CRS_SELECT 0x0400 +#define IGP01E1000_PSCR_FLIP_CHIP 0x0800 +#define IGP01E1000_PSCR_AUTO_MDIX 0x1000 +#define IGP01E1000_PSCR_FORCE_MDI_MDIX 0x2000 /* 0-MDI, 1-MDIX */ + +/* IGP01E1000 Specific Port Link Health Register */ +#define IGP01E1000_PLHR_SS_DOWNGRADE 0x8000 +#define IGP01E1000_PLHR_GIG_SCRAMBLER_ERROR 0x4000 +#define IGP01E1000_PLHR_GIG_REM_RCVR_NOK 0x0800 /* LH */ +#define IGP01E1000_PLHR_IDLE_ERROR_CNT_OFLOW 0x0400 /* LH */ +#define IGP01E1000_PLHR_DATA_ERR_1 0x0200 /* LH */ +#define IGP01E1000_PLHR_DATA_ERR_0 0x0100 +#define IGP01E1000_PLHR_AUTONEG_FAULT 0x0010 +#define IGP01E1000_PLHR_AUTONEG_ACTIVE 0x0008 +#define IGP01E1000_PLHR_VALID_CHANNEL_D 0x0004 +#define IGP01E1000_PLHR_VALID_CHANNEL_C 0x0002 +#define IGP01E1000_PLHR_VALID_CHANNEL_B 0x0001 +#define IGP01E1000_PLHR_VALID_CHANNEL_A 0x0000 + +/* IGP01E1000 Channel Quality Register */ +#define IGP01E1000_MSE_CHANNEL_D 0x000F +#define IGP01E1000_MSE_CHANNEL_C 0x00F0 +#define IGP01E1000_MSE_CHANNEL_B 0x0F00 +#define IGP01E1000_MSE_CHANNEL_A 0xF000 + +/* IGP01E1000 AGC Registers */ + +#define IGP01E1000_AGC_LENGTH_SHIFT 7 /* Coarse - 13:11, Fine - 10:7 */ + +/* 7 bits (3 Coarse + 4 Fine) --> 128 optional values */ +#define IGP01E1000_AGC_LENGTH_TABLE_SIZE 128 + +/* The precision of the length is +/- 10 meters */ +#define IGP01E1000_AGC_RANGE 10 + +/* IGP cable length table */ +static const +uint16_t e1000_igp_cable_length_table[IGP01E1000_AGC_LENGTH_TABLE_SIZE] = + { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 10, 10, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 25, 25, 25, + 25, 25, 25, 25, 30, 30, 30, 30, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 50, 50, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60, 60, 60, + 60, 70, 70, 70, 70, 70, 70, 80, 80, 80, 80, 80, 80, 90, 90, 90, + 90, 90, 90, 90, 90, 90, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, + 100, 100, 100, 100, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, + 110, 110, 110, 110, 110, 110, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120}; + +/* IGP01E1000 PCS Initialization register */ +/* bits 3:6 in the PCS registers stores the channels polarity */ +#define IGP01E1000_PHY_POLARITY_MASK 0x0078 + +/* IGP01E1000 GMII FIFO Register */ +#define IGP01E1000_GMII_FLEX_SPD 0x10 /* Enable flexible speed + * on Link-Up */ +#define IGP01E1000_GMII_SPD 0x20 /* Enable SPD */ + /* Bit definitions for valid PHY IDs. */ #define M88E1000_E_PHY_ID 0x01410C50 #define M88E1000_I_PHY_ID 0x01410C30 #define M88E1011_I_PHY_ID 0x01410C20 +#define IGP01E1000_I_PHY_ID 0x02A80380 #define M88E1000_12_PHY_ID M88E1000_E_PHY_ID #define M88E1000_14_PHY_ID M88E1000_E_PHY_ID #define M88E1011_I_REV_4 0x04 diff -Nru a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c --- a/drivers/net/e1000/e1000_main.c Sun Mar 23 00:22:52 2003 +++ b/drivers/net/e1000/e1000_main.c Sun Mar 23 00:22:52 2003 @@ -1,7 +1,7 @@ /******************************************************************************* - Copyright(c) 1999 - 2002 Intel Corporation. All rights reserved. + Copyright(c) 1999 - 2003 Intel Corporation. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -30,7 +30,22 @@ /* Change Log * - * 4.4.19 11/27/02 + * 5.0.43 3/5/03 + * o Feature: Added support for 82541 and 82547 hardware. + * o Feature: Added support for Intel Gigabit PHY (IGP) and a variety of + * eeproms. + * o Feature: Added support for TCP Segmentation Offload (TSO). + * o Feature: Added MII ioctl. + * o Feature: Added support for statistics reporting through ethtool. + * o Cleanup: Removed proprietary hooks for ANS. + * o Cleanup: Miscellaneous code changes to improve CPU utilization. + * - Replaced "%" with conditionals and "+-" operators. + * - Implemented dynamic Interrupt Throttle Rate (ITR). + * - Reduced expensive PCI reads of ICR in interrupt. + * o Bug fix: Request IRQ after descriptor ring setup to avoid panic in + * shared interrupt instances. + * + * 4.4.18 11/27/02 * o Feature: Added user-settable knob for interrupt throttle rate (ITR). * o Cleanup: removed large static array allocations. * o Cleanup: C99 struct initializer format. @@ -42,25 +57,12 @@ * o Bug fix: Make ethtool EEPROM acceses work on older versions of ethtool. * * 4.4.12 10/15/02 - * o Clean up: use members of pci_device rather than direct calls to - * pci_read_config_word. - * o Bug fix: changed default flow control settings. - * o Clean up: ethtool file now has an inclusive list for adapters in the - * Wake-On-LAN capabilities instead of an exclusive list. - * o Bug fix: miscellaneous WoL bug fixes. - * o Added software interrupt for clearing rx ring - * o Bug fix: easier to undo "forcing" of 1000/fd using ethtool. - * o Now setting netdev->mem_end in e1000_probe. - * o Clean up: Moved tx_timeout from interrupt context to process context - * using schedule_task. - * - * 4.3.15 8/9/02 */ char e1000_driver_name[] = "e1000"; char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver"; -char e1000_driver_version[] = "4.4.19-k3"; -char e1000_copyright[] = "Copyright (c) 1999-2002 Intel Corporation."; +char e1000_driver_version[] = "5.0.43-k1"; +char e1000_copyright[] = "Copyright (c) 1999-2003 Intel Corporation."; /* e1000_pci_tbl - PCI Device ID Table * @@ -104,6 +106,8 @@ {0x8086, 0x1016, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {0x8086, 0x1017, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {0x8086, 0x101E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, + {0x8086, 0x1013, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, + {0x8086, 0x1019, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* required last entry */ {0,} }; @@ -112,7 +116,7 @@ static char *e1000_strings[] = { "Intel(R) PRO/1000 Network Connection", - "Compaq Gigabit Ethernet Server Adapter", + "HP Gigabit Ethernet Server Adapter", "IBM Mobile, Desktop & Server Adapters" }; @@ -121,6 +125,7 @@ int e1000_up(struct e1000_adapter *adapter); void e1000_down(struct e1000_adapter *adapter); void e1000_reset(struct e1000_adapter *adapter); +int e1000_set_spd_dplx(struct e1000_adapter *adapter, uint16_t spddplx); static int e1000_init_module(void); static void e1000_exit_module(void); @@ -141,6 +146,7 @@ static void e1000_set_multi(struct net_device *netdev); static void e1000_update_phy_info(unsigned long data); static void e1000_watchdog(unsigned long data); +static void e1000_82547_tx_fifo_stall(unsigned long data); static int e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev); static struct net_device_stats * e1000_get_stats(struct net_device *netdev); static int e1000_change_mtu(struct net_device *netdev, int new_mtu); @@ -149,14 +155,18 @@ static inline void e1000_irq_disable(struct e1000_adapter *adapter); static inline void e1000_irq_enable(struct e1000_adapter *adapter); static void e1000_intr(int irq, void *data, struct pt_regs *regs); -static void e1000_clean_tx_irq(struct e1000_adapter *adapter); #ifdef CONFIG_E1000_NAPI -static int e1000_poll(struct net_device *netdev, int *budget); +static int e1000_clean(struct net_device *netdev, int *budget); +static boolean_t e1000_clean_rx_irq(struct e1000_adapter *adapter, + int *work_done, int work_to_do); #else -static void e1000_clean_rx_irq(struct e1000_adapter *adapter); +static boolean_t e1000_clean_rx_irq(struct e1000_adapter *adapter); #endif +static boolean_t e1000_clean_tx_irq(struct e1000_adapter *adapter); static void e1000_alloc_rx_buffers(struct e1000_adapter *adapter); static int e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd); +static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, + int cmd); static void e1000_enter_82542_rst(struct e1000_adapter *adapter); static void e1000_leave_82542_rst(struct e1000_adapter *adapter); static inline void e1000_rx_checksum(struct e1000_adapter *adapter, @@ -164,6 +174,9 @@ struct sk_buff *skb); static void e1000_tx_timeout(struct net_device *dev); static void e1000_tx_timeout_task(struct net_device *dev); +static void e1000_smartspeed(struct e1000_adapter *adapter); +static inline int e1000_82547_fifo_workaround(struct e1000_adapter *adapter, + struct sk_buff *skb); static void e1000_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp); static void e1000_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid); @@ -182,6 +195,7 @@ .priority = 0 }; + /* Exported from other modules */ extern void e1000_check_options(struct e1000_adapter *adapter); @@ -249,13 +263,10 @@ { struct net_device *netdev = adapter->netdev; - if(request_irq(netdev->irq, &e1000_intr, SA_SHIRQ | SA_SAMPLE_RANDOM, - netdev->name, netdev)) - return -1; - /* hardware has been reset, we need to reload some things */ e1000_set_multi(netdev); + e1000_restore_vlan(adapter); e1000_configure_tx(adapter); @@ -263,6 +274,14 @@ e1000_configure_rx(adapter); e1000_alloc_rx_buffers(adapter); + if(request_irq(netdev->irq, &e1000_intr, SA_SHIRQ | SA_SAMPLE_RANDOM, + netdev->name, netdev)) { + e1000_reset_hw(&adapter->hw); + e1000_free_tx_resources(adapter); + e1000_free_rx_resources(adapter); + return -1; + } + mod_timer(&adapter->watchdog_timer, jiffies); e1000_irq_enable(adapter); @@ -276,6 +295,7 @@ e1000_irq_disable(adapter); free_irq(netdev->irq, netdev); + del_timer_sync(&adapter->tx_fifo_stall_timer); del_timer_sync(&adapter->watchdog_timer); del_timer_sync(&adapter->phy_info_timer); adapter->link_speed = 0; @@ -291,14 +311,28 @@ void e1000_reset(struct e1000_adapter *adapter) { + uint32_t pba; /* Repartition Pba for greater than 9k mtu * To take effect CTRL.RST is required. */ - if(adapter->rx_buffer_len > E1000_RXBUFFER_8192) - E1000_WRITE_REG(&adapter->hw, PBA, E1000_JUMBO_PBA); - else - E1000_WRITE_REG(&adapter->hw, PBA, E1000_DEFAULT_PBA); + if(adapter->hw.mac_type < e1000_82547) { + if(adapter->rx_buffer_len > E1000_RXBUFFER_8192) + pba = E1000_PBA_40K; + else + pba = E1000_PBA_48K; + } else { + if(adapter->rx_buffer_len > E1000_RXBUFFER_8192) + pba = E1000_PBA_22K; + else + pba = E1000_PBA_30K; + adapter->tx_fifo_head = 0; + adapter->tx_head_addr = pba << E1000_TX_HEAD_ADDR_SHIFT; + adapter->tx_fifo_size = + (E1000_PBA_40K - pba) << E1000_TX_FIFO_SIZE_SHIFT; + atomic_set(&adapter->tx_fifo_stall, 0); + } + E1000_WRITE_REG(&adapter->hw, PBA, pba); adapter->hw.fc = adapter->hw.original_fc; e1000_reset_hw(&adapter->hw); @@ -389,9 +423,9 @@ netdev->change_mtu = &e1000_change_mtu; netdev->do_ioctl = &e1000_ioctl; netdev->tx_timeout = &e1000_tx_timeout; - netdev->watchdog_timeo = HZ; + netdev->watchdog_timeo = 5 * HZ; #ifdef CONFIG_E1000_NAPI - netdev->poll = &e1000_poll; + netdev->poll = &e1000_clean; netdev->weight = 64; #endif netdev->vlan_rx_register = e1000_vlan_rx_register; @@ -413,17 +447,18 @@ if(adapter->hw.mac_type >= e1000_82543) { netdev->features = NETIF_F_SG | - NETIF_F_HW_CSUM | - NETIF_F_HW_VLAN_TX | - NETIF_F_HW_VLAN_RX | + NETIF_F_HW_CSUM | + NETIF_F_HW_VLAN_TX | + NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_FILTER; } else { netdev->features = NETIF_F_SG; } - if(adapter->hw.mac_type >= e1000_82544) + if((adapter->hw.mac_type >= e1000_82544) && + (adapter->hw.mac_type != e1000_82547)) netdev->features |= NETIF_F_TSO; - + if(pci_using_dac) netdev->features |= NETIF_F_HIGHDMA; @@ -446,13 +481,9 @@ e1000_get_bus_info(&adapter->hw); - if((adapter->hw.mac_type == e1000_82544) && - (adapter->hw.bus_type == e1000_bus_type_pcix)) - - adapter->max_data_per_txd = 4096; - else - adapter->max_data_per_txd = MAX_JUMBO_FRAME_SIZE; - + init_timer(&adapter->tx_fifo_stall_timer); + adapter->tx_fifo_stall_timer.function = &e1000_82547_tx_fifo_stall; + adapter->tx_fifo_stall_timer.data = (unsigned long) adapter; init_timer(&adapter->watchdog_timer); adapter->watchdog_timer.function = &e1000_watchdog; @@ -482,11 +513,12 @@ * enable the ACPI Magic Packet filter */ - e1000_read_eeprom(&adapter->hw, EEPROM_INIT_CONTROL2_REG, &eeprom_data); + e1000_read_eeprom(&adapter->hw, EEPROM_INIT_CONTROL2_REG,1, &eeprom_data); if((adapter->hw.mac_type >= e1000_82544) && (eeprom_data & E1000_EEPROM_APME)) adapter->wol |= E1000_WUFC_MAG; + /* reset the hardware with the new settings */ e1000_reset(adapter); @@ -533,6 +565,7 @@ e1000_phy_hw_reset(&adapter->hw); + iounmap(adapter->hw.hw_addr); pci_release_regions(pdev); @@ -568,7 +601,7 @@ adapter->rx_buffer_len = E1000_RXBUFFER_2048; hw->max_frame_size = netdev->mtu + - ENET_HEADER_SIZE + ETHERNET_FCS_SIZE; + ENET_HEADER_SIZE + ETHERNET_FCS_SIZE; hw->min_frame_size = MINIMUM_ETHERNET_FRAME_SIZE; /* identify the MAC */ @@ -578,6 +611,10 @@ return -1; } + /* initialize eeprom parameters */ + + e1000_init_eeprom_params(hw); + /* flow control settings */ hw->fc_high_water = E1000_FC_HIGH_THRESH; @@ -585,6 +622,9 @@ hw->fc_pause_time = E1000_FC_PAUSE_TIME; hw->fc_send_xon = 1; + if((hw->mac_type == e1000_82541) || (hw->mac_type == e1000_82547)) + hw->phy_init_script = 1; + /* Media type - copper or fiber */ if(hw->mac_type >= e1000_82543) { @@ -782,7 +822,7 @@ tctl &= ~E1000_TCTL_CT; tctl |= E1000_TCTL_EN | E1000_TCTL_PSP | - (E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT); + (E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT); E1000_WRITE_REG(&adapter->hw, TCTL, tctl); @@ -852,8 +892,8 @@ rctl &= ~(3 << E1000_RCTL_MO_SHIFT); rctl |= E1000_RCTL_EN | E1000_RCTL_BAM | - E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF | - (adapter->hw.mc_filter_type << E1000_RCTL_MO_SHIFT); + E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF | + (adapter->hw.mc_filter_type << E1000_RCTL_MO_SHIFT); if(adapter->hw.tbi_compatibility_on == 1) rctl |= E1000_RCTL_SBP; @@ -907,12 +947,9 @@ if(adapter->hw.mac_type >= e1000_82540) { E1000_WRITE_REG(&adapter->hw, RADV, adapter->rx_abs_int_delay); - - /* Set the interrupt throttling rate. Value is calculated - * as DEFAULT_ITR = 1/(MAX_INTS_PER_SEC * 256ns) */ -#define MAX_INTS_PER_SEC 8000 -#define DEFAULT_ITR 1000000000/(MAX_INTS_PER_SEC * 256) - E1000_WRITE_REG(&adapter->hw, ITR, DEFAULT_ITR); + if(adapter->itr > 1) + E1000_WRITE_REG(&adapter->hw, ITR, + 1000000000 / (adapter->itr * 256)); } /* Setup the Base and Length of the Rx Descriptor Ring */ @@ -1184,9 +1221,9 @@ if(hw->mac_type == e1000_82542_rev2_0) e1000_enter_82542_rst(adapter); - /* load the first 15 multicast address into the exact filters 1-15 + /* load the first 14 multicast address into the exact filters 1-14 * RAR 0 is used for the station MAC adddress - * if there are not 15 addresses, go ahead and clear the filters + * if there are not 14 addresses, go ahead and clear the filters */ mc_ptr = netdev->mc_list; @@ -1216,6 +1253,40 @@ e1000_leave_82542_rst(adapter); } +static void +e1000_tx_flush(struct e1000_adapter *adapter) +{ + uint32_t ctrl, tctl, txcw, icr; + + e1000_irq_disable(adapter); + + if(adapter->hw.mac_type < e1000_82543) { + /* Transmit Unit Reset */ + tctl = E1000_READ_REG(&adapter->hw, TCTL); + E1000_WRITE_REG(&adapter->hw, TCTL, tctl | E1000_TCTL_RST); + E1000_WRITE_REG(&adapter->hw, TCTL, tctl); + e1000_clean_tx_ring(adapter); + e1000_configure_tx(adapter); + } else { + txcw = E1000_READ_REG(&adapter->hw, TXCW); + E1000_WRITE_REG(&adapter->hw, TXCW, txcw & ~E1000_TXCW_ANE); + + ctrl = E1000_READ_REG(&adapter->hw, CTRL); + E1000_WRITE_REG(&adapter->hw, CTRL, ctrl | E1000_CTRL_SLU | + E1000_CTRL_ILOS); + + mdelay(10); + + e1000_clean_tx_irq(adapter); + E1000_WRITE_REG(&adapter->hw, CTRL, ctrl); + E1000_WRITE_REG(&adapter->hw, TXCW, txcw); + + /* clear the link status change interrupts this caused */ + icr = E1000_READ_REG(&adapter->hw, ICR); + } + + e1000_irq_enable(adapter); +} /* need to wait a few seconds after link up to get diagnostic information from the phy */ @@ -1227,6 +1298,48 @@ } /** + * e1000_82547_tx_fifo_stall - Timer Call-back + * @data: pointer to adapter cast into an unsigned long + **/ + +static void +e1000_82547_tx_fifo_stall(unsigned long data) +{ + struct e1000_adapter *adapter = (struct e1000_adapter *) data; + struct net_device *netdev = adapter->netdev; + uint32_t tctl; + + if(atomic_read(&adapter->tx_fifo_stall)) { + if((E1000_READ_REG(&adapter->hw, TDT) == + E1000_READ_REG(&adapter->hw, TDH)) && + (E1000_READ_REG(&adapter->hw, TDFT) == + E1000_READ_REG(&adapter->hw, TDFH)) && + (E1000_READ_REG(&adapter->hw, TDFTS) == + E1000_READ_REG(&adapter->hw, TDFHS))) { + tctl = E1000_READ_REG(&adapter->hw, TCTL); + E1000_WRITE_REG(&adapter->hw, TCTL, + tctl & ~E1000_TCTL_EN); + E1000_WRITE_REG(&adapter->hw, TDFT, + adapter->tx_head_addr); + E1000_WRITE_REG(&adapter->hw, TDFH, + adapter->tx_head_addr); + E1000_WRITE_REG(&adapter->hw, TDFTS, + adapter->tx_head_addr); + E1000_WRITE_REG(&adapter->hw, TDFHS, + adapter->tx_head_addr); + E1000_WRITE_REG(&adapter->hw, TCTL, tctl); + E1000_WRITE_FLUSH(&adapter->hw); + + adapter->tx_fifo_head = 0; + atomic_set(&adapter->tx_fifo_stall, 0); + netif_wake_queue(netdev); + } else { + mod_timer(&adapter->tx_fifo_stall_timer, jiffies + 1); + } + } +} + +/** * e1000_watchdog - Timer Call-back * @data: pointer to netdev cast into an unsigned long **/ @@ -1256,6 +1369,7 @@ netif_carrier_on(netdev); netif_wake_queue(netdev); mod_timer(&adapter->phy_info_timer, jiffies + 2 * HZ); + adapter->smartspeed = 0; } } else { if(netif_carrier_ok(netdev)) { @@ -1268,11 +1382,34 @@ netif_stop_queue(netdev); mod_timer(&adapter->phy_info_timer, jiffies + 2 * HZ); } + + e1000_smartspeed(adapter); } e1000_update_stats(adapter); e1000_update_adaptive(&adapter->hw); + if(!netif_carrier_ok(netdev)) { + if(E1000_DESC_UNUSED(txdr) + 1 < txdr->count) { + unsigned long flags; + spin_lock_irqsave(&netdev->xmit_lock, flags); + e1000_tx_flush(adapter); + spin_unlock_irqrestore(&netdev->xmit_lock, flags); + } + } + + /* Dynamic mode for Interrupt Throttle Rate (ITR) */ + if(adapter->hw.mac_type >= e1000_82540 && adapter->itr == 1) { + /* Symmetric Tx/Rx gets a reduced ITR=2000; Total + * asymmetrical Tx or Rx gets ITR=8000; everyone + * else is between 2000-8000. */ + uint32_t goc = (adapter->gotcl + adapter->gorcl) / 10000; + uint32_t dif = (adapter->gotcl > adapter->gorcl ? + adapter->gotcl - adapter->gorcl : + adapter->gorcl - adapter->gotcl) / 10000; + uint32_t itr = goc > 0 ? (dif * 6000 / goc + 2000) : 8000; + E1000_WRITE_REG(&adapter->hw, ITR, 1000000000 / (itr * 256)); + } /* Cause software interrupt to ensure rx ring is cleaned */ E1000_WRITE_REG(&adapter->hw, ICS, E1000_ICS_RXDMT0); @@ -1301,7 +1438,7 @@ int i; uint8_t ipcss, ipcso, tucss, tucso, hdr_len; uint16_t ipcse, tucse, mss; - + if(skb_shinfo(skb)->tso_size) { hdr_len = ((skb->h.raw - skb->data) + (skb->h.th->doff << 2)); mss = skb_shinfo(skb)->tso_size; @@ -1321,7 +1458,7 @@ i = adapter->tx_ring.next_to_use; context_desc = E1000_CONTEXT_DESC(adapter->tx_ring, i); - + context_desc->lower_setup.ip_fields.ipcss = ipcss; context_desc->lower_setup.ip_fields.ipcso = ipcso; context_desc->lower_setup.ip_fields.ipcse = cpu_to_le16(ipcse); @@ -1335,12 +1472,12 @@ E1000_TXD_CMD_IP | E1000_TXD_CMD_TCP | (skb->len - (hdr_len))); - i = (i + 1) % adapter->tx_ring.count; + if(++i == adapter->tx_ring.count) i = 0; adapter->tx_ring.next_to_use = i; return TRUE; } - + return FALSE; } @@ -1365,7 +1502,7 @@ context_desc->cmd_and_length = cpu_to_le32(adapter->txd_cmd | E1000_TXD_CMD_DEXT); - i = (i + 1) % adapter->tx_ring.count; + if(++i == adapter->tx_ring.count) i = 0; adapter->tx_ring.next_to_use = i; return TRUE; @@ -1374,24 +1511,24 @@ return FALSE; } +#define E1000_MAX_TXD_PWR 12 +#define E1000_MAX_DATA_PER_TXD (1<tx_ring; - int len, offset, size, count, i; + int len = skb->len, offset = 0, size, count = 0, i; + int tso = skb_shinfo(skb)->tso_size; int nr_frags = skb_shinfo(skb)->nr_frags; - int f; - len = skb->len - skb->data_len; - i = (tx_ring->next_to_use + tx_ring->count - 1) % tx_ring->count; - count = 0; + len -= skb->data_len; - offset = 0; + i = tx_ring->next_to_use; while(len) { - i = (i + 1) % tx_ring->count; - size = min(len, adapter->max_data_per_txd); + size = min(len, E1000_MAX_DATA_PER_TXD); /* Workaround for premature desc write-backs * in TSO mode. Append 4-byte sentinel desc */ if(tso && !nr_frags && size == len && size > 4) @@ -1407,6 +1544,7 @@ len -= size; offset += size; count++; + if(++i == tx_ring->count) i = 0; } for(f = 0; f < nr_frags; f++) { @@ -1417,8 +1555,7 @@ offset = 0; while(len) { - i = (i + 1) % tx_ring->count; - size = min(len, adapter->max_data_per_txd); + size = min(len, E1000_MAX_DATA_PER_TXD); /* Workaround for premature desc write-backs * in TSO mode. Append 4-byte sentinel desc */ if(tso && f == (nr_frags-1) && size == len && size > 4) @@ -1435,8 +1572,10 @@ len -= size; offset += size; count++; + if(++i == tx_ring->count) i = 0; } } + if(--i < 0) i = tx_ring->count - 1; tx_ring->buffer_info[i].skb = skb; return count; @@ -1477,7 +1616,7 @@ tx_desc->lower.data = cpu_to_le32(txd_lower | tx_ring->buffer_info[i].length); tx_desc->upper.data = cpu_to_le32(txd_upper); - i = (i + 1) % tx_ring->count; + if(++i == tx_ring->count) i = 0; } tx_desc->lower.data |= cpu_to_le32(E1000_TXD_CMD_EOP); @@ -1492,34 +1631,74 @@ E1000_WRITE_REG(&adapter->hw, TDT, i); } -#define TXD_USE_COUNT(S, X) (((S) / (X)) + (((S) % (X)) ? 1 : 0)) +/** + * 82547 workaround to avoid controller hang in half-duplex environment. + * The workaround is to avoid queuing a large packet that would span + * the internal Tx FIFO ring boundary by notifying the stack to resend + * the packet at a later time. This gives the Tx FIFO an opportunity to + * flush all packets. When that occurs, we reset the Tx FIFO pointers + * to the beginning of the Tx FIFO. + **/ + +#define E1000_FIFO_HDR 0x10 +#define E1000_82547_PAD_LEN 0x3E0 + +static inline int +e1000_82547_fifo_workaround(struct e1000_adapter *adapter, struct sk_buff *skb) +{ + uint32_t fifo_space = adapter->tx_fifo_size - adapter->tx_fifo_head; + uint32_t skb_fifo_len = skb->len + E1000_FIFO_HDR; + + E1000_ROUNDUP(skb_fifo_len, E1000_FIFO_HDR); + + if(adapter->link_duplex != HALF_DUPLEX) + goto no_fifo_stall_required; + + if(atomic_read(&adapter->tx_fifo_stall)) + return 1; + + if(skb_fifo_len >= (E1000_82547_PAD_LEN + fifo_space)) { + atomic_set(&adapter->tx_fifo_stall, 1); + return 1; + } + +no_fifo_stall_required: + adapter->tx_fifo_head += skb_fifo_len; + if(adapter->tx_fifo_head >= adapter->tx_fifo_size) + adapter->tx_fifo_head -= adapter->tx_fifo_size; + return 0; +} + +/* Tx Descriptors needed, worst case */ +#define TXD_USE_COUNT(S) (((S) >> E1000_MAX_TXD_PWR) + \ + (((S) & (E1000_MAX_DATA_PER_TXD - 1)) ? 1 : 0)) +#define DESC_NEEDED TXD_USE_COUNT(MAX_JUMBO_FRAME_SIZE) + \ + MAX_SKB_FRAGS * TXD_USE_COUNT(PAGE_SIZE) + 1 static int e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev) { struct e1000_adapter *adapter = netdev->priv; - int tx_flags = 0, count; - int f; + int tx_flags = 0; - count = TXD_USE_COUNT(skb->len - skb->data_len, - adapter->max_data_per_txd); - - if(count == 0) { + if(skb->len <= 0) { dev_kfree_skb_any(skb); return 0; } - for(f = 0; f < skb_shinfo(skb)->nr_frags; f++) - count += TXD_USE_COUNT(skb_shinfo(skb)->frags[f].size, - adapter->max_data_per_txd); - if((skb_shinfo(skb)->tso_size) || (skb->ip_summed == CHECKSUM_HW)) - count++; - - if(E1000_DESC_UNUSED(&adapter->tx_ring) < count) { + if(E1000_DESC_UNUSED(&adapter->tx_ring) < DESC_NEEDED) { netif_stop_queue(netdev); return 1; } + if(adapter->hw.mac_type == e1000_82547) { + if(e1000_82547_fifo_workaround(adapter, skb)) { + netif_stop_queue(netdev); + mod_timer(&adapter->tx_fifo_stall_timer, jiffies); + return 1; + } + } + if(adapter->vlgrp && vlan_tx_tag_present(skb)) { tx_flags |= E1000_TX_FLAGS_VLAN; tx_flags |= (vlan_tx_tag_get(skb) << E1000_TX_FLAGS_VLAN_SHIFT); @@ -1530,9 +1709,7 @@ else if(e1000_tx_csum(adapter, skb)) tx_flags |= E1000_TX_FLAGS_CSUM; - count = e1000_tx_map(adapter, skb); - - e1000_tx_queue(adapter, count, tx_flags); + e1000_tx_queue(adapter, e1000_tx_map(adapter, skb), tx_flags); netdev->trans_start = jiffies; @@ -1653,7 +1830,8 @@ adapter->stats.crcerrs += E1000_READ_REG(hw, CRCERRS); adapter->stats.gprc += E1000_READ_REG(hw, GPRC); - adapter->stats.gorcl += E1000_READ_REG(hw, GORCL); + adapter->gorcl = E1000_READ_REG(hw, GORCL); + adapter->stats.gorcl += adapter->gorcl; adapter->stats.gorch += E1000_READ_REG(hw, GORCH); adapter->stats.bprc += E1000_READ_REG(hw, BPRC); adapter->stats.mprc += E1000_READ_REG(hw, MPRC); @@ -1684,7 +1862,8 @@ adapter->stats.xofftxc += E1000_READ_REG(hw, XOFFTXC); adapter->stats.fcruc += E1000_READ_REG(hw, FCRUC); adapter->stats.gptc += E1000_READ_REG(hw, GPTC); - adapter->stats.gotcl += E1000_READ_REG(hw, GOTCL); + adapter->gotcl = E1000_READ_REG(hw, GOTCL); + adapter->stats.gotcl += adapter->gotcl; adapter->stats.gotch += E1000_READ_REG(hw, GOTCH); adapter->stats.rnbc += E1000_READ_REG(hw, RNBC); adapter->stats.ruc += E1000_READ_REG(hw, RUC); @@ -1807,60 +1986,57 @@ { struct net_device *netdev = data; struct e1000_adapter *adapter = netdev->priv; - -#ifdef CONFIG_E1000_NAPI - if (netif_rx_schedule_prep(netdev)) { - /* Disable interrupts and enable polling */ - atomic_inc(&adapter->irq_sem); - E1000_WRITE_REG(&adapter->hw, IMC, ~0); - E1000_WRITE_FLUSH(&adapter->hw); - __netif_rx_schedule(netdev); - } -#else - uint32_t icr; - int i = E1000_MAX_INTR; - - while(i && (icr = E1000_READ_REG(&adapter->hw, ICR))) { - - if(icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC)) { - adapter->hw.get_link_status = 1; - mod_timer(&adapter->watchdog_timer, jiffies); - } + uint32_t icr = E1000_READ_REG(&adapter->hw, ICR); +#ifndef CONFIG_E1000_NAPI + int i; +#endif - e1000_clean_rx_irq(adapter); - e1000_clean_tx_irq(adapter); - i--; + if(!icr) + return; /* Not our interrupt */ + if(icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC)) { + adapter->hw.get_link_status = 1; + mod_timer(&adapter->watchdog_timer, jiffies); } + +#ifdef CONFIG_E1000_NAPI + /* Don't disable interrupts - rely on h/w interrupt + * moderation to keep interrupts low. netif_rx_schedule + * is NOP if already polling. */ + netif_rx_schedule(netdev); +#else + for(i = 0; i < E1000_MAX_INTR; i++) + if(!e1000_clean_rx_irq(adapter) && + !e1000_clean_tx_irq(adapter)) + break; #endif } #ifdef CONFIG_E1000_NAPI +/** + * e1000_clean - NAPI Rx polling callback + * @adapter: board private structure + **/ + static int -e1000_process_intr(struct net_device *netdev) +e1000_clean(struct net_device *netdev, int *budget) { struct e1000_adapter *adapter = netdev->priv; - uint32_t icr; - int i = E1000_MAX_INTR; - int hasReceived = 0; - - while(i && (icr = E1000_READ_REG(&adapter->hw, ICR))) { - if (icr & E1000_ICR_RXT0) - hasReceived = 1; - - if (!(icr & ~(E1000_ICR_RXT0))) + int work_to_do = min(*budget, netdev->quota); + int work_done = 0; + + while(work_done < work_to_do) + if(!e1000_clean_rx_irq(adapter, &work_done, work_to_do) && + !e1000_clean_tx_irq(adapter)) break; - - if (icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC)) { - adapter->hw.get_link_status = 1; - mod_timer(&adapter->watchdog_timer, jiffies); - } - - e1000_clean_tx_irq(adapter); - i--; - } - return hasReceived; + *budget -= work_done; + netdev->quota -= work_done; + + if(work_done < work_to_do) + netif_rx_complete(netdev); + + return (work_done >= work_to_do); } #endif @@ -1869,20 +2045,22 @@ * @adapter: board private structure **/ -static void +static boolean_t e1000_clean_tx_irq(struct e1000_adapter *adapter) { struct e1000_desc_ring *tx_ring = &adapter->tx_ring; struct net_device *netdev = adapter->netdev; struct pci_dev *pdev = adapter->pdev; struct e1000_tx_desc *tx_desc; - int i; + int i, cleaned = FALSE; i = tx_ring->next_to_clean; tx_desc = E1000_TX_DESC(*tx_ring, i); while(tx_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) { + cleaned = TRUE; + if(tx_ring->buffer_info[i].dma) { pci_unmap_page(pdev, @@ -1900,158 +2078,34 @@ tx_ring->buffer_info[i].skb = NULL; } + tx_desc->buffer_addr = 0; + tx_desc->lower.data = 0; tx_desc->upper.data = 0; - i = (i + 1) % tx_ring->count; + if(++i == tx_ring->count) i = 0; tx_desc = E1000_TX_DESC(*tx_ring, i); } tx_ring->next_to_clean = i; - if(netif_queue_stopped(netdev) && netif_carrier_ok(netdev) && - (E1000_DESC_UNUSED(tx_ring) > E1000_TX_QUEUE_WAKE)) { - + if(cleaned && netif_queue_stopped(netdev) && netif_carrier_ok(netdev)) netif_wake_queue(netdev); - } -} - -#ifdef CONFIG_E1000_NAPI -static int -e1000_poll(struct net_device *netdev, int *budget) -{ - struct e1000_adapter *adapter = netdev->priv; - struct e1000_desc_ring *rx_ring = &adapter->rx_ring; - struct pci_dev *pdev = adapter->pdev; - struct e1000_rx_desc *rx_desc; - struct sk_buff *skb; - unsigned long flags; - uint32_t length; - uint8_t last_byte; - int i; - int received = 0; - int rx_work_limit = *budget; - - if(rx_work_limit > netdev->quota) - rx_work_limit = netdev->quota; - - e1000_process_intr(netdev); - - i = rx_ring->next_to_clean; - rx_desc = E1000_RX_DESC(*rx_ring, i); - - while(rx_desc->status & E1000_RXD_STAT_DD) { - if(--rx_work_limit < 0) - goto not_done; - - pci_unmap_single(pdev, - rx_ring->buffer_info[i].dma, - rx_ring->buffer_info[i].length, - PCI_DMA_FROMDEVICE); - - skb = rx_ring->buffer_info[i].skb; - length = le16_to_cpu(rx_desc->length); - - if(!(rx_desc->status & E1000_RXD_STAT_EOP)) { - - /* All receives must fit into a single buffer */ - - E1000_DBG("Receive packet consumed multiple buffers\n"); - - dev_kfree_skb_irq(skb); - rx_desc->status = 0; - rx_ring->buffer_info[i].skb = NULL; - - i = (i + 1) % rx_ring->count; - - rx_desc = E1000_RX_DESC(*rx_ring, i); - continue; - } - - if(rx_desc->errors & E1000_RXD_ERR_FRAME_ERR_MASK) { - - last_byte = *(skb->data + length - 1); - - if(TBI_ACCEPT(&adapter->hw, rx_desc->status, - rx_desc->errors, length, last_byte)) { - - spin_lock_irqsave(&adapter->stats_lock, flags); - - e1000_tbi_adjust_stats(&adapter->hw, - &adapter->stats, - length, skb->data); - - spin_unlock_irqrestore(&adapter->stats_lock, - flags); - length--; - } else { - - dev_kfree_skb_irq(skb); - rx_desc->status = 0; - rx_ring->buffer_info[i].skb = NULL; - - i = (i + 1) % rx_ring->count; - rx_desc = E1000_RX_DESC(*rx_ring, i); - continue; - } - } - - /* Good Receive */ - skb_put(skb, length - ETHERNET_FCS_SIZE); - - /* Receive Checksum Offload */ - e1000_rx_checksum(adapter, rx_desc, skb); - - skb->protocol = eth_type_trans(skb, netdev); - if(adapter->vlgrp && (rx_desc->status & E1000_RXD_STAT_VP)) { - vlan_hwaccel_rx(skb, adapter->vlgrp, - (rx_desc->special & E1000_RXD_SPC_VLAN_MASK)); - } else { - netif_receive_skb(skb); - } - netdev->last_rx = jiffies; - - rx_desc->status = 0; - rx_ring->buffer_info[i].skb = NULL; - - i = (i + 1) % rx_ring->count; - - rx_desc = E1000_RX_DESC(*rx_ring, i); - received++; - } - - if(!received) - received = 1; - - e1000_alloc_rx_buffers(adapter); - - rx_ring->next_to_clean = i; - netdev->quota -= received; - *budget -= received; - - netif_rx_complete(netdev); - - e1000_irq_enable(adapter); - return 0; - -not_done: - - e1000_alloc_rx_buffers(adapter); - - rx_ring->next_to_clean = i; - netdev->quota -= received; - *budget -= received; - - return 1; + return cleaned; } -#else + /** * e1000_clean_rx_irq - Send received data up the network stack, * @adapter: board private structure **/ -static void +static boolean_t +#ifdef CONFIG_E1000_NAPI +e1000_clean_rx_irq(struct e1000_adapter *adapter, int *work_done, + int work_to_do) +#else e1000_clean_rx_irq(struct e1000_adapter *adapter) +#endif { struct e1000_desc_ring *rx_ring = &adapter->rx_ring; struct net_device *netdev = adapter->netdev; @@ -2061,13 +2115,22 @@ unsigned long flags; uint32_t length; uint8_t last_byte; - int i; + int i, cleaned = FALSE; i = rx_ring->next_to_clean; rx_desc = E1000_RX_DESC(*rx_ring, i); while(rx_desc->status & E1000_RXD_STAT_DD) { +#ifdef CONFIG_E1000_NAPI + if(*work_done >= work_to_do) + break; + + (*work_done)++; +#endif + + cleaned = TRUE; + pci_unmap_single(pdev, rx_ring->buffer_info[i].dma, rx_ring->buffer_info[i].length, @@ -2086,7 +2149,7 @@ rx_desc->status = 0; rx_ring->buffer_info[i].skb = NULL; - i = (i + 1) % rx_ring->count; + if(++i == rx_ring->count) i = 0; rx_desc = E1000_RX_DESC(*rx_ring, i); continue; @@ -2114,7 +2177,7 @@ rx_desc->status = 0; rx_ring->buffer_info[i].skb = NULL; - i = (i + 1) % rx_ring->count; + if(++i == rx_ring->count) i = 0; rx_desc = E1000_RX_DESC(*rx_ring, i); continue; @@ -2128,18 +2191,28 @@ e1000_rx_checksum(adapter, rx_desc, skb); skb->protocol = eth_type_trans(skb, netdev); +#ifdef CONFIG_E1000_NAPI + if(adapter->vlgrp && (rx_desc->status & E1000_RXD_STAT_VP)) { + vlan_hwaccel_receive_skb(skb, adapter->vlgrp, + (rx_desc->special & E1000_RXD_SPC_VLAN_MASK)); + } else { + netif_receive_skb(skb); + } +#else /* CONFIG_E1000_NAPI */ if(adapter->vlgrp && (rx_desc->status & E1000_RXD_STAT_VP)) { vlan_hwaccel_rx(skb, adapter->vlgrp, (rx_desc->special & E1000_RXD_SPC_VLAN_MASK)); } else { netif_rx(skb); } +#endif /* CONFIG_E1000_NAPI */ + netdev->last_rx = jiffies; rx_desc->status = 0; rx_ring->buffer_info[i].skb = NULL; - i = (i + 1) % rx_ring->count; + if(++i == rx_ring->count) i = 0; rx_desc = E1000_RX_DESC(*rx_ring, i); } @@ -2147,8 +2220,9 @@ rx_ring->next_to_clean = i; e1000_alloc_rx_buffers(adapter); + + return cleaned; } -#endif /** * e1000_alloc_rx_buffers - Replace used receive buffers @@ -2163,11 +2237,9 @@ struct pci_dev *pdev = adapter->pdev; struct e1000_rx_desc *rx_desc; struct sk_buff *skb; - int reserve_len; + int reserve_len = 2; int i; - reserve_len = 2; - i = rx_ring->next_to_use; while(!rx_ring->buffer_info[i].skb) { @@ -2198,7 +2270,7 @@ rx_desc->buffer_addr = cpu_to_le64(rx_ring->buffer_info[i].dma); - if(!(i % E1000_RX_BUFFER_WRITE)) { + if((i & ~(E1000_RX_BUFFER_WRITE - 1)) == i) { /* Force memory writes to complete before letting h/w * know there are new descriptors to fetch. (Only * applicable for weak-ordered memory model archs, @@ -2208,13 +2280,68 @@ E1000_WRITE_REG(&adapter->hw, RDT, i); } - i = (i + 1) % rx_ring->count; + if(++i == rx_ring->count) i = 0; } rx_ring->next_to_use = i; } /** + * e1000_smartspeed - Workaround for SmartSpeed on 82541 and 82547 controllers. + * @adapter: + **/ + +static void +e1000_smartspeed(struct e1000_adapter *adapter) +{ + uint16_t phy_status; + uint16_t phy_ctrl; + + if((adapter->hw.phy_type != e1000_phy_igp) || !adapter->hw.autoneg || + !(adapter->hw.autoneg_advertised & ADVERTISE_1000_FULL)) + return; + + if(adapter->smartspeed == 0) { + /* If Master/Slave config fault is asserted twice, + * we assume back-to-back */ + e1000_read_phy_reg(&adapter->hw, PHY_1000T_STATUS, &phy_status); + if(!(phy_status & SR_1000T_MS_CONFIG_FAULT)) return; + e1000_read_phy_reg(&adapter->hw, PHY_1000T_STATUS, &phy_status); + if(!(phy_status & SR_1000T_MS_CONFIG_FAULT)) return; + e1000_read_phy_reg(&adapter->hw, PHY_1000T_CTRL, &phy_ctrl); + if(phy_ctrl & CR_1000T_MS_ENABLE) { + phy_ctrl &= ~CR_1000T_MS_ENABLE; + e1000_write_phy_reg(&adapter->hw, PHY_1000T_CTRL, + phy_ctrl); + adapter->smartspeed++; + if(!e1000_phy_setup_autoneg(&adapter->hw) && + !e1000_read_phy_reg(&adapter->hw, PHY_CTRL, + &phy_ctrl)) { + phy_ctrl |= (MII_CR_AUTO_NEG_EN | + MII_CR_RESTART_AUTO_NEG); + e1000_write_phy_reg(&adapter->hw, PHY_CTRL, + phy_ctrl); + } + } + return; + } else if(adapter->smartspeed == E1000_SMARTSPEED_DOWNSHIFT) { + /* If still no link, perhaps using 2/3 pair cable */ + e1000_read_phy_reg(&adapter->hw, PHY_1000T_CTRL, &phy_ctrl); + phy_ctrl |= CR_1000T_MS_ENABLE; + e1000_write_phy_reg(&adapter->hw, PHY_1000T_CTRL, phy_ctrl); + if(!e1000_phy_setup_autoneg(&adapter->hw) && + !e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &phy_ctrl)) { + phy_ctrl |= (MII_CR_AUTO_NEG_EN | + MII_CR_RESTART_AUTO_NEG); + e1000_write_phy_reg(&adapter->hw, PHY_CTRL, phy_ctrl); + } + } + /* Restart process after E1000_SMARTSPEED_MAX iterations */ + if(adapter->smartspeed++ == E1000_SMARTSPEED_MAX) + adapter->smartspeed = 0; +} + +/** * e1000_ioctl - * @netdev: * @ifreq: @@ -2225,6 +2352,10 @@ e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) { switch (cmd) { + case SIOCGMIIPHY: + case SIOCGMIIREG: + case SIOCSMIIREG: + return e1000_mii_ioctl(netdev, ifr, cmd); case SIOCETHTOOL: return e1000_ethtool_ioctl(netdev, ifr); default: @@ -2233,6 +2364,86 @@ } /** + * e1000_mii_ioctl - + * @netdev: + * @ifreq: + * @cmd: + **/ + +static int +e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) +{ + struct e1000_adapter *adapter = netdev->priv; + struct mii_ioctl_data *data = (struct mii_ioctl_data *)&ifr->ifr_data; + int retval; + uint16_t mii_reg; + uint16_t spddplx; + + if(adapter->hw.media_type == e1000_media_type_fiber) + return -EOPNOTSUPP; + + switch (cmd) { + case SIOCGMIIPHY: + data->phy_id = adapter->hw.phy_addr; + break; + case SIOCGMIIREG: + if (!capable(CAP_NET_ADMIN)) + return -EPERM; + if (e1000_read_phy_reg(&adapter->hw, data->reg_num & 0x1F, + &data->val_out)) + return -EIO; + break; + case SIOCSMIIREG: + if (!capable(CAP_NET_ADMIN)) + return -EPERM; + if (data->reg_num & ~(0x1F)) + return -EFAULT; + mii_reg = data->val_in; + if (e1000_write_phy_reg(&adapter->hw, data->reg_num, + data->val_in)) + return -EIO; + if (adapter->hw.phy_type == e1000_phy_m88) { + switch (data->reg_num) { + case PHY_CTRL: + if(data->val_in & MII_CR_AUTO_NEG_EN) { + adapter->hw.autoneg = 1; + adapter->hw.autoneg_advertised = 0x2F; + } else { + if (data->val_in & 0x40) + spddplx = SPEED_1000; + else if (data->val_in & 0x2000) + spddplx = SPEED_100; + else + spddplx = SPEED_10; + spddplx += (data->val_in & 0x100) + ? FULL_DUPLEX : + HALF_DUPLEX; + retval = e1000_set_spd_dplx(adapter, + spddplx); + if(retval) + return retval; + } + if(netif_running(adapter->netdev)) { + e1000_down(adapter); + e1000_up(adapter); + } else + e1000_reset(adapter); + break; + case M88E1000_PHY_SPEC_CTRL: + case M88E1000_EXT_PHY_SPEC_CTRL: + if (e1000_phy_reset(&adapter->hw)) + return -EIO; + break; + } + } + break; + default: + return -EOPNOTSUPP; + } + return E1000_SUCCESS; +} + +/** * e1000_rx_checksum - Receive Checksum Offload for 82543 * @adapter: board private structure * @rx_desc: receive descriptor @@ -2402,6 +2613,35 @@ } } +int +e1000_set_spd_dplx(struct e1000_adapter *adapter, uint16_t spddplx) +{ + adapter->hw.autoneg = 0; + + switch(spddplx) { + case SPEED_10 + DUPLEX_HALF: + adapter->hw.forced_speed_duplex = e1000_10_half; + break; + case SPEED_10 + DUPLEX_FULL: + adapter->hw.forced_speed_duplex = e1000_10_full; + break; + case SPEED_100 + DUPLEX_HALF: + adapter->hw.forced_speed_duplex = e1000_100_half; + break; + case SPEED_100 + DUPLEX_FULL: + adapter->hw.forced_speed_duplex = e1000_100_full; + break; + case SPEED_1000 + DUPLEX_FULL: + adapter->hw.autoneg = 1; + adapter->hw.autoneg_advertised = ADVERTISE_1000_FULL; + break; + case SPEED_1000 + DUPLEX_HALF: /* not supported */ + default: + return -EINVAL; + } + return 0; +} + static int e1000_notify_reboot(struct notifier_block *nb, unsigned long event, void *p) { @@ -2419,6 +2659,7 @@ return NOTIFY_DONE; } + static int e1000_suspend(struct pci_dev *pdev, uint32_t state) { @@ -2483,7 +2724,8 @@ if(manc & E1000_MANC_SMBUS_EN) { manc |= E1000_MANC_ARP_EN; E1000_WRITE_REG(&adapter->hw, MANC, manc); - state = 0; + pci_enable_wake(pdev, 3, 1); + pci_enable_wake(pdev, 4, 1); /* 4 == D3 cold */ } } diff -Nru a/drivers/net/e1000/e1000_osdep.h b/drivers/net/e1000/e1000_osdep.h --- a/drivers/net/e1000/e1000_osdep.h Sun Mar 23 00:22:51 2003 +++ b/drivers/net/e1000/e1000_osdep.h Sun Mar 23 00:22:51 2003 @@ -1,7 +1,7 @@ /******************************************************************************* - Copyright(c) 1999 - 2002 Intel Corporation. All rights reserved. + Copyright(c) 1999 - 2003 Intel Corporation. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -77,24 +77,22 @@ #define E1000_WRITE_REG(a, reg, value) ( \ - ((a)->mac_type >= e1000_82543) ? \ - (writel((value), ((a)->hw_addr + E1000_##reg))) : \ - (writel((value), ((a)->hw_addr + E1000_82542_##reg)))) + writel((value), ((a)->hw_addr + \ + (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg)))) #define E1000_READ_REG(a, reg) ( \ - ((a)->mac_type >= e1000_82543) ? \ - readl((a)->hw_addr + E1000_##reg) : \ - readl((a)->hw_addr + E1000_82542_##reg)) + readl((a)->hw_addr + \ + (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg))) #define E1000_WRITE_REG_ARRAY(a, reg, offset, value) ( \ - ((a)->mac_type >= e1000_82543) ? \ - writel((value), ((a)->hw_addr + E1000_##reg + ((offset) << 2))) : \ - writel((value), ((a)->hw_addr + E1000_82542_##reg + ((offset) << 2)))) + writel((value), ((a)->hw_addr + \ + (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \ + ((offset) << 2)))) #define E1000_READ_REG_ARRAY(a, reg, offset) ( \ - ((a)->mac_type >= e1000_82543) ? \ - readl((a)->hw_addr + E1000_##reg + ((offset) << 2)) : \ - readl((a)->hw_addr + E1000_82542_##reg + ((offset) << 2))) + readl((a)->hw_addr + \ + (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \ + ((offset) << 2))) #define E1000_WRITE_FLUSH(a) E1000_READ_REG(a, STATUS) diff -Nru a/drivers/net/e1000/e1000_param.c b/drivers/net/e1000/e1000_param.c --- a/drivers/net/e1000/e1000_param.c Sun Mar 23 00:22:54 2003 +++ b/drivers/net/e1000/e1000_param.c Sun Mar 23 00:22:54 2003 @@ -1,7 +1,7 @@ /******************************************************************************* - Copyright(c) 1999 - 2002 Intel Corporation. All rights reserved. + Copyright(c) 1999 - 2003 Intel Corporation. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -75,7 +75,7 @@ * Valid Range: 80-256 for 82542 and 82543 gigabit ethernet controllers * Valid Range: 80-4096 for 82544 * - * Default Value: 80 + * Default Value: 256 */ E1000_PARAM(RxDescriptors, "Number of receive descriptors"); @@ -169,7 +169,7 @@ * * Valid Range: 0-65535 * - * Default Value: 0/128 + * Default Value: 0 */ E1000_PARAM(RxIntDelay, "Receive Interrupt Delay"); @@ -183,6 +183,15 @@ E1000_PARAM(RxAbsIntDelay, "Receive Absolute Interrupt Delay"); +/* Interrupt Throttle Rate (interrupts/sec) + * + * Valid Range: 100-100000 (0=off, 1=dynamic) + * + * Default Value: 1 + */ + +E1000_PARAM(InterruptThrottleRate, "Interrupt Throttling Rate"); + #define AUTONEG_ADV_DEFAULT 0x2F #define AUTONEG_ADV_MASK 0x2F #define FLOW_CONTROL_DEFAULT FLOW_CONTROL_FULL @@ -192,7 +201,7 @@ #define MIN_TXD 80 #define MAX_82544_TXD 4096 -#define DEFAULT_RXD 80 +#define DEFAULT_RXD 256 #define MAX_RXD 256 #define MIN_RXD 80 #define MAX_82544_RXD 4096 @@ -213,6 +222,10 @@ #define MAX_TXABSDELAY 0xFFFF #define MIN_TXABSDELAY 0 +#define DEFAULT_ITR 1 +#define MAX_ITR 100000 +#define MIN_ITR 100 + struct e1000_option { enum { enable_option, range_option, list_option } type; char *name; @@ -309,7 +322,7 @@ .name = "Transmit Descriptors", .err = "using default of " __MODULE_STRING(DEFAULT_TXD), .def = DEFAULT_TXD, - .arg = { .r = { .min = MIN_TXD }} + .arg = { .r { .min = MIN_TXD }} }; struct e1000_desc_ring *tx_ring = &adapter->tx_ring; e1000_mac_type mac_type = adapter->hw.mac_type; @@ -362,7 +375,8 @@ .name = "Flow Control", .err = "reading default settings from EEPROM", .def = e1000_fc_default, - .arg = { .l = { .nr = ARRAY_SIZE(fc_list), .p = fc_list }} + .arg = { .l = { .nr = ARRAY_SIZE(fc_list), + .p = fc_list }} }; int fc = FlowControl[bd]; @@ -370,58 +384,78 @@ adapter->hw.fc = adapter->hw.original_fc = fc; } { /* Transmit Interrupt Delay */ - char *tidv = "using default of " __MODULE_STRING(DEFAULT_TIDV); struct e1000_option opt = { .type = range_option, .name = "Transmit Interrupt Delay", - .arg = { .r = { .min = MIN_TXDELAY, .max = MAX_TXDELAY }} + .err = "using default of " __MODULE_STRING(DEFAULT_TIDV), + .def = DEFAULT_TIDV, + .arg = { .r = { .min = MIN_TXDELAY, + .max = MAX_TXDELAY }} }; - opt.def = DEFAULT_TIDV; - opt.err = tidv; adapter->tx_int_delay = TxIntDelay[bd]; e1000_validate_option(&adapter->tx_int_delay, &opt); } { /* Transmit Absolute Interrupt Delay */ - char *tadv = "using default of " __MODULE_STRING(DEFAULT_TADV); struct e1000_option opt = { .type = range_option, .name = "Transmit Absolute Interrupt Delay", - .arg = { .r = { .min = MIN_TXABSDELAY, .max = MAX_TXABSDELAY }} + .err = "using default of " __MODULE_STRING(DEFAULT_TADV), + .def = DEFAULT_TADV, + .arg = { .r = { .min = MIN_TXABSDELAY, + .max = MAX_TXABSDELAY }} }; - opt.def = DEFAULT_TADV; - opt.err = tadv; adapter->tx_abs_int_delay = TxAbsIntDelay[bd]; e1000_validate_option(&adapter->tx_abs_int_delay, &opt); } { /* Receive Interrupt Delay */ - char *rdtr = "using default of " __MODULE_STRING(DEFAULT_RDTR); struct e1000_option opt = { .type = range_option, .name = "Receive Interrupt Delay", - .arg = { .r = { .min = MIN_RXDELAY, .max = MAX_RXDELAY }} + .err = "using default of " __MODULE_STRING(DEFAULT_RDTR), + .def = DEFAULT_RDTR, + .arg = { .r = { .min = MIN_RXDELAY, + .max = MAX_RXDELAY }} }; - opt.def = DEFAULT_RDTR; - opt.err = rdtr; adapter->rx_int_delay = RxIntDelay[bd]; e1000_validate_option(&adapter->rx_int_delay, &opt); } { /* Receive Absolute Interrupt Delay */ - char *radv = "using default of " __MODULE_STRING(DEFAULT_RADV); struct e1000_option opt = { .type = range_option, .name = "Receive Absolute Interrupt Delay", - .arg = { .r = { .min = MIN_RXABSDELAY, .max = MAX_RXABSDELAY }} + .err = "using default of " __MODULE_STRING(DEFAULT_RADV), + .def = DEFAULT_RADV, + .arg = { .r = { .min = MIN_RXABSDELAY, + .max = MAX_RXABSDELAY }} }; - opt.def = DEFAULT_RADV; - opt.err = radv; adapter->rx_abs_int_delay = RxAbsIntDelay[bd]; e1000_validate_option(&adapter->rx_abs_int_delay, &opt); } - + { /* Interrupt Throttling Rate */ + struct e1000_option opt = { + .type = range_option, + .name = "Interrupt Throttling Rate (ints/sec)", + .err = "using default of " __MODULE_STRING(DEFAULT_ITR), + .def = DEFAULT_ITR, + .arg = { .r = { .min = MIN_ITR, + .max = MAX_ITR }} + }; + + adapter->itr = InterruptThrottleRate[bd]; + if(adapter->itr == 0) { + printk(KERN_INFO "%s turned off\n", opt.name); + } else if(adapter->itr == 1 || adapter->itr == -1) { + /* Dynamic mode */ + adapter->itr = 1; + } else { + e1000_validate_option(&adapter->itr, &opt); + } + } + switch(adapter->hw.media_type) { case e1000_media_type_fiber: e1000_check_fiber_options(adapter); @@ -486,7 +520,8 @@ .name = "Speed", .err = "parameter ignored", .def = 0, - .arg = { .l = { .nr = ARRAY_SIZE(speed_list), .p = speed_list }} + .arg = { .l = { .nr = ARRAY_SIZE(speed_list), + .p = speed_list }} }; speed = Speed[bd]; @@ -502,7 +537,8 @@ .name = "Duplex", .err = "parameter ignored", .def = 0, - .arg = { .l = { .nr = ARRAY_SIZE(dplx_list), .p = dplx_list }} + .arg = { .l = { .nr = ARRAY_SIZE(dplx_list), + .p = dplx_list }} }; dplx = Duplex[bd]; @@ -554,7 +590,8 @@ .name = "AutoNeg", .err = "parameter ignored", .def = AUTONEG_ADV_DEFAULT, - .arg = { .l = { .nr = ARRAY_SIZE(an_list), .p = an_list }} + .arg = { .l = { .nr = ARRAY_SIZE(an_list), + .p = an_list }} }; int an = AutoNeg[bd]; diff -Nru a/drivers/net/irda/ali-ircc.c b/drivers/net/irda/ali-ircc.c --- a/drivers/net/irda/ali-ircc.c Sun Mar 23 00:22:52 2003 +++ b/drivers/net/irda/ali-ircc.c Sun Mar 23 00:22:52 2003 @@ -248,7 +248,6 @@ struct ali_ircc_cb *self; struct pm_dev *pmdev; int dongle_id; - int ret; int err; IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__); diff -Nru a/drivers/net/macmace.c b/drivers/net/macmace.c --- a/drivers/net/macmace.c Sun Mar 23 00:22:52 2003 +++ b/drivers/net/macmace.c Sun Mar 23 00:22:52 2003 @@ -331,8 +331,8 @@ return -ENOMEM; } - mp->rx_ring_phys = (unsigned char *) virt_to_bus(mp->rx_ring); - mp->tx_ring_phys = (unsigned char *) virt_to_bus(mp->tx_ring); + mp->rx_ring_phys = (unsigned char *) virt_to_bus((void *)mp->rx_ring); + mp->tx_ring_phys = (unsigned char *) virt_to_bus((void *)mp->tx_ring); /* We want the Rx buffer to be uncached and the Tx buffer to be writethrough */ diff -Nru a/drivers/net/ne2k_cbus.c b/drivers/net/ne2k_cbus.c --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/drivers/net/ne2k_cbus.c Sun Mar 23 00:22:57 2003 @@ -0,0 +1,879 @@ +/* ne.c: A general non-shared-memory NS8390 ethernet driver for linux. */ +/* + Written 1992-94 by Donald Becker. + + Copyright 1993 United States Government as represented by the + Director, National Security Agency. + + This software may be used and distributed according to the terms + of the GNU General Public License, incorporated herein by reference. + + The author may be reached as becker@scyld.com, or C/O + Scyld Computing Corporation, 410 Severn Ave., Suite 210, Annapolis MD 21403 + + This driver should work with many programmed-I/O 8390-based ethernet + boards. Currently it supports the NE1000, NE2000, many clones, + and some Cabletron products. + + Changelog: + + Paul Gortmaker : use ENISR_RDC to monitor Tx PIO uploads, made + sanity checks and bad clone support optional. + Paul Gortmaker : new reset code, reset card after probe at boot. + Paul Gortmaker : multiple card support for module users. + Paul Gortmaker : Support for PCI ne2k clones, similar to lance.c + Paul Gortmaker : Allow users with bad cards to avoid full probe. + Paul Gortmaker : PCI probe changes, more PCI cards supported. + rjohnson@analogic.com : Changed init order so an interrupt will only + occur after memory is allocated for dev->priv. Deallocated memory + last in cleanup_modue() + Richard Guenther : Added support for ISAPnP cards + Paul Gortmaker : Discontinued PCI support - use ne2k-pci.c instead. + Osamu Tomita : Separate driver for NEC PC-9800. + +*/ + +/* Routines for the NatSemi-based designs (NE[12]000). */ + +static const char version1[] = +"ne.c:v1.10 9/23/94 Donald Becker (becker@scyld.com)\n"; +static const char version2[] = +"Last modified Nov 1, 2000 by Paul Gortmaker\n"; + + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "8390.h" + +/* Some defines that people can play with if so inclined. */ + +/* Do we support clones that don't adhere to 14,15 of the SAprom ? */ +#define SUPPORT_NE_BAD_CLONES + +/* Do we perform extra sanity checks on stuff ? */ +/* #define NE_SANITY_CHECK */ + +/* Do we implement the read before write bugfix ? */ +/* #define NE_RW_BUGFIX */ + +/* Do we have a non std. amount of memory? (in units of 256 byte pages) */ +/* #define PACKETBUF_MEMSIZE 0x40 */ + +#ifdef SUPPORT_NE_BAD_CLONES +/* A list of bad clones that we none-the-less recognize. */ +static struct { const char *name8, *name16; unsigned char SAprefix[4];} +bad_clone_list[] __initdata = { + {"LA/T-98?", "LA/T-98", {0x00, 0xa0, 0xb0}}, /* I/O Data */ + {"EGY-98?", "EGY-98", {0x00, 0x40, 0x26}}, /* Melco EGY98 */ + {"ICM?", "ICM-27xx-ET", {0x00, 0x80, 0xc8}}, /* ICM IF-27xx-ET */ + {"CNET-98/EL?", "CNET(98)E/L", {0x00, 0x80, 0x4C}}, /* Contec CNET-98/EL */ + {0,} +}; +#endif + +/* ---- No user-serviceable parts below ---- */ + +#define NE_BASE (dev->base_addr) +#define NE_CMD EI_SHIFT(0x00) +#define NE_DATAPORT EI_SHIFT(0x10) /* NatSemi-defined port window offset. */ +#define NE_RESET EI_SHIFT(0x1f) /* Issue a read to reset, a write to clear. */ +#define NE_IO_EXTENT 0x20 + +#define NE1SM_START_PG 0x20 /* First page of TX buffer */ +#define NE1SM_STOP_PG 0x40 /* Last page +1 of RX ring */ +#define NESM_START_PG 0x40 /* First page of TX buffer */ +#define NESM_STOP_PG 0x80 /* Last page +1 of RX ring */ + +#include "ne2k_cbus.h" + +int ne_probe(struct net_device *dev); +static int ne_probe1(struct net_device *dev, int ioaddr); +static int ne_open(struct net_device *dev); +static int ne_close(struct net_device *dev); + +static void ne_reset_8390(struct net_device *dev); +static void ne_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, + int ring_page); +static void ne_block_input(struct net_device *dev, int count, + struct sk_buff *skb, int ring_offset); +static void ne_block_output(struct net_device *dev, const int count, + const unsigned char *buf, const int start_page); + + +/* Probe for various non-shared-memory ethercards. + + NEx000-clone boards have a Station Address PROM (SAPROM) in the packet + buffer memory space. NE2000 clones have 0x57,0x57 in bytes 0x0e,0x0f of + the SAPROM, while other supposed NE2000 clones must be detected by their + SA prefix. + + Reading the SAPROM from a word-wide card with the 8390 set in byte-wide + mode results in doubled values, which can be detected and compensated for. + + The probe is also responsible for initializing the card and filling + in the 'dev' and 'ei_status' structures. + + We use the minimum memory size for some ethercard product lines, iff we can't + distinguish models. You can increase the packet buffer size by setting + PACKETBUF_MEMSIZE. Reported Cabletron packet buffer locations are: + E1010 starts at 0x100 and ends at 0x2000. + E1010-x starts at 0x100 and ends at 0x8000. ("-x" means "more memory") + E2010 starts at 0x100 and ends at 0x4000. + E2010-x starts at 0x100 and ends at 0xffff. */ + +int __init ne_probe(struct net_device *dev) +{ + unsigned int base_addr = dev->base_addr; + + SET_MODULE_OWNER(dev); + + if (ei_debug > 2) + printk(KERN_DEBUG "ne_probe(): entered.\n"); + + /* If CONFIG_NET_CBUS, + we need dev->priv->reg_offset BEFORE to probe */ + if (ne2k_cbus_init(dev) != 0) + return -ENOMEM; + + /* First check any supplied i/o locations. User knows best. */ + if (base_addr > 0) { + int result; + const struct ne2k_cbus_hwinfo *hw = ne2k_cbus_get_hwinfo((int)(dev->mem_start & NE2K_CBUS_HARDWARE_TYPE_MASK)); + + if (ei_debug > 2) + printk(KERN_DEBUG "ne_probe(): call ne_probe_cbus(base_addr=0x%x)\n", base_addr); + + result = ne_probe_cbus(dev, hw, base_addr); + if (result != 0) + ne2k_cbus_destroy(dev); + + return result; + } + + if (ei_debug > 2) + printk(KERN_DEBUG "ne_probe(): base_addr is not specified.\n"); + +#ifndef MODULE + /* Last resort. The semi-risky C-Bus auto-probe. */ + if (ei_debug > 2) + printk(KERN_DEBUG "ne_probe(): auto-probe start.\n"); + + { + const struct ne2k_cbus_hwinfo *hw = ne2k_cbus_get_hwinfo((int)(dev->mem_start & NE2K_CBUS_HARDWARE_TYPE_MASK)); + + if (hw && hw->hwtype) { + const unsigned short *plist; + for (plist = hw->portlist; *plist; plist++) + if (ne_probe_cbus(dev, hw, *plist) == 0) + return 0; + } else { + for (hw = &ne2k_cbus_hwinfo_list[0]; hw->hwtype; hw++) { + const unsigned short *plist; + for (plist = hw->portlist; *plist; plist++) + if (ne_probe_cbus(dev, hw, *plist) == 0) + return 0; + } + } + } +#endif + + ne2k_cbus_destroy(dev); + + return -ENODEV; +} + +static int __init ne_probe_cbus(struct net_device *dev, const struct ne2k_cbus_hwinfo *hw, int ioaddr) +{ + if (ei_debug > 2) + printk(KERN_DEBUG "ne_probe_cbus(): entered. (called from %p)\n", + __builtin_return_address(0)); + + if (hw && hw->hwtype) { + ne2k_cbus_set_hwtype(dev, hw, ioaddr); + return ne_probe1(dev, ioaddr); + } else { + /* auto detect */ + + printk(KERN_DEBUG "ne_probe_cbus(): try to determine hardware types.\n"); + for (hw = &ne2k_cbus_hwinfo_list[0]; hw->hwtype; hw++) { + ne2k_cbus_set_hwtype(dev, hw, ioaddr); + if (ne_probe1(dev, ioaddr) == 0) + return 0; + } + } + return -ENODEV; +} + +static int __init ne_probe1(struct net_device *dev, int ioaddr) +{ + int i; + unsigned char SA_prom[32]; + int wordlength = 2; + const char *name = NULL; + int start_page, stop_page; + int neX000, bad_card; + int reg0, ret; + static unsigned version_printed; + const struct ne2k_cbus_region *rlist; + const struct ne2k_cbus_hwinfo *hw = ne2k_cbus_get_hwinfo((int)(dev->mem_start & NE2K_CBUS_HARDWARE_TYPE_MASK)); + struct ei_device *ei_local = (struct ei_device *)(dev->priv); + +#ifdef CONFIG_NE2K_CBUS_CNET98EL + if (hw->hwtype == NE2K_CBUS_HARDWARE_TYPE_CNET98EL) { + outb_p(0, CONFIG_NE2K_CBUS_CNET98EL_IO_BASE); + /* udelay(5000); */ + outb_p(1, CONFIG_NE2K_CBUS_CNET98EL_IO_BASE); + /* udelay(5000); */ + outb_p((ioaddr & 0xf000) >> 8 | 0x08 | 0x01, CONFIG_NE2K_CBUS_CNET98EL_IO_BASE + 2); + /* udelay(5000); */ + } +#endif + + for (rlist = hw->regionlist; rlist->range; rlist++) + if (!request_region(ioaddr + rlist->start, + rlist->range, dev->name)) { + ret = -EBUSY; + goto err_out; + } + + reg0 = inb_p(ioaddr + EI_SHIFT(0)); + if (reg0 == 0xFF) { + ret = -ENODEV; + goto err_out; + } + + /* Do a preliminary verification that we have a 8390. */ +#ifdef CONFIG_NE2K_CBUS_CNET98EL + if (hw->hwtype != NE2K_CBUS_HARDWARE_TYPE_CNET98EL) +#endif + { + int regd; + outb_p(E8390_NODMA+E8390_PAGE1+E8390_STOP, ioaddr + E8390_CMD); + regd = inb_p(ioaddr + EI_SHIFT(0x0d)); + outb_p(0xff, ioaddr + EI_SHIFT(0x0d)); + outb_p(E8390_NODMA+E8390_PAGE0, ioaddr + E8390_CMD); + inb_p(ioaddr + EN0_COUNTER0); /* Clear the counter by reading. */ + if (inb_p(ioaddr + EN0_COUNTER0) != 0) { + outb_p(reg0, ioaddr); + outb_p(regd, ioaddr + EI_SHIFT(0x0d)); /* Restore the old values. */ + ret = -ENODEV; + goto err_out; + } + } + + if (ei_debug && version_printed++ == 0) + printk(KERN_INFO "%s" KERN_INFO "%s", version1, version2); + + printk(KERN_INFO "NE*000 ethercard probe at %#3x:", ioaddr); + + /* A user with a poor card that fails to ack the reset, or that + does not have a valid 0x57,0x57 signature can still use this + without having to recompile. Specifying an i/o address along + with an otherwise unused dev->mem_end value of "0xBAD" will + cause the driver to skip these parts of the probe. */ + + bad_card = ((dev->base_addr != 0) && (dev->mem_end == 0xbad)); + + /* Reset card. Who knows what dain-bramaged state it was left in. */ + + { + unsigned long reset_start_time = jiffies; + + /* derived from CNET98EL-patch for bad clones */ + outb_p(E8390_NODMA | E8390_STOP, ioaddr + E8390_CMD); + + /* DON'T change these to inb_p/outb_p or reset will fail on clones. */ + outb(inb(ioaddr + NE_RESET), ioaddr + NE_RESET); + + while ((inb_p(ioaddr + EN0_ISR) & ENISR_RESET) == 0) + if (jiffies - reset_start_time > 2*HZ/100) { + if (bad_card) { + printk(" (warning: no reset ack)"); + break; + } else { + printk(" not found (no reset ack).\n"); + ret = -ENODEV; + goto err_out; + } + } + + outb_p(0xff, ioaddr + EN0_ISR); /* Ack all intr. */ + } + +#ifdef CONFIG_NE2K_CBUS_CNET98EL + if (hw->hwtype == NE2K_CBUS_HARDWARE_TYPE_CNET98EL) { + static const char pat[32] ="AbcdeFghijKlmnoPqrstUvwxyZ789012"; + char buf[32]; + int maxwait = 200; + + if (ei_debug > 2) + printk(" [CNET98EL-specific initialize..."); + outb_p(E8390_NODMA | E8390_STOP, ioaddr + E8390_CMD); /* 0x20|0x1 */ + i = inb(ioaddr); + if ((i & ~0x2) != (0x20 | 0x01)) + return -ENODEV; + if ((inb(ioaddr + 0x7) & 0x80) != 0x80) + return -ENODEV; + outb_p(E8390_RXOFF, ioaddr + EN0_RXCR); /* out(ioaddr+0xc, 0x20) */ + /* outb_p(ENDCFG_WTS|ENDCFG_FT1|ENDCFG_LS, ioaddr+EN0_DCFG); */ + outb_p(ENDCFG_WTS | 0x48, ioaddr + EN0_DCFG); /* 0x49 */ + outb_p(CNET98EL_START_PG, ioaddr + EN0_STARTPG); + outb_p(CNET98EL_STOP_PG, ioaddr + EN0_STOPPG); + if (ei_debug > 2) + printk("memory check"); + for (i = 0; i < 65536; i += 1024) { + if (ei_debug > 2) + printk(" %04x", i); + ne2k_cbus_writemem(dev, ioaddr, i, pat, 32); + while (((inb(ioaddr + EN0_ISR) & ENISR_RDC) != ENISR_RDC) && --maxwait) + ; + ne2k_cbus_readmem(dev, ioaddr, i, buf, 32); + if (memcmp(pat, buf, 32)) { + if (ei_debug > 2) + printk(" failed."); + break; + } + } + if (i != 16384) { + if (ei_debug > 2) + printk("] "); + printk("memory failure at %x\n", i); + return -ENODEV; + } + if (ei_debug > 2) + printk(" good..."); + if (!dev->irq) { + if (ei_debug > 2) + printk("] "); + printk("IRQ must be specified for C-NET(98)E/L. probe failed.\n"); + return -ENODEV; + } + outb((dev->irq > 5) ? (dev->irq & 4):(dev->irq >> 1), ioaddr + (0x2 | 0x400)); + outb(0x7e, ioaddr + (0x4 | 0x400)); + ne2k_cbus_readmem(dev, ioaddr, 16384, SA_prom, 32); + outb(0xff, ioaddr + EN0_ISR); + if (ei_debug > 2) + printk("done]"); + } else +#endif /* CONFIG_NE2K_CBUS_CNET98EL */ + /* Read the 16 bytes of station address PROM. + We must first initialize registers, similar to NS8390_init(eifdev, 0). + We can't reliably read the SAPROM address without this. + (I learned the hard way!). */ + { + struct {unsigned char value; unsigned short offset;} program_seq[] = + { + {E8390_NODMA+E8390_PAGE0+E8390_STOP, E8390_CMD}, /* Select page 0*/ + /* NEC PC-9800: some board can only handle word-wide access? */ + {0x48 | ENDCFG_WTS, EN0_DCFG}, /* Set word-wide (0x48) access. */ + {16384 / 256, EN0_STARTPG}, + {32768 / 256, EN0_STOPPG}, + {0x00, EN0_RCNTLO}, /* Clear the count regs. */ + {0x00, EN0_RCNTHI}, + {0x00, EN0_IMR}, /* Mask completion irq. */ + {0xFF, EN0_ISR}, + {E8390_RXOFF, EN0_RXCR}, /* 0x20 Set to monitor */ + {E8390_TXOFF, EN0_TXCR}, /* 0x02 and loopback mode. */ + {32, EN0_RCNTLO}, + {0x00, EN0_RCNTHI}, + {0x00, EN0_RSARLO}, /* DMA starting at 0x0000. */ + {0x00, EN0_RSARHI}, + {E8390_RREAD+E8390_START, E8390_CMD}, + }; + + for (i = 0; i < sizeof(program_seq)/sizeof(program_seq[0]); i++) + outb_p(program_seq[i].value, ioaddr + program_seq[i].offset); + insw(ioaddr + NE_DATAPORT, SA_prom, 32 >> 1); + + } + + if (wordlength == 2) + { + for (i = 0; i < 16; i++) + SA_prom[i] = SA_prom[i+i]; + start_page = NESM_START_PG; + stop_page = NESM_STOP_PG; +#ifdef CONFIG_NE2K_CBUS_CNET98EL + if (hw->hwtype == NE2K_CBUS_HARDWARE_TYPE_CNET98EL) { + start_page = CNET98EL_START_PG; + stop_page = CNET98EL_STOP_PG; + } +#endif + } else { + start_page = NE1SM_START_PG; + stop_page = NE1SM_STOP_PG; + } + + neX000 = (SA_prom[14] == 0x57 && SA_prom[15] == 0x57); + if (neX000) { + name = "C-Bus-NE2K-compat"; + } + else + { +#ifdef SUPPORT_NE_BAD_CLONES + /* Ack! Well, there might be a *bad* NE*000 clone there. + Check for total bogus addresses. */ + for (i = 0; bad_clone_list[i].name8; i++) + { + if (SA_prom[0] == bad_clone_list[i].SAprefix[0] && + SA_prom[1] == bad_clone_list[i].SAprefix[1] && + SA_prom[2] == bad_clone_list[i].SAprefix[2]) + { + if (wordlength == 2) + { + name = bad_clone_list[i].name16; + } else { + name = bad_clone_list[i].name8; + } + break; + } + } + if (bad_clone_list[i].name8 == NULL) + { + printk(" not found (invalid signature %2.2x %2.2x).\n", + SA_prom[14], SA_prom[15]); + ret = -ENXIO; + goto err_out; + } +#else + printk(" not found.\n"); + ret = -ENXIO; + goto err_out; +#endif + } + + if (dev->irq < 2) + { + unsigned long cookie = probe_irq_on(); + outb_p(0x50, ioaddr + EN0_IMR); /* Enable one interrupt. */ + outb_p(0x00, ioaddr + EN0_RCNTLO); + outb_p(0x00, ioaddr + EN0_RCNTHI); + outb_p(E8390_RREAD+E8390_START, ioaddr); /* Trigger it... */ + mdelay(10); /* wait 10ms for interrupt to propagate */ + outb_p(0x00, ioaddr + EN0_IMR); /* Mask it again. */ + dev->irq = probe_irq_off(cookie); + if (ei_debug > 2) + printk(" autoirq is %d\n", dev->irq); + } else if (dev->irq == 7) + /* Fixup for users that don't know that IRQ 7 is really IRQ 11, + or don't know which one to set. */ + dev->irq = 11; + + if (! dev->irq) { + printk(" failed to detect IRQ line.\n"); + ret = -EAGAIN; + goto err_out; + } + + /* Allocate dev->priv and fill in 8390 specific dev fields. */ + if (ethdev_init(dev)) + { + printk (" unable to get memory for dev->priv.\n"); + ret = -ENOMEM; + goto err_out; + } + + /* Snarf the interrupt now. There's no point in waiting since we cannot + share and the board will usually be enabled. */ + ret = request_irq(dev->irq, ei_interrupt, 0, name, dev); + if (ret) { + printk (" unable to get IRQ %d (errno=%d).\n", dev->irq, ret); + goto err_out_kfree; + } + + dev->base_addr = ioaddr; + + for(i = 0; i < ETHER_ADDR_LEN; i++) { + printk(" %2.2x", SA_prom[i]); + dev->dev_addr[i] = SA_prom[i]; + } + + printk("\n%s: %s found at %#x, hardware type %d(%s), using IRQ %d.\n", + dev->name, name, ioaddr, hw->hwtype, hw->hwident, dev->irq); + + ei_status.name = name; + ei_status.tx_start_page = start_page; + ei_status.stop_page = stop_page; + ei_status.word16 = (wordlength == 2); + + ei_status.rx_start_page = start_page + TX_PAGES; +#ifdef PACKETBUF_MEMSIZE + /* Allow the packet buffer size to be overridden by know-it-alls. */ + ei_status.stop_page = ei_status.tx_start_page + PACKETBUF_MEMSIZE; +#endif + + ei_status.reset_8390 = &ne_reset_8390; + ei_status.block_input = &ne_block_input; + ei_status.block_output = &ne_block_output; + ei_status.get_8390_hdr = &ne_get_8390_hdr; + ei_status.priv = 0; + dev->open = &ne_open; + dev->stop = &ne_close; + NS8390_init(dev, 0); + return 0; + +err_out_kfree: + ne2k_cbus_destroy(dev); +err_out: + while (rlist > hw->regionlist) { + rlist --; + release_region(ioaddr + rlist->start, rlist->range); + } + return ret; +} + +static int ne_open(struct net_device *dev) +{ + ei_open(dev); + return 0; +} + +static int ne_close(struct net_device *dev) +{ + if (ei_debug > 1) + printk(KERN_DEBUG "%s: Shutting down ethercard.\n", dev->name); + ei_close(dev); + return 0; +} + +/* Hard reset the card. This used to pause for the same period that a + 8390 reset command required, but that shouldn't be necessary. */ + +static void ne_reset_8390(struct net_device *dev) +{ + unsigned long reset_start_time = jiffies; + struct ei_device *ei_local = (struct ei_device *)(dev->priv); + + if (ei_debug > 1) + printk(KERN_DEBUG "resetting the 8390 t=%ld...", jiffies); + + /* derived from CNET98EL-patch for bad clones... */ + outb_p(E8390_NODMA | E8390_STOP, NE_BASE + E8390_CMD); /* 0x20 | 0x1 */ + + /* DON'T change these to inb_p/outb_p or reset will fail on clones. */ + outb(inb(NE_BASE + NE_RESET), NE_BASE + NE_RESET); + + ei_status.txing = 0; + ei_status.dmaing = 0; + + /* This check _should_not_ be necessary, omit eventually. */ + while ((inb_p(NE_BASE+EN0_ISR) & ENISR_RESET) == 0) + if (jiffies - reset_start_time > 2*HZ/100) { + printk(KERN_WARNING "%s: ne_reset_8390() did not complete.\n", dev->name); + break; + } + outb_p(ENISR_RESET, NE_BASE + EN0_ISR); /* Ack intr. */ +} + +/* Grab the 8390 specific header. Similar to the block_input routine, but + we don't need to be concerned with ring wrap as the header will be at + the start of a page, so we optimize accordingly. */ + +static void ne_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_page) +{ + int nic_base = dev->base_addr; + struct ei_device *ei_local = (struct ei_device *)(dev->priv); + + /* This *shouldn't* happen. If it does, it's the last thing you'll see */ + + if (ei_status.dmaing) + { + printk(KERN_EMERG "%s: DMAing conflict in ne_get_8390_hdr " + "[DMAstat:%d][irqlock:%d].\n", + dev->name, ei_status.dmaing, ei_status.irqlock); + return; + } + + ei_status.dmaing |= 0x01; + outb_p(E8390_NODMA+E8390_PAGE0+E8390_START, nic_base+ NE_CMD); + outb_p(sizeof(struct e8390_pkt_hdr), nic_base + EN0_RCNTLO); + outb_p(0, nic_base + EN0_RCNTHI); + outb_p(0, nic_base + EN0_RSARLO); /* On page boundary */ + outb_p(ring_page, nic_base + EN0_RSARHI); + outb_p(E8390_RREAD+E8390_START, nic_base + NE_CMD); + + if (ei_status.word16) + insw(NE_BASE + NE_DATAPORT, hdr, sizeof(struct e8390_pkt_hdr)>>1); + else + insb(NE_BASE + NE_DATAPORT, hdr, sizeof(struct e8390_pkt_hdr)); + + outb_p(ENISR_RDC, nic_base + EN0_ISR); /* Ack intr. */ + ei_status.dmaing &= ~0x01; + + le16_to_cpus(&hdr->count); +} + +/* Block input and output, similar to the Crynwr packet driver. If you + are porting to a new ethercard, look at the packet driver source for hints. + The NEx000 doesn't share the on-board packet memory -- you have to put + the packet out through the "remote DMA" dataport using outb. */ + +static void ne_block_input(struct net_device *dev, int count, struct sk_buff *skb, int ring_offset) +{ +#ifdef NE_SANITY_CHECK + int xfer_count = count; +#endif + int nic_base = dev->base_addr; + char *buf = skb->data; + struct ei_device *ei_local = (struct ei_device *)(dev->priv); + + /* This *shouldn't* happen. If it does, it's the last thing you'll see */ + if (ei_status.dmaing) + { + printk(KERN_EMERG "%s: DMAing conflict in ne_block_input " + "[DMAstat:%d][irqlock:%d].\n", + dev->name, ei_status.dmaing, ei_status.irqlock); + return; + } + ei_status.dmaing |= 0x01; + + /* round up count to a word (derived from ICM-patch) */ + count = (count + 1) & ~1; + + outb_p(E8390_NODMA+E8390_PAGE0+E8390_START, nic_base+ NE_CMD); + outb_p(count & 0xff, nic_base + EN0_RCNTLO); + outb_p(count >> 8, nic_base + EN0_RCNTHI); + outb_p(ring_offset & 0xff, nic_base + EN0_RSARLO); + outb_p(ring_offset >> 8, nic_base + EN0_RSARHI); + outb_p(E8390_RREAD+E8390_START, nic_base + NE_CMD); + if (ei_status.word16) + { + insw(NE_BASE + NE_DATAPORT,buf,count>>1); + if (count & 0x01) + { + buf[count-1] = inb(NE_BASE + NE_DATAPORT); +#ifdef NE_SANITY_CHECK + xfer_count++; +#endif + } + } else { + insb(NE_BASE + NE_DATAPORT, buf, count); + } + +#ifdef NE_SANITY_CHECK + /* This was for the ALPHA version only, but enough people have + been encountering problems so it is still here. If you see + this message you either 1) have a slightly incompatible clone + or 2) have noise/speed problems with your bus. */ + + if (ei_debug > 1) + { + /* DMA termination address check... */ + int addr, tries = 20; + do { + /* DON'T check for 'inb_p(EN0_ISR) & ENISR_RDC' here + -- it's broken for Rx on some cards! */ + int high = inb_p(nic_base + EN0_RSARHI); + int low = inb_p(nic_base + EN0_RSARLO); + addr = (high << 8) + low; + if (((ring_offset + xfer_count) & 0xff) == low) + break; + } while (--tries > 0); + if (tries <= 0) + printk(KERN_WARNING "%s: RX transfer address mismatch," + "%#4.4x (expected) vs. %#4.4x (actual).\n", + dev->name, ring_offset + xfer_count, addr); + } +#endif + outb_p(ENISR_RDC, nic_base + EN0_ISR); /* Ack intr. */ + ei_status.dmaing &= ~0x01; +} + +static void ne_block_output(struct net_device *dev, int count, + const unsigned char *buf, const int start_page) +{ + int nic_base = NE_BASE; + unsigned long dma_start; +#ifdef NE_SANITY_CHECK + int retries = 0; +#endif + struct ei_device *ei_local = (struct ei_device *)(dev->priv); + + /* Round the count up for word writes. Do we need to do this? + What effect will an odd byte count have on the 8390? + I should check someday. */ + + if (ei_status.word16 && (count & 0x01)) + count++; + + /* This *shouldn't* happen. If it does, it's the last thing you'll see */ + if (ei_status.dmaing) + { + printk(KERN_EMERG "%s: DMAing conflict in ne_block_output." + "[DMAstat:%d][irqlock:%d]\n", + dev->name, ei_status.dmaing, ei_status.irqlock); + return; + } + ei_status.dmaing |= 0x01; + /* We should already be in page 0, but to be safe... */ + outb_p(E8390_PAGE0+E8390_START+E8390_NODMA, nic_base + NE_CMD); + +#ifdef NE_SANITY_CHECK +retry: +#endif + +#ifdef NE8390_RW_BUGFIX + /* Handle the read-before-write bug the same way as the + Crynwr packet driver -- the NatSemi method doesn't work. + Actually this doesn't always work either, but if you have + problems with your NEx000 this is better than nothing! */ + + outb_p(0x42, nic_base + EN0_RCNTLO); + outb_p(0x00, nic_base + EN0_RCNTHI); + outb_p(0x42, nic_base + EN0_RSARLO); + outb_p(0x00, nic_base + EN0_RSARHI); + outb_p(E8390_RREAD+E8390_START, nic_base + NE_CMD); + /* Make certain that the dummy read has occurred. */ + udelay(6); +#endif + + outb_p(ENISR_RDC, nic_base + EN0_ISR); + + /* Now the normal output. */ + outb_p(count & 0xff, nic_base + EN0_RCNTLO); + outb_p(count >> 8, nic_base + EN0_RCNTHI); + outb_p(0x00, nic_base + EN0_RSARLO); + outb_p(start_page, nic_base + EN0_RSARHI); + + outb_p(E8390_RWRITE+E8390_START, nic_base + NE_CMD); + if (ei_status.word16) { + outsw(NE_BASE + NE_DATAPORT, buf, count>>1); + } else { + outsb(NE_BASE + NE_DATAPORT, buf, count); + } + + dma_start = jiffies; + +#ifdef NE_SANITY_CHECK + /* This was for the ALPHA version only, but enough people have + been encountering problems so it is still here. */ + + if (ei_debug > 1) + { + /* DMA termination address check... */ + int addr, tries = 20; + do { + int high = inb_p(nic_base + EN0_RSARHI); + int low = inb_p(nic_base + EN0_RSARLO); + addr = (high << 8) + low; + if ((start_page << 8) + count == addr) + break; + } while (--tries > 0); + + if (tries <= 0) + { + printk(KERN_WARNING "%s: Tx packet transfer address mismatch," + "%#4.4x (expected) vs. %#4.4x (actual).\n", + dev->name, (start_page << 8) + count, addr); + if (retries++ == 0) + goto retry; + } + } +#endif + + while ((inb_p(nic_base + EN0_ISR) & ENISR_RDC) == 0) + if (jiffies - dma_start > 2*HZ/100) { /* 20ms */ + printk(KERN_WARNING "%s: timeout waiting for Tx RDC.\n", dev->name); + ne_reset_8390(dev); + NS8390_init(dev,1); + break; + } + + outb_p(ENISR_RDC, nic_base + EN0_ISR); /* Ack intr. */ + ei_status.dmaing &= ~0x01; + return; +} + + +#ifdef MODULE +#define MAX_NE_CARDS 4 /* Max number of NE cards per module */ +static struct net_device dev_ne[MAX_NE_CARDS]; +static int io[MAX_NE_CARDS]; +static int irq[MAX_NE_CARDS]; +static int bad[MAX_NE_CARDS]; /* 0xbad = bad sig or no reset ack */ +static int hwtype[MAX_NE_CARDS] = { 0, }; /* board type */ + +MODULE_PARM(io, "1-" __MODULE_STRING(MAX_NE_CARDS) "i"); +MODULE_PARM(irq, "1-" __MODULE_STRING(MAX_NE_CARDS) "i"); +MODULE_PARM(bad, "1-" __MODULE_STRING(MAX_NE_CARDS) "i"); +MODULE_PARM(hwtype, "1-" __MODULE_STRING(MAX_NE_CARDS) "i"); +MODULE_PARM_DESC(io, "I/O base address(es),required"); +MODULE_PARM_DESC(irq, "IRQ number(s)"); +MODULE_PARM_DESC(bad, "Accept card(s) with bad signatures"); +MODULE_PARM_DESC(hwtype, "Board type of PC-9800 C-Bus NIC"); +MODULE_DESCRIPTION("NE1000/NE2000 PC-9800 C-bus Ethernet driver"); +MODULE_LICENSE("GPL"); + +/* This is set up so that no ISA autoprobe takes place. We can't guarantee +that the ne2k probe is the last 8390 based probe to take place (as it +is at boot) and so the probe will get confused by any other 8390 cards. +ISA device autoprobes on a running machine are not recommended anyway. */ + +int init_module(void) +{ + int this_dev, found = 0; + + for (this_dev = 0; this_dev < MAX_NE_CARDS; this_dev++) { + struct net_device *dev = &dev_ne[this_dev]; + dev->irq = irq[this_dev]; + dev->mem_end = bad[this_dev]; + dev->base_addr = io[this_dev]; + dev->mem_start = hwtype[this_dev]; + dev->init = ne_probe; + if (register_netdev(dev) == 0) { + found++; + continue; + } + if (found != 0) { /* Got at least one. */ + return 0; + } + if (io[this_dev] != 0) + printk(KERN_WARNING "ne.c: No NE*000 card found at i/o = %#x\n", io[this_dev]); + else + printk(KERN_NOTICE "ne.c: You must supply \"io=0xNNN\" value(s) for C-Bus cards.\n"); + return -ENXIO; + } + return 0; +} + +void cleanup_module(void) +{ + int this_dev; + + for (this_dev = 0; this_dev < MAX_NE_CARDS; this_dev++) { + struct net_device *dev = &dev_ne[this_dev]; + if (dev->priv != NULL) { + const struct ne2k_cbus_region *rlist; + const struct ne2k_cbus_hwinfo *hw = ne2k_cbus_get_hwinfo((int)(dev->mem_start & NE2K_CBUS_HARDWARE_TYPE_MASK)); + + free_irq(dev->irq, dev); + for (rlist = hw->regionlist; rlist->range; rlist++) { + release_region(dev->base_addr + rlist->start, + rlist->range); + } + unregister_netdev(dev); + ne2k_cbus_destroy(dev); + } + } +} +#endif /* MODULE */ + + +/* + * Local variables: + * compile-command: "gcc -DKERNEL -Wall -O6 -fomit-frame-pointer -I/usr/src/linux/net/tcp -c ne.c" + * version-control: t + * kept-new-versions: 5 + * End: + */ diff -Nru a/drivers/net/ne2k_cbus.h b/drivers/net/ne2k_cbus.h --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/drivers/net/ne2k_cbus.h Sun Mar 23 00:22:57 2003 @@ -0,0 +1,481 @@ +/* ne2k_cbus.h: + vender-specific information definition for NEC PC-9800 + C-bus Ethernet Cards + Used in ne.c + + (C)1998,1999 KITAGWA Takurou & Linux/98 project +*/ + +#include + +#undef NE_RESET +#define NE_RESET EI_SHIFT(0x11) /* Issue a read to reset, a write to clear. */ + +#ifdef CONFIG_NE2K_CBUS_CNET98EL +#ifndef CONFIG_NE2K_CBUS_CNET98EL_IO_BASE +#warning CONFIG_NE2K_CBUS_CNET98EL_IO_BASE is not defined(config error?) +#warning use 0xaaed as default +#define CONFIG_NE2K_CBUS_CNET98EL_IO_BASE 0xaaed /* or 0x55ed */ +#endif +#define CNET98EL_START_PG 0x00 +#define CNET98EL_STOP_PG 0x40 +#endif + +/* Hardware type definition (derived from *BSD) */ +#define NE2K_CBUS_HARDWARE_TYPE_MASK 0xff + +/* 0: reserved for auto-detect */ +/* 1: (not tested) + Allied Telesis CentreCom LA-98-T */ +#define NE2K_CBUS_HARDWARE_TYPE_ATLA98 1 +/* 2: (not tested) + ELECOM Laneed + LD-BDN[123]A + PLANET SMART COM 98 EN-2298-C + MACNICA ME98 */ +#define NE2K_CBUS_HARDWARE_TYPE_BDN 2 +/* 3: + Melco EGY-98 + Contec C-NET(98)E*A/L*A,C-NET(98)P */ +#define NE2K_CBUS_HARDWARE_TYPE_EGY98 3 +/* 4: + Melco LGY-98,IND-SP,IND-SS + MACNICA NE2098 */ +#define NE2K_CBUS_HARDWARE_TYPE_LGY98 4 +/* 5: + ICM DT-ET-25,DT-ET-T5,IF-2766ET,IF-2771ET + PLANET SMART COM 98 EN-2298-T,EN-2298P-T + D-Link DE-298PT,DE-298PCAT + ELECOM Laneed LD-98P */ +#define NE2K_CBUS_HARDWARE_TYPE_ICM 5 +/* 6: (reserved for SIC-98, which is not supported in this driver.) */ +/* 7: (unused in *BSD?) + + +*/ +#define NE2K_CBUS_HARDWARE_TYPE_NE2K 7 +/* 8: + NEC PC-9801-108 */ +#define NE2K_CBUS_HARDWARE_TYPE_NEC108 8 +/* 9: + I-O DATA LA-98,LA/T-98 */ +#define NE2K_CBUS_HARDWARE_TYPE_IOLA98 9 +/* 10: (reserved for C-NET(98), which is not supported in this driver.) */ +/* 11: + Contec C-NET(98)E,L */ +#define NE2K_CBUS_HARDWARE_TYPE_CNET98EL 11 + +#define NE2K_CBUS_HARDWARE_TYPE_MAX 11 + +/* HARDWARE TYPE ID 12-31: reserved */ + +struct ne2k_cbus_offsetinfo { + unsigned short skip; + unsigned short offset8; /* +0x8 - +0xf */ + unsigned short offset10; /* +0x10 */ + unsigned short offset1f; /* +0x1f */ +}; + +struct ne2k_cbus_region { + unsigned short start; + short range; +}; + +struct ne2k_cbus_hwinfo { + const unsigned short hwtype; + const unsigned char *hwident; +#ifndef MODULE + const unsigned short *portlist; +#endif + const struct ne2k_cbus_offsetinfo *offsetinfo; + const struct ne2k_cbus_region *regionlist; +}; + +#ifdef CONFIG_NE2K_CBUS_ATLA98 +#ifndef MODULE +static unsigned short atla98_portlist[] __initdata = { + 0xd0, + 0 +}; +#endif +#define atla98_offsetinfo ne2k_offsetinfo +#define atla98_regionlist ne2k_regionlist +#endif /* CONFIG_NE2K_CBUS_ATLA98 */ + +#ifdef CONFIG_NE2K_CBUS_BDN +#ifndef MODULE +static unsigned short bdn_portlist[] __initdata = { + 0xd0, + 0 +}; +#endif +static struct ne2k_cbus_offsetinfo bdn_offsetinfo __initdata = { +#if 0 + /* comes from FreeBSD(98) ed98.h */ + 0x1000, 0x8000, 0x100, 0xc200 /* ??? */ +#else + /* comes from NetBSD/pc98 if_ne_isa.c */ + 0x1000, 0x8000, 0x100, 0x7f00 /* ??? */ +#endif +}; +static struct ne2k_cbus_region bdn_regionlist[] __initdata = { + {0x0, 1}, {0x1000, 1}, {0x2000, 1}, {0x3000,1}, + {0x4000, 1}, {0x5000, 1}, {0x6000, 1}, {0x7000, 1}, + {0x8000, 1}, {0x9000, 1}, {0xa000, 1}, {0xb000, 1}, + {0xc000, 1}, {0xd000, 1}, {0xe000, 1}, {0xf000, 1}, + {0x100, 1}, {0x7f00, 1}, + {0x0, 0} +}; +#endif /* CONFIG_NE2K_CBUS_BDN */ + +#ifdef CONFIG_NE2K_CBUS_EGY98 +#ifndef MODULE +static unsigned short egy98_portlist[] __initdata = { + 0xd0, + 0 +}; +#endif +static struct ne2k_cbus_offsetinfo egy98_offsetinfo __initdata = { + 0x02, 0x100, 0x200, 0x300 +}; +static struct ne2k_cbus_region egy98_regionlist[] __initdata = { + {0x0, 1}, {0x2, 1}, {0x4, 1}, {0x6, 1}, + {0x8, 1}, {0xa, 1}, {0xc, 1}, {0xe, 1}, + {0x100, 1}, {0x102, 1}, {0x104, 1}, {0x106, 1}, + {0x108, 1}, {0x10a, 1}, {0x10c, 1}, {0x10e, 1}, + {0x200, 1}, {0x300, 1}, + {0x0, 0} +}; +#endif /* CONFIG_NE2K_CBUS_EGY98 */ + +#ifdef CONFIG_NE2K_CBUS_LGY98 +#ifndef MODULE +static unsigned short lgy98_portlist[] __initdata = { + 0xd0, 0x10d0, 0x20d0, 0x30d0, 0x40d0, 0x50d0, 0x60d0, 0x70d0, + 0 +}; +#endif +static struct ne2k_cbus_offsetinfo lgy98_offsetinfo __initdata = { + 0x01, 0x08, 0x200, 0x300 +}; +static struct ne2k_cbus_region lgy98_regionlist[] __initdata = { + {0x0, 16}, {0x200, 1}, {0x300, 1}, + {0x0, 0} +}; +#endif /* CONFIG_NE2K_CBUS_LGY98 */ + +#ifdef CONFIG_NE2K_CBUS_ICM +#ifndef MODULE +static unsigned short icm_portlist[] __initdata = { + /* ICM */ + 0x56d0, + /* LD-98PT */ + 0x46d0, 0x66d0, 0x76d0, 0x86d0, 0x96d0, 0xa6d0, 0xb6d0, 0xc6d0, + 0 +}; +#endif +static struct ne2k_cbus_offsetinfo icm_offsetinfo __initdata = { + 0x01, 0x08, 0x100, 0x10f +}; +static struct ne2k_cbus_region icm_regionlist[] __initdata = { + {0x0, 16}, {0x100, 16}, + {0x0, 0} +}; +#endif /* CONFIG_NE2K_CBUS_ICM */ + +#if defined(CONFIG_NE2K_CBUS_NE2K) && !defined(MODULE) +static unsigned short ne2k_portlist[] __initdata = { + 0xd0, 0x300, 0x280, 0x320, 0x340, 0x360, 0x380, + 0 +}; +#endif +#if defined(CONFIG_NE2K_CBUS_NE2K) || defined(CONFIG_NE2K_CBUS_ATLA98) +static struct ne2k_cbus_offsetinfo ne2k_offsetinfo __initdata = { + 0x01, 0x08, 0x10, 0x1f +}; +static struct ne2k_cbus_region ne2k_regionlist[] __initdata = { + {0x0, 32}, + {0x0, 0} +}; +#endif + +#ifdef CONFIG_NE2K_CBUS_NEC108 +#ifndef MODULE +static unsigned short nec108_portlist[] __initdata = { + 0x770, 0x2770, 0x4770, 0x6770, + 0 +}; +#endif +static struct ne2k_cbus_offsetinfo nec108_offsetinfo __initdata = { + 0x02, 0x1000, 0x888, 0x88a +}; +static struct ne2k_cbus_region nec108_regionlist[] __initdata = { + {0x0, 1}, {0x2, 1}, {0x4, 1}, {0x6, 1}, + {0x8, 1}, {0xa, 1}, {0xc, 1}, {0xe, 1}, + {0x1000, 1}, {0x1002, 1}, {0x1004, 1}, {0x1006, 1}, + {0x1008, 1}, {0x100a, 1}, {0x100c, 1}, {0x100e, 1}, + {0x888, 1}, {0x88a, 1}, {0x88c, 1}, {0x88e, 1}, + {0x0, 0} +}; +#endif + +#ifdef CONFIG_NE2K_CBUS_IOLA98 +#ifndef MODULE +static unsigned short iola98_portlist[] __initdata = { + 0xd0, 0xd2, 0xd4, 0xd6, 0xd8, 0xda, 0xdc, 0xde, + 0 +}; +#endif +static struct ne2k_cbus_offsetinfo iola98_offsetinfo __initdata = { + 0x1000, 0x8000, 0x100, 0xf100 +}; +static struct ne2k_cbus_region iola98_regionlist[] __initdata = { + {0x0, 1}, {0x1000, 1}, {0x2000, 1}, {0x3000, 1}, + {0x4000, 1}, {0x5000, 1}, {0x6000, 1}, {0x7000, 1}, + {0x8000, 1}, {0x9000, 1}, {0xa000, 1}, {0xb000, 1}, + {0xc000, 1}, {0xd000, 1}, {0xe000, 1}, {0xf000, 1}, + {0x100, 1}, {0xf100, 1}, + {0x0,0} +}; +#endif /* CONFIG_NE2K_CBUS_IOLA98 */ + +#ifdef CONFIG_NE2K_CBUS_CNET98EL +#ifndef MODULE +static unsigned short cnet98el_portlist[] __initdata = { + 0x3d0, 0x13d0, 0x23d0, 0x33d0, 0x43d0, 0x53d0, 0x60d0, 0x70d0, + 0 +}; +#endif +static struct ne2k_cbus_offsetinfo cnet98el_offsetinfo __initdata = { + 0x01, 0x08, 0x40e, 0x400 +}; +static struct ne2k_cbus_region cnet98el_regionlist[] __initdata = { + {0x0, 16}, {0x400, 16}, + {0x0, 0} +}; +#endif + + +/* port information table (for ne.c initialize/probe process) */ + +static struct ne2k_cbus_hwinfo ne2k_cbus_hwinfo_list[] __initdata = { +#ifdef CONFIG_NE2K_CBUS_ATLA98 +/* NOT TESTED */ + { + NE2K_CBUS_HARDWARE_TYPE_ATLA98, + "LA-98-T", +#ifndef MODULE + atla98_portlist, +#endif + &atla98_offsetinfo, atla98_regionlist + }, +#endif +#ifdef CONFIG_NE2K_CBUS_BDN +/* NOT TESTED */ + { + NE2K_CBUS_HARDWARE_TYPE_BDN, + "LD-BDN[123]A", +#ifndef MODULE + bdn_portlist, +#endif + &bdn_offsetinfo, bdn_regionlist + }, +#endif +#ifdef CONFIG_NE2K_CBUS_ICM + { + NE2K_CBUS_HARDWARE_TYPE_ICM, + "IF-27xxET", +#ifndef MODULE + icm_portlist, +#endif + &icm_offsetinfo, icm_regionlist + }, +#endif +#ifdef CONFIG_NE2K_CBUS_NE2K + { + NE2K_CBUS_HARDWARE_TYPE_NE2K, + "NE2000 compat.", +#ifndef MODULE + ne2k_portlist, +#endif + &ne2k_offsetinfo, ne2k_regionlist + }, +#endif +#ifdef CONFIG_NE2K_CBUS_NEC108 + { + NE2K_CBUS_HARDWARE_TYPE_NEC108, + "PC-9801-108", +#ifndef MODULE + nec108_portlist, +#endif + &nec108_offsetinfo, nec108_regionlist + }, +#endif +#ifdef CONFIG_NE2K_CBUS_IOLA98 + { + NE2K_CBUS_HARDWARE_TYPE_IOLA98, + "LA-98", +#ifndef MODULE + iola98_portlist, +#endif + &iola98_offsetinfo, iola98_regionlist + }, +#endif +#ifdef CONFIG_NE2K_CBUS_CNET98EL + { + NE2K_CBUS_HARDWARE_TYPE_CNET98EL, + "C-NET(98)E/L", +#ifndef MODULE + cnet98el_portlist, +#endif + &cnet98el_offsetinfo, cnet98el_regionlist + }, +#endif +/* NOTE: LGY98 must be probed before EGY98, or system stalled!? */ +#ifdef CONFIG_NE2K_CBUS_LGY98 + { + NE2K_CBUS_HARDWARE_TYPE_LGY98, + "LGY-98", +#ifndef MODULE + lgy98_portlist, +#endif + &lgy98_offsetinfo, lgy98_regionlist + }, +#endif +#ifdef CONFIG_NE2K_CBUS_EGY98 + { + NE2K_CBUS_HARDWARE_TYPE_EGY98, + "EGY-98", +#ifndef MODULE + egy98_portlist, +#endif + &egy98_offsetinfo, egy98_regionlist + }, +#endif + { + 0, + "unsupported hardware", +#ifndef MODULE + NULL, +#endif + NULL, NULL + } +}; + +static int __init ne2k_cbus_init(struct net_device *dev) +{ + struct ei_device *ei_local; + if (dev->priv == NULL) { + ei_local = kmalloc(sizeof(struct ei_device), GFP_KERNEL); + if (ei_local == NULL) + return -ENOMEM; + memset(ei_local, 0, sizeof(struct ei_device)); + ei_local->reg_offset = kmalloc(sizeof(typeof(*ei_local->reg_offset))*18, GFP_KERNEL); + if (ei_local->reg_offset == NULL) { + kfree(ei_local); + return -ENOMEM; + } + spin_lock_init(&ei_local->page_lock); + dev->priv = ei_local; + } + return 0; +} + +static void ne2k_cbus_destroy(struct net_device *dev) +{ + struct ei_device *ei_local = (struct ei_device *)(dev->priv); + if (ei_local != NULL) { + if (ei_local->reg_offset) + kfree(ei_local->reg_offset); + kfree(dev->priv); + dev->priv = NULL; + } +} + +static const struct ne2k_cbus_hwinfo * __init ne2k_cbus_get_hwinfo(int hwtype) +{ + const struct ne2k_cbus_hwinfo *hw; + + for (hw = &ne2k_cbus_hwinfo_list[0]; hw->hwtype; hw++) { + if (hw->hwtype == hwtype) break; + } + return hw; +} + +static void __init ne2k_cbus_set_hwtype(struct net_device *dev, const struct ne2k_cbus_hwinfo *hw, int ioaddr) +{ + struct ei_device *ei_local = (struct ei_device *)(dev->priv); + int i; + int hwtype_old = dev->mem_start & NE2K_CBUS_HARDWARE_TYPE_MASK; + + if (!ei_local) + panic("Gieee! ei_local == NULL!! (from %p)", + __builtin_return_address(0)); + + dev->mem_start &= ~NE2K_CBUS_HARDWARE_TYPE_MASK; + dev->mem_start |= hw->hwtype & NE2K_CBUS_HARDWARE_TYPE_MASK; + + if (ei_debug > 2) { + printk(KERN_DEBUG "hwtype changed: %d -> %d\n",hwtype_old,(int)(dev->mem_start & NE2K_CBUS_HARDWARE_TYPE_MASK)); + } + + if (hw->offsetinfo) { + for (i = 0; i < 8; i++) { + ei_local->reg_offset[i] = hw->offsetinfo->skip * i; + } + for (i = 8; i < 16; i++) { + ei_local->reg_offset[i] = + hw->offsetinfo->skip*(i-8) + hw->offsetinfo->offset8; + } +#ifdef CONFIG_NE2K_CBUS_NEC108 + if (hw->hwtype == NE2K_CBUS_HARDWARE_TYPE_NEC108) { + int adj = (ioaddr & 0xf000) /2; + ei_local->reg_offset[16] = + (hw->offsetinfo->offset10 | adj) - ioaddr; + ei_local->reg_offset[17] = + (hw->offsetinfo->offset1f | adj) - ioaddr; + } else { +#endif /* CONFIG_NE2K_CBUS_NEC108 */ + ei_local->reg_offset[16] = hw->offsetinfo->offset10; + ei_local->reg_offset[17] = hw->offsetinfo->offset1f; +#ifdef CONFIG_NE2K_CBUS_NEC108 + } +#endif + } else { + /* make dummmy offset list */ + for (i = 0; i < 16; i++) { + ei_local->reg_offset[i] = i; + } + ei_local->reg_offset[16] = 0x10; + ei_local->reg_offset[17] = 0x1f; + } +} + +#if defined(CONFIG_NE2K_CBUS_ICM) || defined(CONFIG_NE2K_CBUS_CNET98EL) +static void __init ne2k_cbus_readmem(struct net_device *dev, int ioaddr, unsigned short memaddr, char *buf, unsigned short len) +{ + struct ei_device *ei_local = (struct ei_device *)(dev->priv); + outb_p(E8390_NODMA | E8390_START, ioaddr+E8390_CMD); + outb_p(len & 0xff, ioaddr+EN0_RCNTLO); + outb_p(len >> 8, ioaddr+EN0_RCNTHI); + outb_p(memaddr & 0xff, ioaddr+EN0_RSARLO); + outb_p(memaddr >> 8, ioaddr+EN0_RSARHI); + outb_p(E8390_RREAD | E8390_START, ioaddr+E8390_CMD); + insw(ioaddr+NE_DATAPORT, buf, len >> 1); +} +static void __init ne2k_cbus_writemem(struct net_device *dev, int ioaddr, unsigned short memaddr, const char *buf, unsigned short len) +{ + struct ei_device *ei_local = (struct ei_device *)(dev->priv); + outb_p(E8390_NODMA | E8390_START, ioaddr+E8390_CMD); + outb_p(ENISR_RDC, ioaddr+EN0_ISR); + outb_p(len & 0xff, ioaddr+EN0_RCNTLO); + outb_p(len >> 8, ioaddr+EN0_RCNTHI); + outb_p(memaddr & 0xff, ioaddr+EN0_RSARLO); + outb_p(memaddr >> 8, ioaddr+EN0_RSARHI); + outb_p(E8390_RWRITE | E8390_START, ioaddr+E8390_CMD); + outsw(ioaddr+NE_DATAPORT, buf, len >> 1); +} +#endif + +static int ne_probe_cbus(struct net_device *dev, const struct ne2k_cbus_hwinfo *hw, int ioaddr); +/* End of ne2k_cbus.h */ diff -Nru a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c --- a/drivers/net/pcmcia/pcnet_cs.c Sun Mar 23 00:22:55 2003 +++ b/drivers/net/pcmcia/pcnet_cs.c Sun Mar 23 00:22:55 2003 @@ -1617,6 +1617,15 @@ /*====================================================================*/ +static struct pcmcia_driver pcnet_driver = { + .drv = { + .name = "pcnet_cs", + }, + .attach = pcnet_attach, + .detach = pcnet_detach, + .owner = THIS_MODULE, +}; + static int __init init_pcnet_cs(void) { servinfo_t serv; @@ -1627,14 +1636,14 @@ "does not match!\n"); return -EINVAL; } - register_pccard_driver(&dev_info, &pcnet_attach, &pcnet_detach); + pcmcia_register_driver(&pcnet_driver); return 0; } static void __exit exit_pcnet_cs(void) { DEBUG(0, "pcnet_cs: unloading\n"); - unregister_pccard_driver(&dev_info); + pcmcia_unregister_driver(&pcnet_driver); while (dev_list != NULL) pcnet_detach(dev_list); } diff -Nru a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c --- a/drivers/net/ppp_generic.c Sun Mar 23 00:22:55 2003 +++ b/drivers/net/ppp_generic.c Sun Mar 23 00:22:55 2003 @@ -2214,6 +2214,11 @@ * and for initialization. */ +static void ppp_device_destructor(struct net_device *dev) +{ + kfree(dev); +} + /* * Create a new ppp interface unit. Fails if it can't allocate memory * or if there is already a unit with the requested number. @@ -2262,7 +2267,7 @@ dev->init = ppp_net_init; sprintf(dev->name, "ppp%d", unit); dev->priv = ppp; - dev->features |= NETIF_F_DYNALLOC; + dev->destructor = ppp_device_destructor; rtnl_lock(); ret = register_netdevice(dev); diff -Nru a/drivers/net/sk98lin/skvpd.c b/drivers/net/sk98lin/skvpd.c --- a/drivers/net/sk98lin/skvpd.c Sun Mar 23 00:22:53 2003 +++ b/drivers/net/sk98lin/skvpd.c Sun Mar 23 00:22:53 2003 @@ -121,7 +121,7 @@ ******************************************************************************/ /* - Please refer skvpd.txt for infomation how to include this module + Please refer skvpd.txt for information how to include this module */ static const char SysKonnectFileId[] = "@(#)$Id: skvpd.c,v 1.26 2000/06/13 08:00:01 mkarl Exp $ (C) SK" ; diff -Nru a/drivers/net/tg3.c b/drivers/net/tg3.c --- a/drivers/net/tg3.c Sun Mar 23 00:22:53 2003 +++ b/drivers/net/tg3.c Sun Mar 23 00:22:53 2003 @@ -55,8 +55,8 @@ #define DRV_MODULE_NAME "tg3" #define PFX DRV_MODULE_NAME ": " -#define DRV_MODULE_VERSION "1.4c" -#define DRV_MODULE_RELDATE "Feb 18, 2003" +#define DRV_MODULE_VERSION "1.5" +#define DRV_MODULE_RELDATE "March 21, 2003" #define TG3_DEF_MAC_MODE 0 #define TG3_DEF_RX_MODE 0 @@ -6581,11 +6581,11 @@ tw32(TG3PCI_DMA_RW_CTRL, tp->dma_rwctrl); + ret = 0; if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5700 && GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5701) - return 0; + goto out; - ret = 0; while (1) { u32 *p, i; diff -Nru a/drivers/net/tulip/winbond-840.c b/drivers/net/tulip/winbond-840.c --- a/drivers/net/tulip/winbond-840.c Sun Mar 23 00:22:51 2003 +++ b/drivers/net/tulip/winbond-840.c Sun Mar 23 00:22:51 2003 @@ -17,7 +17,7 @@ Support and updates available at http://www.scyld.com/network/drivers.html - Do not remove the copyright infomation. + Do not remove the copyright information. Do not change the version information unless an improvement has been made. Merely removing my name, as Compex has done in the past, does not count as an improvement. diff -Nru a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c --- a/drivers/net/wireless/airo.c Sun Mar 23 00:22:50 2003 +++ b/drivers/net/wireless/airo.c Sun Mar 23 00:22:50 2003 @@ -5894,6 +5894,7 @@ #endif /* WIRELESS_EXT */ #ifdef CISCO_EXT +#define RIDS_SIZE 2048 /* * This just translates from driver IOCTL codes to the command codes to * feed to the radio's host interface. Things can be added/deleted @@ -5902,11 +5903,15 @@ */ static int readrids(struct net_device *dev, aironet_ioctl *comp) { unsigned short ridcode; - unsigned char iobuf[2048]; + unsigned char *iobuf; struct airo_info *ai = dev->priv; + int ret = 0; if (ai->flags & FLAG_FLASHING) return -EIO; + iobuf = kmalloc(RIDS_SIZE, GFP_KERNEL); + if (!iobuf) + return -ENOMEM; switch(comp->command) { @@ -5919,13 +5924,17 @@ case AIROGEHTENC: ridcode = RID_ETHERENCAP; break; case AIROGWEPKTMP: ridcode = RID_WEP_TEMP; /* Only super-user can read WEP keys */ - if (!capable(CAP_NET_ADMIN)) - return -EPERM; + if (!capable(CAP_NET_ADMIN)) { + ret = -EPERM; + goto rr_free; + } break; case AIROGWEPKNV: ridcode = RID_WEP_PERM; /* Only super-user can read WEP keys */ - if (!capable(CAP_NET_ADMIN)) - return -EPERM; + if (!capable(CAP_NET_ADMIN)) { + ret = -EPERM; + goto rr_free; + } break; case AIROGSTAT: ridcode = RID_STATUS; break; case AIROGSTATSD32: ridcode = RID_STATSDELTA; break; @@ -5933,23 +5942,25 @@ case AIROGMICSTATS: if (copy_to_user(comp->data, &ai->micstats, min((int)comp->len,(int)sizeof(ai->micstats)))) - return -EFAULT; - return 0; + ret = -EFAULT; + goto rr_free; default: - return -EINVAL; - break; + ret = -EINVAL; + goto rr_free; } - PC4500_readrid(ai,ridcode,iobuf,sizeof(iobuf)); + PC4500_readrid(ai,ridcode,iobuf,RIDS_SIZE); /* get the count of bytes in the rid docs say 1st 2 bytes is it. * then return it to the user * 9/22/2000 Honor user given length */ if (copy_to_user(comp->data, iobuf, - min((int)comp->len, (int)sizeof(iobuf)))) - return -EFAULT; - return 0; + min((int)comp->len, (int)RIDS_SIZE))) + ret = -EFAULT; +rr_free: + kfree(iobuf); + return ret; } /* @@ -5961,7 +5972,8 @@ int ridcode, enabled; Resp rsp; static int (* writer)(struct airo_info *, u16 rid, const void *, int); - unsigned char iobuf[2048]; + unsigned char *iobuf; + int ret = 0; /* Only super-user can write RIDs */ if (!capable(CAP_NET_ADMIN)) @@ -5970,6 +5982,10 @@ if (ai->flags & FLAG_FLASHING) return -EIO; + iobuf = kmalloc(RIDS_SIZE, GFP_KERNEL); + if (!iobuf) + return -ENOMEM; + ridcode = 0; writer = do_writerid; @@ -5991,8 +6007,8 @@ */ case AIROPMACON: if (enable_MAC(ai, &rsp) != 0) - return -EIO; - return 0; + ret = -EIO; + goto wr_free; /* * Evidently this code in the airo driver does not get a symbol @@ -6000,32 +6016,38 @@ */ case AIROPMACOFF: disable_MAC(ai); - return 0; + goto wr_free; /* This command merely clears the counts does not actually store any data * only reads rid. But as it changes the cards state, I put it in the * writerid routines. */ case AIROPSTCLR: - PC4500_readrid(ai,RID_STATSDELTACLEAR,iobuf,sizeof(iobuf)); + PC4500_readrid(ai,RID_STATSDELTACLEAR,iobuf,RIDS_SIZE); enabled = ai->micstats.enabled; memset(&ai->micstats,0,sizeof(ai->micstats)); ai->micstats.enabled = enabled; if (copy_to_user(comp->data, iobuf, - min((int)comp->len, (int)sizeof(iobuf)))) - return -EFAULT; - return 0; + min((int)comp->len, (int)RIDS_SIZE))) + ret = -EFAULT; + goto wr_free; default: - return -EOPNOTSUPP; /* Blarg! */ + ret = -EOPNOTSUPP; /* Blarg! */ + goto wr_free; + } + + if (comp->len > RIDS_SIZE) { + ret = -EINVAL; + goto wr_free; } - if(comp->len > sizeof(iobuf)) - return -EINVAL; - if (copy_from_user(iobuf,comp->data,comp->len)) - return -EFAULT; + if (copy_from_user(iobuf,comp->data,comp->len)) { + ret = -EFAULT; + goto wr_free; + } if (comp->command == AIROPCFG) { ConfigRid *cfg = (ConfigRid *)iobuf; @@ -6040,8 +6062,10 @@ } if((*writer)(ai, ridcode, iobuf,comp->len)) - return -EIO; - return 0; + ret = -EIO; +wr_free: + kfree(iobuf); + return ret; } /***************************************************************************** diff -Nru a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c --- a/drivers/oprofile/buffer_sync.c Sun Mar 23 00:22:51 2003 +++ b/drivers/oprofile/buffer_sync.c Sun Mar 23 00:22:51 2003 @@ -82,9 +82,16 @@ int sync_start(void) { - int err = profile_event_register(EXIT_TASK, &exit_task_nb); + int err; + + init_timer(&sync_timer); + sync_timer.function = timer_ping; + sync_timer.expires = jiffies + DEFAULT_EXPIRE; + add_timer(&sync_timer); + + err = profile_event_register(EXIT_TASK, &exit_task_nb); if (err) - goto out; + goto out1; err = profile_event_register(EXIT_MMAP, &exit_mmap_nb); if (err) goto out2; @@ -92,16 +99,14 @@ if (err) goto out3; - init_timer(&sync_timer); - sync_timer.function = timer_ping; - sync_timer.expires = jiffies + DEFAULT_EXPIRE; - add_timer(&sync_timer); out: return err; out3: profile_event_unregister(EXIT_MMAP, &exit_mmap_nb); out2: profile_event_unregister(EXIT_TASK, &exit_task_nb); +out1: + del_timer_sync(&sync_timer); goto out; } diff -Nru a/drivers/parport/init.c b/drivers/parport/init.c --- a/drivers/parport/init.c Sun Mar 23 00:22:53 2003 +++ b/drivers/parport/init.c Sun Mar 23 00:22:53 2003 @@ -227,17 +227,3 @@ EXPORT_SYMBOL(parport_find_device); EXPORT_SYMBOL(parport_find_class); #endif - -void inc_parport_count(void) -{ -#ifdef MODULE - MOD_INC_USE_COUNT; -#endif -} - -void dec_parport_count(void) -{ -#ifdef MODULE - MOD_DEC_USE_COUNT; -#endif -} diff -Nru a/drivers/parport/parport_amiga.c b/drivers/parport/parport_amiga.c --- a/drivers/parport/parport_amiga.c Sun Mar 23 00:22:54 2003 +++ b/drivers/parport/parport_amiga.c Sun Mar 23 00:22:54 2003 @@ -195,51 +195,40 @@ mb(); } -static void amiga_inc_use_count(void) -{ - MOD_INC_USE_COUNT; -} - -static void amiga_dec_use_count(void) -{ - MOD_DEC_USE_COUNT; -} - static struct parport_operations pp_amiga_ops = { - amiga_write_data, - amiga_read_data, + .write_data = amiga_write_data, + .read_data = amiga_read_data, - amiga_write_control, - amiga_read_control, - amiga_frob_control, + .write_control = amiga_write_control, + .read_control = amiga_read_control, + .frob_control = amiga_frob_control, - amiga_read_status, + .read_status = amiga_read_status, - amiga_enable_irq, - amiga_disable_irq, + .enable_irq = amiga_enable_irq, + .disable_irq = amiga_disable_irq, - amiga_data_forward, - amiga_data_reverse, + .data_forward = amiga_data_forward, + .data_reverse = amiga_data_reverse, - amiga_init_state, - amiga_save_state, - amiga_restore_state, + .init_state = amiga_init_state, + .save_state = amiga_save_state, + .restore_state = amiga_restore_state, - amiga_inc_use_count, - amiga_dec_use_count, + .epp_write_data = parport_ieee1284_epp_write_data, + .epp_read_data = parport_ieee1284_epp_read_data, + .epp_write_addr = parport_ieee1284_epp_write_addr, + .epp_read_addr = parport_ieee1284_epp_read_addr, - parport_ieee1284_epp_write_data, - parport_ieee1284_epp_read_data, - parport_ieee1284_epp_write_addr, - parport_ieee1284_epp_read_addr, + .ecp_write_data = parport_ieee1284_ecp_write_data, + .ecp_read_data = parport_ieee1284_ecp_read_data, + .ecp_write_addr = parport_ieee1284_ecp_write_addr, - parport_ieee1284_ecp_write_data, - parport_ieee1284_ecp_read_data, - parport_ieee1284_ecp_write_addr, + .compat_write_data = parport_ieee1284_write_compat, + .nibble_read_data = parport_ieee1284_read_nibble, + .byte_read_data = parport_ieee1284_read_byte, - parport_ieee1284_write_compat, - parport_ieee1284_read_nibble, - parport_ieee1284_read_byte, + .owner = THIS_MODULE, }; /* ----------- Initialisation code --------------------------------- */ diff -Nru a/drivers/parport/parport_arc.c b/drivers/parport/parport_arc.c --- a/drivers/parport/parport_arc.c Sun Mar 23 00:22:49 2003 +++ b/drivers/parport/parport_arc.c Sun Mar 23 00:22:49 2003 @@ -65,56 +65,41 @@ return data_copy; } -static void arc_inc_use_count(void) -{ -#ifdef MODULE - MOD_INC_USE_COUNT; -#endif -} - -static void arc_dec_use_count(void) -{ -#ifdef MODULE - MOD_DEC_USE_COUNT; -#endif -} - static struct parport_operations parport_arc_ops = { - arc_write_data, - arc_read_data, - - arc_write_control, - arc_read_control, - arc_frob_control, + .write_data = arc_write_data, + .read_data = arc_read_data, - arc_read_status, + .write_control = arc_write_control, + .read_control = arc_read_control, + .frob_control = arc_frob_control, - arc_enable_irq, - arc_disable_irq, + .read_status = arc_read_status, - arc_data_forward, - arc_data_reverse, + .enable_irq = arc_enable_irq, + .disable_irq = arc_disable_irq, - arc_init_state, - arc_save_state, - arc_restore_state, + .data_forward = arc_data_forward, + .data_reverse = arc_data_reverse, - arc_inc_use_count, - arc_dec_use_count, + .init_state = arc_init_state, + .save_state = arc_save_state, + .restore_state = arc_restore_state, - parport_ieee1284_epp_write_data, - parport_ieee1284_epp_read_data, - parport_ieee1284_epp_write_addr, - parport_ieee1284_epp_read_addr, + .epp_write_data = parport_ieee1284_epp_write_data, + .epp_read_data = parport_ieee1284_epp_read_data, + .epp_write_addr = parport_ieee1284_epp_write_addr, + .epp_read_addr = parport_ieee1284_epp_read_addr, - parport_ieee1284_ecp_write_data, - parport_ieee1284_ecp_read_data, - parport_ieee1284_ecp_write_addr, + .ecp_write_data = parport_ieee1284_ecp_write_data, + .ecp_read_data = parport_ieee1284_ecp_read_data, + .ecp_write_addr = parport_ieee1284_ecp_write_addr, - parport_ieee1284_write_compat, - parport_ieee1284_read_nibble, - parport_ieee1284_read_byte, + .compat_write_data = parport_ieee1284_write_compat, + .nibble_read_data = parport_ieee1284_read_nibble, + .byte_read_data = parport_ieee1284_read_byte, + + .owner = THIS_MODULE, }; /* --- Initialisation code -------------------------------- */ @@ -123,18 +108,24 @@ { /* Archimedes hardware provides only one port, at a fixed address */ struct parport *p; + struct resource res; + char *fake_name = "parport probe"); - if (check_region(PORT_BASE, 1)) + res = request_region(PORT_BASE, 1, fake_name); + if (res == NULL) return 0; p = parport_register_port (PORT_BASE, IRQ_PRINTERACK, PARPORT_DMA_NONE, &parport_arc_ops); - if (!p) + if (!p) { + release_region(PORT_BASE, 1); return 0; + } p->modes = PARPORT_MODE_ARCSPP; p->size = 1; + rename_region(res, p->name); printk(KERN_INFO "%s: Archimedes on-board port, using irq %d\n", p->irq); diff -Nru a/drivers/parport/parport_atari.c b/drivers/parport/parport_atari.c --- a/drivers/parport/parport_atari.c Sun Mar 23 00:22:51 2003 +++ b/drivers/parport/parport_atari.c Sun Mar 23 00:22:51 2003 @@ -147,53 +147,40 @@ #endif } -static void -parport_atari_inc_use_count(void) -{ - MOD_INC_USE_COUNT; -} - -static void -parport_atari_dec_use_count(void) -{ - MOD_DEC_USE_COUNT; -} - static struct parport_operations parport_atari_ops = { - parport_atari_write_data, - parport_atari_read_data, + .write_data = parport_atari_write_data, + .read_data = parport_atari_read_data, - parport_atari_write_control, - parport_atari_read_control, - parport_atari_frob_control, + .write_control = parport_atari_write_control, + .read_control = parport_atari_read_control, + .frob_control = parport_atari_frob_control, - parport_atari_read_status, + .read_status = parport_atari_read_status, - parport_atari_enable_irq, - parport_atari_disable_irq, + .enable_irq = parport_atari_enable_irq, + .disable_irq = parport_atari_disable_irq, - parport_atari_data_forward, - parport_atari_data_reverse, + .data_forward = parport_atari_data_forward, + .data_reverse = parport_atari_data_reverse, - parport_atari_init_state, - parport_atari_save_state, - parport_atari_restore_state, + .init_state = parport_atari_init_state, + .save_state = parport_atari_save_state, + .restore_state = parport_atari_restore_state, - parport_atari_inc_use_count, - parport_atari_dec_use_count, + .epp_write_data = parport_ieee1284_epp_write_data, + .epp_read_data = parport_ieee1284_epp_read_data, + .epp_write_addr = parport_ieee1284_epp_write_addr, + .epp_read_addr = parport_ieee1284_epp_read_addr, - parport_ieee1284_epp_write_data, - parport_ieee1284_epp_read_data, - parport_ieee1284_epp_write_addr, - parport_ieee1284_epp_read_addr, + .ecp_write_data = parport_ieee1284_ecp_write_data, + .ecp_read_data = parport_ieee1284_ecp_read_data, + .ecp_write_addr = parport_ieee1284_ecp_write_addr, - parport_ieee1284_ecp_write_data, - parport_ieee1284_ecp_read_data, - parport_ieee1284_ecp_write_addr, + .compat_write_data = parport_ieee1284_write_compat, + .nibble_read_data = parport_ieee1284_read_nibble, + .byte_read_data = parport_ieee1284_read_byte, - parport_ieee1284_write_compat, - parport_ieee1284_read_nibble, - parport_ieee1284_read_byte, + .owner = THIS_MODULE, }; diff -Nru a/drivers/parport/parport_gsc.c b/drivers/parport/parport_gsc.c --- a/drivers/parport/parport_gsc.c Sun Mar 23 00:22:55 2003 +++ b/drivers/parport/parport_gsc.c Sun Mar 23 00:22:55 2003 @@ -190,17 +190,6 @@ parport_writeb (s->u.pc.ctr, CONTROL (p)); } -void parport_gsc_inc_use_count(void) -{ - MOD_INC_USE_COUNT; -} - -void parport_gsc_dec_use_count(void) -{ - MOD_DEC_USE_COUNT; -} - - struct parport_operations parport_gsc_ops = { .write_data = parport_gsc_write_data, @@ -222,9 +211,6 @@ .save_state = parport_gsc_save_state, .restore_state = parport_gsc_restore_state, - .inc_use_count = parport_gsc_inc_use_count, - .dec_use_count = parport_gsc_dec_use_count, - .epp_write_data = parport_ieee1284_epp_write_data, .epp_read_data = parport_ieee1284_epp_read_data, .epp_write_addr = parport_ieee1284_epp_write_addr, @@ -237,6 +223,8 @@ .compat_write_data = parport_ieee1284_write_compat, .nibble_read_data = parport_ieee1284_read_nibble, .byte_read_data = parport_ieee1284_read_byte, + + .owner = THIS_MODULE, }; /* --- Mode detection ------------------------------------- */ diff -Nru a/drivers/parport/parport_mfc3.c b/drivers/parport/parport_mfc3.c --- a/drivers/parport/parport_mfc3.c Sun Mar 23 00:22:52 2003 +++ b/drivers/parport/parport_mfc3.c Sun Mar 23 00:22:52 2003 @@ -281,51 +281,40 @@ pia(p)->cra |= PIA_DDR; } -static void mfc3_inc_use_count(void) -{ - MOD_INC_USE_COUNT; -} - -static void mfc3_dec_use_count(void) -{ - MOD_DEC_USE_COUNT; -} - static struct parport_operations pp_mfc3_ops = { - mfc3_write_data, - mfc3_read_data, + .write_data = mfc3_write_data, + .read_data = mfc3_read_data, - mfc3_write_control, - mfc3_read_control, - mfc3_frob_control, + .write_control = mfc3_write_control, + .read_control = mfc3_read_control, + .frob_control = mfc3_frob_control, - mfc3_read_status, + .read_status = mfc3_read_status, - mfc3_enable_irq, - mfc3_disable_irq, + .enable_irq = mfc3_enable_irq, + .disable_irq = mfc3_disable_irq, - mfc3_data_forward, - mfc3_data_reverse, + .data_forward = mfc3_data_forward, + .data_reverse = mfc3_data_reverse, - mfc3_init_state, - mfc3_save_state, - mfc3_restore_state, + .init_state = mfc3_init_state, + .save_state = mfc3_save_state, + .restore_state = mfc3_restore_state, - mfc3_inc_use_count, - mfc3_dec_use_count, + .epp_write_data = parport_ieee1284_epp_write_data, + .epp_read_data = parport_ieee1284_epp_read_data, + .epp_write_addr = parport_ieee1284_epp_write_addr, + .epp_read_addr = parport_ieee1284_epp_read_addr, - parport_ieee1284_epp_write_data, - parport_ieee1284_epp_read_data, - parport_ieee1284_epp_write_addr, - parport_ieee1284_epp_read_addr, + .ecp_write_data = parport_ieee1284_ecp_write_data, + .ecp_read_data = parport_ieee1284_ecp_read_data, + .ecp_write_addr = parport_ieee1284_ecp_write_addr, - parport_ieee1284_ecp_write_data, - parport_ieee1284_ecp_read_data, - parport_ieee1284_ecp_write_addr, + .compat_write_data = parport_ieee1284_write_compat, + .nibble_read_data = parport_ieee1284_read_nibble, + .byte_read_data = parport_ieee1284_read_byte, - parport_ieee1284_write_compat, - parport_ieee1284_read_nibble, - parport_ieee1284_read_byte, + .owner = THIS_MODULE, }; /* ----------- Initialisation code --------------------------------- */ diff -Nru a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c --- a/drivers/parport/parport_pc.c Sun Mar 23 00:22:56 2003 +++ b/drivers/parport/parport_pc.c Sun Mar 23 00:22:56 2003 @@ -1232,57 +1232,41 @@ * ****************************************** */ - -void parport_pc_inc_use_count(void) -{ -#ifdef MODULE - MOD_INC_USE_COUNT; -#endif -} - -void parport_pc_dec_use_count(void) -{ -#ifdef MODULE - MOD_DEC_USE_COUNT; -#endif -} - struct parport_operations parport_pc_ops = { - parport_pc_write_data, - parport_pc_read_data, + .write_data = parport_pc_write_data, + .read_data = parport_pc_read_data, - parport_pc_write_control, - parport_pc_read_control, - parport_pc_frob_control, + .write_control = parport_pc_write_control, + .read_control = parport_pc_read_control, + .frob_control = parport_pc_frob_control, - parport_pc_read_status, + .read_status = parport_pc_read_status, - parport_pc_enable_irq, - parport_pc_disable_irq, + .enable_irq = parport_pc_enable_irq, + .disable_irq = parport_pc_disable_irq, - parport_pc_data_forward, - parport_pc_data_reverse, + .data_forward = parport_pc_data_forward, + .data_reverse = parport_pc_data_reverse, - parport_pc_init_state, - parport_pc_save_state, - parport_pc_restore_state, + .init_state = parport_pc_init_state, + .save_state = parport_pc_save_state, + .restore_state = parport_pc_restore_state, - parport_pc_inc_use_count, - parport_pc_dec_use_count, + .epp_write_data = parport_ieee1284_epp_write_data, + .epp_read_data = parport_ieee1284_epp_read_data, + .epp_write_addr = parport_ieee1284_epp_write_addr, + .epp_read_addr = parport_ieee1284_epp_read_addr, - parport_ieee1284_epp_write_data, - parport_ieee1284_epp_read_data, - parport_ieee1284_epp_write_addr, - parport_ieee1284_epp_read_addr, + .ecp_write_data = parport_ieee1284_ecp_write_data, + .ecp_read_data = parport_ieee1284_ecp_read_data, + .ecp_write_addr = parport_ieee1284_ecp_write_addr, - parport_ieee1284_ecp_write_data, - parport_ieee1284_ecp_read_data, - parport_ieee1284_ecp_write_addr, + .compat_write_data = parport_ieee1284_write_compat, + .nibble_read_data = parport_ieee1284_read_nibble, + .byte_read_data = parport_ieee1284_read_byte, - parport_ieee1284_write_compat, - parport_ieee1284_read_nibble, - parport_ieee1284_read_byte, + .owner = THIS_MODULE, }; #ifdef CONFIG_PARPORT_PC_SUPERIO @@ -2212,16 +2196,32 @@ struct parport tmp; struct parport *p = &tmp; int probedirq = PARPORT_IRQ_NONE; - if (check_region(base, 3)) return NULL; + struct resource *base_res; + struct resource *ECR_res = NULL; + struct resource *EPP_res = NULL; + char *fake_name = "parport probe"; + + /* + * Chicken and Egg problem. request_region() wants the name of + * the owner, but this instance will not know that name until + * after the parport_register_port() call. Give request_region() + * a fake name until after parport_register_port(), then use + * rename_region() to set correct name. + */ + base_res = request_region(base, 3, fake_name); + if (base_res == NULL) + return NULL; priv = kmalloc (sizeof (struct parport_pc_private), GFP_KERNEL); if (!priv) { printk (KERN_DEBUG "parport (0x%lx): no memory!\n", base); + release_region(base, 3); return NULL; } ops = kmalloc (sizeof (struct parport_operations), GFP_KERNEL); if (!ops) { printk (KERN_DEBUG "parport (0x%lx): no memory for ops!\n", base); + release_region(base, 3); kfree (priv); return NULL; } @@ -2242,32 +2242,39 @@ p->private_data = priv; p->physport = p; - if (base_hi && !check_region(base_hi,3)) - parport_ECR_present(p); + if (base_hi) { + ECR_res = request_region(base_hi, 3, fake_name); + if (ECR_res) + parport_ECR_present(p); + } if (base != 0x3bc) { - if (!check_region(base+0x3, 5)) { + EPP_res = request_region(base+0x3, 5, fake_name); + if (EPP_res) if (!parport_EPP_supported(p)) parport_ECPEPP_supported(p); - } } - if (!parport_SPP_supported (p)) { + if (!parport_SPP_supported (p)) /* No port. */ - kfree (priv); - kfree (ops); - return NULL; - } + goto errout; if (priv->ecr) parport_ECPPS2_supported(p); else parport_PS2_supported (p); if (!(p = parport_register_port(base, PARPORT_IRQ_NONE, - PARPORT_DMA_NONE, ops))) { - kfree (priv); - kfree (ops); - return NULL; - } + PARPORT_DMA_NONE, ops))) + goto errout; + + /* + * Now the real name is known... Replace the fake name + * in the resources with the correct one. + */ + rename_region(base_res, p->name); + if (ECR_res) + rename_region(ECR_res, p->name); + if (EPP_res) + rename_region(EPP_res, p->name); p->base_hi = base_hi; p->modes = tmp.modes; @@ -2343,11 +2350,11 @@ printk(KERN_INFO "%s: irq %d detected\n", p->name, probedirq); parport_proc_register(p); - request_region (p->base, 3, p->name); - if (p->size > 3) - request_region (p->base + 3, p->size - 3, p->name); - if (p->modes & PARPORT_MODE_ECP) - request_region (p->base_hi, 3, p->name); + /* If No ECP release the ports grabbed above. */ + if (ECR_res && (p->modes & PARPORT_MODE_ECP) == 0) { + release_region(base_hi, 3); + ECR_res = NULL; + } if (p->irq != PARPORT_IRQ_NONE) { if (request_irq (p->irq, parport_pc_interrupt, @@ -2401,6 +2408,17 @@ parport_announce_port (p); return p; + +errout: + release_region(p->base, 3); + if (ECR_res) + release_region(base_hi, 3); + if (EPP_res) + release_region(base+0x3, 5); + + kfree (priv); + kfree (ops); + return NULL; } void parport_pc_unregister_port (struct parport *p) @@ -2437,9 +2455,11 @@ int autodma) { short inta_addr[6] = { 0x2A0, 0x2C0, 0x220, 0x240, 0x1E0 }; + struct resource *base_res; u32 ite8872set; u32 ite8872_lpt, ite8872_lpthi; u8 ite8872_irq, type; + char *fake_name = "parport probe"; int irq; int i; @@ -2447,7 +2467,8 @@ // make sure which one chip for(i = 0; i < 5; i++) { - if (check_region (inta_addr[i], 0x8) >= 0) { + base_res = request_region(inta_addr[i], 0x8, fake_name); + if (base_res) { int test; pci_write_config_dword (pdev, 0x60, 0xe7000000 | inta_addr[i]); @@ -2455,6 +2476,7 @@ 0x00000000 | inta_addr[i]); test = inb (inta_addr[i]); if (test != 0xff) break; + release_region(inta_addr[i], 0x8); } } if(i >= 5) { @@ -2515,6 +2537,10 @@ if (autoirq != PARPORT_IRQ_AUTO) irq = PARPORT_IRQ_NONE; + /* + * Release the resource so that parport_pc_probe_port can get it. + */ + release_resource(base_res); if (parport_pc_probe_port (ite8872_lpt, ite8872_lpthi, irq, PARPORT_DMA_NONE, NULL)) { printk (KERN_INFO diff -Nru a/drivers/parport/parport_sunbpp.c b/drivers/parport/parport_sunbpp.c --- a/drivers/parport/parport_sunbpp.c Sun Mar 23 00:22:50 2003 +++ b/drivers/parport/parport_sunbpp.c Sun Mar 23 00:22:50 2003 @@ -249,56 +249,41 @@ parport_sunbpp_write_control(p, s->u.pc.ctr); } -static void parport_sunbpp_inc_use_count(void) -{ -#ifdef MODULE - MOD_INC_USE_COUNT; -#endif -} - -static void parport_sunbpp_dec_use_count(void) -{ -#ifdef MODULE - MOD_DEC_USE_COUNT; -#endif -} - static struct parport_operations parport_sunbpp_ops = { - parport_sunbpp_write_data, - parport_sunbpp_read_data, + .write_data = parport_sunbpp_write_data, + .read_data = parport_sunbpp_read_data, - parport_sunbpp_write_control, - parport_sunbpp_read_control, - parport_sunbpp_frob_control, + .write_control = parport_sunbpp_write_control, + .read_control = parport_sunbpp_read_control, + .frob_control = parport_sunbpp_frob_control, - parport_sunbpp_read_status, + .read_status = parport_sunbpp_read_status, - parport_sunbpp_enable_irq, - parport_sunbpp_disable_irq, + .enable_irq = parport_sunbpp_enable_irq, + .disable_irq = parport_sunbpp_disable_irq, - parport_sunbpp_data_forward, - parport_sunbpp_data_reverse, + .data_forward = parport_sunbpp_data_forward, + .data_reverse = parport_sunbpp_data_reverse, - parport_sunbpp_init_state, - parport_sunbpp_save_state, - parport_sunbpp_restore_state, + .init_state = parport_sunbpp_init_state, + .save_state = parport_sunbpp_save_state, + .restore_state = parport_sunbpp_restore_state, - parport_sunbpp_inc_use_count, - parport_sunbpp_dec_use_count, + .epp_write_data = parport_ieee1284_epp_write_data, + .epp_read_data = parport_ieee1284_epp_read_data, + .epp_write_addr = parport_ieee1284_epp_write_addr, + .epp_read_addr = parport_ieee1284_epp_read_addr, - parport_ieee1284_epp_write_data, - parport_ieee1284_epp_read_data, - parport_ieee1284_epp_write_addr, - parport_ieee1284_epp_read_addr, + .ecp_write_data = parport_ieee1284_ecp_write_data, + .ecp_read_data = parport_ieee1284_ecp_read_data, + .ecp_write_addr = parport_ieee1284_ecp_write_addr, - parport_ieee1284_ecp_write_data, - parport_ieee1284_ecp_read_data, - parport_ieee1284_ecp_write_addr, + .compat_write_data = parport_ieee1284_write_compat, + .nibble_read_data = parport_ieee1284_read_nibble, + .byte_read_data = parport_ieee1284_read_byte, - parport_ieee1284_write_compat, - parport_ieee1284_read_nibble, - parport_ieee1284_read_byte, + .owner = THIS_MODULE, }; static int __init init_one_port(struct sbus_dev *sdev) diff -Nru a/drivers/parport/share.c b/drivers/parport/share.c --- a/drivers/parport/share.c Sun Mar 23 00:22:53 2003 +++ b/drivers/parport/share.c Sun Mar 23 00:22:53 2003 @@ -55,37 +55,44 @@ static void dead_onearg (struct parport *p){} static void dead_initstate (struct pardevice *d, struct parport_state *s) { } static void dead_state (struct parport *p, struct parport_state *s) { } -static void dead_noargs (void) { } static size_t dead_write (struct parport *p, const void *b, size_t l, int f) { return 0; } static size_t dead_read (struct parport *p, void *b, size_t l, int f) { return 0; } static struct parport_operations dead_ops = { - dead_write_lines, /* data */ - dead_read_lines, - dead_write_lines, /* control */ - dead_read_lines, - dead_frob_lines, - dead_read_lines, /* status */ - dead_onearg, /* enable_irq */ - dead_onearg, /* disable_irq */ - dead_onearg, /* data_forward */ - dead_onearg, /* data_reverse */ - dead_initstate, /* init_state */ - dead_state, - dead_state, - dead_noargs, /* xxx_use_count */ - dead_noargs, - dead_write, /* epp */ - dead_read, - dead_write, - dead_read, - dead_write, /* ecp */ - dead_read, - dead_write, - dead_write, /* compat */ - dead_read, /* nibble */ - dead_read /* byte */ + .write_data = dead_write_lines, /* data */ + .read_data = dead_read_lines, + + .write_control = dead_write_lines, /* control */ + .read_control = dead_read_lines, + .frob_control = dead_frob_lines, + + .read_status = dead_read_lines, /* status */ + + .enable_irq = dead_onearg, /* enable_irq */ + .disable_irq = dead_onearg, /* disable_irq */ + + .data_forward = dead_onearg, /* data_forward */ + .data_reverse = dead_onearg, /* data_reverse */ + + .init_state = dead_initstate, /* init_state */ + .save_state = dead_state, + .restore_state = dead_state, + + .epp_write_data = dead_write, /* epp */ + .epp_read_data = dead_read, + .epp_write_addr = dead_write, + .epp_read_addr = dead_read, + + .ecp_write_data = dead_write, /* ecp */ + .ecp_read_data = dead_read, + .ecp_write_addr = dead_write, + + .compat_write_data = dead_write, /* compat */ + .nibble_read_data = dead_read, /* nibble */ + .byte_read_data = dead_read, /* byte */ + + .owner = NULL, }; /* Call attach(port) for each registered driver. */ @@ -390,25 +397,6 @@ return NULL; } - /* Search for the lowest free parport number. */ - - spin_lock_irq (&parportlist_lock); - for (portnum = 0; ; portnum++) { - struct parport *itr = portlist; - while (itr) { - if (itr->number == portnum) - /* No good, already used. */ - break; - else - itr = itr->next; - } - - if (itr == NULL) - /* Got to the end of the list. */ - break; - } - spin_unlock_irq (&parportlist_lock); - /* Init our structure */ memset(tmp, 0, sizeof(struct parport)); tmp->base = base; @@ -420,7 +408,6 @@ tmp->devices = tmp->cad = NULL; tmp->flags = 0; tmp->ops = ops; - tmp->portnum = tmp->number = portnum; tmp->physport = tmp; memset (tmp->probe_info, 0, 5 * sizeof (struct parport_device_info)); tmp->cad_lock = RW_LOCK_UNLOCKED; @@ -438,9 +425,32 @@ kfree(tmp); return NULL; } + /* Search for the lowest free parport number. */ + + spin_lock_irq (&parportlist_lock); + for (portnum = 0; ; portnum++) { + struct parport *itr = portlist; + while (itr) { + if (itr->number == portnum) + /* No good, already used. */ + break; + else + itr = itr->next; + } + + if (itr == NULL) + /* Got to the end of the list. */ + break; + } + + /* + * Now that the portnum is known finish doing the Init. + */ + tmp->portnum = tmp->number = portnum; sprintf(name, "parport%d", portnum); tmp->name = name; + /* * Chain the entry to our list. * @@ -448,8 +458,6 @@ * to clear irq on the local CPU. -arca */ - spin_lock(&parportlist_lock); - /* We are locked against anyone else performing alterations, but * because of parport_enumerate people can still _read_ the list * while we are changing it; so be careful.. @@ -664,8 +672,10 @@ kmalloc. To be absolutely safe, we have to require that our caller doesn't sleep in between parport_enumerate and parport_register_device.. */ - inc_parport_count(); - port->ops->inc_use_count(); + if (!try_module_get(port->ops->owner)) { + return NULL; + } + parport_get_port (port); tmp = kmalloc(sizeof(struct pardevice), GFP_KERNEL); @@ -736,9 +746,9 @@ out_free_pardevice: kfree (tmp); out: - dec_parport_count(); - port->ops->dec_use_count(); parport_put_port (port); + module_put(port->ops->owner); + return NULL; } @@ -801,8 +811,7 @@ kfree(dev->state); kfree(dev); - dec_parport_count(); - port->ops->dec_use_count(); + module_put(port->ops->owner); parport_put_port (port); /* Yes, that's right, someone _could_ still have a pointer to diff -Nru a/drivers/pci/pci.c b/drivers/pci/pci.c --- a/drivers/pci/pci.c Sun Mar 23 00:22:51 2003 +++ b/drivers/pci/pci.c Sun Mar 23 00:22:51 2003 @@ -584,6 +584,9 @@ } #ifndef HAVE_ARCH_PCI_MWI +/* This can be overridden by arch code. */ +u8 pci_cache_line_size = L1_CACHE_BYTES >> 2; + /** * pci_generic_prep_mwi - helper function for pci_set_mwi * @dev: the PCI device for which MWI is enabled @@ -597,32 +600,29 @@ static int pci_generic_prep_mwi(struct pci_dev *dev) { - int rc = 0; - u8 cache_size; + u8 cacheline_size; + + if (!pci_cache_line_size) + return -EINVAL; /* The system doesn't support MWI. */ + + /* Validate current setting: the PCI_CACHE_LINE_SIZE must be + equal to or multiple of the right value. */ + pci_read_config_byte(dev, PCI_CACHE_LINE_SIZE, &cacheline_size); + if (cacheline_size >= pci_cache_line_size && + (cacheline_size % pci_cache_line_size) == 0) + return 0; + + /* Write the correct value. */ + pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, pci_cache_line_size); + /* Read it back. */ + pci_read_config_byte(dev, PCI_CACHE_LINE_SIZE, &cacheline_size); + if (cacheline_size == pci_cache_line_size) + return 0; - /* - * Looks like this is necessary to deal with on all architectures, - * even this %$#%$# N440BX Intel based thing doesn't get it right. - * Ie. having two NICs in the machine, one will have the cache - * line set at boot time, the other will not. - */ - pci_read_config_byte(dev, PCI_CACHE_LINE_SIZE, &cache_size); - cache_size <<= 2; - if (cache_size != SMP_CACHE_BYTES) { - printk(KERN_WARNING "PCI: %s PCI cache line size set " - "incorrectly (%i bytes) by BIOS/FW, ", - dev->slot_name, cache_size); - if (cache_size > SMP_CACHE_BYTES) { - printk("expecting %i\n", SMP_CACHE_BYTES); - rc = -EINVAL; - } else { - printk("correcting to %i\n", SMP_CACHE_BYTES); - pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, - SMP_CACHE_BYTES >> 2); - } - } + printk(KERN_WARNING "PCI: cache line size of %d is not supported " + "by device %s\n", pci_cache_line_size << 2, dev->slot_name); - return rc; + return -EINVAL; } #endif /* !HAVE_ARCH_PCI_MWI */ diff -Nru a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c --- a/drivers/pci/setup-bus.c Sun Mar 23 00:22:56 2003 +++ b/drivers/pci/setup-bus.c Sun Mar 23 00:22:56 2003 @@ -36,6 +36,13 @@ #define ROUND_UP(x, a) (((x) + (a) - 1) & ~((a) - 1)) +/* + * FIXME: IO should be max 256 bytes. However, since we may + * have a P2P bridge below a cardbus bridge, we need 4K. + */ +#define CARDBUS_IO_SIZE (4096) +#define CARDBUS_MEM_SIZE (32*1024*1024) + static int __devinit pbus_assign_resources_sorted(struct pci_bus *bus) { @@ -67,12 +74,67 @@ return found_vga; } +static void __devinit +pci_setup_cardbus(struct pci_bus *bus) +{ + struct pci_dev *bridge = bus->self; + struct pci_bus_region region; + + printk("PCI: Bus %d, cardbus bridge: %s\n", + bus->number, bridge->slot_name); + + pcibios_resource_to_bus(bridge, ®ion, bus->resource[0]); + if (bus->resource[0]->flags & IORESOURCE_IO) { + /* + * The IO resource is allocated a range twice as large as it + * would normally need. This allows us to set both IO regs. + */ + printk(" IO window: %08lx-%08lx\n", + region.start, region.end); + pci_write_config_dword(bridge, PCI_CB_IO_BASE_0, + region.start); + pci_write_config_dword(bridge, PCI_CB_IO_LIMIT_0, + region.end); + } + + pcibios_resource_to_bus(bridge, ®ion, bus->resource[1]); + if (bus->resource[1]->flags & IORESOURCE_IO) { + printk(" IO window: %08lx-%08lx\n", + region.start, region.end); + pci_write_config_dword(bridge, PCI_CB_IO_BASE_1, + region.start); + pci_write_config_dword(bridge, PCI_CB_IO_LIMIT_1, + region.end); + } + + pcibios_resource_to_bus(bridge, ®ion, bus->resource[2]); + if (bus->resource[2]->flags & IORESOURCE_MEM) { + printk(" PREFETCH window: %08lx-%08lx\n", + region.start, region.end); + pci_write_config_dword(bridge, PCI_CB_MEMORY_BASE_0, + region.start); + pci_write_config_dword(bridge, PCI_CB_MEMORY_LIMIT_0, + region.end); + } + + pcibios_resource_to_bus(bridge, ®ion, bus->resource[3]); + if (bus->resource[3]->flags & IORESOURCE_MEM) { + printk(" MEM window: %08lx-%08lx\n", + region.start, region.end); + pci_write_config_dword(bridge, PCI_CB_MEMORY_BASE_1, + region.start); + pci_write_config_dword(bridge, PCI_CB_MEMORY_LIMIT_1, + region.end); + } +} + /* Initialize bridges with base/limit values we have collected. PCI-to-PCI Bridge Architecture Specification rev. 1.1 (1998) requires that if there is no I/O ports or memory behind the bridge, corresponding range must be turned off by writing base value greater than limit to the bridge's base/limit registers. */ -static void __devinit pci_setup_bridge(struct pci_bus *bus) +static void __devinit +pci_setup_bridge(struct pci_bus *bus) { struct pci_dev *bridge = bus->self; struct pci_bus_region region; @@ -154,9 +216,6 @@ struct pci_dev *bridge = bus->self; struct resource *b_res; - if (!bridge || (bridge->class >> 8) != PCI_CLASS_BRIDGE_PCI) - return; - b_res = &bridge->resource[PCI_BRIDGE_RESOURCES]; b_res[1].flags |= IORESOURCE_MEM; @@ -184,6 +243,26 @@ b_res[2].flags |= IORESOURCE_MEM | IORESOURCE_PREFETCH; } +/* Helper function for sizing routines: find first available + bus resource of a given type. Note: we intentionally skip + the bus resources which have already been assigned (that is, + have non-NULL parent resource). */ +static struct resource * __devinit +find_free_bus_resource(struct pci_bus *bus, unsigned long type) +{ + int i; + struct resource *r; + unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM | + IORESOURCE_PREFETCH; + + for (i = 0; i < PCI_BUS_NUM_RESOURCES; i++) { + r = bus->resource[i]; + if (r && (r->flags & type_mask) == type && !r->parent) + return r; + } + return NULL; +} + /* Sizing the IO windows of the PCI-PCI bridge is trivial, since these windows have 4K granularity and the IO ranges of non-bridge PCI devices are limited to 256 bytes. @@ -192,15 +271,15 @@ pbus_size_io(struct pci_bus *bus) { struct pci_dev *dev; - struct resource *b_res = bus->resource[0]; + struct resource *b_res = find_free_bus_resource(bus, IORESOURCE_IO); unsigned long size = 0, size1 = 0; - if (!(b_res->flags & IORESOURCE_IO)) - return; + if (!b_res) + return; list_for_each_entry(dev, &bus->devices, bus_list) { int i; - + for (i = 0; i < PCI_NUM_RESOURCES; i++) { struct resource *r = &dev->resource[i]; unsigned long r_size; @@ -215,9 +294,6 @@ else size1 += r_size; } - /* ??? Reserve some resources for CardBus. */ - if ((dev->class >> 8) == PCI_CLASS_BRIDGE_CARDBUS) - size1 += 4*1024; } /* To be fixed in 2.5: we should have sort of HAVE_ISA flag in the struct pci_bus. */ @@ -236,15 +312,17 @@ /* Calculate the size of the bus and minimal alignment which guarantees that all child resources fit in this size. */ -static void __devinit +static int __devinit pbus_size_mem(struct pci_bus *bus, unsigned long mask, unsigned long type) { struct pci_dev *dev; unsigned long min_align, align, size; unsigned long aligns[12]; /* Alignments from 1Mb to 2Gb */ int order, max_order; - struct resource *b_res = (type & IORESOURCE_PREFETCH) ? - bus->resource[2] : bus->resource[1]; + struct resource *b_res = find_free_bus_resource(bus, type); + + if (!b_res) + return 0; memset(aligns, 0, sizeof(aligns)); max_order = 0; @@ -280,11 +358,6 @@ if (order > max_order) max_order = order; } - /* ??? Reserve some resources for CardBus. */ - if ((dev->class >> 8) == PCI_CLASS_BRIDGE_CARDBUS) { - size += 1UL << 24; /* 16 Mb */ - aligns[24 - 20] += 1UL << 24; - } } align = 0; @@ -301,38 +374,111 @@ size = ROUND_UP(size, min_align); if (!size) { b_res->flags = 0; - return; + return 1; } b_res->start = min_align; b_res->end = size + min_align - 1; + return 1; +} + +static void __devinit +pci_bus_size_cardbus(struct pci_bus *bus) +{ + struct pci_dev *bridge = bus->self; + struct resource *b_res = &bridge->resource[PCI_BRIDGE_RESOURCES]; + u16 ctrl; + + /* + * Reserve some resources for CardBus. We reserve + * a fixed amount of bus space for CardBus bridges. + */ + b_res[0].start = CARDBUS_IO_SIZE; + b_res[0].end = b_res[0].start + CARDBUS_IO_SIZE - 1; + b_res[0].flags |= IORESOURCE_IO; + + b_res[1].start = CARDBUS_IO_SIZE; + b_res[1].end = b_res[1].start + CARDBUS_IO_SIZE - 1; + b_res[1].flags |= IORESOURCE_IO; + + /* + * Check whether prefetchable memory is supported + * by this bridge. + */ + pci_read_config_word(bridge, PCI_CB_BRIDGE_CONTROL, &ctrl); + if (!(ctrl & PCI_CB_BRIDGE_CTL_PREFETCH_MEM0)) { + ctrl |= PCI_CB_BRIDGE_CTL_PREFETCH_MEM0; + pci_write_config_word(bridge, PCI_CB_BRIDGE_CONTROL, ctrl); + pci_read_config_word(bridge, PCI_CB_BRIDGE_CONTROL, &ctrl); + } + + /* + * If we have prefetchable memory support, allocate + * two regions. Otherwise, allocate one region of + * twice the size. + */ + if (ctrl & PCI_CB_BRIDGE_CTL_PREFETCH_MEM0) { + b_res[2].start = CARDBUS_MEM_SIZE; + b_res[2].end = b_res[2].start + CARDBUS_MEM_SIZE - 1; + b_res[2].flags |= IORESOURCE_MEM | IORESOURCE_PREFETCH; + + b_res[3].start = CARDBUS_MEM_SIZE; + b_res[3].end = b_res[3].start + CARDBUS_MEM_SIZE - 1; + b_res[3].flags |= IORESOURCE_MEM; + } else { + b_res[3].start = CARDBUS_MEM_SIZE * 2; + b_res[3].end = b_res[3].start + CARDBUS_MEM_SIZE * 2 - 1; + b_res[3].flags |= IORESOURCE_MEM; + } } void __devinit pci_bus_size_bridges(struct pci_bus *bus) { - struct pci_bus *b; - unsigned long mask, type; + struct pci_dev *dev; + unsigned long mask, prefmask; - list_for_each_entry(b, &bus->children, node) { - pci_bus_size_bridges(b); + list_for_each_entry(dev, &bus->devices, bus_list) { + struct pci_bus *b = dev->subordinate; + if (!b) + continue; + + switch (dev->class >> 8) { + case PCI_CLASS_BRIDGE_CARDBUS: + pci_bus_size_cardbus(b); + break; + + case PCI_CLASS_BRIDGE_PCI: + default: + pci_bus_size_bridges(b); + break; + } } /* The root bus? */ if (!bus->self) return; - pci_bridge_check_ranges(bus); - - pbus_size_io(bus); - - mask = type = IORESOURCE_MEM; - /* If the bridge supports prefetchable range, size it separately. */ - if (bus->resource[2] && - bus->resource[2]->flags & IORESOURCE_PREFETCH) { - pbus_size_mem(bus, IORESOURCE_PREFETCH, IORESOURCE_PREFETCH); - mask |= IORESOURCE_PREFETCH; /* Size non-prefetch only. */ + switch (bus->self->class >> 8) { + case PCI_CLASS_BRIDGE_CARDBUS: + /* don't size cardbuses yet. */ + break; + + case PCI_CLASS_BRIDGE_PCI: + pci_bridge_check_ranges(bus); + default: + pbus_size_io(bus); + /* If the bridge supports prefetchable range, size it + separately. If it doesn't, or its prefetchable window + has already been allocated by arch code, try + non-prefetchable range for both types of PCI memory + resources. */ + mask = IORESOURCE_MEM; + prefmask = IORESOURCE_MEM | IORESOURCE_PREFETCH; + if (pbus_size_mem(bus, prefmask, prefmask)) + mask = prefmask; /* Success, size non-prefetch only. */ + pbus_size_mem(bus, mask, IORESOURCE_MEM); + break; } - pbus_size_mem(bus, mask, type); } EXPORT_SYMBOL(pci_bus_size_bridges); @@ -351,9 +497,24 @@ } list_for_each_entry(dev, &bus->devices, bus_list) { b = dev->subordinate; - if (b) { - pci_bus_assign_resources(b); + if (!b) + continue; + + pci_bus_assign_resources(b); + + switch (dev->class >> 8) { + case PCI_CLASS_BRIDGE_PCI: pci_setup_bridge(b); + break; + + case PCI_CLASS_BRIDGE_CARDBUS: + pci_setup_cardbus(b); + break; + + default: + printk(KERN_INFO "PCI: not setting up bridge %s " + "for bus %d\n", dev->slot_name, b->number); + break; } } } diff -Nru a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c --- a/drivers/pci/setup-res.c Sun Mar 23 00:22:55 2003 +++ b/drivers/pci/setup-res.c Sun Mar 23 00:22:55 2003 @@ -59,9 +59,7 @@ reg = dev->rom_base_reg; } else { /* Hmm, non-standard resource. */ - printk("PCI: trying to set non-standard region %s/%d\n", - dev->slot_name, resno); - return; + BUG(); } pci_write_config_dword(dev, reg, new); @@ -141,7 +139,7 @@ if (ret) { printk(KERN_ERR "PCI: Failed to allocate resource %d(%lx-%lx) for %s\n", resno, res->start, res->end, dev->slot_name); - } else { + } else if (resno < PCI_BRIDGE_RESOURCES) { pci_update_resource(dev, res, resno); } diff -Nru a/drivers/pcmcia/bulkmem.c b/drivers/pcmcia/bulkmem.c --- a/drivers/pcmcia/bulkmem.c Sun Mar 23 00:22:57 2003 +++ b/drivers/pcmcia/bulkmem.c Sun Mar 23 00:22:57 2003 @@ -31,8 +31,6 @@ ======================================================================*/ -#define __NO_VERSION__ - #include #include #include diff -Nru a/drivers/pcmcia/cardbus.c b/drivers/pcmcia/cardbus.c --- a/drivers/pcmcia/cardbus.c Sun Mar 23 00:22:51 2003 +++ b/drivers/pcmcia/cardbus.c Sun Mar 23 00:22:51 2003 @@ -46,8 +46,6 @@ */ -#define __NO_VERSION__ - #include #include #include diff -Nru a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c --- a/drivers/pcmcia/cistpl.c Sun Mar 23 00:22:52 2003 +++ b/drivers/pcmcia/cistpl.c Sun Mar 23 00:22:52 2003 @@ -31,8 +31,6 @@ ======================================================================*/ -#define __NO_VERSION__ - #include #include #include diff -Nru a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c --- a/drivers/pcmcia/cs.c Sun Mar 23 00:22:51 2003 +++ b/drivers/pcmcia/cs.c Sun Mar 23 00:22:51 2003 @@ -895,6 +895,10 @@ c = &s->config[reg->Function]; } else c = CONFIG(handle); + + if (c == NULL) + return CS_NO_CARD; + if (!(c->state & CONFIG_LOCKED)) return CS_CONFIGURATION_LOCKED; diff -Nru a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c --- a/drivers/pcmcia/ds.c Sun Mar 23 00:22:55 2003 +++ b/drivers/pcmcia/ds.c Sun Mar 23 00:22:55 2003 @@ -77,16 +77,8 @@ /*====================================================================*/ -typedef struct driver_info_t { - dev_info_t dev_info; - int use_count, status; - dev_link_t *(*attach)(void); - void (*detach)(dev_link_t *); - struct driver_info_t *next; -} driver_info_t; - typedef struct socket_bind_t { - driver_info_t *driver; + struct pcmcia_driver *driver; u_char function; dev_link_t *instance; struct socket_bind_t *next; @@ -124,9 +116,6 @@ /* Device driver ID passed to Card Services */ static dev_info_t dev_info = "Driver Services"; -/* Linked list of all registered device drivers */ -static driver_info_t *root_driver = NULL; - static int sockets = 0, major_dev = -1; static socket_info_t *socket_table = NULL; @@ -143,35 +132,66 @@ pcmcia_report_error(handle, &err); } -/*====================================================================== +/*======================================================================*/ + +static struct pcmcia_driver * get_pcmcia_driver (dev_info_t *dev_info); + +/** + * pcmcia_register_driver - register a PCMCIA driver with the bus core + * + * Registers a PCMCIA driver with the PCMCIA bus core. + */ +int pcmcia_register_driver(struct pcmcia_driver *driver) +{ + if (!driver) + return -EINVAL; + + driver->use_count = 0; + driver->status = init_status; + driver->drv.bus = &pcmcia_bus_type; + + return driver_register(&driver->drv); +} +EXPORT_SYMBOL(pcmcia_register_driver); + +/** + * pcmcia_unregister_driver - unregister a PCMCIA driver with the bus core + */ +void pcmcia_unregister_driver(struct pcmcia_driver *driver) +{ + socket_bind_t *b; + int i; + + if (driver->use_count > 0) { + /* Blank out any left-over device instances */ + driver->attach = NULL; driver->detach = NULL; + for (i = 0; i < sockets; i++) + for (b = socket_table[i].bind; b; b = b->next) + if (b->driver == driver) + b->instance = NULL; + } + + driver_unregister(&driver->drv); +} +EXPORT_SYMBOL(pcmcia_unregister_driver); - Register_pccard_driver() and unregister_pccard_driver() are used - tell Driver Services that a PC Card client driver is available to - be bound to sockets. - -======================================================================*/ int register_pccard_driver(dev_info_t *dev_info, dev_link_t *(*attach)(void), void (*detach)(dev_link_t *)) { - driver_info_t *driver; + struct pcmcia_driver *driver; socket_bind_t *b; int i; DEBUG(0, "ds: register_pccard_driver('%s')\n", (char *)dev_info); - for (driver = root_driver; driver; driver = driver->next) - if (strncmp((char *)dev_info, (char *)driver->dev_info, - DEV_NAME_LEN) == 0) - break; + driver = get_pcmcia_driver(dev_info); if (!driver) { - driver = kmalloc(sizeof(driver_info_t), GFP_KERNEL); + driver = kmalloc(sizeof(struct pcmcia_driver), GFP_KERNEL); if (!driver) return -ENOMEM; - strncpy(driver->dev_info, (char *)dev_info, DEV_NAME_LEN); - driver->use_count = 0; - driver->status = init_status; - driver->next = root_driver; - root_driver = driver; + memset(driver, 0, sizeof(struct pcmcia_driver)); + driver->drv.name = (char *)dev_info; + pcmcia_register_driver(driver); } driver->attach = attach; @@ -185,7 +205,7 @@ b->instance = driver->attach(); if (b->instance == NULL) printk(KERN_NOTICE "ds: unable to create instance " - "of '%s'!\n", driver->dev_info); + "of '%s'!\n", driver->drv.name); } return 0; @@ -195,44 +215,45 @@ int unregister_pccard_driver(dev_info_t *dev_info) { - driver_info_t *target, **d = &root_driver; - socket_bind_t *b; - int i; - + struct pcmcia_driver *driver; + DEBUG(0, "ds: unregister_pccard_driver('%s')\n", (char *)dev_info); - while ((*d) && (strncmp((*d)->dev_info, (char *)dev_info, - DEV_NAME_LEN) != 0)) - d = &(*d)->next; - if (*d == NULL) + + driver = get_pcmcia_driver(dev_info); + if (!driver) return -ENODEV; - target = *d; - if (target->use_count == 0) { - *d = target->next; - kfree(target); - } else { - /* Blank out any left-over device instances */ - target->attach = NULL; target->detach = NULL; - for (i = 0; i < sockets; i++) - for (b = socket_table[i].bind; b; b = b->next) - if (b->driver == target) b->instance = NULL; - } + pcmcia_unregister_driver(driver); + kfree(driver); return 0; } /* unregister_pccard_driver */ /*====================================================================*/ #ifdef CONFIG_PROC_FS +static int proc_read_drivers_callback(struct device_driver *driver, void *d) +{ + char **p = d; + struct pcmcia_driver *p_dev = container_of(driver, + struct pcmcia_driver, drv); + + *p += sprintf(*p, "%-24.24s %d %d\n", driver->name, p_dev->status, + p_dev->use_count); + d = (void *) p; + + return 0; +} + static int proc_read_drivers(char *buf, char **start, off_t pos, int count, int *eof, void *data) { - driver_info_t *d; - char *p = buf; - for (d = root_driver; d; d = d->next) - p += sprintf(p, "%-24.24s %d %d\n", d->dev_info, - d->status, d->use_count); - return (p - buf); + char *p = buf; + + bus_for_each_drv(&pcmcia_bus_type, NULL, + (void *) &p, proc_read_drivers_callback); + + return (p - buf); } #endif @@ -376,7 +397,7 @@ static int bind_request(int i, bind_info_t *bind_info) { - struct driver_info_t *driver; + struct pcmcia_driver *driver; socket_bind_t *b; bind_req_t bind_req; socket_info_t *s = &socket_table[i]; @@ -384,18 +405,13 @@ DEBUG(2, "bind_request(%d, '%s')\n", i, (char *)bind_info->dev_info); - for (driver = root_driver; driver; driver = driver->next) - if (strcmp((char *)driver->dev_info, - (char *)bind_info->dev_info) == 0) - break; + driver = get_pcmcia_driver(&bind_info->dev_info); if (driver == NULL) { - driver = kmalloc(sizeof(driver_info_t), GFP_KERNEL); + driver = kmalloc(sizeof(struct pcmcia_driver), GFP_KERNEL); if (!driver) return -ENOMEM; - strncpy(driver->dev_info, bind_info->dev_info, DEV_NAME_LEN); - driver->use_count = 0; - driver->next = root_driver; - driver->attach = NULL; driver->detach = NULL; - root_driver = driver; + memset(driver, 0, sizeof(struct pcmcia_driver)); + driver->drv.name = bind_info->dev_info; + pcmcia_register_driver(driver); } for (b = s->bind; b; b = b->next) @@ -409,7 +425,7 @@ bind_req.Socket = i; bind_req.Function = bind_info->function; - bind_req.dev_info = &driver->dev_info; + bind_req.dev_info = (dev_info_t *) driver->drv.name; ret = pcmcia_bind_device(&bind_req); if (ret != CS_SUCCESS) { cs_error(NULL, BindDevice, ret); @@ -490,7 +506,7 @@ #endif for (b = s->bind; b; b = b->next) - if ((strcmp((char *)b->driver->dev_info, + if ((strcmp((char *)b->driver->drv.name, (char *)bind_info->dev_info) == 0) && (b->function == bind_info->function)) break; @@ -524,7 +540,7 @@ DEBUG(2, "unbind_request(%d, '%s')\n", i, (char *)bind_info->dev_info); for (b = &s->bind; *b; b = &(*b)->next) - if ((strcmp((char *)(*b)->driver->dev_info, + if ((strcmp((char *)(*b)->driver->drv.name, (char *)bind_info->dev_info) == 0) && ((*b)->function == bind_info->function)) break; @@ -536,14 +552,6 @@ if (c->driver->detach) { if (c->instance) c->driver->detach(c->instance); - } else { - if (c->driver->use_count == 0) { - driver_info_t **d; - for (d = &root_driver; *d; d = &((*d)->next)) - if (c->driver == *d) break; - *d = (*d)->next; - kfree(c->driver); - } } *b = c->next; kfree(c); @@ -881,7 +889,18 @@ /*====================================================================*/ -int __init init_pcmcia_ds(void) +struct bus_type pcmcia_bus_type = { + .name = "pcmcia", +}; +EXPORT_SYMBOL(pcmcia_bus_type); + +static int __init init_pcmcia_bus(void) +{ + bus_register(&pcmcia_bus_type); + return 0; +} + +static int __init init_pcmcia_ds(void) { client_reg_t client_reg; servinfo_t serv; @@ -967,11 +986,8 @@ return 0; } -late_initcall(init_pcmcia_ds); -#ifdef MODULE - -void __exit cleanup_module(void) +static void __exit exit_pcmcia_ds(void) { int i; #ifdef CONFIG_PROC_FS @@ -984,6 +1000,57 @@ pcmcia_deregister_client(socket_table[i].handle); sockets = 0; kfree(socket_table); + bus_unregister(&pcmcia_bus_type); } +#ifdef MODULE + +/* init_pcmcia_bus must be done early, init_pcmcia_ds late. If we load this + * as a module, we can only specify one initcall, though... + */ +static int __init init_pcmcia_module(void) { + init_pcmcia_bus(); + return init_pcmcia_ds(); +} +module_init(init_pcmcia_module); + +#else /* !MODULE */ +subsys_initcall(init_pcmcia_bus); +late_initcall(init_pcmcia_ds); #endif + +module_exit(exit_pcmcia_ds); + + +/* helpers for backwards-compatible functions */ + +/* backwards-compatible accessing of driver --- by name! */ + +struct cmp_data { + void *dev_info; + struct pcmcia_driver *drv; +}; + +static int cmp_drv_callback(struct device_driver *drv, void *data) +{ + struct cmp_data *cmp = data; + if (strncmp((char *)cmp->dev_info, (char *)drv->name, + DEV_NAME_LEN) == 0) { + cmp->drv = container_of(drv, struct pcmcia_driver, drv); + return -EINVAL; + } + return 0; +} + +static struct pcmcia_driver * get_pcmcia_driver (dev_info_t *dev_info) +{ + int ret; + struct cmp_data cmp = { + .dev_info = dev_info, + }; + + ret = bus_for_each_drv(&pcmcia_bus_type, NULL, &cmp, cmp_drv_callback); + if (ret) + return cmp.drv; + return NULL; +} diff -Nru a/drivers/pcmcia/i82365.c b/drivers/pcmcia/i82365.c --- a/drivers/pcmcia/i82365.c Sun Mar 23 00:22:55 2003 +++ b/drivers/pcmcia/i82365.c Sun Mar 23 00:22:55 2003 @@ -1608,9 +1608,11 @@ return -1; } DEBUG(0, "%s\n", version); + if (driver_register(&i82365_driver)) + return -1; + printk(KERN_INFO "Intel PCIC probe: "); sockets = 0; - driver_register(&i82365_driver); #ifdef CONFIG_ISA isa_probe(); diff -Nru a/drivers/pcmcia/rsrc_mgr.c b/drivers/pcmcia/rsrc_mgr.c --- a/drivers/pcmcia/rsrc_mgr.c Sun Mar 23 00:22:54 2003 +++ b/drivers/pcmcia/rsrc_mgr.c Sun Mar 23 00:22:54 2003 @@ -31,8 +31,6 @@ ======================================================================*/ -#define __NO_VERSION__ - #include #include #include diff -Nru a/drivers/pcmcia/tcic.c b/drivers/pcmcia/tcic.c --- a/drivers/pcmcia/tcic.c Sun Mar 23 00:22:53 2003 +++ b/drivers/pcmcia/tcic.c Sun Mar 23 00:22:53 2003 @@ -408,7 +408,8 @@ return -1; } - driver_register(&tcic_driver); + if (driver_register(&tcic_driver)) + return -1; printk(KERN_INFO "Databook TCIC-2 PCMCIA probe: "); sock = 0; diff -Nru a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c --- a/drivers/pnp/pnpbios/core.c Sun Mar 23 00:22:50 2003 +++ b/drivers/pnp/pnpbios/core.c Sun Mar 23 00:22:50 2003 @@ -322,7 +322,7 @@ u16 status; if (!pnp_bios_present()) return PNP_FUNCTION_NOT_SUPPORTED; - if ( !boot & pnpbios_dont_use_current_config ) + if ( !boot && pnpbios_dont_use_current_config ) return PNP_FUNCTION_NOT_SUPPORTED; status = call_pnp_bios(PNP_GET_SYS_DEV_NODE, 0, PNP_TS1, 0, PNP_TS2, boot ? 2 : 1, PNP_DS, 0, nodenum, sizeof(char), data, 65536); @@ -350,7 +350,7 @@ u16 status; if (!pnp_bios_present()) return PNP_FUNCTION_NOT_SUPPORTED; - if ( !boot & pnpbios_dont_use_current_config ) + if ( !boot && pnpbios_dont_use_current_config ) return PNP_FUNCTION_NOT_SUPPORTED; status = call_pnp_bios(PNP_SET_SYS_DEV_NODE, nodenum, 0, PNP_TS1, boot ? 2 : 1, PNP_DS, 0, 0, data, 65536, 0, 0); @@ -969,7 +969,7 @@ spin_lock_init(&pnp_bios_lock); - if(pnpbios_disabled) { + if(pnpbios_disabled || (dmi_broken & BROKEN_PNP_BIOS)) { printk(KERN_INFO "PnPBIOS: Disabled\n"); return -ENODEV; } diff -Nru a/drivers/pnp/pnpbios/proc.c b/drivers/pnp/pnpbios/proc.c --- a/drivers/pnp/pnpbios/proc.c Sun Mar 23 00:22:55 2003 +++ b/drivers/pnp/pnpbios/proc.c Sun Mar 23 00:22:55 2003 @@ -19,7 +19,6 @@ */ //#include -#define __NO_VERSION__ //#include #include diff -Nru a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c --- a/drivers/scsi/3w-xxxx.c Sun Mar 23 00:22:55 2003 +++ b/drivers/scsi/3w-xxxx.c Sun Mar 23 00:22:55 2003 @@ -6,7 +6,7 @@ Arnaldo Carvalho de Melo Brad Strand - Copyright (C) 1999-2002 3ware Inc. + Copyright (C) 1999-2003 3ware Inc. Kernel compatiblity By: Andre Hedrick Non-Copyright (C) 2000 Andre Hedrick @@ -164,6 +164,11 @@ Add support for mode sense opcode. Add support for cache mode page. Add support for synchronize cache opcode. + 1.02.00.032 - Fix small multicard rollcall bug. + Make driver stay loaded with no units for hot add/swap. + Add support for "twe" character device for ioctls. + Clean up request_id queueing code. + Fix tw_scsi_queue() spinlocks. */ #include @@ -203,6 +208,9 @@ #include "3w-xxxx.h" +static int tw_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg); +static int tw_chrdev_open(struct inode *inode, struct file *file); +static int tw_chrdev_release(struct inode *inode, struct file *file); static int tw_copy_info(TW_Info *info, char *fmt, ...); static void tw_copy_mem_info(TW_Info *info, char *data, int len); static void tw_interrupt(int irq, void *dev_instance, struct pt_regs *regs); @@ -216,10 +224,19 @@ tw_halt, NULL, 0 }; +/* File operations struct for character device */ +static struct file_operations tw_fops = { + owner: THIS_MODULE, + ioctl: tw_chrdev_ioctl, + open: tw_chrdev_open, + release: tw_chrdev_release +}; + /* Globals */ -char *tw_driver_version="1.02.00.031"; +char *tw_driver_version="1.02.00.032"; TW_Device_Extension *tw_device_extension_list[TW_MAX_SLOT]; int tw_device_extension_count = 0; +static int twe_major = -1; /* Functions */ @@ -599,6 +616,191 @@ return 0; } /* End tw_check_errors() */ +/* This function handles ioctl for the character device */ +static int tw_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) +{ + int error, request_id; + dma_addr_t dma_handle; + unsigned short tw_aen_code; + unsigned long before, timeout; + unsigned long flags; + unsigned int data_buffer_length = 0; + unsigned long data_buffer_length_adjusted = 0; + unsigned long *cpu_addr; + TW_New_Ioctl *tw_ioctl; + TW_Passthru *passthru; + TW_Device_Extension *tw_dev = tw_device_extension_list[minor(inode->i_rdev)]; + int retval = -EFAULT; + + dprintk(KERN_WARNING "3w-xxxx: tw_chrdev_ioctl()\n"); + + /* Only let one of these through at a time */ + down(&tw_dev->ioctl_sem); + + /* First copy down the buffer length */ + error = copy_from_user(&data_buffer_length, (void *)arg, sizeof(unsigned int)); + if (error) + goto out; + + /* Check size */ + if (data_buffer_length > TW_MAX_SECTORS * 512) { + retval = -EINVAL; + goto out; + } + + /* Hardware can only do multiple of 512 byte transfers */ + data_buffer_length_adjusted = (data_buffer_length + 511) & ~511; + + /* Now allocate ioctl buf memory */ + cpu_addr = pci_alloc_consistent(tw_dev->tw_pci_dev, data_buffer_length_adjusted+sizeof(TW_New_Ioctl) - 1, &dma_handle); + if (cpu_addr == NULL) { + retval -ENOMEM; + goto out; + } + + tw_ioctl = (TW_New_Ioctl *)cpu_addr; + + /* Now copy down the entire ioctl */ + error = copy_from_user(tw_ioctl, (void *)arg, data_buffer_length + sizeof(TW_New_Ioctl) - 1); + if (error) + goto out2; + + passthru = (TW_Passthru *)&tw_ioctl->firmware_command; + + /* See which ioctl we are doing */ + switch (cmd) { + case TW_OP_NOP: + dprintk(KERN_WARNING "3w-xxxx: tw_chrdev_ioctl(): caught TW_OP_NOP.\n"); + break; + case TW_OP_AEN_LISTEN: + dprintk(KERN_WARNING "3w-xxxx: tw_chrdev_ioctl(): caught TW_AEN_LISTEN.\n"); + memset(tw_ioctl->data_buffer, 0, tw_ioctl->data_buffer_length); + + spin_lock_irqsave(&tw_dev->host->host_lock, flags); + if (tw_dev->aen_head == tw_dev->aen_tail) { + tw_aen_code = TW_AEN_QUEUE_EMPTY; + } else { + tw_aen_code = tw_dev->aen_queue[tw_dev->aen_head]; + if (tw_dev->aen_head == TW_Q_LENGTH - 1) { + tw_dev->aen_head = TW_Q_START; + } else { + tw_dev->aen_head = tw_dev->aen_head + 1; + } + } + spin_unlock_irqrestore(&tw_dev->tw_lock, flags); + memcpy(tw_ioctl->data_buffer, &tw_aen_code, sizeof(tw_aen_code)); + break; + case TW_CMD_PACKET_WITH_DATA: + dprintk(KERN_WARNING "3w-xxxx: tw_chrdev_ioctl(): caught TW_CMD_PACKET_WITH_DATA.\n"); + spin_lock_irqsave(&tw_dev->tw_lock, flags); + + tw_state_request_start(tw_dev, &request_id); + + /* Flag internal command */ + tw_dev->srb[request_id] = 0; + + /* Flag chrdev ioctl */ + tw_dev->chrdev_request_id = request_id; + + tw_ioctl->firmware_command.request_id = request_id; + + /* Load the sg list */ + switch (tw_ioctl->firmware_command.byte0.sgl_offset) { + case 2: + tw_ioctl->firmware_command.byte8.param.sgl[0].address = dma_handle + sizeof(TW_New_Ioctl) - 1; + tw_ioctl->firmware_command.byte8.param.sgl[0].length = data_buffer_length_adjusted; + break; + case 3: + tw_ioctl->firmware_command.byte8.io.sgl[0].address = dma_handle + sizeof(TW_New_Ioctl) - 1; + tw_ioctl->firmware_command.byte8.io.sgl[0].length = data_buffer_length_adjusted; + break; + case 5: + passthru->sg_list[0].address = dma_handle + sizeof(TW_New_Ioctl) - 1; + passthru->sg_list[0].length = data_buffer_length_adjusted; + break; + } + + memcpy(tw_dev->command_packet_virtual_address[request_id], &(tw_ioctl->firmware_command), sizeof(TW_Command)); + + /* Now post the command packet to the controller */ + tw_post_command_packet(tw_dev, request_id); + spin_unlock_irqrestore(&tw_dev->tw_lock, flags); + + /* Now wait for the command to complete */ + before = jiffies; + + while (tw_dev->chrdev_request_id != TW_IOCTL_CHRDEV_FREE) + { + /* FIXME: race condition on the wait*/ + interruptible_sleep_on_timeout(&tw_dev->ioctl_wqueue, 1); + if (time_after(jiffies, before + HZ *TW_IOCTL_CHRDEV_TIMEOUT)) { + /* Now we need to reset the board */ + printk(KERN_WARNING "3w-xxxx: scsi%d: Character ioctl (0x%x) timed out, resetting card.\n", tw_dev->host->host_no, cmd); + spin_lock_irqsave(&tw_dev->tw_lock, flags); + tw_dev->state[request_id] = TW_S_COMPLETED; + tw_state_request_finish(tw_dev, request_id); + tw_dev->posted_request_count--; + if (tw_reset_device_extension(tw_dev)) { + printk(KERN_WARNING "3w-xxxx: tw_chrdev_ioctl(): Reset failed for card %d.\n", tw_dev->host->host_no); + } + spin_unlock_irqrestore(&tw_dev->tw_lock, flags); + if (signal_pending(current)) + retval = -EINTR; + else + retval = -EIO; + goto out2; + } + } + + /* Now copy in the command packet response */ + memcpy(&(tw_ioctl->firmware_command), tw_dev->command_packet_virtual_address[request_id], sizeof(TW_Command)); + + /* Now complete the io */ + spin_lock_irqsave(&tw_dev->tw_lock, flags); + tw_dev->posted_request_count--; + tw_dev->state[request_id] = TW_S_COMPLETED; + tw_state_request_finish(tw_dev, request_id); + spin_unlock_irqrestore(&tw_dev->tw_lock, flags); + break; + default: + retval = -ENOTTY; + goto out2; + } + + /* Now copy the response to userspace */ + error = copy_to_user((void *)arg, tw_ioctl, sizeof(TW_New_Ioctl) + tw_ioctl->data_buffer_length - 1); + if (error == 0) + retval = 0; +out2: + /* Now free ioctl buf memory */ + pci_free_consistent(tw_dev->tw_pci_dev, data_buffer_length_adjusted+sizeof(TW_New_Ioctl) - 1, cpu_addr, dma_handle); +out: + up(&tw_dev->ioctl_sem); + return retval; +} /* End tw_chrdev_ioctl() */ + +/* This function handles open for the character device */ +static int tw_chrdev_open(struct inode *inode, struct file *file) +{ + unsigned int minor_number; + + dprintk(KERN_WARNING "3w-xxxx: tw_ioctl_open()\n"); + + minor_number = minor(inode->i_rdev); + if (minor_number >= tw_device_extension_count) + return -ENODEV; + + return 0; +} /* End tw_chrdev_open() */ + +/* This function handles close for the character device */ +static int tw_chrdev_release(struct inode *inode, struct file *file) +{ + dprintk(KERN_WARNING "3w-xxxx: tw_ioctl_release()\n"); + + return 0; +} /* End tw_chrdev_release() */ + /* This function will clear all interrupts on the controller */ void tw_clear_all_interrupts(TW_Device_Extension *tw_dev) { @@ -833,6 +1035,8 @@ continue; } memset(tw_dev, 0, sizeof(TW_Device_Extension)); + + init_MUTEX(&tw_dev->ioctl_sem); /* Save pci_dev struct to device extension */ tw_dev->tw_pci_dev = tw_pci_dev; @@ -867,7 +1071,9 @@ /* Disable interrupts on the card */ tw_disable_interrupts(tw_dev); - + + tries = 0; + while (tries < TW_MAX_RESET_TRIES) { /* Do soft reset */ tw_soft_reset(tw_dev); @@ -897,8 +1103,8 @@ continue; } - /* Make sure that io region isn't already taken */ - if (check_region((tw_dev->tw_pci_dev->resource[0].start), TW_IO_ADDRESS_RANGE)) { + /* Reserve the io address space */ + if (!request_region((tw_dev->tw_pci_dev->resource[0].start), TW_IO_ADDRESS_RANGE, TW_DEVICE_NAME)) { printk(KERN_WARNING "3w-xxxx: tw_findcards(): Couldn't get io range 0x%lx-0x%lx for card %d.\n", (tw_dev->tw_pci_dev->resource[0].start), (tw_dev->tw_pci_dev->resource[0].start) + @@ -907,16 +1113,10 @@ kfree(tw_dev); continue; } - - /* Reserve the io address space */ - request_region((tw_dev->tw_pci_dev->resource[0].start), TW_IO_ADDRESS_RANGE, TW_DEVICE_NAME); + error = tw_initialize_units(tw_dev); if (error) { printk(KERN_WARNING "3w-xxxx: No valid units for for card %d.\n", j); - release_region((tw_dev->tw_pci_dev->resource[0].start), TW_IO_ADDRESS_RANGE); - tw_free_device_extension(tw_dev); - kfree(tw_dev); - continue; } error = tw_initconnection(tw_dev, TW_INIT_MESSAGE_CREDITS); @@ -935,7 +1135,7 @@ if (tw_dev->num_units > 0) { /* Use SHT cmd_per_lun here */ tw_dev->free_head = TW_Q_START; - tw_dev->free_tail = TW_Q_LENGTH - 1; + tw_dev->free_tail = TW_Q_START; tw_dev->free_wrap = TW_Q_LENGTH - 1; } @@ -992,13 +1192,7 @@ /* Tell the firmware we support shutdown notification*/ error = tw_setfeature(tw_dev2, 2, 1, &c); if (error) { - printk(KERN_WARNING "3w-xxxx: tw_setfeature(): Error setting features for card %d.\n", j); - scsi_unregister(host); - release_region((tw_dev->tw_pci_dev->resource[0].start), TW_IO_ADDRESS_RANGE); - tw_free_device_extension(tw_dev); - kfree(tw_dev); - numcards--; - continue; + printk(KERN_WARNING "3w-xxxx: Unable to set features for card %d, old firmware or card.\n", j); } /* Now setup the interrupt handler */ @@ -1023,10 +1217,14 @@ } } - if (numcards == 0) - printk(KERN_WARNING "3w-xxxx: No cards with valid units found.\n"); - else - register_reboot_notifier(&tw_notifier); + if (numcards == 0) { + printk(KERN_WARNING "3w-xxxx: No cards found.\n"); + } else { + register_reboot_notifier(&tw_notifier); + if ((twe_major = register_chrdev (0, "twe", &tw_fops)) < 0) { + printk(KERN_WARNING "3w-xxxx: Unable to register \"twe\" character device, error = %d.\n", twe_major); + } + } return numcards; } /* End tw_findcards() */ @@ -1153,6 +1351,8 @@ tw_dev->pending_head = TW_Q_START; tw_dev->pending_tail = TW_Q_START; spin_lock_init(&tw_dev->tw_lock); + tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE; + init_waitqueue_head(&tw_dev->ioctl_wqueue); return 0; } /* End tw_initialize_device_extension() */ @@ -1395,9 +1595,14 @@ /* Check for internal command completion */ if (tw_dev->srb[request_id] == 0) { dprintk(KERN_WARNING "3w-xxxx: tw_interrupt(): Found internally posted command.\n"); - retval = tw_aen_complete(tw_dev, request_id); - if (retval) { - printk(KERN_WARNING "3w-xxxx: scsi%d: Error completing aen.\n", tw_dev->host->host_no); + /* Check for chrdev ioctl completion */ + if (request_id != tw_dev->chrdev_request_id) { + retval = tw_aen_complete(tw_dev, request_id); + if (retval) { + printk(KERN_WARNING "3w-xxxx: scsi%d: Error completing aen.\n", tw_dev->host->host_no); + } + } else { + tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE; } } else { switch (tw_dev->srb[request_id]->cmnd[0]) { @@ -1409,6 +1614,10 @@ case WRITE_6: dprintk(KERN_NOTICE "3w-xxxx: tw_interrupt(): caught WRITE_10/WRITE_6\n"); break; + case TEST_UNIT_READY: + dprintk(KERN_NOTICE "3w-xxxx: tw_interrupt(): caught TEST_UNIT_READY\n"); + error = tw_scsiop_test_unit_ready_complete(tw_dev, request_id); + break; case INQUIRY: dprintk(KERN_NOTICE "3w-xxxx: tw_interrupt(): caught INQUIRY\n"); error = tw_scsiop_inquiry_complete(tw_dev, request_id); @@ -2070,12 +2279,13 @@ tw_dev->state[i] = TW_S_INITIAL; } tw_dev->free_head = TW_Q_START; - tw_dev->free_tail = TW_Q_LENGTH - 1; + tw_dev->free_tail = TW_Q_START; tw_dev->posted_request_count = 0; tw_dev->pending_request_count = 0; tw_dev->pending_head = TW_Q_START; tw_dev->pending_tail = TW_Q_START; tw_dev->reset_print = 0; + tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE; return 0; } /* End tw_reset_device_extension() */ @@ -2357,7 +2567,6 @@ unsigned char *command = SCpnt->cmnd; int request_id = 0; int error = 0; - unsigned long flags = 0; TW_Device_Extension *tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata; if (tw_dev == NULL) { @@ -2367,14 +2576,14 @@ return 0; } - spin_lock_irqsave(&tw_dev->tw_lock, flags); + spin_lock(&tw_dev->tw_lock); dprintk(KERN_NOTICE "3w-xxxx: tw_scsi_queue()\n"); /* Skip scsi command if it isn't for us */ - if ((tw_dev->is_unit_present[SCpnt->device->id] == FALSE) || (SCpnt->device->lun != 0)) { + if ((SCpnt->device->channel != 0) || (SCpnt->device->lun != 0)) { SCpnt->result = (DID_BAD_TARGET << 16); done(SCpnt); - spin_unlock_irqrestore(&tw_dev->tw_lock, flags); + spin_unlock(&tw_dev->tw_lock); return 0; } @@ -2387,6 +2596,9 @@ /* Save the scsi command for use by the ISR */ tw_dev->srb[request_id] = SCpnt; + /* Initialize phase to zero */ + SCpnt->SCp.phase = 0; + switch (*command) { case READ_10: case READ_6: @@ -2436,7 +2648,7 @@ SCpnt->result = (DID_ERROR << 16); done(SCpnt); } - spin_unlock_irqrestore(&tw_dev->tw_lock, flags); + spin_unlock(&tw_dev->tw_lock); return 0; } /* End tw_scsi_queue() */ @@ -2460,6 +2672,12 @@ /* Free up the IRQ */ free_irq(tw_dev->tw_pci_dev->irq, tw_dev); + /* Unregister character device */ + if (twe_major >= 0) { + unregister_chrdev(twe_major, "twe"); + twe_major = -1; + } + /* Free up device extension resources */ tw_free_device_extension(tw_dev); @@ -2533,7 +2751,6 @@ { unsigned char *is_unit_present; unsigned char *request_buffer; - int i; TW_Param *param; dprintk(KERN_NOTICE "3w-xxxx: tw_scsiop_inquiry_complete()\n"); @@ -2545,12 +2762,12 @@ } request_buffer = tw_dev->srb[request_id]->request_buffer; memset(request_buffer, 0, tw_dev->srb[request_id]->request_bufflen); - request_buffer[0] = TYPE_DISK; /* Peripheral device type */ - request_buffer[1] = 0; /* Device type modifier */ - request_buffer[2] = 0; /* No ansi/iso compliance */ - request_buffer[4] = 31; /* Additional length */ + request_buffer[0] = TYPE_DISK; /* Peripheral device type */ + request_buffer[1] = 0; /* Device type modifier */ + request_buffer[2] = 0; /* No ansi/iso compliance */ + request_buffer[4] = 31; /* Additional length */ memcpy(&request_buffer[8], "3ware ", 8); /* Vendor ID */ - memcpy(&request_buffer[16], "3w-xxxx ", 16); /* Product ID */ + sprintf(&request_buffer[16], "Logical Disk %-2d ", tw_dev->srb[request_id]->device->id); memcpy(&request_buffer[32], tw_driver_version, 3); param = (TW_Param *)tw_dev->alignment_virtual_address[request_id]; @@ -2560,15 +2777,12 @@ } is_unit_present = &(param->data[0]); - for (i=0 ; iis_unit_present[i] = FALSE; - } else { - if (is_unit_present[i] & TW_UNIT_ONLINE) { - tw_dev->is_unit_present[i] = TRUE; - dprintk(KERN_NOTICE "3w-xxxx: tw_scsiop_inquiry_complete: Unit %d found.\n", i); - } - } + if (is_unit_present[tw_dev->srb[request_id]->device->id] & TW_UNIT_ONLINE) { + tw_dev->is_unit_present[tw_dev->srb[request_id]->device->id] = TRUE; + } else { + tw_dev->is_unit_present[tw_dev->srb[request_id]->device->id] = FALSE; + tw_dev->srb[request_id]->result = (DID_BAD_TARGET << 16); + return TW_ISR_DONT_RESULT; } return 0; @@ -2946,17 +3160,88 @@ /* This function will handle test unit ready scsi command */ int tw_scsiop_test_unit_ready(TW_Device_Extension *tw_dev, int request_id) { + TW_Param *param; + TW_Command *command_packet; + unsigned long command_que_value; + u32 command_que_addr; + unsigned long param_value; + dprintk(KERN_NOTICE "3w-xxxx: tw_scsiop_test_unit_ready()\n"); - /* Tell the scsi layer were done */ - tw_dev->state[request_id] = TW_S_COMPLETED; - tw_state_request_finish(tw_dev, request_id); - tw_dev->srb[request_id]->result = (DID_OK << 16); - tw_dev->srb[request_id]->scsi_done(tw_dev->srb[request_id]); + /* Initialize command packet */ + command_que_addr = tw_dev->registers.command_que_addr; + command_packet = (TW_Command *)tw_dev->command_packet_virtual_address[request_id]; + if (command_packet == NULL) { + printk(KERN_WARNING "3w-xxxx: tw_scsiop_test_unit_ready(): Bad command packet virtual address.\n"); + return 1; + } + memset(command_packet, 0, sizeof(TW_Sector)); + command_packet->byte0.opcode = TW_OP_GET_PARAM; + command_packet->byte0.sgl_offset = 2; + command_packet->size = 4; + command_packet->request_id = request_id; + command_packet->byte3.unit = 0; + command_packet->byte3.host_id = 0; + command_packet->status = 0; + command_packet->flags = 0; + command_packet->byte6.parameter_count = 1; + + /* Now setup the param */ + if (tw_dev->alignment_virtual_address[request_id] == NULL) { + printk(KERN_WARNING "3w-xxxx: tw_scsiop_test_unit_ready(): Bad alignment virtual address.\n"); + return 1; + } + param = (TW_Param *)tw_dev->alignment_virtual_address[request_id]; + memset(param, 0, sizeof(TW_Sector)); + param->table_id = 3; /* unit summary table */ + param->parameter_id = 3; /* unitsstatus parameter */ + param->parameter_size_bytes = TW_MAX_UNITS; + param_value = tw_dev->alignment_physical_address[request_id]; + if (param_value == 0) { + printk(KERN_WARNING "3w-xxxx: tw_scsiop_test_unit_ready(): Bad alignment physical address.\n"); + return 1; + } + + command_packet->byte8.param.sgl[0].address = param_value; + command_packet->byte8.param.sgl[0].length = sizeof(TW_Sector); + command_que_value = tw_dev->command_packet_physical_address[request_id]; + if (command_que_value == 0) { + printk(KERN_WARNING "3w-xxxx: tw_scsiop_test_unit_ready(): Bad command packet physical address.\n"); + return 1; + } + + /* Now try to post the command packet */ + tw_post_command_packet(tw_dev, request_id); return 0; } /* End tw_scsiop_test_unit_ready() */ +/* This function is called by the isr to complete a testunitready command */ +int tw_scsiop_test_unit_ready_complete(TW_Device_Extension *tw_dev, int request_id) +{ + unsigned char *is_unit_present; + TW_Param *param; + + dprintk(KERN_WARNING "3w-xxxx: tw_scsiop_test_unit_ready_complete()\n"); + + param = (TW_Param *)tw_dev->alignment_virtual_address[request_id]; + if (param == NULL) { + printk(KERN_WARNING "3w-xxxx: tw_scsiop_test_unit_ready_complete(): Bad alignment virtual address.\n"); + return 1; + } + is_unit_present = &(param->data[0]); + + if (is_unit_present[tw_dev->srb[request_id]->device->id] & TW_UNIT_ONLINE) { + tw_dev->is_unit_present[tw_dev->srb[request_id]->device->id] = TRUE; + } else { + tw_dev->is_unit_present[tw_dev->srb[request_id]->device->id] = FALSE; + tw_dev->srb[request_id]->result = (DID_BAD_TARGET << 16); + return TW_ISR_DONT_RESULT; + } + + return 0; +} /* End tw_scsiop_test_unit_ready_complete() */ + /* Set a value in the features table */ int tw_setfeature(TW_Device_Extension *tw_dev, int parm, int param_size, unsigned char *val) @@ -3091,17 +3376,13 @@ { dprintk(KERN_NOTICE "3w-xxxx: tw_state_request_finish()\n"); - do { - if (tw_dev->free_tail == tw_dev->free_wrap) { - tw_dev->free_tail = TW_Q_START; - } else { - tw_dev->free_tail = tw_dev->free_tail + 1; - } - } while ((tw_dev->state[tw_dev->free_queue[tw_dev->free_tail]] != TW_S_COMPLETED)); - tw_dev->free_queue[tw_dev->free_tail] = request_id; - tw_dev->state[request_id] = TW_S_FINISHED; + if (tw_dev->free_tail == tw_dev->free_wrap) + tw_dev->free_tail = TW_Q_START; + else + tw_dev->free_tail++; + dprintk(KERN_NOTICE "3w-xxxx: tw_state_request_finish(): Freeing request_id %d\n", request_id); return 0; @@ -3115,20 +3396,16 @@ dprintk(KERN_NOTICE "3w-xxxx: tw_state_request_start()\n"); /* Obtain next free request_id */ - do { - if (tw_dev->free_head == tw_dev->free_wrap) { - tw_dev->free_head = TW_Q_START; - } else { - tw_dev->free_head = tw_dev->free_head + 1; - } - } while (tw_dev->state[tw_dev->free_queue[tw_dev->free_head]] & TW_START_MASK); - id = tw_dev->free_queue[tw_dev->free_head]; + if (tw_dev->free_head == tw_dev->free_wrap) + tw_dev->free_head = TW_Q_START; + else + tw_dev->free_head++; - dprintk(KERN_NOTICE "3w-xxxx: tw_state_request_start(): id = %d.\n", id); *request_id = id; tw_dev->state[id] = TW_S_STARTED; + dprintk(KERN_NOTICE "3w-xxxx: tw_state_request_start(): id = %d.\n", id); return 0; } /* End tw_state_request_start() */ diff -Nru a/drivers/scsi/3w-xxxx.h b/drivers/scsi/3w-xxxx.h --- a/drivers/scsi/3w-xxxx.h Sun Mar 23 00:22:51 2003 +++ b/drivers/scsi/3w-xxxx.h Sun Mar 23 00:22:51 2003 @@ -6,7 +6,7 @@ Arnaldo Carvalho de Melo Brad Strand - Copyright (C) 1999-2002 3ware Inc. + Copyright (C) 1999-2003 3ware Inc. Kernel compatiblity By: Andre Hedrick Non-Copyright (C) 2000 Andre Hedrick @@ -113,11 +113,11 @@ {0x84, 0x0b, 0x47, 0x00}, // Data CRC error SCSI parity error {0xd0, 0x0b, 0x00, 0x00}, // Device busy Aborted command {0xd1, 0x0b, 0x00, 0x00}, // Device busy Aborted command + {0x37, 0x02, 0x04, 0x00}, // Unit offline Not ready /* Codes for older firmware */ // 3ware Error SCSI Error {0x09, 0x0b, 0x00, 0x00}, // Unrecovered disk error Aborted command - {0x37, 0x0b, 0x04, 0x00}, // Unit offline Logical unit not ready {0x51, 0x0b, 0x00, 0x00} // Unspecified Aborted command }; @@ -219,18 +219,23 @@ #define TW_MAX_PCI_BUSES 255 #define TW_MAX_RESET_TRIES 3 #define TW_UNIT_INFORMATION_TABLE_BASE 0x300 -#define TW_MAX_CMDS_PER_LUN 255 +#define TW_MAX_CMDS_PER_LUN 254 /* 254 for io, 1 for + chrdev ioctl, one for + internal aen post */ #define TW_BLOCK_SIZE 0x200 /* 512-byte blocks */ #define TW_IOCTL 0x80 #define TW_UNIT_ONLINE 1 #define TW_IN_INTR 1 #define TW_IN_IOCTL 2 +#define TW_IN_CHRDEV_IOCTL 3 #define TW_MAX_SECTORS 256 #define TW_AEN_WAIT_TIME 1000 #define TW_IOCTL_WAIT_TIME (1 * HZ) /* 1 second */ #define TW_ISR_DONT_COMPLETE 2 #define TW_ISR_DONT_RESULT 3 #define TW_IOCTL_TIMEOUT 25 /* 25 seconds */ +#define TW_IOCTL_CHRDEV_TIMEOUT 25 /* 25 seconds */ +#define TW_IOCTL_CHRDEV_FREE -1 /* Macros */ #define TW_STATUS_ERRORS(x) \ @@ -246,6 +251,8 @@ #define dprintk(msg...) do { } while(0) #endif +#pragma pack(1) + /* Scatter Gather List Entry */ typedef struct TAG_TW_SG_Entry { u32 address; @@ -295,6 +302,8 @@ } byte8; } TW_Command; +#pragma pack() + typedef struct TAG_TW_Ioctl { unsigned char opcode; unsigned short table_id; @@ -304,6 +313,16 @@ unsigned char data[1]; } TW_Ioctl; +#pragma pack(1) + +/* Structure for new chardev ioctls */ +typedef struct TAG_TW_New_Ioctl { + unsigned int data_buffer_length; + unsigned char padding [508]; + TW_Command firmware_command; + char data_buffer[1]; +} TW_New_Ioctl; + /* GetParam descriptor */ typedef struct { unsigned short table_id; @@ -406,6 +425,7 @@ u32 aen_count; struct Scsi_Host *host; spinlock_t tw_lock; + struct semaphore ioctl_sem; int ioctl_size[TW_Q_LENGTH]; unsigned short aen_queue[TW_Q_LENGTH]; unsigned char aen_head; @@ -414,8 +434,12 @@ unsigned long *ioctl_data[TW_Q_LENGTH]; int reset_print; char online; + volatile int chrdev_request_id; + wait_queue_head_t ioctl_wqueue; } TW_Device_Extension; +#pragma pack() + /* Function prototypes */ int tw_aen_complete(TW_Device_Extension *tw_dev, int request_id); int tw_aen_drain_queue(TW_Device_Extension *tw_dev); @@ -463,6 +487,7 @@ int tw_scsiop_request_sense(TW_Device_Extension *tw_dev, int request_id); int tw_scsiop_synchronize_cache(TW_Device_Extension *tw_dev, int request_id); int tw_scsiop_test_unit_ready(TW_Device_Extension *tw_dev, int request_id); +int tw_scsiop_test_unit_ready_complete(TW_Device_Extension *tw_dev, int request_id); int tw_setfeature(TW_Device_Extension *tw_dev, int parm, int param_size, unsigned char *val); int tw_setup_irq(TW_Device_Extension *tw_dev); @@ -483,9 +508,10 @@ .eh_abort_handler = tw_scsi_eh_abort, \ .eh_host_reset_handler = tw_scsi_eh_reset, \ .bios_param = tw_scsi_biosparam, \ - .can_queue = TW_Q_LENGTH-1, \ + .can_queue = TW_Q_LENGTH-2, \ .this_id = -1, \ .sg_tablesize = TW_MAX_SGL_LENGTH, \ + .max_sectors = TW_MAX_SECTORS, \ .cmd_per_lun = TW_MAX_CMDS_PER_LUN, \ .present = 0, \ .unchecked_isa_dma = 0, \ diff -Nru a/drivers/scsi/53c7xx.c b/drivers/scsi/53c7xx.c --- a/drivers/scsi/53c7xx.c Sun Mar 23 00:22:56 2003 +++ b/drivers/scsi/53c7xx.c Sun Mar 23 00:22:56 2003 @@ -1463,9 +1463,9 @@ patch_abs_32 (hostdata->script, 0, test_src, virt_to_bus(&hostdata->test_source)); patch_abs_32 (hostdata->script, 0, saved_dsa, - virt_to_bus(&hostdata->saved2_dsa)); + virt_to_bus((void *)&hostdata->saved2_dsa)); patch_abs_32 (hostdata->script, 0, emulfly, - virt_to_bus(&hostdata->emulated_intfly)); + virt_to_bus((void *)&hostdata->emulated_intfly)); patch_abs_rwri_data (hostdata->script, 0, dsa_check_reselect, (unsigned char)(Ent_dsa_code_check_reselect - Ent_dsa_zero)); @@ -1759,7 +1759,7 @@ static void NCR53c7xx_dsa_fixup (struct NCR53c7x0_cmd *cmd) { Scsi_Cmnd *c = cmd->cmd; - struct Scsi_Host *host = c->host; + struct Scsi_Host *host = c->device->host; struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *) host->hostdata[0]; int i; @@ -1784,18 +1784,18 @@ */ patch_abs_tci_data (cmd->dsa, Ent_dsa_code_template / sizeof(u32), - dsa_temp_lun, c->lun); + dsa_temp_lun, c->device->lun); patch_abs_32 (cmd->dsa, Ent_dsa_code_template / sizeof(u32), dsa_temp_addr_next, virt_to_bus(&cmd->dsa_next_addr)); patch_abs_32 (cmd->dsa, Ent_dsa_code_template / sizeof(u32), dsa_temp_next, virt_to_bus(cmd->dsa) + Ent_dsa_zero - Ent_dsa_code_template + A_dsa_next); patch_abs_32 (cmd->dsa, Ent_dsa_code_template / sizeof(u32), - dsa_temp_sync, virt_to_bus((void *)hostdata->sync[c->target].script)); + dsa_temp_sync, virt_to_bus((void *)hostdata->sync[c->device->id].script)); patch_abs_32 (cmd->dsa, Ent_dsa_code_template / sizeof(u32), - dsa_sscf_710, virt_to_bus((void *)&hostdata->sync[c->target].sscf_710)); + dsa_sscf_710, virt_to_bus((void *)&hostdata->sync[c->device->id].sscf_710)); patch_abs_tci_data (cmd->dsa, Ent_dsa_code_template / sizeof(u32), - dsa_temp_target, 1 << c->target); + dsa_temp_target, 1 << c->device->id); /* XXX - new pointer stuff */ patch_abs_32 (cmd->dsa, Ent_dsa_code_template / sizeof(u32), dsa_temp_addr_saved_pointer, virt_to_bus(&cmd->saved_data_pointer)); @@ -1856,7 +1856,7 @@ static void abnormal_finished (struct NCR53c7x0_cmd *cmd, int result) { Scsi_Cmnd *c = cmd->cmd; - struct Scsi_Host *host = c->host; + struct Scsi_Host *host = c->device->host; struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *) host->hostdata[0]; unsigned long flags; @@ -1940,7 +1940,7 @@ host->host_no, c->pid); else if (linux_search) { *linux_prev = linux_search->next; - --hostdata->busy[c->target][c->lun]; + --hostdata->busy[c->device->id][c->device->lun]; } /* Return the NCR command structure to the free list */ @@ -2287,9 +2287,9 @@ hostdata->dsp_changed = 1; if (cmd && (cmd->flags & CMD_FLAG_SDTR)) { printk ("scsi%d : target %d rejected SDTR\n", host->host_no, - c->target); + c->device->id); cmd->flags &= ~CMD_FLAG_SDTR; - asynchronous (host, c->target); + asynchronous (host, c->device->id); print = 0; } break; @@ -2311,7 +2311,7 @@ if (print) { printk ("scsi%d : received message", host->host_no); if (c) - printk (" from target %d lun %d ", c->target, c->lun); + printk (" from target %d lun %d ", c->device->id, c->device->lun); print_msg ((unsigned char *) hostdata->msg_buf); printk("\n"); } @@ -2331,7 +2331,7 @@ if (cmd) { char buf[80]; - sprintf (buf, "scsi%d : target %d %s ", host->host_no, c->target, + sprintf (buf, "scsi%d : target %d %s ", host->host_no, c->device->id, (cmd->flags & CMD_FLAG_SDTR) ? "accepting" : "requesting"); print_synchronous (buf, (unsigned char *) hostdata->msg_buf); @@ -2346,10 +2346,10 @@ if (cmd->flags & CMD_FLAG_SDTR) { cmd->flags &= ~CMD_FLAG_SDTR; if (hostdata->msg_buf[4]) - synchronous (host, c->target, (unsigned char *) + synchronous (host, c->device->id, (unsigned char *) hostdata->msg_buf); else - asynchronous (host, c->target); + asynchronous (host, c->device->id); hostdata->dsp = hostdata->script + hostdata->E_accept_message / sizeof(u32); hostdata->dsp_changed = 1; @@ -2357,11 +2357,11 @@ } else { if (hostdata->options & OPTION_SYNCHRONOUS) { cmd->flags |= CMD_FLAG_DID_SDTR; - synchronous (host, c->target, (unsigned char *) + synchronous (host, c->device->id, (unsigned char *) hostdata->msg_buf); } else { hostdata->msg_buf[4] = 0; /* 0 offset = async */ - asynchronous (host, c->target); + asynchronous (host, c->device->id); } patch_dsa_32 (cmd->dsa, dsa_msgout_other, 0, 5); patch_dsa_32 (cmd->dsa, dsa_msgout_other, 1, (u32) @@ -2545,9 +2545,9 @@ host->host_no, NCR53c7x0_read8(SXFER_REG)); if (c) { print_insn (host, (u32 *) - hostdata->sync[c->target].script, "", 1); + hostdata->sync[c->device->id].script, "", 1); print_insn (host, (u32 *) - hostdata->sync[c->target].script + 2, "", 1); + hostdata->sync[c->device->id].script + 2, "", 1); } } return SPECIFIC_INT_RESTART; @@ -2658,7 +2658,7 @@ if (hostdata->options & (OPTION_DEBUG_SCRIPT|OPTION_DEBUG_INTR)) { if (c) printk("scsi%d : target %d lun %d disconnecting\n", - host->host_no, c->target, c->lun); + host->host_no, c->device->id, c->device->lun); else printk("scsi%d : unknown target disconnecting\n", host->host_no); @@ -2680,9 +2680,9 @@ #endif if (c) { print_insn (host, (u32 *) - hostdata->sync[c->target].script, "", 1); + hostdata->sync[c->device->id].script, "", 1); print_insn (host, (u32 *) - hostdata->sync[c->target].script + 2, "", 1); + hostdata->sync[c->device->id].script + 2, "", 1); } } return SPECIFIC_INT_RESTART; @@ -2734,8 +2734,8 @@ if ((hostdata->chip / 100) == 8) { scntl3 = NCR53c7x0_read8 (SCNTL3_REG_800); if (c) { - if (sxfer != hostdata->sync[c->target].sxfer_sanity || - scntl3 != hostdata->sync[c->target].scntl3_sanity) { + if (sxfer != hostdata->sync[c->device->id].sxfer_sanity || + scntl3 != hostdata->sync[c->device->id].scntl3_sanity) { printk ("scsi%d : sync sanity check failed sxfer=0x%x, scntl3=0x%x", host->host_no, sxfer, scntl3); NCR53c7x0_write8 (SXFER_REG, sxfer); @@ -2746,12 +2746,12 @@ host->host_no, (int) sxfer, (int) scntl3); } else { if (c) { - if (sxfer != hostdata->sync[c->target].sxfer_sanity) { + if (sxfer != hostdata->sync[c->device->id].sxfer_sanity) { printk ("scsi%d : sync sanity check failed sxfer=0x%x", host->host_no, sxfer); NCR53c7x0_write8 (SXFER_REG, sxfer); NCR53c7x0_write8 (SBCL_REG, - hostdata->sync[c->target].sscf_710); + hostdata->sync[c->device->id].sscf_710); } } else printk ("scsi%d : unknown command sxfer=0x%x\n", @@ -2807,9 +2807,9 @@ (DCMD_REG)) == hostdata->script + Ent_select_check_dsa / sizeof(u32) ? "selection" : "reselection"; - if (c && sdid != c->target) { + if (c && sdid != c->device->id) { printk ("scsi%d : SDID target %d != DSA target %d at %s\n", - host->host_no, sdid, c->target, where); + host->host_no, sdid, c->device->id, where); print_lots(host); dump_events (host, 20); return SPECIFIC_INT_PANIC; @@ -2855,7 +2855,7 @@ if (event->event == EVENT_RESELECT) event->lun = hostdata->reselected_identify & 0xf; else if (c) - event->lun = c->lun; + event->lun = c->device->lun; else event->lun = 255; do_gettimeofday(&(event->time)); @@ -3049,7 +3049,7 @@ static struct NCR53c7x0_cmd * allocate_cmd (Scsi_Cmnd *cmd) { - struct Scsi_Host *host = cmd->host; + struct Scsi_Host *host = cmd->device->host; struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *) host->hostdata[0]; u32 real; /* Real address */ @@ -3061,8 +3061,8 @@ printk ("scsi%d : num_cmds = %d, can_queue = %d\n" " target = %d, lun = %d, %s\n", host->host_no, hostdata->num_cmds, host->can_queue, - cmd->target, cmd->lun, (hostdata->cmd_allocated[cmd->target] & - (1 << cmd->lun)) ? "already allocated" : "not allocated"); + cmd->device->id, cmd->device->lun, (hostdata->cmd_allocated[cmd->device->id] & + (1 << cmd->device->lun)) ? "already allocated" : "not allocated"); /* * If we have not yet reserved commands for this I_T_L nexus, and @@ -3070,11 +3070,11 @@ * being allocated under 1.3.x, or being outside of scan_scsis in * 1.2.x), do so now. */ - if (!(hostdata->cmd_allocated[cmd->target] & (1 << cmd->lun)) && + if (!(hostdata->cmd_allocated[cmd->device->id] & (1 << cmd->device->lun)) && cmd->device && cmd->device->has_cmdblocks) { if ((hostdata->extra_allocate + hostdata->num_cmds) < host->can_queue) hostdata->extra_allocate += host->cmd_per_lun; - hostdata->cmd_allocated[cmd->target] |= (1 << cmd->lun); + hostdata->cmd_allocated[cmd->device->id] |= (1 << cmd->device->lun); } for (; hostdata->extra_allocate > 0 ; --hostdata->extra_allocate, @@ -3130,7 +3130,7 @@ local_irq_restore(flags); if (!tmp) printk ("scsi%d : can't allocate command for target %d lun %d\n", - host->host_no, cmd->target, cmd->lun); + host->host_no, cmd->device->id, cmd->device->lun); return tmp; } @@ -3150,7 +3150,7 @@ static struct NCR53c7x0_cmd * create_cmd (Scsi_Cmnd *cmd) { NCR53c7x0_local_declare(); - struct Scsi_Host *host = cmd->host; + struct Scsi_Host *host = cmd->device->host; struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *) host->hostdata[0]; struct NCR53c7x0_cmd *tmp; /* NCR53c7x0_cmd structure for this command */ @@ -3166,7 +3166,7 @@ #endif unsigned long flags; u32 exp_select_indirect; /* Used in sanity check */ - NCR53c7x0_local_setup(cmd->host); + NCR53c7x0_local_setup(cmd->device->host); if (!(tmp = allocate_cmd (cmd))) return NULL; @@ -3322,45 +3322,45 @@ if (hostdata->options & OPTION_DEBUG_SYNCHRONOUS) { - exp_select_indirect = ((1 << cmd->target) << 16) | - (hostdata->sync[cmd->target].sxfer_sanity << 8); + exp_select_indirect = ((1 << cmd->device->id) << 16) | + (hostdata->sync[cmd->device->id].sxfer_sanity << 8); - if (hostdata->sync[cmd->target].select_indirect != + if (hostdata->sync[cmd->device->id].select_indirect != exp_select_indirect) { printk ("scsi%d : sanity check failed select_indirect=0x%x\n", - host->host_no, hostdata->sync[cmd->target].select_indirect); + host->host_no, hostdata->sync[cmd->device->id].select_indirect); FATAL(host); } } patch_dsa_32(tmp->dsa, dsa_select, 0, - hostdata->sync[cmd->target].select_indirect); + hostdata->sync[cmd->device->id].select_indirect); /* * Right now, we'll do the WIDE and SYNCHRONOUS negotiations on * different commands; although it should be trivial to do them * both at the same time. */ - if (hostdata->initiate_wdtr & (1 << cmd->target)) { + if (hostdata->initiate_wdtr & (1 << cmd->device->id)) { memcpy ((void *) (tmp->select + 1), (void *) wdtr_message, sizeof(wdtr_message)); patch_dsa_32(tmp->dsa, dsa_msgout, 0, 1 + sizeof(wdtr_message)); local_irq_save(flags); - hostdata->initiate_wdtr &= ~(1 << cmd->target); + hostdata->initiate_wdtr &= ~(1 << cmd->device->id); local_irq_restore(flags); - } else if (hostdata->initiate_sdtr & (1 << cmd->target)) { + } else if (hostdata->initiate_sdtr & (1 << cmd->device->id)) { memcpy ((void *) (tmp->select + 1), (void *) sdtr_message, sizeof(sdtr_message)); patch_dsa_32(tmp->dsa, dsa_msgout, 0, 1 + sizeof(sdtr_message)); tmp->flags |= CMD_FLAG_SDTR; local_irq_save(flags); - hostdata->initiate_sdtr &= ~(1 << cmd->target); + hostdata->initiate_sdtr &= ~(1 << cmd->device->id); local_irq_restore(flags); } #if 1 - else if (!(hostdata->talked_to & (1 << cmd->target)) && + else if (!(hostdata->talked_to & (1 << cmd->device->id)) && !(hostdata->options & OPTION_NO_ASYNC)) { memcpy ((void *) (tmp->select + 1), (void *) async_message, @@ -3372,9 +3372,9 @@ else patch_dsa_32(tmp->dsa, dsa_msgout, 0, 1); - hostdata->talked_to |= (1 << cmd->target); + hostdata->talked_to |= (1 << cmd->device->id); tmp->select[0] = (hostdata->options & OPTION_DISCONNECT) ? - IDENTIFY (1, cmd->lun) : IDENTIFY (0, cmd->lun); + IDENTIFY (1, cmd->device->lun) : IDENTIFY (0, cmd->device->lun); patch_dsa_32(tmp->dsa, dsa_msgout, 1, virt_to_bus(tmp->select)); patch_dsa_32(tmp->dsa, dsa_cmdout, 0, cmd->cmd_len); patch_dsa_32(tmp->dsa, dsa_cmdout, 1, virt_to_bus(tmp->cmnd)); @@ -3591,7 +3591,7 @@ int NCR53c7xx_queue_command (Scsi_Cmnd *cmd, void (* done)(Scsi_Cmnd *)) { - struct Scsi_Host *host = cmd->host; + struct Scsi_Host *host = cmd->device->host; struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *) host->hostdata[0]; unsigned long flags; @@ -3604,9 +3604,9 @@ #ifdef VALID_IDS /* Ignore commands on invalid IDs */ - if (!hostdata->valid_ids[cmd->target]) { + if (!hostdata->valid_ids[cmd->device->id]) { printk("scsi%d : ignoring target %d lun %d\n", host->host_no, - cmd->target, cmd->lun); + cmd->device->id, cmd->device->lun); cmd->result = (DID_BAD_TARGET << 16); done(cmd); return 0; @@ -3616,16 +3616,16 @@ local_irq_save(flags); if ((hostdata->options & (OPTION_DEBUG_INIT_ONLY|OPTION_DEBUG_PROBE_ONLY)) || ((hostdata->options & OPTION_DEBUG_TARGET_LIMIT) && - !(hostdata->debug_lun_limit[cmd->target] & (1 << cmd->lun))) + !(hostdata->debug_lun_limit[cmd->device->id] & (1 << cmd->device->lun))) #ifdef LINUX_1_2 - || cmd->target > 7 + || cmd->device->id > 7 #else - || cmd->target > host->max_id + || cmd->device->id > host->max_id #endif - || cmd->target == host->this_id + || cmd->device->id == host->this_id || hostdata->state == STATE_DISABLED) { printk("scsi%d : disabled or bad target %d lun %d\n", host->host_no, - cmd->target, cmd->lun); + cmd->device->id, cmd->device->lun); cmd->result = (DID_BAD_TARGET << 16); done(cmd); local_irq_restore(flags); @@ -3738,7 +3738,7 @@ --i, ncrcurrent += 2 /* JUMP instructions are two words */); if (i > 0) { - ++hostdata->busy[tmp->target][tmp->lun]; + ++hostdata->busy[tmp->device->id][tmp->device->lun]; cmd->next = hostdata->running_list; hostdata->running_list = cmd; @@ -3799,7 +3799,7 @@ /* FIXME : in the future, this needs to accommodate SCSI-II tagged queuing, and we may be able to play with fairness here a bit. */ - return hostdata->busy[cmd->target][cmd->lun]; + return hostdata->busy[cmd->device->id][cmd->device->lun]; } /* @@ -3873,7 +3873,7 @@ if (tmp->host_scribble) { if (hostdata->options & OPTION_DEBUG_QUEUES) printk ("scsi%d : moving command for target %d lun %d to start list\n", - host->host_no, tmp->target, tmp->lun); + host->host_no, tmp->device->id, tmp->device->lun); to_schedule_list (host, hostdata, @@ -3937,7 +3937,7 @@ printk ("scsi%d : Selection Timeout\n", host->host_no); if (cmd) { printk("scsi%d : target %d, lun %d, command ", - host->host_no, cmd->cmd->target, cmd->cmd->lun); + host->host_no, cmd->cmd->device->id, cmd->cmd->device->lun); print_command (cmd->cmd->cmnd); printk("scsi%d : dsp = 0x%x (virt 0x%p)\n", host->host_no, NCR53c7x0_read32(DSP_REG), @@ -3975,7 +3975,7 @@ fatal = 1; if (cmd) { printk("scsi%d : target %d lun %d unexpected disconnect\n", - host->host_no, cmd->cmd->target, cmd->cmd->lun); + host->host_no, cmd->cmd->device->id, cmd->cmd->device->lun); print_lots (host); abnormal_finished(cmd, DID_ERROR << 16); } else @@ -3991,7 +3991,7 @@ fatal = 1; if (cmd && cmd->cmd) { printk("scsi%d : target %d lun %d parity error.\n", - host->host_no, cmd->cmd->target, cmd->cmd->lun); + host->host_no, cmd->cmd->device->id, cmd->cmd->device->lun); abnormal_finished (cmd, DID_PARITY << 16); } else printk("scsi%d : parity error\n", host->host_no); @@ -4199,7 +4199,7 @@ if (cmd_prev_ptr) *cmd_prev_ptr = (struct NCR53c7x0_cmd *) cmd->next; - --hostdata->busy[tmp->target][tmp->lun]; + --hostdata->busy[tmp->device->id][tmp->device->lun]; cmd->next = hostdata->free; hostdata->free = cmd; @@ -4207,7 +4207,7 @@ if (hostdata->options & OPTION_DEBUG_INTR) { printk ("scsi%d : command complete : pid %lu, id %d,lun %d result 0x%x ", - host->host_no, tmp->pid, tmp->target, tmp->lun, tmp->result); + host->host_no, tmp->pid, tmp->device->id, tmp->device->lun, tmp->result); print_command (tmp->cmnd); } @@ -4292,8 +4292,8 @@ if (hostdata->options & OPTION_DEBUG_INTR) { if (cmd) { printk("scsi%d : interrupt for pid %lu, id %d, lun %d ", - host->host_no, cmd->cmd->pid, (int) cmd->cmd->target, - (int) cmd->cmd->lun); + host->host_no, cmd->cmd->pid, (int) cmd->cmd->device->id, + (int) cmd->cmd->device->lun); print_command (cmd->cmd->cmnd); } else { printk("scsi%d : no active command\n", host->host_no); @@ -4671,7 +4671,7 @@ hostdata->dsp = dsp + 2 /* two _words_ */; hostdata->dsp_changed = 1; printk ("scsi%d : target %d ignored SDTR and went into COMMAND OUT\n", - host->host_no, cmd->cmd->target); + host->host_no, cmd->cmd->device->id); cmd->flags &= ~CMD_FLAG_SDTR; action = ACTION_CONTINUE; break; @@ -5136,7 +5136,7 @@ int NCR53c7xx_abort (Scsi_Cmnd *cmd) { NCR53c7x0_local_declare(); - struct Scsi_Host *host = cmd->host; + struct Scsi_Host *host = cmd->device->host; struct NCR53c7x0_hostdata *hostdata = host ? (struct NCR53c7x0_hostdata *) host->hostdata[0] : NULL; unsigned long flags; @@ -5242,7 +5242,7 @@ return SCSI_ABORT_NOT_RUNNING; } else { printk ("scsi%d : DANGER : command running, can not abort.\n", - cmd->host->host_no); + cmd->device->host->host_no); local_irq_restore(flags); return SCSI_ABORT_BUSY; } @@ -5273,7 +5273,7 @@ * command was ever counted as BUSY, so if we end up here we can * decrement the busy count if and only if it is necessary. */ - --hostdata->busy[cmd->target][cmd->lun]; + --hostdata->busy[cmd->device->id][cmd->device->lun]; } local_irq_restore(flags); cmd->scsi_done(cmd); @@ -5318,7 +5318,7 @@ * each command. */ Scsi_Cmnd *nuke_list = NULL; - struct Scsi_Host *host = cmd->host; + struct Scsi_Host *host = cmd->device->host; struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *) host->hostdata[0]; @@ -5388,7 +5388,7 @@ static int insn_to_offset (Scsi_Cmnd *cmd, u32 *insn) { struct NCR53c7x0_hostdata *hostdata = - (struct NCR53c7x0_hostdata *) cmd->host->hostdata[0]; + (struct NCR53c7x0_hostdata *) cmd->device->host->hostdata[0]; struct NCR53c7x0_cmd *ncmd = (struct NCR53c7x0_cmd *) cmd->host_scribble; int offset = 0, buffers; @@ -5418,7 +5418,7 @@ --buffers, offset += segment->length, ++segment) #if 0 printk("scsi%d: comparing 0x%p to 0x%p\n", - cmd->host->host_no, saved, page_address(segment->page+segment->offset); + cmd->device->host->host_no, saved, page_address(segment->page+segment->offset); #else ; #endif @@ -5456,7 +5456,7 @@ int offset, i; char *where; u32 *ptr; - NCR53c7x0_local_setup (cmd->host); + NCR53c7x0_local_setup (cmd->device->host); if (check_address ((unsigned long) ncmd,sizeof (struct NCR53c7x0_cmd)) == 0) { @@ -5484,15 +5484,15 @@ if (offset != -1) printk ("scsi%d : %s data pointer at offset %d\n", - cmd->host->host_no, where, offset); + cmd->device->host->host_no, where, offset); else { int size; printk ("scsi%d : can't determine %s data pointer offset\n", - cmd->host->host_no, where); + cmd->device->host->host_no, where); if (ncmd) { - size = print_insn (cmd->host, + size = print_insn (cmd->device->host, bus_to_virt(ncmd->saved_data_pointer), "", 1); - print_insn (cmd->host, + print_insn (cmd->device->host, bus_to_virt(ncmd->saved_data_pointer) + size * sizeof(u32), "", 1); } @@ -5549,7 +5549,7 @@ /* XXX Maybe we should access cmd->host_scribble->result here. RGH */ if (cmd) { printk(" result = 0x%x, target = %d, lun = %d, cmd = ", - cmd->result, cmd->target, cmd->lun); + cmd->result, cmd->device->id, cmd->device->lun); print_command(cmd->cmnd); } else printk("\n"); @@ -5558,11 +5558,11 @@ if (cmd) { printk("scsi%d target %d : sxfer_sanity = 0x%x, scntl3_sanity = 0x%x\n" " script : ", - host->host_no, cmd->target, - hostdata->sync[cmd->target].sxfer_sanity, - hostdata->sync[cmd->target].scntl3_sanity); - for (i = 0; i < (sizeof(hostdata->sync[cmd->target].script) / 4); ++i) - printk ("0x%x ", hostdata->sync[cmd->target].script[i]); + host->host_no, cmd->device->id, + hostdata->sync[cmd->device->id].sxfer_sanity, + hostdata->sync[cmd->device->id].scntl3_sanity); + for (i = 0; i < (sizeof(hostdata->sync[cmd->device->id].script) / 4); ++i) + printk ("0x%x ", hostdata->sync[cmd->device->id].script[i]); printk ("\n"); print_progress (cmd); } @@ -5604,7 +5604,7 @@ -> dsa, ""); } else printk ("scsi%d : scsi pid %ld for target %d lun %d has no NCR53c7x0_cmd\n", - host->host_no, cmd->pid, cmd->target, cmd->lun); + host->host_no, cmd->pid, cmd->device->id, cmd->device->lun); local_irq_restore(flags); } diff -Nru a/drivers/scsi/NCR53C9x.c b/drivers/scsi/NCR53C9x.c --- a/drivers/scsi/NCR53C9x.c Sun Mar 23 00:22:51 2003 +++ b/drivers/scsi/NCR53C9x.c Sun Mar 23 00:22:51 2003 @@ -1099,7 +1099,7 @@ * disconnect. */ ESPMISC(("esp: Selecting device for first time. target=%d " - "lun=%d\n", target, SCptr->lun)); + "lun=%d\n", target, SCptr->device->lun)); if(!SDptr->borken && !esp_dev->disconnect) esp_dev->disconnect = 1; @@ -1173,7 +1173,7 @@ if(((SDptr->scsi_level < 3) && (SDptr->type != TYPE_TAPE)) || toshiba_cdrom_hwbug_wkaround || SDptr->borken) { ESPMISC((KERN_INFO "esp%d: Disabling DISCONNECT for target %d " - "lun %d\n", esp->esp_id, SCptr->target, SCptr->lun)); + "lun %d\n", esp->esp_id, SCptr->device->id, SCptr->device->lun)); esp_dev->disconnect = 0; *cmdp++ = IDENTIFY(0, lun); } else { @@ -1255,8 +1255,8 @@ esp->dma_led_on(esp); /* We use the scratch area. */ - ESPQUEUE(("esp_queue: target=%d lun=%d ", SCpnt->target, SCpnt->lun)); - ESPDISC(("N<%02x,%02x>", SCpnt->target, SCpnt->lun)); + ESPQUEUE(("esp_queue: target=%d lun=%d ", SCpnt->device->id, SCpnt->lun)); + ESPDISC(("N<%02x,%02x>", SCpnt->device->id, SCpnt->lun)); esp_get_dmabufs(esp, SCpnt); esp_save_pointers(esp, SCpnt); /* FIXME for tag queueing */ @@ -2235,7 +2235,7 @@ * state. */ ESPMISC(("esp: Status <%d> for target %d lun %d\n", - SCptr->SCp.Status, SCptr->target, SCptr->lun)); + SCptr->SCp.Status, SCptr->device->id, SCptr->device->lun)); /* But don't do this when spinning up a disk at * boot time while we poll for completion as it @@ -2246,14 +2246,14 @@ if(esp_should_clear_sync(SCptr) != 0) esp_dev->sync = 0; } - ESPDISC(("F<%02x,%02x>", SCptr->target, SCptr->lun)); + ESPDISC(("F<%02x,%02x>", SCptr->device->id, SCptr->device->lun)); esp_done(esp, ((SCptr->SCp.Status & 0xff) | ((SCptr->SCp.Message & 0xff)<<8) | (DID_OK << 16))); } else if(esp->prevmsgin == DISCONNECT) { /* Normal disconnect. */ esp_cmd(esp, eregs, ESP_CMD_ESEL); - ESPDISC(("D<%02x,%02x>", SCptr->target, SCptr->lun)); + ESPDISC(("D<%02x,%02x>", SCptr->device->id, SCptr->device->lun)); append_SC(&esp->disconnected_SC, SCptr); esp->current_SC = NULL; if(esp->issue_SC) @@ -2811,7 +2811,7 @@ /* Else, there really isn't anyone there. */ ESPMISC(("esp: selection failure, maybe nobody there?\n")); ESPMISC(("esp: target %d lun %d\n", - SCptr->target, SCptr->lun)); + SCptr->device->id, SCptr->device->lun)); esp_done(esp, (DID_BAD_TARGET << 16)); } return do_intr_end; @@ -3084,7 +3084,7 @@ ESPSDTR(("soff=%2x stp=%2x cfg3=%2x\n", esp_dev->sync_max_offset, esp_dev->sync_min_period, - esp->config3[SCptr->target])); + esp->config3[SCptr->device->id])); esp->snip = 0; } else if(esp_dev->sync_max_offset) { diff -Nru a/drivers/scsi/a2091.c b/drivers/scsi/a2091.c --- a/drivers/scsi/a2091.c Sun Mar 23 00:22:53 2003 +++ b/drivers/scsi/a2091.c Sun Mar 23 00:22:53 2003 @@ -52,7 +52,7 @@ { unsigned short cntr = CNTR_PDMD | CNTR_INTEN; unsigned long addr = virt_to_bus(cmd->SCp.ptr); - struct Scsi_Host *instance = cmd->host; + struct Scsi_Host *instance = cmd->device->host; /* don't allow DMA if the physical address is bad */ if (addr & A2091_XFER_MASK || @@ -102,12 +102,12 @@ cntr |= CNTR_DDIR; /* remember direction */ - HDATA(cmd->host)->dma_dir = dir_in; + HDATA(cmd->device->host)->dma_dir = dir_in; - DMA(cmd->host)->CNTR = cntr; + DMA(cmd->device->host)->CNTR = cntr; /* setup DMA *physical* address */ - DMA(cmd->host)->ACR = addr; + DMA(cmd->device->host)->ACR = addr; if (dir_in){ /* invalidate any cache */ @@ -117,7 +117,7 @@ cache_push (addr, cmd->SCp.this_residual); } /* start DMA */ - DMA(cmd->host)->ST_DMA = 1; + DMA(cmd->device->host)->ST_DMA = 1; /* return success */ return 0; diff -Nru a/drivers/scsi/a3000.c b/drivers/scsi/a3000.c --- a/drivers/scsi/a3000.c Sun Mar 23 00:22:54 2003 +++ b/drivers/scsi/a3000.c Sun Mar 23 00:22:54 2003 @@ -225,7 +225,7 @@ #include "scsi_module.c" -int __exit a3000_release(struct Scsi_Host *instance) +int a3000_release(struct Scsi_Host *instance) { wd33c93_release(); DMA(instance)->CNTR = 0; diff -Nru a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c --- a/drivers/scsi/advansys.c Sun Mar 23 00:22:51 2003 +++ b/drivers/scsi/advansys.c Sun Mar 23 00:22:51 2003 @@ -7099,7 +7099,7 @@ * then return the number of underrun bytes. */ if (scp->request_bufflen != 0 && qdonep->remain_bytes != 0 && - qdonep->remain_bytes <= scp->request_bufflen != 0) { + qdonep->remain_bytes <= scp->request_bufflen) { ASC_DBG1(1, "asc_isr_callback: underrun condition %u bytes\n", (unsigned) qdonep->remain_bytes); scp->resid = qdonep->remain_bytes; diff -Nru a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c --- a/drivers/scsi/aha152x.c Sun Mar 23 00:22:50 2003 +++ b/drivers/scsi/aha152x.c Sun Mar 23 00:22:50 2003 @@ -2651,7 +2651,7 @@ static void datai_run(struct Scsi_Host *shpnt) { - unsigned int the_time; + unsigned long the_time; int fifodata, data_count; /* @@ -2793,7 +2793,7 @@ static void datao_run(struct Scsi_Host *shpnt) { - unsigned int the_time; + unsigned long the_time; int data_count; /* until phase changes or all data sent */ diff -Nru a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c --- a/drivers/scsi/aha1542.c Sun Mar 23 00:22:53 2003 +++ b/drivers/scsi/aha1542.c Sun Mar 23 00:22:53 2003 @@ -1020,7 +1020,7 @@ static int __init do_setup(char *str) { - int ints[4]; + int ints[5]; int count=setup_idx; diff -Nru a/drivers/scsi/amiga7xx.c b/drivers/scsi/amiga7xx.c --- a/drivers/scsi/amiga7xx.c Sun Mar 23 00:22:52 2003 +++ b/drivers/scsi/amiga7xx.c Sun Mar 23 00:22:52 2003 @@ -86,7 +86,7 @@ #ifdef CONFIG_WARPENGINE_SCSI case ZORRO_PROD_MACROSYSTEMS_WARP_ENGINE_40xx: if (request_mem_region(address+0x40000, 0x1000, "ncr53c710")) { - address = (unsigned long)ioremap(address, size); + address = (unsigned long)z_ioremap(address, size); options = OPTION_MEMORY_MAPPED | OPTION_DEBUG_TEST1 | OPTION_INTFLY | OPTION_SYNCHRONOUS | OPTION_ALWAYS_SYNCHRONOUS | OPTION_DISCONNECT; @@ -102,7 +102,7 @@ case ZORRO_PROD_CBM_A4091_1: case ZORRO_PROD_CBM_A4091_2: if (request_mem_region(address+0x800000, 0x1000, "ncr53c710")) { - address = (unsigned long)ioremap(address, size); + address = (unsigned long)z_ioremap(address, size); options = OPTION_MEMORY_MAPPED | OPTION_DEBUG_TEST1 | OPTION_INTFLY | OPTION_SYNCHRONOUS | OPTION_ALWAYS_SYNCHRONOUS | OPTION_DISCONNECT; diff -Nru a/drivers/scsi/atari_NCR5380.c b/drivers/scsi/atari_NCR5380.c --- a/drivers/scsi/atari_NCR5380.c Sun Mar 23 00:22:53 2003 +++ b/drivers/scsi/atari_NCR5380.c Sun Mar 23 00:22:53 2003 @@ -266,7 +266,7 @@ #define NEXTADDR(cmd) ((Scsi_Cmnd **)&((cmd)->host_scribble)) #define HOSTNO instance->host_no -#define H_NO(cmd) (cmd)->host->host_no +#define H_NO(cmd) (cmd)->device->host->host_no #ifdef SUPPORT_TAGS @@ -350,17 +350,17 @@ static int is_lun_busy( Scsi_Cmnd *cmd, int should_be_tagged ) { - SETUP_HOSTDATA(cmd->host); + SETUP_HOSTDATA(cmd->device->host); - if (hostdata->busy[cmd->target] & (1 << cmd->lun)) + if (hostdata->busy[cmd->device->id] & (1 << cmd->device->lun)) return( 1 ); if (!should_be_tagged || !setup_use_tagged_queuing || !cmd->device->tagged_supported) return( 0 ); - if (TagAlloc[cmd->target][cmd->lun].nr_allocated >= - TagAlloc[cmd->target][cmd->lun].queue_size ) { + if (TagAlloc[cmd->device->id][cmd->device->lun].nr_allocated >= + TagAlloc[cmd->device->id][cmd->device->lun].queue_size ) { TAG_PRINTK( "scsi%d: target %d lun %d: no free tags\n", - H_NO(cmd), cmd->target, cmd->lun ); + H_NO(cmd), cmd->device->id, cmd->device->lun ); return( 1 ); } return( 0 ); @@ -374,7 +374,7 @@ static void cmd_get_tag( Scsi_Cmnd *cmd, int should_be_tagged ) { - SETUP_HOSTDATA(cmd->host); + SETUP_HOSTDATA(cmd->device->host); /* If we or the target don't support tagged queuing, allocate the LUN for * an untagged command. @@ -382,19 +382,19 @@ if (!should_be_tagged || !setup_use_tagged_queuing || !cmd->device->tagged_supported) { cmd->tag = TAG_NONE; - hostdata->busy[cmd->target] |= (1 << cmd->lun); + hostdata->busy[cmd->device->id] |= (1 << cmd->device->lun); TAG_PRINTK( "scsi%d: target %d lun %d now allocated by untagged " - "command\n", H_NO(cmd), cmd->target, cmd->lun ); + "command\n", H_NO(cmd), cmd->device->id, cmd->device->lun ); } else { - TAG_ALLOC *ta = &TagAlloc[cmd->target][cmd->lun]; + TAG_ALLOC *ta = &TagAlloc[cmd->device->id][cmd->device->lun]; cmd->tag = find_first_zero_bit( ta->allocated, MAX_TAGS ); set_bit( cmd->tag, ta->allocated ); ta->nr_allocated++; TAG_PRINTK( "scsi%d: using tag %d for target %d lun %d " "(now %d tags in use)\n", - H_NO(cmd), cmd->tag, cmd->target, cmd->lun, + H_NO(cmd), cmd->tag, cmd->device->id, cmd->device->lun, ta->nr_allocated ); } } @@ -406,23 +406,23 @@ static void cmd_free_tag( Scsi_Cmnd *cmd ) { - SETUP_HOSTDATA(cmd->host); + SETUP_HOSTDATA(cmd->device->host); if (cmd->tag == TAG_NONE) { - hostdata->busy[cmd->target] &= ~(1 << cmd->lun); + hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun); TAG_PRINTK( "scsi%d: target %d lun %d untagged cmd finished\n", - H_NO(cmd), cmd->target, cmd->lun ); + H_NO(cmd), cmd->device->id, cmd->device->lun ); } else if (cmd->tag >= MAX_TAGS) { printk(KERN_NOTICE "scsi%d: trying to free bad tag %d!\n", H_NO(cmd), cmd->tag ); } else { - TAG_ALLOC *ta = &TagAlloc[cmd->target][cmd->lun]; + TAG_ALLOC *ta = &TagAlloc[cmd->device->id][cmd->device->lun]; clear_bit( cmd->tag, ta->allocated ); ta->nr_allocated--; TAG_PRINTK( "scsi%d: freed tag %d for target %d lun %d\n", - H_NO(cmd), cmd->tag, cmd->target, cmd->lun ); + H_NO(cmd), cmd->tag, cmd->device->id, cmd->device->lun ); } } @@ -811,7 +811,7 @@ int i, s; unsigned char *command; SPRINTF("scsi%d: destination target %d, lun %d\n", - H_NO(cmd), cmd->target, cmd->lun); + H_NO(cmd), cmd->device->id, cmd->device->lun); SPRINTF(" command = "); command = cmd->cmnd; SPRINTF("%2d (0x%02x)", command[0], command[0]); @@ -834,7 +834,7 @@ * */ -static void __init NCR5380_init (struct Scsi_Host *instance, int flags) +static int NCR5380_init (struct Scsi_Host *instance, int flags) { int i; SETUP_HOSTDATA(instance); @@ -878,6 +878,8 @@ NCR5380_write(MODE_REG, MR_BASE); NCR5380_write(TARGET_COMMAND_REG, 0); NCR5380_write(SELECT_ENABLE_REG, 0); + + return 0; } /* @@ -898,13 +900,10 @@ * */ -/* Only make static if a wrapper function is used */ -#ifndef NCR5380_queue_command static -#endif int NCR5380_queue_command (Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *)) { - SETUP_HOSTDATA(cmd->host); + SETUP_HOSTDATA(cmd->device->host); Scsi_Cmnd *tmp; int oldto; unsigned long flags; @@ -938,15 +937,15 @@ case WRITE: case WRITE_6: case WRITE_10: - hostdata->time_write[cmd->target] -= (jiffies - hostdata->timebase); - hostdata->bytes_write[cmd->target] += cmd->request_bufflen; + hostdata->time_write[cmd->device->id] -= (jiffies - hostdata->timebase); + hostdata->bytes_write[cmd->device->id] += cmd->request_bufflen; hostdata->pendingw++; break; case READ: case READ_6: case READ_10: - hostdata->time_read[cmd->target] -= (jiffies - hostdata->timebase); - hostdata->bytes_read[cmd->target] += cmd->request_bufflen; + hostdata->time_read[cmd->device->id] -= (jiffies - hostdata->timebase); + hostdata->bytes_read[cmd->device->id] += cmd->request_bufflen; hostdata->pendingr++; break; } @@ -1014,7 +1013,7 @@ if (in_interrupt() || ((flags >> 8) & 7) >= 6) queue_main(); else - NCR5380_main(); + NCR5380_main(NULL); return 0; } @@ -1030,7 +1029,7 @@ * reenable them. This prevents reentrancy and kernel stack overflow. */ -static void NCR5380_main (void) +static void NCR5380_main (void *bl) { Scsi_Cmnd *tmp, *prev; struct Scsi_Host *instance = first_instance; @@ -1087,8 +1086,8 @@ #if (NDEBUG & NDEBUG_LISTS) if (prev != tmp) printk("MAIN tmp=%p target=%d busy=%d lun=%d\n", - tmp, tmp->target, hostdata->busy[tmp->target], - tmp->lun); + tmp, tmp->device->id, hostdata->busy[tmp->device->id], + tmp->device->lun); #endif /* When we find one, remove it from the issue queue. */ /* ++guenther: possible race with Falcon locking */ @@ -1096,7 +1095,7 @@ #ifdef SUPPORT_TAGS !is_lun_busy( tmp, tmp->cmnd[0] != REQUEST_SENSE) #else - !(hostdata->busy[tmp->target] & (1 << tmp->lun)) + !(hostdata->busy[tmp->device->id] & (1 << tmp->device->lun)) #endif ) { /* ++guenther: just to be sure, this must be atomic */ @@ -1122,7 +1121,7 @@ */ MAIN_PRINTK("scsi%d: main(): command for target %d " "lun %d removed from issue_queue\n", - HOSTNO, tmp->target, tmp->lun); + HOSTNO, tmp->device->id, tmp->device->lun); /* * REQUEST SENSE commands are issued without tagged * queueing, even on SCSI-II devices because the @@ -1356,15 +1355,15 @@ case WRITE: case WRITE_6: case WRITE_10: - hostdata->time_write[cmd->target] += (jiffies - hostdata->timebase); - /*hostdata->bytes_write[cmd->target] += cmd->request_bufflen;*/ + hostdata->time_write[cmd->device->id] += (jiffies - hostdata->timebase); + /*hostdata->bytes_write[cmd->device->id] += cmd->request_bufflen;*/ hostdata->pendingw--; break; case READ: case READ_6: case READ_10: - hostdata->time_read[cmd->target] += (jiffies - hostdata->timebase); - /*hostdata->bytes_read[cmd->target] += cmd->request_bufflen;*/ + hostdata->time_read[cmd->device->id] += (jiffies - hostdata->timebase); + /*hostdata->bytes_read[cmd->device->id] += cmd->request_bufflen;*/ hostdata->pendingr--; break; } @@ -1525,7 +1524,7 @@ * the host and target ID's on the SCSI bus. */ - NCR5380_write(OUTPUT_DATA_REG, (hostdata->id_mask | (1 << cmd->target))); + NCR5380_write(OUTPUT_DATA_REG, (hostdata->id_mask | (1 << cmd->device->id))); /* * Raise ATN while SEL is true before BSY goes false from arbitration, @@ -1578,7 +1577,7 @@ udelay(1); - SEL_PRINTK("scsi%d: selecting target %d\n", HOSTNO, cmd->target); + SEL_PRINTK("scsi%d: selecting target %d\n", HOSTNO, cmd->device->id); /* * The SCSI specification calls for a 250 ms timeout for the actual @@ -1629,7 +1628,7 @@ if (!(NCR5380_read(STATUS_REG) & SR_BSY)) { NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); - if (hostdata->targets_present & (1 << cmd->target)) { + if (hostdata->targets_present & (1 << cmd->device->id)) { printk(KERN_ERR "scsi%d: weirdness\n", HOSTNO); if (hostdata->restart_select) printk(KERN_NOTICE "\trestart select\n"); @@ -1651,7 +1650,7 @@ return 0; } - hostdata->targets_present |= (1 << cmd->target); + hostdata->targets_present |= (1 << cmd->device->id); /* * Since we followed the SCSI spec, and raised ATN while SEL @@ -1672,8 +1671,8 @@ while (!(NCR5380_read(STATUS_REG) & SR_REQ)); SEL_PRINTK("scsi%d: target %d selected, going into MESSAGE OUT phase.\n", - HOSTNO, cmd->target); - tmp[0] = IDENTIFY(1, cmd->lun); + HOSTNO, cmd->device->id); + tmp[0] = IDENTIFY(1, cmd->device->lun); #ifdef SUPPORT_TAGS if (cmd->tag != TAG_NONE) { @@ -1695,7 +1694,7 @@ /* XXX need to handle errors here */ hostdata->connected = cmd; #ifndef SUPPORT_TAGS - hostdata->busy[cmd->target] |= (1 << cmd->lun); + hostdata->busy[cmd->device->id] |= (1 << cmd->device->lun); #endif initialize_SCp(cmd); @@ -2085,7 +2084,7 @@ * polled-IO. */ printk(KERN_NOTICE "scsi%d: switching target %d " "lun %d to slow handshake\n", HOSTNO, - cmd->target, cmd->lun); + cmd->device->id, cmd->device->lun); cmd->device->borken = 1; NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN); @@ -2137,7 +2136,7 @@ NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); LNK_PRINTK("scsi%d: target %d lun %d linked command " - "complete.\n", HOSTNO, cmd->target, cmd->lun); + "complete.\n", HOSTNO, cmd->device->id, cmd->device->lun); /* Enable reselect interrupts */ NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask); @@ -2150,7 +2149,7 @@ if (!cmd->next_link) { printk(KERN_NOTICE "scsi%d: target %d lun %d " "linked command complete, no next_link\n", - HOSTNO, cmd->target, cmd->lun); + HOSTNO, cmd->device->id, cmd->device->lun); sink = 1; do_abort (instance); return; @@ -2163,7 +2162,7 @@ cmd->result = cmd->SCp.Status | (cmd->SCp.Message << 8); LNK_PRINTK("scsi%d: target %d lun %d linked request " "done, calling scsi_done().\n", - HOSTNO, cmd->target, cmd->lun); + HOSTNO, cmd->device->id, cmd->device->lun); #ifdef NCR5380_STATS collect_stats(hostdata, cmd); #endif @@ -2179,7 +2178,7 @@ falcon_dont_release++; hostdata->connected = NULL; QU_PRINTK("scsi%d: command for target %d, lun %d " - "completed\n", HOSTNO, cmd->target, cmd->lun); + "completed\n", HOSTNO, cmd->device->id, cmd->device->lun); #ifdef SUPPORT_TAGS cmd_free_tag( cmd ); if (status_byte(cmd->SCp.Status) == QUEUE_FULL) { @@ -2191,16 +2190,16 @@ */ /* ++Andreas: the mid level code knows about QUEUE_FULL now. */ - TAG_ALLOC *ta = &TagAlloc[cmd->target][cmd->lun]; + TAG_ALLOC *ta = &TagAlloc[cmd->device->id][cmd->device->lun]; TAG_PRINTK("scsi%d: target %d lun %d returned " "QUEUE_FULL after %d commands\n", - HOSTNO, cmd->target, cmd->lun, + HOSTNO, cmd->device->id, cmd->device->lun, ta->nr_allocated); if (ta->queue_size > ta->nr_allocated) ta->nr_allocated = ta->queue_size; } #else - hostdata->busy[cmd->target] &= ~(1 << cmd->lun); + hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun); #endif /* Enable reselect interrupts */ NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask); @@ -2296,12 +2295,12 @@ * the command is treated as untagged further on. */ cmd->device->tagged_supported = 0; - hostdata->busy[cmd->target] |= (1 << cmd->lun); + hostdata->busy[cmd->device->id] |= (1 << cmd->device->lun); cmd->tag = TAG_NONE; TAG_PRINTK("scsi%d: target %d lun %d rejected " "QUEUE_TAG message; tagged queuing " "disabled\n", - HOSTNO, cmd->target, cmd->lun); + HOSTNO, cmd->device->id, cmd->device->lun); break; } break; @@ -2318,7 +2317,7 @@ QU_PRINTK("scsi%d: command for target %d lun %d was " "moved from connected to the " "disconnected_queue\n", HOSTNO, - cmd->target, cmd->lun); + cmd->device->id, cmd->device->lun); /* * Restore phase bits to 0 so an interrupted selection, * arbitration can resume. @@ -2417,13 +2416,13 @@ } else if (tmp != EXTENDED_MESSAGE) printk(KERN_DEBUG "scsi%d: rejecting unknown " "message %02x from target %d, lun %d\n", - HOSTNO, tmp, cmd->target, cmd->lun); + HOSTNO, tmp, cmd->device->id, cmd->device->lun); else printk(KERN_DEBUG "scsi%d: rejecting unknown " "extended message " "code %02x, length %d from target %d, lun %d\n", HOSTNO, extended_msg[1], extended_msg[0], - cmd->target, cmd->lun); + cmd->device->id, cmd->device->lun); msgout = MESSAGE_REJECT; @@ -2441,7 +2440,7 @@ #ifdef SUPPORT_TAGS cmd_free_tag( cmd ); #else - hostdata->busy[cmd->target] &= ~(1 << cmd->lun); + hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun); #endif hostdata->connected = NULL; cmd->result = DID_ERROR << 16; @@ -2577,7 +2576,7 @@ for (tmp = (Scsi_Cmnd *) hostdata->disconnected_queue, prev = NULL; tmp; prev = tmp, tmp = NEXT(tmp) ) { - if ((target_mask == (1 << tmp->target)) && (lun == tmp->lun) + if ((target_mask == (1 << tmp->device->id)) && (lun == tmp->device->lun) #ifdef SUPPORT_TAGS && (tag == tmp->tag) #endif @@ -2620,7 +2619,7 @@ hostdata->connected = tmp; RSL_PRINTK("scsi%d: nexus established, target = %d, lun = %d, tag = %d\n", - HOSTNO, tmp->target, tmp->lun, tmp->tag); + HOSTNO, tmp->device->id, tmp->device->lun, tmp->tag); falcon_dont_release--; } @@ -2642,12 +2641,10 @@ * called where the loop started in NCR5380_main(). */ -#ifndef NCR5380_abort static -#endif int NCR5380_abort (Scsi_Cmnd *cmd) { - struct Scsi_Host *instance = cmd->host; + struct Scsi_Host *instance = cmd->device->host; SETUP_HOSTDATA(instance); Scsi_Cmnd *tmp, **prev; unsigned long flags; @@ -2701,7 +2698,7 @@ #ifdef SUPPORT_TAGS cmd_free_tag( cmd ); #else - hostdata->busy[cmd->target] &= ~(1 << cmd->lun); + hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun); #endif local_irq_restore(flags); cmd->scsi_done(cmd); @@ -2808,7 +2805,7 @@ #ifdef SUPPORT_TAGS cmd_free_tag( tmp ); #else - hostdata->busy[cmd->target] &= ~(1 << cmd->lun); + hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun); #endif local_irq_restore(flags); tmp->scsi_done(tmp); @@ -2842,7 +2839,7 @@ /* - * Function : int NCR5380_reset (Scsi_Cmnd *cmd, unsigned int reset_flags) + * Function : int NCR5380_reset (Scsi_Cmnd *cmd) * * Purpose : reset the SCSI bus. * @@ -2850,9 +2847,9 @@ * */ -static int NCR5380_reset( Scsi_Cmnd *cmd, unsigned int reset_flags) +static int NCR5380_bus_reset( Scsi_Cmnd *cmd) { - SETUP_HOSTDATA(cmd->host); + SETUP_HOSTDATA(cmd->device->host); int i; unsigned long flags; #if 1 @@ -2863,7 +2860,7 @@ printk(KERN_ERR "scsi%d: !!BINGO!! Falcon has no lock in NCR5380_reset\n", H_NO(cmd) ); - NCR5380_print_status (cmd->host); + NCR5380_print_status (cmd->device->host); /* get in phase */ NCR5380_write( TARGET_COMMAND_REG, diff -Nru a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c --- a/drivers/scsi/atari_scsi.c Sun Mar 23 00:22:56 2003 +++ b/drivers/scsi/atari_scsi.c Sun Mar 23 00:22:56 2003 @@ -819,11 +819,11 @@ #endif } -int atari_scsi_reset( Scsi_Cmnd *cmd, unsigned int reset_flags) +int atari_scsi_bus_reset(Scsi_Cmnd *cmd) { int rv; struct NCR5380_hostdata *hostdata = - (struct NCR5380_hostdata *)cmd->host->hostdata; + (struct NCR5380_hostdata *)cmd->device->host->hostdata; /* For doing the reset, SCSI interrupts must be disabled first, * since the 5380 raises its IRQ line while _RST is active and we @@ -845,7 +845,7 @@ #endif /* REAL_DMA */ } - rv = NCR5380_reset(cmd, reset_flags); + rv = NCR5380_bus_reset(cmd); /* Re-enable ints */ if (IS_A_TT()) { @@ -1146,8 +1146,8 @@ .release = atari_scsi_release, .info = atari_scsi_info, .queuecommand = atari_scsi_queue_command, - .abort = atari_scsi_abort, - .reset = atari_scsi_reset, + .eh_abort_handler = atari_scsi_abort, + .eh_bus_reset_handler = atari_scsi_bus_reset, .can_queue = 0, /* initialized at run-time */ .this_id = 0, /* initialized at run-time */ .sg_tablesize = 0, /* initialized at run-time */ diff -Nru a/drivers/scsi/atari_scsi.h b/drivers/scsi/atari_scsi.h --- a/drivers/scsi/atari_scsi.h Sun Mar 23 00:22:53 2003 +++ b/drivers/scsi/atari_scsi.h Sun Mar 23 00:22:53 2003 @@ -18,10 +18,8 @@ /* (I_HAVE_OVERRUNS stuff removed) */ #ifndef ASM -int atari_scsi_abort (Scsi_Cmnd *); int atari_scsi_detect (Scsi_Host_Template *); const char *atari_scsi_info (struct Scsi_Host *); -int atari_scsi_queue_command (Scsi_Cmnd *, void (*done) (Scsi_Cmnd *)); int atari_scsi_reset (Scsi_Cmnd *, unsigned int); int atari_scsi_proc_info (char *, char **, off_t, int, int, int); #ifdef MODULE diff -Nru a/drivers/scsi/blz1230.c b/drivers/scsi/blz1230.c --- a/drivers/scsi/blz1230.c Sun Mar 23 00:22:54 2003 +++ b/drivers/scsi/blz1230.c Sun Mar 23 00:22:54 2003 @@ -167,8 +167,8 @@ esp->eregs = eregs; /* Set the command buffer */ - esp->esp_command = (volatile unsigned char*) cmd_buffer; - esp->esp_command_dvma = virt_to_bus(cmd_buffer); + esp->esp_command = cmd_buffer; + esp->esp_command_dvma = virt_to_bus((void *)cmd_buffer); esp->irq = IRQ_AMIGA_PORTS; esp->slot = board+REAL_BLZ1230_ESP_ADDR; diff -Nru a/drivers/scsi/blz2060.c b/drivers/scsi/blz2060.c --- a/drivers/scsi/blz2060.c Sun Mar 23 00:22:52 2003 +++ b/drivers/scsi/blz2060.c Sun Mar 23 00:22:52 2003 @@ -142,8 +142,8 @@ esp->eregs = (struct ESP_regs *)(address + BLZ2060_ESP_ADDR); /* Set the command buffer */ - esp->esp_command = (volatile unsigned char*) cmd_buffer; - esp->esp_command_dvma = virt_to_bus(cmd_buffer); + esp->esp_command = cmd_buffer; + esp->esp_command_dvma = virt_to_bus((void *)cmd_buffer); esp->irq = IRQ_AMIGA_PORTS; request_irq(IRQ_AMIGA_PORTS, esp_intr, SA_SHIRQ, diff -Nru a/drivers/scsi/cpqfcTSinit.c b/drivers/scsi/cpqfcTSinit.c --- a/drivers/scsi/cpqfcTSinit.c Sun Mar 23 00:22:50 2003 +++ b/drivers/scsi/cpqfcTSinit.c Sun Mar 23 00:22:50 2003 @@ -686,7 +686,7 @@ if( (vendor_cmd->rw_flag == VENDOR_READ_OPCODE) && vendor_cmd->len ) if( copy_to_user( vendor_cmd->bufp, buf, vendor_cmd->len)) - return( -EFAULT); + result = -EFAULT; if( buf) kfree( buf); diff -Nru a/drivers/scsi/cyberstorm.c b/drivers/scsi/cyberstorm.c --- a/drivers/scsi/cyberstorm.c Sun Mar 23 00:22:55 2003 +++ b/drivers/scsi/cyberstorm.c Sun Mar 23 00:22:55 2003 @@ -168,8 +168,8 @@ esp->eregs = (struct ESP_regs *)(address + CYBER_ESP_ADDR); /* Set the command buffer */ - esp->esp_command = (volatile unsigned char*) cmd_buffer; - esp->esp_command_dvma = virt_to_bus(cmd_buffer); + esp->esp_command = cmd_buffer; + esp->esp_command_dvma = virt_to_bus((void *)cmd_buffer); esp->irq = IRQ_AMIGA_PORTS; request_irq(IRQ_AMIGA_PORTS, esp_intr, SA_SHIRQ, diff -Nru a/drivers/scsi/cyberstormII.c b/drivers/scsi/cyberstormII.c --- a/drivers/scsi/cyberstormII.c Sun Mar 23 00:22:55 2003 +++ b/drivers/scsi/cyberstormII.c Sun Mar 23 00:22:55 2003 @@ -149,8 +149,8 @@ esp->eregs = eregs; /* Set the command buffer */ - esp->esp_command = (volatile unsigned char*) cmd_buffer; - esp->esp_command_dvma = virt_to_bus(cmd_buffer); + esp->esp_command = cmd_buffer; + esp->esp_command_dvma = virt_to_bus((void *)cmd_buffer); esp->irq = IRQ_AMIGA_PORTS; request_irq(IRQ_AMIGA_PORTS, esp_intr, SA_SHIRQ, diff -Nru a/drivers/scsi/fastlane.c b/drivers/scsi/fastlane.c --- a/drivers/scsi/fastlane.c Sun Mar 23 00:22:52 2003 +++ b/drivers/scsi/fastlane.c Sun Mar 23 00:22:52 2003 @@ -191,8 +191,8 @@ esp->edev = (void *) address; /* Set the command buffer */ - esp->esp_command = (volatile unsigned char*) cmd_buffer; - esp->esp_command_dvma = virt_to_bus(cmd_buffer); + esp->esp_command = cmd_buffer; + esp->esp_command_dvma = virt_to_bus((void *)cmd_buffer); esp->irq = IRQ_AMIGA_PORTS; esp->slot = board+FASTLANE_ESP_ADDR; diff -Nru a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c --- a/drivers/scsi/gdth.c Sun Mar 23 00:22:54 2003 +++ b/drivers/scsi/gdth.c Sun Mar 23 00:22:54 2003 @@ -4,7 +4,7 @@ * Intel Corporation: Storage RAID Controllers * * * * gdth.c * - * Copyright (C) 1995-02 ICP vortex, an Intel company, Achim Leubner * + * Copyright (C) 1995-03 ICP vortex, an Intel company, Achim Leubner * * * * * * Additions/Fixes: Boji Tony Kannanthanam * @@ -24,11 +24,17 @@ * along with this kernel; if not, write to the Free Software * * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * * - * Tested with Linux 1.2.13, ..., 2.2.20, ..., 2.4.18 * + * Tested with Linux 1.2.13, ..., 2.2.20, ..., 2.4.20 * * * * $Log: gdth.c,v $ - * Revision 1.61 2002/10/03 09:35:22 boji - * Fixed SCREENSERVICE initialisation in SMP cases. + * Revision 1.62 2003/02/27 15:01:59 achim + * Dynamic DMA mapping implemented + * New (character device) IOCTL interface added + * Other controller related changes made + * + * Revision 1.61 2002/11/08 13:09:52 boji + * Added support for XSCALE based RAID Controllers + * Fixed SCREENSERVICE initialization in SMP cases * Added checks for gdth_polling before GDTH_HA_LOCK * * Revision 1.60 2002/02/05 09:35:22 achim @@ -216,7 +222,7 @@ * * Revision 1.9 1997/09/04 10:07:25 achim * IO-mapping with virt_to_bus(), gdth_readb(), gdth_writeb(), ... - * register_reboot_notifier() to get a notify on shutdown used + * register_reboot_notifier() to get a notify on shutown used * * Revision 1.8 1997/04/02 12:14:30 achim * Version 1.00 (see gdth.h), tested with kernel 2.0.29 @@ -248,7 +254,7 @@ * Initial revision * ************************************************************************/ -#ident "$Id: gdth.c,v 1.60 2002/02/05 09:35:22 achim Exp $" +#ident "$Id: gdth.c,v 1.62 2003/02/27 15:01:59 achim Exp $" /* All GDT Disk Array Controllers are fully supported by this driver. * This includes the PCI/EISA/ISA SCSI Disk Array Controllers and the @@ -300,18 +306,21 @@ */ /* The meaning of the Scsi_Pointer members in this driver is as follows: - * ptr: Chaining - * this_residual: Command priority - * buffer: Unused - * buffers_residual: Timeout value - * Status: Command status (gdth_do_cmd()) - * Message: Additional info (gdth_do_cmd()) - * have_data_in: Flag for gdth_wait_completion() - * sent_command: Opcode special command - * phase: Service/parameter/return code special command + * ptr: Chaining + * this_residual: Command priority + * buffer: phys. DMA sense buffer + * dma_handle: phys. DMA buffer (kernel >= 2.4.0) + * buffers_residual: Timeout value + * Status: Command status (gdth_do_cmd()), DMA mem. mappings + * Message: Additional info (gdth_do_cmd()), DMA direction + * have_data_in: Flag for gdth_wait_completion() + * sent_command: Opcode special command + * phase: Service/parameter/return code special command */ -#error Please convert me to Documentation/DMA-mapping.txt +/* default: activate /proc and character device IOCTL interface */ +#define GDTH_IOCTL_PROC +#define GDTH_IOCTL_CHRDEV #include @@ -324,6 +333,7 @@ #include #include #include +#include #include #include #include @@ -340,6 +350,7 @@ #include #include #include +#include #if LINUX_VERSION_CODE >= 0x020322 #include #elif LINUX_VERSION_CODE >= 0x02015F @@ -353,6 +364,9 @@ #endif #include "scsi.h" #include "hosts.h" +#if LINUX_VERSION_CODE < 0x020503 +#include "sd.h" +#endif #include "gdth.h" @@ -378,7 +392,8 @@ gdth_evt_str *estr); static void gdth_clear_events(void); -static void gdth_copy_internal_data(Scsi_Cmnd *scp,char *buffer,ushort count); +static void gdth_copy_internal_data(int hanum,Scsi_Cmnd *scp, + char *buffer,ushort count); static int gdth_internal_cache_cmd(int hanum,Scsi_Cmnd *scp); static int gdth_fill_cache_cmd(int hanum,Scsi_Cmnd *scp,ushort hdrive); @@ -408,6 +423,13 @@ static const char *gdth_ctr_name(int hanum); +#ifdef GDTH_IOCTL_CHRDEV +static int gdth_open(struct inode *inode, struct file *filep); +static int gdth_close(struct inode *inode, struct file *filep); +static int gdth_ioctl(struct inode *inode, struct file *filep, + unsigned int cmd, unsigned long arg); +#endif + #if LINUX_VERSION_CODE >= 0x010300 static void gdth_flush(int hanum); #if LINUX_VERSION_CODE >= 0x020100 @@ -604,6 +626,9 @@ static gdth_evt_str ebuffer[MAX_EVENTS]; /* event buffer */ static int elastidx; static int eoldidx; +#ifdef GDTH_IOCTL_CHRDEV +static int major; +#endif #define DIN 1 /* IN data direction */ #define DOU 2 /* OUT data direction */ @@ -641,24 +666,35 @@ #define __init #endif -#if LINUX_VERSION_CODE >= 0x02015F +#if LINUX_VERSION_CODE >= 0x020503 +#define GDTH_INIT_LOCK_HA(ha) spin_lock_init(&(ha)->smp_lock) +#define GDTH_LOCK_HA(ha,flags) spin_lock_irqsave(&(ha)->smp_lock,flags) +#define GDTH_UNLOCK_HA(ha,flags) spin_unlock_irqrestore(&(ha)->smp_lock,flags) + +#define GDTH_LOCK_SCSI_DONE(dev, flags) spin_lock_irqsave(dev->host_lock,flags) +#define GDTH_UNLOCK_SCSI_DONE(dev, flags) spin_unlock_irqrestore(dev->host_lock,flags) +#define GDTH_LOCK_SCSI_DOCMD(dev) spin_lock_irq(dev->host_lock) +#define GDTH_UNLOCK_SCSI_DOCMD(dev) spin_unlock_irq(dev->host_lock) + +#elif LINUX_VERSION_CODE >= 0x02015F #define GDTH_INIT_LOCK_HA(ha) spin_lock_init(&(ha)->smp_lock) #define GDTH_LOCK_HA(ha,flags) spin_lock_irqsave(&(ha)->smp_lock,flags) #define GDTH_UNLOCK_HA(ha,flags) spin_unlock_irqrestore(&(ha)->smp_lock,flags) -#define GDTH_LOCK_SCSI_DONE(dev, flags) spin_lock_irqsave(dev->host_lock,flags) -#define GDTH_UNLOCK_SCSI_DONE(flags) spin_unlock_irqrestore(dev->host_lock,flags) -#define GDTH_LOCK_SCSI_DOCMD(dev) spin_lock_irq(dev->host_lock) -#define GDTH_UNLOCK_SCSI_DOCMD(dev) spin_unlock_irq(dev->host_lock) +#define GDTH_LOCK_SCSI_DONE(flags) spin_lock_irqsave(&io_request_lock,flags) +#define GDTH_UNLOCK_SCSI_DONE(flags) spin_unlock_irqrestore(&io_request_lock,flags) +#define GDTH_LOCK_SCSI_DOCMD() spin_lock_irq(&io_request_lock) +#define GDTH_UNLOCK_SCSI_DOCMD() spin_unlock_irq(&io_request_lock) + #else #define GDTH_INIT_LOCK_HA(ha) do {} while (0) #define GDTH_LOCK_HA(ha,flags) do {save_flags(flags); cli();} while (0) #define GDTH_UNLOCK_HA(ha,flags) do {restore_flags(flags);} while (0) -#define GDTH_LOCK_SCSI_DONE(dev, flags) do {} while (0) -#define GDTH_UNLOCK_SCSI_DONE(dev, flags) do {} while (0) -#define GDTH_LOCK_SCSI_DOCMD(dev) do {} while (0) -#define GDTH_UNLOCK_SCSI_DOCMD(dev) do {} while (0) +#define GDTH_LOCK_SCSI_DONE(flags) do {} while (0) +#define GDTH_UNLOCK_SCSI_DONE(flags) do {} while (0) +#define GDTH_LOCK_SCSI_DOCMD() do {} while (0) +#define GDTH_UNLOCK_SCSI_DOCMD() do {} while (0) #endif /* LILO and modprobe/insmod parameters */ @@ -702,10 +738,21 @@ MODULE_PARM(virt_ctr, "i"); MODULE_PARM(shared_access, "i"); MODULE_AUTHOR("Achim Leubner"); +#endif +#if LINUX_VERSION_CODE >= 0x02040B MODULE_LICENSE("GPL"); #endif #endif +#ifdef GDTH_IOCTL_CHRDEV +/* ioctl interface */ +static struct file_operations gdth_fops = { + ioctl:gdth_ioctl, + open:gdth_open, + release:gdth_close, +}; +#endif + /* /proc support */ #if LINUX_VERSION_CODE >= 0x010300 #include @@ -813,6 +860,8 @@ PCI_DEVICE_ID_VORTEX_GDTNEWRX); gdth_search_dev(pcistr, &cnt, PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SRC); + gdth_search_dev(pcistr, &cnt, PCI_VENDOR_ID_INTEL, + PCI_DEVICE_ID_INTEL_SRC_XSCALE); return cnt; } @@ -820,10 +869,11 @@ /* Vortex only makes RAID controllers. * We do not really want to specify all 550 ids here, so wildcard match. */ -static struct pci_device_id gdthtable[] = { - {PCI_VENDOR_ID_VORTEX,PCI_ANY_ID,PCI_ANY_ID, PCI_ANY_ID }, - {PCI_VENDOR_ID_INTEL,PCI_DEVICE_ID_INTEL_SRC,PCI_ANY_ID,PCI_ANY_ID }, - {0} +static struct pci_device_id gdthtable[] __devinitdata = { + {PCI_VENDOR_ID_VORTEX,PCI_ANY_ID,PCI_ANY_ID, PCI_ANY_ID}, + {PCI_VENDOR_ID_INTEL,PCI_DEVICE_ID_INTEL_SRC,PCI_ANY_ID,PCI_ANY_ID}, + {PCI_VENDOR_ID_INTEL,PCI_DEVICE_ID_INTEL_SRC_XSCALE,PCI_ANY_ID,PCI_ANY_ID}, + {0} }; MODULE_DEVICE_TABLE(pci,gdthtable); #endif @@ -1235,6 +1285,9 @@ ha->stype = (ulong32)pcistr->device_id; ha->subdevice_id = pcistr->subdevice_id; ha->irq = pcistr->irq; +#if LINUX_VERSION_CODE >= 0x20400 + ha->pdev = pcistr->pdev; +#endif if (ha->stype <= PCI_DEVICE_ID_VORTEX_GDT6000B) { /* GDT6000/B */ TRACE2(("init_pci() dpmem %lx irq %d\n",pcistr->dpmem,ha->irq)); @@ -1511,6 +1564,11 @@ PCI_ROM_ADDRESS, rom_addr); #endif + /* Ensure that it is safe to access the non HW portions of DPMEM. + * Aditional check needed for Xscale based RAID controllers */ + while( ((int)gdth_readb(&((gdt6m_dpram_str *)ha->brd)->i960r.sema0_reg) ) & 3 ) + gdth_delay(1); + /* check and reset interface area */ dp6m_ptr = (gdt6m_dpram_str *)ha->brd; gdth_writel(DPMEM_MAGIC, &dp6m_ptr->u); @@ -1840,7 +1898,7 @@ if (ha->type == GDT_EISA) { if (ha->pccb->OpCode == GDT_INIT) /* store DMA buffer */ - outl(virt_to_bus(ha->pccb), ha->bmic + MAILBOXREG); + outl(ha->ccb_phys, ha->bmic + MAILBOXREG); outb(ha->pccb->Service, ha->bmic + LDOORREG); } else if (ha->type == GDT_ISA) { gdth_writeb(0, &((gdt2_dpram_str *)ha->brd)->io.event); @@ -1916,7 +1974,7 @@ cmd_ptr->u.ioctl.subfunc = p1; cmd_ptr->u.ioctl.channel = p2; cmd_ptr->u.ioctl.param_size = (ushort)p3; - cmd_ptr->u.ioctl.p_param = virt_to_bus(ha->pscratch); + cmd_ptr->u.ioctl.p_param = ha->scratch_phys; } else { cmd_ptr->u.cache.DeviceNo = (ushort)p1; cmd_ptr->u.cache.BlockNo = p2; @@ -1965,6 +2023,8 @@ gdth_raw_iochan_str *iocr; gdth_arcdl_str *alst; gdth_alist_str *alst2; + gdth_oem_str_ioctl *oemstr; + #ifdef GDTH_RTC unchar rtc[12]; ulong flags; @@ -2233,6 +2293,27 @@ } } + /* Determine OEM string using IOCTL */ + oemstr = (gdth_oem_str_ioctl *)ha->pscratch; + oemstr->params.ctl_version = 0x01; + oemstr->params.buffer_size = sizeof(oemstr->text); + if (gdth_internal_cmd(hanum,CACHESERVICE,GDT_IOCTL, + CACHE_READ_OEM_STRING_RECORD,INVALID_CHANNEL, + sizeof(gdth_oem_str_ioctl))) { + TRACE2(("gdth_search_drives(): CACHE_READ_OEM_STRING_RECORD OK\n")); + printk("GDT CTR%d Vendor: %s\n",hanum,oemstr->text.oem_company_name); + /* Save the Host Drive inquiry data */ + strncpy(ha->oem_name,oemstr->text.scsi_host_drive_inquiry_vendor_id,7); + ha->oem_name[7] = '\0'; + } else { + /* Old method, based on PCI ID */ + TRACE2(("gdth_search_drives(): CACHE_READ_OEM_STRING_RECORD failed\n")); + if (ha->oem_id == OEM_ID_INTEL) + strcpy(ha->oem_name,"Intel "); + else + strcpy(ha->oem_name,"ICP "); + } + /* scanning for host drives */ for (i = 0; i < cdev_cnt; ++i) gdth_analyse_hdrive(hanum,i); @@ -2313,8 +2394,13 @@ GDTH_LOCK_HA(ha, flags); scp->SCp.this_residual = (int)priority; +#if LINUX_VERSION_CODE >= 0x02053C b = virt_ctr ? NUMDATA(scp->device->host)->busnum : scp->device->channel; t = scp->device->id; +#else + b = virt_ctr ? NUMDATA(scp->host)->busnum : scp->channel; + t = scp->target; +#endif #if LINUX_VERSION_CODE >= 0x010300 if (priority >= DEFAULT_PRI) { if ((b != ha->virt_bus && ha->raw[BUS_L2P(ha,b)].lock) || @@ -2357,7 +2443,7 @@ register gdth_ha_str *ha; register Scsi_Cmnd *pscp; register Scsi_Cmnd *nscp; - unchar b, t, firsttime; + unchar b, t, l, firsttime; unchar this_cmd, next_cmd; ulong flags = 0; int cmd_index; @@ -2365,7 +2451,7 @@ TRACE(("gdth_next() hanum %d\n",hanum)); ha = HADATA(gdth_ctr_tab[hanum]); if (!gdth_polling) - GDTH_LOCK_HA(ha, flags); + GDTH_LOCK_HA(ha, flags); ha->cmd_cnt = ha->cmd_offs_dpmem = 0; this_cmd = firsttime = TRUE; @@ -2375,8 +2461,15 @@ for (nscp = pscp = ha->req_first; nscp; nscp = (Scsi_Cmnd *)nscp->SCp.ptr) { if (nscp != pscp && nscp != (Scsi_Cmnd *)pscp->SCp.ptr) pscp = (Scsi_Cmnd *)pscp->SCp.ptr; +#if LINUX_VERSION_CODE >= 0x02053C b = virt_ctr ? NUMDATA(nscp->device->host)->busnum : nscp->device->channel; t = nscp->device->id; + l = nscp->device->lun; +#else + b = virt_ctr ? NUMDATA(nscp->host)->busnum : nscp->channel; + t = nscp->target; + l = nscp->lun; +#endif if (nscp->SCp.this_residual >= DEFAULT_PRI) { if ((b != ha->virt_bus && ha->raw[BUS_L2P(ha,b)].lock) || (b == ha->virt_bus && t < MAX_HDRIVES && ha->hdr[t].lock)) @@ -2404,16 +2497,16 @@ nscp->SCp.phase = CACHESERVICE; /* default: cache svc. */ if (nscp->cmnd[0] == TEST_UNIT_READY) { TRACE2(("TEST_UNIT_READY Bus %d Id %d LUN %d\n", - b, t, nscp->lun)); + b, t, l)); /* TEST_UNIT_READY -> set scan mode */ if ((ha->scan_mode & 0x0f) == 0) { - if (b == 0 && t == 0 && nscp->device->lun == 0) { + if (b == 0 && t == 0 && l == 0) { ha->scan_mode |= 1; TRACE2(("Scan mode: 0x%x\n", ha->scan_mode)); } } else if ((ha->scan_mode & 0x0f) == 1) { - if (b == 0 && ((t == 0 && nscp->device->lun == 1) || - (t == 1 && nscp->device->lun == 0))) { + if (b == 0 && ((t == 0 && l == 1) || + (t == 1 && l == 0))) { nscp->SCp.sent_command = GDT_SCAN_START; nscp->SCp.phase = ((ha->scan_mode & 0x10 ? 1:0) << 8) | SCSIRAWSERVICE; @@ -2465,7 +2558,7 @@ /* io_request_lock already active ! */ nscp->scsi_done(nscp); if (!gdth_polling) - GDTH_LOCK_HA(ha,flags); + GDTH_LOCK_HA(ha,flags); } } } else @@ -2483,19 +2576,19 @@ this_cmd = FALSE; else ha->raw[BUS_L2P(ha,b)].io_cnt[t]++; - } else if (t >= MAX_HDRIVES || !ha->hdr[t].present || nscp->device->lun != 0) { + } else if (t >= MAX_HDRIVES || !ha->hdr[t].present || l != 0) { TRACE2(("Command 0x%x to bus %d id %d lun %d -> IGNORE\n", - nscp->cmnd[0], b, t, nscp->lun)); + nscp->cmnd[0], b, t, l)); nscp->result = DID_BAD_TARGET << 16; if (!nscp->SCp.have_data_in) nscp->SCp.have_data_in++; else { if (!gdth_polling) - GDTH_UNLOCK_HA(ha,flags); + GDTH_UNLOCK_HA(ha,flags); /* io_request_lock already active ! */ nscp->scsi_done(nscp); if (!gdth_polling) - GDTH_LOCK_HA(ha,flags); + GDTH_LOCK_HA(ha,flags); } } else { switch (nscp->cmnd[0]) { @@ -2521,20 +2614,20 @@ if (!nscp->SCp.have_data_in) nscp->SCp.have_data_in++; else { - if (!gdth_polling) - GDTH_UNLOCK_HA(ha,flags); + if (!gdth_polling) + GDTH_UNLOCK_HA(ha,flags); /* io_request_lock already active ! */ nscp->scsi_done(nscp); - if (!gdth_polling) - GDTH_LOCK_HA(ha,flags); + if (!gdth_polling) + GDTH_LOCK_HA(ha,flags); } } else if (gdth_internal_cache_cmd(hanum,nscp)) { if (!gdth_polling) - GDTH_UNLOCK_HA(ha,flags); + GDTH_UNLOCK_HA(ha,flags); /* io_request_lock already active ! */ nscp->scsi_done(nscp); if (!gdth_polling) - GDTH_LOCK_HA(ha,flags); + GDTH_LOCK_HA(ha,flags); } break; @@ -2549,12 +2642,12 @@ if (!nscp->SCp.have_data_in) nscp->SCp.have_data_in++; else { - if (!gdth_polling) - GDTH_UNLOCK_HA(ha,flags); + if (!gdth_polling) + GDTH_UNLOCK_HA(ha,flags); /* io_request_lock already active ! */ nscp->scsi_done(nscp); - if (!gdth_polling) - GDTH_LOCK_HA(ha,flags); + if (!gdth_polling) + GDTH_LOCK_HA(ha,flags); } } else { nscp->cmnd[3] = (ha->hdr[t].devtype&1) ? 1:0; @@ -2589,12 +2682,12 @@ if (!nscp->SCp.have_data_in) nscp->SCp.have_data_in++; else { - if (!gdth_polling) - GDTH_UNLOCK_HA(ha,flags); + if (!gdth_polling) + GDTH_UNLOCK_HA(ha,flags); /* io_request_lock already active ! */ nscp->scsi_done(nscp); - if (!gdth_polling) - GDTH_LOCK_HA(ha,flags); + if (!gdth_polling) + GDTH_LOCK_HA(ha,flags); } } else if (!(cmd_index=gdth_fill_cache_cmd(hanum,nscp,t))) this_cmd = FALSE; @@ -2611,11 +2704,11 @@ nscp->SCp.have_data_in++; else { if (!gdth_polling) - GDTH_UNLOCK_HA(ha,flags); + GDTH_UNLOCK_HA(ha,flags); /* io_request_lock already active ! */ nscp->scsi_done(nscp); if (!gdth_polling) - GDTH_LOCK_HA(ha,flags); + GDTH_LOCK_HA(ha,flags); } break; } @@ -2636,7 +2729,7 @@ } if (!gdth_polling) - GDTH_UNLOCK_HA(ha, flags); + GDTH_UNLOCK_HA(ha, flags); if (gdth_polling && ha->cmd_cnt > 0) { if (!gdth_wait(hanum,cmd_index,POLL_TIMEOUT)) @@ -2645,27 +2738,54 @@ } } -static void gdth_copy_internal_data(Scsi_Cmnd *scp,char *buffer,ushort count) +static void gdth_copy_internal_data(int hanum,Scsi_Cmnd *scp, + char *buffer,ushort count) { ushort cpcount,i; ushort cpsum,cpnow; struct scatterlist *sl; + gdth_ha_str *ha; + int sgcnt; + char *address; cpcount = count<=(ushort)scp->bufflen ? count:(ushort)scp->bufflen; + ha = HADATA(gdth_ctr_tab[hanum]); + if (scp->use_sg) { sl = (struct scatterlist *)scp->request_buffer; - for (i=0,cpsum=0; iuse_sg; ++i,++sl) { - cpnow = (ushort)sl->length; +#if LINUX_VERSION_CODE >= 0x020400 + sgcnt = pci_map_sg(ha->pdev,sl,scp->use_sg,PCI_DMA_FROMDEVICE); + for (i=0,cpsum=0; ibufflen)); if (cpsum+cpnow > cpcount) cpnow = cpcount - cpsum; cpsum += cpnow; - memcpy((char*)sl->address,buffer,cpnow); + address = (char *)phys_to_virt(sg_dma_address(sl)); + memcpy(address,buffer,cpnow); + if (cpsum == cpcount) + break; + buffer += cpnow; + } + pci_unmap_sg(ha->pdev,scp->request_buffer, + scp->use_sg,PCI_DMA_FROMDEVICE); +#else + sgcnt = scp->use_sg; + for (i=0,cpsum=0; ilength; + TRACE(("copy_internal() now %d sum %d count %d %d\n", + cpnow,cpsum,cpcount,(ushort)scp->bufflen)); + if (cpsum+cpnow > cpcount) + cpnow = cpcount - cpsum; + cpsum += cpnow; + address = (char *)sl->address; + memcpy(address,buffer,cpnow); if (cpsum == cpcount) break; buffer += cpnow; } +#endif } else { TRACE(("copy_internal() count %d\n",cpcount)); memcpy((char*)scp->request_buffer,buffer,cpcount); @@ -2682,7 +2802,11 @@ gdth_modep_data mpd; ha = HADATA(gdth_ctr_tab[hanum]); +#if LINUX_VERSION_CODE >= 0x02053C t = scp->device->id; +#else + t = scp->target; +#endif TRACE(("gdth_internal_cache_cmd() cmd 0x%x hdrive %d\n", scp->cmnd[0],t)); @@ -2706,13 +2830,10 @@ inq.version = 2; inq.resp_aenc = 2; inq.add_length= 32; - if (ha->oem_id == OEM_ID_INTEL) - strcpy(inq.vendor,"Intel "); - else - strcpy(inq.vendor,"ICP "); + strcpy(inq.vendor,ha->oem_name); sprintf(inq.product,"Host Drive #%02d",t); strcpy(inq.revision," "); - gdth_copy_internal_data(scp,(char*)&inq,sizeof(gdth_inq_data)); + gdth_copy_internal_data(hanum,scp,(char*)&inq,sizeof(gdth_inq_data)); break; case REQUEST_SENSE: @@ -2722,7 +2843,7 @@ sd.key = NO_SENSE; sd.info = 0; sd.add_length= 0; - gdth_copy_internal_data(scp,(char*)&sd,sizeof(gdth_sense_data)); + gdth_copy_internal_data(hanum,scp,(char*)&sd,sizeof(gdth_sense_data)); break; case MODE_SENSE: @@ -2734,14 +2855,14 @@ mpd.bd.block_length[0] = (SECTOR_SIZE & 0x00ff0000) >> 16; mpd.bd.block_length[1] = (SECTOR_SIZE & 0x0000ff00) >> 8; mpd.bd.block_length[2] = (SECTOR_SIZE & 0x000000ff); - gdth_copy_internal_data(scp,(char*)&mpd,sizeof(gdth_modep_data)); + gdth_copy_internal_data(hanum,scp,(char*)&mpd,sizeof(gdth_modep_data)); break; case READ_CAPACITY: TRACE2(("Read capacity hdrive %d\n",t)); rdc.last_block_no = ntohl(ha->hdr[t].size-1); rdc.block_length = ntohl(SECTOR_SIZE); - gdth_copy_internal_data(scp,(char*)&rdc,sizeof(gdth_rdcap_data)); + gdth_copy_internal_data(hanum,scp,(char*)&rdc,sizeof(gdth_rdcap_data)); break; default: @@ -2766,8 +2887,8 @@ register gdth_cmd_str *cmdp; struct scatterlist *sl; ushort i, cnt; - ulong32 no; - int cmd_index, read_write; + ulong32 no, phys_addr; + int cmd_index, read_write, sgcnt; ha = HADATA(gdth_ctr_tab[hanum]); cmdp = ha->pccb; @@ -2789,7 +2910,7 @@ gdth_set_sema0(hanum); /* fill command */ - read_write = FALSE; + read_write = 0; if (scp->SCp.sent_command != -1) cmdp->OpCode = scp->SCp.sent_command; /* special cache cmd. */ else if (scp->cmnd[0] == RESERVE) @@ -2803,15 +2924,16 @@ cmdp->OpCode = GDT_UNMOUNT; else cmdp->OpCode = GDT_FLUSH; - } else if (scp->cmnd[0] == WRITE_6 || scp->cmnd[0] == WRITE_10) { - read_write = TRUE; + } else if (scp->cmnd[0] == WRITE_6 || scp->cmnd[0] == WRITE_10 || + scp->cmnd[0] == WRITE_12) { + read_write = 1; if (gdth_write_through || ((ha->hdr[hdrive].rw_attribs & 1) && (ha->cache_feat & GDT_WR_THROUGH))) cmdp->OpCode = GDT_WRITE_THR; else cmdp->OpCode = GDT_WRITE; } else { - read_write = TRUE; + read_write = 2; cmdp->OpCode = GDT_READ; } @@ -2835,10 +2957,22 @@ if (scp->use_sg) { cmdp->u.cache.DestAddr= 0xffffffff; sl = (struct scatterlist *)scp->request_buffer; - for (i=0; iuse_sg; ++i,++sl) { + sgcnt = scp->use_sg; +#if LINUX_VERSION_CODE >= 0x020400 + scp->SCp.Status = GDTH_MAP_SG; + scp->SCp.Message = (read_write == 1 ? + PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE); + sgcnt = pci_map_sg(ha->pdev,sl,scp->use_sg,scp->SCp.Message); + for (i=0; iu.cache.sg_lst[i].sg_ptr = sg_dma_address(sl); + cmdp->u.cache.sg_lst[i].sg_len = sg_dma_len(sl); + } +#else + for (i=0; iu.cache.sg_lst[i].sg_ptr = virt_to_bus(sl->address); cmdp->u.cache.sg_lst[i].sg_len = (ulong32)sl->length; } +#endif cmdp->u.cache.sg_canz = (ulong32)i; #ifdef GDTH_STATISTICS @@ -2850,15 +2984,24 @@ if (iu.cache.sg_lst[i].sg_len = 0; } else { +#if LINUX_VERSION_CODE >= 0x020400 + scp->SCp.Status = GDTH_MAP_SINGLE; + scp->SCp.Message = (read_write == 1 ? + PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE); + phys_addr = pci_map_single(ha->pdev,scp->request_buffer, + scp->request_bufflen,scp->SCp.Message); + scp->SCp.dma_handle = phys_addr; +#else + phys_addr = virt_to_bus(scp->request_buffer); +#endif if (ha->cache_feat & SCATTER_GATHER) { cmdp->u.cache.DestAddr = 0xffffffff; cmdp->u.cache.sg_canz = 1; - cmdp->u.cache.sg_lst[0].sg_ptr = - virt_to_bus(scp->request_buffer); + cmdp->u.cache.sg_lst[0].sg_ptr = phys_addr; cmdp->u.cache.sg_lst[0].sg_len = scp->request_bufflen; cmdp->u.cache.sg_lst[1].sg_len = 0; } else { - cmdp->u.cache.DestAddr = virt_to_bus(scp->request_buffer); + cmdp->u.cache.DestAddr = phys_addr; cmdp->u.cache.sg_canz= 0; } } @@ -2896,12 +3039,18 @@ register gdth_cmd_str *cmdp; struct scatterlist *sl; ushort i; - int cmd_index; + ulong32 phys_addr, sense_paddr; + int cmd_index, sgcnt; unchar t,l; ha = HADATA(gdth_ctr_tab[hanum]); +#if LINUX_VERSION_CODE >= 0x02053C t = scp->device->id; l = scp->device->lun; +#else + t = scp->target; + l = scp->lun; +#endif cmdp = ha->pccb; TRACE(("gdth_fill_raw_cmd() cmd 0x%x bus %d ID %d LUN %d\n", scp->cmnd[0],b,t,l)); @@ -2931,6 +3080,13 @@ /* evaluate command size */ ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.raw.sg_lst); } else { +#if LINUX_VERSION_CODE >= 0x020400 + sense_paddr = pci_map_single(ha->pdev,scp->sense_buffer, + 16,PCI_DMA_FROMDEVICE); + scp->SCp.buffer = (struct scatterlist *)sense_paddr; +#else + sense_paddr = virt_to_bus(scp->sense_buffer); +#endif cmdp->OpCode = GDT_WRITE; /* always */ cmdp->BoardNode = LOCALBOARD; cmdp->u.raw.reserved = 0; @@ -2944,7 +3100,7 @@ cmdp->u.raw.link_p = 0; cmdp->u.raw.sdlen = scp->request_bufflen; cmdp->u.raw.sense_len = 16; - cmdp->u.raw.sense_data = virt_to_bus(scp->sense_buffer); + cmdp->u.raw.sense_data = sense_paddr; cmdp->u.raw.direction = gdth_direction_tab[scp->cmnd[0]]==DOU ? GDTH_DATA_OUT:GDTH_DATA_IN; memcpy(cmdp->u.raw.cmd,scp->cmnd,12); @@ -2952,10 +3108,21 @@ if (scp->use_sg) { cmdp->u.raw.sdata = 0xffffffff; sl = (struct scatterlist *)scp->request_buffer; - for (i=0; iuse_sg; ++i,++sl) { + sgcnt = scp->use_sg; +#if LINUX_VERSION_CODE >= 0x020400 + scp->SCp.Status = GDTH_MAP_SG; + scp->SCp.Message = PCI_DMA_BIDIRECTIONAL; + sgcnt = pci_map_sg(ha->pdev,sl,scp->use_sg,scp->SCp.Message); + for (i=0; iu.raw.sg_lst[i].sg_ptr = sg_dma_address(sl); + cmdp->u.raw.sg_lst[i].sg_len = sg_dma_len(sl); + } +#else + for (i=0; iu.raw.sg_lst[i].sg_ptr = virt_to_bus(sl->address); cmdp->u.raw.sg_lst[i].sg_len = (ulong32)sl->length; } +#endif cmdp->u.raw.sg_ranz = (ulong32)i; #ifdef GDTH_STATISTICS @@ -2967,14 +3134,23 @@ if (iu.raw.sg_lst[i].sg_len = 0; } else { +#if LINUX_VERSION_CODE >= 0x020400 + scp->SCp.Status = GDTH_MAP_SINGLE; + scp->SCp.Message = PCI_DMA_BIDIRECTIONAL; + phys_addr = pci_map_single(ha->pdev,scp->request_buffer, + scp->request_bufflen,scp->SCp.Message); + scp->SCp.dma_handle = phys_addr; +#else + phys_addr = virt_to_bus(scp->request_buffer); +#endif if (ha->raw_feat & SCATTER_GATHER) { cmdp->u.raw.sdata = 0xffffffff; cmdp->u.raw.sg_ranz= 1; - cmdp->u.raw.sg_lst[0].sg_ptr = virt_to_bus(scp->request_buffer); + cmdp->u.raw.sg_lst[0].sg_ptr = phys_addr; cmdp->u.raw.sg_lst[0].sg_len = scp->request_bufflen; cmdp->u.raw.sg_lst[1].sg_len = 0; } else { - cmdp->u.raw.sdata = virt_to_bus(scp->request_buffer); + cmdp->u.raw.sdata = phys_addr; cmdp->u.raw.sg_ranz= 0; } } @@ -3372,9 +3548,19 @@ if (rval == 2) { gdth_putq(hanum,scp,scp->SCp.this_residual); } else if (rval == 1) { +#if LINUX_VERSION_CODE >= 0x02053C GDTH_LOCK_SCSI_DONE(scp->device->host, flags); scp->scsi_done(scp); - GDTH_UNLOCK_SCSI_DONE(scp->host,flags); + GDTH_UNLOCK_SCSI_DONE(scp->device->host, flags); +#elif LINUX_VERSION_CODE >= 0x020503 + GDTH_LOCK_SCSI_DONE(scp->host, flags); + scp->scsi_done(scp); + GDTH_UNLOCK_SCSI_DONE(scp->host, flags); +#else + GDTH_LOCK_SCSI_DONE(flags); + scp->scsi_done(scp); + GDTH_UNLOCK_SCSI_DONE(flags); +#endif } gdth_next(hanum); } @@ -3384,7 +3570,7 @@ register gdth_ha_str *ha; gdth_msg_str *msg; gdth_cmd_str *cmdp; - unchar b; + unchar b, t; ha = HADATA(gdth_ctr_tab[hanum]); cmdp = ha->pccb; @@ -3413,7 +3599,7 @@ cmdp->BoardNode = LOCALBOARD; cmdp->u.screen.reserved = 0; cmdp->u.screen.su.msg.msg_handle= msg->msg_handle; - cmdp->u.screen.su.msg.msg_addr = virt_to_bus(msg); + cmdp->u.screen.su.msg.msg_addr = ha->scratch_phys; ha->scratch_busy = TRUE; ha->cmd_offs_dpmem = 0; ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.screen.su.msg.msg_addr) @@ -3448,7 +3634,7 @@ cmdp->BoardNode = LOCALBOARD; cmdp->u.screen.reserved = 0; cmdp->u.screen.su.msg.msg_handle= msg->msg_handle; - cmdp->u.screen.su.msg.msg_addr = virt_to_bus(msg); + cmdp->u.screen.su.msg.msg_addr = ha->scratch_phys; ha->scratch_busy = TRUE; ha->cmd_offs_dpmem = 0; ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.screen.su.msg.msg_addr) @@ -3461,11 +3647,35 @@ printk("\n"); } else { +#if LINUX_VERSION_CODE >= 0x02053C b = virt_ctr ? NUMDATA(scp->device->host)->busnum : scp->device->channel; + t = scp->device->id; +#else + b = virt_ctr ? NUMDATA(scp->host)->busnum : scp->channel; + t = scp->target; +#endif if (scp->SCp.sent_command == -1 && b != ha->virt_bus) { - ha->raw[BUS_L2P(ha,b)].io_cnt[scp->device->id]--; + ha->raw[BUS_L2P(ha,b)].io_cnt[t]--; } /* cache or raw service */ + if (ha->status == S_BSY) { + TRACE2(("Controller busy -> retry !\n")); + if (scp->SCp.sent_command == GDT_MOUNT) + scp->SCp.sent_command = GDT_CLUST_INFO; + /* retry */ + return 2; + } +#if LINUX_VERSION_CODE >= 0x020400 + if (scp->SCp.Status == GDTH_MAP_SG) + pci_unmap_sg(ha->pdev,scp->request_buffer, + scp->use_sg,scp->SCp.Message); + else if (scp->SCp.Status == GDTH_MAP_SINGLE) + pci_unmap_single(ha->pdev,scp->SCp.dma_handle, + scp->request_bufflen,scp->SCp.Message); + if (scp->SCp.buffer) + pci_unmap_single(ha->pdev,(dma_addr_t)scp->SCp.buffer, + 16,PCI_DMA_FROMDEVICE); +#endif if (ha->status == S_OK) { scp->SCp.Status = S_OK; scp->SCp.Message = ha->info; @@ -3474,12 +3684,12 @@ scp->SCp.sent_command)); /* special commands GDT_CLUST_INFO/GDT_MOUNT ? */ if (scp->SCp.sent_command == GDT_CLUST_INFO) { - ha->hdr[scp->device->id].cluster_type = (unchar)ha->info; - if (!(ha->hdr[scp->device->id].cluster_type & + ha->hdr[t].cluster_type = (unchar)ha->info; + if (!(ha->hdr[t].cluster_type & CLUSTER_MOUNTED)) { /* NOT MOUNTED -> MOUNT */ scp->SCp.sent_command = GDT_MOUNT; - if (ha->hdr[scp->device->id].cluster_type & + if (ha->hdr[t].cluster_type & CLUSTER_RESERVED) { /* cluster drive RESERVED (on the other node) */ scp->SCp.phase = -2; /* reservation conflict */ @@ -3489,11 +3699,11 @@ } } else { if (scp->SCp.sent_command == GDT_MOUNT) { - ha->hdr[scp->device->id].cluster_type |= CLUSTER_MOUNTED; - ha->hdr[scp->device->id].media_changed = TRUE; + ha->hdr[t].cluster_type |= CLUSTER_MOUNTED; + ha->hdr[t].media_changed = TRUE; } else if (scp->SCp.sent_command == GDT_UNMOUNT) { - ha->hdr[scp->device->id].cluster_type &= ~CLUSTER_MOUNTED; - ha->hdr[scp->device->id].media_changed = TRUE; + ha->hdr[t].cluster_type &= ~CLUSTER_MOUNTED; + ha->hdr[t].media_changed = TRUE; } scp->SCp.sent_command = -1; } @@ -3503,21 +3713,13 @@ } else { /* RESERVE/RELEASE ? */ if (scp->cmnd[0] == RESERVE) { - ha->hdr[scp->device->id].cluster_type |= CLUSTER_RESERVED; + ha->hdr[t].cluster_type |= CLUSTER_RESERVED; } else if (scp->cmnd[0] == RELEASE) { - ha->hdr[scp->device->id].cluster_type &= ~CLUSTER_RESERVED; + ha->hdr[t].cluster_type &= ~CLUSTER_RESERVED; } scp->result = DID_OK << 16; scp->sense_buffer[0] = 0; } - } else if (ha->status == S_BSY) { - TRACE2(("Controller busy -> retry !\n")); - scp->SCp.Status = S_BSY; - scp->SCp.Message = ha->info; - if (scp->SCp.sent_command == GDT_MOUNT) - scp->SCp.sent_command = GDT_CLUST_INFO; - /* retry */ - return 2; } else { scp->SCp.Status = ha->status; scp->SCp.Message = ha->info; @@ -3538,10 +3740,10 @@ scp->result = (DID_OK << 16) | (CHECK_CONDITION << 1); } else if (service == CACHESERVICE) { if (ha->status == S_CACHE_UNKNOWN && - (ha->hdr[scp->device->id].cluster_type & + (ha->hdr[t].cluster_type & CLUSTER_RESERVE_STATE) == CLUSTER_RESERVE_STATE) { /* bus reset -> force GDT_CLUST_INFO */ - ha->hdr[scp->device->id].cluster_type &= ~CLUSTER_RESERVED; + ha->hdr[t].cluster_type &= ~CLUSTER_RESERVED; } memset((char*)scp->sense_buffer,0,16); if (ha->status == (ushort)S_CACHE_RESERV) { @@ -3560,7 +3762,7 @@ ha->dvr.eu.sync.service = service; ha->dvr.eu.sync.status = ha->status; ha->dvr.eu.sync.info = ha->info; - ha->dvr.eu.sync.hostdrive = scp->device->id; + ha->dvr.eu.sync.hostdrive = t; if (ha->status >= 0x8000) gdth_store_event(ha, ES_SYNC, 0, &ha->dvr); else @@ -3765,7 +3967,7 @@ cmdp->BoardNode = LOCALBOARD; cmdp->u.screen.reserved = 0; cmdp->u.screen.su.msg.msg_handle= MSG_INV_HANDLE; - cmdp->u.screen.su.msg.msg_addr = virt_to_bus(msg); + cmdp->u.screen.su.msg.msg_addr = ha->scratch_phys; ha->scratch_busy = TRUE; ha->cmd_offs_dpmem = 0; ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.screen.su.msg.msg_addr) @@ -4028,8 +4230,8 @@ break; if (gdth_search_isa(isa_bios)) { /* controller found */ shp = scsi_register(shtp,sizeof(gdth_ext_str)); - if(shp == NULL) - continue; + if (shp == NULL) + continue; ha = HADATA(shp); if (!gdth_init_isa(isa_bios,ha)) { @@ -4076,11 +4278,15 @@ NUMDATA(shp)->busnum= 0; ha->pccb = CMDDATA(shp); -#if LINUX_VERSION_CODE >= 0x020322 - ha->pscratch = (void *) __get_free_pages(GFP_ATOMIC | GFP_DMA, - GDTH_SCRATCH_ORD); + ha->ccb_phys = 0L; +#if LINUX_VERSION_CODE >= 0x020400 + ha->pdev = NULL; + ha->pscratch = pci_alloc_consistent(ha->pdev, GDTH_SCRATCH, + &ha->scratch_phys); #else ha->pscratch = scsi_init_malloc(GDTH_SCRATCH, GFP_ATOMIC | GFP_DMA); + if (ha->pscratch) + ha->scratch_phys = virt_to_bus(ha->pscratch); #endif ha->scratch_busy = FALSE; ha->req_first = NULL; @@ -4095,12 +4301,14 @@ printk("GDT-ISA: Error during device scan\n"); --gdth_ctr_count; --gdth_ctr_vcount; - if (ha->pscratch != NULL) -#if LINUX_VERSION_CODE >= 0x020322 - free_pages((unsigned long)ha->pscratch, GDTH_SCRATCH_ORD); + if (ha->pscratch != NULL) { +#if LINUX_VERSION_CODE >= 0x020400 + pci_free_consistent(ha->pdev, GDTH_SCRATCH, + ha->pscratch, ha->scratch_phys); #else scsi_init_free((void *)ha->pscratch, GDTH_SCRATCH); #endif + } #if LINUX_VERSION_CODE >= 0x010346 free_irq(ha->irq,ha); #else @@ -4145,8 +4353,8 @@ break; if (gdth_search_eisa(eisa_slot)) { /* controller found */ shp = scsi_register(shtp,sizeof(gdth_ext_str)); - if(shp == NULL) - continue; + if (shp == NULL) + continue; ha = HADATA(shp); if (!gdth_init_eisa(eisa_slot,ha)) { @@ -4180,11 +4388,19 @@ NUMDATA(shp)->hanum)); ha->pccb = CMDDATA(shp); -#if LINUX_VERSION_CODE >= 0x020322 - ha->pscratch = (void *) __get_free_pages(GFP_ATOMIC | GFP_DMA, - GDTH_SCRATCH_ORD); + ha->ccb_phys = 0L; +#if LINUX_VERSION_CODE >= 0x020400 + ha->pdev = NULL; + ha->pscratch = pci_alloc_consistent(ha->pdev, GDTH_SCRATCH, + &ha->scratch_phys); + ha->ccb_phys = + pci_map_single(ha->pdev,ha->pccb, + sizeof(gdth_cmd_str),PCI_DMA_BIDIRECTIONAL); #else ha->pscratch = scsi_init_malloc(GDTH_SCRATCH, GFP_ATOMIC | GFP_DMA); + if (ha->pscratch) + ha->scratch_phys = virt_to_bus(ha->pscratch); + ha->ccb_phys = virt_to_bus(ha->pccb); #endif ha->scratch_busy = FALSE; ha->req_first = NULL; @@ -4199,12 +4415,16 @@ printk("GDT-EISA: Error during device scan\n"); --gdth_ctr_count; --gdth_ctr_vcount; - if (ha->pscratch != NULL) -#if LINUX_VERSION_CODE >= 0x020322 - free_pages((unsigned long)ha->pscratch, GDTH_SCRATCH_ORD); + if (ha->pscratch != NULL) { +#if LINUX_VERSION_CODE >= 0x020400 + pci_free_consistent(ha->pdev, GDTH_SCRATCH, + ha->pscratch, ha->scratch_phys); + pci_unmap_single(ha->pdev,ha->ccb_phys, + sizeof(gdth_cmd_str),PCI_DMA_BIDIRECTIONAL); #else scsi_init_free((void *)ha->pscratch, GDTH_SCRATCH); #endif + } #if LINUX_VERSION_CODE >= 0x010346 free_irq(ha->irq,ha); #else @@ -4252,14 +4472,14 @@ gdth_pci_str pcistr[MAXHA]; cnt = gdth_search_pci(pcistr); - printk("GDT: Found %d PCI Storage RAID Controllers\n",cnt); + printk("GDT: Found %d PCI Storage RAID Controllers\n",cnt); gdth_sort_pci(pcistr,cnt); for (ctr = 0; ctr < cnt; ++ctr) { if (gdth_ctr_count >= MAXHA) break; shp = scsi_register(shtp,sizeof(gdth_ext_str)); - if(shp == NULL) - continue; + if (shp == NULL) + continue; ha = HADATA(shp); if (!gdth_init_pci(&pcistr[ctr],ha)) { @@ -4293,11 +4513,14 @@ NUMDATA(shp)->busnum= 0; ha->pccb = CMDDATA(shp); -#if LINUX_VERSION_CODE >= 0x020322 - ha->pscratch = (void *) __get_free_pages(GFP_ATOMIC | GFP_DMA, - GDTH_SCRATCH_ORD); + ha->ccb_phys = 0L; +#if LINUX_VERSION_CODE >= 0x020400 + ha->pscratch = pci_alloc_consistent(ha->pdev, GDTH_SCRATCH, + &ha->scratch_phys); #else ha->pscratch = scsi_init_malloc(GDTH_SCRATCH, GFP_ATOMIC | GFP_DMA); + if (ha->pscratch) + ha->scratch_phys = virt_to_bus(ha->pscratch); #endif ha->scratch_busy = FALSE; ha->req_first = NULL; @@ -4312,12 +4535,14 @@ printk("GDT-PCI: Error during device scan\n"); --gdth_ctr_count; --gdth_ctr_vcount; - if (ha->pscratch != NULL) -#if LINUX_VERSION_CODE >= 0x020322 - free_pages((unsigned long)ha->pscratch, GDTH_SCRATCH_ORD); + if (ha->pscratch != NULL) { +#if LINUX_VERSION_CODE >= 0x020400 + pci_free_consistent(ha->pdev, GDTH_SCRATCH, + ha->pscratch, ha->scratch_phys); #else scsi_init_free((void *)ha->pscratch, GDTH_SCRATCH); #endif + } #if LINUX_VERSION_CODE >= 0x010346 free_irq(ha->irq,ha); #else @@ -4365,6 +4590,9 @@ gdth_timer.function = gdth_timeout; add_timer(&gdth_timer); #endif +#ifdef GDTH_IOCTL_CHRDEV + major = register_chrdev(0,"gdth",&gdth_fops); +#endif #if LINUX_VERSION_CODE >= 0x020100 register_reboot_notifier(&gdth_notifier); #endif @@ -4399,8 +4627,12 @@ free_dma(shp->dma_channel); } #endif -#if LINUX_VERSION_CODE >= 0x020322 - free_pages((unsigned long)ha->pscratch, GDTH_SCRATCH_ORD); +#if LINUX_VERSION_CODE >= 0x020400 + pci_free_consistent(ha->pdev, GDTH_SCRATCH, + ha->pscratch, ha->scratch_phys); + if (ha->ccb_phys) + pci_unmap_single(ha->pdev,ha->ccb_phys, + sizeof(gdth_cmd_str),PCI_DMA_BIDIRECTIONAL); #else scsi_init_free((void *)ha->pscratch, GDTH_SCRATCH); #endif @@ -4412,6 +4644,9 @@ #ifdef GDTH_STATISTICS del_timer(&gdth_timer); #endif +#ifdef GDTH_IOCTL_CHRDEV + unregister_chrdev(major,"gdth"); +#endif #if LINUX_VERSION_CODE >= 0x020100 unregister_reboot_notifier(&gdth_notifier); #endif @@ -4507,15 +4742,24 @@ unchar b; TRACE2(("gdth_eh_bus_reset()\n")); +#if LINUX_VERSION_CODE >= 0x02053C hanum = NUMDATA(scp->device->host)->hanum; b = virt_ctr ? NUMDATA(scp->device->host)->busnum : scp->device->channel; +#else + hanum = NUMDATA(scp->host)->hanum; + b = virt_ctr ? NUMDATA(scp->host)->busnum : scp->channel; +#endif ha = HADATA(gdth_ctr_tab[hanum]); /* clear command tab */ GDTH_LOCK_HA(ha, flags); for (i = 0; i < GDTH_MAXCMDS; ++i) { cmnd = ha->cmd_tab[i].cmnd; +#if LINUX_VERSION_CODE >= 0x02053C if (!SPECIAL_SCP(cmnd) && cmnd->device->channel == b) +#else + if (!SPECIAL_SCP(cmnd) && cmnd->channel == b) +#endif ha->cmd_tab[i].cmnd = UNUSED_CMND; } GDTH_UNLOCK_HA(ha, flags); @@ -4558,16 +4802,31 @@ } #endif -int gdth_bios_param(struct scsi_device *sdev, struct block_device *bdev, - sector_t capacity, int *ip) + +#if LINUX_VERSION_CODE >= 0x020503 +int gdth_bios_param(struct scsi_device *sdev,struct block_device *bdev,sector_t cap,int *ip) +#elif LINUX_VERSION_CODE >= 0x010300 +int gdth_bios_param(Disk *disk,kdev_t dev,int *ip) +#else +int gdth_bios_param(Disk *disk,int dev,int *ip) +#endif { unchar b, t; int hanum; gdth_ha_str *ha; + struct scsi_device *sd; + unsigned capacity; - hanum = NUMDATA(sdev->host)->hanum; - b = virt_ctr ? NUMDATA(sdev->host)->busnum : sdev->channel; - t = sdev->id; +#if LINUX_VERSION_CODE >= 0x020503 + sd = sdev; + capacity = cap; +#else + sd = disk->device; + capacity = disk->capacity; +#endif + hanum = NUMDATA(sd->host)->hanum; + b = virt_ctr ? NUMDATA(sd->host)->busnum : sd->channel; + t = sd->id; TRACE2(("gdth_bios_param() ha %d bus %d target %d\n", hanum, b, t)); ha = HADATA(gdth_ctr_tab[hanum]); @@ -4592,14 +4851,19 @@ int hanum; int priority; - TRACE(("gdth_queuecommand() cmd 0x%x id %d lun %d\n", - scp->cmnd[0],scp->device->id,scp->lun)); + TRACE(("gdth_queuecommand() cmd 0x%x\n", scp->cmnd[0])); scp->scsi_done = (void *)done; scp->SCp.have_data_in = 1; scp->SCp.phase = -1; scp->SCp.sent_command = -1; + scp->SCp.Status = GDTH_MAP_NONE; + scp->SCp.buffer = (struct scatterlist *)NULL; +#if LINUX_VERSION_CODE >= 0x02053C hanum = NUMDATA(scp->device->host)->hanum; +#else + hanum = NUMDATA(scp->host)->hanum; +#endif #ifdef GDTH_STATISTICS ++act_ios; #endif @@ -4615,6 +4879,667 @@ return 0; } +#ifdef GDTH_IOCTL_CHRDEV +static int gdth_open(struct inode *inode, struct file *filep) +{ + TRACE(("gdth_open()\n")); + return 0; +} + +static int gdth_close(struct inode *inode, struct file *filep) +{ + TRACE(("gdth_close()\n")); + return 0; +} + +static int gdth_ioctl(struct inode *inode, struct file *filep, + unsigned int cmd, unsigned long arg) +{ + gdth_ha_str *ha; +#if LINUX_VERSION_CODE >= 0x020503 + Scsi_Request *srp; + Scsi_Cmnd *scp; + Scsi_Device *sdev; +#elif LINUX_VERSION_CODE >= 0x020322 + Scsi_Cmnd *scp; + Scsi_Device *sdev; +#else + Scsi_Cmnd scp; + Scsi_Device sdev; +#endif + ulong flags; + char cmnd[MAX_COMMAND_SIZE]; + memset(cmnd, 0xff, 12); + + TRACE(("gdth_ioctl() cmd 0x%x\n", cmd)); + + switch (cmd) { + case GDTIOCTL_CTRCNT: + { + int cnt = gdth_ctr_count; + put_user(cnt, (int *)arg); + break; + } + + case GDTIOCTL_DRVERS: + { + int ver = (GDTH_VERSION<<8) | GDTH_SUBVERSION; + put_user(ver, (int *)arg); + break; + } + + case GDTIOCTL_OSVERS: + { + gdth_ioctl_osvers osv; + + osv.version = (unchar)(LINUX_VERSION_CODE >> 16); + osv.subversion = (unchar)(LINUX_VERSION_CODE >> 8); + osv.revision = (ushort)(LINUX_VERSION_CODE & 0xff); + copy_to_user((char *)arg, &osv, sizeof(gdth_ioctl_osvers)); + break; + } + + case GDTIOCTL_CTRTYPE: + { + gdth_ioctl_ctrtype ctrt; + + if (copy_from_user(&ctrt, (char *)arg, sizeof(gdth_ioctl_ctrtype)) || + ctrt.ionode >= gdth_ctr_count) + return -EFAULT; + ha = HADATA(gdth_ctr_tab[ctrt.ionode]); + if (ha->type == GDT_ISA || ha->type == GDT_EISA) { + ctrt.type = (unchar)((ha->stype>>20) - 0x10); + } else { + if (ha->type != GDT_PCIMPR) { + ctrt.type = (unchar)((ha->stype<<4) + 6); + } else { + ctrt.type = + (ha->oem_id == OEM_ID_INTEL ? 0xfd : 0xfe); + if (ha->stype >= 0x300) + ctrt.ext_type = 0x6000 | ha->subdevice_id; + else + ctrt.ext_type = 0x6000 | ha->stype; + } + ctrt.device_id = ha->stype; + ctrt.sub_device_id = ha->subdevice_id; + } + ctrt.info = ha->brd_phys; + ctrt.oem_id = ha->oem_id; + if (copy_to_user((char *)arg, &ctrt, sizeof(gdth_ioctl_ctrtype))) + return -EFAULT; + break; + } + + case GDTIOCTL_GENERAL: + { + gdth_ioctl_general gen; + char *buf = NULL; + ulong32 paddr; + int hanum; + + if (copy_from_user(&gen, (char *)arg, sizeof(gdth_ioctl_general)) || + gen.ionode >= gdth_ctr_count) + return -EFAULT; + hanum = gen.ionode; + ha = HADATA(gdth_ctr_tab[hanum]); + if (gen.data_len + gen.sense_len != 0) { + if (!(buf = gdth_ioctl_alloc(hanum, gen.data_len + gen.sense_len, + FALSE, &paddr))) + return -EFAULT; + if (copy_from_user(buf, (char *)arg + sizeof(gdth_ioctl_general), + gen.data_len + gen.sense_len)) { + gdth_ioctl_free(hanum, gen.data_len+gen.sense_len, buf, paddr); + return -EFAULT; + } + + if (gen.command.OpCode == GDT_IOCTL) { + gen.command.u.ioctl.p_param = paddr; + } else if (gen.command.Service == CACHESERVICE) { + if (ha->cache_feat & SCATTER_GATHER) { + gen.command.u.cache.DestAddr = 0xffffffff; + gen.command.u.cache.sg_canz = 1; + gen.command.u.cache.sg_lst[0].sg_ptr = paddr; + gen.command.u.cache.sg_lst[0].sg_len = gen.data_len; + gen.command.u.cache.sg_lst[1].sg_len = 0; + } else { + gen.command.u.cache.DestAddr = paddr; + gen.command.u.cache.sg_canz = 0; + } + } else if (gen.command.Service == SCSIRAWSERVICE) { + if (ha->raw_feat & SCATTER_GATHER) { + gen.command.u.raw.sdata = 0xffffffff; + gen.command.u.raw.sg_ranz = 1; + gen.command.u.raw.sg_lst[0].sg_ptr = paddr; + gen.command.u.raw.sg_lst[0].sg_len = gen.data_len; + gen.command.u.raw.sg_lst[1].sg_len = 0; + } else { + gen.command.u.raw.sdata = paddr; + gen.command.u.raw.sg_ranz = 0; + } + gen.command.u.raw.sense_data = paddr + gen.data_len; + + } else { + gdth_ioctl_free(hanum, gen.data_len+gen.sense_len, buf, paddr); + return -EFAULT; + } + } + +#if LINUX_VERSION_CODE >= 0x020503 + sdev = scsi_get_host_dev(gdth_ctr_tab[hanum]); + srp = scsi_allocate_request(sdev); + if (!srp) + return -ENOMEM; + srp->sr_cmd_len = 12; + srp->sr_use_sg = 0; + gdth_do_req(srp, &gen.command, cmnd, gen.timeout); + gen.status = srp->sr_command->SCp.Status; + gen.info = srp->sr_command->SCp.Message; + scsi_release_request(srp); + scsi_free_host_dev(sdev); +#elif LINUX_VERSION_CODE >= 0x020322 + sdev = scsi_get_host_dev(gdth_ctr_tab[hanum]); + scp = scsi_allocate_device(sdev, 1, FALSE); + if (!scp) + return -ENOMEM; + scp->cmd_len = 12; + scp->use_sg = 0; + gdth_do_cmd(scp, &gen.command, cmnd, gen.timeout); + gen.status = scp->SCp.Status; + gen.info = scp->SCp.Message; + scsi_release_command(scp); + scsi_free_host_dev(sdev); +#else + memset(&sdev,0,sizeof(Scsi_Device)); + memset(&scp, 0,sizeof(Scsi_Cmnd)); + sdev.host = scp.host = gdth_ctr_tab[hanum]; + sdev.id = scp.target = sdev.host->this_id; + scp.device = &sdev; + gdth_do_cmd(&scp, &gen.command, cmnd, gen.timeout); + gen.status = scp.SCp.Status; + gen.info = scp.SCp.Message; +#endif + + if (copy_to_user((char *)arg + sizeof(gdth_ioctl_general), buf, + gen.data_len + gen.sense_len)) { + gdth_ioctl_free(hanum, gen.data_len+gen.sense_len, buf, paddr); + return -EFAULT; + } + if (copy_to_user((char *)arg, &gen, + sizeof(gdth_ioctl_general) - sizeof(gdth_cmd_str))) { + gdth_ioctl_free(hanum, gen.data_len+gen.sense_len, buf, paddr); + return -EFAULT; + } + gdth_ioctl_free(hanum, gen.data_len+gen.sense_len, buf, paddr); + break; + } + + case GDTIOCTL_EVENT: + { + gdth_ioctl_event evt; + gdth_ha_str *ha; + ulong flags; + + if (copy_from_user(&evt, (char *)arg, sizeof(gdth_ioctl_event)) || + evt.ionode >= gdth_ctr_count) + return -EFAULT; + ha = HADATA(gdth_ctr_tab[evt.ionode]); + + if (evt.erase == 0xff) { + if (evt.event.event_source == ES_TEST) + evt.event.event_data.size=sizeof(evt.event.event_data.eu.test); + else if (evt.event.event_source == ES_DRIVER) + evt.event.event_data.size=sizeof(evt.event.event_data.eu.driver); + else if (evt.event.event_source == ES_SYNC) + evt.event.event_data.size=sizeof(evt.event.event_data.eu.sync); + else + evt.event.event_data.size=sizeof(evt.event.event_data.eu.async); + GDTH_LOCK_HA(ha, flags); + gdth_store_event(ha, evt.event.event_source, evt.event.event_idx, + &evt.event.event_data); + GDTH_UNLOCK_HA(ha, flags); + } else if (evt.erase == 0xfe) { + gdth_clear_events(); + } else if (evt.erase == 0) { + evt.handle = gdth_read_event(ha, evt.handle, &evt.event); + } else { + gdth_readapp_event(ha, evt.erase, &evt.event); + } + if (copy_to_user((char *)arg, &evt, sizeof(gdth_ioctl_event))) + return -EFAULT; + break; + } + + case GDTIOCTL_LOCKDRV: + { + gdth_ioctl_lockdrv ldrv; + unchar i, j; + + if (copy_from_user(&ldrv, (char *)arg, sizeof(gdth_ioctl_lockdrv)) || + ldrv.ionode >= gdth_ctr_count) + return -EFAULT; + ha = HADATA(gdth_ctr_tab[ldrv.ionode]); + + for (i = 0; i < ldrv.drive_cnt && i < MAX_HDRIVES; ++i) { + j = ldrv.drives[i]; + if (j >= MAX_HDRIVES || !ha->hdr[j].present) + continue; + if (ldrv.lock) { + GDTH_LOCK_HA(ha, flags); + ha->hdr[j].lock = 1; + GDTH_UNLOCK_HA(ha, flags); + gdth_wait_completion(ldrv.ionode, ha->bus_cnt, j); + gdth_stop_timeout(ldrv.ionode, ha->bus_cnt, j); + } else { + GDTH_LOCK_HA(ha, flags); + ha->hdr[j].lock = 0; + GDTH_UNLOCK_HA(ha, flags); + gdth_start_timeout(ldrv.ionode, ha->bus_cnt, j); + gdth_next(ldrv.ionode); + } + } + break; + } + + case GDTIOCTL_LOCKCHN: + { + gdth_ioctl_lockchn lchn; + unchar i, j; + + if (copy_from_user(&lchn, (char *)arg, sizeof(gdth_ioctl_lockchn)) || + lchn.ionode >= gdth_ctr_count) + return -EFAULT; + ha = HADATA(gdth_ctr_tab[lchn.ionode]); + + i = lchn.channel; + if (i < ha->bus_cnt) { + if (lchn.lock) { + GDTH_LOCK_HA(ha, flags); + ha->raw[i].lock = 1; + GDTH_UNLOCK_HA(ha, flags); + for (j = 0; j < ha->tid_cnt; ++j) { + gdth_wait_completion(lchn.ionode, i, j); + gdth_stop_timeout(lchn.ionode, i, j); + } + } else { + GDTH_LOCK_HA(ha, flags); + ha->raw[i].lock = 0; + GDTH_UNLOCK_HA(ha, flags); + for (j = 0; j < ha->tid_cnt; ++j) { + gdth_start_timeout(lchn.ionode, i, j); + gdth_next(lchn.ionode); + } + } + } + break; + } + + case GDTIOCTL_RESCAN: + { + gdth_ioctl_rescan rsc; + gdth_cmd_str cmd; + ushort i, status, hdr_cnt; + ulong32 info; + int hanum, cyls, hds, secs; + + if (copy_from_user(&rsc, (char *)arg, sizeof(gdth_ioctl_rescan)) || + rsc.ionode >= gdth_ctr_count) + return -EFAULT; + hanum = rsc.ionode; + ha = HADATA(gdth_ctr_tab[hanum]); + +#if LINUX_VERSION_CODE >= 0x020503 + sdev = scsi_get_host_dev(gdth_ctr_tab[hanum]); + srp = scsi_allocate_request(sdev); + if (!srp) + return -ENOMEM; + srp->sr_cmd_len = 12; + srp->sr_use_sg = 0; +#elif LINUX_VERSION_CODE >= 0x020322 + sdev = scsi_get_host_dev(gdth_ctr_tab[hanum]); + scp = scsi_allocate_device(sdev, 1, FALSE); + if (!scp) + return -ENOMEM; + scp->cmd_len = 12; + scp->use_sg = 0; +#else + memset(&sdev,0,sizeof(Scsi_Device)); + memset(&scp, 0,sizeof(Scsi_Cmnd)); + sdev.host = scp.host = gdth_ctr_tab[hanum]; + sdev.id = scp.target = sdev.host->this_id; + scp.device = &sdev; +#endif + + if (rsc.flag == 0) { + /* old method: re-init. cache service */ + cmd.Service = CACHESERVICE; + cmd.OpCode = GDT_INIT; + cmd.u.cache.DeviceNo = LINUX_OS; +#if LINUX_VERSION_CODE >= 0x020503 + gdth_do_req(srp, &cmd, cmnd, 30); + status = (ushort)srp->sr_command->SCp.Status; + info = (ulong32)srp->sr_command->SCp.Message; +#elif LINUX_VERSION_CODE >= 0x020322 + gdth_do_cmd(scp, &cmd, cmnd, 30); + status = (ushort)scp->SCp.Status; + info = (ulong32)scp->SCp.Message; +#else + gdth_do_cmd(&scp, &cmd, cmnd, 30); + status = (ushort)scp.SCp.Status; + info = (ulong32)scp.SCp.Message; +#endif + i = 0; + hdr_cnt = (status == S_OK ? (ushort)info : 0); + } else { + i = rsc.hdr_no; + hdr_cnt = i + 1; + } + for (; i < hdr_cnt && i < MAX_HDRIVES; ++i) { + cmd.Service = CACHESERVICE; + cmd.OpCode = GDT_INFO; + cmd.u.cache.DeviceNo = i; +#if LINUX_VERSION_CODE >= 0x020503 + gdth_do_req(srp, &cmd, cmnd, 30); + status = (ushort)srp->sr_command->SCp.Status; + info = (ulong32)srp->sr_command->SCp.Message; +#elif LINUX_VERSION_CODE >= 0x020322 + gdth_do_cmd(scp, &cmd, cmnd, 30); + status = (ushort)scp->SCp.Status; + info = (ulong32)scp->SCp.Message; +#else + gdth_do_cmd(&scp, &cmd, cmnd, 30); + status = (ushort)scp.SCp.Status; + info = (ulong32)scp.SCp.Message; +#endif + GDTH_LOCK_HA(ha, flags); + rsc.hdr_list[i].bus = ha->virt_bus; + rsc.hdr_list[i].target = i; + rsc.hdr_list[i].lun = 0; + if (status != S_OK) { + ha->hdr[i].present = FALSE; + } else { + ha->hdr[i].present = TRUE; + ha->hdr[i].size = info; + /* evaluate mapping */ + ha->hdr[i].size &= ~SECS32; + gdth_eval_mapping(ha->hdr[i].size,&cyls,&hds,&secs); + ha->hdr[i].heads = hds; + ha->hdr[i].secs = secs; + /* round size */ + ha->hdr[i].size = cyls * hds * secs; + } + GDTH_UNLOCK_HA(ha, flags); + if (status != S_OK) + continue; + + /* devtype, cluster info, R/W attribs */ + cmd.Service = CACHESERVICE; + cmd.OpCode = GDT_DEVTYPE; + cmd.u.cache.DeviceNo = i; +#if LINUX_VERSION_CODE >= 0x020503 + gdth_do_req(srp, &cmd, cmnd, 30); + status = (ushort)srp->sr_command->SCp.Status; + info = (ulong32)srp->sr_command->SCp.Message; +#elif LINUX_VERSION_CODE >= 0x020322 + gdth_do_cmd(scp, &cmd, cmnd, 30); + status = (ushort)scp->SCp.Status; + info = (ulong32)scp->SCp.Message; +#else + gdth_do_cmd(&scp, &cmd, cmnd, 30); + status = (ushort)scp.SCp.Status; + info = (ulong32)scp.SCp.Message; +#endif + GDTH_LOCK_HA(ha, flags); + ha->hdr[i].devtype = (status == S_OK ? (ushort)info : 0); + GDTH_UNLOCK_HA(ha, flags); + + cmd.Service = CACHESERVICE; + cmd.OpCode = GDT_CLUST_INFO; + cmd.u.cache.DeviceNo = i; +#if LINUX_VERSION_CODE >= 0x020503 + gdth_do_req(srp, &cmd, cmnd, 30); + status = (ushort)srp->sr_command->SCp.Status; + info = (ulong32)srp->sr_command->SCp.Message; +#elif LINUX_VERSION_CODE >= 0x020322 + gdth_do_cmd(scp, &cmd, cmnd, 30); + status = (ushort)scp->SCp.Status; + info = (ulong32)scp->SCp.Message; +#else + gdth_do_cmd(&scp, &cmd, cmnd, 30); + status = (ushort)scp.SCp.Status; + info = (ulong32)scp.SCp.Message; +#endif + GDTH_LOCK_HA(ha, flags); + ha->hdr[i].cluster_type = + ((status == S_OK && !shared_access) ? (ushort)info : 0); + GDTH_UNLOCK_HA(ha, flags); + rsc.hdr_list[i].cluster_type = ha->hdr[i].cluster_type; + + cmd.Service = CACHESERVICE; + cmd.OpCode = GDT_RW_ATTRIBS; + cmd.u.cache.DeviceNo = i; +#if LINUX_VERSION_CODE >= 0x020503 + gdth_do_req(srp, &cmd, cmnd, 30); + status = (ushort)srp->sr_command->SCp.Status; + info = (ulong32)srp->sr_command->SCp.Message; +#elif LINUX_VERSION_CODE >= 0x020322 + gdth_do_cmd(scp, &cmd, cmnd, 30); + status = (ushort)scp->SCp.Status; + info = (ulong32)scp->SCp.Message; +#else + gdth_do_cmd(&scp, &cmd, cmnd, 30); + status = (ushort)scp.SCp.Status; + info = (ulong32)scp.SCp.Message; +#endif + GDTH_LOCK_HA(ha, flags); + ha->hdr[i].rw_attribs = (status == S_OK ? (ushort)info : 0); + GDTH_UNLOCK_HA(ha, flags); + } +#if LINUX_VERSION_CODE >= 0x020503 + scsi_release_request(srp); + scsi_free_host_dev(sdev); +#elif LINUX_VERSION_CODE >= 0x020322 + scsi_release_command(scp); + scsi_free_host_dev(sdev); +#endif + + if (copy_to_user((char *)arg, &rsc, sizeof(gdth_ioctl_rescan))) + return -EFAULT; + break; + } + + case GDTIOCTL_HDRLIST: + { + gdth_ioctl_rescan rsc; + gdth_cmd_str cmd; + gdth_ha_str *ha; + unchar i; + int hanum; + + if (copy_from_user(&rsc, (char *)arg, sizeof(gdth_ioctl_rescan)) || + rsc.ionode >= gdth_ctr_count) + return -EFAULT; + hanum = rsc.ionode; + ha = HADATA(gdth_ctr_tab[hanum]); + +#if LINUX_VERSION_CODE >= 0x020503 + sdev = scsi_get_host_dev(gdth_ctr_tab[hanum]); + srp = scsi_allocate_request(sdev); + if (!srp) + return -ENOMEM; + srp->sr_cmd_len = 12; + srp->sr_use_sg = 0; +#elif LINUX_VERSION_CODE >= 0x020322 + sdev = scsi_get_host_dev(gdth_ctr_tab[hanum]); + scp = scsi_allocate_device(sdev, 1, FALSE); + if (!scp) + return -ENOMEM; + scp->cmd_len = 12; + scp->use_sg = 0; +#else + memset(&sdev,0,sizeof(Scsi_Device)); + memset(&scp, 0,sizeof(Scsi_Cmnd)); + sdev.host = scp.host = gdth_ctr_tab[hanum]; + sdev.id = scp.target = sdev.host->this_id; + scp.device = &sdev; +#endif + + for (i = 0; i < MAX_HDRIVES; ++i) { + if (!ha->hdr[i].present) { + rsc.hdr_list[i].bus = 0xff; + continue; + } + rsc.hdr_list[i].bus = ha->virt_bus; + rsc.hdr_list[i].target = i; + rsc.hdr_list[i].lun = 0; + rsc.hdr_list[i].cluster_type = ha->hdr[i].cluster_type; + if (ha->hdr[i].cluster_type & CLUSTER_DRIVE) { + cmd.Service = CACHESERVICE; + cmd.OpCode = GDT_CLUST_INFO; + cmd.u.cache.DeviceNo = i; +#if LINUX_VERSION_CODE >= 0x020503 + gdth_do_req(srp, &cmd, cmnd, 30); + if (srp->sr_command->SCp.Status == S_OK) + rsc.hdr_list[i].cluster_type = srp->sr_command->SCp.Message; +#elif LINUX_VERSION_CODE >= 0x020322 + gdth_do_cmd(scp, &cmd, cmnd, 30); + if (scp->SCp.Status == S_OK) + rsc.hdr_list[i].cluster_type = scp->SCp.Message; +#else + gdth_do_cmd(&scp, &cmd, cmnd, 30); + if (scp.SCp.Status == S_OK) + rsc.hdr_list[i].cluster_type = scp.SCp.Message; +#endif + } + } +#if LINUX_VERSION_CODE >= 0x020503 + scsi_release_request(srp); + scsi_free_host_dev(sdev); +#elif LINUX_VERSION_CODE >= 0x020322 + scsi_release_command(scp); + scsi_free_host_dev(sdev); +#endif + + if (copy_to_user((char *)arg, &rsc, sizeof(gdth_ioctl_rescan))) + return -EFAULT; + break; + } + + case GDTIOCTL_RESET_BUS: + { + gdth_ioctl_reset res; + int hanum, rval; + + if (copy_from_user(&res, (char *)arg, sizeof(gdth_ioctl_reset)) || + res.ionode >= gdth_ctr_count) + return -EFAULT; + hanum = res.ionode; + + /* Because we need a Scsi_Cmnd struct., we make a scsi_allocate device also for kernels >=2.5.x */ +#if LINUX_VERSION_CODE >= 0x02053C + sdev = scsi_get_host_dev(gdth_ctr_tab[hanum]); + scp = scsi_get_command(sdev, GFP_KERNEL); + if (!scp) + return -ENOMEM; + scp->cmd_len = 12; + scp->use_sg = 0; + scp->device->channel = virt_ctr ? 0 : res.number; + rval = gdth_eh_bus_reset(scp); + res.status = (rval == SUCCESS ? S_OK : S_GENERR); + scsi_put_command(scp); + scsi_free_host_dev(sdev); +#elif LINUX_VERSION_CODE >= 0x020322 + sdev = scsi_get_host_dev(gdth_ctr_tab[hanum]); +#if LINUX_VERSION_CODE >= 0x020503 + scp = scsi_allocate_device(sdev, 1); +#else + scp = scsi_allocate_device(sdev, 1, FALSE); +#endif + if (!scp) + return -ENOMEM; + scp->cmd_len = 12; + scp->use_sg = 0; + scp->channel = virt_ctr ? 0 : res.number; + rval = gdth_eh_bus_reset(scp); + res.status = (rval == SUCCESS ? S_OK : S_GENERR); + scsi_release_command(scp); + scsi_free_host_dev(sdev); +#elif LINUX_VERSION_CODE >= 0x02015F + memset(&sdev,0,sizeof(Scsi_Device)); + memset(&scp, 0,sizeof(Scsi_Cmnd)); + sdev.host = scp.host = gdth_ctr_tab[hanum]; + sdev.id = scp.target = sdev.host->this_id; + scp.device = &sdev; + scp.channel = virt_ctr ? 0 : res.number; + rval = gdth_eh_bus_reset(&scp); + res.status = (rval == SUCCESS ? S_OK : S_GENERR); +#else + res.status = S_OK; +#endif + if (copy_to_user((char *)arg, &res, sizeof(gdth_ioctl_reset))) + return -EFAULT; + break; + } + + case GDTIOCTL_RESET_DRV: + { + gdth_ioctl_reset res; + gdth_cmd_str cmd; + int hanum; + + if (copy_from_user(&res, (char *)arg, sizeof(gdth_ioctl_reset)) || + res.ionode >= gdth_ctr_count || res.number >= MAX_HDRIVES) + return -EFAULT; + hanum = res.ionode; + ha = HADATA(gdth_ctr_tab[hanum]); + + if (!ha->hdr[res.number].present) + return 0; + cmd.Service = CACHESERVICE; + cmd.OpCode = GDT_CLUST_RESET; + cmd.u.cache.DeviceNo = res.number; +#if LINUX_VERSION_CODE >= 0x020503 + sdev = scsi_get_host_dev(gdth_ctr_tab[hanum]); + srp = scsi_allocate_request(sdev); + if (!srp) + return -ENOMEM; + srp->sr_cmd_len = 12; + srp->sr_use_sg = 0; + gdth_do_req(srp, &cmd, cmnd, 30); + res.status = (ushort)srp->sr_command->SCp.Status; + scsi_release_request(srp); + scsi_free_host_dev(sdev); +#elif LINUX_VERSION_CODE >= 0x020322 + sdev = scsi_get_host_dev(gdth_ctr_tab[hanum]); + scp = scsi_allocate_device(sdev, 1, FALSE); + if (!scp) + return -ENOMEM; + scp->cmd_len = 12; + scp->use_sg = 0; + gdth_do_cmd(scp, &cmd, cmnd, 30); + res.status = (ushort)scp->SCp.Status; + scsi_release_command(scp); + scsi_free_host_dev(sdev); +#else + memset(&sdev,0,sizeof(Scsi_Device)); + memset(&scp, 0,sizeof(Scsi_Cmnd)); + sdev.host = scp.host = gdth_ctr_tab[hanum]; + sdev.id = scp.target = sdev.host->this_id; + scp.device = &sdev; + gdth_do_cmd(&scp, &cmd, cmnd, 30); + res.status = (ushort)scp.SCp.Status; +#endif + if (copy_to_user((char *)arg, &res, sizeof(gdth_ioctl_reset))) + return -EFAULT; + break; + } + + default: + break; + } + return 0; +} +#endif + #if LINUX_VERSION_CODE >= 0x010300 /* flush routine */ static void gdth_flush(int hanum) @@ -4622,7 +5547,10 @@ int i; gdth_ha_str *ha; gdth_cmd_str gdtcmd; -#if LINUX_VERSION_CODE >= 0x020322 +#if LINUX_VERSION_CODE >= 0x020503 + Scsi_Request *srp; + Scsi_Device *sdev; +#elif LINUX_VERSION_CODE >= 0x020322 Scsi_Cmnd *scp; Scsi_Device *sdev; #else @@ -4635,9 +5563,18 @@ TRACE2(("gdth_flush() hanum %d\n",hanum)); ha = HADATA(gdth_ctr_tab[hanum]); -#if LINUX_VERSION_CODE >= 0x020322 +#if LINUX_VERSION_CODE >= 0x020503 sdev = scsi_get_host_dev(gdth_ctr_tab[hanum]); - scp = scsi_get_command(sdev, GFP_KERNEL); + srp = scsi_allocate_request(sdev); + if (!srp) + return; + srp->sr_cmd_len = 12; + srp->sr_use_sg = 0; +#elif LINUX_VERSION_CODE >= 0x020322 + sdev = scsi_get_host_dev(gdth_ctr_tab[hanum]); + scp = scsi_allocate_device(sdev, 1, FALSE); + if (!scp) + return; scp->cmd_len = 12; scp->use_sg = 0; #else @@ -4657,15 +5594,20 @@ gdtcmd.u.cache.BlockNo = 1; gdtcmd.u.cache.sg_canz = 0; TRACE2(("gdth_flush(): flush ha %d drive %d\n", hanum, i)); -#if LINUX_VERSION_CODE >= 0x020322 +#if LINUX_VERSION_CODE >= 0x020503 + gdth_do_req(srp, &gdtcmd, cmnd, 30); +#elif LINUX_VERSION_CODE >= 0x020322 gdth_do_cmd(scp, &gdtcmd, cmnd, 30); #else gdth_do_cmd(&scp, &gdtcmd, cmnd, 30); #endif } } -#if LINUX_VERSION_CODE >= 0x020322 - scsi_put_command(scp); +#if LINUX_VERSION_CODE >= 0x020503 + scsi_release_request(srp); + scsi_free_host_dev(sdev); +#elif LINUX_VERSION_CODE >= 0x020322 + scsi_release_command(scp); scsi_free_host_dev(sdev); #endif } @@ -4680,7 +5622,10 @@ int hanum; #ifndef __alpha__ gdth_cmd_str gdtcmd; -#if LINUX_VERSION_CODE >= 0x020322 +#if LINUX_VERSION_CODE >= 0x020503 + Scsi_Request *srp; + Scsi_Device *sdev; +#elif LINUX_VERSION_CODE >= 0x020322 Scsi_Cmnd *scp; Scsi_Device *sdev; #else @@ -4702,6 +5647,7 @@ } halt_called = TRUE; #endif + printk("GDT: Flushing all host drives .. "); for (hanum = 0; hanum < gdth_ctr_count; ++hanum) { gdth_flush(hanum); @@ -4709,28 +5655,48 @@ #ifndef __alpha__ /* controller reset */ memset(cmnd, 0xff, MAX_COMMAND_SIZE); -#if LINUX_VERSION_CODE >= 0x020322 + gdtcmd.BoardNode = LOCALBOARD; + gdtcmd.Service = CACHESERVICE; + gdtcmd.OpCode = GDT_RESET; + TRACE2(("gdth_halt(): reset controller %d\n", hanum)); +#if LINUX_VERSION_CODE >= 0x020503 sdev = scsi_get_host_dev(gdth_ctr_tab[hanum]); - scp = scsi_get_command(sdev, GFP_KERNEL); + srp = scsi_allocate_request(sdev); + if (!srp) { +#if LINUX_VERSION_CODE >= 0x020100 + unregister_reboot_notifier(&gdth_notifier); + return NOTIFY_OK; +#else + return; +#endif + } + srp->sr_cmd_len = 12; + srp->sr_use_sg = 0; + gdth_do_req(srp, &gdtcmd, cmnd, 10); + scsi_release_request(srp); + scsi_free_host_dev(sdev); +#elif LINUX_VERSION_CODE >= 0x020322 + sdev = scsi_get_host_dev(gdth_ctr_tab[hanum]); + scp = scsi_allocate_device(sdev, 1, FALSE); + if (!scp) { +#if LINUX_VERSION_CODE >= 0x020100 + unregister_reboot_notifier(&gdth_notifier); + return NOTIFY_OK; +#else + return; +#endif + } scp->cmd_len = 12; scp->use_sg = 0; + gdth_do_cmd(scp, &gdtcmd, cmnd, 10); + scsi_release_command(scp); + scsi_free_host_dev(sdev); #else memset(&sdev,0,sizeof(Scsi_Device)); memset(&scp, 0,sizeof(Scsi_Cmnd)); sdev.host = scp.host = gdth_ctr_tab[hanum]; sdev.id = scp.target = sdev.host->this_id; scp.device = &sdev; -#endif - - gdtcmd.BoardNode = LOCALBOARD; - gdtcmd.Service = CACHESERVICE; - gdtcmd.OpCode = GDT_RESET; - TRACE2(("gdth_halt(): reset controller %d\n", hanum)); -#if LINUX_VERSION_CODE >= 0x020322 - gdth_do_cmd(scp, &gdtcmd, cmnd, 10); - scsi_put_command(scp); - scsi_free_host_dev(sdev); -#else gdth_do_cmd(&scp, &gdtcmd, cmnd, 10); #endif #endif diff -Nru a/drivers/scsi/gdth.h b/drivers/scsi/gdth.h --- a/drivers/scsi/gdth.h Sun Mar 23 00:22:52 2003 +++ b/drivers/scsi/gdth.h Sun Mar 23 00:22:52 2003 @@ -10,7 +10,7 @@ * * * - * $Id: gdth.h,v 1.46 2002/02/05 09:39:53 achim Exp $ + * $Id: gdth.h,v 1.48 2003/02/27 14:58:22 achim Exp $ */ #include @@ -29,16 +29,16 @@ /* defines, macros */ /* driver version */ -#define GDTH_VERSION_STR "2.05" +#define GDTH_VERSION_STR "2.07" #define GDTH_VERSION 2 -#define GDTH_SUBVERSION 5 +#define GDTH_SUBVERSION 7 /* protocol version */ #define PROTOCOL_VERSION 1 /* OEM IDs */ -#define OEM_ID_ICP 0x941c -#define OEM_ID_INTEL 0x8000 +#define OEM_ID_ICP 0x941c +#define OEM_ID_INTEL 0x8000 /* controller classes */ #define GDT_ISA 0x01 /* ISA controller */ @@ -134,12 +134,17 @@ #ifndef PCI_DEVICE_ID_VORTEX_GDTNEWRX /* new GDT Rx Controller */ -#define PCI_DEVICE_ID_VORTEX_GDTNEWRX 0x300 +#define PCI_DEVICE_ID_VORTEX_GDTNEWRX 0x300 #endif - + #ifndef PCI_DEVICE_ID_INTEL_SRC /* Intel Storage RAID Controller */ -#define PCI_DEVICE_ID_INTEL_SRC 0x600 +#define PCI_DEVICE_ID_INTEL_SRC 0x600 +#endif + +#ifndef PCI_DEVICE_ID_INTEL_SRC_XSCALE +/* Intel Storage RAID Controller */ +#define PCI_DEVICE_ID_INTEL_SRC_XSCALE 0x601 #endif /* limits */ @@ -153,8 +158,6 @@ #define MAXID 127 #define MAXLUN 8 #define MAXBUS 6 -#define MAX_HDRIVES 100 /* max. host drive count */ -#define MAX_LDRIVES 255 /* max. log. drive count */ #define MAX_EVENTS 100 /* event buffer count */ #define MAX_RES_ARGS 40 /* device reservation, must be a multiple of 4 */ @@ -254,6 +257,7 @@ #define CACHE_DRV_INFO 0x07 /* cache drive info */ #define BOARD_FEATURES 0x15 /* controller features */ #define BOARD_INFO 0x28 /* controller info */ +#define CACHE_READ_OEM_STRING_RECORD 0x84 /* read OEM string record */ #define HOST_GET 0x10001L /* get host drive list */ #define IO_CHANNEL 0x00020000L /* default IO channel */ #define INVALID_CHANNEL 0x0000ffffL /* invalid channel */ @@ -265,7 +269,7 @@ #define S_CACHE_UNKNOWN 12 /* cache serv.: drive unknown */ #define S_RAW_SCSI 12 /* raw serv.: target error */ #define S_RAW_ILL 0xff /* raw serv.: illegal */ -#define S_CACHE_RESERV -24 /* cache: reserv. conflict */ +#define S_CACHE_RESERV -24 /* cache: reserv. conflict */ /* timeout values */ #define INIT_RETRIES 100000 /* 100000 * 1ms = 100s */ @@ -292,10 +296,15 @@ #define MAILBOXREG 0x0c90 /* mailbox reg. (16 bytes) */ #define EISAREG 0x0cc0 /* EISA configuration */ +/* DMA memory mappings */ +#define GDTH_MAP_NONE 0 +#define GDTH_MAP_SINGLE 1 +#define GDTH_MAP_SG 2 +#define GDTH_MAP_IOCTL 3 + /* other defines */ #define LINUX_OS 8 /* used for cache optim. */ #define SCATTER_GATHER 1 /* s/g feature */ -#define GDTH_MAXSG 32 /* max. s/g elements */ #define SECS32 0x1f /* round capacity */ #define BIOS_ID_OFFS 0x10 /* offset contr-ID in ISABIOS */ #define LOCALBOARD 0 /* board node always 0 */ @@ -303,10 +312,7 @@ #define SPEZINDEX 1 /* cmd index unknown service */ #define GDT_WR_THROUGH 0x100 /* WRITE_THROUGH supported */ - -/* typedefs */ -typedef u32 ulong32; -#define PACKED __attribute__((packed)) +#include "gdth_ioctl.h" /* screenservice message */ typedef struct { @@ -535,6 +541,50 @@ unchar ld_error; /* error */ } PACKED gdth_cdrinfo_str; +/* OEM string */ +typedef struct { + ulong32 ctl_version; + ulong32 file_major_version; + ulong32 file_minor_version; + ulong32 buffer_size; + ulong32 cpy_count; + ulong32 ext_error; + ulong32 oem_id; + ulong32 board_id; +} PACKED gdth_oem_str_params; + +typedef struct { + unchar product_0_1_name[16]; + unchar product_4_5_name[16]; + unchar product_cluster_name[16]; + unchar product_reserved[16]; + unchar scsi_cluster_target_vendor_id[16]; + unchar cluster_raid_fw_name[16]; + unchar oem_brand_name[16]; + unchar oem_raid_type[16]; + unchar bios_type[13]; + unchar bios_title[50]; + unchar oem_company_name[37]; + ulong32 pci_id_1; + ulong32 pci_id_2; + unchar validation_status[80]; + unchar reserved_1[4]; + unchar scsi_host_drive_inquiry_vendor_id[16]; + unchar library_file_template[16]; + unchar reserved_2[16]; + unchar tool_name_1[32]; + unchar tool_name_2[32]; + unchar tool_name_3[32]; + unchar oem_contact_1[84]; + unchar oem_contact_2[84]; + unchar oem_contact_3[84]; +} PACKED gdth_oem_str; + +typedef struct { + gdth_oem_str_params params; + gdth_oem_str text; +} PACKED gdth_oem_str_ioctl; + /* board features */ typedef struct { unchar chaining; /* Chaining supported */ @@ -594,118 +644,6 @@ gdth_hentry_str entry[MAX_HDRIVES]; /* entries */ } PACKED gdth_hget_str; -/* scatter/gather element */ -typedef struct { - ulong32 sg_ptr; /* address */ - ulong32 sg_len; /* length */ -} PACKED gdth_sg_str; - -/* command structure */ -typedef struct { - ulong32 BoardNode; /* board node (always 0) */ - ulong32 CommandIndex; /* command number */ - ushort OpCode; /* the command (READ,..) */ - union { - struct { - ushort DeviceNo; /* number of cache drive */ - ulong32 BlockNo; /* block number */ - ulong32 BlockCnt; /* block count */ - ulong32 DestAddr; /* dest. addr. (if s/g: -1) */ - ulong32 sg_canz; /* s/g element count */ - gdth_sg_str sg_lst[GDTH_MAXSG]; /* s/g list */ - } PACKED cache; /* cache service cmd. str. */ - struct { - ushort param_size; /* size of p_param buffer */ - ulong32 subfunc; /* IOCTL function */ - ulong32 channel; /* device */ - ulong32 p_param; /* buffer */ - } PACKED ioctl; /* IOCTL command structure */ - struct { - ushort reserved; - union { - struct { - ulong32 msg_handle; /* message handle */ - ulong32 msg_addr; /* message buffer address */ - } PACKED msg; - unchar data[12]; /* buffer for rtc data, ... */ - } su; - } PACKED screen; /* screen service cmd. str. */ - struct { - ushort reserved; - ulong32 direction; /* data direction */ - ulong32 mdisc_time; /* disc. time (0: no timeout)*/ - ulong32 mcon_time; /* connect time(0: no to.) */ - ulong32 sdata; /* dest. addr. (if s/g: -1) */ - ulong32 sdlen; /* data length (bytes) */ - ulong32 clen; /* SCSI cmd. length(6,10,12) */ - unchar cmd[12]; /* SCSI command */ - unchar target; /* target ID */ - unchar lun; /* LUN */ - unchar bus; /* SCSI bus number */ - unchar priority; /* only 0 used */ - ulong32 sense_len; /* sense data length */ - ulong32 sense_data; /* sense data addr. */ - ulong32 link_p; /* linked cmds (not supp.) */ - ulong32 sg_ranz; /* s/g element count */ - gdth_sg_str sg_lst[GDTH_MAXSG]; /* s/g list */ - } PACKED raw; /* raw service cmd. struct. */ - } u; - /* additional variables */ - unchar Service; /* controller service */ - ushort Status; /* command result */ - ulong32 Info; /* additional information */ - Scsi_Cmnd *RequestBuffer; /* request buffer */ -} PACKED gdth_cmd_str; - -/* controller event structure */ -#define ES_ASYNC 1 -#define ES_DRIVER 2 -#define ES_TEST 3 -#define ES_SYNC 4 -typedef struct { - ushort size; /* size of structure */ - union { - char stream[16]; - struct { - ushort ionode; - ushort service; - ulong32 index; - } PACKED driver; - struct { - ushort ionode; - ushort service; - ushort status; - ulong32 info; - unchar scsi_coord[3]; - } PACKED async; - struct { - ushort ionode; - ushort service; - ushort status; - ulong32 info; - ushort hostdrive; - unchar scsi_coord[3]; - unchar sense_key; - } PACKED sync; - struct { - ulong32 l1, l2, l3, l4; - } PACKED test; - } eu; - ulong32 severity; - unchar event_string[256]; -} PACKED gdth_evt_data; - -typedef struct { - ulong32 first_stamp; - ulong32 last_stamp; - ushort same_count; - ushort event_source; - ushort event_idx; - unchar application; - unchar reserved; - gdth_evt_data event_data; -} PACKED gdth_evt_str; - /* DPRAM structures */ @@ -889,7 +827,9 @@ ulong32 brd_phys; /* slot number/BIOS address */ gdt6c_plx_regs *plx; /* PLX regs (new PCI contr.) */ gdth_cmd_str *pccb; /* address command structure */ + ulong32 ccb_phys; /* phys. address */ char *pscratch; /* scratch (DMA) buffer */ + ulong32 scratch_phys; /* phys. address */ unchar scratch_busy; /* in use? */ unchar scan_mode; /* current scan mode */ unchar irq; /* IRQ */ @@ -946,6 +886,10 @@ #if LINUX_VERSION_CODE >= 0x02015F spinlock_t smp_lock; #endif +#if LINUX_VERSION_CODE >= 0x020400 + struct pci_dev *pdev; +#endif + char oem_name[8]; } gdth_ha_str; /* structure for scsi_register(), SCSI bus != 0 */ @@ -1032,34 +976,145 @@ #endif const char *gdth_info(struct Scsi_Host *); +#if LINUX_VERSION_CODE >= 0x020501 int gdth_bios_param(struct scsi_device *,struct block_device *,sector_t,int *); int gdth_proc_info(char *,char **,off_t,int,int,int); int gdth_eh_abort(Scsi_Cmnd *scp); int gdth_eh_device_reset(Scsi_Cmnd *scp); int gdth_eh_bus_reset(Scsi_Cmnd *scp); int gdth_eh_host_reset(Scsi_Cmnd *scp); -#define GDTH { .proc_name = "gdth", \ - .proc_info = gdth_proc_info, \ - .name = "GDT SCSI Disk Array Controller",\ - .detect = gdth_detect, \ - .release = gdth_release, \ - .info = gdth_info, \ - .command = NULL, \ - .queuecommand = gdth_queuecommand, \ - .eh_abort_handler = gdth_eh_abort, \ - .eh_device_reset_handler = gdth_eh_device_reset, \ - .eh_bus_reset_handler = gdth_eh_bus_reset, \ - .eh_host_reset_handler = gdth_eh_host_reset, \ - .abort = gdth_abort, \ - .reset = gdth_reset, \ - .bios_param = gdth_bios_param, \ - .can_queue = GDTH_MAXCMDS, \ - .this_id = -1, \ - .sg_tablesize = GDTH_MAXSG, \ - .cmd_per_lun = GDTH_MAXC_P_L, \ - .present = 0, \ - .unchecked_isa_dma = 1, \ - .use_clustering = ENABLE_CLUSTERING } +#define GDTH { .proc_name = "gdth", \ + .proc_info = gdth_proc_info, \ + .name = "GDT SCSI Disk Array Controller",\ + .detect = gdth_detect, \ + .release = gdth_release, \ + .info = gdth_info, \ + .command = NULL, \ + .queuecommand = gdth_queuecommand, \ + .eh_abort_handler = gdth_eh_abort, \ + .eh_device_reset_handler = gdth_eh_device_reset, \ + .eh_bus_reset_handler = gdth_eh_bus_reset, \ + .eh_host_reset_handler = gdth_eh_host_reset, \ + .abort = NULL, \ + .reset = NULL, \ + .bios_param = gdth_bios_param, \ + .can_queue = GDTH_MAXCMDS, \ + .this_id = -1, \ + .sg_tablesize = GDTH_MAXSG, \ + .cmd_per_lun = GDTH_MAXC_P_L, \ + .present = 0, \ + .unchecked_isa_dma = 1, \ + .use_clustering = ENABLE_CLUSTERING} + +#elif LINUX_VERSION_CODE >= 0x020322 +int gdth_bios_param(Disk *,kdev_t,int *); +int gdth_proc_info(char *,char **,off_t,int,int,int); +int gdth_eh_abort(Scsi_Cmnd *scp); +int gdth_eh_device_reset(Scsi_Cmnd *scp); +int gdth_eh_bus_reset(Scsi_Cmnd *scp); +int gdth_eh_host_reset(Scsi_Cmnd *scp); +#define GDTH { proc_name: "gdth", \ + proc_info: gdth_proc_info, \ + name: "GDT SCSI Disk Array Controller",\ + detect: gdth_detect, \ + release: gdth_release, \ + info: gdth_info, \ + command: NULL, \ + queuecommand: gdth_queuecommand, \ + eh_abort_handler: gdth_eh_abort, \ + eh_device_reset_handler: gdth_eh_device_reset, \ + eh_bus_reset_handler: gdth_eh_bus_reset, \ + eh_host_reset_handler: gdth_eh_host_reset, \ + abort: gdth_abort, \ + reset: gdth_reset, \ + bios_param: gdth_bios_param, \ + can_queue: GDTH_MAXCMDS, \ + this_id: -1, \ + sg_tablesize: GDTH_MAXSG, \ + cmd_per_lun: GDTH_MAXC_P_L, \ + present: 0, \ + unchecked_isa_dma: 1, \ + use_clustering: ENABLE_CLUSTERING, \ + use_new_eh_code: 1 /* use new error code */ } + +#elif LINUX_VERSION_CODE >= 0x02015F +int gdth_bios_param(Disk *,kdev_t,int *); +extern struct proc_dir_entry proc_scsi_gdth; +int gdth_proc_info(char *,char **,off_t,int,int,int); +int gdth_eh_abort(Scsi_Cmnd *scp); +int gdth_eh_device_reset(Scsi_Cmnd *scp); +int gdth_eh_bus_reset(Scsi_Cmnd *scp); +int gdth_eh_host_reset(Scsi_Cmnd *scp); +#define GDTH { proc_dir: &proc_scsi_gdth, \ + proc_info: gdth_proc_info, \ + name: "GDT SCSI Disk Array Controller",\ + detect: gdth_detect, \ + release: gdth_release, \ + info: gdth_info, \ + command: NULL, \ + queuecommand: gdth_queuecommand, \ + eh_abort_handler: gdth_eh_abort, \ + eh_device_reset_handler: gdth_eh_device_reset, \ + eh_bus_reset_handler: gdth_eh_bus_reset, \ + eh_host_reset_handler: gdth_eh_host_reset, \ + abort: gdth_abort, \ + reset: gdth_reset, \ + bios_param: gdth_bios_param, \ + can_queue: GDTH_MAXCMDS, \ + this_id: -1, \ + sg_tablesize: GDTH_MAXSG, \ + cmd_per_lun: GDTH_MAXC_P_L, \ + present: 0, \ + unchecked_isa_dma: 1, \ + use_clustering: ENABLE_CLUSTERING, \ + use_new_eh_code: 1 /* use new error code */ } + +#elif LINUX_VERSION_CODE >= 0x010300 +int gdth_bios_param(Disk *,kdev_t,int *); +extern struct proc_dir_entry proc_scsi_gdth; +int gdth_proc_info(char *,char **,off_t,int,int,int); +#define GDTH { NULL, NULL, \ + &proc_scsi_gdth, \ + gdth_proc_info, \ + "GDT SCSI Disk Array Controller", \ + gdth_detect, \ + gdth_release, \ + gdth_info, \ + NULL, \ + gdth_queuecommand, \ + gdth_abort, \ + gdth_reset, \ + NULL, \ + gdth_bios_param, \ + GDTH_MAXCMDS, \ + -1, \ + GDTH_MAXSG, \ + GDTH_MAXC_P_L, \ + 0, \ + 1, \ + ENABLE_CLUSTERING} + +#else +int gdth_bios_param(Disk *,int,int *); +#define GDTH { NULL, NULL, \ + "GDT SCSI Disk Array Controller", \ + gdth_detect, \ + gdth_release, \ + gdth_info, \ + NULL, \ + gdth_queuecommand, \ + gdth_abort, \ + gdth_reset, \ + NULL, \ + gdth_bios_param, \ + GDTH_MAXCMDS, \ + -1, \ + GDTH_MAXSG, \ + GDTH_MAXC_P_L, \ + 0, \ + 1, \ + ENABLE_CLUSTERING} +#endif #endif diff -Nru a/drivers/scsi/gdth_ioctl.h b/drivers/scsi/gdth_ioctl.h --- a/drivers/scsi/gdth_ioctl.h Sun Mar 23 00:22:55 2003 +++ b/drivers/scsi/gdth_ioctl.h Sun Mar 23 00:22:55 2003 @@ -2,7 +2,7 @@ #define _GDTH_IOCTL_H /* gdth_ioctl.h - * $Id: gdth_ioctl.h,v 1.10 2001/05/22 06:28:59 achim Exp $ + * $Id: gdth_ioctl.h,v 1.11 2003/02/27 14:59:03 achim Exp $ */ /* IOCTLs */ @@ -23,8 +23,136 @@ #define GDTIOCTL_MAGIC 0xaffe0004 #define EVENT_SIZE 294 -#define MAX_HDRIVES 100 +#define GDTH_MAXSG 32 /* max. s/g elements */ +#define MAX_LDRIVES 255 /* max. log. drive count */ +#ifdef GDTH_IOCTL_PROC +#define MAX_HDRIVES 100 /* max. host drive count */ +#else +#define MAX_HDRIVES MAX_LDRIVES /* max. host drive count */ +#endif + +/* typedefs */ +#ifdef __KERNEL__ +typedef u32 ulong32; +#endif +#define PACKED __attribute__((packed)) + +/* scatter/gather element */ +typedef struct { + ulong32 sg_ptr; /* address */ + ulong32 sg_len; /* length */ +} PACKED gdth_sg_str; + +/* command structure */ +typedef struct { + ulong32 BoardNode; /* board node (always 0) */ + ulong32 CommandIndex; /* command number */ + ushort OpCode; /* the command (READ,..) */ + union { + struct { + ushort DeviceNo; /* number of cache drive */ + ulong32 BlockNo; /* block number */ + ulong32 BlockCnt; /* block count */ + ulong32 DestAddr; /* dest. addr. (if s/g: -1) */ + ulong32 sg_canz; /* s/g element count */ + gdth_sg_str sg_lst[GDTH_MAXSG]; /* s/g list */ + } PACKED cache; /* cache service cmd. str. */ + struct { + ushort param_size; /* size of p_param buffer */ + ulong32 subfunc; /* IOCTL function */ + ulong32 channel; /* device */ + ulong32 p_param; /* buffer */ + } PACKED ioctl; /* IOCTL command structure */ + struct { + ushort reserved; + union { + struct { + ulong32 msg_handle; /* message handle */ + ulong32 msg_addr; /* message buffer address */ + } PACKED msg; + unchar data[12]; /* buffer for rtc data, ... */ + } su; + } PACKED screen; /* screen service cmd. str. */ + struct { + ushort reserved; + ulong32 direction; /* data direction */ + ulong32 mdisc_time; /* disc. time (0: no timeout)*/ + ulong32 mcon_time; /* connect time(0: no to.) */ + ulong32 sdata; /* dest. addr. (if s/g: -1) */ + ulong32 sdlen; /* data length (bytes) */ + ulong32 clen; /* SCSI cmd. length(6,10,12) */ + unchar cmd[12]; /* SCSI command */ + unchar target; /* target ID */ + unchar lun; /* LUN */ + unchar bus; /* SCSI bus number */ + unchar priority; /* only 0 used */ + ulong32 sense_len; /* sense data length */ + ulong32 sense_data; /* sense data addr. */ + ulong32 link_p; /* linked cmds (not supp.) */ + ulong32 sg_ranz; /* s/g element count */ + gdth_sg_str sg_lst[GDTH_MAXSG]; /* s/g list */ + } PACKED raw; /* raw service cmd. struct. */ + } u; + /* additional variables */ + unchar Service; /* controller service */ + unchar reserved; + ushort Status; /* command result */ + ulong32 Info; /* additional information */ + void *RequestBuffer; /* request buffer */ +} PACKED gdth_cmd_str; + +/* controller event structure */ +#define ES_ASYNC 1 +#define ES_DRIVER 2 +#define ES_TEST 3 +#define ES_SYNC 4 +typedef struct { + ushort size; /* size of structure */ + union { + char stream[16]; + struct { + ushort ionode; + ushort service; + ulong32 index; + } PACKED driver; + struct { + ushort ionode; + ushort service; + ushort status; + ulong32 info; + unchar scsi_coord[3]; + } PACKED async; + struct { + ushort ionode; + ushort service; + ushort status; + ulong32 info; + ushort hostdrive; + unchar scsi_coord[3]; + unchar sense_key; + } PACKED sync; + struct { + ulong32 l1, l2, l3, l4; + } PACKED test; + } eu; + ulong32 severity; + unchar event_string[256]; +} PACKED gdth_evt_data; + +typedef struct { + ulong32 first_stamp; + ulong32 last_stamp; + ushort same_count; + ushort event_source; + ushort event_idx; + unchar application; + unchar reserved; + gdth_evt_data event_data; +} PACKED gdth_evt_str; + + +#ifdef GDTH_IOCTL_PROC /* IOCTL structure (write) */ typedef struct { ulong32 magic; /* IOCTL magic */ @@ -106,7 +234,82 @@ } hdr_list[MAX_HDRIVES]; /* index is host drive number */ } iu; } gdth_iord_str; +#endif + +#ifdef GDTH_IOCTL_CHRDEV +/* GDTIOCTL_GENERAL */ +typedef struct { + ushort ionode; /* controller number */ + ushort timeout; /* timeout */ + ulong32 info; /* error info */ + ushort status; /* status */ + ulong data_len; /* data buffer size */ + ulong sense_len; /* sense buffer size */ + gdth_cmd_str command; /* command */ +} gdth_ioctl_general; + +/* GDTIOCTL_LOCKDRV */ +typedef struct { + ushort ionode; /* controller number */ + unchar lock; /* lock/unlock */ + unchar drive_cnt; /* drive count */ + ushort drives[MAX_HDRIVES]; /* drives */ +} gdth_ioctl_lockdrv; + +/* GDTIOCTL_LOCKCHN */ +typedef struct { + ushort ionode; /* controller number */ + unchar lock; /* lock/unlock */ + unchar channel; /* channel */ +} gdth_ioctl_lockchn; + +/* GDTIOCTL_OSVERS */ +typedef struct { + unchar version; /* OS version */ + unchar subversion; /* OS subversion */ + ushort revision; /* revision */ +} gdth_ioctl_osvers; + +/* GDTIOCTL_CTRTYPE */ +typedef struct { + ushort ionode; /* controller number */ + unchar type; /* controller type */ + ushort info; /* slot etc. */ + ushort oem_id; /* OEM ID */ + ushort bios_ver; /* not used */ + ushort access; /* not used */ + ushort ext_type; /* extended type */ + ushort device_id; /* device ID */ + ushort sub_device_id; /* sub device ID */ +} gdth_ioctl_ctrtype; + +/* GDTIOCTL_EVENT */ +typedef struct { + ushort ionode; + int erase; /* erase event? */ + int handle; /* event handle */ + gdth_evt_str event; +} gdth_ioctl_event; +/* GDTIOCTL_RESCAN/GDTIOCTL_HDRLIST */ +typedef struct { + ushort ionode; /* controller number */ + unchar flag; /* add/remove */ + ushort hdr_no; /* drive no. */ + struct { + unchar bus; /* SCSI bus */ + unchar target; /* target ID */ + unchar lun; /* LUN */ + unchar cluster_type; /* cluster properties */ + } hdr_list[MAX_HDRIVES]; /* index is host drive number */ +} gdth_ioctl_rescan; +/* GDTIOCTL_RESET_BUS/GDTIOCTL_RESET_DRV */ +typedef struct { + ushort ionode; /* controller number */ + ushort number; /* bus/host drive number */ + ushort status; /* status */ +} gdth_ioctl_reset; #endif +#endif diff -Nru a/drivers/scsi/gdth_proc.c b/drivers/scsi/gdth_proc.c --- a/drivers/scsi/gdth_proc.c Sun Mar 23 00:22:53 2003 +++ b/drivers/scsi/gdth_proc.c Sun Mar 23 00:22:53 2003 @@ -1,8 +1,7 @@ /* gdth_proc.c - * $Id: gdth_proc.c,v 1.33 2001/08/10 07:54:39 achim Exp $ + * $Id: gdth_proc.c,v 1.35 2003/02/27 15:00:44 achim Exp $ */ -#include "gdth_ioctl.h" #if LINUX_VERSION_CODE >= 0x020407 #include #endif @@ -33,22 +32,33 @@ static int gdth_set_info(char *buffer,int length,int vh,int hanum,int busnum) { - int ret_val; -#if LINUX_VERSION_CODE >= 0x020322 + int ret_val = -EINVAL; +#if LINUX_VERSION_CODE >= 0x020503 + Scsi_Request *scp; + Scsi_Device *sdev; +#elif LINUX_VERSION_CODE >= 0x020322 Scsi_Cmnd *scp; Scsi_Device *sdev; #else Scsi_Cmnd scp; Scsi_Device sdev; #endif +#ifdef GDTH_IOCTL_PROC gdth_iowr_str *piowr; - - TRACE2(("gdth_set_info() ha %d bus %d\n",hanum,busnum)); piowr = (gdth_iowr_str *)buffer; +#endif + TRACE2(("gdth_set_info() ha %d bus %d\n",hanum,busnum)); -#if LINUX_VERSION_CODE >= 0x020322 - sdev = scsi_get_host_dev(gdth_ctr_vtab[vh]); - scp = scsi_get_command(sdev, GFP_KERNEL); +#if LINUX_VERSION_CODE >= 0x020503 + sdev = scsi_get_host_dev(gdth_ctr_tab[hanum]); + scp = scsi_allocate_request(sdev); + if (!scp) + return -ENOMEM; + scp->sr_cmd_len = 12; + scp->sr_use_sg = 0; +#elif LINUX_VERSION_CODE >= 0x020322 + sdev = scsi_get_host_dev(gdth_ctr_tab[hanum]); + scp = scsi_allocate_device(sdev, 1, FALSE); if (!scp) return -ENOMEM; scp->cmd_len = 12; @@ -56,7 +66,7 @@ #else memset(&sdev,0,sizeof(Scsi_Device)); memset(&scp, 0,sizeof(Scsi_Cmnd)); - sdev.host = scp.host = gdth_ctr_vtab[vh]; + sdev.host = scp.host = gdth_ctr_tab[hanum]; sdev.id = scp.target = sdev.host->this_id; scp.device = &sdev; #endif @@ -66,6 +76,7 @@ buffer += 5; length -= 5; ret_val = gdth_set_asc_info( buffer, length, hanum, scp ); +#ifdef GDTH_IOCTL_PROC } else if (piowr->magic == GDTIOCTL_MAGIC) { ret_val = gdth_set_bin_info( buffer, length, hanum, scp ); } else { @@ -75,19 +86,22 @@ printk("GDT: Please update your driver.\n"); else printk("GDT: Please update your tool.\n"); - ret_val = -EINVAL; +#endif } - } else { - ret_val = -EINVAL; } -#if LINUX_VERSION_CODE >= 0x020322 - scsi_put_command(scp); +#if LINUX_VERSION_CODE >= 0x020503 + scsi_release_request(scp); + scsi_free_host_dev(sdev); +#elif LINUX_VERSION_CODE >= 0x020322 + scsi_release_command(scp); scsi_free_host_dev(sdev); #endif return ret_val; } -#if LINUX_VERSION_CODE >= 0x020322 +#if LINUX_VERSION_CODE >= 0x020503 +static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Request *scp) +#elif LINUX_VERSION_CODE >= 0x020322 static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Cmnd *scp) #else static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Cmnd scp) @@ -98,6 +112,7 @@ gdth_ha_str *ha; gdth_cmd_str gdtcmd; gdth_cpar_str *pcpar; + ulong32 paddr; char cmnd[MAX_COMMAND_SIZE]; memset(cmnd, 0xff, 12); @@ -133,7 +148,9 @@ gdtcmd.OpCode = GDT_FLUSH; gdtcmd.u.cache.DeviceNo = i; gdtcmd.u.cache.BlockNo = 1; -#if LINUX_VERSION_CODE >= 0x020322 +#if LINUX_VERSION_CODE >= 0x020503 + gdth_do_req(scp, &gdtcmd, cmnd, 30); +#elif LINUX_VERSION_CODE >= 0x020322 gdth_do_cmd(scp, &gdtcmd, cmnd, 30); #else gdth_do_cmd(&scp, &gdtcmd, cmnd, 30); @@ -178,23 +195,25 @@ } if (wb_mode) { - if (!gdth_ioctl_alloc(hanum, sizeof(gdth_cpar_str), TRUE)) + if (!gdth_ioctl_alloc(hanum, sizeof(gdth_cpar_str), TRUE, &paddr)) return(-EBUSY); pcpar = (gdth_cpar_str *)ha->pscratch; memcpy( pcpar, &ha->cpar, sizeof(gdth_cpar_str) ); gdtcmd.Service = CACHESERVICE; gdtcmd.OpCode = GDT_IOCTL; - gdtcmd.u.ioctl.p_param = virt_to_bus(pcpar); + gdtcmd.u.ioctl.p_param = paddr; gdtcmd.u.ioctl.param_size = sizeof(gdth_cpar_str); gdtcmd.u.ioctl.subfunc = CACHE_CONFIG; gdtcmd.u.ioctl.channel = INVALID_CHANNEL; pcpar->write_back = wb_mode==1 ? 0:1; -#if LINUX_VERSION_CODE >= 0x020322 +#if LINUX_VERSION_CODE >= 0x020503 + gdth_do_req(scp, &gdtcmd, cmnd, 30); +#elif LINUX_VERSION_CODE >= 0x020322 gdth_do_cmd(scp, &gdtcmd, cmnd, 30); #else gdth_do_cmd(&scp, &gdtcmd, cmnd, 30); #endif - gdth_ioctl_free(hanum, ha->pscratch); + gdth_ioctl_free(hanum, GDTH_SCRATCH, ha->pscratch, paddr); printk("Done.\n"); return(orig_length); } @@ -203,7 +222,10 @@ return(-EINVAL); } -#if LINUX_VERSION_CODE >= 0x020322 +#ifdef GDTH_IOCTL_PROC +#if LINUX_VERSION_CODE >= 0x020503 +static int gdth_set_bin_info(char *buffer,int length,int hanum,Scsi_Request *scp) +#elif LINUX_VERSION_CODE >= 0x020322 static int gdth_set_bin_info(char *buffer,int length,int hanum,Scsi_Cmnd *scp) #else static int gdth_set_bin_info(char *buffer,int length,int hanum,Scsi_Cmnd scp) @@ -216,7 +238,7 @@ gdth_iord_str *piord; gdth_cmd_str *pcmd; gdth_evt_str *pevt; - ulong32 *ppadd, add_size, *ppadd2, add_size2, info; + ulong32 *ppadd, add_size, *ppadd2, add_size2, info, paddr; ulong flags; gdth_cmd_str gdtcmd; int drv_cyls, drv_hds, drv_secs; @@ -273,21 +295,25 @@ return(-EINVAL); } if (!gdth_ioctl_alloc( hanum, sizeof(gdth_iord_str)+add_size+add_size2, - TRUE )) + TRUE, &paddr )) return(-EBUSY); piord = (gdth_iord_str *)ha->pscratch; - piord->size = sizeof(gdth_iord_str) + add_size + add_size2; if (add_size > 0) { memcpy(piord->iu.general.data, piowr->iu.general.data, add_size); - *ppadd = virt_to_bus(piord->iu.general.data); + *ppadd = paddr + GDTOFFSOF(gdth_iord_str, iu.general.data[0]); } if (add_size2 > 0) { memcpy(piord->iu.general.data+add_size, piowr->iu.general.data, add_size2); - *ppadd2 = virt_to_bus(piord->iu.general.data+add_size); + *ppadd2 = paddr + GDTOFFSOF(gdth_iord_str, iu.general.data[0]) + add_size2; } + /* do IOCTL */ -#if LINUX_VERSION_CODE >= 0x020322 +#if LINUX_VERSION_CODE >= 0x020503 + gdth_do_req(scp, pcmd, cmnd, piowr->timeout); + piord->status = (scp->sr_command->SCp.Message << 16) | + scp->sr_command->SCp.Status; +#elif LINUX_VERSION_CODE >= 0x020322 gdth_do_cmd(scp, pcmd, cmnd, piowr->timeout); piord->status = (scp->SCp.Message<<16)|scp->SCp.Status; #else @@ -297,7 +323,7 @@ break; case GDTIOCTL_DRVERS: - if (!gdth_ioctl_alloc( hanum, sizeof(gdth_iord_str), TRUE )) + if (!gdth_ioctl_alloc( hanum, sizeof(gdth_iord_str), TRUE, &paddr )) return(-EBUSY); piord = (gdth_iord_str *)ha->pscratch; piord->size = sizeof(gdth_iord_str); @@ -306,7 +332,7 @@ break; case GDTIOCTL_CTRTYPE: - if (!gdth_ioctl_alloc( hanum, sizeof(gdth_iord_str), TRUE )) + if (!gdth_ioctl_alloc( hanum, sizeof(gdth_iord_str), TRUE, &paddr )) return(-EBUSY); piord = (gdth_iord_str *)ha->pscratch; piord->size = sizeof(gdth_iord_str); @@ -332,7 +358,7 @@ break; case GDTIOCTL_CTRCNT: - if (!gdth_ioctl_alloc( hanum, sizeof(gdth_iord_str), TRUE )) + if (!gdth_ioctl_alloc( hanum, sizeof(gdth_iord_str), TRUE, &paddr )) return(-EBUSY); piord = (gdth_iord_str *)ha->pscratch; piord->size = sizeof(gdth_iord_str); @@ -341,7 +367,7 @@ break; case GDTIOCTL_OSVERS: - if (!gdth_ioctl_alloc( hanum, sizeof(gdth_iord_str), TRUE )) + if (!gdth_ioctl_alloc( hanum, sizeof(gdth_iord_str), TRUE, &paddr )) return(-EBUSY); piord = (gdth_iord_str *)ha->pscratch; piord->size = sizeof(gdth_iord_str); @@ -352,7 +378,7 @@ break; case GDTIOCTL_LOCKDRV: - if (!gdth_ioctl_alloc( hanum, sizeof(gdth_iord_str), TRUE )) + if (!gdth_ioctl_alloc( hanum, sizeof(gdth_iord_str), TRUE, &paddr )) return(-EBUSY); piord = (gdth_iord_str *)ha->pscratch; for (i = 0; i < piowr->iu.lockdrv.drive_cnt; ++i) { @@ -378,7 +404,7 @@ break; case GDTIOCTL_LOCKCHN: - if (!gdth_ioctl_alloc( hanum, sizeof(gdth_iord_str), TRUE )) + if (!gdth_ioctl_alloc( hanum, sizeof(gdth_iord_str), TRUE, &paddr )) return(-EBUSY); i = piowr->iu.lockchn.channel; if (i < ha->bus_cnt) { @@ -406,7 +432,7 @@ break; case GDTIOCTL_EVENT: - if (!gdth_ioctl_alloc( hanum, sizeof(gdth_iord_str), TRUE )) + if (!gdth_ioctl_alloc( hanum, sizeof(gdth_iord_str), TRUE, &paddr )) return(-EBUSY); piord = (gdth_iord_str *)ha->pscratch; if (piowr->iu.event.erase == 0xff) { @@ -439,16 +465,19 @@ piord->size = sizeof(gdth_iord_str); piord->status = S_OK; break; - + case GDTIOCTL_SCSI: - if (!gdth_ioctl_alloc( hanum, sizeof(gdth_iord_str), TRUE )) +#if LINUX_VERSION_CODE >= 0x020503 + return(-EINVAL); +#else + if (!gdth_ioctl_alloc( hanum, sizeof(gdth_iord_str), TRUE, &paddr )) return(-EBUSY); piord = (gdth_iord_str *)ha->pscratch; piord->size = sizeof(gdth_iord_str); memcpy(cmnd, piowr->iu.scsi.cmd, 12); #if LINUX_VERSION_CODE >= 0x020322 - scp->device->id = piowr->iu.scsi.target; - scp->device->channel = virt_ctr ? 0 : piowr->iu.scsi.bus; + scp->target = piowr->iu.scsi.target; + scp->channel = virt_ctr ? 0 : piowr->iu.scsi.bus; scp->cmd_len = piowr->iu.scsi.cmd_len; gdth_do_cmd(scp, pcmd, cmnd, piowr->timeout); piord->status = (scp->SCp.Message<<16)|scp->SCp.Status; @@ -459,15 +488,47 @@ gdth_do_cmd(&scp, pcmd, cmnd, piowr->timeout); piord->status = (scp.SCp.Message<<16)|scp.SCp.Status; #endif +#endif break; case GDTIOCTL_RESET_BUS: - if (!gdth_ioctl_alloc( hanum, sizeof(gdth_iord_str), TRUE )) + if (!gdth_ioctl_alloc( hanum, sizeof(gdth_iord_str), TRUE, &paddr )) return(-EBUSY); piord = (gdth_iord_str *)ha->pscratch; piord->size = sizeof(gdth_iord_str); -#if LINUX_VERSION_CODE >= 0x020322 - scp->device->channel = virt_ctr ? 0 : piowr->iu.scsi.bus; +#if LINUX_VERSION_CODE >= 0x02053C + { + Scsi_Device *sdev; + Scsi_Cmnd *scmnd; + + sdev = scsi_get_host_dev(gdth_ctr_tab[hanum]); + scmnd= scsi_get_command(sdev, GFP_KERNEL); + if (!scmnd) + return(-ENOMEM); + scmnd->device->host = scp->sr_host; + scmnd->device->channel = virt_ctr ? 0 : piowr->iu.scsi.bus; + piord->status = (ulong32)gdth_eh_bus_reset( scmnd ); + if (piord->status == SUCCESS) + piord->status = S_OK; + else + piord->status = S_GENERR; + scsi_put_command(scmnd); + scsi_free_host_dev(sdev); + } +#elif LINUX_VERSION_CODE >= 0x020503 + { + Scsi_Cmnd scmnd; + + scmnd.host = scp->sr_host; + scmnd.channel = virt_ctr ? 0 : piowr->iu.scsi.bus; + piord->status = (ulong32)gdth_eh_bus_reset( &scmnd ); + if (piord->status == SUCCESS) + piord->status = S_OK; + else + piord->status = S_GENERR; + } +#elif LINUX_VERSION_CODE >= 0x020322 + scp->channel = virt_ctr ? 0 : piowr->iu.scsi.bus; piord->status = (ulong32)gdth_eh_bus_reset( scp ); if (piord->status == SUCCESS) piord->status = S_OK; @@ -486,7 +547,7 @@ break; case GDTIOCTL_HDRLIST: - if (!gdth_ioctl_alloc( hanum, sizeof(gdth_iord_str), TRUE )) + if (!gdth_ioctl_alloc( hanum, sizeof(gdth_iord_str), TRUE, &paddr )) return(-EBUSY); piord = (gdth_iord_str *)ha->pscratch; piord->size = sizeof(gdth_iord_str); @@ -501,7 +562,12 @@ gdtcmd.Service = CACHESERVICE; gdtcmd.OpCode = GDT_CLUST_INFO; gdtcmd.u.cache.DeviceNo = i; -#if LINUX_VERSION_CODE >= 0x020322 +#if LINUX_VERSION_CODE >= 0x020503 + gdth_do_req(scp, &gdtcmd, cmnd, 30); + if (scp->sr_command->SCp.Status == S_OK) + piord->iu.hdr_list[i].cluster_type = + (unchar)scp->sr_command->SCp.Message; +#elif LINUX_VERSION_CODE >= 0x020322 gdth_do_cmd(scp, &gdtcmd, cmnd, 30); if (scp->SCp.Status == S_OK) piord->iu.hdr_list[i].cluster_type = @@ -520,7 +586,7 @@ break; case GDTIOCTL_RESCAN: - if (!gdth_ioctl_alloc( hanum, sizeof(gdth_iord_str), TRUE )) + if (!gdth_ioctl_alloc( hanum, sizeof(gdth_iord_str), TRUE, &paddr )) return(-EBUSY); piord = (gdth_iord_str *)ha->pscratch; piord->size = sizeof(gdth_iord_str); @@ -532,7 +598,11 @@ gdtcmd.Service = CACHESERVICE; gdtcmd.OpCode = GDT_INIT; gdtcmd.u.cache.DeviceNo = LINUX_OS; -#if LINUX_VERSION_CODE >= 0x020322 +#if LINUX_VERSION_CODE >= 0x020503 + gdth_do_req(scp, &gdtcmd, cmnd, 30); + status = (ushort)scp->sr_command->SCp.Status; + info = (ulong32)scp->sr_command->SCp.Message; +#elif LINUX_VERSION_CODE >= 0x020322 gdth_do_cmd(scp, &gdtcmd, cmnd, 30); status = (ushort)scp->SCp.Status; info = (ulong32)scp->SCp.Message; @@ -557,7 +627,11 @@ gdtcmd.Service = CACHESERVICE; gdtcmd.OpCode = GDT_INFO; gdtcmd.u.cache.DeviceNo = k; -#if LINUX_VERSION_CODE >= 0x020322 +#if LINUX_VERSION_CODE >= 0x020503 + gdth_do_req(scp, &gdtcmd, cmnd, 30); + status = (ushort)scp->sr_command->SCp.Status; + info = (ulong32)scp->sr_command->SCp.Message; +#elif LINUX_VERSION_CODE >= 0x020322 gdth_do_cmd(scp, &gdtcmd, cmnd, 30); status = (ushort)scp->SCp.Status; info = (ulong32)scp->SCp.Message; @@ -591,7 +665,11 @@ gdtcmd.Service = CACHESERVICE; gdtcmd.OpCode = GDT_DEVTYPE; gdtcmd.u.cache.DeviceNo = k; -#if LINUX_VERSION_CODE >= 0x020322 +#if LINUX_VERSION_CODE >= 0x020503 + gdth_do_req(scp, &gdtcmd, cmnd, 30); + status = (ushort)scp->sr_command->SCp.Status; + info = (ulong32)scp->sr_command->SCp.Message; +#elif LINUX_VERSION_CODE >= 0x020322 gdth_do_cmd(scp, &gdtcmd, cmnd, 30); status = (ushort)scp->SCp.Status; info = (ulong32)scp->SCp.Message; @@ -609,7 +687,11 @@ gdtcmd.Service = CACHESERVICE; gdtcmd.OpCode = GDT_CLUST_INFO; gdtcmd.u.cache.DeviceNo = k; -#if LINUX_VERSION_CODE >= 0x020322 +#if LINUX_VERSION_CODE >= 0x020503 + gdth_do_req(scp, &gdtcmd, cmnd, 30); + status = (ushort)scp->sr_command->SCp.Status; + info = (ulong32)scp->sr_command->SCp.Message; +#elif LINUX_VERSION_CODE >= 0x020322 gdth_do_cmd(scp, &gdtcmd, cmnd, 30); status = (ushort)scp->SCp.Status; info = (ulong32)scp->SCp.Message; @@ -628,7 +710,11 @@ gdtcmd.Service = CACHESERVICE; gdtcmd.OpCode = GDT_RW_ATTRIBS; gdtcmd.u.cache.DeviceNo = k; -#if LINUX_VERSION_CODE >= 0x020322 +#if LINUX_VERSION_CODE >= 0x020503 + gdth_do_req(scp, &gdtcmd, cmnd, 30); + status = (ushort)scp->sr_command->SCp.Status; + info = (ulong32)scp->sr_command->SCp.Message; +#elif LINUX_VERSION_CODE >= 0x020322 gdth_do_cmd(scp, &gdtcmd, cmnd, 30); status = (ushort)scp->SCp.Status; info = (ulong32)scp->SCp.Message; @@ -646,7 +732,7 @@ break; case GDTIOCTL_RESET_DRV: - if (!gdth_ioctl_alloc( hanum, sizeof(gdth_iord_str), TRUE )) + if (!gdth_ioctl_alloc( hanum, sizeof(gdth_iord_str), TRUE, &paddr )) return(-EBUSY); piord = (gdth_iord_str *)ha->pscratch; piord->size = sizeof(gdth_iord_str); @@ -656,7 +742,10 @@ gdtcmd.Service = CACHESERVICE; gdtcmd.OpCode = GDT_CLUST_RESET; gdtcmd.u.cache.DeviceNo = i; -#if LINUX_VERSION_CODE >= 0x020322 +#if LINUX_VERSION_CODE >= 0x020503 + gdth_do_req(scp, &gdtcmd, cmnd, 30); + piord->status = (ushort)scp->sr_command->SCp.Status; +#elif LINUX_VERSION_CODE >= 0x020322 gdth_do_cmd(scp, &gdtcmd, cmnd, 30); piord->status = (scp->SCp.Message<<16)|scp->SCp.Status; #else @@ -671,6 +760,7 @@ } return length; } +#endif static int gdth_get_info(char *buffer,char **start,off_t offset, int length,int vh,int hanum,int busnum) @@ -678,14 +768,16 @@ int size = 0,len = 0; off_t begin = 0,pos = 0; gdth_ha_str *ha; - gdth_iord_str *piord; int id, i, j, k, sec, flag; int no_mdrv = 0, drv_no, is_mirr; - ulong32 cnt; + ulong32 cnt, paddr; gdth_cmd_str gdtcmd; gdth_evt_str estr; -#if LINUX_VERSION_CODE >= 0x020322 +#if LINUX_VERSION_CODE >= 0x020503 + Scsi_Request *scp; + Scsi_Device *sdev; +#elif LINUX_VERSION_CODE >= 0x020322 Scsi_Cmnd *scp; Scsi_Device *sdev; #else @@ -710,9 +802,16 @@ TRACE2(("gdth_get_info() ha %d bus %d\n",hanum,busnum)); ha = HADATA(gdth_ctr_tab[hanum]); -#if LINUX_VERSION_CODE >= 0x020322 - sdev = scsi_get_host_dev(gdth_ctr_vtab[vh]); - scp = scsi_get_command(sdev, GFP_KERNEL); +#if LINUX_VERSION_CODE >= 0x020503 + sdev = scsi_get_host_dev(gdth_ctr_tab[hanum]); + scp = scsi_allocate_request(sdev); + if (!scp) + return -ENOMEM; + scp->sr_cmd_len = 12; + scp->sr_use_sg = 0; +#elif LINUX_VERSION_CODE >= 0x020322 + sdev = scsi_get_host_dev(gdth_ctr_tab[hanum]); + scp = scsi_allocate_device(sdev, 1, FALSE); if (!scp) return -ENOMEM; scp->cmd_len = 12; @@ -720,13 +819,15 @@ #else memset(&sdev,0,sizeof(Scsi_Device)); memset(&scp, 0,sizeof(Scsi_Cmnd)); - sdev.host = scp.host = gdth_ctr_vtab[vh]; + sdev.host = scp.host = gdth_ctr_tab[hanum]; sdev.id = scp.target = sdev.host->this_id; scp.device = &sdev; #endif +#ifdef GDTH_IOCTL_PROC /* ioctl from tool? */ if (!gdth_ioctl_check_bin(hanum, (ushort)length)) { +#endif /* request is i.e. "cat /proc/scsi/gdth/0" */ /* format: %-15s\t%-10s\t%-15s\t%s */ /* driver parameters */ @@ -798,7 +899,7 @@ len += size; pos = begin + len; flag = FALSE; - buf = gdth_ioctl_alloc(hanum, GDTH_SCRATCH, FALSE); + buf = gdth_ioctl_alloc(hanum, GDTH_SCRATCH, FALSE, &paddr); if (!buf) goto stop_output; for (i = 0; i < ha->bus_cnt; ++i) { @@ -807,7 +908,7 @@ pds = (gdth_dskstat_str *)(buf + GDTH_SCRATCH/4); gdtcmd.Service = CACHESERVICE; gdtcmd.OpCode = GDT_IOCTL; - gdtcmd.u.ioctl.p_param = virt_to_bus(pds); + gdtcmd.u.ioctl.p_param = paddr + GDTH_SCRATCH/4; gdtcmd.u.ioctl.param_size = 3*GDTH_SCRATCH/4; gdtcmd.u.ioctl.subfunc = DSK_STATISTICS | L_CTRL_PATTERN; gdtcmd.u.ioctl.channel = ha->raw[i].address | INVALID_CHANNEL; @@ -818,7 +919,10 @@ sizeof(pds->list[0]); if (pds->entries > cnt) pds->entries = cnt; -#if LINUX_VERSION_CODE >= 0x020322 +#if LINUX_VERSION_CODE >= 0x020503 + gdth_do_req(scp, &gdtcmd, cmnd, 30); + if (scp->sr_command->SCp.Status != S_OK) +#elif LINUX_VERSION_CODE >= 0x020322 gdth_do_cmd(scp, &gdtcmd, cmnd, 30); if (scp->SCp.Status != S_OK) #else @@ -837,12 +941,15 @@ pdi = (gdth_diskinfo_str *)buf; gdtcmd.Service = CACHESERVICE; gdtcmd.OpCode = GDT_IOCTL; - gdtcmd.u.ioctl.p_param = virt_to_bus(pdi); + gdtcmd.u.ioctl.p_param = paddr; gdtcmd.u.ioctl.param_size = sizeof(gdth_diskinfo_str); gdtcmd.u.ioctl.subfunc = SCSI_DR_INFO | L_CTRL_PATTERN; gdtcmd.u.ioctl.channel = ha->raw[i].address | ha->raw[i].id_list[j]; -#if LINUX_VERSION_CODE >= 0x020322 +#if LINUX_VERSION_CODE >= 0x020503 + gdth_do_req(scp, &gdtcmd, cmnd, 30); + if (scp->sr_command->SCp.Status == S_OK) +#elif LINUX_VERSION_CODE >= 0x020322 gdth_do_cmd(scp, &gdtcmd, cmnd, 30); if (scp->SCp.Status == S_OK) #else @@ -892,13 +999,16 @@ pdef = (gdth_defcnt_str *)buf; gdtcmd.Service = CACHESERVICE; gdtcmd.OpCode = GDT_IOCTL; - gdtcmd.u.ioctl.p_param = virt_to_bus(pdef); + gdtcmd.u.ioctl.p_param = paddr; gdtcmd.u.ioctl.param_size = sizeof(gdth_defcnt_str); gdtcmd.u.ioctl.subfunc = SCSI_DEF_CNT | L_CTRL_PATTERN; gdtcmd.u.ioctl.channel = ha->raw[i].address | ha->raw[i].id_list[j]; pdef->sddc_type = 0x08; -#if LINUX_VERSION_CODE >= 0x020322 +#if LINUX_VERSION_CODE >= 0x020503 + gdth_do_req(scp, &gdtcmd, cmnd, 30); + if (scp->sr_command->SCp.Status == S_OK) +#elif LINUX_VERSION_CODE >= 0x020322 gdth_do_cmd(scp, &gdtcmd, cmnd, 30); if (scp->SCp.Status == S_OK) #else @@ -920,7 +1030,7 @@ goto stop_output; } } - gdth_ioctl_free(hanum, buf); + gdth_ioctl_free(hanum, GDTH_SCRATCH, buf, paddr); if (!flag) { size = sprintf(buffer+len, "\n --\n"); @@ -932,7 +1042,7 @@ len += size; pos = begin + len; flag = FALSE; - buf = gdth_ioctl_alloc(hanum, GDTH_SCRATCH, FALSE); + buf = gdth_ioctl_alloc(hanum, GDTH_SCRATCH, FALSE, &paddr); if (!buf) goto stop_output; for (i = 0; i < MAX_LDRIVES; ++i) { @@ -947,11 +1057,14 @@ pcdi = (gdth_cdrinfo_str *)buf; gdtcmd.Service = CACHESERVICE; gdtcmd.OpCode = GDT_IOCTL; - gdtcmd.u.ioctl.p_param = virt_to_bus(pcdi); + gdtcmd.u.ioctl.p_param = paddr; gdtcmd.u.ioctl.param_size = sizeof(gdth_cdrinfo_str); gdtcmd.u.ioctl.subfunc = CACHE_DRV_INFO; gdtcmd.u.ioctl.channel = drv_no; -#if LINUX_VERSION_CODE >= 0x020322 +#if LINUX_VERSION_CODE >= 0x020503 + gdth_do_req(scp, &gdtcmd, cmnd, 30); + if (scp->sr_command->SCp.Status != S_OK) +#elif LINUX_VERSION_CODE >= 0x020322 gdth_do_cmd(scp, &gdtcmd, cmnd, 30); if (scp->SCp.Status != S_OK) #else @@ -1034,7 +1147,7 @@ if (pos > offset + length) goto stop_output; } - gdth_ioctl_free(hanum, buf); + gdth_ioctl_free(hanum, GDTH_SCRATCH, buf, paddr); if (!flag) { size = sprintf(buffer+len, "\n --\n"); @@ -1046,7 +1159,7 @@ len += size; pos = begin + len; flag = FALSE; - buf = gdth_ioctl_alloc(hanum, GDTH_SCRATCH, FALSE); + buf = gdth_ioctl_alloc(hanum, GDTH_SCRATCH, FALSE, &paddr); if (!buf) goto stop_output; for (i = 0; i < MAX_LDRIVES; ++i) { @@ -1057,11 +1170,14 @@ pai = (gdth_arrayinf_str *)buf; gdtcmd.Service = CACHESERVICE; gdtcmd.OpCode = GDT_IOCTL; - gdtcmd.u.ioctl.p_param = virt_to_bus(pai); + gdtcmd.u.ioctl.p_param = paddr; gdtcmd.u.ioctl.param_size = sizeof(gdth_arrayinf_str); gdtcmd.u.ioctl.subfunc = ARRAY_INFO | LA_CTRL_PATTERN; gdtcmd.u.ioctl.channel = i; -#if LINUX_VERSION_CODE >= 0x020322 +#if LINUX_VERSION_CODE >= 0x020503 + gdth_do_req(scp, &gdtcmd, cmnd, 30); + if (scp->sr_command->SCp.Status == S_OK) +#elif LINUX_VERSION_CODE >= 0x020322 gdth_do_cmd(scp, &gdtcmd, cmnd, 30); if (scp->SCp.Status == S_OK) #else @@ -1112,7 +1228,7 @@ goto stop_output; } } - gdth_ioctl_free(hanum, buf); + gdth_ioctl_free(hanum, GDTH_SCRATCH, buf, paddr); if (!flag) { size = sprintf(buffer+len, "\n --\n"); @@ -1124,7 +1240,7 @@ len += size; pos = begin + len; flag = FALSE; - buf = gdth_ioctl_alloc(hanum, GDTH_SCRATCH, FALSE); + buf = gdth_ioctl_alloc(hanum, sizeof(gdth_hget_str), FALSE, &paddr); if (!buf) goto stop_output; for (i = 0; i < MAX_LDRIVES; ++i) { @@ -1136,13 +1252,16 @@ phg = (gdth_hget_str *)buf; gdtcmd.Service = CACHESERVICE; gdtcmd.OpCode = GDT_IOCTL; - gdtcmd.u.ioctl.p_param = virt_to_bus(phg); + gdtcmd.u.ioctl.p_param = paddr; gdtcmd.u.ioctl.param_size = sizeof(gdth_hget_str); gdtcmd.u.ioctl.subfunc = HOST_GET | LA_CTRL_PATTERN; gdtcmd.u.ioctl.channel = i; phg->entries = MAX_HDRIVES; phg->offset = GDTOFFSOF(gdth_hget_str, entry[0]); -#if LINUX_VERSION_CODE >= 0x020322 +#if LINUX_VERSION_CODE >= 0x020503 + gdth_do_req(scp, &gdtcmd, cmnd, 30); + if (scp->sr_command->SCp.Status != S_OK) +#elif LINUX_VERSION_CODE >= 0x020322 gdth_do_cmd(scp, &gdtcmd, cmnd, 30); if (scp->SCp.Status != S_OK) #else @@ -1164,7 +1283,7 @@ } } } - gdth_ioctl_free(hanum, buf); + gdth_ioctl_free(hanum, sizeof(gdth_hget_str), buf, paddr); for (i = 0; i < MAX_HDRIVES; ++i) { if (!(ha->hdr[i].present)) @@ -1221,20 +1340,27 @@ if (id == -1) break; } +#ifdef GDTH_IOCTL_PROC } else { + gdth_iord_str *piord; + /* request from tool (GDTMON,..) */ piord = (gdth_iord_str *)ha->pscratch; if (piord == NULL) goto stop_output; length = piord->size; memcpy(buffer+len, (char *)piord, length); - gdth_ioctl_free(hanum, ha->pscratch); + gdth_ioctl_free(hanum, GDTH_SCRATCH, ha->pscratch, paddr); len = length; } +#endif stop_output: -#if LINUX_VERSION_CODE >= 0x020322 - scsi_put_command(scp); +#if LINUX_VERSION_CODE >= 0x020503 + scsi_release_request(scp); + scsi_free_host_dev(sdev); +#elif LINUX_VERSION_CODE >= 0x020322 + scsi_release_command(scp); scsi_free_host_dev(sdev); #endif *start = buffer +(offset-begin); @@ -1246,6 +1372,26 @@ return(len); } +#if LINUX_VERSION_CODE >= 0x020503 +static void gdth_do_req(Scsi_Request *scp, gdth_cmd_str *gdtcmd, + char *cmnd, int timeout) +{ + unsigned bufflen; + DECLARE_COMPLETION(wait); + + TRACE2(("gdth_do_req()\n")); + if (gdtcmd != NULL) { + bufflen = sizeof(gdth_cmd_str); + } else { + bufflen = 0; + } + scp->sr_request->rq_status = RQ_SCSI_BUSY; + scp->sr_request->waiting = &wait; + scsi_do_req(scp, cmnd, gdtcmd, bufflen, gdth_scsi_done, timeout*HZ, 1); + wait_for_completion(&wait); +} + +#else static void gdth_do_cmd(Scsi_Cmnd *scp, gdth_cmd_str *gdtcmd, char *cmnd, int timeout) { @@ -1266,8 +1412,8 @@ scp->SCp.this_residual = DEFAULT_PRI; bufflen = 0; } - scp->request.rq_status = RQ_SCSI_BUSY; #if LINUX_VERSION_CODE >= 0x020407 + scp->request.rq_status = RQ_SCSI_BUSY; scp->request.waiting = &wait; scsi_do_cmd(scp, cmnd, gdtcmd, bufflen, gdth_scsi_done, timeout*HZ, 1); wait_for_completion(&wait); @@ -1283,46 +1429,53 @@ down(&sem); #endif } +#endif void gdth_scsi_done(Scsi_Cmnd *scp) { TRACE2(("gdth_scsi_done()\n")); +#if LINUX_VERSION_CODE >= 0x020503 + scp->request->rq_status = RQ_SCSI_DONE; + if (scp->request->waiting != NULL) + complete(scp->request->waiting); +#elif LINUX_VERSION_CODE >= 0x020407 scp->request.rq_status = RQ_SCSI_DONE; - -#if LINUX_VERSION_CODE >= 0x020407 if (scp->request.waiting != NULL) complete(scp->request.waiting); #else + scp->request.rq_status = RQ_SCSI_DONE; if (scp->request.sem != NULL) up(scp->request.sem); #endif } -static char *gdth_ioctl_alloc(int hanum, ushort size, int scratch) +static char *gdth_ioctl_alloc(int hanum, int size, int scratch, + ulong32 *paddr) { gdth_ha_str *ha; ulong flags; char *ret_val; - if (size == 0 || size > GDTH_SCRATCH) - return FALSE; + if (size == 0) + return NULL; ha = HADATA(gdth_ctr_tab[hanum]); GDTH_LOCK_HA(ha, flags); - if (scratch) { - if (!ha->scratch_busy) { - ha->scratch_busy = TRUE; - ret_val = ha->pscratch; - } else - ret_val = NULL; + if (!ha->scratch_busy && size <= GDTH_SCRATCH) { + ha->scratch_busy = TRUE; + ret_val = ha->pscratch; + *paddr = ha->scratch_phys; + } else if (scratch) { + ret_val = NULL; } else { -#if LINUX_VERSION_CODE >= 0x020322 - ret_val = (void *) __get_free_pages(GFP_ATOMIC | GFP_DMA, - GDTH_SCRATCH_ORD); +#if LINUX_VERSION_CODE >= 0x020400 + ret_val = pci_alloc_consistent(ha->pdev, size, paddr); #else - ret_val = scsi_init_malloc(GDTH_SCRATCH, GFP_ATOMIC | GFP_DMA); + ret_val = scsi_init_malloc(size, GFP_ATOMIC | GFP_DMA); + if (ret_val) + *paddr = virt_to_bus(ret_val); #endif } @@ -1330,7 +1483,7 @@ return ret_val; } -static void gdth_ioctl_free(int hanum, char *buf) +static void gdth_ioctl_free(int hanum, int size, char *buf, ulong32 paddr) { gdth_ha_str *ha; ulong flags; @@ -1341,16 +1494,17 @@ if (buf == ha->pscratch) { ha->scratch_busy = FALSE; } else { -#if LINUX_VERSION_CODE >= 0x020322 - free_pages((unsigned long)buf, GDTH_SCRATCH_ORD); +#if LINUX_VERSION_CODE >= 0x020400 + pci_free_consistent(ha->pdev, size, buf, paddr); #else - scsi_init_free((void *)buf, GDTH_SCRATCH); + scsi_init_free((void *)buf, size); #endif } GDTH_UNLOCK_HA(ha, flags); } +#ifdef GDTH_IOCTL_PROC static int gdth_ioctl_check_bin(int hanum, ushort size) { gdth_ha_str *ha; @@ -1368,7 +1522,7 @@ GDTH_UNLOCK_HA(ha, flags); return ret_val; } - +#endif static void gdth_wait_completion(int hanum, int busnum, int id) { @@ -1376,23 +1530,39 @@ ulong flags; int i; Scsi_Cmnd *scp; - unchar b; + unchar b, t; ha = HADATA(gdth_ctr_tab[hanum]); GDTH_LOCK_HA(ha, flags); for (i = 0; i < GDTH_MAXCMDS; ++i) { scp = ha->cmd_tab[i].cmnd; +#if LINUX_VERSION_CODE >= 0x02053C b = virt_ctr ? NUMDATA(scp->device->host)->busnum : scp->device->channel; - if (!SPECIAL_SCP(scp) && scp->device->id == (unchar)id && + t = scp->device->id; +#else + b = virt_ctr ? NUMDATA(scp->host)->busnum : scp->channel; + t = scp->target; +#endif + if (!SPECIAL_SCP(scp) && t == (unchar)id && b == (unchar)busnum) { scp->SCp.have_data_in = 0; GDTH_UNLOCK_HA(ha, flags); while (!scp->SCp.have_data_in) barrier(); +#if LINUX_VERSION_CODE >= 0x02053C + GDTH_LOCK_SCSI_DONE(scp->device->host, flags); + scp->scsi_done(scp); + GDTH_UNLOCK_SCSI_DONE(scp->device->host, flags); +#elif LINUX_VERSION_CODE >= 0x020503 + GDTH_LOCK_SCSI_DONE(scp->host, flags); + scp->scsi_done(scp); + GDTH_UNLOCK_SCSI_DONE(scp->host, flags); +#else GDTH_LOCK_SCSI_DONE(flags); scp->scsi_done(scp); GDTH_UNLOCK_SCSI_DONE(flags); +#endif GDTH_LOCK_HA(ha, flags); } } @@ -1404,14 +1574,20 @@ gdth_ha_str *ha; ulong flags; Scsi_Cmnd *scp; - unchar b; + unchar b, t; ha = HADATA(gdth_ctr_tab[hanum]); GDTH_LOCK_HA(ha, flags); for (scp = ha->req_first; scp; scp = (Scsi_Cmnd *)scp->SCp.ptr) { +#if LINUX_VERSION_CODE >= 0x02053C b = virt_ctr ? NUMDATA(scp->device->host)->busnum : scp->device->channel; - if (scp->device->id == (unchar)id && b == (unchar)busnum) { + t = scp->device->id; +#else + b = virt_ctr ? NUMDATA(scp->host)->busnum : scp->channel; + t = scp->target; +#endif + if (t == (unchar)id && b == (unchar)busnum) { TRACE2(("gdth_stop_timeout(): update_timeout()\n")); scp->SCp.buffers_residual = gdth_update_timeout(hanum, scp, 0); } @@ -1424,14 +1600,20 @@ gdth_ha_str *ha; ulong flags; Scsi_Cmnd *scp; - unchar b; + unchar b, t; ha = HADATA(gdth_ctr_tab[hanum]); GDTH_LOCK_HA(ha, flags); for (scp = ha->req_first; scp; scp = (Scsi_Cmnd *)scp->SCp.ptr) { +#if LINUX_VERSION_CODE >= 0x02053C b = virt_ctr ? NUMDATA(scp->device->host)->busnum : scp->device->channel; - if (scp->device->id == (unchar)id && b == (unchar)busnum) { + t = scp->device->id; +#else + b = virt_ctr ? NUMDATA(scp->host)->busnum : scp->channel; + t = scp->target; +#endif + if (t == (unchar)id && b == (unchar)busnum) { TRACE2(("gdth_start_timeout(): update_timeout()\n")); gdth_update_timeout(hanum, scp, scp->SCp.buffers_residual); } @@ -1464,7 +1646,7 @@ timer_table[SCSI_TIMER].expires = jiffies + timeout; timer_active |= 1 << SCSI_TIMER; } else { - if (time_before(jiffies + timeout, timer_table[SCSI_TIMER].expires)) + if (jiffies + timeout < timer_table[SCSI_TIMER].expires) timer_table[SCSI_TIMER].expires = jiffies + timeout; } } diff -Nru a/drivers/scsi/gdth_proc.h b/drivers/scsi/gdth_proc.h --- a/drivers/scsi/gdth_proc.h Sun Mar 23 00:22:54 2003 +++ b/drivers/scsi/gdth_proc.h Sun Mar 23 00:22:54 2003 @@ -2,26 +2,42 @@ #define _GDTH_PROC_H /* gdth_proc.h - * $Id: gdth_proc.h,v 1.11 2001/07/25 15:37:40 achim Exp $ + * $Id: gdth_proc.h,v 1.13 2003/02/27 14:59:25 achim Exp $ */ static int gdth_set_info(char *buffer,int length,int vh,int hanum,int busnum); static int gdth_get_info(char *buffer,char **start,off_t offset, int length,int vh,int hanum,int busnum); -#if LINUX_VERSION_CODE >= 0x020322 +#if LINUX_VERSION_CODE >= 0x020503 +static void gdth_do_req(Scsi_Request *srp, gdth_cmd_str *cmd, + char *cmnd, int timeout); +static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Request *scp); +#ifdef GDTH_IOCTL_PROC +static int gdth_set_bin_info(char *buffer,int length,int hanum,Scsi_Request *scp); +#endif +#elif LINUX_VERSION_CODE >= 0x020322 +static void gdth_do_cmd(Scsi_Cmnd *scp, gdth_cmd_str *cmd, + char *cmnd, int timeout); static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Cmnd *scp); +#ifdef GDTH_IOCTL_PROC static int gdth_set_bin_info(char *buffer,int length,int hanum,Scsi_Cmnd *scp); +#endif #else +static void gdth_do_cmd(Scsi_Cmnd *scp, gdth_cmd_str *cmd, + char *cmnd, int timeout); static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Cmnd scp); +#ifdef GDTH_IOCTL_PROC static int gdth_set_bin_info(char *buffer,int length,int hanum,Scsi_Cmnd scp); #endif -static void gdth_do_cmd(Scsi_Cmnd *scp, gdth_cmd_str *cmd, - char *cmnd, int timeout); +#endif -static char *gdth_ioctl_alloc(int hanum, ushort size, int scratch); -static void gdth_ioctl_free(int hanum, char *buf); +static char *gdth_ioctl_alloc(int hanum, int size, int scratch, + ulong32 *paddr); +static void gdth_ioctl_free(int hanum, int size, char *buf, ulong32 paddr); +#ifdef GDTH_IOCTL_PROC static int gdth_ioctl_check_bin(int hanum, ushort size); +#endif static void gdth_wait_completion(int hanum, int busnum, int id); static void gdth_stop_timeout(int hanum, int busnum, int id); static void gdth_start_timeout(int hanum, int busnum, int id); diff -Nru a/drivers/scsi/gvp11.c b/drivers/scsi/gvp11.c --- a/drivers/scsi/gvp11.c Sun Mar 23 00:22:55 2003 +++ b/drivers/scsi/gvp11.c Sun Mar 23 00:22:55 2003 @@ -62,61 +62,62 @@ static int scsi_alloc_out_of_range = 0; /* use bounce buffer if the physical address is bad */ - if (addr & HDATA(cmd->host)->dma_xfer_mask || + if (addr & HDATA(cmd->device->host)->dma_xfer_mask || (!dir_in && mm_end_of_chunk (addr, cmd->SCp.this_residual))) { - HDATA(cmd->host)->dma_bounce_len = (cmd->SCp.this_residual + 511) + HDATA(cmd->device->host)->dma_bounce_len = (cmd->SCp.this_residual + 511) & ~0x1ff; if( !scsi_alloc_out_of_range ) { - HDATA(cmd->host)->dma_bounce_buffer = - kmalloc (HDATA(cmd->host)->dma_bounce_len, GFP_KERNEL); - HDATA(cmd->host)->dma_buffer_pool = BUF_SCSI_ALLOCED; + HDATA(cmd->device->host)->dma_bounce_buffer = + kmalloc (HDATA(cmd->device->host)->dma_bounce_len, GFP_KERNEL); + HDATA(cmd->device->host)->dma_buffer_pool = BUF_SCSI_ALLOCED; } - if ( scsi_alloc_out_of_range || !HDATA(cmd->host)->dma_bounce_buffer) { - HDATA(cmd->host)->dma_bounce_buffer = - amiga_chip_alloc(HDATA(cmd->host)->dma_bounce_len, + if (scsi_alloc_out_of_range || + !HDATA(cmd->device->host)->dma_bounce_buffer) { + HDATA(cmd->device->host)->dma_bounce_buffer = + amiga_chip_alloc(HDATA(cmd->device->host)->dma_bounce_len, "GVP II SCSI Bounce Buffer"); - if(!HDATA(cmd->host)->dma_bounce_buffer) + if(!HDATA(cmd->device->host)->dma_bounce_buffer) { - HDATA(cmd->host)->dma_bounce_len = 0; + HDATA(cmd->device->host)->dma_bounce_len = 0; return 1; } - HDATA(cmd->host)->dma_buffer_pool = BUF_CHIP_ALLOCED; + HDATA(cmd->device->host)->dma_buffer_pool = BUF_CHIP_ALLOCED; } /* check if the address of the bounce buffer is OK */ - addr = virt_to_bus(HDATA(cmd->host)->dma_bounce_buffer); + addr = virt_to_bus(HDATA(cmd->device->host)->dma_bounce_buffer); - if (addr & HDATA(cmd->host)->dma_xfer_mask) { + if (addr & HDATA(cmd->device->host)->dma_xfer_mask) { /* fall back to Chip RAM if address out of range */ - if( HDATA(cmd->host)->dma_buffer_pool == BUF_SCSI_ALLOCED) { - kfree (HDATA(cmd->host)->dma_bounce_buffer); + if( HDATA(cmd->device->host)->dma_buffer_pool == BUF_SCSI_ALLOCED) { + kfree (HDATA(cmd->device->host)->dma_bounce_buffer); scsi_alloc_out_of_range = 1; } else { - amiga_chip_free (HDATA(cmd->host)->dma_bounce_buffer); + amiga_chip_free (HDATA(cmd->device->host)->dma_bounce_buffer); } - HDATA(cmd->host)->dma_bounce_buffer = - amiga_chip_alloc(HDATA(cmd->host)->dma_bounce_len, + HDATA(cmd->device->host)->dma_bounce_buffer = + amiga_chip_alloc(HDATA(cmd->device->host)->dma_bounce_len, "GVP II SCSI Bounce Buffer"); - if(!HDATA(cmd->host)->dma_bounce_buffer) + if(!HDATA(cmd->device->host)->dma_bounce_buffer) { - HDATA(cmd->host)->dma_bounce_len = 0; + HDATA(cmd->device->host)->dma_bounce_len = 0; return 1; } - addr = virt_to_bus(HDATA(cmd->host)->dma_bounce_buffer); - HDATA(cmd->host)->dma_buffer_pool = BUF_CHIP_ALLOCED; + addr = virt_to_bus(HDATA(cmd->device->host)->dma_bounce_buffer); + HDATA(cmd->device->host)->dma_buffer_pool = BUF_CHIP_ALLOCED; } if (!dir_in) { /* copy to bounce buffer for a write */ - memcpy (HDATA(cmd->host)->dma_bounce_buffer, + memcpy (HDATA(cmd->device->host)->dma_bounce_buffer, cmd->SCp.ptr, cmd->SCp.this_residual); } } @@ -125,11 +126,11 @@ if (!dir_in) cntr |= GVP11_DMAC_DIR_WRITE; - HDATA(cmd->host)->dma_dir = dir_in; - DMA(cmd->host)->CNTR = cntr; + HDATA(cmd->device->host)->dma_dir = dir_in; + DMA(cmd->device->host)->CNTR = cntr; /* setup DMA *physical* address */ - DMA(cmd->host)->ACR = addr; + DMA(cmd->device->host)->ACR = addr; if (dir_in) /* invalidate any cache */ @@ -138,11 +139,11 @@ /* push any dirty cache */ cache_push (addr, cmd->SCp.this_residual); - if ((bank_mask = (~HDATA(cmd->host)->dma_xfer_mask >> 18) & 0x01c0)) - DMA(cmd->host)->BANK = bank_mask & (addr >> 18); + if ((bank_mask = (~HDATA(cmd->device->host)->dma_xfer_mask >> 18) & 0x01c0)) + DMA(cmd->device->host)->BANK = bank_mask & (addr >> 18); /* start DMA */ - DMA(cmd->host)->ST_DMA = 1; + DMA(cmd->device->host)->ST_DMA = 1; /* return success */ return 0; diff -Nru a/drivers/scsi/mac53c94.c b/drivers/scsi/mac53c94.c --- a/drivers/scsi/mac53c94.c Sun Mar 23 00:22:50 2003 +++ b/drivers/scsi/mac53c94.c Sun Mar 23 00:22:50 2003 @@ -16,11 +16,13 @@ #include #include #include +#include #include #include #include #include #include +#include #include "scsi.h" #include "hosts.h" @@ -48,6 +50,8 @@ enum fsc_phase phase; /* what we're currently trying to do */ struct dbdma_cmd *dma_cmds; /* space for dbdma commands, aligned */ void *dma_cmd_space; + struct pci_dev *pdev; + dma_addr_t dma_addr; }; static struct fsc_state *all_53c94s; @@ -70,36 +74,66 @@ void *dma_cmd_space; unsigned char *clkprop; int proplen; + struct pci_dev *pdev; + u8 pbus, devfn; nfscs = 0; prev_statep = &all_53c94s; for (node = find_devices("53c94"); node != 0; node = node->next) { - if (node->n_addrs != 2 || node->n_intrs != 2) - panic("53c94: expected 2 addrs and intrs (got %d/%d)", - node->n_addrs, node->n_intrs); + if (node->n_addrs != 2 || node->n_intrs != 2) { + printk(KERN_ERR "mac53c94: expected 2 addrs and intrs" + " (got %d/%d) for node %s\n", + node->n_addrs, node->n_intrs, node->full_name); + continue; + } + + pdev = NULL; + if (node->parent != NULL + && !pci_device_from_OF_node(node->parent, &pbus, &devfn)) + pdev = pci_find_slot(pbus, devfn); + if (pdev == NULL) { + printk(KERN_ERR "mac53c94: can't find PCI device " + "for %s\n", node->full_name); + continue; + } + host = scsi_register(tp, sizeof(struct fsc_state)); if (host == NULL) break; host->unique_id = nfscs; -#ifndef MODULE - note_scsi_host(node, host); -#endif state = (struct fsc_state *) host->hostdata; - if (state == 0) - panic("no 53c94 state"); + if (state == 0) { + /* "can't happen" */ + printk(KERN_ERR "mac53c94: no state for %s?!\n", + node->full_name); + scsi_unregister(host); + break; + } state->host = host; + state->pdev = pdev; + state->regs = (volatile struct mac53c94_regs *) ioremap(node->addrs[0].address, 0x1000); state->intr = node->intrs[0].line; state->dma = (volatile struct dbdma_regs *) ioremap(node->addrs[1].address, 0x1000); state->dmaintr = node->intrs[1].line; + if (state->regs == NULL || state->dma == NULL) { + printk(KERN_ERR "mac53c94: ioremap failed for %s\n", + node->full_name); + if (state->dma != NULL) + iounmap(state->dma); + if (state->regs != NULL) + iounmap(state->regs); + scsi_unregister(host); + break; + } clkprop = get_property(node, "clock-frequency", &proplen); if (clkprop == NULL || proplen != sizeof(int)) { - printk(KERN_ERR "%s: can't get clock frequency\n", - node->full_name); + printk(KERN_ERR "%s: can't get clock frequency, " + "assuming 25MHz\n", node->full_name); state->clk_freq = 25000000; } else state->clk_freq = *(int *)clkprop; @@ -108,8 +142,11 @@ +1 to allow for aligning. */ dma_cmd_space = kmalloc((host->sg_tablesize + 2) * sizeof(struct dbdma_cmd), GFP_KERNEL); - if (dma_cmd_space == 0) - panic("53c94: couldn't allocate dma command space"); + if (dma_cmd_space == 0) { + printk(KERN_ERR "mac53c94: couldn't allocate dma " + "command space for %s\n", node->full_name); + goto err_cleanup; + } state->dma_cmds = (struct dbdma_cmd *) DBDMA_ALIGN(dma_cmd_space); memset(state->dma_cmds, 0, (host->sg_tablesize + 1) @@ -121,7 +158,13 @@ if (request_irq(state->intr, do_mac53c94_interrupt, 0, "53C94", state)) { - printk(KERN_ERR "mac53C94: can't get irq %d\n", state->intr); + printk(KERN_ERR "mac53C94: can't get irq %d for %s\n", + state->intr, node->full_name); + err_cleanup: + iounmap(state->dma); + iounmap(state->regs); + scsi_unregister(host); + break; } mac53c94_init(state); @@ -150,7 +193,6 @@ int mac53c94_queue(Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *)) { - unsigned long flags; struct fsc_state *state; #if 0 @@ -167,10 +209,8 @@ cmd->scsi_done = done; cmd->host_scribble = NULL; - state = (struct fsc_state *) cmd->host->hostdata; + state = (struct fsc_state *) cmd->device->host->hostdata; - save_flags(flags); - cli(); if (state->request_q == NULL) state->request_q = cmd; else @@ -180,7 +220,6 @@ if (state->phase == idle) mac53c94_start(state); - restore_flags(flags); return 0; } @@ -191,15 +230,12 @@ } int -mac53c94_reset(Scsi_Cmnd *cmd, unsigned how) +mac53c94_host_reset(Scsi_Cmnd *cmd) { - struct fsc_state *state = (struct fsc_state *) cmd->host->hostdata; + struct fsc_state *state = (struct fsc_state *) cmd->device->host->hostdata; volatile struct mac53c94_regs *regs = state->regs; volatile struct dbdma_regs *dma = state->dma; - unsigned long flags; - save_flags(flags); - cli(); st_le32(&dma->control, (RUN|PAUSE|FLUSH|WAKE) << 16); regs->command = CMD_SCSI_RESET; /* assert RST */ eieio(); @@ -210,15 +246,7 @@ mac53c94_init(state); regs->command = CMD_NOP; eieio(); - restore_flags(flags); - return SCSI_RESET_PENDING; -} - -int -mac53c94_command(Scsi_Cmnd *cmd) -{ - printk(KERN_DEBUG "whoops... mac53c94_command called\n"); - return -1; + return SUCCESS; } static void @@ -269,7 +297,7 @@ regs->command = CMD_FLUSH; udelay(1); eieio(); - regs->dest_id = cmd->target; + regs->dest_id = cmd->device->id; regs->sync_period = 0; regs->sync_offset = 0; eieio(); @@ -292,7 +320,7 @@ do_mac53c94_interrupt(int irq, void *dev_id, struct pt_regs *ptregs) { unsigned long flags; - struct Scsi_Host *dev = ((struct fsc_state *) dev_id)->current_req->host; + struct Scsi_Host *dev = ((struct fsc_state *) dev_id)->current_req->device->host; spin_lock_irqsave(dev->host_lock, flags); mac53c94_interrupt(irq, dev_id, ptregs); @@ -308,6 +336,7 @@ Scsi_Cmnd *cmd = state->current_req; int nb, stat, seq, intr; static int mac53c94_errors; + int dma_dir; /* * Apparently, reading the interrupt register unlatches @@ -427,7 +456,16 @@ if ((stat & STAT_PHASE) != STAT_CD + STAT_IO) { printk(KERN_DEBUG "intr %x before data xfer complete\n", intr); } - st_le32(&dma->control, RUN << 16); /* stop dma */ + out_le32(&dma->control, RUN << 16); /* stop dma */ + dma_dir = scsi_to_pci_dma_dir(cmd->sc_data_direction); + if (cmd->use_sg != 0) { + pci_unmap_sg(state->pdev, + (struct scatterlist *)cmd->request_buffer, + cmd->use_sg, dma_dir); + } else { + pci_unmap_single(state->pdev, state->dma_addr, + cmd->request_bufflen, dma_dir); + } /* should check dma status */ regs->command = CMD_I_COMPLETE; state->phase = completing; @@ -480,19 +518,27 @@ int i, dma_cmd, total; struct scatterlist *scl; struct dbdma_cmd *dcmds; + dma_addr_t dma_addr; + u32 dma_len; + int dma_dir = scsi_to_pci_dma_dir(cmd->sc_data_direction); dma_cmd = data_goes_out(cmd)? OUTPUT_MORE: INPUT_MORE; dcmds = state->dma_cmds; if (cmd->use_sg > 0) { + int nseg; + total = 0; scl = (struct scatterlist *) cmd->buffer; - for (i = 0; i < cmd->use_sg; ++i) { - if (scl->length > 0xffff) + nseg = pci_map_sg(state->pdev, scl, cmd->use_sg, dma_dir); + for (i = 0; i < nseg; ++i) { + dma_addr = sg_dma_address(scl); + dma_len = sg_dma_len(scl); + if (dma_len > 0xffff) panic("mac53c94: scatterlist element >= 64k"); - total += scl->length; - st_le16(&dcmds->req_count, scl->length); + total += dma_len; + st_le16(&dcmds->req_count, dma_len); st_le16(&dcmds->command, dma_cmd); - st_le32(&dcmds->phy_addr, virt_to_phys(scl->address)); + st_le32(&dcmds->phy_addr, dma_addr); dcmds->xfer_status = 0; ++scl; ++dcmds; @@ -501,8 +547,11 @@ total = cmd->request_bufflen; if (total > 0xffff) panic("mac53c94: transfer size >= 64k"); + dma_addr = pci_map_single(state->pdev, cmd->request_buffer, + total, dma_dir); + state->dma_addr = dma_addr; st_le16(&dcmds->req_count, total); - st_le32(&dcmds->phy_addr, virt_to_phys(cmd->request_buffer)); + st_le32(&dcmds->phy_addr, dma_addr); dcmds->xfer_status = 0; ++dcmds; } @@ -514,12 +563,19 @@ /* * Work out whether data will be going out from the host adaptor or into it. - * (If this information is available from somewhere else in the scsi - * code, somebody please let me know :-) */ static int data_goes_out(Scsi_Cmnd *cmd) { + switch (cmd->sc_data_direction) { + case SCSI_DATA_WRITE: + return 1; + case SCSI_DATA_READ: + return 0; + } + + /* for SCSI_DATA_UNKNOWN or SCSI_DATA_NONE, fall back on the + old method for now... */ switch (cmd->cmnd[0]) { case CHANGE_DEFINITION: case COMPARE: @@ -557,6 +613,19 @@ } } -static Scsi_Host_Template driver_template = SCSI_MAC53C94; +static Scsi_Host_Template driver_template = { + .proc_name = "53c94", + .name = "53C94", + .detect = mac53c94_detect, + .release = mac53c94_release, + .queuecommand = mac53c94_queue, + .eh_abort_handler = mac53c94_abort, + .eh_host_reset_handler = mac53c94_host_reset, + .can_queue = 1, + .this_id = 7, + .sg_tablesize = SG_ALL, + .cmd_per_lun = 1, + .use_clustering = DISABLE_CLUSTERING, +}; #include "scsi_module.c" diff -Nru a/drivers/scsi/mac53c94.h b/drivers/scsi/mac53c94.h --- a/drivers/scsi/mac53c94.h Sun Mar 23 00:22:52 2003 +++ b/drivers/scsi/mac53c94.h Sun Mar 23 00:22:52 2003 @@ -7,29 +7,6 @@ #ifndef _MAC53C94_H #define _MAC53C94_H -int mac53c94_detect(Scsi_Host_Template *); -int mac53c94_release(struct Scsi_Host *); -int mac53c94_command(Scsi_Cmnd *); -int mac53c94_queue(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *)); -int mac53c94_abort(Scsi_Cmnd *); -int mac53c94_reset(Scsi_Cmnd *, unsigned int); - -#define SCSI_MAC53C94 { \ - .proc_name = "53c94", \ - .name = "53C94", \ - .detect = mac53c94_detect, \ - .release = mac53c94_release, \ - .command = mac53c94_command, \ - .queuecommand = mac53c94_queue, \ - .abort = mac53c94_abort, \ - .reset = mac53c94_reset, \ - .can_queue = 1, \ - .this_id = 7, \ - .sg_tablesize = SG_ALL, \ - .cmd_per_lun = 1, \ - .use_clustering = DISABLE_CLUSTERING, \ -} - /* * Registers in the 53C94 controller. */ diff -Nru a/drivers/scsi/mac_NCR5380.c b/drivers/scsi/mac_NCR5380.c --- a/drivers/scsi/mac_NCR5380.c Sun Mar 23 00:22:55 2003 +++ b/drivers/scsi/mac_NCR5380.c Sun Mar 23 00:22:55 2003 @@ -850,7 +850,7 @@ /* - * Function : void NCR5380_init (struct Scsi_Host *instance) + * Function : void NCR5380_init (struct Scsi_Host *instance, int flags) * * Purpose : initializes *instance and corresponding 5380 chip. * @@ -861,7 +861,7 @@ * */ -static void NCR5380_init (struct Scsi_Host *instance, int flags) +static int NCR5380_init (struct Scsi_Host *instance, int flags) { int i; SETUP_HOSTDATA(instance); @@ -905,6 +905,8 @@ NCR5380_write(MODE_REG, MR_BASE); NCR5380_write(TARGET_COMMAND_REG, 0); NCR5380_write(SELECT_ENABLE_REG, 0); + + return 0; } /* @@ -925,17 +927,13 @@ * */ -/* Only make static if a wrapper function is used */ -#ifndef NCR5380_queue_command static -#endif int NCR5380_queue_command (Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *)) { SETUP_HOSTDATA(cmd->host); Scsi_Cmnd *tmp; int oldto; unsigned long flags; - extern int update_timeout(Scsi_Cmnd * SCset, int timeout); #if (NDEBUG & NDEBUG_NO_WRITE) switch (cmd->cmnd[0]) { @@ -1025,12 +1023,12 @@ if (in_interrupt() > 0 || ((flags >> 8) & 7) >= 6) queue_main(); else - NCR5380_main(); + NCR5380_main(NULL); return 0; } /* - * Function : NCR5380_main (void) + * Function : NCR5380_main (void *bl) * * Purpose : NCR5380_main is a coroutine that runs as long as more work can * be done on the NCR5380 host adapters in a system. Both @@ -1041,7 +1039,7 @@ * reenable them. This prevents reentrancy and kernel stack overflow. */ -static void NCR5380_main (void) +static void NCR5380_main (void *bl) { Scsi_Cmnd *tmp, *prev; struct Scsi_Host *instance = first_instance; @@ -2790,9 +2788,6 @@ * called where the loop started in NCR5380_main(). */ -#ifndef NCR5380_abort -static -#endif int NCR5380_abort (Scsi_Cmnd *cmd) { struct Scsi_Host *instance = cmd->host; @@ -2982,7 +2977,7 @@ /* - * Function : int NCR5380_reset (Scsi_Cmnd *cmd, unsigned int reset_flags) + * Function : int NCR5380_bus_reset (Scsi_Cmnd *cmd) * * Purpose : reset the SCSI bus. * @@ -2990,7 +2985,7 @@ * */ -static int NCR5380_reset( Scsi_Cmnd *cmd, unsigned int reset_flags) +static int NCR5380_bus_reset( Scsi_Cmnd *cmd) { SETUP_HOSTDATA(cmd->host); int i; diff -Nru a/drivers/scsi/mesh.c b/drivers/scsi/mesh.c --- a/drivers/scsi/mesh.c Sun Mar 23 00:22:54 2003 +++ b/drivers/scsi/mesh.c Sun Mar 23 00:22:54 2003 @@ -80,7 +80,7 @@ #define ALLOW_SYNC(tgt) ((sync_targets >> (tgt)) & 1) #define ALLOW_RESEL(tgt) ((resel_targets >> (tgt)) & 1) #define ALLOW_DEBUG(tgt) ((debug_targets >> (tgt)) & 1) -#define DEBUG_TARGET(cmd) ((cmd) && ALLOW_DEBUG((cmd)->target)) +#define DEBUG_TARGET(cmd) ((cmd) && ALLOW_DEBUG((cmd)->device->id)) #undef MESH_DBG #define N_DBG_LOG 50 @@ -465,7 +465,7 @@ cmd->scsi_done = done; cmd->host_scribble = NULL; - ms = (struct mesh_state *) cmd->host->hostdata; + ms = (struct mesh_state *) cmd->device->host->hostdata; if (ms->request_q == NULL) ms->request_q = cmd; @@ -486,15 +486,12 @@ int mesh_abort(Scsi_Cmnd *cmd) { - struct mesh_state *ms = (struct mesh_state *) cmd->host->hostdata; - unsigned long flags; + struct mesh_state *ms = (struct mesh_state *) cmd->device->host->hostdata; printk(KERN_DEBUG "mesh_abort(%p)\n", cmd); - spin_lock_irqsave(ms->host->host_lock, flags); mesh_dump_regs(ms); - dumplog(ms, cmd->target); + dumplog(ms, cmd->device->id); dumpslog(ms); - spin_unlock_irqrestore(ms->host->host_lock, flags); return SCSI_ABORT_SNOOZE; } @@ -540,7 +537,7 @@ int mesh_host_reset(Scsi_Cmnd *cmd) { - struct mesh_state *ms = (struct mesh_state *) cmd->host->hostdata; + struct mesh_state *ms = (struct mesh_state *) cmd->device->host->hostdata; volatile struct mesh_regs *mr = ms->mesh; volatile struct dbdma_regs *md = ms->dma; @@ -661,7 +658,7 @@ for (cmd = ms->request_q; ; cmd = (Scsi_Cmnd *) cmd->host_scribble) { if (cmd == NULL) return; - if (ms->tgts[cmd->target].current_req == NULL) + if (ms->tgts[cmd->device->id].current_req == NULL) break; prev = cmd; } @@ -681,17 +678,18 @@ mesh_start_cmd(struct mesh_state *ms, Scsi_Cmnd *cmd) { volatile struct mesh_regs *mr = ms->mesh; - int t; + int t, id; + id = cmd->device->id; ms->current_req = cmd; - ms->tgts[cmd->target].data_goes_out = data_goes_out(cmd); - ms->tgts[cmd->target].current_req = cmd; + ms->tgts[id].data_goes_out = data_goes_out(cmd); + ms->tgts[id].current_req = cmd; #if 1 if (DEBUG_TARGET(cmd)) { int i; printk(KERN_DEBUG "mesh_start: %p ser=%lu tgt=%d cmd=", - cmd, cmd->serial_number, cmd->target); + cmd, cmd->serial_number, id); for (i = 0; i < cmd->cmd_len; ++i) printk(" %x", cmd->cmnd[i]); printk(" use_sg=%d buffer=%p bufflen=%u\n", @@ -708,12 +706,12 @@ ms->n_msgout = 0; ms->last_n_msgout = 0; ms->expect_reply = 0; - ms->conn_tgt = cmd->target; - ms->tgts[cmd->target].saved_ptr = 0; + ms->conn_tgt = id; + ms->tgts[id].saved_ptr = 0; ms->stat = DID_OK; ms->aborting = 0; #ifdef MESH_DBG - ms->tgts[cmd->target].n_log = 0; + ms->tgts[id].n_log = 0; dlog(ms, "start cmd=%x", (int) cmd); #endif @@ -1160,7 +1158,7 @@ case selecting: dlog(ms, "Selecting phase at command completion",0); ms->msgout[0] = IDENTIFY(ALLOW_RESEL(ms->conn_tgt), - (cmd? cmd->lun: 0)); + (cmd? cmd->device->lun: 0)); ms->n_msgout = 1; ms->expect_reply = 0; if (ms->aborting) { @@ -1331,7 +1329,7 @@ if (ms->request_q == NULL) ms->request_qtail = cmd; ms->request_q = cmd; - tp = &ms->tgts[cmd->target]; + tp = &ms->tgts[cmd->device->id]; tp->current_req = NULL; } break; @@ -1714,10 +1712,10 @@ if (cmd == NULL) { do_abort(ms); ms->msgphase = msg_out; - } else if (code != cmd->lun + IDENTIFY_BASE) { + } else if (code != cmd->device->lun + IDENTIFY_BASE) { printk(KERN_WARNING "mesh: lun mismatch " "(%d != %d) on reselection from " - "target %d\n", i, cmd->lun, + "target %d\n", i, cmd->device->lun, ms->conn_tgt); } break; @@ -1902,12 +1900,19 @@ /* * Work out whether we expect data to go out from the host adaptor or into it. - * (If this information is available from somewhere else in the scsi - * code, somebody please let me know :-) */ static int data_goes_out(Scsi_Cmnd *cmd) { + switch (cmd->sc_data_direction) { + case SCSI_DATA_WRITE: + return 1; + case SCSI_DATA_READ: + return 0; + } + + /* for SCSI_DATA_UNKNOWN or SCSI_DATA_NONE, fall back on the + old method for now... */ switch (cmd->cmnd[0]) { case CHANGE_DEFINITION: case COMPARE: @@ -2036,6 +2041,22 @@ } #endif /* MESH_DBG */ -static Scsi_Host_Template driver_template = SCSI_MESH; +static Scsi_Host_Template driver_template = { + .proc_name = "mesh", + .name = "MESH", + .detect = mesh_detect, + .release = mesh_release, + .command = NULL, + .queuecommand = mesh_queue, + .eh_abort_handler = mesh_abort, + .eh_device_reset_handler = NULL, + .eh_bus_reset_handler = NULL, + .eh_host_reset_handler = mesh_host_reset, + .can_queue = 20, + .this_id = 7, + .sg_tablesize = SG_ALL, + .cmd_per_lun = 2, + .use_clustering = DISABLE_CLUSTERING, +}; #include "scsi_module.c" diff -Nru a/drivers/scsi/mesh.h b/drivers/scsi/mesh.h --- a/drivers/scsi/mesh.h Sun Mar 23 00:22:51 2003 +++ b/drivers/scsi/mesh.h Sun Mar 23 00:22:51 2003 @@ -7,30 +7,6 @@ #ifndef _MESH_H #define _MESH_H -int mesh_detect(Scsi_Host_Template *); -int mesh_release(struct Scsi_Host *); -int mesh_queue(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *)); -int mesh_abort(Scsi_Cmnd *); -int mesh_host_reset(Scsi_Cmnd *); - -#define SCSI_MESH { \ - .proc_name = "mesh", \ - .name = "MESH", \ - .detect = mesh_detect, \ - .release = mesh_release, \ - .command = NULL, \ - .queuecommand = mesh_queue, \ - .eh_abort_handler = mesh_abort, \ - .eh_device_reset_handler = NULL, \ - .eh_bus_reset_handler = NULL, \ - .eh_host_reset_handler = mesh_host_reset, \ - .can_queue = 20, \ - .this_id = 7, \ - .sg_tablesize = SG_ALL, \ - .cmd_per_lun = 2, \ - .use_clustering = DISABLE_CLUSTERING, \ -} - /* * Registers in the MESH controller. */ diff -Nru a/drivers/scsi/sun3_NCR5380.c b/drivers/scsi/sun3_NCR5380.c --- a/drivers/scsi/sun3_NCR5380.c Sun Mar 23 00:22:50 2003 +++ b/drivers/scsi/sun3_NCR5380.c Sun Mar 23 00:22:50 2003 @@ -268,7 +268,7 @@ #define NEXTADDR(cmd) ((Scsi_Cmnd **)&((cmd)->host_scribble)) #define HOSTNO instance->host_no -#define H_NO(cmd) (cmd)->host->host_no +#define H_NO(cmd) (cmd)->device->host->host_no #define SGADDR(buffer) (void *)(((unsigned long)page_address((buffer)->page)) + \ (buffer)->offset) @@ -360,17 +360,17 @@ static int is_lun_busy( Scsi_Cmnd *cmd, int should_be_tagged ) { - SETUP_HOSTDATA(cmd->host); + SETUP_HOSTDATA(cmd->device->host); - if (hostdata->busy[cmd->target] & (1 << cmd->lun)) + if (hostdata->busy[cmd->device->id] & (1 << cmd->device->lun)) return( 1 ); if (!should_be_tagged || !setup_use_tagged_queuing || !cmd->device->tagged_supported) return( 0 ); - if (TagAlloc[cmd->target][cmd->lun].nr_allocated >= - TagAlloc[cmd->target][cmd->lun].queue_size ) { + if (TagAlloc[cmd->device->id][cmd->device->lun].nr_allocated >= + TagAlloc[cmd->device->id][cmd->device->lun].queue_size ) { TAG_PRINTK( "scsi%d: target %d lun %d: no free tags\n", - H_NO(cmd), cmd->target, cmd->lun ); + H_NO(cmd), cmd->device->id, cmd->device->lun ); return( 1 ); } return( 0 ); @@ -384,7 +384,7 @@ static void cmd_get_tag( Scsi_Cmnd *cmd, int should_be_tagged ) { - SETUP_HOSTDATA(cmd->host); + SETUP_HOSTDATA(cmd->device->host); /* If we or the target don't support tagged queuing, allocate the LUN for * an untagged command. @@ -392,19 +392,19 @@ if (!should_be_tagged || !setup_use_tagged_queuing || !cmd->device->tagged_supported) { cmd->tag = TAG_NONE; - hostdata->busy[cmd->target] |= (1 << cmd->lun); + hostdata->busy[cmd->device->id] |= (1 << cmd->device->lun); TAG_PRINTK( "scsi%d: target %d lun %d now allocated by untagged " - "command\n", H_NO(cmd), cmd->target, cmd->lun ); + "command\n", H_NO(cmd), cmd->device->id, cmd->device->lun ); } else { - TAG_ALLOC *ta = &TagAlloc[cmd->target][cmd->lun]; + TAG_ALLOC *ta = &TagAlloc[cmd->device->id][cmd->device->lun]; cmd->tag = find_first_zero_bit( &ta->allocated, MAX_TAGS ); set_bit( cmd->tag, &ta->allocated ); ta->nr_allocated++; TAG_PRINTK( "scsi%d: using tag %d for target %d lun %d " "(now %d tags in use)\n", - H_NO(cmd), cmd->tag, cmd->target, cmd->lun, + H_NO(cmd), cmd->tag, cmd->device->id, cmd->device->lun, ta->nr_allocated ); } } @@ -416,23 +416,23 @@ static void cmd_free_tag( Scsi_Cmnd *cmd ) { - SETUP_HOSTDATA(cmd->host); + SETUP_HOSTDATA(cmd->device->host); if (cmd->tag == TAG_NONE) { - hostdata->busy[cmd->target] &= ~(1 << cmd->lun); + hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun); TAG_PRINTK( "scsi%d: target %d lun %d untagged cmd finished\n", - H_NO(cmd), cmd->target, cmd->lun ); + H_NO(cmd), cmd->device->id, cmd->device->lun ); } else if (cmd->tag >= MAX_TAGS) { printk(KERN_NOTICE "scsi%d: trying to free bad tag %d!\n", H_NO(cmd), cmd->tag ); } else { - TAG_ALLOC *ta = &TagAlloc[cmd->target][cmd->lun]; + TAG_ALLOC *ta = &TagAlloc[cmd->device->id][cmd->device->lun]; clear_bit( cmd->tag, &ta->allocated ); ta->nr_allocated--; TAG_PRINTK( "scsi%d: freed tag %d for target %d lun %d\n", - H_NO(cmd), cmd->tag, cmd->target, cmd->lun ); + H_NO(cmd), cmd->tag, cmd->device->id, cmd->device->lun ); } } @@ -616,11 +616,11 @@ status = NCR5380_read(STATUS_REG); if (!(status & SR_REQ)) - printk("scsi%d: REQ not asserted, phase unknown.\n", HOSTNO); + printk(KERN_DEBUG "scsi%d: REQ not asserted, phase unknown.\n", HOSTNO); else { for (i = 0; (phases[i].value != PHASE_UNKNOWN) && (phases[i].value != (status & PHASE_MASK)); ++i); - printk("scsi%d: phase %s\n", HOSTNO, phases[i].name); + printk(KERN_DEBUG "scsi%d: phase %s\n", HOSTNO, phases[i].name); } } @@ -819,7 +819,7 @@ int i, s; unsigned char *command; SPRINTF("scsi%d: destination target %d, lun %d\n", - H_NO(cmd), cmd->target, cmd->lun); + H_NO(cmd), cmd->device->id, cmd->device->lun); SPRINTF(" command = "); command = cmd->cmnd; SPRINTF("%2d (0x%02x)", command[0], command[0]); @@ -842,7 +842,7 @@ * */ -static void __init NCR5380_init (struct Scsi_Host *instance, int flags) +static int NCR5380_init (struct Scsi_Host *instance, int flags) { int i; SETUP_HOSTDATA(instance); @@ -886,6 +886,8 @@ NCR5380_write(MODE_REG, MR_BASE); NCR5380_write(TARGET_COMMAND_REG, 0); NCR5380_write(SELECT_ENABLE_REG, 0); + + return 0; } /* @@ -909,10 +911,9 @@ /* Only make static if a wrapper function is used */ static int NCR5380_queue_command (Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *)) { - SETUP_HOSTDATA(cmd->host); + SETUP_HOSTDATA(cmd->device->host); Scsi_Cmnd *tmp; unsigned long flags; - extern int update_timeout(Scsi_Cmnd * SCset, int timeout); #if (NDEBUG & NDEBUG_NO_WRITE) switch (cmd->cmnd[0]) { @@ -942,15 +943,15 @@ case WRITE: case WRITE_6: case WRITE_10: - hostdata->time_write[cmd->target] -= (jiffies - hostdata->timebase); - hostdata->bytes_write[cmd->target] += cmd->request_bufflen; + hostdata->time_write[cmd->device->id] -= (jiffies - hostdata->timebase); + hostdata->bytes_write[cmd->device->id] += cmd->request_bufflen; hostdata->pendingw++; break; case READ: case READ_6: case READ_10: - hostdata->time_read[cmd->target] -= (jiffies - hostdata->timebase); - hostdata->bytes_read[cmd->target] += cmd->request_bufflen; + hostdata->time_read[cmd->device->id] -= (jiffies - hostdata->timebase); + hostdata->bytes_read[cmd->device->id] += cmd->request_bufflen; hostdata->pendingr++; break; } @@ -1014,7 +1015,7 @@ if (in_interrupt() || ((flags >> 8) & 7) >= 6) queue_main(); else - NCR5380_main(); + NCR5380_main(NULL); return 0; } @@ -1030,7 +1031,7 @@ * reenable them. This prevents reentrancy and kernel stack overflow. */ -static void NCR5380_main (void) +static void NCR5380_main (void *bl) { Scsi_Cmnd *tmp, *prev; struct Scsi_Host *instance = first_instance; @@ -1065,7 +1066,7 @@ local_save_flags(flags); do { - local_irq_disable(flags); /* Freeze request queues */ + local_irq_disable(); /* Freeze request queues */ done = 1; if (!hostdata->connected) { @@ -1095,7 +1096,7 @@ #ifdef SUPPORT_TAGS !is_lun_busy( tmp, tmp->cmnd[0] != REQUEST_SENSE) #else - !(hostdata->busy[tmp->target] & (1 << tmp->lun)) + !(hostdata->busy[tmp->device->id] & (1 << tmp->device->lun)) #endif ) { /* ++guenther: just to be sure, this must be atomic */ @@ -1217,8 +1218,8 @@ BASR_ACK)) == (BASR_PHASE_MATCH | BASR_ACK)) { printk("scsi%d: BASR %02x\n", HOSTNO, NCR5380_read(BUS_AND_STATUS_REG)); - printk("scsi%d: bus stuck in data phase -- probably a - single byte overrun!\n", HOSTNO); + printk("scsi%d: bus stuck in data phase -- probably a single byte " + "overrun!\n", HOSTNO); printk("not prepared for this error!\n"); printk("please e-mail sammy@sammy.net with a description of how this\n"); printk("error was produced.\n"); @@ -1349,15 +1350,15 @@ case WRITE: case WRITE_6: case WRITE_10: - hostdata->time_write[cmd->target] += (jiffies - hostdata->timebase); - /*hostdata->bytes_write[cmd->target] += cmd->request_bufflen;*/ + hostdata->time_write[cmd->device->id] += (jiffies - hostdata->timebase); + /*hostdata->bytes_write[cmd->device->id] += cmd->request_bufflen;*/ hostdata->pendingw--; break; case READ: case READ_6: case READ_10: - hostdata->time_read[cmd->target] += (jiffies - hostdata->timebase); - /*hostdata->bytes_read[cmd->target] += cmd->request_bufflen;*/ + hostdata->time_read[cmd->device->id] += (jiffies - hostdata->timebase); + /*hostdata->bytes_read[cmd->device->id] += cmd->request_bufflen;*/ hostdata->pendingr--; break; } @@ -1518,7 +1519,7 @@ * the host and target ID's on the SCSI bus. */ - NCR5380_write(OUTPUT_DATA_REG, (hostdata->id_mask | (1 << cmd->target))); + NCR5380_write(OUTPUT_DATA_REG, (hostdata->id_mask | (1 << cmd->device->id))); /* * Raise ATN while SEL is true before BSY goes false from arbitration, @@ -1571,7 +1572,7 @@ udelay(1); - SEL_PRINTK("scsi%d: selecting target %d\n", HOSTNO, cmd->target); + SEL_PRINTK("scsi%d: selecting target %d\n", HOSTNO, cmd->device->id); /* * The SCSI specification calls for a 250 ms timeout for the actual @@ -1622,7 +1623,7 @@ if (!(NCR5380_read(STATUS_REG) & SR_BSY)) { NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); - if (hostdata->targets_present & (1 << cmd->target)) { + if (hostdata->targets_present & (1 << cmd->device->id)) { printk(KERN_ERR "scsi%d: weirdness\n", HOSTNO); if (hostdata->restart_select) printk(KERN_NOTICE "\trestart select\n"); @@ -1644,7 +1645,7 @@ return 0; } - hostdata->targets_present |= (1 << cmd->target); + hostdata->targets_present |= (1 << cmd->device->id); /* * Since we followed the SCSI spec, and raised ATN while SEL @@ -1665,8 +1666,8 @@ while (!(NCR5380_read(STATUS_REG) & SR_REQ)); SEL_PRINTK("scsi%d: target %d selected, going into MESSAGE OUT phase.\n", - HOSTNO, cmd->target); - tmp[0] = IDENTIFY(1, cmd->lun); + HOSTNO, cmd->device->id); + tmp[0] = IDENTIFY(1, cmd->device->lun); #ifdef SUPPORT_TAGS if (cmd->tag != TAG_NONE) { @@ -1688,7 +1689,7 @@ /* XXX need to handle errors here */ hostdata->connected = cmd; #ifndef SUPPORT_TAGS - hostdata->busy[cmd->target] |= (1 << cmd->lun); + hostdata->busy[cmd->device->id] |= (1 << cmd->device->lun); #endif #ifdef SUN3_SCSI_VME dregs->csr |= CSR_INTR; @@ -2103,7 +2104,7 @@ * polled-IO. */ printk(KERN_NOTICE "scsi%d: switching target %d " "lun %d to slow handshake\n", HOSTNO, - cmd->target, cmd->lun); + cmd->device->id, cmd->device->lun); cmd->device->borken = 1; NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN); @@ -2161,7 +2162,7 @@ NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); LNK_PRINTK("scsi%d: target %d lun %d linked command " - "complete.\n", HOSTNO, cmd->target, cmd->lun); + "complete.\n", HOSTNO, cmd->device->id, cmd->device->lun); /* Enable reselect interrupts */ NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask); @@ -2174,7 +2175,7 @@ if (!cmd->next_link) { printk(KERN_NOTICE "scsi%d: target %d lun %d " "linked command complete, no next_link\n", - HOSTNO, cmd->target, cmd->lun); + HOSTNO, cmd->device->id, cmd->device->lun); sink = 1; do_abort (instance); return; @@ -2187,7 +2188,7 @@ cmd->result = cmd->SCp.Status | (cmd->SCp.Message << 8); LNK_PRINTK("scsi%d: target %d lun %d linked request " "done, calling scsi_done().\n", - HOSTNO, cmd->target, cmd->lun); + HOSTNO, cmd->device->id, cmd->device->lun); #ifdef NCR5380_STATS collect_stats(hostdata, cmd); #endif @@ -2201,7 +2202,7 @@ NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); hostdata->connected = NULL; QU_PRINTK("scsi%d: command for target %d, lun %d " - "completed\n", HOSTNO, cmd->target, cmd->lun); + "completed\n", HOSTNO, cmd->device->id, cmd->device->lun); #ifdef SUPPORT_TAGS cmd_free_tag( cmd ); if (status_byte(cmd->SCp.Status) == QUEUE_FULL) { @@ -2213,16 +2214,16 @@ */ /* ++Andreas: the mid level code knows about QUEUE_FULL now. */ - TAG_ALLOC *ta = &TagAlloc[cmd->target][cmd->lun]; + TAG_ALLOC *ta = &TagAlloc[cmd->device->id][cmd->device->lun]; TAG_PRINTK("scsi%d: target %d lun %d returned " "QUEUE_FULL after %d commands\n", - HOSTNO, cmd->target, cmd->lun, + HOSTNO, cmd->device->id, cmd->device->lun, ta->nr_allocated); if (ta->queue_size > ta->nr_allocated) ta->nr_allocated = ta->queue_size; } #else - hostdata->busy[cmd->target] &= ~(1 << cmd->lun); + hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun); #endif /* Enable reselect interrupts */ NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask); @@ -2312,12 +2313,12 @@ * the command is treated as untagged further on. */ cmd->device->tagged_supported = 0; - hostdata->busy[cmd->target] |= (1 << cmd->lun); + hostdata->busy[cmd->device->id] |= (1 << cmd->device->lun); cmd->tag = TAG_NONE; TAG_PRINTK("scsi%d: target %d lun %d rejected " "QUEUE_TAG message; tagged queuing " "disabled\n", - HOSTNO, cmd->target, cmd->lun); + HOSTNO, cmd->device->id, cmd->device->lun); break; } break; @@ -2334,7 +2335,7 @@ QU_PRINTK("scsi%d: command for target %d lun %d was " "moved from connected to the " "disconnected_queue\n", HOSTNO, - cmd->target, cmd->lun); + cmd->device->id, cmd->device->lun); /* * Restore phase bits to 0 so an interrupted selection, * arbitration can resume. @@ -2436,13 +2437,13 @@ } else if (tmp != EXTENDED_MESSAGE) printk(KERN_DEBUG "scsi%d: rejecting unknown " "message %02x from target %d, lun %d\n", - HOSTNO, tmp, cmd->target, cmd->lun); + HOSTNO, tmp, cmd->device->id, cmd->device->lun); else printk(KERN_DEBUG "scsi%d: rejecting unknown " "extended message " "code %02x, length %d from target %d, lun %d\n", HOSTNO, extended_msg[1], extended_msg[0], - cmd->target, cmd->lun); + cmd->device->id, cmd->device->lun); msgout = MESSAGE_REJECT; @@ -2460,7 +2461,7 @@ #ifdef SUPPORT_TAGS cmd_free_tag( cmd ); #else - hostdata->busy[cmd->target] &= ~(1 << cmd->lun); + hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun); #endif hostdata->connected = NULL; cmd->result = DID_ERROR << 16; @@ -2579,7 +2580,7 @@ for (tmp = (Scsi_Cmnd *) hostdata->disconnected_queue, prev = NULL; tmp; prev = tmp, tmp = NEXT(tmp) ) { - if ((target_mask == (1 << tmp->target)) && (lun == tmp->lun) + if ((target_mask == (1 << tmp->device->id)) && (lun == tmp->device->lun) #ifdef SUPPORT_TAGS && (tag == tmp->tag) #endif @@ -2686,7 +2687,7 @@ static int NCR5380_abort (Scsi_Cmnd *cmd) { - struct Scsi_Host *instance = cmd->host; + struct Scsi_Host *instance = cmd->device->host; SETUP_HOSTDATA(instance); Scsi_Cmnd *tmp, **prev; unsigned long flags; @@ -2736,7 +2737,7 @@ #ifdef SUPPORT_TAGS cmd_free_tag( cmd ); #else - hostdata->busy[cmd->target] &= ~(1 << cmd->lun); + hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun); #endif local_irq_restore(flags); cmd->scsi_done(cmd); @@ -2841,7 +2842,7 @@ #ifdef SUPPORT_TAGS cmd_free_tag( tmp ); #else - hostdata->busy[cmd->target] &= ~(1 << cmd->lun); + hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun); #endif local_irq_restore(flags); tmp->scsi_done(tmp); @@ -2868,7 +2869,7 @@ /* - * Function : int NCR5380_reset (Scsi_Cmnd *cmd, unsigned int reset_flags) + * Function : int NCR5380_bus_reset (Scsi_Cmnd *cmd) * * Purpose : reset the SCSI bus. * @@ -2876,9 +2877,9 @@ * */ -static int NCR5380_reset( Scsi_Cmnd *cmd, unsigned int reset_flags) +static int NCR5380_bus_reset( Scsi_Cmnd *cmd) { - SETUP_HOSTDATA(cmd->host); + SETUP_HOSTDATA(cmd->device->host); int i; unsigned long flags; #if 1 @@ -2886,7 +2887,7 @@ #endif - NCR5380_print_status (cmd->host); + NCR5380_print_status (cmd->device->host); /* get in phase */ NCR5380_write( TARGET_COMMAND_REG, diff -Nru a/drivers/scsi/sun3_scsi.c b/drivers/scsi/sun3_scsi.c --- a/drivers/scsi/sun3_scsi.c Sun Mar 23 00:22:50 2003 +++ b/drivers/scsi/sun3_scsi.c Sun Mar 23 00:22:50 2003 @@ -79,6 +79,8 @@ #include "sun3_scsi.h" #include "NCR5380.h" +static void NCR5380_print(struct Scsi_Host *instance); + /* #define OLDDMA */ #define USE_WRAPPER @@ -312,7 +314,7 @@ if (shpnt->irq != IRQ_NONE) free_irq (shpnt->irq, NULL); - iounmap(sun3_scsi_regp); + iounmap((void *)sun3_scsi_regp); return 0; } @@ -621,8 +623,8 @@ .release = sun3scsi_release, .info = sun3scsi_info, .queuecommand = sun3scsi_queue_command, - .abort = sun3scsi_abort, - .reset = sun3scsi_reset, + .eh_abort_handler = sun3scsi_abort, + .eh_bus_reset_handler = sun3scsi_bus_reset, .can_queue = CAN_QUEUE, .this_id = 7, .sg_tablesize = SG_TABLESIZE, diff -Nru a/drivers/scsi/sun3_scsi.h b/drivers/scsi/sun3_scsi.h --- a/drivers/scsi/sun3_scsi.h Sun Mar 23 00:22:50 2003 +++ b/drivers/scsi/sun3_scsi.h Sun Mar 23 00:22:50 2003 @@ -55,7 +55,7 @@ static int sun3scsi_abort (Scsi_Cmnd *); static int sun3scsi_detect (Scsi_Host_Template *); static const char *sun3scsi_info (struct Scsi_Host *); -static int sun3scsi_reset(Scsi_Cmnd *, unsigned int); +static int sun3scsi_bus_reset(Scsi_Cmnd *); static int sun3scsi_queue_command (Scsi_Cmnd *, void (*done)(Scsi_Cmnd *)); static int sun3scsi_proc_info (char *buffer, char **start, off_t offset, int length, int hostno, int inout); @@ -109,7 +109,7 @@ #define NCR5380_intr sun3scsi_intr #define NCR5380_queue_command sun3scsi_queue_command -#define NCR5380_reset sun3scsi_reset +#define NCR5380_bus_reset sun3scsi_bus_reset #define NCR5380_abort sun3scsi_abort #define NCR5380_proc_info sun3scsi_proc_info #define NCR5380_dma_xfer_len(i, cmd, phase) \ diff -Nru a/drivers/scsi/sun3_scsi_vme.c b/drivers/scsi/sun3_scsi_vme.c --- a/drivers/scsi/sun3_scsi_vme.c Sun Mar 23 00:22:56 2003 +++ b/drivers/scsi/sun3_scsi_vme.c Sun Mar 23 00:22:56 2003 @@ -1,4 +1,4 @@ -/* + /* * Sun3 SCSI stuff by Erik Verbruggen (erik@bigmama.xtdnet.nl) * * Sun3 DMA routines added by Sam Creasey (sammy@sammy.net) @@ -566,8 +566,8 @@ .release = sun3scsi_release, .info = sun3scsi_info, .queuecommand = sun3scsi_queue_command, - .abort = sun3scsi_abort, - .reset = sun3scsi_reset, + .eh_abort_handler = sun3scsi_abort, + .eh_bus_reset_handler = sun3scsi_bus_reset, .can_queue = CAN_QUEUE, .this_id = 7, .sg_tablesize = SG_TABLESIZE, diff -Nru a/drivers/scsi/sun3x_esp.c b/drivers/scsi/sun3x_esp.c --- a/drivers/scsi/sun3x_esp.c Sun Mar 23 00:22:54 2003 +++ b/drivers/scsi/sun3x_esp.c Sun Mar 23 00:22:54 2003 @@ -374,11 +374,44 @@ sp->SCp.ptr = (char *)((unsigned long)sp->SCp.buffer->dvma_address); } + +static int esp_slave_alloc(Scsi_Device *SDptr) +{ + struct esp_device *esp_dev = + kmalloc(sizeof(struct esp_device), GFP_ATOMIC); + + if (!esp_dev) + return -ENOMEM; + memset(esp_dev, 0, sizeof(struct esp_device)); + SDptr->hostdata = esp_dev; + return 0; +} + +static void esp_slave_destroy(Scsi_Device *SDptr) +{ + struct NCR_ESP *esp = (struct NCR_ESP *) SDptr->host->hostdata; + + esp->targets_present &= ~(1 << SDptr->id); + kfree(SDptr->hostdata); + SDptr->hostdata = NULL; +} + + +static int sun3x_esp_release(struct Scsi_Host *instance) +{ + /* this code does not support being compiled as a module */ + return 1; + +} + static Scsi_Host_Template driver_template = { .proc_name = "esp", .proc_info = &esp_proc_info, .name = "Sun ESP 100/100a/200", .detect = sun3x_esp_detect, + .release = sun3x_esp_release, + .slave_alloc = esp_slave_alloc, + .slave_destroy = esp_slave_destroy, .info = esp_info, .command = esp_command, .queuecommand = esp_queue, diff -Nru a/drivers/scsi/sym53c416.h b/drivers/scsi/sym53c416.h --- a/drivers/scsi/sym53c416.h Sun Mar 23 00:22:54 2003 +++ b/drivers/scsi/sym53c416.h Sun Mar 23 00:22:54 2003 @@ -18,14 +18,6 @@ #ifndef _SYM53C416_H #define _SYM53C416_H -#if !defined(LINUX_VERSION_CODE) -#include -#endif - -#ifndef LinuxVersionCode -#define LinuxVersionCode(v, p, s) (((v)<<16)+((p)<<8)+(s)) -#endif - #include #define SYM53C416_SCSI_ID 7 diff -Nru a/drivers/scsi/wd33c93.c b/drivers/scsi/wd33c93.c --- a/drivers/scsi/wd33c93.c Sun Mar 23 00:22:54 2003 +++ b/drivers/scsi/wd33c93.c Sun Mar 23 00:22:54 2003 @@ -1471,7 +1471,7 @@ int busycount = 0; extern void sgiwd93_reset(unsigned long); /* wait 'til the chip gets some time for us */ - while ((READ_AUX_STAT() & ASR_BSY) && busycount++ < 100) + while ((read_aux_stat(regs) & ASR_BSY) && busycount++ < 100) udelay (10); /* * there are scsi devices out there, which manage to lock up @@ -1481,7 +1481,7 @@ * does this for the SGI Indy, where this is possible */ /* still busy ? */ - if (READ_AUX_STAT() & ASR_BSY) + if (read_aux_stat(regs) & ASR_BSY) sgiwd93_reset(instance->base); /* yeah, give it the hard one */ } #endif @@ -2086,3 +2086,4 @@ EXPORT_SYMBOL(wd33c93_abort); EXPORT_SYMBOL(wd33c93_queuecommand); EXPORT_SYMBOL(wd33c93_intr); +EXPORT_SYMBOL(wd33c93_proc_info); diff -Nru a/drivers/scsi/wd7000.c b/drivers/scsi/wd7000.c --- a/drivers/scsi/wd7000.c Sun Mar 23 00:22:56 2003 +++ b/drivers/scsi/wd7000.c Sun Mar 23 00:22:56 2003 @@ -1710,7 +1710,11 @@ static int wd7000_biosparam(struct scsi_device *sdev, struct block_device *bdev, sector_t capacity, int *ip) { - dprintk("wd7000_biosparam: dev=%s, size=%d, ", bdevname(bdev), capacity); + char b[BDEVNAME_SIZE]; + + dprintk("wd7000_biosparam: dev=%s, size=%d, ", + bdevname(bdev, b), capacity); + (void)b; /* unused var warning? */ /* * try default translation diff -Nru a/drivers/serial/8250_pnp.c b/drivers/serial/8250_pnp.c --- a/drivers/serial/8250_pnp.c Sun Mar 23 00:22:50 2003 +++ b/drivers/serial/8250_pnp.c Sun Mar 23 00:22:50 2003 @@ -188,6 +188,8 @@ { "MVX00A1", 0 }, /* PC Rider K56 Phone System PnP */ { "MVX00F2", 0 }, + /* NEC 98NOTE SPEAKER PHONE FAX MODEM(33600bps) */ + { "nEC8241", 0 }, /* Pace 56 Voice Internal Plug & Play Modem */ { "PMC2430", 0 }, /* Generic */ @@ -373,6 +375,9 @@ ((port->min == 0x2f8) || (port->min == 0x3f8) || (port->min == 0x2e8) || +#ifdef CONFIG_X86_PC9800 + (port->min == 0x8b0) || +#endif (port->min == 0x3e8))) return 0; } diff -Nru a/drivers/serial/serial98.c b/drivers/serial/serial98.c --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/drivers/serial/serial98.c Sun Mar 23 00:22:57 2003 @@ -0,0 +1,1124 @@ +/* + * linux/drivers/serial/serial98.c + * + * Driver for NEC PC-9801/PC-9821 standard serial ports + * + * Based on drivers/serial/8250.c, by Russell King. + * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o. + * + * Copyright (C) 2002 Osamu Tomita + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#if defined(CONFIG_SERIAL98_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) +#define SUPPORT_SYSRQ +#endif + +#include + +#define SERIAL98_NR 1 +#define SERIAL98_ISR_PASS_LIMIT 256 +#define SERIAL98_EXT 0x434 + +//#define RX_8251F 0x130 /* In: Receive buffer */ +//#define TX_8251F 0x130 /* Out: Transmit buffer */ +//#define LSR_8251F 0x132 /* In: Line Status Register */ +//#define MSR_8251F 0x134 /* In: Modem Status Register */ +#define IIR_8251F 0x136 /* In: Interrupt ID Register */ +#define FCR_8251F 0x138 /* I/O: FIFO Control Register */ +#define VFAST_8251F 0x13a /* I/O: VFAST mode Register */ + +#define CMD_8251F 0x32 /* Out: 8251 Command Resister */ +#define IER2_8251F 0x34 /* I/O: Interrupt Enable Register */ +#define IER1_8251F 0x35 /* I/O: Interrupt Enable Register */ +#define IER1_CTL 0x37 /* Out: Interrupt Enable Register */ +#define DIS_RXR_INT 0x00 /* disable RxRDY Interrupt */ +#define ENA_RXR_INT 0x01 /* enable RxRDY Interrupt */ +#define DIS_TXE_INT 0x02 /* disable TxEMPTY Interrupt */ +#define ENA_TXE_INT 0x03 /* enable TxEMPTY Interrupt */ +#define DIS_TXR_INT 0x04 /* disable TxRDY Interrupt */ +#define ENA_TXR_INT 0x05 /* enable TxRDY Interrupt */ + +#define CMD_RESET 0x40 /* Reset Command */ +#define CMD_RTS 0x20 /* Set RTS line */ +#define CMD_CLR_ERR 0x10 /* Clear error flag */ +#define CMD_BREAK 0x08 /* Send Break */ +#define CMD_RXE 0x04 /* Enable receive */ +#define CMD_DTR 0x02 /* Set DTR line */ +#define CMD_TXE 0x01 /* Enable send */ +#define CMD_DUMMY 0x00 /* Dummy Command */ + +#define VFAST_ENABLE 0x80 /* V.Fast mode Enable */ + +/* Interrupt masks */ +#define INTR_8251_TXRE 0x04 +#define INTR_8251_TXEE 0x02 +#define INTR_8251_RXRE 0x01 +/* I/O Port */ +//#define PORT_8251_DATA 0 +//#define PORT_8251_CMD 2 +//#define PORT_8251_MOD 2 +//#define PORT_8251_STS 2 +/* status read */ +#define STAT_8251_TXRDY 0x01 +#define STAT_8251_RXRDY 0x02 +#define STAT_8251_TXEMP 0x04 +#define STAT_8251_PER 0x08 +#define STAT_8251_OER 0x10 +#define STAT_8251_FER 0x20 +#define STAT_8251_BRK 0x40 +#define STAT_8251_DSR 0x80 +#if 1 +#define STAT_8251F_TXEMP 0x01 +#define STAT_8251F_TXRDY 0x02 +#define STAT_8251F_RXRDY 0x04 +#define STAT_8251F_DSR 0x08 +#define STAT_8251F_OER 0x10 +#define STAT_8251F_PER 0x20 +#define STAT_8251F_FER 0x40 +#define STAT_8251F_BRK 0x80 +#else +#define STAT_8251F_TXEMP 0x01 +#define STAT_8251F_TEMT 0x01 +#define STAT_8251F_TXRDY 0x02 +#define STAT_8251F_THRE 0x02 +#define STAT_8251F_RXRDY 0x04 +#define STAT_8251F_DSR 0x04 +#define STAT_8251F_PER 0x08 +#define STAT_8251F_OER 0x10 +#define STAT_8251F_FER 0x20 +#define STAT_8251F_BRK 0x40 +#endif + +/* + * We wrap our port structure around the generic uart_port. + */ +struct serial98_port { + struct uart_port port; + unsigned int type; + unsigned int ext; + unsigned int lsr_break_flag; + unsigned char cmd; + unsigned char mode; + unsigned char msr; + unsigned char ier; + unsigned char rxchk; + unsigned char txemp; + unsigned char txrdy; + unsigned char rxrdy; + unsigned char brk; + unsigned char fe; + unsigned char oe; + unsigned char pe; + unsigned char dr; +}; + +#ifdef CONFIG_SERIAL98_CONSOLE +static void +serial98_console_write(struct console *co, const char *s, unsigned int count); +static kdev_t serial98_console_device(struct console *co); +static int __init serial98_console_setup(struct console *co, char *options); + +static struct console serial98_console = { + .name = "ttyS", + .write = serial98_console_write, + .device = serial98_console_device, + .setup = serial98_console_setup, + .flags = CON_PRINTBUFFER, + .index = -1, +}; + +#define SERIAL98_CONSOLE &serial98_console +#else +#define SERIAL98_CONSOLE NULL +#endif + +static struct uart_driver serial98_reg = { + .owner = THIS_MODULE, + .driver_name = "serial98", + .dev_name = "ttyS%d", + .major = TTY_MAJOR, + .minor = 64, + .nr = SERIAL98_NR, + .cons = SERIAL98_CONSOLE, +}; + +static int serial98_clk; +static char type_str[48]; + +#define PORT98 ((struct serial98_port *)port) +#define PORT (PORT98->port) + +static void serial98_fifo_enable(struct uart_port *port, int enable) +{ + unsigned char fcr; + + if (PORT.type == PORT_FIFO_PC98 || PORT.type == PORT_VFAST_PC98) { + fcr = inb(FCR_8251F); + if (enable) + fcr |= UART_FCR_ENABLE_FIFO; + else + fcr &= ~UART_FCR_ENABLE_FIFO; + outb(fcr, FCR_8251F); + } + + if (!enable) + return; + + outb(0, 0x5f); /* wait */ + outb(0, 0x5f); + outb(0, 0x5f); + outb(0, 0x5f); +} + +static void serial98_cmd_out(struct uart_port *port, unsigned char cmd) +{ + serial98_fifo_enable(port, 0); + outb(cmd, CMD_8251F); + serial98_fifo_enable(port, 1); +} + +static void serial98_mode_set(struct uart_port *port) +{ + serial98_cmd_out(port, CMD_DUMMY); + serial98_cmd_out(port, CMD_DUMMY); + serial98_cmd_out(port, CMD_DUMMY); + serial98_cmd_out(port, CMD_RESET); + serial98_cmd_out(port, PORT98->mode); +} + +static unsigned char serial98_msr_in(struct uart_port *port) +{ + unsigned long flags; + unsigned int ms, st; + unsigned int tmp; + + spin_lock_irqsave(&PORT.lock, flags); + if (PORT.type == PORT_FIFO_PC98 || PORT.type == PORT_VFAST_PC98) { + PORT98->msr = inb(PORT.iobase + 4); + } else { + ms = inb(0x33); + st = inb(0x32); + tmp = 0; + if(!(ms & 0x20)) + tmp |= UART_MSR_DCD; + if(!(ms & 0x80)) { + tmp |= UART_MSR_RI; + PORT98->msr |= UART_MSR_RI; + } + if(!(ms & 0x40)) + tmp |= UART_MSR_CTS; + if(st & 0x80) + tmp |= UART_MSR_DSR; + PORT98->msr = ((PORT98->msr ^ tmp) >> 4) | tmp; + } + + spin_unlock_irqrestore(&PORT.lock, flags); + return PORT98->msr; +} + +static void serial98_stop_tx(struct uart_port *port, unsigned int tty_stop) +{ + unsigned int ier = inb(IER1_8251F); + + ier &= ~(INTR_8251_TXRE | INTR_8251_TXEE); + outb(ier, IER1_8251F); +} + +static void serial98_start_tx(struct uart_port *port, unsigned int tty_start) +{ + unsigned int ier = inb(IER1_8251F); + + ier |= INTR_8251_TXRE | INTR_8251_TXEE; + outb(ier, IER1_8251F); +} + +static void serial98_stop_rx(struct uart_port *port) +{ + PORT.read_status_mask &= ~PORT98->dr; + outb(DIS_RXR_INT, IER1_CTL); +} + +static void serial98_enable_ms(struct uart_port *port) +{ + outb(PORT98->ier | 0x80, IER2_8251F); +} + +static void serial98_rx_chars(struct uart_port *port, int *status, + struct pt_regs *regs) +{ + struct tty_struct *tty = PORT.info->tty; + unsigned char ch; + int max_count = 256; + + do { + if (unlikely(tty->flip.count >= TTY_FLIPBUF_SIZE)) { + tty->flip.work.func((void *)tty); + if (tty->flip.count >= TTY_FLIPBUF_SIZE) + return; // if TTY_DONT_FLIP is set + } + ch = inb(PORT.iobase); + *tty->flip.char_buf_ptr = ch; + *tty->flip.flag_buf_ptr = TTY_NORMAL; + PORT.icount.rx++; + + if (unlikely(*status & (PORT98->brk | PORT98->pe | + PORT98->fe | PORT98->oe))) { + /* + * For statistics only + */ + if (*status & PORT98->brk) { + *status &= ~(PORT98->fe | PORT98->pe); + PORT.icount.brk++; + /* + * We do the SysRQ and SAK checking + * here because otherwise the break + * may get masked by ignore_status_mask + * or read_status_mask. + */ + if (uart_handle_break(&PORT)) + goto ignore_char; + } else if (*status & PORT98->pe) + PORT.icount.parity++; + else if (*status & PORT98->fe) + PORT.icount.frame++; + if (*status & PORT98->oe) + PORT.icount.overrun++; + + /* + * Mask off conditions which should be ingored. + */ + *status &= PORT.read_status_mask; + +#ifdef CONFIG_SERIAL98_CONSOLE + if (PORT.line == PORT.cons->index) { + /* Recover the break flag from console xmit */ + *status |= PORT98->lsr_break_flag; + PORT98->lsr_break_flag = 0; + } +#endif + if (*status & PORT98->brk) { + *tty->flip.flag_buf_ptr = TTY_BREAK; + } else if (*status & PORT98->pe) + *tty->flip.flag_buf_ptr = TTY_PARITY; + else if (*status & PORT98->fe) + *tty->flip.flag_buf_ptr = TTY_FRAME; + } + if (uart_handle_sysrq_char(&PORT, ch, regs)) + goto ignore_char; + if ((*status & PORT.ignore_status_mask) == 0) { + tty->flip.flag_buf_ptr++; + tty->flip.char_buf_ptr++; + tty->flip.count++; + } + if ((*status & PORT98->oe) && + tty->flip.count < TTY_FLIPBUF_SIZE) { + /* + * Overrun is special, since it's reported + * immediately, and doesn't affect the current + * character. + */ + *tty->flip.flag_buf_ptr = TTY_OVERRUN; + tty->flip.flag_buf_ptr++; + tty->flip.char_buf_ptr++; + tty->flip.count++; + } + ignore_char: + *status = inb(PORT.iobase + 2); + } while ((*status & PORT98->rxchk) && (max_count-- > 0)); + tty_flip_buffer_push(tty); +} + +static void serial98_tx_chars(struct uart_port *port) +{ + struct circ_buf *xmit = &PORT.info->xmit; + int count; + + if (PORT.x_char) { + outb(PORT.x_char, PORT.iobase); + PORT.icount.tx++; + PORT.x_char = 0; + return; + } + if (uart_circ_empty(xmit) || uart_tx_stopped(&PORT)) { + serial98_stop_tx(port, 0); + return; + } + + count = PORT.fifosize; + do { + outb(xmit->buf[xmit->tail], PORT.iobase); + xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); + PORT.icount.tx++; + if (uart_circ_empty(xmit)) + break; + } while (--count > 0); + + if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) + uart_write_wakeup(&PORT); + + if (uart_circ_empty(xmit)) + serial98_stop_tx(&PORT, 0); +} + +static void serial98_modem_status(struct uart_port *port) +{ + int status; + + status = serial98_msr_in(port); + + if ((status & UART_MSR_ANY_DELTA) == 0) + return; + + if (status & UART_MSR_TERI) + PORT.icount.rng++; + if (status & UART_MSR_DDSR) + PORT.icount.dsr++; + if (status & UART_MSR_DDCD) + uart_handle_dcd_change(&PORT, status & UART_MSR_DCD); + if (status & UART_MSR_DCTS) + uart_handle_cts_change(&PORT, status & UART_MSR_CTS); + + wake_up_interruptible(&PORT.info->delta_msr_wait); +} + +static void serial98_int(int irq, void *port, struct pt_regs *regs) +{ + unsigned int status; + + spin_lock(&PORT.lock); + status = inb(PORT.iobase + 2); + if (status & PORT98->rxrdy) { + serial98_rx_chars(port, &status, regs); + } + serial98_modem_status(port); + if (status & PORT98->txrdy) { + serial98_tx_chars(port); + } + spin_unlock(&PORT.lock); +} + +static unsigned int serial98_tx_empty(struct uart_port *port) +{ + unsigned long flags; + unsigned int ret = 0; + + spin_lock_irqsave(&PORT.lock, flags); + if (inb(PORT.iobase + 2) & PORT98->txemp) + ret = TIOCSER_TEMT; + + spin_unlock_irqrestore(&PORT.lock, flags); + return ret; +} + +static unsigned int serial98_get_mctrl(struct uart_port *port) +{ + unsigned char status; + unsigned int ret = 0; + + status = serial98_msr_in(port); + if (status & UART_MSR_DCD) + ret |= TIOCM_CAR; + if (status & UART_MSR_RI) + ret |= TIOCM_RNG; + if (status & UART_MSR_DSR) + ret |= TIOCM_DSR; + if (status & UART_MSR_CTS) + ret |= TIOCM_CTS; + return ret; +} + +static void serial98_set_mctrl(struct uart_port *port, unsigned int mctrl) +{ + PORT98->cmd &= 0xdd; + if (mctrl & TIOCM_RTS) + PORT98->cmd |= CMD_RTS; + + if (mctrl & TIOCM_DTR) + PORT98->cmd |= CMD_DTR; + + serial98_cmd_out(port, PORT98->cmd); +} + +static void serial98_break_ctl(struct uart_port *port, int break_state) +{ + unsigned long flags; + + spin_lock_irqsave(&PORT.lock, flags); + if (break_state == -1) + PORT98->cmd |= CMD_BREAK; + else + PORT98->cmd &= ~CMD_BREAK; + + serial98_cmd_out(port, PORT98->cmd); + spin_unlock_irqrestore(&PORT.lock, flags); +} + +static int serial98_startup(struct uart_port *port) +{ + int retval; + + if (PORT.type == PORT_8251_PC98) { + /* Wake up UART */ + PORT98->mode = 0xfc; + serial98_mode_set(port); + outb(DIS_RXR_INT, IER1_CTL); + outb(DIS_TXE_INT, IER1_CTL); + outb(DIS_TXR_INT, IER1_CTL); + PORT98->mode = 0; + serial98_mode_set(port); + } + + /* + * Clear the FIFO buffers and disable them. + * (they will be reeanbled in set_termios()) + */ + if (PORT.type == PORT_FIFO_PC98 || PORT.type == PORT_VFAST_PC98) { + outb(UART_FCR_ENABLE_FIFO, FCR_8251F); + outb((UART_FCR_ENABLE_FIFO + | UART_FCR_CLEAR_RCVR + | UART_FCR_CLEAR_XMIT), FCR_8251F); + outb(0, FCR_8251F); + } + + /* Clear the interrupt registers. */ + inb(0x30); + inb(0x32); + if (PORT.type == PORT_FIFO_PC98 || PORT.type == PORT_VFAST_PC98) { + inb(PORT.iobase); + inb(PORT.iobase + 2); + inb(PORT.iobase + 4); + inb(PORT.iobase + 6); + } + + /* Allocate the IRQ */ + retval = request_irq(PORT.irq, serial98_int, 0, + serial98_reg.driver_name, port); + if (retval) + return retval; + + /* + * Now, initialize the UART + */ + PORT98->mode = 0x4e; + serial98_mode_set(port); + PORT98->cmd = 0x15; + serial98_cmd_out(port, PORT98->cmd); + PORT98->cmd = 0x05; + + /* + * Finally, enable interrupts + */ + outb(0x00, IER2_8251F); + outb(ENA_RXR_INT, IER1_CTL); + + /* + * And clear the interrupt registers again for luck. + */ + inb(0x30); + inb(0x32); + if (PORT.type == PORT_FIFO_PC98 || PORT.type == PORT_VFAST_PC98) { + inb(PORT.iobase); + inb(PORT.iobase + 2); + inb(PORT.iobase + 4); + inb(PORT.iobase + 6); + } + + return 0; +} + +static void serial98_shutdown(struct uart_port *port) +{ + unsigned long flags; + + /* + * disable all interrupts + */ + spin_lock_irqsave(&PORT.lock, flags); + if (PORT.type == PORT_VFAST_PC98) + outb(0, VFAST_8251F); /* V.FAST mode off */ + + /* disnable all modem status interrupt */ + outb(0x80, IER2_8251F); + + /* disnable TX/RX interrupt */ + outb(0x00, IER2_8251F); + outb(DIS_RXR_INT, IER1_CTL); + outb(DIS_TXE_INT, IER1_CTL); + outb(DIS_TXR_INT, IER1_CTL); + PORT98->ier = 0; + + spin_unlock_irqrestore(&PORT.lock, flags); + + /* + * Free the interrupt + */ + free_irq(PORT.irq, port); + + /* disable break condition and disable the port */ + serial98_mode_set(port); + + /* disable FIFO's */ + if (PORT.type == PORT_FIFO_PC98 || PORT.type == PORT_VFAST_PC98) { + outb((UART_FCR_ENABLE_FIFO + | UART_FCR_CLEAR_RCVR + | UART_FCR_CLEAR_XMIT), FCR_8251F); + outb(0, FCR_8251F); + } + + inb(PORT.iobase); +} + +static void +serial98_set_termios(struct uart_port *port, struct termios *termios, + struct termios *old) +{ + unsigned char stopbit, cval, fcr = 0, ier = 0; + unsigned long flags; + unsigned int baud, quot; + + stopbit = 0x80; + switch (termios->c_cflag & CSIZE) { + case CS5: + cval = 0x42; + stopbit = 0xc0; + break; + case CS6: + cval = 0x46; + break; + case CS7: + cval = 0x4a; + break; + default: + case CS8: + cval = 0x4e; + break; + } + + if (termios->c_cflag & CSTOPB) + cval ^= stopbit; + if (termios->c_cflag & PARENB) + cval |= 0x10; + if (!(termios->c_cflag & PARODD)) + cval |= 0x20; + + /* + * Ask the core to calculate the divisor for us. + */ + baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16); + quot = uart_get_divisor(port, baud); + + if (PORT.type == PORT_FIFO_PC98 || PORT.type == PORT_VFAST_PC98) { + if ((PORT.uartclk / quot) < (2400 * 16)) + fcr = UART_FCR_ENABLE_FIFO | UART_FCR_TRIGGER_1; + else + fcr = UART_FCR_ENABLE_FIFO | UART_FCR_TRIGGER_8; + } + + /* + * Ok, we're now changing the port state. Do it with + * interrupts disabled. + */ + spin_lock_irqsave(&PORT.lock, flags); + + /* + * Update the per-port timeout. + */ + uart_update_timeout(port, termios->c_cflag, baud); + + PORT.read_status_mask = PORT98->oe | PORT98->txemp | PORT98->dr; + if (termios->c_iflag & INPCK) + PORT.read_status_mask |= PORT98->fe | PORT98->pe; + + if (termios->c_iflag & (BRKINT | PARMRK)) + PORT.read_status_mask |= PORT98->brk; + /* + * Characters to ignore + */ + PORT.ignore_status_mask = 0; + if (termios->c_iflag & IGNPAR) + PORT.ignore_status_mask |= PORT98->fe | PORT98->pe; + + if (termios->c_iflag & IGNBRK) { + PORT.ignore_status_mask |= PORT98->brk; + /* + * If we're ignoring parity and break indicators, + * ignore overruns too (for real raw support). + */ + if (termios->c_iflag & IGNPAR) + PORT.ignore_status_mask |= PORT98->oe; + } + + /* + * ignore all characters if CREAD is not set + */ + if ((termios->c_cflag & CREAD) == 0) + PORT.ignore_status_mask |= PORT98->dr; + + /* + * CTS flow control flag and modem status interrupts + */ + if (PORT.flags & UPF_HARDPPS_CD) + ier |= 0x80; /* enable modem status interrupt */ + if (termios->c_cflag & CRTSCTS) { + ier |= 0x08; /* enable CTS interrupt */ + ier |= 0x80; /* enable modem status interrupt */ + } + if (!(termios->c_cflag & CLOCAL)) { + ier |= 0x20; /* enable CD interrupt */ + ier |= 0x80; /* enable modem status interrupt */ + } + PORT98->ier = ier; + + PORT98->mode = cval; + serial98_mode_set(port); + if (PORT.type == PORT_VFAST_PC98 && quot <= 48) { + quot /= 4; + if (quot < 1) + quot = 1; + outb(quot | VFAST_ENABLE, VFAST_8251F); + } else { + quot /= 3; + if (quot < 1) + quot = 1; + if (PORT.type == PORT_VFAST_PC98) + outb(0, VFAST_8251F); /* V.FAST mode off */ + outb(0xb6, 0x77); + outb(quot & 0xff, 0x75); /* LS of divisor */ + outb(quot >> 8, 0x75); /* MS of divisor */ + } + + if (fcr & UART_FCR_ENABLE_FIFO) { + outb(UART_FCR_ENABLE_FIFO, FCR_8251F); + outb(fcr, FCR_8251F); + } + + /* enable RX/TX */ + PORT98->cmd = 0x15; + serial98_cmd_out(port, PORT98->cmd); + PORT98->cmd = 0x05; + /* enable interrupts */ + outb(0x00, IER2_8251F); + outb(ENA_RXR_INT, IER1_CTL); + spin_unlock_irqrestore(&PORT.lock, flags); +} + +static const char *serial98_type(struct uart_port *port) +{ + char *p; + + switch (PORT.type) { + case PORT_8251_PC98: + p = "PC98 onboard legacy 8251"; + break; + case PORT_19K_PC98: + p = "PC98 onboard max 19200bps"; + break; + case PORT_FIFO_PC98: + p = "PC98 onboard with FIFO"; + break; + case PORT_VFAST_PC98: + p = "PC98 onboard V.FAST"; + break; + case PORT_PC9861: + p = "PC-9861K RS-232C ext. board"; + break; + case PORT_PC9801_101: + p = "PC-9801-101 RS-232C ext. board"; + break; + default: + return NULL; + } + + sprintf(type_str, "%s Clock %dMHz", p, serial98_clk); + return type_str; +} + +/* Release the region(s) being used by 'port' */ +static void serial98_release_port(struct uart_port *port) +{ + switch (PORT.type) { + case PORT_VFAST_PC98: + release_region(PORT.iobase + 0xa, 1); + case PORT_FIFO_PC98: + release_region(PORT.iobase + 8, 1); + release_region(PORT.iobase + 6, 1); + release_region(PORT.iobase + 4, 1); + release_region(PORT.iobase + 2, 1); + release_region(PORT.iobase, 1); + case PORT_19K_PC98: + release_region(SERIAL98_EXT, 1); + release_region(0x34, 1); + case PORT_8251_PC98: + release_region(0x32, 1); + release_region(0x30, 1); + } +} + +/* Request the region(s) being used by 'port' */ +#define REQ_REGION98(base) (request_region((base), 1, serial98_reg.driver_name)) +static int serial98_request_region(unsigned int type) +{ + if (!REQ_REGION98(0x30)) + return -EBUSY; + if (REQ_REGION98(0x32)) { + if (type == PORT_8251_PC98) + return 0; + if (REQ_REGION98(0x34)) { + if (REQ_REGION98(SERIAL98_EXT)) { + unsigned long base; + + if (type == PORT_19K_PC98) + return 0; + for (base = 0x130; base <= 0x138; base += 2) { + if (!REQ_REGION98(base)) { + base -= 2; + goto err; + } + } + if (type == PORT_FIFO_PC98) + return 0; + if (type == PORT_VFAST_PC98) { + if (REQ_REGION98(0x13a)) + return 0; + } + err: + while (base >= 0x130) { + release_region(base, 1); + base -= 2; + } + release_region(SERIAL98_EXT, 1); + } + release_region(0x34, 1); + } + release_region(0x32, 1); + } + release_region(0x30, 1); + return -EBUSY; +} + +static int serial98_request_port(struct uart_port *port) +{ + return serial98_request_region(PORT.type); +} + +/* + * Configure/autoconfigure the port. + */ +static void serial98_config_port(struct uart_port *port, int flags) +{ + if (flags & UART_CONFIG_TYPE) + PORT.type = PORT98->type; +} + +/* + * verify the new serial_struct (for TIOCSSERIAL). + */ +static int serial98_verify_port(struct uart_port *port, struct serial_struct *ser) +{ + switch (ser->type) { + case PORT_VFAST_PC98: + case PORT_FIFO_PC98: + case PORT_19K_PC98: + case PORT_8251_PC98: + /* not implemented yet + case PORT_PC9861: + case PORT_PC9801_101: + */ + case PORT_UNKNOWN: + break; + default: + return -EINVAL; + } + if (ser->irq < 0 || ser->irq >= NR_IRQS) + return -EINVAL; + if (ser->baud_base < 9600) + return -EINVAL; + return 0; +} + +static struct uart_ops serial98_ops = { + .tx_empty = serial98_tx_empty, + .set_mctrl = serial98_set_mctrl, + .get_mctrl = serial98_get_mctrl, + .stop_tx = serial98_stop_tx, + .start_tx = serial98_start_tx, + .stop_rx = serial98_stop_rx, + .enable_ms = serial98_enable_ms, + .break_ctl = serial98_break_ctl, + .startup = serial98_startup, + .shutdown = serial98_shutdown, + .set_termios = serial98_set_termios, + .type = serial98_type, + .release_port = serial98_release_port, + .request_port = serial98_request_port, + .config_port = serial98_config_port, + .verify_port = serial98_verify_port, +}; + +static struct serial98_port serial98_ports[SERIAL98_NR] = { + { + .port = { + .iobase = 0x30, + .iotype = SERIAL_IO_PORT, + .irq = 4, + .fifosize = 1, + .ops = &serial98_ops, + .flags = ASYNC_BOOT_AUTOCONF, + .line = 0, + }, + .rxchk = STAT_8251_RXRDY, + .txemp = STAT_8251_TXEMP, + .txrdy = STAT_8251_TXRDY, + .rxrdy = STAT_8251_RXRDY, + .brk = STAT_8251_BRK, + .fe = STAT_8251_FER, + .oe = STAT_8251_OER, + .pe = STAT_8251_PER, + .dr = STAT_8251_DSR, + }, +}; + +#ifdef CONFIG_SERIAL98_CONSOLE + +#define BOTH_EMPTY (PORT98->txemp | PORT98->txrdy) + +/* + * Wait for transmitter & holding register to empty + */ +static inline void wait_for_xmitr(struct uart_port *port) +{ + unsigned int status, tmout = 10000; + + /* Wait up to 10ms for the character(s) to be sent. */ + do { + status = inb(PORT.iobase + 2); + + if (status & PORT98->brk) + PORT98->lsr_break_flag = PORT98->brk; + + if (--tmout == 0) + break; + udelay(1); + } while ((status & BOTH_EMPTY) != BOTH_EMPTY); + + /* Wait up to 1s for flow control if necessary */ + if (PORT.flags & UPF_CONS_FLOW) { + tmout = 1000000; + while (--tmout && + ((serial98_msr_in(port) & UART_MSR_CTS) == 0)) + udelay(1); + } +} + +/* + * Print a string to the serial port trying not to disturb + * any possible real use of the port... + * + * The console_lock must be held when we get here. + */ +static void +serial98_console_write(struct console *co, const char *s, unsigned int count) +{ + struct uart_port *port = (struct uart_port *)&serial98_ports[co->index]; + unsigned int ier1, ier2; + int i; + + /* + * First save the UER then disable the interrupts + */ + ier1 = inb(IER1_8251F); + ier2 = inb(IER2_8251F); + /* disnable all modem status interrupt */ + outb(0x80, IER2_8251F); + + /* disnable TX/RX interrupt */ + outb(0x00, IER2_8251F); + outb(DIS_RXR_INT, IER1_CTL); + outb(DIS_TXE_INT, IER1_CTL); + outb(DIS_TXR_INT, IER1_CTL); + + /* + * Now, do each character + */ + for (i = 0; i < count; i++, s++) { + wait_for_xmitr(port); + + /* + * Send the character out. + * If a LF, also do CR... + */ + outb(*s, PORT.iobase); + if (*s == 10) { + wait_for_xmitr(port); + outb(13, PORT.iobase); + } + } + + /* + * Finally, wait for transmitter to become empty + * and restore the IER + */ + wait_for_xmitr(port); + + /* restore TX/RX interrupt */ + outb(0x00, IER2_8251F); + if (ier1 & 0x01) + outb(ENA_RXR_INT, IER1_CTL); + if (ier1 & 0x02) + outb(ENA_TXE_INT, IER1_CTL); + if (ier1 & 0x04) + outb(ENA_TXR_INT, IER1_CTL); + + /* restore modem status interrupt */ + outb(ier2, IER2_8251F); +} + +static kdev_t serial98_console_device(struct console *co) +{ + return mk_kdev(TTY_MAJOR, 64 + co->index); +} + +static int __init serial98_console_setup(struct console *co, char *options) +{ + struct uart_port *port; + int baud = 9600; + int bits = 8; + int parity = 'n'; + int flow = 'n'; + + /* + * Check whether an invalid uart number has been specified, and + * if so, search for the first available port that does have + * console support. + */ + if (co->index >= SERIAL98_NR) + co->index = 0; + port = &serial98_ports[co->index].port; + + /* + * Temporary fix. + */ + spin_lock_init(&port->lock); + + if (options) + uart_parse_options(options, &baud, &parity, &bits, &flow); + + return uart_set_options(port, co, baud, parity, bits, flow); +} + +void __init serial98_console_init(void) +{ + register_console(&serial98_console); +} + +#endif /* CONFIG_SERIAL98_CONSOLE */ + + +static int __init serial98_init(void) +{ + int ret; + unsigned char iir1, iir2; + + if (PC9800_8MHz_P()) { + serial98_clk = 8; + serial98_ports[0].port.uartclk = 374400 * 16; + } else { + serial98_clk = 5; + serial98_ports[0].port.uartclk = 460800 * 16; + } + + printk(KERN_INFO "serial98: PC-9801 standard serial port driver Version 0.1alpha\n"); + serial98_ports[0].type = PORT_8251_PC98; + /* Check FIFO exist */ + iir1 = inb(IIR_8251F); + iir2 = inb(IIR_8251F); + if ((iir1 & 0x40) != (iir2 & 0x40) && (iir1 & 0x20) == (iir2 & 0x20)) { + serial98_ports[0].port.iobase = 0x130; + serial98_ports[0].port.fifosize = 16; + serial98_ports[0].rxchk = STAT_8251F_DSR; + serial98_ports[0].txemp = STAT_8251F_TXEMP; + serial98_ports[0].txrdy = STAT_8251F_TXRDY; + serial98_ports[0].rxrdy = STAT_8251F_RXRDY; + serial98_ports[0].brk = STAT_8251F_BRK; + serial98_ports[0].fe = STAT_8251F_FER; + serial98_ports[0].oe = STAT_8251F_OER; + serial98_ports[0].pe = STAT_8251F_PER; + serial98_ports[0].dr = STAT_8251F_DSR; + + if (*(unsigned char*)__va(PC9821SCA_RSFLAGS) & 0x10) + serial98_ports[0].type = PORT_VFAST_PC98; + else { + outb(serial98_ports[0].ext | 0x40, SERIAL98_EXT); + serial98_ports[0].port.uartclk *= 4; + serial98_ports[0].type = PORT_FIFO_PC98; + } + } else if ((serial98_ports[0].ext = inb(SERIAL98_EXT)) != 0xff) { + outb(serial98_ports[0].ext | 0x40, SERIAL98_EXT); + if (inb(SERIAL98_EXT) == (serial98_ports[0].ext | 0x40)) { + serial98_ports[0].port.uartclk *= 4; + serial98_ports[0].type = PORT_19K_PC98; + } else { + serial98_ops.enable_ms = NULL; + outb(serial98_ports[0].ext, SERIAL98_EXT); + } + } + + if (serial98_request_region(serial98_ports[0].type)) + return -EBUSY; + + ret = uart_register_driver(&serial98_reg); + if (ret == 0) { + int i; + + for (i = 0; i < SERIAL98_NR; i++) { + uart_add_one_port(&serial98_reg, + (struct uart_port *)&serial98_ports[i]); + } + } + + return ret; +} + +static void __exit serial98_exit(void) +{ + int i; + + if (serial98_ports[0].type == PORT_19K_PC98 + || serial98_ports[0].type == PORT_FIFO_PC98) + outb(serial98_ports[0].ext, SERIAL98_EXT); + + for (i = 0; i < SERIAL98_NR; i++) { + uart_remove_one_port(&serial98_reg, + (struct uart_port *)&serial98_ports[i]); + } + + uart_unregister_driver(&serial98_reg); +} + +module_init(serial98_init); +module_exit(serial98_exit); + +MODULE_AUTHOR("Osamu Tomita "); +MODULE_DESCRIPTION("PC-9801 standard serial port driver Version 0.1alpha"); +MODULE_LICENSE("GPL"); diff -Nru a/drivers/serial/uart00.c b/drivers/serial/uart00.c --- a/drivers/serial/uart00.c Sun Mar 23 00:22:52 2003 +++ b/drivers/serial/uart00.c Sun Mar 23 00:22:52 2003 @@ -235,8 +235,8 @@ status = UART_GET_MSR(port); - if (!status & (UART_MSR_DCTS_MSK | UART_MSR_DDSR_MSK | - UART_MSR_TERI_MSK | UART_MSR_DDCD_MSK)) + if (!(status & (UART_MSR_DCTS_MSK | UART_MSR_DDSR_MSK | + UART_MSR_TERI_MSK | UART_MSR_DDCD_MSK))) return; if (status & UART_MSR_DDCD_MSK) diff -Nru a/drivers/telephony/ixj.c b/drivers/telephony/ixj.c --- a/drivers/telephony/ixj.c Sun Mar 23 00:22:50 2003 +++ b/drivers/telephony/ixj.c Sun Mar 23 00:22:50 2003 @@ -5999,12 +5999,14 @@ if(ixjdebug & 0x0001) { printk(KERN_INFO "Could not copy cadence to kernel\n"); } + kfree(lcp); return -EFAULT; } if (lcp->filter > 5) { if(ixjdebug & 0x0001) { printk(KERN_INFO "Cadence out of range\n"); } + kfree(lcp); return -1; } j->cadence_f[lcp->filter].state = 0; diff -Nru a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c --- a/drivers/usb/core/hub.c Sun Mar 23 00:22:53 2003 +++ b/drivers/usb/core/hub.c Sun Mar 23 00:22:53 2003 @@ -1175,7 +1175,7 @@ int usb_reset_device(struct usb_device *dev) { struct usb_device *parent = dev->parent; - struct usb_device_descriptor descriptor; + struct usb_device_descriptor *descriptor; int i, ret, port = -1; if (!parent) { @@ -1224,17 +1224,24 @@ * If nothing changed, we reprogram the configuration and then * the alternate settings. */ - ret = usb_get_descriptor(dev, USB_DT_DEVICE, 0, &descriptor, - sizeof(descriptor)); - if (ret < 0) + descriptor = kmalloc(sizeof *descriptor, GFP_NOIO); + if (!descriptor) { + return -ENOMEM; + } + ret = usb_get_descriptor(dev, USB_DT_DEVICE, 0, descriptor, + sizeof(*descriptor)); + if (ret < 0) { + kfree(descriptor); return ret; + } - le16_to_cpus(&descriptor.bcdUSB); - le16_to_cpus(&descriptor.idVendor); - le16_to_cpus(&descriptor.idProduct); - le16_to_cpus(&descriptor.bcdDevice); + le16_to_cpus(&descriptor->bcdUSB); + le16_to_cpus(&descriptor->idVendor); + le16_to_cpus(&descriptor->idProduct); + le16_to_cpus(&descriptor->bcdDevice); - if (memcmp(&dev->descriptor, &descriptor, sizeof(descriptor))) { + if (memcmp(&dev->descriptor, descriptor, sizeof(*descriptor))) { + kfree(descriptor); usb_destroy_configuration(dev); ret = usb_get_device_descriptor(dev); @@ -1267,6 +1274,8 @@ return 1; } + + kfree(descriptor); ret = usb_set_configuration(dev, dev->actconfig->desc.bConfigurationValue); if (ret < 0) { diff -Nru a/drivers/usb/core/message.c b/drivers/usb/core/message.c --- a/drivers/usb/core/message.c Sun Mar 23 00:22:51 2003 +++ b/drivers/usb/core/message.c Sun Mar 23 00:22:51 2003 @@ -88,7 +88,7 @@ int retv; int length; - urb = usb_alloc_urb(0, GFP_KERNEL); + urb = usb_alloc_urb(0, GFP_NOIO); if (!urb) return -ENOMEM; @@ -131,7 +131,7 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request, __u8 requesttype, __u16 value, __u16 index, void *data, __u16 size, int timeout) { - struct usb_ctrlrequest *dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL); + struct usb_ctrlrequest *dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_NOIO); int ret; if (!dr) diff -Nru a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c --- a/drivers/usb/host/ehci-dbg.c Sun Mar 23 00:22:55 2003 +++ b/drivers/usb/host/ehci-dbg.c Sun Mar 23 00:22:55 2003 @@ -117,10 +117,10 @@ static void __attribute__((__unused__)) dbg_qh (char *label, struct ehci_hcd *ehci, struct ehci_qh *qh) { - dbg ("%s %p info1 %x info2 %x hw_curr %x qtd_next %x", label, - qh, qh->hw_info1, qh->hw_info2, + dbg ("%s %p n%08x info1 %x info2 %x hw_curr %x qtd_next %x", label, + qh, qh->hw_next, qh->hw_info1, qh->hw_info2, qh->hw_current, qh->hw_qtd_next); - dbg (" alt+errs= %x, token= %x, page0= %x, page1= %x", + dbg (" alt+nak+t= %x, token= %x, page0= %x, page1= %x", qh->hw_alt_next, qh->hw_token, qh->hw_buf [0], qh->hw_buf [1]); if (qh->hw_buf [2]) { diff -Nru a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c --- a/drivers/usb/host/ehci-hcd.c Sun Mar 23 00:22:54 2003 +++ b/drivers/usb/host/ehci-hcd.c Sun Mar 23 00:22:54 2003 @@ -576,7 +576,7 @@ int ports; int i; - dbg ("%s: suspend to %d", hcd_to_bus (hcd)->bus_name, state); + ehci_dbg (ehci, "suspend to %d\n", state); ports = HCS_N_PORTS (ehci->hcs_params); @@ -593,7 +593,7 @@ if ((temp & PORT_PE) == 0 || (temp & PORT_OWNER) != 0) continue; -dbg ("%s: suspend port %d", hcd_to_bus (hcd)->bus_name, i); + ehci_dbg (ehci, "suspend port %d", i); temp |= PORT_SUSPEND; writel (temp, &ehci->regs->port_status [i]); } @@ -615,7 +615,7 @@ int ports; int i; - dbg ("%s: resume", hcd_to_bus (hcd)->bus_name); + ehci_dbg (ehci, "resume\n"); ports = HCS_N_PORTS (ehci->hcs_params); @@ -635,7 +635,7 @@ if ((temp & PORT_PE) == 0 || (temp & PORT_SUSPEND) != 0) continue; -dbg ("%s: resume port %d", hcd_to_bus (hcd)->bus_name, i); + ehci_dbg (ehci, "resume port %d", i); temp |= PORT_RESUME; writel (temp, &ehci->regs->port_status [i]); readl (&ehci->regs->command); /* unblock posted writes */ @@ -880,8 +880,8 @@ /* ASSERT: no requests/urbs are still linked (so no TDs) */ /* ASSERT: nobody can be submitting urbs for this any more */ - dbg ("%s: free_config devnum %d", - hcd_to_bus (hcd)->bus_name, udev->devnum); + ehci_dbg (ehci, "free_config %s devnum %d\n", + udev->devpath, udev->devnum); spin_lock_irqsave (&ehci->lock, flags); for (i = 0; i < 32; i++) { @@ -912,7 +912,8 @@ dev->ep [i] = 0; if (qh->qh_state == QH_STATE_IDLE) goto idle; - dbg ("free_config, async ep 0x%02x qh %p", i, qh); + ehci_dbg (ehci, "free_config, async ep 0x%02x qh %p", + i, qh); /* scan_async() empties the ring as it does its work, * using IAA, but doesn't (yet?) turn it off. if it diff -Nru a/drivers/usb/image/scanner.c b/drivers/usb/image/scanner.c --- a/drivers/usb/image/scanner.c Sun Mar 23 00:22:51 2003 +++ b/drivers/usb/image/scanner.c Sun Mar 23 00:22:51 2003 @@ -347,8 +347,9 @@ * - Don't print errors when the device is busy. * * 0.4.11 2003-02-25 - * - Added vendor/product ids for Artec, Avision, Brother, Medion, Primax, - * Prolink, Fujitsu, Plustek, and SYSCAN scanners. + * - Added vendor/product ids for Artec, Avision, Brother, Canon, Compaq, + * Fujitsu, Hewlett-Packard, Lexmark, LG Electronics, Medion, Microtek, + * Primax, Prolink, Plustek, SYSCAN, Trust and UMAX scanners. * - Fixed generation of devfs names if dynamic minors are disabled. * - Used kobject reference counting to free the scn struct when the device * is closed and disconnected. Avoids crashes when writing to a diff -Nru a/drivers/usb/image/scanner.h b/drivers/usb/image/scanner.h --- a/drivers/usb/image/scanner.h Sun Mar 23 00:22:52 2003 +++ b/drivers/usb/image/scanner.h Sun Mar 23 00:22:52 2003 @@ -105,6 +105,7 @@ { USB_DEVICE(0x0638, 0x0a10) }, /* iVina FB1600 (=Umax Astra 4500) */ /* Benq: see Acer */ /* Brother */ + { USB_DEVICE(0x04f9, 0x010f) }, /* MFC 5100C */ { USB_DEVICE(0x04f9, 0x0111) }, /* MFC 6800 */ /* Canon */ { USB_DEVICE(0x04a9, 0x2201) }, /* CanoScan FB320U */ @@ -118,9 +119,11 @@ { USB_DEVICE(0x04a9, 0x220c) }, /* CanoScan D1250U2 */ { USB_DEVICE(0x04a9, 0x220d) }, /* CanoScan N670U/N676U/LIDE 20 */ { USB_DEVICE(0x04a9, 0x220e) }, /* CanoScan N1240U/LIDE 30 */ + { USB_DEVICE(0x04a9, 0x2213) }, /* LIDE 50 */ { USB_DEVICE(0x04a9, 0x3042) }, /* FS4000US */ /* Colorado -- See Primax/Colorado below */ /* Compaq */ + { USB_DEVICE(0x049f, 0x001a) }, /* S4 100 */ { USB_DEVICE(0x049f, 0x0021) }, /* S200 */ /* Epson -- See Seiko/Epson below */ /* Fujitsu */ @@ -152,6 +155,8 @@ { USB_DEVICE(0x03f0, 0x0705) }, /* ScanJet 4400C */ // { USB_DEVICE(0x03f0, 0x0801) }, /* ScanJet 7400C - NOT SUPPORTED - use hpusbscsi driver */ { USB_DEVICE(0x03f0, 0x0901) }, /* ScanJet 2300C */ + { USB_DEVICE(0x03F0, 0x1005) }, /* ScanJet 5400C */ + { USB_DEVICE(0x03F0, 0x1105) }, /* ScanJet 5470C */ { USB_DEVICE(0x03f0, 0x1305) }, /* Scanjet 4570c */ { USB_DEVICE(0x03f0, 0x2005) }, /* ScanJet 3570c */ { USB_DEVICE(0x03f0, 0x2205) }, /* ScanJet 3500c */ @@ -159,12 +164,16 @@ { USB_DEVICE(0x0638, 0x0268) }, /* 1200U */ /* Lexmark */ { USB_DEVICE(0x043d, 0x002d) }, /* X70/X73 */ + { USB_DEVICE(0x043d, 0x003d) }, /* X83 */ + /* LG Electronics */ + { USB_DEVICE(0x0461, 0x0364) }, /* Scanworks 600U (repackaged Primax?) */ /* Medion */ { USB_DEVICE(0x0461, 0x0377) }, /* MD 5345 - repackaged Primax? */ /* Memorex */ { USB_DEVICE(0x0461, 0x0346) }, /* 6136u - repackaged Primax ? */ /* Microtek */ { USB_DEVICE(0x05da, 0x30ce) }, /* ScanMaker 3800 */ + { USB_DEVICE(0x05da, 0x30cf) }, /* ScanMaker 4800 */ /* The following SCSI-over-USB Microtek devices are supported by the microtek driver: Enable SCSI and USB Microtek in kernel config */ // { USB_DEVICE(0x05da, 0x0099) }, /* ScanMaker X6 - X6U */ @@ -259,7 +268,11 @@ { USB_DEVICE(0x04b8, 0x0802) }, /* Stylus CX3200 */ /* SYSCAN */ { USB_DEVICE(0x0a82, 0x4600) }, /* TravelScan 460/464 */ + /* Trust */ + { USB_DEVICE(0x05cb, 0x1483) }, /* CombiScan 19200 */ + { USB_DEVICE(0x05d8, 0x4006) }, /* Easy Webscan 19200 (repackaged Artec?) */ /* Umax */ + { USB_DEVICE(0x05d8, 0x4009) }, /* Astraslim (actually Artec?) */ { USB_DEVICE(0x1606, 0x0010) }, /* Astra 1220U */ { USB_DEVICE(0x1606, 0x0030) }, /* Astra 2000U */ { USB_DEVICE(0x1606, 0x0060) }, /* Astra 3400U/3450U */ diff -Nru a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c --- a/drivers/usb/input/hid-core.c Sun Mar 23 00:22:53 2003 +++ b/drivers/usb/input/hid-core.c Sun Mar 23 00:22:53 2003 @@ -1334,6 +1334,9 @@ #define USB_VENDOR_ID_TANGTOP 0x0d3d #define USB_DEVICE_ID_TANGTOP_USBPS2 0x0001 +#define USB_VENDOR_ID_ESSENTIAL_REALITY 0x0d7f +#define USB_DEVICE_ID_ESSENTIAL_REALITY_P5 0x0100 + struct hid_blacklist { __u16 idVendor; __u16 idProduct; @@ -1377,6 +1380,7 @@ { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 400, HID_QUIRK_IGNORE }, { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 500, HID_QUIRK_IGNORE }, { USB_VENDOR_ID_TANGTOP, USB_DEVICE_ID_TANGTOP_USBPS2, HID_QUIRK_NOGET }, + { USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5, HID_QUIRK_IGNORE }, { 0, 0 } }; diff -Nru a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile --- a/drivers/usb/misc/Makefile Sun Mar 23 00:22:53 2003 +++ b/drivers/usb/misc/Makefile Sun Mar 23 00:22:53 2003 @@ -12,5 +12,3 @@ obj-$(CONFIG_USB_TEST) += usbtest.o obj-$(CONFIG_USB_TIGL) += tiglusb.o obj-$(CONFIG_USB_USS720) += uss720.o - -speedtch-objs := speedtouch.o atmsar.o diff -Nru a/drivers/usb/misc/atmsar.c b/drivers/usb/misc/atmsar.c --- a/drivers/usb/misc/atmsar.c Sun Mar 23 00:22:51 2003 +++ /dev/null Wed Dec 31 16:00:00 1969 @@ -1,380 +0,0 @@ -/****************************************************************************** - * atmsar.c -- General SAR library for ATM devices. - * - * Copyright (C) 2000, Johan Verrept - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 - * Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - ******************************************************************************/ - -/* - * Written by Johan Verrept (Johan.Verrept@advalvas.be) - * - * 0.2.4A: - Version for inclusion in 2.5 series kernel - * - Modifications by Richard Purdie (rpurdie@rpsys.net) - * - replaced "sarlib" with "atmsar" - * - adaptations for inclusion in kernel tree - * - * 0.2.4: - Fixed wrong buffer overrun check in atmsar_decode_rawcell() - * reported by Stephen Robinson - * - Fixed bug when input skb did not contain a multple of 52/53 - * bytes (would happen when the speedtouch device resynced) - * also reported by Stephen Robinson - * - * 0.2.3: - Fixed wrong allocation size. caused memory corruption in some - * cases. Reported by Vladimir Dergachev - * - Added some comments - * - * 0.2.2: - Fixed CRCASM - * patch from Linus Flannagan - * - Fixed problem when user did NOT use the - * ATMSAR_USE_53BYTE_CELL flag. - * reported by Piers Scannell - * - No more in-buffer rewriting for cloned buffers. - * - Removed the PII specific CFLAGS in the Makefile. - * - * 0.2.1: - removed dependency on alloc_tx. tis presented problems when - * using this with the br2684 code. - * - * 0.2: - added AAL0 reassembly - * - added alloc_tx support - * - replaced alloc_skb in decode functions to dev_alloc_skb to - * allow calling from interrupt - * - fixed embarassing AAL5 bug. I was setting the pti bit in the - * wrong byte... - * - fixed another emabrassing bug.. picked up the wrong crc type - * and forgot to invert the crc result... - * - fixed AAL5 length calculations. - * - removed automatic skb freeing from encode functions. - * This caused problems because i did kfree_skb it, while it - * needed to be popped. I cannot determine though whether it - * needs to be popped or not. Figu'e it out ye'self ;-) - * - added mru field. This is the buffersize. atmsar_decode_aal0 - * will use when it allocates a receive buffer. A stop gap for - * real buffer management. - * - * 0.1: - library created. - * - only contains AAL5, AAL0 can be easily added. (actually, only - * AAL0 reassembly is missing) - * - */ - -#include -#include "atmsar.h" - -/*********************** - ** - ** things to remember - ** - ***********************/ - -/* - 1. the atmsar_vcc_data list pointer MUST be initialized to NULL - 2. atmsar_encode_rawcell will drop incomplete cells. - 3. ownership of the skb goes to the library ! -*/ - -#define ATM_HDR_VPVC_MASK (ATM_HDR_VPI_MASK | ATM_HDR_VCI_MASK) - -/*********************** - ** - ** LOCAL STRUCTURES - ** - ***********************/ - -/*********************** - ** - ** LOCAL MACROS - ** - ***********************/ -/* -#define DEBUG 1 -*/ -#ifdef DEBUG -#define PDEBUG(arg...) printk(KERN_DEBUG "atmsar: " arg) -#else -#define PDEBUG(arg...) -#endif - -#define ADD_HEADER(dest, header) \ - *dest++ = (unsigned char) (header >> 24); \ - *dest++ = (unsigned char) (header >> 16); \ - *dest++ = (unsigned char) (header >> 8); \ - *dest++ = (unsigned char) (header & 0xff); - - -struct atmsar_vcc_data *atmsar_open (struct atmsar_vcc_data **list, struct atm_vcc *vcc, uint type, - ushort vpi, ushort vci, unchar pti, unchar gfc, uint flags) -{ - struct atmsar_vcc_data *new; - - if (!vcc) - return NULL; - - new = kmalloc (sizeof (struct atmsar_vcc_data), GFP_KERNEL); - - if (!new) - return NULL; - - memset (new, 0, sizeof (struct atmsar_vcc_data)); - new->vcc = vcc; - new->stats = vcc->stats; - new->type = type; - new->next = NULL; - new->gfc = gfc; - new->vp = vpi; - new->vc = vci; - new->pti = pti; - - switch (type) { - case ATMSAR_TYPE_AAL0: - new->mtu = ATMSAR_DEF_MTU_AAL0; - break; - case ATMSAR_TYPE_AAL1: - new->mtu = ATMSAR_DEF_MTU_AAL1; - break; - case ATMSAR_TYPE_AAL2: - new->mtu = ATMSAR_DEF_MTU_AAL2; - break; - case ATMSAR_TYPE_AAL34: - /* not supported */ - new->mtu = ATMSAR_DEF_MTU_AAL34; - break; - case ATMSAR_TYPE_AAL5: - new->mtu = ATMSAR_DEF_MTU_AAL5; - break; - } - - new->atmHeader = ((unsigned long) gfc << ATM_HDR_GFC_SHIFT) - | ((unsigned long) vpi << ATM_HDR_VPI_SHIFT) - | ((unsigned long) vci << ATM_HDR_VCI_SHIFT) - | ((unsigned long) pti << ATM_HDR_PTI_SHIFT); - new->flags = flags; - new->next = NULL; - new->reasBuffer = NULL; - - new->next = *list; - *list = new; - - PDEBUG ("Allocated new SARLib vcc 0x%p with vp %d vc %d\n", new, vpi, vci); - - return new; -} - -void atmsar_close (struct atmsar_vcc_data **list, struct atmsar_vcc_data *vcc) -{ - struct atmsar_vcc_data *work; - - if (*list == vcc) { - *list = (*list)->next; - } else { - for (work = *list; work && work->next && (work->next != vcc); work = work->next); - - /* return if not found */ - if (work->next != vcc) - return; - - work->next = work->next->next; - } - - if (vcc->reasBuffer) { - dev_kfree_skb (vcc->reasBuffer); - } - - PDEBUG ("Allocated SARLib vcc 0x%p with vp %d vc %d\n", vcc, vcc->vp, vcc->vc); - - kfree (vcc); -} - - -/*********************** - ** - ** DECODE FUNCTIONS - ** - ***********************/ - -struct sk_buff *atmsar_decode_rawcell (struct atmsar_vcc_data *list, struct sk_buff *skb, - struct atmsar_vcc_data **ctx) -{ - while (skb->len) { - unsigned char *cell = skb->data; - unsigned char *cell_payload; - struct atmsar_vcc_data *vcc = list; - unsigned long atmHeader = - ((unsigned long) (cell[0]) << 24) | ((unsigned long) (cell[1]) << 16) | - ((unsigned long) (cell[2]) << 8) | (cell[3] & 0xff); - - PDEBUG ("atmsar_decode_rawcell (0x%p, 0x%p, 0x%p) called\n", list, skb, ctx); - PDEBUG ("atmsar_decode_rawcell skb->data %p, skb->tail %p\n", skb->data, skb->tail); - - if (!list || !skb || !ctx) - return NULL; - if (!skb->data || !skb->tail) - return NULL; - - /* here should the header CRC check be... */ - - /* look up correct vcc */ - for (; - vcc - && ((vcc->atmHeader & ATM_HDR_VPVC_MASK) != (atmHeader & ATM_HDR_VPVC_MASK)); - vcc = vcc->next); - - PDEBUG ("atmsar_decode_rawcell found vcc %p for packet on vp %d, vc %d\n", vcc, - (int) ((atmHeader & ATM_HDR_VPI_MASK) >> ATM_HDR_VPI_SHIFT), - (int) ((atmHeader & ATM_HDR_VCI_MASK) >> ATM_HDR_VCI_SHIFT)); - - if (vcc && (skb->len >= (vcc->flags & ATMSAR_USE_53BYTE_CELL ? 53 : 52))) { - cell_payload = cell + (vcc->flags & ATMSAR_USE_53BYTE_CELL ? 5 : 4); - - switch (vcc->type) { - case ATMSAR_TYPE_AAL0: - /* case ATMSAR_TYPE_AAL1: when we have a decode AAL1 function... */ - { - struct sk_buff *tmp = dev_alloc_skb (vcc->mtu); - - if (tmp) { - memcpy (tmp->tail, cell_payload, 48); - skb_put (tmp, 48); - - if (vcc->stats) - atomic_inc (&vcc->stats->rx); - - skb_pull (skb, - (vcc-> - flags & ATMSAR_USE_53BYTE_CELL ? 53 : - 52)); - PDEBUG - ("atmsar_decode_rawcell returns ATMSAR_TYPE_AAL0 pdu 0x%p with length %d\n", - tmp, tmp->len); - return tmp; - }; - } - break; - case ATMSAR_TYPE_AAL1: - case ATMSAR_TYPE_AAL2: - case ATMSAR_TYPE_AAL34: - /* not supported */ - break; - case ATMSAR_TYPE_AAL5: - if (!vcc->reasBuffer) - vcc->reasBuffer = dev_alloc_skb (vcc->mtu); - - /* if alloc fails, we just drop the cell. it is possible that we can still - * receive cells on other vcc's - */ - if (vcc->reasBuffer) { - /* if (buffer overrun) discard received cells until now */ - if ((vcc->reasBuffer->len) > (vcc->mtu - 48)) - skb_trim (vcc->reasBuffer, 0); - - /* copy data */ - memcpy (vcc->reasBuffer->tail, cell_payload, 48); - skb_put (vcc->reasBuffer, 48); - - /* check for end of buffer */ - if (cell[3] & 0x2) { - struct sk_buff *tmp; - - /* the aal5 buffer ends here, cut the buffer. */ - /* buffer will always have at least one whole cell, so */ - /* don't need to check return from skb_pull */ - skb_pull (skb, - (vcc-> - flags & ATMSAR_USE_53BYTE_CELL ? 53 : - 52)); - *ctx = vcc; - tmp = vcc->reasBuffer; - vcc->reasBuffer = NULL; - - PDEBUG - ("atmsar_decode_rawcell returns ATMSAR_TYPE_AAL5 pdu 0x%p with length %d\n", - tmp, tmp->len); - return tmp; - } - } - break; - }; - /* flush the cell */ - /* buffer will always contain at least one whole cell, so don't */ - /* need to check return value from skb_pull */ - skb_pull (skb, (vcc->flags & ATMSAR_USE_53BYTE_CELL ? 53 : 52)); - } else { - /* If data is corrupt and skb doesn't hold a whole cell, flush the lot */ - if (skb_pull (skb, (list->flags & ATMSAR_USE_53BYTE_CELL ? 53 : 52)) == - NULL) - return NULL; - } - } - - return NULL; -}; - -struct sk_buff *atmsar_decode_aal5 (struct atmsar_vcc_data *ctx, struct sk_buff *skb) -{ - uint crc = 0xffffffff; - uint length, pdu_crc, pdu_length; - - PDEBUG ("atmsar_decode_aal5 (0x%p, 0x%p) called\n", ctx, skb); - - if (skb->len && (skb->len % 48)) - return NULL; - - length = (skb->tail[-6] << 8) + skb->tail[-5]; - pdu_crc = - (skb->tail[-4] << 24) + (skb->tail[-3] << 16) + (skb->tail[-2] << 8) + skb->tail[-1]; - pdu_length = ((length + 47 + 8) / 48) * 48; - - PDEBUG ("atmsar_decode_aal5: skb->len = %d, length = %d, pdu_crc = 0x%x, pdu_length = %d\n", - skb->len, length, pdu_crc, pdu_length); - - /* is skb long enough ? */ - if (skb->len < pdu_length) { - if (ctx->stats) - atomic_inc (&ctx->stats->rx_err); - return NULL; - } - - /* is skb too long ? */ - if (skb->len > pdu_length) { - PDEBUG ("atmsar_decode_aal5: Warning: readjusting illeagl size %d -> %d\n", - skb->len, pdu_length); - /* buffer is too long. we can try to recover - * if we discard the first part of the skb. - * the crc will decide whether this was ok - */ - skb_pull (skb, skb->len - pdu_length); - } - - crc = ~crc32_be (crc, skb->data, pdu_length - 4); - - /* check crc */ - if (pdu_crc != crc) { - PDEBUG ("atmsar_decode_aal5: crc check failed!\n"); - if (ctx->stats) - atomic_inc (&ctx->stats->rx_err); - return NULL; - } - - /* pdu is ok */ - skb_trim (skb, length); - - /* update stats */ - if (ctx->stats) - atomic_inc (&ctx->stats->rx); - - PDEBUG ("atmsar_decode_aal5 returns pdu 0x%p with length %d\n", skb, skb->len); - return skb; -}; diff -Nru a/drivers/usb/misc/atmsar.h b/drivers/usb/misc/atmsar.h --- a/drivers/usb/misc/atmsar.h Sun Mar 23 00:22:52 2003 +++ /dev/null Wed Dec 31 16:00:00 1969 @@ -1,87 +0,0 @@ -#ifndef _ATMSAR_H_ -#define _ATMSAR_H_ - -/****************************************************************************** - * atmsar.h -- General SAR library for ATM devices. - * - * Copyright (C) 2000, Johan Verrept - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 - * Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - ******************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include - -#define ATMSAR_USE_53BYTE_CELL 0x1L -#define ATMSAR_SET_PTI 0x2L - -#define ATM_CELL_HEADER (ATM_CELL_SIZE - ATM_CELL_PAYLOAD) - -/* types */ -#define ATMSAR_TYPE_AAL0 ATM_AAL0 -#define ATMSAR_TYPE_AAL1 ATM_AAL1 -#define ATMSAR_TYPE_AAL2 ATM_AAL2 -#define ATMSAR_TYPE_AAL34 ATM_AAL34 -#define ATMSAR_TYPE_AAL5 ATM_AAL5 - - -/* default MTU's */ -#define ATMSAR_DEF_MTU_AAL0 48 -#define ATMSAR_DEF_MTU_AAL1 47 -#define ATMSAR_DEF_MTU_AAL2 0 /* not supported */ -#define ATMSAR_DEF_MTU_AAL34 0 /* not supported */ -#define ATMSAR_DEF_MTU_AAL5 65535 /* max mtu .. */ - -struct atmsar_vcc_data { - struct atmsar_vcc_data *next; - - /* general atmsar flags, per connection */ - int flags; - int type; - - /* connection specific non-atmsar data */ - struct atm_vcc *vcc; - struct k_atm_aal_stats *stats; - unsigned short mtu; /* max is actually 65k for AAL5... */ - - /* cell data */ - unsigned int vp; - unsigned int vc; - unsigned char gfc; - unsigned char pti; - unsigned int headerFlags; - unsigned long atmHeader; - - /* raw cell reassembly */ - struct sk_buff *reasBuffer; -}; - - -extern struct atmsar_vcc_data *atmsar_open (struct atmsar_vcc_data **list, struct atm_vcc *vcc, - uint type, ushort vpi, ushort vci, unchar pti, - unchar gfc, uint flags); -extern void atmsar_close (struct atmsar_vcc_data **list, struct atmsar_vcc_data *vcc); - -struct sk_buff *atmsar_decode_rawcell (struct atmsar_vcc_data *list, struct sk_buff *skb, - struct atmsar_vcc_data **ctx); -struct sk_buff *atmsar_decode_aal5 (struct atmsar_vcc_data *ctx, struct sk_buff *skb); - -#endif /* _ATMSAR_H_ */ diff -Nru a/drivers/usb/misc/speedtch.c b/drivers/usb/misc/speedtch.c --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/drivers/usb/misc/speedtch.c Sun Mar 23 00:22:56 2003 @@ -0,0 +1,1514 @@ +/****************************************************************************** + * speedtouch.c -- Alcatel SpeedTouch USB xDSL modem driver. + * + * Copyright (C) 2001, Alcatel + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 59 + * Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + ******************************************************************************/ + +/* + * Written by Johan Verrept (Johan.Verrept@advalvas.be) + * + * 1.5A: - Version for inclusion in 2.5 series kernel + * - Modifications by Richard Purdie (rpurdie@rpsys.net) + * - made compatible with kernel 2.5.6 onwards by changing + * udsl_usb_send_data_context->urb to a pointer and adding code + * to alloc and free it + * - remove_wait_queue() added to udsl_atm_processqueue_thread() + * + * 1.5: - fixed memory leak when atmsar_decode_aal5 returned NULL. + * (reported by stephen.robinson@zen.co.uk) + * + * 1.4: - changed the spin_lock() under interrupt to spin_lock_irqsave() + * - unlink all active send urbs of a vcc that is being closed. + * + * 1.3.1: - added the version number + * + * 1.3: - Added multiple send urb support + * - fixed memory leak and vcc->tx_inuse starvation bug + * when not enough memory left in vcc. + * + * 1.2: - Fixed race condition in udsl_usb_send_data() + * 1.1: - Turned off packet debugging + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* +#define DEBUG 1 +#define DEBUG_PACKET 1 +*/ + +#include + + +#ifdef DEBUG_PACKET +static int udsl_print_packet (const unsigned char *data, int len); +#define PACKETDEBUG(arg...) udsl_print_packet (arg) +#else +#define PACKETDEBUG(arg...) +#endif + +#define DRIVER_AUTHOR "Johan Verrept, Johan.Verrept@advalvas.be" +#define DRIVER_DESC "Driver for the Alcatel SpeedTouch USB ADSL modem" +#define DRIVER_VERSION "1.5A" + +#define SPEEDTOUCH_VENDORID 0x06b9 +#define SPEEDTOUCH_PRODUCTID 0x4061 + +#define UDSL_NUMBER_RCV_URBS 1 +#define UDSL_NUMBER_SND_URBS 1 +#define UDSL_NUMBER_SND_BUFS (2*UDSL_NUMBER_SND_URBS) +#define UDSL_RCV_BUFFER_SIZE (1*64) /* ATM cells */ +#define UDSL_SND_BUFFER_SIZE (1*64) /* ATM cells */ +/* max should be (1500 IP mtu + 2 ppp bytes + 32 * 5 cellheader overhead) for + * PPPoA and (1500 + 14 + 32*5 cellheader overhead) for PPPoE */ +#define UDSL_MAX_AAL5_MRU 2048 + +#define UDSL_IOCTL_START 1 +#define UDSL_IOCTL_STOP 2 + +/* endpoint declarations */ + +#define UDSL_ENDPOINT_DATA_OUT 0x07 +#define UDSL_ENDPOINT_DATA_IN 0x87 + +#define ATM_CELL_HEADER (ATM_CELL_SIZE - ATM_CELL_PAYLOAD) + +#define hex2int(c) ( (c >= '0')&&(c <= '9') ? (c - '0') : ((c & 0xf)+9) ) + +/* usb_device_id struct */ + +static struct usb_device_id udsl_usb_ids [] = { + { USB_DEVICE (SPEEDTOUCH_VENDORID, SPEEDTOUCH_PRODUCTID) }, + { } /* Terminating entry */ +}; + +MODULE_DEVICE_TABLE (usb, udsl_usb_ids); + +/* context declarations */ + +struct udsl_receiver { + struct list_head list; + struct sk_buff *skb; + struct urb *urb; + struct udsl_instance_data *instance; +}; + +struct udsl_send_buffer { + struct list_head list; + unsigned char *base; + unsigned char *free_start; + unsigned int free_cells; +}; + +struct udsl_sender { + struct list_head list; + struct udsl_send_buffer *buffer; + struct urb *urb; + struct udsl_instance_data *instance; +}; + +struct udsl_control { + struct atm_skb_data atm_data; + unsigned int num_cells; + unsigned int num_entire; + unsigned char cell_header [ATM_CELL_HEADER]; + unsigned int pdu_padding; + unsigned char aal5_trailer [ATM_AAL5_TRAILER]; +}; + +#define UDSL_SKB(x) ((struct udsl_control *)(x)->cb) + +struct atmsar_vcc_data { + struct atmsar_vcc_data *next; + + /* general atmsar flags, per connection */ + int flags; + int type; + + /* connection specific non-atmsar data */ + struct atm_vcc *vcc; + struct k_atm_aal_stats *stats; + unsigned short mtu; /* max is actually 65k for AAL5... */ + + /* cell data */ + unsigned int vp; + unsigned int vc; + unsigned char gfc; + unsigned char pti; + unsigned int headerFlags; + unsigned long atmHeader; + + /* raw cell reassembly */ + struct sk_buff *reasBuffer; +}; + +/* + * UDSL main driver data + */ + +struct udsl_instance_data { + struct semaphore serialize; + + /* usb device part */ + struct usb_device *usb_dev; + char description [64]; + int firmware_loaded; + + /* atm device part */ + struct atm_dev *atm_dev; + struct atmsar_vcc_data *atmsar_vcc_list; + + /* receiving */ + struct udsl_receiver all_receivers [UDSL_NUMBER_RCV_URBS]; + + spinlock_t spare_receivers_lock; + struct list_head spare_receivers; + + spinlock_t completed_receivers_lock; + struct list_head completed_receivers; + + struct tasklet_struct receive_tasklet; + + /* sending */ + struct udsl_sender all_senders [UDSL_NUMBER_SND_URBS]; + struct udsl_send_buffer all_buffers [UDSL_NUMBER_SND_BUFS]; + + struct sk_buff_head sndqueue; + + spinlock_t send_lock; + struct list_head spare_senders; + struct list_head spare_buffers; + + struct tasklet_struct send_tasklet; + struct sk_buff *current_skb; /* being emptied */ + struct udsl_send_buffer *current_buffer; /* being filled */ + struct list_head filled_buffers; +}; + +static const char udsl_driver_name [] = "speedtch"; + +/* + * atm driver prototypes and structures + */ + +static void udsl_atm_dev_close (struct atm_dev *dev); +static int udsl_atm_open (struct atm_vcc *vcc, short vpi, int vci); +static void udsl_atm_close (struct atm_vcc *vcc); +static int udsl_atm_ioctl (struct atm_dev *dev, unsigned int cmd, void *arg); +static int udsl_atm_send (struct atm_vcc *vcc, struct sk_buff *skb); +static int udsl_atm_proc_read (struct atm_dev *atm_dev, loff_t *pos, char *page); + +static struct atmdev_ops udsl_atm_devops = { + .dev_close = udsl_atm_dev_close, + .open = udsl_atm_open, + .close = udsl_atm_close, + .ioctl = udsl_atm_ioctl, + .send = udsl_atm_send, + .proc_read = udsl_atm_proc_read, +}; + +/* + * usb driver prototypes and structures + */ +static int udsl_usb_probe (struct usb_interface *intf, + const struct usb_device_id *id); +static void udsl_usb_disconnect (struct usb_interface *intf); +static int udsl_usb_ioctl (struct usb_interface *intf, unsigned int code, void *user_data); + +static struct usb_driver udsl_usb_driver = { + .name = udsl_driver_name, + .probe = udsl_usb_probe, + .disconnect = udsl_usb_disconnect, + .ioctl = udsl_usb_ioctl, + .id_table = udsl_usb_ids, +}; + + +/************* +** decode ** +*************/ + +#define ATM_HDR_VPVC_MASK (ATM_HDR_VPI_MASK | ATM_HDR_VCI_MASK) +#define ATMSAR_USE_53BYTE_CELL 0x1L + +struct sk_buff *atmsar_decode_rawcell (struct atmsar_vcc_data *list, struct sk_buff *skb, + struct atmsar_vcc_data **ctx) +{ + while (skb->len) { + unsigned char *cell = skb->data; + unsigned char *cell_payload; + struct atmsar_vcc_data *vcc = list; + unsigned long atmHeader = + ((unsigned long) (cell[0]) << 24) | ((unsigned long) (cell[1]) << 16) | + ((unsigned long) (cell[2]) << 8) | (cell[3] & 0xff); + + dbg ("atmsar_decode_rawcell (0x%p, 0x%p, 0x%p) called", list, skb, ctx); + dbg ("atmsar_decode_rawcell skb->data %p, skb->tail %p", skb->data, skb->tail); + + if (!list || !skb || !ctx) + return NULL; + if (!skb->data || !skb->tail) + return NULL; + + /* here should the header CRC check be... */ + + /* look up correct vcc */ + for (; + vcc + && ((vcc->atmHeader & ATM_HDR_VPVC_MASK) != (atmHeader & ATM_HDR_VPVC_MASK)); + vcc = vcc->next); + + dbg ("atmsar_decode_rawcell found vcc %p for packet on vp %d, vc %d", vcc, + (int) ((atmHeader & ATM_HDR_VPI_MASK) >> ATM_HDR_VPI_SHIFT), + (int) ((atmHeader & ATM_HDR_VCI_MASK) >> ATM_HDR_VCI_SHIFT)); + + if (vcc && (skb->len >= (vcc->flags & ATMSAR_USE_53BYTE_CELL ? 53 : 52))) { + cell_payload = cell + (vcc->flags & ATMSAR_USE_53BYTE_CELL ? 5 : 4); + + switch (vcc->type) { + case ATM_AAL0: + /* case ATM_AAL1: when we have a decode AAL1 function... */ + { + struct sk_buff *tmp = dev_alloc_skb (vcc->mtu); + + if (tmp) { + memcpy (tmp->tail, cell_payload, 48); + skb_put (tmp, 48); + + if (vcc->stats) + atomic_inc (&vcc->stats->rx); + + skb_pull (skb, + (vcc-> + flags & ATMSAR_USE_53BYTE_CELL ? 53 : + 52)); + dbg + ("atmsar_decode_rawcell returns ATM_AAL0 pdu 0x%p with length %d", + tmp, tmp->len); + return tmp; + }; + } + break; + case ATM_AAL1: + case ATM_AAL2: + case ATM_AAL34: + /* not supported */ + break; + case ATM_AAL5: + if (!vcc->reasBuffer) + vcc->reasBuffer = dev_alloc_skb (vcc->mtu); + + /* if alloc fails, we just drop the cell. it is possible that we can still + * receive cells on other vcc's + */ + if (vcc->reasBuffer) { + /* if (buffer overrun) discard received cells until now */ + if ((vcc->reasBuffer->len) > (vcc->mtu - 48)) + skb_trim (vcc->reasBuffer, 0); + + /* copy data */ + memcpy (vcc->reasBuffer->tail, cell_payload, 48); + skb_put (vcc->reasBuffer, 48); + + /* check for end of buffer */ + if (cell[3] & 0x2) { + struct sk_buff *tmp; + + /* the aal5 buffer ends here, cut the buffer. */ + /* buffer will always have at least one whole cell, so */ + /* don't need to check return from skb_pull */ + skb_pull (skb, + (vcc-> + flags & ATMSAR_USE_53BYTE_CELL ? 53 : + 52)); + *ctx = vcc; + tmp = vcc->reasBuffer; + vcc->reasBuffer = NULL; + + dbg + ("atmsar_decode_rawcell returns ATM_AAL5 pdu 0x%p with length %d", + tmp, tmp->len); + return tmp; + } + } + break; + }; + /* flush the cell */ + /* buffer will always contain at least one whole cell, so don't */ + /* need to check return value from skb_pull */ + skb_pull (skb, (vcc->flags & ATMSAR_USE_53BYTE_CELL ? 53 : 52)); + } else { + /* If data is corrupt and skb doesn't hold a whole cell, flush the lot */ + if (skb_pull (skb, (list->flags & ATMSAR_USE_53BYTE_CELL ? 53 : 52)) == + NULL) + return NULL; + } + } + + return NULL; +}; + +struct sk_buff *atmsar_decode_aal5 (struct atmsar_vcc_data *ctx, struct sk_buff *skb) +{ + uint crc = 0xffffffff; + uint length, pdu_crc, pdu_length; + + dbg ("atmsar_decode_aal5 (0x%p, 0x%p) called", ctx, skb); + + if (skb->len && (skb->len % 48)) + return NULL; + + length = (skb->tail[-6] << 8) + skb->tail[-5]; + pdu_crc = + (skb->tail[-4] << 24) + (skb->tail[-3] << 16) + (skb->tail[-2] << 8) + skb->tail[-1]; + pdu_length = ((length + 47 + 8) / 48) * 48; + + dbg ("atmsar_decode_aal5: skb->len = %d, length = %d, pdu_crc = 0x%x, pdu_length = %d", + skb->len, length, pdu_crc, pdu_length); + + /* is skb long enough ? */ + if (skb->len < pdu_length) { + if (ctx->stats) + atomic_inc (&ctx->stats->rx_err); + return NULL; + } + + /* is skb too long ? */ + if (skb->len > pdu_length) { + dbg ("atmsar_decode_aal5: Warning: readjusting illeagl size %d -> %d", + skb->len, pdu_length); + /* buffer is too long. we can try to recover + * if we discard the first part of the skb. + * the crc will decide whether this was ok + */ + skb_pull (skb, skb->len - pdu_length); + } + + crc = ~crc32_be (crc, skb->data, pdu_length - 4); + + /* check crc */ + if (pdu_crc != crc) { + dbg ("atmsar_decode_aal5: crc check failed!"); + if (ctx->stats) + atomic_inc (&ctx->stats->rx_err); + return NULL; + } + + /* pdu is ok */ + skb_trim (skb, length); + + /* update stats */ + if (ctx->stats) + atomic_inc (&ctx->stats->rx); + + dbg ("atmsar_decode_aal5 returns pdu 0x%p with length %d", skb, skb->len); + return skb; +}; + + +/************* +** encode ** +*************/ + +static void udsl_groom_skb (struct atm_vcc *vcc, struct sk_buff *skb) { + struct udsl_control *ctrl = UDSL_SKB (skb); + unsigned int i, zero_padding; + unsigned char zero = 0; + u32 crc; + + ctrl->atm_data.vcc = vcc; + ctrl->cell_header [0] = vcc->vpi >> 4; + ctrl->cell_header [1] = (vcc->vpi << 4) | (vcc->vci >> 12); + ctrl->cell_header [2] = vcc->vci >> 4; + ctrl->cell_header [3] = vcc->vci << 4; + ctrl->cell_header [4] = 0xec; + + ctrl->num_cells = (skb->len + ATM_AAL5_TRAILER + ATM_CELL_PAYLOAD - 1) / ATM_CELL_PAYLOAD; + ctrl->num_entire = skb->len / ATM_CELL_PAYLOAD; + + zero_padding = ctrl->num_cells * ATM_CELL_PAYLOAD - skb->len - ATM_AAL5_TRAILER; + + if (ctrl->num_entire + 1 < ctrl->num_cells) + ctrl->pdu_padding = zero_padding - (ATM_CELL_PAYLOAD - ATM_AAL5_TRAILER); + else + ctrl->pdu_padding = zero_padding; + + ctrl->aal5_trailer [0] = 0; /* UU = 0 */ + ctrl->aal5_trailer [1] = 0; /* CPI = 0 */ + ctrl->aal5_trailer [2] = skb->len >> 8; + ctrl->aal5_trailer [3] = skb->len; + + crc = crc32_be (~0, skb->data, skb->len); + for (i = 0; i < zero_padding; i++) + crc = crc32_be (crc, &zero, 1); + crc = crc32_be (crc, ctrl->aal5_trailer, 4); + crc = ~crc; + + ctrl->aal5_trailer [4] = crc >> 24; + ctrl->aal5_trailer [5] = crc >> 16; + ctrl->aal5_trailer [6] = crc >> 8; + ctrl->aal5_trailer [7] = crc; +} + +unsigned int udsl_write_cells (unsigned int howmany, struct sk_buff *skb, unsigned char **target_p) { + struct udsl_control *ctrl = UDSL_SKB (skb); + unsigned char *target = *target_p; + unsigned int nc, ne, i; + + dbg ("udsl_write_cells: howmany=%u, skb->len=%d, num_cells=%u, num_entire=%u, pdu_padding=%u", howmany, skb->len, ctrl->num_cells, ctrl->num_entire, ctrl->pdu_padding); + + nc = ctrl->num_cells; + ne = min (howmany, ctrl->num_entire); + + for (i = 0; i < ne; i++) { + memcpy (target, ctrl->cell_header, ATM_CELL_HEADER); + target += ATM_CELL_HEADER; + memcpy (target, skb->data, ATM_CELL_PAYLOAD); + target += ATM_CELL_PAYLOAD; + __skb_pull (skb, ATM_CELL_PAYLOAD); + } + + ctrl->num_entire -= ne; + + if (!(ctrl->num_cells -= ne) || !(howmany -= ne)) + goto out; + + memcpy (target, ctrl->cell_header, ATM_CELL_HEADER); + target += ATM_CELL_HEADER; + memcpy (target, skb->data, skb->len); + target += skb->len; + __skb_pull (skb, skb->len); + memset (target, 0, ctrl->pdu_padding); + target += ctrl->pdu_padding; + + if (--ctrl->num_cells) { + if (!--howmany) { + ctrl->pdu_padding = ATM_CELL_PAYLOAD - ATM_AAL5_TRAILER; + goto out; + } + + memcpy (target, ctrl->cell_header, ATM_CELL_HEADER); + target += ATM_CELL_HEADER; + memset (target, 0, ATM_CELL_PAYLOAD - ATM_AAL5_TRAILER); + target += ATM_CELL_PAYLOAD - ATM_AAL5_TRAILER; + + if (--ctrl->num_cells) + BUG(); + } + + memcpy (target, ctrl->aal5_trailer, ATM_AAL5_TRAILER); + target += ATM_AAL5_TRAILER; + /* set pti bit in last cell */ + *(target + 3 - ATM_CELL_SIZE) |= 0x2; + +out: + *target_p = target; + return nc - ctrl->num_cells; +} + + +/************** +** receive ** +**************/ + +static void udsl_complete_receive (struct urb *urb, struct pt_regs *regs) +{ + struct udsl_instance_data *instance; + struct udsl_receiver *rcv; + unsigned long flags; + + if (!urb || !(rcv = urb->context) || !(instance = rcv->instance)) { + dbg ("udsl_complete_receive: bad urb!"); + return; + } + + dbg ("udsl_complete_receive entered (urb 0x%p, status %d)", urb, urb->status); + + /* may not be in_interrupt() */ + spin_lock_irqsave (&instance->completed_receivers_lock, flags); + list_add_tail (&rcv->list, &instance->completed_receivers); + tasklet_schedule (&instance->receive_tasklet); + spin_unlock_irqrestore (&instance->completed_receivers_lock, flags); +} + +static void udsl_process_receive (unsigned long data) +{ + struct udsl_instance_data *instance = (struct udsl_instance_data *) data; + struct udsl_receiver *rcv; + unsigned long flags; + unsigned char *data_start; + struct sk_buff *skb; + struct urb *urb; + struct atmsar_vcc_data *atmsar_vcc = NULL; + struct sk_buff *new = NULL, *tmp = NULL; + int err; + + dbg ("udsl_process_receive entered"); + + spin_lock_irqsave (&instance->completed_receivers_lock, flags); + while (!list_empty (&instance->completed_receivers)) { + rcv = list_entry (instance->completed_receivers.next, struct udsl_receiver, list); + list_del (&rcv->list); + spin_unlock_irqrestore (&instance->completed_receivers_lock, flags); + + urb = rcv->urb; + dbg ("udsl_process_receive: got packet %p with length %d and status %d", urb, urb->actual_length, urb->status); + + switch (urb->status) { + case 0: + dbg ("udsl_process_receive: processing urb with rcv %p, urb %p, skb %p", rcv, urb, rcv->skb); + + /* update the skb structure */ + skb = rcv->skb; + skb_trim (skb, 0); + skb_put (skb, urb->actual_length); + data_start = skb->data; + + dbg ("skb->len = %d", skb->len); + PACKETDEBUG (skb->data, skb->len); + + while ((new = + atmsar_decode_rawcell (instance->atmsar_vcc_list, skb, + &atmsar_vcc)) != NULL) { + dbg ("(after cell processing)skb->len = %d", new->len); + + switch (atmsar_vcc->type) { + case ATM_AAL5: + tmp = new; + new = atmsar_decode_aal5 (atmsar_vcc, new); + + /* we can't send NULL skbs upstream, the ATM layer would try to close the vcc... */ + if (new) { + dbg ("(after aal5 decap) skb->len = %d", new->len); + if (new->len && atm_charge (atmsar_vcc->vcc, new->truesize)) { + PACKETDEBUG (new->data, new->len); + atmsar_vcc->vcc->push (atmsar_vcc->vcc, new); + } else { + dbg + ("dropping incoming packet : rx_inuse = %d, vcc->sk->rcvbuf = %d, skb->true_size = %d", + atomic_read (&atmsar_vcc->vcc->rx_inuse), + atmsar_vcc->vcc->sk->rcvbuf, new->truesize); + dev_kfree_skb (new); + } + } else { + dbg ("atmsar_decode_aal5 returned NULL!"); + dev_kfree_skb (tmp); + } + break; + default: + /* not supported. we delete the skb. */ + printk (KERN_INFO + "SpeedTouch USB: illegal vcc type. Dropping packet.\n"); + dev_kfree_skb (new); + break; + } + } + + /* restore skb */ + skb_push (skb, skb->data - data_start); + + usb_fill_bulk_urb (urb, + instance->usb_dev, + usb_rcvbulkpipe (instance->usb_dev, UDSL_ENDPOINT_DATA_IN), + (unsigned char *) rcv->skb->data, + UDSL_RCV_BUFFER_SIZE * ATM_CELL_SIZE, + udsl_complete_receive, + rcv); + if (!(err = usb_submit_urb (urb, GFP_ATOMIC))) + break; + dbg ("udsl_process_receive: submission failed (%d)", err); + /* fall through */ + default: /* error or urb unlinked */ + dbg ("udsl_process_receive: adding to spare_receivers"); + spin_lock_irqsave (&instance->spare_receivers_lock, flags); + list_add (&rcv->list, &instance->spare_receivers); + spin_unlock_irqrestore (&instance->spare_receivers_lock, flags); + break; + } /* switch */ + + spin_lock_irqsave (&instance->completed_receivers_lock, flags); + } /* while */ + spin_unlock_irqrestore (&instance->completed_receivers_lock, flags); + dbg ("udsl_process_receive successful"); +} + +static void udsl_fire_receivers (struct udsl_instance_data *instance) +{ + struct list_head receivers, *pos, *n; + unsigned long flags; + + INIT_LIST_HEAD (&receivers); + + down (&instance->serialize); + + spin_lock_irqsave (&instance->spare_receivers_lock, flags); + list_splice_init (&instance->spare_receivers, &receivers); + spin_unlock_irqrestore (&instance->spare_receivers_lock, flags); + + list_for_each_safe (pos, n, &receivers) { + struct udsl_receiver *rcv = list_entry (pos, struct udsl_receiver, list); + + dbg ("udsl_fire_receivers: firing urb %p", rcv->urb); + + usb_fill_bulk_urb (rcv->urb, + instance->usb_dev, + usb_rcvbulkpipe (instance->usb_dev, UDSL_ENDPOINT_DATA_IN), + (unsigned char *) rcv->skb->data, + UDSL_RCV_BUFFER_SIZE * ATM_CELL_SIZE, + udsl_complete_receive, + rcv); + + if (usb_submit_urb (rcv->urb, GFP_KERNEL) < 0) { + dbg ("udsl_fire_receivers: submit failed!"); + spin_lock_irqsave (&instance->spare_receivers_lock, flags); + list_move (pos, &instance->spare_receivers); + spin_unlock_irqrestore (&instance->spare_receivers_lock, flags); + } + } + + up (&instance->serialize); +} + + +/*********** +** send ** +***********/ + +static void udsl_complete_send (struct urb *urb, struct pt_regs *regs) +{ + struct udsl_instance_data *instance; + struct udsl_sender *snd; + unsigned long flags; + + if (!urb || !(snd = urb->context) || !(instance = snd->instance)) { + dbg ("udsl_complete_send: bad urb!"); + return; + } + + dbg ("udsl_complete_send entered (urb 0x%p, status %d)", urb, urb->status); + + /* may not be in_interrupt() */ + spin_lock_irqsave (&instance->send_lock, flags); + list_add (&snd->list, &instance->spare_senders); + list_add (&snd->buffer->list, &instance->spare_buffers); + tasklet_schedule (&instance->send_tasklet); + spin_unlock_irqrestore (&instance->send_lock, flags); +} + +static void udsl_process_send (unsigned long data) +{ + struct udsl_send_buffer *buf; + int err; + unsigned long flags; + struct udsl_instance_data *instance = (struct udsl_instance_data *) data; + unsigned int num_written; + struct sk_buff *skb; + struct udsl_sender *snd; + + dbg ("udsl_process_send entered"); + +made_progress: + spin_lock_irqsave (&instance->send_lock, flags); + while (!list_empty (&instance->spare_senders)) { + if (!list_empty (&instance->filled_buffers)) { + buf = list_entry (instance->filled_buffers.next, struct udsl_send_buffer, list); + list_del (&buf->list); + dbg ("sending filled buffer (0x%p)", buf); + } else if ((buf = instance->current_buffer)) { + instance->current_buffer = NULL; + dbg ("sending current buffer (0x%p)", buf); + } else /* all buffers empty */ + break; + + snd = list_entry (instance->spare_senders.next, struct udsl_sender, list); + list_del (&snd->list); + spin_unlock_irqrestore (&instance->send_lock, flags); + + snd->buffer = buf; + usb_fill_bulk_urb (snd->urb, + instance->usb_dev, + usb_sndbulkpipe (instance->usb_dev, UDSL_ENDPOINT_DATA_OUT), + buf->base, + (UDSL_SND_BUFFER_SIZE - buf->free_cells) * ATM_CELL_SIZE, + udsl_complete_send, + snd); + + dbg ("submitting urb 0x%p, contains %d cells", snd->urb, UDSL_SND_BUFFER_SIZE - buf->free_cells); + + if ((err = usb_submit_urb(snd->urb, GFP_ATOMIC)) < 0) { + dbg ("submission failed (%d)!", err); + spin_lock_irqsave (&instance->send_lock, flags); + list_add (&snd->list, &instance->spare_senders); + spin_unlock_irqrestore (&instance->send_lock, flags); + list_add (&buf->list, &instance->filled_buffers); + return; + } + + spin_lock_irqsave (&instance->send_lock, flags); + } /* while */ + spin_unlock_irqrestore (&instance->send_lock, flags); + + if (!instance->current_skb && !(instance->current_skb = skb_dequeue (&instance->sndqueue))) { + dbg ("done - no more skbs"); + return; + } + + skb = instance->current_skb; + + if (!(buf = instance->current_buffer)) { + spin_lock_irqsave (&instance->send_lock, flags); + if (list_empty (&instance->spare_buffers)) { + instance->current_buffer = NULL; + spin_unlock_irqrestore (&instance->send_lock, flags); + dbg ("done - no more buffers"); + return; + } + buf = list_entry (instance->spare_buffers.next, struct udsl_send_buffer, list); + list_del (&buf->list); + spin_unlock_irqrestore (&instance->send_lock, flags); + + buf->free_start = buf->base; + buf->free_cells = UDSL_SND_BUFFER_SIZE; + + instance->current_buffer = buf; + } + + num_written = udsl_write_cells (buf->free_cells, skb, &buf->free_start); + + dbg ("wrote %u cells from skb 0x%p to buffer 0x%p", num_written, skb, buf); + + if (!(buf->free_cells -= num_written)) { + list_add_tail (&buf->list, &instance->filled_buffers); + instance->current_buffer = NULL; + dbg ("queued filled buffer"); + } + + dbg ("buffer contains %d cells, %d left", UDSL_SND_BUFFER_SIZE - buf->free_cells, buf->free_cells); + + if (!UDSL_SKB (skb)->num_cells) { + struct atm_vcc *vcc = UDSL_SKB (skb)->atm_data.vcc; + + dbg ("discarding empty skb"); + if (vcc->pop) + vcc->pop (vcc, skb); + else + kfree_skb (skb); + instance->current_skb = NULL; + + if (vcc->stats) + atomic_inc (&vcc->stats->tx); + } + + goto made_progress; +} + +static void udsl_cancel_send (struct udsl_instance_data *instance, struct atm_vcc *vcc) +{ + unsigned long flags; + struct sk_buff *skb, *n; + + dbg ("udsl_cancel_send entered"); + spin_lock_irqsave (&instance->sndqueue.lock, flags); + for (skb = instance->sndqueue.next, n = skb->next; skb != (struct sk_buff *)&instance->sndqueue; skb = n, n = skb->next) + if (UDSL_SKB (skb)->atm_data.vcc == vcc) { + dbg ("popping skb 0x%p", skb); + __skb_unlink (skb, &instance->sndqueue); + if (vcc->pop) + vcc->pop (vcc, skb); + else + kfree_skb (skb); + } + spin_unlock_irqrestore (&instance->sndqueue.lock, flags); + + tasklet_disable (&instance->send_tasklet); + if ((skb = instance->current_skb) && (UDSL_SKB (skb)->atm_data.vcc == vcc)) { + dbg ("popping current skb (0x%p)", skb); + instance->current_skb = NULL; + if (vcc->pop) + vcc->pop (vcc, skb); + else + kfree_skb (skb); + } + tasklet_enable (&instance->send_tasklet); + dbg ("udsl_cancel_send done"); +} + +static int udsl_atm_send (struct atm_vcc *vcc, struct sk_buff *skb) +{ + struct udsl_instance_data *instance = vcc->dev->dev_data; + + dbg ("udsl_atm_send called (skb 0x%p, len %u)", skb, skb->len); + + if (!instance || !instance->usb_dev) { + dbg ("NULL data!"); + return -ENODEV; + } + + if (!instance->firmware_loaded) + return -EAGAIN; + + if (vcc->qos.aal != ATM_AAL5) { + dbg ("unsupported ATM type %d!", vcc->qos.aal); + return -EINVAL; + } + + if (skb->len > ATM_MAX_AAL5_PDU) { + dbg ("packet too long (%d vs %d)!", skb->len, ATM_MAX_AAL5_PDU); + return -EINVAL; + } + + PACKETDEBUG (skb->data, skb->len); + + udsl_groom_skb (vcc, skb); + skb_queue_tail (&instance->sndqueue, skb); + tasklet_schedule (&instance->send_tasklet); + + return 0; +} + + +/********** +** ATM ** +**********/ + +#define ATMSAR_DEF_MTU_AAL0 48 +#define ATMSAR_DEF_MTU_AAL1 47 +#define ATMSAR_DEF_MTU_AAL2 0 /* not supported */ +#define ATMSAR_DEF_MTU_AAL34 0 /* not supported */ +#define ATMSAR_DEF_MTU_AAL5 65535 /* max mtu .. */ + +struct atmsar_vcc_data *atmsar_open (struct atmsar_vcc_data **list, struct atm_vcc *vcc, uint type, + ushort vpi, ushort vci, unchar pti, unchar gfc, uint flags) +{ + struct atmsar_vcc_data *new; + + if (!vcc) + return NULL; + + new = kmalloc (sizeof (struct atmsar_vcc_data), GFP_KERNEL); + + if (!new) + return NULL; + + memset (new, 0, sizeof (struct atmsar_vcc_data)); + new->vcc = vcc; + new->stats = vcc->stats; + new->type = type; + new->next = NULL; + new->gfc = gfc; + new->vp = vpi; + new->vc = vci; + new->pti = pti; + + switch (type) { + case ATM_AAL0: + new->mtu = ATMSAR_DEF_MTU_AAL0; + break; + case ATM_AAL1: + new->mtu = ATMSAR_DEF_MTU_AAL1; + break; + case ATM_AAL2: + new->mtu = ATMSAR_DEF_MTU_AAL2; + break; + case ATM_AAL34: + /* not supported */ + new->mtu = ATMSAR_DEF_MTU_AAL34; + break; + case ATM_AAL5: + new->mtu = ATMSAR_DEF_MTU_AAL5; + break; + } + + new->atmHeader = ((unsigned long) gfc << ATM_HDR_GFC_SHIFT) + | ((unsigned long) vpi << ATM_HDR_VPI_SHIFT) + | ((unsigned long) vci << ATM_HDR_VCI_SHIFT) + | ((unsigned long) pti << ATM_HDR_PTI_SHIFT); + new->flags = flags; + new->next = NULL; + new->reasBuffer = NULL; + + new->next = *list; + *list = new; + + dbg ("Allocated new SARLib vcc 0x%p with vp %d vc %d", new, vpi, vci); + + return new; +} + +void atmsar_close (struct atmsar_vcc_data **list, struct atmsar_vcc_data *vcc) +{ + struct atmsar_vcc_data *work; + + if (*list == vcc) { + *list = (*list)->next; + } else { + for (work = *list; work && work->next && (work->next != vcc); work = work->next); + + /* return if not found */ + if (work->next != vcc) + return; + + work->next = work->next->next; + } + + if (vcc->reasBuffer) { + dev_kfree_skb (vcc->reasBuffer); + } + + dbg ("Allocated SARLib vcc 0x%p with vp %d vc %d", vcc, vcc->vp, vcc->vc); + + kfree (vcc); +} + +static void udsl_atm_dev_close (struct atm_dev *dev) +{ + struct udsl_instance_data *instance = dev->dev_data; + + if (!instance) { + dbg ("udsl_atm_dev_close: NULL instance!"); + return; + } + + dbg ("udsl_atm_dev_close: queue has %u elements", instance->sndqueue.qlen); + + dbg ("udsl_atm_dev_close: killing tasklet"); + tasklet_kill (&instance->send_tasklet); + dbg ("udsl_atm_dev_close: freeing instance"); + kfree (instance); + dev->dev_data = NULL; +} + +static int udsl_atm_proc_read (struct atm_dev *atm_dev, loff_t *pos, char *page) +{ + struct udsl_instance_data *instance = atm_dev->dev_data; + int left = *pos; + + if (!instance) { + dbg ("NULL instance!"); + return -ENODEV; + } + + if (!left--) + return sprintf (page, "%s\n", instance->description); + + if (!left--) + return sprintf (page, "MAC: %02x:%02x:%02x:%02x:%02x:%02x\n", + atm_dev->esi[0], atm_dev->esi[1], atm_dev->esi[2], + atm_dev->esi[3], atm_dev->esi[4], atm_dev->esi[5]); + + if (!left--) + return sprintf (page, "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n", + atomic_read (&atm_dev->stats.aal5.tx), + atomic_read (&atm_dev->stats.aal5.tx_err), + atomic_read (&atm_dev->stats.aal5.rx), + atomic_read (&atm_dev->stats.aal5.rx_err), + atomic_read (&atm_dev->stats.aal5.rx_drop)); + + if (!left--) { + switch (atm_dev->signal) { + case ATM_PHY_SIG_FOUND: + sprintf (page, "Line up"); + break; + case ATM_PHY_SIG_LOST: + sprintf (page, "Line down"); + break; + default: + sprintf (page, "Line state unknown"); + break; + } + + if (instance->usb_dev) { + if (!instance->firmware_loaded) + strcat (page, ", no firmware\n"); + else + strcat (page, ", firmware loaded\n"); + } else + strcat (page, ", disconnected\n"); + + return strlen (page); + } + + return 0; +} + +#define ATMSAR_SET_PTI 0x2L + +static int udsl_atm_open (struct atm_vcc *vcc, short vpi, int vci) +{ + struct udsl_instance_data *instance = vcc->dev->dev_data; + + dbg ("udsl_atm_open called"); + + if (!instance || !instance->usb_dev) { + dbg ("NULL data!"); + return -ENODEV; + } + + /* at the moment only AAL5 support */ + if (vcc->qos.aal != ATM_AAL5) + return -EINVAL; + + MOD_INC_USE_COUNT; + + vcc->dev_data = + atmsar_open (&(instance->atmsar_vcc_list), vcc, ATM_AAL5, vpi, vci, 0, 0, + ATMSAR_USE_53BYTE_CELL | ATMSAR_SET_PTI); + if (!vcc->dev_data) { + MOD_DEC_USE_COUNT; + return -ENOMEM; /* this is the only reason atmsar_open can fail... */ + } + + vcc->vpi = vpi; + vcc->vci = vci; + set_bit (ATM_VF_ADDR, &vcc->flags); + set_bit (ATM_VF_PARTIAL, &vcc->flags); + set_bit (ATM_VF_READY, &vcc->flags); + + ((struct atmsar_vcc_data *)vcc->dev_data)->mtu = UDSL_MAX_AAL5_MRU; + + if (instance->firmware_loaded) + udsl_fire_receivers (instance); + + dbg ("udsl_atm_open successful"); + return 0; +} + +static void udsl_atm_close (struct atm_vcc *vcc) +{ + struct udsl_instance_data *instance = vcc->dev->dev_data; + + dbg ("udsl_atm_close called"); + + if (!instance) { + dbg ("NULL instance!"); + return; + } + + /* freeing resources */ + /* cancel all sends on this vcc */ + udsl_cancel_send (instance, vcc); + + atmsar_close (&(instance->atmsar_vcc_list), vcc->dev_data); + vcc->dev_data = NULL; + clear_bit (ATM_VF_PARTIAL, &vcc->flags); + + /* freeing address */ + vcc->vpi = ATM_VPI_UNSPEC; + vcc->vci = ATM_VCI_UNSPEC; + clear_bit (ATM_VF_ADDR, &vcc->flags); + + MOD_DEC_USE_COUNT; + + dbg ("udsl_atm_close successful"); + return; +} + +static int udsl_atm_ioctl (struct atm_dev *dev, unsigned int cmd, void *arg) +{ + switch (cmd) { + case ATM_QUERYLOOP: + return put_user (ATM_LM_NONE, (int *) arg) ? -EFAULT : 0; + default: + return -ENOIOCTLCMD; + } +} + + +/********** +** USB ** +**********/ + +static int udsl_usb_ioctl (struct usb_interface *intf, unsigned int code, void *user_data) +{ + struct udsl_instance_data *instance = usb_get_intfdata (intf); + + dbg ("udsl_usb_ioctl entered"); + + if (!instance) { + dbg ("NULL instance!"); + return -ENODEV; + } + + switch (code) { + case UDSL_IOCTL_START: + instance->atm_dev->signal = ATM_PHY_SIG_FOUND; + down (&instance->serialize); /* vs self */ + if (!instance->firmware_loaded) { + usb_set_interface (instance->usb_dev, 1, 1); + instance->firmware_loaded = 1; + } + up (&instance->serialize); + udsl_fire_receivers (instance); + return 0; + case UDSL_IOCTL_STOP: + instance->atm_dev->signal = ATM_PHY_SIG_LOST; + return 0; + default: + return -ENOTTY; + } +} + +static int udsl_usb_probe (struct usb_interface *intf, const struct usb_device_id *id) +{ + struct usb_device *dev = interface_to_usbdev(intf); + int ifnum = intf->altsetting->desc.bInterfaceNumber; + struct udsl_instance_data *instance; + unsigned char mac_str [13]; + int i, length; + char *buf; + + dbg ("Trying device with Vendor=0x%x, Product=0x%x, ifnum %d", + dev->descriptor.idVendor, dev->descriptor.idProduct, ifnum); + + if ((dev->descriptor.bDeviceClass != USB_CLASS_VENDOR_SPEC) || + (dev->descriptor.idVendor != SPEEDTOUCH_VENDORID) || + (dev->descriptor.idProduct != SPEEDTOUCH_PRODUCTID) || (ifnum != 1)) + return -ENODEV; + + dbg ("Device Accepted"); + + /* instance init */ + if (!(instance = kmalloc (sizeof (struct udsl_instance_data), GFP_KERNEL))) { + dbg ("No memory for Instance data!"); + return -ENOMEM; + } + + memset (instance, 0, sizeof (struct udsl_instance_data)); + + init_MUTEX (&instance->serialize); + + instance->usb_dev = dev; + + spin_lock_init (&instance->spare_receivers_lock); + INIT_LIST_HEAD (&instance->spare_receivers); + + spin_lock_init (&instance->completed_receivers_lock); + INIT_LIST_HEAD (&instance->completed_receivers); + + tasklet_init (&instance->receive_tasklet, udsl_process_receive, (unsigned long) instance); + + skb_queue_head_init (&instance->sndqueue); + + spin_lock_init (&instance->send_lock); + INIT_LIST_HEAD (&instance->spare_senders); + INIT_LIST_HEAD (&instance->spare_buffers); + + tasklet_init (&instance->send_tasklet, udsl_process_send, (unsigned long) instance); + INIT_LIST_HEAD (&instance->filled_buffers); + + /* receive init */ + for (i = 0; i < UDSL_NUMBER_RCV_URBS; i++) { + struct udsl_receiver *rcv = &(instance->all_receivers[i]); + + if (!(rcv->skb = dev_alloc_skb (UDSL_RCV_BUFFER_SIZE * ATM_CELL_SIZE))) { + dbg ("No memory for skb %d!", i); + goto fail; + } + + if (!(rcv->urb = usb_alloc_urb (0, GFP_KERNEL))) { + dbg ("No memory for receive urb %d!", i); + goto fail; + } + + rcv->instance = instance; + + list_add (&rcv->list, &instance->spare_receivers); + + dbg ("skb->truesize = %d (asked for %d)", rcv->skb->truesize, UDSL_RCV_BUFFER_SIZE * ATM_CELL_SIZE); + } + + /* send init */ + for (i = 0; i < UDSL_NUMBER_SND_URBS; i++) { + struct udsl_sender *snd = &(instance->all_senders[i]); + + if (!(snd->urb = usb_alloc_urb (0, GFP_KERNEL))) { + dbg ("No memory for send urb %d!", i); + goto fail; + } + + snd->instance = instance; + + list_add (&snd->list, &instance->spare_senders); + } + + for (i = 0; i < UDSL_NUMBER_SND_BUFS; i++) { + struct udsl_send_buffer *buf = &(instance->all_buffers[i]); + + if (!(buf->base = kmalloc (UDSL_SND_BUFFER_SIZE * ATM_CELL_SIZE, GFP_KERNEL))) { + dbg ("No memory for send buffer %d!", i); + goto fail; + } + + list_add (&buf->list, &instance->spare_buffers); + } + + /* atm init */ + if (!(instance->atm_dev = atm_dev_register (udsl_driver_name, &udsl_atm_devops, -1, 0))) { + dbg ("failed to register ATM device!"); + goto fail; + } + + instance->atm_dev->ci_range.vpi_bits = ATM_CI_MAX; + instance->atm_dev->ci_range.vci_bits = ATM_CI_MAX; + instance->atm_dev->signal = ATM_PHY_SIG_UNKNOWN; + + /* tmp init atm device, set to 128kbit */ + instance->atm_dev->link_rate = 128 * 1000 / 424; + + /* set MAC address, it is stored in the serial number */ + memset (instance->atm_dev->esi, 0, sizeof (instance->atm_dev->esi)); + if (usb_string (dev, dev->descriptor.iSerialNumber, mac_str, sizeof (mac_str)) == 12) + for (i = 0; i < 6; i++) + instance->atm_dev->esi[i] = (hex2int (mac_str[i * 2]) * 16) + (hex2int (mac_str[i * 2 + 1])); + + /* device description */ + buf = instance->description; + length = sizeof (instance->description); + + if ((i = usb_string (dev, dev->descriptor.iProduct, buf, length)) < 0) + goto finish; + + buf += i; + length -= i; + + i = snprintf (buf, length, " ("); + buf += i; + length -= i; + + if (length <= 0 || (i = usb_make_path (dev, buf, length)) < 0) + goto finish; + + buf += i; + length -= i; + + snprintf (buf, length, ")"); + +finish: + /* ready for ATM callbacks */ + instance->atm_dev->dev_data = instance; + + usb_set_intfdata (intf, instance); + + return 0; + +fail: + for (i = 0; i < UDSL_NUMBER_SND_BUFS; i++) + kfree (instance->all_buffers[i].base); + + for (i = 0; i < UDSL_NUMBER_SND_URBS; i++) + usb_free_urb (instance->all_senders[i].urb); + + for (i = 0; i < UDSL_NUMBER_RCV_URBS; i++) { + struct udsl_receiver *rcv = &(instance->all_receivers[i]); + + usb_free_urb (rcv->urb); + + if (rcv->skb) + kfree_skb (rcv->skb); + } + + kfree (instance); + + return -ENOMEM; +} + +static void udsl_usb_disconnect (struct usb_interface *intf) +{ + struct udsl_instance_data *instance = usb_get_intfdata (intf); + struct list_head *pos; + unsigned long flags; + unsigned int count = 0; + int result, i; + + dbg ("disconnecting"); + + usb_set_intfdata (intf, NULL); + + if (!instance) { + dbg ("NULL instance!"); + return; + } + + tasklet_disable (&instance->receive_tasklet); + + /* receive finalize */ + down (&instance->serialize); /* vs udsl_fire_receivers */ + /* no need to take the spinlock */ + list_for_each (pos, &instance->spare_receivers) + if (++count > UDSL_NUMBER_RCV_URBS) + panic (__FILE__ ": memory corruption detected at line %d!\n", __LINE__); + INIT_LIST_HEAD (&instance->spare_receivers); + up (&instance->serialize); + + dbg ("udsl_usb_disconnect: flushed %u spare receivers", count); + + count = UDSL_NUMBER_RCV_URBS - count; + + for (i = 0; i < UDSL_NUMBER_RCV_URBS; i++) + if ((result = usb_unlink_urb (instance->all_receivers[i].urb)) < 0) + dbg ("udsl_usb_disconnect: usb_unlink_urb on receive urb %d returned %d", i, result); + + /* wait for completion handlers to finish */ + do { + unsigned int completed = 0; + + spin_lock_irqsave (&instance->completed_receivers_lock, flags); + list_for_each (pos, &instance->completed_receivers) + if (++completed > count) + panic (__FILE__ ": memory corruption detected at line %d!\n", __LINE__); + spin_unlock_irqrestore (&instance->completed_receivers_lock, flags); + + dbg ("udsl_usb_disconnect: found %u completed receivers", completed); + + if (completed == count) + break; + + yield (); + } while (1); + + dbg ("udsl_usb_disconnect: flushing"); + /* no need to take the spinlock */ + INIT_LIST_HEAD (&instance->completed_receivers); + + tasklet_enable (&instance->receive_tasklet); + tasklet_kill (&instance->receive_tasklet); + + dbg ("udsl_usb_disconnect: freeing receivers"); + for (i = 0; i < UDSL_NUMBER_RCV_URBS; i++) { + struct udsl_receiver *rcv = &(instance->all_receivers[i]); + + usb_free_urb (rcv->urb); + kfree_skb (rcv->skb); + } + + /* send finalize */ + tasklet_disable (&instance->send_tasklet); + + for (i = 0; i < UDSL_NUMBER_SND_URBS; i++) + if ((result = usb_unlink_urb (instance->all_senders[i].urb)) < 0) + dbg ("udsl_usb_disconnect: usb_unlink_urb on send urb %d returned %d", i, result); + + /* wait for completion handlers to finish */ + do { + count = 0; + spin_lock_irqsave (&instance->send_lock, flags); + list_for_each (pos, &instance->spare_senders) + if (++count > UDSL_NUMBER_SND_URBS) + panic (__FILE__ ": memory corruption detected at line %d!\n", __LINE__); + spin_unlock_irqrestore (&instance->send_lock, flags); + + dbg ("udsl_usb_disconnect: found %u spare senders", count); + + if (count == UDSL_NUMBER_SND_URBS) + break; + + yield (); + } while (1); + + dbg ("udsl_usb_disconnect: flushing"); + /* no need to take the spinlock */ + INIT_LIST_HEAD (&instance->spare_senders); + INIT_LIST_HEAD (&instance->spare_buffers); + instance->current_buffer = NULL; + + tasklet_enable (&instance->send_tasklet); + + dbg ("udsl_usb_disconnect: freeing senders"); + for (i = 0; i < UDSL_NUMBER_SND_URBS; i++) + usb_free_urb (instance->all_senders[i].urb); + + dbg ("udsl_usb_disconnect: freeing buffers"); + for (i = 0; i < UDSL_NUMBER_SND_BUFS; i++) + kfree (instance->all_buffers[i].base); + + instance->usb_dev = NULL; + + /* atm finalize */ + shutdown_atm_dev (instance->atm_dev); /* frees instance */ +} + + +/*********** +** init ** +***********/ + +static int __init udsl_usb_init (void) +{ + struct sk_buff *skb; /* dummy for sizeof */ + + dbg ("udsl_usb_init: driver version " DRIVER_VERSION); + + if (sizeof (struct udsl_control) > sizeof (skb->cb)) { + printk (KERN_ERR __FILE__ ": unusable with this kernel!\n"); + return -EIO; + } + + return usb_register (&udsl_usb_driver); +} + +static void __exit udsl_usb_cleanup (void) +{ + dbg ("udsl_usb_cleanup"); + + usb_deregister (&udsl_usb_driver); +} + +module_init (udsl_usb_init); +module_exit (udsl_usb_cleanup); + +MODULE_AUTHOR (DRIVER_AUTHOR); +MODULE_DESCRIPTION (DRIVER_DESC); +MODULE_LICENSE ("GPL"); + + +/************ +** debug ** +************/ + +#ifdef DEBUG_PACKET +static int udsl_print_packet (const unsigned char *data, int len) +{ + unsigned char buffer [256]; + int i = 0, j = 0; + + for (i = 0; i < len;) { + buffer[0] = '\0'; + sprintf (buffer, "%.3d :", i); + for (j = 0; (j < 16) && (i < len); j++, i++) { + sprintf (buffer, "%s %2.2x", buffer, data[i]); + } + dbg ("%s", buffer); + } + return i; +} +#endif diff -Nru a/drivers/usb/misc/speedtouch.c b/drivers/usb/misc/speedtouch.c --- a/drivers/usb/misc/speedtouch.c Sun Mar 23 00:22:56 2003 +++ /dev/null Wed Dec 31 16:00:00 1969 @@ -1,1241 +0,0 @@ -/****************************************************************************** - * speedtouch.c -- Alcatel SpeedTouch USB xDSL modem driver. - * - * Copyright (C) 2001, Alcatel - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 - * Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - ******************************************************************************/ - -/* - * Written by Johan Verrept (Johan.Verrept@advalvas.be) - * - * 1.5A: - Version for inclusion in 2.5 series kernel - * - Modifications by Richard Purdie (rpurdie@rpsys.net) - * - made compatible with kernel 2.5.6 onwards by changing - * udsl_usb_send_data_context->urb to a pointer and adding code - * to alloc and free it - * - remove_wait_queue() added to udsl_atm_processqueue_thread() - * - * 1.5: - fixed memory leak when atmsar_decode_aal5 returned NULL. - * (reported by stephen.robinson@zen.co.uk) - * - * 1.4: - changed the spin_lock() under interrupt to spin_lock_irqsave() - * - unlink all active send urbs of a vcc that is being closed. - * - * 1.3.1: - added the version number - * - * 1.3: - Added multiple send urb support - * - fixed memory leak and vcc->tx_inuse starvation bug - * when not enough memory left in vcc. - * - * 1.2: - Fixed race condition in udsl_usb_send_data() - * 1.1: - Turned off packet debugging - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "atmsar.h" - -/* -#define DEBUG 1 -#define DEBUG_PACKET 1 -*/ - -#include - - -#ifdef DEBUG_PACKET -static int udsl_print_packet (const unsigned char *data, int len); -#define PACKETDEBUG(arg...) udsl_print_packet (arg) -#else -#define PACKETDEBUG(arg...) -#endif - -#define DRIVER_AUTHOR "Johan Verrept, Johan.Verrept@advalvas.be" -#define DRIVER_DESC "Driver for the Alcatel SpeedTouch USB ADSL modem" -#define DRIVER_VERSION "1.5A" - -#define SPEEDTOUCH_VENDORID 0x06b9 -#define SPEEDTOUCH_PRODUCTID 0x4061 - -#define UDSL_NUMBER_RCV_URBS 1 -#define UDSL_NUMBER_SND_URBS 1 -#define UDSL_NUMBER_SND_BUFS (2*UDSL_NUMBER_SND_URBS) -#define UDSL_RCV_BUFFER_SIZE (1*64) /* ATM cells */ -#define UDSL_SND_BUFFER_SIZE (1*64) /* ATM cells */ -/* max should be (1500 IP mtu + 2 ppp bytes + 32 * 5 cellheader overhead) for - * PPPoA and (1500 + 14 + 32*5 cellheader overhead) for PPPoE */ -#define UDSL_MAX_AAL5_MRU 2048 - -#define UDSL_IOCTL_START 1 -#define UDSL_IOCTL_STOP 2 - -/* endpoint declarations */ - -#define UDSL_ENDPOINT_DATA_OUT 0x07 -#define UDSL_ENDPOINT_DATA_IN 0x87 - -#define hex2int(c) ( (c >= '0')&&(c <= '9') ? (c - '0') : ((c & 0xf)+9) ) - -/* usb_device_id struct */ - -static struct usb_device_id udsl_usb_ids [] = { - { USB_DEVICE (SPEEDTOUCH_VENDORID, SPEEDTOUCH_PRODUCTID) }, - { } /* Terminating entry */ -}; - -MODULE_DEVICE_TABLE (usb, udsl_usb_ids); - -/* context declarations */ - -struct udsl_receiver { - struct list_head list; - struct sk_buff *skb; - struct urb *urb; - struct udsl_instance_data *instance; -}; - -struct udsl_send_buffer { - struct list_head list; - unsigned char *base; - unsigned char *free_start; - unsigned int free_cells; -}; - -struct udsl_sender { - struct list_head list; - struct udsl_send_buffer *buffer; - struct urb *urb; - struct udsl_instance_data *instance; -}; - -struct udsl_control { - struct atm_skb_data atm_data; - unsigned int num_cells; - unsigned int num_entire; - unsigned char cell_header [ATM_CELL_HEADER]; - unsigned int pdu_padding; - unsigned char aal5_trailer [ATM_AAL5_TRAILER]; -}; - -#define UDSL_SKB(x) ((struct udsl_control *)(x)->cb) - -/* - * UDSL main driver data - */ - -struct udsl_instance_data { - struct semaphore serialize; - - /* usb device part */ - struct usb_device *usb_dev; - char description [64]; - int firmware_loaded; - - /* atm device part */ - struct atm_dev *atm_dev; - struct atmsar_vcc_data *atmsar_vcc_list; - - /* receiving */ - struct udsl_receiver all_receivers [UDSL_NUMBER_RCV_URBS]; - - spinlock_t spare_receivers_lock; - struct list_head spare_receivers; - - spinlock_t completed_receivers_lock; - struct list_head completed_receivers; - - struct tasklet_struct receive_tasklet; - - /* sending */ - struct udsl_sender all_senders [UDSL_NUMBER_SND_URBS]; - struct udsl_send_buffer all_buffers [UDSL_NUMBER_SND_BUFS]; - - struct sk_buff_head sndqueue; - - spinlock_t send_lock; - struct list_head spare_senders; - struct list_head spare_buffers; - - struct tasklet_struct send_tasklet; - struct sk_buff *current_skb; /* being emptied */ - struct udsl_send_buffer *current_buffer; /* being filled */ - struct list_head filled_buffers; -}; - -static const char udsl_driver_name [] = "speedtch"; - -/* - * atm driver prototypes and structures - */ - -static void udsl_atm_dev_close (struct atm_dev *dev); -static int udsl_atm_open (struct atm_vcc *vcc, short vpi, int vci); -static void udsl_atm_close (struct atm_vcc *vcc); -static int udsl_atm_ioctl (struct atm_dev *dev, unsigned int cmd, void *arg); -static int udsl_atm_send (struct atm_vcc *vcc, struct sk_buff *skb); -static int udsl_atm_proc_read (struct atm_dev *atm_dev, loff_t *pos, char *page); - -static struct atmdev_ops udsl_atm_devops = { - .dev_close = udsl_atm_dev_close, - .open = udsl_atm_open, - .close = udsl_atm_close, - .ioctl = udsl_atm_ioctl, - .send = udsl_atm_send, - .proc_read = udsl_atm_proc_read, -}; - -/* - * usb driver prototypes and structures - */ -static int udsl_usb_probe (struct usb_interface *intf, - const struct usb_device_id *id); -static void udsl_usb_disconnect (struct usb_interface *intf); -static int udsl_usb_ioctl (struct usb_interface *intf, unsigned int code, void *user_data); - -static struct usb_driver udsl_usb_driver = { - .name = udsl_driver_name, - .probe = udsl_usb_probe, - .disconnect = udsl_usb_disconnect, - .ioctl = udsl_usb_ioctl, - .id_table = udsl_usb_ids, -}; - - -/************* -** encode ** -*************/ - -static void udsl_groom_skb (struct atm_vcc *vcc, struct sk_buff *skb) { - struct udsl_control *ctrl = UDSL_SKB (skb); - unsigned int i, zero_padding; - unsigned char zero = 0; - u32 crc; - - ctrl->atm_data.vcc = vcc; - ctrl->cell_header [0] = vcc->vpi >> 4; - ctrl->cell_header [1] = (vcc->vpi << 4) | (vcc->vci >> 12); - ctrl->cell_header [2] = vcc->vci >> 4; - ctrl->cell_header [3] = vcc->vci << 4; - ctrl->cell_header [4] = 0xec; - - ctrl->num_cells = (skb->len + ATM_AAL5_TRAILER + ATM_CELL_PAYLOAD - 1) / ATM_CELL_PAYLOAD; - ctrl->num_entire = skb->len / ATM_CELL_PAYLOAD; - - zero_padding = ctrl->num_cells * ATM_CELL_PAYLOAD - skb->len - ATM_AAL5_TRAILER; - - if (ctrl->num_entire + 1 < ctrl->num_cells) - ctrl->pdu_padding = zero_padding - (ATM_CELL_PAYLOAD - ATM_AAL5_TRAILER); - else - ctrl->pdu_padding = zero_padding; - - ctrl->aal5_trailer [0] = 0; /* UU = 0 */ - ctrl->aal5_trailer [1] = 0; /* CPI = 0 */ - ctrl->aal5_trailer [2] = skb->len >> 8; - ctrl->aal5_trailer [3] = skb->len; - - crc = crc32_be (~0, skb->data, skb->len); - for (i = 0; i < zero_padding; i++) - crc = crc32_be (crc, &zero, 1); - crc = crc32_be (crc, ctrl->aal5_trailer, 4); - crc = ~crc; - - ctrl->aal5_trailer [4] = crc >> 24; - ctrl->aal5_trailer [5] = crc >> 16; - ctrl->aal5_trailer [6] = crc >> 8; - ctrl->aal5_trailer [7] = crc; -} - -unsigned int udsl_write_cells (unsigned int howmany, struct sk_buff *skb, unsigned char **target_p) { - struct udsl_control *ctrl = UDSL_SKB (skb); - unsigned char *target = *target_p; - unsigned int nc, ne, i; - - dbg ("udsl_write_cells: howmany=%u, skb->len=%d, num_cells=%u, num_entire=%u, pdu_padding=%u", howmany, skb->len, ctrl->num_cells, ctrl->num_entire, ctrl->pdu_padding); - - nc = ctrl->num_cells; - ne = min (howmany, ctrl->num_entire); - - for (i = 0; i < ne; i++) { - memcpy (target, ctrl->cell_header, ATM_CELL_HEADER); - target += ATM_CELL_HEADER; - memcpy (target, skb->data, ATM_CELL_PAYLOAD); - target += ATM_CELL_PAYLOAD; - __skb_pull (skb, ATM_CELL_PAYLOAD); - } - - ctrl->num_entire -= ne; - - if (!(ctrl->num_cells -= ne) || !(howmany -= ne)) - goto out; - - memcpy (target, ctrl->cell_header, ATM_CELL_HEADER); - target += ATM_CELL_HEADER; - memcpy (target, skb->data, skb->len); - target += skb->len; - __skb_pull (skb, skb->len); - memset (target, 0, ctrl->pdu_padding); - target += ctrl->pdu_padding; - - if (--ctrl->num_cells) { - if (!--howmany) { - ctrl->pdu_padding = ATM_CELL_PAYLOAD - ATM_AAL5_TRAILER; - goto out; - } - - memcpy (target, ctrl->cell_header, ATM_CELL_HEADER); - target += ATM_CELL_HEADER; - memset (target, 0, ATM_CELL_PAYLOAD - ATM_AAL5_TRAILER); - target += ATM_CELL_PAYLOAD - ATM_AAL5_TRAILER; - - if (--ctrl->num_cells) - BUG(); - } - - memcpy (target, ctrl->aal5_trailer, ATM_AAL5_TRAILER); - target += ATM_AAL5_TRAILER; - /* set pti bit in last cell */ - *(target + 3 - ATM_CELL_SIZE) |= 0x2; - -out: - *target_p = target; - return nc - ctrl->num_cells; -} - - -/************** -** receive ** -**************/ - -static void udsl_complete_receive (struct urb *urb, struct pt_regs *regs) -{ - struct udsl_instance_data *instance; - struct udsl_receiver *rcv; - unsigned long flags; - - if (!urb || !(rcv = urb->context) || !(instance = rcv->instance)) { - dbg ("udsl_complete_receive: bad urb!"); - return; - } - - dbg ("udsl_complete_receive entered (urb 0x%p, status %d)", urb, urb->status); - - /* may not be in_interrupt() */ - spin_lock_irqsave (&instance->completed_receivers_lock, flags); - list_add_tail (&rcv->list, &instance->completed_receivers); - tasklet_schedule (&instance->receive_tasklet); - spin_unlock_irqrestore (&instance->completed_receivers_lock, flags); -} - -static void udsl_process_receive (unsigned long data) -{ - struct udsl_instance_data *instance = (struct udsl_instance_data *) data; - struct udsl_receiver *rcv; - unsigned long flags; - unsigned char *data_start; - struct sk_buff *skb; - struct urb *urb; - struct atmsar_vcc_data *atmsar_vcc = NULL; - struct sk_buff *new = NULL, *tmp = NULL; - int err; - - dbg ("udsl_process_receive entered"); - - spin_lock_irqsave (&instance->completed_receivers_lock, flags); - while (!list_empty (&instance->completed_receivers)) { - rcv = list_entry (instance->completed_receivers.next, struct udsl_receiver, list); - list_del (&rcv->list); - spin_unlock_irqrestore (&instance->completed_receivers_lock, flags); - - urb = rcv->urb; - dbg ("udsl_process_receive: got packet %p with length %d and status %d", urb, urb->actual_length, urb->status); - - switch (urb->status) { - case 0: - dbg ("udsl_process_receive: processing urb with rcv %p, urb %p, skb %p", rcv, urb, rcv->skb); - - /* update the skb structure */ - skb = rcv->skb; - skb_trim (skb, 0); - skb_put (skb, urb->actual_length); - data_start = skb->data; - - dbg ("skb->len = %d", skb->len); - PACKETDEBUG (skb->data, skb->len); - - while ((new = - atmsar_decode_rawcell (instance->atmsar_vcc_list, skb, - &atmsar_vcc)) != NULL) { - dbg ("(after cell processing)skb->len = %d", new->len); - - switch (atmsar_vcc->type) { - case ATMSAR_TYPE_AAL5: - tmp = new; - new = atmsar_decode_aal5 (atmsar_vcc, new); - - /* we can't send NULL skbs upstream, the ATM layer would try to close the vcc... */ - if (new) { - dbg ("(after aal5 decap) skb->len = %d", new->len); - if (new->len && atm_charge (atmsar_vcc->vcc, new->truesize)) { - PACKETDEBUG (new->data, new->len); - atmsar_vcc->vcc->push (atmsar_vcc->vcc, new); - } else { - dbg - ("dropping incoming packet : rx_inuse = %d, vcc->sk->rcvbuf = %d, skb->true_size = %d", - atomic_read (&atmsar_vcc->vcc->rx_inuse), - atmsar_vcc->vcc->sk->rcvbuf, new->truesize); - dev_kfree_skb (new); - } - } else { - dbg ("atmsar_decode_aal5 returned NULL!"); - dev_kfree_skb (tmp); - } - break; - default: - /* not supported. we delete the skb. */ - printk (KERN_INFO - "SpeedTouch USB: illegal vcc type. Dropping packet.\n"); - dev_kfree_skb (new); - break; - } - } - - /* restore skb */ - skb_push (skb, skb->data - data_start); - - usb_fill_bulk_urb (urb, - instance->usb_dev, - usb_rcvbulkpipe (instance->usb_dev, UDSL_ENDPOINT_DATA_IN), - (unsigned char *) rcv->skb->data, - UDSL_RCV_BUFFER_SIZE * ATM_CELL_SIZE, - udsl_complete_receive, - rcv); - if (!(err = usb_submit_urb (urb, GFP_ATOMIC))) - break; - dbg ("udsl_process_receive: submission failed (%d)", err); - /* fall through */ - default: /* error or urb unlinked */ - dbg ("udsl_process_receive: adding to spare_receivers"); - spin_lock_irqsave (&instance->spare_receivers_lock, flags); - list_add (&rcv->list, &instance->spare_receivers); - spin_unlock_irqrestore (&instance->spare_receivers_lock, flags); - break; - } /* switch */ - - spin_lock_irqsave (&instance->completed_receivers_lock, flags); - } /* while */ - spin_unlock_irqrestore (&instance->completed_receivers_lock, flags); - dbg ("udsl_process_receive successful"); -} - -static void udsl_fire_receivers (struct udsl_instance_data *instance) -{ - struct list_head receivers, *pos, *n; - unsigned long flags; - - INIT_LIST_HEAD (&receivers); - - down (&instance->serialize); - - spin_lock_irqsave (&instance->spare_receivers_lock, flags); - list_splice_init (&instance->spare_receivers, &receivers); - spin_unlock_irqrestore (&instance->spare_receivers_lock, flags); - - list_for_each_safe (pos, n, &receivers) { - struct udsl_receiver *rcv = list_entry (pos, struct udsl_receiver, list); - - dbg ("udsl_fire_receivers: firing urb %p", rcv->urb); - - usb_fill_bulk_urb (rcv->urb, - instance->usb_dev, - usb_rcvbulkpipe (instance->usb_dev, UDSL_ENDPOINT_DATA_IN), - (unsigned char *) rcv->skb->data, - UDSL_RCV_BUFFER_SIZE * ATM_CELL_SIZE, - udsl_complete_receive, - rcv); - - if (usb_submit_urb (rcv->urb, GFP_KERNEL) < 0) { - dbg ("udsl_fire_receivers: submit failed!"); - spin_lock_irqsave (&instance->spare_receivers_lock, flags); - list_move (pos, &instance->spare_receivers); - spin_unlock_irqrestore (&instance->spare_receivers_lock, flags); - } - } - - up (&instance->serialize); -} - - -/*********** -** send ** -***********/ - -static void udsl_complete_send (struct urb *urb, struct pt_regs *regs) -{ - struct udsl_instance_data *instance; - struct udsl_sender *snd; - unsigned long flags; - - if (!urb || !(snd = urb->context) || !(instance = snd->instance)) { - dbg ("udsl_complete_send: bad urb!"); - return; - } - - dbg ("udsl_complete_send entered (urb 0x%p, status %d)", urb, urb->status); - - /* may not be in_interrupt() */ - spin_lock_irqsave (&instance->send_lock, flags); - list_add (&snd->list, &instance->spare_senders); - list_add (&snd->buffer->list, &instance->spare_buffers); - tasklet_schedule (&instance->send_tasklet); - spin_unlock_irqrestore (&instance->send_lock, flags); -} - -static void udsl_process_send (unsigned long data) -{ - struct udsl_send_buffer *buf; - int err; - unsigned long flags; - struct udsl_instance_data *instance = (struct udsl_instance_data *) data; - unsigned int num_written; - struct sk_buff *skb; - struct udsl_sender *snd; - - dbg ("udsl_process_send entered"); - -made_progress: - spin_lock_irqsave (&instance->send_lock, flags); - while (!list_empty (&instance->spare_senders)) { - if (!list_empty (&instance->filled_buffers)) { - buf = list_entry (instance->filled_buffers.next, struct udsl_send_buffer, list); - list_del (&buf->list); - dbg ("sending filled buffer (0x%p)", buf); - } else if ((buf = instance->current_buffer)) { - instance->current_buffer = NULL; - dbg ("sending current buffer (0x%p)", buf); - } else /* all buffers empty */ - break; - - snd = list_entry (instance->spare_senders.next, struct udsl_sender, list); - list_del (&snd->list); - spin_unlock_irqrestore (&instance->send_lock, flags); - - snd->buffer = buf; - usb_fill_bulk_urb (snd->urb, - instance->usb_dev, - usb_sndbulkpipe (instance->usb_dev, UDSL_ENDPOINT_DATA_OUT), - buf->base, - (UDSL_SND_BUFFER_SIZE - buf->free_cells) * ATM_CELL_SIZE, - udsl_complete_send, - snd); - - dbg ("submitting urb 0x%p, contains %d cells", snd->urb, UDSL_SND_BUFFER_SIZE - buf->free_cells); - - if ((err = usb_submit_urb(snd->urb, GFP_ATOMIC)) < 0) { - dbg ("submission failed (%d)!", err); - spin_lock_irqsave (&instance->send_lock, flags); - list_add (&snd->list, &instance->spare_senders); - spin_unlock_irqrestore (&instance->send_lock, flags); - list_add (&buf->list, &instance->filled_buffers); - return; - } - - spin_lock_irqsave (&instance->send_lock, flags); - } /* while */ - spin_unlock_irqrestore (&instance->send_lock, flags); - - if (!instance->current_skb && !(instance->current_skb = skb_dequeue (&instance->sndqueue))) { - dbg ("done - no more skbs"); - return; - } - - skb = instance->current_skb; - - if (!(buf = instance->current_buffer)) { - spin_lock_irqsave (&instance->send_lock, flags); - if (list_empty (&instance->spare_buffers)) { - instance->current_buffer = NULL; - spin_unlock_irqrestore (&instance->send_lock, flags); - dbg ("done - no more buffers"); - return; - } - buf = list_entry (instance->spare_buffers.next, struct udsl_send_buffer, list); - list_del (&buf->list); - spin_unlock_irqrestore (&instance->send_lock, flags); - - buf->free_start = buf->base; - buf->free_cells = UDSL_SND_BUFFER_SIZE; - - instance->current_buffer = buf; - } - - num_written = udsl_write_cells (buf->free_cells, skb, &buf->free_start); - - dbg ("wrote %u cells from skb 0x%p to buffer 0x%p", num_written, skb, buf); - - if (!(buf->free_cells -= num_written)) { - list_add_tail (&buf->list, &instance->filled_buffers); - instance->current_buffer = NULL; - dbg ("queued filled buffer"); - } - - dbg ("buffer contains %d cells, %d left", UDSL_SND_BUFFER_SIZE - buf->free_cells, buf->free_cells); - - if (!UDSL_SKB (skb)->num_cells) { - struct atm_vcc *vcc = UDSL_SKB (skb)->atm_data.vcc; - - dbg ("discarding empty skb"); - if (vcc->pop) - vcc->pop (vcc, skb); - else - kfree_skb (skb); - instance->current_skb = NULL; - - if (vcc->stats) - atomic_inc (&vcc->stats->tx); - } - - goto made_progress; -} - -static void udsl_cancel_send (struct udsl_instance_data *instance, struct atm_vcc *vcc) -{ - unsigned long flags; - struct sk_buff *skb, *n; - - dbg ("udsl_cancel_send entered"); - spin_lock_irqsave (&instance->sndqueue.lock, flags); - for (skb = instance->sndqueue.next, n = skb->next; skb != (struct sk_buff *)&instance->sndqueue; skb = n, n = skb->next) - if (UDSL_SKB (skb)->atm_data.vcc == vcc) { - dbg ("popping skb 0x%p", skb); - __skb_unlink (skb, &instance->sndqueue); - if (vcc->pop) - vcc->pop (vcc, skb); - else - kfree_skb (skb); - } - spin_unlock_irqrestore (&instance->sndqueue.lock, flags); - - tasklet_disable (&instance->send_tasklet); - if ((skb = instance->current_skb) && (UDSL_SKB (skb)->atm_data.vcc == vcc)) { - dbg ("popping current skb (0x%p)", skb); - instance->current_skb = NULL; - if (vcc->pop) - vcc->pop (vcc, skb); - else - kfree_skb (skb); - } - tasklet_enable (&instance->send_tasklet); - dbg ("udsl_cancel_send done"); -} - -static int udsl_atm_send (struct atm_vcc *vcc, struct sk_buff *skb) -{ - struct udsl_instance_data *instance = vcc->dev->dev_data; - - dbg ("udsl_atm_send called (skb 0x%p, len %u)", skb, skb->len); - - if (!instance || !instance->usb_dev) { - dbg ("NULL data!"); - return -ENODEV; - } - - if (!instance->firmware_loaded) - return -EAGAIN; - - if (vcc->qos.aal != ATM_AAL5) { - dbg ("unsupported ATM type %d!", vcc->qos.aal); - return -EINVAL; - } - - if (skb->len > ATM_MAX_AAL5_PDU) { - dbg ("packet too long (%d vs %d)!", skb->len, ATM_MAX_AAL5_PDU); - return -EINVAL; - } - - PACKETDEBUG (skb->data, skb->len); - - udsl_groom_skb (vcc, skb); - skb_queue_tail (&instance->sndqueue, skb); - tasklet_schedule (&instance->send_tasklet); - - return 0; -} - - -/************ -** ATM ** -************/ - -/*************************************************************************** -* -* init functions -* -****************************************************************************/ - -static void udsl_atm_dev_close (struct atm_dev *dev) -{ - struct udsl_instance_data *instance = dev->dev_data; - - if (!instance) { - dbg ("udsl_atm_dev_close: NULL instance!"); - return; - } - - dbg ("udsl_atm_dev_close: queue has %u elements", instance->sndqueue.qlen); - - dbg ("udsl_atm_dev_close: killing tasklet"); - tasklet_kill (&instance->send_tasklet); - dbg ("udsl_atm_dev_close: freeing instance"); - kfree (instance); - dev->dev_data = NULL; -} - - -/*************************************************************************** -* -* ATM helper functions -* -****************************************************************************/ - -static int udsl_atm_proc_read (struct atm_dev *atm_dev, loff_t *pos, char *page) -{ - struct udsl_instance_data *instance = atm_dev->dev_data; - int left = *pos; - - if (!instance) { - dbg ("NULL instance!"); - return -ENODEV; - } - - if (!left--) - return sprintf (page, "%s\n", instance->description); - - if (!left--) - return sprintf (page, "MAC: %02x:%02x:%02x:%02x:%02x:%02x\n", - atm_dev->esi[0], atm_dev->esi[1], atm_dev->esi[2], - atm_dev->esi[3], atm_dev->esi[4], atm_dev->esi[5]); - - if (!left--) - return sprintf (page, "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n", - atomic_read (&atm_dev->stats.aal5.tx), - atomic_read (&atm_dev->stats.aal5.tx_err), - atomic_read (&atm_dev->stats.aal5.rx), - atomic_read (&atm_dev->stats.aal5.rx_err), - atomic_read (&atm_dev->stats.aal5.rx_drop)); - - if (!left--) { - switch (atm_dev->signal) { - case ATM_PHY_SIG_FOUND: - sprintf (page, "Line up"); - break; - case ATM_PHY_SIG_LOST: - sprintf (page, "Line down"); - break; - default: - sprintf (page, "Line state unknown"); - break; - } - - if (instance->usb_dev) { - if (!instance->firmware_loaded) - strcat (page, ", no firmware\n"); - else - strcat (page, ", firmware loaded\n"); - } else - strcat (page, ", disconnected\n"); - - return strlen (page); - } - - return 0; -} - - -/*************************************************************************** -* -* SAR driver entries -* -****************************************************************************/ - -static int udsl_atm_open (struct atm_vcc *vcc, short vpi, int vci) -{ - struct udsl_instance_data *instance = vcc->dev->dev_data; - - dbg ("udsl_atm_open called"); - - if (!instance || !instance->usb_dev) { - dbg ("NULL data!"); - return -ENODEV; - } - - /* at the moment only AAL5 support */ - if (vcc->qos.aal != ATM_AAL5) - return -EINVAL; - - MOD_INC_USE_COUNT; - - vcc->dev_data = - atmsar_open (&(instance->atmsar_vcc_list), vcc, ATMSAR_TYPE_AAL5, vpi, vci, 0, 0, - ATMSAR_USE_53BYTE_CELL | ATMSAR_SET_PTI); - if (!vcc->dev_data) { - MOD_DEC_USE_COUNT; - return -ENOMEM; /* this is the only reason atmsar_open can fail... */ - } - - vcc->vpi = vpi; - vcc->vci = vci; - set_bit (ATM_VF_ADDR, &vcc->flags); - set_bit (ATM_VF_PARTIAL, &vcc->flags); - set_bit (ATM_VF_READY, &vcc->flags); - - ((struct atmsar_vcc_data *)vcc->dev_data)->mtu = UDSL_MAX_AAL5_MRU; - - if (instance->firmware_loaded) - udsl_fire_receivers (instance); - - dbg ("udsl_atm_open successful"); - return 0; -} - -static void udsl_atm_close (struct atm_vcc *vcc) -{ - struct udsl_instance_data *instance = vcc->dev->dev_data; - - dbg ("udsl_atm_close called"); - - if (!instance) { - dbg ("NULL instance!"); - return; - } - - /* freeing resources */ - /* cancel all sends on this vcc */ - udsl_cancel_send (instance, vcc); - - atmsar_close (&(instance->atmsar_vcc_list), vcc->dev_data); - vcc->dev_data = NULL; - clear_bit (ATM_VF_PARTIAL, &vcc->flags); - - /* freeing address */ - vcc->vpi = ATM_VPI_UNSPEC; - vcc->vci = ATM_VCI_UNSPEC; - clear_bit (ATM_VF_ADDR, &vcc->flags); - - MOD_DEC_USE_COUNT; - - dbg ("udsl_atm_close successful"); - return; -} - -static int udsl_atm_ioctl (struct atm_dev *dev, unsigned int cmd, void *arg) -{ - switch (cmd) { - case ATM_QUERYLOOP: - return put_user (ATM_LM_NONE, (int *) arg) ? -EFAULT : 0; - default: - return -ENOIOCTLCMD; - } -} - - -/************ -** USB ** -************/ - -static int udsl_usb_ioctl (struct usb_interface *intf, unsigned int code, void *user_data) -{ - struct udsl_instance_data *instance = usb_get_intfdata (intf); - - dbg ("udsl_usb_ioctl entered"); - - if (!instance) { - dbg ("NULL instance!"); - return -ENODEV; - } - - switch (code) { - case UDSL_IOCTL_START: - instance->atm_dev->signal = ATM_PHY_SIG_FOUND; - down (&instance->serialize); /* vs self */ - if (!instance->firmware_loaded) { - usb_set_interface (instance->usb_dev, 1, 1); - instance->firmware_loaded = 1; - } - up (&instance->serialize); - udsl_fire_receivers (instance); - return 0; - case UDSL_IOCTL_STOP: - instance->atm_dev->signal = ATM_PHY_SIG_LOST; - return 0; - default: - return -ENOTTY; - } -} - -static int udsl_usb_probe (struct usb_interface *intf, const struct usb_device_id *id) -{ - struct usb_device *dev = interface_to_usbdev(intf); - int ifnum = intf->altsetting->desc.bInterfaceNumber; - struct udsl_instance_data *instance; - unsigned char mac_str [13]; - int i, length; - char *buf; - - dbg ("Trying device with Vendor=0x%x, Product=0x%x, ifnum %d", - dev->descriptor.idVendor, dev->descriptor.idProduct, ifnum); - - if ((dev->descriptor.bDeviceClass != USB_CLASS_VENDOR_SPEC) || - (dev->descriptor.idVendor != SPEEDTOUCH_VENDORID) || - (dev->descriptor.idProduct != SPEEDTOUCH_PRODUCTID) || (ifnum != 1)) - return -ENODEV; - - dbg ("Device Accepted"); - - /* instance init */ - if (!(instance = kmalloc (sizeof (struct udsl_instance_data), GFP_KERNEL))) { - dbg ("No memory for Instance data!"); - return -ENOMEM; - } - - memset (instance, 0, sizeof (struct udsl_instance_data)); - - init_MUTEX (&instance->serialize); - - instance->usb_dev = dev; - - spin_lock_init (&instance->spare_receivers_lock); - INIT_LIST_HEAD (&instance->spare_receivers); - - spin_lock_init (&instance->completed_receivers_lock); - INIT_LIST_HEAD (&instance->completed_receivers); - - tasklet_init (&instance->receive_tasklet, udsl_process_receive, (unsigned long) instance); - - skb_queue_head_init (&instance->sndqueue); - - spin_lock_init (&instance->send_lock); - INIT_LIST_HEAD (&instance->spare_senders); - INIT_LIST_HEAD (&instance->spare_buffers); - - tasklet_init (&instance->send_tasklet, udsl_process_send, (unsigned long) instance); - INIT_LIST_HEAD (&instance->filled_buffers); - - /* receive init */ - for (i = 0; i < UDSL_NUMBER_RCV_URBS; i++) { - struct udsl_receiver *rcv = &(instance->all_receivers[i]); - - if (!(rcv->skb = dev_alloc_skb (UDSL_RCV_BUFFER_SIZE * ATM_CELL_SIZE))) { - dbg ("No memory for skb %d!", i); - goto fail; - } - - if (!(rcv->urb = usb_alloc_urb (0, GFP_KERNEL))) { - dbg ("No memory for receive urb %d!", i); - goto fail; - } - - rcv->instance = instance; - - list_add (&rcv->list, &instance->spare_receivers); - - dbg ("skb->truesize = %d (asked for %d)", rcv->skb->truesize, UDSL_RCV_BUFFER_SIZE * ATM_CELL_SIZE); - } - - /* send init */ - for (i = 0; i < UDSL_NUMBER_SND_URBS; i++) { - struct udsl_sender *snd = &(instance->all_senders[i]); - - if (!(snd->urb = usb_alloc_urb (0, GFP_KERNEL))) { - dbg ("No memory for send urb %d!", i); - goto fail; - } - - snd->instance = instance; - - list_add (&snd->list, &instance->spare_senders); - } - - for (i = 0; i < UDSL_NUMBER_SND_BUFS; i++) { - struct udsl_send_buffer *buf = &(instance->all_buffers[i]); - - if (!(buf->base = kmalloc (UDSL_SND_BUFFER_SIZE * ATM_CELL_SIZE, GFP_KERNEL))) { - dbg ("No memory for send buffer %d!", i); - goto fail; - } - - list_add (&buf->list, &instance->spare_buffers); - } - - /* atm init */ - if (!(instance->atm_dev = atm_dev_register (udsl_driver_name, &udsl_atm_devops, -1, 0))) { - dbg ("failed to register ATM device!"); - goto fail; - } - - instance->atm_dev->ci_range.vpi_bits = ATM_CI_MAX; - instance->atm_dev->ci_range.vci_bits = ATM_CI_MAX; - instance->atm_dev->signal = ATM_PHY_SIG_UNKNOWN; - - /* tmp init atm device, set to 128kbit */ - instance->atm_dev->link_rate = 128 * 1000 / 424; - - /* set MAC address, it is stored in the serial number */ - memset (instance->atm_dev->esi, 0, sizeof (instance->atm_dev->esi)); - if (usb_string (dev, dev->descriptor.iSerialNumber, mac_str, sizeof (mac_str)) == 12) - for (i = 0; i < 6; i++) - instance->atm_dev->esi[i] = (hex2int (mac_str[i * 2]) * 16) + (hex2int (mac_str[i * 2 + 1])); - - /* device description */ - buf = instance->description; - length = sizeof (instance->description); - - if ((i = usb_string (dev, dev->descriptor.iProduct, buf, length)) < 0) - goto finish; - - buf += i; - length -= i; - - i = snprintf (buf, length, " ("); - buf += i; - length -= i; - - if (length <= 0 || (i = usb_make_path (dev, buf, length)) < 0) - goto finish; - - buf += i; - length -= i; - - snprintf (buf, length, ")"); - -finish: - /* ready for ATM callbacks */ - instance->atm_dev->dev_data = instance; - - usb_set_intfdata (intf, instance); - - return 0; - -fail: - for (i = 0; i < UDSL_NUMBER_SND_BUFS; i++) - kfree (instance->all_buffers[i].base); - - for (i = 0; i < UDSL_NUMBER_SND_URBS; i++) - usb_free_urb (instance->all_senders[i].urb); - - for (i = 0; i < UDSL_NUMBER_RCV_URBS; i++) { - struct udsl_receiver *rcv = &(instance->all_receivers[i]); - - usb_free_urb (rcv->urb); - - if (rcv->skb) - kfree_skb (rcv->skb); - } - - kfree (instance); - - return -ENOMEM; -} - -static void udsl_usb_disconnect (struct usb_interface *intf) -{ - struct udsl_instance_data *instance = usb_get_intfdata (intf); - struct list_head *pos; - unsigned long flags; - unsigned int count = 0; - int result, i; - - dbg ("disconnecting"); - - usb_set_intfdata (intf, NULL); - - if (!instance) { - dbg ("NULL instance!"); - return; - } - - tasklet_disable (&instance->receive_tasklet); - - /* receive finalize */ - down (&instance->serialize); /* vs udsl_fire_receivers */ - /* no need to take the spinlock */ - list_for_each (pos, &instance->spare_receivers) - if (++count > UDSL_NUMBER_RCV_URBS) - panic (__FILE__ ": memory corruption detected at line %d!\n", __LINE__); - INIT_LIST_HEAD (&instance->spare_receivers); - up (&instance->serialize); - - dbg ("udsl_usb_disconnect: flushed %u spare receivers", count); - - count = UDSL_NUMBER_RCV_URBS - count; - - for (i = 0; i < UDSL_NUMBER_RCV_URBS; i++) - if ((result = usb_unlink_urb (instance->all_receivers[i].urb)) < 0) - dbg ("udsl_usb_disconnect: usb_unlink_urb on receive urb %d returned %d", i, result); - - /* wait for completion handlers to finish */ - do { - unsigned int completed = 0; - - spin_lock_irqsave (&instance->completed_receivers_lock, flags); - list_for_each (pos, &instance->completed_receivers) - if (++completed > count) - panic (__FILE__ ": memory corruption detected at line %d!\n", __LINE__); - spin_unlock_irqrestore (&instance->completed_receivers_lock, flags); - - dbg ("udsl_usb_disconnect: found %u completed receivers", completed); - - if (completed == count) - break; - - yield (); - } while (1); - - dbg ("udsl_usb_disconnect: flushing"); - /* no need to take the spinlock */ - INIT_LIST_HEAD (&instance->completed_receivers); - - tasklet_enable (&instance->receive_tasklet); - tasklet_kill (&instance->receive_tasklet); - - dbg ("udsl_usb_disconnect: freeing receivers"); - for (i = 0; i < UDSL_NUMBER_RCV_URBS; i++) { - struct udsl_receiver *rcv = &(instance->all_receivers[i]); - - usb_free_urb (rcv->urb); - kfree_skb (rcv->skb); - } - - /* send finalize */ - tasklet_disable (&instance->send_tasklet); - - for (i = 0; i < UDSL_NUMBER_SND_URBS; i++) - if ((result = usb_unlink_urb (instance->all_senders[i].urb)) < 0) - dbg ("udsl_usb_disconnect: usb_unlink_urb on send urb %d returned %d", i, result); - - /* wait for completion handlers to finish */ - do { - count = 0; - spin_lock_irqsave (&instance->send_lock, flags); - list_for_each (pos, &instance->spare_senders) - if (++count > UDSL_NUMBER_SND_URBS) - panic (__FILE__ ": memory corruption detected at line %d!\n", __LINE__); - spin_unlock_irqrestore (&instance->send_lock, flags); - - dbg ("udsl_usb_disconnect: found %u spare senders", count); - - if (count == UDSL_NUMBER_SND_URBS) - break; - - yield (); - } while (1); - - dbg ("udsl_usb_disconnect: flushing"); - /* no need to take the spinlock */ - INIT_LIST_HEAD (&instance->spare_senders); - INIT_LIST_HEAD (&instance->spare_buffers); - instance->current_buffer = NULL; - - tasklet_enable (&instance->send_tasklet); - - dbg ("udsl_usb_disconnect: freeing senders"); - for (i = 0; i < UDSL_NUMBER_SND_URBS; i++) - usb_free_urb (instance->all_senders[i].urb); - - dbg ("udsl_usb_disconnect: freeing buffers"); - for (i = 0; i < UDSL_NUMBER_SND_BUFS; i++) - kfree (instance->all_buffers[i].base); - - instance->usb_dev = NULL; - - /* atm finalize */ - shutdown_atm_dev (instance->atm_dev); /* frees instance */ -} - - -/*************************************************************************** -* -* Driver Init -* -****************************************************************************/ - -static int __init udsl_usb_init (void) -{ - struct sk_buff *skb; /* dummy for sizeof */ - - dbg ("udsl_usb_init: driver version " DRIVER_VERSION); - - if (sizeof (struct udsl_control) > sizeof (skb->cb)) { - printk (KERN_ERR __FILE__ ": unusable with this kernel!\n"); - return -EIO; - } - - return usb_register (&udsl_usb_driver); -} - -static void __exit udsl_usb_cleanup (void) -{ - dbg ("udsl_usb_cleanup"); - - usb_deregister (&udsl_usb_driver); -} - -module_init (udsl_usb_init); -module_exit (udsl_usb_cleanup); - -MODULE_AUTHOR (DRIVER_AUTHOR); -MODULE_DESCRIPTION (DRIVER_DESC); -MODULE_LICENSE ("GPL"); - - -#ifdef DEBUG_PACKET -/******************************************************************************* -* -* Debug -* -*******************************************************************************/ - -static int udsl_print_packet (const unsigned char *data, int len) -{ - unsigned char buffer [256]; - int i = 0, j = 0; - - for (i = 0; i < len;) { - buffer[0] = '\0'; - sprintf (buffer, "%.3d :", i); - for (j = 0; (j < 16) && (i < len); j++, i++) { - sprintf (buffer, "%s %2.2x", buffer, data[i]); - } - dbg ("%s", buffer); - } - return i; -} - -#endif /* PACKETDEBUG */ diff -Nru a/drivers/usb/net/cdc-ether.c b/drivers/usb/net/cdc-ether.c --- a/drivers/usb/net/cdc-ether.c Sun Mar 23 00:22:50 2003 +++ b/drivers/usb/net/cdc-ether.c Sun Mar 23 00:22:50 2003 @@ -1064,15 +1064,23 @@ // Used by driver's probe routine //////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -void log_device_info(ether_dev_t *ether_dev) +static void log_device_info(ether_dev_t *ether_dev) { int len; int string_num; - unsigned char manu[256]; - unsigned char prod[256]; - unsigned char sern[256]; + unsigned char *manu = NULL; + unsigned char *prod = NULL; + unsigned char *sern = NULL; unsigned char *mac_addr; + manu = kmalloc(256, GFP_KERNEL); + prod = kmalloc(256, GFP_KERNEL); + sern = kmalloc(256, GFP_KERNEL); + if (!manu || !prod || !sern) { + dbg("no mem for log_device_info"); + goto fini; + } + // Default empty strings in case we don't find a real one manu[0] = 0x00; prod[0] = 0x00; @@ -1113,6 +1121,10 @@ ether_dev->net->name, manu, prod, sern, mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5] ); +fini: + kfree(manu); + kfree(prod); + kfree(sern); } /* Forward declaration */ diff -Nru a/drivers/usb/net/pegasus.c b/drivers/usb/net/pegasus.c --- a/drivers/usb/net/pegasus.c Sun Mar 23 00:22:56 2003 +++ b/drivers/usb/net/pegasus.c Sun Mar 23 00:22:56 2003 @@ -121,7 +121,7 @@ char *buffer; DECLARE_WAITQUEUE(wait, current); - buffer = kmalloc(size, GFP_DMA); + buffer = kmalloc(size, GFP_KERNEL); if (!buffer) { warn("%s: looks like we're out of memory", __FUNCTION__); return -ENOMEM; @@ -170,7 +170,7 @@ char *buffer; DECLARE_WAITQUEUE(wait, current); - buffer = kmalloc(size, GFP_DMA); + buffer = kmalloc(size, GFP_KERNEL); if (!buffer) { warn("%s: looks like we're out of memory", __FUNCTION__); return -ENOMEM; @@ -218,7 +218,7 @@ char *tmp; DECLARE_WAITQUEUE(wait, current); - tmp = kmalloc(1, GFP_DMA); + tmp = kmalloc(1, GFP_KERNEL); if (!tmp) { warn("%s: looks like we're out of memory", __FUNCTION__); return -ENOMEM; diff -Nru a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c --- a/drivers/usb/serial/whiteheat.c Sun Mar 23 00:22:52 2003 +++ b/drivers/usb/serial/whiteheat.c Sun Mar 23 00:22:52 2003 @@ -783,7 +783,7 @@ if (info->mcr & UART_MCR_RTS) modem_signals |= TIOCM_RTS; - if (copy_to_user((unsigned int *)arg, &modem_signals, sizeof(unsigned int))); + if (copy_to_user((unsigned int *)arg, &modem_signals, sizeof(unsigned int))) return -EFAULT; break; diff -Nru a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c --- a/drivers/usb/usb-skeleton.c Sun Mar 23 00:22:52 2003 +++ b/drivers/usb/usb-skeleton.c Sun Mar 23 00:22:52 2003 @@ -1,5 +1,5 @@ /* - * USB Skeleton driver - 0.9 + * USB Skeleton driver - 1.0 * * Copyright (c) 2001-2002 Greg Kroah-Hartman (greg@kroah.com) * @@ -12,14 +12,17 @@ * USB driver quickly. The design of it is based on the usb-serial and * dc2xx drivers. * - * Thanks to Oliver Neukum and David Brownell for their help in debugging - * this driver. + * Thanks to Oliver Neukum, David Brownell, and Alan Stern for their help + * in debugging this driver. * - * TODO: - * - fix urb->status race condition in write sequence * * History: * + * 2003-02-25 - 1.0 - fix races involving urb->status, unlink_urb(), and + * disconnect. Fix transfer amount in read(). Use + * macros instead of magic numbers in probe(). Change + * size variables to size_t. Show how to eliminate + * DMA bounce buffer. * 2002_12_12 - 0.9 - compile fixes and got rid of fixed minor array. * 2002_09_26 - 0.8 - changes due to USB core conversion to struct device * driver. @@ -33,7 +36,7 @@ * 2001_05_29 - 0.3 - more bug fixes based on review from linux-usb-devel * 2001_05_24 - 0.2 - bug fixes based on review from linux-usb-devel people * 2001_05_01 - 0.1 - first version - * + * */ #include @@ -42,8 +45,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -60,7 +63,7 @@ /* Version Information */ -#define DRIVER_VERSION "v0.4" +#define DRIVER_VERSION "v1.0" #define DRIVER_AUTHOR "Greg Kroah-Hartman, greg@kroah.com" #define DRIVER_DESC "USB Skeleton Driver" @@ -101,15 +104,16 @@ char num_bulk_out; /* number of bulk out endpoints we have */ unsigned char * bulk_in_buffer; /* the buffer to receive data */ - int bulk_in_size; /* the size of the receive buffer */ + size_t bulk_in_size; /* the size of the receive buffer */ __u8 bulk_in_endpointAddr; /* the address of the bulk in endpoint */ unsigned char * bulk_out_buffer; /* the buffer to send data */ - int bulk_out_size; /* the size of the send buffer */ + size_t bulk_out_size; /* the size of the send buffer */ struct urb * write_urb; /* the urb used to send data */ __u8 bulk_out_endpointAddr; /* the address of the bulk out endpoint */ + atomic_t write_busy; /* true iff write urb is busy */ + struct completion write_finished; /* wait for the write to finish */ - struct work_struct work; /* work queue entry for line discipline waking up */ int open; /* if the port is open or not */ struct semaphore sem; /* locks this structure */ }; @@ -118,6 +122,8 @@ /* the global usb devfs handle */ extern devfs_handle_t usb_devfs_handle; +/* prevent races between open() and disconnect() */ +static DECLARE_MUTEX (disconnect_sem); /* local function prototypes */ static ssize_t skel_read (struct file *file, char *buffer, size_t count, loff_t *ppos); @@ -125,7 +131,7 @@ static int skel_ioctl (struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg); static int skel_open (struct inode *inode, struct file *file); static int skel_release (struct inode *inode, struct file *file); - + static int skel_probe (struct usb_interface *intf, const struct usb_device_id *id); static void skel_disconnect (struct usb_interface *intf); @@ -138,7 +144,7 @@ * to have a node in the /dev directory. If the USB * device were for a network interface then the driver * would use "struct net_driver" instead, and a serial - * device would use "struct tty_driver". + * device would use "struct tty_driver". */ static struct file_operations skel_fops = { /* @@ -167,7 +173,7 @@ .ioctl = skel_ioctl, .open = skel_open, .release = skel_release, -}; +}; /* usb specific object needed to register this driver with the usb subsystem */ @@ -188,8 +194,8 @@ if (!debug) return; - - printk (KERN_DEBUG __FILE__": %s - length = %d, data = ", + + printk (KERN_DEBUG __FILE__": %s - length = %d, data = ", function, size); for (i = 0; i < size; ++i) { printk ("%.2x ", data[i]); @@ -206,7 +212,9 @@ if (dev->bulk_in_buffer != NULL) kfree (dev->bulk_in_buffer); if (dev->bulk_out_buffer != NULL) - kfree (dev->bulk_out_buffer); + usb_buffer_free (dev->udev, dev->bulk_out_size, + dev->bulk_out_buffer, + dev->write_urb->transfer_dma); if (dev->write_urb != NULL) usb_free_urb (dev->write_urb); kfree (dev); @@ -222,22 +230,28 @@ struct usb_interface *interface; int subminor; int retval = 0; - + dbg("%s", __FUNCTION__); subminor = minor (inode->i_rdev); + /* prevent disconnects */ + down (&disconnect_sem); + interface = usb_find_interface (&skel_driver, mk_kdev(USB_MAJOR, subminor)); if (!interface) { err ("%s - error, can't find device for minor %d", __FUNCTION__, subminor); - return -ENODEV; + retval = -ENODEV; + goto exit_no_device; } - + dev = usb_get_intfdata(interface); - if (!dev) - return -ENODEV; + if (!dev) { + retval = -ENODEV; + goto exit_no_device; + } /* lock this device */ down (&dev->sem); @@ -251,6 +265,8 @@ /* unlock this device */ up (&dev->sem); +exit_no_device: + up (&disconnect_sem); return retval; } @@ -280,6 +296,12 @@ goto exit_not_opened; } + /* wait for any bulk writes that might be going on to finish up */ + if (atomic_read (&dev->write_busy)) + wait_for_completion (&dev->write_finished); + + dev->open = 0; + if (dev->udev == NULL) { /* the device was unplugged before the file was released */ up (&dev->sem); @@ -287,11 +309,6 @@ return 0; } - /* shutdown any bulk writes that might be going on */ - usb_unlink_urb (dev->write_urb); - - dev->open = 0; - exit_not_opened: up (&dev->sem); @@ -308,7 +325,7 @@ int retval = 0; dev = (struct usb_skel *)file->private_data; - + dbg("%s - minor %d, count = %d", __FUNCTION__, dev->minor, count); /* lock this object */ @@ -319,12 +336,13 @@ up (&dev->sem); return -ENODEV; } - - /* do an immediate bulk read to get data from the device */ + + /* do a blocking bulk read to get data from the device */ retval = usb_bulk_msg (dev->udev, - usb_rcvbulkpipe (dev->udev, + usb_rcvbulkpipe (dev->udev, dev->bulk_in_endpointAddr), - dev->bulk_in_buffer, dev->bulk_in_size, + dev->bulk_in_buffer, + min (dev->bulk_in_size, count), &count, HZ*10); /* if the read was successful, copy the data to userspace */ @@ -334,7 +352,7 @@ else retval = count; } - + /* unlock the device */ up (&dev->sem); return retval; @@ -343,6 +361,18 @@ /** * skel_write + * + * A device driver has to decide how to report I/O errors back to the + * user. The safest course is to wait for the transfer to finish before + * returning so that any errors will be reported reliably. skel_read() + * works like this. But waiting for I/O is slow, so many drivers only + * check for errors during I/O initiation and do not report problems + * that occur during the actual transfer. That's what we will do here. + * + * A driver concerned with maximum I/O throughput would use double- + * buffering: Two urbs would be devoted to write transfers, so that + * one urb could always be active while the other was waiting for the + * user to send more data. */ static ssize_t skel_write (struct file *file, const char *buffer, size_t count, loff_t *ppos) { @@ -369,37 +399,38 @@ goto exit; } - /* see if we are already in the middle of a write */ - if (dev->write_urb->status == -EINPROGRESS) { - dbg ("%s - already writing", __FUNCTION__); - goto exit; - } + /* wait for a previous write to finish up; we don't use a timeout + * and so a nonresponsive device can delay us indefinitely. + */ + if (atomic_read (&dev->write_busy)) + wait_for_completion (&dev->write_finished); - /* we can only write as much as 1 urb will hold */ - bytes_written = (count > dev->bulk_out_size) ? - dev->bulk_out_size : count; + /* we can only write as much as our buffer will hold */ + bytes_written = min (dev->bulk_out_size, count); - /* copy the data from userspace into our urb */ - if (copy_from_user(dev->write_urb->transfer_buffer, buffer, + /* copy the data from userspace into our transfer buffer; + * this is the only copy required. + */ + if (copy_from_user(dev->write_urb->transfer_buffer, buffer, bytes_written)) { retval = -EFAULT; goto exit; } - usb_skel_debug_data (__FUNCTION__, bytes_written, + usb_skel_debug_data (__FUNCTION__, bytes_written, dev->write_urb->transfer_buffer); - /* set up our urb */ - usb_fill_bulk_urb(dev->write_urb, dev->udev, - usb_sndbulkpipe(dev->udev, dev->bulk_out_endpointAddr), - dev->write_urb->transfer_buffer, bytes_written, - skel_write_bulk_callback, dev); + /* this urb was already set up, except for this write size */ + dev->write_urb->transfer_buffer_length = bytes_written; /* send the data out the bulk port */ /* a character device write uses GFP_KERNEL, unless a spinlock is held */ + init_completion (&dev->write_finished); + atomic_set (&dev->write_busy, 1); retval = usb_submit_urb(dev->write_urb, GFP_KERNEL); if (retval) { + atomic_set (&dev->write_busy, 0); err("%s - failed submitting write urb, error %d", __FUNCTION__, retval); } else { @@ -435,12 +466,11 @@ dbg("%s - minor %d, cmd 0x%.4x, arg %ld", __FUNCTION__, dev->minor, cmd, arg); - /* fill in your device specific stuff here */ - + /* unlock the device */ up (&dev->sem); - + /* return that we did not understand this ioctl call */ return -ENOTTY; } @@ -455,14 +485,16 @@ dbg("%s - minor %d", __FUNCTION__, dev->minor); - if ((urb->status != -ENOENT) && - (urb->status != -ECONNRESET)) { + /* sync/async unlink faults aren't errors */ + if (urb->status && !(urb->status == -ENOENT || + urb->status == -ECONNRESET)) { dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status); - return; } - return; + /* notify anyone waiting that the write has finished */ + atomic_set (&dev->write_busy, 0); + complete (&dev->write_finished); } @@ -479,12 +511,12 @@ struct usb_host_interface *iface_desc; struct usb_endpoint_descriptor *endpoint; int minor; - int buffer_size; + size_t buffer_size; int i; int retval; char name[10]; - + /* See if the device offered us matches what we can accept */ if ((udev->descriptor.idVendor != USB_SKEL_VENDOR_ID) || (udev->descriptor.idProduct != USB_SKEL_PRODUCT_ID)) { @@ -513,12 +545,15 @@ /* set up the endpoint information */ /* check out the endpoints */ + /* use only the first bulk-in and bulk-out endpoints */ iface_desc = &interface->altsetting[0]; for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { endpoint = &iface_desc->endpoint[i].desc; - if ((endpoint->bEndpointAddress & 0x80) && - ((endpoint->bmAttributes & 3) == 0x02)) { + if (!dev->bulk_in_endpointAddr && + (endpoint->bEndpointAddress & USB_DIR_IN) && + ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) + == USB_ENDPOINT_XFER_BULK)) { /* we found a bulk in endpoint */ buffer_size = endpoint->wMaxPacketSize; dev->bulk_in_size = buffer_size; @@ -529,9 +564,11 @@ goto error; } } - - if (((endpoint->bEndpointAddress & 0x80) == 0x00) && - ((endpoint->bmAttributes & 3) == 0x02)) { + + if (!dev->bulk_out_endpointAddr && + !(endpoint->bEndpointAddress & USB_DIR_IN) && + ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) + == USB_ENDPOINT_XFER_BULK)) { /* we found a bulk out endpoint */ /* a probe() may sleep and has no restrictions on memory allocations */ dev->write_urb = usb_alloc_urb(0, GFP_KERNEL); @@ -539,40 +576,56 @@ err("No free urbs available"); goto error; } + dev->bulk_out_endpointAddr = endpoint->bEndpointAddress; + + /* on some platforms using this kind of buffer alloc + * call eliminates a dma "bounce buffer". + * + * NOTE: you'd normally want i/o buffers that hold + * more than one packet, so that i/o delays between + * packets don't hurt throughput. + */ buffer_size = endpoint->wMaxPacketSize; dev->bulk_out_size = buffer_size; - dev->bulk_out_endpointAddr = endpoint->bEndpointAddress; - dev->bulk_out_buffer = kmalloc (buffer_size, GFP_KERNEL); + dev->write_urb->transfer_flags = (URB_NO_DMA_MAP | + URB_ASYNC_UNLINK); + dev->bulk_out_buffer = usb_buffer_alloc (udev, + buffer_size, GFP_KERNEL, + &dev->write_urb->transfer_dma); if (!dev->bulk_out_buffer) { err("Couldn't allocate bulk_out_buffer"); goto error; } - usb_fill_bulk_urb(dev->write_urb, udev, - usb_sndbulkpipe(udev, + usb_fill_bulk_urb(dev->write_urb, udev, + usb_sndbulkpipe(udev, endpoint->bEndpointAddress), dev->bulk_out_buffer, buffer_size, skel_write_bulk_callback, dev); } } + if (!(dev->bulk_in_endpointAddr && dev->bulk_out_endpointAddr)) { + err("Couldn't find both bulk-in and bulk-out endpoints"); + goto error; + } /* initialize the devfs node for this device and register it */ sprintf(name, "skel%d", dev->minor); - + dev->devfs = devfs_register (usb_devfs_handle, name, DEVFS_FL_DEFAULT, USB_MAJOR, dev->minor, - S_IFCHR | S_IRUSR | S_IWUSR | - S_IRGRP | S_IWGRP | S_IROTH, + S_IFCHR | S_IRUSR | S_IWUSR | + S_IRGRP | S_IWGRP | S_IROTH, &skel_fops, NULL); /* let the user know what node this device is now attached to */ - info ("USB Skeleton device now attached to USBSkel%d", dev->minor); + info ("USB Skeleton device now attached to USBSkel-%d", dev->minor); /* add device id so the device works when advertised */ interface->kdev = mk_kdev(USB_MAJOR, dev->minor); goto exit; - + error: skel_delete (dev); dev = NULL; @@ -593,12 +646,21 @@ * skel_disconnect * * Called by the usb core when the device is removed from the system. + * + * This routine guarantees that the driver will not submit any more urbs + * by clearing dev->udev. It is also supposed to terminate any currently + * active urbs. Unfortunately, usb_bulk_msg(), used in skel_read(), does + * not provide any way to do this. But at least we can cancel an active + * write. */ static void skel_disconnect(struct usb_interface *interface) { struct usb_skel *dev; int minor; + /* prevent races with open() */ + down (&disconnect_sem); + dev = usb_get_intfdata (interface); usb_set_intfdata (interface, NULL); @@ -606,7 +668,7 @@ return; down (&dev->sem); - + /* remove device id to disable open() */ interface->kdev = NODEV; @@ -617,15 +679,21 @@ /* give back our dynamic minor */ usb_deregister_dev (1, minor); - + + /* terminate an ongoing write */ + if (atomic_read (&dev->write_busy)) { + usb_unlink_urb (dev->write_urb); + wait_for_completion (&dev->write_finished); + } + + dev->udev = NULL; + up (&dev->sem); + /* if the device is not opened, then we clean up right now */ - if (!dev->open) { - up (&dev->sem); + if (!dev->open) skel_delete (dev); - } else { - dev->udev = NULL; - up (&dev->sem); - } + + up (&disconnect_sem); info("USB Skeleton #%d now disconnected", minor); } @@ -668,4 +736,3 @@ MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); MODULE_LICENSE("GPL"); - diff -Nru a/drivers/video/Kconfig b/drivers/video/Kconfig --- a/drivers/video/Kconfig Sun Mar 23 00:22:50 2003 +++ b/drivers/video/Kconfig Sun Mar 23 00:22:50 2003 @@ -38,7 +38,7 @@ (e.g. an accelerated X server) and that are not frame buffer device-aware may cause unexpected results. If unsure, say N. -config FB_CLGEN +config FB_CIRRUS tristate "Cirrus Logic support" depends on FB && (AMIGA || PCI) ---help--- @@ -48,7 +48,7 @@ If you have a PCI-based system, this enables support for these chips: GD-543x, GD-544x, GD-5480. - Please read the file . + Please read the file . Say N unless you have such a graphics board or plan to get one before you next recompile the kernel. @@ -282,7 +282,7 @@ If you have a S3 Trio say Y. Say N for S3 Virge. config FB_VGA16 - tristate "VGA 16-color graphics console" + tristate "VGA 16-color graphics support" depends on FB && (X86 || PPC) help This is the frame buffer device driver for VGA 16 color graphic @@ -329,7 +329,7 @@ cards. Say Y if you have one of those. config FB_VESA - bool "VESA VGA graphics console" + bool "VESA VGA graphics support" depends on FB && (X86 || X86_64) help This is the frame buffer device driver for generic VESA 2.0 @@ -343,7 +343,7 @@ default y config FB_HGA - tristate "Hercules mono graphics console" + tristate "Hercules mono graphics support" depends on FB && X86 help Say Y here if you have a Hercules mono graphics card. @@ -715,6 +715,12 @@ is at . +config FB_ATY_XL_INIT + bool " Rage XL No-BIOS Init support" if FB_ATY_CT + depends on FB_ATY + help + Say Y here to support booting a Rage XL without BIOS support. + config FB_SIS tristate "SIS acceleration" depends on FB && PCI @@ -921,8 +927,13 @@ say M here and read . If unsure, say N. - -source "drivers/video/console/Kconfig" +if VT + source "drivers/video/console/Kconfig" +endif + +if FB || SGI_NEWPORT_CONSOLE + source "drivers/video/logo/Kconfig" +endif endmenu diff -Nru a/drivers/video/Makefile b/drivers/video/Makefile --- a/drivers/video/Makefile Sun Mar 23 00:22:50 2003 +++ b/drivers/video/Makefile Sun Mar 23 00:22:50 2003 @@ -5,6 +5,7 @@ # Each configuration option enables a list of files. obj-$(CONFIG_VT) += console/ +obj-$(CONFIG_LOGO) += logo/ obj-$(CONFIG_FB) += fbmem.o fbmon.o fbcmap.o modedb.o softcursor.o # Only include macmodes.o if we have FB support and are PPC @@ -13,14 +14,13 @@ endif obj-$(CONFIG_FB_ACORN) += acornfb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o -obj-$(CONFIG_FB_AMIGA) += amifb.o +obj-$(CONFIG_FB_AMIGA) += amifb.o c2p.o obj-$(CONFIG_FB_PM2) += pm2fb.o obj-$(CONFIG_FB_PM3) += pm3fb.o obj-$(CONFIG_FB_APOLLO) += dnfb.o cfbfillrect.o cfbimgblt.o obj-$(CONFIG_FB_Q40) += q40fb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o obj-$(CONFIG_FB_ATARI) += atafb.o obj-$(CONFIG_FB_68328) += 68328fb.o -obj-$(CONFIG_FB_ATY128) += aty128fb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o obj-$(CONFIG_FB_RADEON) += radeonfb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o obj-$(CONFIG_FB_NEOMAGIC) += neofb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o obj-$(CONFIG_FB_IGA) += igafb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o @@ -37,9 +37,9 @@ obj-$(CONFIG_FB_MAC) += macfb.o macmodes.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o obj-$(CONFIG_FB_HP300) += hpfb.o cfbfillrect.o cfbimgblt.o obj-$(CONFIG_FB_OF) += offb.o cfbfillrect.o cfbimgblt.o cfbcopyarea.o -obj-$(CONFIG_FB_IMSTT) += imsttfb.o +obj-$(CONFIG_FB_IMSTT) += imsttfb.o cfbimgblt.o obj-$(CONFIG_FB_RETINAZ3) += retz3fb.o -obj-$(CONFIG_FB_CLGEN) += clgenfb.o +obj-$(CONFIG_FB_CIRRUS) += cirrusfb.o obj-$(CONFIG_FB_TRIDENT) += tridentfb.o cfbfillrect.o cfbimgblt.o cfbcopyarea.o obj-$(CONFIG_FB_S3TRIO) += S3triofb.o obj-$(CONFIG_FB_TGA) += tgafb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o @@ -57,8 +57,9 @@ obj-$(CONFIG_FB_MATROX) += matrox/ obj-$(CONFIG_FB_RIVA) += riva/ cfbimgblt.o vgastate.o -obj-$(CONFIG_FB_SIS) += sis/ -obj-$(CONFIG_FB_ATY) += aty/ cfbimgblt.o cfbfillrect.o cfbimgblt.o +obj-$(CONFIG_FB_SIS) += sis/ cfbcopyarea.o cfbfillrect.o cfbimgblt.o +obj-$(CONFIG_FB_ATY) += aty/ cfbcopyarea.o cfbfillrect.o cfbimgblt.o +obj-$(CONFIG_FB_ATY128) += aty/ cfbcopyarea.o cfbfillrect.o cfbimgblt.o obj-$(CONFIG_FB_I810) += i810/ cfbfillrect.o cfbcopyarea.o \ cfbimgblt.o vgastate.o @@ -85,12 +86,4 @@ cfbfillrect.o obj-$(CONFIG_FB_LEO) += leo.o sbuslib.o cfbimgblt.o cfbcopyarea.o \ cfbfillrect.o - -# Files generated that shall be removed upon make clean -clean-files := promcon_tbl.c - -$(obj)/promcon_tbl.c: $(src)/prom.uni - $(objtree)/scripts/conmakehash $< | \ - sed -e '/#include <[^>]*>/p' -e 's/types/init/' \ - -e 's/dfont\(_uni.*\]\)/promfont\1 __initdata/' > $@ diff -Nru a/drivers/video/amifb.c b/drivers/video/amifb.c --- a/drivers/video/amifb.c Sun Mar 23 00:22:55 2003 +++ b/drivers/video/amifb.c Sun Mar 23 00:22:55 2003 @@ -1,7 +1,7 @@ /* * linux/drivers/video/amifb.c -- Amiga builtin chipset frame buffer device * - * Copyright (C) 1995 Geert Uytterhoeven + * Copyright (C) 1995-2003 Geert Uytterhoeven * * with work by Roman Zippel * @@ -52,7 +52,6 @@ #include #include #include -#include #include #include @@ -62,10 +61,7 @@ #include #include -#include