aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor@insightbb.com>2006-12-08 01:07:56 -0500
committerDmitry Torokhov <dtor@insightbb.com>2006-12-08 01:07:56 -0500
commitbef986502fa398b1785a3979b1aa17cd902d3527 (patch)
treeb59c1afe7b1dfcc001b86e54863f550d7ddc8c34 /drivers
parent4bdbd2807deeccc0793d57fb5120d7a53f2c0b3c (diff)
parentc99767974ebd2a719d849fdeaaa1674456f5283f (diff)
Merge rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Conflicts: drivers/usb/input/hid.h
Diffstat (limited to 'drivers')
-rw-r--r--drivers/Makefile1
-rw-r--r--drivers/acpi/dock.c1
-rw-r--r--drivers/acpi/glue.c20
-rw-r--r--drivers/acpi/osl.c41
-rw-r--r--drivers/acpi/processor_perflib.c4
-rw-r--r--drivers/amba/bus.c113
-rw-r--r--drivers/ata/Kconfig35
-rw-r--r--drivers/ata/Makefile4
-rw-r--r--drivers/ata/ahci.c239
-rw-r--r--drivers/ata/ata_generic.c12
-rw-r--r--drivers/ata/ata_piix.c194
-rw-r--r--drivers/ata/libata-core.c566
-rw-r--r--drivers/ata/libata-eh.c110
-rw-r--r--drivers/ata/libata-scsi.c365
-rw-r--r--drivers/ata/libata-sff.c43
-rw-r--r--drivers/ata/libata.h28
-rw-r--r--drivers/ata/pata_ali.c141
-rw-r--r--drivers/ata/pata_amd.c27
-rw-r--r--drivers/ata/pata_artop.c4
-rw-r--r--drivers/ata/pata_atiixp.c10
-rw-r--r--drivers/ata/pata_cmd64x.c24
-rw-r--r--drivers/ata/pata_cs5520.c26
-rw-r--r--drivers/ata/pata_cs5530.c101
-rw-r--r--drivers/ata/pata_cs5535.c10
-rw-r--r--drivers/ata/pata_cypress.c10
-rw-r--r--drivers/ata/pata_efar.c8
-rw-r--r--drivers/ata/pata_hpt366.c59
-rw-r--r--drivers/ata/pata_hpt37x.c21
-rw-r--r--drivers/ata/pata_hpt3x2n.c2
-rw-r--r--drivers/ata/pata_hpt3x3.c48
-rw-r--r--drivers/ata/pata_isapnp.c2
-rw-r--r--drivers/ata/pata_it821x.c20
-rw-r--r--drivers/ata/pata_ixp4xx_cf.c271
-rw-r--r--drivers/ata/pata_jmicron.c37
-rw-r--r--drivers/ata/pata_legacy.c2
-rw-r--r--drivers/ata/pata_marvell.c224
-rw-r--r--drivers/ata/pata_mpiix.c10
-rw-r--r--drivers/ata/pata_netcell.c9
-rw-r--r--drivers/ata/pata_ns87410.c10
-rw-r--r--drivers/ata/pata_oldpiix.c6
-rw-r--r--drivers/ata/pata_opti.c35
-rw-r--r--drivers/ata/pata_optidma.c10
-rw-r--r--drivers/ata/pata_pcmcia.c17
-rw-r--r--drivers/ata/pata_pdc2027x.c4
-rw-r--r--drivers/ata/pata_pdc202xx_old.c66
-rw-r--r--drivers/ata/pata_platform.c295
-rw-r--r--drivers/ata/pata_qdi.c2
-rw-r--r--drivers/ata/pata_radisys.c6
-rw-r--r--drivers/ata/pata_rz1000.c50
-rw-r--r--drivers/ata/pata_sc1200.c10
-rw-r--r--drivers/ata/pata_serverworks.c34
-rw-r--r--drivers/ata/pata_sil680.c84
-rw-r--r--drivers/ata/pata_sis.c8
-rw-r--r--drivers/ata/pata_sl82c105.c2
-rw-r--r--drivers/ata/pata_triflex.c10
-rw-r--r--drivers/ata/pata_via.c110
-rw-r--r--drivers/ata/pata_winbond.c306
-rw-r--r--drivers/ata/sata_nv.c1044
-rw-r--r--drivers/ata/sata_promise.c164
-rw-r--r--drivers/ata/sata_sil.c16
-rw-r--r--drivers/ata/sata_sil24.c18
-rw-r--r--drivers/ata/sata_sis.c17
-rw-r--r--drivers/ata/sata_via.c2
-rw-r--r--drivers/atm/Makefile2
-rw-r--r--drivers/atm/ambassador.c2
-rw-r--r--drivers/atm/firestream.c2
-rw-r--r--drivers/atm/he.c6
-rw-r--r--drivers/atm/idt77252.c9
-rw-r--r--drivers/atm/iphase.c2
-rw-r--r--drivers/base/bus.c34
-rw-r--r--drivers/base/class.c166
-rw-r--r--drivers/base/core.c242
-rw-r--r--drivers/base/cpu.c7
-rw-r--r--drivers/base/dd.c92
-rw-r--r--drivers/base/dmapool.c4
-rw-r--r--drivers/base/firmware_class.c119
-rw-r--r--drivers/base/memory.c34
-rw-r--r--drivers/base/platform.c48
-rw-r--r--drivers/base/topology.c53
-rw-r--r--drivers/block/DAC960.c4
-rw-r--r--drivers/block/Kconfig4
-rw-r--r--drivers/block/aoe/aoe.h2
-rw-r--r--drivers/block/aoe/aoeblk.c3
-rw-r--r--drivers/block/aoe/aoecmd.c4
-rw-r--r--drivers/block/aoe/aoedev.c2
-rw-r--r--drivers/block/cciss.c338
-rw-r--r--drivers/block/cciss.h6
-rw-r--r--drivers/block/cciss_cmd.h3
-rw-r--r--drivers/block/cpqarray.c15
-rw-r--r--drivers/block/floppy.c10
-rw-r--r--drivers/block/nbd.c16
-rw-r--r--drivers/block/paride/aten.c4
-rw-r--r--drivers/block/paride/bpck.c4
-rw-r--r--drivers/block/paride/bpck6.c17
-rw-r--r--drivers/block/paride/comm.c4
-rw-r--r--drivers/block/paride/dstr.c4
-rw-r--r--drivers/block/paride/epat.c4
-rw-r--r--drivers/block/paride/epia.c4
-rw-r--r--drivers/block/paride/fit2.c4
-rw-r--r--drivers/block/paride/fit3.c4
-rw-r--r--drivers/block/paride/friq.c4
-rw-r--r--drivers/block/paride/frpw.c4
-rw-r--r--drivers/block/paride/jumbo70
-rw-r--r--drivers/block/paride/kbic.c14
-rw-r--r--drivers/block/paride/ktti.c4
-rw-r--r--drivers/block/paride/on20.c4
-rw-r--r--drivers/block/paride/on26.c4
-rw-r--r--drivers/block/paride/paride.c47
-rw-r--r--drivers/block/paride/paride.h4
-rw-r--r--drivers/block/paride/pcd.c8
-rw-r--r--drivers/block/paride/pd.c8
-rw-r--r--drivers/block/paride/pf.c8
-rw-r--r--drivers/block/paride/pg.c4
-rw-r--r--drivers/block/paride/pseudo.h10
-rw-r--r--drivers/block/paride/pt.c4
-rw-r--r--drivers/block/pktcdvd.c2
-rw-r--r--drivers/block/sx8.c7
-rw-r--r--drivers/block/ub.c8
-rw-r--r--drivers/block/viodasd.c49
-rw-r--r--drivers/bluetooth/bcm203x.c7
-rw-r--r--drivers/bluetooth/bluecard_cs.c38
-rw-r--r--drivers/bluetooth/bt3c_cs.c20
-rw-r--r--drivers/bluetooth/btuart_cs.c20
-rw-r--r--drivers/bluetooth/dtl1_cs.c20
-rw-r--r--drivers/bluetooth/hci_bcsp.c4
-rw-r--r--drivers/cdrom/cdrom.c6
-rw-r--r--drivers/cdrom/optcd.c2
-rw-r--r--drivers/cdrom/sbpcd.c5
-rw-r--r--drivers/char/Kconfig43
-rw-r--r--drivers/char/Makefile1
-rw-r--r--drivers/char/agp/amd64-agp.c2
-rw-r--r--drivers/char/agp/generic.c2
-rw-r--r--drivers/char/agp/intel-agp.c33
-rw-r--r--drivers/char/cyclades.c9
-rw-r--r--drivers/char/decserial.c38
-rw-r--r--drivers/char/drm/drm_sman.c1
-rw-r--r--drivers/char/drm/drm_vm.c8
-rw-r--r--drivers/char/drm/via_dmablit.c6
-rw-r--r--drivers/char/epca.c8
-rw-r--r--drivers/char/esp.c14
-rw-r--r--drivers/char/ftape/Kconfig330
-rw-r--r--drivers/char/ftape/Makefile28
-rw-r--r--drivers/char/ftape/README.PCI81
-rw-r--r--drivers/char/ftape/RELEASE-NOTES966
-rw-r--r--drivers/char/ftape/compressor/Makefile31
-rw-r--r--drivers/char/ftape/compressor/lzrw3.c743
-rw-r--r--drivers/char/ftape/compressor/lzrw3.h253
-rw-r--r--drivers/char/ftape/compressor/zftape-compress.c1203
-rw-r--r--drivers/char/ftape/compressor/zftape-compress.h83
-rw-r--r--drivers/char/ftape/lowlevel/Makefile43
-rw-r--r--drivers/char/ftape/lowlevel/fc-10.c175
-rw-r--r--drivers/char/ftape/lowlevel/fc-10.h39
-rw-r--r--drivers/char/ftape/lowlevel/fdc-io.c1349
-rw-r--r--drivers/char/ftape/lowlevel/fdc-io.h252
-rw-r--r--drivers/char/ftape/lowlevel/fdc-isr.c1170
-rw-r--r--drivers/char/ftape/lowlevel/fdc-isr.h55
-rw-r--r--drivers/char/ftape/lowlevel/ftape-bsm.c491
-rw-r--r--drivers/char/ftape/lowlevel/ftape-bsm.h66
-rw-r--r--drivers/char/ftape/lowlevel/ftape-buffer.c130
-rw-r--r--drivers/char/ftape/lowlevel/ftape-buffer.h32
-rw-r--r--drivers/char/ftape/lowlevel/ftape-calibr.c275
-rw-r--r--drivers/char/ftape/lowlevel/ftape-calibr.h37
-rw-r--r--drivers/char/ftape/lowlevel/ftape-ctl.c896
-rw-r--r--drivers/char/ftape/lowlevel/ftape-ctl.h162
-rw-r--r--drivers/char/ftape/lowlevel/ftape-ecc.c853
-rw-r--r--drivers/char/ftape/lowlevel/ftape-ecc.h84
-rw-r--r--drivers/char/ftape/lowlevel/ftape-format.c344
-rw-r--r--drivers/char/ftape/lowlevel/ftape-format.h37
-rw-r--r--drivers/char/ftape/lowlevel/ftape-init.c160
-rw-r--r--drivers/char/ftape/lowlevel/ftape-init.h43
-rw-r--r--drivers/char/ftape/lowlevel/ftape-io.c992
-rw-r--r--drivers/char/ftape/lowlevel/ftape-io.h90
-rw-r--r--drivers/char/ftape/lowlevel/ftape-proc.c214
-rw-r--r--drivers/char/ftape/lowlevel/ftape-proc.h35
-rw-r--r--drivers/char/ftape/lowlevel/ftape-read.c621
-rw-r--r--drivers/char/ftape/lowlevel/ftape-read.h51
-rw-r--r--drivers/char/ftape/lowlevel/ftape-rw.c1092
-rw-r--r--drivers/char/ftape/lowlevel/ftape-rw.h111
-rw-r--r--drivers/char/ftape/lowlevel/ftape-setup.c104
-rw-r--r--drivers/char/ftape/lowlevel/ftape-tracing.c118
-rw-r--r--drivers/char/ftape/lowlevel/ftape-tracing.h179
-rw-r--r--drivers/char/ftape/lowlevel/ftape-write.c336
-rw-r--r--drivers/char/ftape/lowlevel/ftape-write.h53
-rw-r--r--drivers/char/ftape/lowlevel/ftape_syms.c87
-rw-r--r--drivers/char/ftape/zftape/Makefile36
-rw-r--r--drivers/char/ftape/zftape/zftape-buffers.c149
-rw-r--r--drivers/char/ftape/zftape/zftape-buffers.h55
-rw-r--r--drivers/char/ftape/zftape/zftape-ctl.c1417
-rw-r--r--drivers/char/ftape/zftape/zftape-ctl.h58
-rw-r--r--drivers/char/ftape/zftape/zftape-eof.c199
-rw-r--r--drivers/char/ftape/zftape/zftape-eof.h52
-rw-r--r--drivers/char/ftape/zftape/zftape-init.c377
-rw-r--r--drivers/char/ftape/zftape/zftape-init.h77
-rw-r--r--drivers/char/ftape/zftape/zftape-read.c377
-rw-r--r--drivers/char/ftape/zftape/zftape-read.h53
-rw-r--r--drivers/char/ftape/zftape/zftape-rw.c375
-rw-r--r--drivers/char/ftape/zftape/zftape-rw.h101
-rw-r--r--drivers/char/ftape/zftape/zftape-vtbl.c757
-rw-r--r--drivers/char/ftape/zftape/zftape-vtbl.h227
-rw-r--r--drivers/char/ftape/zftape/zftape-write.c483
-rw-r--r--drivers/char/ftape/zftape/zftape-write.h38
-rw-r--r--drivers/char/ftape/zftape/zftape_syms.c43
-rw-r--r--drivers/char/genrtc.c4
-rw-r--r--drivers/char/hpet.c1
-rw-r--r--drivers/char/hvc_console.c1
-rw-r--r--drivers/char/hvcs.c426
-rw-r--r--drivers/char/hvsi.c16
-rw-r--r--drivers/char/hw_random/Kconfig19
-rw-r--r--drivers/char/hw_random/Makefile3
-rw-r--r--drivers/char/hw_random/core.c39
-rw-r--r--drivers/char/ip2/i2cmd.h5
-rw-r--r--drivers/char/ip2/i2lib.c13
-rw-r--r--drivers/char/ip2/ip2main.c23
-rw-r--r--drivers/char/ipmi/ipmi_bt_sm.c641
-rw-r--r--drivers/char/ipmi/ipmi_devintf.c25
-rw-r--r--drivers/char/ipmi/ipmi_kcs_sm.c18
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c746
-rw-r--r--drivers/char/ipmi/ipmi_poweroff.c114
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c384
-rw-r--r--drivers/char/ipmi/ipmi_smic_sm.c14
-rw-r--r--drivers/char/ipmi/ipmi_watchdog.c121
-rw-r--r--drivers/char/isicom.c15
-rw-r--r--drivers/char/istallion.c12
-rw-r--r--drivers/char/mem.c8
-rw-r--r--drivers/char/misc.c15
-rw-r--r--drivers/char/mmtimer.c23
-rw-r--r--drivers/char/moxa.c13
-rw-r--r--drivers/char/mspec.c8
-rw-r--r--drivers/char/mxser.c9
-rw-r--r--drivers/char/pcmcia/cm4000_cs.c26
-rw-r--r--drivers/char/pcmcia/cm4040_cs.c26
-rw-r--r--drivers/char/pcmcia/synclink_cs.c41
-rw-r--r--drivers/char/ppdev.c6
-rw-r--r--drivers/char/random.c54
-rw-r--r--drivers/char/raw.c12
-rw-r--r--drivers/char/rio/rio_linux.c8
-rw-r--r--drivers/char/rio/riocmd.c2
-rw-r--r--drivers/char/rio/rioinit.c2
-rw-r--r--drivers/char/rio/rioparam.c6
-rw-r--r--drivers/char/riscom8.c17
-rw-r--r--drivers/char/serial167.c6
-rw-r--r--drivers/char/sonypi.c4
-rw-r--r--drivers/char/specialix.c14
-rw-r--r--drivers/char/stallion.c10
-rw-r--r--drivers/char/synclink.c35
-rw-r--r--drivers/char/synclink_gt.c37
-rw-r--r--drivers/char/synclinkmp.c34
-rw-r--r--drivers/char/sysrq.c18
-rw-r--r--drivers/char/tlclk.c5
-rw-r--r--drivers/char/toshiba.c1
-rw-r--r--drivers/char/tpm/tpm.c9
-rw-r--r--drivers/char/tpm/tpm.h1
-rw-r--r--drivers/char/tty_io.c50
-rw-r--r--drivers/char/vc_screen.c16
-rw-r--r--drivers/char/vt.c103
-rw-r--r--drivers/char/watchdog/Kconfig32
-rw-r--r--drivers/char/watchdog/Makefile4
-rw-r--r--drivers/char/watchdog/at91rm9200_wdt.c1
-rw-r--r--drivers/char/watchdog/iTCO_vendor_support.c307
-rw-r--r--drivers/char/watchdog/iTCO_wdt.c29
-rw-r--r--drivers/char/watchdog/pc87413_wdt.c635
-rw-r--r--drivers/char/watchdog/pcwd_usb.c5
-rw-r--r--drivers/char/watchdog/rm9k_wdt.c420
-rw-r--r--drivers/connector/cn_queue.c8
-rw-r--r--drivers/connector/connector.c31
-rw-r--r--drivers/cpufreq/Kconfig1
-rw-r--r--drivers/cpufreq/cpufreq.c14
-rw-r--r--drivers/cpufreq/cpufreq_conservative.c7
-rw-r--r--drivers/cpufreq/cpufreq_ondemand.c28
-rw-r--r--drivers/crypto/Kconfig13
-rw-r--r--drivers/crypto/Makefile1
-rw-r--r--drivers/crypto/geode-aes.c474
-rw-r--r--drivers/crypto/geode-aes.h40
-rw-r--r--drivers/dma/ioatdma.c4
-rw-r--r--drivers/edac/edac_mc.c1
-rw-r--r--drivers/firmware/dell_rbu.c9
-rw-r--r--drivers/hwmon/abituguru.c1
-rw-r--r--drivers/hwmon/hdaps.c1
-rw-r--r--drivers/i2c/busses/Kconfig7
-rw-r--r--drivers/i2c/busses/i2c-i801.c2
-rw-r--r--drivers/i2c/busses/i2c-ixp4xx.c3
-rw-r--r--drivers/i2c/busses/i2c-pxa.c131
-rw-r--r--drivers/i2c/busses/scx200_acb.c7
-rw-r--r--drivers/i2c/chips/ds1374.c12
-rw-r--r--drivers/i2c/chips/m41t00.c9
-rw-r--r--drivers/i2c/i2c-dev.c26
-rw-r--r--drivers/ide/Kconfig16
-rw-r--r--drivers/ide/ide-cd.c2
-rw-r--r--drivers/ide/ide-floppy.c2
-rw-r--r--drivers/ide/ide.c19
-rw-r--r--drivers/ide/legacy/hd.c2
-rw-r--r--drivers/ide/legacy/ide-cs.c20
-rw-r--r--drivers/ide/pci/sgiioc4.c7
-rw-r--r--drivers/ide/pci/via82cxxx.c25
-rw-r--r--drivers/ieee1394/Kconfig26
-rw-r--r--drivers/ieee1394/Makefile5
-rw-r--r--drivers/ieee1394/csr.c8
-rw-r--r--drivers/ieee1394/dv1394.c24
-rw-r--r--drivers/ieee1394/eth1394.c6
-rw-r--r--drivers/ieee1394/highlevel.h1
-rw-r--r--drivers/ieee1394/hosts.c52
-rw-r--r--drivers/ieee1394/hosts.h2
-rw-r--r--drivers/ieee1394/ieee1394_core.c4
-rw-r--r--drivers/ieee1394/nodemgr.c466
-rw-r--r--drivers/ieee1394/nodemgr.h7
-rw-r--r--drivers/ieee1394/ohci1394.c148
-rw-r--r--drivers/ieee1394/pcilynx.c3
-rw-r--r--drivers/ieee1394/raw1394-private.h10
-rw-r--r--drivers/ieee1394/raw1394.c63
-rw-r--r--drivers/ieee1394/sbp2.c2192
-rw-r--r--drivers/ieee1394/sbp2.h309
-rw-r--r--drivers/ieee1394/video1394.c54
-rw-r--r--drivers/infiniband/core/addr.c25
-rw-r--r--drivers/infiniband/core/cache.c7
-rw-r--r--drivers/infiniband/core/cm.c140
-rw-r--r--drivers/infiniband/core/cma.c59
-rw-r--r--drivers/infiniband/core/iwcm.c47
-rw-r--r--drivers/infiniband/core/mad.c29
-rw-r--r--drivers/infiniband/core/mad_priv.h2
-rw-r--r--drivers/infiniband/core/mad_rmpp.c18
-rw-r--r--drivers/infiniband/core/sa_query.c10
-rw-r--r--drivers/infiniband/core/ucm.c20
-rw-r--r--drivers/infiniband/core/uverbs_mem.c7
-rw-r--r--drivers/infiniband/hw/amso1100/c2.c3
-rw-r--r--drivers/infiniband/hw/amso1100/c2.h2
-rw-r--r--drivers/infiniband/hw/amso1100/c2_provider.c39
-rw-r--r--drivers/infiniband/hw/amso1100/c2_qp.c36
-rw-r--r--drivers/infiniband/hw/amso1100/c2_rnic.c8
-rw-r--r--drivers/infiniband/hw/amso1100/c2_vq.c2
-rw-r--r--drivers/infiniband/hw/ehca/Kconfig1
-rw-r--r--drivers/infiniband/hw/ehca/ehca_av.c7
-rw-r--r--drivers/infiniband/hw/ehca/ehca_cq.c2
-rw-r--r--drivers/infiniband/hw/ehca/ehca_hca.c17
-rw-r--r--drivers/infiniband/hw/ehca/ehca_irq.c17
-rw-r--r--drivers/infiniband/hw/ehca/ehca_iverbs.h8
-rw-r--r--drivers/infiniband/hw/ehca/ehca_main.c56
-rw-r--r--drivers/infiniband/hw/ehca/ehca_mrmw.c12
-rw-r--r--drivers/infiniband/hw/ehca/ehca_pd.c2
-rw-r--r--drivers/infiniband/hw/ehca/ehca_qp.c34
-rw-r--r--drivers/infiniband/hw/ehca/hipz_hw.h2
-rw-r--r--drivers/infiniband/hw/ehca/ipz_pt_fn.c13
-rw-r--r--drivers/infiniband/hw/ehca/ipz_pt_fn.h15
-rw-r--r--drivers/infiniband/hw/ipath/Kconfig2
-rw-r--r--drivers/infiniband/hw/ipath/Makefile5
-rw-r--r--drivers/infiniband/hw/ipath/ipath_driver.c21
-rw-r--r--drivers/infiniband/hw/ipath/ipath_iba6110.c117
-rw-r--r--drivers/infiniband/hw/ipath/ipath_iba6120.c8
-rw-r--r--drivers/infiniband/hw/ipath/ipath_intr.c10
-rw-r--r--drivers/infiniband/hw/ipath/ipath_kernel.h4
-rw-r--r--drivers/infiniband/hw/ipath/ipath_user_pages.c7
-rw-r--r--drivers/infiniband/hw/ipath/ipath_verbs.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_av.c5
-rw-r--r--drivers/infiniband/hw/mthca/mthca_catas.c4
-rw-r--r--drivers/infiniband/hw/mthca/mthca_cq.c3
-rw-r--r--drivers/infiniband/hw/mthca/mthca_eq.c21
-rw-r--r--drivers/infiniband/hw/mthca/mthca_mad.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_main.c29
-rw-r--r--drivers/infiniband/hw/mthca/mthca_mcg.c3
-rw-r--r--drivers/infiniband/hw/mthca/mthca_mr.c5
-rw-r--r--drivers/infiniband/hw/mthca/mthca_pd.c3
-rw-r--r--drivers/infiniband/hw/mthca/mthca_provider.c3
-rw-r--r--drivers/infiniband/hw/mthca/mthca_qp.c3
-rw-r--r--drivers/infiniband/hw/mthca/mthca_srq.c4
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib.h18
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_ib.c25
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_main.c44
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_multicast.c24
-rw-r--r--drivers/infiniband/ulp/iser/iscsi_iser.h2
-rw-r--r--drivers/infiniband/ulp/iser/iser_memory.c1
-rw-r--r--drivers/infiniband/ulp/iser/iser_verbs.c10
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.c18
-rw-r--r--drivers/input/gameport/gameport.c1
-rw-r--r--drivers/input/joystick/iforce/iforce-usb.c6
-rw-r--r--drivers/input/keyboard/atkbd.c6
-rw-r--r--drivers/input/keyboard/lkkbd.c11
-rw-r--r--drivers/input/keyboard/sunkbd.c6
-rw-r--r--drivers/input/misc/hp_sdc_rtc.c4
-rw-r--r--drivers/input/mouse/psmouse-base.c7
-rw-r--r--drivers/input/serio/libps2.c6
-rw-r--r--drivers/input/serio/serio.c1
-rw-r--r--drivers/input/serio/serio_raw.c2
-rw-r--r--drivers/input/touchscreen/ads7846.c2
-rw-r--r--drivers/isdn/act2000/capi.c4
-rw-r--r--drivers/isdn/act2000/capi.h2
-rw-r--r--drivers/isdn/act2000/module.c18
-rw-r--r--drivers/isdn/capi/kcapi.c14
-rw-r--r--drivers/isdn/divert/isdn_divert.c2
-rw-r--r--drivers/isdn/gigaset/bas-gigaset.c34
-rw-r--r--drivers/isdn/gigaset/common.c4
-rw-r--r--drivers/isdn/gigaset/gigaset.h2
-rw-r--r--drivers/isdn/gigaset/interface.c10
-rw-r--r--drivers/isdn/gigaset/proc.c19
-rw-r--r--drivers/isdn/gigaset/usb-gigaset.c27
-rw-r--r--drivers/isdn/hardware/avm/avm_cs.c36
-rw-r--r--drivers/isdn/hardware/eicon/os_4bri.c2
-rw-r--r--drivers/isdn/hisax/Kconfig2
-rw-r--r--drivers/isdn/hisax/amd7930_fn.c7
-rw-r--r--drivers/isdn/hisax/avma1_cs.c36
-rw-r--r--drivers/isdn/hisax/config.c9
-rw-r--r--drivers/isdn/hisax/elsa_cs.c17
-rw-r--r--drivers/isdn/hisax/hfc4s8s_l1.c5
-rw-r--r--drivers/isdn/hisax/hfc4s8s_l1.h2
-rw-r--r--drivers/isdn/hisax/hfc_2bds0.c9
-rw-r--r--drivers/isdn/hisax/hfc_pci.c6
-rw-r--r--drivers/isdn/hisax/hfc_sx.c6
-rw-r--r--drivers/isdn/hisax/icc.c6
-rw-r--r--drivers/isdn/hisax/isac.c6
-rw-r--r--drivers/isdn/hisax/isar.c6
-rw-r--r--drivers/isdn/hisax/isdnhdlc.h8
-rw-r--r--drivers/isdn/hisax/isdnl1.c6
-rw-r--r--drivers/isdn/hisax/isdnl2.c20
-rw-r--r--drivers/isdn/hisax/sedlbauer_cs.c10
-rw-r--r--drivers/isdn/hisax/teles_cs.c17
-rw-r--r--drivers/isdn/hisax/w6692.c6
-rw-r--r--drivers/isdn/hysdn/boardergo.c5
-rw-r--r--drivers/isdn/i4l/isdn_net.c6
-rw-r--r--drivers/isdn/pcbit/drv.c4
-rw-r--r--drivers/isdn/pcbit/layer2.c6
-rw-r--r--drivers/isdn/pcbit/pcbit.h2
-rw-r--r--drivers/leds/Kconfig6
-rw-r--r--drivers/leds/Makefile1
-rw-r--r--drivers/leds/leds-wrap.c142
-rw-r--r--drivers/leds/ledtrig-ide-disk.c1
-rw-r--r--drivers/leds/ledtrig-timer.c1
-rw-r--r--drivers/macintosh/Kconfig7
-rw-r--r--drivers/macintosh/Makefile1
-rw-r--r--drivers/macintosh/adb.c4
-rw-r--r--drivers/macintosh/apm_emu.c3
-rw-r--r--drivers/macintosh/rack-meter.c616
-rw-r--r--drivers/macintosh/smu.c7
-rw-r--r--drivers/macintosh/therm_adt746x.c3
-rw-r--r--drivers/macintosh/therm_pm72.c5
-rw-r--r--drivers/macintosh/therm_windtunnel.c7
-rw-r--r--drivers/macintosh/via-pmu.c2
-rw-r--r--drivers/macintosh/windfarm_core.c1
-rw-r--r--drivers/macintosh/windfarm_pm112.c11
-rw-r--r--drivers/macintosh/windfarm_pm81.c1
-rw-r--r--drivers/macintosh/windfarm_pm91.c1
-rw-r--r--drivers/md/dm-crypt.c78
-rw-r--r--drivers/md/dm-ioctl.c9
-rw-r--r--drivers/md/dm-mpath.c20
-rw-r--r--drivers/md/dm-raid1.c26
-rw-r--r--drivers/md/dm-round-robin.c2
-rw-r--r--drivers/md/dm-snap.c15
-rw-r--r--drivers/md/dm.c8
-rw-r--r--drivers/md/kcopyd.c6
-rw-r--r--drivers/md/md.c7
-rw-r--r--drivers/md/raid5.c6
-rw-r--r--drivers/media/common/saa7146_i2c.c10
-rw-r--r--drivers/media/dvb/b2c2/flexcop-pci.c9
-rw-r--r--drivers/media/dvb/b2c2/flexcop-usb.c2
-rw-r--r--drivers/media/dvb/cinergyT2/cinergyT2.c27
-rw-r--r--drivers/media/dvb/dvb-core/dvb_frontend.c4
-rw-r--r--drivers/media/dvb/dvb-core/dvb_net.c19
-rw-r--r--drivers/media/dvb/dvb-usb/Kconfig12
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-remote.c7
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb.h2
-rw-r--r--drivers/media/dvb/dvb-usb/usb-urb.c2
-rw-r--r--drivers/media/dvb/frontends/Kconfig2
-rw-r--r--drivers/media/dvb/frontends/bcm3510.h2
-rw-r--r--drivers/media/dvb/frontends/cx22700.h2
-rw-r--r--drivers/media/dvb/frontends/cx22702.h2
-rw-r--r--drivers/media/dvb/frontends/cx24110.h2
-rw-r--r--drivers/media/dvb/frontends/cx24123.h2
-rw-r--r--drivers/media/dvb/frontends/dib3000.h2
-rw-r--r--drivers/media/dvb/frontends/dib3000mc.h2
-rw-r--r--drivers/media/dvb/frontends/isl6421.h2
-rw-r--r--drivers/media/dvb/frontends/l64781.c2
-rw-r--r--drivers/media/dvb/frontends/l64781.h2
-rw-r--r--drivers/media/dvb/frontends/lgdt330x.h2
-rw-r--r--drivers/media/dvb/frontends/lnbp21.h2
-rw-r--r--drivers/media/dvb/frontends/mt2060.h8
-rw-r--r--drivers/media/dvb/frontends/mt312.h2
-rw-r--r--drivers/media/dvb/frontends/mt352.h2
-rw-r--r--drivers/media/dvb/frontends/nxt200x.h2
-rw-r--r--drivers/media/dvb/frontends/nxt6000.h2
-rw-r--r--drivers/media/dvb/frontends/or51132.h2
-rw-r--r--drivers/media/dvb/frontends/or51211.h2
-rw-r--r--drivers/media/dvb/frontends/s5h1420.h2
-rw-r--r--drivers/media/dvb/frontends/sp8870.h2
-rw-r--r--drivers/media/dvb/frontends/sp887x.h2
-rw-r--r--drivers/media/dvb/frontends/stv0297.h2
-rw-r--r--drivers/media/dvb/frontends/stv0299.h2
-rw-r--r--drivers/media/dvb/frontends/tda10021.h2
-rw-r--r--drivers/media/dvb/frontends/tda1004x.h2
-rw-r--r--drivers/media/dvb/frontends/tda10086.c4
-rw-r--r--drivers/media/dvb/frontends/tda10086.h2
-rw-r--r--drivers/media/dvb/frontends/tda8083.h2
-rw-r--r--drivers/media/dvb/frontends/tda826x.c2
-rw-r--r--drivers/media/dvb/frontends/tda826x.h2
-rw-r--r--drivers/media/dvb/frontends/tua6100.h2
-rw-r--r--drivers/media/dvb/frontends/ves1820.h2
-rw-r--r--drivers/media/dvb/frontends/ves1x93.h2
-rw-r--r--drivers/media/dvb/frontends/zl10353.h2
-rw-r--r--drivers/media/dvb/ttpci/budget-ci.c10
-rw-r--r--drivers/media/dvb/ttpci/budget-patch.c8
-rw-r--r--drivers/media/dvb/ttpci/budget.c9
-rw-r--r--drivers/media/dvb/ttusb-dec/ttusb_dec.c5
-rw-r--r--drivers/media/radio/Kconfig32
-rw-r--r--drivers/media/video/Kconfig4
-rw-r--r--drivers/media/video/bt8xx/bttv-cards.c2
-rw-r--r--drivers/media/video/cpia_pp.c20
-rw-r--r--drivers/media/video/cx88/cx88-input.c16
-rw-r--r--drivers/media/video/et61x251/et61x251_core.c3
-rw-r--r--drivers/media/video/ir-kbd-i2c.c6
-rw-r--r--drivers/media/video/msp3400-driver.c2
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-context.c13
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c2
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.c10
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-io.c2
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-v4l2.c6
-rw-r--r--drivers/media/video/pwc/pwc-if.c9
-rw-r--r--drivers/media/video/saa6588.c10
-rw-r--r--drivers/media/video/saa7115.c9
-rw-r--r--drivers/media/video/saa7134/saa7134-cards.c5
-rw-r--r--drivers/media/video/saa7134/saa7134-dvb.c2
-rw-r--r--drivers/media/video/saa7134/saa7134-empress.c9
-rw-r--r--drivers/media/video/saa7134/saa7134-input.c11
-rw-r--r--drivers/media/video/sn9c102/sn9c102_core.c5
-rw-r--r--drivers/media/video/tvaudio.c1
-rw-r--r--drivers/media/video/tveeprom.c2
-rw-r--r--drivers/media/video/usbvideo/quickcam_messenger.c3
-rw-r--r--drivers/media/video/video-buf-dvb.c2
-rw-r--r--drivers/media/video/vivi.c1
-rw-r--r--drivers/media/video/zc0301/zc0301_core.c2
-rw-r--r--drivers/message/fusion/mptbase.c257
-rw-r--r--drivers/message/fusion/mptfc.c19
-rw-r--r--drivers/message/fusion/mptlan.c29
-rw-r--r--drivers/message/fusion/mptsas.c25
-rw-r--r--drivers/message/fusion/mptscsih.c24
-rw-r--r--drivers/message/fusion/mptspi.c18
-rw-r--r--drivers/message/i2o/bus-osm.c3
-rw-r--r--drivers/message/i2o/device.c27
-rw-r--r--drivers/message/i2o/driver.c22
-rw-r--r--drivers/message/i2o/exec-osm.c23
-rw-r--r--drivers/message/i2o/i2o_block.c30
-rw-r--r--drivers/message/i2o/i2o_block.h4
-rw-r--r--drivers/message/i2o/i2o_config.c8
-rw-r--r--drivers/message/i2o/i2o_proc.c2
-rw-r--r--drivers/message/i2o/i2o_scsi.c23
-rw-r--r--drivers/message/i2o/pci.c20
-rw-r--r--drivers/mfd/ucb1x00-ts.c2
-rw-r--r--drivers/misc/lkdtm.c8
-rw-r--r--drivers/misc/tifm_7xx1.c18
-rw-r--r--drivers/misc/tifm_core.c5
-rw-r--r--drivers/mmc/Kconfig10
-rw-r--r--drivers/mmc/Makefile2
-rw-r--r--drivers/mmc/at91_mci.c6
-rw-r--r--drivers/mmc/au1xmmc.c2
-rw-r--r--drivers/mmc/imxmmc.c2
-rw-r--r--drivers/mmc/mmc.c327
-rw-r--r--drivers/mmc/mmc.h2
-rw-r--r--drivers/mmc/mmc_block.c15
-rw-r--r--drivers/mmc/mmc_queue.c67
-rw-r--r--drivers/mmc/mmc_queue.h3
-rw-r--r--drivers/mmc/mmc_sysfs.c30
-rw-r--r--drivers/mmc/mmci.c2
-rw-r--r--drivers/mmc/omap.c275
-rw-r--r--drivers/mmc/omap.h55
-rw-r--r--drivers/mmc/pxamci.c2
-rw-r--r--drivers/mmc/sdhci.c17
-rw-r--r--drivers/mmc/sdhci.h2
-rw-r--r--drivers/mmc/tifm_sd.c28
-rw-r--r--drivers/mmc/wbsd.c8
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0001.c2
-rw-r--r--drivers/mtd/devices/m25p80.c2
-rw-r--r--drivers/mtd/maps/Kconfig2
-rw-r--r--drivers/mtd/maps/cfi_flagadm.c2
-rw-r--r--drivers/net/3c501.c2
-rw-r--r--drivers/net/3c503.c2
-rw-r--r--drivers/net/3c505.c2
-rw-r--r--drivers/net/3c507.c2
-rw-r--r--drivers/net/3c523.c2
-rw-r--r--drivers/net/3c527.c2
-rw-r--r--drivers/net/8139too.c26
-rw-r--r--drivers/net/8390.c1080
-rw-r--r--drivers/net/8390.h37
-rw-r--r--drivers/net/Kconfig59
-rw-r--r--drivers/net/Makefile13
-rw-r--r--drivers/net/Space.c1
-rw-r--r--drivers/net/ac3200.c2
-rw-r--r--drivers/net/amd8111e.c27
-rw-r--r--drivers/net/amd8111e.h4
-rw-r--r--drivers/net/apne.c4
-rw-r--r--drivers/net/appletalk/cops.c2
-rw-r--r--drivers/net/arcnet/com20020.c7
-rw-r--r--drivers/net/arm/at91_ether.c88
-rw-r--r--drivers/net/arm/at91_ether.h1
-rw-r--r--drivers/net/arm/ether1.c6
-rw-r--r--drivers/net/arm/ether3.c8
-rw-r--r--drivers/net/arm/etherh.c39
-rw-r--r--drivers/net/at1700.c2
-rw-r--r--drivers/net/atarilance.c4
-rw-r--r--drivers/net/au1000_eth.c3
-rw-r--r--drivers/net/b44.c5
-rw-r--r--drivers/net/bnx2.c695
-rw-r--r--drivers/net/bnx2.h2940
-rw-r--r--drivers/net/bnx2_fw.h1234
-rw-r--r--drivers/net/bnx2_fw2.h4086
-rw-r--r--drivers/net/bonding/bond_main.c70
-rw-r--r--drivers/net/cassini.c8
-rw-r--r--drivers/net/chelsio/Makefile8
-rw-r--r--drivers/net/chelsio/common.h107
-rw-r--r--drivers/net/chelsio/cphy.h24
-rw-r--r--drivers/net/chelsio/cpl5_cmd.h510
-rw-r--r--drivers/net/chelsio/cxgb2.c607
-rw-r--r--drivers/net/chelsio/elmer0.h7
-rw-r--r--drivers/net/chelsio/espi.c205
-rw-r--r--drivers/net/chelsio/espi.h1
-rw-r--r--drivers/net/chelsio/fpga_defs.h232
-rw-r--r--drivers/net/chelsio/gmac.h5
-rw-r--r--drivers/net/chelsio/ixf1010.c485
-rw-r--r--drivers/net/chelsio/mac.c368
-rw-r--r--drivers/net/chelsio/mv88e1xxx.c397
-rw-r--r--drivers/net/chelsio/mv88e1xxx.h127
-rw-r--r--drivers/net/chelsio/mv88x201x.c36
-rw-r--r--drivers/net/chelsio/my3126.c206
-rw-r--r--drivers/net/chelsio/pm3393.c125
-rw-r--r--drivers/net/chelsio/regs.h1718
-rw-r--r--drivers/net/chelsio/sge.c867
-rw-r--r--drivers/net/chelsio/sge.h33
-rw-r--r--drivers/net/chelsio/subr.c494
-rw-r--r--drivers/net/chelsio/suni1x10gexp_regs.h1430
-rw-r--r--drivers/net/chelsio/tp.c178
-rw-r--r--drivers/net/chelsio/tp.h73
-rw-r--r--drivers/net/chelsio/vsc7326.c725
-rw-r--r--drivers/net/chelsio/vsc7326_reg.h286
-rw-r--r--drivers/net/chelsio/vsc8244.c368
-rw-r--r--drivers/net/chelsio/vsc8244_reg.h172
-rw-r--r--drivers/net/cris/eth_v10.c2
-rw-r--r--drivers/net/cs89x0.c6
-rw-r--r--drivers/net/de600.c1
-rw-r--r--drivers/net/declance.c404
-rw-r--r--drivers/net/defxx.c39
-rw-r--r--drivers/net/defxx.h15
-rw-r--r--drivers/net/depca.c28
-rw-r--r--drivers/net/e100.c10
-rw-r--r--drivers/net/e1000/e1000.h17
-rw-r--r--drivers/net/e1000/e1000_ethtool.c36
-rw-r--r--drivers/net/e1000/e1000_hw.c139
-rw-r--r--drivers/net/e1000/e1000_hw.h90
-rw-r--r--drivers/net/e1000/e1000_main.c507
-rw-r--r--drivers/net/e1000/e1000_osdep.h9
-rw-r--r--drivers/net/e1000/e1000_param.c98
-rw-r--r--drivers/net/e2100.c2
-rw-r--r--drivers/net/eepro.c2
-rw-r--r--drivers/net/eexpress.c2
-rw-r--r--drivers/net/ehea/ehea.h5
-rw-r--r--drivers/net/ehea/ehea_ethtool.c2
-rw-r--r--drivers/net/ehea/ehea_main.c35
-rw-r--r--drivers/net/ehea/ehea_phyp.c2
-rw-r--r--drivers/net/ehea/ehea_phyp.h6
-rw-r--r--drivers/net/ehea/ehea_qmr.c18
-rw-r--r--drivers/net/es3210.c2
-rw-r--r--drivers/net/eth16i.c2
-rw-r--r--drivers/net/forcedeth.c290
-rw-r--r--drivers/net/fs_enet/fs_enet-main.c3
-rw-r--r--drivers/net/gianfar.c72
-rw-r--r--drivers/net/gianfar.h3
-rw-r--r--drivers/net/hamradio/6pack.c2
-rw-r--r--drivers/net/hamradio/baycom_epp.c14
-rw-r--r--drivers/net/hamradio/dmascc.c8
-rw-r--r--drivers/net/hp-plus.c2
-rw-r--r--drivers/net/hp.c2
-rw-r--r--drivers/net/hydra.c23
-rw-r--r--drivers/net/ibm_emac/ibm_emac_mal.h6
-rw-r--r--drivers/net/ibmveth.c4
-rw-r--r--drivers/net/ibmveth.h1
-rw-r--r--drivers/net/ioc3-eth.c1
-rw-r--r--drivers/net/irda/irda-usb.c6
-rw-r--r--drivers/net/irda/mcs7780.c6
-rw-r--r--drivers/net/irda/pxaficp_ir.c26
-rw-r--r--drivers/net/irda/sir-dev.h2
-rw-r--r--drivers/net/irda/sir_dev.c8
-rw-r--r--drivers/net/irda/stir4200.c1
-rw-r--r--drivers/net/iseries_veth.c12
-rw-r--r--drivers/net/ixgb/ixgb_main.c12
-rw-r--r--drivers/net/lance.c3
-rw-r--r--drivers/net/lasi_82596.c94
-rw-r--r--drivers/net/lib8390.c1097
-rw-r--r--drivers/net/lne390.c2
-rw-r--r--drivers/net/mac8390.c26
-rw-r--r--drivers/net/macb.c1210
-rw-r--r--drivers/net/macb.h387
-rw-r--r--drivers/net/meth.c1
-rw-r--r--drivers/net/mv643xx_eth.c13
-rw-r--r--drivers/net/mvme147.c4
-rw-r--r--drivers/net/myri10ge/myri10ge.c104
-rw-r--r--drivers/net/myri10ge/myri10ge_mcp.h56
-rw-r--r--drivers/net/myri10ge/myri10ge_mcp_gen_header.h2
-rw-r--r--drivers/net/myri_sbus.c1
-rw-r--r--drivers/net/ne-h8300.c23
-rw-r--r--drivers/net/ne.c2
-rw-r--r--drivers/net/ne2.c2
-rw-r--r--drivers/net/ne3210.c1
-rw-r--r--drivers/net/netconsole.c8
-rw-r--r--drivers/net/netxen/Makefile35
-rw-r--r--drivers/net/netxen/netxen_nic.h1180
-rw-r--r--drivers/net/netxen/netxen_nic_ethtool.c742
-rw-r--r--drivers/net/netxen/netxen_nic_hdr.h678
-rw-r--r--drivers/net/netxen/netxen_nic_hw.c1293
-rw-r--r--drivers/net/netxen/netxen_nic_hw.h482
-rw-r--r--drivers/net/netxen/netxen_nic_init.c1524
-rw-r--r--drivers/net/netxen/netxen_nic_ioctl.h77
-rw-r--r--drivers/net/netxen/netxen_nic_isr.c208
-rw-r--r--drivers/net/netxen/netxen_nic_main.c1210
-rw-r--r--drivers/net/netxen/netxen_nic_niu.c898
-rw-r--r--drivers/net/netxen/netxen_nic_phan_reg.h271
-rw-r--r--drivers/net/ni52.c2
-rw-r--r--drivers/net/ni65.c2
-rw-r--r--drivers/net/ns83820.c35
-rw-r--r--drivers/net/pcmcia/3c574_cs.c25
-rw-r--r--drivers/net/pcmcia/3c589_cs.c19
-rw-r--r--drivers/net/pcmcia/axnet_cs.c6
-rw-r--r--drivers/net/pcmcia/com20020_cs.c13
-rw-r--r--drivers/net/pcmcia/fmvj18x_cs.c40
-rw-r--r--drivers/net/pcmcia/ibmtr_cs.c12
-rw-r--r--drivers/net/pcmcia/nmclan_cs.c12
-rw-r--r--drivers/net/pcmcia/pcnet_cs.c31
-rw-r--r--drivers/net/pcmcia/smc91c92_cs.c59
-rw-r--r--drivers/net/pcmcia/xirc2ps_cs.c40
-rw-r--r--drivers/net/phy/Kconfig10
-rw-r--r--drivers/net/phy/Makefile1
-rw-r--r--drivers/net/phy/broadcom.c175
-rw-r--r--drivers/net/phy/fixed.c2
-rw-r--r--drivers/net/phy/phy.c121
-rw-r--r--drivers/net/phy/phy_device.c30
-rw-r--r--drivers/net/plip.c38
-rw-r--r--drivers/net/ppp_generic.c4
-rw-r--r--drivers/net/pppoe.c2
-rw-r--r--drivers/net/qla3xxx.c20
-rw-r--r--drivers/net/qla3xxx.h4
-rw-r--r--drivers/net/r8169.c133
-rw-r--r--drivers/net/s2io.c16
-rw-r--r--drivers/net/s2io.h2
-rw-r--r--drivers/net/seeq8005.c2
-rw-r--r--drivers/net/sis190.c13
-rw-r--r--drivers/net/sk98lin/h/skdrv2nd.h2
-rw-r--r--drivers/net/sk98lin/skdim.c4
-rw-r--r--drivers/net/sk98lin/skethtool.c26
-rw-r--r--drivers/net/sk98lin/skge.c59
-rw-r--r--drivers/net/sk98lin/skgesirq.c2
-rw-r--r--drivers/net/skge.c23
-rw-r--r--drivers/net/skge.h152
-rw-r--r--drivers/net/sky2.c156
-rw-r--r--drivers/net/sky2.h65
-rw-r--r--drivers/net/smc-ultra.c2
-rw-r--r--drivers/net/smc-ultra32.c2
-rw-r--r--drivers/net/smc9194.c2
-rw-r--r--drivers/net/smc91x.c15
-rw-r--r--drivers/net/smc91x.h24
-rw-r--r--drivers/net/spider_net.c47
-rw-r--r--drivers/net/spider_net.h8
-rw-r--r--drivers/net/starfire.c1
-rw-r--r--drivers/net/sun3lance.c5
-rw-r--r--drivers/net/sundance.c58
-rw-r--r--drivers/net/sungem.c9
-rw-r--r--drivers/net/sunhme.c8
-rw-r--r--drivers/net/tg3.c196
-rw-r--r--drivers/net/tg3.h1
-rw-r--r--drivers/net/tlan.c23
-rw-r--r--drivers/net/tlan.h1
-rw-r--r--drivers/net/tokenring/ibmtr.c2
-rw-r--r--drivers/net/tokenring/olympic.c2
-rw-r--r--drivers/net/tokenring/smctr.c2
-rw-r--r--drivers/net/tsi108_eth.c1708
-rw-r--r--drivers/net/tsi108_eth.h365
-rw-r--r--drivers/net/tulip/21142.c7
-rw-r--r--drivers/net/tulip/de2104x.c4
-rw-r--r--drivers/net/tulip/de4x5.c8
-rw-r--r--drivers/net/tulip/dmfe.c9
-rw-r--r--drivers/net/tulip/timer.c7
-rw-r--r--drivers/net/tulip/tulip.h7
-rw-r--r--drivers/net/tulip/tulip_core.c3
-rw-r--r--drivers/net/typhoon.c2
-rw-r--r--drivers/net/ucc_geth.c6
-rw-r--r--drivers/net/wan/Kconfig76
-rw-r--r--drivers/net/wan/pc300_tty.c23
-rw-r--r--drivers/net/wd.c2
-rw-r--r--drivers/net/wireless/airo.c1
-rw-r--r--drivers/net/wireless/airo_cs.c19
-rw-r--r--drivers/net/wireless/atmel.c36
-rw-r--r--drivers/net/wireless/atmel_cs.c83
-rw-r--r--drivers/net/wireless/atmel_pci.c10
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx.h34
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_leds.c7
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_leds.h6
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_main.c265
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_power.c28
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_wx.c4
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_xmit.c18
-rw-r--r--drivers/net/wireless/hostap/hostap.h2
-rw-r--r--drivers/net/wireless/hostap/hostap_ap.c23
-rw-r--r--drivers/net/wireless/hostap/hostap_cs.c16
-rw-r--r--drivers/net/wireless/hostap/hostap_download.c4
-rw-r--r--drivers/net/wireless/hostap/hostap_hw.c33
-rw-r--r--drivers/net/wireless/hostap/hostap_info.c9
-rw-r--r--drivers/net/wireless/hostap/hostap_ioctl.c12
-rw-r--r--drivers/net/wireless/hostap/hostap_main.c8
-rw-r--r--drivers/net/wireless/hostap/hostap_pci.c11
-rw-r--r--drivers/net/wireless/hostap/hostap_plx.c7
-rw-r--r--drivers/net/wireless/ipw2100.c74
-rw-r--r--drivers/net/wireless/ipw2100.h10
-rw-r--r--drivers/net/wireless/ipw2200.c263
-rw-r--r--drivers/net/wireless/ipw2200.h16
-rw-r--r--drivers/net/wireless/netwave_cs.c18
-rw-r--r--drivers/net/wireless/orinoco.c28
-rw-r--r--drivers/net/wireless/orinoco_cs.c19
-rw-r--r--drivers/net/wireless/orinoco_pci.h7
-rw-r--r--drivers/net/wireless/prism54/isl_38xx.c17
-rw-r--r--drivers/net/wireless/prism54/isl_38xx.h7
-rw-r--r--drivers/net/wireless/prism54/isl_ioctl.c78
-rw-r--r--drivers/net/wireless/prism54/isl_ioctl.h5
-rw-r--r--drivers/net/wireless/prism54/isl_oid.h48
-rw-r--r--drivers/net/wireless/prism54/islpci_dev.c18
-rw-r--r--drivers/net/wireless/prism54/islpci_dev.h11
-rw-r--r--drivers/net/wireless/prism54/islpci_eth.c32
-rw-r--r--drivers/net/wireless/prism54/islpci_eth.h3
-rw-r--r--drivers/net/wireless/prism54/islpci_hotplug.c43
-rw-r--r--drivers/net/wireless/prism54/islpci_mgt.c5
-rw-r--r--drivers/net/wireless/prism54/islpci_mgt.h5
-rw-r--r--drivers/net/wireless/prism54/oid_mgt.c10
-rw-r--r--drivers/net/wireless/prism54/prismcompat.h4
-rw-r--r--drivers/net/wireless/ray_cs.c30
-rw-r--r--drivers/net/wireless/spectrum_cs.c19
-rw-r--r--drivers/net/wireless/wavelan_cs.c33
-rw-r--r--drivers/net/wireless/wl3501_cs.c15
-rw-r--r--drivers/net/wireless/zd1201.c6
-rw-r--r--drivers/net/wireless/zd1211rw/zd_chip.c51
-rw-r--r--drivers/net/wireless/zd1211rw/zd_chip.h147
-rw-r--r--drivers/net/wireless/zd1211rw/zd_def.h1
-rw-r--r--drivers/net/wireless/zd1211rw/zd_ieee80211.c10
-rw-r--r--drivers/net/wireless/zd1211rw/zd_ieee80211.h3
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.c467
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.h43
-rw-r--r--drivers/net/wireless/zd1211rw/zd_netdev.c15
-rw-r--r--drivers/net/wireless/zd1211rw/zd_usb.c45
-rw-r--r--drivers/net/wireless/zd1211rw/zd_usb.h14
-rw-r--r--drivers/net/zorro8390.c24
-rw-r--r--drivers/oprofile/cpu_buffer.c9
-rw-r--r--drivers/oprofile/cpu_buffer.h2
-rw-r--r--drivers/parisc/ccio-dma.c2
-rw-r--r--drivers/parisc/iosapic.c6
-rw-r--r--drivers/parport/parport_cs.c9
-rw-r--r--drivers/parport/parport_ip32.c2
-rw-r--r--drivers/parport/parport_pc.c12
-rw-r--r--drivers/pci/Kconfig6
-rw-r--r--drivers/pci/access.c76
-rw-r--r--drivers/pci/hotplug/acpiphp.h4
-rw-r--r--drivers/pci/hotplug/acpiphp_core.c39
-rw-r--r--drivers/pci/hotplug/acpiphp_glue.c8
-rw-r--r--drivers/pci/hotplug/ibmphp_hpc.c2
-rw-r--r--drivers/pci/hotplug/ibmphp_pci.c4
-rw-r--r--drivers/pci/hotplug/pciehp_core.c7
-rw-r--r--drivers/pci/hotplug/pciehp_hpc.c2
-rw-r--r--drivers/pci/hotplug/rpadlpar_core.c2
-rw-r--r--drivers/pci/hotplug/rpaphp_core.c2
-rw-r--r--drivers/pci/hotplug/sgi_hotplug.c35
-rw-r--r--drivers/pci/hotplug/shpchp.h4
-rw-r--r--drivers/pci/hotplug/shpchp_core.c2
-rw-r--r--drivers/pci/hotplug/shpchp_ctrl.c19
-rw-r--r--drivers/pci/htirq.c101
-rw-r--r--drivers/pci/msi.c14
-rw-r--r--drivers/pci/msi.h8
-rw-r--r--drivers/pci/pci-acpi.c10
-rw-r--r--drivers/pci/pci-driver.c11
-rw-r--r--drivers/pci/pci-sysfs.c36
-rw-r--r--drivers/pci/pci.c123
-rw-r--r--drivers/pci/pci.h1
-rw-r--r--drivers/pci/pcie/aer/aerdrv.c2
-rw-r--r--drivers/pci/pcie/aer/aerdrv.h2
-rw-r--r--drivers/pci/pcie/aer/aerdrv_core.c8
-rw-r--r--drivers/pci/probe.c28
-rw-r--r--drivers/pci/quirks.c86
-rw-r--r--drivers/pci/rom.c9
-rw-r--r--drivers/pcmcia/at91_cf.c71
-rw-r--r--drivers/pcmcia/cs.c1
-rw-r--r--drivers/pcmcia/cs_internal.h2
-rw-r--r--drivers/pcmcia/ds.c279
-rw-r--r--drivers/pcmcia/m32r_cfc.c2
-rw-r--r--drivers/pcmcia/pcmcia_ioctl.c7
-rw-r--r--drivers/pcmcia/pd6729.c8
-rw-r--r--drivers/pcmcia/socket_sysfs.c4
-rw-r--r--drivers/pnp/card.c30
-rw-r--r--drivers/pnp/interface.c17
-rw-r--r--drivers/pnp/pnpbios/core.c4
-rw-r--r--drivers/ps3/Makefile1
-rw-r--r--drivers/ps3/system-bus.c362
-rw-r--r--drivers/rtc/Kconfig12
-rw-r--r--drivers/rtc/Makefile1
-rw-r--r--drivers/rtc/interface.c16
-rw-r--r--drivers/rtc/rtc-at91.c3
-rw-r--r--drivers/rtc/rtc-dev.c32
-rw-r--r--drivers/rtc/rtc-ds1553.c3
-rw-r--r--drivers/rtc/rtc-ds1672.c9
-rw-r--r--drivers/rtc/rtc-ds1742.c67
-rw-r--r--drivers/rtc/rtc-omap.c572
-rw-r--r--drivers/rtc/rtc-rs5c372.c96
-rw-r--r--drivers/rtc/rtc-test.c11
-rw-r--r--drivers/rtc/rtc-x1205.c12
-rw-r--r--drivers/s390/block/dasd.c26
-rw-r--r--drivers/s390/block/dasd_devmap.c38
-rw-r--r--drivers/s390/block/dasd_eckd.c2
-rw-r--r--drivers/s390/block/dasd_fba.c2
-rw-r--r--drivers/s390/block/dasd_int.h2
-rw-r--r--drivers/s390/char/con3215.c50
-rw-r--r--drivers/s390/char/sclp_quiesce.c37
-rw-r--r--drivers/s390/cio/chsc.c82
-rw-r--r--drivers/s390/cio/cio.c128
-rw-r--r--drivers/s390/cio/css.c9
-rw-r--r--drivers/s390/cio/css.h3
-rw-r--r--drivers/s390/cio/device.c17
-rw-r--r--drivers/s390/cio/device_fsm.c27
-rw-r--r--drivers/s390/cio/device_id.c10
-rw-r--r--drivers/s390/cio/device_pgid.c30
-rw-r--r--drivers/s390/cio/device_status.c3
-rw-r--r--drivers/s390/cio/qdio.c8
-rw-r--r--drivers/s390/cio/qdio.h4
-rw-r--r--drivers/s390/crypto/ap_bus.c16
-rw-r--r--drivers/s390/net/claw.h2
-rw-r--r--drivers/s390/net/lcs.c88
-rw-r--r--drivers/s390/net/lcs.h29
-rw-r--r--drivers/s390/net/qeth.h2
-rw-r--r--drivers/s390/net/qeth_eddp.c40
-rw-r--r--drivers/s390/net/qeth_eddp.h2
-rw-r--r--drivers/s390/net/qeth_main.c12
-rw-r--r--drivers/s390/scsi/zfcp_def.h6
-rw-r--r--drivers/s390/scsi/zfcp_fsf.c2
-rw-r--r--drivers/scsi/3w-9xxx.c141
-rw-r--r--drivers/scsi/3w-9xxx.h14
-rw-r--r--drivers/scsi/53c700.c89
-rw-r--r--drivers/scsi/53c700.h16
-rw-r--r--drivers/scsi/BusLogic.c12
-rw-r--r--drivers/scsi/Kconfig59
-rw-r--r--drivers/scsi/Makefile7
-rw-r--r--drivers/scsi/NCR5380.c11
-rw-r--r--drivers/scsi/NCR5380.h4
-rw-r--r--drivers/scsi/NCR53c406a.c5
-rw-r--r--drivers/scsi/aacraid/aacraid.h4
-rw-r--r--drivers/scsi/aacraid/commsup.c23
-rw-r--r--drivers/scsi/aha152x.c4
-rw-r--r--drivers/scsi/aha1740.c10
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_osm_pci.c1
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_pci.c8
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_pci.h1
-rw-r--r--drivers/scsi/aic94xx/aic94xx.h4
-rw-r--r--drivers/scsi/aic94xx/aic94xx_hwi.c20
-rw-r--r--drivers/scsi/aic94xx/aic94xx_hwi.h12
-rw-r--r--drivers/scsi/aic94xx/aic94xx_init.c15
-rw-r--r--drivers/scsi/aic94xx/aic94xx_reg_def.h2
-rw-r--r--drivers/scsi/aic94xx/aic94xx_sas.h1
-rw-r--r--drivers/scsi/aic94xx/aic94xx_scb.c193
-rw-r--r--drivers/scsi/aic94xx/aic94xx_sds.c4
-rw-r--r--drivers/scsi/aic94xx/aic94xx_seq.c5
-rw-r--r--drivers/scsi/aic94xx/aic94xx_seq.h2
-rw-r--r--drivers/scsi/fd_mcs.c2
-rw-r--r--drivers/scsi/gdth.c4
-rw-r--r--drivers/scsi/hosts.c8
-rw-r--r--drivers/scsi/ibmvscsi/Makefile2
-rw-r--r--drivers/scsi/ibmvscsi/ibmvstgt.c960
-rw-r--r--drivers/scsi/ide-scsi.c6
-rw-r--r--drivers/scsi/imm.c12
-rw-r--r--drivers/scsi/initio.c2
-rw-r--r--drivers/scsi/ipr.c324
-rw-r--r--drivers/scsi/ipr.h83
-rw-r--r--drivers/scsi/ips.c28
-rw-r--r--drivers/scsi/ips.h9
-rw-r--r--drivers/scsi/iscsi_tcp.c22
-rw-r--r--drivers/scsi/libiscsi.c16
-rw-r--r--drivers/scsi/libsas/sas_discover.c22
-rw-r--r--drivers/scsi/libsas/sas_event.c14
-rw-r--r--drivers/scsi/libsas/sas_expander.c120
-rw-r--r--drivers/scsi/libsas/sas_init.c12
-rw-r--r--drivers/scsi/libsas/sas_internal.h12
-rw-r--r--drivers/scsi/libsas/sas_phy.c45
-rw-r--r--drivers/scsi/libsas/sas_port.c30
-rw-r--r--drivers/scsi/libsas/sas_scsi_host.c92
-rw-r--r--drivers/scsi/libsrp.c441
-rw-r--r--drivers/scsi/lpfc/lpfc.h6
-rw-r--r--drivers/scsi/lpfc/lpfc_attr.c118
-rw-r--r--drivers/scsi/lpfc/lpfc_ct.c24
-rw-r--r--drivers/scsi/lpfc/lpfc_els.c34
-rw-r--r--drivers/scsi/lpfc/lpfc_hbadisc.c229
-rw-r--r--drivers/scsi/lpfc/lpfc_hw.h35
-rw-r--r--drivers/scsi/lpfc/lpfc_init.c136
-rw-r--r--drivers/scsi/lpfc/lpfc_logmsg.h2
-rw-r--r--drivers/scsi/lpfc/lpfc_nportdisc.c9
-rw-r--r--drivers/scsi/lpfc/lpfc_scsi.c56
-rw-r--r--drivers/scsi/lpfc/lpfc_sli.c42
-rw-r--r--drivers/scsi/lpfc/lpfc_sli.h2
-rw-r--r--drivers/scsi/lpfc/lpfc_version.h2
-rw-r--r--drivers/scsi/megaraid.c13
-rw-r--r--drivers/scsi/megaraid.h3
-rw-r--r--drivers/scsi/megaraid/megaraid_sas.c4
-rw-r--r--drivers/scsi/ncr53c8xx.c33
-rw-r--r--drivers/scsi/ncr53c8xx.h6
-rw-r--r--drivers/scsi/oktagon_esp.c6
-rw-r--r--drivers/scsi/pcmcia/aha152x_stub.c7
-rw-r--r--drivers/scsi/pcmcia/fdomain_stub.c5
-rw-r--r--drivers/scsi/pcmcia/nsp_cs.c6
-rw-r--r--drivers/scsi/pcmcia/qlogic_stub.c11
-rw-r--r--drivers/scsi/pcmcia/sym53c500_cs.c12
-rw-r--r--drivers/scsi/ppa.c12
-rw-r--r--drivers/scsi/psi240i.c2
-rw-r--r--drivers/scsi/qla2xxx/qla_attr.c2
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c94
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c68
-rw-r--r--drivers/scsi/qla2xxx/qla_sup.c8
-rw-r--r--drivers/scsi/qla4xxx/ql4_dbg.c4
-rw-r--r--drivers/scsi/qla4xxx/ql4_def.h105
-rw-r--r--drivers/scsi/qla4xxx/ql4_fw.h7
-rw-r--r--drivers/scsi/qla4xxx/ql4_glbl.h3
-rw-r--r--drivers/scsi/qla4xxx/ql4_init.c47
-rw-r--r--drivers/scsi/qla4xxx/ql4_inline.h4
-rw-r--r--drivers/scsi/qla4xxx/ql4_iocb.c6
-rw-r--r--drivers/scsi/qla4xxx/ql4_isr.c1
-rw-r--r--drivers/scsi/qla4xxx/ql4_nvram.c70
-rw-r--r--drivers/scsi/qla4xxx/ql4_nvram.h4
-rw-r--r--drivers/scsi/qla4xxx/ql4_os.c126
-rw-r--r--drivers/scsi/qla4xxx/ql4_version.h7
-rw-r--r--drivers/scsi/scsi.c47
-rw-r--r--drivers/scsi/scsi_error.c33
-rw-r--r--drivers/scsi/scsi_lib.c351
-rw-r--r--drivers/scsi/scsi_priv.h3
-rw-r--r--drivers/scsi/scsi_scan.c250
-rw-r--r--drivers/scsi/scsi_sysfs.c10
-rw-r--r--drivers/scsi/scsi_tgt_if.c352
-rw-r--r--drivers/scsi/scsi_tgt_lib.c745
-rw-r--r--drivers/scsi/scsi_tgt_priv.h25
-rw-r--r--drivers/scsi/scsi_transport_fc.c60
-rw-r--r--drivers/scsi/scsi_transport_iscsi.c10
-rw-r--r--drivers/scsi/scsi_transport_sas.c1
-rw-r--r--drivers/scsi/scsi_transport_spi.c7
-rw-r--r--drivers/scsi/scsi_wait_scan.c31
-rw-r--r--drivers/scsi/sd.c29
-rw-r--r--drivers/scsi/sg.c25
-rw-r--r--drivers/scsi/st.c16
-rw-r--r--drivers/scsi/stex.c130
-rw-r--r--drivers/scsi/t128.h39
-rw-r--r--drivers/serial/8250_exar_st16c554.c52
-rw-r--r--drivers/serial/8250_pnp.c29
-rw-r--r--drivers/serial/Kconfig30
-rw-r--r--drivers/serial/Makefile2
-rw-r--r--drivers/serial/amba-pl010.c2
-rw-r--r--drivers/serial/atmel_serial.c10
-rw-r--r--drivers/serial/atmel_serial.h11
-rw-r--r--drivers/serial/cpm_uart/cpm_uart.h2
-rw-r--r--drivers/serial/cpm_uart/cpm_uart_core.c16
-rw-r--r--drivers/serial/cpm_uart/cpm_uart_cpm1.c2
-rw-r--r--drivers/serial/cpm_uart/cpm_uart_cpm2.c2
-rw-r--r--drivers/serial/dz.c371
-rw-r--r--drivers/serial/dz.h32
-rw-r--r--drivers/serial/mcfserial.c54
-rw-r--r--drivers/serial/mpc52xx_uart.c469
-rw-r--r--drivers/serial/mpsc.c22
-rw-r--r--drivers/serial/serial_cs.c67
-rw-r--r--drivers/serial/sh-sci.c6
-rw-r--r--drivers/serial/sh-sci.h37
-rw-r--r--drivers/serial/uartlite.c505
-rw-r--r--drivers/spi/Kconfig2
-rw-r--r--drivers/spi/pxa2xx_spi.c9
-rw-r--r--drivers/spi/spi.c25
-rw-r--r--drivers/spi/spi_bitbang.c9
-rw-r--r--drivers/spi/spi_butterfly.c3
-rw-r--r--drivers/telephony/ixj.h2
-rw-r--r--drivers/telephony/ixj_pcmcia.c37
-rw-r--r--drivers/usb/Kconfig2
-rw-r--r--drivers/usb/atm/cxacru.c12
-rw-r--r--drivers/usb/atm/speedtch.c19
-rw-r--r--drivers/usb/atm/ueagle-atm.c18
-rw-r--r--drivers/usb/class/cdc-acm.c8
-rw-r--r--drivers/usb/core/Kconfig15
-rw-r--r--drivers/usb/core/buffer.c2
-rw-r--r--drivers/usb/core/devices.c9
-rw-r--r--drivers/usb/core/devio.c4
-rw-r--r--drivers/usb/core/driver.c304
-rw-r--r--drivers/usb/core/endpoint.c98
-rw-r--r--drivers/usb/core/hcd.c4
-rw-r--r--drivers/usb/core/hub.c259
-rw-r--r--drivers/usb/core/hub.h41
-rw-r--r--drivers/usb/core/message.c22
-rw-r--r--drivers/usb/core/usb.c169
-rw-r--r--drivers/usb/core/usb.h9
-rw-r--r--drivers/usb/gadget/Kconfig2
-rw-r--r--drivers/usb/gadget/ether.c10
-rw-r--r--drivers/usb/gadget/file_storage.c2
-rw-r--r--drivers/usb/gadget/gmidi.c2
-rw-r--r--drivers/usb/gadget/goku_udc.c2
-rw-r--r--drivers/usb/gadget/inode.c6
-rw-r--r--drivers/usb/gadget/lh7a40x_udc.c1
-rw-r--r--drivers/usb/gadget/net2280.c10
-rw-r--r--drivers/usb/gadget/net2280.h3
-rw-r--r--drivers/usb/gadget/omap_udc.c2
-rw-r--r--drivers/usb/gadget/pxa2xx_udc.c2
-rw-r--r--drivers/usb/gadget/zero.c2
-rw-r--r--drivers/usb/host/Kconfig2
-rw-r--r--drivers/usb/host/ehci-dbg.c2
-rw-r--r--drivers/usb/host/ehci-hcd.c16
-rw-r--r--drivers/usb/host/ehci-hub.c104
-rw-r--r--drivers/usb/host/ehci-pci.c40
-rw-r--r--drivers/usb/host/ehci.h1
-rw-r--r--drivers/usb/host/hc_crisv10.c16
-rw-r--r--drivers/usb/host/ohci-dbg.c2
-rw-r--r--drivers/usb/host/ohci-hcd.c40
-rw-r--r--drivers/usb/host/ohci-hub.c172
-rw-r--r--drivers/usb/host/ohci-pnx4008.c2
-rw-r--r--drivers/usb/host/sl811_cs.c15
-rw-r--r--drivers/usb/host/u132-hcd.c76
-rw-r--r--drivers/usb/host/uhci-hcd.c2
-rw-r--r--drivers/usb/host/uhci-q.c2
-rw-r--r--drivers/usb/image/microtek.c8
-rw-r--r--drivers/usb/input/Kconfig6
-rw-r--r--drivers/usb/input/acecad.c2
-rw-r--r--drivers/usb/input/aiptek.c2
-rw-r--r--drivers/usb/input/ati_remote.c23
-rw-r--r--drivers/usb/input/ati_remote2.c3
-rw-r--r--drivers/usb/input/hid-core.c107
-rw-r--r--drivers/usb/input/hid-input.c17
-rw-r--r--drivers/usb/input/hid.h4
-rw-r--r--drivers/usb/input/keyspan_remote.c2
-rw-r--r--drivers/usb/input/mtouchusb.c2
-rw-r--r--drivers/usb/input/powermate.c4
-rw-r--r--drivers/usb/input/touchkitusb.c2
-rw-r--r--drivers/usb/input/usbkbd.c18
-rw-r--r--drivers/usb/input/usbmouse.c8
-rw-r--r--drivers/usb/input/usbtouchscreen.c98
-rw-r--r--drivers/usb/input/wacom.h1
-rw-r--r--drivers/usb/input/wacom_sys.c2
-rw-r--r--drivers/usb/input/xpad.c2
-rw-r--r--drivers/usb/input/yealink.c12
-rw-r--r--drivers/usb/misc/Makefile1
-rw-r--r--drivers/usb/misc/appledisplay.c16
-rw-r--r--drivers/usb/misc/auerswald.c9
-rw-r--r--drivers/usb/misc/emi26.c3
-rw-r--r--drivers/usb/misc/emi62.c3
-rw-r--r--drivers/usb/misc/ftdi-elan.c106
-rw-r--r--drivers/usb/misc/idmouse.c22
-rw-r--r--drivers/usb/misc/legousbtower.c31
-rw-r--r--drivers/usb/misc/phidgetkit.c30
-rw-r--r--drivers/usb/misc/phidgetmotorcontrol.c20
-rw-r--r--drivers/usb/misc/usb_u132.h6
-rw-r--r--drivers/usb/misc/usbtest.c40
-rw-r--r--drivers/usb/mon/mon_text.c10
-rw-r--r--drivers/usb/net/asix.c6
-rw-r--r--drivers/usb/net/catc.c14
-rw-r--r--drivers/usb/net/cdc_ether.c3
-rw-r--r--drivers/usb/net/kaweth.c9
-rw-r--r--drivers/usb/net/net1080.c6
-rw-r--r--drivers/usb/net/pegasus.c9
-rw-r--r--drivers/usb/net/pegasus.h2
-rw-r--r--drivers/usb/net/rndis_host.c2
-rw-r--r--drivers/usb/net/rtl8150.c2
-rw-r--r--drivers/usb/net/usbnet.c15
-rw-r--r--drivers/usb/serial/Kconfig11
-rw-r--r--drivers/usb/serial/Makefile1
-rw-r--r--drivers/usb/serial/aircable.c22
-rw-r--r--drivers/usb/serial/airprime.c1
-rw-r--r--drivers/usb/serial/ark3116.c3
-rw-r--r--drivers/usb/serial/console.c6
-rw-r--r--drivers/usb/serial/cypress_m8.c9
-rw-r--r--drivers/usb/serial/digi_acceleport.c16
-rw-r--r--drivers/usb/serial/ezusb.c3
-rw-r--r--drivers/usb/serial/ftdi_sio.c24
-rw-r--r--drivers/usb/serial/ftdi_sio.h11
-rw-r--r--drivers/usb/serial/garmin_gps.c3
-rw-r--r--drivers/usb/serial/io_edgeport.c4
-rw-r--r--drivers/usb/serial/ipaq.c1
-rw-r--r--drivers/usb/serial/ipw.c3
-rw-r--r--drivers/usb/serial/keyspan.c18
-rw-r--r--drivers/usb/serial/keyspan_pda.c22
-rw-r--r--drivers/usb/serial/kobil_sct.c9
-rw-r--r--drivers/usb/serial/mct_u232.c6
-rw-r--r--drivers/usb/serial/mos7720.c2
-rw-r--r--drivers/usb/serial/mos7840.c7
-rw-r--r--drivers/usb/serial/navman.c3
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c5
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.h1
-rw-r--r--drivers/usb/serial/usb-serial.c19
-rw-r--r--drivers/usb/serial/usb_debug.c65
-rw-r--r--drivers/usb/serial/visor.c3
-rw-r--r--drivers/usb/serial/whiteheat.c15
-rw-r--r--drivers/usb/storage/onetouch.c9
-rw-r--r--drivers/usb/storage/transport.c2
-rw-r--r--drivers/usb/storage/unusual_devs.h28
-rw-r--r--drivers/usb/storage/usb.c10
-rw-r--r--drivers/video/aty/atyfb_base.c2
-rw-r--r--drivers/video/aty/radeon_i2c.c8
-rw-r--r--drivers/video/console/fbcon.c6
-rw-r--r--drivers/video/fb_ddc.c6
-rw-r--r--drivers/video/fbmem.c16
-rw-r--r--drivers/video/fbsysfs.c163
-rw-r--r--drivers/video/geode/gxfb_core.c2
-rw-r--r--drivers/video/nvidia/nv_hw.c12
-rw-r--r--drivers/video/nvidia/nv_setup.c20
-rw-r--r--drivers/video/nvidia/nv_type.h1
-rw-r--r--drivers/video/nvidia/nvidia.c24
-rw-r--r--drivers/video/platinumfb.c5
-rw-r--r--drivers/video/pnx4008/pnxrgbfb.c5
-rw-r--r--drivers/video/pnx4008/sdum.c2
-rw-r--r--drivers/video/pxafb.c7
-rw-r--r--drivers/w1/Makefile4
-rw-r--r--drivers/w1/masters/matrox_w1.c2
-rw-r--r--drivers/w1/slaves/Makefile4
-rw-r--r--drivers/w1/slaves/w1_ds2433.c30
-rw-r--r--drivers/w1/slaves/w1_therm.c1
-rw-r--r--drivers/w1/w1.c1
1206 files changed, 58319 insertions, 35635 deletions
diff --git a/drivers/Makefile b/drivers/Makefile
index 4ac14dab3079..67711770b1d9 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -77,3 +77,4 @@ obj-$(CONFIG_CRYPTO) += crypto/
77obj-$(CONFIG_SUPERH) += sh/ 77obj-$(CONFIG_SUPERH) += sh/
78obj-$(CONFIG_GENERIC_TIME) += clocksource/ 78obj-$(CONFIG_GENERIC_TIME) += clocksource/
79obj-$(CONFIG_DMA_ENGINE) += dma/ 79obj-$(CONFIG_DMA_ENGINE) += dma/
80obj-$(CONFIG_PPC_PS3) += ps3/
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index 578b99b71d9c..bf5b79ed3613 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -27,6 +27,7 @@
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/types.h> 28#include <linux/types.h>
29#include <linux/notifier.h> 29#include <linux/notifier.h>
30#include <linux/jiffies.h>
30#include <acpi/acpi_bus.h> 31#include <acpi/acpi_bus.h>
31#include <acpi/acpi_drivers.h> 32#include <acpi/acpi_drivers.h>
32 33
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index 10f160dc75b1..a2f46d587d55 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -267,9 +267,9 @@ static int acpi_bind_one(struct device *dev, acpi_handle handle)
267{ 267{
268 acpi_status status; 268 acpi_status status;
269 269
270 if (dev->firmware_data) { 270 if (dev->archdata.acpi_handle) {
271 printk(KERN_WARNING PREFIX 271 printk(KERN_WARNING PREFIX
272 "Drivers changed 'firmware_data' for %s\n", dev->bus_id); 272 "Drivers changed 'acpi_handle' for %s\n", dev->bus_id);
273 return -EINVAL; 273 return -EINVAL;
274 } 274 }
275 get_device(dev); 275 get_device(dev);
@@ -278,25 +278,26 @@ static int acpi_bind_one(struct device *dev, acpi_handle handle)
278 put_device(dev); 278 put_device(dev);
279 return -EINVAL; 279 return -EINVAL;
280 } 280 }
281 dev->firmware_data = handle; 281 dev->archdata.acpi_handle = handle;
282 282
283 return 0; 283 return 0;
284} 284}
285 285
286static int acpi_unbind_one(struct device *dev) 286static int acpi_unbind_one(struct device *dev)
287{ 287{
288 if (!dev->firmware_data) 288 if (!dev->archdata.acpi_handle)
289 return 0; 289 return 0;
290 if (dev == acpi_get_physical_device(dev->firmware_data)) { 290 if (dev == acpi_get_physical_device(dev->archdata.acpi_handle)) {
291 /* acpi_get_physical_device increase refcnt by one */ 291 /* acpi_get_physical_device increase refcnt by one */
292 put_device(dev); 292 put_device(dev);
293 acpi_detach_data(dev->firmware_data, acpi_glue_data_handler); 293 acpi_detach_data(dev->archdata.acpi_handle,
294 dev->firmware_data = NULL; 294 acpi_glue_data_handler);
295 dev->archdata.acpi_handle = NULL;
295 /* acpi_bind_one increase refcnt by one */ 296 /* acpi_bind_one increase refcnt by one */
296 put_device(dev); 297 put_device(dev);
297 } else { 298 } else {
298 printk(KERN_ERR PREFIX 299 printk(KERN_ERR PREFIX
299 "Oops, 'firmware_data' corrupt for %s\n", dev->bus_id); 300 "Oops, 'acpi_handle' corrupt for %s\n", dev->bus_id);
300 } 301 }
301 return 0; 302 return 0;
302} 303}
@@ -328,7 +329,8 @@ static int acpi_platform_notify(struct device *dev)
328 if (!ret) { 329 if (!ret) {
329 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 330 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
330 331
331 acpi_get_name(dev->firmware_data, ACPI_FULL_PATHNAME, &buffer); 332 acpi_get_name(dev->archdata.acpi_handle,
333 ACPI_FULL_PATHNAME, &buffer);
332 DBG("Device %s -> %s\n", dev->bus_id, (char *)buffer.pointer); 334 DBG("Device %s -> %s\n", dev->bus_id, (char *)buffer.pointer);
333 kfree(buffer.pointer); 335 kfree(buffer.pointer);
334 } else 336 } else
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index c84286cbbe25..02b30ae6a68e 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -50,6 +50,7 @@ ACPI_MODULE_NAME("osl")
50struct acpi_os_dpc { 50struct acpi_os_dpc {
51 acpi_osd_exec_callback function; 51 acpi_osd_exec_callback function;
52 void *context; 52 void *context;
53 struct work_struct work;
53}; 54};
54 55
55#ifdef CONFIG_ACPI_CUSTOM_DSDT 56#ifdef CONFIG_ACPI_CUSTOM_DSDT
@@ -73,7 +74,6 @@ static unsigned int acpi_irq_irq;
73static acpi_osd_handler acpi_irq_handler; 74static acpi_osd_handler acpi_irq_handler;
74static void *acpi_irq_context; 75static void *acpi_irq_context;
75static struct workqueue_struct *kacpid_wq; 76static struct workqueue_struct *kacpid_wq;
76static struct workqueue_struct *kacpi_notify_wq;
77 77
78acpi_status acpi_os_initialize(void) 78acpi_status acpi_os_initialize(void)
79{ 79{
@@ -92,9 +92,8 @@ acpi_status acpi_os_initialize1(void)
92 return AE_NULL_ENTRY; 92 return AE_NULL_ENTRY;
93 } 93 }
94 kacpid_wq = create_singlethread_workqueue("kacpid"); 94 kacpid_wq = create_singlethread_workqueue("kacpid");
95 kacpi_notify_wq = create_singlethread_workqueue("kacpi_notify");
96 BUG_ON(!kacpid_wq); 95 BUG_ON(!kacpid_wq);
97 BUG_ON(!kacpi_notify_wq); 96
98 return AE_OK; 97 return AE_OK;
99} 98}
100 99
@@ -106,7 +105,6 @@ acpi_status acpi_os_terminate(void)
106 } 105 }
107 106
108 destroy_workqueue(kacpid_wq); 107 destroy_workqueue(kacpid_wq);
109 destroy_workqueue(kacpi_notify_wq);
110 108
111 return AE_OK; 109 return AE_OK;
112} 110}
@@ -567,9 +565,9 @@ void acpi_os_derive_pci_id(acpi_handle rhandle, /* upper bound */
567 acpi_os_derive_pci_id_2(rhandle, chandle, id, &is_bridge, &bus_number); 565 acpi_os_derive_pci_id_2(rhandle, chandle, id, &is_bridge, &bus_number);
568} 566}
569 567
570static void acpi_os_execute_deferred(void *context) 568static void acpi_os_execute_deferred(struct work_struct *work)
571{ 569{
572 struct acpi_os_dpc *dpc = (struct acpi_os_dpc *)context; 570 struct acpi_os_dpc *dpc = container_of(work, struct acpi_os_dpc, work);
573 if (!dpc) { 571 if (!dpc) {
574 printk(KERN_ERR PREFIX "Invalid (NULL) context\n"); 572 printk(KERN_ERR PREFIX "Invalid (NULL) context\n");
575 return; 573 return;
@@ -602,40 +600,41 @@ acpi_status acpi_os_execute(acpi_execute_type type,
602{ 600{
603 acpi_status status = AE_OK; 601 acpi_status status = AE_OK;
604 struct acpi_os_dpc *dpc; 602 struct acpi_os_dpc *dpc;
605 struct work_struct *task; 603
604 ACPI_FUNCTION_TRACE("os_queue_for_execution");
606 605
607 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 606 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
608 "Scheduling function [%p(%p)] for deferred execution.\n", 607 "Scheduling function [%p(%p)] for deferred execution.\n",
609 function, context)); 608 function, context));
610 609
611 if (!function) 610 if (!function)
612 return AE_BAD_PARAMETER; 611 return_ACPI_STATUS(AE_BAD_PARAMETER);
613 612
614 /* 613 /*
615 * Allocate/initialize DPC structure. Note that this memory will be 614 * Allocate/initialize DPC structure. Note that this memory will be
616 * freed by the callee. The kernel handles the tq_struct list in a 615 * freed by the callee. The kernel handles the work_struct list in a
617 * way that allows us to also free its memory inside the callee. 616 * way that allows us to also free its memory inside the callee.
618 * Because we may want to schedule several tasks with different 617 * Because we may want to schedule several tasks with different
619 * parameters we can't use the approach some kernel code uses of 618 * parameters we can't use the approach some kernel code uses of
620 * having a static tq_struct. 619 * having a static work_struct.
621 * We can save time and code by allocating the DPC and tq_structs
622 * from the same memory.
623 */ 620 */
624 621
625 dpc = kmalloc(sizeof(struct acpi_os_dpc) + 622 dpc = kmalloc(sizeof(struct acpi_os_dpc), GFP_ATOMIC);
626 sizeof(struct work_struct), GFP_ATOMIC);
627 if (!dpc) 623 if (!dpc)
628 return AE_NO_MEMORY; 624 return_ACPI_STATUS(AE_NO_MEMORY);
625
629 dpc->function = function; 626 dpc->function = function;
630 dpc->context = context; 627 dpc->context = context;
631 task = (void *)(dpc + 1); 628
632 INIT_WORK(task, acpi_os_execute_deferred, (void *)dpc); 629 INIT_WORK(&dpc->work, acpi_os_execute_deferred);
633 if (!queue_work((type == OSL_NOTIFY_HANDLER)? 630 if (!queue_work(kacpid_wq, &dpc->work)) {
634 kacpi_notify_wq : kacpid_wq, task)) { 631 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
635 status = AE_ERROR; 632 "Call to queue_work() failed.\n"));
636 kfree(dpc); 633 kfree(dpc);
634 status = AE_ERROR;
637 } 635 }
638 return status; 636
637 return_ACPI_STATUS(status);
639} 638}
640 639
641EXPORT_SYMBOL(acpi_os_execute); 640EXPORT_SYMBOL(acpi_os_execute);
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index 7ba5e49ab302..6fd174a37149 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -83,10 +83,8 @@ static int acpi_processor_ppc_notifier(struct notifier_block *nb,
83 goto out; 83 goto out;
84 84
85 ppc = (unsigned int)pr->performance_platform_limit; 85 ppc = (unsigned int)pr->performance_platform_limit;
86 if (!ppc)
87 goto out;
88 86
89 if (ppc > pr->performance->state_count) 87 if (ppc >= pr->performance->state_count)
90 goto out; 88 goto out;
91 89
92 cpufreq_verify_within_limits(policy, 0, 90 cpufreq_verify_within_limits(policy, 0,
diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index 9e3e2a69c03a..fd5475071acc 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -80,12 +80,38 @@ static int amba_resume(struct device *dev)
80 return ret; 80 return ret;
81} 81}
82 82
83#define amba_attr_func(name,fmt,arg...) \
84static ssize_t name##_show(struct device *_dev, \
85 struct device_attribute *attr, char *buf) \
86{ \
87 struct amba_device *dev = to_amba_device(_dev); \
88 return sprintf(buf, fmt, arg); \
89}
90
91#define amba_attr(name,fmt,arg...) \
92amba_attr_func(name,fmt,arg) \
93static DEVICE_ATTR(name, S_IRUGO, name##_show, NULL)
94
95amba_attr_func(id, "%08x\n", dev->periphid);
96amba_attr(irq0, "%u\n", dev->irq[0]);
97amba_attr(irq1, "%u\n", dev->irq[1]);
98amba_attr_func(resource, "\t%016llx\t%016llx\t%016lx\n",
99 (unsigned long long)dev->res.start, (unsigned long long)dev->res.end,
100 dev->res.flags);
101
102static struct device_attribute amba_dev_attrs[] = {
103 __ATTR_RO(id),
104 __ATTR_RO(resource),
105 __ATTR_NULL,
106};
107
83/* 108/*
84 * Primecells are part of the Advanced Microcontroller Bus Architecture, 109 * Primecells are part of the Advanced Microcontroller Bus Architecture,
85 * so we call the bus "amba". 110 * so we call the bus "amba".
86 */ 111 */
87static struct bus_type amba_bustype = { 112static struct bus_type amba_bustype = {
88 .name = "amba", 113 .name = "amba",
114 .dev_attrs = amba_dev_attrs,
89 .match = amba_match, 115 .match = amba_match,
90 .uevent = amba_uevent, 116 .uevent = amba_uevent,
91 .suspend = amba_suspend, 117 .suspend = amba_suspend,
@@ -169,21 +195,6 @@ static void amba_device_release(struct device *dev)
169 kfree(d); 195 kfree(d);
170} 196}
171 197
172#define amba_attr(name,fmt,arg...) \
173static ssize_t show_##name(struct device *_dev, struct device_attribute *attr, char *buf) \
174{ \
175 struct amba_device *dev = to_amba_device(_dev); \
176 return sprintf(buf, fmt, arg); \
177} \
178static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL)
179
180amba_attr(id, "%08x\n", dev->periphid);
181amba_attr(irq0, "%u\n", dev->irq[0]);
182amba_attr(irq1, "%u\n", dev->irq[1]);
183amba_attr(resource, "\t%016llx\t%016llx\t%016lx\n",
184 (unsigned long long)dev->res.start, (unsigned long long)dev->res.end,
185 dev->res.flags);
186
187/** 198/**
188 * amba_device_register - register an AMBA device 199 * amba_device_register - register an AMBA device
189 * @dev: AMBA device to register 200 * @dev: AMBA device to register
@@ -208,40 +219,46 @@ int amba_device_register(struct amba_device *dev, struct resource *parent)
208 dev_warn(&dev->dev, "coherent dma mask is unset\n"); 219 dev_warn(&dev->dev, "coherent dma mask is unset\n");
209 220
210 ret = request_resource(parent, &dev->res); 221 ret = request_resource(parent, &dev->res);
211 if (ret == 0) { 222 if (ret)
212 tmp = ioremap(dev->res.start, SZ_4K); 223 goto err_out;
213 if (!tmp) { 224
214 ret = -ENOMEM; 225 tmp = ioremap(dev->res.start, SZ_4K);
215 goto out; 226 if (!tmp) {
216 } 227 ret = -ENOMEM;
217 228 goto err_release;
218 for (pid = 0, i = 0; i < 4; i++)
219 pid |= (readl(tmp + 0xfe0 + 4 * i) & 255) << (i * 8);
220 for (cid = 0, i = 0; i < 4; i++)
221 cid |= (readl(tmp + 0xff0 + 4 * i) & 255) << (i * 8);
222
223 iounmap(tmp);
224
225 if (cid == 0xb105f00d)
226 dev->periphid = pid;
227
228 if (dev->periphid)
229 ret = device_register(&dev->dev);
230 else
231 ret = -ENODEV;
232
233 if (ret == 0) {
234 device_create_file(&dev->dev, &dev_attr_id);
235 if (dev->irq[0] != NO_IRQ)
236 device_create_file(&dev->dev, &dev_attr_irq0);
237 if (dev->irq[1] != NO_IRQ)
238 device_create_file(&dev->dev, &dev_attr_irq1);
239 device_create_file(&dev->dev, &dev_attr_resource);
240 } else {
241 out:
242 release_resource(&dev->res);
243 }
244 } 229 }
230
231 for (pid = 0, i = 0; i < 4; i++)
232 pid |= (readl(tmp + 0xfe0 + 4 * i) & 255) << (i * 8);
233 for (cid = 0, i = 0; i < 4; i++)
234 cid |= (readl(tmp + 0xff0 + 4 * i) & 255) << (i * 8);
235
236 iounmap(tmp);
237
238 if (cid == 0xb105f00d)
239 dev->periphid = pid;
240
241 if (!dev->periphid) {
242 ret = -ENODEV;
243 goto err_release;
244 }
245
246 ret = device_register(&dev->dev);
247 if (ret)
248 goto err_release;
249
250 if (dev->irq[0] != NO_IRQ)
251 ret = device_create_file(&dev->dev, &dev_attr_irq0);
252 if (ret == 0 && dev->irq[1] != NO_IRQ)
253 ret = device_create_file(&dev->dev, &dev_attr_irq1);
254 if (ret == 0)
255 return ret;
256
257 device_unregister(&dev->dev);
258
259 err_release:
260 release_resource(&dev->res);
261 err_out:
245 return ret; 262 return ret;
246} 263}
247 264
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index 03f6338acc8f..984ab284382a 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -328,6 +328,15 @@ config PATA_TRIFLEX
328 328
329 If unsure, say N. 329 If unsure, say N.
330 330
331config PATA_MARVELL
332 tristate "Marvell PATA support via legacy mode"
333 depends on PCI
334 help
335 This option enables limited support for the Marvell 88SE6145 ATA
336 controller.
337
338 If unsure, say N.
339
331config PATA_MPIIX 340config PATA_MPIIX
332 tristate "Intel PATA MPIIX support" 341 tristate "Intel PATA MPIIX support"
333 depends on PCI 342 depends on PCI
@@ -483,6 +492,32 @@ config PATA_WINBOND
483 492
484 If unsure, say N. 493 If unsure, say N.
485 494
495config PATA_WINBOND_VLB
496 tristate "Winbond W83759A VLB PATA support (Experimental)"
497 depends on ISA && EXPERIMENTAL
498 help
499 Support for the Winbond W83759A controller on Vesa Local Bus
500 systems.
501
502config PATA_PLATFORM
503 tristate "Generic platform device PATA support"
504 depends on EMBEDDED
505 help
506 This option enables support for generic directly connected ATA
507 devices commonly found on embedded systems.
508
509 If unsure, say N.
510
511config PATA_IXP4XX_CF
512 tristate "IXP4XX Compact Flash support"
513 depends on ARCH_IXP4XX
514 help
515 This option enables support for a Compact Flash connected on
516 the ixp4xx expansion bus. This driver had been written for
517 Loft/Avila boards in mind but can work with others.
518
519 If unsure, say N.
520
486endif 521endif
487endmenu 522endmenu
488 523
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
index 72243a677f9b..bc3d81ae757e 100644
--- a/drivers/ata/Makefile
+++ b/drivers/ata/Makefile
@@ -38,6 +38,7 @@ obj-$(CONFIG_PATA_NETCELL) += pata_netcell.o
38obj-$(CONFIG_PATA_NS87410) += pata_ns87410.o 38obj-$(CONFIG_PATA_NS87410) += pata_ns87410.o
39obj-$(CONFIG_PATA_OPTI) += pata_opti.o 39obj-$(CONFIG_PATA_OPTI) += pata_opti.o
40obj-$(CONFIG_PATA_OPTIDMA) += pata_optidma.o 40obj-$(CONFIG_PATA_OPTIDMA) += pata_optidma.o
41obj-$(CONFIG_PATA_MARVELL) += pata_marvell.o
41obj-$(CONFIG_PATA_MPIIX) += pata_mpiix.o 42obj-$(CONFIG_PATA_MPIIX) += pata_mpiix.o
42obj-$(CONFIG_PATA_OLDPIIX) += pata_oldpiix.o 43obj-$(CONFIG_PATA_OLDPIIX) += pata_oldpiix.o
43obj-$(CONFIG_PATA_PCMCIA) += pata_pcmcia.o 44obj-$(CONFIG_PATA_PCMCIA) += pata_pcmcia.o
@@ -51,8 +52,11 @@ obj-$(CONFIG_PATA_SERVERWORKS) += pata_serverworks.o
51obj-$(CONFIG_PATA_SIL680) += pata_sil680.o 52obj-$(CONFIG_PATA_SIL680) += pata_sil680.o
52obj-$(CONFIG_PATA_VIA) += pata_via.o 53obj-$(CONFIG_PATA_VIA) += pata_via.o
53obj-$(CONFIG_PATA_WINBOND) += pata_sl82c105.o 54obj-$(CONFIG_PATA_WINBOND) += pata_sl82c105.o
55obj-$(CONFIG_PATA_WINBOND_VLB) += pata_winbond.o
54obj-$(CONFIG_PATA_SIS) += pata_sis.o 56obj-$(CONFIG_PATA_SIS) += pata_sis.o
55obj-$(CONFIG_PATA_TRIFLEX) += pata_triflex.o 57obj-$(CONFIG_PATA_TRIFLEX) += pata_triflex.o
58obj-$(CONFIG_PATA_IXP4XX_CF) += pata_ixp4xx_cf.o
59obj-$(CONFIG_PATA_PLATFORM) += pata_platform.o
56# Should be last but one libata driver 60# Should be last but one libata driver
57obj-$(CONFIG_ATA_GENERIC) += ata_generic.o 61obj-$(CONFIG_ATA_GENERIC) += ata_generic.o
58# Should be last libata driver 62# Should be last libata driver
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 234197e57e9e..f36da488a2c1 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -53,6 +53,7 @@
53 53
54enum { 54enum {
55 AHCI_PCI_BAR = 5, 55 AHCI_PCI_BAR = 5,
56 AHCI_MAX_PORTS = 32,
56 AHCI_MAX_SG = 168, /* hardware max is 64K */ 57 AHCI_MAX_SG = 168, /* hardware max is 64K */
57 AHCI_DMA_BOUNDARY = 0xffffffff, 58 AHCI_DMA_BOUNDARY = 0xffffffff,
58 AHCI_USE_CLUSTERING = 0, 59 AHCI_USE_CLUSTERING = 0,
@@ -77,7 +78,9 @@ enum {
77 RX_FIS_UNK = 0x60, /* offset of Unknown FIS data */ 78 RX_FIS_UNK = 0x60, /* offset of Unknown FIS data */
78 79
79 board_ahci = 0, 80 board_ahci = 0,
80 board_ahci_vt8251 = 1, 81 board_ahci_pi = 1,
82 board_ahci_vt8251 = 2,
83 board_ahci_ign_iferr = 3,
81 84
82 /* global controller registers */ 85 /* global controller registers */
83 HOST_CAP = 0x00, /* host capabilities */ 86 HOST_CAP = 0x00, /* host capabilities */
@@ -166,8 +169,9 @@ enum {
166 AHCI_FLAG_MSI = (1 << 0), 169 AHCI_FLAG_MSI = (1 << 0),
167 170
168 /* ap->flags bits */ 171 /* ap->flags bits */
169 AHCI_FLAG_RESET_NEEDS_CLO = (1 << 24), 172 AHCI_FLAG_NO_NCQ = (1 << 24),
170 AHCI_FLAG_NO_NCQ = (1 << 25), 173 AHCI_FLAG_IGN_IRQ_IF_ERR = (1 << 25), /* ignore IRQ_IF_ERR */
174 AHCI_FLAG_HONOR_PI = (1 << 26), /* honor PORTS_IMPL */
171}; 175};
172 176
173struct ahci_cmd_hdr { 177struct ahci_cmd_hdr {
@@ -214,6 +218,7 @@ static u8 ahci_check_status(struct ata_port *ap);
214static void ahci_freeze(struct ata_port *ap); 218static void ahci_freeze(struct ata_port *ap);
215static void ahci_thaw(struct ata_port *ap); 219static void ahci_thaw(struct ata_port *ap);
216static void ahci_error_handler(struct ata_port *ap); 220static void ahci_error_handler(struct ata_port *ap);
221static void ahci_vt8251_error_handler(struct ata_port *ap);
217static void ahci_post_internal_cmd(struct ata_queued_cmd *qc); 222static void ahci_post_internal_cmd(struct ata_queued_cmd *qc);
218static int ahci_port_suspend(struct ata_port *ap, pm_message_t mesg); 223static int ahci_port_suspend(struct ata_port *ap, pm_message_t mesg);
219static int ahci_port_resume(struct ata_port *ap); 224static int ahci_port_resume(struct ata_port *ap);
@@ -273,6 +278,37 @@ static const struct ata_port_operations ahci_ops = {
273 .port_stop = ahci_port_stop, 278 .port_stop = ahci_port_stop,
274}; 279};
275 280
281static const struct ata_port_operations ahci_vt8251_ops = {
282 .port_disable = ata_port_disable,
283
284 .check_status = ahci_check_status,
285 .check_altstatus = ahci_check_status,
286 .dev_select = ata_noop_dev_select,
287
288 .tf_read = ahci_tf_read,
289
290 .qc_prep = ahci_qc_prep,
291 .qc_issue = ahci_qc_issue,
292
293 .irq_handler = ahci_interrupt,
294 .irq_clear = ahci_irq_clear,
295
296 .scr_read = ahci_scr_read,
297 .scr_write = ahci_scr_write,
298
299 .freeze = ahci_freeze,
300 .thaw = ahci_thaw,
301
302 .error_handler = ahci_vt8251_error_handler,
303 .post_internal_cmd = ahci_post_internal_cmd,
304
305 .port_suspend = ahci_port_suspend,
306 .port_resume = ahci_port_resume,
307
308 .port_start = ahci_port_start,
309 .port_stop = ahci_port_stop,
310};
311
276static const struct ata_port_info ahci_port_info[] = { 312static const struct ata_port_info ahci_port_info[] = {
277 /* board_ahci */ 313 /* board_ahci */
278 { 314 {
@@ -284,13 +320,34 @@ static const struct ata_port_info ahci_port_info[] = {
284 .udma_mask = 0x7f, /* udma0-6 ; FIXME */ 320 .udma_mask = 0x7f, /* udma0-6 ; FIXME */
285 .port_ops = &ahci_ops, 321 .port_ops = &ahci_ops,
286 }, 322 },
323 /* board_ahci_pi */
324 {
325 .sht = &ahci_sht,
326 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
327 ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA |
328 ATA_FLAG_SKIP_D2H_BSY | AHCI_FLAG_HONOR_PI,
329 .pio_mask = 0x1f, /* pio0-4 */
330 .udma_mask = 0x7f, /* udma0-6 ; FIXME */
331 .port_ops = &ahci_ops,
332 },
287 /* board_ahci_vt8251 */ 333 /* board_ahci_vt8251 */
288 { 334 {
289 .sht = &ahci_sht, 335 .sht = &ahci_sht,
290 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 336 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
291 ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA | 337 ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA |
292 ATA_FLAG_SKIP_D2H_BSY | 338 ATA_FLAG_SKIP_D2H_BSY |
293 AHCI_FLAG_RESET_NEEDS_CLO | AHCI_FLAG_NO_NCQ, 339 ATA_FLAG_HRST_TO_RESUME | AHCI_FLAG_NO_NCQ,
340 .pio_mask = 0x1f, /* pio0-4 */
341 .udma_mask = 0x7f, /* udma0-6 ; FIXME */
342 .port_ops = &ahci_vt8251_ops,
343 },
344 /* board_ahci_ign_iferr */
345 {
346 .sht = &ahci_sht,
347 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
348 ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA |
349 ATA_FLAG_SKIP_D2H_BSY |
350 AHCI_FLAG_IGN_IRQ_IF_ERR,
294 .pio_mask = 0x1f, /* pio0-4 */ 351 .pio_mask = 0x1f, /* pio0-4 */
295 .udma_mask = 0x7f, /* udma0-6 ; FIXME */ 352 .udma_mask = 0x7f, /* udma0-6 ; FIXME */
296 .port_ops = &ahci_ops, 353 .port_ops = &ahci_ops,
@@ -309,18 +366,29 @@ static const struct pci_device_id ahci_pci_tbl[] = {
309 { PCI_VDEVICE(INTEL, 0x2682), board_ahci }, /* ESB2 */ 366 { PCI_VDEVICE(INTEL, 0x2682), board_ahci }, /* ESB2 */
310 { PCI_VDEVICE(INTEL, 0x2683), board_ahci }, /* ESB2 */ 367 { PCI_VDEVICE(INTEL, 0x2683), board_ahci }, /* ESB2 */
311 { PCI_VDEVICE(INTEL, 0x27c6), board_ahci }, /* ICH7-M DH */ 368 { PCI_VDEVICE(INTEL, 0x27c6), board_ahci }, /* ICH7-M DH */
312 { PCI_VDEVICE(INTEL, 0x2821), board_ahci }, /* ICH8 */ 369 { PCI_VDEVICE(INTEL, 0x2821), board_ahci_pi }, /* ICH8 */
313 { PCI_VDEVICE(INTEL, 0x2822), board_ahci }, /* ICH8 */ 370 { PCI_VDEVICE(INTEL, 0x2822), board_ahci_pi }, /* ICH8 */
314 { PCI_VDEVICE(INTEL, 0x2824), board_ahci }, /* ICH8 */ 371 { PCI_VDEVICE(INTEL, 0x2824), board_ahci_pi }, /* ICH8 */
315 { PCI_VDEVICE(INTEL, 0x2829), board_ahci }, /* ICH8M */ 372 { PCI_VDEVICE(INTEL, 0x2829), board_ahci_pi }, /* ICH8M */
316 { PCI_VDEVICE(INTEL, 0x282a), board_ahci }, /* ICH8M */ 373 { PCI_VDEVICE(INTEL, 0x282a), board_ahci_pi }, /* ICH8M */
374 { PCI_VDEVICE(INTEL, 0x2922), board_ahci_pi }, /* ICH9 */
375 { PCI_VDEVICE(INTEL, 0x2923), board_ahci_pi }, /* ICH9 */
376 { PCI_VDEVICE(INTEL, 0x2924), board_ahci_pi }, /* ICH9 */
377 { PCI_VDEVICE(INTEL, 0x2925), board_ahci_pi }, /* ICH9 */
378 { PCI_VDEVICE(INTEL, 0x2927), board_ahci_pi }, /* ICH9 */
379 { PCI_VDEVICE(INTEL, 0x2929), board_ahci_pi }, /* ICH9M */
380 { PCI_VDEVICE(INTEL, 0x292a), board_ahci_pi }, /* ICH9M */
381 { PCI_VDEVICE(INTEL, 0x292b), board_ahci_pi }, /* ICH9M */
382 { PCI_VDEVICE(INTEL, 0x292f), board_ahci_pi }, /* ICH9M */
383 { PCI_VDEVICE(INTEL, 0x294d), board_ahci_pi }, /* ICH9 */
384 { PCI_VDEVICE(INTEL, 0x294e), board_ahci_pi }, /* ICH9M */
317 385
318 /* JMicron */ 386 /* JMicron */
319 { PCI_VDEVICE(JMICRON, 0x2360), board_ahci }, /* JMicron JMB360 */ 387 { PCI_VDEVICE(JMICRON, 0x2360), board_ahci_ign_iferr }, /* JMB360 */
320 { PCI_VDEVICE(JMICRON, 0x2361), board_ahci }, /* JMicron JMB361 */ 388 { PCI_VDEVICE(JMICRON, 0x2361), board_ahci_ign_iferr }, /* JMB361 */
321 { PCI_VDEVICE(JMICRON, 0x2363), board_ahci }, /* JMicron JMB363 */ 389 { PCI_VDEVICE(JMICRON, 0x2363), board_ahci_ign_iferr }, /* JMB363 */
322 { PCI_VDEVICE(JMICRON, 0x2365), board_ahci }, /* JMicron JMB365 */ 390 { PCI_VDEVICE(JMICRON, 0x2365), board_ahci_ign_iferr }, /* JMB365 */
323 { PCI_VDEVICE(JMICRON, 0x2366), board_ahci }, /* JMicron JMB366 */ 391 { PCI_VDEVICE(JMICRON, 0x2366), board_ahci_ign_iferr }, /* JMB366 */
324 392
325 /* ATI */ 393 /* ATI */
326 { PCI_VDEVICE(ATI, 0x4380), board_ahci }, /* ATI SB600 non-raid */ 394 { PCI_VDEVICE(ATI, 0x4380), board_ahci }, /* ATI SB600 non-raid */
@@ -348,6 +416,10 @@ static const struct pci_device_id ahci_pci_tbl[] = {
348 { PCI_VDEVICE(SI, 0x1185), board_ahci }, /* SiS 966 */ 416 { PCI_VDEVICE(SI, 0x1185), board_ahci }, /* SiS 966 */
349 { PCI_VDEVICE(SI, 0x0186), board_ahci }, /* SiS 968 */ 417 { PCI_VDEVICE(SI, 0x0186), board_ahci }, /* SiS 968 */
350 418
419 /* Generic, PCI class code for AHCI */
420 { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
421 0x010601, 0xffffff, board_ahci },
422
351 { } /* terminate list */ 423 { } /* terminate list */
352}; 424};
353 425
@@ -362,6 +434,11 @@ static struct pci_driver ahci_pci_driver = {
362}; 434};
363 435
364 436
437static inline int ahci_nr_ports(u32 cap)
438{
439 return (cap & 0x1f) + 1;
440}
441
365static inline unsigned long ahci_port_base_ul (unsigned long base, unsigned int port) 442static inline unsigned long ahci_port_base_ul (unsigned long base, unsigned int port)
366{ 443{
367 return base + 0x100 + (port * 0x80); 444 return base + 0x100 + (port * 0x80);
@@ -535,9 +612,6 @@ static void ahci_power_down(void __iomem *port_mmio, u32 cap)
535static void ahci_init_port(void __iomem *port_mmio, u32 cap, 612static void ahci_init_port(void __iomem *port_mmio, u32 cap,
536 dma_addr_t cmd_slot_dma, dma_addr_t rx_fis_dma) 613 dma_addr_t cmd_slot_dma, dma_addr_t rx_fis_dma)
537{ 614{
538 /* power up */
539 ahci_power_up(port_mmio, cap);
540
541 /* enable FIS reception */ 615 /* enable FIS reception */
542 ahci_start_fis_rx(port_mmio, cap, cmd_slot_dma, rx_fis_dma); 616 ahci_start_fis_rx(port_mmio, cap, cmd_slot_dma, rx_fis_dma);
543 617
@@ -563,19 +637,17 @@ static int ahci_deinit_port(void __iomem *port_mmio, u32 cap, const char **emsg)
563 return rc; 637 return rc;
564 } 638 }
565 639
566 /* put device into slumber mode */
567 ahci_power_down(port_mmio, cap);
568
569 return 0; 640 return 0;
570} 641}
571 642
572static int ahci_reset_controller(void __iomem *mmio, struct pci_dev *pdev) 643static int ahci_reset_controller(void __iomem *mmio, struct pci_dev *pdev)
573{ 644{
574 u32 cap_save, tmp; 645 u32 cap_save, impl_save, tmp;
575 646
576 cap_save = readl(mmio + HOST_CAP); 647 cap_save = readl(mmio + HOST_CAP);
577 cap_save &= ( (1<<28) | (1<<17) ); 648 cap_save &= ( (1<<28) | (1<<17) );
578 cap_save |= (1 << 27); 649 cap_save |= (1 << 27);
650 impl_save = readl(mmio + HOST_PORTS_IMPL);
579 651
580 /* global controller reset */ 652 /* global controller reset */
581 tmp = readl(mmio + HOST_CTL); 653 tmp = readl(mmio + HOST_CTL);
@@ -596,10 +668,21 @@ static int ahci_reset_controller(void __iomem *mmio, struct pci_dev *pdev)
596 return -EIO; 668 return -EIO;
597 } 669 }
598 670
671 /* turn on AHCI mode */
599 writel(HOST_AHCI_EN, mmio + HOST_CTL); 672 writel(HOST_AHCI_EN, mmio + HOST_CTL);
600 (void) readl(mmio + HOST_CTL); /* flush */ 673 (void) readl(mmio + HOST_CTL); /* flush */
674
675 /* These write-once registers are normally cleared on reset.
676 * Restore BIOS values... which we HOPE were present before
677 * reset.
678 */
679 if (!impl_save) {
680 impl_save = (1 << ahci_nr_ports(cap_save)) - 1;
681 dev_printk(KERN_WARNING, &pdev->dev,
682 "PORTS_IMPL is zero, forcing 0x%x\n", impl_save);
683 }
601 writel(cap_save, mmio + HOST_CAP); 684 writel(cap_save, mmio + HOST_CAP);
602 writel(0xf, mmio + HOST_PORTS_IMPL); 685 writel(impl_save, mmio + HOST_PORTS_IMPL);
603 (void) readl(mmio + HOST_PORTS_IMPL); /* flush */ 686 (void) readl(mmio + HOST_PORTS_IMPL); /* flush */
604 687
605 if (pdev->vendor == PCI_VENDOR_ID_INTEL) { 688 if (pdev->vendor == PCI_VENDOR_ID_INTEL) {
@@ -615,7 +698,8 @@ static int ahci_reset_controller(void __iomem *mmio, struct pci_dev *pdev)
615} 698}
616 699
617static void ahci_init_controller(void __iomem *mmio, struct pci_dev *pdev, 700static void ahci_init_controller(void __iomem *mmio, struct pci_dev *pdev,
618 int n_ports, u32 cap) 701 int n_ports, unsigned int port_flags,
702 struct ahci_host_priv *hpriv)
619{ 703{
620 int i, rc; 704 int i, rc;
621 u32 tmp; 705 u32 tmp;
@@ -624,13 +708,12 @@ static void ahci_init_controller(void __iomem *mmio, struct pci_dev *pdev,
624 void __iomem *port_mmio = ahci_port_base(mmio, i); 708 void __iomem *port_mmio = ahci_port_base(mmio, i);
625 const char *emsg = NULL; 709 const char *emsg = NULL;
626 710
627#if 0 /* BIOSen initialize this incorrectly */ 711 if ((port_flags & AHCI_FLAG_HONOR_PI) &&
628 if (!(hpriv->port_map & (1 << i))) 712 !(hpriv->port_map & (1 << i)))
629 continue; 713 continue;
630#endif
631 714
632 /* make sure port is not active */ 715 /* make sure port is not active */
633 rc = ahci_deinit_port(port_mmio, cap, &emsg); 716 rc = ahci_deinit_port(port_mmio, hpriv->cap, &emsg);
634 if (rc) 717 if (rc)
635 dev_printk(KERN_WARNING, &pdev->dev, 718 dev_printk(KERN_WARNING, &pdev->dev,
636 "%s (%d)\n", emsg, rc); 719 "%s (%d)\n", emsg, rc);
@@ -705,17 +788,6 @@ static int ahci_clo(struct ata_port *ap)
705 return 0; 788 return 0;
706} 789}
707 790
708static int ahci_prereset(struct ata_port *ap)
709{
710 if ((ap->flags & AHCI_FLAG_RESET_NEEDS_CLO) &&
711 (ata_busy_wait(ap, ATA_BUSY, 1000) & ATA_BUSY)) {
712 /* ATA_BUSY hasn't cleared, so send a CLO */
713 ahci_clo(ap);
714 }
715
716 return ata_std_prereset(ap);
717}
718
719static int ahci_softreset(struct ata_port *ap, unsigned int *class) 791static int ahci_softreset(struct ata_port *ap, unsigned int *class)
720{ 792{
721 struct ahci_port_priv *pp = ap->private_data; 793 struct ahci_port_priv *pp = ap->private_data;
@@ -853,6 +925,31 @@ static int ahci_hardreset(struct ata_port *ap, unsigned int *class)
853 return rc; 925 return rc;
854} 926}
855 927
928static int ahci_vt8251_hardreset(struct ata_port *ap, unsigned int *class)
929{
930 void __iomem *mmio = ap->host->mmio_base;
931 void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
932 int rc;
933
934 DPRINTK("ENTER\n");
935
936 ahci_stop_engine(port_mmio);
937
938 rc = sata_port_hardreset(ap, sata_ehc_deb_timing(&ap->eh_context));
939
940 /* vt8251 needs SError cleared for the port to operate */
941 ahci_scr_write(ap, SCR_ERROR, ahci_scr_read(ap, SCR_ERROR));
942
943 ahci_start_engine(port_mmio);
944
945 DPRINTK("EXIT, rc=%d, class=%u\n", rc, *class);
946
947 /* vt8251 doesn't clear BSY on signature FIS reception,
948 * request follow-up softreset.
949 */
950 return rc ?: -EAGAIN;
951}
952
856static void ahci_postreset(struct ata_port *ap, unsigned int *class) 953static void ahci_postreset(struct ata_port *ap, unsigned int *class)
857{ 954{
858 void __iomem *port_mmio = (void __iomem *) ap->ioaddr.cmd_addr; 955 void __iomem *port_mmio = (void __iomem *) ap->ioaddr.cmd_addr;
@@ -969,6 +1066,10 @@ static void ahci_error_intr(struct ata_port *ap, u32 irq_stat)
969 /* analyze @irq_stat */ 1066 /* analyze @irq_stat */
970 ata_ehi_push_desc(ehi, "irq_stat 0x%08x", irq_stat); 1067 ata_ehi_push_desc(ehi, "irq_stat 0x%08x", irq_stat);
971 1068
1069 /* some controllers set IRQ_IF_ERR on device errors, ignore it */
1070 if (ap->flags & AHCI_FLAG_IGN_IRQ_IF_ERR)
1071 irq_stat &= ~PORT_IRQ_IF_ERR;
1072
972 if (irq_stat & PORT_IRQ_TF_ERR) 1073 if (irq_stat & PORT_IRQ_TF_ERR)
973 err_mask |= AC_ERR_DEV; 1074 err_mask |= AC_ERR_DEV;
974 1075
@@ -1168,7 +1269,23 @@ static void ahci_error_handler(struct ata_port *ap)
1168 } 1269 }
1169 1270
1170 /* perform recovery */ 1271 /* perform recovery */
1171 ata_do_eh(ap, ahci_prereset, ahci_softreset, ahci_hardreset, 1272 ata_do_eh(ap, ata_std_prereset, ahci_softreset, ahci_hardreset,
1273 ahci_postreset);
1274}
1275
1276static void ahci_vt8251_error_handler(struct ata_port *ap)
1277{
1278 void __iomem *mmio = ap->host->mmio_base;
1279 void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
1280
1281 if (!(ap->pflags & ATA_PFLAG_FROZEN)) {
1282 /* restart engine */
1283 ahci_stop_engine(port_mmio);
1284 ahci_start_engine(port_mmio);
1285 }
1286
1287 /* perform recovery */
1288 ata_do_eh(ap, ata_std_prereset, ahci_softreset, ahci_vt8251_hardreset,
1172 ahci_postreset); 1289 ahci_postreset);
1173} 1290}
1174 1291
@@ -1198,7 +1315,9 @@ static int ahci_port_suspend(struct ata_port *ap, pm_message_t mesg)
1198 int rc; 1315 int rc;
1199 1316
1200 rc = ahci_deinit_port(port_mmio, hpriv->cap, &emsg); 1317 rc = ahci_deinit_port(port_mmio, hpriv->cap, &emsg);
1201 if (rc) { 1318 if (rc == 0)
1319 ahci_power_down(port_mmio, hpriv->cap);
1320 else {
1202 ata_port_printk(ap, KERN_ERR, "%s (%d)\n", emsg, rc); 1321 ata_port_printk(ap, KERN_ERR, "%s (%d)\n", emsg, rc);
1203 ahci_init_port(port_mmio, hpriv->cap, 1322 ahci_init_port(port_mmio, hpriv->cap,
1204 pp->cmd_slot_dma, pp->rx_fis_dma); 1323 pp->cmd_slot_dma, pp->rx_fis_dma);
@@ -1214,6 +1333,7 @@ static int ahci_port_resume(struct ata_port *ap)
1214 void __iomem *mmio = ap->host->mmio_base; 1333 void __iomem *mmio = ap->host->mmio_base;
1215 void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no); 1334 void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
1216 1335
1336 ahci_power_up(port_mmio, hpriv->cap);
1217 ahci_init_port(port_mmio, hpriv->cap, pp->cmd_slot_dma, pp->rx_fis_dma); 1337 ahci_init_port(port_mmio, hpriv->cap, pp->cmd_slot_dma, pp->rx_fis_dma);
1218 1338
1219 return 0; 1339 return 0;
@@ -1253,7 +1373,8 @@ static int ahci_pci_device_resume(struct pci_dev *pdev)
1253 if (rc) 1373 if (rc)
1254 return rc; 1374 return rc;
1255 1375
1256 ahci_init_controller(mmio, pdev, host->n_ports, hpriv->cap); 1376 ahci_init_controller(mmio, pdev, host->n_ports,
1377 host->ports[0]->flags, hpriv);
1257 } 1378 }
1258 1379
1259 ata_host_resume(host); 1380 ata_host_resume(host);
@@ -1319,6 +1440,9 @@ static int ahci_port_start(struct ata_port *ap)
1319 1440
1320 ap->private_data = pp; 1441 ap->private_data = pp;
1321 1442
1443 /* power up port */
1444 ahci_power_up(port_mmio, hpriv->cap);
1445
1322 /* initialize port */ 1446 /* initialize port */
1323 ahci_init_port(port_mmio, hpriv->cap, pp->cmd_slot_dma, pp->rx_fis_dma); 1447 ahci_init_port(port_mmio, hpriv->cap, pp->cmd_slot_dma, pp->rx_fis_dma);
1324 1448
@@ -1365,7 +1489,7 @@ static int ahci_host_init(struct ata_probe_ent *probe_ent)
1365 struct ahci_host_priv *hpriv = probe_ent->private_data; 1489 struct ahci_host_priv *hpriv = probe_ent->private_data;
1366 struct pci_dev *pdev = to_pci_dev(probe_ent->dev); 1490 struct pci_dev *pdev = to_pci_dev(probe_ent->dev);
1367 void __iomem *mmio = probe_ent->mmio_base; 1491 void __iomem *mmio = probe_ent->mmio_base;
1368 unsigned int i, using_dac; 1492 unsigned int i, cap_n_ports, using_dac;
1369 int rc; 1493 int rc;
1370 1494
1371 rc = ahci_reset_controller(mmio, pdev); 1495 rc = ahci_reset_controller(mmio, pdev);
@@ -1374,10 +1498,34 @@ static int ahci_host_init(struct ata_probe_ent *probe_ent)
1374 1498
1375 hpriv->cap = readl(mmio + HOST_CAP); 1499 hpriv->cap = readl(mmio + HOST_CAP);
1376 hpriv->port_map = readl(mmio + HOST_PORTS_IMPL); 1500 hpriv->port_map = readl(mmio + HOST_PORTS_IMPL);
1377 probe_ent->n_ports = (hpriv->cap & 0x1f) + 1; 1501 cap_n_ports = ahci_nr_ports(hpriv->cap);
1378 1502
1379 VPRINTK("cap 0x%x port_map 0x%x n_ports %d\n", 1503 VPRINTK("cap 0x%x port_map 0x%x n_ports %d\n",
1380 hpriv->cap, hpriv->port_map, probe_ent->n_ports); 1504 hpriv->cap, hpriv->port_map, cap_n_ports);
1505
1506 if (probe_ent->port_flags & AHCI_FLAG_HONOR_PI) {
1507 unsigned int n_ports = cap_n_ports;
1508 u32 port_map = hpriv->port_map;
1509 int max_port = 0;
1510
1511 for (i = 0; i < AHCI_MAX_PORTS && n_ports; i++) {
1512 if (port_map & (1 << i)) {
1513 n_ports--;
1514 port_map &= ~(1 << i);
1515 max_port = i;
1516 } else
1517 probe_ent->dummy_port_mask |= 1 << i;
1518 }
1519
1520 if (n_ports || port_map)
1521 dev_printk(KERN_WARNING, &pdev->dev,
1522 "nr_ports (%u) and implemented port map "
1523 "(0x%x) don't match\n",
1524 cap_n_ports, hpriv->port_map);
1525
1526 probe_ent->n_ports = max_port + 1;
1527 } else
1528 probe_ent->n_ports = cap_n_ports;
1381 1529
1382 using_dac = hpriv->cap & HOST_CAP_64; 1530 using_dac = hpriv->cap & HOST_CAP_64;
1383 if (using_dac && 1531 if (using_dac &&
@@ -1409,7 +1557,8 @@ static int ahci_host_init(struct ata_probe_ent *probe_ent)
1409 for (i = 0; i < probe_ent->n_ports; i++) 1557 for (i = 0; i < probe_ent->n_ports; i++)
1410 ahci_setup_port(&probe_ent->port[i], (unsigned long) mmio, i); 1558 ahci_setup_port(&probe_ent->port[i], (unsigned long) mmio, i);
1411 1559
1412 ahci_init_controller(mmio, pdev, probe_ent->n_ports, hpriv->cap); 1560 ahci_init_controller(mmio, pdev, probe_ent->n_ports,
1561 probe_ent->port_flags, hpriv);
1413 1562
1414 pci_set_master(pdev); 1563 pci_set_master(pdev);
1415 1564
diff --git a/drivers/ata/ata_generic.c b/drivers/ata/ata_generic.c
index 377425e71391..908751d27e76 100644
--- a/drivers/ata/ata_generic.c
+++ b/drivers/ata/ata_generic.c
@@ -26,7 +26,7 @@
26#include <linux/libata.h> 26#include <linux/libata.h>
27 27
28#define DRV_NAME "ata_generic" 28#define DRV_NAME "ata_generic"
29#define DRV_VERSION "0.2.6" 29#define DRV_VERSION "0.2.10"
30 30
31/* 31/*
32 * A generic parallel ATA driver using libata 32 * A generic parallel ATA driver using libata
@@ -109,14 +109,16 @@ static struct scsi_host_template generic_sht = {
109 .can_queue = ATA_DEF_QUEUE, 109 .can_queue = ATA_DEF_QUEUE,
110 .this_id = ATA_SHT_THIS_ID, 110 .this_id = ATA_SHT_THIS_ID,
111 .sg_tablesize = LIBATA_MAX_PRD, 111 .sg_tablesize = LIBATA_MAX_PRD,
112 .max_sectors = ATA_MAX_SECTORS,
113 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 112 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
114 .emulated = ATA_SHT_EMULATED, 113 .emulated = ATA_SHT_EMULATED,
115 .use_clustering = ATA_SHT_USE_CLUSTERING, 114 .use_clustering = ATA_SHT_USE_CLUSTERING,
116 .proc_name = DRV_NAME, 115 .proc_name = DRV_NAME,
117 .dma_boundary = ATA_DMA_BOUNDARY, 116 .dma_boundary = ATA_DMA_BOUNDARY,
118 .slave_configure = ata_scsi_slave_config, 117 .slave_configure = ata_scsi_slave_config,
118 .slave_destroy = ata_scsi_slave_destroy,
119 .bios_param = ata_std_bios_param, 119 .bios_param = ata_std_bios_param,
120 .resume = ata_scsi_device_resume,
121 .suspend = ata_scsi_device_suspend,
120}; 122};
121 123
122static struct ata_port_operations generic_port_ops = { 124static struct ata_port_operations generic_port_ops = {
@@ -225,12 +227,14 @@ static struct pci_driver ata_generic_pci_driver = {
225 .name = DRV_NAME, 227 .name = DRV_NAME,
226 .id_table = ata_generic, 228 .id_table = ata_generic,
227 .probe = ata_generic_init_one, 229 .probe = ata_generic_init_one,
228 .remove = ata_pci_remove_one 230 .remove = ata_pci_remove_one,
231 .suspend = ata_pci_device_suspend,
232 .resume = ata_pci_device_resume,
229}; 233};
230 234
231static int __init ata_generic_init(void) 235static int __init ata_generic_init(void)
232{ 236{
233 return pci_module_init(&ata_generic_pci_driver); 237 return pci_register_driver(&ata_generic_pci_driver);
234} 238}
235 239
236 240
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index 720174d628fa..c7de0bb1591f 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -40,7 +40,7 @@
40 * Documentation 40 * Documentation
41 * Publically available from Intel web site. Errata documentation 41 * Publically available from Intel web site. Errata documentation
42 * is also publically available. As an aide to anyone hacking on this 42 * is also publically available. As an aide to anyone hacking on this
43 * driver the list of errata that are relevant is below.going back to 43 * driver the list of errata that are relevant is below, going back to
44 * PIIX4. Older device documentation is now a bit tricky to find. 44 * PIIX4. Older device documentation is now a bit tricky to find.
45 * 45 *
46 * The chipsets all follow very much the same design. The orginal Triton 46 * The chipsets all follow very much the same design. The orginal Triton
@@ -93,7 +93,7 @@
93#include <linux/libata.h> 93#include <linux/libata.h>
94 94
95#define DRV_NAME "ata_piix" 95#define DRV_NAME "ata_piix"
96#define DRV_VERSION "2.00ac6" 96#define DRV_VERSION "2.00ac7"
97 97
98enum { 98enum {
99 PIIX_IOCFG = 0x54, /* IDE I/O configuration register */ 99 PIIX_IOCFG = 0x54, /* IDE I/O configuration register */
@@ -101,11 +101,13 @@ enum {
101 ICH5_PCS = 0x92, /* port control and status */ 101 ICH5_PCS = 0x92, /* port control and status */
102 PIIX_SCC = 0x0A, /* sub-class code register */ 102 PIIX_SCC = 0x0A, /* sub-class code register */
103 103
104 PIIX_FLAG_IGNORE_PCS = (1 << 25), /* ignore PCS present bits */
105 PIIX_FLAG_SCR = (1 << 26), /* SCR available */ 104 PIIX_FLAG_SCR = (1 << 26), /* SCR available */
106 PIIX_FLAG_AHCI = (1 << 27), /* AHCI possible */ 105 PIIX_FLAG_AHCI = (1 << 27), /* AHCI possible */
107 PIIX_FLAG_CHECKINTR = (1 << 28), /* make sure PCI INTx enabled */ 106 PIIX_FLAG_CHECKINTR = (1 << 28), /* make sure PCI INTx enabled */
108 107
108 PIIX_PATA_FLAGS = ATA_FLAG_SLAVE_POSS,
109 PIIX_SATA_FLAGS = ATA_FLAG_SATA | PIIX_FLAG_CHECKINTR,
110
109 /* combined mode. if set, PATA is channel 0. 111 /* combined mode. if set, PATA is channel 0.
110 * if clear, PATA is channel 1. 112 * if clear, PATA is channel 1.
111 */ 113 */
@@ -122,11 +124,10 @@ enum {
122 ich_pata_100 = 3, /* ICH up to UDMA 100 */ 124 ich_pata_100 = 3, /* ICH up to UDMA 100 */
123 ich_pata_133 = 4, /* ICH up to UDMA 133 */ 125 ich_pata_133 = 4, /* ICH up to UDMA 133 */
124 ich5_sata = 5, 126 ich5_sata = 5,
125 esb_sata = 6, 127 ich6_sata = 6,
126 ich6_sata = 7, 128 ich6_sata_ahci = 7,
127 ich6_sata_ahci = 8, 129 ich6m_sata_ahci = 8,
128 ich6m_sata_ahci = 9, 130 ich8_sata_ahci = 9,
129 ich8_sata_ahci = 10,
130 131
131 /* constants for mapping table */ 132 /* constants for mapping table */
132 P0 = 0, /* port 0 */ 133 P0 = 0, /* port 0 */
@@ -143,13 +144,11 @@ enum {
143struct piix_map_db { 144struct piix_map_db {
144 const u32 mask; 145 const u32 mask;
145 const u16 port_enable; 146 const u16 port_enable;
146 const int present_shift;
147 const int map[][4]; 147 const int map[][4];
148}; 148};
149 149
150struct piix_host_priv { 150struct piix_host_priv {
151 const int *map; 151 const int *map;
152 const struct piix_map_db *map_db;
153}; 152};
154 153
155static int piix_init_one (struct pci_dev *pdev, 154static int piix_init_one (struct pci_dev *pdev,
@@ -214,9 +213,9 @@ static const struct pci_device_id piix_pci_tbl[] = {
214 /* 82801EB (ICH5) */ 213 /* 82801EB (ICH5) */
215 { 0x8086, 0x24df, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich5_sata }, 214 { 0x8086, 0x24df, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich5_sata },
216 /* 6300ESB (ICH5 variant with broken PCS present bits) */ 215 /* 6300ESB (ICH5 variant with broken PCS present bits) */
217 { 0x8086, 0x25a3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, esb_sata }, 216 { 0x8086, 0x25a3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich5_sata },
218 /* 6300ESB pretending RAID */ 217 /* 6300ESB pretending RAID */
219 { 0x8086, 0x25b0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, esb_sata }, 218 { 0x8086, 0x25b0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich5_sata },
220 /* 82801FB/FW (ICH6/ICH6W) */ 219 /* 82801FB/FW (ICH6/ICH6W) */
221 { 0x8086, 0x2651, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata }, 220 { 0x8086, 0x2651, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata },
222 /* 82801FR/FRW (ICH6R/ICH6RW) */ 221 /* 82801FR/FRW (ICH6R/ICH6RW) */
@@ -367,7 +366,6 @@ static const struct ata_port_operations piix_sata_ops = {
367static const struct piix_map_db ich5_map_db = { 366static const struct piix_map_db ich5_map_db = {
368 .mask = 0x7, 367 .mask = 0x7,
369 .port_enable = 0x3, 368 .port_enable = 0x3,
370 .present_shift = 4,
371 .map = { 369 .map = {
372 /* PM PS SM SS MAP */ 370 /* PM PS SM SS MAP */
373 { P0, NA, P1, NA }, /* 000b */ 371 { P0, NA, P1, NA }, /* 000b */
@@ -384,7 +382,6 @@ static const struct piix_map_db ich5_map_db = {
384static const struct piix_map_db ich6_map_db = { 382static const struct piix_map_db ich6_map_db = {
385 .mask = 0x3, 383 .mask = 0x3,
386 .port_enable = 0xf, 384 .port_enable = 0xf,
387 .present_shift = 4,
388 .map = { 385 .map = {
389 /* PM PS SM SS MAP */ 386 /* PM PS SM SS MAP */
390 { P0, P2, P1, P3 }, /* 00b */ 387 { P0, P2, P1, P3 }, /* 00b */
@@ -397,7 +394,6 @@ static const struct piix_map_db ich6_map_db = {
397static const struct piix_map_db ich6m_map_db = { 394static const struct piix_map_db ich6m_map_db = {
398 .mask = 0x3, 395 .mask = 0x3,
399 .port_enable = 0x5, 396 .port_enable = 0x5,
400 .present_shift = 4,
401 397
402 /* Map 01b isn't specified in the doc but some notebooks use 398 /* Map 01b isn't specified in the doc but some notebooks use
403 * it anyway. MAP 01b have been spotted on both ICH6M and 399 * it anyway. MAP 01b have been spotted on both ICH6M and
@@ -415,7 +411,6 @@ static const struct piix_map_db ich6m_map_db = {
415static const struct piix_map_db ich8_map_db = { 411static const struct piix_map_db ich8_map_db = {
416 .mask = 0x3, 412 .mask = 0x3,
417 .port_enable = 0x3, 413 .port_enable = 0x3,
418 .present_shift = 8,
419 .map = { 414 .map = {
420 /* PM PS SM SS MAP */ 415 /* PM PS SM SS MAP */
421 { P0, P2, P1, P3 }, /* 00b (hardwired when in AHCI) */ 416 { P0, P2, P1, P3 }, /* 00b (hardwired when in AHCI) */
@@ -427,7 +422,6 @@ static const struct piix_map_db ich8_map_db = {
427 422
428static const struct piix_map_db *piix_map_db_table[] = { 423static const struct piix_map_db *piix_map_db_table[] = {
429 [ich5_sata] = &ich5_map_db, 424 [ich5_sata] = &ich5_map_db,
430 [esb_sata] = &ich5_map_db,
431 [ich6_sata] = &ich6_map_db, 425 [ich6_sata] = &ich6_map_db,
432 [ich6_sata_ahci] = &ich6_map_db, 426 [ich6_sata_ahci] = &ich6_map_db,
433 [ich6m_sata_ahci] = &ich6m_map_db, 427 [ich6m_sata_ahci] = &ich6m_map_db,
@@ -438,7 +432,7 @@ static struct ata_port_info piix_port_info[] = {
438 /* piix_pata_33: 0: PIIX3 or 4 at 33MHz */ 432 /* piix_pata_33: 0: PIIX3 or 4 at 33MHz */
439 { 433 {
440 .sht = &piix_sht, 434 .sht = &piix_sht,
441 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 435 .flags = PIIX_PATA_FLAGS,
442 .pio_mask = 0x1f, /* pio0-4 */ 436 .pio_mask = 0x1f, /* pio0-4 */
443 .mwdma_mask = 0x06, /* mwdma1-2 ?? CHECK 0 should be ok but slow */ 437 .mwdma_mask = 0x06, /* mwdma1-2 ?? CHECK 0 should be ok but slow */
444 .udma_mask = ATA_UDMA_MASK_40C, 438 .udma_mask = ATA_UDMA_MASK_40C,
@@ -448,7 +442,7 @@ static struct ata_port_info piix_port_info[] = {
448 /* ich_pata_33: 1 ICH0 - ICH at 33Mhz*/ 442 /* ich_pata_33: 1 ICH0 - ICH at 33Mhz*/
449 { 443 {
450 .sht = &piix_sht, 444 .sht = &piix_sht,
451 .flags = ATA_FLAG_SRST | ATA_FLAG_SLAVE_POSS, 445 .flags = PIIX_PATA_FLAGS,
452 .pio_mask = 0x1f, /* pio 0-4 */ 446 .pio_mask = 0x1f, /* pio 0-4 */
453 .mwdma_mask = 0x06, /* Check: maybe 0x07 */ 447 .mwdma_mask = 0x06, /* Check: maybe 0x07 */
454 .udma_mask = ATA_UDMA2, /* UDMA33 */ 448 .udma_mask = ATA_UDMA2, /* UDMA33 */
@@ -457,7 +451,7 @@ static struct ata_port_info piix_port_info[] = {
457 /* ich_pata_66: 2 ICH controllers up to 66MHz */ 451 /* ich_pata_66: 2 ICH controllers up to 66MHz */
458 { 452 {
459 .sht = &piix_sht, 453 .sht = &piix_sht,
460 .flags = ATA_FLAG_SRST | ATA_FLAG_SLAVE_POSS, 454 .flags = PIIX_PATA_FLAGS,
461 .pio_mask = 0x1f, /* pio 0-4 */ 455 .pio_mask = 0x1f, /* pio 0-4 */
462 .mwdma_mask = 0x06, /* MWDMA0 is broken on chip */ 456 .mwdma_mask = 0x06, /* MWDMA0 is broken on chip */
463 .udma_mask = ATA_UDMA4, 457 .udma_mask = ATA_UDMA4,
@@ -467,7 +461,7 @@ static struct ata_port_info piix_port_info[] = {
467 /* ich_pata_100: 3 */ 461 /* ich_pata_100: 3 */
468 { 462 {
469 .sht = &piix_sht, 463 .sht = &piix_sht,
470 .flags = ATA_FLAG_SRST | ATA_FLAG_SLAVE_POSS | PIIX_FLAG_CHECKINTR, 464 .flags = PIIX_PATA_FLAGS | PIIX_FLAG_CHECKINTR,
471 .pio_mask = 0x1f, /* pio0-4 */ 465 .pio_mask = 0x1f, /* pio0-4 */
472 .mwdma_mask = 0x06, /* mwdma1-2 */ 466 .mwdma_mask = 0x06, /* mwdma1-2 */
473 .udma_mask = ATA_UDMA5, /* udma0-5 */ 467 .udma_mask = ATA_UDMA5, /* udma0-5 */
@@ -477,7 +471,7 @@ static struct ata_port_info piix_port_info[] = {
477 /* ich_pata_133: 4 ICH with full UDMA6 */ 471 /* ich_pata_133: 4 ICH with full UDMA6 */
478 { 472 {
479 .sht = &piix_sht, 473 .sht = &piix_sht,
480 .flags = ATA_FLAG_SRST | ATA_FLAG_SLAVE_POSS | PIIX_FLAG_CHECKINTR, 474 .flags = PIIX_PATA_FLAGS | PIIX_FLAG_CHECKINTR,
481 .pio_mask = 0x1f, /* pio 0-4 */ 475 .pio_mask = 0x1f, /* pio 0-4 */
482 .mwdma_mask = 0x06, /* Check: maybe 0x07 */ 476 .mwdma_mask = 0x06, /* Check: maybe 0x07 */
483 .udma_mask = ATA_UDMA6, /* UDMA133 */ 477 .udma_mask = ATA_UDMA6, /* UDMA133 */
@@ -487,41 +481,27 @@ static struct ata_port_info piix_port_info[] = {
487 /* ich5_sata: 5 */ 481 /* ich5_sata: 5 */
488 { 482 {
489 .sht = &piix_sht, 483 .sht = &piix_sht,
490 .flags = ATA_FLAG_SATA | PIIX_FLAG_CHECKINTR | 484 .flags = PIIX_SATA_FLAGS,
491 PIIX_FLAG_IGNORE_PCS,
492 .pio_mask = 0x1f, /* pio0-4 */
493 .mwdma_mask = 0x07, /* mwdma0-2 */
494 .udma_mask = 0x7f, /* udma0-6 */
495 .port_ops = &piix_sata_ops,
496 },
497
498 /* i6300esb_sata: 6 */
499 {
500 .sht = &piix_sht,
501 .flags = ATA_FLAG_SATA |
502 PIIX_FLAG_CHECKINTR | PIIX_FLAG_IGNORE_PCS,
503 .pio_mask = 0x1f, /* pio0-4 */ 485 .pio_mask = 0x1f, /* pio0-4 */
504 .mwdma_mask = 0x07, /* mwdma0-2 */ 486 .mwdma_mask = 0x07, /* mwdma0-2 */
505 .udma_mask = 0x7f, /* udma0-6 */ 487 .udma_mask = 0x7f, /* udma0-6 */
506 .port_ops = &piix_sata_ops, 488 .port_ops = &piix_sata_ops,
507 }, 489 },
508 490
509 /* ich6_sata: 7 */ 491 /* ich6_sata: 6 */
510 { 492 {
511 .sht = &piix_sht, 493 .sht = &piix_sht,
512 .flags = ATA_FLAG_SATA | 494 .flags = PIIX_SATA_FLAGS | PIIX_FLAG_SCR,
513 PIIX_FLAG_CHECKINTR | PIIX_FLAG_SCR,
514 .pio_mask = 0x1f, /* pio0-4 */ 495 .pio_mask = 0x1f, /* pio0-4 */
515 .mwdma_mask = 0x07, /* mwdma0-2 */ 496 .mwdma_mask = 0x07, /* mwdma0-2 */
516 .udma_mask = 0x7f, /* udma0-6 */ 497 .udma_mask = 0x7f, /* udma0-6 */
517 .port_ops = &piix_sata_ops, 498 .port_ops = &piix_sata_ops,
518 }, 499 },
519 500
520 /* ich6_sata_ahci: 8 */ 501 /* ich6_sata_ahci: 7 */
521 { 502 {
522 .sht = &piix_sht, 503 .sht = &piix_sht,
523 .flags = ATA_FLAG_SATA | 504 .flags = PIIX_SATA_FLAGS | PIIX_FLAG_SCR |
524 PIIX_FLAG_CHECKINTR | PIIX_FLAG_SCR |
525 PIIX_FLAG_AHCI, 505 PIIX_FLAG_AHCI,
526 .pio_mask = 0x1f, /* pio0-4 */ 506 .pio_mask = 0x1f, /* pio0-4 */
527 .mwdma_mask = 0x07, /* mwdma0-2 */ 507 .mwdma_mask = 0x07, /* mwdma0-2 */
@@ -529,11 +509,10 @@ static struct ata_port_info piix_port_info[] = {
529 .port_ops = &piix_sata_ops, 509 .port_ops = &piix_sata_ops,
530 }, 510 },
531 511
532 /* ich6m_sata_ahci: 9 */ 512 /* ich6m_sata_ahci: 8 */
533 { 513 {
534 .sht = &piix_sht, 514 .sht = &piix_sht,
535 .flags = ATA_FLAG_SATA | 515 .flags = PIIX_SATA_FLAGS | PIIX_FLAG_SCR |
536 PIIX_FLAG_CHECKINTR | PIIX_FLAG_SCR |
537 PIIX_FLAG_AHCI, 516 PIIX_FLAG_AHCI,
538 .pio_mask = 0x1f, /* pio0-4 */ 517 .pio_mask = 0x1f, /* pio0-4 */
539 .mwdma_mask = 0x07, /* mwdma0-2 */ 518 .mwdma_mask = 0x07, /* mwdma0-2 */
@@ -541,11 +520,10 @@ static struct ata_port_info piix_port_info[] = {
541 .port_ops = &piix_sata_ops, 520 .port_ops = &piix_sata_ops,
542 }, 521 },
543 522
544 /* ich8_sata_ahci: 10 */ 523 /* ich8_sata_ahci: 9 */
545 { 524 {
546 .sht = &piix_sht, 525 .sht = &piix_sht,
547 .flags = ATA_FLAG_SATA | 526 .flags = PIIX_SATA_FLAGS | PIIX_FLAG_SCR |
548 PIIX_FLAG_CHECKINTR | PIIX_FLAG_SCR |
549 PIIX_FLAG_AHCI, 527 PIIX_FLAG_AHCI,
550 .pio_mask = 0x1f, /* pio0-4 */ 528 .pio_mask = 0x1f, /* pio0-4 */
551 .mwdma_mask = 0x07, /* mwdma0-2 */ 529 .mwdma_mask = 0x07, /* mwdma0-2 */
@@ -566,10 +544,22 @@ MODULE_LICENSE("GPL");
566MODULE_DEVICE_TABLE(pci, piix_pci_tbl); 544MODULE_DEVICE_TABLE(pci, piix_pci_tbl);
567MODULE_VERSION(DRV_VERSION); 545MODULE_VERSION(DRV_VERSION);
568 546
569static int force_pcs = 0; 547struct ich_laptop {
570module_param(force_pcs, int, 0444); 548 u16 device;
571MODULE_PARM_DESC(force_pcs, "force honoring or ignoring PCS to work around " 549 u16 subvendor;
572 "device mis-detection (0=default, 1=ignore PCS, 2=honor PCS)"); 550 u16 subdevice;
551};
552
553/*
554 * List of laptops that use short cables rather than 80 wire
555 */
556
557static const struct ich_laptop ich_laptop[] = {
558 /* devid, subvendor, subdev */
559 { 0x27DF, 0x0005, 0x0280 }, /* ICH7 on Acer 5602WLMi */
560 /* end marker */
561 { 0, }
562};
573 563
574/** 564/**
575 * piix_pata_cbl_detect - Probe host controller cable detect info 565 * piix_pata_cbl_detect - Probe host controller cable detect info
@@ -585,12 +575,24 @@ MODULE_PARM_DESC(force_pcs, "force honoring or ignoring PCS to work around "
585static void ich_pata_cbl_detect(struct ata_port *ap) 575static void ich_pata_cbl_detect(struct ata_port *ap)
586{ 576{
587 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 577 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
578 const struct ich_laptop *lap = &ich_laptop[0];
588 u8 tmp, mask; 579 u8 tmp, mask;
589 580
590 /* no 80c support in host controller? */ 581 /* no 80c support in host controller? */
591 if ((ap->udma_mask & ~ATA_UDMA_MASK_40C) == 0) 582 if ((ap->udma_mask & ~ATA_UDMA_MASK_40C) == 0)
592 goto cbl40; 583 goto cbl40;
593 584
585 /* Check for specials - Acer Aspire 5602WLMi */
586 while (lap->device) {
587 if (lap->device == pdev->device &&
588 lap->subvendor == pdev->subsystem_vendor &&
589 lap->subdevice == pdev->subsystem_device) {
590 ap->cbl = ATA_CBL_PATA40_SHORT;
591 return;
592 }
593 lap++;
594 }
595
594 /* check BIOS cable detect results */ 596 /* check BIOS cable detect results */
595 mask = ap->port_no == 0 ? PIIX_80C_PRI : PIIX_80C_SEC; 597 mask = ap->port_no == 0 ? PIIX_80C_PRI : PIIX_80C_SEC;
596 pci_read_config_byte(pdev, PIIX_IOCFG, &tmp); 598 pci_read_config_byte(pdev, PIIX_IOCFG, &tmp);
@@ -659,84 +661,9 @@ static void ich_pata_error_handler(struct ata_port *ap)
659 ata_std_postreset); 661 ata_std_postreset);
660} 662}
661 663
662/**
663 * piix_sata_present_mask - determine present mask for SATA host controller
664 * @ap: Target port
665 *
666 * Reads SATA PCI device's PCI config register Port Configuration
667 * and Status (PCS) to determine port and device availability.
668 *
669 * LOCKING:
670 * None (inherited from caller).
671 *
672 * RETURNS:
673 * determined present_mask
674 */
675static unsigned int piix_sata_present_mask(struct ata_port *ap)
676{
677 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
678 struct piix_host_priv *hpriv = ap->host->private_data;
679 const unsigned int *map = hpriv->map;
680 int base = 2 * ap->port_no;
681 unsigned int present_mask = 0;
682 int port, i;
683 u16 pcs;
684
685 pci_read_config_word(pdev, ICH5_PCS, &pcs);
686 DPRINTK("ata%u: ENTER, pcs=0x%x base=%d\n", ap->id, pcs, base);
687
688 for (i = 0; i < 2; i++) {
689 port = map[base + i];
690 if (port < 0)
691 continue;
692 if ((ap->flags & PIIX_FLAG_IGNORE_PCS) ||
693 (pcs & 1 << (hpriv->map_db->present_shift + port)))
694 present_mask |= 1 << i;
695 }
696
697 DPRINTK("ata%u: LEAVE, pcs=0x%x present_mask=0x%x\n",
698 ap->id, pcs, present_mask);
699
700 return present_mask;
701}
702
703/**
704 * piix_sata_softreset - reset SATA host port via ATA SRST
705 * @ap: port to reset
706 * @classes: resulting classes of attached devices
707 *
708 * Reset SATA host port via ATA SRST. On controllers with
709 * reliable PCS present bits, the bits are used to determine
710 * device presence.
711 *
712 * LOCKING:
713 * Kernel thread context (may sleep)
714 *
715 * RETURNS:
716 * 0 on success, -errno otherwise.
717 */
718static int piix_sata_softreset(struct ata_port *ap, unsigned int *classes)
719{
720 unsigned int present_mask;
721 int i, rc;
722
723 present_mask = piix_sata_present_mask(ap);
724
725 rc = ata_std_softreset(ap, classes);
726 if (rc)
727 return rc;
728
729 for (i = 0; i < ATA_MAX_DEVICES; i++) {
730 if (!(present_mask & (1 << i)))
731 classes[i] = ATA_DEV_NONE;
732 }
733
734 return 0;
735}
736
737static void piix_sata_error_handler(struct ata_port *ap) 664static void piix_sata_error_handler(struct ata_port *ap)
738{ 665{
739 ata_bmdma_drive_eh(ap, ata_std_prereset, piix_sata_softreset, NULL, 666 ata_bmdma_drive_eh(ap, ata_std_prereset, ata_std_softreset, NULL,
740 ata_std_postreset); 667 ata_std_postreset);
741} 668}
742 669
@@ -1051,18 +978,6 @@ static void __devinit piix_init_pcs(struct pci_dev *pdev,
1051 pci_write_config_word(pdev, ICH5_PCS, new_pcs); 978 pci_write_config_word(pdev, ICH5_PCS, new_pcs);
1052 msleep(150); 979 msleep(150);
1053 } 980 }
1054
1055 if (force_pcs == 1) {
1056 dev_printk(KERN_INFO, &pdev->dev,
1057 "force ignoring PCS (0x%x)\n", new_pcs);
1058 pinfo[0].flags |= PIIX_FLAG_IGNORE_PCS;
1059 pinfo[1].flags |= PIIX_FLAG_IGNORE_PCS;
1060 } else if (force_pcs == 2) {
1061 dev_printk(KERN_INFO, &pdev->dev,
1062 "force honoring PCS (0x%x)\n", new_pcs);
1063 pinfo[0].flags &= ~PIIX_FLAG_IGNORE_PCS;
1064 pinfo[1].flags &= ~PIIX_FLAG_IGNORE_PCS;
1065 }
1066} 981}
1067 982
1068static void __devinit piix_init_sata_map(struct pci_dev *pdev, 983static void __devinit piix_init_sata_map(struct pci_dev *pdev,
@@ -1112,7 +1027,6 @@ static void __devinit piix_init_sata_map(struct pci_dev *pdev,
1112 "invalid MAP value %u\n", map_value); 1027 "invalid MAP value %u\n", map_value);
1113 1028
1114 hpriv->map = map; 1029 hpriv->map = map;
1115 hpriv->map_db = map_db;
1116} 1030}
1117 1031
1118/** 1032/**
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index a8fd0c3e59b3..011c0a8a2dcc 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -199,7 +199,8 @@ static const u8 ata_rw_cmds[] = {
199 199
200/** 200/**
201 * ata_rwcmd_protocol - set taskfile r/w commands and protocol 201 * ata_rwcmd_protocol - set taskfile r/w commands and protocol
202 * @qc: command to examine and configure 202 * @tf: command to examine and configure
203 * @dev: device tf belongs to
203 * 204 *
204 * Examine the device configuration and tf->flags to calculate 205 * Examine the device configuration and tf->flags to calculate
205 * the proper read/write commands and protocol to use. 206 * the proper read/write commands and protocol to use.
@@ -207,10 +208,8 @@ static const u8 ata_rw_cmds[] = {
207 * LOCKING: 208 * LOCKING:
208 * caller. 209 * caller.
209 */ 210 */
210int ata_rwcmd_protocol(struct ata_queued_cmd *qc) 211static int ata_rwcmd_protocol(struct ata_taskfile *tf, struct ata_device *dev)
211{ 212{
212 struct ata_taskfile *tf = &qc->tf;
213 struct ata_device *dev = qc->dev;
214 u8 cmd; 213 u8 cmd;
215 214
216 int index, fua, lba48, write; 215 int index, fua, lba48, write;
@@ -222,7 +221,7 @@ int ata_rwcmd_protocol(struct ata_queued_cmd *qc)
222 if (dev->flags & ATA_DFLAG_PIO) { 221 if (dev->flags & ATA_DFLAG_PIO) {
223 tf->protocol = ATA_PROT_PIO; 222 tf->protocol = ATA_PROT_PIO;
224 index = dev->multi_count ? 0 : 8; 223 index = dev->multi_count ? 0 : 8;
225 } else if (lba48 && (qc->ap->flags & ATA_FLAG_PIO_LBA48)) { 224 } else if (lba48 && (dev->ap->flags & ATA_FLAG_PIO_LBA48)) {
226 /* Unable to use DMA due to host limitation */ 225 /* Unable to use DMA due to host limitation */
227 tf->protocol = ATA_PROT_PIO; 226 tf->protocol = ATA_PROT_PIO;
228 index = dev->multi_count ? 0 : 8; 227 index = dev->multi_count ? 0 : 8;
@@ -240,6 +239,174 @@ int ata_rwcmd_protocol(struct ata_queued_cmd *qc)
240} 239}
241 240
242/** 241/**
242 * ata_tf_read_block - Read block address from ATA taskfile
243 * @tf: ATA taskfile of interest
244 * @dev: ATA device @tf belongs to
245 *
246 * LOCKING:
247 * None.
248 *
249 * Read block address from @tf. This function can handle all
250 * three address formats - LBA, LBA48 and CHS. tf->protocol and
251 * flags select the address format to use.
252 *
253 * RETURNS:
254 * Block address read from @tf.
255 */
256u64 ata_tf_read_block(struct ata_taskfile *tf, struct ata_device *dev)
257{
258 u64 block = 0;
259
260 if (tf->flags & ATA_TFLAG_LBA) {
261 if (tf->flags & ATA_TFLAG_LBA48) {
262 block |= (u64)tf->hob_lbah << 40;
263 block |= (u64)tf->hob_lbam << 32;
264 block |= tf->hob_lbal << 24;
265 } else
266 block |= (tf->device & 0xf) << 24;
267
268 block |= tf->lbah << 16;
269 block |= tf->lbam << 8;
270 block |= tf->lbal;
271 } else {
272 u32 cyl, head, sect;
273
274 cyl = tf->lbam | (tf->lbah << 8);
275 head = tf->device & 0xf;
276 sect = tf->lbal;
277
278 block = (cyl * dev->heads + head) * dev->sectors + sect;
279 }
280
281 return block;
282}
283
284/**
285 * ata_build_rw_tf - Build ATA taskfile for given read/write request
286 * @tf: Target ATA taskfile
287 * @dev: ATA device @tf belongs to
288 * @block: Block address
289 * @n_block: Number of blocks
290 * @tf_flags: RW/FUA etc...
291 * @tag: tag
292 *
293 * LOCKING:
294 * None.
295 *
296 * Build ATA taskfile @tf for read/write request described by
297 * @block, @n_block, @tf_flags and @tag on @dev.
298 *
299 * RETURNS:
300 *
301 * 0 on success, -ERANGE if the request is too large for @dev,
302 * -EINVAL if the request is invalid.
303 */
304int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev,
305 u64 block, u32 n_block, unsigned int tf_flags,
306 unsigned int tag)
307{
308 tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
309 tf->flags |= tf_flags;
310
311 if ((dev->flags & (ATA_DFLAG_PIO | ATA_DFLAG_NCQ_OFF |
312 ATA_DFLAG_NCQ)) == ATA_DFLAG_NCQ &&
313 likely(tag != ATA_TAG_INTERNAL)) {
314 /* yay, NCQ */
315 if (!lba_48_ok(block, n_block))
316 return -ERANGE;
317
318 tf->protocol = ATA_PROT_NCQ;
319 tf->flags |= ATA_TFLAG_LBA | ATA_TFLAG_LBA48;
320
321 if (tf->flags & ATA_TFLAG_WRITE)
322 tf->command = ATA_CMD_FPDMA_WRITE;
323 else
324 tf->command = ATA_CMD_FPDMA_READ;
325
326 tf->nsect = tag << 3;
327 tf->hob_feature = (n_block >> 8) & 0xff;
328 tf->feature = n_block & 0xff;
329
330 tf->hob_lbah = (block >> 40) & 0xff;
331 tf->hob_lbam = (block >> 32) & 0xff;
332 tf->hob_lbal = (block >> 24) & 0xff;
333 tf->lbah = (block >> 16) & 0xff;
334 tf->lbam = (block >> 8) & 0xff;
335 tf->lbal = block & 0xff;
336
337 tf->device = 1 << 6;
338 if (tf->flags & ATA_TFLAG_FUA)
339 tf->device |= 1 << 7;
340 } else if (dev->flags & ATA_DFLAG_LBA) {
341 tf->flags |= ATA_TFLAG_LBA;
342
343 if (lba_28_ok(block, n_block)) {
344 /* use LBA28 */
345 tf->device |= (block >> 24) & 0xf;
346 } else if (lba_48_ok(block, n_block)) {
347 if (!(dev->flags & ATA_DFLAG_LBA48))
348 return -ERANGE;
349
350 /* use LBA48 */
351 tf->flags |= ATA_TFLAG_LBA48;
352
353 tf->hob_nsect = (n_block >> 8) & 0xff;
354
355 tf->hob_lbah = (block >> 40) & 0xff;
356 tf->hob_lbam = (block >> 32) & 0xff;
357 tf->hob_lbal = (block >> 24) & 0xff;
358 } else
359 /* request too large even for LBA48 */
360 return -ERANGE;
361
362 if (unlikely(ata_rwcmd_protocol(tf, dev) < 0))
363 return -EINVAL;
364
365 tf->nsect = n_block & 0xff;
366
367 tf->lbah = (block >> 16) & 0xff;
368 tf->lbam = (block >> 8) & 0xff;
369 tf->lbal = block & 0xff;
370
371 tf->device |= ATA_LBA;
372 } else {
373 /* CHS */
374 u32 sect, head, cyl, track;
375
376 /* The request -may- be too large for CHS addressing. */
377 if (!lba_28_ok(block, n_block))
378 return -ERANGE;
379
380 if (unlikely(ata_rwcmd_protocol(tf, dev) < 0))
381 return -EINVAL;
382
383 /* Convert LBA to CHS */
384 track = (u32)block / dev->sectors;
385 cyl = track / dev->heads;
386 head = track % dev->heads;
387 sect = (u32)block % dev->sectors + 1;
388
389 DPRINTK("block %u track %u cyl %u head %u sect %u\n",
390 (u32)block, track, cyl, head, sect);
391
392 /* Check whether the converted CHS can fit.
393 Cylinder: 0-65535
394 Head: 0-15
395 Sector: 1-255*/
396 if ((cyl >> 16) || (head >> 4) || (sect >> 8) || (!sect))
397 return -ERANGE;
398
399 tf->nsect = n_block & 0xff; /* Sector count 0 means 256 sectors */
400 tf->lbal = sect;
401 tf->lbam = cyl;
402 tf->lbah = cyl >> 8;
403 tf->device |= head;
404 }
405
406 return 0;
407}
408
409/**
243 * ata_pack_xfermask - Pack pio, mwdma and udma masks into xfer_mask 410 * ata_pack_xfermask - Pack pio, mwdma and udma masks into xfer_mask
244 * @pio_mask: pio_mask 411 * @pio_mask: pio_mask
245 * @mwdma_mask: mwdma_mask 412 * @mwdma_mask: mwdma_mask
@@ -914,7 +1081,7 @@ static unsigned int ata_id_xfermask(const u16 *id)
914 * ata_port_queue_task - Queue port_task 1081 * ata_port_queue_task - Queue port_task
915 * @ap: The ata_port to queue port_task for 1082 * @ap: The ata_port to queue port_task for
916 * @fn: workqueue function to be scheduled 1083 * @fn: workqueue function to be scheduled
917 * @data: data value to pass to workqueue function 1084 * @data: data for @fn to use
918 * @delay: delay time for workqueue function 1085 * @delay: delay time for workqueue function
919 * 1086 *
920 * Schedule @fn(@data) for execution after @delay jiffies using 1087 * Schedule @fn(@data) for execution after @delay jiffies using
@@ -929,7 +1096,7 @@ static unsigned int ata_id_xfermask(const u16 *id)
929 * LOCKING: 1096 * LOCKING:
930 * Inherited from caller. 1097 * Inherited from caller.
931 */ 1098 */
932void ata_port_queue_task(struct ata_port *ap, void (*fn)(void *), void *data, 1099void ata_port_queue_task(struct ata_port *ap, work_func_t fn, void *data,
933 unsigned long delay) 1100 unsigned long delay)
934{ 1101{
935 int rc; 1102 int rc;
@@ -937,12 +1104,10 @@ void ata_port_queue_task(struct ata_port *ap, void (*fn)(void *), void *data,
937 if (ap->pflags & ATA_PFLAG_FLUSH_PORT_TASK) 1104 if (ap->pflags & ATA_PFLAG_FLUSH_PORT_TASK)
938 return; 1105 return;
939 1106
940 PREPARE_WORK(&ap->port_task, fn, data); 1107 PREPARE_DELAYED_WORK(&ap->port_task, fn);
1108 ap->port_task_data = data;
941 1109
942 if (!delay) 1110 rc = queue_delayed_work(ata_wq, &ap->port_task, delay);
943 rc = queue_work(ata_wq, &ap->port_task);
944 else
945 rc = queue_delayed_work(ata_wq, &ap->port_task, delay);
946 1111
947 /* rc == 0 means that another user is using port task */ 1112 /* rc == 0 means that another user is using port task */
948 WARN_ON(rc == 0); 1113 WARN_ON(rc == 0);
@@ -999,13 +1164,13 @@ void ata_qc_complete_internal(struct ata_queued_cmd *qc)
999} 1164}
1000 1165
1001/** 1166/**
1002 * ata_exec_internal - execute libata internal command 1167 * ata_exec_internal_sg - execute libata internal command
1003 * @dev: Device to which the command is sent 1168 * @dev: Device to which the command is sent
1004 * @tf: Taskfile registers for the command and the result 1169 * @tf: Taskfile registers for the command and the result
1005 * @cdb: CDB for packet command 1170 * @cdb: CDB for packet command
1006 * @dma_dir: Data tranfer direction of the command 1171 * @dma_dir: Data tranfer direction of the command
1007 * @buf: Data buffer of the command 1172 * @sg: sg list for the data buffer of the command
1008 * @buflen: Length of data buffer 1173 * @n_elem: Number of sg entries
1009 * 1174 *
1010 * Executes libata internal command with timeout. @tf contains 1175 * Executes libata internal command with timeout. @tf contains
1011 * command on entry and result on return. Timeout and error 1176 * command on entry and result on return. Timeout and error
@@ -1019,9 +1184,10 @@ void ata_qc_complete_internal(struct ata_queued_cmd *qc)
1019 * RETURNS: 1184 * RETURNS:
1020 * Zero on success, AC_ERR_* mask on failure 1185 * Zero on success, AC_ERR_* mask on failure
1021 */ 1186 */
1022unsigned ata_exec_internal(struct ata_device *dev, 1187unsigned ata_exec_internal_sg(struct ata_device *dev,
1023 struct ata_taskfile *tf, const u8 *cdb, 1188 struct ata_taskfile *tf, const u8 *cdb,
1024 int dma_dir, void *buf, unsigned int buflen) 1189 int dma_dir, struct scatterlist *sg,
1190 unsigned int n_elem)
1025{ 1191{
1026 struct ata_port *ap = dev->ap; 1192 struct ata_port *ap = dev->ap;
1027 u8 command = tf->command; 1193 u8 command = tf->command;
@@ -1077,7 +1243,12 @@ unsigned ata_exec_internal(struct ata_device *dev,
1077 qc->flags |= ATA_QCFLAG_RESULT_TF; 1243 qc->flags |= ATA_QCFLAG_RESULT_TF;
1078 qc->dma_dir = dma_dir; 1244 qc->dma_dir = dma_dir;
1079 if (dma_dir != DMA_NONE) { 1245 if (dma_dir != DMA_NONE) {
1080 ata_sg_init_one(qc, buf, buflen); 1246 unsigned int i, buflen = 0;
1247
1248 for (i = 0; i < n_elem; i++)
1249 buflen += sg[i].length;
1250
1251 ata_sg_init(qc, sg, n_elem);
1081 qc->nsect = buflen / ATA_SECT_SIZE; 1252 qc->nsect = buflen / ATA_SECT_SIZE;
1082 } 1253 }
1083 1254
@@ -1161,6 +1332,35 @@ unsigned ata_exec_internal(struct ata_device *dev,
1161} 1332}
1162 1333
1163/** 1334/**
1335 * ata_exec_internal_sg - execute libata internal command
1336 * @dev: Device to which the command is sent
1337 * @tf: Taskfile registers for the command and the result
1338 * @cdb: CDB for packet command
1339 * @dma_dir: Data tranfer direction of the command
1340 * @buf: Data buffer of the command
1341 * @buflen: Length of data buffer
1342 *
1343 * Wrapper around ata_exec_internal_sg() which takes simple
1344 * buffer instead of sg list.
1345 *
1346 * LOCKING:
1347 * None. Should be called with kernel context, might sleep.
1348 *
1349 * RETURNS:
1350 * Zero on success, AC_ERR_* mask on failure
1351 */
1352unsigned ata_exec_internal(struct ata_device *dev,
1353 struct ata_taskfile *tf, const u8 *cdb,
1354 int dma_dir, void *buf, unsigned int buflen)
1355{
1356 struct scatterlist sg;
1357
1358 sg_init_one(&sg, buf, buflen);
1359
1360 return ata_exec_internal_sg(dev, tf, cdb, dma_dir, &sg, 1);
1361}
1362
1363/**
1164 * ata_do_simple_cmd - execute simple internal command 1364 * ata_do_simple_cmd - execute simple internal command
1165 * @dev: Device to which the command is sent 1365 * @dev: Device to which the command is sent
1166 * @cmd: Opcode to execute 1366 * @cmd: Opcode to execute
@@ -1224,7 +1424,7 @@ unsigned int ata_pio_need_iordy(const struct ata_device *adev)
1224 * ata_dev_read_id - Read ID data from the specified device 1424 * ata_dev_read_id - Read ID data from the specified device
1225 * @dev: target device 1425 * @dev: target device
1226 * @p_class: pointer to class of the target device (may be changed) 1426 * @p_class: pointer to class of the target device (may be changed)
1227 * @post_reset: is this read ID post-reset? 1427 * @flags: ATA_READID_* flags
1228 * @id: buffer to read IDENTIFY data into 1428 * @id: buffer to read IDENTIFY data into
1229 * 1429 *
1230 * Read ID data from the specified device. ATA_CMD_ID_ATA is 1430 * Read ID data from the specified device. ATA_CMD_ID_ATA is
@@ -1239,7 +1439,7 @@ unsigned int ata_pio_need_iordy(const struct ata_device *adev)
1239 * 0 on success, -errno otherwise. 1439 * 0 on success, -errno otherwise.
1240 */ 1440 */
1241int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, 1441int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
1242 int post_reset, u16 *id) 1442 unsigned int flags, u16 *id)
1243{ 1443{
1244 struct ata_port *ap = dev->ap; 1444 struct ata_port *ap = dev->ap;
1245 unsigned int class = *p_class; 1445 unsigned int class = *p_class;
@@ -1271,10 +1471,17 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
1271 } 1471 }
1272 1472
1273 tf.protocol = ATA_PROT_PIO; 1473 tf.protocol = ATA_PROT_PIO;
1474 tf.flags |= ATA_TFLAG_POLLING; /* for polling presence detection */
1274 1475
1275 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_FROM_DEVICE, 1476 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_FROM_DEVICE,
1276 id, sizeof(id[0]) * ATA_ID_WORDS); 1477 id, sizeof(id[0]) * ATA_ID_WORDS);
1277 if (err_mask) { 1478 if (err_mask) {
1479 if (err_mask & AC_ERR_NODEV_HINT) {
1480 DPRINTK("ata%u.%d: NODEV after polling detection\n",
1481 ap->id, dev->devno);
1482 return -ENOENT;
1483 }
1484
1278 rc = -EIO; 1485 rc = -EIO;
1279 reason = "I/O error"; 1486 reason = "I/O error";
1280 goto err_out; 1487 goto err_out;
@@ -1294,7 +1501,7 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
1294 goto err_out; 1501 goto err_out;
1295 } 1502 }
1296 1503
1297 if (post_reset && class == ATA_DEV_ATA) { 1504 if ((flags & ATA_READID_POSTRESET) && class == ATA_DEV_ATA) {
1298 /* 1505 /*
1299 * The exact sequence expected by certain pre-ATA4 drives is: 1506 * The exact sequence expected by certain pre-ATA4 drives is:
1300 * SRST RESET 1507 * SRST RESET
@@ -1314,7 +1521,7 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
1314 /* current CHS translation info (id[53-58]) might be 1521 /* current CHS translation info (id[53-58]) might be
1315 * changed. reread the identify device info. 1522 * changed. reread the identify device info.
1316 */ 1523 */
1317 post_reset = 0; 1524 flags &= ~ATA_READID_POSTRESET;
1318 goto retry; 1525 goto retry;
1319 } 1526 }
1320 } 1527 }
@@ -1345,7 +1552,10 @@ static void ata_dev_config_ncq(struct ata_device *dev,
1345 desc[0] = '\0'; 1552 desc[0] = '\0';
1346 return; 1553 return;
1347 } 1554 }
1348 1555 if (ata_device_blacklisted(dev) & ATA_HORKAGE_NONCQ) {
1556 snprintf(desc, desc_sz, "NCQ (not used)");
1557 return;
1558 }
1349 if (ap->flags & ATA_FLAG_NCQ) { 1559 if (ap->flags & ATA_FLAG_NCQ) {
1350 hdepth = min(ap->scsi_host->can_queue, ATA_MAX_QUEUE - 1); 1560 hdepth = min(ap->scsi_host->can_queue, ATA_MAX_QUEUE - 1);
1351 dev->flags |= ATA_DFLAG_NCQ; 1561 dev->flags |= ATA_DFLAG_NCQ;
@@ -1374,7 +1584,6 @@ static void ata_set_port_max_cmd_len(struct ata_port *ap)
1374/** 1584/**
1375 * ata_dev_configure - Configure the specified ATA/ATAPI device 1585 * ata_dev_configure - Configure the specified ATA/ATAPI device
1376 * @dev: Target device to configure 1586 * @dev: Target device to configure
1377 * @print_info: Enable device info printout
1378 * 1587 *
1379 * Configure @dev according to @dev->id. Generic and low-level 1588 * Configure @dev according to @dev->id. Generic and low-level
1380 * driver specific fixups are also applied. 1589 * driver specific fixups are also applied.
@@ -1385,9 +1594,10 @@ static void ata_set_port_max_cmd_len(struct ata_port *ap)
1385 * RETURNS: 1594 * RETURNS:
1386 * 0 on success, -errno otherwise 1595 * 0 on success, -errno otherwise
1387 */ 1596 */
1388int ata_dev_configure(struct ata_device *dev, int print_info) 1597int ata_dev_configure(struct ata_device *dev)
1389{ 1598{
1390 struct ata_port *ap = dev->ap; 1599 struct ata_port *ap = dev->ap;
1600 int print_info = ap->eh_context.i.flags & ATA_EHI_PRINTINFO;
1391 const u16 *id = dev->id; 1601 const u16 *id = dev->id;
1392 unsigned int xfer_mask; 1602 unsigned int xfer_mask;
1393 char revbuf[7]; /* XYZ-99\0 */ 1603 char revbuf[7]; /* XYZ-99\0 */
@@ -1454,6 +1664,10 @@ int ata_dev_configure(struct ata_device *dev, int print_info)
1454 if (ata_id_has_lba48(id)) { 1664 if (ata_id_has_lba48(id)) {
1455 dev->flags |= ATA_DFLAG_LBA48; 1665 dev->flags |= ATA_DFLAG_LBA48;
1456 lba_desc = "LBA48"; 1666 lba_desc = "LBA48";
1667
1668 if (dev->n_sectors >= (1UL << 28) &&
1669 ata_id_has_flush_ext(id))
1670 dev->flags |= ATA_DFLAG_FLUSH_EXT;
1457 } 1671 }
1458 1672
1459 /* config NCQ */ 1673 /* config NCQ */
@@ -1530,6 +1744,11 @@ int ata_dev_configure(struct ata_device *dev, int print_info)
1530 cdb_intr_string); 1744 cdb_intr_string);
1531 } 1745 }
1532 1746
1747 /* determine max_sectors */
1748 dev->max_sectors = ATA_MAX_SECTORS;
1749 if (dev->flags & ATA_DFLAG_LBA48)
1750 dev->max_sectors = ATA_MAX_SECTORS_LBA48;
1751
1533 if (dev->horkage & ATA_HORKAGE_DIAGNOSTIC) { 1752 if (dev->horkage & ATA_HORKAGE_DIAGNOSTIC) {
1534 /* Let the user know. We don't want to disallow opens for 1753 /* Let the user know. We don't want to disallow opens for
1535 rescue purposes, or in case the vendor is just a blithering 1754 rescue purposes, or in case the vendor is just a blithering
@@ -1631,11 +1850,14 @@ int ata_bus_probe(struct ata_port *ap)
1631 if (!ata_dev_enabled(dev)) 1850 if (!ata_dev_enabled(dev))
1632 continue; 1851 continue;
1633 1852
1634 rc = ata_dev_read_id(dev, &dev->class, 1, dev->id); 1853 rc = ata_dev_read_id(dev, &dev->class, ATA_READID_POSTRESET,
1854 dev->id);
1635 if (rc) 1855 if (rc)
1636 goto fail; 1856 goto fail;
1637 1857
1638 rc = ata_dev_configure(dev, 1); 1858 ap->eh_context.i.flags |= ATA_EHI_PRINTINFO;
1859 rc = ata_dev_configure(dev);
1860 ap->eh_context.i.flags &= ~ATA_EHI_PRINTINFO;
1639 if (rc) 1861 if (rc)
1640 goto fail; 1862 goto fail;
1641 } 1863 }
@@ -2081,7 +2303,7 @@ int ata_timing_compute(struct ata_device *adev, unsigned short speed,
2081 * DMA cycle timing is slower/equal than the fastest PIO timing. 2303 * DMA cycle timing is slower/equal than the fastest PIO timing.
2082 */ 2304 */
2083 2305
2084 if (speed > XFER_PIO_4) { 2306 if (speed > XFER_PIO_6) {
2085 ata_timing_compute(adev, adev->pio_mode, &p, T, UT); 2307 ata_timing_compute(adev, adev->pio_mode, &p, T, UT);
2086 ata_timing_merge(&p, t, t, ATA_TIMING_ALL); 2308 ata_timing_merge(&p, t, t, ATA_TIMING_ALL);
2087 } 2309 }
@@ -2153,6 +2375,7 @@ int ata_down_xfermask_limit(struct ata_device *dev, int force_pio0)
2153 2375
2154static int ata_dev_set_mode(struct ata_device *dev) 2376static int ata_dev_set_mode(struct ata_device *dev)
2155{ 2377{
2378 struct ata_eh_context *ehc = &dev->ap->eh_context;
2156 unsigned int err_mask; 2379 unsigned int err_mask;
2157 int rc; 2380 int rc;
2158 2381
@@ -2167,7 +2390,9 @@ static int ata_dev_set_mode(struct ata_device *dev)
2167 return -EIO; 2390 return -EIO;
2168 } 2391 }
2169 2392
2393 ehc->i.flags |= ATA_EHI_POST_SETMODE;
2170 rc = ata_dev_revalidate(dev, 0); 2394 rc = ata_dev_revalidate(dev, 0);
2395 ehc->i.flags &= ~ATA_EHI_POST_SETMODE;
2171 if (rc) 2396 if (rc)
2172 return rc; 2397 return rc;
2173 2398
@@ -2325,11 +2550,14 @@ static inline void ata_tf_to_host(struct ata_port *ap,
2325 * Sleep until ATA Status register bit BSY clears, 2550 * Sleep until ATA Status register bit BSY clears,
2326 * or a timeout occurs. 2551 * or a timeout occurs.
2327 * 2552 *
2328 * LOCKING: None. 2553 * LOCKING:
2554 * Kernel thread context (may sleep).
2555 *
2556 * RETURNS:
2557 * 0 on success, -errno otherwise.
2329 */ 2558 */
2330 2559int ata_busy_sleep(struct ata_port *ap,
2331unsigned int ata_busy_sleep (struct ata_port *ap, 2560 unsigned long tmout_pat, unsigned long tmout)
2332 unsigned long tmout_pat, unsigned long tmout)
2333{ 2561{
2334 unsigned long timer_start, timeout; 2562 unsigned long timer_start, timeout;
2335 u8 status; 2563 u8 status;
@@ -2337,27 +2565,32 @@ unsigned int ata_busy_sleep (struct ata_port *ap,
2337 status = ata_busy_wait(ap, ATA_BUSY, 300); 2565 status = ata_busy_wait(ap, ATA_BUSY, 300);
2338 timer_start = jiffies; 2566 timer_start = jiffies;
2339 timeout = timer_start + tmout_pat; 2567 timeout = timer_start + tmout_pat;
2340 while ((status & ATA_BUSY) && (time_before(jiffies, timeout))) { 2568 while (status != 0xff && (status & ATA_BUSY) &&
2569 time_before(jiffies, timeout)) {
2341 msleep(50); 2570 msleep(50);
2342 status = ata_busy_wait(ap, ATA_BUSY, 3); 2571 status = ata_busy_wait(ap, ATA_BUSY, 3);
2343 } 2572 }
2344 2573
2345 if (status & ATA_BUSY) 2574 if (status != 0xff && (status & ATA_BUSY))
2346 ata_port_printk(ap, KERN_WARNING, 2575 ata_port_printk(ap, KERN_WARNING,
2347 "port is slow to respond, please be patient " 2576 "port is slow to respond, please be patient "
2348 "(Status 0x%x)\n", status); 2577 "(Status 0x%x)\n", status);
2349 2578
2350 timeout = timer_start + tmout; 2579 timeout = timer_start + tmout;
2351 while ((status & ATA_BUSY) && (time_before(jiffies, timeout))) { 2580 while (status != 0xff && (status & ATA_BUSY) &&
2581 time_before(jiffies, timeout)) {
2352 msleep(50); 2582 msleep(50);
2353 status = ata_chk_status(ap); 2583 status = ata_chk_status(ap);
2354 } 2584 }
2355 2585
2586 if (status == 0xff)
2587 return -ENODEV;
2588
2356 if (status & ATA_BUSY) { 2589 if (status & ATA_BUSY) {
2357 ata_port_printk(ap, KERN_ERR, "port failed to respond " 2590 ata_port_printk(ap, KERN_ERR, "port failed to respond "
2358 "(%lu secs, Status 0x%x)\n", 2591 "(%lu secs, Status 0x%x)\n",
2359 tmout / HZ, status); 2592 tmout / HZ, status);
2360 return 1; 2593 return -EBUSY;
2361 } 2594 }
2362 2595
2363 return 0; 2596 return 0;
@@ -2448,10 +2681,8 @@ static unsigned int ata_bus_softreset(struct ata_port *ap,
2448 * the bus shows 0xFF because the odd clown forgets the D7 2681 * the bus shows 0xFF because the odd clown forgets the D7
2449 * pulldown resistor. 2682 * pulldown resistor.
2450 */ 2683 */
2451 if (ata_check_status(ap) == 0xFF) { 2684 if (ata_check_status(ap) == 0xFF)
2452 ata_port_printk(ap, KERN_ERR, "SRST failed (status 0xFF)\n"); 2685 return 0;
2453 return AC_ERR_OTHER;
2454 }
2455 2686
2456 ata_bus_post_reset(ap, devmask); 2687 ata_bus_post_reset(ap, devmask);
2457 2688
@@ -2777,9 +3008,9 @@ int ata_std_softreset(struct ata_port *ap, unsigned int *classes)
2777} 3008}
2778 3009
2779/** 3010/**
2780 * sata_std_hardreset - reset host port via SATA phy reset 3011 * sata_port_hardreset - reset port via SATA phy reset
2781 * @ap: port to reset 3012 * @ap: port to reset
2782 * @class: resulting class of attached device 3013 * @timing: timing parameters { interval, duratinon, timeout } in msec
2783 * 3014 *
2784 * SATA phy-reset host port using DET bits of SControl register. 3015 * SATA phy-reset host port using DET bits of SControl register.
2785 * 3016 *
@@ -2789,10 +3020,8 @@ int ata_std_softreset(struct ata_port *ap, unsigned int *classes)
2789 * RETURNS: 3020 * RETURNS:
2790 * 0 on success, -errno otherwise. 3021 * 0 on success, -errno otherwise.
2791 */ 3022 */
2792int sata_std_hardreset(struct ata_port *ap, unsigned int *class) 3023int sata_port_hardreset(struct ata_port *ap, const unsigned long *timing)
2793{ 3024{
2794 struct ata_eh_context *ehc = &ap->eh_context;
2795 const unsigned long *timing = sata_ehc_deb_timing(ehc);
2796 u32 scontrol; 3025 u32 scontrol;
2797 int rc; 3026 int rc;
2798 3027
@@ -2805,24 +3034,24 @@ int sata_std_hardreset(struct ata_port *ap, unsigned int *class)
2805 * and Sil3124. 3034 * and Sil3124.
2806 */ 3035 */
2807 if ((rc = sata_scr_read(ap, SCR_CONTROL, &scontrol))) 3036 if ((rc = sata_scr_read(ap, SCR_CONTROL, &scontrol)))
2808 return rc; 3037 goto out;
2809 3038
2810 scontrol = (scontrol & 0x0f0) | 0x304; 3039 scontrol = (scontrol & 0x0f0) | 0x304;
2811 3040
2812 if ((rc = sata_scr_write(ap, SCR_CONTROL, scontrol))) 3041 if ((rc = sata_scr_write(ap, SCR_CONTROL, scontrol)))
2813 return rc; 3042 goto out;
2814 3043
2815 sata_set_spd(ap); 3044 sata_set_spd(ap);
2816 } 3045 }
2817 3046
2818 /* issue phy wake/reset */ 3047 /* issue phy wake/reset */
2819 if ((rc = sata_scr_read(ap, SCR_CONTROL, &scontrol))) 3048 if ((rc = sata_scr_read(ap, SCR_CONTROL, &scontrol)))
2820 return rc; 3049 goto out;
2821 3050
2822 scontrol = (scontrol & 0x0f0) | 0x301; 3051 scontrol = (scontrol & 0x0f0) | 0x301;
2823 3052
2824 if ((rc = sata_scr_write_flush(ap, SCR_CONTROL, scontrol))) 3053 if ((rc = sata_scr_write_flush(ap, SCR_CONTROL, scontrol)))
2825 return rc; 3054 goto out;
2826 3055
2827 /* Couldn't find anything in SATA I/II specs, but AHCI-1.1 3056 /* Couldn't find anything in SATA I/II specs, but AHCI-1.1
2828 * 10.4.2 says at least 1 ms. 3057 * 10.4.2 says at least 1 ms.
@@ -2830,7 +3059,40 @@ int sata_std_hardreset(struct ata_port *ap, unsigned int *class)
2830 msleep(1); 3059 msleep(1);
2831 3060
2832 /* bring phy back */ 3061 /* bring phy back */
2833 sata_phy_resume(ap, timing); 3062 rc = sata_phy_resume(ap, timing);
3063 out:
3064 DPRINTK("EXIT, rc=%d\n", rc);
3065 return rc;
3066}
3067
3068/**
3069 * sata_std_hardreset - reset host port via SATA phy reset
3070 * @ap: port to reset
3071 * @class: resulting class of attached device
3072 *
3073 * SATA phy-reset host port using DET bits of SControl register,
3074 * wait for !BSY and classify the attached device.
3075 *
3076 * LOCKING:
3077 * Kernel thread context (may sleep)
3078 *
3079 * RETURNS:
3080 * 0 on success, -errno otherwise.
3081 */
3082int sata_std_hardreset(struct ata_port *ap, unsigned int *class)
3083{
3084 const unsigned long *timing = sata_ehc_deb_timing(&ap->eh_context);
3085 int rc;
3086
3087 DPRINTK("ENTER\n");
3088
3089 /* do hardreset */
3090 rc = sata_port_hardreset(ap, timing);
3091 if (rc) {
3092 ata_port_printk(ap, KERN_ERR,
3093 "COMRESET failed (errno=%d)\n", rc);
3094 return rc;
3095 }
2834 3096
2835 /* TODO: phy layer with polling, timeouts, etc. */ 3097 /* TODO: phy layer with polling, timeouts, etc. */
2836 if (ata_port_offline(ap)) { 3098 if (ata_port_offline(ap)) {
@@ -2969,7 +3231,7 @@ static int ata_dev_same_device(struct ata_device *dev, unsigned int new_class,
2969/** 3231/**
2970 * ata_dev_revalidate - Revalidate ATA device 3232 * ata_dev_revalidate - Revalidate ATA device
2971 * @dev: device to revalidate 3233 * @dev: device to revalidate
2972 * @post_reset: is this revalidation after reset? 3234 * @readid_flags: read ID flags
2973 * 3235 *
2974 * Re-read IDENTIFY page and make sure @dev is still attached to 3236 * Re-read IDENTIFY page and make sure @dev is still attached to
2975 * the port. 3237 * the port.
@@ -2980,7 +3242,7 @@ static int ata_dev_same_device(struct ata_device *dev, unsigned int new_class,
2980 * RETURNS: 3242 * RETURNS:
2981 * 0 on success, negative errno otherwise 3243 * 0 on success, negative errno otherwise
2982 */ 3244 */
2983int ata_dev_revalidate(struct ata_device *dev, int post_reset) 3245int ata_dev_revalidate(struct ata_device *dev, unsigned int readid_flags)
2984{ 3246{
2985 unsigned int class = dev->class; 3247 unsigned int class = dev->class;
2986 u16 *id = (void *)dev->ap->sector_buf; 3248 u16 *id = (void *)dev->ap->sector_buf;
@@ -2992,7 +3254,7 @@ int ata_dev_revalidate(struct ata_device *dev, int post_reset)
2992 } 3254 }
2993 3255
2994 /* read ID data */ 3256 /* read ID data */
2995 rc = ata_dev_read_id(dev, &class, post_reset, id); 3257 rc = ata_dev_read_id(dev, &class, readid_flags, id);
2996 if (rc) 3258 if (rc)
2997 goto fail; 3259 goto fail;
2998 3260
@@ -3005,7 +3267,7 @@ int ata_dev_revalidate(struct ata_device *dev, int post_reset)
3005 memcpy(dev->id, id, sizeof(id[0]) * ATA_ID_WORDS); 3267 memcpy(dev->id, id, sizeof(id[0]) * ATA_ID_WORDS);
3006 3268
3007 /* configure device according to the new ID */ 3269 /* configure device according to the new ID */
3008 rc = ata_dev_configure(dev, 0); 3270 rc = ata_dev_configure(dev);
3009 if (rc == 0) 3271 if (rc == 0)
3010 return 0; 3272 return 0;
3011 3273
@@ -3014,37 +3276,55 @@ int ata_dev_revalidate(struct ata_device *dev, int post_reset)
3014 return rc; 3276 return rc;
3015} 3277}
3016 3278
3017static const char * const ata_dma_blacklist [] = { 3279struct ata_blacklist_entry {
3018 "WDC AC11000H", NULL, 3280 const char *model_num;
3019 "WDC AC22100H", NULL, 3281 const char *model_rev;
3020 "WDC AC32500H", NULL, 3282 unsigned long horkage;
3021 "WDC AC33100H", NULL, 3283};
3022 "WDC AC31600H", NULL, 3284
3023 "WDC AC32100H", "24.09P07", 3285static const struct ata_blacklist_entry ata_device_blacklist [] = {
3024 "WDC AC23200L", "21.10N21", 3286 /* Devices with DMA related problems under Linux */
3025 "Compaq CRD-8241B", NULL, 3287 { "WDC AC11000H", NULL, ATA_HORKAGE_NODMA },
3026 "CRD-8400B", NULL, 3288 { "WDC AC22100H", NULL, ATA_HORKAGE_NODMA },
3027 "CRD-8480B", NULL, 3289 { "WDC AC32500H", NULL, ATA_HORKAGE_NODMA },
3028 "CRD-8482B", NULL, 3290 { "WDC AC33100H", NULL, ATA_HORKAGE_NODMA },
3029 "CRD-84", NULL, 3291 { "WDC AC31600H", NULL, ATA_HORKAGE_NODMA },
3030 "SanDisk SDP3B", NULL, 3292 { "WDC AC32100H", "24.09P07", ATA_HORKAGE_NODMA },
3031 "SanDisk SDP3B-64", NULL, 3293 { "WDC AC23200L", "21.10N21", ATA_HORKAGE_NODMA },
3032 "SANYO CD-ROM CRD", NULL, 3294 { "Compaq CRD-8241B", NULL, ATA_HORKAGE_NODMA },
3033 "HITACHI CDR-8", NULL, 3295 { "CRD-8400B", NULL, ATA_HORKAGE_NODMA },
3034 "HITACHI CDR-8335", NULL, 3296 { "CRD-8480B", NULL, ATA_HORKAGE_NODMA },
3035 "HITACHI CDR-8435", NULL, 3297 { "CRD-8482B", NULL, ATA_HORKAGE_NODMA },
3036 "Toshiba CD-ROM XM-6202B", NULL, 3298 { "CRD-84", NULL, ATA_HORKAGE_NODMA },
3037 "TOSHIBA CD-ROM XM-1702BC", NULL, 3299 { "SanDisk SDP3B", NULL, ATA_HORKAGE_NODMA },
3038 "CD-532E-A", NULL, 3300 { "SanDisk SDP3B-64", NULL, ATA_HORKAGE_NODMA },
3039 "E-IDE CD-ROM CR-840", NULL, 3301 { "SANYO CD-ROM CRD", NULL, ATA_HORKAGE_NODMA },
3040 "CD-ROM Drive/F5A", NULL, 3302 { "HITACHI CDR-8", NULL, ATA_HORKAGE_NODMA },
3041 "WPI CDD-820", NULL, 3303 { "HITACHI CDR-8335", NULL, ATA_HORKAGE_NODMA },
3042 "SAMSUNG CD-ROM SC-148C", NULL, 3304 { "HITACHI CDR-8435", NULL, ATA_HORKAGE_NODMA },
3043 "SAMSUNG CD-ROM SC", NULL, 3305 { "Toshiba CD-ROM XM-6202B", NULL, ATA_HORKAGE_NODMA },
3044 "SanDisk SDP3B-64", NULL, 3306 { "TOSHIBA CD-ROM XM-1702BC", NULL, ATA_HORKAGE_NODMA },
3045 "ATAPI CD-ROM DRIVE 40X MAXIMUM",NULL, 3307 { "CD-532E-A", NULL, ATA_HORKAGE_NODMA },
3046 "_NEC DV5800A", NULL, 3308 { "E-IDE CD-ROM CR-840",NULL, ATA_HORKAGE_NODMA },
3047 "SAMSUNG CD-ROM SN-124", "N001" 3309 { "CD-ROM Drive/F5A", NULL, ATA_HORKAGE_NODMA },
3310 { "WPI CDD-820", NULL, ATA_HORKAGE_NODMA },
3311 { "SAMSUNG CD-ROM SC-148C", NULL, ATA_HORKAGE_NODMA },
3312 { "SAMSUNG CD-ROM SC", NULL, ATA_HORKAGE_NODMA },
3313 { "SanDisk SDP3B-64", NULL, ATA_HORKAGE_NODMA },
3314 { "ATAPI CD-ROM DRIVE 40X MAXIMUM",NULL,ATA_HORKAGE_NODMA },
3315 { "_NEC DV5800A", NULL, ATA_HORKAGE_NODMA },
3316 { "SAMSUNG CD-ROM SN-124","N001", ATA_HORKAGE_NODMA },
3317
3318 /* Devices we expect to fail diagnostics */
3319
3320 /* Devices where NCQ should be avoided */
3321 /* NCQ is slow */
3322 { "WDC WD740ADFD-00", NULL, ATA_HORKAGE_NONCQ },
3323
3324 /* Devices with NCQ limits */
3325
3326 /* End Marker */
3327 { }
3048}; 3328};
3049 3329
3050static int ata_strim(char *s, size_t len) 3330static int ata_strim(char *s, size_t len)
@@ -3059,20 +3339,12 @@ static int ata_strim(char *s, size_t len)
3059 return len; 3339 return len;
3060} 3340}
3061 3341
3062static int ata_dma_blacklisted(const struct ata_device *dev) 3342unsigned long ata_device_blacklisted(const struct ata_device *dev)
3063{ 3343{
3064 unsigned char model_num[40]; 3344 unsigned char model_num[40];
3065 unsigned char model_rev[16]; 3345 unsigned char model_rev[16];
3066 unsigned int nlen, rlen; 3346 unsigned int nlen, rlen;
3067 int i; 3347 const struct ata_blacklist_entry *ad = ata_device_blacklist;
3068
3069 /* We don't support polling DMA.
3070 * DMA blacklist those ATAPI devices with CDB-intr (and use PIO)
3071 * if the LLDD handles only interrupts in the HSM_ST_LAST state.
3072 */
3073 if ((dev->ap->flags & ATA_FLAG_PIO_POLLING) &&
3074 (dev->flags & ATA_DFLAG_CDB_INTR))
3075 return 1;
3076 3348
3077 ata_id_string(dev->id, model_num, ATA_ID_PROD_OFS, 3349 ata_id_string(dev->id, model_num, ATA_ID_PROD_OFS,
3078 sizeof(model_num)); 3350 sizeof(model_num));
@@ -3081,17 +3353,30 @@ static int ata_dma_blacklisted(const struct ata_device *dev)
3081 nlen = ata_strim(model_num, sizeof(model_num)); 3353 nlen = ata_strim(model_num, sizeof(model_num));
3082 rlen = ata_strim(model_rev, sizeof(model_rev)); 3354 rlen = ata_strim(model_rev, sizeof(model_rev));
3083 3355
3084 for (i = 0; i < ARRAY_SIZE(ata_dma_blacklist); i += 2) { 3356 while (ad->model_num) {
3085 if (!strncmp(ata_dma_blacklist[i], model_num, nlen)) { 3357 if (!strncmp(ad->model_num, model_num, nlen)) {
3086 if (ata_dma_blacklist[i+1] == NULL) 3358 if (ad->model_rev == NULL)
3087 return 1; 3359 return ad->horkage;
3088 if (!strncmp(ata_dma_blacklist[i], model_rev, rlen)) 3360 if (!strncmp(ad->model_rev, model_rev, rlen))
3089 return 1; 3361 return ad->horkage;
3090 } 3362 }
3363 ad++;
3091 } 3364 }
3092 return 0; 3365 return 0;
3093} 3366}
3094 3367
3368static int ata_dma_blacklisted(const struct ata_device *dev)
3369{
3370 /* We don't support polling DMA.
3371 * DMA blacklist those ATAPI devices with CDB-intr (and use PIO)
3372 * if the LLDD handles only interrupts in the HSM_ST_LAST state.
3373 */
3374 if ((dev->ap->flags & ATA_FLAG_PIO_POLLING) &&
3375 (dev->flags & ATA_DFLAG_CDB_INTR))
3376 return 1;
3377 return (ata_device_blacklisted(dev) & ATA_HORKAGE_NODMA) ? 1 : 0;
3378}
3379
3095/** 3380/**
3096 * ata_dev_xfermask - Compute supported xfermask of the given device 3381 * ata_dev_xfermask - Compute supported xfermask of the given device
3097 * @dev: Device to compute xfermask for 3382 * @dev: Device to compute xfermask for
@@ -3119,6 +3404,13 @@ static void ata_dev_xfermask(struct ata_device *dev)
3119 */ 3404 */
3120 if (ap->cbl == ATA_CBL_PATA40) 3405 if (ap->cbl == ATA_CBL_PATA40)
3121 xfer_mask &= ~(0xF8 << ATA_SHIFT_UDMA); 3406 xfer_mask &= ~(0xF8 << ATA_SHIFT_UDMA);
3407 /* Apply drive side cable rule. Unknown or 80 pin cables reported
3408 * host side are checked drive side as well. Cases where we know a
3409 * 40wire cable is used safely for 80 are not checked here.
3410 */
3411 if (ata_drive_40wire(dev->id) && (ap->cbl == ATA_CBL_PATA_UNK || ap->cbl == ATA_CBL_PATA80))
3412 xfer_mask &= ~(0xF8 << ATA_SHIFT_UDMA);
3413
3122 3414
3123 xfer_mask &= ata_pack_xfermask(dev->pio_mask, 3415 xfer_mask &= ata_pack_xfermask(dev->pio_mask,
3124 dev->mwdma_mask, dev->udma_mask); 3416 dev->mwdma_mask, dev->udma_mask);
@@ -3236,8 +3528,7 @@ static unsigned int ata_dev_init_params(struct ata_device *dev,
3236 * LOCKING: 3528 * LOCKING:
3237 * spin_lock_irqsave(host lock) 3529 * spin_lock_irqsave(host lock)
3238 */ 3530 */
3239 3531void ata_sg_clean(struct ata_queued_cmd *qc)
3240static void ata_sg_clean(struct ata_queued_cmd *qc)
3241{ 3532{
3242 struct ata_port *ap = qc->ap; 3533 struct ata_port *ap = qc->ap;
3243 struct scatterlist *sg = qc->__sg; 3534 struct scatterlist *sg = qc->__sg;
@@ -3395,19 +3686,15 @@ void ata_noop_qc_prep(struct ata_queued_cmd *qc) { }
3395 3686
3396void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, unsigned int buflen) 3687void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, unsigned int buflen)
3397{ 3688{
3398 struct scatterlist *sg;
3399
3400 qc->flags |= ATA_QCFLAG_SINGLE; 3689 qc->flags |= ATA_QCFLAG_SINGLE;
3401 3690
3402 memset(&qc->sgent, 0, sizeof(qc->sgent));
3403 qc->__sg = &qc->sgent; 3691 qc->__sg = &qc->sgent;
3404 qc->n_elem = 1; 3692 qc->n_elem = 1;
3405 qc->orig_n_elem = 1; 3693 qc->orig_n_elem = 1;
3406 qc->buf_virt = buf; 3694 qc->buf_virt = buf;
3407 qc->nbytes = buflen; 3695 qc->nbytes = buflen;
3408 3696
3409 sg = qc->__sg; 3697 sg_init_one(&qc->sgent, buf, buflen);
3410 sg_init_one(sg, buf, buflen);
3411} 3698}
3412 3699
3413/** 3700/**
@@ -4200,8 +4487,12 @@ fsm_start:
4200 /* device stops HSM for abort/error */ 4487 /* device stops HSM for abort/error */
4201 qc->err_mask |= AC_ERR_DEV; 4488 qc->err_mask |= AC_ERR_DEV;
4202 else 4489 else
4203 /* HSM violation. Let EH handle this */ 4490 /* HSM violation. Let EH handle this.
4204 qc->err_mask |= AC_ERR_HSM; 4491 * Phantom devices also trigger this
4492 * condition. Mark hint.
4493 */
4494 qc->err_mask |= AC_ERR_HSM |
4495 AC_ERR_NODEV_HINT;
4205 4496
4206 ap->hsm_task_state = HSM_ST_ERR; 4497 ap->hsm_task_state = HSM_ST_ERR;
4207 goto fsm_start; 4498 goto fsm_start;
@@ -4295,10 +4586,11 @@ fsm_start:
4295 return poll_next; 4586 return poll_next;
4296} 4587}
4297 4588
4298static void ata_pio_task(void *_data) 4589static void ata_pio_task(struct work_struct *work)
4299{ 4590{
4300 struct ata_queued_cmd *qc = _data; 4591 struct ata_port *ap =
4301 struct ata_port *ap = qc->ap; 4592 container_of(work, struct ata_port, port_task.work);
4593 struct ata_queued_cmd *qc = ap->port_task_data;
4302 u8 status; 4594 u8 status;
4303 int poll_next; 4595 int poll_next;
4304 4596
@@ -4440,6 +4732,14 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
4440 qc->complete_fn(qc); 4732 qc->complete_fn(qc);
4441} 4733}
4442 4734
4735static void fill_result_tf(struct ata_queued_cmd *qc)
4736{
4737 struct ata_port *ap = qc->ap;
4738
4739 ap->ops->tf_read(ap, &qc->result_tf);
4740 qc->result_tf.flags = qc->tf.flags;
4741}
4742
4443/** 4743/**
4444 * ata_qc_complete - Complete an active ATA command 4744 * ata_qc_complete - Complete an active ATA command
4445 * @qc: Command to complete 4745 * @qc: Command to complete
@@ -4477,7 +4777,7 @@ void ata_qc_complete(struct ata_queued_cmd *qc)
4477 if (unlikely(qc->flags & ATA_QCFLAG_FAILED)) { 4777 if (unlikely(qc->flags & ATA_QCFLAG_FAILED)) {
4478 if (!ata_tag_internal(qc->tag)) { 4778 if (!ata_tag_internal(qc->tag)) {
4479 /* always fill result TF for failed qc */ 4779 /* always fill result TF for failed qc */
4480 ap->ops->tf_read(ap, &qc->result_tf); 4780 fill_result_tf(qc);
4481 ata_qc_schedule_eh(qc); 4781 ata_qc_schedule_eh(qc);
4482 return; 4782 return;
4483 } 4783 }
@@ -4485,7 +4785,7 @@ void ata_qc_complete(struct ata_queued_cmd *qc)
4485 4785
4486 /* read result TF if requested */ 4786 /* read result TF if requested */
4487 if (qc->flags & ATA_QCFLAG_RESULT_TF) 4787 if (qc->flags & ATA_QCFLAG_RESULT_TF)
4488 ap->ops->tf_read(ap, &qc->result_tf); 4788 fill_result_tf(qc);
4489 4789
4490 __ata_qc_complete(qc); 4790 __ata_qc_complete(qc);
4491 } else { 4791 } else {
@@ -4494,7 +4794,7 @@ void ata_qc_complete(struct ata_queued_cmd *qc)
4494 4794
4495 /* read result TF if failed or requested */ 4795 /* read result TF if failed or requested */
4496 if (qc->err_mask || qc->flags & ATA_QCFLAG_RESULT_TF) 4796 if (qc->err_mask || qc->flags & ATA_QCFLAG_RESULT_TF)
4497 ap->ops->tf_read(ap, &qc->result_tf); 4797 fill_result_tf(qc);
4498 4798
4499 __ata_qc_complete(qc); 4799 __ata_qc_complete(qc);
4500 } 4800 }
@@ -4660,6 +4960,7 @@ unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc)
4660 if (ap->flags & ATA_FLAG_PIO_POLLING) { 4960 if (ap->flags & ATA_FLAG_PIO_POLLING) {
4661 switch (qc->tf.protocol) { 4961 switch (qc->tf.protocol) {
4662 case ATA_PROT_PIO: 4962 case ATA_PROT_PIO:
4963 case ATA_PROT_NODATA:
4663 case ATA_PROT_ATAPI: 4964 case ATA_PROT_ATAPI:
4664 case ATA_PROT_ATAPI_NODATA: 4965 case ATA_PROT_ATAPI_NODATA:
4665 qc->tf.flags |= ATA_TFLAG_POLLING; 4966 qc->tf.flags |= ATA_TFLAG_POLLING;
@@ -4674,6 +4975,14 @@ unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc)
4674 } 4975 }
4675 } 4976 }
4676 4977
4978 /* Some controllers show flaky interrupt behavior after
4979 * setting xfer mode. Use polling instead.
4980 */
4981 if (unlikely(qc->tf.command == ATA_CMD_SET_FEATURES &&
4982 qc->tf.feature == SETFEATURES_XFER) &&
4983 (ap->flags & ATA_FLAG_SETXFER_POLLING))
4984 qc->tf.flags |= ATA_TFLAG_POLLING;
4985
4677 /* select the device */ 4986 /* select the device */
4678 ata_dev_select(ap, qc->dev->devno, 1, 0); 4987 ata_dev_select(ap, qc->dev->devno, 1, 0);
4679 4988
@@ -4782,6 +5091,7 @@ unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc)
4782inline unsigned int ata_host_intr (struct ata_port *ap, 5091inline unsigned int ata_host_intr (struct ata_port *ap,
4783 struct ata_queued_cmd *qc) 5092 struct ata_queued_cmd *qc)
4784{ 5093{
5094 struct ata_eh_info *ehi = &ap->eh_info;
4785 u8 status, host_stat = 0; 5095 u8 status, host_stat = 0;
4786 5096
4787 VPRINTK("ata%u: protocol %d task_state %d\n", 5097 VPRINTK("ata%u: protocol %d task_state %d\n",
@@ -4842,6 +5152,11 @@ inline unsigned int ata_host_intr (struct ata_port *ap,
4842 ap->ops->irq_clear(ap); 5152 ap->ops->irq_clear(ap);
4843 5153
4844 ata_hsm_move(ap, qc, status, 0); 5154 ata_hsm_move(ap, qc, status, 0);
5155
5156 if (unlikely(qc->err_mask) && (qc->tf.protocol == ATA_PROT_DMA ||
5157 qc->tf.protocol == ATA_PROT_ATAPI_DMA))
5158 ata_ehi_push_desc(ehi, "BMDMA stat 0x%x", host_stat);
5159
4845 return 1; /* irq handled */ 5160 return 1; /* irq handled */
4846 5161
4847idle_irq: 5162idle_irq:
@@ -5048,7 +5363,7 @@ int ata_flush_cache(struct ata_device *dev)
5048 if (!ata_try_flush_cache(dev)) 5363 if (!ata_try_flush_cache(dev))
5049 return 0; 5364 return 0;
5050 5365
5051 if (ata_id_has_flush_ext(dev->id)) 5366 if (dev->flags & ATA_DFLAG_FLUSH_EXT)
5052 cmd = ATA_CMD_FLUSH_EXT; 5367 cmd = ATA_CMD_FLUSH_EXT;
5053 else 5368 else
5054 cmd = ATA_CMD_FLUSH; 5369 cmd = ATA_CMD_FLUSH;
@@ -5320,9 +5635,9 @@ void ata_port_init(struct ata_port *ap, struct ata_host *host,
5320 ap->msg_enable = ATA_MSG_DRV | ATA_MSG_ERR | ATA_MSG_WARN; 5635 ap->msg_enable = ATA_MSG_DRV | ATA_MSG_ERR | ATA_MSG_WARN;
5321#endif 5636#endif
5322 5637
5323 INIT_WORK(&ap->port_task, NULL, NULL); 5638 INIT_DELAYED_WORK(&ap->port_task, NULL);
5324 INIT_WORK(&ap->hotplug_task, ata_scsi_hotplug, ap); 5639 INIT_DELAYED_WORK(&ap->hotplug_task, ata_scsi_hotplug);
5325 INIT_WORK(&ap->scsi_rescan_task, ata_scsi_dev_rescan, ap); 5640 INIT_WORK(&ap->scsi_rescan_task, ata_scsi_dev_rescan);
5326 INIT_LIST_HEAD(&ap->eh_done_q); 5641 INIT_LIST_HEAD(&ap->eh_done_q);
5327 init_waitqueue_head(&ap->eh_wait_q); 5642 init_waitqueue_head(&ap->eh_wait_q);
5328 5643
@@ -5520,9 +5835,8 @@ int ata_device_add(const struct ata_probe_ent *ent)
5520 ap->ioaddr.bmdma_addr, 5835 ap->ioaddr.bmdma_addr,
5521 irq_line); 5836 irq_line);
5522 5837
5523 ata_chk_status(ap); 5838 /* freeze port before requesting IRQ */
5524 host->ops->irq_clear(ap); 5839 ata_eh_freeze_port(ap);
5525 ata_eh_freeze_port(ap); /* freeze port before requesting IRQ */
5526 } 5840 }
5527 5841
5528 /* obtain irq, that may be shared between channels */ 5842 /* obtain irq, that may be shared between channels */
@@ -5957,7 +6271,7 @@ static void __exit ata_exit(void)
5957 destroy_workqueue(ata_aux_wq); 6271 destroy_workqueue(ata_aux_wq);
5958} 6272}
5959 6273
5960module_init(ata_init); 6274subsys_initcall(ata_init);
5961module_exit(ata_exit); 6275module_exit(ata_exit);
5962 6276
5963static unsigned long ratelimit_time; 6277static unsigned long ratelimit_time;
@@ -6120,6 +6434,7 @@ EXPORT_SYMBOL_GPL(__sata_phy_reset);
6120EXPORT_SYMBOL_GPL(ata_bus_reset); 6434EXPORT_SYMBOL_GPL(ata_bus_reset);
6121EXPORT_SYMBOL_GPL(ata_std_prereset); 6435EXPORT_SYMBOL_GPL(ata_std_prereset);
6122EXPORT_SYMBOL_GPL(ata_std_softreset); 6436EXPORT_SYMBOL_GPL(ata_std_softreset);
6437EXPORT_SYMBOL_GPL(sata_port_hardreset);
6123EXPORT_SYMBOL_GPL(sata_std_hardreset); 6438EXPORT_SYMBOL_GPL(sata_std_hardreset);
6124EXPORT_SYMBOL_GPL(ata_std_postreset); 6439EXPORT_SYMBOL_GPL(ata_std_postreset);
6125EXPORT_SYMBOL_GPL(ata_dev_classify); 6440EXPORT_SYMBOL_GPL(ata_dev_classify);
@@ -6146,6 +6461,7 @@ EXPORT_SYMBOL_GPL(ata_host_suspend);
6146EXPORT_SYMBOL_GPL(ata_host_resume); 6461EXPORT_SYMBOL_GPL(ata_host_resume);
6147EXPORT_SYMBOL_GPL(ata_id_string); 6462EXPORT_SYMBOL_GPL(ata_id_string);
6148EXPORT_SYMBOL_GPL(ata_id_c_string); 6463EXPORT_SYMBOL_GPL(ata_id_c_string);
6464EXPORT_SYMBOL_GPL(ata_device_blacklisted);
6149EXPORT_SYMBOL_GPL(ata_scsi_simulate); 6465EXPORT_SYMBOL_GPL(ata_scsi_simulate);
6150 6466
6151EXPORT_SYMBOL_GPL(ata_pio_need_iordy); 6467EXPORT_SYMBOL_GPL(ata_pio_need_iordy);
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 02b2b2787d9b..08ad44b3e48f 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -332,7 +332,7 @@ void ata_scsi_error(struct Scsi_Host *host)
332 if (ap->pflags & ATA_PFLAG_LOADING) 332 if (ap->pflags & ATA_PFLAG_LOADING)
333 ap->pflags &= ~ATA_PFLAG_LOADING; 333 ap->pflags &= ~ATA_PFLAG_LOADING;
334 else if (ap->pflags & ATA_PFLAG_SCSI_HOTPLUG) 334 else if (ap->pflags & ATA_PFLAG_SCSI_HOTPLUG)
335 queue_work(ata_aux_wq, &ap->hotplug_task); 335 queue_delayed_work(ata_aux_wq, &ap->hotplug_task, 0);
336 336
337 if (ap->pflags & ATA_PFLAG_RECOVERED) 337 if (ap->pflags & ATA_PFLAG_RECOVERED)
338 ata_port_printk(ap, KERN_INFO, "EH complete\n"); 338 ata_port_printk(ap, KERN_INFO, "EH complete\n");
@@ -1136,19 +1136,21 @@ static unsigned int ata_eh_analyze_tf(struct ata_queued_cmd *qc,
1136 break; 1136 break;
1137 1137
1138 case ATA_DEV_ATAPI: 1138 case ATA_DEV_ATAPI:
1139 tmp = atapi_eh_request_sense(qc->dev, 1139 if (!(qc->ap->pflags & ATA_PFLAG_FROZEN)) {
1140 qc->scsicmd->sense_buffer); 1140 tmp = atapi_eh_request_sense(qc->dev,
1141 if (!tmp) { 1141 qc->scsicmd->sense_buffer);
1142 /* ATA_QCFLAG_SENSE_VALID is used to tell 1142 if (!tmp) {
1143 * atapi_qc_complete() that sense data is 1143 /* ATA_QCFLAG_SENSE_VALID is used to
1144 * already valid. 1144 * tell atapi_qc_complete() that sense
1145 * 1145 * data is already valid.
1146 * TODO: interpret sense data and set 1146 *
1147 * appropriate err_mask. 1147 * TODO: interpret sense data and set
1148 */ 1148 * appropriate err_mask.
1149 qc->flags |= ATA_QCFLAG_SENSE_VALID; 1149 */
1150 } else 1150 qc->flags |= ATA_QCFLAG_SENSE_VALID;
1151 qc->err_mask |= tmp; 1151 } else
1152 qc->err_mask |= tmp;
1153 }
1152 } 1154 }
1153 1155
1154 if (qc->err_mask & (AC_ERR_HSM | AC_ERR_TIMEOUT | AC_ERR_ATA_BUS)) 1156 if (qc->err_mask & (AC_ERR_HSM | AC_ERR_TIMEOUT | AC_ERR_ATA_BUS))
@@ -1433,16 +1435,39 @@ static void ata_eh_report(struct ata_port *ap)
1433 } 1435 }
1434 1436
1435 for (tag = 0; tag < ATA_MAX_QUEUE; tag++) { 1437 for (tag = 0; tag < ATA_MAX_QUEUE; tag++) {
1438 static const char *dma_str[] = {
1439 [DMA_BIDIRECTIONAL] = "bidi",
1440 [DMA_TO_DEVICE] = "out",
1441 [DMA_FROM_DEVICE] = "in",
1442 [DMA_NONE] = "",
1443 };
1436 struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag); 1444 struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag);
1445 struct ata_taskfile *cmd = &qc->tf, *res = &qc->result_tf;
1446 unsigned int nbytes;
1437 1447
1438 if (!(qc->flags & ATA_QCFLAG_FAILED) || !qc->err_mask) 1448 if (!(qc->flags & ATA_QCFLAG_FAILED) || !qc->err_mask)
1439 continue; 1449 continue;
1440 1450
1441 ata_dev_printk(qc->dev, KERN_ERR, "tag %d cmd 0x%x " 1451 nbytes = qc->nbytes;
1442 "Emask 0x%x stat 0x%x err 0x%x (%s)\n", 1452 if (!nbytes)
1443 qc->tag, qc->tf.command, qc->err_mask, 1453 nbytes = qc->nsect << 9;
1444 qc->result_tf.command, qc->result_tf.feature, 1454
1445 ata_err_string(qc->err_mask)); 1455 ata_dev_printk(qc->dev, KERN_ERR,
1456 "cmd %02x/%02x:%02x:%02x:%02x:%02x/%02x:%02x:%02x:%02x:%02x/%02x "
1457 "tag %d cdb 0x%x data %u %s\n "
1458 "res %02x/%02x:%02x:%02x:%02x:%02x/%02x:%02x:%02x:%02x:%02x/%02x "
1459 "Emask 0x%x (%s)\n",
1460 cmd->command, cmd->feature, cmd->nsect,
1461 cmd->lbal, cmd->lbam, cmd->lbah,
1462 cmd->hob_feature, cmd->hob_nsect,
1463 cmd->hob_lbal, cmd->hob_lbam, cmd->hob_lbah,
1464 cmd->device, qc->tag, qc->cdb[0], nbytes,
1465 dma_str[qc->dma_dir],
1466 res->command, res->feature, res->nsect,
1467 res->lbal, res->lbam, res->lbah,
1468 res->hob_feature, res->hob_nsect,
1469 res->hob_lbal, res->hob_lbam, res->hob_lbah,
1470 res->device, qc->err_mask, ata_err_string(qc->err_mask));
1446 } 1471 }
1447} 1472}
1448 1473
@@ -1634,11 +1659,14 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap,
1634 DPRINTK("ENTER\n"); 1659 DPRINTK("ENTER\n");
1635 1660
1636 for (i = 0; i < ATA_MAX_DEVICES; i++) { 1661 for (i = 0; i < ATA_MAX_DEVICES; i++) {
1637 unsigned int action; 1662 unsigned int action, readid_flags = 0;
1638 1663
1639 dev = &ap->device[i]; 1664 dev = &ap->device[i];
1640 action = ata_eh_dev_action(dev); 1665 action = ata_eh_dev_action(dev);
1641 1666
1667 if (ehc->i.flags & ATA_EHI_DID_RESET)
1668 readid_flags |= ATA_READID_POSTRESET;
1669
1642 if (action & ATA_EH_REVALIDATE && ata_dev_ready(dev)) { 1670 if (action & ATA_EH_REVALIDATE && ata_dev_ready(dev)) {
1643 if (ata_port_offline(ap)) { 1671 if (ata_port_offline(ap)) {
1644 rc = -EIO; 1672 rc = -EIO;
@@ -1646,13 +1674,17 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap,
1646 } 1674 }
1647 1675
1648 ata_eh_about_to_do(ap, dev, ATA_EH_REVALIDATE); 1676 ata_eh_about_to_do(ap, dev, ATA_EH_REVALIDATE);
1649 rc = ata_dev_revalidate(dev, 1677 rc = ata_dev_revalidate(dev, readid_flags);
1650 ehc->i.flags & ATA_EHI_DID_RESET);
1651 if (rc) 1678 if (rc)
1652 break; 1679 break;
1653 1680
1654 ata_eh_done(ap, dev, ATA_EH_REVALIDATE); 1681 ata_eh_done(ap, dev, ATA_EH_REVALIDATE);
1655 1682
1683 /* Configuration may have changed, reconfigure
1684 * transfer mode.
1685 */
1686 ehc->i.flags |= ATA_EHI_SETMODE;
1687
1656 /* schedule the scsi_rescan_device() here */ 1688 /* schedule the scsi_rescan_device() here */
1657 queue_work(ata_aux_wq, &(ap->scsi_rescan_task)); 1689 queue_work(ata_aux_wq, &(ap->scsi_rescan_task));
1658 } else if (dev->class == ATA_DEV_UNKNOWN && 1690 } else if (dev->class == ATA_DEV_UNKNOWN &&
@@ -1660,18 +1692,35 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap,
1660 ata_class_enabled(ehc->classes[dev->devno])) { 1692 ata_class_enabled(ehc->classes[dev->devno])) {
1661 dev->class = ehc->classes[dev->devno]; 1693 dev->class = ehc->classes[dev->devno];
1662 1694
1663 rc = ata_dev_read_id(dev, &dev->class, 1, dev->id); 1695 rc = ata_dev_read_id(dev, &dev->class, readid_flags,
1664 if (rc == 0) 1696 dev->id);
1665 rc = ata_dev_configure(dev, 1); 1697 if (rc == 0) {
1698 ehc->i.flags |= ATA_EHI_PRINTINFO;
1699 rc = ata_dev_configure(dev);
1700 ehc->i.flags &= ~ATA_EHI_PRINTINFO;
1701 } else if (rc == -ENOENT) {
1702 /* IDENTIFY was issued to non-existent
1703 * device. No need to reset. Just
1704 * thaw and kill the device.
1705 */
1706 ata_eh_thaw_port(ap);
1707 dev->class = ATA_DEV_UNKNOWN;
1708 rc = 0;
1709 }
1666 1710
1667 if (rc) { 1711 if (rc) {
1668 dev->class = ATA_DEV_UNKNOWN; 1712 dev->class = ATA_DEV_UNKNOWN;
1669 break; 1713 break;
1670 } 1714 }
1671 1715
1672 spin_lock_irqsave(ap->lock, flags); 1716 if (ata_dev_enabled(dev)) {
1673 ap->pflags |= ATA_PFLAG_SCSI_HOTPLUG; 1717 spin_lock_irqsave(ap->lock, flags);
1674 spin_unlock_irqrestore(ap->lock, flags); 1718 ap->pflags |= ATA_PFLAG_SCSI_HOTPLUG;
1719 spin_unlock_irqrestore(ap->lock, flags);
1720
1721 /* new device discovered, configure xfermode */
1722 ehc->i.flags |= ATA_EHI_SETMODE;
1723 }
1675 } 1724 }
1676 } 1725 }
1677 1726
@@ -1987,13 +2036,14 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
1987 if (rc) 2036 if (rc)
1988 goto dev_fail; 2037 goto dev_fail;
1989 2038
1990 /* configure transfer mode if the port has been reset */ 2039 /* configure transfer mode if necessary */
1991 if (ehc->i.flags & ATA_EHI_DID_RESET) { 2040 if (ehc->i.flags & ATA_EHI_SETMODE) {
1992 rc = ata_set_mode(ap, &dev); 2041 rc = ata_set_mode(ap, &dev);
1993 if (rc) { 2042 if (rc) {
1994 down_xfermask = 1; 2043 down_xfermask = 1;
1995 goto dev_fail; 2044 goto dev_fail;
1996 } 2045 }
2046 ehc->i.flags &= ~ATA_EHI_SETMODE;
1997 } 2047 }
1998 2048
1999 /* suspend devices */ 2049 /* suspend devices */
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 7af2a4ba4990..664e1377b54c 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -671,7 +671,7 @@ void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc,
671} 671}
672 672
673/* 673/*
674 * ata_gen_ata_desc_sense - Generate check condition sense block. 674 * ata_gen_passthru_sense - Generate check condition sense block.
675 * @qc: Command that completed. 675 * @qc: Command that completed.
676 * 676 *
677 * This function is specific to the ATA descriptor format sense 677 * This function is specific to the ATA descriptor format sense
@@ -681,9 +681,9 @@ void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc,
681 * block. Clear sense key, ASC & ASCQ if there is no error. 681 * block. Clear sense key, ASC & ASCQ if there is no error.
682 * 682 *
683 * LOCKING: 683 * LOCKING:
684 * spin_lock_irqsave(host lock) 684 * None.
685 */ 685 */
686void ata_gen_ata_desc_sense(struct ata_queued_cmd *qc) 686static void ata_gen_passthru_sense(struct ata_queued_cmd *qc)
687{ 687{
688 struct scsi_cmnd *cmd = qc->scsicmd; 688 struct scsi_cmnd *cmd = qc->scsicmd;
689 struct ata_taskfile *tf = &qc->result_tf; 689 struct ata_taskfile *tf = &qc->result_tf;
@@ -713,12 +713,9 @@ void ata_gen_ata_desc_sense(struct ata_queued_cmd *qc)
713 713
714 desc[0] = 0x09; 714 desc[0] = 0x09;
715 715
716 /* 716 /* set length of additional sense data */
717 * Set length of additional sense data. 717 sb[7] = 14;
718 * Since we only populate descriptor 0, the total 718 desc[1] = 12;
719 * length is the same (fixed) length as descriptor 0.
720 */
721 desc[1] = sb[7] = 14;
722 719
723 /* 720 /*
724 * Copy registers into sense buffer. 721 * Copy registers into sense buffer.
@@ -746,56 +743,56 @@ void ata_gen_ata_desc_sense(struct ata_queued_cmd *qc)
746} 743}
747 744
748/** 745/**
749 * ata_gen_fixed_sense - generate a SCSI fixed sense block 746 * ata_gen_ata_sense - generate a SCSI fixed sense block
750 * @qc: Command that we are erroring out 747 * @qc: Command that we are erroring out
751 * 748 *
752 * Leverage ata_to_sense_error() to give us the codes. Fit our 749 * Generate sense block for a failed ATA command @qc. Descriptor
753 * LBA in here if there's room. 750 * format is used to accomodate LBA48 block address.
754 * 751 *
755 * LOCKING: 752 * LOCKING:
756 * inherited from caller 753 * None.
757 */ 754 */
758void ata_gen_fixed_sense(struct ata_queued_cmd *qc) 755static void ata_gen_ata_sense(struct ata_queued_cmd *qc)
759{ 756{
757 struct ata_device *dev = qc->dev;
760 struct scsi_cmnd *cmd = qc->scsicmd; 758 struct scsi_cmnd *cmd = qc->scsicmd;
761 struct ata_taskfile *tf = &qc->result_tf; 759 struct ata_taskfile *tf = &qc->result_tf;
762 unsigned char *sb = cmd->sense_buffer; 760 unsigned char *sb = cmd->sense_buffer;
761 unsigned char *desc = sb + 8;
763 int verbose = qc->ap->ops->error_handler == NULL; 762 int verbose = qc->ap->ops->error_handler == NULL;
763 u64 block;
764 764
765 memset(sb, 0, SCSI_SENSE_BUFFERSIZE); 765 memset(sb, 0, SCSI_SENSE_BUFFERSIZE);
766 766
767 cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; 767 cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION;
768 768
769 /* 769 /* sense data is current and format is descriptor */
770 * Use ata_to_sense_error() to map status register bits 770 sb[0] = 0x72;
771
772 /* Use ata_to_sense_error() to map status register bits
771 * onto sense key, asc & ascq. 773 * onto sense key, asc & ascq.
772 */ 774 */
773 if (qc->err_mask || 775 if (qc->err_mask ||
774 tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ)) { 776 tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ)) {
775 ata_to_sense_error(qc->ap->id, tf->command, tf->feature, 777 ata_to_sense_error(qc->ap->id, tf->command, tf->feature,
776 &sb[2], &sb[12], &sb[13], verbose); 778 &sb[1], &sb[2], &sb[3], verbose);
777 sb[2] &= 0x0f; 779 sb[1] &= 0x0f;
778 } 780 }
779 781
780 sb[0] = 0x70; 782 block = ata_tf_read_block(&qc->result_tf, dev);
781 sb[7] = 0x0a;
782 783
783 if (tf->flags & ATA_TFLAG_LBA48) { 784 /* information sense data descriptor */
784 /* TODO: find solution for LBA48 descriptors */ 785 sb[7] = 12;
785 } 786 desc[0] = 0x00;
787 desc[1] = 10;
786 788
787 else if (tf->flags & ATA_TFLAG_LBA) { 789 desc[2] |= 0x80; /* valid */
788 /* A small (28b) LBA will fit in the 32b info field */ 790 desc[6] = block >> 40;
789 sb[0] |= 0x80; /* set valid bit */ 791 desc[7] = block >> 32;
790 sb[3] = tf->device & 0x0f; 792 desc[8] = block >> 24;
791 sb[4] = tf->lbah; 793 desc[9] = block >> 16;
792 sb[5] = tf->lbam; 794 desc[10] = block >> 8;
793 sb[6] = tf->lbal; 795 desc[11] = block;
794 }
795
796 else {
797 /* TODO: C/H/S */
798 }
799} 796}
800 797
801static void ata_scsi_sdev_config(struct scsi_device *sdev) 798static void ata_scsi_sdev_config(struct scsi_device *sdev)
@@ -807,23 +804,10 @@ static void ata_scsi_sdev_config(struct scsi_device *sdev)
807static void ata_scsi_dev_config(struct scsi_device *sdev, 804static void ata_scsi_dev_config(struct scsi_device *sdev,
808 struct ata_device *dev) 805 struct ata_device *dev)
809{ 806{
810 unsigned int max_sectors; 807 /* configure max sectors */
811 808 blk_queue_max_sectors(sdev->request_queue, dev->max_sectors);
812 /* TODO: 2048 is an arbitrary number, not the
813 * hardware maximum. This should be increased to
814 * 65534 when Jens Axboe's patch for dynamically
815 * determining max_sectors is merged.
816 */
817 max_sectors = ATA_MAX_SECTORS;
818 if (dev->flags & ATA_DFLAG_LBA48)
819 max_sectors = ATA_MAX_SECTORS_LBA48;
820 if (dev->max_sectors)
821 max_sectors = dev->max_sectors;
822 809
823 blk_queue_max_sectors(sdev->request_queue, max_sectors); 810 /* SATA DMA transfers must be multiples of 4 byte, so
824
825 /*
826 * SATA DMA transfers must be multiples of 4 byte, so
827 * we need to pad ATAPI transfers using an extra sg. 811 * we need to pad ATAPI transfers using an extra sg.
828 * Decrement max hw segments accordingly. 812 * Decrement max hw segments accordingly.
829 */ 813 */
@@ -1040,8 +1024,7 @@ static unsigned int ata_scsi_flush_xlat(struct ata_queued_cmd *qc, const u8 *scs
1040 tf->flags |= ATA_TFLAG_DEVICE; 1024 tf->flags |= ATA_TFLAG_DEVICE;
1041 tf->protocol = ATA_PROT_NODATA; 1025 tf->protocol = ATA_PROT_NODATA;
1042 1026
1043 if ((qc->dev->flags & ATA_DFLAG_LBA48) && 1027 if (qc->dev->flags & ATA_DFLAG_FLUSH_EXT)
1044 (ata_id_has_flush_ext(qc->dev->id)))
1045 tf->command = ATA_CMD_FLUSH_EXT; 1028 tf->command = ATA_CMD_FLUSH_EXT;
1046 else 1029 else
1047 tf->command = ATA_CMD_FLUSH; 1030 tf->command = ATA_CMD_FLUSH;
@@ -1282,17 +1265,14 @@ nothing_to_do:
1282 1265
1283static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicmd) 1266static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicmd)
1284{ 1267{
1285 struct ata_taskfile *tf = &qc->tf; 1268 unsigned int tf_flags = 0;
1286 struct ata_device *dev = qc->dev;
1287 u64 block; 1269 u64 block;
1288 u32 n_block; 1270 u32 n_block;
1289 1271 int rc;
1290 qc->flags |= ATA_QCFLAG_IO;
1291 tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
1292 1272
1293 if (scsicmd[0] == WRITE_10 || scsicmd[0] == WRITE_6 || 1273 if (scsicmd[0] == WRITE_10 || scsicmd[0] == WRITE_6 ||
1294 scsicmd[0] == WRITE_16) 1274 scsicmd[0] == WRITE_16)
1295 tf->flags |= ATA_TFLAG_WRITE; 1275 tf_flags |= ATA_TFLAG_WRITE;
1296 1276
1297 /* Calculate the SCSI LBA, transfer length and FUA. */ 1277 /* Calculate the SCSI LBA, transfer length and FUA. */
1298 switch (scsicmd[0]) { 1278 switch (scsicmd[0]) {
@@ -1300,7 +1280,7 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm
1300 case WRITE_10: 1280 case WRITE_10:
1301 scsi_10_lba_len(scsicmd, &block, &n_block); 1281 scsi_10_lba_len(scsicmd, &block, &n_block);
1302 if (unlikely(scsicmd[1] & (1 << 3))) 1282 if (unlikely(scsicmd[1] & (1 << 3)))
1303 tf->flags |= ATA_TFLAG_FUA; 1283 tf_flags |= ATA_TFLAG_FUA;
1304 break; 1284 break;
1305 case READ_6: 1285 case READ_6:
1306 case WRITE_6: 1286 case WRITE_6:
@@ -1316,7 +1296,7 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm
1316 case WRITE_16: 1296 case WRITE_16:
1317 scsi_16_lba_len(scsicmd, &block, &n_block); 1297 scsi_16_lba_len(scsicmd, &block, &n_block);
1318 if (unlikely(scsicmd[1] & (1 << 3))) 1298 if (unlikely(scsicmd[1] & (1 << 3)))
1319 tf->flags |= ATA_TFLAG_FUA; 1299 tf_flags |= ATA_TFLAG_FUA;
1320 break; 1300 break;
1321 default: 1301 default:
1322 DPRINTK("no-byte command\n"); 1302 DPRINTK("no-byte command\n");
@@ -1334,106 +1314,17 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm
1334 */ 1314 */
1335 goto nothing_to_do; 1315 goto nothing_to_do;
1336 1316
1337 if ((dev->flags & (ATA_DFLAG_PIO | ATA_DFLAG_NCQ_OFF | 1317 qc->flags |= ATA_QCFLAG_IO;
1338 ATA_DFLAG_NCQ)) == ATA_DFLAG_NCQ) { 1318 qc->nsect = n_block;
1339 /* yay, NCQ */
1340 if (!lba_48_ok(block, n_block))
1341 goto out_of_range;
1342
1343 tf->protocol = ATA_PROT_NCQ;
1344 tf->flags |= ATA_TFLAG_LBA | ATA_TFLAG_LBA48;
1345
1346 if (tf->flags & ATA_TFLAG_WRITE)
1347 tf->command = ATA_CMD_FPDMA_WRITE;
1348 else
1349 tf->command = ATA_CMD_FPDMA_READ;
1350
1351 qc->nsect = n_block;
1352
1353 tf->nsect = qc->tag << 3;
1354 tf->hob_feature = (n_block >> 8) & 0xff;
1355 tf->feature = n_block & 0xff;
1356
1357 tf->hob_lbah = (block >> 40) & 0xff;
1358 tf->hob_lbam = (block >> 32) & 0xff;
1359 tf->hob_lbal = (block >> 24) & 0xff;
1360 tf->lbah = (block >> 16) & 0xff;
1361 tf->lbam = (block >> 8) & 0xff;
1362 tf->lbal = block & 0xff;
1363
1364 tf->device = 1 << 6;
1365 if (tf->flags & ATA_TFLAG_FUA)
1366 tf->device |= 1 << 7;
1367 } else if (dev->flags & ATA_DFLAG_LBA) {
1368 tf->flags |= ATA_TFLAG_LBA;
1369
1370 if (lba_28_ok(block, n_block)) {
1371 /* use LBA28 */
1372 tf->device |= (block >> 24) & 0xf;
1373 } else if (lba_48_ok(block, n_block)) {
1374 if (!(dev->flags & ATA_DFLAG_LBA48))
1375 goto out_of_range;
1376
1377 /* use LBA48 */
1378 tf->flags |= ATA_TFLAG_LBA48;
1379
1380 tf->hob_nsect = (n_block >> 8) & 0xff;
1381
1382 tf->hob_lbah = (block >> 40) & 0xff;
1383 tf->hob_lbam = (block >> 32) & 0xff;
1384 tf->hob_lbal = (block >> 24) & 0xff;
1385 } else
1386 /* request too large even for LBA48 */
1387 goto out_of_range;
1388
1389 if (unlikely(ata_rwcmd_protocol(qc) < 0))
1390 goto invalid_fld;
1391
1392 qc->nsect = n_block;
1393 tf->nsect = n_block & 0xff;
1394
1395 tf->lbah = (block >> 16) & 0xff;
1396 tf->lbam = (block >> 8) & 0xff;
1397 tf->lbal = block & 0xff;
1398
1399 tf->device |= ATA_LBA;
1400 } else {
1401 /* CHS */
1402 u32 sect, head, cyl, track;
1403
1404 /* The request -may- be too large for CHS addressing. */
1405 if (!lba_28_ok(block, n_block))
1406 goto out_of_range;
1407
1408 if (unlikely(ata_rwcmd_protocol(qc) < 0))
1409 goto invalid_fld;
1410
1411 /* Convert LBA to CHS */
1412 track = (u32)block / dev->sectors;
1413 cyl = track / dev->heads;
1414 head = track % dev->heads;
1415 sect = (u32)block % dev->sectors + 1;
1416
1417 DPRINTK("block %u track %u cyl %u head %u sect %u\n",
1418 (u32)block, track, cyl, head, sect);
1419
1420 /* Check whether the converted CHS can fit.
1421 Cylinder: 0-65535
1422 Head: 0-15
1423 Sector: 1-255*/
1424 if ((cyl >> 16) || (head >> 4) || (sect >> 8) || (!sect))
1425 goto out_of_range;
1426
1427 qc->nsect = n_block;
1428 tf->nsect = n_block & 0xff; /* Sector count 0 means 256 sectors */
1429 tf->lbal = sect;
1430 tf->lbam = cyl;
1431 tf->lbah = cyl >> 8;
1432 tf->device |= head;
1433 }
1434 1319
1435 return 0; 1320 rc = ata_build_rw_tf(&qc->tf, qc->dev, block, n_block, tf_flags,
1321 qc->tag);
1322 if (likely(rc == 0))
1323 return 0;
1436 1324
1325 if (rc == -ERANGE)
1326 goto out_of_range;
1327 /* treat all other errors as -EINVAL, fall through */
1437invalid_fld: 1328invalid_fld:
1438 ata_scsi_set_sense(qc->scsicmd, ILLEGAL_REQUEST, 0x24, 0x0); 1329 ata_scsi_set_sense(qc->scsicmd, ILLEGAL_REQUEST, 0x24, 0x0);
1439 /* "Invalid field in cbd" */ 1330 /* "Invalid field in cbd" */
@@ -1451,6 +1342,7 @@ nothing_to_do:
1451 1342
1452static void ata_scsi_qc_complete(struct ata_queued_cmd *qc) 1343static void ata_scsi_qc_complete(struct ata_queued_cmd *qc)
1453{ 1344{
1345 struct ata_port *ap = qc->ap;
1454 struct scsi_cmnd *cmd = qc->scsicmd; 1346 struct scsi_cmnd *cmd = qc->scsicmd;
1455 u8 *cdb = cmd->cmnd; 1347 u8 *cdb = cmd->cmnd;
1456 int need_sense = (qc->err_mask != 0); 1348 int need_sense = (qc->err_mask != 0);
@@ -1459,11 +1351,12 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc)
1459 * schedule EH_REVALIDATE operation to update the IDENTIFY DEVICE 1351 * schedule EH_REVALIDATE operation to update the IDENTIFY DEVICE
1460 * cache 1352 * cache
1461 */ 1353 */
1462 if (!need_sense && (qc->tf.command == ATA_CMD_SET_FEATURES) && 1354 if (ap->ops->error_handler &&
1355 !need_sense && (qc->tf.command == ATA_CMD_SET_FEATURES) &&
1463 ((qc->tf.feature == SETFEATURES_WC_ON) || 1356 ((qc->tf.feature == SETFEATURES_WC_ON) ||
1464 (qc->tf.feature == SETFEATURES_WC_OFF))) { 1357 (qc->tf.feature == SETFEATURES_WC_OFF))) {
1465 qc->ap->eh_info.action |= ATA_EH_REVALIDATE; 1358 ap->eh_info.action |= ATA_EH_REVALIDATE;
1466 ata_port_schedule_eh(qc->ap); 1359 ata_port_schedule_eh(ap);
1467 } 1360 }
1468 1361
1469 /* For ATA pass thru (SAT) commands, generate a sense block if 1362 /* For ATA pass thru (SAT) commands, generate a sense block if
@@ -1475,7 +1368,7 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc)
1475 */ 1368 */
1476 if (((cdb[0] == ATA_16) || (cdb[0] == ATA_12)) && 1369 if (((cdb[0] == ATA_16) || (cdb[0] == ATA_12)) &&
1477 ((cdb[2] & 0x20) || need_sense)) { 1370 ((cdb[2] & 0x20) || need_sense)) {
1478 ata_gen_ata_desc_sense(qc); 1371 ata_gen_passthru_sense(qc);
1479 } else { 1372 } else {
1480 if (!need_sense) { 1373 if (!need_sense) {
1481 cmd->result = SAM_STAT_GOOD; 1374 cmd->result = SAM_STAT_GOOD;
@@ -1486,12 +1379,12 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc)
1486 * good for smaller LBA (and maybe CHS?) 1379 * good for smaller LBA (and maybe CHS?)
1487 * devices. 1380 * devices.
1488 */ 1381 */
1489 ata_gen_fixed_sense(qc); 1382 ata_gen_ata_sense(qc);
1490 } 1383 }
1491 } 1384 }
1492 1385
1493 if (need_sense && !qc->ap->ops->error_handler) 1386 if (need_sense && !ap->ops->error_handler)
1494 ata_dump_status(qc->ap->id, &qc->result_tf); 1387 ata_dump_status(ap->id, &qc->result_tf);
1495 1388
1496 qc->scsidone(cmd); 1389 qc->scsidone(cmd);
1497 1390
@@ -1612,9 +1505,9 @@ early_finish:
1612 1505
1613err_did: 1506err_did:
1614 ata_qc_free(qc); 1507 ata_qc_free(qc);
1615err_mem:
1616 cmd->result = (DID_ERROR << 16); 1508 cmd->result = (DID_ERROR << 16);
1617 done(cmd); 1509 done(cmd);
1510err_mem:
1618 DPRINTK("EXIT - internal\n"); 1511 DPRINTK("EXIT - internal\n");
1619 return 0; 1512 return 0;
1620 1513
@@ -1713,6 +1606,22 @@ void ata_scsi_rbuf_fill(struct ata_scsi_args *args,
1713} 1606}
1714 1607
1715/** 1608/**
1609 * ATA_SCSI_RBUF_SET - helper to set values in SCSI response buffer
1610 * @idx: byte index into SCSI response buffer
1611 * @val: value to set
1612 *
1613 * To be used by SCSI command simulator functions. This macros
1614 * expects two local variables, u8 *rbuf and unsigned int buflen,
1615 * are in scope.
1616 *
1617 * LOCKING:
1618 * None.
1619 */
1620#define ATA_SCSI_RBUF_SET(idx, val) do { \
1621 if ((idx) < buflen) rbuf[(idx)] = (u8)(val); \
1622 } while (0)
1623
1624/**
1716 * ata_scsiop_inq_std - Simulate INQUIRY command 1625 * ata_scsiop_inq_std - Simulate INQUIRY command
1717 * @args: device IDENTIFY data / SCSI command of interest. 1626 * @args: device IDENTIFY data / SCSI command of interest.
1718 * @rbuf: Response buffer, to which simulated SCSI cmd output is sent. 1627 * @rbuf: Response buffer, to which simulated SCSI cmd output is sent.
@@ -2171,67 +2080,42 @@ saving_not_supp:
2171 * Simulate READ CAPACITY commands. 2080 * Simulate READ CAPACITY commands.
2172 * 2081 *
2173 * LOCKING: 2082 * LOCKING:
2174 * spin_lock_irqsave(host lock) 2083 * None.
2175 */ 2084 */
2176
2177unsigned int ata_scsiop_read_cap(struct ata_scsi_args *args, u8 *rbuf, 2085unsigned int ata_scsiop_read_cap(struct ata_scsi_args *args, u8 *rbuf,
2178 unsigned int buflen) 2086 unsigned int buflen)
2179{ 2087{
2180 u64 n_sectors; 2088 u64 last_lba = args->dev->n_sectors - 1; /* LBA of the last block */
2181 u32 tmp;
2182 2089
2183 VPRINTK("ENTER\n"); 2090 VPRINTK("ENTER\n");
2184 2091
2185 if (ata_id_has_lba(args->id)) {
2186 if (ata_id_has_lba48(args->id))
2187 n_sectors = ata_id_u64(args->id, 100);
2188 else
2189 n_sectors = ata_id_u32(args->id, 60);
2190 } else {
2191 /* CHS default translation */
2192 n_sectors = args->id[1] * args->id[3] * args->id[6];
2193
2194 if (ata_id_current_chs_valid(args->id))
2195 /* CHS current translation */
2196 n_sectors = ata_id_u32(args->id, 57);
2197 }
2198
2199 n_sectors--; /* ATA TotalUserSectors - 1 */
2200
2201 if (args->cmd->cmnd[0] == READ_CAPACITY) { 2092 if (args->cmd->cmnd[0] == READ_CAPACITY) {
2202 if( n_sectors >= 0xffffffffULL ) 2093 if (last_lba >= 0xffffffffULL)
2203 tmp = 0xffffffff ; /* Return max count on overflow */ 2094 last_lba = 0xffffffff;
2204 else
2205 tmp = n_sectors ;
2206 2095
2207 /* sector count, 32-bit */ 2096 /* sector count, 32-bit */
2208 rbuf[0] = tmp >> (8 * 3); 2097 ATA_SCSI_RBUF_SET(0, last_lba >> (8 * 3));
2209 rbuf[1] = tmp >> (8 * 2); 2098 ATA_SCSI_RBUF_SET(1, last_lba >> (8 * 2));
2210 rbuf[2] = tmp >> (8 * 1); 2099 ATA_SCSI_RBUF_SET(2, last_lba >> (8 * 1));
2211 rbuf[3] = tmp; 2100 ATA_SCSI_RBUF_SET(3, last_lba);
2212 2101
2213 /* sector size */ 2102 /* sector size */
2214 tmp = ATA_SECT_SIZE; 2103 ATA_SCSI_RBUF_SET(6, ATA_SECT_SIZE >> 8);
2215 rbuf[6] = tmp >> 8; 2104 ATA_SCSI_RBUF_SET(7, ATA_SECT_SIZE);
2216 rbuf[7] = tmp;
2217
2218 } else { 2105 } else {
2219 /* sector count, 64-bit */ 2106 /* sector count, 64-bit */
2220 tmp = n_sectors >> (8 * 4); 2107 ATA_SCSI_RBUF_SET(0, last_lba >> (8 * 7));
2221 rbuf[2] = tmp >> (8 * 3); 2108 ATA_SCSI_RBUF_SET(1, last_lba >> (8 * 6));
2222 rbuf[3] = tmp >> (8 * 2); 2109 ATA_SCSI_RBUF_SET(2, last_lba >> (8 * 5));
2223 rbuf[4] = tmp >> (8 * 1); 2110 ATA_SCSI_RBUF_SET(3, last_lba >> (8 * 4));
2224 rbuf[5] = tmp; 2111 ATA_SCSI_RBUF_SET(4, last_lba >> (8 * 3));
2225 tmp = n_sectors; 2112 ATA_SCSI_RBUF_SET(5, last_lba >> (8 * 2));
2226 rbuf[6] = tmp >> (8 * 3); 2113 ATA_SCSI_RBUF_SET(6, last_lba >> (8 * 1));
2227 rbuf[7] = tmp >> (8 * 2); 2114 ATA_SCSI_RBUF_SET(7, last_lba);
2228 rbuf[8] = tmp >> (8 * 1);
2229 rbuf[9] = tmp;
2230 2115
2231 /* sector size */ 2116 /* sector size */
2232 tmp = ATA_SECT_SIZE; 2117 ATA_SCSI_RBUF_SET(10, ATA_SECT_SIZE >> 8);
2233 rbuf[12] = tmp >> 8; 2118 ATA_SCSI_RBUF_SET(11, ATA_SECT_SIZE);
2234 rbuf[13] = tmp;
2235 } 2119 }
2236 2120
2237 return 0; 2121 return 0;
@@ -2317,7 +2201,7 @@ static void atapi_sense_complete(struct ata_queued_cmd *qc)
2317 * a sense descriptors, since that's only 2201 * a sense descriptors, since that's only
2318 * correct for ATA, not ATAPI 2202 * correct for ATA, not ATAPI
2319 */ 2203 */
2320 ata_gen_ata_desc_sense(qc); 2204 ata_gen_passthru_sense(qc);
2321 } 2205 }
2322 2206
2323 qc->scsidone(qc->scsicmd); 2207 qc->scsidone(qc->scsicmd);
@@ -2392,7 +2276,7 @@ static void atapi_qc_complete(struct ata_queued_cmd *qc)
2392 * sense descriptors, since that's only 2276 * sense descriptors, since that's only
2393 * correct for ATA, not ATAPI 2277 * correct for ATA, not ATAPI
2394 */ 2278 */
2395 ata_gen_ata_desc_sense(qc); 2279 ata_gen_passthru_sense(qc);
2396 } 2280 }
2397 2281
2398 /* SCSI EH automatically locks door if sdev->locked is 2282 /* SCSI EH automatically locks door if sdev->locked is
@@ -2425,7 +2309,7 @@ static void atapi_qc_complete(struct ata_queued_cmd *qc)
2425 * a sense descriptors, since that's only 2309 * a sense descriptors, since that's only
2426 * correct for ATA, not ATAPI 2310 * correct for ATA, not ATAPI
2427 */ 2311 */
2428 ata_gen_ata_desc_sense(qc); 2312 ata_gen_passthru_sense(qc);
2429 } else { 2313 } else {
2430 u8 *scsicmd = cmd->cmnd; 2314 u8 *scsicmd = cmd->cmnd;
2431 2315
@@ -3079,7 +2963,7 @@ static void ata_scsi_remove_dev(struct ata_device *dev)
3079 2963
3080/** 2964/**
3081 * ata_scsi_hotplug - SCSI part of hotplug 2965 * ata_scsi_hotplug - SCSI part of hotplug
3082 * @data: Pointer to ATA port to perform SCSI hotplug on 2966 * @work: Pointer to ATA port to perform SCSI hotplug on
3083 * 2967 *
3084 * Perform SCSI part of hotplug. It's executed from a separate 2968 * Perform SCSI part of hotplug. It's executed from a separate
3085 * workqueue after EH completes. This is necessary because SCSI 2969 * workqueue after EH completes. This is necessary because SCSI
@@ -3089,9 +2973,10 @@ static void ata_scsi_remove_dev(struct ata_device *dev)
3089 * LOCKING: 2973 * LOCKING:
3090 * Kernel thread context (may sleep). 2974 * Kernel thread context (may sleep).
3091 */ 2975 */
3092void ata_scsi_hotplug(void *data) 2976void ata_scsi_hotplug(struct work_struct *work)
3093{ 2977{
3094 struct ata_port *ap = data; 2978 struct ata_port *ap =
2979 container_of(work, struct ata_port, hotplug_task.work);
3095 int i; 2980 int i;
3096 2981
3097 if (ap->pflags & ATA_PFLAG_UNLOADING) { 2982 if (ap->pflags & ATA_PFLAG_UNLOADING) {
@@ -3180,17 +3065,19 @@ static int ata_scsi_user_scan(struct Scsi_Host *shost, unsigned int channel,
3180 rc = -EINVAL; 3065 rc = -EINVAL;
3181 } 3066 }
3182 3067
3183 if (rc == 0) 3068 if (rc == 0) {
3184 ata_port_schedule_eh(ap); 3069 ata_port_schedule_eh(ap);
3185 3070 spin_unlock_irqrestore(ap->lock, flags);
3186 spin_unlock_irqrestore(ap->lock, flags); 3071 ata_port_wait_eh(ap);
3072 } else
3073 spin_unlock_irqrestore(ap->lock, flags);
3187 3074
3188 return rc; 3075 return rc;
3189} 3076}
3190 3077
3191/** 3078/**
3192 * ata_scsi_dev_rescan - initiate scsi_rescan_device() 3079 * ata_scsi_dev_rescan - initiate scsi_rescan_device()
3193 * @data: Pointer to ATA port to perform scsi_rescan_device() 3080 * @work: Pointer to ATA port to perform scsi_rescan_device()
3194 * 3081 *
3195 * After ATA pass thru (SAT) commands are executed successfully, 3082 * After ATA pass thru (SAT) commands are executed successfully,
3196 * libata need to propagate the changes to SCSI layer. This 3083 * libata need to propagate the changes to SCSI layer. This
@@ -3200,18 +3087,31 @@ static int ata_scsi_user_scan(struct Scsi_Host *shost, unsigned int channel,
3200 * LOCKING: 3087 * LOCKING:
3201 * Kernel thread context (may sleep). 3088 * Kernel thread context (may sleep).
3202 */ 3089 */
3203void ata_scsi_dev_rescan(void *data) 3090void ata_scsi_dev_rescan(struct work_struct *work)
3204{ 3091{
3205 struct ata_port *ap = data; 3092 struct ata_port *ap =
3206 struct ata_device *dev; 3093 container_of(work, struct ata_port, scsi_rescan_task);
3094 unsigned long flags;
3207 unsigned int i; 3095 unsigned int i;
3208 3096
3097 spin_lock_irqsave(ap->lock, flags);
3098
3209 for (i = 0; i < ATA_MAX_DEVICES; i++) { 3099 for (i = 0; i < ATA_MAX_DEVICES; i++) {
3210 dev = &ap->device[i]; 3100 struct ata_device *dev = &ap->device[i];
3101 struct scsi_device *sdev = dev->sdev;
3102
3103 if (!ata_dev_enabled(dev) || !sdev)
3104 continue;
3105 if (scsi_device_get(sdev))
3106 continue;
3211 3107
3212 if (ata_dev_enabled(dev) && dev->sdev) 3108 spin_unlock_irqrestore(ap->lock, flags);
3213 scsi_rescan_device(&(dev->sdev->sdev_gendev)); 3109 scsi_rescan_device(&(sdev->sdev_gendev));
3110 scsi_device_put(sdev);
3111 spin_lock_irqsave(ap->lock, flags);
3214 } 3112 }
3113
3114 spin_unlock_irqrestore(ap->lock, flags);
3215} 3115}
3216 3116
3217/** 3117/**
@@ -3345,20 +3245,23 @@ EXPORT_SYMBOL_GPL(ata_sas_slave_configure);
3345 * @ap: ATA port to which the command is being sent 3245 * @ap: ATA port to which the command is being sent
3346 * 3246 *
3347 * RETURNS: 3247 * RETURNS:
3348 * Zero. 3248 * Return value from __ata_scsi_queuecmd() if @cmd can be queued,
3249 * 0 otherwise.
3349 */ 3250 */
3350 3251
3351int ata_sas_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *), 3252int ata_sas_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *),
3352 struct ata_port *ap) 3253 struct ata_port *ap)
3353{ 3254{
3255 int rc = 0;
3256
3354 ata_scsi_dump_cdb(ap, cmd); 3257 ata_scsi_dump_cdb(ap, cmd);
3355 3258
3356 if (likely(ata_scsi_dev_enabled(ap->device))) 3259 if (likely(ata_scsi_dev_enabled(ap->device)))
3357 __ata_scsi_queuecmd(cmd, done, ap->device); 3260 rc = __ata_scsi_queuecmd(cmd, done, ap->device);
3358 else { 3261 else {
3359 cmd->result = (DID_BAD_TARGET << 16); 3262 cmd->result = (DID_BAD_TARGET << 16);
3360 done(cmd); 3263 done(cmd);
3361 } 3264 }
3362 return 0; 3265 return rc;
3363} 3266}
3364EXPORT_SYMBOL_GPL(ata_sas_queuecmd); 3267EXPORT_SYMBOL_GPL(ata_sas_queuecmd);
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index 7645f2b30ccf..10ee22ae5c15 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -39,6 +39,35 @@
39#include "libata.h" 39#include "libata.h"
40 40
41/** 41/**
42 * ata_irq_on - Enable interrupts on a port.
43 * @ap: Port on which interrupts are enabled.
44 *
45 * Enable interrupts on a legacy IDE device using MMIO or PIO,
46 * wait for idle, clear any pending interrupts.
47 *
48 * LOCKING:
49 * Inherited from caller.
50 */
51u8 ata_irq_on(struct ata_port *ap)
52{
53 struct ata_ioports *ioaddr = &ap->ioaddr;
54 u8 tmp;
55
56 ap->ctl &= ~ATA_NIEN;
57 ap->last_ctl = ap->ctl;
58
59 if (ap->flags & ATA_FLAG_MMIO)
60 writeb(ap->ctl, (void __iomem *) ioaddr->ctl_addr);
61 else
62 outb(ap->ctl, ioaddr->ctl_addr);
63 tmp = ata_wait_idle(ap);
64
65 ap->ops->irq_clear(ap);
66
67 return tmp;
68}
69
70/**
42 * ata_tf_load_pio - send taskfile registers to host controller 71 * ata_tf_load_pio - send taskfile registers to host controller
43 * @ap: Port to which output is sent 72 * @ap: Port to which output is sent
44 * @tf: ATA taskfile register set 73 * @tf: ATA taskfile register set
@@ -671,6 +700,14 @@ void ata_bmdma_freeze(struct ata_port *ap)
671 writeb(ap->ctl, (void __iomem *)ioaddr->ctl_addr); 700 writeb(ap->ctl, (void __iomem *)ioaddr->ctl_addr);
672 else 701 else
673 outb(ap->ctl, ioaddr->ctl_addr); 702 outb(ap->ctl, ioaddr->ctl_addr);
703
704 /* Under certain circumstances, some controllers raise IRQ on
705 * ATA_NIEN manipulation. Also, many controllers fail to mask
706 * previously pending IRQ on ATA_NIEN assertion. Clear it.
707 */
708 ata_chk_status(ap);
709
710 ap->ops->irq_clear(ap);
674} 711}
675 712
676/** 713/**
@@ -714,7 +751,6 @@ void ata_bmdma_drive_eh(struct ata_port *ap, ata_prereset_fn_t prereset,
714 ata_reset_fn_t softreset, ata_reset_fn_t hardreset, 751 ata_reset_fn_t softreset, ata_reset_fn_t hardreset,
715 ata_postreset_fn_t postreset) 752 ata_postreset_fn_t postreset)
716{ 753{
717 struct ata_eh_context *ehc = &ap->eh_context;
718 struct ata_queued_cmd *qc; 754 struct ata_queued_cmd *qc;
719 unsigned long flags; 755 unsigned long flags;
720 int thaw = 0; 756 int thaw = 0;
@@ -732,9 +768,7 @@ void ata_bmdma_drive_eh(struct ata_port *ap, ata_prereset_fn_t prereset,
732 qc->tf.protocol == ATA_PROT_ATAPI_DMA)) { 768 qc->tf.protocol == ATA_PROT_ATAPI_DMA)) {
733 u8 host_stat; 769 u8 host_stat;
734 770
735 host_stat = ata_bmdma_status(ap); 771 host_stat = ap->ops->bmdma_status(ap);
736
737 ata_ehi_push_desc(&ehc->i, "BMDMA stat 0x%x", host_stat);
738 772
739 /* BMDMA controllers indicate host bus error by 773 /* BMDMA controllers indicate host bus error by
740 * setting DMA_ERR bit and timing out. As it wasn't 774 * setting DMA_ERR bit and timing out. As it wasn't
@@ -877,6 +911,7 @@ static struct ata_probe_ent *ata_pci_init_legacy_port(struct pci_dev *pdev,
877 return NULL; 911 return NULL;
878 912
879 probe_ent->n_ports = 2; 913 probe_ent->n_ports = 2;
914 probe_ent->irq_flags = IRQF_SHARED;
880 915
881 if (port_mask & ATA_PORT_PRIMARY) { 916 if (port_mask & ATA_PORT_PRIMARY) {
882 probe_ent->irq = ATA_PRIMARY_IRQ; 917 probe_ent->irq = ATA_PRIMARY_IRQ;
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
index 0ed263be652a..81ae41d5f23f 100644
--- a/drivers/ata/libata.h
+++ b/drivers/ata/libata.h
@@ -39,26 +39,39 @@ struct ata_scsi_args {
39}; 39};
40 40
41/* libata-core.c */ 41/* libata-core.c */
42enum {
43 /* flags for ata_dev_read_id() */
44 ATA_READID_POSTRESET = (1 << 0), /* reading ID after reset */
45};
46
42extern struct workqueue_struct *ata_aux_wq; 47extern struct workqueue_struct *ata_aux_wq;
43extern int atapi_enabled; 48extern int atapi_enabled;
44extern int atapi_dmadir; 49extern int atapi_dmadir;
45extern int libata_fua; 50extern int libata_fua;
46extern struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev); 51extern struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev);
47extern int ata_rwcmd_protocol(struct ata_queued_cmd *qc); 52extern int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev,
53 u64 block, u32 n_block, unsigned int tf_flags,
54 unsigned int tag);
55extern u64 ata_tf_read_block(struct ata_taskfile *tf, struct ata_device *dev);
48extern void ata_dev_disable(struct ata_device *dev); 56extern void ata_dev_disable(struct ata_device *dev);
49extern void ata_port_flush_task(struct ata_port *ap); 57extern void ata_port_flush_task(struct ata_port *ap);
50extern unsigned ata_exec_internal(struct ata_device *dev, 58extern unsigned ata_exec_internal(struct ata_device *dev,
51 struct ata_taskfile *tf, const u8 *cdb, 59 struct ata_taskfile *tf, const u8 *cdb,
52 int dma_dir, void *buf, unsigned int buflen); 60 int dma_dir, void *buf, unsigned int buflen);
61extern unsigned ata_exec_internal_sg(struct ata_device *dev,
62 struct ata_taskfile *tf, const u8 *cdb,
63 int dma_dir, struct scatterlist *sg,
64 unsigned int n_elem);
53extern unsigned int ata_do_simple_cmd(struct ata_device *dev, u8 cmd); 65extern unsigned int ata_do_simple_cmd(struct ata_device *dev, u8 cmd);
54extern int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, 66extern int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
55 int post_reset, u16 *id); 67 unsigned int flags, u16 *id);
56extern int ata_dev_revalidate(struct ata_device *dev, int post_reset); 68extern int ata_dev_revalidate(struct ata_device *dev, unsigned int flags);
57extern int ata_dev_configure(struct ata_device *dev, int print_info); 69extern int ata_dev_configure(struct ata_device *dev);
58extern int sata_down_spd_limit(struct ata_port *ap); 70extern int sata_down_spd_limit(struct ata_port *ap);
59extern int sata_set_spd_needed(struct ata_port *ap); 71extern int sata_set_spd_needed(struct ata_port *ap);
60extern int ata_down_xfermask_limit(struct ata_device *dev, int force_pio0); 72extern int ata_down_xfermask_limit(struct ata_device *dev, int force_pio0);
61extern int ata_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev); 73extern int ata_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev);
74extern void ata_sg_clean(struct ata_queued_cmd *qc);
62extern void ata_qc_free(struct ata_queued_cmd *qc); 75extern void ata_qc_free(struct ata_queued_cmd *qc);
63extern void ata_qc_issue(struct ata_queued_cmd *qc); 76extern void ata_qc_issue(struct ata_queued_cmd *qc);
64extern void __ata_qc_complete(struct ata_queued_cmd *qc); 77extern void __ata_qc_complete(struct ata_queued_cmd *qc);
@@ -81,7 +94,7 @@ extern struct scsi_transport_template ata_scsi_transport_template;
81 94
82extern void ata_scsi_scan_host(struct ata_port *ap); 95extern void ata_scsi_scan_host(struct ata_port *ap);
83extern int ata_scsi_offline_dev(struct ata_device *dev); 96extern int ata_scsi_offline_dev(struct ata_device *dev);
84extern void ata_scsi_hotplug(void *data); 97extern void ata_scsi_hotplug(struct work_struct *work);
85extern unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf, 98extern unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf,
86 unsigned int buflen); 99 unsigned int buflen);
87 100
@@ -111,7 +124,7 @@ extern void ata_scsi_rbuf_fill(struct ata_scsi_args *args,
111 unsigned int (*actor) (struct ata_scsi_args *args, 124 unsigned int (*actor) (struct ata_scsi_args *args,
112 u8 *rbuf, unsigned int buflen)); 125 u8 *rbuf, unsigned int buflen));
113extern void ata_schedule_scsi_eh(struct Scsi_Host *shost); 126extern void ata_schedule_scsi_eh(struct Scsi_Host *shost);
114extern void ata_scsi_dev_rescan(void *data); 127extern void ata_scsi_dev_rescan(struct work_struct *work);
115extern int ata_bus_probe(struct ata_port *ap); 128extern int ata_bus_probe(struct ata_port *ap);
116 129
117/* libata-eh.c */ 130/* libata-eh.c */
@@ -120,4 +133,7 @@ extern void ata_scsi_error(struct Scsi_Host *host);
120extern void ata_port_wait_eh(struct ata_port *ap); 133extern void ata_port_wait_eh(struct ata_port *ap);
121extern void ata_qc_schedule_eh(struct ata_queued_cmd *qc); 134extern void ata_qc_schedule_eh(struct ata_queued_cmd *qc);
122 135
136/* libata-sff.c */
137extern u8 ata_irq_on(struct ata_port *ap);
138
123#endif /* __LIBATA_H__ */ 139#endif /* __LIBATA_H__ */
diff --git a/drivers/ata/pata_ali.c b/drivers/ata/pata_ali.c
index 1d695df5860a..c5d61d1911a5 100644
--- a/drivers/ata/pata_ali.c
+++ b/drivers/ata/pata_ali.c
@@ -34,7 +34,7 @@
34#include <linux/dmi.h> 34#include <linux/dmi.h>
35 35
36#define DRV_NAME "pata_ali" 36#define DRV_NAME "pata_ali"
37#define DRV_VERSION "0.6.6" 37#define DRV_VERSION "0.7.2"
38 38
39/* 39/*
40 * Cable special cases 40 * Cable special cases
@@ -78,7 +78,7 @@ static int ali_c2_cable_detect(struct ata_port *ap)
78 implement the detect logic */ 78 implement the detect logic */
79 79
80 if (ali_cable_override(pdev)) 80 if (ali_cable_override(pdev))
81 return ATA_CBL_PATA80; 81 return ATA_CBL_PATA40_SHORT;
82 82
83 /* Host view cable detect 0x4A bit 0 primary bit 1 secondary 83 /* Host view cable detect 0x4A bit 0 primary bit 1 secondary
84 Bit set for 40 pin */ 84 Bit set for 40 pin */
@@ -337,16 +337,16 @@ static struct scsi_host_template ali_sht = {
337 .can_queue = ATA_DEF_QUEUE, 337 .can_queue = ATA_DEF_QUEUE,
338 .this_id = ATA_SHT_THIS_ID, 338 .this_id = ATA_SHT_THIS_ID,
339 .sg_tablesize = LIBATA_MAX_PRD, 339 .sg_tablesize = LIBATA_MAX_PRD,
340 /* Keep LBA28 counts so large I/O's don't turn LBA48 and PIO
341 with older controllers. Not locked so will grow on C5 or later */
342 .max_sectors = 255,
343 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 340 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
344 .emulated = ATA_SHT_EMULATED, 341 .emulated = ATA_SHT_EMULATED,
345 .use_clustering = ATA_SHT_USE_CLUSTERING, 342 .use_clustering = ATA_SHT_USE_CLUSTERING,
346 .proc_name = DRV_NAME, 343 .proc_name = DRV_NAME,
347 .dma_boundary = ATA_DMA_BOUNDARY, 344 .dma_boundary = ATA_DMA_BOUNDARY,
348 .slave_configure = ata_scsi_slave_config, 345 .slave_configure = ata_scsi_slave_config,
346 .slave_destroy = ata_scsi_slave_destroy,
349 .bios_param = ata_std_bios_param, 347 .bios_param = ata_std_bios_param,
348 .resume = ata_scsi_device_resume,
349 .suspend = ata_scsi_device_suspend,
350}; 350};
351 351
352/* 352/*
@@ -496,6 +496,69 @@ static struct ata_port_operations ali_c5_port_ops = {
496 .host_stop = ata_host_stop 496 .host_stop = ata_host_stop
497}; 497};
498 498
499
500/**
501 * ali_init_chipset - chip setup function
502 * @pdev: PCI device of ATA controller
503 *
504 * Perform the setup on the device that must be done both at boot
505 * and at resume time.
506 */
507
508static void ali_init_chipset(struct pci_dev *pdev)
509{
510 u8 rev, tmp;
511 struct pci_dev *north, *isa_bridge;
512
513 pci_read_config_byte(pdev, PCI_REVISION_ID, &rev);
514
515 /*
516 * The chipset revision selects the driver operations and
517 * mode data.
518 */
519
520 if (rev >= 0x20 && rev < 0xC2) {
521 /* 1543-E/F, 1543C-C, 1543C-D, 1543C-E */
522 pci_read_config_byte(pdev, 0x4B, &tmp);
523 /* Clear CD-ROM DMA write bit */
524 tmp &= 0x7F;
525 pci_write_config_byte(pdev, 0x4B, tmp);
526 } else if (rev >= 0xC2) {
527 /* Enable cable detection logic */
528 pci_read_config_byte(pdev, 0x4B, &tmp);
529 pci_write_config_byte(pdev, 0x4B, tmp | 0x08);
530 }
531 north = pci_get_bus_and_slot(0, PCI_DEVFN(0,0));
532 isa_bridge = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, NULL);
533
534 if (north && north->vendor == PCI_VENDOR_ID_AL && isa_bridge) {
535 /* Configure the ALi bridge logic. For non ALi rely on BIOS.
536 Set the south bridge enable bit */
537 pci_read_config_byte(isa_bridge, 0x79, &tmp);
538 if (rev == 0xC2)
539 pci_write_config_byte(isa_bridge, 0x79, tmp | 0x04);
540 else if (rev > 0xC2 && rev < 0xC5)
541 pci_write_config_byte(isa_bridge, 0x79, tmp | 0x02);
542 }
543 if (rev >= 0x20) {
544 /*
545 * CD_ROM DMA on (0x53 bit 0). Enable this even if we want
546 * to use PIO. 0x53 bit 1 (rev 20 only) - enable FIFO control
547 * via 0x54/55.
548 */
549 pci_read_config_byte(pdev, 0x53, &tmp);
550 if (rev <= 0x20)
551 tmp &= ~0x02;
552 if (rev >= 0xc7)
553 tmp |= 0x03;
554 else
555 tmp |= 0x01; /* CD_ROM enable for DMA */
556 pci_write_config_byte(pdev, 0x53, tmp);
557 }
558 pci_dev_put(isa_bridge);
559 pci_dev_put(north);
560 ata_pci_clear_simplex(pdev);
561}
499/** 562/**
500 * ali_init_one - discovery callback 563 * ali_init_one - discovery callback
501 * @pdev: PCI device ID 564 * @pdev: PCI device ID
@@ -569,7 +632,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
569 632
570 static struct ata_port_info *port_info[2]; 633 static struct ata_port_info *port_info[2];
571 u8 rev, tmp; 634 u8 rev, tmp;
572 struct pci_dev *north, *isa_bridge; 635 struct pci_dev *isa_bridge;
573 636
574 pci_read_config_byte(pdev, PCI_REVISION_ID, &rev); 637 pci_read_config_byte(pdev, PCI_REVISION_ID, &rev);
575 638
@@ -581,11 +644,6 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
581 if (rev < 0x20) { 644 if (rev < 0x20) {
582 port_info[0] = port_info[1] = &info_early; 645 port_info[0] = port_info[1] = &info_early;
583 } else if (rev < 0xC2) { 646 } else if (rev < 0xC2) {
584 /* 1543-E/F, 1543C-C, 1543C-D, 1543C-E */
585 pci_read_config_byte(pdev, 0x4B, &tmp);
586 /* Clear CD-ROM DMA write bit */
587 tmp &= 0x7F;
588 pci_write_config_byte(pdev, 0x4B, tmp);
589 port_info[0] = port_info[1] = &info_20; 647 port_info[0] = port_info[1] = &info_20;
590 } else if (rev == 0xC2) { 648 } else if (rev == 0xC2) {
591 port_info[0] = port_info[1] = &info_c2; 649 port_info[0] = port_info[1] = &info_c2;
@@ -596,54 +654,25 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
596 } else 654 } else
597 port_info[0] = port_info[1] = &info_c5; 655 port_info[0] = port_info[1] = &info_c5;
598 656
599 if (rev >= 0xC2) { 657 ali_init_chipset(pdev);
600 /* Enable cable detection logic */ 658
601 pci_read_config_byte(pdev, 0x4B, &tmp);
602 pci_write_config_byte(pdev, 0x4B, tmp | 0x08);
603 }
604
605 north = pci_get_slot(pdev->bus, PCI_DEVFN(0,0));
606 isa_bridge = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, NULL); 659 isa_bridge = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, NULL);
607 660 if (isa_bridge && rev >= 0x20 && rev < 0xC2) {
608 if (north && north->vendor == PCI_VENDOR_ID_AL) { 661 /* Are we paired with a UDMA capable chip */
609 /* Configure the ALi bridge logic. For non ALi rely on BIOS. 662 pci_read_config_byte(isa_bridge, 0x5E, &tmp);
610 Set the south bridge enable bit */ 663 if ((tmp & 0x1E) == 0x12)
611 pci_read_config_byte(isa_bridge, 0x79, &tmp); 664 port_info[0] = port_info[1] = &info_20_udma;
612 if (rev == 0xC2) 665 pci_dev_put(isa_bridge);
613 pci_write_config_byte(isa_bridge, 0x79, tmp | 0x04);
614 else if (rev > 0xC2)
615 pci_write_config_byte(isa_bridge, 0x79, tmp | 0x02);
616 }
617
618 if (rev >= 0x20) {
619 if (rev < 0xC2) {
620 /* Are we paired with a UDMA capable chip */
621 pci_read_config_byte(isa_bridge, 0x5E, &tmp);
622 if ((tmp & 0x1E) == 0x12)
623 port_info[0] = port_info[1] = &info_20_udma;
624 }
625 /*
626 * CD_ROM DMA on (0x53 bit 0). Enable this even if we want
627 * to use PIO. 0x53 bit 1 (rev 20 only) - enable FIFO control
628 * via 0x54/55.
629 */
630 pci_read_config_byte(pdev, 0x53, &tmp);
631 if (rev <= 0x20)
632 tmp &= ~0x02;
633 if (rev >= 0xc7)
634 tmp |= 0x03;
635 else
636 tmp |= 0x01; /* CD_ROM enable for DMA */
637 pci_write_config_byte(pdev, 0x53, tmp);
638 } 666 }
639
640 pci_dev_put(isa_bridge);
641 pci_dev_put(north);
642
643 ata_pci_clear_simplex(pdev);
644 return ata_pci_init_one(pdev, port_info, 2); 667 return ata_pci_init_one(pdev, port_info, 2);
645} 668}
646 669
670static int ali_reinit_one(struct pci_dev *pdev)
671{
672 ali_init_chipset(pdev);
673 return ata_pci_device_resume(pdev);
674}
675
647static const struct pci_device_id ali[] = { 676static const struct pci_device_id ali[] = {
648 { PCI_VDEVICE(AL, PCI_DEVICE_ID_AL_M5228), }, 677 { PCI_VDEVICE(AL, PCI_DEVICE_ID_AL_M5228), },
649 { PCI_VDEVICE(AL, PCI_DEVICE_ID_AL_M5229), }, 678 { PCI_VDEVICE(AL, PCI_DEVICE_ID_AL_M5229), },
@@ -655,7 +684,9 @@ static struct pci_driver ali_pci_driver = {
655 .name = DRV_NAME, 684 .name = DRV_NAME,
656 .id_table = ali, 685 .id_table = ali,
657 .probe = ali_init_one, 686 .probe = ali_init_one,
658 .remove = ata_pci_remove_one 687 .remove = ata_pci_remove_one,
688 .suspend = ata_pci_device_suspend,
689 .resume = ali_reinit_one,
659}; 690};
660 691
661static int __init ali_init(void) 692static int __init ali_init(void)
diff --git a/drivers/ata/pata_amd.c b/drivers/ata/pata_amd.c
index 5c47a9e0e0ca..a6b330089f22 100644
--- a/drivers/ata/pata_amd.c
+++ b/drivers/ata/pata_amd.c
@@ -25,7 +25,7 @@
25#include <linux/libata.h> 25#include <linux/libata.h>
26 26
27#define DRV_NAME "pata_amd" 27#define DRV_NAME "pata_amd"
28#define DRV_VERSION "0.2.4" 28#define DRV_VERSION "0.2.7"
29 29
30/** 30/**
31 * timing_setup - shared timing computation and load 31 * timing_setup - shared timing computation and load
@@ -326,14 +326,16 @@ static struct scsi_host_template amd_sht = {
326 .can_queue = ATA_DEF_QUEUE, 326 .can_queue = ATA_DEF_QUEUE,
327 .this_id = ATA_SHT_THIS_ID, 327 .this_id = ATA_SHT_THIS_ID,
328 .sg_tablesize = LIBATA_MAX_PRD, 328 .sg_tablesize = LIBATA_MAX_PRD,
329 .max_sectors = ATA_MAX_SECTORS,
330 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 329 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
331 .emulated = ATA_SHT_EMULATED, 330 .emulated = ATA_SHT_EMULATED,
332 .use_clustering = ATA_SHT_USE_CLUSTERING, 331 .use_clustering = ATA_SHT_USE_CLUSTERING,
333 .proc_name = DRV_NAME, 332 .proc_name = DRV_NAME,
334 .dma_boundary = ATA_DMA_BOUNDARY, 333 .dma_boundary = ATA_DMA_BOUNDARY,
335 .slave_configure = ata_scsi_slave_config, 334 .slave_configure = ata_scsi_slave_config,
335 .slave_destroy = ata_scsi_slave_destroy,
336 .bios_param = ata_std_bios_param, 336 .bios_param = ata_std_bios_param,
337 .resume = ata_scsi_device_resume,
338 .suspend = ata_scsi_device_suspend,
337}; 339};
338 340
339static struct ata_port_operations amd33_port_ops = { 341static struct ata_port_operations amd33_port_ops = {
@@ -661,6 +663,23 @@ static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
661 return ata_pci_init_one(pdev, port_info, 2); 663 return ata_pci_init_one(pdev, port_info, 2);
662} 664}
663 665
666static int amd_reinit_one(struct pci_dev *pdev)
667{
668 if (pdev->vendor == PCI_VENDOR_ID_AMD) {
669 u8 fifo;
670 pci_read_config_byte(pdev, 0x41, &fifo);
671 if (pdev->device == PCI_DEVICE_ID_AMD_VIPER_7411)
672 /* FIFO is broken */
673 pci_write_config_byte(pdev, 0x41, fifo & 0x0F);
674 else
675 pci_write_config_byte(pdev, 0x41, fifo | 0xF0);
676 if (pdev->device == PCI_DEVICE_ID_AMD_VIPER_7409 ||
677 pdev->device == PCI_DEVICE_ID_AMD_COBRA_7401)
678 ata_pci_clear_simplex(pdev);
679 }
680 return ata_pci_device_resume(pdev);
681}
682
664static const struct pci_device_id amd[] = { 683static const struct pci_device_id amd[] = {
665 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_COBRA_7401), 0 }, 684 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_COBRA_7401), 0 },
666 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_VIPER_7409), 1 }, 685 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_VIPER_7409), 1 },
@@ -688,7 +707,9 @@ static struct pci_driver amd_pci_driver = {
688 .name = DRV_NAME, 707 .name = DRV_NAME,
689 .id_table = amd, 708 .id_table = amd,
690 .probe = amd_init_one, 709 .probe = amd_init_one,
691 .remove = ata_pci_remove_one 710 .remove = ata_pci_remove_one,
711 .suspend = ata_pci_device_suspend,
712 .resume = amd_reinit_one,
692}; 713};
693 714
694static int __init amd_init(void) 715static int __init amd_init(void)
diff --git a/drivers/ata/pata_artop.c b/drivers/ata/pata_artop.c
index 690828eb5226..37bc1323bda7 100644
--- a/drivers/ata/pata_artop.c
+++ b/drivers/ata/pata_artop.c
@@ -92,7 +92,7 @@ static int artop6260_pre_reset(struct ata_port *ap)
92 return -ENOENT; 92 return -ENOENT;
93 93
94 pci_read_config_byte(pdev, 0x49, &tmp); 94 pci_read_config_byte(pdev, 0x49, &tmp);
95 if (tmp & (1 >> ap->port_no)) 95 if (tmp & (1 << ap->port_no))
96 ap->cbl = ATA_CBL_PATA40; 96 ap->cbl = ATA_CBL_PATA40;
97 else 97 else
98 ap->cbl = ATA_CBL_PATA80; 98 ap->cbl = ATA_CBL_PATA80;
@@ -307,13 +307,13 @@ static struct scsi_host_template artop_sht = {
307 .can_queue = ATA_DEF_QUEUE, 307 .can_queue = ATA_DEF_QUEUE,
308 .this_id = ATA_SHT_THIS_ID, 308 .this_id = ATA_SHT_THIS_ID,
309 .sg_tablesize = LIBATA_MAX_PRD, 309 .sg_tablesize = LIBATA_MAX_PRD,
310 .max_sectors = ATA_MAX_SECTORS,
311 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 310 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
312 .emulated = ATA_SHT_EMULATED, 311 .emulated = ATA_SHT_EMULATED,
313 .use_clustering = ATA_SHT_USE_CLUSTERING, 312 .use_clustering = ATA_SHT_USE_CLUSTERING,
314 .proc_name = DRV_NAME, 313 .proc_name = DRV_NAME,
315 .dma_boundary = ATA_DMA_BOUNDARY, 314 .dma_boundary = ATA_DMA_BOUNDARY,
316 .slave_configure = ata_scsi_slave_config, 315 .slave_configure = ata_scsi_slave_config,
316 .slave_destroy = ata_scsi_slave_destroy,
317 .bios_param = ata_std_bios_param, 317 .bios_param = ata_std_bios_param,
318}; 318};
319 319
diff --git a/drivers/ata/pata_atiixp.c b/drivers/ata/pata_atiixp.c
index 1ce28d2125f4..6f6672c55131 100644
--- a/drivers/ata/pata_atiixp.c
+++ b/drivers/ata/pata_atiixp.c
@@ -22,7 +22,7 @@
22#include <linux/libata.h> 22#include <linux/libata.h>
23 23
24#define DRV_NAME "pata_atiixp" 24#define DRV_NAME "pata_atiixp"
25#define DRV_VERSION "0.4.3" 25#define DRV_VERSION "0.4.4"
26 26
27enum { 27enum {
28 ATIIXP_IDE_PIO_TIMING = 0x40, 28 ATIIXP_IDE_PIO_TIMING = 0x40,
@@ -209,14 +209,16 @@ static struct scsi_host_template atiixp_sht = {
209 .can_queue = ATA_DEF_QUEUE, 209 .can_queue = ATA_DEF_QUEUE,
210 .this_id = ATA_SHT_THIS_ID, 210 .this_id = ATA_SHT_THIS_ID,
211 .sg_tablesize = LIBATA_MAX_PRD, 211 .sg_tablesize = LIBATA_MAX_PRD,
212 .max_sectors = ATA_MAX_SECTORS,
213 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 212 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
214 .emulated = ATA_SHT_EMULATED, 213 .emulated = ATA_SHT_EMULATED,
215 .use_clustering = ATA_SHT_USE_CLUSTERING, 214 .use_clustering = ATA_SHT_USE_CLUSTERING,
216 .proc_name = DRV_NAME, 215 .proc_name = DRV_NAME,
217 .dma_boundary = ATA_DMA_BOUNDARY, 216 .dma_boundary = ATA_DMA_BOUNDARY,
218 .slave_configure = ata_scsi_slave_config, 217 .slave_configure = ata_scsi_slave_config,
218 .slave_destroy = ata_scsi_slave_destroy,
219 .bios_param = ata_std_bios_param, 219 .bios_param = ata_std_bios_param,
220 .resume = ata_scsi_device_resume,
221 .suspend = ata_scsi_device_suspend,
220}; 222};
221 223
222static struct ata_port_operations atiixp_port_ops = { 224static struct ata_port_operations atiixp_port_ops = {
@@ -280,7 +282,9 @@ static struct pci_driver atiixp_pci_driver = {
280 .name = DRV_NAME, 282 .name = DRV_NAME,
281 .id_table = atiixp, 283 .id_table = atiixp,
282 .probe = atiixp_init_one, 284 .probe = atiixp_init_one,
283 .remove = ata_pci_remove_one 285 .remove = ata_pci_remove_one,
286 .resume = ata_pci_device_resume,
287 .suspend = ata_pci_device_suspend,
284}; 288};
285 289
286static int __init atiixp_init(void) 290static int __init atiixp_init(void)
diff --git a/drivers/ata/pata_cmd64x.c b/drivers/ata/pata_cmd64x.c
index b9bbd1d454bf..15841a563694 100644
--- a/drivers/ata/pata_cmd64x.c
+++ b/drivers/ata/pata_cmd64x.c
@@ -31,7 +31,7 @@
31#include <linux/libata.h> 31#include <linux/libata.h>
32 32
33#define DRV_NAME "pata_cmd64x" 33#define DRV_NAME "pata_cmd64x"
34#define DRV_VERSION "0.2.1" 34#define DRV_VERSION "0.2.2"
35 35
36/* 36/*
37 * CMD64x specific registers definition. 37 * CMD64x specific registers definition.
@@ -268,14 +268,16 @@ static struct scsi_host_template cmd64x_sht = {
268 .can_queue = ATA_DEF_QUEUE, 268 .can_queue = ATA_DEF_QUEUE,
269 .this_id = ATA_SHT_THIS_ID, 269 .this_id = ATA_SHT_THIS_ID,
270 .sg_tablesize = LIBATA_MAX_PRD, 270 .sg_tablesize = LIBATA_MAX_PRD,
271 .max_sectors = ATA_MAX_SECTORS,
272 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 271 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
273 .emulated = ATA_SHT_EMULATED, 272 .emulated = ATA_SHT_EMULATED,
274 .use_clustering = ATA_SHT_USE_CLUSTERING, 273 .use_clustering = ATA_SHT_USE_CLUSTERING,
275 .proc_name = DRV_NAME, 274 .proc_name = DRV_NAME,
276 .dma_boundary = ATA_DMA_BOUNDARY, 275 .dma_boundary = ATA_DMA_BOUNDARY,
277 .slave_configure = ata_scsi_slave_config, 276 .slave_configure = ata_scsi_slave_config,
277 .slave_destroy = ata_scsi_slave_destroy,
278 .bios_param = ata_std_bios_param, 278 .bios_param = ata_std_bios_param,
279 .resume = ata_scsi_device_resume,
280 .suspend = ata_scsi_device_suspend,
279}; 281};
280 282
281static struct ata_port_operations cmd64x_port_ops = { 283static struct ata_port_operations cmd64x_port_ops = {
@@ -468,6 +470,20 @@ static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
468 return ata_pci_init_one(pdev, port_info, 2); 470 return ata_pci_init_one(pdev, port_info, 2);
469} 471}
470 472
473static int cmd64x_reinit_one(struct pci_dev *pdev)
474{
475 u8 mrdmode;
476 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 64);
477 pci_read_config_byte(pdev, MRDMODE, &mrdmode);
478 mrdmode &= ~ 0x30; /* IRQ set up */
479 mrdmode |= 0x02; /* Memory read line enable */
480 pci_write_config_byte(pdev, MRDMODE, mrdmode);
481#ifdef CONFIG_PPC
482 pci_write_config_byte(pdev, UDIDETCR0, 0xF0);
483#endif
484 return ata_pci_device_resume(pdev);
485}
486
471static const struct pci_device_id cmd64x[] = { 487static const struct pci_device_id cmd64x[] = {
472 { PCI_VDEVICE(CMD, PCI_DEVICE_ID_CMD_643), 0 }, 488 { PCI_VDEVICE(CMD, PCI_DEVICE_ID_CMD_643), 0 },
473 { PCI_VDEVICE(CMD, PCI_DEVICE_ID_CMD_646), 1 }, 489 { PCI_VDEVICE(CMD, PCI_DEVICE_ID_CMD_646), 1 },
@@ -481,7 +497,9 @@ static struct pci_driver cmd64x_pci_driver = {
481 .name = DRV_NAME, 497 .name = DRV_NAME,
482 .id_table = cmd64x, 498 .id_table = cmd64x,
483 .probe = cmd64x_init_one, 499 .probe = cmd64x_init_one,
484 .remove = ata_pci_remove_one 500 .remove = ata_pci_remove_one,
501 .suspend = ata_pci_device_suspend,
502 .resume = cmd64x_reinit_one,
485}; 503};
486 504
487static int __init cmd64x_init(void) 505static int __init cmd64x_init(void)
diff --git a/drivers/ata/pata_cs5520.c b/drivers/ata/pata_cs5520.c
index 2cd3c0ff76df..9f165a8e032d 100644
--- a/drivers/ata/pata_cs5520.c
+++ b/drivers/ata/pata_cs5520.c
@@ -41,7 +41,7 @@
41#include <linux/libata.h> 41#include <linux/libata.h>
42 42
43#define DRV_NAME "pata_cs5520" 43#define DRV_NAME "pata_cs5520"
44#define DRV_VERSION "0.6.2" 44#define DRV_VERSION "0.6.3"
45 45
46struct pio_clocks 46struct pio_clocks
47{ 47{
@@ -159,14 +159,16 @@ static struct scsi_host_template cs5520_sht = {
159 .can_queue = ATA_DEF_QUEUE, 159 .can_queue = ATA_DEF_QUEUE,
160 .this_id = ATA_SHT_THIS_ID, 160 .this_id = ATA_SHT_THIS_ID,
161 .sg_tablesize = LIBATA_MAX_PRD, 161 .sg_tablesize = LIBATA_MAX_PRD,
162 .max_sectors = ATA_MAX_SECTORS,
163 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 162 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
164 .emulated = ATA_SHT_EMULATED, 163 .emulated = ATA_SHT_EMULATED,
165 .use_clustering = ATA_SHT_USE_CLUSTERING, 164 .use_clustering = ATA_SHT_USE_CLUSTERING,
166 .proc_name = DRV_NAME, 165 .proc_name = DRV_NAME,
167 .dma_boundary = ATA_DMA_BOUNDARY, 166 .dma_boundary = ATA_DMA_BOUNDARY,
168 .slave_configure = ata_scsi_slave_config, 167 .slave_configure = ata_scsi_slave_config,
168 .slave_destroy = ata_scsi_slave_destroy,
169 .bios_param = ata_std_bios_param, 169 .bios_param = ata_std_bios_param,
170 .resume = ata_scsi_device_resume,
171 .suspend = ata_scsi_device_suspend,
170}; 172};
171 173
172static struct ata_port_operations cs5520_port_ops = { 174static struct ata_port_operations cs5520_port_ops = {
@@ -296,6 +298,22 @@ static void __devexit cs5520_remove_one(struct pci_dev *pdev)
296 dev_set_drvdata(dev, NULL); 298 dev_set_drvdata(dev, NULL);
297} 299}
298 300
301/**
302 * cs5520_reinit_one - device resume
303 * @pdev: PCI device
304 *
305 * Do any reconfiguration work needed by a resume from RAM. We need
306 * to restore DMA mode support on BIOSen which disabled it
307 */
308
309static int cs5520_reinit_one(struct pci_dev *pdev)
310{
311 u8 pcicfg;
312 pci_read_config_byte(pdev, 0x60, &pcicfg);
313 if ((pcicfg & 0x40) == 0)
314 pci_write_config_byte(pdev, 0x60, pcicfg | 0x40);
315 return ata_pci_device_resume(pdev);
316}
299/* For now keep DMA off. We can set it for all but A rev CS5510 once the 317/* For now keep DMA off. We can set it for all but A rev CS5510 once the
300 core ATA code can handle it */ 318 core ATA code can handle it */
301 319
@@ -310,7 +328,9 @@ static struct pci_driver cs5520_pci_driver = {
310 .name = DRV_NAME, 328 .name = DRV_NAME,
311 .id_table = pata_cs5520, 329 .id_table = pata_cs5520,
312 .probe = cs5520_init_one, 330 .probe = cs5520_init_one,
313 .remove = cs5520_remove_one 331 .remove = cs5520_remove_one,
332 .suspend = ata_pci_device_suspend,
333 .resume = cs5520_reinit_one,
314}; 334};
315 335
316static int __init cs5520_init(void) 336static int __init cs5520_init(void)
diff --git a/drivers/ata/pata_cs5530.c b/drivers/ata/pata_cs5530.c
index a07cc81ef791..1c628014dae6 100644
--- a/drivers/ata/pata_cs5530.c
+++ b/drivers/ata/pata_cs5530.c
@@ -35,7 +35,7 @@
35#include <linux/dmi.h> 35#include <linux/dmi.h>
36 36
37#define DRV_NAME "pata_cs5530" 37#define DRV_NAME "pata_cs5530"
38#define DRV_VERSION "0.6" 38#define DRV_VERSION "0.7.1"
39 39
40/** 40/**
41 * cs5530_set_piomode - PIO setup 41 * cs5530_set_piomode - PIO setup
@@ -173,14 +173,16 @@ static struct scsi_host_template cs5530_sht = {
173 .can_queue = ATA_DEF_QUEUE, 173 .can_queue = ATA_DEF_QUEUE,
174 .this_id = ATA_SHT_THIS_ID, 174 .this_id = ATA_SHT_THIS_ID,
175 .sg_tablesize = LIBATA_MAX_PRD, 175 .sg_tablesize = LIBATA_MAX_PRD,
176 .max_sectors = ATA_MAX_SECTORS,
177 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 176 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
178 .emulated = ATA_SHT_EMULATED, 177 .emulated = ATA_SHT_EMULATED,
179 .use_clustering = ATA_SHT_USE_CLUSTERING, 178 .use_clustering = ATA_SHT_USE_CLUSTERING,
180 .proc_name = DRV_NAME, 179 .proc_name = DRV_NAME,
181 .dma_boundary = ATA_DMA_BOUNDARY, 180 .dma_boundary = ATA_DMA_BOUNDARY,
182 .slave_configure = ata_scsi_slave_config, 181 .slave_configure = ata_scsi_slave_config,
182 .slave_destroy = ata_scsi_slave_destroy,
183 .bios_param = ata_std_bios_param, 183 .bios_param = ata_std_bios_param,
184 .resume = ata_scsi_device_resume,
185 .suspend = ata_scsi_device_suspend,
184}; 186};
185 187
186static struct ata_port_operations cs5530_port_ops = { 188static struct ata_port_operations cs5530_port_ops = {
@@ -238,38 +240,18 @@ static int cs5530_is_palmax(void)
238 return 0; 240 return 0;
239} 241}
240 242
243
241/** 244/**
242 * cs5530_init_one - Initialise a CS5530 245 * cs5530_init_chip - Chipset init
243 * @dev: PCI device
244 * @id: Entry in match table
245 * 246 *
246 * Install a driver for the newly found CS5530 companion chip. Most of 247 * Perform the chip initialisation work that is shared between both
247 * this is just housekeeping. We have to set the chip up correctly and 248 * setup and resume paths
248 * turn off various bits of emulation magic.
249 */ 249 */
250 250
251static int cs5530_init_one(struct pci_dev *dev, const struct pci_device_id *id) 251static int cs5530_init_chip(void)
252{ 252{
253 int compiler_warning_pointless_fix; 253 struct pci_dev *master_0 = NULL, *cs5530_0 = NULL, *dev = NULL;
254 struct pci_dev *master_0 = NULL, *cs5530_0 = NULL;
255 static struct ata_port_info info = {
256 .sht = &cs5530_sht,
257 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
258 .pio_mask = 0x1f,
259 .mwdma_mask = 0x07,
260 .udma_mask = 0x07,
261 .port_ops = &cs5530_port_ops
262 };
263 /* The docking connector doesn't do UDMA, and it seems not MWDMA */
264 static struct ata_port_info info_palmax_secondary = {
265 .sht = &cs5530_sht,
266 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
267 .pio_mask = 0x1f,
268 .port_ops = &cs5530_port_ops
269 };
270 static struct ata_port_info *port_info[2] = { &info, &info };
271 254
272 dev = NULL;
273 while ((dev = pci_get_device(PCI_VENDOR_ID_CYRIX, PCI_ANY_ID, dev)) != NULL) { 255 while ((dev = pci_get_device(PCI_VENDOR_ID_CYRIX, PCI_ANY_ID, dev)) != NULL) {
274 switch (dev->device) { 256 switch (dev->device) {
275 case PCI_DEVICE_ID_CYRIX_PCI_MASTER: 257 case PCI_DEVICE_ID_CYRIX_PCI_MASTER:
@@ -290,7 +272,7 @@ static int cs5530_init_one(struct pci_dev *dev, const struct pci_device_id *id)
290 } 272 }
291 273
292 pci_set_master(cs5530_0); 274 pci_set_master(cs5530_0);
293 compiler_warning_pointless_fix = pci_set_mwi(cs5530_0); 275 pci_set_mwi(cs5530_0);
294 276
295 /* 277 /*
296 * Set PCI CacheLineSize to 16-bytes: 278 * Set PCI CacheLineSize to 16-bytes:
@@ -338,13 +320,7 @@ static int cs5530_init_one(struct pci_dev *dev, const struct pci_device_id *id)
338 320
339 pci_dev_put(master_0); 321 pci_dev_put(master_0);
340 pci_dev_put(cs5530_0); 322 pci_dev_put(cs5530_0);
341 323 return 0;
342 if (cs5530_is_palmax())
343 port_info[1] = &info_palmax_secondary;
344
345 /* Now kick off ATA set up */
346 return ata_pci_init_one(dev, port_info, 2);
347
348fail_put: 324fail_put:
349 if (master_0) 325 if (master_0)
350 pci_dev_put(master_0); 326 pci_dev_put(master_0);
@@ -353,6 +329,53 @@ fail_put:
353 return -ENODEV; 329 return -ENODEV;
354} 330}
355 331
332/**
333 * cs5530_init_one - Initialise a CS5530
334 * @dev: PCI device
335 * @id: Entry in match table
336 *
337 * Install a driver for the newly found CS5530 companion chip. Most of
338 * this is just housekeeping. We have to set the chip up correctly and
339 * turn off various bits of emulation magic.
340 */
341
342static int cs5530_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
343{
344 static struct ata_port_info info = {
345 .sht = &cs5530_sht,
346 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
347 .pio_mask = 0x1f,
348 .mwdma_mask = 0x07,
349 .udma_mask = 0x07,
350 .port_ops = &cs5530_port_ops
351 };
352 /* The docking connector doesn't do UDMA, and it seems not MWDMA */
353 static struct ata_port_info info_palmax_secondary = {
354 .sht = &cs5530_sht,
355 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
356 .pio_mask = 0x1f,
357 .port_ops = &cs5530_port_ops
358 };
359 static struct ata_port_info *port_info[2] = { &info, &info };
360
361 /* Chip initialisation */
362 if (cs5530_init_chip())
363 return -ENODEV;
364
365 if (cs5530_is_palmax())
366 port_info[1] = &info_palmax_secondary;
367
368 /* Now kick off ATA set up */
369 return ata_pci_init_one(pdev, port_info, 2);
370}
371
372static int cs5530_reinit_one(struct pci_dev *pdev)
373{
374 /* If we fail on resume we are doomed */
375 BUG_ON(cs5530_init_chip());
376 return ata_pci_device_resume(pdev);
377}
378
356static const struct pci_device_id cs5530[] = { 379static const struct pci_device_id cs5530[] = {
357 { PCI_VDEVICE(CYRIX, PCI_DEVICE_ID_CYRIX_5530_IDE), }, 380 { PCI_VDEVICE(CYRIX, PCI_DEVICE_ID_CYRIX_5530_IDE), },
358 381
@@ -363,7 +386,9 @@ static struct pci_driver cs5530_pci_driver = {
363 .name = DRV_NAME, 386 .name = DRV_NAME,
364 .id_table = cs5530, 387 .id_table = cs5530,
365 .probe = cs5530_init_one, 388 .probe = cs5530_init_one,
366 .remove = ata_pci_remove_one 389 .remove = ata_pci_remove_one,
390 .suspend = ata_pci_device_suspend,
391 .resume = cs5530_reinit_one,
367}; 392};
368 393
369static int __init cs5530_init(void) 394static int __init cs5530_init(void)
diff --git a/drivers/ata/pata_cs5535.c b/drivers/ata/pata_cs5535.c
index f8def3f9c618..e3efec4ffc79 100644
--- a/drivers/ata/pata_cs5535.c
+++ b/drivers/ata/pata_cs5535.c
@@ -39,7 +39,7 @@
39#include <asm/msr.h> 39#include <asm/msr.h>
40 40
41#define DRV_NAME "cs5535" 41#define DRV_NAME "cs5535"
42#define DRV_VERSION "0.2.10" 42#define DRV_VERSION "0.2.11"
43 43
44/* 44/*
45 * The Geode (Aka Athlon GX now) uses an internal MSR based 45 * The Geode (Aka Athlon GX now) uses an internal MSR based
@@ -177,14 +177,16 @@ static struct scsi_host_template cs5535_sht = {
177 .can_queue = ATA_DEF_QUEUE, 177 .can_queue = ATA_DEF_QUEUE,
178 .this_id = ATA_SHT_THIS_ID, 178 .this_id = ATA_SHT_THIS_ID,
179 .sg_tablesize = LIBATA_MAX_PRD, 179 .sg_tablesize = LIBATA_MAX_PRD,
180 .max_sectors = ATA_MAX_SECTORS,
181 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 180 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
182 .emulated = ATA_SHT_EMULATED, 181 .emulated = ATA_SHT_EMULATED,
183 .use_clustering = ATA_SHT_USE_CLUSTERING, 182 .use_clustering = ATA_SHT_USE_CLUSTERING,
184 .proc_name = DRV_NAME, 183 .proc_name = DRV_NAME,
185 .dma_boundary = ATA_DMA_BOUNDARY, 184 .dma_boundary = ATA_DMA_BOUNDARY,
186 .slave_configure = ata_scsi_slave_config, 185 .slave_configure = ata_scsi_slave_config,
186 .slave_destroy = ata_scsi_slave_destroy,
187 .bios_param = ata_std_bios_param, 187 .bios_param = ata_std_bios_param,
188 .resume = ata_scsi_device_resume,
189 .suspend = ata_scsi_device_suspend,
188}; 190};
189 191
190static struct ata_port_operations cs5535_port_ops = { 192static struct ata_port_operations cs5535_port_ops = {
@@ -267,7 +269,9 @@ static struct pci_driver cs5535_pci_driver = {
267 .name = DRV_NAME, 269 .name = DRV_NAME,
268 .id_table = cs5535, 270 .id_table = cs5535,
269 .probe = cs5535_init_one, 271 .probe = cs5535_init_one,
270 .remove = ata_pci_remove_one 272 .remove = ata_pci_remove_one,
273 .suspend = ata_pci_device_suspend,
274 .resume = ata_pci_device_resume,
271}; 275};
272 276
273static int __init cs5535_init(void) 277static int __init cs5535_init(void)
diff --git a/drivers/ata/pata_cypress.c b/drivers/ata/pata_cypress.c
index 247b43608b14..e2a95699bae7 100644
--- a/drivers/ata/pata_cypress.c
+++ b/drivers/ata/pata_cypress.c
@@ -18,7 +18,7 @@
18#include <linux/libata.h> 18#include <linux/libata.h>
19 19
20#define DRV_NAME "pata_cypress" 20#define DRV_NAME "pata_cypress"
21#define DRV_VERSION "0.1.2" 21#define DRV_VERSION "0.1.4"
22 22
23/* here are the offset definitions for the registers */ 23/* here are the offset definitions for the registers */
24 24
@@ -128,14 +128,16 @@ static struct scsi_host_template cy82c693_sht = {
128 .can_queue = ATA_DEF_QUEUE, 128 .can_queue = ATA_DEF_QUEUE,
129 .this_id = ATA_SHT_THIS_ID, 129 .this_id = ATA_SHT_THIS_ID,
130 .sg_tablesize = LIBATA_MAX_PRD, 130 .sg_tablesize = LIBATA_MAX_PRD,
131 .max_sectors = ATA_MAX_SECTORS,
132 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 131 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
133 .emulated = ATA_SHT_EMULATED, 132 .emulated = ATA_SHT_EMULATED,
134 .use_clustering = ATA_SHT_USE_CLUSTERING, 133 .use_clustering = ATA_SHT_USE_CLUSTERING,
135 .proc_name = DRV_NAME, 134 .proc_name = DRV_NAME,
136 .dma_boundary = ATA_DMA_BOUNDARY, 135 .dma_boundary = ATA_DMA_BOUNDARY,
137 .slave_configure = ata_scsi_slave_config, 136 .slave_configure = ata_scsi_slave_config,
137 .slave_destroy = ata_scsi_slave_destroy,
138 .bios_param = ata_std_bios_param, 138 .bios_param = ata_std_bios_param,
139 .resume = ata_scsi_device_resume,
140 .suspend = ata_scsi_device_suspend,
139}; 141};
140 142
141static struct ata_port_operations cy82c693_port_ops = { 143static struct ata_port_operations cy82c693_port_ops = {
@@ -203,7 +205,9 @@ static struct pci_driver cy82c693_pci_driver = {
203 .name = DRV_NAME, 205 .name = DRV_NAME,
204 .id_table = cy82c693, 206 .id_table = cy82c693,
205 .probe = cy82c693_init_one, 207 .probe = cy82c693_init_one,
206 .remove = ata_pci_remove_one 208 .remove = ata_pci_remove_one,
209 .suspend = ata_pci_device_suspend,
210 .resume = ata_pci_device_resume,
207}; 211};
208 212
209static int __init cy82c693_init(void) 213static int __init cy82c693_init(void)
diff --git a/drivers/ata/pata_efar.c b/drivers/ata/pata_efar.c
index ef18c60fe140..edf8a63f50af 100644
--- a/drivers/ata/pata_efar.c
+++ b/drivers/ata/pata_efar.c
@@ -22,7 +22,7 @@
22#include <linux/ata.h> 22#include <linux/ata.h>
23 23
24#define DRV_NAME "pata_efar" 24#define DRV_NAME "pata_efar"
25#define DRV_VERSION "0.4.2" 25#define DRV_VERSION "0.4.3"
26 26
27/** 27/**
28 * efar_pre_reset - check for 40/80 pin 28 * efar_pre_reset - check for 40/80 pin
@@ -226,14 +226,16 @@ static struct scsi_host_template efar_sht = {
226 .can_queue = ATA_DEF_QUEUE, 226 .can_queue = ATA_DEF_QUEUE,
227 .this_id = ATA_SHT_THIS_ID, 227 .this_id = ATA_SHT_THIS_ID,
228 .sg_tablesize = LIBATA_MAX_PRD, 228 .sg_tablesize = LIBATA_MAX_PRD,
229 .max_sectors = ATA_MAX_SECTORS,
230 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 229 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
231 .emulated = ATA_SHT_EMULATED, 230 .emulated = ATA_SHT_EMULATED,
232 .use_clustering = ATA_SHT_USE_CLUSTERING, 231 .use_clustering = ATA_SHT_USE_CLUSTERING,
233 .proc_name = DRV_NAME, 232 .proc_name = DRV_NAME,
234 .dma_boundary = ATA_DMA_BOUNDARY, 233 .dma_boundary = ATA_DMA_BOUNDARY,
235 .slave_configure = ata_scsi_slave_config, 234 .slave_configure = ata_scsi_slave_config,
235 .slave_destroy = ata_scsi_slave_destroy,
236 .bios_param = ata_std_bios_param, 236 .bios_param = ata_std_bios_param,
237 .resume = ata_scsi_device_resume,
238 .suspend = ata_scsi_device_suspend,
237}; 239};
238 240
239static const struct ata_port_operations efar_ops = { 241static const struct ata_port_operations efar_ops = {
@@ -315,6 +317,8 @@ static struct pci_driver efar_pci_driver = {
315 .id_table = efar_pci_tbl, 317 .id_table = efar_pci_tbl,
316 .probe = efar_init_one, 318 .probe = efar_init_one,
317 .remove = ata_pci_remove_one, 319 .remove = ata_pci_remove_one,
320 .suspend = ata_pci_device_suspend,
321 .resume = ata_pci_device_resume,
318}; 322};
319 323
320static int __init efar_init(void) 324static int __init efar_init(void)
diff --git a/drivers/ata/pata_hpt366.c b/drivers/ata/pata_hpt366.c
index 6d3e4c0f15fe..2663599a7c02 100644
--- a/drivers/ata/pata_hpt366.c
+++ b/drivers/ata/pata_hpt366.c
@@ -27,7 +27,7 @@
27#include <linux/libata.h> 27#include <linux/libata.h>
28 28
29#define DRV_NAME "pata_hpt366" 29#define DRV_NAME "pata_hpt366"
30#define DRV_VERSION "0.5" 30#define DRV_VERSION "0.5.3"
31 31
32struct hpt_clock { 32struct hpt_clock {
33 u8 xfer_speed; 33 u8 xfer_speed;
@@ -222,9 +222,17 @@ static u32 hpt36x_find_mode(struct ata_port *ap, int speed)
222 222
223static int hpt36x_pre_reset(struct ata_port *ap) 223static int hpt36x_pre_reset(struct ata_port *ap)
224{ 224{
225 static const struct pci_bits hpt36x_enable_bits[] = {
226 { 0x50, 1, 0x04, 0x04 },
227 { 0x54, 1, 0x04, 0x04 }
228 };
229
225 u8 ata66; 230 u8 ata66;
226 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 231 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
227 232
233 if (!pci_test_config_bits(pdev, &hpt36x_enable_bits[ap->port_no]))
234 return -ENOENT;
235
228 pci_read_config_byte(pdev, 0x5A, &ata66); 236 pci_read_config_byte(pdev, 0x5A, &ata66);
229 if (ata66 & (1 << ap->port_no)) 237 if (ata66 & (1 << ap->port_no))
230 ap->cbl = ATA_CBL_PATA40; 238 ap->cbl = ATA_CBL_PATA40;
@@ -322,14 +330,16 @@ static struct scsi_host_template hpt36x_sht = {
322 .can_queue = ATA_DEF_QUEUE, 330 .can_queue = ATA_DEF_QUEUE,
323 .this_id = ATA_SHT_THIS_ID, 331 .this_id = ATA_SHT_THIS_ID,
324 .sg_tablesize = LIBATA_MAX_PRD, 332 .sg_tablesize = LIBATA_MAX_PRD,
325 .max_sectors = ATA_MAX_SECTORS,
326 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 333 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
327 .emulated = ATA_SHT_EMULATED, 334 .emulated = ATA_SHT_EMULATED,
328 .use_clustering = ATA_SHT_USE_CLUSTERING, 335 .use_clustering = ATA_SHT_USE_CLUSTERING,
329 .proc_name = DRV_NAME, 336 .proc_name = DRV_NAME,
330 .dma_boundary = ATA_DMA_BOUNDARY, 337 .dma_boundary = ATA_DMA_BOUNDARY,
331 .slave_configure = ata_scsi_slave_config, 338 .slave_configure = ata_scsi_slave_config,
339 .slave_destroy = ata_scsi_slave_destroy,
332 .bios_param = ata_std_bios_param, 340 .bios_param = ata_std_bios_param,
341 .resume = ata_scsi_device_resume,
342 .suspend = ata_scsi_device_suspend,
333}; 343};
334 344
335/* 345/*
@@ -372,6 +382,27 @@ static struct ata_port_operations hpt366_port_ops = {
372}; 382};
373 383
374/** 384/**
385 * hpt36x_init_chipset - common chip setup
386 * @dev: PCI device
387 *
388 * Perform the chip setup work that must be done at both init and
389 * resume time
390 */
391
392static void hpt36x_init_chipset(struct pci_dev *dev)
393{
394 u8 drive_fast;
395 pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, (L1_CACHE_BYTES / 4));
396 pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x78);
397 pci_write_config_byte(dev, PCI_MIN_GNT, 0x08);
398 pci_write_config_byte(dev, PCI_MAX_LAT, 0x08);
399
400 pci_read_config_byte(dev, 0x51, &drive_fast);
401 if (drive_fast & 0x80)
402 pci_write_config_byte(dev, 0x51, drive_fast & ~0x80);
403}
404
405/**
375 * hpt36x_init_one - Initialise an HPT366/368 406 * hpt36x_init_one - Initialise an HPT366/368
376 * @dev: PCI device 407 * @dev: PCI device
377 * @id: Entry in match table 408 * @id: Entry in match table
@@ -406,7 +437,6 @@ static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
406 437
407 u32 class_rev; 438 u32 class_rev;
408 u32 reg1; 439 u32 reg1;
409 u8 drive_fast;
410 440
411 pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev); 441 pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
412 class_rev &= 0xFF; 442 class_rev &= 0xFF;
@@ -416,14 +446,7 @@ static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
416 if (class_rev > 2) 446 if (class_rev > 2)
417 return -ENODEV; 447 return -ENODEV;
418 448
419 pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, (L1_CACHE_BYTES / 4)); 449 hpt36x_init_chipset(dev);
420 pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x78);
421 pci_write_config_byte(dev, PCI_MIN_GNT, 0x08);
422 pci_write_config_byte(dev, PCI_MAX_LAT, 0x08);
423
424 pci_read_config_byte(dev, 0x51, &drive_fast);
425 if (drive_fast & 0x80)
426 pci_write_config_byte(dev, 0x51, drive_fast & ~0x80);
427 450
428 pci_read_config_dword(dev, 0x40, &reg1); 451 pci_read_config_dword(dev, 0x40, &reg1);
429 452
@@ -444,9 +467,15 @@ static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
444 return ata_pci_init_one(dev, port_info, 2); 467 return ata_pci_init_one(dev, port_info, 2);
445} 468}
446 469
470static int hpt36x_reinit_one(struct pci_dev *dev)
471{
472 hpt36x_init_chipset(dev);
473 return ata_pci_device_resume(dev);
474}
475
476
447static const struct pci_device_id hpt36x[] = { 477static const struct pci_device_id hpt36x[] = {
448 { PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT366), }, 478 { PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT366), },
449
450 { }, 479 { },
451}; 480};
452 481
@@ -454,7 +483,9 @@ static struct pci_driver hpt36x_pci_driver = {
454 .name = DRV_NAME, 483 .name = DRV_NAME,
455 .id_table = hpt36x, 484 .id_table = hpt36x,
456 .probe = hpt36x_init_one, 485 .probe = hpt36x_init_one,
457 .remove = ata_pci_remove_one 486 .remove = ata_pci_remove_one,
487 .suspend = ata_pci_device_suspend,
488 .resume = hpt36x_reinit_one,
458}; 489};
459 490
460static int __init hpt36x_init(void) 491static int __init hpt36x_init(void)
@@ -462,13 +493,11 @@ static int __init hpt36x_init(void)
462 return pci_register_driver(&hpt36x_pci_driver); 493 return pci_register_driver(&hpt36x_pci_driver);
463} 494}
464 495
465
466static void __exit hpt36x_exit(void) 496static void __exit hpt36x_exit(void)
467{ 497{
468 pci_unregister_driver(&hpt36x_pci_driver); 498 pci_unregister_driver(&hpt36x_pci_driver);
469} 499}
470 500
471
472MODULE_AUTHOR("Alan Cox"); 501MODULE_AUTHOR("Alan Cox");
473MODULE_DESCRIPTION("low-level driver for the Highpoint HPT366/368"); 502MODULE_DESCRIPTION("low-level driver for the Highpoint HPT366/368");
474MODULE_LICENSE("GPL"); 503MODULE_LICENSE("GPL");
diff --git a/drivers/ata/pata_hpt37x.c b/drivers/ata/pata_hpt37x.c
index 7350443948c1..47082df7199e 100644
--- a/drivers/ata/pata_hpt37x.c
+++ b/drivers/ata/pata_hpt37x.c
@@ -25,7 +25,7 @@
25#include <linux/libata.h> 25#include <linux/libata.h>
26 26
27#define DRV_NAME "pata_hpt37x" 27#define DRV_NAME "pata_hpt37x"
28#define DRV_VERSION "0.5" 28#define DRV_VERSION "0.5.1"
29 29
30struct hpt_clock { 30struct hpt_clock {
31 u8 xfer_speed; 31 u8 xfer_speed;
@@ -453,7 +453,13 @@ static int hpt37x_pre_reset(struct ata_port *ap)
453{ 453{
454 u8 scr2, ata66; 454 u8 scr2, ata66;
455 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 455 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
456 456 static const struct pci_bits hpt37x_enable_bits[] = {
457 { 0x50, 1, 0x04, 0x04 },
458 { 0x54, 1, 0x04, 0x04 }
459 };
460 if (!pci_test_config_bits(pdev, &hpt37x_enable_bits[ap->port_no]))
461 return -ENOENT;
462
457 pci_read_config_byte(pdev, 0x5B, &scr2); 463 pci_read_config_byte(pdev, 0x5B, &scr2);
458 pci_write_config_byte(pdev, 0x5B, scr2 & ~0x01); 464 pci_write_config_byte(pdev, 0x5B, scr2 & ~0x01);
459 /* Cable register now active */ 465 /* Cable register now active */
@@ -488,10 +494,17 @@ static void hpt37x_error_handler(struct ata_port *ap)
488 494
489static int hpt374_pre_reset(struct ata_port *ap) 495static int hpt374_pre_reset(struct ata_port *ap)
490{ 496{
497 static const struct pci_bits hpt37x_enable_bits[] = {
498 { 0x50, 1, 0x04, 0x04 },
499 { 0x54, 1, 0x04, 0x04 }
500 };
491 u16 mcr3, mcr6; 501 u16 mcr3, mcr6;
492 u8 ata66; 502 u8 ata66;
493
494 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 503 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
504
505 if (!pci_test_config_bits(pdev, &hpt37x_enable_bits[ap->port_no]))
506 return -ENOENT;
507
495 /* Do the extra channel work */ 508 /* Do the extra channel work */
496 pci_read_config_word(pdev, 0x52, &mcr3); 509 pci_read_config_word(pdev, 0x52, &mcr3);
497 pci_read_config_word(pdev, 0x56, &mcr6); 510 pci_read_config_word(pdev, 0x56, &mcr6);
@@ -755,13 +768,13 @@ static struct scsi_host_template hpt37x_sht = {
755 .can_queue = ATA_DEF_QUEUE, 768 .can_queue = ATA_DEF_QUEUE,
756 .this_id = ATA_SHT_THIS_ID, 769 .this_id = ATA_SHT_THIS_ID,
757 .sg_tablesize = LIBATA_MAX_PRD, 770 .sg_tablesize = LIBATA_MAX_PRD,
758 .max_sectors = ATA_MAX_SECTORS,
759 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 771 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
760 .emulated = ATA_SHT_EMULATED, 772 .emulated = ATA_SHT_EMULATED,
761 .use_clustering = ATA_SHT_USE_CLUSTERING, 773 .use_clustering = ATA_SHT_USE_CLUSTERING,
762 .proc_name = DRV_NAME, 774 .proc_name = DRV_NAME,
763 .dma_boundary = ATA_DMA_BOUNDARY, 775 .dma_boundary = ATA_DMA_BOUNDARY,
764 .slave_configure = ata_scsi_slave_config, 776 .slave_configure = ata_scsi_slave_config,
777 .slave_destroy = ata_scsi_slave_destroy,
765 .bios_param = ata_std_bios_param, 778 .bios_param = ata_std_bios_param,
766}; 779};
767 780
diff --git a/drivers/ata/pata_hpt3x2n.c b/drivers/ata/pata_hpt3x2n.c
index 58cfb2bc8098..f6817b4093a4 100644
--- a/drivers/ata/pata_hpt3x2n.c
+++ b/drivers/ata/pata_hpt3x2n.c
@@ -334,13 +334,13 @@ static struct scsi_host_template hpt3x2n_sht = {
334 .can_queue = ATA_DEF_QUEUE, 334 .can_queue = ATA_DEF_QUEUE,
335 .this_id = ATA_SHT_THIS_ID, 335 .this_id = ATA_SHT_THIS_ID,
336 .sg_tablesize = LIBATA_MAX_PRD, 336 .sg_tablesize = LIBATA_MAX_PRD,
337 .max_sectors = ATA_MAX_SECTORS,
338 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 337 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
339 .emulated = ATA_SHT_EMULATED, 338 .emulated = ATA_SHT_EMULATED,
340 .use_clustering = ATA_SHT_USE_CLUSTERING, 339 .use_clustering = ATA_SHT_USE_CLUSTERING,
341 .proc_name = DRV_NAME, 340 .proc_name = DRV_NAME,
342 .dma_boundary = ATA_DMA_BOUNDARY, 341 .dma_boundary = ATA_DMA_BOUNDARY,
343 .slave_configure = ata_scsi_slave_config, 342 .slave_configure = ata_scsi_slave_config,
343 .slave_destroy = ata_scsi_slave_destroy,
344 .bios_param = ata_std_bios_param, 344 .bios_param = ata_std_bios_param,
345}; 345};
346 346
diff --git a/drivers/ata/pata_hpt3x3.c b/drivers/ata/pata_hpt3x3.c
index 3334d72e251b..5f1d385eb592 100644
--- a/drivers/ata/pata_hpt3x3.c
+++ b/drivers/ata/pata_hpt3x3.c
@@ -23,7 +23,7 @@
23#include <linux/libata.h> 23#include <linux/libata.h>
24 24
25#define DRV_NAME "pata_hpt3x3" 25#define DRV_NAME "pata_hpt3x3"
26#define DRV_VERSION "0.4.1" 26#define DRV_VERSION "0.4.2"
27 27
28static int hpt3x3_probe_init(struct ata_port *ap) 28static int hpt3x3_probe_init(struct ata_port *ap)
29{ 29{
@@ -111,14 +111,16 @@ static struct scsi_host_template hpt3x3_sht = {
111 .can_queue = ATA_DEF_QUEUE, 111 .can_queue = ATA_DEF_QUEUE,
112 .this_id = ATA_SHT_THIS_ID, 112 .this_id = ATA_SHT_THIS_ID,
113 .sg_tablesize = LIBATA_MAX_PRD, 113 .sg_tablesize = LIBATA_MAX_PRD,
114 .max_sectors = ATA_MAX_SECTORS,
115 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 114 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
116 .emulated = ATA_SHT_EMULATED, 115 .emulated = ATA_SHT_EMULATED,
117 .use_clustering = ATA_SHT_USE_CLUSTERING, 116 .use_clustering = ATA_SHT_USE_CLUSTERING,
118 .proc_name = DRV_NAME, 117 .proc_name = DRV_NAME,
119 .dma_boundary = ATA_DMA_BOUNDARY, 118 .dma_boundary = ATA_DMA_BOUNDARY,
120 .slave_configure = ata_scsi_slave_config, 119 .slave_configure = ata_scsi_slave_config,
120 .slave_destroy = ata_scsi_slave_destroy,
121 .bios_param = ata_std_bios_param, 121 .bios_param = ata_std_bios_param,
122 .resume = ata_scsi_device_resume,
123 .suspend = ata_scsi_device_suspend,
122}; 124};
123 125
124static struct ata_port_operations hpt3x3_port_ops = { 126static struct ata_port_operations hpt3x3_port_ops = {
@@ -157,6 +159,27 @@ static struct ata_port_operations hpt3x3_port_ops = {
157}; 159};
158 160
159/** 161/**
162 * hpt3x3_init_chipset - chip setup
163 * @dev: PCI device
164 *
165 * Perform the setup required at boot and on resume.
166 */
167
168static void hpt3x3_init_chipset(struct pci_dev *dev)
169{
170 u16 cmd;
171 /* Initialize the board */
172 pci_write_config_word(dev, 0x80, 0x00);
173 /* Check if it is a 343 or a 363. 363 has COMMAND_MEMORY set */
174 pci_read_config_word(dev, PCI_COMMAND, &cmd);
175 if (cmd & PCI_COMMAND_MEMORY)
176 pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0xF0);
177 else
178 pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x20);
179}
180
181
182/**
160 * hpt3x3_init_one - Initialise an HPT343/363 183 * hpt3x3_init_one - Initialise an HPT343/363
161 * @dev: PCI device 184 * @dev: PCI device
162 * @id: Entry in match table 185 * @id: Entry in match table
@@ -177,21 +200,18 @@ static int hpt3x3_init_one(struct pci_dev *dev, const struct pci_device_id *id)
177 .port_ops = &hpt3x3_port_ops 200 .port_ops = &hpt3x3_port_ops
178 }; 201 };
179 static struct ata_port_info *port_info[2] = { &info, &info }; 202 static struct ata_port_info *port_info[2] = { &info, &info };
180 u16 cmd;
181
182 /* Initialize the board */
183 pci_write_config_word(dev, 0x80, 0x00);
184 /* Check if it is a 343 or a 363. 363 has COMMAND_MEMORY set */
185 pci_read_config_word(dev, PCI_COMMAND, &cmd);
186 if (cmd & PCI_COMMAND_MEMORY)
187 pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0xF0);
188 else
189 pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x20);
190 203
204 hpt3x3_init_chipset(dev);
191 /* Now kick off ATA set up */ 205 /* Now kick off ATA set up */
192 return ata_pci_init_one(dev, port_info, 2); 206 return ata_pci_init_one(dev, port_info, 2);
193} 207}
194 208
209static int hpt3x3_reinit_one(struct pci_dev *dev)
210{
211 hpt3x3_init_chipset(dev);
212 return ata_pci_device_resume(dev);
213}
214
195static const struct pci_device_id hpt3x3[] = { 215static const struct pci_device_id hpt3x3[] = {
196 { PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT343), }, 216 { PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT343), },
197 217
@@ -202,7 +222,9 @@ static struct pci_driver hpt3x3_pci_driver = {
202 .name = DRV_NAME, 222 .name = DRV_NAME,
203 .id_table = hpt3x3, 223 .id_table = hpt3x3,
204 .probe = hpt3x3_init_one, 224 .probe = hpt3x3_init_one,
205 .remove = ata_pci_remove_one 225 .remove = ata_pci_remove_one,
226 .suspend = ata_pci_device_suspend,
227 .resume = hpt3x3_reinit_one,
206}; 228};
207 229
208static int __init hpt3x3_init(void) 230static int __init hpt3x3_init(void)
diff --git a/drivers/ata/pata_isapnp.c b/drivers/ata/pata_isapnp.c
index 640b8b0954f5..a97d55ae95c9 100644
--- a/drivers/ata/pata_isapnp.c
+++ b/drivers/ata/pata_isapnp.c
@@ -27,13 +27,13 @@ static struct scsi_host_template isapnp_sht = {
27 .can_queue = ATA_DEF_QUEUE, 27 .can_queue = ATA_DEF_QUEUE,
28 .this_id = ATA_SHT_THIS_ID, 28 .this_id = ATA_SHT_THIS_ID,
29 .sg_tablesize = LIBATA_MAX_PRD, 29 .sg_tablesize = LIBATA_MAX_PRD,
30 .max_sectors = ATA_MAX_SECTORS,
31 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 30 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
32 .emulated = ATA_SHT_EMULATED, 31 .emulated = ATA_SHT_EMULATED,
33 .use_clustering = ATA_SHT_USE_CLUSTERING, 32 .use_clustering = ATA_SHT_USE_CLUSTERING,
34 .proc_name = DRV_NAME, 33 .proc_name = DRV_NAME,
35 .dma_boundary = ATA_DMA_BOUNDARY, 34 .dma_boundary = ATA_DMA_BOUNDARY,
36 .slave_configure = ata_scsi_slave_config, 35 .slave_configure = ata_scsi_slave_config,
36 .slave_destroy = ata_scsi_slave_destroy,
37 .bios_param = ata_std_bios_param, 37 .bios_param = ata_std_bios_param,
38}; 38};
39 39
diff --git a/drivers/ata/pata_it821x.c b/drivers/ata/pata_it821x.c
index 18ff3e59a89b..0b56ff3d1cfe 100644
--- a/drivers/ata/pata_it821x.c
+++ b/drivers/ata/pata_it821x.c
@@ -80,7 +80,7 @@
80 80
81 81
82#define DRV_NAME "pata_it821x" 82#define DRV_NAME "pata_it821x"
83#define DRV_VERSION "0.3.2" 83#define DRV_VERSION "0.3.3"
84 84
85struct it821x_dev 85struct it821x_dev
86{ 86{
@@ -666,16 +666,16 @@ static struct scsi_host_template it821x_sht = {
666 .can_queue = ATA_DEF_QUEUE, 666 .can_queue = ATA_DEF_QUEUE,
667 .this_id = ATA_SHT_THIS_ID, 667 .this_id = ATA_SHT_THIS_ID,
668 .sg_tablesize = LIBATA_MAX_PRD, 668 .sg_tablesize = LIBATA_MAX_PRD,
669 /* 255 sectors to begin with. This is locked in smart mode but not
670 in pass through */
671 .max_sectors = 255,
672 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 669 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
673 .emulated = ATA_SHT_EMULATED, 670 .emulated = ATA_SHT_EMULATED,
674 .use_clustering = ATA_SHT_USE_CLUSTERING, 671 .use_clustering = ATA_SHT_USE_CLUSTERING,
675 .proc_name = DRV_NAME, 672 .proc_name = DRV_NAME,
676 .dma_boundary = ATA_DMA_BOUNDARY, 673 .dma_boundary = ATA_DMA_BOUNDARY,
677 .slave_configure = ata_scsi_slave_config, 674 .slave_configure = ata_scsi_slave_config,
675 .slave_destroy = ata_scsi_slave_destroy,
678 .bios_param = ata_std_bios_param, 676 .bios_param = ata_std_bios_param,
677 .resume = ata_scsi_device_resume,
678 .suspend = ata_scsi_device_suspend,
679}; 679};
680 680
681static struct ata_port_operations it821x_smart_port_ops = { 681static struct ata_port_operations it821x_smart_port_ops = {
@@ -808,6 +808,14 @@ static int it821x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
808 return ata_pci_init_one(pdev, port_info, 2); 808 return ata_pci_init_one(pdev, port_info, 2);
809} 809}
810 810
811static int it821x_reinit_one(struct pci_dev *pdev)
812{
813 /* Resume - turn raid back off if need be */
814 if (it8212_noraid)
815 it821x_disable_raid(pdev);
816 return ata_pci_device_resume(pdev);
817}
818
811static const struct pci_device_id it821x[] = { 819static const struct pci_device_id it821x[] = {
812 { PCI_VDEVICE(ITE, PCI_DEVICE_ID_ITE_8211), }, 820 { PCI_VDEVICE(ITE, PCI_DEVICE_ID_ITE_8211), },
813 { PCI_VDEVICE(ITE, PCI_DEVICE_ID_ITE_8212), }, 821 { PCI_VDEVICE(ITE, PCI_DEVICE_ID_ITE_8212), },
@@ -819,7 +827,9 @@ static struct pci_driver it821x_pci_driver = {
819 .name = DRV_NAME, 827 .name = DRV_NAME,
820 .id_table = it821x, 828 .id_table = it821x,
821 .probe = it821x_init_one, 829 .probe = it821x_init_one,
822 .remove = ata_pci_remove_one 830 .remove = ata_pci_remove_one,
831 .suspend = ata_pci_device_suspend,
832 .resume = it821x_reinit_one,
823}; 833};
824 834
825static int __init it821x_init(void) 835static int __init it821x_init(void)
diff --git a/drivers/ata/pata_ixp4xx_cf.c b/drivers/ata/pata_ixp4xx_cf.c
new file mode 100644
index 000000000000..cb8924109f59
--- /dev/null
+++ b/drivers/ata/pata_ixp4xx_cf.c
@@ -0,0 +1,271 @@
1/*
2 * ixp4xx PATA/Compact Flash driver
3 * Copyright (c) 2006 Tower Technologies
4 * Author: Alessandro Zummo <a.zummo@towertech.it>
5 *
6 * An ATA driver to handle a Compact Flash connected
7 * to the ixp4xx expansion bus in TrueIDE mode. The CF
8 * must have it chip selects connected to two CS lines
9 * on the ixp4xx. The interrupt line is optional, if not
10 * specified the driver will run in polling mode.
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
15 *
16 */
17
18#include <linux/kernel.h>
19#include <linux/module.h>
20#include <linux/libata.h>
21#include <linux/irq.h>
22#include <linux/platform_device.h>
23#include <scsi/scsi_host.h>
24
25#define DRV_NAME "pata_ixp4xx_cf"
26#define DRV_VERSION "0.1.1"
27
28static void ixp4xx_set_mode(struct ata_port *ap)
29{
30 int i;
31
32 for (i = 0; i < ATA_MAX_DEVICES; i++) {
33 struct ata_device *dev = &ap->device[i];
34 if (ata_dev_enabled(dev)) {
35 dev->pio_mode = XFER_PIO_0;
36 dev->xfer_mode = XFER_PIO_0;
37 dev->xfer_shift = ATA_SHIFT_PIO;
38 dev->flags |= ATA_DFLAG_PIO;
39 }
40 }
41}
42
43static void ixp4xx_phy_reset(struct ata_port *ap)
44{
45 ap->cbl = ATA_CBL_PATA40;
46 ata_port_probe(ap);
47 ata_bus_reset(ap);
48}
49
50static void ixp4xx_mmio_data_xfer(struct ata_device *adev, unsigned char *buf,
51 unsigned int buflen, int write_data)
52{
53 unsigned int i;
54 unsigned int words = buflen >> 1;
55 u16 *buf16 = (u16 *) buf;
56 struct ata_port *ap = adev->ap;
57 void __iomem *mmio = (void __iomem *)ap->ioaddr.data_addr;
58 struct ixp4xx_pata_data *data = ap->host->dev->platform_data;
59
60 /* set the expansion bus in 16bit mode and restore
61 * 8 bit mode after the transaction.
62 */
63 *data->cs0_cfg &= ~(0x01);
64 udelay(100);
65
66 /* Transfer multiple of 2 bytes */
67 if (write_data) {
68 for (i = 0; i < words; i++)
69 writew(buf16[i], mmio);
70 } else {
71 for (i = 0; i < words; i++)
72 buf16[i] = readw(mmio);
73 }
74
75 /* Transfer trailing 1 byte, if any. */
76 if (unlikely(buflen & 0x01)) {
77 u16 align_buf[1] = { 0 };
78 unsigned char *trailing_buf = buf + buflen - 1;
79
80 if (write_data) {
81 memcpy(align_buf, trailing_buf, 1);
82 writew(align_buf[0], mmio);
83 } else {
84 align_buf[0] = readw(mmio);
85 memcpy(trailing_buf, align_buf, 1);
86 }
87 }
88
89 udelay(100);
90 *data->cs0_cfg |= 0x01;
91}
92
93static void ixp4xx_irq_clear(struct ata_port *ap)
94{
95}
96
97static void ixp4xx_host_stop (struct ata_host *host)
98{
99 struct ixp4xx_pata_data *data = host->dev->platform_data;
100
101 iounmap(data->cs0);
102 iounmap(data->cs1);
103}
104
105static struct scsi_host_template ixp4xx_sht = {
106 .module = THIS_MODULE,
107 .name = DRV_NAME,
108 .ioctl = ata_scsi_ioctl,
109 .queuecommand = ata_scsi_queuecmd,
110 .can_queue = ATA_DEF_QUEUE,
111 .this_id = ATA_SHT_THIS_ID,
112 .sg_tablesize = LIBATA_MAX_PRD,
113 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
114 .emulated = ATA_SHT_EMULATED,
115 .use_clustering = ATA_SHT_USE_CLUSTERING,
116 .proc_name = DRV_NAME,
117 .dma_boundary = ATA_DMA_BOUNDARY,
118 .slave_configure = ata_scsi_slave_config,
119 .slave_destroy = ata_scsi_slave_destroy,
120 .bios_param = ata_std_bios_param,
121};
122
123static struct ata_port_operations ixp4xx_port_ops = {
124 .set_mode = ixp4xx_set_mode,
125 .mode_filter = ata_pci_default_filter,
126
127 .port_disable = ata_port_disable,
128 .tf_load = ata_tf_load,
129 .tf_read = ata_tf_read,
130 .check_status = ata_check_status,
131 .exec_command = ata_exec_command,
132 .dev_select = ata_std_dev_select,
133
134 .qc_prep = ata_qc_prep,
135 .qc_issue = ata_qc_issue_prot,
136 .eng_timeout = ata_eng_timeout,
137 .data_xfer = ixp4xx_mmio_data_xfer,
138
139 .irq_handler = ata_interrupt,
140 .irq_clear = ixp4xx_irq_clear,
141
142 .port_start = ata_port_start,
143 .port_stop = ata_port_stop,
144 .host_stop = ixp4xx_host_stop,
145
146 .phy_reset = ixp4xx_phy_reset,
147};
148
149static void ixp4xx_setup_port(struct ata_ioports *ioaddr,
150 struct ixp4xx_pata_data *data)
151{
152 ioaddr->cmd_addr = (unsigned long) data->cs0;
153 ioaddr->altstatus_addr = (unsigned long) data->cs1 + 0x06;
154 ioaddr->ctl_addr = (unsigned long) data->cs1 + 0x06;
155
156 ata_std_ports(ioaddr);
157
158#ifndef __ARMEB__
159
160 /* adjust the addresses to handle the address swizzling of the
161 * ixp4xx in little endian mode.
162 */
163
164 ioaddr->data_addr ^= 0x02;
165 ioaddr->cmd_addr ^= 0x03;
166 ioaddr->altstatus_addr ^= 0x03;
167 ioaddr->ctl_addr ^= 0x03;
168 ioaddr->error_addr ^= 0x03;
169 ioaddr->feature_addr ^= 0x03;
170 ioaddr->nsect_addr ^= 0x03;
171 ioaddr->lbal_addr ^= 0x03;
172 ioaddr->lbam_addr ^= 0x03;
173 ioaddr->lbah_addr ^= 0x03;
174 ioaddr->device_addr ^= 0x03;
175 ioaddr->status_addr ^= 0x03;
176 ioaddr->command_addr ^= 0x03;
177#endif
178}
179
180static __devinit int ixp4xx_pata_probe(struct platform_device *pdev)
181{
182 int ret;
183 unsigned int irq;
184 struct resource *cs0, *cs1;
185 struct ata_probe_ent ae;
186
187 struct ixp4xx_pata_data *data = pdev->dev.platform_data;
188
189 cs0 = platform_get_resource(pdev, IORESOURCE_MEM, 0);
190 cs1 = platform_get_resource(pdev, IORESOURCE_MEM, 1);
191
192 if (!cs0 || !cs1)
193 return -EINVAL;
194
195 pdev->dev.coherent_dma_mask = DMA_32BIT_MASK;
196
197 data->cs0 = ioremap(cs0->start, 0x1000);
198 data->cs1 = ioremap(cs1->start, 0x1000);
199
200 irq = platform_get_irq(pdev, 0);
201 if (irq)
202 set_irq_type(irq, IRQT_HIGH);
203
204 /* Setup expansion bus chip selects */
205 *data->cs0_cfg = data->cs0_bits;
206 *data->cs1_cfg = data->cs1_bits;
207
208 memset(&ae, 0, sizeof(struct ata_probe_ent));
209 INIT_LIST_HEAD(&ae.node);
210
211 ae.dev = &pdev->dev;
212 ae.port_ops = &ixp4xx_port_ops;
213 ae.sht = &ixp4xx_sht;
214 ae.n_ports = 1;
215 ae.pio_mask = 0x1f; /* PIO4 */
216 ae.irq = irq;
217 ae.irq_flags = 0;
218 ae.port_flags = ATA_FLAG_MMIO | ATA_FLAG_NO_LEGACY
219 | ATA_FLAG_NO_ATAPI | ATA_FLAG_SRST;
220
221 /* run in polling mode if no irq has been assigned */
222 if (!irq)
223 ae.port_flags |= ATA_FLAG_PIO_POLLING;
224
225 ixp4xx_setup_port(&ae.port[0], data);
226
227 dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n");
228
229 ret = ata_device_add(&ae);
230 if (ret == 0)
231 return -ENODEV;
232
233 return 0;
234}
235
236static __devexit int ixp4xx_pata_remove(struct platform_device *dev)
237{
238 struct ata_host *host = platform_get_drvdata(dev);
239
240 ata_host_remove(host);
241 platform_set_drvdata(dev, NULL);
242
243 return 0;
244}
245
246static struct platform_driver ixp4xx_pata_platform_driver = {
247 .driver = {
248 .name = DRV_NAME,
249 .owner = THIS_MODULE,
250 },
251 .probe = ixp4xx_pata_probe,
252 .remove = __devexit_p(ixp4xx_pata_remove),
253};
254
255static int __init ixp4xx_pata_init(void)
256{
257 return platform_driver_register(&ixp4xx_pata_platform_driver);
258}
259
260static void __exit ixp4xx_pata_exit(void)
261{
262 platform_driver_unregister(&ixp4xx_pata_platform_driver);
263}
264
265MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>");
266MODULE_DESCRIPTION("low-level driver for ixp4xx Compact Flash PATA");
267MODULE_LICENSE("GPL");
268MODULE_VERSION(DRV_VERSION);
269
270module_init(ixp4xx_pata_init);
271module_exit(ixp4xx_pata_exit);
diff --git a/drivers/ata/pata_jmicron.c b/drivers/ata/pata_jmicron.c
index 52a2bdf3c38d..2d661cb4df3c 100644
--- a/drivers/ata/pata_jmicron.c
+++ b/drivers/ata/pata_jmicron.c
@@ -19,7 +19,7 @@
19#include <linux/ata.h> 19#include <linux/ata.h>
20 20
21#define DRV_NAME "pata_jmicron" 21#define DRV_NAME "pata_jmicron"
22#define DRV_VERSION "0.1.2" 22#define DRV_VERSION "0.1.4"
23 23
24typedef enum { 24typedef enum {
25 PORT_PATA0 = 0, 25 PORT_PATA0 = 0,
@@ -128,14 +128,13 @@ static struct scsi_host_template jmicron_sht = {
128 .can_queue = ATA_DEF_QUEUE, 128 .can_queue = ATA_DEF_QUEUE,
129 .this_id = ATA_SHT_THIS_ID, 129 .this_id = ATA_SHT_THIS_ID,
130 .sg_tablesize = LIBATA_MAX_PRD, 130 .sg_tablesize = LIBATA_MAX_PRD,
131 /* Special handling needed if you have sector or LBA48 limits */
132 .max_sectors = ATA_MAX_SECTORS,
133 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 131 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
134 .emulated = ATA_SHT_EMULATED, 132 .emulated = ATA_SHT_EMULATED,
135 .use_clustering = ATA_SHT_USE_CLUSTERING, 133 .use_clustering = ATA_SHT_USE_CLUSTERING,
136 .proc_name = DRV_NAME, 134 .proc_name = DRV_NAME,
137 .dma_boundary = ATA_DMA_BOUNDARY, 135 .dma_boundary = ATA_DMA_BOUNDARY,
138 .slave_configure = ata_scsi_slave_config, 136 .slave_configure = ata_scsi_slave_config,
137 .slave_destroy = ata_scsi_slave_destroy,
139 /* Use standard CHS mapping rules */ 138 /* Use standard CHS mapping rules */
140 .bios_param = ata_std_bios_param, 139 .bios_param = ata_std_bios_param,
141}; 140};
@@ -212,12 +211,11 @@ static int jmicron_init_one (struct pci_dev *pdev, const struct pci_device_id *i
212 211
213 /* FIXME: We may want a way to override this in future */ 212 /* FIXME: We may want a way to override this in future */
214 pci_write_config_byte(pdev, 0x41, 0xa1); 213 pci_write_config_byte(pdev, 0x41, 0xa1);
215 }
216
217 /* PATA controller is fn 1, AHCI is fn 0 */
218 if (PCI_FUNC(pdev->devfn) != 1)
219 return -ENODEV;
220 214
215 /* PATA controller is fn 1, AHCI is fn 0 */
216 if (PCI_FUNC(pdev->devfn) != 1)
217 return -ENODEV;
218 }
221 if ( id->driver_data == 365 || id->driver_data == 366) { 219 if ( id->driver_data == 365 || id->driver_data == 366) {
222 /* The 365/66 have two PATA channels, redirect the second */ 220 /* The 365/66 have two PATA channels, redirect the second */
223 pci_read_config_dword(pdev, 0x80, &reg); 221 pci_read_config_dword(pdev, 0x80, &reg);
@@ -228,6 +226,27 @@ static int jmicron_init_one (struct pci_dev *pdev, const struct pci_device_id *i
228 return ata_pci_init_one(pdev, port_info, 2); 226 return ata_pci_init_one(pdev, port_info, 2);
229} 227}
230 228
229static int jmicron_reinit_one(struct pci_dev *pdev)
230{
231 u32 reg;
232
233 switch(pdev->device) {
234 case PCI_DEVICE_ID_JMICRON_JMB368:
235 break;
236 case PCI_DEVICE_ID_JMICRON_JMB365:
237 case PCI_DEVICE_ID_JMICRON_JMB366:
238 /* Restore mapping or disks swap and boy does it get ugly */
239 pci_read_config_dword(pdev, 0x80, &reg);
240 reg |= (1 << 24); /* IDE1 to PATA IDE secondary */
241 pci_write_config_dword(pdev, 0x80, reg);
242 /* Fall through */
243 default:
244 /* Make sure AHCI is turned back on */
245 pci_write_config_byte(pdev, 0x41, 0xa1);
246 }
247 return ata_pci_device_resume(pdev);
248}
249
231static const struct pci_device_id jmicron_pci_tbl[] = { 250static const struct pci_device_id jmicron_pci_tbl[] = {
232 { PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMB361), 361}, 251 { PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMB361), 361},
233 { PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMB363), 363}, 252 { PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMB363), 363},
@@ -243,6 +262,8 @@ static struct pci_driver jmicron_pci_driver = {
243 .id_table = jmicron_pci_tbl, 262 .id_table = jmicron_pci_tbl,
244 .probe = jmicron_init_one, 263 .probe = jmicron_init_one,
245 .remove = ata_pci_remove_one, 264 .remove = ata_pci_remove_one,
265 .suspend = ata_pci_device_suspend,
266 .resume = jmicron_reinit_one,
246}; 267};
247 268
248static int __init jmicron_init(void) 269static int __init jmicron_init(void)
diff --git a/drivers/ata/pata_legacy.c b/drivers/ata/pata_legacy.c
index 10231ef731d1..c7d1738e4e69 100644
--- a/drivers/ata/pata_legacy.c
+++ b/drivers/ata/pata_legacy.c
@@ -128,13 +128,13 @@ static struct scsi_host_template legacy_sht = {
128 .can_queue = ATA_DEF_QUEUE, 128 .can_queue = ATA_DEF_QUEUE,
129 .this_id = ATA_SHT_THIS_ID, 129 .this_id = ATA_SHT_THIS_ID,
130 .sg_tablesize = LIBATA_MAX_PRD, 130 .sg_tablesize = LIBATA_MAX_PRD,
131 .max_sectors = ATA_MAX_SECTORS,
132 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 131 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
133 .emulated = ATA_SHT_EMULATED, 132 .emulated = ATA_SHT_EMULATED,
134 .use_clustering = ATA_SHT_USE_CLUSTERING, 133 .use_clustering = ATA_SHT_USE_CLUSTERING,
135 .proc_name = DRV_NAME, 134 .proc_name = DRV_NAME,
136 .dma_boundary = ATA_DMA_BOUNDARY, 135 .dma_boundary = ATA_DMA_BOUNDARY,
137 .slave_configure = ata_scsi_slave_config, 136 .slave_configure = ata_scsi_slave_config,
137 .slave_destroy = ata_scsi_slave_destroy,
138 .bios_param = ata_std_bios_param, 138 .bios_param = ata_std_bios_param,
139}; 139};
140 140
diff --git a/drivers/ata/pata_marvell.c b/drivers/ata/pata_marvell.c
new file mode 100644
index 000000000000..1c810ea00253
--- /dev/null
+++ b/drivers/ata/pata_marvell.c
@@ -0,0 +1,224 @@
1/*
2 * Marvell PATA driver.
3 *
4 * For the moment we drive the PATA port in legacy mode. That
5 * isn't making full use of the device functionality but it is
6 * easy to get working.
7 *
8 * (c) 2006 Red Hat <alan@redhat.com>
9 */
10
11#include <linux/kernel.h>
12#include <linux/module.h>
13#include <linux/pci.h>
14#include <linux/init.h>
15#include <linux/blkdev.h>
16#include <linux/delay.h>
17#include <linux/device.h>
18#include <scsi/scsi_host.h>
19#include <linux/libata.h>
20#include <linux/ata.h>
21
22#define DRV_NAME "pata_marvell"
23#define DRV_VERSION "0.1.1"
24
25/**
26 * marvell_pre_reset - check for 40/80 pin
27 * @ap: Port
28 *
29 * Perform the PATA port setup we need.
30 */
31
32static int marvell_pre_reset(struct ata_port *ap)
33{
34 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
35 u32 devices;
36 void __iomem *barp;
37 int i;
38
39 /* Check if our port is enabled */
40
41 barp = pci_iomap(pdev, 5, 0x10);
42 if (barp == NULL)
43 return -ENOMEM;
44 printk("BAR5:");
45 for(i = 0; i <= 0x0F; i++)
46 printk("%02X:%02X ", i, readb(barp + i));
47 printk("\n");
48
49 devices = readl(barp + 0x0C);
50 pci_iounmap(pdev, barp);
51
52 if ((pdev->device == 0x6145) && (ap->port_no == 0) &&
53 (!(devices & 0x10))) /* PATA enable ? */
54 return -ENOENT;
55
56 /* Cable type */
57 switch(ap->port_no)
58 {
59 case 0:
60 if (inb(ap->ioaddr.bmdma_addr + 1) & 1)
61 ap->cbl = ATA_CBL_PATA40;
62 else
63 ap->cbl = ATA_CBL_PATA80;
64 break;
65
66 case 1: /* Legacy SATA port */
67 ap->cbl = ATA_CBL_SATA;
68 break;
69 }
70 return ata_std_prereset(ap);
71}
72
73/**
74 * marvell_error_handler - Setup and error handler
75 * @ap: Port to handle
76 *
77 * LOCKING:
78 * None (inherited from caller).
79 */
80
81static void marvell_error_handler(struct ata_port *ap)
82{
83 return ata_bmdma_drive_eh(ap, marvell_pre_reset, ata_std_softreset,
84 NULL, ata_std_postreset);
85}
86
87/* No PIO or DMA methods needed for this device */
88
89static struct scsi_host_template marvell_sht = {
90 .module = THIS_MODULE,
91 .name = DRV_NAME,
92 .ioctl = ata_scsi_ioctl,
93 .queuecommand = ata_scsi_queuecmd,
94 .can_queue = ATA_DEF_QUEUE,
95 .this_id = ATA_SHT_THIS_ID,
96 .sg_tablesize = LIBATA_MAX_PRD,
97 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
98 .emulated = ATA_SHT_EMULATED,
99 .use_clustering = ATA_SHT_USE_CLUSTERING,
100 .proc_name = DRV_NAME,
101 .dma_boundary = ATA_DMA_BOUNDARY,
102 .slave_configure = ata_scsi_slave_config,
103 .slave_destroy = ata_scsi_slave_destroy,
104 /* Use standard CHS mapping rules */
105 .bios_param = ata_std_bios_param,
106 .resume = ata_scsi_device_resume,
107 .suspend = ata_scsi_device_suspend,
108};
109
110static const struct ata_port_operations marvell_ops = {
111 .port_disable = ata_port_disable,
112
113 /* Task file is PCI ATA format, use helpers */
114 .tf_load = ata_tf_load,
115 .tf_read = ata_tf_read,
116 .check_status = ata_check_status,
117 .exec_command = ata_exec_command,
118 .dev_select = ata_std_dev_select,
119
120 .freeze = ata_bmdma_freeze,
121 .thaw = ata_bmdma_thaw,
122 .error_handler = marvell_error_handler,
123 .post_internal_cmd = ata_bmdma_post_internal_cmd,
124
125 /* BMDMA handling is PCI ATA format, use helpers */
126 .bmdma_setup = ata_bmdma_setup,
127 .bmdma_start = ata_bmdma_start,
128 .bmdma_stop = ata_bmdma_stop,
129 .bmdma_status = ata_bmdma_status,
130 .qc_prep = ata_qc_prep,
131 .qc_issue = ata_qc_issue_prot,
132 .data_xfer = ata_pio_data_xfer,
133
134 /* Timeout handling */
135 .irq_handler = ata_interrupt,
136 .irq_clear = ata_bmdma_irq_clear,
137
138 /* Generic PATA PCI ATA helpers */
139 .port_start = ata_port_start,
140 .port_stop = ata_port_stop,
141 .host_stop = ata_host_stop,
142};
143
144
145/**
146 * marvell_init_one - Register Marvell ATA PCI device with kernel services
147 * @pdev: PCI device to register
148 * @ent: Entry in marvell_pci_tbl matching with @pdev
149 *
150 * Called from kernel PCI layer.
151 *
152 * LOCKING:
153 * Inherited from PCI layer (may sleep).
154 *
155 * RETURNS:
156 * Zero on success, or -ERRNO value.
157 */
158
159static int marvell_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
160{
161 static struct ata_port_info info = {
162 .sht = &marvell_sht,
163 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
164
165 .pio_mask = 0x1f,
166 .mwdma_mask = 0x07,
167 .udma_mask = 0x3f,
168
169 .port_ops = &marvell_ops,
170 };
171 static struct ata_port_info info_sata = {
172 .sht = &marvell_sht,
173 /* Slave possible as its magically mapped not real */
174 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
175
176 .pio_mask = 0x1f,
177 .mwdma_mask = 0x07,
178 .udma_mask = 0x7f,
179
180 .port_ops = &marvell_ops,
181 };
182 struct ata_port_info *port_info[2] = { &info, &info_sata };
183 int n_port = 2;
184
185 if (pdev->device == 0x6101)
186 n_port = 1;
187
188 return ata_pci_init_one(pdev, port_info, n_port);
189}
190
191static const struct pci_device_id marvell_pci_tbl[] = {
192 { PCI_DEVICE(0x11AB, 0x6101), },
193 { PCI_DEVICE(0x11AB, 0x6145), },
194 { } /* terminate list */
195};
196
197static struct pci_driver marvell_pci_driver = {
198 .name = DRV_NAME,
199 .id_table = marvell_pci_tbl,
200 .probe = marvell_init_one,
201 .remove = ata_pci_remove_one,
202 .suspend = ata_pci_device_suspend,
203 .resume = ata_pci_device_resume,
204};
205
206static int __init marvell_init(void)
207{
208 return pci_register_driver(&marvell_pci_driver);
209}
210
211static void __exit marvell_exit(void)
212{
213 pci_unregister_driver(&marvell_pci_driver);
214}
215
216module_init(marvell_init);
217module_exit(marvell_exit);
218
219MODULE_AUTHOR("Alan Cox");
220MODULE_DESCRIPTION("SCSI low-level driver for Marvell ATA in legacy mode");
221MODULE_LICENSE("GPL");
222MODULE_DEVICE_TABLE(pci, marvell_pci_tbl);
223MODULE_VERSION(DRV_VERSION);
224
diff --git a/drivers/ata/pata_mpiix.c b/drivers/ata/pata_mpiix.c
index 9dfe3e9abea3..4ccca938675e 100644
--- a/drivers/ata/pata_mpiix.c
+++ b/drivers/ata/pata_mpiix.c
@@ -35,7 +35,7 @@
35#include <linux/libata.h> 35#include <linux/libata.h>
36 36
37#define DRV_NAME "pata_mpiix" 37#define DRV_NAME "pata_mpiix"
38#define DRV_VERSION "0.7.2" 38#define DRV_VERSION "0.7.3"
39 39
40enum { 40enum {
41 IDETIM = 0x6C, /* IDE control register */ 41 IDETIM = 0x6C, /* IDE control register */
@@ -159,14 +159,16 @@ static struct scsi_host_template mpiix_sht = {
159 .can_queue = ATA_DEF_QUEUE, 159 .can_queue = ATA_DEF_QUEUE,
160 .this_id = ATA_SHT_THIS_ID, 160 .this_id = ATA_SHT_THIS_ID,
161 .sg_tablesize = LIBATA_MAX_PRD, 161 .sg_tablesize = LIBATA_MAX_PRD,
162 .max_sectors = ATA_MAX_SECTORS,
163 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 162 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
164 .emulated = ATA_SHT_EMULATED, 163 .emulated = ATA_SHT_EMULATED,
165 .use_clustering = ATA_SHT_USE_CLUSTERING, 164 .use_clustering = ATA_SHT_USE_CLUSTERING,
166 .proc_name = DRV_NAME, 165 .proc_name = DRV_NAME,
167 .dma_boundary = ATA_DMA_BOUNDARY, 166 .dma_boundary = ATA_DMA_BOUNDARY,
168 .slave_configure = ata_scsi_slave_config, 167 .slave_configure = ata_scsi_slave_config,
168 .slave_destroy = ata_scsi_slave_destroy,
169 .bios_param = ata_std_bios_param, 169 .bios_param = ata_std_bios_param,
170 .resume = ata_scsi_device_resume,
171 .suspend = ata_scsi_device_suspend,
170}; 172};
171 173
172static struct ata_port_operations mpiix_port_ops = { 174static struct ata_port_operations mpiix_port_ops = {
@@ -284,7 +286,9 @@ static struct pci_driver mpiix_pci_driver = {
284 .name = DRV_NAME, 286 .name = DRV_NAME,
285 .id_table = mpiix, 287 .id_table = mpiix,
286 .probe = mpiix_init_one, 288 .probe = mpiix_init_one,
287 .remove = mpiix_remove_one 289 .remove = mpiix_remove_one,
290 .suspend = ata_pci_device_suspend,
291 .resume = ata_pci_device_resume,
288}; 292};
289 293
290static int __init mpiix_init(void) 294static int __init mpiix_init(void)
diff --git a/drivers/ata/pata_netcell.c b/drivers/ata/pata_netcell.c
index f5672de99c22..cf7fe037471c 100644
--- a/drivers/ata/pata_netcell.c
+++ b/drivers/ata/pata_netcell.c
@@ -16,7 +16,7 @@
16#include <linux/ata.h> 16#include <linux/ata.h>
17 17
18#define DRV_NAME "pata_netcell" 18#define DRV_NAME "pata_netcell"
19#define DRV_VERSION "0.1.5" 19#define DRV_VERSION "0.1.6"
20 20
21/** 21/**
22 * netcell_probe_init - check for 40/80 pin 22 * netcell_probe_init - check for 40/80 pin
@@ -54,16 +54,17 @@ static struct scsi_host_template netcell_sht = {
54 .can_queue = ATA_DEF_QUEUE, 54 .can_queue = ATA_DEF_QUEUE,
55 .this_id = ATA_SHT_THIS_ID, 55 .this_id = ATA_SHT_THIS_ID,
56 .sg_tablesize = LIBATA_MAX_PRD, 56 .sg_tablesize = LIBATA_MAX_PRD,
57 /* Special handling needed if you have sector or LBA48 limits */
58 .max_sectors = ATA_MAX_SECTORS,
59 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 57 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
60 .emulated = ATA_SHT_EMULATED, 58 .emulated = ATA_SHT_EMULATED,
61 .use_clustering = ATA_SHT_USE_CLUSTERING, 59 .use_clustering = ATA_SHT_USE_CLUSTERING,
62 .proc_name = DRV_NAME, 60 .proc_name = DRV_NAME,
63 .dma_boundary = ATA_DMA_BOUNDARY, 61 .dma_boundary = ATA_DMA_BOUNDARY,
64 .slave_configure = ata_scsi_slave_config, 62 .slave_configure = ata_scsi_slave_config,
63 .slave_destroy = ata_scsi_slave_destroy,
65 /* Use standard CHS mapping rules */ 64 /* Use standard CHS mapping rules */
66 .bios_param = ata_std_bios_param, 65 .bios_param = ata_std_bios_param,
66 .resume = ata_scsi_device_resume,
67 .suspend = ata_scsi_device_suspend,
67}; 68};
68 69
69static const struct ata_port_operations netcell_ops = { 70static const struct ata_port_operations netcell_ops = {
@@ -152,6 +153,8 @@ static struct pci_driver netcell_pci_driver = {
152 .id_table = netcell_pci_tbl, 153 .id_table = netcell_pci_tbl,
153 .probe = netcell_init_one, 154 .probe = netcell_init_one,
154 .remove = ata_pci_remove_one, 155 .remove = ata_pci_remove_one,
156 .suspend = ata_pci_device_suspend,
157 .resume = ata_pci_device_resume,
155}; 158};
156 159
157static int __init netcell_init(void) 160static int __init netcell_init(void)
diff --git a/drivers/ata/pata_ns87410.c b/drivers/ata/pata_ns87410.c
index 2a3dbeed89b4..c3032eb9010d 100644
--- a/drivers/ata/pata_ns87410.c
+++ b/drivers/ata/pata_ns87410.c
@@ -28,7 +28,7 @@
28#include <linux/libata.h> 28#include <linux/libata.h>
29 29
30#define DRV_NAME "pata_ns87410" 30#define DRV_NAME "pata_ns87410"
31#define DRV_VERSION "0.4.2" 31#define DRV_VERSION "0.4.3"
32 32
33/** 33/**
34 * ns87410_pre_reset - probe begin 34 * ns87410_pre_reset - probe begin
@@ -149,14 +149,16 @@ static struct scsi_host_template ns87410_sht = {
149 .can_queue = ATA_DEF_QUEUE, 149 .can_queue = ATA_DEF_QUEUE,
150 .this_id = ATA_SHT_THIS_ID, 150 .this_id = ATA_SHT_THIS_ID,
151 .sg_tablesize = LIBATA_MAX_PRD, 151 .sg_tablesize = LIBATA_MAX_PRD,
152 .max_sectors = ATA_MAX_SECTORS,
153 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 152 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
154 .emulated = ATA_SHT_EMULATED, 153 .emulated = ATA_SHT_EMULATED,
155 .use_clustering = ATA_SHT_USE_CLUSTERING, 154 .use_clustering = ATA_SHT_USE_CLUSTERING,
156 .proc_name = DRV_NAME, 155 .proc_name = DRV_NAME,
157 .dma_boundary = ATA_DMA_BOUNDARY, 156 .dma_boundary = ATA_DMA_BOUNDARY,
158 .slave_configure = ata_scsi_slave_config, 157 .slave_configure = ata_scsi_slave_config,
158 .slave_destroy = ata_scsi_slave_destroy,
159 .bios_param = ata_std_bios_param, 159 .bios_param = ata_std_bios_param,
160 .resume = ata_scsi_device_resume,
161 .suspend = ata_scsi_device_suspend,
160}; 162};
161 163
162static struct ata_port_operations ns87410_port_ops = { 164static struct ata_port_operations ns87410_port_ops = {
@@ -209,7 +211,9 @@ static struct pci_driver ns87410_pci_driver = {
209 .name = DRV_NAME, 211 .name = DRV_NAME,
210 .id_table = ns87410, 212 .id_table = ns87410,
211 .probe = ns87410_init_one, 213 .probe = ns87410_init_one,
212 .remove = ata_pci_remove_one 214 .remove = ata_pci_remove_one,
215 .suspend = ata_pci_device_suspend,
216 .resume = ata_pci_device_resume,
213}; 217};
214 218
215static int __init ns87410_init(void) 219static int __init ns87410_init(void)
diff --git a/drivers/ata/pata_oldpiix.c b/drivers/ata/pata_oldpiix.c
index fc947dfecd73..10ac3cc10181 100644
--- a/drivers/ata/pata_oldpiix.c
+++ b/drivers/ata/pata_oldpiix.c
@@ -224,14 +224,16 @@ static struct scsi_host_template oldpiix_sht = {
224 .can_queue = ATA_DEF_QUEUE, 224 .can_queue = ATA_DEF_QUEUE,
225 .this_id = ATA_SHT_THIS_ID, 225 .this_id = ATA_SHT_THIS_ID,
226 .sg_tablesize = LIBATA_MAX_PRD, 226 .sg_tablesize = LIBATA_MAX_PRD,
227 .max_sectors = ATA_MAX_SECTORS,
228 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 227 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
229 .emulated = ATA_SHT_EMULATED, 228 .emulated = ATA_SHT_EMULATED,
230 .use_clustering = ATA_SHT_USE_CLUSTERING, 229 .use_clustering = ATA_SHT_USE_CLUSTERING,
231 .proc_name = DRV_NAME, 230 .proc_name = DRV_NAME,
232 .dma_boundary = ATA_DMA_BOUNDARY, 231 .dma_boundary = ATA_DMA_BOUNDARY,
233 .slave_configure = ata_scsi_slave_config, 232 .slave_configure = ata_scsi_slave_config,
233 .slave_destroy = ata_scsi_slave_destroy,
234 .bios_param = ata_std_bios_param, 234 .bios_param = ata_std_bios_param,
235 .resume = ata_scsi_device_resume,
236 .suspend = ata_scsi_device_suspend,
235}; 237};
236 238
237static const struct ata_port_operations oldpiix_pata_ops = { 239static const struct ata_port_operations oldpiix_pata_ops = {
@@ -313,6 +315,8 @@ static struct pci_driver oldpiix_pci_driver = {
313 .id_table = oldpiix_pci_tbl, 315 .id_table = oldpiix_pci_tbl,
314 .probe = oldpiix_init_one, 316 .probe = oldpiix_init_one,
315 .remove = ata_pci_remove_one, 317 .remove = ata_pci_remove_one,
318 .suspend = ata_pci_device_suspend,
319 .resume = ata_pci_device_resume,
316}; 320};
317 321
318static int __init oldpiix_init(void) 322static int __init oldpiix_init(void)
diff --git a/drivers/ata/pata_opti.c b/drivers/ata/pata_opti.c
index a7320ba15575..c2988b0aa8ea 100644
--- a/drivers/ata/pata_opti.c
+++ b/drivers/ata/pata_opti.c
@@ -34,7 +34,7 @@
34#include <linux/libata.h> 34#include <linux/libata.h>
35 35
36#define DRV_NAME "pata_opti" 36#define DRV_NAME "pata_opti"
37#define DRV_VERSION "0.2.5" 37#define DRV_VERSION "0.2.7"
38 38
39enum { 39enum {
40 READ_REG = 0, /* index of Read cycle timing register */ 40 READ_REG = 0, /* index of Read cycle timing register */
@@ -109,30 +109,6 @@ static void opti_write_reg(struct ata_port *ap, u8 val, int reg)
109 outb(0x83, regio + 2); 109 outb(0x83, regio + 2);
110} 110}
111 111
112#if 0
113/**
114 * opti_read_reg - control register read
115 * @ap: ATA port
116 * @reg: control register number
117 *
118 * The Opti uses magic 'trapdoor' register accesses to do configuration
119 * rather than using PCI space as other controllers do. The double inw
120 * on the error register activates configuration mode. We can then read
121 * the control register
122 */
123
124static u8 opti_read_reg(struct ata_port *ap, int reg)
125{
126 unsigned long regio = ap->ioaddr.cmd_addr;
127 u8 ret;
128 inw(regio + 1);
129 inw(regio + 1);
130 outb(3, regio + 2);
131 ret = inb(regio + reg);
132 outb(0x83, regio + 2);
133}
134#endif
135
136/** 112/**
137 * opti_set_piomode - set initial PIO mode data 113 * opti_set_piomode - set initial PIO mode data
138 * @ap: ATA interface 114 * @ap: ATA interface
@@ -195,20 +171,21 @@ static struct scsi_host_template opti_sht = {
195 .can_queue = ATA_DEF_QUEUE, 171 .can_queue = ATA_DEF_QUEUE,
196 .this_id = ATA_SHT_THIS_ID, 172 .this_id = ATA_SHT_THIS_ID,
197 .sg_tablesize = LIBATA_MAX_PRD, 173 .sg_tablesize = LIBATA_MAX_PRD,
198 .max_sectors = ATA_MAX_SECTORS,
199 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 174 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
200 .emulated = ATA_SHT_EMULATED, 175 .emulated = ATA_SHT_EMULATED,
201 .use_clustering = ATA_SHT_USE_CLUSTERING, 176 .use_clustering = ATA_SHT_USE_CLUSTERING,
202 .proc_name = DRV_NAME, 177 .proc_name = DRV_NAME,
203 .dma_boundary = ATA_DMA_BOUNDARY, 178 .dma_boundary = ATA_DMA_BOUNDARY,
204 .slave_configure = ata_scsi_slave_config, 179 .slave_configure = ata_scsi_slave_config,
180 .slave_destroy = ata_scsi_slave_destroy,
205 .bios_param = ata_std_bios_param, 181 .bios_param = ata_std_bios_param,
182 .resume = ata_scsi_device_resume,
183 .suspend = ata_scsi_device_suspend,
206}; 184};
207 185
208static struct ata_port_operations opti_port_ops = { 186static struct ata_port_operations opti_port_ops = {
209 .port_disable = ata_port_disable, 187 .port_disable = ata_port_disable,
210 .set_piomode = opti_set_piomode, 188 .set_piomode = opti_set_piomode,
211/* .set_dmamode = opti_set_dmamode, */
212 .tf_load = ata_tf_load, 189 .tf_load = ata_tf_load,
213 .tf_read = ata_tf_read, 190 .tf_read = ata_tf_read,
214 .check_status = ata_check_status, 191 .check_status = ata_check_status,
@@ -266,7 +243,9 @@ static struct pci_driver opti_pci_driver = {
266 .name = DRV_NAME, 243 .name = DRV_NAME,
267 .id_table = opti, 244 .id_table = opti,
268 .probe = opti_init_one, 245 .probe = opti_init_one,
269 .remove = ata_pci_remove_one 246 .remove = ata_pci_remove_one,
247 .suspend = ata_pci_device_suspend,
248 .resume = ata_pci_device_resume,
270}; 249};
271 250
272static int __init opti_init(void) 251static int __init opti_init(void)
diff --git a/drivers/ata/pata_optidma.c b/drivers/ata/pata_optidma.c
index c6906b4215de..80d111c569dc 100644
--- a/drivers/ata/pata_optidma.c
+++ b/drivers/ata/pata_optidma.c
@@ -33,7 +33,7 @@
33#include <linux/libata.h> 33#include <linux/libata.h>
34 34
35#define DRV_NAME "pata_optidma" 35#define DRV_NAME "pata_optidma"
36#define DRV_VERSION "0.2.2" 36#define DRV_VERSION "0.2.3"
37 37
38enum { 38enum {
39 READ_REG = 0, /* index of Read cycle timing register */ 39 READ_REG = 0, /* index of Read cycle timing register */
@@ -352,14 +352,16 @@ static struct scsi_host_template optidma_sht = {
352 .can_queue = ATA_DEF_QUEUE, 352 .can_queue = ATA_DEF_QUEUE,
353 .this_id = ATA_SHT_THIS_ID, 353 .this_id = ATA_SHT_THIS_ID,
354 .sg_tablesize = LIBATA_MAX_PRD, 354 .sg_tablesize = LIBATA_MAX_PRD,
355 .max_sectors = ATA_MAX_SECTORS,
356 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 355 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
357 .emulated = ATA_SHT_EMULATED, 356 .emulated = ATA_SHT_EMULATED,
358 .use_clustering = ATA_SHT_USE_CLUSTERING, 357 .use_clustering = ATA_SHT_USE_CLUSTERING,
359 .proc_name = DRV_NAME, 358 .proc_name = DRV_NAME,
360 .dma_boundary = ATA_DMA_BOUNDARY, 359 .dma_boundary = ATA_DMA_BOUNDARY,
361 .slave_configure = ata_scsi_slave_config, 360 .slave_configure = ata_scsi_slave_config,
361 .slave_destroy = ata_scsi_slave_destroy,
362 .bios_param = ata_std_bios_param, 362 .bios_param = ata_std_bios_param,
363 .resume = ata_scsi_device_resume,
364 .suspend = ata_scsi_device_suspend,
363}; 365};
364 366
365static struct ata_port_operations optidma_port_ops = { 367static struct ata_port_operations optidma_port_ops = {
@@ -521,7 +523,9 @@ static struct pci_driver optidma_pci_driver = {
521 .name = DRV_NAME, 523 .name = DRV_NAME,
522 .id_table = optidma, 524 .id_table = optidma,
523 .probe = optidma_init_one, 525 .probe = optidma_init_one,
524 .remove = ata_pci_remove_one 526 .remove = ata_pci_remove_one,
527 .suspend = ata_pci_device_suspend,
528 .resume = ata_pci_device_resume,
525}; 529};
526 530
527static int __init optidma_init(void) 531static int __init optidma_init(void)
diff --git a/drivers/ata/pata_pcmcia.c b/drivers/ata/pata_pcmcia.c
index e93ea2702c73..9ed7f58424a3 100644
--- a/drivers/ata/pata_pcmcia.c
+++ b/drivers/ata/pata_pcmcia.c
@@ -62,13 +62,13 @@ static struct scsi_host_template pcmcia_sht = {
62 .can_queue = ATA_DEF_QUEUE, 62 .can_queue = ATA_DEF_QUEUE,
63 .this_id = ATA_SHT_THIS_ID, 63 .this_id = ATA_SHT_THIS_ID,
64 .sg_tablesize = LIBATA_MAX_PRD, 64 .sg_tablesize = LIBATA_MAX_PRD,
65 .max_sectors = ATA_MAX_SECTORS,
66 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 65 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
67 .emulated = ATA_SHT_EMULATED, 66 .emulated = ATA_SHT_EMULATED,
68 .use_clustering = ATA_SHT_USE_CLUSTERING, 67 .use_clustering = ATA_SHT_USE_CLUSTERING,
69 .proc_name = DRV_NAME, 68 .proc_name = DRV_NAME,
70 .dma_boundary = ATA_DMA_BOUNDARY, 69 .dma_boundary = ATA_DMA_BOUNDARY,
71 .slave_configure = ata_scsi_slave_config, 70 .slave_configure = ata_scsi_slave_config,
71 .slave_destroy = ata_scsi_slave_destroy,
72 .bios_param = ata_std_bios_param, 72 .bios_param = ata_std_bios_param,
73}; 73};
74 74
@@ -154,19 +154,12 @@ static int pcmcia_init_one(struct pcmcia_device *pdev)
154 tuple.TupleOffset = 0; 154 tuple.TupleOffset = 0;
155 tuple.TupleDataMax = 255; 155 tuple.TupleDataMax = 255;
156 tuple.Attributes = 0; 156 tuple.Attributes = 0;
157 tuple.DesiredTuple = CISTPL_CONFIG;
158
159 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(pdev, &tuple));
160 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(pdev, &tuple));
161 CS_CHECK(ParseTuple, pcmcia_parse_tuple(pdev, &tuple, &stk->parse));
162 pdev->conf.ConfigBase = stk->parse.config.base;
163 pdev->conf.Present = stk->parse.config.rmask[0];
164 157
165 /* See if we have a manufacturer identifier. Use it to set is_kme for 158 /* See if we have a manufacturer identifier. Use it to set is_kme for
166 vendor quirks */ 159 vendor quirks */
167 tuple.DesiredTuple = CISTPL_MANFID; 160 is_kme = ((pdev->manf_id == MANFID_KME) &&
168 if (!pcmcia_get_first_tuple(pdev, &tuple) && !pcmcia_get_tuple_data(pdev, &tuple) && !pcmcia_parse_tuple(pdev, &tuple, &stk->parse)) 161 ((pdev->card_id == PRODID_KME_KXLC005_A) ||
169 is_kme = ((stk->parse.manfid.manf == MANFID_KME) && ((stk->parse.manfid.card == PRODID_KME_KXLC005_A) || (stk->parse.manfid.card == PRODID_KME_KXLC005_B))); 162 (pdev->card_id == PRODID_KME_KXLC005_B)));
170 163
171 /* Not sure if this is right... look up the current Vcc */ 164 /* Not sure if this is right... look up the current Vcc */
172 CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(pdev, &stk->conf)); 165 CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(pdev, &stk->conf));
@@ -356,8 +349,10 @@ static struct pcmcia_device_id pcmcia_devices[] = {
356 PCMCIA_DEVICE_PROD_ID12("SMI VENDOR", "SMI PRODUCT", 0x30896c92, 0x703cc5f6), 349 PCMCIA_DEVICE_PROD_ID12("SMI VENDOR", "SMI PRODUCT", 0x30896c92, 0x703cc5f6),
357 PCMCIA_DEVICE_PROD_ID12("TOSHIBA", "MK2001MPL", 0xb4585a1a, 0x3489e003), 350 PCMCIA_DEVICE_PROD_ID12("TOSHIBA", "MK2001MPL", 0xb4585a1a, 0x3489e003),
358 PCMCIA_DEVICE_PROD_ID1("TRANSCEND 512M ", 0xd0909443), 351 PCMCIA_DEVICE_PROD_ID1("TRANSCEND 512M ", 0xd0909443),
352 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS1GCF80", 0x709b1bf1, 0x2a54d4b1),
359 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS4GCF120", 0x709b1bf1, 0xf54a91c8), 353 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS4GCF120", 0x709b1bf1, 0xf54a91c8),
360 PCMCIA_DEVICE_PROD_ID12("WIT", "IDE16", 0x244e5994, 0x3e232852), 354 PCMCIA_DEVICE_PROD_ID12("WIT", "IDE16", 0x244e5994, 0x3e232852),
355 PCMCIA_DEVICE_PROD_ID12("WEIDA", "TWTTI", 0xcc7cf69c, 0x212bb918),
361 PCMCIA_DEVICE_PROD_ID1("STI Flash", 0xe4a13209), 356 PCMCIA_DEVICE_PROD_ID1("STI Flash", 0xe4a13209),
362 PCMCIA_DEVICE_PROD_ID12("STI", "Flash 5.0", 0xbf2df18d, 0x8cb57a0e), 357 PCMCIA_DEVICE_PROD_ID12("STI", "Flash 5.0", 0xbf2df18d, 0x8cb57a0e),
363 PCMCIA_MFC_DEVICE_PROD_ID12(1, "SanDisk", "ConnectPlus", 0x7a954bd9, 0x74be00c6), 358 PCMCIA_MFC_DEVICE_PROD_ID12(1, "SanDisk", "ConnectPlus", 0x7a954bd9, 0x74be00c6),
diff --git a/drivers/ata/pata_pdc2027x.c b/drivers/ata/pata_pdc2027x.c
index d894d9918b1d..76dd1c935dbd 100644
--- a/drivers/ata/pata_pdc2027x.c
+++ b/drivers/ata/pata_pdc2027x.c
@@ -134,13 +134,13 @@ static struct scsi_host_template pdc2027x_sht = {
134 .can_queue = ATA_DEF_QUEUE, 134 .can_queue = ATA_DEF_QUEUE,
135 .this_id = ATA_SHT_THIS_ID, 135 .this_id = ATA_SHT_THIS_ID,
136 .sg_tablesize = LIBATA_MAX_PRD, 136 .sg_tablesize = LIBATA_MAX_PRD,
137 .max_sectors = ATA_MAX_SECTORS,
138 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 137 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
139 .emulated = ATA_SHT_EMULATED, 138 .emulated = ATA_SHT_EMULATED,
140 .use_clustering = ATA_SHT_USE_CLUSTERING, 139 .use_clustering = ATA_SHT_USE_CLUSTERING,
141 .proc_name = DRV_NAME, 140 .proc_name = DRV_NAME,
142 .dma_boundary = ATA_DMA_BOUNDARY, 141 .dma_boundary = ATA_DMA_BOUNDARY,
143 .slave_configure = ata_scsi_slave_config, 142 .slave_configure = ata_scsi_slave_config,
143 .slave_destroy = ata_scsi_slave_destroy,
144 .bios_param = ata_std_bios_param, 144 .bios_param = ata_std_bios_param,
145}; 145};
146 146
@@ -853,7 +853,7 @@ static void __devexit pdc2027x_remove_one(struct pci_dev *pdev)
853 */ 853 */
854static int __init pdc2027x_init(void) 854static int __init pdc2027x_init(void)
855{ 855{
856 return pci_module_init(&pdc2027x_pci_driver); 856 return pci_register_driver(&pdc2027x_pci_driver);
857} 857}
858 858
859/** 859/**
diff --git a/drivers/ata/pata_pdc202xx_old.c b/drivers/ata/pata_pdc202xx_old.c
index 5ba9eb20a6c2..ad691b9e7743 100644
--- a/drivers/ata/pata_pdc202xx_old.c
+++ b/drivers/ata/pata_pdc202xx_old.c
@@ -21,7 +21,7 @@
21#include <linux/libata.h> 21#include <linux/libata.h>
22 22
23#define DRV_NAME "pata_pdc202xx_old" 23#define DRV_NAME "pata_pdc202xx_old"
24#define DRV_VERSION "0.2.1" 24#define DRV_VERSION "0.2.3"
25 25
26/** 26/**
27 * pdc2024x_pre_reset - probe begin 27 * pdc2024x_pre_reset - probe begin
@@ -63,7 +63,7 @@ static void pdc2026x_error_handler(struct ata_port *ap)
63} 63}
64 64
65/** 65/**
66 * pdc_configure_piomode - set chip PIO timing 66 * pdc202xx_configure_piomode - set chip PIO timing
67 * @ap: ATA interface 67 * @ap: ATA interface
68 * @adev: ATA device 68 * @adev: ATA device
69 * @pio: PIO mode 69 * @pio: PIO mode
@@ -73,7 +73,7 @@ static void pdc2026x_error_handler(struct ata_port *ap)
73 * versa 73 * versa
74 */ 74 */
75 75
76static void pdc_configure_piomode(struct ata_port *ap, struct ata_device *adev, int pio) 76static void pdc202xx_configure_piomode(struct ata_port *ap, struct ata_device *adev, int pio)
77{ 77{
78 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 78 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
79 int port = 0x60 + 4 * ap->port_no + 2 * adev->devno; 79 int port = 0x60 + 4 * ap->port_no + 2 * adev->devno;
@@ -98,7 +98,7 @@ static void pdc_configure_piomode(struct ata_port *ap, struct ata_device *adev,
98} 98}
99 99
100/** 100/**
101 * pdc_set_piomode - set initial PIO mode data 101 * pdc202xx_set_piomode - set initial PIO mode data
102 * @ap: ATA interface 102 * @ap: ATA interface
103 * @adev: ATA device 103 * @adev: ATA device
104 * 104 *
@@ -106,13 +106,13 @@ static void pdc_configure_piomode(struct ata_port *ap, struct ata_device *adev,
106 * but we want to set the PIO timing by default. 106 * but we want to set the PIO timing by default.
107 */ 107 */
108 108
109static void pdc_set_piomode(struct ata_port *ap, struct ata_device *adev) 109static void pdc202xx_set_piomode(struct ata_port *ap, struct ata_device *adev)
110{ 110{
111 pdc_configure_piomode(ap, adev, adev->pio_mode - XFER_PIO_0); 111 pdc202xx_configure_piomode(ap, adev, adev->pio_mode - XFER_PIO_0);
112} 112}
113 113
114/** 114/**
115 * pdc_configure_dmamode - set DMA mode in chip 115 * pdc202xx_configure_dmamode - set DMA mode in chip
116 * @ap: ATA interface 116 * @ap: ATA interface
117 * @adev: ATA device 117 * @adev: ATA device
118 * 118 *
@@ -120,7 +120,7 @@ static void pdc_set_piomode(struct ata_port *ap, struct ata_device *adev)
120 * to occur. 120 * to occur.
121 */ 121 */
122 122
123static void pdc_set_dmamode(struct ata_port *ap, struct ata_device *adev) 123static void pdc202xx_set_dmamode(struct ata_port *ap, struct ata_device *adev)
124{ 124{
125 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 125 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
126 int port = 0x60 + 4 * ap->port_no + 2 * adev->devno; 126 int port = 0x60 + 4 * ap->port_no + 2 * adev->devno;
@@ -184,7 +184,7 @@ static void pdc2026x_bmdma_start(struct ata_queued_cmd *qc)
184 184
185 /* The DMA clocks may have been trashed by a reset. FIXME: make conditional 185 /* The DMA clocks may have been trashed by a reset. FIXME: make conditional
186 and move to qc_issue ? */ 186 and move to qc_issue ? */
187 pdc_set_dmamode(ap, qc->dev); 187 pdc202xx_set_dmamode(ap, qc->dev);
188 188
189 /* Cases the state machine will not complete correctly without help */ 189 /* Cases the state machine will not complete correctly without help */
190 if ((tf->flags & ATA_TFLAG_LBA48) || tf->protocol == ATA_PROT_ATAPI_DMA) 190 if ((tf->flags & ATA_TFLAG_LBA48) || tf->protocol == ATA_PROT_ATAPI_DMA)
@@ -254,7 +254,7 @@ static void pdc2026x_dev_config(struct ata_port *ap, struct ata_device *adev)
254 adev->max_sectors = 256; 254 adev->max_sectors = 256;
255} 255}
256 256
257static struct scsi_host_template pdc_sht = { 257static struct scsi_host_template pdc202xx_sht = {
258 .module = THIS_MODULE, 258 .module = THIS_MODULE,
259 .name = DRV_NAME, 259 .name = DRV_NAME,
260 .ioctl = ata_scsi_ioctl, 260 .ioctl = ata_scsi_ioctl,
@@ -262,20 +262,22 @@ static struct scsi_host_template pdc_sht = {
262 .can_queue = ATA_DEF_QUEUE, 262 .can_queue = ATA_DEF_QUEUE,
263 .this_id = ATA_SHT_THIS_ID, 263 .this_id = ATA_SHT_THIS_ID,
264 .sg_tablesize = LIBATA_MAX_PRD, 264 .sg_tablesize = LIBATA_MAX_PRD,
265 .max_sectors = ATA_MAX_SECTORS,
266 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 265 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
267 .emulated = ATA_SHT_EMULATED, 266 .emulated = ATA_SHT_EMULATED,
268 .use_clustering = ATA_SHT_USE_CLUSTERING, 267 .use_clustering = ATA_SHT_USE_CLUSTERING,
269 .proc_name = DRV_NAME, 268 .proc_name = DRV_NAME,
270 .dma_boundary = ATA_DMA_BOUNDARY, 269 .dma_boundary = ATA_DMA_BOUNDARY,
271 .slave_configure = ata_scsi_slave_config, 270 .slave_configure = ata_scsi_slave_config,
271 .slave_destroy = ata_scsi_slave_destroy,
272 .bios_param = ata_std_bios_param, 272 .bios_param = ata_std_bios_param,
273 .resume = ata_scsi_device_resume,
274 .suspend = ata_scsi_device_suspend,
273}; 275};
274 276
275static struct ata_port_operations pdc2024x_port_ops = { 277static struct ata_port_operations pdc2024x_port_ops = {
276 .port_disable = ata_port_disable, 278 .port_disable = ata_port_disable,
277 .set_piomode = pdc_set_piomode, 279 .set_piomode = pdc202xx_set_piomode,
278 .set_dmamode = pdc_set_dmamode, 280 .set_dmamode = pdc202xx_set_dmamode,
279 .mode_filter = ata_pci_default_filter, 281 .mode_filter = ata_pci_default_filter,
280 .tf_load = ata_tf_load, 282 .tf_load = ata_tf_load,
281 .tf_read = ata_tf_read, 283 .tf_read = ata_tf_read,
@@ -307,8 +309,8 @@ static struct ata_port_operations pdc2024x_port_ops = {
307 309
308static struct ata_port_operations pdc2026x_port_ops = { 310static struct ata_port_operations pdc2026x_port_ops = {
309 .port_disable = ata_port_disable, 311 .port_disable = ata_port_disable,
310 .set_piomode = pdc_set_piomode, 312 .set_piomode = pdc202xx_set_piomode,
311 .set_dmamode = pdc_set_dmamode, 313 .set_dmamode = pdc202xx_set_dmamode,
312 .mode_filter = ata_pci_default_filter, 314 .mode_filter = ata_pci_default_filter,
313 .tf_load = ata_tf_load, 315 .tf_load = ata_tf_load,
314 .tf_read = ata_tf_read, 316 .tf_read = ata_tf_read,
@@ -339,11 +341,11 @@ static struct ata_port_operations pdc2026x_port_ops = {
339 .host_stop = ata_host_stop 341 .host_stop = ata_host_stop
340}; 342};
341 343
342static int pdc_init_one(struct pci_dev *dev, const struct pci_device_id *id) 344static int pdc202xx_init_one(struct pci_dev *dev, const struct pci_device_id *id)
343{ 345{
344 static struct ata_port_info info[3] = { 346 static struct ata_port_info info[3] = {
345 { 347 {
346 .sht = &pdc_sht, 348 .sht = &pdc202xx_sht,
347 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 349 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
348 .pio_mask = 0x1f, 350 .pio_mask = 0x1f,
349 .mwdma_mask = 0x07, 351 .mwdma_mask = 0x07,
@@ -351,7 +353,7 @@ static int pdc_init_one(struct pci_dev *dev, const struct pci_device_id *id)
351 .port_ops = &pdc2024x_port_ops 353 .port_ops = &pdc2024x_port_ops
352 }, 354 },
353 { 355 {
354 .sht = &pdc_sht, 356 .sht = &pdc202xx_sht,
355 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 357 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
356 .pio_mask = 0x1f, 358 .pio_mask = 0x1f,
357 .mwdma_mask = 0x07, 359 .mwdma_mask = 0x07,
@@ -359,7 +361,7 @@ static int pdc_init_one(struct pci_dev *dev, const struct pci_device_id *id)
359 .port_ops = &pdc2026x_port_ops 361 .port_ops = &pdc2026x_port_ops
360 }, 362 },
361 { 363 {
362 .sht = &pdc_sht, 364 .sht = &pdc202xx_sht,
363 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 365 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
364 .pio_mask = 0x1f, 366 .pio_mask = 0x1f,
365 .mwdma_mask = 0x07, 367 .mwdma_mask = 0x07,
@@ -385,7 +387,7 @@ static int pdc_init_one(struct pci_dev *dev, const struct pci_device_id *id)
385 return ata_pci_init_one(dev, port_info, 2); 387 return ata_pci_init_one(dev, port_info, 2);
386} 388}
387 389
388static const struct pci_device_id pdc[] = { 390static const struct pci_device_id pdc202xx[] = {
389 { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20246), 0 }, 391 { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20246), 0 },
390 { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20262), 1 }, 392 { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20262), 1 },
391 { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20263), 1 }, 393 { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20263), 1 },
@@ -395,28 +397,30 @@ static const struct pci_device_id pdc[] = {
395 { }, 397 { },
396}; 398};
397 399
398static struct pci_driver pdc_pci_driver = { 400static struct pci_driver pdc202xx_pci_driver = {
399 .name = DRV_NAME, 401 .name = DRV_NAME,
400 .id_table = pdc, 402 .id_table = pdc202xx,
401 .probe = pdc_init_one, 403 .probe = pdc202xx_init_one,
402 .remove = ata_pci_remove_one 404 .remove = ata_pci_remove_one,
405 .suspend = ata_pci_device_suspend,
406 .resume = ata_pci_device_resume,
403}; 407};
404 408
405static int __init pdc_init(void) 409static int __init pdc202xx_init(void)
406{ 410{
407 return pci_register_driver(&pdc_pci_driver); 411 return pci_register_driver(&pdc202xx_pci_driver);
408} 412}
409 413
410static void __exit pdc_exit(void) 414static void __exit pdc202xx_exit(void)
411{ 415{
412 pci_unregister_driver(&pdc_pci_driver); 416 pci_unregister_driver(&pdc202xx_pci_driver);
413} 417}
414 418
415MODULE_AUTHOR("Alan Cox"); 419MODULE_AUTHOR("Alan Cox");
416MODULE_DESCRIPTION("low-level driver for Promise 2024x and 20262-20267"); 420MODULE_DESCRIPTION("low-level driver for Promise 2024x and 20262-20267");
417MODULE_LICENSE("GPL"); 421MODULE_LICENSE("GPL");
418MODULE_DEVICE_TABLE(pci, pdc); 422MODULE_DEVICE_TABLE(pci, pdc202xx);
419MODULE_VERSION(DRV_VERSION); 423MODULE_VERSION(DRV_VERSION);
420 424
421module_init(pdc_init); 425module_init(pdc202xx_init);
422module_exit(pdc_exit); 426module_exit(pdc202xx_exit);
diff --git a/drivers/ata/pata_platform.c b/drivers/ata/pata_platform.c
new file mode 100644
index 000000000000..443b1d85c6c4
--- /dev/null
+++ b/drivers/ata/pata_platform.c
@@ -0,0 +1,295 @@
1/*
2 * Generic platform device PATA driver
3 *
4 * Copyright (C) 2006 Paul Mundt
5 *
6 * Based on pata_pcmcia:
7 *
8 * Copyright 2005-2006 Red Hat Inc <alan@redhat.com>, all rights reserved.
9 *
10 * This file is subject to the terms and conditions of the GNU General Public
11 * License. See the file "COPYING" in the main directory of this archive
12 * for more details.
13 */
14#include <linux/kernel.h>
15#include <linux/module.h>
16#include <linux/init.h>
17#include <linux/blkdev.h>
18#include <scsi/scsi_host.h>
19#include <linux/ata.h>
20#include <linux/libata.h>
21#include <linux/platform_device.h>
22#include <linux/pata_platform.h>
23
24#define DRV_NAME "pata_platform"
25#define DRV_VERSION "0.1.2"
26
27static int pio_mask = 1;
28
29/*
30 * Provide our own set_mode() as we don't want to change anything that has
31 * already been configured..
32 */
33static void pata_platform_set_mode(struct ata_port *ap)
34{
35 int i;
36
37 for (i = 0; i < ATA_MAX_DEVICES; i++) {
38 struct ata_device *dev = &ap->device[i];
39
40 if (ata_dev_enabled(dev)) {
41 /* We don't really care */
42 dev->pio_mode = dev->xfer_mode = XFER_PIO_0;
43 dev->xfer_shift = ATA_SHIFT_PIO;
44 dev->flags |= ATA_DFLAG_PIO;
45 }
46 }
47}
48
49static void pata_platform_host_stop(struct ata_host *host)
50{
51 int i;
52
53 /*
54 * Unmap the bases for MMIO
55 */
56 for (i = 0; i < host->n_ports; i++) {
57 struct ata_port *ap = host->ports[i];
58
59 if (ap->flags & ATA_FLAG_MMIO) {
60 iounmap((void __iomem *)ap->ioaddr.ctl_addr);
61 iounmap((void __iomem *)ap->ioaddr.cmd_addr);
62 }
63 }
64}
65
66static struct scsi_host_template pata_platform_sht = {
67 .module = THIS_MODULE,
68 .name = DRV_NAME,
69 .ioctl = ata_scsi_ioctl,
70 .queuecommand = ata_scsi_queuecmd,
71 .can_queue = ATA_DEF_QUEUE,
72 .this_id = ATA_SHT_THIS_ID,
73 .sg_tablesize = LIBATA_MAX_PRD,
74 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
75 .emulated = ATA_SHT_EMULATED,
76 .use_clustering = ATA_SHT_USE_CLUSTERING,
77 .proc_name = DRV_NAME,
78 .dma_boundary = ATA_DMA_BOUNDARY,
79 .slave_configure = ata_scsi_slave_config,
80 .slave_destroy = ata_scsi_slave_destroy,
81 .bios_param = ata_std_bios_param,
82};
83
84static struct ata_port_operations pata_platform_port_ops = {
85 .set_mode = pata_platform_set_mode,
86
87 .port_disable = ata_port_disable,
88 .tf_load = ata_tf_load,
89 .tf_read = ata_tf_read,
90 .check_status = ata_check_status,
91 .exec_command = ata_exec_command,
92 .dev_select = ata_std_dev_select,
93
94 .freeze = ata_bmdma_freeze,
95 .thaw = ata_bmdma_thaw,
96 .error_handler = ata_bmdma_error_handler,
97 .post_internal_cmd = ata_bmdma_post_internal_cmd,
98
99 .qc_prep = ata_qc_prep,
100 .qc_issue = ata_qc_issue_prot,
101
102 .data_xfer = ata_pio_data_xfer_noirq,
103
104 .irq_handler = ata_interrupt,
105 .irq_clear = ata_bmdma_irq_clear,
106
107 .port_start = ata_port_start,
108 .port_stop = ata_port_stop,
109 .host_stop = pata_platform_host_stop
110};
111
112static void pata_platform_setup_port(struct ata_ioports *ioaddr,
113 struct pata_platform_info *info)
114{
115 unsigned int shift = 0;
116
117 /* Fixup the port shift for platforms that need it */
118 if (info && info->ioport_shift)
119 shift = info->ioport_shift;
120
121 ioaddr->data_addr = ioaddr->cmd_addr + (ATA_REG_DATA << shift);
122 ioaddr->error_addr = ioaddr->cmd_addr + (ATA_REG_ERR << shift);
123 ioaddr->feature_addr = ioaddr->cmd_addr + (ATA_REG_FEATURE << shift);
124 ioaddr->nsect_addr = ioaddr->cmd_addr + (ATA_REG_NSECT << shift);
125 ioaddr->lbal_addr = ioaddr->cmd_addr + (ATA_REG_LBAL << shift);
126 ioaddr->lbam_addr = ioaddr->cmd_addr + (ATA_REG_LBAM << shift);
127 ioaddr->lbah_addr = ioaddr->cmd_addr + (ATA_REG_LBAH << shift);
128 ioaddr->device_addr = ioaddr->cmd_addr + (ATA_REG_DEVICE << shift);
129 ioaddr->status_addr = ioaddr->cmd_addr + (ATA_REG_STATUS << shift);
130 ioaddr->command_addr = ioaddr->cmd_addr + (ATA_REG_CMD << shift);
131}
132
133/**
134 * pata_platform_probe - attach a platform interface
135 * @pdev: platform device
136 *
137 * Register a platform bus IDE interface. Such interfaces are PIO and we
138 * assume do not support IRQ sharing.
139 *
140 * Platform devices are expected to contain 3 resources per port:
141 *
142 * - I/O Base (IORESOURCE_IO or IORESOURCE_MEM)
143 * - CTL Base (IORESOURCE_IO or IORESOURCE_MEM)
144 * - IRQ (IORESOURCE_IRQ)
145 *
146 * If the base resources are both mem types, the ioremap() is handled
147 * here. For IORESOURCE_IO, it's assumed that there's no remapping
148 * necessary.
149 */
150static int __devinit pata_platform_probe(struct platform_device *pdev)
151{
152 struct resource *io_res, *ctl_res;
153 struct ata_probe_ent ae;
154 unsigned int mmio;
155 int ret;
156
157 /*
158 * Simple resource validation ..
159 */
160 if (unlikely(pdev->num_resources != 3)) {
161 dev_err(&pdev->dev, "invalid number of resources\n");
162 return -EINVAL;
163 }
164
165 /*
166 * Get the I/O base first
167 */
168 io_res = platform_get_resource(pdev, IORESOURCE_IO, 0);
169 if (io_res == NULL) {
170 io_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
171 if (unlikely(io_res == NULL))
172 return -EINVAL;
173 }
174
175 /*
176 * Then the CTL base
177 */
178 ctl_res = platform_get_resource(pdev, IORESOURCE_IO, 1);
179 if (ctl_res == NULL) {
180 ctl_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
181 if (unlikely(ctl_res == NULL))
182 return -EINVAL;
183 }
184
185 /*
186 * Check for MMIO
187 */
188 mmio = (( io_res->flags == IORESOURCE_MEM) &&
189 (ctl_res->flags == IORESOURCE_MEM));
190
191 /*
192 * Now that that's out of the way, wire up the port..
193 */
194 memset(&ae, 0, sizeof(struct ata_probe_ent));
195 INIT_LIST_HEAD(&ae.node);
196 ae.dev = &pdev->dev;
197 ae.port_ops = &pata_platform_port_ops;
198 ae.sht = &pata_platform_sht;
199 ae.n_ports = 1;
200 ae.pio_mask = pio_mask;
201 ae.irq = platform_get_irq(pdev, 0);
202 ae.irq_flags = 0;
203 ae.port_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST;
204
205 /*
206 * Handle the MMIO case
207 */
208 if (mmio) {
209 ae.port_flags |= ATA_FLAG_MMIO;
210
211 ae.port[0].cmd_addr = (unsigned long)ioremap(io_res->start,
212 io_res->end - io_res->start + 1);
213 if (unlikely(!ae.port[0].cmd_addr)) {
214 dev_err(&pdev->dev, "failed to remap IO base\n");
215 return -ENXIO;
216 }
217
218 ae.port[0].ctl_addr = (unsigned long)ioremap(ctl_res->start,
219 ctl_res->end - ctl_res->start + 1);
220 if (unlikely(!ae.port[0].ctl_addr)) {
221 dev_err(&pdev->dev, "failed to remap CTL base\n");
222 ret = -ENXIO;
223 goto bad_remap;
224 }
225 } else {
226 ae.port[0].cmd_addr = io_res->start;
227 ae.port[0].ctl_addr = ctl_res->start;
228 }
229
230 ae.port[0].altstatus_addr = ae.port[0].ctl_addr;
231
232 pata_platform_setup_port(&ae.port[0], pdev->dev.platform_data);
233
234 if (unlikely(ata_device_add(&ae) == 0)) {
235 ret = -ENODEV;
236 goto add_failed;
237 }
238
239 return 0;
240
241add_failed:
242 if (ae.port[0].ctl_addr && mmio)
243 iounmap((void __iomem *)ae.port[0].ctl_addr);
244bad_remap:
245 if (ae.port[0].cmd_addr && mmio)
246 iounmap((void __iomem *)ae.port[0].cmd_addr);
247
248 return ret;
249}
250
251/**
252 * pata_platform_remove - unplug a platform interface
253 * @pdev: platform device
254 *
255 * A platform bus ATA device has been unplugged. Perform the needed
256 * cleanup. Also called on module unload for any active devices.
257 */
258static int __devexit pata_platform_remove(struct platform_device *pdev)
259{
260 struct device *dev = &pdev->dev;
261 struct ata_host *host = dev_get_drvdata(dev);
262
263 ata_host_remove(host);
264 dev_set_drvdata(dev, NULL);
265
266 return 0;
267}
268
269static struct platform_driver pata_platform_driver = {
270 .probe = pata_platform_probe,
271 .remove = __devexit_p(pata_platform_remove),
272 .driver = {
273 .name = DRV_NAME,
274 .owner = THIS_MODULE,
275 },
276};
277
278static int __init pata_platform_init(void)
279{
280 return platform_driver_register(&pata_platform_driver);
281}
282
283static void __exit pata_platform_exit(void)
284{
285 platform_driver_unregister(&pata_platform_driver);
286}
287module_init(pata_platform_init);
288module_exit(pata_platform_exit);
289
290module_param(pio_mask, int, 0);
291
292MODULE_AUTHOR("Paul Mundt");
293MODULE_DESCRIPTION("low-level driver for platform device ATA");
294MODULE_LICENSE("GPL");
295MODULE_VERSION(DRV_VERSION);
diff --git a/drivers/ata/pata_qdi.c b/drivers/ata/pata_qdi.c
index 2c3cc0ccc606..36f621abc390 100644
--- a/drivers/ata/pata_qdi.c
+++ b/drivers/ata/pata_qdi.c
@@ -157,13 +157,13 @@ static struct scsi_host_template qdi_sht = {
157 .can_queue = ATA_DEF_QUEUE, 157 .can_queue = ATA_DEF_QUEUE,
158 .this_id = ATA_SHT_THIS_ID, 158 .this_id = ATA_SHT_THIS_ID,
159 .sg_tablesize = LIBATA_MAX_PRD, 159 .sg_tablesize = LIBATA_MAX_PRD,
160 .max_sectors = ATA_MAX_SECTORS,
161 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 160 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
162 .emulated = ATA_SHT_EMULATED, 161 .emulated = ATA_SHT_EMULATED,
163 .use_clustering = ATA_SHT_USE_CLUSTERING, 162 .use_clustering = ATA_SHT_USE_CLUSTERING,
164 .proc_name = DRV_NAME, 163 .proc_name = DRV_NAME,
165 .dma_boundary = ATA_DMA_BOUNDARY, 164 .dma_boundary = ATA_DMA_BOUNDARY,
166 .slave_configure = ata_scsi_slave_config, 165 .slave_configure = ata_scsi_slave_config,
166 .slave_destroy = ata_scsi_slave_destroy,
167 .bios_param = ata_std_bios_param, 167 .bios_param = ata_std_bios_param,
168}; 168};
169 169
diff --git a/drivers/ata/pata_radisys.c b/drivers/ata/pata_radisys.c
index 1af83d7694d5..065541d034ad 100644
--- a/drivers/ata/pata_radisys.c
+++ b/drivers/ata/pata_radisys.c
@@ -220,14 +220,16 @@ static struct scsi_host_template radisys_sht = {
220 .can_queue = ATA_DEF_QUEUE, 220 .can_queue = ATA_DEF_QUEUE,
221 .this_id = ATA_SHT_THIS_ID, 221 .this_id = ATA_SHT_THIS_ID,
222 .sg_tablesize = LIBATA_MAX_PRD, 222 .sg_tablesize = LIBATA_MAX_PRD,
223 .max_sectors = ATA_MAX_SECTORS,
224 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 223 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
225 .emulated = ATA_SHT_EMULATED, 224 .emulated = ATA_SHT_EMULATED,
226 .use_clustering = ATA_SHT_USE_CLUSTERING, 225 .use_clustering = ATA_SHT_USE_CLUSTERING,
227 .proc_name = DRV_NAME, 226 .proc_name = DRV_NAME,
228 .dma_boundary = ATA_DMA_BOUNDARY, 227 .dma_boundary = ATA_DMA_BOUNDARY,
229 .slave_configure = ata_scsi_slave_config, 228 .slave_configure = ata_scsi_slave_config,
229 .slave_destroy = ata_scsi_slave_destroy,
230 .bios_param = ata_std_bios_param, 230 .bios_param = ata_std_bios_param,
231 .resume = ata_scsi_device_resume,
232 .suspend = ata_scsi_device_suspend,
231}; 233};
232 234
233static const struct ata_port_operations radisys_pata_ops = { 235static const struct ata_port_operations radisys_pata_ops = {
@@ -310,6 +312,8 @@ static struct pci_driver radisys_pci_driver = {
310 .id_table = radisys_pci_tbl, 312 .id_table = radisys_pci_tbl,
311 .probe = radisys_init_one, 313 .probe = radisys_init_one,
312 .remove = ata_pci_remove_one, 314 .remove = ata_pci_remove_one,
315 .suspend = ata_pci_device_suspend,
316 .resume = ata_pci_device_resume,
313}; 317};
314 318
315static int __init radisys_init(void) 319static int __init radisys_init(void)
diff --git a/drivers/ata/pata_rz1000.c b/drivers/ata/pata_rz1000.c
index 4533b6357d99..3677c642c9f9 100644
--- a/drivers/ata/pata_rz1000.c
+++ b/drivers/ata/pata_rz1000.c
@@ -21,7 +21,7 @@
21#include <linux/libata.h> 21#include <linux/libata.h>
22 22
23#define DRV_NAME "pata_rz1000" 23#define DRV_NAME "pata_rz1000"
24#define DRV_VERSION "0.2.2" 24#define DRV_VERSION "0.2.3"
25 25
26 26
27/** 27/**
@@ -83,14 +83,16 @@ static struct scsi_host_template rz1000_sht = {
83 .can_queue = ATA_DEF_QUEUE, 83 .can_queue = ATA_DEF_QUEUE,
84 .this_id = ATA_SHT_THIS_ID, 84 .this_id = ATA_SHT_THIS_ID,
85 .sg_tablesize = LIBATA_MAX_PRD, 85 .sg_tablesize = LIBATA_MAX_PRD,
86 .max_sectors = ATA_MAX_SECTORS,
87 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 86 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
88 .emulated = ATA_SHT_EMULATED, 87 .emulated = ATA_SHT_EMULATED,
89 .use_clustering = ATA_SHT_USE_CLUSTERING, 88 .use_clustering = ATA_SHT_USE_CLUSTERING,
90 .proc_name = DRV_NAME, 89 .proc_name = DRV_NAME,
91 .dma_boundary = ATA_DMA_BOUNDARY, 90 .dma_boundary = ATA_DMA_BOUNDARY,
92 .slave_configure = ata_scsi_slave_config, 91 .slave_configure = ata_scsi_slave_config,
92 .slave_destroy = ata_scsi_slave_destroy,
93 .bios_param = ata_std_bios_param, 93 .bios_param = ata_std_bios_param,
94 .resume = ata_scsi_device_resume,
95 .suspend = ata_scsi_device_suspend,
94}; 96};
95 97
96static struct ata_port_operations rz1000_port_ops = { 98static struct ata_port_operations rz1000_port_ops = {
@@ -128,6 +130,19 @@ static struct ata_port_operations rz1000_port_ops = {
128 .host_stop = ata_host_stop 130 .host_stop = ata_host_stop
129}; 131};
130 132
133static int rz1000_fifo_disable(struct pci_dev *pdev)
134{
135 u16 reg;
136 /* Be exceptionally paranoid as we must be sure to apply the fix */
137 if (pci_read_config_word(pdev, 0x40, &reg) != 0)
138 return -1;
139 reg &= 0xDFFF;
140 if (pci_write_config_word(pdev, 0x40, reg) != 0)
141 return -1;
142 printk(KERN_INFO DRV_NAME ": disabled chipset readahead.\n");
143 return 0;
144}
145
131/** 146/**
132 * rz1000_init_one - Register RZ1000 ATA PCI device with kernel services 147 * rz1000_init_one - Register RZ1000 ATA PCI device with kernel services
133 * @pdev: PCI device to register 148 * @pdev: PCI device to register
@@ -142,7 +157,6 @@ static int rz1000_init_one (struct pci_dev *pdev, const struct pci_device_id *en
142{ 157{
143 static int printed_version; 158 static int printed_version;
144 struct ata_port_info *port_info[2]; 159 struct ata_port_info *port_info[2];
145 u16 reg;
146 static struct ata_port_info info = { 160 static struct ata_port_info info = {
147 .sht = &rz1000_sht, 161 .sht = &rz1000_sht,
148 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 162 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
@@ -153,23 +167,25 @@ static int rz1000_init_one (struct pci_dev *pdev, const struct pci_device_id *en
153 if (!printed_version++) 167 if (!printed_version++)
154 printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); 168 printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n");
155 169
156 /* Be exceptionally paranoid as we must be sure to apply the fix */ 170 if (rz1000_fifo_disable(pdev) == 0) {
157 if (pci_read_config_word(pdev, 0x40, &reg) != 0) 171 port_info[0] = &info;
158 goto fail; 172 port_info[1] = &info;
159 reg &= 0xDFFF; 173 return ata_pci_init_one(pdev, port_info, 2);
160 if (pci_write_config_word(pdev, 0x40, reg) != 0) 174 }
161 goto fail;
162 printk(KERN_INFO DRV_NAME ": disabled chipset readahead.\n");
163
164 port_info[0] = &info;
165 port_info[1] = &info;
166 return ata_pci_init_one(pdev, port_info, 2);
167fail:
168 printk(KERN_ERR DRV_NAME ": failed to disable read-ahead on chipset..\n"); 175 printk(KERN_ERR DRV_NAME ": failed to disable read-ahead on chipset..\n");
169 /* Not safe to use so skip */ 176 /* Not safe to use so skip */
170 return -ENODEV; 177 return -ENODEV;
171} 178}
172 179
180static int rz1000_reinit_one(struct pci_dev *pdev)
181{
182 /* If this fails on resume (which is a "cant happen" case), we
183 must stop as any progress risks data loss */
184 if (rz1000_fifo_disable(pdev))
185 panic("rz1000 fifo");
186 return ata_pci_device_resume(pdev);
187}
188
173static const struct pci_device_id pata_rz1000[] = { 189static const struct pci_device_id pata_rz1000[] = {
174 { PCI_VDEVICE(PCTECH, PCI_DEVICE_ID_PCTECH_RZ1000), }, 190 { PCI_VDEVICE(PCTECH, PCI_DEVICE_ID_PCTECH_RZ1000), },
175 { PCI_VDEVICE(PCTECH, PCI_DEVICE_ID_PCTECH_RZ1001), }, 191 { PCI_VDEVICE(PCTECH, PCI_DEVICE_ID_PCTECH_RZ1001), },
@@ -181,7 +197,9 @@ static struct pci_driver rz1000_pci_driver = {
181 .name = DRV_NAME, 197 .name = DRV_NAME,
182 .id_table = pata_rz1000, 198 .id_table = pata_rz1000,
183 .probe = rz1000_init_one, 199 .probe = rz1000_init_one,
184 .remove = ata_pci_remove_one 200 .remove = ata_pci_remove_one,
201 .suspend = ata_pci_device_suspend,
202 .resume = rz1000_reinit_one,
185}; 203};
186 204
187static int __init rz1000_init(void) 205static int __init rz1000_init(void)
diff --git a/drivers/ata/pata_sc1200.c b/drivers/ata/pata_sc1200.c
index 067d9d223e35..a3b35bc50394 100644
--- a/drivers/ata/pata_sc1200.c
+++ b/drivers/ata/pata_sc1200.c
@@ -40,7 +40,7 @@
40#include <linux/libata.h> 40#include <linux/libata.h>
41 41
42#define DRV_NAME "sc1200" 42#define DRV_NAME "sc1200"
43#define DRV_VERSION "0.2.3" 43#define DRV_VERSION "0.2.4"
44 44
45#define SC1200_REV_A 0x00 45#define SC1200_REV_A 0x00
46#define SC1200_REV_B1 0x01 46#define SC1200_REV_B1 0x01
@@ -186,14 +186,16 @@ static struct scsi_host_template sc1200_sht = {
186 .can_queue = ATA_DEF_QUEUE, 186 .can_queue = ATA_DEF_QUEUE,
187 .this_id = ATA_SHT_THIS_ID, 187 .this_id = ATA_SHT_THIS_ID,
188 .sg_tablesize = LIBATA_MAX_PRD, 188 .sg_tablesize = LIBATA_MAX_PRD,
189 .max_sectors = ATA_MAX_SECTORS,
190 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 189 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
191 .emulated = ATA_SHT_EMULATED, 190 .emulated = ATA_SHT_EMULATED,
192 .use_clustering = ATA_SHT_USE_CLUSTERING, 191 .use_clustering = ATA_SHT_USE_CLUSTERING,
193 .proc_name = DRV_NAME, 192 .proc_name = DRV_NAME,
194 .dma_boundary = ATA_DMA_BOUNDARY, 193 .dma_boundary = ATA_DMA_BOUNDARY,
195 .slave_configure = ata_scsi_slave_config, 194 .slave_configure = ata_scsi_slave_config,
195 .slave_destroy = ata_scsi_slave_destroy,
196 .bios_param = ata_std_bios_param, 196 .bios_param = ata_std_bios_param,
197 .resume = ata_scsi_device_resume,
198 .suspend = ata_scsi_device_suspend,
197}; 199};
198 200
199static struct ata_port_operations sc1200_port_ops = { 201static struct ata_port_operations sc1200_port_ops = {
@@ -263,7 +265,9 @@ static struct pci_driver sc1200_pci_driver = {
263 .name = DRV_NAME, 265 .name = DRV_NAME,
264 .id_table = sc1200, 266 .id_table = sc1200,
265 .probe = sc1200_init_one, 267 .probe = sc1200_init_one,
266 .remove = ata_pci_remove_one 268 .remove = ata_pci_remove_one,
269 .suspend = ata_pci_device_suspend,
270 .resume = ata_pci_device_resume,
267}; 271};
268 272
269static int __init sc1200_init(void) 273static int __init sc1200_init(void)
diff --git a/drivers/ata/pata_serverworks.c b/drivers/ata/pata_serverworks.c
index 5bbf76ec14a4..f02b6a3b0f10 100644
--- a/drivers/ata/pata_serverworks.c
+++ b/drivers/ata/pata_serverworks.c
@@ -41,7 +41,7 @@
41#include <linux/libata.h> 41#include <linux/libata.h>
42 42
43#define DRV_NAME "pata_serverworks" 43#define DRV_NAME "pata_serverworks"
44#define DRV_VERSION "0.3.7" 44#define DRV_VERSION "0.3.9"
45 45
46#define SVWKS_CSB5_REVISION_NEW 0x92 /* min PCI_REVISION_ID for UDMA5 (A2.0) */ 46#define SVWKS_CSB5_REVISION_NEW 0x92 /* min PCI_REVISION_ID for UDMA5 (A2.0) */
47#define SVWKS_CSB6_REVISION 0xa0 /* min PCI_REVISION_ID for UDMA4 (A1.0) */ 47#define SVWKS_CSB6_REVISION 0xa0 /* min PCI_REVISION_ID for UDMA4 (A1.0) */
@@ -318,14 +318,16 @@ static struct scsi_host_template serverworks_sht = {
318 .can_queue = ATA_DEF_QUEUE, 318 .can_queue = ATA_DEF_QUEUE,
319 .this_id = ATA_SHT_THIS_ID, 319 .this_id = ATA_SHT_THIS_ID,
320 .sg_tablesize = LIBATA_MAX_PRD, 320 .sg_tablesize = LIBATA_MAX_PRD,
321 .max_sectors = ATA_MAX_SECTORS,
322 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 321 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
323 .emulated = ATA_SHT_EMULATED, 322 .emulated = ATA_SHT_EMULATED,
324 .use_clustering = ATA_SHT_USE_CLUSTERING, 323 .use_clustering = ATA_SHT_USE_CLUSTERING,
325 .proc_name = DRV_NAME, 324 .proc_name = DRV_NAME,
326 .dma_boundary = ATA_DMA_BOUNDARY, 325 .dma_boundary = ATA_DMA_BOUNDARY,
327 .slave_configure = ata_scsi_slave_config, 326 .slave_configure = ata_scsi_slave_config,
327 .slave_destroy = ata_scsi_slave_destroy,
328 .bios_param = ata_std_bios_param, 328 .bios_param = ata_std_bios_param,
329 .resume = ata_scsi_device_resume,
330 .suspend = ata_scsi_device_suspend,
329}; 331};
330 332
331static struct ata_port_operations serverworks_osb4_port_ops = { 333static struct ata_port_operations serverworks_osb4_port_ops = {
@@ -553,6 +555,30 @@ static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id
553 return ata_pci_init_one(pdev, port_info, ports); 555 return ata_pci_init_one(pdev, port_info, ports);
554} 556}
555 557
558static int serverworks_reinit_one(struct pci_dev *pdev)
559{
560 /* Force master latency timer to 64 PCI clocks */
561 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x40);
562
563 switch (pdev->device)
564 {
565 case PCI_DEVICE_ID_SERVERWORKS_OSB4IDE:
566 serverworks_fixup_osb4(pdev);
567 break;
568 case PCI_DEVICE_ID_SERVERWORKS_CSB5IDE:
569 ata_pci_clear_simplex(pdev);
570 /* fall through */
571 case PCI_DEVICE_ID_SERVERWORKS_CSB6IDE:
572 case PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2:
573 serverworks_fixup_csb(pdev);
574 break;
575 case PCI_DEVICE_ID_SERVERWORKS_HT1000IDE:
576 serverworks_fixup_ht1000(pdev);
577 break;
578 }
579 return ata_pci_device_resume(pdev);
580}
581
556static const struct pci_device_id serverworks[] = { 582static const struct pci_device_id serverworks[] = {
557 { PCI_VDEVICE(SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_OSB4IDE), 0}, 583 { PCI_VDEVICE(SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_OSB4IDE), 0},
558 { PCI_VDEVICE(SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB5IDE), 2}, 584 { PCI_VDEVICE(SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB5IDE), 2},
@@ -567,7 +593,9 @@ static struct pci_driver serverworks_pci_driver = {
567 .name = DRV_NAME, 593 .name = DRV_NAME,
568 .id_table = serverworks, 594 .id_table = serverworks,
569 .probe = serverworks_init_one, 595 .probe = serverworks_init_one,
570 .remove = ata_pci_remove_one 596 .remove = ata_pci_remove_one,
597 .suspend = ata_pci_device_suspend,
598 .resume = serverworks_reinit_one,
571}; 599};
572 600
573static int __init serverworks_init(void) 601static int __init serverworks_init(void)
diff --git a/drivers/ata/pata_sil680.c b/drivers/ata/pata_sil680.c
index 4a2b72b4be8a..32cf0bfa8921 100644
--- a/drivers/ata/pata_sil680.c
+++ b/drivers/ata/pata_sil680.c
@@ -33,7 +33,7 @@
33#include <linux/libata.h> 33#include <linux/libata.h>
34 34
35#define DRV_NAME "pata_sil680" 35#define DRV_NAME "pata_sil680"
36#define DRV_VERSION "0.3.2" 36#define DRV_VERSION "0.4.1"
37 37
38/** 38/**
39 * sil680_selreg - return register base 39 * sil680_selreg - return register base
@@ -218,13 +218,13 @@ static struct scsi_host_template sil680_sht = {
218 .can_queue = ATA_DEF_QUEUE, 218 .can_queue = ATA_DEF_QUEUE,
219 .this_id = ATA_SHT_THIS_ID, 219 .this_id = ATA_SHT_THIS_ID,
220 .sg_tablesize = LIBATA_MAX_PRD, 220 .sg_tablesize = LIBATA_MAX_PRD,
221 .max_sectors = ATA_MAX_SECTORS,
222 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 221 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
223 .emulated = ATA_SHT_EMULATED, 222 .emulated = ATA_SHT_EMULATED,
224 .use_clustering = ATA_SHT_USE_CLUSTERING, 223 .use_clustering = ATA_SHT_USE_CLUSTERING,
225 .proc_name = DRV_NAME, 224 .proc_name = DRV_NAME,
226 .dma_boundary = ATA_DMA_BOUNDARY, 225 .dma_boundary = ATA_DMA_BOUNDARY,
227 .slave_configure = ata_scsi_slave_config, 226 .slave_configure = ata_scsi_slave_config,
227 .slave_destroy = ata_scsi_slave_destroy,
228 .bios_param = ata_std_bios_param, 228 .bios_param = ata_std_bios_param,
229}; 229};
230 230
@@ -262,32 +262,20 @@ static struct ata_port_operations sil680_port_ops = {
262 .host_stop = ata_host_stop 262 .host_stop = ata_host_stop
263}; 263};
264 264
265static int sil680_init_one(struct pci_dev *pdev, const struct pci_device_id *id) 265/**
266 * sil680_init_chip - chip setup
267 * @pdev: PCI device
268 *
269 * Perform all the chip setup which must be done both when the device
270 * is powered up on boot and when we resume in case we resumed from RAM.
271 * Returns the final clock settings.
272 */
273
274static u8 sil680_init_chip(struct pci_dev *pdev)
266{ 275{
267 static struct ata_port_info info = {
268 .sht = &sil680_sht,
269 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
270 .pio_mask = 0x1f,
271 .mwdma_mask = 0x07,
272 .udma_mask = 0x7f,
273 .port_ops = &sil680_port_ops
274 };
275 static struct ata_port_info info_slow = {
276 .sht = &sil680_sht,
277 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
278 .pio_mask = 0x1f,
279 .mwdma_mask = 0x07,
280 .udma_mask = 0x3f,
281 .port_ops = &sil680_port_ops
282 };
283 static struct ata_port_info *port_info[2] = {&info, &info};
284 static int printed_version;
285 u32 class_rev = 0; 276 u32 class_rev = 0;
286 u8 tmpbyte = 0; 277 u8 tmpbyte = 0;
287 278
288 if (!printed_version++)
289 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
290
291 pci_read_config_dword(pdev, PCI_CLASS_REVISION, &class_rev); 279 pci_read_config_dword(pdev, PCI_CLASS_REVISION, &class_rev);
292 class_rev &= 0xff; 280 class_rev &= 0xff;
293 /* FIXME: double check */ 281 /* FIXME: double check */
@@ -322,8 +310,6 @@ static int sil680_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
322 pci_read_config_byte(pdev, 0x8A, &tmpbyte); 310 pci_read_config_byte(pdev, 0x8A, &tmpbyte);
323 printk(KERN_INFO "sil680: BA5_EN = %d clock = %02X\n", 311 printk(KERN_INFO "sil680: BA5_EN = %d clock = %02X\n",
324 tmpbyte & 1, tmpbyte & 0x30); 312 tmpbyte & 1, tmpbyte & 0x30);
325 if ((tmpbyte & 0x30) == 0)
326 port_info[0] = port_info[1] = &info_slow;
327 313
328 pci_write_config_byte(pdev, 0xA1, 0x72); 314 pci_write_config_byte(pdev, 0xA1, 0x72);
329 pci_write_config_word(pdev, 0xA2, 0x328A); 315 pci_write_config_word(pdev, 0xA2, 0x328A);
@@ -342,11 +328,51 @@ static int sil680_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
342 case 0x20: printk(KERN_INFO "sil680: Using PCI clock.\n");break; 328 case 0x20: printk(KERN_INFO "sil680: Using PCI clock.\n");break;
343 /* This last case is _NOT_ ok */ 329 /* This last case is _NOT_ ok */
344 case 0x30: printk(KERN_ERR "sil680: Clock disabled ?\n"); 330 case 0x30: printk(KERN_ERR "sil680: Clock disabled ?\n");
345 return -EIO; 331 }
332 return tmpbyte & 0x30;
333}
334
335static int sil680_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
336{
337 static struct ata_port_info info = {
338 .sht = &sil680_sht,
339 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
340 .pio_mask = 0x1f,
341 .mwdma_mask = 0x07,
342 .udma_mask = 0x7f,
343 .port_ops = &sil680_port_ops
344 };
345 static struct ata_port_info info_slow = {
346 .sht = &sil680_sht,
347 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
348 .pio_mask = 0x1f,
349 .mwdma_mask = 0x07,
350 .udma_mask = 0x3f,
351 .port_ops = &sil680_port_ops
352 };
353 static struct ata_port_info *port_info[2] = {&info, &info};
354 static int printed_version;
355
356 if (!printed_version++)
357 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
358
359 switch(sil680_init_chip(pdev))
360 {
361 case 0:
362 port_info[0] = port_info[1] = &info_slow;
363 break;
364 case 0x30:
365 return -ENODEV;
346 } 366 }
347 return ata_pci_init_one(pdev, port_info, 2); 367 return ata_pci_init_one(pdev, port_info, 2);
348} 368}
349 369
370static int sil680_reinit_one(struct pci_dev *pdev)
371{
372 sil680_init_chip(pdev);
373 return ata_pci_device_resume(pdev);
374}
375
350static const struct pci_device_id sil680[] = { 376static const struct pci_device_id sil680[] = {
351 { PCI_VDEVICE(CMD, PCI_DEVICE_ID_SII_680), }, 377 { PCI_VDEVICE(CMD, PCI_DEVICE_ID_SII_680), },
352 378
@@ -357,7 +383,9 @@ static struct pci_driver sil680_pci_driver = {
357 .name = DRV_NAME, 383 .name = DRV_NAME,
358 .id_table = sil680, 384 .id_table = sil680,
359 .probe = sil680_init_one, 385 .probe = sil680_init_one,
360 .remove = ata_pci_remove_one 386 .remove = ata_pci_remove_one,
387 .suspend = ata_pci_device_suspend,
388 .resume = sil680_reinit_one,
361}; 389};
362 390
363static int __init sil680_init(void) 391static int __init sil680_init(void)
diff --git a/drivers/ata/pata_sis.c b/drivers/ata/pata_sis.c
index b9ffafb4198c..916cedb3d755 100644
--- a/drivers/ata/pata_sis.c
+++ b/drivers/ata/pata_sis.c
@@ -34,7 +34,7 @@
34#include <linux/ata.h> 34#include <linux/ata.h>
35 35
36#define DRV_NAME "pata_sis" 36#define DRV_NAME "pata_sis"
37#define DRV_VERSION "0.4.4" 37#define DRV_VERSION "0.4.5"
38 38
39struct sis_chipset { 39struct sis_chipset {
40 u16 device; /* PCI host ID */ 40 u16 device; /* PCI host ID */
@@ -538,14 +538,16 @@ static struct scsi_host_template sis_sht = {
538 .can_queue = ATA_DEF_QUEUE, 538 .can_queue = ATA_DEF_QUEUE,
539 .this_id = ATA_SHT_THIS_ID, 539 .this_id = ATA_SHT_THIS_ID,
540 .sg_tablesize = LIBATA_MAX_PRD, 540 .sg_tablesize = LIBATA_MAX_PRD,
541 .max_sectors = ATA_MAX_SECTORS,
542 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 541 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
543 .emulated = ATA_SHT_EMULATED, 542 .emulated = ATA_SHT_EMULATED,
544 .use_clustering = ATA_SHT_USE_CLUSTERING, 543 .use_clustering = ATA_SHT_USE_CLUSTERING,
545 .proc_name = DRV_NAME, 544 .proc_name = DRV_NAME,
546 .dma_boundary = ATA_DMA_BOUNDARY, 545 .dma_boundary = ATA_DMA_BOUNDARY,
547 .slave_configure = ata_scsi_slave_config, 546 .slave_configure = ata_scsi_slave_config,
547 .slave_destroy = ata_scsi_slave_destroy,
548 .bios_param = ata_std_bios_param, 548 .bios_param = ata_std_bios_param,
549 .resume = ata_scsi_device_resume,
550 .suspend = ata_scsi_device_suspend,
549}; 551};
550 552
551static const struct ata_port_operations sis_133_ops = { 553static const struct ata_port_operations sis_133_ops = {
@@ -999,6 +1001,8 @@ static struct pci_driver sis_pci_driver = {
999 .id_table = sis_pci_tbl, 1001 .id_table = sis_pci_tbl,
1000 .probe = sis_init_one, 1002 .probe = sis_init_one,
1001 .remove = ata_pci_remove_one, 1003 .remove = ata_pci_remove_one,
1004 .suspend = ata_pci_device_suspend,
1005 .resume = ata_pci_device_resume,
1002}; 1006};
1003 1007
1004static int __init sis_init(void) 1008static int __init sis_init(void)
diff --git a/drivers/ata/pata_sl82c105.c b/drivers/ata/pata_sl82c105.c
index 08a6dc88676f..e94f515ef54b 100644
--- a/drivers/ata/pata_sl82c105.c
+++ b/drivers/ata/pata_sl82c105.c
@@ -230,13 +230,13 @@ static struct scsi_host_template sl82c105_sht = {
230 .can_queue = ATA_DEF_QUEUE, 230 .can_queue = ATA_DEF_QUEUE,
231 .this_id = ATA_SHT_THIS_ID, 231 .this_id = ATA_SHT_THIS_ID,
232 .sg_tablesize = LIBATA_MAX_PRD, 232 .sg_tablesize = LIBATA_MAX_PRD,
233 .max_sectors = ATA_MAX_SECTORS,
234 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 233 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
235 .emulated = ATA_SHT_EMULATED, 234 .emulated = ATA_SHT_EMULATED,
236 .use_clustering = ATA_SHT_USE_CLUSTERING, 235 .use_clustering = ATA_SHT_USE_CLUSTERING,
237 .proc_name = DRV_NAME, 236 .proc_name = DRV_NAME,
238 .dma_boundary = ATA_DMA_BOUNDARY, 237 .dma_boundary = ATA_DMA_BOUNDARY,
239 .slave_configure = ata_scsi_slave_config, 238 .slave_configure = ata_scsi_slave_config,
239 .slave_destroy = ata_scsi_slave_destroy,
240 .bios_param = ata_std_bios_param, 240 .bios_param = ata_std_bios_param,
241}; 241};
242 242
diff --git a/drivers/ata/pata_triflex.c b/drivers/ata/pata_triflex.c
index 9640f80e8b0d..a142971f1307 100644
--- a/drivers/ata/pata_triflex.c
+++ b/drivers/ata/pata_triflex.c
@@ -43,7 +43,7 @@
43#include <linux/libata.h> 43#include <linux/libata.h>
44 44
45#define DRV_NAME "pata_triflex" 45#define DRV_NAME "pata_triflex"
46#define DRV_VERSION "0.2.5" 46#define DRV_VERSION "0.2.7"
47 47
48/** 48/**
49 * triflex_prereset - probe begin 49 * triflex_prereset - probe begin
@@ -185,14 +185,16 @@ static struct scsi_host_template triflex_sht = {
185 .can_queue = ATA_DEF_QUEUE, 185 .can_queue = ATA_DEF_QUEUE,
186 .this_id = ATA_SHT_THIS_ID, 186 .this_id = ATA_SHT_THIS_ID,
187 .sg_tablesize = LIBATA_MAX_PRD, 187 .sg_tablesize = LIBATA_MAX_PRD,
188 .max_sectors = ATA_MAX_SECTORS,
189 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 188 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
190 .emulated = ATA_SHT_EMULATED, 189 .emulated = ATA_SHT_EMULATED,
191 .use_clustering = ATA_SHT_USE_CLUSTERING, 190 .use_clustering = ATA_SHT_USE_CLUSTERING,
192 .proc_name = DRV_NAME, 191 .proc_name = DRV_NAME,
193 .dma_boundary = ATA_DMA_BOUNDARY, 192 .dma_boundary = ATA_DMA_BOUNDARY,
194 .slave_configure = ata_scsi_slave_config, 193 .slave_configure = ata_scsi_slave_config,
194 .slave_destroy = ata_scsi_slave_destroy,
195 .bios_param = ata_std_bios_param, 195 .bios_param = ata_std_bios_param,
196 .resume = ata_scsi_device_resume,
197 .suspend = ata_scsi_device_suspend,
196}; 198};
197 199
198static struct ata_port_operations triflex_port_ops = { 200static struct ata_port_operations triflex_port_ops = {
@@ -257,7 +259,9 @@ static struct pci_driver triflex_pci_driver = {
257 .name = DRV_NAME, 259 .name = DRV_NAME,
258 .id_table = triflex, 260 .id_table = triflex,
259 .probe = triflex_init_one, 261 .probe = triflex_init_one,
260 .remove = ata_pci_remove_one 262 .remove = ata_pci_remove_one,
263 .suspend = ata_pci_device_suspend,
264 .resume = ata_pci_device_resume,
261}; 265};
262 266
263static int __init triflex_init(void) 267static int __init triflex_init(void)
diff --git a/drivers/ata/pata_via.c b/drivers/ata/pata_via.c
index 1e7be9eee9c3..cc09d47fb927 100644
--- a/drivers/ata/pata_via.c
+++ b/drivers/ata/pata_via.c
@@ -23,6 +23,7 @@
23 * VIA VT8233c - UDMA100 23 * VIA VT8233c - UDMA100
24 * VIA VT8235 - UDMA133 24 * VIA VT8235 - UDMA133
25 * VIA VT8237 - UDMA133 25 * VIA VT8237 - UDMA133
26 * VIA VT8251 - UDMA133
26 * 27 *
27 * Most registers remain compatible across chips. Others start reserved 28 * Most registers remain compatible across chips. Others start reserved
28 * and acquire sensible semantics if set to 1 (eg cable detect). A few 29 * and acquire sensible semantics if set to 1 (eg cable detect). A few
@@ -60,7 +61,7 @@
60#include <linux/libata.h> 61#include <linux/libata.h>
61 62
62#define DRV_NAME "pata_via" 63#define DRV_NAME "pata_via"
63#define DRV_VERSION "0.1.14" 64#define DRV_VERSION "0.2.0"
64 65
65/* 66/*
66 * The following comes directly from Vojtech Pavlik's ide/pci/via82cxxx 67 * The following comes directly from Vojtech Pavlik's ide/pci/via82cxxx
@@ -94,6 +95,7 @@ static const struct via_isa_bridge {
94 u8 rev_max; 95 u8 rev_max;
95 u16 flags; 96 u16 flags;
96} via_isa_bridges[] = { 97} via_isa_bridges[] = {
98 { "vt8251", PCI_DEVICE_ID_VIA_8251, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
97 { "cx700", PCI_DEVICE_ID_VIA_CX700, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST }, 99 { "cx700", PCI_DEVICE_ID_VIA_CX700, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
98 { "vt6410", PCI_DEVICE_ID_VIA_6410, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST | VIA_NO_ENABLES}, 100 { "vt6410", PCI_DEVICE_ID_VIA_6410, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST | VIA_NO_ENABLES},
99 { "vt8237a", PCI_DEVICE_ID_VIA_8237A, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST }, 101 { "vt8237a", PCI_DEVICE_ID_VIA_8237A, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
@@ -288,14 +290,16 @@ static struct scsi_host_template via_sht = {
288 .can_queue = ATA_DEF_QUEUE, 290 .can_queue = ATA_DEF_QUEUE,
289 .this_id = ATA_SHT_THIS_ID, 291 .this_id = ATA_SHT_THIS_ID,
290 .sg_tablesize = LIBATA_MAX_PRD, 292 .sg_tablesize = LIBATA_MAX_PRD,
291 .max_sectors = ATA_MAX_SECTORS,
292 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 293 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
293 .emulated = ATA_SHT_EMULATED, 294 .emulated = ATA_SHT_EMULATED,
294 .use_clustering = ATA_SHT_USE_CLUSTERING, 295 .use_clustering = ATA_SHT_USE_CLUSTERING,
295 .proc_name = DRV_NAME, 296 .proc_name = DRV_NAME,
296 .dma_boundary = ATA_DMA_BOUNDARY, 297 .dma_boundary = ATA_DMA_BOUNDARY,
297 .slave_configure = ata_scsi_slave_config, 298 .slave_configure = ata_scsi_slave_config,
299 .slave_destroy = ata_scsi_slave_destroy,
298 .bios_param = ata_std_bios_param, 300 .bios_param = ata_std_bios_param,
301 .resume = ata_scsi_device_resume,
302 .suspend = ata_scsi_device_suspend,
299}; 303};
300 304
301static struct ata_port_operations via_port_ops = { 305static struct ata_port_operations via_port_ops = {
@@ -369,8 +373,42 @@ static struct ata_port_operations via_port_ops_noirq = {
369}; 373};
370 374
371/** 375/**
376 * via_config_fifo - set up the FIFO
377 * @pdev: PCI device
378 * @flags: configuration flags
379 *
380 * Set the FIFO properties for this device if neccessary. Used both on
381 * set up and on and the resume path
382 */
383
384static void via_config_fifo(struct pci_dev *pdev, unsigned int flags)
385{
386 u8 enable;
387
388 /* 0x40 low bits indicate enabled channels */
389 pci_read_config_byte(pdev, 0x40 , &enable);
390 enable &= 3;
391
392 if (flags & VIA_SET_FIFO) {
393 u8 fifo_setting[4] = {0x00, 0x60, 0x00, 0x20};
394 u8 fifo;
395
396 pci_read_config_byte(pdev, 0x43, &fifo);
397
398 /* Clear PREQ# until DDACK# for errata */
399 if (flags & VIA_BAD_PREQ)
400 fifo &= 0x7F;
401 else
402 fifo &= 0x9f;
403 /* Turn on FIFO for enabled channels */
404 fifo |= fifo_setting[enable];
405 pci_write_config_byte(pdev, 0x43, fifo);
406 }
407}
408
409/**
372 * via_init_one - discovery callback 410 * via_init_one - discovery callback
373 * @pdev: PCI device ID 411 * @pdev: PCI device
374 * @id: PCI table info 412 * @id: PCI table info
375 * 413 *
376 * A VIA IDE interface has been discovered. Figure out what revision 414 * A VIA IDE interface has been discovered. Figure out what revision
@@ -382,7 +420,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
382 /* Early VIA without UDMA support */ 420 /* Early VIA without UDMA support */
383 static struct ata_port_info via_mwdma_info = { 421 static struct ata_port_info via_mwdma_info = {
384 .sht = &via_sht, 422 .sht = &via_sht,
385 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 423 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING,
386 .pio_mask = 0x1f, 424 .pio_mask = 0x1f,
387 .mwdma_mask = 0x07, 425 .mwdma_mask = 0x07,
388 .port_ops = &via_port_ops 426 .port_ops = &via_port_ops
@@ -390,7 +428,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
390 /* Ditto with IRQ masking required */ 428 /* Ditto with IRQ masking required */
391 static struct ata_port_info via_mwdma_info_borked = { 429 static struct ata_port_info via_mwdma_info_borked = {
392 .sht = &via_sht, 430 .sht = &via_sht,
393 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 431 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING,
394 .pio_mask = 0x1f, 432 .pio_mask = 0x1f,
395 .mwdma_mask = 0x07, 433 .mwdma_mask = 0x07,
396 .port_ops = &via_port_ops_noirq, 434 .port_ops = &via_port_ops_noirq,
@@ -398,7 +436,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
398 /* VIA UDMA 33 devices (and borked 66) */ 436 /* VIA UDMA 33 devices (and borked 66) */
399 static struct ata_port_info via_udma33_info = { 437 static struct ata_port_info via_udma33_info = {
400 .sht = &via_sht, 438 .sht = &via_sht,
401 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 439 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING,
402 .pio_mask = 0x1f, 440 .pio_mask = 0x1f,
403 .mwdma_mask = 0x07, 441 .mwdma_mask = 0x07,
404 .udma_mask = 0x7, 442 .udma_mask = 0x7,
@@ -407,7 +445,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
407 /* VIA UDMA 66 devices */ 445 /* VIA UDMA 66 devices */
408 static struct ata_port_info via_udma66_info = { 446 static struct ata_port_info via_udma66_info = {
409 .sht = &via_sht, 447 .sht = &via_sht,
410 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 448 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING,
411 .pio_mask = 0x1f, 449 .pio_mask = 0x1f,
412 .mwdma_mask = 0x07, 450 .mwdma_mask = 0x07,
413 .udma_mask = 0x1f, 451 .udma_mask = 0x1f,
@@ -416,7 +454,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
416 /* VIA UDMA 100 devices */ 454 /* VIA UDMA 100 devices */
417 static struct ata_port_info via_udma100_info = { 455 static struct ata_port_info via_udma100_info = {
418 .sht = &via_sht, 456 .sht = &via_sht,
419 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 457 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING,
420 .pio_mask = 0x1f, 458 .pio_mask = 0x1f,
421 .mwdma_mask = 0x07, 459 .mwdma_mask = 0x07,
422 .udma_mask = 0x3f, 460 .udma_mask = 0x3f,
@@ -425,7 +463,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
425 /* UDMA133 with bad AST (All current 133) */ 463 /* UDMA133 with bad AST (All current 133) */
426 static struct ata_port_info via_udma133_info = { 464 static struct ata_port_info via_udma133_info = {
427 .sht = &via_sht, 465 .sht = &via_sht,
428 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 466 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING,
429 .pio_mask = 0x1f, 467 .pio_mask = 0x1f,
430 .mwdma_mask = 0x07, 468 .mwdma_mask = 0x07,
431 .udma_mask = 0x7f, /* FIXME: should check north bridge */ 469 .udma_mask = 0x7f, /* FIXME: should check north bridge */
@@ -470,21 +508,8 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
470 } 508 }
471 509
472 /* Initialise the FIFO for the enabled channels. */ 510 /* Initialise the FIFO for the enabled channels. */
473 if (config->flags & VIA_SET_FIFO) { 511 via_config_fifo(pdev, config->flags);
474 u8 fifo_setting[4] = {0x00, 0x60, 0x00, 0x20}; 512
475 u8 fifo;
476
477 pci_read_config_byte(pdev, 0x43, &fifo);
478
479 /* Clear PREQ# until DDACK# for errata */
480 if (config->flags & VIA_BAD_PREQ)
481 fifo &= 0x7F;
482 else
483 fifo &= 0x9f;
484 /* Turn on FIFO for enabled channels */
485 fifo |= fifo_setting[enable];
486 pci_write_config_byte(pdev, 0x43, fifo);
487 }
488 /* Clock set up */ 513 /* Clock set up */
489 switch(config->flags & VIA_UDMA) { 514 switch(config->flags & VIA_UDMA) {
490 case VIA_UDMA_NONE: 515 case VIA_UDMA_NONE:
@@ -528,6 +553,39 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
528 return ata_pci_init_one(pdev, port_info, 2); 553 return ata_pci_init_one(pdev, port_info, 2);
529} 554}
530 555
556/**
557 * via_reinit_one - reinit after resume
558 * @pdev; PCI device
559 *
560 * Called when the VIA PATA device is resumed. We must then
561 * reconfigure the fifo and other setup we may have altered. In
562 * addition the kernel needs to have the resume methods on PCI
563 * quirk supported.
564 */
565
566static int via_reinit_one(struct pci_dev *pdev)
567{
568 u32 timing;
569 struct ata_host *host = dev_get_drvdata(&pdev->dev);
570 const struct via_isa_bridge *config = host->private_data;
571
572 via_config_fifo(pdev, config->flags);
573
574 if ((config->flags & VIA_UDMA) == VIA_UDMA_66) {
575 /* The 66 MHz devices require we enable the clock */
576 pci_read_config_dword(pdev, 0x50, &timing);
577 timing |= 0x80008;
578 pci_write_config_dword(pdev, 0x50, timing);
579 }
580 if (config->flags & VIA_BAD_CLK66) {
581 /* Disable the 66MHz clock on problem devices */
582 pci_read_config_dword(pdev, 0x50, &timing);
583 timing &= ~0x80008;
584 pci_write_config_dword(pdev, 0x50, timing);
585 }
586 return ata_pci_device_resume(pdev);
587}
588
531static const struct pci_device_id via[] = { 589static const struct pci_device_id via[] = {
532 { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_82C576_1), }, 590 { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_82C576_1), },
533 { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_82C586_1), }, 591 { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_82C586_1), },
@@ -541,7 +599,9 @@ static struct pci_driver via_pci_driver = {
541 .name = DRV_NAME, 599 .name = DRV_NAME,
542 .id_table = via, 600 .id_table = via,
543 .probe = via_init_one, 601 .probe = via_init_one,
544 .remove = ata_pci_remove_one 602 .remove = ata_pci_remove_one,
603 .suspend = ata_pci_device_suspend,
604 .resume = via_reinit_one,
545}; 605};
546 606
547static int __init via_init(void) 607static int __init via_init(void)
diff --git a/drivers/ata/pata_winbond.c b/drivers/ata/pata_winbond.c
new file mode 100644
index 000000000000..3ea345cde52e
--- /dev/null
+++ b/drivers/ata/pata_winbond.c
@@ -0,0 +1,306 @@
1/*
2 * pata_winbond.c - Winbond VLB ATA controllers
3 * (C) 2006 Red Hat <alan@redhat.com>
4 *
5 * Support for the Winbond 83759A when operating in advanced mode.
6 * Multichip mode is not currently supported.
7 */
8
9#include <linux/kernel.h>
10#include <linux/module.h>
11#include <linux/pci.h>
12#include <linux/init.h>
13#include <linux/blkdev.h>
14#include <linux/delay.h>
15#include <scsi/scsi_host.h>
16#include <linux/libata.h>
17#include <linux/platform_device.h>
18
19#define DRV_NAME "pata_winbond"
20#define DRV_VERSION "0.0.1"
21
22#define NR_HOST 4 /* Two winbond controllers, two channels each */
23
24struct winbond_data {
25 unsigned long config;
26 struct platform_device *platform_dev;
27};
28
29static struct ata_host *winbond_host[NR_HOST];
30static struct winbond_data winbond_data[NR_HOST];
31static int nr_winbond_host;
32
33#ifdef MODULE
34static int probe_winbond = 1;
35#else
36static int probe_winbond;
37#endif
38
39static spinlock_t winbond_lock = SPIN_LOCK_UNLOCKED;
40
41static void winbond_writecfg(unsigned long port, u8 reg, u8 val)
42{
43 unsigned long flags;
44 spin_lock_irqsave(&winbond_lock, flags);
45 outb(reg, port + 0x01);
46 outb(val, port + 0x02);
47 spin_unlock_irqrestore(&winbond_lock, flags);
48}
49
50static u8 winbond_readcfg(unsigned long port, u8 reg)
51{
52 u8 val;
53
54 unsigned long flags;
55 spin_lock_irqsave(&winbond_lock, flags);
56 outb(reg, port + 0x01);
57 val = inb(port + 0x02);
58 spin_unlock_irqrestore(&winbond_lock, flags);
59
60 return val;
61}
62
63static void winbond_set_piomode(struct ata_port *ap, struct ata_device *adev)
64{
65 struct ata_timing t;
66 struct winbond_data *winbond = ap->host->private_data;
67 int active, recovery;
68 u8 reg;
69 int timing = 0x88 + (ap->port_no * 4) + (adev->devno * 2);
70
71 reg = winbond_readcfg(winbond->config, 0x81);
72
73 /* Get the timing data in cycles */
74 if (reg & 0x40) /* Fast VLB bus, assume 50MHz */
75 ata_timing_compute(adev, adev->pio_mode, &t, 20000, 1000);
76 else
77 ata_timing_compute(adev, adev->pio_mode, &t, 30303, 1000);
78
79 active = (FIT(t.active, 3, 17) - 1) & 0x0F;
80 recovery = (FIT(t.recover, 1, 15) + 1) & 0x0F;
81 timing = (active << 4) | recovery;
82 winbond_writecfg(winbond->config, timing, reg);
83
84 /* Load the setup timing */
85
86 reg = 0x35;
87 if (adev->class != ATA_DEV_ATA)
88 reg |= 0x08; /* FIFO off */
89 if (!ata_pio_need_iordy(adev))
90 reg |= 0x02; /* IORDY off */
91 reg |= (FIT(t.setup, 0, 3) << 6);
92 winbond_writecfg(winbond->config, timing + 1, reg);
93}
94
95
96static void winbond_data_xfer(struct ata_device *adev, unsigned char *buf, unsigned int buflen, int write_data)
97{
98 struct ata_port *ap = adev->ap;
99 int slop = buflen & 3;
100
101 if (ata_id_has_dword_io(adev->id)) {
102 if (write_data)
103 outsl(ap->ioaddr.data_addr, buf, buflen >> 2);
104 else
105 insl(ap->ioaddr.data_addr, buf, buflen >> 2);
106
107 if (unlikely(slop)) {
108 u32 pad;
109 if (write_data) {
110 memcpy(&pad, buf + buflen - slop, slop);
111 outl(le32_to_cpu(pad), ap->ioaddr.data_addr);
112 } else {
113 pad = cpu_to_le16(inl(ap->ioaddr.data_addr));
114 memcpy(buf + buflen - slop, &pad, slop);
115 }
116 }
117 } else
118 ata_pio_data_xfer(adev, buf, buflen, write_data);
119}
120
121static struct scsi_host_template winbond_sht = {
122 .module = THIS_MODULE,
123 .name = DRV_NAME,
124 .ioctl = ata_scsi_ioctl,
125 .queuecommand = ata_scsi_queuecmd,
126 .can_queue = ATA_DEF_QUEUE,
127 .this_id = ATA_SHT_THIS_ID,
128 .sg_tablesize = LIBATA_MAX_PRD,
129 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
130 .emulated = ATA_SHT_EMULATED,
131 .use_clustering = ATA_SHT_USE_CLUSTERING,
132 .proc_name = DRV_NAME,
133 .dma_boundary = ATA_DMA_BOUNDARY,
134 .slave_configure = ata_scsi_slave_config,
135 .slave_destroy = ata_scsi_slave_destroy,
136 .bios_param = ata_std_bios_param,
137};
138
139static struct ata_port_operations winbond_port_ops = {
140 .port_disable = ata_port_disable,
141 .set_piomode = winbond_set_piomode,
142
143 .tf_load = ata_tf_load,
144 .tf_read = ata_tf_read,
145 .check_status = ata_check_status,
146 .exec_command = ata_exec_command,
147 .dev_select = ata_std_dev_select,
148
149 .freeze = ata_bmdma_freeze,
150 .thaw = ata_bmdma_thaw,
151 .error_handler = ata_bmdma_error_handler,
152 .post_internal_cmd = ata_bmdma_post_internal_cmd,
153
154 .qc_prep = ata_qc_prep,
155 .qc_issue = ata_qc_issue_prot,
156
157 .data_xfer = winbond_data_xfer,
158
159 .irq_handler = ata_interrupt,
160 .irq_clear = ata_bmdma_irq_clear,
161
162 .port_start = ata_port_start,
163 .port_stop = ata_port_stop,
164 .host_stop = ata_host_stop
165};
166
167/**
168 * winbond_init_one - attach a winbond interface
169 * @type: Type to display
170 * @io: I/O port start
171 * @irq: interrupt line
172 * @fast: True if on a > 33Mhz VLB
173 *
174 * Register a VLB bus IDE interface. Such interfaces are PIO and we
175 * assume do not support IRQ sharing.
176 */
177
178static __init int winbond_init_one(unsigned long port)
179{
180 struct ata_probe_ent ae;
181 struct platform_device *pdev;
182 int ret;
183 u8 reg;
184 int i;
185
186 reg = winbond_readcfg(port, 0x81);
187 reg |= 0x80; /* jumpered mode off */
188 winbond_writecfg(port, 0x81, reg);
189 reg = winbond_readcfg(port, 0x83);
190 reg |= 0xF0; /* local control */
191 winbond_writecfg(port, 0x83, reg);
192 reg = winbond_readcfg(port, 0x85);
193 reg |= 0xF0; /* programmable timing */
194 winbond_writecfg(port, 0x85, reg);
195
196 reg = winbond_readcfg(port, 0x81);
197
198 if (!(reg & 0x03)) /* Disabled */
199 return 0;
200
201 for (i = 0; i < 2 ; i ++) {
202
203 if (reg & (1 << i)) {
204 /*
205 * Fill in a probe structure first of all
206 */
207
208 pdev = platform_device_register_simple(DRV_NAME, nr_winbond_host, NULL, 0);
209 if (pdev == NULL)
210 return -ENOMEM;
211
212 memset(&ae, 0, sizeof(struct ata_probe_ent));
213 INIT_LIST_HEAD(&ae.node);
214 ae.dev = &pdev->dev;
215
216 ae.port_ops = &winbond_port_ops;
217 ae.pio_mask = 0x1F;
218
219 ae.sht = &winbond_sht;
220
221 ae.n_ports = 1;
222 ae.irq = 14 + i;
223 ae.irq_flags = 0;
224 ae.port_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST;
225 ae.port[0].cmd_addr = 0x1F0 - (0x80 * i);
226 ae.port[0].altstatus_addr = ae.port[0].cmd_addr + 0x0206;
227 ae.port[0].ctl_addr = ae.port[0].altstatus_addr;
228 ata_std_ports(&ae.port[0]);
229 /*
230 * Hook in a private data structure per channel
231 */
232 ae.private_data = &winbond_data[nr_winbond_host];
233 winbond_data[nr_winbond_host].config = port;
234 winbond_data[nr_winbond_host].platform_dev = pdev;
235
236 ret = ata_device_add(&ae);
237 if (ret == 0) {
238 platform_device_unregister(pdev);
239 return -ENODEV;
240 }
241 winbond_host[nr_winbond_host++] = dev_get_drvdata(&pdev->dev);
242 }
243 }
244
245 return 0;
246}
247
248/**
249 * winbond_init - attach winbond interfaces
250 *
251 * Attach winbond IDE interfaces by scanning the ports it may occupy.
252 */
253
254static __init int winbond_init(void)
255{
256 static const unsigned long config[2] = { 0x130, 0x1B0 };
257
258 int ct = 0;
259 int i;
260
261 if (probe_winbond == 0)
262 return -ENODEV;
263
264 /*
265 * Check both base addresses
266 */
267
268 for (i = 0; i < 2; i++) {
269 if (probe_winbond & (1<<i)) {
270 int ret = 0;
271 unsigned long port = config[i];
272
273 if (request_region(port, 2, "pata_winbond")) {
274 ret = winbond_init_one(port);
275 if(ret <= 0)
276 release_region(port, 2);
277 else ct+= ret;
278 }
279 }
280 }
281 if (ct != 0)
282 return 0;
283 return -ENODEV;
284}
285
286static __exit void winbond_exit(void)
287{
288 int i;
289
290 for (i = 0; i < nr_winbond_host; i++) {
291 ata_host_remove(winbond_host[i]);
292 release_region(winbond_data[i].config, 2);
293 platform_device_unregister(winbond_data[i].platform_dev);
294 }
295}
296
297MODULE_AUTHOR("Alan Cox");
298MODULE_DESCRIPTION("low-level driver for Winbond VL ATA");
299MODULE_LICENSE("GPL");
300MODULE_VERSION(DRV_VERSION);
301
302module_init(winbond_init);
303module_exit(winbond_exit);
304
305module_param(probe_winbond, int, 0);
306
diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c
index d65ebfd7c7b2..0d316eb3c214 100644
--- a/drivers/ata/sata_nv.c
+++ b/drivers/ata/sata_nv.c
@@ -29,6 +29,11 @@
29 * NV-specific details such as register offsets, SATA phy location, 29 * NV-specific details such as register offsets, SATA phy location,
30 * hotplug info, etc. 30 * hotplug info, etc.
31 * 31 *
32 * CK804/MCP04 controllers support an alternate programming interface
33 * similar to the ADMA specification (with some modifications).
34 * This allows the use of NCQ. Non-DMA-mapped ATA commands are still
35 * sent through the legacy interface.
36 *
32 */ 37 */
33 38
34#include <linux/kernel.h> 39#include <linux/kernel.h>
@@ -40,10 +45,13 @@
40#include <linux/interrupt.h> 45#include <linux/interrupt.h>
41#include <linux/device.h> 46#include <linux/device.h>
42#include <scsi/scsi_host.h> 47#include <scsi/scsi_host.h>
48#include <scsi/scsi_device.h>
43#include <linux/libata.h> 49#include <linux/libata.h>
44 50
45#define DRV_NAME "sata_nv" 51#define DRV_NAME "sata_nv"
46#define DRV_VERSION "2.0" 52#define DRV_VERSION "3.2"
53
54#define NV_ADMA_DMA_BOUNDARY 0xffffffffUL
47 55
48enum { 56enum {
49 NV_PORTS = 2, 57 NV_PORTS = 2,
@@ -78,8 +86,138 @@ enum {
78 // For PCI config register 20 86 // For PCI config register 20
79 NV_MCP_SATA_CFG_20 = 0x50, 87 NV_MCP_SATA_CFG_20 = 0x50,
80 NV_MCP_SATA_CFG_20_SATA_SPACE_EN = 0x04, 88 NV_MCP_SATA_CFG_20_SATA_SPACE_EN = 0x04,
89 NV_MCP_SATA_CFG_20_PORT0_EN = (1 << 17),
90 NV_MCP_SATA_CFG_20_PORT1_EN = (1 << 16),
91 NV_MCP_SATA_CFG_20_PORT0_PWB_EN = (1 << 14),
92 NV_MCP_SATA_CFG_20_PORT1_PWB_EN = (1 << 12),
93
94 NV_ADMA_MAX_CPBS = 32,
95 NV_ADMA_CPB_SZ = 128,
96 NV_ADMA_APRD_SZ = 16,
97 NV_ADMA_SGTBL_LEN = (1024 - NV_ADMA_CPB_SZ) /
98 NV_ADMA_APRD_SZ,
99 NV_ADMA_SGTBL_TOTAL_LEN = NV_ADMA_SGTBL_LEN + 5,
100 NV_ADMA_SGTBL_SZ = NV_ADMA_SGTBL_LEN * NV_ADMA_APRD_SZ,
101 NV_ADMA_PORT_PRIV_DMA_SZ = NV_ADMA_MAX_CPBS *
102 (NV_ADMA_CPB_SZ + NV_ADMA_SGTBL_SZ),
103
104 /* BAR5 offset to ADMA general registers */
105 NV_ADMA_GEN = 0x400,
106 NV_ADMA_GEN_CTL = 0x00,
107 NV_ADMA_NOTIFIER_CLEAR = 0x30,
108
109 /* BAR5 offset to ADMA ports */
110 NV_ADMA_PORT = 0x480,
111
112 /* size of ADMA port register space */
113 NV_ADMA_PORT_SIZE = 0x100,
114
115 /* ADMA port registers */
116 NV_ADMA_CTL = 0x40,
117 NV_ADMA_CPB_COUNT = 0x42,
118 NV_ADMA_NEXT_CPB_IDX = 0x43,
119 NV_ADMA_STAT = 0x44,
120 NV_ADMA_CPB_BASE_LOW = 0x48,
121 NV_ADMA_CPB_BASE_HIGH = 0x4C,
122 NV_ADMA_APPEND = 0x50,
123 NV_ADMA_NOTIFIER = 0x68,
124 NV_ADMA_NOTIFIER_ERROR = 0x6C,
125
126 /* NV_ADMA_CTL register bits */
127 NV_ADMA_CTL_HOTPLUG_IEN = (1 << 0),
128 NV_ADMA_CTL_CHANNEL_RESET = (1 << 5),
129 NV_ADMA_CTL_GO = (1 << 7),
130 NV_ADMA_CTL_AIEN = (1 << 8),
131 NV_ADMA_CTL_READ_NON_COHERENT = (1 << 11),
132 NV_ADMA_CTL_WRITE_NON_COHERENT = (1 << 12),
133
134 /* CPB response flag bits */
135 NV_CPB_RESP_DONE = (1 << 0),
136 NV_CPB_RESP_ATA_ERR = (1 << 3),
137 NV_CPB_RESP_CMD_ERR = (1 << 4),
138 NV_CPB_RESP_CPB_ERR = (1 << 7),
139
140 /* CPB control flag bits */
141 NV_CPB_CTL_CPB_VALID = (1 << 0),
142 NV_CPB_CTL_QUEUE = (1 << 1),
143 NV_CPB_CTL_APRD_VALID = (1 << 2),
144 NV_CPB_CTL_IEN = (1 << 3),
145 NV_CPB_CTL_FPDMA = (1 << 4),
146
147 /* APRD flags */
148 NV_APRD_WRITE = (1 << 1),
149 NV_APRD_END = (1 << 2),
150 NV_APRD_CONT = (1 << 3),
151
152 /* NV_ADMA_STAT flags */
153 NV_ADMA_STAT_TIMEOUT = (1 << 0),
154 NV_ADMA_STAT_HOTUNPLUG = (1 << 1),
155 NV_ADMA_STAT_HOTPLUG = (1 << 2),
156 NV_ADMA_STAT_CPBERR = (1 << 4),
157 NV_ADMA_STAT_SERROR = (1 << 5),
158 NV_ADMA_STAT_CMD_COMPLETE = (1 << 6),
159 NV_ADMA_STAT_IDLE = (1 << 8),
160 NV_ADMA_STAT_LEGACY = (1 << 9),
161 NV_ADMA_STAT_STOPPED = (1 << 10),
162 NV_ADMA_STAT_DONE = (1 << 12),
163 NV_ADMA_STAT_ERR = NV_ADMA_STAT_CPBERR |
164 NV_ADMA_STAT_TIMEOUT,
165
166 /* port flags */
167 NV_ADMA_PORT_REGISTER_MODE = (1 << 0),
168 NV_ADMA_ATAPI_SETUP_COMPLETE = (1 << 1),
169
170};
171
172/* ADMA Physical Region Descriptor - one SG segment */
173struct nv_adma_prd {
174 __le64 addr;
175 __le32 len;
176 u8 flags;
177 u8 packet_len;
178 __le16 reserved;
179};
180
181enum nv_adma_regbits {
182 CMDEND = (1 << 15), /* end of command list */
183 WNB = (1 << 14), /* wait-not-BSY */
184 IGN = (1 << 13), /* ignore this entry */
185 CS1n = (1 << (4 + 8)), /* std. PATA signals follow... */
186 DA2 = (1 << (2 + 8)),
187 DA1 = (1 << (1 + 8)),
188 DA0 = (1 << (0 + 8)),
189};
190
191/* ADMA Command Parameter Block
192 The first 5 SG segments are stored inside the Command Parameter Block itself.
193 If there are more than 5 segments the remainder are stored in a separate
194 memory area indicated by next_aprd. */
195struct nv_adma_cpb {
196 u8 resp_flags; /* 0 */
197 u8 reserved1; /* 1 */
198 u8 ctl_flags; /* 2 */
199 /* len is length of taskfile in 64 bit words */
200 u8 len; /* 3 */
201 u8 tag; /* 4 */
202 u8 next_cpb_idx; /* 5 */
203 __le16 reserved2; /* 6-7 */
204 __le16 tf[12]; /* 8-31 */
205 struct nv_adma_prd aprd[5]; /* 32-111 */
206 __le64 next_aprd; /* 112-119 */
207 __le64 reserved3; /* 120-127 */
208};
209
210
211struct nv_adma_port_priv {
212 struct nv_adma_cpb *cpb;
213 dma_addr_t cpb_dma;
214 struct nv_adma_prd *aprd;
215 dma_addr_t aprd_dma;
216 u8 flags;
81}; 217};
82 218
219#define NV_ADMA_CHECK_INTR(GCTL, PORT) ((GCTL) & ( 1 << (19 + (12 * (PORT)))))
220
83static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); 221static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent);
84static void nv_ck804_host_stop(struct ata_host *host); 222static void nv_ck804_host_stop(struct ata_host *host);
85static irqreturn_t nv_generic_interrupt(int irq, void *dev_instance); 223static irqreturn_t nv_generic_interrupt(int irq, void *dev_instance);
@@ -93,13 +231,28 @@ static void nv_nf2_thaw(struct ata_port *ap);
93static void nv_ck804_freeze(struct ata_port *ap); 231static void nv_ck804_freeze(struct ata_port *ap);
94static void nv_ck804_thaw(struct ata_port *ap); 232static void nv_ck804_thaw(struct ata_port *ap);
95static void nv_error_handler(struct ata_port *ap); 233static void nv_error_handler(struct ata_port *ap);
234static int nv_adma_slave_config(struct scsi_device *sdev);
235static int nv_adma_check_atapi_dma(struct ata_queued_cmd *qc);
236static void nv_adma_qc_prep(struct ata_queued_cmd *qc);
237static unsigned int nv_adma_qc_issue(struct ata_queued_cmd *qc);
238static irqreturn_t nv_adma_interrupt(int irq, void *dev_instance);
239static void nv_adma_irq_clear(struct ata_port *ap);
240static int nv_adma_port_start(struct ata_port *ap);
241static void nv_adma_port_stop(struct ata_port *ap);
242static void nv_adma_error_handler(struct ata_port *ap);
243static void nv_adma_host_stop(struct ata_host *host);
244static void nv_adma_bmdma_setup(struct ata_queued_cmd *qc);
245static void nv_adma_bmdma_start(struct ata_queued_cmd *qc);
246static void nv_adma_bmdma_stop(struct ata_queued_cmd *qc);
247static u8 nv_adma_bmdma_status(struct ata_port *ap);
96 248
97enum nv_host_type 249enum nv_host_type
98{ 250{
99 GENERIC, 251 GENERIC,
100 NFORCE2, 252 NFORCE2,
101 NFORCE3 = NFORCE2, /* NF2 == NF3 as far as sata_nv is concerned */ 253 NFORCE3 = NFORCE2, /* NF2 == NF3 as far as sata_nv is concerned */
102 CK804 254 CK804,
255 ADMA
103}; 256};
104 257
105static const struct pci_device_id nv_pci_tbl[] = { 258static const struct pci_device_id nv_pci_tbl[] = {
@@ -160,6 +313,24 @@ static struct scsi_host_template nv_sht = {
160 .bios_param = ata_std_bios_param, 313 .bios_param = ata_std_bios_param,
161}; 314};
162 315
316static struct scsi_host_template nv_adma_sht = {
317 .module = THIS_MODULE,
318 .name = DRV_NAME,
319 .ioctl = ata_scsi_ioctl,
320 .queuecommand = ata_scsi_queuecmd,
321 .can_queue = NV_ADMA_MAX_CPBS,
322 .this_id = ATA_SHT_THIS_ID,
323 .sg_tablesize = NV_ADMA_SGTBL_TOTAL_LEN,
324 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
325 .emulated = ATA_SHT_EMULATED,
326 .use_clustering = ATA_SHT_USE_CLUSTERING,
327 .proc_name = DRV_NAME,
328 .dma_boundary = NV_ADMA_DMA_BOUNDARY,
329 .slave_configure = nv_adma_slave_config,
330 .slave_destroy = ata_scsi_slave_destroy,
331 .bios_param = ata_std_bios_param,
332};
333
163static const struct ata_port_operations nv_generic_ops = { 334static const struct ata_port_operations nv_generic_ops = {
164 .port_disable = ata_port_disable, 335 .port_disable = ata_port_disable,
165 .tf_load = ata_tf_load, 336 .tf_load = ata_tf_load,
@@ -241,11 +412,40 @@ static const struct ata_port_operations nv_ck804_ops = {
241 .host_stop = nv_ck804_host_stop, 412 .host_stop = nv_ck804_host_stop,
242}; 413};
243 414
415static const struct ata_port_operations nv_adma_ops = {
416 .port_disable = ata_port_disable,
417 .tf_load = ata_tf_load,
418 .tf_read = ata_tf_read,
419 .check_atapi_dma = nv_adma_check_atapi_dma,
420 .exec_command = ata_exec_command,
421 .check_status = ata_check_status,
422 .dev_select = ata_std_dev_select,
423 .bmdma_setup = nv_adma_bmdma_setup,
424 .bmdma_start = nv_adma_bmdma_start,
425 .bmdma_stop = nv_adma_bmdma_stop,
426 .bmdma_status = nv_adma_bmdma_status,
427 .qc_prep = nv_adma_qc_prep,
428 .qc_issue = nv_adma_qc_issue,
429 .freeze = nv_ck804_freeze,
430 .thaw = nv_ck804_thaw,
431 .error_handler = nv_adma_error_handler,
432 .post_internal_cmd = nv_adma_bmdma_stop,
433 .data_xfer = ata_mmio_data_xfer,
434 .irq_handler = nv_adma_interrupt,
435 .irq_clear = nv_adma_irq_clear,
436 .scr_read = nv_scr_read,
437 .scr_write = nv_scr_write,
438 .port_start = nv_adma_port_start,
439 .port_stop = nv_adma_port_stop,
440 .host_stop = nv_adma_host_stop,
441};
442
244static struct ata_port_info nv_port_info[] = { 443static struct ata_port_info nv_port_info[] = {
245 /* generic */ 444 /* generic */
246 { 445 {
247 .sht = &nv_sht, 446 .sht = &nv_sht,
248 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY, 447 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
448 ATA_FLAG_HRST_TO_RESUME,
249 .pio_mask = NV_PIO_MASK, 449 .pio_mask = NV_PIO_MASK,
250 .mwdma_mask = NV_MWDMA_MASK, 450 .mwdma_mask = NV_MWDMA_MASK,
251 .udma_mask = NV_UDMA_MASK, 451 .udma_mask = NV_UDMA_MASK,
@@ -254,7 +454,8 @@ static struct ata_port_info nv_port_info[] = {
254 /* nforce2/3 */ 454 /* nforce2/3 */
255 { 455 {
256 .sht = &nv_sht, 456 .sht = &nv_sht,
257 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY, 457 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
458 ATA_FLAG_HRST_TO_RESUME,
258 .pio_mask = NV_PIO_MASK, 459 .pio_mask = NV_PIO_MASK,
259 .mwdma_mask = NV_MWDMA_MASK, 460 .mwdma_mask = NV_MWDMA_MASK,
260 .udma_mask = NV_UDMA_MASK, 461 .udma_mask = NV_UDMA_MASK,
@@ -263,12 +464,23 @@ static struct ata_port_info nv_port_info[] = {
263 /* ck804 */ 464 /* ck804 */
264 { 465 {
265 .sht = &nv_sht, 466 .sht = &nv_sht,
266 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY, 467 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
468 ATA_FLAG_HRST_TO_RESUME,
267 .pio_mask = NV_PIO_MASK, 469 .pio_mask = NV_PIO_MASK,
268 .mwdma_mask = NV_MWDMA_MASK, 470 .mwdma_mask = NV_MWDMA_MASK,
269 .udma_mask = NV_UDMA_MASK, 471 .udma_mask = NV_UDMA_MASK,
270 .port_ops = &nv_ck804_ops, 472 .port_ops = &nv_ck804_ops,
271 }, 473 },
474 /* ADMA */
475 {
476 .sht = &nv_adma_sht,
477 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
478 ATA_FLAG_MMIO | ATA_FLAG_NCQ,
479 .pio_mask = NV_PIO_MASK,
480 .mwdma_mask = NV_MWDMA_MASK,
481 .udma_mask = NV_UDMA_MASK,
482 .port_ops = &nv_adma_ops,
483 },
272}; 484};
273 485
274MODULE_AUTHOR("NVIDIA"); 486MODULE_AUTHOR("NVIDIA");
@@ -277,37 +489,220 @@ MODULE_LICENSE("GPL");
277MODULE_DEVICE_TABLE(pci, nv_pci_tbl); 489MODULE_DEVICE_TABLE(pci, nv_pci_tbl);
278MODULE_VERSION(DRV_VERSION); 490MODULE_VERSION(DRV_VERSION);
279 491
280static irqreturn_t nv_generic_interrupt(int irq, void *dev_instance) 492static int adma_enabled = 1;
493
494static inline void __iomem *__nv_adma_ctl_block(void __iomem *mmio,
495 unsigned int port_no)
281{ 496{
282 struct ata_host *host = dev_instance; 497 mmio += NV_ADMA_PORT + port_no * NV_ADMA_PORT_SIZE;
283 unsigned int i; 498 return mmio;
284 unsigned int handled = 0; 499}
285 unsigned long flags;
286 500
287 spin_lock_irqsave(&host->lock, flags); 501static inline void __iomem *nv_adma_ctl_block(struct ata_port *ap)
502{
503 return __nv_adma_ctl_block(ap->host->mmio_base, ap->port_no);
504}
288 505
289 for (i = 0; i < host->n_ports; i++) { 506static inline void __iomem *nv_adma_gen_block(struct ata_port *ap)
290 struct ata_port *ap; 507{
508 return (ap->host->mmio_base + NV_ADMA_GEN);
509}
291 510
292 ap = host->ports[i]; 511static inline void __iomem *nv_adma_notifier_clear_block(struct ata_port *ap)
293 if (ap && 512{
294 !(ap->flags & ATA_FLAG_DISABLED)) { 513 return (nv_adma_gen_block(ap) + NV_ADMA_NOTIFIER_CLEAR + (4 * ap->port_no));
295 struct ata_queued_cmd *qc; 514}
296 515
297 qc = ata_qc_from_tag(ap, ap->active_tag); 516static void nv_adma_register_mode(struct ata_port *ap)
298 if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING))) 517{
299 handled += ata_host_intr(ap, qc); 518 void __iomem *mmio = nv_adma_ctl_block(ap);
300 else 519 struct nv_adma_port_priv *pp = ap->private_data;
301 // No request pending? Clear interrupt status 520 u16 tmp;
302 // anyway, in case there's one pending. 521
303 ap->ops->check_status(ap); 522 if (pp->flags & NV_ADMA_PORT_REGISTER_MODE)
304 } 523 return;
524
525 tmp = readw(mmio + NV_ADMA_CTL);
526 writew(tmp & ~NV_ADMA_CTL_GO, mmio + NV_ADMA_CTL);
527
528 pp->flags |= NV_ADMA_PORT_REGISTER_MODE;
529}
530
531static void nv_adma_mode(struct ata_port *ap)
532{
533 void __iomem *mmio = nv_adma_ctl_block(ap);
534 struct nv_adma_port_priv *pp = ap->private_data;
535 u16 tmp;
305 536
537 if (!(pp->flags & NV_ADMA_PORT_REGISTER_MODE))
538 return;
539
540 WARN_ON(pp->flags & NV_ADMA_ATAPI_SETUP_COMPLETE);
541
542 tmp = readw(mmio + NV_ADMA_CTL);
543 writew(tmp | NV_ADMA_CTL_GO, mmio + NV_ADMA_CTL);
544
545 pp->flags &= ~NV_ADMA_PORT_REGISTER_MODE;
546}
547
548static int nv_adma_slave_config(struct scsi_device *sdev)
549{
550 struct ata_port *ap = ata_shost_to_port(sdev->host);
551 struct nv_adma_port_priv *pp = ap->private_data;
552 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
553 u64 bounce_limit;
554 unsigned long segment_boundary;
555 unsigned short sg_tablesize;
556 int rc;
557 int adma_enable;
558 u32 current_reg, new_reg, config_mask;
559
560 rc = ata_scsi_slave_config(sdev);
561
562 if (sdev->id >= ATA_MAX_DEVICES || sdev->channel || sdev->lun)
563 /* Not a proper libata device, ignore */
564 return rc;
565
566 if (ap->device[sdev->id].class == ATA_DEV_ATAPI) {
567 /*
568 * NVIDIA reports that ADMA mode does not support ATAPI commands.
569 * Therefore ATAPI commands are sent through the legacy interface.
570 * However, the legacy interface only supports 32-bit DMA.
571 * Restrict DMA parameters as required by the legacy interface
572 * when an ATAPI device is connected.
573 */
574 bounce_limit = ATA_DMA_MASK;
575 segment_boundary = ATA_DMA_BOUNDARY;
576 /* Subtract 1 since an extra entry may be needed for padding, see
577 libata-scsi.c */
578 sg_tablesize = LIBATA_MAX_PRD - 1;
579
580 /* Since the legacy DMA engine is in use, we need to disable ADMA
581 on the port. */
582 adma_enable = 0;
583 nv_adma_register_mode(ap);
584 }
585 else {
586 bounce_limit = *ap->dev->dma_mask;
587 segment_boundary = NV_ADMA_DMA_BOUNDARY;
588 sg_tablesize = NV_ADMA_SGTBL_TOTAL_LEN;
589 adma_enable = 1;
590 }
591
592 pci_read_config_dword(pdev, NV_MCP_SATA_CFG_20, &current_reg);
593
594 if(ap->port_no == 1)
595 config_mask = NV_MCP_SATA_CFG_20_PORT1_EN |
596 NV_MCP_SATA_CFG_20_PORT1_PWB_EN;
597 else
598 config_mask = NV_MCP_SATA_CFG_20_PORT0_EN |
599 NV_MCP_SATA_CFG_20_PORT0_PWB_EN;
600
601 if(adma_enable) {
602 new_reg = current_reg | config_mask;
603 pp->flags &= ~NV_ADMA_ATAPI_SETUP_COMPLETE;
604 }
605 else {
606 new_reg = current_reg & ~config_mask;
607 pp->flags |= NV_ADMA_ATAPI_SETUP_COMPLETE;
306 } 608 }
609
610 if(current_reg != new_reg)
611 pci_write_config_dword(pdev, NV_MCP_SATA_CFG_20, new_reg);
612
613 blk_queue_bounce_limit(sdev->request_queue, bounce_limit);
614 blk_queue_segment_boundary(sdev->request_queue, segment_boundary);
615 blk_queue_max_hw_segments(sdev->request_queue, sg_tablesize);
616 ata_port_printk(ap, KERN_INFO,
617 "bounce limit 0x%llX, segment boundary 0x%lX, hw segs %hu\n",
618 (unsigned long long)bounce_limit, segment_boundary, sg_tablesize);
619 return rc;
620}
307 621
308 spin_unlock_irqrestore(&host->lock, flags); 622static int nv_adma_check_atapi_dma(struct ata_queued_cmd *qc)
623{
624 struct nv_adma_port_priv *pp = qc->ap->private_data;
625 return !(pp->flags & NV_ADMA_ATAPI_SETUP_COMPLETE);
626}
309 627
310 return IRQ_RETVAL(handled); 628static unsigned int nv_adma_tf_to_cpb(struct ata_taskfile *tf, __le16 *cpb)
629{
630 unsigned int idx = 0;
631
632 cpb[idx++] = cpu_to_le16((ATA_REG_DEVICE << 8) | tf->device | WNB);
633
634 if ((tf->flags & ATA_TFLAG_LBA48) == 0) {
635 cpb[idx++] = cpu_to_le16(IGN);
636 cpb[idx++] = cpu_to_le16(IGN);
637 cpb[idx++] = cpu_to_le16(IGN);
638 cpb[idx++] = cpu_to_le16(IGN);
639 cpb[idx++] = cpu_to_le16(IGN);
640 }
641 else {
642 cpb[idx++] = cpu_to_le16((ATA_REG_ERR << 8) | tf->hob_feature);
643 cpb[idx++] = cpu_to_le16((ATA_REG_NSECT << 8) | tf->hob_nsect);
644 cpb[idx++] = cpu_to_le16((ATA_REG_LBAL << 8) | tf->hob_lbal);
645 cpb[idx++] = cpu_to_le16((ATA_REG_LBAM << 8) | tf->hob_lbam);
646 cpb[idx++] = cpu_to_le16((ATA_REG_LBAH << 8) | tf->hob_lbah);
647 }
648 cpb[idx++] = cpu_to_le16((ATA_REG_ERR << 8) | tf->feature);
649 cpb[idx++] = cpu_to_le16((ATA_REG_NSECT << 8) | tf->nsect);
650 cpb[idx++] = cpu_to_le16((ATA_REG_LBAL << 8) | tf->lbal);
651 cpb[idx++] = cpu_to_le16((ATA_REG_LBAM << 8) | tf->lbam);
652 cpb[idx++] = cpu_to_le16((ATA_REG_LBAH << 8) | tf->lbah);
653
654 cpb[idx++] = cpu_to_le16((ATA_REG_CMD << 8) | tf->command | CMDEND);
655
656 return idx;
657}
658
659static void nv_adma_check_cpb(struct ata_port *ap, int cpb_num, int force_err)
660{
661 struct nv_adma_port_priv *pp = ap->private_data;
662 int complete = 0, have_err = 0;
663 u8 flags = pp->cpb[cpb_num].resp_flags;
664
665 VPRINTK("CPB %d, flags=0x%x\n", cpb_num, flags);
666
667 if (flags & NV_CPB_RESP_DONE) {
668 VPRINTK("CPB flags done, flags=0x%x\n", flags);
669 complete = 1;
670 }
671 if (flags & NV_CPB_RESP_ATA_ERR) {
672 ata_port_printk(ap, KERN_ERR, "CPB flags ATA err, flags=0x%x\n", flags);
673 have_err = 1;
674 complete = 1;
675 }
676 if (flags & NV_CPB_RESP_CMD_ERR) {
677 ata_port_printk(ap, KERN_ERR, "CPB flags CMD err, flags=0x%x\n", flags);
678 have_err = 1;
679 complete = 1;
680 }
681 if (flags & NV_CPB_RESP_CPB_ERR) {
682 ata_port_printk(ap, KERN_ERR, "CPB flags CPB err, flags=0x%x\n", flags);
683 have_err = 1;
684 complete = 1;
685 }
686 if(complete || force_err)
687 {
688 struct ata_queued_cmd *qc = ata_qc_from_tag(ap, cpb_num);
689 if(likely(qc)) {
690 u8 ata_status = 0;
691 /* Only use the ATA port status for non-NCQ commands.
692 For NCQ commands the current status may have nothing to do with
693 the command just completed. */
694 if(qc->tf.protocol != ATA_PROT_NCQ)
695 ata_status = readb(nv_adma_ctl_block(ap) + (ATA_REG_STATUS * 4));
696
697 if(have_err || force_err)
698 ata_status |= ATA_ERR;
699
700 qc->err_mask |= ac_err_mask(ata_status);
701 DPRINTK("Completing qc from tag %d with err_mask %u\n",cpb_num,
702 qc->err_mask);
703 ata_qc_complete(qc);
704 }
705 }
311} 706}
312 707
313static int nv_host_intr(struct ata_port *ap, u8 irq_stat) 708static int nv_host_intr(struct ata_port *ap, u8 irq_stat)
@@ -341,6 +736,486 @@ static int nv_host_intr(struct ata_port *ap, u8 irq_stat)
341 return 1; 736 return 1;
342} 737}
343 738
739static irqreturn_t nv_adma_interrupt(int irq, void *dev_instance)
740{
741 struct ata_host *host = dev_instance;
742 int i, handled = 0;
743 u32 notifier_clears[2];
744
745 spin_lock(&host->lock);
746
747 for (i = 0; i < host->n_ports; i++) {
748 struct ata_port *ap = host->ports[i];
749 notifier_clears[i] = 0;
750
751 if (ap && !(ap->flags & ATA_FLAG_DISABLED)) {
752 struct nv_adma_port_priv *pp = ap->private_data;
753 void __iomem *mmio = nv_adma_ctl_block(ap);
754 u16 status;
755 u32 gen_ctl;
756 int have_global_err = 0;
757 u32 notifier, notifier_error;
758
759 /* if in ATA register mode, use standard ata interrupt handler */
760 if (pp->flags & NV_ADMA_PORT_REGISTER_MODE) {
761 u8 irq_stat = readb(host->mmio_base + NV_INT_STATUS_CK804)
762 >> (NV_INT_PORT_SHIFT * i);
763 handled += nv_host_intr(ap, irq_stat);
764 continue;
765 }
766
767 notifier = readl(mmio + NV_ADMA_NOTIFIER);
768 notifier_error = readl(mmio + NV_ADMA_NOTIFIER_ERROR);
769 notifier_clears[i] = notifier | notifier_error;
770
771 gen_ctl = readl(nv_adma_gen_block(ap) + NV_ADMA_GEN_CTL);
772
773 if( !NV_ADMA_CHECK_INTR(gen_ctl, ap->port_no) && !notifier &&
774 !notifier_error)
775 /* Nothing to do */
776 continue;
777
778 status = readw(mmio + NV_ADMA_STAT);
779
780 /* Clear status. Ensure the controller sees the clearing before we start
781 looking at any of the CPB statuses, so that any CPB completions after
782 this point in the handler will raise another interrupt. */
783 writew(status, mmio + NV_ADMA_STAT);
784 readw(mmio + NV_ADMA_STAT); /* flush posted write */
785 rmb();
786
787 /* freeze if hotplugged */
788 if (unlikely(status & (NV_ADMA_STAT_HOTPLUG | NV_ADMA_STAT_HOTUNPLUG))) {
789 ata_port_printk(ap, KERN_NOTICE, "Hotplug event, freezing\n");
790 ata_port_freeze(ap);
791 handled++;
792 continue;
793 }
794
795 if (status & NV_ADMA_STAT_TIMEOUT) {
796 ata_port_printk(ap, KERN_ERR, "timeout, stat=0x%x\n", status);
797 have_global_err = 1;
798 }
799 if (status & NV_ADMA_STAT_CPBERR) {
800 ata_port_printk(ap, KERN_ERR, "CPB error, stat=0x%x\n", status);
801 have_global_err = 1;
802 }
803 if ((status & NV_ADMA_STAT_DONE) || have_global_err) {
804 /** Check CPBs for completed commands */
805
806 if(ata_tag_valid(ap->active_tag))
807 /* Non-NCQ command */
808 nv_adma_check_cpb(ap, ap->active_tag, have_global_err ||
809 (notifier_error & (1 << ap->active_tag)));
810 else {
811 int pos;
812 u32 active = ap->sactive;
813 while( (pos = ffs(active)) ) {
814 pos--;
815 nv_adma_check_cpb(ap, pos, have_global_err ||
816 (notifier_error & (1 << pos)) );
817 active &= ~(1 << pos );
818 }
819 }
820 }
821
822 handled++; /* irq handled if we got here */
823 }
824 }
825
826 if(notifier_clears[0] || notifier_clears[1]) {
827 /* Note: Both notifier clear registers must be written
828 if either is set, even if one is zero, according to NVIDIA. */
829 writel(notifier_clears[0],
830 nv_adma_notifier_clear_block(host->ports[0]));
831 writel(notifier_clears[1],
832 nv_adma_notifier_clear_block(host->ports[1]));
833 }
834
835 spin_unlock(&host->lock);
836
837 return IRQ_RETVAL(handled);
838}
839
840static void nv_adma_irq_clear(struct ata_port *ap)
841{
842 void __iomem *mmio = nv_adma_ctl_block(ap);
843 u16 status = readw(mmio + NV_ADMA_STAT);
844 u32 notifier = readl(mmio + NV_ADMA_NOTIFIER);
845 u32 notifier_error = readl(mmio + NV_ADMA_NOTIFIER_ERROR);
846 unsigned long dma_stat_addr = ap->ioaddr.bmdma_addr + ATA_DMA_STATUS;
847
848 /* clear ADMA status */
849 writew(status, mmio + NV_ADMA_STAT);
850 writel(notifier | notifier_error,
851 nv_adma_notifier_clear_block(ap));
852
853 /** clear legacy status */
854 outb(inb(dma_stat_addr), dma_stat_addr);
855}
856
857static void nv_adma_bmdma_setup(struct ata_queued_cmd *qc)
858{
859 struct ata_port *ap = qc->ap;
860 unsigned int rw = (qc->tf.flags & ATA_TFLAG_WRITE);
861 struct nv_adma_port_priv *pp = ap->private_data;
862 u8 dmactl;
863
864 if(!(pp->flags & NV_ADMA_PORT_REGISTER_MODE)) {
865 WARN_ON(1);
866 return;
867 }
868
869 /* load PRD table addr. */
870 outl(ap->prd_dma, ap->ioaddr.bmdma_addr + ATA_DMA_TABLE_OFS);
871
872 /* specify data direction, triple-check start bit is clear */
873 dmactl = inb(ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
874 dmactl &= ~(ATA_DMA_WR | ATA_DMA_START);
875 if (!rw)
876 dmactl |= ATA_DMA_WR;
877
878 outb(dmactl, ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
879
880 /* issue r/w command */
881 ata_exec_command(ap, &qc->tf);
882}
883
884static void nv_adma_bmdma_start(struct ata_queued_cmd *qc)
885{
886 struct ata_port *ap = qc->ap;
887 struct nv_adma_port_priv *pp = ap->private_data;
888 u8 dmactl;
889
890 if(!(pp->flags & NV_ADMA_PORT_REGISTER_MODE)) {
891 WARN_ON(1);
892 return;
893 }
894
895 /* start host DMA transaction */
896 dmactl = inb(ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
897 outb(dmactl | ATA_DMA_START,
898 ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
899}
900
901static void nv_adma_bmdma_stop(struct ata_queued_cmd *qc)
902{
903 struct ata_port *ap = qc->ap;
904 struct nv_adma_port_priv *pp = ap->private_data;
905
906 if(!(pp->flags & NV_ADMA_PORT_REGISTER_MODE))
907 return;
908
909 /* clear start/stop bit */
910 outb(inb(ap->ioaddr.bmdma_addr + ATA_DMA_CMD) & ~ATA_DMA_START,
911 ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
912
913 /* one-PIO-cycle guaranteed wait, per spec, for HDMA1:0 transition */
914 ata_altstatus(ap); /* dummy read */
915}
916
917static u8 nv_adma_bmdma_status(struct ata_port *ap)
918{
919 struct nv_adma_port_priv *pp = ap->private_data;
920
921 WARN_ON(!(pp->flags & NV_ADMA_PORT_REGISTER_MODE));
922
923 return inb(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
924}
925
926static int nv_adma_port_start(struct ata_port *ap)
927{
928 struct device *dev = ap->host->dev;
929 struct nv_adma_port_priv *pp;
930 int rc;
931 void *mem;
932 dma_addr_t mem_dma;
933 void __iomem *mmio = nv_adma_ctl_block(ap);
934 u16 tmp;
935
936 VPRINTK("ENTER\n");
937
938 rc = ata_port_start(ap);
939 if (rc)
940 return rc;
941
942 pp = kzalloc(sizeof(*pp), GFP_KERNEL);
943 if (!pp) {
944 rc = -ENOMEM;
945 goto err_out;
946 }
947
948 mem = dma_alloc_coherent(dev, NV_ADMA_PORT_PRIV_DMA_SZ,
949 &mem_dma, GFP_KERNEL);
950
951 if (!mem) {
952 rc = -ENOMEM;
953 goto err_out_kfree;
954 }
955 memset(mem, 0, NV_ADMA_PORT_PRIV_DMA_SZ);
956
957 /*
958 * First item in chunk of DMA memory:
959 * 128-byte command parameter block (CPB)
960 * one for each command tag
961 */
962 pp->cpb = mem;
963 pp->cpb_dma = mem_dma;
964
965 writel(mem_dma & 0xFFFFFFFF, mmio + NV_ADMA_CPB_BASE_LOW);
966 writel((mem_dma >> 16 ) >> 16, mmio + NV_ADMA_CPB_BASE_HIGH);
967
968 mem += NV_ADMA_MAX_CPBS * NV_ADMA_CPB_SZ;
969 mem_dma += NV_ADMA_MAX_CPBS * NV_ADMA_CPB_SZ;
970
971 /*
972 * Second item: block of ADMA_SGTBL_LEN s/g entries
973 */
974 pp->aprd = mem;
975 pp->aprd_dma = mem_dma;
976
977 ap->private_data = pp;
978
979 /* clear any outstanding interrupt conditions */
980 writew(0xffff, mmio + NV_ADMA_STAT);
981
982 /* initialize port variables */
983 pp->flags = NV_ADMA_PORT_REGISTER_MODE;
984
985 /* clear CPB fetch count */
986 writew(0, mmio + NV_ADMA_CPB_COUNT);
987
988 /* clear GO for register mode */
989 tmp = readw(mmio + NV_ADMA_CTL);
990 writew(tmp & ~NV_ADMA_CTL_GO, mmio + NV_ADMA_CTL);
991
992 tmp = readw(mmio + NV_ADMA_CTL);
993 writew(tmp | NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL);
994 readl( mmio + NV_ADMA_CTL ); /* flush posted write */
995 udelay(1);
996 writew(tmp & ~NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL);
997 readl( mmio + NV_ADMA_CTL ); /* flush posted write */
998
999 return 0;
1000
1001err_out_kfree:
1002 kfree(pp);
1003err_out:
1004 ata_port_stop(ap);
1005 return rc;
1006}
1007
1008static void nv_adma_port_stop(struct ata_port *ap)
1009{
1010 struct device *dev = ap->host->dev;
1011 struct nv_adma_port_priv *pp = ap->private_data;
1012 void __iomem *mmio = nv_adma_ctl_block(ap);
1013
1014 VPRINTK("ENTER\n");
1015
1016 writew(0, mmio + NV_ADMA_CTL);
1017
1018 ap->private_data = NULL;
1019 dma_free_coherent(dev, NV_ADMA_PORT_PRIV_DMA_SZ, pp->cpb, pp->cpb_dma);
1020 kfree(pp);
1021 ata_port_stop(ap);
1022}
1023
1024
1025static void nv_adma_setup_port(struct ata_probe_ent *probe_ent, unsigned int port)
1026{
1027 void __iomem *mmio = probe_ent->mmio_base;
1028 struct ata_ioports *ioport = &probe_ent->port[port];
1029
1030 VPRINTK("ENTER\n");
1031
1032 mmio += NV_ADMA_PORT + port * NV_ADMA_PORT_SIZE;
1033
1034 ioport->cmd_addr = (unsigned long) mmio;
1035 ioport->data_addr = (unsigned long) mmio + (ATA_REG_DATA * 4);
1036 ioport->error_addr =
1037 ioport->feature_addr = (unsigned long) mmio + (ATA_REG_ERR * 4);
1038 ioport->nsect_addr = (unsigned long) mmio + (ATA_REG_NSECT * 4);
1039 ioport->lbal_addr = (unsigned long) mmio + (ATA_REG_LBAL * 4);
1040 ioport->lbam_addr = (unsigned long) mmio + (ATA_REG_LBAM * 4);
1041 ioport->lbah_addr = (unsigned long) mmio + (ATA_REG_LBAH * 4);
1042 ioport->device_addr = (unsigned long) mmio + (ATA_REG_DEVICE * 4);
1043 ioport->status_addr =
1044 ioport->command_addr = (unsigned long) mmio + (ATA_REG_STATUS * 4);
1045 ioport->altstatus_addr =
1046 ioport->ctl_addr = (unsigned long) mmio + 0x20;
1047}
1048
1049static int nv_adma_host_init(struct ata_probe_ent *probe_ent)
1050{
1051 struct pci_dev *pdev = to_pci_dev(probe_ent->dev);
1052 unsigned int i;
1053 u32 tmp32;
1054
1055 VPRINTK("ENTER\n");
1056
1057 /* enable ADMA on the ports */
1058 pci_read_config_dword(pdev, NV_MCP_SATA_CFG_20, &tmp32);
1059 tmp32 |= NV_MCP_SATA_CFG_20_PORT0_EN |
1060 NV_MCP_SATA_CFG_20_PORT0_PWB_EN |
1061 NV_MCP_SATA_CFG_20_PORT1_EN |
1062 NV_MCP_SATA_CFG_20_PORT1_PWB_EN;
1063
1064 pci_write_config_dword(pdev, NV_MCP_SATA_CFG_20, tmp32);
1065
1066 for (i = 0; i < probe_ent->n_ports; i++)
1067 nv_adma_setup_port(probe_ent, i);
1068
1069 for (i = 0; i < probe_ent->n_ports; i++) {
1070 void __iomem *mmio = __nv_adma_ctl_block(probe_ent->mmio_base, i);
1071 u16 tmp;
1072
1073 /* enable interrupt, clear reset if not already clear */
1074 tmp = readw(mmio + NV_ADMA_CTL);
1075 writew(tmp | NV_ADMA_CTL_AIEN, mmio + NV_ADMA_CTL);
1076 }
1077
1078 return 0;
1079}
1080
1081static void nv_adma_fill_aprd(struct ata_queued_cmd *qc,
1082 struct scatterlist *sg,
1083 int idx,
1084 struct nv_adma_prd *aprd)
1085{
1086 u8 flags;
1087
1088 memset(aprd, 0, sizeof(struct nv_adma_prd));
1089
1090 flags = 0;
1091 if (qc->tf.flags & ATA_TFLAG_WRITE)
1092 flags |= NV_APRD_WRITE;
1093 if (idx == qc->n_elem - 1)
1094 flags |= NV_APRD_END;
1095 else if (idx != 4)
1096 flags |= NV_APRD_CONT;
1097
1098 aprd->addr = cpu_to_le64(((u64)sg_dma_address(sg)));
1099 aprd->len = cpu_to_le32(((u32)sg_dma_len(sg))); /* len in bytes */
1100 aprd->flags = flags;
1101}
1102
1103static void nv_adma_fill_sg(struct ata_queued_cmd *qc, struct nv_adma_cpb *cpb)
1104{
1105 struct nv_adma_port_priv *pp = qc->ap->private_data;
1106 unsigned int idx;
1107 struct nv_adma_prd *aprd;
1108 struct scatterlist *sg;
1109
1110 VPRINTK("ENTER\n");
1111
1112 idx = 0;
1113
1114 ata_for_each_sg(sg, qc) {
1115 aprd = (idx < 5) ? &cpb->aprd[idx] : &pp->aprd[NV_ADMA_SGTBL_LEN * qc->tag + (idx-5)];
1116 nv_adma_fill_aprd(qc, sg, idx, aprd);
1117 idx++;
1118 }
1119 if (idx > 5)
1120 cpb->next_aprd = cpu_to_le64(((u64)(pp->aprd_dma + NV_ADMA_SGTBL_SZ * qc->tag)));
1121}
1122
1123static void nv_adma_qc_prep(struct ata_queued_cmd *qc)
1124{
1125 struct nv_adma_port_priv *pp = qc->ap->private_data;
1126 struct nv_adma_cpb *cpb = &pp->cpb[qc->tag];
1127 u8 ctl_flags = NV_CPB_CTL_CPB_VALID |
1128 NV_CPB_CTL_APRD_VALID |
1129 NV_CPB_CTL_IEN;
1130
1131 VPRINTK("qc->flags = 0x%lx\n", qc->flags);
1132
1133 if (!(qc->flags & ATA_QCFLAG_DMAMAP) ||
1134 (pp->flags & NV_ADMA_ATAPI_SETUP_COMPLETE)) {
1135 nv_adma_register_mode(qc->ap);
1136 ata_qc_prep(qc);
1137 return;
1138 }
1139
1140 memset(cpb, 0, sizeof(struct nv_adma_cpb));
1141
1142 cpb->len = 3;
1143 cpb->tag = qc->tag;
1144 cpb->next_cpb_idx = 0;
1145
1146 /* turn on NCQ flags for NCQ commands */
1147 if (qc->tf.protocol == ATA_PROT_NCQ)
1148 ctl_flags |= NV_CPB_CTL_QUEUE | NV_CPB_CTL_FPDMA;
1149
1150 nv_adma_tf_to_cpb(&qc->tf, cpb->tf);
1151
1152 nv_adma_fill_sg(qc, cpb);
1153
1154 /* Be paranoid and don't let the device see NV_CPB_CTL_CPB_VALID until we are
1155 finished filling in all of the contents */
1156 wmb();
1157 cpb->ctl_flags = ctl_flags;
1158}
1159
1160static unsigned int nv_adma_qc_issue(struct ata_queued_cmd *qc)
1161{
1162 struct nv_adma_port_priv *pp = qc->ap->private_data;
1163 void __iomem *mmio = nv_adma_ctl_block(qc->ap);
1164
1165 VPRINTK("ENTER\n");
1166
1167 if (!(qc->flags & ATA_QCFLAG_DMAMAP) ||
1168 (pp->flags & NV_ADMA_ATAPI_SETUP_COMPLETE)) {
1169 /* use ATA register mode */
1170 VPRINTK("no dmamap or ATAPI, using ATA register mode: 0x%lx\n", qc->flags);
1171 nv_adma_register_mode(qc->ap);
1172 return ata_qc_issue_prot(qc);
1173 } else
1174 nv_adma_mode(qc->ap);
1175
1176 /* write append register, command tag in lower 8 bits
1177 and (number of cpbs to append -1) in top 8 bits */
1178 wmb();
1179 writew(qc->tag, mmio + NV_ADMA_APPEND);
1180
1181 DPRINTK("Issued tag %u\n",qc->tag);
1182
1183 return 0;
1184}
1185
1186static irqreturn_t nv_generic_interrupt(int irq, void *dev_instance)
1187{
1188 struct ata_host *host = dev_instance;
1189 unsigned int i;
1190 unsigned int handled = 0;
1191 unsigned long flags;
1192
1193 spin_lock_irqsave(&host->lock, flags);
1194
1195 for (i = 0; i < host->n_ports; i++) {
1196 struct ata_port *ap;
1197
1198 ap = host->ports[i];
1199 if (ap &&
1200 !(ap->flags & ATA_FLAG_DISABLED)) {
1201 struct ata_queued_cmd *qc;
1202
1203 qc = ata_qc_from_tag(ap, ap->active_tag);
1204 if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING)))
1205 handled += ata_host_intr(ap, qc);
1206 else
1207 // No request pending? Clear interrupt status
1208 // anyway, in case there's one pending.
1209 ap->ops->check_status(ap);
1210 }
1211
1212 }
1213
1214 spin_unlock_irqrestore(&host->lock, flags);
1215
1216 return IRQ_RETVAL(handled);
1217}
1218
344static irqreturn_t nv_do_interrupt(struct ata_host *host, u8 irq_stat) 1219static irqreturn_t nv_do_interrupt(struct ata_host *host, u8 irq_stat)
345{ 1220{
346 int i, handled = 0; 1221 int i, handled = 0;
@@ -466,6 +1341,56 @@ static void nv_error_handler(struct ata_port *ap)
466 nv_hardreset, ata_std_postreset); 1341 nv_hardreset, ata_std_postreset);
467} 1342}
468 1343
1344static void nv_adma_error_handler(struct ata_port *ap)
1345{
1346 struct nv_adma_port_priv *pp = ap->private_data;
1347 if(!(pp->flags & NV_ADMA_PORT_REGISTER_MODE)) {
1348 void __iomem *mmio = nv_adma_ctl_block(ap);
1349 int i;
1350 u16 tmp;
1351
1352 u32 notifier = readl(mmio + NV_ADMA_NOTIFIER);
1353 u32 notifier_error = readl(mmio + NV_ADMA_NOTIFIER_ERROR);
1354 u32 gen_ctl = readl(nv_adma_gen_block(ap) + NV_ADMA_GEN_CTL);
1355 u32 status = readw(mmio + NV_ADMA_STAT);
1356
1357 ata_port_printk(ap, KERN_ERR, "EH in ADMA mode, notifier 0x%X "
1358 "notifier_error 0x%X gen_ctl 0x%X status 0x%X\n",
1359 notifier, notifier_error, gen_ctl, status);
1360
1361 for( i=0;i<NV_ADMA_MAX_CPBS;i++) {
1362 struct nv_adma_cpb *cpb = &pp->cpb[i];
1363 if( cpb->ctl_flags || cpb->resp_flags )
1364 ata_port_printk(ap, KERN_ERR,
1365 "CPB %d: ctl_flags 0x%x, resp_flags 0x%x\n",
1366 i, cpb->ctl_flags, cpb->resp_flags);
1367 }
1368
1369 /* Push us back into port register mode for error handling. */
1370 nv_adma_register_mode(ap);
1371
1372 ata_port_printk(ap, KERN_ERR, "Resetting port\n");
1373
1374 /* Mark all of the CPBs as invalid to prevent them from being executed */
1375 for( i=0;i<NV_ADMA_MAX_CPBS;i++)
1376 pp->cpb[i].ctl_flags &= ~NV_CPB_CTL_CPB_VALID;
1377
1378 /* clear CPB fetch count */
1379 writew(0, mmio + NV_ADMA_CPB_COUNT);
1380
1381 /* Reset channel */
1382 tmp = readw(mmio + NV_ADMA_CTL);
1383 writew(tmp | NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL);
1384 readl( mmio + NV_ADMA_CTL ); /* flush posted write */
1385 udelay(1);
1386 writew(tmp & ~NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL);
1387 readl( mmio + NV_ADMA_CTL ); /* flush posted write */
1388 }
1389
1390 ata_bmdma_drive_eh(ap, ata_std_prereset, ata_std_softreset,
1391 nv_hardreset, ata_std_postreset);
1392}
1393
469static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 1394static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
470{ 1395{
471 static int printed_version = 0; 1396 static int printed_version = 0;
@@ -475,6 +1400,8 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
475 int rc; 1400 int rc;
476 u32 bar; 1401 u32 bar;
477 unsigned long base; 1402 unsigned long base;
1403 unsigned long type = ent->driver_data;
1404 int mask_set = 0;
478 1405
479 // Make sure this is a SATA controller by counting the number of bars 1406 // Make sure this is a SATA controller by counting the number of bars
480 // (NVIDIA SATA controllers will always have six bars). Otherwise, 1407 // (NVIDIA SATA controllers will always have six bars). Otherwise,
@@ -483,7 +1410,7 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
483 if (pci_resource_start(pdev, bar) == 0) 1410 if (pci_resource_start(pdev, bar) == 0)
484 return -ENODEV; 1411 return -ENODEV;
485 1412
486 if (!printed_version++) 1413 if ( !printed_version++)
487 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); 1414 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
488 1415
489 rc = pci_enable_device(pdev); 1416 rc = pci_enable_device(pdev);
@@ -496,16 +1423,26 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
496 goto err_out_disable; 1423 goto err_out_disable;
497 } 1424 }
498 1425
499 rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); 1426 if(type >= CK804 && adma_enabled) {
500 if (rc) 1427 dev_printk(KERN_NOTICE, &pdev->dev, "Using ADMA mode\n");
501 goto err_out_regions; 1428 type = ADMA;
502 rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); 1429 if(!pci_set_dma_mask(pdev, DMA_64BIT_MASK) &&
503 if (rc) 1430 !pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK))
504 goto err_out_regions; 1431 mask_set = 1;
1432 }
1433
1434 if(!mask_set) {
1435 rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
1436 if (rc)
1437 goto err_out_regions;
1438 rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK);
1439 if (rc)
1440 goto err_out_regions;
1441 }
505 1442
506 rc = -ENOMEM; 1443 rc = -ENOMEM;
507 1444
508 ppi[0] = ppi[1] = &nv_port_info[ent->driver_data]; 1445 ppi[0] = ppi[1] = &nv_port_info[type];
509 probe_ent = ata_pci_init_native_mode(pdev, ppi, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY); 1446 probe_ent = ata_pci_init_native_mode(pdev, ppi, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY);
510 if (!probe_ent) 1447 if (!probe_ent)
511 goto err_out_regions; 1448 goto err_out_regions;
@@ -522,7 +1459,7 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
522 probe_ent->port[1].scr_addr = base + NV_PORT1_SCR_REG_OFFSET; 1459 probe_ent->port[1].scr_addr = base + NV_PORT1_SCR_REG_OFFSET;
523 1460
524 /* enable SATA space for CK804 */ 1461 /* enable SATA space for CK804 */
525 if (ent->driver_data == CK804) { 1462 if (type >= CK804) {
526 u8 regval; 1463 u8 regval;
527 1464
528 pci_read_config_byte(pdev, NV_MCP_SATA_CFG_20, &regval); 1465 pci_read_config_byte(pdev, NV_MCP_SATA_CFG_20, &regval);
@@ -532,6 +1469,12 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
532 1469
533 pci_set_master(pdev); 1470 pci_set_master(pdev);
534 1471
1472 if (type == ADMA) {
1473 rc = nv_adma_host_init(probe_ent);
1474 if (rc)
1475 goto err_out_iounmap;
1476 }
1477
535 rc = ata_device_add(probe_ent); 1478 rc = ata_device_add(probe_ent);
536 if (rc != NV_PORTS) 1479 if (rc != NV_PORTS)
537 goto err_out_iounmap; 1480 goto err_out_iounmap;
@@ -566,6 +1509,33 @@ static void nv_ck804_host_stop(struct ata_host *host)
566 ata_pci_host_stop(host); 1509 ata_pci_host_stop(host);
567} 1510}
568 1511
1512static void nv_adma_host_stop(struct ata_host *host)
1513{
1514 struct pci_dev *pdev = to_pci_dev(host->dev);
1515 int i;
1516 u32 tmp32;
1517
1518 for (i = 0; i < host->n_ports; i++) {
1519 void __iomem *mmio = __nv_adma_ctl_block(host->mmio_base, i);
1520 u16 tmp;
1521
1522 /* disable interrupt */
1523 tmp = readw(mmio + NV_ADMA_CTL);
1524 writew(tmp & ~NV_ADMA_CTL_AIEN, mmio + NV_ADMA_CTL);
1525 }
1526
1527 /* disable ADMA on the ports */
1528 pci_read_config_dword(pdev, NV_MCP_SATA_CFG_20, &tmp32);
1529 tmp32 &= ~(NV_MCP_SATA_CFG_20_PORT0_EN |
1530 NV_MCP_SATA_CFG_20_PORT0_PWB_EN |
1531 NV_MCP_SATA_CFG_20_PORT1_EN |
1532 NV_MCP_SATA_CFG_20_PORT1_PWB_EN);
1533
1534 pci_write_config_dword(pdev, NV_MCP_SATA_CFG_20, tmp32);
1535
1536 nv_ck804_host_stop(host);
1537}
1538
569static int __init nv_init(void) 1539static int __init nv_init(void)
570{ 1540{
571 return pci_register_driver(&nv_pci_driver); 1541 return pci_register_driver(&nv_pci_driver);
@@ -578,3 +1548,5 @@ static void __exit nv_exit(void)
578 1548
579module_init(nv_init); 1549module_init(nv_init);
580module_exit(nv_exit); 1550module_exit(nv_exit);
1551module_param_named(adma, adma_enabled, bool, 0444);
1552MODULE_PARM_DESC(adma, "Enable use of ADMA (Default: true)");
diff --git a/drivers/ata/sata_promise.c b/drivers/ata/sata_promise.c
index 72eda5160fad..f055874a6ec5 100644
--- a/drivers/ata/sata_promise.c
+++ b/drivers/ata/sata_promise.c
@@ -46,20 +46,19 @@
46#include "sata_promise.h" 46#include "sata_promise.h"
47 47
48#define DRV_NAME "sata_promise" 48#define DRV_NAME "sata_promise"
49#define DRV_VERSION "1.04" 49#define DRV_VERSION "1.05"
50 50
51 51
52enum { 52enum {
53 PDC_PKT_SUBMIT = 0x40, /* Command packet pointer addr */ 53 PDC_PKT_SUBMIT = 0x40, /* Command packet pointer addr */
54 PDC_INT_SEQMASK = 0x40, /* Mask of asserted SEQ INTs */ 54 PDC_INT_SEQMASK = 0x40, /* Mask of asserted SEQ INTs */
55 PDC_TBG_MODE = 0x41, /* TBG mode */
56 PDC_FLASH_CTL = 0x44, /* Flash control register */ 55 PDC_FLASH_CTL = 0x44, /* Flash control register */
57 PDC_PCI_CTL = 0x48, /* PCI control and status register */
58 PDC_GLOBAL_CTL = 0x48, /* Global control/status (per port) */ 56 PDC_GLOBAL_CTL = 0x48, /* Global control/status (per port) */
59 PDC_CTLSTAT = 0x60, /* IDE control and status (per port) */ 57 PDC_CTLSTAT = 0x60, /* IDE control and status (per port) */
60 PDC_SATA_PLUG_CSR = 0x6C, /* SATA Plug control/status reg */ 58 PDC_SATA_PLUG_CSR = 0x6C, /* SATA Plug control/status reg */
61 PDC2_SATA_PLUG_CSR = 0x60, /* SATAII Plug control/status reg */ 59 PDC2_SATA_PLUG_CSR = 0x60, /* SATAII Plug control/status reg */
62 PDC_SLEW_CTL = 0x470, /* slew rate control reg */ 60 PDC_TBG_MODE = 0x41C, /* TBG mode (not SATAII) */
61 PDC_SLEW_CTL = 0x470, /* slew rate control reg (not SATAII) */
63 62
64 PDC_ERR_MASK = (1<<19) | (1<<20) | (1<<21) | (1<<22) | 63 PDC_ERR_MASK = (1<<19) | (1<<20) | (1<<21) | (1<<22) |
65 (1<<8) | (1<<9) | (1<<10), 64 (1<<8) | (1<<9) | (1<<10),
@@ -67,17 +66,22 @@ enum {
67 board_2037x = 0, /* FastTrak S150 TX2plus */ 66 board_2037x = 0, /* FastTrak S150 TX2plus */
68 board_20319 = 1, /* FastTrak S150 TX4 */ 67 board_20319 = 1, /* FastTrak S150 TX4 */
69 board_20619 = 2, /* FastTrak TX4000 */ 68 board_20619 = 2, /* FastTrak TX4000 */
70 board_20771 = 3, /* FastTrak TX2300 */ 69 board_2057x = 3, /* SATAII150 Tx2plus */
71 board_2057x = 4, /* SATAII150 Tx2plus */ 70 board_40518 = 4, /* SATAII150 Tx4 */
72 board_40518 = 5, /* SATAII150 Tx4 */
73 71
74 PDC_HAS_PATA = (1 << 1), /* PDC20375/20575 has PATA */ 72 PDC_HAS_PATA = (1 << 1), /* PDC20375/20575 has PATA */
75 73
74 /* PDC_CTLSTAT bit definitions */
75 PDC_DMA_ENABLE = (1 << 7),
76 PDC_IRQ_DISABLE = (1 << 10),
76 PDC_RESET = (1 << 11), /* HDMA reset */ 77 PDC_RESET = (1 << 11), /* HDMA reset */
77 78
78 PDC_COMMON_FLAGS = ATA_FLAG_NO_LEGACY | ATA_FLAG_SRST | 79 PDC_COMMON_FLAGS = ATA_FLAG_NO_LEGACY |
79 ATA_FLAG_MMIO | ATA_FLAG_NO_ATAPI | 80 ATA_FLAG_MMIO | ATA_FLAG_NO_ATAPI |
80 ATA_FLAG_PIO_POLLING, 81 ATA_FLAG_PIO_POLLING,
82
83 /* hp->flags bits */
84 PDC_FLAG_GEN_II = (1 << 0),
81}; 85};
82 86
83 87
@@ -87,7 +91,7 @@ struct pdc_port_priv {
87}; 91};
88 92
89struct pdc_host_priv { 93struct pdc_host_priv {
90 int hotplug_offset; 94 unsigned long flags;
91}; 95};
92 96
93static u32 pdc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg); 97static u32 pdc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg);
@@ -98,13 +102,16 @@ static void pdc_eng_timeout(struct ata_port *ap);
98static int pdc_port_start(struct ata_port *ap); 102static int pdc_port_start(struct ata_port *ap);
99static void pdc_port_stop(struct ata_port *ap); 103static void pdc_port_stop(struct ata_port *ap);
100static void pdc_pata_phy_reset(struct ata_port *ap); 104static void pdc_pata_phy_reset(struct ata_port *ap);
101static void pdc_sata_phy_reset(struct ata_port *ap);
102static void pdc_qc_prep(struct ata_queued_cmd *qc); 105static void pdc_qc_prep(struct ata_queued_cmd *qc);
103static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf); 106static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf);
104static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf); 107static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf);
105static void pdc_irq_clear(struct ata_port *ap); 108static void pdc_irq_clear(struct ata_port *ap);
106static unsigned int pdc_qc_issue_prot(struct ata_queued_cmd *qc); 109static unsigned int pdc_qc_issue_prot(struct ata_queued_cmd *qc);
107static void pdc_host_stop(struct ata_host *host); 110static void pdc_host_stop(struct ata_host *host);
111static void pdc_freeze(struct ata_port *ap);
112static void pdc_thaw(struct ata_port *ap);
113static void pdc_error_handler(struct ata_port *ap);
114static void pdc_post_internal_cmd(struct ata_queued_cmd *qc);
108 115
109 116
110static struct scsi_host_template pdc_ata_sht = { 117static struct scsi_host_template pdc_ata_sht = {
@@ -133,11 +140,12 @@ static const struct ata_port_operations pdc_sata_ops = {
133 .exec_command = pdc_exec_command_mmio, 140 .exec_command = pdc_exec_command_mmio,
134 .dev_select = ata_std_dev_select, 141 .dev_select = ata_std_dev_select,
135 142
136 .phy_reset = pdc_sata_phy_reset,
137
138 .qc_prep = pdc_qc_prep, 143 .qc_prep = pdc_qc_prep,
139 .qc_issue = pdc_qc_issue_prot, 144 .qc_issue = pdc_qc_issue_prot,
140 .eng_timeout = pdc_eng_timeout, 145 .freeze = pdc_freeze,
146 .thaw = pdc_thaw,
147 .error_handler = pdc_error_handler,
148 .post_internal_cmd = pdc_post_internal_cmd,
141 .data_xfer = ata_mmio_data_xfer, 149 .data_xfer = ata_mmio_data_xfer,
142 .irq_handler = pdc_interrupt, 150 .irq_handler = pdc_interrupt,
143 .irq_clear = pdc_irq_clear, 151 .irq_clear = pdc_irq_clear,
@@ -195,23 +203,13 @@ static const struct ata_port_info pdc_port_info[] = {
195 /* board_20619 */ 203 /* board_20619 */
196 { 204 {
197 .sht = &pdc_ata_sht, 205 .sht = &pdc_ata_sht,
198 .flags = PDC_COMMON_FLAGS | ATA_FLAG_SLAVE_POSS, 206 .flags = PDC_COMMON_FLAGS | ATA_FLAG_SRST | ATA_FLAG_SLAVE_POSS,
199 .pio_mask = 0x1f, /* pio0-4 */ 207 .pio_mask = 0x1f, /* pio0-4 */
200 .mwdma_mask = 0x07, /* mwdma0-2 */ 208 .mwdma_mask = 0x07, /* mwdma0-2 */
201 .udma_mask = 0x7f, /* udma0-6 ; FIXME */ 209 .udma_mask = 0x7f, /* udma0-6 ; FIXME */
202 .port_ops = &pdc_pata_ops, 210 .port_ops = &pdc_pata_ops,
203 }, 211 },
204 212
205 /* board_20771 */
206 {
207 .sht = &pdc_ata_sht,
208 .flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA,
209 .pio_mask = 0x1f, /* pio0-4 */
210 .mwdma_mask = 0x07, /* mwdma0-2 */
211 .udma_mask = 0x7f, /* udma0-6 ; FIXME */
212 .port_ops = &pdc_sata_ops,
213 },
214
215 /* board_2057x */ 213 /* board_2057x */
216 { 214 {
217 .sht = &pdc_ata_sht, 215 .sht = &pdc_ata_sht,
@@ -235,33 +233,25 @@ static const struct ata_port_info pdc_port_info[] = {
235 233
236static const struct pci_device_id pdc_ata_pci_tbl[] = { 234static const struct pci_device_id pdc_ata_pci_tbl[] = {
237 { PCI_VDEVICE(PROMISE, 0x3371), board_2037x }, 235 { PCI_VDEVICE(PROMISE, 0x3371), board_2037x },
238 { PCI_VDEVICE(PROMISE, 0x3570), board_2037x },
239 { PCI_VDEVICE(PROMISE, 0x3571), board_2037x },
240 { PCI_VDEVICE(PROMISE, 0x3373), board_2037x }, 236 { PCI_VDEVICE(PROMISE, 0x3373), board_2037x },
241 { PCI_VDEVICE(PROMISE, 0x3375), board_2037x }, 237 { PCI_VDEVICE(PROMISE, 0x3375), board_2037x },
242 { PCI_VDEVICE(PROMISE, 0x3376), board_2037x }, 238 { PCI_VDEVICE(PROMISE, 0x3376), board_2037x },
239 { PCI_VDEVICE(PROMISE, 0x3570), board_2057x },
240 { PCI_VDEVICE(PROMISE, 0x3571), board_2057x },
243 { PCI_VDEVICE(PROMISE, 0x3574), board_2057x }, 241 { PCI_VDEVICE(PROMISE, 0x3574), board_2057x },
242 { PCI_VDEVICE(PROMISE, 0x3577), board_2057x },
243 { PCI_VDEVICE(PROMISE, 0x3d73), board_2057x },
244 { PCI_VDEVICE(PROMISE, 0x3d75), board_2057x }, 244 { PCI_VDEVICE(PROMISE, 0x3d75), board_2057x },
245 { PCI_VDEVICE(PROMISE, 0x3d73), board_2037x },
246 245
247 { PCI_VDEVICE(PROMISE, 0x3318), board_20319 }, 246 { PCI_VDEVICE(PROMISE, 0x3318), board_20319 },
248 { PCI_VDEVICE(PROMISE, 0x3319), board_20319 }, 247 { PCI_VDEVICE(PROMISE, 0x3319), board_20319 },
249 { PCI_VDEVICE(PROMISE, 0x3515), board_20319 }, 248 { PCI_VDEVICE(PROMISE, 0x3515), board_20319 },
250 { PCI_VDEVICE(PROMISE, 0x3519), board_20319 }, 249 { PCI_VDEVICE(PROMISE, 0x3519), board_20319 },
251 { PCI_VDEVICE(PROMISE, 0x3d17), board_20319 }, 250 { PCI_VDEVICE(PROMISE, 0x3d17), board_40518 },
252 { PCI_VDEVICE(PROMISE, 0x3d18), board_40518 }, 251 { PCI_VDEVICE(PROMISE, 0x3d18), board_40518 },
253 252
254 { PCI_VDEVICE(PROMISE, 0x6629), board_20619 }, 253 { PCI_VDEVICE(PROMISE, 0x6629), board_20619 },
255 254
256/* TODO: remove all associated board_20771 code, as it completely
257 * duplicates board_2037x code, unless reason for separation can be
258 * divined.
259 */
260#if 0
261 { PCI_VDEVICE(PROMISE, 0x3570), board_20771 },
262#endif
263 { PCI_VDEVICE(PROMISE, 0x3577), board_20771 },
264
265 { } /* terminate list */ 255 { } /* terminate list */
266}; 256};
267 257
@@ -277,6 +267,7 @@ static struct pci_driver pdc_ata_pci_driver = {
277static int pdc_port_start(struct ata_port *ap) 267static int pdc_port_start(struct ata_port *ap)
278{ 268{
279 struct device *dev = ap->host->dev; 269 struct device *dev = ap->host->dev;
270 struct pdc_host_priv *hp = ap->host->private_data;
280 struct pdc_port_priv *pp; 271 struct pdc_port_priv *pp;
281 int rc; 272 int rc;
282 273
@@ -298,6 +289,16 @@ static int pdc_port_start(struct ata_port *ap)
298 289
299 ap->private_data = pp; 290 ap->private_data = pp;
300 291
292 /* fix up PHYMODE4 align timing */
293 if ((hp->flags & PDC_FLAG_GEN_II) && sata_scr_valid(ap)) {
294 void __iomem *mmio = (void __iomem *) ap->ioaddr.scr_addr;
295 unsigned int tmp;
296
297 tmp = readl(mmio + 0x014);
298 tmp = (tmp & ~3) | 1; /* set bits 1:0 = 0:1 */
299 writel(tmp, mmio + 0x014);
300 }
301
301 return 0; 302 return 0;
302 303
303err_out_kfree: 304err_out_kfree:
@@ -352,12 +353,6 @@ static void pdc_reset_port(struct ata_port *ap)
352 readl(mmio); /* flush */ 353 readl(mmio); /* flush */
353} 354}
354 355
355static void pdc_sata_phy_reset(struct ata_port *ap)
356{
357 pdc_reset_port(ap);
358 sata_phy_reset(ap);
359}
360
361static void pdc_pata_cbl_detect(struct ata_port *ap) 356static void pdc_pata_cbl_detect(struct ata_port *ap)
362{ 357{
363 u8 tmp; 358 u8 tmp;
@@ -425,6 +420,61 @@ static void pdc_qc_prep(struct ata_queued_cmd *qc)
425 } 420 }
426} 421}
427 422
423static void pdc_freeze(struct ata_port *ap)
424{
425 void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr;
426 u32 tmp;
427
428 tmp = readl(mmio + PDC_CTLSTAT);
429 tmp |= PDC_IRQ_DISABLE;
430 tmp &= ~PDC_DMA_ENABLE;
431 writel(tmp, mmio + PDC_CTLSTAT);
432 readl(mmio + PDC_CTLSTAT); /* flush */
433}
434
435static void pdc_thaw(struct ata_port *ap)
436{
437 void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr;
438 u32 tmp;
439
440 /* clear IRQ */
441 readl(mmio + PDC_INT_SEQMASK);
442
443 /* turn IRQ back on */
444 tmp = readl(mmio + PDC_CTLSTAT);
445 tmp &= ~PDC_IRQ_DISABLE;
446 writel(tmp, mmio + PDC_CTLSTAT);
447 readl(mmio + PDC_CTLSTAT); /* flush */
448}
449
450static void pdc_error_handler(struct ata_port *ap)
451{
452 ata_reset_fn_t hardreset;
453
454 if (!(ap->pflags & ATA_PFLAG_FROZEN))
455 pdc_reset_port(ap);
456
457 hardreset = NULL;
458 if (sata_scr_valid(ap))
459 hardreset = sata_std_hardreset;
460
461 /* perform recovery */
462 ata_do_eh(ap, ata_std_prereset, ata_std_softreset, hardreset,
463 ata_std_postreset);
464}
465
466static void pdc_post_internal_cmd(struct ata_queued_cmd *qc)
467{
468 struct ata_port *ap = qc->ap;
469
470 if (qc->flags & ATA_QCFLAG_FAILED)
471 qc->err_mask |= AC_ERR_OTHER;
472
473 /* make DMA engine forget about the failed command */
474 if (qc->err_mask)
475 pdc_reset_port(ap);
476}
477
428static void pdc_eng_timeout(struct ata_port *ap) 478static void pdc_eng_timeout(struct ata_port *ap)
429{ 479{
430 struct ata_host *host = ap->host; 480 struct ata_host *host = ap->host;
@@ -631,18 +681,25 @@ static void pdc_host_init(unsigned int chip_id, struct ata_probe_ent *pe)
631{ 681{
632 void __iomem *mmio = pe->mmio_base; 682 void __iomem *mmio = pe->mmio_base;
633 struct pdc_host_priv *hp = pe->private_data; 683 struct pdc_host_priv *hp = pe->private_data;
634 int hotplug_offset = hp->hotplug_offset; 684 int hotplug_offset;
635 u32 tmp; 685 u32 tmp;
636 686
687 if (hp->flags & PDC_FLAG_GEN_II)
688 hotplug_offset = PDC2_SATA_PLUG_CSR;
689 else
690 hotplug_offset = PDC_SATA_PLUG_CSR;
691
637 /* 692 /*
638 * Except for the hotplug stuff, this is voodoo from the 693 * Except for the hotplug stuff, this is voodoo from the
639 * Promise driver. Label this entire section 694 * Promise driver. Label this entire section
640 * "TODO: figure out why we do this" 695 * "TODO: figure out why we do this"
641 */ 696 */
642 697
643 /* change FIFO_SHD to 8 dwords, enable BMR_BURST */ 698 /* enable BMR_BURST, maybe change FIFO_SHD to 8 dwords */
644 tmp = readl(mmio + PDC_FLASH_CTL); 699 tmp = readl(mmio + PDC_FLASH_CTL);
645 tmp |= 0x12000; /* bit 16 (fifo 8 dw) and 13 (bmr burst?) */ 700 tmp |= 0x02000; /* bit 13 (enable bmr burst) */
701 if (!(hp->flags & PDC_FLAG_GEN_II))
702 tmp |= 0x10000; /* bit 16 (fifo threshold at 8 dw) */
646 writel(tmp, mmio + PDC_FLASH_CTL); 703 writel(tmp, mmio + PDC_FLASH_CTL);
647 704
648 /* clear plug/unplug flags for all ports */ 705 /* clear plug/unplug flags for all ports */
@@ -653,6 +710,10 @@ static void pdc_host_init(unsigned int chip_id, struct ata_probe_ent *pe)
653 tmp = readl(mmio + hotplug_offset); 710 tmp = readl(mmio + hotplug_offset);
654 writel(tmp | 0xff0000, mmio + hotplug_offset); 711 writel(tmp | 0xff0000, mmio + hotplug_offset);
655 712
713 /* don't initialise TBG or SLEW on 2nd generation chips */
714 if (hp->flags & PDC_FLAG_GEN_II)
715 return;
716
656 /* reduce TBG clock to 133 Mhz. */ 717 /* reduce TBG clock to 133 Mhz. */
657 tmp = readl(mmio + PDC_TBG_MODE); 718 tmp = readl(mmio + PDC_TBG_MODE);
658 tmp &= ~0x30000; /* clear bit 17, 16*/ 719 tmp &= ~0x30000; /* clear bit 17, 16*/
@@ -722,8 +783,6 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
722 goto err_out_free_ent; 783 goto err_out_free_ent;
723 } 784 }
724 785
725 /* Set default hotplug offset */
726 hp->hotplug_offset = PDC_SATA_PLUG_CSR;
727 probe_ent->private_data = hp; 786 probe_ent->private_data = hp;
728 787
729 probe_ent->sht = pdc_port_info[board_idx].sht; 788 probe_ent->sht = pdc_port_info[board_idx].sht;
@@ -746,8 +805,7 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
746 /* notice 4-port boards */ 805 /* notice 4-port boards */
747 switch (board_idx) { 806 switch (board_idx) {
748 case board_40518: 807 case board_40518:
749 /* Override hotplug offset for SATAII150 */ 808 hp->flags |= PDC_FLAG_GEN_II;
750 hp->hotplug_offset = PDC2_SATA_PLUG_CSR;
751 /* Fall through */ 809 /* Fall through */
752 case board_20319: 810 case board_20319:
753 probe_ent->n_ports = 4; 811 probe_ent->n_ports = 4;
@@ -759,15 +817,11 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
759 probe_ent->port[3].scr_addr = base + 0x700; 817 probe_ent->port[3].scr_addr = base + 0x700;
760 break; 818 break;
761 case board_2057x: 819 case board_2057x:
762 /* Override hotplug offset for SATAII150 */ 820 hp->flags |= PDC_FLAG_GEN_II;
763 hp->hotplug_offset = PDC2_SATA_PLUG_CSR;
764 /* Fall through */ 821 /* Fall through */
765 case board_2037x: 822 case board_2037x:
766 probe_ent->n_ports = 2; 823 probe_ent->n_ports = 2;
767 break; 824 break;
768 case board_20771:
769 probe_ent->n_ports = 2;
770 break;
771 case board_20619: 825 case board_20619:
772 probe_ent->n_ports = 4; 826 probe_ent->n_ports = 4;
773 827
diff --git a/drivers/ata/sata_sil.c b/drivers/ata/sata_sil.c
index ca8d99312472..7808d0369d91 100644
--- a/drivers/ata/sata_sil.c
+++ b/drivers/ata/sata_sil.c
@@ -356,6 +356,7 @@ static void sil_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
356 356
357static void sil_host_intr(struct ata_port *ap, u32 bmdma2) 357static void sil_host_intr(struct ata_port *ap, u32 bmdma2)
358{ 358{
359 struct ata_eh_info *ehi = &ap->eh_info;
359 struct ata_queued_cmd *qc = ata_qc_from_tag(ap, ap->active_tag); 360 struct ata_queued_cmd *qc = ata_qc_from_tag(ap, ap->active_tag);
360 u8 status; 361 u8 status;
361 362
@@ -428,6 +429,10 @@ static void sil_host_intr(struct ata_port *ap, u32 bmdma2)
428 /* kick HSM in the ass */ 429 /* kick HSM in the ass */
429 ata_hsm_move(ap, qc, status, 0); 430 ata_hsm_move(ap, qc, status, 0);
430 431
432 if (unlikely(qc->err_mask) && (qc->tf.protocol == ATA_PROT_DMA ||
433 qc->tf.protocol == ATA_PROT_ATAPI_DMA))
434 ata_ehi_push_desc(ehi, "BMDMA2 stat 0x%x", bmdma2);
435
431 return; 436 return;
432 437
433 err_hsm: 438 err_hsm:
@@ -534,6 +539,7 @@ static void sil_thaw(struct ata_port *ap)
534 */ 539 */
535static void sil_dev_config(struct ata_port *ap, struct ata_device *dev) 540static void sil_dev_config(struct ata_port *ap, struct ata_device *dev)
536{ 541{
542 int print_info = ap->eh_context.i.flags & ATA_EHI_PRINTINFO;
537 unsigned int n, quirks = 0; 543 unsigned int n, quirks = 0;
538 unsigned char model_num[41]; 544 unsigned char model_num[41];
539 545
@@ -549,16 +555,18 @@ static void sil_dev_config(struct ata_port *ap, struct ata_device *dev)
549 if (slow_down || 555 if (slow_down ||
550 ((ap->flags & SIL_FLAG_MOD15WRITE) && 556 ((ap->flags & SIL_FLAG_MOD15WRITE) &&
551 (quirks & SIL_QUIRK_MOD15WRITE))) { 557 (quirks & SIL_QUIRK_MOD15WRITE))) {
552 ata_dev_printk(dev, KERN_INFO, "applying Seagate errata fix " 558 if (print_info)
553 "(mod15write workaround)\n"); 559 ata_dev_printk(dev, KERN_INFO, "applying Seagate "
560 "errata fix (mod15write workaround)\n");
554 dev->max_sectors = 15; 561 dev->max_sectors = 15;
555 return; 562 return;
556 } 563 }
557 564
558 /* limit to udma5 */ 565 /* limit to udma5 */
559 if (quirks & SIL_QUIRK_UDMA5MAX) { 566 if (quirks & SIL_QUIRK_UDMA5MAX) {
560 ata_dev_printk(dev, KERN_INFO, 567 if (print_info)
561 "applying Maxtor errata fix %s\n", model_num); 568 ata_dev_printk(dev, KERN_INFO, "applying Maxtor "
569 "errata fix %s\n", model_num);
562 dev->udma_mask &= ATA_UDMA5; 570 dev->udma_mask &= ATA_UDMA5;
563 return; 571 return;
564 } 572 }
diff --git a/drivers/ata/sata_sil24.c b/drivers/ata/sata_sil24.c
index 169e200a6a71..5aa288d2fb86 100644
--- a/drivers/ata/sata_sil24.c
+++ b/drivers/ata/sata_sil24.c
@@ -100,10 +100,14 @@ enum {
100 */ 100 */
101 PORT_REGS_SIZE = 0x2000, 101 PORT_REGS_SIZE = 0x2000,
102 102
103 PORT_LRAM = 0x0000, /* 31 LRAM slots and PM regs */ 103 PORT_LRAM = 0x0000, /* 31 LRAM slots and PMP regs */
104 PORT_LRAM_SLOT_SZ = 0x0080, /* 32 bytes PRB + 2 SGE, ACT... */ 104 PORT_LRAM_SLOT_SZ = 0x0080, /* 32 bytes PRB + 2 SGE, ACT... */
105 105
106 PORT_PM = 0x0f80, /* 8 bytes PM * 16 (128 bytes) */ 106 PORT_PMP = 0x0f80, /* 8 bytes PMP * 16 (128 bytes) */
107 PORT_PMP_STATUS = 0x0000, /* port device status offset */
108 PORT_PMP_QACTIVE = 0x0004, /* port device QActive offset */
109 PORT_PMP_SIZE = 0x0008, /* 8 bytes per PMP */
110
107 /* 32 bit regs */ 111 /* 32 bit regs */
108 PORT_CTRL_STAT = 0x1000, /* write: ctrl-set, read: stat */ 112 PORT_CTRL_STAT = 0x1000, /* write: ctrl-set, read: stat */
109 PORT_CTRL_CLR = 0x1004, /* write: ctrl-clear */ 113 PORT_CTRL_CLR = 0x1004, /* write: ctrl-clear */
@@ -126,6 +130,7 @@ enum {
126 PORT_PHY_CFG = 0x1050, 130 PORT_PHY_CFG = 0x1050,
127 PORT_SLOT_STAT = 0x1800, 131 PORT_SLOT_STAT = 0x1800,
128 PORT_CMD_ACTIVATE = 0x1c00, /* 64 bit cmd activate * 31 (248 bytes) */ 132 PORT_CMD_ACTIVATE = 0x1c00, /* 64 bit cmd activate * 31 (248 bytes) */
133 PORT_CONTEXT = 0x1e04,
129 PORT_EXEC_DIAG = 0x1e00, /* 32bit exec diag * 16 (64 bytes, 0-10 used on 3124) */ 134 PORT_EXEC_DIAG = 0x1e00, /* 32bit exec diag * 16 (64 bytes, 0-10 used on 3124) */
130 PORT_PSD_DIAG = 0x1e40, /* 32bit psd diag * 16 (64 bytes, 0-8 used on 3124) */ 135 PORT_PSD_DIAG = 0x1e40, /* 32bit psd diag * 16 (64 bytes, 0-8 used on 3124) */
131 PORT_SCONTROL = 0x1f00, 136 PORT_SCONTROL = 0x1f00,
@@ -139,9 +144,9 @@ enum {
139 PORT_CS_INIT = (1 << 2), /* port initialize */ 144 PORT_CS_INIT = (1 << 2), /* port initialize */
140 PORT_CS_IRQ_WOC = (1 << 3), /* interrupt write one to clear */ 145 PORT_CS_IRQ_WOC = (1 << 3), /* interrupt write one to clear */
141 PORT_CS_CDB16 = (1 << 5), /* 0=12b cdb, 1=16b cdb */ 146 PORT_CS_CDB16 = (1 << 5), /* 0=12b cdb, 1=16b cdb */
142 PORT_CS_RESUME = (1 << 6), /* port resume */ 147 PORT_CS_PMP_RESUME = (1 << 6), /* PMP resume */
143 PORT_CS_32BIT_ACTV = (1 << 10), /* 32-bit activation */ 148 PORT_CS_32BIT_ACTV = (1 << 10), /* 32-bit activation */
144 PORT_CS_PM_EN = (1 << 13), /* port multiplier enable */ 149 PORT_CS_PMP_EN = (1 << 13), /* port multiplier enable */
145 PORT_CS_RDY = (1 << 31), /* port ready to accept commands */ 150 PORT_CS_RDY = (1 << 31), /* port ready to accept commands */
146 151
147 /* PORT_IRQ_STAT/ENABLE_SET/CLR */ 152 /* PORT_IRQ_STAT/ENABLE_SET/CLR */
@@ -562,7 +567,7 @@ static int sil24_softreset(struct ata_port *ap, unsigned int *class)
562 567
563 /* do SRST */ 568 /* do SRST */
564 prb->ctrl = cpu_to_le16(PRB_CTRL_SRST); 569 prb->ctrl = cpu_to_le16(PRB_CTRL_SRST);
565 prb->fis[1] = 0; /* no PM yet */ 570 prb->fis[1] = 0; /* no PMP yet */
566 571
567 writel((u32)paddr, port + PORT_CMD_ACTIVATE); 572 writel((u32)paddr, port + PORT_CMD_ACTIVATE);
568 writel((u64)paddr >> 32, port + PORT_CMD_ACTIVATE + 4); 573 writel((u64)paddr >> 32, port + PORT_CMD_ACTIVATE + 4);
@@ -1050,7 +1055,8 @@ static void sil24_init_controller(struct pci_dev *pdev, int n_ports,
1050 writel(PORT_CS_32BIT_ACTV, port + PORT_CTRL_CLR); 1055 writel(PORT_CS_32BIT_ACTV, port + PORT_CTRL_CLR);
1051 1056
1052 /* Clear port multiplier enable and resume bits */ 1057 /* Clear port multiplier enable and resume bits */
1053 writel(PORT_CS_PM_EN | PORT_CS_RESUME, port + PORT_CTRL_CLR); 1058 writel(PORT_CS_PMP_EN | PORT_CS_PMP_RESUME,
1059 port + PORT_CTRL_CLR);
1054 } 1060 }
1055 1061
1056 /* Turn on interrupts */ 1062 /* Turn on interrupts */
diff --git a/drivers/ata/sata_sis.c b/drivers/ata/sata_sis.c
index 9d1235ba06b1..9c25a1e91730 100644
--- a/drivers/ata/sata_sis.c
+++ b/drivers/ata/sata_sis.c
@@ -173,7 +173,7 @@ static u32 sis_scr_cfg_read (struct ata_port *ap, unsigned int sc_reg)
173 if ((pdev->device == 0x182) || (pmr & SIS_PMR_COMBINED)) 173 if ((pdev->device == 0x182) || (pmr & SIS_PMR_COMBINED))
174 pci_read_config_dword(pdev, cfg_addr+0x10, &val2); 174 pci_read_config_dword(pdev, cfg_addr+0x10, &val2);
175 175
176 return val|val2; 176 return (val|val2) & 0xfffffffb; /* avoid problems with powerdowned ports */
177} 177}
178 178
179static void sis_scr_cfg_write (struct ata_port *ap, unsigned int scr, u32 val) 179static void sis_scr_cfg_write (struct ata_port *ap, unsigned int scr, u32 val)
@@ -212,7 +212,7 @@ static u32 sis_scr_read (struct ata_port *ap, unsigned int sc_reg)
212 if ((pdev->device == 0x182) || (pmr & SIS_PMR_COMBINED)) 212 if ((pdev->device == 0x182) || (pmr & SIS_PMR_COMBINED))
213 val2 = inl(ap->ioaddr.scr_addr + (sc_reg * 4) + 0x10); 213 val2 = inl(ap->ioaddr.scr_addr + (sc_reg * 4) + 0x10);
214 214
215 return val | val2; 215 return (val | val2) & 0xfffffffb;
216} 216}
217 217
218static void sis_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val) 218static void sis_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
@@ -239,7 +239,7 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
239 static int printed_version; 239 static int printed_version;
240 struct ata_probe_ent *probe_ent = NULL; 240 struct ata_probe_ent *probe_ent = NULL;
241 int rc; 241 int rc;
242 u32 genctl; 242 u32 genctl, val;
243 struct ata_port_info pi = sis_port_info, *ppi[2] = { &pi, &pi }; 243 struct ata_port_info pi = sis_port_info, *ppi[2] = { &pi, &pi };
244 int pci_dev_busy = 0; 244 int pci_dev_busy = 0;
245 u8 pmr; 245 u8 pmr;
@@ -285,17 +285,24 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
285 if (ent->device != 0x182) { 285 if (ent->device != 0x182) {
286 if ((pmr & SIS_PMR_COMBINED) == 0) { 286 if ((pmr & SIS_PMR_COMBINED) == 0) {
287 dev_printk(KERN_INFO, &pdev->dev, 287 dev_printk(KERN_INFO, &pdev->dev,
288 "Detected SiS 180/181 chipset in SATA mode\n"); 288 "Detected SiS 180/181/964 chipset in SATA mode\n");
289 port2_start = 64; 289 port2_start = 64;
290 } 290 }
291 else { 291 else {
292 dev_printk(KERN_INFO, &pdev->dev, 292 dev_printk(KERN_INFO, &pdev->dev,
293 "Detected SiS 180/181 chipset in combined mode\n"); 293 "Detected SiS 180/181 chipset in combined mode\n");
294 port2_start=0; 294 port2_start=0;
295 pi.flags |= ATA_FLAG_SLAVE_POSS;
295 } 296 }
296 } 297 }
297 else { 298 else {
298 dev_printk(KERN_INFO, &pdev->dev, "Detected SiS 182 chipset\n"); 299 pci_read_config_dword ( pdev, 0x6C, &val);
300 if (val & (1L << 31)) {
301 dev_printk(KERN_INFO, &pdev->dev, "Detected SiS 182/965 chipset\n");
302 pi.flags |= ATA_FLAG_SLAVE_POSS;
303 }
304 else
305 dev_printk(KERN_INFO, &pdev->dev, "Detected SiS 182/965L chipset\n");
299 port2_start = 0x20; 306 port2_start = 0x20;
300 } 307 }
301 308
diff --git a/drivers/ata/sata_via.c b/drivers/ata/sata_via.c
index f4455a1efe2d..1c7f19aecc25 100644
--- a/drivers/ata/sata_via.c
+++ b/drivers/ata/sata_via.c
@@ -230,7 +230,7 @@ static int vt6420_prereset(struct ata_port *ap)
230 int online; 230 int online;
231 231
232 /* don't do any SCR stuff if we're not loading */ 232 /* don't do any SCR stuff if we're not loading */
233 if (!ATA_PFLAG_LOADING) 233 if (!(ap->pflags & ATA_PFLAG_LOADING))
234 goto skip_scr; 234 goto skip_scr;
235 235
236 /* Resume phy. This is the old resume sequence from 236 /* Resume phy. This is the old resume sequence from
diff --git a/drivers/atm/Makefile b/drivers/atm/Makefile
index b5077ce8cb40..1b16f8166b09 100644
--- a/drivers/atm/Makefile
+++ b/drivers/atm/Makefile
@@ -41,7 +41,7 @@ ifeq ($(CONFIG_ATM_FORE200E_PCA),y)
41 # guess the target endianess to choose the right PCA-200E firmware image 41 # guess the target endianess to choose the right PCA-200E firmware image
42 ifeq ($(CONFIG_ATM_FORE200E_PCA_DEFAULT_FW),y) 42 ifeq ($(CONFIG_ATM_FORE200E_PCA_DEFAULT_FW),y)
43 byteorder.h := include$(if $(patsubst $(srctree),,$(objtree)),2)/asm/byteorder.h 43 byteorder.h := include$(if $(patsubst $(srctree),,$(objtree)),2)/asm/byteorder.h
44 CONFIG_ATM_FORE200E_PCA_FW := $(obj)/pca200e$(if $(shell $(CC) -E -dM $(byteorder.h) | grep ' __LITTLE_ENDIAN '),.bin,_ecd.bin2) 44 CONFIG_ATM_FORE200E_PCA_FW := $(obj)/pca200e$(if $(shell $(CC) $(CPPFLAGS) -E -dM $(byteorder.h) | grep ' __LITTLE_ENDIAN '),.bin,_ecd.bin2)
45 endif 45 endif
46endif 46endif
47 47
diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
index 9fffa7af6db1..afa7d750a593 100644
--- a/drivers/atm/ambassador.c
+++ b/drivers/atm/ambassador.c
@@ -972,7 +972,7 @@ static int make_rate (unsigned int rate, rounding r,
972 } 972 }
973 case round_up: { 973 case round_up: {
974 // check all bits that we are discarding 974 // check all bits that we are discarding
975 if (man & (-1>>9)) { 975 if (man & (~0U>>9)) {
976 man = (man>>(32-9)) + 1; 976 man = (man>>(32-9)) + 1;
977 if (man == (1<<9)) { 977 if (man == (1<<9)) {
978 // no need to check for round up outside of range 978 // no need to check for round up outside of range
diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
index 697ad82f6634..9c67df5ccfa4 100644
--- a/drivers/atm/firestream.c
+++ b/drivers/atm/firestream.c
@@ -512,7 +512,7 @@ static unsigned int make_rate (unsigned int rate, int r,
512 } 512 }
513 case ROUND_UP: { 513 case ROUND_UP: {
514 /* check all bits that we are discarding */ 514 /* check all bits that we are discarding */
515 if (man & (-1>>9)) { 515 if (man & (~0U>>9)) {
516 man = (man>>(32-9)) + 1; 516 man = (man>>(32-9)) + 1;
517 if (man == (1<<9)) { 517 if (man == (1<<9)) {
518 /* no need to check for round up outside of range */ 518 /* no need to check for round up outside of range */
diff --git a/drivers/atm/he.c b/drivers/atm/he.c
index c7314a79da0f..7d9b4e52f0bf 100644
--- a/drivers/atm/he.c
+++ b/drivers/atm/he.c
@@ -820,7 +820,7 @@ he_init_group(struct he_dev *he_dev, int group)
820 void *cpuaddr; 820 void *cpuaddr;
821 821
822#ifdef USE_RBPS_POOL 822#ifdef USE_RBPS_POOL
823 cpuaddr = pci_pool_alloc(he_dev->rbps_pool, SLAB_KERNEL|SLAB_DMA, &dma_handle); 823 cpuaddr = pci_pool_alloc(he_dev->rbps_pool, GFP_KERNEL|GFP_DMA, &dma_handle);
824 if (cpuaddr == NULL) 824 if (cpuaddr == NULL)
825 return -ENOMEM; 825 return -ENOMEM;
826#else 826#else
@@ -884,7 +884,7 @@ he_init_group(struct he_dev *he_dev, int group)
884 void *cpuaddr; 884 void *cpuaddr;
885 885
886#ifdef USE_RBPL_POOL 886#ifdef USE_RBPL_POOL
887 cpuaddr = pci_pool_alloc(he_dev->rbpl_pool, SLAB_KERNEL|SLAB_DMA, &dma_handle); 887 cpuaddr = pci_pool_alloc(he_dev->rbpl_pool, GFP_KERNEL|GFP_DMA, &dma_handle);
888 if (cpuaddr == NULL) 888 if (cpuaddr == NULL)
889 return -ENOMEM; 889 return -ENOMEM;
890#else 890#else
@@ -1724,7 +1724,7 @@ __alloc_tpd(struct he_dev *he_dev)
1724 struct he_tpd *tpd; 1724 struct he_tpd *tpd;
1725 dma_addr_t dma_handle; 1725 dma_addr_t dma_handle;
1726 1726
1727 tpd = pci_pool_alloc(he_dev->tpd_pool, SLAB_ATOMIC|SLAB_DMA, &dma_handle); 1727 tpd = pci_pool_alloc(he_dev->tpd_pool, GFP_ATOMIC|GFP_DMA, &dma_handle);
1728 if (tpd == NULL) 1728 if (tpd == NULL)
1729 return NULL; 1729 return NULL;
1730 1730
diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
index 87b17c33b3f9..f40786121948 100644
--- a/drivers/atm/idt77252.c
+++ b/drivers/atm/idt77252.c
@@ -135,7 +135,7 @@ static int idt77252_change_qos(struct atm_vcc *vcc, struct atm_qos *qos,
135 int flags); 135 int flags);
136static int idt77252_proc_read(struct atm_dev *dev, loff_t * pos, 136static int idt77252_proc_read(struct atm_dev *dev, loff_t * pos,
137 char *page); 137 char *page);
138static void idt77252_softint(void *dev_id); 138static void idt77252_softint(struct work_struct *work);
139 139
140 140
141static struct atmdev_ops idt77252_ops = 141static struct atmdev_ops idt77252_ops =
@@ -2866,9 +2866,10 @@ out:
2866} 2866}
2867 2867
2868static void 2868static void
2869idt77252_softint(void *dev_id) 2869idt77252_softint(struct work_struct *work)
2870{ 2870{
2871 struct idt77252_dev *card = dev_id; 2871 struct idt77252_dev *card =
2872 container_of(work, struct idt77252_dev, tqueue);
2872 u32 stat; 2873 u32 stat;
2873 int done; 2874 int done;
2874 2875
@@ -3697,7 +3698,7 @@ idt77252_init_one(struct pci_dev *pcidev, const struct pci_device_id *id)
3697 card->pcidev = pcidev; 3698 card->pcidev = pcidev;
3698 sprintf(card->name, "idt77252-%d", card->index); 3699 sprintf(card->name, "idt77252-%d", card->index);
3699 3700
3700 INIT_WORK(&card->tqueue, idt77252_softint, (void *)card); 3701 INIT_WORK(&card->tqueue, idt77252_softint);
3701 3702
3702 membase = pci_resource_start(pcidev, 1); 3703 membase = pci_resource_start(pcidev, 1);
3703 srambase = pci_resource_start(pcidev, 2); 3704 srambase = pci_resource_start(pcidev, 2);
diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
index 9ed1c60048f0..bb7ef570514c 100644
--- a/drivers/atm/iphase.c
+++ b/drivers/atm/iphase.c
@@ -305,7 +305,7 @@ static void clear_lockup (struct atm_vcc *vcc, IADEV *dev) {
305** | R | NZ | 5-bit exponent | 9-bit mantissa | 305** | R | NZ | 5-bit exponent | 9-bit mantissa |
306** +----+----+------------------+-------------------------------+ 306** +----+----+------------------+-------------------------------+
307** 307**
308** R = reserverd (written as 0) 308** R = reserved (written as 0)
309** NZ = 0 if 0 cells/sec; 1 otherwise 309** NZ = 0 if 0 cells/sec; 1 otherwise
310** 310**
311** if NZ = 1, rate = 1.mmmmmmmmm x 2^(eeeee) cells/sec 311** if NZ = 1, rate = 1.mmmmmmmmm x 2^(eeeee) cells/sec
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 7d8a7ce73fb3..472810f8e6e7 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -355,6 +355,21 @@ static void device_remove_attrs(struct bus_type * bus, struct device * dev)
355 } 355 }
356} 356}
357 357
358#ifdef CONFIG_SYSFS_DEPRECATED
359static int make_deprecated_bus_links(struct device *dev)
360{
361 return sysfs_create_link(&dev->kobj,
362 &dev->bus->subsys.kset.kobj, "bus");
363}
364
365static void remove_deprecated_bus_links(struct device *dev)
366{
367 sysfs_remove_link(&dev->kobj, "bus");
368}
369#else
370static inline int make_deprecated_bus_links(struct device *dev) { return 0; }
371static inline void remove_deprecated_bus_links(struct device *dev) { }
372#endif
358 373
359/** 374/**
360 * bus_add_device - add device to bus 375 * bus_add_device - add device to bus
@@ -381,8 +396,7 @@ int bus_add_device(struct device * dev)
381 &dev->bus->subsys.kset.kobj, "subsystem"); 396 &dev->bus->subsys.kset.kobj, "subsystem");
382 if (error) 397 if (error)
383 goto out_subsys; 398 goto out_subsys;
384 error = sysfs_create_link(&dev->kobj, 399 error = make_deprecated_bus_links(dev);
385 &dev->bus->subsys.kset.kobj, "bus");
386 if (error) 400 if (error)
387 goto out_deprecated; 401 goto out_deprecated;
388 } 402 }
@@ -436,7 +450,7 @@ void bus_remove_device(struct device * dev)
436{ 450{
437 if (dev->bus) { 451 if (dev->bus) {
438 sysfs_remove_link(&dev->kobj, "subsystem"); 452 sysfs_remove_link(&dev->kobj, "subsystem");
439 sysfs_remove_link(&dev->kobj, "bus"); 453 remove_deprecated_bus_links(dev);
440 sysfs_remove_link(&dev->bus->devices.kobj, dev->bus_id); 454 sysfs_remove_link(&dev->bus->devices.kobj, dev->bus_id);
441 device_remove_attrs(dev->bus, dev); 455 device_remove_attrs(dev->bus, dev);
442 if (dev->is_registered) { 456 if (dev->is_registered) {
@@ -724,6 +738,8 @@ int bus_register(struct bus_type * bus)
724{ 738{
725 int retval; 739 int retval;
726 740
741 BLOCKING_INIT_NOTIFIER_HEAD(&bus->bus_notifier);
742
727 retval = kobject_set_name(&bus->subsys.kset.kobj, "%s", bus->name); 743 retval = kobject_set_name(&bus->subsys.kset.kobj, "%s", bus->name);
728 if (retval) 744 if (retval)
729 goto out; 745 goto out;
@@ -782,6 +798,18 @@ void bus_unregister(struct bus_type * bus)
782 subsystem_unregister(&bus->subsys); 798 subsystem_unregister(&bus->subsys);
783} 799}
784 800
801int bus_register_notifier(struct bus_type *bus, struct notifier_block *nb)
802{
803 return blocking_notifier_chain_register(&bus->bus_notifier, nb);
804}
805EXPORT_SYMBOL_GPL(bus_register_notifier);
806
807int bus_unregister_notifier(struct bus_type *bus, struct notifier_block *nb)
808{
809 return blocking_notifier_chain_unregister(&bus->bus_notifier, nb);
810}
811EXPORT_SYMBOL_GPL(bus_unregister_notifier);
812
785int __init buses_init(void) 813int __init buses_init(void)
786{ 814{
787 return subsystem_register(&bus_subsys); 815 return subsystem_register(&bus_subsys);
diff --git a/drivers/base/class.c b/drivers/base/class.c
index 0ff267a248db..f098881f45b2 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -352,6 +352,92 @@ static const char *class_uevent_name(struct kset *kset, struct kobject *kobj)
352 return class_dev->class->name; 352 return class_dev->class->name;
353} 353}
354 354
355#ifdef CONFIG_SYSFS_DEPRECATED
356char *make_class_name(const char *name, struct kobject *kobj)
357{
358 char *class_name;
359 int size;
360
361 size = strlen(name) + strlen(kobject_name(kobj)) + 2;
362
363 class_name = kmalloc(size, GFP_KERNEL);
364 if (!class_name)
365 return ERR_PTR(-ENOMEM);
366
367 strcpy(class_name, name);
368 strcat(class_name, ":");
369 strcat(class_name, kobject_name(kobj));
370 return class_name;
371}
372
373static int deprecated_class_uevent(char **envp, int num_envp, int *cur_index,
374 char *buffer, int buffer_size,
375 int *cur_len,
376 struct class_device *class_dev)
377{
378 struct device *dev = class_dev->dev;
379 char *path;
380
381 if (!dev)
382 return 0;
383
384 /* add device, backing this class device (deprecated) */
385 path = kobject_get_path(&dev->kobj, GFP_KERNEL);
386
387 add_uevent_var(envp, num_envp, cur_index, buffer, buffer_size,
388 cur_len, "PHYSDEVPATH=%s", path);
389 kfree(path);
390
391 if (dev->bus)
392 add_uevent_var(envp, num_envp, cur_index,
393 buffer, buffer_size, cur_len,
394 "PHYSDEVBUS=%s", dev->bus->name);
395
396 if (dev->driver)
397 add_uevent_var(envp, num_envp, cur_index,
398 buffer, buffer_size, cur_len,
399 "PHYSDEVDRIVER=%s", dev->driver->name);
400 return 0;
401}
402
403static int make_deprecated_class_device_links(struct class_device *class_dev)
404{
405 char *class_name;
406 int error;
407
408 if (!class_dev->dev)
409 return 0;
410
411 class_name = make_class_name(class_dev->class->name, &class_dev->kobj);
412 error = sysfs_create_link(&class_dev->dev->kobj, &class_dev->kobj,
413 class_name);
414 kfree(class_name);
415 return error;
416}
417
418static void remove_deprecated_class_device_links(struct class_device *class_dev)
419{
420 char *class_name;
421
422 if (!class_dev->dev)
423 return;
424
425 class_name = make_class_name(class_dev->class->name, &class_dev->kobj);
426 sysfs_remove_link(&class_dev->dev->kobj, class_name);
427 kfree(class_name);
428}
429#else
430static inline int deprecated_class_uevent(char **envp, int num_envp,
431 int *cur_index, char *buffer,
432 int buffer_size, int *cur_len,
433 struct class_device *class_dev)
434{ return 0; }
435static inline int make_deprecated_class_device_links(struct class_device *cd)
436{ return 0; }
437static void remove_deprecated_class_device_links(struct class_device *cd)
438{ }
439#endif
440
355static int class_uevent(struct kset *kset, struct kobject *kobj, char **envp, 441static int class_uevent(struct kset *kset, struct kobject *kobj, char **envp,
356 int num_envp, char *buffer, int buffer_size) 442 int num_envp, char *buffer, int buffer_size)
357{ 443{
@@ -362,25 +448,8 @@ static int class_uevent(struct kset *kset, struct kobject *kobj, char **envp,
362 448
363 pr_debug("%s - name = %s\n", __FUNCTION__, class_dev->class_id); 449 pr_debug("%s - name = %s\n", __FUNCTION__, class_dev->class_id);
364 450
365 if (class_dev->dev) { 451 deprecated_class_uevent(envp, num_envp, &i, buffer, buffer_size,
366 /* add device, backing this class device (deprecated) */ 452 &length, class_dev);
367 struct device *dev = class_dev->dev;
368 char *path = kobject_get_path(&dev->kobj, GFP_KERNEL);
369
370 add_uevent_var(envp, num_envp, &i, buffer, buffer_size,
371 &length, "PHYSDEVPATH=%s", path);
372 kfree(path);
373
374 if (dev->bus)
375 add_uevent_var(envp, num_envp, &i,
376 buffer, buffer_size, &length,
377 "PHYSDEVBUS=%s", dev->bus->name);
378
379 if (dev->driver)
380 add_uevent_var(envp, num_envp, &i,
381 buffer, buffer_size, &length,
382 "PHYSDEVDRIVER=%s", dev->driver->name);
383 }
384 453
385 if (MAJOR(class_dev->devt)) { 454 if (MAJOR(class_dev->devt)) {
386 add_uevent_var(envp, num_envp, &i, 455 add_uevent_var(envp, num_envp, &i,
@@ -506,29 +575,11 @@ void class_device_initialize(struct class_device *class_dev)
506 INIT_LIST_HEAD(&class_dev->node); 575 INIT_LIST_HEAD(&class_dev->node);
507} 576}
508 577
509char *make_class_name(const char *name, struct kobject *kobj)
510{
511 char *class_name;
512 int size;
513
514 size = strlen(name) + strlen(kobject_name(kobj)) + 2;
515
516 class_name = kmalloc(size, GFP_KERNEL);
517 if (!class_name)
518 return ERR_PTR(-ENOMEM);
519
520 strcpy(class_name, name);
521 strcat(class_name, ":");
522 strcat(class_name, kobject_name(kobj));
523 return class_name;
524}
525
526int class_device_add(struct class_device *class_dev) 578int class_device_add(struct class_device *class_dev)
527{ 579{
528 struct class *parent_class = NULL; 580 struct class *parent_class = NULL;
529 struct class_device *parent_class_dev = NULL; 581 struct class_device *parent_class_dev = NULL;
530 struct class_interface *class_intf; 582 struct class_interface *class_intf;
531 char *class_name = NULL;
532 int error = -EINVAL; 583 int error = -EINVAL;
533 584
534 class_dev = class_device_get(class_dev); 585 class_dev = class_device_get(class_dev);
@@ -599,20 +650,18 @@ int class_device_add(struct class_device *class_dev)
599 goto out5; 650 goto out5;
600 651
601 if (class_dev->dev) { 652 if (class_dev->dev) {
602 class_name = make_class_name(class_dev->class->name,
603 &class_dev->kobj);
604 error = sysfs_create_link(&class_dev->kobj, 653 error = sysfs_create_link(&class_dev->kobj,
605 &class_dev->dev->kobj, "device"); 654 &class_dev->dev->kobj, "device");
606 if (error) 655 if (error)
607 goto out6; 656 goto out6;
608 error = sysfs_create_link(&class_dev->dev->kobj, &class_dev->kobj,
609 class_name);
610 if (error)
611 goto out7;
612 } 657 }
613 658
614 error = class_device_add_groups(class_dev); 659 error = class_device_add_groups(class_dev);
615 if (error) 660 if (error)
661 goto out7;
662
663 error = make_deprecated_class_device_links(class_dev);
664 if (error)
616 goto out8; 665 goto out8;
617 666
618 kobject_uevent(&class_dev->kobj, KOBJ_ADD); 667 kobject_uevent(&class_dev->kobj, KOBJ_ADD);
@@ -629,8 +678,7 @@ int class_device_add(struct class_device *class_dev)
629 goto out1; 678 goto out1;
630 679
631 out8: 680 out8:
632 if (class_dev->dev) 681 class_device_remove_groups(class_dev);
633 sysfs_remove_link(&class_dev->kobj, class_name);
634 out7: 682 out7:
635 if (class_dev->dev) 683 if (class_dev->dev)
636 sysfs_remove_link(&class_dev->kobj, "device"); 684 sysfs_remove_link(&class_dev->kobj, "device");
@@ -649,7 +697,6 @@ int class_device_add(struct class_device *class_dev)
649 class_put(parent_class); 697 class_put(parent_class);
650 out1: 698 out1:
651 class_device_put(class_dev); 699 class_device_put(class_dev);
652 kfree(class_name);
653 return error; 700 return error;
654} 701}
655 702
@@ -726,7 +773,6 @@ void class_device_del(struct class_device *class_dev)
726 struct class *parent_class = class_dev->class; 773 struct class *parent_class = class_dev->class;
727 struct class_device *parent_device = class_dev->parent; 774 struct class_device *parent_device = class_dev->parent;
728 struct class_interface *class_intf; 775 struct class_interface *class_intf;
729 char *class_name = NULL;
730 776
731 if (parent_class) { 777 if (parent_class) {
732 down(&parent_class->sem); 778 down(&parent_class->sem);
@@ -738,10 +784,8 @@ void class_device_del(struct class_device *class_dev)
738 } 784 }
739 785
740 if (class_dev->dev) { 786 if (class_dev->dev) {
741 class_name = make_class_name(class_dev->class->name, 787 remove_deprecated_class_device_links(class_dev);
742 &class_dev->kobj);
743 sysfs_remove_link(&class_dev->kobj, "device"); 788 sysfs_remove_link(&class_dev->kobj, "device");
744 sysfs_remove_link(&class_dev->dev->kobj, class_name);
745 } 789 }
746 sysfs_remove_link(&class_dev->kobj, "subsystem"); 790 sysfs_remove_link(&class_dev->kobj, "subsystem");
747 class_device_remove_file(class_dev, &class_dev->uevent_attr); 791 class_device_remove_file(class_dev, &class_dev->uevent_attr);
@@ -755,7 +799,6 @@ void class_device_del(struct class_device *class_dev)
755 799
756 class_device_put(parent_device); 800 class_device_put(parent_device);
757 class_put(parent_class); 801 class_put(parent_class);
758 kfree(class_name);
759} 802}
760 803
761void class_device_unregister(struct class_device *class_dev) 804void class_device_unregister(struct class_device *class_dev)
@@ -804,14 +847,17 @@ int class_device_rename(struct class_device *class_dev, char *new_name)
804 pr_debug("CLASS: renaming '%s' to '%s'\n", class_dev->class_id, 847 pr_debug("CLASS: renaming '%s' to '%s'\n", class_dev->class_id,
805 new_name); 848 new_name);
806 849
850#ifdef CONFIG_SYSFS_DEPRECATED
807 if (class_dev->dev) 851 if (class_dev->dev)
808 old_class_name = make_class_name(class_dev->class->name, 852 old_class_name = make_class_name(class_dev->class->name,
809 &class_dev->kobj); 853 &class_dev->kobj);
854#endif
810 855
811 strlcpy(class_dev->class_id, new_name, KOBJ_NAME_LEN); 856 strlcpy(class_dev->class_id, new_name, KOBJ_NAME_LEN);
812 857
813 error = kobject_rename(&class_dev->kobj, new_name); 858 error = kobject_rename(&class_dev->kobj, new_name);
814 859
860#ifdef CONFIG_SYSFS_DEPRECATED
815 if (class_dev->dev) { 861 if (class_dev->dev) {
816 new_class_name = make_class_name(class_dev->class->name, 862 new_class_name = make_class_name(class_dev->class->name,
817 &class_dev->kobj); 863 &class_dev->kobj);
@@ -819,6 +865,7 @@ int class_device_rename(struct class_device *class_dev, char *new_name)
819 new_class_name); 865 new_class_name);
820 sysfs_remove_link(&class_dev->dev->kobj, old_class_name); 866 sysfs_remove_link(&class_dev->dev->kobj, old_class_name);
821 } 867 }
868#endif
822 class_device_put(class_dev); 869 class_device_put(class_dev);
823 870
824 kfree(old_class_name); 871 kfree(old_class_name);
@@ -893,23 +940,6 @@ void class_interface_unregister(struct class_interface *class_intf)
893 class_put(parent); 940 class_put(parent);
894} 941}
895 942
896int virtual_device_parent(struct device *dev)
897{
898 if (!dev->class)
899 return -ENODEV;
900
901 if (!dev->class->virtual_dir) {
902 static struct kobject *virtual_dir = NULL;
903
904 if (!virtual_dir)
905 virtual_dir = kobject_add_dir(&devices_subsys.kset.kobj, "virtual");
906 dev->class->virtual_dir = kobject_add_dir(virtual_dir, dev->class->name);
907 }
908
909 dev->kobj.parent = dev->class->virtual_dir;
910 return 0;
911}
912
913int __init classes_init(void) 943int __init classes_init(void)
914{ 944{
915 int retval; 945 int retval;
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 68ad11af22b4..67b79a7592a9 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -17,6 +17,7 @@
17#include <linux/slab.h> 17#include <linux/slab.h>
18#include <linux/string.h> 18#include <linux/string.h>
19#include <linux/kdev_t.h> 19#include <linux/kdev_t.h>
20#include <linux/notifier.h>
20 21
21#include <asm/semaphore.h> 22#include <asm/semaphore.h>
22 23
@@ -153,20 +154,24 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj, char **envp,
153 "MINOR=%u", MINOR(dev->devt)); 154 "MINOR=%u", MINOR(dev->devt));
154 } 155 }
155 156
157#ifdef CONFIG_SYSFS_DEPRECATED
156 /* add bus name (same as SUBSYSTEM, deprecated) */ 158 /* add bus name (same as SUBSYSTEM, deprecated) */
157 if (dev->bus) 159 if (dev->bus)
158 add_uevent_var(envp, num_envp, &i, 160 add_uevent_var(envp, num_envp, &i,
159 buffer, buffer_size, &length, 161 buffer, buffer_size, &length,
160 "PHYSDEVBUS=%s", dev->bus->name); 162 "PHYSDEVBUS=%s", dev->bus->name);
163#endif
161 164
162 /* add driver name (PHYSDEV* values are deprecated)*/ 165 /* add driver name (PHYSDEV* values are deprecated)*/
163 if (dev->driver) { 166 if (dev->driver) {
164 add_uevent_var(envp, num_envp, &i, 167 add_uevent_var(envp, num_envp, &i,
165 buffer, buffer_size, &length, 168 buffer, buffer_size, &length,
166 "DRIVER=%s", dev->driver->name); 169 "DRIVER=%s", dev->driver->name);
170#ifdef CONFIG_SYSFS_DEPRECATED
167 add_uevent_var(envp, num_envp, &i, 171 add_uevent_var(envp, num_envp, &i,
168 buffer, buffer_size, &length, 172 buffer, buffer_size, &length,
169 "PHYSDEVDRIVER=%s", dev->driver->name); 173 "PHYSDEVDRIVER=%s", dev->driver->name);
174#endif
170 } 175 }
171 176
172 /* terminate, set to next free slot, shrink available space */ 177 /* terminate, set to next free slot, shrink available space */
@@ -381,8 +386,55 @@ void device_initialize(struct device *dev)
381 INIT_LIST_HEAD(&dev->node); 386 INIT_LIST_HEAD(&dev->node);
382 init_MUTEX(&dev->sem); 387 init_MUTEX(&dev->sem);
383 device_init_wakeup(dev, 0); 388 device_init_wakeup(dev, 0);
389 set_dev_node(dev, -1);
384} 390}
385 391
392#ifdef CONFIG_SYSFS_DEPRECATED
393static int setup_parent(struct device *dev, struct device *parent)
394{
395 /* Set the parent to the class, not the parent device */
396 /* this keeps sysfs from having a symlink to make old udevs happy */
397 if (dev->class)
398 dev->kobj.parent = &dev->class->subsys.kset.kobj;
399 else if (parent)
400 dev->kobj.parent = &parent->kobj;
401
402 return 0;
403}
404#else
405static int virtual_device_parent(struct device *dev)
406{
407 if (!dev->class)
408 return -ENODEV;
409
410 if (!dev->class->virtual_dir) {
411 static struct kobject *virtual_dir = NULL;
412
413 if (!virtual_dir)
414 virtual_dir = kobject_add_dir(&devices_subsys.kset.kobj, "virtual");
415 dev->class->virtual_dir = kobject_add_dir(virtual_dir, dev->class->name);
416 }
417
418 dev->kobj.parent = dev->class->virtual_dir;
419 return 0;
420}
421
422static int setup_parent(struct device *dev, struct device *parent)
423{
424 int error;
425
426 /* if this is a class device, and has no parent, create one */
427 if ((dev->class) && (parent == NULL)) {
428 error = virtual_device_parent(dev);
429 if (error)
430 return error;
431 } else if (parent)
432 dev->kobj.parent = &parent->kobj;
433
434 return 0;
435}
436#endif
437
386/** 438/**
387 * device_add - add device to device hierarchy. 439 * device_add - add device to device hierarchy.
388 * @dev: device. 440 * @dev: device.
@@ -405,29 +457,29 @@ int device_add(struct device *dev)
405 if (!dev || !strlen(dev->bus_id)) 457 if (!dev || !strlen(dev->bus_id))
406 goto Error; 458 goto Error;
407 459
408 /* if this is a class device, and has no parent, create one */ 460 pr_debug("DEV: registering device: ID = '%s'\n", dev->bus_id);
409 if ((dev->class) && (dev->parent == NULL)) {
410 error = virtual_device_parent(dev);
411 if (error)
412 goto Error;
413 }
414 461
415 parent = get_device(dev->parent); 462 parent = get_device(dev->parent);
416 463
417 pr_debug("DEV: registering device: ID = '%s'\n", dev->bus_id); 464 error = setup_parent(dev, parent);
465 if (error)
466 goto Error;
418 467
419 /* first, register with generic layer. */ 468 /* first, register with generic layer. */
420 kobject_set_name(&dev->kobj, "%s", dev->bus_id); 469 kobject_set_name(&dev->kobj, "%s", dev->bus_id);
421 if (parent) 470 error = kobject_add(&dev->kobj);
422 dev->kobj.parent = &parent->kobj; 471 if (error)
423
424 if ((error = kobject_add(&dev->kobj)))
425 goto Error; 472 goto Error;
426 473
427 /* notify platform of device entry */ 474 /* notify platform of device entry */
428 if (platform_notify) 475 if (platform_notify)
429 platform_notify(dev); 476 platform_notify(dev);
430 477
478 /* notify clients of device entry (new way) */
479 if (dev->bus)
480 blocking_notifier_call_chain(&dev->bus->bus_notifier,
481 BUS_NOTIFY_ADD_DEVICE, dev);
482
431 dev->uevent_attr.attr.name = "uevent"; 483 dev->uevent_attr.attr.name = "uevent";
432 dev->uevent_attr.attr.mode = S_IWUSR; 484 dev->uevent_attr.attr.mode = S_IWUSR;
433 if (dev->driver) 485 if (dev->driver)
@@ -461,13 +513,18 @@ int device_add(struct device *dev)
461 if (dev->class) { 513 if (dev->class) {
462 sysfs_create_link(&dev->kobj, &dev->class->subsys.kset.kobj, 514 sysfs_create_link(&dev->kobj, &dev->class->subsys.kset.kobj,
463 "subsystem"); 515 "subsystem");
464 sysfs_create_link(&dev->class->subsys.kset.kobj, &dev->kobj, 516 /* If this is not a "fake" compatible device, then create the
465 dev->bus_id); 517 * symlink from the class to the device. */
518 if (dev->kobj.parent != &dev->class->subsys.kset.kobj)
519 sysfs_create_link(&dev->class->subsys.kset.kobj,
520 &dev->kobj, dev->bus_id);
521#ifdef CONFIG_SYSFS_DEPRECATED
466 if (parent) { 522 if (parent) {
467 sysfs_create_link(&dev->kobj, &dev->parent->kobj, "device"); 523 sysfs_create_link(&dev->kobj, &dev->parent->kobj, "device");
468 class_name = make_class_name(dev->class->name, &dev->kobj); 524 class_name = make_class_name(dev->class->name, &dev->kobj);
469 sysfs_create_link(&dev->parent->kobj, &dev->kobj, class_name); 525 sysfs_create_link(&dev->parent->kobj, &dev->kobj, class_name);
470 } 526 }
527#endif
471 } 528 }
472 529
473 if ((error = device_add_attrs(dev))) 530 if ((error = device_add_attrs(dev)))
@@ -504,6 +561,9 @@ int device_add(struct device *dev)
504 BusError: 561 BusError:
505 device_pm_remove(dev); 562 device_pm_remove(dev);
506 PMError: 563 PMError:
564 if (dev->bus)
565 blocking_notifier_call_chain(&dev->bus->bus_notifier,
566 BUS_NOTIFY_DEL_DEVICE, dev);
507 device_remove_groups(dev); 567 device_remove_groups(dev);
508 GroupError: 568 GroupError:
509 device_remove_attrs(dev); 569 device_remove_attrs(dev);
@@ -586,22 +646,31 @@ void put_device(struct device * dev)
586void device_del(struct device * dev) 646void device_del(struct device * dev)
587{ 647{
588 struct device * parent = dev->parent; 648 struct device * parent = dev->parent;
589 char *class_name = NULL;
590 struct class_interface *class_intf; 649 struct class_interface *class_intf;
591 650
592 if (parent) 651 if (parent)
593 klist_del(&dev->knode_parent); 652 klist_del(&dev->knode_parent);
594 if (dev->devt_attr) 653 if (dev->devt_attr) {
595 device_remove_file(dev, dev->devt_attr); 654 device_remove_file(dev, dev->devt_attr);
655 kfree(dev->devt_attr);
656 }
596 if (dev->class) { 657 if (dev->class) {
597 sysfs_remove_link(&dev->kobj, "subsystem"); 658 sysfs_remove_link(&dev->kobj, "subsystem");
598 sysfs_remove_link(&dev->class->subsys.kset.kobj, dev->bus_id); 659 /* If this is not a "fake" compatible device, remove the
599 class_name = make_class_name(dev->class->name, &dev->kobj); 660 * symlink from the class to the device. */
661 if (dev->kobj.parent != &dev->class->subsys.kset.kobj)
662 sysfs_remove_link(&dev->class->subsys.kset.kobj,
663 dev->bus_id);
664#ifdef CONFIG_SYSFS_DEPRECATED
600 if (parent) { 665 if (parent) {
601 sysfs_remove_link(&dev->kobj, "device"); 666 char *class_name = make_class_name(dev->class->name,
667 &dev->kobj);
602 sysfs_remove_link(&dev->parent->kobj, class_name); 668 sysfs_remove_link(&dev->parent->kobj, class_name);
669 kfree(class_name);
670 sysfs_remove_link(&dev->kobj, "device");
603 } 671 }
604 kfree(class_name); 672#endif
673
605 down(&dev->class->sem); 674 down(&dev->class->sem);
606 /* notify any interfaces that the device is now gone */ 675 /* notify any interfaces that the device is now gone */
607 list_for_each_entry(class_intf, &dev->class->interfaces, node) 676 list_for_each_entry(class_intf, &dev->class->interfaces, node)
@@ -614,13 +683,16 @@ void device_del(struct device * dev)
614 device_remove_file(dev, &dev->uevent_attr); 683 device_remove_file(dev, &dev->uevent_attr);
615 device_remove_groups(dev); 684 device_remove_groups(dev);
616 device_remove_attrs(dev); 685 device_remove_attrs(dev);
686 bus_remove_device(dev);
617 687
618 /* Notify the platform of the removal, in case they 688 /* Notify the platform of the removal, in case they
619 * need to do anything... 689 * need to do anything...
620 */ 690 */
621 if (platform_notify_remove) 691 if (platform_notify_remove)
622 platform_notify_remove(dev); 692 platform_notify_remove(dev);
623 bus_remove_device(dev); 693 if (dev->bus)
694 blocking_notifier_call_chain(&dev->bus->bus_notifier,
695 BUS_NOTIFY_DEL_DEVICE, dev);
624 device_pm_remove(dev); 696 device_pm_remove(dev);
625 kobject_uevent(&dev->kobj, KOBJ_REMOVE); 697 kobject_uevent(&dev->kobj, KOBJ_REMOVE);
626 kobject_del(&dev->kobj); 698 kobject_del(&dev->kobj);
@@ -679,12 +751,45 @@ int device_for_each_child(struct device * parent, void * data,
679 return error; 751 return error;
680} 752}
681 753
754/**
755 * device_find_child - device iterator for locating a particular device.
756 * @parent: parent struct device
757 * @data: Data to pass to match function
758 * @match: Callback function to check device
759 *
760 * This is similar to the device_for_each_child() function above, but it
761 * returns a reference to a device that is 'found' for later use, as
762 * determined by the @match callback.
763 *
764 * The callback should return 0 if the device doesn't match and non-zero
765 * if it does. If the callback returns non-zero and a reference to the
766 * current device can be obtained, this function will return to the caller
767 * and not iterate over any more devices.
768 */
769struct device * device_find_child(struct device *parent, void *data,
770 int (*match)(struct device *, void *))
771{
772 struct klist_iter i;
773 struct device *child;
774
775 if (!parent)
776 return NULL;
777
778 klist_iter_init(&parent->klist_children, &i);
779 while ((child = next_device(&i)))
780 if (match(child, data) && get_device(child))
781 break;
782 klist_iter_exit(&i);
783 return child;
784}
785
682int __init devices_init(void) 786int __init devices_init(void)
683{ 787{
684 return subsystem_register(&devices_subsys); 788 return subsystem_register(&devices_subsys);
685} 789}
686 790
687EXPORT_SYMBOL_GPL(device_for_each_child); 791EXPORT_SYMBOL_GPL(device_for_each_child);
792EXPORT_SYMBOL_GPL(device_find_child);
688 793
689EXPORT_SYMBOL_GPL(device_initialize); 794EXPORT_SYMBOL_GPL(device_initialize);
690EXPORT_SYMBOL_GPL(device_add); 795EXPORT_SYMBOL_GPL(device_add);
@@ -807,8 +912,10 @@ int device_rename(struct device *dev, char *new_name)
807 912
808 pr_debug("DEVICE: renaming '%s' to '%s'\n", dev->bus_id, new_name); 913 pr_debug("DEVICE: renaming '%s' to '%s'\n", dev->bus_id, new_name);
809 914
915#ifdef CONFIG_SYSFS_DEPRECATED
810 if ((dev->class) && (dev->parent)) 916 if ((dev->class) && (dev->parent))
811 old_class_name = make_class_name(dev->class->name, &dev->kobj); 917 old_class_name = make_class_name(dev->class->name, &dev->kobj);
918#endif
812 919
813 if (dev->class) { 920 if (dev->class) {
814 old_symlink_name = kmalloc(BUS_ID_SIZE, GFP_KERNEL); 921 old_symlink_name = kmalloc(BUS_ID_SIZE, GFP_KERNEL);
@@ -823,6 +930,7 @@ int device_rename(struct device *dev, char *new_name)
823 930
824 error = kobject_rename(&dev->kobj, new_name); 931 error = kobject_rename(&dev->kobj, new_name);
825 932
933#ifdef CONFIG_SYSFS_DEPRECATED
826 if (old_class_name) { 934 if (old_class_name) {
827 new_class_name = make_class_name(dev->class->name, &dev->kobj); 935 new_class_name = make_class_name(dev->class->name, &dev->kobj);
828 if (new_class_name) { 936 if (new_class_name) {
@@ -831,6 +939,8 @@ int device_rename(struct device *dev, char *new_name)
831 sysfs_remove_link(&dev->parent->kobj, old_class_name); 939 sysfs_remove_link(&dev->parent->kobj, old_class_name);
832 } 940 }
833 } 941 }
942#endif
943
834 if (dev->class) { 944 if (dev->class) {
835 sysfs_remove_link(&dev->class->subsys.kset.kobj, 945 sysfs_remove_link(&dev->class->subsys.kset.kobj,
836 old_symlink_name); 946 old_symlink_name);
@@ -846,3 +956,95 @@ int device_rename(struct device *dev, char *new_name)
846 956
847 return error; 957 return error;
848} 958}
959
960
961static int device_move_class_links(struct device *dev,
962 struct device *old_parent,
963 struct device *new_parent)
964{
965#ifdef CONFIG_SYSFS_DEPRECATED
966 int error;
967 char *class_name;
968
969 class_name = make_class_name(dev->class->name, &dev->kobj);
970 if (!class_name) {
971 error = PTR_ERR(class_name);
972 class_name = NULL;
973 goto out;
974 }
975 if (old_parent) {
976 sysfs_remove_link(&dev->kobj, "device");
977 sysfs_remove_link(&old_parent->kobj, class_name);
978 }
979 error = sysfs_create_link(&dev->kobj, &new_parent->kobj, "device");
980 if (error)
981 goto out;
982 error = sysfs_create_link(&new_parent->kobj, &dev->kobj, class_name);
983 if (error)
984 sysfs_remove_link(&dev->kobj, "device");
985out:
986 kfree(class_name);
987 return error;
988#else
989 return 0;
990#endif
991}
992
993/**
994 * device_move - moves a device to a new parent
995 * @dev: the pointer to the struct device to be moved
996 * @new_parent: the new parent of the device
997 */
998int device_move(struct device *dev, struct device *new_parent)
999{
1000 int error;
1001 struct device *old_parent;
1002
1003 dev = get_device(dev);
1004 if (!dev)
1005 return -EINVAL;
1006
1007 if (!device_is_registered(dev)) {
1008 error = -EINVAL;
1009 goto out;
1010 }
1011 new_parent = get_device(new_parent);
1012 if (!new_parent) {
1013 error = -EINVAL;
1014 goto out;
1015 }
1016 pr_debug("DEVICE: moving '%s' to '%s'\n", dev->bus_id,
1017 new_parent->bus_id);
1018 error = kobject_move(&dev->kobj, &new_parent->kobj);
1019 if (error) {
1020 put_device(new_parent);
1021 goto out;
1022 }
1023 old_parent = dev->parent;
1024 dev->parent = new_parent;
1025 if (old_parent)
1026 klist_remove(&dev->knode_parent);
1027 klist_add_tail(&dev->knode_parent, &new_parent->klist_children);
1028 if (!dev->class)
1029 goto out_put;
1030 error = device_move_class_links(dev, old_parent, new_parent);
1031 if (error) {
1032 /* We ignore errors on cleanup since we're hosed anyway... */
1033 device_move_class_links(dev, new_parent, old_parent);
1034 if (!kobject_move(&dev->kobj, &old_parent->kobj)) {
1035 klist_remove(&dev->knode_parent);
1036 if (old_parent)
1037 klist_add_tail(&dev->knode_parent,
1038 &old_parent->klist_children);
1039 }
1040 put_device(new_parent);
1041 goto out;
1042 }
1043out_put:
1044 put_device(old_parent);
1045out:
1046 put_device(dev);
1047 return error;
1048}
1049
1050EXPORT_SYMBOL_GPL(device_move);
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 4bef76a2f3f2..7fd095efaebd 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -5,6 +5,7 @@
5#include <linux/sysdev.h> 5#include <linux/sysdev.h>
6#include <linux/module.h> 6#include <linux/module.h>
7#include <linux/init.h> 7#include <linux/init.h>
8#include <linux/sched.h>
8#include <linux/cpu.h> 9#include <linux/cpu.h>
9#include <linux/topology.h> 10#include <linux/topology.h>
10#include <linux/device.h> 11#include <linux/device.h>
@@ -103,8 +104,8 @@ static SYSDEV_ATTR(crash_notes, 0400, show_crash_notes, NULL);
103 104
104/* 105/*
105 * register_cpu - Setup a driverfs device for a CPU. 106 * register_cpu - Setup a driverfs device for a CPU.
106 * @cpu - Callers can set the cpu->no_control field to 1, to indicate not to 107 * @cpu - cpu->hotpluggable field set to 1 will generate a control file in
107 * generate a control file in sysfs for this CPU. 108 * sysfs for this CPU.
108 * @num - CPU number to use when creating the device. 109 * @num - CPU number to use when creating the device.
109 * 110 *
110 * Initialize and register the CPU device. 111 * Initialize and register the CPU device.
@@ -118,7 +119,7 @@ int __devinit register_cpu(struct cpu *cpu, int num)
118 119
119 error = sysdev_register(&cpu->sysdev); 120 error = sysdev_register(&cpu->sysdev);
120 121
121 if (!error && !cpu->no_control) 122 if (!error && cpu->hotpluggable)
122 register_cpu_control(cpu); 123 register_cpu_control(cpu);
123 if (!error) 124 if (!error)
124 cpu_sys_devices[num] = &cpu->sysdev; 125 cpu_sys_devices[num] = &cpu->sysdev;
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index c5d6bb4290ad..510e7884975f 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -26,33 +26,28 @@
26#define to_drv(node) container_of(node, struct device_driver, kobj.entry) 26#define to_drv(node) container_of(node, struct device_driver, kobj.entry)
27 27
28 28
29/** 29static void driver_bound(struct device *dev)
30 * device_bind_driver - bind a driver to one device.
31 * @dev: device.
32 *
33 * Allow manual attachment of a driver to a device.
34 * Caller must have already set @dev->driver.
35 *
36 * Note that this does not modify the bus reference count
37 * nor take the bus's rwsem. Please verify those are accounted
38 * for before calling this. (It is ok to call with no other effort
39 * from a driver's probe() method.)
40 *
41 * This function must be called with @dev->sem held.
42 */
43int device_bind_driver(struct device *dev)
44{ 30{
45 int ret;
46
47 if (klist_node_attached(&dev->knode_driver)) { 31 if (klist_node_attached(&dev->knode_driver)) {
48 printk(KERN_WARNING "%s: device %s already bound\n", 32 printk(KERN_WARNING "%s: device %s already bound\n",
49 __FUNCTION__, kobject_name(&dev->kobj)); 33 __FUNCTION__, kobject_name(&dev->kobj));
50 return 0; 34 return;
51 } 35 }
52 36
53 pr_debug("bound device '%s' to driver '%s'\n", 37 pr_debug("bound device '%s' to driver '%s'\n",
54 dev->bus_id, dev->driver->name); 38 dev->bus_id, dev->driver->name);
39
40 if (dev->bus)
41 blocking_notifier_call_chain(&dev->bus->bus_notifier,
42 BUS_NOTIFY_BOUND_DRIVER, dev);
43
55 klist_add_tail(&dev->knode_driver, &dev->driver->klist_devices); 44 klist_add_tail(&dev->knode_driver, &dev->driver->klist_devices);
45}
46
47static int driver_sysfs_add(struct device *dev)
48{
49 int ret;
50
56 ret = sysfs_create_link(&dev->driver->kobj, &dev->kobj, 51 ret = sysfs_create_link(&dev->driver->kobj, &dev->kobj,
57 kobject_name(&dev->kobj)); 52 kobject_name(&dev->kobj));
58 if (ret == 0) { 53 if (ret == 0) {
@@ -65,6 +60,36 @@ int device_bind_driver(struct device *dev)
65 return ret; 60 return ret;
66} 61}
67 62
63static void driver_sysfs_remove(struct device *dev)
64{
65 struct device_driver *drv = dev->driver;
66
67 if (drv) {
68 sysfs_remove_link(&drv->kobj, kobject_name(&dev->kobj));
69 sysfs_remove_link(&dev->kobj, "driver");
70 }
71}
72
73/**
74 * device_bind_driver - bind a driver to one device.
75 * @dev: device.
76 *
77 * Allow manual attachment of a driver to a device.
78 * Caller must have already set @dev->driver.
79 *
80 * Note that this does not modify the bus reference count
81 * nor take the bus's rwsem. Please verify those are accounted
82 * for before calling this. (It is ok to call with no other effort
83 * from a driver's probe() method.)
84 *
85 * This function must be called with @dev->sem held.
86 */
87int device_bind_driver(struct device *dev)
88{
89 driver_bound(dev);
90 return driver_sysfs_add(dev);
91}
92
68struct stupid_thread_structure { 93struct stupid_thread_structure {
69 struct device_driver *drv; 94 struct device_driver *drv;
70 struct device *dev; 95 struct device *dev;
@@ -85,30 +110,32 @@ static int really_probe(void *void_data)
85 drv->bus->name, drv->name, dev->bus_id); 110 drv->bus->name, drv->name, dev->bus_id);
86 111
87 dev->driver = drv; 112 dev->driver = drv;
113 if (driver_sysfs_add(dev)) {
114 printk(KERN_ERR "%s: driver_sysfs_add(%s) failed\n",
115 __FUNCTION__, dev->bus_id);
116 goto probe_failed;
117 }
118
88 if (dev->bus->probe) { 119 if (dev->bus->probe) {
89 ret = dev->bus->probe(dev); 120 ret = dev->bus->probe(dev);
90 if (ret) { 121 if (ret)
91 dev->driver = NULL;
92 goto probe_failed; 122 goto probe_failed;
93 }
94 } else if (drv->probe) { 123 } else if (drv->probe) {
95 ret = drv->probe(dev); 124 ret = drv->probe(dev);
96 if (ret) { 125 if (ret)
97 dev->driver = NULL;
98 goto probe_failed; 126 goto probe_failed;
99 }
100 }
101 if (device_bind_driver(dev)) {
102 printk(KERN_ERR "%s: device_bind_driver(%s) failed\n",
103 __FUNCTION__, dev->bus_id);
104 /* How does undo a ->probe? We're screwed. */
105 } 127 }
128
129 driver_bound(dev);
106 ret = 1; 130 ret = 1;
107 pr_debug("%s: Bound Device %s to Driver %s\n", 131 pr_debug("%s: Bound Device %s to Driver %s\n",
108 drv->bus->name, dev->bus_id, drv->name); 132 drv->bus->name, dev->bus_id, drv->name);
109 goto done; 133 goto done;
110 134
111probe_failed: 135probe_failed:
136 driver_sysfs_remove(dev);
137 dev->driver = NULL;
138
112 if (ret == -ENODEV || ret == -ENXIO) { 139 if (ret == -ENODEV || ret == -ENXIO) {
113 /* Driver matched, but didn't support device 140 /* Driver matched, but didn't support device
114 * or device not found. 141 * or device not found.
@@ -284,10 +311,15 @@ static void __device_release_driver(struct device * dev)
284 drv = dev->driver; 311 drv = dev->driver;
285 if (drv) { 312 if (drv) {
286 get_driver(drv); 313 get_driver(drv);
287 sysfs_remove_link(&drv->kobj, kobject_name(&dev->kobj)); 314 driver_sysfs_remove(dev);
288 sysfs_remove_link(&dev->kobj, "driver"); 315 sysfs_remove_link(&dev->kobj, "driver");
289 klist_remove(&dev->knode_driver); 316 klist_remove(&dev->knode_driver);
290 317
318 if (dev->bus)
319 blocking_notifier_call_chain(&dev->bus->bus_notifier,
320 BUS_NOTIFY_UNBIND_DRIVER,
321 dev);
322
291 if (dev->bus && dev->bus->remove) 323 if (dev->bus && dev->bus->remove)
292 dev->bus->remove(dev); 324 dev->bus->remove(dev);
293 else if (drv->remove) 325 else if (drv->remove)
diff --git a/drivers/base/dmapool.c b/drivers/base/dmapool.c
index b2efbd4cf710..dbe0735f8c9e 100644
--- a/drivers/base/dmapool.c
+++ b/drivers/base/dmapool.c
@@ -126,7 +126,7 @@ dma_pool_create (const char *name, struct device *dev,
126 } else if (allocation < size) 126 } else if (allocation < size)
127 return NULL; 127 return NULL;
128 128
129 if (!(retval = kmalloc (sizeof *retval, SLAB_KERNEL))) 129 if (!(retval = kmalloc (sizeof *retval, GFP_KERNEL)))
130 return retval; 130 return retval;
131 131
132 strlcpy (retval->name, name, sizeof retval->name); 132 strlcpy (retval->name, name, sizeof retval->name);
@@ -297,7 +297,7 @@ restart:
297 } 297 }
298 } 298 }
299 } 299 }
300 if (!(page = pool_alloc_page (pool, SLAB_ATOMIC))) { 300 if (!(page = pool_alloc_page (pool, GFP_ATOMIC))) {
301 if (mem_flags & __GFP_WAIT) { 301 if (mem_flags & __GFP_WAIT) {
302 DECLARE_WAITQUEUE (wait, current); 302 DECLARE_WAITQUEUE (wait, current);
303 303
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 14615694ae9a..4bad2870c485 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -21,6 +21,8 @@
21#include <linux/firmware.h> 21#include <linux/firmware.h>
22#include "base.h" 22#include "base.h"
23 23
24#define to_dev(obj) container_of(obj, struct device, kobj)
25
24MODULE_AUTHOR("Manuel Estrada Sainz <ranty@debian.org>"); 26MODULE_AUTHOR("Manuel Estrada Sainz <ranty@debian.org>");
25MODULE_DESCRIPTION("Multi purpose firmware loading support"); 27MODULE_DESCRIPTION("Multi purpose firmware loading support");
26MODULE_LICENSE("GPL"); 28MODULE_LICENSE("GPL");
@@ -86,12 +88,12 @@ firmware_timeout_store(struct class *class, const char *buf, size_t count)
86 88
87static CLASS_ATTR(timeout, 0644, firmware_timeout_show, firmware_timeout_store); 89static CLASS_ATTR(timeout, 0644, firmware_timeout_show, firmware_timeout_store);
88 90
89static void fw_class_dev_release(struct class_device *class_dev); 91static void fw_dev_release(struct device *dev);
90 92
91static int firmware_class_uevent(struct class_device *class_dev, char **envp, 93static int firmware_uevent(struct device *dev, char **envp, int num_envp,
92 int num_envp, char *buffer, int buffer_size) 94 char *buffer, int buffer_size)
93{ 95{
94 struct firmware_priv *fw_priv = class_get_devdata(class_dev); 96 struct firmware_priv *fw_priv = dev_get_drvdata(dev);
95 int i = 0, len = 0; 97 int i = 0, len = 0;
96 98
97 if (!test_bit(FW_STATUS_READY, &fw_priv->status)) 99 if (!test_bit(FW_STATUS_READY, &fw_priv->status))
@@ -110,21 +112,21 @@ static int firmware_class_uevent(struct class_device *class_dev, char **envp,
110 112
111static struct class firmware_class = { 113static struct class firmware_class = {
112 .name = "firmware", 114 .name = "firmware",
113 .uevent = firmware_class_uevent, 115 .dev_uevent = firmware_uevent,
114 .release = fw_class_dev_release, 116 .dev_release = fw_dev_release,
115}; 117};
116 118
117static ssize_t 119static ssize_t firmware_loading_show(struct device *dev,
118firmware_loading_show(struct class_device *class_dev, char *buf) 120 struct device_attribute *attr, char *buf)
119{ 121{
120 struct firmware_priv *fw_priv = class_get_devdata(class_dev); 122 struct firmware_priv *fw_priv = dev_get_drvdata(dev);
121 int loading = test_bit(FW_STATUS_LOADING, &fw_priv->status); 123 int loading = test_bit(FW_STATUS_LOADING, &fw_priv->status);
122 return sprintf(buf, "%d\n", loading); 124 return sprintf(buf, "%d\n", loading);
123} 125}
124 126
125/** 127/**
126 * firmware_loading_store - set value in the 'loading' control file 128 * firmware_loading_store - set value in the 'loading' control file
127 * @class_dev: class_device pointer 129 * @dev: device pointer
128 * @buf: buffer to scan for loading control value 130 * @buf: buffer to scan for loading control value
129 * @count: number of bytes in @buf 131 * @count: number of bytes in @buf
130 * 132 *
@@ -134,11 +136,11 @@ firmware_loading_show(struct class_device *class_dev, char *buf)
134 * 0: Conclude the load and hand the data to the driver code. 136 * 0: Conclude the load and hand the data to the driver code.
135 * -1: Conclude the load with an error and discard any written data. 137 * -1: Conclude the load with an error and discard any written data.
136 **/ 138 **/
137static ssize_t 139static ssize_t firmware_loading_store(struct device *dev,
138firmware_loading_store(struct class_device *class_dev, 140 struct device_attribute *attr,
139 const char *buf, size_t count) 141 const char *buf, size_t count)
140{ 142{
141 struct firmware_priv *fw_priv = class_get_devdata(class_dev); 143 struct firmware_priv *fw_priv = dev_get_drvdata(dev);
142 int loading = simple_strtol(buf, NULL, 10); 144 int loading = simple_strtol(buf, NULL, 10);
143 145
144 switch (loading) { 146 switch (loading) {
@@ -174,15 +176,14 @@ firmware_loading_store(struct class_device *class_dev,
174 return count; 176 return count;
175} 177}
176 178
177static CLASS_DEVICE_ATTR(loading, 0644, 179static DEVICE_ATTR(loading, 0644, firmware_loading_show, firmware_loading_store);
178 firmware_loading_show, firmware_loading_store);
179 180
180static ssize_t 181static ssize_t
181firmware_data_read(struct kobject *kobj, 182firmware_data_read(struct kobject *kobj,
182 char *buffer, loff_t offset, size_t count) 183 char *buffer, loff_t offset, size_t count)
183{ 184{
184 struct class_device *class_dev = to_class_dev(kobj); 185 struct device *dev = to_dev(kobj);
185 struct firmware_priv *fw_priv = class_get_devdata(class_dev); 186 struct firmware_priv *fw_priv = dev_get_drvdata(dev);
186 struct firmware *fw; 187 struct firmware *fw;
187 ssize_t ret_count = count; 188 ssize_t ret_count = count;
188 189
@@ -234,7 +235,7 @@ fw_realloc_buffer(struct firmware_priv *fw_priv, int min_size)
234 235
235/** 236/**
236 * firmware_data_write - write method for firmware 237 * firmware_data_write - write method for firmware
237 * @kobj: kobject for the class_device 238 * @kobj: kobject for the device
238 * @buffer: buffer being written 239 * @buffer: buffer being written
239 * @offset: buffer offset for write in total data store area 240 * @offset: buffer offset for write in total data store area
240 * @count: buffer size 241 * @count: buffer size
@@ -246,8 +247,8 @@ static ssize_t
246firmware_data_write(struct kobject *kobj, 247firmware_data_write(struct kobject *kobj,
247 char *buffer, loff_t offset, size_t count) 248 char *buffer, loff_t offset, size_t count)
248{ 249{
249 struct class_device *class_dev = to_class_dev(kobj); 250 struct device *dev = to_dev(kobj);
250 struct firmware_priv *fw_priv = class_get_devdata(class_dev); 251 struct firmware_priv *fw_priv = dev_get_drvdata(dev);
251 struct firmware *fw; 252 struct firmware *fw;
252 ssize_t retval; 253 ssize_t retval;
253 254
@@ -280,13 +281,12 @@ static struct bin_attribute firmware_attr_data_tmpl = {
280 .write = firmware_data_write, 281 .write = firmware_data_write,
281}; 282};
282 283
283static void 284static void fw_dev_release(struct device *dev)
284fw_class_dev_release(struct class_device *class_dev)
285{ 285{
286 struct firmware_priv *fw_priv = class_get_devdata(class_dev); 286 struct firmware_priv *fw_priv = dev_get_drvdata(dev);
287 287
288 kfree(fw_priv); 288 kfree(fw_priv);
289 kfree(class_dev); 289 kfree(dev);
290 290
291 module_put(THIS_MODULE); 291 module_put(THIS_MODULE);
292} 292}
@@ -298,26 +298,23 @@ firmware_class_timeout(u_long data)
298 fw_load_abort(fw_priv); 298 fw_load_abort(fw_priv);
299} 299}
300 300
301static inline void 301static inline void fw_setup_device_id(struct device *f_dev, struct device *dev)
302fw_setup_class_device_id(struct class_device *class_dev, struct device *dev)
303{ 302{
304 /* XXX warning we should watch out for name collisions */ 303 /* XXX warning we should watch out for name collisions */
305 strlcpy(class_dev->class_id, dev->bus_id, BUS_ID_SIZE); 304 strlcpy(f_dev->bus_id, dev->bus_id, BUS_ID_SIZE);
306} 305}
307 306
308static int 307static int fw_register_device(struct device **dev_p, const char *fw_name,
309fw_register_class_device(struct class_device **class_dev_p, 308 struct device *device)
310 const char *fw_name, struct device *device)
311{ 309{
312 int retval; 310 int retval;
313 struct firmware_priv *fw_priv = kzalloc(sizeof(*fw_priv), 311 struct firmware_priv *fw_priv = kzalloc(sizeof(*fw_priv),
314 GFP_KERNEL); 312 GFP_KERNEL);
315 struct class_device *class_dev = kzalloc(sizeof(*class_dev), 313 struct device *f_dev = kzalloc(sizeof(*f_dev), GFP_KERNEL);
316 GFP_KERNEL);
317 314
318 *class_dev_p = NULL; 315 *dev_p = NULL;
319 316
320 if (!fw_priv || !class_dev) { 317 if (!fw_priv || !f_dev) {
321 printk(KERN_ERR "%s: kmalloc failed\n", __FUNCTION__); 318 printk(KERN_ERR "%s: kmalloc failed\n", __FUNCTION__);
322 retval = -ENOMEM; 319 retval = -ENOMEM;
323 goto error_kfree; 320 goto error_kfree;
@@ -331,55 +328,54 @@ fw_register_class_device(struct class_device **class_dev_p,
331 fw_priv->timeout.data = (u_long) fw_priv; 328 fw_priv->timeout.data = (u_long) fw_priv;
332 init_timer(&fw_priv->timeout); 329 init_timer(&fw_priv->timeout);
333 330
334 fw_setup_class_device_id(class_dev, device); 331 fw_setup_device_id(f_dev, device);
335 class_dev->dev = device; 332 f_dev->parent = device;
336 class_dev->class = &firmware_class; 333 f_dev->class = &firmware_class;
337 class_set_devdata(class_dev, fw_priv); 334 dev_set_drvdata(f_dev, fw_priv);
338 retval = class_device_register(class_dev); 335 retval = device_register(f_dev);
339 if (retval) { 336 if (retval) {
340 printk(KERN_ERR "%s: class_device_register failed\n", 337 printk(KERN_ERR "%s: device_register failed\n",
341 __FUNCTION__); 338 __FUNCTION__);
342 goto error_kfree; 339 goto error_kfree;
343 } 340 }
344 *class_dev_p = class_dev; 341 *dev_p = f_dev;
345 return 0; 342 return 0;
346 343
347error_kfree: 344error_kfree:
348 kfree(fw_priv); 345 kfree(fw_priv);
349 kfree(class_dev); 346 kfree(f_dev);
350 return retval; 347 return retval;
351} 348}
352 349
353static int 350static int fw_setup_device(struct firmware *fw, struct device **dev_p,
354fw_setup_class_device(struct firmware *fw, struct class_device **class_dev_p, 351 const char *fw_name, struct device *device,
355 const char *fw_name, struct device *device, int uevent) 352 int uevent)
356{ 353{
357 struct class_device *class_dev; 354 struct device *f_dev;
358 struct firmware_priv *fw_priv; 355 struct firmware_priv *fw_priv;
359 int retval; 356 int retval;
360 357
361 *class_dev_p = NULL; 358 *dev_p = NULL;
362 retval = fw_register_class_device(&class_dev, fw_name, device); 359 retval = fw_register_device(&f_dev, fw_name, device);
363 if (retval) 360 if (retval)
364 goto out; 361 goto out;
365 362
366 /* Need to pin this module until class device is destroyed */ 363 /* Need to pin this module until class device is destroyed */
367 __module_get(THIS_MODULE); 364 __module_get(THIS_MODULE);
368 365
369 fw_priv = class_get_devdata(class_dev); 366 fw_priv = dev_get_drvdata(f_dev);
370 367
371 fw_priv->fw = fw; 368 fw_priv->fw = fw;
372 retval = sysfs_create_bin_file(&class_dev->kobj, &fw_priv->attr_data); 369 retval = sysfs_create_bin_file(&f_dev->kobj, &fw_priv->attr_data);
373 if (retval) { 370 if (retval) {
374 printk(KERN_ERR "%s: sysfs_create_bin_file failed\n", 371 printk(KERN_ERR "%s: sysfs_create_bin_file failed\n",
375 __FUNCTION__); 372 __FUNCTION__);
376 goto error_unreg; 373 goto error_unreg;
377 } 374 }
378 375
379 retval = class_device_create_file(class_dev, 376 retval = device_create_file(f_dev, &dev_attr_loading);
380 &class_device_attr_loading);
381 if (retval) { 377 if (retval) {
382 printk(KERN_ERR "%s: class_device_create_file failed\n", 378 printk(KERN_ERR "%s: device_create_file failed\n",
383 __FUNCTION__); 379 __FUNCTION__);
384 goto error_unreg; 380 goto error_unreg;
385 } 381 }
@@ -388,11 +384,11 @@ fw_setup_class_device(struct firmware *fw, struct class_device **class_dev_p,
388 set_bit(FW_STATUS_READY, &fw_priv->status); 384 set_bit(FW_STATUS_READY, &fw_priv->status);
389 else 385 else
390 set_bit(FW_STATUS_READY_NOHOTPLUG, &fw_priv->status); 386 set_bit(FW_STATUS_READY_NOHOTPLUG, &fw_priv->status);
391 *class_dev_p = class_dev; 387 *dev_p = f_dev;
392 goto out; 388 goto out;
393 389
394error_unreg: 390error_unreg:
395 class_device_unregister(class_dev); 391 device_unregister(f_dev);
396out: 392out:
397 return retval; 393 return retval;
398} 394}
@@ -401,7 +397,7 @@ static int
401_request_firmware(const struct firmware **firmware_p, const char *name, 397_request_firmware(const struct firmware **firmware_p, const char *name,
402 struct device *device, int uevent) 398 struct device *device, int uevent)
403{ 399{
404 struct class_device *class_dev; 400 struct device *f_dev;
405 struct firmware_priv *fw_priv; 401 struct firmware_priv *fw_priv;
406 struct firmware *firmware; 402 struct firmware *firmware;
407 int retval; 403 int retval;
@@ -417,12 +413,11 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
417 goto out; 413 goto out;
418 } 414 }
419 415
420 retval = fw_setup_class_device(firmware, &class_dev, name, device, 416 retval = fw_setup_device(firmware, &f_dev, name, device, uevent);
421 uevent);
422 if (retval) 417 if (retval)
423 goto error_kfree_fw; 418 goto error_kfree_fw;
424 419
425 fw_priv = class_get_devdata(class_dev); 420 fw_priv = dev_get_drvdata(f_dev);
426 421
427 if (uevent) { 422 if (uevent) {
428 if (loading_timeout > 0) { 423 if (loading_timeout > 0) {
@@ -430,7 +425,7 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
430 add_timer(&fw_priv->timeout); 425 add_timer(&fw_priv->timeout);
431 } 426 }
432 427
433 kobject_uevent(&class_dev->kobj, KOBJ_ADD); 428 kobject_uevent(&f_dev->kobj, KOBJ_ADD);
434 wait_for_completion(&fw_priv->completion); 429 wait_for_completion(&fw_priv->completion);
435 set_bit(FW_STATUS_DONE, &fw_priv->status); 430 set_bit(FW_STATUS_DONE, &fw_priv->status);
436 del_timer_sync(&fw_priv->timeout); 431 del_timer_sync(&fw_priv->timeout);
@@ -445,7 +440,7 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
445 } 440 }
446 fw_priv->fw = NULL; 441 fw_priv->fw = NULL;
447 mutex_unlock(&fw_lock); 442 mutex_unlock(&fw_lock);
448 class_device_unregister(class_dev); 443 device_unregister(f_dev);
449 goto out; 444 goto out;
450 445
451error_kfree_fw: 446error_kfree_fw:
diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index c6b7d9c4b651..74b96795d2f5 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -290,9 +290,8 @@ static CLASS_ATTR(block_size_bytes, 0444, print_block_size, NULL);
290 290
291static int block_size_init(void) 291static int block_size_init(void)
292{ 292{
293 sysfs_create_file(&memory_sysdev_class.kset.kobj, 293 return sysfs_create_file(&memory_sysdev_class.kset.kobj,
294 &class_attr_block_size_bytes.attr); 294 &class_attr_block_size_bytes.attr);
295 return 0;
296} 295}
297 296
298/* 297/*
@@ -323,12 +322,14 @@ static CLASS_ATTR(probe, 0700, NULL, memory_probe_store);
323 322
324static int memory_probe_init(void) 323static int memory_probe_init(void)
325{ 324{
326 sysfs_create_file(&memory_sysdev_class.kset.kobj, 325 return sysfs_create_file(&memory_sysdev_class.kset.kobj,
327 &class_attr_probe.attr); 326 &class_attr_probe.attr);
328 return 0;
329} 327}
330#else 328#else
331#define memory_probe_init(...) do {} while (0) 329static inline int memory_probe_init(void)
330{
331 return 0;
332}
332#endif 333#endif
333 334
334/* 335/*
@@ -431,9 +432,12 @@ int __init memory_dev_init(void)
431{ 432{
432 unsigned int i; 433 unsigned int i;
433 int ret; 434 int ret;
435 int err;
434 436
435 memory_sysdev_class.kset.uevent_ops = &memory_uevent_ops; 437 memory_sysdev_class.kset.uevent_ops = &memory_uevent_ops;
436 ret = sysdev_class_register(&memory_sysdev_class); 438 ret = sysdev_class_register(&memory_sysdev_class);
439 if (ret)
440 goto out;
437 441
438 /* 442 /*
439 * Create entries for memory sections that were found 443 * Create entries for memory sections that were found
@@ -442,11 +446,19 @@ int __init memory_dev_init(void)
442 for (i = 0; i < NR_MEM_SECTIONS; i++) { 446 for (i = 0; i < NR_MEM_SECTIONS; i++) {
443 if (!valid_section_nr(i)) 447 if (!valid_section_nr(i))
444 continue; 448 continue;
445 add_memory_block(0, __nr_to_section(i), MEM_ONLINE, 0); 449 err = add_memory_block(0, __nr_to_section(i), MEM_ONLINE, 0);
450 if (!ret)
451 ret = err;
446 } 452 }
447 453
448 memory_probe_init(); 454 err = memory_probe_init();
449 block_size_init(); 455 if (!ret)
450 456 ret = err;
457 err = block_size_init();
458 if (!ret)
459 ret = err;
460out:
461 if (ret)
462 printk(KERN_ERR "%s() failed: %d\n", __FUNCTION__, ret);
451 return ret; 463 return ret;
452} 464}
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 940ce41f1887..d1df4a087924 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -388,6 +388,11 @@ static int platform_drv_probe(struct device *_dev)
388 return drv->probe(dev); 388 return drv->probe(dev);
389} 389}
390 390
391static int platform_drv_probe_fail(struct device *_dev)
392{
393 return -ENXIO;
394}
395
391static int platform_drv_remove(struct device *_dev) 396static int platform_drv_remove(struct device *_dev)
392{ 397{
393 struct platform_driver *drv = to_platform_driver(_dev->driver); 398 struct platform_driver *drv = to_platform_driver(_dev->driver);
@@ -451,6 +456,49 @@ void platform_driver_unregister(struct platform_driver *drv)
451} 456}
452EXPORT_SYMBOL_GPL(platform_driver_unregister); 457EXPORT_SYMBOL_GPL(platform_driver_unregister);
453 458
459/**
460 * platform_driver_probe - register driver for non-hotpluggable device
461 * @drv: platform driver structure
462 * @probe: the driver probe routine, probably from an __init section
463 *
464 * Use this instead of platform_driver_register() when you know the device
465 * is not hotpluggable and has already been registered, and you want to
466 * remove its run-once probe() infrastructure from memory after the driver
467 * has bound to the device.
468 *
469 * One typical use for this would be with drivers for controllers integrated
470 * into system-on-chip processors, where the controller devices have been
471 * configured as part of board setup.
472 *
473 * Returns zero if the driver registered and bound to a device, else returns
474 * a negative error code and with the driver not registered.
475 */
476int platform_driver_probe(struct platform_driver *drv,
477 int (*probe)(struct platform_device *))
478{
479 int retval, code;
480
481 /* temporary section violation during probe() */
482 drv->probe = probe;
483 retval = code = platform_driver_register(drv);
484
485 /* Fixup that section violation, being paranoid about code scanning
486 * the list of drivers in order to probe new devices. Check to see
487 * if the probe was successful, and make sure any forced probes of
488 * new devices fail.
489 */
490 spin_lock(&platform_bus_type.klist_drivers.k_lock);
491 drv->probe = NULL;
492 if (code == 0 && list_empty(&drv->driver.klist_devices.k_list))
493 retval = -ENODEV;
494 drv->driver.probe = platform_drv_probe_fail;
495 spin_unlock(&platform_bus_type.klist_drivers.k_lock);
496
497 if (code != retval)
498 platform_driver_unregister(drv);
499 return retval;
500}
501EXPORT_SYMBOL_GPL(platform_driver_probe);
454 502
455/* modalias support enables more hands-off userspace setup: 503/* modalias support enables more hands-off userspace setup:
456 * (a) environment variable lets new-style hotplug events work once system is 504 * (a) environment variable lets new-style hotplug events work once system is
diff --git a/drivers/base/topology.c b/drivers/base/topology.c
index 28dccb730af9..067a9e8bc377 100644
--- a/drivers/base/topology.c
+++ b/drivers/base/topology.c
@@ -94,54 +94,61 @@ static struct attribute_group topology_attr_group = {
94 .name = "topology" 94 .name = "topology"
95}; 95};
96 96
97static cpumask_t topology_dev_map = CPU_MASK_NONE;
98
97/* Add/Remove cpu_topology interface for CPU device */ 99/* Add/Remove cpu_topology interface for CPU device */
98static int __cpuinit topology_add_dev(struct sys_device * sys_dev) 100static int __cpuinit topology_add_dev(unsigned int cpu)
99{ 101{
100 return sysfs_create_group(&sys_dev->kobj, &topology_attr_group); 102 int rc;
103 struct sys_device *sys_dev = get_cpu_sysdev(cpu);
104
105 rc = sysfs_create_group(&sys_dev->kobj, &topology_attr_group);
106 if (!rc)
107 cpu_set(cpu, topology_dev_map);
108 return rc;
101} 109}
102 110
103static int __cpuinit topology_remove_dev(struct sys_device * sys_dev) 111static void __cpuinit topology_remove_dev(unsigned int cpu)
104{ 112{
113 struct sys_device *sys_dev = get_cpu_sysdev(cpu);
114
115 if (!cpu_isset(cpu, topology_dev_map))
116 return;
117 cpu_clear(cpu, topology_dev_map);
105 sysfs_remove_group(&sys_dev->kobj, &topology_attr_group); 118 sysfs_remove_group(&sys_dev->kobj, &topology_attr_group);
106 return 0;
107} 119}
108 120
109static int __cpuinit topology_cpu_callback(struct notifier_block *nfb, 121static int __cpuinit topology_cpu_callback(struct notifier_block *nfb,
110 unsigned long action, void *hcpu) 122 unsigned long action, void *hcpu)
111{ 123{
112 unsigned int cpu = (unsigned long)hcpu; 124 unsigned int cpu = (unsigned long)hcpu;
113 struct sys_device *sys_dev; 125 int rc = 0;
114 126
115 sys_dev = get_cpu_sysdev(cpu);
116 switch (action) { 127 switch (action) {
117 case CPU_ONLINE: 128 case CPU_UP_PREPARE:
118 topology_add_dev(sys_dev); 129 rc = topology_add_dev(cpu);
119 break; 130 break;
131 case CPU_UP_CANCELED:
120 case CPU_DEAD: 132 case CPU_DEAD:
121 topology_remove_dev(sys_dev); 133 topology_remove_dev(cpu);
122 break; 134 break;
123 } 135 }
124 return NOTIFY_OK; 136 return rc ? NOTIFY_BAD : NOTIFY_OK;
125} 137}
126 138
127static struct notifier_block __cpuinitdata topology_cpu_notifier =
128{
129 .notifier_call = topology_cpu_callback,
130};
131
132static int __cpuinit topology_sysfs_init(void) 139static int __cpuinit topology_sysfs_init(void)
133{ 140{
134 int i; 141 int cpu;
142 int rc;
135 143
136 for_each_online_cpu(i) { 144 for_each_online_cpu(cpu) {
137 topology_cpu_callback(&topology_cpu_notifier, CPU_ONLINE, 145 rc = topology_add_dev(cpu);
138 (void *)(long)i); 146 if (rc)
147 return rc;
139 } 148 }
140 149 hotcpu_notifier(topology_cpu_callback, 0);
141 register_hotcpu_notifier(&topology_cpu_notifier);
142 150
143 return 0; 151 return 0;
144} 152}
145 153
146device_initcall(topology_sysfs_init); 154device_initcall(topology_sysfs_init);
147
diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c
index 742d07403101..8d81a3a64c07 100644
--- a/drivers/block/DAC960.c
+++ b/drivers/block/DAC960.c
@@ -324,13 +324,13 @@ static boolean DAC960_CreateAuxiliaryStructures(DAC960_Controller_T *Controller)
324 Command->Next = Controller->FreeCommands; 324 Command->Next = Controller->FreeCommands;
325 Controller->FreeCommands = Command; 325 Controller->FreeCommands = Command;
326 Controller->Commands[CommandIdentifier-1] = Command; 326 Controller->Commands[CommandIdentifier-1] = Command;
327 ScatterGatherCPU = pci_pool_alloc(ScatterGatherPool, SLAB_ATOMIC, 327 ScatterGatherCPU = pci_pool_alloc(ScatterGatherPool, GFP_ATOMIC,
328 &ScatterGatherDMA); 328 &ScatterGatherDMA);
329 if (ScatterGatherCPU == NULL) 329 if (ScatterGatherCPU == NULL)
330 return DAC960_Failure(Controller, "AUXILIARY STRUCTURE CREATION"); 330 return DAC960_Failure(Controller, "AUXILIARY STRUCTURE CREATION");
331 331
332 if (RequestSensePool != NULL) { 332 if (RequestSensePool != NULL) {
333 RequestSenseCPU = pci_pool_alloc(RequestSensePool, SLAB_ATOMIC, 333 RequestSenseCPU = pci_pool_alloc(RequestSensePool, GFP_ATOMIC,
334 &RequestSenseDMA); 334 &RequestSenseDMA);
335 if (RequestSenseCPU == NULL) { 335 if (RequestSenseCPU == NULL) {
336 pci_pool_free(ScatterGatherPool, ScatterGatherCPU, 336 pci_pool_free(ScatterGatherPool, ScatterGatherCPU,
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index 17dc22282e14..85072446d772 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -168,7 +168,8 @@ config BLK_CPQ_CISS_DA
168 168
169config CISS_SCSI_TAPE 169config CISS_SCSI_TAPE
170 bool "SCSI tape drive support for Smart Array 5xxx" 170 bool "SCSI tape drive support for Smart Array 5xxx"
171 depends on BLK_CPQ_CISS_DA && SCSI && PROC_FS 171 depends on BLK_CPQ_CISS_DA && PROC_FS
172 depends on SCSI=y || SCSI=BLK_CPQ_CISS_DA
172 help 173 help
173 When enabled (Y), this option allows SCSI tape drives and SCSI medium 174 When enabled (Y), this option allows SCSI tape drives and SCSI medium
174 changers (tape robots) to be accessed via a Compaq 5xxx array 175 changers (tape robots) to be accessed via a Compaq 5xxx array
@@ -305,6 +306,7 @@ config BLK_DEV_LOOP
305config BLK_DEV_CRYPTOLOOP 306config BLK_DEV_CRYPTOLOOP
306 tristate "Cryptoloop Support" 307 tristate "Cryptoloop Support"
307 select CRYPTO 308 select CRYPTO
309 select CRYPTO_CBC
308 depends on BLK_DEV_LOOP 310 depends on BLK_DEV_LOOP
309 ---help--- 311 ---help---
310 Say Y here if you want to be able to use the ciphers that are 312 Say Y here if you want to be able to use the ciphers that are
diff --git a/drivers/block/aoe/aoe.h b/drivers/block/aoe/aoe.h
index 6d111228cfac..2308e83e5f33 100644
--- a/drivers/block/aoe/aoe.h
+++ b/drivers/block/aoe/aoe.h
@@ -159,7 +159,7 @@ void aoecmd_work(struct aoedev *d);
159void aoecmd_cfg(ushort aoemajor, unsigned char aoeminor); 159void aoecmd_cfg(ushort aoemajor, unsigned char aoeminor);
160void aoecmd_ata_rsp(struct sk_buff *); 160void aoecmd_ata_rsp(struct sk_buff *);
161void aoecmd_cfg_rsp(struct sk_buff *); 161void aoecmd_cfg_rsp(struct sk_buff *);
162void aoecmd_sleepwork(void *vp); 162void aoecmd_sleepwork(struct work_struct *);
163struct sk_buff *new_skb(ulong); 163struct sk_buff *new_skb(ulong);
164 164
165int aoedev_init(void); 165int aoedev_init(void);
diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c
index d433f27e0ce2..478489c568a4 100644
--- a/drivers/block/aoe/aoeblk.c
+++ b/drivers/block/aoe/aoeblk.c
@@ -12,7 +12,7 @@
12#include <linux/netdevice.h> 12#include <linux/netdevice.h>
13#include "aoe.h" 13#include "aoe.h"
14 14
15static kmem_cache_t *buf_pool_cache; 15static struct kmem_cache *buf_pool_cache;
16 16
17static ssize_t aoedisk_show_state(struct gendisk * disk, char *page) 17static ssize_t aoedisk_show_state(struct gendisk * disk, char *page)
18{ 18{
@@ -68,6 +68,7 @@ static struct attribute *aoe_attrs[] = {
68 &disk_attr_mac.attr, 68 &disk_attr_mac.attr,
69 &disk_attr_netif.attr, 69 &disk_attr_netif.attr,
70 &disk_attr_fwver.attr, 70 &disk_attr_fwver.attr,
71 NULL
71}; 72};
72 73
73static const struct attribute_group attr_group = { 74static const struct attribute_group attr_group = {
diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c
index 8a13b1af8bab..97f7f535f412 100644
--- a/drivers/block/aoe/aoecmd.c
+++ b/drivers/block/aoe/aoecmd.c
@@ -408,9 +408,9 @@ rexmit_timer(ulong vp)
408/* this function performs work that has been deferred until sleeping is OK 408/* this function performs work that has been deferred until sleeping is OK
409 */ 409 */
410void 410void
411aoecmd_sleepwork(void *vp) 411aoecmd_sleepwork(struct work_struct *work)
412{ 412{
413 struct aoedev *d = (struct aoedev *) vp; 413 struct aoedev *d = container_of(work, struct aoedev, work);
414 414
415 if (d->flags & DEVFL_GDALLOC) 415 if (d->flags & DEVFL_GDALLOC)
416 aoeblk_gdalloc(d); 416 aoeblk_gdalloc(d);
diff --git a/drivers/block/aoe/aoedev.c b/drivers/block/aoe/aoedev.c
index 6125921bbec4..05a97197c918 100644
--- a/drivers/block/aoe/aoedev.c
+++ b/drivers/block/aoe/aoedev.c
@@ -88,7 +88,7 @@ aoedev_newdev(ulong nframes)
88 kfree(d); 88 kfree(d);
89 return NULL; 89 return NULL;
90 } 90 }
91 INIT_WORK(&d->work, aoecmd_sleepwork, d); 91 INIT_WORK(&d->work, aoecmd_sleepwork);
92 spin_lock_init(&d->lock); 92 spin_lock_init(&d->lock);
93 init_timer(&d->timer); 93 init_timer(&d->timer);
94 d->timer.data = (ulong) d; 94 d->timer.data = (ulong) d;
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 6ffe2b2bdacc..892e092afe9a 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -47,14 +47,15 @@
47#include <linux/completion.h> 47#include <linux/completion.h>
48 48
49#define CCISS_DRIVER_VERSION(maj,min,submin) ((maj<<16)|(min<<8)|(submin)) 49#define CCISS_DRIVER_VERSION(maj,min,submin) ((maj<<16)|(min<<8)|(submin))
50#define DRIVER_NAME "HP CISS Driver (v 3.6.10)" 50#define DRIVER_NAME "HP CISS Driver (v 3.6.14)"
51#define DRIVER_VERSION CCISS_DRIVER_VERSION(3,6,10) 51#define DRIVER_VERSION CCISS_DRIVER_VERSION(3,6,14)
52 52
53/* Embedded module documentation macros - see modules.h */ 53/* Embedded module documentation macros - see modules.h */
54MODULE_AUTHOR("Hewlett-Packard Company"); 54MODULE_AUTHOR("Hewlett-Packard Company");
55MODULE_DESCRIPTION("Driver for HP Controller SA5xxx SA6xxx version 3.6.10"); 55MODULE_DESCRIPTION("Driver for HP Controller SA5xxx SA6xxx version 3.6.14");
56MODULE_SUPPORTED_DEVICE("HP SA5i SA5i+ SA532 SA5300 SA5312 SA641 SA642 SA6400" 56MODULE_SUPPORTED_DEVICE("HP SA5i SA5i+ SA532 SA5300 SA5312 SA641 SA642 SA6400"
57 " SA6i P600 P800 P400 P400i E200 E200i E500"); 57 " SA6i P600 P800 P400 P400i E200 E200i E500");
58MODULE_VERSION("3.6.14");
58MODULE_LICENSE("GPL"); 59MODULE_LICENSE("GPL");
59 60
60#include "cciss_cmd.h" 61#include "cciss_cmd.h"
@@ -81,7 +82,9 @@ static const struct pci_device_id cciss_pci_device_id[] = {
81 {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, 0x103C, 0x3213}, 82 {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, 0x103C, 0x3213},
82 {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, 0x103C, 0x3214}, 83 {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, 0x103C, 0x3214},
83 {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, 0x103C, 0x3215}, 84 {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, 0x103C, 0x3215},
84 {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSC, 0x103C, 0x3233}, 85 {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSC, 0x103C, 0x3237},
86 {PCI_VENDOR_ID_HP, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
87 PCI_CLASS_STORAGE_RAID << 8, 0xffff << 8, 0},
85 {0,} 88 {0,}
86}; 89};
87 90
@@ -90,27 +93,29 @@ MODULE_DEVICE_TABLE(pci, cciss_pci_device_id);
90/* board_id = Subsystem Device ID & Vendor ID 93/* board_id = Subsystem Device ID & Vendor ID
91 * product = Marketing Name for the board 94 * product = Marketing Name for the board
92 * access = Address of the struct of function pointers 95 * access = Address of the struct of function pointers
96 * nr_cmds = Number of commands supported by controller
93 */ 97 */
94static struct board_type products[] = { 98static struct board_type products[] = {
95 {0x40700E11, "Smart Array 5300", &SA5_access}, 99 {0x40700E11, "Smart Array 5300", &SA5_access, 512},
96 {0x40800E11, "Smart Array 5i", &SA5B_access}, 100 {0x40800E11, "Smart Array 5i", &SA5B_access, 512},
97 {0x40820E11, "Smart Array 532", &SA5B_access}, 101 {0x40820E11, "Smart Array 532", &SA5B_access, 512},
98 {0x40830E11, "Smart Array 5312", &SA5B_access}, 102 {0x40830E11, "Smart Array 5312", &SA5B_access, 512},
99 {0x409A0E11, "Smart Array 641", &SA5_access}, 103 {0x409A0E11, "Smart Array 641", &SA5_access, 512},
100 {0x409B0E11, "Smart Array 642", &SA5_access}, 104 {0x409B0E11, "Smart Array 642", &SA5_access, 512},
101 {0x409C0E11, "Smart Array 6400", &SA5_access}, 105 {0x409C0E11, "Smart Array 6400", &SA5_access, 512},
102 {0x409D0E11, "Smart Array 6400 EM", &SA5_access}, 106 {0x409D0E11, "Smart Array 6400 EM", &SA5_access, 512},
103 {0x40910E11, "Smart Array 6i", &SA5_access}, 107 {0x40910E11, "Smart Array 6i", &SA5_access, 512},
104 {0x3225103C, "Smart Array P600", &SA5_access}, 108 {0x3225103C, "Smart Array P600", &SA5_access, 512},
105 {0x3223103C, "Smart Array P800", &SA5_access}, 109 {0x3223103C, "Smart Array P800", &SA5_access, 512},
106 {0x3234103C, "Smart Array P400", &SA5_access}, 110 {0x3234103C, "Smart Array P400", &SA5_access, 512},
107 {0x3235103C, "Smart Array P400i", &SA5_access}, 111 {0x3235103C, "Smart Array P400i", &SA5_access, 512},
108 {0x3211103C, "Smart Array E200i", &SA5_access}, 112 {0x3211103C, "Smart Array E200i", &SA5_access, 120},
109 {0x3212103C, "Smart Array E200", &SA5_access}, 113 {0x3212103C, "Smart Array E200", &SA5_access, 120},
110 {0x3213103C, "Smart Array E200i", &SA5_access}, 114 {0x3213103C, "Smart Array E200i", &SA5_access, 120},
111 {0x3214103C, "Smart Array E200i", &SA5_access}, 115 {0x3214103C, "Smart Array E200i", &SA5_access, 120},
112 {0x3215103C, "Smart Array E200i", &SA5_access}, 116 {0x3215103C, "Smart Array E200i", &SA5_access, 120},
113 {0x3233103C, "Smart Array E500", &SA5_access}, 117 {0x3237103C, "Smart Array E500", &SA5_access, 512},
118 {0xFFFF103C, "Unknown Smart Array", &SA5_access, 120},
114}; 119};
115 120
116/* How long to wait (in milliseconds) for board to go into simple mode */ 121/* How long to wait (in milliseconds) for board to go into simple mode */
@@ -121,7 +126,6 @@ static struct board_type products[] = {
121#define MAX_CMD_RETRIES 3 126#define MAX_CMD_RETRIES 3
122 127
123#define READ_AHEAD 1024 128#define READ_AHEAD 1024
124#define NR_CMDS 384 /* #commands that can be outstanding */
125#define MAX_CTLR 32 129#define MAX_CTLR 32
126 130
127/* Originally cciss driver only supports 8 major numbers */ 131/* Originally cciss driver only supports 8 major numbers */
@@ -137,7 +141,6 @@ static int cciss_ioctl(struct inode *inode, struct file *filep,
137 unsigned int cmd, unsigned long arg); 141 unsigned int cmd, unsigned long arg);
138static int cciss_getgeo(struct block_device *bdev, struct hd_geometry *geo); 142static int cciss_getgeo(struct block_device *bdev, struct hd_geometry *geo);
139 143
140static int revalidate_allvol(ctlr_info_t *host);
141static int cciss_revalidate(struct gendisk *disk); 144static int cciss_revalidate(struct gendisk *disk);
142static int rebuild_lun_table(ctlr_info_t *h, struct gendisk *del_disk); 145static int rebuild_lun_table(ctlr_info_t *h, struct gendisk *del_disk);
143static int deregister_disk(struct gendisk *disk, drive_info_struct *drv, 146static int deregister_disk(struct gendisk *disk, drive_info_struct *drv,
@@ -265,6 +268,7 @@ static int cciss_proc_get_info(char *buffer, char **start, off_t offset,
265 "Firmware Version: %c%c%c%c\n" 268 "Firmware Version: %c%c%c%c\n"
266 "IRQ: %d\n" 269 "IRQ: %d\n"
267 "Logical drives: %d\n" 270 "Logical drives: %d\n"
271 "Max sectors: %d\n"
268 "Current Q depth: %d\n" 272 "Current Q depth: %d\n"
269 "Current # commands on controller: %d\n" 273 "Current # commands on controller: %d\n"
270 "Max Q depth since init: %d\n" 274 "Max Q depth since init: %d\n"
@@ -275,7 +279,9 @@ static int cciss_proc_get_info(char *buffer, char **start, off_t offset,
275 (unsigned long)h->board_id, 279 (unsigned long)h->board_id,
276 h->firm_ver[0], h->firm_ver[1], h->firm_ver[2], 280 h->firm_ver[0], h->firm_ver[1], h->firm_ver[2],
277 h->firm_ver[3], (unsigned int)h->intr[SIMPLE_MODE_INT], 281 h->firm_ver[3], (unsigned int)h->intr[SIMPLE_MODE_INT],
278 h->num_luns, h->Qdepth, h->commands_outstanding, 282 h->num_luns,
283 h->cciss_max_sectors,
284 h->Qdepth, h->commands_outstanding,
279 h->maxQsinceinit, h->max_outstanding, h->maxSG); 285 h->maxQsinceinit, h->max_outstanding, h->maxSG);
280 286
281 pos += size; 287 pos += size;
@@ -400,8 +406,8 @@ static CommandList_struct *cmd_alloc(ctlr_info_t *h, int get_from_pool)
400 } else { /* get it out of the controllers pool */ 406 } else { /* get it out of the controllers pool */
401 407
402 do { 408 do {
403 i = find_first_zero_bit(h->cmd_pool_bits, NR_CMDS); 409 i = find_first_zero_bit(h->cmd_pool_bits, h->nr_cmds);
404 if (i == NR_CMDS) 410 if (i == h->nr_cmds)
405 return NULL; 411 return NULL;
406 } while (test_and_set_bit 412 } while (test_and_set_bit
407 (i & (BITS_PER_LONG - 1), 413 (i & (BITS_PER_LONG - 1),
@@ -487,7 +493,7 @@ static int cciss_open(struct inode *inode, struct file *filep)
487 * but I'm already using way to many device nodes to claim another one 493 * but I'm already using way to many device nodes to claim another one
488 * for "raw controller". 494 * for "raw controller".
489 */ 495 */
490 if (drv->nr_blocks == 0) { 496 if (drv->heads == 0) {
491 if (iminor(inode) != 0) { /* not node 0? */ 497 if (iminor(inode) != 0) { /* not node 0? */
492 /* if not node 0 make sure it is a partition = 0 */ 498 /* if not node 0 make sure it is a partition = 0 */
493 if (iminor(inode) & 0x0f) { 499 if (iminor(inode) & 0x0f) {
@@ -850,9 +856,7 @@ static int cciss_ioctl(struct inode *inode, struct file *filep,
850 } 856 }
851 857
852 case CCISS_REVALIDVOLS: 858 case CCISS_REVALIDVOLS:
853 if (bdev != bdev->bd_contains || drv != host->drv) 859 return rebuild_lun_table(host, NULL);
854 return -ENXIO;
855 return revalidate_allvol(host);
856 860
857 case CCISS_GETLUNINFO:{ 861 case CCISS_GETLUNINFO:{
858 LogvolInfo_struct luninfo; 862 LogvolInfo_struct luninfo;
@@ -1152,75 +1156,6 @@ static int cciss_ioctl(struct inode *inode, struct file *filep,
1152 } 1156 }
1153} 1157}
1154 1158
1155/*
1156 * revalidate_allvol is for online array config utilities. After a
1157 * utility reconfigures the drives in the array, it can use this function
1158 * (through an ioctl) to make the driver zap any previous disk structs for
1159 * that controller and get new ones.
1160 *
1161 * Right now I'm using the getgeometry() function to do this, but this
1162 * function should probably be finer grained and allow you to revalidate one
1163 * particular logical volume (instead of all of them on a particular
1164 * controller).
1165 */
1166static int revalidate_allvol(ctlr_info_t *host)
1167{
1168 int ctlr = host->ctlr, i;
1169 unsigned long flags;
1170
1171 spin_lock_irqsave(CCISS_LOCK(ctlr), flags);
1172 if (host->usage_count > 1) {
1173 spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags);
1174 printk(KERN_WARNING "cciss: Device busy for volume"
1175 " revalidation (usage=%d)\n", host->usage_count);
1176 return -EBUSY;
1177 }
1178 host->usage_count++;
1179 spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags);
1180
1181 for (i = 0; i < NWD; i++) {
1182 struct gendisk *disk = host->gendisk[i];
1183 if (disk) {
1184 request_queue_t *q = disk->queue;
1185
1186 if (disk->flags & GENHD_FL_UP)
1187 del_gendisk(disk);
1188 if (q)
1189 blk_cleanup_queue(q);
1190 }
1191 }
1192
1193 /*
1194 * Set the partition and block size structures for all volumes
1195 * on this controller to zero. We will reread all of this data
1196 */
1197 memset(host->drv, 0, sizeof(drive_info_struct)
1198 * CISS_MAX_LUN);
1199 /*
1200 * Tell the array controller not to give us any interrupts while
1201 * we check the new geometry. Then turn interrupts back on when
1202 * we're done.
1203 */
1204 host->access.set_intr_mask(host, CCISS_INTR_OFF);
1205 cciss_getgeometry(ctlr);
1206 host->access.set_intr_mask(host, CCISS_INTR_ON);
1207
1208 /* Loop through each real device */
1209 for (i = 0; i < NWD; i++) {
1210 struct gendisk *disk = host->gendisk[i];
1211 drive_info_struct *drv = &(host->drv[i]);
1212 /* we must register the controller even if no disks exist */
1213 /* this is for the online array utilities */
1214 if (!drv->heads && i)
1215 continue;
1216 blk_queue_hardsect_size(drv->queue, drv->block_size);
1217 set_capacity(disk, drv->nr_blocks);
1218 add_disk(disk);
1219 }
1220 host->usage_count--;
1221 return 0;
1222}
1223
1224static inline void complete_buffers(struct bio *bio, int status) 1159static inline void complete_buffers(struct bio *bio, int status)
1225{ 1160{
1226 while (bio) { 1161 while (bio) {
@@ -1243,7 +1178,7 @@ static void cciss_check_queues(ctlr_info_t *h)
1243 * in case the interrupt we serviced was from an ioctl and did not 1178 * in case the interrupt we serviced was from an ioctl and did not
1244 * free any new commands. 1179 * free any new commands.
1245 */ 1180 */
1246 if ((find_first_zero_bit(h->cmd_pool_bits, NR_CMDS)) == NR_CMDS) 1181 if ((find_first_zero_bit(h->cmd_pool_bits, h->nr_cmds)) == h->nr_cmds)
1247 return; 1182 return;
1248 1183
1249 /* We have room on the queue for more commands. Now we need to queue 1184 /* We have room on the queue for more commands. Now we need to queue
@@ -1262,7 +1197,7 @@ static void cciss_check_queues(ctlr_info_t *h)
1262 /* check to see if we have maxed out the number of commands 1197 /* check to see if we have maxed out the number of commands
1263 * that can be placed on the queue. 1198 * that can be placed on the queue.
1264 */ 1199 */
1265 if ((find_first_zero_bit(h->cmd_pool_bits, NR_CMDS)) == NR_CMDS) { 1200 if ((find_first_zero_bit(h->cmd_pool_bits, h->nr_cmds)) == h->nr_cmds) {
1266 if (curr_queue == start_queue) { 1201 if (curr_queue == start_queue) {
1267 h->next_to_run = 1202 h->next_to_run =
1268 (start_queue + 1) % (h->highest_lun + 1); 1203 (start_queue + 1) % (h->highest_lun + 1);
@@ -1300,6 +1235,12 @@ static void cciss_softirq_done(struct request *rq)
1300 1235
1301 complete_buffers(rq->bio, rq->errors); 1236 complete_buffers(rq->bio, rq->errors);
1302 1237
1238 if (blk_fs_request(rq)) {
1239 const int rw = rq_data_dir(rq);
1240
1241 disk_stat_add(rq->rq_disk, sectors[rw], rq->nr_sectors);
1242 }
1243
1303#ifdef CCISS_DEBUG 1244#ifdef CCISS_DEBUG
1304 printk("Done with %p\n", rq); 1245 printk("Done with %p\n", rq);
1305#endif /* CCISS_DEBUG */ 1246#endif /* CCISS_DEBUG */
@@ -1374,6 +1315,11 @@ static void cciss_update_drive_info(int ctlr, int drv_index)
1374 /* if it's the controller it's already added */ 1315 /* if it's the controller it's already added */
1375 if (drv_index) { 1316 if (drv_index) {
1376 disk->queue = blk_init_queue(do_cciss_request, &h->lock); 1317 disk->queue = blk_init_queue(do_cciss_request, &h->lock);
1318 sprintf(disk->disk_name, "cciss/c%dd%d", ctlr, drv_index);
1319 disk->major = h->major;
1320 disk->first_minor = drv_index << NWD_SHIFT;
1321 disk->fops = &cciss_fops;
1322 disk->private_data = &h->drv[drv_index];
1377 1323
1378 /* Set up queue information */ 1324 /* Set up queue information */
1379 disk->queue->backing_dev_info.ra_pages = READ_AHEAD; 1325 disk->queue->backing_dev_info.ra_pages = READ_AHEAD;
@@ -1385,7 +1331,7 @@ static void cciss_update_drive_info(int ctlr, int drv_index)
1385 /* This is a limit in the driver and could be eliminated. */ 1331 /* This is a limit in the driver and could be eliminated. */
1386 blk_queue_max_phys_segments(disk->queue, MAXSGENTRIES); 1332 blk_queue_max_phys_segments(disk->queue, MAXSGENTRIES);
1387 1333
1388 blk_queue_max_sectors(disk->queue, 512); 1334 blk_queue_max_sectors(disk->queue, h->cciss_max_sectors);
1389 1335
1390 blk_queue_softirq_done(disk->queue, cciss_softirq_done); 1336 blk_queue_softirq_done(disk->queue, cciss_softirq_done);
1391 1337
@@ -1452,11 +1398,6 @@ static int rebuild_lun_table(ctlr_info_t *h, struct gendisk *del_disk)
1452 1398
1453 /* Set busy_configuring flag for this operation */ 1399 /* Set busy_configuring flag for this operation */
1454 spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags); 1400 spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags);
1455 if (h->num_luns >= CISS_MAX_LUN) {
1456 spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags);
1457 return -EINVAL;
1458 }
1459
1460 if (h->busy_configuring) { 1401 if (h->busy_configuring) {
1461 spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); 1402 spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags);
1462 return -EBUSY; 1403 return -EBUSY;
@@ -1489,17 +1430,8 @@ static int rebuild_lun_table(ctlr_info_t *h, struct gendisk *del_disk)
1489 0, 0, TYPE_CMD); 1430 0, 0, TYPE_CMD);
1490 1431
1491 if (return_code == IO_OK) { 1432 if (return_code == IO_OK) {
1492 listlength |= 1433 listlength =
1493 (0xff & (unsigned int)(ld_buff->LUNListLength[0])) 1434 be32_to_cpu(*(__u32 *) ld_buff->LUNListLength);
1494 << 24;
1495 listlength |=
1496 (0xff & (unsigned int)(ld_buff->LUNListLength[1]))
1497 << 16;
1498 listlength |=
1499 (0xff & (unsigned int)(ld_buff->LUNListLength[2]))
1500 << 8;
1501 listlength |=
1502 0xff & (unsigned int)(ld_buff->LUNListLength[3]);
1503 } else { /* reading number of logical volumes failed */ 1435 } else { /* reading number of logical volumes failed */
1504 printk(KERN_WARNING "cciss: report logical volume" 1436 printk(KERN_WARNING "cciss: report logical volume"
1505 " command failed\n"); 1437 " command failed\n");
@@ -1550,6 +1482,14 @@ static int rebuild_lun_table(ctlr_info_t *h, struct gendisk *del_disk)
1550 if (drv_index == -1) 1482 if (drv_index == -1)
1551 goto freeret; 1483 goto freeret;
1552 1484
1485 /*Check if the gendisk needs to be allocated */
1486 if (!h->gendisk[drv_index]){
1487 h->gendisk[drv_index] = alloc_disk(1 << NWD_SHIFT);
1488 if (!h->gendisk[drv_index]){
1489 printk(KERN_ERR "cciss: could not allocate new disk %d\n", drv_index);
1490 goto mem_msg;
1491 }
1492 }
1553 } 1493 }
1554 h->drv[drv_index].LunID = lunid; 1494 h->drv[drv_index].LunID = lunid;
1555 cciss_update_drive_info(ctlr, drv_index); 1495 cciss_update_drive_info(ctlr, drv_index);
@@ -1587,6 +1527,7 @@ static int rebuild_lun_table(ctlr_info_t *h, struct gendisk *del_disk)
1587static int deregister_disk(struct gendisk *disk, drive_info_struct *drv, 1527static int deregister_disk(struct gendisk *disk, drive_info_struct *drv,
1588 int clear_all) 1528 int clear_all)
1589{ 1529{
1530 int i;
1590 ctlr_info_t *h = get_host(disk); 1531 ctlr_info_t *h = get_host(disk);
1591 1532
1592 if (!capable(CAP_SYS_RAWIO)) 1533 if (!capable(CAP_SYS_RAWIO))
@@ -1610,9 +1551,35 @@ static int deregister_disk(struct gendisk *disk, drive_info_struct *drv,
1610 del_gendisk(disk); 1551 del_gendisk(disk);
1611 if (q) { 1552 if (q) {
1612 blk_cleanup_queue(q); 1553 blk_cleanup_queue(q);
1554 /* Set drv->queue to NULL so that we do not try
1555 * to call blk_start_queue on this queue in the
1556 * interrupt handler
1557 */
1613 drv->queue = NULL; 1558 drv->queue = NULL;
1614 } 1559 }
1560 /* If clear_all is set then we are deleting the logical
1561 * drive, not just refreshing its info. For drives
1562 * other than disk 0 we will call put_disk. We do not
1563 * do this for disk 0 as we need it to be able to
1564 * configure the controller.
1565 */
1566 if (clear_all){
1567 /* This isn't pretty, but we need to find the
1568 * disk in our array and NULL our the pointer.
1569 * This is so that we will call alloc_disk if
1570 * this index is used again later.
1571 */
1572 for (i=0; i < CISS_MAX_LUN; i++){
1573 if(h->gendisk[i] == disk){
1574 h->gendisk[i] = NULL;
1575 break;
1576 }
1577 }
1578 put_disk(disk);
1579 }
1615 } 1580 }
1581 } else {
1582 set_capacity(disk, 0);
1616 } 1583 }
1617 1584
1618 --h->num_luns; 1585 --h->num_luns;
@@ -2130,7 +2097,7 @@ static int add_sendcmd_reject(__u8 cmd, int ctlr, unsigned long complete)
2130 2097
2131 /* We've sent down an abort or reset, but something else 2098 /* We've sent down an abort or reset, but something else
2132 has completed */ 2099 has completed */
2133 if (srl->ncompletions >= (NR_CMDS + 2)) { 2100 if (srl->ncompletions >= (hba[ctlr]->nr_cmds + 2)) {
2134 /* Uh oh. No room to save it for later... */ 2101 /* Uh oh. No room to save it for later... */
2135 printk(KERN_WARNING "cciss%d: Sendcmd: Invalid command addr, " 2102 printk(KERN_WARNING "cciss%d: Sendcmd: Invalid command addr, "
2136 "reject list overflow, command lost!\n", ctlr); 2103 "reject list overflow, command lost!\n", ctlr);
@@ -2667,7 +2634,7 @@ static irqreturn_t do_cciss_intr(int irq, void *dev_id)
2667 a1 = a; 2634 a1 = a;
2668 if ((a & 0x04)) { 2635 if ((a & 0x04)) {
2669 a2 = (a >> 3); 2636 a2 = (a >> 3);
2670 if (a2 >= NR_CMDS) { 2637 if (a2 >= h->nr_cmds) {
2671 printk(KERN_WARNING 2638 printk(KERN_WARNING
2672 "cciss: controller cciss%d failed, stopping.\n", 2639 "cciss: controller cciss%d failed, stopping.\n",
2673 h->ctlr); 2640 h->ctlr);
@@ -2821,23 +2788,21 @@ static void __devinit cciss_interrupt_mode(ctlr_info_t *c,
2821 if (err > 0) { 2788 if (err > 0) {
2822 printk(KERN_WARNING "cciss: only %d MSI-X vectors " 2789 printk(KERN_WARNING "cciss: only %d MSI-X vectors "
2823 "available\n", err); 2790 "available\n", err);
2791 goto default_int_mode;
2824 } else { 2792 } else {
2825 printk(KERN_WARNING "cciss: MSI-X init failed %d\n", 2793 printk(KERN_WARNING "cciss: MSI-X init failed %d\n",
2826 err); 2794 err);
2795 goto default_int_mode;
2827 } 2796 }
2828 } 2797 }
2829 if (pci_find_capability(pdev, PCI_CAP_ID_MSI)) { 2798 if (pci_find_capability(pdev, PCI_CAP_ID_MSI)) {
2830 if (!pci_enable_msi(pdev)) { 2799 if (!pci_enable_msi(pdev)) {
2831 c->intr[SIMPLE_MODE_INT] = pdev->irq;
2832 c->msi_vector = 1; 2800 c->msi_vector = 1;
2833 return;
2834 } else { 2801 } else {
2835 printk(KERN_WARNING "cciss: MSI init failed\n"); 2802 printk(KERN_WARNING "cciss: MSI init failed\n");
2836 c->intr[SIMPLE_MODE_INT] = pdev->irq;
2837 return;
2838 } 2803 }
2839 } 2804 }
2840 default_int_mode: 2805default_int_mode:
2841#endif /* CONFIG_PCI_MSI */ 2806#endif /* CONFIG_PCI_MSI */
2842 /* if we get here we're going to use the default interrupt mode */ 2807 /* if we get here we're going to use the default interrupt mode */
2843 c->intr[SIMPLE_MODE_INT] = pdev->irq; 2808 c->intr[SIMPLE_MODE_INT] = pdev->irq;
@@ -2950,16 +2915,10 @@ static int cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
2950 if (board_id == products[i].board_id) { 2915 if (board_id == products[i].board_id) {
2951 c->product_name = products[i].product_name; 2916 c->product_name = products[i].product_name;
2952 c->access = *(products[i].access); 2917 c->access = *(products[i].access);
2918 c->nr_cmds = products[i].nr_cmds;
2953 break; 2919 break;
2954 } 2920 }
2955 } 2921 }
2956 if (i == ARRAY_SIZE(products)) {
2957 printk(KERN_WARNING "cciss: Sorry, I don't know how"
2958 " to access the Smart Array controller %08lx\n",
2959 (unsigned long)board_id);
2960 err = -ENODEV;
2961 goto err_out_free_res;
2962 }
2963 if ((readb(&c->cfgtable->Signature[0]) != 'C') || 2922 if ((readb(&c->cfgtable->Signature[0]) != 'C') ||
2964 (readb(&c->cfgtable->Signature[1]) != 'I') || 2923 (readb(&c->cfgtable->Signature[1]) != 'I') ||
2965 (readb(&c->cfgtable->Signature[2]) != 'S') || 2924 (readb(&c->cfgtable->Signature[2]) != 'S') ||
@@ -2968,6 +2927,27 @@ static int cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
2968 err = -ENODEV; 2927 err = -ENODEV;
2969 goto err_out_free_res; 2928 goto err_out_free_res;
2970 } 2929 }
2930 /* We didn't find the controller in our list. We know the
2931 * signature is valid. If it's an HP device let's try to
2932 * bind to the device and fire it up. Otherwise we bail.
2933 */
2934 if (i == ARRAY_SIZE(products)) {
2935 if (subsystem_vendor_id == PCI_VENDOR_ID_HP) {
2936 c->product_name = products[i-1].product_name;
2937 c->access = *(products[i-1].access);
2938 c->nr_cmds = products[i-1].nr_cmds;
2939 printk(KERN_WARNING "cciss: This is an unknown "
2940 "Smart Array controller.\n"
2941 "cciss: Please update to the latest driver "
2942 "available from www.hp.com.\n");
2943 } else {
2944 printk(KERN_WARNING "cciss: Sorry, I don't know how"
2945 " to access the Smart Array controller %08lx\n"
2946 , (unsigned long)board_id);
2947 err = -ENODEV;
2948 goto err_out_free_res;
2949 }
2950 }
2971#ifdef CONFIG_X86 2951#ifdef CONFIG_X86
2972 { 2952 {
2973 /* Need to enable prefetch in the SCSI core for 6400 in x86 */ 2953 /* Need to enable prefetch in the SCSI core for 6400 in x86 */
@@ -2978,6 +2958,17 @@ static int cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
2978 } 2958 }
2979#endif 2959#endif
2980 2960
2961 /* Disabling DMA prefetch for the P600
2962 * An ASIC bug may result in a prefetch beyond
2963 * physical memory.
2964 */
2965 if(board_id == 0x3225103C) {
2966 __u32 dma_prefetch;
2967 dma_prefetch = readl(c->vaddr + I2O_DMA1_CFG);
2968 dma_prefetch |= 0x8000;
2969 writel(dma_prefetch, c->vaddr + I2O_DMA1_CFG);
2970 }
2971
2981#ifdef CCISS_DEBUG 2972#ifdef CCISS_DEBUG
2982 printk("Trying to put board into Simple mode\n"); 2973 printk("Trying to put board into Simple mode\n");
2983#endif /* CCISS_DEBUG */ 2974#endif /* CCISS_DEBUG */
@@ -3152,13 +3143,7 @@ geo_inq:
3152/* Returns -1 if no free entries are left. */ 3143/* Returns -1 if no free entries are left. */
3153static int alloc_cciss_hba(void) 3144static int alloc_cciss_hba(void)
3154{ 3145{
3155 struct gendisk *disk[NWD]; 3146 int i;
3156 int i, n;
3157 for (n = 0; n < NWD; n++) {
3158 disk[n] = alloc_disk(1 << NWD_SHIFT);
3159 if (!disk[n])
3160 goto out;
3161 }
3162 3147
3163 for (i = 0; i < MAX_CTLR; i++) { 3148 for (i = 0; i < MAX_CTLR; i++) {
3164 if (!hba[i]) { 3149 if (!hba[i]) {
@@ -3166,20 +3151,18 @@ static int alloc_cciss_hba(void)
3166 p = kzalloc(sizeof(ctlr_info_t), GFP_KERNEL); 3151 p = kzalloc(sizeof(ctlr_info_t), GFP_KERNEL);
3167 if (!p) 3152 if (!p)
3168 goto Enomem; 3153 goto Enomem;
3169 for (n = 0; n < NWD; n++) 3154 p->gendisk[0] = alloc_disk(1 << NWD_SHIFT);
3170 p->gendisk[n] = disk[n]; 3155 if (!p->gendisk[0])
3156 goto Enomem;
3171 hba[i] = p; 3157 hba[i] = p;
3172 return i; 3158 return i;
3173 } 3159 }
3174 } 3160 }
3175 printk(KERN_WARNING "cciss: This driver supports a maximum" 3161 printk(KERN_WARNING "cciss: This driver supports a maximum"
3176 " of %d controllers.\n", MAX_CTLR); 3162 " of %d controllers.\n", MAX_CTLR);
3177 goto out; 3163 return -1;
3178 Enomem: 3164Enomem:
3179 printk(KERN_ERR "cciss: out of memory.\n"); 3165 printk(KERN_ERR "cciss: out of memory.\n");
3180 out:
3181 while (n--)
3182 put_disk(disk[n]);
3183 return -1; 3166 return -1;
3184} 3167}
3185 3168
@@ -3189,7 +3172,7 @@ static void free_hba(int i)
3189 int n; 3172 int n;
3190 3173
3191 hba[i] = NULL; 3174 hba[i] = NULL;
3192 for (n = 0; n < NWD; n++) 3175 for (n = 0; n < CISS_MAX_LUN; n++)
3193 put_disk(p->gendisk[n]); 3176 put_disk(p->gendisk[n]);
3194 kfree(p); 3177 kfree(p);
3195} 3178}
@@ -3202,9 +3185,8 @@ static void free_hba(int i)
3202static int __devinit cciss_init_one(struct pci_dev *pdev, 3185static int __devinit cciss_init_one(struct pci_dev *pdev,
3203 const struct pci_device_id *ent) 3186 const struct pci_device_id *ent)
3204{ 3187{
3205 request_queue_t *q;
3206 int i; 3188 int i;
3207 int j; 3189 int j = 0;
3208 int rc; 3190 int rc;
3209 int dac; 3191 int dac;
3210 3192
@@ -3263,15 +3245,15 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
3263 hba[i]->intr[SIMPLE_MODE_INT], dac ? "" : " not"); 3245 hba[i]->intr[SIMPLE_MODE_INT], dac ? "" : " not");
3264 3246
3265 hba[i]->cmd_pool_bits = 3247 hba[i]->cmd_pool_bits =
3266 kmalloc(((NR_CMDS + BITS_PER_LONG - 3248 kmalloc(((hba[i]->nr_cmds + BITS_PER_LONG -
3267 1) / BITS_PER_LONG) * sizeof(unsigned long), GFP_KERNEL); 3249 1) / BITS_PER_LONG) * sizeof(unsigned long), GFP_KERNEL);
3268 hba[i]->cmd_pool = (CommandList_struct *) 3250 hba[i]->cmd_pool = (CommandList_struct *)
3269 pci_alloc_consistent(hba[i]->pdev, 3251 pci_alloc_consistent(hba[i]->pdev,
3270 NR_CMDS * sizeof(CommandList_struct), 3252 hba[i]->nr_cmds * sizeof(CommandList_struct),
3271 &(hba[i]->cmd_pool_dhandle)); 3253 &(hba[i]->cmd_pool_dhandle));
3272 hba[i]->errinfo_pool = (ErrorInfo_struct *) 3254 hba[i]->errinfo_pool = (ErrorInfo_struct *)
3273 pci_alloc_consistent(hba[i]->pdev, 3255 pci_alloc_consistent(hba[i]->pdev,
3274 NR_CMDS * sizeof(ErrorInfo_struct), 3256 hba[i]->nr_cmds * sizeof(ErrorInfo_struct),
3275 &(hba[i]->errinfo_pool_dhandle)); 3257 &(hba[i]->errinfo_pool_dhandle));
3276 if ((hba[i]->cmd_pool_bits == NULL) 3258 if ((hba[i]->cmd_pool_bits == NULL)
3277 || (hba[i]->cmd_pool == NULL) 3259 || (hba[i]->cmd_pool == NULL)
@@ -3282,7 +3264,7 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
3282#ifdef CONFIG_CISS_SCSI_TAPE 3264#ifdef CONFIG_CISS_SCSI_TAPE
3283 hba[i]->scsi_rejects.complete = 3265 hba[i]->scsi_rejects.complete =
3284 kmalloc(sizeof(hba[i]->scsi_rejects.complete[0]) * 3266 kmalloc(sizeof(hba[i]->scsi_rejects.complete[0]) *
3285 (NR_CMDS + 5), GFP_KERNEL); 3267 (hba[i]->nr_cmds + 5), GFP_KERNEL);
3286 if (hba[i]->scsi_rejects.complete == NULL) { 3268 if (hba[i]->scsi_rejects.complete == NULL) {
3287 printk(KERN_ERR "cciss: out of memory"); 3269 printk(KERN_ERR "cciss: out of memory");
3288 goto clean4; 3270 goto clean4;
@@ -3296,7 +3278,7 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
3296 /* command and error info recs zeroed out before 3278 /* command and error info recs zeroed out before
3297 they are used */ 3279 they are used */
3298 memset(hba[i]->cmd_pool_bits, 0, 3280 memset(hba[i]->cmd_pool_bits, 0,
3299 ((NR_CMDS + BITS_PER_LONG - 3281 ((hba[i]->nr_cmds + BITS_PER_LONG -
3300 1) / BITS_PER_LONG) * sizeof(unsigned long)); 3282 1) / BITS_PER_LONG) * sizeof(unsigned long));
3301 3283
3302#ifdef CCISS_DEBUG 3284#ifdef CCISS_DEBUG
@@ -3311,18 +3293,34 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
3311 hba[i]->access.set_intr_mask(hba[i], CCISS_INTR_ON); 3293 hba[i]->access.set_intr_mask(hba[i], CCISS_INTR_ON);
3312 3294
3313 cciss_procinit(i); 3295 cciss_procinit(i);
3296
3297 hba[i]->cciss_max_sectors = 2048;
3298
3314 hba[i]->busy_initializing = 0; 3299 hba[i]->busy_initializing = 0;
3315 3300
3316 for (j = 0; j < NWD; j++) { /* mfm */ 3301 do {
3317 drive_info_struct *drv = &(hba[i]->drv[j]); 3302 drive_info_struct *drv = &(hba[i]->drv[j]);
3318 struct gendisk *disk = hba[i]->gendisk[j]; 3303 struct gendisk *disk = hba[i]->gendisk[j];
3304 request_queue_t *q;
3305
3306 /* Check if the disk was allocated already */
3307 if (!disk){
3308 hba[i]->gendisk[j] = alloc_disk(1 << NWD_SHIFT);
3309 disk = hba[i]->gendisk[j];
3310 }
3311
3312 /* Check that the disk was able to be allocated */
3313 if (!disk) {
3314 printk(KERN_ERR "cciss: unable to allocate memory for disk %d\n", j);
3315 goto clean4;
3316 }
3319 3317
3320 q = blk_init_queue(do_cciss_request, &hba[i]->lock); 3318 q = blk_init_queue(do_cciss_request, &hba[i]->lock);
3321 if (!q) { 3319 if (!q) {
3322 printk(KERN_ERR 3320 printk(KERN_ERR
3323 "cciss: unable to allocate queue for disk %d\n", 3321 "cciss: unable to allocate queue for disk %d\n",
3324 j); 3322 j);
3325 break; 3323 goto clean4;
3326 } 3324 }
3327 drv->queue = q; 3325 drv->queue = q;
3328 3326
@@ -3335,7 +3333,7 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
3335 /* This is a limit in the driver and could be eliminated. */ 3333 /* This is a limit in the driver and could be eliminated. */
3336 blk_queue_max_phys_segments(q, MAXSGENTRIES); 3334 blk_queue_max_phys_segments(q, MAXSGENTRIES);
3337 3335
3338 blk_queue_max_sectors(q, 512); 3336 blk_queue_max_sectors(q, hba[i]->cciss_max_sectors);
3339 3337
3340 blk_queue_softirq_done(q, cciss_softirq_done); 3338 blk_queue_softirq_done(q, cciss_softirq_done);
3341 3339
@@ -3354,7 +3352,8 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
3354 blk_queue_hardsect_size(q, drv->block_size); 3352 blk_queue_hardsect_size(q, drv->block_size);
3355 set_capacity(disk, drv->nr_blocks); 3353 set_capacity(disk, drv->nr_blocks);
3356 add_disk(disk); 3354 add_disk(disk);
3357 } 3355 j++;
3356 } while (j <= hba[i]->highest_lun);
3358 3357
3359 return 1; 3358 return 1;
3360 3359
@@ -3365,11 +3364,11 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
3365 kfree(hba[i]->cmd_pool_bits); 3364 kfree(hba[i]->cmd_pool_bits);
3366 if (hba[i]->cmd_pool) 3365 if (hba[i]->cmd_pool)
3367 pci_free_consistent(hba[i]->pdev, 3366 pci_free_consistent(hba[i]->pdev,
3368 NR_CMDS * sizeof(CommandList_struct), 3367 hba[i]->nr_cmds * sizeof(CommandList_struct),
3369 hba[i]->cmd_pool, hba[i]->cmd_pool_dhandle); 3368 hba[i]->cmd_pool, hba[i]->cmd_pool_dhandle);
3370 if (hba[i]->errinfo_pool) 3369 if (hba[i]->errinfo_pool)
3371 pci_free_consistent(hba[i]->pdev, 3370 pci_free_consistent(hba[i]->pdev,
3372 NR_CMDS * sizeof(ErrorInfo_struct), 3371 hba[i]->nr_cmds * sizeof(ErrorInfo_struct),
3373 hba[i]->errinfo_pool, 3372 hba[i]->errinfo_pool,
3374 hba[i]->errinfo_pool_dhandle); 3373 hba[i]->errinfo_pool_dhandle);
3375 free_irq(hba[i]->intr[SIMPLE_MODE_INT], hba[i]); 3374 free_irq(hba[i]->intr[SIMPLE_MODE_INT], hba[i]);
@@ -3377,6 +3376,15 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
3377 unregister_blkdev(hba[i]->major, hba[i]->devname); 3376 unregister_blkdev(hba[i]->major, hba[i]->devname);
3378 clean1: 3377 clean1:
3379 hba[i]->busy_initializing = 0; 3378 hba[i]->busy_initializing = 0;
3379 /* cleanup any queues that may have been initialized */
3380 for (j=0; j <= hba[i]->highest_lun; j++){
3381 drive_info_struct *drv = &(hba[i]->drv[j]);
3382 if (drv->queue)
3383 blk_cleanup_queue(drv->queue);
3384 }
3385 pci_release_regions(pdev);
3386 pci_disable_device(pdev);
3387 pci_set_drvdata(pdev, NULL);
3380 free_hba(i); 3388 free_hba(i);
3381 return -1; 3389 return -1;
3382} 3390}
@@ -3424,7 +3432,7 @@ static void __devexit cciss_remove_one(struct pci_dev *pdev)
3424 remove_proc_entry(hba[i]->devname, proc_cciss); 3432 remove_proc_entry(hba[i]->devname, proc_cciss);
3425 3433
3426 /* remove it from the disk list */ 3434 /* remove it from the disk list */
3427 for (j = 0; j < NWD; j++) { 3435 for (j = 0; j < CISS_MAX_LUN; j++) {
3428 struct gendisk *disk = hba[i]->gendisk[j]; 3436 struct gendisk *disk = hba[i]->gendisk[j];
3429 if (disk) { 3437 if (disk) {
3430 request_queue_t *q = disk->queue; 3438 request_queue_t *q = disk->queue;
@@ -3436,9 +3444,9 @@ static void __devexit cciss_remove_one(struct pci_dev *pdev)
3436 } 3444 }
3437 } 3445 }
3438 3446
3439 pci_free_consistent(hba[i]->pdev, NR_CMDS * sizeof(CommandList_struct), 3447 pci_free_consistent(hba[i]->pdev, hba[i]->nr_cmds * sizeof(CommandList_struct),
3440 hba[i]->cmd_pool, hba[i]->cmd_pool_dhandle); 3448 hba[i]->cmd_pool, hba[i]->cmd_pool_dhandle);
3441 pci_free_consistent(hba[i]->pdev, NR_CMDS * sizeof(ErrorInfo_struct), 3449 pci_free_consistent(hba[i]->pdev, hba[i]->nr_cmds * sizeof(ErrorInfo_struct),
3442 hba[i]->errinfo_pool, hba[i]->errinfo_pool_dhandle); 3450 hba[i]->errinfo_pool, hba[i]->errinfo_pool_dhandle);
3443 kfree(hba[i]->cmd_pool_bits); 3451 kfree(hba[i]->cmd_pool_bits);
3444#ifdef CONFIG_CISS_SCSI_TAPE 3452#ifdef CONFIG_CISS_SCSI_TAPE
diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
index 562235c1445a..b70988dd33ec 100644
--- a/drivers/block/cciss.h
+++ b/drivers/block/cciss.h
@@ -6,7 +6,6 @@
6#include "cciss_cmd.h" 6#include "cciss_cmd.h"
7 7
8 8
9#define NWD 16
10#define NWD_SHIFT 4 9#define NWD_SHIFT 4
11#define MAX_PART (1 << NWD_SHIFT) 10#define MAX_PART (1 << NWD_SHIFT)
12 11
@@ -60,6 +59,7 @@ struct ctlr_info
60 __u32 board_id; 59 __u32 board_id;
61 void __iomem *vaddr; 60 void __iomem *vaddr;
62 unsigned long paddr; 61 unsigned long paddr;
62 int nr_cmds; /* Number of commands allowed on this controller */
63 CfgTable_struct __iomem *cfgtable; 63 CfgTable_struct __iomem *cfgtable;
64 int interrupts_enabled; 64 int interrupts_enabled;
65 int major; 65 int major;
@@ -76,6 +76,7 @@ struct ctlr_info
76 unsigned int intr[4]; 76 unsigned int intr[4];
77 unsigned int msix_vector; 77 unsigned int msix_vector;
78 unsigned int msi_vector; 78 unsigned int msi_vector;
79 int cciss_max_sectors;
79 BYTE cciss_read; 80 BYTE cciss_read;
80 BYTE cciss_write; 81 BYTE cciss_write;
81 BYTE cciss_read_capacity; 82 BYTE cciss_read_capacity;
@@ -110,7 +111,7 @@ struct ctlr_info
110 int next_to_run; 111 int next_to_run;
111 112
112 // Disk structures we need to pass back 113 // Disk structures we need to pass back
113 struct gendisk *gendisk[NWD]; 114 struct gendisk *gendisk[CISS_MAX_LUN];
114#ifdef CONFIG_CISS_SCSI_TAPE 115#ifdef CONFIG_CISS_SCSI_TAPE
115 void *scsi_ctlr; /* ptr to structure containing scsi related stuff */ 116 void *scsi_ctlr; /* ptr to structure containing scsi related stuff */
116 /* list of block side commands the scsi error handling sucked up */ 117 /* list of block side commands the scsi error handling sucked up */
@@ -282,6 +283,7 @@ struct board_type {
282 __u32 board_id; 283 __u32 board_id;
283 char *product_name; 284 char *product_name;
284 struct access_method *access; 285 struct access_method *access;
286 int nr_cmds; /* Max cmds this kind of ctlr can handle. */
285}; 287};
286 288
287#define CCISS_LOCK(i) (&hba[i]->lock) 289#define CCISS_LOCK(i) (&hba[i]->lock)
diff --git a/drivers/block/cciss_cmd.h b/drivers/block/cciss_cmd.h
index 4af7c4c0c7af..43bf5593b59b 100644
--- a/drivers/block/cciss_cmd.h
+++ b/drivers/block/cciss_cmd.h
@@ -55,6 +55,7 @@
55#define I2O_INT_MASK 0x34 55#define I2O_INT_MASK 0x34
56#define I2O_IBPOST_Q 0x40 56#define I2O_IBPOST_Q 0x40
57#define I2O_OBPOST_Q 0x44 57#define I2O_OBPOST_Q 0x44
58#define I2O_DMA1_CFG 0x214
58 59
59//Configuration Table 60//Configuration Table
60#define CFGTBL_ChangeReq 0x00000001l 61#define CFGTBL_ChangeReq 0x00000001l
@@ -88,7 +89,7 @@ typedef union _u64bit
88//########################################################################### 89//###########################################################################
89//STRUCTURES 90//STRUCTURES
90//########################################################################### 91//###########################################################################
91#define CISS_MAX_LUN 16 92#define CISS_MAX_LUN 1024
92#define CISS_MAX_PHYS_LUN 1024 93#define CISS_MAX_PHYS_LUN 1024
93// SCSI-3 Cmmands 94// SCSI-3 Cmmands
94 95
diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
index 570d2f049323..d5f519ebbc08 100644
--- a/drivers/block/cpqarray.c
+++ b/drivers/block/cpqarray.c
@@ -998,6 +998,7 @@ static inline void complete_buffers(struct bio *bio, int ok)
998 */ 998 */
999static inline void complete_command(cmdlist_t *cmd, int timeout) 999static inline void complete_command(cmdlist_t *cmd, int timeout)
1000{ 1000{
1001 struct request *rq = cmd->rq;
1001 int ok=1; 1002 int ok=1;
1002 int i, ddir; 1003 int i, ddir;
1003 1004
@@ -1029,12 +1030,18 @@ static inline void complete_command(cmdlist_t *cmd, int timeout)
1029 pci_unmap_page(hba[cmd->ctlr]->pci_dev, cmd->req.sg[i].addr, 1030 pci_unmap_page(hba[cmd->ctlr]->pci_dev, cmd->req.sg[i].addr,
1030 cmd->req.sg[i].size, ddir); 1031 cmd->req.sg[i].size, ddir);
1031 1032
1032 complete_buffers(cmd->rq->bio, ok); 1033 complete_buffers(rq->bio, ok);
1033 1034
1034 add_disk_randomness(cmd->rq->rq_disk); 1035 if (blk_fs_request(rq)) {
1036 const int rw = rq_data_dir(rq);
1035 1037
1036 DBGPX(printk("Done with %p\n", cmd->rq);); 1038 disk_stat_add(rq->rq_disk, sectors[rw], rq->nr_sectors);
1037 end_that_request_last(cmd->rq, ok ? 1 : -EIO); 1039 }
1040
1041 add_disk_randomness(rq->rq_disk);
1042
1043 DBGPX(printk("Done with %p\n", rq););
1044 end_that_request_last(rq, ok ? 1 : -EIO);
1038} 1045}
1039 1046
1040/* 1047/*
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 9e6d3a87cbe3..3f1b38276e96 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -992,11 +992,11 @@ static void empty(void)
992{ 992{
993} 993}
994 994
995static DECLARE_WORK(floppy_work, NULL, NULL); 995static DECLARE_WORK(floppy_work, NULL);
996 996
997static void schedule_bh(void (*handler) (void)) 997static void schedule_bh(void (*handler) (void))
998{ 998{
999 PREPARE_WORK(&floppy_work, (void (*)(void *))handler, NULL); 999 PREPARE_WORK(&floppy_work, (work_func_t)handler);
1000 schedule_work(&floppy_work); 1000 schedule_work(&floppy_work);
1001} 1001}
1002 1002
@@ -1008,7 +1008,7 @@ static void cancel_activity(void)
1008 1008
1009 spin_lock_irqsave(&floppy_lock, flags); 1009 spin_lock_irqsave(&floppy_lock, flags);
1010 do_floppy = NULL; 1010 do_floppy = NULL;
1011 PREPARE_WORK(&floppy_work, (void *)empty, NULL); 1011 PREPARE_WORK(&floppy_work, (work_func_t)empty);
1012 del_timer(&fd_timer); 1012 del_timer(&fd_timer);
1013 spin_unlock_irqrestore(&floppy_lock, flags); 1013 spin_unlock_irqrestore(&floppy_lock, flags);
1014} 1014}
@@ -1868,7 +1868,7 @@ static void show_floppy(void)
1868 printk("fdc_busy=%lu\n", fdc_busy); 1868 printk("fdc_busy=%lu\n", fdc_busy);
1869 if (do_floppy) 1869 if (do_floppy)
1870 printk("do_floppy=%p\n", do_floppy); 1870 printk("do_floppy=%p\n", do_floppy);
1871 if (floppy_work.pending) 1871 if (work_pending(&floppy_work))
1872 printk("floppy_work.func=%p\n", floppy_work.func); 1872 printk("floppy_work.func=%p\n", floppy_work.func);
1873 if (timer_pending(&fd_timer)) 1873 if (timer_pending(&fd_timer))
1874 printk("fd_timer.function=%p\n", fd_timer.function); 1874 printk("fd_timer.function=%p\n", fd_timer.function);
@@ -4498,7 +4498,7 @@ static void floppy_release_irq_and_dma(void)
4498 printk("floppy timer still active:%s\n", timeout_message); 4498 printk("floppy timer still active:%s\n", timeout_message);
4499 if (timer_pending(&fd_timer)) 4499 if (timer_pending(&fd_timer))
4500 printk("auxiliary floppy timer still active\n"); 4500 printk("auxiliary floppy timer still active\n");
4501 if (floppy_work.pending) 4501 if (work_pending(&floppy_work))
4502 printk("work still pending\n"); 4502 printk("work still pending\n");
4503#endif 4503#endif
4504 old_fdc = fdc; 4504 old_fdc = fdc;
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 9d1035e8d9d8..7bf2cfbd6285 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -355,14 +355,30 @@ harderror:
355 return NULL; 355 return NULL;
356} 356}
357 357
358static ssize_t pid_show(struct gendisk *disk, char *page)
359{
360 return sprintf(page, "%ld\n",
361 (long) ((struct nbd_device *)disk->private_data)->pid);
362}
363
364static struct disk_attribute pid_attr = {
365 .attr = { .name = "pid", .mode = S_IRUGO },
366 .show = pid_show,
367};
368
358static void nbd_do_it(struct nbd_device *lo) 369static void nbd_do_it(struct nbd_device *lo)
359{ 370{
360 struct request *req; 371 struct request *req;
361 372
362 BUG_ON(lo->magic != LO_MAGIC); 373 BUG_ON(lo->magic != LO_MAGIC);
363 374
375 lo->pid = current->pid;
376 sysfs_create_file(&lo->disk->kobj, &pid_attr.attr);
377
364 while ((req = nbd_read_stat(lo)) != NULL) 378 while ((req = nbd_read_stat(lo)) != NULL)
365 nbd_end_request(req); 379 nbd_end_request(req);
380
381 sysfs_remove_file(&lo->disk->kobj, &pid_attr.attr);
366 return; 382 return;
367} 383}
368 384
diff --git a/drivers/block/paride/aten.c b/drivers/block/paride/aten.c
index c4d696d43dc1..2695465568ad 100644
--- a/drivers/block/paride/aten.c
+++ b/drivers/block/paride/aten.c
@@ -149,12 +149,12 @@ static struct pi_protocol aten = {
149 149
150static int __init aten_init(void) 150static int __init aten_init(void)
151{ 151{
152 return pi_register(&aten)-1; 152 return paride_register(&aten);
153} 153}
154 154
155static void __exit aten_exit(void) 155static void __exit aten_exit(void)
156{ 156{
157 pi_unregister( &aten ); 157 paride_unregister( &aten );
158} 158}
159 159
160MODULE_LICENSE("GPL"); 160MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/bpck.c b/drivers/block/paride/bpck.c
index d462ff6b139d..4f27e7392e38 100644
--- a/drivers/block/paride/bpck.c
+++ b/drivers/block/paride/bpck.c
@@ -464,12 +464,12 @@ static struct pi_protocol bpck = {
464 464
465static int __init bpck_init(void) 465static int __init bpck_init(void)
466{ 466{
467 return pi_register(&bpck)-1; 467 return paride_register(&bpck);
468} 468}
469 469
470static void __exit bpck_exit(void) 470static void __exit bpck_exit(void)
471{ 471{
472 pi_unregister(&bpck); 472 paride_unregister(&bpck);
473} 473}
474 474
475MODULE_LICENSE("GPL"); 475MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/bpck6.c b/drivers/block/paride/bpck6.c
index 41a237c5957d..ad124525ac23 100644
--- a/drivers/block/paride/bpck6.c
+++ b/drivers/block/paride/bpck6.c
@@ -31,10 +31,7 @@ static int verbose; /* set this to 1 to see debugging messages and whatnot */
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/types.h> 32#include <linux/types.h>
33#include <asm/io.h> 33#include <asm/io.h>
34
35#if defined(CONFIG_PARPORT_MODULE)||defined(CONFIG_PARPORT)
36#include <linux/parport.h> 34#include <linux/parport.h>
37#endif
38 35
39#include "ppc6lnx.c" 36#include "ppc6lnx.c"
40#include "paride.h" 37#include "paride.h"
@@ -139,11 +136,6 @@ static int bpck6_test_port ( PIA *pi ) /* check for 8-bit port */
139 PPCSTRUCT(pi)->ppc_id=pi->unit; 136 PPCSTRUCT(pi)->ppc_id=pi->unit;
140 PPCSTRUCT(pi)->lpt_addr=pi->port; 137 PPCSTRUCT(pi)->lpt_addr=pi->port;
141 138
142#ifdef CONFIG_PARPORT_PC_MODULE
143#define CONFIG_PARPORT_PC
144#endif
145
146#ifdef CONFIG_PARPORT_PC
147 /* look at the parport device to see if what modes we can use */ 139 /* look at the parport device to see if what modes we can use */
148 if(((struct pardevice *)(pi->pardev))->port->modes & 140 if(((struct pardevice *)(pi->pardev))->port->modes &
149 (PARPORT_MODE_EPP) 141 (PARPORT_MODE_EPP)
@@ -161,11 +153,6 @@ static int bpck6_test_port ( PIA *pi ) /* check for 8-bit port */
161 { 153 {
162 return 1; 154 return 1;
163 } 155 }
164#else
165 /* there is no way of knowing what kind of port we have
166 default to the highest mode possible */
167 return 5;
168#endif
169} 156}
170 157
171static int bpck6_probe_unit ( PIA *pi ) 158static int bpck6_probe_unit ( PIA *pi )
@@ -265,12 +252,12 @@ static int __init bpck6_init(void)
265 printk(KERN_INFO "bpck6: Copyright 2001 by Micro Solutions, Inc., DeKalb IL. USA\n"); 252 printk(KERN_INFO "bpck6: Copyright 2001 by Micro Solutions, Inc., DeKalb IL. USA\n");
266 if(verbose) 253 if(verbose)
267 printk(KERN_DEBUG "bpck6: verbose debug enabled.\n"); 254 printk(KERN_DEBUG "bpck6: verbose debug enabled.\n");
268 return pi_register(&bpck6) - 1; 255 return paride_register(&bpck6);
269} 256}
270 257
271static void __exit bpck6_exit(void) 258static void __exit bpck6_exit(void)
272{ 259{
273 pi_unregister(&bpck6); 260 paride_unregister(&bpck6);
274} 261}
275 262
276MODULE_LICENSE("GPL"); 263MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/comm.c b/drivers/block/paride/comm.c
index 43d61359d8ec..9bcd35495323 100644
--- a/drivers/block/paride/comm.c
+++ b/drivers/block/paride/comm.c
@@ -205,12 +205,12 @@ static struct pi_protocol comm = {
205 205
206static int __init comm_init(void) 206static int __init comm_init(void)
207{ 207{
208 return pi_register(&comm)-1; 208 return paride_register(&comm);
209} 209}
210 210
211static void __exit comm_exit(void) 211static void __exit comm_exit(void)
212{ 212{
213 pi_unregister(&comm); 213 paride_unregister(&comm);
214} 214}
215 215
216MODULE_LICENSE("GPL"); 216MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/dstr.c b/drivers/block/paride/dstr.c
index 04d53bf58e8c..accc5c777cbb 100644
--- a/drivers/block/paride/dstr.c
+++ b/drivers/block/paride/dstr.c
@@ -220,12 +220,12 @@ static struct pi_protocol dstr = {
220 220
221static int __init dstr_init(void) 221static int __init dstr_init(void)
222{ 222{
223 return pi_register(&dstr)-1; 223 return paride_register(&dstr);
224} 224}
225 225
226static void __exit dstr_exit(void) 226static void __exit dstr_exit(void)
227{ 227{
228 pi_unregister(&dstr); 228 paride_unregister(&dstr);
229} 229}
230 230
231MODULE_LICENSE("GPL"); 231MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/epat.c b/drivers/block/paride/epat.c
index 55d1c0a1fb90..1bcdff77322e 100644
--- a/drivers/block/paride/epat.c
+++ b/drivers/block/paride/epat.c
@@ -327,12 +327,12 @@ static int __init epat_init(void)
327#ifdef CONFIG_PARIDE_EPATC8 327#ifdef CONFIG_PARIDE_EPATC8
328 epatc8 = 1; 328 epatc8 = 1;
329#endif 329#endif
330 return pi_register(&epat)-1; 330 return paride_register(&epat);
331} 331}
332 332
333static void __exit epat_exit(void) 333static void __exit epat_exit(void)
334{ 334{
335 pi_unregister(&epat); 335 paride_unregister(&epat);
336} 336}
337 337
338MODULE_LICENSE("GPL"); 338MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/epia.c b/drivers/block/paride/epia.c
index 0f2e0c292d82..fb0e782d055e 100644
--- a/drivers/block/paride/epia.c
+++ b/drivers/block/paride/epia.c
@@ -303,12 +303,12 @@ static struct pi_protocol epia = {
303 303
304static int __init epia_init(void) 304static int __init epia_init(void)
305{ 305{
306 return pi_register(&epia)-1; 306 return paride_register(&epia);
307} 307}
308 308
309static void __exit epia_exit(void) 309static void __exit epia_exit(void)
310{ 310{
311 pi_unregister(&epia); 311 paride_unregister(&epia);
312} 312}
313 313
314MODULE_LICENSE("GPL"); 314MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/fit2.c b/drivers/block/paride/fit2.c
index e0f0691d8bc2..381283753ae4 100644
--- a/drivers/block/paride/fit2.c
+++ b/drivers/block/paride/fit2.c
@@ -138,12 +138,12 @@ static struct pi_protocol fit2 = {
138 138
139static int __init fit2_init(void) 139static int __init fit2_init(void)
140{ 140{
141 return pi_register(&fit2)-1; 141 return paride_register(&fit2);
142} 142}
143 143
144static void __exit fit2_exit(void) 144static void __exit fit2_exit(void)
145{ 145{
146 pi_unregister(&fit2); 146 paride_unregister(&fit2);
147} 147}
148 148
149MODULE_LICENSE("GPL"); 149MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/fit3.c b/drivers/block/paride/fit3.c
index 15400e7bc666..275d269458eb 100644
--- a/drivers/block/paride/fit3.c
+++ b/drivers/block/paride/fit3.c
@@ -198,12 +198,12 @@ static struct pi_protocol fit3 = {
198 198
199static int __init fit3_init(void) 199static int __init fit3_init(void)
200{ 200{
201 return pi_register(&fit3)-1; 201 return paride_register(&fit3);
202} 202}
203 203
204static void __exit fit3_exit(void) 204static void __exit fit3_exit(void)
205{ 205{
206 pi_unregister(&fit3); 206 paride_unregister(&fit3);
207} 207}
208 208
209MODULE_LICENSE("GPL"); 209MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/friq.c b/drivers/block/paride/friq.c
index 5ea2904d2815..4f2ba244689b 100644
--- a/drivers/block/paride/friq.c
+++ b/drivers/block/paride/friq.c
@@ -263,12 +263,12 @@ static struct pi_protocol friq = {
263 263
264static int __init friq_init(void) 264static int __init friq_init(void)
265{ 265{
266 return pi_register(&friq)-1; 266 return paride_register(&friq);
267} 267}
268 268
269static void __exit friq_exit(void) 269static void __exit friq_exit(void)
270{ 270{
271 pi_unregister(&friq); 271 paride_unregister(&friq);
272} 272}
273 273
274MODULE_LICENSE("GPL"); 274MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/frpw.c b/drivers/block/paride/frpw.c
index 56b3824b1538..c3cde364603a 100644
--- a/drivers/block/paride/frpw.c
+++ b/drivers/block/paride/frpw.c
@@ -300,12 +300,12 @@ static struct pi_protocol frpw = {
300 300
301static int __init frpw_init(void) 301static int __init frpw_init(void)
302{ 302{
303 return pi_register(&frpw)-1; 303 return paride_register(&frpw);
304} 304}
305 305
306static void __exit frpw_exit(void) 306static void __exit frpw_exit(void)
307{ 307{
308 pi_unregister(&frpw); 308 paride_unregister(&frpw);
309} 309}
310 310
311MODULE_LICENSE("GPL"); 311MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/jumbo b/drivers/block/paride/jumbo
deleted file mode 100644
index e793b9cb7e72..000000000000
--- a/drivers/block/paride/jumbo
+++ /dev/null
@@ -1,70 +0,0 @@
1#!/bin/sh
2#
3# This script can be used to build "jumbo" modules that contain the
4# base PARIDE support, one protocol module and one high-level driver.
5#
6echo -n "High level driver [pcd] : "
7read X
8HLD=${X:-pcd}
9#
10echo -n "Protocol module [bpck] : "
11read X
12PROTO=${X:-bpck}
13#
14echo -n "Use MODVERSIONS [y] ? "
15read X
16UMODV=${X:-y}
17#
18echo -n "For SMP kernel [n] ? "
19read X
20USMP=${X:-n}
21#
22echo -n "Support PARPORT [n] ? "
23read X
24UPARP=${X:-n}
25#
26echo
27#
28case $USMP in
29 y* | Y* ) FSMP="-DCONFIG_SMP"
30 ;;
31 *) FSMP=""
32 ;;
33esac
34#
35MODI="-include ../../../include/linux/modversions.h"
36#
37case $UMODV in
38 y* | Y* ) FMODV="-DMODVERSIONS $MODI"
39 ;;
40 *) FMODV=""
41 ;;
42esac
43#
44case $UPARP in
45 y* | Y* ) FPARP="-DCONFIG_PARPORT"
46 ;;
47 *) FPARP=""
48 ;;
49esac
50#
51TARG=$HLD-$PROTO.o
52FPROTO=-DCONFIG_PARIDE_`echo "$PROTO" | tr [a-z] [A-Z]`
53FK="-D__KERNEL__ -I ../../../include"
54FLCH=-D_LINUX_CONFIG_H
55#
56echo cc $FK $FSMP $FLCH $FPARP $FPROTO $FMODV -Wall -O2 -o Jb.o -c paride.c
57cc $FK $FSMP $FLCH $FPARP $FPROTO $FMODV -Wall -O2 -o Jb.o -c paride.c
58#
59echo cc $FK $FSMP $FMODV -Wall -O2 -o Jp.o -c $PROTO.c
60cc $FK $FSMP $FMODV -Wall -O2 -o Jp.o -c $PROTO.c
61#
62echo cc $FK $FSMP $FMODV -DMODULE -DPARIDE_JUMBO -Wall -O2 -o Jd.o -c $HLD.c
63cc $FK $FSMP $FMODV -DMODULE -DPARIDE_JUMBO -Wall -O2 -o Jd.o -c $HLD.c
64#
65echo ld -r -o $TARG Jp.o Jb.o Jd.o
66ld -r -o $TARG Jp.o Jb.o Jd.o
67#
68#
69rm Jp.o Jb.o Jd.o
70#
diff --git a/drivers/block/paride/kbic.c b/drivers/block/paride/kbic.c
index d983bcea76fe..35999c415ee3 100644
--- a/drivers/block/paride/kbic.c
+++ b/drivers/block/paride/kbic.c
@@ -283,13 +283,21 @@ static struct pi_protocol k971 = {
283 283
284static int __init kbic_init(void) 284static int __init kbic_init(void)
285{ 285{
286 return (pi_register(&k951)||pi_register(&k971))-1; 286 int rv;
287
288 rv = paride_register(&k951);
289 if (rv < 0)
290 return rv;
291 rv = paride_register(&k971);
292 if (rv < 0)
293 paride_unregister(&k951);
294 return rv;
287} 295}
288 296
289static void __exit kbic_exit(void) 297static void __exit kbic_exit(void)
290{ 298{
291 pi_unregister(&k951); 299 paride_unregister(&k951);
292 pi_unregister(&k971); 300 paride_unregister(&k971);
293} 301}
294 302
295MODULE_LICENSE("GPL"); 303MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/ktti.c b/drivers/block/paride/ktti.c
index 6c7edbfba9a0..117ab0e8ccf0 100644
--- a/drivers/block/paride/ktti.c
+++ b/drivers/block/paride/ktti.c
@@ -115,12 +115,12 @@ static struct pi_protocol ktti = {
115 115
116static int __init ktti_init(void) 116static int __init ktti_init(void)
117{ 117{
118 return pi_register(&ktti)-1; 118 return paride_register(&ktti);
119} 119}
120 120
121static void __exit ktti_exit(void) 121static void __exit ktti_exit(void)
122{ 122{
123 pi_unregister(&ktti); 123 paride_unregister(&ktti);
124} 124}
125 125
126MODULE_LICENSE("GPL"); 126MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/on20.c b/drivers/block/paride/on20.c
index 9f8e01096809..0173697a1a4d 100644
--- a/drivers/block/paride/on20.c
+++ b/drivers/block/paride/on20.c
@@ -140,12 +140,12 @@ static struct pi_protocol on20 = {
140 140
141static int __init on20_init(void) 141static int __init on20_init(void)
142{ 142{
143 return pi_register(&on20)-1; 143 return paride_register(&on20);
144} 144}
145 145
146static void __exit on20_exit(void) 146static void __exit on20_exit(void)
147{ 147{
148 pi_unregister(&on20); 148 paride_unregister(&on20);
149} 149}
150 150
151MODULE_LICENSE("GPL"); 151MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/on26.c b/drivers/block/paride/on26.c
index 0f833caa2101..95ba256921f2 100644
--- a/drivers/block/paride/on26.c
+++ b/drivers/block/paride/on26.c
@@ -306,12 +306,12 @@ static struct pi_protocol on26 = {
306 306
307static int __init on26_init(void) 307static int __init on26_init(void)
308{ 308{
309 return pi_register(&on26)-1; 309 return paride_register(&on26);
310} 310}
311 311
312static void __exit on26_exit(void) 312static void __exit on26_exit(void)
313{ 313{
314 pi_unregister(&on26); 314 paride_unregister(&on26);
315} 315}
316 316
317MODULE_LICENSE("GPL"); 317MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/paride.c b/drivers/block/paride/paride.c
index 4b258f7836f3..48c50f11f63b 100644
--- a/drivers/block/paride/paride.c
+++ b/drivers/block/paride/paride.c
@@ -29,14 +29,7 @@
29#include <linux/spinlock.h> 29#include <linux/spinlock.h>
30#include <linux/wait.h> 30#include <linux/wait.h>
31#include <linux/sched.h> /* TASK_* */ 31#include <linux/sched.h> /* TASK_* */
32
33#ifdef CONFIG_PARPORT_MODULE
34#define CONFIG_PARPORT
35#endif
36
37#ifdef CONFIG_PARPORT
38#include <linux/parport.h> 32#include <linux/parport.h>
39#endif
40 33
41#include "paride.h" 34#include "paride.h"
42 35
@@ -76,8 +69,6 @@ void pi_read_block(PIA * pi, char *buf, int count)
76 69
77EXPORT_SYMBOL(pi_read_block); 70EXPORT_SYMBOL(pi_read_block);
78 71
79#ifdef CONFIG_PARPORT
80
81static void pi_wake_up(void *p) 72static void pi_wake_up(void *p)
82{ 73{
83 PIA *pi = (PIA *) p; 74 PIA *pi = (PIA *) p;
@@ -100,11 +91,8 @@ static void pi_wake_up(void *p)
100 cont(); 91 cont();
101} 92}
102 93
103#endif
104
105int pi_schedule_claimed(PIA * pi, void (*cont) (void)) 94int pi_schedule_claimed(PIA * pi, void (*cont) (void))
106{ 95{
107#ifdef CONFIG_PARPORT
108 unsigned long flags; 96 unsigned long flags;
109 97
110 spin_lock_irqsave(&pi_spinlock, flags); 98 spin_lock_irqsave(&pi_spinlock, flags);
@@ -115,7 +103,6 @@ int pi_schedule_claimed(PIA * pi, void (*cont) (void))
115 } 103 }
116 pi->claimed = 1; 104 pi->claimed = 1;
117 spin_unlock_irqrestore(&pi_spinlock, flags); 105 spin_unlock_irqrestore(&pi_spinlock, flags);
118#endif
119 return 1; 106 return 1;
120} 107}
121EXPORT_SYMBOL(pi_schedule_claimed); 108EXPORT_SYMBOL(pi_schedule_claimed);
@@ -133,20 +120,16 @@ static void pi_claim(PIA * pi)
133 if (pi->claimed) 120 if (pi->claimed)
134 return; 121 return;
135 pi->claimed = 1; 122 pi->claimed = 1;
136#ifdef CONFIG_PARPORT
137 if (pi->pardev) 123 if (pi->pardev)
138 wait_event(pi->parq, 124 wait_event(pi->parq,
139 !parport_claim((struct pardevice *) pi->pardev)); 125 !parport_claim((struct pardevice *) pi->pardev));
140#endif
141} 126}
142 127
143static void pi_unclaim(PIA * pi) 128static void pi_unclaim(PIA * pi)
144{ 129{
145 pi->claimed = 0; 130 pi->claimed = 0;
146#ifdef CONFIG_PARPORT
147 if (pi->pardev) 131 if (pi->pardev)
148 parport_release((struct pardevice *) (pi->pardev)); 132 parport_release((struct pardevice *) (pi->pardev));
149#endif
150} 133}
151 134
152void pi_connect(PIA * pi) 135void pi_connect(PIA * pi)
@@ -167,21 +150,15 @@ EXPORT_SYMBOL(pi_disconnect);
167 150
168static void pi_unregister_parport(PIA * pi) 151static void pi_unregister_parport(PIA * pi)
169{ 152{
170#ifdef CONFIG_PARPORT
171 if (pi->pardev) { 153 if (pi->pardev) {
172 parport_unregister_device((struct pardevice *) (pi->pardev)); 154 parport_unregister_device((struct pardevice *) (pi->pardev));
173 pi->pardev = NULL; 155 pi->pardev = NULL;
174 } 156 }
175#endif
176} 157}
177 158
178void pi_release(PIA * pi) 159void pi_release(PIA * pi)
179{ 160{
180 pi_unregister_parport(pi); 161 pi_unregister_parport(pi);
181#ifndef CONFIG_PARPORT
182 if (pi->reserved)
183 release_region(pi->port, pi->reserved);
184#endif /* !CONFIG_PARPORT */
185 if (pi->proto->release_proto) 162 if (pi->proto->release_proto)
186 pi->proto->release_proto(pi); 163 pi->proto->release_proto(pi);
187 module_put(pi->proto->owner); 164 module_put(pi->proto->owner);
@@ -229,7 +206,7 @@ static int pi_test_proto(PIA * pi, char *scratch, int verbose)
229 return res; 206 return res;
230} 207}
231 208
232int pi_register(PIP * pr) 209int paride_register(PIP * pr)
233{ 210{
234 int k; 211 int k;
235 212
@@ -237,24 +214,24 @@ int pi_register(PIP * pr)
237 if (protocols[k] && !strcmp(pr->name, protocols[k]->name)) { 214 if (protocols[k] && !strcmp(pr->name, protocols[k]->name)) {
238 printk("paride: %s protocol already registered\n", 215 printk("paride: %s protocol already registered\n",
239 pr->name); 216 pr->name);
240 return 0; 217 return -1;
241 } 218 }
242 k = 0; 219 k = 0;
243 while ((k < MAX_PROTOS) && (protocols[k])) 220 while ((k < MAX_PROTOS) && (protocols[k]))
244 k++; 221 k++;
245 if (k == MAX_PROTOS) { 222 if (k == MAX_PROTOS) {
246 printk("paride: protocol table full\n"); 223 printk("paride: protocol table full\n");
247 return 0; 224 return -1;
248 } 225 }
249 protocols[k] = pr; 226 protocols[k] = pr;
250 pr->index = k; 227 pr->index = k;
251 printk("paride: %s registered as protocol %d\n", pr->name, k); 228 printk("paride: %s registered as protocol %d\n", pr->name, k);
252 return 1; 229 return 0;
253} 230}
254 231
255EXPORT_SYMBOL(pi_register); 232EXPORT_SYMBOL(paride_register);
256 233
257void pi_unregister(PIP * pr) 234void paride_unregister(PIP * pr)
258{ 235{
259 if (!pr) 236 if (!pr)
260 return; 237 return;
@@ -265,12 +242,10 @@ void pi_unregister(PIP * pr)
265 protocols[pr->index] = NULL; 242 protocols[pr->index] = NULL;
266} 243}
267 244
268EXPORT_SYMBOL(pi_unregister); 245EXPORT_SYMBOL(paride_unregister);
269 246
270static int pi_register_parport(PIA * pi, int verbose) 247static int pi_register_parport(PIA * pi, int verbose)
271{ 248{
272#ifdef CONFIG_PARPORT
273
274 struct parport *port; 249 struct parport *port;
275 250
276 port = parport_find_base(pi->port); 251 port = parport_find_base(pi->port);
@@ -290,7 +265,6 @@ static int pi_register_parport(PIA * pi, int verbose)
290 printk("%s: 0x%x is %s\n", pi->device, pi->port, port->name); 265 printk("%s: 0x%x is %s\n", pi->device, pi->port, port->name);
291 266
292 pi->parname = (char *) port->name; 267 pi->parname = (char *) port->name;
293#endif
294 268
295 return 1; 269 return 1;
296} 270}
@@ -447,13 +421,6 @@ int pi_init(PIA * pi, int autoprobe, int port, int mode,
447 printk("%s: Adapter not found\n", device); 421 printk("%s: Adapter not found\n", device);
448 return 0; 422 return 0;
449 } 423 }
450#ifndef CONFIG_PARPORT
451 if (!request_region(pi->port, pi->reserved, pi->device)) {
452 printk(KERN_WARNING "paride: Unable to request region 0x%x\n",
453 pi->port);
454 return 0;
455 }
456#endif /* !CONFIG_PARPORT */
457 424
458 if (pi->parname) 425 if (pi->parname)
459 printk("%s: Sharing %s at 0x%x\n", pi->device, 426 printk("%s: Sharing %s at 0x%x\n", pi->device,
diff --git a/drivers/block/paride/paride.h b/drivers/block/paride/paride.h
index c6d98ef09e48..2bddbf45518b 100644
--- a/drivers/block/paride/paride.h
+++ b/drivers/block/paride/paride.h
@@ -163,8 +163,8 @@ struct pi_protocol {
163 163
164typedef struct pi_protocol PIP; 164typedef struct pi_protocol PIP;
165 165
166extern int pi_register( PIP * ); 166extern int paride_register( PIP * );
167extern void pi_unregister ( PIP * ); 167extern void paride_unregister ( PIP * );
168 168
169#endif /* __DRIVERS_PARIDE_H__ */ 169#endif /* __DRIVERS_PARIDE_H__ */
170/* end of paride.h */ 170/* end of paride.h */
diff --git a/drivers/block/paride/pcd.c b/drivers/block/paride/pcd.c
index ac5ba462710b..c852eed91e4b 100644
--- a/drivers/block/paride/pcd.c
+++ b/drivers/block/paride/pcd.c
@@ -912,12 +912,12 @@ static int __init pcd_init(void)
912 int unit; 912 int unit;
913 913
914 if (disable) 914 if (disable)
915 return -1; 915 return -EINVAL;
916 916
917 pcd_init_units(); 917 pcd_init_units();
918 918
919 if (pcd_detect()) 919 if (pcd_detect())
920 return -1; 920 return -ENODEV;
921 921
922 /* get the atapi capabilities page */ 922 /* get the atapi capabilities page */
923 pcd_probe_capabilities(); 923 pcd_probe_capabilities();
@@ -925,7 +925,7 @@ static int __init pcd_init(void)
925 if (register_blkdev(major, name)) { 925 if (register_blkdev(major, name)) {
926 for (unit = 0, cd = pcd; unit < PCD_UNITS; unit++, cd++) 926 for (unit = 0, cd = pcd; unit < PCD_UNITS; unit++, cd++)
927 put_disk(cd->disk); 927 put_disk(cd->disk);
928 return -1; 928 return -EBUSY;
929 } 929 }
930 930
931 pcd_queue = blk_init_queue(do_pcd_request, &pcd_lock); 931 pcd_queue = blk_init_queue(do_pcd_request, &pcd_lock);
@@ -933,7 +933,7 @@ static int __init pcd_init(void)
933 unregister_blkdev(major, name); 933 unregister_blkdev(major, name);
934 for (unit = 0, cd = pcd; unit < PCD_UNITS; unit++, cd++) 934 for (unit = 0, cd = pcd; unit < PCD_UNITS; unit++, cd++)
935 put_disk(cd->disk); 935 put_disk(cd->disk);
936 return -1; 936 return -ENOMEM;
937 } 937 }
938 938
939 for (unit = 0, cd = pcd; unit < PCD_UNITS; unit++, cd++) { 939 for (unit = 0, cd = pcd; unit < PCD_UNITS; unit++, cd++) {
diff --git a/drivers/block/paride/pd.c b/drivers/block/paride/pd.c
index 40a11e567970..9d9bff23f426 100644
--- a/drivers/block/paride/pd.c
+++ b/drivers/block/paride/pd.c
@@ -352,19 +352,19 @@ static enum action (*phase)(void);
352 352
353static void run_fsm(void); 353static void run_fsm(void);
354 354
355static void ps_tq_int( void *data); 355static void ps_tq_int(struct work_struct *work);
356 356
357static DECLARE_WORK(fsm_tq, ps_tq_int, NULL); 357static DECLARE_DELAYED_WORK(fsm_tq, ps_tq_int);
358 358
359static void schedule_fsm(void) 359static void schedule_fsm(void)
360{ 360{
361 if (!nice) 361 if (!nice)
362 schedule_work(&fsm_tq); 362 schedule_delayed_work(&fsm_tq, 0);
363 else 363 else
364 schedule_delayed_work(&fsm_tq, nice-1); 364 schedule_delayed_work(&fsm_tq, nice-1);
365} 365}
366 366
367static void ps_tq_int(void *data) 367static void ps_tq_int(struct work_struct *work)
368{ 368{
369 run_fsm(); 369 run_fsm();
370} 370}
diff --git a/drivers/block/paride/pf.c b/drivers/block/paride/pf.c
index 1a9dee19efcf..7cdaa1951260 100644
--- a/drivers/block/paride/pf.c
+++ b/drivers/block/paride/pf.c
@@ -933,25 +933,25 @@ static int __init pf_init(void)
933 int unit; 933 int unit;
934 934
935 if (disable) 935 if (disable)
936 return -1; 936 return -EINVAL;
937 937
938 pf_init_units(); 938 pf_init_units();
939 939
940 if (pf_detect()) 940 if (pf_detect())
941 return -1; 941 return -ENODEV;
942 pf_busy = 0; 942 pf_busy = 0;
943 943
944 if (register_blkdev(major, name)) { 944 if (register_blkdev(major, name)) {
945 for (pf = units, unit = 0; unit < PF_UNITS; pf++, unit++) 945 for (pf = units, unit = 0; unit < PF_UNITS; pf++, unit++)
946 put_disk(pf->disk); 946 put_disk(pf->disk);
947 return -1; 947 return -EBUSY;
948 } 948 }
949 pf_queue = blk_init_queue(do_pf_request, &pf_spin_lock); 949 pf_queue = blk_init_queue(do_pf_request, &pf_spin_lock);
950 if (!pf_queue) { 950 if (!pf_queue) {
951 unregister_blkdev(major, name); 951 unregister_blkdev(major, name);
952 for (pf = units, unit = 0; unit < PF_UNITS; pf++, unit++) 952 for (pf = units, unit = 0; unit < PF_UNITS; pf++, unit++)
953 put_disk(pf->disk); 953 put_disk(pf->disk);
954 return -1; 954 return -ENOMEM;
955 } 955 }
956 956
957 blk_queue_max_phys_segments(pf_queue, cluster); 957 blk_queue_max_phys_segments(pf_queue, cluster);
diff --git a/drivers/block/paride/pg.c b/drivers/block/paride/pg.c
index 13f998aa1cd3..9970aedbb5d9 100644
--- a/drivers/block/paride/pg.c
+++ b/drivers/block/paride/pg.c
@@ -646,14 +646,14 @@ static int __init pg_init(void)
646 int err; 646 int err;
647 647
648 if (disable){ 648 if (disable){
649 err = -1; 649 err = -EINVAL;
650 goto out; 650 goto out;
651 } 651 }
652 652
653 pg_init_units(); 653 pg_init_units();
654 654
655 if (pg_detect()) { 655 if (pg_detect()) {
656 err = -1; 656 err = -ENODEV;
657 goto out; 657 goto out;
658 } 658 }
659 659
diff --git a/drivers/block/paride/pseudo.h b/drivers/block/paride/pseudo.h
index 932342d7a8eb..bc3703294143 100644
--- a/drivers/block/paride/pseudo.h
+++ b/drivers/block/paride/pseudo.h
@@ -35,7 +35,7 @@
35#include <linux/sched.h> 35#include <linux/sched.h>
36#include <linux/workqueue.h> 36#include <linux/workqueue.h>
37 37
38static void ps_tq_int( void *data); 38static void ps_tq_int(struct work_struct *work);
39 39
40static void (* ps_continuation)(void); 40static void (* ps_continuation)(void);
41static int (* ps_ready)(void); 41static int (* ps_ready)(void);
@@ -45,7 +45,7 @@ static int ps_nice = 0;
45 45
46static DEFINE_SPINLOCK(ps_spinlock __attribute__((unused))); 46static DEFINE_SPINLOCK(ps_spinlock __attribute__((unused)));
47 47
48static DECLARE_WORK(ps_tq, ps_tq_int, NULL); 48static DECLARE_DELAYED_WORK(ps_tq, ps_tq_int);
49 49
50static void ps_set_intr(void (*continuation)(void), 50static void ps_set_intr(void (*continuation)(void),
51 int (*ready)(void), 51 int (*ready)(void),
@@ -63,14 +63,14 @@ static void ps_set_intr(void (*continuation)(void),
63 if (!ps_tq_active) { 63 if (!ps_tq_active) {
64 ps_tq_active = 1; 64 ps_tq_active = 1;
65 if (!ps_nice) 65 if (!ps_nice)
66 schedule_work(&ps_tq); 66 schedule_delayed_work(&ps_tq, 0);
67 else 67 else
68 schedule_delayed_work(&ps_tq, ps_nice-1); 68 schedule_delayed_work(&ps_tq, ps_nice-1);
69 } 69 }
70 spin_unlock_irqrestore(&ps_spinlock,flags); 70 spin_unlock_irqrestore(&ps_spinlock,flags);
71} 71}
72 72
73static void ps_tq_int(void *data) 73static void ps_tq_int(struct work_struct *work)
74{ 74{
75 void (*con)(void); 75 void (*con)(void);
76 unsigned long flags; 76 unsigned long flags;
@@ -92,7 +92,7 @@ static void ps_tq_int(void *data)
92 } 92 }
93 ps_tq_active = 1; 93 ps_tq_active = 1;
94 if (!ps_nice) 94 if (!ps_nice)
95 schedule_work(&ps_tq); 95 schedule_delayed_work(&ps_tq, 0);
96 else 96 else
97 schedule_delayed_work(&ps_tq, ps_nice-1); 97 schedule_delayed_work(&ps_tq, ps_nice-1);
98 spin_unlock_irqrestore(&ps_spinlock,flags); 98 spin_unlock_irqrestore(&ps_spinlock,flags);
diff --git a/drivers/block/paride/pt.c b/drivers/block/paride/pt.c
index 35fb26636721..c902b25e4869 100644
--- a/drivers/block/paride/pt.c
+++ b/drivers/block/paride/pt.c
@@ -946,12 +946,12 @@ static int __init pt_init(void)
946 int err; 946 int err;
947 947
948 if (disable) { 948 if (disable) {
949 err = -1; 949 err = -EINVAL;
950 goto out; 950 goto out;
951 } 951 }
952 952
953 if (pt_detect()) { 953 if (pt_detect()) {
954 err = -1; 954 err = -ENODEV;
955 goto out; 955 goto out;
956 } 956 }
957 957
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index f2904f67af47..e45eaa264119 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -54,7 +54,7 @@
54#include <linux/proc_fs.h> 54#include <linux/proc_fs.h>
55#include <linux/seq_file.h> 55#include <linux/seq_file.h>
56#include <linux/miscdevice.h> 56#include <linux/miscdevice.h>
57#include <linux/suspend.h> 57#include <linux/freezer.h>
58#include <linux/mutex.h> 58#include <linux/mutex.h>
59#include <scsi/scsi_cmnd.h> 59#include <scsi/scsi_cmnd.h>
60#include <scsi/scsi_ioctl.h> 60#include <scsi/scsi_ioctl.h>
diff --git a/drivers/block/sx8.c b/drivers/block/sx8.c
index 47d6975268ff..54509eb3391b 100644
--- a/drivers/block/sx8.c
+++ b/drivers/block/sx8.c
@@ -1244,9 +1244,10 @@ out:
1244 return IRQ_RETVAL(handled); 1244 return IRQ_RETVAL(handled);
1245} 1245}
1246 1246
1247static void carm_fsm_task (void *_data) 1247static void carm_fsm_task (struct work_struct *work)
1248{ 1248{
1249 struct carm_host *host = _data; 1249 struct carm_host *host =
1250 container_of(work, struct carm_host, fsm_task);
1250 unsigned long flags; 1251 unsigned long flags;
1251 unsigned int state; 1252 unsigned int state;
1252 int rc, i, next_dev; 1253 int rc, i, next_dev;
@@ -1619,7 +1620,7 @@ static int carm_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
1619 host->pdev = pdev; 1620 host->pdev = pdev;
1620 host->flags = pci_dac ? FL_DAC : 0; 1621 host->flags = pci_dac ? FL_DAC : 0;
1621 spin_lock_init(&host->lock); 1622 spin_lock_init(&host->lock);
1622 INIT_WORK(&host->fsm_task, carm_fsm_task, host); 1623 INIT_WORK(&host->fsm_task, carm_fsm_task);
1623 init_completion(&host->probe_comp); 1624 init_completion(&host->probe_comp);
1624 1625
1625 for (i = 0; i < ARRAY_SIZE(host->req); i++) 1626 for (i = 0; i < ARRAY_SIZE(host->req); i++)
diff --git a/drivers/block/ub.c b/drivers/block/ub.c
index 0d5c73f07265..2098eff91e14 100644
--- a/drivers/block/ub.c
+++ b/drivers/block/ub.c
@@ -376,7 +376,7 @@ static int ub_submit_clear_stall(struct ub_dev *sc, struct ub_scsi_cmd *cmd,
376 int stalled_pipe); 376 int stalled_pipe);
377static void ub_top_sense_done(struct ub_dev *sc, struct ub_scsi_cmd *scmd); 377static void ub_top_sense_done(struct ub_dev *sc, struct ub_scsi_cmd *scmd);
378static void ub_reset_enter(struct ub_dev *sc, int try); 378static void ub_reset_enter(struct ub_dev *sc, int try);
379static void ub_reset_task(void *arg); 379static void ub_reset_task(struct work_struct *work);
380static int ub_sync_tur(struct ub_dev *sc, struct ub_lun *lun); 380static int ub_sync_tur(struct ub_dev *sc, struct ub_lun *lun);
381static int ub_sync_read_cap(struct ub_dev *sc, struct ub_lun *lun, 381static int ub_sync_read_cap(struct ub_dev *sc, struct ub_lun *lun,
382 struct ub_capacity *ret); 382 struct ub_capacity *ret);
@@ -1558,9 +1558,9 @@ static void ub_reset_enter(struct ub_dev *sc, int try)
1558 schedule_work(&sc->reset_work); 1558 schedule_work(&sc->reset_work);
1559} 1559}
1560 1560
1561static void ub_reset_task(void *arg) 1561static void ub_reset_task(struct work_struct *work)
1562{ 1562{
1563 struct ub_dev *sc = arg; 1563 struct ub_dev *sc = container_of(work, struct ub_dev, reset_work);
1564 unsigned long flags; 1564 unsigned long flags;
1565 struct list_head *p; 1565 struct list_head *p;
1566 struct ub_lun *lun; 1566 struct ub_lun *lun;
@@ -2179,7 +2179,7 @@ static int ub_probe(struct usb_interface *intf,
2179 usb_init_urb(&sc->work_urb); 2179 usb_init_urb(&sc->work_urb);
2180 tasklet_init(&sc->tasklet, ub_scsi_action, (unsigned long)sc); 2180 tasklet_init(&sc->tasklet, ub_scsi_action, (unsigned long)sc);
2181 atomic_set(&sc->poison, 0); 2181 atomic_set(&sc->poison, 0);
2182 INIT_WORK(&sc->reset_work, ub_reset_task, sc); 2182 INIT_WORK(&sc->reset_work, ub_reset_task);
2183 init_waitqueue_head(&sc->reset_wait); 2183 init_waitqueue_head(&sc->reset_wait);
2184 2184
2185 init_timer(&sc->work_timer); 2185 init_timer(&sc->work_timer);
diff --git a/drivers/block/viodasd.c b/drivers/block/viodasd.c
index ec5a1b90a0a2..e19ba4ebcd4e 100644
--- a/drivers/block/viodasd.c
+++ b/drivers/block/viodasd.c
@@ -759,6 +759,8 @@ static struct vio_driver viodasd_driver = {
759 } 759 }
760}; 760};
761 761
762static int need_delete_probe;
763
762/* 764/*
763 * Initialize the whole device driver. Handle module and non-module 765 * Initialize the whole device driver. Handle module and non-module
764 * versions 766 * versions
@@ -773,46 +775,67 @@ static int __init viodasd_init(void)
773 775
774 if (viopath_hostLp == HvLpIndexInvalid) { 776 if (viopath_hostLp == HvLpIndexInvalid) {
775 printk(VIOD_KERN_WARNING "invalid hosting partition\n"); 777 printk(VIOD_KERN_WARNING "invalid hosting partition\n");
776 return -EIO; 778 rc = -EIO;
779 goto early_fail;
777 } 780 }
778 781
779 printk(VIOD_KERN_INFO "vers " VIOD_VERS ", hosting partition %d\n", 782 printk(VIOD_KERN_INFO "vers " VIOD_VERS ", hosting partition %d\n",
780 viopath_hostLp); 783 viopath_hostLp);
781 784
782 /* register the block device */ 785 /* register the block device */
783 if (register_blkdev(VIODASD_MAJOR, VIOD_GENHD_NAME)) { 786 rc = register_blkdev(VIODASD_MAJOR, VIOD_GENHD_NAME);
787 if (rc) {
784 printk(VIOD_KERN_WARNING 788 printk(VIOD_KERN_WARNING
785 "Unable to get major number %d for %s\n", 789 "Unable to get major number %d for %s\n",
786 VIODASD_MAJOR, VIOD_GENHD_NAME); 790 VIODASD_MAJOR, VIOD_GENHD_NAME);
787 return -EIO; 791 goto early_fail;
788 } 792 }
789 /* Actually open the path to the hosting partition */ 793 /* Actually open the path to the hosting partition */
790 if (viopath_open(viopath_hostLp, viomajorsubtype_blockio, 794 rc = viopath_open(viopath_hostLp, viomajorsubtype_blockio,
791 VIOMAXREQ + 2)) { 795 VIOMAXREQ + 2);
796 if (rc) {
792 printk(VIOD_KERN_WARNING 797 printk(VIOD_KERN_WARNING
793 "error opening path to host partition %d\n", 798 "error opening path to host partition %d\n",
794 viopath_hostLp); 799 viopath_hostLp);
795 unregister_blkdev(VIODASD_MAJOR, VIOD_GENHD_NAME); 800 goto unregister_blk;
796 return -EIO;
797 } 801 }
798 802
799 /* Initialize our request handler */ 803 /* Initialize our request handler */
800 vio_setHandler(viomajorsubtype_blockio, handle_block_event); 804 vio_setHandler(viomajorsubtype_blockio, handle_block_event);
801 805
802 rc = vio_register_driver(&viodasd_driver); 806 rc = vio_register_driver(&viodasd_driver);
803 if (rc == 0) 807 if (rc) {
804 driver_create_file(&viodasd_driver.driver, &driver_attr_probe); 808 printk(VIOD_KERN_WARNING "vio_register_driver failed\n");
809 goto unset_handler;
810 }
811
812 /*
813 * If this call fails, it just means that we cannot dynamically
814 * add virtual disks, but the driver will still work fine for
815 * all existing disk, so ignore the failure.
816 */
817 if (!driver_create_file(&viodasd_driver.driver, &driver_attr_probe))
818 need_delete_probe = 1;
819
820 return 0;
821
822unset_handler:
823 vio_clearHandler(viomajorsubtype_blockio);
824 viopath_close(viopath_hostLp, viomajorsubtype_blockio, VIOMAXREQ + 2);
825unregister_blk:
826 unregister_blkdev(VIODASD_MAJOR, VIOD_GENHD_NAME);
827early_fail:
805 return rc; 828 return rc;
806} 829}
807module_init(viodasd_init); 830module_init(viodasd_init);
808 831
809void viodasd_exit(void) 832void __exit viodasd_exit(void)
810{ 833{
811 driver_remove_file(&viodasd_driver.driver, &driver_attr_probe); 834 if (need_delete_probe)
835 driver_remove_file(&viodasd_driver.driver, &driver_attr_probe);
812 vio_unregister_driver(&viodasd_driver); 836 vio_unregister_driver(&viodasd_driver);
813 vio_clearHandler(viomajorsubtype_blockio); 837 vio_clearHandler(viomajorsubtype_blockio);
814 unregister_blkdev(VIODASD_MAJOR, VIOD_GENHD_NAME);
815 viopath_close(viopath_hostLp, viomajorsubtype_blockio, VIOMAXREQ + 2); 838 viopath_close(viopath_hostLp, viomajorsubtype_blockio, VIOMAXREQ + 2);
839 unregister_blkdev(VIODASD_MAJOR, VIOD_GENHD_NAME);
816} 840}
817
818module_exit(viodasd_exit); 841module_exit(viodasd_exit);
diff --git a/drivers/bluetooth/bcm203x.c b/drivers/bluetooth/bcm203x.c
index 516751754aa9..9256985cbe36 100644
--- a/drivers/bluetooth/bcm203x.c
+++ b/drivers/bluetooth/bcm203x.c
@@ -157,9 +157,10 @@ static void bcm203x_complete(struct urb *urb)
157 } 157 }
158} 158}
159 159
160static void bcm203x_work(void *user_data) 160static void bcm203x_work(struct work_struct *work)
161{ 161{
162 struct bcm203x_data *data = user_data; 162 struct bcm203x_data *data =
163 container_of(work, struct bcm203x_data, work);
163 164
164 if (usb_submit_urb(data->urb, GFP_ATOMIC) < 0) 165 if (usb_submit_urb(data->urb, GFP_ATOMIC) < 0)
165 BT_ERR("Can't submit URB"); 166 BT_ERR("Can't submit URB");
@@ -246,7 +247,7 @@ static int bcm203x_probe(struct usb_interface *intf, const struct usb_device_id
246 247
247 release_firmware(firmware); 248 release_firmware(firmware);
248 249
249 INIT_WORK(&data->work, bcm203x_work, (void *) data); 250 INIT_WORK(&data->work, bcm203x_work);
250 251
251 usb_set_intfdata(intf, data); 252 usb_set_intfdata(intf, data);
252 253
diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c
index cbc07250b898..acfb6a430dcc 100644
--- a/drivers/bluetooth/bluecard_cs.c
+++ b/drivers/bluetooth/bluecard_cs.c
@@ -892,43 +892,10 @@ static void bluecard_detach(struct pcmcia_device *link)
892} 892}
893 893
894 894
895static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse)
896{
897 int i;
898
899 i = pcmcia_get_first_tuple(handle, tuple);
900 if (i != CS_SUCCESS)
901 return CS_NO_MORE_ITEMS;
902
903 i = pcmcia_get_tuple_data(handle, tuple);
904 if (i != CS_SUCCESS)
905 return i;
906
907 return pcmcia_parse_tuple(handle, tuple, parse);
908}
909
910static int bluecard_config(struct pcmcia_device *link) 895static int bluecard_config(struct pcmcia_device *link)
911{ 896{
912 bluecard_info_t *info = link->priv; 897 bluecard_info_t *info = link->priv;
913 tuple_t tuple; 898 int i, n;
914 u_short buf[256];
915 cisparse_t parse;
916 int i, n, last_ret, last_fn;
917
918 tuple.TupleData = (cisdata_t *)buf;
919 tuple.TupleOffset = 0;
920 tuple.TupleDataMax = 255;
921 tuple.Attributes = 0;
922
923 /* Get configuration register information */
924 tuple.DesiredTuple = CISTPL_CONFIG;
925 last_ret = first_tuple(link, &tuple, &parse);
926 if (last_ret != CS_SUCCESS) {
927 last_fn = ParseTuple;
928 goto cs_failed;
929 }
930 link->conf.ConfigBase = parse.config.base;
931 link->conf.Present = parse.config.rmask[0];
932 899
933 link->conf.ConfigIndex = 0x20; 900 link->conf.ConfigIndex = 0x20;
934 link->io.NumPorts1 = 64; 901 link->io.NumPorts1 = 64;
@@ -966,9 +933,6 @@ static int bluecard_config(struct pcmcia_device *link)
966 933
967 return 0; 934 return 0;
968 935
969cs_failed:
970 cs_error(link, last_fn, last_ret);
971
972failed: 936failed:
973 bluecard_release(link); 937 bluecard_release(link);
974 return -ENODEV; 938 return -ENODEV;
diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c
index 3a96a0babc6a..aae3abace586 100644
--- a/drivers/bluetooth/bt3c_cs.c
+++ b/drivers/bluetooth/bt3c_cs.c
@@ -713,22 +713,7 @@ static int bt3c_config(struct pcmcia_device *link)
713 u_short buf[256]; 713 u_short buf[256];
714 cisparse_t parse; 714 cisparse_t parse;
715 cistpl_cftable_entry_t *cf = &parse.cftable_entry; 715 cistpl_cftable_entry_t *cf = &parse.cftable_entry;
716 int i, j, try, last_ret, last_fn; 716 int i, j, try;
717
718 tuple.TupleData = (cisdata_t *)buf;
719 tuple.TupleOffset = 0;
720 tuple.TupleDataMax = 255;
721 tuple.Attributes = 0;
722
723 /* Get configuration register information */
724 tuple.DesiredTuple = CISTPL_CONFIG;
725 last_ret = first_tuple(link, &tuple, &parse);
726 if (last_ret != CS_SUCCESS) {
727 last_fn = ParseTuple;
728 goto cs_failed;
729 }
730 link->conf.ConfigBase = parse.config.base;
731 link->conf.Present = parse.config.rmask[0];
732 717
733 /* First pass: look for a config entry that looks normal. */ 718 /* First pass: look for a config entry that looks normal. */
734 tuple.TupleData = (cisdata_t *)buf; 719 tuple.TupleData = (cisdata_t *)buf;
@@ -802,9 +787,6 @@ found_port:
802 787
803 return 0; 788 return 0;
804 789
805cs_failed:
806 cs_error(link, last_fn, last_ret);
807
808failed: 790failed:
809 bt3c_release(link); 791 bt3c_release(link);
810 return -ENODEV; 792 return -ENODEV;
diff --git a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c
index 3b29086b7c3f..92648ef2f5d0 100644
--- a/drivers/bluetooth/btuart_cs.c
+++ b/drivers/bluetooth/btuart_cs.c
@@ -644,22 +644,7 @@ static int btuart_config(struct pcmcia_device *link)
644 u_short buf[256]; 644 u_short buf[256];
645 cisparse_t parse; 645 cisparse_t parse;
646 cistpl_cftable_entry_t *cf = &parse.cftable_entry; 646 cistpl_cftable_entry_t *cf = &parse.cftable_entry;
647 int i, j, try, last_ret, last_fn; 647 int i, j, try;
648
649 tuple.TupleData = (cisdata_t *)buf;
650 tuple.TupleOffset = 0;
651 tuple.TupleDataMax = 255;
652 tuple.Attributes = 0;
653
654 /* Get configuration register information */
655 tuple.DesiredTuple = CISTPL_CONFIG;
656 last_ret = first_tuple(link, &tuple, &parse);
657 if (last_ret != CS_SUCCESS) {
658 last_fn = ParseTuple;
659 goto cs_failed;
660 }
661 link->conf.ConfigBase = parse.config.base;
662 link->conf.Present = parse.config.rmask[0];
663 648
664 /* First pass: look for a config entry that looks normal. */ 649 /* First pass: look for a config entry that looks normal. */
665 tuple.TupleData = (cisdata_t *) buf; 650 tuple.TupleData = (cisdata_t *) buf;
@@ -734,9 +719,6 @@ found_port:
734 719
735 return 0; 720 return 0;
736 721
737cs_failed:
738 cs_error(link, last_fn, last_ret);
739
740failed: 722failed:
741 btuart_release(link); 723 btuart_release(link);
742 return -ENODEV; 724 return -ENODEV;
diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c
index 07eafbc5dc3a..77b99eecbc49 100644
--- a/drivers/bluetooth/dtl1_cs.c
+++ b/drivers/bluetooth/dtl1_cs.c
@@ -626,22 +626,7 @@ static int dtl1_config(struct pcmcia_device *link)
626 u_short buf[256]; 626 u_short buf[256];
627 cisparse_t parse; 627 cisparse_t parse;
628 cistpl_cftable_entry_t *cf = &parse.cftable_entry; 628 cistpl_cftable_entry_t *cf = &parse.cftable_entry;
629 int i, last_ret, last_fn; 629 int i;
630
631 tuple.TupleData = (cisdata_t *)buf;
632 tuple.TupleOffset = 0;
633 tuple.TupleDataMax = 255;
634 tuple.Attributes = 0;
635
636 /* Get configuration register information */
637 tuple.DesiredTuple = CISTPL_CONFIG;
638 last_ret = first_tuple(link, &tuple, &parse);
639 if (last_ret != CS_SUCCESS) {
640 last_fn = ParseTuple;
641 goto cs_failed;
642 }
643 link->conf.ConfigBase = parse.config.base;
644 link->conf.Present = parse.config.rmask[0];
645 630
646 tuple.TupleData = (cisdata_t *)buf; 631 tuple.TupleData = (cisdata_t *)buf;
647 tuple.TupleOffset = 0; 632 tuple.TupleOffset = 0;
@@ -690,9 +675,6 @@ static int dtl1_config(struct pcmcia_device *link)
690 675
691 return 0; 676 return 0;
692 677
693cs_failed:
694 cs_error(link, last_fn, last_ret);
695
696failed: 678failed:
697 dtl1_release(link); 679 dtl1_release(link);
698 return -ENODEV; 680 return -ENODEV;
diff --git a/drivers/bluetooth/hci_bcsp.c b/drivers/bluetooth/hci_bcsp.c
index d0cface535fb..5e2c31882003 100644
--- a/drivers/bluetooth/hci_bcsp.c
+++ b/drivers/bluetooth/hci_bcsp.c
@@ -330,7 +330,7 @@ static struct sk_buff *bcsp_dequeue(struct hci_uart *hu)
330 reliable packet if the number of packets sent but not yet ack'ed 330 reliable packet if the number of packets sent but not yet ack'ed
331 is < than the winsize */ 331 is < than the winsize */
332 332
333 spin_lock_irqsave(&bcsp->unack.lock, flags); 333 spin_lock_irqsave_nested(&bcsp->unack.lock, flags, SINGLE_DEPTH_NESTING);
334 334
335 if (bcsp->unack.qlen < BCSP_TXWINSIZE && (skb = skb_dequeue(&bcsp->rel)) != NULL) { 335 if (bcsp->unack.qlen < BCSP_TXWINSIZE && (skb = skb_dequeue(&bcsp->rel)) != NULL) {
336 struct sk_buff *nskb = bcsp_prepare_pkt(bcsp, skb->data, skb->len, bt_cb(skb)->pkt_type); 336 struct sk_buff *nskb = bcsp_prepare_pkt(bcsp, skb->data, skb->len, bt_cb(skb)->pkt_type);
@@ -696,7 +696,7 @@ static void bcsp_timed_event(unsigned long arg)
696 696
697 BT_DBG("hu %p retransmitting %u pkts", hu, bcsp->unack.qlen); 697 BT_DBG("hu %p retransmitting %u pkts", hu, bcsp->unack.qlen);
698 698
699 spin_lock_irqsave(&bcsp->unack.lock, flags); 699 spin_lock_irqsave_nested(&bcsp->unack.lock, flags, SINGLE_DEPTH_NESTING);
700 700
701 while ((skb = __skb_dequeue_tail(&bcsp->unack)) != NULL) { 701 while ((skb = __skb_dequeue_tail(&bcsp->unack)) != NULL) {
702 bcsp->msgq_txseq = (bcsp->msgq_txseq - 1) & 0x07; 702 bcsp->msgq_txseq = (bcsp->msgq_txseq - 1) & 0x07;
diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
index 7ea0f48f8fa6..2df5cf4ec743 100644
--- a/drivers/cdrom/cdrom.c
+++ b/drivers/cdrom/cdrom.c
@@ -2133,16 +2133,14 @@ static int cdrom_read_cdda_bpc(struct cdrom_device_info *cdi, __u8 __user *ubuf,
2133 rq->timeout = 60 * HZ; 2133 rq->timeout = 60 * HZ;
2134 bio = rq->bio; 2134 bio = rq->bio;
2135 2135
2136 if (rq->bio)
2137 blk_queue_bounce(q, &rq->bio);
2138
2139 if (blk_execute_rq(q, cdi->disk, rq, 0)) { 2136 if (blk_execute_rq(q, cdi->disk, rq, 0)) {
2140 struct request_sense *s = rq->sense; 2137 struct request_sense *s = rq->sense;
2141 ret = -EIO; 2138 ret = -EIO;
2142 cdi->last_sense = s->sense_key; 2139 cdi->last_sense = s->sense_key;
2143 } 2140 }
2144 2141
2145 if (blk_rq_unmap_user(bio, len)) 2142 rq->bio = bio;
2143 if (blk_rq_unmap_user(rq))
2146 ret = -EFAULT; 2144 ret = -EFAULT;
2147 2145
2148 if (ret) 2146 if (ret)
diff --git a/drivers/cdrom/optcd.c b/drivers/cdrom/optcd.c
index 25032d7edc55..3541690a77d4 100644
--- a/drivers/cdrom/optcd.c
+++ b/drivers/cdrom/optcd.c
@@ -101,7 +101,7 @@ static void debug(int debug_this, const char* fmt, ...)
101 return; 101 return;
102 102
103 va_start(args, fmt); 103 va_start(args, fmt);
104 vsprintf(s, fmt, args); 104 vsnprintf(s, sizeof(s), fmt, args);
105 printk(KERN_DEBUG "optcd: %s\n", s); 105 printk(KERN_DEBUG "optcd: %s\n", s);
106 va_end(args); 106 va_end(args);
107} 107}
diff --git a/drivers/cdrom/sbpcd.c b/drivers/cdrom/sbpcd.c
index ba50e5a712f2..a1283b1ef989 100644
--- a/drivers/cdrom/sbpcd.c
+++ b/drivers/cdrom/sbpcd.c
@@ -770,11 +770,10 @@ static void msg(int level, const char *fmt, ...)
770 770
771 msgnum++; 771 msgnum++;
772 if (msgnum>99) msgnum=0; 772 if (msgnum>99) msgnum=0;
773 sprintf(buf, MSG_LEVEL "%s-%d [%02d]: ", major_name, current_drive - D_S, msgnum);
774 va_start(args, fmt); 773 va_start(args, fmt);
775 vsprintf(&buf[18], fmt, args); 774 vsnprintf(buf, sizeof(buf), fmt, args);
776 va_end(args); 775 va_end(args);
777 printk(buf); 776 printk(MSG_LEVEL "%s-%d [%02d]: %s", major_name, current_drive - D_S, msgnum, buf);
778#if KLOGD_PAUSE 777#if KLOGD_PAUSE
779 sbp_sleep(KLOGD_PAUSE); /* else messages get lost */ 778 sbp_sleep(KLOGD_PAUSE); /* else messages get lost */
780#endif /* KLOGD_PAUSE */ 779#endif /* KLOGD_PAUSE */
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index 39a9f8cc6412..24f922f12783 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -409,14 +409,6 @@ config SGI_MBCS
409 If you have an SGI Altix with an attached SABrick 409 If you have an SGI Altix with an attached SABrick
410 say Y or M here, otherwise say N. 410 say Y or M here, otherwise say N.
411 411
412config MSPEC
413 tristate "Memory special operations driver"
414 depends on IA64
415 help
416 If you have an ia64 and you want to enable memory special
417 operations support (formerly known as fetchop), say Y here,
418 otherwise say N.
419
420source "drivers/serial/Kconfig" 412source "drivers/serial/Kconfig"
421 413
422config UNIX98_PTYS 414config UNIX98_PTYS
@@ -863,39 +855,6 @@ config TANBAC_TB0219
863 depends TANBAC_TB022X 855 depends TANBAC_TB022X
864 select GPIO_VR41XX 856 select GPIO_VR41XX
865 857
866menu "Ftape, the floppy tape device driver"
867
868config FTAPE
869 tristate "Ftape (QIC-80/Travan) support"
870 depends on BROKEN_ON_SMP && (ALPHA || X86)
871 ---help---
872 If you have a tape drive that is connected to your floppy
873 controller, say Y here.
874
875 Some tape drives (like the Seagate "Tape Store 3200" or the Iomega
876 "Ditto 3200" or the Exabyte "Eagle TR-3") come with a "high speed"
877 controller of their own. These drives (and their companion
878 controllers) are also supported if you say Y here.
879
880 If you have a special controller (such as the CMS FC-10, FC-20,
881 Mountain Mach-II, or any controller that is based on the Intel 82078
882 FDC like the high speed controllers by Seagate and Exabyte and
883 Iomega's "Ditto Dash") you must configure it by selecting the
884 appropriate entries from the "Floppy tape controllers" sub-menu
885 below and possibly modify the default values for the IRQ and DMA
886 channel and the IO base in ftape's configuration menu.
887
888 If you want to use your floppy tape drive on a PCI-bus based system,
889 please read the file <file:drivers/char/ftape/README.PCI>.
890
891 The ftape kernel driver is also available as a runtime loadable
892 module. To compile this driver as a module, choose M here: the
893 module will be called ftape.
894
895source "drivers/char/ftape/Kconfig"
896
897endmenu
898
899source "drivers/char/agp/Kconfig" 858source "drivers/char/agp/Kconfig"
900 859
901source "drivers/char/drm/Kconfig" 860source "drivers/char/drm/Kconfig"
@@ -1002,7 +961,7 @@ config HPET
1002 help 961 help
1003 If you say Y here, you will have a miscdevice named "/dev/hpet/". Each 962 If you say Y here, you will have a miscdevice named "/dev/hpet/". Each
1004 open selects one of the timers supported by the HPET. The timers are 963 open selects one of the timers supported by the HPET. The timers are
1005 non-periodioc and/or periodic. 964 non-periodic and/or periodic.
1006 965
1007config HPET_RTC_IRQ 966config HPET_RTC_IRQ
1008 bool "HPET Control RTC IRQ" if !HPET_EMULATE_RTC 967 bool "HPET Control RTC IRQ" if !HPET_EMULATE_RTC
diff --git a/drivers/char/Makefile b/drivers/char/Makefile
index 777cad045094..b1fcdab90947 100644
--- a/drivers/char/Makefile
+++ b/drivers/char/Makefile
@@ -78,7 +78,6 @@ obj-$(CONFIG_TOSHIBA) += toshiba.o
78obj-$(CONFIG_I8K) += i8k.o 78obj-$(CONFIG_I8K) += i8k.o
79obj-$(CONFIG_DS1620) += ds1620.o 79obj-$(CONFIG_DS1620) += ds1620.o
80obj-$(CONFIG_HW_RANDOM) += hw_random/ 80obj-$(CONFIG_HW_RANDOM) += hw_random/
81obj-$(CONFIG_FTAPE) += ftape/
82obj-$(CONFIG_COBALT_LCD) += lcd.o 81obj-$(CONFIG_COBALT_LCD) += lcd.o
83obj-$(CONFIG_PPDEV) += ppdev.o 82obj-$(CONFIG_PPDEV) += ppdev.o
84obj-$(CONFIG_NWBUTTON) += nwbutton.o 83obj-$(CONFIG_NWBUTTON) += nwbutton.o
diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c
index 00b17ae39736..2f2c4efff8a3 100644
--- a/drivers/char/agp/amd64-agp.c
+++ b/drivers/char/agp/amd64-agp.c
@@ -459,7 +459,7 @@ static const struct aper_size_info_32 nforce3_sizes[5] =
459 459
460/* Handle shadow device of the Nvidia NForce3 */ 460/* Handle shadow device of the Nvidia NForce3 */
461/* CHECK-ME original 2.4 version set up some IORRs. Check if that is needed. */ 461/* CHECK-ME original 2.4 version set up some IORRs. Check if that is needed. */
462static int __devinit nforce3_agp_init(struct pci_dev *pdev) 462static int nforce3_agp_init(struct pci_dev *pdev)
463{ 463{
464 u32 tmp, apbase, apbar, aplimit; 464 u32 tmp, apbase, apbar, aplimit;
465 struct pci_dev *dev1; 465 struct pci_dev *dev1;
diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c
index c39200161688..5ff457b41efb 100644
--- a/drivers/char/agp/generic.c
+++ b/drivers/char/agp/generic.c
@@ -1054,7 +1054,7 @@ void *agp_generic_alloc_page(struct agp_bridge_data *bridge)
1054{ 1054{
1055 struct page * page; 1055 struct page * page;
1056 1056
1057 page = alloc_page(GFP_KERNEL); 1057 page = alloc_page(GFP_KERNEL | GFP_DMA32);
1058 if (page == NULL) 1058 if (page == NULL)
1059 return NULL; 1059 return NULL;
1060 1060
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
index d1ede7db5a12..555b3a8ab49c 100644
--- a/drivers/char/agp/intel-agp.c
+++ b/drivers/char/agp/intel-agp.c
@@ -169,7 +169,7 @@ static void *i8xx_alloc_pages(void)
169{ 169{
170 struct page * page; 170 struct page * page;
171 171
172 page = alloc_pages(GFP_KERNEL, 2); 172 page = alloc_pages(GFP_KERNEL | GFP_DMA32, 2);
173 if (page == NULL) 173 if (page == NULL)
174 return NULL; 174 return NULL;
175 175
@@ -387,11 +387,7 @@ static void intel_i830_init_gtt_entries(void)
387 /* We obtain the size of the GTT, which is also stored (for some 387 /* We obtain the size of the GTT, which is also stored (for some
388 * reason) at the top of stolen memory. Then we add 4KB to that 388 * reason) at the top of stolen memory. Then we add 4KB to that
389 * for the video BIOS popup, which is also stored in there. */ 389 * for the video BIOS popup, which is also stored in there. */
390 390 size = agp_bridge->driver->fetch_size() + 4;
391 if (IS_I965)
392 size = 512 + 4;
393 else
394 size = agp_bridge->driver->fetch_size() + 4;
395 391
396 if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82830_HB || 392 if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82830_HB ||
397 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82845G_HB) { 393 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82845G_HB) {
@@ -805,6 +801,26 @@ static int intel_i915_create_gatt_table(struct agp_bridge_data *bridge)
805 801
806 return 0; 802 return 0;
807} 803}
804
805/*
806 * The i965 supports 36-bit physical addresses, but to keep
807 * the format of the GTT the same, the bits that don't fit
808 * in a 32-bit word are shifted down to bits 4..7.
809 *
810 * Gcc is smart enough to notice that "(addr >> 28) & 0xf0"
811 * is always zero on 32-bit architectures, so no need to make
812 * this conditional.
813 */
814static unsigned long intel_i965_mask_memory(struct agp_bridge_data *bridge,
815 unsigned long addr, int type)
816{
817 /* Shift high bits down */
818 addr |= (addr >> 28) & 0xf0;
819
820 /* Type checking must be done elsewhere */
821 return addr | bridge->driver->masks[type].mask;
822}
823
808static int intel_i965_fetch_size(void) 824static int intel_i965_fetch_size(void)
809{ 825{
810 struct aper_size_info_fixed *values; 826 struct aper_size_info_fixed *values;
@@ -832,7 +848,8 @@ static int intel_i965_fetch_size(void)
832 848
833 agp_bridge->previous_size = agp_bridge->current_size = (void *)(values + offset); 849 agp_bridge->previous_size = agp_bridge->current_size = (void *)(values + offset);
834 850
835 return values[offset].size; 851 /* The i965 GTT is always sized as if it had a 512kB aperture size */
852 return 512;
836} 853}
837 854
838/* The intel i965 automatically initializes the agp aperture during POST. 855/* The intel i965 automatically initializes the agp aperture during POST.
@@ -1584,7 +1601,7 @@ static struct agp_bridge_driver intel_i965_driver = {
1584 .fetch_size = intel_i965_fetch_size, 1601 .fetch_size = intel_i965_fetch_size,
1585 .cleanup = intel_i915_cleanup, 1602 .cleanup = intel_i915_cleanup,
1586 .tlb_flush = intel_i810_tlbflush, 1603 .tlb_flush = intel_i810_tlbflush,
1587 .mask_memory = intel_i810_mask_memory, 1604 .mask_memory = intel_i965_mask_memory,
1588 .masks = intel_i810_masks, 1605 .masks = intel_i810_masks,
1589 .agp_enable = intel_i810_agp_enable, 1606 .agp_enable = intel_i810_agp_enable,
1590 .cache_flush = global_cache_flush, 1607 .cache_flush = global_cache_flush,
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
index e608dadece2f..acb2de5e3a98 100644
--- a/drivers/char/cyclades.c
+++ b/drivers/char/cyclades.c
@@ -926,9 +926,10 @@ cy_sched_event(struct cyclades_port *info, int event)
926 * had to poll every port to see if that port needed servicing. 926 * had to poll every port to see if that port needed servicing.
927 */ 927 */
928static void 928static void
929do_softint(void *private_) 929do_softint(struct work_struct *work)
930{ 930{
931 struct cyclades_port *info = (struct cyclades_port *) private_; 931 struct cyclades_port *info =
932 container_of(work, struct cyclades_port, tqueue);
932 struct tty_struct *tty; 933 struct tty_struct *tty;
933 934
934 tty = info->tty; 935 tty = info->tty;
@@ -5328,7 +5329,7 @@ cy_init(void)
5328 info->blocked_open = 0; 5329 info->blocked_open = 0;
5329 info->default_threshold = 0; 5330 info->default_threshold = 0;
5330 info->default_timeout = 0; 5331 info->default_timeout = 0;
5331 INIT_WORK(&info->tqueue, do_softint, info); 5332 INIT_WORK(&info->tqueue, do_softint);
5332 init_waitqueue_head(&info->open_wait); 5333 init_waitqueue_head(&info->open_wait);
5333 init_waitqueue_head(&info->close_wait); 5334 init_waitqueue_head(&info->close_wait);
5334 init_waitqueue_head(&info->shutdown_wait); 5335 init_waitqueue_head(&info->shutdown_wait);
@@ -5403,7 +5404,7 @@ cy_init(void)
5403 info->blocked_open = 0; 5404 info->blocked_open = 0;
5404 info->default_threshold = 0; 5405 info->default_threshold = 0;
5405 info->default_timeout = 0; 5406 info->default_timeout = 0;
5406 INIT_WORK(&info->tqueue, do_softint, info); 5407 INIT_WORK(&info->tqueue, do_softint);
5407 init_waitqueue_head(&info->open_wait); 5408 init_waitqueue_head(&info->open_wait);
5408 init_waitqueue_head(&info->close_wait); 5409 init_waitqueue_head(&info->close_wait);
5409 init_waitqueue_head(&info->shutdown_wait); 5410 init_waitqueue_head(&info->shutdown_wait);
diff --git a/drivers/char/decserial.c b/drivers/char/decserial.c
index 85f404e25c73..8ea2bea2b183 100644
--- a/drivers/char/decserial.c
+++ b/drivers/char/decserial.c
@@ -23,20 +23,12 @@
23extern int zs_init(void); 23extern int zs_init(void);
24#endif 24#endif
25 25
26#ifdef CONFIG_DZ
27extern int dz_init(void);
28#endif
29
30#ifdef CONFIG_SERIAL_CONSOLE 26#ifdef CONFIG_SERIAL_CONSOLE
31 27
32#ifdef CONFIG_ZS 28#ifdef CONFIG_ZS
33extern void zs_serial_console_init(void); 29extern void zs_serial_console_init(void);
34#endif 30#endif
35 31
36#ifdef CONFIG_DZ
37extern void dz_serial_console_init(void);
38#endif
39
40#endif 32#endif
41 33
42/* rs_init - starts up the serial interface - 34/* rs_init - starts up the serial interface -
@@ -46,23 +38,11 @@ extern void dz_serial_console_init(void);
46 38
47int __init rs_init(void) 39int __init rs_init(void)
48{ 40{
49 41#ifdef CONFIG_ZS
50#if defined(CONFIG_ZS) && defined(CONFIG_DZ)
51 if (IOASIC) 42 if (IOASIC)
52 return zs_init(); 43 return zs_init();
53 else
54 return dz_init();
55#else
56
57#ifdef CONFIG_ZS
58 return zs_init();
59#endif
60
61#ifdef CONFIG_DZ
62 return dz_init();
63#endif
64
65#endif 44#endif
45 return -ENXIO;
66} 46}
67 47
68__initcall(rs_init); 48__initcall(rs_init);
@@ -76,21 +56,9 @@ __initcall(rs_init);
76 */ 56 */
77static int __init decserial_console_init(void) 57static int __init decserial_console_init(void)
78{ 58{
79#if defined(CONFIG_ZS) && defined(CONFIG_DZ) 59#ifdef CONFIG_ZS
80 if (IOASIC) 60 if (IOASIC)
81 zs_serial_console_init(); 61 zs_serial_console_init();
82 else
83 dz_serial_console_init();
84#else
85
86#ifdef CONFIG_ZS
87 zs_serial_console_init();
88#endif
89
90#ifdef CONFIG_DZ
91 dz_serial_console_init();
92#endif
93
94#endif 62#endif
95 return 0; 63 return 0;
96} 64}
diff --git a/drivers/char/drm/drm_sman.c b/drivers/char/drm/drm_sman.c
index 425c82336ee0..19c81d2e13d0 100644
--- a/drivers/char/drm/drm_sman.c
+++ b/drivers/char/drm/drm_sman.c
@@ -162,6 +162,7 @@ drm_sman_set_manager(drm_sman_t * sman, unsigned int manager,
162 162
163 return 0; 163 return 0;
164} 164}
165EXPORT_SYMBOL(drm_sman_set_manager);
165 166
166static drm_owner_item_t *drm_sman_get_owner_item(drm_sman_t * sman, 167static drm_owner_item_t *drm_sman_get_owner_item(drm_sman_t * sman,
167 unsigned long owner) 168 unsigned long owner)
diff --git a/drivers/char/drm/drm_vm.c b/drivers/char/drm/drm_vm.c
index b40ae438f531..ae2691942ddb 100644
--- a/drivers/char/drm/drm_vm.c
+++ b/drivers/char/drm/drm_vm.c
@@ -147,14 +147,14 @@ static __inline__ struct page *drm_do_vm_shm_nopage(struct vm_area_struct *vma,
147 if (address > vma->vm_end) 147 if (address > vma->vm_end)
148 return NOPAGE_SIGBUS; /* Disallow mremap */ 148 return NOPAGE_SIGBUS; /* Disallow mremap */
149 if (!map) 149 if (!map)
150 return NOPAGE_OOM; /* Nothing allocated */ 150 return NOPAGE_SIGBUS; /* Nothing allocated */
151 151
152 offset = address - vma->vm_start; 152 offset = address - vma->vm_start;
153 i = (unsigned long)map->handle + offset; 153 i = (unsigned long)map->handle + offset;
154 page = (map->type == _DRM_CONSISTENT) ? 154 page = (map->type == _DRM_CONSISTENT) ?
155 virt_to_page((void *)i) : vmalloc_to_page((void *)i); 155 virt_to_page((void *)i) : vmalloc_to_page((void *)i);
156 if (!page) 156 if (!page)
157 return NOPAGE_OOM; 157 return NOPAGE_SIGBUS;
158 get_page(page); 158 get_page(page);
159 159
160 DRM_DEBUG("shm_nopage 0x%lx\n", address); 160 DRM_DEBUG("shm_nopage 0x%lx\n", address);
@@ -272,7 +272,7 @@ static __inline__ struct page *drm_do_vm_dma_nopage(struct vm_area_struct *vma,
272 if (address > vma->vm_end) 272 if (address > vma->vm_end)
273 return NOPAGE_SIGBUS; /* Disallow mremap */ 273 return NOPAGE_SIGBUS; /* Disallow mremap */
274 if (!dma->pagelist) 274 if (!dma->pagelist)
275 return NOPAGE_OOM; /* Nothing allocated */ 275 return NOPAGE_SIGBUS; /* Nothing allocated */
276 276
277 offset = address - vma->vm_start; /* vm_[pg]off[set] should be 0 */ 277 offset = address - vma->vm_start; /* vm_[pg]off[set] should be 0 */
278 page_nr = offset >> PAGE_SHIFT; 278 page_nr = offset >> PAGE_SHIFT;
@@ -310,7 +310,7 @@ static __inline__ struct page *drm_do_vm_sg_nopage(struct vm_area_struct *vma,
310 if (address > vma->vm_end) 310 if (address > vma->vm_end)
311 return NOPAGE_SIGBUS; /* Disallow mremap */ 311 return NOPAGE_SIGBUS; /* Disallow mremap */
312 if (!entry->pagelist) 312 if (!entry->pagelist)
313 return NOPAGE_OOM; /* Nothing allocated */ 313 return NOPAGE_SIGBUS; /* Nothing allocated */
314 314
315 offset = address - vma->vm_start; 315 offset = address - vma->vm_start;
316 map_offset = map->offset - (unsigned long)dev->sg->virtual; 316 map_offset = map->offset - (unsigned long)dev->sg->virtual;
diff --git a/drivers/char/drm/via_dmablit.c b/drivers/char/drm/via_dmablit.c
index 60c1695db300..806f9ce5f47b 100644
--- a/drivers/char/drm/via_dmablit.c
+++ b/drivers/char/drm/via_dmablit.c
@@ -500,9 +500,9 @@ via_dmablit_timer(unsigned long data)
500 500
501 501
502static void 502static void
503via_dmablit_workqueue(void *data) 503via_dmablit_workqueue(struct work_struct *work)
504{ 504{
505 drm_via_blitq_t *blitq = (drm_via_blitq_t *) data; 505 drm_via_blitq_t *blitq = container_of(work, drm_via_blitq_t, wq);
506 drm_device_t *dev = blitq->dev; 506 drm_device_t *dev = blitq->dev;
507 unsigned long irqsave; 507 unsigned long irqsave;
508 drm_via_sg_info_t *cur_sg; 508 drm_via_sg_info_t *cur_sg;
@@ -571,7 +571,7 @@ via_init_dmablit(drm_device_t *dev)
571 DRM_INIT_WAITQUEUE(blitq->blit_queue + j); 571 DRM_INIT_WAITQUEUE(blitq->blit_queue + j);
572 } 572 }
573 DRM_INIT_WAITQUEUE(&blitq->busy_queue); 573 DRM_INIT_WAITQUEUE(&blitq->busy_queue);
574 INIT_WORK(&blitq->wq, via_dmablit_workqueue, blitq); 574 INIT_WORK(&blitq->wq, via_dmablit_workqueue);
575 init_timer(&blitq->poll_timer); 575 init_timer(&blitq->poll_timer);
576 blitq->poll_timer.function = &via_dmablit_timer; 576 blitq->poll_timer.function = &via_dmablit_timer;
577 blitq->poll_timer.data = (unsigned long) blitq; 577 blitq->poll_timer.data = (unsigned long) blitq;
diff --git a/drivers/char/epca.c b/drivers/char/epca.c
index 706733c0b36a..7c71eb779802 100644
--- a/drivers/char/epca.c
+++ b/drivers/char/epca.c
@@ -200,7 +200,7 @@ static int pc_ioctl(struct tty_struct *, struct file *,
200static int info_ioctl(struct tty_struct *, struct file *, 200static int info_ioctl(struct tty_struct *, struct file *,
201 unsigned int, unsigned long); 201 unsigned int, unsigned long);
202static void pc_set_termios(struct tty_struct *, struct termios *); 202static void pc_set_termios(struct tty_struct *, struct termios *);
203static void do_softint(void *); 203static void do_softint(struct work_struct *work);
204static void pc_stop(struct tty_struct *); 204static void pc_stop(struct tty_struct *);
205static void pc_start(struct tty_struct *); 205static void pc_start(struct tty_struct *);
206static void pc_throttle(struct tty_struct * tty); 206static void pc_throttle(struct tty_struct * tty);
@@ -1505,7 +1505,7 @@ static void post_fep_init(unsigned int crd)
1505 1505
1506 ch->brdchan = bc; 1506 ch->brdchan = bc;
1507 ch->mailbox = gd; 1507 ch->mailbox = gd;
1508 INIT_WORK(&ch->tqueue, do_softint, ch); 1508 INIT_WORK(&ch->tqueue, do_softint);
1509 ch->board = &boards[crd]; 1509 ch->board = &boards[crd];
1510 1510
1511 spin_lock_irqsave(&epca_lock, flags); 1511 spin_lock_irqsave(&epca_lock, flags);
@@ -2566,9 +2566,9 @@ static void pc_set_termios(struct tty_struct *tty, struct termios *old_termios)
2566 2566
2567/* --------------------- Begin do_softint ----------------------- */ 2567/* --------------------- Begin do_softint ----------------------- */
2568 2568
2569static void do_softint(void *private_) 2569static void do_softint(struct work_struct *work)
2570{ /* Begin do_softint */ 2570{ /* Begin do_softint */
2571 struct channel *ch = (struct channel *) private_; 2571 struct channel *ch = container_of(work, struct channel, tqueue);
2572 /* Called in response to a modem change event */ 2572 /* Called in response to a modem change event */
2573 if (ch && ch->magic == EPCA_MAGIC) { /* Begin EPCA_MAGIC */ 2573 if (ch && ch->magic == EPCA_MAGIC) { /* Begin EPCA_MAGIC */
2574 struct tty_struct *tty = ch->tty; 2574 struct tty_struct *tty = ch->tty;
diff --git a/drivers/char/esp.c b/drivers/char/esp.c
index 15a4ea896328..93b551962513 100644
--- a/drivers/char/esp.c
+++ b/drivers/char/esp.c
@@ -723,9 +723,10 @@ static irqreturn_t rs_interrupt_single(int irq, void *dev_id)
723 * ------------------------------------------------------------------- 723 * -------------------------------------------------------------------
724 */ 724 */
725 725
726static void do_softint(void *private_) 726static void do_softint(struct work_struct *work)
727{ 727{
728 struct esp_struct *info = (struct esp_struct *) private_; 728 struct esp_struct *info =
729 container_of(work, struct esp_struct, tqueue);
729 struct tty_struct *tty; 730 struct tty_struct *tty;
730 731
731 tty = info->tty; 732 tty = info->tty;
@@ -746,9 +747,10 @@ static void do_softint(void *private_)
746 * do_serial_hangup() -> tty->hangup() -> esp_hangup() 747 * do_serial_hangup() -> tty->hangup() -> esp_hangup()
747 * 748 *
748 */ 749 */
749static void do_serial_hangup(void *private_) 750static void do_serial_hangup(struct work_struct *work)
750{ 751{
751 struct esp_struct *info = (struct esp_struct *) private_; 752 struct esp_struct *info =
753 container_of(work, struct esp_struct, tqueue_hangup);
752 struct tty_struct *tty; 754 struct tty_struct *tty;
753 755
754 tty = info->tty; 756 tty = info->tty;
@@ -2501,8 +2503,8 @@ static int __init espserial_init(void)
2501 info->magic = ESP_MAGIC; 2503 info->magic = ESP_MAGIC;
2502 info->close_delay = 5*HZ/10; 2504 info->close_delay = 5*HZ/10;
2503 info->closing_wait = 30*HZ; 2505 info->closing_wait = 30*HZ;
2504 INIT_WORK(&info->tqueue, do_softint, info); 2506 INIT_WORK(&info->tqueue, do_softint);
2505 INIT_WORK(&info->tqueue_hangup, do_serial_hangup, info); 2507 INIT_WORK(&info->tqueue_hangup, do_serial_hangup);
2506 info->config.rx_timeout = rx_timeout; 2508 info->config.rx_timeout = rx_timeout;
2507 info->config.flow_on = flow_on; 2509 info->config.flow_on = flow_on;
2508 info->config.flow_off = flow_off; 2510 info->config.flow_off = flow_off;
diff --git a/drivers/char/ftape/Kconfig b/drivers/char/ftape/Kconfig
deleted file mode 100644
index 0d65189a7ae8..000000000000
--- a/drivers/char/ftape/Kconfig
+++ /dev/null
@@ -1,330 +0,0 @@
1#
2# Ftape configuration
3#
4config ZFTAPE
5 tristate "Zftape, the VFS interface"
6 depends on FTAPE
7 ---help---
8 Normally, you want to say Y or M. DON'T say N here or you
9 WON'T BE ABLE TO USE YOUR FLOPPY TAPE DRIVE.
10
11 The ftape module itself no longer contains the routines necessary
12 to interface with the kernel VFS layer (i.e. to actually write data
13 to and read data from the tape drive). Instead the file system
14 interface (i.e. the hardware independent part of the driver) has
15 been moved to a separate module.
16
17 To compile this driver as a module, choose M here: the
18 module will be called zftape.
19
20 Regardless of whether you say Y or M here, an additional runtime
21 loadable module called `zft-compressor' which contains code to
22 support user transparent on-the-fly compression based on Ross
23 William's lzrw3 algorithm will be produced. If you have enabled the
24 kernel module loader (i.e. have said Y to "Kernel module loader
25 support", above) then `zft-compressor' will be loaded
26 automatically by zftape when needed.
27
28 Despite its name, zftape does NOT use compression by default.
29
30config ZFT_DFLT_BLK_SZ
31 int "Default block size"
32 depends on ZFTAPE
33 default "10240"
34 ---help---
35 If unsure leave this at its default value, i.e. 10240. Note that
36 you specify only the default block size here. The block size can be
37 changed at run time using the MTSETBLK tape operation with the
38 MTIOCTOP ioctl (i.e. with "mt -f /dev/qft0 setblk #BLKSZ" from the
39 shell command line).
40
41 The probably most striking difference between zftape and previous
42 versions of ftape is the fact that all data must be written or read
43 in multiples of a fixed block size. The block size defaults to
44 10240 which is what GNU tar uses. The values for the block size
45 should be either 1 or multiples of 1024 up to a maximum value of
46 63488 (i.e. 62 K). If you specify `1' then zftape's builtin
47 compression will be disabled.
48
49 Reasonable values are `10240' (GNU tar's default block size),
50 `5120' (afio's default block size), `32768' (default block size some
51 backup programs assume for SCSI tape drives) or `1' (no restriction
52 on block size, but disables builtin compression).
53
54comment "The compressor will be built as a module only!"
55 depends on FTAPE && ZFTAPE
56
57config ZFT_COMPRESSOR
58 tristate
59 depends on FTAPE!=n && ZFTAPE!=n
60 default m
61
62config FT_NR_BUFFERS
63 int "Number of ftape buffers (EXPERIMENTAL)"
64 depends on FTAPE && EXPERIMENTAL
65 default "3"
66 help
67 Please leave this at `3' unless you REALLY know what you are doing.
68 It is not necessary to change this value. Values below 3 make the
69 proper use of ftape impossible, values greater than 3 are a waste of
70 memory. You can change the amount of DMA memory used by ftape at
71 runtime with "mt -f /dev/qft0 setdrvbuffer #NUMBUFFERS". Each buffer
72 wastes 32 KB of memory. Please note that this memory cannot be
73 swapped out.
74
75config FT_PROC_FS
76 bool "Enable procfs status report (+2kb)"
77 depends on FTAPE && PROC_FS
78 ---help---
79 Optional. Saying Y will result in creation of a directory
80 `/proc/ftape' under the /proc file system. The files can be viewed
81 with your favorite pager (i.e. use "more /proc/ftape/history" or
82 "less /proc/ftape/history" or simply "cat /proc/ftape/history"). The
83 file will contain some status information about the inserted
84 cartridge, the kernel driver, your tape drive, the floppy disk
85 controller and the error history for the most recent use of the
86 kernel driver. Saying Y will enlarge the size of the ftape driver
87 by approximately 2 KB.
88
89 WARNING: When compiling ftape as a module (i.e. saying M to "Floppy
90 tape drive") it is dangerous to use ftape's /proc file system
91 interface. Accessing `/proc/ftape' while the module is unloaded will
92 result in a kernel Oops. This cannot be fixed from inside ftape.
93
94choice
95 prompt "Debugging output"
96 depends on FTAPE
97 default FT_NORMAL_DEBUG
98
99config FT_NORMAL_DEBUG
100 bool "Normal"
101 ---help---
102 This option controls the amount of debugging output the ftape driver
103 is ABLE to produce; it does not increase or diminish the debugging
104 level itself. If unsure, leave this at its default setting,
105 i.e. choose "Normal".
106
107 Ftape can print lots of debugging messages to the system console
108 resp. kernel log files. Reducing the amount of possible debugging
109 output reduces the size of the kernel module by some KB, so it might
110 be a good idea to use "None" for emergency boot floppies.
111
112 If you want to save memory then the following strategy is
113 recommended: leave this option at its default setting "Normal" until
114 you know that the driver works as expected, afterwards reconfigure
115 the kernel, this time specifying "Reduced" or "None" and recompile
116 and install the kernel as usual. Note that choosing "Excessive"
117 debugging output does not increase the amount of debugging output
118 printed to the console but only makes it possible to produce
119 "Excessive" debugging output.
120
121 Please read <file:Documentation/ftape.txt> for a short description
122 how to control the amount of debugging output.
123
124config FT_FULL_DEBUG
125 bool "Excessive"
126 help
127 Extremely verbose output for driver debugging purposes.
128
129config FT_NO_TRACE
130 bool "Reduced"
131 help
132 Reduced tape driver debugging output.
133
134config FT_NO_TRACE_AT_ALL
135 bool "None"
136 help
137 Suppress all debugging output from the tape drive.
138
139endchoice
140
141comment "Hardware configuration"
142 depends on FTAPE
143
144choice
145 prompt "Floppy tape controllers"
146 depends on FTAPE
147 default FT_STD_FDC
148
149config FT_STD_FDC
150 bool "Standard"
151 ---help---
152 Only change this setting if you have a special controller. If you
153 didn't plug any add-on card into your computer system but just
154 plugged the floppy tape cable into the already existing floppy drive
155 controller then you don't want to change the default setting,
156 i.e. choose "Standard".
157
158 Choose "MACH-2" if you have a Mountain Mach-2 controller.
159 Choose "FC-10/FC-20" if you have a Colorado FC-10 or FC-20
160 controller.
161 Choose "Alt/82078" if you have another controller that is located at
162 an IO base address different from the standard floppy drive
163 controller's base address of `0x3f0', or uses an IRQ (interrupt)
164 channel different from `6', or a DMA channel different from
165 `2'. This is necessary for any controller card that is based on
166 Intel's 82078 FDC such as Seagate's, Exabyte's and Iomega's "high
167 speed" controllers.
168
169 If you choose something other than "Standard" then please make
170 sure that the settings for the IO base address and the IRQ and DMA
171 channel in the configuration menus below are correct. Use the manual
172 of your tape drive to determine the correct settings!
173
174 If you are already successfully using your tape drive with another
175 operating system then you definitely should use the same settings
176 for the IO base, the IRQ and DMA channel that have proven to work
177 with that other OS.
178
179 Note that this menu lets you specify only the default setting for
180 the hardware setup. The hardware configuration can be changed at
181 boot time (when ftape is compiled into the kernel, i.e. if you
182 have said Y to "Floppy tape drive") or module load time (i.e. if you
183 have said M to "Floppy tape drive").
184
185 Please read also the file <file:Documentation/ftape.txt> which
186 contains a short description of the parameters that can be set at
187 boot or load time. If you want to use your floppy tape drive on a
188 PCI-bus based system, please read the file
189 <file:drivers/char/ftape/README.PCI>.
190
191config FT_MACH2
192 bool "MACH-2"
193
194config FT_PROBE_FC10
195 bool "FC-10/FC-20"
196
197config FT_ALT_FDC
198 bool "Alt/82078"
199
200endchoice
201
202comment "Consult the manuals of your tape drive for the correct settings!"
203 depends on FTAPE && !FT_STD_FDC
204
205config FT_FDC_BASE
206 hex "IO base of the floppy disk controller"
207 depends on FTAPE && !FT_STD_FDC
208 default "0"
209 ---help---
210 You don't need to specify a value if the following default
211 settings for the base IO address are correct:
212 <<< MACH-2 : 0x1E0 >>>
213 <<< FC-10/FC-20: 0x180 >>>
214 <<< Secondary : 0x370 >>>
215 Secondary refers to a secondary FDC controller like the "high speed"
216 controllers delivered by Seagate or Exabyte or Iomega's Ditto Dash.
217 Please make sure that the setting for the IO base address
218 specified here is correct. USE THE MANUAL OF YOUR TAPE DRIVE OR
219 CONTROLLER CARD TO DETERMINE THE CORRECT SETTING. If you are already
220 successfully using the tape drive with another operating system then
221 you definitely should use the same settings for the IO base that has
222 proven to work with that other OS.
223
224 Note that this menu lets you specify only the default setting for
225 the IO base. The hardware configuration can be changed at boot time
226 (when ftape is compiled into the kernel, i.e. if you specified Y to
227 "Floppy tape drive") or module load time (i.e. if you have said M to
228 "Floppy tape drive").
229
230 Please read also the file <file:Documentation/ftape.txt> which
231 contains a short description of the parameters that can be set at
232 boot or load time.
233
234config FT_FDC_IRQ
235 int "IRQ channel of the floppy disk controller"
236 depends on FTAPE && !FT_STD_FDC
237 default "0"
238 ---help---
239 You don't need to specify a value if the following default
240 settings for the interrupt channel are correct:
241 <<< MACH-2 : 6 >>>
242 <<< FC-10/FC-20: 9 >>>
243 <<< Secondary : 6 >>>
244 Secondary refers to secondary a FDC controller like the "high speed"
245 controllers delivered by Seagate or Exabyte or Iomega's Ditto Dash.
246 Please make sure that the setting for the IO base address
247 specified here is correct. USE THE MANUAL OF YOUR TAPE DRIVE OR
248 CONTROLLER CARD TO DETERMINE THE CORRECT SETTING. If you are already
249 successfully using the tape drive with another operating system then
250 you definitely should use the same settings for the IO base that has
251 proven to work with that other OS.
252
253 Note that this menu lets you specify only the default setting for
254 the IRQ channel. The hardware configuration can be changed at boot
255 time (when ftape is compiled into the kernel, i.e. if you said Y to
256 "Floppy tape drive") or module load time (i.e. if you said M to
257 "Floppy tape drive").
258
259 Please read also the file <file:Documentation/ftape.txt> which
260 contains a short description of the parameters that can be set at
261 boot or load time.
262
263config FT_FDC_DMA
264 int "DMA channel of the floppy disk controller"
265 depends on FTAPE && !FT_STD_FDC
266 default "0"
267 ---help---
268 You don't need to specify a value if the following default
269 settings for the DMA channel are correct:
270 <<< MACH-2 : 2 >>>
271 <<< FC-10/FC-20: 3 >>>
272 <<< Secondary : 2 >>>
273 Secondary refers to a secondary FDC controller like the "high speed"
274 controllers delivered by Seagate or Exabyte or Iomega's Ditto Dash.
275 Please make sure that the setting for the IO base address
276 specified here is correct. USE THE MANUAL OF YOUR TAPE DRIVE OR
277 CONTROLLER CARD TO DETERMINE THE CORRECT SETTING. If you are already
278 successfully using the tape drive with another operating system then
279 you definitely should use the same settings for the IO base that has
280 proven to work with that other OS.
281
282 Note that this menu lets you specify only the default setting for
283 the DMA channel. The hardware configuration can be changed at boot
284 time (when ftape is compiled into the kernel, i.e. if you said Y to
285 "Floppy tape drive") or module load time (i.e. if you said M to
286 "Floppy tape drive").
287
288 Please read also the file <file:Documentation/ftape.txt> which
289 contains a short description of the parameters that can be set at
290 boot or load time.
291
292config FT_FDC_THR
293 int "Default FIFO threshold (EXPERIMENTAL)"
294 depends on FTAPE && EXPERIMENTAL
295 default "8"
296 help
297 Set the FIFO threshold of the FDC. If this is higher the DMA
298 controller may serve the FDC after a higher latency time. If this is
299 lower, fewer DMA transfers occur leading to less bus contention.
300 You may try to tune this if ftape annoys you with "reduced data
301 rate because of excessive overrun errors" messages. However, this
302 doesn't seem to have too much effect.
303
304 If unsure, don't touch the initial value, i.e. leave it at "8".
305
306config FT_FDC_MAX_RATE
307 int "Maximal data rate to use (EXPERIMENTAL)"
308 depends on FTAPE && EXPERIMENTAL
309 default "2000"
310 ---help---
311 With some motherboard/FDC combinations ftape will not be able to
312 run your FDC/tape drive combination at the highest available
313 speed. If this is the case you'll encounter "reduced data rate
314 because of excessive overrun errors" messages and lots of retries
315 before ftape finally decides to reduce the data rate.
316
317 In this case it might be desirable to tell ftape beforehand that
318 it need not try to run the tape drive at the highest available
319 speed. If unsure, leave this disabled, i.e. leave it at 2000
320 bits/sec.
321
322config FT_ALPHA_CLOCK
323 int "CPU clock frequency of your DEC Alpha" if ALPHA
324 depends on FTAPE
325 default "0"
326 help
327 On some DEC Alpha machines the CPU clock frequency cannot be
328 determined automatically, so you need to specify it here ONLY if
329 running a DEC Alpha, otherwise this setting has no effect.
330
diff --git a/drivers/char/ftape/Makefile b/drivers/char/ftape/Makefile
deleted file mode 100644
index 0e67d2f8b7ec..000000000000
--- a/drivers/char/ftape/Makefile
+++ /dev/null
@@ -1,28 +0,0 @@
1#
2# Copyright (C) 1997 Claus Heine.
3#
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 2, or (at your option)
7# any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program; see the file COPYING. If not, write to
16# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17#
18# $Source: /homes/cvs/ftape-stacked/ftape/Makefile,v $
19# $Revision: 1.4 $
20# $Date: 1997/10/05 19:17:56 $
21#
22# Makefile for the QIC-40/80/3010/3020 floppy-tape driver for
23# Linux.
24#
25
26obj-$(CONFIG_FTAPE) += lowlevel/
27obj-$(CONFIG_ZFTAPE) += zftape/
28obj-$(CONFIG_ZFT_COMPRESSOR) += compressor/
diff --git a/drivers/char/ftape/README.PCI b/drivers/char/ftape/README.PCI
deleted file mode 100644
index 18de159d36e0..000000000000
--- a/drivers/char/ftape/README.PCI
+++ /dev/null
@@ -1,81 +0,0 @@
1Some notes for ftape users with PCI motherboards:
2=================================================
3
4The problem:
5------------
6
7There have been some problem reports from people using PCI-bus based
8systems getting overrun errors.
9I wasn't able to reproduce these until I ran ftape on a Intel Plato
10(Premiere PCI II) motherboard with bios version 1.00.08AX1.
11It turned out that if GAT (Guaranteed Access Timing) is enabled (?)
12ftape gets a lot of overrun errors.
13The problem disappears when disabling GAT in the bios.
14Note that Intel removed this setting (permanently disabled) from the
151.00.10AX1 bios !
16
17It looks like that if GAT is enabled there are often large periods
18(greater than 120 us !??) on the ISA bus that the DMA controller cannot
19service the floppy disk controller.
20I cannot imagine this being acceptable in a decent PCI implementation.
21Maybe this is a `feature' of the chipset. I can only speculate why
22Intel choose to remove the option from the latest Bios...
23
24The lesson of this all is that there may be other motherboard
25implementations having the same of similar problems.
26If you experience a lot of overrun errors during a backup to tape,
27see if there is some setting in the Bios that may influence the
28bus timing.
29
30I judge this a hardware problem and not a limitation of ftape ;-)
31My DOS backup software seems to be suffering from the same problems
32and even refuses to run at 1 Mbps !
33Ftape will reduce the data-rate from 1 Mbps to 500 Kbps if the number
34of overrun errors on a track exceeds a threshold.
35
36
37Possible solutions:
38-------------------
39
40Some of the problems were solved by upgrading the (flash) bios.
41Other suggest that it has to do with the FDC being on the PCI
42bus, but that is not the case with the Intel Premiere II boards.
43[If upgrading the bios doesn't solve the problem you could try
44a floppy disk controller on the isa-bus].
45
46Here is a list of systems and recommended BIOS settings:
47
48
49 Intel Premiere PCI (Revenge):
50
51Bios version 1.00.09.AF2 is reported to work.
52
53
54
55 Intel Premiere PCI II (Plato):
56
57Bios version 1.00.10.AX1 and version 11 beta are ok.
58If using version 1.00.08.AX1, GAT must be disabled !
59
60
61
62 ASUS PCI/I-SP3G:
63
64Preferred settings: ISA-GAT-mode : disabled
65 DMA-linebuffer-mode : standard
66 ISA-masterbuffer-mode : standard
67
68
69 DELL Dimension XPS P90
70
71Bios version A2 is reported to be broken, while bios version A5 works.
72You can get a flash bios upgrade from http://www.dell.com
73
74
75To see if you're having the GAT problem, try making a backup
76under DOS. If it's very slow and often repositions you're
77probably having this problem.
78
79 --//--
80 LocalWords: ftape PCI bios GAT ISA DMA chipset Mbps Kbps FDC isa AF ok ASUS
81 LocalWords: SP linebuffer masterbuffer XPS http www com
diff --git a/drivers/char/ftape/RELEASE-NOTES b/drivers/char/ftape/RELEASE-NOTES
deleted file mode 100644
index 03799dbc05a4..000000000000
--- a/drivers/char/ftape/RELEASE-NOTES
+++ /dev/null
@@ -1,966 +0,0 @@
1Hey, Emacs, we're -*-Text-*- mode!
2
3===== Release notes for ftape-3.04d 25/11/97 =====
4- The correct pre-processor statement for "else if" is "#elif" not
5 "elsif".
6- Need to call zft_reset_position() when overwriting cartridges
7 previously written with ftape-2.x, sftape, or ancient
8 (pre-ftape-3.x) versions of zftape.
9
10===== Release notes for ftape-3.04c 16/11/97 =====
11- fdc_probe() was calling DUMPREGS with a result length of "1" which
12 was just fine. Undo previous change.
13
14===== Release notes for ftape-3.04b 14/11/97 =====
15
16- patches/2.x.x/floppy.c.diff was somewhat broken, releasing i/o
17 regions it never had allocated.
18- fdc_probe() was calling DUMPREGS with a result length of "1" instead
19 of "10"
20- Writing deleted data marks if the first segents on track zero are
21 should work now.
22- ftformat should now be able to handle those cases where the tape
23 drive sets the read only status bit (QIC-40/80 cartridges with
24 QIC-3010/3020 tape drives) because the header segment is damaged.
25- the MTIOCFTCMD ioctl may now be issued by the superuser ONLY.
26
27===== Release notes for ftape-3.04a 12/11/97 =====
28- Fix an "infinite loop can't be killed by signal" bug in
29 ftape_get_drive_status(). Only relevant when trying to access
30 buggy/misconfigured hardware
31- Try to compensate a bug in the HP Colorado T3000's firmware: it
32 doesn't set the write protect bit for QIC80/QIC40 cartridges.
33
34===== Release notes for ftape-3.04 06/11/97 =====
35- If positioning with fast seeking fails fall back to a slow seek
36 before giving up.
37- (nearly) no retries on "no data errors" when verifying after
38 formatting. Improved tuning of the bad sector map after formatting.
39- the directory layout has changed again to allow for easier kernel
40 integration
41- Module parameter "ftape_tracing" now is called "ft_tracing" because
42 the "ftape_tracing" variable has the version checksum attached to it.
43- `/proc/ftape' interface for 2.0.* kernels. `/proc/ftape' no longer
44 is a directory but a file that contains all the information formerly
45 provided in separate files under the `/proc/ftape/' directory.
46- Most of the configuration options have been prefixed by "CONFIG_FT_"
47 in preparation of the kernel inclusion. The Makefiles under
48 "./ftape/" should be directly usable by the kernel.
49- The MODVERSIONS stuff is now auto-detected.
50- Broke backslashed multi line options in MCONFIG into separate lines
51 using GNU-make's "+=" feature.
52- The html and dvi version of the manual is now installed under
53 '/usr/doc/ftape` with 'make install`
54- New SMP define in MCONFIG. ftape works with SMP if this is defined.
55- attempt to cope with "excessive overrun errors" by gradually
56 increasing FDC FIFO threshold. But this doesn't seem to have too
57 much an effect.
58- New load time configuration parameter "ft_fdc_rate_limit". If you
59 encounter too many overrun errors with a 2Mb controller then you
60 might want to set this to 1000.
61- overrun errors on the last sector in a segment sometimes result in
62 a zero DMA residue. Dunno why, but compensate for it.
63- there were still fdc_read() timeout errors. I think I have fixed it
64 now, please FIXME.
65- Sometimes ftape_write() failed to re-start the tape drive when a
66 segment without a good sector was reached ("wait for empty segment
67 failed"). This is fixed. Especially important for > QIC-3010.
68- sftape (aka ftape-2.x) has vanished. I didn't work on it for
69 ages. It is probably still possible to use the old code with
70 ftape-3.04, if one really needs it (BUT RECOMPILE IT)
71- zftape no longer alters the contents of already existing volume
72 table entries, which makes it possible to fill in missing fields,
73 like time stamps using some user space program.
74- ./contrib/vtblc/ contains such a program.
75- new perl script ./contrib/scripts/listtape that list the contents of a
76 floppy tape cartridge parsing the output of "mt volinfo" + "mt fsf"
77- the MTWEOF implementation has changed a little bit (after I had a
78 look at amanda). Calling MTWEOF while the tape is still held open
79 after writing something to the tape now will terminate the current
80 volume, and start a new one at the current position.
81- the volume table maintained by zftape now is a doubly linked list
82 that grows dynamically as needed.
83
84 formatting floppy tape cartridges
85 ---------------------------------
86 * there is a new user space formatting program that does most of the
87 dirty work in user space (auto-detect, computing the sector
88 coordinates, adjusting time stamps and statistics). It has a
89 simple command line interface.
90 * ftape-format.o has vanished, it has been folded into the low level
91 ftape.o module, and the ioctl interface into zftape.o. Most of the
92 complicated stuff has been moved to user space, so there was no
93 need for a separate module anymore.
94 * there is a new ioctl MTIOCFTCMD that sends a bare QIC-117 command
95 to the tape drive.
96 * there is a new mmap() feature to map the dma buffers into user
97 space to be used by the user level formatting program.
98 * Formatting of yet unformatted or totally degaussed cartridges
99 should be possible now. FIXME.
100
101===== Release notes for ftape-3.03b, <forgot the exact date> ====
102
103ftape-3.03b was released as a beta release only. Its main new feature
104was support of the DITTO-2GB drive. This was made possible by reverse
105engineering done by <fill in his name> after Iomega failed to support
106ftape. Although they had promised to do so (this makes me feel a bit
107sad and uncomfortable about Iomega).
108
109===== Release notes for ftape-3.03a, 22/05/97 ====
110
111- Finally fixed auto-un-loading of modules for kernels > 2.1.18
112- Add an "uninstall" target to the Makefile
113- removed the kdtime hack
114- texi2www didn't properly set the back-reference from a footnote back
115 to the regular text.
116
117 zftape specific
118 ---------------
119 * hide the old compression map volume. Taper doesn't accept the
120 presence of non-Taper volumes and Taper-written volume on the same
121 tape.
122 * EOD (End Of Data) handling was still broken: the expected behavior
123 is to return a zero byte count at the first attempt to read past
124 EOD, return a zero byte count at the second attempt to read past
125 EOD and THEN return -EIO.
126
127 ftape-format specific
128 ---------------------
129 * Detection of QIC-40 cartridges in select_tape_format() was broken
130 and made it impossible to format QIC-3010/3020 cartridges.
131 * There are strange "TR-1 Extra" cartridges out there which weren't
132 detected properly because the don't strictly conform to the
133 QIC-80, Rev. N, spec.
134
135===== Release notes for ftape-3.03, 30/04/97 =====
136
137- Removed kernel integration code from the package. I plan to provide
138 a package that can be integrated into the stock kernel separately
139 (hopefully soon).
140 As a result, a simple `make' command now will build everything.
141- ALL compile time configuration options have been moved to the file
142 `MCONFIG'.
143- Quite a few `low level' changes to allow formatting of cartridges.
144- formatting is implemented as a separate module `ftape-format.o'. The
145 modified `mt' program contains sample code that shows how to use it.
146- The VFS interface has been moved from the `ftape.o' module to the
147 high level modules `zftape.o' resp. `sftape.o'. `ftape.o' contains
148 the hardware support only.
149- A bit of /proc support for kernels > 2.1.28
150- Moved documentation to Doc subdir. INSTALL now contains some real
151 installation notes.
152- `install' target in Makefile.
153
154zftape specific:
155----------------
156
157- zftape works for large cartridges now ( > 2^31 bytes)
158- MTIOCVOLINFO and MTIOCGETSIZE now return the size in KILOBYTES,
159 NO LONGER in bytes.
160
161- permissions for write access to a cartridge have changed:
162 * zftape now also takes the file access mode into account
163 * zftape no longer allows writing in the middle of the recorded
164 media. The tape has to be positioned at BOT or EOD for write
165 access.
166
167- MTBSF has changed. It used to position at the beginning of the
168 previous file when called with count 1. This was different from the
169 expected behavior for other Un*x tape drivers (i.e. SCSI). MTBSF
170 with count 1 should merely position at the beginning of the current
171 volume. Fixed. As a result, `tar --verify' now produces the desired
172 result: it verifies the last written volume, not the pre-last
173 written volume.
174
175- The compression map has vanished --> no need for `mt erase' any
176 more. Fast seeking in a compressed volume is still be possible, but
177 takes slightly longer. As a side effect, you may experience an
178 additional volume showing up in front of all others for old
179 cartridges. This is the tape volume that holds the compression map.
180
181- The compression support for zftape has been moved to a separate
182 module `zft-compressor'. DON'T forget to load it before trying to
183 read back compressed volumes. The stock `zftape.o' module probes for
184 the module `zft-compressor' using the kerneld message channel; you
185 have to install `zft-compressor.o' in a place where modprobe can
186 find it if you want to use this.
187
188- New experimental feature that tries to get the broken down GMT time
189 from user space via a kernel daemon message channel. You need to
190 compile and start the `kdtime' daemon contained in the contrib
191 directory to use it. Needed (?) for time stamps in the header
192 segments and the volume table.
193
194- variable block size mode via MTSETBLK 0
195
196- keep modules locked in memory after the block size has been changed
197
198sftape specific:
199----------------
200
201- end of tape handling should be fixed, i.e. multi volume archives
202 written with `afio' can be read back now.
203
204
205===== Release notes for ftape-3.02a, 09/01/97 =====
206
207No big news:
208- call zft_init() resp. sft_init() when compiling the entire stuff
209 into the kernel image.
210- fix bug in ftape-setup.c when NO_TRACE_AT_ALL was defined.
211- fix bug in sftape-eof.c/zftape-eof.c for old kernels (1.2.*)
212- add support for new module interface for recent kernels
213
214===== Release notes for ftape-3.02, 16/12/96 =====
215- Fixed the `FDC unlock command failed' bug in fdc-io.c. When the FIFO
216 was already locked when ftape was loaded, ftape failed to unlock it.
217- Fixed compilation of `contrib/gnumt'. It now finds `mtio.h' even if
218 ftape is NOT included into the kernel source tree.
219- fc-10.c: include <asm/io.h> for inb() and outb().
220- ftape/sftape/zftape: all global variable now have either a `ftape_',
221 a `ft_', `sft_', `zft_' or `qic_' prefix to prevent name clashes
222 with other parts of the kernel when including ftape into the kernel
223 source tree.
224- Kerneld support has changed. `ftape' now searches for a module
225 `ftape-frontend' when none of the frontend (`sftape' or `zftape') is
226 loaded. Please refer to the `Installation/Loading ftape' section of
227 the TeXinfo manual.
228- Add load resp. boot-time configuration of ftape. There are now
229 variables ft_fdc_base, ft_fdc_dma and ft_fdc_irq corresponding to
230 the former FDC_BASE etc. compile time definitions. One can also use
231 the kernel command line parameters to configure the driver if it is
232 compiled into the kernel. Also, the FC-10/FC-20 support is load-time
233 configurable now as well as the MACH-II hack (ft_probe_fc10,
234 resp. ft_mach2). Please refer to the section `Installation/Configure
235 ftape' of the TeXinfo manual.
236- I removed the MODVERSIONS option from `Makefile.module'. Let me alone
237 with ftape and MODVERSIONS unless you include the ftape sources into
238 the kernel source tree.
239- new vendors in `vendors.h':
240 * HP Colorado T3000
241 * ComByte DoublePlay (including a bug fix for their broken
242 formatting software, thanks to whraven@njackn.com)
243 * Iomega DITTO 2GIG. NOTE: this drive cannot work with ftape because
244 the logical data layout of the cartridges used by this drive does
245 NOT conform to the QIC standards, it is a special Iomega specific
246 format. I've sent mail to Iomega but didn't receive an answer
247 yet. If you want this drive to be supported by ftape, ask Iomega
248 to give me information about it.
249- zftape:
250 * re-introduced the MTIOC_ZFTAPE_GETBLKSZ ioctl for compatibility
251 with zftape 1.06a and earlier. Please don't use it when writing
252 new software, use the MTIOCVOLINFO ioctl instead.
253 * Major overhaul of the code that updates the header segments. Never
254 change the tape label unless erasing the tape. Thus we almost
255 never need to write the header segments, unless we would modify
256 the bad sector map which isn't done yet. Updating of volume table
257 and compression map more secure now although it takes a bit
258 longer.
259 * Fixed bug when aborting a write operation with a signal: zftape
260 now finishes the current volume (i.e. writes an eof marker) at the
261 current position. It didn't before which led to somehow *strange*
262 behavior in this cases.
263 * Keep module locked in memory when using it with the non-rewinding
264 devices and the tape is not logical at BOT. Needed for kerneld
265 support.
266- sftape:
267 * Keep module locked in memory when using it with the non-rewinding
268 devices and the tape is not logical at BOT. Needed for kerneld
269 support.
270
271===== Release notes for ftape-3.01, 14/11/96 =====
272
273- Fixed silly bugs in ftape-3.00:
274 * MAKEDEV.ftape: major device number must be 27, not 23
275 * sftape/sftape-read.c: sftape_read_header_segments() called
276 itself recursively instead of calling ftape_read_header_segment()
277 * zftape/qic-vtbl.h: conversion of ftape's file marks to zftape's
278 internal volume table was broken.
279 * patches/2.x.x/linux-2.0.21.dif: my RCS (resp. CVS) system replaced
280 the `$Revison:' etc. macros in the `ftape.h' concerning part of the
281 patch :-( Fixed.
282 * info/ftape.info: Fixed misspellings (`cp' <-> `cp -r' etc.)
283 * when ftape/sftape or ftape/zftape was compiled into the kernel the
284 variable ftape_status was declared twice. Fixed.
285 * removed reference to undeclared variable kernel_version when not
286 compiling as module
287 * fixed a bug introduced by the use of bit-fields for some flags
288 (i.e. write_protected, no_cartridge, formatted)
289 * flag `header_read' is now reset correctly to zero when tape is
290 removed.
291- fixed a bug in sftape/sftape-eof.c that was already in the original
292 ftape code. MTFSF/BSF was not handled correctly when positioned
293 right before the file mark (think of tar)
294- Changed TRACE macros (following a suggestion of Marcin Dalecki) to use
295 the predefined __FUNCTION__ macro of GCC. Spares about 4k of code.
296- added new vendor id for Iomega DITTO 2GIG
297- fixed a bug already present in zftape-1.06 when aborting a write
298 with a signal: we now finish the current volume at that
299 position. Header segments remain NOT up to date until an explicit call
300 to MTREW or MTOFFL is done.
301
302===== Release notes for ftape-3.00, 14/10/96 =====
303
304- Merged ftape with zftape. There are three modules now:
305 ftape for the hardware support, sftape for the implementation of the
306 original ftape eof mark stuff and zftape that implements zftape's way
307 of handling things (compression, volume table, tape blocks of
308 constant length)
309- Documentation in TeXinfo format in the `info' subdirectory.
310- New ioctls for zftape. See zftape/zftape.h
311- Dummy formatting ioctl for ftape. See ftape.h
312- Kernel patch files for the 2.*.* series to include ftape-3.00 in the
313 kernel source tree. These includes a kernel compatible Config.in
314 script and fairly large online information for the kernel configure
315 script.
316- Support for compiling with Linux-1.2.13.
317- Modified GNU mt from their cpio package that can handle the new
318 ioctls.
319- ftape/sftape/zftape is kerneld save now!
320
321Notes on sftape:
322- sftape implements the eof handling code of the original ftape. If
323 you like to stick with the original ftape stuff, you have to use
324 this module, not zftape.
325- sftape is kerneld save, unlike the original ftape.
326- we keep the entire header segment now in memory, so no need to read
327 it before updating the header segments. Additional memory
328 consumption: 256 bytes.
329
330Notes for zftape:
331- zftape has support for tapes with format code 6 now, which use a
332 slightly different volume table format compared with other floppy
333 tapes.
334- new ioctls for zftape. Have a look at zftape/zftape.h
335- The internal volume table representation has changed for zftape. Old
336 cartridges are converted automatically.
337- zftape no longer uses compression map segments, which have vanished
338 from the QIC specs, but creates volume table entry that reserves
339 enough space for the compression map.
340- zftape is kerneld save now.
341- we keep the entire header segment now in memory, so no need to read
342 it before updating the header segments. Additional memory
343 consumption: 256 bytes.
344
345Notes for contrib/gnumt:
346- modified mt from the GNU cpio package that supports all the new
347 ioctls of zftape.
348Notes for contrib/swapout:
349- This contains the swapout.c program that was written by Kai
350 Harrekilde-Pederson. I simply added a Makefile.
351
352===== Release notes for ftape-2.10, 14/10/96 =====
353
354The ftape maintainer has changed.
355Kai Harrekilde-Petersen <khp@dolphinics.no>
356has resigned from maintaining ftape, and I,
357Claus-Justus Heine <claus@momo.math.rwth-aachen.de>,
358have taken over.
359
360- Added support for tapes with `format code 6', i.e. QIC-3020 tapes
361 with more than 2^16 segments.
362- merged changes made by Bas Laarhoven with ftape-2.09. Refer
363 to his release notes below. I've included them into this
364 file unchanged for your reference.
365- disabled call stack back trace for now. This new feature
366 introduced by the interim release 2.0.x still seems to
367 be buggy.
368- Tried to minimize differences between the ftape version
369 to be included into the kernel source tree and the standalone
370 module version.
371- Reintroduced support for Linux-1.2.13. Please refer to the
372 Install-guide.
373
374===== Release notes for ftape-2.09, 16/06/96 =====
375
376There aren't any really big news in this release, mostly just that I
377(the maintainer) have changed my email address (due to a new job). My
378new address is <khp@dolphinics.no>
379
380- The CLK_48MHZ and FDC_82078SL options has gone (all 2Mbps cards seem
381 to use a 48MHz oscillator anyway and I haven't heard of an 'SL
382 chip out there).
383- The S82078B has been `downgraded' to i82077AA compability.
384- TESTING option revived. Right now, it'll enable the (seriously broken)
385 2Mbps code. If you enable it, you'll experience a tape drive that's
386 *really* out to lunch!
387- Some (bold) changes in the init code. Please notify me if they
388 break things for you.
389
390===== Release notes for ftape-2.08, 14/03/96 =====
391
392If you correct a problem with ftape, please send your patch to
393khp@dolphinics.no too.
394
395- Updated to reflect that NR_MEM_LISTS is gone in 1.3.74
396- Teac 700 added to list of known drives.
397- The registered device name is now "ft" rather than "ftape".
398
399===== Release notes for ftape-2.07a, 14/03/96 =====
400
401Bugfixes by Marcin Dalecki <dalecki@namu03.gwdg.de>:
402- In the last release it just compiled against 1.3.70;
403 now the params to request_irq() and free_irq are() are fixed, so it also
404 works in 1.3.73 :-)
405- Support for modules is now correct for newer kernels.
406
407===== Release notes for ftape-2.07, 04/03/96 =====
408
409
410- ftape updated to compile against 1.3.70.
411- Iomega 700 and Wangtek 3200 recognised.
412
413
414===== Release notes for ftape-2.06b, 13/02/96 =====
415
416Another simple bugfix version.
417
418- Jumbo 700 recognised.
419- Typo in vendors.h fixed.
420
421
422===== Release notes for ftape-2.06a, 10/02/96 =====
423
424This release is a simple bugfix version.
425
426- Linux/SMP: ftape *should* work.
427- FC-10/20: Only accepts IRQs 3-7, or 9. If IRQ 9, properly tell the card
428 to use IRQ 2. Thanks to Greg Crider (gcrider@iclnet.org) for finding and
429 locating this bug and testing the patch.
430- Insight drive recognised correctly again.
431- Motor-on wakeup version of the Iomega 250 drive added
432
433
434===== Release notes for ftape-2.06, 28/01/96 =====
435
436Special thanks go to Neal Friedman and Steven Sorbom for their
437help in producing and testing this release.
438
439I have continued to clean up the code, with an eye towards inclusion
440of ftape in Linus' official kernel (In fact, as I type this, I am
441running on a kernel with ftape support statically linked). I have
442test-compiled ftape against my 1.2.13 tree without problems.
443Hopefully, everything should be OK for the v1.2.x people.
444
445WARNING! Alan Cox has mailed me that ftape does *NOT* work with
446Linux/SMP. If you try to run ftape under Linux/SMP, it will cause a
447kernel deadlock (which is worse than a panic).
448
449- QIC-3020/TR-3: 1Mbps support works. Neal is capable of reading and
450 writing data to a tape. ftape will automatically detect the type of
451 tape (e.g. TR-3 vs QIC-80) and move the fdc in and out of
452 "perpendicular mode" as necessary.
453- 2Mbps support is disabled by default, since it is not fully
454 debugged. If you are adventurous, remove -DFDC_82078SL in the
455 Makefile and see what happens :-)
456- fdc detection: silly bugs removed (Only 2Mbps fdcs were affected)
457 and added detection of the National Semiconductors PC8744 fdc chip
458 (used in the PC873xx "super-IO" chips).
459- Removed warning about incompatible types when compiling with Linux
460 1.2.x.
461- README.PCI updated with info about the DELL Dimension XPS P90.
462- Connor TST3200R added to detected drives.
463- `swapout' utility added to distribution. It will dirty 5Meg of
464 memory, trying to swap out other programs. Just say `make swapout'
465 to build it. ftape will do this automatically Real Soon Now (ie:
466 when I have found out which kernel memory alloc function to call).
467
468
469===== Release notes for ftape-2.05, 08/01/96 =====
470
471- For v1.2.x Kernels, you must apply the patch linux-1.2/ksyms.patch to
472 the kernel and rebuild it (it adds the __get_dma_pages symbol to
473 ksyms.c).
474- Included new asm-i386/io.h file from v1.3.x kernel series, to enable
475 gcc v.2.7.[12] to compile v1.2.x kernels (linux-1.2/io.h).
476- Module versions: If you wish to compile ftape as a versioned module,
477 you must first compile your kernel with CONFIG_MODVERSIONS=y.
478 Otherwise, you will get complaints that <linux/modversions.h> does not
479 exist (if that happens, a `touch modversions.h' will help you out).
480- CLK_48MHZ: new define in the Makefile (default: non-zero). If you have
481 a tape controller card that uses the i82078(-1) chip, but cannot get
482 it to work with ftape, try set it to 0 (and please report this).
483- QIC-3010/3020: Complete support is still missing, but will hopefully
484 come soon. Steven Sorbom has kindly provided me with hints about
485 this. Writing of QIC-3020 tapes definitely does NOT work (do not try
486 it! - the drive will not be in "perpendicular mode" and this will ruin
487 the formatting info on the tape).
488- ftape_num_buffers is out of fashion: use NR_BUFFERS instead (and
489 recompile if you want to change it :-).
490
491
492===== Release notes for ftape-2.04, 01/01/96 =====
493
494This version by Kai Harrekilde-Petersen <khp@dolphinics.no>
495
496- ALERT! Support for Kernels earlier then v1.1.85 is about to go away.
497 I intend to clean up some of the code (getting rid of an annoyingly
498 large numbers of #ifdef mostly), which means that support for
499 pre-1.1.85 kernels must go as well.
500- NR_FTAPE_BUFFERS is gone; You can instead select the number of dma
501 buffers by saying `insmod ftape.o ftape_num_buffer=<n>' instead.
502- Configure script gone. ftape will now automagically determine your
503 kernel version by /usr/include/linux/version.h instead.
504- CONFIG_MODVERSIONS now work. All combinations of versioned /
505 unversioned kernel and ftape module works (at least with my 1.3.52
506 kernel).
507- If you have problems with inserting ftape into an old (1.2.x)
508 kernel (e.g. insmod says "1.2.8 does not match 1.2.8), recompile
509 your modules utilities with your new compiler.
510- Reveal TB1400 drive added to vendors.h
511- Support for the i82078-1 (2Mbps) chip is coming along. The
512 biggest problem is that I don't have such a card, which makes
513 testing / debugging somewhat problematic. The second biggest
514 problem is that I do not have the QIC-3010/3020 standards either.
515 Status right now is that the chip is detected, and it should be
516 possible to put it into 2Mbps mode. However, I do not know what
517 "extras" are needed to complete the support. Although putting the
518 i82078 into 1Mbps mode ought to work out of the box, it doesn't
519 (right now, ftape complains about id am errors).
520
521
522===== Release notes for ftape-2.04beta5, 29/12/95 =====
523
524Bas offline linux-tape
525----------------------
526For reasons only known to the majordomo mail list processor, Bas was
527kicked off the linux-tape list sometime during the summer. Being
528overworked at his for-pay job, he didn't notice it much. Instead I
529(Kai, khp@dolphinics.no) has worked on ftape to produce the 2.04(beta)
530version.
531
532zftape
533------
534Note that there exists a much improved version of ftape, written by
535Claus-Justus Heine <claus@willi.math.rwth-aachen.de> which is named
536zftape, which conforms to the QIC-80 specs on how to mark backups, and
537is capable of doing automatic compression. However, zftape makes
538substantial changes to ftape, and I (Kai) have therefore declined to
539integrate zftape into ftape. Hopefully, this will happen soon.
540
541CONFIG_QIC117 removed from the kernel
542-------------------------------------
543The biggest change of all is that ftape now will allocate its dma
544buffers when it is inserted. The means that the CONFIG_QIC117 option
545has disappeared from the Linux kernel as of v1.3.34. If you have an
546earlier kernel, simply answer 'no' to the question will do the trick
547(if you get complains about __get_free_pages() missing, contact the
548linux-tape mailing list).
549
550Note that ftape-2.04beta will work equally well on kernels with and
551without `ftape support'. The only catch is, that you will waste
552around 96-128Kb of precious DMA'able memory on a box that has ftape
553support compiled in.
554
555Now for the real changes:
556
557- FC-20 can now use DMA channels 1, 2, and 3. Thanks to Daniel
558 Cohen, catman@wpi.edu.
559- ftape no longer requires a (gigantic) 96Kb buffer to be statically
560 allocated by the kernel.
561- Added new Iomega drive (8882) to vendors.h
562- -fno-strength-reduce added to Makefile, since GCC is broken.
563- i82078-1 (2Mbps) FDC support started.
564
565
566===== Release notes for ftape-2.03b, 27/05/95 =====
567
568- Prevented verify_area to return error if called with zero length.
569- Fixed a bug in flush_buffers that caused too much padding to be
570 written when a final segment had bad sectors.
571- Increased maximum fast-seek overshoot value from 5 to 10 segments.
572- Breaking loop after 5 retries when positioning fails.
573- Fixed wrong calculation of tape length for QIC-3010 and QIC-3020
574 tapes (densities were swapped).
575- Fixed wrong calculation of overshoot on seek_forward: Wrong sign
576 of error.
577- Suppress (false) error message due to new tape loaded.
578- Added two new CMS drives (11c3 and 11c5) to vendors.h.
579
580
581===== Release notes for ftape-2.03a, 09/05/95 =====
582
583- Fixed display of old error (even if already cleared) in ftape_open.
584- Improved tape length detection, ioctls would fail for 425 ft tapes.
585 Until the tape length is calculated with data from the header
586 segment, we'll use worst-case values.
587- Clear eof_mark after rewinding ioctls.
588- Fixed wrong version message (2.03 had 2.02g id).
589- Fixed bug that caused the fdc to be reset very frequently.
590 This shouldn't affect normal operation but the timing of the
591 report routines has changed again and that may cause problems.
592 We'll just have to find out....
593- Implemented correct write precompensation setting for QIC-3010/3020.
594- Cleaned up fdc_interrupt_wait routine. Hope it still works :-)
595- Finally removed (already disabled) special eof mark handling for
596 gnu tar.
597- Changed order of get_dma_residue and disable_dma in fdc-isr.c
598 because the current order would fail on at least one system.
599 We're back to the original order again, hope (and expect) this
600 doesn't break any other system.
601
602
603===== Release notes for ftape-2.03, 07/05/95 =====
604
605(Changes refer to the first ftape-2.02 release)
606
607Support for wide and extended length tapes
608------------------------------------------
609The Conner TSM 420 and 850 drives are reported to be working.
610I haven't received any reports about other brands; the TSM 420
611and 850 seem to be the most widely used wide drives.
612Extended length tapes (425 ft) with normal QIC-80 drives
613are operating too (At least I've had no reports stating otherwise).
614_Not_ yet completely supported (although they may work) are
615QIC-3020 drives and 2 Mbps floppy disk controllers won't work at
616the highest speed.
617If someone is kind enough to send me one of these, I'll include
618support for it too ;-)
619
620Easier configuration
621--------------------
622Problems due to wrong settings in the Makefile are prevented
623by using a configuration script that sets the necessary (kernel
624version dependent) compile time options.
625This kernel version is now determined from the sources found
626at /usr/src/linux, or if not found, the old way using
627/proc/version.
628Versioned modules will be used automatically when supported
629by- and configured in- the kernel.
630Note that the current modules code (1.1.87) is still broken
631and _needs_ the fix included in the insmod directory.
632Please don't send me any more Oops reports caused by insmod :-(
633
634Reduced module size
635-------------------
636The standard module size is much reduced and some compile time
637options can even reduce it further. (I don't recommend this
638for normal use but it can be handy for rescue diskettes)
639
640Option: Approx. module size:
641
642<standard> 150 Kb
643NO_TRACE 125 Kb
644NO_TRACE_AT_ALL 67 Kb
645
646
647Much improved driver interruption
648---------------------------------
649Most possible loops have been broken and signal detection
650has been improved.
651In most cases the driver can be aborted by ^C (SIGINT) and
652SIGKILL (kill -9) will generate be a sure kill.
653(Note that aborting a tape operation may damage the last
654data written to tape)
655
656Improved error recovery
657-----------------------
658Ftape now returns an error (ENODATA) to the application if
659a segment proves to be unrecoverable and then skips the
660bad segment.
661This causes most applications to continue to work (tar
662and afio) loosing only a small amount (up to 29 Kb) of data.
663Retried read operations will now be done slightly off-track
664to improve the chance of success. Serious head off-track
665errors will be detected.
666
667FC-10 and FC-20 controllers
668---------------------------
669Ftape now supports both the old CMS FC-10 and the newer FC-20
670controllers.
671Because the operation of these cards is still undocumented,
672thus far they will only work with the default settings (See
673Makefile). Any feed-back on how to use them with other settings
674will be welcome !
675Compilation will fail if one changes the settings to illegal
676values.
677
678Kernels and compilers
679---------------------
680Ftape is currently being developed using the 2.5.8 compiler.
681The older 2.4.5 probably works too (Set option in Makefile!).
682I have no experience with any later compilers nor Elf support.
683Any information on this is welcome.
684The latest kernel I have tested ftape with is 1.2.6.
685
686Compression
687-----------
688An impressive collection of changes for ftape including
689on-the-fly compression is still lying on my desk.
690If 2.03 proves to be reliable I might start integrating these
691but as usual, I'm short in time :-(
692
693Formatting
694----------
695There is still no way to format tapes under Linux. As far as
696I know all attempts to write such a program have died now.
697Since formatted tapes are rather common now, I think all we
698need is a utility that writes a worst case pattern and verifies
699that with the drive put in verify mode, reducing margins.
700Any takers ?
701
702Furthermore
703-----------
704Cleaned up messages.
705Prepared to support multiple tape drives on one fdc.
706Thanks to all the people who sent bug reports and helped me
707improve the driver. Without trying to be complete I'll mention
708Gary Anderson (without his accurate reports and unreliable
709hardware there wouldn't be a 2.03), Stefan Kneifel (FC-20),
710Robert Broughton (FC-20, you were almost there ;-), Bjorn
711Ekwall (for the versioned modules and buggy insmod ;-), Peter
712Fox, Christopher Oliver, Ralph Whittaker and not the least
713Linus Torvalds (for Linux and keeping me busy because of
714changes to the kernel ;-)
715Thanks to anyone I forgot, for the bug reports, the ftape
716bashing and the mental support...
717
718
719That's it for now. Have Fun,
720
721Bas.
722
723
724===== Release notes for ftape-2.02g, 06/05/95 =====
725
726- Added extra test to break read-id loop with signal.
727- Changed rewind code to handle negative overshoot for drives
728 that take very long to start or stop.
729- Let use of get/set i/o-regions depend on kernel version.
730- Changed code to use a more general test for conditional
731 compilations depending on kernel version.
732- Improved micro-step functionality to go off-track only
733 while reading (id & data).
734- Added failure on tape-not-referenced bit in ftape_command.
735- Added FOREVER option to read-wait routine.
736- Changed read-id to use shorter timeout causing smaller
737 rewinds on timeout.
738- Made kernel-interface functions static.
739
740
741===== Release notes for ftape-2.02f, 03/05/95 =====
742
743- Added support for dual tape drives on my system, extended Configure
744 script to detect host 'dodo'.
745- Log media defect in history if ecc failed and no data was returned.
746- Fixed Configure script that was failing for kernel versions with
747 double digit version or revision numbers.
748
749
750===== Release notes for ftape-2.02e, 01/05/95 =====
751
752- Fixed reposition loop at logical eot (failing read_id).
753- Fixed 34 segment offset when rewinding.
754- Added fast seek capability for more than 255 segments.
755- Fixed wrong busy result from ftape_command causing reverse
756 seek to fail.
757- Added breakout from infinite rewind loop (if something fails).
758
759
760===== Release notes for ftape-2.02d, 30/04/95 =====
761
762- Improved abortion on signals: Interrupt will make a graceful
763 exit, Kill will be less nice and should be used if everything
764 else fails.
765- Included check for tape-head off track.
766- Implemented exit from tape-start loop.
767- Added kernel io-port registration.
768- Implemented skip of failing segment (ENODATA) on ecc failure.
769 This allows afio and tar to continue when the tape is damaged.
770- Made distinction between drive names with different codes.
771
772
773===== Release notes for ftape-2.02c, 22/04/95 =====
774
775- Fixed too tight command queueing after tape stop/pause command
776 issued from within interrupt service routine (Showed as timeout
777 on Acknowledge errors during retries on some systems)
778- Tried to fix timeouts when using 425 ft tape because the extended
779 length doesn't seem to be detected by the hardware.
780 We now use the format code from the header segment so adjust the
781 timing after reading the header segment.
782- Fixed some messages stating 'unexpected something...' being not
783 unexpected anymore.
784- Started preparations for merge of dynamic buffer allocation and
785 compression code.
786- Changed some debug messages to include relevant segment information
787 at level 4.
788- Included early bail-out when drive offline, preventing a lot of
789 false messages.
790- Moved ftape_parameter_xxx() offsets into function instead of in calls.
791- Removed 'weird, drive busy but no data' error when caused by
792 an error during a read-id.
793- Improved 'timeout on acknowledge' diagnostics.
794- Moved MODULE option into Configure.
795- Reduced code size when no tracing at all was set (Claus Heine).
796- No longer log error code 0 (no error) as an error.
797
798
799===== Release notes for ftape-2.02b, 09/04/95 =====
800
801- Relaxed timing for status operation and displaying
802 abnormal results. Hopefully this shows what's going
803 wrong with the Conner TSM850R drives.
804- Created script for configuration, using version number
805 of kernel source if available, otherwise /proc/version.
806- Fixed conditionals in kernel-interface.c.
807- Removed unavoidable TRACE output.
808
809
810===== Release notes for ftape-2.02a, 01/04/95 =====
811
812- Implemented `new-style' (versioned) modules support for new
813 kernels.
814- Reduced size of module by moving static data to bss.
815- Now using version number of kernel source instead of running
816 kernel for kernel versions >= 1.1.82
817- Added feedback on drive speeds to vendor information.
818- Included fixed insmod sources to distribution (Let's hope
819 the modules distribution get fixed soon :-/).
820
821Note that I haven't yet implemented any of the code extension I
822received. I hope to find some time to do this soon.
823
824
825===== Release notes for ftape-2.02, 15/01/95 =====
826
827
828- Fixed failing repositioning when overshoot was incremented.
829- Fixed rate selection: Because of a deficiency in the QIC-117
830 specification one cannot distinguish between a not implemented
831 and a failing command. Therefor we now try to find out if the
832 drive does support this command before usage.
833- Fixed error retry using wrong offset in fdc-isr.
834- Improved retry code to retry only once on a single no-data
835 error in a segment.
836- Validate sector number extracted from eof mark because an
837 invalid file mark (due to ???) could cause kernel panic.
838- Split ftape-io.c into ftape-io.c and ftape-ctl.c files.
839- Corrected too high media error count after writing to
840 a bad tape.
841- Added #include <asm/segment.h> again because old kernel versions
842 need it.
843- Fixed fdc not being disabled when open failed because no tape
844 drive was found.
845- Fixed problem with soft error in sector 32 (shift operator with
846 shiftcount 32 is not defined).
847
848
849===== Release notes for ftape-2.01, 08/01/95 =====
850
851
852- Removed TESTING setting from distributed Makefile.
853- Fixed `mt asf' failure: Rewind was deferred to close which
854 overruled the fsf ioctl.
855- Prevented non-interruptible commands being interrupted.
856- Added missing timeout.pause setting.
857- Maximum tape speed read from drive type information table.
858 If the information is not in the table (0) the drive will
859 determine the speed itself and put a message in the logfile.
860 This information should then be added to the table in the
861 vendors.h file (and reported to me).
862- Added call to ftape_init_drive after soft reset for those
863 (antique) drives that don't do an implicit seek_load_point
864 after a reset or power up.
865- Don't try to set data rate if reset failed.
866- Prevent update of seek variables when starting from the
867 beginning or the end of the tape.
868- Fixed wrong adjustment of overshoot in seek_forward().
869- Added sync to Makefile (again).
870- Added code to diagnose timer problems (calibr.c).
871- Replaced time differences by timediff calls.
872- Removed reference to do_floppy from object for recent kernels.
873- Fixed wrong display of 'failing dma controller' message.
874- Removed various no longer used #include statements.
875- Added max. tape speed value to vendor-struct.
876- Changed ftape-command to check pre-conditions and wait
877 if needed.
878- Further updated qic117.h to rev G.
879- Combined command name table and restrictions table to one.
880 Extended this table with some new fields.
881- Increased timeout on Ack timer value and included code to
882 report out of spec behaviour.
883- Increased rewind timeout margin to calculated + 20%.
884- Improved data rate selection so it won't fail on some
885 older (pre standard) drives.
886- Changed initialisation code so drive will be rewound if the
887 driver is reloaded and the tape is not at bot.
888- Moved some of the flush operations from close to the ioctls.
889- Added exit code value to failing verify area message.
890- Loop until tape halted in smart-stop.
891- Fast seek handled specially if located at bot or eot.
892- Being more conservative on overshoot value.
893
894
895===== Release notes for ftape-2.00, 31/12/94 =====
896
897 The Install-guide is completely rewritten and now also includes
898some information on how to use the driver. If you're either new
899to ftape or new to Unix tape devices make sure to read it !
900
901 If you own a pci system and experience problems with the
902ftape driver make sure to read the README.PCI file. It contains
903some hints on how to fix your hardware.
904
905 For anybody who hasn't noticed: The version number of the
906driver has been incremented (The latest released version has
907been version 1.14d).
908 This has been done for two major reasons:
909
910 o A new (better) error recovery scheme is implemented.
911 o Support for new drive types has been added.
912
913 All these improvements/changes will probably include a couple
914of new (and old?) bugs. If you encounter any problems that you think
915I'm not yet aware of, feel free to send a report to <bas@vimec.nl>.
916 I recommend keeping a version of ftape-1.14d available, just
917in case ;-)
918
919 This version should work with all kernel versions from 1.0.9 up
920to 1.1.72 (and probably earlier and later versions too).
921
922
923Major new features:
924
925- Better handling of tapes with defects: When a sector repeatedly
926 (SOFT_RETRIES in ftape.h) cannot be written to or read from it is
927 marked as an hard error and gets skipped.
928 The error correction code can handle up to three of these hard
929 errors provided there are no other errors in that segment (32 Kb).
930
931- Allows writing to tapes with defects (although the risk of loosing
932 data increases !)
933 Look for the media-defects entry printed with the statistics when
934 the tape is closed. A non-zero value here shows a bad tape.
935 [the actual count is wrong (too high), this is a known bug].
936
937- Use of backup header segment if first one is failing.
938
939- Support for extended length tapes with QIC-80: both 425 and 1100 ft.
940 0.25 inch tapes are now recognized and handled.
941
942- Support for new QIC-80 drives with 8 mm `wide' tapes (e.g. Conner
943 TSM 420).
944
945- Support for new QIC-3010 and QIC-3020 drives (experimental) with
946 both 0.25 inch and 8 mm tapes.
947
948Some minor features were added, a couple of small bugs were fixed and
949probably some new ones introduced ;-).
950
951[lseek() didn't make it into this version]
952
953Have fun,
954
955Bas.
956----
957 LocalWords: ftape MCONFIG mt VFS zftape resp sftape proc subdir MTIOCVOLINFO
958 LocalWords: MTIOCGETSIZE BOT EOD MTBSF zft kerneld modprobe kdtime contrib TR
959 LocalWords: MTSETBLK afio uninstall texi www EIO QIC init sft eof aka dma GB
960 LocalWords: SIGKILL MTIOCFTCMD mmap Iomega FDC fdc io gnumt mtio fc asm inb
961 LocalWords: outb ft qic frontend TeXinfo irq mach MODVERSIONS CONFIG html dvi
962 LocalWords: usr doc SMP Mb Dunno FIXME vtblc perl listtape volinfo fsf MTWEOF
963 LocalWords: amanda degaussed ComByte DoublePlay whraven njackn com MTIOC vtbl
964 LocalWords: GETBLKSZ MAKEDEV zftape's linux dif CVS Revison cp MTREW MTOFFL
965 LocalWords: MTFSF BSF Marcin Dalecki GCC Config cpio swapout Kai Harrekilde
966 LocalWords: Pederson khp dolphinics Justus claus momo rwth aachen Laarhoven
diff --git a/drivers/char/ftape/compressor/Makefile b/drivers/char/ftape/compressor/Makefile
deleted file mode 100644
index 1fbd6c4019db..000000000000
--- a/drivers/char/ftape/compressor/Makefile
+++ /dev/null
@@ -1,31 +0,0 @@
1#
2# Copyright (C) 1997 Claus-Justus Heine.
3#
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 2, or (at your option)
7# any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program; see the file COPYING. If not, write to
16# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17#
18# $Source: /homes/cvs/ftape-stacked/ftape/compressor/Makefile,v $
19# $Revision: 1.1 $
20# $Date: 1997/10/05 19:12:28 $
21#
22# Makefile for the optional compressor for th zftape VFS
23# interface to the QIC-40/80/3010/3020 floppy-tape driver for
24# Linux.
25#
26
27obj-$(CONFIG_ZFT_COMPRESSOR) += zft-compressor.o
28
29zft-compressor-objs := zftape-compress.o lzrw3.o
30
31CFLAGS_lzrw3.o := -O6 -funroll-all-loops
diff --git a/drivers/char/ftape/compressor/lzrw3.c b/drivers/char/ftape/compressor/lzrw3.c
deleted file mode 100644
index a032a0ee2a99..000000000000
--- a/drivers/char/ftape/compressor/lzrw3.c
+++ /dev/null
@@ -1,743 +0,0 @@
1/*
2 * $Source: /homes/cvs/ftape-stacked/ftape/compressor/lzrw3.c,v $
3 * $Revision: 1.1 $
4 * $Date: 1997/10/05 19:12:29 $
5 *
6 * Implementation of Ross Williams lzrw3 algorithm. Adaption for zftape.
7 *
8 */
9
10#include "../compressor/lzrw3.h" /* Defines single exported function "compress". */
11
12/******************************************************************************/
13/* */
14/* LZRW3.C */
15/* */
16/******************************************************************************/
17/* */
18/* Author : Ross Williams. */
19/* Date : 30-Jun-1991. */
20/* Release : 1. */
21/* */
22/******************************************************************************/
23/* */
24/* This file contains an implementation of the LZRW3 data compression */
25/* algorithm in C. */
26/* */
27/* The algorithm is a general purpose compression algorithm that runs fast */
28/* and gives reasonable compression. The algorithm is a member of the Lempel */
29/* Ziv family of algorithms and bases its compression on the presence in the */
30/* data of repeated substrings. */
31/* */
32/* This algorithm is unpatented and the code is public domain. As the */
33/* algorithm is based on the LZ77 class of algorithms, it is unlikely to be */
34/* the subject of a patent challenge. */
35/* */
36/* Unlike the LZRW1 and LZRW1-A algorithms, the LZRW3 algorithm is */
37/* deterministic and is guaranteed to yield the same compressed */
38/* representation for a given file each time it is run. */
39/* */
40/* The LZRW3 algorithm was originally designed and implemented */
41/* by Ross Williams on 31-Dec-1990. */
42/* */
43/* Here are the results of applying this code, compiled under THINK C 4.0 */
44/* and running on a Mac-SE (8MHz 68000), to the standard calgary corpus. */
45/* */
46/* +----------------------------------------------------------------+ */
47/* | DATA COMPRESSION TEST | */
48/* | ===================== | */
49/* | Time of run : Sun 30-Jun-1991 09:31PM | */
50/* | Timing accuracy : One part in 100 | */
51/* | Context length : 262144 bytes (= 256.0000K) | */
52/* | Test suite : Calgary Corpus Suite | */
53/* | Files in suite : 14 | */
54/* | Algorithm : LZRW3 | */
55/* | Note: All averages are calculated from the un-rounded values. | */
56/* +----------------------------------------------------------------+ */
57/* | File Name Length CxB ComLen %Remn Bits Com K/s Dec K/s | */
58/* | ---------- ------ --- ------ ----- ---- ------- ------- | */
59/* | rpus:Bib.D 111261 1 55033 49.5 3.96 19.46 32.27 | */
60/* | us:Book1.D 768771 3 467962 60.9 4.87 17.03 31.07 | */
61/* | us:Book2.D 610856 3 317102 51.9 4.15 19.39 34.15 | */
62/* | rpus:Geo.D 102400 1 82424 80.5 6.44 11.65 18.18 | */
63/* | pus:News.D 377109 2 205670 54.5 4.36 17.14 27.47 | */
64/* | pus:Obj1.D 21504 1 13027 60.6 4.85 13.40 18.95 | */
65/* | pus:Obj2.D 246814 1 116286 47.1 3.77 19.31 30.10 | */
66/* | s:Paper1.D 53161 1 27522 51.8 4.14 18.60 31.15 | */
67/* | s:Paper2.D 82199 1 45160 54.9 4.40 18.45 32.84 | */
68/* | rpus:Pic.D 513216 2 122388 23.8 1.91 35.29 51.05 | */
69/* | us:Progc.D 39611 1 19669 49.7 3.97 18.87 30.64 | */
70/* | us:Progl.D 71646 1 28247 39.4 3.15 24.34 40.66 | */
71/* | us:Progp.D 49379 1 19377 39.2 3.14 23.91 39.23 | */
72/* | us:Trans.D 93695 1 33481 35.7 2.86 25.48 40.37 | */
73/* +----------------------------------------------------------------+ */
74/* | Average 224401 1 110953 50.0 4.00 20.17 32.72 | */
75/* +----------------------------------------------------------------+ */
76/* */
77/******************************************************************************/
78
79/******************************************************************************/
80
81/* The following structure is returned by the "compress" function below when */
82/* the user asks the function to return identifying information. */
83/* The most important field in the record is the working memory field which */
84/* tells the calling program how much working memory should be passed to */
85/* "compress" when it is called to perform a compression or decompression. */
86/* LZRW3 uses the same amount of memory during compression and decompression. */
87/* For more information on this structure see "compress.h". */
88
89#define U(X) ((ULONG) X)
90#define SIZE_P_BYTE (U(sizeof(UBYTE *)))
91#define SIZE_WORD (U(sizeof(UWORD )))
92#define ALIGNMENT_FUDGE (U(16))
93#define MEM_REQ ( U(4096)*(SIZE_P_BYTE) + ALIGNMENT_FUDGE )
94
95static struct compress_identity identity =
96{
97 U(0x032DDEA8), /* Algorithm identification number. */
98 MEM_REQ, /* Working memory (bytes) required. */
99 "LZRW3", /* Name of algorithm. */
100 "1.0", /* Version number of algorithm. */
101 "31-Dec-1990", /* Date of algorithm. */
102 "Public Domain", /* Copyright notice. */
103 "Ross N. Williams", /* Author of algorithm. */
104 "Renaissance Software", /* Affiliation of author. */
105 "Public Domain" /* Vendor of algorithm. */
106};
107
108LOCAL void compress_compress (UBYTE *,UBYTE *,ULONG,UBYTE *, LONG *);
109LOCAL void compress_decompress(UBYTE *,UBYTE *,LONG, UBYTE *, ULONG *);
110
111/******************************************************************************/
112
113/* This function is the only function exported by this module. */
114/* Depending on its first parameter, the function can be requested to */
115/* compress a block of memory, decompress a block of memory, or to identify */
116/* itself. For more information, see the specification file "compress.h". */
117
118EXPORT void lzrw3_compress(
119 UWORD action, /* Action to be performed. */
120 UBYTE *wrk_mem, /* Address of working memory we can use.*/
121 UBYTE *src_adr, /* Address of input data. */
122 LONG src_len, /* Length of input data. */
123 UBYTE *dst_adr, /* Address to put output data. */
124 void *p_dst_len /* Address of longword for length of output data.*/
125)
126{
127 switch (action)
128 {
129 case COMPRESS_ACTION_IDENTITY:
130 *((struct compress_identity **)p_dst_len)= &identity;
131 break;
132 case COMPRESS_ACTION_COMPRESS:
133 compress_compress(wrk_mem,src_adr,src_len,dst_adr,(LONG *)p_dst_len);
134 break;
135 case COMPRESS_ACTION_DECOMPRESS:
136 compress_decompress(wrk_mem,src_adr,src_len,dst_adr,(LONG *)p_dst_len);
137 break;
138 }
139}
140
141/******************************************************************************/
142/* */
143/* BRIEF DESCRIPTION OF THE LZRW3 ALGORITHM */
144/* ======================================== */
145/* The LZRW3 algorithm is identical to the LZRW1-A algorithm except that */
146/* instead of transmitting history offsets, it transmits hash table indexes. */
147/* In order to decode the indexes, the decompressor must maintain an */
148/* identical hash table. Copy items are straightforward:when the decompressor */
149/* receives a copy item, it simply looks up the hash table to translate the */
150/* index into a pointer into the data already decompressed. To update the */
151/* hash table, it replaces the same table entry with a pointer to the start */
152/* of the newly decoded phrase. The tricky part is with literal items, for at */
153/* the time that the decompressor receives a literal item the decompressor */
154/* does not have the three bytes in the Ziv (that the compressor has) to */
155/* perform the three-byte hash. To solve this problem, in LZRW3, both the */
156/* compressor and decompressor are wired up so that they "buffer" these */
157/* literals and update their hash tables only when three bytes are available. */
158/* This makes the maximum buffering 2 bytes. */
159/* */
160/* Replacement of offsets by hash table indexes yields a few percent extra */
161/* compression at the cost of some speed. LZRW3 is slower than LZRW1, LZRW1-A */
162/* and LZRW2, but yields better compression. */
163/* */
164/* Extra compression could be obtained by using a hash table of depth two. */
165/* However, increasing the depth above one incurs a significant decrease in */
166/* compression speed which was not considered worthwhile. Another reason for */
167/* keeping the depth down to one was to allow easy comparison with the */
168/* LZRW1-A and LZRW2 algorithms so as to demonstrate the exact effect of the */
169/* use of direct hash indexes. */
170/* */
171/* +---+ */
172/* |___|4095 */
173/* |___| */
174/* +---------------------*_|<---+ /----+---\ */
175/* | |___| +---|Hash | */
176/* | |___| |Function| */
177/* | |___| \--------/ */
178/* | |___|0 ^ */
179/* | +---+ | */
180/* | Hash +-----+ */
181/* | Table | */
182/* | --- */
183/* v ^^^ */
184/* +-------------------------------------|----------------+ */
185/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
186/* +-------------------------------------|----------------+ */
187/* | |1......18| | */
188/* |<------- Lempel=History ------------>|<--Ziv-->| | */
189/* | (=bytes already processed) |<-Still to go-->| */
190/* |<-------------------- INPUT BLOCK ------------------->| */
191/* */
192/* The diagram above for LZRW3 looks almost identical to the diagram for */
193/* LZRW1. The difference is that in LZRW3, the compressor transmits hash */
194/* table indices instead of Lempel offsets. For this to work, the */
195/* decompressor must maintain a hash table as well as the compressor and both */
196/* compressor and decompressor must "buffer" literals, as the decompressor */
197/* cannot hash phrases commencing with a literal until another two bytes have */
198/* arrived. */
199/* */
200/* LZRW3 Algorithm Execution Summary */
201/* --------------------------------- */
202/* 1. Hash the first three bytes of the Ziv to yield a hash table index h. */
203/* 2. Look up the hash table yielding history pointer p. */
204/* 3. Match where p points with the Ziv. If there is a match of three or */
205/* more bytes, code those bytes (in the Ziv) as a copy item, otherwise */
206/* code the next byte in the Ziv as a literal item. */
207/* 4. Update the hash table as possible subject to the constraint that only */
208/* phrases commencing three bytes back from the Ziv can be hashed and */
209/* entered into the hash table. (This enables the decompressor to keep */
210/* pace). See the description and code for more details. */
211/* */
212/******************************************************************************/
213/* */
214/* DEFINITION OF COMPRESSED FILE FORMAT */
215/* ==================================== */
216/* * A compressed file consists of a COPY FLAG followed by a REMAINDER. */
217/* * The copy flag CF uses up four bytes with the first byte being the */
218/* least significant. */
219/* * If CF=1, then the compressed file represents the remainder of the file */
220/* exactly. Otherwise CF=0 and the remainder of the file consists of zero */
221/* or more GROUPS, each of which represents one or more bytes. */
222/* * Each group consists of two bytes of CONTROL information followed by */
223/* sixteen ITEMs except for the last group which can contain from one */
224/* to sixteen items. */
225/* * An item can be either a LITERAL item or a COPY item. */
226/* * Each item corresponds to a bit in the control bytes. */
227/* * The first control byte corresponds to the first 8 items in the group */
228/* with bit 0 corresponding to the first item in the group and bit 7 to */
229/* the eighth item in the group. */
230/* * The second control byte corresponds to the second 8 items in the group */
231/* with bit 0 corresponding to the ninth item in the group and bit 7 to */
232/* the sixteenth item in the group. */
233/* * A zero bit in a control word means that the corresponding item is a */
234/* literal item. A one bit corresponds to a copy item. */
235/* * A literal item consists of a single byte which represents itself. */
236/* * A copy item consists of two bytes that represent from 3 to 18 bytes. */
237/* * The first byte in a copy item will be denoted C1. */
238/* * The second byte in a copy item will be denoted C2. */
239/* * Bits will be selected using square brackets. */
240/* For example: C1[0..3] is the low nibble of the first control byte. */
241/* of copy item C1. */
242/* * The LENGTH of a copy item is defined to be C1[0..3]+3 which is a number */
243/* in the range [3,18]. */
244/* * The INDEX of a copy item is defined to be C1[4..7]*256+C2[0..8] which */
245/* is a number in the range [0,4095]. */
246/* * A copy item represents the sequence of bytes */
247/* text[POS-OFFSET..POS-OFFSET+LENGTH-1] where */
248/* text is the entire text of the uncompressed string. */
249/* POS is the index in the text of the character following the */
250/* string represented by all the items preceeding the item */
251/* being defined. */
252/* OFFSET is obtained from INDEX by looking up the hash table. */
253/* */
254/******************************************************************************/
255
256/* The following #define defines the length of the copy flag that appears at */
257/* the start of the compressed file. The value of four bytes was chosen */
258/* because the fast_copy routine on my Macintosh runs faster if the source */
259/* and destination blocks are relatively longword aligned. */
260/* The actual flag data appears in the first byte. The rest are zeroed so as */
261/* to normalize the compressed representation (i.e. not non-deterministic). */
262#define FLAG_BYTES 4
263
264/* The following #defines define the meaning of the values of the copy */
265/* flag at the start of the compressed file. */
266#define FLAG_COMPRESS 0 /* Signals that output was result of compression. */
267#define FLAG_COPY 1 /* Signals that output was simply copied over. */
268
269/* The 68000 microprocessor (on which this algorithm was originally developed */
270/* is fussy about non-aligned arrays of words. To avoid these problems the */
271/* following macro can be used to "waste" from 0 to 3 bytes so as to align */
272/* the argument pointer. */
273#define ULONG_ALIGN_UP(X) ((((ULONG)X)+sizeof(ULONG)-1)&~(sizeof(ULONG)-1))
274
275
276/* The following constant defines the maximum length of an uncompressed item. */
277/* This definition must not be changed; its value is hardwired into the code. */
278/* The longest number of bytes that can be spanned by a single item is 18 */
279/* for the longest copy item. */
280#define MAX_RAW_ITEM (18)
281
282/* The following constant defines the maximum length of an uncompressed group.*/
283/* This definition must not be changed; its value is hardwired into the code. */
284/* A group contains at most 16 items which explains this definition. */
285#define MAX_RAW_GROUP (16*MAX_RAW_ITEM)
286
287/* The following constant defines the maximum length of a compressed group. */
288/* This definition must not be changed; its value is hardwired into the code. */
289/* A compressed group consists of two control bytes followed by up to 16 */
290/* compressed items each of which can have a maximum length of two bytes. */
291#define MAX_CMP_GROUP (2+16*2)
292
293/* The following constant defines the number of entries in the hash table. */
294/* This definition must not be changed; its value is hardwired into the code. */
295#define HASH_TABLE_LENGTH (4096)
296
297/* LZRW3, unlike LZRW1(-A), must initialize its hash table so as to enable */
298/* the compressor and decompressor to stay in step maintaining identical hash */
299/* tables. In an early version of the algorithm, the tables were simply */
300/* initialized to zero and a check for zero was included just before the */
301/* matching code. However, this test costs time. A better solution is to */
302/* initialize all the entries in the hash table to point to a constant */
303/* string. The decompressor does the same. This solution requires no extra */
304/* test. The contents of the string do not matter so long as the string is */
305/* the same for the compressor and decompressor and contains at least */
306/* MAX_RAW_ITEM bytes. I chose consecutive decimal digits because they do not */
307/* have white space problems (e.g. there is no chance that the compiler will */
308/* replace more than one space by a TAB) and because they make the length of */
309/* the string obvious by inspection. */
310#define START_STRING_18 ((UBYTE *) "123456789012345678")
311
312/* In this algorithm, hash values have to be calculated at more than one */
313/* point. The following macro neatens the code up for this. */
314#define HASH(PTR) \
315 (((40543*(((*(PTR))<<8)^((*((PTR)+1))<<4)^(*((PTR)+2))))>>4) & 0xFFF)
316
317/******************************************************************************/
318
319/* Input : Hand over the required amount of working memory in p_wrk_mem. */
320/* Input : Specify input block using p_src_first and src_len. */
321/* Input : Point p_dst_first to the start of the output zone (OZ). */
322/* Input : Point p_dst_len to a ULONG to receive the output length. */
323/* Input : Input block and output zone must not overlap. */
324/* Output : Length of output block written to *p_dst_len. */
325/* Output : Output block in Mem[p_dst_first..p_dst_first+*p_dst_len-1]. May */
326/* Output : write in OZ=Mem[p_dst_first..p_dst_first+src_len+MAX_CMP_GROUP-1].*/
327/* Output : Upon completion guaranteed *p_dst_len<=src_len+FLAG_BYTES. */
328LOCAL void compress_compress(UBYTE *p_wrk_mem,
329 UBYTE *p_src_first, ULONG src_len,
330 UBYTE *p_dst_first, LONG *p_dst_len)
331{
332 /* p_src and p_dst step through the source and destination blocks. */
333 register UBYTE *p_src = p_src_first;
334 register UBYTE *p_dst = p_dst_first;
335
336 /* The following variables are never modified and are used in the */
337 /* calculations that determine when the main loop terminates. */
338 UBYTE *p_src_post = p_src_first+src_len;
339 UBYTE *p_dst_post = p_dst_first+src_len;
340 UBYTE *p_src_max1 = p_src_first+src_len-MAX_RAW_ITEM;
341 UBYTE *p_src_max16 = p_src_first+src_len-MAX_RAW_ITEM*16;
342
343 /* The variables 'p_control' and 'control' are used to buffer control bits. */
344 /* Before each group is processed, the next two bytes of the output block */
345 /* are set aside for the control word for the group about to be processed. */
346 /* 'p_control' is set to point to the first byte of that word. Meanwhile, */
347 /* 'control' buffers the control bits being generated during the processing */
348 /* of the group. Instead of having a counter to keep track of how many items */
349 /* have been processed (=the number of bits in the control word), at the */
350 /* start of each group, the top word of 'control' is filled with 1 bits. */
351 /* As 'control' is shifted for each item, the 1 bits in the top word are */
352 /* absorbed or destroyed. When they all run out (i.e. when the top word is */
353 /* all zero bits, we know that we are at the end of a group. */
354# define TOPWORD 0xFFFF0000
355 UBYTE *p_control;
356 register ULONG control=TOPWORD;
357
358 /* THe variable 'hash' always points to the first element of the hash table. */
359 UBYTE **hash= (UBYTE **) ULONG_ALIGN_UP(p_wrk_mem);
360
361 /* The following two variables represent the literal buffer. p_h1 points to */
362 /* the hash table entry corresponding to the youngest literal. p_h2 points */
363 /* to the hash table entry corresponding to the second youngest literal. */
364 /* Note: p_h1=0=>p_h2=0 because zero values denote absence of a pending */
365 /* literal. The variables are initialized to zero meaning an empty "buffer". */
366 UBYTE **p_h1=NULL;
367 UBYTE **p_h2=NULL;
368
369 /* To start, we write the flag bytes. Being optimistic, we set the flag to */
370 /* FLAG_COMPRESS. The remaining flag bytes are zeroed so as to keep the */
371 /* algorithm deterministic. */
372 *p_dst++=FLAG_COMPRESS;
373 {UWORD i; for (i=2;i<=FLAG_BYTES;i++) *p_dst++=0;}
374
375 /* Reserve the first word of output as the control word for the first group. */
376 /* Note: This is undone at the end if the input block is empty. */
377 p_control=p_dst; p_dst+=2;
378
379 /* Initialize all elements of the hash table to point to a constant string. */
380 /* Use of an unrolled loop speeds this up considerably. */
381 {UWORD i; UBYTE **p_h=hash;
382# define ZH *p_h++=START_STRING_18
383 for (i=0;i<256;i++) /* 256=HASH_TABLE_LENGTH/16. */
384 {ZH;ZH;ZH;ZH;
385 ZH;ZH;ZH;ZH;
386 ZH;ZH;ZH;ZH;
387 ZH;ZH;ZH;ZH;}
388 }
389
390 /* The main loop processes either 1 or 16 items per iteration. As its */
391 /* termination logic is complicated, I have opted for an infinite loop */
392 /* structure containing 'break' and 'goto' statements. */
393 while (TRUE)
394 {/* Begin main processing loop. */
395
396 /* Note: All the variables here except unroll should be defined within */
397 /* the inner loop. Unfortunately the loop hasn't got a block. */
398 register UBYTE *p; /* Scans through targ phrase during matching. */
399 register UBYTE *p_ziv= NULL ; /* Points to first byte of current Ziv. */
400 register UWORD unroll; /* Loop counter for unrolled inner loop. */
401 register UWORD index; /* Index of current hash table entry. */
402 register UBYTE **p_h0 = NULL ; /* Pointer to current hash table entry. */
403
404 /* Test for overrun and jump to overrun code if necessary. */
405 if (p_dst>p_dst_post)
406 goto overrun;
407
408 /* The following cascade of if statements efficiently catches and deals */
409 /* with varying degrees of closeness to the end of the input block. */
410 /* When we get very close to the end, we stop updating the table and */
411 /* code the remaining bytes as literals. This makes the code simpler. */
412 unroll=16;
413 if (p_src>p_src_max16)
414 {
415 unroll=1;
416 if (p_src>p_src_max1)
417 {
418 if (p_src==p_src_post)
419 break;
420 else
421 goto literal;
422 }
423 }
424
425 /* This inner unrolled loop processes 'unroll' (whose value is either 1 */
426 /* or 16) items. I have chosen to implement this loop with labels and */
427 /* gotos to heighten the ease with which the loop may be implemented with */
428 /* a single decrement and branch instruction in assembly language and */
429 /* also because the labels act as highly readable place markers. */
430 /* (Also because we jump into the loop for endgame literals (see above)). */
431
432 begin_unrolled_loop:
433
434 /* To process the next phrase, we hash the next three bytes and use */
435 /* the resultant hash table index to look up the hash table. A pointer */
436 /* to the entry is stored in p_h0 so as to avoid an array lookup. The */
437 /* hash table entry *p_h0 is looked up yielding a pointer p to a */
438 /* potential match of the Ziv in the history. */
439 index=HASH(p_src);
440 p_h0=&hash[index];
441 p=*p_h0;
442
443 /* Having looked up the candidate position, we are in a position to */
444 /* attempt a match. The match loop has been unrolled using the PS */
445 /* macro so that failure within the first three bytes automatically */
446 /* results in the literal branch being taken. The coding is simple. */
447 /* p_ziv saves p_src so we can let p_src wander. */
448# define PS *p++!=*p_src++
449 p_ziv=p_src;
450 if (PS || PS || PS)
451 {
452 /* Literal. */
453
454 /* Code the literal byte as itself and a zero control bit. */
455 p_src=p_ziv; literal: *p_dst++=*p_src++; control&=0xFFFEFFFF;
456
457 /* We have just coded a literal. If we had two pending ones, that */
458 /* makes three and we can update the hash table. */
459 if (p_h2!=0)
460 {*p_h2=p_ziv-2;}
461
462 /* In any case, rotate the hash table pointers for next time. */
463 p_h2=p_h1; p_h1=p_h0;
464
465 }
466 else
467 {
468 /* Copy */
469
470 /* Match up to 15 remaining bytes using an unrolled loop and code. */
471#if 0
472 PS || PS || PS || PS || PS || PS || PS || PS ||
473 PS || PS || PS || PS || PS || PS || PS || p_src++;
474#else
475 if (
476 !( PS || PS || PS || PS || PS || PS || PS || PS ||
477 PS || PS || PS || PS || PS || PS || PS )
478 ) p_src++;
479#endif
480 *p_dst++=((index&0xF00)>>4)|(--p_src-p_ziv-3);
481 *p_dst++=index&0xFF;
482
483 /* As we have just coded three bytes, we are now in a position to */
484 /* update the hash table with the literal bytes that were pending */
485 /* upon the arrival of extra context bytes. */
486 if (p_h1!=0)
487 {
488 if (p_h2)
489 {*p_h2=p_ziv-2; p_h2=NULL;}
490 *p_h1=p_ziv-1; p_h1=NULL;
491 }
492
493 /* In any case, we can update the hash table based on the current */
494 /* position as we just coded at least three bytes in a copy items. */
495 *p_h0=p_ziv;
496
497 }
498 control>>=1;
499
500 /* This loop is all set up for a decrement and jump instruction! */
501#ifndef linux
502` end_unrolled_loop: if (--unroll) goto begin_unrolled_loop;
503#else
504 /* end_unrolled_loop: */ if (--unroll) goto begin_unrolled_loop;
505#endif
506
507 /* At this point it will nearly always be the end of a group in which */
508 /* case, we have to do some control-word processing. However, near the */
509 /* end of the input block, the inner unrolled loop is only executed once. */
510 /* This necessitates the 'if' test. */
511 if ((control&TOPWORD)==0)
512 {
513 /* Write the control word to the place we saved for it in the output. */
514 *p_control++= control &0xFF;
515 *p_control = (control>>8) &0xFF;
516
517 /* Reserve the next word in the output block for the control word */
518 /* for the group about to be processed. */
519 p_control=p_dst; p_dst+=2;
520
521 /* Reset the control bits buffer. */
522 control=TOPWORD;
523 }
524
525 } /* End main processing loop. */
526
527 /* After the main processing loop has executed, all the input bytes have */
528 /* been processed. However, the control word has still to be written to the */
529 /* word reserved for it in the output at the start of the most recent group. */
530 /* Before writing, the control word has to be shifted so that all the bits */
531 /* are in the right place. The "empty" bit positions are filled with 1s */
532 /* which partially fill the top word. */
533 while(control&TOPWORD) control>>=1;
534 *p_control++= control &0xFF;
535 *p_control++=(control>>8) &0xFF;
536
537 /* If the last group contained no items, delete the control word too. */
538 if (p_control==p_dst) p_dst-=2;
539
540 /* Write the length of the output block to the dst_len parameter and return. */
541 *p_dst_len=p_dst-p_dst_first;
542 return;
543
544 /* Jump here as soon as an overrun is detected. An overrun is defined to */
545 /* have occurred if p_dst>p_dst_first+src_len. That is, the moment the */
546 /* length of the output written so far exceeds the length of the input block.*/
547 /* The algorithm checks for overruns at least at the end of each group */
548 /* which means that the maximum overrun is MAX_CMP_GROUP bytes. */
549 /* Once an overrun occurs, the only thing to do is to set the copy flag and */
550 /* copy the input over. */
551 overrun:
552#if 0
553 *p_dst_first=FLAG_COPY;
554 fast_copy(p_src_first,p_dst_first+FLAG_BYTES,src_len);
555 *p_dst_len=src_len+FLAG_BYTES;
556#else
557 fast_copy(p_src_first,p_dst_first,src_len);
558 *p_dst_len= -src_len; /* return a negative number to indicate uncompressed data */
559#endif
560}
561
562/******************************************************************************/
563
564/* Input : Hand over the required amount of working memory in p_wrk_mem. */
565/* Input : Specify input block using p_src_first and src_len. */
566/* Input : Point p_dst_first to the start of the output zone. */
567/* Input : Point p_dst_len to a ULONG to receive the output length. */
568/* Input : Input block and output zone must not overlap. User knows */
569/* Input : upperbound on output block length from earlier compression. */
570/* Input : In any case, maximum expansion possible is nine times. */
571/* Output : Length of output block written to *p_dst_len. */
572/* Output : Output block in Mem[p_dst_first..p_dst_first+*p_dst_len-1]. */
573/* Output : Writes only in Mem[p_dst_first..p_dst_first+*p_dst_len-1]. */
574LOCAL void compress_decompress( UBYTE *p_wrk_mem,
575 UBYTE *p_src_first, LONG src_len,
576 UBYTE *p_dst_first, ULONG *p_dst_len)
577{
578 /* Byte pointers p_src and p_dst scan through the input and output blocks. */
579 register UBYTE *p_src = p_src_first+FLAG_BYTES;
580 register UBYTE *p_dst = p_dst_first;
581 /* we need to avoid a SEGV when trying to uncompress corrupt data */
582 register UBYTE *p_dst_post = p_dst_first + *p_dst_len;
583
584 /* The following two variables are never modified and are used to control */
585 /* the main loop. */
586 UBYTE *p_src_post = p_src_first+src_len;
587 UBYTE *p_src_max16 = p_src_first+src_len-(MAX_CMP_GROUP-2);
588
589 /* The hash table is the only resident of the working memory. The hash table */
590 /* contains HASH_TABLE_LENGTH=4096 pointers to positions in the history. To */
591 /* keep Macintoshes happy, it is longword aligned. */
592 UBYTE **hash = (UBYTE **) ULONG_ALIGN_UP(p_wrk_mem);
593
594 /* The variable 'control' is used to buffer the control bits which appear in */
595 /* groups of 16 bits (control words) at the start of each compressed group. */
596 /* When each group is read, bit 16 of the register is set to one. Whenever */
597 /* a new bit is needed, the register is shifted right. When the value of the */
598 /* register becomes 1, we know that we have reached the end of a group. */
599 /* Initializing the register to 1 thus instructs the code to follow that it */
600 /* should read a new control word immediately. */
601 register ULONG control=1;
602
603 /* The value of 'literals' is always in the range 0..3. It is the number of */
604 /* consecutive literal items just seen. We have to record this number so as */
605 /* to know when to update the hash table. When literals gets to 3, there */
606 /* have been three consecutive literals and we can update at the position of */
607 /* the oldest of the three. */
608 register UWORD literals=0;
609
610 /* Check the leading copy flag to see if the compressor chose to use a copy */
611 /* operation instead of a compression operation. If a copy operation was */
612 /* used, then all we need to do is copy the data over, set the output length */
613 /* and return. */
614#if 0
615 if (*p_src_first==FLAG_COPY)
616 {
617 fast_copy(p_src_first+FLAG_BYTES,p_dst_first,src_len-FLAG_BYTES);
618 *p_dst_len=src_len-FLAG_BYTES;
619 return;
620 }
621#else
622 if ( src_len < 0 )
623 {
624 fast_copy(p_src_first,p_dst_first,-src_len );
625 *p_dst_len = (ULONG)-src_len;
626 return;
627 }
628#endif
629
630 /* Initialize all elements of the hash table to point to a constant string. */
631 /* Use of an unrolled loop speeds this up considerably. */
632 {UWORD i; UBYTE **p_h=hash;
633# define ZJ *p_h++=START_STRING_18
634 for (i=0;i<256;i++) /* 256=HASH_TABLE_LENGTH/16. */
635 {ZJ;ZJ;ZJ;ZJ;
636 ZJ;ZJ;ZJ;ZJ;
637 ZJ;ZJ;ZJ;ZJ;
638 ZJ;ZJ;ZJ;ZJ;}
639 }
640
641 /* The outer loop processes either 1 or 16 items per iteration depending on */
642 /* how close p_src is to the end of the input block. */
643 while (p_src!=p_src_post)
644 {/* Start of outer loop */
645
646 register UWORD unroll; /* Counts unrolled loop executions. */
647
648 /* When 'control' has the value 1, it means that the 16 buffered control */
649 /* bits that were read in at the start of the current group have all been */
650 /* shifted out and that all that is left is the 1 bit that was injected */
651 /* into bit 16 at the start of the current group. When we reach the end */
652 /* of a group, we have to load a new control word and inject a new 1 bit. */
653 if (control==1)
654 {
655 control=0x10000|*p_src++;
656 control|=(*p_src++)<<8;
657 }
658
659 /* If it is possible that we are within 16 groups from the end of the */
660 /* input, execute the unrolled loop only once, else process a whole group */
661 /* of 16 items by looping 16 times. */
662 unroll= p_src<=p_src_max16 ? 16 : 1;
663
664 /* This inner loop processes one phrase (item) per iteration. */
665 while (unroll--)
666 { /* Begin unrolled inner loop. */
667
668 /* Process a literal or copy item depending on the next control bit. */
669 if (control&1)
670 {
671 /* Copy item. */
672
673 register UBYTE *p; /* Points to place from which to copy. */
674 register UWORD lenmt; /* Length of copy item minus three. */
675 register UBYTE **p_hte; /* Pointer to current hash table entry.*/
676 register UBYTE *p_ziv=p_dst; /* Pointer to start of current Ziv. */
677
678 /* Read and dismantle the copy word. Work out from where to copy. */
679 lenmt=*p_src++;
680 p_hte=&hash[((lenmt&0xF0)<<4)|*p_src++];
681 p=*p_hte;
682 lenmt&=0xF;
683
684 /* Now perform the copy using a half unrolled loop. */
685 *p_dst++=*p++;
686 *p_dst++=*p++;
687 *p_dst++=*p++;
688 while (lenmt--)
689 *p_dst++=*p++;
690
691 /* Because we have just received 3 or more bytes in a copy item */
692 /* (whose bytes we have just installed in the output), we are now */
693 /* in a position to flush all the pending literal hashings that had */
694 /* been postponed for lack of bytes. */
695 if (literals>0)
696 {
697 register UBYTE *r=p_ziv-literals;
698 hash[HASH(r)]=r;
699 if (literals==2)
700 {r++; hash[HASH(r)]=r;}
701 literals=0;
702 }
703
704 /* In any case, we can immediately update the hash table with the */
705 /* current position. We don't need to do a HASH(...) to work out */
706 /* where to put the pointer, as the compressor just told us!!! */
707 *p_hte=p_ziv;
708
709 }
710 else
711 {
712 /* Literal item. */
713
714 /* Copy over the literal byte. */
715 *p_dst++=*p_src++;
716
717 /* If we now have three literals waiting to be hashed into the hash */
718 /* table, we can do one of them now (because there are three). */
719 if (++literals == 3)
720 {register UBYTE *p=p_dst-3; hash[HASH(p)]=p; literals=2;}
721 }
722
723 /* Shift the control buffer so the next control bit is in bit 0. */
724 control>>=1;
725#if 1
726 if (p_dst > p_dst_post)
727 {
728 /* Shit: we tried to decompress corrupt data */
729 *p_dst_len = 0;
730 return;
731 }
732#endif
733 } /* End unrolled inner loop. */
734
735 } /* End of outer loop */
736
737 /* Write the length of the decompressed data before returning. */
738 *p_dst_len=p_dst-p_dst_first;
739}
740
741/******************************************************************************/
742/* End of LZRW3.C */
743/******************************************************************************/
diff --git a/drivers/char/ftape/compressor/lzrw3.h b/drivers/char/ftape/compressor/lzrw3.h
deleted file mode 100644
index 533feba47526..000000000000
--- a/drivers/char/ftape/compressor/lzrw3.h
+++ /dev/null
@@ -1,253 +0,0 @@
1#ifndef _LZRW3_H
2#define _LZRW3_H
3/*
4 * $Source: /homes/cvs/ftape-stacked/ftape/compressor/lzrw3.h,v $
5 * $Revision: 1.1 $
6 * $Date: 1997/10/05 19:12:30 $
7 *
8 * include files for lzrw3. Only slighty modified from the original
9 * version. Assembles the three include files compress.h, port.h and
10 * fastcopy.h from the original lzrw3 package.
11 *
12 */
13
14#include <linux/types.h>
15#include <linux/string.h>
16
17/******************************************************************************/
18/* */
19/* COMPRESS.H */
20/* */
21/******************************************************************************/
22/* */
23/* Author : Ross Williams. */
24/* Date : December 1989. */
25/* */
26/* This header file defines the interface to a set of functions called */
27/* 'compress', each member of which implements a particular data compression */
28/* algorithm. */
29/* */
30/* Normally in C programming, for each .H file, there is a corresponding .C */
31/* file that implements the functions promised in the .H file. */
32/* Here, there are many .C files corresponding to this header file. */
33/* Each comforming implementation file contains a single function */
34/* called 'compress' that implements a single data compression */
35/* algorithm that conforms with the interface specified in this header file. */
36/* Only one algorithm can be linked in at a time in this organization. */
37/* */
38/******************************************************************************/
39/* */
40/* DEFINITION OF FUNCTION COMPRESS */
41/* =============================== */
42/* */
43/* Summary of Function Compress */
44/* ---------------------------- */
45/* The action that 'compress' takes depends on its first argument called */
46/* 'action'. The function provides three actions: */
47/* */
48/* - Return information about the algorithm. */
49/* - Compress a block of memory. */
50/* - Decompress a block of memory. */
51/* */
52/* Parameters */
53/* ---------- */
54/* See the formal C definition later for a description of the parameters. */
55/* */
56/* Constants */
57/* --------- */
58/* COMPRESS_OVERRUN: The constant COMPRESS_OVERRUN defines by how many bytes */
59/* an algorithm is allowed to expand a block during a compression operation. */
60/* */
61/* Although compression algorithms usually compress data, there will always */
62/* be data that a given compressor will expand (this can be proven). */
63/* Fortunately, the degree of expansion can be limited to a single bit, by */
64/* copying over the input data if the data gets bigger during compression. */
65/* To allow for this possibility, the first bit of a compressed */
66/* representation can be used as a flag indicating whether the */
67/* input data was copied over, or truly compressed. In practice, the first */
68/* byte would be used to store this bit so as to maintain byte alignment. */
69/* */
70/* Unfortunately, in general, the only way to tell if an algorithm will */
71/* expand a particular block of data is to run the algorithm on the data. */
72/* If the algorithm does not continuously monitor how many output bytes it */
73/* has written, it might write an output block far larger than the input */
74/* block before realizing that it has done so. */
75/* On the other hand, continuous checks on output length are inefficient. */
76/* */
77/* To cater for all these problems, this interface definition: */
78/* > Allows a compression algorithm to return an output block that is up to */
79/* COMPRESS_OVERRUN bytes longer than the input block. */
80/* > Allows a compression algorithm to write up to COMPRESS_OVERRUN bytes */
81/* more than the length of the input block to the memory of the output */
82/* block regardless of the length of the output block eventually returned. */
83/* This allows an algorithm to overrun the length of the input block in the */
84/* output block by up to COMPRESS_OVERRUN bytes between expansion checks. */
85/* */
86/* The problem does not arise for decompression. */
87/* */
88/* Identity Action */
89/* --------------- */
90/* > action must be COMPRESS_ACTION_IDENTITY. */
91/* > p_dst_len must point to a longword to receive a longword address. */
92/* > The value of the other parameters does not matter. */
93/* > After execution, the longword that p_dst_len points to will be a pointer */
94/* to a structure of type compress_identity. */
95/* Thus, for example, after the call, (*p_dst_len)->memory will return the */
96/* number of bytes of working memory that the algorithm requires to run. */
97/* > The values of the identity structure returned are fixed constant */
98/* attributes of the algorithm and must not vary from call to call. */
99/* */
100/* Common Requirements for Compression and Decompression Actions */
101/* ------------------------------------------------------------- */
102/* > wrk_mem must point to an unused block of memory of a length specified in */
103/* the algorithm's identity block. The identity block can be obtained by */
104/* making a separate call to compress, specifying the identity action. */
105/* > The INPUT BLOCK is defined to be Memory[src_addr,src_addr+src_len-1]. */
106/* > dst_len will be used to denote *p_dst_len. */
107/* > dst_len is not read by compress, only written. */
108/* > The value of dst_len is defined only upon termination. */
109/* > The OUTPUT BLOCK is defined to be Memory[dst_addr,dst_addr+dst_len-1]. */
110/* */
111/* Compression Action */
112/* ------------------ */
113/* > action must be COMPRESS_ACTION_COMPRESS. */
114/* > src_len must be in the range [0,COMPRESS_MAX_ORG]. */
115/* > The OUTPUT ZONE is defined to be */
116/* Memory[dst_addr,dst_addr+src_len-1+COMPRESS_OVERRUN]. */
117/* > The function can modify any part of the output zone regardless of the */
118/* final length of the output block. */
119/* > The input block and the output zone must not overlap. */
120/* > dst_len will be in the range [0,src_len+COMPRESS_OVERRUN]. */
121/* > dst_len will be in the range [0,COMPRESS_MAX_COM] (from prev fact). */
122/* > The output block will consist of a representation of the input block. */
123/* */
124/* Decompression Action */
125/* -------------------- */
126/* > action must be COMPRESS_ACTION_DECOMPRESS. */
127/* > The input block must be the result of an earlier compression operation. */
128/* > If the previous fact is true, the following facts must also be true: */
129/* > src_len will be in the range [0,COMPRESS_MAX_COM]. */
130/* > dst_len will be in the range [0,COMPRESS_MAX_ORG]. */
131/* > The input and output blocks must not overlap. */
132/* > Only the output block is modified. */
133/* > Upon termination, the output block will consist of the bytes contained */
134/* in the input block passed to the earlier compression operation. */
135/* */
136/******************************************************************************/
137
138/******************************************************************************/
139/* */
140/* PORT.H */
141/* */
142/******************************************************************************/
143/* */
144/* This module contains macro definitions and types that are likely to */
145/* change between computers. */
146/* */
147/******************************************************************************/
148
149#ifndef DONE_PORT /* Only do this if not previously done. */
150
151 #ifdef THINK_C
152 #define UBYTE unsigned char /* Unsigned byte */
153 #define UWORD unsigned int /* Unsigned word (2 bytes) */
154 #define ULONG unsigned long /* Unsigned word (4 bytes) */
155 #define BOOL unsigned char /* Boolean */
156 #define FOPEN_BINARY_READ "rb" /* Mode string for binary reading. */
157 #define FOPEN_BINARY_WRITE "wb" /* Mode string for binary writing. */
158 #define FOPEN_TEXT_APPEND "a" /* Mode string for text appending. */
159 #define REAL double /* USed for floating point stuff. */
160 #endif
161 #if defined(LINUX) || defined(linux)
162 #define UBYTE __u8 /* Unsigned byte */
163 #define UWORD __u16 /* Unsigned word (2 bytes) */
164 #define ULONG __u32 /* Unsigned word (4 bytes) */
165 #define LONG __s32 /* Signed word (4 bytes) */
166 #define BOOL is not used here /* Boolean */
167 #define FOPEN_BINARY_READ not used /* Mode string for binary reading. */
168 #define FOPEN_BINARY_WRITE not used /* Mode string for binary writing. */
169 #define FOPEN_TEXT_APPEND not used /* Mode string for text appending. */
170 #define REAL not used /* USed for floating point stuff. */
171 #ifndef TRUE
172 #define TRUE 1
173 #endif
174 #endif
175
176 #define DONE_PORT /* Don't do all this again. */
177 #define MALLOC_FAIL NULL /* Failure status from malloc() */
178 #define LOCAL static /* For non-exported routines. */
179 #define EXPORT /* Signals exported function. */
180 #define then /* Useful for aligning ifs. */
181
182#endif
183
184/******************************************************************************/
185/* End of PORT.H */
186/******************************************************************************/
187
188#define COMPRESS_ACTION_IDENTITY 0
189#define COMPRESS_ACTION_COMPRESS 1
190#define COMPRESS_ACTION_DECOMPRESS 2
191
192#define COMPRESS_OVERRUN 1024
193#define COMPRESS_MAX_COM 0x70000000
194#define COMPRESS_MAX_ORG (COMPRESS_MAX_COM-COMPRESS_OVERRUN)
195
196#define COMPRESS_MAX_STRLEN 255
197
198/* The following structure provides information about the algorithm. */
199/* > The top bit of id must be zero. The remaining bits must be chosen by */
200/* the author of the algorithm by tossing a coin 31 times. */
201/* > The amount of memory requested by the algorithm is specified in bytes */
202/* and must be in the range [0,0x70000000]. */
203/* > All strings s must be such that strlen(s)<=COMPRESS_MAX_STRLEN. */
204struct compress_identity
205 {
206 ULONG id; /* Identifying number of algorithm. */
207 ULONG memory; /* Number of bytes of working memory required. */
208
209 char *name; /* Name of algorithm. */
210 char *version; /* Version number. */
211 char *date; /* Date of release of this version. */
212 char *copyright; /* Copyright message. */
213
214 char *author; /* Author of algorithm. */
215 char *affiliation; /* Affiliation of author. */
216 char *vendor; /* Where the algorithm can be obtained. */
217 };
218
219void lzrw3_compress( /* Single function interface to compression algorithm. */
220UWORD action, /* Action to be performed. */
221UBYTE *wrk_mem, /* Working memory temporarily given to routine to use. */
222UBYTE *src_adr, /* Address of input data. */
223LONG src_len, /* Length of input data. */
224UBYTE *dst_adr, /* Address of output data. */
225void *p_dst_len /* Pointer to a longword where routine will write: */
226 /* If action=..IDENTITY => Adr of id structure. */
227 /* If action=..COMPRESS => Length of output data. */
228 /* If action=..DECOMPRESS => Length of output data. */
229);
230
231/******************************************************************************/
232/* End of COMPRESS.H */
233/******************************************************************************/
234
235
236/******************************************************************************/
237/* fast_copy.h */
238/******************************************************************************/
239
240/* This function copies a block of memory very quickly. */
241/* The exact speed depends on the relative alignment of the blocks of memory. */
242/* PRE : 0<=src_len<=(2^32)-1 . */
243/* PRE : Source and destination blocks must not overlap. */
244/* POST : MEM[dst_adr,dst_adr+src_len-1]=MEM[src_adr,src_adr+src_len-1]. */
245/* POST : MEM[dst_adr,dst_adr+src_len-1] is the only memory changed. */
246
247#define fast_copy(src,dst,len) memcpy(dst,src,len)
248
249/******************************************************************************/
250/* End of fast_copy.h */
251/******************************************************************************/
252
253#endif
diff --git a/drivers/char/ftape/compressor/zftape-compress.c b/drivers/char/ftape/compressor/zftape-compress.c
deleted file mode 100644
index 65ffc0be3df9..000000000000
--- a/drivers/char/ftape/compressor/zftape-compress.c
+++ /dev/null
@@ -1,1203 +0,0 @@
1/*
2 * Copyright (C) 1994-1997 Claus-Justus Heine
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License as
6 published by the Free Software Foundation; either version 2, or (at
7 your option) any later version.
8
9 This program is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
17 USA.
18
19 *
20 * This file implements a "generic" interface between the *
21 * zftape-driver and a compression-algorithm. The *
22 * compression-algorithm currently used is a LZ77. I use the *
23 * implementation lzrw3 by Ross N. Williams (Renaissance *
24 * Software). The compression program itself is in the file
25 * lzrw3.c * and lzrw3.h. To adopt another compression algorithm
26 * the functions * zft_compress() and zft_uncompress() must be
27 * changed * appropriately. See below.
28 */
29
30#include <linux/errno.h>
31#include <linux/mm.h>
32#include <linux/module.h>
33
34#include <linux/zftape.h>
35
36#include <asm/uaccess.h>
37
38#include "../zftape/zftape-init.h"
39#include "../zftape/zftape-eof.h"
40#include "../zftape/zftape-ctl.h"
41#include "../zftape/zftape-write.h"
42#include "../zftape/zftape-read.h"
43#include "../zftape/zftape-rw.h"
44#include "../compressor/zftape-compress.h"
45#include "../zftape/zftape-vtbl.h"
46#include "../compressor/lzrw3.h"
47
48/*
49 * global variables
50 */
51
52/* I handle the allocation of this buffer as a special case, because
53 * it's size varies depending on the tape length inserted.
54 */
55
56/* local variables
57 */
58static void *zftc_wrk_mem = NULL;
59static __u8 *zftc_buf = NULL;
60static void *zftc_scratch_buf = NULL;
61
62/* compression statistics
63 */
64static unsigned int zftc_wr_uncompressed = 0;
65static unsigned int zftc_wr_compressed = 0;
66static unsigned int zftc_rd_uncompressed = 0;
67static unsigned int zftc_rd_compressed = 0;
68
69/* forward */
70static int zftc_write(int *write_cnt,
71 __u8 *dst_buf, const int seg_sz,
72 const __u8 __user *src_buf, const int req_len,
73 const zft_position *pos, const zft_volinfo *volume);
74static int zftc_read(int *read_cnt,
75 __u8 __user *dst_buf, const int to_do,
76 const __u8 *src_buf, const int seg_sz,
77 const zft_position *pos, const zft_volinfo *volume);
78static int zftc_seek(unsigned int new_block_pos,
79 zft_position *pos, const zft_volinfo *volume,
80 __u8 *buffer);
81static void zftc_lock (void);
82static void zftc_reset (void);
83static void zftc_cleanup(void);
84static void zftc_stats (void);
85
86/* compressed segment. This conforms to QIC-80-MC, Revision K.
87 *
88 * Rev. K applies to tapes with `fixed length format' which is
89 * indicated by format code 2,3 and 5. See below for format code 4 and 6
90 *
91 * 2 bytes: offset of compression segment structure
92 * 29k > offset >= 29k-18: data from previous segment ens in this
93 * segment and no compressed block starts
94 * in this segment
95 * offset == 0: data from previous segment occupies entire
96 * segment and continues in next segment
97 * n bytes: remainder from previous segment
98 *
99 * Rev. K:
100 * 4 bytes: 4 bytes: files set byte offset
101 * Post Rev. K and QIC-3020/3020:
102 * 8 bytes: 8 bytes: files set byte offset
103 * 2 bytes: byte count N (amount of data following)
104 * bit 15 is set if data is compressed, bit 15 is not
105 * set if data is uncompressed
106 * N bytes: data (as much as specified in the byte count)
107 * 2 bytes: byte count N_1 of next cluster
108 * N_1 bytes: data of next cluset
109 * 2 bytes: byte count N_2 of next cluster
110 * N_2 bytes: ...
111 *
112 * Note that the `N' byte count accounts only for the bytes that in the
113 * current segment if the cluster spans to the next segment.
114 */
115
116typedef struct
117{
118 int cmpr_pos; /* actual position in compression buffer */
119 int cmpr_sz; /* what is left in the compression buffer
120 * when copying the compressed data to the
121 * deblock buffer
122 */
123 unsigned int first_block; /* location of header information in
124 * this segment
125 */
126 unsigned int count; /* amount of data of current block
127 * contained in current segment
128 */
129 unsigned int offset; /* offset in current segment */
130 unsigned int spans:1; /* might continue in next segment */
131 unsigned int uncmpr; /* 0x8000 if this block contains
132 * uncompressed data
133 */
134 __s64 foffs; /* file set byte offset, same as in
135 * compression map segment
136 */
137} cmpr_info;
138
139static cmpr_info cseg; /* static data. Must be kept uptodate and shared by
140 * read, write and seek functions
141 */
142
143#define DUMP_CMPR_INFO(level, msg, info) \
144 TRACE(level, msg "\n" \
145 KERN_INFO "cmpr_pos : %d\n" \
146 KERN_INFO "cmpr_sz : %d\n" \
147 KERN_INFO "first_block: %d\n" \
148 KERN_INFO "count : %d\n" \
149 KERN_INFO "offset : %d\n" \
150 KERN_INFO "spans : %d\n" \
151 KERN_INFO "uncmpr : 0x%04x\n" \
152 KERN_INFO "foffs : " LL_X, \
153 (info)->cmpr_pos, (info)->cmpr_sz, (info)->first_block, \
154 (info)->count, (info)->offset, (info)->spans == 1, \
155 (info)->uncmpr, LL((info)->foffs))
156
157/* dispatch compression segment info, return error code
158 *
159 * afterwards, cseg->offset points to start of data of the NEXT
160 * compressed block, and cseg->count contains the amount of data
161 * left in the actual compressed block. cseg->spans is set to 1 if
162 * the block is continued in the following segment. Otherwise it is
163 * set to 0.
164 */
165static int get_cseg (cmpr_info *cinfo, const __u8 *buff,
166 const unsigned int seg_sz,
167 const zft_volinfo *volume)
168{
169 TRACE_FUN(ft_t_flow);
170
171 cinfo->first_block = GET2(buff, 0);
172 if (cinfo->first_block == 0) { /* data spans to next segment */
173 cinfo->count = seg_sz - sizeof(__u16);
174 cinfo->offset = seg_sz;
175 cinfo->spans = 1;
176 } else { /* cluster definetely ends in this segment */
177 if (cinfo->first_block > seg_sz) {
178 /* data corrupted */
179 TRACE_ABORT(-EIO, ft_t_err, "corrupted data:\n"
180 KERN_INFO "segment size: %d\n"
181 KERN_INFO "first block : %d",
182 seg_sz, cinfo->first_block);
183 }
184 cinfo->count = cinfo->first_block - sizeof(__u16);
185 cinfo->offset = cinfo->first_block;
186 cinfo->spans = 0;
187 }
188 /* now get the offset the first block should have in the
189 * uncompressed data stream.
190 *
191 * For this magic `18' refer to CRF-3 standard or QIC-80MC,
192 * Rev. K.
193 */
194 if ((seg_sz - cinfo->offset) > 18) {
195 if (volume->qic113) { /* > revision K */
196 TRACE(ft_t_data_flow, "New QIC-113 compliance");
197 cinfo->foffs = GET8(buff, cinfo->offset);
198 cinfo->offset += sizeof(__s64);
199 } else {
200 TRACE(/* ft_t_data_flow */ ft_t_noise, "pre QIC-113 version");
201 cinfo->foffs = (__s64)GET4(buff, cinfo->offset);
202 cinfo->offset += sizeof(__u32);
203 }
204 }
205 if (cinfo->foffs > volume->size) {
206 TRACE_ABORT(-EIO, ft_t_err, "Inconsistency:\n"
207 KERN_INFO "offset in current volume: %d\n"
208 KERN_INFO "size of current volume : %d",
209 (int)(cinfo->foffs>>10), (int)(volume->size>>10));
210 }
211 if (cinfo->cmpr_pos + cinfo->count > volume->blk_sz) {
212 TRACE_ABORT(-EIO, ft_t_err, "Inconsistency:\n"
213 KERN_INFO "block size : %d\n"
214 KERN_INFO "data record: %d",
215 volume->blk_sz, cinfo->cmpr_pos + cinfo->count);
216 }
217 DUMP_CMPR_INFO(ft_t_noise /* ft_t_any */, "", cinfo);
218 TRACE_EXIT 0;
219}
220
221/* This one is called, when a new cluster starts in same segment.
222 *
223 * Note: if this is the first cluster in the current segment, we must
224 * not check whether there are more than 18 bytes available because
225 * this have already been done in get_cseg() and there may be less
226 * than 18 bytes available due to header information.
227 *
228 */
229static void get_next_cluster(cmpr_info *cluster, const __u8 *buff,
230 const int seg_sz, const int finish)
231{
232 TRACE_FUN(ft_t_flow);
233
234 if (seg_sz - cluster->offset > 18 || cluster->foffs != 0) {
235 cluster->count = GET2(buff, cluster->offset);
236 cluster->uncmpr = cluster->count & 0x8000;
237 cluster->count -= cluster->uncmpr;
238 cluster->offset += sizeof(__u16);
239 cluster->foffs = 0;
240 if ((cluster->offset + cluster->count) < seg_sz) {
241 cluster->spans = 0;
242 } else if (cluster->offset + cluster->count == seg_sz) {
243 cluster->spans = !finish;
244 } else {
245 /* either an error or a volume written by an
246 * old version. If this is a data error, then we'll
247 * catch it later.
248 */
249 TRACE(ft_t_data_flow, "Either error or old volume");
250 cluster->spans = 1;
251 cluster->count = seg_sz - cluster->offset;
252 }
253 } else {
254 cluster->count = 0;
255 cluster->spans = 0;
256 cluster->foffs = 0;
257 }
258 DUMP_CMPR_INFO(ft_t_noise /* ft_t_any */ , "", cluster);
259 TRACE_EXIT;
260}
261
262static void zftc_lock(void)
263{
264}
265
266/* this function is needed for zftape_reset_position in zftape-io.c
267 */
268static void zftc_reset(void)
269{
270 TRACE_FUN(ft_t_flow);
271
272 memset((void *)&cseg, '\0', sizeof(cseg));
273 zftc_stats();
274 TRACE_EXIT;
275}
276
277static int cmpr_mem_initialized = 0;
278static unsigned int alloc_blksz = 0;
279
280static int zft_allocate_cmpr_mem(unsigned int blksz)
281{
282 TRACE_FUN(ft_t_flow);
283
284 if (cmpr_mem_initialized && blksz == alloc_blksz) {
285 TRACE_EXIT 0;
286 }
287 TRACE_CATCH(zft_vmalloc_once(&zftc_wrk_mem, CMPR_WRK_MEM_SIZE),
288 zftc_cleanup());
289 TRACE_CATCH(zft_vmalloc_always(&zftc_buf, blksz + CMPR_OVERRUN),
290 zftc_cleanup());
291 alloc_blksz = blksz;
292 TRACE_CATCH(zft_vmalloc_always(&zftc_scratch_buf, blksz+CMPR_OVERRUN),
293 zftc_cleanup());
294 cmpr_mem_initialized = 1;
295 TRACE_EXIT 0;
296}
297
298static void zftc_cleanup(void)
299{
300 TRACE_FUN(ft_t_flow);
301
302 zft_vfree(&zftc_wrk_mem, CMPR_WRK_MEM_SIZE);
303 zft_vfree(&zftc_buf, alloc_blksz + CMPR_OVERRUN);
304 zft_vfree(&zftc_scratch_buf, alloc_blksz + CMPR_OVERRUN);
305 cmpr_mem_initialized = alloc_blksz = 0;
306 TRACE_EXIT;
307}
308
309/*****************************************************************************
310 * *
311 * The following two functions "ftape_compress()" and *
312 * "ftape_uncompress()" are the interface to the actual compression *
313 * algorithm (i.e. they are calling the "compress()" function from *
314 * the lzrw3 package for now). These routines could quite easily be *
315 * changed to adopt another compression algorithm instead of lzrw3, *
316 * which currently is used. *
317 * *
318 *****************************************************************************/
319
320/* called by zft_compress_write() to perform the compression. Must
321 * return the size of the compressed data.
322 *
323 * NOTE: The size of the compressed data should not exceed the size of
324 * the uncompressed data. Most compression algorithms have means
325 * to store data unchanged if the "compressed" data amount would
326 * exceed the original one. Mostly this is done by storing some
327 * flag-bytes in front of the compressed data to indicate if it
328 * is compressed or not. Thus the worst compression result
329 * length is the original length plus those flag-bytes.
330 *
331 * We don't want that, as the QIC-80 standard provides a means
332 * of marking uncompressed blocks by simply setting bit 15 of
333 * the compressed block's length. Thus a compessed block can
334 * have at most a length of 2^15-1 bytes. The QIC-80 standard
335 * restricts the block-length even further, allowing only 29k -
336 * 6 bytes.
337 *
338 * Currently, the maximum blocksize used by zftape is 28k.
339 *
340 * In short: don't exceed the length of the input-package, set
341 * bit 15 of the compressed size to 1 if you have copied data
342 * instead of compressing it.
343 */
344static int zft_compress(__u8 *in_buffer, unsigned int in_sz, __u8 *out_buffer)
345{
346 __s32 compressed_sz;
347 TRACE_FUN(ft_t_flow);
348
349
350 lzrw3_compress(COMPRESS_ACTION_COMPRESS, zftc_wrk_mem,
351 in_buffer, in_sz, out_buffer, &compressed_sz);
352 if (TRACE_LEVEL >= ft_t_info) {
353 /* the compiler will optimize this away when
354 * compiled with NO_TRACE_AT_ALL option
355 */
356 TRACE(ft_t_data_flow, "\n"
357 KERN_INFO "before compression: %d bytes\n"
358 KERN_INFO "after compresison : %d bytes",
359 in_sz,
360 (int)(compressed_sz < 0
361 ? -compressed_sz : compressed_sz));
362 /* for statistical purposes
363 */
364 zftc_wr_compressed += (compressed_sz < 0
365 ? -compressed_sz : compressed_sz);
366 zftc_wr_uncompressed += in_sz;
367 }
368 TRACE_EXIT (int)compressed_sz;
369}
370
371/* called by zft_compress_read() to decompress the data. Must
372 * return the size of the decompressed data for sanity checks
373 * (compared with zft_blk_sz)
374 *
375 * NOTE: Read the note for zft_compress() above! If bit 15 of the
376 * parameter in_sz is set, then the data in in_buffer isn't
377 * compressed, which must be handled by the un-compression
378 * algorithm. (I changed lzrw3 to handle this.)
379 *
380 * The parameter max_out_sz is needed to prevent buffer overruns when
381 * uncompressing corrupt data.
382 */
383static unsigned int zft_uncompress(__u8 *in_buffer,
384 int in_sz,
385 __u8 *out_buffer,
386 unsigned int max_out_sz)
387{
388 TRACE_FUN(ft_t_flow);
389
390 lzrw3_compress(COMPRESS_ACTION_DECOMPRESS, zftc_wrk_mem,
391 in_buffer, (__s32)in_sz,
392 out_buffer, (__u32 *)&max_out_sz);
393
394 if (TRACE_LEVEL >= ft_t_info) {
395 TRACE(ft_t_data_flow, "\n"
396 KERN_INFO "before decompression: %d bytes\n"
397 KERN_INFO "after decompression : %d bytes",
398 in_sz < 0 ? -in_sz : in_sz,(int)max_out_sz);
399 /* for statistical purposes
400 */
401 zftc_rd_compressed += in_sz < 0 ? -in_sz : in_sz;
402 zftc_rd_uncompressed += max_out_sz;
403 }
404 TRACE_EXIT (unsigned int)max_out_sz;
405}
406
407/* print some statistics about the efficiency of the compression to
408 * the kernel log
409 */
410static void zftc_stats(void)
411{
412 TRACE_FUN(ft_t_flow);
413
414 if (TRACE_LEVEL < ft_t_info) {
415 TRACE_EXIT;
416 }
417 if (zftc_wr_uncompressed != 0) {
418 if (zftc_wr_compressed > (1<<14)) {
419 TRACE(ft_t_info, "compression statistics (writing):\n"
420 KERN_INFO " compr./uncmpr. : %3d %%",
421 (((zftc_wr_compressed>>10) * 100)
422 / (zftc_wr_uncompressed>>10)));
423 } else {
424 TRACE(ft_t_info, "compression statistics (writing):\n"
425 KERN_INFO " compr./uncmpr. : %3d %%",
426 ((zftc_wr_compressed * 100)
427 / zftc_wr_uncompressed));
428 }
429 }
430 if (zftc_rd_uncompressed != 0) {
431 if (zftc_rd_compressed > (1<<14)) {
432 TRACE(ft_t_info, "compression statistics (reading):\n"
433 KERN_INFO " compr./uncmpr. : %3d %%",
434 (((zftc_rd_compressed>>10) * 100)
435 / (zftc_rd_uncompressed>>10)));
436 } else {
437 TRACE(ft_t_info, "compression statistics (reading):\n"
438 KERN_INFO " compr./uncmpr. : %3d %%",
439 ((zftc_rd_compressed * 100)
440 / zftc_rd_uncompressed));
441 }
442 }
443 /* only print it once: */
444 zftc_wr_uncompressed =
445 zftc_wr_compressed =
446 zftc_rd_uncompressed =
447 zftc_rd_compressed = 0;
448 TRACE_EXIT;
449}
450
451/* start new compressed block
452 */
453static int start_new_cseg(cmpr_info *cluster,
454 char *dst_buf,
455 const zft_position *pos,
456 const unsigned int blk_sz,
457 const char *src_buf,
458 const int this_segs_sz,
459 const int qic113)
460{
461 int size_left;
462 int cp_cnt;
463 int buf_pos;
464 TRACE_FUN(ft_t_flow);
465
466 size_left = this_segs_sz - sizeof(__u16) - cluster->cmpr_sz;
467 TRACE(ft_t_data_flow,"\n"
468 KERN_INFO "segment size : %d\n"
469 KERN_INFO "compressed_sz: %d\n"
470 KERN_INFO "size_left : %d",
471 this_segs_sz, cluster->cmpr_sz, size_left);
472 if (size_left > 18) { /* start a new cluseter */
473 cp_cnt = cluster->cmpr_sz;
474 cluster->cmpr_sz = 0;
475 buf_pos = cp_cnt + sizeof(__u16);
476 PUT2(dst_buf, 0, buf_pos);
477
478 if (qic113) {
479 __s64 foffs = pos->volume_pos;
480 if (cp_cnt) foffs += (__s64)blk_sz;
481
482 TRACE(ft_t_data_flow, "new style QIC-113 header");
483 PUT8(dst_buf, buf_pos, foffs);
484 buf_pos += sizeof(__s64);
485 } else {
486 __u32 foffs = (__u32)pos->volume_pos;
487 if (cp_cnt) foffs += (__u32)blk_sz;
488
489 TRACE(ft_t_data_flow, "old style QIC-80MC header");
490 PUT4(dst_buf, buf_pos, foffs);
491 buf_pos += sizeof(__u32);
492 }
493 } else if (size_left >= 0) {
494 cp_cnt = cluster->cmpr_sz;
495 cluster->cmpr_sz = 0;
496 buf_pos = cp_cnt + sizeof(__u16);
497 PUT2(dst_buf, 0, buf_pos);
498 /* zero unused part of segment. */
499 memset(dst_buf + buf_pos, '\0', size_left);
500 buf_pos = this_segs_sz;
501 } else { /* need entire segment and more space */
502 PUT2(dst_buf, 0, 0);
503 cp_cnt = this_segs_sz - sizeof(__u16);
504 cluster->cmpr_sz -= cp_cnt;
505 buf_pos = this_segs_sz;
506 }
507 memcpy(dst_buf + sizeof(__u16), src_buf + cluster->cmpr_pos, cp_cnt);
508 cluster->cmpr_pos += cp_cnt;
509 TRACE_EXIT buf_pos;
510}
511
512/* return-value: the number of bytes removed from the user-buffer
513 * `src_buf' or error code
514 *
515 * int *write_cnt : how much actually has been moved to the
516 * dst_buf. Need not be initialized when
517 * function returns with an error code
518 * (negativ return value)
519 * __u8 *dst_buf : kernel space buffer where the has to be
520 * copied to. The contents of this buffers
521 * goes to a specific segment.
522 * const int seg_sz : the size of the segment dst_buf will be
523 * copied to.
524 * const zft_position *pos : struct containing the coordinates in
525 * the current volume (byte position,
526 * segment id of current segment etc)
527 * const zft_volinfo *volume: information about the current volume,
528 * size etc.
529 * const __u8 *src_buf : user space buffer that contains the
530 * data the user wants to be written to
531 * tape.
532 * const int req_len : the amount of data the user wants to be
533 * written to tape.
534 */
535static int zftc_write(int *write_cnt,
536 __u8 *dst_buf, const int seg_sz,
537 const __u8 __user *src_buf, const int req_len,
538 const zft_position *pos, const zft_volinfo *volume)
539{
540 int req_len_left = req_len;
541 int result;
542 int len_left;
543 int buf_pos_write = pos->seg_byte_pos;
544 TRACE_FUN(ft_t_flow);
545
546 /* Note: we do not unlock the module because
547 * there are some values cached in that `cseg' variable. We
548 * don't don't want to use this information when being
549 * unloaded by kerneld even when the tape is full or when we
550 * cannot allocate enough memory.
551 */
552 if (pos->tape_pos > (volume->size-volume->blk_sz-ZFT_CMPR_OVERHEAD)) {
553 TRACE_EXIT -ENOSPC;
554 }
555 if (zft_allocate_cmpr_mem(volume->blk_sz) < 0) {
556 /* should we unlock the module? But it shouldn't
557 * be locked anyway ...
558 */
559 TRACE_EXIT -ENOMEM;
560 }
561 if (buf_pos_write == 0) { /* fill a new segment */
562 *write_cnt = buf_pos_write = start_new_cseg(&cseg,
563 dst_buf,
564 pos,
565 volume->blk_sz,
566 zftc_buf,
567 seg_sz,
568 volume->qic113);
569 if (cseg.cmpr_sz == 0 && cseg.cmpr_pos != 0) {
570 req_len_left -= result = volume->blk_sz;
571 cseg.cmpr_pos = 0;
572 } else {
573 result = 0;
574 }
575 } else {
576 *write_cnt = result = 0;
577 }
578
579 len_left = seg_sz - buf_pos_write;
580 while ((req_len_left > 0) && (len_left > 18)) {
581 /* now we have some size left for a new compressed
582 * block. We know, that the compression buffer is
583 * empty (else there wouldn't be any space left).
584 */
585 if (copy_from_user(zftc_scratch_buf, src_buf + result,
586 volume->blk_sz) != 0) {
587 TRACE_EXIT -EFAULT;
588 }
589 req_len_left -= volume->blk_sz;
590 cseg.cmpr_sz = zft_compress(zftc_scratch_buf, volume->blk_sz,
591 zftc_buf);
592 if (cseg.cmpr_sz < 0) {
593 cseg.uncmpr = 0x8000;
594 cseg.cmpr_sz = -cseg.cmpr_sz;
595 } else {
596 cseg.uncmpr = 0;
597 }
598 /* increment "result" iff we copied the entire
599 * compressed block to the zft_deblock_buf
600 */
601 len_left -= sizeof(__u16);
602 if (len_left >= cseg.cmpr_sz) {
603 len_left -= cseg.count = cseg.cmpr_sz;
604 cseg.cmpr_pos = cseg.cmpr_sz = 0;
605 result += volume->blk_sz;
606 } else {
607 cseg.cmpr_sz -=
608 cseg.cmpr_pos =
609 cseg.count = len_left;
610 len_left = 0;
611 }
612 PUT2(dst_buf, buf_pos_write, cseg.uncmpr | cseg.count);
613 buf_pos_write += sizeof(__u16);
614 memcpy(dst_buf + buf_pos_write, zftc_buf, cseg.count);
615 buf_pos_write += cseg.count;
616 *write_cnt += cseg.count + sizeof(__u16);
617 FT_SIGNAL_EXIT(_DONT_BLOCK);
618 }
619 /* erase the remainder of the segment if less than 18 bytes
620 * left (18 bytes is due to the QIC-80 standard)
621 */
622 if (len_left <= 18) {
623 memset(dst_buf + buf_pos_write, '\0', len_left);
624 (*write_cnt) += len_left;
625 }
626 TRACE(ft_t_data_flow, "returning %d", result);
627 TRACE_EXIT result;
628}
629
630/* out:
631 *
632 * int *read_cnt: the number of bytes we removed from the zft_deblock_buf
633 * (result)
634 * int *to_do : the remaining size of the read-request.
635 *
636 * in:
637 *
638 * char *buff : buff is the address of the upper part of the user
639 * buffer, that hasn't been filled with data yet.
640
641 * int buf_pos_read : copy of from _ftape_read()
642 * int buf_len_read : copy of buf_len_rd from _ftape_read()
643 * char *zft_deblock_buf: zft_deblock_buf
644 * unsigned short blk_sz: the block size valid for this volume, may differ
645 * from zft_blk_sz.
646 * int finish: if != 0 means that this is the last segment belonging
647 * to this volume
648 * returns the amount of data actually copied to the user-buffer
649 *
650 * to_do MUST NOT SHRINK except to indicate an EOF. In this case *to_do has to
651 * be set to 0
652 */
653static int zftc_read (int *read_cnt,
654 __u8 __user *dst_buf, const int to_do,
655 const __u8 *src_buf, const int seg_sz,
656 const zft_position *pos, const zft_volinfo *volume)
657{
658 int uncompressed_sz;
659 int result = 0;
660 int remaining = to_do;
661 TRACE_FUN(ft_t_flow);
662
663 TRACE_CATCH(zft_allocate_cmpr_mem(volume->blk_sz),);
664 if (pos->seg_byte_pos == 0) {
665 /* new segment just read
666 */
667 TRACE_CATCH(get_cseg(&cseg, src_buf, seg_sz, volume),
668 *read_cnt = 0);
669 memcpy(zftc_buf + cseg.cmpr_pos, src_buf + sizeof(__u16),
670 cseg.count);
671 cseg.cmpr_pos += cseg.count;
672 *read_cnt = cseg.offset;
673 DUMP_CMPR_INFO(ft_t_noise /* ft_t_any */, "", &cseg);
674 } else {
675 *read_cnt = 0;
676 }
677 /* loop and uncompress until user buffer full or
678 * deblock-buffer empty
679 */
680 TRACE(ft_t_data_flow, "compressed_sz: %d, compos : %d, *read_cnt: %d",
681 cseg.cmpr_sz, cseg.cmpr_pos, *read_cnt);
682 while ((cseg.spans == 0) && (remaining > 0)) {
683 if (cseg.cmpr_pos != 0) { /* cmpr buf is not empty */
684 uncompressed_sz =
685 zft_uncompress(zftc_buf,
686 cseg.uncmpr == 0x8000 ?
687 -cseg.cmpr_pos : cseg.cmpr_pos,
688 zftc_scratch_buf,
689 volume->blk_sz);
690 if (uncompressed_sz != volume->blk_sz) {
691 *read_cnt = 0;
692 TRACE_ABORT(-EIO, ft_t_warn,
693 "Uncompressed blk (%d) != blk size (%d)",
694 uncompressed_sz, volume->blk_sz);
695 }
696 if (copy_to_user(dst_buf + result,
697 zftc_scratch_buf,
698 uncompressed_sz) != 0 ) {
699 TRACE_EXIT -EFAULT;
700 }
701 remaining -= uncompressed_sz;
702 result += uncompressed_sz;
703 cseg.cmpr_pos = 0;
704 }
705 if (remaining > 0) {
706 get_next_cluster(&cseg, src_buf, seg_sz,
707 volume->end_seg == pos->seg_pos);
708 if (cseg.count != 0) {
709 memcpy(zftc_buf, src_buf + cseg.offset,
710 cseg.count);
711 cseg.cmpr_pos = cseg.count;
712 cseg.offset += cseg.count;
713 *read_cnt += cseg.count + sizeof(__u16);
714 } else {
715 remaining = 0;
716 }
717 }
718 TRACE(ft_t_data_flow, "\n"
719 KERN_INFO "compressed_sz: %d\n"
720 KERN_INFO "compos : %d\n"
721 KERN_INFO "*read_cnt : %d",
722 cseg.cmpr_sz, cseg.cmpr_pos, *read_cnt);
723 }
724 if (seg_sz - cseg.offset <= 18) {
725 *read_cnt += seg_sz - cseg.offset;
726 TRACE(ft_t_data_flow, "expanding read cnt to: %d", *read_cnt);
727 }
728 TRACE(ft_t_data_flow, "\n"
729 KERN_INFO "segment size : %d\n"
730 KERN_INFO "read count : %d\n"
731 KERN_INFO "buf_pos_read : %d\n"
732 KERN_INFO "remaining : %d",
733 seg_sz, *read_cnt, pos->seg_byte_pos,
734 seg_sz - *read_cnt - pos->seg_byte_pos);
735 TRACE(ft_t_data_flow, "returning: %d", result);
736 TRACE_EXIT result;
737}
738
739/* seeks to the new data-position. Reads sometimes a segment.
740 *
741 * start_seg and end_seg give the boundaries of the current volume
742 * blk_sz is the blk_sz of the current volume as stored in the
743 * volume label
744 *
745 * We don't allow blocksizes less than 1024 bytes, therefore we don't need
746 * a 64 bit argument for new_block_pos.
747 */
748
749static int seek_in_segment(const unsigned int to_do, cmpr_info *c_info,
750 const char *src_buf, const int seg_sz,
751 const int seg_pos, const zft_volinfo *volume);
752static int slow_seek_forward_until_error(const unsigned int distance,
753 cmpr_info *c_info, zft_position *pos,
754 const zft_volinfo *volume, __u8 *buf);
755static int search_valid_segment(unsigned int segment,
756 const unsigned int end_seg,
757 const unsigned int max_foffs,
758 zft_position *pos, cmpr_info *c_info,
759 const zft_volinfo *volume, __u8 *buf);
760static int slow_seek_forward(unsigned int dest, cmpr_info *c_info,
761 zft_position *pos, const zft_volinfo *volume,
762 __u8 *buf);
763static int compute_seg_pos(unsigned int dest, zft_position *pos,
764 const zft_volinfo *volume);
765
766#define ZFT_SLOW_SEEK_THRESHOLD 10 /* segments */
767#define ZFT_FAST_SEEK_MAX_TRIALS 10 /* times */
768#define ZFT_FAST_SEEK_BACKUP 10 /* segments */
769
770static int zftc_seek(unsigned int new_block_pos,
771 zft_position *pos, const zft_volinfo *volume, __u8 *buf)
772{
773 unsigned int dest;
774 int limit;
775 int distance;
776 int result = 0;
777 int seg_dist;
778 int new_seg;
779 int old_seg = 0;
780 int fast_seek_trials = 0;
781 TRACE_FUN(ft_t_flow);
782
783 if (new_block_pos == 0) {
784 pos->seg_pos = volume->start_seg;
785 pos->seg_byte_pos = 0;
786 pos->volume_pos = 0;
787 zftc_reset();
788 TRACE_EXIT 0;
789 }
790 dest = new_block_pos * (volume->blk_sz >> 10);
791 distance = dest - (pos->volume_pos >> 10);
792 while (distance != 0) {
793 seg_dist = compute_seg_pos(dest, pos, volume);
794 TRACE(ft_t_noise, "\n"
795 KERN_INFO "seg_dist: %d\n"
796 KERN_INFO "distance: %d\n"
797 KERN_INFO "dest : %d\n"
798 KERN_INFO "vpos : %d\n"
799 KERN_INFO "seg_pos : %d\n"
800 KERN_INFO "trials : %d",
801 seg_dist, distance, dest,
802 (unsigned int)(pos->volume_pos>>10), pos->seg_pos,
803 fast_seek_trials);
804 if (distance > 0) {
805 if (seg_dist < 0) {
806 TRACE(ft_t_bug, "BUG: distance %d > 0, "
807 "segment difference %d < 0",
808 distance, seg_dist);
809 result = -EIO;
810 break;
811 }
812 new_seg = pos->seg_pos + seg_dist;
813 if (new_seg > volume->end_seg) {
814 new_seg = volume->end_seg;
815 }
816 if (old_seg == new_seg || /* loop */
817 seg_dist <= ZFT_SLOW_SEEK_THRESHOLD ||
818 fast_seek_trials >= ZFT_FAST_SEEK_MAX_TRIALS) {
819 TRACE(ft_t_noise, "starting slow seek:\n"
820 KERN_INFO "fast seek failed too often: %s\n"
821 KERN_INFO "near target position : %s\n"
822 KERN_INFO "looping between two segs : %s",
823 (fast_seek_trials >=
824 ZFT_FAST_SEEK_MAX_TRIALS)
825 ? "yes" : "no",
826 (seg_dist <= ZFT_SLOW_SEEK_THRESHOLD)
827 ? "yes" : "no",
828 (old_seg == new_seg)
829 ? "yes" : "no");
830 result = slow_seek_forward(dest, &cseg,
831 pos, volume, buf);
832 break;
833 }
834 old_seg = new_seg;
835 limit = volume->end_seg;
836 fast_seek_trials ++;
837 for (;;) {
838 result = search_valid_segment(new_seg, limit,
839 volume->size,
840 pos, &cseg,
841 volume, buf);
842 if (result == 0 || result == -EINTR) {
843 break;
844 }
845 if (new_seg == volume->start_seg) {
846 result = -EIO; /* set errror
847 * condition
848 */
849 break;
850 }
851 limit = new_seg;
852 new_seg -= ZFT_FAST_SEEK_BACKUP;
853 if (new_seg < volume->start_seg) {
854 new_seg = volume->start_seg;
855 }
856 }
857 if (result < 0) {
858 TRACE(ft_t_warn,
859 "Couldn't find a readable segment");
860 break;
861 }
862 } else /* if (distance < 0) */ {
863 if (seg_dist > 0) {
864 TRACE(ft_t_bug, "BUG: distance %d < 0, "
865 "segment difference %d >0",
866 distance, seg_dist);
867 result = -EIO;
868 break;
869 }
870 new_seg = pos->seg_pos + seg_dist;
871 if (fast_seek_trials > 0 && seg_dist == 0) {
872 /* this avoids sticking to the same
873 * segment all the time. On the other hand:
874 * if we got here for the first time, and the
875 * deblock_buffer still contains a valid
876 * segment, then there is no need to skip to
877 * the previous segment if the desired position
878 * is inside this segment.
879 */
880 new_seg --;
881 }
882 if (new_seg < volume->start_seg) {
883 new_seg = volume->start_seg;
884 }
885 limit = pos->seg_pos;
886 fast_seek_trials ++;
887 for (;;) {
888 result = search_valid_segment(new_seg, limit,
889 pos->volume_pos,
890 pos, &cseg,
891 volume, buf);
892 if (result == 0 || result == -EINTR) {
893 break;
894 }
895 if (new_seg == volume->start_seg) {
896 result = -EIO; /* set errror
897 * condition
898 */
899 break;
900 }
901 limit = new_seg;
902 new_seg -= ZFT_FAST_SEEK_BACKUP;
903 if (new_seg < volume->start_seg) {
904 new_seg = volume->start_seg;
905 }
906 }
907 if (result < 0) {
908 TRACE(ft_t_warn,
909 "Couldn't find a readable segment");
910 break;
911 }
912 }
913 distance = dest - (pos->volume_pos >> 10);
914 }
915 TRACE_EXIT result;
916}
917
918
919/* advance inside the given segment at most to_do bytes.
920 * of kilobytes moved
921 */
922
923static int seek_in_segment(const unsigned int to_do,
924 cmpr_info *c_info,
925 const char *src_buf,
926 const int seg_sz,
927 const int seg_pos,
928 const zft_volinfo *volume)
929{
930 int result = 0;
931 int blk_sz = volume->blk_sz >> 10;
932 int remaining = to_do;
933 TRACE_FUN(ft_t_flow);
934
935 if (c_info->offset == 0) {
936 /* new segment just read
937 */
938 TRACE_CATCH(get_cseg(c_info, src_buf, seg_sz, volume),);
939 c_info->cmpr_pos += c_info->count;
940 DUMP_CMPR_INFO(ft_t_noise, "", c_info);
941 }
942 /* loop and uncompress until user buffer full or
943 * deblock-buffer empty
944 */
945 TRACE(ft_t_noise, "compressed_sz: %d, compos : %d",
946 c_info->cmpr_sz, c_info->cmpr_pos);
947 while (c_info->spans == 0 && remaining > 0) {
948 if (c_info->cmpr_pos != 0) { /* cmpr buf is not empty */
949 result += blk_sz;
950 remaining -= blk_sz;
951 c_info->cmpr_pos = 0;
952 }
953 if (remaining > 0) {
954 get_next_cluster(c_info, src_buf, seg_sz,
955 volume->end_seg == seg_pos);
956 if (c_info->count != 0) {
957 c_info->cmpr_pos = c_info->count;
958 c_info->offset += c_info->count;
959 } else {
960 break;
961 }
962 }
963 /* Allow escape from this loop on signal!
964 */
965 FT_SIGNAL_EXIT(_DONT_BLOCK);
966 DUMP_CMPR_INFO(ft_t_noise, "", c_info);
967 TRACE(ft_t_noise, "to_do: %d", remaining);
968 }
969 if (seg_sz - c_info->offset <= 18) {
970 c_info->offset = seg_sz;
971 }
972 TRACE(ft_t_noise, "\n"
973 KERN_INFO "segment size : %d\n"
974 KERN_INFO "buf_pos_read : %d\n"
975 KERN_INFO "remaining : %d",
976 seg_sz, c_info->offset,
977 seg_sz - c_info->offset);
978 TRACE_EXIT result;
979}
980
981static int slow_seek_forward_until_error(const unsigned int distance,
982 cmpr_info *c_info,
983 zft_position *pos,
984 const zft_volinfo *volume,
985 __u8 *buf)
986{
987 unsigned int remaining = distance;
988 int seg_sz;
989 int seg_pos;
990 int result;
991 TRACE_FUN(ft_t_flow);
992
993 seg_pos = pos->seg_pos;
994 do {
995 TRACE_CATCH(seg_sz = zft_fetch_segment(seg_pos, buf,
996 FT_RD_AHEAD),);
997 /* now we have the contents of the actual segment in
998 * the deblock buffer
999 */
1000 TRACE_CATCH(result = seek_in_segment(remaining, c_info, buf,
1001 seg_sz, seg_pos,volume),);
1002 remaining -= result;
1003 pos->volume_pos += result<<10;
1004 pos->seg_pos = seg_pos;
1005 pos->seg_byte_pos = c_info->offset;
1006 seg_pos ++;
1007 if (seg_pos <= volume->end_seg && c_info->offset == seg_sz) {
1008 pos->seg_pos ++;
1009 pos->seg_byte_pos = 0;
1010 c_info->offset = 0;
1011 }
1012 /* Allow escape from this loop on signal!
1013 */
1014 FT_SIGNAL_EXIT(_DONT_BLOCK);
1015 TRACE(ft_t_noise, "\n"
1016 KERN_INFO "remaining: %d\n"
1017 KERN_INFO "seg_pos: %d\n"
1018 KERN_INFO "end_seg: %d\n"
1019 KERN_INFO "result: %d",
1020 remaining, seg_pos, volume->end_seg, result);
1021 } while (remaining > 0 && seg_pos <= volume->end_seg);
1022 TRACE_EXIT 0;
1023}
1024
1025/* return segment id of next segment containing valid data, -EIO otherwise
1026 */
1027static int search_valid_segment(unsigned int segment,
1028 const unsigned int end_seg,
1029 const unsigned int max_foffs,
1030 zft_position *pos,
1031 cmpr_info *c_info,
1032 const zft_volinfo *volume,
1033 __u8 *buf)
1034{
1035 cmpr_info tmp_info;
1036 int seg_sz;
1037 TRACE_FUN(ft_t_flow);
1038
1039 memset(&tmp_info, 0, sizeof(cmpr_info));
1040 while (segment <= end_seg) {
1041 FT_SIGNAL_EXIT(_DONT_BLOCK);
1042 TRACE(ft_t_noise,
1043 "Searching readable segment between %d and %d",
1044 segment, end_seg);
1045 seg_sz = zft_fetch_segment(segment, buf, FT_RD_AHEAD);
1046 if ((seg_sz > 0) &&
1047 (get_cseg (&tmp_info, buf, seg_sz, volume) >= 0) &&
1048 (tmp_info.foffs != 0 || segment == volume->start_seg)) {
1049 if ((tmp_info.foffs>>10) > max_foffs) {
1050 TRACE_ABORT(-EIO, ft_t_noise, "\n"
1051 KERN_INFO "cseg.foff: %d\n"
1052 KERN_INFO "dest : %d",
1053 (int)(tmp_info.foffs >> 10),
1054 max_foffs);
1055 }
1056 DUMP_CMPR_INFO(ft_t_noise, "", &tmp_info);
1057 *c_info = tmp_info;
1058 pos->seg_pos = segment;
1059 pos->volume_pos = c_info->foffs;
1060 pos->seg_byte_pos = c_info->offset;
1061 TRACE(ft_t_noise, "found segment at %d", segment);
1062 TRACE_EXIT 0;
1063 }
1064 segment++;
1065 }
1066 TRACE_EXIT -EIO;
1067}
1068
1069static int slow_seek_forward(unsigned int dest,
1070 cmpr_info *c_info,
1071 zft_position *pos,
1072 const zft_volinfo *volume,
1073 __u8 *buf)
1074{
1075 unsigned int distance;
1076 int result = 0;
1077 TRACE_FUN(ft_t_flow);
1078
1079 distance = dest - (pos->volume_pos >> 10);
1080 while ((distance > 0) &&
1081 (result = slow_seek_forward_until_error(distance,
1082 c_info,
1083 pos,
1084 volume,
1085 buf)) < 0) {
1086 if (result == -EINTR) {
1087 break;
1088 }
1089 TRACE(ft_t_noise, "seg_pos: %d", pos->seg_pos);
1090 /* the failing segment is either pos->seg_pos or
1091 * pos->seg_pos + 1. There is no need to further try
1092 * that segment, because ftape_read_segment() already
1093 * has tried very much to read it. So we start with
1094 * following segment, which is pos->seg_pos + 1
1095 */
1096 if(search_valid_segment(pos->seg_pos+1, volume->end_seg, dest,
1097 pos, c_info,
1098 volume, buf) < 0) {
1099 TRACE(ft_t_noise, "search_valid_segment() failed");
1100 result = -EIO;
1101 break;
1102 }
1103 distance = dest - (pos->volume_pos >> 10);
1104 result = 0;
1105 TRACE(ft_t_noise, "segment: %d", pos->seg_pos);
1106 /* found valid segment, retry the seek */
1107 }
1108 TRACE_EXIT result;
1109}
1110
1111static int compute_seg_pos(const unsigned int dest,
1112 zft_position *pos,
1113 const zft_volinfo *volume)
1114{
1115 int segment;
1116 int distance = dest - (pos->volume_pos >> 10);
1117 unsigned int raw_size;
1118 unsigned int virt_size;
1119 unsigned int factor;
1120 TRACE_FUN(ft_t_flow);
1121
1122 if (distance >= 0) {
1123 raw_size = volume->end_seg - pos->seg_pos + 1;
1124 virt_size = ((unsigned int)(volume->size>>10)
1125 - (unsigned int)(pos->volume_pos>>10)
1126 + FT_SECTORS_PER_SEGMENT - FT_ECC_SECTORS - 1);
1127 virt_size /= FT_SECTORS_PER_SEGMENT - FT_ECC_SECTORS;
1128 if (virt_size == 0 || raw_size == 0) {
1129 TRACE_EXIT 0;
1130 }
1131 if (raw_size >= (1<<25)) {
1132 factor = raw_size/(virt_size>>7);
1133 } else {
1134 factor = (raw_size<<7)/virt_size;
1135 }
1136 segment = distance/(FT_SECTORS_PER_SEGMENT-FT_ECC_SECTORS);
1137 segment = (segment * factor)>>7;
1138 } else {
1139 raw_size = pos->seg_pos - volume->start_seg + 1;
1140 virt_size = ((unsigned int)(pos->volume_pos>>10)
1141 + FT_SECTORS_PER_SEGMENT - FT_ECC_SECTORS - 1);
1142 virt_size /= FT_SECTORS_PER_SEGMENT - FT_ECC_SECTORS;
1143 if (virt_size == 0 || raw_size == 0) {
1144 TRACE_EXIT 0;
1145 }
1146 if (raw_size >= (1<<25)) {
1147 factor = raw_size/(virt_size>>7);
1148 } else {
1149 factor = (raw_size<<7)/virt_size;
1150 }
1151 segment = distance/(FT_SECTORS_PER_SEGMENT-FT_ECC_SECTORS);
1152 }
1153 TRACE(ft_t_noise, "factor: %d/%d", factor, 1<<7);
1154 TRACE_EXIT segment;
1155}
1156
1157static struct zft_cmpr_ops cmpr_ops = {
1158 zftc_write,
1159 zftc_read,
1160 zftc_seek,
1161 zftc_lock,
1162 zftc_reset,
1163 zftc_cleanup
1164};
1165
1166int zft_compressor_init(void)
1167{
1168 TRACE_FUN(ft_t_flow);
1169
1170#ifdef MODULE
1171 printk(KERN_INFO "zftape compressor v1.00a 970514 for " FTAPE_VERSION "\n");
1172 if (TRACE_LEVEL >= ft_t_info) {
1173 printk(
1174KERN_INFO "(c) 1997 Claus-Justus Heine (claus@momo.math.rwth-aachen.de)\n"
1175KERN_INFO "Compressor for zftape (lzrw3 algorithm)\n");
1176 }
1177#else /* !MODULE */
1178 /* print a short no-nonsense boot message */
1179 printk(KERN_INFO "zftape compressor v1.00a 970514\n");
1180 printk(KERN_INFO "For use with " FTAPE_VERSION "\n");
1181#endif /* MODULE */
1182 TRACE(ft_t_info, "zft_compressor_init @ 0x%p", zft_compressor_init);
1183 TRACE(ft_t_info, "installing compressor for zftape ...");
1184 TRACE_CATCH(zft_cmpr_register(&cmpr_ops),);
1185 TRACE_EXIT 0;
1186}
1187
1188#ifdef MODULE
1189
1190MODULE_AUTHOR(
1191 "(c) 1996, 1997 Claus-Justus Heine (claus@momo.math.rwth-aachen.de");
1192MODULE_DESCRIPTION(
1193"Compression routines for zftape. Uses the lzrw3 algorithm by Ross Williams");
1194MODULE_LICENSE("GPL");
1195
1196/* Called by modules package when installing the driver
1197 */
1198int init_module(void)
1199{
1200 return zft_compressor_init();
1201}
1202
1203#endif /* MODULE */
diff --git a/drivers/char/ftape/compressor/zftape-compress.h b/drivers/char/ftape/compressor/zftape-compress.h
deleted file mode 100644
index f200741e33bf..000000000000
--- a/drivers/char/ftape/compressor/zftape-compress.h
+++ /dev/null
@@ -1,83 +0,0 @@
1#ifndef _ZFTAPE_COMPRESS_H
2#define _ZFTAPE_COMPRESS_H
3/*
4 * Copyright (c) 1994-1997 Claus-Justus Heine
5
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License as
8 published by the Free Software Foundation; either version 2, or (at
9 your option) any later version.
10
11 This program is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
19 USA.
20
21 *
22 * $Source: /homes/cvs/ftape-stacked/ftape/compressor/zftape-compress.h,v $
23 * $Revision: 1.1 $
24 * $Date: 1997/10/05 19:12:32 $
25 *
26 * This file contains macros and definitions for zftape's
27 * builtin compression code.
28 *
29 */
30
31#include "../zftape/zftape-buffers.h"
32#include "../zftape/zftape-vtbl.h"
33#include "../compressor/lzrw3.h"
34
35/* CMPR_WRK_MEM_SIZE gives the size of the compression wrk_mem */
36/* I got these out of lzrw3.c */
37#define U(X) ((__u32) X)
38#define SIZE_P_BYTE (U(sizeof(__u8 *)))
39#define ALIGNMENT_FUDGE (U(16))
40
41#define CMPR_WRK_MEM_SIZE (U(4096)*(SIZE_P_BYTE) + ALIGNMENT_FUDGE)
42
43/* the maximum number of bytes the size of the "compressed" data can
44 * exceed the uncompressed data. As it is quite useless to compress
45 * data twice it is sometimes the case that it is more efficient to
46 * copy a block of data but to feed it to the "compression"
47 * algorithm. In this case there are some flag bytes or the like
48 * proceding the "compressed" data. THAT MUST NOT BE THE CASE for the
49 * algorithm we use for this driver. Instead, the high bit 15 of
50 * compressed_size:
51 *
52 * compressed_size = ftape_compress()
53 *
54 * must be set in such a case.
55 *
56 * Nevertheless, it might also be as for lzrw3 that there is an
57 * "intermediate" overrun that exceeds the amount of the compressed
58 * data that is actually produced. During the algorithm we need in the
59 * worst case MAX_CMP_GROUP bytes more than the input-size.
60 */
61#define MAX_CMP_GROUP (2+16*2) /* from lzrw3.c */
62
63#define CMPR_OVERRUN MAX_CMP_GROUP /* during compression */
64
65/****************************************************/
66
67#define CMPR_BUFFER_SIZE (MAX_BLOCK_SIZE + CMPR_OVERRUN)
68
69/* the compression map stores the byte offset compressed blocks within
70 * the current volume for catridges with format code 2,3 and 5
71 * (and old versions of zftape) and the offset measured in kilobytes for
72 * format code 4 and 6. This gives us a possible max. size of a
73 * compressed volume of 1024*4GIG which should be enough.
74 */
75typedef __u32 CmprMap;
76
77/* globals
78 */
79
80/* exported functions
81 */
82
83#endif /* _ZFTAPE_COMPRESS_H */
diff --git a/drivers/char/ftape/lowlevel/Makefile b/drivers/char/ftape/lowlevel/Makefile
deleted file mode 100644
index febab07ba427..000000000000
--- a/drivers/char/ftape/lowlevel/Makefile
+++ /dev/null
@@ -1,43 +0,0 @@
1#
2# Copyright (C) 1996, 1997 Clau-Justus Heine.
3#
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 2, or (at your option)
7# any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program; see the file COPYING. If not, write to
16# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17#
18# $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/Makefile,v $
19# $Revision: 1.4 $
20# $Date: 1997/10/07 09:26:02 $
21#
22# Makefile for the lowlevel part QIC-40/80/3010/3020 floppy-tape
23# driver for Linux.
24#
25
26obj-$(CONFIG_FTAPE) += ftape.o
27
28ftape-objs := ftape-init.o fdc-io.o fdc-isr.o \
29 ftape-bsm.o ftape-ctl.o ftape-read.o ftape-rw.o \
30 ftape-write.o ftape-io.o ftape-calibr.o ftape-ecc.o fc-10.o \
31 ftape-buffer.o ftape-format.o ftape_syms.o
32
33ifeq ($(CONFIG_FTAPE),y)
34ftape-objs += ftape-setup.o
35endif
36
37ifndef CONFIG_FT_NO_TRACE_AT_ALL
38ftape-objs += ftape-tracing.o
39endif
40
41ifeq ($(CONFIG_FT_PROC_FS),y)
42ftape-objs += ftape-proc.o
43endif
diff --git a/drivers/char/ftape/lowlevel/fc-10.c b/drivers/char/ftape/lowlevel/fc-10.c
deleted file mode 100644
index 9bc1cddade76..000000000000
--- a/drivers/char/ftape/lowlevel/fc-10.c
+++ /dev/null
@@ -1,175 +0,0 @@
1/*
2 *
3
4 Copyright (C) 1993,1994 Jon Tombs.
5
6 This program is distributed in the hope that it will be useful,
7 but WITHOUT ANY WARRANTY; without even the implied warranty of
8 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 GNU General Public License for more details.
10
11 The entire guts of this program was written by dosemu, modified to
12 record reads and writes to the ports in the 0x180-0x188 address space,
13 while running the CMS program TAPE.EXE V2.0.5 supplied with the drive.
14
15 Modified to use an array of addresses and generally cleaned up (made
16 much shorter) 4 June 94, dosemu isn't that good at writing short code it
17 would seem :-). Made independent of 0x180, but I doubt it will work
18 at any other address.
19
20 Modified for distribution with ftape source. 21 June 94, SJL.
21
22 Modifications on 20 October 95, by Daniel Cohen (catman@wpi.edu):
23 Modified to support different DMA, IRQ, and IO Ports. Borland's
24 Turbo Debugger in virtual 8086 mode (TD386.EXE with hardware breakpoints
25 provided by the TDH386.SYS Device Driver) was used on the CMS program
26 TAPE V4.0.5. I set breakpoints on I/O to ports 0x180-0x187. Note that
27 CMS's program will not successfully configure the tape drive if you set
28 breakpoints on IO Reads, but you can set them on IO Writes without problems.
29 Known problems:
30 - You can not use DMA Channels 5 or 7.
31
32 Modification on 29 January 96, by Daniel Cohen (catman@wpi.edu):
33 Modified to only accept IRQs 3 - 7, or 9. Since we can only send a 3 bit
34 number representing the IRQ to the card, special handling is required when
35 IRQ 9 is selected. IRQ 2 and 9 are the same, and we should request IRQ 9
36 from the kernel while telling the card to use IRQ 2. Thanks to Greg
37 Crider (gcrider@iclnet.org) for finding and locating this bug, as well as
38 testing the patch.
39
40 Modification on 11 December 96, by Claus Heine (claus@momo.math.rwth-aachen.de):
41 Modified a little to use variahle ft_fdc_base, ft_fdc_irq, ft_fdc_dma
42 instead of preprocessor symbols. Thus we can compile this into the module
43 or kernel and let the user specify the options as command line arguments.
44
45 *
46 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/fc-10.c,v $
47 * $Revision: 1.2 $
48 * $Date: 1997/10/05 19:18:04 $
49 *
50 * This file contains code for the CMS FC-10/FC-20 card.
51 */
52
53#include <asm/io.h>
54#include <linux/ftape.h>
55#include "../lowlevel/ftape-tracing.h"
56#include "../lowlevel/fdc-io.h"
57#include "../lowlevel/fc-10.h"
58
59static __u16 inbs_magic[] = {
60 0x3, 0x3, 0x0, 0x4, 0x7, 0x2, 0x5, 0x3, 0x1, 0x4,
61 0x3, 0x5, 0x2, 0x0, 0x3, 0x7, 0x4, 0x2,
62 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7
63};
64
65static __u16 fc10_ports[] = {
66 0x180, 0x210, 0x2A0, 0x300, 0x330, 0x340, 0x370
67};
68
69int fc10_enable(void)
70{
71 int i;
72 __u8 cardConfig = 0x00;
73 __u8 x;
74 TRACE_FUN(ft_t_flow);
75
76/* This code will only work if the FC-10 (or FC-20) is set to
77 * use DMA channels 1, 2, or 3. DMA channels 5 and 7 seem to be
78 * initialized by the same command as channels 1 and 3, respectively.
79 */
80 if (ft_fdc_dma > 3) {
81 TRACE_ABORT(0, ft_t_err,
82"Error: The FC-10/20 must be set to use DMA channels 1, 2, or 3!");
83 }
84/* Only allow the FC-10/20 to use IRQ 3-7, or 9. Note that CMS's program
85 * only accepts IRQ's 2-7, but in linux, IRQ 2 is the same as IRQ 9.
86 */
87 if (ft_fdc_irq < 3 || ft_fdc_irq == 8 || ft_fdc_irq > 9) {
88 TRACE_ABORT(0, ft_t_err,
89"Error: The FC-10/20 must be set to use IRQ levels 3 - 7, or 9!\n"
90KERN_INFO "Note: IRQ 9 is the same as IRQ 2");
91 }
92 /* Clear state machine ???
93 */
94 for (i = 0; i < NR_ITEMS(inbs_magic); i++) {
95 inb(ft_fdc_base + inbs_magic[i]);
96 }
97 outb(0x0, ft_fdc_base);
98
99 x = inb(ft_fdc_base);
100 if (x == 0x13 || x == 0x93) {
101 for (i = 1; i < 8; i++) {
102 if (inb(ft_fdc_base + i) != x) {
103 TRACE_EXIT 0;
104 }
105 }
106 } else {
107 TRACE_EXIT 0;
108 }
109
110 outb(0x8, ft_fdc_base);
111
112 for (i = 0; i < 8; i++) {
113 if (inb(ft_fdc_base + i) != 0x0) {
114 TRACE_EXIT 0;
115 }
116 }
117 outb(0x10, ft_fdc_base);
118
119 for (i = 0; i < 8; i++) {
120 if (inb(ft_fdc_base + i) != 0xff) {
121 TRACE_EXIT 0;
122 }
123 }
124
125 /* Okay, we found a FC-10 card ! ???
126 */
127 outb(0x0, fdc.ccr);
128
129 /* Clear state machine again ???
130 */
131 for (i = 0; i < NR_ITEMS(inbs_magic); i++) {
132 inb(ft_fdc_base + inbs_magic[i]);
133 }
134 /* Send io port */
135 for (i = 0; i < NR_ITEMS(fc10_ports); i++)
136 if (ft_fdc_base == fc10_ports[i])
137 cardConfig = i + 1;
138 if (cardConfig == 0) {
139 TRACE_EXIT 0; /* Invalid I/O Port */
140 }
141 /* and IRQ - If using IRQ 9, tell the FC card it is actually IRQ 2 */
142 if (ft_fdc_irq != 9)
143 cardConfig |= ft_fdc_irq << 3;
144 else
145 cardConfig |= 2 << 3;
146
147 /* and finally DMA Channel */
148 cardConfig |= ft_fdc_dma << 6;
149 outb(cardConfig, ft_fdc_base); /* DMA [2 bits]/IRQ [3 bits]/BASE [3 bits] */
150
151 /* Enable FC-10 ???
152 */
153 outb(0, fdc.ccr);
154 outb(0, fdc.dor2);
155 outb(FDC_DMA_MODE /* 8 */, fdc.dor);
156 outb(FDC_DMA_MODE /* 8 */, fdc.dor);
157 outb(1, fdc.dor2);
158
159 /*************************************
160 *
161 * cH: why the hell should this be necessary? This is done
162 * by fdc_reset()!!!
163 *
164 *************************************/
165 /* Initialize fdc, select drive B:
166 */
167 outb(FDC_DMA_MODE, fdc.dor); /* assert reset, dma & irq enabled */
168 /* 0x08 */
169 outb(FDC_DMA_MODE|FDC_RESET_NOT, fdc.dor); /* release reset */
170 /* 0x08 | 0x04 = 0x0c */
171 outb(FDC_DMA_MODE|FDC_RESET_NOT|FDC_MOTOR_1|FTAPE_SEL_B, fdc.dor);
172 /* 0x08 | 0x04 | 0x20 | 0x01 = 0x2d */
173 /* select drive 1 */ /* why not drive 0 ???? */
174 TRACE_EXIT (x == 0x93) ? 2 : 1;
175}
diff --git a/drivers/char/ftape/lowlevel/fc-10.h b/drivers/char/ftape/lowlevel/fc-10.h
deleted file mode 100644
index da7b88bca889..000000000000
--- a/drivers/char/ftape/lowlevel/fc-10.h
+++ /dev/null
@@ -1,39 +0,0 @@
1#ifndef _FC_10_H
2#define _FC_10_H
3
4/*
5 * Copyright (C) 1994-1996 Bas Laarhoven.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 *
22 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/fc-10.h,v $
23 * $Revision: 1.1 $
24 * $Date: 1997/09/19 09:05:22 $
25 *
26 * This file contains definitions for the FC-10 code
27 * of the QIC-40/80 floppy-tape driver for Linux.
28 */
29
30/*
31 * fc-10.c defined global vars.
32 */
33
34/*
35 * fc-10.c defined global functions.
36 */
37extern int fc10_enable(void);
38
39#endif
diff --git a/drivers/char/ftape/lowlevel/fdc-io.c b/drivers/char/ftape/lowlevel/fdc-io.c
deleted file mode 100644
index bbcf918f056f..000000000000
--- a/drivers/char/ftape/lowlevel/fdc-io.c
+++ /dev/null
@@ -1,1349 +0,0 @@
1/*
2 * Copyright (C) 1993-1996 Bas Laarhoven,
3 * (C) 1996-1997 Claus-Justus Heine.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
8 any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; see the file COPYING. If not, write to
17 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 *
20 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/fdc-io.c,v $
21 * $Revision: 1.7.4.2 $
22 * $Date: 1997/11/16 14:48:17 $
23 *
24 * This file contains the low-level floppy disk interface code
25 * for the QIC-40/80/3010/3020 floppy-tape driver "ftape" for
26 * Linux.
27 */
28
29#include <linux/errno.h>
30#include <linux/sched.h>
31#include <linux/ioport.h>
32#include <linux/interrupt.h>
33#include <linux/kernel.h>
34#include <asm/system.h>
35#include <asm/io.h>
36#include <asm/dma.h>
37#include <asm/irq.h>
38
39#include <linux/ftape.h>
40#include <linux/qic117.h>
41#include "../lowlevel/ftape-tracing.h"
42#include "../lowlevel/fdc-io.h"
43#include "../lowlevel/fdc-isr.h"
44#include "../lowlevel/ftape-io.h"
45#include "../lowlevel/ftape-rw.h"
46#include "../lowlevel/ftape-ctl.h"
47#include "../lowlevel/ftape-calibr.h"
48#include "../lowlevel/fc-10.h"
49
50/* Global vars.
51 */
52static int ftape_motor;
53volatile int ftape_current_cylinder = -1;
54volatile fdc_mode_enum fdc_mode = fdc_idle;
55fdc_config_info fdc;
56DECLARE_WAIT_QUEUE_HEAD(ftape_wait_intr);
57
58unsigned int ft_fdc_base = CONFIG_FT_FDC_BASE;
59unsigned int ft_fdc_irq = CONFIG_FT_FDC_IRQ;
60unsigned int ft_fdc_dma = CONFIG_FT_FDC_DMA;
61unsigned int ft_fdc_threshold = CONFIG_FT_FDC_THR; /* bytes */
62unsigned int ft_fdc_rate_limit = CONFIG_FT_FDC_MAX_RATE; /* bits/sec */
63int ft_probe_fc10 = CONFIG_FT_PROBE_FC10;
64int ft_mach2 = CONFIG_FT_MACH2;
65
66/* Local vars.
67 */
68static spinlock_t fdc_io_lock;
69static unsigned int fdc_calibr_count;
70static unsigned int fdc_calibr_time;
71static int fdc_status;
72volatile __u8 fdc_head; /* FDC head from sector id */
73volatile __u8 fdc_cyl; /* FDC track from sector id */
74volatile __u8 fdc_sect; /* FDC sector from sector id */
75static int fdc_data_rate = 500; /* data rate (Kbps) */
76static int fdc_rate_code; /* data rate code (0 == 500 Kbps) */
77static int fdc_seek_rate = 2; /* step rate (msec) */
78static void (*do_ftape) (void);
79static int fdc_fifo_state; /* original fifo setting - fifo enabled */
80static int fdc_fifo_thr; /* original fifo setting - threshold */
81static int fdc_lock_state; /* original lock setting - locked */
82static int fdc_fifo_locked; /* has fifo && lock set ? */
83static __u8 fdc_precomp; /* default precomp. value (nsec) */
84static __u8 fdc_prec_code; /* fdc precomp. select code */
85
86static char ftape_id[] = "ftape"; /* used by request irq and free irq */
87
88static int fdc_set_seek_rate(int seek_rate);
89
90void fdc_catch_stray_interrupts(int count)
91{
92 unsigned long flags;
93
94 spin_lock_irqsave(&fdc_io_lock, flags);
95 if (count == 0) {
96 ft_expected_stray_interrupts = 0;
97 } else {
98 ft_expected_stray_interrupts += count;
99 }
100 spin_unlock_irqrestore(&fdc_io_lock, flags);
101}
102
103/* Wait during a timeout period for a given FDC status.
104 * If usecs == 0 then just test status, else wait at least for usecs.
105 * Returns -ETIME on timeout. Function must be calibrated first !
106 */
107static int fdc_wait(unsigned int usecs, __u8 mask, __u8 state)
108{
109 int count_1 = (fdc_calibr_count * usecs +
110 fdc_calibr_count - 1) / fdc_calibr_time;
111
112 do {
113 fdc_status = inb_p(fdc.msr);
114 if ((fdc_status & mask) == state) {
115 return 0;
116 }
117 } while (count_1-- >= 0);
118 return -ETIME;
119}
120
121int fdc_ready_wait(unsigned int usecs)
122{
123 return fdc_wait(usecs, FDC_DATA_READY | FDC_BUSY, FDC_DATA_READY);
124}
125
126/* Why can't we just use udelay()?
127 */
128static void fdc_usec_wait(unsigned int usecs)
129{
130 fdc_wait(usecs, 0, 1); /* will always timeout ! */
131}
132
133static int fdc_ready_out_wait(unsigned int usecs)
134{
135 fdc_usec_wait(FT_RQM_DELAY); /* wait for valid RQM status */
136 return fdc_wait(usecs, FDC_DATA_OUT_READY, FDC_DATA_OUT_READY);
137}
138
139void fdc_wait_calibrate(void)
140{
141 ftape_calibrate("fdc_wait",
142 fdc_usec_wait, &fdc_calibr_count, &fdc_calibr_time);
143}
144
145/* Wait for a (short) while for the FDC to become ready
146 * and transfer the next command byte.
147 * Return -ETIME on timeout on getting ready (depends on hardware!).
148 */
149static int fdc_write(const __u8 data)
150{
151 fdc_usec_wait(FT_RQM_DELAY); /* wait for valid RQM status */
152 if (fdc_wait(150, FDC_DATA_READY_MASK, FDC_DATA_IN_READY) < 0) {
153 return -ETIME;
154 } else {
155 outb(data, fdc.fifo);
156 return 0;
157 }
158}
159
160/* Wait for a (short) while for the FDC to become ready
161 * and transfer the next result byte.
162 * Return -ETIME if timeout on getting ready (depends on hardware!).
163 */
164static int fdc_read(__u8 * data)
165{
166 fdc_usec_wait(FT_RQM_DELAY); /* wait for valid RQM status */
167 if (fdc_wait(150, FDC_DATA_READY_MASK, FDC_DATA_OUT_READY) < 0) {
168 return -ETIME;
169 } else {
170 *data = inb(fdc.fifo);
171 return 0;
172 }
173}
174
175/* Output a cmd_len long command string to the FDC.
176 * The FDC should be ready to receive a new command or
177 * an error (EBUSY or ETIME) will occur.
178 */
179int fdc_command(const __u8 * cmd_data, int cmd_len)
180{
181 int result = 0;
182 unsigned long flags;
183 int count = cmd_len;
184 int retry = 0;
185#ifdef TESTING
186 static unsigned int last_time;
187 unsigned int time;
188#endif
189 TRACE_FUN(ft_t_any);
190
191 fdc_usec_wait(FT_RQM_DELAY); /* wait for valid RQM status */
192 spin_lock_irqsave(&fdc_io_lock, flags);
193 if (!in_interrupt())
194 /* Yes, I know, too much comments inside this function
195 * ...
196 *
197 * Yet another bug in the original driver. All that
198 * havoc is caused by the fact that the isr() sends
199 * itself a command to the floppy tape driver (pause,
200 * micro step pause). Now, the problem is that
201 * commands are transmitted via the fdc_seek
202 * command. But: the fdc performs seeks in the
203 * background i.e. it doesn't signal busy while
204 * sending the step pulses to the drive. Therefore the
205 * non-interrupt level driver has no chance to tell
206 * whether the isr() just has issued a seek. Therefore
207 * we HAVE TO have a look at the ft_hide_interrupt
208 * flag: it signals the non-interrupt level part of
209 * the driver that it has to wait for the fdc until it
210 * has completet seeking.
211 *
212 * THIS WAS PRESUMABLY THE REASON FOR ALL THAT
213 * "fdc_read timeout" errors, I HOPE :-)
214 */
215 if (ft_hide_interrupt) {
216 restore_flags(flags);
217 TRACE(ft_t_info,
218 "Waiting for the isr() completing fdc_seek()");
219 if (fdc_interrupt_wait(2 * FT_SECOND) < 0) {
220 TRACE(ft_t_warn,
221 "Warning: timeout waiting for isr() seek to complete");
222 }
223 if (ft_hide_interrupt || !ft_seek_completed) {
224 /* There cannot be another
225 * interrupt. The isr() only stops
226 * the tape and the next interrupt
227 * won't come until we have send our
228 * command to the drive.
229 */
230 TRACE_ABORT(-EIO, ft_t_bug,
231 "BUG? isr() is still seeking?\n"
232 KERN_INFO "hide: %d\n"
233 KERN_INFO "seek: %d",
234 ft_hide_interrupt,
235 ft_seek_completed);
236
237 }
238 fdc_usec_wait(FT_RQM_DELAY); /* wait for valid RQM status */
239 spin_lock_irqsave(&fdc_io_lock, flags);
240 }
241 fdc_status = inb(fdc.msr);
242 if ((fdc_status & FDC_DATA_READY_MASK) != FDC_DATA_IN_READY) {
243 spin_unlock_irqrestore(&fdc_io_lock, flags);
244 TRACE_ABORT(-EBUSY, ft_t_err, "fdc not ready");
245 }
246 fdc_mode = *cmd_data; /* used by isr */
247#ifdef TESTING
248 if (fdc_mode == FDC_SEEK) {
249 time = ftape_timediff(last_time, ftape_timestamp());
250 if (time < 6000) {
251 TRACE(ft_t_bug,"Warning: short timeout between seek commands: %d",
252 time);
253 }
254 }
255#endif
256 if (!in_interrupt()) {
257 /* shouldn't be cleared if called from isr
258 */
259 ft_interrupt_seen = 0;
260 }
261 while (count) {
262 result = fdc_write(*cmd_data);
263 if (result < 0) {
264 TRACE(ft_t_fdc_dma,
265 "fdc_mode = %02x, status = %02x at index %d",
266 (int) fdc_mode, (int) fdc_status,
267 cmd_len - count);
268 if (++retry <= 3) {
269 TRACE(ft_t_warn, "fdc_write timeout, retry");
270 } else {
271 TRACE(ft_t_err, "fdc_write timeout, fatal");
272 /* recover ??? */
273 break;
274 }
275 } else {
276 --count;
277 ++cmd_data;
278 }
279 }
280#ifdef TESTING
281 if (fdc_mode == FDC_SEEK) {
282 last_time = ftape_timestamp();
283 }
284#endif
285 spin_unlock_irqrestore(&fdc_io_lock, flags);
286 TRACE_EXIT result;
287}
288
289/* Input a res_len long result string from the FDC.
290 * The FDC should be ready to send the result or an error
291 * (EBUSY or ETIME) will occur.
292 */
293int fdc_result(__u8 * res_data, int res_len)
294{
295 int result = 0;
296 unsigned long flags;
297 int count = res_len;
298 int retry = 0;
299 TRACE_FUN(ft_t_any);
300
301 spin_lock_irqsave(&fdc_io_lock, flags);
302 fdc_status = inb(fdc.msr);
303 if ((fdc_status & FDC_DATA_READY_MASK) != FDC_DATA_OUT_READY) {
304 TRACE(ft_t_err, "fdc not ready");
305 result = -EBUSY;
306 } else while (count) {
307 if (!(fdc_status & FDC_BUSY)) {
308 spin_unlock_irqrestore(&fdc_io_lock, flags);
309 TRACE_ABORT(-EIO, ft_t_err, "premature end of result phase");
310 }
311 result = fdc_read(res_data);
312 if (result < 0) {
313 TRACE(ft_t_fdc_dma,
314 "fdc_mode = %02x, status = %02x at index %d",
315 (int) fdc_mode,
316 (int) fdc_status,
317 res_len - count);
318 if (++retry <= 3) {
319 TRACE(ft_t_warn, "fdc_read timeout, retry");
320 } else {
321 TRACE(ft_t_err, "fdc_read timeout, fatal");
322 /* recover ??? */
323 break;
324 ++retry;
325 }
326 } else {
327 --count;
328 ++res_data;
329 }
330 }
331 spin_unlock_irqrestore(&fdc_io_lock, flags);
332 fdc_usec_wait(FT_RQM_DELAY); /* allow FDC to negate BSY */
333 TRACE_EXIT result;
334}
335
336/* Handle command and result phases for
337 * commands without data phase.
338 */
339static int fdc_issue_command(const __u8 * out_data, int out_count,
340 __u8 * in_data, int in_count)
341{
342 TRACE_FUN(ft_t_any);
343
344 if (out_count > 0) {
345 TRACE_CATCH(fdc_command(out_data, out_count),);
346 }
347 /* will take 24 - 30 usec for fdc_sense_drive_status and
348 * fdc_sense_interrupt_status commands.
349 * 35 fails sometimes (5/9/93 SJL)
350 * On a loaded system it incidentally takes longer than
351 * this for the fdc to get ready ! ?????? WHY ??????
352 * So until we know what's going on use a very long timeout.
353 */
354 TRACE_CATCH(fdc_ready_out_wait(500 /* usec */),);
355 if (in_count > 0) {
356 TRACE_CATCH(fdc_result(in_data, in_count),
357 TRACE(ft_t_err, "result phase aborted"));
358 }
359 TRACE_EXIT 0;
360}
361
362/* Wait for FDC interrupt with timeout (in milliseconds).
363 * Signals are blocked so the wait will not be aborted.
364 * Note: interrupts must be enabled ! (23/05/93 SJL)
365 */
366int fdc_interrupt_wait(unsigned int time)
367{
368 DECLARE_WAITQUEUE(wait,current);
369 sigset_t old_sigmask;
370 static int resetting;
371 long timeout;
372
373 TRACE_FUN(ft_t_fdc_dma);
374
375 if (waitqueue_active(&ftape_wait_intr)) {
376 TRACE_ABORT(-EIO, ft_t_err, "error: nested call");
377 }
378 /* timeout time will be up to USPT microseconds too long ! */
379 timeout = (1000 * time + FT_USPT - 1) / FT_USPT;
380
381 spin_lock_irq(&current->sighand->siglock);
382 old_sigmask = current->blocked;
383 sigfillset(&current->blocked);
384 recalc_sigpending();
385 spin_unlock_irq(&current->sighand->siglock);
386
387 set_current_state(TASK_INTERRUPTIBLE);
388 add_wait_queue(&ftape_wait_intr, &wait);
389 while (!ft_interrupt_seen && timeout)
390 timeout = schedule_timeout_interruptible(timeout);
391
392 spin_lock_irq(&current->sighand->siglock);
393 current->blocked = old_sigmask;
394 recalc_sigpending();
395 spin_unlock_irq(&current->sighand->siglock);
396
397 remove_wait_queue(&ftape_wait_intr, &wait);
398 /* the following IS necessary. True: as well
399 * wake_up_interruptible() as the schedule() set TASK_RUNNING
400 * when they wakeup a task, BUT: it may very well be that
401 * ft_interrupt_seen is already set to 1 when we enter here
402 * in which case schedule() gets never called, and
403 * TASK_RUNNING never set. This has the funny effect that we
404 * execute all the code until we leave kernel space, but then
405 * the task is stopped (a task CANNOT be preempted while in
406 * kernel mode. Sending a pair of SIGSTOP/SIGCONT to the
407 * tasks wakes it up again. Funny! :-)
408 */
409 current->state = TASK_RUNNING;
410 if (ft_interrupt_seen) { /* woken up by interrupt */
411 ft_interrupt_seen = 0;
412 TRACE_EXIT 0;
413 }
414 /* Original comment:
415 * In first instance, next statement seems unnecessary since
416 * it will be cleared in fdc_command. However, a small part of
417 * the software seems to rely on this being cleared here
418 * (ftape_close might fail) so stick to it until things get fixed !
419 */
420 /* My deeply sought of knowledge:
421 * Behold NO! It is obvious. fdc_reset() doesn't call fdc_command()
422 * but nevertheless uses fdc_interrupt_wait(). OF COURSE this needs to
423 * be reset here.
424 */
425 ft_interrupt_seen = 0; /* clear for next call */
426 if (!resetting) {
427 resetting = 1; /* break infinite recursion if reset fails */
428 TRACE(ft_t_any, "cleanup reset");
429 fdc_reset();
430 resetting = 0;
431 }
432 TRACE_EXIT (signal_pending(current)) ? -EINTR : -ETIME;
433}
434
435/* Start/stop drive motor. Enable DMA mode.
436 */
437void fdc_motor(int motor)
438{
439 int unit = ft_drive_sel;
440 int data = unit | FDC_RESET_NOT | FDC_DMA_MODE;
441 TRACE_FUN(ft_t_any);
442
443 ftape_motor = motor;
444 if (ftape_motor) {
445 data |= FDC_MOTOR_0 << unit;
446 TRACE(ft_t_noise, "turning motor %d on", unit);
447 } else {
448 TRACE(ft_t_noise, "turning motor %d off", unit);
449 }
450 if (ft_mach2) {
451 outb_p(data, fdc.dor2);
452 } else {
453 outb_p(data, fdc.dor);
454 }
455 ftape_sleep(10 * FT_MILLISECOND);
456 TRACE_EXIT;
457}
458
459static void fdc_update_dsr(void)
460{
461 TRACE_FUN(ft_t_any);
462
463 TRACE(ft_t_flow, "rate = %d Kbps, precomp = %d ns",
464 fdc_data_rate, fdc_precomp);
465 if (fdc.type >= i82077) {
466 outb_p((fdc_rate_code & 0x03) | fdc_prec_code, fdc.dsr);
467 } else {
468 outb_p(fdc_rate_code & 0x03, fdc.ccr);
469 }
470 TRACE_EXIT;
471}
472
473void fdc_set_write_precomp(int precomp)
474{
475 TRACE_FUN(ft_t_any);
476
477 TRACE(ft_t_noise, "New precomp: %d nsec", precomp);
478 fdc_precomp = precomp;
479 /* write precompensation can be set in multiples of 41.67 nsec.
480 * round the parameter to the nearest multiple and convert it
481 * into a fdc setting. Note that 0 means default to the fdc,
482 * 7 is used instead of that.
483 */
484 fdc_prec_code = ((fdc_precomp + 21) / 42) << 2;
485 if (fdc_prec_code == 0 || fdc_prec_code > (6 << 2)) {
486 fdc_prec_code = 7 << 2;
487 }
488 fdc_update_dsr();
489 TRACE_EXIT;
490}
491
492/* Reprogram the 82078 registers to use Data Rate Table 1 on all drives.
493 */
494static void fdc_set_drive_specs(void)
495{
496 __u8 cmd[] = { FDC_DRIVE_SPEC, 0x00, 0x00, 0x00, 0x00, 0xc0};
497 int result;
498 TRACE_FUN(ft_t_any);
499
500 TRACE(ft_t_flow, "Setting of drive specs called");
501 if (fdc.type >= i82078_1) {
502 cmd[1] = (0 << 5) | (2 << 2);
503 cmd[2] = (1 << 5) | (2 << 2);
504 cmd[3] = (2 << 5) | (2 << 2);
505 cmd[4] = (3 << 5) | (2 << 2);
506 result = fdc_command(cmd, NR_ITEMS(cmd));
507 if (result < 0) {
508 TRACE(ft_t_err, "Setting of drive specs failed");
509 }
510 }
511 TRACE_EXIT;
512}
513
514/* Select clock for fdc, must correspond with tape drive setting !
515 * This also influences the fdc timing so we must adjust some values.
516 */
517int fdc_set_data_rate(int rate)
518{
519 int bad_rate = 0;
520 TRACE_FUN(ft_t_any);
521
522 /* Select clock for fdc, must correspond with tape drive setting !
523 * This also influences the fdc timing so we must adjust some values.
524 */
525 TRACE(ft_t_fdc_dma, "new rate = %d", rate);
526 switch (rate) {
527 case 250:
528 fdc_rate_code = fdc_data_rate_250;
529 break;
530 case 500:
531 fdc_rate_code = fdc_data_rate_500;
532 break;
533 case 1000:
534 if (fdc.type < i82077) {
535 bad_rate = 1;
536 } else {
537 fdc_rate_code = fdc_data_rate_1000;
538 }
539 break;
540 case 2000:
541 if (fdc.type < i82078_1) {
542 bad_rate = 1;
543 } else {
544 fdc_rate_code = fdc_data_rate_2000;
545 }
546 break;
547 default:
548 bad_rate = 1;
549 }
550 if (bad_rate) {
551 TRACE_ABORT(-EIO,
552 ft_t_fdc_dma, "%d is not a valid data rate", rate);
553 }
554 fdc_data_rate = rate;
555 fdc_update_dsr();
556 fdc_set_seek_rate(fdc_seek_rate); /* clock changed! */
557 ftape_udelay(1000);
558 TRACE_EXIT 0;
559}
560
561/* keep the unit select if keep_select is != 0,
562 */
563static void fdc_dor_reset(int keep_select)
564{
565 __u8 fdc_ctl = ft_drive_sel;
566
567 if (keep_select != 0) {
568 fdc_ctl |= FDC_DMA_MODE;
569 if (ftape_motor) {
570 fdc_ctl |= FDC_MOTOR_0 << ft_drive_sel;
571 }
572 }
573 ftape_udelay(10); /* ??? but seems to be necessary */
574 if (ft_mach2) {
575 outb_p(fdc_ctl & 0x0f, fdc.dor);
576 outb_p(fdc_ctl, fdc.dor2);
577 } else {
578 outb_p(fdc_ctl, fdc.dor);
579 }
580 fdc_usec_wait(10); /* delay >= 14 fdc clocks */
581 if (keep_select == 0) {
582 fdc_ctl = 0;
583 }
584 fdc_ctl |= FDC_RESET_NOT;
585 if (ft_mach2) {
586 outb_p(fdc_ctl & 0x0f, fdc.dor);
587 outb_p(fdc_ctl, fdc.dor2);
588 } else {
589 outb_p(fdc_ctl, fdc.dor);
590 }
591}
592
593/* Reset the floppy disk controller. Leave the ftape_unit selected.
594 */
595void fdc_reset(void)
596{
597 int st0;
598 int i;
599 int dummy;
600 unsigned long flags;
601 TRACE_FUN(ft_t_any);
602
603 spin_lock_irqsave(&fdc_io_lock, flags);
604
605 fdc_dor_reset(1); /* keep unit selected */
606
607 fdc_mode = fdc_idle;
608
609 /* maybe the spin_lock_irq* pair is not necessary, BUT:
610 * the following line MUST be here. Otherwise fdc_interrupt_wait()
611 * won't wait. Note that fdc_reset() is called from
612 * ftape_dumb_stop() when the fdc is busy transferring data. In this
613 * case fdc_isr() MOST PROBABLY sets ft_interrupt_seen, and tries
614 * to get the result bytes from the fdc etc. CLASH.
615 */
616 ft_interrupt_seen = 0;
617
618 /* Program data rate
619 */
620 fdc_update_dsr(); /* restore data rate and precomp */
621
622 spin_unlock_irqrestore(&fdc_io_lock, flags);
623
624 /*
625 * Wait for first polling cycle to complete
626 */
627 if (fdc_interrupt_wait(1 * FT_SECOND) < 0) {
628 TRACE(ft_t_err, "no drive polling interrupt!");
629 } else { /* clear all disk-changed statuses */
630 for (i = 0; i < 4; ++i) {
631 if(fdc_sense_interrupt_status(&st0, &dummy) != 0) {
632 TRACE(ft_t_err, "sense failed for %d", i);
633 }
634 if (i == ft_drive_sel) {
635 ftape_current_cylinder = dummy;
636 }
637 }
638 TRACE(ft_t_noise, "drive polling completed");
639 }
640 /*
641 * SPECIFY COMMAND
642 */
643 fdc_set_seek_rate(fdc_seek_rate);
644 /*
645 * DRIVE SPECIFICATION COMMAND (if fdc type known)
646 */
647 if (fdc.type >= i82078_1) {
648 fdc_set_drive_specs();
649 }
650 TRACE_EXIT;
651}
652
653#if !defined(CLK_48MHZ)
654# define CLK_48MHZ 1
655#endif
656
657/* When we're done, put the fdc into reset mode so that the regular
658 * floppy disk driver will figure out that something is wrong and
659 * initialize the controller the way it wants.
660 */
661void fdc_disable(void)
662{
663 __u8 cmd1[] = {FDC_CONFIGURE, 0x00, 0x00, 0x00};
664 __u8 cmd2[] = {FDC_LOCK};
665 __u8 cmd3[] = {FDC_UNLOCK};
666 __u8 stat[1];
667 TRACE_FUN(ft_t_flow);
668
669 if (!fdc_fifo_locked) {
670 fdc_reset();
671 TRACE_EXIT;
672 }
673 if (fdc_issue_command(cmd3, 1, stat, 1) < 0 || stat[0] != 0x00) {
674 fdc_dor_reset(0);
675 TRACE_ABORT(/**/, ft_t_bug,
676 "couldn't unlock fifo, configuration remains changed");
677 }
678 fdc_fifo_locked = 0;
679 if (CLK_48MHZ && fdc.type >= i82078) {
680 cmd1[0] |= FDC_CLK48_BIT;
681 }
682 cmd1[2] = ((fdc_fifo_state) ? 0 : 0x20) + (fdc_fifo_thr - 1);
683 if (fdc_command(cmd1, NR_ITEMS(cmd1)) < 0) {
684 fdc_dor_reset(0);
685 TRACE_ABORT(/**/, ft_t_bug,
686 "couldn't reconfigure fifo to old state");
687 }
688 if (fdc_lock_state &&
689 fdc_issue_command(cmd2, 1, stat, 1) < 0) {
690 fdc_dor_reset(0);
691 TRACE_ABORT(/**/, ft_t_bug, "couldn't lock old state again");
692 }
693 TRACE(ft_t_noise, "fifo restored: %sabled, thr. %d, %slocked",
694 fdc_fifo_state ? "en" : "dis",
695 fdc_fifo_thr, (fdc_lock_state) ? "" : "not ");
696 fdc_dor_reset(0);
697 TRACE_EXIT;
698}
699
700/* Specify FDC seek-rate (milliseconds)
701 */
702static int fdc_set_seek_rate(int seek_rate)
703{
704 /* set step rate, dma mode, and minimal head load and unload times
705 */
706 __u8 in[3] = { FDC_SPECIFY, 1, (1 << 1)};
707
708 fdc_seek_rate = seek_rate;
709 in[1] |= (16 - (fdc_data_rate * fdc_seek_rate) / 500) << 4;
710
711 return fdc_command(in, 3);
712}
713
714/* Sense drive status: get unit's drive status (ST3)
715 */
716int fdc_sense_drive_status(int *st3)
717{
718 __u8 out[2];
719 __u8 in[1];
720 TRACE_FUN(ft_t_any);
721
722 out[0] = FDC_SENSED;
723 out[1] = ft_drive_sel;
724 TRACE_CATCH(fdc_issue_command(out, 2, in, 1),);
725 *st3 = in[0];
726 TRACE_EXIT 0;
727}
728
729/* Sense Interrupt Status command:
730 * should be issued at the end of each seek.
731 * get ST0 and current cylinder.
732 */
733int fdc_sense_interrupt_status(int *st0, int *current_cylinder)
734{
735 __u8 out[1];
736 __u8 in[2];
737 TRACE_FUN(ft_t_any);
738
739 out[0] = FDC_SENSEI;
740 TRACE_CATCH(fdc_issue_command(out, 1, in, 2),);
741 *st0 = in[0];
742 *current_cylinder = in[1];
743 TRACE_EXIT 0;
744}
745
746/* step to track
747 */
748int fdc_seek(int track)
749{
750 __u8 out[3];
751 int st0, pcn;
752#ifdef TESTING
753 unsigned int time;
754#endif
755 TRACE_FUN(ft_t_any);
756
757 out[0] = FDC_SEEK;
758 out[1] = ft_drive_sel;
759 out[2] = track;
760#ifdef TESTING
761 time = ftape_timestamp();
762#endif
763 /* We really need this command to work !
764 */
765 ft_seek_completed = 0;
766 TRACE_CATCH(fdc_command(out, 3),
767 fdc_reset();
768 TRACE(ft_t_noise, "destination was: %d, resetting FDC...",
769 track));
770 /* Handle interrupts until ft_seek_completed or timeout.
771 */
772 for (;;) {
773 TRACE_CATCH(fdc_interrupt_wait(2 * FT_SECOND),);
774 if (ft_seek_completed) {
775 TRACE_CATCH(fdc_sense_interrupt_status(&st0, &pcn),);
776 if ((st0 & ST0_SEEK_END) == 0) {
777 TRACE_ABORT(-EIO, ft_t_err,
778 "no seek-end after seek completion !??");
779 }
780 break;
781 }
782 }
783#ifdef TESTING
784 time = ftape_timediff(time, ftape_timestamp()) / abs(track - ftape_current_cylinder);
785 if ((time < 900 || time > 3100) && abs(track - ftape_current_cylinder) > 5) {
786 TRACE(ft_t_warn, "Wrong FDC STEP interval: %d usecs (%d)",
787 time, track - ftape_current_cylinder);
788 }
789#endif
790 /* Verify whether we issued the right tape command.
791 */
792 /* Verify that we seek to the proper track. */
793 if (pcn != track) {
794 TRACE_ABORT(-EIO, ft_t_err, "bad seek..");
795 }
796 ftape_current_cylinder = track;
797 TRACE_EXIT 0;
798}
799
800static int perpend_mode; /* set if fdc is in perpendicular mode */
801
802static int perpend_off(void)
803{
804 __u8 perpend[] = {FDC_PERPEND, 0x00};
805 TRACE_FUN(ft_t_any);
806
807 if (perpend_mode) {
808 /* Turn off perpendicular mode */
809 perpend[1] = 0x80;
810 TRACE_CATCH(fdc_command(perpend, 2),
811 TRACE(ft_t_err,"Perpendicular mode exit failed!"));
812 perpend_mode = 0;
813 }
814 TRACE_EXIT 0;
815}
816
817static int handle_perpend(int segment_id)
818{
819 __u8 perpend[] = {FDC_PERPEND, 0x00};
820 TRACE_FUN(ft_t_any);
821
822 /* When writing QIC-3020 tapes, turn on perpendicular mode
823 * if tape is moving in forward direction (even tracks).
824 */
825 if (ft_qic_std == QIC_TAPE_QIC3020 &&
826 ((segment_id / ft_segments_per_track) & 1) == 0) {
827/* FIXME: some i82077 seem to support perpendicular mode as
828 * well.
829 */
830#if 0
831 if (fdc.type < i82077AA) {}
832#else
833 if (fdc.type < i82077 && ft_data_rate < 1000) {
834#endif
835 /* fdc does not support perpendicular mode: complain
836 */
837 TRACE_ABORT(-EIO, ft_t_err,
838 "Your FDC does not support QIC-3020.");
839 }
840 perpend[1] = 0x03 /* 0x83 + (0x4 << ft_drive_sel) */ ;
841 TRACE_CATCH(fdc_command(perpend, 2),
842 TRACE(ft_t_err,"Perpendicular mode entry failed!"));
843 TRACE(ft_t_flow, "Perpendicular mode set");
844 perpend_mode = 1;
845 TRACE_EXIT 0;
846 }
847 TRACE_EXIT perpend_off();
848}
849
850static inline void fdc_setup_dma(char mode,
851 volatile void *addr, unsigned int count)
852{
853 /* Program the DMA controller.
854 */
855 disable_dma(fdc.dma);
856 clear_dma_ff(fdc.dma);
857 set_dma_mode(fdc.dma, mode);
858 set_dma_addr(fdc.dma, virt_to_bus((void*)addr));
859 set_dma_count(fdc.dma, count);
860 enable_dma(fdc.dma);
861}
862
863/* Setup fdc and dma for formatting the next segment
864 */
865int fdc_setup_formatting(buffer_struct * buff)
866{
867 unsigned long flags;
868 __u8 out[6] = {
869 FDC_FORMAT, 0x00, 3, 4 * FT_SECTORS_PER_SEGMENT, 0x00, 0x6b
870 };
871 TRACE_FUN(ft_t_any);
872
873 TRACE_CATCH(handle_perpend(buff->segment_id),);
874 /* Program the DMA controller.
875 */
876 TRACE(ft_t_fdc_dma,
877 "phys. addr. = %lx", virt_to_bus((void*) buff->ptr));
878 spin_lock_irqsave(&fdc_io_lock, flags);
879 fdc_setup_dma(DMA_MODE_WRITE, buff->ptr, FT_SECTORS_PER_SEGMENT * 4);
880 /* Issue FDC command to start reading/writing.
881 */
882 out[1] = ft_drive_sel;
883 out[4] = buff->gap3;
884 TRACE_CATCH(fdc_setup_error = fdc_command(out, sizeof(out)),
885 restore_flags(flags); fdc_mode = fdc_idle);
886 spin_unlock_irqrestore(&fdc_io_lock, flags);
887 TRACE_EXIT 0;
888}
889
890
891/* Setup Floppy Disk Controller and DMA to read or write the next cluster
892 * of good sectors from or to the current segment.
893 */
894int fdc_setup_read_write(buffer_struct * buff, __u8 operation)
895{
896 unsigned long flags;
897 __u8 out[9];
898 int dma_mode;
899 TRACE_FUN(ft_t_any);
900
901 switch(operation) {
902 case FDC_VERIFY:
903 if (fdc.type < i82077) {
904 operation = FDC_READ;
905 }
906 case FDC_READ:
907 case FDC_READ_DELETED:
908 dma_mode = DMA_MODE_READ;
909 TRACE(ft_t_fdc_dma, "xfer %d sectors to 0x%p",
910 buff->sector_count, buff->ptr);
911 TRACE_CATCH(perpend_off(),);
912 break;
913 case FDC_WRITE_DELETED:
914 TRACE(ft_t_noise, "deleting segment %d", buff->segment_id);
915 case FDC_WRITE:
916 dma_mode = DMA_MODE_WRITE;
917 /* When writing QIC-3020 tapes, turn on perpendicular mode
918 * if tape is moving in forward direction (even tracks).
919 */
920 TRACE_CATCH(handle_perpend(buff->segment_id),);
921 TRACE(ft_t_fdc_dma, "xfer %d sectors from 0x%p",
922 buff->sector_count, buff->ptr);
923 break;
924 default:
925 TRACE_ABORT(-EIO,
926 ft_t_bug, "bug: invalid operation parameter");
927 }
928 TRACE(ft_t_fdc_dma, "phys. addr. = %lx",virt_to_bus((void*)buff->ptr));
929 spin_lock_irqsave(&fdc_io_lock, flags);
930 if (operation != FDC_VERIFY) {
931 fdc_setup_dma(dma_mode, buff->ptr,
932 FT_SECTOR_SIZE * buff->sector_count);
933 }
934 /* Issue FDC command to start reading/writing.
935 */
936 out[0] = operation;
937 out[1] = ft_drive_sel;
938 out[2] = buff->cyl;
939 out[3] = buff->head;
940 out[4] = buff->sect + buff->sector_offset;
941 out[5] = 3; /* Sector size of 1K. */
942 out[6] = out[4] + buff->sector_count - 1; /* last sector */
943 out[7] = 109; /* Gap length. */
944 out[8] = 0xff; /* No limit to transfer size. */
945 TRACE(ft_t_fdc_dma, "C: 0x%02x, H: 0x%02x, R: 0x%02x, cnt: 0x%02x",
946 out[2], out[3], out[4], out[6] - out[4] + 1);
947 spin_unlock_irqrestore(&fdc_io_lock, flags);
948 TRACE_CATCH(fdc_setup_error = fdc_command(out, 9),fdc_mode = fdc_idle);
949 TRACE_EXIT 0;
950}
951
952int fdc_fifo_threshold(__u8 threshold,
953 int *fifo_state, int *lock_state, int *fifo_thr)
954{
955 const __u8 cmd0[] = {FDC_DUMPREGS};
956 __u8 cmd1[] = {FDC_CONFIGURE, 0, (0x0f & (threshold - 1)), 0};
957 const __u8 cmd2[] = {FDC_LOCK};
958 const __u8 cmd3[] = {FDC_UNLOCK};
959 __u8 reg[10];
960 __u8 stat;
961 int i;
962 int result;
963 TRACE_FUN(ft_t_any);
964
965 if (CLK_48MHZ && fdc.type >= i82078) {
966 cmd1[0] |= FDC_CLK48_BIT;
967 }
968 /* Dump fdc internal registers for examination
969 */
970 TRACE_CATCH(fdc_command(cmd0, NR_ITEMS(cmd0)),
971 TRACE(ft_t_warn, "dumpreg cmd failed, fifo unchanged"));
972 /* Now read fdc internal registers from fifo
973 */
974 for (i = 0; i < (int)NR_ITEMS(reg); ++i) {
975 fdc_read(&reg[i]);
976 TRACE(ft_t_fdc_dma, "Register %d = 0x%02x", i, reg[i]);
977 }
978 if (fifo_state && lock_state && fifo_thr) {
979 *fifo_state = (reg[8] & 0x20) == 0;
980 *lock_state = reg[7] & 0x80;
981 *fifo_thr = 1 + (reg[8] & 0x0f);
982 }
983 TRACE(ft_t_noise,
984 "original fifo state: %sabled, threshold %d, %slocked",
985 ((reg[8] & 0x20) == 0) ? "en" : "dis",
986 1 + (reg[8] & 0x0f), (reg[7] & 0x80) ? "" : "not ");
987 /* If fdc is already locked, unlock it first ! */
988 if (reg[7] & 0x80) {
989 fdc_ready_wait(100);
990 TRACE_CATCH(fdc_issue_command(cmd3, NR_ITEMS(cmd3), &stat, 1),
991 TRACE(ft_t_bug, "FDC unlock command failed, "
992 "configuration unchanged"));
993 }
994 fdc_fifo_locked = 0;
995 /* Enable fifo and set threshold at xx bytes to allow a
996 * reasonably large latency and reduce number of dma bursts.
997 */
998 fdc_ready_wait(100);
999 if ((result = fdc_command(cmd1, NR_ITEMS(cmd1))) < 0) {
1000 TRACE(ft_t_bug, "configure cmd failed, fifo unchanged");
1001 }
1002 /* Now lock configuration so reset will not change it
1003 */
1004 if(fdc_issue_command(cmd2, NR_ITEMS(cmd2), &stat, 1) < 0 ||
1005 stat != 0x10) {
1006 TRACE_ABORT(-EIO, ft_t_bug,
1007 "FDC lock command failed, stat = 0x%02x", stat);
1008 }
1009 fdc_fifo_locked = 1;
1010 TRACE_EXIT result;
1011}
1012
1013static int fdc_fifo_enable(void)
1014{
1015 TRACE_FUN(ft_t_any);
1016
1017 if (fdc_fifo_locked) {
1018 TRACE_ABORT(0, ft_t_warn, "Fifo not enabled because locked");
1019 }
1020 TRACE_CATCH(fdc_fifo_threshold(ft_fdc_threshold /* bytes */,
1021 &fdc_fifo_state,
1022 &fdc_lock_state,
1023 &fdc_fifo_thr),);
1024 TRACE_CATCH(fdc_fifo_threshold(ft_fdc_threshold /* bytes */,
1025 NULL, NULL, NULL),);
1026 TRACE_EXIT 0;
1027}
1028
1029/* Determine fd controller type
1030 */
1031static __u8 fdc_save_state[2];
1032
1033static int fdc_probe(void)
1034{
1035 __u8 cmd[1];
1036 __u8 stat[16]; /* must be able to hold dumpregs & save results */
1037 int i;
1038 TRACE_FUN(ft_t_any);
1039
1040 /* Try to find out what kind of fd controller we have to deal with
1041 * Scheme borrowed from floppy driver:
1042 * first try if FDC_DUMPREGS command works
1043 * (this indicates that we have a 82072 or better)
1044 * then try the FDC_VERSION command (82072 doesn't support this)
1045 * then try the FDC_UNLOCK command (some older 82077's don't support this)
1046 * then try the FDC_PARTID command (82078's support this)
1047 */
1048 cmd[0] = FDC_DUMPREGS;
1049 if (fdc_issue_command(cmd, 1, stat, 1) != 0) {
1050 TRACE_ABORT(no_fdc, ft_t_bug, "No FDC found");
1051 }
1052 if (stat[0] == 0x80) {
1053 /* invalid command: must be pre 82072 */
1054 TRACE_ABORT(i8272,
1055 ft_t_warn, "Type 8272A/765A compatible FDC found");
1056 }
1057 fdc_result(&stat[1], 9);
1058 fdc_save_state[0] = stat[7];
1059 fdc_save_state[1] = stat[8];
1060 cmd[0] = FDC_VERSION;
1061 if (fdc_issue_command(cmd, 1, stat, 1) < 0 || stat[0] == 0x80) {
1062 TRACE_ABORT(i8272, ft_t_warn, "Type 82072 FDC found");
1063 }
1064 if (*stat != 0x90) {
1065 TRACE_ABORT(i8272, ft_t_warn, "Unknown FDC found");
1066 }
1067 cmd[0] = FDC_UNLOCK;
1068 if(fdc_issue_command(cmd, 1, stat, 1) < 0 || stat[0] != 0x00) {
1069 TRACE_ABORT(i8272, ft_t_warn,
1070 "Type pre-1991 82077 FDC found, "
1071 "treating it like a 82072");
1072 }
1073 if (fdc_save_state[0] & 0x80) { /* was locked */
1074 cmd[0] = FDC_LOCK; /* restore lock */
1075 (void)fdc_issue_command(cmd, 1, stat, 1);
1076 TRACE(ft_t_warn, "FDC is already locked");
1077 }
1078 /* Test for a i82078 FDC */
1079 cmd[0] = FDC_PARTID;
1080 if (fdc_issue_command(cmd, 1, stat, 1) < 0 || stat[0] == 0x80) {
1081 /* invalid command: not a i82078xx type FDC */
1082 for (i = 0; i < 4; ++i) {
1083 outb_p(i, fdc.tdr);
1084 if ((inb_p(fdc.tdr) & 0x03) != i) {
1085 TRACE_ABORT(i82077,
1086 ft_t_warn, "Type 82077 FDC found");
1087 }
1088 }
1089 TRACE_ABORT(i82077AA, ft_t_warn, "Type 82077AA FDC found");
1090 }
1091 /* FDC_PARTID cmd succeeded */
1092 switch (stat[0] >> 5) {
1093 case 0x0:
1094 /* i82078SL or i82078-1. The SL part cannot run at
1095 * 2Mbps (the SL and -1 dies are identical; they are
1096 * speed graded after production, according to Intel).
1097 * Some SL's can be detected by doing a SAVE cmd and
1098 * look at bit 7 of the first byte (the SEL3V# bit).
1099 * If it is 0, the part runs off 3Volts, and hence it
1100 * is a SL.
1101 */
1102 cmd[0] = FDC_SAVE;
1103 if(fdc_issue_command(cmd, 1, stat, 16) < 0) {
1104 TRACE(ft_t_err, "FDC_SAVE failed. Dunno why");
1105 /* guess we better claim the fdc to be a i82078 */
1106 TRACE_ABORT(i82078,
1107 ft_t_warn,
1108 "Type i82078 FDC (i suppose) found");
1109 }
1110 if ((stat[0] & FDC_SEL3V_BIT)) {
1111 /* fdc running off 5Volts; Pray that it's a i82078-1
1112 */
1113 TRACE_ABORT(i82078_1, ft_t_warn,
1114 "Type i82078-1 or 5Volt i82078SL FDC found");
1115 }
1116 TRACE_ABORT(i82078, ft_t_warn,
1117 "Type 3Volt i82078SL FDC (1Mbps) found");
1118 case 0x1:
1119 case 0x2: /* S82078B */
1120 /* The '78B isn't '78 compatible. Detect it as a '77AA */
1121 TRACE_ABORT(i82077AA, ft_t_warn, "Type i82077AA FDC found");
1122 case 0x3: /* NSC PC8744 core; used in several super-IO chips */
1123 TRACE_ABORT(i82077AA,
1124 ft_t_warn, "Type 82077AA compatible FDC found");
1125 default:
1126 TRACE(ft_t_warn, "A previously undetected FDC found");
1127 TRACE_ABORT(i82077AA, ft_t_warn,
1128 "Treating it as a 82077AA. Please report partid= %d",
1129 stat[0]);
1130 } /* switch(stat[ 0] >> 5) */
1131 TRACE_EXIT no_fdc;
1132}
1133
1134static int fdc_request_regions(void)
1135{
1136 TRACE_FUN(ft_t_flow);
1137
1138 if (ft_mach2 || ft_probe_fc10) {
1139 if (!request_region(fdc.sra, 8, "fdc (ft)")) {
1140#ifndef BROKEN_FLOPPY_DRIVER
1141 TRACE_EXIT -EBUSY;
1142#else
1143 TRACE(ft_t_warn,
1144"address 0x%03x occupied (by floppy driver?), using it anyway", fdc.sra);
1145#endif
1146 }
1147 } else {
1148 if (!request_region(fdc.sra, 6, "fdc (ft)")) {
1149#ifndef BROKEN_FLOPPY_DRIVER
1150 TRACE_EXIT -EBUSY;
1151#else
1152 TRACE(ft_t_warn,
1153"address 0x%03x occupied (by floppy driver?), using it anyway", fdc.sra);
1154#endif
1155 }
1156 if (!request_region(fdc.sra + 7, 1, "fdc (ft)")) {
1157#ifndef BROKEN_FLOPPY_DRIVER
1158 release_region(fdc.sra, 6);
1159 TRACE_EXIT -EBUSY;
1160#else
1161 TRACE(ft_t_warn,
1162"address 0x%03x occupied (by floppy driver?), using it anyway", fdc.sra + 7);
1163#endif
1164 }
1165 }
1166 TRACE_EXIT 0;
1167}
1168
1169void fdc_release_regions(void)
1170{
1171 TRACE_FUN(ft_t_flow);
1172
1173 if (fdc.sra != 0) {
1174 if (fdc.dor2 != 0) {
1175 release_region(fdc.sra, 8);
1176 } else {
1177 release_region(fdc.sra, 6);
1178 release_region(fdc.dir, 1);
1179 }
1180 }
1181 TRACE_EXIT;
1182}
1183
1184static int fdc_config_regs(unsigned int fdc_base,
1185 unsigned int fdc_irq,
1186 unsigned int fdc_dma)
1187{
1188 TRACE_FUN(ft_t_flow);
1189
1190 fdc.irq = fdc_irq;
1191 fdc.dma = fdc_dma;
1192 fdc.sra = fdc_base;
1193 fdc.srb = fdc_base + 1;
1194 fdc.dor = fdc_base + 2;
1195 fdc.tdr = fdc_base + 3;
1196 fdc.msr = fdc.dsr = fdc_base + 4;
1197 fdc.fifo = fdc_base + 5;
1198 fdc.dir = fdc.ccr = fdc_base + 7;
1199 fdc.dor2 = (ft_mach2 || ft_probe_fc10) ? fdc_base + 6 : 0;
1200 TRACE_CATCH(fdc_request_regions(), fdc.sra = 0);
1201 TRACE_EXIT 0;
1202}
1203
1204static int fdc_config(void)
1205{
1206 static int already_done;
1207 TRACE_FUN(ft_t_any);
1208
1209 if (already_done) {
1210 TRACE_CATCH(fdc_request_regions(),);
1211 *(fdc.hook) = fdc_isr; /* hook our handler in */
1212 TRACE_EXIT 0;
1213 }
1214 if (ft_probe_fc10) {
1215 int fc_type;
1216
1217 TRACE_CATCH(fdc_config_regs(ft_fdc_base,
1218 ft_fdc_irq, ft_fdc_dma),);
1219 fc_type = fc10_enable();
1220 if (fc_type != 0) {
1221 TRACE(ft_t_warn, "FC-%c0 controller found", '0' + fc_type);
1222 fdc.type = fc10;
1223 fdc.hook = &do_ftape;
1224 *(fdc.hook) = fdc_isr; /* hook our handler in */
1225 already_done = 1;
1226 TRACE_EXIT 0;
1227 } else {
1228 TRACE(ft_t_warn, "FC-10/20 controller not found");
1229 fdc_release_regions();
1230 fdc.type = no_fdc;
1231 ft_probe_fc10 = 0;
1232 ft_fdc_base = 0x3f0;
1233 ft_fdc_irq = 6;
1234 ft_fdc_dma = 2;
1235 }
1236 }
1237 TRACE(ft_t_warn, "fdc base: 0x%x, irq: %d, dma: %d",
1238 ft_fdc_base, ft_fdc_irq, ft_fdc_dma);
1239 TRACE_CATCH(fdc_config_regs(ft_fdc_base, ft_fdc_irq, ft_fdc_dma),);
1240 fdc.hook = &do_ftape;
1241 *(fdc.hook) = fdc_isr; /* hook our handler in */
1242 already_done = 1;
1243 TRACE_EXIT 0;
1244}
1245
1246static irqreturn_t ftape_interrupt(int irq, void *dev_id)
1247{
1248 void (*handler) (void) = *fdc.hook;
1249 int handled = 0;
1250 TRACE_FUN(ft_t_any);
1251
1252 *fdc.hook = NULL;
1253 if (handler) {
1254 handled = 1;
1255 handler();
1256 } else {
1257 TRACE(ft_t_bug, "Unexpected ftape interrupt");
1258 }
1259 TRACE_EXIT IRQ_RETVAL(handled);
1260}
1261
1262static int fdc_grab_irq_and_dma(void)
1263{
1264 TRACE_FUN(ft_t_any);
1265
1266 if (fdc.hook == &do_ftape) {
1267 /* Get fast interrupt handler.
1268 */
1269 if (request_irq(fdc.irq, ftape_interrupt,
1270 IRQF_DISABLED, "ft", ftape_id)) {
1271 TRACE_ABORT(-EIO, ft_t_bug,
1272 "Unable to grab IRQ%d for ftape driver",
1273 fdc.irq);
1274 }
1275 if (request_dma(fdc.dma, ftape_id)) {
1276 free_irq(fdc.irq, ftape_id);
1277 TRACE_ABORT(-EIO, ft_t_bug,
1278 "Unable to grab DMA%d for ftape driver",
1279 fdc.dma);
1280 }
1281 }
1282 if (ft_fdc_base != 0x3f0 && (ft_fdc_dma == 2 || ft_fdc_irq == 6)) {
1283 /* Using same dma channel or irq as standard fdc, need
1284 * to disable the dma-gate on the std fdc. This
1285 * couldn't be done in the floppy driver as some
1286 * laptops are using the dma-gate to enter a low power
1287 * or even suspended state :-(
1288 */
1289 outb_p(FDC_RESET_NOT, 0x3f2);
1290 TRACE(ft_t_noise, "DMA-gate on standard fdc disabled");
1291 }
1292 TRACE_EXIT 0;
1293}
1294
1295int fdc_release_irq_and_dma(void)
1296{
1297 TRACE_FUN(ft_t_any);
1298
1299 if (fdc.hook == &do_ftape) {
1300 disable_dma(fdc.dma); /* just in case... */
1301 free_dma(fdc.dma);
1302 free_irq(fdc.irq, ftape_id);
1303 }
1304 if (ft_fdc_base != 0x3f0 && (ft_fdc_dma == 2 || ft_fdc_irq == 6)) {
1305 /* Using same dma channel as standard fdc, need to
1306 * disable the dma-gate on the std fdc. This couldn't
1307 * be done in the floppy driver as some laptops are
1308 * using the dma-gate to enter a low power or even
1309 * suspended state :-(
1310 */
1311 outb_p(FDC_RESET_NOT | FDC_DMA_MODE, 0x3f2);
1312 TRACE(ft_t_noise, "DMA-gate on standard fdc enabled again");
1313 }
1314 TRACE_EXIT 0;
1315}
1316
1317int fdc_init(void)
1318{
1319 TRACE_FUN(ft_t_any);
1320
1321 /* find a FDC to use */
1322 TRACE_CATCH(fdc_config(),);
1323 TRACE_CATCH(fdc_grab_irq_and_dma(), fdc_release_regions());
1324 ftape_motor = 0;
1325 fdc_catch_stray_interrupts(0); /* clear number of awainted
1326 * stray interrupte
1327 */
1328 fdc_catch_stray_interrupts(1); /* one always comes (?) */
1329 TRACE(ft_t_flow, "resetting fdc");
1330 fdc_set_seek_rate(2); /* use nominal QIC step rate */
1331 fdc_reset(); /* init fdc & clear track counters */
1332 if (fdc.type == no_fdc) { /* no FC-10 or FC-20 found */
1333 fdc.type = fdc_probe();
1334 fdc_reset(); /* update with new knowledge */
1335 }
1336 if (fdc.type == no_fdc) {
1337 fdc_release_irq_and_dma();
1338 fdc_release_regions();
1339 TRACE_EXIT -ENXIO;
1340 }
1341 if (fdc.type >= i82077) {
1342 if (fdc_fifo_enable() < 0) {
1343 TRACE(ft_t_warn, "couldn't enable fdc fifo !");
1344 } else {
1345 TRACE(ft_t_flow, "fdc fifo enabled and locked");
1346 }
1347 }
1348 TRACE_EXIT 0;
1349}
diff --git a/drivers/char/ftape/lowlevel/fdc-io.h b/drivers/char/ftape/lowlevel/fdc-io.h
deleted file mode 100644
index 7ec3c72178bb..000000000000
--- a/drivers/char/ftape/lowlevel/fdc-io.h
+++ /dev/null
@@ -1,252 +0,0 @@
1#ifndef _FDC_IO_H
2#define _FDC_IO_H
3
4/*
5 * Copyright (C) 1993-1996 Bas Laarhoven,
6 * (C) 1996-1997 Claus-Justus Heine.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; see the file COPYING. If not, write to
20 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21
22 *
23 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/fdc-io.h,v $
24 * $Revision: 1.3 $
25 * $Date: 1997/10/05 19:18:06 $
26 *
27 * This file contains the declarations for the low level
28 * functions that communicate with the floppy disk controller,
29 * for the QIC-40/80/3010/3020 floppy-tape driver "ftape" for
30 * Linux.
31 */
32
33#include <linux/fdreg.h>
34
35#include "../lowlevel/ftape-bsm.h"
36
37#define FDC_SK_BIT (0x20)
38#define FDC_MT_BIT (0x80)
39
40#define FDC_READ (FD_READ & ~(FDC_SK_BIT | FDC_MT_BIT))
41#define FDC_WRITE (FD_WRITE & ~FDC_MT_BIT)
42#define FDC_READ_DELETED (0x4c)
43#define FDC_WRITE_DELETED (0x49)
44#define FDC_VERIFY (0x56)
45#define FDC_READID (0x4a)
46#define FDC_SENSED (0x04)
47#define FDC_SENSEI (FD_SENSEI)
48#define FDC_FORMAT (FD_FORMAT)
49#define FDC_RECAL (FD_RECALIBRATE)
50#define FDC_SEEK (FD_SEEK)
51#define FDC_SPECIFY (FD_SPECIFY)
52#define FDC_RECALIBR (FD_RECALIBRATE)
53#define FDC_VERSION (FD_VERSION)
54#define FDC_PERPEND (FD_PERPENDICULAR)
55#define FDC_DUMPREGS (FD_DUMPREGS)
56#define FDC_LOCK (FD_LOCK)
57#define FDC_UNLOCK (FD_UNLOCK)
58#define FDC_CONFIGURE (FD_CONFIGURE)
59#define FDC_DRIVE_SPEC (0x8e) /* i82078 has this (any others?) */
60#define FDC_PARTID (0x18) /* i82078 has this */
61#define FDC_SAVE (0x2e) /* i82078 has this (any others?) */
62#define FDC_RESTORE (0x4e) /* i82078 has this (any others?) */
63
64#define FDC_STATUS_MASK (STATUS_BUSY | STATUS_DMA | STATUS_DIR | STATUS_READY)
65#define FDC_DATA_READY (STATUS_READY)
66#define FDC_DATA_OUTPUT (STATUS_DIR)
67#define FDC_DATA_READY_MASK (STATUS_READY | STATUS_DIR)
68#define FDC_DATA_OUT_READY (STATUS_READY | STATUS_DIR)
69#define FDC_DATA_IN_READY (STATUS_READY)
70#define FDC_BUSY (STATUS_BUSY)
71#define FDC_CLK48_BIT (0x80)
72#define FDC_SEL3V_BIT (0x40)
73
74#define ST0_INT_MASK (ST0_INTR)
75#define FDC_INT_NORMAL (ST0_INTR & 0x00)
76#define FDC_INT_ABNORMAL (ST0_INTR & 0x40)
77#define FDC_INT_INVALID (ST0_INTR & 0x80)
78#define FDC_INT_READYCH (ST0_INTR & 0xC0)
79#define ST0_SEEK_END (ST0_SE)
80#define ST3_TRACK_0 (ST3_TZ)
81
82#define FDC_RESET_NOT (0x04)
83#define FDC_DMA_MODE (0x08)
84#define FDC_MOTOR_0 (0x10)
85#define FDC_MOTOR_1 (0x20)
86
87typedef struct {
88 void (**hook) (void); /* our wedge into the isr */
89 enum {
90 no_fdc, i8272, i82077, i82077AA, fc10,
91 i82078, i82078_1
92 } type; /* FDC type */
93 unsigned int irq; /* FDC irq nr */
94 unsigned int dma; /* FDC dma channel nr */
95 __u16 sra; /* Status register A (PS/2 only) */
96 __u16 srb; /* Status register B (PS/2 only) */
97 __u16 dor; /* Digital output register */
98 __u16 tdr; /* Tape Drive Register (82077SL-1 &
99 82078 only) */
100 __u16 msr; /* Main Status Register */
101 __u16 dsr; /* Datarate Select Register (8207x only) */
102 __u16 fifo; /* Data register / Fifo on 8207x */
103 __u16 dir; /* Digital Input Register */
104 __u16 ccr; /* Configuration Control Register */
105 __u16 dor2; /* Alternate dor on MACH-2 controller,
106 also used with FC-10, meaning unknown */
107} fdc_config_info;
108
109typedef enum {
110 fdc_data_rate_250 = 2,
111 fdc_data_rate_300 = 1, /* any fdc in default configuration */
112 fdc_data_rate_500 = 0,
113 fdc_data_rate_1000 = 3,
114 fdc_data_rate_2000 = 1, /* i82078-1: when using Data Rate Table #2 */
115} fdc_data_rate_type;
116
117typedef enum {
118 fdc_idle = 0,
119 fdc_reading_data = FDC_READ,
120 fdc_seeking = FDC_SEEK,
121 fdc_writing_data = FDC_WRITE,
122 fdc_deleting = FDC_WRITE_DELETED,
123 fdc_reading_id = FDC_READID,
124 fdc_recalibrating = FDC_RECAL,
125 fdc_formatting = FDC_FORMAT,
126 fdc_verifying = FDC_VERIFY
127} fdc_mode_enum;
128
129typedef enum {
130 waiting = 0,
131 reading,
132 writing,
133 formatting,
134 verifying,
135 deleting,
136 done,
137 error,
138 mmapped,
139} buffer_state_enum;
140
141typedef struct {
142 __u8 *address;
143 volatile buffer_state_enum status;
144 volatile __u8 *ptr;
145 volatile unsigned int bytes;
146 volatile unsigned int segment_id;
147
148 /* bitmap for remainder of segment not yet handled.
149 * one bit set for each bad sector that must be skipped.
150 */
151 volatile SectorMap bad_sector_map;
152
153 /* bitmap with bad data blocks in data buffer.
154 * the errors in this map may be retried.
155 */
156 volatile SectorMap soft_error_map;
157
158 /* bitmap with bad data blocks in data buffer
159 * the errors in this map may not be retried.
160 */
161 volatile SectorMap hard_error_map;
162
163 /* retry counter for soft errors.
164 */
165 volatile int retry;
166
167 /* sectors to skip on retry ???
168 */
169 volatile unsigned int skip;
170
171 /* nr of data blocks in data buffer
172 */
173 volatile unsigned int data_offset;
174
175 /* offset in segment for first sector to be handled.
176 */
177 volatile unsigned int sector_offset;
178
179 /* size of cluster of good sectors to be handled.
180 */
181 volatile unsigned int sector_count;
182
183 /* size of remaining part of segment to be handled.
184 */
185 volatile unsigned int remaining;
186
187 /* points to next segment (contiguous) to be handled,
188 * or is zero if no read-ahead is allowed.
189 */
190 volatile unsigned int next_segment;
191
192 /* flag being set if deleted data was read.
193 */
194 volatile int deleted;
195
196 /* floppy coordinates of first sector in segment */
197 volatile __u8 head;
198 volatile __u8 cyl;
199 volatile __u8 sect;
200
201 /* gap to use when formatting */
202 __u8 gap3;
203 /* flag set when buffer is mmaped */
204 int mmapped;
205} buffer_struct;
206
207/*
208 * fdc-io.c defined public variables
209 */
210extern volatile fdc_mode_enum fdc_mode;
211extern int fdc_setup_error; /* outdated ??? */
212extern wait_queue_head_t ftape_wait_intr;
213extern volatile int ftape_current_cylinder; /* track nr FDC thinks we're on */
214extern volatile __u8 fdc_head; /* FDC head */
215extern volatile __u8 fdc_cyl; /* FDC track */
216extern volatile __u8 fdc_sect; /* FDC sector */
217extern fdc_config_info fdc; /* FDC hardware configuration */
218
219extern unsigned int ft_fdc_base;
220extern unsigned int ft_fdc_irq;
221extern unsigned int ft_fdc_dma;
222extern unsigned int ft_fdc_threshold;
223extern unsigned int ft_fdc_rate_limit;
224extern int ft_probe_fc10;
225extern int ft_mach2;
226/*
227 * fdc-io.c defined public functions
228 */
229extern void fdc_catch_stray_interrupts(int count);
230extern int fdc_ready_wait(unsigned int timeout);
231extern int fdc_command(const __u8 * cmd_data, int cmd_len);
232extern int fdc_result(__u8 * res_data, int res_len);
233extern int fdc_interrupt_wait(unsigned int time);
234extern int fdc_seek(int track);
235extern int fdc_sense_drive_status(int *st3);
236extern void fdc_motor(int motor);
237extern void fdc_reset(void);
238extern void fdc_disable(void);
239extern int fdc_fifo_threshold(__u8 threshold,
240 int *fifo_state, int *lock_state, int *fifo_thr);
241extern void fdc_wait_calibrate(void);
242extern int fdc_sense_interrupt_status(int *st0, int *current_cylinder);
243extern void fdc_save_drive_specs(void);
244extern void fdc_restore_drive_specs(void);
245extern int fdc_set_data_rate(int rate);
246extern void fdc_set_write_precomp(int precomp);
247extern int fdc_release_irq_and_dma(void);
248extern void fdc_release_regions(void);
249extern int fdc_init(void);
250extern int fdc_setup_read_write(buffer_struct * buff, __u8 operation);
251extern int fdc_setup_formatting(buffer_struct * buff);
252#endif
diff --git a/drivers/char/ftape/lowlevel/fdc-isr.c b/drivers/char/ftape/lowlevel/fdc-isr.c
deleted file mode 100644
index ad2bc733ae1b..000000000000
--- a/drivers/char/ftape/lowlevel/fdc-isr.c
+++ /dev/null
@@ -1,1170 +0,0 @@
1/*
2 * Copyright (C) 1994-1996 Bas Laarhoven,
3 * (C) 1996-1997 Claus-Justus Heine.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
8 any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; see the file COPYING. If not, write to
17 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 *
20 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/fdc-isr.c,v $
21 * $Revision: 1.9 $
22 * $Date: 1997/10/17 23:01:53 $
23 *
24 * This file contains the interrupt service routine and
25 * associated code for the QIC-40/80/3010/3020 floppy-tape driver
26 * "ftape" for Linux.
27 */
28
29#include <asm/io.h>
30#include <asm/dma.h>
31
32#define volatile /* */
33
34#include <linux/ftape.h>
35#include <linux/qic117.h>
36#include "../lowlevel/ftape-tracing.h"
37#include "../lowlevel/fdc-isr.h"
38#include "../lowlevel/fdc-io.h"
39#include "../lowlevel/ftape-ctl.h"
40#include "../lowlevel/ftape-rw.h"
41#include "../lowlevel/ftape-io.h"
42#include "../lowlevel/ftape-calibr.h"
43#include "../lowlevel/ftape-bsm.h"
44
45/* Global vars.
46 */
47volatile int ft_expected_stray_interrupts;
48volatile int ft_interrupt_seen;
49volatile int ft_seek_completed;
50volatile int ft_hide_interrupt;
51/* Local vars.
52 */
53typedef enum {
54 no_error = 0, id_am_error = 0x01, id_crc_error = 0x02,
55 data_am_error = 0x04, data_crc_error = 0x08,
56 no_data_error = 0x10, overrun_error = 0x20,
57} error_cause;
58static int stop_read_ahead;
59
60
61static void print_error_cause(int cause)
62{
63 TRACE_FUN(ft_t_any);
64
65 switch (cause) {
66 case no_data_error:
67 TRACE(ft_t_noise, "no data error");
68 break;
69 case id_am_error:
70 TRACE(ft_t_noise, "id am error");
71 break;
72 case id_crc_error:
73 TRACE(ft_t_noise, "id crc error");
74 break;
75 case data_am_error:
76 TRACE(ft_t_noise, "data am error");
77 break;
78 case data_crc_error:
79 TRACE(ft_t_noise, "data crc error");
80 break;
81 case overrun_error:
82 TRACE(ft_t_noise, "overrun error");
83 break;
84 default:;
85 }
86 TRACE_EXIT;
87}
88
89static char *fdc_mode_txt(fdc_mode_enum mode)
90{
91 switch (mode) {
92 case fdc_idle:
93 return "fdc_idle";
94 case fdc_reading_data:
95 return "fdc_reading_data";
96 case fdc_seeking:
97 return "fdc_seeking";
98 case fdc_writing_data:
99 return "fdc_writing_data";
100 case fdc_reading_id:
101 return "fdc_reading_id";
102 case fdc_recalibrating:
103 return "fdc_recalibrating";
104 case fdc_formatting:
105 return "fdc_formatting";
106 case fdc_verifying:
107 return "fdc_verifying";
108 default:
109 return "unknown";
110 }
111}
112
113static inline error_cause decode_irq_cause(fdc_mode_enum mode, __u8 st[])
114{
115 error_cause cause = no_error;
116 TRACE_FUN(ft_t_any);
117
118 /* Valid st[], decode cause of interrupt.
119 */
120 switch (st[0] & ST0_INT_MASK) {
121 case FDC_INT_NORMAL:
122 TRACE(ft_t_fdc_dma,"normal completion: %s",fdc_mode_txt(mode));
123 break;
124 case FDC_INT_ABNORMAL:
125 TRACE(ft_t_flow, "abnormal completion %s", fdc_mode_txt(mode));
126 TRACE(ft_t_fdc_dma, "ST0: 0x%02x, ST1: 0x%02x, ST2: 0x%02x",
127 st[0], st[1], st[2]);
128 TRACE(ft_t_fdc_dma,
129 "C: 0x%02x, H: 0x%02x, R: 0x%02x, N: 0x%02x",
130 st[3], st[4], st[5], st[6]);
131 if (st[1] & 0x01) {
132 if (st[2] & 0x01) {
133 cause = data_am_error;
134 } else {
135 cause = id_am_error;
136 }
137 } else if (st[1] & 0x20) {
138 if (st[2] & 0x20) {
139 cause = data_crc_error;
140 } else {
141 cause = id_crc_error;
142 }
143 } else if (st[1] & 0x04) {
144 cause = no_data_error;
145 } else if (st[1] & 0x10) {
146 cause = overrun_error;
147 }
148 print_error_cause(cause);
149 break;
150 case FDC_INT_INVALID:
151 TRACE(ft_t_flow, "invalid completion %s", fdc_mode_txt(mode));
152 break;
153 case FDC_INT_READYCH:
154 if (st[0] & ST0_SEEK_END) {
155 TRACE(ft_t_flow, "drive poll completed");
156 } else {
157 TRACE(ft_t_flow, "ready change %s",fdc_mode_txt(mode));
158 }
159 break;
160 default:
161 break;
162 }
163 TRACE_EXIT cause;
164}
165
166static void update_history(error_cause cause)
167{
168 switch (cause) {
169 case id_am_error:
170 ft_history.id_am_errors++;
171 break;
172 case id_crc_error:
173 ft_history.id_crc_errors++;
174 break;
175 case data_am_error:
176 ft_history.data_am_errors++;
177 break;
178 case data_crc_error:
179 ft_history.data_crc_errors++;
180 break;
181 case overrun_error:
182 ft_history.overrun_errors++;
183 break;
184 case no_data_error:
185 ft_history.no_data_errors++;
186 break;
187 default:;
188 }
189}
190
191static void skip_bad_sector(buffer_struct * buff)
192{
193 TRACE_FUN(ft_t_any);
194
195 /* Mark sector as soft error and skip it
196 */
197 if (buff->remaining > 0) {
198 ++buff->sector_offset;
199 ++buff->data_offset;
200 --buff->remaining;
201 buff->ptr += FT_SECTOR_SIZE;
202 buff->bad_sector_map >>= 1;
203 } else {
204 /* Hey, what is this????????????? C code: if we shift
205 * more than 31 bits, we get no shift. That's bad!!!!!!
206 */
207 ++buff->sector_offset; /* hack for error maps */
208 TRACE(ft_t_warn, "skipping last sector in segment");
209 }
210 TRACE_EXIT;
211}
212
213static void update_error_maps(buffer_struct * buff, unsigned int error_offset)
214{
215 int hard = 0;
216 TRACE_FUN(ft_t_any);
217
218 if (buff->retry < FT_SOFT_RETRIES) {
219 buff->soft_error_map |= (1 << error_offset);
220 } else {
221 buff->hard_error_map |= (1 << error_offset);
222 buff->soft_error_map &= ~buff->hard_error_map;
223 buff->retry = -1; /* will be set to 0 in setup_segment */
224 hard = 1;
225 }
226 TRACE(ft_t_noise, "sector %d : %s error\n"
227 KERN_INFO "hard map: 0x%08lx\n"
228 KERN_INFO "soft map: 0x%08lx",
229 FT_SECTOR(error_offset), hard ? "hard" : "soft",
230 (long) buff->hard_error_map, (long) buff->soft_error_map);
231 TRACE_EXIT;
232}
233
234static void print_progress(buffer_struct *buff, error_cause cause)
235{
236 TRACE_FUN(ft_t_any);
237
238 switch (cause) {
239 case no_error:
240 TRACE(ft_t_flow,"%d Sector(s) transferred", buff->sector_count);
241 break;
242 case no_data_error:
243 TRACE(ft_t_flow, "Sector %d not found",
244 FT_SECTOR(buff->sector_offset));
245 break;
246 case overrun_error:
247 /* got an overrun error on the first byte, must be a
248 * hardware problem
249 */
250 TRACE(ft_t_bug,
251 "Unexpected error: failing DMA or FDC controller ?");
252 break;
253 case data_crc_error:
254 TRACE(ft_t_flow, "Error in sector %d",
255 FT_SECTOR(buff->sector_offset - 1));
256 break;
257 case id_crc_error:
258 case id_am_error:
259 case data_am_error:
260 TRACE(ft_t_flow, "Error in sector %d",
261 FT_SECTOR(buff->sector_offset));
262 break;
263 default:
264 TRACE(ft_t_flow, "Unexpected error at sector %d",
265 FT_SECTOR(buff->sector_offset));
266 break;
267 }
268 TRACE_EXIT;
269}
270
271/*
272 * Error cause: Amount xferred: Action:
273 *
274 * id_am_error 0 mark bad and skip
275 * id_crc_error 0 mark bad and skip
276 * data_am_error 0 mark bad and skip
277 * data_crc_error % 1024 mark bad and skip
278 * no_data_error 0 retry on write
279 * mark bad and skip on read
280 * overrun_error [ 0..all-1 ] mark bad and skip
281 * no_error all continue
282 */
283
284/* the arg `sector' is returned by the fdc and tells us at which sector we
285 * are positioned at (relative to starting sector of segment)
286 */
287static void determine_verify_progress(buffer_struct *buff,
288 error_cause cause,
289 __u8 sector)
290{
291 TRACE_FUN(ft_t_any);
292
293 if (cause == no_error && sector == 1) {
294 buff->sector_offset = FT_SECTORS_PER_SEGMENT;
295 buff->remaining = 0;
296 if (TRACE_LEVEL >= ft_t_flow) {
297 print_progress(buff, cause);
298 }
299 } else {
300 buff->sector_offset = sector - buff->sect;
301 buff->remaining = FT_SECTORS_PER_SEGMENT - buff->sector_offset;
302 TRACE(ft_t_noise, "%ssector offset: 0x%04x",
303 (cause == no_error) ? "unexpected " : "",
304 buff->sector_offset);
305 switch (cause) {
306 case overrun_error:
307 break;
308#if 0
309 case no_data_error:
310 buff->retry = FT_SOFT_RETRIES;
311 if (buff->hard_error_map &&
312 buff->sector_offset > 1 &&
313 (buff->hard_error_map &
314 (1 << (buff->sector_offset-2)))) {
315 buff->retry --;
316 }
317 break;
318#endif
319 default:
320 buff->retry = FT_SOFT_RETRIES;
321 break;
322 }
323 if (TRACE_LEVEL >= ft_t_flow) {
324 print_progress(buff, cause);
325 }
326 /* Sector_offset points to the problem area Now adjust
327 * sector_offset so it always points one past he failing
328 * sector. I.e. skip the bad sector.
329 */
330 ++buff->sector_offset;
331 --buff->remaining;
332 update_error_maps(buff, buff->sector_offset - 1);
333 }
334 TRACE_EXIT;
335}
336
337static void determine_progress(buffer_struct *buff,
338 error_cause cause,
339 __u8 sector)
340{
341 unsigned int dma_residue;
342 TRACE_FUN(ft_t_any);
343
344 /* Using less preferred order of disable_dma and
345 * get_dma_residue because this seems to fail on at least one
346 * system if reversed!
347 */
348 dma_residue = get_dma_residue(fdc.dma);
349 disable_dma(fdc.dma);
350 if (cause != no_error || dma_residue != 0) {
351 TRACE(ft_t_noise, "%sDMA residue: 0x%04x",
352 (cause == no_error) ? "unexpected " : "",
353 dma_residue);
354 /* adjust to actual value: */
355 if (dma_residue == 0) {
356 /* this happens sometimes with overrun errors.
357 * I don't know whether we could ignore the
358 * overrun error. Play save.
359 */
360 buff->sector_count --;
361 } else {
362 buff->sector_count -= ((dma_residue +
363 (FT_SECTOR_SIZE - 1)) /
364 FT_SECTOR_SIZE);
365 }
366 }
367 /* Update var's influenced by the DMA operation.
368 */
369 if (buff->sector_count > 0) {
370 buff->sector_offset += buff->sector_count;
371 buff->data_offset += buff->sector_count;
372 buff->ptr += (buff->sector_count *
373 FT_SECTOR_SIZE);
374 buff->remaining -= buff->sector_count;
375 buff->bad_sector_map >>= buff->sector_count;
376 }
377 if (TRACE_LEVEL >= ft_t_flow) {
378 print_progress(buff, cause);
379 }
380 if (cause != no_error) {
381 if (buff->remaining == 0) {
382 TRACE(ft_t_warn, "foo?\n"
383 KERN_INFO "count : %d\n"
384 KERN_INFO "offset: %d\n"
385 KERN_INFO "soft : %08x\n"
386 KERN_INFO "hard : %08x",
387 buff->sector_count,
388 buff->sector_offset,
389 buff->soft_error_map,
390 buff->hard_error_map);
391 }
392 /* Sector_offset points to the problem area, except if we got
393 * a data_crc_error. In that case it points one past the
394 * failing sector.
395 *
396 * Now adjust sector_offset so it always points one past he
397 * failing sector. I.e. skip the bad sector.
398 */
399 if (cause != data_crc_error) {
400 skip_bad_sector(buff);
401 }
402 update_error_maps(buff, buff->sector_offset - 1);
403 }
404 TRACE_EXIT;
405}
406
407static int calc_steps(int cmd)
408{
409 if (ftape_current_cylinder > cmd) {
410 return ftape_current_cylinder - cmd;
411 } else {
412 return ftape_current_cylinder + cmd;
413 }
414}
415
416static void pause_tape(int retry, int mode)
417{
418 int result;
419 __u8 out[3] = {FDC_SEEK, ft_drive_sel, 0};
420 TRACE_FUN(ft_t_any);
421
422 /* We'll use a raw seek command to get the tape to rewind and
423 * stop for a retry.
424 */
425 ++ft_history.rewinds;
426 if (qic117_cmds[ftape_current_command].non_intr) {
427 TRACE(ft_t_warn, "motion command may be issued too soon");
428 }
429 if (retry && (mode == fdc_reading_data ||
430 mode == fdc_reading_id ||
431 mode == fdc_verifying)) {
432 ftape_current_command = QIC_MICRO_STEP_PAUSE;
433 ftape_might_be_off_track = 1;
434 } else {
435 ftape_current_command = QIC_PAUSE;
436 }
437 out[2] = calc_steps(ftape_current_command);
438 result = fdc_command(out, 3); /* issue QIC_117 command */
439 ftape_current_cylinder = out[ 2];
440 if (result < 0) {
441 TRACE(ft_t_noise, "qic-pause failed, status = %d", result);
442 } else {
443 ft_location.known = 0;
444 ft_runner_status = idle;
445 ft_hide_interrupt = 1;
446 ftape_tape_running = 0;
447 }
448 TRACE_EXIT;
449}
450
451static void continue_xfer(buffer_struct *buff,
452 fdc_mode_enum mode,
453 unsigned int skip)
454{
455 int write = 0;
456 TRACE_FUN(ft_t_any);
457
458 if (mode == fdc_writing_data || mode == fdc_deleting) {
459 write = 1;
460 }
461 /* This part can be removed if it never happens
462 */
463 if (skip > 0 &&
464 (ft_runner_status != running ||
465 (write && (buff->status != writing)) ||
466 (!write && (buff->status != reading &&
467 buff->status != verifying)))) {
468 TRACE(ft_t_err, "unexpected runner/buffer state %d/%d",
469 ft_runner_status, buff->status);
470 buff->status = error;
471 /* finish this buffer: */
472 (void)ftape_next_buffer(ft_queue_head);
473 ft_runner_status = aborting;
474 fdc_mode = fdc_idle;
475 } else if (buff->remaining > 0 && ftape_calc_next_cluster(buff) > 0) {
476 /* still sectors left in current segment, continue
477 * with this segment
478 */
479 if (fdc_setup_read_write(buff, mode) < 0) {
480 /* failed, abort operation
481 */
482 buff->bytes = buff->ptr - buff->address;
483 buff->status = error;
484 /* finish this buffer: */
485 (void)ftape_next_buffer(ft_queue_head);
486 ft_runner_status = aborting;
487 fdc_mode = fdc_idle;
488 }
489 } else {
490 /* current segment completed
491 */
492 unsigned int last_segment = buff->segment_id;
493 int eot = ((last_segment + 1) % ft_segments_per_track) == 0;
494 unsigned int next = buff->next_segment; /* 0 means stop ! */
495
496 buff->bytes = buff->ptr - buff->address;
497 buff->status = done;
498 buff = ftape_next_buffer(ft_queue_head);
499 if (eot) {
500 /* finished last segment on current track,
501 * can't continue
502 */
503 ft_runner_status = logical_eot;
504 fdc_mode = fdc_idle;
505 TRACE_EXIT;
506 }
507 if (next <= 0) {
508 /* don't continue with next segment
509 */
510 TRACE(ft_t_noise, "no %s allowed, stopping tape",
511 (write) ? "write next" : "read ahead");
512 pause_tape(0, mode);
513 ft_runner_status = idle; /* not quite true until
514 * next irq
515 */
516 TRACE_EXIT;
517 }
518 /* continue with next segment
519 */
520 if (buff->status != waiting) {
521 TRACE(ft_t_noise, "all input buffers %s, pausing tape",
522 (write) ? "empty" : "full");
523 pause_tape(0, mode);
524 ft_runner_status = idle; /* not quite true until
525 * next irq
526 */
527 TRACE_EXIT;
528 }
529 if (write && next != buff->segment_id) {
530 TRACE(ft_t_noise,
531 "segments out of order, aborting write");
532 ft_runner_status = do_abort;
533 fdc_mode = fdc_idle;
534 TRACE_EXIT;
535 }
536 ftape_setup_new_segment(buff, next, 0);
537 if (stop_read_ahead) {
538 buff->next_segment = 0;
539 stop_read_ahead = 0;
540 }
541 if (ftape_calc_next_cluster(buff) == 0 ||
542 fdc_setup_read_write(buff, mode) != 0) {
543 TRACE(ft_t_err, "couldn't start %s-ahead",
544 write ? "write" : "read");
545 ft_runner_status = do_abort;
546 fdc_mode = fdc_idle;
547 } else {
548 /* keep on going */
549 switch (ft_driver_state) {
550 case reading: buff->status = reading; break;
551 case verifying: buff->status = verifying; break;
552 case writing: buff->status = writing; break;
553 case deleting: buff->status = deleting; break;
554 default:
555 TRACE(ft_t_err,
556 "BUG: ft_driver_state %d should be one out of "
557 "{reading, writing, verifying, deleting}",
558 ft_driver_state);
559 buff->status = write ? writing : reading;
560 break;
561 }
562 }
563 }
564 TRACE_EXIT;
565}
566
567static void retry_sector(buffer_struct *buff,
568 int mode,
569 unsigned int skip)
570{
571 TRACE_FUN(ft_t_any);
572
573 TRACE(ft_t_noise, "%s error, will retry",
574 (mode == fdc_writing_data || mode == fdc_deleting) ? "write" : "read");
575 pause_tape(1, mode);
576 ft_runner_status = aborting;
577 buff->status = error;
578 buff->skip = skip;
579 TRACE_EXIT;
580}
581
582static unsigned int find_resume_point(buffer_struct *buff)
583{
584 int i = 0;
585 SectorMap mask;
586 SectorMap map;
587 TRACE_FUN(ft_t_any);
588
589 /* This function is to be called after all variables have been
590 * updated to point past the failing sector.
591 * If there are any soft errors before the failing sector,
592 * find the first soft error and return the sector offset.
593 * Otherwise find the last hard error.
594 * Note: there should always be at least one hard or soft error !
595 */
596 if (buff->sector_offset < 1 || buff->sector_offset > 32) {
597 TRACE(ft_t_bug, "BUG: sector_offset = %d",
598 buff->sector_offset);
599 TRACE_EXIT 0;
600 }
601 if (buff->sector_offset >= 32) { /* C-limitation on shift ! */
602 mask = 0xffffffff;
603 } else {
604 mask = (1 << buff->sector_offset) - 1;
605 }
606 map = buff->soft_error_map & mask;
607 if (map) {
608 while ((map & (1 << i)) == 0) {
609 ++i;
610 }
611 TRACE(ft_t_noise, "at sector %d", FT_SECTOR(i));
612 } else {
613 map = buff->hard_error_map & mask;
614 i = buff->sector_offset - 1;
615 if (map) {
616 while ((map & (1 << i)) == 0) {
617 --i;
618 }
619 TRACE(ft_t_noise, "after sector %d", FT_SECTOR(i));
620 ++i; /* first sector after last hard error */
621 } else {
622 TRACE(ft_t_bug, "BUG: no soft or hard errors");
623 }
624 }
625 TRACE_EXIT i;
626}
627
628/* check possible dma residue when formatting, update position record in
629 * buffer struct. This is, of course, modelled after determine_progress(), but
630 * we don't need to set up for retries because the format process cannot be
631 * interrupted (except at the end of the tape track).
632 */
633static int determine_fmt_progress(buffer_struct *buff, error_cause cause)
634{
635 unsigned int dma_residue;
636 TRACE_FUN(ft_t_any);
637
638 /* Using less preferred order of disable_dma and
639 * get_dma_residue because this seems to fail on at least one
640 * system if reversed!
641 */
642 dma_residue = get_dma_residue(fdc.dma);
643 disable_dma(fdc.dma);
644 if (cause != no_error || dma_residue != 0) {
645 TRACE(ft_t_info, "DMA residue = 0x%04x", dma_residue);
646 fdc_mode = fdc_idle;
647 switch(cause) {
648 case no_error:
649 ft_runner_status = aborting;
650 buff->status = idle;
651 break;
652 case overrun_error:
653 /* got an overrun error on the first byte, must be a
654 * hardware problem
655 */
656 TRACE(ft_t_bug,
657 "Unexpected error: failing DMA controller ?");
658 ft_runner_status = do_abort;
659 buff->status = error;
660 break;
661 default:
662 TRACE(ft_t_noise, "Unexpected error at segment %d",
663 buff->segment_id);
664 ft_runner_status = do_abort;
665 buff->status = error;
666 break;
667 }
668 TRACE_EXIT -EIO; /* can only retry entire track in format mode
669 */
670 }
671 /* Update var's influenced by the DMA operation.
672 */
673 buff->ptr += FT_SECTORS_PER_SEGMENT * 4;
674 buff->bytes -= FT_SECTORS_PER_SEGMENT * 4;
675 buff->remaining -= FT_SECTORS_PER_SEGMENT;
676 buff->segment_id ++; /* done with segment */
677 TRACE_EXIT 0;
678}
679
680/*
681 * Continue formatting, switch buffers if there is no data left in
682 * current buffer. This is, of course, modelled after
683 * continue_xfer(), but we don't need to set up for retries because
684 * the format process cannot be interrupted (except at the end of the
685 * tape track).
686 */
687static void continue_formatting(buffer_struct *buff)
688{
689 TRACE_FUN(ft_t_any);
690
691 if (buff->remaining <= 0) { /* no space left in dma buffer */
692 unsigned int next = buff->next_segment;
693
694 if (next == 0) { /* end of tape track */
695 buff->status = done;
696 ft_runner_status = logical_eot;
697 fdc_mode = fdc_idle;
698 TRACE(ft_t_noise, "Done formatting track %d",
699 ft_location.track);
700 TRACE_EXIT;
701 }
702 /*
703 * switch to next buffer!
704 */
705 buff->status = done;
706 buff = ftape_next_buffer(ft_queue_head);
707
708 if (buff->status != waiting || next != buff->segment_id) {
709 goto format_setup_error;
710 }
711 }
712 if (fdc_setup_formatting(buff) < 0) {
713 goto format_setup_error;
714 }
715 buff->status = formatting;
716 TRACE(ft_t_fdc_dma, "Formatting segment %d on track %d",
717 buff->segment_id, ft_location.track);
718 TRACE_EXIT;
719 format_setup_error:
720 ft_runner_status = do_abort;
721 fdc_mode = fdc_idle;
722 buff->status = error;
723 TRACE(ft_t_err, "Error setting up for segment %d on track %d",
724 buff->segment_id, ft_location.track);
725 TRACE_EXIT;
726
727}
728
729/* this handles writing, read id, reading and formatting
730 */
731static void handle_fdc_busy(buffer_struct *buff)
732{
733 static int no_data_error_count;
734 int retry = 0;
735 error_cause cause;
736 __u8 in[7];
737 int skip;
738 fdc_mode_enum fmode = fdc_mode;
739 TRACE_FUN(ft_t_any);
740
741 if (fdc_result(in, 7) < 0) { /* better get it fast ! */
742 TRACE(ft_t_err,
743 "Probably fatal error during FDC Result Phase\n"
744 KERN_INFO
745 "drive may hang until (power on) reset :-(");
746 /* what to do next ????
747 */
748 TRACE_EXIT;
749 }
750 cause = decode_irq_cause(fdc_mode, in);
751#ifdef TESTING
752 { int i;
753 for (i = 0; i < (int)ft_nr_buffers; ++i)
754 TRACE(ft_t_any, "buffer[%d] status: %d, segment_id: %d",
755 i, ft_buffer[i]->status, ft_buffer[i]->segment_id);
756 }
757#endif
758 if (fmode == fdc_reading_data && ft_driver_state == verifying) {
759 fmode = fdc_verifying;
760 }
761 switch (fmode) {
762 case fdc_verifying:
763 if (ft_runner_status == aborting ||
764 ft_runner_status == do_abort) {
765 TRACE(ft_t_noise,"aborting %s",fdc_mode_txt(fdc_mode));
766 break;
767 }
768 if (buff->retry > 0) {
769 TRACE(ft_t_flow, "this is retry nr %d", buff->retry);
770 }
771 switch (cause) {
772 case no_error:
773 no_data_error_count = 0;
774 determine_verify_progress(buff, cause, in[5]);
775 if (in[2] & 0x40) {
776 /* This should not happen when verifying
777 */
778 TRACE(ft_t_warn,
779 "deleted data in segment %d/%d",
780 buff->segment_id,
781 FT_SECTOR(buff->sector_offset - 1));
782 buff->remaining = 0; /* abort transfer */
783 buff->hard_error_map = EMPTY_SEGMENT;
784 skip = 1;
785 } else {
786 skip = 0;
787 }
788 continue_xfer(buff, fdc_mode, skip);
789 break;
790 case no_data_error:
791 no_data_error_count ++;
792 case overrun_error:
793 retry ++;
794 case id_am_error:
795 case id_crc_error:
796 case data_am_error:
797 case data_crc_error:
798 determine_verify_progress(buff, cause, in[5]);
799 if (cause == no_data_error) {
800 if (no_data_error_count >= 2) {
801 TRACE(ft_t_warn,
802 "retrying because of successive "
803 "no data errors");
804 no_data_error_count = 0;
805 } else {
806 retry --;
807 }
808 } else {
809 no_data_error_count = 0;
810 }
811 if (retry) {
812 skip = find_resume_point(buff);
813 } else {
814 skip = buff->sector_offset;
815 }
816 if (retry && skip < 32) {
817 retry_sector(buff, fdc_mode, skip);
818 } else {
819 continue_xfer(buff, fdc_mode, skip);
820 }
821 update_history(cause);
822 break;
823 default:
824 /* Don't know why this could happen
825 * but find out.
826 */
827 determine_verify_progress(buff, cause, in[5]);
828 retry_sector(buff, fdc_mode, 0);
829 TRACE(ft_t_err, "Error: unexpected error");
830 break;
831 }
832 break;
833 case fdc_reading_data:
834#ifdef TESTING
835 /* I'm sorry, but: NOBODY ever used this trace
836 * messages for ages. I guess that Bas was the last person
837 * that ever really used this (thank you, between the lines)
838 */
839 if (cause == no_error) {
840 TRACE(ft_t_flow,"reading segment %d",buff->segment_id);
841 } else {
842 TRACE(ft_t_noise, "error reading segment %d",
843 buff->segment_id);
844 TRACE(ft_t_noise, "\n"
845 KERN_INFO
846 "IRQ:C: 0x%02x, H: 0x%02x, R: 0x%02x, N: 0x%02x\n"
847 KERN_INFO
848 "BUF:C: 0x%02x, H: 0x%02x, R: 0x%02x",
849 in[3], in[4], in[5], in[6],
850 buff->cyl, buff->head, buff->sect);
851 }
852#endif
853 if (ft_runner_status == aborting ||
854 ft_runner_status == do_abort) {
855 TRACE(ft_t_noise,"aborting %s",fdc_mode_txt(fdc_mode));
856 break;
857 }
858 if (buff->bad_sector_map == FAKE_SEGMENT) {
859 /* This condition occurs when reading a `fake'
860 * sector that's not accessible. Doesn't
861 * really matter as we would have ignored it
862 * anyway !
863 *
864 * Chance is that we're past the next segment
865 * now, so the next operation may fail and
866 * result in a retry.
867 */
868 buff->remaining = 0; /* skip failing sector */
869 /* buff->ptr = buff->address; */
870 /* fake success: */
871 continue_xfer(buff, fdc_mode, 1);
872 /* trace calls are expensive: place them AFTER
873 * the real stuff has been done.
874 *
875 */
876 TRACE(ft_t_noise, "skipping empty segment %d (read), size? %d",
877 buff->segment_id, buff->ptr - buff->address);
878 TRACE_EXIT;
879 }
880 if (buff->retry > 0) {
881 TRACE(ft_t_flow, "this is retry nr %d", buff->retry);
882 }
883 switch (cause) {
884 case no_error:
885 determine_progress(buff, cause, in[5]);
886 if (in[2] & 0x40) {
887 /* Handle deleted data in header segments.
888 * Skip segment and force read-ahead.
889 */
890 TRACE(ft_t_warn,
891 "deleted data in segment %d/%d",
892 buff->segment_id,
893 FT_SECTOR(buff->sector_offset - 1));
894 buff->deleted = 1;
895 buff->remaining = 0;/*abort transfer */
896 buff->soft_error_map |=
897 (-1L << buff->sector_offset);
898 if (buff->segment_id == 0) {
899 /* stop on next segment */
900 stop_read_ahead = 1;
901 }
902 /* force read-ahead: */
903 buff->next_segment =
904 buff->segment_id + 1;
905 skip = (FT_SECTORS_PER_SEGMENT -
906 buff->sector_offset);
907 } else {
908 skip = 0;
909 }
910 continue_xfer(buff, fdc_mode, skip);
911 break;
912 case no_data_error:
913 /* Tape started too far ahead of or behind the
914 * right sector. This may also happen in the
915 * middle of a segment !
916 *
917 * Handle no-data as soft error. If next
918 * sector fails too, a retry (with needed
919 * reposition) will follow.
920 */
921 retry ++;
922 case id_am_error:
923 case id_crc_error:
924 case data_am_error:
925 case data_crc_error:
926 case overrun_error:
927 retry += (buff->soft_error_map != 0 ||
928 buff->hard_error_map != 0);
929 determine_progress(buff, cause, in[5]);
930#if 1 || defined(TESTING)
931 if (cause == overrun_error) retry ++;
932#endif
933 if (retry) {
934 skip = find_resume_point(buff);
935 } else {
936 skip = buff->sector_offset;
937 }
938 /* Try to resume with next sector on single
939 * errors (let ecc correct it), but retry on
940 * no_data (we'll be past the target when we
941 * get here so we cannot retry) or on
942 * multiple errors (reduce chance on ecc
943 * failure).
944 */
945 /* cH: 23/02/97: if the last sector in the
946 * segment was a hard error, then there is
947 * no sense in a retry. This occasion seldom
948 * occurs but ... @:³²¸`@%&§$
949 */
950 if (retry && skip < 32) {
951 retry_sector(buff, fdc_mode, skip);
952 } else {
953 continue_xfer(buff, fdc_mode, skip);
954 }
955 update_history(cause);
956 break;
957 default:
958 /* Don't know why this could happen
959 * but find out.
960 */
961 determine_progress(buff, cause, in[5]);
962 retry_sector(buff, fdc_mode, 0);
963 TRACE(ft_t_err, "Error: unexpected error");
964 break;
965 }
966 break;
967 case fdc_reading_id:
968 if (cause == no_error) {
969 fdc_cyl = in[3];
970 fdc_head = in[4];
971 fdc_sect = in[5];
972 TRACE(ft_t_fdc_dma,
973 "id read: C: 0x%02x, H: 0x%02x, R: 0x%02x",
974 fdc_cyl, fdc_head, fdc_sect);
975 } else { /* no valid information, use invalid sector */
976 fdc_cyl = fdc_head = fdc_sect = 0;
977 TRACE(ft_t_flow, "Didn't find valid sector Id");
978 }
979 fdc_mode = fdc_idle;
980 break;
981 case fdc_deleting:
982 case fdc_writing_data:
983#ifdef TESTING
984 if (cause == no_error) {
985 TRACE(ft_t_flow, "writing segment %d", buff->segment_id);
986 } else {
987 TRACE(ft_t_noise, "error writing segment %d",
988 buff->segment_id);
989 }
990#endif
991 if (ft_runner_status == aborting ||
992 ft_runner_status == do_abort) {
993 TRACE(ft_t_flow, "aborting %s",fdc_mode_txt(fdc_mode));
994 break;
995 }
996 if (buff->retry > 0) {
997 TRACE(ft_t_flow, "this is retry nr %d", buff->retry);
998 }
999 if (buff->bad_sector_map == FAKE_SEGMENT) {
1000 /* This condition occurs when trying to write to a
1001 * `fake' sector that's not accessible. Doesn't really
1002 * matter as it isn't used anyway ! Might be located
1003 * at wrong segment, then we'll fail on the next
1004 * segment.
1005 */
1006 TRACE(ft_t_noise, "skipping empty segment (write)");
1007 buff->remaining = 0; /* skip failing sector */
1008 /* fake success: */
1009 continue_xfer(buff, fdc_mode, 1);
1010 break;
1011 }
1012 switch (cause) {
1013 case no_error:
1014 determine_progress(buff, cause, in[5]);
1015 continue_xfer(buff, fdc_mode, 0);
1016 break;
1017 case no_data_error:
1018 case id_am_error:
1019 case id_crc_error:
1020 case data_am_error:
1021 case overrun_error:
1022 update_history(cause);
1023 determine_progress(buff, cause, in[5]);
1024 skip = find_resume_point(buff);
1025 retry_sector(buff, fdc_mode, skip);
1026 break;
1027 default:
1028 if (in[1] & 0x02) {
1029 TRACE(ft_t_err, "media not writable");
1030 } else {
1031 TRACE(ft_t_bug, "unforeseen write error");
1032 }
1033 fdc_mode = fdc_idle;
1034 break;
1035 }
1036 break; /* fdc_deleting || fdc_writing_data */
1037 case fdc_formatting:
1038 /* The interrupt comes after formatting a segment. We then
1039 * have to set up QUICKLY for the next segment. But
1040 * afterwards, there is plenty of time.
1041 */
1042 switch (cause) {
1043 case no_error:
1044 /* would like to keep most of the formatting stuff
1045 * outside the isr code, but timing is too critical
1046 */
1047 if (determine_fmt_progress(buff, cause) >= 0) {
1048 continue_formatting(buff);
1049 }
1050 break;
1051 case no_data_error:
1052 case id_am_error:
1053 case id_crc_error:
1054 case data_am_error:
1055 case overrun_error:
1056 default:
1057 determine_fmt_progress(buff, cause);
1058 update_history(cause);
1059 if (in[1] & 0x02) {
1060 TRACE(ft_t_err, "media not writable");
1061 } else {
1062 TRACE(ft_t_bug, "unforeseen write error");
1063 }
1064 break;
1065 } /* cause */
1066 break;
1067 default:
1068 TRACE(ft_t_warn, "Warning: unexpected irq during: %s",
1069 fdc_mode_txt(fdc_mode));
1070 fdc_mode = fdc_idle;
1071 break;
1072 }
1073 TRACE_EXIT;
1074}
1075
1076/* FDC interrupt service routine.
1077 */
1078void fdc_isr(void)
1079{
1080 static int isr_active;
1081#ifdef TESTING
1082 unsigned int t0 = ftape_timestamp();
1083#endif
1084 TRACE_FUN(ft_t_any);
1085
1086 if (isr_active++) {
1087 --isr_active;
1088 TRACE(ft_t_bug, "BUG: nested interrupt, not good !");
1089 *fdc.hook = fdc_isr; /* hook our handler into the fdc
1090 * code again
1091 */
1092 TRACE_EXIT;
1093 }
1094 sti();
1095 if (inb_p(fdc.msr) & FDC_BUSY) { /* Entering Result Phase */
1096 ft_hide_interrupt = 0;
1097 handle_fdc_busy(ftape_get_buffer(ft_queue_head));
1098 if (ft_runner_status == do_abort) {
1099 /* cease operation, remember tape position
1100 */
1101 TRACE(ft_t_flow, "runner aborting");
1102 ft_runner_status = aborting;
1103 ++ft_expected_stray_interrupts;
1104 }
1105 } else { /* !FDC_BUSY */
1106 /* clear interrupt, cause should be gotten by issuing
1107 * a Sense Interrupt Status command.
1108 */
1109 if (fdc_mode == fdc_recalibrating || fdc_mode == fdc_seeking) {
1110 if (ft_hide_interrupt) {
1111 int st0;
1112 int pcn;
1113
1114 if (fdc_sense_interrupt_status(&st0, &pcn) < 0)
1115 TRACE(ft_t_err,
1116 "sense interrupt status failed");
1117 ftape_current_cylinder = pcn;
1118 TRACE(ft_t_flow, "handled hidden interrupt");
1119 }
1120 ft_seek_completed = 1;
1121 fdc_mode = fdc_idle;
1122 } else if (!waitqueue_active(&ftape_wait_intr)) {
1123 if (ft_expected_stray_interrupts == 0) {
1124 TRACE(ft_t_warn, "unexpected stray interrupt");
1125 } else {
1126 TRACE(ft_t_flow, "expected stray interrupt");
1127 --ft_expected_stray_interrupts;
1128 }
1129 } else {
1130 if (fdc_mode == fdc_reading_data ||
1131 fdc_mode == fdc_verifying ||
1132 fdc_mode == fdc_writing_data ||
1133 fdc_mode == fdc_deleting ||
1134 fdc_mode == fdc_formatting ||
1135 fdc_mode == fdc_reading_id) {
1136 if (inb_p(fdc.msr) & FDC_BUSY) {
1137 TRACE(ft_t_bug,
1138 "***** FDC failure, busy too late");
1139 } else {
1140 TRACE(ft_t_bug,
1141 "***** FDC failure, no busy");
1142 }
1143 } else {
1144 TRACE(ft_t_fdc_dma, "awaited stray interrupt");
1145 }
1146 }
1147 ft_hide_interrupt = 0;
1148 }
1149 /* Handle sleep code.
1150 */
1151 if (!ft_hide_interrupt) {
1152 ft_interrupt_seen ++;
1153 if (waitqueue_active(&ftape_wait_intr)) {
1154 wake_up_interruptible(&ftape_wait_intr);
1155 }
1156 } else {
1157 TRACE(ft_t_flow, "hiding interrupt while %s",
1158 waitqueue_active(&ftape_wait_intr) ? "waiting":"active");
1159 }
1160#ifdef TESTING
1161 t0 = ftape_timediff(t0, ftape_timestamp());
1162 if (t0 >= 1000) {
1163 /* only tell us about long calls */
1164 TRACE(ft_t_noise, "isr() duration: %5d usec", t0);
1165 }
1166#endif
1167 *fdc.hook = fdc_isr; /* hook our handler into the fdc code again */
1168 --isr_active;
1169 TRACE_EXIT;
1170}
diff --git a/drivers/char/ftape/lowlevel/fdc-isr.h b/drivers/char/ftape/lowlevel/fdc-isr.h
deleted file mode 100644
index 065aa978942d..000000000000
--- a/drivers/char/ftape/lowlevel/fdc-isr.h
+++ /dev/null
@@ -1,55 +0,0 @@
1#ifndef _FDC_ISR_H
2#define _FDC_ISR_H
3
4/*
5 * Copyright (C) 1993-1996 Bas Laarhoven,
6 * (C) 1996-1997 Claus-Justus Heine.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; see the file COPYING. If not, write to
20 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21
22 *
23 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/fdc-isr.h,v $
24 * $Revision: 1.2 $
25 * $Date: 1997/10/05 19:18:07 $
26 *
27 * This file declares the global variables necessary to
28 * synchronize the interrupt service routine (isr) with the
29 * remainder of the QIC-40/80/3010/3020 floppy-tape driver
30 * "ftape" for Linux.
31 */
32
33/*
34 * fdc-isr.c defined public variables
35 */
36extern volatile int ft_expected_stray_interrupts; /* masks stray interrupts */
37extern volatile int ft_seek_completed; /* flag set by isr */
38extern volatile int ft_interrupt_seen; /* flag set by isr */
39extern volatile int ft_hide_interrupt; /* flag set by isr */
40
41/*
42 * fdc-io.c defined public functions
43 */
44extern void fdc_isr(void);
45
46/*
47 * A kernel hook that steals one interrupt from the floppy
48 * driver (Should be fixed when the new fdc driver gets ready)
49 * See the linux kernel source files:
50 * drivers/block/floppy.c & drivers/block/blk.h
51 * for the details.
52 */
53extern void (*do_floppy) (void);
54
55#endif
diff --git a/drivers/char/ftape/lowlevel/ftape-bsm.c b/drivers/char/ftape/lowlevel/ftape-bsm.c
deleted file mode 100644
index d1a301cc344f..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-bsm.c
+++ /dev/null
@@ -1,491 +0,0 @@
1/*
2 * Copyright (C) 1994-1996 Bas Laarhoven,
3 * (C) 1996-1997 Claus Heine.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
8 any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; see the file COPYING. If not, write to
17 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 *
20 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-bsm.c,v $
21 * $Revision: 1.3 $
22 * $Date: 1997/10/05 19:15:15 $
23 *
24 * This file contains the bad-sector map handling code for
25 * the QIC-117 floppy tape driver for Linux.
26 * QIC-40, QIC-80, QIC-3010 and QIC-3020 maps are implemented.
27 */
28
29#include <linux/string.h>
30
31#include <linux/ftape.h>
32#include "../lowlevel/ftape-tracing.h"
33#include "../lowlevel/ftape-bsm.h"
34#include "../lowlevel/ftape-ctl.h"
35#include "../lowlevel/ftape-rw.h"
36
37/* Global vars.
38 */
39
40/* Local vars.
41 */
42static __u8 *bad_sector_map;
43static SectorCount *bsm_hash_ptr;
44
45typedef enum {
46 forward, backward
47} mode_type;
48
49#if 0
50static void ftape_put_bad_sector_entry(int segment_id, SectorMap new_map);
51#endif
52
53#if 0
54/* fix_tape converts a normal QIC-80 tape into a 'wide' tape.
55 * For testing purposes only !
56 */
57void fix_tape(__u8 * buffer, ft_format_type new_code)
58{
59 static __u8 list[BAD_SECTOR_MAP_SIZE];
60 SectorMap *src_ptr = (SectorMap *) list;
61 __u8 *dst_ptr = bad_sector_map;
62 SectorMap map;
63 unsigned int sector = 1;
64 int i;
65
66 if (format_code != fmt_var && format_code != fmt_big) {
67 memcpy(list, bad_sector_map, sizeof(list));
68 memset(bad_sector_map, 0, sizeof(bad_sector_map));
69 while ((__u8 *) src_ptr - list < sizeof(list)) {
70 map = *src_ptr++;
71 if (map == EMPTY_SEGMENT) {
72 *(SectorMap *) dst_ptr = 0x800000 + sector;
73 dst_ptr += 3;
74 sector += SECTORS_PER_SEGMENT;
75 } else {
76 for (i = 0; i < SECTORS_PER_SEGMENT; ++i) {
77 if (map & 1) {
78 *(SewctorMap *) dst_ptr = sector;
79 dst_ptr += 3;
80 }
81 map >>= 1;
82 ++sector;
83 }
84 }
85 }
86 }
87 bad_sector_map_changed = 1;
88 *(buffer + 4) = new_code; /* put new format code */
89 if (format_code != fmt_var && new_code == fmt_big) {
90 PUT4(buffer, FT_6_HSEG_1, (__u32)GET2(buffer, 6));
91 PUT4(buffer, FT_6_HSEG_2, (__u32)GET2(buffer, 8));
92 PUT4(buffer, FT_6_FRST_SEG, (__u32)GET2(buffer, 10));
93 PUT4(buffer, FT_6_LAST_SEG, (__u32)GET2(buffer, 12));
94 memset(buffer+6, '\0', 8);
95 }
96 format_code = new_code;
97}
98
99#endif
100
101/* given buffer that contains a header segment, find the end of
102 * of the bsm list
103 */
104__u8 * ftape_find_end_of_bsm_list(__u8 * address)
105{
106 __u8 *ptr = address + FT_HEADER_END; /* start of bsm list */
107 __u8 *limit = address + FT_SEGMENT_SIZE;
108 while (ptr + 2 < limit) {
109 if (ptr[0] || ptr[1] || ptr[2]) {
110 ptr += 3;
111 } else {
112 return ptr;
113 }
114 }
115 return NULL;
116}
117
118static inline void put_sector(SectorCount *ptr, unsigned int sector)
119{
120 ptr->bytes[0] = sector & 0xff;
121 sector >>= 8;
122 ptr->bytes[1] = sector & 0xff;
123 sector >>= 8;
124 ptr->bytes[2] = sector & 0xff;
125}
126
127static inline unsigned int get_sector(SectorCount *ptr)
128{
129#if 1
130 unsigned int sector;
131
132 sector = ptr->bytes[0];
133 sector += ptr->bytes[1] << 8;
134 sector += ptr->bytes[2] << 16;
135
136 return sector;
137#else
138 /* GET4 gets the next four bytes in Intel little endian order
139 * and converts them to host byte order and handles unaligned
140 * access.
141 */
142 return (GET4(ptr, 0) & 0x00ffffff); /* back to host byte order */
143#endif
144}
145
146static void bsm_debug_fake(void)
147{
148 /* for testing of bad sector handling at end of tape
149 */
150#if 0
151 ftape_put_bad_sector_entry(segments_per_track * tracks_per_tape - 3,
152 0x000003e0;
153 ftape_put_bad_sector_entry(segments_per_track * tracks_per_tape - 2,
154 0xff3fffff;
155 ftape_put_bad_sector_entry(segments_per_track * tracks_per_tape - 1,
156 0xffffe000;
157#endif
158 /* Enable to test bad sector handling
159 */
160#if 0
161 ftape_put_bad_sector_entry(30, 0xfffffffe)
162 ftape_put_bad_sector_entry(32, 0x7fffffff);
163 ftape_put_bad_sector_entry(34, 0xfffeffff);
164 ftape_put_bad_sector_entry(36, 0x55555555);
165 ftape_put_bad_sector_entry(38, 0xffffffff);
166 ftape_put_bad_sector_entry(50, 0xffff0000);
167 ftape_put_bad_sector_entry(51, 0xffffffff);
168 ftape_put_bad_sector_entry(52, 0xffffffff);
169 ftape_put_bad_sector_entry(53, 0x0000ffff);
170#endif
171 /* Enable when testing multiple volume tar dumps.
172 */
173#if 0
174 {
175 int i;
176
177 for (i = ft_first_data_segment;
178 i <= ft_last_data_segment - 7; ++i) {
179 ftape_put_bad_sector_entry(i, EMPTY_SEGMENT);
180 }
181 }
182#endif
183 /* Enable when testing bit positions in *_error_map
184 */
185#if 0
186 {
187 int i;
188
189 for (i = first_data_segment; i <= last_data_segment; ++i) {
190 ftape_put_bad_sector_entry(i,
191 ftape_get_bad_sector_entry(i)
192 | 0x00ff00ff);
193 }
194 }
195#endif
196}
197
198static void print_bad_sector_map(void)
199{
200 unsigned int good_sectors;
201 unsigned int total_bad = 0;
202 int i;
203 TRACE_FUN(ft_t_flow);
204
205 if (ft_format_code == fmt_big ||
206 ft_format_code == fmt_var ||
207 ft_format_code == fmt_1100ft) {
208 SectorCount *ptr = (SectorCount *)bad_sector_map;
209 unsigned int sector;
210 __u16 *ptr16;
211
212 while((sector = get_sector(ptr++)) != 0) {
213 if ((ft_format_code == fmt_big ||
214 ft_format_code == fmt_var) &&
215 sector & 0x800000) {
216 total_bad += FT_SECTORS_PER_SEGMENT - 3;
217 TRACE(ft_t_noise, "bad segment at sector: %6d",
218 sector & 0x7fffff);
219 } else {
220 ++total_bad;
221 TRACE(ft_t_noise, "bad sector: %6d", sector);
222 }
223 }
224 /* Display old ftape's end-of-file marks
225 */
226 ptr16 = (__u16*)ptr;
227 while ((sector = get_unaligned(ptr16++)) != 0) {
228 TRACE(ft_t_noise, "Old ftape eof mark: %4d/%2d",
229 sector, get_unaligned(ptr16++));
230 }
231 } else { /* fixed size format */
232 for (i = ft_first_data_segment;
233 i < (int)(ft_segments_per_track * ft_tracks_per_tape); ++i) {
234 SectorMap map = ((SectorMap *) bad_sector_map)[i];
235
236 if (map) {
237 TRACE(ft_t_noise,
238 "bsm for segment %4d: 0x%08x", i, (unsigned int)map);
239 total_bad += ((map == EMPTY_SEGMENT)
240 ? FT_SECTORS_PER_SEGMENT - 3
241 : count_ones(map));
242 }
243 }
244 }
245 good_sectors =
246 ((ft_segments_per_track * ft_tracks_per_tape - ft_first_data_segment)
247 * (FT_SECTORS_PER_SEGMENT - 3)) - total_bad;
248 TRACE(ft_t_info, "%d Kb usable on this tape", good_sectors);
249 if (total_bad == 0) {
250 TRACE(ft_t_info,
251 "WARNING: this tape has no bad blocks registered !");
252 } else {
253 TRACE(ft_t_info, "%d bad sectors", total_bad);
254 }
255 TRACE_EXIT;
256}
257
258
259void ftape_extract_bad_sector_map(__u8 * buffer)
260{
261 TRACE_FUN(ft_t_any);
262
263 /* Fill the bad sector map with the contents of buffer.
264 */
265 if (ft_format_code == fmt_var || ft_format_code == fmt_big) {
266 /* QIC-3010/3020 and wide QIC-80 tapes no longer have a failed
267 * sector log but use this area to extend the bad sector map.
268 */
269 bad_sector_map = &buffer[FT_HEADER_END];
270 } else {
271 /* non-wide QIC-80 tapes have a failed sector log area that
272 * mustn't be included in the bad sector map.
273 */
274 bad_sector_map = &buffer[FT_FSL + FT_FSL_SIZE];
275 }
276 if (ft_format_code == fmt_1100ft ||
277 ft_format_code == fmt_var ||
278 ft_format_code == fmt_big) {
279 bsm_hash_ptr = (SectorCount *)bad_sector_map;
280 } else {
281 bsm_hash_ptr = NULL;
282 }
283 bsm_debug_fake();
284 if (TRACE_LEVEL >= ft_t_info) {
285 print_bad_sector_map();
286 }
287 TRACE_EXIT;
288}
289
290static inline SectorMap cvt2map(unsigned int sector)
291{
292 return 1 << (((sector & 0x7fffff) - 1) % FT_SECTORS_PER_SEGMENT);
293}
294
295static inline int cvt2segment(unsigned int sector)
296{
297 return ((sector & 0x7fffff) - 1) / FT_SECTORS_PER_SEGMENT;
298}
299
300static int forward_seek_entry(int segment_id,
301 SectorCount **ptr,
302 SectorMap *map)
303{
304 unsigned int sector;
305 int segment;
306
307 do {
308 sector = get_sector((*ptr)++);
309 segment = cvt2segment(sector);
310 } while (sector != 0 && segment < segment_id);
311 (*ptr) --; /* point to first sector >= segment_id */
312 /* Get all sectors in segment_id
313 */
314 if (sector == 0 || segment != segment_id) {
315 *map = 0;
316 return 0;
317 } else if ((sector & 0x800000) &&
318 (ft_format_code == fmt_var || ft_format_code == fmt_big)) {
319 *map = EMPTY_SEGMENT;
320 return FT_SECTORS_PER_SEGMENT;
321 } else {
322 int count = 1;
323 SectorCount *tmp_ptr = (*ptr) + 1;
324
325 *map = cvt2map(sector);
326 while ((sector = get_sector(tmp_ptr++)) != 0 &&
327 (segment = cvt2segment(sector)) == segment_id) {
328 *map |= cvt2map(sector);
329 ++count;
330 }
331 return count;
332 }
333}
334
335static int backwards_seek_entry(int segment_id,
336 SectorCount **ptr,
337 SectorMap *map)
338{
339 unsigned int sector;
340 int segment; /* max unsigned int */
341
342 if (*ptr <= (SectorCount *)bad_sector_map) {
343 *map = 0;
344 return 0;
345 }
346 do {
347 sector = get_sector(--(*ptr));
348 segment = cvt2segment(sector);
349 } while (*ptr > (SectorCount *)bad_sector_map && segment > segment_id);
350 if (segment > segment_id) { /* at start of list, no entry found */
351 *map = 0;
352 return 0;
353 } else if (segment < segment_id) {
354 /* before smaller entry, adjust for overshoot */
355 (*ptr) ++;
356 *map = 0;
357 return 0;
358 } else if ((sector & 0x800000) &&
359 (ft_format_code == fmt_big || ft_format_code == fmt_var)) {
360 *map = EMPTY_SEGMENT;
361 return FT_SECTORS_PER_SEGMENT;
362 } else { /* get all sectors in segment_id */
363 int count = 1;
364
365 *map = cvt2map(sector);
366 while(*ptr > (SectorCount *)bad_sector_map) {
367 sector = get_sector(--(*ptr));
368 segment = cvt2segment(sector);
369 if (segment != segment_id) {
370 break;
371 }
372 *map |= cvt2map(sector);
373 ++count;
374 }
375 if (segment < segment_id) {
376 (*ptr) ++;
377 }
378 return count;
379 }
380}
381
382#if 0
383static void ftape_put_bad_sector_entry(int segment_id, SectorMap new_map)
384{
385 SectorCount *ptr = (SectorCount *)bad_sector_map;
386 int count;
387 int new_count;
388 SectorMap map;
389 TRACE_FUN(ft_t_any);
390
391 if (ft_format_code == fmt_1100ft ||
392 ft_format_code == fmt_var ||
393 ft_format_code == fmt_big) {
394 count = forward_seek_entry(segment_id, &ptr, &map);
395 new_count = count_ones(new_map);
396 /* If format code == 4 put empty segment instead of 32
397 * bad sectors.
398 */
399 if (ft_format_code == fmt_var || ft_format_code == fmt_big) {
400 if (new_count == FT_SECTORS_PER_SEGMENT) {
401 new_count = 1;
402 }
403 if (count == FT_SECTORS_PER_SEGMENT) {
404 count = 1;
405 }
406 }
407 if (count != new_count) {
408 /* insert (or delete if < 0) new_count - count
409 * entries. Move trailing part of list
410 * including terminating 0.
411 */
412 SectorCount *hi_ptr = ptr;
413
414 do {
415 } while (get_sector(hi_ptr++) != 0);
416 /* Note: ptr is of type byte *, and each bad sector
417 * consumes 3 bytes.
418 */
419 memmove(ptr + new_count, ptr + count,
420 (size_t)(hi_ptr - (ptr + count))*sizeof(SectorCount));
421 }
422 TRACE(ft_t_noise, "putting map 0x%08x at %p, segment %d",
423 (unsigned int)new_map, ptr, segment_id);
424 if (new_count == 1 && new_map == EMPTY_SEGMENT) {
425 put_sector(ptr++, (0x800001 +
426 segment_id *
427 FT_SECTORS_PER_SEGMENT));
428 } else {
429 int i = 0;
430
431 while (new_map) {
432 if (new_map & 1) {
433 put_sector(ptr++,
434 1 + segment_id *
435 FT_SECTORS_PER_SEGMENT + i);
436 }
437 ++i;
438 new_map >>= 1;
439 }
440 }
441 } else {
442 ((SectorMap *) bad_sector_map)[segment_id] = new_map;
443 }
444 TRACE_EXIT;
445}
446#endif /* 0 */
447
448SectorMap ftape_get_bad_sector_entry(int segment_id)
449{
450 if (ft_used_header_segment == -1) {
451 /* When reading header segment we'll need a blank map.
452 */
453 return 0;
454 } else if (bsm_hash_ptr != NULL) {
455 /* Invariants:
456 * map - mask value returned on last call.
457 * bsm_hash_ptr - points to first sector greater or equal to
458 * first sector in last_referenced segment.
459 * last_referenced - segment id used in the last call,
460 * sector and map belong to this id.
461 * This code is designed for sequential access and retries.
462 * For true random access it may have to be redesigned.
463 */
464 static int last_reference = -1;
465 static SectorMap map;
466
467 if (segment_id > last_reference) {
468 /* Skip all sectors before segment_id
469 */
470 forward_seek_entry(segment_id, &bsm_hash_ptr, &map);
471 } else if (segment_id < last_reference) {
472 /* Skip backwards until begin of buffer or
473 * first sector in segment_id
474 */
475 backwards_seek_entry(segment_id, &bsm_hash_ptr, &map);
476 } /* segment_id == last_reference : keep map */
477 last_reference = segment_id;
478 return map;
479 } else {
480 return ((SectorMap *) bad_sector_map)[segment_id];
481 }
482}
483
484/* This is simply here to prevent us from overwriting other kernel
485 * data. Writes will result in NULL Pointer dereference.
486 */
487void ftape_init_bsm(void)
488{
489 bad_sector_map = NULL;
490 bsm_hash_ptr = NULL;
491}
diff --git a/drivers/char/ftape/lowlevel/ftape-bsm.h b/drivers/char/ftape/lowlevel/ftape-bsm.h
deleted file mode 100644
index ed45465af4d4..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-bsm.h
+++ /dev/null
@@ -1,66 +0,0 @@
1#ifndef _FTAPE_BSM_H
2#define _FTAPE_BSM_H
3
4/*
5 * Copyright (C) 1994-1996 Bas Laarhoven,
6 * (C) 1996-1997 Claus-Justus Heine.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; see the file COPYING. If not, write to
20 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21
22 *
23 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-bsm.h,v $
24 * $Revision: 1.2 $
25 * $Date: 1997/10/05 19:18:07 $
26 *
27 * This file contains definitions for the bad sector map handling
28 * routines for the QIC-117 floppy-tape driver for Linux.
29 */
30
31#include <linux/ftape.h>
32#include <linux/ftape-header-segment.h>
33
34#define EMPTY_SEGMENT (0xffffffff)
35#define FAKE_SEGMENT (0xfffffffe)
36
37/* maximum (format code 4) bad sector map size (bytes).
38 */
39#define BAD_SECTOR_MAP_SIZE (29 * SECTOR_SIZE - 256)
40
41/* format code 4 bad sector entry, ftape uses this
42 * internally for all format codes
43 */
44typedef __u32 SectorMap;
45/* variable and 1100 ft bad sector map entry. These three bytes represent
46 * a single sector address measured from BOT.
47 */
48typedef struct NewSectorMap {
49 __u8 bytes[3];
50} SectorCount;
51
52
53/*
54 * ftape-bsm.c defined global vars.
55 */
56
57/*
58 * ftape-bsm.c defined global functions.
59 */
60extern void update_bad_sector_map(__u8 * buffer);
61extern void ftape_extract_bad_sector_map(__u8 * buffer);
62extern SectorMap ftape_get_bad_sector_entry(int segment_id);
63extern __u8 *ftape_find_end_of_bsm_list(__u8 * address);
64extern void ftape_init_bsm(void);
65
66#endif
diff --git a/drivers/char/ftape/lowlevel/ftape-buffer.c b/drivers/char/ftape/lowlevel/ftape-buffer.c
deleted file mode 100644
index c706ff162771..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-buffer.c
+++ /dev/null
@@ -1,130 +0,0 @@
1/*
2 * Copyright (C) 1997 Claus-Justus Heine
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 *
19 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-buffer.c,v $
20 * $Revision: 1.3 $
21 * $Date: 1997/10/16 23:33:11 $
22 *
23 * This file contains the allocator/dealloctor for ftape's dynamic dma
24 * buffer.
25 */
26
27#include <linux/slab.h>
28#include <linux/mm.h>
29#include <linux/mman.h>
30#include <asm/dma.h>
31
32#include <linux/ftape.h>
33#include "../lowlevel/ftape-rw.h"
34#include "../lowlevel/ftape-read.h"
35#include "../lowlevel/ftape-tracing.h"
36#include "../lowlevel/ftape-buffer.h"
37
38/* DMA'able memory allocation stuff.
39 */
40
41static inline void *dmaalloc(size_t size)
42{
43 unsigned long addr;
44
45 if (size == 0) {
46 return NULL;
47 }
48 addr = __get_dma_pages(GFP_KERNEL, get_order(size));
49 if (addr) {
50 struct page *page;
51
52 for (page = virt_to_page(addr); page < virt_to_page(addr+size); page++)
53 SetPageReserved(page);
54 }
55 return (void *)addr;
56}
57
58static inline void dmafree(void *addr, size_t size)
59{
60 if (size > 0) {
61 struct page *page;
62
63 for (page = virt_to_page((unsigned long)addr);
64 page < virt_to_page((unsigned long)addr+size); page++)
65 ClearPageReserved(page);
66 free_pages((unsigned long) addr, get_order(size));
67 }
68}
69
70static int add_one_buffer(void)
71{
72 TRACE_FUN(ft_t_flow);
73
74 if (ft_nr_buffers >= FT_MAX_NR_BUFFERS) {
75 TRACE_EXIT -ENOMEM;
76 }
77 ft_buffer[ft_nr_buffers] = kmalloc(sizeof(buffer_struct), GFP_KERNEL);
78 if (ft_buffer[ft_nr_buffers] == NULL) {
79 TRACE_EXIT -ENOMEM;
80 }
81 memset(ft_buffer[ft_nr_buffers], 0, sizeof(buffer_struct));
82 ft_buffer[ft_nr_buffers]->address = dmaalloc(FT_BUFF_SIZE);
83 if (ft_buffer[ft_nr_buffers]->address == NULL) {
84 kfree(ft_buffer[ft_nr_buffers]);
85 ft_buffer[ft_nr_buffers] = NULL;
86 TRACE_EXIT -ENOMEM;
87 }
88 ft_nr_buffers ++;
89 TRACE(ft_t_info, "buffer nr #%d @ %p, dma area @ %p",
90 ft_nr_buffers,
91 ft_buffer[ft_nr_buffers-1],
92 ft_buffer[ft_nr_buffers-1]->address);
93 TRACE_EXIT 0;
94}
95
96static void del_one_buffer(void)
97{
98 TRACE_FUN(ft_t_flow);
99 if (ft_nr_buffers > 0) {
100 TRACE(ft_t_info, "releasing buffer nr #%d @ %p, dma area @ %p",
101 ft_nr_buffers,
102 ft_buffer[ft_nr_buffers-1],
103 ft_buffer[ft_nr_buffers-1]->address);
104 ft_nr_buffers --;
105 dmafree(ft_buffer[ft_nr_buffers]->address, FT_BUFF_SIZE);
106 kfree(ft_buffer[ft_nr_buffers]);
107 ft_buffer[ft_nr_buffers] = NULL;
108 }
109 TRACE_EXIT;
110}
111
112int ftape_set_nr_buffers(int cnt)
113{
114 int delta = cnt - ft_nr_buffers;
115 TRACE_FUN(ft_t_flow);
116
117 if (delta > 0) {
118 while (delta--) {
119 if (add_one_buffer() < 0) {
120 TRACE_EXIT -ENOMEM;
121 }
122 }
123 } else if (delta < 0) {
124 while (delta++) {
125 del_one_buffer();
126 }
127 }
128 ftape_zap_read_buffers();
129 TRACE_EXIT 0;
130}
diff --git a/drivers/char/ftape/lowlevel/ftape-buffer.h b/drivers/char/ftape/lowlevel/ftape-buffer.h
deleted file mode 100644
index eec99cee8f82..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-buffer.h
+++ /dev/null
@@ -1,32 +0,0 @@
1#ifndef _FTAPE_BUFFER_H
2#define _FTAPE_BUFFER_H
3
4/*
5 * Copyright (C) 1997 Claus-Justus Heine.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 *
22 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-buffer.h,v $
23 * $Revision: 1.2 $
24 * $Date: 1997/10/05 19:18:08 $
25 *
26 * This file contains the allocator/dealloctor for ftape's dynamic dma
27 * buffer.
28 */
29
30extern int ftape_set_nr_buffers(int cnt);
31
32#endif
diff --git a/drivers/char/ftape/lowlevel/ftape-calibr.c b/drivers/char/ftape/lowlevel/ftape-calibr.c
deleted file mode 100644
index 8e50bfd35a52..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-calibr.c
+++ /dev/null
@@ -1,275 +0,0 @@
1/*
2 * Copyright (C) 1993-1996 Bas Laarhoven.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 *
19 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-calibr.c,v $
20 * $Revision: 1.2 $
21 * $Date: 1997/10/05 19:18:08 $
22 *
23 * GP calibration routine for processor speed dependent
24 * functions.
25 */
26
27#include <linux/errno.h>
28#include <linux/jiffies.h>
29#include <asm/system.h>
30#include <asm/io.h>
31#if defined(__alpha__)
32# include <asm/hwrpb.h>
33#elif defined(__x86_64__)
34# include <asm/msr.h>
35# include <asm/timex.h>
36#elif defined(__i386__)
37# include <linux/timex.h>
38#endif
39#include <linux/ftape.h>
40#include "../lowlevel/ftape-tracing.h"
41#include "../lowlevel/ftape-calibr.h"
42#include "../lowlevel/fdc-io.h"
43
44#undef DEBUG
45
46#if !defined(__alpha__) && !defined(__i386__) && !defined(__x86_64__)
47# error Ftape is not implemented for this architecture!
48#endif
49
50#if defined(__alpha__) || defined(__x86_64__)
51static unsigned long ps_per_cycle = 0;
52#endif
53
54static spinlock_t calibr_lock;
55
56/*
57 * Note: On Intel PCs, the clock ticks at 100 Hz (HZ==100) which is
58 * too slow for certain timeouts (and that clock doesn't even tick
59 * when interrupts are disabled). For that reason, the 8254 timer is
60 * used directly to implement fine-grained timeouts. However, on
61 * Alpha PCs, the 8254 is *not* used to implement the clock tick
62 * (which is 1024 Hz, normally) and the 8254 timer runs at some
63 * "random" frequency (it seems to run at 18Hz, but it's not safe to
64 * rely on this value). Instead, we use the Alpha's "rpcc"
65 * instruction to read cycle counts. As this is a 32 bit counter,
66 * it will overflow only once per 30 seconds (on a 200MHz machine),
67 * which is plenty.
68 */
69
70unsigned int ftape_timestamp(void)
71{
72#if defined(__alpha__)
73 unsigned long r;
74
75 asm volatile ("rpcc %0" : "=r" (r));
76 return r;
77#elif defined(__x86_64__)
78 unsigned long r;
79 rdtscl(r);
80 return r;
81#elif defined(__i386__)
82
83/*
84 * Note that there is some time between counter underflowing and jiffies
85 * increasing, so the code below won't always give correct output.
86 * -Vojtech
87 */
88
89 unsigned long flags;
90 __u16 lo;
91 __u16 hi;
92
93 spin_lock_irqsave(&calibr_lock, flags);
94 outb_p(0x00, 0x43); /* latch the count ASAP */
95 lo = inb_p(0x40); /* read the latched count */
96 lo |= inb(0x40) << 8;
97 hi = jiffies;
98 spin_unlock_irqrestore(&calibr_lock, flags);
99 return ((hi + 1) * (unsigned int) LATCH) - lo; /* downcounter ! */
100#endif
101}
102
103static unsigned int short_ftape_timestamp(void)
104{
105#if defined(__alpha__) || defined(__x86_64__)
106 return ftape_timestamp();
107#elif defined(__i386__)
108 unsigned int count;
109 unsigned long flags;
110
111 spin_lock_irqsave(&calibr_lock, flags);
112 outb_p(0x00, 0x43); /* latch the count ASAP */
113 count = inb_p(0x40); /* read the latched count */
114 count |= inb(0x40) << 8;
115 spin_unlock_irqrestore(&calibr_lock, flags);
116 return (LATCH - count); /* normal: downcounter */
117#endif
118}
119
120static unsigned int diff(unsigned int t0, unsigned int t1)
121{
122#if defined(__alpha__) || defined(__x86_64__)
123 return (t1 - t0);
124#elif defined(__i386__)
125 /*
126 * This is tricky: to work for both short and full ftape_timestamps
127 * we'll have to discriminate between these.
128 * If it _looks_ like short stamps with wrapping around we'll
129 * asume it are. This will generate a small error if it really
130 * was a (very large) delta from full ftape_timestamps.
131 */
132 return (t1 <= t0 && t0 <= LATCH) ? t1 + LATCH - t0 : t1 - t0;
133#endif
134}
135
136static unsigned int usecs(unsigned int count)
137{
138#if defined(__alpha__) || defined(__x86_64__)
139 return (ps_per_cycle * count) / 1000000UL;
140#elif defined(__i386__)
141 return (10000 * count) / ((CLOCK_TICK_RATE + 50) / 100);
142#endif
143}
144
145unsigned int ftape_timediff(unsigned int t0, unsigned int t1)
146{
147 /*
148 * Calculate difference in usec for ftape_timestamp results t0 & t1.
149 * Note that on the i386 platform with short time-stamps, the
150 * maximum allowed timespan is 1/HZ or we'll lose ticks!
151 */
152 return usecs(diff(t0, t1));
153}
154
155/* To get an indication of the I/O performance,
156 * measure the duration of the inb() function.
157 */
158static void time_inb(void)
159{
160 int i;
161 int t0, t1;
162 unsigned long flags;
163 int status;
164 TRACE_FUN(ft_t_any);
165
166 spin_lock_irqsave(&calibr_lock, flags);
167 t0 = short_ftape_timestamp();
168 for (i = 0; i < 1000; ++i) {
169 status = inb(fdc.msr);
170 }
171 t1 = short_ftape_timestamp();
172 spin_unlock_irqrestore(&calibr_lock, flags);
173 TRACE(ft_t_info, "inb() duration: %d nsec", ftape_timediff(t0, t1));
174 TRACE_EXIT;
175}
176
177static void init_clock(void)
178{
179 TRACE_FUN(ft_t_any);
180
181#if defined(__x86_64__)
182 ps_per_cycle = 1000000000UL / cpu_khz;
183#elif defined(__alpha__)
184 extern struct hwrpb_struct *hwrpb;
185 ps_per_cycle = (1000*1000*1000*1000UL) / hwrpb->cycle_freq;
186#endif
187 TRACE_EXIT;
188}
189
190/*
191 * Input: function taking int count as parameter.
192 * pointers to calculated calibration variables.
193 */
194void ftape_calibrate(char *name,
195 void (*fun) (unsigned int),
196 unsigned int *calibr_count,
197 unsigned int *calibr_time)
198{
199 static int first_time = 1;
200 int i;
201 unsigned int tc = 0;
202 unsigned int count;
203 unsigned int time;
204#if defined(__i386__)
205 unsigned int old_tc = 0;
206 unsigned int old_count = 1;
207 unsigned int old_time = 1;
208#endif
209 TRACE_FUN(ft_t_flow);
210
211 if (first_time) { /* get idea of I/O performance */
212 init_clock();
213 time_inb();
214 first_time = 0;
215 }
216 /* value of timeout must be set so that on very slow systems
217 * it will give a time less than one jiffy, and on
218 * very fast systems it'll give reasonable precision.
219 */
220
221 count = 40;
222 for (i = 0; i < 15; ++i) {
223 unsigned int t0;
224 unsigned int t1;
225 unsigned int once;
226 unsigned int multiple;
227 unsigned long flags;
228
229 *calibr_count =
230 *calibr_time = count; /* set TC to 1 */
231 spin_lock_irqsave(&calibr_lock, flags);
232 fun(0); /* dummy, get code into cache */
233 t0 = short_ftape_timestamp();
234 fun(0); /* overhead + one test */
235 t1 = short_ftape_timestamp();
236 once = diff(t0, t1);
237 t0 = short_ftape_timestamp();
238 fun(count); /* overhead + count tests */
239 t1 = short_ftape_timestamp();
240 multiple = diff(t0, t1);
241 spin_unlock_irqrestore(&calibr_lock, flags);
242 time = ftape_timediff(0, multiple - once);
243 tc = (1000 * time) / (count - 1);
244 TRACE(ft_t_any, "once:%3d us,%6d times:%6d us, TC:%5d ns",
245 usecs(once), count - 1, usecs(multiple), tc);
246#if defined(__alpha__) || defined(__x86_64__)
247 /*
248 * Increase the calibration count exponentially until the
249 * calibration time exceeds 100 ms.
250 */
251 if (time >= 100*1000) {
252 break;
253 }
254#elif defined(__i386__)
255 /*
256 * increase the count until the resulting time nears 2/HZ,
257 * then the tc will drop sharply because we lose LATCH counts.
258 */
259 if (tc <= old_tc / 2) {
260 time = old_time;
261 count = old_count;
262 break;
263 }
264 old_tc = tc;
265 old_count = count;
266 old_time = time;
267#endif
268 count *= 2;
269 }
270 *calibr_count = count - 1;
271 *calibr_time = time;
272 TRACE(ft_t_info, "TC for `%s()' = %d nsec (at %d counts)",
273 name, (1000 * *calibr_time) / *calibr_count, *calibr_count);
274 TRACE_EXIT;
275}
diff --git a/drivers/char/ftape/lowlevel/ftape-calibr.h b/drivers/char/ftape/lowlevel/ftape-calibr.h
deleted file mode 100644
index 0c7e75246c7d..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-calibr.h
+++ /dev/null
@@ -1,37 +0,0 @@
1#ifndef _FTAPE_CALIBR_H
2#define _FTAPE_CALIBR_H
3
4/*
5 * Copyright (C) 1993-1996 Bas Laarhoven.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 *
22 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-calibr.h,v $
23 * $Revision: 1.1 $
24 * $Date: 1997/09/19 09:05:26 $
25 *
26 * This file contains a gp calibration routine for
27 * hardware dependent timeout functions.
28 */
29
30extern void ftape_calibrate(char *name,
31 void (*fun) (unsigned int),
32 unsigned int *calibr_count,
33 unsigned int *calibr_time);
34extern unsigned int ftape_timestamp(void);
35extern unsigned int ftape_timediff(unsigned int t0, unsigned int t1);
36
37#endif /* _FTAPE_CALIBR_H */
diff --git a/drivers/char/ftape/lowlevel/ftape-ctl.c b/drivers/char/ftape/lowlevel/ftape-ctl.c
deleted file mode 100644
index 5d7c1ce92d59..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-ctl.c
+++ /dev/null
@@ -1,896 +0,0 @@
1/*
2 * Copyright (C) 1993-1996 Bas Laarhoven,
3 * 1996-1997 Claus-Justus Heine.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
8 any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; see the file COPYING. If not, write to
17 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 *
20 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-ctl.c,v $
21 * $Revision: 1.4 $
22 * $Date: 1997/11/11 14:37:44 $
23 *
24 * This file contains the non-read/write ftape functions for the
25 * QIC-40/80/3010/3020 floppy-tape driver "ftape" for Linux.
26 */
27
28#include <linux/errno.h>
29#include <linux/mm.h>
30#include <linux/mman.h>
31
32#include <linux/ftape.h>
33#include <linux/qic117.h>
34#include <asm/uaccess.h>
35#include <asm/io.h>
36
37/* ease porting between pre-2.4.x and later kernels */
38#define vma_get_pgoff(v) ((v)->vm_pgoff)
39
40#include "../lowlevel/ftape-tracing.h"
41#include "../lowlevel/ftape-io.h"
42#include "../lowlevel/ftape-ctl.h"
43#include "../lowlevel/ftape-write.h"
44#include "../lowlevel/ftape-read.h"
45#include "../lowlevel/ftape-rw.h"
46#include "../lowlevel/ftape-bsm.h"
47
48/* Global vars.
49 */
50ftape_info ftape_status = {
51/* vendor information */
52 { 0, }, /* drive type */
53/* data rates */
54 500, /* used data rate */
55 500, /* drive max rate */
56 500, /* fdc max rate */
57/* drive selection, either FTAPE_SEL_A/B/C/D */
58 -1, /* drive selection */
59/* flags set after decode the drive and tape status */
60 0, /* formatted */
61 1, /* no tape */
62 1, /* write protected */
63 1, /* new tape */
64/* values of last queried drive/tape status and error */
65 {{0,}}, /* last error code */
66 {{0,}}, /* drive status, configuration, tape status */
67/* cartridge geometry */
68 20, /* tracks_per_tape */
69 102, /* segments_per_track */
70/* location of header segments, etc. */
71 -1, /* used_header_segment */
72 -1, /* header_segment_1 */
73 -1, /* header_segment_2 */
74 -1, /* first_data_segment */
75 -1, /* last_data_segment */
76/* the format code as stored in the header segment */
77 fmt_normal, /* format code */
78/* the default for the qic std: unknown */
79 -1,
80/* is tape running? */
81 idle, /* runner_state */
82/* is tape reading/writing/verifying/formatting/deleting */
83 idle, /* driver state */
84/* flags fatal hardware error */
85 1, /* failure */
86/* history record */
87 { 0, } /* history record */
88};
89
90int ftape_segments_per_head = 1020;
91int ftape_segments_per_cylinder = 4;
92int ftape_init_drive_needed = 1; /* need to be global for ftape_reset_drive()
93 * in ftape-io.c
94 */
95
96/* Local vars.
97 */
98static const vendor_struct vendors[] = QIC117_VENDORS;
99static const wakeup_method methods[] = WAKEUP_METHODS;
100
101const ftape_info *ftape_get_status(void)
102{
103#if defined(STATUS_PARANOYA)
104 static ftape_info get_status;
105
106 get_status = ftape_status;
107 return &get_status;
108#else
109 return &ftape_status; /* maybe return only a copy of it to assure
110 * read only access
111 */
112#endif
113}
114
115static int ftape_not_operational(int status)
116{
117 /* return true if status indicates tape can not be used.
118 */
119 return ((status ^ QIC_STATUS_CARTRIDGE_PRESENT) &
120 (QIC_STATUS_ERROR |
121 QIC_STATUS_CARTRIDGE_PRESENT |
122 QIC_STATUS_NEW_CARTRIDGE));
123}
124
125int ftape_seek_to_eot(void)
126{
127 int status;
128 TRACE_FUN(ft_t_any);
129
130 TRACE_CATCH(ftape_ready_wait(ftape_timeout.pause, &status),);
131 while ((status & QIC_STATUS_AT_EOT) == 0) {
132 if (ftape_not_operational(status)) {
133 TRACE_EXIT -EIO;
134 }
135 TRACE_CATCH(ftape_command_wait(QIC_PHYSICAL_FORWARD,
136 ftape_timeout.rewind,&status),);
137 }
138 TRACE_EXIT 0;
139}
140
141int ftape_seek_to_bot(void)
142{
143 int status;
144 TRACE_FUN(ft_t_any);
145
146 TRACE_CATCH(ftape_ready_wait(ftape_timeout.pause, &status),);
147 while ((status & QIC_STATUS_AT_BOT) == 0) {
148 if (ftape_not_operational(status)) {
149 TRACE_EXIT -EIO;
150 }
151 TRACE_CATCH(ftape_command_wait(QIC_PHYSICAL_REVERSE,
152 ftape_timeout.rewind,&status),);
153 }
154 TRACE_EXIT 0;
155}
156
157static int ftape_new_cartridge(void)
158{
159 ft_location.track = -1; /* force seek on first access */
160 ftape_zap_read_buffers();
161 ftape_zap_write_buffers();
162 return 0;
163}
164
165int ftape_abort_operation(void)
166{
167 int result = 0;
168 int status;
169 TRACE_FUN(ft_t_flow);
170
171 if (ft_runner_status == running) {
172 TRACE(ft_t_noise, "aborting runner, waiting");
173
174 ft_runner_status = do_abort;
175 /* set timeout so that the tape will run to logical EOT
176 * if we missed the last sector and there are no queue pulses.
177 */
178 result = ftape_dumb_stop();
179 }
180 if (ft_runner_status != idle) {
181 if (ft_runner_status == do_abort) {
182 TRACE(ft_t_noise, "forcing runner abort");
183 }
184 TRACE(ft_t_noise, "stopping tape");
185 result = ftape_stop_tape(&status);
186 ft_location.known = 0;
187 ft_runner_status = idle;
188 }
189 ftape_reset_buffer();
190 ftape_zap_read_buffers();
191 ftape_set_state(idle);
192 TRACE_EXIT result;
193}
194
195static int lookup_vendor_id(unsigned int vendor_id)
196{
197 int i = 0;
198
199 while (vendors[i].vendor_id != vendor_id) {
200 if (++i >= NR_ITEMS(vendors)) {
201 return -1;
202 }
203 }
204 return i;
205}
206
207static void ftape_detach_drive(void)
208{
209 TRACE_FUN(ft_t_any);
210
211 TRACE(ft_t_flow, "disabling tape drive and fdc");
212 ftape_put_drive_to_sleep(ft_drive_type.wake_up);
213 fdc_catch_stray_interrupts(1); /* one always comes */
214 fdc_disable();
215 fdc_release_irq_and_dma();
216 fdc_release_regions();
217 TRACE_EXIT;
218}
219
220static void clear_history(void)
221{
222 ft_history.used = 0;
223 ft_history.id_am_errors =
224 ft_history.id_crc_errors =
225 ft_history.data_am_errors =
226 ft_history.data_crc_errors =
227 ft_history.overrun_errors =
228 ft_history.no_data_errors =
229 ft_history.retries =
230 ft_history.crc_errors =
231 ft_history.crc_failures =
232 ft_history.ecc_failures =
233 ft_history.corrected =
234 ft_history.defects =
235 ft_history.rewinds = 0;
236}
237
238static int ftape_activate_drive(vendor_struct * drive_type)
239{
240 int result = 0;
241 TRACE_FUN(ft_t_flow);
242
243 /* If we already know the drive type, wake it up.
244 * Else try to find out what kind of drive is attached.
245 */
246 if (drive_type->wake_up != unknown_wake_up) {
247 TRACE(ft_t_flow, "enabling tape drive and fdc");
248 result = ftape_wakeup_drive(drive_type->wake_up);
249 if (result < 0) {
250 TRACE(ft_t_err, "known wakeup method failed");
251 }
252 } else {
253 wake_up_types method;
254 const ft_trace_t old_tracing = TRACE_LEVEL;
255 if (TRACE_LEVEL < ft_t_flow) {
256 SET_TRACE_LEVEL(ft_t_bug);
257 }
258
259 /* Try to awaken the drive using all known methods.
260 * Lower tracing for a while.
261 */
262 for (method=no_wake_up; method < NR_ITEMS(methods); ++method) {
263 drive_type->wake_up = method;
264#ifdef CONFIG_FT_TWO_DRIVES
265 /* Test setup for dual drive configuration.
266 * /dev/rft2 uses mountain wakeup
267 * /dev/rft3 uses colorado wakeup
268 * Other systems will use the normal scheme.
269 */
270 if ((ft_drive_sel < 2) ||
271 (ft_drive_sel == 2 && method == FT_WAKE_UP_1) ||
272 (ft_drive_sel == 3 && method == FT_WAKE_UP_2)) {
273 result=ftape_wakeup_drive(drive_type->wake_up);
274 } else {
275 result = -EIO;
276 }
277#else
278 result = ftape_wakeup_drive(drive_type->wake_up);
279#endif
280 if (result >= 0) {
281 TRACE(ft_t_warn, "drive wakeup method: %s",
282 methods[drive_type->wake_up].name);
283 break;
284 }
285 }
286 SET_TRACE_LEVEL(old_tracing);
287
288 if (method >= NR_ITEMS(methods)) {
289 /* no response at all, cannot open this drive */
290 drive_type->wake_up = unknown_wake_up;
291 TRACE(ft_t_err, "no tape drive found !");
292 result = -ENODEV;
293 }
294 }
295 TRACE_EXIT result;
296}
297
298static int ftape_get_drive_status(void)
299{
300 int result;
301 int status;
302 TRACE_FUN(ft_t_flow);
303
304 ft_no_tape = ft_write_protected = 0;
305 /* Tape drive is activated now.
306 * First clear error status if present.
307 */
308 do {
309 result = ftape_ready_wait(ftape_timeout.reset, &status);
310 if (result < 0) {
311 if (result == -ETIME) {
312 TRACE(ft_t_err, "ftape_ready_wait timeout");
313 } else if (result == -EINTR) {
314 TRACE(ft_t_err, "ftape_ready_wait aborted");
315 } else {
316 TRACE(ft_t_err, "ftape_ready_wait failed");
317 }
318 TRACE_EXIT -EIO;
319 }
320 /* Clear error condition (drive is ready !)
321 */
322 if (status & QIC_STATUS_ERROR) {
323 unsigned int error;
324 qic117_cmd_t command;
325
326 TRACE(ft_t_err, "error status set");
327 result = ftape_report_error(&error, &command, 1);
328 if (result < 0) {
329 TRACE(ft_t_err,
330 "report_error_code failed: %d", result);
331 /* hope it's working next time */
332 ftape_reset_drive();
333 TRACE_EXIT -EIO;
334 } else if (error != 0) {
335 TRACE(ft_t_noise, "error code : %d", error);
336 TRACE(ft_t_noise, "error command: %d", command);
337 }
338 }
339 if (status & QIC_STATUS_NEW_CARTRIDGE) {
340 unsigned int error;
341 qic117_cmd_t command;
342 const ft_trace_t old_tracing = TRACE_LEVEL;
343 SET_TRACE_LEVEL(ft_t_bug);
344
345 /* Undocumented feature: Must clear (not present!)
346 * error here or we'll fail later.
347 */
348 ftape_report_error(&error, &command, 1);
349
350 SET_TRACE_LEVEL(old_tracing);
351 TRACE(ft_t_info, "status: new cartridge");
352 ft_new_tape = 1;
353 } else {
354 ft_new_tape = 0;
355 }
356 FT_SIGNAL_EXIT(_DONT_BLOCK);
357 } while (status & QIC_STATUS_ERROR);
358
359 ft_no_tape = !(status & QIC_STATUS_CARTRIDGE_PRESENT);
360 ft_write_protected = (status & QIC_STATUS_WRITE_PROTECT) != 0;
361 if (ft_no_tape) {
362 TRACE(ft_t_warn, "no cartridge present");
363 } else {
364 if (ft_write_protected) {
365 TRACE(ft_t_noise, "Write protected cartridge");
366 }
367 }
368 TRACE_EXIT 0;
369}
370
371static void ftape_log_vendor_id(void)
372{
373 int vendor_index;
374 TRACE_FUN(ft_t_flow);
375
376 ftape_report_vendor_id(&ft_drive_type.vendor_id);
377 vendor_index = lookup_vendor_id(ft_drive_type.vendor_id);
378 if (ft_drive_type.vendor_id == UNKNOWN_VENDOR &&
379 ft_drive_type.wake_up == wake_up_colorado) {
380 vendor_index = 0;
381 /* hack to get rid of all this mail */
382 ft_drive_type.vendor_id = 0;
383 }
384 if (vendor_index < 0) {
385 /* Unknown vendor id, first time opening device. The
386 * drive_type remains set to type found at wakeup
387 * time, this will probably keep the driver operating
388 * for this new vendor.
389 */
390 TRACE(ft_t_warn, "\n"
391 KERN_INFO "============ unknown vendor id ===========\n"
392 KERN_INFO "A new, yet unsupported tape drive is found\n"
393 KERN_INFO "Please report the following values:\n"
394 KERN_INFO " Vendor id : 0x%04x\n"
395 KERN_INFO " Wakeup method : %s\n"
396 KERN_INFO "And a description of your tape drive\n"
397 KERN_INFO "to "THE_FTAPE_MAINTAINER"\n"
398 KERN_INFO "==========================================",
399 ft_drive_type.vendor_id,
400 methods[ft_drive_type.wake_up].name);
401 ft_drive_type.speed = 0; /* unknown */
402 } else {
403 ft_drive_type.name = vendors[vendor_index].name;
404 ft_drive_type.speed = vendors[vendor_index].speed;
405 TRACE(ft_t_info, "tape drive type: %s", ft_drive_type.name);
406 /* scan all methods for this vendor_id in table */
407 while(ft_drive_type.wake_up != vendors[vendor_index].wake_up) {
408 if (vendor_index < NR_ITEMS(vendors) - 1 &&
409 vendors[vendor_index + 1].vendor_id
410 ==
411 ft_drive_type.vendor_id) {
412 ++vendor_index;
413 } else {
414 break;
415 }
416 }
417 if (ft_drive_type.wake_up != vendors[vendor_index].wake_up) {
418 TRACE(ft_t_warn, "\n"
419 KERN_INFO "==========================================\n"
420 KERN_INFO "wakeup type mismatch:\n"
421 KERN_INFO "found: %s, expected: %s\n"
422 KERN_INFO "please report this to "THE_FTAPE_MAINTAINER"\n"
423 KERN_INFO "==========================================",
424 methods[ft_drive_type.wake_up].name,
425 methods[vendors[vendor_index].wake_up].name);
426 }
427 }
428 TRACE_EXIT;
429}
430
431void ftape_calc_timeouts(unsigned int qic_std,
432 unsigned int data_rate,
433 unsigned int tape_len)
434{
435 int speed; /* deci-ips ! */
436 int ff_speed;
437 int length;
438 TRACE_FUN(ft_t_any);
439
440 /* tape transport speed
441 * data rate: QIC-40 QIC-80 QIC-3010 QIC-3020
442 *
443 * 250 Kbps 25 ips n/a n/a n/a
444 * 500 Kbps 50 ips 34 ips 22.6 ips n/a
445 * 1 Mbps n/a 68 ips 45.2 ips 22.6 ips
446 * 2 Mbps n/a n/a n/a 45.2 ips
447 *
448 * fast tape transport speed is at least 68 ips.
449 */
450 switch (qic_std) {
451 case QIC_TAPE_QIC40:
452 speed = (data_rate == 250) ? 250 : 500;
453 break;
454 case QIC_TAPE_QIC80:
455 speed = (data_rate == 500) ? 340 : 680;
456 break;
457 case QIC_TAPE_QIC3010:
458 speed = (data_rate == 500) ? 226 : 452;
459 break;
460 case QIC_TAPE_QIC3020:
461 speed = (data_rate == 1000) ? 226 : 452;
462 break;
463 default:
464 TRACE(ft_t_bug, "Unknown qic_std (bug) ?");
465 speed = 500;
466 break;
467 }
468 if (ft_drive_type.speed == 0) {
469 unsigned long t0;
470 static int dt = 0; /* keep gcc from complaining */
471 static int first_time = 1;
472
473 /* Measure the time it takes to wind to EOT and back to BOT.
474 * If the tape length is known, calculate the rewind speed.
475 * Else keep the time value for calculation of the rewind
476 * speed later on, when the length _is_ known.
477 * Ask for a report only when length and speed are both known.
478 */
479 if (first_time) {
480 ftape_seek_to_bot();
481 t0 = jiffies;
482 ftape_seek_to_eot();
483 ftape_seek_to_bot();
484 dt = (int) (((jiffies - t0) * FT_USPT) / 1000);
485 if (dt < 1) {
486 dt = 1; /* prevent div by zero on failures */
487 }
488 first_time = 0;
489 TRACE(ft_t_info,
490 "trying to determine seek timeout, got %d msec",
491 dt);
492 }
493 if (tape_len != 0) {
494 ft_drive_type.speed =
495 (2 * 12 * tape_len * 1000) / dt;
496 TRACE(ft_t_warn, "\n"
497 KERN_INFO "==========================================\n"
498 KERN_INFO "drive type: %s\n"
499 KERN_INFO "delta time = %d ms, length = %d ft\n"
500 KERN_INFO "has a maximum tape speed of %d ips\n"
501 KERN_INFO "please report this to "THE_FTAPE_MAINTAINER"\n"
502 KERN_INFO "==========================================",
503 ft_drive_type.name, dt, tape_len,
504 ft_drive_type.speed);
505 }
506 }
507 /* Handle unknown length tapes as very long ones. We'll
508 * determine the actual length from a header segment later.
509 * This is normal for all modern (Wide,TR1/2/3) formats.
510 */
511 if (tape_len <= 0) {
512 TRACE(ft_t_noise,
513 "Unknown tape length, using maximal timeouts");
514 length = QIC_TOP_TAPE_LEN; /* use worst case values */
515 } else {
516 length = tape_len; /* use actual values */
517 }
518 if (ft_drive_type.speed == 0) {
519 ff_speed = speed;
520 } else {
521 ff_speed = ft_drive_type.speed;
522 }
523 /* time to go from bot to eot at normal speed (data rate):
524 * time = (1+delta) * length (ft) * 12 (inch/ft) / speed (ips)
525 * delta = 10 % for seek speed, 20 % for rewind speed.
526 */
527 ftape_timeout.seek = (length * 132 * FT_SECOND) / speed;
528 ftape_timeout.rewind = (length * 144 * FT_SECOND) / (10 * ff_speed);
529 ftape_timeout.reset = 20 * FT_SECOND + ftape_timeout.rewind;
530 TRACE(ft_t_noise, "timeouts for speed = %d, length = %d\n"
531 KERN_INFO "seek timeout : %d sec\n"
532 KERN_INFO "rewind timeout: %d sec\n"
533 KERN_INFO "reset timeout : %d sec",
534 speed, length,
535 (ftape_timeout.seek + 500) / 1000,
536 (ftape_timeout.rewind + 500) / 1000,
537 (ftape_timeout.reset + 500) / 1000);
538 TRACE_EXIT;
539}
540
541/* This function calibrates the datarate (i.e. determines the maximal
542 * usable data rate) and sets the global variable ft_qic_std to qic_std
543 *
544 */
545int ftape_calibrate_data_rate(unsigned int qic_std)
546{
547 int rate = ft_fdc_rate_limit;
548 int result;
549 TRACE_FUN(ft_t_flow);
550
551 ft_qic_std = qic_std;
552
553 if (ft_qic_std == -1) {
554 TRACE_ABORT(-EIO, ft_t_err,
555 "Unable to determine data rate if QIC standard is unknown");
556 }
557
558 /* Select highest rate supported by both fdc and drive.
559 * Start with highest rate supported by the fdc.
560 */
561 while (fdc_set_data_rate(rate) < 0 && rate > 250) {
562 rate /= 2;
563 }
564 TRACE(ft_t_info,
565 "Highest FDC supported data rate: %d Kbps", rate);
566 ft_fdc_max_rate = rate;
567 do {
568 result = ftape_set_data_rate(rate, ft_qic_std);
569 } while (result == -EINVAL && (rate /= 2) > 250);
570 if (result < 0) {
571 TRACE_ABORT(-EIO, ft_t_err, "set datarate failed");
572 }
573 ft_data_rate = rate;
574 TRACE_EXIT 0;
575}
576
577static int ftape_init_drive(void)
578{
579 int status;
580 qic_model model;
581 unsigned int qic_std;
582 unsigned int data_rate;
583 TRACE_FUN(ft_t_flow);
584
585 ftape_init_drive_needed = 0; /* don't retry if this fails ? */
586 TRACE_CATCH(ftape_report_raw_drive_status(&status),);
587 if (status & QIC_STATUS_CARTRIDGE_PRESENT) {
588 if (!(status & QIC_STATUS_AT_BOT)) {
589 /* Antique drives will get here after a soft reset,
590 * modern ones only if the driver is loaded when the
591 * tape wasn't rewound properly.
592 */
593 /* Tape should be at bot if new cartridge ! */
594 ftape_seek_to_bot();
595 }
596 if (!(status & QIC_STATUS_REFERENCED)) {
597 TRACE(ft_t_flow, "starting seek_load_point");
598 TRACE_CATCH(ftape_command_wait(QIC_SEEK_LOAD_POINT,
599 ftape_timeout.reset,
600 &status),);
601 }
602 }
603 ft_formatted = (status & QIC_STATUS_REFERENCED) != 0;
604 if (!ft_formatted) {
605 TRACE(ft_t_warn, "Warning: tape is not formatted !");
606 }
607
608 /* report configuration aborts when ftape_tape_len == -1
609 * unknown qic_std is okay if not formatted.
610 */
611 TRACE_CATCH(ftape_report_configuration(&model,
612 &data_rate,
613 &qic_std,
614 &ftape_tape_len),);
615
616 /* Maybe add the following to the /proc entry
617 */
618 TRACE(ft_t_info, "%s drive @ %d Kbps",
619 (model == prehistoric) ? "prehistoric" :
620 ((model == pre_qic117c) ? "pre QIC-117C" :
621 ((model == post_qic117b) ? "post QIC-117B" :
622 "post QIC-117D")), data_rate);
623
624 if (ft_formatted) {
625 /* initialize ft_used_data_rate to maximum value
626 * and set ft_qic_std
627 */
628 TRACE_CATCH(ftape_calibrate_data_rate(qic_std),);
629 if (ftape_tape_len == 0) {
630 TRACE(ft_t_info, "unknown length QIC-%s tape",
631 (ft_qic_std == QIC_TAPE_QIC40) ? "40" :
632 ((ft_qic_std == QIC_TAPE_QIC80) ? "80" :
633 ((ft_qic_std == QIC_TAPE_QIC3010)
634 ? "3010" : "3020")));
635 } else {
636 TRACE(ft_t_info, "%d ft. QIC-%s tape", ftape_tape_len,
637 (ft_qic_std == QIC_TAPE_QIC40) ? "40" :
638 ((ft_qic_std == QIC_TAPE_QIC80) ? "80" :
639 ((ft_qic_std == QIC_TAPE_QIC3010)
640 ? "3010" : "3020")));
641 }
642 ftape_calc_timeouts(ft_qic_std, ft_data_rate, ftape_tape_len);
643 /* soft write-protect QIC-40/QIC-80 cartridges used with a
644 * Colorado T3000 drive. Buggy hardware!
645 */
646 if ((ft_drive_type.vendor_id == 0x011c6) &&
647 ((ft_qic_std == QIC_TAPE_QIC40 ||
648 ft_qic_std == QIC_TAPE_QIC80) &&
649 !ft_write_protected)) {
650 TRACE(ft_t_warn, "\n"
651 KERN_INFO "The famous Colorado T3000 bug:\n"
652 KERN_INFO "%s drives can't write QIC40 and QIC80\n"
653 KERN_INFO "cartridges but don't set the write-protect flag!",
654 ft_drive_type.name);
655 ft_write_protected = 1;
656 }
657 } else {
658 /* Doesn't make too much sense to set the data rate
659 * because we don't know what to use for the write
660 * precompensation.
661 * Need to do this again when formatting the cartridge.
662 */
663 ft_data_rate = data_rate;
664 ftape_calc_timeouts(QIC_TAPE_QIC40,
665 data_rate,
666 ftape_tape_len);
667 }
668 ftape_new_cartridge();
669 TRACE_EXIT 0;
670}
671
672static void ftape_munmap(void)
673{
674 int i;
675 TRACE_FUN(ft_t_flow);
676
677 for (i = 0; i < ft_nr_buffers; i++) {
678 ft_buffer[i]->mmapped = 0;
679 }
680 TRACE_EXIT;
681}
682
683/* Map the dma buffers into the virtual address range given by vma.
684 * We only check the caller doesn't map non-existent buffers. We
685 * don't check for multiple mappings.
686 */
687int ftape_mmap(struct vm_area_struct *vma)
688{
689 int num_buffers;
690 int i;
691 TRACE_FUN(ft_t_flow);
692
693 if (ft_failure) {
694 TRACE_EXIT -ENODEV;
695 }
696 if (!(vma->vm_flags & (VM_READ|VM_WRITE))) {
697 TRACE_ABORT(-EINVAL, ft_t_err, "Undefined mmap() access");
698 }
699 if (vma_get_pgoff(vma) != 0) {
700 TRACE_ABORT(-EINVAL, ft_t_err, "page offset must be 0");
701 }
702 if ((vma->vm_end - vma->vm_start) % FT_BUFF_SIZE != 0) {
703 TRACE_ABORT(-EINVAL, ft_t_err,
704 "size = %ld, should be a multiple of %d",
705 vma->vm_end - vma->vm_start,
706 FT_BUFF_SIZE);
707 }
708 num_buffers = (vma->vm_end - vma->vm_start) / FT_BUFF_SIZE;
709 if (num_buffers > ft_nr_buffers) {
710 TRACE_ABORT(-EINVAL,
711 ft_t_err, "size = %ld, should be less than %d",
712 vma->vm_end - vma->vm_start,
713 ft_nr_buffers * FT_BUFF_SIZE);
714 }
715 if (ft_driver_state != idle) {
716 /* this also clears the buffer states
717 */
718 ftape_abort_operation();
719 } else {
720 ftape_reset_buffer();
721 }
722 for (i = 0; i < num_buffers; i++) {
723 unsigned long pfn;
724
725 pfn = virt_to_phys(ft_buffer[i]->address) >> PAGE_SHIFT;
726 TRACE_CATCH(remap_pfn_range(vma, vma->vm_start +
727 i * FT_BUFF_SIZE,
728 pfn,
729 FT_BUFF_SIZE,
730 vma->vm_page_prot),
731 _res = -EAGAIN);
732 TRACE(ft_t_noise, "remapped dma buffer @ %p to location @ %p",
733 ft_buffer[i]->address,
734 (void *)(vma->vm_start + i * FT_BUFF_SIZE));
735 }
736 for (i = 0; i < num_buffers; i++) {
737 memset(ft_buffer[i]->address, 0xAA, FT_BUFF_SIZE);
738 ft_buffer[i]->mmapped++;
739 }
740 TRACE_EXIT 0;
741}
742
743static void ftape_init_driver(void); /* forward declaration */
744
745/* OPEN routine called by kernel-interface code
746 */
747int ftape_enable(int drive_selection)
748{
749 TRACE_FUN(ft_t_any);
750
751 if (ft_drive_sel == -1 || ft_drive_sel != drive_selection) {
752 /* Other selection than last time
753 */
754 ftape_init_driver();
755 }
756 ft_drive_sel = FTAPE_SEL(drive_selection);
757 ft_failure = 0;
758 TRACE_CATCH(fdc_init(),); /* init & detect fdc */
759 TRACE_CATCH(ftape_activate_drive(&ft_drive_type),
760 fdc_disable();
761 fdc_release_irq_and_dma();
762 fdc_release_regions());
763 TRACE_CATCH(ftape_get_drive_status(), ftape_detach_drive());
764 if (ft_drive_type.vendor_id == UNKNOWN_VENDOR) {
765 ftape_log_vendor_id();
766 }
767 if (ft_new_tape) {
768 ftape_init_drive_needed = 1;
769 }
770 if (!ft_no_tape && ftape_init_drive_needed) {
771 TRACE_CATCH(ftape_init_drive(), ftape_detach_drive());
772 }
773 ftape_munmap(); /* clear the mmap flag */
774 clear_history();
775 TRACE_EXIT 0;
776}
777
778/* release routine called by the high level interface modules
779 * zftape or sftape.
780 */
781void ftape_disable(void)
782{
783 int i;
784 TRACE_FUN(ft_t_any);
785
786 for (i = 0; i < ft_nr_buffers; i++) {
787 if (ft_buffer[i]->mmapped) {
788 TRACE(ft_t_noise, "first byte of buffer %d: 0x%02x",
789 i, *ft_buffer[i]->address);
790 }
791 }
792 if (sigtestsetmask(&current->pending.signal, _DONT_BLOCK) &&
793 !(sigtestsetmask(&current->pending.signal, _NEVER_BLOCK)) &&
794 ftape_tape_running) {
795 TRACE(ft_t_warn,
796 "Interrupted by fatal signal and tape still running");
797 ftape_dumb_stop();
798 ftape_abort_operation(); /* it's annoying */
799 } else {
800 ftape_set_state(idle);
801 }
802 ftape_detach_drive();
803 if (ft_history.used) {
804 TRACE(ft_t_info, "== Non-fatal errors this run: ==");
805 TRACE(ft_t_info, "fdc isr statistics:\n"
806 KERN_INFO " id_am_errors : %3d\n"
807 KERN_INFO " id_crc_errors : %3d\n"
808 KERN_INFO " data_am_errors : %3d\n"
809 KERN_INFO " data_crc_errors : %3d\n"
810 KERN_INFO " overrun_errors : %3d\n"
811 KERN_INFO " no_data_errors : %3d\n"
812 KERN_INFO " retries : %3d",
813 ft_history.id_am_errors, ft_history.id_crc_errors,
814 ft_history.data_am_errors, ft_history.data_crc_errors,
815 ft_history.overrun_errors, ft_history.no_data_errors,
816 ft_history.retries);
817 if (ft_history.used & 1) {
818 TRACE(ft_t_info, "ecc statistics:\n"
819 KERN_INFO " crc_errors : %3d\n"
820 KERN_INFO " crc_failures : %3d\n"
821 KERN_INFO " ecc_failures : %3d\n"
822 KERN_INFO " sectors corrected: %3d",
823 ft_history.crc_errors, ft_history.crc_failures,
824 ft_history.ecc_failures, ft_history.corrected);
825 }
826 if (ft_history.defects > 0) {
827 TRACE(ft_t_warn, "Warning: %d media defects!",
828 ft_history.defects);
829 }
830 if (ft_history.rewinds > 0) {
831 TRACE(ft_t_info, "tape motion statistics:\n"
832 KERN_INFO "repositions : %3d",
833 ft_history.rewinds);
834 }
835 }
836 ft_failure = 1;
837 TRACE_EXIT;
838}
839
840static void ftape_init_driver(void)
841{
842 TRACE_FUN(ft_t_flow);
843
844 ft_drive_type.vendor_id = UNKNOWN_VENDOR;
845 ft_drive_type.speed = 0;
846 ft_drive_type.wake_up = unknown_wake_up;
847 ft_drive_type.name = "Unknown";
848
849 ftape_timeout.seek = 650 * FT_SECOND;
850 ftape_timeout.reset = 670 * FT_SECOND;
851 ftape_timeout.rewind = 650 * FT_SECOND;
852 ftape_timeout.head_seek = 15 * FT_SECOND;
853 ftape_timeout.stop = 5 * FT_SECOND;
854 ftape_timeout.pause = 16 * FT_SECOND;
855
856 ft_qic_std = -1;
857 ftape_tape_len = 0; /* unknown */
858 ftape_current_command = 0;
859 ftape_current_cylinder = -1;
860
861 ft_segments_per_track = 102;
862 ftape_segments_per_head = 1020;
863 ftape_segments_per_cylinder = 4;
864 ft_tracks_per_tape = 20;
865
866 ft_failure = 1;
867
868 ft_formatted = 0;
869 ft_no_tape = 1;
870 ft_write_protected = 1;
871 ft_new_tape = 1;
872
873 ft_driver_state = idle;
874
875 ft_data_rate =
876 ft_fdc_max_rate = 500;
877 ft_drive_max_rate = 0; /* triggers set_rate_test() */
878
879 ftape_init_drive_needed = 1;
880
881 ft_header_segment_1 = -1;
882 ft_header_segment_2 = -1;
883 ft_used_header_segment = -1;
884 ft_first_data_segment = -1;
885 ft_last_data_segment = -1;
886
887 ft_location.track = -1;
888 ft_location.known = 0;
889
890 ftape_tape_running = 0;
891 ftape_might_be_off_track = 1;
892
893 ftape_new_cartridge(); /* init some tape related variables */
894 ftape_init_bsm();
895 TRACE_EXIT;
896}
diff --git a/drivers/char/ftape/lowlevel/ftape-ctl.h b/drivers/char/ftape/lowlevel/ftape-ctl.h
deleted file mode 100644
index 5f5e30bc3615..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-ctl.h
+++ /dev/null
@@ -1,162 +0,0 @@
1#ifndef _FTAPE_CTL_H
2#define _FTAPE_CTL_H
3
4/*
5 * Copyright (C) 1993-1996 Bas Laarhoven,
6 * (C) 1996-1997 Claus-Justus Heine.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; see the file COPYING. If not, write to
20 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21
22 *
23 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-ctl.h,v $
24 * $Revision: 1.2 $
25 * $Date: 1997/10/05 19:18:09 $
26 *
27 * This file contains the non-standard IOCTL related definitions
28 * for the QIC-40/80/3010/3020 floppy-tape driver "ftape" for
29 * Linux.
30 */
31
32#include <linux/ioctl.h>
33#include <linux/mtio.h>
34#include <linux/ftape-vendors.h>
35
36#include "../lowlevel/ftape-rw.h"
37#include <linux/ftape-header-segment.h>
38
39typedef struct {
40 int used; /* any reading or writing done */
41 /* isr statistics */
42 unsigned int id_am_errors; /* id address mark not found */
43 unsigned int id_crc_errors; /* crc error in id address mark */
44 unsigned int data_am_errors; /* data address mark not found */
45 unsigned int data_crc_errors; /* crc error in data field */
46 unsigned int overrun_errors; /* fdc access timing problem */
47 unsigned int no_data_errors; /* sector not found */
48 unsigned int retries; /* number of tape retries */
49 /* ecc statistics */
50 unsigned int crc_errors; /* crc error in data */
51 unsigned int crc_failures; /* bad data without crc error */
52 unsigned int ecc_failures; /* failed to correct */
53 unsigned int corrected; /* total sectors corrected */
54 /* general statistics */
55 unsigned int rewinds; /* number of tape rewinds */
56 unsigned int defects; /* bad sectors due to media defects */
57} history_record;
58
59/* this structure contains * ALL * information that we want
60 * our child modules to know about, but don't want them to
61 * modify.
62 */
63typedef struct {
64 /* vendor information */
65 vendor_struct fti_drive_type;
66 /* data rates */
67 unsigned int fti_used_data_rate;
68 unsigned int fti_drive_max_rate;
69 unsigned int fti_fdc_max_rate;
70 /* drive selection, either FTAPE_SEL_A/B/C/D */
71 int fti_drive_sel;
72 /* flags set after decode the drive and tape status */
73 unsigned int fti_formatted :1;
74 unsigned int fti_no_tape :1;
75 unsigned int fti_write_protected:1;
76 unsigned int fti_new_tape :1;
77 /* values of last queried drive/tape status and error */
78 ft_drive_error fti_last_error;
79 ft_drive_status fti_last_status;
80 /* cartridge geometry */
81 unsigned int fti_tracks_per_tape;
82 unsigned int fti_segments_per_track;
83 /* location of header segments, etc. */
84 int fti_used_header_segment;
85 int fti_header_segment_1;
86 int fti_header_segment_2;
87 int fti_first_data_segment;
88 int fti_last_data_segment;
89 /* the format code as stored in the header segment */
90 ft_format_type fti_format_code;
91 /* the following is the sole reason for the ftape_set_status() call */
92 unsigned int fti_qic_std;
93 /* is tape running? */
94 volatile enum runner_status_enum fti_runner_status;
95 /* is tape reading/writing/verifying/formatting/deleting */
96 buffer_state_enum fti_state;
97 /* flags fatal hardware error */
98 unsigned int fti_failure:1;
99 /* history record */
100 history_record fti_history;
101} ftape_info;
102
103/* vendor information */
104#define ft_drive_type ftape_status.fti_drive_type
105/* data rates */
106#define ft_data_rate ftape_status.fti_used_data_rate
107#define ft_drive_max_rate ftape_status.fti_drive_max_rate
108#define ft_fdc_max_rate ftape_status.fti_fdc_max_rate
109/* drive selection, either FTAPE_SEL_A/B/C/D */
110#define ft_drive_sel ftape_status.fti_drive_sel
111/* flags set after decode the drive and tape status */
112#define ft_formatted ftape_status.fti_formatted
113#define ft_no_tape ftape_status.fti_no_tape
114#define ft_write_protected ftape_status.fti_write_protected
115#define ft_new_tape ftape_status.fti_new_tape
116/* values of last queried drive/tape status and error */
117#define ft_last_error ftape_status.fti_last_error
118#define ft_last_status ftape_status.fti_last_status
119/* cartridge geometry */
120#define ft_tracks_per_tape ftape_status.fti_tracks_per_tape
121#define ft_segments_per_track ftape_status.fti_segments_per_track
122/* the format code as stored in the header segment */
123#define ft_format_code ftape_status.fti_format_code
124/* the qic status as returned by report drive configuration */
125#define ft_qic_std ftape_status.fti_qic_std
126#define ft_used_header_segment ftape_status.fti_used_header_segment
127#define ft_header_segment_1 ftape_status.fti_header_segment_1
128#define ft_header_segment_2 ftape_status.fti_header_segment_2
129#define ft_first_data_segment ftape_status.fti_first_data_segment
130#define ft_last_data_segment ftape_status.fti_last_data_segment
131/* is tape running? */
132#define ft_runner_status ftape_status.fti_runner_status
133/* is tape reading/writing/verifying/formatting/deleting */
134#define ft_driver_state ftape_status.fti_state
135/* flags fatal hardware error */
136#define ft_failure ftape_status.fti_failure
137/* history record */
138#define ft_history ftape_status.fti_history
139
140/*
141 * ftape-ctl.c defined global vars.
142 */
143extern ftape_info ftape_status;
144extern int ftape_segments_per_head;
145extern int ftape_segments_per_cylinder;
146extern int ftape_init_drive_needed;
147
148/*
149 * ftape-ctl.c defined global functions.
150 */
151extern int ftape_mmap(struct vm_area_struct *vma);
152extern int ftape_enable(int drive_selection);
153extern void ftape_disable(void);
154extern int ftape_seek_to_bot(void);
155extern int ftape_seek_to_eot(void);
156extern int ftape_abort_operation(void);
157extern void ftape_calc_timeouts(unsigned int qic_std,
158 unsigned int data_rate,
159 unsigned int tape_len);
160extern int ftape_calibrate_data_rate(unsigned int qic_std);
161extern const ftape_info *ftape_get_status(void);
162#endif
diff --git a/drivers/char/ftape/lowlevel/ftape-ecc.c b/drivers/char/ftape/lowlevel/ftape-ecc.c
deleted file mode 100644
index e5632f674bc8..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-ecc.c
+++ /dev/null
@@ -1,853 +0,0 @@
1/*
2 *
3 * Copyright (c) 1993 Ning and David Mosberger.
4
5 This is based on code originally written by Bas Laarhoven (bas@vimec.nl)
6 and David L. Brown, Jr., and incorporates improvements suggested by
7 Kai Harrekilde-Petersen.
8
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2, or (at
12 your option) any later version.
13
14 This program is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; see the file COPYING. If not, write to
21 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
22 USA.
23
24 *
25 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-ecc.c,v $
26 * $Revision: 1.3 $
27 * $Date: 1997/10/05 19:18:10 $
28 *
29 * This file contains the Reed-Solomon error correction code
30 * for the QIC-40/80 floppy-tape driver for Linux.
31 */
32
33#include <linux/ftape.h>
34
35#include "../lowlevel/ftape-tracing.h"
36#include "../lowlevel/ftape-ecc.h"
37
38/* Machines that are big-endian should define macro BIG_ENDIAN.
39 * Unfortunately, there doesn't appear to be a standard include file
40 * that works for all OSs.
41 */
42
43#if defined(__sparc__) || defined(__hppa)
44#define BIG_ENDIAN
45#endif /* __sparc__ || __hppa */
46
47#if defined(__mips__)
48#error Find a smart way to determine the Endianness of the MIPS CPU
49#endif
50
51/* Notice: to minimize the potential for confusion, we use r to
52 * denote the independent variable of the polynomials in the
53 * Galois Field GF(2^8). We reserve x for polynomials that
54 * that have coefficients in GF(2^8).
55 *
56 * The Galois Field in which coefficient arithmetic is performed are
57 * the polynomials over Z_2 (i.e., 0 and 1) modulo the irreducible
58 * polynomial f(r), where f(r)=r^8 + r^7 + r^2 + r + 1. A polynomial
59 * is represented as a byte with the MSB as the coefficient of r^7 and
60 * the LSB as the coefficient of r^0. For example, the binary
61 * representation of f(x) is 0x187 (of course, this doesn't fit into 8
62 * bits). In this field, the polynomial r is a primitive element.
63 * That is, r^i with i in 0,...,255 enumerates all elements in the
64 * field.
65 *
66 * The generator polynomial for the QIC-80 ECC is
67 *
68 * g(x) = x^3 + r^105*x^2 + r^105*x + 1
69 *
70 * which can be factored into:
71 *
72 * g(x) = (x-r^-1)(x-r^0)(x-r^1)
73 *
74 * the byte representation of the coefficients are:
75 *
76 * r^105 = 0xc0
77 * r^-1 = 0xc3
78 * r^0 = 0x01
79 * r^1 = 0x02
80 *
81 * Notice that r^-1 = r^254 as exponent arithmetic is performed
82 * modulo 2^8-1 = 255.
83 *
84 * For more information on Galois Fields and Reed-Solomon codes, refer
85 * to any good book. I found _An Introduction to Error Correcting
86 * Codes with Applications_ by S. A. Vanstone and P. C. van Oorschot
87 * to be a good introduction into the former. _CODING THEORY: The
88 * Essentials_ I found very useful for its concise description of
89 * Reed-Solomon encoding/decoding.
90 *
91 */
92
93typedef __u8 Matrix[3][3];
94
95/*
96 * gfpow[] is defined such that gfpow[i] returns r^i if
97 * i is in the range [0..255].
98 */
99static const __u8 gfpow[] =
100{
101 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80,
102 0x87, 0x89, 0x95, 0xad, 0xdd, 0x3d, 0x7a, 0xf4,
103 0x6f, 0xde, 0x3b, 0x76, 0xec, 0x5f, 0xbe, 0xfb,
104 0x71, 0xe2, 0x43, 0x86, 0x8b, 0x91, 0xa5, 0xcd,
105 0x1d, 0x3a, 0x74, 0xe8, 0x57, 0xae, 0xdb, 0x31,
106 0x62, 0xc4, 0x0f, 0x1e, 0x3c, 0x78, 0xf0, 0x67,
107 0xce, 0x1b, 0x36, 0x6c, 0xd8, 0x37, 0x6e, 0xdc,
108 0x3f, 0x7e, 0xfc, 0x7f, 0xfe, 0x7b, 0xf6, 0x6b,
109 0xd6, 0x2b, 0x56, 0xac, 0xdf, 0x39, 0x72, 0xe4,
110 0x4f, 0x9e, 0xbb, 0xf1, 0x65, 0xca, 0x13, 0x26,
111 0x4c, 0x98, 0xb7, 0xe9, 0x55, 0xaa, 0xd3, 0x21,
112 0x42, 0x84, 0x8f, 0x99, 0xb5, 0xed, 0x5d, 0xba,
113 0xf3, 0x61, 0xc2, 0x03, 0x06, 0x0c, 0x18, 0x30,
114 0x60, 0xc0, 0x07, 0x0e, 0x1c, 0x38, 0x70, 0xe0,
115 0x47, 0x8e, 0x9b, 0xb1, 0xe5, 0x4d, 0x9a, 0xb3,
116 0xe1, 0x45, 0x8a, 0x93, 0xa1, 0xc5, 0x0d, 0x1a,
117 0x34, 0x68, 0xd0, 0x27, 0x4e, 0x9c, 0xbf, 0xf9,
118 0x75, 0xea, 0x53, 0xa6, 0xcb, 0x11, 0x22, 0x44,
119 0x88, 0x97, 0xa9, 0xd5, 0x2d, 0x5a, 0xb4, 0xef,
120 0x59, 0xb2, 0xe3, 0x41, 0x82, 0x83, 0x81, 0x85,
121 0x8d, 0x9d, 0xbd, 0xfd, 0x7d, 0xfa, 0x73, 0xe6,
122 0x4b, 0x96, 0xab, 0xd1, 0x25, 0x4a, 0x94, 0xaf,
123 0xd9, 0x35, 0x6a, 0xd4, 0x2f, 0x5e, 0xbc, 0xff,
124 0x79, 0xf2, 0x63, 0xc6, 0x0b, 0x16, 0x2c, 0x58,
125 0xb0, 0xe7, 0x49, 0x92, 0xa3, 0xc1, 0x05, 0x0a,
126 0x14, 0x28, 0x50, 0xa0, 0xc7, 0x09, 0x12, 0x24,
127 0x48, 0x90, 0xa7, 0xc9, 0x15, 0x2a, 0x54, 0xa8,
128 0xd7, 0x29, 0x52, 0xa4, 0xcf, 0x19, 0x32, 0x64,
129 0xc8, 0x17, 0x2e, 0x5c, 0xb8, 0xf7, 0x69, 0xd2,
130 0x23, 0x46, 0x8c, 0x9f, 0xb9, 0xf5, 0x6d, 0xda,
131 0x33, 0x66, 0xcc, 0x1f, 0x3e, 0x7c, 0xf8, 0x77,
132 0xee, 0x5b, 0xb6, 0xeb, 0x51, 0xa2, 0xc3, 0x01
133};
134
135/*
136 * This is a log table. That is, gflog[r^i] returns i (modulo f(r)).
137 * gflog[0] is undefined and the first element is therefore not valid.
138 */
139static const __u8 gflog[256] =
140{
141 0xff, 0x00, 0x01, 0x63, 0x02, 0xc6, 0x64, 0x6a,
142 0x03, 0xcd, 0xc7, 0xbc, 0x65, 0x7e, 0x6b, 0x2a,
143 0x04, 0x8d, 0xce, 0x4e, 0xc8, 0xd4, 0xbd, 0xe1,
144 0x66, 0xdd, 0x7f, 0x31, 0x6c, 0x20, 0x2b, 0xf3,
145 0x05, 0x57, 0x8e, 0xe8, 0xcf, 0xac, 0x4f, 0x83,
146 0xc9, 0xd9, 0xd5, 0x41, 0xbe, 0x94, 0xe2, 0xb4,
147 0x67, 0x27, 0xde, 0xf0, 0x80, 0xb1, 0x32, 0x35,
148 0x6d, 0x45, 0x21, 0x12, 0x2c, 0x0d, 0xf4, 0x38,
149 0x06, 0x9b, 0x58, 0x1a, 0x8f, 0x79, 0xe9, 0x70,
150 0xd0, 0xc2, 0xad, 0xa8, 0x50, 0x75, 0x84, 0x48,
151 0xca, 0xfc, 0xda, 0x8a, 0xd6, 0x54, 0x42, 0x24,
152 0xbf, 0x98, 0x95, 0xf9, 0xe3, 0x5e, 0xb5, 0x15,
153 0x68, 0x61, 0x28, 0xba, 0xdf, 0x4c, 0xf1, 0x2f,
154 0x81, 0xe6, 0xb2, 0x3f, 0x33, 0xee, 0x36, 0x10,
155 0x6e, 0x18, 0x46, 0xa6, 0x22, 0x88, 0x13, 0xf7,
156 0x2d, 0xb8, 0x0e, 0x3d, 0xf5, 0xa4, 0x39, 0x3b,
157 0x07, 0x9e, 0x9c, 0x9d, 0x59, 0x9f, 0x1b, 0x08,
158 0x90, 0x09, 0x7a, 0x1c, 0xea, 0xa0, 0x71, 0x5a,
159 0xd1, 0x1d, 0xc3, 0x7b, 0xae, 0x0a, 0xa9, 0x91,
160 0x51, 0x5b, 0x76, 0x72, 0x85, 0xa1, 0x49, 0xeb,
161 0xcb, 0x7c, 0xfd, 0xc4, 0xdb, 0x1e, 0x8b, 0xd2,
162 0xd7, 0x92, 0x55, 0xaa, 0x43, 0x0b, 0x25, 0xaf,
163 0xc0, 0x73, 0x99, 0x77, 0x96, 0x5c, 0xfa, 0x52,
164 0xe4, 0xec, 0x5f, 0x4a, 0xb6, 0xa2, 0x16, 0x86,
165 0x69, 0xc5, 0x62, 0xfe, 0x29, 0x7d, 0xbb, 0xcc,
166 0xe0, 0xd3, 0x4d, 0x8c, 0xf2, 0x1f, 0x30, 0xdc,
167 0x82, 0xab, 0xe7, 0x56, 0xb3, 0x93, 0x40, 0xd8,
168 0x34, 0xb0, 0xef, 0x26, 0x37, 0x0c, 0x11, 0x44,
169 0x6f, 0x78, 0x19, 0x9a, 0x47, 0x74, 0xa7, 0xc1,
170 0x23, 0x53, 0x89, 0xfb, 0x14, 0x5d, 0xf8, 0x97,
171 0x2e, 0x4b, 0xb9, 0x60, 0x0f, 0xed, 0x3e, 0xe5,
172 0xf6, 0x87, 0xa5, 0x17, 0x3a, 0xa3, 0x3c, 0xb7
173};
174
175/* This is a multiplication table for the factor 0xc0 (i.e., r^105 (mod f(r)).
176 * gfmul_c0[f] returns r^105 * f(r) (modulo f(r)).
177 */
178static const __u8 gfmul_c0[256] =
179{
180 0x00, 0xc0, 0x07, 0xc7, 0x0e, 0xce, 0x09, 0xc9,
181 0x1c, 0xdc, 0x1b, 0xdb, 0x12, 0xd2, 0x15, 0xd5,
182 0x38, 0xf8, 0x3f, 0xff, 0x36, 0xf6, 0x31, 0xf1,
183 0x24, 0xe4, 0x23, 0xe3, 0x2a, 0xea, 0x2d, 0xed,
184 0x70, 0xb0, 0x77, 0xb7, 0x7e, 0xbe, 0x79, 0xb9,
185 0x6c, 0xac, 0x6b, 0xab, 0x62, 0xa2, 0x65, 0xa5,
186 0x48, 0x88, 0x4f, 0x8f, 0x46, 0x86, 0x41, 0x81,
187 0x54, 0x94, 0x53, 0x93, 0x5a, 0x9a, 0x5d, 0x9d,
188 0xe0, 0x20, 0xe7, 0x27, 0xee, 0x2e, 0xe9, 0x29,
189 0xfc, 0x3c, 0xfb, 0x3b, 0xf2, 0x32, 0xf5, 0x35,
190 0xd8, 0x18, 0xdf, 0x1f, 0xd6, 0x16, 0xd1, 0x11,
191 0xc4, 0x04, 0xc3, 0x03, 0xca, 0x0a, 0xcd, 0x0d,
192 0x90, 0x50, 0x97, 0x57, 0x9e, 0x5e, 0x99, 0x59,
193 0x8c, 0x4c, 0x8b, 0x4b, 0x82, 0x42, 0x85, 0x45,
194 0xa8, 0x68, 0xaf, 0x6f, 0xa6, 0x66, 0xa1, 0x61,
195 0xb4, 0x74, 0xb3, 0x73, 0xba, 0x7a, 0xbd, 0x7d,
196 0x47, 0x87, 0x40, 0x80, 0x49, 0x89, 0x4e, 0x8e,
197 0x5b, 0x9b, 0x5c, 0x9c, 0x55, 0x95, 0x52, 0x92,
198 0x7f, 0xbf, 0x78, 0xb8, 0x71, 0xb1, 0x76, 0xb6,
199 0x63, 0xa3, 0x64, 0xa4, 0x6d, 0xad, 0x6a, 0xaa,
200 0x37, 0xf7, 0x30, 0xf0, 0x39, 0xf9, 0x3e, 0xfe,
201 0x2b, 0xeb, 0x2c, 0xec, 0x25, 0xe5, 0x22, 0xe2,
202 0x0f, 0xcf, 0x08, 0xc8, 0x01, 0xc1, 0x06, 0xc6,
203 0x13, 0xd3, 0x14, 0xd4, 0x1d, 0xdd, 0x1a, 0xda,
204 0xa7, 0x67, 0xa0, 0x60, 0xa9, 0x69, 0xae, 0x6e,
205 0xbb, 0x7b, 0xbc, 0x7c, 0xb5, 0x75, 0xb2, 0x72,
206 0x9f, 0x5f, 0x98, 0x58, 0x91, 0x51, 0x96, 0x56,
207 0x83, 0x43, 0x84, 0x44, 0x8d, 0x4d, 0x8a, 0x4a,
208 0xd7, 0x17, 0xd0, 0x10, 0xd9, 0x19, 0xde, 0x1e,
209 0xcb, 0x0b, 0xcc, 0x0c, 0xc5, 0x05, 0xc2, 0x02,
210 0xef, 0x2f, 0xe8, 0x28, 0xe1, 0x21, 0xe6, 0x26,
211 0xf3, 0x33, 0xf4, 0x34, 0xfd, 0x3d, 0xfa, 0x3a
212};
213
214
215/* Returns V modulo 255 provided V is in the range -255,-254,...,509.
216 */
217static inline __u8 mod255(int v)
218{
219 if (v > 0) {
220 if (v < 255) {
221 return v;
222 } else {
223 return v - 255;
224 }
225 } else {
226 return v + 255;
227 }
228}
229
230
231/* Add two numbers in the field. Addition in this field is equivalent
232 * to a bit-wise exclusive OR operation---subtraction is therefore
233 * identical to addition.
234 */
235static inline __u8 gfadd(__u8 a, __u8 b)
236{
237 return a ^ b;
238}
239
240
241/* Add two vectors of numbers in the field. Each byte in A and B gets
242 * added individually.
243 */
244static inline unsigned long gfadd_long(unsigned long a, unsigned long b)
245{
246 return a ^ b;
247}
248
249
250/* Multiply two numbers in the field:
251 */
252static inline __u8 gfmul(__u8 a, __u8 b)
253{
254 if (a && b) {
255 return gfpow[mod255(gflog[a] + gflog[b])];
256 } else {
257 return 0;
258 }
259}
260
261
262/* Just like gfmul, except we have already looked up the log of the
263 * second number.
264 */
265static inline __u8 gfmul_exp(__u8 a, int b)
266{
267 if (a) {
268 return gfpow[mod255(gflog[a] + b)];
269 } else {
270 return 0;
271 }
272}
273
274
275/* Just like gfmul_exp, except that A is a vector of numbers. That
276 * is, each byte in A gets multiplied by gfpow[mod255(B)].
277 */
278static inline unsigned long gfmul_exp_long(unsigned long a, int b)
279{
280 __u8 t;
281
282 if (sizeof(long) == 4) {
283 return (
284 ((t = (__u32)a >> 24 & 0xff) ?
285 (((__u32) gfpow[mod255(gflog[t] + b)]) << 24) : 0) |
286 ((t = (__u32)a >> 16 & 0xff) ?
287 (((__u32) gfpow[mod255(gflog[t] + b)]) << 16) : 0) |
288 ((t = (__u32)a >> 8 & 0xff) ?
289 (((__u32) gfpow[mod255(gflog[t] + b)]) << 8) : 0) |
290 ((t = (__u32)a >> 0 & 0xff) ?
291 (((__u32) gfpow[mod255(gflog[t] + b)]) << 0) : 0));
292 } else if (sizeof(long) == 8) {
293 return (
294 ((t = (__u64)a >> 56 & 0xff) ?
295 (((__u64) gfpow[mod255(gflog[t] + b)]) << 56) : 0) |
296 ((t = (__u64)a >> 48 & 0xff) ?
297 (((__u64) gfpow[mod255(gflog[t] + b)]) << 48) : 0) |
298 ((t = (__u64)a >> 40 & 0xff) ?
299 (((__u64) gfpow[mod255(gflog[t] + b)]) << 40) : 0) |
300 ((t = (__u64)a >> 32 & 0xff) ?
301 (((__u64) gfpow[mod255(gflog[t] + b)]) << 32) : 0) |
302 ((t = (__u64)a >> 24 & 0xff) ?
303 (((__u64) gfpow[mod255(gflog[t] + b)]) << 24) : 0) |
304 ((t = (__u64)a >> 16 & 0xff) ?
305 (((__u64) gfpow[mod255(gflog[t] + b)]) << 16) : 0) |
306 ((t = (__u64)a >> 8 & 0xff) ?
307 (((__u64) gfpow[mod255(gflog[t] + b)]) << 8) : 0) |
308 ((t = (__u64)a >> 0 & 0xff) ?
309 (((__u64) gfpow[mod255(gflog[t] + b)]) << 0) : 0));
310 } else {
311 TRACE_FUN(ft_t_any);
312 TRACE_ABORT(-1, ft_t_err, "Error: size of long is %d bytes",
313 (int)sizeof(long));
314 }
315}
316
317
318/* Divide two numbers in the field. Returns a/b (modulo f(x)).
319 */
320static inline __u8 gfdiv(__u8 a, __u8 b)
321{
322 if (!b) {
323 TRACE_FUN(ft_t_any);
324 TRACE_ABORT(0xff, ft_t_bug, "Error: division by zero");
325 } else if (a == 0) {
326 return 0;
327 } else {
328 return gfpow[mod255(gflog[a] - gflog[b])];
329 }
330}
331
332
333/* The following functions return the inverse of the matrix of the
334 * linear system that needs to be solved to determine the error
335 * magnitudes. The first deals with matrices of rank 3, while the
336 * second deals with matrices of rank 2. The error indices are passed
337 * in arguments L0,..,L2 (0=first sector, 31=last sector). The error
338 * indices must be sorted in ascending order, i.e., L0<L1<L2.
339 *
340 * The linear system that needs to be solved for the error magnitudes
341 * is A * b = s, where s is the known vector of syndromes, b is the
342 * vector of error magnitudes and A in the ORDER=3 case:
343 *
344 * A_3 = {{1/r^L[0], 1/r^L[1], 1/r^L[2]},
345 * { 1, 1, 1},
346 * { r^L[0], r^L[1], r^L[2]}}
347 */
348static inline int gfinv3(__u8 l0,
349 __u8 l1,
350 __u8 l2,
351 Matrix Ainv)
352{
353 __u8 det;
354 __u8 t20, t10, t21, t12, t01, t02;
355 int log_det;
356
357 /* compute some intermediate results: */
358 t20 = gfpow[l2 - l0]; /* t20 = r^l2/r^l0 */
359 t10 = gfpow[l1 - l0]; /* t10 = r^l1/r^l0 */
360 t21 = gfpow[l2 - l1]; /* t21 = r^l2/r^l1 */
361 t12 = gfpow[l1 - l2 + 255]; /* t12 = r^l1/r^l2 */
362 t01 = gfpow[l0 - l1 + 255]; /* t01 = r^l0/r^l1 */
363 t02 = gfpow[l0 - l2 + 255]; /* t02 = r^l0/r^l2 */
364 /* Calculate the determinant of matrix A_3^-1 (sometimes
365 * called the Vandermonde determinant):
366 */
367 det = gfadd(t20, gfadd(t10, gfadd(t21, gfadd(t12, gfadd(t01, t02)))));
368 if (!det) {
369 TRACE_FUN(ft_t_any);
370 TRACE_ABORT(0, ft_t_err,
371 "Inversion failed (3 CRC errors, >0 CRC failures)");
372 }
373 log_det = 255 - gflog[det];
374
375 /* Now, calculate all of the coefficients:
376 */
377 Ainv[0][0]= gfmul_exp(gfadd(gfpow[l1], gfpow[l2]), log_det);
378 Ainv[0][1]= gfmul_exp(gfadd(t21, t12), log_det);
379 Ainv[0][2]= gfmul_exp(gfadd(gfpow[255 - l1], gfpow[255 - l2]),log_det);
380
381 Ainv[1][0]= gfmul_exp(gfadd(gfpow[l0], gfpow[l2]), log_det);
382 Ainv[1][1]= gfmul_exp(gfadd(t20, t02), log_det);
383 Ainv[1][2]= gfmul_exp(gfadd(gfpow[255 - l0], gfpow[255 - l2]),log_det);
384
385 Ainv[2][0]= gfmul_exp(gfadd(gfpow[l0], gfpow[l1]), log_det);
386 Ainv[2][1]= gfmul_exp(gfadd(t10, t01), log_det);
387 Ainv[2][2]= gfmul_exp(gfadd(gfpow[255 - l0], gfpow[255 - l1]),log_det);
388
389 return 1;
390}
391
392
393static inline int gfinv2(__u8 l0, __u8 l1, Matrix Ainv)
394{
395 __u8 det;
396 __u8 t1, t2;
397 int log_det;
398
399 t1 = gfpow[255 - l0];
400 t2 = gfpow[255 - l1];
401 det = gfadd(t1, t2);
402 if (!det) {
403 TRACE_FUN(ft_t_any);
404 TRACE_ABORT(0, ft_t_err,
405 "Inversion failed (2 CRC errors, >0 CRC failures)");
406 }
407 log_det = 255 - gflog[det];
408
409 /* Now, calculate all of the coefficients:
410 */
411 Ainv[0][0] = Ainv[1][0] = gfpow[log_det];
412
413 Ainv[0][1] = gfmul_exp(t2, log_det);
414 Ainv[1][1] = gfmul_exp(t1, log_det);
415
416 return 1;
417}
418
419
420/* Multiply matrix A by vector S and return result in vector B. M is
421 * assumed to be of order NxN, S and B of order Nx1.
422 */
423static inline void gfmat_mul(int n, Matrix A,
424 __u8 *s, __u8 *b)
425{
426 int i, j;
427 __u8 dot_prod;
428
429 for (i = 0; i < n; ++i) {
430 dot_prod = 0;
431 for (j = 0; j < n; ++j) {
432 dot_prod = gfadd(dot_prod, gfmul(A[i][j], s[j]));
433 }
434 b[i] = dot_prod;
435 }
436}
437
438
439
440/* The Reed Solomon ECC codes are computed over the N-th byte of each
441 * block, where N=SECTOR_SIZE. There are up to 29 blocks of data, and
442 * 3 blocks of ECC. The blocks are stored contiguously in memory. A
443 * segment, consequently, is assumed to have at least 4 blocks: one or
444 * more data blocks plus three ECC blocks.
445 *
446 * Notice: In QIC-80 speak, a CRC error is a sector with an incorrect
447 * CRC. A CRC failure is a sector with incorrect data, but
448 * a valid CRC. In the error control literature, the former
449 * is usually called "erasure", the latter "error."
450 */
451/* Compute the parity bytes for C columns of data, where C is the
452 * number of bytes that fit into a long integer. We use a linear
453 * feed-back register to do this. The parity bytes P[0], P[STRIDE],
454 * P[2*STRIDE] are computed such that:
455 *
456 * x^k * p(x) + m(x) = 0 (modulo g(x))
457 *
458 * where k = NBLOCKS,
459 * p(x) = P[0] + P[STRIDE]*x + P[2*STRIDE]*x^2, and
460 * m(x) = sum_{i=0}^k m_i*x^i.
461 * m_i = DATA[i*SECTOR_SIZE]
462 */
463static inline void set_parity(unsigned long *data,
464 int nblocks,
465 unsigned long *p,
466 int stride)
467{
468 unsigned long p0, p1, p2, t1, t2, *end;
469
470 end = data + nblocks * (FT_SECTOR_SIZE / sizeof(long));
471 p0 = p1 = p2 = 0;
472 while (data < end) {
473 /* The new parity bytes p0_i, p1_i, p2_i are computed
474 * from the old values p0_{i-1}, p1_{i-1}, p2_{i-1}
475 * recursively as:
476 *
477 * p0_i = p1_{i-1} + r^105 * (m_{i-1} - p0_{i-1})
478 * p1_i = p2_{i-1} + r^105 * (m_{i-1} - p0_{i-1})
479 * p2_i = (m_{i-1} - p0_{i-1})
480 *
481 * With the initial condition: p0_0 = p1_0 = p2_0 = 0.
482 */
483 t1 = gfadd_long(*data, p0);
484 /*
485 * Multiply each byte in t1 by 0xc0:
486 */
487 if (sizeof(long) == 4) {
488 t2= (((__u32) gfmul_c0[(__u32)t1 >> 24 & 0xff]) << 24 |
489 ((__u32) gfmul_c0[(__u32)t1 >> 16 & 0xff]) << 16 |
490 ((__u32) gfmul_c0[(__u32)t1 >> 8 & 0xff]) << 8 |
491 ((__u32) gfmul_c0[(__u32)t1 >> 0 & 0xff]) << 0);
492 } else if (sizeof(long) == 8) {
493 t2= (((__u64) gfmul_c0[(__u64)t1 >> 56 & 0xff]) << 56 |
494 ((__u64) gfmul_c0[(__u64)t1 >> 48 & 0xff]) << 48 |
495 ((__u64) gfmul_c0[(__u64)t1 >> 40 & 0xff]) << 40 |
496 ((__u64) gfmul_c0[(__u64)t1 >> 32 & 0xff]) << 32 |
497 ((__u64) gfmul_c0[(__u64)t1 >> 24 & 0xff]) << 24 |
498 ((__u64) gfmul_c0[(__u64)t1 >> 16 & 0xff]) << 16 |
499 ((__u64) gfmul_c0[(__u64)t1 >> 8 & 0xff]) << 8 |
500 ((__u64) gfmul_c0[(__u64)t1 >> 0 & 0xff]) << 0);
501 } else {
502 TRACE_FUN(ft_t_any);
503 TRACE(ft_t_err, "Error: long is of size %d",
504 (int) sizeof(long));
505 TRACE_EXIT;
506 }
507 p0 = gfadd_long(t2, p1);
508 p1 = gfadd_long(t2, p2);
509 p2 = t1;
510 data += FT_SECTOR_SIZE / sizeof(long);
511 }
512 *p = p0;
513 p += stride;
514 *p = p1;
515 p += stride;
516 *p = p2;
517 return;
518}
519
520
521/* Compute the 3 syndrome values. DATA should point to the first byte
522 * of the column for which the syndromes are desired. The syndromes
523 * are computed over the first NBLOCKS of rows. The three bytes will
524 * be placed in S[0], S[1], and S[2].
525 *
526 * S[i] is the value of the "message" polynomial m(x) evaluated at the
527 * i-th root of the generator polynomial g(x).
528 *
529 * As g(x)=(x-r^-1)(x-1)(x-r^1) we evaluate the message polynomial at
530 * x=r^-1 to get S[0], at x=r^0=1 to get S[1], and at x=r to get S[2].
531 * This could be done directly and efficiently via the Horner scheme.
532 * However, it would require multiplication tables for the factors
533 * r^-1 (0xc3) and r (0x02). The following scheme does not require
534 * any multiplication tables beyond what's needed for set_parity()
535 * anyway and is slightly faster if there are no errors and slightly
536 * slower if there are errors. The latter is hopefully the infrequent
537 * case.
538 *
539 * To understand the alternative algorithm, notice that set_parity(m,
540 * k, p) computes parity bytes such that:
541 *
542 * x^k * p(x) = m(x) (modulo g(x)).
543 *
544 * That is, to evaluate m(r^m), where r^m is a root of g(x), we can
545 * simply evaluate (r^m)^k*p(r^m). Also, notice that p is 0 if and
546 * only if s is zero. That is, if all parity bytes are 0, we know
547 * there is no error in the data and consequently there is no need to
548 * compute s(x) at all! In all other cases, we compute s(x) from p(x)
549 * by evaluating (r^m)^k*p(r^m) for m=-1, m=0, and m=1. The p(x)
550 * polynomial is evaluated via the Horner scheme.
551 */
552static int compute_syndromes(unsigned long *data, int nblocks, unsigned long *s)
553{
554 unsigned long p[3];
555
556 set_parity(data, nblocks, p, 1);
557 if (p[0] | p[1] | p[2]) {
558 /* Some of the checked columns do not have a zero
559 * syndrome. For simplicity, we compute the syndromes
560 * for all columns that we have computed the
561 * remainders for.
562 */
563 s[0] = gfmul_exp_long(
564 gfadd_long(p[0],
565 gfmul_exp_long(
566 gfadd_long(p[1],
567 gfmul_exp_long(p[2], -1)),
568 -1)),
569 -nblocks);
570 s[1] = gfadd_long(gfadd_long(p[2], p[1]), p[0]);
571 s[2] = gfmul_exp_long(
572 gfadd_long(p[0],
573 gfmul_exp_long(
574 gfadd_long(p[1],
575 gfmul_exp_long(p[2], 1)),
576 1)),
577 nblocks);
578 return 0;
579 } else {
580 return 1;
581 }
582}
583
584
585/* Correct the block in the column pointed to by DATA. There are NBAD
586 * CRC errors and their indices are in BAD_LOC[0], up to
587 * BAD_LOC[NBAD-1]. If NBAD>1, Ainv holds the inverse of the matrix
588 * of the linear system that needs to be solved to determine the error
589 * magnitudes. S[0], S[1], and S[2] are the syndrome values. If row
590 * j gets corrected, then bit j will be set in CORRECTION_MAP.
591 */
592static inline int correct_block(__u8 *data, int nblocks,
593 int nbad, int *bad_loc, Matrix Ainv,
594 __u8 *s,
595 SectorMap * correction_map)
596{
597 int ncorrected = 0;
598 int i;
599 __u8 t1, t2;
600 __u8 c0, c1, c2; /* check bytes */
601 __u8 error_mag[3], log_error_mag;
602 __u8 *dp, l, e;
603 TRACE_FUN(ft_t_any);
604
605 switch (nbad) {
606 case 0:
607 /* might have a CRC failure: */
608 if (s[0] == 0) {
609 /* more than one error */
610 TRACE_ABORT(-1, ft_t_err,
611 "ECC failed (0 CRC errors, >1 CRC failures)");
612 }
613 t1 = gfdiv(s[1], s[0]);
614 if ((bad_loc[nbad++] = gflog[t1]) >= nblocks) {
615 TRACE(ft_t_err,
616 "ECC failed (0 CRC errors, >1 CRC failures)");
617 TRACE_ABORT(-1, ft_t_err,
618 "attempt to correct data at %d", bad_loc[0]);
619 }
620 error_mag[0] = s[1];
621 break;
622 case 1:
623 t1 = gfadd(gfmul_exp(s[1], bad_loc[0]), s[2]);
624 t2 = gfadd(gfmul_exp(s[0], bad_loc[0]), s[1]);
625 if (t1 == 0 && t2 == 0) {
626 /* one erasure, no error: */
627 Ainv[0][0] = gfpow[bad_loc[0]];
628 } else if (t1 == 0 || t2 == 0) {
629 /* one erasure and more than one error: */
630 TRACE_ABORT(-1, ft_t_err,
631 "ECC failed (1 erasure, >1 error)");
632 } else {
633 /* one erasure, one error: */
634 if ((bad_loc[nbad++] = gflog[gfdiv(t1, t2)])
635 >= nblocks) {
636 TRACE(ft_t_err, "ECC failed "
637 "(1 CRC errors, >1 CRC failures)");
638 TRACE_ABORT(-1, ft_t_err,
639 "attempt to correct data at %d",
640 bad_loc[1]);
641 }
642 if (!gfinv2(bad_loc[0], bad_loc[1], Ainv)) {
643 /* inversion failed---must have more
644 * than one error
645 */
646 TRACE_EXIT -1;
647 }
648 }
649 /* FALL THROUGH TO ERROR MAGNITUDE COMPUTATION:
650 */
651 case 2:
652 case 3:
653 /* compute error magnitudes: */
654 gfmat_mul(nbad, Ainv, s, error_mag);
655 break;
656
657 default:
658 TRACE_ABORT(-1, ft_t_err,
659 "Internal Error: number of CRC errors > 3");
660 }
661
662 /* Perform correction by adding ERROR_MAG[i] to the byte at
663 * offset BAD_LOC[i]. Also add the value of the computed
664 * error polynomial to the syndrome values. If the correction
665 * was successful, the resulting check bytes should be zero
666 * (i.e., the corrected data is a valid code word).
667 */
668 c0 = s[0];
669 c1 = s[1];
670 c2 = s[2];
671 for (i = 0; i < nbad; ++i) {
672 e = error_mag[i];
673 if (e) {
674 /* correct the byte at offset L by magnitude E: */
675 l = bad_loc[i];
676 dp = &data[l * FT_SECTOR_SIZE];
677 *dp = gfadd(*dp, e);
678 *correction_map |= 1 << l;
679 ++ncorrected;
680
681 log_error_mag = gflog[e];
682 c0 = gfadd(c0, gfpow[mod255(log_error_mag - l)]);
683 c1 = gfadd(c1, e);
684 c2 = gfadd(c2, gfpow[mod255(log_error_mag + l)]);
685 }
686 }
687 if (c0 || c1 || c2) {
688 TRACE_ABORT(-1, ft_t_err,
689 "ECC self-check failed, too many errors");
690 }
691 TRACE_EXIT ncorrected;
692}
693
694
695#if defined(ECC_SANITY_CHECK) || defined(ECC_PARANOID)
696
697/* Perform a sanity check on the computed parity bytes:
698 */
699static int sanity_check(unsigned long *data, int nblocks)
700{
701 TRACE_FUN(ft_t_any);
702 unsigned long s[3];
703
704 if (!compute_syndromes(data, nblocks, s)) {
705 TRACE_ABORT(0, ft_bug,
706 "Internal Error: syndrome self-check failed");
707 }
708 TRACE_EXIT 1;
709}
710
711#endif /* defined(ECC_SANITY_CHECK) || defined(ECC_PARANOID) */
712
713/* Compute the parity for an entire segment of data.
714 */
715int ftape_ecc_set_segment_parity(struct memory_segment *mseg)
716{
717 int i;
718 __u8 *parity_bytes;
719
720 parity_bytes = &mseg->data[(mseg->blocks - 3) * FT_SECTOR_SIZE];
721 for (i = 0; i < FT_SECTOR_SIZE; i += sizeof(long)) {
722 set_parity((unsigned long *) &mseg->data[i], mseg->blocks - 3,
723 (unsigned long *) &parity_bytes[i],
724 FT_SECTOR_SIZE / sizeof(long));
725#ifdef ECC_PARANOID
726 if (!sanity_check((unsigned long *) &mseg->data[i],
727 mseg->blocks)) {
728 return -1;
729 }
730#endif /* ECC_PARANOID */
731 }
732 return 0;
733}
734
735
736/* Checks and corrects (if possible) the segment MSEG. Returns one of
737 * ECC_OK, ECC_CORRECTED, and ECC_FAILED.
738 */
739int ftape_ecc_correct_data(struct memory_segment *mseg)
740{
741 int col, i, result;
742 int ncorrected = 0;
743 int nerasures = 0; /* # of erasures (CRC errors) */
744 int erasure_loc[3]; /* erasure locations */
745 unsigned long ss[3];
746 __u8 s[3];
747 Matrix Ainv;
748 TRACE_FUN(ft_t_flow);
749
750 mseg->corrected = 0;
751
752 /* find first column that has non-zero syndromes: */
753 for (col = 0; col < FT_SECTOR_SIZE; col += sizeof(long)) {
754 if (!compute_syndromes((unsigned long *) &mseg->data[col],
755 mseg->blocks, ss)) {
756 /* something is wrong---have to fix things */
757 break;
758 }
759 }
760 if (col >= FT_SECTOR_SIZE) {
761 /* all syndromes are ok, therefore nothing to correct */
762 TRACE_EXIT ECC_OK;
763 }
764 /* count the number of CRC errors if there were any: */
765 if (mseg->read_bad) {
766 for (i = 0; i < mseg->blocks; i++) {
767 if (BAD_CHECK(mseg->read_bad, i)) {
768 if (nerasures >= 3) {
769 /* this is too much for ECC */
770 TRACE_ABORT(ECC_FAILED, ft_t_err,
771 "ECC failed (>3 CRC errors)");
772 } /* if */
773 erasure_loc[nerasures++] = i;
774 }
775 }
776 }
777 /*
778 * If there are at least 2 CRC errors, determine inverse of matrix
779 * of linear system to be solved:
780 */
781 switch (nerasures) {
782 case 2:
783 if (!gfinv2(erasure_loc[0], erasure_loc[1], Ainv)) {
784 TRACE_EXIT ECC_FAILED;
785 }
786 break;
787 case 3:
788 if (!gfinv3(erasure_loc[0], erasure_loc[1],
789 erasure_loc[2], Ainv)) {
790 TRACE_EXIT ECC_FAILED;
791 }
792 break;
793 default:
794 /* this is not an error condition... */
795 break;
796 }
797
798 do {
799 for (i = 0; i < sizeof(long); ++i) {
800 s[0] = ss[0];
801 s[1] = ss[1];
802 s[2] = ss[2];
803 if (s[0] | s[1] | s[2]) {
804#ifdef BIG_ENDIAN
805 result = correct_block(
806 &mseg->data[col + sizeof(long) - 1 - i],
807 mseg->blocks,
808 nerasures,
809 erasure_loc,
810 Ainv,
811 s,
812 &mseg->corrected);
813#else
814 result = correct_block(&mseg->data[col + i],
815 mseg->blocks,
816 nerasures,
817 erasure_loc,
818 Ainv,
819 s,
820 &mseg->corrected);
821#endif
822 if (result < 0) {
823 TRACE_EXIT ECC_FAILED;
824 }
825 ncorrected += result;
826 }
827 ss[0] >>= 8;
828 ss[1] >>= 8;
829 ss[2] >>= 8;
830 }
831
832#ifdef ECC_SANITY_CHECK
833 if (!sanity_check((unsigned long *) &mseg->data[col],
834 mseg->blocks)) {
835 TRACE_EXIT ECC_FAILED;
836 }
837#endif /* ECC_SANITY_CHECK */
838
839 /* find next column with non-zero syndromes: */
840 while ((col += sizeof(long)) < FT_SECTOR_SIZE) {
841 if (!compute_syndromes((unsigned long *)
842 &mseg->data[col], mseg->blocks, ss)) {
843 /* something is wrong---have to fix things */
844 break;
845 }
846 }
847 } while (col < FT_SECTOR_SIZE);
848 if (ncorrected && nerasures == 0) {
849 TRACE(ft_t_warn, "block contained error not caught by CRC");
850 }
851 TRACE((ncorrected > 0) ? ft_t_noise : ft_t_any, "number of corrections: %d", ncorrected);
852 TRACE_EXIT ncorrected ? ECC_CORRECTED : ECC_OK;
853}
diff --git a/drivers/char/ftape/lowlevel/ftape-ecc.h b/drivers/char/ftape/lowlevel/ftape-ecc.h
deleted file mode 100644
index 4829146fe9a0..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-ecc.h
+++ /dev/null
@@ -1,84 +0,0 @@
1#ifndef _FTAPE_ECC_H_
2#define _FTAPE_ECC_H_
3
4/*
5 * Copyright (C) 1993 Ning and David Mosberger.
6 * Original:
7 * Copyright (C) 1993 Bas Laarhoven.
8 * Copyright (C) 1992 David L. Brown, Jr.
9
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
14
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; see the file COPYING. If not, write to
22 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
23 USA.
24
25 *
26 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-ecc.h,v $
27 * $Revision: 1.2 $
28 * $Date: 1997/10/05 19:18:11 $
29 *
30 * This file contains the definitions for the
31 * Reed-Solomon error correction code
32 * for the QIC-40/80 tape streamer device driver.
33 */
34
35#include "../lowlevel/ftape-bsm.h"
36
37#define BAD_CLEAR(entry) ((entry)=0)
38#define BAD_SET(entry,sector) ((entry)|=(1<<(sector)))
39#define BAD_CHECK(entry,sector) ((entry)&(1<<(sector)))
40
41/*
42 * Return values for ecc_correct_data:
43 */
44enum {
45 ECC_OK, /* Data was correct. */
46 ECC_CORRECTED, /* Correctable error in data. */
47 ECC_FAILED, /* Could not correct data. */
48};
49
50/*
51 * Representation of an in memory segment. MARKED_BAD lists the
52 * sectors that were marked bad during formatting. If the N-th sector
53 * in a segment is marked bad, bit 1<<N will be set in MARKED_BAD.
54 * The sectors should be read in from the disk and packed, as if the
55 * bad sectors were not there, and the segment just contained fewer
56 * sectors. READ_SECTORS is a bitmap of errors encountered while
57 * reading the data. These offsets are relative to the packed data.
58 * BLOCKS is a count of the sectors not marked bad. This is just to
59 * prevent having to count the zero bits in MARKED_BAD each time this
60 * is needed. DATA is the actual sector packed data from (or to) the
61 * tape.
62 */
63 struct memory_segment {
64 SectorMap marked_bad;
65 SectorMap read_bad;
66 int blocks;
67 __u8 *data;
68 SectorMap corrected;
69 };
70
71/*
72 * ecc.c defined global variables:
73 */
74#ifdef TEST
75extern int ftape_ecc_tracing;
76#endif
77
78/*
79 * ecc.c defined global functions:
80 */
81extern int ftape_ecc_correct_data(struct memory_segment *data);
82extern int ftape_ecc_set_segment_parity(struct memory_segment *data);
83
84#endif /* _FTAPE_ECC_H_ */
diff --git a/drivers/char/ftape/lowlevel/ftape-format.c b/drivers/char/ftape/lowlevel/ftape-format.c
deleted file mode 100644
index 5dd4c59a3f34..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-format.c
+++ /dev/null
@@ -1,344 +0,0 @@
1/*
2 * Copyright (C) 1997 Claus-Justus Heine.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 *
19 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-format.c,v $
20 * $Revision: 1.2.4.1 $
21 * $Date: 1997/11/14 16:05:39 $
22 *
23 * This file contains the code to support formatting of floppy
24 * tape cartridges with the QIC-40/80/3010/3020 floppy-tape
25 * driver "ftape" for Linux.
26 */
27
28#include <linux/string.h>
29#include <linux/errno.h>
30
31#include <linux/ftape.h>
32#include <linux/qic117.h>
33#include "../lowlevel/ftape-tracing.h"
34#include "../lowlevel/ftape-io.h"
35#include "../lowlevel/ftape-ctl.h"
36#include "../lowlevel/ftape-rw.h"
37#include "../lowlevel/ftape-ecc.h"
38#include "../lowlevel/ftape-bsm.h"
39#include "../lowlevel/ftape-format.h"
40
41#if defined(TESTING)
42#define FT_FMT_SEGS_PER_BUF 50
43#else
44#define FT_FMT_SEGS_PER_BUF (FT_BUFF_SIZE/(4*FT_SECTORS_PER_SEGMENT))
45#endif
46
47static spinlock_t ftape_format_lock;
48
49/*
50 * first segment of the new buffer
51 */
52static int switch_segment;
53
54/*
55 * at most 256 segments fit into one 32 kb buffer. Even TR-1 cartridges have
56 * more than this many segments per track, so better be careful.
57 *
58 * buffer_struct *buff: buffer to store the formatting coordinates in
59 * int start: starting segment for this buffer.
60 * int spt: segments per track
61 *
62 * Note: segment ids are relative to the start of the track here.
63 */
64static void setup_format_buffer(buffer_struct *buff, int start, int spt,
65 __u8 gap3)
66{
67 int to_do = spt - start;
68 TRACE_FUN(ft_t_flow);
69
70 if (to_do > FT_FMT_SEGS_PER_BUF) {
71 to_do = FT_FMT_SEGS_PER_BUF;
72 }
73 buff->ptr = buff->address;
74 buff->remaining = to_do * FT_SECTORS_PER_SEGMENT; /* # sectors */
75 buff->bytes = buff->remaining * 4; /* need 4 bytes per sector */
76 buff->gap3 = gap3;
77 buff->segment_id = start;
78 buff->next_segment = start + to_do;
79 if (buff->next_segment >= spt) {
80 buff->next_segment = 0; /* 0 means: stop runner */
81 }
82 buff->status = waiting; /* tells the isr that it can use
83 * this buffer
84 */
85 TRACE_EXIT;
86}
87
88
89/*
90 * start formatting a new track.
91 */
92int ftape_format_track(const unsigned int track, const __u8 gap3)
93{
94 unsigned long flags;
95 buffer_struct *tail, *head;
96 int status;
97 TRACE_FUN(ft_t_flow);
98
99 TRACE_CATCH(ftape_ready_wait(ftape_timeout.pause, &status),);
100 if (track & 1) {
101 if (!(status & QIC_STATUS_AT_EOT)) {
102 TRACE_CATCH(ftape_seek_to_eot(),);
103 }
104 } else {
105 if (!(status & QIC_STATUS_AT_BOT)) {
106 TRACE_CATCH(ftape_seek_to_bot(),);
107 }
108 }
109 ftape_abort_operation(); /* this sets ft_head = ft_tail = 0 */
110 ftape_set_state(formatting);
111
112 TRACE(ft_t_noise,
113 "Formatting track %d, logical: from segment %d to %d",
114 track, track * ft_segments_per_track,
115 (track + 1) * ft_segments_per_track - 1);
116
117 /*
118 * initialize the buffer switching protocol for this track
119 */
120 head = ftape_get_buffer(ft_queue_head); /* tape isn't running yet */
121 tail = ftape_get_buffer(ft_queue_tail); /* tape isn't running yet */
122 switch_segment = 0;
123 do {
124 FT_SIGNAL_EXIT(_DONT_BLOCK);
125 setup_format_buffer(tail, switch_segment,
126 ft_segments_per_track, gap3);
127 switch_segment = tail->next_segment;
128 } while ((switch_segment != 0) &&
129 ((tail = ftape_next_buffer(ft_queue_tail)) != head));
130 /* go */
131 head->status = formatting;
132 TRACE_CATCH(ftape_seek_head_to_track(track),);
133 TRACE_CATCH(ftape_command(QIC_LOGICAL_FORWARD),);
134 spin_lock_irqsave(&ftape_format_lock, flags);
135 TRACE_CATCH(fdc_setup_formatting(head), restore_flags(flags));
136 spin_unlock_irqrestore(&ftape_format_lock, flags);
137 TRACE_EXIT 0;
138}
139
140/* return segment id of segment currently being formatted and do the
141 * buffer switching stuff.
142 */
143int ftape_format_status(unsigned int *segment_id)
144{
145 buffer_struct *tail = ftape_get_buffer(ft_queue_tail);
146 int result;
147 TRACE_FUN(ft_t_flow);
148
149 while (switch_segment != 0 &&
150 ftape_get_buffer(ft_queue_head) != tail) {
151 FT_SIGNAL_EXIT(_DONT_BLOCK);
152 /* need more buffers, first wait for empty buffer
153 */
154 TRACE_CATCH(ftape_wait_segment(formatting),);
155 /* don't worry for gap3. If we ever hit this piece of code,
156 * then all buffer already have the correct gap3 set!
157 */
158 setup_format_buffer(tail, switch_segment,
159 ft_segments_per_track, tail->gap3);
160 switch_segment = tail->next_segment;
161 if (switch_segment != 0) {
162 tail = ftape_next_buffer(ft_queue_tail);
163 }
164 }
165 /* should runner stop ?
166 */
167 if (ft_runner_status == aborting || ft_runner_status == do_abort) {
168 buffer_struct *head = ftape_get_buffer(ft_queue_head);
169 TRACE(ft_t_warn, "Error formatting segment %d",
170 ftape_get_buffer(ft_queue_head)->segment_id);
171 (void)ftape_abort_operation();
172 TRACE_EXIT (head->status != error) ? -EAGAIN : -EIO;
173 }
174 /*
175 * don't care if the timer expires, this is just kind of a
176 * "select" operation that lets the calling process sleep
177 * until something has happened
178 */
179 if (fdc_interrupt_wait(5 * FT_SECOND) < 0) {
180 TRACE(ft_t_noise, "End of track %d at segment %d",
181 ft_location.track,
182 ftape_get_buffer(ft_queue_head)->segment_id);
183 result = 1; /* end of track, unlock module */
184 } else {
185 result = 0;
186 }
187 /*
188 * the calling process should use the seg id to determine
189 * which parts of the dma buffers can be safely overwritten
190 * with new data.
191 */
192 *segment_id = ftape_get_buffer(ft_queue_head)->segment_id;
193 /*
194 * Internally we start counting segment ids from the start of
195 * each track when formatting, but externally we keep them
196 * relative to the start of the tape:
197 */
198 *segment_id += ft_location.track * ft_segments_per_track;
199 TRACE_EXIT result;
200}
201
202/*
203 * The segment id is relative to the start of the tape
204 */
205int ftape_verify_segment(const unsigned int segment_id, SectorMap *bsm)
206{
207 int result;
208 int verify_done = 0;
209 TRACE_FUN(ft_t_flow);
210
211 TRACE(ft_t_noise, "Verifying segment %d", segment_id);
212
213 if (ft_driver_state != verifying) {
214 TRACE(ft_t_noise, "calling ftape_abort_operation");
215 if (ftape_abort_operation() < 0) {
216 TRACE(ft_t_err, "ftape_abort_operation failed");
217 TRACE_EXIT -EIO;
218 }
219 }
220 *bsm = 0x00000000;
221 ftape_set_state(verifying);
222 for (;;) {
223 buffer_struct *tail;
224 /*
225 * Allow escape from this loop on signal
226 */
227 FT_SIGNAL_EXIT(_DONT_BLOCK);
228 /*
229 * Search all full buffers for the first matching the
230 * wanted segment. Clear other buffers on the fly.
231 */
232 tail = ftape_get_buffer(ft_queue_tail);
233 while (!verify_done && tail->status == done) {
234 /*
235 * Allow escape from this loop on signal !
236 */
237 FT_SIGNAL_EXIT(_DONT_BLOCK);
238 if (tail->segment_id == segment_id) {
239 /* If out buffer is already full,
240 * return its contents.
241 */
242 TRACE(ft_t_flow, "found segment in cache: %d",
243 segment_id);
244 if ((tail->soft_error_map |
245 tail->hard_error_map) != 0) {
246 TRACE(ft_t_info,"bsm[%d] = 0x%08lx",
247 segment_id,
248 (unsigned long)
249 (tail->soft_error_map |
250 tail->hard_error_map));
251 *bsm = (tail->soft_error_map |
252 tail->hard_error_map);
253 }
254 verify_done = 1;
255 } else {
256 TRACE(ft_t_flow,"zapping segment in cache: %d",
257 tail->segment_id);
258 }
259 tail->status = waiting;
260 tail = ftape_next_buffer(ft_queue_tail);
261 }
262 if (!verify_done && tail->status == verifying) {
263 if (tail->segment_id == segment_id) {
264 switch(ftape_wait_segment(verifying)) {
265 case 0:
266 break;
267 case -EINTR:
268 TRACE_ABORT(-EINTR, ft_t_warn,
269 "interrupted by "
270 "non-blockable signal");
271 break;
272 default:
273 ftape_abort_operation();
274 ftape_set_state(verifying);
275 /* be picky */
276 TRACE_ABORT(-EIO, ft_t_warn,
277 "wait_segment failed");
278 }
279 } else {
280 /* We're reading the wrong segment,
281 * stop runner.
282 */
283 TRACE(ft_t_noise, "verifying wrong segment");
284 ftape_abort_operation();
285 ftape_set_state(verifying);
286 }
287 }
288 /* should runner stop ?
289 */
290 if (ft_runner_status == aborting) {
291 buffer_struct *head = ftape_get_buffer(ft_queue_head);
292 if (head->status == error ||
293 head->status == verifying) {
294 /* no data or overrun error */
295 head->status = waiting;
296 }
297 TRACE_CATCH(ftape_dumb_stop(),);
298 } else {
299 /* If just passed last segment on tape: wait
300 * for BOT or EOT mark. Sets ft_runner_status to
301 * idle if at lEOT and successful
302 */
303 TRACE_CATCH(ftape_handle_logical_eot(),);
304 }
305 if (verify_done) {
306 TRACE_EXIT 0;
307 }
308 /* Now at least one buffer is idle!
309 * Restart runner & tape if needed.
310 */
311 /* We could optimize the following a little bit. We know that
312 * the bad sector map is empty.
313 */
314 tail = ftape_get_buffer(ft_queue_tail);
315 if (tail->status == waiting) {
316 buffer_struct *head = ftape_get_buffer(ft_queue_head);
317
318 ftape_setup_new_segment(head, segment_id, -1);
319 ftape_calc_next_cluster(head);
320 if (ft_runner_status == idle) {
321 result = ftape_start_tape(segment_id,
322 head->sector_offset);
323 switch(result) {
324 case 0:
325 break;
326 case -ETIME:
327 case -EINTR:
328 TRACE_ABORT(result, ft_t_err, "Error: "
329 "segment %d unreachable",
330 segment_id);
331 break;
332 default:
333 *bsm = EMPTY_SEGMENT;
334 TRACE_EXIT 0;
335 break;
336 }
337 }
338 head->status = verifying;
339 fdc_setup_read_write(head, FDC_VERIFY);
340 }
341 }
342 /* not reached */
343 TRACE_EXIT -EIO;
344}
diff --git a/drivers/char/ftape/lowlevel/ftape-format.h b/drivers/char/ftape/lowlevel/ftape-format.h
deleted file mode 100644
index f15161566643..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-format.h
+++ /dev/null
@@ -1,37 +0,0 @@
1#ifndef _FTAPE_FORMAT_H
2#define _FTAPE_FORMAT_H
3
4/*
5 * Copyright (C) 1996-1997 Claus-Justus Heine.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 *
22 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-format.h,v $
23 * $Revision: 1.2 $
24 * $Date: 1997/10/05 19:18:13 $
25 *
26 * This file contains the low level definitions for the
27 * formatting support for the QIC-40/80/3010/3020 floppy-tape
28 * driver "ftape" for Linux.
29 */
30
31#ifdef __KERNEL__
32extern int ftape_format_track(const unsigned int track, const __u8 gap3);
33extern int ftape_format_status(unsigned int *segment_id);
34extern int ftape_verify_segment(const unsigned int segment_id, SectorMap *bsm);
35#endif /* __KERNEL__ */
36
37#endif
diff --git a/drivers/char/ftape/lowlevel/ftape-init.c b/drivers/char/ftape/lowlevel/ftape-init.c
deleted file mode 100644
index 4998132a81d1..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-init.c
+++ /dev/null
@@ -1,160 +0,0 @@
1/*
2 * Copyright (C) 1993-1996 Bas Laarhoven,
3 * (C) 1996-1997 Claus-Justus Heine.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
8 any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; see the file COPYING. If not, write to
17 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 *
20 * This file contains the code that interfaces the kernel
21 * for the QIC-40/80/3010/3020 floppy-tape driver for Linux.
22 */
23
24#include <linux/module.h>
25#include <linux/errno.h>
26#include <linux/fs.h>
27#include <linux/kernel.h>
28#include <linux/signal.h>
29#include <linux/major.h>
30
31#include <linux/ftape.h>
32#include <linux/init.h>
33#include <linux/qic117.h>
34#ifdef CONFIG_ZFTAPE
35#include <linux/zftape.h>
36#endif
37
38#include "../lowlevel/ftape-init.h"
39#include "../lowlevel/ftape-io.h"
40#include "../lowlevel/ftape-read.h"
41#include "../lowlevel/ftape-write.h"
42#include "../lowlevel/ftape-ctl.h"
43#include "../lowlevel/ftape-rw.h"
44#include "../lowlevel/fdc-io.h"
45#include "../lowlevel/ftape-buffer.h"
46#include "../lowlevel/ftape-proc.h"
47#include "../lowlevel/ftape-tracing.h"
48
49
50#if defined(MODULE) && !defined(CONFIG_FT_NO_TRACE_AT_ALL)
51static int ft_tracing = -1;
52#endif
53
54
55/* Called by modules package when installing the driver
56 * or by kernel during the initialization phase
57 */
58static int __init ftape_init(void)
59{
60 TRACE_FUN(ft_t_flow);
61
62#ifdef MODULE
63#ifndef CONFIG_FT_NO_TRACE_AT_ALL
64 if (ft_tracing != -1) {
65 ftape_tracing = ft_tracing;
66 }
67#endif
68 printk(KERN_INFO FTAPE_VERSION "\n");
69 if (TRACE_LEVEL >= ft_t_info) {
70 printk(
71KERN_INFO "(c) 1993-1996 Bas Laarhoven (bas@vimec.nl)\n"
72KERN_INFO "(c) 1995-1996 Kai Harrekilde-Petersen (khp@dolphinics.no)\n"
73KERN_INFO "(c) 1996-1997 Claus-Justus Heine (claus@momo.math.rwth-aachen.de)\n"
74KERN_INFO "QIC-117 driver for QIC-40/80/3010/3020 floppy tape drives\n");
75 }
76#else /* !MODULE */
77 /* print a short no-nonsense boot message */
78 printk(KERN_INFO FTAPE_VERSION "\n");
79#endif /* MODULE */
80 TRACE(ft_t_info, "installing QIC-117 floppy tape hardware drive ... ");
81 TRACE(ft_t_info, "ftape_init @ 0x%p", ftape_init);
82 /* Allocate the DMA buffers. They are deallocated at cleanup() time.
83 */
84#ifdef TESTING
85#ifdef MODULE
86 while (ftape_set_nr_buffers(CONFIG_FT_NR_BUFFERS) < 0) {
87 ftape_sleep(FT_SECOND/20);
88 if (signal_pending(current)) {
89 (void)ftape_set_nr_buffers(0);
90 TRACE(ft_t_bug,
91 "Killed by signal while allocating buffers.");
92 TRACE_ABORT(-EINTR,
93 ft_t_bug, "Free up memory and retry");
94 }
95 }
96#else
97 TRACE_CATCH(ftape_set_nr_buffers(CONFIG_FT_NR_BUFFERS),
98 (void)ftape_set_nr_buffers(0));
99#endif
100#else
101 TRACE_CATCH(ftape_set_nr_buffers(CONFIG_FT_NR_BUFFERS),
102 (void)ftape_set_nr_buffers(0));
103#endif
104 ft_drive_sel = -1;
105 ft_failure = 1; /* inhibit any operation but open */
106 ftape_udelay_calibrate(); /* must be before fdc_wait_calibrate ! */
107 fdc_wait_calibrate();
108#if defined(CONFIG_PROC_FS) && defined(CONFIG_FT_PROC_FS)
109 (void)ftape_proc_init();
110#endif
111#ifdef CONFIG_ZFTAPE
112 (void)zft_init();
113#endif
114 TRACE_EXIT 0;
115}
116
117module_param(ft_fdc_base, uint, 0);
118MODULE_PARM_DESC(ft_fdc_base, "Base address of FDC controller.");
119module_param(ft_fdc_irq, uint, 0);
120MODULE_PARM_DESC(ft_fdc_irq, "IRQ (interrupt channel) to use.");
121module_param(ft_fdc_dma, uint, 0);
122MODULE_PARM_DESC(ft_fdc_dma, "DMA channel to use.");
123module_param(ft_fdc_threshold, uint, 0);
124MODULE_PARM_DESC(ft_fdc_threshold, "Threshold of the FDC Fifo.");
125module_param(ft_fdc_rate_limit, uint, 0);
126MODULE_PARM_DESC(ft_fdc_rate_limit, "Maximal data rate for FDC.");
127module_param(ft_probe_fc10, bool, 0);
128MODULE_PARM_DESC(ft_probe_fc10,
129 "If non-zero, probe for a Colorado FC-10/FC-20 controller.");
130module_param(ft_mach2, bool, 0);
131MODULE_PARM_DESC(ft_mach2,
132 "If non-zero, probe for a Mountain MACH-2 controller.");
133#if defined(MODULE) && !defined(CONFIG_FT_NO_TRACE_AT_ALL)
134module_param(ft_tracing, int, 0644);
135MODULE_PARM_DESC(ft_tracing,
136 "Amount of debugging output, 0 <= tracing <= 8, default 3.");
137#endif
138
139MODULE_AUTHOR(
140 "(c) 1993-1996 Bas Laarhoven (bas@vimec.nl), "
141 "(c) 1995-1996 Kai Harrekilde-Petersen (khp@dolphinics.no), "
142 "(c) 1996, 1997 Claus-Justus Heine (claus@momo.math.rwth-aachen.de)");
143MODULE_DESCRIPTION(
144 "QIC-117 driver for QIC-40/80/3010/3020 floppy tape drives.");
145MODULE_LICENSE("GPL");
146
147static void __exit ftape_exit(void)
148{
149 TRACE_FUN(ft_t_flow);
150
151#if defined(CONFIG_PROC_FS) && defined(CONFIG_FT_PROC_FS)
152 ftape_proc_destroy();
153#endif
154 (void)ftape_set_nr_buffers(0);
155 printk(KERN_INFO "ftape: unloaded.\n");
156 TRACE_EXIT;
157}
158
159module_init(ftape_init);
160module_exit(ftape_exit);
diff --git a/drivers/char/ftape/lowlevel/ftape-init.h b/drivers/char/ftape/lowlevel/ftape-init.h
deleted file mode 100644
index 99a7b8ab086f..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-init.h
+++ /dev/null
@@ -1,43 +0,0 @@
1#ifndef _FTAPE_INIT_H
2#define _FTAPE_INIT_H
3
4/*
5 * Copyright (C) 1993-1996 Bas Laarhoven,
6 * (C) 1996-1997 Claus-Justus Heine.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; see the file COPYING. If not, write to
20 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21
22 *
23 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-init.h,v $
24 * $Revision: 1.2 $
25 * $Date: 1997/10/05 19:18:16 $
26 *
27 * This file contains the definitions for the interface to
28 * the Linux kernel for floppy tape driver ftape.
29 *
30 */
31
32#include <linux/linkage.h>
33#include <linux/signal.h>
34
35#define _NEVER_BLOCK (sigmask(SIGKILL) | sigmask(SIGSTOP))
36#define _DONT_BLOCK (_NEVER_BLOCK | sigmask(SIGINT))
37#define _DO_BLOCK (sigmask(SIGPIPE))
38
39#ifndef QIC117_TAPE_MAJOR
40#define QIC117_TAPE_MAJOR 27
41#endif
42
43#endif
diff --git a/drivers/char/ftape/lowlevel/ftape-io.c b/drivers/char/ftape/lowlevel/ftape-io.c
deleted file mode 100644
index 259015aeff55..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-io.c
+++ /dev/null
@@ -1,992 +0,0 @@
1/*
2 * Copyright (C) 1993-1996 Bas Laarhoven,
3 * (C) 1996 Kai Harrekilde-Petersen,
4 * (C) 1997 Claus-Justus Heine.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
19
20 *
21 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-io.c,v $
22 * $Revision: 1.4 $
23 * $Date: 1997/11/11 14:02:36 $
24 *
25 * This file contains the general control functions for the
26 * QIC-40/80/3010/3020 floppy-tape driver "ftape" for Linux.
27 */
28
29#include <linux/errno.h>
30#include <linux/sched.h>
31#include <linux/mm.h>
32#include <asm/system.h>
33#include <linux/ioctl.h>
34#include <linux/mtio.h>
35#include <linux/delay.h>
36
37#include <linux/ftape.h>
38#include <linux/qic117.h>
39#include "../lowlevel/ftape-tracing.h"
40#include "../lowlevel/fdc-io.h"
41#include "../lowlevel/ftape-io.h"
42#include "../lowlevel/ftape-ctl.h"
43#include "../lowlevel/ftape-rw.h"
44#include "../lowlevel/ftape-write.h"
45#include "../lowlevel/ftape-read.h"
46#include "../lowlevel/ftape-init.h"
47#include "../lowlevel/ftape-calibr.h"
48
49/* Global vars.
50 */
51/* NOTE: sectors start numbering at 1, all others at 0 ! */
52ft_timeout_table ftape_timeout;
53unsigned int ftape_tape_len;
54volatile qic117_cmd_t ftape_current_command;
55const struct qic117_command_table qic117_cmds[] = QIC117_COMMANDS;
56int ftape_might_be_off_track;
57
58/* Local vars.
59 */
60static int diagnostic_mode;
61static unsigned int ftape_udelay_count;
62static unsigned int ftape_udelay_time;
63
64void ftape_udelay(unsigned int usecs)
65{
66 volatile int count = (ftape_udelay_count * usecs +
67 ftape_udelay_count - 1) / ftape_udelay_time;
68 volatile int i;
69
70 while (count-- > 0) {
71 for (i = 0; i < 20; ++i);
72 }
73}
74
75void ftape_udelay_calibrate(void)
76{
77 ftape_calibrate("ftape_udelay",
78 ftape_udelay, &ftape_udelay_count, &ftape_udelay_time);
79}
80
81/* Delay (msec) routine.
82 */
83void ftape_sleep(unsigned int time)
84{
85 TRACE_FUN(ft_t_any);
86
87 time *= 1000; /* msecs -> usecs */
88 if (time < FT_USPT) {
89 /* Time too small for scheduler, do a busy wait ! */
90 ftape_udelay(time);
91 } else {
92 long timeout;
93 unsigned long flags;
94 unsigned int ticks = (time + FT_USPT - 1) / FT_USPT;
95
96 TRACE(ft_t_any, "%d msec, %d ticks", time/1000, ticks);
97 timeout = ticks;
98 save_flags(flags);
99 sti();
100 msleep_interruptible(jiffies_to_msecs(timeout));
101 /* Mmm. Isn't current->blocked == 0xffffffff ?
102 */
103 if (signal_pending(current)) {
104 TRACE(ft_t_err, "awoken by non-blocked signal :-(");
105 }
106 restore_flags(flags);
107 }
108 TRACE_EXIT;
109}
110
111/* send a command or parameter to the drive
112 * Generates # of step pulses.
113 */
114static inline int ft_send_to_drive(int arg)
115{
116 /* Always wait for a command_timeout period to separate
117 * individuals commands and/or parameters.
118 */
119 ftape_sleep(3 * FT_MILLISECOND);
120 /* Keep cylinder nr within range, step towards home if possible.
121 */
122 if (ftape_current_cylinder >= arg) {
123 return fdc_seek(ftape_current_cylinder - arg);
124 } else {
125 return fdc_seek(ftape_current_cylinder + arg);
126 }
127}
128
129/* forward */ int ftape_report_raw_drive_status(int *status);
130
131static int ft_check_cmd_restrictions(qic117_cmd_t command)
132{
133 int status = -1;
134 TRACE_FUN(ft_t_any);
135
136 TRACE(ft_t_flow, "%s", qic117_cmds[command].name);
137 /* A new motion command during an uninterruptible (motion)
138 * command requires a ready status before the new command can
139 * be issued. Otherwise a new motion command needs to be
140 * checked against required status.
141 */
142 if (qic117_cmds[command].cmd_type == motion &&
143 qic117_cmds[ftape_current_command].non_intr) {
144 ftape_report_raw_drive_status(&status);
145 if ((status & QIC_STATUS_READY) == 0) {
146 TRACE(ft_t_noise,
147 "motion cmd (%d) during non-intr cmd (%d)",
148 command, ftape_current_command);
149 TRACE(ft_t_noise, "waiting until drive gets ready");
150 ftape_ready_wait(ftape_timeout.seek,
151 &status);
152 }
153 }
154 if (qic117_cmds[command].mask != 0) {
155 __u8 difference;
156 /* Some commands do require a certain status:
157 */
158 if (status == -1) { /* not yet set */
159 ftape_report_raw_drive_status(&status);
160 }
161 difference = ((status ^ qic117_cmds[command].state) &
162 qic117_cmds[command].mask);
163 /* Wait until the drive gets
164 * ready. This may last forever if
165 * the drive never gets ready...
166 */
167 while ((difference & QIC_STATUS_READY) != 0) {
168 TRACE(ft_t_noise, "command %d issued while not ready",
169 command);
170 TRACE(ft_t_noise, "waiting until drive gets ready");
171 if (ftape_ready_wait(ftape_timeout.seek,
172 &status) == -EINTR) {
173 /* Bail out on signal !
174 */
175 TRACE_ABORT(-EINTR, ft_t_warn,
176 "interrupted by non-blockable signal");
177 }
178 difference = ((status ^ qic117_cmds[command].state) &
179 qic117_cmds[command].mask);
180 }
181 while ((difference & QIC_STATUS_ERROR) != 0) {
182 int err;
183 qic117_cmd_t cmd;
184
185 TRACE(ft_t_noise,
186 "command %d issued while error pending",
187 command);
188 TRACE(ft_t_noise, "clearing error status");
189 ftape_report_error(&err, &cmd, 1);
190 ftape_report_raw_drive_status(&status);
191 difference = ((status ^ qic117_cmds[command].state) &
192 qic117_cmds[command].mask);
193 if ((difference & QIC_STATUS_ERROR) != 0) {
194 /* Bail out on fatal signal !
195 */
196 FT_SIGNAL_EXIT(_NEVER_BLOCK);
197 }
198 }
199 if (difference) {
200 /* Any remaining difference can't be solved
201 * here.
202 */
203 if (difference & (QIC_STATUS_CARTRIDGE_PRESENT |
204 QIC_STATUS_NEW_CARTRIDGE |
205 QIC_STATUS_REFERENCED)) {
206 TRACE(ft_t_warn,
207 "Fatal: tape removed or reinserted !");
208 ft_failure = 1;
209 } else {
210 TRACE(ft_t_err, "wrong state: 0x%02x should be: 0x%02x",
211 status & qic117_cmds[command].mask,
212 qic117_cmds[command].state);
213 }
214 TRACE_EXIT -EIO;
215 }
216 if (~status & QIC_STATUS_READY & qic117_cmds[command].mask) {
217 TRACE_ABORT(-EBUSY, ft_t_err, "Bad: still busy!");
218 }
219 }
220 TRACE_EXIT 0;
221}
222
223/* Issue a tape command:
224 */
225int ftape_command(qic117_cmd_t command)
226{
227 int result = 0;
228 static int level;
229 TRACE_FUN(ft_t_any);
230
231 if ((unsigned int)command > NR_ITEMS(qic117_cmds)) {
232 /* This is a bug we'll want to know about too.
233 */
234 TRACE_ABORT(-EIO, ft_t_bug, "bug - bad command: %d", command);
235 }
236 if (++level > 5) { /* This is a bug we'll want to know about. */
237 --level;
238 TRACE_ABORT(-EIO, ft_t_bug, "bug - recursion for command: %d",
239 command);
240 }
241 /* disable logging and restriction check for some commands,
242 * check all other commands that have a prescribed starting
243 * status.
244 */
245 if (diagnostic_mode) {
246 TRACE(ft_t_flow, "diagnostic command %d", command);
247 } else if (command == QIC_REPORT_DRIVE_STATUS ||
248 command == QIC_REPORT_NEXT_BIT) {
249 TRACE(ft_t_any, "%s", qic117_cmds[command].name);
250 } else {
251 TRACE_CATCH(ft_check_cmd_restrictions(command), --level);
252 }
253 /* Now all conditions are met or result was < 0.
254 */
255 result = ft_send_to_drive((unsigned int)command);
256 if (qic117_cmds[command].cmd_type == motion &&
257 command != QIC_LOGICAL_FORWARD && command != QIC_STOP_TAPE) {
258 ft_location.known = 0;
259 }
260 ftape_current_command = command;
261 --level;
262 TRACE_EXIT result;
263}
264
265/* Send a tape command parameter:
266 * Generates command # of step pulses.
267 * Skips tape-status call !
268 */
269int ftape_parameter(unsigned int parameter)
270{
271 TRACE_FUN(ft_t_any);
272
273 TRACE(ft_t_flow, "called with parameter = %d", parameter);
274 TRACE_EXIT ft_send_to_drive(parameter + 2);
275}
276
277/* Wait for the drive to get ready.
278 * timeout time in milli-seconds
279 * Returned status is valid if result != -EIO
280 *
281 * Should we allow to be killed by SIGINT? (^C)
282 * Would be nice at least for large timeouts.
283 */
284int ftape_ready_wait(unsigned int timeout, int *status)
285{
286 unsigned long t0;
287 unsigned int poll_delay;
288 int signal_retries;
289 TRACE_FUN(ft_t_any);
290
291 /* the following ** REALLY ** reduces the system load when
292 * e.g. one simply rewinds or retensions. The tape is slow
293 * anyway. It is really not necessary to detect error
294 * conditions with 1/10 seconds granularity
295 *
296 * On my AMD 133MHZ 486: 100 ms: 23% system load
297 * 1 sec: 5%
298 * 5 sec: 0.6%, yeah
299 */
300 if (timeout <= FT_SECOND) {
301 poll_delay = 100 * FT_MILLISECOND;
302 signal_retries = 20; /* two seconds */
303 } else if (timeout < 20 * FT_SECOND) {
304 TRACE(ft_t_flow, "setting poll delay to 1 second");
305 poll_delay = FT_SECOND;
306 signal_retries = 2; /* two seconds */
307 } else {
308 TRACE(ft_t_flow, "setting poll delay to 5 seconds");
309 poll_delay = 5 * FT_SECOND;
310 signal_retries = 1; /* five seconds */
311 }
312 for (;;) {
313 t0 = jiffies;
314 TRACE_CATCH(ftape_report_raw_drive_status(status),);
315 if (*status & QIC_STATUS_READY) {
316 TRACE_EXIT 0;
317 }
318 if (!signal_retries--) {
319 FT_SIGNAL_EXIT(_NEVER_BLOCK);
320 }
321 if ((int)timeout >= 0) {
322 /* this will fail when jiffies wraps around about
323 * once every year :-)
324 */
325 timeout -= ((jiffies - t0) * FT_SECOND) / HZ;
326 if (timeout <= 0) {
327 TRACE_ABORT(-ETIME, ft_t_err, "timeout");
328 }
329 ftape_sleep(poll_delay);
330 timeout -= poll_delay;
331 } else {
332 ftape_sleep(poll_delay);
333 }
334 }
335 TRACE_EXIT -ETIME;
336}
337
338/* Issue command and wait up to timeout milli seconds for drive ready
339 */
340int ftape_command_wait(qic117_cmd_t command, unsigned int timeout, int *status)
341{
342 int result;
343
344 /* Drive should be ready, issue command
345 */
346 result = ftape_command(command);
347 if (result >= 0) {
348 result = ftape_ready_wait(timeout, status);
349 }
350 return result;
351}
352
353static int ftape_parameter_wait(unsigned int parm, unsigned int timeout, int *status)
354{
355 int result;
356
357 /* Drive should be ready, issue command
358 */
359 result = ftape_parameter(parm);
360 if (result >= 0) {
361 result = ftape_ready_wait(timeout, status);
362 }
363 return result;
364}
365
366/*--------------------------------------------------------------------------
367 * Report operations
368 */
369
370/* Query the drive about its status. The command is sent and
371 result_length bits of status are returned (2 extra bits are read
372 for start and stop). */
373
374int ftape_report_operation(int *status,
375 qic117_cmd_t command,
376 int result_length)
377{
378 int i, st3;
379 unsigned int t0;
380 unsigned int dt;
381 TRACE_FUN(ft_t_any);
382
383 TRACE_CATCH(ftape_command(command),);
384 t0 = ftape_timestamp();
385 i = 0;
386 do {
387 ++i;
388 ftape_sleep(3 * FT_MILLISECOND); /* see remark below */
389 TRACE_CATCH(fdc_sense_drive_status(&st3),);
390 dt = ftape_timediff(t0, ftape_timestamp());
391 /* Ack should be asserted within Ttimout + Tack = 6 msec.
392 * Looks like some drives fail to do this so extend this
393 * period to 300 msec.
394 */
395 } while (!(st3 & ST3_TRACK_0) && dt < 300000);
396 if (!(st3 & ST3_TRACK_0)) {
397 TRACE(ft_t_err,
398 "No acknowledge after %u msec. (%i iter)", dt / 1000, i);
399 TRACE_ABORT(-EIO, ft_t_err, "timeout on Acknowledge");
400 }
401 /* dt may be larger than expected because of other tasks
402 * scheduled while we were sleeping.
403 */
404 if (i > 1 && dt > 6000) {
405 TRACE(ft_t_err, "Acknowledge after %u msec. (%i iter)",
406 dt / 1000, i);
407 }
408 *status = 0;
409 for (i = 0; i < result_length + 1; i++) {
410 TRACE_CATCH(ftape_command(QIC_REPORT_NEXT_BIT),);
411 TRACE_CATCH(fdc_sense_drive_status(&st3),);
412 if (i < result_length) {
413 *status |= ((st3 & ST3_TRACK_0) ? 1 : 0) << i;
414 } else if ((st3 & ST3_TRACK_0) == 0) {
415 TRACE_ABORT(-EIO, ft_t_err, "missing status stop bit");
416 }
417 }
418 /* this command will put track zero and index back into normal state */
419 (void)ftape_command(QIC_REPORT_NEXT_BIT);
420 TRACE_EXIT 0;
421}
422
423/* Report the current drive status. */
424
425int ftape_report_raw_drive_status(int *status)
426{
427 int result;
428 int count = 0;
429 TRACE_FUN(ft_t_any);
430
431 do {
432 result = ftape_report_operation(status,
433 QIC_REPORT_DRIVE_STATUS, 8);
434 } while (result < 0 && ++count <= 3);
435 if (result < 0) {
436 TRACE_ABORT(-EIO, ft_t_err,
437 "report_operation failed after %d trials", count);
438 }
439 if ((*status & 0xff) == 0xff) {
440 TRACE_ABORT(-EIO, ft_t_err,
441 "impossible drive status 0xff");
442 }
443 if (*status & QIC_STATUS_READY) {
444 ftape_current_command = QIC_NO_COMMAND; /* completed */
445 }
446 ft_last_status.status.drive_status = (__u8)(*status & 0xff);
447 TRACE_EXIT 0;
448}
449
450int ftape_report_drive_status(int *status)
451{
452 TRACE_FUN(ft_t_any);
453
454 TRACE_CATCH(ftape_report_raw_drive_status(status),);
455 if (*status & QIC_STATUS_NEW_CARTRIDGE ||
456 !(*status & QIC_STATUS_CARTRIDGE_PRESENT)) {
457 ft_failure = 1; /* will inhibit further operations */
458 TRACE_EXIT -EIO;
459 }
460 if (*status & QIC_STATUS_READY && *status & QIC_STATUS_ERROR) {
461 /* Let caller handle all errors */
462 TRACE_ABORT(1, ft_t_warn, "warning: error status set!");
463 }
464 TRACE_EXIT 0;
465}
466
467int ftape_report_error(unsigned int *error,
468 qic117_cmd_t *command, int report)
469{
470 static const ftape_error ftape_errors[] = QIC117_ERRORS;
471 int code;
472 TRACE_FUN(ft_t_any);
473
474 TRACE_CATCH(ftape_report_operation(&code, QIC_REPORT_ERROR_CODE, 16),);
475 *error = (unsigned int)(code & 0xff);
476 *command = (qic117_cmd_t)((code>>8)&0xff);
477 /* remember hardware status, maybe useful for status ioctls
478 */
479 ft_last_error.error.command = (__u8)*command;
480 ft_last_error.error.error = (__u8)*error;
481 if (!report) {
482 TRACE_EXIT 0;
483 }
484 if (*error == 0) {
485 TRACE_ABORT(0, ft_t_info, "No error");
486 }
487 TRACE(ft_t_info, "errorcode: %d", *error);
488 if (*error < NR_ITEMS(ftape_errors)) {
489 TRACE(ft_t_noise, "%sFatal ERROR:",
490 (ftape_errors[*error].fatal ? "" : "Non-"));
491 TRACE(ft_t_noise, "%s ...", ftape_errors[*error].message);
492 } else {
493 TRACE(ft_t_noise, "Unknown ERROR !");
494 }
495 if ((unsigned int)*command < NR_ITEMS(qic117_cmds) &&
496 qic117_cmds[*command].name != NULL) {
497 TRACE(ft_t_noise, "... caused by command \'%s\'",
498 qic117_cmds[*command].name);
499 } else {
500 TRACE(ft_t_noise, "... caused by unknown command %d",
501 *command);
502 }
503 TRACE_EXIT 0;
504}
505
506int ftape_report_configuration(qic_model *model,
507 unsigned int *rate,
508 int *qic_std,
509 int *tape_len)
510{
511 int result;
512 int config;
513 int status;
514 static const unsigned int qic_rates[ 4] = { 250, 2000, 500, 1000 };
515 TRACE_FUN(ft_t_any);
516
517 result = ftape_report_operation(&config,
518 QIC_REPORT_DRIVE_CONFIGURATION, 8);
519 if (result < 0) {
520 ft_last_status.status.drive_config = (__u8)0x00;
521 *model = prehistoric;
522 *rate = 500;
523 *qic_std = QIC_TAPE_QIC40;
524 *tape_len = 205;
525 TRACE_EXIT 0;
526 } else {
527 ft_last_status.status.drive_config = (__u8)(config & 0xff);
528 }
529 *rate = qic_rates[(config & QIC_CONFIG_RATE_MASK) >> QIC_CONFIG_RATE_SHIFT];
530 result = ftape_report_operation(&status, QIC_REPORT_TAPE_STATUS, 8);
531 if (result < 0) {
532 ft_last_status.status.tape_status = (__u8)0x00;
533 /* pre- QIC117 rev C spec. drive, QIC_CONFIG_80 bit is valid.
534 */
535 *qic_std = (config & QIC_CONFIG_80) ?
536 QIC_TAPE_QIC80 : QIC_TAPE_QIC40;
537 /* ?? how's about 425ft tapes? */
538 *tape_len = (config & QIC_CONFIG_LONG) ? 307 : 0;
539 *model = pre_qic117c;
540 result = 0;
541 } else {
542 ft_last_status.status.tape_status = (__u8)(status & 0xff);
543 *model = post_qic117b;
544 TRACE(ft_t_any, "report tape status result = %02x", status);
545 /* post- QIC117 rev C spec. drive, QIC_CONFIG_80 bit is
546 * invalid.
547 */
548 switch (status & QIC_TAPE_STD_MASK) {
549 case QIC_TAPE_QIC40:
550 case QIC_TAPE_QIC80:
551 case QIC_TAPE_QIC3020:
552 case QIC_TAPE_QIC3010:
553 *qic_std = status & QIC_TAPE_STD_MASK;
554 break;
555 default:
556 *qic_std = -1;
557 break;
558 }
559 switch (status & QIC_TAPE_LEN_MASK) {
560 case QIC_TAPE_205FT:
561 /* 205 or 425+ ft 550 Oe tape */
562 *tape_len = 0;
563 break;
564 case QIC_TAPE_307FT:
565 /* 307.5 ft 550 Oe Extended Length (XL) tape */
566 *tape_len = 307;
567 break;
568 case QIC_TAPE_VARIABLE:
569 /* Variable length 550 Oe tape */
570 *tape_len = 0;
571 break;
572 case QIC_TAPE_1100FT:
573 /* 1100 ft 550 Oe tape */
574 *tape_len = 1100;
575 break;
576 case QIC_TAPE_FLEX:
577 /* Variable length 900 Oe tape */
578 *tape_len = 0;
579 break;
580 default:
581 *tape_len = -1;
582 break;
583 }
584 if (*qic_std == -1 || *tape_len == -1) {
585 TRACE(ft_t_any,
586 "post qic-117b spec drive with unknown tape");
587 }
588 result = *tape_len == -1 ? -EIO : 0;
589 if (status & QIC_TAPE_WIDE) {
590 switch (*qic_std) {
591 case QIC_TAPE_QIC80:
592 TRACE(ft_t_info, "TR-1 tape detected");
593 break;
594 case QIC_TAPE_QIC3010:
595 TRACE(ft_t_info, "TR-2 tape detected");
596 break;
597 case QIC_TAPE_QIC3020:
598 TRACE(ft_t_info, "TR-3 tape detected");
599 break;
600 default:
601 TRACE(ft_t_warn,
602 "Unknown Travan tape type detected");
603 break;
604 }
605 }
606 }
607 TRACE_EXIT (result < 0) ? -EIO : 0;
608}
609
610static int ftape_report_rom_version(int *version)
611{
612
613 if (ftape_report_operation(version, QIC_REPORT_ROM_VERSION, 8) < 0) {
614 return -EIO;
615 } else {
616 return 0;
617 }
618}
619
620void ftape_report_vendor_id(unsigned int *id)
621{
622 int result;
623 TRACE_FUN(ft_t_any);
624
625 /* We'll try to get a vendor id from the drive. First
626 * according to the QIC-117 spec, a 16-bit id is requested.
627 * If that fails we'll try an 8-bit version, otherwise we'll
628 * try an undocumented query.
629 */
630 result = ftape_report_operation((int *) id, QIC_REPORT_VENDOR_ID, 16);
631 if (result < 0) {
632 result = ftape_report_operation((int *) id,
633 QIC_REPORT_VENDOR_ID, 8);
634 if (result < 0) {
635 /* The following is an undocumented call found
636 * in the CMS code.
637 */
638 result = ftape_report_operation((int *) id, 24, 8);
639 if (result < 0) {
640 *id = UNKNOWN_VENDOR;
641 } else {
642 TRACE(ft_t_noise, "got old 8 bit id: %04x",
643 *id);
644 *id |= 0x20000;
645 }
646 } else {
647 TRACE(ft_t_noise, "got 8 bit id: %04x", *id);
648 *id |= 0x10000;
649 }
650 } else {
651 TRACE(ft_t_noise, "got 16 bit id: %04x", *id);
652 }
653 if (*id == 0x0047) {
654 int version;
655 int sign;
656
657 if (ftape_report_rom_version(&version) < 0) {
658 TRACE(ft_t_bug, "report rom version failed");
659 TRACE_EXIT;
660 }
661 TRACE(ft_t_noise, "CMS rom version: %d", version);
662 ftape_command(QIC_ENTER_DIAGNOSTIC_1);
663 ftape_command(QIC_ENTER_DIAGNOSTIC_1);
664 diagnostic_mode = 1;
665 if (ftape_report_operation(&sign, 9, 8) < 0) {
666 unsigned int error;
667 qic117_cmd_t command;
668
669 ftape_report_error(&error, &command, 1);
670 ftape_command(QIC_ENTER_PRIMARY_MODE);
671 diagnostic_mode = 0;
672 TRACE_EXIT; /* failure ! */
673 } else {
674 TRACE(ft_t_noise, "CMS signature: %02x", sign);
675 }
676 if (sign == 0xa5) {
677 result = ftape_report_operation(&sign, 37, 8);
678 if (result < 0) {
679 if (version >= 63) {
680 *id = 0x8880;
681 TRACE(ft_t_noise,
682 "This is an Iomega drive !");
683 } else {
684 *id = 0x0047;
685 TRACE(ft_t_noise,
686 "This is a real CMS drive !");
687 }
688 } else {
689 *id = 0x0047;
690 TRACE(ft_t_noise, "CMS status: %d", sign);
691 }
692 } else {
693 *id = UNKNOWN_VENDOR;
694 }
695 ftape_command(QIC_ENTER_PRIMARY_MODE);
696 diagnostic_mode = 0;
697 }
698 TRACE_EXIT;
699}
700
701static int qic_rate_code(unsigned int rate)
702{
703 switch (rate) {
704 case 250:
705 return QIC_CONFIG_RATE_250;
706 case 500:
707 return QIC_CONFIG_RATE_500;
708 case 1000:
709 return QIC_CONFIG_RATE_1000;
710 case 2000:
711 return QIC_CONFIG_RATE_2000;
712 default:
713 return QIC_CONFIG_RATE_500;
714 }
715}
716
717static int ftape_set_rate_test(unsigned int *max_rate)
718{
719 unsigned int error;
720 qic117_cmd_t command;
721 int status;
722 int supported = 0;
723 TRACE_FUN(ft_t_any);
724
725 /* Check if the drive does support the select rate command
726 * by testing all different settings. If any one is accepted
727 * we assume the command is supported, else not.
728 */
729 for (*max_rate = 2000; *max_rate >= 250; *max_rate /= 2) {
730 if (ftape_command(QIC_SELECT_RATE) < 0) {
731 continue;
732 }
733 if (ftape_parameter_wait(qic_rate_code(*max_rate),
734 1 * FT_SECOND, &status) < 0) {
735 continue;
736 }
737 if (status & QIC_STATUS_ERROR) {
738 ftape_report_error(&error, &command, 0);
739 continue;
740 }
741 supported = 1; /* did accept a request */
742 break;
743 }
744 TRACE(ft_t_noise, "Select Rate command is%s supported",
745 supported ? "" : " not");
746 TRACE_EXIT supported;
747}
748
749int ftape_set_data_rate(unsigned int new_rate /* Kbps */, unsigned int qic_std)
750{
751 int status;
752 int result = 0;
753 unsigned int data_rate = new_rate;
754 static int supported;
755 int rate_changed = 0;
756 qic_model dummy_model;
757 unsigned int dummy_qic_std, dummy_tape_len;
758 TRACE_FUN(ft_t_any);
759
760 if (ft_drive_max_rate == 0) { /* first time */
761 supported = ftape_set_rate_test(&ft_drive_max_rate);
762 }
763 if (supported) {
764 ftape_command(QIC_SELECT_RATE);
765 result = ftape_parameter_wait(qic_rate_code(new_rate),
766 1 * FT_SECOND, &status);
767 if (result >= 0 && !(status & QIC_STATUS_ERROR)) {
768 rate_changed = 1;
769 }
770 }
771 TRACE_CATCH(result = ftape_report_configuration(&dummy_model,
772 &data_rate,
773 &dummy_qic_std,
774 &dummy_tape_len),);
775 if (data_rate != new_rate) {
776 if (!supported) {
777 TRACE(ft_t_warn, "Rate change not supported!");
778 } else if (rate_changed) {
779 TRACE(ft_t_warn, "Requested: %d, got %d",
780 new_rate, data_rate);
781 } else {
782 TRACE(ft_t_warn, "Rate change failed!");
783 }
784 result = -EINVAL;
785 }
786 /*
787 * Set data rate and write precompensation as specified:
788 *
789 * | QIC-40/80 | QIC-3010/3020
790 * rate | precomp | precomp
791 * ----------+-------------+--------------
792 * 250 Kbps. | 250 ns. | 0 ns.
793 * 500 Kbps. | 125 ns. | 0 ns.
794 * 1 Mbps. | 42 ns. | 0 ns.
795 * 2 Mbps | N/A | 0 ns.
796 */
797 if ((qic_std == QIC_TAPE_QIC40 && data_rate > 500) ||
798 (qic_std == QIC_TAPE_QIC80 && data_rate > 1000)) {
799 TRACE_ABORT(-EINVAL,
800 ft_t_warn, "Datarate too high for QIC-mode");
801 }
802 TRACE_CATCH(fdc_set_data_rate(data_rate),_res = -EINVAL);
803 ft_data_rate = data_rate;
804 if (qic_std == QIC_TAPE_QIC40 || qic_std == QIC_TAPE_QIC80) {
805 switch (data_rate) {
806 case 250:
807 fdc_set_write_precomp(250);
808 break;
809 default:
810 case 500:
811 fdc_set_write_precomp(125);
812 break;
813 case 1000:
814 fdc_set_write_precomp(42);
815 break;
816 }
817 } else {
818 fdc_set_write_precomp(0);
819 }
820 TRACE_EXIT result;
821}
822
823/* The next two functions are used to cope with excessive overrun errors
824 */
825int ftape_increase_threshold(void)
826{
827 TRACE_FUN(ft_t_flow);
828
829 if (fdc.type < i82077 || ft_fdc_threshold >= 12) {
830 TRACE_ABORT(-EIO, ft_t_err, "cannot increase fifo threshold");
831 }
832 if (fdc_fifo_threshold(++ft_fdc_threshold, NULL, NULL, NULL) < 0) {
833 TRACE(ft_t_err, "cannot increase fifo threshold");
834 ft_fdc_threshold --;
835 fdc_reset();
836 }
837 TRACE(ft_t_info, "New FIFO threshold: %d", ft_fdc_threshold);
838 TRACE_EXIT 0;
839}
840
841int ftape_half_data_rate(void)
842{
843 if (ft_data_rate < 500) {
844 return -1;
845 }
846 if (ftape_set_data_rate(ft_data_rate / 2, ft_qic_std) < 0) {
847 return -EIO;
848 }
849 ftape_calc_timeouts(ft_qic_std, ft_data_rate, ftape_tape_len);
850 return 0;
851}
852
853/* Seek the head to the specified track.
854 */
855int ftape_seek_head_to_track(unsigned int track)
856{
857 int status;
858 TRACE_FUN(ft_t_any);
859
860 ft_location.track = -1; /* remains set in case of error */
861 if (track >= ft_tracks_per_tape) {
862 TRACE_ABORT(-EINVAL, ft_t_bug, "track out of bounds");
863 }
864 TRACE(ft_t_flow, "seeking track %d", track);
865 TRACE_CATCH(ftape_command(QIC_SEEK_HEAD_TO_TRACK),);
866 TRACE_CATCH(ftape_parameter_wait(track, ftape_timeout.head_seek,
867 &status),);
868 ft_location.track = track;
869 ftape_might_be_off_track = 0;
870 TRACE_EXIT 0;
871}
872
873int ftape_wakeup_drive(wake_up_types method)
874{
875 int status;
876 int motor_on = 0;
877 TRACE_FUN(ft_t_any);
878
879 switch (method) {
880 case wake_up_colorado:
881 TRACE_CATCH(ftape_command(QIC_PHANTOM_SELECT),);
882 TRACE_CATCH(ftape_parameter(0 /* ft_drive_sel ?? */),);
883 break;
884 case wake_up_mountain:
885 TRACE_CATCH(ftape_command(QIC_SOFT_SELECT),);
886 ftape_sleep(FT_MILLISECOND); /* NEEDED */
887 TRACE_CATCH(ftape_parameter(18),);
888 break;
889 case wake_up_insight:
890 ftape_sleep(100 * FT_MILLISECOND);
891 motor_on = 1;
892 fdc_motor(motor_on); /* enable is done by motor-on */
893 case no_wake_up:
894 break;
895 default:
896 TRACE_EXIT -ENODEV; /* unknown wakeup method */
897 break;
898 }
899 /* If wakeup succeeded we shouldn't get an error here..
900 */
901 TRACE_CATCH(ftape_report_raw_drive_status(&status),
902 if (motor_on) {
903 fdc_motor(0);
904 });
905 TRACE_EXIT 0;
906}
907
908int ftape_put_drive_to_sleep(wake_up_types method)
909{
910 TRACE_FUN(ft_t_any);
911
912 switch (method) {
913 case wake_up_colorado:
914 TRACE_CATCH(ftape_command(QIC_PHANTOM_DESELECT),);
915 break;
916 case wake_up_mountain:
917 TRACE_CATCH(ftape_command(QIC_SOFT_DESELECT),);
918 break;
919 case wake_up_insight:
920 fdc_motor(0); /* enable is done by motor-on */
921 case no_wake_up: /* no wakeup / no sleep ! */
922 break;
923 default:
924 TRACE_EXIT -ENODEV; /* unknown wakeup method */
925 }
926 TRACE_EXIT 0;
927}
928
929int ftape_reset_drive(void)
930{
931 int result = 0;
932 int status;
933 unsigned int err_code;
934 qic117_cmd_t err_command;
935 int i;
936 TRACE_FUN(ft_t_any);
937
938 /* We want to re-establish contact with our drive. Fire a
939 * number of reset commands (single step pulses) and pray for
940 * success.
941 */
942 for (i = 0; i < 2; ++i) {
943 TRACE(ft_t_flow, "Resetting fdc");
944 fdc_reset();
945 ftape_sleep(10 * FT_MILLISECOND);
946 TRACE(ft_t_flow, "Reset command to drive");
947 result = ftape_command(QIC_RESET);
948 if (result == 0) {
949 ftape_sleep(1 * FT_SECOND); /* drive not
950 * accessible
951 * during 1 second
952 */
953 TRACE(ft_t_flow, "Re-selecting drive");
954
955 /* Strange, the QIC-117 specs don't mention
956 * this but the drive gets deselected after a
957 * soft reset ! So we need to enable it
958 * again.
959 */
960 if (ftape_wakeup_drive(ft_drive_type.wake_up) < 0) {
961 TRACE(ft_t_err, "Wakeup failed !");
962 }
963 TRACE(ft_t_flow, "Waiting until drive gets ready");
964 result= ftape_ready_wait(ftape_timeout.reset, &status);
965 if (result == 0 && (status & QIC_STATUS_ERROR)) {
966 result = ftape_report_error(&err_code,
967 &err_command, 1);
968 if (result == 0 && err_code == 27) {
969 /* Okay, drive saw reset
970 * command and responded as it
971 * should
972 */
973 break;
974 } else {
975 result = -EIO;
976 }
977 } else {
978 result = -EIO;
979 }
980 }
981 FT_SIGNAL_EXIT(_DONT_BLOCK);
982 }
983 if (result != 0) {
984 TRACE(ft_t_err, "General failure to reset tape drive");
985 } else {
986 /* Restore correct settings: keep original rate
987 */
988 ftape_set_data_rate(ft_data_rate, ft_qic_std);
989 }
990 ftape_init_drive_needed = 1;
991 TRACE_EXIT result;
992}
diff --git a/drivers/char/ftape/lowlevel/ftape-io.h b/drivers/char/ftape/lowlevel/ftape-io.h
deleted file mode 100644
index 26a7baad8717..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-io.h
+++ /dev/null
@@ -1,90 +0,0 @@
1#ifndef _FTAPE_IO_H
2#define _FTAPE_IO_H
3
4/*
5 * Copyright (C) 1993-1996 Bas Laarhoven,
6 * (C) 1997 Claus-Justus Heine.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; see the file COPYING. If not, write to
20 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21
22 *
23 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-io.h,v $
24 * $Revision: 1.2 $
25 * $Date: 1997/10/05 19:18:18 $
26 *
27 * This file contains definitions for the glue part of the
28 * QIC-40/80/3010/3020 floppy-tape driver "ftape" for Linux.
29 */
30
31#include <linux/qic117.h>
32#include <linux/ftape-vendors.h>
33
34typedef struct {
35 unsigned int seek;
36 unsigned int reset;
37 unsigned int rewind;
38 unsigned int head_seek;
39 unsigned int stop;
40 unsigned int pause;
41} ft_timeout_table;
42
43typedef enum {
44 prehistoric, pre_qic117c, post_qic117b, post_qic117d
45} qic_model;
46
47/*
48 * ftape-io.c defined global vars.
49 */
50extern ft_timeout_table ftape_timeout;
51extern unsigned int ftape_tape_len;
52extern volatile qic117_cmd_t ftape_current_command;
53extern const struct qic117_command_table qic117_cmds[];
54extern int ftape_might_be_off_track;
55
56/*
57 * ftape-io.c defined global functions.
58 */
59extern void ftape_udelay(unsigned int usecs);
60extern void ftape_udelay_calibrate(void);
61extern void ftape_sleep(unsigned int time);
62extern void ftape_report_vendor_id(unsigned int *id);
63extern int ftape_command(qic117_cmd_t command);
64extern int ftape_command_wait(qic117_cmd_t command,
65 unsigned int timeout,
66 int *status);
67extern int ftape_parameter(unsigned int parameter);
68extern int ftape_report_operation(int *status,
69 qic117_cmd_t command,
70 int result_length);
71extern int ftape_report_configuration(qic_model *model,
72 unsigned int *rate,
73 int *qic_std,
74 int *tape_len);
75extern int ftape_report_drive_status(int *status);
76extern int ftape_report_raw_drive_status(int *status);
77extern int ftape_report_status(int *status);
78extern int ftape_ready_wait(unsigned int timeout, int *status);
79extern int ftape_seek_head_to_track(unsigned int track);
80extern int ftape_set_data_rate(unsigned int new_rate, unsigned int qic_std);
81extern int ftape_report_error(unsigned int *error,
82 qic117_cmd_t *command,
83 int report);
84extern int ftape_reset_drive(void);
85extern int ftape_put_drive_to_sleep(wake_up_types method);
86extern int ftape_wakeup_drive(wake_up_types method);
87extern int ftape_increase_threshold(void);
88extern int ftape_half_data_rate(void);
89
90#endif
diff --git a/drivers/char/ftape/lowlevel/ftape-proc.c b/drivers/char/ftape/lowlevel/ftape-proc.c
deleted file mode 100644
index e805b15e0a12..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-proc.c
+++ /dev/null
@@ -1,214 +0,0 @@
1/*
2 * Copyright (C) 1997 Claus-Justus Heine
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 *
19 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-proc.c,v $
20 * $Revision: 1.11 $
21 * $Date: 1997/10/24 14:47:37 $
22 *
23 * This file contains the procfs interface for the
24 * QIC-40/80/3010/3020 floppy-tape driver "ftape" for Linux.
25
26 * Old code removed, switched to dynamic proc entry.
27 */
28
29
30#if defined(CONFIG_PROC_FS) && defined(CONFIG_FT_PROC_FS)
31
32#include <linux/proc_fs.h>
33
34#include <linux/ftape.h>
35#include <linux/init.h>
36#include <linux/qic117.h>
37
38#include "../lowlevel/ftape-io.h"
39#include "../lowlevel/ftape-ctl.h"
40#include "../lowlevel/ftape-proc.h"
41#include "../lowlevel/ftape-tracing.h"
42
43static size_t get_driver_info(char *buf)
44{
45 const char *debug_level[] = { "bugs" ,
46 "errors",
47 "warnings",
48 "informational",
49 "noisy",
50 "program flow",
51 "fdc and dma",
52 "data flow",
53 "anything" };
54
55 return sprintf(buf,
56 "version : %s\n"
57 "used data rate: %d kbit/sec\n"
58 "dma memory : %d kb\n"
59 "debug messages: %s\n",
60 FTAPE_VERSION,
61 ft_data_rate,
62 FT_BUFF_SIZE * ft_nr_buffers >> 10,
63 debug_level[TRACE_LEVEL]);
64}
65
66static size_t get_tapedrive_info(char *buf)
67{
68 return sprintf(buf,
69 "vendor id : 0x%04x\n"
70 "drive name: %s\n"
71 "wind speed: %d ips\n"
72 "wakeup : %s\n"
73 "max. rate : %d kbit/sec\n",
74 ft_drive_type.vendor_id,
75 ft_drive_type.name,
76 ft_drive_type.speed,
77 ((ft_drive_type.wake_up == no_wake_up)
78 ? "No wakeup needed" :
79 ((ft_drive_type.wake_up == wake_up_colorado)
80 ? "Colorado" :
81 ((ft_drive_type.wake_up == wake_up_mountain)
82 ? "Mountain" :
83 ((ft_drive_type.wake_up == wake_up_insight)
84 ? "Motor on" :
85 "Unknown")))),
86 ft_drive_max_rate);
87}
88
89static size_t get_cartridge_info(char *buf)
90{
91 if (ftape_init_drive_needed) {
92 return sprintf(buf, "uninitialized\n");
93 }
94 if (ft_no_tape) {
95 return sprintf(buf, "no cartridge inserted\n");
96 }
97 return sprintf(buf,
98 "segments : %5d\n"
99 "tracks : %5d\n"
100 "length : %5dft\n"
101 "formatted : %3s\n"
102 "writable : %3s\n"
103 "QIC spec. : QIC-%s\n"
104 "fmt-code : %1d\n",
105 ft_segments_per_track,
106 ft_tracks_per_tape,
107 ftape_tape_len,
108 (ft_formatted == 1) ? "yes" : "no",
109 (ft_write_protected == 1) ? "no" : "yes",
110 ((ft_qic_std == QIC_TAPE_QIC40) ? "40" :
111 ((ft_qic_std == QIC_TAPE_QIC80) ? "80" :
112 ((ft_qic_std == QIC_TAPE_QIC3010) ? "3010" :
113 ((ft_qic_std == QIC_TAPE_QIC3020) ? "3020" :
114 "???")))),
115 ft_format_code);
116}
117
118static size_t get_controller_info(char *buf)
119{
120 const char *fdc_name[] = { "no fdc",
121 "i8272",
122 "i82077",
123 "i82077AA",
124 "Colorado FC-10 or FC-20",
125 "i82078",
126 "i82078_1" };
127
128 return sprintf(buf,
129 "FDC type : %s\n"
130 "FDC base : 0x%03x\n"
131 "FDC irq : %d\n"
132 "FDC dma : %d\n"
133 "FDC thr. : %d\n"
134 "max. rate : %d kbit/sec\n",
135 ft_mach2 ? "Mountain MACH-2" : fdc_name[fdc.type],
136 fdc.sra, fdc.irq, fdc.dma,
137 ft_fdc_threshold, ft_fdc_max_rate);
138}
139
140static size_t get_history_info(char *buf)
141{
142 size_t len;
143
144 len = sprintf(buf,
145 "\nFDC isr statistics\n"
146 " id_am_errors : %3d\n"
147 " id_crc_errors : %3d\n"
148 " data_am_errors : %3d\n"
149 " data_crc_errors : %3d\n"
150 " overrun_errors : %3d\n"
151 " no_data_errors : %3d\n"
152 " retries : %3d\n",
153 ft_history.id_am_errors, ft_history.id_crc_errors,
154 ft_history.data_am_errors, ft_history.data_crc_errors,
155 ft_history.overrun_errors, ft_history.no_data_errors,
156 ft_history.retries);
157 len += sprintf(buf + len,
158 "\nECC statistics\n"
159 " crc_errors : %3d\n"
160 " crc_failures : %3d\n"
161 " ecc_failures : %3d\n"
162 " sectors corrected: %3d\n",
163 ft_history.crc_errors, ft_history.crc_failures,
164 ft_history.ecc_failures, ft_history.corrected);
165 len += sprintf(buf + len,
166 "\ntape quality statistics\n"
167 " media defects : %3d\n",
168 ft_history.defects);
169 len += sprintf(buf + len,
170 "\ntape motion statistics\n"
171 " repositions : %3d\n",
172 ft_history.rewinds);
173 return len;
174}
175
176static int ftape_read_proc(char *page, char **start, off_t off,
177 int count, int *eof, void *data)
178{
179 char *ptr = page;
180 size_t len;
181
182 ptr += sprintf(ptr, "Kernel Driver\n\n");
183 ptr += get_driver_info(ptr);
184 ptr += sprintf(ptr, "\nTape Drive\n\n");
185 ptr += get_tapedrive_info(ptr);
186 ptr += sprintf(ptr, "\nFDC Controller\n\n");
187 ptr += get_controller_info(ptr);
188 ptr += sprintf(ptr, "\nTape Cartridge\n\n");
189 ptr += get_cartridge_info(ptr);
190 ptr += sprintf(ptr, "\nHistory Record\n\n");
191 ptr += get_history_info(ptr);
192
193 len = strlen(page);
194 *start = NULL;
195 if (off+count >= len) {
196 *eof = 1;
197 } else {
198 *eof = 0;
199 }
200 return len;
201}
202
203int __init ftape_proc_init(void)
204{
205 return create_proc_read_entry("ftape", 0, &proc_root,
206 ftape_read_proc, NULL) != NULL;
207}
208
209void ftape_proc_destroy(void)
210{
211 remove_proc_entry("ftape", &proc_root);
212}
213
214#endif /* defined(CONFIG_PROC_FS) && defined(CONFIG_FT_PROC_FS) */
diff --git a/drivers/char/ftape/lowlevel/ftape-proc.h b/drivers/char/ftape/lowlevel/ftape-proc.h
deleted file mode 100644
index 264dfcc1d22d..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-proc.h
+++ /dev/null
@@ -1,35 +0,0 @@
1#ifndef _FTAPE_PROC_H
2#define _FTAPE_PROC_H
3
4/*
5 * Copyright (C) 1997 Claus-Justus Heine
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 *
22 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-proc.h,v $
23 * $Revision: 1.2 $
24 * $Date: 1997/10/05 19:18:20 $
25 *
26 * This file contains definitions for the procfs interface of the
27 * QIC-40/80/3010/3020 floppy-tape driver "ftape" for Linux.
28 */
29
30#include <linux/proc_fs.h>
31
32extern int ftape_proc_init(void);
33extern void ftape_proc_destroy(void);
34
35#endif
diff --git a/drivers/char/ftape/lowlevel/ftape-read.c b/drivers/char/ftape/lowlevel/ftape-read.c
deleted file mode 100644
index d967d8cd86dc..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-read.c
+++ /dev/null
@@ -1,621 +0,0 @@
1/*
2 * Copyright (C) 1993-1996 Bas Laarhoven,
3 * (C) 1996-1997 Claus-Justus Heine.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
8 any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; see the file COPYING. If not, write to
17 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 *
20 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-read.c,v $
21 * $Revision: 1.6 $
22 * $Date: 1997/10/21 14:39:22 $
23 *
24 * This file contains the reading code
25 * for the QIC-117 floppy-tape driver for Linux.
26 *
27 */
28
29#include <linux/string.h>
30#include <linux/errno.h>
31#include <linux/mm.h>
32
33#include <linux/ftape.h>
34#include <linux/qic117.h>
35#include "../lowlevel/ftape-tracing.h"
36#include "../lowlevel/ftape-read.h"
37#include "../lowlevel/ftape-io.h"
38#include "../lowlevel/ftape-ctl.h"
39#include "../lowlevel/ftape-rw.h"
40#include "../lowlevel/ftape-write.h"
41#include "../lowlevel/ftape-ecc.h"
42#include "../lowlevel/ftape-bsm.h"
43
44/* Global vars.
45 */
46
47/* Local vars.
48 */
49
50void ftape_zap_read_buffers(void)
51{
52 int i;
53
54 for (i = 0; i < ft_nr_buffers; ++i) {
55/* changed to "fit" with dynamic allocation of tape_buffer. --khp */
56 ft_buffer[i]->status = waiting;
57 ft_buffer[i]->bytes = 0;
58 ft_buffer[i]->skip = 0;
59 ft_buffer[i]->retry = 0;
60 }
61/* ftape_reset_buffer(); */
62}
63
64static SectorMap convert_sector_map(buffer_struct * buff)
65{
66 int i = 0;
67 SectorMap bad_map = ftape_get_bad_sector_entry(buff->segment_id);
68 SectorMap src_map = buff->soft_error_map | buff->hard_error_map;
69 SectorMap dst_map = 0;
70 TRACE_FUN(ft_t_any);
71
72 if (bad_map || src_map) {
73 TRACE(ft_t_flow, "bad_map = 0x%08lx", (long) bad_map);
74 TRACE(ft_t_flow, "src_map = 0x%08lx", (long) src_map);
75 }
76 while (bad_map) {
77 while ((bad_map & 1) == 0) {
78 if (src_map & 1) {
79 dst_map |= (1 << i);
80 }
81 src_map >>= 1;
82 bad_map >>= 1;
83 ++i;
84 }
85 /* (bad_map & 1) == 1 */
86 src_map >>= 1;
87 bad_map >>= 1;
88 }
89 if (src_map) {
90 dst_map |= (src_map << i);
91 }
92 if (dst_map) {
93 TRACE(ft_t_flow, "dst_map = 0x%08lx", (long) dst_map);
94 }
95 TRACE_EXIT dst_map;
96}
97
98static int correct_and_copy_fraction(buffer_struct *buff, __u8 * destination,
99 int start, int size)
100{
101 struct memory_segment mseg;
102 int result;
103 SectorMap read_bad;
104 TRACE_FUN(ft_t_any);
105
106 mseg.read_bad = convert_sector_map(buff);
107 mseg.marked_bad = 0; /* not used... */
108 mseg.blocks = buff->bytes / FT_SECTOR_SIZE;
109 mseg.data = buff->address;
110 /* If there are no data sectors we can skip this segment.
111 */
112 if (mseg.blocks <= 3) {
113 TRACE_ABORT(0, ft_t_noise, "empty segment");
114 }
115 read_bad = mseg.read_bad;
116 ft_history.crc_errors += count_ones(read_bad);
117 result = ftape_ecc_correct_data(&mseg);
118 if (read_bad != 0 || mseg.corrected != 0) {
119 TRACE(ft_t_noise, "crc error map: 0x%08lx", (unsigned long)read_bad);
120 TRACE(ft_t_noise, "corrected map: 0x%08lx", (unsigned long)mseg.corrected);
121 ft_history.corrected += count_ones(mseg.corrected);
122 }
123 if (result == ECC_CORRECTED || result == ECC_OK) {
124 if (result == ECC_CORRECTED) {
125 TRACE(ft_t_info, "ecc corrected segment: %d", buff->segment_id);
126 }
127 if(start < 0) {
128 start= 0;
129 }
130 if((start+size) > ((mseg.blocks - 3) * FT_SECTOR_SIZE)) {
131 size = (mseg.blocks - 3) * FT_SECTOR_SIZE - start;
132 }
133 if (size < 0) {
134 size= 0;
135 }
136 if(size > 0) {
137 memcpy(destination + start, mseg.data + start, size);
138 }
139 if ((read_bad ^ mseg.corrected) & mseg.corrected) {
140 /* sectors corrected without crc errors set */
141 ft_history.crc_failures++;
142 }
143 TRACE_EXIT size; /* (mseg.blocks - 3) * FT_SECTOR_SIZE; */
144 } else {
145 ft_history.ecc_failures++;
146 TRACE_ABORT(-EAGAIN,
147 ft_t_err, "ecc failure on segment %d",
148 buff->segment_id);
149 }
150 TRACE_EXIT 0;
151}
152
153/* Read given segment into buffer at address.
154 */
155int ftape_read_segment_fraction(const int segment_id,
156 void *address,
157 const ft_read_mode_t read_mode,
158 const int start,
159 const int size)
160{
161 int result = 0;
162 int retry = 0;
163 int bytes_read = 0;
164 int read_done = 0;
165 TRACE_FUN(ft_t_flow);
166
167 ft_history.used |= 1;
168 TRACE(ft_t_data_flow, "segment_id = %d", segment_id);
169 if (ft_driver_state != reading) {
170 TRACE(ft_t_noise, "calling ftape_abort_operation");
171 TRACE_CATCH(ftape_abort_operation(),);
172 ftape_set_state(reading);
173 }
174 for(;;) {
175 buffer_struct *tail;
176 /* Allow escape from this loop on signal !
177 */
178 FT_SIGNAL_EXIT(_DONT_BLOCK);
179 /* Search all full buffers for the first matching the
180 * wanted segment. Clear other buffers on the fly.
181 */
182 tail = ftape_get_buffer(ft_queue_tail);
183 while (!read_done && tail->status == done) {
184 /* Allow escape from this loop on signal !
185 */
186 FT_SIGNAL_EXIT(_DONT_BLOCK);
187 if (tail->segment_id == segment_id) {
188 /* If out buffer is already full,
189 * return its contents.
190 */
191 TRACE(ft_t_flow, "found segment in cache: %d",
192 segment_id);
193 if (tail->deleted) {
194 /* Return a value that
195 * read_header_segment
196 * understands. As this
197 * should only occur when
198 * searching for the header
199 * segments it shouldn't be
200 * misinterpreted elsewhere.
201 */
202 TRACE_EXIT 0;
203 }
204 result = correct_and_copy_fraction(
205 tail,
206 address,
207 start,
208 size);
209 TRACE(ft_t_flow, "segment contains (bytes): %d",
210 result);
211 if (result < 0) {
212 if (result != -EAGAIN) {
213 TRACE_EXIT result;
214 }
215 /* keep read_done == 0, will
216 * trigger
217 * ftape_abort_operation
218 * because reading wrong
219 * segment.
220 */
221 TRACE(ft_t_err, "ecc failed, retry");
222 ++retry;
223 } else {
224 read_done = 1;
225 bytes_read = result;
226 }
227 } else {
228 TRACE(ft_t_flow,"zapping segment in cache: %d",
229 tail->segment_id);
230 }
231 tail->status = waiting;
232 tail = ftape_next_buffer(ft_queue_tail);
233 }
234 if (!read_done && tail->status == reading) {
235 if (tail->segment_id == segment_id) {
236 switch(ftape_wait_segment(reading)) {
237 case 0:
238 break;
239 case -EINTR:
240 TRACE_ABORT(-EINTR, ft_t_warn,
241 "interrupted by "
242 "non-blockable signal");
243 break;
244 default:
245 TRACE(ft_t_noise,
246 "wait_segment failed");
247 ftape_abort_operation();
248 ftape_set_state(reading);
249 break;
250 }
251 } else {
252 /* We're reading the wrong segment,
253 * stop runner.
254 */
255 TRACE(ft_t_noise, "reading wrong segment");
256 ftape_abort_operation();
257 ftape_set_state(reading);
258 }
259 }
260 /* should runner stop ?
261 */
262 if (ft_runner_status == aborting) {
263 buffer_struct *head = ftape_get_buffer(ft_queue_head);
264 switch(head->status) {
265 case error:
266 ft_history.defects +=
267 count_ones(head->hard_error_map);
268 case reading:
269 head->status = waiting;
270 break;
271 default:
272 break;
273 }
274 TRACE_CATCH(ftape_dumb_stop(),);
275 } else {
276 /* If just passed last segment on tape: wait
277 * for BOT or EOT mark. Sets ft_runner_status to
278 * idle if at lEOT and successful
279 */
280 TRACE_CATCH(ftape_handle_logical_eot(),);
281 }
282 /* If we got a segment: quit, or else retry up to limit.
283 *
284 * If segment to read is empty, do not start runner for it,
285 * but wait for next read call.
286 */
287 if (read_done ||
288 ftape_get_bad_sector_entry(segment_id) == EMPTY_SEGMENT ) {
289 /* bytes_read = 0; should still be zero */
290 TRACE_EXIT bytes_read;
291
292 }
293 if (retry > FT_RETRIES_ON_ECC_ERROR) {
294 ft_history.defects++;
295 TRACE_ABORT(-ENODATA, ft_t_err,
296 "too many retries on ecc failure");
297 }
298 /* Now at least one buffer is empty !
299 * Restart runner & tape if needed.
300 */
301 TRACE(ft_t_any, "head: %d, tail: %d, ft_runner_status: %d",
302 ftape_buffer_id(ft_queue_head),
303 ftape_buffer_id(ft_queue_tail),
304 ft_runner_status);
305 TRACE(ft_t_any, "buffer[].status, [head]: %d, [tail]: %d",
306 ftape_get_buffer(ft_queue_head)->status,
307 ftape_get_buffer(ft_queue_tail)->status);
308 tail = ftape_get_buffer(ft_queue_tail);
309 if (tail->status == waiting) {
310 buffer_struct *head = ftape_get_buffer(ft_queue_head);
311
312 ftape_setup_new_segment(head, segment_id, -1);
313 if (read_mode == FT_RD_SINGLE) {
314 /* disable read-ahead */
315 head->next_segment = 0;
316 }
317 ftape_calc_next_cluster(head);
318 if (ft_runner_status == idle) {
319 result = ftape_start_tape(segment_id,
320 head->sector_offset);
321 if (result < 0) {
322 TRACE_ABORT(result, ft_t_err, "Error: "
323 "segment %d unreachable",
324 segment_id);
325 }
326 }
327 head->status = reading;
328 fdc_setup_read_write(head, FDC_READ);
329 }
330 }
331 /* not reached */
332 TRACE_EXIT -EIO;
333}
334
335int ftape_read_header_segment(__u8 *address)
336{
337 int result;
338 int header_segment;
339 int first_failed = 0;
340 int status;
341 TRACE_FUN(ft_t_flow);
342
343 ft_used_header_segment = -1;
344 TRACE_CATCH(ftape_report_drive_status(&status),);
345 TRACE(ft_t_flow, "reading...");
346 /* We're looking for the first header segment.
347 * A header segment cannot contain bad sectors, therefor at the
348 * tape start, segments with bad sectors are (according to QIC-40/80)
349 * written with deleted data marks and must be skipped.
350 */
351 memset(address, '\0', (FT_SECTORS_PER_SEGMENT - 3) * FT_SECTOR_SIZE);
352 result = 0;
353#define HEADER_SEGMENT_BOUNDARY 68 /* why not 42? */
354 for (header_segment = 0;
355 header_segment < HEADER_SEGMENT_BOUNDARY && result == 0;
356 ++header_segment) {
357 /* Set no read-ahead, the isr will force read-ahead whenever
358 * it encounters deleted data !
359 */
360 result = ftape_read_segment(header_segment,
361 address,
362 FT_RD_SINGLE);
363 if (result < 0 && !first_failed) {
364 TRACE(ft_t_err, "header segment damaged, trying backup");
365 first_failed = 1;
366 result = 0; /* force read of next (backup) segment */
367 }
368 }
369 if (result < 0 || header_segment >= HEADER_SEGMENT_BOUNDARY) {
370 TRACE_ABORT(-EIO, ft_t_err,
371 "no readable header segment found");
372 }
373 TRACE_CATCH(ftape_abort_operation(),);
374 ft_used_header_segment = header_segment;
375 result = ftape_decode_header_segment(address);
376 TRACE_EXIT result;
377}
378
379int ftape_decode_header_segment(__u8 *address)
380{
381 unsigned int max_floppy_side;
382 unsigned int max_floppy_track;
383 unsigned int max_floppy_sector;
384 unsigned int new_tape_len;
385 TRACE_FUN(ft_t_flow);
386
387 if (GET4(address, FT_SIGNATURE) == FT_D2G_MAGIC) {
388 /* Ditto 2GB header segment. They encrypt the bad sector map.
389 * We decrypt it and store them in normal format.
390 * I hope this is correct.
391 */
392 int i;
393 TRACE(ft_t_warn,
394 "Found Ditto 2GB tape, "
395 "trying to decrypt bad sector map");
396 for (i=256; i < 29 * FT_SECTOR_SIZE; i++) {
397 address[i] = ~(address[i] - (i&0xff));
398 }
399 PUT4(address, 0,FT_HSEG_MAGIC);
400 } else if (GET4(address, FT_SIGNATURE) != FT_HSEG_MAGIC) {
401 TRACE_ABORT(-EIO, ft_t_err,
402 "wrong signature in header segment");
403 }
404 ft_format_code = (ft_format_type) address[FT_FMT_CODE];
405 if (ft_format_code != fmt_big) {
406 ft_header_segment_1 = GET2(address, FT_HSEG_1);
407 ft_header_segment_2 = GET2(address, FT_HSEG_2);
408 ft_first_data_segment = GET2(address, FT_FRST_SEG);
409 ft_last_data_segment = GET2(address, FT_LAST_SEG);
410 } else {
411 ft_header_segment_1 = GET4(address, FT_6_HSEG_1);
412 ft_header_segment_2 = GET4(address, FT_6_HSEG_2);
413 ft_first_data_segment = GET4(address, FT_6_FRST_SEG);
414 ft_last_data_segment = GET4(address, FT_6_LAST_SEG);
415 }
416 TRACE(ft_t_noise, "first data segment: %d", ft_first_data_segment);
417 TRACE(ft_t_noise, "last data segment: %d", ft_last_data_segment);
418 TRACE(ft_t_noise, "header segments are %d and %d",
419 ft_header_segment_1, ft_header_segment_2);
420
421 /* Verify tape parameters...
422 * QIC-40/80 spec: tape_parameters:
423 *
424 * segments-per-track segments_per_track
425 * tracks-per-cartridge tracks_per_tape
426 * max-floppy-side (segments_per_track *
427 * tracks_per_tape - 1) /
428 * ftape_segments_per_head
429 * max-floppy-track ftape_segments_per_head /
430 * ftape_segments_per_cylinder - 1
431 * max-floppy-sector ftape_segments_per_cylinder *
432 * FT_SECTORS_PER_SEGMENT
433 */
434 ft_segments_per_track = GET2(address, FT_SPT);
435 ft_tracks_per_tape = address[FT_TPC];
436 max_floppy_side = address[FT_FHM];
437 max_floppy_track = address[FT_FTM];
438 max_floppy_sector = address[FT_FSM];
439 TRACE(ft_t_noise, "(fmt/spt/tpc/fhm/ftm/fsm) = %d/%d/%d/%d/%d/%d",
440 ft_format_code, ft_segments_per_track, ft_tracks_per_tape,
441 max_floppy_side, max_floppy_track, max_floppy_sector);
442 new_tape_len = ftape_tape_len;
443 switch (ft_format_code) {
444 case fmt_425ft:
445 new_tape_len = 425;
446 break;
447 case fmt_normal:
448 if (ftape_tape_len == 0) { /* otherwise 307 ft */
449 new_tape_len = 205;
450 }
451 break;
452 case fmt_1100ft:
453 new_tape_len = 1100;
454 break;
455 case fmt_var:{
456 int segments_per_1000_inch = 1; /* non-zero default for switch */
457 switch (ft_qic_std) {
458 case QIC_TAPE_QIC40:
459 segments_per_1000_inch = 332;
460 break;
461 case QIC_TAPE_QIC80:
462 segments_per_1000_inch = 488;
463 break;
464 case QIC_TAPE_QIC3010:
465 segments_per_1000_inch = 730;
466 break;
467 case QIC_TAPE_QIC3020:
468 segments_per_1000_inch = 1430;
469 break;
470 }
471 new_tape_len = (1000 * ft_segments_per_track +
472 (segments_per_1000_inch - 1)) / segments_per_1000_inch;
473 break;
474 }
475 case fmt_big:{
476 int segments_per_1000_inch = 1; /* non-zero default for switch */
477 switch (ft_qic_std) {
478 case QIC_TAPE_QIC40:
479 segments_per_1000_inch = 332;
480 break;
481 case QIC_TAPE_QIC80:
482 segments_per_1000_inch = 488;
483 break;
484 case QIC_TAPE_QIC3010:
485 segments_per_1000_inch = 730;
486 break;
487 case QIC_TAPE_QIC3020:
488 segments_per_1000_inch = 1430;
489 break;
490 default:
491 TRACE_ABORT(-EIO, ft_t_bug,
492 "%x QIC-standard with fmt-code %d, please report",
493 ft_qic_std, ft_format_code);
494 }
495 new_tape_len = ((1000 * ft_segments_per_track +
496 (segments_per_1000_inch - 1)) /
497 segments_per_1000_inch);
498 break;
499 }
500 default:
501 TRACE_ABORT(-EIO, ft_t_err,
502 "unknown tape format, please report !");
503 }
504 if (new_tape_len != ftape_tape_len) {
505 ftape_tape_len = new_tape_len;
506 TRACE(ft_t_info, "calculated tape length is %d ft",
507 ftape_tape_len);
508 ftape_calc_timeouts(ft_qic_std, ft_data_rate, ftape_tape_len);
509 }
510 if (ft_segments_per_track == 0 && ft_tracks_per_tape == 0 &&
511 max_floppy_side == 0 && max_floppy_track == 0 &&
512 max_floppy_sector == 0) {
513 /* QIC-40 Rev E and earlier has no values in the header.
514 */
515 ft_segments_per_track = 68;
516 ft_tracks_per_tape = 20;
517 max_floppy_side = 1;
518 max_floppy_track = 169;
519 max_floppy_sector = 128;
520 }
521 /* This test will compensate for the wrong parameter on tapes
522 * formatted by Conner software.
523 */
524 if (ft_segments_per_track == 150 &&
525 ft_tracks_per_tape == 28 &&
526 max_floppy_side == 7 &&
527 max_floppy_track == 149 &&
528 max_floppy_sector == 128) {
529TRACE(ft_t_info, "the famous CONNER bug: max_floppy_side off by one !");
530 max_floppy_side = 6;
531 }
532 /* These tests will compensate for the wrong parameter on tapes
533 * formatted by ComByte Windows software.
534 *
535 * First, for 205 foot tapes
536 */
537 if (ft_segments_per_track == 100 &&
538 ft_tracks_per_tape == 28 &&
539 max_floppy_side == 9 &&
540 max_floppy_track == 149 &&
541 max_floppy_sector == 128) {
542TRACE(ft_t_info, "the ComByte bug: max_floppy_side incorrect!");
543 max_floppy_side = 4;
544 }
545 /* Next, for 307 foot tapes. */
546 if (ft_segments_per_track == 150 &&
547 ft_tracks_per_tape == 28 &&
548 max_floppy_side == 9 &&
549 max_floppy_track == 149 &&
550 max_floppy_sector == 128) {
551TRACE(ft_t_info, "the ComByte bug: max_floppy_side incorrect!");
552 max_floppy_side = 6;
553 }
554 /* This test will compensate for the wrong parameter on tapes
555 * formatted by Colorado Windows software.
556 */
557 if (ft_segments_per_track == 150 &&
558 ft_tracks_per_tape == 28 &&
559 max_floppy_side == 6 &&
560 max_floppy_track == 150 &&
561 max_floppy_sector == 128) {
562TRACE(ft_t_info, "the famous Colorado bug: max_floppy_track off by one !");
563 max_floppy_track = 149;
564 }
565 ftape_segments_per_head = ((max_floppy_sector/FT_SECTORS_PER_SEGMENT) *
566 (max_floppy_track + 1));
567 /* This test will compensate for some bug reported by Dima
568 * Brodsky. Seems to be a Colorado bug, either. (freebee
569 * Imation tape shipped together with Colorado T3000
570 */
571 if ((ft_format_code == fmt_var || ft_format_code == fmt_big) &&
572 ft_tracks_per_tape == 50 &&
573 max_floppy_side == 54 &&
574 max_floppy_track == 255 &&
575 max_floppy_sector == 128) {
576TRACE(ft_t_info, "the famous ??? bug: max_floppy_track off by one !");
577 max_floppy_track = 254;
578 }
579 /*
580 * Verify drive_configuration with tape parameters
581 */
582 if (ftape_segments_per_head == 0 || ftape_segments_per_cylinder == 0 ||
583 ((ft_segments_per_track * ft_tracks_per_tape - 1) / ftape_segments_per_head
584 != max_floppy_side) ||
585 (ftape_segments_per_head / ftape_segments_per_cylinder - 1 != max_floppy_track) ||
586 (ftape_segments_per_cylinder * FT_SECTORS_PER_SEGMENT != max_floppy_sector)
587#ifdef TESTING
588 || ((ft_format_code == fmt_var || ft_format_code == fmt_big) &&
589 (max_floppy_track != 254 || max_floppy_sector != 128))
590#endif
591 ) {
592 char segperheadz = ftape_segments_per_head ? ' ' : '?';
593 char segpercylz = ftape_segments_per_cylinder ? ' ' : '?';
594 TRACE(ft_t_err,"Tape parameters inconsistency, please report");
595 TRACE(ft_t_err, "reported = %d/%d/%d/%d/%d/%d",
596 ft_format_code,
597 ft_segments_per_track,
598 ft_tracks_per_tape,
599 max_floppy_side,
600 max_floppy_track,
601 max_floppy_sector);
602 TRACE(ft_t_err, "required = %d/%d/%d/%d%c/%d%c/%d",
603 ft_format_code,
604 ft_segments_per_track,
605 ft_tracks_per_tape,
606 ftape_segments_per_head ?
607 ((ft_segments_per_track * ft_tracks_per_tape -1) /
608 ftape_segments_per_head ) :
609 (ft_segments_per_track * ft_tracks_per_tape -1),
610 segperheadz,
611 ftape_segments_per_cylinder ?
612 (ftape_segments_per_head /
613 ftape_segments_per_cylinder - 1 ) :
614 ftape_segments_per_head - 1,
615 segpercylz,
616 (ftape_segments_per_cylinder * FT_SECTORS_PER_SEGMENT));
617 TRACE_EXIT -EIO;
618 }
619 ftape_extract_bad_sector_map(address);
620 TRACE_EXIT 0;
621}
diff --git a/drivers/char/ftape/lowlevel/ftape-read.h b/drivers/char/ftape/lowlevel/ftape-read.h
deleted file mode 100644
index 069f99f2a984..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-read.h
+++ /dev/null
@@ -1,51 +0,0 @@
1#ifndef _FTAPE_READ_H
2#define _FTAPE_READ_H
3
4/*
5 * Copyright (C) 1994-1996 Bas Laarhoven,
6 * (C) 1996-1997 Claus-Justus Heine.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; see the file COPYING. If not, write to
20 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21
22 *
23 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-read.h,v $
24 * $Revision: 1.2 $
25 * $Date: 1997/10/05 19:18:22 $
26 *
27 * This file contains the definitions for the read functions
28 * for the QIC-117 floppy-tape driver for Linux.
29 *
30 */
31
32/* ftape-read.c defined global functions.
33 */
34typedef enum {
35 FT_RD_SINGLE = 0,
36 FT_RD_AHEAD = 1,
37} ft_read_mode_t;
38
39extern int ftape_read_header_segment(__u8 *address);
40extern int ftape_decode_header_segment(__u8 *address);
41extern int ftape_read_segment_fraction(const int segment,
42 void *address,
43 const ft_read_mode_t read_mode,
44 const int start,
45 const int size);
46#define ftape_read_segment(segment, address, read_mode) \
47 ftape_read_segment_fraction(segment, address, read_mode, \
48 0, FT_SEGMENT_SIZE)
49extern void ftape_zap_read_buffers(void);
50
51#endif /* _FTAPE_READ_H */
diff --git a/drivers/char/ftape/lowlevel/ftape-rw.c b/drivers/char/ftape/lowlevel/ftape-rw.c
deleted file mode 100644
index c0d6dc2cbfd3..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-rw.c
+++ /dev/null
@@ -1,1092 +0,0 @@
1/*
2 * Copyright (C) 1993-1996 Bas Laarhoven,
3 * (C) 1996-1997 Claus-Justus Heine.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
8 any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; see the file COPYING. If not, write to
17 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 *
20 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-rw.c,v $
21 * $Revision: 1.7 $
22 * $Date: 1997/10/28 14:26:49 $
23 *
24 * This file contains some common code for the segment read and
25 * segment write routines for the QIC-117 floppy-tape driver for
26 * Linux.
27 */
28
29#include <linux/string.h>
30#include <linux/errno.h>
31
32#include <linux/ftape.h>
33#include <linux/qic117.h>
34#include "../lowlevel/ftape-tracing.h"
35#include "../lowlevel/ftape-rw.h"
36#include "../lowlevel/fdc-io.h"
37#include "../lowlevel/ftape-init.h"
38#include "../lowlevel/ftape-io.h"
39#include "../lowlevel/ftape-ctl.h"
40#include "../lowlevel/ftape-read.h"
41#include "../lowlevel/ftape-ecc.h"
42#include "../lowlevel/ftape-bsm.h"
43
44/* Global vars.
45 */
46int ft_nr_buffers;
47buffer_struct *ft_buffer[FT_MAX_NR_BUFFERS];
48static volatile int ft_head;
49static volatile int ft_tail; /* not volatile but need same type as head */
50int fdc_setup_error;
51location_record ft_location = {-1, 0};
52volatile int ftape_tape_running;
53
54/* Local vars.
55 */
56static int overrun_count_offset;
57static int inhibit_correction;
58
59/* maxmimal allowed overshoot when fast seeking
60 */
61#define OVERSHOOT_LIMIT 10
62
63/* Increment cyclic buffer nr.
64 */
65buffer_struct *ftape_next_buffer(ft_buffer_queue_t pos)
66{
67 switch (pos) {
68 case ft_queue_head:
69 if (++ft_head >= ft_nr_buffers) {
70 ft_head = 0;
71 }
72 return ft_buffer[ft_head];
73 case ft_queue_tail:
74 if (++ft_tail >= ft_nr_buffers) {
75 ft_tail = 0;
76 }
77 return ft_buffer[ft_tail];
78 default:
79 return NULL;
80 }
81}
82int ftape_buffer_id(ft_buffer_queue_t pos)
83{
84 switch(pos) {
85 case ft_queue_head: return ft_head;
86 case ft_queue_tail: return ft_tail;
87 default: return -1;
88 }
89}
90buffer_struct *ftape_get_buffer(ft_buffer_queue_t pos)
91{
92 switch(pos) {
93 case ft_queue_head: return ft_buffer[ft_head];
94 case ft_queue_tail: return ft_buffer[ft_tail];
95 default: return NULL;
96 }
97}
98void ftape_reset_buffer(void)
99{
100 ft_head = ft_tail = 0;
101}
102
103buffer_state_enum ftape_set_state(buffer_state_enum new_state)
104{
105 buffer_state_enum old_state = ft_driver_state;
106
107 ft_driver_state = new_state;
108 return old_state;
109}
110/* Calculate Floppy Disk Controller and DMA parameters for a segment.
111 * head: selects buffer struct in array.
112 * offset: number of physical sectors to skip (including bad ones).
113 * count: number of physical sectors to handle (including bad ones).
114 */
115static int setup_segment(buffer_struct * buff,
116 int segment_id,
117 unsigned int sector_offset,
118 unsigned int sector_count,
119 int retry)
120{
121 SectorMap offset_mask;
122 SectorMap mask;
123 TRACE_FUN(ft_t_any);
124
125 buff->segment_id = segment_id;
126 buff->sector_offset = sector_offset;
127 buff->remaining = sector_count;
128 buff->head = segment_id / ftape_segments_per_head;
129 buff->cyl = (segment_id % ftape_segments_per_head) / ftape_segments_per_cylinder;
130 buff->sect = (segment_id % ftape_segments_per_cylinder) * FT_SECTORS_PER_SEGMENT + 1;
131 buff->deleted = 0;
132 offset_mask = (1 << buff->sector_offset) - 1;
133 mask = ftape_get_bad_sector_entry(segment_id) & offset_mask;
134 while (mask) {
135 if (mask & 1) {
136 offset_mask >>= 1; /* don't count bad sector */
137 }
138 mask >>= 1;
139 }
140 buff->data_offset = count_ones(offset_mask); /* good sectors to skip */
141 buff->ptr = buff->address + buff->data_offset * FT_SECTOR_SIZE;
142 TRACE(ft_t_flow, "data offset = %d sectors", buff->data_offset);
143 if (retry) {
144 buff->soft_error_map &= offset_mask; /* keep skipped part */
145 } else {
146 buff->hard_error_map = buff->soft_error_map = 0;
147 }
148 buff->bad_sector_map = ftape_get_bad_sector_entry(buff->segment_id);
149 if (buff->bad_sector_map != 0) {
150 TRACE(ft_t_noise, "segment: %d, bad sector map: %08lx",
151 buff->segment_id, (long)buff->bad_sector_map);
152 } else {
153 TRACE(ft_t_flow, "segment: %d", buff->segment_id);
154 }
155 if (buff->sector_offset > 0) {
156 buff->bad_sector_map >>= buff->sector_offset;
157 }
158 if (buff->sector_offset != 0 || buff->remaining != FT_SECTORS_PER_SEGMENT) {
159 TRACE(ft_t_flow, "sector offset = %d, count = %d",
160 buff->sector_offset, buff->remaining);
161 }
162 /* Segments with 3 or less sectors are not written with valid
163 * data because there is no space left for the ecc. The
164 * data written is whatever happens to be in the buffer.
165 * Reading such a segment will return a zero byte-count.
166 * To allow us to read/write segments with all bad sectors
167 * we fake one readable sector in the segment. This
168 * prevents having to handle these segments in a very
169 * special way. It is not important if the reading of this
170 * bad sector fails or not (the data is ignored). It is
171 * only read to keep the driver running.
172 *
173 * The QIC-40/80 spec. has no information on how to handle
174 * this case, so this is my interpretation.
175 */
176 if (buff->bad_sector_map == EMPTY_SEGMENT) {
177 TRACE(ft_t_flow, "empty segment %d, fake first sector good",
178 buff->segment_id);
179 if (buff->ptr != buff->address) {
180 TRACE(ft_t_bug, "This is a bug: %p/%p",
181 buff->ptr, buff->address);
182 }
183 buff->bad_sector_map = FAKE_SEGMENT;
184 }
185 fdc_setup_error = 0;
186 buff->next_segment = segment_id + 1;
187 TRACE_EXIT 0;
188}
189
190/* Calculate Floppy Disk Controller and DMA parameters for a new segment.
191 */
192int ftape_setup_new_segment(buffer_struct * buff, int segment_id, int skip)
193{
194 int result = 0;
195 static int old_segment_id = -1;
196 static buffer_state_enum old_ft_driver_state = idle;
197 int retry = 0;
198 unsigned offset = 0;
199 int count = FT_SECTORS_PER_SEGMENT;
200 TRACE_FUN(ft_t_flow);
201
202 TRACE(ft_t_flow, "%s segment %d (old = %d)",
203 (ft_driver_state == reading || ft_driver_state == verifying)
204 ? "reading" : "writing",
205 segment_id, old_segment_id);
206 if (ft_driver_state != old_ft_driver_state) { /* when verifying */
207 old_segment_id = -1;
208 old_ft_driver_state = ft_driver_state;
209 }
210 if (segment_id == old_segment_id) {
211 ++buff->retry;
212 ++ft_history.retries;
213 TRACE(ft_t_flow, "setting up for retry nr %d", buff->retry);
214 retry = 1;
215 if (skip && buff->skip > 0) { /* allow skip on retry */
216 offset = buff->skip;
217 count -= offset;
218 TRACE(ft_t_flow, "skipping %d sectors", offset);
219 }
220 } else {
221 buff->retry = 0;
222 buff->skip = 0;
223 old_segment_id = segment_id;
224 }
225 result = setup_segment(buff, segment_id, offset, count, retry);
226 TRACE_EXIT result;
227}
228
229/* Determine size of next cluster of good sectors.
230 */
231int ftape_calc_next_cluster(buffer_struct * buff)
232{
233 /* Skip bad sectors.
234 */
235 while (buff->remaining > 0 && (buff->bad_sector_map & 1) != 0) {
236 buff->bad_sector_map >>= 1;
237 ++buff->sector_offset;
238 --buff->remaining;
239 }
240 /* Find next cluster of good sectors
241 */
242 if (buff->bad_sector_map == 0) { /* speed up */
243 buff->sector_count = buff->remaining;
244 } else {
245 SectorMap map = buff->bad_sector_map;
246
247 buff->sector_count = 0;
248 while (buff->sector_count < buff->remaining && (map & 1) == 0) {
249 ++buff->sector_count;
250 map >>= 1;
251 }
252 }
253 return buff->sector_count;
254}
255
256/* if just passed the last segment on a track, wait for BOT
257 * or EOT mark.
258 */
259int ftape_handle_logical_eot(void)
260{
261 TRACE_FUN(ft_t_flow);
262
263 if (ft_runner_status == logical_eot) {
264 int status;
265
266 TRACE(ft_t_noise, "tape at logical EOT");
267 TRACE_CATCH(ftape_ready_wait(ftape_timeout.seek, &status),);
268 if ((status & (QIC_STATUS_AT_BOT | QIC_STATUS_AT_EOT)) == 0) {
269 TRACE_ABORT(-EIO, ft_t_err, "eot/bot not reached");
270 }
271 ft_runner_status = end_of_tape;
272 }
273 if (ft_runner_status == end_of_tape) {
274 TRACE(ft_t_noise, "runner stopped because of logical EOT");
275 ft_runner_status = idle;
276 }
277 TRACE_EXIT 0;
278}
279
280static int check_bot_eot(int status)
281{
282 TRACE_FUN(ft_t_flow);
283
284 if (status & (QIC_STATUS_AT_BOT | QIC_STATUS_AT_EOT)) {
285 ft_location.bot = ((ft_location.track & 1) == 0 ?
286 (status & QIC_STATUS_AT_BOT) != 0:
287 (status & QIC_STATUS_AT_EOT) != 0);
288 ft_location.eot = !ft_location.bot;
289 ft_location.segment = (ft_location.track +
290 (ft_location.bot ? 0 : 1)) * ft_segments_per_track - 1;
291 ft_location.sector = -1;
292 ft_location.known = 1;
293 TRACE(ft_t_flow, "tape at logical %s",
294 ft_location.bot ? "bot" : "eot");
295 TRACE(ft_t_flow, "segment = %d", ft_location.segment);
296 } else {
297 ft_location.known = 0;
298 }
299 TRACE_EXIT ft_location.known;
300}
301
302/* Read Id of first sector passing tape head.
303 */
304static int ftape_read_id(void)
305{
306 int status;
307 __u8 out[2];
308 TRACE_FUN(ft_t_any);
309
310 /* Assume tape is running on entry, be able to handle
311 * situation where it stopped or is stopping.
312 */
313 ft_location.known = 0; /* default is location not known */
314 out[0] = FDC_READID;
315 out[1] = ft_drive_sel;
316 TRACE_CATCH(fdc_command(out, 2),);
317 switch (fdc_interrupt_wait(20 * FT_SECOND)) {
318 case 0:
319 if (fdc_sect == 0) {
320 if (ftape_report_drive_status(&status) >= 0 &&
321 (status & QIC_STATUS_READY)) {
322 ftape_tape_running = 0;
323 TRACE(ft_t_flow, "tape has stopped");
324 check_bot_eot(status);
325 }
326 } else {
327 ft_location.known = 1;
328 ft_location.segment = (ftape_segments_per_head
329 * fdc_head
330 + ftape_segments_per_cylinder
331 * fdc_cyl
332 + (fdc_sect - 1)
333 / FT_SECTORS_PER_SEGMENT);
334 ft_location.sector = ((fdc_sect - 1)
335 % FT_SECTORS_PER_SEGMENT);
336 ft_location.eot = ft_location.bot = 0;
337 }
338 break;
339 case -ETIME:
340 /* Didn't find id on tape, must be near end: Wait
341 * until stopped.
342 */
343 if (ftape_ready_wait(FT_FOREVER, &status) >= 0) {
344 ftape_tape_running = 0;
345 TRACE(ft_t_flow, "tape has stopped");
346 check_bot_eot(status);
347 }
348 break;
349 default:
350 /* Interrupted or otherwise failing
351 * fdc_interrupt_wait()
352 */
353 TRACE(ft_t_err, "fdc_interrupt_wait failed");
354 break;
355 }
356 if (!ft_location.known) {
357 TRACE_ABORT(-EIO, ft_t_flow, "no id found");
358 }
359 if (ft_location.sector == 0) {
360 TRACE(ft_t_flow, "passing segment %d/%d",
361 ft_location.segment, ft_location.sector);
362 } else {
363 TRACE(ft_t_fdc_dma, "passing segment %d/%d",
364 ft_location.segment, ft_location.sector);
365 }
366 TRACE_EXIT 0;
367}
368
369static int logical_forward(void)
370{
371 ftape_tape_running = 1;
372 return ftape_command(QIC_LOGICAL_FORWARD);
373}
374
375int ftape_stop_tape(int *pstatus)
376{
377 int retry = 0;
378 int result;
379 TRACE_FUN(ft_t_flow);
380
381 do {
382 result = ftape_command_wait(QIC_STOP_TAPE,
383 ftape_timeout.stop, pstatus);
384 if (result == 0) {
385 if ((*pstatus & QIC_STATUS_READY) == 0) {
386 result = -EIO;
387 } else {
388 ftape_tape_running = 0;
389 }
390 }
391 } while (result < 0 && ++retry <= 3);
392 if (result < 0) {
393 TRACE(ft_t_err, "failed ! (fatal)");
394 }
395 TRACE_EXIT result;
396}
397
398int ftape_dumb_stop(void)
399{
400 int result;
401 int status;
402 TRACE_FUN(ft_t_flow);
403
404 /* Abort current fdc operation if it's busy (probably read
405 * or write operation pending) with a reset.
406 */
407 if (fdc_ready_wait(100 /* usec */) < 0) {
408 TRACE(ft_t_noise, "aborting fdc operation");
409 fdc_reset();
410 }
411 /* Reading id's after the last segment on a track may fail
412 * but eventually the drive will become ready (logical eot).
413 */
414 result = ftape_report_drive_status(&status);
415 ft_location.known = 0;
416 do {
417 if (result == 0 && status & QIC_STATUS_READY) {
418 /* Tape is not running any more.
419 */
420 TRACE(ft_t_noise, "tape already halted");
421 check_bot_eot(status);
422 ftape_tape_running = 0;
423 } else if (ftape_tape_running) {
424 /* Tape is (was) still moving.
425 */
426#ifdef TESTING
427 ftape_read_id();
428#endif
429 result = ftape_stop_tape(&status);
430 } else {
431 /* Tape not yet ready but stopped.
432 */
433 result = ftape_ready_wait(ftape_timeout.pause,&status);
434 }
435 } while (ftape_tape_running
436 && !(sigtestsetmask(&current->pending.signal, _NEVER_BLOCK)));
437#ifndef TESTING
438 ft_location.known = 0;
439#endif
440 if (ft_runner_status == aborting || ft_runner_status == do_abort) {
441 ft_runner_status = idle;
442 }
443 TRACE_EXIT result;
444}
445
446/* Wait until runner has finished tail buffer.
447 *
448 */
449int ftape_wait_segment(buffer_state_enum state)
450{
451 int status;
452 int result = 0;
453 TRACE_FUN(ft_t_flow);
454
455 while (ft_buffer[ft_tail]->status == state) {
456 TRACE(ft_t_flow, "state: %d", ft_buffer[ft_tail]->status);
457 /* First buffer still being worked on, wait up to timeout.
458 *
459 * Note: we check two times for being killed. 50
460 * seconds are quite long. Note that
461 * fdc_interrupt_wait() is not killable by any
462 * means. ftape_read_segment() wants us to return
463 * -EINTR in case of a signal.
464 */
465 FT_SIGNAL_EXIT(_DONT_BLOCK);
466 result = fdc_interrupt_wait(50 * FT_SECOND);
467 FT_SIGNAL_EXIT(_DONT_BLOCK);
468 if (result < 0) {
469 TRACE_ABORT(result,
470 ft_t_err, "fdc_interrupt_wait failed");
471 }
472 if (fdc_setup_error) {
473 /* recover... FIXME */
474 TRACE_ABORT(-EIO, ft_t_err, "setup error");
475 }
476 }
477 if (ft_buffer[ft_tail]->status != error) {
478 TRACE_EXIT 0;
479 }
480 TRACE_CATCH(ftape_report_drive_status(&status),);
481 TRACE(ft_t_noise, "ftape_report_drive_status: 0x%02x", status);
482 if ((status & QIC_STATUS_READY) &&
483 (status & QIC_STATUS_ERROR)) {
484 unsigned int error;
485 qic117_cmd_t command;
486
487 /* Report and clear error state.
488 * In case the drive can't operate at the selected
489 * rate, select the next lower data rate.
490 */
491 ftape_report_error(&error, &command, 1);
492 if (error == 31 && command == QIC_LOGICAL_FORWARD) {
493 /* drive does not accept this data rate */
494 if (ft_data_rate > 250) {
495 TRACE(ft_t_info,
496 "Probable data rate conflict");
497 TRACE(ft_t_info,
498 "Lowering data rate to %d Kbps",
499 ft_data_rate / 2);
500 ftape_half_data_rate();
501 if (ft_buffer[ft_tail]->retry > 0) {
502 /* give it a chance */
503 --ft_buffer[ft_tail]->retry;
504 }
505 } else {
506 /* no rate is accepted... */
507 TRACE(ft_t_err, "We're dead :(");
508 }
509 } else {
510 TRACE(ft_t_err, "Unknown error");
511 }
512 TRACE_EXIT -EIO; /* g.p. error */
513 }
514 TRACE_EXIT 0;
515}
516
517/* forward */ static int seek_forward(int segment_id, int fast);
518
519static int fast_seek(int count, int reverse)
520{
521 int result = 0;
522 int status;
523 TRACE_FUN(ft_t_flow);
524
525 if (count > 0) {
526 /* If positioned at begin or end of tape, fast seeking needs
527 * special treatment.
528 * Starting from logical bot needs a (slow) seek to the first
529 * segment before the high speed seek. Most drives do this
530 * automatically but some older don't, so we treat them
531 * all the same.
532 * Starting from logical eot is even more difficult because
533 * we cannot (slow) reverse seek to the last segment.
534 * TO BE IMPLEMENTED.
535 */
536 inhibit_correction = 0;
537 if (ft_location.known &&
538 ((ft_location.bot && !reverse) ||
539 (ft_location.eot && reverse))) {
540 if (!reverse) {
541 /* (slow) skip to first segment on a track
542 */
543 seek_forward(ft_location.track * ft_segments_per_track, 0);
544 --count;
545 } else {
546 /* When seeking backwards from
547 * end-of-tape the number of erased
548 * gaps found seems to be higher than
549 * expected. Therefor the drive must
550 * skip some more segments than
551 * calculated, but we don't know how
552 * many. Thus we will prevent the
553 * re-calculation of offset and
554 * overshoot when seeking backwards.
555 */
556 inhibit_correction = 1;
557 count += 3; /* best guess */
558 }
559 }
560 } else {
561 TRACE(ft_t_flow, "warning: zero or negative count: %d", count);
562 }
563 if (count > 0) {
564 int i;
565 int nibbles = count > 255 ? 3 : 2;
566
567 if (count > 4095) {
568 TRACE(ft_t_noise, "skipping clipped at 4095 segment");
569 count = 4095;
570 }
571 /* Issue this tape command first. */
572 if (!reverse) {
573 TRACE(ft_t_noise, "skipping %d segment(s)", count);
574 result = ftape_command(nibbles == 3 ?
575 QIC_SKIP_EXTENDED_FORWARD : QIC_SKIP_FORWARD);
576 } else {
577 TRACE(ft_t_noise, "backing up %d segment(s)", count);
578 result = ftape_command(nibbles == 3 ?
579 QIC_SKIP_EXTENDED_REVERSE : QIC_SKIP_REVERSE);
580 }
581 if (result < 0) {
582 TRACE(ft_t_noise, "Skip command failed");
583 } else {
584 --count; /* 0 means one gap etc. */
585 for (i = 0; i < nibbles; ++i) {
586 if (result >= 0) {
587 result = ftape_parameter(count & 15);
588 count /= 16;
589 }
590 }
591 result = ftape_ready_wait(ftape_timeout.rewind, &status);
592 if (result >= 0) {
593 ftape_tape_running = 0;
594 }
595 }
596 }
597 TRACE_EXIT result;
598}
599
600static int validate(int id)
601{
602 /* Check to see if position found is off-track as reported
603 * once. Because all tracks in one direction lie next to
604 * each other, if off-track the error will be approximately
605 * 2 * ft_segments_per_track.
606 */
607 if (ft_location.track == -1) {
608 return 1; /* unforseen situation, don't generate error */
609 } else {
610 /* Use margin of ft_segments_per_track on both sides
611 * because ftape needs some margin and the error we're
612 * looking for is much larger !
613 */
614 int lo = (ft_location.track - 1) * ft_segments_per_track;
615 int hi = (ft_location.track + 2) * ft_segments_per_track;
616
617 return (id >= lo && id < hi);
618 }
619}
620
621static int seek_forward(int segment_id, int fast)
622{
623 int failures = 0;
624 int count;
625 static int margin = 1; /* fixed: stop this before target */
626 static int overshoot = 1;
627 static int min_count = 8;
628 int expected = -1;
629 int target = segment_id - margin;
630 int fast_seeking;
631 int prev_segment = ft_location.segment;
632 TRACE_FUN(ft_t_flow);
633
634 if (!ft_location.known) {
635 TRACE_ABORT(-EIO, ft_t_err,
636 "fatal: cannot seek from unknown location");
637 }
638 if (!validate(segment_id)) {
639 ftape_sleep(1 * FT_SECOND);
640 ft_failure = 1;
641 TRACE_ABORT(-EIO, ft_t_err,
642 "fatal: head off track (bad hardware?)");
643 }
644 TRACE(ft_t_noise, "from %d/%d to %d/0 - %d",
645 ft_location.segment, ft_location.sector,segment_id,margin);
646 count = target - ft_location.segment - overshoot;
647 fast_seeking = (fast &&
648 count > (min_count + (ft_location.bot ? 1 : 0)));
649 if (fast_seeking) {
650 TRACE(ft_t_noise, "fast skipping %d segments", count);
651 expected = segment_id - margin;
652 fast_seek(count, 0);
653 }
654 if (!ftape_tape_running) {
655 logical_forward();
656 }
657 while (ft_location.segment < segment_id) {
658 /* This requires at least one sector in a (bad) segment to
659 * have a valid and readable sector id !
660 * It looks like this is not guaranteed, so we must try
661 * to find a way to skip an EMPTY_SEGMENT. !!! FIXME !!!
662 */
663 if (ftape_read_id() < 0 || !ft_location.known ||
664 sigtestsetmask(&current->pending.signal, _DONT_BLOCK)) {
665 ft_location.known = 0;
666 if (!ftape_tape_running ||
667 ++failures > FT_SECTORS_PER_SEGMENT) {
668 TRACE_ABORT(-EIO, ft_t_err,
669 "read_id failed completely");
670 }
671 FT_SIGNAL_EXIT(_DONT_BLOCK);
672 TRACE(ft_t_flow, "read_id failed, retry (%d)",
673 failures);
674 continue;
675 }
676 if (fast_seeking) {
677 TRACE(ft_t_noise, "ended at %d/%d (%d,%d)",
678 ft_location.segment, ft_location.sector,
679 overshoot, inhibit_correction);
680 if (!inhibit_correction &&
681 (ft_location.segment < expected ||
682 ft_location.segment > expected + margin)) {
683 int error = ft_location.segment - expected;
684 TRACE(ft_t_noise,
685 "adjusting overshoot from %d to %d",
686 overshoot, overshoot + error);
687 overshoot += error;
688 /* All overshoots have the same
689 * direction, so it should never
690 * become negative, but who knows.
691 */
692 if (overshoot < -5 ||
693 overshoot > OVERSHOOT_LIMIT) {
694 if (overshoot < 0) {
695 /* keep sane value */
696 overshoot = -5;
697 } else {
698 /* keep sane value */
699 overshoot = OVERSHOOT_LIMIT;
700 }
701 TRACE(ft_t_noise,
702 "clipped overshoot to %d",
703 overshoot);
704 }
705 }
706 fast_seeking = 0;
707 }
708 if (ft_location.known) {
709 if (ft_location.segment > prev_segment + 1) {
710 TRACE(ft_t_noise,
711 "missed segment %d while skipping",
712 prev_segment + 1);
713 }
714 prev_segment = ft_location.segment;
715 }
716 }
717 if (ft_location.segment > segment_id) {
718 TRACE_ABORT(-EIO,
719 ft_t_noise, "failed: skip ended at segment %d/%d",
720 ft_location.segment, ft_location.sector);
721 }
722 TRACE_EXIT 0;
723}
724
725static int skip_reverse(int segment_id, int *pstatus)
726{
727 int failures = 0;
728 static int overshoot = 1;
729 static int min_rewind = 2; /* 1 + overshoot */
730 static const int margin = 1; /* stop this before target */
731 int expected = 0;
732 int count = 1;
733 int short_seek;
734 int target = segment_id - margin;
735 TRACE_FUN(ft_t_flow);
736
737 if (ft_location.known && !validate(segment_id)) {
738 ftape_sleep(1 * FT_SECOND);
739 ft_failure = 1;
740 TRACE_ABORT(-EIO, ft_t_err,
741 "fatal: head off track (bad hardware?)");
742 }
743 do {
744 if (!ft_location.known) {
745 TRACE(ft_t_warn, "warning: location not known");
746 }
747 TRACE(ft_t_noise, "from %d/%d to %d/0 - %d",
748 ft_location.segment, ft_location.sector,
749 segment_id, margin);
750 /* min_rewind == 1 + overshoot_when_doing_minimum_rewind
751 * overshoot == overshoot_when_doing_larger_rewind
752 * Initially min_rewind == 1 + overshoot, optimization
753 * of both values will be done separately.
754 * overshoot and min_rewind can be negative as both are
755 * sums of three components:
756 * any_overshoot == rewind_overshoot -
757 * stop_overshoot -
758 * start_overshoot
759 */
760 if (ft_location.segment - target - (min_rewind - 1) < 1) {
761 short_seek = 1;
762 } else {
763 count = ft_location.segment - target - overshoot;
764 short_seek = (count < 1);
765 }
766 if (short_seek) {
767 count = 1; /* do shortest rewind */
768 expected = ft_location.segment - min_rewind;
769 if (expected/ft_segments_per_track != ft_location.track) {
770 expected = (ft_location.track *
771 ft_segments_per_track);
772 }
773 } else {
774 expected = target;
775 }
776 fast_seek(count, 1);
777 logical_forward();
778 if (ftape_read_id() < 0 || !ft_location.known ||
779 (sigtestsetmask(&current->pending.signal, _DONT_BLOCK))) {
780 if ((!ftape_tape_running && !ft_location.known) ||
781 ++failures > FT_SECTORS_PER_SEGMENT) {
782 TRACE_ABORT(-EIO, ft_t_err,
783 "read_id failed completely");
784 }
785 FT_SIGNAL_EXIT(_DONT_BLOCK);
786 TRACE_CATCH(ftape_report_drive_status(pstatus),);
787 TRACE(ft_t_noise, "ftape_read_id failed, retry (%d)",
788 failures);
789 continue;
790 }
791 TRACE(ft_t_noise, "ended at %d/%d (%d,%d,%d)",
792 ft_location.segment, ft_location.sector,
793 min_rewind, overshoot, inhibit_correction);
794 if (!inhibit_correction &&
795 (ft_location.segment < expected ||
796 ft_location.segment > expected + margin)) {
797 int error = expected - ft_location.segment;
798 if (short_seek) {
799 TRACE(ft_t_noise,
800 "adjusting min_rewind from %d to %d",
801 min_rewind, min_rewind + error);
802 min_rewind += error;
803 if (min_rewind < -5) {
804 /* is this right ? FIXME ! */
805 /* keep sane value */
806 min_rewind = -5;
807 TRACE(ft_t_noise,
808 "clipped min_rewind to %d",
809 min_rewind);
810 }
811 } else {
812 TRACE(ft_t_noise,
813 "adjusting overshoot from %d to %d",
814 overshoot, overshoot + error);
815 overshoot += error;
816 if (overshoot < -5 ||
817 overshoot > OVERSHOOT_LIMIT) {
818 if (overshoot < 0) {
819 /* keep sane value */
820 overshoot = -5;
821 } else {
822 /* keep sane value */
823 overshoot = OVERSHOOT_LIMIT;
824 }
825 TRACE(ft_t_noise,
826 "clipped overshoot to %d",
827 overshoot);
828 }
829 }
830 }
831 } while (ft_location.segment > segment_id);
832 if (ft_location.known) {
833 TRACE(ft_t_noise, "current location: %d/%d",
834 ft_location.segment, ft_location.sector);
835 }
836 TRACE_EXIT 0;
837}
838
839static int determine_position(void)
840{
841 int retry = 0;
842 int status;
843 int result;
844 TRACE_FUN(ft_t_flow);
845
846 if (!ftape_tape_running) {
847 /* This should only happen if tape is stopped by isr.
848 */
849 TRACE(ft_t_flow, "waiting for tape stop");
850 if (ftape_ready_wait(ftape_timeout.pause, &status) < 0) {
851 TRACE(ft_t_flow, "drive still running (fatal)");
852 ftape_tape_running = 1; /* ? */
853 }
854 } else {
855 ftape_report_drive_status(&status);
856 }
857 if (status & QIC_STATUS_READY) {
858 /* Drive must be ready to check error state !
859 */
860 TRACE(ft_t_flow, "drive is ready");
861 if (status & QIC_STATUS_ERROR) {
862 unsigned int error;
863 qic117_cmd_t command;
864
865 /* Report and clear error state, try to continue.
866 */
867 TRACE(ft_t_flow, "error status set");
868 ftape_report_error(&error, &command, 1);
869 ftape_ready_wait(ftape_timeout.reset, &status);
870 ftape_tape_running = 0; /* ? */
871 }
872 if (check_bot_eot(status)) {
873 if (ft_location.bot) {
874 if ((status & QIC_STATUS_READY) == 0) {
875 /* tape moving away from
876 * bot/eot, let's see if we
877 * can catch up with the first
878 * segment on this track.
879 */
880 } else {
881 TRACE(ft_t_flow,
882 "start tape from logical bot");
883 logical_forward(); /* start moving */
884 }
885 } else {
886 if ((status & QIC_STATUS_READY) == 0) {
887 TRACE(ft_t_noise, "waiting for logical end of track");
888 result = ftape_ready_wait(ftape_timeout.reset, &status);
889 /* error handling needed ? */
890 } else {
891 TRACE(ft_t_noise,
892 "tape at logical end of track");
893 }
894 }
895 } else {
896 TRACE(ft_t_flow, "start tape");
897 logical_forward(); /* start moving */
898 ft_location.known = 0; /* not cleared by logical forward ! */
899 }
900 }
901 /* tape should be moving now, start reading id's
902 */
903 while (!ft_location.known &&
904 retry++ < FT_SECTORS_PER_SEGMENT &&
905 (result = ftape_read_id()) < 0) {
906
907 TRACE(ft_t_flow, "location unknown");
908
909 /* exit on signal
910 */
911 FT_SIGNAL_EXIT(_DONT_BLOCK);
912
913 /* read-id somehow failed, tape may
914 * have reached end or some other
915 * error happened.
916 */
917 TRACE(ft_t_flow, "read-id failed");
918 TRACE_CATCH(ftape_report_drive_status(&status),);
919 TRACE(ft_t_err, "ftape_report_drive_status: 0x%02x", status);
920 if (status & QIC_STATUS_READY) {
921 ftape_tape_running = 0;
922 TRACE(ft_t_noise, "tape stopped for unknown reason! "
923 "status = 0x%02x", status);
924 if (status & QIC_STATUS_ERROR ||
925 !check_bot_eot(status)) {
926 /* oops, tape stopped but not at end!
927 */
928 TRACE_EXIT -EIO;
929 }
930 }
931 }
932 TRACE(ft_t_flow,
933 "tape is positioned at segment %d", ft_location.segment);
934 TRACE_EXIT ft_location.known ? 0 : -EIO;
935}
936
937/* Get the tape running and position it just before the
938 * requested segment.
939 * Seek tape-track and reposition as needed.
940 */
941int ftape_start_tape(int segment_id, int sector_offset)
942{
943 int track = segment_id / ft_segments_per_track;
944 int result = -EIO;
945 int status;
946 static int last_segment = -1;
947 static int bad_bus_timing = 0;
948 /* number of segments passing the head between starting the tape
949 * and being able to access the first sector.
950 */
951 static int start_offset = 1;
952 int retry;
953 TRACE_FUN(ft_t_flow);
954
955 /* If sector_offset > 0, seek into wanted segment instead of
956 * into previous.
957 * This allows error recovery if a part of the segment is bad
958 * (erased) causing the tape drive to generate an index pulse
959 * thus causing a no-data error before the requested sector
960 * is reached.
961 */
962 ftape_tape_running = 0;
963 TRACE(ft_t_noise, "target segment: %d/%d%s", segment_id, sector_offset,
964 ft_buffer[ft_head]->retry > 0 ? " retry" : "");
965 if (ft_buffer[ft_head]->retry > 0) { /* this is a retry */
966 int dist = segment_id - last_segment;
967
968 if ((int)ft_history.overrun_errors < overrun_count_offset) {
969 overrun_count_offset = ft_history.overrun_errors;
970 } else if (dist < 0 || dist > 50) {
971 overrun_count_offset = ft_history.overrun_errors;
972 } else if ((ft_history.overrun_errors -
973 overrun_count_offset) >= 8) {
974 if (ftape_increase_threshold() >= 0) {
975 --ft_buffer[ft_head]->retry;
976 overrun_count_offset =
977 ft_history.overrun_errors;
978 TRACE(ft_t_warn, "increased threshold because "
979 "of excessive overrun errors");
980 } else if (!bad_bus_timing && ft_data_rate >= 1000) {
981 ftape_half_data_rate();
982 --ft_buffer[ft_head]->retry;
983 bad_bus_timing = 1;
984 overrun_count_offset =
985 ft_history.overrun_errors;
986 TRACE(ft_t_warn, "reduced datarate because "
987 "of excessive overrun errors");
988 }
989 }
990 }
991 last_segment = segment_id;
992 if (ft_location.track != track ||
993 (ftape_might_be_off_track && ft_buffer[ft_head]->retry== 0)) {
994 /* current track unknown or not equal to destination
995 */
996 ftape_ready_wait(ftape_timeout.seek, &status);
997 ftape_seek_head_to_track(track);
998 /* overrun_count_offset = ft_history.overrun_errors; */
999 }
1000 result = -EIO;
1001 retry = 0;
1002 while (result < 0 &&
1003 retry++ <= 5 &&
1004 !ft_failure &&
1005 !(sigtestsetmask(&current->pending.signal, _DONT_BLOCK))) {
1006
1007 if (retry && start_offset < 5) {
1008 start_offset ++;
1009 }
1010 /* Check if we are able to catch the requested
1011 * segment in time.
1012 */
1013 if ((ft_location.known || (determine_position() == 0)) &&
1014 ft_location.segment >=
1015 (segment_id -
1016 ((ftape_tape_running || ft_location.bot)
1017 ? 0 : start_offset))) {
1018 /* Too far ahead (in or past target segment).
1019 */
1020 if (ftape_tape_running) {
1021 if ((result = ftape_stop_tape(&status)) < 0) {
1022 TRACE(ft_t_err,
1023 "stop tape failed with code %d",
1024 result);
1025 break;
1026 }
1027 TRACE(ft_t_noise, "tape stopped");
1028 ftape_tape_running = 0;
1029 }
1030 TRACE(ft_t_noise, "repositioning");
1031 ++ft_history.rewinds;
1032 if (segment_id % ft_segments_per_track < start_offset){
1033 TRACE(ft_t_noise, "end of track condition\n"
1034 KERN_INFO "segment_id : %d\n"
1035 KERN_INFO "ft_segments_per_track: %d\n"
1036 KERN_INFO "start_offset : %d",
1037 segment_id, ft_segments_per_track,
1038 start_offset);
1039
1040 /* If seeking to first segments on
1041 * track better do a complete rewind
1042 * to logical begin of track to get a
1043 * more steady tape motion.
1044 */
1045 result = ftape_command_wait(
1046 (ft_location.track & 1)
1047 ? QIC_PHYSICAL_FORWARD
1048 : QIC_PHYSICAL_REVERSE,
1049 ftape_timeout.rewind, &status);
1050 check_bot_eot(status); /* update location */
1051 } else {
1052 result= skip_reverse(segment_id - start_offset,
1053 &status);
1054 }
1055 }
1056 if (!ft_location.known) {
1057 TRACE(ft_t_bug, "panic: location not known");
1058 result = -EIO;
1059 continue; /* while() will check for failure */
1060 }
1061 TRACE(ft_t_noise, "current segment: %d/%d",
1062 ft_location.segment, ft_location.sector);
1063 /* We're on the right track somewhere before the
1064 * wanted segment. Start tape movement if needed and
1065 * skip to just before or inside the requested
1066 * segment. Keep tape running.
1067 */
1068 result = 0;
1069 if (ft_location.segment <
1070 (segment_id - ((ftape_tape_running || ft_location.bot)
1071 ? 0 : start_offset))) {
1072 if (sector_offset > 0) {
1073 result = seek_forward(segment_id,
1074 retry <= 3);
1075 } else {
1076 result = seek_forward(segment_id - 1,
1077 retry <= 3);
1078 }
1079 }
1080 if (result == 0 &&
1081 ft_location.segment !=
1082 (segment_id - (sector_offset > 0 ? 0 : 1))) {
1083 result = -EIO;
1084 }
1085 }
1086 if (result < 0) {
1087 TRACE(ft_t_err, "failed to reposition");
1088 } else {
1089 ft_runner_status = running;
1090 }
1091 TRACE_EXIT result;
1092}
diff --git a/drivers/char/ftape/lowlevel/ftape-rw.h b/drivers/char/ftape/lowlevel/ftape-rw.h
deleted file mode 100644
index 32f4feeb887c..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-rw.h
+++ /dev/null
@@ -1,111 +0,0 @@
1#ifndef _FTAPE_RW_H
2#define _FTAPE_RW_H
3
4/*
5 * Copyright (C) 1993-1996 Bas Laarhoven,
6 * (C) 1996-1997 Claus-Justus Heine.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; see the file COPYING. If not, write to
20 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21
22 *
23 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-rw.h,v $
24 * $Revision: 1.2 $
25 * $Date: 1997/10/05 19:18:25 $
26 *
27 * This file contains the definitions for the read and write
28 * functions for the QIC-117 floppy-tape driver for Linux.
29 *
30 * Claus-Justus Heine (1996/09/20): Add definition of format code 6
31 * Claus-Justus Heine (1996/10/04): Changed GET/PUT macros to cast to (__u8 *)
32 *
33 */
34
35#include "../lowlevel/fdc-io.h"
36#include "../lowlevel/ftape-init.h"
37#include "../lowlevel/ftape-bsm.h"
38
39#include <asm/unaligned.h>
40
41#define GET2(address, offset) get_unaligned((__u16*)((__u8 *)address + offset))
42#define GET4(address, offset) get_unaligned((__u32*)((__u8 *)address + offset))
43#define GET8(address, offset) get_unaligned((__u64*)((__u8 *)address + offset))
44#define PUT2(address, offset , value) put_unaligned((value), (__u16*)((__u8 *)address + offset))
45#define PUT4(address, offset , value) put_unaligned((value), (__u32*)((__u8 *)address + offset))
46#define PUT8(address, offset , value) put_unaligned((value), (__u64*)((__u8 *)address + offset))
47
48enum runner_status_enum {
49 idle = 0,
50 running,
51 do_abort,
52 aborting,
53 logical_eot,
54 end_of_tape,
55};
56
57typedef enum ft_buffer_queue {
58 ft_queue_head = 0,
59 ft_queue_tail = 1
60} ft_buffer_queue_t;
61
62
63typedef struct {
64 int track; /* tape head position */
65 volatile int segment; /* current segment */
66 volatile int sector; /* sector offset within current segment */
67 volatile unsigned int bot; /* logical begin of track */
68 volatile unsigned int eot; /* logical end of track */
69 volatile unsigned int known; /* validates bot, segment, sector */
70} location_record;
71
72/* Count nr of 1's in pattern.
73 */
74static inline int count_ones(unsigned long mask)
75{
76 int bits;
77
78 for (bits = 0; mask != 0; mask >>= 1) {
79 if (mask & 1) {
80 ++bits;
81 }
82 }
83 return bits;
84}
85
86#define FT_MAX_NR_BUFFERS 16 /* arbitrary value */
87/* ftape-rw.c defined global vars.
88 */
89extern buffer_struct *ft_buffer[FT_MAX_NR_BUFFERS];
90extern int ft_nr_buffers;
91extern location_record ft_location;
92extern volatile int ftape_tape_running;
93
94/* ftape-rw.c defined global functions.
95 */
96extern int ftape_setup_new_segment(buffer_struct * buff,
97 int segment_id,
98 int offset);
99extern int ftape_calc_next_cluster(buffer_struct * buff);
100extern buffer_struct *ftape_next_buffer (ft_buffer_queue_t pos);
101extern buffer_struct *ftape_get_buffer (ft_buffer_queue_t pos);
102extern int ftape_buffer_id (ft_buffer_queue_t pos);
103extern void ftape_reset_buffer(void);
104extern void ftape_tape_parameters(__u8 drive_configuration);
105extern int ftape_wait_segment(buffer_state_enum state);
106extern int ftape_dumb_stop(void);
107extern int ftape_start_tape(int segment_id, int offset);
108extern int ftape_stop_tape(int *pstatus);
109extern int ftape_handle_logical_eot(void);
110extern buffer_state_enum ftape_set_state(buffer_state_enum new_state);
111#endif /* _FTAPE_RW_H */
diff --git a/drivers/char/ftape/lowlevel/ftape-setup.c b/drivers/char/ftape/lowlevel/ftape-setup.c
deleted file mode 100644
index 678340acd0b7..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-setup.c
+++ /dev/null
@@ -1,104 +0,0 @@
1/*
2 * Copyright (C) 1996, 1997 Claus-Justus Heine.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 *
19 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-setup.c,v $
20 * $Revision: 1.7 $
21 * $Date: 1997/10/10 09:57:06 $
22 *
23 * This file contains the code for processing the kernel command
24 * line options for the QIC-40/80/3010/3020 floppy-tape driver
25 * "ftape" for Linux.
26 */
27
28#include <linux/string.h>
29#include <linux/errno.h>
30#include <linux/mm.h>
31
32#include <linux/ftape.h>
33#include <linux/init.h>
34#include "../lowlevel/ftape-tracing.h"
35#include "../lowlevel/fdc-io.h"
36
37static struct param_table {
38 const char *name;
39 int *var;
40 int def_param;
41 int min;
42 int max;
43} config_params[] __initdata = {
44#ifndef CONFIG_FT_NO_TRACE_AT_ALL
45 { "tracing", &ftape_tracing, 3, ft_t_bug, ft_t_any},
46#endif
47 { "ioport", &ft_fdc_base, CONFIG_FT_FDC_BASE, 0x0, 0xfff},
48 { "irq", &ft_fdc_irq, CONFIG_FT_FDC_IRQ, 2, 15},
49 { "dma", &ft_fdc_dma, CONFIG_FT_FDC_DMA, 0, 3},
50 { "threshold", &ft_fdc_threshold, CONFIG_FT_FDC_THR, 1, 16},
51 { "datarate", &ft_fdc_rate_limit, CONFIG_FT_FDC_MAX_RATE, 500, 2000},
52 { "fc10", &ft_probe_fc10, CONFIG_FT_PROBE_FC10, 0, 1},
53 { "mach2", &ft_mach2, CONFIG_FT_MACH2, 0, 1}
54};
55
56static int __init ftape_setup(char *str)
57{
58 int i;
59 int param;
60 int ints[2];
61
62 TRACE_FUN(ft_t_flow);
63
64 str = get_options(str, ARRAY_SIZE(ints), ints);
65 if (str) {
66 for (i=0; i < NR_ITEMS(config_params); i++) {
67 if (strcmp(str,config_params[i].name) == 0){
68 if (ints[0]) {
69 param = ints[1];
70 } else {
71 param = config_params[i].def_param;
72 }
73 if (param < config_params[i].min ||
74 param > config_params[i].max) {
75 TRACE(ft_t_err,
76 "parameter %s out of range %d ... %d",
77 config_params[i].name,
78 config_params[i].min,
79 config_params[i].max);
80 goto out;
81 }
82 if(config_params[i].var) {
83 TRACE(ft_t_info, "%s=%d", str, param);
84 *config_params[i].var = param;
85 }
86 goto out;
87 }
88 }
89 }
90 if (str) {
91 TRACE(ft_t_err, "unknown ftape option [%s]", str);
92
93 TRACE(ft_t_err, "allowed options are:");
94 for (i=0; i < NR_ITEMS(config_params); i++) {
95 TRACE(ft_t_err, " %s",config_params[i].name);
96 }
97 } else {
98 TRACE(ft_t_err, "botched ftape option");
99 }
100 out:
101 TRACE_EXIT 1;
102}
103
104__setup("ftape=", ftape_setup);
diff --git a/drivers/char/ftape/lowlevel/ftape-tracing.c b/drivers/char/ftape/lowlevel/ftape-tracing.c
deleted file mode 100644
index 7fdc6567440b..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-tracing.c
+++ /dev/null
@@ -1,118 +0,0 @@
1/*
2 * Copyright (C) 1993-1996 Bas Laarhoven,
3 * (C) 1996-1997 Claus-Justus Heine.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
8 any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; see the file COPYING. If not, write to
17 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 *
20 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-tracing.c,v $
21 * $Revision: 1.2 $
22 * $Date: 1997/10/05 19:18:27 $
23 *
24 * This file contains the reading code
25 * for the QIC-117 floppy-tape driver for Linux.
26 */
27
28#include <linux/ftape.h>
29#include "../lowlevel/ftape-tracing.h"
30
31/* Global vars.
32 */
33/* tracing
34 * set it to: to log :
35 * 0 bugs
36 * 1 + errors
37 * 2 + warnings
38 * 3 + information
39 * 4 + more information
40 * 5 + program flow
41 * 6 + fdc/dma info
42 * 7 + data flow
43 * 8 + everything else
44 */
45ft_trace_t ftape_tracing = ft_t_info; /* Default level: information and up */
46int ftape_function_nest_level;
47
48/* Local vars.
49 */
50static __u8 trace_id;
51static char spacing[] = "* ";
52
53void ftape_trace_call(const char *file, const char *name)
54{
55 char *indent;
56
57 /* Since printk seems not to work with "%*s" format
58 * we'll use this work-around.
59 */
60 if (ftape_function_nest_level < 0) {
61 printk(KERN_INFO "function nest level (%d) < 0\n",
62 ftape_function_nest_level);
63 ftape_function_nest_level = 0;
64 }
65 if (ftape_function_nest_level < sizeof(spacing)) {
66 indent = (spacing +
67 sizeof(spacing) - 1 -
68 ftape_function_nest_level);
69 } else {
70 indent = spacing;
71 }
72 printk(KERN_INFO "[%03d]%s+%s (%s)\n",
73 (int) trace_id++, indent, file, name);
74}
75
76void ftape_trace_exit(const char *file, const char *name)
77{
78 char *indent;
79
80 /* Since printk seems not to work with "%*s" format
81 * we'll use this work-around.
82 */
83 if (ftape_function_nest_level < 0) {
84 printk(KERN_INFO "function nest level (%d) < 0\n", ftape_function_nest_level);
85 ftape_function_nest_level = 0;
86 }
87 if (ftape_function_nest_level < sizeof(spacing)) {
88 indent = (spacing +
89 sizeof(spacing) - 1 -
90 ftape_function_nest_level);
91 } else {
92 indent = spacing;
93 }
94 printk(KERN_INFO "[%03d]%s-%s (%s)\n",
95 (int) trace_id++, indent, file, name);
96}
97
98void ftape_trace_log(const char *file, const char *function)
99{
100 char *indent;
101
102 /* Since printk seems not to work with "%*s" format
103 * we'll use this work-around.
104 */
105 if (ftape_function_nest_level < 0) {
106 printk(KERN_INFO "function nest level (%d) < 0\n", ftape_function_nest_level);
107 ftape_function_nest_level = 0;
108 }
109 if (ftape_function_nest_level < sizeof(spacing)) {
110 indent = (spacing +
111 sizeof(spacing) - 1 -
112 ftape_function_nest_level);
113 } else {
114 indent = spacing;
115 }
116 printk(KERN_INFO "[%03d]%s%s (%s) - ",
117 (int) trace_id++, indent, file, function);
118}
diff --git a/drivers/char/ftape/lowlevel/ftape-tracing.h b/drivers/char/ftape/lowlevel/ftape-tracing.h
deleted file mode 100644
index 2950810c7085..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-tracing.h
+++ /dev/null
@@ -1,179 +0,0 @@
1#ifndef _FTAPE_TRACING_H
2#define _FTAPE_TRACING_H
3
4/*
5 * Copyright (C) 1994-1996 Bas Laarhoven,
6 * (C) 1996-1997 Claus-Justus Heine.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; see the file COPYING. If not, write to
20 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21
22 *
23 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-tracing.h,v $
24 * $Revision: 1.2 $
25 * $Date: 1997/10/05 19:18:28 $
26 *
27 * This file contains definitions that eases the debugging of the
28 * QIC-40/80/3010/3020 floppy-tape driver "ftape" for Linux.
29 */
30
31#include <linux/kernel.h>
32
33/*
34 * Be very careful with TRACE_EXIT and TRACE_ABORT.
35 *
36 * if (something) TRACE_EXIT error;
37 *
38 * will NOT work. Use
39 *
40 * if (something) {
41 * TRACE_EXIT error;
42 * }
43 *
44 * instead. Maybe a bit dangerous, but save lots of lines of code.
45 */
46
47#define LL_X "%d/%d KB"
48#define LL(x) (unsigned int)((__u64)(x)>>10), (unsigned int)((x)&1023)
49
50typedef enum {
51 ft_t_nil = -1,
52 ft_t_bug,
53 ft_t_err,
54 ft_t_warn,
55 ft_t_info,
56 ft_t_noise,
57 ft_t_flow,
58 ft_t_fdc_dma,
59 ft_t_data_flow,
60 ft_t_any
61} ft_trace_t;
62
63#ifdef CONFIG_FT_NO_TRACE_AT_ALL
64/* the compiler will optimize away most TRACE() macros
65 */
66#define FT_TRACE_TOP_LEVEL ft_t_bug
67#define TRACE_FUN(level) do {} while(0)
68#define TRACE_EXIT return
69#define TRACE(l, m, i...) \
70{ \
71 if ((ft_trace_t)(l) == FT_TRACE_TOP_LEVEL) { \
72 printk(KERN_INFO"ftape%s(%s):\n" \
73 KERN_INFO m".\n" ,__FILE__, __FUNCTION__ , ##i); \
74 } \
75}
76#define SET_TRACE_LEVEL(l) if ((l) == (l)) do {} while(0)
77#define TRACE_LEVEL FT_TRACE_TOP_LEVEL
78
79#else
80
81#ifdef CONFIG_FT_NO_TRACE
82/* the compiler will optimize away many TRACE() macros
83 * the ftape_simple_trace_call() function simply increments
84 * the function nest level.
85 */
86#define FT_TRACE_TOP_LEVEL ft_t_warn
87#define TRACE_FUN(level) ftape_function_nest_level++
88#define TRACE_EXIT ftape_function_nest_level--; return
89
90#else
91#ifdef CONFIG_FT_FULL_DEBUG
92#define FT_TRACE_TOP_LEVEL ft_t_any
93#else
94#define FT_TRACE_TOP_LEVEL ft_t_flow
95#endif
96#define TRACE_FUN(level) \
97 const ft_trace_t _tracing = level; \
98 if (ftape_tracing >= (ft_trace_t)(level) && \
99 (ft_trace_t)(level) <= FT_TRACE_TOP_LEVEL) \
100 ftape_trace_call(__FILE__, __FUNCTION__); \
101 ftape_function_nest_level ++;
102
103#define TRACE_EXIT \
104 --ftape_function_nest_level; \
105 if (ftape_tracing >= (ft_trace_t)(_tracing) && \
106 (ft_trace_t)(_tracing) <= FT_TRACE_TOP_LEVEL) \
107 ftape_trace_exit(__FILE__, __FUNCTION__); \
108 return
109
110#endif
111
112#define TRACE(l, m, i...) \
113{ \
114 if (ftape_tracing >= (ft_trace_t)(l) && \
115 (ft_trace_t)(l) <= FT_TRACE_TOP_LEVEL) { \
116 ftape_trace_log(__FILE__, __FUNCTION__); \
117 printk(m".\n" ,##i); \
118 } \
119}
120
121#define SET_TRACE_LEVEL(l) \
122{ \
123 if ((ft_trace_t)(l) <= FT_TRACE_TOP_LEVEL) { \
124 ftape_tracing = (ft_trace_t)(l); \
125 } else { \
126 ftape_tracing = FT_TRACE_TOP_LEVEL; \
127 } \
128}
129#define TRACE_LEVEL \
130((ftape_tracing <= FT_TRACE_TOP_LEVEL) ? ftape_tracing : FT_TRACE_TOP_LEVEL)
131
132
133/* Global variables declared in tracing.c
134 */
135extern ft_trace_t ftape_tracing; /* sets default level */
136extern int ftape_function_nest_level;
137
138/* Global functions declared in tracing.c
139 */
140extern void ftape_trace_call(const char *file, const char *name);
141extern void ftape_trace_exit(const char *file, const char *name);
142extern void ftape_trace_log (const char *file, const char *name);
143
144#endif /* !defined(CONFIG_FT_NO_TRACE_AT_ALL) */
145
146/*
147 * Abort with a message.
148 */
149#define TRACE_ABORT(res, i...) \
150{ \
151 TRACE(i); \
152 TRACE_EXIT res; \
153}
154
155/* The following transforms the common "if(result < 0) ... " into a
156 * one-liner.
157 */
158#define _TRACE_CATCH(level, fun, action) \
159{ \
160 int _res = (fun); \
161 if (_res < 0) { \
162 do { action /* */ ; } while(0); \
163 TRACE_ABORT(_res, level, "%s failed: %d", #fun, _res); \
164 } \
165}
166
167#define TRACE_CATCH(fun, fail) _TRACE_CATCH(ft_t_err, fun, fail)
168
169/* Abort the current function when signalled. This doesn't belong here,
170 * but rather into ftape-rw.h (maybe)
171 */
172#define FT_SIGNAL_EXIT(sig_mask) \
173 if (sigtestsetmask(&current->pending.signal, sig_mask)) { \
174 TRACE_ABORT(-EINTR, \
175 ft_t_warn, \
176 "interrupted by non-blockable signal"); \
177 }
178
179#endif /* _FTAPE_TRACING_H */
diff --git a/drivers/char/ftape/lowlevel/ftape-write.c b/drivers/char/ftape/lowlevel/ftape-write.c
deleted file mode 100644
index 45601ec801ee..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-write.c
+++ /dev/null
@@ -1,336 +0,0 @@
1/*
2 * Copyright (C) 1993-1995 Bas Laarhoven,
3 * (C) 1996-1997 Claus-Justus Heine.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
8 any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; see the file COPYING. If not, write to
17 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 *
20 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-write.c,v $
21 * $Revision: 1.3.4.1 $
22 * $Date: 1997/11/14 18:07:04 $
23 *
24 * This file contains the writing code
25 * for the QIC-117 floppy-tape driver for Linux.
26 */
27
28#include <linux/string.h>
29#include <linux/errno.h>
30#include <linux/mm.h>
31
32#include <linux/ftape.h>
33#include <linux/qic117.h>
34#include "../lowlevel/ftape-tracing.h"
35#include "../lowlevel/ftape-write.h"
36#include "../lowlevel/ftape-read.h"
37#include "../lowlevel/ftape-io.h"
38#include "../lowlevel/ftape-ctl.h"
39#include "../lowlevel/ftape-rw.h"
40#include "../lowlevel/ftape-ecc.h"
41#include "../lowlevel/ftape-bsm.h"
42#include "../lowlevel/fdc-isr.h"
43
44/* Global vars.
45 */
46
47/* Local vars.
48 */
49static int last_write_failed;
50
51void ftape_zap_write_buffers(void)
52{
53 int i;
54
55 for (i = 0; i < ft_nr_buffers; ++i) {
56 ft_buffer[i]->status = done;
57 }
58 ftape_reset_buffer();
59}
60
61static int copy_and_gen_ecc(void *destination,
62 const void *source,
63 const SectorMap bad_sector_map)
64{
65 int result;
66 struct memory_segment mseg;
67 int bads = count_ones(bad_sector_map);
68 TRACE_FUN(ft_t_any);
69
70 if (bads > 0) {
71 TRACE(ft_t_noise, "bad sectors in map: %d", bads);
72 }
73 if (bads + 3 >= FT_SECTORS_PER_SEGMENT) {
74 TRACE(ft_t_noise, "empty segment");
75 mseg.blocks = 0; /* skip entire segment */
76 result = 0; /* nothing written */
77 } else {
78 mseg.blocks = FT_SECTORS_PER_SEGMENT - bads;
79 mseg.data = destination;
80 memcpy(mseg.data, source, (mseg.blocks - 3) * FT_SECTOR_SIZE);
81 result = ftape_ecc_set_segment_parity(&mseg);
82 if (result < 0) {
83 TRACE(ft_t_err, "ecc_set_segment_parity failed");
84 } else {
85 result = (mseg.blocks - 3) * FT_SECTOR_SIZE;
86 }
87 }
88 TRACE_EXIT result;
89}
90
91
92int ftape_start_writing(const ft_write_mode_t mode)
93{
94 buffer_struct *head = ftape_get_buffer(ft_queue_head);
95 int segment_id = head->segment_id;
96 int result;
97 buffer_state_enum wanted_state = (mode == FT_WR_DELETE
98 ? deleting
99 : writing);
100 TRACE_FUN(ft_t_flow);
101
102 if ((ft_driver_state != wanted_state) || head->status != waiting) {
103 TRACE_EXIT 0;
104 }
105 ftape_setup_new_segment(head, segment_id, 1);
106 if (mode == FT_WR_SINGLE) {
107 /* stop tape instead of pause */
108 head->next_segment = 0;
109 }
110 ftape_calc_next_cluster(head); /* prepare */
111 head->status = ft_driver_state; /* either writing or deleting */
112 if (ft_runner_status == idle) {
113 TRACE(ft_t_noise,
114 "starting runner for segment %d", segment_id);
115 TRACE_CATCH(ftape_start_tape(segment_id,head->sector_offset),);
116 } else {
117 TRACE(ft_t_noise, "runner not idle, not starting tape");
118 }
119 /* go */
120 result = fdc_setup_read_write(head, (mode == FT_WR_DELETE
121 ? FDC_WRITE_DELETED : FDC_WRITE));
122 ftape_set_state(wanted_state); /* should not be necessary */
123 TRACE_EXIT result;
124}
125
126/* Wait until all data is actually written to tape.
127 *
128 * There is a problem: when the tape runs into logical EOT, then this
129 * failes. We need to restart the runner in this case.
130 */
131int ftape_loop_until_writes_done(void)
132{
133 buffer_struct *head;
134 TRACE_FUN(ft_t_flow);
135
136 while ((ft_driver_state == writing || ft_driver_state == deleting) &&
137 ftape_get_buffer(ft_queue_head)->status != done) {
138 /* set the runner status to idle if at lEOT */
139 TRACE_CATCH(ftape_handle_logical_eot(), last_write_failed = 1);
140 /* restart the tape if necessary */
141 if (ft_runner_status == idle) {
142 TRACE(ft_t_noise, "runner is idle, restarting");
143 if (ft_driver_state == deleting) {
144 TRACE_CATCH(ftape_start_writing(FT_WR_DELETE),
145 last_write_failed = 1);
146 } else {
147 TRACE_CATCH(ftape_start_writing(FT_WR_MULTI),
148 last_write_failed = 1);
149 }
150 }
151 TRACE(ft_t_noise, "tail: %d, head: %d",
152 ftape_buffer_id(ft_queue_tail),
153 ftape_buffer_id(ft_queue_head));
154 TRACE_CATCH(fdc_interrupt_wait(5 * FT_SECOND),
155 last_write_failed = 1);
156 head = ftape_get_buffer(ft_queue_head);
157 if (head->status == error) {
158 /* Allow escape from loop when signaled !
159 */
160 FT_SIGNAL_EXIT(_DONT_BLOCK);
161 if (head->hard_error_map != 0) {
162 /* Implement hard write error recovery here
163 */
164 }
165 /* retry this one */
166 head->status = waiting;
167 if (ft_runner_status == aborting) {
168 ftape_dumb_stop();
169 }
170 if (ft_runner_status != idle) {
171 TRACE_ABORT(-EIO, ft_t_err,
172 "unexpected state: "
173 "ft_runner_status != idle");
174 }
175 ftape_start_writing(ft_driver_state == deleting
176 ? FT_WR_MULTI : FT_WR_DELETE);
177 }
178 TRACE(ft_t_noise, "looping until writes done");
179 }
180 ftape_set_state(idle);
181 TRACE_EXIT 0;
182}
183
184/* Write given segment from buffer at address to tape.
185 */
186static int write_segment(const int segment_id,
187 const void *address,
188 const ft_write_mode_t write_mode)
189{
190 int bytes_written = 0;
191 buffer_struct *tail;
192 buffer_state_enum wanted_state = (write_mode == FT_WR_DELETE
193 ? deleting : writing);
194 TRACE_FUN(ft_t_flow);
195
196 TRACE(ft_t_noise, "segment_id = %d", segment_id);
197 if (ft_driver_state != wanted_state) {
198 if (ft_driver_state == deleting ||
199 wanted_state == deleting) {
200 TRACE_CATCH(ftape_loop_until_writes_done(),);
201 }
202 TRACE(ft_t_noise, "calling ftape_abort_operation");
203 TRACE_CATCH(ftape_abort_operation(),);
204 ftape_zap_write_buffers();
205 ftape_set_state(wanted_state);
206 }
207 /* if all buffers full we'll have to wait...
208 */
209 ftape_wait_segment(wanted_state);
210 tail = ftape_get_buffer(ft_queue_tail);
211 switch(tail->status) {
212 case done:
213 ft_history.defects += count_ones(tail->hard_error_map);
214 break;
215 case waiting:
216 /* this could happen with multiple EMPTY_SEGMENTs, but
217 * shouldn't happen any more as we re-start the runner even
218 * with an empty segment.
219 */
220 bytes_written = -EAGAIN;
221 break;
222 case error:
223 /* setup for a retry
224 */
225 tail->status = waiting;
226 bytes_written = -EAGAIN; /* force retry */
227 if (tail->hard_error_map != 0) {
228 TRACE(ft_t_warn,
229 "warning: %d hard error(s) in written segment",
230 count_ones(tail->hard_error_map));
231 TRACE(ft_t_noise, "hard_error_map = 0x%08lx",
232 (long)tail->hard_error_map);
233 /* Implement hard write error recovery here
234 */
235 }
236 break;
237 default:
238 TRACE_ABORT(-EIO, ft_t_err,
239 "wait for empty segment failed, tail status: %d",
240 tail->status);
241 }
242 /* should runner stop ?
243 */
244 if (ft_runner_status == aborting) {
245 buffer_struct *head = ftape_get_buffer(ft_queue_head);
246 if (head->status == wanted_state) {
247 head->status = done; /* ???? */
248 }
249 /* don't call abort_operation(), we don't want to zap
250 * the dma buffers
251 */
252 TRACE_CATCH(ftape_dumb_stop(),);
253 } else {
254 /* If just passed last segment on tape: wait for BOT
255 * or EOT mark. Sets ft_runner_status to idle if at lEOT
256 * and successful
257 */
258 TRACE_CATCH(ftape_handle_logical_eot(),);
259 }
260 if (tail->status == done) {
261 /* now at least one buffer is empty, fill it with our
262 * data. skip bad sectors and generate ecc.
263 * copy_and_gen_ecc return nr of bytes written, range
264 * 0..29 Kb inclusive!
265 *
266 * Empty segments are handled inside coyp_and_gen_ecc()
267 */
268 if (write_mode != FT_WR_DELETE) {
269 TRACE_CATCH(bytes_written = copy_and_gen_ecc(
270 tail->address, address,
271 ftape_get_bad_sector_entry(segment_id)),);
272 }
273 tail->segment_id = segment_id;
274 tail->status = waiting;
275 tail = ftape_next_buffer(ft_queue_tail);
276 }
277 /* Start tape only if all buffers full or flush mode.
278 * This will give higher probability of streaming.
279 */
280 if (ft_runner_status != running &&
281 ((tail->status == waiting &&
282 ftape_get_buffer(ft_queue_head) == tail) ||
283 write_mode != FT_WR_ASYNC)) {
284 TRACE_CATCH(ftape_start_writing(write_mode),);
285 }
286 TRACE_EXIT bytes_written;
287}
288
289/* Write as much as fits from buffer to the given segment on tape
290 * and handle retries.
291 * Return the number of bytes written (>= 0), or:
292 * -EIO write failed
293 * -EINTR interrupted by signal
294 * -ENOSPC device full
295 */
296int ftape_write_segment(const int segment_id,
297 const void *buffer,
298 const ft_write_mode_t flush)
299{
300 int retry = 0;
301 int result;
302 TRACE_FUN(ft_t_flow);
303
304 ft_history.used |= 2;
305 if (segment_id >= ft_tracks_per_tape*ft_segments_per_track) {
306 /* tape full */
307 TRACE_ABORT(-ENOSPC, ft_t_err,
308 "invalid segment id: %d (max %d)",
309 segment_id,
310 ft_tracks_per_tape * ft_segments_per_track -1);
311 }
312 for (;;) {
313 if ((result = write_segment(segment_id, buffer, flush)) >= 0) {
314 if (result == 0) { /* empty segment */
315 TRACE(ft_t_noise,
316 "empty segment, nothing written");
317 }
318 TRACE_EXIT result;
319 }
320 if (result == -EAGAIN) {
321 if (++retry > 100) { /* give up */
322 TRACE_ABORT(-EIO, ft_t_err,
323 "write failed, >100 retries in segment");
324 }
325 TRACE(ft_t_warn, "write error, retry %d (%d)",
326 retry,
327 ftape_get_buffer(ft_queue_tail)->segment_id);
328 } else {
329 TRACE_ABORT(result, ft_t_err,
330 "write_segment failed, error: %d", result);
331 }
332 /* Allow escape from loop when signaled !
333 */
334 FT_SIGNAL_EXIT(_DONT_BLOCK);
335 }
336}
diff --git a/drivers/char/ftape/lowlevel/ftape-write.h b/drivers/char/ftape/lowlevel/ftape-write.h
deleted file mode 100644
index 0e7f898b7af9..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-write.h
+++ /dev/null
@@ -1,53 +0,0 @@
1#ifndef _FTAPE_WRITE_H
2#define _FTAPE_WRITE_H
3
4/*
5 * Copyright (C) 1994-1995 Bas Laarhoven,
6 * (C) 1996-1997 Claus-Justus Heine.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; see the file COPYING. If not, write to
20 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21
22 *
23 $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-write.h,v $
24 $Author: claus $
25 *
26 $Revision: 1.2 $
27 $Date: 1997/10/05 19:18:30 $
28 $State: Exp $
29 *
30 * This file contains the definitions for the write functions
31 * for the QIC-117 floppy-tape driver for Linux.
32 *
33 */
34
35
36/* ftape-write.c defined global functions.
37 */
38typedef enum {
39 FT_WR_ASYNC = 0, /* start tape only when all buffers are full */
40 FT_WR_MULTI = 1, /* start tape, but don't necessarily stop */
41 FT_WR_SINGLE = 2, /* write a single segment and stop afterwards */
42 FT_WR_DELETE = 3 /* write deleted data marks */
43} ft_write_mode_t;
44
45extern int ftape_start_writing(const ft_write_mode_t mode);
46extern int ftape_write_segment(const int segment,
47 const void *address,
48 const ft_write_mode_t flushing);
49extern void ftape_zap_write_buffers(void);
50extern int ftape_loop_until_writes_done(void);
51
52#endif /* _FTAPE_WRITE_H */
53
diff --git a/drivers/char/ftape/lowlevel/ftape_syms.c b/drivers/char/ftape/lowlevel/ftape_syms.c
deleted file mode 100644
index 8e0dc4a07ca6..000000000000
--- a/drivers/char/ftape/lowlevel/ftape_syms.c
+++ /dev/null
@@ -1,87 +0,0 @@
1/*
2 * Copyright (C) 1996-1997 Claus-Justus Heine
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 *
19 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape_syms.c,v $
20 * $Revision: 1.4 $
21 * $Date: 1997/10/17 00:03:51 $
22 *
23 * This file contains the symbols that the ftape low level
24 * part of the QIC-40/80/3010/3020 floppy-tape driver "ftape"
25 * exports to its high level clients
26 */
27
28#include <linux/module.h>
29
30#include <linux/ftape.h>
31#include "../lowlevel/ftape-tracing.h"
32#include "../lowlevel/ftape-init.h"
33#include "../lowlevel/fdc-io.h"
34#include "../lowlevel/ftape-read.h"
35#include "../lowlevel/ftape-write.h"
36#include "../lowlevel/ftape-io.h"
37#include "../lowlevel/ftape-ctl.h"
38#include "../lowlevel/ftape-rw.h"
39#include "../lowlevel/ftape-bsm.h"
40#include "../lowlevel/ftape-buffer.h"
41#include "../lowlevel/ftape-format.h"
42
43/* bad sector handling from ftape-bsm.c */
44EXPORT_SYMBOL(ftape_get_bad_sector_entry);
45EXPORT_SYMBOL(ftape_find_end_of_bsm_list);
46/* from ftape-rw.c */
47EXPORT_SYMBOL(ftape_set_state);
48/* from ftape-ctl.c */
49EXPORT_SYMBOL(ftape_seek_to_bot);
50EXPORT_SYMBOL(ftape_seek_to_eot);
51EXPORT_SYMBOL(ftape_abort_operation);
52EXPORT_SYMBOL(ftape_get_status);
53EXPORT_SYMBOL(ftape_enable);
54EXPORT_SYMBOL(ftape_disable);
55EXPORT_SYMBOL(ftape_mmap);
56EXPORT_SYMBOL(ftape_calibrate_data_rate);
57/* from ftape-io.c */
58EXPORT_SYMBOL(ftape_reset_drive);
59EXPORT_SYMBOL(ftape_command);
60EXPORT_SYMBOL(ftape_parameter);
61EXPORT_SYMBOL(ftape_ready_wait);
62EXPORT_SYMBOL(ftape_report_operation);
63EXPORT_SYMBOL(ftape_report_error);
64/* from ftape-read.c */
65EXPORT_SYMBOL(ftape_read_segment_fraction);
66EXPORT_SYMBOL(ftape_zap_read_buffers);
67EXPORT_SYMBOL(ftape_read_header_segment);
68EXPORT_SYMBOL(ftape_decode_header_segment);
69/* from ftape-write.c */
70EXPORT_SYMBOL(ftape_write_segment);
71EXPORT_SYMBOL(ftape_start_writing);
72EXPORT_SYMBOL(ftape_loop_until_writes_done);
73/* from ftape-buffer.h */
74EXPORT_SYMBOL(ftape_set_nr_buffers);
75/* from ftape-format.h */
76EXPORT_SYMBOL(ftape_format_track);
77EXPORT_SYMBOL(ftape_format_status);
78EXPORT_SYMBOL(ftape_verify_segment);
79/* from tracing.c */
80#ifndef CONFIG_FT_NO_TRACE_AT_ALL
81EXPORT_SYMBOL(ftape_tracing);
82EXPORT_SYMBOL(ftape_function_nest_level);
83EXPORT_SYMBOL(ftape_trace_call);
84EXPORT_SYMBOL(ftape_trace_exit);
85EXPORT_SYMBOL(ftape_trace_log);
86#endif
87
diff --git a/drivers/char/ftape/zftape/Makefile b/drivers/char/ftape/zftape/Makefile
deleted file mode 100644
index 6d91c1f77c05..000000000000
--- a/drivers/char/ftape/zftape/Makefile
+++ /dev/null
@@ -1,36 +0,0 @@
1#
2# Copyright (C) 1996, 1997 Claus-Justus Heine.
3#
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 2, or (at your option)
7# any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program; see the file COPYING. If not, write to
16# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17#
18# $Source: /homes/cvs/ftape-stacked/ftape/zftape/Makefile,v $
19# $Revision: 1.4 $
20# $Date: 1997/10/05 19:18:58 $
21#
22# Makefile for the QIC-40/80/3010/3020 zftape interface VFS to
23# ftape
24#
25
26
27# ZFT_OBSOLETE - enable the MTIOC_ZFTAPE_GETBLKSZ ioctl. You should
28# leave this enabled for compatibility with taper.
29
30obj-$(CONFIG_ZFTAPE) += zftape.o
31
32zftape-objs := zftape-rw.o zftape-ctl.o zftape-read.o \
33 zftape-write.o zftape-vtbl.o zftape-eof.o \
34 zftape-init.o zftape-buffers.o zftape_syms.o
35
36EXTRA_CFLAGS := -DZFT_OBSOLETE
diff --git a/drivers/char/ftape/zftape/zftape-buffers.c b/drivers/char/ftape/zftape/zftape-buffers.c
deleted file mode 100644
index da06f138334e..000000000000
--- a/drivers/char/ftape/zftape/zftape-buffers.c
+++ /dev/null
@@ -1,149 +0,0 @@
1/*
2 * Copyright (C) 1995-1997 Claus-Justus Heine.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 *
19 * $Source: /homes/cvs/ftape-stacked/ftape/zftape/zftape-buffers.c,v $
20 * $Revision: 1.2 $
21 * $Date: 1997/10/05 19:18:59 $
22 *
23 * This file contains the dynamic buffer allocation routines
24 * of zftape
25 */
26
27#include <linux/errno.h>
28#include <linux/mm.h>
29#include <linux/slab.h>
30#include <linux/delay.h>
31
32#include <linux/zftape.h>
33
34#include <linux/vmalloc.h>
35
36#include "../zftape/zftape-init.h"
37#include "../zftape/zftape-eof.h"
38#include "../zftape/zftape-ctl.h"
39#include "../zftape/zftape-write.h"
40#include "../zftape/zftape-read.h"
41#include "../zftape/zftape-rw.h"
42#include "../zftape/zftape-vtbl.h"
43
44/* global variables
45 */
46
47/* local varibales
48 */
49static unsigned int used_memory;
50static unsigned int peak_memory;
51
52void zft_memory_stats(void)
53{
54 TRACE_FUN(ft_t_flow);
55
56 TRACE(ft_t_noise, "Memory usage (vmalloc allocations):\n"
57 KERN_INFO "total allocated: %d\n"
58 KERN_INFO "peak allocation: %d",
59 used_memory, peak_memory);
60 peak_memory = used_memory;
61 TRACE_EXIT;
62}
63
64int zft_vcalloc_once(void *new, size_t size)
65{
66 TRACE_FUN(ft_t_flow);
67 if (zft_vmalloc_once(new, size) < 0) {
68 TRACE_EXIT -ENOMEM;
69 }
70 memset(*(void **)new, '\0', size);
71 TRACE_EXIT 0;
72}
73int zft_vmalloc_once(void *new, size_t size)
74{
75 TRACE_FUN(ft_t_flow);
76
77 if (*(void **)new != NULL || size == 0) {
78 TRACE_EXIT 0;
79 }
80 if ((*(void **)new = vmalloc(size)) == NULL) {
81 TRACE_EXIT -ENOMEM;
82 }
83 used_memory += size;
84 if (peak_memory < used_memory) {
85 peak_memory = used_memory;
86 }
87 TRACE_ABORT(0, ft_t_noise,
88 "allocated buffer @ %p, %d bytes", *(void **)new, size);
89}
90int zft_vmalloc_always(void *new, size_t size)
91{
92 TRACE_FUN(ft_t_flow);
93
94 zft_vfree(new, size);
95 TRACE_EXIT zft_vmalloc_once(new, size);
96}
97void zft_vfree(void *old, size_t size)
98{
99 TRACE_FUN(ft_t_flow);
100
101 if (*(void **)old) {
102 vfree(*(void **)old);
103 used_memory -= size;
104 TRACE(ft_t_noise, "released buffer @ %p, %d bytes",
105 *(void **)old, size);
106 *(void **)old = NULL;
107 }
108 TRACE_EXIT;
109}
110
111void *zft_kmalloc(size_t size)
112{
113 void *new;
114
115 while ((new = kmalloc(size, GFP_KERNEL)) == NULL) {
116 msleep_interruptible(100);
117 }
118 memset(new, 0, size);
119 used_memory += size;
120 if (peak_memory < used_memory) {
121 peak_memory = used_memory;
122 }
123 return new;
124}
125
126void zft_kfree(void *old, size_t size)
127{
128 kfree(old);
129 used_memory -= size;
130}
131
132/* there are some more buffers that are allocated on demand.
133 * cleanup_module() calles this function to be sure to have released
134 * them
135 */
136void zft_uninit_mem(void)
137{
138 TRACE_FUN(ft_t_flow);
139
140 zft_vfree(&zft_hseg_buf, FT_SEGMENT_SIZE);
141 zft_vfree(&zft_deblock_buf, FT_SEGMENT_SIZE); zft_deblock_segment = -1;
142 zft_free_vtbl();
143 if (zft_cmpr_lock(0 /* don't load */) == 0) {
144 (*zft_cmpr_ops->cleanup)();
145 (*zft_cmpr_ops->reset)(); /* unlock it again */
146 }
147 zft_memory_stats();
148 TRACE_EXIT;
149}
diff --git a/drivers/char/ftape/zftape/zftape-buffers.h b/drivers/char/ftape/zftape/zftape-buffers.h
deleted file mode 100644
index 798e3128c682..000000000000
--- a/drivers/char/ftape/zftape/zftape-buffers.h
+++ /dev/null
@@ -1,55 +0,0 @@
1#ifndef _FTAPE_DYNMEM_H
2#define _FTAPE_DYNMEM_H
3
4/*
5 * Copyright (C) 1995-1997 Claus-Justus Heine.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 *
22 * $Source: /homes/cvs/ftape-stacked/ftape/zftape/zftape-buffers.h,v $
23 * $Revision: 1.2 $
24 * $Date: 1997/10/05 19:18:59 $
25 *
26 * memory allocation routines.
27 *
28 */
29
30/* we do not allocate all of the really large buffer memory before
31 * someone tries to open the drive. ftape_open() may fail with
32 * -ENOMEM, but that's better having 200k of vmalloced memory which
33 * cannot be swapped out.
34 */
35
36extern void zft_memory_stats(void);
37extern int zft_vmalloc_once(void *new, size_t size);
38extern int zft_vcalloc_once(void *new, size_t size);
39extern int zft_vmalloc_always(void *new, size_t size);
40extern void zft_vfree(void *old, size_t size);
41extern void *zft_kmalloc(size_t size);
42extern void zft_kfree(void *old, size_t size);
43
44/* called by cleanup_module()
45 */
46extern void zft_uninit_mem(void);
47
48#endif
49
50
51
52
53
54
55
diff --git a/drivers/char/ftape/zftape/zftape-ctl.c b/drivers/char/ftape/zftape/zftape-ctl.c
deleted file mode 100644
index 22ba0f5d00cf..000000000000
--- a/drivers/char/ftape/zftape/zftape-ctl.c
+++ /dev/null
@@ -1,1417 +0,0 @@
1/*
2 * Copyright (C) 1996, 1997 Claus-Justus Heine
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 *
19 * $Source: /homes/cvs/ftape-stacked/ftape/zftape/zftape-ctl.c,v $
20 * $Revision: 1.2.6.2 $
21 * $Date: 1997/11/14 18:07:33 $
22 *
23 * This file contains the non-read/write zftape functions
24 * for the QIC-40/80/3010/3020 floppy-tape driver for Linux.
25 */
26
27#include <linux/errno.h>
28#include <linux/mm.h>
29#include <linux/module.h>
30#include <linux/fcntl.h>
31
32#include <linux/zftape.h>
33
34#include <asm/uaccess.h>
35
36#include "../zftape/zftape-init.h"
37#include "../zftape/zftape-eof.h"
38#include "../zftape/zftape-ctl.h"
39#include "../zftape/zftape-write.h"
40#include "../zftape/zftape-read.h"
41#include "../zftape/zftape-rw.h"
42#include "../zftape/zftape-vtbl.h"
43
44/* Global vars.
45 */
46int zft_write_protected; /* this is when cartridge rdonly or O_RDONLY */
47int zft_header_read;
48int zft_offline;
49unsigned int zft_unit;
50int zft_resid;
51int zft_mt_compression;
52
53/* Local vars.
54 */
55static int going_offline;
56
57typedef int (mt_fun)(int *argptr);
58typedef int (*mt_funp)(int *argptr);
59typedef struct
60{
61 mt_funp function;
62 unsigned offline : 1; /* op permitted if offline or no_tape */
63 unsigned write_protected : 1; /* op permitted if write-protected */
64 unsigned not_formatted : 1; /* op permitted if tape not formatted */
65 unsigned raw_mode : 1; /* op permitted if zft_mode == 0 */
66 unsigned need_idle_state : 1; /* need to call def_idle_state */
67 char *name;
68} fun_entry;
69
70static mt_fun mt_dummy, mt_reset, mt_fsr, mt_bsr, mt_rew, mt_offl, mt_nop,
71 mt_weof, mt_erase, mt_ras2, mt_setblk, mt_setdensity,
72 mt_seek, mt_tell, mt_reten, mt_eom, mt_fsf, mt_bsf,
73 mt_fsfm, mt_bsfm, mt_setdrvbuffer, mt_compression;
74
75static fun_entry mt_funs[]=
76{
77 {mt_reset , 1, 1, 1, 1, 0, "MT_RESET" }, /* 0 */
78 {mt_fsf , 0, 1, 0, 0, 1, "MT_FSF" },
79 {mt_bsf , 0, 1, 0, 0, 1, "MT_BSF" },
80 {mt_fsr , 0, 1, 0, 1, 1, "MT_FSR" },
81 {mt_bsr , 0, 1, 0, 1, 1, "MT_BSR" },
82 {mt_weof , 0, 0, 0, 0, 0, "MT_WEOF" }, /* 5 */
83 {mt_rew , 0, 1, 1, 1, 0, "MT_REW" },
84 {mt_offl , 0, 1, 1, 1, 0, "MT_OFFL" },
85 {mt_nop , 1, 1, 1, 1, 0, "MT_NOP" },
86 {mt_reten , 0, 1, 1, 1, 0, "MT_RETEN" },
87 {mt_bsfm , 0, 1, 0, 0, 1, "MT_BSFM" }, /* 10 */
88 {mt_fsfm , 0, 1, 0, 0, 1, "MT_FSFM" },
89 {mt_eom , 0, 1, 0, 0, 1, "MT_EOM" },
90 {mt_erase , 0, 0, 0, 1, 0, "MT_ERASE" },
91 {mt_dummy , 1, 1, 1, 1, 0, "MT_RAS1" },
92 {mt_ras2 , 0, 0, 0, 1, 0, "MT_RAS2" },
93 {mt_dummy , 1, 1, 1, 1, 0, "MT_RAS3" },
94 {mt_dummy , 1, 1, 1, 1, 0, "UNKNOWN" },
95 {mt_dummy , 1, 1, 1, 1, 0, "UNKNOWN" },
96 {mt_dummy , 1, 1, 1, 1, 0, "UNKNOWN" },
97 {mt_setblk , 1, 1, 1, 1, 1, "MT_SETBLK"}, /* 20 */
98 {mt_setdensity , 1, 1, 1, 1, 0, "MT_SETDENSITY"},
99 {mt_seek , 0, 1, 0, 1, 1, "MT_SEEK" },
100 {mt_dummy , 0, 1, 0, 1, 1, "MT_TELL" }, /* wr-only ?! */
101 {mt_setdrvbuffer, 1, 1, 1, 1, 0, "MT_SETDRVBUFFER" },
102 {mt_dummy , 1, 1, 1, 1, 0, "MT_FSS" }, /* 25 */
103 {mt_dummy , 1, 1, 1, 1, 0, "MT_BSS" },
104 {mt_dummy , 1, 1, 1, 1, 0, "MT_WSM" },
105 {mt_dummy , 1, 1, 1, 1, 0, "MT_LOCK" },
106 {mt_dummy , 1, 1, 1, 1, 0, "MT_UNLOCK"},
107 {mt_dummy , 1, 1, 1, 1, 0, "MT_LOAD" }, /* 30 */
108 {mt_dummy , 1, 1, 1, 1, 0, "MT_UNLOAD"},
109 {mt_compression , 1, 1, 1, 0, 1, "MT_COMPRESSION"},
110 {mt_dummy , 1, 1, 1, 1, 0, "MT_SETPART"},
111 {mt_dummy , 1, 1, 1, 1, 0, "MT_MKPART"}
112};
113
114#define NR_MT_CMDS NR_ITEMS(mt_funs)
115
116void zft_reset_position(zft_position *pos)
117{
118 TRACE_FUN(ft_t_flow);
119
120 pos->seg_byte_pos =
121 pos->volume_pos = 0;
122 if (zft_header_read) {
123 /* need to keep track of the volume table and
124 * compression map. We therefor simply
125 * position at the beginning of the first
126 * volume. This covers old ftape archives as
127 * well has various flavours of the
128 * compression map segments. The worst case is
129 * that the compression map shows up as a
130 * additional volume in front of all others.
131 */
132 pos->seg_pos = zft_find_volume(0)->start_seg;
133 pos->tape_pos = zft_calc_tape_pos(pos->seg_pos);
134 } else {
135 pos->tape_pos = 0;
136 pos->seg_pos = -1;
137 }
138 zft_just_before_eof = 0;
139 zft_deblock_segment = -1;
140 zft_io_state = zft_idle;
141 zft_zap_read_buffers();
142 zft_prevent_flush();
143 /* unlock the compresison module if it is loaded.
144 * The zero arg means not to try to load the module.
145 */
146 if (zft_cmpr_lock(0) == 0) {
147 (*zft_cmpr_ops->reset)(); /* unlock */
148 }
149 TRACE_EXIT;
150}
151
152static void zft_init_driver(void)
153{
154 TRACE_FUN(ft_t_flow);
155
156 zft_resid =
157 zft_header_read =
158 zft_old_ftape =
159 zft_offline =
160 zft_write_protected =
161 going_offline =
162 zft_mt_compression =
163 zft_header_changed =
164 zft_volume_table_changed =
165 zft_written_segments = 0;
166 zft_blk_sz = CONFIG_ZFT_DFLT_BLK_SZ;
167 zft_reset_position(&zft_pos); /* does most of the stuff */
168 ftape_zap_read_buffers();
169 ftape_set_state(idle);
170 TRACE_EXIT;
171}
172
173int zft_def_idle_state(void)
174{
175 int result = 0;
176 TRACE_FUN(ft_t_flow);
177
178 if (!zft_header_read) {
179 result = zft_read_header_segments();
180 } else if ((result = zft_flush_buffers()) >= 0 && zft_qic_mode) {
181 /* don't move past eof
182 */
183 (void)zft_close_volume(&zft_pos);
184 }
185 if (ftape_abort_operation() < 0) {
186 TRACE(ft_t_warn, "ftape_abort_operation() failed");
187 result = -EIO;
188 }
189 /* clear remaining read buffers */
190 zft_zap_read_buffers();
191 zft_io_state = zft_idle;
192 TRACE_EXIT result;
193}
194
195/*****************************************************************************
196 * *
197 * functions for the MTIOCTOP commands *
198 * *
199 *****************************************************************************/
200
201static int mt_dummy(int *dummy)
202{
203 TRACE_FUN(ft_t_flow);
204
205 TRACE_EXIT -ENOSYS;
206}
207
208static int mt_reset(int *dummy)
209{
210 TRACE_FUN(ft_t_flow);
211
212 (void)ftape_seek_to_bot();
213 TRACE_CATCH(ftape_reset_drive(),
214 zft_init_driver(); zft_uninit_mem(); zft_offline = 1);
215 /* fake a re-open of the device. This will set all flage and
216 * allocate buffers as appropriate. The new tape condition will
217 * force the open routine to do anything we need.
218 */
219 TRACE_CATCH(_zft_open(-1 /* fake reopen */, 0 /* dummy */),);
220 TRACE_EXIT 0;
221}
222
223static int mt_fsf(int *arg)
224{
225 int result;
226 TRACE_FUN(ft_t_flow);
227
228 result = zft_skip_volumes(*arg, &zft_pos);
229 zft_just_before_eof = 0;
230 TRACE_EXIT result;
231}
232
233static int mt_bsf(int *arg)
234{
235 int result = 0;
236 TRACE_FUN(ft_t_flow);
237
238 if (*arg != 0) {
239 result = zft_skip_volumes(-*arg + 1, &zft_pos);
240 }
241 TRACE_EXIT result;
242}
243
244static int seek_block(__s64 data_offset,
245 __s64 block_increment,
246 zft_position *pos)
247{
248 int result = 0;
249 __s64 new_block_pos;
250 __s64 vol_block_count;
251 const zft_volinfo *volume;
252 int exceed;
253 TRACE_FUN(ft_t_flow);
254
255 volume = zft_find_volume(pos->seg_pos);
256 if (volume->start_seg == 0 || volume->end_seg == 0) {
257 TRACE_EXIT -EIO;
258 }
259 new_block_pos = (zft_div_blksz(data_offset, volume->blk_sz)
260 + block_increment);
261 vol_block_count = zft_div_blksz(volume->size, volume->blk_sz);
262 if (new_block_pos < 0) {
263 TRACE(ft_t_noise,
264 "new_block_pos " LL_X " < 0", LL(new_block_pos));
265 zft_resid = (int)new_block_pos;
266 new_block_pos = 0;
267 exceed = 1;
268 } else if (new_block_pos > vol_block_count) {
269 TRACE(ft_t_noise,
270 "new_block_pos " LL_X " exceeds size of volume " LL_X,
271 LL(new_block_pos), LL(vol_block_count));
272 zft_resid = (int)(vol_block_count - new_block_pos);
273 new_block_pos = vol_block_count;
274 exceed = 1;
275 } else {
276 exceed = 0;
277 }
278 if (zft_use_compression && volume->use_compression) {
279 TRACE_CATCH(zft_cmpr_lock(1 /* try to load */),);
280 result = (*zft_cmpr_ops->seek)(new_block_pos, pos, volume,
281 zft_deblock_buf);
282 pos->tape_pos = zft_calc_tape_pos(pos->seg_pos);
283 pos->tape_pos += pos->seg_byte_pos;
284 } else {
285 pos->volume_pos = zft_mul_blksz(new_block_pos, volume->blk_sz);
286 pos->tape_pos = zft_calc_tape_pos(volume->start_seg);
287 pos->tape_pos += pos->volume_pos;
288 pos->seg_pos = zft_calc_seg_byte_coord(&pos->seg_byte_pos,
289 pos->tape_pos);
290 }
291 zft_just_before_eof = volume->size == pos->volume_pos;
292 if (zft_just_before_eof) {
293 /* why this? because zft_file_no checks agains start
294 * and end segment of a volume. We do not want to
295 * advance to the next volume with this function.
296 */
297 TRACE(ft_t_noise, "set zft_just_before_eof");
298 zft_position_before_eof(pos, volume);
299 }
300 TRACE(ft_t_noise, "\n"
301 KERN_INFO "new_seg_pos : %d\n"
302 KERN_INFO "new_tape_pos: " LL_X "\n"
303 KERN_INFO "vol_size : " LL_X "\n"
304 KERN_INFO "seg_byte_pos: %d\n"
305 KERN_INFO "blk_sz : %d",
306 pos->seg_pos, LL(pos->tape_pos),
307 LL(volume->size), pos->seg_byte_pos,
308 volume->blk_sz);
309 if (!exceed) {
310 zft_resid = new_block_pos - zft_div_blksz(pos->volume_pos,
311 volume->blk_sz);
312 }
313 if (zft_resid < 0) {
314 zft_resid = -zft_resid;
315 }
316 TRACE_EXIT ((exceed || zft_resid != 0) && result >= 0) ? -EINVAL : result;
317}
318
319static int mt_fsr(int *arg)
320{
321 int result;
322 TRACE_FUN(ft_t_flow);
323
324 result = seek_block(zft_pos.volume_pos, *arg, &zft_pos);
325 TRACE_EXIT result;
326}
327
328static int mt_bsr(int *arg)
329{
330 int result;
331 TRACE_FUN(ft_t_flow);
332
333 result = seek_block(zft_pos.volume_pos, -*arg, &zft_pos);
334 TRACE_EXIT result;
335}
336
337static int mt_weof(int *arg)
338{
339 int result;
340 TRACE_FUN(ft_t_flow);
341
342 TRACE_CATCH(zft_flush_buffers(),);
343 result = zft_weof(*arg, &zft_pos);
344 TRACE_EXIT result;
345}
346
347static int mt_rew(int *dummy)
348{
349 int result;
350 TRACE_FUN(ft_t_flow);
351
352 if(zft_header_read) {
353 (void)zft_def_idle_state();
354 }
355 result = ftape_seek_to_bot();
356 zft_reset_position(&zft_pos);
357 TRACE_EXIT result;
358}
359
360static int mt_offl(int *dummy)
361{
362 int result;
363 TRACE_FUN(ft_t_flow);
364
365 going_offline= 1;
366 result = mt_rew(NULL);
367 TRACE_EXIT result;
368}
369
370static int mt_nop(int *dummy)
371{
372 TRACE_FUN(ft_t_flow);
373 /* should we set tape status?
374 */
375 if (!zft_offline) { /* offline includes no_tape */
376 (void)zft_def_idle_state();
377 }
378 TRACE_EXIT 0;
379}
380
381static int mt_reten(int *dummy)
382{
383 int result;
384 TRACE_FUN(ft_t_flow);
385
386 if(zft_header_read) {
387 (void)zft_def_idle_state();
388 }
389 result = ftape_seek_to_eot();
390 if (result >= 0) {
391 result = ftape_seek_to_bot();
392 }
393 TRACE_EXIT(result);
394}
395
396static int fsfbsfm(int arg, zft_position *pos)
397{
398 const zft_volinfo *vtbl;
399 __s64 block_pos;
400 TRACE_FUN(ft_t_flow);
401
402 /* What to do? This should seek to the next file-mark and
403 * position BEFORE. That is, a next write would just extend
404 * the current file. Well. Let's just seek to the end of the
405 * current file, if count == 1. If count > 1, then do a
406 * "mt_fsf(count - 1)", and then seek to the end of that file.
407 * If count == 0, do nothing
408 */
409 if (arg == 0) {
410 TRACE_EXIT 0;
411 }
412 zft_just_before_eof = 0;
413 TRACE_CATCH(zft_skip_volumes(arg < 0 ? arg : arg-1, pos),
414 if (arg > 0) {
415 zft_resid ++;
416 });
417 vtbl = zft_find_volume(pos->seg_pos);
418 block_pos = zft_div_blksz(vtbl->size, vtbl->blk_sz);
419 (void)seek_block(0, block_pos, pos);
420 if (pos->volume_pos != vtbl->size) {
421 zft_just_before_eof = 0;
422 zft_resid = 1;
423 /* we didn't managed to go there */
424 TRACE_ABORT(-EIO, ft_t_err,
425 "wanted file position " LL_X ", arrived at " LL_X,
426 LL(vtbl->size), LL(pos->volume_pos));
427 }
428 zft_just_before_eof = 1;
429 TRACE_EXIT 0;
430}
431
432static int mt_bsfm(int *arg)
433{
434 int result;
435 TRACE_FUN(ft_t_flow);
436
437 result = fsfbsfm(-*arg, &zft_pos);
438 TRACE_EXIT result;
439}
440
441static int mt_fsfm(int *arg)
442{
443 int result;
444 TRACE_FUN(ft_t_flow);
445
446 result = fsfbsfm(*arg, &zft_pos);
447 TRACE_EXIT result;
448}
449
450static int mt_eom(int *dummy)
451{
452 TRACE_FUN(ft_t_flow);
453
454 zft_skip_to_eom(&zft_pos);
455 TRACE_EXIT 0;
456}
457
458static int mt_erase(int *dummy)
459{
460 int result;
461 TRACE_FUN(ft_t_flow);
462
463 result = zft_erase();
464 TRACE_EXIT result;
465}
466
467static int mt_ras2(int *dummy)
468{
469 int result;
470 TRACE_FUN(ft_t_flow);
471
472 result = -ENOSYS;
473 TRACE_EXIT result;
474}
475
476/* Sets the new blocksize in BYTES
477 *
478 */
479static int mt_setblk(int *new_size)
480{
481 TRACE_FUN(ft_t_flow);
482
483 if((unsigned int)(*new_size) > ZFT_MAX_BLK_SZ) {
484 TRACE_ABORT(-EINVAL, ft_t_info,
485 "desired blk_sz (%d) should be <= %d bytes",
486 *new_size, ZFT_MAX_BLK_SZ);
487 }
488 if ((*new_size & (FT_SECTOR_SIZE-1)) != 0) {
489 TRACE_ABORT(-EINVAL, ft_t_info,
490 "desired blk_sz (%d) must be a multiple of %d bytes",
491 *new_size, FT_SECTOR_SIZE);
492 }
493 if (*new_size == 0) {
494 if (zft_use_compression) {
495 TRACE_ABORT(-EINVAL, ft_t_info,
496 "Variable block size not yet "
497 "supported with compression");
498 }
499 *new_size = 1;
500 }
501 zft_blk_sz = *new_size;
502 TRACE_EXIT 0;
503}
504
505static int mt_setdensity(int *arg)
506{
507 TRACE_FUN(ft_t_flow);
508
509 SET_TRACE_LEVEL(*arg);
510 TRACE(TRACE_LEVEL, "tracing set to %d", TRACE_LEVEL);
511 if ((int)TRACE_LEVEL != *arg) {
512 TRACE_EXIT -EINVAL;
513 }
514 TRACE_EXIT 0;
515}
516
517static int mt_seek(int *new_block_pos)
518{
519 int result= 0;
520 TRACE_FUN(ft_t_any);
521
522 result = seek_block(0, (__s64)*new_block_pos, &zft_pos);
523 TRACE_EXIT result;
524}
525
526/* OK, this is totally different from SCSI, but the worst thing that can
527 * happen is that there is not enough defragmentated memory that can be
528 * allocated. Also, there is a hardwired limit of 16 dma buffers in the
529 * stock ftape module. This shouldn't bring the system down.
530 *
531 * NOTE: the argument specifies the total number of dma buffers to use.
532 * The driver needs at least 3 buffers to function at all.
533 *
534 */
535static int mt_setdrvbuffer(int *cnt)
536{
537 TRACE_FUN(ft_t_flow);
538
539 if (*cnt < 3) {
540 TRACE_EXIT -EINVAL;
541 }
542 TRACE_CATCH(ftape_set_nr_buffers(*cnt),);
543 TRACE_EXIT 0;
544}
545/* return the block position from start of volume
546 */
547static int mt_tell(int *arg)
548{
549 TRACE_FUN(ft_t_flow);
550
551 *arg = zft_div_blksz(zft_pos.volume_pos,
552 zft_find_volume(zft_pos.seg_pos)->blk_sz);
553 TRACE_EXIT 0;
554}
555
556static int mt_compression(int *arg)
557{
558 TRACE_FUN(ft_t_flow);
559
560 /* Ok. We could also check whether compression is available at
561 * all by trying to load the compression module. We could
562 * also check for a block size of 1 byte which is illegal
563 * with compression. Instead of doing it here we rely on
564 * zftape_write() to do the proper checks.
565 */
566 if ((unsigned int)*arg > 1) {
567 TRACE_EXIT -EINVAL;
568 }
569 if (*arg != 0 && zft_blk_sz == 1) { /* variable block size */
570 TRACE_ABORT(-EINVAL, ft_t_info,
571 "Compression not yet supported "
572 "with variable block size");
573 }
574 zft_mt_compression = *arg;
575 if ((zft_unit & ZFT_ZIP_MODE) == 0) {
576 zft_use_compression = zft_mt_compression;
577 }
578 TRACE_EXIT 0;
579}
580
581/* check whether write access is allowed. Write access is denied when
582 * + zft_write_protected == 1 -- this accounts for either hard write
583 * protection of the cartridge or for
584 * O_RDONLY access mode of the tape device
585 * + zft_offline == 1 -- this meany that there is either no tape
586 * or that the MTOFFLINE ioctl has been
587 * previously issued (`soft eject')
588 * + ft_formatted == 0 -- this means that the cartridge is not
589 * formatted
590 * Then we distinuguish two cases. When zft_qic_mode is TRUE, then we try
591 * to emulate a `traditional' (aka SCSI like) UN*X tape device. Therefore we
592 * deny writes when
593 * + zft_qic_mode ==1 &&
594 * (!zft_tape_at_lbot() && -- tape no at logical BOT
595 * !(zft_tape_at_eom() || -- tape not at logical EOM (or EOD)
596 * (zft_tape_at_eom() &&
597 * zft_old_ftape()))) -- we can't add new volume to tapes
598 * written by old ftape because ftape
599 * don't use the volume table
600 *
601 * when the drive is in true raw mode (aka /dev/rawft0) then we don't
602 * care about LBOT and EOM conditions. This device is intended for a
603 * user level program that wants to truly implement the QIC-80 compliance
604 * at the logical data layout level of the cartridge, i.e. implement all
605 * that volume table and volume directory stuff etc.<
606 */
607int zft_check_write_access(zft_position *pos)
608{
609 TRACE_FUN(ft_t_flow);
610
611 if (zft_offline) { /* offline includes no_tape */
612 TRACE_ABORT(-ENXIO,
613 ft_t_info, "tape is offline or no cartridge");
614 }
615 if (!ft_formatted) {
616 TRACE_ABORT(-EACCES, ft_t_info, "tape is not formatted");
617 }
618 if (zft_write_protected) {
619 TRACE_ABORT(-EACCES, ft_t_info, "cartridge write protected");
620 }
621 if (zft_qic_mode) {
622 /* check BOT condition */
623 if (!zft_tape_at_lbot(pos)) {
624 /* protect cartridges written by old ftape if
625 * not at BOT because they use the vtbl
626 * segment for storing data
627 */
628 if (zft_old_ftape) {
629 TRACE_ABORT(-EACCES, ft_t_warn,
630 "Cannot write to cartridges written by old ftape when not at BOT");
631 }
632 /* not at BOT, but allow writes at EOD, of course
633 */
634 if (!zft_tape_at_eod(pos)) {
635 TRACE_ABORT(-EACCES, ft_t_info,
636 "tape not at BOT and not at EOD");
637 }
638 }
639 /* fine. Now the tape is either at BOT or at EOD. */
640 }
641 /* or in raw mode in which case we don't care about BOT and EOD */
642 TRACE_EXIT 0;
643}
644
645/* OPEN routine called by kernel-interface code
646 *
647 * NOTE: this is also called by mt_reset() with dev_minor == -1
648 * to fake a reopen after a reset.
649 */
650int _zft_open(unsigned int dev_minor, unsigned int access_mode)
651{
652 static unsigned int tape_unit;
653 static unsigned int file_access_mode;
654 int result;
655 TRACE_FUN(ft_t_flow);
656
657 if ((int)dev_minor == -1) {
658 /* fake reopen */
659 zft_unit = tape_unit;
660 access_mode = file_access_mode;
661 zft_init_driver(); /* reset all static data to defaults */
662 } else {
663 tape_unit = dev_minor;
664 file_access_mode = access_mode;
665 if ((result = ftape_enable(FTAPE_SEL(dev_minor))) < 0) {
666 TRACE_ABORT(-ENXIO, ft_t_err,
667 "ftape_enable failed: %d", result);
668 }
669 if (ft_new_tape || ft_no_tape || !ft_formatted ||
670 (FTAPE_SEL(zft_unit) != FTAPE_SEL(dev_minor)) ||
671 (zft_unit & ZFT_RAW_MODE) != (dev_minor & ZFT_RAW_MODE)) {
672 /* reset all static data to defaults,
673 */
674 zft_init_driver();
675 }
676 zft_unit = dev_minor;
677 }
678 zft_set_flags(zft_unit); /* decode the minor bits */
679 if (zft_blk_sz == 1 && zft_use_compression) {
680 ftape_disable(); /* resets ft_no_tape */
681 TRACE_ABORT(-ENODEV, ft_t_warn, "Variable block size not yet "
682 "supported with compression");
683 }
684 /* no need for most of the buffers when no tape or not
685 * formatted. for the read/write operations, it is the
686 * regardless whether there is no tape, a not-formatted tape
687 * or the whether the driver is soft offline.
688 * Nevertheless we allow some ioctls with non-formatted tapes,
689 * like rewind and reset.
690 */
691 if (ft_no_tape || !ft_formatted) {
692 zft_uninit_mem();
693 }
694 if (ft_no_tape) {
695 zft_offline = 1; /* so we need not test two variables */
696 }
697 if ((access_mode == O_WRONLY || access_mode == O_RDWR) &&
698 (ft_write_protected || ft_no_tape)) {
699 ftape_disable(); /* resets ft_no_tape */
700 TRACE_ABORT(ft_no_tape ? -ENXIO : -EROFS,
701 ft_t_warn, "wrong access mode %s cartridge",
702 ft_no_tape ? "without a" : "with write protected");
703 }
704 zft_write_protected = (access_mode == O_RDONLY ||
705 ft_write_protected != 0);
706 if (zft_write_protected) {
707 TRACE(ft_t_noise,
708 "read only access mode: %d, "
709 "drive write protected: %d",
710 access_mode == O_RDONLY,
711 ft_write_protected != 0);
712 }
713 if (!zft_offline) {
714 TRACE_CATCH(zft_vmalloc_once(&zft_deblock_buf,FT_SEGMENT_SIZE),
715 ftape_disable());
716 }
717 /* zft_seg_pos should be greater than the vtbl segpos but not
718 * if in compatibility mode and only after we read in the
719 * header segments
720 *
721 * might also be a problem if the user makes a backup with a
722 * *qft* device and rewinds it with a raw device.
723 */
724 if (zft_qic_mode &&
725 !zft_old_ftape &&
726 zft_pos.seg_pos >= 0 &&
727 zft_header_read &&
728 zft_pos.seg_pos <= ft_first_data_segment) {
729 TRACE(ft_t_noise, "you probably mixed up the zftape devices!");
730 zft_reset_position(&zft_pos);
731 }
732 TRACE_EXIT 0;
733}
734
735/* RELEASE routine called by kernel-interface code
736 */
737int _zft_close(void)
738{
739 int result = 0;
740 TRACE_FUN(ft_t_flow);
741
742 if (zft_offline) {
743 /* call the hardware release routine. Puts the drive offline */
744 ftape_disable();
745 TRACE_EXIT 0;
746 }
747 if (!(ft_write_protected || zft_old_ftape)) {
748 result = zft_flush_buffers();
749 TRACE(ft_t_noise, "writing file mark at current position");
750 if (zft_qic_mode && zft_close_volume(&zft_pos) == 0) {
751 zft_move_past_eof(&zft_pos);
752 }
753 if ((zft_tape_at_lbot(&zft_pos) ||
754 !(zft_unit & FTAPE_NO_REWIND))) {
755 if (result >= 0) {
756 result = zft_update_header_segments();
757 } else {
758 TRACE(ft_t_err,
759 "Error: unable to update header segments");
760 }
761 }
762 }
763 ftape_abort_operation();
764 if (!(zft_unit & FTAPE_NO_REWIND)) {
765 TRACE(ft_t_noise, "rewinding tape");
766 if (ftape_seek_to_bot() < 0 && result >= 0) {
767 result = -EIO; /* keep old value */
768 }
769 zft_reset_position(&zft_pos);
770 }
771 zft_zap_read_buffers();
772 /* now free up memory as much as possible. We don't destroy
773 * the deblock buffer if it containes a valid segment.
774 */
775 if (zft_deblock_segment == -1) {
776 zft_vfree(&zft_deblock_buf, FT_SEGMENT_SIZE);
777 }
778 /* high level driver status, forces creation of a new volume
779 * when calling ftape_write again and not zft_just_before_eof
780 */
781 zft_io_state = zft_idle;
782 if (going_offline) {
783 zft_init_driver();
784 zft_uninit_mem();
785 going_offline = 0;
786 zft_offline = 1;
787 } else if (zft_cmpr_lock(0 /* don't load */) == 0) {
788 (*zft_cmpr_ops->reset)(); /* unlock it again */
789 }
790 zft_memory_stats();
791 /* call the hardware release routine. Puts the drive offline */
792 ftape_disable();
793 TRACE_EXIT result;
794}
795
796/*
797 * the wrapper function around the wrapper MTIOCTOP ioctl
798 */
799static int mtioctop(struct mtop *mtop, int arg_size)
800{
801 int result = 0;
802 fun_entry *mt_fun_entry;
803 TRACE_FUN(ft_t_flow);
804
805 if (arg_size != sizeof(struct mtop) || mtop->mt_op >= NR_MT_CMDS) {
806 TRACE_EXIT -EINVAL;
807 }
808 TRACE(ft_t_noise, "calling MTIOCTOP command: %s",
809 mt_funs[mtop->mt_op].name);
810 mt_fun_entry= &mt_funs[mtop->mt_op];
811 zft_resid = mtop->mt_count;
812 if (!mt_fun_entry->offline && zft_offline) {
813 if (ft_no_tape) {
814 TRACE_ABORT(-ENXIO, ft_t_info, "no tape present");
815 } else {
816 TRACE_ABORT(-ENXIO, ft_t_info, "drive is offline");
817 }
818 }
819 if (!mt_fun_entry->not_formatted && !ft_formatted) {
820 TRACE_ABORT(-EACCES, ft_t_info, "tape is not formatted");
821 }
822 if (!mt_fun_entry->write_protected) {
823 TRACE_CATCH(zft_check_write_access(&zft_pos),);
824 }
825 if (mt_fun_entry->need_idle_state && !(zft_offline || !ft_formatted)) {
826 TRACE_CATCH(zft_def_idle_state(),);
827 }
828 if (!zft_qic_mode && !mt_fun_entry->raw_mode) {
829 TRACE_ABORT(-EACCES, ft_t_info,
830"Drive needs to be in QIC-80 compatibility mode for this command");
831 }
832 result = (mt_fun_entry->function)(&mtop->mt_count);
833 if (zft_tape_at_lbot(&zft_pos)) {
834 TRACE_CATCH(zft_update_header_segments(),);
835 }
836 if (result >= 0) {
837 zft_resid = 0;
838 }
839 TRACE_EXIT result;
840}
841
842/*
843 * standard MTIOCGET ioctl
844 */
845static int mtiocget(struct mtget *mtget, int arg_size)
846{
847 const zft_volinfo *volume;
848 __s64 max_tape_pos;
849 TRACE_FUN(ft_t_flow);
850
851 if (arg_size != sizeof(struct mtget)) {
852 TRACE_ABORT(-EINVAL, ft_t_info, "bad argument size: %d",
853 arg_size);
854 }
855 mtget->mt_type = ft_drive_type.vendor_id + 0x800000;
856 mtget->mt_dsreg = ft_last_status.space;
857 mtget->mt_erreg = ft_last_error.space; /* error register */
858 mtget->mt_resid = zft_resid; /* residuum of writes, reads and
859 * MTIOCTOP commands
860 */
861 if (!zft_offline) { /* neither no_tape nor soft offline */
862 mtget->mt_gstat = GMT_ONLINE(~0UL);
863 /* should rather return the status of the cartridge
864 * than the access mode of the file, therefor use
865 * ft_write_protected, not zft_write_protected
866 */
867 if (ft_write_protected) {
868 mtget->mt_gstat |= GMT_WR_PROT(~0UL);
869 }
870 if(zft_header_read) { /* this catches non-formatted */
871 volume = zft_find_volume(zft_pos.seg_pos);
872 mtget->mt_fileno = volume->count;
873 max_tape_pos = zft_capacity - zft_blk_sz;
874 if (zft_use_compression) {
875 max_tape_pos -= ZFT_CMPR_OVERHEAD;
876 }
877 if (zft_tape_at_eod(&zft_pos)) {
878 mtget->mt_gstat |= GMT_EOD(~0UL);
879 }
880 if (zft_pos.tape_pos > max_tape_pos) {
881 mtget->mt_gstat |= GMT_EOT(~0UL);
882 }
883 mtget->mt_blkno = zft_div_blksz(zft_pos.volume_pos,
884 volume->blk_sz);
885 if (zft_just_before_eof) {
886 mtget->mt_gstat |= GMT_EOF(~0UL);
887 }
888 if (zft_tape_at_lbot(&zft_pos)) {
889 mtget->mt_gstat |= GMT_BOT(~0UL);
890 }
891 } else {
892 mtget->mt_fileno = mtget->mt_blkno = -1;
893 if (mtget->mt_dsreg & QIC_STATUS_AT_BOT) {
894 mtget->mt_gstat |= GMT_BOT(~0UL);
895 }
896 }
897 } else {
898 if (ft_no_tape) {
899 mtget->mt_gstat = GMT_DR_OPEN(~0UL);
900 } else {
901 mtget->mt_gstat = 0UL;
902 }
903 mtget->mt_fileno = mtget->mt_blkno = -1;
904 }
905 TRACE_EXIT 0;
906}
907
908#ifdef MTIOCRDFTSEG
909/*
910 * Read a floppy tape segment. This is useful for manipulating the
911 * volume table, and read the old header segment before re-formatting
912 * the cartridge.
913 */
914static int mtiocrdftseg(struct mtftseg * mtftseg, int arg_size)
915{
916 TRACE_FUN(ft_t_flow);
917
918 TRACE(ft_t_noise, "Mag tape ioctl command: MTIOCRDFTSEG");
919 if (zft_qic_mode) {
920 TRACE_ABORT(-EACCES, ft_t_info,
921 "driver needs to be in raw mode for this ioctl");
922 }
923 if (arg_size != sizeof(struct mtftseg)) {
924 TRACE_ABORT(-EINVAL, ft_t_info, "bad argument size: %d",
925 arg_size);
926 }
927 if (zft_offline) {
928 TRACE_EXIT -ENXIO;
929 }
930 if (mtftseg->mt_mode != FT_RD_SINGLE &&
931 mtftseg->mt_mode != FT_RD_AHEAD) {
932 TRACE_ABORT(-EINVAL, ft_t_info, "invalid read mode");
933 }
934 if (!ft_formatted) {
935 TRACE_EXIT -EACCES; /* -ENXIO ? */
936
937 }
938 if (!zft_header_read) {
939 TRACE_CATCH(zft_def_idle_state(),);
940 }
941 if (mtftseg->mt_segno > ft_last_data_segment) {
942 TRACE_ABORT(-EINVAL, ft_t_info, "segment number is too large");
943 }
944 mtftseg->mt_result = ftape_read_segment(mtftseg->mt_segno,
945 zft_deblock_buf,
946 mtftseg->mt_mode);
947 if (mtftseg->mt_result < 0) {
948 /* a negativ result is not an ioctl error. if
949 * the user wants to read damaged tapes,
950 * it's up to her/him
951 */
952 TRACE_EXIT 0;
953 }
954 if (copy_to_user(mtftseg->mt_data,
955 zft_deblock_buf,
956 mtftseg->mt_result) != 0) {
957 TRACE_EXIT -EFAULT;
958 }
959 TRACE_EXIT 0;
960}
961#endif
962
963#ifdef MTIOCWRFTSEG
964/*
965 * write a floppy tape segment. This version features writing of
966 * deleted address marks, and gracefully ignores the (software)
967 * ft_formatted flag to support writing of header segments after
968 * formatting.
969 */
970static int mtiocwrftseg(struct mtftseg * mtftseg, int arg_size)
971{
972 int result;
973 TRACE_FUN(ft_t_flow);
974
975 TRACE(ft_t_noise, "Mag tape ioctl command: MTIOCWRFTSEG");
976 if (zft_write_protected || zft_qic_mode) {
977 TRACE_EXIT -EACCES;
978 }
979 if (arg_size != sizeof(struct mtftseg)) {
980 TRACE_ABORT(-EINVAL, ft_t_info, "bad argument size: %d",
981 arg_size);
982 }
983 if (zft_offline) {
984 TRACE_EXIT -ENXIO;
985 }
986 if (mtftseg->mt_mode != FT_WR_ASYNC &&
987 mtftseg->mt_mode != FT_WR_MULTI &&
988 mtftseg->mt_mode != FT_WR_SINGLE &&
989 mtftseg->mt_mode != FT_WR_DELETE) {
990 TRACE_ABORT(-EINVAL, ft_t_info, "invalid write mode");
991 }
992 /*
993 * We don't check for ft_formatted, because this gives
994 * only the software status of the driver.
995 *
996 * We assume that the user knows what it is
997 * doing. And rely on the low level stuff to fail
998 * when the tape isn't formatted. We only make sure
999 * that The header segment buffer is allocated,
1000 * because it holds the bad sector map.
1001 */
1002 if (zft_hseg_buf == NULL) {
1003 TRACE_EXIT -ENXIO;
1004 }
1005 if (mtftseg->mt_mode != FT_WR_DELETE) {
1006 if (copy_from_user(zft_deblock_buf,
1007 mtftseg->mt_data,
1008 FT_SEGMENT_SIZE) != 0) {
1009 TRACE_EXIT -EFAULT;
1010 }
1011 }
1012 mtftseg->mt_result = ftape_write_segment(mtftseg->mt_segno,
1013 zft_deblock_buf,
1014 mtftseg->mt_mode);
1015 if (mtftseg->mt_result >= 0 && mtftseg->mt_mode == FT_WR_SINGLE) {
1016 /*
1017 * a negativ result is not an ioctl error. if
1018 * the user wants to write damaged tapes,
1019 * it's up to her/him
1020 */
1021 if ((result = ftape_loop_until_writes_done()) < 0) {
1022 mtftseg->mt_result = result;
1023 }
1024 }
1025 TRACE_EXIT 0;
1026}
1027#endif
1028
1029#ifdef MTIOCVOLINFO
1030/*
1031 * get information about volume positioned at.
1032 */
1033static int mtiocvolinfo(struct mtvolinfo *volinfo, int arg_size)
1034{
1035 const zft_volinfo *volume;
1036 TRACE_FUN(ft_t_flow);
1037
1038 TRACE(ft_t_noise, "Mag tape ioctl command: MTIOCVOLINFO");
1039 if (arg_size != sizeof(struct mtvolinfo)) {
1040 TRACE_ABORT(-EINVAL,
1041 ft_t_info, "bad argument size: %d", arg_size);
1042 }
1043 if (zft_offline) {
1044 TRACE_EXIT -ENXIO;
1045 }
1046 if (!ft_formatted) {
1047 TRACE_EXIT -EACCES;
1048 }
1049 TRACE_CATCH(zft_def_idle_state(),);
1050 volume = zft_find_volume(zft_pos.seg_pos);
1051 volinfo->mt_volno = volume->count;
1052 volinfo->mt_blksz = volume->blk_sz == 1 ? 0 : volume->blk_sz;
1053 volinfo->mt_size = volume->size >> 10;
1054 volinfo->mt_rawsize = ((zft_calc_tape_pos(volume->end_seg + 1) >> 10) -
1055 (zft_calc_tape_pos(volume->start_seg) >> 10));
1056 volinfo->mt_cmpr = volume->use_compression;
1057 TRACE_EXIT 0;
1058}
1059#endif
1060
1061#ifdef ZFT_OBSOLETE
1062static int mtioc_zftape_getblksz(struct mtblksz *blksz, int arg_size)
1063{
1064 TRACE_FUN(ft_t_flow);
1065
1066 TRACE(ft_t_noise, "\n"
1067 KERN_INFO "Mag tape ioctl command: MTIOC_ZTAPE_GETBLKSZ\n"
1068 KERN_INFO "This ioctl is here merely for compatibility.\n"
1069 KERN_INFO "Please use MTIOCVOLINFO instead");
1070 if (arg_size != sizeof(struct mtblksz)) {
1071 TRACE_ABORT(-EINVAL,
1072 ft_t_info, "bad argument size: %d", arg_size);
1073 }
1074 if (zft_offline) {
1075 TRACE_EXIT -ENXIO;
1076 }
1077 if (!ft_formatted) {
1078 TRACE_EXIT -EACCES;
1079 }
1080 TRACE_CATCH(zft_def_idle_state(),);
1081 blksz->mt_blksz = zft_find_volume(zft_pos.seg_pos)->blk_sz;
1082 TRACE_EXIT 0;
1083}
1084#endif
1085
1086#ifdef MTIOCGETSIZE
1087/*
1088 * get the capacity of the tape cartridge.
1089 */
1090static int mtiocgetsize(struct mttapesize *size, int arg_size)
1091{
1092 TRACE_FUN(ft_t_flow);
1093
1094 TRACE(ft_t_noise, "Mag tape ioctl command: MTIOC_ZFTAPE_GETSIZE");
1095 if (arg_size != sizeof(struct mttapesize)) {
1096 TRACE_ABORT(-EINVAL,
1097 ft_t_info, "bad argument size: %d", arg_size);
1098 }
1099 if (zft_offline) {
1100 TRACE_EXIT -ENXIO;
1101 }
1102 if (!ft_formatted) {
1103 TRACE_EXIT -EACCES;
1104 }
1105 TRACE_CATCH(zft_def_idle_state(),);
1106 size->mt_capacity = (unsigned int)(zft_capacity>>10);
1107 size->mt_used = (unsigned int)(zft_get_eom_pos()>>10);
1108 TRACE_EXIT 0;
1109}
1110#endif
1111
1112static int mtiocpos(struct mtpos *mtpos, int arg_size)
1113{
1114 int result;
1115 TRACE_FUN(ft_t_flow);
1116
1117 TRACE(ft_t_noise, "Mag tape ioctl command: MTIOCPOS");
1118 if (arg_size != sizeof(struct mtpos)) {
1119 TRACE_ABORT(-EINVAL,
1120 ft_t_info, "bad argument size: %d", arg_size);
1121 }
1122 result = mt_tell((int *)&mtpos->mt_blkno);
1123 TRACE_EXIT result;
1124}
1125
1126#ifdef MTIOCFTFORMAT
1127/*
1128 * formatting of floppy tape cartridges. This is intended to be used
1129 * together with the MTIOCFTCMD ioctl and the new mmap feature
1130 */
1131
1132/*
1133 * This function uses ftape_decode_header_segment() to inform the low
1134 * level ftape module about the new parameters.
1135 *
1136 * It erases the hseg_buf. The calling process must specify all
1137 * parameters to assure proper operation.
1138 *
1139 * return values: -EINVAL - wrong argument size
1140 * -EINVAL - if ftape_decode_header_segment() failed.
1141 */
1142static int set_format_parms(struct ftfmtparms *p, __u8 *hseg_buf)
1143{
1144 ft_trace_t old_level = TRACE_LEVEL;
1145 TRACE_FUN(ft_t_flow);
1146
1147 TRACE(ft_t_noise, "MTIOCFTFORMAT operation FTFMT_SETPARMS");
1148 memset(hseg_buf, 0, FT_SEGMENT_SIZE);
1149 PUT4(hseg_buf, FT_SIGNATURE, FT_HSEG_MAGIC);
1150
1151 /* fill in user specified parameters
1152 */
1153 hseg_buf[FT_FMT_CODE] = (__u8)p->ft_fmtcode;
1154 PUT2(hseg_buf, FT_SPT, p->ft_spt);
1155 hseg_buf[FT_TPC] = (__u8)p->ft_tpc;
1156 hseg_buf[FT_FHM] = (__u8)p->ft_fhm;
1157 hseg_buf[FT_FTM] = (__u8)p->ft_ftm;
1158
1159 /* fill in sane defaults to make ftape happy.
1160 */
1161 hseg_buf[FT_FSM] = (__u8)128; /* 128 is hard wired all over ftape */
1162 if (p->ft_fmtcode == fmt_big) {
1163 PUT4(hseg_buf, FT_6_HSEG_1, 0);
1164 PUT4(hseg_buf, FT_6_HSEG_2, 1);
1165 PUT4(hseg_buf, FT_6_FRST_SEG, 2);
1166 PUT4(hseg_buf, FT_6_LAST_SEG, p->ft_spt * p->ft_tpc - 1);
1167 } else {
1168 PUT2(hseg_buf, FT_HSEG_1, 0);
1169 PUT2(hseg_buf, FT_HSEG_2, 1);
1170 PUT2(hseg_buf, FT_FRST_SEG, 2);
1171 PUT2(hseg_buf, FT_LAST_SEG, p->ft_spt * p->ft_tpc - 1);
1172 }
1173
1174 /* Synchronize with the low level module. This is particularly
1175 * needed for unformatted cartridges as the QIC std was previously
1176 * unknown BUT is needed to set data rate and to calculate timeouts.
1177 */
1178 TRACE_CATCH(ftape_calibrate_data_rate(p->ft_qicstd&QIC_TAPE_STD_MASK),
1179 _res = -EINVAL);
1180
1181 /* The following will also recalcualte the timeouts for the tape
1182 * length and QIC std we want to format to.
1183 * abort with -EINVAL rather than -EIO
1184 */
1185 SET_TRACE_LEVEL(ft_t_warn);
1186 TRACE_CATCH(ftape_decode_header_segment(hseg_buf),
1187 SET_TRACE_LEVEL(old_level); _res = -EINVAL);
1188 SET_TRACE_LEVEL(old_level);
1189 TRACE_EXIT 0;
1190}
1191
1192/*
1193 * Return the internal SOFTWARE status of the kernel driver. This does
1194 * NOT query the tape drive about its status.
1195 */
1196static int get_format_parms(struct ftfmtparms *p, __u8 *hseg_buffer)
1197{
1198 TRACE_FUN(ft_t_flow);
1199
1200 TRACE(ft_t_noise, "MTIOCFTFORMAT operation FTFMT_GETPARMS");
1201 p->ft_qicstd = ft_qic_std;
1202 p->ft_fmtcode = ft_format_code;
1203 p->ft_fhm = hseg_buffer[FT_FHM];
1204 p->ft_ftm = hseg_buffer[FT_FTM];
1205 p->ft_spt = ft_segments_per_track;
1206 p->ft_tpc = ft_tracks_per_tape;
1207 TRACE_EXIT 0;
1208}
1209
1210static int mtiocftformat(struct mtftformat *mtftformat, int arg_size)
1211{
1212 int result;
1213 union fmt_arg *arg = &mtftformat->fmt_arg;
1214 TRACE_FUN(ft_t_flow);
1215
1216 TRACE(ft_t_noise, "Mag tape ioctl command: MTIOCFTFORMAT");
1217 if (zft_offline) {
1218 if (ft_no_tape) {
1219 TRACE_ABORT(-ENXIO, ft_t_info, "no tape present");
1220 } else {
1221 TRACE_ABORT(-ENXIO, ft_t_info, "drive is offline");
1222 }
1223 }
1224 if (zft_qic_mode) {
1225 TRACE_ABORT(-EACCES, ft_t_info,
1226 "driver needs to be in raw mode for this ioctl");
1227 }
1228 if (zft_hseg_buf == NULL) {
1229 TRACE_CATCH(zft_vcalloc_once(&zft_hseg_buf, FT_SEGMENT_SIZE),);
1230 }
1231 zft_header_read = 0;
1232 switch(mtftformat->fmt_op) {
1233 case FTFMT_SET_PARMS:
1234 TRACE_CATCH(set_format_parms(&arg->fmt_parms, zft_hseg_buf),);
1235 TRACE_EXIT 0;
1236 case FTFMT_GET_PARMS:
1237 TRACE_CATCH(get_format_parms(&arg->fmt_parms, zft_hseg_buf),);
1238 TRACE_EXIT 0;
1239 case FTFMT_FORMAT_TRACK:
1240 if ((ft_formatted && zft_check_write_access(&zft_pos) < 0) ||
1241 (!ft_formatted && zft_write_protected)) {
1242 TRACE_ABORT(-EACCES, ft_t_info, "Write access denied");
1243 }
1244 TRACE_CATCH(ftape_format_track(arg->fmt_track.ft_track,
1245 arg->fmt_track.ft_gap3),);
1246 TRACE_EXIT 0;
1247 case FTFMT_STATUS:
1248 TRACE_CATCH(ftape_format_status(&arg->fmt_status.ft_segment),);
1249 TRACE_EXIT 0;
1250 case FTFMT_VERIFY:
1251 TRACE_CATCH(ftape_verify_segment(arg->fmt_verify.ft_segment,
1252 (SectorMap *)&arg->fmt_verify.ft_bsm),);
1253 TRACE_EXIT 0;
1254 default:
1255 TRACE_ABORT(-EINVAL, ft_t_err, "Invalid format operation");
1256 }
1257 TRACE_EXIT result;
1258}
1259#endif
1260
1261#ifdef MTIOCFTCMD
1262/*
1263 * send a QIC-117 command to the drive, with optional timeouts,
1264 * parameter and result bits. This is intended to be used together
1265 * with the formatting ioctl.
1266 */
1267static int mtiocftcmd(struct mtftcmd *ftcmd, int arg_size)
1268{
1269 int i;
1270 TRACE_FUN(ft_t_flow);
1271
1272 TRACE(ft_t_noise, "Mag tape ioctl command: MTIOCFTCMD");
1273 if (!capable(CAP_SYS_ADMIN)) {
1274 TRACE_ABORT(-EPERM, ft_t_info,
1275 "need CAP_SYS_ADMIN capability to send raw qic-117 commands");
1276 }
1277 if (zft_qic_mode) {
1278 TRACE_ABORT(-EACCES, ft_t_info,
1279 "driver needs to be in raw mode for this ioctl");
1280 }
1281 if (arg_size != sizeof(struct mtftcmd)) {
1282 TRACE_ABORT(-EINVAL,
1283 ft_t_info, "bad argument size: %d", arg_size);
1284 }
1285 if (ftcmd->ft_wait_before) {
1286 TRACE_CATCH(ftape_ready_wait(ftcmd->ft_wait_before,
1287 &ftcmd->ft_status),);
1288 }
1289 if (ftcmd->ft_status & QIC_STATUS_ERROR)
1290 goto ftmtcmd_error;
1291 if (ftcmd->ft_result_bits != 0) {
1292 TRACE_CATCH(ftape_report_operation(&ftcmd->ft_result,
1293 ftcmd->ft_cmd,
1294 ftcmd->ft_result_bits),);
1295 } else {
1296 TRACE_CATCH(ftape_command(ftcmd->ft_cmd),);
1297 if (ftcmd->ft_status & QIC_STATUS_ERROR)
1298 goto ftmtcmd_error;
1299 for (i = 0; i < ftcmd->ft_parm_cnt; i++) {
1300 TRACE_CATCH(ftape_parameter(ftcmd->ft_parms[i]&0x0f),);
1301 if (ftcmd->ft_status & QIC_STATUS_ERROR)
1302 goto ftmtcmd_error;
1303 }
1304 }
1305 if (ftcmd->ft_wait_after != 0) {
1306 TRACE_CATCH(ftape_ready_wait(ftcmd->ft_wait_after,
1307 &ftcmd->ft_status),);
1308 }
1309ftmtcmd_error:
1310 if (ftcmd->ft_status & QIC_STATUS_ERROR) {
1311 TRACE(ft_t_noise, "error status set");
1312 TRACE_CATCH(ftape_report_error(&ftcmd->ft_error,
1313 &ftcmd->ft_cmd, 1),);
1314 }
1315 TRACE_EXIT 0; /* this is not an i/o error */
1316}
1317#endif
1318
1319/* IOCTL routine called by kernel-interface code
1320 */
1321int _zft_ioctl(unsigned int command, void __user * arg)
1322{
1323 int result;
1324 union { struct mtop mtop;
1325 struct mtget mtget;
1326 struct mtpos mtpos;
1327#ifdef MTIOCRDFTSEG
1328 struct mtftseg mtftseg;
1329#endif
1330#ifdef MTIOCVOLINFO
1331 struct mtvolinfo mtvolinfo;
1332#endif
1333#ifdef MTIOCGETSIZE
1334 struct mttapesize mttapesize;
1335#endif
1336#ifdef MTIOCFTFORMAT
1337 struct mtftformat mtftformat;
1338#endif
1339#ifdef ZFT_OBSOLETE
1340 struct mtblksz mtblksz;
1341#endif
1342#ifdef MTIOCFTCMD
1343 struct mtftcmd mtftcmd;
1344#endif
1345 } krnl_arg;
1346 int arg_size = _IOC_SIZE(command);
1347 int dir = _IOC_DIR(command);
1348 TRACE_FUN(ft_t_flow);
1349
1350 /* This check will only catch arguments that are too large !
1351 */
1352 if (dir & (_IOC_READ | _IOC_WRITE) && arg_size > sizeof(krnl_arg)) {
1353 TRACE_ABORT(-EINVAL,
1354 ft_t_info, "bad argument size: %d", arg_size);
1355 }
1356 if (dir & _IOC_WRITE) {
1357 if (copy_from_user(&krnl_arg, arg, arg_size) != 0) {
1358 TRACE_EXIT -EFAULT;
1359 }
1360 }
1361 TRACE(ft_t_flow, "called with ioctl command: 0x%08x", command);
1362 switch (command) {
1363 case MTIOCTOP:
1364 result = mtioctop(&krnl_arg.mtop, arg_size);
1365 break;
1366 case MTIOCGET:
1367 result = mtiocget(&krnl_arg.mtget, arg_size);
1368 break;
1369 case MTIOCPOS:
1370 result = mtiocpos(&krnl_arg.mtpos, arg_size);
1371 break;
1372#ifdef MTIOCVOLINFO
1373 case MTIOCVOLINFO:
1374 result = mtiocvolinfo(&krnl_arg.mtvolinfo, arg_size);
1375 break;
1376#endif
1377#ifdef ZFT_OBSOLETE
1378 case MTIOC_ZFTAPE_GETBLKSZ:
1379 result = mtioc_zftape_getblksz(&krnl_arg.mtblksz, arg_size);
1380 break;
1381#endif
1382#ifdef MTIOCRDFTSEG
1383 case MTIOCRDFTSEG: /* read a segment via ioctl */
1384 result = mtiocrdftseg(&krnl_arg.mtftseg, arg_size);
1385 break;
1386#endif
1387#ifdef MTIOCWRFTSEG
1388 case MTIOCWRFTSEG: /* write a segment via ioctl */
1389 result = mtiocwrftseg(&krnl_arg.mtftseg, arg_size);
1390 break;
1391#endif
1392#ifdef MTIOCGETSIZE
1393 case MTIOCGETSIZE:
1394 result = mtiocgetsize(&krnl_arg.mttapesize, arg_size);
1395 break;
1396#endif
1397#ifdef MTIOCFTFORMAT
1398 case MTIOCFTFORMAT:
1399 result = mtiocftformat(&krnl_arg.mtftformat, arg_size);
1400 break;
1401#endif
1402#ifdef MTIOCFTCMD
1403 case MTIOCFTCMD:
1404 result = mtiocftcmd(&krnl_arg.mtftcmd, arg_size);
1405 break;
1406#endif
1407 default:
1408 result = -EINVAL;
1409 break;
1410 }
1411 if ((result >= 0) && (dir & _IOC_READ)) {
1412 if (copy_to_user(arg, &krnl_arg, arg_size) != 0) {
1413 TRACE_EXIT -EFAULT;
1414 }
1415 }
1416 TRACE_EXIT result;
1417}
diff --git a/drivers/char/ftape/zftape/zftape-ctl.h b/drivers/char/ftape/zftape/zftape-ctl.h
deleted file mode 100644
index 8e6f2d7ac74e..000000000000
--- a/drivers/char/ftape/zftape/zftape-ctl.h
+++ /dev/null
@@ -1,58 +0,0 @@
1#ifndef _ZFTAPE_CTL_H
2#define _ZFTAPE_CTL_H
3
4/*
5 * Copyright (C) 1996, 1997 Claus-Justus Heine.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 *
22 * $Source: /homes/cvs/ftape-stacked/ftape/zftape/zftape-ctl.h,v $
23 * $Revision: 1.2 $
24 * $Date: 1997/10/05 19:19:02 $
25 *
26 * This file contains the non-standard IOCTL related definitions
27 * for the QIC-40/80 floppy-tape driver for Linux.
28 */
29
30#include <linux/ioctl.h>
31#include <linux/mtio.h>
32
33#include "../zftape/zftape-rw.h"
34
35#ifdef CONFIG_ZFTAPE_MODULE
36#define ftape_status (*zft_status)
37#endif
38
39extern int zft_offline;
40extern int zft_mt_compression;
41extern int zft_write_protected;
42extern int zft_header_read;
43extern unsigned int zft_unit;
44extern int zft_resid;
45
46extern void zft_reset_position(zft_position *pos);
47extern int zft_check_write_access(zft_position *pos);
48extern int zft_def_idle_state(void);
49
50/* hooks for the VFS interface
51 */
52extern int _zft_open(unsigned int dev_minor, unsigned int access_mode);
53extern int _zft_close(void);
54extern int _zft_ioctl(unsigned int command, void __user *arg);
55#endif
56
57
58
diff --git a/drivers/char/ftape/zftape/zftape-eof.c b/drivers/char/ftape/zftape/zftape-eof.c
deleted file mode 100644
index dcadcaee9ac1..000000000000
--- a/drivers/char/ftape/zftape/zftape-eof.c
+++ /dev/null
@@ -1,199 +0,0 @@
1/*
2 * I use these routines just to decide when I have to fake a
3 * volume-table to preserve compatibility to original ftape.
4 */
5/*
6 * Copyright (C) 1994-1995 Bas Laarhoven.
7 *
8 * Modified for zftape 1996, 1997 Claus Heine.
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2, or (at your option)
13 any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; see the file COPYING. If not, write to
22 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
23
24 * $Source: /homes/cvs/ftape-stacked/ftape/zftape/zftape-eof.c,v $
25 * $Revision: 1.2 $
26 * $Date: 1997/10/05 19:19:02 $
27 *
28 * This file contains the eof mark handling code
29 * for the QIC-40/80 floppy-tape driver for Linux.
30 */
31
32#include <linux/string.h>
33#include <linux/errno.h>
34
35#include <linux/zftape.h>
36
37#include "../zftape/zftape-init.h"
38#include "../zftape/zftape-rw.h"
39#include "../zftape/zftape-eof.h"
40
41/* Global vars.
42 */
43
44/* a copy of the failed sector log from the header segment.
45 */
46eof_mark_union *zft_eof_map;
47
48/* number of eof marks (entries in bad sector log) on tape.
49 */
50int zft_nr_eof_marks = -1;
51
52
53/* Local vars.
54 */
55
56static char linux_tape_label[] = "Linux raw format V";
57enum {
58 min_fmt_version = 1, max_fmt_version = 2
59};
60static unsigned ftape_fmt_version = 0;
61
62
63/* Ftape (mis)uses the bad sector log to record end-of-file marks.
64 * Initially (when the tape is erased) all entries in the bad sector
65 * log are added to the tape's bad sector map. The bad sector log then
66 * is cleared.
67 *
68 * The bad sector log normally contains entries of the form:
69 * even 16-bit word: segment number of bad sector
70 * odd 16-bit word: encoded date
71 * There can be a total of 448 entries (1792 bytes).
72 *
73 * My guess is that no program is using this bad sector log (the *
74 * format seems useless as there is no indication of the bad sector
75 * itself, only the segment) However, if any program does use the bad
76 * sector log, the format used by ftape will let the program think
77 * there are some bad sectors and no harm is done.
78 *
79 * The eof mark entries that ftape stores in the bad sector log: even
80 * 16-bit word: segment number of eof mark odd 16-bit word: sector
81 * number of eof mark [1..32]
82 *
83 * The zft_eof_map as maintained is a sorted list of eof mark entries.
84 *
85 *
86 * The tape name field in the header segments is used to store a linux
87 * tape identification string and a version number. This way the tape
88 * can be recognized as a Linux raw format tape when using tools under
89 * other OS's.
90 *
91 * 'Wide' QIC tapes (format code 4) don't have a failed sector list
92 * anymore. That space is used for the (longer) bad sector map that
93 * now is a variable length list too. We now store our end-of-file
94 * marker list after the bad-sector-map on tape. The list is delimited
95 * by a (__u32) 0 entry.
96 */
97
98int zft_ftape_validate_label(char *label)
99{
100 static char tmp_label[45];
101 int result = 0;
102 TRACE_FUN(ft_t_any);
103
104 memcpy(tmp_label, label, FT_LABEL_SZ);
105 tmp_label[FT_LABEL_SZ] = '\0';
106 TRACE(ft_t_noise, "tape label = `%s'", tmp_label);
107 ftape_fmt_version = 0;
108 if (memcmp(label, linux_tape_label, strlen(linux_tape_label)) == 0) {
109 int pos = strlen(linux_tape_label);
110 while (label[pos] >= '0' && label[pos] <= '9') {
111 ftape_fmt_version *= 10;
112 ftape_fmt_version = label[ pos++] - '0';
113 }
114 result = (ftape_fmt_version >= min_fmt_version &&
115 ftape_fmt_version <= max_fmt_version);
116 }
117 TRACE(ft_t_noise, "format version = %d", ftape_fmt_version);
118 TRACE_EXIT result;
119}
120
121static __u8 * find_end_of_eof_list(__u8 * ptr, __u8 * limit)
122{
123 while (ptr + 3 < limit) {
124
125 if (get_unaligned((__u32*)ptr)) {
126 ptr += sizeof(__u32);
127 } else {
128 return ptr;
129 }
130 }
131 return NULL;
132}
133
134void zft_ftape_extract_file_marks(__u8* address)
135{
136 int i;
137 TRACE_FUN(ft_t_any);
138
139 zft_eof_map = NULL;
140 if (ft_format_code == fmt_var || ft_format_code == fmt_big) {
141 __u8* end;
142 __u8* start = ftape_find_end_of_bsm_list(address);
143
144 zft_nr_eof_marks = 0;
145 if (start) {
146 start += 3; /* skip end of list mark */
147 end = find_end_of_eof_list(start,
148 address + FT_SEGMENT_SIZE);
149 if (end && end - start <= FT_FSL_SIZE) {
150 zft_nr_eof_marks = ((end - start) /
151 sizeof(eof_mark_union));
152 zft_eof_map = (eof_mark_union *)start;
153 } else {
154 TRACE(ft_t_err,
155 "EOF Mark List is too long or damaged!");
156 }
157 } else {
158 TRACE(ft_t_err,
159 "Bad Sector List is too long or damaged !");
160 }
161 } else {
162 zft_eof_map = (eof_mark_union *)&address[FT_FSL];
163 zft_nr_eof_marks = GET2(address, FT_FSL_CNT);
164 }
165 TRACE(ft_t_noise, "number of file marks: %d", zft_nr_eof_marks);
166 if (ftape_fmt_version == 1) {
167 TRACE(ft_t_info, "swapping version 1 fields");
168 /* version 1 format uses swapped sector and segment
169 * fields, correct that !
170 */
171 for (i = 0; i < zft_nr_eof_marks; ++i) {
172 __u16 tmp = GET2(&zft_eof_map[i].mark.segment,0);
173 PUT2(&zft_eof_map[i].mark.segment, 0,
174 GET2(&zft_eof_map[i].mark.date,0));
175 PUT2(&zft_eof_map[i].mark.date, 0, tmp);
176 }
177 }
178 for (i = 0; i < zft_nr_eof_marks; ++i) {
179 TRACE(ft_t_noise, "eof mark: %5d/%2d",
180 GET2(&zft_eof_map[i].mark.segment, 0),
181 GET2(&zft_eof_map[i].mark.date,0));
182 }
183 TRACE_EXIT;
184}
185
186void zft_clear_ftape_file_marks(void)
187{
188 TRACE_FUN(ft_t_flow);
189 /* Clear failed sector log: remove all tape marks. We
190 * don't use old ftape-style EOF-marks.
191 */
192 TRACE(ft_t_info, "Clearing old ftape's eof map");
193 memset(zft_eof_map, 0, zft_nr_eof_marks * sizeof(__u32));
194 zft_nr_eof_marks = 0;
195 PUT2(zft_hseg_buf, FT_FSL_CNT, 0); /* nr of eof-marks */
196 zft_header_changed = 1;
197 zft_update_label(zft_hseg_buf);
198 TRACE_EXIT;
199}
diff --git a/drivers/char/ftape/zftape/zftape-eof.h b/drivers/char/ftape/zftape/zftape-eof.h
deleted file mode 100644
index 26568c26c518..000000000000
--- a/drivers/char/ftape/zftape/zftape-eof.h
+++ /dev/null
@@ -1,52 +0,0 @@
1#ifndef _ZFTAPE_EOF_H
2#define _ZFTAPE_EOF_H
3
4/*
5 * Copyright (C) 1994-1995 Bas Laarhoven.
6 * adaptaed for zftape 1996, 1997 by Claus Heine
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; see the file COPYING. If not, write to
20 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21
22 *
23 * $Source: /homes/cvs/ftape-stacked/ftape/zftape/zftape-eof.h,v $
24 * $Revision: 1.2 $
25 * $Date: 1997/10/05 19:19:03 $
26 *
27 * Definitions and declarations for the end of file markers
28 * for the QIC-40/80 floppy-tape driver for Linux.
29 */
30
31#include <linux/ftape-header-segment.h>
32#include "../zftape/zftape-buffers.h"
33/* failed sector log size (only used if format code != 4).
34 */
35
36typedef union {
37 ft_fsl_entry mark;
38 __u32 entry;
39} eof_mark_union;
40
41/* ftape-eof.c defined global vars.
42 */
43extern int zft_nr_eof_marks;
44extern eof_mark_union *zft_eof_map;
45
46/* ftape-eof.c defined global functions.
47 */
48extern void zft_ftape_extract_file_marks(__u8* address);
49extern int zft_ftape_validate_label(char* label);
50extern void zft_clear_ftape_file_marks(void);
51
52#endif
diff --git a/drivers/char/ftape/zftape/zftape-init.c b/drivers/char/ftape/zftape/zftape-init.c
deleted file mode 100644
index 164a1aa77a2f..000000000000
--- a/drivers/char/ftape/zftape/zftape-init.c
+++ /dev/null
@@ -1,377 +0,0 @@
1/*
2 * Copyright (C) 1996, 1997 Claus-Justus Heine.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 *
19 * This file contains the code that registers the zftape frontend
20 * to the ftape floppy tape driver for Linux
21 */
22
23#include <linux/module.h>
24#include <linux/errno.h>
25#include <linux/fs.h>
26#include <linux/kernel.h>
27#include <linux/signal.h>
28#include <linux/major.h>
29#include <linux/slab.h>
30#ifdef CONFIG_KMOD
31#include <linux/kmod.h>
32#endif
33#include <linux/fcntl.h>
34#include <linux/smp_lock.h>
35
36#include <linux/zftape.h>
37#include <linux/init.h>
38#include <linux/device.h>
39
40#include "../zftape/zftape-init.h"
41#include "../zftape/zftape-read.h"
42#include "../zftape/zftape-write.h"
43#include "../zftape/zftape-ctl.h"
44#include "../zftape/zftape-buffers.h"
45
46MODULE_AUTHOR("(c) 1996, 1997 Claus-Justus Heine "
47 "(claus@momo.math.rwth-aachen.de)");
48MODULE_DESCRIPTION(ZFTAPE_VERSION " - "
49 "VFS interface for the Linux floppy tape driver. "
50 "Support for QIC-113 compatible volume table "
51 "and builtin compression (lzrw3 algorithm)");
52MODULE_SUPPORTED_DEVICE("char-major-27");
53MODULE_LICENSE("GPL");
54
55/* Global vars.
56 */
57struct zft_cmpr_ops *zft_cmpr_ops = NULL;
58const ftape_info *zft_status;
59
60/* Local vars.
61 */
62static unsigned long busy_flag;
63
64static sigset_t orig_sigmask;
65
66/* the interface to the kernel vfs layer
67 */
68
69/* Note about llseek():
70 *
71 * st.c and tpqic.c update fp->f_pos but don't implment llseek() and
72 * initialize the llseek component of the file_ops struct with NULL.
73 * This means that the user will get the default seek, but the tape
74 * device will not respect the new position, but happily read from the
75 * old position. Think a zftape specific llseek() function would be
76 * better, returning -ESPIPE. TODO.
77 */
78
79static int zft_open (struct inode *ino, struct file *filep);
80static int zft_close(struct inode *ino, struct file *filep);
81static int zft_ioctl(struct inode *ino, struct file *filep,
82 unsigned int command, unsigned long arg);
83static int zft_mmap(struct file *filep, struct vm_area_struct *vma);
84static ssize_t zft_read (struct file *fp, char __user *buff,
85 size_t req_len, loff_t *ppos);
86static ssize_t zft_write(struct file *fp, const char __user *buff,
87 size_t req_len, loff_t *ppos);
88
89static const struct file_operations zft_cdev =
90{
91 .owner = THIS_MODULE,
92 .read = zft_read,
93 .write = zft_write,
94 .ioctl = zft_ioctl,
95 .mmap = zft_mmap,
96 .open = zft_open,
97 .release = zft_close,
98};
99
100static struct class *zft_class;
101
102/* Open floppy tape device
103 */
104static int zft_open(struct inode *ino, struct file *filep)
105{
106 int result;
107 TRACE_FUN(ft_t_flow);
108
109 nonseekable_open(ino, filep);
110 TRACE(ft_t_flow, "called for minor %d", iminor(ino));
111 if ( test_and_set_bit(0,&busy_flag) ) {
112 TRACE_ABORT(-EBUSY, ft_t_warn, "failed: already busy");
113 }
114 if ((iminor(ino) & ~(ZFT_MINOR_OP_MASK | FTAPE_NO_REWIND))
115 >
116 FTAPE_SEL_D) {
117 clear_bit(0,&busy_flag);
118 TRACE_ABORT(-ENXIO, ft_t_err, "failed: invalid unit nr");
119 }
120 orig_sigmask = current->blocked;
121 sigfillset(&current->blocked);
122 result = _zft_open(iminor(ino), filep->f_flags & O_ACCMODE);
123 if (result < 0) {
124 current->blocked = orig_sigmask; /* restore mask */
125 clear_bit(0,&busy_flag);
126 TRACE_ABORT(result, ft_t_err, "_ftape_open failed");
127 } else {
128 /* Mask signals that will disturb proper operation of the
129 * program that is calling.
130 */
131 current->blocked = orig_sigmask;
132 sigaddsetmask (&current->blocked, _DO_BLOCK);
133 TRACE_EXIT 0;
134 }
135}
136
137/* Close floppy tape device
138 */
139static int zft_close(struct inode *ino, struct file *filep)
140{
141 int result;
142 TRACE_FUN(ft_t_flow);
143
144 if ( !test_bit(0,&busy_flag) || iminor(ino) != zft_unit) {
145 TRACE(ft_t_err, "failed: not busy or wrong unit");
146 TRACE_EXIT 0;
147 }
148 sigfillset(&current->blocked);
149 result = _zft_close();
150 if (result < 0) {
151 TRACE(ft_t_err, "_zft_close failed");
152 }
153 current->blocked = orig_sigmask; /* restore before open state */
154 clear_bit(0,&busy_flag);
155 TRACE_EXIT 0;
156}
157
158/* Ioctl for floppy tape device
159 */
160static int zft_ioctl(struct inode *ino, struct file *filep,
161 unsigned int command, unsigned long arg)
162{
163 int result = -EIO;
164 sigset_t old_sigmask;
165 TRACE_FUN(ft_t_flow);
166
167 if ( !test_bit(0,&busy_flag) || iminor(ino) != zft_unit || ft_failure) {
168 TRACE_ABORT(-EIO, ft_t_err,
169 "failed: not busy, failure or wrong unit");
170 }
171 old_sigmask = current->blocked; /* save mask */
172 sigfillset(&current->blocked);
173 /* This will work as long as sizeof(void *) == sizeof(long) */
174 result = _zft_ioctl(command, (void __user *) arg);
175 current->blocked = old_sigmask; /* restore mask */
176 TRACE_EXIT result;
177}
178
179/* Ioctl for floppy tape device
180 */
181static int zft_mmap(struct file *filep, struct vm_area_struct *vma)
182{
183 int result = -EIO;
184 sigset_t old_sigmask;
185 TRACE_FUN(ft_t_flow);
186
187 if ( !test_bit(0,&busy_flag) ||
188 iminor(filep->f_dentry->d_inode) != zft_unit ||
189 ft_failure)
190 {
191 TRACE_ABORT(-EIO, ft_t_err,
192 "failed: not busy, failure or wrong unit");
193 }
194 old_sigmask = current->blocked; /* save mask */
195 sigfillset(&current->blocked);
196 if ((result = ftape_mmap(vma)) >= 0) {
197#ifndef MSYNC_BUG_WAS_FIXED
198 static struct vm_operations_struct dummy = { NULL, };
199 vma->vm_ops = &dummy;
200#endif
201 }
202 current->blocked = old_sigmask; /* restore mask */
203 TRACE_EXIT result;
204}
205
206/* Read from floppy tape device
207 */
208static ssize_t zft_read(struct file *fp, char __user *buff,
209 size_t req_len, loff_t *ppos)
210{
211 int result = -EIO;
212 sigset_t old_sigmask;
213 struct inode *ino = fp->f_dentry->d_inode;
214 TRACE_FUN(ft_t_flow);
215
216 TRACE(ft_t_data_flow, "called with count: %ld", (unsigned long)req_len);
217 if (!test_bit(0,&busy_flag) || iminor(ino) != zft_unit || ft_failure) {
218 TRACE_ABORT(-EIO, ft_t_err,
219 "failed: not busy, failure or wrong unit");
220 }
221 old_sigmask = current->blocked; /* save mask */
222 sigfillset(&current->blocked);
223 result = _zft_read(buff, req_len);
224 current->blocked = old_sigmask; /* restore mask */
225 TRACE(ft_t_data_flow, "return with count: %d", result);
226 TRACE_EXIT result;
227}
228
229/* Write to tape device
230 */
231static ssize_t zft_write(struct file *fp, const char __user *buff,
232 size_t req_len, loff_t *ppos)
233{
234 int result = -EIO;
235 sigset_t old_sigmask;
236 struct inode *ino = fp->f_dentry->d_inode;
237 TRACE_FUN(ft_t_flow);
238
239 TRACE(ft_t_flow, "called with count: %ld", (unsigned long)req_len);
240 if (!test_bit(0,&busy_flag) || iminor(ino) != zft_unit || ft_failure) {
241 TRACE_ABORT(-EIO, ft_t_err,
242 "failed: not busy, failure or wrong unit");
243 }
244 old_sigmask = current->blocked; /* save mask */
245 sigfillset(&current->blocked);
246 result = _zft_write(buff, req_len);
247 current->blocked = old_sigmask; /* restore mask */
248 TRACE(ft_t_data_flow, "return with count: %d", result);
249 TRACE_EXIT result;
250}
251
252/* END OF VFS INTERFACE
253 *
254 *****************************************************************************/
255
256/* driver/module initialization
257 */
258
259/* the compression module has to call this function to hook into the zftape
260 * code
261 */
262int zft_cmpr_register(struct zft_cmpr_ops *new_ops)
263{
264 TRACE_FUN(ft_t_flow);
265
266 if (zft_cmpr_ops != NULL) {
267 TRACE_EXIT -EBUSY;
268 } else {
269 zft_cmpr_ops = new_ops;
270 TRACE_EXIT 0;
271 }
272}
273
274/* lock the zft-compressor() module.
275 */
276int zft_cmpr_lock(int try_to_load)
277{
278 if (zft_cmpr_ops == NULL) {
279#ifdef CONFIG_KMOD
280 if (try_to_load) {
281 request_module("zft-compressor");
282 if (zft_cmpr_ops == NULL) {
283 return -ENOSYS;
284 }
285 } else {
286 return -ENOSYS;
287 }
288#else
289 return -ENOSYS;
290#endif
291 }
292 (*zft_cmpr_ops->lock)();
293 return 0;
294}
295
296#ifdef CONFIG_ZFT_COMPRESSOR
297extern int zft_compressor_init(void);
298#endif
299
300/* Called by modules package when installing the driver or by kernel
301 * during the initialization phase
302 */
303int __init zft_init(void)
304{
305 int i;
306 TRACE_FUN(ft_t_flow);
307
308#ifdef MODULE
309 printk(KERN_INFO ZFTAPE_VERSION "\n");
310 if (TRACE_LEVEL >= ft_t_info) {
311 printk(
312KERN_INFO
313"(c) 1996, 1997 Claus-Justus Heine (claus@momo.math.rwth-aachen.de)\n"
314KERN_INFO
315"vfs interface for ftape floppy tape driver.\n"
316KERN_INFO
317"Support for QIC-113 compatible volume table, dynamic memory allocation\n"
318KERN_INFO
319"and builtin compression (lzrw3 algorithm).\n");
320 }
321#else /* !MODULE */
322 /* print a short no-nonsense boot message */
323 printk(KERN_INFO ZFTAPE_VERSION "\n");
324#endif /* MODULE */
325 TRACE(ft_t_info, "zft_init @ 0x%p", zft_init);
326 TRACE(ft_t_info,
327 "installing zftape VFS interface for ftape driver ...");
328 TRACE_CATCH(register_chrdev(QIC117_TAPE_MAJOR, "zft", &zft_cdev),);
329
330 zft_class = class_create(THIS_MODULE, "zft");
331 for (i = 0; i < 4; i++) {
332 class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i), NULL, "qft%i", i);
333 class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i + 4), NULL, "nqft%i", i);
334 class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i + 16), NULL, "zqft%i", i);
335 class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i + 20), NULL, "nzqft%i", i);
336 class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i + 32), NULL, "rawqft%i", i);
337 class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i + 36), NULL, "nrawrawqft%i", i);
338 }
339
340#ifdef CONFIG_ZFT_COMPRESSOR
341 (void)zft_compressor_init();
342#endif
343 zft_status = ftape_get_status(); /* fetch global data of ftape
344 * hardware driver
345 */
346 TRACE_EXIT 0;
347}
348
349
350/* Called by modules package when removing the driver
351 */
352static void zft_exit(void)
353{
354 int i;
355 TRACE_FUN(ft_t_flow);
356
357 if (unregister_chrdev(QIC117_TAPE_MAJOR, "zft") != 0) {
358 TRACE(ft_t_warn, "failed");
359 } else {
360 TRACE(ft_t_info, "successful");
361 }
362 for (i = 0; i < 4; i++) {
363 class_device_destroy(zft_class, MKDEV(QIC117_TAPE_MAJOR, i));
364 class_device_destroy(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 4));
365 class_device_destroy(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 16));
366 class_device_destroy(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 20));
367 class_device_destroy(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 32));
368 class_device_destroy(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 36));
369 }
370 class_destroy(zft_class);
371 zft_uninit_mem(); /* release remaining memory, if any */
372 printk(KERN_INFO "zftape successfully unloaded.\n");
373 TRACE_EXIT;
374}
375
376module_init(zft_init);
377module_exit(zft_exit);
diff --git a/drivers/char/ftape/zftape/zftape-init.h b/drivers/char/ftape/zftape/zftape-init.h
deleted file mode 100644
index 937e5d48c20e..000000000000
--- a/drivers/char/ftape/zftape/zftape-init.h
+++ /dev/null
@@ -1,77 +0,0 @@
1#ifndef _ZFTAPE_INIT_H
2#define _ZFTAPE_INIT_H
3
4/*
5 * Copyright (C) 1996, 1997 Claus Heine.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 *
22 * $Source: /homes/cvs/ftape-stacked/ftape/zftape/zftape-init.h,v $
23 * $Revision: 1.2 $
24 * $Date: 1997/10/05 19:19:05 $
25 *
26 * This file contains definitions and macro for the vfs
27 * interface defined by zftape
28 *
29 */
30
31#include <linux/ftape-header-segment.h>
32
33#include "../lowlevel/ftape-tracing.h"
34#include "../lowlevel/ftape-ctl.h"
35#include "../lowlevel/ftape-read.h"
36#include "../lowlevel/ftape-write.h"
37#include "../lowlevel/ftape-bsm.h"
38#include "../lowlevel/ftape-io.h"
39#include "../lowlevel/ftape-buffer.h"
40#include "../lowlevel/ftape-format.h"
41
42#include "../zftape/zftape-rw.h"
43
44#ifdef MODULE
45#define ftape_status (*zft_status)
46#endif
47
48extern const ftape_info *zft_status; /* needed for zftape-vtbl.h */
49
50#include "../zftape/zftape-vtbl.h"
51
52struct zft_cmpr_ops {
53 int (*write)(int *write_cnt,
54 __u8 *dst_buf, const int seg_sz,
55 const __u8 __user *src_buf, const int req_len,
56 const zft_position *pos, const zft_volinfo *volume);
57 int (*read)(int *read_cnt,
58 __u8 __user *dst_buf, const int req_len,
59 const __u8 *src_buf, const int seg_sz,
60 const zft_position *pos, const zft_volinfo *volume);
61 int (*seek)(unsigned int new_block_pos,
62 zft_position *pos, const zft_volinfo *volume,
63 __u8 *buffer);
64 void (*lock) (void);
65 void (*reset) (void);
66 void (*cleanup)(void);
67};
68
69extern struct zft_cmpr_ops *zft_cmpr_ops;
70/* zftape-init.c defined global functions.
71 */
72extern int zft_cmpr_register(struct zft_cmpr_ops *new_ops);
73extern int zft_cmpr_lock(int try_to_load);
74
75#endif
76
77
diff --git a/drivers/char/ftape/zftape/zftape-read.c b/drivers/char/ftape/zftape/zftape-read.c
deleted file mode 100644
index 214bf03dce68..000000000000
--- a/drivers/char/ftape/zftape/zftape-read.c
+++ /dev/null
@@ -1,377 +0,0 @@
1/*
2 * Copyright (C) 1996, 1997 Claus-Justus Heine
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 *
19 * $Source: /homes/cvs/ftape-stacked/ftape/zftape/zftape-read.c,v $
20 * $Revision: 1.2 $
21 * $Date: 1997/10/05 19:19:06 $
22 *
23 * This file contains the high level reading code
24 * for the QIC-117 floppy-tape driver for Linux.
25 */
26
27#include <linux/errno.h>
28#include <linux/mm.h>
29
30#include <linux/zftape.h>
31
32#include <asm/uaccess.h>
33
34#include "../zftape/zftape-init.h"
35#include "../zftape/zftape-eof.h"
36#include "../zftape/zftape-ctl.h"
37#include "../zftape/zftape-write.h"
38#include "../zftape/zftape-read.h"
39#include "../zftape/zftape-rw.h"
40#include "../zftape/zftape-vtbl.h"
41
42/* Global vars.
43 */
44int zft_just_before_eof;
45
46/* Local vars.
47 */
48static int buf_len_rd;
49
50void zft_zap_read_buffers(void)
51{
52 buf_len_rd = 0;
53}
54
55int zft_read_header_segments(void)
56{
57 TRACE_FUN(ft_t_flow);
58
59 zft_header_read = 0;
60 TRACE_CATCH(zft_vmalloc_once(&zft_hseg_buf, FT_SEGMENT_SIZE),);
61 TRACE_CATCH(ftape_read_header_segment(zft_hseg_buf),);
62 TRACE(ft_t_info, "Segments written since first format: %d",
63 (int)GET4(zft_hseg_buf, FT_SEG_CNT));
64 zft_qic113 = (ft_format_code != fmt_normal &&
65 ft_format_code != fmt_1100ft &&
66 ft_format_code != fmt_425ft);
67 TRACE(ft_t_info, "ft_first_data_segment: %d, ft_last_data_segment: %d",
68 ft_first_data_segment, ft_last_data_segment);
69 zft_capacity = zft_get_capacity();
70 zft_old_ftape = zft_ftape_validate_label(&zft_hseg_buf[FT_LABEL]);
71 if (zft_old_ftape) {
72 TRACE(ft_t_info,
73"Found old ftaped tape, emulating eof marks, entering read-only mode");
74 zft_ftape_extract_file_marks(zft_hseg_buf);
75 TRACE_CATCH(zft_fake_volume_headers(zft_eof_map,
76 zft_nr_eof_marks),);
77 } else {
78 /* the specs say that the volume table must be
79 * initialized with zeroes during formatting, so it
80 * MUST be readable, i.e. contain vaid ECC
81 * information.
82 */
83 TRACE_CATCH(ftape_read_segment(ft_first_data_segment,
84 zft_deblock_buf,
85 FT_RD_SINGLE),);
86 TRACE_CATCH(zft_extract_volume_headers(zft_deblock_buf),);
87 }
88 zft_header_read = 1;
89 zft_set_flags(zft_unit);
90 zft_reset_position(&zft_pos);
91 TRACE_EXIT 0;
92}
93
94int zft_fetch_segment_fraction(const unsigned int segment, void *buffer,
95 const ft_read_mode_t read_mode,
96 const unsigned int start,
97 const unsigned int size)
98{
99 int seg_sz;
100 TRACE_FUN(ft_t_flow);
101
102 if (segment == zft_deblock_segment) {
103 TRACE(ft_t_data_flow,
104 "re-using segment %d already in deblock buffer",
105 segment);
106 seg_sz = zft_get_seg_sz(segment);
107 if (start > seg_sz) {
108 TRACE_ABORT(-EINVAL, ft_t_bug,
109 "trying to read beyond end of segment:\n"
110 KERN_INFO "seg_sz : %d\n"
111 KERN_INFO "start : %d\n"
112 KERN_INFO "segment: %d",
113 seg_sz, start, segment);
114 }
115 if ((start + size) > seg_sz) {
116 TRACE_EXIT seg_sz - start;
117 }
118 TRACE_EXIT size;
119 }
120 seg_sz = ftape_read_segment_fraction(segment, buffer, read_mode,
121 start, size);
122 TRACE(ft_t_data_flow, "segment %d, result %d", segment, seg_sz);
123 if ((int)seg_sz >= 0 && start == 0 && size == FT_SEGMENT_SIZE) {
124 /* this implicitly assumes that we are always called with
125 * buffer == zft_deblock_buf
126 */
127 zft_deblock_segment = segment;
128 } else {
129 zft_deblock_segment = -1;
130 }
131 TRACE_EXIT seg_sz;
132}
133
134/*
135 * out:
136 *
137 * int *read_cnt: the number of bytes we removed from the
138 * zft_deblock_buf (result)
139 *
140 * int *to_do : the remaining size of the read-request. Is changed.
141 *
142 * in:
143 *
144 * char *buff : buff is the address of the upper part of the user
145 * buffer, that hasn't been filled with data yet.
146 * int buf_pos_read: copy of buf_pos_rd
147 * int buf_len_read: copy of buf_len_rd
148 * char *zft_deblock_buf: ftape_zft_deblock_buf
149 *
150 * returns the amount of data actually copied to the user-buffer
151 *
152 * to_do MUST NOT SHRINK except to indicate an EOT. In this case to_do
153 * has to be set to 0. We cannot return -ENOSPC, because we return the
154 * amount of data actually * copied to the user-buffer
155 */
156static int zft_simple_read (int *read_cnt,
157 __u8 __user *dst_buf,
158 const int to_do,
159 const __u8 *src_buf,
160 const int seg_sz,
161 const zft_position *pos,
162 const zft_volinfo *volume)
163{
164 TRACE_FUN(ft_t_flow);
165
166 if (seg_sz - pos->seg_byte_pos < to_do) {
167 *read_cnt = seg_sz - pos->seg_byte_pos;
168 } else {
169 *read_cnt = to_do;
170 }
171 if (copy_to_user(dst_buf,
172 src_buf + pos->seg_byte_pos, *read_cnt) != 0) {
173 TRACE_EXIT -EFAULT;
174 }
175 TRACE(ft_t_noise, "nr bytes just read: %d", *read_cnt);
176 TRACE_EXIT *read_cnt;
177}
178
179/* req_len: gets clipped due to EOT of EOF.
180 * req_clipped: is a flag indicating whether req_len was clipped or not
181 * volume: contains information on current volume (blk_sz etc.)
182 */
183static int check_read_access(int *req_len,
184 const zft_volinfo **volume,
185 int *req_clipped,
186 const zft_position *pos)
187{
188 static __s64 remaining;
189 static int eod;
190 TRACE_FUN(ft_t_flow);
191
192 if (zft_io_state != zft_reading) {
193 if (zft_offline) { /* offline includes no_tape */
194 TRACE_ABORT(-ENXIO, ft_t_warn,
195 "tape is offline or no cartridge");
196 }
197 if (!ft_formatted) {
198 TRACE_ABORT(-EACCES,
199 ft_t_warn, "tape is not formatted");
200 }
201 /* now enter defined state, read header segment if not
202 * already done and flush write buffers
203 */
204 TRACE_CATCH(zft_def_idle_state(),);
205 zft_io_state = zft_reading;
206 if (zft_tape_at_eod(pos)) {
207 eod = 1;
208 TRACE_EXIT 1;
209 }
210 eod = 0;
211 *volume = zft_find_volume(pos->seg_pos);
212 /* get the space left until EOF */
213 remaining = zft_check_for_eof(*volume, pos);
214 buf_len_rd = 0;
215 TRACE(ft_t_noise, "remaining: " LL_X ", vol_no: %d",
216 LL(remaining), (*volume)->count);
217 } else if (zft_tape_at_eod(pos)) {
218 if (++eod > 2) {
219 TRACE_EXIT -EIO; /* st.c also returns -EIO */
220 } else {
221 TRACE_EXIT 1;
222 }
223 }
224 if ((*req_len % (*volume)->blk_sz) != 0) {
225 /* this message is informational only. The user gets the
226 * proper return value
227 */
228 TRACE_ABORT(-EINVAL, ft_t_info,
229 "req_len %d not a multiple of block size %d",
230 *req_len, (*volume)->blk_sz);
231 }
232 /* As GNU tar doesn't accept partial read counts when the
233 * multiple volume flag is set, we make sure to return the
234 * requested amount of data. Except, of course, at the end of
235 * the tape or file mark.
236 */
237 remaining -= *req_len;
238 if (remaining <= 0) {
239 TRACE(ft_t_noise,
240 "clipped request from %d to %d.",
241 *req_len, (int)(*req_len + remaining));
242 *req_len += remaining;
243 *req_clipped = 1;
244 } else {
245 *req_clipped = 0;
246 }
247 TRACE_EXIT 0;
248}
249
250/* this_segs_size: the current segment's size.
251 * buff: the USER-SPACE buffer provided by the calling function.
252 * req_len: how much data should be read at most.
253 * volume: contains information on current volume (blk_sz etc.)
254 */
255static int empty_deblock_buf(__u8 __user *usr_buf, const int req_len,
256 const __u8 *src_buf, const int seg_sz,
257 zft_position *pos,
258 const zft_volinfo *volume)
259{
260 int cnt;
261 int result = 0;
262 TRACE_FUN(ft_t_flow);
263
264 TRACE(ft_t_data_flow, "this_segs_size: %d", seg_sz);
265 if (zft_use_compression && volume->use_compression) {
266 TRACE_CATCH(zft_cmpr_lock(1 /* try to load */),);
267 TRACE_CATCH(result= (*zft_cmpr_ops->read)(&cnt,
268 usr_buf, req_len,
269 src_buf, seg_sz,
270 pos, volume),);
271 } else {
272 TRACE_CATCH(result= zft_simple_read (&cnt,
273 usr_buf, req_len,
274 src_buf, seg_sz,
275 pos, volume),);
276 }
277 pos->volume_pos += result;
278 pos->tape_pos += cnt;
279 pos->seg_byte_pos += cnt;
280 buf_len_rd -= cnt; /* remaining bytes in buffer */
281 TRACE(ft_t_data_flow, "buf_len_rd: %d, cnt: %d", buf_len_rd, cnt);
282 if(pos->seg_byte_pos >= seg_sz) {
283 pos->seg_pos++;
284 pos->seg_byte_pos = 0;
285 }
286 TRACE(ft_t_data_flow, "bytes moved out of deblock-buffer: %d", cnt);
287 TRACE_EXIT result;
288}
289
290
291/* note: we store the segment id of the segment that is inside the
292 * deblock buffer. This spares a lot of ftape_read_segment()s when we
293 * use small block-sizes. The block-size may be 1kb (SECTOR_SIZE). In
294 * this case a MTFSR 28 maybe still inside the same segment.
295 */
296int _zft_read(char __user *buff, int req_len)
297{
298 int req_clipped;
299 int result = 0;
300 int bytes_read = 0;
301 static unsigned int seg_sz = 0;
302 static const zft_volinfo *volume = NULL;
303 TRACE_FUN(ft_t_flow);
304
305 zft_resid = req_len;
306 result = check_read_access(&req_len, &volume,
307 &req_clipped, &zft_pos);
308 switch(result) {
309 case 0:
310 break; /* nothing special */
311 case 1:
312 TRACE(ft_t_noise, "EOD reached");
313 TRACE_EXIT 0; /* EOD */
314 default:
315 TRACE_ABORT(result, ft_t_noise,
316 "check_read_access() failed with result %d",
317 result);
318 TRACE_EXIT result;
319 }
320 while (req_len > 0) {
321 /* Allow escape from this loop on signal !
322 */
323 FT_SIGNAL_EXIT(_DONT_BLOCK);
324 /* buf_len_rd == 0 means that we need to read a new
325 * segment.
326 */
327 if (buf_len_rd == 0) {
328 while((result = zft_fetch_segment(zft_pos.seg_pos,
329 zft_deblock_buf,
330 FT_RD_AHEAD)) == 0) {
331 zft_pos.seg_pos ++;
332 zft_pos.seg_byte_pos = 0;
333 }
334 if (result < 0) {
335 zft_resid -= bytes_read;
336 TRACE_ABORT(result, ft_t_noise,
337 "zft_fetch_segment(): %d",
338 result);
339 }
340 seg_sz = result;
341 buf_len_rd = seg_sz - zft_pos.seg_byte_pos;
342 }
343 TRACE_CATCH(result = empty_deblock_buf(buff,
344 req_len,
345 zft_deblock_buf,
346 seg_sz,
347 &zft_pos,
348 volume),
349 zft_resid -= bytes_read);
350 TRACE(ft_t_data_flow, "bytes just read: %d", result);
351 bytes_read += result; /* what we got so far */
352 buff += result; /* index in user-buffer */
353 req_len -= result; /* what's left from req_len */
354 } /* while (req_len > 0) */
355 if (req_clipped) {
356 TRACE(ft_t_data_flow,
357 "maybe partial count because of eof mark");
358 if (zft_just_before_eof && bytes_read == 0) {
359 /* req_len was > 0, but user didn't get
360 * anything the user has read in the eof-mark
361 */
362 zft_move_past_eof(&zft_pos);
363 ftape_abort_operation();
364 } else {
365 /* don't skip to the next file before the user
366 * tried to read a second time past EOF Just
367 * mark that we are at EOF and maybe decrement
368 * zft_seg_pos to stay in the same volume;
369 */
370 zft_just_before_eof = 1;
371 zft_position_before_eof(&zft_pos, volume);
372 TRACE(ft_t_noise, "just before eof");
373 }
374 }
375 zft_resid -= result; /* for MTSTATUS */
376 TRACE_EXIT bytes_read;
377}
diff --git a/drivers/char/ftape/zftape/zftape-read.h b/drivers/char/ftape/zftape/zftape-read.h
deleted file mode 100644
index 42941de0c23a..000000000000
--- a/drivers/char/ftape/zftape/zftape-read.h
+++ /dev/null
@@ -1,53 +0,0 @@
1#ifndef _ZFTAPE_READ_H
2#define _ZFTAPE_READ_H
3
4/*
5 * Copyright (C) 1996, 1997 Claus-Justus Heine
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 *
22 * $Source: /homes/cvs/ftape-stacked/ftape/zftape/zftape-read.h,v $
23 * $Revision: 1.2 $
24 * $Date: 1997/10/05 19:19:07 $
25 *
26 * This file contains the definitions for the read functions
27 * for the zftape driver for Linux.
28 *
29 */
30
31#include "../lowlevel/ftape-read.h"
32
33/* ftape-read.c defined global vars.
34 */
35extern int zft_just_before_eof;
36
37/* ftape-read.c defined global functions.
38 */
39extern void zft_zap_read_buffers(void);
40extern int zft_read_header_segments(void);
41extern int zft_fetch_segment_fraction(const unsigned int segment,
42 void *buffer,
43 const ft_read_mode_t read_mode,
44 const unsigned int start,
45 const unsigned int size);
46#define zft_fetch_segment(segment, address, read_mode) \
47 zft_fetch_segment_fraction(segment, address, read_mode, \
48 0, FT_SEGMENT_SIZE)
49/* hook for the VFS interface
50 */
51extern int _zft_read(char __user *buff, int req_len);
52
53#endif /* _ZFTAPE_READ_H */
diff --git a/drivers/char/ftape/zftape/zftape-rw.c b/drivers/char/ftape/zftape/zftape-rw.c
deleted file mode 100644
index dab634686885..000000000000
--- a/drivers/char/ftape/zftape/zftape-rw.c
+++ /dev/null
@@ -1,375 +0,0 @@
1/*
2 * Copyright (C) 1996, 1997 Claus-Justus Heine
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 *
19 * $Source: /homes/cvs/ftape-stacked/ftape/zftape/zftape-rw.c,v $
20 * $Revision: 1.2 $
21 * $Date: 1997/10/05 19:19:08 $
22 *
23 * This file contains some common code for the r/w code for
24 * zftape.
25 */
26
27#include <linux/errno.h>
28#include <linux/mm.h>
29
30#include <linux/zftape.h>
31#include "../zftape/zftape-init.h"
32#include "../zftape/zftape-eof.h"
33#include "../zftape/zftape-ctl.h"
34#include "../zftape/zftape-write.h"
35#include "../zftape/zftape-read.h"
36#include "../zftape/zftape-rw.h"
37#include "../zftape/zftape-vtbl.h"
38
39/* Global vars.
40 */
41
42__u8 *zft_deblock_buf;
43__u8 *zft_hseg_buf;
44int zft_deblock_segment = -1;
45zft_status_enum zft_io_state = zft_idle;
46int zft_header_changed;
47int zft_qic113; /* conform to old specs. and old zftape */
48int zft_use_compression;
49zft_position zft_pos = {
50 -1, /* seg_pos */
51 0, /* seg_byte_pos */
52 0, /* tape_pos */
53 0 /* volume_pos */
54};
55unsigned int zft_blk_sz = CONFIG_ZFT_DFLT_BLK_SZ;
56__s64 zft_capacity;
57
58unsigned int zft_written_segments;
59int zft_label_changed;
60
61/* Local vars.
62 */
63
64unsigned int zft_get_seg_sz(unsigned int segment)
65{
66 int size;
67 TRACE_FUN(ft_t_any);
68
69 size = FT_SEGMENT_SIZE -
70 count_ones(ftape_get_bad_sector_entry(segment))*FT_SECTOR_SIZE;
71 if (size > 0) {
72 TRACE_EXIT (unsigned)size;
73 } else {
74 TRACE_EXIT 0;
75 }
76}
77
78/* ftape_set_flags(). Claus-Justus Heine, 1994/1995
79 */
80void zft_set_flags(unsigned minor_unit)
81{
82 TRACE_FUN(ft_t_flow);
83
84 zft_use_compression = zft_qic_mode = 0;
85 switch (minor_unit & ZFT_MINOR_OP_MASK) {
86 case (ZFT_Q80_MODE | ZFT_ZIP_MODE):
87 case ZFT_ZIP_MODE:
88 zft_use_compression = 1;
89 case 0:
90 case ZFT_Q80_MODE:
91 zft_qic_mode = 1;
92 if (zft_mt_compression) { /* override the default */
93 zft_use_compression = 1;
94 }
95 break;
96 case ZFT_RAW_MODE:
97 TRACE(ft_t_noise, "switching to raw mode");
98 break;
99 default:
100 TRACE(ft_t_warn, "Warning:\n"
101 KERN_INFO "Wrong combination of minor device bits.\n"
102 KERN_INFO "Switching to raw read-only mode.");
103 zft_write_protected = 1;
104 break;
105 }
106 TRACE_EXIT;
107}
108
109/* computes the segment and byte offset inside the segment
110 * corresponding to tape_pos.
111 *
112 * tape_pos gives the offset in bytes from the beginning of the
113 * ft_first_data_segment *seg_byte_pos is the offset in the current
114 * segment in bytes
115 *
116 * Of, if this routine was called often one should cache the last data
117 * pos it was called with, but actually this is only needed in
118 * ftape_seek_block(), that is, almost never.
119 */
120int zft_calc_seg_byte_coord(int *seg_byte_pos, __s64 tape_pos)
121{
122 int segment;
123 int seg_sz;
124 TRACE_FUN(ft_t_flow);
125
126 if (tape_pos == 0) {
127 *seg_byte_pos = 0;
128 segment = ft_first_data_segment;
129 } else {
130 seg_sz = 0;
131
132 for (segment = ft_first_data_segment;
133 ((tape_pos > 0) && (segment <= ft_last_data_segment));
134 segment++) {
135 seg_sz = zft_get_seg_sz(segment);
136 tape_pos -= seg_sz;
137 }
138 if(tape_pos >= 0) {
139 /* the case tape_pos > != 0 means that the
140 * argument tape_pos lies beyond the EOT.
141 */
142 *seg_byte_pos= 0;
143 } else { /* tape_pos < 0 */
144 segment--;
145 *seg_byte_pos= tape_pos + seg_sz;
146 }
147 }
148 TRACE_EXIT(segment);
149}
150
151/* ftape_calc_tape_pos().
152 *
153 * computes the offset in bytes from the beginning of the
154 * ft_first_data_segment inverse to ftape_calc_seg_byte_coord
155 *
156 * We should do some caching. But how:
157 *
158 * Each time the header segments are read in, this routine is called
159 * with ft_tracks_per_tape*segments_per_track argumnet. So this should be
160 * the time to reset the cache.
161 *
162 * Also, it might be in the future that the bad sector map gets
163 * changed. -> reset the cache
164 */
165static int seg_pos;
166static __s64 tape_pos;
167
168__s64 zft_get_capacity(void)
169{
170 seg_pos = ft_first_data_segment;
171 tape_pos = 0;
172
173 while (seg_pos <= ft_last_data_segment) {
174 tape_pos += zft_get_seg_sz(seg_pos ++);
175 }
176 return tape_pos;
177}
178
179__s64 zft_calc_tape_pos(int segment)
180{
181 int d1, d2, d3;
182 TRACE_FUN(ft_t_any);
183
184 if (segment > ft_last_data_segment) {
185 TRACE_EXIT zft_capacity;
186 }
187 if (segment < ft_first_data_segment) {
188 TRACE_EXIT 0;
189 }
190 d2 = segment - seg_pos;
191 if (-d2 > 10) {
192 d1 = segment - ft_first_data_segment;
193 if (-d2 > d1) {
194 tape_pos = 0;
195 seg_pos = ft_first_data_segment;
196 d2 = d1;
197 }
198 }
199 if (d2 > 10) {
200 d3 = ft_last_data_segment - segment;
201 if (d2 > d3) {
202 tape_pos = zft_capacity;
203 seg_pos = ft_last_data_segment + 1;
204 d2 = -d3;
205 }
206 }
207 if (d2 > 0) {
208 while (seg_pos < segment) {
209 tape_pos += zft_get_seg_sz(seg_pos++);
210 }
211 } else {
212 while (seg_pos > segment) {
213 tape_pos -= zft_get_seg_sz(--seg_pos);
214 }
215 }
216 TRACE(ft_t_noise, "new cached pos: %d", seg_pos);
217
218 TRACE_EXIT tape_pos;
219}
220
221/* copy Z-label string to buffer, keeps track of the correct offset in
222 * `buffer'
223 */
224void zft_update_label(__u8 *buffer)
225{
226 TRACE_FUN(ft_t_flow);
227
228 if (strncmp(&buffer[FT_LABEL], ZFTAPE_LABEL,
229 sizeof(ZFTAPE_LABEL)-1) != 0) {
230 TRACE(ft_t_info, "updating label from \"%s\" to \"%s\"",
231 &buffer[FT_LABEL], ZFTAPE_LABEL);
232 strcpy(&buffer[FT_LABEL], ZFTAPE_LABEL);
233 memset(&buffer[FT_LABEL] + sizeof(ZFTAPE_LABEL) - 1, ' ',
234 FT_LABEL_SZ - sizeof(ZFTAPE_LABEL + 1));
235 PUT4(buffer, FT_LABEL_DATE, 0);
236 zft_label_changed = zft_header_changed = 1; /* changed */
237 }
238 TRACE_EXIT;
239}
240
241int zft_verify_write_segments(unsigned int segment,
242 __u8 *data, size_t size,
243 __u8 *buffer)
244{
245 int result;
246 __u8 *write_buf;
247 __u8 *src_buf;
248 int single;
249 int seg_pos;
250 int seg_sz;
251 int remaining;
252 ft_write_mode_t write_mode;
253 TRACE_FUN(ft_t_flow);
254
255 seg_pos = segment;
256 seg_sz = zft_get_seg_sz(seg_pos);
257 src_buf = data;
258 single = size <= seg_sz;
259 remaining = size;
260 do {
261 TRACE(ft_t_noise, "\n"
262 KERN_INFO "remaining: %d\n"
263 KERN_INFO "seg_sz : %d\n"
264 KERN_INFO "segment : %d",
265 remaining, seg_sz, seg_pos);
266 if (remaining == seg_sz) {
267 write_buf = src_buf;
268 write_mode = single ? FT_WR_SINGLE : FT_WR_MULTI;
269 remaining = 0;
270 } else if (remaining > seg_sz) {
271 write_buf = src_buf;
272 write_mode = FT_WR_ASYNC; /* don't start tape */
273 remaining -= seg_sz;
274 } else { /* remaining < seg_sz */
275 write_buf = buffer;
276 memcpy(write_buf, src_buf, remaining);
277 memset(&write_buf[remaining],'\0',seg_sz-remaining);
278 write_mode = single ? FT_WR_SINGLE : FT_WR_MULTI;
279 remaining = 0;
280 }
281 if ((result = ftape_write_segment(seg_pos,
282 write_buf,
283 write_mode)) != seg_sz) {
284 TRACE(ft_t_err, "Error: "
285 "Couldn't write segment %d", seg_pos);
286 TRACE_EXIT result < 0 ? result : -EIO; /* bail out */
287 }
288 zft_written_segments ++;
289 seg_sz = zft_get_seg_sz(++seg_pos);
290 src_buf += result;
291 } while (remaining > 0);
292 if (ftape_get_status()->fti_state == writing) {
293 TRACE_CATCH(ftape_loop_until_writes_done(),);
294 TRACE_CATCH(ftape_abort_operation(),);
295 zft_prevent_flush();
296 }
297 seg_pos = segment;
298 src_buf = data;
299 remaining = size;
300 do {
301 TRACE_CATCH(result = ftape_read_segment(seg_pos, buffer,
302 single ? FT_RD_SINGLE
303 : FT_RD_AHEAD),);
304 if (memcmp(src_buf, buffer,
305 remaining > result ? result : remaining) != 0) {
306 TRACE_ABORT(-EIO, ft_t_err,
307 "Failed to verify written segment %d",
308 seg_pos);
309 }
310 remaining -= result;
311 TRACE(ft_t_noise, "verify successful:\n"
312 KERN_INFO "segment : %d\n"
313 KERN_INFO "segsize : %d\n"
314 KERN_INFO "remaining: %d",
315 seg_pos, result, remaining);
316 src_buf += seg_sz;
317 seg_pos++;
318 } while (remaining > 0);
319 TRACE_EXIT size;
320}
321
322
323/* zft_erase(). implemented compression-handling
324 *
325 * calculate the first data-segment when using/not using compression.
326 *
327 * update header-segment and compression-map-segment.
328 */
329int zft_erase(void)
330{
331 int result = 0;
332 TRACE_FUN(ft_t_flow);
333
334 if (!zft_header_read) {
335 TRACE_CATCH(zft_vmalloc_once((void **)&zft_hseg_buf,
336 FT_SEGMENT_SIZE),);
337 /* no need to read the vtbl and compression map */
338 TRACE_CATCH(ftape_read_header_segment(zft_hseg_buf),);
339 if ((zft_old_ftape =
340 zft_ftape_validate_label(&zft_hseg_buf[FT_LABEL]))) {
341 zft_ftape_extract_file_marks(zft_hseg_buf);
342 }
343 TRACE(ft_t_noise,
344 "ft_first_data_segment: %d, ft_last_data_segment: %d",
345 ft_first_data_segment, ft_last_data_segment);
346 zft_qic113 = (ft_format_code != fmt_normal &&
347 ft_format_code != fmt_1100ft &&
348 ft_format_code != fmt_425ft);
349 }
350 if (zft_old_ftape) {
351 zft_clear_ftape_file_marks();
352 zft_old_ftape = 0; /* no longer old ftape */
353 }
354 PUT2(zft_hseg_buf, FT_CMAP_START, 0);
355 zft_volume_table_changed = 1;
356 zft_capacity = zft_get_capacity();
357 zft_init_vtbl();
358 /* the rest must be done in ftape_update_header_segments
359 */
360 zft_header_read = 1;
361 zft_header_changed = 1; /* force update of timestamp */
362 result = zft_update_header_segments();
363
364 ftape_abort_operation();
365
366 zft_reset_position(&zft_pos);
367 zft_set_flags (zft_unit);
368 TRACE_EXIT result;
369}
370
371unsigned int zft_get_time(void)
372{
373 unsigned int date = FT_TIME_STAMP(2097, 11, 30, 23, 59, 59); /* fun */
374 return date;
375}
diff --git a/drivers/char/ftape/zftape/zftape-rw.h b/drivers/char/ftape/zftape/zftape-rw.h
deleted file mode 100644
index 1ceec22b60bd..000000000000
--- a/drivers/char/ftape/zftape/zftape-rw.h
+++ /dev/null
@@ -1,101 +0,0 @@
1#ifndef _ZFTAPE_RW_H
2#define _ZFTAPE_RW_H
3
4/*
5 * Copyright (C) 1996, 1997 Claus-Justus Heine.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 *
22 * $Source: /homes/cvs/ftape-stacked/ftape/zftape/zftape-rw.h,v $
23 * $Revision: 1.2 $
24 * $Date: 1997/10/05 19:19:09 $
25 *
26 * This file contains the definitions for the read and write
27 * functions for the QIC-117 floppy-tape driver for Linux.
28 *
29 */
30
31#include "../zftape/zftape-buffers.h"
32
33#define SEGMENTS_PER_TAPE (ft_segments_per_track * ft_tracks_per_tape)
34
35/* QIC-113 Rev. G says that `a maximum of 63488 raw bytes may be
36 * compressed into a single frame'.
37 * Maybe we should stick to 32kb to make it more `beautiful'
38 */
39#define ZFT_MAX_BLK_SZ (62*1024) /* bytes */
40#if !defined(CONFIG_ZFT_DFLT_BLK_SZ)
41# define CONFIG_ZFT_DFLT_BLK_SZ (10*1024) /* bytes, default of gnu tar */
42#elif CONFIG_ZFT_DFLT_BLK_SZ == 0
43# undef CONFIG_ZFT_DFLT_BLK_SZ
44# define CONFIG_ZFT_DFLT_BLK_SZ 1
45#elif (CONFIG_ZFT_DFLT_BLK_SZ % 1024) != 0
46# error CONFIG_ZFT_DFLT_BLK_SZ must be 1 or a multiple of 1024
47#endif
48/* The *optional* compression routines need some overhead per tape
49 * block for their purposes. Instead of asking the actual compression
50 * implementation how much it needs, we restrict this overhead to be
51 * maximal of ZFT_CMPT_OVERHEAD size. We need this for EOT
52 * conditions. The tape is assumed to be logical at EOT when the
53 * distance from the physical EOT is less than
54 * one tape block + ZFT_CMPR_OVERHEAD
55 */
56#define ZFT_CMPR_OVERHEAD 16 /* bytes */
57
58typedef enum
59{
60 zft_idle = 0,
61 zft_reading,
62 zft_writing,
63} zft_status_enum;
64
65typedef struct /* all values measured in bytes */
66{
67 int seg_pos; /* segment currently positioned at */
68 int seg_byte_pos; /* offset in current segment */
69 __s64 tape_pos; /* real offset from BOT */
70 __s64 volume_pos; /* pos. in uncompressed data stream in
71 * current volume
72 */
73} zft_position;
74
75extern zft_position zft_pos;
76extern __u8 *zft_deblock_buf;
77extern __u8 *zft_hseg_buf;
78extern int zft_deblock_segment;
79extern zft_status_enum zft_io_state;
80extern int zft_header_changed;
81extern int zft_qic113; /* conform to old specs. and old zftape */
82extern int zft_use_compression;
83extern unsigned int zft_blk_sz;
84extern __s64 zft_capacity;
85extern unsigned int zft_written_segments;
86extern int zft_label_changed;
87
88/* zftape-rw.c exported functions
89 */
90extern unsigned int zft_get_seg_sz(unsigned int segment);
91extern void zft_set_flags(unsigned int minor_unit);
92extern int zft_calc_seg_byte_coord(int *seg_byte_pos, __s64 tape_pos);
93extern __s64 zft_calc_tape_pos(int segment);
94extern __s64 zft_get_capacity(void);
95extern void zft_update_label(__u8 *buffer);
96extern int zft_erase(void);
97extern int zft_verify_write_segments(unsigned int segment,
98 __u8 *data, size_t size, __u8 *buffer);
99extern unsigned int zft_get_time(void);
100#endif /* _ZFTAPE_RW_H */
101
diff --git a/drivers/char/ftape/zftape/zftape-vtbl.c b/drivers/char/ftape/zftape/zftape-vtbl.c
deleted file mode 100644
index ad7f8be6340b..000000000000
--- a/drivers/char/ftape/zftape/zftape-vtbl.c
+++ /dev/null
@@ -1,757 +0,0 @@
1/*
2 * Copyright (c) 1995-1997 Claus-Justus Heine
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License as
6 published by the Free Software Foundation; either version 2, or (at
7 your option) any later version.
8
9 This program is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
17 USA.
18
19 *
20 * $Source: /homes/cvs/ftape-stacked/ftape/zftape/zftape-vtbl.c,v $
21 * $Revision: 1.7.6.1 $
22 * $Date: 1997/11/24 13:48:31 $
23 *
24 * This file defines a volume table as defined in various QIC
25 * standards.
26 *
27 * This is a minimal implementation, just allowing ordinary DOS
28 * :( prgrams to identify the cartridge as used.
29 */
30
31#include <linux/errno.h>
32#include <linux/mm.h>
33#include <linux/slab.h>
34
35#include <linux/zftape.h>
36#include "../zftape/zftape-init.h"
37#include "../zftape/zftape-eof.h"
38#include "../zftape/zftape-ctl.h"
39#include "../zftape/zftape-write.h"
40#include "../zftape/zftape-read.h"
41#include "../zftape/zftape-rw.h"
42#include "../zftape/zftape-vtbl.h"
43
44#define ZFT_CMAP_HACK /* leave this defined to hide the compression map */
45
46/*
47 * global variables
48 */
49int zft_qic_mode = 1; /* use the vtbl */
50int zft_old_ftape; /* prevents old ftaped tapes to be overwritten */
51int zft_volume_table_changed; /* for write_header_segments() */
52
53/*
54 * private variables (only exported for inline functions)
55 */
56LIST_HEAD(zft_vtbl);
57
58/* We could also allocate these dynamically when extracting the volume table
59 * sizeof(zft_volinfo) is about 32 or something close to that
60 */
61static zft_volinfo tape_vtbl;
62static zft_volinfo eot_vtbl;
63static zft_volinfo *cur_vtbl;
64
65static inline void zft_new_vtbl_entry(void)
66{
67 struct list_head *tmp = &zft_last_vtbl->node;
68 zft_volinfo *new = zft_kmalloc(sizeof(zft_volinfo));
69
70 list_add(&new->node, tmp);
71 new->count = zft_eom_vtbl->count ++;
72}
73
74void zft_free_vtbl(void)
75{
76 for (;;) {
77 struct list_head *tmp = zft_vtbl.prev;
78 zft_volinfo *vtbl;
79
80 if (tmp == &zft_vtbl)
81 break;
82 list_del(tmp);
83 vtbl = list_entry(tmp, zft_volinfo, node);
84 zft_kfree(vtbl, sizeof(zft_volinfo));
85 }
86 INIT_LIST_HEAD(&zft_vtbl);
87 cur_vtbl = NULL;
88}
89
90/* initialize vtbl, called by ftape_new_cartridge()
91 */
92void zft_init_vtbl(void)
93{
94 zft_volinfo *new;
95
96 zft_free_vtbl();
97
98 /* Create the two dummy vtbl entries
99 */
100 new = zft_kmalloc(sizeof(zft_volinfo));
101 list_add(&new->node, &zft_vtbl);
102 new = zft_kmalloc(sizeof(zft_volinfo));
103 list_add(&new->node, &zft_vtbl);
104 zft_head_vtbl->end_seg = ft_first_data_segment;
105 zft_head_vtbl->blk_sz = zft_blk_sz;
106 zft_head_vtbl->count = -1;
107 zft_eom_vtbl->start_seg = ft_first_data_segment + 1;
108 zft_eom_vtbl->end_seg = ft_last_data_segment + 1;
109 zft_eom_vtbl->blk_sz = zft_blk_sz;
110 zft_eom_vtbl->count = 0;
111
112 /* Reset the pointer for zft_find_volume()
113 */
114 cur_vtbl = zft_eom_vtbl;
115
116 /* initialize the dummy vtbl entries for zft_qic_mode == 0
117 */
118 eot_vtbl.start_seg = ft_last_data_segment + 1;
119 eot_vtbl.end_seg = ft_last_data_segment + 1;
120 eot_vtbl.blk_sz = zft_blk_sz;
121 eot_vtbl.count = -1;
122 tape_vtbl.start_seg = ft_first_data_segment;
123 tape_vtbl.end_seg = ft_last_data_segment;
124 tape_vtbl.blk_sz = zft_blk_sz;
125 tape_vtbl.size = zft_capacity;
126 tape_vtbl.count = 0;
127}
128
129/* check for a valid VTBL signature.
130 */
131static int vtbl_signature_valid(__u8 signature[4])
132{
133 const char *vtbl_ids[] = VTBL_IDS; /* valid signatures */
134 int j;
135
136 for (j = 0;
137 (j < NR_ITEMS(vtbl_ids)) && (memcmp(signature, vtbl_ids[j], 4) != 0);
138 j++);
139 return j < NR_ITEMS(vtbl_ids);
140}
141
142/* We used to store the block-size of the volume in the volume-label,
143 * using the keyword "blocksize". The blocksize written to the
144 * volume-label is in bytes.
145 *
146 * We use this now only for compatibility with old zftape version. We
147 * store the blocksize directly as binary number in the vendor
148 * extension part of the volume entry.
149 */
150static int check_volume_label(const char *label, int *blk_sz)
151{
152 int valid_format;
153 char *blocksize;
154 TRACE_FUN(ft_t_flow);
155
156 TRACE(ft_t_noise, "called with \"%s\" / \"%s\"", label, ZFT_VOL_NAME);
157 if (strncmp(label, ZFT_VOL_NAME, strlen(ZFT_VOL_NAME)) != 0) {
158 *blk_sz = 1; /* smallest block size that we allow */
159 valid_format = 0;
160 } else {
161 TRACE(ft_t_noise, "got old style zftape vtbl entry");
162 /* get the default blocksize */
163 /* use the kernel strstr() */
164 blocksize= strstr(label, " blocksize ");
165 if (blocksize) {
166 blocksize += strlen(" blocksize ");
167 for(*blk_sz= 0;
168 *blocksize >= '0' && *blocksize <= '9';
169 blocksize++) {
170 *blk_sz *= 10;
171 *blk_sz += *blocksize - '0';
172 }
173 if (*blk_sz > ZFT_MAX_BLK_SZ) {
174 *blk_sz= 1;
175 valid_format= 0;
176 } else {
177 valid_format = 1;
178 }
179 } else {
180 *blk_sz= 1;
181 valid_format= 0;
182 }
183 }
184 TRACE_EXIT valid_format;
185}
186
187/* check for a zftape volume
188 */
189static int check_volume(__u8 *entry, zft_volinfo *volume)
190{
191 TRACE_FUN(ft_t_flow);
192
193 if(strncmp(&entry[VTBL_EXT+EXT_ZFTAPE_SIG], ZFTAPE_SIG,
194 strlen(ZFTAPE_SIG)) == 0) {
195 TRACE(ft_t_noise, "got new style zftape vtbl entry");
196 volume->blk_sz = GET2(entry, VTBL_EXT+EXT_ZFTAPE_BLKSZ);
197 volume->qic113 = entry[VTBL_EXT+EXT_ZFTAPE_QIC113];
198 TRACE_EXIT 1;
199 } else {
200 TRACE_EXIT check_volume_label(&entry[VTBL_DESC], &volume->blk_sz);
201 }
202}
203
204
205/* create zftape specific vtbl entry, the volume bounds are inserted
206 * in the calling function, zft_create_volume_headers()
207 */
208static void create_zft_volume(__u8 *entry, zft_volinfo *vtbl)
209{
210 TRACE_FUN(ft_t_flow);
211
212 memset(entry, 0, VTBL_SIZE);
213 memcpy(&entry[VTBL_SIG], VTBL_ID, 4);
214 sprintf(&entry[VTBL_DESC], ZFT_VOL_NAME" %03d", vtbl->count);
215 entry[VTBL_FLAGS] = (VTBL_FL_NOT_VERIFIED | VTBL_FL_SEG_SPANNING);
216 entry[VTBL_M_NO] = 1; /* multi_cartridge_count */
217 strcpy(&entry[VTBL_EXT+EXT_ZFTAPE_SIG], ZFTAPE_SIG);
218 PUT2(entry, VTBL_EXT+EXT_ZFTAPE_BLKSZ, vtbl->blk_sz);
219 if (zft_qic113) {
220 PUT8(entry, VTBL_DATA_SIZE, vtbl->size);
221 entry[VTBL_CMPR] = VTBL_CMPR_UNREG;
222 if (vtbl->use_compression) { /* use compression: */
223 entry[VTBL_CMPR] |= VTBL_CMPR_USED;
224 }
225 entry[VTBL_EXT+EXT_ZFTAPE_QIC113] = 1;
226 } else {
227 PUT4(entry, VTBL_DATA_SIZE, vtbl->size);
228 entry[VTBL_K_CMPR] = VTBL_CMPR_UNREG;
229 if (vtbl->use_compression) { /* use compression: */
230 entry[VTBL_K_CMPR] |= VTBL_CMPR_USED;
231 }
232 }
233 if (ft_format_code == fmt_big) {
234 /* SCSI like vtbl, store the number of used
235 * segments as 4 byte value
236 */
237 PUT4(entry, VTBL_SCSI_SEGS, vtbl->end_seg-vtbl->start_seg + 1);
238 } else {
239 /* normal, QIC-80MC like vtbl
240 */
241 PUT2(entry, VTBL_START, vtbl->start_seg);
242 PUT2(entry, VTBL_END, vtbl->end_seg);
243 }
244 TRACE_EXIT;
245}
246
247/* this one creates the volume headers for each volume. It is assumed
248 * that buffer already contains the old volume-table, so that vtbl
249 * entries without the zft_volume flag set can savely be ignored.
250 */
251static void zft_create_volume_headers(__u8 *buffer)
252{
253 __u8 *entry;
254 struct list_head *tmp;
255 zft_volinfo *vtbl;
256 TRACE_FUN(ft_t_flow);
257
258#ifdef ZFT_CMAP_HACK
259 if((strncmp(&buffer[VTBL_EXT+EXT_ZFTAPE_SIG], ZFTAPE_SIG,
260 strlen(ZFTAPE_SIG)) == 0) &&
261 buffer[VTBL_EXT+EXT_ZFTAPE_CMAP] != 0) {
262 TRACE(ft_t_noise, "deleting cmap volume");
263 memmove(buffer, buffer + VTBL_SIZE,
264 FT_SEGMENT_SIZE - VTBL_SIZE);
265 }
266#endif
267 entry = buffer;
268 for (tmp = zft_head_vtbl->node.next;
269 tmp != &zft_eom_vtbl->node;
270 tmp = tmp->next) {
271 vtbl = list_entry(tmp, zft_volinfo, node);
272 /* we now fill in the values only for newly created volumes.
273 */
274 if (vtbl->new_volume) {
275 create_zft_volume(entry, vtbl);
276 vtbl->new_volume = 0; /* clear the flag */
277 }
278
279 DUMP_VOLINFO(ft_t_noise, &entry[VTBL_DESC], vtbl);
280 entry += VTBL_SIZE;
281 }
282 memset(entry, 0, FT_SEGMENT_SIZE - zft_eom_vtbl->count * VTBL_SIZE);
283 TRACE_EXIT;
284}
285
286/* write volume table to tape. Calls zft_create_volume_headers()
287 */
288int zft_update_volume_table(unsigned int segment)
289{
290 int result = 0;
291 __u8 *verify_buf = NULL;
292 TRACE_FUN(ft_t_flow);
293
294 TRACE_CATCH(result = ftape_read_segment(ft_first_data_segment,
295 zft_deblock_buf,
296 FT_RD_SINGLE),);
297 zft_create_volume_headers(zft_deblock_buf);
298 TRACE(ft_t_noise, "writing volume table segment %d", segment);
299 if (zft_vmalloc_once(&verify_buf, FT_SEGMENT_SIZE) == 0) {
300 TRACE_CATCH(zft_verify_write_segments(segment,
301 zft_deblock_buf, result,
302 verify_buf),
303 zft_vfree(&verify_buf, FT_SEGMENT_SIZE));
304 zft_vfree(&verify_buf, FT_SEGMENT_SIZE);
305 } else {
306 TRACE_CATCH(ftape_write_segment(segment, zft_deblock_buf,
307 FT_WR_SINGLE),);
308 }
309 TRACE_EXIT 0;
310}
311
312/* non zftape volumes are handled in raw mode. Thus we need to
313 * calculate the raw amount of data contained in those segments.
314 */
315static void extract_alien_volume(__u8 *entry, zft_volinfo *vtbl)
316{
317 TRACE_FUN(ft_t_flow);
318
319 vtbl->size = (zft_calc_tape_pos(zft_last_vtbl->end_seg+1) -
320 zft_calc_tape_pos(zft_last_vtbl->start_seg));
321 vtbl->use_compression = 0;
322 vtbl->qic113 = zft_qic113;
323 if (vtbl->qic113) {
324 TRACE(ft_t_noise,
325 "Fake alien volume's size from " LL_X " to " LL_X,
326 LL(GET8(entry, VTBL_DATA_SIZE)), LL(vtbl->size));
327 } else {
328 TRACE(ft_t_noise,
329 "Fake alien volume's size from %d to " LL_X,
330 (int)GET4(entry, VTBL_DATA_SIZE), LL(vtbl->size));
331 }
332 TRACE_EXIT;
333}
334
335
336/* extract an zftape specific volume
337 */
338static void extract_zft_volume(__u8 *entry, zft_volinfo *vtbl)
339{
340 TRACE_FUN(ft_t_flow);
341
342 if (vtbl->qic113) {
343 vtbl->size = GET8(entry, VTBL_DATA_SIZE);
344 vtbl->use_compression =
345 (entry[VTBL_CMPR] & VTBL_CMPR_USED) != 0;
346 } else {
347 vtbl->size = GET4(entry, VTBL_DATA_SIZE);
348 if (entry[VTBL_K_CMPR] & VTBL_CMPR_UNREG) {
349 vtbl->use_compression =
350 (entry[VTBL_K_CMPR] & VTBL_CMPR_USED) != 0;
351 } else if (entry[VTBL_CMPR] & VTBL_CMPR_UNREG) {
352 vtbl->use_compression =
353 (entry[VTBL_CMPR] & VTBL_CMPR_USED) != 0;
354 } else {
355 TRACE(ft_t_warn, "Geeh! There is something wrong:\n"
356 KERN_INFO "QIC compression (Rev = K): %x\n"
357 KERN_INFO "QIC compression (Rev > K): %x",
358 entry[VTBL_K_CMPR], entry[VTBL_CMPR]);
359 }
360 }
361 TRACE_EXIT;
362}
363
364/* extract the volume table from buffer. "buffer" must already contain
365 * the vtbl-segment
366 */
367int zft_extract_volume_headers(__u8 *buffer)
368{
369 __u8 *entry;
370 TRACE_FUN(ft_t_flow);
371
372 zft_init_vtbl();
373 entry = buffer;
374#ifdef ZFT_CMAP_HACK
375 if ((strncmp(&entry[VTBL_EXT+EXT_ZFTAPE_SIG], ZFTAPE_SIG,
376 strlen(ZFTAPE_SIG)) == 0) &&
377 entry[VTBL_EXT+EXT_ZFTAPE_CMAP] != 0) {
378 TRACE(ft_t_noise, "ignoring cmap volume");
379 entry += VTBL_SIZE;
380 }
381#endif
382 /* the end of the vtbl is indicated by an invalid signature
383 */
384 while (vtbl_signature_valid(&entry[VTBL_SIG]) &&
385 (entry - buffer) < FT_SEGMENT_SIZE) {
386 zft_new_vtbl_entry();
387 if (ft_format_code == fmt_big) {
388 /* SCSI like vtbl, stores only the number of
389 * segments used
390 */
391 unsigned int num_segments= GET4(entry, VTBL_SCSI_SEGS);
392 zft_last_vtbl->start_seg = zft_eom_vtbl->start_seg;
393 zft_last_vtbl->end_seg =
394 zft_last_vtbl->start_seg + num_segments - 1;
395 } else {
396 /* `normal', QIC-80 like vtbl
397 */
398 zft_last_vtbl->start_seg = GET2(entry, VTBL_START);
399 zft_last_vtbl->end_seg = GET2(entry, VTBL_END);
400 }
401 zft_eom_vtbl->start_seg = zft_last_vtbl->end_seg + 1;
402 /* check if we created this volume and get the
403 * blk_sz
404 */
405 zft_last_vtbl->zft_volume = check_volume(entry, zft_last_vtbl);
406 if (zft_last_vtbl->zft_volume == 0) {
407 extract_alien_volume(entry, zft_last_vtbl);
408 } else {
409 extract_zft_volume(entry, zft_last_vtbl);
410 }
411 DUMP_VOLINFO(ft_t_noise, &entry[VTBL_DESC], zft_last_vtbl);
412 entry +=VTBL_SIZE;
413 }
414#if 0
415/*
416 * undefine to test end of tape handling
417 */
418 zft_new_vtbl_entry();
419 zft_last_vtbl->start_seg = zft_eom_vtbl->start_seg;
420 zft_last_vtbl->end_seg = ft_last_data_segment - 10;
421 zft_last_vtbl->blk_sz = zft_blk_sz;
422 zft_last_vtbl->zft_volume = 1;
423 zft_last_vtbl->qic113 = zft_qic113;
424 zft_last_vtbl->size = (zft_calc_tape_pos(zft_last_vtbl->end_seg+1)
425 - zft_calc_tape_pos(zft_last_vtbl->start_seg));
426#endif
427 TRACE_EXIT 0;
428}
429
430/* this functions translates the failed_sector_log, misused as
431 * EOF-marker list, into a virtual volume table. The table mustn't be
432 * written to tape, because this would occupy the first data segment,
433 * which should be the volume table, but is actually the first segment
434 * that is filled with data (when using standard ftape). We assume,
435 * that we get a non-empty failed_sector_log.
436 */
437int zft_fake_volume_headers (eof_mark_union *eof_map, int num_failed_sectors)
438{
439 unsigned int segment, sector;
440 int have_eom = 0;
441 int vol_no;
442 TRACE_FUN(ft_t_flow);
443
444 if ((num_failed_sectors >= 2) &&
445 (GET2(&eof_map[num_failed_sectors - 1].mark.segment, 0)
446 ==
447 GET2(&eof_map[num_failed_sectors - 2].mark.segment, 0) + 1) &&
448 (GET2(&eof_map[num_failed_sectors - 1].mark.date, 0) == 1)) {
449 /* this should be eom. We keep the remainder of the
450 * tape as another volume.
451 */
452 have_eom = 1;
453 }
454 zft_init_vtbl();
455 zft_eom_vtbl->start_seg = ft_first_data_segment;
456 for(vol_no = 0; vol_no < num_failed_sectors - have_eom; vol_no ++) {
457 zft_new_vtbl_entry();
458
459 segment = GET2(&eof_map[vol_no].mark.segment, 0);
460 sector = GET2(&eof_map[vol_no].mark.date, 0);
461
462 zft_last_vtbl->start_seg = zft_eom_vtbl->start_seg;
463 zft_last_vtbl->end_seg = segment;
464 zft_eom_vtbl->start_seg = segment + 1;
465 zft_last_vtbl->blk_sz = 1;
466 zft_last_vtbl->size =
467 (zft_calc_tape_pos(zft_last_vtbl->end_seg)
468 - zft_calc_tape_pos(zft_last_vtbl->start_seg)
469 + (sector-1) * FT_SECTOR_SIZE);
470 TRACE(ft_t_noise,
471 "failed sector log: segment: %d, sector: %d",
472 segment, sector);
473 DUMP_VOLINFO(ft_t_noise, "Faked volume", zft_last_vtbl);
474 }
475 if (!have_eom) {
476 zft_new_vtbl_entry();
477 zft_last_vtbl->start_seg = zft_eom_vtbl->start_seg;
478 zft_last_vtbl->end_seg = ft_last_data_segment;
479 zft_eom_vtbl->start_seg = ft_last_data_segment + 1;
480 zft_last_vtbl->size = zft_capacity;
481 zft_last_vtbl->size -= zft_calc_tape_pos(zft_last_vtbl->start_seg);
482 zft_last_vtbl->blk_sz = 1;
483 DUMP_VOLINFO(ft_t_noise, "Faked volume",zft_last_vtbl);
484 }
485 TRACE_EXIT 0;
486}
487
488/* update the internal volume table
489 *
490 * if before start of last volume: erase all following volumes if
491 * inside a volume: set end of volume to infinity
492 *
493 * this function is intended to be called every time _ftape_write() is
494 * called
495 *
496 * return: 0 if no new volume was created, 1 if a new volume was
497 * created
498 *
499 * NOTE: we don't need to check for zft_mode as ftape_write() does
500 * that already. This function gets never called without accessing
501 * zftape via the *qft* devices
502 */
503
504int zft_open_volume(zft_position *pos, int blk_sz, int use_compression)
505{
506 TRACE_FUN(ft_t_flow);
507
508 if (!zft_qic_mode) {
509 TRACE_EXIT 0;
510 }
511 if (zft_tape_at_lbot(pos)) {
512 zft_init_vtbl();
513 if(zft_old_ftape) {
514 /* clear old ftape's eof marks */
515 zft_clear_ftape_file_marks();
516 zft_old_ftape = 0; /* no longer old ftape */
517 }
518 zft_reset_position(pos);
519 }
520 if (pos->seg_pos != zft_last_vtbl->end_seg + 1) {
521 TRACE_ABORT(-EIO, ft_t_bug,
522 "BUG: seg_pos: %d, zft_last_vtbl->end_seg: %d",
523 pos->seg_pos, zft_last_vtbl->end_seg);
524 }
525 TRACE(ft_t_noise, "create new volume");
526 if (zft_eom_vtbl->count >= ZFT_MAX_VOLUMES) {
527 TRACE_ABORT(-ENOSPC, ft_t_err,
528 "Error: maxmimal number of volumes exhausted "
529 "(maxmimum is %d)", ZFT_MAX_VOLUMES);
530 }
531 zft_new_vtbl_entry();
532 pos->volume_pos = pos->seg_byte_pos = 0;
533 zft_last_vtbl->start_seg = pos->seg_pos;
534 zft_last_vtbl->end_seg = ft_last_data_segment; /* infinity */
535 zft_last_vtbl->blk_sz = blk_sz;
536 zft_last_vtbl->size = zft_capacity;
537 zft_last_vtbl->zft_volume = 1;
538 zft_last_vtbl->use_compression = use_compression;
539 zft_last_vtbl->qic113 = zft_qic113;
540 zft_last_vtbl->new_volume = 1;
541 zft_last_vtbl->open = 1;
542 zft_volume_table_changed = 1;
543 zft_eom_vtbl->start_seg = ft_last_data_segment + 1;
544 TRACE_EXIT 0;
545}
546
547/* perform mtfsf, mtbsf, not allowed without zft_qic_mode
548 */
549int zft_skip_volumes(int count, zft_position *pos)
550{
551 const zft_volinfo *vtbl;
552 TRACE_FUN(ft_t_flow);
553
554 TRACE(ft_t_noise, "count: %d", count);
555
556 vtbl= zft_find_volume(pos->seg_pos);
557 while (count > 0 && vtbl != zft_eom_vtbl) {
558 vtbl = list_entry(vtbl->node.next, zft_volinfo, node);
559 count --;
560 }
561 while (count < 0 && vtbl != zft_first_vtbl) {
562 vtbl = list_entry(vtbl->node.prev, zft_volinfo, node);
563 count ++;
564 }
565 pos->seg_pos = vtbl->start_seg;
566 pos->seg_byte_pos = 0;
567 pos->volume_pos = 0;
568 pos->tape_pos = zft_calc_tape_pos(pos->seg_pos);
569 zft_just_before_eof = vtbl->size == 0;
570 if (zft_cmpr_ops) {
571 (*zft_cmpr_ops->reset)();
572 }
573 zft_deblock_segment = -1; /* no need to keep cache */
574 TRACE(ft_t_noise, "repositioning to:\n"
575 KERN_INFO "zft_seg_pos : %d\n"
576 KERN_INFO "zft_seg_byte_pos : %d\n"
577 KERN_INFO "zft_tape_pos : " LL_X "\n"
578 KERN_INFO "zft_volume_pos : " LL_X "\n"
579 KERN_INFO "file number : %d",
580 pos->seg_pos, pos->seg_byte_pos,
581 LL(pos->tape_pos), LL(pos->volume_pos), vtbl->count);
582 zft_resid = count < 0 ? -count : count;
583 TRACE_EXIT zft_resid ? -EINVAL : 0;
584}
585
586/* the following simply returns the raw data position of the EOM
587 * marker, MTIOCSIZE ioctl
588 */
589__s64 zft_get_eom_pos(void)
590{
591 if (zft_qic_mode) {
592 return zft_calc_tape_pos(zft_eom_vtbl->start_seg);
593 } else {
594 /* there is only one volume in raw mode */
595 return zft_capacity;
596 }
597}
598
599/* skip to eom, used for MTEOM
600 */
601void zft_skip_to_eom(zft_position *pos)
602{
603 TRACE_FUN(ft_t_flow);
604 pos->seg_pos = zft_eom_vtbl->start_seg;
605 pos->seg_byte_pos =
606 pos->volume_pos =
607 zft_just_before_eof = 0;
608 pos->tape_pos = zft_calc_tape_pos(pos->seg_pos);
609 TRACE(ft_t_noise, "ftape positioned to segment %d, data pos " LL_X,
610 pos->seg_pos, LL(pos->tape_pos));
611 TRACE_EXIT;
612}
613
614/* write an EOF-marker by setting zft_last_vtbl->end_seg to seg_pos.
615 * NOTE: this function assumes that zft_last_vtbl points to a valid
616 * vtbl entry
617 *
618 * NOTE: this routine always positions before the EOF marker
619 */
620int zft_close_volume(zft_position *pos)
621{
622 TRACE_FUN(ft_t_any);
623
624 if (zft_vtbl_empty || !zft_last_vtbl->open) { /* should not happen */
625 TRACE(ft_t_noise, "There are no volumes to finish");
626 TRACE_EXIT -EIO;
627 }
628 if (pos->seg_byte_pos == 0 &&
629 pos->seg_pos != zft_last_vtbl->start_seg) {
630 pos->seg_pos --;
631 pos->seg_byte_pos = zft_get_seg_sz(pos->seg_pos);
632 }
633 zft_last_vtbl->end_seg = pos->seg_pos;
634 zft_last_vtbl->size = pos->volume_pos;
635 zft_volume_table_changed = 1;
636 zft_just_before_eof = 1;
637 zft_eom_vtbl->start_seg = zft_last_vtbl->end_seg + 1;
638 zft_last_vtbl->open = 0; /* closed */
639 TRACE_EXIT 0;
640}
641
642/* write count file-marks at current position.
643 *
644 * The tape is positioned after the eof-marker, that is at byte 0 of
645 * the segment following the eof-marker
646 *
647 * this function is only allowed in zft_qic_mode
648 *
649 * Only allowed when tape is at BOT or EOD.
650 */
651int zft_weof(unsigned int count, zft_position *pos)
652{
653
654 TRACE_FUN(ft_t_flow);
655
656 if (!count) { /* write zero EOF marks should be a real no-op */
657 TRACE_EXIT 0;
658 }
659 zft_volume_table_changed = 1;
660 if (zft_tape_at_lbot(pos)) {
661 zft_init_vtbl();
662 if(zft_old_ftape) {
663 /* clear old ftape's eof marks */
664 zft_clear_ftape_file_marks();
665 zft_old_ftape = 0; /* no longer old ftape */
666 }
667 }
668 if (zft_last_vtbl->open) {
669 zft_close_volume(pos);
670 zft_move_past_eof(pos);
671 count --;
672 }
673 /* now it's easy, just append eof-marks, that is empty
674 * volumes, to the end of the already recorded media.
675 */
676 while (count > 0 &&
677 pos->seg_pos <= ft_last_data_segment &&
678 zft_eom_vtbl->count < ZFT_MAX_VOLUMES) {
679 TRACE(ft_t_noise,
680 "Writing zero sized file at segment %d", pos->seg_pos);
681 zft_new_vtbl_entry();
682 zft_last_vtbl->start_seg = pos->seg_pos;
683 zft_last_vtbl->end_seg = pos->seg_pos;
684 zft_last_vtbl->size = 0;
685 zft_last_vtbl->blk_sz = zft_blk_sz;
686 zft_last_vtbl->zft_volume = 1;
687 zft_last_vtbl->use_compression = 0;
688 pos->tape_pos += zft_get_seg_sz(pos->seg_pos);
689 zft_eom_vtbl->start_seg = ++ pos->seg_pos;
690 count --;
691 }
692 if (count > 0) {
693 /* there are two possibilities: end of tape, or the
694 * maximum number of files is exhausted.
695 */
696 zft_resid = count;
697 TRACE(ft_t_noise,"Number of marks NOT written: %d", zft_resid);
698 if (zft_eom_vtbl->count == ZFT_MAX_VOLUMES) {
699 TRACE_ABORT(-EINVAL, ft_t_warn,
700 "maximum allowed number of files "
701 "exhausted: %d", ZFT_MAX_VOLUMES);
702 } else {
703 TRACE_ABORT(-ENOSPC,
704 ft_t_noise, "reached end of tape");
705 }
706 }
707 TRACE_EXIT 0;
708}
709
710const zft_volinfo *zft_find_volume(unsigned int seg_pos)
711{
712 TRACE_FUN(ft_t_flow);
713
714 TRACE(ft_t_any, "called with seg_pos %d",seg_pos);
715 if (!zft_qic_mode) {
716 if (seg_pos > ft_last_data_segment) {
717 TRACE_EXIT &eot_vtbl;
718 }
719 tape_vtbl.blk_sz = zft_blk_sz;
720 TRACE_EXIT &tape_vtbl;
721 }
722 if (seg_pos < zft_first_vtbl->start_seg) {
723 TRACE_EXIT (cur_vtbl = zft_first_vtbl);
724 }
725 while (seg_pos > cur_vtbl->end_seg) {
726 cur_vtbl = list_entry(cur_vtbl->node.next, zft_volinfo, node);
727 TRACE(ft_t_noise, "%d - %d", cur_vtbl->start_seg, cur_vtbl->end_seg);
728 }
729 while (seg_pos < cur_vtbl->start_seg) {
730 cur_vtbl = list_entry(cur_vtbl->node.prev, zft_volinfo, node);
731 TRACE(ft_t_noise, "%d - %d", cur_vtbl->start_seg, cur_vtbl->end_seg);
732 }
733 if (seg_pos > cur_vtbl->end_seg || seg_pos < cur_vtbl->start_seg) {
734 TRACE(ft_t_bug, "This cannot happen");
735 }
736 DUMP_VOLINFO(ft_t_noise, "", cur_vtbl);
737 TRACE_EXIT cur_vtbl;
738}
739
740/* this function really assumes that we are just before eof
741 */
742void zft_move_past_eof(zft_position *pos)
743{
744 TRACE_FUN(ft_t_flow);
745
746 TRACE(ft_t_noise, "old seg. pos: %d", pos->seg_pos);
747 pos->tape_pos += zft_get_seg_sz(pos->seg_pos++) - pos->seg_byte_pos;
748 pos->seg_byte_pos = 0;
749 pos->volume_pos = 0;
750 if (zft_cmpr_ops) {
751 (*zft_cmpr_ops->reset)();
752 }
753 zft_just_before_eof = 0;
754 zft_deblock_segment = -1; /* no need to cache it anymore */
755 TRACE(ft_t_noise, "new seg. pos: %d", pos->seg_pos);
756 TRACE_EXIT;
757}
diff --git a/drivers/char/ftape/zftape/zftape-vtbl.h b/drivers/char/ftape/zftape/zftape-vtbl.h
deleted file mode 100644
index f31d196d1759..000000000000
--- a/drivers/char/ftape/zftape/zftape-vtbl.h
+++ /dev/null
@@ -1,227 +0,0 @@
1#ifndef _ZFTAPE_VTBL_H
2#define _ZFTAPE_VTBL_H
3
4/*
5 * Copyright (c) 1995-1997 Claus-Justus Heine
6
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2, or (at
10 your option) any later version.
11
12 This program is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
20 USA.
21
22 *
23 * $Source: /homes/cvs/ftape-stacked/ftape/zftape/zftape-vtbl.h,v $
24 * $Revision: 1.3 $
25 * $Date: 1997/10/28 14:30:09 $
26 *
27 * This file defines a volume table as defined in the QIC-80
28 * development standards.
29 */
30
31#include <linux/list.h>
32
33#include "../lowlevel/ftape-tracing.h"
34
35#include "../zftape/zftape-eof.h"
36#include "../zftape/zftape-ctl.h"
37#include "../zftape/zftape-rw.h"
38
39#define VTBL_SIZE 128 /* bytes */
40
41/* The following are offsets in the vtbl. */
42#define VTBL_SIG 0
43#define VTBL_START 4
44#define VTBL_END 6
45#define VTBL_DESC 8
46#define VTBL_DATE 52
47#define VTBL_FLAGS 56
48#define VTBL_FL_VENDOR_SPECIFIC (1<<0)
49#define VTBL_FL_MUTLI_CARTRIDGE (1<<1)
50#define VTBL_FL_NOT_VERIFIED (1<<2)
51#define VTBL_FL_REDIR_INHIBIT (1<<3)
52#define VTBL_FL_SEG_SPANNING (1<<4)
53#define VTBL_FL_DIRECTORY_LAST (1<<5)
54#define VTBL_FL_RESERVED_6 (1<<6)
55#define VTBL_FL_RESERVED_7 (1<<7)
56#define VTBL_M_NO 57
57#define VTBL_EXT 58
58#define EXT_ZFTAPE_SIG 0
59#define EXT_ZFTAPE_BLKSZ 10
60#define EXT_ZFTAPE_CMAP 12
61#define EXT_ZFTAPE_QIC113 13
62#define VTBL_PWD 84
63#define VTBL_DIR_SIZE 92
64#define VTBL_DATA_SIZE 96
65#define VTBL_OS_VERSION 104
66#define VTBL_SRC_DRIVE 106
67#define VTBL_DEV 122
68#define VTBL_RESERVED_1 123
69#define VTBL_CMPR 124
70#define VTBL_CMPR_UNREG 0x3f
71#define VTBL_CMPR_USED 0x80
72#define VTBL_FMT 125
73#define VTBL_RESERVED_2 126
74#define VTBL_RESERVED_3 127
75/* compatibility with pre revision K */
76#define VTBL_K_CMPR 120
77
78/* the next is used by QIC-3020 tapes with format code 6 (>2^16
79 * segments) It is specified in QIC-113, Rev. G, Section 5 (SCSI
80 * volume table). The difference is simply, that we only store the
81 * number of segments used, not the starting segment.
82 */
83#define VTBL_SCSI_SEGS 4 /* is a 4 byte value */
84
85/* one vtbl is 128 bytes, that results in a maximum number of
86 * 29*1024/128 = 232 volumes.
87 */
88#define ZFT_MAX_VOLUMES (FT_SEGMENT_SIZE/VTBL_SIZE)
89#define VTBL_ID "VTBL"
90#define VTBL_IDS { VTBL_ID, "XTBL", "UTID", "EXVT" } /* other valid ids */
91#define ZFT_VOL_NAME "zftape volume" /* volume label used by me */
92#define ZFTAPE_SIG "LINUX ZFT"
93
94/* global variables
95 */
96typedef struct zft_internal_vtbl
97{
98 struct list_head node;
99 int count;
100 unsigned int start_seg; /* 32 bits are enough for now */
101 unsigned int end_seg; /* 32 bits are enough for now */
102 __s64 size; /* uncompressed size */
103 unsigned int blk_sz; /* block size for this volume */
104 unsigned int zft_volume :1; /* zftape created this volume */
105 unsigned int use_compression:1; /* compressed volume */
106 unsigned int qic113 :1; /* layout of compressed block
107 * info and vtbl conforms to
108 * QIC-113, Rev. G
109 */
110 unsigned int new_volume :1; /* it was created by us, this
111 * run. this allows the
112 * fields that aren't really
113 * used by zftape to be filled
114 * in by some user level
115 * program.
116 */
117 unsigned int open :1; /* just in progress of being
118 * written
119 */
120} zft_volinfo;
121
122extern struct list_head zft_vtbl;
123#define zft_head_vtbl list_entry(zft_vtbl.next, zft_volinfo, node)
124#define zft_eom_vtbl list_entry(zft_vtbl.prev, zft_volinfo, node)
125#define zft_last_vtbl list_entry(zft_eom_vtbl->node.prev, zft_volinfo, node)
126#define zft_first_vtbl list_entry(zft_head_vtbl->node.next, zft_volinfo, node)
127#define zft_vtbl_empty (zft_eom_vtbl->node.prev == &zft_head_vtbl->node)
128
129#define DUMP_VOLINFO(level, desc, info) \
130{ \
131 char tmp[21]; \
132 strlcpy(tmp, desc, sizeof(tmp)); \
133 TRACE(level, "Volume %d:\n" \
134 KERN_INFO "description : %s\n" \
135 KERN_INFO "first segment: %d\n" \
136 KERN_INFO "last segment: %d\n" \
137 KERN_INFO "size : " LL_X "\n" \
138 KERN_INFO "block size : %d\n" \
139 KERN_INFO "compression : %d\n" \
140 KERN_INFO "zftape volume: %d\n" \
141 KERN_INFO "QIC-113 conf.: %d", \
142 (info)->count, tmp, (info)->start_seg, (info)->end_seg, \
143 LL((info)->size), (info)->blk_sz, \
144 (info)->use_compression != 0, (info)->zft_volume != 0, \
145 (info)->qic113 != 0); \
146}
147
148extern int zft_qic_mode;
149extern int zft_old_ftape;
150extern int zft_volume_table_changed;
151
152/* exported functions */
153extern void zft_init_vtbl (void);
154extern void zft_free_vtbl (void);
155extern int zft_extract_volume_headers(__u8 *buffer);
156extern int zft_update_volume_table (unsigned int segment);
157extern int zft_open_volume (zft_position *pos,
158 int blk_sz, int use_compression);
159extern int zft_close_volume (zft_position *pos);
160extern const zft_volinfo *zft_find_volume(unsigned int seg_pos);
161extern int zft_skip_volumes (int count, zft_position *pos);
162extern __s64 zft_get_eom_pos (void);
163extern void zft_skip_to_eom (zft_position *pos);
164extern int zft_fake_volume_headers (eof_mark_union *eof_map,
165 int num_failed_sectors);
166extern int zft_weof (unsigned int count, zft_position *pos);
167extern void zft_move_past_eof (zft_position *pos);
168
169static inline int zft_tape_at_eod (const zft_position *pos);
170static inline int zft_tape_at_lbot (const zft_position *pos);
171static inline void zft_position_before_eof (zft_position *pos,
172 const zft_volinfo *volume);
173static inline __s64 zft_check_for_eof(const zft_volinfo *vtbl,
174 const zft_position *pos);
175
176/* this function decrements the zft_seg_pos counter if we are right
177 * at the beginning of a segment. This is to handle fsfm/bsfm -- we
178 * need to position before the eof mark. NOTE: zft_tape_pos is not
179 * changed
180 */
181static inline void zft_position_before_eof(zft_position *pos,
182 const zft_volinfo *volume)
183{
184 TRACE_FUN(ft_t_flow);
185
186 if (pos->seg_pos == volume->end_seg + 1 && pos->seg_byte_pos == 0) {
187 pos->seg_pos --;
188 pos->seg_byte_pos = zft_get_seg_sz(pos->seg_pos);
189 }
190 TRACE_EXIT;
191}
192
193/* Mmmh. Is the position at the end of the last volume, that is right
194 * before the last EOF mark also logical an EOD condition?
195 */
196static inline int zft_tape_at_eod(const zft_position *pos)
197{
198 TRACE_FUN(ft_t_any);
199
200 if (zft_qic_mode) {
201 TRACE_EXIT (pos->seg_pos >= zft_eom_vtbl->start_seg ||
202 zft_last_vtbl->open);
203 } else {
204 TRACE_EXIT pos->seg_pos > ft_last_data_segment;
205 }
206}
207
208static inline int zft_tape_at_lbot(const zft_position *pos)
209{
210 if (zft_qic_mode) {
211 return (pos->seg_pos <= zft_first_vtbl->start_seg &&
212 pos->volume_pos == 0);
213 } else {
214 return (pos->seg_pos <= ft_first_data_segment &&
215 pos->volume_pos == 0);
216 }
217}
218
219/* This one checks for EOF. return remaing space (may be negative)
220 */
221static inline __s64 zft_check_for_eof(const zft_volinfo *vtbl,
222 const zft_position *pos)
223{
224 return (__s64)(vtbl->size - pos->volume_pos);
225}
226
227#endif /* _ZFTAPE_VTBL_H */
diff --git a/drivers/char/ftape/zftape/zftape-write.c b/drivers/char/ftape/zftape/zftape-write.c
deleted file mode 100644
index 94327b8c97b9..000000000000
--- a/drivers/char/ftape/zftape/zftape-write.c
+++ /dev/null
@@ -1,483 +0,0 @@
1/*
2 * Copyright (C) 1996, 1997 Claus Heine
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 *
19 * $Source: /homes/cvs/ftape-stacked/ftape/zftape/zftape-write.c,v $
20 * $Revision: 1.3 $
21 * $Date: 1997/11/06 00:50:29 $
22 *
23 * This file contains the writing code
24 * for the QIC-117 floppy-tape driver for Linux.
25 */
26
27#include <linux/errno.h>
28#include <linux/mm.h>
29
30#include <linux/zftape.h>
31
32#include <asm/uaccess.h>
33
34#include "../zftape/zftape-init.h"
35#include "../zftape/zftape-eof.h"
36#include "../zftape/zftape-ctl.h"
37#include "../zftape/zftape-write.h"
38#include "../zftape/zftape-read.h"
39#include "../zftape/zftape-rw.h"
40#include "../zftape/zftape-vtbl.h"
41
42/* Global vars.
43 */
44
45/* Local vars.
46 */
47static int last_write_failed;
48static int need_flush;
49
50void zft_prevent_flush(void)
51{
52 need_flush = 0;
53}
54
55static int zft_write_header_segments(__u8* buffer)
56{
57 int header_1_ok = 0;
58 int header_2_ok = 0;
59 unsigned int time_stamp;
60 TRACE_FUN(ft_t_noise);
61
62 TRACE_CATCH(ftape_abort_operation(),);
63 ftape_seek_to_bot(); /* prevents extra rewind */
64 if (GET4(buffer, 0) != FT_HSEG_MAGIC) {
65 TRACE_ABORT(-EIO, ft_t_err,
66 "wrong header signature found, aborting");
67 }
68 /* Be optimistic: */
69 PUT4(buffer, FT_SEG_CNT,
70 zft_written_segments + GET4(buffer, FT_SEG_CNT) + 2);
71 if ((time_stamp = zft_get_time()) != 0) {
72 PUT4(buffer, FT_WR_DATE, time_stamp);
73 if (zft_label_changed) {
74 PUT4(buffer, FT_LABEL_DATE, time_stamp);
75 }
76 }
77 TRACE(ft_t_noise,
78 "writing first header segment %d", ft_header_segment_1);
79 header_1_ok = zft_verify_write_segments(ft_header_segment_1,
80 buffer, FT_SEGMENT_SIZE,
81 zft_deblock_buf) >= 0;
82 TRACE(ft_t_noise,
83 "writing second header segment %d", ft_header_segment_2);
84 header_2_ok = zft_verify_write_segments(ft_header_segment_2,
85 buffer, FT_SEGMENT_SIZE,
86 zft_deblock_buf) >= 0;
87 if (!header_1_ok) {
88 TRACE(ft_t_warn, "Warning: "
89 "update of first header segment failed");
90 }
91 if (!header_2_ok) {
92 TRACE(ft_t_warn, "Warning: "
93 "update of second header segment failed");
94 }
95 if (!header_1_ok && !header_2_ok) {
96 TRACE_ABORT(-EIO, ft_t_err, "Error: "
97 "update of both header segments failed.");
98 }
99 TRACE_EXIT 0;
100}
101
102int zft_update_header_segments(void)
103{
104 TRACE_FUN(ft_t_noise);
105
106 /* must NOT use zft_write_protected, as it also includes the
107 * file access mode. But we also want to update when soft
108 * write protection is enabled (O_RDONLY)
109 */
110 if (ft_write_protected || zft_old_ftape) {
111 TRACE_ABORT(0, ft_t_noise, "Tape set read-only: no update");
112 }
113 if (!zft_header_read) {
114 TRACE_ABORT(0, ft_t_noise, "Nothing to update");
115 }
116 if (!zft_header_changed) {
117 zft_header_changed = zft_written_segments > 0;
118 }
119 if (!zft_header_changed && !zft_volume_table_changed) {
120 TRACE_ABORT(0, ft_t_noise, "Nothing to update");
121 }
122 TRACE(ft_t_noise, "Updating header segments");
123 if (ftape_get_status()->fti_state == writing) {
124 TRACE_CATCH(ftape_loop_until_writes_done(),);
125 }
126 TRACE_CATCH(ftape_abort_operation(),);
127
128 zft_deblock_segment = -1; /* invalidate the cache */
129 if (zft_header_changed) {
130 TRACE_CATCH(zft_write_header_segments(zft_hseg_buf),);
131 }
132 if (zft_volume_table_changed) {
133 TRACE_CATCH(zft_update_volume_table(ft_first_data_segment),);
134 }
135 zft_header_changed =
136 zft_volume_table_changed =
137 zft_label_changed =
138 zft_written_segments = 0;
139 TRACE_CATCH(ftape_abort_operation(),);
140 ftape_seek_to_bot();
141 TRACE_EXIT 0;
142}
143
144static int read_merge_buffer(int seg_pos, __u8 *buffer, int offset, int seg_sz)
145{
146 int result = 0;
147 const ft_trace_t old_tracing = TRACE_LEVEL;
148 TRACE_FUN(ft_t_flow);
149
150 if (zft_qic_mode) {
151 /* writing in the middle of a volume is NOT allowed
152 *
153 */
154 TRACE(ft_t_noise, "No need to read a segment");
155 memset(buffer + offset, 0, seg_sz - offset);
156 TRACE_EXIT 0;
157 }
158 TRACE(ft_t_any, "waiting");
159 ftape_start_writing(FT_WR_MULTI);
160 TRACE_CATCH(ftape_loop_until_writes_done(),);
161
162 TRACE(ft_t_noise, "trying to read segment %d from offset %d",
163 seg_pos, offset);
164 SET_TRACE_LEVEL(ft_t_bug);
165 result = zft_fetch_segment_fraction(seg_pos, buffer,
166 FT_RD_SINGLE,
167 offset, seg_sz - offset);
168 SET_TRACE_LEVEL(old_tracing);
169 if (result != (seg_sz - offset)) {
170 TRACE(ft_t_noise, "Ignore error: read_segment() result: %d",
171 result);
172 memset(buffer + offset, 0, seg_sz - offset);
173 }
174 TRACE_EXIT 0;
175}
176
177/* flush the write buffer to tape and write an eof-marker at the
178 * current position if not in raw mode. This function always
179 * positions the tape before the eof-marker. _ftape_close() should
180 * then advance to the next segment.
181 *
182 * the parameter "finish_volume" describes whether to position before
183 * or after the possibly created file-mark. We always position after
184 * the file-mark when called from ftape_close() and a flush was needed
185 * (that is ftape_write() was the last tape operation before calling
186 * ftape_flush) But we always position before the file-mark when this
187 * function get's called from outside ftape_close()
188 */
189int zft_flush_buffers(void)
190{
191 int result;
192 int data_remaining;
193 int this_segs_size;
194 TRACE_FUN(ft_t_flow);
195
196 TRACE(ft_t_data_flow,
197 "entered, ftape_state = %d", ftape_get_status()->fti_state);
198 if (ftape_get_status()->fti_state != writing && !need_flush) {
199 TRACE_ABORT(0, ft_t_noise, "no need for flush");
200 }
201 zft_io_state = zft_idle; /* triggers some initializations for the
202 * read and write routines
203 */
204 if (last_write_failed) {
205 ftape_abort_operation();
206 TRACE_EXIT -EIO;
207 }
208 TRACE(ft_t_noise, "flushing write buffers");
209 this_segs_size = zft_get_seg_sz(zft_pos.seg_pos);
210 if (this_segs_size == zft_pos.seg_byte_pos) {
211 zft_pos.seg_pos ++;
212 data_remaining = zft_pos.seg_byte_pos = 0;
213 } else {
214 data_remaining = zft_pos.seg_byte_pos;
215 }
216 /* If there is any data not written to tape yet, append zero's
217 * up to the end of the sector (if using compression) or merge
218 * it with the data existing on the tape Then write the
219 * segment(s) to tape.
220 */
221 TRACE(ft_t_noise, "Position:\n"
222 KERN_INFO "seg_pos : %d\n"
223 KERN_INFO "byte pos : %d\n"
224 KERN_INFO "remaining: %d",
225 zft_pos.seg_pos, zft_pos.seg_byte_pos, data_remaining);
226 if (data_remaining > 0) {
227 do {
228 this_segs_size = zft_get_seg_sz(zft_pos.seg_pos);
229 if (this_segs_size > data_remaining) {
230 TRACE_CATCH(read_merge_buffer(zft_pos.seg_pos,
231 zft_deblock_buf,
232 data_remaining,
233 this_segs_size),
234 last_write_failed = 1);
235 }
236 result = ftape_write_segment(zft_pos.seg_pos,
237 zft_deblock_buf,
238 FT_WR_MULTI);
239 if (result != this_segs_size) {
240 TRACE(ft_t_err, "flush buffers failed");
241 zft_pos.tape_pos -= zft_pos.seg_byte_pos;
242 zft_pos.seg_byte_pos = 0;
243
244 last_write_failed = 1;
245 TRACE_EXIT result;
246 }
247 zft_written_segments ++;
248 TRACE(ft_t_data_flow,
249 "flush, moved out buffer: %d", result);
250 /* need next segment for more data (empty segments?)
251 */
252 if (result < data_remaining) {
253 if (result > 0) {
254 /* move remainder to buffer beginning
255 */
256 memmove(zft_deblock_buf,
257 zft_deblock_buf + result,
258 FT_SEGMENT_SIZE - result);
259 }
260 }
261 data_remaining -= result;
262 zft_pos.seg_pos ++;
263 } while (data_remaining > 0);
264 TRACE(ft_t_any, "result: %d", result);
265 zft_deblock_segment = --zft_pos.seg_pos;
266 if (data_remaining == 0) { /* first byte next segment */
267 zft_pos.seg_byte_pos = this_segs_size;
268 } else { /* after data previous segment, data_remaining < 0 */
269 zft_pos.seg_byte_pos = data_remaining + result;
270 }
271 } else {
272 TRACE(ft_t_noise, "zft_deblock_buf empty");
273 zft_pos.seg_pos --;
274 zft_pos.seg_byte_pos = zft_get_seg_sz (zft_pos.seg_pos);
275 ftape_start_writing(FT_WR_MULTI);
276 }
277 TRACE(ft_t_any, "waiting");
278 if ((result = ftape_loop_until_writes_done()) < 0) {
279 /* that's really bad. What to to with zft_tape_pos?
280 */
281 TRACE(ft_t_err, "flush buffers failed");
282 }
283 TRACE(ft_t_any, "zft_seg_pos: %d, zft_seg_byte_pos: %d",
284 zft_pos.seg_pos, zft_pos.seg_byte_pos);
285 last_write_failed =
286 need_flush = 0;
287 TRACE_EXIT result;
288}
289
290/* return-value: the number of bytes removed from the user-buffer
291 *
292 * out:
293 * int *write_cnt: how much actually has been moved to the
294 * zft_deblock_buf
295 * int req_len : MUST NOT BE CHANGED, except at EOT, in
296 * which case it may be adjusted
297 * in :
298 * char *buff : the user buffer
299 * int buf_pos_write : copy of buf_len_wr int
300 * this_segs_size : the size in bytes of the actual segment
301 * char
302 * *zft_deblock_buf : zft_deblock_buf
303 */
304static int zft_simple_write(int *cnt,
305 __u8 *dst_buf, const int seg_sz,
306 const __u8 __user *src_buf, const int req_len,
307 const zft_position *pos,const zft_volinfo *volume)
308{
309 int space_left;
310 TRACE_FUN(ft_t_flow);
311
312 /* volume->size holds the tape capacity while volume is open */
313 if (pos->tape_pos + volume->blk_sz > volume->size) {
314 TRACE_EXIT -ENOSPC;
315 }
316 /* remaining space in this segment, NOT zft_deblock_buf
317 */
318 space_left = seg_sz - pos->seg_byte_pos;
319 *cnt = req_len < space_left ? req_len : space_left;
320 if (copy_from_user(dst_buf + pos->seg_byte_pos, src_buf, *cnt) != 0) {
321 TRACE_EXIT -EFAULT;
322 }
323 TRACE_EXIT *cnt;
324}
325
326static int check_write_access(int req_len,
327 const zft_volinfo **volume,
328 zft_position *pos,
329 const unsigned int blk_sz)
330{
331 int result;
332 TRACE_FUN(ft_t_flow);
333
334 if ((req_len % zft_blk_sz) != 0) {
335 TRACE_ABORT(-EINVAL, ft_t_info,
336 "write-count %d must be multiple of block-size %d",
337 req_len, blk_sz);
338 }
339 if (zft_io_state == zft_writing) {
340 /* all other error conditions have been checked earlier
341 */
342 TRACE_EXIT 0;
343 }
344 zft_io_state = zft_idle;
345 TRACE_CATCH(zft_check_write_access(pos),);
346 /* If we haven't read the header segment yet, do it now.
347 * This will verify the configuration, get the bad sector
348 * table and read the volume table segment
349 */
350 if (!zft_header_read) {
351 TRACE_CATCH(zft_read_header_segments(),);
352 }
353 /* fine. Now the tape is either at BOT or at EOD,
354 * Write start of volume now
355 */
356 TRACE_CATCH(zft_open_volume(pos, blk_sz, zft_use_compression),);
357 *volume = zft_find_volume(pos->seg_pos);
358 DUMP_VOLINFO(ft_t_noise, "", *volume);
359 zft_just_before_eof = 0;
360 /* now merge with old data if necessary */
361 if (!zft_qic_mode && pos->seg_byte_pos != 0){
362 result = zft_fetch_segment(pos->seg_pos,
363 zft_deblock_buf,
364 FT_RD_SINGLE);
365 if (result < 0) {
366 if (result == -EINTR || result == -ENOSPC) {
367 TRACE_EXIT result;
368 }
369 TRACE(ft_t_noise,
370 "ftape_read_segment() result: %d. "
371 "This might be normal when using "
372 "a newly\nformatted tape", result);
373 memset(zft_deblock_buf, '\0', pos->seg_byte_pos);
374 }
375 }
376 zft_io_state = zft_writing;
377 TRACE_EXIT 0;
378}
379
380static int fill_deblock_buf(__u8 *dst_buf, const int seg_sz,
381 zft_position *pos, const zft_volinfo *volume,
382 const char __user *usr_buf, const int req_len)
383{
384 int cnt = 0;
385 int result = 0;
386 TRACE_FUN(ft_t_flow);
387
388 if (seg_sz == 0) {
389 TRACE_ABORT(0, ft_t_data_flow, "empty segment");
390 }
391 TRACE(ft_t_data_flow, "\n"
392 KERN_INFO "remaining req_len: %d\n"
393 KERN_INFO " buf_pos: %d",
394 req_len, pos->seg_byte_pos);
395 /* zft_deblock_buf will not contain a valid segment any longer */
396 zft_deblock_segment = -1;
397 if (zft_use_compression) {
398 TRACE_CATCH(zft_cmpr_lock(1 /* try to load */),);
399 TRACE_CATCH(result= (*zft_cmpr_ops->write)(&cnt,
400 dst_buf, seg_sz,
401 usr_buf, req_len,
402 pos, volume),);
403 } else {
404 TRACE_CATCH(result= zft_simple_write(&cnt,
405 dst_buf, seg_sz,
406 usr_buf, req_len,
407 pos, volume),);
408 }
409 pos->volume_pos += result;
410 pos->seg_byte_pos += cnt;
411 pos->tape_pos += cnt;
412 TRACE(ft_t_data_flow, "\n"
413 KERN_INFO "removed from user-buffer : %d bytes.\n"
414 KERN_INFO "copied to zft_deblock_buf: %d bytes.\n"
415 KERN_INFO "zft_tape_pos : " LL_X " bytes.",
416 result, cnt, LL(pos->tape_pos));
417 TRACE_EXIT result;
418}
419
420
421/* called by the kernel-interface routine "zft_write()"
422 */
423int _zft_write(const char __user *buff, int req_len)
424{
425 int result = 0;
426 int written = 0;
427 int write_cnt;
428 int seg_sz;
429 static const zft_volinfo *volume = NULL;
430 TRACE_FUN(ft_t_flow);
431
432 zft_resid = req_len;
433 last_write_failed = 1; /* reset to 0 when successful */
434 /* check if write is allowed
435 */
436 TRACE_CATCH(check_write_access(req_len, &volume,&zft_pos,zft_blk_sz),);
437 while (req_len > 0) {
438 /* Allow us to escape from this loop with a signal !
439 */
440 FT_SIGNAL_EXIT(_DONT_BLOCK);
441 seg_sz = zft_get_seg_sz(zft_pos.seg_pos);
442 if ((write_cnt = fill_deblock_buf(zft_deblock_buf,
443 seg_sz,
444 &zft_pos,
445 volume,
446 buff,
447 req_len)) < 0) {
448 zft_resid -= written;
449 if (write_cnt == -ENOSPC) {
450 /* leave the remainder to flush_buffers()
451 */
452 TRACE(ft_t_info, "No space left on device");
453 last_write_failed = 0;
454 if (!need_flush) {
455 need_flush = written > 0;
456 }
457 TRACE_EXIT written > 0 ? written : -ENOSPC;
458 } else {
459 TRACE_EXIT result;
460 }
461 }
462 if (zft_pos.seg_byte_pos == seg_sz) {
463 TRACE_CATCH(ftape_write_segment(zft_pos.seg_pos,
464 zft_deblock_buf,
465 FT_WR_ASYNC),
466 zft_resid -= written);
467 zft_written_segments ++;
468 zft_pos.seg_byte_pos = 0;
469 zft_deblock_segment = zft_pos.seg_pos;
470 ++zft_pos.seg_pos;
471 }
472 written += write_cnt;
473 buff += write_cnt;
474 req_len -= write_cnt;
475 } /* while (req_len > 0) */
476 TRACE(ft_t_data_flow, "remaining in blocking buffer: %d",
477 zft_pos.seg_byte_pos);
478 TRACE(ft_t_data_flow, "just written bytes: %d", written);
479 last_write_failed = 0;
480 zft_resid -= written;
481 need_flush = need_flush || written > 0;
482 TRACE_EXIT written; /* bytes written */
483}
diff --git a/drivers/char/ftape/zftape/zftape-write.h b/drivers/char/ftape/zftape/zftape-write.h
deleted file mode 100644
index ea887015b493..000000000000
--- a/drivers/char/ftape/zftape/zftape-write.h
+++ /dev/null
@@ -1,38 +0,0 @@
1#ifndef _ZFTAPE_WRITE_H
2#define _ZFTAPE_WRITE_H
3
4/*
5 * Copyright (C) 1996, 1997 Claus-Justus Heine
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 *
22 * $Source: /homes/cvs/ftape-stacked/ftape/zftape/zftape-write.h,v $
23 * $Revision: 1.2 $
24 * $Date: 1997/10/05 19:19:13 $
25 *
26 * This file contains the definitions for the write functions
27 * for the zftape driver for Linux.
28 *
29 */
30
31extern int zft_flush_buffers(void);
32extern int zft_update_header_segments(void);
33extern void zft_prevent_flush(void);
34
35/* hook for the VFS interface
36 */
37extern int _zft_write(const char __user *buff, int req_len);
38#endif /* _ZFTAPE_WRITE_H */
diff --git a/drivers/char/ftape/zftape/zftape_syms.c b/drivers/char/ftape/zftape/zftape_syms.c
deleted file mode 100644
index 2db1401682df..000000000000
--- a/drivers/char/ftape/zftape/zftape_syms.c
+++ /dev/null
@@ -1,43 +0,0 @@
1/*
2 * Copyright (C) 1997 Claus-Justus Heine
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 *
19 * $Source: /homes/cvs/ftape-stacked/ftape/zftape/zftape_syms.c,v $
20 * $Revision: 1.3 $
21 * $Date: 1997/10/05 19:19:14 $
22 *
23 * This file contains the symbols that the zftape frontend to
24 * the ftape floppy tape driver exports
25 */
26
27#include <linux/module.h>
28
29#include <linux/zftape.h>
30
31#include "../zftape/zftape-init.h"
32#include "../zftape/zftape-read.h"
33#include "../zftape/zftape-buffers.h"
34#include "../zftape/zftape-ctl.h"
35
36/* zftape-init.c */
37EXPORT_SYMBOL(zft_cmpr_register);
38/* zftape-read.c */
39EXPORT_SYMBOL(zft_fetch_segment_fraction);
40/* zftape-buffers.c */
41EXPORT_SYMBOL(zft_vmalloc_once);
42EXPORT_SYMBOL(zft_vmalloc_always);
43EXPORT_SYMBOL(zft_vfree);
diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
index 817dc409ac20..23b25ada65ea 100644
--- a/drivers/char/genrtc.c
+++ b/drivers/char/genrtc.c
@@ -102,7 +102,7 @@ static void gen_rtc_interrupt(unsigned long arg);
102 * Routine to poll RTC seconds field for change as often as possible, 102 * Routine to poll RTC seconds field for change as often as possible,
103 * after first RTC_UIE use timer to reduce polling 103 * after first RTC_UIE use timer to reduce polling
104 */ 104 */
105static void genrtc_troutine(void *data) 105static void genrtc_troutine(struct work_struct *work)
106{ 106{
107 unsigned int tmp = get_rtc_ss(); 107 unsigned int tmp = get_rtc_ss();
108 108
@@ -255,7 +255,7 @@ static inline int gen_set_rtc_irq_bit(unsigned char bit)
255 irq_active = 1; 255 irq_active = 1;
256 stop_rtc_timers = 0; 256 stop_rtc_timers = 0;
257 lostint = 0; 257 lostint = 0;
258 INIT_WORK(&genrtc_task, genrtc_troutine, NULL); 258 INIT_WORK(&genrtc_task, genrtc_troutine);
259 oldsecs = get_rtc_ss(); 259 oldsecs = get_rtc_ss();
260 init_timer(&timer_task); 260 init_timer(&timer_task);
261 261
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index 091a11cd878c..20dc3be5ecfc 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -21,6 +21,7 @@
21#include <linux/fcntl.h> 21#include <linux/fcntl.h>
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/poll.h> 23#include <linux/poll.h>
24#include <linux/mm.h>
24#include <linux/proc_fs.h> 25#include <linux/proc_fs.h>
25#include <linux/spinlock.h> 26#include <linux/spinlock.h>
26#include <linux/sysctl.h> 27#include <linux/sysctl.h>
diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c
index 9902ffad3b12..cc2cd46bedc6 100644
--- a/drivers/char/hvc_console.c
+++ b/drivers/char/hvc_console.c
@@ -38,6 +38,7 @@
38#include <linux/sched.h> 38#include <linux/sched.h>
39#include <linux/spinlock.h> 39#include <linux/spinlock.h>
40#include <linux/delay.h> 40#include <linux/delay.h>
41#include <linux/freezer.h>
41 42
42#include <asm/uaccess.h> 43#include <asm/uaccess.h>
43 44
diff --git a/drivers/char/hvcs.c b/drivers/char/hvcs.c
index 8728255c9463..d090622f1dea 100644
--- a/drivers/char/hvcs.c
+++ b/drivers/char/hvcs.c
@@ -337,11 +337,6 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp);
337static void hvcs_close(struct tty_struct *tty, struct file *filp); 337static void hvcs_close(struct tty_struct *tty, struct file *filp);
338static void hvcs_hangup(struct tty_struct * tty); 338static void hvcs_hangup(struct tty_struct * tty);
339 339
340static void hvcs_create_device_attrs(struct hvcs_struct *hvcsd);
341static void hvcs_remove_device_attrs(struct vio_dev *vdev);
342static void hvcs_create_driver_attrs(void);
343static void hvcs_remove_driver_attrs(void);
344
345static int __devinit hvcs_probe(struct vio_dev *dev, 340static int __devinit hvcs_probe(struct vio_dev *dev,
346 const struct vio_device_id *id); 341 const struct vio_device_id *id);
347static int __devexit hvcs_remove(struct vio_dev *dev); 342static int __devexit hvcs_remove(struct vio_dev *dev);
@@ -353,6 +348,172 @@ static void __exit hvcs_module_exit(void);
353#define HVCS_TRY_WRITE 0x00000004 348#define HVCS_TRY_WRITE 0x00000004
354#define HVCS_READ_MASK (HVCS_SCHED_READ | HVCS_QUICK_READ) 349#define HVCS_READ_MASK (HVCS_SCHED_READ | HVCS_QUICK_READ)
355 350
351static inline struct hvcs_struct *from_vio_dev(struct vio_dev *viod)
352{
353 return viod->dev.driver_data;
354}
355/* The sysfs interface for the driver and devices */
356
357static ssize_t hvcs_partner_vtys_show(struct device *dev, struct device_attribute *attr, char *buf)
358{
359 struct vio_dev *viod = to_vio_dev(dev);
360 struct hvcs_struct *hvcsd = from_vio_dev(viod);
361 unsigned long flags;
362 int retval;
363
364 spin_lock_irqsave(&hvcsd->lock, flags);
365 retval = sprintf(buf, "%X\n", hvcsd->p_unit_address);
366 spin_unlock_irqrestore(&hvcsd->lock, flags);
367 return retval;
368}
369static DEVICE_ATTR(partner_vtys, S_IRUGO, hvcs_partner_vtys_show, NULL);
370
371static ssize_t hvcs_partner_clcs_show(struct device *dev, struct device_attribute *attr, char *buf)
372{
373 struct vio_dev *viod = to_vio_dev(dev);
374 struct hvcs_struct *hvcsd = from_vio_dev(viod);
375 unsigned long flags;
376 int retval;
377
378 spin_lock_irqsave(&hvcsd->lock, flags);
379 retval = sprintf(buf, "%s\n", &hvcsd->p_location_code[0]);
380 spin_unlock_irqrestore(&hvcsd->lock, flags);
381 return retval;
382}
383static DEVICE_ATTR(partner_clcs, S_IRUGO, hvcs_partner_clcs_show, NULL);
384
385static ssize_t hvcs_current_vty_store(struct device *dev, struct device_attribute *attr, const char * buf,
386 size_t count)
387{
388 /*
389 * Don't need this feature at the present time because firmware doesn't
390 * yet support multiple partners.
391 */
392 printk(KERN_INFO "HVCS: Denied current_vty change: -EPERM.\n");
393 return -EPERM;
394}
395
396static ssize_t hvcs_current_vty_show(struct device *dev, struct device_attribute *attr, char *buf)
397{
398 struct vio_dev *viod = to_vio_dev(dev);
399 struct hvcs_struct *hvcsd = from_vio_dev(viod);
400 unsigned long flags;
401 int retval;
402
403 spin_lock_irqsave(&hvcsd->lock, flags);
404 retval = sprintf(buf, "%s\n", &hvcsd->p_location_code[0]);
405 spin_unlock_irqrestore(&hvcsd->lock, flags);
406 return retval;
407}
408
409static DEVICE_ATTR(current_vty,
410 S_IRUGO | S_IWUSR, hvcs_current_vty_show, hvcs_current_vty_store);
411
412static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribute *attr, const char *buf,
413 size_t count)
414{
415 struct vio_dev *viod = to_vio_dev(dev);
416 struct hvcs_struct *hvcsd = from_vio_dev(viod);
417 unsigned long flags;
418
419 /* writing a '0' to this sysfs entry will result in the disconnect. */
420 if (simple_strtol(buf, NULL, 0) != 0)
421 return -EINVAL;
422
423 spin_lock_irqsave(&hvcsd->lock, flags);
424
425 if (hvcsd->open_count > 0) {
426 spin_unlock_irqrestore(&hvcsd->lock, flags);
427 printk(KERN_INFO "HVCS: vterm state unchanged. "
428 "The hvcs device node is still in use.\n");
429 return -EPERM;
430 }
431
432 if (hvcsd->connected == 0) {
433 spin_unlock_irqrestore(&hvcsd->lock, flags);
434 printk(KERN_INFO "HVCS: vterm state unchanged. The"
435 " vty-server is not connected to a vty.\n");
436 return -EPERM;
437 }
438
439 hvcs_partner_free(hvcsd);
440 printk(KERN_INFO "HVCS: Closed vty-server@%X and"
441 " partner vty@%X:%d connection.\n",
442 hvcsd->vdev->unit_address,
443 hvcsd->p_unit_address,
444 (uint32_t)hvcsd->p_partition_ID);
445
446 spin_unlock_irqrestore(&hvcsd->lock, flags);
447 return count;
448}
449
450static ssize_t hvcs_vterm_state_show(struct device *dev, struct device_attribute *attr, char *buf)
451{
452 struct vio_dev *viod = to_vio_dev(dev);
453 struct hvcs_struct *hvcsd = from_vio_dev(viod);
454 unsigned long flags;
455 int retval;
456
457 spin_lock_irqsave(&hvcsd->lock, flags);
458 retval = sprintf(buf, "%d\n", hvcsd->connected);
459 spin_unlock_irqrestore(&hvcsd->lock, flags);
460 return retval;
461}
462static DEVICE_ATTR(vterm_state, S_IRUGO | S_IWUSR,
463 hvcs_vterm_state_show, hvcs_vterm_state_store);
464
465static ssize_t hvcs_index_show(struct device *dev, struct device_attribute *attr, char *buf)
466{
467 struct vio_dev *viod = to_vio_dev(dev);
468 struct hvcs_struct *hvcsd = from_vio_dev(viod);
469 unsigned long flags;
470 int retval;
471
472 spin_lock_irqsave(&hvcsd->lock, flags);
473 retval = sprintf(buf, "%d\n", hvcsd->index);
474 spin_unlock_irqrestore(&hvcsd->lock, flags);
475 return retval;
476}
477
478static DEVICE_ATTR(index, S_IRUGO, hvcs_index_show, NULL);
479
480static struct attribute *hvcs_attrs[] = {
481 &dev_attr_partner_vtys.attr,
482 &dev_attr_partner_clcs.attr,
483 &dev_attr_current_vty.attr,
484 &dev_attr_vterm_state.attr,
485 &dev_attr_index.attr,
486 NULL,
487};
488
489static struct attribute_group hvcs_attr_group = {
490 .attrs = hvcs_attrs,
491};
492
493static ssize_t hvcs_rescan_show(struct device_driver *ddp, char *buf)
494{
495 /* A 1 means it is updating, a 0 means it is done updating */
496 return snprintf(buf, PAGE_SIZE, "%d\n", hvcs_rescan_status);
497}
498
499static ssize_t hvcs_rescan_store(struct device_driver *ddp, const char * buf,
500 size_t count)
501{
502 if ((simple_strtol(buf, NULL, 0) != 1)
503 && (hvcs_rescan_status != 0))
504 return -EINVAL;
505
506 hvcs_rescan_status = 1;
507 printk(KERN_INFO "HVCS: rescanning partner info for all"
508 " vty-servers.\n");
509 hvcs_rescan_devices_list();
510 hvcs_rescan_status = 0;
511 return count;
512}
513
514static DRIVER_ATTR(rescan,
515 S_IRUGO | S_IWUSR, hvcs_rescan_show, hvcs_rescan_store);
516
356static void hvcs_kick(void) 517static void hvcs_kick(void)
357{ 518{
358 hvcs_kicked = 1; 519 hvcs_kicked = 1;
@@ -575,7 +736,7 @@ static void destroy_hvcs_struct(struct kobject *kobj)
575 spin_unlock_irqrestore(&hvcsd->lock, flags); 736 spin_unlock_irqrestore(&hvcsd->lock, flags);
576 spin_unlock(&hvcs_structs_lock); 737 spin_unlock(&hvcs_structs_lock);
577 738
578 hvcs_remove_device_attrs(vdev); 739 sysfs_remove_group(&vdev->dev.kobj, &hvcs_attr_group);
579 740
580 kfree(hvcsd); 741 kfree(hvcsd);
581} 742}
@@ -608,6 +769,7 @@ static int __devinit hvcs_probe(
608{ 769{
609 struct hvcs_struct *hvcsd; 770 struct hvcs_struct *hvcsd;
610 int index; 771 int index;
772 int retval;
611 773
612 if (!dev || !id) { 774 if (!dev || !id) {
613 printk(KERN_ERR "HVCS: probed with invalid parameter.\n"); 775 printk(KERN_ERR "HVCS: probed with invalid parameter.\n");
@@ -658,14 +820,16 @@ static int __devinit hvcs_probe(
658 * the hvcs_struct has been added to the devices list then the user app 820 * the hvcs_struct has been added to the devices list then the user app
659 * will get -ENODEV. 821 * will get -ENODEV.
660 */ 822 */
661
662 spin_lock(&hvcs_structs_lock); 823 spin_lock(&hvcs_structs_lock);
663
664 list_add_tail(&(hvcsd->next), &hvcs_structs); 824 list_add_tail(&(hvcsd->next), &hvcs_structs);
665
666 spin_unlock(&hvcs_structs_lock); 825 spin_unlock(&hvcs_structs_lock);
667 826
668 hvcs_create_device_attrs(hvcsd); 827 retval = sysfs_create_group(&dev->dev.kobj, &hvcs_attr_group);
828 if (retval) {
829 printk(KERN_ERR "HVCS: Can't create sysfs attrs for vty-server@%X\n",
830 hvcsd->vdev->unit_address);
831 return retval;
832 }
669 833
670 printk(KERN_INFO "HVCS: vty-server@%X added to the vio bus.\n", dev->unit_address); 834 printk(KERN_INFO "HVCS: vty-server@%X added to the vio bus.\n", dev->unit_address);
671 835
@@ -1354,8 +1518,10 @@ static int __init hvcs_module_init(void)
1354 if (!hvcs_tty_driver) 1518 if (!hvcs_tty_driver)
1355 return -ENOMEM; 1519 return -ENOMEM;
1356 1520
1357 if (hvcs_alloc_index_list(num_ttys_to_alloc)) 1521 if (hvcs_alloc_index_list(num_ttys_to_alloc)) {
1358 return -ENOMEM; 1522 rc = -ENOMEM;
1523 goto index_fail;
1524 }
1359 1525
1360 hvcs_tty_driver->owner = THIS_MODULE; 1526 hvcs_tty_driver->owner = THIS_MODULE;
1361 1527
@@ -1385,41 +1551,57 @@ static int __init hvcs_module_init(void)
1385 * dynamically assigned major and minor numbers for our devices. 1551 * dynamically assigned major and minor numbers for our devices.
1386 */ 1552 */
1387 if (tty_register_driver(hvcs_tty_driver)) { 1553 if (tty_register_driver(hvcs_tty_driver)) {
1388 printk(KERN_ERR "HVCS: registration " 1554 printk(KERN_ERR "HVCS: registration as a tty driver failed.\n");
1389 " as a tty driver failed.\n"); 1555 rc = -EIO;
1390 hvcs_free_index_list(); 1556 goto register_fail;
1391 put_tty_driver(hvcs_tty_driver);
1392 return -EIO;
1393 } 1557 }
1394 1558
1395 hvcs_pi_buff = kmalloc(PAGE_SIZE, GFP_KERNEL); 1559 hvcs_pi_buff = kmalloc(PAGE_SIZE, GFP_KERNEL);
1396 if (!hvcs_pi_buff) { 1560 if (!hvcs_pi_buff) {
1397 tty_unregister_driver(hvcs_tty_driver); 1561 rc = -ENOMEM;
1398 hvcs_free_index_list(); 1562 goto buff_alloc_fail;
1399 put_tty_driver(hvcs_tty_driver);
1400 return -ENOMEM;
1401 } 1563 }
1402 1564
1403 hvcs_task = kthread_run(khvcsd, NULL, "khvcsd"); 1565 hvcs_task = kthread_run(khvcsd, NULL, "khvcsd");
1404 if (IS_ERR(hvcs_task)) { 1566 if (IS_ERR(hvcs_task)) {
1405 printk(KERN_ERR "HVCS: khvcsd creation failed. Driver not loaded.\n"); 1567 printk(KERN_ERR "HVCS: khvcsd creation failed. Driver not loaded.\n");
1406 kfree(hvcs_pi_buff); 1568 rc = -EIO;
1407 tty_unregister_driver(hvcs_tty_driver); 1569 goto kthread_fail;
1408 hvcs_free_index_list();
1409 put_tty_driver(hvcs_tty_driver);
1410 return -EIO;
1411 } 1570 }
1412 1571
1413 rc = vio_register_driver(&hvcs_vio_driver); 1572 rc = vio_register_driver(&hvcs_vio_driver);
1573 if (rc) {
1574 printk(KERN_ERR "HVCS: can't register vio driver\n");
1575 goto vio_fail;
1576 }
1414 1577
1415 /* 1578 /*
1416 * This needs to be done AFTER the vio_register_driver() call or else 1579 * This needs to be done AFTER the vio_register_driver() call or else
1417 * the kobjects won't be initialized properly. 1580 * the kobjects won't be initialized properly.
1418 */ 1581 */
1419 hvcs_create_driver_attrs(); 1582 rc = driver_create_file(&(hvcs_vio_driver.driver), &driver_attr_rescan);
1583 if (rc) {
1584 printk(KERN_ERR "HVCS: sysfs attr create failed\n");
1585 goto attr_fail;
1586 }
1420 1587
1421 printk(KERN_INFO "HVCS: driver module inserted.\n"); 1588 printk(KERN_INFO "HVCS: driver module inserted.\n");
1422 1589
1590 return 0;
1591
1592attr_fail:
1593 vio_unregister_driver(&hvcs_vio_driver);
1594vio_fail:
1595 kthread_stop(hvcs_task);
1596kthread_fail:
1597 kfree(hvcs_pi_buff);
1598buff_alloc_fail:
1599 tty_unregister_driver(hvcs_tty_driver);
1600register_fail:
1601 hvcs_free_index_list();
1602index_fail:
1603 put_tty_driver(hvcs_tty_driver);
1604 hvcs_tty_driver = NULL;
1423 return rc; 1605 return rc;
1424} 1606}
1425 1607
@@ -1441,7 +1623,7 @@ static void __exit hvcs_module_exit(void)
1441 hvcs_pi_buff = NULL; 1623 hvcs_pi_buff = NULL;
1442 spin_unlock(&hvcs_pi_lock); 1624 spin_unlock(&hvcs_pi_lock);
1443 1625
1444 hvcs_remove_driver_attrs(); 1626 driver_remove_file(&hvcs_vio_driver.driver, &driver_attr_rescan);
1445 1627
1446 vio_unregister_driver(&hvcs_vio_driver); 1628 vio_unregister_driver(&hvcs_vio_driver);
1447 1629
@@ -1456,191 +1638,3 @@ static void __exit hvcs_module_exit(void)
1456 1638
1457module_init(hvcs_module_init); 1639module_init(hvcs_module_init);
1458module_exit(hvcs_module_exit); 1640module_exit(hvcs_module_exit);
1459
1460static inline struct hvcs_struct *from_vio_dev(struct vio_dev *viod)
1461{
1462 return viod->dev.driver_data;
1463}
1464/* The sysfs interface for the driver and devices */
1465
1466static ssize_t hvcs_partner_vtys_show(struct device *dev, struct device_attribute *attr, char *buf)
1467{
1468 struct vio_dev *viod = to_vio_dev(dev);
1469 struct hvcs_struct *hvcsd = from_vio_dev(viod);
1470 unsigned long flags;
1471 int retval;
1472
1473 spin_lock_irqsave(&hvcsd->lock, flags);
1474 retval = sprintf(buf, "%X\n", hvcsd->p_unit_address);
1475 spin_unlock_irqrestore(&hvcsd->lock, flags);
1476 return retval;
1477}
1478static DEVICE_ATTR(partner_vtys, S_IRUGO, hvcs_partner_vtys_show, NULL);
1479
1480static ssize_t hvcs_partner_clcs_show(struct device *dev, struct device_attribute *attr, char *buf)
1481{
1482 struct vio_dev *viod = to_vio_dev(dev);
1483 struct hvcs_struct *hvcsd = from_vio_dev(viod);
1484 unsigned long flags;
1485 int retval;
1486
1487 spin_lock_irqsave(&hvcsd->lock, flags);
1488 retval = sprintf(buf, "%s\n", &hvcsd->p_location_code[0]);
1489 spin_unlock_irqrestore(&hvcsd->lock, flags);
1490 return retval;
1491}
1492static DEVICE_ATTR(partner_clcs, S_IRUGO, hvcs_partner_clcs_show, NULL);
1493
1494static ssize_t hvcs_current_vty_store(struct device *dev, struct device_attribute *attr, const char * buf,
1495 size_t count)
1496{
1497 /*
1498 * Don't need this feature at the present time because firmware doesn't
1499 * yet support multiple partners.
1500 */
1501 printk(KERN_INFO "HVCS: Denied current_vty change: -EPERM.\n");
1502 return -EPERM;
1503}
1504
1505static ssize_t hvcs_current_vty_show(struct device *dev, struct device_attribute *attr, char *buf)
1506{
1507 struct vio_dev *viod = to_vio_dev(dev);
1508 struct hvcs_struct *hvcsd = from_vio_dev(viod);
1509 unsigned long flags;
1510 int retval;
1511
1512 spin_lock_irqsave(&hvcsd->lock, flags);
1513 retval = sprintf(buf, "%s\n", &hvcsd->p_location_code[0]);
1514 spin_unlock_irqrestore(&hvcsd->lock, flags);
1515 return retval;
1516}
1517
1518static DEVICE_ATTR(current_vty,
1519 S_IRUGO | S_IWUSR, hvcs_current_vty_show, hvcs_current_vty_store);
1520
1521static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribute *attr, const char *buf,
1522 size_t count)
1523{
1524 struct vio_dev *viod = to_vio_dev(dev);
1525 struct hvcs_struct *hvcsd = from_vio_dev(viod);
1526 unsigned long flags;
1527
1528 /* writing a '0' to this sysfs entry will result in the disconnect. */
1529 if (simple_strtol(buf, NULL, 0) != 0)
1530 return -EINVAL;
1531
1532 spin_lock_irqsave(&hvcsd->lock, flags);
1533
1534 if (hvcsd->open_count > 0) {
1535 spin_unlock_irqrestore(&hvcsd->lock, flags);
1536 printk(KERN_INFO "HVCS: vterm state unchanged. "
1537 "The hvcs device node is still in use.\n");
1538 return -EPERM;
1539 }
1540
1541 if (hvcsd->connected == 0) {
1542 spin_unlock_irqrestore(&hvcsd->lock, flags);
1543 printk(KERN_INFO "HVCS: vterm state unchanged. The"
1544 " vty-server is not connected to a vty.\n");
1545 return -EPERM;
1546 }
1547
1548 hvcs_partner_free(hvcsd);
1549 printk(KERN_INFO "HVCS: Closed vty-server@%X and"
1550 " partner vty@%X:%d connection.\n",
1551 hvcsd->vdev->unit_address,
1552 hvcsd->p_unit_address,
1553 (uint32_t)hvcsd->p_partition_ID);
1554
1555 spin_unlock_irqrestore(&hvcsd->lock, flags);
1556 return count;
1557}
1558
1559static ssize_t hvcs_vterm_state_show(struct device *dev, struct device_attribute *attr, char *buf)
1560{
1561 struct vio_dev *viod = to_vio_dev(dev);
1562 struct hvcs_struct *hvcsd = from_vio_dev(viod);
1563 unsigned long flags;
1564 int retval;
1565
1566 spin_lock_irqsave(&hvcsd->lock, flags);
1567 retval = sprintf(buf, "%d\n", hvcsd->connected);
1568 spin_unlock_irqrestore(&hvcsd->lock, flags);
1569 return retval;
1570}
1571static DEVICE_ATTR(vterm_state, S_IRUGO | S_IWUSR,
1572 hvcs_vterm_state_show, hvcs_vterm_state_store);
1573
1574static ssize_t hvcs_index_show(struct device *dev, struct device_attribute *attr, char *buf)
1575{
1576 struct vio_dev *viod = to_vio_dev(dev);
1577 struct hvcs_struct *hvcsd = from_vio_dev(viod);
1578 unsigned long flags;
1579 int retval;
1580
1581 spin_lock_irqsave(&hvcsd->lock, flags);
1582 retval = sprintf(buf, "%d\n", hvcsd->index);
1583 spin_unlock_irqrestore(&hvcsd->lock, flags);
1584 return retval;
1585}
1586
1587static DEVICE_ATTR(index, S_IRUGO, hvcs_index_show, NULL);
1588
1589static struct attribute *hvcs_attrs[] = {
1590 &dev_attr_partner_vtys.attr,
1591 &dev_attr_partner_clcs.attr,
1592 &dev_attr_current_vty.attr,
1593 &dev_attr_vterm_state.attr,
1594 &dev_attr_index.attr,
1595 NULL,
1596};
1597
1598static struct attribute_group hvcs_attr_group = {
1599 .attrs = hvcs_attrs,
1600};
1601
1602static void hvcs_create_device_attrs(struct hvcs_struct *hvcsd)
1603{
1604 struct vio_dev *vdev = hvcsd->vdev;
1605 sysfs_create_group(&vdev->dev.kobj, &hvcs_attr_group);
1606}
1607
1608static void hvcs_remove_device_attrs(struct vio_dev *vdev)
1609{
1610 sysfs_remove_group(&vdev->dev.kobj, &hvcs_attr_group);
1611}
1612
1613static ssize_t hvcs_rescan_show(struct device_driver *ddp, char *buf)
1614{
1615 /* A 1 means it is updating, a 0 means it is done updating */
1616 return snprintf(buf, PAGE_SIZE, "%d\n", hvcs_rescan_status);
1617}
1618
1619static ssize_t hvcs_rescan_store(struct device_driver *ddp, const char * buf,
1620 size_t count)
1621{
1622 if ((simple_strtol(buf, NULL, 0) != 1)
1623 && (hvcs_rescan_status != 0))
1624 return -EINVAL;
1625
1626 hvcs_rescan_status = 1;
1627 printk(KERN_INFO "HVCS: rescanning partner info for all"
1628 " vty-servers.\n");
1629 hvcs_rescan_devices_list();
1630 hvcs_rescan_status = 0;
1631 return count;
1632}
1633static DRIVER_ATTR(rescan,
1634 S_IRUGO | S_IWUSR, hvcs_rescan_show, hvcs_rescan_store);
1635
1636static void hvcs_create_driver_attrs(void)
1637{
1638 struct device_driver *driverfs = &(hvcs_vio_driver.driver);
1639 driver_create_file(driverfs, &driver_attr_rescan);
1640}
1641
1642static void hvcs_remove_driver_attrs(void)
1643{
1644 struct device_driver *driverfs = &(hvcs_vio_driver.driver);
1645 driver_remove_file(driverfs, &driver_attr_rescan);
1646}
diff --git a/drivers/char/hvsi.c b/drivers/char/hvsi.c
index 2cf63e7305a3..82a41d5b4ed0 100644
--- a/drivers/char/hvsi.c
+++ b/drivers/char/hvsi.c
@@ -69,7 +69,7 @@
69#define __ALIGNED__ __attribute__((__aligned__(sizeof(long)))) 69#define __ALIGNED__ __attribute__((__aligned__(sizeof(long))))
70 70
71struct hvsi_struct { 71struct hvsi_struct {
72 struct work_struct writer; 72 struct delayed_work writer;
73 struct work_struct handshaker; 73 struct work_struct handshaker;
74 wait_queue_head_t emptyq; /* woken when outbuf is emptied */ 74 wait_queue_head_t emptyq; /* woken when outbuf is emptied */
75 wait_queue_head_t stateq; /* woken when HVSI state changes */ 75 wait_queue_head_t stateq; /* woken when HVSI state changes */
@@ -744,9 +744,10 @@ static int hvsi_handshake(struct hvsi_struct *hp)
744 return 0; 744 return 0;
745} 745}
746 746
747static void hvsi_handshaker(void *arg) 747static void hvsi_handshaker(struct work_struct *work)
748{ 748{
749 struct hvsi_struct *hp = (struct hvsi_struct *)arg; 749 struct hvsi_struct *hp =
750 container_of(work, struct hvsi_struct, handshaker);
750 751
751 if (hvsi_handshake(hp) >= 0) 752 if (hvsi_handshake(hp) >= 0)
752 return; 753 return;
@@ -951,9 +952,10 @@ static void hvsi_push(struct hvsi_struct *hp)
951} 952}
952 953
953/* hvsi_write_worker will keep rescheduling itself until outbuf is empty */ 954/* hvsi_write_worker will keep rescheduling itself until outbuf is empty */
954static void hvsi_write_worker(void *arg) 955static void hvsi_write_worker(struct work_struct *work)
955{ 956{
956 struct hvsi_struct *hp = (struct hvsi_struct *)arg; 957 struct hvsi_struct *hp =
958 container_of(work, struct hvsi_struct, writer.work);
957 unsigned long flags; 959 unsigned long flags;
958#ifdef DEBUG 960#ifdef DEBUG
959 static long start_j = 0; 961 static long start_j = 0;
@@ -1287,8 +1289,8 @@ static int __init hvsi_console_init(void)
1287 } 1289 }
1288 1290
1289 hp = &hvsi_ports[hvsi_count]; 1291 hp = &hvsi_ports[hvsi_count];
1290 INIT_WORK(&hp->writer, hvsi_write_worker, hp); 1292 INIT_DELAYED_WORK(&hp->writer, hvsi_write_worker);
1291 INIT_WORK(&hp->handshaker, hvsi_handshaker, hp); 1293 INIT_WORK(&hp->handshaker, hvsi_handshaker);
1292 init_waitqueue_head(&hp->emptyq); 1294 init_waitqueue_head(&hp->emptyq);
1293 init_waitqueue_head(&hp->stateq); 1295 init_waitqueue_head(&hp->stateq);
1294 spin_lock_init(&hp->lock); 1296 spin_lock_init(&hp->lock);
diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig
index 9f7635f75178..5f3acd8e64b8 100644
--- a/drivers/char/hw_random/Kconfig
+++ b/drivers/char/hw_random/Kconfig
@@ -3,17 +3,20 @@
3# 3#
4 4
5config HW_RANDOM 5config HW_RANDOM
6 bool "Hardware Random Number Generator Core support" 6 tristate "Hardware Random Number Generator Core support"
7 default y 7 default m
8 ---help--- 8 ---help---
9 Hardware Random Number Generator Core infrastructure. 9 Hardware Random Number Generator Core infrastructure.
10 10
11 To compile this driver as a module, choose M here: the
12 module will be called rng-core.
13
11 If unsure, say Y. 14 If unsure, say Y.
12 15
13config HW_RANDOM_INTEL 16config HW_RANDOM_INTEL
14 tristate "Intel HW Random Number Generator support" 17 tristate "Intel HW Random Number Generator support"
15 depends on HW_RANDOM && (X86 || IA64) && PCI 18 depends on HW_RANDOM && (X86 || IA64) && PCI
16 default y 19 default HW_RANDOM
17 ---help--- 20 ---help---
18 This driver provides kernel-side support for the Random Number 21 This driver provides kernel-side support for the Random Number
19 Generator hardware found on Intel i8xx-based motherboards. 22 Generator hardware found on Intel i8xx-based motherboards.
@@ -26,7 +29,7 @@ config HW_RANDOM_INTEL
26config HW_RANDOM_AMD 29config HW_RANDOM_AMD
27 tristate "AMD HW Random Number Generator support" 30 tristate "AMD HW Random Number Generator support"
28 depends on HW_RANDOM && X86 && PCI 31 depends on HW_RANDOM && X86 && PCI
29 default y 32 default HW_RANDOM
30 ---help--- 33 ---help---
31 This driver provides kernel-side support for the Random Number 34 This driver provides kernel-side support for the Random Number
32 Generator hardware found on AMD 76x-based motherboards. 35 Generator hardware found on AMD 76x-based motherboards.
@@ -39,7 +42,7 @@ config HW_RANDOM_AMD
39config HW_RANDOM_GEODE 42config HW_RANDOM_GEODE
40 tristate "AMD Geode HW Random Number Generator support" 43 tristate "AMD Geode HW Random Number Generator support"
41 depends on HW_RANDOM && X86 && PCI 44 depends on HW_RANDOM && X86 && PCI
42 default y 45 default HW_RANDOM
43 ---help--- 46 ---help---
44 This driver provides kernel-side support for the Random Number 47 This driver provides kernel-side support for the Random Number
45 Generator hardware found on the AMD Geode LX. 48 Generator hardware found on the AMD Geode LX.
@@ -52,7 +55,7 @@ config HW_RANDOM_GEODE
52config HW_RANDOM_VIA 55config HW_RANDOM_VIA
53 tristate "VIA HW Random Number Generator support" 56 tristate "VIA HW Random Number Generator support"
54 depends on HW_RANDOM && X86_32 57 depends on HW_RANDOM && X86_32
55 default y 58 default HW_RANDOM
56 ---help--- 59 ---help---
57 This driver provides kernel-side support for the Random Number 60 This driver provides kernel-side support for the Random Number
58 Generator hardware found on VIA based motherboards. 61 Generator hardware found on VIA based motherboards.
@@ -65,7 +68,7 @@ config HW_RANDOM_VIA
65config HW_RANDOM_IXP4XX 68config HW_RANDOM_IXP4XX
66 tristate "Intel IXP4xx NPU HW Random Number Generator support" 69 tristate "Intel IXP4xx NPU HW Random Number Generator support"
67 depends on HW_RANDOM && ARCH_IXP4XX 70 depends on HW_RANDOM && ARCH_IXP4XX
68 default y 71 default HW_RANDOM
69 ---help--- 72 ---help---
70 This driver provides kernel-side support for the Random 73 This driver provides kernel-side support for the Random
71 Number Generator hardware found on the Intel IXP4xx NPU. 74 Number Generator hardware found on the Intel IXP4xx NPU.
@@ -78,7 +81,7 @@ config HW_RANDOM_IXP4XX
78config HW_RANDOM_OMAP 81config HW_RANDOM_OMAP
79 tristate "OMAP Random Number Generator support" 82 tristate "OMAP Random Number Generator support"
80 depends on HW_RANDOM && (ARCH_OMAP16XX || ARCH_OMAP24XX) 83 depends on HW_RANDOM && (ARCH_OMAP16XX || ARCH_OMAP24XX)
81 default y 84 default HW_RANDOM
82 ---help--- 85 ---help---
83 This driver provides kernel-side support for the Random Number 86 This driver provides kernel-side support for the Random Number
84 Generator hardware found on OMAP16xx and OMAP24xx multimedia 87 Generator hardware found on OMAP16xx and OMAP24xx multimedia
diff --git a/drivers/char/hw_random/Makefile b/drivers/char/hw_random/Makefile
index e263ae96f940..c41fa19454e3 100644
--- a/drivers/char/hw_random/Makefile
+++ b/drivers/char/hw_random/Makefile
@@ -2,7 +2,8 @@
2# Makefile for HW Random Number Generator (RNG) device drivers. 2# Makefile for HW Random Number Generator (RNG) device drivers.
3# 3#
4 4
5obj-$(CONFIG_HW_RANDOM) += core.o 5obj-$(CONFIG_HW_RANDOM) += rng-core.o
6rng-core-y := core.o
6obj-$(CONFIG_HW_RANDOM_INTEL) += intel-rng.o 7obj-$(CONFIG_HW_RANDOM_INTEL) += intel-rng.o
7obj-$(CONFIG_HW_RANDOM_AMD) += amd-rng.o 8obj-$(CONFIG_HW_RANDOM_AMD) += amd-rng.o
8obj-$(CONFIG_HW_RANDOM_GEODE) += geode-rng.o 9obj-$(CONFIG_HW_RANDOM_GEODE) += geode-rng.o
diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c
index 154a81d328c1..26a860adcb38 100644
--- a/drivers/char/hw_random/core.c
+++ b/drivers/char/hw_random/core.c
@@ -36,6 +36,7 @@
36#include <linux/module.h> 36#include <linux/module.h>
37#include <linux/kernel.h> 37#include <linux/kernel.h>
38#include <linux/fs.h> 38#include <linux/fs.h>
39#include <linux/sched.h>
39#include <linux/init.h> 40#include <linux/init.h>
40#include <linux/miscdevice.h> 41#include <linux/miscdevice.h>
41#include <linux/delay.h> 42#include <linux/delay.h>
@@ -162,7 +163,8 @@ static struct miscdevice rng_miscdev = {
162}; 163};
163 164
164 165
165static ssize_t hwrng_attr_current_store(struct class_device *class, 166static ssize_t hwrng_attr_current_store(struct device *dev,
167 struct device_attribute *attr,
166 const char *buf, size_t len) 168 const char *buf, size_t len)
167{ 169{
168 int err; 170 int err;
@@ -192,7 +194,8 @@ static ssize_t hwrng_attr_current_store(struct class_device *class,
192 return err ? : len; 194 return err ? : len;
193} 195}
194 196
195static ssize_t hwrng_attr_current_show(struct class_device *class, 197static ssize_t hwrng_attr_current_show(struct device *dev,
198 struct device_attribute *attr,
196 char *buf) 199 char *buf)
197{ 200{
198 int err; 201 int err;
@@ -210,7 +213,8 @@ static ssize_t hwrng_attr_current_show(struct class_device *class,
210 return ret; 213 return ret;
211} 214}
212 215
213static ssize_t hwrng_attr_available_show(struct class_device *class, 216static ssize_t hwrng_attr_available_show(struct device *dev,
217 struct device_attribute *attr,
214 char *buf) 218 char *buf)
215{ 219{
216 int err; 220 int err;
@@ -234,20 +238,18 @@ static ssize_t hwrng_attr_available_show(struct class_device *class,
234 return ret; 238 return ret;
235} 239}
236 240
237static CLASS_DEVICE_ATTR(rng_current, S_IRUGO | S_IWUSR, 241static DEVICE_ATTR(rng_current, S_IRUGO | S_IWUSR,
238 hwrng_attr_current_show, 242 hwrng_attr_current_show,
239 hwrng_attr_current_store); 243 hwrng_attr_current_store);
240static CLASS_DEVICE_ATTR(rng_available, S_IRUGO, 244static DEVICE_ATTR(rng_available, S_IRUGO,
241 hwrng_attr_available_show, 245 hwrng_attr_available_show,
242 NULL); 246 NULL);
243 247
244 248
245static void unregister_miscdev(void) 249static void unregister_miscdev(void)
246{ 250{
247 class_device_remove_file(rng_miscdev.class, 251 device_remove_file(rng_miscdev.this_device, &dev_attr_rng_available);
248 &class_device_attr_rng_available); 252 device_remove_file(rng_miscdev.this_device, &dev_attr_rng_current);
249 class_device_remove_file(rng_miscdev.class,
250 &class_device_attr_rng_current);
251 misc_deregister(&rng_miscdev); 253 misc_deregister(&rng_miscdev);
252} 254}
253 255
@@ -258,20 +260,19 @@ static int register_miscdev(void)
258 err = misc_register(&rng_miscdev); 260 err = misc_register(&rng_miscdev);
259 if (err) 261 if (err)
260 goto out; 262 goto out;
261 err = class_device_create_file(rng_miscdev.class, 263 err = device_create_file(rng_miscdev.this_device,
262 &class_device_attr_rng_current); 264 &dev_attr_rng_current);
263 if (err) 265 if (err)
264 goto err_misc_dereg; 266 goto err_misc_dereg;
265 err = class_device_create_file(rng_miscdev.class, 267 err = device_create_file(rng_miscdev.this_device,
266 &class_device_attr_rng_available); 268 &dev_attr_rng_available);
267 if (err) 269 if (err)
268 goto err_remove_current; 270 goto err_remove_current;
269out: 271out:
270 return err; 272 return err;
271 273
272err_remove_current: 274err_remove_current:
273 class_device_remove_file(rng_miscdev.class, 275 device_remove_file(rng_miscdev.this_device, &dev_attr_rng_current);
274 &class_device_attr_rng_current);
275err_misc_dereg: 276err_misc_dereg:
276 misc_deregister(&rng_miscdev); 277 misc_deregister(&rng_miscdev);
277 goto out; 278 goto out;
diff --git a/drivers/char/ip2/i2cmd.h b/drivers/char/ip2/i2cmd.h
index baa4e721b758..29277ec6b8ed 100644
--- a/drivers/char/ip2/i2cmd.h
+++ b/drivers/char/ip2/i2cmd.h
@@ -367,11 +367,6 @@ static UCHAR cc02[];
367#define CSE_NULL 3 // Replace with a null 367#define CSE_NULL 3 // Replace with a null
368#define CSE_MARK 4 // Replace with a 3-character sequence (as Unix) 368#define CSE_MARK 4 // Replace with a 3-character sequence (as Unix)
369 369
370#define CMD_SET_REPLACEMENT(arg,ch) \
371 (((cmdSyntaxPtr)(ct36a))->cmd[1] = (arg), \
372 (((cmdSyntaxPtr)(ct36a))->cmd[2] = (ch), \
373 (cmdSyntaxPtr)(ct36a))
374
375#define CSE_REPLACE 0x8 // Replace the errored character with the 370#define CSE_REPLACE 0x8 // Replace the errored character with the
376 // replacement character defined here 371 // replacement character defined here
377 372
diff --git a/drivers/char/ip2/i2lib.c b/drivers/char/ip2/i2lib.c
index 54d93f0345e8..78045767ec33 100644
--- a/drivers/char/ip2/i2lib.c
+++ b/drivers/char/ip2/i2lib.c
@@ -84,8 +84,8 @@ static void iiSendPendingMail(i2eBordStrPtr);
84static void serviceOutgoingFifo(i2eBordStrPtr); 84static void serviceOutgoingFifo(i2eBordStrPtr);
85 85
86// Functions defined in ip2.c as part of interrupt handling 86// Functions defined in ip2.c as part of interrupt handling
87static void do_input(void *); 87static void do_input(struct work_struct *);
88static void do_status(void *); 88static void do_status(struct work_struct *);
89 89
90//*************** 90//***************
91//* Debug Data * 91//* Debug Data *
@@ -331,8 +331,8 @@ i2InitChannels ( i2eBordStrPtr pB, int nChannels, i2ChanStrPtr pCh)
331 pCh->ClosingWaitTime = 30*HZ; 331 pCh->ClosingWaitTime = 30*HZ;
332 332
333 // Initialize task queue objects 333 // Initialize task queue objects
334 INIT_WORK(&pCh->tqueue_input, do_input, pCh); 334 INIT_WORK(&pCh->tqueue_input, do_input);
335 INIT_WORK(&pCh->tqueue_status, do_status, pCh); 335 INIT_WORK(&pCh->tqueue_status, do_status);
336 336
337#ifdef IP2DEBUG_TRACE 337#ifdef IP2DEBUG_TRACE
338 pCh->trace = ip2trace; 338 pCh->trace = ip2trace;
@@ -1016,7 +1016,6 @@ i2Output(i2ChanStrPtr pCh, const char *pSource, int count)
1016 unsigned short channel; 1016 unsigned short channel;
1017 unsigned short stuffIndex; 1017 unsigned short stuffIndex;
1018 unsigned long flags; 1018 unsigned long flags;
1019 int rc = 0;
1020 1019
1021 int bailout = 10; 1020 int bailout = 10;
1022 1021
@@ -1573,7 +1572,7 @@ i2StripFifo(i2eBordStrPtr pB)
1573#ifdef USE_IQ 1572#ifdef USE_IQ
1574 schedule_work(&pCh->tqueue_input); 1573 schedule_work(&pCh->tqueue_input);
1575#else 1574#else
1576 do_input(pCh); 1575 do_input(&pCh->tqueue_input);
1577#endif 1576#endif
1578 1577
1579 // Note we do not need to maintain any flow-control credits at this 1578 // Note we do not need to maintain any flow-control credits at this
@@ -1810,7 +1809,7 @@ i2StripFifo(i2eBordStrPtr pB)
1810#ifdef USE_IQ 1809#ifdef USE_IQ
1811 schedule_work(&pCh->tqueue_status); 1810 schedule_work(&pCh->tqueue_status);
1812#else 1811#else
1813 do_status(pCh); 1812 do_status(&pCh->tqueue_status);
1814#endif 1813#endif
1815 } 1814 }
1816 } 1815 }
diff --git a/drivers/char/ip2/ip2main.c b/drivers/char/ip2/ip2main.c
index a3f32d46d2f8..cda2459c1d60 100644
--- a/drivers/char/ip2/ip2main.c
+++ b/drivers/char/ip2/ip2main.c
@@ -189,12 +189,12 @@ static int ip2_tiocmset(struct tty_struct *tty, struct file *file,
189 unsigned int set, unsigned int clear); 189 unsigned int set, unsigned int clear);
190 190
191static void set_irq(int, int); 191static void set_irq(int, int);
192static void ip2_interrupt_bh(i2eBordStrPtr pB); 192static void ip2_interrupt_bh(struct work_struct *work);
193static irqreturn_t ip2_interrupt(int irq, void *dev_id); 193static irqreturn_t ip2_interrupt(int irq, void *dev_id);
194static void ip2_poll(unsigned long arg); 194static void ip2_poll(unsigned long arg);
195static inline void service_all_boards(void); 195static inline void service_all_boards(void);
196static void do_input(void *p); 196static void do_input(struct work_struct *);
197static void do_status(void *p); 197static void do_status(struct work_struct *);
198 198
199static void ip2_wait_until_sent(PTTY,int); 199static void ip2_wait_until_sent(PTTY,int);
200 200
@@ -918,7 +918,7 @@ ip2_init_board( int boardnum )
918 pCh++; 918 pCh++;
919 } 919 }
920ex_exit: 920ex_exit:
921 INIT_WORK(&pB->tqueue_interrupt, (void(*)(void*)) ip2_interrupt_bh, pB); 921 INIT_WORK(&pB->tqueue_interrupt, ip2_interrupt_bh);
922 return; 922 return;
923 923
924err_release_region: 924err_release_region:
@@ -1125,8 +1125,8 @@ service_all_boards(void)
1125 1125
1126 1126
1127/******************************************************************************/ 1127/******************************************************************************/
1128/* Function: ip2_interrupt_bh(pB) */ 1128/* Function: ip2_interrupt_bh(work) */
1129/* Parameters: pB - pointer to the board structure */ 1129/* Parameters: work - pointer to the board structure */
1130/* Returns: Nothing */ 1130/* Returns: Nothing */
1131/* */ 1131/* */
1132/* Description: */ 1132/* Description: */
@@ -1135,8 +1135,9 @@ service_all_boards(void)
1135/* */ 1135/* */
1136/******************************************************************************/ 1136/******************************************************************************/
1137static void 1137static void
1138ip2_interrupt_bh(i2eBordStrPtr pB) 1138ip2_interrupt_bh(struct work_struct *work)
1139{ 1139{
1140 i2eBordStrPtr pB = container_of(work, i2eBordStr, tqueue_interrupt);
1140// pB better well be set or we have a problem! We can only get 1141// pB better well be set or we have a problem! We can only get
1141// here from the IMMEDIATE queue. Here, we process the boards. 1142// here from the IMMEDIATE queue. Here, we process the boards.
1142// Checking pB doesn't cost much and it saves us from the sanity checkers. 1143// Checking pB doesn't cost much and it saves us from the sanity checkers.
@@ -1245,9 +1246,9 @@ ip2_poll(unsigned long arg)
1245 ip2trace (ITRC_NO_PORT, ITRC_INTR, ITRC_RETURN, 0 ); 1246 ip2trace (ITRC_NO_PORT, ITRC_INTR, ITRC_RETURN, 0 );
1246} 1247}
1247 1248
1248static void do_input(void *p) 1249static void do_input(struct work_struct *work)
1249{ 1250{
1250 i2ChanStrPtr pCh = p; 1251 i2ChanStrPtr pCh = container_of(work, i2ChanStr, tqueue_input);
1251 unsigned long flags; 1252 unsigned long flags;
1252 1253
1253 ip2trace(CHANN, ITRC_INPUT, 21, 0 ); 1254 ip2trace(CHANN, ITRC_INPUT, 21, 0 );
@@ -1279,9 +1280,9 @@ static inline void isig(int sig, struct tty_struct *tty, int flush)
1279 } 1280 }
1280} 1281}
1281 1282
1282static void do_status(void *p) 1283static void do_status(struct work_struct *work)
1283{ 1284{
1284 i2ChanStrPtr pCh = p; 1285 i2ChanStrPtr pCh = container_of(work, i2ChanStr, tqueue_status);
1285 int status; 1286 int status;
1286 1287
1287 status = i2GetStatus( pCh, (I2_BRK|I2_PAR|I2_FRA|I2_OVR) ); 1288 status = i2GetStatus( pCh, (I2_BRK|I2_PAR|I2_FRA|I2_OVR) );
diff --git a/drivers/char/ipmi/ipmi_bt_sm.c b/drivers/char/ipmi/ipmi_bt_sm.c
index 0030cd8e2e95..6c59baa887a8 100644
--- a/drivers/char/ipmi/ipmi_bt_sm.c
+++ b/drivers/char/ipmi/ipmi_bt_sm.c
@@ -33,11 +33,13 @@
33#include <linux/ipmi_msgdefs.h> /* for completion codes */ 33#include <linux/ipmi_msgdefs.h> /* for completion codes */
34#include "ipmi_si_sm.h" 34#include "ipmi_si_sm.h"
35 35
36static int bt_debug = 0x00; /* Production value 0, see following flags */ 36#define BT_DEBUG_OFF 0 /* Used in production */
37#define BT_DEBUG_ENABLE 1 /* Generic messages */
38#define BT_DEBUG_MSG 2 /* Prints all request/response buffers */
39#define BT_DEBUG_STATES 4 /* Verbose look at state changes */
40
41static int bt_debug = BT_DEBUG_OFF;
37 42
38#define BT_DEBUG_ENABLE 1
39#define BT_DEBUG_MSG 2
40#define BT_DEBUG_STATES 4
41module_param(bt_debug, int, 0644); 43module_param(bt_debug, int, 0644);
42MODULE_PARM_DESC(bt_debug, "debug bitmask, 1=enable, 2=messages, 4=states"); 44MODULE_PARM_DESC(bt_debug, "debug bitmask, 1=enable, 2=messages, 4=states");
43 45
@@ -47,38 +49,54 @@ MODULE_PARM_DESC(bt_debug, "debug bitmask, 1=enable, 2=messages, 4=states");
47 Since the Open IPMI architecture is single-message oriented at this 49 Since the Open IPMI architecture is single-message oriented at this
48 stage, the queue depth of BT is of no concern. */ 50 stage, the queue depth of BT is of no concern. */
49 51
50#define BT_NORMAL_TIMEOUT 5000000 /* seconds in microseconds */ 52#define BT_NORMAL_TIMEOUT 5 /* seconds */
51#define BT_RETRY_LIMIT 2 53#define BT_NORMAL_RETRY_LIMIT 2
52#define BT_RESET_DELAY 6000000 /* 6 seconds after warm reset */ 54#define BT_RESET_DELAY 6 /* seconds after warm reset */
55
56/* States are written in chronological order and usually cover
57 multiple rows of the state table discussion in the IPMI spec. */
53 58
54enum bt_states { 59enum bt_states {
55 BT_STATE_IDLE, 60 BT_STATE_IDLE = 0, /* Order is critical in this list */
56 BT_STATE_XACTION_START, 61 BT_STATE_XACTION_START,
57 BT_STATE_WRITE_BYTES, 62 BT_STATE_WRITE_BYTES,
58 BT_STATE_WRITE_END,
59 BT_STATE_WRITE_CONSUME, 63 BT_STATE_WRITE_CONSUME,
60 BT_STATE_B2H_WAIT, 64 BT_STATE_READ_WAIT,
61 BT_STATE_READ_END, 65 BT_STATE_CLEAR_B2H,
62 BT_STATE_RESET1, /* These must come last */ 66 BT_STATE_READ_BYTES,
67 BT_STATE_RESET1, /* These must come last */
63 BT_STATE_RESET2, 68 BT_STATE_RESET2,
64 BT_STATE_RESET3, 69 BT_STATE_RESET3,
65 BT_STATE_RESTART, 70 BT_STATE_RESTART,
66 BT_STATE_HOSED 71 BT_STATE_PRINTME,
72 BT_STATE_CAPABILITIES_BEGIN,
73 BT_STATE_CAPABILITIES_END,
74 BT_STATE_LONG_BUSY /* BT doesn't get hosed :-) */
67}; 75};
68 76
77/* Macros seen at the end of state "case" blocks. They help with legibility
78 and debugging. */
79
80#define BT_STATE_CHANGE(X,Y) { bt->state = X; return Y; }
81
82#define BT_SI_SM_RETURN(Y) { last_printed = BT_STATE_PRINTME; return Y; }
83
69struct si_sm_data { 84struct si_sm_data {
70 enum bt_states state; 85 enum bt_states state;
71 enum bt_states last_state; /* assist printing and resets */
72 unsigned char seq; /* BT sequence number */ 86 unsigned char seq; /* BT sequence number */
73 struct si_sm_io *io; 87 struct si_sm_io *io;
74 unsigned char write_data[IPMI_MAX_MSG_LENGTH]; 88 unsigned char write_data[IPMI_MAX_MSG_LENGTH];
75 int write_count; 89 int write_count;
76 unsigned char read_data[IPMI_MAX_MSG_LENGTH]; 90 unsigned char read_data[IPMI_MAX_MSG_LENGTH];
77 int read_count; 91 int read_count;
78 int truncated; 92 int truncated;
79 long timeout; 93 long timeout; /* microseconds countdown */
80 unsigned int error_retries; /* end of "common" fields */ 94 int error_retries; /* end of "common" fields */
81 int nonzero_status; /* hung BMCs stay all 0 */ 95 int nonzero_status; /* hung BMCs stay all 0 */
96 enum bt_states complete; /* to divert the state machine */
97 int BT_CAP_outreqs;
98 long BT_CAP_req2rsp;
99 int BT_CAP_retries; /* Recommended retries */
82}; 100};
83 101
84#define BT_CLR_WR_PTR 0x01 /* See IPMI 1.5 table 11.6.4 */ 102#define BT_CLR_WR_PTR 0x01 /* See IPMI 1.5 table 11.6.4 */
@@ -111,86 +129,118 @@ struct si_sm_data {
111static char *state2txt(unsigned char state) 129static char *state2txt(unsigned char state)
112{ 130{
113 switch (state) { 131 switch (state) {
114 case BT_STATE_IDLE: return("IDLE"); 132 case BT_STATE_IDLE: return("IDLE");
115 case BT_STATE_XACTION_START: return("XACTION"); 133 case BT_STATE_XACTION_START: return("XACTION");
116 case BT_STATE_WRITE_BYTES: return("WR_BYTES"); 134 case BT_STATE_WRITE_BYTES: return("WR_BYTES");
117 case BT_STATE_WRITE_END: return("WR_END"); 135 case BT_STATE_WRITE_CONSUME: return("WR_CONSUME");
118 case BT_STATE_WRITE_CONSUME: return("WR_CONSUME"); 136 case BT_STATE_READ_WAIT: return("RD_WAIT");
119 case BT_STATE_B2H_WAIT: return("B2H_WAIT"); 137 case BT_STATE_CLEAR_B2H: return("CLEAR_B2H");
120 case BT_STATE_READ_END: return("RD_END"); 138 case BT_STATE_READ_BYTES: return("RD_BYTES");
121 case BT_STATE_RESET1: return("RESET1"); 139 case BT_STATE_RESET1: return("RESET1");
122 case BT_STATE_RESET2: return("RESET2"); 140 case BT_STATE_RESET2: return("RESET2");
123 case BT_STATE_RESET3: return("RESET3"); 141 case BT_STATE_RESET3: return("RESET3");
124 case BT_STATE_RESTART: return("RESTART"); 142 case BT_STATE_RESTART: return("RESTART");
125 case BT_STATE_HOSED: return("HOSED"); 143 case BT_STATE_LONG_BUSY: return("LONG_BUSY");
144 case BT_STATE_CAPABILITIES_BEGIN: return("CAP_BEGIN");
145 case BT_STATE_CAPABILITIES_END: return("CAP_END");
126 } 146 }
127 return("BAD STATE"); 147 return("BAD STATE");
128} 148}
129#define STATE2TXT state2txt(bt->state) 149#define STATE2TXT state2txt(bt->state)
130 150
131static char *status2txt(unsigned char status, char *buf) 151static char *status2txt(unsigned char status)
132{ 152{
153 /*
154 * This cannot be called by two threads at the same time and
155 * the buffer is always consumed immediately, so the static is
156 * safe to use.
157 */
158 static char buf[40];
159
133 strcpy(buf, "[ "); 160 strcpy(buf, "[ ");
134 if (status & BT_B_BUSY) strcat(buf, "B_BUSY "); 161 if (status & BT_B_BUSY)
135 if (status & BT_H_BUSY) strcat(buf, "H_BUSY "); 162 strcat(buf, "B_BUSY ");
136 if (status & BT_OEM0) strcat(buf, "OEM0 "); 163 if (status & BT_H_BUSY)
137 if (status & BT_SMS_ATN) strcat(buf, "SMS "); 164 strcat(buf, "H_BUSY ");
138 if (status & BT_B2H_ATN) strcat(buf, "B2H "); 165 if (status & BT_OEM0)
139 if (status & BT_H2B_ATN) strcat(buf, "H2B "); 166 strcat(buf, "OEM0 ");
167 if (status & BT_SMS_ATN)
168 strcat(buf, "SMS ");
169 if (status & BT_B2H_ATN)
170 strcat(buf, "B2H ");
171 if (status & BT_H2B_ATN)
172 strcat(buf, "H2B ");
140 strcat(buf, "]"); 173 strcat(buf, "]");
141 return buf; 174 return buf;
142} 175}
143#define STATUS2TXT(buf) status2txt(status, buf) 176#define STATUS2TXT status2txt(status)
177
178/* called externally at insmod time, and internally on cleanup */
144 179
145/* This will be called from within this module on a hosed condition */
146#define FIRST_SEQ 0
147static unsigned int bt_init_data(struct si_sm_data *bt, struct si_sm_io *io) 180static unsigned int bt_init_data(struct si_sm_data *bt, struct si_sm_io *io)
148{ 181{
149 bt->state = BT_STATE_IDLE; 182 memset(bt, 0, sizeof(struct si_sm_data));
150 bt->last_state = BT_STATE_IDLE; 183 if (bt->io != io) { /* external: one-time only things */
151 bt->seq = FIRST_SEQ; 184 bt->io = io;
152 bt->io = io; 185 bt->seq = 0;
153 bt->write_count = 0; 186 }
154 bt->read_count = 0; 187 bt->state = BT_STATE_IDLE; /* start here */
155 bt->error_retries = 0; 188 bt->complete = BT_STATE_IDLE; /* end here */
156 bt->nonzero_status = 0; 189 bt->BT_CAP_req2rsp = BT_NORMAL_TIMEOUT * 1000000;
157 bt->truncated = 0; 190 bt->BT_CAP_retries = BT_NORMAL_RETRY_LIMIT;
158 bt->timeout = BT_NORMAL_TIMEOUT; 191 /* BT_CAP_outreqs == zero is a flag to read BT Capabilities */
159 return 3; /* We claim 3 bytes of space; ought to check SPMI table */ 192 return 3; /* We claim 3 bytes of space; ought to check SPMI table */
160} 193}
161 194
195/* Jam a completion code (probably an error) into a response */
196
197static void force_result(struct si_sm_data *bt, unsigned char completion_code)
198{
199 bt->read_data[0] = 4; /* # following bytes */
200 bt->read_data[1] = bt->write_data[1] | 4; /* Odd NetFn/LUN */
201 bt->read_data[2] = bt->write_data[2]; /* seq (ignored) */
202 bt->read_data[3] = bt->write_data[3]; /* Command */
203 bt->read_data[4] = completion_code;
204 bt->read_count = 5;
205}
206
207/* The upper state machine starts here */
208
162static int bt_start_transaction(struct si_sm_data *bt, 209static int bt_start_transaction(struct si_sm_data *bt,
163 unsigned char *data, 210 unsigned char *data,
164 unsigned int size) 211 unsigned int size)
165{ 212{
166 unsigned int i; 213 unsigned int i;
167 214
168 if ((size < 2) || (size > (IPMI_MAX_MSG_LENGTH - 2))) 215 if (size < 2)
169 return -1; 216 return IPMI_REQ_LEN_INVALID_ERR;
217 if (size > IPMI_MAX_MSG_LENGTH)
218 return IPMI_REQ_LEN_EXCEEDED_ERR;
170 219
171 if ((bt->state != BT_STATE_IDLE) && (bt->state != BT_STATE_HOSED)) 220 if (bt->state == BT_STATE_LONG_BUSY)
172 return -2; 221 return IPMI_NODE_BUSY_ERR;
222
223 if (bt->state != BT_STATE_IDLE)
224 return IPMI_NOT_IN_MY_STATE_ERR;
173 225
174 if (bt_debug & BT_DEBUG_MSG) { 226 if (bt_debug & BT_DEBUG_MSG) {
175 printk(KERN_WARNING "+++++++++++++++++++++++++++++++++++++\n"); 227 printk(KERN_WARNING "BT: +++++++++++++++++ New command\n");
176 printk(KERN_WARNING "BT: write seq=0x%02X:", bt->seq); 228 printk(KERN_WARNING "BT: NetFn/LUN CMD [%d data]:", size - 2);
177 for (i = 0; i < size; i ++) 229 for (i = 0; i < size; i ++)
178 printk (" %02x", data[i]); 230 printk (" %02x", data[i]);
179 printk("\n"); 231 printk("\n");
180 } 232 }
181 bt->write_data[0] = size + 1; /* all data plus seq byte */ 233 bt->write_data[0] = size + 1; /* all data plus seq byte */
182 bt->write_data[1] = *data; /* NetFn/LUN */ 234 bt->write_data[1] = *data; /* NetFn/LUN */
183 bt->write_data[2] = bt->seq; 235 bt->write_data[2] = bt->seq++;
184 memcpy(bt->write_data + 3, data + 1, size - 1); 236 memcpy(bt->write_data + 3, data + 1, size - 1);
185 bt->write_count = size + 2; 237 bt->write_count = size + 2;
186
187 bt->error_retries = 0; 238 bt->error_retries = 0;
188 bt->nonzero_status = 0; 239 bt->nonzero_status = 0;
189 bt->read_count = 0;
190 bt->truncated = 0; 240 bt->truncated = 0;
191 bt->state = BT_STATE_XACTION_START; 241 bt->state = BT_STATE_XACTION_START;
192 bt->last_state = BT_STATE_IDLE; 242 bt->timeout = bt->BT_CAP_req2rsp;
193 bt->timeout = BT_NORMAL_TIMEOUT; 243 force_result(bt, IPMI_ERR_UNSPECIFIED);
194 return 0; 244 return 0;
195} 245}
196 246
@@ -198,38 +248,30 @@ static int bt_start_transaction(struct si_sm_data *bt,
198 it calls this. Strip out the length and seq bytes. */ 248 it calls this. Strip out the length and seq bytes. */
199 249
200static int bt_get_result(struct si_sm_data *bt, 250static int bt_get_result(struct si_sm_data *bt,
201 unsigned char *data, 251 unsigned char *data,
202 unsigned int length) 252 unsigned int length)
203{ 253{
204 int i, msg_len; 254 int i, msg_len;
205 255
206 msg_len = bt->read_count - 2; /* account for length & seq */ 256 msg_len = bt->read_count - 2; /* account for length & seq */
207 /* Always NetFn, Cmd, cCode */
208 if (msg_len < 3 || msg_len > IPMI_MAX_MSG_LENGTH) { 257 if (msg_len < 3 || msg_len > IPMI_MAX_MSG_LENGTH) {
209 printk(KERN_DEBUG "BT results: bad msg_len = %d\n", msg_len); 258 force_result(bt, IPMI_ERR_UNSPECIFIED);
210 data[0] = bt->write_data[1] | 0x4; /* Kludge a response */
211 data[1] = bt->write_data[3];
212 data[2] = IPMI_ERR_UNSPECIFIED;
213 msg_len = 3; 259 msg_len = 3;
214 } else { 260 }
215 data[0] = bt->read_data[1]; 261 data[0] = bt->read_data[1];
216 data[1] = bt->read_data[3]; 262 data[1] = bt->read_data[3];
217 if (length < msg_len) 263 if (length < msg_len || bt->truncated) {
218 bt->truncated = 1; 264 data[2] = IPMI_ERR_MSG_TRUNCATED;
219 if (bt->truncated) { /* can be set in read_all_bytes() */ 265 msg_len = 3;
220 data[2] = IPMI_ERR_MSG_TRUNCATED; 266 } else
221 msg_len = 3; 267 memcpy(data + 2, bt->read_data + 4, msg_len - 2);
222 } else
223 memcpy(data + 2, bt->read_data + 4, msg_len - 2);
224 268
225 if (bt_debug & BT_DEBUG_MSG) { 269 if (bt_debug & BT_DEBUG_MSG) {
226 printk (KERN_WARNING "BT: res (raw)"); 270 printk (KERN_WARNING "BT: result %d bytes:", msg_len);
227 for (i = 0; i < msg_len; i++) 271 for (i = 0; i < msg_len; i++)
228 printk(" %02x", data[i]); 272 printk(" %02x", data[i]);
229 printk ("\n"); 273 printk ("\n");
230 }
231 } 274 }
232 bt->read_count = 0; /* paranoia */
233 return msg_len; 275 return msg_len;
234} 276}
235 277
@@ -238,22 +280,40 @@ static int bt_get_result(struct si_sm_data *bt,
238 280
239static void reset_flags(struct si_sm_data *bt) 281static void reset_flags(struct si_sm_data *bt)
240{ 282{
283 if (bt_debug)
284 printk(KERN_WARNING "IPMI BT: flag reset %s\n",
285 status2txt(BT_STATUS));
241 if (BT_STATUS & BT_H_BUSY) 286 if (BT_STATUS & BT_H_BUSY)
242 BT_CONTROL(BT_H_BUSY); 287 BT_CONTROL(BT_H_BUSY); /* force clear */
243 if (BT_STATUS & BT_B_BUSY) 288 BT_CONTROL(BT_CLR_WR_PTR); /* always reset */
244 BT_CONTROL(BT_B_BUSY); 289 BT_CONTROL(BT_SMS_ATN); /* always clear */
245 BT_CONTROL(BT_CLR_WR_PTR); 290 BT_INTMASK_W(BT_BMC_HWRST);
246 BT_CONTROL(BT_SMS_ATN); 291}
247 292
248 if (BT_STATUS & BT_B2H_ATN) { 293/* Get rid of an unwanted/stale response. This should only be needed for
249 int i; 294 BMCs that support multiple outstanding requests. */
250 BT_CONTROL(BT_H_BUSY); 295
251 BT_CONTROL(BT_B2H_ATN); 296static void drain_BMC2HOST(struct si_sm_data *bt)
252 BT_CONTROL(BT_CLR_RD_PTR); 297{
253 for (i = 0; i < IPMI_MAX_MSG_LENGTH + 2; i++) 298 int i, size;
254 BMC2HOST; 299
255 BT_CONTROL(BT_H_BUSY); 300 if (!(BT_STATUS & BT_B2H_ATN)) /* Not signalling a response */
256 } 301 return;
302
303 BT_CONTROL(BT_H_BUSY); /* now set */
304 BT_CONTROL(BT_B2H_ATN); /* always clear */
305 BT_STATUS; /* pause */
306 BT_CONTROL(BT_B2H_ATN); /* some BMCs are stubborn */
307 BT_CONTROL(BT_CLR_RD_PTR); /* always reset */
308 if (bt_debug)
309 printk(KERN_WARNING "IPMI BT: stale response %s; ",
310 status2txt(BT_STATUS));
311 size = BMC2HOST;
312 for (i = 0; i < size ; i++)
313 BMC2HOST;
314 BT_CONTROL(BT_H_BUSY); /* now clear */
315 if (bt_debug)
316 printk("drained %d bytes\n", size + 1);
257} 317}
258 318
259static inline void write_all_bytes(struct si_sm_data *bt) 319static inline void write_all_bytes(struct si_sm_data *bt)
@@ -261,201 +321,256 @@ static inline void write_all_bytes(struct si_sm_data *bt)
261 int i; 321 int i;
262 322
263 if (bt_debug & BT_DEBUG_MSG) { 323 if (bt_debug & BT_DEBUG_MSG) {
264 printk(KERN_WARNING "BT: write %d bytes seq=0x%02X", 324 printk(KERN_WARNING "BT: write %d bytes seq=0x%02X",
265 bt->write_count, bt->seq); 325 bt->write_count, bt->seq);
266 for (i = 0; i < bt->write_count; i++) 326 for (i = 0; i < bt->write_count; i++)
267 printk (" %02x", bt->write_data[i]); 327 printk (" %02x", bt->write_data[i]);
268 printk ("\n"); 328 printk ("\n");
269 } 329 }
270 for (i = 0; i < bt->write_count; i++) 330 for (i = 0; i < bt->write_count; i++)
271 HOST2BMC(bt->write_data[i]); 331 HOST2BMC(bt->write_data[i]);
272} 332}
273 333
274static inline int read_all_bytes(struct si_sm_data *bt) 334static inline int read_all_bytes(struct si_sm_data *bt)
275{ 335{
276 unsigned char i; 336 unsigned char i;
277 337
338 /* length is "framing info", minimum = 4: NetFn, Seq, Cmd, cCode.
339 Keep layout of first four bytes aligned with write_data[] */
340
278 bt->read_data[0] = BMC2HOST; 341 bt->read_data[0] = BMC2HOST;
279 bt->read_count = bt->read_data[0]; 342 bt->read_count = bt->read_data[0];
280 if (bt_debug & BT_DEBUG_MSG)
281 printk(KERN_WARNING "BT: read %d bytes:", bt->read_count);
282 343
283 /* minimum: length, NetFn, Seq, Cmd, cCode == 5 total, or 4 more
284 following the length byte. */
285 if (bt->read_count < 4 || bt->read_count >= IPMI_MAX_MSG_LENGTH) { 344 if (bt->read_count < 4 || bt->read_count >= IPMI_MAX_MSG_LENGTH) {
286 if (bt_debug & BT_DEBUG_MSG) 345 if (bt_debug & BT_DEBUG_MSG)
287 printk("bad length %d\n", bt->read_count); 346 printk(KERN_WARNING "BT: bad raw rsp len=%d\n",
347 bt->read_count);
288 bt->truncated = 1; 348 bt->truncated = 1;
289 return 1; /* let next XACTION START clean it up */ 349 return 1; /* let next XACTION START clean it up */
290 } 350 }
291 for (i = 1; i <= bt->read_count; i++) 351 for (i = 1; i <= bt->read_count; i++)
292 bt->read_data[i] = BMC2HOST; 352 bt->read_data[i] = BMC2HOST;
293 bt->read_count++; /* account for the length byte */ 353 bt->read_count++; /* Account internally for length byte */
294 354
295 if (bt_debug & BT_DEBUG_MSG) { 355 if (bt_debug & BT_DEBUG_MSG) {
296 for (i = 0; i < bt->read_count; i++) 356 int max = bt->read_count;
357
358 printk(KERN_WARNING "BT: got %d bytes seq=0x%02X",
359 max, bt->read_data[2]);
360 if (max > 16)
361 max = 16;
362 for (i = 0; i < max; i++)
297 printk (" %02x", bt->read_data[i]); 363 printk (" %02x", bt->read_data[i]);
298 printk ("\n"); 364 printk ("%s\n", bt->read_count == max ? "" : " ...");
299 } 365 }
300 if (bt->seq != bt->write_data[2]) /* idiot check */
301 printk(KERN_DEBUG "BT: internal error: sequence mismatch\n");
302 366
303 /* per the spec, the (NetFn, Seq, Cmd) tuples should match */ 367 /* per the spec, the (NetFn[1], Seq[2], Cmd[3]) tuples must match */
304 if ((bt->read_data[3] == bt->write_data[3]) && /* Cmd */ 368 if ((bt->read_data[3] == bt->write_data[3]) &&
305 (bt->read_data[2] == bt->write_data[2]) && /* Sequence */ 369 (bt->read_data[2] == bt->write_data[2]) &&
306 ((bt->read_data[1] & 0xF8) == (bt->write_data[1] & 0xF8))) 370 ((bt->read_data[1] & 0xF8) == (bt->write_data[1] & 0xF8)))
307 return 1; 371 return 1;
308 372
309 if (bt_debug & BT_DEBUG_MSG) 373 if (bt_debug & BT_DEBUG_MSG)
310 printk(KERN_WARNING "BT: bad packet: " 374 printk(KERN_WARNING "IPMI BT: bad packet: "
311 "want 0x(%02X, %02X, %02X) got (%02X, %02X, %02X)\n", 375 "want 0x(%02X, %02X, %02X) got (%02X, %02X, %02X)\n",
312 bt->write_data[1], bt->write_data[2], bt->write_data[3], 376 bt->write_data[1] | 0x04, bt->write_data[2], bt->write_data[3],
313 bt->read_data[1], bt->read_data[2], bt->read_data[3]); 377 bt->read_data[1], bt->read_data[2], bt->read_data[3]);
314 return 0; 378 return 0;
315} 379}
316 380
317/* Modifies bt->state appropriately, need to get into the bt_event() switch */ 381/* Restart if retries are left, or return an error completion code */
318 382
319static void error_recovery(struct si_sm_data *bt, char *reason) 383static enum si_sm_result error_recovery(struct si_sm_data *bt,
384 unsigned char status,
385 unsigned char cCode)
320{ 386{
321 unsigned char status; 387 char *reason;
322 char buf[40]; /* For getting status */
323 388
324 bt->timeout = BT_NORMAL_TIMEOUT; /* various places want to retry */ 389 bt->timeout = bt->BT_CAP_req2rsp;
325 390
326 status = BT_STATUS; 391 switch (cCode) {
327 printk(KERN_DEBUG "BT: %s in %s %s\n", reason, STATE2TXT, 392 case IPMI_TIMEOUT_ERR:
328 STATUS2TXT(buf)); 393 reason = "timeout";
394 break;
395 default:
396 reason = "internal error";
397 break;
398 }
399
400 printk(KERN_WARNING "IPMI BT: %s in %s %s ", /* open-ended line */
401 reason, STATE2TXT, STATUS2TXT);
329 402
403 /* Per the IPMI spec, retries are based on the sequence number
404 known only to this module, so manage a restart here. */
330 (bt->error_retries)++; 405 (bt->error_retries)++;
331 if (bt->error_retries > BT_RETRY_LIMIT) { 406 if (bt->error_retries < bt->BT_CAP_retries) {
332 printk(KERN_DEBUG "retry limit (%d) exceeded\n", BT_RETRY_LIMIT); 407 printk("%d retries left\n",
333 bt->state = BT_STATE_HOSED; 408 bt->BT_CAP_retries - bt->error_retries);
334 if (!bt->nonzero_status) 409 bt->state = BT_STATE_RESTART;
335 printk(KERN_ERR "IPMI: BT stuck, try power cycle\n"); 410 return SI_SM_CALL_WITHOUT_DELAY;
336 else if (bt->error_retries <= BT_RETRY_LIMIT + 1) {
337 printk(KERN_DEBUG "IPMI: BT reset (takes 5 secs)\n");
338 bt->state = BT_STATE_RESET1;
339 }
340 return;
341 } 411 }
342 412
343 /* Sometimes the BMC queues get in an "off-by-one" state...*/ 413 printk("failed %d retries, sending error response\n",
344 if ((bt->state == BT_STATE_B2H_WAIT) && (status & BT_B2H_ATN)) { 414 bt->BT_CAP_retries);
345 printk(KERN_DEBUG "retry B2H_WAIT\n"); 415 if (!bt->nonzero_status)
346 return; 416 printk(KERN_ERR "IPMI BT: stuck, try power cycle\n");
417
418 /* this is most likely during insmod */
419 else if (bt->seq <= (unsigned char)(bt->BT_CAP_retries & 0xFF)) {
420 printk(KERN_WARNING "IPMI: BT reset (takes 5 secs)\n");
421 bt->state = BT_STATE_RESET1;
422 return SI_SM_CALL_WITHOUT_DELAY;
347 } 423 }
348 424
349 printk(KERN_DEBUG "restart command\n"); 425 /* Concoct a useful error message, set up the next state, and
350 bt->state = BT_STATE_RESTART; 426 be done with this sequence. */
427
428 bt->state = BT_STATE_IDLE;
429 switch (cCode) {
430 case IPMI_TIMEOUT_ERR:
431 if (status & BT_B_BUSY) {
432 cCode = IPMI_NODE_BUSY_ERR;
433 bt->state = BT_STATE_LONG_BUSY;
434 }
435 break;
436 default:
437 break;
438 }
439 force_result(bt, cCode);
440 return SI_SM_TRANSACTION_COMPLETE;
351} 441}
352 442
353/* Check the status and (possibly) advance the BT state machine. The 443/* Check status and (usually) take action and change this state machine. */
354 default return is SI_SM_CALL_WITH_DELAY. */
355 444
356static enum si_sm_result bt_event(struct si_sm_data *bt, long time) 445static enum si_sm_result bt_event(struct si_sm_data *bt, long time)
357{ 446{
358 unsigned char status; 447 unsigned char status, BT_CAP[8];
359 char buf[40]; /* For getting status */ 448 static enum bt_states last_printed = BT_STATE_PRINTME;
360 int i; 449 int i;
361 450
362 status = BT_STATUS; 451 status = BT_STATUS;
363 bt->nonzero_status |= status; 452 bt->nonzero_status |= status;
364 453 if ((bt_debug & BT_DEBUG_STATES) && (bt->state != last_printed)) {
365 if ((bt_debug & BT_DEBUG_STATES) && (bt->state != bt->last_state))
366 printk(KERN_WARNING "BT: %s %s TO=%ld - %ld \n", 454 printk(KERN_WARNING "BT: %s %s TO=%ld - %ld \n",
367 STATE2TXT, 455 STATE2TXT,
368 STATUS2TXT(buf), 456 STATUS2TXT,
369 bt->timeout, 457 bt->timeout,
370 time); 458 time);
371 bt->last_state = bt->state; 459 last_printed = bt->state;
460 }
372 461
373 if (bt->state == BT_STATE_HOSED) 462 /* Commands that time out may still (eventually) provide a response.
374 return SI_SM_HOSED; 463 This stale response will get in the way of a new response so remove
464 it if possible (hopefully during IDLE). Even if it comes up later
465 it will be rejected by its (now-forgotten) seq number. */
466
467 if ((bt->state < BT_STATE_WRITE_BYTES) && (status & BT_B2H_ATN)) {
468 drain_BMC2HOST(bt);
469 BT_SI_SM_RETURN(SI_SM_CALL_WITH_DELAY);
470 }
375 471
376 if (bt->state != BT_STATE_IDLE) { /* do timeout test */ 472 if ((bt->state != BT_STATE_IDLE) &&
473 (bt->state < BT_STATE_PRINTME)) { /* check timeout */
377 bt->timeout -= time; 474 bt->timeout -= time;
378 if ((bt->timeout < 0) && (bt->state < BT_STATE_RESET1)) { 475 if ((bt->timeout < 0) && (bt->state < BT_STATE_RESET1))
379 error_recovery(bt, "timed out"); 476 return error_recovery(bt,
380 return SI_SM_CALL_WITHOUT_DELAY; 477 status,
381 } 478 IPMI_TIMEOUT_ERR);
382 } 479 }
383 480
384 switch (bt->state) { 481 switch (bt->state) {
385 482
386 case BT_STATE_IDLE: /* check for asynchronous messages */ 483 /* Idle state first checks for asynchronous messages from another
484 channel, then does some opportunistic housekeeping. */
485
486 case BT_STATE_IDLE:
387 if (status & BT_SMS_ATN) { 487 if (status & BT_SMS_ATN) {
388 BT_CONTROL(BT_SMS_ATN); /* clear it */ 488 BT_CONTROL(BT_SMS_ATN); /* clear it */
389 return SI_SM_ATTN; 489 return SI_SM_ATTN;
390 } 490 }
391 return SI_SM_IDLE;
392 491
393 case BT_STATE_XACTION_START: 492 if (status & BT_H_BUSY) /* clear a leftover H_BUSY */
394 if (status & BT_H_BUSY) {
395 BT_CONTROL(BT_H_BUSY); 493 BT_CONTROL(BT_H_BUSY);
396 break;
397 }
398 if (status & BT_B2H_ATN)
399 break;
400 bt->state = BT_STATE_WRITE_BYTES;
401 return SI_SM_CALL_WITHOUT_DELAY; /* for logging */
402 494
403 case BT_STATE_WRITE_BYTES: 495 /* Read BT capabilities if it hasn't been done yet */
496 if (!bt->BT_CAP_outreqs)
497 BT_STATE_CHANGE(BT_STATE_CAPABILITIES_BEGIN,
498 SI_SM_CALL_WITHOUT_DELAY);
499 bt->timeout = bt->BT_CAP_req2rsp;
500 BT_SI_SM_RETURN(SI_SM_IDLE);
501
502 case BT_STATE_XACTION_START:
404 if (status & (BT_B_BUSY | BT_H2B_ATN)) 503 if (status & (BT_B_BUSY | BT_H2B_ATN))
405 break; 504 BT_SI_SM_RETURN(SI_SM_CALL_WITH_DELAY);
505 if (BT_STATUS & BT_H_BUSY)
506 BT_CONTROL(BT_H_BUSY); /* force clear */
507 BT_STATE_CHANGE(BT_STATE_WRITE_BYTES,
508 SI_SM_CALL_WITHOUT_DELAY);
509
510 case BT_STATE_WRITE_BYTES:
511 if (status & BT_H_BUSY)
512 BT_CONTROL(BT_H_BUSY); /* clear */
406 BT_CONTROL(BT_CLR_WR_PTR); 513 BT_CONTROL(BT_CLR_WR_PTR);
407 write_all_bytes(bt); 514 write_all_bytes(bt);
408 BT_CONTROL(BT_H2B_ATN); /* clears too fast to catch? */ 515 BT_CONTROL(BT_H2B_ATN); /* can clear too fast to catch */
409 bt->state = BT_STATE_WRITE_CONSUME; 516 BT_STATE_CHANGE(BT_STATE_WRITE_CONSUME,
410 return SI_SM_CALL_WITHOUT_DELAY; /* it MIGHT sail through */ 517 SI_SM_CALL_WITHOUT_DELAY);
411
412 case BT_STATE_WRITE_CONSUME: /* BMCs usually blow right thru here */
413 if (status & (BT_H2B_ATN | BT_B_BUSY))
414 break;
415 bt->state = BT_STATE_B2H_WAIT;
416 /* fall through with status */
417
418 /* Stay in BT_STATE_B2H_WAIT until a packet matches. However, spinning
419 hard here, constantly reading status, seems to hold off the
420 generation of B2H_ATN so ALWAYS return CALL_WITH_DELAY. */
421
422 case BT_STATE_B2H_WAIT:
423 if (!(status & BT_B2H_ATN))
424 break;
425
426 /* Assume ordered, uncached writes: no need to wait */
427 if (!(status & BT_H_BUSY))
428 BT_CONTROL(BT_H_BUSY); /* set */
429 BT_CONTROL(BT_B2H_ATN); /* clear it, ACK to the BMC */
430 BT_CONTROL(BT_CLR_RD_PTR); /* reset the queue */
431 i = read_all_bytes(bt);
432 BT_CONTROL(BT_H_BUSY); /* clear */
433 if (!i) /* Try this state again */
434 break;
435 bt->state = BT_STATE_READ_END;
436 return SI_SM_CALL_WITHOUT_DELAY; /* for logging */
437
438 case BT_STATE_READ_END:
439
440 /* I could wait on BT_H_BUSY to go clear for a truly clean
441 exit. However, this is already done in XACTION_START
442 and the (possible) extra loop/status/possible wait affects
443 performance. So, as long as it works, just ignore H_BUSY */
444
445#ifdef MAKE_THIS_TRUE_IF_NECESSARY
446 518
447 if (status & BT_H_BUSY) 519 case BT_STATE_WRITE_CONSUME:
448 break; 520 if (status & (BT_B_BUSY | BT_H2B_ATN))
449#endif 521 BT_SI_SM_RETURN(SI_SM_CALL_WITH_DELAY);
450 bt->seq++; 522 BT_STATE_CHANGE(BT_STATE_READ_WAIT,
451 bt->state = BT_STATE_IDLE; 523 SI_SM_CALL_WITHOUT_DELAY);
452 return SI_SM_TRANSACTION_COMPLETE; 524
525 /* Spinning hard can suppress B2H_ATN and force a timeout */
526
527 case BT_STATE_READ_WAIT:
528 if (!(status & BT_B2H_ATN))
529 BT_SI_SM_RETURN(SI_SM_CALL_WITH_DELAY);
530 BT_CONTROL(BT_H_BUSY); /* set */
531
532 /* Uncached, ordered writes should just proceeed serially but
533 some BMCs don't clear B2H_ATN with one hit. Fast-path a
534 workaround without too much penalty to the general case. */
535
536 BT_CONTROL(BT_B2H_ATN); /* clear it to ACK the BMC */
537 BT_STATE_CHANGE(BT_STATE_CLEAR_B2H,
538 SI_SM_CALL_WITHOUT_DELAY);
539
540 case BT_STATE_CLEAR_B2H:
541 if (status & BT_B2H_ATN) { /* keep hitting it */
542 BT_CONTROL(BT_B2H_ATN);
543 BT_SI_SM_RETURN(SI_SM_CALL_WITH_DELAY);
544 }
545 BT_STATE_CHANGE(BT_STATE_READ_BYTES,
546 SI_SM_CALL_WITHOUT_DELAY);
547
548 case BT_STATE_READ_BYTES:
549 if (!(status & BT_H_BUSY)) /* check in case of retry */
550 BT_CONTROL(BT_H_BUSY);
551 BT_CONTROL(BT_CLR_RD_PTR); /* start of BMC2HOST buffer */
552 i = read_all_bytes(bt); /* true == packet seq match */
553 BT_CONTROL(BT_H_BUSY); /* NOW clear */
554 if (!i) /* Not my message */
555 BT_STATE_CHANGE(BT_STATE_READ_WAIT,
556 SI_SM_CALL_WITHOUT_DELAY);
557 bt->state = bt->complete;
558 return bt->state == BT_STATE_IDLE ? /* where to next? */
559 SI_SM_TRANSACTION_COMPLETE : /* normal */
560 SI_SM_CALL_WITHOUT_DELAY; /* Startup magic */
561
562 case BT_STATE_LONG_BUSY: /* For example: after FW update */
563 if (!(status & BT_B_BUSY)) {
564 reset_flags(bt); /* next state is now IDLE */
565 bt_init_data(bt, bt->io);
566 }
567 return SI_SM_CALL_WITH_DELAY; /* No repeat printing */
453 568
454 case BT_STATE_RESET1: 569 case BT_STATE_RESET1:
455 reset_flags(bt); 570 reset_flags(bt);
456 bt->timeout = BT_RESET_DELAY; 571 drain_BMC2HOST(bt);
457 bt->state = BT_STATE_RESET2; 572 BT_STATE_CHANGE(BT_STATE_RESET2,
458 break; 573 SI_SM_CALL_WITH_DELAY);
459 574
460 case BT_STATE_RESET2: /* Send a soft reset */ 575 case BT_STATE_RESET2: /* Send a soft reset */
461 BT_CONTROL(BT_CLR_WR_PTR); 576 BT_CONTROL(BT_CLR_WR_PTR);
@@ -464,29 +579,59 @@ static enum si_sm_result bt_event(struct si_sm_data *bt, long time)
464 HOST2BMC(42); /* Sequence number */ 579 HOST2BMC(42); /* Sequence number */
465 HOST2BMC(3); /* Cmd == Soft reset */ 580 HOST2BMC(3); /* Cmd == Soft reset */
466 BT_CONTROL(BT_H2B_ATN); 581 BT_CONTROL(BT_H2B_ATN);
467 bt->state = BT_STATE_RESET3; 582 bt->timeout = BT_RESET_DELAY * 1000000;
468 break; 583 BT_STATE_CHANGE(BT_STATE_RESET3,
584 SI_SM_CALL_WITH_DELAY);
469 585
470 case BT_STATE_RESET3: 586 case BT_STATE_RESET3: /* Hold off everything for a bit */
471 if (bt->timeout > 0) 587 if (bt->timeout > 0)
472 return SI_SM_CALL_WITH_DELAY; 588 return SI_SM_CALL_WITH_DELAY;
473 bt->state = BT_STATE_RESTART; /* printk in debug modes */ 589 drain_BMC2HOST(bt);
474 break; 590 BT_STATE_CHANGE(BT_STATE_RESTART,
591 SI_SM_CALL_WITH_DELAY);
475 592
476 case BT_STATE_RESTART: /* don't reset retries! */ 593 case BT_STATE_RESTART: /* don't reset retries or seq! */
477 reset_flags(bt);
478 bt->write_data[2] = ++bt->seq;
479 bt->read_count = 0; 594 bt->read_count = 0;
480 bt->nonzero_status = 0; 595 bt->nonzero_status = 0;
481 bt->timeout = BT_NORMAL_TIMEOUT; 596 bt->timeout = bt->BT_CAP_req2rsp;
482 bt->state = BT_STATE_XACTION_START; 597 BT_STATE_CHANGE(BT_STATE_XACTION_START,
483 break; 598 SI_SM_CALL_WITH_DELAY);
484 599
485 default: /* HOSED is supposed to be caught much earlier */ 600 /* Get BT Capabilities, using timing of upper level state machine.
486 error_recovery(bt, "internal logic error"); 601 Set outreqs to prevent infinite loop on timeout. */
487 break; 602 case BT_STATE_CAPABILITIES_BEGIN:
488 } 603 bt->BT_CAP_outreqs = 1;
489 return SI_SM_CALL_WITH_DELAY; 604 {
605 unsigned char GetBT_CAP[] = { 0x18, 0x36 };
606 bt->state = BT_STATE_IDLE;
607 bt_start_transaction(bt, GetBT_CAP, sizeof(GetBT_CAP));
608 }
609 bt->complete = BT_STATE_CAPABILITIES_END;
610 BT_STATE_CHANGE(BT_STATE_XACTION_START,
611 SI_SM_CALL_WITH_DELAY);
612
613 case BT_STATE_CAPABILITIES_END:
614 i = bt_get_result(bt, BT_CAP, sizeof(BT_CAP));
615 bt_init_data(bt, bt->io);
616 if ((i == 8) && !BT_CAP[2]) {
617 bt->BT_CAP_outreqs = BT_CAP[3];
618 bt->BT_CAP_req2rsp = BT_CAP[6] * 1000000;
619 bt->BT_CAP_retries = BT_CAP[7];
620 } else
621 printk(KERN_WARNING "IPMI BT: using default values\n");
622 if (!bt->BT_CAP_outreqs)
623 bt->BT_CAP_outreqs = 1;
624 printk(KERN_WARNING "IPMI BT: req2rsp=%ld secs retries=%d\n",
625 bt->BT_CAP_req2rsp / 1000000L, bt->BT_CAP_retries);
626 bt->timeout = bt->BT_CAP_req2rsp;
627 return SI_SM_CALL_WITHOUT_DELAY;
628
629 default: /* should never occur */
630 return error_recovery(bt,
631 status,
632 IPMI_ERR_UNSPECIFIED);
633 }
634 return SI_SM_CALL_WITH_DELAY;
490} 635}
491 636
492static int bt_detect(struct si_sm_data *bt) 637static int bt_detect(struct si_sm_data *bt)
@@ -497,7 +642,7 @@ static int bt_detect(struct si_sm_data *bt)
497 test that first. The calling routine uses negative logic. */ 642 test that first. The calling routine uses negative logic. */
498 643
499 if ((BT_STATUS == 0xFF) && (BT_INTMASK_R == 0xFF)) 644 if ((BT_STATUS == 0xFF) && (BT_INTMASK_R == 0xFF))
500 return 1; 645 return 1;
501 reset_flags(bt); 646 reset_flags(bt);
502 return 0; 647 return 0;
503} 648}
@@ -513,11 +658,11 @@ static int bt_size(void)
513 658
514struct si_sm_handlers bt_smi_handlers = 659struct si_sm_handlers bt_smi_handlers =
515{ 660{
516 .init_data = bt_init_data, 661 .init_data = bt_init_data,
517 .start_transaction = bt_start_transaction, 662 .start_transaction = bt_start_transaction,
518 .get_result = bt_get_result, 663 .get_result = bt_get_result,
519 .event = bt_event, 664 .event = bt_event,
520 .detect = bt_detect, 665 .detect = bt_detect,
521 .cleanup = bt_cleanup, 666 .cleanup = bt_cleanup,
522 .size = bt_size, 667 .size = bt_size,
523}; 668};
diff --git a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c
index 81fcf0ce21d1..375d3378eecd 100644
--- a/drivers/char/ipmi/ipmi_devintf.c
+++ b/drivers/char/ipmi/ipmi_devintf.c
@@ -596,6 +596,31 @@ static int ipmi_ioctl(struct inode *inode,
596 rv = 0; 596 rv = 0;
597 break; 597 break;
598 } 598 }
599
600 case IPMICTL_GET_MAINTENANCE_MODE_CMD:
601 {
602 int mode;
603
604 mode = ipmi_get_maintenance_mode(priv->user);
605 if (copy_to_user(arg, &mode, sizeof(mode))) {
606 rv = -EFAULT;
607 break;
608 }
609 rv = 0;
610 break;
611 }
612
613 case IPMICTL_SET_MAINTENANCE_MODE_CMD:
614 {
615 int mode;
616
617 if (copy_from_user(&mode, arg, sizeof(mode))) {
618 rv = -EFAULT;
619 break;
620 }
621 rv = ipmi_set_maintenance_mode(priv->user, mode);
622 break;
623 }
599 } 624 }
600 625
601 return rv; 626 return rv;
diff --git a/drivers/char/ipmi/ipmi_kcs_sm.c b/drivers/char/ipmi/ipmi_kcs_sm.c
index 2062675f9e99..c1b8228cb7b6 100644
--- a/drivers/char/ipmi/ipmi_kcs_sm.c
+++ b/drivers/char/ipmi/ipmi_kcs_sm.c
@@ -93,8 +93,8 @@ enum kcs_states {
93 state machine. */ 93 state machine. */
94}; 94};
95 95
96#define MAX_KCS_READ_SIZE 80 96#define MAX_KCS_READ_SIZE IPMI_MAX_MSG_LENGTH
97#define MAX_KCS_WRITE_SIZE 80 97#define MAX_KCS_WRITE_SIZE IPMI_MAX_MSG_LENGTH
98 98
99/* Timeouts in microseconds. */ 99/* Timeouts in microseconds. */
100#define IBF_RETRY_TIMEOUT 1000000 100#define IBF_RETRY_TIMEOUT 1000000
@@ -261,12 +261,14 @@ static int start_kcs_transaction(struct si_sm_data *kcs, unsigned char *data,
261{ 261{
262 unsigned int i; 262 unsigned int i;
263 263
264 if ((size < 2) || (size > MAX_KCS_WRITE_SIZE)) { 264 if (size < 2)
265 return -1; 265 return IPMI_REQ_LEN_INVALID_ERR;
266 } 266 if (size > MAX_KCS_WRITE_SIZE)
267 if ((kcs->state != KCS_IDLE) && (kcs->state != KCS_HOSED)) { 267 return IPMI_REQ_LEN_EXCEEDED_ERR;
268 return -2; 268
269 } 269 if ((kcs->state != KCS_IDLE) && (kcs->state != KCS_HOSED))
270 return IPMI_NOT_IN_MY_STATE_ERR;
271
270 if (kcs_debug & KCS_DEBUG_MSG) { 272 if (kcs_debug & KCS_DEBUG_MSG) {
271 printk(KERN_DEBUG "start_kcs_transaction -"); 273 printk(KERN_DEBUG "start_kcs_transaction -");
272 for (i = 0; i < size; i ++) { 274 for (i = 0; i < size; i ++) {
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index 34a4fd13fa81..5703ee28e1cc 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -48,7 +48,7 @@
48 48
49#define PFX "IPMI message handler: " 49#define PFX "IPMI message handler: "
50 50
51#define IPMI_DRIVER_VERSION "39.0" 51#define IPMI_DRIVER_VERSION "39.1"
52 52
53static struct ipmi_recv_msg *ipmi_alloc_recv_msg(void); 53static struct ipmi_recv_msg *ipmi_alloc_recv_msg(void);
54static int ipmi_init_msghandler(void); 54static int ipmi_init_msghandler(void);
@@ -59,6 +59,9 @@ static int initialized = 0;
59static struct proc_dir_entry *proc_ipmi_root = NULL; 59static struct proc_dir_entry *proc_ipmi_root = NULL;
60#endif /* CONFIG_PROC_FS */ 60#endif /* CONFIG_PROC_FS */
61 61
62/* Remain in auto-maintenance mode for this amount of time (in ms). */
63#define IPMI_MAINTENANCE_MODE_TIMEOUT 30000
64
62#define MAX_EVENTS_IN_QUEUE 25 65#define MAX_EVENTS_IN_QUEUE 25
63 66
64/* Don't let a message sit in a queue forever, always time it with at lest 67/* Don't let a message sit in a queue forever, always time it with at lest
@@ -193,17 +196,28 @@ struct ipmi_smi
193 196
194 struct kref refcount; 197 struct kref refcount;
195 198
199 /* Used for a list of interfaces. */
200 struct list_head link;
201
196 /* The list of upper layers that are using me. seq_lock 202 /* The list of upper layers that are using me. seq_lock
197 * protects this. */ 203 * protects this. */
198 struct list_head users; 204 struct list_head users;
199 205
206 /* Information to supply to users. */
207 unsigned char ipmi_version_major;
208 unsigned char ipmi_version_minor;
209
200 /* Used for wake ups at startup. */ 210 /* Used for wake ups at startup. */
201 wait_queue_head_t waitq; 211 wait_queue_head_t waitq;
202 212
203 struct bmc_device *bmc; 213 struct bmc_device *bmc;
204 char *my_dev_name; 214 char *my_dev_name;
215 char *sysfs_name;
205 216
206 /* This is the lower-layer's sender routine. */ 217 /* This is the lower-layer's sender routine. Note that you
218 * must either be holding the ipmi_interfaces_mutex or be in
219 * an umpreemptible region to use this. You must fetch the
220 * value into a local variable and make sure it is not NULL. */
207 struct ipmi_smi_handlers *handlers; 221 struct ipmi_smi_handlers *handlers;
208 void *send_info; 222 void *send_info;
209 223
@@ -242,6 +256,7 @@ struct ipmi_smi
242 spinlock_t events_lock; /* For dealing with event stuff. */ 256 spinlock_t events_lock; /* For dealing with event stuff. */
243 struct list_head waiting_events; 257 struct list_head waiting_events;
244 unsigned int waiting_events_count; /* How many events in queue? */ 258 unsigned int waiting_events_count; /* How many events in queue? */
259 int delivering_events;
245 260
246 /* The event receiver for my BMC, only really used at panic 261 /* The event receiver for my BMC, only really used at panic
247 shutdown as a place to store this. */ 262 shutdown as a place to store this. */
@@ -250,6 +265,12 @@ struct ipmi_smi
250 unsigned char local_sel_device; 265 unsigned char local_sel_device;
251 unsigned char local_event_generator; 266 unsigned char local_event_generator;
252 267
268 /* For handling of maintenance mode. */
269 int maintenance_mode;
270 int maintenance_mode_enable;
271 int auto_maintenance_timeout;
272 spinlock_t maintenance_mode_lock; /* Used in a timer... */
273
253 /* A cheap hack, if this is non-null and a message to an 274 /* A cheap hack, if this is non-null and a message to an
254 interface comes in with a NULL user, call this routine with 275 interface comes in with a NULL user, call this routine with
255 it. Note that the message will still be freed by the 276 it. Note that the message will still be freed by the
@@ -338,13 +359,6 @@ struct ipmi_smi
338}; 359};
339#define to_si_intf_from_dev(device) container_of(device, struct ipmi_smi, dev) 360#define to_si_intf_from_dev(device) container_of(device, struct ipmi_smi, dev)
340 361
341/* Used to mark an interface entry that cannot be used but is not a
342 * free entry, either, primarily used at creation and deletion time so
343 * a slot doesn't get reused too quickly. */
344#define IPMI_INVALID_INTERFACE_ENTRY ((ipmi_smi_t) ((long) 1))
345#define IPMI_INVALID_INTERFACE(i) (((i) == NULL) \
346 || (i == IPMI_INVALID_INTERFACE_ENTRY))
347
348/** 362/**
349 * The driver model view of the IPMI messaging driver. 363 * The driver model view of the IPMI messaging driver.
350 */ 364 */
@@ -354,16 +368,13 @@ static struct device_driver ipmidriver = {
354}; 368};
355static DEFINE_MUTEX(ipmidriver_mutex); 369static DEFINE_MUTEX(ipmidriver_mutex);
356 370
357#define MAX_IPMI_INTERFACES 4 371static struct list_head ipmi_interfaces = LIST_HEAD_INIT(ipmi_interfaces);
358static ipmi_smi_t ipmi_interfaces[MAX_IPMI_INTERFACES]; 372static DEFINE_MUTEX(ipmi_interfaces_mutex);
359
360/* Directly protects the ipmi_interfaces data structure. */
361static DEFINE_SPINLOCK(interfaces_lock);
362 373
363/* List of watchers that want to know when smi's are added and 374/* List of watchers that want to know when smi's are added and
364 deleted. */ 375 deleted. */
365static struct list_head smi_watchers = LIST_HEAD_INIT(smi_watchers); 376static struct list_head smi_watchers = LIST_HEAD_INIT(smi_watchers);
366static DECLARE_RWSEM(smi_watchers_sem); 377static DEFINE_MUTEX(smi_watchers_mutex);
367 378
368 379
369static void free_recv_msg_list(struct list_head *q) 380static void free_recv_msg_list(struct list_head *q)
@@ -376,13 +387,23 @@ static void free_recv_msg_list(struct list_head *q)
376 } 387 }
377} 388}
378 389
390static void free_smi_msg_list(struct list_head *q)
391{
392 struct ipmi_smi_msg *msg, *msg2;
393
394 list_for_each_entry_safe(msg, msg2, q, link) {
395 list_del(&msg->link);
396 ipmi_free_smi_msg(msg);
397 }
398}
399
379static void clean_up_interface_data(ipmi_smi_t intf) 400static void clean_up_interface_data(ipmi_smi_t intf)
380{ 401{
381 int i; 402 int i;
382 struct cmd_rcvr *rcvr, *rcvr2; 403 struct cmd_rcvr *rcvr, *rcvr2;
383 struct list_head list; 404 struct list_head list;
384 405
385 free_recv_msg_list(&intf->waiting_msgs); 406 free_smi_msg_list(&intf->waiting_msgs);
386 free_recv_msg_list(&intf->waiting_events); 407 free_recv_msg_list(&intf->waiting_events);
387 408
388 /* Wholesale remove all the entries from the list in the 409 /* Wholesale remove all the entries from the list in the
@@ -413,48 +434,84 @@ static void intf_free(struct kref *ref)
413 kfree(intf); 434 kfree(intf);
414} 435}
415 436
437struct watcher_entry {
438 int intf_num;
439 ipmi_smi_t intf;
440 struct list_head link;
441};
442
416int ipmi_smi_watcher_register(struct ipmi_smi_watcher *watcher) 443int ipmi_smi_watcher_register(struct ipmi_smi_watcher *watcher)
417{ 444{
418 int i; 445 ipmi_smi_t intf;
419 unsigned long flags; 446 struct list_head to_deliver = LIST_HEAD_INIT(to_deliver);
447 struct watcher_entry *e, *e2;
420 448
421 down_write(&smi_watchers_sem); 449 mutex_lock(&smi_watchers_mutex);
422 list_add(&(watcher->link), &smi_watchers); 450
423 up_write(&smi_watchers_sem); 451 mutex_lock(&ipmi_interfaces_mutex);
424 spin_lock_irqsave(&interfaces_lock, flags); 452
425 for (i = 0; i < MAX_IPMI_INTERFACES; i++) { 453 /* Build a list of things to deliver. */
426 ipmi_smi_t intf = ipmi_interfaces[i]; 454 list_for_each_entry_rcu(intf, &ipmi_interfaces, link) {
427 if (IPMI_INVALID_INTERFACE(intf)) 455 if (intf->intf_num == -1)
428 continue; 456 continue;
429 spin_unlock_irqrestore(&interfaces_lock, flags); 457 e = kmalloc(sizeof(*e), GFP_KERNEL);
430 watcher->new_smi(i, intf->si_dev); 458 if (!e)
431 spin_lock_irqsave(&interfaces_lock, flags); 459 goto out_err;
460 kref_get(&intf->refcount);
461 e->intf = intf;
462 e->intf_num = intf->intf_num;
463 list_add_tail(&e->link, &to_deliver);
464 }
465
466 /* We will succeed, so add it to the list. */
467 list_add(&watcher->link, &smi_watchers);
468
469 mutex_unlock(&ipmi_interfaces_mutex);
470
471 list_for_each_entry_safe(e, e2, &to_deliver, link) {
472 list_del(&e->link);
473 watcher->new_smi(e->intf_num, e->intf->si_dev);
474 kref_put(&e->intf->refcount, intf_free);
475 kfree(e);
432 } 476 }
433 spin_unlock_irqrestore(&interfaces_lock, flags); 477
478 mutex_unlock(&smi_watchers_mutex);
479
434 return 0; 480 return 0;
481
482 out_err:
483 mutex_unlock(&ipmi_interfaces_mutex);
484 mutex_unlock(&smi_watchers_mutex);
485 list_for_each_entry_safe(e, e2, &to_deliver, link) {
486 list_del(&e->link);
487 kref_put(&e->intf->refcount, intf_free);
488 kfree(e);
489 }
490 return -ENOMEM;
435} 491}
436 492
437int ipmi_smi_watcher_unregister(struct ipmi_smi_watcher *watcher) 493int ipmi_smi_watcher_unregister(struct ipmi_smi_watcher *watcher)
438{ 494{
439 down_write(&smi_watchers_sem); 495 mutex_lock(&smi_watchers_mutex);
440 list_del(&(watcher->link)); 496 list_del(&(watcher->link));
441 up_write(&smi_watchers_sem); 497 mutex_unlock(&smi_watchers_mutex);
442 return 0; 498 return 0;
443} 499}
444 500
501/*
502 * Must be called with smi_watchers_mutex held.
503 */
445static void 504static void
446call_smi_watchers(int i, struct device *dev) 505call_smi_watchers(int i, struct device *dev)
447{ 506{
448 struct ipmi_smi_watcher *w; 507 struct ipmi_smi_watcher *w;
449 508
450 down_read(&smi_watchers_sem);
451 list_for_each_entry(w, &smi_watchers, link) { 509 list_for_each_entry(w, &smi_watchers, link) {
452 if (try_module_get(w->owner)) { 510 if (try_module_get(w->owner)) {
453 w->new_smi(i, dev); 511 w->new_smi(i, dev);
454 module_put(w->owner); 512 module_put(w->owner);
455 } 513 }
456 } 514 }
457 up_read(&smi_watchers_sem);
458} 515}
459 516
460static int 517static int
@@ -580,6 +637,17 @@ static void deliver_response(struct ipmi_recv_msg *msg)
580 } 637 }
581} 638}
582 639
640static void
641deliver_err_response(struct ipmi_recv_msg *msg, int err)
642{
643 msg->recv_type = IPMI_RESPONSE_RECV_TYPE;
644 msg->msg_data[0] = err;
645 msg->msg.netfn |= 1; /* Convert to a response. */
646 msg->msg.data_len = 1;
647 msg->msg.data = msg->msg_data;
648 deliver_response(msg);
649}
650
583/* Find the next sequence number not being used and add the given 651/* Find the next sequence number not being used and add the given
584 message with the given timeout to the sequence table. This must be 652 message with the given timeout to the sequence table. This must be
585 called with the interface's seq_lock held. */ 653 called with the interface's seq_lock held. */
@@ -717,14 +785,8 @@ static int intf_err_seq(ipmi_smi_t intf,
717 } 785 }
718 spin_unlock_irqrestore(&(intf->seq_lock), flags); 786 spin_unlock_irqrestore(&(intf->seq_lock), flags);
719 787
720 if (msg) { 788 if (msg)
721 msg->recv_type = IPMI_RESPONSE_RECV_TYPE; 789 deliver_err_response(msg, err);
722 msg->msg_data[0] = err;
723 msg->msg.netfn |= 1; /* Convert to a response. */
724 msg->msg.data_len = 1;
725 msg->msg.data = msg->msg_data;
726 deliver_response(msg);
727 }
728 790
729 return rv; 791 return rv;
730} 792}
@@ -766,17 +828,18 @@ int ipmi_create_user(unsigned int if_num,
766 if (!new_user) 828 if (!new_user)
767 return -ENOMEM; 829 return -ENOMEM;
768 830
769 spin_lock_irqsave(&interfaces_lock, flags); 831 mutex_lock(&ipmi_interfaces_mutex);
770 intf = ipmi_interfaces[if_num]; 832 list_for_each_entry_rcu(intf, &ipmi_interfaces, link) {
771 if ((if_num >= MAX_IPMI_INTERFACES) || IPMI_INVALID_INTERFACE(intf)) { 833 if (intf->intf_num == if_num)
772 spin_unlock_irqrestore(&interfaces_lock, flags); 834 goto found;
773 rv = -EINVAL;
774 goto out_kfree;
775 } 835 }
836 /* Not found, return an error */
837 rv = -EINVAL;
838 goto out_kfree;
776 839
840 found:
777 /* Note that each existing user holds a refcount to the interface. */ 841 /* Note that each existing user holds a refcount to the interface. */
778 kref_get(&intf->refcount); 842 kref_get(&intf->refcount);
779 spin_unlock_irqrestore(&interfaces_lock, flags);
780 843
781 kref_init(&new_user->refcount); 844 kref_init(&new_user->refcount);
782 new_user->handler = handler; 845 new_user->handler = handler;
@@ -797,6 +860,10 @@ int ipmi_create_user(unsigned int if_num,
797 } 860 }
798 } 861 }
799 862
863 /* Hold the lock so intf->handlers is guaranteed to be good
864 * until now */
865 mutex_unlock(&ipmi_interfaces_mutex);
866
800 new_user->valid = 1; 867 new_user->valid = 1;
801 spin_lock_irqsave(&intf->seq_lock, flags); 868 spin_lock_irqsave(&intf->seq_lock, flags);
802 list_add_rcu(&new_user->link, &intf->users); 869 list_add_rcu(&new_user->link, &intf->users);
@@ -807,6 +874,7 @@ int ipmi_create_user(unsigned int if_num,
807out_kref: 874out_kref:
808 kref_put(&intf->refcount, intf_free); 875 kref_put(&intf->refcount, intf_free);
809out_kfree: 876out_kfree:
877 mutex_unlock(&ipmi_interfaces_mutex);
810 kfree(new_user); 878 kfree(new_user);
811 return rv; 879 return rv;
812} 880}
@@ -836,6 +904,7 @@ int ipmi_destroy_user(ipmi_user_t user)
836 && (intf->seq_table[i].recv_msg->user == user)) 904 && (intf->seq_table[i].recv_msg->user == user))
837 { 905 {
838 intf->seq_table[i].inuse = 0; 906 intf->seq_table[i].inuse = 0;
907 ipmi_free_recv_msg(intf->seq_table[i].recv_msg);
839 } 908 }
840 } 909 }
841 spin_unlock_irqrestore(&intf->seq_lock, flags); 910 spin_unlock_irqrestore(&intf->seq_lock, flags);
@@ -862,9 +931,13 @@ int ipmi_destroy_user(ipmi_user_t user)
862 kfree(rcvr); 931 kfree(rcvr);
863 } 932 }
864 933
865 module_put(intf->handlers->owner); 934 mutex_lock(&ipmi_interfaces_mutex);
866 if (intf->handlers->dec_usecount) 935 if (intf->handlers) {
867 intf->handlers->dec_usecount(intf->send_info); 936 module_put(intf->handlers->owner);
937 if (intf->handlers->dec_usecount)
938 intf->handlers->dec_usecount(intf->send_info);
939 }
940 mutex_unlock(&ipmi_interfaces_mutex);
868 941
869 kref_put(&intf->refcount, intf_free); 942 kref_put(&intf->refcount, intf_free);
870 943
@@ -877,8 +950,8 @@ void ipmi_get_version(ipmi_user_t user,
877 unsigned char *major, 950 unsigned char *major,
878 unsigned char *minor) 951 unsigned char *minor)
879{ 952{
880 *major = ipmi_version_major(&user->intf->bmc->id); 953 *major = user->intf->ipmi_version_major;
881 *minor = ipmi_version_minor(&user->intf->bmc->id); 954 *minor = user->intf->ipmi_version_minor;
882} 955}
883 956
884int ipmi_set_my_address(ipmi_user_t user, 957int ipmi_set_my_address(ipmi_user_t user,
@@ -921,6 +994,65 @@ int ipmi_get_my_LUN(ipmi_user_t user,
921 return 0; 994 return 0;
922} 995}
923 996
997int ipmi_get_maintenance_mode(ipmi_user_t user)
998{
999 int mode;
1000 unsigned long flags;
1001
1002 spin_lock_irqsave(&user->intf->maintenance_mode_lock, flags);
1003 mode = user->intf->maintenance_mode;
1004 spin_unlock_irqrestore(&user->intf->maintenance_mode_lock, flags);
1005
1006 return mode;
1007}
1008EXPORT_SYMBOL(ipmi_get_maintenance_mode);
1009
1010static void maintenance_mode_update(ipmi_smi_t intf)
1011{
1012 if (intf->handlers->set_maintenance_mode)
1013 intf->handlers->set_maintenance_mode(
1014 intf->send_info, intf->maintenance_mode_enable);
1015}
1016
1017int ipmi_set_maintenance_mode(ipmi_user_t user, int mode)
1018{
1019 int rv = 0;
1020 unsigned long flags;
1021 ipmi_smi_t intf = user->intf;
1022
1023 spin_lock_irqsave(&intf->maintenance_mode_lock, flags);
1024 if (intf->maintenance_mode != mode) {
1025 switch (mode) {
1026 case IPMI_MAINTENANCE_MODE_AUTO:
1027 intf->maintenance_mode = mode;
1028 intf->maintenance_mode_enable
1029 = (intf->auto_maintenance_timeout > 0);
1030 break;
1031
1032 case IPMI_MAINTENANCE_MODE_OFF:
1033 intf->maintenance_mode = mode;
1034 intf->maintenance_mode_enable = 0;
1035 break;
1036
1037 case IPMI_MAINTENANCE_MODE_ON:
1038 intf->maintenance_mode = mode;
1039 intf->maintenance_mode_enable = 1;
1040 break;
1041
1042 default:
1043 rv = -EINVAL;
1044 goto out_unlock;
1045 }
1046
1047 maintenance_mode_update(intf);
1048 }
1049 out_unlock:
1050 spin_unlock_irqrestore(&intf->maintenance_mode_lock, flags);
1051
1052 return rv;
1053}
1054EXPORT_SYMBOL(ipmi_set_maintenance_mode);
1055
924int ipmi_set_gets_events(ipmi_user_t user, int val) 1056int ipmi_set_gets_events(ipmi_user_t user, int val)
925{ 1057{
926 unsigned long flags; 1058 unsigned long flags;
@@ -933,20 +1065,33 @@ int ipmi_set_gets_events(ipmi_user_t user, int val)
933 spin_lock_irqsave(&intf->events_lock, flags); 1065 spin_lock_irqsave(&intf->events_lock, flags);
934 user->gets_events = val; 1066 user->gets_events = val;
935 1067
936 if (val) { 1068 if (intf->delivering_events)
937 /* Deliver any queued events. */ 1069 /*
1070 * Another thread is delivering events for this, so
1071 * let it handle any new events.
1072 */
1073 goto out;
1074
1075 /* Deliver any queued events. */
1076 while (user->gets_events && !list_empty(&intf->waiting_events)) {
938 list_for_each_entry_safe(msg, msg2, &intf->waiting_events, link) 1077 list_for_each_entry_safe(msg, msg2, &intf->waiting_events, link)
939 list_move_tail(&msg->link, &msgs); 1078 list_move_tail(&msg->link, &msgs);
940 intf->waiting_events_count = 0; 1079 intf->waiting_events_count = 0;
941 }
942 1080
943 /* Hold the events lock while doing this to preserve order. */ 1081 intf->delivering_events = 1;
944 list_for_each_entry_safe(msg, msg2, &msgs, link) { 1082 spin_unlock_irqrestore(&intf->events_lock, flags);
945 msg->user = user; 1083
946 kref_get(&user->refcount); 1084 list_for_each_entry_safe(msg, msg2, &msgs, link) {
947 deliver_response(msg); 1085 msg->user = user;
1086 kref_get(&user->refcount);
1087 deliver_response(msg);
1088 }
1089
1090 spin_lock_irqsave(&intf->events_lock, flags);
1091 intf->delivering_events = 0;
948 } 1092 }
949 1093
1094 out:
950 spin_unlock_irqrestore(&intf->events_lock, flags); 1095 spin_unlock_irqrestore(&intf->events_lock, flags);
951 1096
952 return 0; 1097 return 0;
@@ -1057,7 +1202,8 @@ int ipmi_unregister_for_cmd(ipmi_user_t user,
1057void ipmi_user_set_run_to_completion(ipmi_user_t user, int val) 1202void ipmi_user_set_run_to_completion(ipmi_user_t user, int val)
1058{ 1203{
1059 ipmi_smi_t intf = user->intf; 1204 ipmi_smi_t intf = user->intf;
1060 intf->handlers->set_run_to_completion(intf->send_info, val); 1205 if (intf->handlers)
1206 intf->handlers->set_run_to_completion(intf->send_info, val);
1061} 1207}
1062 1208
1063static unsigned char 1209static unsigned char
@@ -1168,10 +1314,11 @@ static int i_ipmi_request(ipmi_user_t user,
1168 int retries, 1314 int retries,
1169 unsigned int retry_time_ms) 1315 unsigned int retry_time_ms)
1170{ 1316{
1171 int rv = 0; 1317 int rv = 0;
1172 struct ipmi_smi_msg *smi_msg; 1318 struct ipmi_smi_msg *smi_msg;
1173 struct ipmi_recv_msg *recv_msg; 1319 struct ipmi_recv_msg *recv_msg;
1174 unsigned long flags; 1320 unsigned long flags;
1321 struct ipmi_smi_handlers *handlers;
1175 1322
1176 1323
1177 if (supplied_recv) { 1324 if (supplied_recv) {
@@ -1194,6 +1341,13 @@ static int i_ipmi_request(ipmi_user_t user,
1194 } 1341 }
1195 } 1342 }
1196 1343
1344 rcu_read_lock();
1345 handlers = intf->handlers;
1346 if (!handlers) {
1347 rv = -ENODEV;
1348 goto out_err;
1349 }
1350
1197 recv_msg->user = user; 1351 recv_msg->user = user;
1198 if (user) 1352 if (user)
1199 kref_get(&user->refcount); 1353 kref_get(&user->refcount);
@@ -1236,6 +1390,24 @@ static int i_ipmi_request(ipmi_user_t user,
1236 goto out_err; 1390 goto out_err;
1237 } 1391 }
1238 1392
1393 if (((msg->netfn == IPMI_NETFN_APP_REQUEST)
1394 && ((msg->cmd == IPMI_COLD_RESET_CMD)
1395 || (msg->cmd == IPMI_WARM_RESET_CMD)))
1396 || (msg->netfn == IPMI_NETFN_FIRMWARE_REQUEST))
1397 {
1398 spin_lock_irqsave(&intf->maintenance_mode_lock, flags);
1399 intf->auto_maintenance_timeout
1400 = IPMI_MAINTENANCE_MODE_TIMEOUT;
1401 if (!intf->maintenance_mode
1402 && !intf->maintenance_mode_enable)
1403 {
1404 intf->maintenance_mode_enable = 1;
1405 maintenance_mode_update(intf);
1406 }
1407 spin_unlock_irqrestore(&intf->maintenance_mode_lock,
1408 flags);
1409 }
1410
1239 if ((msg->data_len + 2) > IPMI_MAX_MSG_LENGTH) { 1411 if ((msg->data_len + 2) > IPMI_MAX_MSG_LENGTH) {
1240 spin_lock_irqsave(&intf->counter_lock, flags); 1412 spin_lock_irqsave(&intf->counter_lock, flags);
1241 intf->sent_invalid_commands++; 1413 intf->sent_invalid_commands++;
@@ -1510,11 +1682,14 @@ static int i_ipmi_request(ipmi_user_t user,
1510 printk("\n"); 1682 printk("\n");
1511 } 1683 }
1512#endif 1684#endif
1513 intf->handlers->sender(intf->send_info, smi_msg, priority); 1685
1686 handlers->sender(intf->send_info, smi_msg, priority);
1687 rcu_read_unlock();
1514 1688
1515 return 0; 1689 return 0;
1516 1690
1517 out_err: 1691 out_err:
1692 rcu_read_unlock();
1518 ipmi_free_smi_msg(smi_msg); 1693 ipmi_free_smi_msg(smi_msg);
1519 ipmi_free_recv_msg(recv_msg); 1694 ipmi_free_recv_msg(recv_msg);
1520 return rv; 1695 return rv;
@@ -1594,6 +1769,7 @@ int ipmi_request_supply_msgs(ipmi_user_t user,
1594 -1, 0); 1769 -1, 0);
1595} 1770}
1596 1771
1772#ifdef CONFIG_PROC_FS
1597static int ipmb_file_read_proc(char *page, char **start, off_t off, 1773static int ipmb_file_read_proc(char *page, char **start, off_t off,
1598 int count, int *eof, void *data) 1774 int count, int *eof, void *data)
1599{ 1775{
@@ -1682,6 +1858,7 @@ static int stat_file_read_proc(char *page, char **start, off_t off,
1682 1858
1683 return (out - ((char *) page)); 1859 return (out - ((char *) page));
1684} 1860}
1861#endif /* CONFIG_PROC_FS */
1685 1862
1686int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name, 1863int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name,
1687 read_proc_t *read_proc, write_proc_t *write_proc, 1864 read_proc_t *read_proc, write_proc_t *write_proc,
@@ -1807,13 +1984,12 @@ static int __find_bmc_prod_dev_id(struct device *dev, void *data)
1807 struct bmc_device *bmc = dev_get_drvdata(dev); 1984 struct bmc_device *bmc = dev_get_drvdata(dev);
1808 1985
1809 return (bmc->id.product_id == id->product_id 1986 return (bmc->id.product_id == id->product_id
1810 && bmc->id.product_id == id->product_id
1811 && bmc->id.device_id == id->device_id); 1987 && bmc->id.device_id == id->device_id);
1812} 1988}
1813 1989
1814static struct bmc_device *ipmi_find_bmc_prod_dev_id( 1990static struct bmc_device *ipmi_find_bmc_prod_dev_id(
1815 struct device_driver *drv, 1991 struct device_driver *drv,
1816 unsigned char product_id, unsigned char device_id) 1992 unsigned int product_id, unsigned char device_id)
1817{ 1993{
1818 struct prod_dev_id id = { 1994 struct prod_dev_id id = {
1819 .product_id = product_id, 1995 .product_id = product_id,
@@ -1844,7 +2020,7 @@ static ssize_t provides_dev_sdrs_show(struct device *dev,
1844 struct bmc_device *bmc = dev_get_drvdata(dev); 2020 struct bmc_device *bmc = dev_get_drvdata(dev);
1845 2021
1846 return snprintf(buf, 10, "%u\n", 2022 return snprintf(buf, 10, "%u\n",
1847 bmc->id.device_revision && 0x80 >> 7); 2023 (bmc->id.device_revision & 0x80) >> 7);
1848} 2024}
1849 2025
1850static ssize_t revision_show(struct device *dev, struct device_attribute *attr, 2026static ssize_t revision_show(struct device *dev, struct device_attribute *attr,
@@ -1853,7 +2029,7 @@ static ssize_t revision_show(struct device *dev, struct device_attribute *attr,
1853 struct bmc_device *bmc = dev_get_drvdata(dev); 2029 struct bmc_device *bmc = dev_get_drvdata(dev);
1854 2030
1855 return snprintf(buf, 20, "%u\n", 2031 return snprintf(buf, 20, "%u\n",
1856 bmc->id.device_revision && 0x0F); 2032 bmc->id.device_revision & 0x0F);
1857} 2033}
1858 2034
1859static ssize_t firmware_rev_show(struct device *dev, 2035static ssize_t firmware_rev_show(struct device *dev,
@@ -1930,6 +2106,9 @@ static ssize_t guid_show(struct device *dev, struct device_attribute *attr,
1930 2106
1931static void remove_files(struct bmc_device *bmc) 2107static void remove_files(struct bmc_device *bmc)
1932{ 2108{
2109 if (!bmc->dev)
2110 return;
2111
1933 device_remove_file(&bmc->dev->dev, 2112 device_remove_file(&bmc->dev->dev,
1934 &bmc->device_id_attr); 2113 &bmc->device_id_attr);
1935 device_remove_file(&bmc->dev->dev, 2114 device_remove_file(&bmc->dev->dev,
@@ -1963,7 +2142,8 @@ cleanup_bmc_device(struct kref *ref)
1963 bmc = container_of(ref, struct bmc_device, refcount); 2142 bmc = container_of(ref, struct bmc_device, refcount);
1964 2143
1965 remove_files(bmc); 2144 remove_files(bmc);
1966 platform_device_unregister(bmc->dev); 2145 if (bmc->dev)
2146 platform_device_unregister(bmc->dev);
1967 kfree(bmc); 2147 kfree(bmc);
1968} 2148}
1969 2149
@@ -1971,7 +2151,11 @@ static void ipmi_bmc_unregister(ipmi_smi_t intf)
1971{ 2151{
1972 struct bmc_device *bmc = intf->bmc; 2152 struct bmc_device *bmc = intf->bmc;
1973 2153
1974 sysfs_remove_link(&intf->si_dev->kobj, "bmc"); 2154 if (intf->sysfs_name) {
2155 sysfs_remove_link(&intf->si_dev->kobj, intf->sysfs_name);
2156 kfree(intf->sysfs_name);
2157 intf->sysfs_name = NULL;
2158 }
1975 if (intf->my_dev_name) { 2159 if (intf->my_dev_name) {
1976 sysfs_remove_link(&bmc->dev->dev.kobj, intf->my_dev_name); 2160 sysfs_remove_link(&bmc->dev->dev.kobj, intf->my_dev_name);
1977 kfree(intf->my_dev_name); 2161 kfree(intf->my_dev_name);
@@ -1980,6 +2164,7 @@ static void ipmi_bmc_unregister(ipmi_smi_t intf)
1980 2164
1981 mutex_lock(&ipmidriver_mutex); 2165 mutex_lock(&ipmidriver_mutex);
1982 kref_put(&bmc->refcount, cleanup_bmc_device); 2166 kref_put(&bmc->refcount, cleanup_bmc_device);
2167 intf->bmc = NULL;
1983 mutex_unlock(&ipmidriver_mutex); 2168 mutex_unlock(&ipmidriver_mutex);
1984} 2169}
1985 2170
@@ -1987,6 +2172,56 @@ static int create_files(struct bmc_device *bmc)
1987{ 2172{
1988 int err; 2173 int err;
1989 2174
2175 bmc->device_id_attr.attr.name = "device_id";
2176 bmc->device_id_attr.attr.owner = THIS_MODULE;
2177 bmc->device_id_attr.attr.mode = S_IRUGO;
2178 bmc->device_id_attr.show = device_id_show;
2179
2180 bmc->provides_dev_sdrs_attr.attr.name = "provides_device_sdrs";
2181 bmc->provides_dev_sdrs_attr.attr.owner = THIS_MODULE;
2182 bmc->provides_dev_sdrs_attr.attr.mode = S_IRUGO;
2183 bmc->provides_dev_sdrs_attr.show = provides_dev_sdrs_show;
2184
2185 bmc->revision_attr.attr.name = "revision";
2186 bmc->revision_attr.attr.owner = THIS_MODULE;
2187 bmc->revision_attr.attr.mode = S_IRUGO;
2188 bmc->revision_attr.show = revision_show;
2189
2190 bmc->firmware_rev_attr.attr.name = "firmware_revision";
2191 bmc->firmware_rev_attr.attr.owner = THIS_MODULE;
2192 bmc->firmware_rev_attr.attr.mode = S_IRUGO;
2193 bmc->firmware_rev_attr.show = firmware_rev_show;
2194
2195 bmc->version_attr.attr.name = "ipmi_version";
2196 bmc->version_attr.attr.owner = THIS_MODULE;
2197 bmc->version_attr.attr.mode = S_IRUGO;
2198 bmc->version_attr.show = ipmi_version_show;
2199
2200 bmc->add_dev_support_attr.attr.name = "additional_device_support";
2201 bmc->add_dev_support_attr.attr.owner = THIS_MODULE;
2202 bmc->add_dev_support_attr.attr.mode = S_IRUGO;
2203 bmc->add_dev_support_attr.show = add_dev_support_show;
2204
2205 bmc->manufacturer_id_attr.attr.name = "manufacturer_id";
2206 bmc->manufacturer_id_attr.attr.owner = THIS_MODULE;
2207 bmc->manufacturer_id_attr.attr.mode = S_IRUGO;
2208 bmc->manufacturer_id_attr.show = manufacturer_id_show;
2209
2210 bmc->product_id_attr.attr.name = "product_id";
2211 bmc->product_id_attr.attr.owner = THIS_MODULE;
2212 bmc->product_id_attr.attr.mode = S_IRUGO;
2213 bmc->product_id_attr.show = product_id_show;
2214
2215 bmc->guid_attr.attr.name = "guid";
2216 bmc->guid_attr.attr.owner = THIS_MODULE;
2217 bmc->guid_attr.attr.mode = S_IRUGO;
2218 bmc->guid_attr.show = guid_show;
2219
2220 bmc->aux_firmware_rev_attr.attr.name = "aux_firmware_revision";
2221 bmc->aux_firmware_rev_attr.attr.owner = THIS_MODULE;
2222 bmc->aux_firmware_rev_attr.attr.mode = S_IRUGO;
2223 bmc->aux_firmware_rev_attr.show = aux_firmware_rev_show;
2224
1990 err = device_create_file(&bmc->dev->dev, 2225 err = device_create_file(&bmc->dev->dev,
1991 &bmc->device_id_attr); 2226 &bmc->device_id_attr);
1992 if (err) goto out; 2227 if (err) goto out;
@@ -2056,7 +2291,8 @@ out:
2056 return err; 2291 return err;
2057} 2292}
2058 2293
2059static int ipmi_bmc_register(ipmi_smi_t intf) 2294static int ipmi_bmc_register(ipmi_smi_t intf, int ifnum,
2295 const char *sysfs_name)
2060{ 2296{
2061 int rv; 2297 int rv;
2062 struct bmc_device *bmc = intf->bmc; 2298 struct bmc_device *bmc = intf->bmc;
@@ -2096,9 +2332,39 @@ static int ipmi_bmc_register(ipmi_smi_t intf)
2096 bmc->id.product_id, 2332 bmc->id.product_id,
2097 bmc->id.device_id); 2333 bmc->id.device_id);
2098 } else { 2334 } else {
2099 bmc->dev = platform_device_alloc("ipmi_bmc", 2335 char name[14];
2100 bmc->id.device_id); 2336 unsigned char orig_dev_id = bmc->id.device_id;
2337 int warn_printed = 0;
2338
2339 snprintf(name, sizeof(name),
2340 "ipmi_bmc.%4.4x", bmc->id.product_id);
2341
2342 while (ipmi_find_bmc_prod_dev_id(&ipmidriver,
2343 bmc->id.product_id,
2344 bmc->id.device_id))
2345 {
2346 if (!warn_printed) {
2347 printk(KERN_WARNING PFX
2348 "This machine has two different BMCs"
2349 " with the same product id and device"
2350 " id. This is an error in the"
2351 " firmware, but incrementing the"
2352 " device id to work around the problem."
2353 " Prod ID = 0x%x, Dev ID = 0x%x\n",
2354 bmc->id.product_id, bmc->id.device_id);
2355 warn_printed = 1;
2356 }
2357 bmc->id.device_id++; /* Wraps at 255 */
2358 if (bmc->id.device_id == orig_dev_id) {
2359 printk(KERN_ERR PFX
2360 "Out of device ids!\n");
2361 break;
2362 }
2363 }
2364
2365 bmc->dev = platform_device_alloc(name, bmc->id.device_id);
2101 if (!bmc->dev) { 2366 if (!bmc->dev) {
2367 mutex_unlock(&ipmidriver_mutex);
2102 printk(KERN_ERR 2368 printk(KERN_ERR
2103 "ipmi_msghandler:" 2369 "ipmi_msghandler:"
2104 " Unable to allocate platform device\n"); 2370 " Unable to allocate platform device\n");
@@ -2108,9 +2374,11 @@ static int ipmi_bmc_register(ipmi_smi_t intf)
2108 dev_set_drvdata(&bmc->dev->dev, bmc); 2374 dev_set_drvdata(&bmc->dev->dev, bmc);
2109 kref_init(&bmc->refcount); 2375 kref_init(&bmc->refcount);
2110 2376
2111 rv = platform_device_register(bmc->dev); 2377 rv = platform_device_add(bmc->dev);
2112 mutex_unlock(&ipmidriver_mutex); 2378 mutex_unlock(&ipmidriver_mutex);
2113 if (rv) { 2379 if (rv) {
2380 platform_device_put(bmc->dev);
2381 bmc->dev = NULL;
2114 printk(KERN_ERR 2382 printk(KERN_ERR
2115 "ipmi_msghandler:" 2383 "ipmi_msghandler:"
2116 " Unable to register bmc device: %d\n", 2384 " Unable to register bmc device: %d\n",
@@ -2120,57 +2388,6 @@ static int ipmi_bmc_register(ipmi_smi_t intf)
2120 return rv; 2388 return rv;
2121 } 2389 }
2122 2390
2123 bmc->device_id_attr.attr.name = "device_id";
2124 bmc->device_id_attr.attr.owner = THIS_MODULE;
2125 bmc->device_id_attr.attr.mode = S_IRUGO;
2126 bmc->device_id_attr.show = device_id_show;
2127
2128 bmc->provides_dev_sdrs_attr.attr.name = "provides_device_sdrs";
2129 bmc->provides_dev_sdrs_attr.attr.owner = THIS_MODULE;
2130 bmc->provides_dev_sdrs_attr.attr.mode = S_IRUGO;
2131 bmc->provides_dev_sdrs_attr.show = provides_dev_sdrs_show;
2132
2133 bmc->revision_attr.attr.name = "revision";
2134 bmc->revision_attr.attr.owner = THIS_MODULE;
2135 bmc->revision_attr.attr.mode = S_IRUGO;
2136 bmc->revision_attr.show = revision_show;
2137
2138 bmc->firmware_rev_attr.attr.name = "firmware_revision";
2139 bmc->firmware_rev_attr.attr.owner = THIS_MODULE;
2140 bmc->firmware_rev_attr.attr.mode = S_IRUGO;
2141 bmc->firmware_rev_attr.show = firmware_rev_show;
2142
2143 bmc->version_attr.attr.name = "ipmi_version";
2144 bmc->version_attr.attr.owner = THIS_MODULE;
2145 bmc->version_attr.attr.mode = S_IRUGO;
2146 bmc->version_attr.show = ipmi_version_show;
2147
2148 bmc->add_dev_support_attr.attr.name
2149 = "additional_device_support";
2150 bmc->add_dev_support_attr.attr.owner = THIS_MODULE;
2151 bmc->add_dev_support_attr.attr.mode = S_IRUGO;
2152 bmc->add_dev_support_attr.show = add_dev_support_show;
2153
2154 bmc->manufacturer_id_attr.attr.name = "manufacturer_id";
2155 bmc->manufacturer_id_attr.attr.owner = THIS_MODULE;
2156 bmc->manufacturer_id_attr.attr.mode = S_IRUGO;
2157 bmc->manufacturer_id_attr.show = manufacturer_id_show;
2158
2159 bmc->product_id_attr.attr.name = "product_id";
2160 bmc->product_id_attr.attr.owner = THIS_MODULE;
2161 bmc->product_id_attr.attr.mode = S_IRUGO;
2162 bmc->product_id_attr.show = product_id_show;
2163
2164 bmc->guid_attr.attr.name = "guid";
2165 bmc->guid_attr.attr.owner = THIS_MODULE;
2166 bmc->guid_attr.attr.mode = S_IRUGO;
2167 bmc->guid_attr.show = guid_show;
2168
2169 bmc->aux_firmware_rev_attr.attr.name = "aux_firmware_revision";
2170 bmc->aux_firmware_rev_attr.attr.owner = THIS_MODULE;
2171 bmc->aux_firmware_rev_attr.attr.mode = S_IRUGO;
2172 bmc->aux_firmware_rev_attr.show = aux_firmware_rev_show;
2173
2174 rv = create_files(bmc); 2391 rv = create_files(bmc);
2175 if (rv) { 2392 if (rv) {
2176 mutex_lock(&ipmidriver_mutex); 2393 mutex_lock(&ipmidriver_mutex);
@@ -2192,29 +2409,44 @@ static int ipmi_bmc_register(ipmi_smi_t intf)
2192 * create symlink from system interface device to bmc device 2409 * create symlink from system interface device to bmc device
2193 * and back. 2410 * and back.
2194 */ 2411 */
2412 intf->sysfs_name = kstrdup(sysfs_name, GFP_KERNEL);
2413 if (!intf->sysfs_name) {
2414 rv = -ENOMEM;
2415 printk(KERN_ERR
2416 "ipmi_msghandler: allocate link to BMC: %d\n",
2417 rv);
2418 goto out_err;
2419 }
2420
2195 rv = sysfs_create_link(&intf->si_dev->kobj, 2421 rv = sysfs_create_link(&intf->si_dev->kobj,
2196 &bmc->dev->dev.kobj, "bmc"); 2422 &bmc->dev->dev.kobj, intf->sysfs_name);
2197 if (rv) { 2423 if (rv) {
2424 kfree(intf->sysfs_name);
2425 intf->sysfs_name = NULL;
2198 printk(KERN_ERR 2426 printk(KERN_ERR
2199 "ipmi_msghandler: Unable to create bmc symlink: %d\n", 2427 "ipmi_msghandler: Unable to create bmc symlink: %d\n",
2200 rv); 2428 rv);
2201 goto out_err; 2429 goto out_err;
2202 } 2430 }
2203 2431
2204 size = snprintf(dummy, 0, "ipmi%d", intf->intf_num); 2432 size = snprintf(dummy, 0, "ipmi%d", ifnum);
2205 intf->my_dev_name = kmalloc(size+1, GFP_KERNEL); 2433 intf->my_dev_name = kmalloc(size+1, GFP_KERNEL);
2206 if (!intf->my_dev_name) { 2434 if (!intf->my_dev_name) {
2435 kfree(intf->sysfs_name);
2436 intf->sysfs_name = NULL;
2207 rv = -ENOMEM; 2437 rv = -ENOMEM;
2208 printk(KERN_ERR 2438 printk(KERN_ERR
2209 "ipmi_msghandler: allocate link from BMC: %d\n", 2439 "ipmi_msghandler: allocate link from BMC: %d\n",
2210 rv); 2440 rv);
2211 goto out_err; 2441 goto out_err;
2212 } 2442 }
2213 snprintf(intf->my_dev_name, size+1, "ipmi%d", intf->intf_num); 2443 snprintf(intf->my_dev_name, size+1, "ipmi%d", ifnum);
2214 2444
2215 rv = sysfs_create_link(&bmc->dev->dev.kobj, &intf->si_dev->kobj, 2445 rv = sysfs_create_link(&bmc->dev->dev.kobj, &intf->si_dev->kobj,
2216 intf->my_dev_name); 2446 intf->my_dev_name);
2217 if (rv) { 2447 if (rv) {
2448 kfree(intf->sysfs_name);
2449 intf->sysfs_name = NULL;
2218 kfree(intf->my_dev_name); 2450 kfree(intf->my_dev_name);
2219 intf->my_dev_name = NULL; 2451 intf->my_dev_name = NULL;
2220 printk(KERN_ERR 2452 printk(KERN_ERR
@@ -2399,17 +2631,14 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
2399 void *send_info, 2631 void *send_info,
2400 struct ipmi_device_id *device_id, 2632 struct ipmi_device_id *device_id,
2401 struct device *si_dev, 2633 struct device *si_dev,
2634 const char *sysfs_name,
2402 unsigned char slave_addr) 2635 unsigned char slave_addr)
2403{ 2636{
2404 int i, j; 2637 int i, j;
2405 int rv; 2638 int rv;
2406 ipmi_smi_t intf; 2639 ipmi_smi_t intf;
2407 unsigned long flags; 2640 ipmi_smi_t tintf;
2408 int version_major; 2641 struct list_head *link;
2409 int version_minor;
2410
2411 version_major = ipmi_version_major(device_id);
2412 version_minor = ipmi_version_minor(device_id);
2413 2642
2414 /* Make sure the driver is actually initialized, this handles 2643 /* Make sure the driver is actually initialized, this handles
2415 problems with initialization order. */ 2644 problems with initialization order. */
@@ -2427,12 +2656,16 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
2427 if (!intf) 2656 if (!intf)
2428 return -ENOMEM; 2657 return -ENOMEM;
2429 memset(intf, 0, sizeof(*intf)); 2658 memset(intf, 0, sizeof(*intf));
2659
2660 intf->ipmi_version_major = ipmi_version_major(device_id);
2661 intf->ipmi_version_minor = ipmi_version_minor(device_id);
2662
2430 intf->bmc = kzalloc(sizeof(*intf->bmc), GFP_KERNEL); 2663 intf->bmc = kzalloc(sizeof(*intf->bmc), GFP_KERNEL);
2431 if (!intf->bmc) { 2664 if (!intf->bmc) {
2432 kfree(intf); 2665 kfree(intf);
2433 return -ENOMEM; 2666 return -ENOMEM;
2434 } 2667 }
2435 intf->intf_num = -1; 2668 intf->intf_num = -1; /* Mark it invalid for now. */
2436 kref_init(&intf->refcount); 2669 kref_init(&intf->refcount);
2437 intf->bmc->id = *device_id; 2670 intf->bmc->id = *device_id;
2438 intf->si_dev = si_dev; 2671 intf->si_dev = si_dev;
@@ -2460,26 +2693,30 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
2460 INIT_LIST_HEAD(&intf->waiting_events); 2693 INIT_LIST_HEAD(&intf->waiting_events);
2461 intf->waiting_events_count = 0; 2694 intf->waiting_events_count = 0;
2462 mutex_init(&intf->cmd_rcvrs_mutex); 2695 mutex_init(&intf->cmd_rcvrs_mutex);
2696 spin_lock_init(&intf->maintenance_mode_lock);
2463 INIT_LIST_HEAD(&intf->cmd_rcvrs); 2697 INIT_LIST_HEAD(&intf->cmd_rcvrs);
2464 init_waitqueue_head(&intf->waitq); 2698 init_waitqueue_head(&intf->waitq);
2465 2699
2466 spin_lock_init(&intf->counter_lock); 2700 spin_lock_init(&intf->counter_lock);
2467 intf->proc_dir = NULL; 2701 intf->proc_dir = NULL;
2468 2702
2469 rv = -ENOMEM; 2703 mutex_lock(&smi_watchers_mutex);
2470 spin_lock_irqsave(&interfaces_lock, flags); 2704 mutex_lock(&ipmi_interfaces_mutex);
2471 for (i = 0; i < MAX_IPMI_INTERFACES; i++) { 2705 /* Look for a hole in the numbers. */
2472 if (ipmi_interfaces[i] == NULL) { 2706 i = 0;
2473 intf->intf_num = i; 2707 link = &ipmi_interfaces;
2474 /* Reserve the entry till we are done. */ 2708 list_for_each_entry_rcu(tintf, &ipmi_interfaces, link) {
2475 ipmi_interfaces[i] = IPMI_INVALID_INTERFACE_ENTRY; 2709 if (tintf->intf_num != i) {
2476 rv = 0; 2710 link = &tintf->link;
2477 break; 2711 break;
2478 } 2712 }
2713 i++;
2479 } 2714 }
2480 spin_unlock_irqrestore(&interfaces_lock, flags); 2715 /* Add the new interface in numeric order. */
2481 if (rv) 2716 if (i == 0)
2482 goto out; 2717 list_add_rcu(&intf->link, &ipmi_interfaces);
2718 else
2719 list_add_tail_rcu(&intf->link, link);
2483 2720
2484 rv = handlers->start_processing(send_info, intf); 2721 rv = handlers->start_processing(send_info, intf);
2485 if (rv) 2722 if (rv)
@@ -2487,8 +2724,9 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
2487 2724
2488 get_guid(intf); 2725 get_guid(intf);
2489 2726
2490 if ((version_major > 1) 2727 if ((intf->ipmi_version_major > 1)
2491 || ((version_major == 1) && (version_minor >= 5))) 2728 || ((intf->ipmi_version_major == 1)
2729 && (intf->ipmi_version_minor >= 5)))
2492 { 2730 {
2493 /* Start scanning the channels to see what is 2731 /* Start scanning the channels to see what is
2494 available. */ 2732 available. */
@@ -2511,64 +2749,67 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
2511 if (rv == 0) 2749 if (rv == 0)
2512 rv = add_proc_entries(intf, i); 2750 rv = add_proc_entries(intf, i);
2513 2751
2514 rv = ipmi_bmc_register(intf); 2752 rv = ipmi_bmc_register(intf, i, sysfs_name);
2515 2753
2516 out: 2754 out:
2517 if (rv) { 2755 if (rv) {
2518 if (intf->proc_dir) 2756 if (intf->proc_dir)
2519 remove_proc_entries(intf); 2757 remove_proc_entries(intf);
2758 intf->handlers = NULL;
2759 list_del_rcu(&intf->link);
2760 mutex_unlock(&ipmi_interfaces_mutex);
2761 mutex_unlock(&smi_watchers_mutex);
2762 synchronize_rcu();
2520 kref_put(&intf->refcount, intf_free); 2763 kref_put(&intf->refcount, intf_free);
2521 if (i < MAX_IPMI_INTERFACES) {
2522 spin_lock_irqsave(&interfaces_lock, flags);
2523 ipmi_interfaces[i] = NULL;
2524 spin_unlock_irqrestore(&interfaces_lock, flags);
2525 }
2526 } else { 2764 } else {
2527 spin_lock_irqsave(&interfaces_lock, flags); 2765 /* After this point the interface is legal to use. */
2528 ipmi_interfaces[i] = intf; 2766 intf->intf_num = i;
2529 spin_unlock_irqrestore(&interfaces_lock, flags); 2767 mutex_unlock(&ipmi_interfaces_mutex);
2530 call_smi_watchers(i, intf->si_dev); 2768 call_smi_watchers(i, intf->si_dev);
2769 mutex_unlock(&smi_watchers_mutex);
2531 } 2770 }
2532 2771
2533 return rv; 2772 return rv;
2534} 2773}
2535 2774
2775static void cleanup_smi_msgs(ipmi_smi_t intf)
2776{
2777 int i;
2778 struct seq_table *ent;
2779
2780 /* No need for locks, the interface is down. */
2781 for (i = 0; i < IPMI_IPMB_NUM_SEQ; i++) {
2782 ent = &(intf->seq_table[i]);
2783 if (!ent->inuse)
2784 continue;
2785 deliver_err_response(ent->recv_msg, IPMI_ERR_UNSPECIFIED);
2786 }
2787}
2788
2536int ipmi_unregister_smi(ipmi_smi_t intf) 2789int ipmi_unregister_smi(ipmi_smi_t intf)
2537{ 2790{
2538 int i;
2539 struct ipmi_smi_watcher *w; 2791 struct ipmi_smi_watcher *w;
2540 unsigned long flags; 2792 int intf_num = intf->intf_num;
2541 2793
2542 ipmi_bmc_unregister(intf); 2794 ipmi_bmc_unregister(intf);
2543 2795
2544 spin_lock_irqsave(&interfaces_lock, flags); 2796 mutex_lock(&smi_watchers_mutex);
2545 for (i = 0; i < MAX_IPMI_INTERFACES; i++) { 2797 mutex_lock(&ipmi_interfaces_mutex);
2546 if (ipmi_interfaces[i] == intf) { 2798 intf->intf_num = -1;
2547 /* Set the interface number reserved until we 2799 intf->handlers = NULL;
2548 * are done. */ 2800 list_del_rcu(&intf->link);
2549 ipmi_interfaces[i] = IPMI_INVALID_INTERFACE_ENTRY; 2801 mutex_unlock(&ipmi_interfaces_mutex);
2550 intf->intf_num = -1; 2802 synchronize_rcu();
2551 break;
2552 }
2553 }
2554 spin_unlock_irqrestore(&interfaces_lock,flags);
2555 2803
2556 if (i == MAX_IPMI_INTERFACES) 2804 cleanup_smi_msgs(intf);
2557 return -ENODEV;
2558 2805
2559 remove_proc_entries(intf); 2806 remove_proc_entries(intf);
2560 2807
2561 /* Call all the watcher interfaces to tell them that 2808 /* Call all the watcher interfaces to tell them that
2562 an interface is gone. */ 2809 an interface is gone. */
2563 down_read(&smi_watchers_sem);
2564 list_for_each_entry(w, &smi_watchers, link) 2810 list_for_each_entry(w, &smi_watchers, link)
2565 w->smi_gone(i); 2811 w->smi_gone(intf_num);
2566 up_read(&smi_watchers_sem); 2812 mutex_unlock(&smi_watchers_mutex);
2567
2568 /* Allow the entry to be reused now. */
2569 spin_lock_irqsave(&interfaces_lock, flags);
2570 ipmi_interfaces[i] = NULL;
2571 spin_unlock_irqrestore(&interfaces_lock,flags);
2572 2813
2573 kref_put(&intf->refcount, intf_free); 2814 kref_put(&intf->refcount, intf_free);
2574 return 0; 2815 return 0;
@@ -2650,6 +2891,7 @@ static int handle_ipmb_get_msg_cmd(ipmi_smi_t intf,
2650 struct ipmi_ipmb_addr *ipmb_addr; 2891 struct ipmi_ipmb_addr *ipmb_addr;
2651 struct ipmi_recv_msg *recv_msg; 2892 struct ipmi_recv_msg *recv_msg;
2652 unsigned long flags; 2893 unsigned long flags;
2894 struct ipmi_smi_handlers *handlers;
2653 2895
2654 if (msg->rsp_size < 10) { 2896 if (msg->rsp_size < 10) {
2655 /* Message not big enough, just ignore it. */ 2897 /* Message not big enough, just ignore it. */
@@ -2706,10 +2948,16 @@ static int handle_ipmb_get_msg_cmd(ipmi_smi_t intf,
2706 printk("\n"); 2948 printk("\n");
2707 } 2949 }
2708#endif 2950#endif
2709 intf->handlers->sender(intf->send_info, msg, 0); 2951 rcu_read_lock();
2710 2952 handlers = intf->handlers;
2711 rv = -1; /* We used the message, so return the value that 2953 if (handlers) {
2712 causes it to not be freed or queued. */ 2954 handlers->sender(intf->send_info, msg, 0);
2955 /* We used the message, so return the value
2956 that causes it to not be freed or
2957 queued. */
2958 rv = -1;
2959 }
2960 rcu_read_unlock();
2713 } else { 2961 } else {
2714 /* Deliver the message to the user. */ 2962 /* Deliver the message to the user. */
2715 spin_lock_irqsave(&intf->counter_lock, flags); 2963 spin_lock_irqsave(&intf->counter_lock, flags);
@@ -3232,7 +3480,9 @@ void ipmi_smi_msg_received(ipmi_smi_t intf,
3232 report the error immediately. */ 3480 report the error immediately. */
3233 if ((msg->rsp_size >= 3) && (msg->rsp[2] != 0) 3481 if ((msg->rsp_size >= 3) && (msg->rsp[2] != 0)
3234 && (msg->rsp[2] != IPMI_NODE_BUSY_ERR) 3482 && (msg->rsp[2] != IPMI_NODE_BUSY_ERR)
3235 && (msg->rsp[2] != IPMI_LOST_ARBITRATION_ERR)) 3483 && (msg->rsp[2] != IPMI_LOST_ARBITRATION_ERR)
3484 && (msg->rsp[2] != IPMI_BUS_ERR)
3485 && (msg->rsp[2] != IPMI_NAK_ON_WRITE_ERR))
3236 { 3486 {
3237 int chan = msg->rsp[3] & 0xf; 3487 int chan = msg->rsp[3] & 0xf;
3238 3488
@@ -3297,16 +3547,6 @@ void ipmi_smi_watchdog_pretimeout(ipmi_smi_t intf)
3297 rcu_read_unlock(); 3547 rcu_read_unlock();
3298} 3548}
3299 3549
3300static void
3301handle_msg_timeout(struct ipmi_recv_msg *msg)
3302{
3303 msg->recv_type = IPMI_RESPONSE_RECV_TYPE;
3304 msg->msg_data[0] = IPMI_TIMEOUT_COMPLETION_CODE;
3305 msg->msg.netfn |= 1; /* Convert to a response. */
3306 msg->msg.data_len = 1;
3307 msg->msg.data = msg->msg_data;
3308 deliver_response(msg);
3309}
3310 3550
3311static struct ipmi_smi_msg * 3551static struct ipmi_smi_msg *
3312smi_from_recv_msg(ipmi_smi_t intf, struct ipmi_recv_msg *recv_msg, 3552smi_from_recv_msg(ipmi_smi_t intf, struct ipmi_recv_msg *recv_msg,
@@ -3338,7 +3578,11 @@ static void check_msg_timeout(ipmi_smi_t intf, struct seq_table *ent,
3338 struct list_head *timeouts, long timeout_period, 3578 struct list_head *timeouts, long timeout_period,
3339 int slot, unsigned long *flags) 3579 int slot, unsigned long *flags)
3340{ 3580{
3341 struct ipmi_recv_msg *msg; 3581 struct ipmi_recv_msg *msg;
3582 struct ipmi_smi_handlers *handlers;
3583
3584 if (intf->intf_num == -1)
3585 return;
3342 3586
3343 if (!ent->inuse) 3587 if (!ent->inuse)
3344 return; 3588 return;
@@ -3381,13 +3625,19 @@ static void check_msg_timeout(ipmi_smi_t intf, struct seq_table *ent,
3381 return; 3625 return;
3382 3626
3383 spin_unlock_irqrestore(&intf->seq_lock, *flags); 3627 spin_unlock_irqrestore(&intf->seq_lock, *flags);
3628
3384 /* Send the new message. We send with a zero 3629 /* Send the new message. We send with a zero
3385 * priority. It timed out, I doubt time is 3630 * priority. It timed out, I doubt time is
3386 * that critical now, and high priority 3631 * that critical now, and high priority
3387 * messages are really only for messages to the 3632 * messages are really only for messages to the
3388 * local MC, which don't get resent. */ 3633 * local MC, which don't get resent. */
3389 intf->handlers->sender(intf->send_info, 3634 handlers = intf->handlers;
3390 smi_msg, 0); 3635 if (handlers)
3636 intf->handlers->sender(intf->send_info,
3637 smi_msg, 0);
3638 else
3639 ipmi_free_smi_msg(smi_msg);
3640
3391 spin_lock_irqsave(&intf->seq_lock, *flags); 3641 spin_lock_irqsave(&intf->seq_lock, *flags);
3392 } 3642 }
3393} 3643}
@@ -3399,18 +3649,12 @@ static void ipmi_timeout_handler(long timeout_period)
3399 struct ipmi_recv_msg *msg, *msg2; 3649 struct ipmi_recv_msg *msg, *msg2;
3400 struct ipmi_smi_msg *smi_msg, *smi_msg2; 3650 struct ipmi_smi_msg *smi_msg, *smi_msg2;
3401 unsigned long flags; 3651 unsigned long flags;
3402 int i, j; 3652 int i;
3403 3653
3404 INIT_LIST_HEAD(&timeouts); 3654 INIT_LIST_HEAD(&timeouts);
3405 3655
3406 spin_lock(&interfaces_lock); 3656 rcu_read_lock();
3407 for (i = 0; i < MAX_IPMI_INTERFACES; i++) { 3657 list_for_each_entry_rcu(intf, &ipmi_interfaces, link) {
3408 intf = ipmi_interfaces[i];
3409 if (IPMI_INVALID_INTERFACE(intf))
3410 continue;
3411 kref_get(&intf->refcount);
3412 spin_unlock(&interfaces_lock);
3413
3414 /* See if any waiting messages need to be processed. */ 3658 /* See if any waiting messages need to be processed. */
3415 spin_lock_irqsave(&intf->waiting_msgs_lock, flags); 3659 spin_lock_irqsave(&intf->waiting_msgs_lock, flags);
3416 list_for_each_entry_safe(smi_msg, smi_msg2, 3660 list_for_each_entry_safe(smi_msg, smi_msg2,
@@ -3430,35 +3674,60 @@ static void ipmi_timeout_handler(long timeout_period)
3430 have timed out, putting them in the timeouts 3674 have timed out, putting them in the timeouts
3431 list. */ 3675 list. */
3432 spin_lock_irqsave(&intf->seq_lock, flags); 3676 spin_lock_irqsave(&intf->seq_lock, flags);
3433 for (j = 0; j < IPMI_IPMB_NUM_SEQ; j++) 3677 for (i = 0; i < IPMI_IPMB_NUM_SEQ; i++)
3434 check_msg_timeout(intf, &(intf->seq_table[j]), 3678 check_msg_timeout(intf, &(intf->seq_table[i]),
3435 &timeouts, timeout_period, j, 3679 &timeouts, timeout_period, i,
3436 &flags); 3680 &flags);
3437 spin_unlock_irqrestore(&intf->seq_lock, flags); 3681 spin_unlock_irqrestore(&intf->seq_lock, flags);
3438 3682
3439 list_for_each_entry_safe(msg, msg2, &timeouts, link) 3683 list_for_each_entry_safe(msg, msg2, &timeouts, link)
3440 handle_msg_timeout(msg); 3684 deliver_err_response(msg, IPMI_TIMEOUT_COMPLETION_CODE);
3441 3685
3442 kref_put(&intf->refcount, intf_free); 3686 /*
3443 spin_lock(&interfaces_lock); 3687 * Maintenance mode handling. Check the timeout
3688 * optimistically before we claim the lock. It may
3689 * mean a timeout gets missed occasionally, but that
3690 * only means the timeout gets extended by one period
3691 * in that case. No big deal, and it avoids the lock
3692 * most of the time.
3693 */
3694 if (intf->auto_maintenance_timeout > 0) {
3695 spin_lock_irqsave(&intf->maintenance_mode_lock, flags);
3696 if (intf->auto_maintenance_timeout > 0) {
3697 intf->auto_maintenance_timeout
3698 -= timeout_period;
3699 if (!intf->maintenance_mode
3700 && (intf->auto_maintenance_timeout <= 0))
3701 {
3702 intf->maintenance_mode_enable = 0;
3703 maintenance_mode_update(intf);
3704 }
3705 }
3706 spin_unlock_irqrestore(&intf->maintenance_mode_lock,
3707 flags);
3708 }
3444 } 3709 }
3445 spin_unlock(&interfaces_lock); 3710 rcu_read_unlock();
3446} 3711}
3447 3712
3448static void ipmi_request_event(void) 3713static void ipmi_request_event(void)
3449{ 3714{
3450 ipmi_smi_t intf; 3715 ipmi_smi_t intf;
3451 int i; 3716 struct ipmi_smi_handlers *handlers;
3452 3717
3453 spin_lock(&interfaces_lock); 3718 rcu_read_lock();
3454 for (i = 0; i < MAX_IPMI_INTERFACES; i++) { 3719 /* Called from the timer, no need to check if handlers is
3455 intf = ipmi_interfaces[i]; 3720 * valid. */
3456 if (IPMI_INVALID_INTERFACE(intf)) 3721 list_for_each_entry_rcu(intf, &ipmi_interfaces, link) {
3722 /* No event requests when in maintenance mode. */
3723 if (intf->maintenance_mode_enable)
3457 continue; 3724 continue;
3458 3725
3459 intf->handlers->request_events(intf->send_info); 3726 handlers = intf->handlers;
3727 if (handlers)
3728 handlers->request_events(intf->send_info);
3460 } 3729 }
3461 spin_unlock(&interfaces_lock); 3730 rcu_read_unlock();
3462} 3731}
3463 3732
3464static struct timer_list ipmi_timer; 3733static struct timer_list ipmi_timer;
@@ -3587,7 +3856,6 @@ static void send_panic_events(char *str)
3587 struct kernel_ipmi_msg msg; 3856 struct kernel_ipmi_msg msg;
3588 ipmi_smi_t intf; 3857 ipmi_smi_t intf;
3589 unsigned char data[16]; 3858 unsigned char data[16];
3590 int i;
3591 struct ipmi_system_interface_addr *si; 3859 struct ipmi_system_interface_addr *si;
3592 struct ipmi_addr addr; 3860 struct ipmi_addr addr;
3593 struct ipmi_smi_msg smi_msg; 3861 struct ipmi_smi_msg smi_msg;
@@ -3621,9 +3889,9 @@ static void send_panic_events(char *str)
3621 recv_msg.done = dummy_recv_done_handler; 3889 recv_msg.done = dummy_recv_done_handler;
3622 3890
3623 /* For every registered interface, send the event. */ 3891 /* For every registered interface, send the event. */
3624 for (i = 0; i < MAX_IPMI_INTERFACES; i++) { 3892 list_for_each_entry_rcu(intf, &ipmi_interfaces, link) {
3625 intf = ipmi_interfaces[i]; 3893 if (!intf->handlers)
3626 if (IPMI_INVALID_INTERFACE(intf)) 3894 /* Interface is not ready. */
3627 continue; 3895 continue;
3628 3896
3629 /* Send the event announcing the panic. */ 3897 /* Send the event announcing the panic. */
@@ -3648,13 +3916,14 @@ static void send_panic_events(char *str)
3648 if (!str) 3916 if (!str)
3649 return; 3917 return;
3650 3918
3651 for (i = 0; i < MAX_IPMI_INTERFACES; i++) { 3919 /* For every registered interface, send the event. */
3920 list_for_each_entry_rcu(intf, &ipmi_interfaces, link) {
3652 char *p = str; 3921 char *p = str;
3653 struct ipmi_ipmb_addr *ipmb; 3922 struct ipmi_ipmb_addr *ipmb;
3654 int j; 3923 int j;
3655 3924
3656 intf = ipmi_interfaces[i]; 3925 if (intf->intf_num == -1)
3657 if (IPMI_INVALID_INTERFACE(intf)) 3926 /* Interface was not ready yet. */
3658 continue; 3927 continue;
3659 3928
3660 /* First job here is to figure out where to send the 3929 /* First job here is to figure out where to send the
@@ -3780,7 +4049,6 @@ static int panic_event(struct notifier_block *this,
3780 unsigned long event, 4049 unsigned long event,
3781 void *ptr) 4050 void *ptr)
3782{ 4051{
3783 int i;
3784 ipmi_smi_t intf; 4052 ipmi_smi_t intf;
3785 4053
3786 if (has_panicked) 4054 if (has_panicked)
@@ -3788,9 +4056,9 @@ static int panic_event(struct notifier_block *this,
3788 has_panicked = 1; 4056 has_panicked = 1;
3789 4057
3790 /* For every registered interface, set it to run to completion. */ 4058 /* For every registered interface, set it to run to completion. */
3791 for (i = 0; i < MAX_IPMI_INTERFACES; i++) { 4059 list_for_each_entry_rcu(intf, &ipmi_interfaces, link) {
3792 intf = ipmi_interfaces[i]; 4060 if (!intf->handlers)
3793 if (IPMI_INVALID_INTERFACE(intf)) 4061 /* Interface is not ready. */
3794 continue; 4062 continue;
3795 4063
3796 intf->handlers->set_run_to_completion(intf->send_info, 1); 4064 intf->handlers->set_run_to_completion(intf->send_info, 1);
@@ -3811,7 +4079,6 @@ static struct notifier_block panic_block = {
3811 4079
3812static int ipmi_init_msghandler(void) 4080static int ipmi_init_msghandler(void)
3813{ 4081{
3814 int i;
3815 int rv; 4082 int rv;
3816 4083
3817 if (initialized) 4084 if (initialized)
@@ -3826,9 +4093,6 @@ static int ipmi_init_msghandler(void)
3826 printk(KERN_INFO "ipmi message handler version " 4093 printk(KERN_INFO "ipmi message handler version "
3827 IPMI_DRIVER_VERSION "\n"); 4094 IPMI_DRIVER_VERSION "\n");
3828 4095
3829 for (i = 0; i < MAX_IPMI_INTERFACES; i++)
3830 ipmi_interfaces[i] = NULL;
3831
3832#ifdef CONFIG_PROC_FS 4096#ifdef CONFIG_PROC_FS
3833 proc_ipmi_root = proc_mkdir("ipmi", NULL); 4097 proc_ipmi_root = proc_mkdir("ipmi", NULL);
3834 if (!proc_ipmi_root) { 4098 if (!proc_ipmi_root) {
diff --git a/drivers/char/ipmi/ipmi_poweroff.c b/drivers/char/ipmi/ipmi_poweroff.c
index 8d941db83457..597eb4f88b84 100644
--- a/drivers/char/ipmi/ipmi_poweroff.c
+++ b/drivers/char/ipmi/ipmi_poweroff.c
@@ -43,6 +43,9 @@
43 43
44#define PFX "IPMI poweroff: " 44#define PFX "IPMI poweroff: "
45 45
46static void ipmi_po_smi_gone(int if_num);
47static void ipmi_po_new_smi(int if_num, struct device *device);
48
46/* Definitions for controlling power off (if the system supports it). It 49/* Definitions for controlling power off (if the system supports it). It
47 * conveniently matches the IPMI chassis control values. */ 50 * conveniently matches the IPMI chassis control values. */
48#define IPMI_CHASSIS_POWER_DOWN 0 /* power down, the default. */ 51#define IPMI_CHASSIS_POWER_DOWN 0 /* power down, the default. */
@@ -51,6 +54,37 @@
51/* the IPMI data command */ 54/* the IPMI data command */
52static int poweroff_powercycle; 55static int poweroff_powercycle;
53 56
57/* Which interface to use, -1 means the first we see. */
58static int ifnum_to_use = -1;
59
60/* Our local state. */
61static int ready = 0;
62static ipmi_user_t ipmi_user;
63static int ipmi_ifnum;
64static void (*specific_poweroff_func)(ipmi_user_t user) = NULL;
65
66/* Holds the old poweroff function so we can restore it on removal. */
67static void (*old_poweroff_func)(void);
68
69static int set_param_ifnum(const char *val, struct kernel_param *kp)
70{
71 int rv = param_set_int(val, kp);
72 if (rv)
73 return rv;
74 if ((ifnum_to_use < 0) || (ifnum_to_use == ipmi_ifnum))
75 return 0;
76
77 ipmi_po_smi_gone(ipmi_ifnum);
78 ipmi_po_new_smi(ifnum_to_use, NULL);
79 return 0;
80}
81
82module_param_call(ifnum_to_use, set_param_ifnum, param_get_int,
83 &ifnum_to_use, 0644);
84MODULE_PARM_DESC(ifnum_to_use, "The interface number to use for the watchdog "
85 "timer. Setting to -1 defaults to the first registered "
86 "interface");
87
54/* parameter definition to allow user to flag power cycle */ 88/* parameter definition to allow user to flag power cycle */
55module_param(poweroff_powercycle, int, 0644); 89module_param(poweroff_powercycle, int, 0644);
56MODULE_PARM_DESC(poweroff_powercycle, " Set to non-zero to enable power cycle instead of power down. Power cycle is contingent on hardware support, otherwise it defaults back to power down."); 90MODULE_PARM_DESC(poweroff_powercycle, " Set to non-zero to enable power cycle instead of power down. Power cycle is contingent on hardware support, otherwise it defaults back to power down.");
@@ -142,6 +176,42 @@ static int ipmi_request_in_rc_mode(ipmi_user_t user,
142#define IPMI_ATCA_GET_ADDR_INFO_CMD 0x01 176#define IPMI_ATCA_GET_ADDR_INFO_CMD 0x01
143#define IPMI_PICMG_ID 0 177#define IPMI_PICMG_ID 0
144 178
179#define IPMI_NETFN_OEM 0x2e
180#define IPMI_ATCA_PPS_GRACEFUL_RESTART 0x11
181#define IPMI_ATCA_PPS_IANA "\x00\x40\x0A"
182#define IPMI_MOTOROLA_MANUFACTURER_ID 0x0000A1
183#define IPMI_MOTOROLA_PPS_IPMC_PRODUCT_ID 0x0051
184
185static void (*atca_oem_poweroff_hook)(ipmi_user_t user) = NULL;
186
187static void pps_poweroff_atca (ipmi_user_t user)
188{
189 struct ipmi_system_interface_addr smi_addr;
190 struct kernel_ipmi_msg send_msg;
191 int rv;
192 /*
193 * Configure IPMI address for local access
194 */
195 smi_addr.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE;
196 smi_addr.channel = IPMI_BMC_CHANNEL;
197 smi_addr.lun = 0;
198
199 printk(KERN_INFO PFX "PPS powerdown hook used");
200
201 send_msg.netfn = IPMI_NETFN_OEM;
202 send_msg.cmd = IPMI_ATCA_PPS_GRACEFUL_RESTART;
203 send_msg.data = IPMI_ATCA_PPS_IANA;
204 send_msg.data_len = 3;
205 rv = ipmi_request_in_rc_mode(user,
206 (struct ipmi_addr *) &smi_addr,
207 &send_msg);
208 if (rv && rv != IPMI_UNKNOWN_ERR_COMPLETION_CODE) {
209 printk(KERN_ERR PFX "Unable to send ATCA ,"
210 " IPMI error 0x%x\n", rv);
211 }
212 return;
213}
214
145static int ipmi_atca_detect (ipmi_user_t user) 215static int ipmi_atca_detect (ipmi_user_t user)
146{ 216{
147 struct ipmi_system_interface_addr smi_addr; 217 struct ipmi_system_interface_addr smi_addr;
@@ -167,6 +237,13 @@ static int ipmi_atca_detect (ipmi_user_t user)
167 rv = ipmi_request_wait_for_response(user, 237 rv = ipmi_request_wait_for_response(user,
168 (struct ipmi_addr *) &smi_addr, 238 (struct ipmi_addr *) &smi_addr,
169 &send_msg); 239 &send_msg);
240
241 printk(KERN_INFO PFX "ATCA Detect mfg 0x%X prod 0x%X\n", mfg_id, prod_id);
242 if((mfg_id == IPMI_MOTOROLA_MANUFACTURER_ID)
243 && (prod_id == IPMI_MOTOROLA_PPS_IPMC_PRODUCT_ID)) {
244 printk(KERN_INFO PFX "Installing Pigeon Point Systems Poweroff Hook\n");
245 atca_oem_poweroff_hook = pps_poweroff_atca;
246 }
170 return !rv; 247 return !rv;
171} 248}
172 249
@@ -200,12 +277,19 @@ static void ipmi_poweroff_atca (ipmi_user_t user)
200 rv = ipmi_request_in_rc_mode(user, 277 rv = ipmi_request_in_rc_mode(user,
201 (struct ipmi_addr *) &smi_addr, 278 (struct ipmi_addr *) &smi_addr,
202 &send_msg); 279 &send_msg);
203 if (rv) { 280 /** At this point, the system may be shutting down, and most
281 ** serial drivers (if used) will have interrupts turned off
282 ** it may be better to ignore IPMI_UNKNOWN_ERR_COMPLETION_CODE
283 ** return code
284 **/
285 if (rv && rv != IPMI_UNKNOWN_ERR_COMPLETION_CODE) {
204 printk(KERN_ERR PFX "Unable to send ATCA powerdown message," 286 printk(KERN_ERR PFX "Unable to send ATCA powerdown message,"
205 " IPMI error 0x%x\n", rv); 287 " IPMI error 0x%x\n", rv);
206 goto out; 288 goto out;
207 } 289 }
208 290
291 if(atca_oem_poweroff_hook)
292 return atca_oem_poweroff_hook(user);
209 out: 293 out:
210 return; 294 return;
211} 295}
@@ -440,15 +524,6 @@ static struct poweroff_function poweroff_functions[] = {
440 / sizeof(struct poweroff_function)) 524 / sizeof(struct poweroff_function))
441 525
442 526
443/* Our local state. */
444static int ready = 0;
445static ipmi_user_t ipmi_user;
446static void (*specific_poweroff_func)(ipmi_user_t user) = NULL;
447
448/* Holds the old poweroff function so we can restore it on removal. */
449static void (*old_poweroff_func)(void);
450
451
452/* Called on a powerdown request. */ 527/* Called on a powerdown request. */
453static void ipmi_poweroff_function (void) 528static void ipmi_poweroff_function (void)
454{ 529{
@@ -473,6 +548,9 @@ static void ipmi_po_new_smi(int if_num, struct device *device)
473 if (ready) 548 if (ready)
474 return; 549 return;
475 550
551 if ((ifnum_to_use >= 0) && (ifnum_to_use != if_num))
552 return;
553
476 rv = ipmi_create_user(if_num, &ipmi_poweroff_handler, NULL, 554 rv = ipmi_create_user(if_num, &ipmi_poweroff_handler, NULL,
477 &ipmi_user); 555 &ipmi_user);
478 if (rv) { 556 if (rv) {
@@ -481,6 +559,8 @@ static void ipmi_po_new_smi(int if_num, struct device *device)
481 return; 559 return;
482 } 560 }
483 561
562 ipmi_ifnum = if_num;
563
484 /* 564 /*
485 * Do a get device ide and store some results, since this is 565 * Do a get device ide and store some results, since this is
486 * used by several functions. 566 * used by several functions.
@@ -541,9 +621,15 @@ static void ipmi_po_new_smi(int if_num, struct device *device)
541 621
542static void ipmi_po_smi_gone(int if_num) 622static void ipmi_po_smi_gone(int if_num)
543{ 623{
544 /* This can never be called, because once poweroff driver is 624 if (!ready)
545 registered, the interface can't go away until the power 625 return;
546 driver is unregistered. */ 626
627 if (ipmi_ifnum != if_num)
628 return;
629
630 ready = 0;
631 ipmi_destroy_user(ipmi_user);
632 pm_power_off = old_poweroff_func;
547} 633}
548 634
549static struct ipmi_smi_watcher smi_watcher = 635static struct ipmi_smi_watcher smi_watcher =
@@ -616,9 +702,9 @@ static int ipmi_poweroff_init (void)
616 printk(KERN_ERR PFX "Unable to register SMI watcher: %d\n", rv); 702 printk(KERN_ERR PFX "Unable to register SMI watcher: %d\n", rv);
617 goto out_err; 703 goto out_err;
618 } 704 }
619#endif
620 705
621 out_err: 706 out_err:
707#endif
622 return rv; 708 return rv;
623} 709}
624 710
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index 157fa81a264f..81a0c89598e7 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -61,6 +61,10 @@
61#include "ipmi_si_sm.h" 61#include "ipmi_si_sm.h"
62#include <linux/init.h> 62#include <linux/init.h>
63#include <linux/dmi.h> 63#include <linux/dmi.h>
64#include <linux/string.h>
65#include <linux/ctype.h>
66
67#define PFX "ipmi_si: "
64 68
65/* Measure times between events in the driver. */ 69/* Measure times between events in the driver. */
66#undef DEBUG_TIMING 70#undef DEBUG_TIMING
@@ -92,7 +96,7 @@ enum si_intf_state {
92enum si_type { 96enum si_type {
93 SI_KCS, SI_SMIC, SI_BT 97 SI_KCS, SI_SMIC, SI_BT
94}; 98};
95static char *si_to_str[] = { "KCS", "SMIC", "BT" }; 99static char *si_to_str[] = { "kcs", "smic", "bt" };
96 100
97#define DEVICE_NAME "ipmi_si" 101#define DEVICE_NAME "ipmi_si"
98 102
@@ -222,7 +226,10 @@ struct smi_info
222static int force_kipmid[SI_MAX_PARMS]; 226static int force_kipmid[SI_MAX_PARMS];
223static int num_force_kipmid; 227static int num_force_kipmid;
224 228
229static int unload_when_empty = 1;
230
225static int try_smi_init(struct smi_info *smi); 231static int try_smi_init(struct smi_info *smi);
232static void cleanup_one_si(struct smi_info *to_clean);
226 233
227static ATOMIC_NOTIFIER_HEAD(xaction_notifier_list); 234static ATOMIC_NOTIFIER_HEAD(xaction_notifier_list);
228static int register_xaction_notifier(struct notifier_block * nb) 235static int register_xaction_notifier(struct notifier_block * nb)
@@ -240,14 +247,18 @@ static void deliver_recv_msg(struct smi_info *smi_info,
240 spin_lock(&(smi_info->si_lock)); 247 spin_lock(&(smi_info->si_lock));
241} 248}
242 249
243static void return_hosed_msg(struct smi_info *smi_info) 250static void return_hosed_msg(struct smi_info *smi_info, int cCode)
244{ 251{
245 struct ipmi_smi_msg *msg = smi_info->curr_msg; 252 struct ipmi_smi_msg *msg = smi_info->curr_msg;
246 253
254 if (cCode < 0 || cCode > IPMI_ERR_UNSPECIFIED)
255 cCode = IPMI_ERR_UNSPECIFIED;
256 /* else use it as is */
257
247 /* Make it a reponse */ 258 /* Make it a reponse */
248 msg->rsp[0] = msg->data[0] | 4; 259 msg->rsp[0] = msg->data[0] | 4;
249 msg->rsp[1] = msg->data[1]; 260 msg->rsp[1] = msg->data[1];
250 msg->rsp[2] = 0xFF; /* Unknown error. */ 261 msg->rsp[2] = cCode;
251 msg->rsp_size = 3; 262 msg->rsp_size = 3;
252 263
253 smi_info->curr_msg = NULL; 264 smi_info->curr_msg = NULL;
@@ -298,7 +309,7 @@ static enum si_sm_result start_next_msg(struct smi_info *smi_info)
298 smi_info->curr_msg->data, 309 smi_info->curr_msg->data,
299 smi_info->curr_msg->data_size); 310 smi_info->curr_msg->data_size);
300 if (err) { 311 if (err) {
301 return_hosed_msg(smi_info); 312 return_hosed_msg(smi_info, err);
302 } 313 }
303 314
304 rv = SI_SM_CALL_WITHOUT_DELAY; 315 rv = SI_SM_CALL_WITHOUT_DELAY;
@@ -640,7 +651,7 @@ static enum si_sm_result smi_event_handler(struct smi_info *smi_info,
640 /* If we were handling a user message, format 651 /* If we were handling a user message, format
641 a response to send to the upper layer to 652 a response to send to the upper layer to
642 tell it about the error. */ 653 tell it about the error. */
643 return_hosed_msg(smi_info); 654 return_hosed_msg(smi_info, IPMI_ERR_UNSPECIFIED);
644 } 655 }
645 si_sm_result = smi_info->handlers->event(smi_info->si_sm, 0); 656 si_sm_result = smi_info->handlers->event(smi_info->si_sm, 0);
646 } 657 }
@@ -684,22 +695,24 @@ static enum si_sm_result smi_event_handler(struct smi_info *smi_info,
684 { 695 {
685 /* We are idle and the upper layer requested that I fetch 696 /* We are idle and the upper layer requested that I fetch
686 events, so do so. */ 697 events, so do so. */
687 unsigned char msg[2]; 698 atomic_set(&smi_info->req_events, 0);
688 699
689 spin_lock(&smi_info->count_lock); 700 smi_info->curr_msg = ipmi_alloc_smi_msg();
690 smi_info->flag_fetches++; 701 if (!smi_info->curr_msg)
691 spin_unlock(&smi_info->count_lock); 702 goto out;
692 703
693 atomic_set(&smi_info->req_events, 0); 704 smi_info->curr_msg->data[0] = (IPMI_NETFN_APP_REQUEST << 2);
694 msg[0] = (IPMI_NETFN_APP_REQUEST << 2); 705 smi_info->curr_msg->data[1] = IPMI_READ_EVENT_MSG_BUFFER_CMD;
695 msg[1] = IPMI_GET_MSG_FLAGS_CMD; 706 smi_info->curr_msg->data_size = 2;
696 707
697 smi_info->handlers->start_transaction( 708 smi_info->handlers->start_transaction(
698 smi_info->si_sm, msg, 2); 709 smi_info->si_sm,
699 smi_info->si_state = SI_GETTING_FLAGS; 710 smi_info->curr_msg->data,
711 smi_info->curr_msg->data_size);
712 smi_info->si_state = SI_GETTING_EVENTS;
700 goto restart; 713 goto restart;
701 } 714 }
702 715 out:
703 return si_sm_result; 716 return si_sm_result;
704} 717}
705 718
@@ -714,6 +727,15 @@ static void sender(void *send_info,
714 struct timeval t; 727 struct timeval t;
715#endif 728#endif
716 729
730 if (atomic_read(&smi_info->stop_operation)) {
731 msg->rsp[0] = msg->data[0] | 4;
732 msg->rsp[1] = msg->data[1];
733 msg->rsp[2] = IPMI_ERR_UNSPECIFIED;
734 msg->rsp_size = 3;
735 deliver_recv_msg(smi_info, msg);
736 return;
737 }
738
717 spin_lock_irqsave(&(smi_info->msg_lock), flags); 739 spin_lock_irqsave(&(smi_info->msg_lock), flags);
718#ifdef DEBUG_TIMING 740#ifdef DEBUG_TIMING
719 do_gettimeofday(&t); 741 do_gettimeofday(&t);
@@ -805,13 +827,21 @@ static void poll(void *send_info)
805{ 827{
806 struct smi_info *smi_info = send_info; 828 struct smi_info *smi_info = send_info;
807 829
808 smi_event_handler(smi_info, 0); 830 /*
831 * Make sure there is some delay in the poll loop so we can
832 * drive time forward and timeout things.
833 */
834 udelay(10);
835 smi_event_handler(smi_info, 10);
809} 836}
810 837
811static void request_events(void *send_info) 838static void request_events(void *send_info)
812{ 839{
813 struct smi_info *smi_info = send_info; 840 struct smi_info *smi_info = send_info;
814 841
842 if (atomic_read(&smi_info->stop_operation))
843 return;
844
815 atomic_set(&smi_info->req_events, 1); 845 atomic_set(&smi_info->req_events, 1);
816} 846}
817 847
@@ -949,12 +979,21 @@ static int smi_start_processing(void *send_info,
949 return 0; 979 return 0;
950} 980}
951 981
982static void set_maintenance_mode(void *send_info, int enable)
983{
984 struct smi_info *smi_info = send_info;
985
986 if (!enable)
987 atomic_set(&smi_info->req_events, 0);
988}
989
952static struct ipmi_smi_handlers handlers = 990static struct ipmi_smi_handlers handlers =
953{ 991{
954 .owner = THIS_MODULE, 992 .owner = THIS_MODULE,
955 .start_processing = smi_start_processing, 993 .start_processing = smi_start_processing,
956 .sender = sender, 994 .sender = sender,
957 .request_events = request_events, 995 .request_events = request_events,
996 .set_maintenance_mode = set_maintenance_mode,
958 .set_run_to_completion = set_run_to_completion, 997 .set_run_to_completion = set_run_to_completion,
959 .poll = poll, 998 .poll = poll,
960}; 999};
@@ -987,6 +1026,16 @@ static int num_regshifts = 0;
987static int slave_addrs[SI_MAX_PARMS]; 1026static int slave_addrs[SI_MAX_PARMS];
988static int num_slave_addrs = 0; 1027static int num_slave_addrs = 0;
989 1028
1029#define IPMI_IO_ADDR_SPACE 0
1030#define IPMI_MEM_ADDR_SPACE 1
1031static char *addr_space_to_str[] = { "I/O", "mem" };
1032
1033static int hotmod_handler(const char *val, struct kernel_param *kp);
1034
1035module_param_call(hotmod, hotmod_handler, NULL, NULL, 0200);
1036MODULE_PARM_DESC(hotmod, "Add and remove interfaces. See"
1037 " Documentation/IPMI.txt in the kernel sources for the"
1038 " gory details.");
990 1039
991module_param_named(trydefaults, si_trydefaults, bool, 0); 1040module_param_named(trydefaults, si_trydefaults, bool, 0);
992MODULE_PARM_DESC(trydefaults, "Setting this to 'false' will disable the" 1041MODULE_PARM_DESC(trydefaults, "Setting this to 'false' will disable the"
@@ -1038,12 +1087,12 @@ module_param_array(force_kipmid, int, &num_force_kipmid, 0);
1038MODULE_PARM_DESC(force_kipmid, "Force the kipmi daemon to be enabled (1) or" 1087MODULE_PARM_DESC(force_kipmid, "Force the kipmi daemon to be enabled (1) or"
1039 " disabled(0). Normally the IPMI driver auto-detects" 1088 " disabled(0). Normally the IPMI driver auto-detects"
1040 " this, but the value may be overridden by this parm."); 1089 " this, but the value may be overridden by this parm.");
1090module_param(unload_when_empty, int, 0);
1091MODULE_PARM_DESC(unload_when_empty, "Unload the module if no interfaces are"
1092 " specified or found, default is 1. Setting to 0"
1093 " is useful for hot add of devices using hotmod.");
1041 1094
1042 1095
1043#define IPMI_IO_ADDR_SPACE 0
1044#define IPMI_MEM_ADDR_SPACE 1
1045static char *addr_space_to_str[] = { "I/O", "memory" };
1046
1047static void std_irq_cleanup(struct smi_info *info) 1096static void std_irq_cleanup(struct smi_info *info)
1048{ 1097{
1049 if (info->si_type == SI_BT) 1098 if (info->si_type == SI_BT)
@@ -1211,7 +1260,7 @@ static void intf_mem_outb(struct si_sm_io *io, unsigned int offset,
1211static unsigned char intf_mem_inw(struct si_sm_io *io, unsigned int offset) 1260static unsigned char intf_mem_inw(struct si_sm_io *io, unsigned int offset)
1212{ 1261{
1213 return (readw((io->addr)+(offset * io->regspacing)) >> io->regshift) 1262 return (readw((io->addr)+(offset * io->regspacing)) >> io->regshift)
1214 && 0xff; 1263 & 0xff;
1215} 1264}
1216 1265
1217static void intf_mem_outw(struct si_sm_io *io, unsigned int offset, 1266static void intf_mem_outw(struct si_sm_io *io, unsigned int offset,
@@ -1223,7 +1272,7 @@ static void intf_mem_outw(struct si_sm_io *io, unsigned int offset,
1223static unsigned char intf_mem_inl(struct si_sm_io *io, unsigned int offset) 1272static unsigned char intf_mem_inl(struct si_sm_io *io, unsigned int offset)
1224{ 1273{
1225 return (readl((io->addr)+(offset * io->regspacing)) >> io->regshift) 1274 return (readl((io->addr)+(offset * io->regspacing)) >> io->regshift)
1226 && 0xff; 1275 & 0xff;
1227} 1276}
1228 1277
1229static void intf_mem_outl(struct si_sm_io *io, unsigned int offset, 1278static void intf_mem_outl(struct si_sm_io *io, unsigned int offset,
@@ -1236,7 +1285,7 @@ static void intf_mem_outl(struct si_sm_io *io, unsigned int offset,
1236static unsigned char mem_inq(struct si_sm_io *io, unsigned int offset) 1285static unsigned char mem_inq(struct si_sm_io *io, unsigned int offset)
1237{ 1286{
1238 return (readq((io->addr)+(offset * io->regspacing)) >> io->regshift) 1287 return (readq((io->addr)+(offset * io->regspacing)) >> io->regshift)
1239 && 0xff; 1288 & 0xff;
1240} 1289}
1241 1290
1242static void mem_outq(struct si_sm_io *io, unsigned int offset, 1291static void mem_outq(struct si_sm_io *io, unsigned int offset,
@@ -1317,6 +1366,234 @@ static int mem_setup(struct smi_info *info)
1317 return 0; 1366 return 0;
1318} 1367}
1319 1368
1369/*
1370 * Parms come in as <op1>[:op2[:op3...]]. ops are:
1371 * add|remove,kcs|bt|smic,mem|i/o,<address>[,<opt1>[,<opt2>[,...]]]
1372 * Options are:
1373 * rsp=<regspacing>
1374 * rsi=<regsize>
1375 * rsh=<regshift>
1376 * irq=<irq>
1377 * ipmb=<ipmb addr>
1378 */
1379enum hotmod_op { HM_ADD, HM_REMOVE };
1380struct hotmod_vals {
1381 char *name;
1382 int val;
1383};
1384static struct hotmod_vals hotmod_ops[] = {
1385 { "add", HM_ADD },
1386 { "remove", HM_REMOVE },
1387 { NULL }
1388};
1389static struct hotmod_vals hotmod_si[] = {
1390 { "kcs", SI_KCS },
1391 { "smic", SI_SMIC },
1392 { "bt", SI_BT },
1393 { NULL }
1394};
1395static struct hotmod_vals hotmod_as[] = {
1396 { "mem", IPMI_MEM_ADDR_SPACE },
1397 { "i/o", IPMI_IO_ADDR_SPACE },
1398 { NULL }
1399};
1400static int ipmi_strcasecmp(const char *s1, const char *s2)
1401{
1402 while (*s1 || *s2) {
1403 if (!*s1)
1404 return -1;
1405 if (!*s2)
1406 return 1;
1407 if (*s1 != *s2)
1408 return *s1 - *s2;
1409 s1++;
1410 s2++;
1411 }
1412 return 0;
1413}
1414static int parse_str(struct hotmod_vals *v, int *val, char *name, char **curr)
1415{
1416 char *s;
1417 int i;
1418
1419 s = strchr(*curr, ',');
1420 if (!s) {
1421 printk(KERN_WARNING PFX "No hotmod %s given.\n", name);
1422 return -EINVAL;
1423 }
1424 *s = '\0';
1425 s++;
1426 for (i = 0; hotmod_ops[i].name; i++) {
1427 if (ipmi_strcasecmp(*curr, v[i].name) == 0) {
1428 *val = v[i].val;
1429 *curr = s;
1430 return 0;
1431 }
1432 }
1433
1434 printk(KERN_WARNING PFX "Invalid hotmod %s '%s'\n", name, *curr);
1435 return -EINVAL;
1436}
1437
1438static int hotmod_handler(const char *val, struct kernel_param *kp)
1439{
1440 char *str = kstrdup(val, GFP_KERNEL);
1441 int rv = -EINVAL;
1442 char *next, *curr, *s, *n, *o;
1443 enum hotmod_op op;
1444 enum si_type si_type;
1445 int addr_space;
1446 unsigned long addr;
1447 int regspacing;
1448 int regsize;
1449 int regshift;
1450 int irq;
1451 int ipmb;
1452 int ival;
1453 struct smi_info *info;
1454
1455 if (!str)
1456 return -ENOMEM;
1457
1458 /* Kill any trailing spaces, as we can get a "\n" from echo. */
1459 ival = strlen(str) - 1;
1460 while ((ival >= 0) && isspace(str[ival])) {
1461 str[ival] = '\0';
1462 ival--;
1463 }
1464
1465 for (curr = str; curr; curr = next) {
1466 regspacing = 1;
1467 regsize = 1;
1468 regshift = 0;
1469 irq = 0;
1470 ipmb = 0x20;
1471
1472 next = strchr(curr, ':');
1473 if (next) {
1474 *next = '\0';
1475 next++;
1476 }
1477
1478 rv = parse_str(hotmod_ops, &ival, "operation", &curr);
1479 if (rv)
1480 break;
1481 op = ival;
1482
1483 rv = parse_str(hotmod_si, &ival, "interface type", &curr);
1484 if (rv)
1485 break;
1486 si_type = ival;
1487
1488 rv = parse_str(hotmod_as, &addr_space, "address space", &curr);
1489 if (rv)
1490 break;
1491
1492 s = strchr(curr, ',');
1493 if (s) {
1494 *s = '\0';
1495 s++;
1496 }
1497 addr = simple_strtoul(curr, &n, 0);
1498 if ((*n != '\0') || (*curr == '\0')) {
1499 printk(KERN_WARNING PFX "Invalid hotmod address"
1500 " '%s'\n", curr);
1501 break;
1502 }
1503
1504 while (s) {
1505 curr = s;
1506 s = strchr(curr, ',');
1507 if (s) {
1508 *s = '\0';
1509 s++;
1510 }
1511 o = strchr(curr, '=');
1512 if (o) {
1513 *o = '\0';
1514 o++;
1515 }
1516#define HOTMOD_INT_OPT(name, val) \
1517 if (ipmi_strcasecmp(curr, name) == 0) { \
1518 if (!o) { \
1519 printk(KERN_WARNING PFX \
1520 "No option given for '%s'\n", \
1521 curr); \
1522 goto out; \
1523 } \
1524 val = simple_strtoul(o, &n, 0); \
1525 if ((*n != '\0') || (*o == '\0')) { \
1526 printk(KERN_WARNING PFX \
1527 "Bad option given for '%s'\n", \
1528 curr); \
1529 goto out; \
1530 } \
1531 }
1532
1533 HOTMOD_INT_OPT("rsp", regspacing)
1534 else HOTMOD_INT_OPT("rsi", regsize)
1535 else HOTMOD_INT_OPT("rsh", regshift)
1536 else HOTMOD_INT_OPT("irq", irq)
1537 else HOTMOD_INT_OPT("ipmb", ipmb)
1538 else {
1539 printk(KERN_WARNING PFX
1540 "Invalid hotmod option '%s'\n",
1541 curr);
1542 goto out;
1543 }
1544#undef HOTMOD_INT_OPT
1545 }
1546
1547 if (op == HM_ADD) {
1548 info = kzalloc(sizeof(*info), GFP_KERNEL);
1549 if (!info) {
1550 rv = -ENOMEM;
1551 goto out;
1552 }
1553
1554 info->addr_source = "hotmod";
1555 info->si_type = si_type;
1556 info->io.addr_data = addr;
1557 info->io.addr_type = addr_space;
1558 if (addr_space == IPMI_MEM_ADDR_SPACE)
1559 info->io_setup = mem_setup;
1560 else
1561 info->io_setup = port_setup;
1562
1563 info->io.addr = NULL;
1564 info->io.regspacing = regspacing;
1565 if (!info->io.regspacing)
1566 info->io.regspacing = DEFAULT_REGSPACING;
1567 info->io.regsize = regsize;
1568 if (!info->io.regsize)
1569 info->io.regsize = DEFAULT_REGSPACING;
1570 info->io.regshift = regshift;
1571 info->irq = irq;
1572 if (info->irq)
1573 info->irq_setup = std_irq_setup;
1574 info->slave_addr = ipmb;
1575
1576 try_smi_init(info);
1577 } else {
1578 /* remove */
1579 struct smi_info *e, *tmp_e;
1580
1581 mutex_lock(&smi_infos_lock);
1582 list_for_each_entry_safe(e, tmp_e, &smi_infos, link) {
1583 if (e->io.addr_type != addr_space)
1584 continue;
1585 if (e->si_type != si_type)
1586 continue;
1587 if (e->io.addr_data == addr)
1588 cleanup_one_si(e);
1589 }
1590 mutex_unlock(&smi_infos_lock);
1591 }
1592 }
1593 out:
1594 kfree(str);
1595 return rv;
1596}
1320 1597
1321static __devinit void hardcode_find_bmc(void) 1598static __devinit void hardcode_find_bmc(void)
1322{ 1599{
@@ -1333,11 +1610,11 @@ static __devinit void hardcode_find_bmc(void)
1333 1610
1334 info->addr_source = "hardcoded"; 1611 info->addr_source = "hardcoded";
1335 1612
1336 if (!si_type[i] || strcmp(si_type[i], "kcs") == 0) { 1613 if (!si_type[i] || ipmi_strcasecmp(si_type[i], "kcs") == 0) {
1337 info->si_type = SI_KCS; 1614 info->si_type = SI_KCS;
1338 } else if (strcmp(si_type[i], "smic") == 0) { 1615 } else if (ipmi_strcasecmp(si_type[i], "smic") == 0) {
1339 info->si_type = SI_SMIC; 1616 info->si_type = SI_SMIC;
1340 } else if (strcmp(si_type[i], "bt") == 0) { 1617 } else if (ipmi_strcasecmp(si_type[i], "bt") == 0) {
1341 info->si_type = SI_BT; 1618 info->si_type = SI_BT;
1342 } else { 1619 } else {
1343 printk(KERN_WARNING 1620 printk(KERN_WARNING
@@ -1952,19 +2229,9 @@ static int try_get_dev_id(struct smi_info *smi_info)
1952static int type_file_read_proc(char *page, char **start, off_t off, 2229static int type_file_read_proc(char *page, char **start, off_t off,
1953 int count, int *eof, void *data) 2230 int count, int *eof, void *data)
1954{ 2231{
1955 char *out = (char *) page;
1956 struct smi_info *smi = data; 2232 struct smi_info *smi = data;
1957 2233
1958 switch (smi->si_type) { 2234 return sprintf(page, "%s\n", si_to_str[smi->si_type]);
1959 case SI_KCS:
1960 return sprintf(out, "kcs\n");
1961 case SI_SMIC:
1962 return sprintf(out, "smic\n");
1963 case SI_BT:
1964 return sprintf(out, "bt\n");
1965 default:
1966 return 0;
1967 }
1968} 2235}
1969 2236
1970static int stat_file_read_proc(char *page, char **start, off_t off, 2237static int stat_file_read_proc(char *page, char **start, off_t off,
@@ -2000,7 +2267,24 @@ static int stat_file_read_proc(char *page, char **start, off_t off,
2000 out += sprintf(out, "incoming_messages: %ld\n", 2267 out += sprintf(out, "incoming_messages: %ld\n",
2001 smi->incoming_messages); 2268 smi->incoming_messages);
2002 2269
2003 return (out - ((char *) page)); 2270 return out - page;
2271}
2272
2273static int param_read_proc(char *page, char **start, off_t off,
2274 int count, int *eof, void *data)
2275{
2276 struct smi_info *smi = data;
2277
2278 return sprintf(page,
2279 "%s,%s,0x%lx,rsp=%d,rsi=%d,rsh=%d,irq=%d,ipmb=%d\n",
2280 si_to_str[smi->si_type],
2281 addr_space_to_str[smi->io.addr_type],
2282 smi->io.addr_data,
2283 smi->io.regspacing,
2284 smi->io.regsize,
2285 smi->io.regshift,
2286 smi->irq,
2287 smi->slave_addr);
2004} 2288}
2005 2289
2006/* 2290/*
@@ -2346,7 +2630,7 @@ static int try_smi_init(struct smi_info *new_smi)
2346 new_smi->dev = &new_smi->pdev->dev; 2630 new_smi->dev = &new_smi->pdev->dev;
2347 new_smi->dev->driver = &ipmi_driver; 2631 new_smi->dev->driver = &ipmi_driver;
2348 2632
2349 rv = platform_device_register(new_smi->pdev); 2633 rv = platform_device_add(new_smi->pdev);
2350 if (rv) { 2634 if (rv) {
2351 printk(KERN_ERR 2635 printk(KERN_ERR
2352 "ipmi_si_intf:" 2636 "ipmi_si_intf:"
@@ -2362,6 +2646,7 @@ static int try_smi_init(struct smi_info *new_smi)
2362 new_smi, 2646 new_smi,
2363 &new_smi->device_id, 2647 &new_smi->device_id,
2364 new_smi->dev, 2648 new_smi->dev,
2649 "bmc",
2365 new_smi->slave_addr); 2650 new_smi->slave_addr);
2366 if (rv) { 2651 if (rv) {
2367 printk(KERN_ERR 2652 printk(KERN_ERR
@@ -2390,6 +2675,16 @@ static int try_smi_init(struct smi_info *new_smi)
2390 goto out_err_stop_timer; 2675 goto out_err_stop_timer;
2391 } 2676 }
2392 2677
2678 rv = ipmi_smi_add_proc_entry(new_smi->intf, "params",
2679 param_read_proc, NULL,
2680 new_smi, THIS_MODULE);
2681 if (rv) {
2682 printk(KERN_ERR
2683 "ipmi_si: Unable to create proc entry: %d\n",
2684 rv);
2685 goto out_err_stop_timer;
2686 }
2687
2393 list_add_tail(&new_smi->link, &smi_infos); 2688 list_add_tail(&new_smi->link, &smi_infos);
2394 2689
2395 mutex_unlock(&smi_infos_lock); 2690 mutex_unlock(&smi_infos_lock);
@@ -2483,7 +2778,12 @@ static __devinit int init_ipmi_si(void)
2483#endif 2778#endif
2484 2779
2485#ifdef CONFIG_PCI 2780#ifdef CONFIG_PCI
2486 pci_module_init(&ipmi_pci_driver); 2781 rv = pci_register_driver(&ipmi_pci_driver);
2782 if (rv){
2783 printk(KERN_ERR
2784 "init_ipmi_si: Unable to register PCI driver: %d\n",
2785 rv);
2786 }
2487#endif 2787#endif
2488 2788
2489 if (si_trydefaults) { 2789 if (si_trydefaults) {
@@ -2498,7 +2798,7 @@ static __devinit int init_ipmi_si(void)
2498 } 2798 }
2499 2799
2500 mutex_lock(&smi_infos_lock); 2800 mutex_lock(&smi_infos_lock);
2501 if (list_empty(&smi_infos)) { 2801 if (unload_when_empty && list_empty(&smi_infos)) {
2502 mutex_unlock(&smi_infos_lock); 2802 mutex_unlock(&smi_infos_lock);
2503#ifdef CONFIG_PCI 2803#ifdef CONFIG_PCI
2504 pci_unregister_driver(&ipmi_pci_driver); 2804 pci_unregister_driver(&ipmi_pci_driver);
@@ -2513,7 +2813,7 @@ static __devinit int init_ipmi_si(void)
2513} 2813}
2514module_init(init_ipmi_si); 2814module_init(init_ipmi_si);
2515 2815
2516static void __devexit cleanup_one_si(struct smi_info *to_clean) 2816static void cleanup_one_si(struct smi_info *to_clean)
2517{ 2817{
2518 int rv; 2818 int rv;
2519 unsigned long flags; 2819 unsigned long flags;
diff --git a/drivers/char/ipmi/ipmi_smic_sm.c b/drivers/char/ipmi/ipmi_smic_sm.c
index 39d7e5ef1a2b..e64ea7d25d24 100644
--- a/drivers/char/ipmi/ipmi_smic_sm.c
+++ b/drivers/char/ipmi/ipmi_smic_sm.c
@@ -141,12 +141,14 @@ static int start_smic_transaction(struct si_sm_data *smic,
141{ 141{
142 unsigned int i; 142 unsigned int i;
143 143
144 if ((size < 2) || (size > MAX_SMIC_WRITE_SIZE)) { 144 if (size < 2)
145 return -1; 145 return IPMI_REQ_LEN_INVALID_ERR;
146 } 146 if (size > MAX_SMIC_WRITE_SIZE)
147 if ((smic->state != SMIC_IDLE) && (smic->state != SMIC_HOSED)) { 147 return IPMI_REQ_LEN_EXCEEDED_ERR;
148 return -2; 148
149 } 149 if ((smic->state != SMIC_IDLE) && (smic->state != SMIC_HOSED))
150 return IPMI_NOT_IN_MY_STATE_ERR;
151
150 if (smic_debug & SMIC_DEBUG_MSG) { 152 if (smic_debug & SMIC_DEBUG_MSG) {
151 printk(KERN_INFO "start_smic_transaction -"); 153 printk(KERN_INFO "start_smic_transaction -");
152 for (i = 0; i < size; i ++) { 154 for (i = 0; i < size; i ++) {
diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c
index 73f759eaa5a6..90fb2a541916 100644
--- a/drivers/char/ipmi/ipmi_watchdog.c
+++ b/drivers/char/ipmi/ipmi_watchdog.c
@@ -135,6 +135,7 @@
135static int nowayout = WATCHDOG_NOWAYOUT; 135static int nowayout = WATCHDOG_NOWAYOUT;
136 136
137static ipmi_user_t watchdog_user = NULL; 137static ipmi_user_t watchdog_user = NULL;
138static int watchdog_ifnum;
138 139
139/* Default the timeout to 10 seconds. */ 140/* Default the timeout to 10 seconds. */
140static int timeout = 10; 141static int timeout = 10;
@@ -161,6 +162,8 @@ static struct fasync_struct *fasync_q = NULL;
161static char pretimeout_since_last_heartbeat = 0; 162static char pretimeout_since_last_heartbeat = 0;
162static char expect_close; 163static char expect_close;
163 164
165static int ifnum_to_use = -1;
166
164static DECLARE_RWSEM(register_sem); 167static DECLARE_RWSEM(register_sem);
165 168
166/* Parameters to ipmi_set_timeout */ 169/* Parameters to ipmi_set_timeout */
@@ -169,6 +172,8 @@ static DECLARE_RWSEM(register_sem);
169#define IPMI_SET_TIMEOUT_FORCE_HB 2 172#define IPMI_SET_TIMEOUT_FORCE_HB 2
170 173
171static int ipmi_set_timeout(int do_heartbeat); 174static int ipmi_set_timeout(int do_heartbeat);
175static void ipmi_register_watchdog(int ipmi_intf);
176static void ipmi_unregister_watchdog(int ipmi_intf);
172 177
173/* If true, the driver will start running as soon as it is configured 178/* If true, the driver will start running as soon as it is configured
174 and ready. */ 179 and ready. */
@@ -245,6 +250,26 @@ static int get_param_str(char *buffer, struct kernel_param *kp)
245 return strlen(buffer); 250 return strlen(buffer);
246} 251}
247 252
253
254static int set_param_wdog_ifnum(const char *val, struct kernel_param *kp)
255{
256 int rv = param_set_int(val, kp);
257 if (rv)
258 return rv;
259 if ((ifnum_to_use < 0) || (ifnum_to_use == watchdog_ifnum))
260 return 0;
261
262 ipmi_unregister_watchdog(watchdog_ifnum);
263 ipmi_register_watchdog(ifnum_to_use);
264 return 0;
265}
266
267module_param_call(ifnum_to_use, set_param_wdog_ifnum, get_param_int,
268 &ifnum_to_use, 0644);
269MODULE_PARM_DESC(ifnum_to_use, "The interface number to use for the watchdog "
270 "timer. Setting to -1 defaults to the first registered "
271 "interface");
272
248module_param_call(timeout, set_param_int, get_param_int, &timeout, 0644); 273module_param_call(timeout, set_param_int, get_param_int, &timeout, 0644);
249MODULE_PARM_DESC(timeout, "Timeout value in seconds."); 274MODULE_PARM_DESC(timeout, "Timeout value in seconds.");
250 275
@@ -263,12 +288,13 @@ module_param_call(preop, set_param_str, get_param_str, preop_op, 0644);
263MODULE_PARM_DESC(preop, "Pretimeout driver operation. One of: " 288MODULE_PARM_DESC(preop, "Pretimeout driver operation. One of: "
264 "preop_none, preop_panic, preop_give_data."); 289 "preop_none, preop_panic, preop_give_data.");
265 290
266module_param(start_now, int, 0); 291module_param(start_now, int, 0444);
267MODULE_PARM_DESC(start_now, "Set to 1 to start the watchdog as" 292MODULE_PARM_DESC(start_now, "Set to 1 to start the watchdog as"
268 "soon as the driver is loaded."); 293 "soon as the driver is loaded.");
269 294
270module_param(nowayout, int, 0644); 295module_param(nowayout, int, 0644);
271MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); 296MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started "
297 "(default=CONFIG_WATCHDOG_NOWAYOUT)");
272 298
273/* Default state of the timer. */ 299/* Default state of the timer. */
274static unsigned char ipmi_watchdog_state = WDOG_TIMEOUT_NONE; 300static unsigned char ipmi_watchdog_state = WDOG_TIMEOUT_NONE;
@@ -872,6 +898,11 @@ static void ipmi_register_watchdog(int ipmi_intf)
872 if (watchdog_user) 898 if (watchdog_user)
873 goto out; 899 goto out;
874 900
901 if ((ifnum_to_use >= 0) && (ifnum_to_use != ipmi_intf))
902 goto out;
903
904 watchdog_ifnum = ipmi_intf;
905
875 rv = ipmi_create_user(ipmi_intf, &ipmi_hndlrs, NULL, &watchdog_user); 906 rv = ipmi_create_user(ipmi_intf, &ipmi_hndlrs, NULL, &watchdog_user);
876 if (rv < 0) { 907 if (rv < 0) {
877 printk(KERN_CRIT PFX "Unable to register with ipmi\n"); 908 printk(KERN_CRIT PFX "Unable to register with ipmi\n");
@@ -901,6 +932,39 @@ static void ipmi_register_watchdog(int ipmi_intf)
901 } 932 }
902} 933}
903 934
935static void ipmi_unregister_watchdog(int ipmi_intf)
936{
937 int rv;
938
939 down_write(&register_sem);
940
941 if (!watchdog_user)
942 goto out;
943
944 if (watchdog_ifnum != ipmi_intf)
945 goto out;
946
947 /* Make sure no one can call us any more. */
948 misc_deregister(&ipmi_wdog_miscdev);
949
950 /* Wait to make sure the message makes it out. The lower layer has
951 pointers to our buffers, we want to make sure they are done before
952 we release our memory. */
953 while (atomic_read(&set_timeout_tofree))
954 schedule_timeout_uninterruptible(1);
955
956 /* Disconnect from IPMI. */
957 rv = ipmi_destroy_user(watchdog_user);
958 if (rv) {
959 printk(KERN_WARNING PFX "error unlinking from IPMI: %d\n",
960 rv);
961 }
962 watchdog_user = NULL;
963
964 out:
965 up_write(&register_sem);
966}
967
904#ifdef HAVE_NMI_HANDLER 968#ifdef HAVE_NMI_HANDLER
905static int 969static int
906ipmi_nmi(void *dev_id, int cpu, int handled) 970ipmi_nmi(void *dev_id, int cpu, int handled)
@@ -1004,9 +1068,7 @@ static void ipmi_new_smi(int if_num, struct device *device)
1004 1068
1005static void ipmi_smi_gone(int if_num) 1069static void ipmi_smi_gone(int if_num)
1006{ 1070{
1007 /* This can never be called, because once the watchdog is 1071 ipmi_unregister_watchdog(if_num);
1008 registered, the interface can't go away until the watchdog
1009 is unregistered. */
1010} 1072}
1011 1073
1012static struct ipmi_smi_watcher smi_watcher = 1074static struct ipmi_smi_watcher smi_watcher =
@@ -1148,30 +1210,32 @@ static int __init ipmi_wdog_init(void)
1148 1210
1149 check_parms(); 1211 check_parms();
1150 1212
1213 register_reboot_notifier(&wdog_reboot_notifier);
1214 atomic_notifier_chain_register(&panic_notifier_list,
1215 &wdog_panic_notifier);
1216
1151 rv = ipmi_smi_watcher_register(&smi_watcher); 1217 rv = ipmi_smi_watcher_register(&smi_watcher);
1152 if (rv) { 1218 if (rv) {
1153#ifdef HAVE_NMI_HANDLER 1219#ifdef HAVE_NMI_HANDLER
1154 if (preaction_val == WDOG_PRETIMEOUT_NMI) 1220 if (preaction_val == WDOG_PRETIMEOUT_NMI)
1155 release_nmi(&ipmi_nmi_handler); 1221 release_nmi(&ipmi_nmi_handler);
1156#endif 1222#endif
1223 atomic_notifier_chain_unregister(&panic_notifier_list,
1224 &wdog_panic_notifier);
1225 unregister_reboot_notifier(&wdog_reboot_notifier);
1157 printk(KERN_WARNING PFX "can't register smi watcher\n"); 1226 printk(KERN_WARNING PFX "can't register smi watcher\n");
1158 return rv; 1227 return rv;
1159 } 1228 }
1160 1229
1161 register_reboot_notifier(&wdog_reboot_notifier);
1162 atomic_notifier_chain_register(&panic_notifier_list,
1163 &wdog_panic_notifier);
1164
1165 printk(KERN_INFO PFX "driver initialized\n"); 1230 printk(KERN_INFO PFX "driver initialized\n");
1166 1231
1167 return 0; 1232 return 0;
1168} 1233}
1169 1234
1170static __exit void ipmi_unregister_watchdog(void) 1235static void __exit ipmi_wdog_exit(void)
1171{ 1236{
1172 int rv; 1237 ipmi_smi_watcher_unregister(&smi_watcher);
1173 1238 ipmi_unregister_watchdog(watchdog_ifnum);
1174 down_write(&register_sem);
1175 1239
1176#ifdef HAVE_NMI_HANDLER 1240#ifdef HAVE_NMI_HANDLER
1177 if (nmi_handler_registered) 1241 if (nmi_handler_registered)
@@ -1179,37 +1243,8 @@ static __exit void ipmi_unregister_watchdog(void)
1179#endif 1243#endif
1180 1244
1181 atomic_notifier_chain_unregister(&panic_notifier_list, 1245 atomic_notifier_chain_unregister(&panic_notifier_list,
1182 &wdog_panic_notifier); 1246 &wdog_panic_notifier);
1183 unregister_reboot_notifier(&wdog_reboot_notifier); 1247 unregister_reboot_notifier(&wdog_reboot_notifier);
1184
1185 if (! watchdog_user)
1186 goto out;
1187
1188 /* Make sure no one can call us any more. */
1189 misc_deregister(&ipmi_wdog_miscdev);
1190
1191 /* Wait to make sure the message makes it out. The lower layer has
1192 pointers to our buffers, we want to make sure they are done before
1193 we release our memory. */
1194 while (atomic_read(&set_timeout_tofree))
1195 schedule_timeout_uninterruptible(1);
1196
1197 /* Disconnect from IPMI. */
1198 rv = ipmi_destroy_user(watchdog_user);
1199 if (rv) {
1200 printk(KERN_WARNING PFX "error unlinking from IPMI: %d\n",
1201 rv);
1202 }
1203 watchdog_user = NULL;
1204
1205 out:
1206 up_write(&register_sem);
1207}
1208
1209static void __exit ipmi_wdog_exit(void)
1210{
1211 ipmi_smi_watcher_unregister(&smi_watcher);
1212 ipmi_unregister_watchdog();
1213} 1248}
1214module_exit(ipmi_wdog_exit); 1249module_exit(ipmi_wdog_exit);
1215module_init(ipmi_wdog_init); 1250module_init(ipmi_wdog_init);
diff --git a/drivers/char/isicom.c b/drivers/char/isicom.c
index e9e9bf31c369..1637c1d9a4ba 100644
--- a/drivers/char/isicom.c
+++ b/drivers/char/isicom.c
@@ -530,9 +530,9 @@ sched_again:
530/* Interrupt handlers */ 530/* Interrupt handlers */
531 531
532 532
533static void isicom_bottomhalf(void *data) 533static void isicom_bottomhalf(struct work_struct *work)
534{ 534{
535 struct isi_port *port = (struct isi_port *) data; 535 struct isi_port *port = container_of(work, struct isi_port, bh_tqueue);
536 struct tty_struct *tty = port->tty; 536 struct tty_struct *tty = port->tty;
537 537
538 if (!tty) 538 if (!tty)
@@ -1062,11 +1062,12 @@ static void isicom_shutdown_port(struct isi_port *port)
1062static void isicom_close(struct tty_struct *tty, struct file *filp) 1062static void isicom_close(struct tty_struct *tty, struct file *filp)
1063{ 1063{
1064 struct isi_port *port = tty->driver_data; 1064 struct isi_port *port = tty->driver_data;
1065 struct isi_board *card = port->card; 1065 struct isi_board *card;
1066 unsigned long flags; 1066 unsigned long flags;
1067 1067
1068 if (!port) 1068 if (!port)
1069 return; 1069 return;
1070 card = port->card;
1070 if (isicom_paranoia_check(port, tty->name, "isicom_close")) 1071 if (isicom_paranoia_check(port, tty->name, "isicom_close"))
1071 return; 1072 return;
1072 1073
@@ -1473,9 +1474,9 @@ static void isicom_start(struct tty_struct *tty)
1473} 1474}
1474 1475
1475/* hangup et all */ 1476/* hangup et all */
1476static void do_isicom_hangup(void *data) 1477static void do_isicom_hangup(struct work_struct *work)
1477{ 1478{
1478 struct isi_port *port = data; 1479 struct isi_port *port = container_of(work, struct isi_port, hangup_tq);
1479 struct tty_struct *tty; 1480 struct tty_struct *tty;
1480 1481
1481 tty = port->tty; 1482 tty = port->tty;
@@ -1965,8 +1966,8 @@ static int __devinit isicom_setup(void)
1965 port->channel = channel; 1966 port->channel = channel;
1966 port->close_delay = 50 * HZ/100; 1967 port->close_delay = 50 * HZ/100;
1967 port->closing_wait = 3000 * HZ/100; 1968 port->closing_wait = 3000 * HZ/100;
1968 INIT_WORK(&port->hangup_tq, do_isicom_hangup, port); 1969 INIT_WORK(&port->hangup_tq, do_isicom_hangup);
1969 INIT_WORK(&port->bh_tqueue, isicom_bottomhalf, port); 1970 INIT_WORK(&port->bh_tqueue, isicom_bottomhalf);
1970 port->status = 0; 1971 port->status = 0;
1971 init_waitqueue_head(&port->open_wait); 1972 init_waitqueue_head(&port->open_wait);
1972 init_waitqueue_head(&port->close_wait); 1973 init_waitqueue_head(&port->close_wait);
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c
index ffdf9df1a67a..8f591945ebd9 100644
--- a/drivers/char/istallion.c
+++ b/drivers/char/istallion.c
@@ -663,7 +663,7 @@ static int stli_initopen(stlibrd_t *brdp, stliport_t *portp);
663static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait); 663static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait);
664static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait); 664static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait);
665static int stli_waitcarrier(stlibrd_t *brdp, stliport_t *portp, struct file *filp); 665static int stli_waitcarrier(stlibrd_t *brdp, stliport_t *portp, struct file *filp);
666static void stli_dohangup(void *arg); 666static void stli_dohangup(struct work_struct *);
667static int stli_setport(stliport_t *portp); 667static int stli_setport(stliport_t *portp);
668static int stli_cmdwait(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback); 668static int stli_cmdwait(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback);
669static void stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback); 669static void stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback);
@@ -1990,9 +1990,9 @@ static void stli_start(struct tty_struct *tty)
1990 * aren't that time critical). 1990 * aren't that time critical).
1991 */ 1991 */
1992 1992
1993static void stli_dohangup(void *arg) 1993static void stli_dohangup(struct work_struct *ugly_api)
1994{ 1994{
1995 stliport_t *portp = (stliport_t *) arg; 1995 stliport_t *portp = container_of(ugly_api, stliport_t, tqhangup);
1996 if (portp->tty != NULL) { 1996 if (portp->tty != NULL) {
1997 tty_hangup(portp->tty); 1997 tty_hangup(portp->tty);
1998 } 1998 }
@@ -2898,7 +2898,7 @@ static int stli_initports(stlibrd_t *brdp)
2898 portp->baud_base = STL_BAUDBASE; 2898 portp->baud_base = STL_BAUDBASE;
2899 portp->close_delay = STL_CLOSEDELAY; 2899 portp->close_delay = STL_CLOSEDELAY;
2900 portp->closing_wait = 30 * HZ; 2900 portp->closing_wait = 30 * HZ;
2901 INIT_WORK(&portp->tqhangup, stli_dohangup, portp); 2901 INIT_WORK(&portp->tqhangup, stli_dohangup);
2902 init_waitqueue_head(&portp->open_wait); 2902 init_waitqueue_head(&portp->open_wait);
2903 init_waitqueue_head(&portp->close_wait); 2903 init_waitqueue_head(&portp->close_wait);
2904 init_waitqueue_head(&portp->raw_wait); 2904 init_waitqueue_head(&portp->raw_wait);
@@ -3476,6 +3476,8 @@ static int stli_initecp(stlibrd_t *brdp)
3476 if (sig.magic != cpu_to_le32(ECP_MAGIC)) 3476 if (sig.magic != cpu_to_le32(ECP_MAGIC))
3477 { 3477 {
3478 release_region(brdp->iobase, brdp->iosize); 3478 release_region(brdp->iobase, brdp->iosize);
3479 iounmap(brdp->membase);
3480 brdp->membase = NULL;
3479 return -ENODEV; 3481 return -ENODEV;
3480 } 3482 }
3481 3483
@@ -3632,6 +3634,8 @@ static int stli_initonb(stlibrd_t *brdp)
3632 sig.magic3 != cpu_to_le16(ONB_MAGIC3)) 3634 sig.magic3 != cpu_to_le16(ONB_MAGIC3))
3633 { 3635 {
3634 release_region(brdp->iobase, brdp->iosize); 3636 release_region(brdp->iobase, brdp->iosize);
3637 iounmap(brdp->membase);
3638 brdp->membase = NULL;
3635 return -ENODEV; 3639 return -ENODEV;
3636 } 3640 }
3637 3641
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 55473371b7c6..e67eef4867ba 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -980,10 +980,10 @@ static int __init chr_dev_init(void)
980 980
981 mem_class = class_create(THIS_MODULE, "mem"); 981 mem_class = class_create(THIS_MODULE, "mem");
982 for (i = 0; i < ARRAY_SIZE(devlist); i++) 982 for (i = 0; i < ARRAY_SIZE(devlist); i++)
983 class_device_create(mem_class, NULL, 983 device_create(mem_class, NULL,
984 MKDEV(MEM_MAJOR, devlist[i].minor), 984 MKDEV(MEM_MAJOR, devlist[i].minor),
985 NULL, devlist[i].name); 985 devlist[i].name);
986 986
987 return 0; 987 return 0;
988} 988}
989 989
diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index 62ebe09656e3..7e975f606924 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -169,11 +169,6 @@ fail:
169 return err; 169 return err;
170} 170}
171 171
172/*
173 * TODO for 2.7:
174 * - add a struct kref to struct miscdevice and make all usages of
175 * them dynamic.
176 */
177static struct class *misc_class; 172static struct class *misc_class;
178 173
179static const struct file_operations misc_fops = { 174static const struct file_operations misc_fops = {
@@ -204,6 +199,8 @@ int misc_register(struct miscdevice * misc)
204 dev_t dev; 199 dev_t dev;
205 int err = 0; 200 int err = 0;
206 201
202 INIT_LIST_HEAD(&misc->list);
203
207 down(&misc_sem); 204 down(&misc_sem);
208 list_for_each_entry(c, &misc_list, list) { 205 list_for_each_entry(c, &misc_list, list) {
209 if (c->minor == misc->minor) { 206 if (c->minor == misc->minor) {
@@ -228,10 +225,10 @@ int misc_register(struct miscdevice * misc)
228 misc_minors[misc->minor >> 3] |= 1 << (misc->minor & 7); 225 misc_minors[misc->minor >> 3] |= 1 << (misc->minor & 7);
229 dev = MKDEV(MISC_MAJOR, misc->minor); 226 dev = MKDEV(MISC_MAJOR, misc->minor);
230 227
231 misc->class = class_device_create(misc_class, NULL, dev, misc->dev, 228 misc->this_device = device_create(misc_class, misc->parent, dev,
232 "%s", misc->name); 229 "%s", misc->name);
233 if (IS_ERR(misc->class)) { 230 if (IS_ERR(misc->this_device)) {
234 err = PTR_ERR(misc->class); 231 err = PTR_ERR(misc->this_device);
235 goto out; 232 goto out;
236 } 233 }
237 234
@@ -264,7 +261,7 @@ int misc_deregister(struct miscdevice * misc)
264 261
265 down(&misc_sem); 262 down(&misc_sem);
266 list_del(&misc->list); 263 list_del(&misc->list);
267 class_device_destroy(misc_class, MKDEV(MISC_MAJOR, misc->minor)); 264 device_destroy(misc_class, MKDEV(MISC_MAJOR, misc->minor));
268 if (i < DYNAMIC_MINORS && i>0) { 265 if (i < DYNAMIC_MINORS && i>0) {
269 misc_minors[i>>3] &= ~(1 << (misc->minor & 7)); 266 misc_minors[i>>3] &= ~(1 << (misc->minor & 7));
270 } 267 }
diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c
index 22b9905c1e52..c09160383a53 100644
--- a/drivers/char/mmtimer.c
+++ b/drivers/char/mmtimer.c
@@ -680,7 +680,7 @@ static int __init mmtimer_init(void)
680 if (sn_rtc_cycles_per_second < 100000) { 680 if (sn_rtc_cycles_per_second < 100000) {
681 printk(KERN_ERR "%s: unable to determine clock frequency\n", 681 printk(KERN_ERR "%s: unable to determine clock frequency\n",
682 MMTIMER_NAME); 682 MMTIMER_NAME);
683 return -1; 683 goto out1;
684 } 684 }
685 685
686 mmtimer_femtoperiod = ((unsigned long)1E15 + sn_rtc_cycles_per_second / 686 mmtimer_femtoperiod = ((unsigned long)1E15 + sn_rtc_cycles_per_second /
@@ -689,13 +689,13 @@ static int __init mmtimer_init(void)
689 if (request_irq(SGI_MMTIMER_VECTOR, mmtimer_interrupt, IRQF_PERCPU, MMTIMER_NAME, NULL)) { 689 if (request_irq(SGI_MMTIMER_VECTOR, mmtimer_interrupt, IRQF_PERCPU, MMTIMER_NAME, NULL)) {
690 printk(KERN_WARNING "%s: unable to allocate interrupt.", 690 printk(KERN_WARNING "%s: unable to allocate interrupt.",
691 MMTIMER_NAME); 691 MMTIMER_NAME);
692 return -1; 692 goto out1;
693 } 693 }
694 694
695 if (misc_register(&mmtimer_miscdev)) { 695 if (misc_register(&mmtimer_miscdev)) {
696 printk(KERN_ERR "%s: failed to register device\n", 696 printk(KERN_ERR "%s: failed to register device\n",
697 MMTIMER_NAME); 697 MMTIMER_NAME);
698 return -1; 698 goto out2;
699 } 699 }
700 700
701 /* Get max numbered node, calculate slots needed */ 701 /* Get max numbered node, calculate slots needed */
@@ -709,16 +709,18 @@ static int __init mmtimer_init(void)
709 if (timers == NULL) { 709 if (timers == NULL) {
710 printk(KERN_ERR "%s: failed to allocate memory for device\n", 710 printk(KERN_ERR "%s: failed to allocate memory for device\n",
711 MMTIMER_NAME); 711 MMTIMER_NAME);
712 return -1; 712 goto out3;
713 } 713 }
714 714
715 memset(timers,0,(sizeof(mmtimer_t *)*maxn));
716
715 /* Allocate mmtimer_t's for each online node */ 717 /* Allocate mmtimer_t's for each online node */
716 for_each_online_node(node) { 718 for_each_online_node(node) {
717 timers[node] = kmalloc_node(sizeof(mmtimer_t)*NUM_COMPARATORS, GFP_KERNEL, node); 719 timers[node] = kmalloc_node(sizeof(mmtimer_t)*NUM_COMPARATORS, GFP_KERNEL, node);
718 if (timers[node] == NULL) { 720 if (timers[node] == NULL) {
719 printk(KERN_ERR "%s: failed to allocate memory for device\n", 721 printk(KERN_ERR "%s: failed to allocate memory for device\n",
720 MMTIMER_NAME); 722 MMTIMER_NAME);
721 return -1; 723 goto out4;
722 } 724 }
723 for (i=0; i< NUM_COMPARATORS; i++) { 725 for (i=0; i< NUM_COMPARATORS; i++) {
724 mmtimer_t * base = timers[node] + i; 726 mmtimer_t * base = timers[node] + i;
@@ -739,6 +741,17 @@ static int __init mmtimer_init(void)
739 sn_rtc_cycles_per_second/(unsigned long)1E6); 741 sn_rtc_cycles_per_second/(unsigned long)1E6);
740 742
741 return 0; 743 return 0;
744
745out4:
746 for_each_online_node(node) {
747 kfree(timers[node]);
748 }
749out3:
750 misc_deregister(&mmtimer_miscdev);
751out2:
752 free_irq(SGI_MMTIMER_VECTOR, NULL);
753out1:
754 return -1;
742} 755}
743 756
744module_init(mmtimer_init); 757module_init(mmtimer_init);
diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c
index 96cb1f07332b..8b316953173d 100644
--- a/drivers/char/moxa.c
+++ b/drivers/char/moxa.c
@@ -222,7 +222,7 @@ static struct semaphore moxaBuffSem;
222/* 222/*
223 * static functions: 223 * static functions:
224 */ 224 */
225static void do_moxa_softint(void *); 225static void do_moxa_softint(struct work_struct *);
226static int moxa_open(struct tty_struct *, struct file *); 226static int moxa_open(struct tty_struct *, struct file *);
227static void moxa_close(struct tty_struct *, struct file *); 227static void moxa_close(struct tty_struct *, struct file *);
228static int moxa_write(struct tty_struct *, const unsigned char *, int); 228static int moxa_write(struct tty_struct *, const unsigned char *, int);
@@ -363,7 +363,7 @@ static int __init moxa_init(void)
363 for (i = 0, ch = moxaChannels; i < MAX_PORTS; i++, ch++) { 363 for (i = 0, ch = moxaChannels; i < MAX_PORTS; i++, ch++) {
364 ch->type = PORT_16550A; 364 ch->type = PORT_16550A;
365 ch->port = i; 365 ch->port = i;
366 INIT_WORK(&ch->tqueue, do_moxa_softint, ch); 366 INIT_WORK(&ch->tqueue, do_moxa_softint);
367 ch->tty = NULL; 367 ch->tty = NULL;
368 ch->close_delay = 5 * HZ / 10; 368 ch->close_delay = 5 * HZ / 10;
369 ch->closing_wait = 30 * HZ; 369 ch->closing_wait = 30 * HZ;
@@ -498,9 +498,12 @@ static void __exit moxa_exit(void)
498 printk("Couldn't unregister MOXA Intellio family serial driver\n"); 498 printk("Couldn't unregister MOXA Intellio family serial driver\n");
499 put_tty_driver(moxaDriver); 499 put_tty_driver(moxaDriver);
500 500
501 for (i = 0; i < MAX_BOARDS; i++) 501 for (i = 0; i < MAX_BOARDS; i++) {
502 if (moxaBaseAddr[i])
503 iounmap(moxaBaseAddr[i]);
502 if (moxa_boards[i].busType == MOXA_BUS_TYPE_PCI) 504 if (moxa_boards[i].busType == MOXA_BUS_TYPE_PCI)
503 pci_dev_put(moxa_boards[i].pciInfo.pdev); 505 pci_dev_put(moxa_boards[i].pciInfo.pdev);
506 }
504 507
505 if (verbose) 508 if (verbose)
506 printk("Done\n"); 509 printk("Done\n");
@@ -509,9 +512,9 @@ static void __exit moxa_exit(void)
509module_init(moxa_init); 512module_init(moxa_init);
510module_exit(moxa_exit); 513module_exit(moxa_exit);
511 514
512static void do_moxa_softint(void *private_) 515static void do_moxa_softint(struct work_struct *work)
513{ 516{
514 struct moxa_str *ch = (struct moxa_str *) private_; 517 struct moxa_str *ch = container_of(work, struct moxa_str, tqueue);
515 struct tty_struct *tty; 518 struct tty_struct *tty;
516 519
517 if (ch && (tty = ch->tty)) { 520 if (ch && (tty = ch->tty)) {
diff --git a/drivers/char/mspec.c b/drivers/char/mspec.c
index 5c0dec39cf6c..235e89226112 100644
--- a/drivers/char/mspec.c
+++ b/drivers/char/mspec.c
@@ -72,7 +72,11 @@ enum {
72 MSPEC_UNCACHED 72 MSPEC_UNCACHED
73}; 73};
74 74
75#ifdef CONFIG_SGI_SN
75static int is_sn2; 76static int is_sn2;
77#else
78#define is_sn2 0
79#endif
76 80
77/* 81/*
78 * One of these structures is allocated when an mspec region is mmaped. The 82 * One of these structures is allocated when an mspec region is mmaped. The
@@ -211,7 +215,7 @@ mspec_nopfn(struct vm_area_struct *vma, unsigned long address)
211 if (vdata->type == MSPEC_FETCHOP) 215 if (vdata->type == MSPEC_FETCHOP)
212 paddr = TO_AMO(maddr); 216 paddr = TO_AMO(maddr);
213 else 217 else
214 paddr = __pa(TO_CAC(maddr)); 218 paddr = maddr & ~__IA64_UNCACHED_OFFSET;
215 219
216 pfn = paddr >> PAGE_SHIFT; 220 pfn = paddr >> PAGE_SHIFT;
217 221
@@ -335,6 +339,7 @@ mspec_init(void)
335 * The fetchop device only works on SN2 hardware, uncached and cached 339 * The fetchop device only works on SN2 hardware, uncached and cached
336 * memory drivers should both be valid on all ia64 hardware 340 * memory drivers should both be valid on all ia64 hardware
337 */ 341 */
342#ifdef CONFIG_SGI_SN
338 if (ia64_platform_is("sn2")) { 343 if (ia64_platform_is("sn2")) {
339 is_sn2 = 1; 344 is_sn2 = 1;
340 if (is_shub2()) { 345 if (is_shub2()) {
@@ -363,6 +368,7 @@ mspec_init(void)
363 goto free_scratch_pages; 368 goto free_scratch_pages;
364 } 369 }
365 } 370 }
371#endif
366 ret = misc_register(&cached_miscdev); 372 ret = misc_register(&cached_miscdev);
367 if (ret) { 373 if (ret) {
368 printk(KERN_ERR "%s: failed to register device %i\n", 374 printk(KERN_ERR "%s: failed to register device %i\n",
diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c
index 048d91142c17..5ed2486b7581 100644
--- a/drivers/char/mxser.c
+++ b/drivers/char/mxser.c
@@ -389,7 +389,7 @@ static int mxser_init(void);
389/* static void mxser_poll(unsigned long); */ 389/* static void mxser_poll(unsigned long); */
390static int mxser_get_ISA_conf(int, struct mxser_hwconf *); 390static int mxser_get_ISA_conf(int, struct mxser_hwconf *);
391static int mxser_get_PCI_conf(int, int, int, struct mxser_hwconf *); 391static int mxser_get_PCI_conf(int, int, int, struct mxser_hwconf *);
392static void mxser_do_softint(void *); 392static void mxser_do_softint(struct work_struct *);
393static int mxser_open(struct tty_struct *, struct file *); 393static int mxser_open(struct tty_struct *, struct file *);
394static void mxser_close(struct tty_struct *, struct file *); 394static void mxser_close(struct tty_struct *, struct file *);
395static int mxser_write(struct tty_struct *, const unsigned char *, int); 395static int mxser_write(struct tty_struct *, const unsigned char *, int);
@@ -590,7 +590,7 @@ static int mxser_initbrd(int board, struct mxser_hwconf *hwconf)
590 info->custom_divisor = hwconf->baud_base[i] * 16; 590 info->custom_divisor = hwconf->baud_base[i] * 16;
591 info->close_delay = 5 * HZ / 10; 591 info->close_delay = 5 * HZ / 10;
592 info->closing_wait = 30 * HZ; 592 info->closing_wait = 30 * HZ;
593 INIT_WORK(&info->tqueue, mxser_do_softint, info); 593 INIT_WORK(&info->tqueue, mxser_do_softint);
594 info->normal_termios = mxvar_sdriver->init_termios; 594 info->normal_termios = mxvar_sdriver->init_termios;
595 init_waitqueue_head(&info->open_wait); 595 init_waitqueue_head(&info->open_wait);
596 init_waitqueue_head(&info->close_wait); 596 init_waitqueue_head(&info->close_wait);
@@ -917,9 +917,10 @@ static int mxser_init(void)
917 return 0; 917 return 0;
918} 918}
919 919
920static void mxser_do_softint(void *private_) 920static void mxser_do_softint(struct work_struct *work)
921{ 921{
922 struct mxser_struct *info = private_; 922 struct mxser_struct *info =
923 container_of(work, struct mxser_struct, tqueue);
923 struct tty_struct *tty; 924 struct tty_struct *tty;
924 925
925 tty = info->tty; 926 tty = info->tty;
diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c
index 50d20aafeb18..211c93fda6fc 100644
--- a/drivers/char/pcmcia/cm4000_cs.c
+++ b/drivers/char/pcmcia/cm4000_cs.c
@@ -1764,29 +1764,11 @@ static int cm4000_config(struct pcmcia_device * link, int devno)
1764 int rc; 1764 int rc;
1765 1765
1766 /* read the config-tuples */ 1766 /* read the config-tuples */
1767 tuple.DesiredTuple = CISTPL_CONFIG;
1768 tuple.Attributes = 0; 1767 tuple.Attributes = 0;
1769 tuple.TupleData = buf; 1768 tuple.TupleData = buf;
1770 tuple.TupleDataMax = sizeof(buf); 1769 tuple.TupleDataMax = sizeof(buf);
1771 tuple.TupleOffset = 0; 1770 tuple.TupleOffset = 0;
1772 1771
1773 if ((fail_rc = pcmcia_get_first_tuple(link, &tuple)) != CS_SUCCESS) {
1774 fail_fn = GetFirstTuple;
1775 goto cs_failed;
1776 }
1777 if ((fail_rc = pcmcia_get_tuple_data(link, &tuple)) != CS_SUCCESS) {
1778 fail_fn = GetTupleData;
1779 goto cs_failed;
1780 }
1781 if ((fail_rc =
1782 pcmcia_parse_tuple(link, &tuple, &parse)) != CS_SUCCESS) {
1783 fail_fn = ParseTuple;
1784 goto cs_failed;
1785 }
1786
1787 link->conf.ConfigBase = parse.config.base;
1788 link->conf.Present = parse.config.rmask[0];
1789
1790 link->io.BasePort2 = 0; 1772 link->io.BasePort2 = 0;
1791 link->io.NumPorts2 = 0; 1773 link->io.NumPorts2 = 0;
1792 link->io.Attributes2 = 0; 1774 link->io.Attributes2 = 0;
@@ -1841,8 +1823,6 @@ static int cm4000_config(struct pcmcia_device * link, int devno)
1841 1823
1842 return 0; 1824 return 0;
1843 1825
1844cs_failed:
1845 cs_error(link, fail_fn, fail_rc);
1846cs_release: 1826cs_release:
1847 cm4000_release(link); 1827 cm4000_release(link);
1848 return -ENODEV; 1828 return -ENODEV;
@@ -1973,14 +1953,14 @@ static int __init cmm_init(void)
1973 printk(KERN_INFO "%s\n", version); 1953 printk(KERN_INFO "%s\n", version);
1974 1954
1975 cmm_class = class_create(THIS_MODULE, "cardman_4000"); 1955 cmm_class = class_create(THIS_MODULE, "cardman_4000");
1976 if (!cmm_class) 1956 if (IS_ERR(cmm_class))
1977 return -1; 1957 return PTR_ERR(cmm_class);
1978 1958
1979 major = register_chrdev(0, DEVICE_NAME, &cm4000_fops); 1959 major = register_chrdev(0, DEVICE_NAME, &cm4000_fops);
1980 if (major < 0) { 1960 if (major < 0) {
1981 printk(KERN_WARNING MODULE_NAME 1961 printk(KERN_WARNING MODULE_NAME
1982 ": could not get major number\n"); 1962 ": could not get major number\n");
1983 return -1; 1963 return major;
1984 } 1964 }
1985 1965
1986 rc = pcmcia_register_driver(&cm4000_driver); 1966 rc = pcmcia_register_driver(&cm4000_driver);
diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c
index 55cf4be42976..9b1ff7e8f896 100644
--- a/drivers/char/pcmcia/cm4040_cs.c
+++ b/drivers/char/pcmcia/cm4040_cs.c
@@ -523,29 +523,11 @@ static int reader_config(struct pcmcia_device *link, int devno)
523 int fail_fn, fail_rc; 523 int fail_fn, fail_rc;
524 int rc; 524 int rc;
525 525
526 tuple.DesiredTuple = CISTPL_CONFIG;
527 tuple.Attributes = 0; 526 tuple.Attributes = 0;
528 tuple.TupleData = buf; 527 tuple.TupleData = buf;
529 tuple.TupleDataMax = sizeof(buf); 528 tuple.TupleDataMax = sizeof(buf);
530 tuple.TupleOffset = 0; 529 tuple.TupleOffset = 0;
531 530
532 if ((fail_rc = pcmcia_get_first_tuple(link, &tuple)) != CS_SUCCESS) {
533 fail_fn = GetFirstTuple;
534 goto cs_failed;
535 }
536 if ((fail_rc = pcmcia_get_tuple_data(link, &tuple)) != CS_SUCCESS) {
537 fail_fn = GetTupleData;
538 goto cs_failed;
539 }
540 if ((fail_rc = pcmcia_parse_tuple(link, &tuple, &parse))
541 != CS_SUCCESS) {
542 fail_fn = ParseTuple;
543 goto cs_failed;
544 }
545
546 link->conf.ConfigBase = parse.config.base;
547 link->conf.Present = parse.config.rmask[0];
548
549 link->io.BasePort2 = 0; 531 link->io.BasePort2 = 0;
550 link->io.NumPorts2 = 0; 532 link->io.NumPorts2 = 0;
551 link->io.Attributes2 = 0; 533 link->io.Attributes2 = 0;
@@ -609,8 +591,6 @@ static int reader_config(struct pcmcia_device *link, int devno)
609 591
610 return 0; 592 return 0;
611 593
612cs_failed:
613 cs_error(link, fail_fn, fail_rc);
614cs_release: 594cs_release:
615 reader_release(link); 595 reader_release(link);
616 return -ENODEV; 596 return -ENODEV;
@@ -721,14 +701,14 @@ static int __init cm4040_init(void)
721 701
722 printk(KERN_INFO "%s\n", version); 702 printk(KERN_INFO "%s\n", version);
723 cmx_class = class_create(THIS_MODULE, "cardman_4040"); 703 cmx_class = class_create(THIS_MODULE, "cardman_4040");
724 if (!cmx_class) 704 if (IS_ERR(cmx_class))
725 return -1; 705 return PTR_ERR(cmx_class);
726 706
727 major = register_chrdev(0, DEVICE_NAME, &reader_fops); 707 major = register_chrdev(0, DEVICE_NAME, &reader_fops);
728 if (major < 0) { 708 if (major < 0) {
729 printk(KERN_WARNING MODULE_NAME 709 printk(KERN_WARNING MODULE_NAME
730 ": could not get major number\n"); 710 ": could not get major number\n");
731 return -1; 711 return major;
732 } 712 }
733 713
734 rc = pcmcia_register_driver(&reader_driver); 714 rc = pcmcia_register_driver(&reader_driver);
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index 1a0bc30b79d1..74d21c1c104f 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -75,8 +75,10 @@
75#include <pcmcia/cisreg.h> 75#include <pcmcia/cisreg.h>
76#include <pcmcia/ds.h> 76#include <pcmcia/ds.h>
77 77
78#ifdef CONFIG_HDLC_MODULE 78#if defined(CONFIG_HDLC) || (defined(CONFIG_HDLC_MODULE) && defined(CONFIG_SYNCLINK_CS_MODULE))
79#define CONFIG_HDLC 1 79#define SYNCLINK_GENERIC_HDLC 1
80#else
81#define SYNCLINK_GENERIC_HDLC 0
80#endif 82#endif
81 83
82#define GET_USER(error,value,addr) error = get_user(value,addr) 84#define GET_USER(error,value,addr) error = get_user(value,addr)
@@ -235,7 +237,7 @@ typedef struct _mgslpc_info {
235 int dosyncppp; 237 int dosyncppp;
236 spinlock_t netlock; 238 spinlock_t netlock;
237 239
238#ifdef CONFIG_HDLC 240#if SYNCLINK_GENERIC_HDLC
239 struct net_device *netdev; 241 struct net_device *netdev;
240#endif 242#endif
241 243
@@ -392,7 +394,7 @@ static void tx_timeout(unsigned long context);
392 394
393static int ioctl_common(MGSLPC_INFO *info, unsigned int cmd, unsigned long arg); 395static int ioctl_common(MGSLPC_INFO *info, unsigned int cmd, unsigned long arg);
394 396
395#ifdef CONFIG_HDLC 397#if SYNCLINK_GENERIC_HDLC
396#define dev_to_port(D) (dev_to_hdlc(D)->priv) 398#define dev_to_port(D) (dev_to_hdlc(D)->priv)
397static void hdlcdev_tx_done(MGSLPC_INFO *info); 399static void hdlcdev_tx_done(MGSLPC_INFO *info);
398static void hdlcdev_rx(MGSLPC_INFO *info, char *buf, int size); 400static void hdlcdev_rx(MGSLPC_INFO *info, char *buf, int size);
@@ -421,7 +423,7 @@ static irqreturn_t mgslpc_isr(int irq, void *dev_id);
421/* 423/*
422 * Bottom half interrupt handlers 424 * Bottom half interrupt handlers
423 */ 425 */
424static void bh_handler(void* Context); 426static void bh_handler(struct work_struct *work);
425static void bh_transmit(MGSLPC_INFO *info); 427static void bh_transmit(MGSLPC_INFO *info);
426static void bh_status(MGSLPC_INFO *info); 428static void bh_status(MGSLPC_INFO *info);
427 429
@@ -547,7 +549,7 @@ static int mgslpc_probe(struct pcmcia_device *link)
547 549
548 memset(info, 0, sizeof(MGSLPC_INFO)); 550 memset(info, 0, sizeof(MGSLPC_INFO));
549 info->magic = MGSLPC_MAGIC; 551 info->magic = MGSLPC_MAGIC;
550 INIT_WORK(&info->task, bh_handler, info); 552 INIT_WORK(&info->task, bh_handler);
551 info->max_frame_size = 4096; 553 info->max_frame_size = 4096;
552 info->close_delay = 5*HZ/10; 554 info->close_delay = 5*HZ/10;
553 info->closing_wait = 30*HZ; 555 info->closing_wait = 30*HZ;
@@ -604,17 +606,10 @@ static int mgslpc_config(struct pcmcia_device *link)
604 if (debug_level >= DEBUG_LEVEL_INFO) 606 if (debug_level >= DEBUG_LEVEL_INFO)
605 printk("mgslpc_config(0x%p)\n", link); 607 printk("mgslpc_config(0x%p)\n", link);
606 608
607 /* read CONFIG tuple to find its configuration registers */
608 tuple.DesiredTuple = CISTPL_CONFIG;
609 tuple.Attributes = 0; 609 tuple.Attributes = 0;
610 tuple.TupleData = buf; 610 tuple.TupleData = buf;
611 tuple.TupleDataMax = sizeof(buf); 611 tuple.TupleDataMax = sizeof(buf);
612 tuple.TupleOffset = 0; 612 tuple.TupleOffset = 0;
613 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
614 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
615 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
616 link->conf.ConfigBase = parse.config.base;
617 link->conf.Present = parse.config.rmask[0];
618 613
619 /* get CIS configuration entry */ 614 /* get CIS configuration entry */
620 615
@@ -842,9 +837,9 @@ static int bh_action(MGSLPC_INFO *info)
842 return rc; 837 return rc;
843} 838}
844 839
845static void bh_handler(void* Context) 840static void bh_handler(struct work_struct *work)
846{ 841{
847 MGSLPC_INFO *info = (MGSLPC_INFO*)Context; 842 MGSLPC_INFO *info = container_of(work, MGSLPC_INFO, task);
848 int action; 843 int action;
849 844
850 if (!info) 845 if (!info)
@@ -1060,7 +1055,7 @@ static void tx_done(MGSLPC_INFO *info)
1060 info->drop_rts_on_tx_done = 0; 1055 info->drop_rts_on_tx_done = 0;
1061 } 1056 }
1062 1057
1063#ifdef CONFIG_HDLC 1058#if SYNCLINK_GENERIC_HDLC
1064 if (info->netcount) 1059 if (info->netcount)
1065 hdlcdev_tx_done(info); 1060 hdlcdev_tx_done(info);
1066 else 1061 else
@@ -1171,7 +1166,7 @@ static void dcd_change(MGSLPC_INFO *info)
1171 } 1166 }
1172 else 1167 else
1173 info->input_signal_events.dcd_down++; 1168 info->input_signal_events.dcd_down++;
1174#ifdef CONFIG_HDLC 1169#if SYNCLINK_GENERIC_HDLC
1175 if (info->netcount) { 1170 if (info->netcount) {
1176 if (info->serial_signals & SerialSignal_DCD) 1171 if (info->serial_signals & SerialSignal_DCD)
1177 netif_carrier_on(info->netdev); 1172 netif_carrier_on(info->netdev);
@@ -2960,7 +2955,7 @@ static void mgslpc_add_device(MGSLPC_INFO *info)
2960 printk( "SyncLink PC Card %s:IO=%04X IRQ=%d\n", 2955 printk( "SyncLink PC Card %s:IO=%04X IRQ=%d\n",
2961 info->device_name, info->io_base, info->irq_level); 2956 info->device_name, info->io_base, info->irq_level);
2962 2957
2963#ifdef CONFIG_HDLC 2958#if SYNCLINK_GENERIC_HDLC
2964 hdlcdev_init(info); 2959 hdlcdev_init(info);
2965#endif 2960#endif
2966} 2961}
@@ -2976,7 +2971,7 @@ static void mgslpc_remove_device(MGSLPC_INFO *remove_info)
2976 last->next_device = info->next_device; 2971 last->next_device = info->next_device;
2977 else 2972 else
2978 mgslpc_device_list = info->next_device; 2973 mgslpc_device_list = info->next_device;
2979#ifdef CONFIG_HDLC 2974#if SYNCLINK_GENERIC_HDLC
2980 hdlcdev_exit(info); 2975 hdlcdev_exit(info);
2981#endif 2976#endif
2982 release_resources(info); 2977 release_resources(info);
@@ -3908,7 +3903,7 @@ static int rx_get_frame(MGSLPC_INFO *info)
3908 return_frame = 1; 3903 return_frame = 1;
3909 } 3904 }
3910 framesize = 0; 3905 framesize = 0;
3911#ifdef CONFIG_HDLC 3906#if SYNCLINK_GENERIC_HDLC
3912 { 3907 {
3913 struct net_device_stats *stats = hdlc_stats(info->netdev); 3908 struct net_device_stats *stats = hdlc_stats(info->netdev);
3914 stats->rx_errors++; 3909 stats->rx_errors++;
@@ -3942,7 +3937,7 @@ static int rx_get_frame(MGSLPC_INFO *info)
3942 ++framesize; 3937 ++framesize;
3943 } 3938 }
3944 3939
3945#ifdef CONFIG_HDLC 3940#if SYNCLINK_GENERIC_HDLC
3946 if (info->netcount) 3941 if (info->netcount)
3947 hdlcdev_rx(info, buf->data, framesize); 3942 hdlcdev_rx(info, buf->data, framesize);
3948 else 3943 else
@@ -4098,7 +4093,7 @@ static void tx_timeout(unsigned long context)
4098 4093
4099 spin_unlock_irqrestore(&info->lock,flags); 4094 spin_unlock_irqrestore(&info->lock,flags);
4100 4095
4101#ifdef CONFIG_HDLC 4096#if SYNCLINK_GENERIC_HDLC
4102 if (info->netcount) 4097 if (info->netcount)
4103 hdlcdev_tx_done(info); 4098 hdlcdev_tx_done(info);
4104 else 4099 else
@@ -4106,7 +4101,7 @@ static void tx_timeout(unsigned long context)
4106 bh_transmit(info); 4101 bh_transmit(info);
4107} 4102}
4108 4103
4109#ifdef CONFIG_HDLC 4104#if SYNCLINK_GENERIC_HDLC
4110 4105
4111/** 4106/**
4112 * called by generic HDLC layer when protocol selected (PPP, frame relay, etc.) 4107 * called by generic HDLC layer when protocol selected (PPP, frame relay, etc.)
diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c
index efc485edad1c..c1e3dd837fc8 100644
--- a/drivers/char/ppdev.c
+++ b/drivers/char/ppdev.c
@@ -752,13 +752,13 @@ static const struct file_operations pp_fops = {
752 752
753static void pp_attach(struct parport *port) 753static void pp_attach(struct parport *port)
754{ 754{
755 class_device_create(ppdev_class, NULL, MKDEV(PP_MAJOR, port->number), 755 device_create(ppdev_class, NULL, MKDEV(PP_MAJOR, port->number),
756 NULL, "parport%d", port->number); 756 "parport%d", port->number);
757} 757}
758 758
759static void pp_detach(struct parport *port) 759static void pp_detach(struct parport *port)
760{ 760{
761 class_device_destroy(ppdev_class, MKDEV(PP_MAJOR, port->number)); 761 device_destroy(ppdev_class, MKDEV(PP_MAJOR, port->number));
762} 762}
763 763
764static struct parport_driver pp_driver = { 764static struct parport_driver pp_driver = {
diff --git a/drivers/char/random.c b/drivers/char/random.c
index eb6b13f4211a..4c6782a1ecdb 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -1422,9 +1422,9 @@ static struct keydata {
1422 1422
1423static unsigned int ip_cnt; 1423static unsigned int ip_cnt;
1424 1424
1425static void rekey_seq_generator(void *private_); 1425static void rekey_seq_generator(struct work_struct *work);
1426 1426
1427static DECLARE_WORK(rekey_work, rekey_seq_generator, NULL); 1427static DECLARE_DELAYED_WORK(rekey_work, rekey_seq_generator);
1428 1428
1429/* 1429/*
1430 * Lock avoidance: 1430 * Lock avoidance:
@@ -1438,7 +1438,7 @@ static DECLARE_WORK(rekey_work, rekey_seq_generator, NULL);
1438 * happen, and even if that happens only a not perfectly compliant 1438 * happen, and even if that happens only a not perfectly compliant
1439 * ISN is generated, nothing fatal. 1439 * ISN is generated, nothing fatal.
1440 */ 1440 */
1441static void rekey_seq_generator(void *private_) 1441static void rekey_seq_generator(struct work_struct *work)
1442{ 1442{
1443 struct keydata *keyptr = &ip_keydata[1 ^ (ip_cnt & 1)]; 1443 struct keydata *keyptr = &ip_keydata[1 ^ (ip_cnt & 1)];
1444 1444
@@ -1466,8 +1466,8 @@ static __init int seqgen_init(void)
1466late_initcall(seqgen_init); 1466late_initcall(seqgen_init);
1467 1467
1468#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 1468#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
1469__u32 secure_tcpv6_sequence_number(__u32 *saddr, __u32 *daddr, 1469__u32 secure_tcpv6_sequence_number(__be32 *saddr, __be32 *daddr,
1470 __u16 sport, __u16 dport) 1470 __be16 sport, __be16 dport)
1471{ 1471{
1472 struct timeval tv; 1472 struct timeval tv;
1473 __u32 seq; 1473 __u32 seq;
@@ -1479,10 +1479,10 @@ __u32 secure_tcpv6_sequence_number(__u32 *saddr, __u32 *daddr,
1479 */ 1479 */
1480 1480
1481 memcpy(hash, saddr, 16); 1481 memcpy(hash, saddr, 16);
1482 hash[4]=(sport << 16) + dport; 1482 hash[4]=((__force u16)sport << 16) + (__force u16)dport;
1483 memcpy(&hash[5],keyptr->secret,sizeof(__u32) * 7); 1483 memcpy(&hash[5],keyptr->secret,sizeof(__u32) * 7);
1484 1484
1485 seq = twothirdsMD4Transform(daddr, hash) & HASH_MASK; 1485 seq = twothirdsMD4Transform((const __u32 *)daddr, hash) & HASH_MASK;
1486 seq += keyptr->count; 1486 seq += keyptr->count;
1487 1487
1488 do_gettimeofday(&tv); 1488 do_gettimeofday(&tv);
@@ -1496,7 +1496,7 @@ EXPORT_SYMBOL(secure_tcpv6_sequence_number);
1496/* The code below is shamelessly stolen from secure_tcp_sequence_number(). 1496/* The code below is shamelessly stolen from secure_tcp_sequence_number().
1497 * All blames to Andrey V. Savochkin <saw@msu.ru>. 1497 * All blames to Andrey V. Savochkin <saw@msu.ru>.
1498 */ 1498 */
1499__u32 secure_ip_id(__u32 daddr) 1499__u32 secure_ip_id(__be32 daddr)
1500{ 1500{
1501 struct keydata *keyptr; 1501 struct keydata *keyptr;
1502 __u32 hash[4]; 1502 __u32 hash[4];
@@ -1508,7 +1508,7 @@ __u32 secure_ip_id(__u32 daddr)
1508 * The dest ip address is placed in the starting vector, 1508 * The dest ip address is placed in the starting vector,
1509 * which is then hashed with random data. 1509 * which is then hashed with random data.
1510 */ 1510 */
1511 hash[0] = daddr; 1511 hash[0] = (__force __u32)daddr;
1512 hash[1] = keyptr->secret[9]; 1512 hash[1] = keyptr->secret[9];
1513 hash[2] = keyptr->secret[10]; 1513 hash[2] = keyptr->secret[10];
1514 hash[3] = keyptr->secret[11]; 1514 hash[3] = keyptr->secret[11];
@@ -1518,8 +1518,8 @@ __u32 secure_ip_id(__u32 daddr)
1518 1518
1519#ifdef CONFIG_INET 1519#ifdef CONFIG_INET
1520 1520
1521__u32 secure_tcp_sequence_number(__u32 saddr, __u32 daddr, 1521__u32 secure_tcp_sequence_number(__be32 saddr, __be32 daddr,
1522 __u16 sport, __u16 dport) 1522 __be16 sport, __be16 dport)
1523{ 1523{
1524 struct timeval tv; 1524 struct timeval tv;
1525 __u32 seq; 1525 __u32 seq;
@@ -1532,9 +1532,9 @@ __u32 secure_tcp_sequence_number(__u32 saddr, __u32 daddr,
1532 * Note that the words are placed into the starting vector, which is 1532 * Note that the words are placed into the starting vector, which is
1533 * then mixed with a partial MD4 over random data. 1533 * then mixed with a partial MD4 over random data.
1534 */ 1534 */
1535 hash[0]=saddr; 1535 hash[0]=(__force u32)saddr;
1536 hash[1]=daddr; 1536 hash[1]=(__force u32)daddr;
1537 hash[2]=(sport << 16) + dport; 1537 hash[2]=((__force u16)sport << 16) + (__force u16)dport;
1538 hash[3]=keyptr->secret[11]; 1538 hash[3]=keyptr->secret[11];
1539 1539
1540 seq = half_md4_transform(hash, keyptr->secret) & HASH_MASK; 1540 seq = half_md4_transform(hash, keyptr->secret) & HASH_MASK;
@@ -1559,7 +1559,7 @@ __u32 secure_tcp_sequence_number(__u32 saddr, __u32 daddr,
1559EXPORT_SYMBOL(secure_tcp_sequence_number); 1559EXPORT_SYMBOL(secure_tcp_sequence_number);
1560 1560
1561/* Generate secure starting point for ephemeral IPV4 transport port search */ 1561/* Generate secure starting point for ephemeral IPV4 transport port search */
1562u32 secure_ipv4_port_ephemeral(__u32 saddr, __u32 daddr, __u16 dport) 1562u32 secure_ipv4_port_ephemeral(__be32 saddr, __be32 daddr, __be16 dport)
1563{ 1563{
1564 struct keydata *keyptr = get_keyptr(); 1564 struct keydata *keyptr = get_keyptr();
1565 u32 hash[4]; 1565 u32 hash[4];
@@ -1568,25 +1568,25 @@ u32 secure_ipv4_port_ephemeral(__u32 saddr, __u32 daddr, __u16 dport)
1568 * Pick a unique starting offset for each ephemeral port search 1568 * Pick a unique starting offset for each ephemeral port search
1569 * (saddr, daddr, dport) and 48bits of random data. 1569 * (saddr, daddr, dport) and 48bits of random data.
1570 */ 1570 */
1571 hash[0] = saddr; 1571 hash[0] = (__force u32)saddr;
1572 hash[1] = daddr; 1572 hash[1] = (__force u32)daddr;
1573 hash[2] = dport ^ keyptr->secret[10]; 1573 hash[2] = (__force u32)dport ^ keyptr->secret[10];
1574 hash[3] = keyptr->secret[11]; 1574 hash[3] = keyptr->secret[11];
1575 1575
1576 return half_md4_transform(hash, keyptr->secret); 1576 return half_md4_transform(hash, keyptr->secret);
1577} 1577}
1578 1578
1579#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 1579#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
1580u32 secure_ipv6_port_ephemeral(const __u32 *saddr, const __u32 *daddr, __u16 dport) 1580u32 secure_ipv6_port_ephemeral(const __be32 *saddr, const __be32 *daddr, __be16 dport)
1581{ 1581{
1582 struct keydata *keyptr = get_keyptr(); 1582 struct keydata *keyptr = get_keyptr();
1583 u32 hash[12]; 1583 u32 hash[12];
1584 1584
1585 memcpy(hash, saddr, 16); 1585 memcpy(hash, saddr, 16);
1586 hash[4] = dport; 1586 hash[4] = (__force u32)dport;
1587 memcpy(&hash[5],keyptr->secret,sizeof(__u32) * 7); 1587 memcpy(&hash[5],keyptr->secret,sizeof(__u32) * 7);
1588 1588
1589 return twothirdsMD4Transform(daddr, hash); 1589 return twothirdsMD4Transform((const __u32 *)daddr, hash);
1590} 1590}
1591#endif 1591#endif
1592 1592
@@ -1595,17 +1595,17 @@ u32 secure_ipv6_port_ephemeral(const __u32 *saddr, const __u32 *daddr, __u16 dpo
1595 * bit's 32-47 increase every key exchange 1595 * bit's 32-47 increase every key exchange
1596 * 0-31 hash(source, dest) 1596 * 0-31 hash(source, dest)
1597 */ 1597 */
1598u64 secure_dccp_sequence_number(__u32 saddr, __u32 daddr, 1598u64 secure_dccp_sequence_number(__be32 saddr, __be32 daddr,
1599 __u16 sport, __u16 dport) 1599 __be16 sport, __be16 dport)
1600{ 1600{
1601 struct timeval tv; 1601 struct timeval tv;
1602 u64 seq; 1602 u64 seq;
1603 __u32 hash[4]; 1603 __u32 hash[4];
1604 struct keydata *keyptr = get_keyptr(); 1604 struct keydata *keyptr = get_keyptr();
1605 1605
1606 hash[0] = saddr; 1606 hash[0] = (__force u32)saddr;
1607 hash[1] = daddr; 1607 hash[1] = (__force u32)daddr;
1608 hash[2] = (sport << 16) + dport; 1608 hash[2] = ((__force u16)sport << 16) + (__force u16)dport;
1609 hash[3] = keyptr->secret[11]; 1609 hash[3] = keyptr->secret[11];
1610 1610
1611 seq = half_md4_transform(hash, keyptr->secret); 1611 seq = half_md4_transform(hash, keyptr->secret);
@@ -1641,7 +1641,7 @@ unsigned int get_random_int(void)
1641 * drain on it), and uses halfMD4Transform within the second. We 1641 * drain on it), and uses halfMD4Transform within the second. We
1642 * also mix it with jiffies and the PID: 1642 * also mix it with jiffies and the PID:
1643 */ 1643 */
1644 return secure_ip_id(current->pid + jiffies); 1644 return secure_ip_id((__force __be32)(current->pid + jiffies));
1645} 1645}
1646 1646
1647/* 1647/*
diff --git a/drivers/char/raw.c b/drivers/char/raw.c
index 89b718e326e5..3b32313f6eb4 100644
--- a/drivers/char/raw.c
+++ b/drivers/char/raw.c
@@ -127,9 +127,9 @@ raw_ioctl(struct inode *inode, struct file *filp,
127 127
128static void bind_device(struct raw_config_request *rq) 128static void bind_device(struct raw_config_request *rq)
129{ 129{
130 class_device_destroy(raw_class, MKDEV(RAW_MAJOR, rq->raw_minor)); 130 device_destroy(raw_class, MKDEV(RAW_MAJOR, rq->raw_minor));
131 class_device_create(raw_class, NULL, MKDEV(RAW_MAJOR, rq->raw_minor), 131 device_create(raw_class, NULL, MKDEV(RAW_MAJOR, rq->raw_minor),
132 NULL, "raw%d", rq->raw_minor); 132 "raw%d", rq->raw_minor);
133} 133}
134 134
135/* 135/*
@@ -200,7 +200,7 @@ static int raw_ctl_ioctl(struct inode *inode, struct file *filp,
200 if (rq.block_major == 0 && rq.block_minor == 0) { 200 if (rq.block_major == 0 && rq.block_minor == 0) {
201 /* unbind */ 201 /* unbind */
202 rawdev->binding = NULL; 202 rawdev->binding = NULL;
203 class_device_destroy(raw_class, 203 device_destroy(raw_class,
204 MKDEV(RAW_MAJOR, rq.raw_minor)); 204 MKDEV(RAW_MAJOR, rq.raw_minor));
205 } else { 205 } else {
206 rawdev->binding = bdget(dev); 206 rawdev->binding = bdget(dev);
@@ -283,7 +283,7 @@ static int __init raw_init(void)
283 ret = PTR_ERR(raw_class); 283 ret = PTR_ERR(raw_class);
284 goto error_region; 284 goto error_region;
285 } 285 }
286 class_device_create(raw_class, NULL, MKDEV(RAW_MAJOR, 0), NULL, "rawctl"); 286 device_create(raw_class, NULL, MKDEV(RAW_MAJOR, 0), "rawctl");
287 287
288 return 0; 288 return 0;
289 289
@@ -295,7 +295,7 @@ error:
295 295
296static void __exit raw_exit(void) 296static void __exit raw_exit(void)
297{ 297{
298 class_device_destroy(raw_class, MKDEV(RAW_MAJOR, 0)); 298 device_destroy(raw_class, MKDEV(RAW_MAJOR, 0));
299 class_destroy(raw_class); 299 class_destroy(raw_class);
300 cdev_del(&raw_cdev); 300 cdev_del(&raw_cdev);
301 unregister_chrdev_region(MKDEV(RAW_MAJOR, 0), MAX_RAW_MINORS); 301 unregister_chrdev_region(MKDEV(RAW_MAJOR, 0), MAX_RAW_MINORS);
diff --git a/drivers/char/rio/rio_linux.c b/drivers/char/rio/rio_linux.c
index 7ac68cb3bedd..e79b2ede8510 100644
--- a/drivers/char/rio/rio_linux.c
+++ b/drivers/char/rio/rio_linux.c
@@ -1026,6 +1026,7 @@ static int __init rio_init(void)
1026 found++; 1026 found++;
1027 } else { 1027 } else {
1028 iounmap(p->RIOHosts[p->RIONumHosts].Caddr); 1028 iounmap(p->RIOHosts[p->RIONumHosts].Caddr);
1029 p->RIOHosts[p->RIONumHosts].Caddr = NULL;
1029 } 1030 }
1030 } 1031 }
1031 1032
@@ -1078,6 +1079,7 @@ static int __init rio_init(void)
1078 found++; 1079 found++;
1079 } else { 1080 } else {
1080 iounmap(p->RIOHosts[p->RIONumHosts].Caddr); 1081 iounmap(p->RIOHosts[p->RIONumHosts].Caddr);
1082 p->RIOHosts[p->RIONumHosts].Caddr = NULL;
1081 } 1083 }
1082#else 1084#else
1083 printk(KERN_ERR "Found an older RIO PCI card, but the driver is not " "compiled to support it.\n"); 1085 printk(KERN_ERR "Found an older RIO PCI card, but the driver is not " "compiled to support it.\n");
@@ -1117,8 +1119,10 @@ static int __init rio_init(void)
1117 } 1119 }
1118 } 1120 }
1119 1121
1120 if (!okboard) 1122 if (!okboard) {
1121 iounmap(hp->Caddr); 1123 iounmap(hp->Caddr);
1124 hp->Caddr = NULL;
1125 }
1122 } 1126 }
1123 } 1127 }
1124 1128
@@ -1188,6 +1192,8 @@ static void __exit rio_exit(void)
1188 } 1192 }
1189 /* It is safe/allowed to del_timer a non-active timer */ 1193 /* It is safe/allowed to del_timer a non-active timer */
1190 del_timer(&hp->timer); 1194 del_timer(&hp->timer);
1195 if (hp->Caddr)
1196 iounmap(hp->Caddr);
1191 if (hp->Type == RIO_PCI) 1197 if (hp->Type == RIO_PCI)
1192 pci_dev_put(hp->pdev); 1198 pci_dev_put(hp->pdev);
1193 } 1199 }
diff --git a/drivers/char/rio/riocmd.c b/drivers/char/rio/riocmd.c
index 4df6ab2206a1..167ebc84e8d7 100644
--- a/drivers/char/rio/riocmd.c
+++ b/drivers/char/rio/riocmd.c
@@ -922,7 +922,7 @@ int RIOUnUse(unsigned long iPortP, struct CmdBlk *CmdBlkP)
922** 922**
923** Packet is an actual packet structure to be filled in with the packet 923** Packet is an actual packet structure to be filled in with the packet
924** information associated with the command. You need to fill in everything, 924** information associated with the command. You need to fill in everything,
925** as the command processore doesn't process the command packet in any way. 925** as the command processor doesn't process the command packet in any way.
926** 926**
927** The PreFuncP is called before the packet is enqueued on the host rup. 927** The PreFuncP is called before the packet is enqueued on the host rup.
928** PreFuncP is called as (*PreFuncP)(PreArg, CmdBlkP);. PreFuncP must 928** PreFuncP is called as (*PreFuncP)(PreArg, CmdBlkP);. PreFuncP must
diff --git a/drivers/char/rio/rioinit.c b/drivers/char/rio/rioinit.c
index 99f3df02b61c..0794844369d6 100644
--- a/drivers/char/rio/rioinit.c
+++ b/drivers/char/rio/rioinit.c
@@ -222,7 +222,7 @@ int RIOBoardTest(unsigned long paddr, void __iomem *caddr, unsigned char type, i
222** which value will be written into memory. 222** which value will be written into memory.
223** Call with op set to zero means that the RAM will not be read and checked 223** Call with op set to zero means that the RAM will not be read and checked
224** before it is written. 224** before it is written.
225** Call with op not zero, and the RAM will be read and compated with val[op-1] 225** Call with op not zero and the RAM will be read and compared with val[op-1]
226** to check that the data from the previous phase was retained. 226** to check that the data from the previous phase was retained.
227*/ 227*/
228 228
diff --git a/drivers/char/rio/rioparam.c b/drivers/char/rio/rioparam.c
index 1066d9760704..bb498d24adcc 100644
--- a/drivers/char/rio/rioparam.c
+++ b/drivers/char/rio/rioparam.c
@@ -87,8 +87,8 @@ static char *_rioparam_c_sccs_ = "@(#)rioparam.c 1.3";
87** command bit set onto the port. The command bit is in the len field, 87** command bit set onto the port. The command bit is in the len field,
88** and gets ORed in with the actual byte count. 88** and gets ORed in with the actual byte count.
89** 89**
90** When you send a packet with the command bit set, then the first 90** When you send a packet with the command bit set the first
91** data byte ( data[0] ) is interpretted as the command to execute. 91** data byte (data[0]) is interpreted as the command to execute.
92** It also governs what data structure overlay should accompany the packet. 92** It also governs what data structure overlay should accompany the packet.
93** Commands are defined in cirrus/cirrus.h 93** Commands are defined in cirrus/cirrus.h
94** 94**
@@ -103,7 +103,7 @@ static char *_rioparam_c_sccs_ = "@(#)rioparam.c 1.3";
103** 103**
104** Most commands do not use the remaining bytes in the data array. The 104** Most commands do not use the remaining bytes in the data array. The
105** exceptions are OPEN MOPEN and CONFIG. (NB. As with the SI CONFIG and 105** exceptions are OPEN MOPEN and CONFIG. (NB. As with the SI CONFIG and
106** OPEN are currently analagous). With these three commands the following 106** OPEN are currently analogous). With these three commands the following
107** 11 data bytes are all used to pass config information such as baud rate etc. 107** 11 data bytes are all used to pass config information such as baud rate etc.
108** The fields are also defined in cirrus.h. Some contain straightforward 108** The fields are also defined in cirrus.h. Some contain straightforward
109** information such as the transmit XON character. Two contain the transmit and 109** information such as the transmit XON character. Two contain the transmit and
diff --git a/drivers/char/riscom8.c b/drivers/char/riscom8.c
index 5ab32b38f45a..0a77bfcd5b5e 100644
--- a/drivers/char/riscom8.c
+++ b/drivers/char/riscom8.c
@@ -82,11 +82,6 @@
82static struct riscom_board * IRQ_to_board[16]; 82static struct riscom_board * IRQ_to_board[16];
83static struct tty_driver *riscom_driver; 83static struct tty_driver *riscom_driver;
84 84
85static unsigned long baud_table[] = {
86 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
87 9600, 19200, 38400, 57600, 76800, 0,
88};
89
90static struct riscom_board rc_board[RC_NBOARD] = { 85static struct riscom_board rc_board[RC_NBOARD] = {
91 { 86 {
92 .base = RC_IOBASE1, 87 .base = RC_IOBASE1,
@@ -1516,9 +1511,9 @@ static void rc_start(struct tty_struct * tty)
1516 * do_rc_hangup() -> tty->hangup() -> rc_hangup() 1511 * do_rc_hangup() -> tty->hangup() -> rc_hangup()
1517 * 1512 *
1518 */ 1513 */
1519static void do_rc_hangup(void *private_) 1514static void do_rc_hangup(struct work_struct *ugly_api)
1520{ 1515{
1521 struct riscom_port *port = (struct riscom_port *) private_; 1516 struct riscom_port *port = container_of(ugly_api, struct riscom_port, tqueue_hangup);
1522 struct tty_struct *tty; 1517 struct tty_struct *tty;
1523 1518
1524 tty = port->tty; 1519 tty = port->tty;
@@ -1567,9 +1562,9 @@ static void rc_set_termios(struct tty_struct * tty, struct termios * old_termios
1567 } 1562 }
1568} 1563}
1569 1564
1570static void do_softint(void *private_) 1565static void do_softint(struct work_struct *ugly_api)
1571{ 1566{
1572 struct riscom_port *port = (struct riscom_port *) private_; 1567 struct riscom_port *port = container_of(ugly_api, struct riscom_port, tqueue);
1573 struct tty_struct *tty; 1568 struct tty_struct *tty;
1574 1569
1575 if(!(tty = port->tty)) 1570 if(!(tty = port->tty))
@@ -1632,8 +1627,8 @@ static inline int rc_init_drivers(void)
1632 memset(rc_port, 0, sizeof(rc_port)); 1627 memset(rc_port, 0, sizeof(rc_port));
1633 for (i = 0; i < RC_NPORT * RC_NBOARD; i++) { 1628 for (i = 0; i < RC_NPORT * RC_NBOARD; i++) {
1634 rc_port[i].magic = RISCOM8_MAGIC; 1629 rc_port[i].magic = RISCOM8_MAGIC;
1635 INIT_WORK(&rc_port[i].tqueue, do_softint, &rc_port[i]); 1630 INIT_WORK(&rc_port[i].tqueue, do_softint);
1636 INIT_WORK(&rc_port[i].tqueue_hangup, do_rc_hangup, &rc_port[i]); 1631 INIT_WORK(&rc_port[i].tqueue_hangup, do_rc_hangup);
1637 rc_port[i].close_delay = 50 * HZ/100; 1632 rc_port[i].close_delay = 50 * HZ/100;
1638 rc_port[i].closing_wait = 3000 * HZ/100; 1633 rc_port[i].closing_wait = 3000 * HZ/100;
1639 init_waitqueue_head(&rc_port[i].open_wait); 1634 init_waitqueue_head(&rc_port[i].open_wait);
diff --git a/drivers/char/serial167.c b/drivers/char/serial167.c
index 3af7f0958c5d..9ba13af234be 100644
--- a/drivers/char/serial167.c
+++ b/drivers/char/serial167.c
@@ -706,9 +706,9 @@ cd2401_rx_interrupt(int irq, void *dev_id)
706 * had to poll every port to see if that port needed servicing. 706 * had to poll every port to see if that port needed servicing.
707 */ 707 */
708static void 708static void
709do_softint(void *private_) 709do_softint(struct work_struct *ugly_api)
710{ 710{
711 struct cyclades_port *info = (struct cyclades_port *) private_; 711 struct cyclades_port *info = container_of(ugly_api, struct cyclades_port, tqueue);
712 struct tty_struct *tty; 712 struct tty_struct *tty;
713 713
714 tty = info->tty; 714 tty = info->tty;
@@ -2273,7 +2273,7 @@ scrn[1] = '\0';
2273 info->blocked_open = 0; 2273 info->blocked_open = 0;
2274 info->default_threshold = 0; 2274 info->default_threshold = 0;
2275 info->default_timeout = 0; 2275 info->default_timeout = 0;
2276 INIT_WORK(&info->tqueue, do_softint, info); 2276 INIT_WORK(&info->tqueue, do_softint);
2277 init_waitqueue_head(&info->open_wait); 2277 init_waitqueue_head(&info->open_wait);
2278 init_waitqueue_head(&info->close_wait); 2278 init_waitqueue_head(&info->close_wait);
2279 /* info->session */ 2279 /* info->session */
diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
index c084149153de..fc87070f1866 100644
--- a/drivers/char/sonypi.c
+++ b/drivers/char/sonypi.c
@@ -765,7 +765,7 @@ static void sonypi_setbluetoothpower(u8 state)
765 sonypi_device.bluetooth_power = state; 765 sonypi_device.bluetooth_power = state;
766} 766}
767 767
768static void input_keyrelease(void *data) 768static void input_keyrelease(struct work_struct *work)
769{ 769{
770 struct sonypi_keypress kp; 770 struct sonypi_keypress kp;
771 771
@@ -1412,7 +1412,7 @@ static int __devinit sonypi_probe(struct platform_device *dev)
1412 goto err_inpdev_unregister; 1412 goto err_inpdev_unregister;
1413 } 1413 }
1414 1414
1415 INIT_WORK(&sonypi_device.input_work, input_keyrelease, NULL); 1415 INIT_WORK(&sonypi_device.input_work, input_keyrelease);
1416 } 1416 }
1417 1417
1418 sonypi_enable(0); 1418 sonypi_enable(0);
diff --git a/drivers/char/specialix.c b/drivers/char/specialix.c
index 7e1bd9562c2a..99137ab66b62 100644
--- a/drivers/char/specialix.c
+++ b/drivers/char/specialix.c
@@ -2261,9 +2261,10 @@ static void sx_start(struct tty_struct * tty)
2261 * do_sx_hangup() -> tty->hangup() -> sx_hangup() 2261 * do_sx_hangup() -> tty->hangup() -> sx_hangup()
2262 * 2262 *
2263 */ 2263 */
2264static void do_sx_hangup(void *private_) 2264static void do_sx_hangup(struct work_struct *work)
2265{ 2265{
2266 struct specialix_port *port = (struct specialix_port *) private_; 2266 struct specialix_port *port =
2267 container_of(work, struct specialix_port, tqueue_hangup);
2267 struct tty_struct *tty; 2268 struct tty_struct *tty;
2268 2269
2269 func_enter(); 2270 func_enter();
@@ -2336,9 +2337,10 @@ static void sx_set_termios(struct tty_struct * tty, struct termios * old_termios
2336} 2337}
2337 2338
2338 2339
2339static void do_softint(void *private_) 2340static void do_softint(struct work_struct *work)
2340{ 2341{
2341 struct specialix_port *port = (struct specialix_port *) private_; 2342 struct specialix_port *port =
2343 container_of(work, struct specialix_port, tqueue);
2342 struct tty_struct *tty; 2344 struct tty_struct *tty;
2343 2345
2344 func_enter(); 2346 func_enter();
@@ -2411,8 +2413,8 @@ static int sx_init_drivers(void)
2411 memset(sx_port, 0, sizeof(sx_port)); 2413 memset(sx_port, 0, sizeof(sx_port));
2412 for (i = 0; i < SX_NPORT * SX_NBOARD; i++) { 2414 for (i = 0; i < SX_NPORT * SX_NBOARD; i++) {
2413 sx_port[i].magic = SPECIALIX_MAGIC; 2415 sx_port[i].magic = SPECIALIX_MAGIC;
2414 INIT_WORK(&sx_port[i].tqueue, do_softint, &sx_port[i]); 2416 INIT_WORK(&sx_port[i].tqueue, do_softint);
2415 INIT_WORK(&sx_port[i].tqueue_hangup, do_sx_hangup, &sx_port[i]); 2417 INIT_WORK(&sx_port[i].tqueue_hangup, do_sx_hangup);
2416 sx_port[i].close_delay = 50 * HZ/100; 2418 sx_port[i].close_delay = 50 * HZ/100;
2417 sx_port[i].closing_wait = 3000 * HZ/100; 2419 sx_port[i].closing_wait = 3000 * HZ/100;
2418 init_waitqueue_head(&sx_port[i].open_wait); 2420 init_waitqueue_head(&sx_port[i].open_wait);
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c
index 522e88e395cc..5e2de62bce70 100644
--- a/drivers/char/stallion.c
+++ b/drivers/char/stallion.c
@@ -500,7 +500,7 @@ static int stl_echatintr(stlbrd_t *brdp);
500static int stl_echmcaintr(stlbrd_t *brdp); 500static int stl_echmcaintr(stlbrd_t *brdp);
501static int stl_echpciintr(stlbrd_t *brdp); 501static int stl_echpciintr(stlbrd_t *brdp);
502static int stl_echpci64intr(stlbrd_t *brdp); 502static int stl_echpci64intr(stlbrd_t *brdp);
503static void stl_offintr(void *private); 503static void stl_offintr(struct work_struct *);
504static stlbrd_t *stl_allocbrd(void); 504static stlbrd_t *stl_allocbrd(void);
505static stlport_t *stl_getport(int brdnr, int panelnr, int portnr); 505static stlport_t *stl_getport(int brdnr, int panelnr, int portnr);
506 506
@@ -2081,14 +2081,12 @@ static int stl_echpci64intr(stlbrd_t *brdp)
2081/* 2081/*
2082 * Service an off-level request for some channel. 2082 * Service an off-level request for some channel.
2083 */ 2083 */
2084static void stl_offintr(void *private) 2084static void stl_offintr(struct work_struct *work)
2085{ 2085{
2086 stlport_t *portp; 2086 stlport_t *portp = container_of(work, stlport_t, tqueue);
2087 struct tty_struct *tty; 2087 struct tty_struct *tty;
2088 unsigned int oldsigs; 2088 unsigned int oldsigs;
2089 2089
2090 portp = private;
2091
2092#ifdef DEBUG 2090#ifdef DEBUG
2093 printk("stl_offintr(portp=%x)\n", (int) portp); 2091 printk("stl_offintr(portp=%x)\n", (int) portp);
2094#endif 2092#endif
@@ -2156,7 +2154,7 @@ static int __init stl_initports(stlbrd_t *brdp, stlpanel_t *panelp)
2156 portp->baud_base = STL_BAUDBASE; 2154 portp->baud_base = STL_BAUDBASE;
2157 portp->close_delay = STL_CLOSEDELAY; 2155 portp->close_delay = STL_CLOSEDELAY;
2158 portp->closing_wait = 30 * HZ; 2156 portp->closing_wait = 30 * HZ;
2159 INIT_WORK(&portp->tqueue, stl_offintr, portp); 2157 INIT_WORK(&portp->tqueue, stl_offintr);
2160 init_waitqueue_head(&portp->open_wait); 2158 init_waitqueue_head(&portp->open_wait);
2161 init_waitqueue_head(&portp->close_wait); 2159 init_waitqueue_head(&portp->close_wait);
2162 portp->stats.brd = portp->brdnr; 2160 portp->stats.brd = portp->brdnr;
diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c
index 06784adcc35c..645187b9141e 100644
--- a/drivers/char/synclink.c
+++ b/drivers/char/synclink.c
@@ -101,8 +101,10 @@
101#include <linux/hdlc.h> 101#include <linux/hdlc.h>
102#include <linux/dma-mapping.h> 102#include <linux/dma-mapping.h>
103 103
104#ifdef CONFIG_HDLC_MODULE 104#if defined(CONFIG_HDLC) || (defined(CONFIG_HDLC_MODULE) && defined(CONFIG_SYNCLINK_MODULE))
105#define CONFIG_HDLC 1 105#define SYNCLINK_GENERIC_HDLC 1
106#else
107#define SYNCLINK_GENERIC_HDLC 0
106#endif 108#endif
107 109
108#define GET_USER(error,value,addr) error = get_user(value,addr) 110#define GET_USER(error,value,addr) error = get_user(value,addr)
@@ -320,7 +322,7 @@ struct mgsl_struct {
320 int dosyncppp; 322 int dosyncppp;
321 spinlock_t netlock; 323 spinlock_t netlock;
322 324
323#ifdef CONFIG_HDLC 325#if SYNCLINK_GENERIC_HDLC
324 struct net_device *netdev; 326 struct net_device *netdev;
325#endif 327#endif
326}; 328};
@@ -728,7 +730,7 @@ static void usc_loopmode_send_done( struct mgsl_struct * info );
728 730
729static int mgsl_ioctl_common(struct mgsl_struct *info, unsigned int cmd, unsigned long arg); 731static int mgsl_ioctl_common(struct mgsl_struct *info, unsigned int cmd, unsigned long arg);
730 732
731#ifdef CONFIG_HDLC 733#if SYNCLINK_GENERIC_HDLC
732#define dev_to_port(D) (dev_to_hdlc(D)->priv) 734#define dev_to_port(D) (dev_to_hdlc(D)->priv)
733static void hdlcdev_tx_done(struct mgsl_struct *info); 735static void hdlcdev_tx_done(struct mgsl_struct *info);
734static void hdlcdev_rx(struct mgsl_struct *info, char *buf, int size); 736static void hdlcdev_rx(struct mgsl_struct *info, char *buf, int size);
@@ -802,7 +804,7 @@ static int save_tx_buffer_request(struct mgsl_struct *info,const char *Buffer, u
802/* 804/*
803 * Bottom half interrupt handlers 805 * Bottom half interrupt handlers
804 */ 806 */
805static void mgsl_bh_handler(void* Context); 807static void mgsl_bh_handler(struct work_struct *work);
806static void mgsl_bh_receive(struct mgsl_struct *info); 808static void mgsl_bh_receive(struct mgsl_struct *info);
807static void mgsl_bh_transmit(struct mgsl_struct *info); 809static void mgsl_bh_transmit(struct mgsl_struct *info);
808static void mgsl_bh_status(struct mgsl_struct *info); 810static void mgsl_bh_status(struct mgsl_struct *info);
@@ -1071,9 +1073,10 @@ static int mgsl_bh_action(struct mgsl_struct *info)
1071/* 1073/*
1072 * Perform bottom half processing of work items queued by ISR. 1074 * Perform bottom half processing of work items queued by ISR.
1073 */ 1075 */
1074static void mgsl_bh_handler(void* Context) 1076static void mgsl_bh_handler(struct work_struct *work)
1075{ 1077{
1076 struct mgsl_struct *info = (struct mgsl_struct*)Context; 1078 struct mgsl_struct *info =
1079 container_of(work, struct mgsl_struct, task);
1077 int action; 1080 int action;
1078 1081
1079 if (!info) 1082 if (!info)
@@ -1276,7 +1279,7 @@ static void mgsl_isr_transmit_status( struct mgsl_struct *info )
1276 info->drop_rts_on_tx_done = 0; 1279 info->drop_rts_on_tx_done = 0;
1277 } 1280 }
1278 1281
1279#ifdef CONFIG_HDLC 1282#if SYNCLINK_GENERIC_HDLC
1280 if (info->netcount) 1283 if (info->netcount)
1281 hdlcdev_tx_done(info); 1284 hdlcdev_tx_done(info);
1282 else 1285 else
@@ -1341,7 +1344,7 @@ static void mgsl_isr_io_pin( struct mgsl_struct *info )
1341 info->input_signal_events.dcd_up++; 1344 info->input_signal_events.dcd_up++;
1342 } else 1345 } else
1343 info->input_signal_events.dcd_down++; 1346 info->input_signal_events.dcd_down++;
1344#ifdef CONFIG_HDLC 1347#if SYNCLINK_GENERIC_HDLC
1345 if (info->netcount) { 1348 if (info->netcount) {
1346 if (status & MISCSTATUS_DCD) 1349 if (status & MISCSTATUS_DCD)
1347 netif_carrier_on(info->netdev); 1350 netif_carrier_on(info->netdev);
@@ -4312,7 +4315,7 @@ static void mgsl_add_device( struct mgsl_struct *info )
4312 info->max_frame_size ); 4315 info->max_frame_size );
4313 } 4316 }
4314 4317
4315#ifdef CONFIG_HDLC 4318#if SYNCLINK_GENERIC_HDLC
4316 hdlcdev_init(info); 4319 hdlcdev_init(info);
4317#endif 4320#endif
4318 4321
@@ -4337,7 +4340,7 @@ static struct mgsl_struct* mgsl_allocate_device(void)
4337 } else { 4340 } else {
4338 memset(info, 0, sizeof(struct mgsl_struct)); 4341 memset(info, 0, sizeof(struct mgsl_struct));
4339 info->magic = MGSL_MAGIC; 4342 info->magic = MGSL_MAGIC;
4340 INIT_WORK(&info->task, mgsl_bh_handler, info); 4343 INIT_WORK(&info->task, mgsl_bh_handler);
4341 info->max_frame_size = 4096; 4344 info->max_frame_size = 4096;
4342 info->close_delay = 5*HZ/10; 4345 info->close_delay = 5*HZ/10;
4343 info->closing_wait = 30*HZ; 4346 info->closing_wait = 30*HZ;
@@ -4470,7 +4473,7 @@ static void synclink_cleanup(void)
4470 4473
4471 info = mgsl_device_list; 4474 info = mgsl_device_list;
4472 while(info) { 4475 while(info) {
4473#ifdef CONFIG_HDLC 4476#if SYNCLINK_GENERIC_HDLC
4474 hdlcdev_exit(info); 4477 hdlcdev_exit(info);
4475#endif 4478#endif
4476 mgsl_release_resources(info); 4479 mgsl_release_resources(info);
@@ -6644,7 +6647,7 @@ static int mgsl_get_rx_frame(struct mgsl_struct *info)
6644 return_frame = 1; 6647 return_frame = 1;
6645 } 6648 }
6646 framesize = 0; 6649 framesize = 0;
6647#ifdef CONFIG_HDLC 6650#if SYNCLINK_GENERIC_HDLC
6648 { 6651 {
6649 struct net_device_stats *stats = hdlc_stats(info->netdev); 6652 struct net_device_stats *stats = hdlc_stats(info->netdev);
6650 stats->rx_errors++; 6653 stats->rx_errors++;
@@ -6720,7 +6723,7 @@ static int mgsl_get_rx_frame(struct mgsl_struct *info)
6720 *ptmp); 6723 *ptmp);
6721 } 6724 }
6722 6725
6723#ifdef CONFIG_HDLC 6726#if SYNCLINK_GENERIC_HDLC
6724 if (info->netcount) 6727 if (info->netcount)
6725 hdlcdev_rx(info,info->intermediate_rxbuffer,framesize); 6728 hdlcdev_rx(info,info->intermediate_rxbuffer,framesize);
6726 else 6729 else
@@ -7624,7 +7627,7 @@ static void mgsl_tx_timeout(unsigned long context)
7624 7627
7625 spin_unlock_irqrestore(&info->irq_spinlock,flags); 7628 spin_unlock_irqrestore(&info->irq_spinlock,flags);
7626 7629
7627#ifdef CONFIG_HDLC 7630#if SYNCLINK_GENERIC_HDLC
7628 if (info->netcount) 7631 if (info->netcount)
7629 hdlcdev_tx_done(info); 7632 hdlcdev_tx_done(info);
7630 else 7633 else
@@ -7700,7 +7703,7 @@ static int usc_loopmode_active( struct mgsl_struct * info)
7700 return usc_InReg( info, CCSR ) & BIT7 ? 1 : 0 ; 7703 return usc_InReg( info, CCSR ) & BIT7 ? 1 : 0 ;
7701} 7704}
7702 7705
7703#ifdef CONFIG_HDLC 7706#if SYNCLINK_GENERIC_HDLC
7704 7707
7705/** 7708/**
7706 * called by generic HDLC layer when protocol selected (PPP, frame relay, etc.) 7709 * called by generic HDLC layer when protocol selected (PPP, frame relay, etc.)
diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c
index d4334c79f8d4..e4730a7312b5 100644
--- a/drivers/char/synclink_gt.c
+++ b/drivers/char/synclink_gt.c
@@ -83,8 +83,10 @@
83 83
84#include "linux/synclink.h" 84#include "linux/synclink.h"
85 85
86#ifdef CONFIG_HDLC_MODULE 86#if defined(CONFIG_HDLC) || (defined(CONFIG_HDLC_MODULE) && defined(CONFIG_SYNCLINK_GT_MODULE))
87#define CONFIG_HDLC 1 87#define SYNCLINK_GENERIC_HDLC 1
88#else
89#define SYNCLINK_GENERIC_HDLC 0
88#endif 90#endif
89 91
90/* 92/*
@@ -171,7 +173,7 @@ static void set_break(struct tty_struct *tty, int break_state);
171/* 173/*
172 * generic HDLC support and callbacks 174 * generic HDLC support and callbacks
173 */ 175 */
174#ifdef CONFIG_HDLC 176#if SYNCLINK_GENERIC_HDLC
175#define dev_to_port(D) (dev_to_hdlc(D)->priv) 177#define dev_to_port(D) (dev_to_hdlc(D)->priv)
176static void hdlcdev_tx_done(struct slgt_info *info); 178static void hdlcdev_tx_done(struct slgt_info *info);
177static void hdlcdev_rx(struct slgt_info *info, char *buf, int size); 179static void hdlcdev_rx(struct slgt_info *info, char *buf, int size);
@@ -359,7 +361,7 @@ struct slgt_info {
359 int netcount; 361 int netcount;
360 int dosyncppp; 362 int dosyncppp;
361 spinlock_t netlock; 363 spinlock_t netlock;
362#ifdef CONFIG_HDLC 364#if SYNCLINK_GENERIC_HDLC
363 struct net_device *netdev; 365 struct net_device *netdev;
364#endif 366#endif
365 367
@@ -485,7 +487,7 @@ static void enable_loopback(struct slgt_info *info);
485static void set_rate(struct slgt_info *info, u32 data_rate); 487static void set_rate(struct slgt_info *info, u32 data_rate);
486 488
487static int bh_action(struct slgt_info *info); 489static int bh_action(struct slgt_info *info);
488static void bh_handler(void* context); 490static void bh_handler(struct work_struct *work);
489static void bh_transmit(struct slgt_info *info); 491static void bh_transmit(struct slgt_info *info);
490static void isr_serial(struct slgt_info *info); 492static void isr_serial(struct slgt_info *info);
491static void isr_rdma(struct slgt_info *info); 493static void isr_rdma(struct slgt_info *info);
@@ -1354,7 +1356,7 @@ static void set_break(struct tty_struct *tty, int break_state)
1354 spin_unlock_irqrestore(&info->lock,flags); 1356 spin_unlock_irqrestore(&info->lock,flags);
1355} 1357}
1356 1358
1357#ifdef CONFIG_HDLC 1359#if SYNCLINK_GENERIC_HDLC
1358 1360
1359/** 1361/**
1360 * called by generic HDLC layer when protocol selected (PPP, frame relay, etc.) 1362 * called by generic HDLC layer when protocol selected (PPP, frame relay, etc.)
@@ -1878,9 +1880,9 @@ static int bh_action(struct slgt_info *info)
1878/* 1880/*
1879 * perform bottom half processing 1881 * perform bottom half processing
1880 */ 1882 */
1881static void bh_handler(void* context) 1883static void bh_handler(struct work_struct *work)
1882{ 1884{
1883 struct slgt_info *info = context; 1885 struct slgt_info *info = container_of(work, struct slgt_info, task);
1884 int action; 1886 int action;
1885 1887
1886 if (!info) 1888 if (!info)
@@ -2002,7 +2004,7 @@ static void dcd_change(struct slgt_info *info)
2002 } else { 2004 } else {
2003 info->input_signal_events.dcd_down++; 2005 info->input_signal_events.dcd_down++;
2004 } 2006 }
2005#ifdef CONFIG_HDLC 2007#if SYNCLINK_GENERIC_HDLC
2006 if (info->netcount) { 2008 if (info->netcount) {
2007 if (info->signals & SerialSignal_DCD) 2009 if (info->signals & SerialSignal_DCD)
2008 netif_carrier_on(info->netdev); 2010 netif_carrier_on(info->netdev);
@@ -2180,7 +2182,7 @@ static void isr_txeom(struct slgt_info *info, unsigned short status)
2180 set_signals(info); 2182 set_signals(info);
2181 } 2183 }
2182 2184
2183#ifdef CONFIG_HDLC 2185#if SYNCLINK_GENERIC_HDLC
2184 if (info->netcount) 2186 if (info->netcount)
2185 hdlcdev_tx_done(info); 2187 hdlcdev_tx_done(info);
2186 else 2188 else
@@ -3306,7 +3308,7 @@ static void add_device(struct slgt_info *info)
3306 devstr, info->device_name, info->phys_reg_addr, 3308 devstr, info->device_name, info->phys_reg_addr,
3307 info->irq_level, info->max_frame_size); 3309 info->irq_level, info->max_frame_size);
3308 3310
3309#ifdef CONFIG_HDLC 3311#if SYNCLINK_GENERIC_HDLC
3310 hdlcdev_init(info); 3312 hdlcdev_init(info);
3311#endif 3313#endif
3312} 3314}
@@ -3326,7 +3328,7 @@ static struct slgt_info *alloc_dev(int adapter_num, int port_num, struct pci_dev
3326 } else { 3328 } else {
3327 memset(info, 0, sizeof(struct slgt_info)); 3329 memset(info, 0, sizeof(struct slgt_info));
3328 info->magic = MGSL_MAGIC; 3330 info->magic = MGSL_MAGIC;
3329 INIT_WORK(&info->task, bh_handler, info); 3331 INIT_WORK(&info->task, bh_handler);
3330 info->max_frame_size = 4096; 3332 info->max_frame_size = 4096;
3331 info->raw_rx_size = DMABUFSIZE; 3333 info->raw_rx_size = DMABUFSIZE;
3332 info->close_delay = 5*HZ/10; 3334 info->close_delay = 5*HZ/10;
@@ -3488,7 +3490,7 @@ static void slgt_cleanup(void)
3488 /* release devices */ 3490 /* release devices */
3489 info = slgt_device_list; 3491 info = slgt_device_list;
3490 while(info) { 3492 while(info) {
3491#ifdef CONFIG_HDLC 3493#if SYNCLINK_GENERIC_HDLC
3492 hdlcdev_exit(info); 3494 hdlcdev_exit(info);
3493#endif 3495#endif
3494 free_dma_bufs(info); 3496 free_dma_bufs(info);
@@ -3522,6 +3524,7 @@ static int __init slgt_init(void)
3522 3524
3523 if (!slgt_device_list) { 3525 if (!slgt_device_list) {
3524 printk("%s no devices found\n",driver_name); 3526 printk("%s no devices found\n",driver_name);
3527 pci_unregister_driver(&pci_driver);
3525 return -ENODEV; 3528 return -ENODEV;
3526 } 3529 }
3527 3530
@@ -4433,7 +4436,7 @@ check_again:
4433 framesize = 0; 4436 framesize = 0;
4434 } 4437 }
4435 4438
4436#ifdef CONFIG_HDLC 4439#if SYNCLINK_GENERIC_HDLC
4437 if (framesize == 0) { 4440 if (framesize == 0) {
4438 struct net_device_stats *stats = hdlc_stats(info->netdev); 4441 struct net_device_stats *stats = hdlc_stats(info->netdev);
4439 stats->rx_errors++; 4442 stats->rx_errors++;
@@ -4476,7 +4479,7 @@ check_again:
4476 framesize++; 4479 framesize++;
4477 } 4480 }
4478 4481
4479#ifdef CONFIG_HDLC 4482#if SYNCLINK_GENERIC_HDLC
4480 if (info->netcount) 4483 if (info->netcount)
4481 hdlcdev_rx(info,info->tmp_rbuf, framesize); 4484 hdlcdev_rx(info,info->tmp_rbuf, framesize);
4482 else 4485 else
@@ -4779,7 +4782,7 @@ static void tx_timeout(unsigned long context)
4779 info->tx_count = 0; 4782 info->tx_count = 0;
4780 spin_unlock_irqrestore(&info->lock,flags); 4783 spin_unlock_irqrestore(&info->lock,flags);
4781 4784
4782#ifdef CONFIG_HDLC 4785#if SYNCLINK_GENERIC_HDLC
4783 if (info->netcount) 4786 if (info->netcount)
4784 hdlcdev_tx_done(info); 4787 hdlcdev_tx_done(info);
4785 else 4788 else
@@ -4799,6 +4802,6 @@ static void rx_timeout(unsigned long context)
4799 spin_lock_irqsave(&info->lock, flags); 4802 spin_lock_irqsave(&info->lock, flags);
4800 info->pending_bh |= BH_RECEIVE; 4803 info->pending_bh |= BH_RECEIVE;
4801 spin_unlock_irqrestore(&info->lock, flags); 4804 spin_unlock_irqrestore(&info->lock, flags);
4802 bh_handler(info); 4805 bh_handler(&info->task);
4803} 4806}
4804 4807
diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c
index 3e932b681371..20a96ef250be 100644
--- a/drivers/char/synclinkmp.c
+++ b/drivers/char/synclinkmp.c
@@ -67,8 +67,10 @@
67#include <linux/workqueue.h> 67#include <linux/workqueue.h>
68#include <linux/hdlc.h> 68#include <linux/hdlc.h>
69 69
70#ifdef CONFIG_HDLC_MODULE 70#if defined(CONFIG_HDLC) || (defined(CONFIG_HDLC_MODULE) && defined(CONFIG_SYNCLINKMP_MODULE))
71#define CONFIG_HDLC 1 71#define SYNCLINK_GENERIC_HDLC 1
72#else
73#define SYNCLINK_GENERIC_HDLC 0
72#endif 74#endif
73 75
74#define GET_USER(error,value,addr) error = get_user(value,addr) 76#define GET_USER(error,value,addr) error = get_user(value,addr)
@@ -280,7 +282,7 @@ typedef struct _synclinkmp_info {
280 int dosyncppp; 282 int dosyncppp;
281 spinlock_t netlock; 283 spinlock_t netlock;
282 284
283#ifdef CONFIG_HDLC 285#if SYNCLINK_GENERIC_HDLC
284 struct net_device *netdev; 286 struct net_device *netdev;
285#endif 287#endif
286 288
@@ -536,7 +538,7 @@ static void throttle(struct tty_struct * tty);
536static void unthrottle(struct tty_struct * tty); 538static void unthrottle(struct tty_struct * tty);
537static void set_break(struct tty_struct *tty, int break_state); 539static void set_break(struct tty_struct *tty, int break_state);
538 540
539#ifdef CONFIG_HDLC 541#if SYNCLINK_GENERIC_HDLC
540#define dev_to_port(D) (dev_to_hdlc(D)->priv) 542#define dev_to_port(D) (dev_to_hdlc(D)->priv)
541static void hdlcdev_tx_done(SLMP_INFO *info); 543static void hdlcdev_tx_done(SLMP_INFO *info);
542static void hdlcdev_rx(SLMP_INFO *info, char *buf, int size); 544static void hdlcdev_rx(SLMP_INFO *info, char *buf, int size);
@@ -602,7 +604,7 @@ static void enable_loopback(SLMP_INFO *info, int enable);
602static void set_rate(SLMP_INFO *info, u32 data_rate); 604static void set_rate(SLMP_INFO *info, u32 data_rate);
603 605
604static int bh_action(SLMP_INFO *info); 606static int bh_action(SLMP_INFO *info);
605static void bh_handler(void* Context); 607static void bh_handler(struct work_struct *work);
606static void bh_receive(SLMP_INFO *info); 608static void bh_receive(SLMP_INFO *info);
607static void bh_transmit(SLMP_INFO *info); 609static void bh_transmit(SLMP_INFO *info);
608static void bh_status(SLMP_INFO *info); 610static void bh_status(SLMP_INFO *info);
@@ -1607,7 +1609,7 @@ static void set_break(struct tty_struct *tty, int break_state)
1607 spin_unlock_irqrestore(&info->lock,flags); 1609 spin_unlock_irqrestore(&info->lock,flags);
1608} 1610}
1609 1611
1610#ifdef CONFIG_HDLC 1612#if SYNCLINK_GENERIC_HDLC
1611 1613
1612/** 1614/**
1613 * called by generic HDLC layer when protocol selected (PPP, frame relay, etc.) 1615 * called by generic HDLC layer when protocol selected (PPP, frame relay, etc.)
@@ -2063,9 +2065,9 @@ int bh_action(SLMP_INFO *info)
2063 2065
2064/* Perform bottom half processing of work items queued by ISR. 2066/* Perform bottom half processing of work items queued by ISR.
2065 */ 2067 */
2066void bh_handler(void* Context) 2068void bh_handler(struct work_struct *work)
2067{ 2069{
2068 SLMP_INFO *info = (SLMP_INFO*)Context; 2070 SLMP_INFO *info = container_of(work, SLMP_INFO, task);
2069 int action; 2071 int action;
2070 2072
2071 if (!info) 2073 if (!info)
@@ -2339,7 +2341,7 @@ static void isr_txeom(SLMP_INFO * info, unsigned char status)
2339 set_signals(info); 2341 set_signals(info);
2340 } 2342 }
2341 2343
2342#ifdef CONFIG_HDLC 2344#if SYNCLINK_GENERIC_HDLC
2343 if (info->netcount) 2345 if (info->netcount)
2344 hdlcdev_tx_done(info); 2346 hdlcdev_tx_done(info);
2345 else 2347 else
@@ -2523,7 +2525,7 @@ void isr_io_pin( SLMP_INFO *info, u16 status )
2523 info->input_signal_events.dcd_up++; 2525 info->input_signal_events.dcd_up++;
2524 } else 2526 } else
2525 info->input_signal_events.dcd_down++; 2527 info->input_signal_events.dcd_down++;
2526#ifdef CONFIG_HDLC 2528#if SYNCLINK_GENERIC_HDLC
2527 if (info->netcount) { 2529 if (info->netcount) {
2528 if (status & SerialSignal_DCD) 2530 if (status & SerialSignal_DCD)
2529 netif_carrier_on(info->netdev); 2531 netif_carrier_on(info->netdev);
@@ -3783,7 +3785,7 @@ void add_device(SLMP_INFO *info)
3783 info->irq_level, 3785 info->irq_level,
3784 info->max_frame_size ); 3786 info->max_frame_size );
3785 3787
3786#ifdef CONFIG_HDLC 3788#if SYNCLINK_GENERIC_HDLC
3787 hdlcdev_init(info); 3789 hdlcdev_init(info);
3788#endif 3790#endif
3789} 3791}
@@ -3805,7 +3807,7 @@ static SLMP_INFO *alloc_dev(int adapter_num, int port_num, struct pci_dev *pdev)
3805 } else { 3807 } else {
3806 memset(info, 0, sizeof(SLMP_INFO)); 3808 memset(info, 0, sizeof(SLMP_INFO));
3807 info->magic = MGSL_MAGIC; 3809 info->magic = MGSL_MAGIC;
3808 INIT_WORK(&info->task, bh_handler, info); 3810 INIT_WORK(&info->task, bh_handler);
3809 info->max_frame_size = 4096; 3811 info->max_frame_size = 4096;
3810 info->close_delay = 5*HZ/10; 3812 info->close_delay = 5*HZ/10;
3811 info->closing_wait = 30*HZ; 3813 info->closing_wait = 30*HZ;
@@ -3977,7 +3979,7 @@ static void synclinkmp_cleanup(void)
3977 /* release devices */ 3979 /* release devices */
3978 info = synclinkmp_device_list; 3980 info = synclinkmp_device_list;
3979 while(info) { 3981 while(info) {
3980#ifdef CONFIG_HDLC 3982#if SYNCLINK_GENERIC_HDLC
3981 hdlcdev_exit(info); 3983 hdlcdev_exit(info);
3982#endif 3984#endif
3983 free_dma_bufs(info); 3985 free_dma_bufs(info);
@@ -4979,7 +4981,7 @@ CheckAgain:
4979 info->icount.rxcrc++; 4981 info->icount.rxcrc++;
4980 4982
4981 framesize = 0; 4983 framesize = 0;
4982#ifdef CONFIG_HDLC 4984#if SYNCLINK_GENERIC_HDLC
4983 { 4985 {
4984 struct net_device_stats *stats = hdlc_stats(info->netdev); 4986 struct net_device_stats *stats = hdlc_stats(info->netdev);
4985 stats->rx_errors++; 4987 stats->rx_errors++;
@@ -5020,7 +5022,7 @@ CheckAgain:
5020 index = 0; 5022 index = 0;
5021 } 5023 }
5022 5024
5023#ifdef CONFIG_HDLC 5025#if SYNCLINK_GENERIC_HDLC
5024 if (info->netcount) 5026 if (info->netcount)
5025 hdlcdev_rx(info,info->tmp_rx_buf,framesize); 5027 hdlcdev_rx(info,info->tmp_rx_buf,framesize);
5026 else 5028 else
@@ -5531,7 +5533,7 @@ void tx_timeout(unsigned long context)
5531 5533
5532 spin_unlock_irqrestore(&info->lock,flags); 5534 spin_unlock_irqrestore(&info->lock,flags);
5533 5535
5534#ifdef CONFIG_HDLC 5536#if SYNCLINK_GENERIC_HDLC
5535 if (info->netcount) 5537 if (info->netcount)
5536 hdlcdev_tx_done(info); 5538 hdlcdev_tx_done(info);
5537 else 5539 else
diff --git a/drivers/char/sysrq.c b/drivers/char/sysrq.c
index 5f49280779fb..05810c8d20bc 100644
--- a/drivers/char/sysrq.c
+++ b/drivers/char/sysrq.c
@@ -182,6 +182,18 @@ static struct sysrq_key_op sysrq_showstate_op = {
182 .enable_mask = SYSRQ_ENABLE_DUMP, 182 .enable_mask = SYSRQ_ENABLE_DUMP,
183}; 183};
184 184
185static void sysrq_handle_showstate_blocked(int key, struct tty_struct *tty)
186{
187 show_state_filter(TASK_UNINTERRUPTIBLE);
188}
189static struct sysrq_key_op sysrq_showstate_blocked_op = {
190 .handler = sysrq_handle_showstate_blocked,
191 .help_msg = "showBlockedTasks",
192 .action_msg = "Show Blocked State",
193 .enable_mask = SYSRQ_ENABLE_DUMP,
194};
195
196
185static void sysrq_handle_showmem(int key, struct tty_struct *tty) 197static void sysrq_handle_showmem(int key, struct tty_struct *tty)
186{ 198{
187 show_mem(); 199 show_mem();
@@ -219,13 +231,13 @@ static struct sysrq_key_op sysrq_term_op = {
219 .enable_mask = SYSRQ_ENABLE_SIGNAL, 231 .enable_mask = SYSRQ_ENABLE_SIGNAL,
220}; 232};
221 233
222static void moom_callback(void *ignored) 234static void moom_callback(struct work_struct *ignored)
223{ 235{
224 out_of_memory(&NODE_DATA(0)->node_zonelists[ZONE_NORMAL], 236 out_of_memory(&NODE_DATA(0)->node_zonelists[ZONE_NORMAL],
225 GFP_KERNEL, 0); 237 GFP_KERNEL, 0);
226} 238}
227 239
228static DECLARE_WORK(moom_work, moom_callback, NULL); 240static DECLARE_WORK(moom_work, moom_callback);
229 241
230static void sysrq_handle_moom(int key, struct tty_struct *tty) 242static void sysrq_handle_moom(int key, struct tty_struct *tty)
231{ 243{
@@ -304,7 +316,7 @@ static struct sysrq_key_op *sysrq_key_table[36] = {
304 /* May be assigned at init time by SMP VOYAGER */ 316 /* May be assigned at init time by SMP VOYAGER */
305 NULL, /* v */ 317 NULL, /* v */
306 NULL, /* w */ 318 NULL, /* w */
307 NULL, /* x */ 319 &sysrq_showstate_blocked_op, /* x */
308 NULL, /* y */ 320 NULL, /* y */
309 NULL /* z */ 321 NULL /* z */
310}; 322};
diff --git a/drivers/char/tlclk.c b/drivers/char/tlclk.c
index 2444a0e24b31..244d30a03fef 100644
--- a/drivers/char/tlclk.c
+++ b/drivers/char/tlclk.c
@@ -792,15 +792,14 @@ static int __init tlclk_init(void)
792 ret = misc_register(&tlclk_miscdev); 792 ret = misc_register(&tlclk_miscdev);
793 if (ret < 0) { 793 if (ret < 0) {
794 printk(KERN_ERR "tlclk: misc_register returns %d.\n", ret); 794 printk(KERN_ERR "tlclk: misc_register returns %d.\n", ret);
795 ret = -EBUSY;
796 goto out3; 795 goto out3;
797 } 796 }
798 797
799 tlclk_device = platform_device_register_simple("telco_clock", 798 tlclk_device = platform_device_register_simple("telco_clock",
800 -1, NULL, 0); 799 -1, NULL, 0);
801 if (!tlclk_device) { 800 if (IS_ERR(tlclk_device)) {
802 printk(KERN_ERR "tlclk: platform_device_register failed.\n"); 801 printk(KERN_ERR "tlclk: platform_device_register failed.\n");
803 ret = -EBUSY; 802 ret = PTR_ERR(tlclk_device);
804 goto out4; 803 goto out4;
805 } 804 }
806 805
diff --git a/drivers/char/toshiba.c b/drivers/char/toshiba.c
index dd36fd04a842..07067c31c4ec 100644
--- a/drivers/char/toshiba.c
+++ b/drivers/char/toshiba.c
@@ -249,6 +249,7 @@ int tosh_smm(SMMRegisters *regs)
249 249
250 return eax; 250 return eax;
251} 251}
252EXPORT_SYMBOL(tosh_smm);
252 253
253 254
254static int tosh_ioctl(struct inode *ip, struct file *fp, unsigned int cmd, 255static int tosh_ioctl(struct inode *ip, struct file *fp, unsigned int cmd,
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index 6ad2d3bb945c..33e1f66e39cb 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -325,9 +325,9 @@ static void user_reader_timeout(unsigned long ptr)
325 schedule_work(&chip->work); 325 schedule_work(&chip->work);
326} 326}
327 327
328static void timeout_work(void *ptr) 328static void timeout_work(struct work_struct *work)
329{ 329{
330 struct tpm_chip *chip = ptr; 330 struct tpm_chip *chip = container_of(work, struct tpm_chip, work);
331 331
332 down(&chip->buffer_mutex); 332 down(&chip->buffer_mutex);
333 atomic_set(&chip->data_pending, 0); 333 atomic_set(&chip->data_pending, 0);
@@ -1105,7 +1105,7 @@ struct tpm_chip *tpm_register_hardware(struct device *dev, const struct tpm_vend
1105 init_MUTEX(&chip->tpm_mutex); 1105 init_MUTEX(&chip->tpm_mutex);
1106 INIT_LIST_HEAD(&chip->list); 1106 INIT_LIST_HEAD(&chip->list);
1107 1107
1108 INIT_WORK(&chip->work, timeout_work, chip); 1108 INIT_WORK(&chip->work, timeout_work);
1109 1109
1110 init_timer(&chip->user_read_timer); 1110 init_timer(&chip->user_read_timer);
1111 chip->user_read_timer.function = user_reader_timeout; 1111 chip->user_read_timer.function = user_reader_timeout;
@@ -1130,7 +1130,7 @@ struct tpm_chip *tpm_register_hardware(struct device *dev, const struct tpm_vend
1130 scnprintf(devname, DEVNAME_SIZE, "%s%d", "tpm", chip->dev_num); 1130 scnprintf(devname, DEVNAME_SIZE, "%s%d", "tpm", chip->dev_num);
1131 chip->vendor.miscdev.name = devname; 1131 chip->vendor.miscdev.name = devname;
1132 1132
1133 chip->vendor.miscdev.dev = dev; 1133 chip->vendor.miscdev.parent = dev;
1134 chip->dev = get_device(dev); 1134 chip->dev = get_device(dev);
1135 1135
1136 if (misc_register(&chip->vendor.miscdev)) { 1136 if (misc_register(&chip->vendor.miscdev)) {
@@ -1155,6 +1155,7 @@ struct tpm_chip *tpm_register_hardware(struct device *dev, const struct tpm_vend
1155 1155
1156 if (sysfs_create_group(&dev->kobj, chip->vendor.attr_group)) { 1156 if (sysfs_create_group(&dev->kobj, chip->vendor.attr_group)) {
1157 list_del(&chip->list); 1157 list_del(&chip->list);
1158 misc_deregister(&chip->vendor.miscdev);
1158 put_device(dev); 1159 put_device(dev);
1159 clear_bit(chip->dev_num, dev_mask); 1160 clear_bit(chip->dev_num, dev_mask);
1160 kfree(chip); 1161 kfree(chip);
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index 050ced247f68..bb9a43c6cf3d 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -22,6 +22,7 @@
22#include <linux/pci.h> 22#include <linux/pci.h>
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/fs.h> 24#include <linux/fs.h>
25#include <linux/sched.h>
25#include <linux/miscdevice.h> 26#include <linux/miscdevice.h>
26#include <linux/platform_device.h> 27#include <linux/platform_device.h>
27#include <linux/io.h> 28#include <linux/io.h>
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index e90ea39c7c4b..b3cfc8bc613c 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -1254,7 +1254,7 @@ EXPORT_SYMBOL_GPL(tty_ldisc_flush);
1254 1254
1255/** 1255/**
1256 * do_tty_hangup - actual handler for hangup events 1256 * do_tty_hangup - actual handler for hangup events
1257 * @data: tty device 1257 * @work: tty device
1258 * 1258 *
1259 * This can be called by the "eventd" kernel thread. That is process 1259 * This can be called by the "eventd" kernel thread. That is process
1260 * synchronous but doesn't hold any locks, so we need to make sure we 1260 * synchronous but doesn't hold any locks, so we need to make sure we
@@ -1274,9 +1274,10 @@ EXPORT_SYMBOL_GPL(tty_ldisc_flush);
1274 * tasklist_lock to walk task list for hangup event 1274 * tasklist_lock to walk task list for hangup event
1275 * 1275 *
1276 */ 1276 */
1277static void do_tty_hangup(void *data) 1277static void do_tty_hangup(struct work_struct *work)
1278{ 1278{
1279 struct tty_struct *tty = (struct tty_struct *) data; 1279 struct tty_struct *tty =
1280 container_of(work, struct tty_struct, hangup_work);
1280 struct file * cons_filp = NULL; 1281 struct file * cons_filp = NULL;
1281 struct file *filp, *f = NULL; 1282 struct file *filp, *f = NULL;
1282 struct task_struct *p; 1283 struct task_struct *p;
@@ -1433,7 +1434,7 @@ void tty_vhangup(struct tty_struct * tty)
1433 1434
1434 printk(KERN_DEBUG "%s vhangup...\n", tty_name(tty, buf)); 1435 printk(KERN_DEBUG "%s vhangup...\n", tty_name(tty, buf));
1435#endif 1436#endif
1436 do_tty_hangup((void *) tty); 1437 do_tty_hangup(&tty->hangup_work);
1437} 1438}
1438EXPORT_SYMBOL(tty_vhangup); 1439EXPORT_SYMBOL(tty_vhangup);
1439 1440
@@ -3304,12 +3305,13 @@ int tty_ioctl(struct inode * inode, struct file * file,
3304 * Nasty bug: do_SAK is being called in interrupt context. This can 3305 * Nasty bug: do_SAK is being called in interrupt context. This can
3305 * deadlock. We punt it up to process context. AKPM - 16Mar2001 3306 * deadlock. We punt it up to process context. AKPM - 16Mar2001
3306 */ 3307 */
3307static void __do_SAK(void *arg) 3308static void __do_SAK(struct work_struct *work)
3308{ 3309{
3310 struct tty_struct *tty =
3311 container_of(work, struct tty_struct, SAK_work);
3309#ifdef TTY_SOFT_SAK 3312#ifdef TTY_SOFT_SAK
3310 tty_hangup(tty); 3313 tty_hangup(tty);
3311#else 3314#else
3312 struct tty_struct *tty = arg;
3313 struct task_struct *g, *p; 3315 struct task_struct *g, *p;
3314 int session; 3316 int session;
3315 int i; 3317 int i;
@@ -3388,7 +3390,7 @@ void do_SAK(struct tty_struct *tty)
3388{ 3390{
3389 if (!tty) 3391 if (!tty)
3390 return; 3392 return;
3391 PREPARE_WORK(&tty->SAK_work, __do_SAK, tty); 3393 PREPARE_WORK(&tty->SAK_work, __do_SAK);
3392 schedule_work(&tty->SAK_work); 3394 schedule_work(&tty->SAK_work);
3393} 3395}
3394 3396
@@ -3396,7 +3398,7 @@ EXPORT_SYMBOL(do_SAK);
3396 3398
3397/** 3399/**
3398 * flush_to_ldisc 3400 * flush_to_ldisc
3399 * @private_: tty structure passed from work queue. 3401 * @work: tty structure passed from work queue.
3400 * 3402 *
3401 * This routine is called out of the software interrupt to flush data 3403 * This routine is called out of the software interrupt to flush data
3402 * from the buffer chain to the line discipline. 3404 * from the buffer chain to the line discipline.
@@ -3406,9 +3408,10 @@ EXPORT_SYMBOL(do_SAK);
3406 * receive_buf method is single threaded for each tty instance. 3408 * receive_buf method is single threaded for each tty instance.
3407 */ 3409 */
3408 3410
3409static void flush_to_ldisc(void *private_) 3411static void flush_to_ldisc(struct work_struct *work)
3410{ 3412{
3411 struct tty_struct *tty = (struct tty_struct *) private_; 3413 struct tty_struct *tty =
3414 container_of(work, struct tty_struct, buf.work.work);
3412 unsigned long flags; 3415 unsigned long flags;
3413 struct tty_ldisc *disc; 3416 struct tty_ldisc *disc;
3414 struct tty_buffer *tbuf, *head; 3417 struct tty_buffer *tbuf, *head;
@@ -3553,7 +3556,7 @@ void tty_flip_buffer_push(struct tty_struct *tty)
3553 spin_unlock_irqrestore(&tty->buf.lock, flags); 3556 spin_unlock_irqrestore(&tty->buf.lock, flags);
3554 3557
3555 if (tty->low_latency) 3558 if (tty->low_latency)
3556 flush_to_ldisc((void *) tty); 3559 flush_to_ldisc(&tty->buf.work.work);
3557 else 3560 else
3558 schedule_delayed_work(&tty->buf.work, 1); 3561 schedule_delayed_work(&tty->buf.work, 1);
3559} 3562}
@@ -3580,17 +3583,17 @@ static void initialize_tty_struct(struct tty_struct *tty)
3580 tty->overrun_time = jiffies; 3583 tty->overrun_time = jiffies;
3581 tty->buf.head = tty->buf.tail = NULL; 3584 tty->buf.head = tty->buf.tail = NULL;
3582 tty_buffer_init(tty); 3585 tty_buffer_init(tty);
3583 INIT_WORK(&tty->buf.work, flush_to_ldisc, tty); 3586 INIT_DELAYED_WORK(&tty->buf.work, flush_to_ldisc);
3584 init_MUTEX(&tty->buf.pty_sem); 3587 init_MUTEX(&tty->buf.pty_sem);
3585 mutex_init(&tty->termios_mutex); 3588 mutex_init(&tty->termios_mutex);
3586 init_waitqueue_head(&tty->write_wait); 3589 init_waitqueue_head(&tty->write_wait);
3587 init_waitqueue_head(&tty->read_wait); 3590 init_waitqueue_head(&tty->read_wait);
3588 INIT_WORK(&tty->hangup_work, do_tty_hangup, tty); 3591 INIT_WORK(&tty->hangup_work, do_tty_hangup);
3589 mutex_init(&tty->atomic_read_lock); 3592 mutex_init(&tty->atomic_read_lock);
3590 mutex_init(&tty->atomic_write_lock); 3593 mutex_init(&tty->atomic_write_lock);
3591 spin_lock_init(&tty->read_lock); 3594 spin_lock_init(&tty->read_lock);
3592 INIT_LIST_HEAD(&tty->tty_files); 3595 INIT_LIST_HEAD(&tty->tty_files);
3593 INIT_WORK(&tty->SAK_work, NULL, NULL); 3596 INIT_WORK(&tty->SAK_work, NULL);
3594} 3597}
3595 3598
3596/* 3599/*
@@ -3612,7 +3615,8 @@ static struct class *tty_class;
3612 * This field is optional, if there is no known struct device 3615 * This field is optional, if there is no known struct device
3613 * for this tty device it can be set to NULL safely. 3616 * for this tty device it can be set to NULL safely.
3614 * 3617 *
3615 * Returns a pointer to the class device (or ERR_PTR(-EFOO) on error). 3618 * Returns a pointer to the struct device for this tty device
3619 * (or ERR_PTR(-EFOO) on error).
3616 * 3620 *
3617 * This call is required to be made to register an individual tty device 3621 * This call is required to be made to register an individual tty device
3618 * if the tty driver's flags have the TTY_DRIVER_DYNAMIC_DEV bit set. If 3622 * if the tty driver's flags have the TTY_DRIVER_DYNAMIC_DEV bit set. If
@@ -3622,8 +3626,8 @@ static struct class *tty_class;
3622 * Locking: ?? 3626 * Locking: ??
3623 */ 3627 */
3624 3628
3625struct class_device *tty_register_device(struct tty_driver *driver, 3629struct device *tty_register_device(struct tty_driver *driver, unsigned index,
3626 unsigned index, struct device *device) 3630 struct device *device)
3627{ 3631{
3628 char name[64]; 3632 char name[64];
3629 dev_t dev = MKDEV(driver->major, driver->minor_start) + index; 3633 dev_t dev = MKDEV(driver->major, driver->minor_start) + index;
@@ -3639,7 +3643,7 @@ struct class_device *tty_register_device(struct tty_driver *driver,
3639 else 3643 else
3640 tty_line_name(driver, index, name); 3644 tty_line_name(driver, index, name);
3641 3645
3642 return class_device_create(tty_class, NULL, dev, device, "%s", name); 3646 return device_create(tty_class, device, dev, name);
3643} 3647}
3644 3648
3645/** 3649/**
@@ -3655,7 +3659,7 @@ struct class_device *tty_register_device(struct tty_driver *driver,
3655 3659
3656void tty_unregister_device(struct tty_driver *driver, unsigned index) 3660void tty_unregister_device(struct tty_driver *driver, unsigned index)
3657{ 3661{
3658 class_device_destroy(tty_class, MKDEV(driver->major, driver->minor_start) + index); 3662 device_destroy(tty_class, MKDEV(driver->major, driver->minor_start) + index);
3659} 3663}
3660 3664
3661EXPORT_SYMBOL(tty_register_device); 3665EXPORT_SYMBOL(tty_register_device);
@@ -3895,20 +3899,20 @@ static int __init tty_init(void)
3895 if (cdev_add(&tty_cdev, MKDEV(TTYAUX_MAJOR, 0), 1) || 3899 if (cdev_add(&tty_cdev, MKDEV(TTYAUX_MAJOR, 0), 1) ||
3896 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0) 3900 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0)
3897 panic("Couldn't register /dev/tty driver\n"); 3901 panic("Couldn't register /dev/tty driver\n");
3898 class_device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 0), NULL, "tty"); 3902 device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 0), "tty");
3899 3903
3900 cdev_init(&console_cdev, &console_fops); 3904 cdev_init(&console_cdev, &console_fops);
3901 if (cdev_add(&console_cdev, MKDEV(TTYAUX_MAJOR, 1), 1) || 3905 if (cdev_add(&console_cdev, MKDEV(TTYAUX_MAJOR, 1), 1) ||
3902 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 1), 1, "/dev/console") < 0) 3906 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 1), 1, "/dev/console") < 0)
3903 panic("Couldn't register /dev/console driver\n"); 3907 panic("Couldn't register /dev/console driver\n");
3904 class_device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 1), NULL, "console"); 3908 device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 1), "console");
3905 3909
3906#ifdef CONFIG_UNIX98_PTYS 3910#ifdef CONFIG_UNIX98_PTYS
3907 cdev_init(&ptmx_cdev, &ptmx_fops); 3911 cdev_init(&ptmx_cdev, &ptmx_fops);
3908 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) || 3912 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
3909 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 2), 1, "/dev/ptmx") < 0) 3913 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 2), 1, "/dev/ptmx") < 0)
3910 panic("Couldn't register /dev/ptmx driver\n"); 3914 panic("Couldn't register /dev/ptmx driver\n");
3911 class_device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 2), NULL, "ptmx"); 3915 device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 2), "ptmx");
3912#endif 3916#endif
3913 3917
3914#ifdef CONFIG_VT 3918#ifdef CONFIG_VT
@@ -3916,7 +3920,7 @@ static int __init tty_init(void)
3916 if (cdev_add(&vc0_cdev, MKDEV(TTY_MAJOR, 0), 1) || 3920 if (cdev_add(&vc0_cdev, MKDEV(TTY_MAJOR, 0), 1) ||
3917 register_chrdev_region(MKDEV(TTY_MAJOR, 0), 1, "/dev/vc/0") < 0) 3921 register_chrdev_region(MKDEV(TTY_MAJOR, 0), 1, "/dev/vc/0") < 0)
3918 panic("Couldn't register /dev/tty0 driver\n"); 3922 panic("Couldn't register /dev/tty0 driver\n");
3919 class_device_create(tty_class, NULL, MKDEV(TTY_MAJOR, 0), NULL, "tty0"); 3923 device_create(tty_class, NULL, MKDEV(TTY_MAJOR, 0), "tty0");
3920 3924
3921 vty_init(); 3925 vty_init();
3922#endif 3926#endif
diff --git a/drivers/char/vc_screen.c b/drivers/char/vc_screen.c
index bd7a98c6ea7a..f442b574b44a 100644
--- a/drivers/char/vc_screen.c
+++ b/drivers/char/vc_screen.c
@@ -476,16 +476,16 @@ static struct class *vc_class;
476 476
477void vcs_make_sysfs(struct tty_struct *tty) 477void vcs_make_sysfs(struct tty_struct *tty)
478{ 478{
479 class_device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 1), 479 device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 1),
480 NULL, "vcs%u", tty->index + 1); 480 "vcs%u", tty->index + 1);
481 class_device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 129), 481 device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 129),
482 NULL, "vcsa%u", tty->index + 1); 482 "vcsa%u", tty->index + 1);
483} 483}
484 484
485void vcs_remove_sysfs(struct tty_struct *tty) 485void vcs_remove_sysfs(struct tty_struct *tty)
486{ 486{
487 class_device_destroy(vc_class, MKDEV(VCS_MAJOR, tty->index + 1)); 487 device_destroy(vc_class, MKDEV(VCS_MAJOR, tty->index + 1));
488 class_device_destroy(vc_class, MKDEV(VCS_MAJOR, tty->index + 129)); 488 device_destroy(vc_class, MKDEV(VCS_MAJOR, tty->index + 129));
489} 489}
490 490
491int __init vcs_init(void) 491int __init vcs_init(void)
@@ -494,7 +494,7 @@ int __init vcs_init(void)
494 panic("unable to get major %d for vcs device", VCS_MAJOR); 494 panic("unable to get major %d for vcs device", VCS_MAJOR);
495 vc_class = class_create(THIS_MODULE, "vc"); 495 vc_class = class_create(THIS_MODULE, "vc");
496 496
497 class_device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 0), NULL, "vcs"); 497 device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 0), "vcs");
498 class_device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 128), NULL, "vcsa"); 498 device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 128), "vcsa");
499 return 0; 499 return 0;
500} 500}
diff --git a/drivers/char/vt.c b/drivers/char/vt.c
index 8e4413f6fbaf..a8239dac994f 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -112,7 +112,7 @@
112struct con_driver { 112struct con_driver {
113 const struct consw *con; 113 const struct consw *con;
114 const char *desc; 114 const char *desc;
115 struct class_device *class_dev; 115 struct device *dev;
116 int node; 116 int node;
117 int first; 117 int first;
118 int last; 118 int last;
@@ -152,10 +152,10 @@ static void gotoxy(struct vc_data *vc, int new_x, int new_y);
152static void save_cur(struct vc_data *vc); 152static void save_cur(struct vc_data *vc);
153static void reset_terminal(struct vc_data *vc, int do_clear); 153static void reset_terminal(struct vc_data *vc, int do_clear);
154static void con_flush_chars(struct tty_struct *tty); 154static void con_flush_chars(struct tty_struct *tty);
155static void set_vesa_blanking(char __user *p); 155static int set_vesa_blanking(char __user *p);
156static void set_cursor(struct vc_data *vc); 156static void set_cursor(struct vc_data *vc);
157static void hide_cursor(struct vc_data *vc); 157static void hide_cursor(struct vc_data *vc);
158static void console_callback(void *ignored); 158static void console_callback(struct work_struct *ignored);
159static void blank_screen_t(unsigned long dummy); 159static void blank_screen_t(unsigned long dummy);
160static void set_palette(struct vc_data *vc); 160static void set_palette(struct vc_data *vc);
161 161
@@ -174,7 +174,7 @@ static int vesa_blank_mode; /* 0:none 1:suspendV 2:suspendH 3:powerdown */
174static int blankinterval = 10*60*HZ; 174static int blankinterval = 10*60*HZ;
175static int vesa_off_interval; 175static int vesa_off_interval;
176 176
177static DECLARE_WORK(console_work, console_callback, NULL); 177static DECLARE_WORK(console_work, console_callback);
178 178
179/* 179/*
180 * fg_console is the current virtual console, 180 * fg_console is the current virtual console,
@@ -2154,7 +2154,7 @@ out:
2154 * with other console code and prevention of re-entrancy is 2154 * with other console code and prevention of re-entrancy is
2155 * ensured with console_sem. 2155 * ensured with console_sem.
2156 */ 2156 */
2157static void console_callback(void *ignored) 2157static void console_callback(struct work_struct *ignored)
2158{ 2158{
2159 acquire_console_sem(); 2159 acquire_console_sem();
2160 2160
@@ -2369,7 +2369,7 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)
2369 ret = __put_user(data, p); 2369 ret = __put_user(data, p);
2370 break; 2370 break;
2371 case TIOCL_SETVESABLANK: 2371 case TIOCL_SETVESABLANK:
2372 set_vesa_blanking(p); 2372 ret = set_vesa_blanking(p);
2373 break; 2373 break;
2374 case TIOCL_GETKMSGREDIRECT: 2374 case TIOCL_GETKMSGREDIRECT:
2375 data = kmsg_redirect; 2375 data = kmsg_redirect;
@@ -3023,10 +3023,10 @@ static inline int vt_unbind(struct con_driver *con)
3023} 3023}
3024#endif /* CONFIG_VT_HW_CONSOLE_BINDING */ 3024#endif /* CONFIG_VT_HW_CONSOLE_BINDING */
3025 3025
3026static ssize_t store_bind(struct class_device *class_device, 3026static ssize_t store_bind(struct device *dev, struct device_attribute *attr,
3027 const char *buf, size_t count) 3027 const char *buf, size_t count)
3028{ 3028{
3029 struct con_driver *con = class_get_devdata(class_device); 3029 struct con_driver *con = dev_get_drvdata(dev);
3030 int bind = simple_strtoul(buf, NULL, 0); 3030 int bind = simple_strtoul(buf, NULL, 0);
3031 3031
3032 if (bind) 3032 if (bind)
@@ -3037,17 +3037,19 @@ static ssize_t store_bind(struct class_device *class_device,
3037 return count; 3037 return count;
3038} 3038}
3039 3039
3040static ssize_t show_bind(struct class_device *class_device, char *buf) 3040static ssize_t show_bind(struct device *dev, struct device_attribute *attr,
3041 char *buf)
3041{ 3042{
3042 struct con_driver *con = class_get_devdata(class_device); 3043 struct con_driver *con = dev_get_drvdata(dev);
3043 int bind = con_is_bound(con->con); 3044 int bind = con_is_bound(con->con);
3044 3045
3045 return snprintf(buf, PAGE_SIZE, "%i\n", bind); 3046 return snprintf(buf, PAGE_SIZE, "%i\n", bind);
3046} 3047}
3047 3048
3048static ssize_t show_name(struct class_device *class_device, char *buf) 3049static ssize_t show_name(struct device *dev, struct device_attribute *attr,
3050 char *buf)
3049{ 3051{
3050 struct con_driver *con = class_get_devdata(class_device); 3052 struct con_driver *con = dev_get_drvdata(dev);
3051 3053
3052 return snprintf(buf, PAGE_SIZE, "%s %s\n", 3054 return snprintf(buf, PAGE_SIZE, "%s %s\n",
3053 (con->flag & CON_DRIVER_FLAG_MODULE) ? "(M)" : "(S)", 3055 (con->flag & CON_DRIVER_FLAG_MODULE) ? "(M)" : "(S)",
@@ -3055,43 +3057,40 @@ static ssize_t show_name(struct class_device *class_device, char *buf)
3055 3057
3056} 3058}
3057 3059
3058static struct class_device_attribute class_device_attrs[] = { 3060static struct device_attribute device_attrs[] = {
3059 __ATTR(bind, S_IRUGO|S_IWUSR, show_bind, store_bind), 3061 __ATTR(bind, S_IRUGO|S_IWUSR, show_bind, store_bind),
3060 __ATTR(name, S_IRUGO, show_name, NULL), 3062 __ATTR(name, S_IRUGO, show_name, NULL),
3061}; 3063};
3062 3064
3063static int vtconsole_init_class_device(struct con_driver *con) 3065static int vtconsole_init_device(struct con_driver *con)
3064{ 3066{
3065 int i; 3067 int i;
3066 int error = 0; 3068 int error = 0;
3067 3069
3068 con->flag |= CON_DRIVER_FLAG_ATTR; 3070 con->flag |= CON_DRIVER_FLAG_ATTR;
3069 class_set_devdata(con->class_dev, con); 3071 dev_set_drvdata(con->dev, con);
3070 for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) { 3072 for (i = 0; i < ARRAY_SIZE(device_attrs); i++) {
3071 error = class_device_create_file(con->class_dev, 3073 error = device_create_file(con->dev, &device_attrs[i]);
3072 &class_device_attrs[i]);
3073 if (error) 3074 if (error)
3074 break; 3075 break;
3075 } 3076 }
3076 3077
3077 if (error) { 3078 if (error) {
3078 while (--i >= 0) 3079 while (--i >= 0)
3079 class_device_remove_file(con->class_dev, 3080 device_remove_file(con->dev, &device_attrs[i]);
3080 &class_device_attrs[i]);
3081 con->flag &= ~CON_DRIVER_FLAG_ATTR; 3081 con->flag &= ~CON_DRIVER_FLAG_ATTR;
3082 } 3082 }
3083 3083
3084 return error; 3084 return error;
3085} 3085}
3086 3086
3087static void vtconsole_deinit_class_device(struct con_driver *con) 3087static void vtconsole_deinit_device(struct con_driver *con)
3088{ 3088{
3089 int i; 3089 int i;
3090 3090
3091 if (con->flag & CON_DRIVER_FLAG_ATTR) { 3091 if (con->flag & CON_DRIVER_FLAG_ATTR) {
3092 for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) 3092 for (i = 0; i < ARRAY_SIZE(device_attrs); i++)
3093 class_device_remove_file(con->class_dev, 3093 device_remove_file(con->dev, &device_attrs[i]);
3094 &class_device_attrs[i]);
3095 con->flag &= ~CON_DRIVER_FLAG_ATTR; 3094 con->flag &= ~CON_DRIVER_FLAG_ATTR;
3096 } 3095 }
3097} 3096}
@@ -3179,18 +3178,17 @@ int register_con_driver(const struct consw *csw, int first, int last)
3179 if (retval) 3178 if (retval)
3180 goto err; 3179 goto err;
3181 3180
3182 con_driver->class_dev = class_device_create(vtconsole_class, NULL, 3181 con_driver->dev = device_create(vtconsole_class, NULL,
3183 MKDEV(0, con_driver->node), 3182 MKDEV(0, con_driver->node),
3184 NULL, "vtcon%i", 3183 "vtcon%i", con_driver->node);
3185 con_driver->node);
3186 3184
3187 if (IS_ERR(con_driver->class_dev)) { 3185 if (IS_ERR(con_driver->dev)) {
3188 printk(KERN_WARNING "Unable to create class_device for %s; " 3186 printk(KERN_WARNING "Unable to create device for %s; "
3189 "errno = %ld\n", con_driver->desc, 3187 "errno = %ld\n", con_driver->desc,
3190 PTR_ERR(con_driver->class_dev)); 3188 PTR_ERR(con_driver->dev));
3191 con_driver->class_dev = NULL; 3189 con_driver->dev = NULL;
3192 } else { 3190 } else {
3193 vtconsole_init_class_device(con_driver); 3191 vtconsole_init_device(con_driver);
3194 } 3192 }
3195 3193
3196err: 3194err:
@@ -3226,12 +3224,12 @@ int unregister_con_driver(const struct consw *csw)
3226 3224
3227 if (con_driver->con == csw && 3225 if (con_driver->con == csw &&
3228 con_driver->flag & CON_DRIVER_FLAG_MODULE) { 3226 con_driver->flag & CON_DRIVER_FLAG_MODULE) {
3229 vtconsole_deinit_class_device(con_driver); 3227 vtconsole_deinit_device(con_driver);
3230 class_device_destroy(vtconsole_class, 3228 device_destroy(vtconsole_class,
3231 MKDEV(0, con_driver->node)); 3229 MKDEV(0, con_driver->node));
3232 con_driver->con = NULL; 3230 con_driver->con = NULL;
3233 con_driver->desc = NULL; 3231 con_driver->desc = NULL;
3234 con_driver->class_dev = NULL; 3232 con_driver->dev = NULL;
3235 con_driver->node = 0; 3233 con_driver->node = 0;
3236 con_driver->flag = 0; 3234 con_driver->flag = 0;
3237 con_driver->first = 0; 3235 con_driver->first = 0;
@@ -3289,19 +3287,18 @@ static int __init vtconsole_class_init(void)
3289 for (i = 0; i < MAX_NR_CON_DRIVER; i++) { 3287 for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
3290 struct con_driver *con = &registered_con_driver[i]; 3288 struct con_driver *con = &registered_con_driver[i];
3291 3289
3292 if (con->con && !con->class_dev) { 3290 if (con->con && !con->dev) {
3293 con->class_dev = 3291 con->dev = device_create(vtconsole_class, NULL,
3294 class_device_create(vtconsole_class, NULL, 3292 MKDEV(0, con->node),
3295 MKDEV(0, con->node), NULL, 3293 "vtcon%i", con->node);
3296 "vtcon%i", con->node);
3297 3294
3298 if (IS_ERR(con->class_dev)) { 3295 if (IS_ERR(con->dev)) {
3299 printk(KERN_WARNING "Unable to create " 3296 printk(KERN_WARNING "Unable to create "
3300 "class_device for %s; errno = %ld\n", 3297 "device for %s; errno = %ld\n",
3301 con->desc, PTR_ERR(con->class_dev)); 3298 con->desc, PTR_ERR(con->dev));
3302 con->class_dev = NULL; 3299 con->dev = NULL;
3303 } else { 3300 } else {
3304 vtconsole_init_class_device(con); 3301 vtconsole_init_device(con);
3305 } 3302 }
3306 } 3303 }
3307 } 3304 }
@@ -3316,11 +3313,15 @@ postcore_initcall(vtconsole_class_init);
3316 * Screen blanking 3313 * Screen blanking
3317 */ 3314 */
3318 3315
3319static void set_vesa_blanking(char __user *p) 3316static int set_vesa_blanking(char __user *p)
3320{ 3317{
3321 unsigned int mode; 3318 unsigned int mode;
3322 get_user(mode, p + 1); 3319
3323 vesa_blank_mode = (mode < 4) ? mode : 0; 3320 if (get_user(mode, p + 1))
3321 return -EFAULT;
3322
3323 vesa_blank_mode = (mode < 4) ? mode : 0;
3324 return 0;
3324} 3325}
3325 3326
3326void do_blank_screen(int entering_gfx) 3327void do_blank_screen(int entering_gfx)
diff --git a/drivers/char/watchdog/Kconfig b/drivers/char/watchdog/Kconfig
index 0187b1185323..ea09d0c974ea 100644
--- a/drivers/char/watchdog/Kconfig
+++ b/drivers/char/watchdog/Kconfig
@@ -340,6 +340,14 @@ config ITCO_WDT
340 To compile this driver as a module, choose M here: the 340 To compile this driver as a module, choose M here: the
341 module will be called iTCO_wdt. 341 module will be called iTCO_wdt.
342 342
343config ITCO_VENDOR_SUPPORT
344 bool "Intel TCO Timer/Watchdog Specific Vendor Support"
345 depends on ITCO_WDT
346 ---help---
347 Add vendor specific support to the intel TCO timer based watchdog
348 devices. At this moment we only have additional support for some
349 SuperMicro Inc. motherboards.
350
343config SC1200_WDT 351config SC1200_WDT
344 tristate "National Semiconductor PC87307/PC97307 (ala SC1200) Watchdog" 352 tristate "National Semiconductor PC87307/PC97307 (ala SC1200) Watchdog"
345 depends on WATCHDOG && X86 353 depends on WATCHDOG && X86
@@ -363,6 +371,20 @@ config SCx200_WDT
363 371
364 If compiled as a module, it will be called scx200_wdt. 372 If compiled as a module, it will be called scx200_wdt.
365 373
374config PC87413_WDT
375 tristate "NS PC87413 watchdog"
376 depends on WATCHDOG && X86
377 ---help---
378 This is the driver for the hardware watchdog on the PC87413 chipset
379 This watchdog simply watches your kernel to make sure it doesn't
380 freeze, and if it does, it reboots your computer after a certain
381 amount of time.
382
383 To compile this driver as a module, choose M here: the
384 module will be called pc87413_wdt.
385
386 Most people will say N.
387
366config 60XX_WDT 388config 60XX_WDT
367 tristate "SBC-60XX Watchdog Timer" 389 tristate "SBC-60XX Watchdog Timer"
368 depends on WATCHDOG && X86 390 depends on WATCHDOG && X86
@@ -553,6 +575,16 @@ config INDYDOG
553 timer expired and no process has written to /dev/watchdog during 575 timer expired and no process has written to /dev/watchdog during
554 that time. 576 that time.
555 577
578config WDT_RM9K_GPI
579 tristate "RM9000/GPI hardware watchdog"
580 depends on WATCHDOG && CPU_RM9000
581 help
582 Watchdog implementation using the GPI hardware found on
583 PMC-Sierra RM9xxx CPUs.
584
585 To compile this driver as a module, choose M here: the
586 module will be called rm9k_wdt.
587
556# S390 Architecture 588# S390 Architecture
557 589
558config ZVM_WATCHDOG 590config ZVM_WATCHDOG
diff --git a/drivers/char/watchdog/Makefile b/drivers/char/watchdog/Makefile
index 36440497047c..2cd8ff8d10ac 100644
--- a/drivers/char/watchdog/Makefile
+++ b/drivers/char/watchdog/Makefile
@@ -47,9 +47,10 @@ obj-$(CONFIG_IBMASR) += ibmasr.o
47obj-$(CONFIG_WAFER_WDT) += wafer5823wdt.o 47obj-$(CONFIG_WAFER_WDT) += wafer5823wdt.o
48obj-$(CONFIG_I6300ESB_WDT) += i6300esb.o 48obj-$(CONFIG_I6300ESB_WDT) += i6300esb.o
49obj-$(CONFIG_I8XX_TCO) += i8xx_tco.o 49obj-$(CONFIG_I8XX_TCO) += i8xx_tco.o
50obj-$(CONFIG_ITCO_WDT) += iTCO_wdt.o 50obj-$(CONFIG_ITCO_WDT) += iTCO_wdt.o iTCO_vendor_support.o
51obj-$(CONFIG_SC1200_WDT) += sc1200wdt.o 51obj-$(CONFIG_SC1200_WDT) += sc1200wdt.o
52obj-$(CONFIG_SCx200_WDT) += scx200_wdt.o 52obj-$(CONFIG_SCx200_WDT) += scx200_wdt.o
53obj-$(CONFIG_PC87413_WDT) += pc87413_wdt.o
53obj-$(CONFIG_60XX_WDT) += sbc60xxwdt.o 54obj-$(CONFIG_60XX_WDT) += sbc60xxwdt.o
54obj-$(CONFIG_SBC8360_WDT) += sbc8360.o 55obj-$(CONFIG_SBC8360_WDT) += sbc8360.o
55obj-$(CONFIG_CPU5_WDT) += cpu5wdt.o 56obj-$(CONFIG_CPU5_WDT) += cpu5wdt.o
@@ -72,6 +73,7 @@ obj-$(CONFIG_WATCHDOG_RTAS) += wdrtas.o
72 73
73# MIPS Architecture 74# MIPS Architecture
74obj-$(CONFIG_INDYDOG) += indydog.o 75obj-$(CONFIG_INDYDOG) += indydog.o
76obj-$(CONFIG_WDT_RM9K_GPI) += rm9k_wdt.o
75 77
76# S390 Architecture 78# S390 Architecture
77 79
diff --git a/drivers/char/watchdog/at91rm9200_wdt.c b/drivers/char/watchdog/at91rm9200_wdt.c
index 4e7a1145e78f..cb86967e2c5f 100644
--- a/drivers/char/watchdog/at91rm9200_wdt.c
+++ b/drivers/char/watchdog/at91rm9200_wdt.c
@@ -21,6 +21,7 @@
21#include <linux/watchdog.h> 21#include <linux/watchdog.h>
22#include <asm/bitops.h> 22#include <asm/bitops.h>
23#include <asm/uaccess.h> 23#include <asm/uaccess.h>
24#include <asm/arch/at91_st.h>
24 25
25 26
26#define WDT_DEFAULT_TIME 5 /* seconds */ 27#define WDT_DEFAULT_TIME 5 /* seconds */
diff --git a/drivers/char/watchdog/iTCO_vendor_support.c b/drivers/char/watchdog/iTCO_vendor_support.c
new file mode 100644
index 000000000000..415083990097
--- /dev/null
+++ b/drivers/char/watchdog/iTCO_vendor_support.c
@@ -0,0 +1,307 @@
1/*
2 * intel TCO vendor specific watchdog driver support
3 *
4 * (c) Copyright 2006 Wim Van Sebroeck <wim@iguana.be>.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 *
11 * Neither Wim Van Sebroeck nor Iguana vzw. admit liability nor
12 * provide warranty for any of this software. This material is
13 * provided "AS-IS" and at no charge.
14 */
15
16/*
17 * Includes, defines, variables, module parameters, ...
18 */
19
20/* Module and version information */
21#define DRV_NAME "iTCO_vendor_support"
22#define DRV_VERSION "1.01"
23#define DRV_RELDATE "11-Nov-2006"
24#define PFX DRV_NAME ": "
25
26/* Includes */
27#include <linux/module.h> /* For module specific items */
28#include <linux/moduleparam.h> /* For new moduleparam's */
29#include <linux/types.h> /* For standard types (like size_t) */
30#include <linux/errno.h> /* For the -ENODEV/... values */
31#include <linux/kernel.h> /* For printk/panic/... */
32#include <linux/init.h> /* For __init/__exit/... */
33#include <linux/ioport.h> /* For io-port access */
34
35#include <asm/io.h> /* For inb/outb/... */
36
37/* iTCO defines */
38#define SMI_EN acpibase + 0x30 /* SMI Control and Enable Register */
39#define TCOBASE acpibase + 0x60 /* TCO base address */
40#define TCO1_STS TCOBASE + 0x04 /* TCO1 Status Register */
41
42/* List of vendor support modes */
43#define SUPERMICRO_OLD_BOARD 1 /* SuperMicro Pentium 3 Era 370SSE+-OEM1/P3TSSE */
44#define SUPERMICRO_NEW_BOARD 2 /* SuperMicro Pentium 4 / Xeon 4 / EMT64T Era Systems */
45
46static int vendorsupport = 0;
47module_param(vendorsupport, int, 0);
48MODULE_PARM_DESC(vendorsupport, "iTCO vendor specific support mode, default=0 (none), 1=SuperMicro Pent3, 2=SuperMicro Pent4+");
49
50/*
51 * Vendor Specific Support
52 */
53
54/*
55 * Vendor Support: 1
56 * Board: Super Micro Computer Inc. 370SSE+-OEM1/P3TSSE
57 * iTCO chipset: ICH2
58 *
59 * Code contributed by: R. Seretny <lkpatches@paypc.com>
60 * Documentation obtained by R. Seretny from SuperMicro Technical Support
61 *
62 * To enable Watchdog function:
63 * BIOS setup -> Power -> TCO Logic SMI Enable -> Within5Minutes
64 * This setting enables SMI to clear the watchdog expired flag.
65 * If BIOS or CPU fail which may cause SMI hang, then system will
66 * reboot. When application starts to use watchdog function,
67 * application has to take over the control from SMI.
68 *
69 * For P3TSSE, J36 jumper needs to be removed to enable the Watchdog
70 * function.
71 *
72 * Note: The system will reboot when Expire Flag is set TWICE.
73 * So, if the watchdog timer is 20 seconds, then the maximum hang
74 * time is about 40 seconds, and the minimum hang time is about
75 * 20.6 seconds.
76 */
77
78static void supermicro_old_pre_start(unsigned long acpibase)
79{
80 unsigned long val32;
81
82 val32 = inl(SMI_EN);
83 val32 &= 0xffffdfff; /* Turn off SMI clearing watchdog */
84 outl(val32, SMI_EN); /* Needed to activate watchdog */
85}
86
87static void supermicro_old_pre_stop(unsigned long acpibase)
88{
89 unsigned long val32;
90
91 val32 = inl(SMI_EN);
92 val32 &= 0x00002000; /* Turn on SMI clearing watchdog */
93 outl(val32, SMI_EN); /* Needed to deactivate watchdog */
94}
95
96static void supermicro_old_pre_keepalive(unsigned long acpibase)
97{
98 /* Reload TCO Timer (done in iTCO_wdt_keepalive) + */
99 /* Clear "Expire Flag" (Bit 3 of TC01_STS register) */
100 outb(0x08, TCO1_STS);
101}
102
103/*
104 * Vendor Support: 2
105 * Board: Super Micro Computer Inc. P4SBx, P4DPx
106 * iTCO chipset: ICH4
107 *
108 * Code contributed by: R. Seretny <lkpatches@paypc.com>
109 * Documentation obtained by R. Seretny from SuperMicro Technical Support
110 *
111 * To enable Watchdog function:
112 * 1. BIOS
113 * For P4SBx:
114 * BIOS setup -> Advanced -> Integrated Peripherals -> Watch Dog Feature
115 * For P4DPx:
116 * BIOS setup -> Advanced -> I/O Device Configuration -> Watch Dog
117 * This setting enables or disables Watchdog function. When enabled, the
118 * default watchdog timer is set to be 5 minutes (about 4’35â€). It is
119 * enough to load and run the OS. The application (service or driver) has
120 * to take over the control once OS is running up and before watchdog
121 * expires.
122 *
123 * 2. JUMPER
124 * For P4SBx: JP39
125 * For P4DPx: JP37
126 * This jumper is used for safety. Closed is enabled. This jumper
127 * prevents user enables watchdog in BIOS by accident.
128 *
129 * To enable Watch Dog function, both BIOS and JUMPER must be enabled.
130 *
131 * The documentation lists motherboards P4SBx and P4DPx series as of
132 * 20-March-2002. However, this code works flawlessly with much newer
133 * motherboards, such as my X6DHR-8G2 (SuperServer 6014H-82).
134 *
135 * The original iTCO driver as written does not actually reset the
136 * watchdog timer on these machines, as a result they reboot after five
137 * minutes.
138 *
139 * NOTE: You may leave the Watchdog function disabled in the SuperMicro
140 * BIOS to avoid a "boot-race"... This driver will enable watchdog
141 * functionality even if it's disabled in the BIOS once the /dev/watchdog
142 * file is opened.
143 */
144
145/* I/O Port's */
146#define SM_REGINDEX 0x2e /* SuperMicro ICH4+ Register Index */
147#define SM_DATAIO 0x2f /* SuperMicro ICH4+ Register Data I/O */
148
149/* Control Register's */
150#define SM_CTLPAGESW 0x07 /* SuperMicro ICH4+ Control Page Switch */
151#define SM_CTLPAGE 0x08 /* SuperMicro ICH4+ Control Page Num */
152
153#define SM_WATCHENABLE 0x30 /* Watchdog enable: Bit 0: 0=off, 1=on */
154
155#define SM_WATCHPAGE 0x87 /* Watchdog unlock control page */
156
157#define SM_ENDWATCH 0xAA /* Watchdog lock control page */
158
159#define SM_COUNTMODE 0xf5 /* Watchdog count mode select */
160 /* (Bit 3: 0 = seconds, 1 = minutes */
161
162#define SM_WATCHTIMER 0xf6 /* 8-bits, Watchdog timer counter (RW) */
163
164#define SM_RESETCONTROL 0xf7 /* Watchdog reset control */
165 /* Bit 6: timer is reset by kbd interrupt */
166 /* Bit 7: timer is reset by mouse interrupt */
167
168static void supermicro_new_unlock_watchdog(void)
169{
170 outb(SM_WATCHPAGE, SM_REGINDEX); /* Write 0x87 to port 0x2e twice */
171 outb(SM_WATCHPAGE, SM_REGINDEX);
172
173 outb(SM_CTLPAGESW, SM_REGINDEX); /* Switch to watchdog control page */
174 outb(SM_CTLPAGE, SM_DATAIO);
175}
176
177static void supermicro_new_lock_watchdog(void)
178{
179 outb(SM_ENDWATCH, SM_REGINDEX);
180}
181
182static void supermicro_new_pre_start(unsigned int heartbeat)
183{
184 unsigned int val;
185
186 supermicro_new_unlock_watchdog();
187
188 /* Watchdog timer setting needs to be in seconds*/
189 outb(SM_COUNTMODE, SM_REGINDEX);
190 val = inb(SM_DATAIO);
191 val &= 0xF7;
192 outb(val, SM_DATAIO);
193
194 /* Write heartbeat interval to WDOG */
195 outb (SM_WATCHTIMER, SM_REGINDEX);
196 outb((heartbeat & 255), SM_DATAIO);
197
198 /* Make sure keyboard/mouse interrupts don't interfere */
199 outb(SM_RESETCONTROL, SM_REGINDEX);
200 val = inb(SM_DATAIO);
201 val &= 0x3f;
202 outb(val, SM_DATAIO);
203
204 /* enable watchdog by setting bit 0 of Watchdog Enable to 1 */
205 outb(SM_WATCHENABLE, SM_REGINDEX);
206 val = inb(SM_DATAIO);
207 val |= 0x01;
208 outb(val, SM_DATAIO);
209
210 supermicro_new_lock_watchdog();
211}
212
213static void supermicro_new_pre_stop(void)
214{
215 unsigned int val;
216
217 supermicro_new_unlock_watchdog();
218
219 /* disable watchdog by setting bit 0 of Watchdog Enable to 0 */
220 outb(SM_WATCHENABLE, SM_REGINDEX);
221 val = inb(SM_DATAIO);
222 val &= 0xFE;
223 outb(val, SM_DATAIO);
224
225 supermicro_new_lock_watchdog();
226}
227
228static void supermicro_new_pre_set_heartbeat(unsigned int heartbeat)
229{
230 supermicro_new_unlock_watchdog();
231
232 /* reset watchdog timeout to heartveat value */
233 outb(SM_WATCHTIMER, SM_REGINDEX);
234 outb((heartbeat & 255), SM_DATAIO);
235
236 supermicro_new_lock_watchdog();
237}
238
239/*
240 * Generic Support Functions
241 */
242
243void iTCO_vendor_pre_start(unsigned long acpibase,
244 unsigned int heartbeat)
245{
246 if (vendorsupport == SUPERMICRO_OLD_BOARD)
247 supermicro_old_pre_start(acpibase);
248 else if (vendorsupport == SUPERMICRO_NEW_BOARD)
249 supermicro_new_pre_start(heartbeat);
250}
251EXPORT_SYMBOL(iTCO_vendor_pre_start);
252
253void iTCO_vendor_pre_stop(unsigned long acpibase)
254{
255 if (vendorsupport == SUPERMICRO_OLD_BOARD)
256 supermicro_old_pre_stop(acpibase);
257 else if (vendorsupport == SUPERMICRO_NEW_BOARD)
258 supermicro_new_pre_stop();
259}
260EXPORT_SYMBOL(iTCO_vendor_pre_stop);
261
262void iTCO_vendor_pre_keepalive(unsigned long acpibase, unsigned int heartbeat)
263{
264 if (vendorsupport == SUPERMICRO_OLD_BOARD)
265 supermicro_old_pre_keepalive(acpibase);
266 else if (vendorsupport == SUPERMICRO_NEW_BOARD)
267 supermicro_new_pre_set_heartbeat(heartbeat);
268}
269EXPORT_SYMBOL(iTCO_vendor_pre_keepalive);
270
271void iTCO_vendor_pre_set_heartbeat(unsigned int heartbeat)
272{
273 if (vendorsupport == SUPERMICRO_NEW_BOARD)
274 supermicro_new_pre_set_heartbeat(heartbeat);
275}
276EXPORT_SYMBOL(iTCO_vendor_pre_set_heartbeat);
277
278int iTCO_vendor_check_noreboot_on(void)
279{
280 switch(vendorsupport) {
281 case SUPERMICRO_OLD_BOARD:
282 return 0;
283 default:
284 return 1;
285 }
286}
287EXPORT_SYMBOL(iTCO_vendor_check_noreboot_on);
288
289static int __init iTCO_vendor_init_module(void)
290{
291 printk (KERN_INFO PFX "vendor-support=%d\n", vendorsupport);
292 return 0;
293}
294
295static void __exit iTCO_vendor_exit_module(void)
296{
297 printk (KERN_INFO PFX "Module Unloaded\n");
298}
299
300module_init(iTCO_vendor_init_module);
301module_exit(iTCO_vendor_exit_module);
302
303MODULE_AUTHOR("Wim Van Sebroeck <wim@iguana.be>, R. Seretny <lkpatches@paypc.com>");
304MODULE_DESCRIPTION("Intel TCO Vendor Specific WatchDog Timer Driver Support");
305MODULE_VERSION(DRV_VERSION);
306MODULE_LICENSE("GPL");
307
diff --git a/drivers/char/watchdog/iTCO_wdt.c b/drivers/char/watchdog/iTCO_wdt.c
index b6f29cb8bd39..7eac922df867 100644
--- a/drivers/char/watchdog/iTCO_wdt.c
+++ b/drivers/char/watchdog/iTCO_wdt.c
@@ -48,8 +48,8 @@
48 48
49/* Module and version information */ 49/* Module and version information */
50#define DRV_NAME "iTCO_wdt" 50#define DRV_NAME "iTCO_wdt"
51#define DRV_VERSION "1.00" 51#define DRV_VERSION "1.01"
52#define DRV_RELDATE "08-Oct-2006" 52#define DRV_RELDATE "11-Nov-2006"
53#define PFX DRV_NAME ": " 53#define PFX DRV_NAME ": "
54 54
55/* Includes */ 55/* Includes */
@@ -189,6 +189,21 @@ static int nowayout = WATCHDOG_NOWAYOUT;
189module_param(nowayout, int, 0); 189module_param(nowayout, int, 0);
190MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); 190MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)");
191 191
192/* iTCO Vendor Specific Support hooks */
193#ifdef CONFIG_ITCO_VENDOR_SUPPORT
194extern void iTCO_vendor_pre_start(unsigned long, unsigned int);
195extern void iTCO_vendor_pre_stop(unsigned long);
196extern void iTCO_vendor_pre_keepalive(unsigned long, unsigned int);
197extern void iTCO_vendor_pre_set_heartbeat(unsigned int);
198extern int iTCO_vendor_check_noreboot_on(void);
199#else
200#define iTCO_vendor_pre_start(acpibase, heartbeat) {}
201#define iTCO_vendor_pre_stop(acpibase) {}
202#define iTCO_vendor_pre_keepalive(acpibase,heartbeat) {}
203#define iTCO_vendor_pre_set_heartbeat(heartbeat) {}
204#define iTCO_vendor_check_noreboot_on() 1 /* 1=check noreboot; 0=don't check */
205#endif
206
192/* 207/*
193 * Some TCO specific functions 208 * Some TCO specific functions
194 */ 209 */
@@ -249,6 +264,8 @@ static int iTCO_wdt_start(void)
249 264
250 spin_lock(&iTCO_wdt_private.io_lock); 265 spin_lock(&iTCO_wdt_private.io_lock);
251 266
267 iTCO_vendor_pre_start(iTCO_wdt_private.ACPIBASE, heartbeat);
268
252 /* disable chipset's NO_REBOOT bit */ 269 /* disable chipset's NO_REBOOT bit */
253 if (iTCO_wdt_unset_NO_REBOOT_bit()) { 270 if (iTCO_wdt_unset_NO_REBOOT_bit()) {
254 printk(KERN_ERR PFX "failed to reset NO_REBOOT flag, reboot disabled by hardware\n"); 271 printk(KERN_ERR PFX "failed to reset NO_REBOOT flag, reboot disabled by hardware\n");
@@ -273,6 +290,8 @@ static int iTCO_wdt_stop(void)
273 290
274 spin_lock(&iTCO_wdt_private.io_lock); 291 spin_lock(&iTCO_wdt_private.io_lock);
275 292
293 iTCO_vendor_pre_stop(iTCO_wdt_private.ACPIBASE);
294
276 /* Bit 11: TCO Timer Halt -> 1 = The TCO timer is disabled */ 295 /* Bit 11: TCO Timer Halt -> 1 = The TCO timer is disabled */
277 val = inw(TCO1_CNT); 296 val = inw(TCO1_CNT);
278 val |= 0x0800; 297 val |= 0x0800;
@@ -293,6 +312,8 @@ static int iTCO_wdt_keepalive(void)
293{ 312{
294 spin_lock(&iTCO_wdt_private.io_lock); 313 spin_lock(&iTCO_wdt_private.io_lock);
295 314
315 iTCO_vendor_pre_keepalive(iTCO_wdt_private.ACPIBASE, heartbeat);
316
296 /* Reload the timer by writing to the TCO Timer Counter register */ 317 /* Reload the timer by writing to the TCO Timer Counter register */
297 if (iTCO_wdt_private.iTCO_version == 2) { 318 if (iTCO_wdt_private.iTCO_version == 2) {
298 outw(0x01, TCO_RLD); 319 outw(0x01, TCO_RLD);
@@ -319,6 +340,8 @@ static int iTCO_wdt_set_heartbeat(int t)
319 ((iTCO_wdt_private.iTCO_version == 1) && (tmrval > 0x03f))) 340 ((iTCO_wdt_private.iTCO_version == 1) && (tmrval > 0x03f)))
320 return -EINVAL; 341 return -EINVAL;
321 342
343 iTCO_vendor_pre_set_heartbeat(tmrval);
344
322 /* Write new heartbeat to watchdog */ 345 /* Write new heartbeat to watchdog */
323 if (iTCO_wdt_private.iTCO_version == 2) { 346 if (iTCO_wdt_private.iTCO_version == 2) {
324 spin_lock(&iTCO_wdt_private.io_lock); 347 spin_lock(&iTCO_wdt_private.io_lock);
@@ -569,7 +592,7 @@ static int iTCO_wdt_init(struct pci_dev *pdev, const struct pci_device_id *ent,
569 } 592 }
570 593
571 /* Check chipset's NO_REBOOT bit */ 594 /* Check chipset's NO_REBOOT bit */
572 if (iTCO_wdt_unset_NO_REBOOT_bit()) { 595 if (iTCO_wdt_unset_NO_REBOOT_bit() && iTCO_vendor_check_noreboot_on()) {
573 printk(KERN_ERR PFX "failed to reset NO_REBOOT flag, reboot disabled by hardware\n"); 596 printk(KERN_ERR PFX "failed to reset NO_REBOOT flag, reboot disabled by hardware\n");
574 ret = -ENODEV; /* Cannot reset NO_REBOOT bit */ 597 ret = -ENODEV; /* Cannot reset NO_REBOOT bit */
575 goto out; 598 goto out;
diff --git a/drivers/char/watchdog/pc87413_wdt.c b/drivers/char/watchdog/pc87413_wdt.c
new file mode 100644
index 000000000000..1d447e32af41
--- /dev/null
+++ b/drivers/char/watchdog/pc87413_wdt.c
@@ -0,0 +1,635 @@
1/*
2 * NS pc87413-wdt Watchdog Timer driver for Linux 2.6.x.x
3 *
4 * This code is based on wdt.c with original copyright.
5 *
6 * (C) Copyright 2006 Sven Anders, <anders@anduras.de>
7 * and Marcus Junker, <junker@anduras.de>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
13 *
14 * Neither Sven Anders, Marcus Junker nor ANDURAS AG
15 * admit liability nor provide warranty for any of this software.
16 * This material is provided "AS-IS" and at no charge.
17 *
18 * Release 1.1
19 */
20
21#include <linux/module.h>
22#include <linux/types.h>
23#include <linux/miscdevice.h>
24#include <linux/watchdog.h>
25#include <linux/ioport.h>
26#include <linux/delay.h>
27#include <linux/notifier.h>
28#include <linux/fs.h>
29#include <linux/reboot.h>
30#include <linux/init.h>
31#include <linux/spinlock.h>
32#include <linux/moduleparam.h>
33#include <linux/version.h>
34
35#include <asm/io.h>
36#include <asm/uaccess.h>
37#include <asm/system.h>
38
39/* #define DEBUG 1 */
40
41#define DEFAULT_TIMEOUT 1 /* 1 minute */
42#define MAX_TIMEOUT 255
43
44#define VERSION "1.1"
45#define MODNAME "pc87413 WDT"
46#define PFX MODNAME ": "
47#define DPFX MODNAME " - DEBUG: "
48
49#define WDT_INDEX_IO_PORT (io+0) /* I/O port base (index register) */
50#define WDT_DATA_IO_PORT (WDT_INDEX_IO_PORT+1)
51#define SWC_LDN 0x04
52#define SIOCFG2 0x22 /* Serial IO register */
53#define WDCTL 0x10 /* Watchdog-Timer-Controll-Register */
54#define WDTO 0x11 /* Watchdog timeout register */
55#define WDCFG 0x12 /* Watchdog config register */
56
57static int io = 0x2E; /* Address used on Portwell Boards */
58
59static int timeout = DEFAULT_TIMEOUT; /* timeout value */
60static unsigned long timer_enabled = 0; /* is the timer enabled? */
61
62static char expect_close; /* is the close expected? */
63
64static spinlock_t io_lock; /* to guard the watchdog from io races */
65
66static int nowayout = WATCHDOG_NOWAYOUT;
67
68/* -- Low level function ----------------------------------------*/
69
70/* Select pins for Watchdog output */
71
72static inline void pc87413_select_wdt_out (void)
73{
74 unsigned int cr_data = 0;
75
76 /* Step 1: Select multiple pin,pin55,as WDT output */
77
78 outb_p(SIOCFG2, WDT_INDEX_IO_PORT);
79
80 cr_data = inb (WDT_DATA_IO_PORT);
81
82 cr_data |= 0x80; /* Set Bit7 to 1*/
83 outb_p(SIOCFG2, WDT_INDEX_IO_PORT);
84
85 outb_p(cr_data, WDT_DATA_IO_PORT);
86
87#ifdef DEBUG
88 printk(KERN_INFO DPFX "Select multiple pin,pin55,as WDT output:"
89 " Bit7 to 1: %d\n", cr_data);
90#endif
91}
92
93/* Enable SWC functions */
94
95static inline void pc87413_enable_swc(void)
96{
97 unsigned int cr_data=0;
98
99 /* Step 2: Enable SWC functions */
100
101 outb_p(0x07, WDT_INDEX_IO_PORT); /* Point SWC_LDN (LDN=4) */
102 outb_p(SWC_LDN, WDT_DATA_IO_PORT);
103
104 outb_p(0x30, WDT_INDEX_IO_PORT); /* Read Index 0x30 First */
105 cr_data = inb(WDT_DATA_IO_PORT);
106 cr_data |= 0x01; /* Set Bit0 to 1 */
107 outb_p(0x30, WDT_INDEX_IO_PORT);
108 outb_p(cr_data, WDT_DATA_IO_PORT); /* Index0x30_bit0P1 */
109
110#ifdef DEBUG
111 printk(KERN_INFO DPFX "pc87413 - Enable SWC functions\n");
112#endif
113}
114
115/* Read SWC I/O base address */
116
117static inline unsigned int pc87413_get_swc_base(void)
118{
119 unsigned int swc_base_addr = 0;
120 unsigned char addr_l, addr_h = 0;
121
122 /* Step 3: Read SWC I/O Base Address */
123
124 outb_p(0x60, WDT_INDEX_IO_PORT); /* Read Index 0x60 */
125 addr_h = inb(WDT_DATA_IO_PORT);
126
127 outb_p(0x61, WDT_INDEX_IO_PORT); /* Read Index 0x61 */
128
129 addr_l = inb(WDT_DATA_IO_PORT);
130
131 swc_base_addr = (addr_h << 8) + addr_l;
132
133#ifdef DEBUG
134 printk(KERN_INFO DPFX "Read SWC I/O Base Address: low %d, high %d,"
135 " res %d\n", addr_l, addr_h, swc_base_addr);
136#endif
137
138 return swc_base_addr;
139}
140
141/* Select Bank 3 of SWC */
142
143static inline void pc87413_swc_bank3(unsigned int swc_base_addr)
144{
145 /* Step 4: Select Bank3 of SWC */
146
147 outb_p(inb(swc_base_addr + 0x0f) | 0x03, swc_base_addr + 0x0f);
148
149#ifdef DEBUG
150 printk(KERN_INFO DPFX "Select Bank3 of SWC\n");
151#endif
152}
153
154/* Set watchdog timeout to x minutes */
155
156static inline void pc87413_programm_wdto(unsigned int swc_base_addr,
157 char pc87413_time)
158{
159 /* Step 5: Programm WDTO, Twd. */
160
161 outb_p(pc87413_time, swc_base_addr + WDTO);
162
163#ifdef DEBUG
164 printk(KERN_INFO DPFX "Set WDTO to %d minutes\n", pc87413_time);
165#endif
166}
167
168/* Enable WDEN */
169
170static inline void pc87413_enable_wden(unsigned int swc_base_addr)
171{
172 /* Step 6: Enable WDEN */
173
174 outb_p(inb (swc_base_addr + WDCTL) | 0x01, swc_base_addr + WDCTL);
175
176#ifdef DEBUG
177 printk(KERN_INFO DPFX "Enable WDEN\n");
178#endif
179}
180
181/* Enable SW_WD_TREN */
182static inline void pc87413_enable_sw_wd_tren(unsigned int swc_base_addr)
183{
184 /* Enable SW_WD_TREN */
185
186 outb_p(inb (swc_base_addr + WDCFG) | 0x80, swc_base_addr + WDCFG);
187
188#ifdef DEBUG
189 printk(KERN_INFO DPFX "Enable SW_WD_TREN\n");
190#endif
191}
192
193/* Disable SW_WD_TREN */
194
195static inline void pc87413_disable_sw_wd_tren(unsigned int swc_base_addr)
196{
197 /* Disable SW_WD_TREN */
198
199 outb_p(inb (swc_base_addr + WDCFG) & 0x7f, swc_base_addr + WDCFG);
200
201#ifdef DEBUG
202 printk(KERN_INFO DPFX "pc87413 - Disable SW_WD_TREN\n");
203#endif
204}
205
206/* Enable SW_WD_TRG */
207
208static inline void pc87413_enable_sw_wd_trg(unsigned int swc_base_addr)
209{
210 /* Enable SW_WD_TRG */
211
212 outb_p(inb (swc_base_addr + WDCTL) | 0x80, swc_base_addr + WDCTL);
213
214#ifdef DEBUG
215 printk(KERN_INFO DPFX "pc87413 - Enable SW_WD_TRG\n");
216#endif
217}
218
219/* Disable SW_WD_TRG */
220
221static inline void pc87413_disable_sw_wd_trg(unsigned int swc_base_addr)
222{
223 /* Disable SW_WD_TRG */
224
225 outb_p(inb (swc_base_addr + WDCTL) & 0x7f, swc_base_addr + WDCTL);
226
227#ifdef DEBUG
228 printk(KERN_INFO DPFX "Disable SW_WD_TRG\n");
229#endif
230}
231
232/* -- Higher level functions ------------------------------------*/
233
234/* Enable the watchdog */
235
236static void pc87413_enable(void)
237{
238 unsigned int swc_base_addr;
239
240 spin_lock(&io_lock);
241
242 pc87413_select_wdt_out();
243 pc87413_enable_swc();
244 swc_base_addr = pc87413_get_swc_base();
245 pc87413_swc_bank3(swc_base_addr);
246 pc87413_programm_wdto(swc_base_addr, timeout);
247 pc87413_enable_wden(swc_base_addr);
248 pc87413_enable_sw_wd_tren(swc_base_addr);
249 pc87413_enable_sw_wd_trg(swc_base_addr);
250
251 spin_unlock(&io_lock);
252}
253
254/* Disable the watchdog */
255
256static void pc87413_disable(void)
257{
258 unsigned int swc_base_addr;
259
260 spin_lock(&io_lock);
261
262 pc87413_select_wdt_out();
263 pc87413_enable_swc();
264 swc_base_addr = pc87413_get_swc_base();
265 pc87413_swc_bank3(swc_base_addr);
266 pc87413_disable_sw_wd_tren(swc_base_addr);
267 pc87413_disable_sw_wd_trg(swc_base_addr);
268 pc87413_programm_wdto(swc_base_addr, 0);
269
270 spin_unlock(&io_lock);
271}
272
273/* Refresh the watchdog */
274
275static void pc87413_refresh(void)
276{
277 unsigned int swc_base_addr;
278
279 spin_lock(&io_lock);
280
281 pc87413_select_wdt_out();
282 pc87413_enable_swc();
283 swc_base_addr = pc87413_get_swc_base();
284 pc87413_swc_bank3(swc_base_addr);
285 pc87413_disable_sw_wd_tren(swc_base_addr);
286 pc87413_disable_sw_wd_trg(swc_base_addr);
287 pc87413_programm_wdto(swc_base_addr, timeout);
288 pc87413_enable_wden(swc_base_addr);
289 pc87413_enable_sw_wd_tren(swc_base_addr);
290 pc87413_enable_sw_wd_trg(swc_base_addr);
291
292 spin_unlock(&io_lock);
293}
294
295/* -- File operations -------------------------------------------*/
296
297/**
298 * pc87413_open:
299 * @inode: inode of device
300 * @file: file handle to device
301 *
302 */
303
304static int pc87413_open(struct inode *inode, struct file *file)
305{
306 /* /dev/watchdog can only be opened once */
307
308 if (test_and_set_bit(0, &timer_enabled))
309 return -EBUSY;
310
311 if (nowayout)
312 __module_get(THIS_MODULE);
313
314 /* Reload and activate timer */
315 pc87413_refresh();
316
317 printk(KERN_INFO MODNAME "Watchdog enabled. Timeout set to"
318 " %d minute(s).\n", timeout);
319
320 return nonseekable_open(inode, file);
321}
322
323/**
324 * pc87413_release:
325 * @inode: inode to board
326 * @file: file handle to board
327 *
328 * The watchdog has a configurable API. There is a religious dispute
329 * between people who want their watchdog to be able to shut down and
330 * those who want to be sure if the watchdog manager dies the machine
331 * reboots. In the former case we disable the counters, in the latter
332 * case you have to open it again very soon.
333 */
334
335static int pc87413_release(struct inode *inode, struct file *file)
336{
337 /* Shut off the timer. */
338
339 if (expect_close == 42) {
340 pc87413_disable();
341 printk(KERN_INFO MODNAME "Watchdog disabled,"
342 " sleeping again...\n");
343 } else {
344 printk(KERN_CRIT MODNAME "Unexpected close, not stopping"
345 " watchdog!\n");
346 pc87413_refresh();
347 }
348
349 clear_bit(0, &timer_enabled);
350 expect_close = 0;
351
352 return 0;
353}
354
355/**
356 * pc87413_status:
357 *
358 * return, if the watchdog is enabled (timeout is set...)
359 */
360
361
362static int pc87413_status(void)
363{
364 return 0; /* currently not supported */
365}
366
367/**
368 * pc87413_write:
369 * @file: file handle to the watchdog
370 * @data: data buffer to write
371 * @len: length in bytes
372 * @ppos: pointer to the position to write. No seeks allowed
373 *
374 * A write to a watchdog device is defined as a keepalive signal. Any
375 * write of data will do, as we we don't define content meaning.
376 */
377
378static ssize_t pc87413_write(struct file *file, const char __user *data,
379 size_t len, loff_t *ppos)
380{
381 /* See if we got the magic character 'V' and reload the timer */
382 if (len) {
383 if (!nowayout) {
384 size_t i;
385
386 /* reset expect flag */
387 expect_close = 0;
388
389 /* scan to see whether or not we got the magic character */
390 for (i = 0; i != len; i++) {
391 char c;
392 if (get_user(c, data+i))
393 return -EFAULT;
394 if (c == 'V')
395 expect_close = 42;
396 }
397 }
398
399 /* someone wrote to us, we should reload the timer */
400 pc87413_refresh();
401 }
402 return len;
403}
404
405/**
406 * pc87413_ioctl:
407 * @inode: inode of the device
408 * @file: file handle to the device
409 * @cmd: watchdog command
410 * @arg: argument pointer
411 *
412 * The watchdog API defines a common set of functions for all watchdogs
413 * according to their available features. We only actually usefully support
414 * querying capabilities and current status.
415 */
416
417static int pc87413_ioctl(struct inode *inode, struct file *file,
418 unsigned int cmd, unsigned long arg)
419{
420 int new_timeout;
421
422 union {
423 struct watchdog_info __user *ident;
424 int __user *i;
425 } uarg;
426
427 static struct watchdog_info ident = {
428 .options = WDIOF_KEEPALIVEPING |
429 WDIOF_SETTIMEOUT |
430 WDIOF_MAGICCLOSE,
431 .firmware_version = 1,
432 .identity = "PC87413(HF/F) watchdog"
433 };
434
435 uarg.i = (int __user *)arg;
436
437 switch(cmd) {
438 default:
439 return -ENOTTY;
440
441 case WDIOC_GETSUPPORT:
442 return copy_to_user(uarg.ident, &ident,
443 sizeof(ident)) ? -EFAULT : 0;
444
445 case WDIOC_GETSTATUS:
446 return put_user(pc87413_status(), uarg.i);
447
448 case WDIOC_GETBOOTSTATUS:
449 return put_user(0, uarg.i);
450
451 case WDIOC_KEEPALIVE:
452 pc87413_refresh();
453#ifdef DEBUG
454 printk(KERN_INFO DPFX "keepalive\n");
455#endif
456 return 0;
457
458 case WDIOC_SETTIMEOUT:
459 if (get_user(new_timeout, uarg.i))
460 return -EFAULT;
461
462 // the API states this is given in secs
463 new_timeout /= 60;
464
465 if (new_timeout < 0 || new_timeout > MAX_TIMEOUT)
466 return -EINVAL;
467
468 timeout = new_timeout;
469 pc87413_refresh();
470
471 // fall through and return the new timeout...
472
473 case WDIOC_GETTIMEOUT:
474
475 new_timeout = timeout * 60;
476
477 return put_user(new_timeout, uarg.i);
478
479 case WDIOC_SETOPTIONS:
480 {
481 int options, retval = -EINVAL;
482
483 if (get_user(options, uarg.i))
484 return -EFAULT;
485
486 if (options & WDIOS_DISABLECARD) {
487 pc87413_disable();
488 retval = 0;
489 }
490
491 if (options & WDIOS_ENABLECARD) {
492 pc87413_enable();
493 retval = 0;
494 }
495
496 return retval;
497 }
498 }
499}
500
501/* -- Notifier funtions -----------------------------------------*/
502
503/**
504 * notify_sys:
505 * @this: our notifier block
506 * @code: the event being reported
507 * @unused: unused
508 *
509 * Our notifier is called on system shutdowns. We want to turn the card
510 * off at reboot otherwise the machine will reboot again during memory
511 * test or worse yet during the following fsck. This would suck, in fact
512 * trust me - if it happens it does suck.
513 */
514
515static int pc87413_notify_sys(struct notifier_block *this,
516 unsigned long code,
517 void *unused)
518{
519 if (code == SYS_DOWN || code == SYS_HALT)
520 {
521 /* Turn the card off */
522 pc87413_disable();
523 }
524 return NOTIFY_DONE;
525}
526
527/* -- Module's structures ---------------------------------------*/
528
529static struct file_operations pc87413_fops = {
530 .owner = THIS_MODULE,
531 .llseek = no_llseek,
532 .write = pc87413_write,
533 .ioctl = pc87413_ioctl,
534 .open = pc87413_open,
535 .release = pc87413_release,
536};
537
538static struct notifier_block pc87413_notifier =
539{
540 .notifier_call = pc87413_notify_sys,
541};
542
543static struct miscdevice pc87413_miscdev=
544{
545 .minor = WATCHDOG_MINOR,
546 .name = "watchdog",
547 .fops = &pc87413_fops
548};
549
550/* -- Module init functions -------------------------------------*/
551
552/**
553 * pc87413_init: module's "constructor"
554 *
555 * Set up the WDT watchdog board. All we have to do is grab the
556 * resources we require and bitch if anyone beat us to them.
557 * The open() function will actually kick the board off.
558 */
559
560static int __init pc87413_init(void)
561{
562 int ret;
563
564 spin_lock_init(&io_lock);
565
566 printk(KERN_INFO PFX "Version " VERSION " at io 0x%X\n", WDT_INDEX_IO_PORT);
567
568 /* request_region(io, 2, "pc87413"); */
569
570 ret = register_reboot_notifier(&pc87413_notifier);
571 if (ret != 0) {
572 printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n",
573 ret);
574 }
575
576 ret = misc_register(&pc87413_miscdev);
577
578 if (ret != 0) {
579 printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",
580 WATCHDOG_MINOR, ret);
581 unregister_reboot_notifier(&pc87413_notifier);
582 return ret;
583 }
584
585 printk(KERN_INFO PFX "initialized. timeout=%d min \n", timeout);
586
587 pc87413_enable();
588
589 return 0;
590}
591
592/**
593 * pc87413_exit: module's "destructor"
594 *
595 * Unload the watchdog. You cannot do this with any file handles open.
596 * If your watchdog is set to continue ticking on close and you unload
597 * it, well it keeps ticking. We won't get the interrupt but the board
598 * will not touch PC memory so all is fine. You just have to load a new
599 * module in 60 seconds or reboot.
600 */
601
602static void __exit pc87413_exit(void)
603{
604 /* Stop the timer before we leave */
605 if (!nowayout)
606 {
607 pc87413_disable();
608 printk(KERN_INFO MODNAME "Watchdog disabled.\n");
609 }
610
611 misc_deregister(&pc87413_miscdev);
612 unregister_reboot_notifier(&pc87413_notifier);
613 /* release_region(io,2); */
614
615 printk(MODNAME " watchdog component driver removed.\n");
616}
617
618module_init(pc87413_init);
619module_exit(pc87413_exit);
620
621MODULE_AUTHOR("Sven Anders <anders@anduras.de>, Marcus Junker <junker@anduras.de>,");
622MODULE_DESCRIPTION("PC87413 WDT driver");
623MODULE_LICENSE("GPL");
624
625MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
626
627module_param(io, int, 0);
628MODULE_PARM_DESC(io, MODNAME " I/O port (default: " __MODULE_STRING(io) ").");
629
630module_param(timeout, int, 0);
631MODULE_PARM_DESC(timeout, "Watchdog timeout in minutes (default=" __MODULE_STRING(timeout) ").");
632
633module_param(nowayout, int, 0);
634MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)");
635
diff --git a/drivers/char/watchdog/pcwd_usb.c b/drivers/char/watchdog/pcwd_usb.c
index bda45334d802..61138726b501 100644
--- a/drivers/char/watchdog/pcwd_usb.c
+++ b/drivers/char/watchdog/pcwd_usb.c
@@ -561,8 +561,7 @@ static struct notifier_block usb_pcwd_notifier = {
561 */ 561 */
562static inline void usb_pcwd_delete (struct usb_pcwd_private *usb_pcwd) 562static inline void usb_pcwd_delete (struct usb_pcwd_private *usb_pcwd)
563{ 563{
564 if (usb_pcwd->intr_urb != NULL) 564 usb_free_urb(usb_pcwd->intr_urb);
565 usb_free_urb (usb_pcwd->intr_urb);
566 if (usb_pcwd->intr_buffer != NULL) 565 if (usb_pcwd->intr_buffer != NULL)
567 usb_buffer_free(usb_pcwd->udev, usb_pcwd->intr_size, 566 usb_buffer_free(usb_pcwd->udev, usb_pcwd->intr_size,
568 usb_pcwd->intr_buffer, usb_pcwd->intr_dma); 567 usb_pcwd->intr_buffer, usb_pcwd->intr_dma);
@@ -635,7 +634,7 @@ static int usb_pcwd_probe(struct usb_interface *interface, const struct usb_devi
635 usb_pcwd->intr_size = (le16_to_cpu(endpoint->wMaxPacketSize) > 8 ? le16_to_cpu(endpoint->wMaxPacketSize) : 8); 634 usb_pcwd->intr_size = (le16_to_cpu(endpoint->wMaxPacketSize) > 8 ? le16_to_cpu(endpoint->wMaxPacketSize) : 8);
636 635
637 /* set up the memory buffer's */ 636 /* set up the memory buffer's */
638 if (!(usb_pcwd->intr_buffer = usb_buffer_alloc(udev, usb_pcwd->intr_size, SLAB_ATOMIC, &usb_pcwd->intr_dma))) { 637 if (!(usb_pcwd->intr_buffer = usb_buffer_alloc(udev, usb_pcwd->intr_size, GFP_ATOMIC, &usb_pcwd->intr_dma))) {
639 printk(KERN_ERR PFX "Out of memory\n"); 638 printk(KERN_ERR PFX "Out of memory\n");
640 goto error; 639 goto error;
641 } 640 }
diff --git a/drivers/char/watchdog/rm9k_wdt.c b/drivers/char/watchdog/rm9k_wdt.c
new file mode 100644
index 000000000000..ec3909371c21
--- /dev/null
+++ b/drivers/char/watchdog/rm9k_wdt.c
@@ -0,0 +1,420 @@
1/*
2 * Watchdog implementation for GPI h/w found on PMC-Sierra RM9xxx
3 * chips.
4 *
5 * Copyright (C) 2004 by Basler Vision Technologies AG
6 * Author: Thomas Koeller <thomas.koeller@baslerweb.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23#include <linux/platform_device.h>
24#include <linux/module.h>
25#include <linux/moduleparam.h>
26#include <linux/interrupt.h>
27#include <linux/fs.h>
28#include <linux/reboot.h>
29#include <linux/notifier.h>
30#include <linux/miscdevice.h>
31#include <linux/watchdog.h>
32#include <asm/io.h>
33#include <asm/atomic.h>
34#include <asm/processor.h>
35#include <asm/uaccess.h>
36#include <asm/system.h>
37#include <asm/rm9k-ocd.h>
38
39#include <rm9k_wdt.h>
40
41
42#define CLOCK 125000000
43#define MAX_TIMEOUT_SECONDS 32
44#define CPCCR 0x0080
45#define CPGIG1SR 0x0044
46#define CPGIG1ER 0x0054
47
48
49/* Function prototypes */
50static irqreturn_t wdt_gpi_irqhdl(int, void *, struct pt_regs *);
51static void wdt_gpi_start(void);
52static void wdt_gpi_stop(void);
53static void wdt_gpi_set_timeout(unsigned int);
54static int wdt_gpi_open(struct inode *, struct file *);
55static int wdt_gpi_release(struct inode *, struct file *);
56static ssize_t wdt_gpi_write(struct file *, const char __user *, size_t, loff_t *);
57static long wdt_gpi_ioctl(struct file *, unsigned int, unsigned long);
58static int wdt_gpi_notify(struct notifier_block *, unsigned long, void *);
59static const struct resource *wdt_gpi_get_resource(struct platform_device *, const char *, unsigned int);
60static int __init wdt_gpi_probe(struct device *);
61static int __exit wdt_gpi_remove(struct device *);
62
63
64static const char wdt_gpi_name[] = "wdt_gpi";
65static atomic_t opencnt;
66static int expect_close;
67static int locked;
68
69
70/* These are set from device resources */
71static void __iomem * wd_regs;
72static unsigned int wd_irq, wd_ctr;
73
74
75/* Module arguments */
76static int timeout = MAX_TIMEOUT_SECONDS;
77module_param(timeout, int, 0444);
78MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds");
79
80static unsigned long resetaddr = 0xbffdc200;
81module_param(resetaddr, ulong, 0444);
82MODULE_PARM_DESC(resetaddr, "Address to write to to force a reset");
83
84static unsigned long flagaddr = 0xbffdc104;
85module_param(flagaddr, ulong, 0444);
86MODULE_PARM_DESC(flagaddr, "Address to write to boot flags to");
87
88static int powercycle;
89module_param(powercycle, bool, 0444);
90MODULE_PARM_DESC(powercycle, "Cycle power if watchdog expires");
91
92static int nowayout = WATCHDOG_NOWAYOUT;
93module_param(nowayout, bool, 0444);
94MODULE_PARM_DESC(nowayout, "Watchdog cannot be disabled once started");
95
96
97/* Interrupt handler */
98static irqreturn_t wdt_gpi_irqhdl(int irq, void *ctxt, struct pt_regs *regs)
99{
100 if (!unlikely(__raw_readl(wd_regs + 0x0008) & 0x1))
101 return IRQ_NONE;
102 __raw_writel(0x1, wd_regs + 0x0008);
103
104
105 printk(KERN_CRIT "%s: watchdog expired - resetting system\n",
106 wdt_gpi_name);
107
108 *(volatile char *) flagaddr |= 0x01;
109 *(volatile char *) resetaddr = powercycle ? 0x01 : 0x2;
110 iob();
111 while (1)
112 cpu_relax();
113}
114
115
116/* Watchdog functions */
117static void wdt_gpi_start(void)
118{
119 u32 reg;
120
121 lock_titan_regs();
122 reg = titan_readl(CPGIG1ER);
123 titan_writel(reg | (0x100 << wd_ctr), CPGIG1ER);
124 iob();
125 unlock_titan_regs();
126}
127
128static void wdt_gpi_stop(void)
129{
130 u32 reg;
131
132 lock_titan_regs();
133 reg = titan_readl(CPCCR) & ~(0xf << (wd_ctr * 4));
134 titan_writel(reg, CPCCR);
135 reg = titan_readl(CPGIG1ER);
136 titan_writel(reg & ~(0x100 << wd_ctr), CPGIG1ER);
137 iob();
138 unlock_titan_regs();
139}
140
141static void wdt_gpi_set_timeout(unsigned int to)
142{
143 u32 reg;
144 const u32 wdval = (to * CLOCK) & ~0x0000000f;
145
146 lock_titan_regs();
147 reg = titan_readl(CPCCR) & ~(0xf << (wd_ctr * 4));
148 titan_writel(reg, CPCCR);
149 wmb();
150 __raw_writel(wdval, wd_regs + 0x0000);
151 wmb();
152 titan_writel(reg | (0x2 << (wd_ctr * 4)), CPCCR);
153 wmb();
154 titan_writel(reg | (0x5 << (wd_ctr * 4)), CPCCR);
155 iob();
156 unlock_titan_regs();
157}
158
159
160/* /dev/watchdog operations */
161static int wdt_gpi_open(struct inode *inode, struct file *file)
162{
163 int res;
164
165 if (unlikely(atomic_dec_if_positive(&opencnt) < 0))
166 return -EBUSY;
167
168 expect_close = 0;
169 if (locked) {
170 module_put(THIS_MODULE);
171 free_irq(wd_irq, &miscdev);
172 locked = 0;
173 }
174
175 res = request_irq(wd_irq, wdt_gpi_irqhdl, SA_SHIRQ | SA_INTERRUPT,
176 wdt_gpi_name, &miscdev);
177 if (unlikely(res))
178 return res;
179
180 wdt_gpi_set_timeout(timeout);
181 wdt_gpi_start();
182
183 printk(KERN_INFO "%s: watchdog started, timeout = %u seconds\n",
184 wdt_gpi_name, timeout);
185 return nonseekable_open(inode, file);
186}
187
188static int wdt_gpi_release(struct inode *inode, struct file *file)
189{
190 if (nowayout) {
191 printk(KERN_INFO "%s: no way out - watchdog left running\n",
192 wdt_gpi_name);
193 __module_get(THIS_MODULE);
194 locked = 1;
195 } else {
196 if (expect_close) {
197 wdt_gpi_stop();
198 free_irq(wd_irq, &miscdev);
199 printk(KERN_INFO "%s: watchdog stopped\n", wdt_gpi_name);
200 } else {
201 printk(KERN_CRIT "%s: unexpected close() -"
202 " watchdog left running\n",
203 wdt_gpi_name);
204 wdt_gpi_set_timeout(timeout);
205 __module_get(THIS_MODULE);
206 locked = 1;
207 }
208 }
209
210 atomic_inc(&opencnt);
211 return 0;
212}
213
214static ssize_t
215wdt_gpi_write(struct file *f, const char __user *d, size_t s, loff_t *o)
216{
217 char val;
218
219 wdt_gpi_set_timeout(timeout);
220 expect_close = (s > 0) && !get_user(val, d) && (val == 'V');
221 return s ? 1 : 0;
222}
223
224static long
225wdt_gpi_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
226{
227 long res = -ENOTTY;
228 const long size = _IOC_SIZE(cmd);
229 int stat;
230 void __user *argp = (void __user *)arg;
231 static struct watchdog_info wdinfo = {
232 .identity = "RM9xxx/GPI watchdog",
233 .firmware_version = 0,
234 .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING
235 };
236
237 if (unlikely(_IOC_TYPE(cmd) != WATCHDOG_IOCTL_BASE))
238 return -ENOTTY;
239
240 if ((_IOC_DIR(cmd) & _IOC_READ)
241 && !access_ok(VERIFY_WRITE, arg, size))
242 return -EFAULT;
243
244 if ((_IOC_DIR(cmd) & _IOC_WRITE)
245 && !access_ok(VERIFY_READ, arg, size))
246 return -EFAULT;
247
248 expect_close = 0;
249
250 switch (cmd) {
251 case WDIOC_GETSUPPORT:
252 wdinfo.options = nowayout ?
253 WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING :
254 WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE;
255 res = __copy_to_user(argp, &wdinfo, size) ? -EFAULT : size;
256 break;
257
258 case WDIOC_GETSTATUS:
259 break;
260
261 case WDIOC_GETBOOTSTATUS:
262 stat = (*(volatile char *) flagaddr & 0x01)
263 ? WDIOF_CARDRESET : 0;
264 res = __copy_to_user(argp, &stat, size) ?
265 -EFAULT : size;
266 break;
267
268 case WDIOC_SETOPTIONS:
269 break;
270
271 case WDIOC_KEEPALIVE:
272 wdt_gpi_set_timeout(timeout);
273 res = size;
274 break;
275
276 case WDIOC_SETTIMEOUT:
277 {
278 int val;
279 if (unlikely(__copy_from_user(&val, argp, size))) {
280 res = -EFAULT;
281 break;
282 }
283
284 if (val > MAX_TIMEOUT_SECONDS)
285 val = MAX_TIMEOUT_SECONDS;
286 timeout = val;
287 wdt_gpi_set_timeout(val);
288 res = size;
289 printk(KERN_INFO "%s: timeout set to %u seconds\n",
290 wdt_gpi_name, timeout);
291 }
292 break;
293
294 case WDIOC_GETTIMEOUT:
295 res = __copy_to_user(argp, &timeout, size) ?
296 -EFAULT : size;
297 break;
298 }
299
300 return res;
301}
302
303
304/* Shutdown notifier */
305static int
306wdt_gpi_notify(struct notifier_block *this, unsigned long code, void *unused)
307{
308 if (code == SYS_DOWN || code == SYS_HALT)
309 wdt_gpi_stop();
310
311 return NOTIFY_DONE;
312}
313
314
315/* Kernel interfaces */
316static struct file_operations fops = {
317 .owner = THIS_MODULE,
318 .open = wdt_gpi_open,
319 .release = wdt_gpi_release,
320 .write = wdt_gpi_write,
321 .unlocked_ioctl = wdt_gpi_ioctl,
322};
323
324static struct miscdevice miscdev = {
325 .minor = WATCHDOG_MINOR,
326 .name = wdt_gpi_name,
327 .fops = &fops,
328};
329
330static struct notifier_block wdt_gpi_shutdown = {
331 .notifier_call = wdt_gpi_notify,
332};
333
334
335/* Init & exit procedures */
336static const struct resource *
337wdt_gpi_get_resource(struct platform_device *pdv, const char *name,
338 unsigned int type)
339{
340 char buf[80];
341 if (snprintf(buf, sizeof buf, "%s_0", name) >= sizeof buf)
342 return NULL;
343 return platform_get_resource_byname(pdv, type, buf);
344}
345
346/* No hotplugging on the platform bus - use __init */
347static int __init wdt_gpi_probe(struct device *dev)
348{
349 int res;
350 struct platform_device * const pdv = to_platform_device(dev);
351 const struct resource
352 * const rr = wdt_gpi_get_resource(pdv, WDT_RESOURCE_REGS,
353 IORESOURCE_MEM),
354 * const ri = wdt_gpi_get_resource(pdv, WDT_RESOURCE_IRQ,
355 IORESOURCE_IRQ),
356 * const rc = wdt_gpi_get_resource(pdv, WDT_RESOURCE_COUNTER,
357 0);
358
359 if (unlikely(!rr || !ri || !rc))
360 return -ENXIO;
361
362 wd_regs = ioremap_nocache(rr->start, rr->end + 1 - rr->start);
363 if (unlikely(!wd_regs))
364 return -ENOMEM;
365 wd_irq = ri->start;
366 wd_ctr = rc->start;
367 res = misc_register(&miscdev);
368 if (res)
369 iounmap(wd_regs);
370 else
371 register_reboot_notifier(&wdt_gpi_shutdown);
372 return res;
373}
374
375static int __exit wdt_gpi_remove(struct device *dev)
376{
377 int res;
378
379 unregister_reboot_notifier(&wdt_gpi_shutdown);
380 res = misc_deregister(&miscdev);
381 iounmap(wd_regs);
382 wd_regs = NULL;
383 return res;
384}
385
386
387/* Device driver init & exit */
388static struct device_driver wdt_gpi_driver = {
389 .name = (char *) wdt_gpi_name,
390 .bus = &platform_bus_type,
391 .owner = THIS_MODULE,
392 .probe = wdt_gpi_probe,
393 .remove = __exit_p(wdt_gpi_remove),
394 .shutdown = NULL,
395 .suspend = NULL,
396 .resume = NULL,
397};
398
399static int __init wdt_gpi_init_module(void)
400{
401 atomic_set(&opencnt, 1);
402 if (timeout > MAX_TIMEOUT_SECONDS)
403 timeout = MAX_TIMEOUT_SECONDS;
404 return driver_register(&wdt_gpi_driver);
405}
406
407static void __exit wdt_gpi_cleanup_module(void)
408{
409 driver_unregister(&wdt_gpi_driver);
410}
411
412module_init(wdt_gpi_init_module);
413module_exit(wdt_gpi_cleanup_module);
414
415MODULE_AUTHOR("Thomas Koeller <thomas.koeller@baslerweb.com>");
416MODULE_DESCRIPTION("Basler eXcite watchdog driver for gpi devices");
417MODULE_VERSION("0.1");
418MODULE_LICENSE("GPL");
419MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
420
diff --git a/drivers/connector/cn_queue.c b/drivers/connector/cn_queue.c
index 05f8ce2cfb4a..b418b16e910e 100644
--- a/drivers/connector/cn_queue.c
+++ b/drivers/connector/cn_queue.c
@@ -31,9 +31,11 @@
31#include <linux/connector.h> 31#include <linux/connector.h>
32#include <linux/delay.h> 32#include <linux/delay.h>
33 33
34void cn_queue_wrapper(void *data) 34void cn_queue_wrapper(struct work_struct *work)
35{ 35{
36 struct cn_callback_data *d = data; 36 struct cn_callback_entry *cbq =
37 container_of(work, struct cn_callback_entry, work.work);
38 struct cn_callback_data *d = &cbq->data;
37 39
38 d->callback(d->callback_priv); 40 d->callback(d->callback_priv);
39 41
@@ -57,7 +59,7 @@ static struct cn_callback_entry *cn_queue_alloc_callback_entry(char *name, struc
57 memcpy(&cbq->id.id, id, sizeof(struct cb_id)); 59 memcpy(&cbq->id.id, id, sizeof(struct cb_id));
58 cbq->data.callback = callback; 60 cbq->data.callback = callback;
59 61
60 INIT_WORK(&cbq->work, &cn_queue_wrapper, &cbq->data); 62 INIT_DELAYED_WORK(&cbq->work, &cn_queue_wrapper);
61 return cbq; 63 return cbq;
62} 64}
63 65
diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c
index b49bacfd8de8..5e7cd45d10ee 100644
--- a/drivers/connector/connector.c
+++ b/drivers/connector/connector.c
@@ -135,40 +135,39 @@ static int cn_call_callback(struct cn_msg *msg, void (*destruct_data)(void *), v
135 spin_lock_bh(&dev->cbdev->queue_lock); 135 spin_lock_bh(&dev->cbdev->queue_lock);
136 list_for_each_entry(__cbq, &dev->cbdev->queue_list, callback_entry) { 136 list_for_each_entry(__cbq, &dev->cbdev->queue_list, callback_entry) {
137 if (cn_cb_equal(&__cbq->id.id, &msg->id)) { 137 if (cn_cb_equal(&__cbq->id.id, &msg->id)) {
138 if (likely(!test_bit(0, &__cbq->work.pending) && 138 if (likely(!test_bit(WORK_STRUCT_PENDING,
139 &__cbq->work.work.management) &&
139 __cbq->data.ddata == NULL)) { 140 __cbq->data.ddata == NULL)) {
140 __cbq->data.callback_priv = msg; 141 __cbq->data.callback_priv = msg;
141 142
142 __cbq->data.ddata = data; 143 __cbq->data.ddata = data;
143 __cbq->data.destruct_data = destruct_data; 144 __cbq->data.destruct_data = destruct_data;
144 145
145 if (queue_work(dev->cbdev->cn_queue, 146 if (queue_delayed_work(
146 &__cbq->work)) 147 dev->cbdev->cn_queue,
148 &__cbq->work, 0))
147 err = 0; 149 err = 0;
148 } else { 150 } else {
149 struct work_struct *w;
150 struct cn_callback_data *d; 151 struct cn_callback_data *d;
151 152
152 w = kzalloc(sizeof(*w) + sizeof(*d), GFP_ATOMIC); 153 __cbq = kzalloc(sizeof(*__cbq), GFP_ATOMIC);
153 if (w) { 154 if (__cbq) {
154 d = (struct cn_callback_data *)(w+1); 155 d = &__cbq->data;
155
156 d->callback_priv = msg; 156 d->callback_priv = msg;
157 d->callback = __cbq->data.callback; 157 d->callback = __cbq->data.callback;
158 d->ddata = data; 158 d->ddata = data;
159 d->destruct_data = destruct_data; 159 d->destruct_data = destruct_data;
160 d->free = w; 160 d->free = __cbq;
161 161
162 INIT_LIST_HEAD(&w->entry); 162 INIT_DELAYED_WORK(&__cbq->work,
163 w->pending = 0; 163 &cn_queue_wrapper);
164 w->func = &cn_queue_wrapper;
165 w->data = d;
166 init_timer(&w->timer);
167 164
168 if (queue_work(dev->cbdev->cn_queue, w)) 165 if (queue_delayed_work(
166 dev->cbdev->cn_queue,
167 &__cbq->work, 0))
169 err = 0; 168 err = 0;
170 else { 169 else {
171 kfree(w); 170 kfree(__cbq);
172 err = -EINVAL; 171 err = -EINVAL;
173 } 172 }
174 } else 173 } else
diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig
index 2cc71b66231e..491779af8d55 100644
--- a/drivers/cpufreq/Kconfig
+++ b/drivers/cpufreq/Kconfig
@@ -107,6 +107,7 @@ config CPU_FREQ_GOV_USERSPACE
107 107
108config CPU_FREQ_GOV_ONDEMAND 108config CPU_FREQ_GOV_ONDEMAND
109 tristate "'ondemand' cpufreq policy governor" 109 tristate "'ondemand' cpufreq policy governor"
110 select CPU_FREQ_TABLE
110 help 111 help
111 'ondemand' - This driver adds a dynamic cpufreq policy governor. 112 'ondemand' - This driver adds a dynamic cpufreq policy governor.
112 The governor does a periodic polling and 113 The governor does a periodic polling and
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 86e69b7f9122..47ab42db122a 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -42,7 +42,7 @@ static DEFINE_SPINLOCK(cpufreq_driver_lock);
42 42
43/* internal prototypes */ 43/* internal prototypes */
44static int __cpufreq_governor(struct cpufreq_policy *policy, unsigned int event); 44static int __cpufreq_governor(struct cpufreq_policy *policy, unsigned int event);
45static void handle_update(void *data); 45static void handle_update(struct work_struct *work);
46 46
47/** 47/**
48 * Two notifier lists: the "policy" list is involved in the 48 * Two notifier lists: the "policy" list is involved in the
@@ -59,7 +59,7 @@ static int __init init_cpufreq_transition_notifier_list(void)
59 srcu_init_notifier_head(&cpufreq_transition_notifier_list); 59 srcu_init_notifier_head(&cpufreq_transition_notifier_list);
60 return 0; 60 return 0;
61} 61}
62core_initcall(init_cpufreq_transition_notifier_list); 62pure_initcall(init_cpufreq_transition_notifier_list);
63 63
64static LIST_HEAD(cpufreq_governor_list); 64static LIST_HEAD(cpufreq_governor_list);
65static DEFINE_MUTEX (cpufreq_governor_mutex); 65static DEFINE_MUTEX (cpufreq_governor_mutex);
@@ -665,7 +665,7 @@ static int cpufreq_add_dev (struct sys_device * sys_dev)
665 mutex_init(&policy->lock); 665 mutex_init(&policy->lock);
666 mutex_lock(&policy->lock); 666 mutex_lock(&policy->lock);
667 init_completion(&policy->kobj_unregister); 667 init_completion(&policy->kobj_unregister);
668 INIT_WORK(&policy->update, handle_update, (void *)(long)cpu); 668 INIT_WORK(&policy->update, handle_update);
669 669
670 /* call driver. From then on the cpufreq must be able 670 /* call driver. From then on the cpufreq must be able
671 * to accept all calls to ->verify and ->setpolicy for this CPU 671 * to accept all calls to ->verify and ->setpolicy for this CPU
@@ -895,9 +895,11 @@ static int cpufreq_remove_dev (struct sys_device * sys_dev)
895} 895}
896 896
897 897
898static void handle_update(void *data) 898static void handle_update(struct work_struct *work)
899{ 899{
900 unsigned int cpu = (unsigned int)(long)data; 900 struct cpufreq_policy *policy =
901 container_of(work, struct cpufreq_policy, update);
902 unsigned int cpu = policy->cpu;
901 dprintk("handle_update for cpu %u called\n", cpu); 903 dprintk("handle_update for cpu %u called\n", cpu);
902 cpufreq_update_policy(cpu); 904 cpufreq_update_policy(cpu);
903} 905}
@@ -1535,7 +1537,6 @@ int cpufreq_update_policy(unsigned int cpu)
1535} 1537}
1536EXPORT_SYMBOL(cpufreq_update_policy); 1538EXPORT_SYMBOL(cpufreq_update_policy);
1537 1539
1538#ifdef CONFIG_HOTPLUG_CPU
1539static int cpufreq_cpu_callback(struct notifier_block *nfb, 1540static int cpufreq_cpu_callback(struct notifier_block *nfb,
1540 unsigned long action, void *hcpu) 1541 unsigned long action, void *hcpu)
1541{ 1542{
@@ -1575,7 +1576,6 @@ static struct notifier_block __cpuinitdata cpufreq_cpu_notifier =
1575{ 1576{
1576 .notifier_call = cpufreq_cpu_callback, 1577 .notifier_call = cpufreq_cpu_callback,
1577}; 1578};
1578#endif /* CONFIG_HOTPLUG_CPU */
1579 1579
1580/********************************************************************* 1580/*********************************************************************
1581 * REGISTER / UNREGISTER CPUFREQ DRIVER * 1581 * REGISTER / UNREGISTER CPUFREQ DRIVER *
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c
index c4c578defabf..5ef5ede5b884 100644
--- a/drivers/cpufreq/cpufreq_conservative.c
+++ b/drivers/cpufreq/cpufreq_conservative.c
@@ -59,7 +59,7 @@ static unsigned int def_sampling_rate;
59#define MAX_SAMPLING_DOWN_FACTOR (10) 59#define MAX_SAMPLING_DOWN_FACTOR (10)
60#define TRANSITION_LATENCY_LIMIT (10 * 1000) 60#define TRANSITION_LATENCY_LIMIT (10 * 1000)
61 61
62static void do_dbs_timer(void *data); 62static void do_dbs_timer(struct work_struct *work);
63 63
64struct cpu_dbs_info_s { 64struct cpu_dbs_info_s {
65 struct cpufreq_policy *cur_policy; 65 struct cpufreq_policy *cur_policy;
@@ -82,7 +82,7 @@ static unsigned int dbs_enable; /* number of CPUs using this policy */
82 * is recursive for the same process. -Venki 82 * is recursive for the same process. -Venki
83 */ 83 */
84static DEFINE_MUTEX (dbs_mutex); 84static DEFINE_MUTEX (dbs_mutex);
85static DECLARE_WORK (dbs_work, do_dbs_timer, NULL); 85static DECLARE_DELAYED_WORK(dbs_work, do_dbs_timer);
86 86
87struct dbs_tuners { 87struct dbs_tuners {
88 unsigned int sampling_rate; 88 unsigned int sampling_rate;
@@ -420,7 +420,7 @@ static void dbs_check_cpu(int cpu)
420 } 420 }
421} 421}
422 422
423static void do_dbs_timer(void *data) 423static void do_dbs_timer(struct work_struct *work)
424{ 424{
425 int i; 425 int i;
426 lock_cpu_hotplug(); 426 lock_cpu_hotplug();
@@ -435,7 +435,6 @@ static void do_dbs_timer(void *data)
435 435
436static inline void dbs_timer_init(void) 436static inline void dbs_timer_init(void)
437{ 437{
438 INIT_WORK(&dbs_work, do_dbs_timer, NULL);
439 schedule_delayed_work(&dbs_work, 438 schedule_delayed_work(&dbs_work,
440 usecs_to_jiffies(dbs_tuners_ins.sampling_rate)); 439 usecs_to_jiffies(dbs_tuners_ins.sampling_rate));
441 return; 440 return;
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
index bf8aa45d4f01..e1cc5113c2ae 100644
--- a/drivers/cpufreq/cpufreq_ondemand.c
+++ b/drivers/cpufreq/cpufreq_ondemand.c
@@ -47,13 +47,17 @@ static unsigned int def_sampling_rate;
47#define DEF_SAMPLING_RATE_LATENCY_MULTIPLIER (1000) 47#define DEF_SAMPLING_RATE_LATENCY_MULTIPLIER (1000)
48#define TRANSITION_LATENCY_LIMIT (10 * 1000) 48#define TRANSITION_LATENCY_LIMIT (10 * 1000)
49 49
50static void do_dbs_timer(void *data); 50static void do_dbs_timer(struct work_struct *work);
51
52/* Sampling types */
53enum dbs_sample {DBS_NORMAL_SAMPLE, DBS_SUB_SAMPLE};
51 54
52struct cpu_dbs_info_s { 55struct cpu_dbs_info_s {
53 cputime64_t prev_cpu_idle; 56 cputime64_t prev_cpu_idle;
54 cputime64_t prev_cpu_wall; 57 cputime64_t prev_cpu_wall;
55 struct cpufreq_policy *cur_policy; 58 struct cpufreq_policy *cur_policy;
56 struct work_struct work; 59 struct delayed_work work;
60 enum dbs_sample sample_type;
57 unsigned int enable; 61 unsigned int enable;
58 struct cpufreq_frequency_table *freq_table; 62 struct cpufreq_frequency_table *freq_table;
59 unsigned int freq_lo; 63 unsigned int freq_lo;
@@ -407,30 +411,31 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
407 } 411 }
408} 412}
409 413
410/* Sampling types */ 414static void do_dbs_timer(struct work_struct *work)
411enum {DBS_NORMAL_SAMPLE, DBS_SUB_SAMPLE};
412
413static void do_dbs_timer(void *data)
414{ 415{
415 unsigned int cpu = smp_processor_id(); 416 unsigned int cpu = smp_processor_id();
416 struct cpu_dbs_info_s *dbs_info = &per_cpu(cpu_dbs_info, cpu); 417 struct cpu_dbs_info_s *dbs_info = &per_cpu(cpu_dbs_info, cpu);
418 enum dbs_sample sample_type = dbs_info->sample_type;
417 /* We want all CPUs to do sampling nearly on same jiffy */ 419 /* We want all CPUs to do sampling nearly on same jiffy */
418 int delay = usecs_to_jiffies(dbs_tuners_ins.sampling_rate); 420 int delay = usecs_to_jiffies(dbs_tuners_ins.sampling_rate);
421
422 /* Permit rescheduling of this work item */
423 work_release(work);
424
419 delay -= jiffies % delay; 425 delay -= jiffies % delay;
420 426
421 if (!dbs_info->enable) 427 if (!dbs_info->enable)
422 return; 428 return;
423 /* Common NORMAL_SAMPLE setup */ 429 /* Common NORMAL_SAMPLE setup */
424 INIT_WORK(&dbs_info->work, do_dbs_timer, (void *)DBS_NORMAL_SAMPLE); 430 dbs_info->sample_type = DBS_NORMAL_SAMPLE;
425 if (!dbs_tuners_ins.powersave_bias || 431 if (!dbs_tuners_ins.powersave_bias ||
426 (unsigned long) data == DBS_NORMAL_SAMPLE) { 432 sample_type == DBS_NORMAL_SAMPLE) {
427 lock_cpu_hotplug(); 433 lock_cpu_hotplug();
428 dbs_check_cpu(dbs_info); 434 dbs_check_cpu(dbs_info);
429 unlock_cpu_hotplug(); 435 unlock_cpu_hotplug();
430 if (dbs_info->freq_lo) { 436 if (dbs_info->freq_lo) {
431 /* Setup timer for SUB_SAMPLE */ 437 /* Setup timer for SUB_SAMPLE */
432 INIT_WORK(&dbs_info->work, do_dbs_timer, 438 dbs_info->sample_type = DBS_SUB_SAMPLE;
433 (void *)DBS_SUB_SAMPLE);
434 delay = dbs_info->freq_hi_jiffies; 439 delay = dbs_info->freq_hi_jiffies;
435 } 440 }
436 } else { 441 } else {
@@ -449,7 +454,8 @@ static inline void dbs_timer_init(unsigned int cpu)
449 delay -= jiffies % delay; 454 delay -= jiffies % delay;
450 455
451 ondemand_powersave_bias_init(); 456 ondemand_powersave_bias_init();
452 INIT_WORK(&dbs_info->work, do_dbs_timer, NULL); 457 INIT_DELAYED_WORK_NAR(&dbs_info->work, do_dbs_timer);
458 dbs_info->sample_type = DBS_NORMAL_SAMPLE;
453 queue_delayed_work_on(cpu, kondemand_wq, &dbs_info->work, delay); 459 queue_delayed_work_on(cpu, kondemand_wq, &dbs_info->work, delay);
454} 460}
455 461
diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig
index adb554153f67..e816535ab305 100644
--- a/drivers/crypto/Kconfig
+++ b/drivers/crypto/Kconfig
@@ -51,4 +51,17 @@ config CRYPTO_DEV_PADLOCK_SHA
51 If unsure say M. The compiled module will be 51 If unsure say M. The compiled module will be
52 called padlock-sha.ko 52 called padlock-sha.ko
53 53
54config CRYPTO_DEV_GEODE
55 tristate "Support for the Geode LX AES engine"
56 depends on CRYPTO && X86_32
57 select CRYPTO_ALGAPI
58 select CRYPTO_BLKCIPHER
59 default m
60 help
61 Say 'Y' here to use the AMD Geode LX processor on-board AES
62 engine for the CryptoAPI AES alogrithm.
63
64 To compile this driver as a module, choose M here: the module
65 will be called geode-aes.
66
54endmenu 67endmenu
diff --git a/drivers/crypto/Makefile b/drivers/crypto/Makefile
index 4c3d0ec1cf80..6059cf869414 100644
--- a/drivers/crypto/Makefile
+++ b/drivers/crypto/Makefile
@@ -1,3 +1,4 @@
1obj-$(CONFIG_CRYPTO_DEV_PADLOCK) += padlock.o 1obj-$(CONFIG_CRYPTO_DEV_PADLOCK) += padlock.o
2obj-$(CONFIG_CRYPTO_DEV_PADLOCK_AES) += padlock-aes.o 2obj-$(CONFIG_CRYPTO_DEV_PADLOCK_AES) += padlock-aes.o
3obj-$(CONFIG_CRYPTO_DEV_PADLOCK_SHA) += padlock-sha.o 3obj-$(CONFIG_CRYPTO_DEV_PADLOCK_SHA) += padlock-sha.o
4obj-$(CONFIG_CRYPTO_DEV_GEODE) += geode-aes.o
diff --git a/drivers/crypto/geode-aes.c b/drivers/crypto/geode-aes.c
new file mode 100644
index 000000000000..43a68398656f
--- /dev/null
+++ b/drivers/crypto/geode-aes.c
@@ -0,0 +1,474 @@
1 /* Copyright (C) 2004-2006, Advanced Micro Devices, Inc.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 */
8
9#include <linux/module.h>
10#include <linux/kernel.h>
11#include <linux/sched.h>
12#include <linux/pci.h>
13#include <linux/pci_ids.h>
14#include <linux/crypto.h>
15#include <linux/spinlock.h>
16#include <crypto/algapi.h>
17
18#include <asm/io.h>
19#include <asm/delay.h>
20
21#include "geode-aes.h"
22
23/* Register definitions */
24
25#define AES_CTRLA_REG 0x0000
26
27#define AES_CTRL_START 0x01
28#define AES_CTRL_DECRYPT 0x00
29#define AES_CTRL_ENCRYPT 0x02
30#define AES_CTRL_WRKEY 0x04
31#define AES_CTRL_DCA 0x08
32#define AES_CTRL_SCA 0x10
33#define AES_CTRL_CBC 0x20
34
35#define AES_INTR_REG 0x0008
36
37#define AES_INTRA_PENDING (1 << 16)
38#define AES_INTRB_PENDING (1 << 17)
39
40#define AES_INTR_PENDING (AES_INTRA_PENDING | AES_INTRB_PENDING)
41#define AES_INTR_MASK 0x07
42
43#define AES_SOURCEA_REG 0x0010
44#define AES_DSTA_REG 0x0014
45#define AES_LENA_REG 0x0018
46#define AES_WRITEKEY0_REG 0x0030
47#define AES_WRITEIV0_REG 0x0040
48
49/* A very large counter that is used to gracefully bail out of an
50 * operation in case of trouble
51 */
52
53#define AES_OP_TIMEOUT 0x50000
54
55/* Static structures */
56
57static void __iomem * _iobase;
58static spinlock_t lock;
59
60/* Write a 128 bit field (either a writable key or IV) */
61static inline void
62_writefield(u32 offset, void *value)
63{
64 int i;
65 for(i = 0; i < 4; i++)
66 iowrite32(((u32 *) value)[i], _iobase + offset + (i * 4));
67}
68
69/* Read a 128 bit field (either a writable key or IV) */
70static inline void
71_readfield(u32 offset, void *value)
72{
73 int i;
74 for(i = 0; i < 4; i++)
75 ((u32 *) value)[i] = ioread32(_iobase + offset + (i * 4));
76}
77
78static int
79do_crypt(void *src, void *dst, int len, u32 flags)
80{
81 u32 status;
82 u32 counter = AES_OP_TIMEOUT;
83
84 iowrite32(virt_to_phys(src), _iobase + AES_SOURCEA_REG);
85 iowrite32(virt_to_phys(dst), _iobase + AES_DSTA_REG);
86 iowrite32(len, _iobase + AES_LENA_REG);
87
88 /* Start the operation */
89 iowrite32(AES_CTRL_START | flags, _iobase + AES_CTRLA_REG);
90
91 do
92 status = ioread32(_iobase + AES_INTR_REG);
93 while(!(status & AES_INTRA_PENDING) && --counter);
94
95 /* Clear the event */
96 iowrite32((status & 0xFF) | AES_INTRA_PENDING, _iobase + AES_INTR_REG);
97 return counter ? 0 : 1;
98}
99
100static unsigned int
101geode_aes_crypt(struct geode_aes_op *op)
102{
103
104 u32 flags = 0;
105 int iflags;
106
107 if (op->len == 0 || op->src == op->dst)
108 return 0;
109
110 if (op->flags & AES_FLAGS_COHERENT)
111 flags |= (AES_CTRL_DCA | AES_CTRL_SCA);
112
113 if (op->dir == AES_DIR_ENCRYPT)
114 flags |= AES_CTRL_ENCRYPT;
115
116 /* Start the critical section */
117
118 spin_lock_irqsave(&lock, iflags);
119
120 if (op->mode == AES_MODE_CBC) {
121 flags |= AES_CTRL_CBC;
122 _writefield(AES_WRITEIV0_REG, op->iv);
123 }
124
125 if (op->flags & AES_FLAGS_USRKEY) {
126 flags |= AES_CTRL_WRKEY;
127 _writefield(AES_WRITEKEY0_REG, op->key);
128 }
129
130 do_crypt(op->src, op->dst, op->len, flags);
131
132 if (op->mode == AES_MODE_CBC)
133 _readfield(AES_WRITEIV0_REG, op->iv);
134
135 spin_unlock_irqrestore(&lock, iflags);
136
137 return op->len;
138}
139
140/* CRYPTO-API Functions */
141
142static int
143geode_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int len)
144{
145 struct geode_aes_op *op = crypto_tfm_ctx(tfm);
146
147 if (len != AES_KEY_LENGTH) {
148 tfm->crt_flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
149 return -EINVAL;
150 }
151
152 memcpy(op->key, key, len);
153 return 0;
154}
155
156static void
157geode_encrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
158{
159 struct geode_aes_op *op = crypto_tfm_ctx(tfm);
160
161 if ((out == NULL) || (in == NULL))
162 return;
163
164 op->src = (void *) in;
165 op->dst = (void *) out;
166 op->mode = AES_MODE_ECB;
167 op->flags = 0;
168 op->len = AES_MIN_BLOCK_SIZE;
169 op->dir = AES_DIR_ENCRYPT;
170
171 geode_aes_crypt(op);
172}
173
174
175static void
176geode_decrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
177{
178 struct geode_aes_op *op = crypto_tfm_ctx(tfm);
179
180 if ((out == NULL) || (in == NULL))
181 return;
182
183 op->src = (void *) in;
184 op->dst = (void *) out;
185 op->mode = AES_MODE_ECB;
186 op->flags = 0;
187 op->len = AES_MIN_BLOCK_SIZE;
188 op->dir = AES_DIR_DECRYPT;
189
190 geode_aes_crypt(op);
191}
192
193
194static struct crypto_alg geode_alg = {
195 .cra_name = "aes",
196 .cra_driver_name = "geode-aes-128",
197 .cra_priority = 300,
198 .cra_alignmask = 15,
199 .cra_flags = CRYPTO_ALG_TYPE_CIPHER,
200 .cra_blocksize = AES_MIN_BLOCK_SIZE,
201 .cra_ctxsize = sizeof(struct geode_aes_op),
202 .cra_module = THIS_MODULE,
203 .cra_list = LIST_HEAD_INIT(geode_alg.cra_list),
204 .cra_u = {
205 .cipher = {
206 .cia_min_keysize = AES_KEY_LENGTH,
207 .cia_max_keysize = AES_KEY_LENGTH,
208 .cia_setkey = geode_setkey,
209 .cia_encrypt = geode_encrypt,
210 .cia_decrypt = geode_decrypt
211 }
212 }
213};
214
215static int
216geode_cbc_decrypt(struct blkcipher_desc *desc,
217 struct scatterlist *dst, struct scatterlist *src,
218 unsigned int nbytes)
219{
220 struct geode_aes_op *op = crypto_blkcipher_ctx(desc->tfm);
221 struct blkcipher_walk walk;
222 int err, ret;
223
224 blkcipher_walk_init(&walk, dst, src, nbytes);
225 err = blkcipher_walk_virt(desc, &walk);
226
227 while((nbytes = walk.nbytes)) {
228 op->src = walk.src.virt.addr,
229 op->dst = walk.dst.virt.addr;
230 op->mode = AES_MODE_CBC;
231 op->len = nbytes - (nbytes % AES_MIN_BLOCK_SIZE);
232 op->dir = AES_DIR_DECRYPT;
233
234 memcpy(op->iv, walk.iv, AES_IV_LENGTH);
235
236 ret = geode_aes_crypt(op);
237
238 memcpy(walk.iv, op->iv, AES_IV_LENGTH);
239 nbytes -= ret;
240
241 err = blkcipher_walk_done(desc, &walk, nbytes);
242 }
243
244 return err;
245}
246
247static int
248geode_cbc_encrypt(struct blkcipher_desc *desc,
249 struct scatterlist *dst, struct scatterlist *src,
250 unsigned int nbytes)
251{
252 struct geode_aes_op *op = crypto_blkcipher_ctx(desc->tfm);
253 struct blkcipher_walk walk;
254 int err, ret;
255
256 blkcipher_walk_init(&walk, dst, src, nbytes);
257 err = blkcipher_walk_virt(desc, &walk);
258
259 while((nbytes = walk.nbytes)) {
260 op->src = walk.src.virt.addr,
261 op->dst = walk.dst.virt.addr;
262 op->mode = AES_MODE_CBC;
263 op->len = nbytes - (nbytes % AES_MIN_BLOCK_SIZE);
264 op->dir = AES_DIR_ENCRYPT;
265
266 memcpy(op->iv, walk.iv, AES_IV_LENGTH);
267
268 ret = geode_aes_crypt(op);
269 nbytes -= ret;
270 err = blkcipher_walk_done(desc, &walk, nbytes);
271 }
272
273 return err;
274}
275
276static struct crypto_alg geode_cbc_alg = {
277 .cra_name = "cbc(aes)",
278 .cra_driver_name = "cbc-aes-geode-128",
279 .cra_priority = 400,
280 .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER,
281 .cra_blocksize = AES_MIN_BLOCK_SIZE,
282 .cra_ctxsize = sizeof(struct geode_aes_op),
283 .cra_alignmask = 15,
284 .cra_type = &crypto_blkcipher_type,
285 .cra_module = THIS_MODULE,
286 .cra_list = LIST_HEAD_INIT(geode_cbc_alg.cra_list),
287 .cra_u = {
288 .blkcipher = {
289 .min_keysize = AES_KEY_LENGTH,
290 .max_keysize = AES_KEY_LENGTH,
291 .setkey = geode_setkey,
292 .encrypt = geode_cbc_encrypt,
293 .decrypt = geode_cbc_decrypt,
294 }
295 }
296};
297
298static int
299geode_ecb_decrypt(struct blkcipher_desc *desc,
300 struct scatterlist *dst, struct scatterlist *src,
301 unsigned int nbytes)
302{
303 struct geode_aes_op *op = crypto_blkcipher_ctx(desc->tfm);
304 struct blkcipher_walk walk;
305 int err, ret;
306
307 blkcipher_walk_init(&walk, dst, src, nbytes);
308 err = blkcipher_walk_virt(desc, &walk);
309
310 while((nbytes = walk.nbytes)) {
311 op->src = walk.src.virt.addr,
312 op->dst = walk.dst.virt.addr;
313 op->mode = AES_MODE_ECB;
314 op->len = nbytes - (nbytes % AES_MIN_BLOCK_SIZE);
315 op->dir = AES_DIR_DECRYPT;
316
317 ret = geode_aes_crypt(op);
318 nbytes -= ret;
319 err = blkcipher_walk_done(desc, &walk, nbytes);
320 }
321
322 return err;
323}
324
325static int
326geode_ecb_encrypt(struct blkcipher_desc *desc,
327 struct scatterlist *dst, struct scatterlist *src,
328 unsigned int nbytes)
329{
330 struct geode_aes_op *op = crypto_blkcipher_ctx(desc->tfm);
331 struct blkcipher_walk walk;
332 int err, ret;
333
334 blkcipher_walk_init(&walk, dst, src, nbytes);
335 err = blkcipher_walk_virt(desc, &walk);
336
337 while((nbytes = walk.nbytes)) {
338 op->src = walk.src.virt.addr,
339 op->dst = walk.dst.virt.addr;
340 op->mode = AES_MODE_ECB;
341 op->len = nbytes - (nbytes % AES_MIN_BLOCK_SIZE);
342 op->dir = AES_DIR_ENCRYPT;
343
344 ret = geode_aes_crypt(op);
345 nbytes -= ret;
346 ret = blkcipher_walk_done(desc, &walk, nbytes);
347 }
348
349 return err;
350}
351
352static struct crypto_alg geode_ecb_alg = {
353 .cra_name = "ecb(aes)",
354 .cra_driver_name = "ecb-aes-geode-128",
355 .cra_priority = 400,
356 .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER,
357 .cra_blocksize = AES_MIN_BLOCK_SIZE,
358 .cra_ctxsize = sizeof(struct geode_aes_op),
359 .cra_alignmask = 15,
360 .cra_type = &crypto_blkcipher_type,
361 .cra_module = THIS_MODULE,
362 .cra_list = LIST_HEAD_INIT(geode_ecb_alg.cra_list),
363 .cra_u = {
364 .blkcipher = {
365 .min_keysize = AES_KEY_LENGTH,
366 .max_keysize = AES_KEY_LENGTH,
367 .setkey = geode_setkey,
368 .encrypt = geode_ecb_encrypt,
369 .decrypt = geode_ecb_decrypt,
370 }
371 }
372};
373
374static void
375geode_aes_remove(struct pci_dev *dev)
376{
377 crypto_unregister_alg(&geode_alg);
378 crypto_unregister_alg(&geode_ecb_alg);
379 crypto_unregister_alg(&geode_cbc_alg);
380
381 pci_iounmap(dev, _iobase);
382 _iobase = NULL;
383
384 pci_release_regions(dev);
385 pci_disable_device(dev);
386}
387
388
389static int
390geode_aes_probe(struct pci_dev *dev, const struct pci_device_id *id)
391{
392 int ret;
393
394 if ((ret = pci_enable_device(dev)))
395 return ret;
396
397 if ((ret = pci_request_regions(dev, "geode-aes-128")))
398 goto eenable;
399
400 _iobase = pci_iomap(dev, 0, 0);
401
402 if (_iobase == NULL) {
403 ret = -ENOMEM;
404 goto erequest;
405 }
406
407 spin_lock_init(&lock);
408
409 /* Clear any pending activity */
410 iowrite32(AES_INTR_PENDING | AES_INTR_MASK, _iobase + AES_INTR_REG);
411
412 if ((ret = crypto_register_alg(&geode_alg)))
413 goto eiomap;
414
415 if ((ret = crypto_register_alg(&geode_ecb_alg)))
416 goto ealg;
417
418 if ((ret = crypto_register_alg(&geode_cbc_alg)))
419 goto eecb;
420
421 printk(KERN_NOTICE "geode-aes: GEODE AES engine enabled.\n");
422 return 0;
423
424 eecb:
425 crypto_unregister_alg(&geode_ecb_alg);
426
427 ealg:
428 crypto_unregister_alg(&geode_alg);
429
430 eiomap:
431 pci_iounmap(dev, _iobase);
432
433 erequest:
434 pci_release_regions(dev);
435
436 eenable:
437 pci_disable_device(dev);
438
439 printk(KERN_ERR "geode-aes: GEODE AES initialization failed.\n");
440 return ret;
441}
442
443static struct pci_device_id geode_aes_tbl[] = {
444 { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_LX_AES, PCI_ANY_ID, PCI_ANY_ID} ,
445 { 0, }
446};
447
448MODULE_DEVICE_TABLE(pci, geode_aes_tbl);
449
450static struct pci_driver geode_aes_driver = {
451 .name = "Geode LX AES",
452 .id_table = geode_aes_tbl,
453 .probe = geode_aes_probe,
454 .remove = __devexit_p(geode_aes_remove)
455};
456
457static int __init
458geode_aes_init(void)
459{
460 return pci_module_init(&geode_aes_driver);
461}
462
463static void __exit
464geode_aes_exit(void)
465{
466 pci_unregister_driver(&geode_aes_driver);
467}
468
469MODULE_AUTHOR("Advanced Micro Devices, Inc.");
470MODULE_DESCRIPTION("Geode LX Hardware AES driver");
471MODULE_LICENSE("GPL");
472
473module_init(geode_aes_init);
474module_exit(geode_aes_exit);
diff --git a/drivers/crypto/geode-aes.h b/drivers/crypto/geode-aes.h
new file mode 100644
index 000000000000..8003a36f3a83
--- /dev/null
+++ b/drivers/crypto/geode-aes.h
@@ -0,0 +1,40 @@
1/* Copyright (C) 2003-2006, Advanced Micro Devices, Inc.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 */
8
9#ifndef _GEODE_AES_H_
10#define _GEODE_AES_H_
11
12#define AES_KEY_LENGTH 16
13#define AES_IV_LENGTH 16
14
15#define AES_MIN_BLOCK_SIZE 16
16
17#define AES_MODE_ECB 0
18#define AES_MODE_CBC 1
19
20#define AES_DIR_DECRYPT 0
21#define AES_DIR_ENCRYPT 1
22
23#define AES_FLAGS_USRKEY (1 << 0)
24#define AES_FLAGS_COHERENT (1 << 1)
25
26struct geode_aes_op {
27
28 void *src;
29 void *dst;
30
31 u32 mode;
32 u32 dir;
33 u32 flags;
34 int len;
35
36 u8 key[AES_KEY_LENGTH];
37 u8 iv[AES_IV_LENGTH];
38};
39
40#endif
diff --git a/drivers/dma/ioatdma.c b/drivers/dma/ioatdma.c
index 0358419a0e48..8e8726104619 100644
--- a/drivers/dma/ioatdma.c
+++ b/drivers/dma/ioatdma.c
@@ -636,10 +636,10 @@ static int ioat_self_test(struct ioat_device *device)
636 dma_cookie_t cookie; 636 dma_cookie_t cookie;
637 int err = 0; 637 int err = 0;
638 638
639 src = kzalloc(sizeof(u8) * IOAT_TEST_SIZE, SLAB_KERNEL); 639 src = kzalloc(sizeof(u8) * IOAT_TEST_SIZE, GFP_KERNEL);
640 if (!src) 640 if (!src)
641 return -ENOMEM; 641 return -ENOMEM;
642 dest = kzalloc(sizeof(u8) * IOAT_TEST_SIZE, SLAB_KERNEL); 642 dest = kzalloc(sizeof(u8) * IOAT_TEST_SIZE, GFP_KERNEL);
643 if (!dest) { 643 if (!dest) {
644 kfree(src); 644 kfree(src);
645 return -ENOMEM; 645 return -ENOMEM;
diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
index 75e9e38330ff..1b4fc9221803 100644
--- a/drivers/edac/edac_mc.c
+++ b/drivers/edac/edac_mc.c
@@ -28,6 +28,7 @@
28#include <linux/sysdev.h> 28#include <linux/sysdev.h>
29#include <linux/ctype.h> 29#include <linux/ctype.h>
30#include <linux/kthread.h> 30#include <linux/kthread.h>
31#include <linux/freezer.h>
31#include <asm/uaccess.h> 32#include <asm/uaccess.h>
32#include <asm/page.h> 33#include <asm/page.h>
33#include <asm/edac.h> 34#include <asm/edac.h>
diff --git a/drivers/firmware/dell_rbu.c b/drivers/firmware/dell_rbu.c
index 08b161798443..fc702e40bd43 100644
--- a/drivers/firmware/dell_rbu.c
+++ b/drivers/firmware/dell_rbu.c
@@ -705,17 +705,16 @@ static struct bin_attribute rbu_packet_size_attr = {
705 705
706static int __init dcdrbu_init(void) 706static int __init dcdrbu_init(void)
707{ 707{
708 int rc = 0; 708 int rc;
709 spin_lock_init(&rbu_data.lock); 709 spin_lock_init(&rbu_data.lock);
710 710
711 init_packet_head(); 711 init_packet_head();
712 rbu_device = 712 rbu_device = platform_device_register_simple("dell_rbu", -1, NULL, 0);
713 platform_device_register_simple("dell_rbu", -1, NULL, 0); 713 if (IS_ERR(rbu_device)) {
714 if (!rbu_device) {
715 printk(KERN_ERR 714 printk(KERN_ERR
716 "dell_rbu:%s:platform_device_register_simple " 715 "dell_rbu:%s:platform_device_register_simple "
717 "failed\n", __FUNCTION__); 716 "failed\n", __FUNCTION__);
718 return -EIO; 717 return PTR_ERR(rbu_device);
719 } 718 }
720 719
721 rc = sysfs_create_bin_file(&rbu_device->dev.kobj, &rbu_data_attr); 720 rc = sysfs_create_bin_file(&rbu_device->dev.kobj, &rbu_data_attr);
diff --git a/drivers/hwmon/abituguru.c b/drivers/hwmon/abituguru.c
index e5cb0fdab9b1..b1dc63e4ac7b 100644
--- a/drivers/hwmon/abituguru.c
+++ b/drivers/hwmon/abituguru.c
@@ -21,6 +21,7 @@
21 etc voltage & frequency control is not supported! 21 etc voltage & frequency control is not supported!
22*/ 22*/
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/sched.h>
24#include <linux/init.h> 25#include <linux/init.h>
25#include <linux/slab.h> 26#include <linux/slab.h>
26#include <linux/jiffies.h> 27#include <linux/jiffies.h>
diff --git a/drivers/hwmon/hdaps.c b/drivers/hwmon/hdaps.c
index 26be4ea8a38a..e8ef62b83d6b 100644
--- a/drivers/hwmon/hdaps.c
+++ b/drivers/hwmon/hdaps.c
@@ -33,6 +33,7 @@
33#include <linux/module.h> 33#include <linux/module.h>
34#include <linux/timer.h> 34#include <linux/timer.h>
35#include <linux/dmi.h> 35#include <linux/dmi.h>
36#include <linux/jiffies.h>
36#include <asm/io.h> 37#include <asm/io.h>
37 38
38#define HDAPS_LOW_PORT 0x1600 /* first port used by hdaps */ 39#define HDAPS_LOW_PORT 0x1600 /* first port used by hdaps */
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 510816c16da3..90f91d039ee2 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -125,6 +125,7 @@ config I2C_I801
125 ICH7 125 ICH7
126 ESB2 126 ESB2
127 ICH8 127 ICH8
128 ICH9
128 129
129 This driver can also be built as a module. If so, the module 130 This driver can also be built as a module. If so, the module
130 will be called i2c-i801. 131 will be called i2c-i801.
@@ -195,11 +196,11 @@ config I2C_IBM_IIC
195 will be called i2c-ibm_iic. 196 will be called i2c-ibm_iic.
196 197
197config I2C_IOP3XX 198config I2C_IOP3XX
198 tristate "Intel IOP3xx and IXP4xx on-chip I2C interface" 199 tristate "Intel IOPx3xx and IXP4xx on-chip I2C interface"
199 depends on (ARCH_IOP32X || ARCH_IOP33X || ARCH_IXP4XX) && I2C 200 depends on (ARCH_IOP32X || ARCH_IOP33X || ARCH_IXP4XX || ARCH_IOP13XX) && I2C
200 help 201 help
201 Say Y here if you want to use the IIC bus controller on 202 Say Y here if you want to use the IIC bus controller on
202 the Intel IOP3xx I/O Processors or IXP4xx Network Processors. 203 the Intel IOPx3xx I/O Processors or IXP4xx Network Processors.
203 204
204 This driver can also be built as a module. If so, the module 205 This driver can also be built as a module. If so, the module
205 will be called i2c-iop3xx. 206 will be called i2c-iop3xx.
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index bbb2fbee836f..c7be2fdbd86b 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -33,6 +33,7 @@
33 ICH7 27DA 33 ICH7 27DA
34 ESB2 269B 34 ESB2 269B
35 ICH8 283E 35 ICH8 283E
36 ICH9 2930
36 This driver supports several versions of Intel's I/O Controller Hubs (ICH). 37 This driver supports several versions of Intel's I/O Controller Hubs (ICH).
37 For SMBus support, they are similar to the PIIX4 and are part 38 For SMBus support, they are similar to the PIIX4 and are part
38 of Intel's '810' and other chipsets. 39 of Intel's '810' and other chipsets.
@@ -457,6 +458,7 @@ static struct pci_device_id i801_ids[] = {
457 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_17) }, 458 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_17) },
458 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB2_17) }, 459 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB2_17) },
459 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_5) }, 460 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_5) },
461 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH9_6) },
460 { 0, } 462 { 0, }
461}; 463};
462 464
diff --git a/drivers/i2c/busses/i2c-ixp4xx.c b/drivers/i2c/busses/i2c-ixp4xx.c
index 1ce01fb0ac09..68fe863f9d54 100644
--- a/drivers/i2c/busses/i2c-ixp4xx.c
+++ b/drivers/i2c/busses/i2c-ixp4xx.c
@@ -137,7 +137,8 @@ static int ixp4xx_i2c_probe(struct platform_device *plat_dev)
137 gpio_line_set(gpio->scl_pin, 0); 137 gpio_line_set(gpio->scl_pin, 0);
138 gpio_line_set(gpio->sda_pin, 0); 138 gpio_line_set(gpio->sda_pin, 0);
139 139
140 if ((err = i2c_bit_add_bus(&drv_data->adapter) != 0)) { 140 err = i2c_bit_add_bus(&drv_data->adapter);
141 if (err) {
141 printk(KERN_ERR "ERROR: Could not install %s\n", plat_dev->dev.bus_id); 142 printk(KERN_ERR "ERROR: Could not install %s\n", plat_dev->dev.bus_id);
142 143
143 kfree(drv_data); 144 kfree(drv_data);
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index c95a6c154165..c3b1567c852a 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -358,133 +358,6 @@ static void i2c_pxa_reset(struct pxa_i2c *i2c)
358 358
359#ifdef CONFIG_I2C_PXA_SLAVE 359#ifdef CONFIG_I2C_PXA_SLAVE
360/* 360/*
361 * I2C EEPROM emulation.
362 */
363static struct i2c_eeprom_emu eeprom = {
364 .size = I2C_EEPROM_EMU_SIZE,
365 .watch = LIST_HEAD_INIT(eeprom.watch),
366};
367
368struct i2c_eeprom_emu *i2c_pxa_get_eeprom(void)
369{
370 return &eeprom;
371}
372
373int i2c_eeprom_emu_addwatcher(struct i2c_eeprom_emu *emu, void *data,
374 unsigned int addr, unsigned int size,
375 struct i2c_eeprom_emu_watcher *watcher)
376{
377 struct i2c_eeprom_emu_watch *watch;
378 unsigned long flags;
379
380 if (addr + size > emu->size)
381 return -EINVAL;
382
383 watch = kmalloc(sizeof(struct i2c_eeprom_emu_watch), GFP_KERNEL);
384 if (watch) {
385 watch->start = addr;
386 watch->end = addr + size - 1;
387 watch->ops = watcher;
388 watch->data = data;
389
390 local_irq_save(flags);
391 list_add(&watch->node, &emu->watch);
392 local_irq_restore(flags);
393 }
394
395 return watch ? 0 : -ENOMEM;
396}
397
398void i2c_eeprom_emu_delwatcher(struct i2c_eeprom_emu *emu, void *data,
399 struct i2c_eeprom_emu_watcher *watcher)
400{
401 struct i2c_eeprom_emu_watch *watch, *n;
402 unsigned long flags;
403
404 list_for_each_entry_safe(watch, n, &emu->watch, node) {
405 if (watch->ops == watcher && watch->data == data) {
406 local_irq_save(flags);
407 list_del(&watch->node);
408 local_irq_restore(flags);
409 kfree(watch);
410 }
411 }
412}
413
414static void i2c_eeprom_emu_event(void *ptr, i2c_slave_event_t event)
415{
416 struct i2c_eeprom_emu *emu = ptr;
417
418 eedbg(3, "i2c_eeprom_emu_event: %d\n", event);
419
420 switch (event) {
421 case I2C_SLAVE_EVENT_START_WRITE:
422 emu->seen_start = 1;
423 eedbg(2, "i2c_eeprom: write initiated\n");
424 break;
425
426 case I2C_SLAVE_EVENT_START_READ:
427 emu->seen_start = 0;
428 eedbg(2, "i2c_eeprom: read initiated\n");
429 break;
430
431 case I2C_SLAVE_EVENT_STOP:
432 emu->seen_start = 0;
433 eedbg(2, "i2c_eeprom: received stop\n");
434 break;
435
436 default:
437 eedbg(0, "i2c_eeprom: unhandled event\n");
438 break;
439 }
440}
441
442static int i2c_eeprom_emu_read(void *ptr)
443{
444 struct i2c_eeprom_emu *emu = ptr;
445 int ret;
446
447 ret = emu->bytes[emu->ptr];
448 emu->ptr = (emu->ptr + 1) % emu->size;
449
450 return ret;
451}
452
453static void i2c_eeprom_emu_write(void *ptr, unsigned int val)
454{
455 struct i2c_eeprom_emu *emu = ptr;
456 struct i2c_eeprom_emu_watch *watch;
457
458 if (emu->seen_start != 0) {
459 eedbg(2, "i2c_eeprom_emu_write: setting ptr %02x\n", val);
460 emu->ptr = val;
461 emu->seen_start = 0;
462 return;
463 }
464
465 emu->bytes[emu->ptr] = val;
466
467 eedbg(1, "i2c_eeprom_emu_write: ptr=0x%02x, val=0x%02x\n",
468 emu->ptr, val);
469
470 list_for_each_entry(watch, &emu->watch, node) {
471 if (!watch->ops || !watch->ops->write)
472 continue;
473 if (watch->start <= emu->ptr && watch->end >= emu->ptr)
474 watch->ops->write(watch->data, emu->ptr, val);
475 }
476
477 emu->ptr = (emu->ptr + 1) % emu->size;
478}
479
480struct i2c_slave_client eeprom_client = {
481 .data = &eeprom,
482 .event = i2c_eeprom_emu_event,
483 .read = i2c_eeprom_emu_read,
484 .write = i2c_eeprom_emu_write
485};
486
487/*
488 * PXA I2C Slave mode 361 * PXA I2C Slave mode
489 */ 362 */
490 363
@@ -963,11 +836,9 @@ static int i2c_pxa_probe(struct platform_device *dev)
963 i2c->slave_addr = I2C_PXA_SLAVE_ADDR; 836 i2c->slave_addr = I2C_PXA_SLAVE_ADDR;
964 837
965#ifdef CONFIG_I2C_PXA_SLAVE 838#ifdef CONFIG_I2C_PXA_SLAVE
966 i2c->slave = &eeprom_client;
967 if (plat) { 839 if (plat) {
968 i2c->slave_addr = plat->slave_addr; 840 i2c->slave_addr = plat->slave_addr;
969 if (plat->slave) 841 i2c->slave = plat->slave;
970 i2c->slave = plat->slave;
971 } 842 }
972#endif 843#endif
973 844
diff --git a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c
index 32aab0d34ee9..714bae780953 100644
--- a/drivers/i2c/busses/scx200_acb.c
+++ b/drivers/i2c/busses/scx200_acb.c
@@ -494,11 +494,12 @@ static __init int scx200_create_pci(const char *text, struct pci_dev *pdev,
494 iface->pdev = pdev; 494 iface->pdev = pdev;
495 iface->bar = bar; 495 iface->bar = bar;
496 496
497 pci_enable_device_bars(iface->pdev, 1 << iface->bar); 497 rc = pci_enable_device_bars(iface->pdev, 1 << iface->bar);
498 if (rc)
499 goto errout_free;
498 500
499 rc = pci_request_region(iface->pdev, iface->bar, iface->adapter.name); 501 rc = pci_request_region(iface->pdev, iface->bar, iface->adapter.name);
500 502 if (rc) {
501 if (rc != 0) {
502 printk(KERN_ERR NAME ": can't allocate PCI BAR %d\n", 503 printk(KERN_ERR NAME ": can't allocate PCI BAR %d\n",
503 iface->bar); 504 iface->bar);
504 goto errout_free; 505 goto errout_free;
diff --git a/drivers/i2c/chips/ds1374.c b/drivers/i2c/chips/ds1374.c
index 4630f1969a09..15edf40828b4 100644
--- a/drivers/i2c/chips/ds1374.c
+++ b/drivers/i2c/chips/ds1374.c
@@ -140,12 +140,14 @@ ulong ds1374_get_rtc_time(void)
140 return t1; 140 return t1;
141} 141}
142 142
143static void ds1374_set_work(void *arg) 143static ulong new_time;
144
145static void ds1374_set_work(struct work_struct *work)
144{ 146{
145 ulong t1, t2; 147 ulong t1, t2;
146 int limit = 10; /* arbitrary retry limit */ 148 int limit = 10; /* arbitrary retry limit */
147 149
148 t1 = *(ulong *) arg; 150 t1 = new_time;
149 151
150 mutex_lock(&ds1374_mutex); 152 mutex_lock(&ds1374_mutex);
151 153
@@ -167,11 +169,9 @@ static void ds1374_set_work(void *arg)
167 "can't confirm time set from rtc chip\n"); 169 "can't confirm time set from rtc chip\n");
168} 170}
169 171
170static ulong new_time;
171
172static struct workqueue_struct *ds1374_workqueue; 172static struct workqueue_struct *ds1374_workqueue;
173 173
174static DECLARE_WORK(ds1374_work, ds1374_set_work, &new_time); 174static DECLARE_WORK(ds1374_work, ds1374_set_work);
175 175
176int ds1374_set_rtc_time(ulong nowtime) 176int ds1374_set_rtc_time(ulong nowtime)
177{ 177{
@@ -180,7 +180,7 @@ int ds1374_set_rtc_time(ulong nowtime)
180 if (in_interrupt()) 180 if (in_interrupt())
181 queue_work(ds1374_workqueue, &ds1374_work); 181 queue_work(ds1374_workqueue, &ds1374_work);
182 else 182 else
183 ds1374_set_work(&new_time); 183 ds1374_set_work(NULL);
184 184
185 return 0; 185 return 0;
186} 186}
diff --git a/drivers/i2c/chips/m41t00.c b/drivers/i2c/chips/m41t00.c
index 2dd0a34d9472..420377c86422 100644
--- a/drivers/i2c/chips/m41t00.c
+++ b/drivers/i2c/chips/m41t00.c
@@ -215,8 +215,15 @@ m41t00_set(void *arg)
215} 215}
216 216
217static ulong new_time; 217static ulong new_time;
218/* well, isn't this API just _lovely_? */
219static void
220m41t00_barf(struct work_struct *unusable)
221{
222 m41t00_set(&new_time);
223}
224
218static struct workqueue_struct *m41t00_wq; 225static struct workqueue_struct *m41t00_wq;
219static DECLARE_WORK(m41t00_work, m41t00_set, &new_time); 226static DECLARE_WORK(m41t00_work, m41t00_barf);
220 227
221int 228int
222m41t00_set_rtc_time(ulong nowtime) 229m41t00_set_rtc_time(ulong nowtime)
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
index 3f869033ed70..94a4e9a3013c 100644
--- a/drivers/i2c/i2c-dev.c
+++ b/drivers/i2c/i2c-dev.c
@@ -42,7 +42,7 @@ static struct i2c_driver i2cdev_driver;
42struct i2c_dev { 42struct i2c_dev {
43 struct list_head list; 43 struct list_head list;
44 struct i2c_adapter *adap; 44 struct i2c_adapter *adap;
45 struct class_device *class_dev; 45 struct device *dev;
46}; 46};
47 47
48#define I2C_MINORS 256 48#define I2C_MINORS 256
@@ -92,15 +92,16 @@ static void return_i2c_dev(struct i2c_dev *i2c_dev)
92 spin_unlock(&i2c_dev_list_lock); 92 spin_unlock(&i2c_dev_list_lock);
93} 93}
94 94
95static ssize_t show_adapter_name(struct class_device *class_dev, char *buf) 95static ssize_t show_adapter_name(struct device *dev,
96 struct device_attribute *attr, char *buf)
96{ 97{
97 struct i2c_dev *i2c_dev = i2c_dev_get_by_minor(MINOR(class_dev->devt)); 98 struct i2c_dev *i2c_dev = i2c_dev_get_by_minor(MINOR(dev->devt));
98 99
99 if (!i2c_dev) 100 if (!i2c_dev)
100 return -ENODEV; 101 return -ENODEV;
101 return sprintf(buf, "%s\n", i2c_dev->adap->name); 102 return sprintf(buf, "%s\n", i2c_dev->adap->name);
102} 103}
103static CLASS_DEVICE_ATTR(name, S_IRUGO, show_adapter_name, NULL); 104static DEVICE_ATTR(name, S_IRUGO, show_adapter_name, NULL);
104 105
105static ssize_t i2cdev_read (struct file *file, char __user *buf, size_t count, 106static ssize_t i2cdev_read (struct file *file, char __user *buf, size_t count,
106 loff_t *offset) 107 loff_t *offset)
@@ -413,15 +414,14 @@ static int i2cdev_attach_adapter(struct i2c_adapter *adap)
413 return PTR_ERR(i2c_dev); 414 return PTR_ERR(i2c_dev);
414 415
415 /* register this i2c device with the driver core */ 416 /* register this i2c device with the driver core */
416 i2c_dev->class_dev = class_device_create(i2c_dev_class, NULL, 417 i2c_dev->dev = device_create(i2c_dev_class, &adap->dev,
417 MKDEV(I2C_MAJOR, adap->nr), 418 MKDEV(I2C_MAJOR, adap->nr),
418 &adap->dev, "i2c-%d", 419 "i2c-%d", adap->nr);
419 adap->nr); 420 if (!i2c_dev->dev) {
420 if (!i2c_dev->class_dev) {
421 res = -ENODEV; 421 res = -ENODEV;
422 goto error; 422 goto error;
423 } 423 }
424 res = class_device_create_file(i2c_dev->class_dev, &class_device_attr_name); 424 res = device_create_file(i2c_dev->dev, &dev_attr_name);
425 if (res) 425 if (res)
426 goto error_destroy; 426 goto error_destroy;
427 427
@@ -429,7 +429,7 @@ static int i2cdev_attach_adapter(struct i2c_adapter *adap)
429 adap->name, adap->nr); 429 adap->name, adap->nr);
430 return 0; 430 return 0;
431error_destroy: 431error_destroy:
432 class_device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr)); 432 device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr));
433error: 433error:
434 return_i2c_dev(i2c_dev); 434 return_i2c_dev(i2c_dev);
435 kfree(i2c_dev); 435 kfree(i2c_dev);
@@ -444,9 +444,9 @@ static int i2cdev_detach_adapter(struct i2c_adapter *adap)
444 if (!i2c_dev) /* attach_adapter must have failed */ 444 if (!i2c_dev) /* attach_adapter must have failed */
445 return 0; 445 return 0;
446 446
447 class_device_remove_file(i2c_dev->class_dev, &class_device_attr_name); 447 device_remove_file(i2c_dev->dev, &dev_attr_name);
448 return_i2c_dev(i2c_dev); 448 return_i2c_dev(i2c_dev);
449 class_device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr)); 449 device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr));
450 kfree(i2c_dev); 450 kfree(i2c_dev);
451 451
452 pr_debug("i2c-dev: adapter [%s] unregistered\n", adap->name); 452 pr_debug("i2c-dev: adapter [%s] unregistered\n", adap->name);
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index 0c68d0f0d8e5..e23bc0d62159 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -389,14 +389,6 @@ config BLK_DEV_RZ1000
389 Linux. This may slow disk throughput by a few percent, but at least 389 Linux. This may slow disk throughput by a few percent, but at least
390 things will operate 100% reliably. 390 things will operate 100% reliably.
391 391
392config BLK_DEV_SL82C105
393 tristate "Winbond SL82c105 support"
394 depends on PCI && (PPC || ARM) && BLK_DEV_IDEPCI
395 help
396 If you have a Winbond SL82c105 IDE controller, say Y here to enable
397 special configuration for this chip. This is common on various CHRP
398 motherboards, but could be used elsewhere. If in doubt, say Y.
399
400config BLK_DEV_IDEDMA_PCI 392config BLK_DEV_IDEDMA_PCI
401 bool "Generic PCI bus-master DMA support" 393 bool "Generic PCI bus-master DMA support"
402 depends on PCI && BLK_DEV_IDEPCI 394 depends on PCI && BLK_DEV_IDEPCI
@@ -712,6 +704,14 @@ config BLK_DEV_SIS5513
712 704
713 Please read the comments at the top of <file:drivers/ide/pci/sis5513.c>. 705 Please read the comments at the top of <file:drivers/ide/pci/sis5513.c>.
714 706
707config BLK_DEV_SL82C105
708 tristate "Winbond SL82c105 support"
709 depends on (PPC || ARM)
710 help
711 If you have a Winbond SL82c105 IDE controller, say Y here to enable
712 special configuration for this chip. This is common on various CHRP
713 motherboards, but could be used elsewhere. If in doubt, say Y.
714
715config BLK_DEV_SLC90E66 715config BLK_DEV_SLC90E66
716 tristate "SLC90E66 chipset support" 716 tristate "SLC90E66 chipset support"
717 help 717 help
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index bddfebdf91d8..88214943d00a 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -724,7 +724,7 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
724 * if we have an error, pass back CHECK_CONDITION as the 724 * if we have an error, pass back CHECK_CONDITION as the
725 * scsi status byte 725 * scsi status byte
726 */ 726 */
727 if (!rq->errors) 727 if (blk_pc_request(rq) && !rq->errors)
728 rq->errors = SAM_STAT_CHECK_CONDITION; 728 rq->errors = SAM_STAT_CHECK_CONDITION;
729 729
730 /* Check for tray open. */ 730 /* Check for tray open. */
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 8ccee9c769f8..e3a267622bb6 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -1635,7 +1635,7 @@ static int idefloppy_begin_format(ide_drive_t *drive, int __user *arg)
1635/* 1635/*
1636** Get ATAPI_FORMAT_UNIT progress indication. 1636** Get ATAPI_FORMAT_UNIT progress indication.
1637** 1637**
1638** Userland gives a pointer to an int. The int is set to a progresss 1638** Userland gives a pointer to an int. The int is set to a progress
1639** indicator 0-65536, with 65536=100%. 1639** indicator 0-65536, with 65536=100%.
1640** 1640**
1641** If the drive does not support format progress indication, we just check 1641** If the drive does not support format progress indication, we just check
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 287a66201150..16890769dca6 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -973,8 +973,8 @@ ide_settings_t *ide_find_setting_by_name (ide_drive_t *drive, char *name)
973 * @drive: drive 973 * @drive: drive
974 * 974 *
975 * Automatically remove all the driver specific settings for this 975 * Automatically remove all the driver specific settings for this
976 * drive. This function may sleep and must not be called from IRQ 976 * drive. This function may not be called from IRQ context. The
977 * context. The caller must hold ide_setting_sem. 977 * caller must hold ide_setting_sem.
978 */ 978 */
979 979
980static void auto_remove_settings (ide_drive_t *drive) 980static void auto_remove_settings (ide_drive_t *drive)
@@ -1874,11 +1874,22 @@ void ide_unregister_subdriver(ide_drive_t *drive, ide_driver_t *driver)
1874{ 1874{
1875 unsigned long flags; 1875 unsigned long flags;
1876 1876
1877 down(&ide_setting_sem);
1878 spin_lock_irqsave(&ide_lock, flags);
1879#ifdef CONFIG_PROC_FS 1877#ifdef CONFIG_PROC_FS
1880 ide_remove_proc_entries(drive->proc, driver->proc); 1878 ide_remove_proc_entries(drive->proc, driver->proc);
1881#endif 1879#endif
1880 down(&ide_setting_sem);
1881 spin_lock_irqsave(&ide_lock, flags);
1882 /*
1883 * ide_setting_sem protects the settings list
1884 * ide_lock protects the use of settings
1885 *
1886 * so we need to hold both, ide_settings_sem because we want to
1887 * modify the settings list, and ide_lock because we cannot take
1888 * a setting out that is being used.
1889 *
1890 * OTOH both ide_{read,write}_setting are only ever used under
1891 * ide_setting_sem.
1892 */
1882 auto_remove_settings(drive); 1893 auto_remove_settings(drive);
1883 spin_unlock_irqrestore(&ide_lock, flags); 1894 spin_unlock_irqrestore(&ide_lock, flags);
1884 up(&ide_setting_sem); 1895 up(&ide_setting_sem);
diff --git a/drivers/ide/legacy/hd.c b/drivers/ide/legacy/hd.c
index b1d5291531b7..45ed03591cd8 100644
--- a/drivers/ide/legacy/hd.c
+++ b/drivers/ide/legacy/hd.c
@@ -459,7 +459,7 @@ ok_to_read:
459#ifdef DEBUG 459#ifdef DEBUG
460 printk("%s: read: sector %ld, remaining = %ld, buffer=%p\n", 460 printk("%s: read: sector %ld, remaining = %ld, buffer=%p\n",
461 req->rq_disk->disk_name, req->sector, req->nr_sectors, 461 req->rq_disk->disk_name, req->sector, req->nr_sectors,
462 req->buffer+512)); 462 req->buffer+512);
463#endif 463#endif
464 if (req->current_nr_sectors <= 0) 464 if (req->current_nr_sectors <= 0)
465 end_request(req, 1); 465 end_request(req, 1);
diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c
index bef4759f70e5..7efd28ac21ed 100644
--- a/drivers/ide/legacy/ide-cs.c
+++ b/drivers/ide/legacy/ide-cs.c
@@ -192,20 +192,10 @@ static int ide_config(struct pcmcia_device *link)
192 tuple.TupleOffset = 0; 192 tuple.TupleOffset = 0;
193 tuple.TupleDataMax = 255; 193 tuple.TupleDataMax = 255;
194 tuple.Attributes = 0; 194 tuple.Attributes = 0;
195 tuple.DesiredTuple = CISTPL_CONFIG; 195
196 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 196 is_kme = ((link->manf_id == MANFID_KME) &&
197 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 197 ((link->card_id == PRODID_KME_KXLC005_A) ||
198 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &stk->parse)); 198 (link->card_id == PRODID_KME_KXLC005_B)));
199 link->conf.ConfigBase = stk->parse.config.base;
200 link->conf.Present = stk->parse.config.rmask[0];
201
202 tuple.DesiredTuple = CISTPL_MANFID;
203 if (!pcmcia_get_first_tuple(link, &tuple) &&
204 !pcmcia_get_tuple_data(link, &tuple) &&
205 !pcmcia_parse_tuple(link, &tuple, &stk->parse))
206 is_kme = ((stk->parse.manfid.manf == MANFID_KME) &&
207 ((stk->parse.manfid.card == PRODID_KME_KXLC005_A) ||
208 (stk->parse.manfid.card == PRODID_KME_KXLC005_B)));
209 199
210 /* Not sure if this is right... look up the current Vcc */ 200 /* Not sure if this is right... look up the current Vcc */
211 CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link, &stk->conf)); 201 CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link, &stk->conf));
@@ -408,8 +398,10 @@ static struct pcmcia_device_id ide_ids[] = {
408 PCMCIA_DEVICE_PROD_ID12("SMI VENDOR", "SMI PRODUCT", 0x30896c92, 0x703cc5f6), 398 PCMCIA_DEVICE_PROD_ID12("SMI VENDOR", "SMI PRODUCT", 0x30896c92, 0x703cc5f6),
409 PCMCIA_DEVICE_PROD_ID12("TOSHIBA", "MK2001MPL", 0xb4585a1a, 0x3489e003), 399 PCMCIA_DEVICE_PROD_ID12("TOSHIBA", "MK2001MPL", 0xb4585a1a, 0x3489e003),
410 PCMCIA_DEVICE_PROD_ID1("TRANSCEND 512M ", 0xd0909443), 400 PCMCIA_DEVICE_PROD_ID1("TRANSCEND 512M ", 0xd0909443),
401 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS1GCF80", 0x709b1bf1, 0x2a54d4b1),
411 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS4GCF120", 0x709b1bf1, 0xf54a91c8), 402 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS4GCF120", 0x709b1bf1, 0xf54a91c8),
412 PCMCIA_DEVICE_PROD_ID12("WIT", "IDE16", 0x244e5994, 0x3e232852), 403 PCMCIA_DEVICE_PROD_ID12("WIT", "IDE16", 0x244e5994, 0x3e232852),
404 PCMCIA_DEVICE_PROD_ID12("WEIDA", "TWTTI", 0xcc7cf69c, 0x212bb918),
413 PCMCIA_DEVICE_PROD_ID1("STI Flash", 0xe4a13209), 405 PCMCIA_DEVICE_PROD_ID1("STI Flash", 0xe4a13209),
414 PCMCIA_DEVICE_PROD_ID12("STI", "Flash 5.0", 0xbf2df18d, 0x8cb57a0e), 406 PCMCIA_DEVICE_PROD_ID12("STI", "Flash 5.0", 0xbf2df18d, 0x8cb57a0e),
415 PCMCIA_MFC_DEVICE_PROD_ID12(1, "SanDisk", "ConnectPlus", 0x7a954bd9, 0x74be00c6), 407 PCMCIA_MFC_DEVICE_PROD_ID12(1, "SanDisk", "ConnectPlus", 0x7a954bd9, 0x74be00c6),
diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c
index 244f7eb7006d..cfad09accf52 100644
--- a/drivers/ide/pci/sgiioc4.c
+++ b/drivers/ide/pci/sgiioc4.c
@@ -768,14 +768,7 @@ ioc4_ide_init(void)
768 return ioc4_register_submodule(&ioc4_ide_submodule); 768 return ioc4_register_submodule(&ioc4_ide_submodule);
769} 769}
770 770
771static void __devexit
772ioc4_ide_exit(void)
773{
774 ioc4_unregister_submodule(&ioc4_ide_submodule);
775}
776
777late_initcall(ioc4_ide_init); /* Call only after IDE init is done */ 771late_initcall(ioc4_ide_init); /* Call only after IDE init is done */
778module_exit(ioc4_ide_exit);
779 772
780MODULE_AUTHOR("Aniket Malatpure/Jeremy Higdon"); 773MODULE_AUTHOR("Aniket Malatpure/Jeremy Higdon");
781MODULE_DESCRIPTION("IDE PCI driver module for SGI IOC4 Base-IO Card"); 774MODULE_DESCRIPTION("IDE PCI driver module for SGI IOC4 Base-IO Card");
diff --git a/drivers/ide/pci/via82cxxx.c b/drivers/ide/pci/via82cxxx.c
index 2af634d7acf4..61f1a9665a7f 100644
--- a/drivers/ide/pci/via82cxxx.c
+++ b/drivers/ide/pci/via82cxxx.c
@@ -35,7 +35,7 @@
35#include <linux/ide.h> 35#include <linux/ide.h>
36#include <asm/io.h> 36#include <asm/io.h>
37 37
38#ifdef CONFIG_PPC_MULTIPLATFORM 38#ifdef CONFIG_PPC_CHRP
39#include <asm/processor.h> 39#include <asm/processor.h>
40#endif 40#endif
41 41
@@ -282,11 +282,11 @@ static unsigned int __devinit init_chipset_via82cxxx(struct pci_dev *dev, const
282 * Find the ISA bridge to see how good the IDE is. 282 * Find the ISA bridge to see how good the IDE is.
283 */ 283 */
284 via_config = via_config_find(&isa); 284 via_config = via_config_find(&isa);
285 if (!via_config->id) { 285
286 printk(KERN_WARNING "VP_IDE: Unknown VIA SouthBridge, disabling DMA.\n"); 286 /* We checked this earlier so if it fails here deeep badness
287 pci_dev_put(isa); 287 is involved */
288 return -ENODEV; 288
289 } 289 BUG_ON(!via_config->id);
290 290
291 /* 291 /*
292 * Setup or disable Clk66 if appropriate 292 * Setup or disable Clk66 if appropriate
@@ -442,7 +442,7 @@ static void __devinit init_hwif_via82cxxx(ide_hwif_t *hwif)
442 hwif->speedproc = &via_set_drive; 442 hwif->speedproc = &via_set_drive;
443 443
444 444
445#if defined(CONFIG_PPC_CHRP) && defined(CONFIG_PPC32) 445#ifdef CONFIG_PPC_CHRP
446 if(machine_is(chrp) && _chrp_type == _CHRP_Pegasos) { 446 if(machine_is(chrp) && _chrp_type == _CHRP_Pegasos) {
447 hwif->irq = hwif->channel ? 15 : 14; 447 hwif->irq = hwif->channel ? 15 : 14;
448 } 448 }
@@ -494,6 +494,17 @@ static ide_pci_device_t via82cxxx_chipsets[] __devinitdata = {
494 494
495static int __devinit via_init_one(struct pci_dev *dev, const struct pci_device_id *id) 495static int __devinit via_init_one(struct pci_dev *dev, const struct pci_device_id *id)
496{ 496{
497 struct pci_dev *isa = NULL;
498 struct via_isa_bridge *via_config;
499 /*
500 * Find the ISA bridge and check we know what it is.
501 */
502 via_config = via_config_find(&isa);
503 pci_dev_put(isa);
504 if (!via_config->id) {
505 printk(KERN_WARNING "VP_IDE: Unknown VIA SouthBridge, disabling DMA.\n");
506 return -ENODEV;
507 }
497 return ide_setup_pci_device(dev, &via82cxxx_chipsets[id->driver_data]); 508 return ide_setup_pci_device(dev, &via82cxxx_chipsets[id->driver_data]);
498} 509}
499 510
diff --git a/drivers/ieee1394/Kconfig b/drivers/ieee1394/Kconfig
index 672b92ef9f21..e7d56573fe56 100644
--- a/drivers/ieee1394/Kconfig
+++ b/drivers/ieee1394/Kconfig
@@ -36,7 +36,7 @@ config IEEE1394_VERBOSEDEBUG
36 else says N. 36 else says N.
37 37
38config IEEE1394_OUI_DB 38config IEEE1394_OUI_DB
39 bool "OUI Database built-in" 39 bool "OUI Database built-in (deprecated)"
40 depends on IEEE1394 40 depends on IEEE1394
41 help 41 help
42 If you say Y here, then an OUI list (vendor unique ID's) will be 42 If you say Y here, then an OUI list (vendor unique ID's) will be
@@ -67,16 +67,11 @@ config IEEE1394_CONFIG_ROM_IP1394
67 eth1394 option below. 67 eth1394 option below.
68 68
69config IEEE1394_EXPORT_FULL_API 69config IEEE1394_EXPORT_FULL_API
70 bool "Export all symbols of ieee1394's API" 70 bool "Export all symbols of ieee1394's API (deprecated)"
71 depends on IEEE1394 71 depends on IEEE1394
72 default n 72 default n
73 help 73 help
74 Export all symbols of ieee1394's driver programming interface, even 74 This option will be removed soon. Don't worry, say N.
75 those that are not currently used by the standard IEEE 1394 drivers.
76
77 This option does not affect the interface to userspace applications.
78 Say Y here if you want to compile externally developed drivers that
79 make extended use of ieee1394's API. It is otherwise safe to say N.
80 75
81comment "Device Drivers" 76comment "Device Drivers"
82 depends on IEEE1394 77 depends on IEEE1394
@@ -125,7 +120,7 @@ comment "SBP-2 support (for storage devices) requires SCSI"
125 120
126config IEEE1394_SBP2 121config IEEE1394_SBP2
127 tristate "SBP-2 support (Harddisks etc.)" 122 tristate "SBP-2 support (Harddisks etc.)"
128 depends on IEEE1394 && SCSI && (PCI || BROKEN) 123 depends on IEEE1394 && SCSI
129 help 124 help
130 This option enables you to use SBP-2 devices connected to an IEEE 125 This option enables you to use SBP-2 devices connected to an IEEE
131 1394 bus. SBP-2 devices include storage devices like harddisks and 126 1394 bus. SBP-2 devices include storage devices like harddisks and
@@ -161,17 +156,12 @@ config IEEE1394_ETH1394
161 MCAP, therefore multicast support is significantly limited. 156 MCAP, therefore multicast support is significantly limited.
162 157
163config IEEE1394_DV1394 158config IEEE1394_DV1394
164 tristate "OHCI-DV I/O support" 159 tristate "OHCI-DV I/O support (deprecated)"
165 depends on IEEE1394 && IEEE1394_OHCI1394 160 depends on IEEE1394 && IEEE1394_OHCI1394
166 help 161 help
167 This driver allows you to transmit and receive DV (digital video) 162 The dv1394 driver will be removed from Linux in a future release.
168 streams on an OHCI-1394 card using a simple frame-oriented 163 Its functionality is now provided by raw1394 together with libraries
169 interface. 164 such as libiec61883.
170
171 The user-space API for dv1394 is documented in dv1394.h.
172
173 To compile this driver as a module, say M here: the
174 module will be called dv1394.
175 165
176config IEEE1394_RAWIO 166config IEEE1394_RAWIO
177 tristate "Raw IEEE1394 I/O support" 167 tristate "Raw IEEE1394 I/O support"
diff --git a/drivers/ieee1394/Makefile b/drivers/ieee1394/Makefile
index 6f53611fe255..d9650d3d77a0 100644
--- a/drivers/ieee1394/Makefile
+++ b/drivers/ieee1394/Makefile
@@ -3,8 +3,11 @@
3# 3#
4 4
5ieee1394-objs := ieee1394_core.o ieee1394_transactions.o hosts.o \ 5ieee1394-objs := ieee1394_core.o ieee1394_transactions.o hosts.o \
6 highlevel.o csr.o nodemgr.o oui.o dma.o iso.o \ 6 highlevel.o csr.o nodemgr.o dma.o iso.o \
7 csr1212.o config_roms.o 7 csr1212.o config_roms.o
8ifdef CONFIG_IEEE1394_OUI_DB
9ieee1394-objs += oui.o
10endif
8 11
9obj-$(CONFIG_IEEE1394) += ieee1394.o 12obj-$(CONFIG_IEEE1394) += ieee1394.o
10obj-$(CONFIG_IEEE1394_PCILYNX) += pcilynx.o 13obj-$(CONFIG_IEEE1394_PCILYNX) += pcilynx.o
diff --git a/drivers/ieee1394/csr.c b/drivers/ieee1394/csr.c
index ab0c80f61b9d..52ac83e0ebee 100644
--- a/drivers/ieee1394/csr.c
+++ b/drivers/ieee1394/csr.c
@@ -158,12 +158,10 @@ static void host_reset(struct hpsb_host *host)
158 */ 158 */
159static inline void calculate_expire(struct csr_control *csr) 159static inline void calculate_expire(struct csr_control *csr)
160{ 160{
161 unsigned long usecs = 161 unsigned int usecs = (csr->split_timeout_hi & 7) * 1000000 +
162 (csr->split_timeout_hi & 0x07) * USEC_PER_SEC + 162 (csr->split_timeout_lo >> 19) * 125;
163 (csr->split_timeout_lo >> 19) * 125L;
164
165 csr->expire = usecs_to_jiffies(usecs > 100000L ? usecs : 100000L);
166 163
164 csr->expire = usecs_to_jiffies(usecs > 100000 ? usecs : 100000);
167 HPSB_VERBOSE("CSR: setting expire to %lu, HZ=%u", csr->expire, HZ); 165 HPSB_VERBOSE("CSR: setting expire to %lu, HZ=%u", csr->expire, HZ);
168} 166}
169 167
diff --git a/drivers/ieee1394/dv1394.c b/drivers/ieee1394/dv1394.c
index 6c72f04b2b5d..1084da4d88a9 100644
--- a/drivers/ieee1394/dv1394.c
+++ b/drivers/ieee1394/dv1394.c
@@ -1536,27 +1536,20 @@ static ssize_t dv1394_read(struct file *file, char __user *buffer, size_t count
1536 1536
1537static long dv1394_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 1537static long dv1394_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
1538{ 1538{
1539 struct video_card *video; 1539 struct video_card *video = file_to_video_card(file);
1540 unsigned long flags; 1540 unsigned long flags;
1541 int ret = -EINVAL; 1541 int ret = -EINVAL;
1542 void __user *argp = (void __user *)arg; 1542 void __user *argp = (void __user *)arg;
1543 1543
1544 DECLARE_WAITQUEUE(wait, current); 1544 DECLARE_WAITQUEUE(wait, current);
1545 1545
1546 lock_kernel();
1547 video = file_to_video_card(file);
1548
1549 /* serialize this to prevent multi-threaded mayhem */ 1546 /* serialize this to prevent multi-threaded mayhem */
1550 if (file->f_flags & O_NONBLOCK) { 1547 if (file->f_flags & O_NONBLOCK) {
1551 if (!mutex_trylock(&video->mtx)) { 1548 if (!mutex_trylock(&video->mtx))
1552 unlock_kernel();
1553 return -EAGAIN; 1549 return -EAGAIN;
1554 }
1555 } else { 1550 } else {
1556 if (mutex_lock_interruptible(&video->mtx)) { 1551 if (mutex_lock_interruptible(&video->mtx))
1557 unlock_kernel();
1558 return -ERESTARTSYS; 1552 return -ERESTARTSYS;
1559 }
1560 } 1553 }
1561 1554
1562 switch(cmd) 1555 switch(cmd)
@@ -1780,7 +1773,6 @@ static long dv1394_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
1780 1773
1781 out: 1774 out:
1782 mutex_unlock(&video->mtx); 1775 mutex_unlock(&video->mtx);
1783 unlock_kernel();
1784 return ret; 1776 return ret;
1785} 1777}
1786 1778
@@ -2188,12 +2180,8 @@ static struct ieee1394_device_id dv1394_id_table[] = {
2188MODULE_DEVICE_TABLE(ieee1394, dv1394_id_table); 2180MODULE_DEVICE_TABLE(ieee1394, dv1394_id_table);
2189 2181
2190static struct hpsb_protocol_driver dv1394_driver = { 2182static struct hpsb_protocol_driver dv1394_driver = {
2191 .name = "DV/1394 Driver", 2183 .name = "dv1394",
2192 .id_table = dv1394_id_table, 2184 .id_table = dv1394_id_table,
2193 .driver = {
2194 .name = "dv1394",
2195 .bus = &ieee1394_bus_type,
2196 },
2197}; 2185};
2198 2186
2199 2187
@@ -2587,6 +2575,10 @@ static int __init dv1394_init_module(void)
2587{ 2575{
2588 int ret; 2576 int ret;
2589 2577
2578 printk(KERN_WARNING
2579 "WARNING: The dv1394 driver is unsupported and will be removed "
2580 "from Linux soon. Use raw1394 instead.\n");
2581
2590 cdev_init(&dv1394_cdev, &dv1394_fops); 2582 cdev_init(&dv1394_cdev, &dv1394_fops);
2591 dv1394_cdev.owner = THIS_MODULE; 2583 dv1394_cdev.owner = THIS_MODULE;
2592 kobject_set_name(&dv1394_cdev.kobj, "dv1394"); 2584 kobject_set_name(&dv1394_cdev.kobj, "dv1394");
diff --git a/drivers/ieee1394/eth1394.c b/drivers/ieee1394/eth1394.c
index 31e5cc49d61a..97e5c3dd044d 100644
--- a/drivers/ieee1394/eth1394.c
+++ b/drivers/ieee1394/eth1394.c
@@ -133,7 +133,7 @@ struct eth1394_node_info {
133#define ETH1394_DRIVER_NAME "eth1394" 133#define ETH1394_DRIVER_NAME "eth1394"
134static const char driver_name[] = ETH1394_DRIVER_NAME; 134static const char driver_name[] = ETH1394_DRIVER_NAME;
135 135
136static kmem_cache_t *packet_task_cache; 136static struct kmem_cache *packet_task_cache;
137 137
138static struct hpsb_highlevel eth1394_highlevel; 138static struct hpsb_highlevel eth1394_highlevel;
139 139
@@ -474,12 +474,10 @@ static struct ieee1394_device_id eth1394_id_table[] = {
474MODULE_DEVICE_TABLE(ieee1394, eth1394_id_table); 474MODULE_DEVICE_TABLE(ieee1394, eth1394_id_table);
475 475
476static struct hpsb_protocol_driver eth1394_proto_driver = { 476static struct hpsb_protocol_driver eth1394_proto_driver = {
477 .name = "IPv4 over 1394 Driver", 477 .name = ETH1394_DRIVER_NAME,
478 .id_table = eth1394_id_table, 478 .id_table = eth1394_id_table,
479 .update = eth1394_update, 479 .update = eth1394_update,
480 .driver = { 480 .driver = {
481 .name = ETH1394_DRIVER_NAME,
482 .bus = &ieee1394_bus_type,
483 .probe = eth1394_probe, 481 .probe = eth1394_probe,
484 .remove = eth1394_remove, 482 .remove = eth1394_remove,
485 }, 483 },
diff --git a/drivers/ieee1394/highlevel.h b/drivers/ieee1394/highlevel.h
index 50f2dd2c7e20..4b330117067a 100644
--- a/drivers/ieee1394/highlevel.h
+++ b/drivers/ieee1394/highlevel.h
@@ -24,7 +24,6 @@ struct hpsb_address_serve {
24/* Only the following structures are of interest to actual highlevel drivers. */ 24/* Only the following structures are of interest to actual highlevel drivers. */
25 25
26struct hpsb_highlevel { 26struct hpsb_highlevel {
27 struct module *owner;
28 const char *name; 27 const char *name;
29 28
30 /* Any of the following pointers can legally be NULL, except for 29 /* Any of the following pointers can legally be NULL, except for
diff --git a/drivers/ieee1394/hosts.c b/drivers/ieee1394/hosts.c
index d90a3a1898c0..ee82a5320bf7 100644
--- a/drivers/ieee1394/hosts.c
+++ b/drivers/ieee1394/hosts.c
@@ -31,9 +31,10 @@
31#include "config_roms.h" 31#include "config_roms.h"
32 32
33 33
34static void delayed_reset_bus(void * __reset_info) 34static void delayed_reset_bus(struct work_struct *work)
35{ 35{
36 struct hpsb_host *host = (struct hpsb_host*)__reset_info; 36 struct hpsb_host *host =
37 container_of(work, struct hpsb_host, delayed_reset.work);
37 int generation = host->csr.generation + 1; 38 int generation = host->csr.generation + 1;
38 39
39 /* The generation field rolls over to 2 rather than 0 per IEEE 40 /* The generation field rolls over to 2 rather than 0 per IEEE
@@ -43,9 +44,10 @@ static void delayed_reset_bus(void * __reset_info)
43 44
44 CSR_SET_BUS_INFO_GENERATION(host->csr.rom, generation); 45 CSR_SET_BUS_INFO_GENERATION(host->csr.rom, generation);
45 if (csr1212_generate_csr_image(host->csr.rom) != CSR1212_SUCCESS) { 46 if (csr1212_generate_csr_image(host->csr.rom) != CSR1212_SUCCESS) {
46 /* CSR image creation failed, reset generation field and do not 47 /* CSR image creation failed.
47 * issue a bus reset. */ 48 * Reset generation field and do not issue a bus reset. */
48 CSR_SET_BUS_INFO_GENERATION(host->csr.rom, host->csr.generation); 49 CSR_SET_BUS_INFO_GENERATION(host->csr.rom,
50 host->csr.generation);
49 return; 51 return;
50 } 52 }
51 53
@@ -53,7 +55,8 @@ static void delayed_reset_bus(void * __reset_info)
53 55
54 host->update_config_rom = 0; 56 host->update_config_rom = 0;
55 if (host->driver->set_hw_config_rom) 57 if (host->driver->set_hw_config_rom)
56 host->driver->set_hw_config_rom(host, host->csr.rom->bus_info_data); 58 host->driver->set_hw_config_rom(host,
59 host->csr.rom->bus_info_data);
57 60
58 host->csr.gen_timestamp[host->csr.generation] = jiffies; 61 host->csr.gen_timestamp[host->csr.generation] = jiffies;
59 hpsb_reset_bus(host, SHORT_RESET); 62 hpsb_reset_bus(host, SHORT_RESET);
@@ -69,7 +72,8 @@ static int dummy_devctl(struct hpsb_host *h, enum devctl_cmd c, int arg)
69 return -1; 72 return -1;
70} 73}
71 74
72static int dummy_isoctl(struct hpsb_iso *iso, enum isoctl_cmd command, unsigned long arg) 75static int dummy_isoctl(struct hpsb_iso *iso, enum isoctl_cmd command,
76 unsigned long arg)
73{ 77{
74 return -1; 78 return -1;
75} 79}
@@ -122,15 +126,13 @@ struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra,
122 int i; 126 int i;
123 int hostnum = 0; 127 int hostnum = 0;
124 128
125 h = kzalloc(sizeof(*h) + extra, SLAB_KERNEL); 129 h = kzalloc(sizeof(*h) + extra, GFP_KERNEL);
126 if (!h) 130 if (!h)
127 return NULL; 131 return NULL;
128 132
129 h->csr.rom = csr1212_create_csr(&csr_bus_ops, CSR_BUS_INFO_SIZE, h); 133 h->csr.rom = csr1212_create_csr(&csr_bus_ops, CSR_BUS_INFO_SIZE, h);
130 if (!h->csr.rom) { 134 if (!h->csr.rom)
131 kfree(h); 135 goto fail;
132 return NULL;
133 }
134 136
135 h->hostdata = h + 1; 137 h->hostdata = h + 1;
136 h->driver = drv; 138 h->driver = drv;
@@ -145,21 +147,20 @@ struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra,
145 147
146 atomic_set(&h->generation, 0); 148 atomic_set(&h->generation, 0);
147 149
148 INIT_WORK(&h->delayed_reset, delayed_reset_bus, h); 150 INIT_DELAYED_WORK(&h->delayed_reset, delayed_reset_bus);
149 151
150 init_timer(&h->timeout); 152 init_timer(&h->timeout);
151 h->timeout.data = (unsigned long) h; 153 h->timeout.data = (unsigned long) h;
152 h->timeout.function = abort_timedouts; 154 h->timeout.function = abort_timedouts;
153 h->timeout_interval = HZ / 20; // 50ms by default 155 h->timeout_interval = HZ / 20; /* 50ms, half of minimum SPLIT_TIMEOUT */
154 156
155 h->topology_map = h->csr.topology_map + 3; 157 h->topology_map = h->csr.topology_map + 3;
156 h->speed_map = (u8 *)(h->csr.speed_map + 2); 158 h->speed_map = (u8 *)(h->csr.speed_map + 2);
157 159
158 mutex_lock(&host_num_alloc); 160 mutex_lock(&host_num_alloc);
159
160 while (nodemgr_for_each_host(&hostnum, alloc_hostnum_cb)) 161 while (nodemgr_for_each_host(&hostnum, alloc_hostnum_cb))
161 hostnum++; 162 hostnum++;
162 163 mutex_unlock(&host_num_alloc);
163 h->id = hostnum; 164 h->id = hostnum;
164 165
165 memcpy(&h->device, &nodemgr_dev_template_host, sizeof(h->device)); 166 memcpy(&h->device, &nodemgr_dev_template_host, sizeof(h->device));
@@ -170,13 +171,19 @@ struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra,
170 h->class_dev.class = &hpsb_host_class; 171 h->class_dev.class = &hpsb_host_class;
171 snprintf(h->class_dev.class_id, BUS_ID_SIZE, "fw-host%d", h->id); 172 snprintf(h->class_dev.class_id, BUS_ID_SIZE, "fw-host%d", h->id);
172 173
173 device_register(&h->device); 174 if (device_register(&h->device))
174 class_device_register(&h->class_dev); 175 goto fail;
176 if (class_device_register(&h->class_dev)) {
177 device_unregister(&h->device);
178 goto fail;
179 }
175 get_device(&h->device); 180 get_device(&h->device);
176 181
177 mutex_unlock(&host_num_alloc);
178
179 return h; 182 return h;
183
184fail:
185 kfree(h);
186 return NULL;
180} 187}
181 188
182int hpsb_add_host(struct hpsb_host *host) 189int hpsb_add_host(struct hpsb_host *host)
@@ -228,13 +235,14 @@ int hpsb_update_config_rom_image(struct hpsb_host *host)
228 if (time_before(jiffies, host->csr.gen_timestamp[next_gen] + 60 * HZ)) 235 if (time_before(jiffies, host->csr.gen_timestamp[next_gen] + 60 * HZ))
229 /* Wait 60 seconds from the last time this generation number was 236 /* Wait 60 seconds from the last time this generation number was
230 * used. */ 237 * used. */
231 reset_delay = (60 * HZ) + host->csr.gen_timestamp[next_gen] - jiffies; 238 reset_delay =
239 (60 * HZ) + host->csr.gen_timestamp[next_gen] - jiffies;
232 else 240 else
233 /* Wait 1 second in case some other code wants to change the 241 /* Wait 1 second in case some other code wants to change the
234 * Config ROM in the near future. */ 242 * Config ROM in the near future. */
235 reset_delay = HZ; 243 reset_delay = HZ;
236 244
237 PREPARE_WORK(&host->delayed_reset, delayed_reset_bus, host); 245 PREPARE_DELAYED_WORK(&host->delayed_reset, delayed_reset_bus);
238 schedule_delayed_work(&host->delayed_reset, reset_delay); 246 schedule_delayed_work(&host->delayed_reset, reset_delay);
239 247
240 return 0; 248 return 0;
diff --git a/drivers/ieee1394/hosts.h b/drivers/ieee1394/hosts.h
index bc6dbfadb891..d553e38c9543 100644
--- a/drivers/ieee1394/hosts.h
+++ b/drivers/ieee1394/hosts.h
@@ -62,7 +62,7 @@ struct hpsb_host {
62 struct class_device class_dev; 62 struct class_device class_dev;
63 63
64 int update_config_rom; 64 int update_config_rom;
65 struct work_struct delayed_reset; 65 struct delayed_work delayed_reset;
66 unsigned int config_roms; 66 unsigned int config_roms;
67 67
68 struct list_head addr_space; 68 struct list_head addr_space;
diff --git a/drivers/ieee1394/ieee1394_core.c b/drivers/ieee1394/ieee1394_core.c
index 5fccf9f7a1d2..9a48ca20d1fd 100644
--- a/drivers/ieee1394/ieee1394_core.c
+++ b/drivers/ieee1394/ieee1394_core.c
@@ -1237,10 +1237,10 @@ EXPORT_SYMBOL(highlevel_remove_host);
1237/** nodemgr.c **/ 1237/** nodemgr.c **/
1238EXPORT_SYMBOL(hpsb_node_fill_packet); 1238EXPORT_SYMBOL(hpsb_node_fill_packet);
1239EXPORT_SYMBOL(hpsb_node_write); 1239EXPORT_SYMBOL(hpsb_node_write);
1240EXPORT_SYMBOL(hpsb_register_protocol); 1240EXPORT_SYMBOL(__hpsb_register_protocol);
1241EXPORT_SYMBOL(hpsb_unregister_protocol); 1241EXPORT_SYMBOL(hpsb_unregister_protocol);
1242EXPORT_SYMBOL(ieee1394_bus_type);
1243#ifdef CONFIG_IEEE1394_EXPORT_FULL_API 1242#ifdef CONFIG_IEEE1394_EXPORT_FULL_API
1243EXPORT_SYMBOL(ieee1394_bus_type);
1244EXPORT_SYMBOL(nodemgr_for_each_host); 1244EXPORT_SYMBOL(nodemgr_for_each_host);
1245#endif 1245#endif
1246 1246
diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c
index 8e7b83f84485..61307ca296ae 100644
--- a/drivers/ieee1394/nodemgr.c
+++ b/drivers/ieee1394/nodemgr.c
@@ -14,7 +14,9 @@
14#include <linux/slab.h> 14#include <linux/slab.h>
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/kthread.h> 16#include <linux/kthread.h>
17#include <linux/module.h>
17#include <linux/moduleparam.h> 18#include <linux/moduleparam.h>
19#include <linux/freezer.h>
18#include <asm/atomic.h> 20#include <asm/atomic.h>
19 21
20#include "csr.h" 22#include "csr.h"
@@ -66,7 +68,7 @@ static int nodemgr_check_speed(struct nodemgr_csr_info *ci, u64 addr,
66{ 68{
67 quadlet_t q; 69 quadlet_t q;
68 u8 i, *speed, old_speed, good_speed; 70 u8 i, *speed, old_speed, good_speed;
69 int ret; 71 int error;
70 72
71 speed = &(ci->host->speed[NODEID_TO_NODE(ci->nodeid)]); 73 speed = &(ci->host->speed[NODEID_TO_NODE(ci->nodeid)]);
72 old_speed = *speed; 74 old_speed = *speed;
@@ -78,9 +80,9 @@ static int nodemgr_check_speed(struct nodemgr_csr_info *ci, u64 addr,
78 * just finished its initialization. */ 80 * just finished its initialization. */
79 for (i = IEEE1394_SPEED_100; i <= old_speed; i++) { 81 for (i = IEEE1394_SPEED_100; i <= old_speed; i++) {
80 *speed = i; 82 *speed = i;
81 ret = hpsb_read(ci->host, ci->nodeid, ci->generation, addr, 83 error = hpsb_read(ci->host, ci->nodeid, ci->generation, addr,
82 &q, sizeof(quadlet_t)); 84 &q, sizeof(quadlet_t));
83 if (ret) 85 if (error)
84 break; 86 break;
85 *buffer = q; 87 *buffer = q;
86 good_speed = i; 88 good_speed = i;
@@ -94,19 +96,19 @@ static int nodemgr_check_speed(struct nodemgr_csr_info *ci, u64 addr,
94 return 0; 96 return 0;
95 } 97 }
96 *speed = old_speed; 98 *speed = old_speed;
97 return ret; 99 return error;
98} 100}
99 101
100static int nodemgr_bus_read(struct csr1212_csr *csr, u64 addr, u16 length, 102static int nodemgr_bus_read(struct csr1212_csr *csr, u64 addr, u16 length,
101 void *buffer, void *__ci) 103 void *buffer, void *__ci)
102{ 104{
103 struct nodemgr_csr_info *ci = (struct nodemgr_csr_info*)__ci; 105 struct nodemgr_csr_info *ci = (struct nodemgr_csr_info*)__ci;
104 int i, ret; 106 int i, error;
105 107
106 for (i = 1; ; i++) { 108 for (i = 1; ; i++) {
107 ret = hpsb_read(ci->host, ci->nodeid, ci->generation, addr, 109 error = hpsb_read(ci->host, ci->nodeid, ci->generation, addr,
108 buffer, length); 110 buffer, length);
109 if (!ret) { 111 if (!error) {
110 ci->speed_unverified = 0; 112 ci->speed_unverified = 0;
111 break; 113 break;
112 } 114 }
@@ -117,14 +119,14 @@ static int nodemgr_bus_read(struct csr1212_csr *csr, u64 addr, u16 length,
117 /* The ieee1394_core guessed the node's speed capability from 119 /* The ieee1394_core guessed the node's speed capability from
118 * the self ID. Check whether a lower speed works. */ 120 * the self ID. Check whether a lower speed works. */
119 if (ci->speed_unverified && length == sizeof(quadlet_t)) { 121 if (ci->speed_unverified && length == sizeof(quadlet_t)) {
120 ret = nodemgr_check_speed(ci, addr, buffer); 122 error = nodemgr_check_speed(ci, addr, buffer);
121 if (!ret) 123 if (!error)
122 break; 124 break;
123 } 125 }
124 if (msleep_interruptible(334)) 126 if (msleep_interruptible(334))
125 return -EINTR; 127 return -EINTR;
126 } 128 }
127 return ret; 129 return error;
128} 130}
129 131
130static int nodemgr_get_max_rom(quadlet_t *bus_info_data, void *__ci) 132static int nodemgr_get_max_rom(quadlet_t *bus_info_data, void *__ci)
@@ -259,9 +261,20 @@ static struct device nodemgr_dev_template_ne = {
259 .release = nodemgr_release_ne, 261 .release = nodemgr_release_ne,
260}; 262};
261 263
264/* This dummy driver prevents the host devices from being scanned. We have no
265 * useful drivers for them yet, and there would be a deadlock possible if the
266 * driver core scans the host device while the host's low-level driver (i.e.
267 * the host's parent device) is being removed. */
268static struct device_driver nodemgr_mid_layer_driver = {
269 .bus = &ieee1394_bus_type,
270 .name = "nodemgr",
271 .owner = THIS_MODULE,
272};
273
262struct device nodemgr_dev_template_host = { 274struct device nodemgr_dev_template_host = {
263 .bus = &ieee1394_bus_type, 275 .bus = &ieee1394_bus_type,
264 .release = nodemgr_release_host, 276 .release = nodemgr_release_host,
277 .driver = &nodemgr_mid_layer_driver,
265}; 278};
266 279
267 280
@@ -306,8 +319,8 @@ static ssize_t fw_drv_show_##field (struct device_driver *drv, char *buf) \
306 return sprintf(buf, format_string, (type)driver->field);\ 319 return sprintf(buf, format_string, (type)driver->field);\
307} \ 320} \
308static struct driver_attribute driver_attr_drv_##field = { \ 321static struct driver_attribute driver_attr_drv_##field = { \
309 .attr = {.name = __stringify(field), .mode = S_IRUGO }, \ 322 .attr = {.name = __stringify(field), .mode = S_IRUGO }, \
310 .show = fw_drv_show_##field, \ 323 .show = fw_drv_show_##field, \
311}; 324};
312 325
313 326
@@ -361,7 +374,7 @@ static ssize_t fw_show_ne_tlabels_mask(struct device *dev,
361#endif 374#endif
362 spin_unlock_irqrestore(&hpsb_tlabel_lock, flags); 375 spin_unlock_irqrestore(&hpsb_tlabel_lock, flags);
363 376
364 return sprintf(buf, "0x%016llx\n", tm); 377 return sprintf(buf, "0x%016llx\n", (unsigned long long)tm);
365} 378}
366static DEVICE_ATTR(tlabels_mask, S_IRUGO, fw_show_ne_tlabels_mask, NULL); 379static DEVICE_ATTR(tlabels_mask, S_IRUGO, fw_show_ne_tlabels_mask, NULL);
367#endif /* HPSB_DEBUG_TLABELS */ 380#endif /* HPSB_DEBUG_TLABELS */
@@ -373,11 +386,11 @@ static ssize_t fw_set_ignore_driver(struct device *dev, struct device_attribute
373 int state = simple_strtoul(buf, NULL, 10); 386 int state = simple_strtoul(buf, NULL, 10);
374 387
375 if (state == 1) { 388 if (state == 1) {
376 down_write(&dev->bus->subsys.rwsem);
377 device_release_driver(dev);
378 ud->ignore_driver = 1; 389 ud->ignore_driver = 1;
379 up_write(&dev->bus->subsys.rwsem); 390 down_write(&ieee1394_bus_type.subsys.rwsem);
380 } else if (!state) 391 device_release_driver(dev);
392 up_write(&ieee1394_bus_type.subsys.rwsem);
393 } else if (state == 0)
381 ud->ignore_driver = 0; 394 ud->ignore_driver = 0;
382 395
383 return count; 396 return count;
@@ -412,11 +425,14 @@ static ssize_t fw_get_destroy_node(struct bus_type *bus, char *buf)
412static BUS_ATTR(destroy_node, S_IWUSR | S_IRUGO, fw_get_destroy_node, fw_set_destroy_node); 425static BUS_ATTR(destroy_node, S_IWUSR | S_IRUGO, fw_get_destroy_node, fw_set_destroy_node);
413 426
414 427
415static ssize_t fw_set_rescan(struct bus_type *bus, const char *buf, size_t count) 428static ssize_t fw_set_rescan(struct bus_type *bus, const char *buf,
429 size_t count)
416{ 430{
431 int error = 0;
432
417 if (simple_strtoul(buf, NULL, 10) == 1) 433 if (simple_strtoul(buf, NULL, 10) == 1)
418 bus_rescan_devices(&ieee1394_bus_type); 434 error = bus_rescan_devices(&ieee1394_bus_type);
419 return count; 435 return error ? error : count;
420} 436}
421static ssize_t fw_get_rescan(struct bus_type *bus, char *buf) 437static ssize_t fw_get_rescan(struct bus_type *bus, char *buf)
422{ 438{
@@ -432,7 +448,7 @@ static ssize_t fw_set_ignore_drivers(struct bus_type *bus, const char *buf, size
432 448
433 if (state == 1) 449 if (state == 1)
434 ignore_drivers = 1; 450 ignore_drivers = 1;
435 else if (!state) 451 else if (state == 0)
436 ignore_drivers = 0; 452 ignore_drivers = 0;
437 453
438 return count; 454 return count;
@@ -525,7 +541,7 @@ static ssize_t fw_show_drv_device_ids(struct device_driver *drv, char *buf)
525 int length = 0; 541 int length = 0;
526 char *scratch = buf; 542 char *scratch = buf;
527 543
528 driver = container_of(drv, struct hpsb_protocol_driver, driver); 544 driver = container_of(drv, struct hpsb_protocol_driver, driver);
529 545
530 for (id = driver->id_table; id->match_flags != 0; id++) { 546 for (id = driver->id_table; id->match_flags != 0; id++) {
531 int need_coma = 0; 547 int need_coma = 0;
@@ -582,7 +598,11 @@ static void nodemgr_create_drv_files(struct hpsb_protocol_driver *driver)
582 int i; 598 int i;
583 599
584 for (i = 0; i < ARRAY_SIZE(fw_drv_attrs); i++) 600 for (i = 0; i < ARRAY_SIZE(fw_drv_attrs); i++)
585 driver_create_file(drv, fw_drv_attrs[i]); 601 if (driver_create_file(drv, fw_drv_attrs[i]))
602 goto fail;
603 return;
604fail:
605 HPSB_ERR("Failed to add sysfs attribute for driver %s", driver->name);
586} 606}
587 607
588 608
@@ -602,7 +622,12 @@ static void nodemgr_create_ne_dev_files(struct node_entry *ne)
602 int i; 622 int i;
603 623
604 for (i = 0; i < ARRAY_SIZE(fw_ne_attrs); i++) 624 for (i = 0; i < ARRAY_SIZE(fw_ne_attrs); i++)
605 device_create_file(dev, fw_ne_attrs[i]); 625 if (device_create_file(dev, fw_ne_attrs[i]))
626 goto fail;
627 return;
628fail:
629 HPSB_ERR("Failed to add sysfs attribute for node %016Lx",
630 (unsigned long long)ne->guid);
606} 631}
607 632
608 633
@@ -612,11 +637,16 @@ static void nodemgr_create_host_dev_files(struct hpsb_host *host)
612 int i; 637 int i;
613 638
614 for (i = 0; i < ARRAY_SIZE(fw_host_attrs); i++) 639 for (i = 0; i < ARRAY_SIZE(fw_host_attrs); i++)
615 device_create_file(dev, fw_host_attrs[i]); 640 if (device_create_file(dev, fw_host_attrs[i]))
641 goto fail;
642 return;
643fail:
644 HPSB_ERR("Failed to add sysfs attribute for host %d", host->id);
616} 645}
617 646
618 647
619static struct node_entry *find_entry_by_nodeid(struct hpsb_host *host, nodeid_t nodeid); 648static struct node_entry *find_entry_by_nodeid(struct hpsb_host *host,
649 nodeid_t nodeid);
620 650
621static void nodemgr_update_host_dev_links(struct hpsb_host *host) 651static void nodemgr_update_host_dev_links(struct hpsb_host *host)
622{ 652{
@@ -627,12 +657,18 @@ static void nodemgr_update_host_dev_links(struct hpsb_host *host)
627 sysfs_remove_link(&dev->kobj, "busmgr_id"); 657 sysfs_remove_link(&dev->kobj, "busmgr_id");
628 sysfs_remove_link(&dev->kobj, "host_id"); 658 sysfs_remove_link(&dev->kobj, "host_id");
629 659
630 if ((ne = find_entry_by_nodeid(host, host->irm_id))) 660 if ((ne = find_entry_by_nodeid(host, host->irm_id)) &&
631 sysfs_create_link(&dev->kobj, &ne->device.kobj, "irm_id"); 661 sysfs_create_link(&dev->kobj, &ne->device.kobj, "irm_id"))
632 if ((ne = find_entry_by_nodeid(host, host->busmgr_id))) 662 goto fail;
633 sysfs_create_link(&dev->kobj, &ne->device.kobj, "busmgr_id"); 663 if ((ne = find_entry_by_nodeid(host, host->busmgr_id)) &&
634 if ((ne = find_entry_by_nodeid(host, host->node_id))) 664 sysfs_create_link(&dev->kobj, &ne->device.kobj, "busmgr_id"))
635 sysfs_create_link(&dev->kobj, &ne->device.kobj, "host_id"); 665 goto fail;
666 if ((ne = find_entry_by_nodeid(host, host->node_id)) &&
667 sysfs_create_link(&dev->kobj, &ne->device.kobj, "host_id"))
668 goto fail;
669 return;
670fail:
671 HPSB_ERR("Failed to update sysfs attributes for host %d", host->id);
636} 672}
637 673
638static void nodemgr_create_ud_dev_files(struct unit_directory *ud) 674static void nodemgr_create_ud_dev_files(struct unit_directory *ud)
@@ -641,32 +677,39 @@ static void nodemgr_create_ud_dev_files(struct unit_directory *ud)
641 int i; 677 int i;
642 678
643 for (i = 0; i < ARRAY_SIZE(fw_ud_attrs); i++) 679 for (i = 0; i < ARRAY_SIZE(fw_ud_attrs); i++)
644 device_create_file(dev, fw_ud_attrs[i]); 680 if (device_create_file(dev, fw_ud_attrs[i]))
645 681 goto fail;
646 if (ud->flags & UNIT_DIRECTORY_SPECIFIER_ID) 682 if (ud->flags & UNIT_DIRECTORY_SPECIFIER_ID)
647 device_create_file(dev, &dev_attr_ud_specifier_id); 683 if (device_create_file(dev, &dev_attr_ud_specifier_id))
648 684 goto fail;
649 if (ud->flags & UNIT_DIRECTORY_VERSION) 685 if (ud->flags & UNIT_DIRECTORY_VERSION)
650 device_create_file(dev, &dev_attr_ud_version); 686 if (device_create_file(dev, &dev_attr_ud_version))
651 687 goto fail;
652 if (ud->flags & UNIT_DIRECTORY_VENDOR_ID) { 688 if (ud->flags & UNIT_DIRECTORY_VENDOR_ID) {
653 device_create_file(dev, &dev_attr_ud_vendor_id); 689 if (device_create_file(dev, &dev_attr_ud_vendor_id))
654 if (ud->vendor_name_kv) 690 goto fail;
655 device_create_file(dev, &dev_attr_ud_vendor_name_kv); 691 if (ud->vendor_name_kv &&
692 device_create_file(dev, &dev_attr_ud_vendor_name_kv))
693 goto fail;
656 } 694 }
657
658 if (ud->flags & UNIT_DIRECTORY_MODEL_ID) { 695 if (ud->flags & UNIT_DIRECTORY_MODEL_ID) {
659 device_create_file(dev, &dev_attr_ud_model_id); 696 if (device_create_file(dev, &dev_attr_ud_model_id))
660 if (ud->model_name_kv) 697 goto fail;
661 device_create_file(dev, &dev_attr_ud_model_name_kv); 698 if (ud->model_name_kv &&
699 device_create_file(dev, &dev_attr_ud_model_name_kv))
700 goto fail;
662 } 701 }
702 return;
703fail:
704 HPSB_ERR("Failed to add sysfs attributes for unit %s",
705 ud->device.bus_id);
663} 706}
664 707
665 708
666static int nodemgr_bus_match(struct device * dev, struct device_driver * drv) 709static int nodemgr_bus_match(struct device * dev, struct device_driver * drv)
667{ 710{
668 struct hpsb_protocol_driver *driver; 711 struct hpsb_protocol_driver *driver;
669 struct unit_directory *ud; 712 struct unit_directory *ud;
670 struct ieee1394_device_id *id; 713 struct ieee1394_device_id *id;
671 714
672 /* We only match unit directories */ 715 /* We only match unit directories */
@@ -674,55 +717,77 @@ static int nodemgr_bus_match(struct device * dev, struct device_driver * drv)
674 return 0; 717 return 0;
675 718
676 ud = container_of(dev, struct unit_directory, device); 719 ud = container_of(dev, struct unit_directory, device);
677 driver = container_of(drv, struct hpsb_protocol_driver, driver);
678
679 if (ud->ne->in_limbo || ud->ignore_driver) 720 if (ud->ne->in_limbo || ud->ignore_driver)
680 return 0; 721 return 0;
681 722
682 for (id = driver->id_table; id->match_flags != 0; id++) { 723 /* We only match drivers of type hpsb_protocol_driver */
683 if ((id->match_flags & IEEE1394_MATCH_VENDOR_ID) && 724 if (drv == &nodemgr_mid_layer_driver)
684 id->vendor_id != ud->vendor_id) 725 return 0;
685 continue;
686 726
687 if ((id->match_flags & IEEE1394_MATCH_MODEL_ID) && 727 driver = container_of(drv, struct hpsb_protocol_driver, driver);
688 id->model_id != ud->model_id) 728 for (id = driver->id_table; id->match_flags != 0; id++) {
689 continue; 729 if ((id->match_flags & IEEE1394_MATCH_VENDOR_ID) &&
730 id->vendor_id != ud->vendor_id)
731 continue;
690 732
691 if ((id->match_flags & IEEE1394_MATCH_SPECIFIER_ID) && 733 if ((id->match_flags & IEEE1394_MATCH_MODEL_ID) &&
692 id->specifier_id != ud->specifier_id) 734 id->model_id != ud->model_id)
693 continue; 735 continue;
694 736
695 if ((id->match_flags & IEEE1394_MATCH_VERSION) && 737 if ((id->match_flags & IEEE1394_MATCH_SPECIFIER_ID) &&
696 id->version != ud->version) 738 id->specifier_id != ud->specifier_id)
697 continue; 739 continue;
740
741 if ((id->match_flags & IEEE1394_MATCH_VERSION) &&
742 id->version != ud->version)
743 continue;
698 744
699 return 1; 745 return 1;
700 } 746 }
701 747
702 return 0; 748 return 0;
703} 749}
704 750
705 751
752static DEFINE_MUTEX(nodemgr_serialize_remove_uds);
753
706static void nodemgr_remove_uds(struct node_entry *ne) 754static void nodemgr_remove_uds(struct node_entry *ne)
707{ 755{
708 struct class_device *cdev, *next; 756 struct class_device *cdev;
709 struct unit_directory *ud; 757 struct unit_directory *tmp, *ud;
710 758
711 list_for_each_entry_safe(cdev, next, &nodemgr_ud_class.children, node) { 759 /* Iteration over nodemgr_ud_class.children has to be protected by
712 ud = container_of(cdev, struct unit_directory, class_dev); 760 * nodemgr_ud_class.sem, but class_device_unregister() will eventually
713 761 * take nodemgr_ud_class.sem too. Therefore pick out one ud at a time,
714 if (ud->ne != ne) 762 * release the semaphore, and then unregister the ud. Since this code
715 continue; 763 * may be called from other contexts besides the knodemgrds, protect the
716 764 * gap after release of the semaphore by nodemgr_serialize_remove_uds.
765 */
766 mutex_lock(&nodemgr_serialize_remove_uds);
767 for (;;) {
768 ud = NULL;
769 down(&nodemgr_ud_class.sem);
770 list_for_each_entry(cdev, &nodemgr_ud_class.children, node) {
771 tmp = container_of(cdev, struct unit_directory,
772 class_dev);
773 if (tmp->ne == ne) {
774 ud = tmp;
775 break;
776 }
777 }
778 up(&nodemgr_ud_class.sem);
779 if (ud == NULL)
780 break;
717 class_device_unregister(&ud->class_dev); 781 class_device_unregister(&ud->class_dev);
718 device_unregister(&ud->device); 782 device_unregister(&ud->device);
719 } 783 }
784 mutex_unlock(&nodemgr_serialize_remove_uds);
720} 785}
721 786
722 787
723static void nodemgr_remove_ne(struct node_entry *ne) 788static void nodemgr_remove_ne(struct node_entry *ne)
724{ 789{
725 struct device *dev = &ne->device; 790 struct device *dev;
726 791
727 dev = get_device(&ne->device); 792 dev = get_device(&ne->device);
728 if (!dev) 793 if (!dev)
@@ -747,7 +812,7 @@ static int __nodemgr_remove_host_dev(struct device *dev, void *data)
747 812
748static void nodemgr_remove_host_dev(struct device *dev) 813static void nodemgr_remove_host_dev(struct device *dev)
749{ 814{
750 device_for_each_child(dev, NULL, __nodemgr_remove_host_dev); 815 WARN_ON(device_for_each_child(dev, NULL, __nodemgr_remove_host_dev));
751 sysfs_remove_link(&dev->kobj, "irm_id"); 816 sysfs_remove_link(&dev->kobj, "irm_id");
752 sysfs_remove_link(&dev->kobj, "busmgr_id"); 817 sysfs_remove_link(&dev->kobj, "busmgr_id");
753 sysfs_remove_link(&dev->kobj, "host_id"); 818 sysfs_remove_link(&dev->kobj, "host_id");
@@ -761,16 +826,16 @@ static void nodemgr_update_bus_options(struct node_entry *ne)
761#endif 826#endif
762 quadlet_t busoptions = be32_to_cpu(ne->csr->bus_info_data[2]); 827 quadlet_t busoptions = be32_to_cpu(ne->csr->bus_info_data[2]);
763 828
764 ne->busopt.irmc = (busoptions >> 31) & 1; 829 ne->busopt.irmc = (busoptions >> 31) & 1;
765 ne->busopt.cmc = (busoptions >> 30) & 1; 830 ne->busopt.cmc = (busoptions >> 30) & 1;
766 ne->busopt.isc = (busoptions >> 29) & 1; 831 ne->busopt.isc = (busoptions >> 29) & 1;
767 ne->busopt.bmc = (busoptions >> 28) & 1; 832 ne->busopt.bmc = (busoptions >> 28) & 1;
768 ne->busopt.pmc = (busoptions >> 27) & 1; 833 ne->busopt.pmc = (busoptions >> 27) & 1;
769 ne->busopt.cyc_clk_acc = (busoptions >> 16) & 0xff; 834 ne->busopt.cyc_clk_acc = (busoptions >> 16) & 0xff;
770 ne->busopt.max_rec = 1 << (((busoptions >> 12) & 0xf) + 1); 835 ne->busopt.max_rec = 1 << (((busoptions >> 12) & 0xf) + 1);
771 ne->busopt.max_rom = (busoptions >> 8) & 0x3; 836 ne->busopt.max_rom = (busoptions >> 8) & 0x3;
772 ne->busopt.generation = (busoptions >> 4) & 0xf; 837 ne->busopt.generation = (busoptions >> 4) & 0xf;
773 ne->busopt.lnkspd = busoptions & 0x7; 838 ne->busopt.lnkspd = busoptions & 0x7;
774 839
775 HPSB_VERBOSE("NodeMgr: raw=0x%08x irmc=%d cmc=%d isc=%d bmc=%d pmc=%d " 840 HPSB_VERBOSE("NodeMgr: raw=0x%08x irmc=%d cmc=%d isc=%d bmc=%d pmc=%d "
776 "cyc_clk_acc=%d max_rec=%d max_rom=%d gen=%d lspd=%d", 841 "cyc_clk_acc=%d max_rec=%d max_rom=%d gen=%d lspd=%d",
@@ -791,7 +856,7 @@ static struct node_entry *nodemgr_create_node(octlet_t guid, struct csr1212_csr
791 856
792 ne = kzalloc(sizeof(*ne), GFP_KERNEL); 857 ne = kzalloc(sizeof(*ne), GFP_KERNEL);
793 if (!ne) 858 if (!ne)
794 return NULL; 859 goto fail_alloc;
795 860
796 ne->host = host; 861 ne->host = host;
797 ne->nodeid = nodeid; 862 ne->nodeid = nodeid;
@@ -814,12 +879,15 @@ static struct node_entry *nodemgr_create_node(octlet_t guid, struct csr1212_csr
814 snprintf(ne->class_dev.class_id, BUS_ID_SIZE, "%016Lx", 879 snprintf(ne->class_dev.class_id, BUS_ID_SIZE, "%016Lx",
815 (unsigned long long)(ne->guid)); 880 (unsigned long long)(ne->guid));
816 881
817 device_register(&ne->device); 882 if (device_register(&ne->device))
818 class_device_register(&ne->class_dev); 883 goto fail_devreg;
884 if (class_device_register(&ne->class_dev))
885 goto fail_classdevreg;
819 get_device(&ne->device); 886 get_device(&ne->device);
820 887
821 if (ne->guid_vendor_oui) 888 if (ne->guid_vendor_oui &&
822 device_create_file(&ne->device, &dev_attr_ne_guid_vendor_oui); 889 device_create_file(&ne->device, &dev_attr_ne_guid_vendor_oui))
890 goto fail_addoiu;
823 nodemgr_create_ne_dev_files(ne); 891 nodemgr_create_ne_dev_files(ne);
824 892
825 nodemgr_update_bus_options(ne); 893 nodemgr_update_bus_options(ne);
@@ -829,17 +897,28 @@ static struct node_entry *nodemgr_create_node(octlet_t guid, struct csr1212_csr
829 NODE_BUS_ARGS(host, nodeid), (unsigned long long)guid); 897 NODE_BUS_ARGS(host, nodeid), (unsigned long long)guid);
830 898
831 return ne; 899 return ne;
900
901fail_addoiu:
902 put_device(&ne->device);
903fail_classdevreg:
904 device_unregister(&ne->device);
905fail_devreg:
906 kfree(ne);
907fail_alloc:
908 HPSB_ERR("Failed to create node ID:BUS[" NODE_BUS_FMT "] GUID[%016Lx]",
909 NODE_BUS_ARGS(host, nodeid), (unsigned long long)guid);
910
911 return NULL;
832} 912}
833 913
834 914
835static struct node_entry *find_entry_by_guid(u64 guid) 915static struct node_entry *find_entry_by_guid(u64 guid)
836{ 916{
837 struct class *class = &nodemgr_ne_class;
838 struct class_device *cdev; 917 struct class_device *cdev;
839 struct node_entry *ne, *ret_ne = NULL; 918 struct node_entry *ne, *ret_ne = NULL;
840 919
841 down_read(&class->subsys.rwsem); 920 down(&nodemgr_ne_class.sem);
842 list_for_each_entry(cdev, &class->children, node) { 921 list_for_each_entry(cdev, &nodemgr_ne_class.children, node) {
843 ne = container_of(cdev, struct node_entry, class_dev); 922 ne = container_of(cdev, struct node_entry, class_dev);
844 923
845 if (ne->guid == guid) { 924 if (ne->guid == guid) {
@@ -847,20 +926,20 @@ static struct node_entry *find_entry_by_guid(u64 guid)
847 break; 926 break;
848 } 927 }
849 } 928 }
850 up_read(&class->subsys.rwsem); 929 up(&nodemgr_ne_class.sem);
851 930
852 return ret_ne; 931 return ret_ne;
853} 932}
854 933
855 934
856static struct node_entry *find_entry_by_nodeid(struct hpsb_host *host, nodeid_t nodeid) 935static struct node_entry *find_entry_by_nodeid(struct hpsb_host *host,
936 nodeid_t nodeid)
857{ 937{
858 struct class *class = &nodemgr_ne_class;
859 struct class_device *cdev; 938 struct class_device *cdev;
860 struct node_entry *ne, *ret_ne = NULL; 939 struct node_entry *ne, *ret_ne = NULL;
861 940
862 down_read(&class->subsys.rwsem); 941 down(&nodemgr_ne_class.sem);
863 list_for_each_entry(cdev, &class->children, node) { 942 list_for_each_entry(cdev, &nodemgr_ne_class.children, node) {
864 ne = container_of(cdev, struct node_entry, class_dev); 943 ne = container_of(cdev, struct node_entry, class_dev);
865 944
866 if (ne->host == host && ne->nodeid == nodeid) { 945 if (ne->host == host && ne->nodeid == nodeid) {
@@ -868,7 +947,7 @@ static struct node_entry *find_entry_by_nodeid(struct hpsb_host *host, nodeid_t
868 break; 947 break;
869 } 948 }
870 } 949 }
871 up_read(&class->subsys.rwsem); 950 up(&nodemgr_ne_class.sem);
872 951
873 return ret_ne; 952 return ret_ne;
874} 953}
@@ -890,13 +969,25 @@ static void nodemgr_register_device(struct node_entry *ne,
890 snprintf(ud->class_dev.class_id, BUS_ID_SIZE, "%s-%u", 969 snprintf(ud->class_dev.class_id, BUS_ID_SIZE, "%s-%u",
891 ne->device.bus_id, ud->id); 970 ne->device.bus_id, ud->id);
892 971
893 device_register(&ud->device); 972 if (device_register(&ud->device))
894 class_device_register(&ud->class_dev); 973 goto fail_devreg;
974 if (class_device_register(&ud->class_dev))
975 goto fail_classdevreg;
895 get_device(&ud->device); 976 get_device(&ud->device);
896 977
897 if (ud->vendor_oui) 978 if (ud->vendor_oui &&
898 device_create_file(&ud->device, &dev_attr_ud_vendor_oui); 979 device_create_file(&ud->device, &dev_attr_ud_vendor_oui))
980 goto fail_addoui;
899 nodemgr_create_ud_dev_files(ud); 981 nodemgr_create_ud_dev_files(ud);
982
983 return;
984
985fail_addoui:
986 put_device(&ud->device);
987fail_classdevreg:
988 device_unregister(&ud->device);
989fail_devreg:
990 HPSB_ERR("Failed to create unit %s", ud->device.bus_id);
900} 991}
901 992
902 993
@@ -976,10 +1067,9 @@ static struct unit_directory *nodemgr_process_unit_directory
976 /* Logical Unit Number */ 1067 /* Logical Unit Number */
977 if (kv->key.type == CSR1212_KV_TYPE_IMMEDIATE) { 1068 if (kv->key.type == CSR1212_KV_TYPE_IMMEDIATE) {
978 if (ud->flags & UNIT_DIRECTORY_HAS_LUN) { 1069 if (ud->flags & UNIT_DIRECTORY_HAS_LUN) {
979 ud_child = kmalloc(sizeof(*ud_child), GFP_KERNEL); 1070 ud_child = kmemdup(ud, sizeof(*ud_child), GFP_KERNEL);
980 if (!ud_child) 1071 if (!ud_child)
981 goto unit_directory_error; 1072 goto unit_directory_error;
982 memcpy(ud_child, ud, sizeof(*ud_child));
983 nodemgr_register_device(ne, ud_child, &ne->device); 1073 nodemgr_register_device(ne, ud_child, &ne->device);
984 ud_child = NULL; 1074 ud_child = NULL;
985 1075
@@ -1093,10 +1183,16 @@ static void nodemgr_process_root_directory(struct host_info *hi, struct node_ent
1093 last_key_id = kv->key.id; 1183 last_key_id = kv->key.id;
1094 } 1184 }
1095 1185
1096 if (ne->vendor_oui) 1186 if (ne->vendor_oui &&
1097 device_create_file(&ne->device, &dev_attr_ne_vendor_oui); 1187 device_create_file(&ne->device, &dev_attr_ne_vendor_oui))
1098 if (ne->vendor_name_kv) 1188 goto fail;
1099 device_create_file(&ne->device, &dev_attr_ne_vendor_name_kv); 1189 if (ne->vendor_name_kv &&
1190 device_create_file(&ne->device, &dev_attr_ne_vendor_name_kv))
1191 goto fail;
1192 return;
1193fail:
1194 HPSB_ERR("Failed to add sysfs attribute for node %016Lx",
1195 (unsigned long long)ne->guid);
1100} 1196}
1101 1197
1102#ifdef CONFIG_HOTPLUG 1198#ifdef CONFIG_HOTPLUG
@@ -1160,16 +1256,20 @@ static int nodemgr_uevent(struct class_device *cdev, char **envp, int num_envp,
1160#endif /* CONFIG_HOTPLUG */ 1256#endif /* CONFIG_HOTPLUG */
1161 1257
1162 1258
1163int hpsb_register_protocol(struct hpsb_protocol_driver *driver) 1259int __hpsb_register_protocol(struct hpsb_protocol_driver *drv,
1260 struct module *owner)
1164{ 1261{
1165 int ret; 1262 int error;
1166 1263
1167 /* This will cause a probe for devices */ 1264 drv->driver.bus = &ieee1394_bus_type;
1168 ret = driver_register(&driver->driver); 1265 drv->driver.owner = owner;
1169 if (!ret) 1266 drv->driver.name = drv->name;
1170 nodemgr_create_drv_files(driver);
1171 1267
1172 return ret; 1268 /* This will cause a probe for devices */
1269 error = driver_register(&drv->driver);
1270 if (!error)
1271 nodemgr_create_drv_files(drv);
1272 return error;
1173} 1273}
1174 1274
1175void hpsb_unregister_protocol(struct hpsb_protocol_driver *driver) 1275void hpsb_unregister_protocol(struct hpsb_protocol_driver *driver)
@@ -1297,26 +1397,25 @@ static void nodemgr_node_scan_one(struct host_info *hi,
1297 1397
1298static void nodemgr_node_scan(struct host_info *hi, int generation) 1398static void nodemgr_node_scan(struct host_info *hi, int generation)
1299{ 1399{
1300 int count; 1400 int count;
1301 struct hpsb_host *host = hi->host; 1401 struct hpsb_host *host = hi->host;
1302 struct selfid *sid = (struct selfid *)host->topology_map; 1402 struct selfid *sid = (struct selfid *)host->topology_map;
1303 nodeid_t nodeid = LOCAL_BUS; 1403 nodeid_t nodeid = LOCAL_BUS;
1304 1404
1305 /* Scan each node on the bus */ 1405 /* Scan each node on the bus */
1306 for (count = host->selfid_count; count; count--, sid++) { 1406 for (count = host->selfid_count; count; count--, sid++) {
1307 if (sid->extended) 1407 if (sid->extended)
1308 continue; 1408 continue;
1309 1409
1310 if (!sid->link_active) { 1410 if (!sid->link_active) {
1311 nodeid++; 1411 nodeid++;
1312 continue; 1412 continue;
1313 } 1413 }
1314 nodemgr_node_scan_one(hi, nodeid++, generation); 1414 nodemgr_node_scan_one(hi, nodeid++, generation);
1315 } 1415 }
1316} 1416}
1317 1417
1318 1418
1319/* Caller needs to hold nodemgr_ud_class.subsys.rwsem as reader. */
1320static void nodemgr_suspend_ne(struct node_entry *ne) 1419static void nodemgr_suspend_ne(struct node_entry *ne)
1321{ 1420{
1322 struct class_device *cdev; 1421 struct class_device *cdev;
@@ -1326,21 +1425,22 @@ static void nodemgr_suspend_ne(struct node_entry *ne)
1326 NODE_BUS_ARGS(ne->host, ne->nodeid), (unsigned long long)ne->guid); 1425 NODE_BUS_ARGS(ne->host, ne->nodeid), (unsigned long long)ne->guid);
1327 1426
1328 ne->in_limbo = 1; 1427 ne->in_limbo = 1;
1329 device_create_file(&ne->device, &dev_attr_ne_in_limbo); 1428 WARN_ON(device_create_file(&ne->device, &dev_attr_ne_in_limbo));
1330 1429
1331 down_write(&ne->device.bus->subsys.rwsem); 1430 down(&nodemgr_ud_class.sem);
1332 list_for_each_entry(cdev, &nodemgr_ud_class.children, node) { 1431 list_for_each_entry(cdev, &nodemgr_ud_class.children, node) {
1333 ud = container_of(cdev, struct unit_directory, class_dev); 1432 ud = container_of(cdev, struct unit_directory, class_dev);
1334
1335 if (ud->ne != ne) 1433 if (ud->ne != ne)
1336 continue; 1434 continue;
1337 1435
1436 down_write(&ieee1394_bus_type.subsys.rwsem);
1338 if (ud->device.driver && 1437 if (ud->device.driver &&
1339 (!ud->device.driver->suspend || 1438 (!ud->device.driver->suspend ||
1340 ud->device.driver->suspend(&ud->device, PMSG_SUSPEND))) 1439 ud->device.driver->suspend(&ud->device, PMSG_SUSPEND)))
1341 device_release_driver(&ud->device); 1440 device_release_driver(&ud->device);
1441 up_write(&ieee1394_bus_type.subsys.rwsem);
1342 } 1442 }
1343 up_write(&ne->device.bus->subsys.rwsem); 1443 up(&nodemgr_ud_class.sem);
1344} 1444}
1345 1445
1346 1446
@@ -1352,45 +1452,47 @@ static void nodemgr_resume_ne(struct node_entry *ne)
1352 ne->in_limbo = 0; 1452 ne->in_limbo = 0;
1353 device_remove_file(&ne->device, &dev_attr_ne_in_limbo); 1453 device_remove_file(&ne->device, &dev_attr_ne_in_limbo);
1354 1454
1355 down_read(&nodemgr_ud_class.subsys.rwsem); 1455 down(&nodemgr_ud_class.sem);
1356 down_read(&ne->device.bus->subsys.rwsem);
1357 list_for_each_entry(cdev, &nodemgr_ud_class.children, node) { 1456 list_for_each_entry(cdev, &nodemgr_ud_class.children, node) {
1358 ud = container_of(cdev, struct unit_directory, class_dev); 1457 ud = container_of(cdev, struct unit_directory, class_dev);
1359
1360 if (ud->ne != ne) 1458 if (ud->ne != ne)
1361 continue; 1459 continue;
1362 1460
1461 down_read(&ieee1394_bus_type.subsys.rwsem);
1363 if (ud->device.driver && ud->device.driver->resume) 1462 if (ud->device.driver && ud->device.driver->resume)
1364 ud->device.driver->resume(&ud->device); 1463 ud->device.driver->resume(&ud->device);
1464 up_read(&ieee1394_bus_type.subsys.rwsem);
1365 } 1465 }
1366 up_read(&ne->device.bus->subsys.rwsem); 1466 up(&nodemgr_ud_class.sem);
1367 up_read(&nodemgr_ud_class.subsys.rwsem);
1368 1467
1369 HPSB_DEBUG("Node resumed: ID:BUS[" NODE_BUS_FMT "] GUID[%016Lx]", 1468 HPSB_DEBUG("Node resumed: ID:BUS[" NODE_BUS_FMT "] GUID[%016Lx]",
1370 NODE_BUS_ARGS(ne->host, ne->nodeid), (unsigned long long)ne->guid); 1469 NODE_BUS_ARGS(ne->host, ne->nodeid), (unsigned long long)ne->guid);
1371} 1470}
1372 1471
1373 1472
1374/* Caller needs to hold nodemgr_ud_class.subsys.rwsem as reader. */
1375static void nodemgr_update_pdrv(struct node_entry *ne) 1473static void nodemgr_update_pdrv(struct node_entry *ne)
1376{ 1474{
1377 struct unit_directory *ud; 1475 struct unit_directory *ud;
1378 struct hpsb_protocol_driver *pdrv; 1476 struct hpsb_protocol_driver *pdrv;
1379 struct class_device *cdev; 1477 struct class_device *cdev;
1380 1478
1479 down(&nodemgr_ud_class.sem);
1381 list_for_each_entry(cdev, &nodemgr_ud_class.children, node) { 1480 list_for_each_entry(cdev, &nodemgr_ud_class.children, node) {
1382 ud = container_of(cdev, struct unit_directory, class_dev); 1481 ud = container_of(cdev, struct unit_directory, class_dev);
1383 if (ud->ne != ne || !ud->device.driver) 1482 if (ud->ne != ne)
1384 continue; 1483 continue;
1385 1484
1386 pdrv = container_of(ud->device.driver, struct hpsb_protocol_driver, driver); 1485 down_write(&ieee1394_bus_type.subsys.rwsem);
1387 1486 if (ud->device.driver) {
1388 if (pdrv->update && pdrv->update(ud)) { 1487 pdrv = container_of(ud->device.driver,
1389 down_write(&ud->device.bus->subsys.rwsem); 1488 struct hpsb_protocol_driver,
1390 device_release_driver(&ud->device); 1489 driver);
1391 up_write(&ud->device.bus->subsys.rwsem); 1490 if (pdrv->update && pdrv->update(ud))
1491 device_release_driver(&ud->device);
1392 } 1492 }
1493 up_write(&ieee1394_bus_type.subsys.rwsem);
1393 } 1494 }
1495 up(&nodemgr_ud_class.sem);
1394} 1496}
1395 1497
1396 1498
@@ -1404,7 +1506,7 @@ static void nodemgr_irm_write_bc(struct node_entry *ne, int generation)
1404{ 1506{
1405 const u64 bc_addr = (CSR_REGISTER_BASE | CSR_BROADCAST_CHANNEL); 1507 const u64 bc_addr = (CSR_REGISTER_BASE | CSR_BROADCAST_CHANNEL);
1406 quadlet_t bc_remote, bc_local; 1508 quadlet_t bc_remote, bc_local;
1407 int ret; 1509 int error;
1408 1510
1409 if (!ne->host->is_irm || ne->generation != generation || 1511 if (!ne->host->is_irm || ne->generation != generation ||
1410 ne->nodeid == ne->host->node_id) 1512 ne->nodeid == ne->host->node_id)
@@ -1413,16 +1515,14 @@ static void nodemgr_irm_write_bc(struct node_entry *ne, int generation)
1413 bc_local = cpu_to_be32(ne->host->csr.broadcast_channel); 1515 bc_local = cpu_to_be32(ne->host->csr.broadcast_channel);
1414 1516
1415 /* Check if the register is implemented and 1394a compliant. */ 1517 /* Check if the register is implemented and 1394a compliant. */
1416 ret = hpsb_read(ne->host, ne->nodeid, generation, bc_addr, &bc_remote, 1518 error = hpsb_read(ne->host, ne->nodeid, generation, bc_addr, &bc_remote,
1417 sizeof(bc_remote)); 1519 sizeof(bc_remote));
1418 if (!ret && bc_remote & cpu_to_be32(0x80000000) && 1520 if (!error && bc_remote & cpu_to_be32(0x80000000) &&
1419 bc_remote != bc_local) 1521 bc_remote != bc_local)
1420 hpsb_node_write(ne, bc_addr, &bc_local, sizeof(bc_local)); 1522 hpsb_node_write(ne, bc_addr, &bc_local, sizeof(bc_local));
1421} 1523}
1422 1524
1423 1525
1424/* Caller needs to hold nodemgr_ud_class.subsys.rwsem as reader because the
1425 * calls to nodemgr_update_pdrv() and nodemgr_suspend_ne() here require it. */
1426static void nodemgr_probe_ne(struct host_info *hi, struct node_entry *ne, int generation) 1526static void nodemgr_probe_ne(struct host_info *hi, struct node_entry *ne, int generation)
1427{ 1527{
1428 struct device *dev; 1528 struct device *dev;
@@ -1455,7 +1555,6 @@ static void nodemgr_probe_ne(struct host_info *hi, struct node_entry *ne, int ge
1455static void nodemgr_node_probe(struct host_info *hi, int generation) 1555static void nodemgr_node_probe(struct host_info *hi, int generation)
1456{ 1556{
1457 struct hpsb_host *host = hi->host; 1557 struct hpsb_host *host = hi->host;
1458 struct class *class = &nodemgr_ne_class;
1459 struct class_device *cdev; 1558 struct class_device *cdev;
1460 struct node_entry *ne; 1559 struct node_entry *ne;
1461 1560
@@ -1468,18 +1567,18 @@ static void nodemgr_node_probe(struct host_info *hi, int generation)
1468 * while probes are time-consuming. (Well, those probes need some 1567 * while probes are time-consuming. (Well, those probes need some
1469 * improvement...) */ 1568 * improvement...) */
1470 1569
1471 down_read(&class->subsys.rwsem); 1570 down(&nodemgr_ne_class.sem);
1472 list_for_each_entry(cdev, &class->children, node) { 1571 list_for_each_entry(cdev, &nodemgr_ne_class.children, node) {
1473 ne = container_of(cdev, struct node_entry, class_dev); 1572 ne = container_of(cdev, struct node_entry, class_dev);
1474 if (!ne->needs_probe) 1573 if (!ne->needs_probe)
1475 nodemgr_probe_ne(hi, ne, generation); 1574 nodemgr_probe_ne(hi, ne, generation);
1476 } 1575 }
1477 list_for_each_entry(cdev, &class->children, node) { 1576 list_for_each_entry(cdev, &nodemgr_ne_class.children, node) {
1478 ne = container_of(cdev, struct node_entry, class_dev); 1577 ne = container_of(cdev, struct node_entry, class_dev);
1479 if (ne->needs_probe) 1578 if (ne->needs_probe)
1480 nodemgr_probe_ne(hi, ne, generation); 1579 nodemgr_probe_ne(hi, ne, generation);
1481 } 1580 }
1482 up_read(&class->subsys.rwsem); 1581 up(&nodemgr_ne_class.sem);
1483 1582
1484 1583
1485 /* If we had a bus reset while we were scanning the bus, it is 1584 /* If we had a bus reset while we were scanning the bus, it is
@@ -1497,15 +1596,14 @@ static void nodemgr_node_probe(struct host_info *hi, int generation)
1497 * just removed. */ 1596 * just removed. */
1498 1597
1499 if (generation == get_hpsb_generation(host)) 1598 if (generation == get_hpsb_generation(host))
1500 bus_rescan_devices(&ieee1394_bus_type); 1599 if (bus_rescan_devices(&ieee1394_bus_type))
1501 1600 HPSB_DEBUG("bus_rescan_devices had an error");
1502 return;
1503} 1601}
1504 1602
1505static int nodemgr_send_resume_packet(struct hpsb_host *host) 1603static int nodemgr_send_resume_packet(struct hpsb_host *host)
1506{ 1604{
1507 struct hpsb_packet *packet; 1605 struct hpsb_packet *packet;
1508 int ret = 1; 1606 int error = -ENOMEM;
1509 1607
1510 packet = hpsb_make_phypacket(host, 1608 packet = hpsb_make_phypacket(host,
1511 EXTPHYPACKET_TYPE_RESUME | 1609 EXTPHYPACKET_TYPE_RESUME |
@@ -1513,12 +1611,12 @@ static int nodemgr_send_resume_packet(struct hpsb_host *host)
1513 if (packet) { 1611 if (packet) {
1514 packet->no_waiter = 1; 1612 packet->no_waiter = 1;
1515 packet->generation = get_hpsb_generation(host); 1613 packet->generation = get_hpsb_generation(host);
1516 ret = hpsb_send_packet(packet); 1614 error = hpsb_send_packet(packet);
1517 } 1615 }
1518 if (ret) 1616 if (error)
1519 HPSB_WARN("fw-host%d: Failed to broadcast resume packet", 1617 HPSB_WARN("fw-host%d: Failed to broadcast resume packet",
1520 host->id); 1618 host->id);
1521 return ret; 1619 return error;
1522} 1620}
1523 1621
1524/* Perform a few high-level IRM responsibilities. */ 1622/* Perform a few high-level IRM responsibilities. */
@@ -1691,19 +1789,18 @@ exit:
1691 1789
1692int nodemgr_for_each_host(void *__data, int (*cb)(struct hpsb_host *, void *)) 1790int nodemgr_for_each_host(void *__data, int (*cb)(struct hpsb_host *, void *))
1693{ 1791{
1694 struct class *class = &hpsb_host_class;
1695 struct class_device *cdev; 1792 struct class_device *cdev;
1696 struct hpsb_host *host; 1793 struct hpsb_host *host;
1697 int error = 0; 1794 int error = 0;
1698 1795
1699 down_read(&class->subsys.rwsem); 1796 down(&hpsb_host_class.sem);
1700 list_for_each_entry(cdev, &class->children, node) { 1797 list_for_each_entry(cdev, &hpsb_host_class.children, node) {
1701 host = container_of(cdev, struct hpsb_host, class_dev); 1798 host = container_of(cdev, struct hpsb_host, class_dev);
1702 1799
1703 if ((error = cb(host, __data))) 1800 if ((error = cb(host, __data)))
1704 break; 1801 break;
1705 } 1802 }
1706 up_read(&class->subsys.rwsem); 1803 up(&hpsb_host_class.sem);
1707 1804
1708 return error; 1805 return error;
1709} 1806}
@@ -1725,10 +1822,10 @@ int nodemgr_for_each_host(void *__data, int (*cb)(struct hpsb_host *, void *))
1725 1822
1726void hpsb_node_fill_packet(struct node_entry *ne, struct hpsb_packet *pkt) 1823void hpsb_node_fill_packet(struct node_entry *ne, struct hpsb_packet *pkt)
1727{ 1824{
1728 pkt->host = ne->host; 1825 pkt->host = ne->host;
1729 pkt->generation = ne->generation; 1826 pkt->generation = ne->generation;
1730 barrier(); 1827 barrier();
1731 pkt->node_id = ne->nodeid; 1828 pkt->node_id = ne->nodeid;
1732} 1829}
1733 1830
1734int hpsb_node_write(struct node_entry *ne, u64 addr, 1831int hpsb_node_write(struct node_entry *ne, u64 addr,
@@ -1788,26 +1885,25 @@ static struct hpsb_highlevel nodemgr_highlevel = {
1788 1885
1789int init_ieee1394_nodemgr(void) 1886int init_ieee1394_nodemgr(void)
1790{ 1887{
1791 int ret; 1888 int error;
1792 1889
1793 ret = class_register(&nodemgr_ne_class); 1890 error = class_register(&nodemgr_ne_class);
1794 if (ret < 0) 1891 if (error)
1795 return ret; 1892 return error;
1796 1893
1797 ret = class_register(&nodemgr_ud_class); 1894 error = class_register(&nodemgr_ud_class);
1798 if (ret < 0) { 1895 if (error) {
1799 class_unregister(&nodemgr_ne_class); 1896 class_unregister(&nodemgr_ne_class);
1800 return ret; 1897 return error;
1801 } 1898 }
1802 1899 error = driver_register(&nodemgr_mid_layer_driver);
1803 hpsb_register_highlevel(&nodemgr_highlevel); 1900 hpsb_register_highlevel(&nodemgr_highlevel);
1804
1805 return 0; 1901 return 0;
1806} 1902}
1807 1903
1808void cleanup_ieee1394_nodemgr(void) 1904void cleanup_ieee1394_nodemgr(void)
1809{ 1905{
1810 hpsb_unregister_highlevel(&nodemgr_highlevel); 1906 hpsb_unregister_highlevel(&nodemgr_highlevel);
1811 1907
1812 class_unregister(&nodemgr_ud_class); 1908 class_unregister(&nodemgr_ud_class);
1813 class_unregister(&nodemgr_ne_class); 1909 class_unregister(&nodemgr_ne_class);
diff --git a/drivers/ieee1394/nodemgr.h b/drivers/ieee1394/nodemgr.h
index 0e1e7d930783..e25cbadb8be0 100644
--- a/drivers/ieee1394/nodemgr.h
+++ b/drivers/ieee1394/nodemgr.h
@@ -144,7 +144,12 @@ struct hpsb_protocol_driver {
144 struct device_driver driver; 144 struct device_driver driver;
145}; 145};
146 146
147int hpsb_register_protocol(struct hpsb_protocol_driver *driver); 147int __hpsb_register_protocol(struct hpsb_protocol_driver *, struct module *);
148static inline int hpsb_register_protocol(struct hpsb_protocol_driver *driver)
149{
150 return __hpsb_register_protocol(driver, THIS_MODULE);
151}
152
148void hpsb_unregister_protocol(struct hpsb_protocol_driver *driver); 153void hpsb_unregister_protocol(struct hpsb_protocol_driver *driver);
149 154
150static inline int hpsb_node_entry_valid(struct node_entry *ne) 155static inline int hpsb_node_entry_valid(struct node_entry *ne)
diff --git a/drivers/ieee1394/ohci1394.c b/drivers/ieee1394/ohci1394.c
index 6e8ea9110c46..628130a58af3 100644
--- a/drivers/ieee1394/ohci1394.c
+++ b/drivers/ieee1394/ohci1394.c
@@ -468,7 +468,6 @@ static int get_nb_iso_ctx(struct ti_ohci *ohci, int reg)
468/* Global initialization */ 468/* Global initialization */
469static void ohci_initialize(struct ti_ohci *ohci) 469static void ohci_initialize(struct ti_ohci *ohci)
470{ 470{
471 char irq_buf[16];
472 quadlet_t buf; 471 quadlet_t buf;
473 int num_ports, i; 472 int num_ports, i;
474 473
@@ -586,11 +585,10 @@ static void ohci_initialize(struct ti_ohci *ohci)
586 reg_write(ohci, OHCI1394_HCControlSet, OHCI1394_HCControl_linkEnable); 585 reg_write(ohci, OHCI1394_HCControlSet, OHCI1394_HCControl_linkEnable);
587 586
588 buf = reg_read(ohci, OHCI1394_Version); 587 buf = reg_read(ohci, OHCI1394_Version);
589 sprintf (irq_buf, "%d", ohci->dev->irq); 588 PRINT(KERN_INFO, "OHCI-1394 %d.%d (PCI): IRQ=[%d] "
590 PRINT(KERN_INFO, "OHCI-1394 %d.%d (PCI): IRQ=[%s] "
591 "MMIO=[%llx-%llx] Max Packet=[%d] IR/IT contexts=[%d/%d]", 589 "MMIO=[%llx-%llx] Max Packet=[%d] IR/IT contexts=[%d/%d]",
592 ((((buf) >> 16) & 0xf) + (((buf) >> 20) & 0xf) * 10), 590 ((((buf) >> 16) & 0xf) + (((buf) >> 20) & 0xf) * 10),
593 ((((buf) >> 4) & 0xf) + ((buf) & 0xf) * 10), irq_buf, 591 ((((buf) >> 4) & 0xf) + ((buf) & 0xf) * 10), ohci->dev->irq,
594 (unsigned long long)pci_resource_start(ohci->dev, 0), 592 (unsigned long long)pci_resource_start(ohci->dev, 0),
595 (unsigned long long)pci_resource_start(ohci->dev, 0) + OHCI1394_REGISTER_SIZE - 1, 593 (unsigned long long)pci_resource_start(ohci->dev, 0) + OHCI1394_REGISTER_SIZE - 1,
596 ohci->max_packet_size, 594 ohci->max_packet_size,
@@ -1225,7 +1223,7 @@ static int ohci_iso_recv_init(struct hpsb_iso *iso)
1225 int ctx; 1223 int ctx;
1226 int ret = -ENOMEM; 1224 int ret = -ENOMEM;
1227 1225
1228 recv = kmalloc(sizeof(*recv), SLAB_KERNEL); 1226 recv = kmalloc(sizeof(*recv), GFP_KERNEL);
1229 if (!recv) 1227 if (!recv)
1230 return -ENOMEM; 1228 return -ENOMEM;
1231 1229
@@ -1918,7 +1916,7 @@ static int ohci_iso_xmit_init(struct hpsb_iso *iso)
1918 int ctx; 1916 int ctx;
1919 int ret = -ENOMEM; 1917 int ret = -ENOMEM;
1920 1918
1921 xmit = kmalloc(sizeof(*xmit), SLAB_KERNEL); 1919 xmit = kmalloc(sizeof(*xmit), GFP_KERNEL);
1922 if (!xmit) 1920 if (!xmit)
1923 return -ENOMEM; 1921 return -ENOMEM;
1924 1922
@@ -3021,7 +3019,7 @@ alloc_dma_rcv_ctx(struct ti_ohci *ohci, struct dma_rcv_ctx *d,
3021 return -ENOMEM; 3019 return -ENOMEM;
3022 } 3020 }
3023 3021
3024 d->prg_cpu[i] = pci_pool_alloc(d->prg_pool, SLAB_KERNEL, d->prg_bus+i); 3022 d->prg_cpu[i] = pci_pool_alloc(d->prg_pool, GFP_KERNEL, d->prg_bus+i);
3025 OHCI_DMA_ALLOC("pool dma_rcv prg[%d]", i); 3023 OHCI_DMA_ALLOC("pool dma_rcv prg[%d]", i);
3026 3024
3027 if (d->prg_cpu[i] != NULL) { 3025 if (d->prg_cpu[i] != NULL) {
@@ -3117,7 +3115,7 @@ alloc_dma_trm_ctx(struct ti_ohci *ohci, struct dma_trm_ctx *d,
3117 OHCI_DMA_ALLOC("dma_rcv prg pool"); 3115 OHCI_DMA_ALLOC("dma_rcv prg pool");
3118 3116
3119 for (i = 0; i < d->num_desc; i++) { 3117 for (i = 0; i < d->num_desc; i++) {
3120 d->prg_cpu[i] = pci_pool_alloc(d->prg_pool, SLAB_KERNEL, d->prg_bus+i); 3118 d->prg_cpu[i] = pci_pool_alloc(d->prg_pool, GFP_KERNEL, d->prg_bus+i);
3121 OHCI_DMA_ALLOC("pool dma_trm prg[%d]", i); 3119 OHCI_DMA_ALLOC("pool dma_trm prg[%d]", i);
3122 3120
3123 if (d->prg_cpu[i] != NULL) { 3121 if (d->prg_cpu[i] != NULL) {
@@ -3217,6 +3215,18 @@ static int __devinit ohci1394_pci_probe(struct pci_dev *dev,
3217 struct ti_ohci *ohci; /* shortcut to currently handled device */ 3215 struct ti_ohci *ohci; /* shortcut to currently handled device */
3218 resource_size_t ohci_base; 3216 resource_size_t ohci_base;
3219 3217
3218#ifdef CONFIG_PPC_PMAC
3219 /* Necessary on some machines if ohci1394 was loaded/ unloaded before */
3220 if (machine_is(powermac)) {
3221 struct device_node *ofn = pci_device_to_OF_node(dev);
3222
3223 if (ofn) {
3224 pmac_call_feature(PMAC_FTR_1394_CABLE_POWER, ofn, 0, 1);
3225 pmac_call_feature(PMAC_FTR_1394_ENABLE, ofn, 0, 1);
3226 }
3227 }
3228#endif /* CONFIG_PPC_PMAC */
3229
3220 if (pci_enable_device(dev)) 3230 if (pci_enable_device(dev))
3221 FAIL(-ENXIO, "Failed to enable OHCI hardware"); 3231 FAIL(-ENXIO, "Failed to enable OHCI hardware");
3222 pci_set_master(dev); 3232 pci_set_master(dev);
@@ -3505,17 +3515,14 @@ static void ohci1394_pci_remove(struct pci_dev *pdev)
3505#endif 3515#endif
3506 3516
3507#ifdef CONFIG_PPC_PMAC 3517#ifdef CONFIG_PPC_PMAC
3508 /* On UniNorth, power down the cable and turn off the chip 3518 /* On UniNorth, power down the cable and turn off the chip clock
3509 * clock when the module is removed to save power on 3519 * to save power on laptops */
3510 * laptops. Turning it back ON is done by the arch code when 3520 if (machine_is(powermac)) {
3511 * pci_enable_device() is called */ 3521 struct device_node* ofn = pci_device_to_OF_node(ohci->dev);
3512 {
3513 struct device_node* of_node;
3514 3522
3515 of_node = pci_device_to_OF_node(ohci->dev); 3523 if (ofn) {
3516 if (of_node) { 3524 pmac_call_feature(PMAC_FTR_1394_ENABLE, ofn, 0, 0);
3517 pmac_call_feature(PMAC_FTR_1394_ENABLE, of_node, 0, 0); 3525 pmac_call_feature(PMAC_FTR_1394_CABLE_POWER, ofn, 0, 0);
3518 pmac_call_feature(PMAC_FTR_1394_CABLE_POWER, of_node, 0, 0);
3519 } 3526 }
3520 } 3527 }
3521#endif /* CONFIG_PPC_PMAC */ 3528#endif /* CONFIG_PPC_PMAC */
@@ -3529,59 +3536,102 @@ static void ohci1394_pci_remove(struct pci_dev *pdev)
3529} 3536}
3530 3537
3531#ifdef CONFIG_PM 3538#ifdef CONFIG_PM
3532static int ohci1394_pci_resume (struct pci_dev *pdev) 3539static int ohci1394_pci_suspend(struct pci_dev *pdev, pm_message_t state)
3533{
3534/* PowerMac resume code comes first */
3535#ifdef CONFIG_PPC_PMAC
3536 if (machine_is(powermac)) {
3537 struct device_node *of_node;
3538
3539 /* Re-enable 1394 */
3540 of_node = pci_device_to_OF_node (pdev);
3541 if (of_node)
3542 pmac_call_feature (PMAC_FTR_1394_ENABLE, of_node, 0, 1);
3543 }
3544#endif /* CONFIG_PPC_PMAC */
3545
3546 pci_set_power_state(pdev, PCI_D0);
3547 pci_restore_state(pdev);
3548 return pci_enable_device(pdev);
3549}
3550
3551static int ohci1394_pci_suspend (struct pci_dev *pdev, pm_message_t state)
3552{ 3540{
3553 int err; 3541 int err;
3542 struct ti_ohci *ohci = pci_get_drvdata(pdev);
3554 3543
3555 printk(KERN_INFO "%s does not fully support suspend and resume yet\n", 3544 printk(KERN_INFO "%s does not fully support suspend and resume yet\n",
3556 OHCI1394_DRIVER_NAME); 3545 OHCI1394_DRIVER_NAME);
3557 3546
3547 if (!ohci) {
3548 printk(KERN_ERR "%s: tried to suspend nonexisting host\n",
3549 OHCI1394_DRIVER_NAME);
3550 return -ENXIO;
3551 }
3552 DBGMSG("suspend called");
3553
3554 /* Clear the async DMA contexts and stop using the controller */
3555 hpsb_bus_reset(ohci->host);
3556
3557 /* See ohci1394_pci_remove() for comments on this sequence */
3558 reg_write(ohci, OHCI1394_ConfigROMhdr, 0);
3559 reg_write(ohci, OHCI1394_BusOptions,
3560 (reg_read(ohci, OHCI1394_BusOptions) & 0x0000f007) |
3561 0x00ff0000);
3562 reg_write(ohci, OHCI1394_IntMaskClear, 0xffffffff);
3563 reg_write(ohci, OHCI1394_IntEventClear, 0xffffffff);
3564 reg_write(ohci, OHCI1394_IsoXmitIntMaskClear, 0xffffffff);
3565 reg_write(ohci, OHCI1394_IsoXmitIntEventClear, 0xffffffff);
3566 reg_write(ohci, OHCI1394_IsoRecvIntMaskClear, 0xffffffff);
3567 reg_write(ohci, OHCI1394_IsoRecvIntEventClear, 0xffffffff);
3568 set_phy_reg(ohci, 4, ~0xc0 & get_phy_reg(ohci, 4));
3569 reg_write(ohci, OHCI1394_LinkControlClear, 0xffffffff);
3570 ohci_devctl(ohci->host, RESET_BUS, LONG_RESET_NO_FORCE_ROOT);
3571 ohci_soft_reset(ohci);
3572
3558 err = pci_save_state(pdev); 3573 err = pci_save_state(pdev);
3559 if (err) { 3574 if (err) {
3560 printk(KERN_ERR "%s: pci_save_state failed with %d\n", 3575 PRINT(KERN_ERR, "pci_save_state failed with %d", err);
3561 OHCI1394_DRIVER_NAME, err);
3562 return err; 3576 return err;
3563 } 3577 }
3564 err = pci_set_power_state(pdev, pci_choose_state(pdev, state)); 3578 err = pci_set_power_state(pdev, pci_choose_state(pdev, state));
3565#ifdef OHCI1394_DEBUG
3566 if (err) 3579 if (err)
3567 printk(KERN_DEBUG "%s: pci_set_power_state failed with %d\n", 3580 DBGMSG("pci_set_power_state failed with %d", err);
3568 OHCI1394_DRIVER_NAME, err);
3569#endif /* OHCI1394_DEBUG */
3570 3581
3571/* PowerMac suspend code comes last */ 3582/* PowerMac suspend code comes last */
3572#ifdef CONFIG_PPC_PMAC 3583#ifdef CONFIG_PPC_PMAC
3573 if (machine_is(powermac)) { 3584 if (machine_is(powermac)) {
3574 struct device_node *of_node; 3585 struct device_node *ofn = pci_device_to_OF_node(pdev);
3575 3586
3576 /* Disable 1394 */ 3587 if (ofn)
3577 of_node = pci_device_to_OF_node (pdev); 3588 pmac_call_feature(PMAC_FTR_1394_ENABLE, ofn, 0, 0);
3578 if (of_node)
3579 pmac_call_feature(PMAC_FTR_1394_ENABLE, of_node, 0, 0);
3580 } 3589 }
3581#endif /* CONFIG_PPC_PMAC */ 3590#endif /* CONFIG_PPC_PMAC */
3582 3591
3583 return 0; 3592 return 0;
3584} 3593}
3594
3595static int ohci1394_pci_resume(struct pci_dev *pdev)
3596{
3597 int err;
3598 struct ti_ohci *ohci = pci_get_drvdata(pdev);
3599
3600 if (!ohci) {
3601 printk(KERN_ERR "%s: tried to resume nonexisting host\n",
3602 OHCI1394_DRIVER_NAME);
3603 return -ENXIO;
3604 }
3605 DBGMSG("resume called");
3606
3607/* PowerMac resume code comes first */
3608#ifdef CONFIG_PPC_PMAC
3609 if (machine_is(powermac)) {
3610 struct device_node *ofn = pci_device_to_OF_node(pdev);
3611
3612 if (ofn)
3613 pmac_call_feature(PMAC_FTR_1394_ENABLE, ofn, 0, 1);
3614 }
3615#endif /* CONFIG_PPC_PMAC */
3616
3617 pci_set_power_state(pdev, PCI_D0);
3618 pci_restore_state(pdev);
3619 err = pci_enable_device(pdev);
3620 if (err) {
3621 PRINT(KERN_ERR, "pci_enable_device failed with %d", err);
3622 return err;
3623 }
3624
3625 /* See ohci1394_pci_probe() for comments on this sequence */
3626 ohci_soft_reset(ohci);
3627 reg_write(ohci, OHCI1394_HCControlSet, OHCI1394_HCControl_LPS);
3628 reg_write(ohci, OHCI1394_IntEventClear, 0xffffffff);
3629 reg_write(ohci, OHCI1394_IntMaskClear, 0xffffffff);
3630 mdelay(50);
3631 ohci_initialize(ohci);
3632
3633 return 0;
3634}
3585#endif /* CONFIG_PM */ 3635#endif /* CONFIG_PM */
3586 3636
3587#define PCI_CLASS_FIREWIRE_OHCI ((PCI_CLASS_SERIAL_FIREWIRE << 8) | 0x10) 3637#define PCI_CLASS_FIREWIRE_OHCI ((PCI_CLASS_SERIAL_FIREWIRE << 8) | 0x10)
diff --git a/drivers/ieee1394/pcilynx.c b/drivers/ieee1394/pcilynx.c
index 0a7412e27eb4..13a617917bf2 100644
--- a/drivers/ieee1394/pcilynx.c
+++ b/drivers/ieee1394/pcilynx.c
@@ -1428,10 +1428,9 @@ static int __devinit add_card(struct pci_dev *dev,
1428 struct i2c_algo_bit_data i2c_adapter_data; 1428 struct i2c_algo_bit_data i2c_adapter_data;
1429 1429
1430 error = -ENOMEM; 1430 error = -ENOMEM;
1431 i2c_ad = kmalloc(sizeof(*i2c_ad), SLAB_KERNEL); 1431 i2c_ad = kmemdup(&bit_ops, sizeof(*i2c_ad), GFP_KERNEL);
1432 if (!i2c_ad) FAIL("failed to allocate I2C adapter memory"); 1432 if (!i2c_ad) FAIL("failed to allocate I2C adapter memory");
1433 1433
1434 memcpy(i2c_ad, &bit_ops, sizeof(struct i2c_adapter));
1435 i2c_adapter_data = bit_data; 1434 i2c_adapter_data = bit_data;
1436 i2c_ad->algo_data = &i2c_adapter_data; 1435 i2c_ad->algo_data = &i2c_adapter_data;
1437 i2c_adapter_data.data = lynx; 1436 i2c_adapter_data.data = lynx;
diff --git a/drivers/ieee1394/raw1394-private.h b/drivers/ieee1394/raw1394-private.h
index c7731d1bcd89..50daabf6e5fa 100644
--- a/drivers/ieee1394/raw1394-private.h
+++ b/drivers/ieee1394/raw1394-private.h
@@ -27,12 +27,12 @@ struct file_info {
27 27
28 struct hpsb_host *host; 28 struct hpsb_host *host;
29 29
30 struct list_head req_pending; 30 struct list_head req_pending; /* protected by reqlists_lock */
31 struct list_head req_complete; 31 struct list_head req_complete; /* protected by reqlists_lock */
32 spinlock_t reqlists_lock; 32 spinlock_t reqlists_lock;
33 wait_queue_head_t wait_complete; 33 wait_queue_head_t wait_complete;
34 34
35 struct list_head addr_list; 35 struct list_head addr_list; /* protected by host_info_lock */
36 36
37 u8 __user *fcp_buffer; 37 u8 __user *fcp_buffer;
38 38
@@ -63,7 +63,7 @@ struct arm_addr {
63 u8 client_transactions; 63 u8 client_transactions;
64 u64 recvb; 64 u64 recvb;
65 u16 rec_length; 65 u16 rec_length;
66 u8 *addr_space_buffer; /* accessed by read/write/lock */ 66 u8 *addr_space_buffer; /* accessed by read/write/lock requests */
67}; 67};
68 68
69struct pending_request { 69struct pending_request {
@@ -79,7 +79,7 @@ struct pending_request {
79struct host_info { 79struct host_info {
80 struct list_head list; 80 struct list_head list;
81 struct hpsb_host *host; 81 struct hpsb_host *host;
82 struct list_head file_info_list; 82 struct list_head file_info_list; /* protected by host_info_lock */
83}; 83};
84 84
85#endif /* IEEE1394_RAW1394_PRIVATE_H */ 85#endif /* IEEE1394_RAW1394_PRIVATE_H */
diff --git a/drivers/ieee1394/raw1394.c b/drivers/ieee1394/raw1394.c
index 5ec4f5eb6b19..ad2108f27a04 100644
--- a/drivers/ieee1394/raw1394.c
+++ b/drivers/ieee1394/raw1394.c
@@ -99,6 +99,21 @@ static struct hpsb_address_ops arm_ops = {
99 99
100static void queue_complete_cb(struct pending_request *req); 100static void queue_complete_cb(struct pending_request *req);
101 101
102#include <asm/current.h>
103static void print_old_iso_deprecation(void)
104{
105 static pid_t p;
106
107 if (p == current->pid)
108 return;
109 p = current->pid;
110 printk(KERN_WARNING "raw1394: WARNING - Program \"%s\" uses unsupported"
111 " isochronous request types which will be removed in a next"
112 " kernel release\n", current->comm);
113 printk(KERN_WARNING "raw1394: Update your software to use libraw1394's"
114 " newer interface\n");
115}
116
102static struct pending_request *__alloc_pending_request(gfp_t flags) 117static struct pending_request *__alloc_pending_request(gfp_t flags)
103{ 118{
104 struct pending_request *req; 119 struct pending_request *req;
@@ -112,7 +127,7 @@ static struct pending_request *__alloc_pending_request(gfp_t flags)
112 127
113static inline struct pending_request *alloc_pending_request(void) 128static inline struct pending_request *alloc_pending_request(void)
114{ 129{
115 return __alloc_pending_request(SLAB_KERNEL); 130 return __alloc_pending_request(GFP_KERNEL);
116} 131}
117 132
118static void free_pending_request(struct pending_request *req) 133static void free_pending_request(struct pending_request *req)
@@ -259,7 +274,7 @@ static void host_reset(struct hpsb_host *host)
259 if (hi != NULL) { 274 if (hi != NULL) {
260 list_for_each_entry(fi, &hi->file_info_list, list) { 275 list_for_each_entry(fi, &hi->file_info_list, list) {
261 if (fi->notification == RAW1394_NOTIFY_ON) { 276 if (fi->notification == RAW1394_NOTIFY_ON) {
262 req = __alloc_pending_request(SLAB_ATOMIC); 277 req = __alloc_pending_request(GFP_ATOMIC);
263 278
264 if (req != NULL) { 279 if (req != NULL) {
265 req->file_info = fi; 280 req->file_info = fi;
@@ -306,13 +321,13 @@ static void iso_receive(struct hpsb_host *host, int channel, quadlet_t * data,
306 if (!(fi->listen_channels & (1ULL << channel))) 321 if (!(fi->listen_channels & (1ULL << channel)))
307 continue; 322 continue;
308 323
309 req = __alloc_pending_request(SLAB_ATOMIC); 324 req = __alloc_pending_request(GFP_ATOMIC);
310 if (!req) 325 if (!req)
311 break; 326 break;
312 327
313 if (!ibs) { 328 if (!ibs) {
314 ibs = kmalloc(sizeof(*ibs) + length, 329 ibs = kmalloc(sizeof(*ibs) + length,
315 SLAB_ATOMIC); 330 GFP_ATOMIC);
316 if (!ibs) { 331 if (!ibs) {
317 kfree(req); 332 kfree(req);
318 break; 333 break;
@@ -367,13 +382,13 @@ static void fcp_request(struct hpsb_host *host, int nodeid, int direction,
367 if (!fi->fcp_buffer) 382 if (!fi->fcp_buffer)
368 continue; 383 continue;
369 384
370 req = __alloc_pending_request(SLAB_ATOMIC); 385 req = __alloc_pending_request(GFP_ATOMIC);
371 if (!req) 386 if (!req)
372 break; 387 break;
373 388
374 if (!ibs) { 389 if (!ibs) {
375 ibs = kmalloc(sizeof(*ibs) + length, 390 ibs = kmalloc(sizeof(*ibs) + length,
376 SLAB_ATOMIC); 391 GFP_ATOMIC);
377 if (!ibs) { 392 if (!ibs) {
378 kfree(req); 393 kfree(req);
379 break; 394 break;
@@ -593,7 +608,7 @@ static int state_initialized(struct file_info *fi, struct pending_request *req)
593 switch (req->req.type) { 608 switch (req->req.type) {
594 case RAW1394_REQ_LIST_CARDS: 609 case RAW1394_REQ_LIST_CARDS:
595 spin_lock_irqsave(&host_info_lock, flags); 610 spin_lock_irqsave(&host_info_lock, flags);
596 khl = kmalloc(sizeof(*khl) * host_count, SLAB_ATOMIC); 611 khl = kmalloc(sizeof(*khl) * host_count, GFP_ATOMIC);
597 612
598 if (khl) { 613 if (khl) {
599 req->req.misc = host_count; 614 req->req.misc = host_count;
@@ -1045,7 +1060,7 @@ static int arm_read(struct hpsb_host *host, int nodeid, quadlet_t * buffer,
1045 } 1060 }
1046 if (arm_addr->notification_options & ARM_READ) { 1061 if (arm_addr->notification_options & ARM_READ) {
1047 DBGMSG("arm_read -> entering notification-section"); 1062 DBGMSG("arm_read -> entering notification-section");
1048 req = __alloc_pending_request(SLAB_ATOMIC); 1063 req = __alloc_pending_request(GFP_ATOMIC);
1049 if (!req) { 1064 if (!req) {
1050 DBGMSG("arm_read -> rcode_conflict_error"); 1065 DBGMSG("arm_read -> rcode_conflict_error");
1051 spin_unlock_irqrestore(&host_info_lock, irqflags); 1066 spin_unlock_irqrestore(&host_info_lock, irqflags);
@@ -1064,7 +1079,7 @@ static int arm_read(struct hpsb_host *host, int nodeid, quadlet_t * buffer,
1064 sizeof(struct arm_response) + 1079 sizeof(struct arm_response) +
1065 sizeof(struct arm_request_response); 1080 sizeof(struct arm_request_response);
1066 } 1081 }
1067 req->data = kmalloc(size, SLAB_ATOMIC); 1082 req->data = kmalloc(size, GFP_ATOMIC);
1068 if (!(req->data)) { 1083 if (!(req->data)) {
1069 free_pending_request(req); 1084 free_pending_request(req);
1070 DBGMSG("arm_read -> rcode_conflict_error"); 1085 DBGMSG("arm_read -> rcode_conflict_error");
@@ -1198,7 +1213,7 @@ static int arm_write(struct hpsb_host *host, int nodeid, int destid,
1198 } 1213 }
1199 if (arm_addr->notification_options & ARM_WRITE) { 1214 if (arm_addr->notification_options & ARM_WRITE) {
1200 DBGMSG("arm_write -> entering notification-section"); 1215 DBGMSG("arm_write -> entering notification-section");
1201 req = __alloc_pending_request(SLAB_ATOMIC); 1216 req = __alloc_pending_request(GFP_ATOMIC);
1202 if (!req) { 1217 if (!req) {
1203 DBGMSG("arm_write -> rcode_conflict_error"); 1218 DBGMSG("arm_write -> rcode_conflict_error");
1204 spin_unlock_irqrestore(&host_info_lock, irqflags); 1219 spin_unlock_irqrestore(&host_info_lock, irqflags);
@@ -1209,7 +1224,7 @@ static int arm_write(struct hpsb_host *host, int nodeid, int destid,
1209 sizeof(struct arm_request) + sizeof(struct arm_response) + 1224 sizeof(struct arm_request) + sizeof(struct arm_response) +
1210 (length) * sizeof(byte_t) + 1225 (length) * sizeof(byte_t) +
1211 sizeof(struct arm_request_response); 1226 sizeof(struct arm_request_response);
1212 req->data = kmalloc(size, SLAB_ATOMIC); 1227 req->data = kmalloc(size, GFP_ATOMIC);
1213 if (!(req->data)) { 1228 if (!(req->data)) {
1214 free_pending_request(req); 1229 free_pending_request(req);
1215 DBGMSG("arm_write -> rcode_conflict_error"); 1230 DBGMSG("arm_write -> rcode_conflict_error");
@@ -1400,7 +1415,7 @@ static int arm_lock(struct hpsb_host *host, int nodeid, quadlet_t * store,
1400 if (arm_addr->notification_options & ARM_LOCK) { 1415 if (arm_addr->notification_options & ARM_LOCK) {
1401 byte_t *buf1, *buf2; 1416 byte_t *buf1, *buf2;
1402 DBGMSG("arm_lock -> entering notification-section"); 1417 DBGMSG("arm_lock -> entering notification-section");
1403 req = __alloc_pending_request(SLAB_ATOMIC); 1418 req = __alloc_pending_request(GFP_ATOMIC);
1404 if (!req) { 1419 if (!req) {
1405 DBGMSG("arm_lock -> rcode_conflict_error"); 1420 DBGMSG("arm_lock -> rcode_conflict_error");
1406 spin_unlock_irqrestore(&host_info_lock, irqflags); 1421 spin_unlock_irqrestore(&host_info_lock, irqflags);
@@ -1408,7 +1423,7 @@ static int arm_lock(struct hpsb_host *host, int nodeid, quadlet_t * store,
1408 The request may be retried */ 1423 The request may be retried */
1409 } 1424 }
1410 size = sizeof(struct arm_request) + sizeof(struct arm_response) + 3 * sizeof(*store) + sizeof(struct arm_request_response); /* maximum */ 1425 size = sizeof(struct arm_request) + sizeof(struct arm_response) + 3 * sizeof(*store) + sizeof(struct arm_request_response); /* maximum */
1411 req->data = kmalloc(size, SLAB_ATOMIC); 1426 req->data = kmalloc(size, GFP_ATOMIC);
1412 if (!(req->data)) { 1427 if (!(req->data)) {
1413 free_pending_request(req); 1428 free_pending_request(req);
1414 DBGMSG("arm_lock -> rcode_conflict_error"); 1429 DBGMSG("arm_lock -> rcode_conflict_error");
@@ -1628,7 +1643,7 @@ static int arm_lock64(struct hpsb_host *host, int nodeid, octlet_t * store,
1628 if (arm_addr->notification_options & ARM_LOCK) { 1643 if (arm_addr->notification_options & ARM_LOCK) {
1629 byte_t *buf1, *buf2; 1644 byte_t *buf1, *buf2;
1630 DBGMSG("arm_lock64 -> entering notification-section"); 1645 DBGMSG("arm_lock64 -> entering notification-section");
1631 req = __alloc_pending_request(SLAB_ATOMIC); 1646 req = __alloc_pending_request(GFP_ATOMIC);
1632 if (!req) { 1647 if (!req) {
1633 spin_unlock_irqrestore(&host_info_lock, irqflags); 1648 spin_unlock_irqrestore(&host_info_lock, irqflags);
1634 DBGMSG("arm_lock64 -> rcode_conflict_error"); 1649 DBGMSG("arm_lock64 -> rcode_conflict_error");
@@ -1636,7 +1651,7 @@ static int arm_lock64(struct hpsb_host *host, int nodeid, octlet_t * store,
1636 The request may be retried */ 1651 The request may be retried */
1637 } 1652 }
1638 size = sizeof(struct arm_request) + sizeof(struct arm_response) + 3 * sizeof(*store) + sizeof(struct arm_request_response); /* maximum */ 1653 size = sizeof(struct arm_request) + sizeof(struct arm_response) + 3 * sizeof(*store) + sizeof(struct arm_request_response); /* maximum */
1639 req->data = kmalloc(size, SLAB_ATOMIC); 1654 req->data = kmalloc(size, GFP_ATOMIC);
1640 if (!(req->data)) { 1655 if (!(req->data)) {
1641 free_pending_request(req); 1656 free_pending_request(req);
1642 spin_unlock_irqrestore(&host_info_lock, irqflags); 1657 spin_unlock_irqrestore(&host_info_lock, irqflags);
@@ -1737,7 +1752,7 @@ static int arm_register(struct file_info *fi, struct pending_request *req)
1737 return (-EINVAL); 1752 return (-EINVAL);
1738 } 1753 }
1739 /* addr-list-entry for fileinfo */ 1754 /* addr-list-entry for fileinfo */
1740 addr = kmalloc(sizeof(*addr), SLAB_KERNEL); 1755 addr = kmalloc(sizeof(*addr), GFP_KERNEL);
1741 if (!addr) { 1756 if (!addr) {
1742 req->req.length = 0; 1757 req->req.length = 0;
1743 return (-ENOMEM); 1758 return (-ENOMEM);
@@ -2103,7 +2118,7 @@ static int write_phypacket(struct file_info *fi, struct pending_request *req)
2103static int get_config_rom(struct file_info *fi, struct pending_request *req) 2118static int get_config_rom(struct file_info *fi, struct pending_request *req)
2104{ 2119{
2105 int ret = sizeof(struct raw1394_request); 2120 int ret = sizeof(struct raw1394_request);
2106 quadlet_t *data = kmalloc(req->req.length, SLAB_KERNEL); 2121 quadlet_t *data = kmalloc(req->req.length, GFP_KERNEL);
2107 int status; 2122 int status;
2108 2123
2109 if (!data) 2124 if (!data)
@@ -2133,7 +2148,7 @@ static int get_config_rom(struct file_info *fi, struct pending_request *req)
2133static int update_config_rom(struct file_info *fi, struct pending_request *req) 2148static int update_config_rom(struct file_info *fi, struct pending_request *req)
2134{ 2149{
2135 int ret = sizeof(struct raw1394_request); 2150 int ret = sizeof(struct raw1394_request);
2136 quadlet_t *data = kmalloc(req->req.length, SLAB_KERNEL); 2151 quadlet_t *data = kmalloc(req->req.length, GFP_KERNEL);
2137 if (!data) 2152 if (!data)
2138 return -ENOMEM; 2153 return -ENOMEM;
2139 if (copy_from_user(data, int2ptr(req->req.sendb), req->req.length)) { 2154 if (copy_from_user(data, int2ptr(req->req.sendb), req->req.length)) {
@@ -2292,6 +2307,7 @@ static int state_connected(struct file_info *fi, struct pending_request *req)
2292 return sizeof(struct raw1394_request); 2307 return sizeof(struct raw1394_request);
2293 2308
2294 case RAW1394_REQ_ISO_SEND: 2309 case RAW1394_REQ_ISO_SEND:
2310 print_old_iso_deprecation();
2295 return handle_iso_send(fi, req, node); 2311 return handle_iso_send(fi, req, node);
2296 2312
2297 case RAW1394_REQ_ARM_REGISTER: 2313 case RAW1394_REQ_ARM_REGISTER:
@@ -2310,6 +2326,7 @@ static int state_connected(struct file_info *fi, struct pending_request *req)
2310 return reset_notification(fi, req); 2326 return reset_notification(fi, req);
2311 2327
2312 case RAW1394_REQ_ISO_LISTEN: 2328 case RAW1394_REQ_ISO_LISTEN:
2329 print_old_iso_deprecation();
2313 handle_iso_listen(fi, req); 2330 handle_iso_listen(fi, req);
2314 return sizeof(struct raw1394_request); 2331 return sizeof(struct raw1394_request);
2315 2332
@@ -2443,7 +2460,7 @@ static void queue_rawiso_event(struct file_info *fi)
2443 /* only one ISO activity event may be in the queue */ 2460 /* only one ISO activity event may be in the queue */
2444 if (!__rawiso_event_in_queue(fi)) { 2461 if (!__rawiso_event_in_queue(fi)) {
2445 struct pending_request *req = 2462 struct pending_request *req =
2446 __alloc_pending_request(SLAB_ATOMIC); 2463 __alloc_pending_request(GFP_ATOMIC);
2447 2464
2448 if (req) { 2465 if (req) {
2449 req->file_info = fi; 2466 req->file_info = fi;
@@ -2779,7 +2796,7 @@ static int raw1394_open(struct inode *inode, struct file *file)
2779{ 2796{
2780 struct file_info *fi; 2797 struct file_info *fi;
2781 2798
2782 fi = kzalloc(sizeof(*fi), SLAB_KERNEL); 2799 fi = kzalloc(sizeof(*fi), GFP_KERNEL);
2783 if (!fi) 2800 if (!fi)
2784 return -ENOMEM; 2801 return -ENOMEM;
2785 2802
@@ -2970,12 +2987,8 @@ static struct ieee1394_device_id raw1394_id_table[] = {
2970MODULE_DEVICE_TABLE(ieee1394, raw1394_id_table); 2987MODULE_DEVICE_TABLE(ieee1394, raw1394_id_table);
2971 2988
2972static struct hpsb_protocol_driver raw1394_driver = { 2989static struct hpsb_protocol_driver raw1394_driver = {
2973 .name = "raw1394 Driver", 2990 .name = "raw1394",
2974 .id_table = raw1394_id_table, 2991 .id_table = raw1394_id_table,
2975 .driver = {
2976 .name = "raw1394",
2977 .bus = &ieee1394_bus_type,
2978 },
2979}; 2992};
2980 2993
2981/******************************************************************************/ 2994/******************************************************************************/
diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c
index 6986ac188281..e68b80b7340d 100644
--- a/drivers/ieee1394/sbp2.c
+++ b/drivers/ieee1394/sbp2.c
@@ -29,13 +29,26 @@
29 * driver. It also registers as a SCSI lower-level driver in order to accept 29 * driver. It also registers as a SCSI lower-level driver in order to accept
30 * SCSI commands for transport using SBP-2. 30 * SCSI commands for transport using SBP-2.
31 * 31 *
32 * You may access any attached SBP-2 storage devices as if they were SCSI 32 * You may access any attached SBP-2 (usually storage devices) as regular
33 * devices (e.g. mount /dev/sda1, fdisk, mkfs, etc.). 33 * SCSI devices. E.g. mount /dev/sda1, fdisk, mkfs, etc..
34 * 34 *
35 * Current Issues: 35 * See http://www.t10.org/drafts.htm#sbp2 for the final draft of the SBP-2
36 * specification and for where to purchase the official standard.
36 * 37 *
37 * - Error Handling: SCSI aborts and bus reset requests are handled somewhat 38 * TODO:
38 * but the code needs additional debugging. 39 * - look into possible improvements of the SCSI error handlers
40 * - handle Unit_Characteristics.mgt_ORB_timeout and .ORB_size
41 * - handle Logical_Unit_Number.ordered
42 * - handle src == 1 in status blocks
43 * - reimplement the DMA mapping in absence of physical DMA so that
44 * bus_to_virt is no longer required
45 * - debug the handling of absent physical DMA
46 * - replace CONFIG_IEEE1394_SBP2_PHYS_DMA by automatic detection
47 * (this is easy but depends on the previous two TODO items)
48 * - make the parameter serialize_io configurable per device
49 * - move all requests to fetch agent registers into non-atomic context,
50 * replace all usages of sbp2util_node_write_no_wait by true transactions
51 * Grep for inline FIXME comments below.
39 */ 52 */
40 53
41#include <linux/blkdev.h> 54#include <linux/blkdev.h>
@@ -49,7 +62,6 @@
49#include <linux/list.h> 62#include <linux/list.h>
50#include <linux/module.h> 63#include <linux/module.h>
51#include <linux/moduleparam.h> 64#include <linux/moduleparam.h>
52#include <linux/pci.h>
53#include <linux/slab.h> 65#include <linux/slab.h>
54#include <linux/spinlock.h> 66#include <linux/spinlock.h>
55#include <linux/stat.h> 67#include <linux/stat.h>
@@ -98,20 +110,20 @@
98 * (probably due to PCI latency/throughput issues with the part). You can 110 * (probably due to PCI latency/throughput issues with the part). You can
99 * bump down the speed if you are running into problems. 111 * bump down the speed if you are running into problems.
100 */ 112 */
101static int max_speed = IEEE1394_SPEED_MAX; 113static int sbp2_max_speed = IEEE1394_SPEED_MAX;
102module_param(max_speed, int, 0644); 114module_param_named(max_speed, sbp2_max_speed, int, 0644);
103MODULE_PARM_DESC(max_speed, "Force max speed (3 = 800mb, 2 = 400mb, 1 = 200mb, 0 = 100mb)"); 115MODULE_PARM_DESC(max_speed, "Force max speed "
116 "(3 = 800Mb/s, 2 = 400Mb/s, 1 = 200Mb/s, 0 = 100Mb/s)");
104 117
105/* 118/*
106 * Set serialize_io to 1 if you'd like only one scsi command sent 119 * Set serialize_io to 1 if you'd like only one scsi command sent
107 * down to us at a time (debugging). This might be necessary for very 120 * down to us at a time (debugging). This might be necessary for very
108 * badly behaved sbp2 devices. 121 * badly behaved sbp2 devices.
109 *
110 * TODO: Make this configurable per device.
111 */ 122 */
112static int serialize_io = 1; 123static int sbp2_serialize_io = 1;
113module_param(serialize_io, int, 0444); 124module_param_named(serialize_io, sbp2_serialize_io, int, 0444);
114MODULE_PARM_DESC(serialize_io, "Serialize I/O coming from scsi drivers (default = 1, faster = 0)"); 125MODULE_PARM_DESC(serialize_io, "Serialize I/O coming from scsi drivers "
126 "(default = 1, faster = 0)");
115 127
116/* 128/*
117 * Bump up max_sectors if you'd like to support very large sized 129 * Bump up max_sectors if you'd like to support very large sized
@@ -121,10 +133,10 @@ MODULE_PARM_DESC(serialize_io, "Serialize I/O coming from scsi drivers (default
121 * the Oxsemi sbp2 chipsets have no problems supporting very large 133 * the Oxsemi sbp2 chipsets have no problems supporting very large
122 * transfer sizes. 134 * transfer sizes.
123 */ 135 */
124static int max_sectors = SBP2_MAX_SECTORS; 136static int sbp2_max_sectors = SBP2_MAX_SECTORS;
125module_param(max_sectors, int, 0444); 137module_param_named(max_sectors, sbp2_max_sectors, int, 0444);
126MODULE_PARM_DESC(max_sectors, "Change max sectors per I/O supported (default = " 138MODULE_PARM_DESC(max_sectors, "Change max sectors per I/O supported "
127 __stringify(SBP2_MAX_SECTORS) ")"); 139 "(default = " __stringify(SBP2_MAX_SECTORS) ")");
128 140
129/* 141/*
130 * Exclusive login to sbp2 device? In most cases, the sbp2 driver should 142 * Exclusive login to sbp2 device? In most cases, the sbp2 driver should
@@ -139,9 +151,10 @@ MODULE_PARM_DESC(max_sectors, "Change max sectors per I/O supported (default = "
139 * concurrent logins. Depending on firmware, four or two concurrent logins 151 * concurrent logins. Depending on firmware, four or two concurrent logins
140 * are possible on OXFW911 and newer Oxsemi bridges. 152 * are possible on OXFW911 and newer Oxsemi bridges.
141 */ 153 */
142static int exclusive_login = 1; 154static int sbp2_exclusive_login = 1;
143module_param(exclusive_login, int, 0644); 155module_param_named(exclusive_login, sbp2_exclusive_login, int, 0644);
144MODULE_PARM_DESC(exclusive_login, "Exclusive login to sbp2 device (default = 1)"); 156MODULE_PARM_DESC(exclusive_login, "Exclusive login to sbp2 device "
157 "(default = 1)");
145 158
146/* 159/*
147 * If any of the following workarounds is required for your device to work, 160 * If any of the following workarounds is required for your device to work,
@@ -179,123 +192,123 @@ MODULE_PARM_DESC(workarounds, "Work around device bugs (default = 0"
179 ", override internal blacklist = " __stringify(SBP2_WORKAROUND_OVERRIDE) 192 ", override internal blacklist = " __stringify(SBP2_WORKAROUND_OVERRIDE)
180 ", or a combination)"); 193 ", or a combination)");
181 194
182/*
183 * Export information about protocols/devices supported by this driver.
184 */
185static struct ieee1394_device_id sbp2_id_table[] = {
186 {
187 .match_flags = IEEE1394_MATCH_SPECIFIER_ID | IEEE1394_MATCH_VERSION,
188 .specifier_id = SBP2_UNIT_SPEC_ID_ENTRY & 0xffffff,
189 .version = SBP2_SW_VERSION_ENTRY & 0xffffff},
190 {}
191};
192
193MODULE_DEVICE_TABLE(ieee1394, sbp2_id_table);
194
195/*
196 * Debug levels, configured via kernel config, or enable here.
197 */
198
199#define CONFIG_IEEE1394_SBP2_DEBUG 0
200/* #define CONFIG_IEEE1394_SBP2_DEBUG_ORBS */
201/* #define CONFIG_IEEE1394_SBP2_DEBUG_DMA */
202/* #define CONFIG_IEEE1394_SBP2_DEBUG 1 */
203/* #define CONFIG_IEEE1394_SBP2_DEBUG 2 */
204/* #define CONFIG_IEEE1394_SBP2_PACKET_DUMP */
205
206#ifdef CONFIG_IEEE1394_SBP2_DEBUG_ORBS
207#define SBP2_ORB_DEBUG(fmt, args...) HPSB_ERR("sbp2(%s): "fmt, __FUNCTION__, ## args)
208static u32 global_outstanding_command_orbs = 0;
209#define outstanding_orb_incr global_outstanding_command_orbs++
210#define outstanding_orb_decr global_outstanding_command_orbs--
211#else
212#define SBP2_ORB_DEBUG(fmt, args...) do {} while (0)
213#define outstanding_orb_incr do {} while (0)
214#define outstanding_orb_decr do {} while (0)
215#endif
216
217#ifdef CONFIG_IEEE1394_SBP2_DEBUG_DMA
218#define SBP2_DMA_ALLOC(fmt, args...) \
219 HPSB_ERR("sbp2(%s)alloc(%d): "fmt, __FUNCTION__, \
220 ++global_outstanding_dmas, ## args)
221#define SBP2_DMA_FREE(fmt, args...) \
222 HPSB_ERR("sbp2(%s)free(%d): "fmt, __FUNCTION__, \
223 --global_outstanding_dmas, ## args)
224static u32 global_outstanding_dmas = 0;
225#else
226#define SBP2_DMA_ALLOC(fmt, args...) do {} while (0)
227#define SBP2_DMA_FREE(fmt, args...) do {} while (0)
228#endif
229 195
230#if CONFIG_IEEE1394_SBP2_DEBUG >= 2 196#define SBP2_INFO(fmt, args...) HPSB_INFO("sbp2: "fmt, ## args)
231#define SBP2_DEBUG(fmt, args...) HPSB_ERR("sbp2: "fmt, ## args) 197#define SBP2_ERR(fmt, args...) HPSB_ERR("sbp2: "fmt, ## args)
232#define SBP2_INFO(fmt, args...) HPSB_ERR("sbp2: "fmt, ## args)
233#define SBP2_NOTICE(fmt, args...) HPSB_ERR("sbp2: "fmt, ## args)
234#define SBP2_WARN(fmt, args...) HPSB_ERR("sbp2: "fmt, ## args)
235#elif CONFIG_IEEE1394_SBP2_DEBUG == 1
236#define SBP2_DEBUG(fmt, args...) HPSB_DEBUG("sbp2: "fmt, ## args)
237#define SBP2_INFO(fmt, args...) HPSB_INFO("sbp2: "fmt, ## args)
238#define SBP2_NOTICE(fmt, args...) HPSB_NOTICE("sbp2: "fmt, ## args)
239#define SBP2_WARN(fmt, args...) HPSB_WARN("sbp2: "fmt, ## args)
240#else
241#define SBP2_DEBUG(fmt, args...) do {} while (0)
242#define SBP2_INFO(fmt, args...) HPSB_INFO("sbp2: "fmt, ## args)
243#define SBP2_NOTICE(fmt, args...) HPSB_NOTICE("sbp2: "fmt, ## args)
244#define SBP2_WARN(fmt, args...) HPSB_WARN("sbp2: "fmt, ## args)
245#endif
246
247#define SBP2_ERR(fmt, args...) HPSB_ERR("sbp2: "fmt, ## args)
248#define SBP2_DEBUG_ENTER() SBP2_DEBUG("%s", __FUNCTION__)
249 198
250/* 199/*
251 * Globals 200 * Globals
252 */ 201 */
202static void sbp2scsi_complete_all_commands(struct sbp2_lu *, u32);
203static void sbp2scsi_complete_command(struct sbp2_lu *, u32, struct scsi_cmnd *,
204 void (*)(struct scsi_cmnd *));
205static struct sbp2_lu *sbp2_alloc_device(struct unit_directory *);
206static int sbp2_start_device(struct sbp2_lu *);
207static void sbp2_remove_device(struct sbp2_lu *);
208static int sbp2_login_device(struct sbp2_lu *);
209static int sbp2_reconnect_device(struct sbp2_lu *);
210static int sbp2_logout_device(struct sbp2_lu *);
211static void sbp2_host_reset(struct hpsb_host *);
212static int sbp2_handle_status_write(struct hpsb_host *, int, int, quadlet_t *,
213 u64, size_t, u16);
214static int sbp2_agent_reset(struct sbp2_lu *, int);
215static void sbp2_parse_unit_directory(struct sbp2_lu *,
216 struct unit_directory *);
217static int sbp2_set_busy_timeout(struct sbp2_lu *);
218static int sbp2_max_speed_and_size(struct sbp2_lu *);
253 219
254static void sbp2scsi_complete_all_commands(struct scsi_id_instance_data *scsi_id,
255 u32 status);
256
257static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id,
258 u32 scsi_status, struct scsi_cmnd *SCpnt,
259 void (*done)(struct scsi_cmnd *));
260
261static struct scsi_host_template scsi_driver_template;
262 220
263static const u8 sbp2_speedto_max_payload[] = { 0x7, 0x8, 0x9, 0xA, 0xB, 0xC }; 221static const u8 sbp2_speedto_max_payload[] = { 0x7, 0x8, 0x9, 0xA, 0xB, 0xC };
264 222
265static void sbp2_host_reset(struct hpsb_host *host);
266
267static int sbp2_probe(struct device *dev);
268static int sbp2_remove(struct device *dev);
269static int sbp2_update(struct unit_directory *ud);
270
271static struct hpsb_highlevel sbp2_highlevel = { 223static struct hpsb_highlevel sbp2_highlevel = {
272 .name = SBP2_DEVICE_NAME, 224 .name = SBP2_DEVICE_NAME,
273 .host_reset = sbp2_host_reset, 225 .host_reset = sbp2_host_reset,
274}; 226};
275 227
276static struct hpsb_address_ops sbp2_ops = { 228static struct hpsb_address_ops sbp2_ops = {
277 .write = sbp2_handle_status_write 229 .write = sbp2_handle_status_write
278}; 230};
279 231
280#ifdef CONFIG_IEEE1394_SBP2_PHYS_DMA 232#ifdef CONFIG_IEEE1394_SBP2_PHYS_DMA
233static int sbp2_handle_physdma_write(struct hpsb_host *, int, int, quadlet_t *,
234 u64, size_t, u16);
235static int sbp2_handle_physdma_read(struct hpsb_host *, int, quadlet_t *, u64,
236 size_t, u16);
237
281static struct hpsb_address_ops sbp2_physdma_ops = { 238static struct hpsb_address_ops sbp2_physdma_ops = {
282 .read = sbp2_handle_physdma_read, 239 .read = sbp2_handle_physdma_read,
283 .write = sbp2_handle_physdma_write, 240 .write = sbp2_handle_physdma_write,
284}; 241};
285#endif 242#endif
286 243
244
245/*
246 * Interface to driver core and IEEE 1394 core
247 */
248static struct ieee1394_device_id sbp2_id_table[] = {
249 {
250 .match_flags = IEEE1394_MATCH_SPECIFIER_ID | IEEE1394_MATCH_VERSION,
251 .specifier_id = SBP2_UNIT_SPEC_ID_ENTRY & 0xffffff,
252 .version = SBP2_SW_VERSION_ENTRY & 0xffffff},
253 {}
254};
255MODULE_DEVICE_TABLE(ieee1394, sbp2_id_table);
256
257static int sbp2_probe(struct device *);
258static int sbp2_remove(struct device *);
259static int sbp2_update(struct unit_directory *);
260
287static struct hpsb_protocol_driver sbp2_driver = { 261static struct hpsb_protocol_driver sbp2_driver = {
288 .name = "SBP2 Driver", 262 .name = SBP2_DEVICE_NAME,
289 .id_table = sbp2_id_table, 263 .id_table = sbp2_id_table,
290 .update = sbp2_update, 264 .update = sbp2_update,
291 .driver = { 265 .driver = {
292 .name = SBP2_DEVICE_NAME,
293 .bus = &ieee1394_bus_type,
294 .probe = sbp2_probe, 266 .probe = sbp2_probe,
295 .remove = sbp2_remove, 267 .remove = sbp2_remove,
296 }, 268 },
297}; 269};
298 270
271
272/*
273 * Interface to SCSI core
274 */
275static int sbp2scsi_queuecommand(struct scsi_cmnd *,
276 void (*)(struct scsi_cmnd *));
277static int sbp2scsi_abort(struct scsi_cmnd *);
278static int sbp2scsi_reset(struct scsi_cmnd *);
279static int sbp2scsi_slave_alloc(struct scsi_device *);
280static int sbp2scsi_slave_configure(struct scsi_device *);
281static void sbp2scsi_slave_destroy(struct scsi_device *);
282static ssize_t sbp2_sysfs_ieee1394_id_show(struct device *,
283 struct device_attribute *, char *);
284
285static DEVICE_ATTR(ieee1394_id, S_IRUGO, sbp2_sysfs_ieee1394_id_show, NULL);
286
287static struct device_attribute *sbp2_sysfs_sdev_attrs[] = {
288 &dev_attr_ieee1394_id,
289 NULL
290};
291
292static struct scsi_host_template sbp2_shost_template = {
293 .module = THIS_MODULE,
294 .name = "SBP-2 IEEE-1394",
295 .proc_name = SBP2_DEVICE_NAME,
296 .queuecommand = sbp2scsi_queuecommand,
297 .eh_abort_handler = sbp2scsi_abort,
298 .eh_device_reset_handler = sbp2scsi_reset,
299 .slave_alloc = sbp2scsi_slave_alloc,
300 .slave_configure = sbp2scsi_slave_configure,
301 .slave_destroy = sbp2scsi_slave_destroy,
302 .this_id = -1,
303 .sg_tablesize = SG_ALL,
304 .use_clustering = ENABLE_CLUSTERING,
305 .cmd_per_lun = SBP2_MAX_CMDS,
306 .can_queue = SBP2_MAX_CMDS,
307 .emulated = 1,
308 .sdev_attrs = sbp2_sysfs_sdev_attrs,
309};
310
311
299/* 312/*
300 * List of devices with known bugs. 313 * List of devices with known bugs.
301 * 314 *
@@ -363,8 +376,6 @@ static inline void sbp2util_be32_to_cpu_buffer(void *buffer, int length)
363 376
364 for (length = (length >> 2); length--; ) 377 for (length = (length >> 2); length--; )
365 temp[length] = be32_to_cpu(temp[length]); 378 temp[length] = be32_to_cpu(temp[length]);
366
367 return;
368} 379}
369 380
370/* 381/*
@@ -376,8 +387,6 @@ static inline void sbp2util_cpu_to_be32_buffer(void *buffer, int length)
376 387
377 for (length = (length >> 2); length--; ) 388 for (length = (length >> 2); length--; )
378 temp[length] = cpu_to_be32(temp[length]); 389 temp[length] = cpu_to_be32(temp[length]);
379
380 return;
381} 390}
382#else /* BIG_ENDIAN */ 391#else /* BIG_ENDIAN */
383/* Why waste the cpu cycles? */ 392/* Why waste the cpu cycles? */
@@ -385,339 +394,246 @@ static inline void sbp2util_cpu_to_be32_buffer(void *buffer, int length)
385#define sbp2util_cpu_to_be32_buffer(x,y) do {} while (0) 394#define sbp2util_cpu_to_be32_buffer(x,y) do {} while (0)
386#endif 395#endif
387 396
388#ifdef CONFIG_IEEE1394_SBP2_PACKET_DUMP 397static DECLARE_WAIT_QUEUE_HEAD(sbp2_access_wq);
389/*
390 * Debug packet dump routine. Length is in bytes.
391 */
392static void sbp2util_packet_dump(void *buffer, int length, char *dump_name,
393 u32 dump_phys_addr)
394{
395 int i;
396 unsigned char *dump = buffer;
397
398 if (!dump || !length || !dump_name)
399 return;
400
401 if (dump_phys_addr)
402 printk("[%s, 0x%x]", dump_name, dump_phys_addr);
403 else
404 printk("[%s]", dump_name);
405 for (i = 0; i < length; i++) {
406 if (i > 0x3f) {
407 printk("\n ...");
408 break;
409 }
410 if ((i & 0x3) == 0)
411 printk(" ");
412 if ((i & 0xf) == 0)
413 printk("\n ");
414 printk("%02x ", (int)dump[i]);
415 }
416 printk("\n");
417
418 return;
419}
420#else
421#define sbp2util_packet_dump(w,x,y,z) do {} while (0)
422#endif
423
424static DECLARE_WAIT_QUEUE_HEAD(access_wq);
425 398
426/* 399/*
427 * Waits for completion of an SBP-2 access request. 400 * Waits for completion of an SBP-2 access request.
428 * Returns nonzero if timed out or prematurely interrupted. 401 * Returns nonzero if timed out or prematurely interrupted.
429 */ 402 */
430static int sbp2util_access_timeout(struct scsi_id_instance_data *scsi_id, 403static int sbp2util_access_timeout(struct sbp2_lu *lu, int timeout)
431 int timeout)
432{ 404{
433 long leftover = wait_event_interruptible_timeout( 405 long leftover;
434 access_wq, scsi_id->access_complete, timeout);
435 406
436 scsi_id->access_complete = 0; 407 leftover = wait_event_interruptible_timeout(
408 sbp2_access_wq, lu->access_complete, timeout);
409 lu->access_complete = 0;
437 return leftover <= 0; 410 return leftover <= 0;
438} 411}
439 412
440/* Frees an allocated packet */ 413static void sbp2_free_packet(void *packet)
441static void sbp2_free_packet(struct hpsb_packet *packet)
442{ 414{
443 hpsb_free_tlabel(packet); 415 hpsb_free_tlabel(packet);
444 hpsb_free_packet(packet); 416 hpsb_free_packet(packet);
445} 417}
446 418
447/* This is much like hpsb_node_write(), except it ignores the response 419/*
448 * subaction and returns immediately. Can be used from interrupts. 420 * This is much like hpsb_node_write(), except it ignores the response
421 * subaction and returns immediately. Can be used from atomic context.
449 */ 422 */
450static int sbp2util_node_write_no_wait(struct node_entry *ne, u64 addr, 423static int sbp2util_node_write_no_wait(struct node_entry *ne, u64 addr,
451 quadlet_t *buffer, size_t length) 424 quadlet_t *buf, size_t len)
452{ 425{
453 struct hpsb_packet *packet; 426 struct hpsb_packet *packet;
454 427
455 packet = hpsb_make_writepacket(ne->host, ne->nodeid, 428 packet = hpsb_make_writepacket(ne->host, ne->nodeid, addr, buf, len);
456 addr, buffer, length);
457 if (!packet) 429 if (!packet)
458 return -ENOMEM; 430 return -ENOMEM;
459 431
460 hpsb_set_packet_complete_task(packet, 432 hpsb_set_packet_complete_task(packet, sbp2_free_packet, packet);
461 (void (*)(void *))sbp2_free_packet,
462 packet);
463
464 hpsb_node_fill_packet(ne, packet); 433 hpsb_node_fill_packet(ne, packet);
465
466 if (hpsb_send_packet(packet) < 0) { 434 if (hpsb_send_packet(packet) < 0) {
467 sbp2_free_packet(packet); 435 sbp2_free_packet(packet);
468 return -EIO; 436 return -EIO;
469 } 437 }
470
471 return 0; 438 return 0;
472} 439}
473 440
474static void sbp2util_notify_fetch_agent(struct scsi_id_instance_data *scsi_id, 441static void sbp2util_notify_fetch_agent(struct sbp2_lu *lu, u64 offset,
475 u64 offset, quadlet_t *data, size_t len) 442 quadlet_t *data, size_t len)
476{ 443{
477 /* 444 /* There is a small window after a bus reset within which the node
478 * There is a small window after a bus reset within which the node 445 * entry's generation is current but the reconnect wasn't completed. */
479 * entry's generation is current but the reconnect wasn't completed. 446 if (unlikely(atomic_read(&lu->state) == SBP2LU_STATE_IN_RESET))
480 */
481 if (unlikely(atomic_read(&scsi_id->state) == SBP2LU_STATE_IN_RESET))
482 return; 447 return;
483 448
484 if (hpsb_node_write(scsi_id->ne, 449 if (hpsb_node_write(lu->ne, lu->command_block_agent_addr + offset,
485 scsi_id->sbp2_command_block_agent_addr + offset,
486 data, len)) 450 data, len))
487 SBP2_ERR("sbp2util_notify_fetch_agent failed."); 451 SBP2_ERR("sbp2util_notify_fetch_agent failed.");
488 /* 452
489 * Now accept new SCSI commands, unless a bus reset happended during 453 /* Now accept new SCSI commands, unless a bus reset happended during
490 * hpsb_node_write. 454 * hpsb_node_write. */
491 */ 455 if (likely(atomic_read(&lu->state) != SBP2LU_STATE_IN_RESET))
492 if (likely(atomic_read(&scsi_id->state) != SBP2LU_STATE_IN_RESET)) 456 scsi_unblock_requests(lu->shost);
493 scsi_unblock_requests(scsi_id->scsi_host);
494} 457}
495 458
496static void sbp2util_write_orb_pointer(void *p) 459static void sbp2util_write_orb_pointer(struct work_struct *work)
497{ 460{
461 struct sbp2_lu *lu = container_of(work, struct sbp2_lu, protocol_work);
498 quadlet_t data[2]; 462 quadlet_t data[2];
499 463
500 data[0] = ORB_SET_NODE_ID( 464 data[0] = ORB_SET_NODE_ID(lu->hi->host->node_id);
501 ((struct scsi_id_instance_data *)p)->hi->host->node_id); 465 data[1] = lu->last_orb_dma;
502 data[1] = ((struct scsi_id_instance_data *)p)->last_orb_dma;
503 sbp2util_cpu_to_be32_buffer(data, 8); 466 sbp2util_cpu_to_be32_buffer(data, 8);
504 sbp2util_notify_fetch_agent(p, SBP2_ORB_POINTER_OFFSET, data, 8); 467 sbp2util_notify_fetch_agent(lu, SBP2_ORB_POINTER_OFFSET, data, 8);
505} 468}
506 469
507static void sbp2util_write_doorbell(void *p) 470static void sbp2util_write_doorbell(struct work_struct *work)
508{ 471{
509 sbp2util_notify_fetch_agent(p, SBP2_DOORBELL_OFFSET, NULL, 4); 472 struct sbp2_lu *lu = container_of(work, struct sbp2_lu, protocol_work);
473
474 sbp2util_notify_fetch_agent(lu, SBP2_DOORBELL_OFFSET, NULL, 4);
510} 475}
511 476
512/* 477static int sbp2util_create_command_orb_pool(struct sbp2_lu *lu)
513 * This function is called to create a pool of command orbs used for
514 * command processing. It is called when a new sbp2 device is detected.
515 */
516static int sbp2util_create_command_orb_pool(struct scsi_id_instance_data *scsi_id)
517{ 478{
518 struct sbp2scsi_host_info *hi = scsi_id->hi; 479 struct sbp2_fwhost_info *hi = lu->hi;
519 int i; 480 int i;
520 unsigned long flags, orbs; 481 unsigned long flags, orbs;
521 struct sbp2_command_info *command; 482 struct sbp2_command_info *cmd;
522 483
523 orbs = serialize_io ? 2 : SBP2_MAX_CMDS; 484 orbs = sbp2_serialize_io ? 2 : SBP2_MAX_CMDS;
524 485
525 spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags); 486 spin_lock_irqsave(&lu->cmd_orb_lock, flags);
526 for (i = 0; i < orbs; i++) { 487 for (i = 0; i < orbs; i++) {
527 command = kzalloc(sizeof(*command), GFP_ATOMIC); 488 cmd = kzalloc(sizeof(*cmd), GFP_ATOMIC);
528 if (!command) { 489 if (!cmd) {
529 spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, 490 spin_unlock_irqrestore(&lu->cmd_orb_lock, flags);
530 flags);
531 return -ENOMEM; 491 return -ENOMEM;
532 } 492 }
533 command->command_orb_dma = 493 cmd->command_orb_dma = dma_map_single(&hi->host->device,
534 pci_map_single(hi->host->pdev, &command->command_orb, 494 &cmd->command_orb,
535 sizeof(struct sbp2_command_orb), 495 sizeof(struct sbp2_command_orb),
536 PCI_DMA_TODEVICE); 496 DMA_TO_DEVICE);
537 SBP2_DMA_ALLOC("single command orb DMA"); 497 cmd->sge_dma = dma_map_single(&hi->host->device,
538 command->sge_dma = 498 &cmd->scatter_gather_element,
539 pci_map_single(hi->host->pdev, 499 sizeof(cmd->scatter_gather_element),
540 &command->scatter_gather_element, 500 DMA_BIDIRECTIONAL);
541 sizeof(command->scatter_gather_element), 501 INIT_LIST_HEAD(&cmd->list);
542 PCI_DMA_BIDIRECTIONAL); 502 list_add_tail(&cmd->list, &lu->cmd_orb_completed);
543 SBP2_DMA_ALLOC("scatter_gather_element"); 503 }
544 INIT_LIST_HEAD(&command->list); 504 spin_unlock_irqrestore(&lu->cmd_orb_lock, flags);
545 list_add_tail(&command->list, &scsi_id->sbp2_command_orb_completed);
546 }
547 spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags);
548 return 0; 505 return 0;
549} 506}
550 507
551/* 508static void sbp2util_remove_command_orb_pool(struct sbp2_lu *lu)
552 * This function is called to delete a pool of command orbs.
553 */
554static void sbp2util_remove_command_orb_pool(struct scsi_id_instance_data *scsi_id)
555{ 509{
556 struct hpsb_host *host = scsi_id->hi->host; 510 struct hpsb_host *host = lu->hi->host;
557 struct list_head *lh, *next; 511 struct list_head *lh, *next;
558 struct sbp2_command_info *command; 512 struct sbp2_command_info *cmd;
559 unsigned long flags; 513 unsigned long flags;
560 514
561 spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags); 515 spin_lock_irqsave(&lu->cmd_orb_lock, flags);
562 if (!list_empty(&scsi_id->sbp2_command_orb_completed)) { 516 if (!list_empty(&lu->cmd_orb_completed))
563 list_for_each_safe(lh, next, &scsi_id->sbp2_command_orb_completed) { 517 list_for_each_safe(lh, next, &lu->cmd_orb_completed) {
564 command = list_entry(lh, struct sbp2_command_info, list); 518 cmd = list_entry(lh, struct sbp2_command_info, list);
565 519 dma_unmap_single(&host->device, cmd->command_orb_dma,
566 /* Release our generic DMA's */
567 pci_unmap_single(host->pdev, command->command_orb_dma,
568 sizeof(struct sbp2_command_orb), 520 sizeof(struct sbp2_command_orb),
569 PCI_DMA_TODEVICE); 521 DMA_TO_DEVICE);
570 SBP2_DMA_FREE("single command orb DMA"); 522 dma_unmap_single(&host->device, cmd->sge_dma,
571 pci_unmap_single(host->pdev, command->sge_dma, 523 sizeof(cmd->scatter_gather_element),
572 sizeof(command->scatter_gather_element), 524 DMA_BIDIRECTIONAL);
573 PCI_DMA_BIDIRECTIONAL); 525 kfree(cmd);
574 SBP2_DMA_FREE("scatter_gather_element");
575
576 kfree(command);
577 } 526 }
578 } 527 spin_unlock_irqrestore(&lu->cmd_orb_lock, flags);
579 spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags);
580 return; 528 return;
581} 529}
582 530
583/* 531/*
584 * This function finds the sbp2_command for a given outstanding command 532 * Finds the sbp2_command for a given outstanding command ORB.
585 * orb.Only looks at the inuse list. 533 * Only looks at the in-use list.
586 */ 534 */
587static struct sbp2_command_info *sbp2util_find_command_for_orb( 535static struct sbp2_command_info *sbp2util_find_command_for_orb(
588 struct scsi_id_instance_data *scsi_id, dma_addr_t orb) 536 struct sbp2_lu *lu, dma_addr_t orb)
589{ 537{
590 struct sbp2_command_info *command; 538 struct sbp2_command_info *cmd;
591 unsigned long flags; 539 unsigned long flags;
592 540
593 spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags); 541 spin_lock_irqsave(&lu->cmd_orb_lock, flags);
594 if (!list_empty(&scsi_id->sbp2_command_orb_inuse)) { 542 if (!list_empty(&lu->cmd_orb_inuse))
595 list_for_each_entry(command, &scsi_id->sbp2_command_orb_inuse, list) { 543 list_for_each_entry(cmd, &lu->cmd_orb_inuse, list)
596 if (command->command_orb_dma == orb) { 544 if (cmd->command_orb_dma == orb) {
597 spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); 545 spin_unlock_irqrestore(
598 return command; 546 &lu->cmd_orb_lock, flags);
547 return cmd;
599 } 548 }
600 } 549 spin_unlock_irqrestore(&lu->cmd_orb_lock, flags);
601 }
602 spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags);
603
604 SBP2_ORB_DEBUG("could not match command orb %x", (unsigned int)orb);
605
606 return NULL; 550 return NULL;
607} 551}
608 552
609/* 553/*
610 * This function finds the sbp2_command for a given outstanding SCpnt. 554 * Finds the sbp2_command for a given outstanding SCpnt.
611 * Only looks at the inuse list. 555 * Only looks at the in-use list.
612 * Must be called with scsi_id->sbp2_command_orb_lock held. 556 * Must be called with lu->cmd_orb_lock held.
613 */ 557 */
614static struct sbp2_command_info *sbp2util_find_command_for_SCpnt( 558static struct sbp2_command_info *sbp2util_find_command_for_SCpnt(
615 struct scsi_id_instance_data *scsi_id, void *SCpnt) 559 struct sbp2_lu *lu, void *SCpnt)
616{ 560{
617 struct sbp2_command_info *command; 561 struct sbp2_command_info *cmd;
618 562
619 if (!list_empty(&scsi_id->sbp2_command_orb_inuse)) 563 if (!list_empty(&lu->cmd_orb_inuse))
620 list_for_each_entry(command, &scsi_id->sbp2_command_orb_inuse, list) 564 list_for_each_entry(cmd, &lu->cmd_orb_inuse, list)
621 if (command->Current_SCpnt == SCpnt) 565 if (cmd->Current_SCpnt == SCpnt)
622 return command; 566 return cmd;
623 return NULL; 567 return NULL;
624} 568}
625 569
626/*
627 * This function allocates a command orb used to send a scsi command.
628 */
629static struct sbp2_command_info *sbp2util_allocate_command_orb( 570static struct sbp2_command_info *sbp2util_allocate_command_orb(
630 struct scsi_id_instance_data *scsi_id, 571 struct sbp2_lu *lu,
631 struct scsi_cmnd *Current_SCpnt, 572 struct scsi_cmnd *Current_SCpnt,
632 void (*Current_done)(struct scsi_cmnd *)) 573 void (*Current_done)(struct scsi_cmnd *))
633{ 574{
634 struct list_head *lh; 575 struct list_head *lh;
635 struct sbp2_command_info *command = NULL; 576 struct sbp2_command_info *cmd = NULL;
636 unsigned long flags; 577 unsigned long flags;
637 578
638 spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags); 579 spin_lock_irqsave(&lu->cmd_orb_lock, flags);
639 if (!list_empty(&scsi_id->sbp2_command_orb_completed)) { 580 if (!list_empty(&lu->cmd_orb_completed)) {
640 lh = scsi_id->sbp2_command_orb_completed.next; 581 lh = lu->cmd_orb_completed.next;
641 list_del(lh); 582 list_del(lh);
642 command = list_entry(lh, struct sbp2_command_info, list); 583 cmd = list_entry(lh, struct sbp2_command_info, list);
643 command->Current_done = Current_done; 584 cmd->Current_done = Current_done;
644 command->Current_SCpnt = Current_SCpnt; 585 cmd->Current_SCpnt = Current_SCpnt;
645 list_add_tail(&command->list, &scsi_id->sbp2_command_orb_inuse); 586 list_add_tail(&cmd->list, &lu->cmd_orb_inuse);
646 } else { 587 } else
647 SBP2_ERR("%s: no orbs available", __FUNCTION__); 588 SBP2_ERR("%s: no orbs available", __FUNCTION__);
648 } 589 spin_unlock_irqrestore(&lu->cmd_orb_lock, flags);
649 spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); 590 return cmd;
650 return command;
651}
652
653/* Free our DMA's */
654static void sbp2util_free_command_dma(struct sbp2_command_info *command)
655{
656 struct scsi_id_instance_data *scsi_id =
657 (struct scsi_id_instance_data *)command->Current_SCpnt->device->host->hostdata[0];
658 struct hpsb_host *host;
659
660 if (!scsi_id) {
661 SBP2_ERR("%s: scsi_id == NULL", __FUNCTION__);
662 return;
663 }
664
665 host = scsi_id->ud->ne->host;
666
667 if (command->cmd_dma) {
668 if (command->dma_type == CMD_DMA_SINGLE) {
669 pci_unmap_single(host->pdev, command->cmd_dma,
670 command->dma_size, command->dma_dir);
671 SBP2_DMA_FREE("single bulk");
672 } else if (command->dma_type == CMD_DMA_PAGE) {
673 pci_unmap_page(host->pdev, command->cmd_dma,
674 command->dma_size, command->dma_dir);
675 SBP2_DMA_FREE("single page");
676 } /* XXX: Check for CMD_DMA_NONE bug */
677 command->dma_type = CMD_DMA_NONE;
678 command->cmd_dma = 0;
679 }
680
681 if (command->sge_buffer) {
682 pci_unmap_sg(host->pdev, command->sge_buffer,
683 command->dma_size, command->dma_dir);
684 SBP2_DMA_FREE("scatter list");
685 command->sge_buffer = NULL;
686 }
687} 591}
688 592
689/* 593/*
690 * This function moves a command to the completed orb list. 594 * Unmaps the DMAs of a command and moves the command to the completed ORB list.
691 * Must be called with scsi_id->sbp2_command_orb_lock held. 595 * Must be called with lu->cmd_orb_lock held.
692 */ 596 */
693static void sbp2util_mark_command_completed( 597static void sbp2util_mark_command_completed(struct sbp2_lu *lu,
694 struct scsi_id_instance_data *scsi_id, 598 struct sbp2_command_info *cmd)
695 struct sbp2_command_info *command)
696{ 599{
697 list_del(&command->list); 600 struct hpsb_host *host = lu->ud->ne->host;
698 sbp2util_free_command_dma(command); 601
699 list_add_tail(&command->list, &scsi_id->sbp2_command_orb_completed); 602 if (cmd->cmd_dma) {
603 if (cmd->dma_type == CMD_DMA_SINGLE)
604 dma_unmap_single(&host->device, cmd->cmd_dma,
605 cmd->dma_size, cmd->dma_dir);
606 else if (cmd->dma_type == CMD_DMA_PAGE)
607 dma_unmap_page(&host->device, cmd->cmd_dma,
608 cmd->dma_size, cmd->dma_dir);
609 /* XXX: Check for CMD_DMA_NONE bug */
610 cmd->dma_type = CMD_DMA_NONE;
611 cmd->cmd_dma = 0;
612 }
613 if (cmd->sge_buffer) {
614 dma_unmap_sg(&host->device, cmd->sge_buffer,
615 cmd->dma_size, cmd->dma_dir);
616 cmd->sge_buffer = NULL;
617 }
618 list_move_tail(&cmd->list, &lu->cmd_orb_completed);
700} 619}
701 620
702/* 621/*
703 * Is scsi_id valid? Is the 1394 node still present? 622 * Is lu valid? Is the 1394 node still present?
704 */ 623 */
705static inline int sbp2util_node_is_available(struct scsi_id_instance_data *scsi_id) 624static inline int sbp2util_node_is_available(struct sbp2_lu *lu)
706{ 625{
707 return scsi_id && scsi_id->ne && !scsi_id->ne->in_limbo; 626 return lu && lu->ne && !lu->ne->in_limbo;
708} 627}
709 628
710/********************************************* 629/*********************************************
711 * IEEE-1394 core driver stack related section 630 * IEEE-1394 core driver stack related section
712 *********************************************/ 631 *********************************************/
713static struct scsi_id_instance_data *sbp2_alloc_device(struct unit_directory *ud);
714 632
715static int sbp2_probe(struct device *dev) 633static int sbp2_probe(struct device *dev)
716{ 634{
717 struct unit_directory *ud; 635 struct unit_directory *ud;
718 struct scsi_id_instance_data *scsi_id; 636 struct sbp2_lu *lu;
719
720 SBP2_DEBUG_ENTER();
721 637
722 ud = container_of(dev, struct unit_directory, device); 638 ud = container_of(dev, struct unit_directory, device);
723 639
@@ -726,67 +642,58 @@ static int sbp2_probe(struct device *dev)
726 if (ud->flags & UNIT_DIRECTORY_HAS_LUN_DIRECTORY) 642 if (ud->flags & UNIT_DIRECTORY_HAS_LUN_DIRECTORY)
727 return -ENODEV; 643 return -ENODEV;
728 644
729 scsi_id = sbp2_alloc_device(ud); 645 lu = sbp2_alloc_device(ud);
730 646 if (!lu)
731 if (!scsi_id)
732 return -ENOMEM; 647 return -ENOMEM;
733 648
734 sbp2_parse_unit_directory(scsi_id, ud); 649 sbp2_parse_unit_directory(lu, ud);
735 650 return sbp2_start_device(lu);
736 return sbp2_start_device(scsi_id);
737} 651}
738 652
739static int sbp2_remove(struct device *dev) 653static int sbp2_remove(struct device *dev)
740{ 654{
741 struct unit_directory *ud; 655 struct unit_directory *ud;
742 struct scsi_id_instance_data *scsi_id; 656 struct sbp2_lu *lu;
743 struct scsi_device *sdev; 657 struct scsi_device *sdev;
744 658
745 SBP2_DEBUG_ENTER();
746
747 ud = container_of(dev, struct unit_directory, device); 659 ud = container_of(dev, struct unit_directory, device);
748 scsi_id = ud->device.driver_data; 660 lu = ud->device.driver_data;
749 if (!scsi_id) 661 if (!lu)
750 return 0; 662 return 0;
751 663
752 if (scsi_id->scsi_host) { 664 if (lu->shost) {
753 /* Get rid of enqueued commands if there is no chance to 665 /* Get rid of enqueued commands if there is no chance to
754 * send them. */ 666 * send them. */
755 if (!sbp2util_node_is_available(scsi_id)) 667 if (!sbp2util_node_is_available(lu))
756 sbp2scsi_complete_all_commands(scsi_id, DID_NO_CONNECT); 668 sbp2scsi_complete_all_commands(lu, DID_NO_CONNECT);
757 /* scsi_remove_device() will trigger shutdown functions of SCSI 669 /* scsi_remove_device() may trigger shutdown functions of SCSI
758 * highlevel drivers which would deadlock if blocked. */ 670 * highlevel drivers which would deadlock if blocked. */
759 atomic_set(&scsi_id->state, SBP2LU_STATE_IN_SHUTDOWN); 671 atomic_set(&lu->state, SBP2LU_STATE_IN_SHUTDOWN);
760 scsi_unblock_requests(scsi_id->scsi_host); 672 scsi_unblock_requests(lu->shost);
761 } 673 }
762 sdev = scsi_id->sdev; 674 sdev = lu->sdev;
763 if (sdev) { 675 if (sdev) {
764 scsi_id->sdev = NULL; 676 lu->sdev = NULL;
765 scsi_remove_device(sdev); 677 scsi_remove_device(sdev);
766 } 678 }
767 679
768 sbp2_logout_device(scsi_id); 680 sbp2_logout_device(lu);
769 sbp2_remove_device(scsi_id); 681 sbp2_remove_device(lu);
770 682
771 return 0; 683 return 0;
772} 684}
773 685
774static int sbp2_update(struct unit_directory *ud) 686static int sbp2_update(struct unit_directory *ud)
775{ 687{
776 struct scsi_id_instance_data *scsi_id = ud->device.driver_data; 688 struct sbp2_lu *lu = ud->device.driver_data;
777
778 SBP2_DEBUG_ENTER();
779 689
780 if (sbp2_reconnect_device(scsi_id)) { 690 if (sbp2_reconnect_device(lu)) {
691 /* Reconnect has failed. Perhaps we didn't reconnect fast
692 * enough. Try a regular login, but first log out just in
693 * case of any weirdness. */
694 sbp2_logout_device(lu);
781 695
782 /* 696 if (sbp2_login_device(lu)) {
783 * Ok, reconnect has failed. Perhaps we didn't
784 * reconnect fast enough. Try doing a regular login, but
785 * first do a logout just in case of any weirdness.
786 */
787 sbp2_logout_device(scsi_id);
788
789 if (sbp2_login_device(scsi_id)) {
790 /* Login failed too, just fail, and the backend 697 /* Login failed too, just fail, and the backend
791 * will call our sbp2_remove for us */ 698 * will call our sbp2_remove for us */
792 SBP2_ERR("Failed to reconnect to sbp2 device!"); 699 SBP2_ERR("Failed to reconnect to sbp2 device!");
@@ -794,69 +701,59 @@ static int sbp2_update(struct unit_directory *ud)
794 } 701 }
795 } 702 }
796 703
797 /* Set max retries to something large on the device. */ 704 sbp2_set_busy_timeout(lu);
798 sbp2_set_busy_timeout(scsi_id); 705 sbp2_agent_reset(lu, 1);
706 sbp2_max_speed_and_size(lu);
799 707
800 /* Do a SBP-2 fetch agent reset. */ 708 /* Complete any pending commands with busy (so they get retried)
801 sbp2_agent_reset(scsi_id, 1); 709 * and remove them from our queue. */
802 710 sbp2scsi_complete_all_commands(lu, DID_BUS_BUSY);
803 /* Get the max speed and packet size that we can use. */
804 sbp2_max_speed_and_size(scsi_id);
805
806 /* Complete any pending commands with busy (so they get
807 * retried) and remove them from our queue
808 */
809 sbp2scsi_complete_all_commands(scsi_id, DID_BUS_BUSY);
810 711
811 /* Accept new commands unless there was another bus reset in the 712 /* Accept new commands unless there was another bus reset in the
812 * meantime. */ 713 * meantime. */
813 if (hpsb_node_entry_valid(scsi_id->ne)) { 714 if (hpsb_node_entry_valid(lu->ne)) {
814 atomic_set(&scsi_id->state, SBP2LU_STATE_RUNNING); 715 atomic_set(&lu->state, SBP2LU_STATE_RUNNING);
815 scsi_unblock_requests(scsi_id->scsi_host); 716 scsi_unblock_requests(lu->shost);
816 } 717 }
817 return 0; 718 return 0;
818} 719}
819 720
820/* This functions is called by the sbp2_probe, for each new device. We now 721static struct sbp2_lu *sbp2_alloc_device(struct unit_directory *ud)
821 * allocate one scsi host for each scsi_id (unit directory). */
822static struct scsi_id_instance_data *sbp2_alloc_device(struct unit_directory *ud)
823{ 722{
824 struct sbp2scsi_host_info *hi; 723 struct sbp2_fwhost_info *hi;
825 struct Scsi_Host *scsi_host = NULL; 724 struct Scsi_Host *shost = NULL;
826 struct scsi_id_instance_data *scsi_id = NULL; 725 struct sbp2_lu *lu = NULL;
827 726
828 SBP2_DEBUG_ENTER(); 727 lu = kzalloc(sizeof(*lu), GFP_KERNEL);
829 728 if (!lu) {
830 scsi_id = kzalloc(sizeof(*scsi_id), GFP_KERNEL); 729 SBP2_ERR("failed to create lu");
831 if (!scsi_id) {
832 SBP2_ERR("failed to create scsi_id");
833 goto failed_alloc; 730 goto failed_alloc;
834 } 731 }
835 732
836 scsi_id->ne = ud->ne; 733 lu->ne = ud->ne;
837 scsi_id->ud = ud; 734 lu->ud = ud;
838 scsi_id->speed_code = IEEE1394_SPEED_100; 735 lu->speed_code = IEEE1394_SPEED_100;
839 scsi_id->max_payload_size = sbp2_speedto_max_payload[IEEE1394_SPEED_100]; 736 lu->max_payload_size = sbp2_speedto_max_payload[IEEE1394_SPEED_100];
840 scsi_id->status_fifo_addr = CSR1212_INVALID_ADDR_SPACE; 737 lu->status_fifo_addr = CSR1212_INVALID_ADDR_SPACE;
841 INIT_LIST_HEAD(&scsi_id->sbp2_command_orb_inuse); 738 INIT_LIST_HEAD(&lu->cmd_orb_inuse);
842 INIT_LIST_HEAD(&scsi_id->sbp2_command_orb_completed); 739 INIT_LIST_HEAD(&lu->cmd_orb_completed);
843 INIT_LIST_HEAD(&scsi_id->scsi_list); 740 INIT_LIST_HEAD(&lu->lu_list);
844 spin_lock_init(&scsi_id->sbp2_command_orb_lock); 741 spin_lock_init(&lu->cmd_orb_lock);
845 atomic_set(&scsi_id->state, SBP2LU_STATE_RUNNING); 742 atomic_set(&lu->state, SBP2LU_STATE_RUNNING);
846 INIT_WORK(&scsi_id->protocol_work, NULL, NULL); 743 INIT_WORK(&lu->protocol_work, NULL);
847 744
848 ud->device.driver_data = scsi_id; 745 ud->device.driver_data = lu;
849 746
850 hi = hpsb_get_hostinfo(&sbp2_highlevel, ud->ne->host); 747 hi = hpsb_get_hostinfo(&sbp2_highlevel, ud->ne->host);
851 if (!hi) { 748 if (!hi) {
852 hi = hpsb_create_hostinfo(&sbp2_highlevel, ud->ne->host, sizeof(*hi)); 749 hi = hpsb_create_hostinfo(&sbp2_highlevel, ud->ne->host,
750 sizeof(*hi));
853 if (!hi) { 751 if (!hi) {
854 SBP2_ERR("failed to allocate hostinfo"); 752 SBP2_ERR("failed to allocate hostinfo");
855 goto failed_alloc; 753 goto failed_alloc;
856 } 754 }
857 SBP2_DEBUG("sbp2_alloc_device: allocated hostinfo");
858 hi->host = ud->ne->host; 755 hi->host = ud->ne->host;
859 INIT_LIST_HEAD(&hi->scsi_ids); 756 INIT_LIST_HEAD(&hi->logical_units);
860 757
861#ifdef CONFIG_IEEE1394_SBP2_PHYS_DMA 758#ifdef CONFIG_IEEE1394_SBP2_PHYS_DMA
862 /* Handle data movement if physical dma is not 759 /* Handle data movement if physical dma is not
@@ -876,9 +773,9 @@ static struct scsi_id_instance_data *sbp2_alloc_device(struct unit_directory *ud
876 goto failed_alloc; 773 goto failed_alloc;
877 } 774 }
878 775
879 scsi_id->hi = hi; 776 lu->hi = hi;
880 777
881 list_add_tail(&scsi_id->scsi_list, &hi->scsi_ids); 778 list_add_tail(&lu->lu_list, &hi->logical_units);
882 779
883 /* Register the status FIFO address range. We could use the same FIFO 780 /* Register the status FIFO address range. We could use the same FIFO
884 * for targets at different nodes. However we need different FIFOs per 781 * for targets at different nodes. However we need different FIFOs per
@@ -888,302 +785,214 @@ static struct scsi_id_instance_data *sbp2_alloc_device(struct unit_directory *ud
888 * then be performed as unified transactions. This slightly reduces 785 * then be performed as unified transactions. This slightly reduces
889 * bandwidth usage, and some Prolific based devices seem to require it. 786 * bandwidth usage, and some Prolific based devices seem to require it.
890 */ 787 */
891 scsi_id->status_fifo_addr = hpsb_allocate_and_register_addrspace( 788 lu->status_fifo_addr = hpsb_allocate_and_register_addrspace(
892 &sbp2_highlevel, ud->ne->host, &sbp2_ops, 789 &sbp2_highlevel, ud->ne->host, &sbp2_ops,
893 sizeof(struct sbp2_status_block), sizeof(quadlet_t), 790 sizeof(struct sbp2_status_block), sizeof(quadlet_t),
894 ud->ne->host->low_addr_space, CSR1212_ALL_SPACE_END); 791 ud->ne->host->low_addr_space, CSR1212_ALL_SPACE_END);
895 if (scsi_id->status_fifo_addr == CSR1212_INVALID_ADDR_SPACE) { 792 if (lu->status_fifo_addr == CSR1212_INVALID_ADDR_SPACE) {
896 SBP2_ERR("failed to allocate status FIFO address range"); 793 SBP2_ERR("failed to allocate status FIFO address range");
897 goto failed_alloc; 794 goto failed_alloc;
898 } 795 }
899 796
900 /* Register our host with the SCSI stack. */ 797 shost = scsi_host_alloc(&sbp2_shost_template, sizeof(unsigned long));
901 scsi_host = scsi_host_alloc(&scsi_driver_template, 798 if (!shost) {
902 sizeof(unsigned long));
903 if (!scsi_host) {
904 SBP2_ERR("failed to register scsi host"); 799 SBP2_ERR("failed to register scsi host");
905 goto failed_alloc; 800 goto failed_alloc;
906 } 801 }
907 802
908 scsi_host->hostdata[0] = (unsigned long)scsi_id; 803 shost->hostdata[0] = (unsigned long)lu;
909 804
910 if (!scsi_add_host(scsi_host, &ud->device)) { 805 if (!scsi_add_host(shost, &ud->device)) {
911 scsi_id->scsi_host = scsi_host; 806 lu->shost = shost;
912 return scsi_id; 807 return lu;
913 } 808 }
914 809
915 SBP2_ERR("failed to add scsi host"); 810 SBP2_ERR("failed to add scsi host");
916 scsi_host_put(scsi_host); 811 scsi_host_put(shost);
917 812
918failed_alloc: 813failed_alloc:
919 sbp2_remove_device(scsi_id); 814 sbp2_remove_device(lu);
920 return NULL; 815 return NULL;
921} 816}
922 817
923static void sbp2_host_reset(struct hpsb_host *host) 818static void sbp2_host_reset(struct hpsb_host *host)
924{ 819{
925 struct sbp2scsi_host_info *hi; 820 struct sbp2_fwhost_info *hi;
926 struct scsi_id_instance_data *scsi_id; 821 struct sbp2_lu *lu;
927 822
928 hi = hpsb_get_hostinfo(&sbp2_highlevel, host); 823 hi = hpsb_get_hostinfo(&sbp2_highlevel, host);
929 if (!hi) 824 if (!hi)
930 return; 825 return;
931 list_for_each_entry(scsi_id, &hi->scsi_ids, scsi_list) 826 list_for_each_entry(lu, &hi->logical_units, lu_list)
932 if (likely(atomic_read(&scsi_id->state) != 827 if (likely(atomic_read(&lu->state) !=
933 SBP2LU_STATE_IN_SHUTDOWN)) { 828 SBP2LU_STATE_IN_SHUTDOWN)) {
934 atomic_set(&scsi_id->state, SBP2LU_STATE_IN_RESET); 829 atomic_set(&lu->state, SBP2LU_STATE_IN_RESET);
935 scsi_block_requests(scsi_id->scsi_host); 830 scsi_block_requests(lu->shost);
936 } 831 }
937} 832}
938 833
939/* 834static int sbp2_start_device(struct sbp2_lu *lu)
940 * This function is where we first pull the node unique ids, and then
941 * allocate memory and register a SBP-2 device.
942 */
943static int sbp2_start_device(struct scsi_id_instance_data *scsi_id)
944{ 835{
945 struct sbp2scsi_host_info *hi = scsi_id->hi; 836 struct sbp2_fwhost_info *hi = lu->hi;
946 int error; 837 int error;
947 838
948 SBP2_DEBUG_ENTER(); 839 lu->login_response = dma_alloc_coherent(&hi->host->device,
949
950 /* Login FIFO DMA */
951 scsi_id->login_response =
952 pci_alloc_consistent(hi->host->pdev,
953 sizeof(struct sbp2_login_response), 840 sizeof(struct sbp2_login_response),
954 &scsi_id->login_response_dma); 841 &lu->login_response_dma, GFP_KERNEL);
955 if (!scsi_id->login_response) 842 if (!lu->login_response)
956 goto alloc_fail; 843 goto alloc_fail;
957 SBP2_DMA_ALLOC("consistent DMA region for login FIFO");
958 844
959 /* Query logins ORB DMA */ 845 lu->query_logins_orb = dma_alloc_coherent(&hi->host->device,
960 scsi_id->query_logins_orb =
961 pci_alloc_consistent(hi->host->pdev,
962 sizeof(struct sbp2_query_logins_orb), 846 sizeof(struct sbp2_query_logins_orb),
963 &scsi_id->query_logins_orb_dma); 847 &lu->query_logins_orb_dma, GFP_KERNEL);
964 if (!scsi_id->query_logins_orb) 848 if (!lu->query_logins_orb)
965 goto alloc_fail; 849 goto alloc_fail;
966 SBP2_DMA_ALLOC("consistent DMA region for query logins ORB");
967 850
968 /* Query logins response DMA */ 851 lu->query_logins_response = dma_alloc_coherent(&hi->host->device,
969 scsi_id->query_logins_response =
970 pci_alloc_consistent(hi->host->pdev,
971 sizeof(struct sbp2_query_logins_response), 852 sizeof(struct sbp2_query_logins_response),
972 &scsi_id->query_logins_response_dma); 853 &lu->query_logins_response_dma, GFP_KERNEL);
973 if (!scsi_id->query_logins_response) 854 if (!lu->query_logins_response)
974 goto alloc_fail; 855 goto alloc_fail;
975 SBP2_DMA_ALLOC("consistent DMA region for query logins response");
976 856
977 /* Reconnect ORB DMA */ 857 lu->reconnect_orb = dma_alloc_coherent(&hi->host->device,
978 scsi_id->reconnect_orb =
979 pci_alloc_consistent(hi->host->pdev,
980 sizeof(struct sbp2_reconnect_orb), 858 sizeof(struct sbp2_reconnect_orb),
981 &scsi_id->reconnect_orb_dma); 859 &lu->reconnect_orb_dma, GFP_KERNEL);
982 if (!scsi_id->reconnect_orb) 860 if (!lu->reconnect_orb)
983 goto alloc_fail; 861 goto alloc_fail;
984 SBP2_DMA_ALLOC("consistent DMA region for reconnect ORB");
985 862
986 /* Logout ORB DMA */ 863 lu->logout_orb = dma_alloc_coherent(&hi->host->device,
987 scsi_id->logout_orb =
988 pci_alloc_consistent(hi->host->pdev,
989 sizeof(struct sbp2_logout_orb), 864 sizeof(struct sbp2_logout_orb),
990 &scsi_id->logout_orb_dma); 865 &lu->logout_orb_dma, GFP_KERNEL);
991 if (!scsi_id->logout_orb) 866 if (!lu->logout_orb)
992 goto alloc_fail; 867 goto alloc_fail;
993 SBP2_DMA_ALLOC("consistent DMA region for logout ORB");
994 868
995 /* Login ORB DMA */ 869 lu->login_orb = dma_alloc_coherent(&hi->host->device,
996 scsi_id->login_orb =
997 pci_alloc_consistent(hi->host->pdev,
998 sizeof(struct sbp2_login_orb), 870 sizeof(struct sbp2_login_orb),
999 &scsi_id->login_orb_dma); 871 &lu->login_orb_dma, GFP_KERNEL);
1000 if (!scsi_id->login_orb) 872 if (!lu->login_orb)
1001 goto alloc_fail; 873 goto alloc_fail;
1002 SBP2_DMA_ALLOC("consistent DMA region for login ORB");
1003
1004 SBP2_DEBUG("New SBP-2 device inserted, SCSI ID = %x", scsi_id->ud->id);
1005 874
1006 /* 875 if (sbp2util_create_command_orb_pool(lu)) {
1007 * Create our command orb pool
1008 */
1009 if (sbp2util_create_command_orb_pool(scsi_id)) {
1010 SBP2_ERR("sbp2util_create_command_orb_pool failed!"); 876 SBP2_ERR("sbp2util_create_command_orb_pool failed!");
1011 sbp2_remove_device(scsi_id); 877 sbp2_remove_device(lu);
1012 return -ENOMEM; 878 return -ENOMEM;
1013 } 879 }
1014 880
1015 /* Schedule a timeout here. The reason is that we may be so close 881 /* Wait a second before trying to log in. Previously logged in
1016 * to a bus reset, that the device is not available for logins. 882 * initiators need a chance to reconnect. */
1017 * This can happen when the bus reset is caused by the host
1018 * connected to the sbp2 device being removed. That host would
1019 * have a certain amount of time to relogin before the sbp2 device
1020 * allows someone else to login instead. One second makes sense. */
1021 if (msleep_interruptible(1000)) { 883 if (msleep_interruptible(1000)) {
1022 sbp2_remove_device(scsi_id); 884 sbp2_remove_device(lu);
1023 return -EINTR; 885 return -EINTR;
1024 } 886 }
1025 887
1026 /* 888 if (sbp2_login_device(lu)) {
1027 * Login to the sbp-2 device 889 sbp2_remove_device(lu);
1028 */
1029 if (sbp2_login_device(scsi_id)) {
1030 /* Login failed, just remove the device. */
1031 sbp2_remove_device(scsi_id);
1032 return -EBUSY; 890 return -EBUSY;
1033 } 891 }
1034 892
1035 /* 893 sbp2_set_busy_timeout(lu);
1036 * Set max retries to something large on the device 894 sbp2_agent_reset(lu, 1);
1037 */ 895 sbp2_max_speed_and_size(lu);
1038 sbp2_set_busy_timeout(scsi_id);
1039
1040 /*
1041 * Do a SBP-2 fetch agent reset
1042 */
1043 sbp2_agent_reset(scsi_id, 1);
1044 896
1045 /* 897 error = scsi_add_device(lu->shost, 0, lu->ud->id, 0);
1046 * Get the max speed and packet size that we can use
1047 */
1048 sbp2_max_speed_and_size(scsi_id);
1049
1050 /* Add this device to the scsi layer now */
1051 error = scsi_add_device(scsi_id->scsi_host, 0, scsi_id->ud->id, 0);
1052 if (error) { 898 if (error) {
1053 SBP2_ERR("scsi_add_device failed"); 899 SBP2_ERR("scsi_add_device failed");
1054 sbp2_logout_device(scsi_id); 900 sbp2_logout_device(lu);
1055 sbp2_remove_device(scsi_id); 901 sbp2_remove_device(lu);
1056 return error; 902 return error;
1057 } 903 }
1058 904
1059 return 0; 905 return 0;
1060 906
1061alloc_fail: 907alloc_fail:
1062 SBP2_ERR("Could not allocate memory for scsi_id"); 908 SBP2_ERR("Could not allocate memory for lu");
1063 sbp2_remove_device(scsi_id); 909 sbp2_remove_device(lu);
1064 return -ENOMEM; 910 return -ENOMEM;
1065} 911}
1066 912
1067/* 913static void sbp2_remove_device(struct sbp2_lu *lu)
1068 * This function removes an sbp2 device from the sbp2scsi_host_info struct.
1069 */
1070static void sbp2_remove_device(struct scsi_id_instance_data *scsi_id)
1071{ 914{
1072 struct sbp2scsi_host_info *hi; 915 struct sbp2_fwhost_info *hi;
1073
1074 SBP2_DEBUG_ENTER();
1075 916
1076 if (!scsi_id) 917 if (!lu)
1077 return; 918 return;
1078 919
1079 hi = scsi_id->hi; 920 hi = lu->hi;
1080 921
1081 /* This will remove our scsi device aswell */ 922 if (lu->shost) {
1082 if (scsi_id->scsi_host) { 923 scsi_remove_host(lu->shost);
1083 scsi_remove_host(scsi_id->scsi_host); 924 scsi_host_put(lu->shost);
1084 scsi_host_put(scsi_id->scsi_host);
1085 } 925 }
1086 flush_scheduled_work(); 926 flush_scheduled_work();
1087 sbp2util_remove_command_orb_pool(scsi_id); 927 sbp2util_remove_command_orb_pool(lu);
1088 928
1089 list_del(&scsi_id->scsi_list); 929 list_del(&lu->lu_list);
1090 930
1091 if (scsi_id->login_response) { 931 if (lu->login_response)
1092 pci_free_consistent(hi->host->pdev, 932 dma_free_coherent(&hi->host->device,
1093 sizeof(struct sbp2_login_response), 933 sizeof(struct sbp2_login_response),
1094 scsi_id->login_response, 934 lu->login_response,
1095 scsi_id->login_response_dma); 935 lu->login_response_dma);
1096 SBP2_DMA_FREE("single login FIFO"); 936 if (lu->login_orb)
1097 } 937 dma_free_coherent(&hi->host->device,
1098
1099 if (scsi_id->login_orb) {
1100 pci_free_consistent(hi->host->pdev,
1101 sizeof(struct sbp2_login_orb), 938 sizeof(struct sbp2_login_orb),
1102 scsi_id->login_orb, 939 lu->login_orb,
1103 scsi_id->login_orb_dma); 940 lu->login_orb_dma);
1104 SBP2_DMA_FREE("single login ORB"); 941 if (lu->reconnect_orb)
1105 } 942 dma_free_coherent(&hi->host->device,
1106
1107 if (scsi_id->reconnect_orb) {
1108 pci_free_consistent(hi->host->pdev,
1109 sizeof(struct sbp2_reconnect_orb), 943 sizeof(struct sbp2_reconnect_orb),
1110 scsi_id->reconnect_orb, 944 lu->reconnect_orb,
1111 scsi_id->reconnect_orb_dma); 945 lu->reconnect_orb_dma);
1112 SBP2_DMA_FREE("single reconnect orb"); 946 if (lu->logout_orb)
1113 } 947 dma_free_coherent(&hi->host->device,
1114
1115 if (scsi_id->logout_orb) {
1116 pci_free_consistent(hi->host->pdev,
1117 sizeof(struct sbp2_logout_orb), 948 sizeof(struct sbp2_logout_orb),
1118 scsi_id->logout_orb, 949 lu->logout_orb,
1119 scsi_id->logout_orb_dma); 950 lu->logout_orb_dma);
1120 SBP2_DMA_FREE("single logout orb"); 951 if (lu->query_logins_orb)
1121 } 952 dma_free_coherent(&hi->host->device,
1122
1123 if (scsi_id->query_logins_orb) {
1124 pci_free_consistent(hi->host->pdev,
1125 sizeof(struct sbp2_query_logins_orb), 953 sizeof(struct sbp2_query_logins_orb),
1126 scsi_id->query_logins_orb, 954 lu->query_logins_orb,
1127 scsi_id->query_logins_orb_dma); 955 lu->query_logins_orb_dma);
1128 SBP2_DMA_FREE("single query logins orb"); 956 if (lu->query_logins_response)
1129 } 957 dma_free_coherent(&hi->host->device,
1130
1131 if (scsi_id->query_logins_response) {
1132 pci_free_consistent(hi->host->pdev,
1133 sizeof(struct sbp2_query_logins_response), 958 sizeof(struct sbp2_query_logins_response),
1134 scsi_id->query_logins_response, 959 lu->query_logins_response,
1135 scsi_id->query_logins_response_dma); 960 lu->query_logins_response_dma);
1136 SBP2_DMA_FREE("single query logins data");
1137 }
1138 961
1139 if (scsi_id->status_fifo_addr != CSR1212_INVALID_ADDR_SPACE) 962 if (lu->status_fifo_addr != CSR1212_INVALID_ADDR_SPACE)
1140 hpsb_unregister_addrspace(&sbp2_highlevel, hi->host, 963 hpsb_unregister_addrspace(&sbp2_highlevel, hi->host,
1141 scsi_id->status_fifo_addr); 964 lu->status_fifo_addr);
1142 965
1143 scsi_id->ud->device.driver_data = NULL; 966 lu->ud->device.driver_data = NULL;
1144 967
1145 if (hi) 968 if (hi)
1146 module_put(hi->host->driver->owner); 969 module_put(hi->host->driver->owner);
1147 970
1148 SBP2_DEBUG("SBP-2 device removed, SCSI ID = %d", scsi_id->ud->id); 971 kfree(lu);
1149
1150 kfree(scsi_id);
1151} 972}
1152 973
1153#ifdef CONFIG_IEEE1394_SBP2_PHYS_DMA 974#ifdef CONFIG_IEEE1394_SBP2_PHYS_DMA
1154/* 975/*
1155 * This function deals with physical dma write requests (for adapters that do not support 976 * Deal with write requests on adapters which do not support physical DMA or
1156 * physical dma in hardware). Mostly just here for debugging... 977 * have it switched off.
1157 */ 978 */
1158static int sbp2_handle_physdma_write(struct hpsb_host *host, int nodeid, 979static int sbp2_handle_physdma_write(struct hpsb_host *host, int nodeid,
1159 int destid, quadlet_t *data, u64 addr, 980 int destid, quadlet_t *data, u64 addr,
1160 size_t length, u16 flags) 981 size_t length, u16 flags)
1161{ 982{
1162
1163 /*
1164 * Manually put the data in the right place.
1165 */
1166 memcpy(bus_to_virt((u32) addr), data, length); 983 memcpy(bus_to_virt((u32) addr), data, length);
1167 sbp2util_packet_dump(data, length, "sbp2 phys dma write by device",
1168 (u32) addr);
1169 return RCODE_COMPLETE; 984 return RCODE_COMPLETE;
1170} 985}
1171 986
1172/* 987/*
1173 * This function deals with physical dma read requests (for adapters that do not support 988 * Deal with read requests on adapters which do not support physical DMA or
1174 * physical dma in hardware). Mostly just here for debugging... 989 * have it switched off.
1175 */ 990 */
1176static int sbp2_handle_physdma_read(struct hpsb_host *host, int nodeid, 991static int sbp2_handle_physdma_read(struct hpsb_host *host, int nodeid,
1177 quadlet_t *data, u64 addr, size_t length, 992 quadlet_t *data, u64 addr, size_t length,
1178 u16 flags) 993 u16 flags)
1179{ 994{
1180
1181 /*
1182 * Grab data from memory and send a read response.
1183 */
1184 memcpy(data, bus_to_virt((u32) addr), length); 995 memcpy(data, bus_to_virt((u32) addr), length);
1185 sbp2util_packet_dump(data, length, "sbp2 phys dma read by device",
1186 (u32) addr);
1187 return RCODE_COMPLETE; 996 return RCODE_COMPLETE;
1188} 997}
1189#endif 998#endif
@@ -1192,74 +1001,69 @@ static int sbp2_handle_physdma_read(struct hpsb_host *host, int nodeid,
1192 * SBP-2 protocol related section 1001 * SBP-2 protocol related section
1193 **************************************/ 1002 **************************************/
1194 1003
1195/* 1004static int sbp2_query_logins(struct sbp2_lu *lu)
1196 * This function queries the device for the maximum concurrent logins it
1197 * supports.
1198 */
1199static int sbp2_query_logins(struct scsi_id_instance_data *scsi_id)
1200{ 1005{
1201 struct sbp2scsi_host_info *hi = scsi_id->hi; 1006 struct sbp2_fwhost_info *hi = lu->hi;
1202 quadlet_t data[2]; 1007 quadlet_t data[2];
1203 int max_logins; 1008 int max_logins;
1204 int active_logins; 1009 int active_logins;
1205 1010
1206 SBP2_DEBUG_ENTER(); 1011 lu->query_logins_orb->reserved1 = 0x0;
1207 1012 lu->query_logins_orb->reserved2 = 0x0;
1208 scsi_id->query_logins_orb->reserved1 = 0x0;
1209 scsi_id->query_logins_orb->reserved2 = 0x0;
1210
1211 scsi_id->query_logins_orb->query_response_lo = scsi_id->query_logins_response_dma;
1212 scsi_id->query_logins_orb->query_response_hi = ORB_SET_NODE_ID(hi->host->node_id);
1213 1013
1214 scsi_id->query_logins_orb->lun_misc = ORB_SET_FUNCTION(SBP2_QUERY_LOGINS_REQUEST); 1014 lu->query_logins_orb->query_response_lo = lu->query_logins_response_dma;
1215 scsi_id->query_logins_orb->lun_misc |= ORB_SET_NOTIFY(1); 1015 lu->query_logins_orb->query_response_hi =
1216 scsi_id->query_logins_orb->lun_misc |= ORB_SET_LUN(scsi_id->sbp2_lun); 1016 ORB_SET_NODE_ID(hi->host->node_id);
1017 lu->query_logins_orb->lun_misc =
1018 ORB_SET_FUNCTION(SBP2_QUERY_LOGINS_REQUEST);
1019 lu->query_logins_orb->lun_misc |= ORB_SET_NOTIFY(1);
1020 lu->query_logins_orb->lun_misc |= ORB_SET_LUN(lu->lun);
1217 1021
1218 scsi_id->query_logins_orb->reserved_resp_length = 1022 lu->query_logins_orb->reserved_resp_length =
1219 ORB_SET_QUERY_LOGINS_RESP_LENGTH(sizeof(struct sbp2_query_logins_response)); 1023 ORB_SET_QUERY_LOGINS_RESP_LENGTH(
1024 sizeof(struct sbp2_query_logins_response));
1220 1025
1221 scsi_id->query_logins_orb->status_fifo_hi = 1026 lu->query_logins_orb->status_fifo_hi =
1222 ORB_SET_STATUS_FIFO_HI(scsi_id->status_fifo_addr, hi->host->node_id); 1027 ORB_SET_STATUS_FIFO_HI(lu->status_fifo_addr, hi->host->node_id);
1223 scsi_id->query_logins_orb->status_fifo_lo = 1028 lu->query_logins_orb->status_fifo_lo =
1224 ORB_SET_STATUS_FIFO_LO(scsi_id->status_fifo_addr); 1029 ORB_SET_STATUS_FIFO_LO(lu->status_fifo_addr);
1225 1030
1226 sbp2util_cpu_to_be32_buffer(scsi_id->query_logins_orb, sizeof(struct sbp2_query_logins_orb)); 1031 sbp2util_cpu_to_be32_buffer(lu->query_logins_orb,
1032 sizeof(struct sbp2_query_logins_orb));
1227 1033
1228 sbp2util_packet_dump(scsi_id->query_logins_orb, sizeof(struct sbp2_query_logins_orb), 1034 memset(lu->query_logins_response, 0,
1229 "sbp2 query logins orb", scsi_id->query_logins_orb_dma); 1035 sizeof(struct sbp2_query_logins_response));
1230
1231 memset(scsi_id->query_logins_response, 0, sizeof(struct sbp2_query_logins_response));
1232 1036
1233 data[0] = ORB_SET_NODE_ID(hi->host->node_id); 1037 data[0] = ORB_SET_NODE_ID(hi->host->node_id);
1234 data[1] = scsi_id->query_logins_orb_dma; 1038 data[1] = lu->query_logins_orb_dma;
1235 sbp2util_cpu_to_be32_buffer(data, 8); 1039 sbp2util_cpu_to_be32_buffer(data, 8);
1236 1040
1237 hpsb_node_write(scsi_id->ne, scsi_id->sbp2_management_agent_addr, data, 8); 1041 hpsb_node_write(lu->ne, lu->management_agent_addr, data, 8);
1238 1042
1239 if (sbp2util_access_timeout(scsi_id, 2*HZ)) { 1043 if (sbp2util_access_timeout(lu, 2*HZ)) {
1240 SBP2_INFO("Error querying logins to SBP-2 device - timed out"); 1044 SBP2_INFO("Error querying logins to SBP-2 device - timed out");
1241 return -EIO; 1045 return -EIO;
1242 } 1046 }
1243 1047
1244 if (scsi_id->status_block.ORB_offset_lo != scsi_id->query_logins_orb_dma) { 1048 if (lu->status_block.ORB_offset_lo != lu->query_logins_orb_dma) {
1245 SBP2_INFO("Error querying logins to SBP-2 device - timed out"); 1049 SBP2_INFO("Error querying logins to SBP-2 device - timed out");
1246 return -EIO; 1050 return -EIO;
1247 } 1051 }
1248 1052
1249 if (STATUS_TEST_RDS(scsi_id->status_block.ORB_offset_hi_misc)) { 1053 if (STATUS_TEST_RDS(lu->status_block.ORB_offset_hi_misc)) {
1250 SBP2_INFO("Error querying logins to SBP-2 device - failed"); 1054 SBP2_INFO("Error querying logins to SBP-2 device - failed");
1251 return -EIO; 1055 return -EIO;
1252 } 1056 }
1253 1057
1254 sbp2util_cpu_to_be32_buffer(scsi_id->query_logins_response, sizeof(struct sbp2_query_logins_response)); 1058 sbp2util_cpu_to_be32_buffer(lu->query_logins_response,
1255 1059 sizeof(struct sbp2_query_logins_response));
1256 SBP2_DEBUG("length_max_logins = %x",
1257 (unsigned int)scsi_id->query_logins_response->length_max_logins);
1258 1060
1259 max_logins = RESPONSE_GET_MAX_LOGINS(scsi_id->query_logins_response->length_max_logins); 1061 max_logins = RESPONSE_GET_MAX_LOGINS(
1062 lu->query_logins_response->length_max_logins);
1260 SBP2_INFO("Maximum concurrent logins supported: %d", max_logins); 1063 SBP2_INFO("Maximum concurrent logins supported: %d", max_logins);
1261 1064
1262 active_logins = RESPONSE_GET_ACTIVE_LOGINS(scsi_id->query_logins_response->length_max_logins); 1065 active_logins = RESPONSE_GET_ACTIVE_LOGINS(
1066 lu->query_logins_response->length_max_logins);
1263 SBP2_INFO("Number of active logins: %d", active_logins); 1067 SBP2_INFO("Number of active logins: %d", active_logins);
1264 1068
1265 if (active_logins >= max_logins) { 1069 if (active_logins >= max_logins) {
@@ -1269,332 +1073,231 @@ static int sbp2_query_logins(struct scsi_id_instance_data *scsi_id)
1269 return 0; 1073 return 0;
1270} 1074}
1271 1075
1272/* 1076static int sbp2_login_device(struct sbp2_lu *lu)
1273 * This function is called in order to login to a particular SBP-2 device,
1274 * after a bus reset.
1275 */
1276static int sbp2_login_device(struct scsi_id_instance_data *scsi_id)
1277{ 1077{
1278 struct sbp2scsi_host_info *hi = scsi_id->hi; 1078 struct sbp2_fwhost_info *hi = lu->hi;
1279 quadlet_t data[2]; 1079 quadlet_t data[2];
1280 1080
1281 SBP2_DEBUG_ENTER(); 1081 if (!lu->login_orb)
1282
1283 if (!scsi_id->login_orb) {
1284 SBP2_DEBUG("%s: login_orb not alloc'd!", __FUNCTION__);
1285 return -EIO; 1082 return -EIO;
1286 }
1287 1083
1288 if (!exclusive_login) { 1084 if (!sbp2_exclusive_login && sbp2_query_logins(lu)) {
1289 if (sbp2_query_logins(scsi_id)) { 1085 SBP2_INFO("Device does not support any more concurrent logins");
1290 SBP2_INFO("Device does not support any more concurrent logins"); 1086 return -EIO;
1291 return -EIO;
1292 }
1293 } 1087 }
1294 1088
1295 /* Set-up login ORB, assume no password */ 1089 /* assume no password */
1296 scsi_id->login_orb->password_hi = 0; 1090 lu->login_orb->password_hi = 0;
1297 scsi_id->login_orb->password_lo = 0; 1091 lu->login_orb->password_lo = 0;
1298 1092
1299 scsi_id->login_orb->login_response_lo = scsi_id->login_response_dma; 1093 lu->login_orb->login_response_lo = lu->login_response_dma;
1300 scsi_id->login_orb->login_response_hi = ORB_SET_NODE_ID(hi->host->node_id); 1094 lu->login_orb->login_response_hi = ORB_SET_NODE_ID(hi->host->node_id);
1095 lu->login_orb->lun_misc = ORB_SET_FUNCTION(SBP2_LOGIN_REQUEST);
1301 1096
1302 scsi_id->login_orb->lun_misc = ORB_SET_FUNCTION(SBP2_LOGIN_REQUEST); 1097 /* one second reconnect time */
1303 scsi_id->login_orb->lun_misc |= ORB_SET_RECONNECT(0); /* One second reconnect time */ 1098 lu->login_orb->lun_misc |= ORB_SET_RECONNECT(0);
1304 scsi_id->login_orb->lun_misc |= ORB_SET_EXCLUSIVE(exclusive_login); /* Exclusive access to device */ 1099 lu->login_orb->lun_misc |= ORB_SET_EXCLUSIVE(sbp2_exclusive_login);
1305 scsi_id->login_orb->lun_misc |= ORB_SET_NOTIFY(1); /* Notify us of login complete */ 1100 lu->login_orb->lun_misc |= ORB_SET_NOTIFY(1);
1306 scsi_id->login_orb->lun_misc |= ORB_SET_LUN(scsi_id->sbp2_lun); 1101 lu->login_orb->lun_misc |= ORB_SET_LUN(lu->lun);
1307 1102
1308 scsi_id->login_orb->passwd_resp_lengths = 1103 lu->login_orb->passwd_resp_lengths =
1309 ORB_SET_LOGIN_RESP_LENGTH(sizeof(struct sbp2_login_response)); 1104 ORB_SET_LOGIN_RESP_LENGTH(sizeof(struct sbp2_login_response));
1310 1105
1311 scsi_id->login_orb->status_fifo_hi = 1106 lu->login_orb->status_fifo_hi =
1312 ORB_SET_STATUS_FIFO_HI(scsi_id->status_fifo_addr, hi->host->node_id); 1107 ORB_SET_STATUS_FIFO_HI(lu->status_fifo_addr, hi->host->node_id);
1313 scsi_id->login_orb->status_fifo_lo = 1108 lu->login_orb->status_fifo_lo =
1314 ORB_SET_STATUS_FIFO_LO(scsi_id->status_fifo_addr); 1109 ORB_SET_STATUS_FIFO_LO(lu->status_fifo_addr);
1315 1110
1316 sbp2util_cpu_to_be32_buffer(scsi_id->login_orb, sizeof(struct sbp2_login_orb)); 1111 sbp2util_cpu_to_be32_buffer(lu->login_orb,
1112 sizeof(struct sbp2_login_orb));
1317 1113
1318 sbp2util_packet_dump(scsi_id->login_orb, sizeof(struct sbp2_login_orb), 1114 memset(lu->login_response, 0, sizeof(struct sbp2_login_response));
1319 "sbp2 login orb", scsi_id->login_orb_dma);
1320
1321 memset(scsi_id->login_response, 0, sizeof(struct sbp2_login_response));
1322 1115
1323 data[0] = ORB_SET_NODE_ID(hi->host->node_id); 1116 data[0] = ORB_SET_NODE_ID(hi->host->node_id);
1324 data[1] = scsi_id->login_orb_dma; 1117 data[1] = lu->login_orb_dma;
1325 sbp2util_cpu_to_be32_buffer(data, 8); 1118 sbp2util_cpu_to_be32_buffer(data, 8);
1326 1119
1327 hpsb_node_write(scsi_id->ne, scsi_id->sbp2_management_agent_addr, data, 8); 1120 hpsb_node_write(lu->ne, lu->management_agent_addr, data, 8);
1328 1121
1329 /* 1122 /* wait up to 20 seconds for login status */
1330 * Wait for login status (up to 20 seconds)... 1123 if (sbp2util_access_timeout(lu, 20*HZ)) {
1331 */
1332 if (sbp2util_access_timeout(scsi_id, 20*HZ)) {
1333 SBP2_ERR("Error logging into SBP-2 device - timed out"); 1124 SBP2_ERR("Error logging into SBP-2 device - timed out");
1334 return -EIO; 1125 return -EIO;
1335 } 1126 }
1336 1127
1337 /* 1128 /* make sure that the returned status matches the login ORB */
1338 * Sanity. Make sure status returned matches login orb. 1129 if (lu->status_block.ORB_offset_lo != lu->login_orb_dma) {
1339 */
1340 if (scsi_id->status_block.ORB_offset_lo != scsi_id->login_orb_dma) {
1341 SBP2_ERR("Error logging into SBP-2 device - timed out"); 1130 SBP2_ERR("Error logging into SBP-2 device - timed out");
1342 return -EIO; 1131 return -EIO;
1343 } 1132 }
1344 1133
1345 if (STATUS_TEST_RDS(scsi_id->status_block.ORB_offset_hi_misc)) { 1134 if (STATUS_TEST_RDS(lu->status_block.ORB_offset_hi_misc)) {
1346 SBP2_ERR("Error logging into SBP-2 device - failed"); 1135 SBP2_ERR("Error logging into SBP-2 device - failed");
1347 return -EIO; 1136 return -EIO;
1348 } 1137 }
1349 1138
1350 /* 1139 sbp2util_cpu_to_be32_buffer(lu->login_response,
1351 * Byte swap the login response, for use when reconnecting or 1140 sizeof(struct sbp2_login_response));
1352 * logging out. 1141 lu->command_block_agent_addr =
1353 */ 1142 ((u64)lu->login_response->command_block_agent_hi) << 32;
1354 sbp2util_cpu_to_be32_buffer(scsi_id->login_response, sizeof(struct sbp2_login_response)); 1143 lu->command_block_agent_addr |=
1355 1144 ((u64)lu->login_response->command_block_agent_lo);
1356 /* 1145 lu->command_block_agent_addr &= 0x0000ffffffffffffULL;
1357 * Grab our command block agent address from the login response.
1358 */
1359 SBP2_DEBUG("command_block_agent_hi = %x",
1360 (unsigned int)scsi_id->login_response->command_block_agent_hi);
1361 SBP2_DEBUG("command_block_agent_lo = %x",
1362 (unsigned int)scsi_id->login_response->command_block_agent_lo);
1363
1364 scsi_id->sbp2_command_block_agent_addr =
1365 ((u64)scsi_id->login_response->command_block_agent_hi) << 32;
1366 scsi_id->sbp2_command_block_agent_addr |= ((u64)scsi_id->login_response->command_block_agent_lo);
1367 scsi_id->sbp2_command_block_agent_addr &= 0x0000ffffffffffffULL;
1368 1146
1369 SBP2_INFO("Logged into SBP-2 device"); 1147 SBP2_INFO("Logged into SBP-2 device");
1370 return 0; 1148 return 0;
1371} 1149}
1372 1150
1373/* 1151static int sbp2_logout_device(struct sbp2_lu *lu)
1374 * This function is called in order to logout from a particular SBP-2
1375 * device, usually called during driver unload.
1376 */
1377static int sbp2_logout_device(struct scsi_id_instance_data *scsi_id)
1378{ 1152{
1379 struct sbp2scsi_host_info *hi = scsi_id->hi; 1153 struct sbp2_fwhost_info *hi = lu->hi;
1380 quadlet_t data[2]; 1154 quadlet_t data[2];
1381 int error; 1155 int error;
1382 1156
1383 SBP2_DEBUG_ENTER(); 1157 lu->logout_orb->reserved1 = 0x0;
1384 1158 lu->logout_orb->reserved2 = 0x0;
1385 /* 1159 lu->logout_orb->reserved3 = 0x0;
1386 * Set-up logout ORB 1160 lu->logout_orb->reserved4 = 0x0;
1387 */
1388 scsi_id->logout_orb->reserved1 = 0x0;
1389 scsi_id->logout_orb->reserved2 = 0x0;
1390 scsi_id->logout_orb->reserved3 = 0x0;
1391 scsi_id->logout_orb->reserved4 = 0x0;
1392
1393 scsi_id->logout_orb->login_ID_misc = ORB_SET_FUNCTION(SBP2_LOGOUT_REQUEST);
1394 scsi_id->logout_orb->login_ID_misc |= ORB_SET_LOGIN_ID(scsi_id->login_response->length_login_ID);
1395
1396 /* Notify us when complete */
1397 scsi_id->logout_orb->login_ID_misc |= ORB_SET_NOTIFY(1);
1398 1161
1399 scsi_id->logout_orb->reserved5 = 0x0; 1162 lu->logout_orb->login_ID_misc = ORB_SET_FUNCTION(SBP2_LOGOUT_REQUEST);
1400 scsi_id->logout_orb->status_fifo_hi = 1163 lu->logout_orb->login_ID_misc |=
1401 ORB_SET_STATUS_FIFO_HI(scsi_id->status_fifo_addr, hi->host->node_id); 1164 ORB_SET_LOGIN_ID(lu->login_response->length_login_ID);
1402 scsi_id->logout_orb->status_fifo_lo = 1165 lu->logout_orb->login_ID_misc |= ORB_SET_NOTIFY(1);
1403 ORB_SET_STATUS_FIFO_LO(scsi_id->status_fifo_addr);
1404 1166
1405 /* 1167 lu->logout_orb->reserved5 = 0x0;
1406 * Byte swap ORB if necessary 1168 lu->logout_orb->status_fifo_hi =
1407 */ 1169 ORB_SET_STATUS_FIFO_HI(lu->status_fifo_addr, hi->host->node_id);
1408 sbp2util_cpu_to_be32_buffer(scsi_id->logout_orb, sizeof(struct sbp2_logout_orb)); 1170 lu->logout_orb->status_fifo_lo =
1171 ORB_SET_STATUS_FIFO_LO(lu->status_fifo_addr);
1409 1172
1410 sbp2util_packet_dump(scsi_id->logout_orb, sizeof(struct sbp2_logout_orb), 1173 sbp2util_cpu_to_be32_buffer(lu->logout_orb,
1411 "sbp2 logout orb", scsi_id->logout_orb_dma); 1174 sizeof(struct sbp2_logout_orb));
1412 1175
1413 /*
1414 * Ok, let's write to the target's management agent register
1415 */
1416 data[0] = ORB_SET_NODE_ID(hi->host->node_id); 1176 data[0] = ORB_SET_NODE_ID(hi->host->node_id);
1417 data[1] = scsi_id->logout_orb_dma; 1177 data[1] = lu->logout_orb_dma;
1418 sbp2util_cpu_to_be32_buffer(data, 8); 1178 sbp2util_cpu_to_be32_buffer(data, 8);
1419 1179
1420 error = hpsb_node_write(scsi_id->ne, 1180 error = hpsb_node_write(lu->ne, lu->management_agent_addr, data, 8);
1421 scsi_id->sbp2_management_agent_addr, data, 8);
1422 if (error) 1181 if (error)
1423 return error; 1182 return error;
1424 1183
1425 /* Wait for device to logout...1 second. */ 1184 /* wait up to 1 second for the device to complete logout */
1426 if (sbp2util_access_timeout(scsi_id, HZ)) 1185 if (sbp2util_access_timeout(lu, HZ))
1427 return -EIO; 1186 return -EIO;
1428 1187
1429 SBP2_INFO("Logged out of SBP-2 device"); 1188 SBP2_INFO("Logged out of SBP-2 device");
1430 return 0; 1189 return 0;
1431} 1190}
1432 1191
1433/* 1192static int sbp2_reconnect_device(struct sbp2_lu *lu)
1434 * This function is called in order to reconnect to a particular SBP-2
1435 * device, after a bus reset.
1436 */
1437static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id)
1438{ 1193{
1439 struct sbp2scsi_host_info *hi = scsi_id->hi; 1194 struct sbp2_fwhost_info *hi = lu->hi;
1440 quadlet_t data[2]; 1195 quadlet_t data[2];
1441 int error; 1196 int error;
1442 1197
1443 SBP2_DEBUG_ENTER(); 1198 lu->reconnect_orb->reserved1 = 0x0;
1199 lu->reconnect_orb->reserved2 = 0x0;
1200 lu->reconnect_orb->reserved3 = 0x0;
1201 lu->reconnect_orb->reserved4 = 0x0;
1444 1202
1445 /* 1203 lu->reconnect_orb->login_ID_misc =
1446 * Set-up reconnect ORB 1204 ORB_SET_FUNCTION(SBP2_RECONNECT_REQUEST);
1447 */ 1205 lu->reconnect_orb->login_ID_misc |=
1448 scsi_id->reconnect_orb->reserved1 = 0x0; 1206 ORB_SET_LOGIN_ID(lu->login_response->length_login_ID);
1449 scsi_id->reconnect_orb->reserved2 = 0x0; 1207 lu->reconnect_orb->login_ID_misc |= ORB_SET_NOTIFY(1);
1450 scsi_id->reconnect_orb->reserved3 = 0x0;
1451 scsi_id->reconnect_orb->reserved4 = 0x0;
1452
1453 scsi_id->reconnect_orb->login_ID_misc = ORB_SET_FUNCTION(SBP2_RECONNECT_REQUEST);
1454 scsi_id->reconnect_orb->login_ID_misc |=
1455 ORB_SET_LOGIN_ID(scsi_id->login_response->length_login_ID);
1456 1208
1457 /* Notify us when complete */ 1209 lu->reconnect_orb->reserved5 = 0x0;
1458 scsi_id->reconnect_orb->login_ID_misc |= ORB_SET_NOTIFY(1); 1210 lu->reconnect_orb->status_fifo_hi =
1211 ORB_SET_STATUS_FIFO_HI(lu->status_fifo_addr, hi->host->node_id);
1212 lu->reconnect_orb->status_fifo_lo =
1213 ORB_SET_STATUS_FIFO_LO(lu->status_fifo_addr);
1459 1214
1460 scsi_id->reconnect_orb->reserved5 = 0x0; 1215 sbp2util_cpu_to_be32_buffer(lu->reconnect_orb,
1461 scsi_id->reconnect_orb->status_fifo_hi = 1216 sizeof(struct sbp2_reconnect_orb));
1462 ORB_SET_STATUS_FIFO_HI(scsi_id->status_fifo_addr, hi->host->node_id);
1463 scsi_id->reconnect_orb->status_fifo_lo =
1464 ORB_SET_STATUS_FIFO_LO(scsi_id->status_fifo_addr);
1465
1466 /*
1467 * Byte swap ORB if necessary
1468 */
1469 sbp2util_cpu_to_be32_buffer(scsi_id->reconnect_orb, sizeof(struct sbp2_reconnect_orb));
1470
1471 sbp2util_packet_dump(scsi_id->reconnect_orb, sizeof(struct sbp2_reconnect_orb),
1472 "sbp2 reconnect orb", scsi_id->reconnect_orb_dma);
1473 1217
1474 data[0] = ORB_SET_NODE_ID(hi->host->node_id); 1218 data[0] = ORB_SET_NODE_ID(hi->host->node_id);
1475 data[1] = scsi_id->reconnect_orb_dma; 1219 data[1] = lu->reconnect_orb_dma;
1476 sbp2util_cpu_to_be32_buffer(data, 8); 1220 sbp2util_cpu_to_be32_buffer(data, 8);
1477 1221
1478 error = hpsb_node_write(scsi_id->ne, 1222 error = hpsb_node_write(lu->ne, lu->management_agent_addr, data, 8);
1479 scsi_id->sbp2_management_agent_addr, data, 8);
1480 if (error) 1223 if (error)
1481 return error; 1224 return error;
1482 1225
1483 /* 1226 /* wait up to 1 second for reconnect status */
1484 * Wait for reconnect status (up to 1 second)... 1227 if (sbp2util_access_timeout(lu, HZ)) {
1485 */
1486 if (sbp2util_access_timeout(scsi_id, HZ)) {
1487 SBP2_ERR("Error reconnecting to SBP-2 device - timed out"); 1228 SBP2_ERR("Error reconnecting to SBP-2 device - timed out");
1488 return -EIO; 1229 return -EIO;
1489 } 1230 }
1490 1231
1491 /* 1232 /* make sure that the returned status matches the reconnect ORB */
1492 * Sanity. Make sure status returned matches reconnect orb. 1233 if (lu->status_block.ORB_offset_lo != lu->reconnect_orb_dma) {
1493 */
1494 if (scsi_id->status_block.ORB_offset_lo != scsi_id->reconnect_orb_dma) {
1495 SBP2_ERR("Error reconnecting to SBP-2 device - timed out"); 1234 SBP2_ERR("Error reconnecting to SBP-2 device - timed out");
1496 return -EIO; 1235 return -EIO;
1497 } 1236 }
1498 1237
1499 if (STATUS_TEST_RDS(scsi_id->status_block.ORB_offset_hi_misc)) { 1238 if (STATUS_TEST_RDS(lu->status_block.ORB_offset_hi_misc)) {
1500 SBP2_ERR("Error reconnecting to SBP-2 device - failed"); 1239 SBP2_ERR("Error reconnecting to SBP-2 device - failed");
1501 return -EIO; 1240 return -EIO;
1502 } 1241 }
1503 1242
1504 HPSB_DEBUG("Reconnected to SBP-2 device"); 1243 SBP2_INFO("Reconnected to SBP-2 device");
1505 return 0; 1244 return 0;
1506} 1245}
1507 1246
1508/* 1247/*
1509 * This function is called in order to set the busy timeout (number of 1248 * Set the target node's Single Phase Retry limit. Affects the target's retry
1510 * retries to attempt) on the sbp2 device. 1249 * behaviour if our node is too busy to accept requests.
1511 */ 1250 */
1512static int sbp2_set_busy_timeout(struct scsi_id_instance_data *scsi_id) 1251static int sbp2_set_busy_timeout(struct sbp2_lu *lu)
1513{ 1252{
1514 quadlet_t data; 1253 quadlet_t data;
1515 1254
1516 SBP2_DEBUG_ENTER();
1517
1518 data = cpu_to_be32(SBP2_BUSY_TIMEOUT_VALUE); 1255 data = cpu_to_be32(SBP2_BUSY_TIMEOUT_VALUE);
1519 if (hpsb_node_write(scsi_id->ne, SBP2_BUSY_TIMEOUT_ADDRESS, &data, 4)) 1256 if (hpsb_node_write(lu->ne, SBP2_BUSY_TIMEOUT_ADDRESS, &data, 4))
1520 SBP2_ERR("%s error", __FUNCTION__); 1257 SBP2_ERR("%s error", __FUNCTION__);
1521 return 0; 1258 return 0;
1522} 1259}
1523 1260
1524/* 1261static void sbp2_parse_unit_directory(struct sbp2_lu *lu,
1525 * This function is called to parse sbp2 device's config rom unit
1526 * directory. Used to determine things like sbp2 management agent offset,
1527 * and command set used (SCSI or RBC).
1528 */
1529static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id,
1530 struct unit_directory *ud) 1262 struct unit_directory *ud)
1531{ 1263{
1532 struct csr1212_keyval *kv; 1264 struct csr1212_keyval *kv;
1533 struct csr1212_dentry *dentry; 1265 struct csr1212_dentry *dentry;
1534 u64 management_agent_addr; 1266 u64 management_agent_addr;
1535 u32 command_set_spec_id, command_set, unit_characteristics, 1267 u32 unit_characteristics, firmware_revision;
1536 firmware_revision;
1537 unsigned workarounds; 1268 unsigned workarounds;
1538 int i; 1269 int i;
1539 1270
1540 SBP2_DEBUG_ENTER(); 1271 management_agent_addr = 0;
1272 unit_characteristics = 0;
1273 firmware_revision = 0;
1541 1274
1542 management_agent_addr = 0x0;
1543 command_set_spec_id = 0x0;
1544 command_set = 0x0;
1545 unit_characteristics = 0x0;
1546 firmware_revision = 0x0;
1547
1548 /* Handle different fields in the unit directory, based on keys */
1549 csr1212_for_each_dir_entry(ud->ne->csr, kv, ud->ud_kv, dentry) { 1275 csr1212_for_each_dir_entry(ud->ne->csr, kv, ud->ud_kv, dentry) {
1550 switch (kv->key.id) { 1276 switch (kv->key.id) {
1551 case CSR1212_KV_ID_DEPENDENT_INFO: 1277 case CSR1212_KV_ID_DEPENDENT_INFO:
1552 if (kv->key.type == CSR1212_KV_TYPE_CSR_OFFSET) { 1278 if (kv->key.type == CSR1212_KV_TYPE_CSR_OFFSET)
1553 /* Save off the management agent address */
1554 management_agent_addr = 1279 management_agent_addr =
1555 CSR1212_REGISTER_SPACE_BASE + 1280 CSR1212_REGISTER_SPACE_BASE +
1556 (kv->value.csr_offset << 2); 1281 (kv->value.csr_offset << 2);
1557 1282
1558 SBP2_DEBUG("sbp2_management_agent_addr = %x", 1283 else if (kv->key.type == CSR1212_KV_TYPE_IMMEDIATE)
1559 (unsigned int)management_agent_addr); 1284 lu->lun = ORB_SET_LUN(kv->value.immediate);
1560 } else if (kv->key.type == CSR1212_KV_TYPE_IMMEDIATE) {
1561 scsi_id->sbp2_lun =
1562 ORB_SET_LUN(kv->value.immediate);
1563 }
1564 break;
1565
1566 case SBP2_COMMAND_SET_SPEC_ID_KEY:
1567 /* Command spec organization */
1568 command_set_spec_id = kv->value.immediate;
1569 SBP2_DEBUG("sbp2_command_set_spec_id = %x",
1570 (unsigned int)command_set_spec_id);
1571 break;
1572
1573 case SBP2_COMMAND_SET_KEY:
1574 /* Command set used by sbp2 device */
1575 command_set = kv->value.immediate;
1576 SBP2_DEBUG("sbp2_command_set = %x",
1577 (unsigned int)command_set);
1578 break; 1285 break;
1579 1286
1580 case SBP2_UNIT_CHARACTERISTICS_KEY: 1287 case SBP2_UNIT_CHARACTERISTICS_KEY:
1581 /* 1288 /* FIXME: This is ignored so far.
1582 * Unit characterisitcs (orb related stuff 1289 * See SBP-2 clause 7.4.8. */
1583 * that I'm not yet paying attention to)
1584 */
1585 unit_characteristics = kv->value.immediate; 1290 unit_characteristics = kv->value.immediate;
1586 SBP2_DEBUG("sbp2_unit_characteristics = %x",
1587 (unsigned int)unit_characteristics);
1588 break; 1291 break;
1589 1292
1590 case SBP2_FIRMWARE_REVISION_KEY: 1293 case SBP2_FIRMWARE_REVISION_KEY:
1591 /* Firmware revision */
1592 firmware_revision = kv->value.immediate; 1294 firmware_revision = kv->value.immediate;
1593 SBP2_DEBUG("sbp2_firmware_revision = %x",
1594 (unsigned int)firmware_revision);
1595 break; 1295 break;
1596 1296
1597 default: 1297 default:
1298 /* FIXME: Check for SBP2_DEVICE_TYPE_AND_LUN_KEY.
1299 * Its "ordered" bit has consequences for command ORB
1300 * list handling. See SBP-2 clauses 4.6, 7.4.11, 10.2 */
1598 break; 1301 break;
1599 } 1302 }
1600 } 1303 }
@@ -1626,28 +1329,24 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id,
1626 /* We would need one SCSI host template for each target to adjust 1329 /* We would need one SCSI host template for each target to adjust
1627 * max_sectors on the fly, therefore warn only. */ 1330 * max_sectors on the fly, therefore warn only. */
1628 if (workarounds & SBP2_WORKAROUND_128K_MAX_TRANS && 1331 if (workarounds & SBP2_WORKAROUND_128K_MAX_TRANS &&
1629 (max_sectors * 512) > (128 * 1024)) 1332 (sbp2_max_sectors * 512) > (128 * 1024))
1630 SBP2_WARN("Node " NODE_BUS_FMT ": Bridge only supports 128KB " 1333 SBP2_INFO("Node " NODE_BUS_FMT ": Bridge only supports 128KB "
1631 "max transfer size. WARNING: Current max_sectors " 1334 "max transfer size. WARNING: Current max_sectors "
1632 "setting is larger than 128KB (%d sectors)", 1335 "setting is larger than 128KB (%d sectors)",
1633 NODE_BUS_ARGS(ud->ne->host, ud->ne->nodeid), 1336 NODE_BUS_ARGS(ud->ne->host, ud->ne->nodeid),
1634 max_sectors); 1337 sbp2_max_sectors);
1635 1338
1636 /* If this is a logical unit directory entry, process the parent 1339 /* If this is a logical unit directory entry, process the parent
1637 * to get the values. */ 1340 * to get the values. */
1638 if (ud->flags & UNIT_DIRECTORY_LUN_DIRECTORY) { 1341 if (ud->flags & UNIT_DIRECTORY_LUN_DIRECTORY) {
1639 struct unit_directory *parent_ud = 1342 struct unit_directory *parent_ud = container_of(
1640 container_of(ud->device.parent, struct unit_directory, device); 1343 ud->device.parent, struct unit_directory, device);
1641 sbp2_parse_unit_directory(scsi_id, parent_ud); 1344 sbp2_parse_unit_directory(lu, parent_ud);
1642 } else { 1345 } else {
1643 scsi_id->sbp2_management_agent_addr = management_agent_addr; 1346 lu->management_agent_addr = management_agent_addr;
1644 scsi_id->sbp2_command_set_spec_id = command_set_spec_id; 1347 lu->workarounds = workarounds;
1645 scsi_id->sbp2_command_set = command_set;
1646 scsi_id->sbp2_unit_characteristics = unit_characteristics;
1647 scsi_id->sbp2_firmware_revision = firmware_revision;
1648 scsi_id->workarounds = workarounds;
1649 if (ud->flags & UNIT_DIRECTORY_HAS_LUN) 1348 if (ud->flags & UNIT_DIRECTORY_HAS_LUN)
1650 scsi_id->sbp2_lun = ORB_SET_LUN(ud->lun); 1349 lu->lun = ORB_SET_LUN(ud->lun);
1651 } 1350 }
1652} 1351}
1653 1352
@@ -1662,133 +1361,114 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id,
1662 * the speed that it needs to use, and the max_rec the host supports, and 1361 * the speed that it needs to use, and the max_rec the host supports, and
1663 * it takes care of the rest. 1362 * it takes care of the rest.
1664 */ 1363 */
1665static int sbp2_max_speed_and_size(struct scsi_id_instance_data *scsi_id) 1364static int sbp2_max_speed_and_size(struct sbp2_lu *lu)
1666{ 1365{
1667 struct sbp2scsi_host_info *hi = scsi_id->hi; 1366 struct sbp2_fwhost_info *hi = lu->hi;
1668 u8 payload; 1367 u8 payload;
1669 1368
1670 SBP2_DEBUG_ENTER(); 1369 lu->speed_code = hi->host->speed[NODEID_TO_NODE(lu->ne->nodeid)];
1671
1672 scsi_id->speed_code =
1673 hi->host->speed[NODEID_TO_NODE(scsi_id->ne->nodeid)];
1674 1370
1675 /* Bump down our speed if the user requested it */ 1371 if (lu->speed_code > sbp2_max_speed) {
1676 if (scsi_id->speed_code > max_speed) { 1372 lu->speed_code = sbp2_max_speed;
1677 scsi_id->speed_code = max_speed; 1373 SBP2_INFO("Reducing speed to %s",
1678 SBP2_ERR("Forcing SBP-2 max speed down to %s", 1374 hpsb_speedto_str[sbp2_max_speed]);
1679 hpsb_speedto_str[scsi_id->speed_code]);
1680 } 1375 }
1681 1376
1682 /* Payload size is the lesser of what our speed supports and what 1377 /* Payload size is the lesser of what our speed supports and what
1683 * our host supports. */ 1378 * our host supports. */
1684 payload = min(sbp2_speedto_max_payload[scsi_id->speed_code], 1379 payload = min(sbp2_speedto_max_payload[lu->speed_code],
1685 (u8) (hi->host->csr.max_rec - 1)); 1380 (u8) (hi->host->csr.max_rec - 1));
1686 1381
1687 /* If physical DMA is off, work around limitation in ohci1394: 1382 /* If physical DMA is off, work around limitation in ohci1394:
1688 * packet size must not exceed PAGE_SIZE */ 1383 * packet size must not exceed PAGE_SIZE */
1689 if (scsi_id->ne->host->low_addr_space < (1ULL << 32)) 1384 if (lu->ne->host->low_addr_space < (1ULL << 32))
1690 while (SBP2_PAYLOAD_TO_BYTES(payload) + 24 > PAGE_SIZE && 1385 while (SBP2_PAYLOAD_TO_BYTES(payload) + 24 > PAGE_SIZE &&
1691 payload) 1386 payload)
1692 payload--; 1387 payload--;
1693 1388
1694 HPSB_DEBUG("Node " NODE_BUS_FMT ": Max speed [%s] - Max payload [%u]", 1389 SBP2_INFO("Node " NODE_BUS_FMT ": Max speed [%s] - Max payload [%u]",
1695 NODE_BUS_ARGS(hi->host, scsi_id->ne->nodeid), 1390 NODE_BUS_ARGS(hi->host, lu->ne->nodeid),
1696 hpsb_speedto_str[scsi_id->speed_code], 1391 hpsb_speedto_str[lu->speed_code],
1697 SBP2_PAYLOAD_TO_BYTES(payload)); 1392 SBP2_PAYLOAD_TO_BYTES(payload));
1698 1393
1699 scsi_id->max_payload_size = payload; 1394 lu->max_payload_size = payload;
1700 return 0; 1395 return 0;
1701} 1396}
1702 1397
1703/* 1398static int sbp2_agent_reset(struct sbp2_lu *lu, int wait)
1704 * This function is called in order to perform a SBP-2 agent reset.
1705 */
1706static int sbp2_agent_reset(struct scsi_id_instance_data *scsi_id, int wait)
1707{ 1399{
1708 quadlet_t data; 1400 quadlet_t data;
1709 u64 addr; 1401 u64 addr;
1710 int retval; 1402 int retval;
1711 unsigned long flags; 1403 unsigned long flags;
1712 1404
1713 SBP2_DEBUG_ENTER(); 1405 /* flush lu->protocol_work */
1714
1715 cancel_delayed_work(&scsi_id->protocol_work);
1716 if (wait) 1406 if (wait)
1717 flush_scheduled_work(); 1407 flush_scheduled_work();
1718 1408
1719 data = ntohl(SBP2_AGENT_RESET_DATA); 1409 data = ntohl(SBP2_AGENT_RESET_DATA);
1720 addr = scsi_id->sbp2_command_block_agent_addr + SBP2_AGENT_RESET_OFFSET; 1410 addr = lu->command_block_agent_addr + SBP2_AGENT_RESET_OFFSET;
1721 1411
1722 if (wait) 1412 if (wait)
1723 retval = hpsb_node_write(scsi_id->ne, addr, &data, 4); 1413 retval = hpsb_node_write(lu->ne, addr, &data, 4);
1724 else 1414 else
1725 retval = sbp2util_node_write_no_wait(scsi_id->ne, addr, &data, 4); 1415 retval = sbp2util_node_write_no_wait(lu->ne, addr, &data, 4);
1726 1416
1727 if (retval < 0) { 1417 if (retval < 0) {
1728 SBP2_ERR("hpsb_node_write failed.\n"); 1418 SBP2_ERR("hpsb_node_write failed.\n");
1729 return -EIO; 1419 return -EIO;
1730 } 1420 }
1731 1421
1732 /* 1422 /* make sure that the ORB_POINTER is written on next command */
1733 * Need to make sure orb pointer is written on next command 1423 spin_lock_irqsave(&lu->cmd_orb_lock, flags);
1734 */ 1424 lu->last_orb = NULL;
1735 spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags); 1425 spin_unlock_irqrestore(&lu->cmd_orb_lock, flags);
1736 scsi_id->last_orb = NULL;
1737 spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags);
1738 1426
1739 return 0; 1427 return 0;
1740} 1428}
1741 1429
1742static void sbp2_prep_command_orb_sg(struct sbp2_command_orb *orb, 1430static void sbp2_prep_command_orb_sg(struct sbp2_command_orb *orb,
1743 struct sbp2scsi_host_info *hi, 1431 struct sbp2_fwhost_info *hi,
1744 struct sbp2_command_info *command, 1432 struct sbp2_command_info *cmd,
1745 unsigned int scsi_use_sg, 1433 unsigned int scsi_use_sg,
1746 struct scatterlist *sgpnt, 1434 struct scatterlist *sgpnt,
1747 u32 orb_direction, 1435 u32 orb_direction,
1748 enum dma_data_direction dma_dir) 1436 enum dma_data_direction dma_dir)
1749{ 1437{
1750 command->dma_dir = dma_dir; 1438 cmd->dma_dir = dma_dir;
1751 orb->data_descriptor_hi = ORB_SET_NODE_ID(hi->host->node_id); 1439 orb->data_descriptor_hi = ORB_SET_NODE_ID(hi->host->node_id);
1752 orb->misc |= ORB_SET_DIRECTION(orb_direction); 1440 orb->misc |= ORB_SET_DIRECTION(orb_direction);
1753 1441
1754 /* Special case if only one element (and less than 64KB in size) */ 1442 /* special case if only one element (and less than 64KB in size) */
1755 if ((scsi_use_sg == 1) && 1443 if ((scsi_use_sg == 1) &&
1756 (sgpnt[0].length <= SBP2_MAX_SG_ELEMENT_LENGTH)) { 1444 (sgpnt[0].length <= SBP2_MAX_SG_ELEMENT_LENGTH)) {
1757 1445
1758 SBP2_DEBUG("Only one s/g element"); 1446 cmd->dma_size = sgpnt[0].length;
1759 command->dma_size = sgpnt[0].length; 1447 cmd->dma_type = CMD_DMA_PAGE;
1760 command->dma_type = CMD_DMA_PAGE; 1448 cmd->cmd_dma = dma_map_page(&hi->host->device,
1761 command->cmd_dma = pci_map_page(hi->host->pdev, 1449 sgpnt[0].page, sgpnt[0].offset,
1762 sgpnt[0].page, 1450 cmd->dma_size, cmd->dma_dir);
1763 sgpnt[0].offset,
1764 command->dma_size,
1765 command->dma_dir);
1766 SBP2_DMA_ALLOC("single page scatter element");
1767 1451
1768 orb->data_descriptor_lo = command->cmd_dma; 1452 orb->data_descriptor_lo = cmd->cmd_dma;
1769 orb->misc |= ORB_SET_DATA_SIZE(command->dma_size); 1453 orb->misc |= ORB_SET_DATA_SIZE(cmd->dma_size);
1770 1454
1771 } else { 1455 } else {
1772 struct sbp2_unrestricted_page_table *sg_element = 1456 struct sbp2_unrestricted_page_table *sg_element =
1773 &command->scatter_gather_element[0]; 1457 &cmd->scatter_gather_element[0];
1774 u32 sg_count, sg_len; 1458 u32 sg_count, sg_len;
1775 dma_addr_t sg_addr; 1459 dma_addr_t sg_addr;
1776 int i, count = pci_map_sg(hi->host->pdev, sgpnt, scsi_use_sg, 1460 int i, count = dma_map_sg(&hi->host->device, sgpnt, scsi_use_sg,
1777 dma_dir); 1461 dma_dir);
1778 1462
1779 SBP2_DMA_ALLOC("scatter list"); 1463 cmd->dma_size = scsi_use_sg;
1780 1464 cmd->sge_buffer = sgpnt;
1781 command->dma_size = scsi_use_sg;
1782 command->sge_buffer = sgpnt;
1783 1465
1784 /* use page tables (s/g) */ 1466 /* use page tables (s/g) */
1785 orb->misc |= ORB_SET_PAGE_TABLE_PRESENT(0x1); 1467 orb->misc |= ORB_SET_PAGE_TABLE_PRESENT(0x1);
1786 orb->data_descriptor_lo = command->sge_dma; 1468 orb->data_descriptor_lo = cmd->sge_dma;
1787 1469
1788 /* 1470 /* loop through and fill out our SBP-2 page tables
1789 * Loop through and fill out our sbp-2 page tables 1471 * (and split up anything too large) */
1790 * (and split up anything too large)
1791 */
1792 for (i = 0, sg_count = 0 ; i < count; i++, sgpnt++) { 1472 for (i = 0, sg_count = 0 ; i < count; i++, sgpnt++) {
1793 sg_len = sg_dma_len(sgpnt); 1473 sg_len = sg_dma_len(sgpnt);
1794 sg_addr = sg_dma_address(sgpnt); 1474 sg_addr = sg_dma_address(sgpnt);
@@ -1808,70 +1488,53 @@ static void sbp2_prep_command_orb_sg(struct sbp2_command_orb *orb,
1808 } 1488 }
1809 } 1489 }
1810 1490
1811 /* Number of page table (s/g) elements */
1812 orb->misc |= ORB_SET_DATA_SIZE(sg_count); 1491 orb->misc |= ORB_SET_DATA_SIZE(sg_count);
1813 1492
1814 sbp2util_packet_dump(sg_element,
1815 (sizeof(struct sbp2_unrestricted_page_table)) * sg_count,
1816 "sbp2 s/g list", command->sge_dma);
1817
1818 /* Byte swap page tables if necessary */
1819 sbp2util_cpu_to_be32_buffer(sg_element, 1493 sbp2util_cpu_to_be32_buffer(sg_element,
1820 (sizeof(struct sbp2_unrestricted_page_table)) * 1494 (sizeof(struct sbp2_unrestricted_page_table)) *
1821 sg_count); 1495 sg_count);
1822 } 1496 }
1823} 1497}
1824 1498
1825static void sbp2_prep_command_orb_no_sg(struct sbp2_command_orb *orb, 1499static void sbp2_prep_command_orb_no_sg(struct sbp2_command_orb *orb,
1826 struct sbp2scsi_host_info *hi, 1500 struct sbp2_fwhost_info *hi,
1827 struct sbp2_command_info *command, 1501 struct sbp2_command_info *cmd,
1828 struct scatterlist *sgpnt, 1502 struct scatterlist *sgpnt,
1829 u32 orb_direction, 1503 u32 orb_direction,
1830 unsigned int scsi_request_bufflen, 1504 unsigned int scsi_request_bufflen,
1831 void *scsi_request_buffer, 1505 void *scsi_request_buffer,
1832 enum dma_data_direction dma_dir) 1506 enum dma_data_direction dma_dir)
1833{ 1507{
1834 command->dma_dir = dma_dir; 1508 cmd->dma_dir = dma_dir;
1835 command->dma_size = scsi_request_bufflen; 1509 cmd->dma_size = scsi_request_bufflen;
1836 command->dma_type = CMD_DMA_SINGLE; 1510 cmd->dma_type = CMD_DMA_SINGLE;
1837 command->cmd_dma = pci_map_single(hi->host->pdev, scsi_request_buffer, 1511 cmd->cmd_dma = dma_map_single(&hi->host->device, scsi_request_buffer,
1838 command->dma_size, command->dma_dir); 1512 cmd->dma_size, cmd->dma_dir);
1839 orb->data_descriptor_hi = ORB_SET_NODE_ID(hi->host->node_id); 1513 orb->data_descriptor_hi = ORB_SET_NODE_ID(hi->host->node_id);
1840 orb->misc |= ORB_SET_DIRECTION(orb_direction); 1514 orb->misc |= ORB_SET_DIRECTION(orb_direction);
1841 1515
1842 SBP2_DMA_ALLOC("single bulk"); 1516 /* handle case where we get a command w/o s/g enabled
1843 1517 * (but check for transfers larger than 64K) */
1844 /*
1845 * Handle case where we get a command w/o s/g enabled (but
1846 * check for transfers larger than 64K)
1847 */
1848 if (scsi_request_bufflen <= SBP2_MAX_SG_ELEMENT_LENGTH) { 1518 if (scsi_request_bufflen <= SBP2_MAX_SG_ELEMENT_LENGTH) {
1849 1519
1850 orb->data_descriptor_lo = command->cmd_dma; 1520 orb->data_descriptor_lo = cmd->cmd_dma;
1851 orb->misc |= ORB_SET_DATA_SIZE(scsi_request_bufflen); 1521 orb->misc |= ORB_SET_DATA_SIZE(scsi_request_bufflen);
1852 1522
1853 } else { 1523 } else {
1524 /* The buffer is too large. Turn this into page tables. */
1525
1854 struct sbp2_unrestricted_page_table *sg_element = 1526 struct sbp2_unrestricted_page_table *sg_element =
1855 &command->scatter_gather_element[0]; 1527 &cmd->scatter_gather_element[0];
1856 u32 sg_count, sg_len; 1528 u32 sg_count, sg_len;
1857 dma_addr_t sg_addr; 1529 dma_addr_t sg_addr;
1858 1530
1859 /* 1531 orb->data_descriptor_lo = cmd->sge_dma;
1860 * Need to turn this into page tables, since the
1861 * buffer is too large.
1862 */
1863 orb->data_descriptor_lo = command->sge_dma;
1864
1865 /* Use page tables (s/g) */
1866 orb->misc |= ORB_SET_PAGE_TABLE_PRESENT(0x1); 1532 orb->misc |= ORB_SET_PAGE_TABLE_PRESENT(0x1);
1867 1533
1868 /* 1534 /* fill out our SBP-2 page tables; split up the large buffer */
1869 * fill out our sbp-2 page tables (and split up
1870 * the large buffer)
1871 */
1872 sg_count = 0; 1535 sg_count = 0;
1873 sg_len = scsi_request_bufflen; 1536 sg_len = scsi_request_bufflen;
1874 sg_addr = command->cmd_dma; 1537 sg_addr = cmd->cmd_dma;
1875 while (sg_len) { 1538 while (sg_len) {
1876 sg_element[sg_count].segment_base_lo = sg_addr; 1539 sg_element[sg_count].segment_base_lo = sg_addr;
1877 if (sg_len > SBP2_MAX_SG_ELEMENT_LENGTH) { 1540 if (sg_len > SBP2_MAX_SG_ELEMENT_LENGTH) {
@@ -1887,50 +1550,40 @@ static void sbp2_prep_command_orb_no_sg(struct sbp2_command_orb *orb,
1887 sg_count++; 1550 sg_count++;
1888 } 1551 }
1889 1552
1890 /* Number of page table (s/g) elements */
1891 orb->misc |= ORB_SET_DATA_SIZE(sg_count); 1553 orb->misc |= ORB_SET_DATA_SIZE(sg_count);
1892 1554
1893 sbp2util_packet_dump(sg_element,
1894 (sizeof(struct sbp2_unrestricted_page_table)) * sg_count,
1895 "sbp2 s/g list", command->sge_dma);
1896
1897 /* Byte swap page tables if necessary */
1898 sbp2util_cpu_to_be32_buffer(sg_element, 1555 sbp2util_cpu_to_be32_buffer(sg_element,
1899 (sizeof(struct sbp2_unrestricted_page_table)) * 1556 (sizeof(struct sbp2_unrestricted_page_table)) *
1900 sg_count); 1557 sg_count);
1901 } 1558 }
1902} 1559}
1903 1560
1904/* 1561static void sbp2_create_command_orb(struct sbp2_lu *lu,
1905 * This function is called to create the actual command orb and s/g list 1562 struct sbp2_command_info *cmd,
1906 * out of the scsi command itself.
1907 */
1908static void sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id,
1909 struct sbp2_command_info *command,
1910 unchar *scsi_cmd, 1563 unchar *scsi_cmd,
1911 unsigned int scsi_use_sg, 1564 unsigned int scsi_use_sg,
1912 unsigned int scsi_request_bufflen, 1565 unsigned int scsi_request_bufflen,
1913 void *scsi_request_buffer, 1566 void *scsi_request_buffer,
1914 enum dma_data_direction dma_dir) 1567 enum dma_data_direction dma_dir)
1915{ 1568{
1916 struct sbp2scsi_host_info *hi = scsi_id->hi; 1569 struct sbp2_fwhost_info *hi = lu->hi;
1917 struct scatterlist *sgpnt = (struct scatterlist *)scsi_request_buffer; 1570 struct scatterlist *sgpnt = (struct scatterlist *)scsi_request_buffer;
1918 struct sbp2_command_orb *command_orb = &command->command_orb; 1571 struct sbp2_command_orb *orb = &cmd->command_orb;
1919 u32 orb_direction; 1572 u32 orb_direction;
1920 1573
1921 /* 1574 /*
1922 * Set-up our command ORB.. 1575 * Set-up our command ORB.
1923 * 1576 *
1924 * NOTE: We're doing unrestricted page tables (s/g), as this is 1577 * NOTE: We're doing unrestricted page tables (s/g), as this is
1925 * best performance (at least with the devices I have). This means 1578 * best performance (at least with the devices I have). This means
1926 * that data_size becomes the number of s/g elements, and 1579 * that data_size becomes the number of s/g elements, and
1927 * page_size should be zero (for unrestricted). 1580 * page_size should be zero (for unrestricted).
1928 */ 1581 */
1929 command_orb->next_ORB_hi = ORB_SET_NULL_PTR(1); 1582 orb->next_ORB_hi = ORB_SET_NULL_PTR(1);
1930 command_orb->next_ORB_lo = 0x0; 1583 orb->next_ORB_lo = 0x0;
1931 command_orb->misc = ORB_SET_MAX_PAYLOAD(scsi_id->max_payload_size); 1584 orb->misc = ORB_SET_MAX_PAYLOAD(lu->max_payload_size);
1932 command_orb->misc |= ORB_SET_SPEED(scsi_id->speed_code); 1585 orb->misc |= ORB_SET_SPEED(lu->speed_code);
1933 command_orb->misc |= ORB_SET_NOTIFY(1); /* Notify us when complete */ 1586 orb->misc |= ORB_SET_NOTIFY(1);
1934 1587
1935 if (dma_dir == DMA_NONE) 1588 if (dma_dir == DMA_NONE)
1936 orb_direction = ORB_DIRECTION_NO_DATA_TRANSFER; 1589 orb_direction = ORB_DIRECTION_NO_DATA_TRANSFER;
@@ -1939,66 +1592,51 @@ static void sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id,
1939 else if (dma_dir == DMA_FROM_DEVICE && scsi_request_bufflen) 1592 else if (dma_dir == DMA_FROM_DEVICE && scsi_request_bufflen)
1940 orb_direction = ORB_DIRECTION_READ_FROM_MEDIA; 1593 orb_direction = ORB_DIRECTION_READ_FROM_MEDIA;
1941 else { 1594 else {
1942 SBP2_WARN("Falling back to DMA_NONE"); 1595 SBP2_INFO("Falling back to DMA_NONE");
1943 orb_direction = ORB_DIRECTION_NO_DATA_TRANSFER; 1596 orb_direction = ORB_DIRECTION_NO_DATA_TRANSFER;
1944 } 1597 }
1945 1598
1946 /* Set-up our pagetable stuff */ 1599 /* set up our page table stuff */
1947 if (orb_direction == ORB_DIRECTION_NO_DATA_TRANSFER) { 1600 if (orb_direction == ORB_DIRECTION_NO_DATA_TRANSFER) {
1948 SBP2_DEBUG("No data transfer"); 1601 orb->data_descriptor_hi = 0x0;
1949 command_orb->data_descriptor_hi = 0x0; 1602 orb->data_descriptor_lo = 0x0;
1950 command_orb->data_descriptor_lo = 0x0; 1603 orb->misc |= ORB_SET_DIRECTION(1);
1951 command_orb->misc |= ORB_SET_DIRECTION(1); 1604 } else if (scsi_use_sg)
1952 } else if (scsi_use_sg) { 1605 sbp2_prep_command_orb_sg(orb, hi, cmd, scsi_use_sg, sgpnt,
1953 SBP2_DEBUG("Use scatter/gather"); 1606 orb_direction, dma_dir);
1954 sbp2_prep_command_orb_sg(command_orb, hi, command, scsi_use_sg, 1607 else
1955 sgpnt, orb_direction, dma_dir); 1608 sbp2_prep_command_orb_no_sg(orb, hi, cmd, sgpnt, orb_direction,
1956 } else { 1609 scsi_request_bufflen,
1957 SBP2_DEBUG("No scatter/gather");
1958 sbp2_prep_command_orb_no_sg(command_orb, hi, command, sgpnt,
1959 orb_direction, scsi_request_bufflen,
1960 scsi_request_buffer, dma_dir); 1610 scsi_request_buffer, dma_dir);
1961 }
1962 1611
1963 /* Byte swap command ORB if necessary */ 1612 sbp2util_cpu_to_be32_buffer(orb, sizeof(*orb));
1964 sbp2util_cpu_to_be32_buffer(command_orb, sizeof(struct sbp2_command_orb));
1965 1613
1966 /* Put our scsi command in the command ORB */ 1614 memset(orb->cdb, 0, 12);
1967 memset(command_orb->cdb, 0, 12); 1615 memcpy(orb->cdb, scsi_cmd, COMMAND_SIZE(*scsi_cmd));
1968 memcpy(command_orb->cdb, scsi_cmd, COMMAND_SIZE(*scsi_cmd));
1969} 1616}
1970 1617
1971/* 1618static void sbp2_link_orb_command(struct sbp2_lu *lu,
1972 * This function is called in order to begin a regular SBP-2 command. 1619 struct sbp2_command_info *cmd)
1973 */
1974static void sbp2_link_orb_command(struct scsi_id_instance_data *scsi_id,
1975 struct sbp2_command_info *command)
1976{ 1620{
1977 struct sbp2scsi_host_info *hi = scsi_id->hi; 1621 struct sbp2_fwhost_info *hi = lu->hi;
1978 struct sbp2_command_orb *command_orb = &command->command_orb;
1979 struct sbp2_command_orb *last_orb; 1622 struct sbp2_command_orb *last_orb;
1980 dma_addr_t last_orb_dma; 1623 dma_addr_t last_orb_dma;
1981 u64 addr = scsi_id->sbp2_command_block_agent_addr; 1624 u64 addr = lu->command_block_agent_addr;
1982 quadlet_t data[2]; 1625 quadlet_t data[2];
1983 size_t length; 1626 size_t length;
1984 unsigned long flags; 1627 unsigned long flags;
1985 1628
1986 outstanding_orb_incr; 1629 dma_sync_single_for_device(&hi->host->device, cmd->command_orb_dma,
1987 SBP2_ORB_DEBUG("sending command orb %p, total orbs = %x", 1630 sizeof(struct sbp2_command_orb),
1988 command_orb, global_outstanding_command_orbs); 1631 DMA_TO_DEVICE);
1989 1632 dma_sync_single_for_device(&hi->host->device, cmd->sge_dma,
1990 pci_dma_sync_single_for_device(hi->host->pdev, command->command_orb_dma, 1633 sizeof(cmd->scatter_gather_element),
1991 sizeof(struct sbp2_command_orb), 1634 DMA_BIDIRECTIONAL);
1992 PCI_DMA_TODEVICE); 1635
1993 pci_dma_sync_single_for_device(hi->host->pdev, command->sge_dma, 1636 /* check to see if there are any previous orbs to use */
1994 sizeof(command->scatter_gather_element), 1637 spin_lock_irqsave(&lu->cmd_orb_lock, flags);
1995 PCI_DMA_BIDIRECTIONAL); 1638 last_orb = lu->last_orb;
1996 /* 1639 last_orb_dma = lu->last_orb_dma;
1997 * Check to see if there are any previous orbs to use
1998 */
1999 spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags);
2000 last_orb = scsi_id->last_orb;
2001 last_orb_dma = scsi_id->last_orb_dma;
2002 if (!last_orb) { 1640 if (!last_orb) {
2003 /* 1641 /*
2004 * last_orb == NULL means: We know that the target's fetch agent 1642 * last_orb == NULL means: We know that the target's fetch agent
@@ -2006,7 +1644,7 @@ static void sbp2_link_orb_command(struct scsi_id_instance_data *scsi_id,
2006 */ 1644 */
2007 addr += SBP2_ORB_POINTER_OFFSET; 1645 addr += SBP2_ORB_POINTER_OFFSET;
2008 data[0] = ORB_SET_NODE_ID(hi->host->node_id); 1646 data[0] = ORB_SET_NODE_ID(hi->host->node_id);
2009 data[1] = command->command_orb_dma; 1647 data[1] = cmd->command_orb_dma;
2010 sbp2util_cpu_to_be32_buffer(data, 8); 1648 sbp2util_cpu_to_be32_buffer(data, 8);
2011 length = 8; 1649 length = 8;
2012 } else { 1650 } else {
@@ -2017,27 +1655,25 @@ static void sbp2_link_orb_command(struct scsi_id_instance_data *scsi_id,
2017 * The target's fetch agent may or may not have read this 1655 * The target's fetch agent may or may not have read this
2018 * previous ORB yet. 1656 * previous ORB yet.
2019 */ 1657 */
2020 pci_dma_sync_single_for_cpu(hi->host->pdev, last_orb_dma, 1658 dma_sync_single_for_cpu(&hi->host->device, last_orb_dma,
2021 sizeof(struct sbp2_command_orb), 1659 sizeof(struct sbp2_command_orb),
2022 PCI_DMA_TODEVICE); 1660 DMA_TO_DEVICE);
2023 last_orb->next_ORB_lo = cpu_to_be32(command->command_orb_dma); 1661 last_orb->next_ORB_lo = cpu_to_be32(cmd->command_orb_dma);
2024 wmb(); 1662 wmb();
2025 /* Tells hardware that this pointer is valid */ 1663 /* Tells hardware that this pointer is valid */
2026 last_orb->next_ORB_hi = 0; 1664 last_orb->next_ORB_hi = 0;
2027 pci_dma_sync_single_for_device(hi->host->pdev, last_orb_dma, 1665 dma_sync_single_for_device(&hi->host->device, last_orb_dma,
2028 sizeof(struct sbp2_command_orb), 1666 sizeof(struct sbp2_command_orb),
2029 PCI_DMA_TODEVICE); 1667 DMA_TO_DEVICE);
2030 addr += SBP2_DOORBELL_OFFSET; 1668 addr += SBP2_DOORBELL_OFFSET;
2031 data[0] = 0; 1669 data[0] = 0;
2032 length = 4; 1670 length = 4;
2033 } 1671 }
2034 scsi_id->last_orb = command_orb; 1672 lu->last_orb = &cmd->command_orb;
2035 scsi_id->last_orb_dma = command->command_orb_dma; 1673 lu->last_orb_dma = cmd->command_orb_dma;
2036 spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); 1674 spin_unlock_irqrestore(&lu->cmd_orb_lock, flags);
2037 1675
2038 SBP2_ORB_DEBUG("write to %s register, command orb %p", 1676 if (sbp2util_node_write_no_wait(lu->ne, addr, data, length)) {
2039 last_orb ? "DOORBELL" : "ORB_POINTER", command_orb);
2040 if (sbp2util_node_write_no_wait(scsi_id->ne, addr, data, length)) {
2041 /* 1677 /*
2042 * sbp2util_node_write_no_wait failed. We certainly ran out 1678 * sbp2util_node_write_no_wait failed. We certainly ran out
2043 * of transaction labels, perhaps just because there were no 1679 * of transaction labels, perhaps just because there were no
@@ -2046,52 +1682,29 @@ static void sbp2_link_orb_command(struct scsi_id_instance_data *scsi_id,
2046 * the workqueue job will sleep to guaranteedly get a tlabel. 1682 * the workqueue job will sleep to guaranteedly get a tlabel.
2047 * We do not accept new commands until the job is over. 1683 * We do not accept new commands until the job is over.
2048 */ 1684 */
2049 scsi_block_requests(scsi_id->scsi_host); 1685 scsi_block_requests(lu->shost);
2050 PREPARE_WORK(&scsi_id->protocol_work, 1686 PREPARE_WORK(&lu->protocol_work,
2051 last_orb ? sbp2util_write_doorbell: 1687 last_orb ? sbp2util_write_doorbell:
2052 sbp2util_write_orb_pointer, 1688 sbp2util_write_orb_pointer);
2053 scsi_id); 1689 schedule_work(&lu->protocol_work);
2054 schedule_work(&scsi_id->protocol_work);
2055 } 1690 }
2056} 1691}
2057 1692
2058/* 1693static int sbp2_send_command(struct sbp2_lu *lu, struct scsi_cmnd *SCpnt,
2059 * This function is called in order to begin a regular SBP-2 command.
2060 */
2061static int sbp2_send_command(struct scsi_id_instance_data *scsi_id,
2062 struct scsi_cmnd *SCpnt,
2063 void (*done)(struct scsi_cmnd *)) 1694 void (*done)(struct scsi_cmnd *))
2064{ 1695{
2065 unchar *cmd = (unchar *) SCpnt->cmnd; 1696 unchar *scsi_cmd = (unchar *)SCpnt->cmnd;
2066 unsigned int request_bufflen = SCpnt->request_bufflen; 1697 unsigned int request_bufflen = SCpnt->request_bufflen;
2067 struct sbp2_command_info *command; 1698 struct sbp2_command_info *cmd;
2068 1699
2069 SBP2_DEBUG_ENTER(); 1700 cmd = sbp2util_allocate_command_orb(lu, SCpnt, done);
2070 SBP2_DEBUG("SCSI transfer size = %x", request_bufflen); 1701 if (!cmd)
2071 SBP2_DEBUG("SCSI s/g elements = %x", (unsigned int)SCpnt->use_sg);
2072
2073 /*
2074 * Allocate a command orb and s/g structure
2075 */
2076 command = sbp2util_allocate_command_orb(scsi_id, SCpnt, done);
2077 if (!command) {
2078 return -EIO; 1702 return -EIO;
2079 }
2080 1703
2081 /* 1704 sbp2_create_command_orb(lu, cmd, scsi_cmd, SCpnt->use_sg,
2082 * Now actually fill in the comamnd orb and sbp2 s/g list
2083 */
2084 sbp2_create_command_orb(scsi_id, command, cmd, SCpnt->use_sg,
2085 request_bufflen, SCpnt->request_buffer, 1705 request_bufflen, SCpnt->request_buffer,
2086 SCpnt->sc_data_direction); 1706 SCpnt->sc_data_direction);
2087 1707 sbp2_link_orb_command(lu, cmd);
2088 sbp2util_packet_dump(&command->command_orb, sizeof(struct sbp2_command_orb),
2089 "sbp2 command orb", command->command_orb_dma);
2090
2091 /*
2092 * Link up the orb, and ring the doorbell if needed
2093 */
2094 sbp2_link_orb_command(scsi_id, command);
2095 1708
2096 return 0; 1709 return 0;
2097} 1710}
@@ -2099,13 +1712,10 @@ static int sbp2_send_command(struct scsi_id_instance_data *scsi_id,
2099/* 1712/*
2100 * Translates SBP-2 status into SCSI sense data for check conditions 1713 * Translates SBP-2 status into SCSI sense data for check conditions
2101 */ 1714 */
2102static unsigned int sbp2_status_to_sense_data(unchar *sbp2_status, unchar *sense_data) 1715static unsigned int sbp2_status_to_sense_data(unchar *sbp2_status,
1716 unchar *sense_data)
2103{ 1717{
2104 SBP2_DEBUG_ENTER(); 1718 /* OK, it's pretty ugly... ;-) */
2105
2106 /*
2107 * Ok, it's pretty ugly... ;-)
2108 */
2109 sense_data[0] = 0x70; 1719 sense_data[0] = 0x70;
2110 sense_data[1] = 0x0; 1720 sense_data[1] = 0x0;
2111 sense_data[2] = sbp2_status[9]; 1721 sense_data[2] = sbp2_status[9];
@@ -2123,28 +1733,21 @@ static unsigned int sbp2_status_to_sense_data(unchar *sbp2_status, unchar *sense
2123 sense_data[14] = sbp2_status[20]; 1733 sense_data[14] = sbp2_status[20];
2124 sense_data[15] = sbp2_status[21]; 1734 sense_data[15] = sbp2_status[21];
2125 1735
2126 return sbp2_status[8] & 0x3f; /* return scsi status */ 1736 return sbp2_status[8] & 0x3f;
2127} 1737}
2128 1738
2129/*
2130 * This function deals with status writes from the SBP-2 device
2131 */
2132static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, 1739static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid,
2133 int destid, quadlet_t *data, u64 addr, 1740 int destid, quadlet_t *data, u64 addr,
2134 size_t length, u16 fl) 1741 size_t length, u16 fl)
2135{ 1742{
2136 struct sbp2scsi_host_info *hi; 1743 struct sbp2_fwhost_info *hi;
2137 struct scsi_id_instance_data *scsi_id = NULL, *scsi_id_tmp; 1744 struct sbp2_lu *lu = NULL, *lu_tmp;
2138 struct scsi_cmnd *SCpnt = NULL; 1745 struct scsi_cmnd *SCpnt = NULL;
2139 struct sbp2_status_block *sb; 1746 struct sbp2_status_block *sb;
2140 u32 scsi_status = SBP2_SCSI_STATUS_GOOD; 1747 u32 scsi_status = SBP2_SCSI_STATUS_GOOD;
2141 struct sbp2_command_info *command; 1748 struct sbp2_command_info *cmd;
2142 unsigned long flags; 1749 unsigned long flags;
2143 1750
2144 SBP2_DEBUG_ENTER();
2145
2146 sbp2util_packet_dump(data, length, "sbp2 status write by device", (u32)addr);
2147
2148 if (unlikely(length < 8 || length > sizeof(struct sbp2_status_block))) { 1751 if (unlikely(length < 8 || length > sizeof(struct sbp2_status_block))) {
2149 SBP2_ERR("Wrong size of status block"); 1752 SBP2_ERR("Wrong size of status block");
2150 return RCODE_ADDRESS_ERROR; 1753 return RCODE_ADDRESS_ERROR;
@@ -2158,131 +1761,97 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid,
2158 SBP2_ERR("host info is NULL - this is bad!"); 1761 SBP2_ERR("host info is NULL - this is bad!");
2159 return RCODE_ADDRESS_ERROR; 1762 return RCODE_ADDRESS_ERROR;
2160 } 1763 }
2161 /* 1764
2162 * Find our scsi_id structure by looking at the status fifo address 1765 /* Find the unit which wrote the status. */
2163 * written to by the sbp2 device. 1766 list_for_each_entry(lu_tmp, &hi->logical_units, lu_list) {
2164 */ 1767 if (lu_tmp->ne->nodeid == nodeid &&
2165 list_for_each_entry(scsi_id_tmp, &hi->scsi_ids, scsi_list) { 1768 lu_tmp->status_fifo_addr == addr) {
2166 if (scsi_id_tmp->ne->nodeid == nodeid && 1769 lu = lu_tmp;
2167 scsi_id_tmp->status_fifo_addr == addr) {
2168 scsi_id = scsi_id_tmp;
2169 break; 1770 break;
2170 } 1771 }
2171 } 1772 }
2172 if (unlikely(!scsi_id)) { 1773 if (unlikely(!lu)) {
2173 SBP2_ERR("scsi_id is NULL - device is gone?"); 1774 SBP2_ERR("lu is NULL - device is gone?");
2174 return RCODE_ADDRESS_ERROR; 1775 return RCODE_ADDRESS_ERROR;
2175 } 1776 }
2176 1777
2177 /* 1778 /* Put response into lu status fifo buffer. The first two bytes
2178 * Put response into scsi_id status fifo buffer. The first two bytes
2179 * come in big endian bit order. Often the target writes only a 1779 * come in big endian bit order. Often the target writes only a
2180 * truncated status block, minimally the first two quadlets. The rest 1780 * truncated status block, minimally the first two quadlets. The rest
2181 * is implied to be zeros. 1781 * is implied to be zeros. */
2182 */ 1782 sb = &lu->status_block;
2183 sb = &scsi_id->status_block;
2184 memset(sb->command_set_dependent, 0, sizeof(sb->command_set_dependent)); 1783 memset(sb->command_set_dependent, 0, sizeof(sb->command_set_dependent));
2185 memcpy(sb, data, length); 1784 memcpy(sb, data, length);
2186 sbp2util_be32_to_cpu_buffer(sb, 8); 1785 sbp2util_be32_to_cpu_buffer(sb, 8);
2187 1786
2188 /* 1787 /* Ignore unsolicited status. Handle command ORB status. */
2189 * Ignore unsolicited status. Handle command ORB status.
2190 */
2191 if (unlikely(STATUS_GET_SRC(sb->ORB_offset_hi_misc) == 2)) 1788 if (unlikely(STATUS_GET_SRC(sb->ORB_offset_hi_misc) == 2))
2192 command = NULL; 1789 cmd = NULL;
2193 else 1790 else
2194 command = sbp2util_find_command_for_orb(scsi_id, 1791 cmd = sbp2util_find_command_for_orb(lu, sb->ORB_offset_lo);
2195 sb->ORB_offset_lo); 1792 if (cmd) {
2196 if (command) { 1793 dma_sync_single_for_cpu(&hi->host->device, cmd->command_orb_dma,
2197 SBP2_DEBUG("Found status for command ORB"); 1794 sizeof(struct sbp2_command_orb),
2198 pci_dma_sync_single_for_cpu(hi->host->pdev, command->command_orb_dma, 1795 DMA_TO_DEVICE);
2199 sizeof(struct sbp2_command_orb), 1796 dma_sync_single_for_cpu(&hi->host->device, cmd->sge_dma,
2200 PCI_DMA_TODEVICE); 1797 sizeof(cmd->scatter_gather_element),
2201 pci_dma_sync_single_for_cpu(hi->host->pdev, command->sge_dma, 1798 DMA_BIDIRECTIONAL);
2202 sizeof(command->scatter_gather_element), 1799 /* Grab SCSI command pointers and check status. */
2203 PCI_DMA_BIDIRECTIONAL);
2204
2205 SBP2_ORB_DEBUG("matched command orb %p", &command->command_orb);
2206 outstanding_orb_decr;
2207
2208 /*
2209 * Matched status with command, now grab scsi command pointers
2210 * and check status.
2211 */
2212 /* 1800 /*
2213 * FIXME: If the src field in the status is 1, the ORB DMA must 1801 * FIXME: If the src field in the status is 1, the ORB DMA must
2214 * not be reused until status for a subsequent ORB is received. 1802 * not be reused until status for a subsequent ORB is received.
2215 */ 1803 */
2216 SCpnt = command->Current_SCpnt; 1804 SCpnt = cmd->Current_SCpnt;
2217 spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags); 1805 spin_lock_irqsave(&lu->cmd_orb_lock, flags);
2218 sbp2util_mark_command_completed(scsi_id, command); 1806 sbp2util_mark_command_completed(lu, cmd);
2219 spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); 1807 spin_unlock_irqrestore(&lu->cmd_orb_lock, flags);
2220 1808
2221 if (SCpnt) { 1809 if (SCpnt) {
2222 u32 h = sb->ORB_offset_hi_misc; 1810 u32 h = sb->ORB_offset_hi_misc;
2223 u32 r = STATUS_GET_RESP(h); 1811 u32 r = STATUS_GET_RESP(h);
2224 1812
2225 if (r != RESP_STATUS_REQUEST_COMPLETE) { 1813 if (r != RESP_STATUS_REQUEST_COMPLETE) {
2226 SBP2_WARN("resp 0x%x, sbp_status 0x%x", 1814 SBP2_INFO("resp 0x%x, sbp_status 0x%x",
2227 r, STATUS_GET_SBP_STATUS(h)); 1815 r, STATUS_GET_SBP_STATUS(h));
2228 scsi_status = 1816 scsi_status =
2229 r == RESP_STATUS_TRANSPORT_FAILURE ? 1817 r == RESP_STATUS_TRANSPORT_FAILURE ?
2230 SBP2_SCSI_STATUS_BUSY : 1818 SBP2_SCSI_STATUS_BUSY :
2231 SBP2_SCSI_STATUS_COMMAND_TERMINATED; 1819 SBP2_SCSI_STATUS_COMMAND_TERMINATED;
2232 } 1820 }
2233 /* 1821
2234 * See if the target stored any scsi status information. 1822 if (STATUS_GET_LEN(h) > 1)
2235 */
2236 if (STATUS_GET_LEN(h) > 1) {
2237 SBP2_DEBUG("CHECK CONDITION");
2238 scsi_status = sbp2_status_to_sense_data( 1823 scsi_status = sbp2_status_to_sense_data(
2239 (unchar *)sb, SCpnt->sense_buffer); 1824 (unchar *)sb, SCpnt->sense_buffer);
2240 } 1825
2241 /* 1826 if (STATUS_TEST_DEAD(h))
2242 * Check to see if the dead bit is set. If so, we'll 1827 sbp2_agent_reset(lu, 0);
2243 * have to initiate a fetch agent reset.
2244 */
2245 if (STATUS_TEST_DEAD(h)) {
2246 SBP2_DEBUG("Dead bit set - "
2247 "initiating fetch agent reset");
2248 sbp2_agent_reset(scsi_id, 0);
2249 }
2250 SBP2_ORB_DEBUG("completing command orb %p", &command->command_orb);
2251 } 1828 }
2252 1829
2253 /* 1830 /* Check here to see if there are no commands in-use. If there
2254 * Check here to see if there are no commands in-use. If there
2255 * are none, we know that the fetch agent left the active state 1831 * are none, we know that the fetch agent left the active state
2256 * _and_ that we did not reactivate it yet. Therefore clear 1832 * _and_ that we did not reactivate it yet. Therefore clear
2257 * last_orb so that next time we write directly to the 1833 * last_orb so that next time we write directly to the
2258 * ORB_POINTER register. That way the fetch agent does not need 1834 * ORB_POINTER register. That way the fetch agent does not need
2259 * to refetch the next_ORB. 1835 * to refetch the next_ORB. */
2260 */ 1836 spin_lock_irqsave(&lu->cmd_orb_lock, flags);
2261 spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags); 1837 if (list_empty(&lu->cmd_orb_inuse))
2262 if (list_empty(&scsi_id->sbp2_command_orb_inuse)) 1838 lu->last_orb = NULL;
2263 scsi_id->last_orb = NULL; 1839 spin_unlock_irqrestore(&lu->cmd_orb_lock, flags);
2264 spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags);
2265 1840
2266 } else { 1841 } else {
2267 /* 1842 /* It's probably status after a management request. */
2268 * It's probably a login/logout/reconnect status. 1843 if ((sb->ORB_offset_lo == lu->reconnect_orb_dma) ||
2269 */ 1844 (sb->ORB_offset_lo == lu->login_orb_dma) ||
2270 if ((sb->ORB_offset_lo == scsi_id->reconnect_orb_dma) || 1845 (sb->ORB_offset_lo == lu->query_logins_orb_dma) ||
2271 (sb->ORB_offset_lo == scsi_id->login_orb_dma) || 1846 (sb->ORB_offset_lo == lu->logout_orb_dma)) {
2272 (sb->ORB_offset_lo == scsi_id->query_logins_orb_dma) || 1847 lu->access_complete = 1;
2273 (sb->ORB_offset_lo == scsi_id->logout_orb_dma)) { 1848 wake_up_interruptible(&sbp2_access_wq);
2274 scsi_id->access_complete = 1;
2275 wake_up_interruptible(&access_wq);
2276 } 1849 }
2277 } 1850 }
2278 1851
2279 if (SCpnt) { 1852 if (SCpnt)
2280 SBP2_DEBUG("Completing SCSI command"); 1853 sbp2scsi_complete_command(lu, scsi_status, SCpnt,
2281 sbp2scsi_complete_command(scsi_id, scsi_status, SCpnt, 1854 cmd->Current_done);
2282 command->Current_done);
2283 SBP2_ORB_DEBUG("command orb completed");
2284 }
2285
2286 return RCODE_COMPLETE; 1855 return RCODE_COMPLETE;
2287} 1856}
2288 1857
@@ -2290,77 +1859,57 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid,
2290 * SCSI interface related section 1859 * SCSI interface related section
2291 **************************************/ 1860 **************************************/
2292 1861
2293/*
2294 * This routine is the main request entry routine for doing I/O. It is
2295 * called from the scsi stack directly.
2296 */
2297static int sbp2scsi_queuecommand(struct scsi_cmnd *SCpnt, 1862static int sbp2scsi_queuecommand(struct scsi_cmnd *SCpnt,
2298 void (*done)(struct scsi_cmnd *)) 1863 void (*done)(struct scsi_cmnd *))
2299{ 1864{
2300 struct scsi_id_instance_data *scsi_id = 1865 struct sbp2_lu *lu = (struct sbp2_lu *)SCpnt->device->host->hostdata[0];
2301 (struct scsi_id_instance_data *)SCpnt->device->host->hostdata[0]; 1866 struct sbp2_fwhost_info *hi;
2302 struct sbp2scsi_host_info *hi;
2303 int result = DID_NO_CONNECT << 16; 1867 int result = DID_NO_CONNECT << 16;
2304 1868
2305 SBP2_DEBUG_ENTER(); 1869 if (unlikely(!sbp2util_node_is_available(lu)))
2306#if (CONFIG_IEEE1394_SBP2_DEBUG >= 2) || defined(CONFIG_IEEE1394_SBP2_PACKET_DUMP)
2307 scsi_print_command(SCpnt);
2308#endif
2309
2310 if (!sbp2util_node_is_available(scsi_id))
2311 goto done; 1870 goto done;
2312 1871
2313 hi = scsi_id->hi; 1872 hi = lu->hi;
2314 1873
2315 if (!hi) { 1874 if (unlikely(!hi)) {
2316 SBP2_ERR("sbp2scsi_host_info is NULL - this is bad!"); 1875 SBP2_ERR("sbp2_fwhost_info is NULL - this is bad!");
2317 goto done; 1876 goto done;
2318 } 1877 }
2319 1878
2320 /* 1879 /* Multiple units are currently represented to the SCSI core as separate
2321 * Until we handle multiple luns, just return selection time-out 1880 * targets, not as one target with multiple LUs. Therefore return
2322 * to any IO directed at non-zero LUNs 1881 * selection time-out to any IO directed at non-zero LUNs. */
2323 */ 1882 if (unlikely(SCpnt->device->lun))
2324 if (SCpnt->device->lun)
2325 goto done; 1883 goto done;
2326 1884
2327 /* 1885 /* handle the request sense command here (auto-request sense) */
2328 * Check for request sense command, and handle it here
2329 * (autorequest sense)
2330 */
2331 if (SCpnt->cmnd[0] == REQUEST_SENSE) { 1886 if (SCpnt->cmnd[0] == REQUEST_SENSE) {
2332 SBP2_DEBUG("REQUEST_SENSE"); 1887 memcpy(SCpnt->request_buffer, SCpnt->sense_buffer,
2333 memcpy(SCpnt->request_buffer, SCpnt->sense_buffer, SCpnt->request_bufflen); 1888 SCpnt->request_bufflen);
2334 memset(SCpnt->sense_buffer, 0, sizeof(SCpnt->sense_buffer)); 1889 memset(SCpnt->sense_buffer, 0, sizeof(SCpnt->sense_buffer));
2335 sbp2scsi_complete_command(scsi_id, SBP2_SCSI_STATUS_GOOD, SCpnt, done); 1890 sbp2scsi_complete_command(lu, SBP2_SCSI_STATUS_GOOD, SCpnt,
1891 done);
2336 return 0; 1892 return 0;
2337 } 1893 }
2338 1894
2339 /* 1895 if (unlikely(!hpsb_node_entry_valid(lu->ne))) {
2340 * Check to see if we are in the middle of a bus reset.
2341 */
2342 if (!hpsb_node_entry_valid(scsi_id->ne)) {
2343 SBP2_ERR("Bus reset in progress - rejecting command"); 1896 SBP2_ERR("Bus reset in progress - rejecting command");
2344 result = DID_BUS_BUSY << 16; 1897 result = DID_BUS_BUSY << 16;
2345 goto done; 1898 goto done;
2346 } 1899 }
2347 1900
2348 /* 1901 /* Bidirectional commands are not yet implemented,
2349 * Bidirectional commands are not yet implemented, 1902 * and unknown transfer direction not handled. */
2350 * and unknown transfer direction not handled. 1903 if (unlikely(SCpnt->sc_data_direction == DMA_BIDIRECTIONAL)) {
2351 */
2352 if (SCpnt->sc_data_direction == DMA_BIDIRECTIONAL) {
2353 SBP2_ERR("Cannot handle DMA_BIDIRECTIONAL - rejecting command"); 1904 SBP2_ERR("Cannot handle DMA_BIDIRECTIONAL - rejecting command");
2354 result = DID_ERROR << 16; 1905 result = DID_ERROR << 16;
2355 goto done; 1906 goto done;
2356 } 1907 }
2357 1908
2358 /* 1909 if (sbp2_send_command(lu, SCpnt, done)) {
2359 * Try and send our SCSI command
2360 */
2361 if (sbp2_send_command(scsi_id, SCpnt, done)) {
2362 SBP2_ERR("Error sending SCSI command"); 1910 SBP2_ERR("Error sending SCSI command");
2363 sbp2scsi_complete_command(scsi_id, SBP2_SCSI_STATUS_SELECTION_TIMEOUT, 1911 sbp2scsi_complete_command(lu,
1912 SBP2_SCSI_STATUS_SELECTION_TIMEOUT,
2364 SCpnt, done); 1913 SCpnt, done);
2365 } 1914 }
2366 return 0; 1915 return 0;
@@ -2371,75 +1920,46 @@ done:
2371 return 0; 1920 return 0;
2372} 1921}
2373 1922
2374/* 1923static void sbp2scsi_complete_all_commands(struct sbp2_lu *lu, u32 status)
2375 * This function is called in order to complete all outstanding SBP-2
2376 * commands (in case of resets, etc.).
2377 */
2378static void sbp2scsi_complete_all_commands(struct scsi_id_instance_data *scsi_id,
2379 u32 status)
2380{ 1924{
2381 struct sbp2scsi_host_info *hi = scsi_id->hi; 1925 struct sbp2_fwhost_info *hi = lu->hi;
2382 struct list_head *lh; 1926 struct list_head *lh;
2383 struct sbp2_command_info *command; 1927 struct sbp2_command_info *cmd;
2384 unsigned long flags; 1928 unsigned long flags;
2385 1929
2386 SBP2_DEBUG_ENTER(); 1930 spin_lock_irqsave(&lu->cmd_orb_lock, flags);
2387 1931 while (!list_empty(&lu->cmd_orb_inuse)) {
2388 spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags); 1932 lh = lu->cmd_orb_inuse.next;
2389 while (!list_empty(&scsi_id->sbp2_command_orb_inuse)) { 1933 cmd = list_entry(lh, struct sbp2_command_info, list);
2390 SBP2_DEBUG("Found pending command to complete"); 1934 dma_sync_single_for_cpu(&hi->host->device, cmd->command_orb_dma,
2391 lh = scsi_id->sbp2_command_orb_inuse.next; 1935 sizeof(struct sbp2_command_orb),
2392 command = list_entry(lh, struct sbp2_command_info, list); 1936 DMA_TO_DEVICE);
2393 pci_dma_sync_single_for_cpu(hi->host->pdev, command->command_orb_dma, 1937 dma_sync_single_for_cpu(&hi->host->device, cmd->sge_dma,
2394 sizeof(struct sbp2_command_orb), 1938 sizeof(cmd->scatter_gather_element),
2395 PCI_DMA_TODEVICE); 1939 DMA_BIDIRECTIONAL);
2396 pci_dma_sync_single_for_cpu(hi->host->pdev, command->sge_dma, 1940 sbp2util_mark_command_completed(lu, cmd);
2397 sizeof(command->scatter_gather_element), 1941 if (cmd->Current_SCpnt) {
2398 PCI_DMA_BIDIRECTIONAL); 1942 cmd->Current_SCpnt->result = status << 16;
2399 sbp2util_mark_command_completed(scsi_id, command); 1943 cmd->Current_done(cmd->Current_SCpnt);
2400 if (command->Current_SCpnt) {
2401 command->Current_SCpnt->result = status << 16;
2402 command->Current_done(command->Current_SCpnt);
2403 } 1944 }
2404 } 1945 }
2405 spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); 1946 spin_unlock_irqrestore(&lu->cmd_orb_lock, flags);
2406 1947
2407 return; 1948 return;
2408} 1949}
2409 1950
2410/* 1951/*
2411 * This function is called in order to complete a regular SBP-2 command. 1952 * Complete a regular SCSI command. Can be called in atomic context.
2412 *
2413 * This can be called in interrupt context.
2414 */ 1953 */
2415static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id, 1954static void sbp2scsi_complete_command(struct sbp2_lu *lu, u32 scsi_status,
2416 u32 scsi_status, struct scsi_cmnd *SCpnt, 1955 struct scsi_cmnd *SCpnt,
2417 void (*done)(struct scsi_cmnd *)) 1956 void (*done)(struct scsi_cmnd *))
2418{ 1957{
2419 SBP2_DEBUG_ENTER();
2420
2421 /*
2422 * Sanity
2423 */
2424 if (!SCpnt) { 1958 if (!SCpnt) {
2425 SBP2_ERR("SCpnt is NULL"); 1959 SBP2_ERR("SCpnt is NULL");
2426 return; 1960 return;
2427 } 1961 }
2428 1962
2429 /*
2430 * If a bus reset is in progress and there was an error, don't
2431 * complete the command, just let it get retried at the end of the
2432 * bus reset.
2433 */
2434 if (!hpsb_node_entry_valid(scsi_id->ne)
2435 && (scsi_status != SBP2_SCSI_STATUS_GOOD)) {
2436 SBP2_ERR("Bus reset in progress - retry command later");
2437 return;
2438 }
2439
2440 /*
2441 * Switch on scsi status
2442 */
2443 switch (scsi_status) { 1963 switch (scsi_status) {
2444 case SBP2_SCSI_STATUS_GOOD: 1964 case SBP2_SCSI_STATUS_GOOD:
2445 SCpnt->result = DID_OK << 16; 1965 SCpnt->result = DID_OK << 16;
@@ -2451,12 +1971,7 @@ static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id,
2451 break; 1971 break;
2452 1972
2453 case SBP2_SCSI_STATUS_CHECK_CONDITION: 1973 case SBP2_SCSI_STATUS_CHECK_CONDITION:
2454 SBP2_DEBUG("SBP2_SCSI_STATUS_CHECK_CONDITION");
2455 SCpnt->result = CHECK_CONDITION << 1 | DID_OK << 16; 1974 SCpnt->result = CHECK_CONDITION << 1 | DID_OK << 16;
2456#if CONFIG_IEEE1394_SBP2_DEBUG >= 1
2457 scsi_print_command(SCpnt);
2458 scsi_print_sense(SBP2_DEVICE_NAME, SCpnt);
2459#endif
2460 break; 1975 break;
2461 1976
2462 case SBP2_SCSI_STATUS_SELECTION_TIMEOUT: 1977 case SBP2_SCSI_STATUS_SELECTION_TIMEOUT:
@@ -2478,118 +1993,88 @@ static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id,
2478 SCpnt->result = DID_ERROR << 16; 1993 SCpnt->result = DID_ERROR << 16;
2479 } 1994 }
2480 1995
2481 /* 1996 /* If a bus reset is in progress and there was an error, complete
2482 * If a bus reset is in progress and there was an error, complete 1997 * the command as busy so that it will get retried. */
2483 * the command as busy so that it will get retried. 1998 if (!hpsb_node_entry_valid(lu->ne)
2484 */
2485 if (!hpsb_node_entry_valid(scsi_id->ne)
2486 && (scsi_status != SBP2_SCSI_STATUS_GOOD)) { 1999 && (scsi_status != SBP2_SCSI_STATUS_GOOD)) {
2487 SBP2_ERR("Completing command with busy (bus reset)"); 2000 SBP2_ERR("Completing command with busy (bus reset)");
2488 SCpnt->result = DID_BUS_BUSY << 16; 2001 SCpnt->result = DID_BUS_BUSY << 16;
2489 } 2002 }
2490 2003
2491 /* 2004 /* Tell the SCSI stack that we're done with this command. */
2492 * If a unit attention occurs, return busy status so it gets
2493 * retried... it could have happened because of a 1394 bus reset
2494 * or hot-plug...
2495 * XXX DID_BUS_BUSY is actually a bad idea because it will defy
2496 * the scsi layer's retry logic.
2497 */
2498#if 0
2499 if ((scsi_status == SBP2_SCSI_STATUS_CHECK_CONDITION) &&
2500 (SCpnt->sense_buffer[2] == UNIT_ATTENTION)) {
2501 SBP2_DEBUG("UNIT ATTENTION - return busy");
2502 SCpnt->result = DID_BUS_BUSY << 16;
2503 }
2504#endif
2505
2506 /*
2507 * Tell scsi stack that we're done with this command
2508 */
2509 done(SCpnt); 2005 done(SCpnt);
2510} 2006}
2511 2007
2512static int sbp2scsi_slave_alloc(struct scsi_device *sdev) 2008static int sbp2scsi_slave_alloc(struct scsi_device *sdev)
2513{ 2009{
2514 struct scsi_id_instance_data *scsi_id = 2010 struct sbp2_lu *lu = (struct sbp2_lu *)sdev->host->hostdata[0];
2515 (struct scsi_id_instance_data *)sdev->host->hostdata[0];
2516 2011
2517 scsi_id->sdev = sdev; 2012 lu->sdev = sdev;
2518 sdev->allow_restart = 1; 2013 sdev->allow_restart = 1;
2519 2014
2520 if (scsi_id->workarounds & SBP2_WORKAROUND_INQUIRY_36) 2015 if (lu->workarounds & SBP2_WORKAROUND_INQUIRY_36)
2521 sdev->inquiry_len = 36; 2016 sdev->inquiry_len = 36;
2522 return 0; 2017 return 0;
2523} 2018}
2524 2019
2525static int sbp2scsi_slave_configure(struct scsi_device *sdev) 2020static int sbp2scsi_slave_configure(struct scsi_device *sdev)
2526{ 2021{
2527 struct scsi_id_instance_data *scsi_id = 2022 struct sbp2_lu *lu = (struct sbp2_lu *)sdev->host->hostdata[0];
2528 (struct scsi_id_instance_data *)sdev->host->hostdata[0];
2529 2023
2530 blk_queue_dma_alignment(sdev->request_queue, (512 - 1)); 2024 blk_queue_dma_alignment(sdev->request_queue, (512 - 1));
2531 sdev->use_10_for_rw = 1; 2025 sdev->use_10_for_rw = 1;
2532 2026
2533 if (sdev->type == TYPE_DISK && 2027 if (sdev->type == TYPE_DISK &&
2534 scsi_id->workarounds & SBP2_WORKAROUND_MODE_SENSE_8) 2028 lu->workarounds & SBP2_WORKAROUND_MODE_SENSE_8)
2535 sdev->skip_ms_page_8 = 1; 2029 sdev->skip_ms_page_8 = 1;
2536 if (scsi_id->workarounds & SBP2_WORKAROUND_FIX_CAPACITY) 2030 if (lu->workarounds & SBP2_WORKAROUND_FIX_CAPACITY)
2537 sdev->fix_capacity = 1; 2031 sdev->fix_capacity = 1;
2538 return 0; 2032 return 0;
2539} 2033}
2540 2034
2541static void sbp2scsi_slave_destroy(struct scsi_device *sdev) 2035static void sbp2scsi_slave_destroy(struct scsi_device *sdev)
2542{ 2036{
2543 ((struct scsi_id_instance_data *)sdev->host->hostdata[0])->sdev = NULL; 2037 ((struct sbp2_lu *)sdev->host->hostdata[0])->sdev = NULL;
2544 return; 2038 return;
2545} 2039}
2546 2040
2547/* 2041/*
2548 * Called by scsi stack when something has really gone wrong. Usually 2042 * Called by scsi stack when something has really gone wrong.
2549 * called when a command has timed-out for some reason. 2043 * Usually called when a command has timed-out for some reason.
2550 */ 2044 */
2551static int sbp2scsi_abort(struct scsi_cmnd *SCpnt) 2045static int sbp2scsi_abort(struct scsi_cmnd *SCpnt)
2552{ 2046{
2553 struct scsi_id_instance_data *scsi_id = 2047 struct sbp2_lu *lu = (struct sbp2_lu *)SCpnt->device->host->hostdata[0];
2554 (struct scsi_id_instance_data *)SCpnt->device->host->hostdata[0]; 2048 struct sbp2_fwhost_info *hi = lu->hi;
2555 struct sbp2scsi_host_info *hi = scsi_id->hi; 2049 struct sbp2_command_info *cmd;
2556 struct sbp2_command_info *command;
2557 unsigned long flags; 2050 unsigned long flags;
2558 2051
2559 SBP2_ERR("aborting sbp2 command"); 2052 SBP2_INFO("aborting sbp2 command");
2560 scsi_print_command(SCpnt); 2053 scsi_print_command(SCpnt);
2561 2054
2562 if (sbp2util_node_is_available(scsi_id)) { 2055 if (sbp2util_node_is_available(lu)) {
2563 2056 sbp2_agent_reset(lu, 1);
2564 /* 2057
2565 * Right now, just return any matching command structures 2058 /* Return a matching command structure to the free pool. */
2566 * to the free pool. 2059 spin_lock_irqsave(&lu->cmd_orb_lock, flags);
2567 */ 2060 cmd = sbp2util_find_command_for_SCpnt(lu, SCpnt);
2568 spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags); 2061 if (cmd) {
2569 command = sbp2util_find_command_for_SCpnt(scsi_id, SCpnt); 2062 dma_sync_single_for_cpu(&hi->host->device,
2570 if (command) { 2063 cmd->command_orb_dma,
2571 SBP2_DEBUG("Found command to abort"); 2064 sizeof(struct sbp2_command_orb),
2572 pci_dma_sync_single_for_cpu(hi->host->pdev, 2065 DMA_TO_DEVICE);
2573 command->command_orb_dma, 2066 dma_sync_single_for_cpu(&hi->host->device, cmd->sge_dma,
2574 sizeof(struct sbp2_command_orb), 2067 sizeof(cmd->scatter_gather_element),
2575 PCI_DMA_TODEVICE); 2068 DMA_BIDIRECTIONAL);
2576 pci_dma_sync_single_for_cpu(hi->host->pdev, 2069 sbp2util_mark_command_completed(lu, cmd);
2577 command->sge_dma, 2070 if (cmd->Current_SCpnt) {
2578 sizeof(command->scatter_gather_element), 2071 cmd->Current_SCpnt->result = DID_ABORT << 16;
2579 PCI_DMA_BIDIRECTIONAL); 2072 cmd->Current_done(cmd->Current_SCpnt);
2580 sbp2util_mark_command_completed(scsi_id, command);
2581 if (command->Current_SCpnt) {
2582 command->Current_SCpnt->result = DID_ABORT << 16;
2583 command->Current_done(command->Current_SCpnt);
2584 } 2073 }
2585 } 2074 }
2586 spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); 2075 spin_unlock_irqrestore(&lu->cmd_orb_lock, flags);
2587 2076
2588 /* 2077 sbp2scsi_complete_all_commands(lu, DID_BUS_BUSY);
2589 * Initiate a fetch agent reset.
2590 */
2591 sbp2_agent_reset(scsi_id, 1);
2592 sbp2scsi_complete_all_commands(scsi_id, DID_BUS_BUSY);
2593 } 2078 }
2594 2079
2595 return SUCCESS; 2080 return SUCCESS;
@@ -2600,14 +2085,13 @@ static int sbp2scsi_abort(struct scsi_cmnd *SCpnt)
2600 */ 2085 */
2601static int sbp2scsi_reset(struct scsi_cmnd *SCpnt) 2086static int sbp2scsi_reset(struct scsi_cmnd *SCpnt)
2602{ 2087{
2603 struct scsi_id_instance_data *scsi_id = 2088 struct sbp2_lu *lu = (struct sbp2_lu *)SCpnt->device->host->hostdata[0];
2604 (struct scsi_id_instance_data *)SCpnt->device->host->hostdata[0];
2605 2089
2606 SBP2_ERR("reset requested"); 2090 SBP2_INFO("reset requested");
2607 2091
2608 if (sbp2util_node_is_available(scsi_id)) { 2092 if (sbp2util_node_is_available(lu)) {
2609 SBP2_ERR("Generating sbp2 fetch agent reset"); 2093 SBP2_INFO("generating sbp2 fetch agent reset");
2610 sbp2_agent_reset(scsi_id, 1); 2094 sbp2_agent_reset(lu, 1);
2611 } 2095 }
2612 2096
2613 return SUCCESS; 2097 return SUCCESS;
@@ -2618,90 +2102,50 @@ static ssize_t sbp2_sysfs_ieee1394_id_show(struct device *dev,
2618 char *buf) 2102 char *buf)
2619{ 2103{
2620 struct scsi_device *sdev; 2104 struct scsi_device *sdev;
2621 struct scsi_id_instance_data *scsi_id; 2105 struct sbp2_lu *lu;
2622 int lun;
2623 2106
2624 if (!(sdev = to_scsi_device(dev))) 2107 if (!(sdev = to_scsi_device(dev)))
2625 return 0; 2108 return 0;
2626 2109
2627 if (!(scsi_id = (struct scsi_id_instance_data *)sdev->host->hostdata[0])) 2110 if (!(lu = (struct sbp2_lu *)sdev->host->hostdata[0]))
2628 return 0; 2111 return 0;
2629 2112
2630 lun = ORB_SET_LUN(scsi_id->sbp2_lun); 2113 return sprintf(buf, "%016Lx:%d:%d\n", (unsigned long long)lu->ne->guid,
2631 2114 lu->ud->id, ORB_SET_LUN(lu->lun));
2632 return sprintf(buf, "%016Lx:%d:%d\n", (unsigned long long)scsi_id->ne->guid,
2633 scsi_id->ud->id, lun);
2634} 2115}
2635static DEVICE_ATTR(ieee1394_id, S_IRUGO, sbp2_sysfs_ieee1394_id_show, NULL);
2636
2637static struct device_attribute *sbp2_sysfs_sdev_attrs[] = {
2638 &dev_attr_ieee1394_id,
2639 NULL
2640};
2641 2116
2642MODULE_AUTHOR("Ben Collins <bcollins@debian.org>"); 2117MODULE_AUTHOR("Ben Collins <bcollins@debian.org>");
2643MODULE_DESCRIPTION("IEEE-1394 SBP-2 protocol driver"); 2118MODULE_DESCRIPTION("IEEE-1394 SBP-2 protocol driver");
2644MODULE_SUPPORTED_DEVICE(SBP2_DEVICE_NAME); 2119MODULE_SUPPORTED_DEVICE(SBP2_DEVICE_NAME);
2645MODULE_LICENSE("GPL"); 2120MODULE_LICENSE("GPL");
2646 2121
2647/* SCSI host template */
2648static struct scsi_host_template scsi_driver_template = {
2649 .module = THIS_MODULE,
2650 .name = "SBP-2 IEEE-1394",
2651 .proc_name = SBP2_DEVICE_NAME,
2652 .queuecommand = sbp2scsi_queuecommand,
2653 .eh_abort_handler = sbp2scsi_abort,
2654 .eh_device_reset_handler = sbp2scsi_reset,
2655 .slave_alloc = sbp2scsi_slave_alloc,
2656 .slave_configure = sbp2scsi_slave_configure,
2657 .slave_destroy = sbp2scsi_slave_destroy,
2658 .this_id = -1,
2659 .sg_tablesize = SG_ALL,
2660 .use_clustering = ENABLE_CLUSTERING,
2661 .cmd_per_lun = SBP2_MAX_CMDS,
2662 .can_queue = SBP2_MAX_CMDS,
2663 .emulated = 1,
2664 .sdev_attrs = sbp2_sysfs_sdev_attrs,
2665};
2666
2667static int sbp2_module_init(void) 2122static int sbp2_module_init(void)
2668{ 2123{
2669 int ret; 2124 int ret;
2670 2125
2671 SBP2_DEBUG_ENTER(); 2126 if (sbp2_serialize_io) {
2672 2127 sbp2_shost_template.can_queue = 1;
2673 /* Module load debug option to force one command at a time (serializing I/O) */ 2128 sbp2_shost_template.cmd_per_lun = 1;
2674 if (serialize_io) {
2675 SBP2_INFO("Driver forced to serialize I/O (serialize_io=1)");
2676 SBP2_INFO("Try serialize_io=0 for better performance");
2677 scsi_driver_template.can_queue = 1;
2678 scsi_driver_template.cmd_per_lun = 1;
2679 } 2129 }
2680 2130
2681 if (sbp2_default_workarounds & SBP2_WORKAROUND_128K_MAX_TRANS && 2131 if (sbp2_default_workarounds & SBP2_WORKAROUND_128K_MAX_TRANS &&
2682 (max_sectors * 512) > (128 * 1024)) 2132 (sbp2_max_sectors * 512) > (128 * 1024))
2683 max_sectors = 128 * 1024 / 512; 2133 sbp2_max_sectors = 128 * 1024 / 512;
2684 scsi_driver_template.max_sectors = max_sectors; 2134 sbp2_shost_template.max_sectors = sbp2_max_sectors;
2685 2135
2686 /* Register our high level driver with 1394 stack */
2687 hpsb_register_highlevel(&sbp2_highlevel); 2136 hpsb_register_highlevel(&sbp2_highlevel);
2688
2689 ret = hpsb_register_protocol(&sbp2_driver); 2137 ret = hpsb_register_protocol(&sbp2_driver);
2690 if (ret) { 2138 if (ret) {
2691 SBP2_ERR("Failed to register protocol"); 2139 SBP2_ERR("Failed to register protocol");
2692 hpsb_unregister_highlevel(&sbp2_highlevel); 2140 hpsb_unregister_highlevel(&sbp2_highlevel);
2693 return ret; 2141 return ret;
2694 } 2142 }
2695
2696 return 0; 2143 return 0;
2697} 2144}
2698 2145
2699static void __exit sbp2_module_exit(void) 2146static void __exit sbp2_module_exit(void)
2700{ 2147{
2701 SBP2_DEBUG_ENTER();
2702
2703 hpsb_unregister_protocol(&sbp2_driver); 2148 hpsb_unregister_protocol(&sbp2_driver);
2704
2705 hpsb_unregister_highlevel(&sbp2_highlevel); 2149 hpsb_unregister_highlevel(&sbp2_highlevel);
2706} 2150}
2707 2151
diff --git a/drivers/ieee1394/sbp2.h b/drivers/ieee1394/sbp2.h
index abbe48e646c3..9ae842329bf3 100644
--- a/drivers/ieee1394/sbp2.h
+++ b/drivers/ieee1394/sbp2.h
@@ -25,25 +25,25 @@
25#define SBP2_DEVICE_NAME "sbp2" 25#define SBP2_DEVICE_NAME "sbp2"
26 26
27/* 27/*
28 * SBP2 specific structures and defines 28 * SBP-2 specific definitions
29 */ 29 */
30 30
31#define ORB_DIRECTION_WRITE_TO_MEDIA 0x0 31#define ORB_DIRECTION_WRITE_TO_MEDIA 0x0
32#define ORB_DIRECTION_READ_FROM_MEDIA 0x1 32#define ORB_DIRECTION_READ_FROM_MEDIA 0x1
33#define ORB_DIRECTION_NO_DATA_TRANSFER 0x2 33#define ORB_DIRECTION_NO_DATA_TRANSFER 0x2
34 34
35#define ORB_SET_NULL_PTR(value) ((value & 0x1) << 31) 35#define ORB_SET_NULL_PTR(v) (((v) & 0x1) << 31)
36#define ORB_SET_NOTIFY(value) ((value & 0x1) << 31) 36#define ORB_SET_NOTIFY(v) (((v) & 0x1) << 31)
37#define ORB_SET_RQ_FMT(value) ((value & 0x3) << 29) /* unused ? */ 37#define ORB_SET_RQ_FMT(v) (((v) & 0x3) << 29)
38#define ORB_SET_NODE_ID(value) ((value & 0xffff) << 16) 38#define ORB_SET_NODE_ID(v) (((v) & 0xffff) << 16)
39#define ORB_SET_STATUS_FIFO_HI(value, id) (value >> 32 | ORB_SET_NODE_ID(id)) 39#define ORB_SET_STATUS_FIFO_HI(v, id) ((v) >> 32 | ORB_SET_NODE_ID(id))
40#define ORB_SET_STATUS_FIFO_LO(value) (value & 0xffffffff) 40#define ORB_SET_STATUS_FIFO_LO(v) ((v) & 0xffffffff)
41#define ORB_SET_DATA_SIZE(value) (value & 0xffff) 41#define ORB_SET_DATA_SIZE(v) ((v) & 0xffff)
42#define ORB_SET_PAGE_SIZE(value) ((value & 0x7) << 16) 42#define ORB_SET_PAGE_SIZE(v) (((v) & 0x7) << 16)
43#define ORB_SET_PAGE_TABLE_PRESENT(value) ((value & 0x1) << 19) 43#define ORB_SET_PAGE_TABLE_PRESENT(v) (((v) & 0x1) << 19)
44#define ORB_SET_MAX_PAYLOAD(value) ((value & 0xf) << 20) 44#define ORB_SET_MAX_PAYLOAD(v) (((v) & 0xf) << 20)
45#define ORB_SET_SPEED(value) ((value & 0x7) << 24) 45#define ORB_SET_SPEED(v) (((v) & 0x7) << 24)
46#define ORB_SET_DIRECTION(value) ((value & 0x1) << 27) 46#define ORB_SET_DIRECTION(v) (((v) & 0x1) << 27)
47 47
48struct sbp2_command_orb { 48struct sbp2_command_orb {
49 u32 next_ORB_hi; 49 u32 next_ORB_hi;
@@ -64,12 +64,12 @@ struct sbp2_command_orb {
64#define SBP2_LOGICAL_UNIT_RESET 0xe 64#define SBP2_LOGICAL_UNIT_RESET 0xe
65#define SBP2_TARGET_RESET_REQUEST 0xf 65#define SBP2_TARGET_RESET_REQUEST 0xf
66 66
67#define ORB_SET_LUN(value) (value & 0xffff) 67#define ORB_SET_LUN(v) ((v) & 0xffff)
68#define ORB_SET_FUNCTION(value) ((value & 0xf) << 16) 68#define ORB_SET_FUNCTION(v) (((v) & 0xf) << 16)
69#define ORB_SET_RECONNECT(value) ((value & 0xf) << 20) 69#define ORB_SET_RECONNECT(v) (((v) & 0xf) << 20)
70#define ORB_SET_EXCLUSIVE(value) ((value & 0x1) << 28) 70#define ORB_SET_EXCLUSIVE(v) (((v) & 0x1) << 28)
71#define ORB_SET_LOGIN_RESP_LENGTH(value) (value & 0xffff) 71#define ORB_SET_LOGIN_RESP_LENGTH(v) ((v) & 0xffff)
72#define ORB_SET_PASSWD_LENGTH(value) ((value & 0xffff) << 16) 72#define ORB_SET_PASSWD_LENGTH(v) (((v) & 0xffff) << 16)
73 73
74struct sbp2_login_orb { 74struct sbp2_login_orb {
75 u32 password_hi; 75 u32 password_hi;
@@ -82,9 +82,9 @@ struct sbp2_login_orb {
82 u32 status_fifo_lo; 82 u32 status_fifo_lo;
83} __attribute__((packed)); 83} __attribute__((packed));
84 84
85#define RESPONSE_GET_LOGIN_ID(value) (value & 0xffff) 85#define RESPONSE_GET_LOGIN_ID(v) ((v) & 0xffff)
86#define RESPONSE_GET_LENGTH(value) ((value >> 16) & 0xffff) 86#define RESPONSE_GET_LENGTH(v) (((v) >> 16) & 0xffff)
87#define RESPONSE_GET_RECONNECT_HOLD(value) (value & 0xffff) 87#define RESPONSE_GET_RECONNECT_HOLD(v) ((v) & 0xffff)
88 88
89struct sbp2_login_response { 89struct sbp2_login_response {
90 u32 length_login_ID; 90 u32 length_login_ID;
@@ -93,9 +93,8 @@ struct sbp2_login_response {
93 u32 reconnect_hold; 93 u32 reconnect_hold;
94} __attribute__((packed)); 94} __attribute__((packed));
95 95
96#define ORB_SET_LOGIN_ID(value) (value & 0xffff) 96#define ORB_SET_LOGIN_ID(v) ((v) & 0xffff)
97 97#define ORB_SET_QUERY_LOGINS_RESP_LENGTH(v) ((v) & 0xffff)
98#define ORB_SET_QUERY_LOGINS_RESP_LENGTH(value) (value & 0xffff)
99 98
100struct sbp2_query_logins_orb { 99struct sbp2_query_logins_orb {
101 u32 reserved1; 100 u32 reserved1;
@@ -108,8 +107,8 @@ struct sbp2_query_logins_orb {
108 u32 status_fifo_lo; 107 u32 status_fifo_lo;
109} __attribute__((packed)); 108} __attribute__((packed));
110 109
111#define RESPONSE_GET_MAX_LOGINS(value) (value & 0xffff) 110#define RESPONSE_GET_MAX_LOGINS(v) ((v) & 0xffff)
112#define RESPONSE_GET_ACTIVE_LOGINS(value) ((RESPONSE_GET_LENGTH(value) - 4) / 12) 111#define RESPONSE_GET_ACTIVE_LOGINS(v) ((RESPONSE_GET_LENGTH((v)) - 4) / 12)
113 112
114struct sbp2_query_logins_response { 113struct sbp2_query_logins_response {
115 u32 length_max_logins; 114 u32 length_max_logins;
@@ -140,8 +139,8 @@ struct sbp2_logout_orb {
140 u32 status_fifo_lo; 139 u32 status_fifo_lo;
141} __attribute__((packed)); 140} __attribute__((packed));
142 141
143#define PAGE_TABLE_SET_SEGMENT_BASE_HI(value) (value & 0xffff) 142#define PAGE_TABLE_SET_SEGMENT_BASE_HI(v) ((v) & 0xffff)
144#define PAGE_TABLE_SET_SEGMENT_LENGTH(value) ((value & 0xffff) << 16) 143#define PAGE_TABLE_SET_SEGMENT_LENGTH(v) (((v) & 0xffff) << 16)
145 144
146struct sbp2_unrestricted_page_table { 145struct sbp2_unrestricted_page_table {
147 u32 length_segment_base_hi; 146 u32 length_segment_base_hi;
@@ -171,23 +170,14 @@ struct sbp2_unrestricted_page_table {
171#define SFMT_DEFERRED_ERROR 0x1 170#define SFMT_DEFERRED_ERROR 0x1
172#define SFMT_VENDOR_DEPENDENT_STATUS 0x3 171#define SFMT_VENDOR_DEPENDENT_STATUS 0x3
173 172
174#define SBP2_SCSI_STATUS_GOOD 0x0 173#define STATUS_GET_SRC(v) (((v) >> 30) & 0x3)
175#define SBP2_SCSI_STATUS_CHECK_CONDITION 0x2 174#define STATUS_GET_RESP(v) (((v) >> 28) & 0x3)
176#define SBP2_SCSI_STATUS_CONDITION_MET 0x4 175#define STATUS_GET_LEN(v) (((v) >> 24) & 0x7)
177#define SBP2_SCSI_STATUS_BUSY 0x8 176#define STATUS_GET_SBP_STATUS(v) (((v) >> 16) & 0xff)
178#define SBP2_SCSI_STATUS_RESERVATION_CONFLICT 0x18 177#define STATUS_GET_ORB_OFFSET_HI(v) ((v) & 0x0000ffff)
179#define SBP2_SCSI_STATUS_COMMAND_TERMINATED 0x22 178#define STATUS_TEST_DEAD(v) ((v) & 0x08000000)
180
181#define SBP2_SCSI_STATUS_SELECTION_TIMEOUT 0xff
182
183#define STATUS_GET_SRC(value) (((value) >> 30) & 0x3)
184#define STATUS_GET_RESP(value) (((value) >> 28) & 0x3)
185#define STATUS_GET_LEN(value) (((value) >> 24) & 0x7)
186#define STATUS_GET_SBP_STATUS(value) (((value) >> 16) & 0xff)
187#define STATUS_GET_ORB_OFFSET_HI(value) ((value) & 0x0000ffff)
188#define STATUS_TEST_DEAD(value) ((value) & 0x08000000)
189/* test 'resp' | 'dead' | 'sbp2_status' */ 179/* test 'resp' | 'dead' | 'sbp2_status' */
190#define STATUS_TEST_RDS(value) ((value) & 0x38ff0000) 180#define STATUS_TEST_RDS(v) ((v) & 0x38ff0000)
191 181
192struct sbp2_status_block { 182struct sbp2_status_block {
193 u32 ORB_offset_hi_misc; 183 u32 ORB_offset_hi_misc;
@@ -195,66 +185,70 @@ struct sbp2_status_block {
195 u8 command_set_dependent[24]; 185 u8 command_set_dependent[24];
196} __attribute__((packed)); 186} __attribute__((packed));
197 187
188
198/* 189/*
199 * Miscellaneous SBP2 related config rom defines 190 * SBP2 related configuration ROM definitions
200 */ 191 */
201 192
202#define SBP2_UNIT_DIRECTORY_OFFSET_KEY 0xd1 193#define SBP2_UNIT_DIRECTORY_OFFSET_KEY 0xd1
203#define SBP2_CSR_OFFSET_KEY 0x54 194#define SBP2_CSR_OFFSET_KEY 0x54
204#define SBP2_UNIT_SPEC_ID_KEY 0x12 195#define SBP2_UNIT_SPEC_ID_KEY 0x12
205#define SBP2_UNIT_SW_VERSION_KEY 0x13 196#define SBP2_UNIT_SW_VERSION_KEY 0x13
206#define SBP2_COMMAND_SET_SPEC_ID_KEY 0x38 197#define SBP2_COMMAND_SET_SPEC_ID_KEY 0x38
207#define SBP2_COMMAND_SET_KEY 0x39 198#define SBP2_COMMAND_SET_KEY 0x39
208#define SBP2_UNIT_CHARACTERISTICS_KEY 0x3a 199#define SBP2_UNIT_CHARACTERISTICS_KEY 0x3a
209#define SBP2_DEVICE_TYPE_AND_LUN_KEY 0x14 200#define SBP2_DEVICE_TYPE_AND_LUN_KEY 0x14
210#define SBP2_FIRMWARE_REVISION_KEY 0x3c 201#define SBP2_FIRMWARE_REVISION_KEY 0x3c
211 202
212#define SBP2_AGENT_STATE_OFFSET 0x00ULL 203#define SBP2_AGENT_STATE_OFFSET 0x00ULL
213#define SBP2_AGENT_RESET_OFFSET 0x04ULL 204#define SBP2_AGENT_RESET_OFFSET 0x04ULL
214#define SBP2_ORB_POINTER_OFFSET 0x08ULL 205#define SBP2_ORB_POINTER_OFFSET 0x08ULL
215#define SBP2_DOORBELL_OFFSET 0x10ULL 206#define SBP2_DOORBELL_OFFSET 0x10ULL
216#define SBP2_UNSOLICITED_STATUS_ENABLE_OFFSET 0x14ULL 207#define SBP2_UNSOLICITED_STATUS_ENABLE_OFFSET 0x14ULL
217#define SBP2_UNSOLICITED_STATUS_VALUE 0xf 208#define SBP2_UNSOLICITED_STATUS_VALUE 0xf
218 209
219#define SBP2_BUSY_TIMEOUT_ADDRESS 0xfffff0000210ULL 210#define SBP2_BUSY_TIMEOUT_ADDRESS 0xfffff0000210ULL
220#define SBP2_BUSY_TIMEOUT_VALUE 0xf 211/* biggest possible value for Single Phase Retry count is 0xf */
212#define SBP2_BUSY_TIMEOUT_VALUE 0xf
221 213
222#define SBP2_AGENT_RESET_DATA 0xf 214#define SBP2_AGENT_RESET_DATA 0xf
223 215
224/* 216#define SBP2_UNIT_SPEC_ID_ENTRY 0x0000609e
225 * Unit spec id and sw version entry for SBP-2 devices 217#define SBP2_SW_VERSION_ENTRY 0x00010483
226 */
227 218
228#define SBP2_UNIT_SPEC_ID_ENTRY 0x0000609e
229#define SBP2_SW_VERSION_ENTRY 0x00010483
230 219
231/* 220/*
232 * SCSI specific stuff 221 * SCSI specific definitions
233 */ 222 */
234 223
235#define SBP2_MAX_SG_ELEMENT_LENGTH 0xf000 224#define SBP2_MAX_SG_ELEMENT_LENGTH 0xf000
236#define SBP2_MAX_SECTORS 255 /* Max sectors supported */ 225#define SBP2_MAX_SECTORS 255
237#define SBP2_MAX_CMDS 8 /* This should be safe */ 226/* There is no real limitation of the queue depth (i.e. length of the linked
227 * list of command ORBs) at the target. The chosen depth is merely an
228 * implementation detail of the sbp2 driver. */
229#define SBP2_MAX_CMDS 8
230
231#define SBP2_SCSI_STATUS_GOOD 0x0
232#define SBP2_SCSI_STATUS_CHECK_CONDITION 0x2
233#define SBP2_SCSI_STATUS_CONDITION_MET 0x4
234#define SBP2_SCSI_STATUS_BUSY 0x8
235#define SBP2_SCSI_STATUS_RESERVATION_CONFLICT 0x18
236#define SBP2_SCSI_STATUS_COMMAND_TERMINATED 0x22
237#define SBP2_SCSI_STATUS_SELECTION_TIMEOUT 0xff
238 238
239/* Flags for detected oddities and brokeness */
240#define SBP2_WORKAROUND_128K_MAX_TRANS 0x1
241#define SBP2_WORKAROUND_INQUIRY_36 0x2
242#define SBP2_WORKAROUND_MODE_SENSE_8 0x4
243#define SBP2_WORKAROUND_FIX_CAPACITY 0x8
244#define SBP2_WORKAROUND_OVERRIDE 0x100
245 239
246/* This is the two dma types we use for cmd_dma below */ 240/*
247enum cmd_dma_types { 241 * Representations of commands and devices
242 */
243
244enum sbp2_dma_types {
248 CMD_DMA_NONE, 245 CMD_DMA_NONE,
249 CMD_DMA_PAGE, 246 CMD_DMA_PAGE,
250 CMD_DMA_SINGLE 247 CMD_DMA_SINGLE
251}; 248};
252 249
253/* 250/* Per SCSI command */
254 * Encapsulates all the info necessary for an outstanding command.
255 */
256struct sbp2_command_info { 251struct sbp2_command_info {
257
258 struct list_head list; 252 struct list_head list;
259 struct sbp2_command_orb command_orb ____cacheline_aligned; 253 struct sbp2_command_orb command_orb ____cacheline_aligned;
260 dma_addr_t command_orb_dma ____cacheline_aligned; 254 dma_addr_t command_orb_dma ____cacheline_aligned;
@@ -262,25 +256,25 @@ struct sbp2_command_info {
262 void (*Current_done)(struct scsi_cmnd *); 256 void (*Current_done)(struct scsi_cmnd *);
263 257
264 /* Also need s/g structure for each sbp2 command */ 258 /* Also need s/g structure for each sbp2 command */
265 struct sbp2_unrestricted_page_table scatter_gather_element[SG_ALL] ____cacheline_aligned; 259 struct sbp2_unrestricted_page_table
260 scatter_gather_element[SG_ALL] ____cacheline_aligned;
266 dma_addr_t sge_dma ____cacheline_aligned; 261 dma_addr_t sge_dma ____cacheline_aligned;
267 void *sge_buffer; 262 void *sge_buffer;
268 dma_addr_t cmd_dma; 263 dma_addr_t cmd_dma;
269 enum cmd_dma_types dma_type; 264 enum sbp2_dma_types dma_type;
270 unsigned long dma_size; 265 unsigned long dma_size;
271 int dma_dir; 266 enum dma_data_direction dma_dir;
272
273}; 267};
274 268
275struct sbp2scsi_host_info; 269/* Per FireWire host */
270struct sbp2_fwhost_info {
271 struct hpsb_host *host;
272 struct list_head logical_units;
273};
276 274
277/* 275/* Per logical unit */
278 * Information needed on a per scsi id basis (one for each sbp2 device) 276struct sbp2_lu {
279 */ 277 /* Operation request blocks */
280struct scsi_id_instance_data {
281 /*
282 * Various sbp2 specific structures
283 */
284 struct sbp2_command_orb *last_orb; 278 struct sbp2_command_orb *last_orb;
285 dma_addr_t last_orb_dma; 279 dma_addr_t last_orb_dma;
286 struct sbp2_login_orb *login_orb; 280 struct sbp2_login_orb *login_orb;
@@ -297,116 +291,59 @@ struct scsi_id_instance_data {
297 dma_addr_t logout_orb_dma; 291 dma_addr_t logout_orb_dma;
298 struct sbp2_status_block status_block; 292 struct sbp2_status_block status_block;
299 293
300 /* 294 /* How to talk to the unit */
301 * Stuff we need to know about the sbp2 device itself 295 u64 management_agent_addr;
302 */ 296 u64 command_block_agent_addr;
303 u64 sbp2_management_agent_addr;
304 u64 sbp2_command_block_agent_addr;
305 u32 speed_code; 297 u32 speed_code;
306 u32 max_payload_size; 298 u32 max_payload_size;
299 u16 lun;
307 300
308 /* 301 /* Address for the unit to write status blocks to */
309 * Values pulled from the device's unit directory
310 */
311 u32 sbp2_command_set_spec_id;
312 u32 sbp2_command_set;
313 u32 sbp2_unit_characteristics;
314 u32 sbp2_lun;
315 u32 sbp2_firmware_revision;
316
317 /*
318 * Address for the device to write status blocks to
319 */
320 u64 status_fifo_addr; 302 u64 status_fifo_addr;
321 303
322 /* 304 /* Waitqueue flag for logins, reconnects, logouts, query logins */
323 * Waitqueue flag for logins, reconnects, logouts, query logins 305 unsigned int access_complete:1;
324 */
325 int access_complete:1;
326 306
327 /* 307 /* Pool of command ORBs for this logical unit */
328 * Pool of command orbs, so we can have more than overlapped command per id 308 spinlock_t cmd_orb_lock;
329 */ 309 struct list_head cmd_orb_inuse;
330 spinlock_t sbp2_command_orb_lock; 310 struct list_head cmd_orb_completed;
331 struct list_head sbp2_command_orb_inuse;
332 struct list_head sbp2_command_orb_completed;
333 311
334 struct list_head scsi_list; 312 /* Backlink to FireWire host; list of units attached to the host */
313 struct sbp2_fwhost_info *hi;
314 struct list_head lu_list;
335 315
336 /* Node entry, as retrieved from NodeMgr entries */ 316 /* IEEE 1394 core's device representations */
337 struct node_entry *ne; 317 struct node_entry *ne;
338 struct unit_directory *ud; 318 struct unit_directory *ud;
339 319
340 /* A backlink to our host_info */ 320 /* SCSI core's device representations */
341 struct sbp2scsi_host_info *hi;
342
343 /* SCSI related pointers */
344 struct scsi_device *sdev; 321 struct scsi_device *sdev;
345 struct Scsi_Host *scsi_host; 322 struct Scsi_Host *shost;
346 323
347 /* Device specific workarounds/brokeness */ 324 /* Device specific workarounds/brokeness */
348 unsigned workarounds; 325 unsigned workarounds;
349 326
327 /* Connection state */
350 atomic_t state; 328 atomic_t state;
329
330 /* For deferred requests to the fetch agent */
351 struct work_struct protocol_work; 331 struct work_struct protocol_work;
352}; 332};
353 333
354/* For use in scsi_id_instance_data.state */ 334/* For use in sbp2_lu.state */
355enum sbp2lu_state_types { 335enum sbp2lu_state_types {
356 SBP2LU_STATE_RUNNING, /* all normal */ 336 SBP2LU_STATE_RUNNING, /* all normal */
357 SBP2LU_STATE_IN_RESET, /* between bus reset and reconnect */ 337 SBP2LU_STATE_IN_RESET, /* between bus reset and reconnect */
358 SBP2LU_STATE_IN_SHUTDOWN /* when sbp2_remove was called */ 338 SBP2LU_STATE_IN_SHUTDOWN /* when sbp2_remove was called */
359}; 339};
360 340
361/* Sbp2 host data structure (one per IEEE1394 host) */ 341/* For use in sbp2_lu.workarounds and in the corresponding
362struct sbp2scsi_host_info { 342 * module load parameter */
363 struct hpsb_host *host; /* IEEE1394 host */ 343#define SBP2_WORKAROUND_128K_MAX_TRANS 0x1
364 struct list_head scsi_ids; /* List of scsi ids on this host */ 344#define SBP2_WORKAROUND_INQUIRY_36 0x2
365}; 345#define SBP2_WORKAROUND_MODE_SENSE_8 0x4
366 346#define SBP2_WORKAROUND_FIX_CAPACITY 0x8
367/* 347#define SBP2_WORKAROUND_OVERRIDE 0x100
368 * Function prototypes
369 */
370
371/*
372 * Various utility prototypes
373 */
374static int sbp2util_create_command_orb_pool(struct scsi_id_instance_data *scsi_id);
375static void sbp2util_remove_command_orb_pool(struct scsi_id_instance_data *scsi_id);
376static struct sbp2_command_info *sbp2util_find_command_for_orb(struct scsi_id_instance_data *scsi_id, dma_addr_t orb);
377static struct sbp2_command_info *sbp2util_find_command_for_SCpnt(struct scsi_id_instance_data *scsi_id, void *SCpnt);
378static struct sbp2_command_info *sbp2util_allocate_command_orb(struct scsi_id_instance_data *scsi_id,
379 struct scsi_cmnd *Current_SCpnt,
380 void (*Current_done)(struct scsi_cmnd *));
381static void sbp2util_mark_command_completed(struct scsi_id_instance_data *scsi_id,
382 struct sbp2_command_info *command);
383
384
385static int sbp2_start_device(struct scsi_id_instance_data *scsi_id);
386static void sbp2_remove_device(struct scsi_id_instance_data *scsi_id);
387
388#ifdef CONFIG_IEEE1394_SBP2_PHYS_DMA
389static int sbp2_handle_physdma_write(struct hpsb_host *host, int nodeid, int destid, quadlet_t *data,
390 u64 addr, size_t length, u16 flags);
391static int sbp2_handle_physdma_read(struct hpsb_host *host, int nodeid, quadlet_t *data,
392 u64 addr, size_t length, u16 flags);
393#endif
394
395/*
396 * SBP-2 protocol related prototypes
397 */
398static int sbp2_query_logins(struct scsi_id_instance_data *scsi_id);
399static int sbp2_login_device(struct scsi_id_instance_data *scsi_id);
400static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id);
401static int sbp2_logout_device(struct scsi_id_instance_data *scsi_id);
402static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, int destid,
403 quadlet_t *data, u64 addr, size_t length, u16 flags);
404static int sbp2_agent_reset(struct scsi_id_instance_data *scsi_id, int wait);
405static unsigned int sbp2_status_to_sense_data(unchar *sbp2_status,
406 unchar *sense_data);
407static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id,
408 struct unit_directory *ud);
409static int sbp2_set_busy_timeout(struct scsi_id_instance_data *scsi_id);
410static int sbp2_max_speed_and_size(struct scsi_id_instance_data *scsi_id);
411 348
412#endif /* SBP2_H */ 349#endif /* SBP2_H */
diff --git a/drivers/ieee1394/video1394.c b/drivers/ieee1394/video1394.c
index 9bc65059cc69..598b19fc5989 100644
--- a/drivers/ieee1394/video1394.c
+++ b/drivers/ieee1394/video1394.c
@@ -714,8 +714,8 @@ static inline unsigned video1394_buffer_state(struct dma_iso_ctx *d,
714 return ret; 714 return ret;
715} 715}
716 716
717static int __video1394_ioctl(struct file *file, 717static long video1394_ioctl(struct file *file,
718 unsigned int cmd, unsigned long arg) 718 unsigned int cmd, unsigned long arg)
719{ 719{
720 struct file_ctx *ctx = (struct file_ctx *)file->private_data; 720 struct file_ctx *ctx = (struct file_ctx *)file->private_data;
721 struct ti_ohci *ohci = ctx->ohci; 721 struct ti_ohci *ohci = ctx->ohci;
@@ -884,13 +884,14 @@ static int __video1394_ioctl(struct file *file,
884 struct dma_iso_ctx *d; 884 struct dma_iso_ctx *d;
885 int next_prg; 885 int next_prg;
886 886
887 if (copy_from_user(&v, argp, sizeof(v))) 887 if (unlikely(copy_from_user(&v, argp, sizeof(v))))
888 return -EFAULT; 888 return -EFAULT;
889 889
890 d = find_ctx(&ctx->context_list, OHCI_ISO_RECEIVE, v.channel); 890 d = find_ctx(&ctx->context_list, OHCI_ISO_RECEIVE, v.channel);
891 if (d == NULL) return -EFAULT; 891 if (unlikely(d == NULL))
892 return -EFAULT;
892 893
893 if ((v.buffer<0) || (v.buffer>=d->num_desc - 1)) { 894 if (unlikely((v.buffer<0) || (v.buffer>=d->num_desc - 1))) {
894 PRINT(KERN_ERR, ohci->host->id, 895 PRINT(KERN_ERR, ohci->host->id,
895 "Buffer %d out of range",v.buffer); 896 "Buffer %d out of range",v.buffer);
896 return -EINVAL; 897 return -EINVAL;
@@ -898,7 +899,7 @@ static int __video1394_ioctl(struct file *file,
898 899
899 spin_lock_irqsave(&d->lock,flags); 900 spin_lock_irqsave(&d->lock,flags);
900 901
901 if (d->buffer_status[v.buffer]==VIDEO1394_BUFFER_QUEUED) { 902 if (unlikely(d->buffer_status[v.buffer]==VIDEO1394_BUFFER_QUEUED)) {
902 PRINT(KERN_ERR, ohci->host->id, 903 PRINT(KERN_ERR, ohci->host->id,
903 "Buffer %d is already used",v.buffer); 904 "Buffer %d is already used",v.buffer);
904 spin_unlock_irqrestore(&d->lock,flags); 905 spin_unlock_irqrestore(&d->lock,flags);
@@ -949,13 +950,14 @@ static int __video1394_ioctl(struct file *file,
949 struct dma_iso_ctx *d; 950 struct dma_iso_ctx *d;
950 int i = 0; 951 int i = 0;
951 952
952 if (copy_from_user(&v, argp, sizeof(v))) 953 if (unlikely(copy_from_user(&v, argp, sizeof(v))))
953 return -EFAULT; 954 return -EFAULT;
954 955
955 d = find_ctx(&ctx->context_list, OHCI_ISO_RECEIVE, v.channel); 956 d = find_ctx(&ctx->context_list, OHCI_ISO_RECEIVE, v.channel);
956 if (d == NULL) return -EFAULT; 957 if (unlikely(d == NULL))
958 return -EFAULT;
957 959
958 if ((v.buffer<0) || (v.buffer>d->num_desc - 1)) { 960 if (unlikely((v.buffer<0) || (v.buffer>d->num_desc - 1))) {
959 PRINT(KERN_ERR, ohci->host->id, 961 PRINT(KERN_ERR, ohci->host->id,
960 "Buffer %d out of range",v.buffer); 962 "Buffer %d out of range",v.buffer);
961 return -EINVAL; 963 return -EINVAL;
@@ -1008,7 +1010,7 @@ static int __video1394_ioctl(struct file *file,
1008 spin_unlock_irqrestore(&d->lock, flags); 1010 spin_unlock_irqrestore(&d->lock, flags);
1009 1011
1010 v.buffer=i; 1012 v.buffer=i;
1011 if (copy_to_user(argp, &v, sizeof(v))) 1013 if (unlikely(copy_to_user(argp, &v, sizeof(v))))
1012 return -EFAULT; 1014 return -EFAULT;
1013 1015
1014 return 0; 1016 return 0;
@@ -1156,15 +1158,6 @@ static int __video1394_ioctl(struct file *file,
1156 } 1158 }
1157} 1159}
1158 1160
1159static long video1394_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
1160{
1161 int err;
1162 lock_kernel();
1163 err = __video1394_ioctl(file, cmd, arg);
1164 unlock_kernel();
1165 return err;
1166}
1167
1168/* 1161/*
1169 * This maps the vmalloced and reserved buffer to user space. 1162 * This maps the vmalloced and reserved buffer to user space.
1170 * 1163 *
@@ -1177,17 +1170,14 @@ static long video1394_ioctl(struct file *file, unsigned int cmd, unsigned long a
1177static int video1394_mmap(struct file *file, struct vm_area_struct *vma) 1170static int video1394_mmap(struct file *file, struct vm_area_struct *vma)
1178{ 1171{
1179 struct file_ctx *ctx = (struct file_ctx *)file->private_data; 1172 struct file_ctx *ctx = (struct file_ctx *)file->private_data;
1180 int res = -EINVAL;
1181 1173
1182 lock_kernel();
1183 if (ctx->current_ctx == NULL) { 1174 if (ctx->current_ctx == NULL) {
1184 PRINT(KERN_ERR, ctx->ohci->host->id, 1175 PRINT(KERN_ERR, ctx->ohci->host->id,
1185 "Current iso context not set"); 1176 "Current iso context not set");
1186 } else 1177 return -EINVAL;
1187 res = dma_region_mmap(&ctx->current_ctx->dma, file, vma); 1178 }
1188 unlock_kernel();
1189 1179
1190 return res; 1180 return dma_region_mmap(&ctx->current_ctx->dma, file, vma);
1191} 1181}
1192 1182
1193static unsigned int video1394_poll(struct file *file, poll_table *pt) 1183static unsigned int video1394_poll(struct file *file, poll_table *pt)
@@ -1198,14 +1188,12 @@ static unsigned int video1394_poll(struct file *file, poll_table *pt)
1198 struct dma_iso_ctx *d; 1188 struct dma_iso_ctx *d;
1199 int i; 1189 int i;
1200 1190
1201 lock_kernel();
1202 ctx = file->private_data; 1191 ctx = file->private_data;
1203 d = ctx->current_ctx; 1192 d = ctx->current_ctx;
1204 if (d == NULL) { 1193 if (d == NULL) {
1205 PRINT(KERN_ERR, ctx->ohci->host->id, 1194 PRINT(KERN_ERR, ctx->ohci->host->id,
1206 "Current iso context not set"); 1195 "Current iso context not set");
1207 mask = POLLERR; 1196 return POLLERR;
1208 goto done;
1209 } 1197 }
1210 1198
1211 poll_wait(file, &d->waitq, pt); 1199 poll_wait(file, &d->waitq, pt);
@@ -1218,8 +1206,6 @@ static unsigned int video1394_poll(struct file *file, poll_table *pt)
1218 } 1206 }
1219 } 1207 }
1220 spin_unlock_irqrestore(&d->lock, flags); 1208 spin_unlock_irqrestore(&d->lock, flags);
1221done:
1222 unlock_kernel();
1223 1209
1224 return mask; 1210 return mask;
1225} 1211}
@@ -1255,7 +1241,6 @@ static int video1394_release(struct inode *inode, struct file *file)
1255 struct list_head *lh, *next; 1241 struct list_head *lh, *next;
1256 u64 mask; 1242 u64 mask;
1257 1243
1258 lock_kernel();
1259 list_for_each_safe(lh, next, &ctx->context_list) { 1244 list_for_each_safe(lh, next, &ctx->context_list) {
1260 struct dma_iso_ctx *d; 1245 struct dma_iso_ctx *d;
1261 d = list_entry(lh, struct dma_iso_ctx, link); 1246 d = list_entry(lh, struct dma_iso_ctx, link);
@@ -1276,7 +1261,6 @@ static int video1394_release(struct inode *inode, struct file *file)
1276 kfree(ctx); 1261 kfree(ctx);
1277 file->private_data = NULL; 1262 file->private_data = NULL;
1278 1263
1279 unlock_kernel();
1280 return 0; 1264 return 0;
1281} 1265}
1282 1266
@@ -1324,12 +1308,8 @@ static struct ieee1394_device_id video1394_id_table[] = {
1324MODULE_DEVICE_TABLE(ieee1394, video1394_id_table); 1308MODULE_DEVICE_TABLE(ieee1394, video1394_id_table);
1325 1309
1326static struct hpsb_protocol_driver video1394_driver = { 1310static struct hpsb_protocol_driver video1394_driver = {
1327 .name = "1394 Digital Camera Driver", 1311 .name = VIDEO1394_DRIVER_NAME,
1328 .id_table = video1394_id_table, 1312 .id_table = video1394_id_table,
1329 .driver = {
1330 .name = VIDEO1394_DRIVER_NAME,
1331 .bus = &ieee1394_bus_type,
1332 },
1333}; 1313};
1334 1314
1335 1315
diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
index e11187ecc931..af939796750d 100644
--- a/drivers/infiniband/core/addr.c
+++ b/drivers/infiniband/core/addr.c
@@ -55,11 +55,11 @@ struct addr_req {
55 int status; 55 int status;
56}; 56};
57 57
58static void process_req(void *data); 58static void process_req(struct work_struct *work);
59 59
60static DEFINE_MUTEX(lock); 60static DEFINE_MUTEX(lock);
61static LIST_HEAD(req_list); 61static LIST_HEAD(req_list);
62static DECLARE_WORK(work, process_req, NULL); 62static DECLARE_DELAYED_WORK(work, process_req);
63static struct workqueue_struct *addr_wq; 63static struct workqueue_struct *addr_wq;
64 64
65void rdma_addr_register_client(struct rdma_addr_client *client) 65void rdma_addr_register_client(struct rdma_addr_client *client)
@@ -139,7 +139,7 @@ static void queue_req(struct addr_req *req)
139 139
140 mutex_lock(&lock); 140 mutex_lock(&lock);
141 list_for_each_entry_reverse(temp_req, &req_list, list) { 141 list_for_each_entry_reverse(temp_req, &req_list, list) {
142 if (time_after(req->timeout, temp_req->timeout)) 142 if (time_after_eq(req->timeout, temp_req->timeout))
143 break; 143 break;
144 } 144 }
145 145
@@ -215,7 +215,7 @@ out:
215 return ret; 215 return ret;
216} 216}
217 217
218static void process_req(void *data) 218static void process_req(struct work_struct *work)
219{ 219{
220 struct addr_req *req, *temp_req; 220 struct addr_req *req, *temp_req;
221 struct sockaddr_in *src_in, *dst_in; 221 struct sockaddr_in *src_in, *dst_in;
@@ -225,19 +225,17 @@ static void process_req(void *data)
225 225
226 mutex_lock(&lock); 226 mutex_lock(&lock);
227 list_for_each_entry_safe(req, temp_req, &req_list, list) { 227 list_for_each_entry_safe(req, temp_req, &req_list, list) {
228 if (req->status) { 228 if (req->status == -ENODATA) {
229 src_in = (struct sockaddr_in *) &req->src_addr; 229 src_in = (struct sockaddr_in *) &req->src_addr;
230 dst_in = (struct sockaddr_in *) &req->dst_addr; 230 dst_in = (struct sockaddr_in *) &req->dst_addr;
231 req->status = addr_resolve_remote(src_in, dst_in, 231 req->status = addr_resolve_remote(src_in, dst_in,
232 req->addr); 232 req->addr);
233 if (req->status && time_after_eq(jiffies, req->timeout))
234 req->status = -ETIMEDOUT;
235 else if (req->status == -ENODATA)
236 continue;
233 } 237 }
234 if (req->status && time_after(jiffies, req->timeout)) 238 list_move_tail(&req->list, &done_list);
235 req->status = -ETIMEDOUT;
236 else if (req->status == -ENODATA)
237 continue;
238
239 list_del(&req->list);
240 list_add_tail(&req->list, &done_list);
241 } 239 }
242 240
243 if (!list_empty(&req_list)) { 241 if (!list_empty(&req_list)) {
@@ -347,8 +345,7 @@ void rdma_addr_cancel(struct rdma_dev_addr *addr)
347 if (req->addr == addr) { 345 if (req->addr == addr) {
348 req->status = -ECANCELED; 346 req->status = -ECANCELED;
349 req->timeout = jiffies; 347 req->timeout = jiffies;
350 list_del(&req->list); 348 list_move(&req->list, &req_list);
351 list_add(&req->list, &req_list);
352 set_timeout(req->timeout); 349 set_timeout(req->timeout);
353 break; 350 break;
354 } 351 }
diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c
index 20e9f64e67a6..98272fbbfb31 100644
--- a/drivers/infiniband/core/cache.c
+++ b/drivers/infiniband/core/cache.c
@@ -285,9 +285,10 @@ err:
285 kfree(tprops); 285 kfree(tprops);
286} 286}
287 287
288static void ib_cache_task(void *work_ptr) 288static void ib_cache_task(struct work_struct *_work)
289{ 289{
290 struct ib_update_work *work = work_ptr; 290 struct ib_update_work *work =
291 container_of(_work, struct ib_update_work, work);
291 292
292 ib_cache_update(work->device, work->port_num); 293 ib_cache_update(work->device, work->port_num);
293 kfree(work); 294 kfree(work);
@@ -306,7 +307,7 @@ static void ib_cache_event(struct ib_event_handler *handler,
306 event->event == IB_EVENT_CLIENT_REREGISTER) { 307 event->event == IB_EVENT_CLIENT_REREGISTER) {
307 work = kmalloc(sizeof *work, GFP_ATOMIC); 308 work = kmalloc(sizeof *work, GFP_ATOMIC);
308 if (work) { 309 if (work) {
309 INIT_WORK(&work->work, ib_cache_task, work); 310 INIT_WORK(&work->work, ib_cache_task);
310 work->device = event->device; 311 work->device = event->device;
311 work->port_num = event->element.port_num; 312 work->port_num = event->element.port_num;
312 schedule_work(&work->work); 313 schedule_work(&work->work);
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index 25b1018a476c..79c937bf6962 100644
--- a/drivers/infiniband/core/cm.c
+++ b/drivers/infiniband/core/cm.c
@@ -101,7 +101,7 @@ struct cm_av {
101}; 101};
102 102
103struct cm_work { 103struct cm_work {
104 struct work_struct work; 104 struct delayed_work work;
105 struct list_head list; 105 struct list_head list;
106 struct cm_port *port; 106 struct cm_port *port;
107 struct ib_mad_recv_wc *mad_recv_wc; /* Received MADs */ 107 struct ib_mad_recv_wc *mad_recv_wc; /* Received MADs */
@@ -147,12 +147,12 @@ struct cm_id_private {
147 __be32 rq_psn; 147 __be32 rq_psn;
148 int timeout_ms; 148 int timeout_ms;
149 enum ib_mtu path_mtu; 149 enum ib_mtu path_mtu;
150 __be16 pkey;
150 u8 private_data_len; 151 u8 private_data_len;
151 u8 max_cm_retries; 152 u8 max_cm_retries;
152 u8 peer_to_peer; 153 u8 peer_to_peer;
153 u8 responder_resources; 154 u8 responder_resources;
154 u8 initiator_depth; 155 u8 initiator_depth;
155 u8 local_ack_timeout;
156 u8 retry_count; 156 u8 retry_count;
157 u8 rnr_retry_count; 157 u8 rnr_retry_count;
158 u8 service_timeout; 158 u8 service_timeout;
@@ -161,7 +161,7 @@ struct cm_id_private {
161 atomic_t work_count; 161 atomic_t work_count;
162}; 162};
163 163
164static void cm_work_handler(void *data); 164static void cm_work_handler(struct work_struct *work);
165 165
166static inline void cm_deref_id(struct cm_id_private *cm_id_priv) 166static inline void cm_deref_id(struct cm_id_private *cm_id_priv)
167{ 167{
@@ -240,11 +240,10 @@ static void * cm_copy_private_data(const void *private_data,
240 if (!private_data || !private_data_len) 240 if (!private_data || !private_data_len)
241 return NULL; 241 return NULL;
242 242
243 data = kmalloc(private_data_len, GFP_KERNEL); 243 data = kmemdup(private_data, private_data_len, GFP_KERNEL);
244 if (!data) 244 if (!data)
245 return ERR_PTR(-ENOMEM); 245 return ERR_PTR(-ENOMEM);
246 246
247 memcpy(data, private_data, private_data_len);
248 return data; 247 return data;
249} 248}
250 249
@@ -669,8 +668,7 @@ static struct cm_timewait_info * cm_create_timewait_info(__be32 local_id)
669 return ERR_PTR(-ENOMEM); 668 return ERR_PTR(-ENOMEM);
670 669
671 timewait_info->work.local_id = local_id; 670 timewait_info->work.local_id = local_id;
672 INIT_WORK(&timewait_info->work.work, cm_work_handler, 671 INIT_DELAYED_WORK(&timewait_info->work.work, cm_work_handler);
673 &timewait_info->work);
674 timewait_info->work.cm_event.event = IB_CM_TIMEWAIT_EXIT; 672 timewait_info->work.cm_event.event = IB_CM_TIMEWAIT_EXIT;
675 return timewait_info; 673 return timewait_info;
676} 674}
@@ -691,7 +689,7 @@ static void cm_enter_timewait(struct cm_id_private *cm_id_priv)
691 * timewait before notifying the user that we've exited timewait. 689 * timewait before notifying the user that we've exited timewait.
692 */ 690 */
693 cm_id_priv->id.state = IB_CM_TIMEWAIT; 691 cm_id_priv->id.state = IB_CM_TIMEWAIT;
694 wait_time = cm_convert_to_ms(cm_id_priv->local_ack_timeout); 692 wait_time = cm_convert_to_ms(cm_id_priv->av.packet_life_time + 1);
695 queue_delayed_work(cm.wq, &cm_id_priv->timewait_info->work.work, 693 queue_delayed_work(cm.wq, &cm_id_priv->timewait_info->work.work,
696 msecs_to_jiffies(wait_time)); 694 msecs_to_jiffies(wait_time));
697 cm_id_priv->timewait_info = NULL; 695 cm_id_priv->timewait_info = NULL;
@@ -1010,6 +1008,7 @@ int ib_send_cm_req(struct ib_cm_id *cm_id,
1010 cm_id_priv->responder_resources = param->responder_resources; 1008 cm_id_priv->responder_resources = param->responder_resources;
1011 cm_id_priv->retry_count = param->retry_count; 1009 cm_id_priv->retry_count = param->retry_count;
1012 cm_id_priv->path_mtu = param->primary_path->mtu; 1010 cm_id_priv->path_mtu = param->primary_path->mtu;
1011 cm_id_priv->pkey = param->primary_path->pkey;
1013 cm_id_priv->qp_type = param->qp_type; 1012 cm_id_priv->qp_type = param->qp_type;
1014 1013
1015 ret = cm_alloc_msg(cm_id_priv, &cm_id_priv->msg); 1014 ret = cm_alloc_msg(cm_id_priv, &cm_id_priv->msg);
@@ -1024,8 +1023,6 @@ int ib_send_cm_req(struct ib_cm_id *cm_id,
1024 1023
1025 cm_id_priv->local_qpn = cm_req_get_local_qpn(req_msg); 1024 cm_id_priv->local_qpn = cm_req_get_local_qpn(req_msg);
1026 cm_id_priv->rq_psn = cm_req_get_starting_psn(req_msg); 1025 cm_id_priv->rq_psn = cm_req_get_starting_psn(req_msg);
1027 cm_id_priv->local_ack_timeout =
1028 cm_req_get_primary_local_ack_timeout(req_msg);
1029 1026
1030 spin_lock_irqsave(&cm_id_priv->lock, flags); 1027 spin_lock_irqsave(&cm_id_priv->lock, flags);
1031 ret = ib_post_send_mad(cm_id_priv->msg, NULL); 1028 ret = ib_post_send_mad(cm_id_priv->msg, NULL);
@@ -1410,9 +1407,8 @@ static int cm_req_handler(struct cm_work *work)
1410 cm_id_priv->initiator_depth = cm_req_get_resp_res(req_msg); 1407 cm_id_priv->initiator_depth = cm_req_get_resp_res(req_msg);
1411 cm_id_priv->responder_resources = cm_req_get_init_depth(req_msg); 1408 cm_id_priv->responder_resources = cm_req_get_init_depth(req_msg);
1412 cm_id_priv->path_mtu = cm_req_get_path_mtu(req_msg); 1409 cm_id_priv->path_mtu = cm_req_get_path_mtu(req_msg);
1410 cm_id_priv->pkey = req_msg->pkey;
1413 cm_id_priv->sq_psn = cm_req_get_starting_psn(req_msg); 1411 cm_id_priv->sq_psn = cm_req_get_starting_psn(req_msg);
1414 cm_id_priv->local_ack_timeout =
1415 cm_req_get_primary_local_ack_timeout(req_msg);
1416 cm_id_priv->retry_count = cm_req_get_retry_count(req_msg); 1412 cm_id_priv->retry_count = cm_req_get_retry_count(req_msg);
1417 cm_id_priv->rnr_retry_count = cm_req_get_rnr_retry_count(req_msg); 1413 cm_id_priv->rnr_retry_count = cm_req_get_rnr_retry_count(req_msg);
1418 cm_id_priv->qp_type = cm_req_get_qp_type(req_msg); 1414 cm_id_priv->qp_type = cm_req_get_qp_type(req_msg);
@@ -1716,7 +1712,7 @@ static int cm_establish_handler(struct cm_work *work)
1716 unsigned long flags; 1712 unsigned long flags;
1717 int ret; 1713 int ret;
1718 1714
1719 /* See comment in ib_cm_establish about lookup. */ 1715 /* See comment in cm_establish about lookup. */
1720 cm_id_priv = cm_acquire_id(work->local_id, work->remote_id); 1716 cm_id_priv = cm_acquire_id(work->local_id, work->remote_id);
1721 if (!cm_id_priv) 1717 if (!cm_id_priv)
1722 return -EINVAL; 1718 return -EINVAL;
@@ -2402,11 +2398,16 @@ int ib_send_cm_lap(struct ib_cm_id *cm_id,
2402 cm_id_priv = container_of(cm_id, struct cm_id_private, id); 2398 cm_id_priv = container_of(cm_id, struct cm_id_private, id);
2403 spin_lock_irqsave(&cm_id_priv->lock, flags); 2399 spin_lock_irqsave(&cm_id_priv->lock, flags);
2404 if (cm_id->state != IB_CM_ESTABLISHED || 2400 if (cm_id->state != IB_CM_ESTABLISHED ||
2405 cm_id->lap_state != IB_CM_LAP_IDLE) { 2401 (cm_id->lap_state != IB_CM_LAP_UNINIT &&
2402 cm_id->lap_state != IB_CM_LAP_IDLE)) {
2406 ret = -EINVAL; 2403 ret = -EINVAL;
2407 goto out; 2404 goto out;
2408 } 2405 }
2409 2406
2407 ret = cm_init_av_by_path(alternate_path, &cm_id_priv->alt_av);
2408 if (ret)
2409 goto out;
2410
2410 ret = cm_alloc_msg(cm_id_priv, &msg); 2411 ret = cm_alloc_msg(cm_id_priv, &msg);
2411 if (ret) 2412 if (ret)
2412 goto out; 2413 goto out;
@@ -2431,7 +2432,8 @@ out: spin_unlock_irqrestore(&cm_id_priv->lock, flags);
2431} 2432}
2432EXPORT_SYMBOL(ib_send_cm_lap); 2433EXPORT_SYMBOL(ib_send_cm_lap);
2433 2434
2434static void cm_format_path_from_lap(struct ib_sa_path_rec *path, 2435static void cm_format_path_from_lap(struct cm_id_private *cm_id_priv,
2436 struct ib_sa_path_rec *path,
2435 struct cm_lap_msg *lap_msg) 2437 struct cm_lap_msg *lap_msg)
2436{ 2438{
2437 memset(path, 0, sizeof *path); 2439 memset(path, 0, sizeof *path);
@@ -2443,10 +2445,10 @@ static void cm_format_path_from_lap(struct ib_sa_path_rec *path,
2443 path->hop_limit = lap_msg->alt_hop_limit; 2445 path->hop_limit = lap_msg->alt_hop_limit;
2444 path->traffic_class = cm_lap_get_traffic_class(lap_msg); 2446 path->traffic_class = cm_lap_get_traffic_class(lap_msg);
2445 path->reversible = 1; 2447 path->reversible = 1;
2446 /* pkey is same as in REQ */ 2448 path->pkey = cm_id_priv->pkey;
2447 path->sl = cm_lap_get_sl(lap_msg); 2449 path->sl = cm_lap_get_sl(lap_msg);
2448 path->mtu_selector = IB_SA_EQ; 2450 path->mtu_selector = IB_SA_EQ;
2449 /* mtu is same as in REQ */ 2451 path->mtu = cm_id_priv->path_mtu;
2450 path->rate_selector = IB_SA_EQ; 2452 path->rate_selector = IB_SA_EQ;
2451 path->rate = cm_lap_get_packet_rate(lap_msg); 2453 path->rate = cm_lap_get_packet_rate(lap_msg);
2452 path->packet_life_time_selector = IB_SA_EQ; 2454 path->packet_life_time_selector = IB_SA_EQ;
@@ -2472,7 +2474,7 @@ static int cm_lap_handler(struct cm_work *work)
2472 2474
2473 param = &work->cm_event.param.lap_rcvd; 2475 param = &work->cm_event.param.lap_rcvd;
2474 param->alternate_path = &work->path[0]; 2476 param->alternate_path = &work->path[0];
2475 cm_format_path_from_lap(param->alternate_path, lap_msg); 2477 cm_format_path_from_lap(cm_id_priv, param->alternate_path, lap_msg);
2476 work->cm_event.private_data = &lap_msg->private_data; 2478 work->cm_event.private_data = &lap_msg->private_data;
2477 2479
2478 spin_lock_irqsave(&cm_id_priv->lock, flags); 2480 spin_lock_irqsave(&cm_id_priv->lock, flags);
@@ -2480,6 +2482,7 @@ static int cm_lap_handler(struct cm_work *work)
2480 goto unlock; 2482 goto unlock;
2481 2483
2482 switch (cm_id_priv->id.lap_state) { 2484 switch (cm_id_priv->id.lap_state) {
2485 case IB_CM_LAP_UNINIT:
2483 case IB_CM_LAP_IDLE: 2486 case IB_CM_LAP_IDLE:
2484 break; 2487 break;
2485 case IB_CM_MRA_LAP_SENT: 2488 case IB_CM_MRA_LAP_SENT:
@@ -2502,6 +2505,10 @@ static int cm_lap_handler(struct cm_work *work)
2502 2505
2503 cm_id_priv->id.lap_state = IB_CM_LAP_RCVD; 2506 cm_id_priv->id.lap_state = IB_CM_LAP_RCVD;
2504 cm_id_priv->tid = lap_msg->hdr.tid; 2507 cm_id_priv->tid = lap_msg->hdr.tid;
2508 cm_init_av_for_response(work->port, work->mad_recv_wc->wc,
2509 work->mad_recv_wc->recv_buf.grh,
2510 &cm_id_priv->av);
2511 cm_init_av_by_path(param->alternate_path, &cm_id_priv->alt_av);
2505 ret = atomic_inc_and_test(&cm_id_priv->work_count); 2512 ret = atomic_inc_and_test(&cm_id_priv->work_count);
2506 if (!ret) 2513 if (!ret)
2507 list_add_tail(&work->list, &cm_id_priv->work_list); 2514 list_add_tail(&work->list, &cm_id_priv->work_list);
@@ -2987,9 +2994,9 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
2987 } 2994 }
2988} 2995}
2989 2996
2990static void cm_work_handler(void *data) 2997static void cm_work_handler(struct work_struct *_work)
2991{ 2998{
2992 struct cm_work *work = data; 2999 struct cm_work *work = container_of(_work, struct cm_work, work.work);
2993 int ret; 3000 int ret;
2994 3001
2995 switch (work->cm_event.event) { 3002 switch (work->cm_event.event) {
@@ -3040,7 +3047,7 @@ static void cm_work_handler(void *data)
3040 cm_free_work(work); 3047 cm_free_work(work);
3041} 3048}
3042 3049
3043int ib_cm_establish(struct ib_cm_id *cm_id) 3050static int cm_establish(struct ib_cm_id *cm_id)
3044{ 3051{
3045 struct cm_id_private *cm_id_priv; 3052 struct cm_id_private *cm_id_priv;
3046 struct cm_work *work; 3053 struct cm_work *work;
@@ -3079,16 +3086,53 @@ int ib_cm_establish(struct ib_cm_id *cm_id)
3079 * we need to find the cm_id once we're in the context of the 3086 * we need to find the cm_id once we're in the context of the
3080 * worker thread, rather than holding a reference on it. 3087 * worker thread, rather than holding a reference on it.
3081 */ 3088 */
3082 INIT_WORK(&work->work, cm_work_handler, work); 3089 INIT_DELAYED_WORK(&work->work, cm_work_handler);
3083 work->local_id = cm_id->local_id; 3090 work->local_id = cm_id->local_id;
3084 work->remote_id = cm_id->remote_id; 3091 work->remote_id = cm_id->remote_id;
3085 work->mad_recv_wc = NULL; 3092 work->mad_recv_wc = NULL;
3086 work->cm_event.event = IB_CM_USER_ESTABLISHED; 3093 work->cm_event.event = IB_CM_USER_ESTABLISHED;
3087 queue_work(cm.wq, &work->work); 3094 queue_delayed_work(cm.wq, &work->work, 0);
3088out: 3095out:
3089 return ret; 3096 return ret;
3090} 3097}
3091EXPORT_SYMBOL(ib_cm_establish); 3098
3099static int cm_migrate(struct ib_cm_id *cm_id)
3100{
3101 struct cm_id_private *cm_id_priv;
3102 unsigned long flags;
3103 int ret = 0;
3104
3105 cm_id_priv = container_of(cm_id, struct cm_id_private, id);
3106 spin_lock_irqsave(&cm_id_priv->lock, flags);
3107 if (cm_id->state == IB_CM_ESTABLISHED &&
3108 (cm_id->lap_state == IB_CM_LAP_UNINIT ||
3109 cm_id->lap_state == IB_CM_LAP_IDLE)) {
3110 cm_id->lap_state = IB_CM_LAP_IDLE;
3111 cm_id_priv->av = cm_id_priv->alt_av;
3112 } else
3113 ret = -EINVAL;
3114 spin_unlock_irqrestore(&cm_id_priv->lock, flags);
3115
3116 return ret;
3117}
3118
3119int ib_cm_notify(struct ib_cm_id *cm_id, enum ib_event_type event)
3120{
3121 int ret;
3122
3123 switch (event) {
3124 case IB_EVENT_COMM_EST:
3125 ret = cm_establish(cm_id);
3126 break;
3127 case IB_EVENT_PATH_MIG:
3128 ret = cm_migrate(cm_id);
3129 break;
3130 default:
3131 ret = -EINVAL;
3132 }
3133 return ret;
3134}
3135EXPORT_SYMBOL(ib_cm_notify);
3092 3136
3093static void cm_recv_handler(struct ib_mad_agent *mad_agent, 3137static void cm_recv_handler(struct ib_mad_agent *mad_agent,
3094 struct ib_mad_recv_wc *mad_recv_wc) 3138 struct ib_mad_recv_wc *mad_recv_wc)
@@ -3146,11 +3190,11 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
3146 return; 3190 return;
3147 } 3191 }
3148 3192
3149 INIT_WORK(&work->work, cm_work_handler, work); 3193 INIT_DELAYED_WORK(&work->work, cm_work_handler);
3150 work->cm_event.event = event; 3194 work->cm_event.event = event;
3151 work->mad_recv_wc = mad_recv_wc; 3195 work->mad_recv_wc = mad_recv_wc;
3152 work->port = (struct cm_port *)mad_agent->context; 3196 work->port = (struct cm_port *)mad_agent->context;
3153 queue_work(cm.wq, &work->work); 3197 queue_delayed_work(cm.wq, &work->work, 0);
3154} 3198}
3155 3199
3156static int cm_init_qp_init_attr(struct cm_id_private *cm_id_priv, 3200static int cm_init_qp_init_attr(struct cm_id_private *cm_id_priv,
@@ -3173,8 +3217,7 @@ static int cm_init_qp_init_attr(struct cm_id_private *cm_id_priv,
3173 case IB_CM_ESTABLISHED: 3217 case IB_CM_ESTABLISHED:
3174 *qp_attr_mask = IB_QP_STATE | IB_QP_ACCESS_FLAGS | 3218 *qp_attr_mask = IB_QP_STATE | IB_QP_ACCESS_FLAGS |
3175 IB_QP_PKEY_INDEX | IB_QP_PORT; 3219 IB_QP_PKEY_INDEX | IB_QP_PORT;
3176 qp_attr->qp_access_flags = IB_ACCESS_LOCAL_WRITE | 3220 qp_attr->qp_access_flags = IB_ACCESS_REMOTE_WRITE;
3177 IB_ACCESS_REMOTE_WRITE;
3178 if (cm_id_priv->responder_resources) 3221 if (cm_id_priv->responder_resources)
3179 qp_attr->qp_access_flags |= IB_ACCESS_REMOTE_READ | 3222 qp_attr->qp_access_flags |= IB_ACCESS_REMOTE_READ |
3180 IB_ACCESS_REMOTE_ATOMIC; 3223 IB_ACCESS_REMOTE_ATOMIC;
@@ -3222,6 +3265,9 @@ static int cm_init_qp_rtr_attr(struct cm_id_private *cm_id_priv,
3222 if (cm_id_priv->alt_av.ah_attr.dlid) { 3265 if (cm_id_priv->alt_av.ah_attr.dlid) {
3223 *qp_attr_mask |= IB_QP_ALT_PATH; 3266 *qp_attr_mask |= IB_QP_ALT_PATH;
3224 qp_attr->alt_port_num = cm_id_priv->alt_av.port->port_num; 3267 qp_attr->alt_port_num = cm_id_priv->alt_av.port->port_num;
3268 qp_attr->alt_pkey_index = cm_id_priv->alt_av.pkey_index;
3269 qp_attr->alt_timeout =
3270 cm_id_priv->alt_av.packet_life_time + 1;
3225 qp_attr->alt_ah_attr = cm_id_priv->alt_av.ah_attr; 3271 qp_attr->alt_ah_attr = cm_id_priv->alt_av.ah_attr;
3226 } 3272 }
3227 ret = 0; 3273 ret = 0;
@@ -3248,19 +3294,31 @@ static int cm_init_qp_rts_attr(struct cm_id_private *cm_id_priv,
3248 case IB_CM_REP_SENT: 3294 case IB_CM_REP_SENT:
3249 case IB_CM_MRA_REP_RCVD: 3295 case IB_CM_MRA_REP_RCVD:
3250 case IB_CM_ESTABLISHED: 3296 case IB_CM_ESTABLISHED:
3251 *qp_attr_mask = IB_QP_STATE | IB_QP_SQ_PSN; 3297 if (cm_id_priv->id.lap_state == IB_CM_LAP_UNINIT) {
3252 qp_attr->sq_psn = be32_to_cpu(cm_id_priv->sq_psn); 3298 *qp_attr_mask = IB_QP_STATE | IB_QP_SQ_PSN;
3253 if (cm_id_priv->qp_type == IB_QPT_RC) { 3299 qp_attr->sq_psn = be32_to_cpu(cm_id_priv->sq_psn);
3254 *qp_attr_mask |= IB_QP_TIMEOUT | IB_QP_RETRY_CNT | 3300 if (cm_id_priv->qp_type == IB_QPT_RC) {
3255 IB_QP_RNR_RETRY | 3301 *qp_attr_mask |= IB_QP_TIMEOUT | IB_QP_RETRY_CNT |
3256 IB_QP_MAX_QP_RD_ATOMIC; 3302 IB_QP_RNR_RETRY |
3257 qp_attr->timeout = cm_id_priv->local_ack_timeout; 3303 IB_QP_MAX_QP_RD_ATOMIC;
3258 qp_attr->retry_cnt = cm_id_priv->retry_count; 3304 qp_attr->timeout =
3259 qp_attr->rnr_retry = cm_id_priv->rnr_retry_count; 3305 cm_id_priv->av.packet_life_time + 1;
3260 qp_attr->max_rd_atomic = cm_id_priv->initiator_depth; 3306 qp_attr->retry_cnt = cm_id_priv->retry_count;
3261 } 3307 qp_attr->rnr_retry = cm_id_priv->rnr_retry_count;
3262 if (cm_id_priv->alt_av.ah_attr.dlid) { 3308 qp_attr->max_rd_atomic =
3263 *qp_attr_mask |= IB_QP_PATH_MIG_STATE; 3309 cm_id_priv->initiator_depth;
3310 }
3311 if (cm_id_priv->alt_av.ah_attr.dlid) {
3312 *qp_attr_mask |= IB_QP_PATH_MIG_STATE;
3313 qp_attr->path_mig_state = IB_MIG_REARM;
3314 }
3315 } else {
3316 *qp_attr_mask = IB_QP_ALT_PATH | IB_QP_PATH_MIG_STATE;
3317 qp_attr->alt_port_num = cm_id_priv->alt_av.port->port_num;
3318 qp_attr->alt_pkey_index = cm_id_priv->alt_av.pkey_index;
3319 qp_attr->alt_timeout =
3320 cm_id_priv->alt_av.packet_life_time + 1;
3321 qp_attr->alt_ah_attr = cm_id_priv->alt_av.ah_attr;
3264 qp_attr->path_mig_state = IB_MIG_REARM; 3322 qp_attr->path_mig_state = IB_MIG_REARM;
3265 } 3323 }
3266 ret = 0; 3324 ret = 0;
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 845090b0859c..985a6b564d8f 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -344,7 +344,7 @@ static int cma_init_ib_qp(struct rdma_id_private *id_priv, struct ib_qp *qp)
344 return ret; 344 return ret;
345 345
346 qp_attr.qp_state = IB_QPS_INIT; 346 qp_attr.qp_state = IB_QPS_INIT;
347 qp_attr.qp_access_flags = IB_ACCESS_LOCAL_WRITE; 347 qp_attr.qp_access_flags = 0;
348 qp_attr.port_num = id_priv->id.port_num; 348 qp_attr.port_num = id_priv->id.port_num;
349 return ib_modify_qp(qp, &qp_attr, IB_QP_STATE | IB_QP_ACCESS_FLAGS | 349 return ib_modify_qp(qp, &qp_attr, IB_QP_STATE | IB_QP_ACCESS_FLAGS |
350 IB_QP_PKEY_INDEX | IB_QP_PORT); 350 IB_QP_PKEY_INDEX | IB_QP_PORT);
@@ -935,13 +935,8 @@ static int cma_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
935 mutex_lock(&lock); 935 mutex_lock(&lock);
936 ret = cma_acquire_dev(conn_id); 936 ret = cma_acquire_dev(conn_id);
937 mutex_unlock(&lock); 937 mutex_unlock(&lock);
938 if (ret) { 938 if (ret)
939 ret = -ENODEV; 939 goto release_conn_id;
940 cma_exch(conn_id, CMA_DESTROYING);
941 cma_release_remove(conn_id);
942 rdma_destroy_id(&conn_id->id);
943 goto out;
944 }
945 940
946 conn_id->cm_id.ib = cm_id; 941 conn_id->cm_id.ib = cm_id;
947 cm_id->context = conn_id; 942 cm_id->context = conn_id;
@@ -951,13 +946,17 @@ static int cma_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
951 ret = cma_notify_user(conn_id, RDMA_CM_EVENT_CONNECT_REQUEST, 0, 946 ret = cma_notify_user(conn_id, RDMA_CM_EVENT_CONNECT_REQUEST, 0,
952 ib_event->private_data + offset, 947 ib_event->private_data + offset,
953 IB_CM_REQ_PRIVATE_DATA_SIZE - offset); 948 IB_CM_REQ_PRIVATE_DATA_SIZE - offset);
954 if (ret) { 949 if (!ret)
955 /* Destroy the CM ID by returning a non-zero value. */ 950 goto out;
956 conn_id->cm_id.ib = NULL; 951
957 cma_exch(conn_id, CMA_DESTROYING); 952 /* Destroy the CM ID by returning a non-zero value. */
958 cma_release_remove(conn_id); 953 conn_id->cm_id.ib = NULL;
959 rdma_destroy_id(&conn_id->id); 954
960 } 955release_conn_id:
956 cma_exch(conn_id, CMA_DESTROYING);
957 cma_release_remove(conn_id);
958 rdma_destroy_id(&conn_id->id);
959
961out: 960out:
962 cma_release_remove(listen_id); 961 cma_release_remove(listen_id);
963 return ret; 962 return ret;
@@ -1341,9 +1340,9 @@ static int cma_query_ib_route(struct rdma_id_private *id_priv, int timeout_ms,
1341 return (id_priv->query_id < 0) ? id_priv->query_id : 0; 1340 return (id_priv->query_id < 0) ? id_priv->query_id : 0;
1342} 1341}
1343 1342
1344static void cma_work_handler(void *data) 1343static void cma_work_handler(struct work_struct *_work)
1345{ 1344{
1346 struct cma_work *work = data; 1345 struct cma_work *work = container_of(_work, struct cma_work, work);
1347 struct rdma_id_private *id_priv = work->id; 1346 struct rdma_id_private *id_priv = work->id;
1348 int destroy = 0; 1347 int destroy = 0;
1349 1348
@@ -1374,7 +1373,7 @@ static int cma_resolve_ib_route(struct rdma_id_private *id_priv, int timeout_ms)
1374 return -ENOMEM; 1373 return -ENOMEM;
1375 1374
1376 work->id = id_priv; 1375 work->id = id_priv;
1377 INIT_WORK(&work->work, cma_work_handler, work); 1376 INIT_WORK(&work->work, cma_work_handler);
1378 work->old_state = CMA_ROUTE_QUERY; 1377 work->old_state = CMA_ROUTE_QUERY;
1379 work->new_state = CMA_ROUTE_RESOLVED; 1378 work->new_state = CMA_ROUTE_RESOLVED;
1380 work->event.event = RDMA_CM_EVENT_ROUTE_RESOLVED; 1379 work->event.event = RDMA_CM_EVENT_ROUTE_RESOLVED;
@@ -1431,7 +1430,7 @@ static int cma_resolve_iw_route(struct rdma_id_private *id_priv, int timeout_ms)
1431 return -ENOMEM; 1430 return -ENOMEM;
1432 1431
1433 work->id = id_priv; 1432 work->id = id_priv;
1434 INIT_WORK(&work->work, cma_work_handler, work); 1433 INIT_WORK(&work->work, cma_work_handler);
1435 work->old_state = CMA_ROUTE_QUERY; 1434 work->old_state = CMA_ROUTE_QUERY;
1436 work->new_state = CMA_ROUTE_RESOLVED; 1435 work->new_state = CMA_ROUTE_RESOLVED;
1437 work->event.event = RDMA_CM_EVENT_ROUTE_RESOLVED; 1436 work->event.event = RDMA_CM_EVENT_ROUTE_RESOLVED;
@@ -1481,19 +1480,18 @@ static int cma_bind_loopback(struct rdma_id_private *id_priv)
1481 u8 p; 1480 u8 p;
1482 1481
1483 mutex_lock(&lock); 1482 mutex_lock(&lock);
1483 if (list_empty(&dev_list)) {
1484 ret = -ENODEV;
1485 goto out;
1486 }
1484 list_for_each_entry(cma_dev, &dev_list, list) 1487 list_for_each_entry(cma_dev, &dev_list, list)
1485 for (p = 1; p <= cma_dev->device->phys_port_cnt; ++p) 1488 for (p = 1; p <= cma_dev->device->phys_port_cnt; ++p)
1486 if (!ib_query_port (cma_dev->device, p, &port_attr) && 1489 if (!ib_query_port(cma_dev->device, p, &port_attr) &&
1487 port_attr.state == IB_PORT_ACTIVE) 1490 port_attr.state == IB_PORT_ACTIVE)
1488 goto port_found; 1491 goto port_found;
1489 1492
1490 if (!list_empty(&dev_list)) { 1493 p = 1;
1491 p = 1; 1494 cma_dev = list_entry(dev_list.next, struct cma_device, list);
1492 cma_dev = list_entry(dev_list.next, struct cma_device, list);
1493 } else {
1494 ret = -ENODEV;
1495 goto out;
1496 }
1497 1495
1498port_found: 1496port_found:
1499 ret = ib_get_cached_gid(cma_dev->device, p, 0, &gid); 1497 ret = ib_get_cached_gid(cma_dev->device, p, 0, &gid);
@@ -1585,7 +1583,7 @@ static int cma_resolve_loopback(struct rdma_id_private *id_priv)
1585 } 1583 }
1586 1584
1587 work->id = id_priv; 1585 work->id = id_priv;
1588 INIT_WORK(&work->work, cma_work_handler, work); 1586 INIT_WORK(&work->work, cma_work_handler);
1589 work->old_state = CMA_ADDR_QUERY; 1587 work->old_state = CMA_ADDR_QUERY;
1590 work->new_state = CMA_ADDR_RESOLVED; 1588 work->new_state = CMA_ADDR_RESOLVED;
1591 work->event.event = RDMA_CM_EVENT_ADDR_RESOLVED; 1589 work->event.event = RDMA_CM_EVENT_ADDR_RESOLVED;
@@ -2123,8 +2121,6 @@ static void cma_add_one(struct ib_device *device)
2123 2121
2124 cma_dev->device = device; 2122 cma_dev->device = device;
2125 cma_dev->node_guid = device->node_guid; 2123 cma_dev->node_guid = device->node_guid;
2126 if (!cma_dev->node_guid)
2127 goto err;
2128 2124
2129 init_completion(&cma_dev->comp); 2125 init_completion(&cma_dev->comp);
2130 atomic_set(&cma_dev->refcount, 1); 2126 atomic_set(&cma_dev->refcount, 1);
@@ -2136,9 +2132,6 @@ static void cma_add_one(struct ib_device *device)
2136 list_for_each_entry(id_priv, &listen_any_list, list) 2132 list_for_each_entry(id_priv, &listen_any_list, list)
2137 cma_listen_on_dev(id_priv, cma_dev); 2133 cma_listen_on_dev(id_priv, cma_dev);
2138 mutex_unlock(&lock); 2134 mutex_unlock(&lock);
2139 return;
2140err:
2141 kfree(cma_dev);
2142} 2135}
2143 2136
2144static int cma_remove_id_dev(struct rdma_id_private *id_priv) 2137static int cma_remove_id_dev(struct rdma_id_private *id_priv)
diff --git a/drivers/infiniband/core/iwcm.c b/drivers/infiniband/core/iwcm.c
index c3fb304a4e86..1039ad57d53b 100644
--- a/drivers/infiniband/core/iwcm.c
+++ b/drivers/infiniband/core/iwcm.c
@@ -80,7 +80,7 @@ struct iwcm_work {
80 * 1) in the event upcall, cm_event_handler(), for a listening cm_id. If 80 * 1) in the event upcall, cm_event_handler(), for a listening cm_id. If
81 * the backlog is exceeded, then no more connection request events will 81 * the backlog is exceeded, then no more connection request events will
82 * be processed. cm_event_handler() returns -ENOMEM in this case. Its up 82 * be processed. cm_event_handler() returns -ENOMEM in this case. Its up
83 * to the provider to reject the connectino request. 83 * to the provider to reject the connection request.
84 * 2) in the connection request workqueue handler, cm_conn_req_handler(). 84 * 2) in the connection request workqueue handler, cm_conn_req_handler().
85 * If work elements cannot be allocated for the new connect request cm_id, 85 * If work elements cannot be allocated for the new connect request cm_id,
86 * then IWCM will call the provider reject method. This is ok since 86 * then IWCM will call the provider reject method. This is ok since
@@ -131,26 +131,25 @@ static int alloc_work_entries(struct iwcm_id_private *cm_id_priv, int count)
131} 131}
132 132
133/* 133/*
134 * Save private data from incoming connection requests in the 134 * Save private data from incoming connection requests to
135 * cm_id_priv so the low level driver doesn't have to. Adjust 135 * iw_cm_event, so the low level driver doesn't have to. Adjust
136 * the event ptr to point to the local copy. 136 * the event ptr to point to the local copy.
137 */ 137 */
138static int copy_private_data(struct iwcm_id_private *cm_id_priv, 138static int copy_private_data(struct iw_cm_event *event)
139 struct iw_cm_event *event)
140{ 139{
141 void *p; 140 void *p;
142 141
143 p = kmalloc(event->private_data_len, GFP_ATOMIC); 142 p = kmemdup(event->private_data, event->private_data_len, GFP_ATOMIC);
144 if (!p) 143 if (!p)
145 return -ENOMEM; 144 return -ENOMEM;
146 memcpy(p, event->private_data, event->private_data_len);
147 event->private_data = p; 145 event->private_data = p;
148 return 0; 146 return 0;
149} 147}
150 148
151/* 149/*
152 * Release a reference on cm_id. If the last reference is being removed 150 * Release a reference on cm_id. If the last reference is being
153 * and iw_destroy_cm_id is waiting, wake up the waiting thread. 151 * released, enable the waiting thread (in iw_destroy_cm_id) to
152 * get woken up, and return 1 if a thread is already waiting.
154 */ 153 */
155static int iwcm_deref_id(struct iwcm_id_private *cm_id_priv) 154static int iwcm_deref_id(struct iwcm_id_private *cm_id_priv)
156{ 155{
@@ -243,7 +242,7 @@ static int iwcm_modify_qp_sqd(struct ib_qp *qp)
243/* 242/*
244 * CM_ID <-- CLOSING 243 * CM_ID <-- CLOSING
245 * 244 *
246 * Block if a passive or active connection is currenlty being processed. Then 245 * Block if a passive or active connection is currently being processed. Then
247 * process the event as follows: 246 * process the event as follows:
248 * - If we are ESTABLISHED, move to CLOSING and modify the QP state 247 * - If we are ESTABLISHED, move to CLOSING and modify the QP state
249 * based on the abrupt flag 248 * based on the abrupt flag
@@ -408,7 +407,7 @@ int iw_cm_listen(struct iw_cm_id *cm_id, int backlog)
408{ 407{
409 struct iwcm_id_private *cm_id_priv; 408 struct iwcm_id_private *cm_id_priv;
410 unsigned long flags; 409 unsigned long flags;
411 int ret = 0; 410 int ret;
412 411
413 cm_id_priv = container_of(cm_id, struct iwcm_id_private, id); 412 cm_id_priv = container_of(cm_id, struct iwcm_id_private, id);
414 413
@@ -535,7 +534,7 @@ EXPORT_SYMBOL(iw_cm_accept);
535int iw_cm_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *iw_param) 534int iw_cm_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *iw_param)
536{ 535{
537 struct iwcm_id_private *cm_id_priv; 536 struct iwcm_id_private *cm_id_priv;
538 int ret = 0; 537 int ret;
539 unsigned long flags; 538 unsigned long flags;
540 struct ib_qp *qp; 539 struct ib_qp *qp;
541 540
@@ -620,7 +619,7 @@ static void cm_conn_req_handler(struct iwcm_id_private *listen_id_priv,
620 spin_lock_irqsave(&listen_id_priv->lock, flags); 619 spin_lock_irqsave(&listen_id_priv->lock, flags);
621 if (listen_id_priv->state != IW_CM_STATE_LISTEN) { 620 if (listen_id_priv->state != IW_CM_STATE_LISTEN) {
622 spin_unlock_irqrestore(&listen_id_priv->lock, flags); 621 spin_unlock_irqrestore(&listen_id_priv->lock, flags);
623 return; 622 goto out;
624 } 623 }
625 spin_unlock_irqrestore(&listen_id_priv->lock, flags); 624 spin_unlock_irqrestore(&listen_id_priv->lock, flags);
626 625
@@ -629,7 +628,7 @@ static void cm_conn_req_handler(struct iwcm_id_private *listen_id_priv,
629 listen_id_priv->id.context); 628 listen_id_priv->id.context);
630 /* If the cm_id could not be created, ignore the request */ 629 /* If the cm_id could not be created, ignore the request */
631 if (IS_ERR(cm_id)) 630 if (IS_ERR(cm_id))
632 return; 631 goto out;
633 632
634 cm_id->provider_data = iw_event->provider_data; 633 cm_id->provider_data = iw_event->provider_data;
635 cm_id->local_addr = iw_event->local_addr; 634 cm_id->local_addr = iw_event->local_addr;
@@ -642,7 +641,7 @@ static void cm_conn_req_handler(struct iwcm_id_private *listen_id_priv,
642 if (ret) { 641 if (ret) {
643 iw_cm_reject(cm_id, NULL, 0); 642 iw_cm_reject(cm_id, NULL, 0);
644 iw_destroy_cm_id(cm_id); 643 iw_destroy_cm_id(cm_id);
645 return; 644 goto out;
646 } 645 }
647 646
648 /* Call the client CM handler */ 647 /* Call the client CM handler */
@@ -654,6 +653,7 @@ static void cm_conn_req_handler(struct iwcm_id_private *listen_id_priv,
654 kfree(cm_id); 653 kfree(cm_id);
655 } 654 }
656 655
656out:
657 if (iw_event->private_data_len) 657 if (iw_event->private_data_len)
658 kfree(iw_event->private_data); 658 kfree(iw_event->private_data);
659} 659}
@@ -674,7 +674,7 @@ static int cm_conn_est_handler(struct iwcm_id_private *cm_id_priv,
674 struct iw_cm_event *iw_event) 674 struct iw_cm_event *iw_event)
675{ 675{
676 unsigned long flags; 676 unsigned long flags;
677 int ret = 0; 677 int ret;
678 678
679 spin_lock_irqsave(&cm_id_priv->lock, flags); 679 spin_lock_irqsave(&cm_id_priv->lock, flags);
680 680
@@ -704,7 +704,7 @@ static int cm_conn_rep_handler(struct iwcm_id_private *cm_id_priv,
704 struct iw_cm_event *iw_event) 704 struct iw_cm_event *iw_event)
705{ 705{
706 unsigned long flags; 706 unsigned long flags;
707 int ret = 0; 707 int ret;
708 708
709 spin_lock_irqsave(&cm_id_priv->lock, flags); 709 spin_lock_irqsave(&cm_id_priv->lock, flags);
710 /* 710 /*
@@ -828,9 +828,10 @@ static int process_event(struct iwcm_id_private *cm_id_priv,
828 * thread asleep on the destroy_comp list vs. an object destroyed 828 * thread asleep on the destroy_comp list vs. an object destroyed
829 * here synchronously when the last reference is removed. 829 * here synchronously when the last reference is removed.
830 */ 830 */
831static void cm_work_handler(void *arg) 831static void cm_work_handler(struct work_struct *_work)
832{ 832{
833 struct iwcm_work *work = arg, lwork; 833 struct iwcm_work *work = container_of(_work, struct iwcm_work, work);
834 struct iw_cm_event levent;
834 struct iwcm_id_private *cm_id_priv = work->cm_id; 835 struct iwcm_id_private *cm_id_priv = work->cm_id;
835 unsigned long flags; 836 unsigned long flags;
836 int empty; 837 int empty;
@@ -843,11 +844,11 @@ static void cm_work_handler(void *arg)
843 struct iwcm_work, list); 844 struct iwcm_work, list);
844 list_del_init(&work->list); 845 list_del_init(&work->list);
845 empty = list_empty(&cm_id_priv->work_list); 846 empty = list_empty(&cm_id_priv->work_list);
846 lwork = *work; 847 levent = work->event;
847 put_work(work); 848 put_work(work);
848 spin_unlock_irqrestore(&cm_id_priv->lock, flags); 849 spin_unlock_irqrestore(&cm_id_priv->lock, flags);
849 850
850 ret = process_event(cm_id_priv, &work->event); 851 ret = process_event(cm_id_priv, &levent);
851 if (ret) { 852 if (ret) {
852 set_bit(IWCM_F_CALLBACK_DESTROY, &cm_id_priv->flags); 853 set_bit(IWCM_F_CALLBACK_DESTROY, &cm_id_priv->flags);
853 destroy_cm_id(&cm_id_priv->id); 854 destroy_cm_id(&cm_id_priv->id);
@@ -899,14 +900,14 @@ static int cm_event_handler(struct iw_cm_id *cm_id,
899 goto out; 900 goto out;
900 } 901 }
901 902
902 INIT_WORK(&work->work, cm_work_handler, work); 903 INIT_WORK(&work->work, cm_work_handler);
903 work->cm_id = cm_id_priv; 904 work->cm_id = cm_id_priv;
904 work->event = *iw_event; 905 work->event = *iw_event;
905 906
906 if ((work->event.event == IW_CM_EVENT_CONNECT_REQUEST || 907 if ((work->event.event == IW_CM_EVENT_CONNECT_REQUEST ||
907 work->event.event == IW_CM_EVENT_CONNECT_REPLY) && 908 work->event.event == IW_CM_EVENT_CONNECT_REPLY) &&
908 work->event.private_data_len) { 909 work->event.private_data_len) {
909 ret = copy_private_data(cm_id_priv, &work->event); 910 ret = copy_private_data(&work->event);
910 if (ret) { 911 if (ret) {
911 put_work(work); 912 put_work(work);
912 goto out; 913 goto out;
diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
index 493f4c65c7a2..15f38d94b3a8 100644
--- a/drivers/infiniband/core/mad.c
+++ b/drivers/infiniband/core/mad.c
@@ -46,7 +46,7 @@ MODULE_DESCRIPTION("kernel IB MAD API");
46MODULE_AUTHOR("Hal Rosenstock"); 46MODULE_AUTHOR("Hal Rosenstock");
47MODULE_AUTHOR("Sean Hefty"); 47MODULE_AUTHOR("Sean Hefty");
48 48
49static kmem_cache_t *ib_mad_cache; 49static struct kmem_cache *ib_mad_cache;
50 50
51static struct list_head ib_mad_port_list; 51static struct list_head ib_mad_port_list;
52static u32 ib_mad_client_id = 0; 52static u32 ib_mad_client_id = 0;
@@ -65,8 +65,8 @@ static struct ib_mad_agent_private *find_mad_agent(
65static int ib_mad_post_receive_mads(struct ib_mad_qp_info *qp_info, 65static int ib_mad_post_receive_mads(struct ib_mad_qp_info *qp_info,
66 struct ib_mad_private *mad); 66 struct ib_mad_private *mad);
67static void cancel_mads(struct ib_mad_agent_private *mad_agent_priv); 67static void cancel_mads(struct ib_mad_agent_private *mad_agent_priv);
68static void timeout_sends(void *data); 68static void timeout_sends(struct work_struct *work);
69static void local_completions(void *data); 69static void local_completions(struct work_struct *work);
70static int add_nonoui_reg_req(struct ib_mad_reg_req *mad_reg_req, 70static int add_nonoui_reg_req(struct ib_mad_reg_req *mad_reg_req,
71 struct ib_mad_agent_private *agent_priv, 71 struct ib_mad_agent_private *agent_priv,
72 u8 mgmt_class); 72 u8 mgmt_class);
@@ -356,10 +356,9 @@ struct ib_mad_agent *ib_register_mad_agent(struct ib_device *device,
356 INIT_LIST_HEAD(&mad_agent_priv->wait_list); 356 INIT_LIST_HEAD(&mad_agent_priv->wait_list);
357 INIT_LIST_HEAD(&mad_agent_priv->done_list); 357 INIT_LIST_HEAD(&mad_agent_priv->done_list);
358 INIT_LIST_HEAD(&mad_agent_priv->rmpp_list); 358 INIT_LIST_HEAD(&mad_agent_priv->rmpp_list);
359 INIT_WORK(&mad_agent_priv->timed_work, timeout_sends, mad_agent_priv); 359 INIT_DELAYED_WORK(&mad_agent_priv->timed_work, timeout_sends);
360 INIT_LIST_HEAD(&mad_agent_priv->local_list); 360 INIT_LIST_HEAD(&mad_agent_priv->local_list);
361 INIT_WORK(&mad_agent_priv->local_work, local_completions, 361 INIT_WORK(&mad_agent_priv->local_work, local_completions);
362 mad_agent_priv);
363 atomic_set(&mad_agent_priv->refcount, 1); 362 atomic_set(&mad_agent_priv->refcount, 1);
364 init_completion(&mad_agent_priv->comp); 363 init_completion(&mad_agent_priv->comp);
365 364
@@ -1750,7 +1749,7 @@ ib_find_send_mad(struct ib_mad_agent_private *mad_agent_priv,
1750 */ 1749 */
1751 (is_direct(wc->recv_buf.mad->mad_hdr.mgmt_class) || 1750 (is_direct(wc->recv_buf.mad->mad_hdr.mgmt_class) ||
1752 rcv_has_same_gid(mad_agent_priv, wr, wc))) 1751 rcv_has_same_gid(mad_agent_priv, wr, wc)))
1753 return wr; 1752 return (wr->status == IB_WC_SUCCESS) ? wr : NULL;
1754 } 1753 }
1755 1754
1756 /* 1755 /*
@@ -2198,12 +2197,12 @@ static void mad_error_handler(struct ib_mad_port_private *port_priv,
2198/* 2197/*
2199 * IB MAD completion callback 2198 * IB MAD completion callback
2200 */ 2199 */
2201static void ib_mad_completion_handler(void *data) 2200static void ib_mad_completion_handler(struct work_struct *work)
2202{ 2201{
2203 struct ib_mad_port_private *port_priv; 2202 struct ib_mad_port_private *port_priv;
2204 struct ib_wc wc; 2203 struct ib_wc wc;
2205 2204
2206 port_priv = (struct ib_mad_port_private *)data; 2205 port_priv = container_of(work, struct ib_mad_port_private, work);
2207 ib_req_notify_cq(port_priv->cq, IB_CQ_NEXT_COMP); 2206 ib_req_notify_cq(port_priv->cq, IB_CQ_NEXT_COMP);
2208 2207
2209 while (ib_poll_cq(port_priv->cq, 1, &wc) == 1) { 2208 while (ib_poll_cq(port_priv->cq, 1, &wc) == 1) {
@@ -2324,7 +2323,7 @@ void ib_cancel_mad(struct ib_mad_agent *mad_agent,
2324} 2323}
2325EXPORT_SYMBOL(ib_cancel_mad); 2324EXPORT_SYMBOL(ib_cancel_mad);
2326 2325
2327static void local_completions(void *data) 2326static void local_completions(struct work_struct *work)
2328{ 2327{
2329 struct ib_mad_agent_private *mad_agent_priv; 2328 struct ib_mad_agent_private *mad_agent_priv;
2330 struct ib_mad_local_private *local; 2329 struct ib_mad_local_private *local;
@@ -2334,7 +2333,8 @@ static void local_completions(void *data)
2334 struct ib_wc wc; 2333 struct ib_wc wc;
2335 struct ib_mad_send_wc mad_send_wc; 2334 struct ib_mad_send_wc mad_send_wc;
2336 2335
2337 mad_agent_priv = (struct ib_mad_agent_private *)data; 2336 mad_agent_priv =
2337 container_of(work, struct ib_mad_agent_private, local_work);
2338 2338
2339 spin_lock_irqsave(&mad_agent_priv->lock, flags); 2339 spin_lock_irqsave(&mad_agent_priv->lock, flags);
2340 while (!list_empty(&mad_agent_priv->local_list)) { 2340 while (!list_empty(&mad_agent_priv->local_list)) {
@@ -2434,14 +2434,15 @@ static int retry_send(struct ib_mad_send_wr_private *mad_send_wr)
2434 return ret; 2434 return ret;
2435} 2435}
2436 2436
2437static void timeout_sends(void *data) 2437static void timeout_sends(struct work_struct *work)
2438{ 2438{
2439 struct ib_mad_agent_private *mad_agent_priv; 2439 struct ib_mad_agent_private *mad_agent_priv;
2440 struct ib_mad_send_wr_private *mad_send_wr; 2440 struct ib_mad_send_wr_private *mad_send_wr;
2441 struct ib_mad_send_wc mad_send_wc; 2441 struct ib_mad_send_wc mad_send_wc;
2442 unsigned long flags, delay; 2442 unsigned long flags, delay;
2443 2443
2444 mad_agent_priv = (struct ib_mad_agent_private *)data; 2444 mad_agent_priv = container_of(work, struct ib_mad_agent_private,
2445 timed_work.work);
2445 mad_send_wc.vendor_err = 0; 2446 mad_send_wc.vendor_err = 0;
2446 2447
2447 spin_lock_irqsave(&mad_agent_priv->lock, flags); 2448 spin_lock_irqsave(&mad_agent_priv->lock, flags);
@@ -2799,7 +2800,7 @@ static int ib_mad_port_open(struct ib_device *device,
2799 ret = -ENOMEM; 2800 ret = -ENOMEM;
2800 goto error8; 2801 goto error8;
2801 } 2802 }
2802 INIT_WORK(&port_priv->work, ib_mad_completion_handler, port_priv); 2803 INIT_WORK(&port_priv->work, ib_mad_completion_handler);
2803 2804
2804 spin_lock_irqsave(&ib_mad_port_list_lock, flags); 2805 spin_lock_irqsave(&ib_mad_port_list_lock, flags);
2805 list_add_tail(&port_priv->port_list, &ib_mad_port_list); 2806 list_add_tail(&port_priv->port_list, &ib_mad_port_list);
diff --git a/drivers/infiniband/core/mad_priv.h b/drivers/infiniband/core/mad_priv.h
index d06b59083f6e..d5548e73e068 100644
--- a/drivers/infiniband/core/mad_priv.h
+++ b/drivers/infiniband/core/mad_priv.h
@@ -102,7 +102,7 @@ struct ib_mad_agent_private {
102 struct list_head send_list; 102 struct list_head send_list;
103 struct list_head wait_list; 103 struct list_head wait_list;
104 struct list_head done_list; 104 struct list_head done_list;
105 struct work_struct timed_work; 105 struct delayed_work timed_work;
106 unsigned long timeout; 106 unsigned long timeout;
107 struct list_head local_list; 107 struct list_head local_list;
108 struct work_struct local_work; 108 struct work_struct local_work;
diff --git a/drivers/infiniband/core/mad_rmpp.c b/drivers/infiniband/core/mad_rmpp.c
index 1ef79d015a1e..3663fd7022be 100644
--- a/drivers/infiniband/core/mad_rmpp.c
+++ b/drivers/infiniband/core/mad_rmpp.c
@@ -45,8 +45,8 @@ enum rmpp_state {
45struct mad_rmpp_recv { 45struct mad_rmpp_recv {
46 struct ib_mad_agent_private *agent; 46 struct ib_mad_agent_private *agent;
47 struct list_head list; 47 struct list_head list;
48 struct work_struct timeout_work; 48 struct delayed_work timeout_work;
49 struct work_struct cleanup_work; 49 struct delayed_work cleanup_work;
50 struct completion comp; 50 struct completion comp;
51 enum rmpp_state state; 51 enum rmpp_state state;
52 spinlock_t lock; 52 spinlock_t lock;
@@ -233,9 +233,10 @@ static void nack_recv(struct ib_mad_agent_private *agent,
233 } 233 }
234} 234}
235 235
236static void recv_timeout_handler(void *data) 236static void recv_timeout_handler(struct work_struct *work)
237{ 237{
238 struct mad_rmpp_recv *rmpp_recv = data; 238 struct mad_rmpp_recv *rmpp_recv =
239 container_of(work, struct mad_rmpp_recv, timeout_work.work);
239 struct ib_mad_recv_wc *rmpp_wc; 240 struct ib_mad_recv_wc *rmpp_wc;
240 unsigned long flags; 241 unsigned long flags;
241 242
@@ -254,9 +255,10 @@ static void recv_timeout_handler(void *data)
254 ib_free_recv_mad(rmpp_wc); 255 ib_free_recv_mad(rmpp_wc);
255} 256}
256 257
257static void recv_cleanup_handler(void *data) 258static void recv_cleanup_handler(struct work_struct *work)
258{ 259{
259 struct mad_rmpp_recv *rmpp_recv = data; 260 struct mad_rmpp_recv *rmpp_recv =
261 container_of(work, struct mad_rmpp_recv, cleanup_work.work);
260 unsigned long flags; 262 unsigned long flags;
261 263
262 spin_lock_irqsave(&rmpp_recv->agent->lock, flags); 264 spin_lock_irqsave(&rmpp_recv->agent->lock, flags);
@@ -285,8 +287,8 @@ create_rmpp_recv(struct ib_mad_agent_private *agent,
285 287
286 rmpp_recv->agent = agent; 288 rmpp_recv->agent = agent;
287 init_completion(&rmpp_recv->comp); 289 init_completion(&rmpp_recv->comp);
288 INIT_WORK(&rmpp_recv->timeout_work, recv_timeout_handler, rmpp_recv); 290 INIT_DELAYED_WORK(&rmpp_recv->timeout_work, recv_timeout_handler);
289 INIT_WORK(&rmpp_recv->cleanup_work, recv_cleanup_handler, rmpp_recv); 291 INIT_DELAYED_WORK(&rmpp_recv->cleanup_work, recv_cleanup_handler);
290 spin_lock_init(&rmpp_recv->lock); 292 spin_lock_init(&rmpp_recv->lock);
291 rmpp_recv->state = RMPP_STATE_ACTIVE; 293 rmpp_recv->state = RMPP_STATE_ACTIVE;
292 atomic_set(&rmpp_recv->refcount, 1); 294 atomic_set(&rmpp_recv->refcount, 1);
diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
index 1706d3c7e95e..e45afba75341 100644
--- a/drivers/infiniband/core/sa_query.c
+++ b/drivers/infiniband/core/sa_query.c
@@ -360,9 +360,10 @@ static void free_sm_ah(struct kref *kref)
360 kfree(sm_ah); 360 kfree(sm_ah);
361} 361}
362 362
363static void update_sm_ah(void *port_ptr) 363static void update_sm_ah(struct work_struct *work)
364{ 364{
365 struct ib_sa_port *port = port_ptr; 365 struct ib_sa_port *port =
366 container_of(work, struct ib_sa_port, update_task);
366 struct ib_sa_sm_ah *new_ah, *old_ah; 367 struct ib_sa_sm_ah *new_ah, *old_ah;
367 struct ib_port_attr port_attr; 368 struct ib_port_attr port_attr;
368 struct ib_ah_attr ah_attr; 369 struct ib_ah_attr ah_attr;
@@ -992,8 +993,7 @@ static void ib_sa_add_one(struct ib_device *device)
992 if (IS_ERR(sa_dev->port[i].agent)) 993 if (IS_ERR(sa_dev->port[i].agent))
993 goto err; 994 goto err;
994 995
995 INIT_WORK(&sa_dev->port[i].update_task, 996 INIT_WORK(&sa_dev->port[i].update_task, update_sm_ah);
996 update_sm_ah, &sa_dev->port[i]);
997 } 997 }
998 998
999 ib_set_client_data(device, &sa_client, sa_dev); 999 ib_set_client_data(device, &sa_client, sa_dev);
@@ -1010,7 +1010,7 @@ static void ib_sa_add_one(struct ib_device *device)
1010 goto err; 1010 goto err;
1011 1011
1012 for (i = 0; i <= e - s; ++i) 1012 for (i = 0; i <= e - s; ++i)
1013 update_sm_ah(&sa_dev->port[i]); 1013 update_sm_ah(&sa_dev->port[i].update_task);
1014 1014
1015 return; 1015 return;
1016 1016
diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c
index ad4f4d5c2924..f15220a0ee75 100644
--- a/drivers/infiniband/core/ucm.c
+++ b/drivers/infiniband/core/ucm.c
@@ -161,12 +161,14 @@ static void ib_ucm_cleanup_events(struct ib_ucm_context *ctx)
161 struct ib_ucm_event, ctx_list); 161 struct ib_ucm_event, ctx_list);
162 list_del(&uevent->file_list); 162 list_del(&uevent->file_list);
163 list_del(&uevent->ctx_list); 163 list_del(&uevent->ctx_list);
164 mutex_unlock(&ctx->file->file_mutex);
164 165
165 /* clear incoming connections. */ 166 /* clear incoming connections. */
166 if (ib_ucm_new_cm_id(uevent->resp.event)) 167 if (ib_ucm_new_cm_id(uevent->resp.event))
167 ib_destroy_cm_id(uevent->cm_id); 168 ib_destroy_cm_id(uevent->cm_id);
168 169
169 kfree(uevent); 170 kfree(uevent);
171 mutex_lock(&ctx->file->file_mutex);
170 } 172 }
171 mutex_unlock(&ctx->file->file_mutex); 173 mutex_unlock(&ctx->file->file_mutex);
172} 174}
@@ -328,20 +330,18 @@ static int ib_ucm_event_process(struct ib_cm_event *evt,
328 } 330 }
329 331
330 if (uvt->data_len) { 332 if (uvt->data_len) {
331 uvt->data = kmalloc(uvt->data_len, GFP_KERNEL); 333 uvt->data = kmemdup(evt->private_data, uvt->data_len, GFP_KERNEL);
332 if (!uvt->data) 334 if (!uvt->data)
333 goto err1; 335 goto err1;
334 336
335 memcpy(uvt->data, evt->private_data, uvt->data_len);
336 uvt->resp.present |= IB_UCM_PRES_DATA; 337 uvt->resp.present |= IB_UCM_PRES_DATA;
337 } 338 }
338 339
339 if (uvt->info_len) { 340 if (uvt->info_len) {
340 uvt->info = kmalloc(uvt->info_len, GFP_KERNEL); 341 uvt->info = kmemdup(info, uvt->info_len, GFP_KERNEL);
341 if (!uvt->info) 342 if (!uvt->info)
342 goto err2; 343 goto err2;
343 344
344 memcpy(uvt->info, info, uvt->info_len);
345 uvt->resp.present |= IB_UCM_PRES_INFO; 345 uvt->resp.present |= IB_UCM_PRES_INFO;
346 } 346 }
347 return 0; 347 return 0;
@@ -685,11 +685,11 @@ out:
685 return result; 685 return result;
686} 686}
687 687
688static ssize_t ib_ucm_establish(struct ib_ucm_file *file, 688static ssize_t ib_ucm_notify(struct ib_ucm_file *file,
689 const char __user *inbuf, 689 const char __user *inbuf,
690 int in_len, int out_len) 690 int in_len, int out_len)
691{ 691{
692 struct ib_ucm_establish cmd; 692 struct ib_ucm_notify cmd;
693 struct ib_ucm_context *ctx; 693 struct ib_ucm_context *ctx;
694 int result; 694 int result;
695 695
@@ -700,7 +700,7 @@ static ssize_t ib_ucm_establish(struct ib_ucm_file *file,
700 if (IS_ERR(ctx)) 700 if (IS_ERR(ctx))
701 return PTR_ERR(ctx); 701 return PTR_ERR(ctx);
702 702
703 result = ib_cm_establish(ctx->cm_id); 703 result = ib_cm_notify(ctx->cm_id, (enum ib_event_type) cmd.event);
704 ib_ucm_ctx_put(ctx); 704 ib_ucm_ctx_put(ctx);
705 return result; 705 return result;
706} 706}
@@ -1107,7 +1107,7 @@ static ssize_t (*ucm_cmd_table[])(struct ib_ucm_file *file,
1107 [IB_USER_CM_CMD_DESTROY_ID] = ib_ucm_destroy_id, 1107 [IB_USER_CM_CMD_DESTROY_ID] = ib_ucm_destroy_id,
1108 [IB_USER_CM_CMD_ATTR_ID] = ib_ucm_attr_id, 1108 [IB_USER_CM_CMD_ATTR_ID] = ib_ucm_attr_id,
1109 [IB_USER_CM_CMD_LISTEN] = ib_ucm_listen, 1109 [IB_USER_CM_CMD_LISTEN] = ib_ucm_listen,
1110 [IB_USER_CM_CMD_ESTABLISH] = ib_ucm_establish, 1110 [IB_USER_CM_CMD_NOTIFY] = ib_ucm_notify,
1111 [IB_USER_CM_CMD_SEND_REQ] = ib_ucm_send_req, 1111 [IB_USER_CM_CMD_SEND_REQ] = ib_ucm_send_req,
1112 [IB_USER_CM_CMD_SEND_REP] = ib_ucm_send_rep, 1112 [IB_USER_CM_CMD_SEND_REP] = ib_ucm_send_rep,
1113 [IB_USER_CM_CMD_SEND_RTU] = ib_ucm_send_rtu, 1113 [IB_USER_CM_CMD_SEND_RTU] = ib_ucm_send_rtu,
diff --git a/drivers/infiniband/core/uverbs_mem.c b/drivers/infiniband/core/uverbs_mem.c
index efe147dbeb42..db12cc0841df 100644
--- a/drivers/infiniband/core/uverbs_mem.c
+++ b/drivers/infiniband/core/uverbs_mem.c
@@ -179,9 +179,10 @@ void ib_umem_release(struct ib_device *dev, struct ib_umem *umem)
179 up_write(&current->mm->mmap_sem); 179 up_write(&current->mm->mmap_sem);
180} 180}
181 181
182static void ib_umem_account(void *work_ptr) 182static void ib_umem_account(struct work_struct *_work)
183{ 183{
184 struct ib_umem_account_work *work = work_ptr; 184 struct ib_umem_account_work *work =
185 container_of(_work, struct ib_umem_account_work, work);
185 186
186 down_write(&work->mm->mmap_sem); 187 down_write(&work->mm->mmap_sem);
187 work->mm->locked_vm -= work->diff; 188 work->mm->locked_vm -= work->diff;
@@ -216,7 +217,7 @@ void ib_umem_release_on_close(struct ib_device *dev, struct ib_umem *umem)
216 return; 217 return;
217 } 218 }
218 219
219 INIT_WORK(&work->work, ib_umem_account, work); 220 INIT_WORK(&work->work, ib_umem_account);
220 work->mm = mm; 221 work->mm = mm;
221 work->diff = PAGE_ALIGN(umem->length + umem->offset) >> PAGE_SHIFT; 222 work->diff = PAGE_ALIGN(umem->length + umem->offset) >> PAGE_SHIFT;
222 223
diff --git a/drivers/infiniband/hw/amso1100/c2.c b/drivers/infiniband/hw/amso1100/c2.c
index 9e7bd94b958a..27fe242ed435 100644
--- a/drivers/infiniband/hw/amso1100/c2.c
+++ b/drivers/infiniband/hw/amso1100/c2.c
@@ -1155,7 +1155,8 @@ static int __devinit c2_probe(struct pci_dev *pcidev,
1155 goto bail10; 1155 goto bail10;
1156 } 1156 }
1157 1157
1158 c2_register_device(c2dev); 1158 if (c2_register_device(c2dev))
1159 goto bail10;
1159 1160
1160 return 0; 1161 return 0;
1161 1162
diff --git a/drivers/infiniband/hw/amso1100/c2.h b/drivers/infiniband/hw/amso1100/c2.h
index 1b17dcdd0505..04a9db5de881 100644
--- a/drivers/infiniband/hw/amso1100/c2.h
+++ b/drivers/infiniband/hw/amso1100/c2.h
@@ -302,7 +302,7 @@ struct c2_dev {
302 unsigned long pa; /* PA device memory */ 302 unsigned long pa; /* PA device memory */
303 void **qptr_array; 303 void **qptr_array;
304 304
305 kmem_cache_t *host_msg_cache; 305 struct kmem_cache *host_msg_cache;
306 306
307 struct list_head cca_link; /* adapter list */ 307 struct list_head cca_link; /* adapter list */
308 struct list_head eh_wakeup_list; /* event wakeup list */ 308 struct list_head eh_wakeup_list; /* event wakeup list */
diff --git a/drivers/infiniband/hw/amso1100/c2_provider.c b/drivers/infiniband/hw/amso1100/c2_provider.c
index da98d9f71429..fef972752912 100644
--- a/drivers/infiniband/hw/amso1100/c2_provider.c
+++ b/drivers/infiniband/hw/amso1100/c2_provider.c
@@ -757,20 +757,17 @@ static struct net_device *c2_pseudo_netdev_init(struct c2_dev *c2dev)
757 757
758int c2_register_device(struct c2_dev *dev) 758int c2_register_device(struct c2_dev *dev)
759{ 759{
760 int ret; 760 int ret = -ENOMEM;
761 int i; 761 int i;
762 762
763 /* Register pseudo network device */ 763 /* Register pseudo network device */
764 dev->pseudo_netdev = c2_pseudo_netdev_init(dev); 764 dev->pseudo_netdev = c2_pseudo_netdev_init(dev);
765 if (dev->pseudo_netdev) { 765 if (!dev->pseudo_netdev)
766 ret = register_netdev(dev->pseudo_netdev); 766 goto out3;
767 if (ret) { 767
768 printk(KERN_ERR PFX 768 ret = register_netdev(dev->pseudo_netdev);
769 "Unable to register netdev, ret = %d\n", ret); 769 if (ret)
770 free_netdev(dev->pseudo_netdev); 770 goto out2;
771 return ret;
772 }
773 }
774 771
775 pr_debug("%s:%u\n", __FUNCTION__, __LINE__); 772 pr_debug("%s:%u\n", __FUNCTION__, __LINE__);
776 strlcpy(dev->ibdev.name, "amso%d", IB_DEVICE_NAME_MAX); 773 strlcpy(dev->ibdev.name, "amso%d", IB_DEVICE_NAME_MAX);
@@ -848,21 +845,25 @@ int c2_register_device(struct c2_dev *dev)
848 845
849 ret = ib_register_device(&dev->ibdev); 846 ret = ib_register_device(&dev->ibdev);
850 if (ret) 847 if (ret)
851 return ret; 848 goto out1;
852 849
853 for (i = 0; i < ARRAY_SIZE(c2_class_attributes); ++i) { 850 for (i = 0; i < ARRAY_SIZE(c2_class_attributes); ++i) {
854 ret = class_device_create_file(&dev->ibdev.class_dev, 851 ret = class_device_create_file(&dev->ibdev.class_dev,
855 c2_class_attributes[i]); 852 c2_class_attributes[i]);
856 if (ret) { 853 if (ret)
857 unregister_netdev(dev->pseudo_netdev); 854 goto out0;
858 free_netdev(dev->pseudo_netdev);
859 ib_unregister_device(&dev->ibdev);
860 return ret;
861 }
862 } 855 }
856 goto out3;
863 857
864 pr_debug("%s:%u\n", __FUNCTION__, __LINE__); 858out0:
865 return 0; 859 ib_unregister_device(&dev->ibdev);
860out1:
861 unregister_netdev(dev->pseudo_netdev);
862out2:
863 free_netdev(dev->pseudo_netdev);
864out3:
865 pr_debug("%s:%u ret=%d\n", __FUNCTION__, __LINE__, ret);
866 return ret;
866} 867}
867 868
868void c2_unregister_device(struct c2_dev *dev) 869void c2_unregister_device(struct c2_dev *dev)
diff --git a/drivers/infiniband/hw/amso1100/c2_qp.c b/drivers/infiniband/hw/amso1100/c2_qp.c
index 5bcf697aa335..179d005ed4a5 100644
--- a/drivers/infiniband/hw/amso1100/c2_qp.c
+++ b/drivers/infiniband/hw/amso1100/c2_qp.c
@@ -564,6 +564,32 @@ int c2_alloc_qp(struct c2_dev *c2dev,
564 return err; 564 return err;
565} 565}
566 566
567static inline void c2_lock_cqs(struct c2_cq *send_cq, struct c2_cq *recv_cq)
568{
569 if (send_cq == recv_cq)
570 spin_lock_irq(&send_cq->lock);
571 else if (send_cq > recv_cq) {
572 spin_lock_irq(&send_cq->lock);
573 spin_lock_nested(&recv_cq->lock, SINGLE_DEPTH_NESTING);
574 } else {
575 spin_lock_irq(&recv_cq->lock);
576 spin_lock_nested(&send_cq->lock, SINGLE_DEPTH_NESTING);
577 }
578}
579
580static inline void c2_unlock_cqs(struct c2_cq *send_cq, struct c2_cq *recv_cq)
581{
582 if (send_cq == recv_cq)
583 spin_unlock_irq(&send_cq->lock);
584 else if (send_cq > recv_cq) {
585 spin_unlock(&recv_cq->lock);
586 spin_unlock_irq(&send_cq->lock);
587 } else {
588 spin_unlock(&send_cq->lock);
589 spin_unlock_irq(&recv_cq->lock);
590 }
591}
592
567void c2_free_qp(struct c2_dev *c2dev, struct c2_qp *qp) 593void c2_free_qp(struct c2_dev *c2dev, struct c2_qp *qp)
568{ 594{
569 struct c2_cq *send_cq; 595 struct c2_cq *send_cq;
@@ -576,15 +602,9 @@ void c2_free_qp(struct c2_dev *c2dev, struct c2_qp *qp)
576 * Lock CQs here, so that CQ polling code can do QP lookup 602 * Lock CQs here, so that CQ polling code can do QP lookup
577 * without taking a lock. 603 * without taking a lock.
578 */ 604 */
579 spin_lock_irq(&send_cq->lock); 605 c2_lock_cqs(send_cq, recv_cq);
580 if (send_cq != recv_cq)
581 spin_lock(&recv_cq->lock);
582
583 c2_free_qpn(c2dev, qp->qpn); 606 c2_free_qpn(c2dev, qp->qpn);
584 607 c2_unlock_cqs(send_cq, recv_cq);
585 if (send_cq != recv_cq)
586 spin_unlock(&recv_cq->lock);
587 spin_unlock_irq(&send_cq->lock);
588 608
589 /* 609 /*
590 * Destory qp in the rnic... 610 * Destory qp in the rnic...
diff --git a/drivers/infiniband/hw/amso1100/c2_rnic.c b/drivers/infiniband/hw/amso1100/c2_rnic.c
index 21d9612a56cc..1687c511cb2f 100644
--- a/drivers/infiniband/hw/amso1100/c2_rnic.c
+++ b/drivers/infiniband/hw/amso1100/c2_rnic.c
@@ -157,8 +157,8 @@ static int c2_rnic_query(struct c2_dev *c2dev, struct ib_device_attr *props)
157 157
158 props->fw_ver = 158 props->fw_ver =
159 ((u64)be32_to_cpu(reply->fw_ver_major) << 32) | 159 ((u64)be32_to_cpu(reply->fw_ver_major) << 32) |
160 ((be32_to_cpu(reply->fw_ver_minor) && 0xFFFF) << 16) | 160 ((be32_to_cpu(reply->fw_ver_minor) & 0xFFFF) << 16) |
161 (be32_to_cpu(reply->fw_ver_patch) && 0xFFFF); 161 (be32_to_cpu(reply->fw_ver_patch) & 0xFFFF);
162 memcpy(&props->sys_image_guid, c2dev->netdev->dev_addr, 6); 162 memcpy(&props->sys_image_guid, c2dev->netdev->dev_addr, 6);
163 props->max_mr_size = 0xFFFFFFFF; 163 props->max_mr_size = 0xFFFFFFFF;
164 props->page_size_cap = ~(C2_MIN_PAGESIZE-1); 164 props->page_size_cap = ~(C2_MIN_PAGESIZE-1);
@@ -441,7 +441,7 @@ static int c2_rnic_close(struct c2_dev *c2dev)
441 * involves initalizing the various limits and resouce pools that 441 * involves initalizing the various limits and resouce pools that
442 * comprise the RNIC instance. 442 * comprise the RNIC instance.
443 */ 443 */
444int c2_rnic_init(struct c2_dev *c2dev) 444int __devinit c2_rnic_init(struct c2_dev *c2dev)
445{ 445{
446 int err; 446 int err;
447 u32 qsize, msgsize; 447 u32 qsize, msgsize;
@@ -611,7 +611,7 @@ int c2_rnic_init(struct c2_dev *c2dev)
611/* 611/*
612 * Called by c2_remove to cleanup the RNIC resources. 612 * Called by c2_remove to cleanup the RNIC resources.
613 */ 613 */
614void c2_rnic_term(struct c2_dev *c2dev) 614void __devexit c2_rnic_term(struct c2_dev *c2dev)
615{ 615{
616 616
617 /* Close the open adapter instance */ 617 /* Close the open adapter instance */
diff --git a/drivers/infiniband/hw/amso1100/c2_vq.c b/drivers/infiniband/hw/amso1100/c2_vq.c
index 40caeb5f41b4..36620a22413c 100644
--- a/drivers/infiniband/hw/amso1100/c2_vq.c
+++ b/drivers/infiniband/hw/amso1100/c2_vq.c
@@ -164,7 +164,7 @@ void vq_req_put(struct c2_dev *c2dev, struct c2_vq_req *r)
164 */ 164 */
165void *vq_repbuf_alloc(struct c2_dev *c2dev) 165void *vq_repbuf_alloc(struct c2_dev *c2dev)
166{ 166{
167 return kmem_cache_alloc(c2dev->host_msg_cache, SLAB_ATOMIC); 167 return kmem_cache_alloc(c2dev->host_msg_cache, GFP_ATOMIC);
168} 168}
169 169
170/* 170/*
diff --git a/drivers/infiniband/hw/ehca/Kconfig b/drivers/infiniband/hw/ehca/Kconfig
index 922389b64394..727b10d89686 100644
--- a/drivers/infiniband/hw/ehca/Kconfig
+++ b/drivers/infiniband/hw/ehca/Kconfig
@@ -10,6 +10,7 @@ config INFINIBAND_EHCA
10config INFINIBAND_EHCA_SCALING 10config INFINIBAND_EHCA_SCALING
11 bool "Scaling support (EXPERIMENTAL)" 11 bool "Scaling support (EXPERIMENTAL)"
12 depends on IBMEBUS && INFINIBAND_EHCA && HOTPLUG_CPU && EXPERIMENTAL 12 depends on IBMEBUS && INFINIBAND_EHCA && HOTPLUG_CPU && EXPERIMENTAL
13 default y
13 ---help--- 14 ---help---
14 eHCA scaling support schedules the CQ callbacks to different CPUs. 15 eHCA scaling support schedules the CQ callbacks to different CPUs.
15 16
diff --git a/drivers/infiniband/hw/ehca/ehca_av.c b/drivers/infiniband/hw/ehca/ehca_av.c
index 3bac197f9014..0d6e2c4bb245 100644
--- a/drivers/infiniband/hw/ehca/ehca_av.c
+++ b/drivers/infiniband/hw/ehca/ehca_av.c
@@ -57,7 +57,7 @@ struct ib_ah *ehca_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr)
57 struct ehca_shca *shca = container_of(pd->device, struct ehca_shca, 57 struct ehca_shca *shca = container_of(pd->device, struct ehca_shca,
58 ib_device); 58 ib_device);
59 59
60 av = kmem_cache_alloc(av_cache, SLAB_KERNEL); 60 av = kmem_cache_alloc(av_cache, GFP_KERNEL);
61 if (!av) { 61 if (!av) {
62 ehca_err(pd->device, "Out of memory pd=%p ah_attr=%p", 62 ehca_err(pd->device, "Out of memory pd=%p ah_attr=%p",
63 pd, ah_attr); 63 pd, ah_attr);
@@ -118,8 +118,7 @@ struct ib_ah *ehca_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr)
118 } 118 }
119 memcpy(&av->av.grh.word_1, &gid, sizeof(gid)); 119 memcpy(&av->av.grh.word_1, &gid, sizeof(gid));
120 } 120 }
121 /* for the time being we use a hard coded PMTU of 2048 Bytes */ 121 av->av.pmtu = EHCA_MAX_MTU;
122 av->av.pmtu = 4;
123 122
124 /* dgid comes in grh.word_3 */ 123 /* dgid comes in grh.word_3 */
125 memcpy(&av->av.grh.word_3, &ah_attr->grh.dgid, 124 memcpy(&av->av.grh.word_3, &ah_attr->grh.dgid,
@@ -193,7 +192,7 @@ int ehca_modify_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr)
193 memcpy(&new_ehca_av.grh.word_1, &gid, sizeof(gid)); 192 memcpy(&new_ehca_av.grh.word_1, &gid, sizeof(gid));
194 } 193 }
195 194
196 new_ehca_av.pmtu = 4; /* see also comment in create_ah() */ 195 new_ehca_av.pmtu = EHCA_MAX_MTU;
197 196
198 memcpy(&new_ehca_av.grh.word_3, &ah_attr->grh.dgid, 197 memcpy(&new_ehca_av.grh.word_3, &ah_attr->grh.dgid,
199 sizeof(ah_attr->grh.dgid)); 198 sizeof(ah_attr->grh.dgid));
diff --git a/drivers/infiniband/hw/ehca/ehca_cq.c b/drivers/infiniband/hw/ehca/ehca_cq.c
index 458fe19648a1..93995b658d94 100644
--- a/drivers/infiniband/hw/ehca/ehca_cq.c
+++ b/drivers/infiniband/hw/ehca/ehca_cq.c
@@ -134,7 +134,7 @@ struct ib_cq *ehca_create_cq(struct ib_device *device, int cqe,
134 if (cqe >= 0xFFFFFFFF - 64 - additional_cqe) 134 if (cqe >= 0xFFFFFFFF - 64 - additional_cqe)
135 return ERR_PTR(-EINVAL); 135 return ERR_PTR(-EINVAL);
136 136
137 my_cq = kmem_cache_alloc(cq_cache, SLAB_KERNEL); 137 my_cq = kmem_cache_alloc(cq_cache, GFP_KERNEL);
138 if (!my_cq) { 138 if (!my_cq) {
139 ehca_err(device, "Out of memory for ehca_cq struct device=%p", 139 ehca_err(device, "Out of memory for ehca_cq struct device=%p",
140 device); 140 device);
diff --git a/drivers/infiniband/hw/ehca/ehca_hca.c b/drivers/infiniband/hw/ehca/ehca_hca.c
index 5eae6ac48425..e1b618c5f685 100644
--- a/drivers/infiniband/hw/ehca/ehca_hca.c
+++ b/drivers/infiniband/hw/ehca/ehca_hca.c
@@ -40,6 +40,7 @@
40 */ 40 */
41 41
42#include "ehca_tools.h" 42#include "ehca_tools.h"
43#include "ehca_iverbs.h"
43#include "hcp_if.h" 44#include "hcp_if.h"
44 45
45int ehca_query_device(struct ib_device *ibdev, struct ib_device_attr *props) 46int ehca_query_device(struct ib_device *ibdev, struct ib_device_attr *props)
@@ -49,7 +50,7 @@ int ehca_query_device(struct ib_device *ibdev, struct ib_device_attr *props)
49 ib_device); 50 ib_device);
50 struct hipz_query_hca *rblock; 51 struct hipz_query_hca *rblock;
51 52
52 rblock = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 53 rblock = ehca_alloc_fw_ctrlblock();
53 if (!rblock) { 54 if (!rblock) {
54 ehca_err(&shca->ib_device, "Can't allocate rblock memory."); 55 ehca_err(&shca->ib_device, "Can't allocate rblock memory.");
55 return -ENOMEM; 56 return -ENOMEM;
@@ -96,7 +97,7 @@ int ehca_query_device(struct ib_device *ibdev, struct ib_device_attr *props)
96 = min_t(int, rblock->max_total_mcast_qp_attach, INT_MAX); 97 = min_t(int, rblock->max_total_mcast_qp_attach, INT_MAX);
97 98
98query_device1: 99query_device1:
99 kfree(rblock); 100 ehca_free_fw_ctrlblock(rblock);
100 101
101 return ret; 102 return ret;
102} 103}
@@ -109,7 +110,7 @@ int ehca_query_port(struct ib_device *ibdev,
109 ib_device); 110 ib_device);
110 struct hipz_query_port *rblock; 111 struct hipz_query_port *rblock;
111 112
112 rblock = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 113 rblock = ehca_alloc_fw_ctrlblock();
113 if (!rblock) { 114 if (!rblock) {
114 ehca_err(&shca->ib_device, "Can't allocate rblock memory."); 115 ehca_err(&shca->ib_device, "Can't allocate rblock memory.");
115 return -ENOMEM; 116 return -ENOMEM;
@@ -162,7 +163,7 @@ int ehca_query_port(struct ib_device *ibdev,
162 props->active_speed = 0x1; 163 props->active_speed = 0x1;
163 164
164query_port1: 165query_port1:
165 kfree(rblock); 166 ehca_free_fw_ctrlblock(rblock);
166 167
167 return ret; 168 return ret;
168} 169}
@@ -178,7 +179,7 @@ int ehca_query_pkey(struct ib_device *ibdev, u8 port, u16 index, u16 *pkey)
178 return -EINVAL; 179 return -EINVAL;
179 } 180 }
180 181
181 rblock = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 182 rblock = ehca_alloc_fw_ctrlblock();
182 if (!rblock) { 183 if (!rblock) {
183 ehca_err(&shca->ib_device, "Can't allocate rblock memory."); 184 ehca_err(&shca->ib_device, "Can't allocate rblock memory.");
184 return -ENOMEM; 185 return -ENOMEM;
@@ -193,7 +194,7 @@ int ehca_query_pkey(struct ib_device *ibdev, u8 port, u16 index, u16 *pkey)
193 memcpy(pkey, &rblock->pkey_entries + index, sizeof(u16)); 194 memcpy(pkey, &rblock->pkey_entries + index, sizeof(u16));
194 195
195query_pkey1: 196query_pkey1:
196 kfree(rblock); 197 ehca_free_fw_ctrlblock(rblock);
197 198
198 return ret; 199 return ret;
199} 200}
@@ -211,7 +212,7 @@ int ehca_query_gid(struct ib_device *ibdev, u8 port,
211 return -EINVAL; 212 return -EINVAL;
212 } 213 }
213 214
214 rblock = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 215 rblock = ehca_alloc_fw_ctrlblock();
215 if (!rblock) { 216 if (!rblock) {
216 ehca_err(&shca->ib_device, "Can't allocate rblock memory."); 217 ehca_err(&shca->ib_device, "Can't allocate rblock memory.");
217 return -ENOMEM; 218 return -ENOMEM;
@@ -227,7 +228,7 @@ int ehca_query_gid(struct ib_device *ibdev, u8 port,
227 memcpy(&gid->raw[8], &rblock->guid_entries[index], sizeof(u64)); 228 memcpy(&gid->raw[8], &rblock->guid_entries[index], sizeof(u64));
228 229
229query_gid1: 230query_gid1:
230 kfree(rblock); 231 ehca_free_fw_ctrlblock(rblock);
231 232
232 return ret; 233 return ret;
233} 234}
diff --git a/drivers/infiniband/hw/ehca/ehca_irq.c b/drivers/infiniband/hw/ehca/ehca_irq.c
index 048cc443d1e7..c3ea746e9045 100644
--- a/drivers/infiniband/hw/ehca/ehca_irq.c
+++ b/drivers/infiniband/hw/ehca/ehca_irq.c
@@ -45,6 +45,7 @@
45#include "ehca_tools.h" 45#include "ehca_tools.h"
46#include "hcp_if.h" 46#include "hcp_if.h"
47#include "hipz_fns.h" 47#include "hipz_fns.h"
48#include "ipz_pt_fn.h"
48 49
49#define EQE_COMPLETION_EVENT EHCA_BMASK_IBM(1,1) 50#define EQE_COMPLETION_EVENT EHCA_BMASK_IBM(1,1)
50#define EQE_CQ_QP_NUMBER EHCA_BMASK_IBM(8,31) 51#define EQE_CQ_QP_NUMBER EHCA_BMASK_IBM(8,31)
@@ -137,38 +138,36 @@ int ehca_error_data(struct ehca_shca *shca, void *data,
137 u64 *rblock; 138 u64 *rblock;
138 unsigned long block_count; 139 unsigned long block_count;
139 140
140 rblock = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 141 rblock = ehca_alloc_fw_ctrlblock();
141 if (!rblock) { 142 if (!rblock) {
142 ehca_err(&shca->ib_device, "Cannot allocate rblock memory."); 143 ehca_err(&shca->ib_device, "Cannot allocate rblock memory.");
143 ret = -ENOMEM; 144 ret = -ENOMEM;
144 goto error_data1; 145 goto error_data1;
145 } 146 }
146 147
148 /* rblock must be 4K aligned and should be 4K large */
147 ret = hipz_h_error_data(shca->ipz_hca_handle, 149 ret = hipz_h_error_data(shca->ipz_hca_handle,
148 resource, 150 resource,
149 rblock, 151 rblock,
150 &block_count); 152 &block_count);
151 153
152 if (ret == H_R_STATE) { 154 if (ret == H_R_STATE)
153 ehca_err(&shca->ib_device, 155 ehca_err(&shca->ib_device,
154 "No error data is available: %lx.", resource); 156 "No error data is available: %lx.", resource);
155 }
156 else if (ret == H_SUCCESS) { 157 else if (ret == H_SUCCESS) {
157 int length; 158 int length;
158 159
159 length = EHCA_BMASK_GET(ERROR_DATA_LENGTH, rblock[0]); 160 length = EHCA_BMASK_GET(ERROR_DATA_LENGTH, rblock[0]);
160 161
161 if (length > PAGE_SIZE) 162 if (length > EHCA_PAGESIZE)
162 length = PAGE_SIZE; 163 length = EHCA_PAGESIZE;
163 164
164 print_error_data(shca, data, rblock, length); 165 print_error_data(shca, data, rblock, length);
165 } 166 } else
166 else {
167 ehca_err(&shca->ib_device, 167 ehca_err(&shca->ib_device,
168 "Error data could not be fetched: %lx", resource); 168 "Error data could not be fetched: %lx", resource);
169 }
170 169
171 kfree(rblock); 170 ehca_free_fw_ctrlblock(rblock);
172 171
173error_data1: 172error_data1:
174 return ret; 173 return ret;
diff --git a/drivers/infiniband/hw/ehca/ehca_iverbs.h b/drivers/infiniband/hw/ehca/ehca_iverbs.h
index 319c39d47f3a..3720e3032cce 100644
--- a/drivers/infiniband/hw/ehca/ehca_iverbs.h
+++ b/drivers/infiniband/hw/ehca/ehca_iverbs.h
@@ -179,4 +179,12 @@ int ehca_mmap_register(u64 physical,void **mapped,
179 179
180int ehca_munmap(unsigned long addr, size_t len); 180int ehca_munmap(unsigned long addr, size_t len);
181 181
182#ifdef CONFIG_PPC_64K_PAGES
183void *ehca_alloc_fw_ctrlblock(void);
184void ehca_free_fw_ctrlblock(void *ptr);
185#else
186#define ehca_alloc_fw_ctrlblock() ((void *) get_zeroed_page(GFP_KERNEL))
187#define ehca_free_fw_ctrlblock(ptr) free_page((unsigned long)(ptr))
188#endif
189
182#endif 190#endif
diff --git a/drivers/infiniband/hw/ehca/ehca_main.c b/drivers/infiniband/hw/ehca/ehca_main.c
index 024d511c4b58..cc47e4c13a18 100644
--- a/drivers/infiniband/hw/ehca/ehca_main.c
+++ b/drivers/infiniband/hw/ehca/ehca_main.c
@@ -40,6 +40,9 @@
40 * POSSIBILITY OF SUCH DAMAGE. 40 * POSSIBILITY OF SUCH DAMAGE.
41 */ 41 */
42 42
43#ifdef CONFIG_PPC_64K_PAGES
44#include <linux/slab.h>
45#endif
43#include "ehca_classes.h" 46#include "ehca_classes.h"
44#include "ehca_iverbs.h" 47#include "ehca_iverbs.h"
45#include "ehca_mrmw.h" 48#include "ehca_mrmw.h"
@@ -49,7 +52,7 @@
49MODULE_LICENSE("Dual BSD/GPL"); 52MODULE_LICENSE("Dual BSD/GPL");
50MODULE_AUTHOR("Christoph Raisch <raisch@de.ibm.com>"); 53MODULE_AUTHOR("Christoph Raisch <raisch@de.ibm.com>");
51MODULE_DESCRIPTION("IBM eServer HCA InfiniBand Device Driver"); 54MODULE_DESCRIPTION("IBM eServer HCA InfiniBand Device Driver");
52MODULE_VERSION("SVNEHCA_0017"); 55MODULE_VERSION("SVNEHCA_0019");
53 56
54int ehca_open_aqp1 = 0; 57int ehca_open_aqp1 = 0;
55int ehca_debug_level = 0; 58int ehca_debug_level = 0;
@@ -94,11 +97,31 @@ spinlock_t ehca_cq_idr_lock;
94DEFINE_IDR(ehca_qp_idr); 97DEFINE_IDR(ehca_qp_idr);
95DEFINE_IDR(ehca_cq_idr); 98DEFINE_IDR(ehca_cq_idr);
96 99
100
97static struct list_head shca_list; /* list of all registered ehcas */ 101static struct list_head shca_list; /* list of all registered ehcas */
98static spinlock_t shca_list_lock; 102static spinlock_t shca_list_lock;
99 103
100static struct timer_list poll_eqs_timer; 104static struct timer_list poll_eqs_timer;
101 105
106#ifdef CONFIG_PPC_64K_PAGES
107static struct kmem_cache *ctblk_cache = NULL;
108
109void *ehca_alloc_fw_ctrlblock(void)
110{
111 void *ret = kmem_cache_zalloc(ctblk_cache, GFP_KERNEL);
112 if (!ret)
113 ehca_gen_err("Out of memory for ctblk");
114 return ret;
115}
116
117void ehca_free_fw_ctrlblock(void *ptr)
118{
119 if (ptr)
120 kmem_cache_free(ctblk_cache, ptr);
121
122}
123#endif
124
102static int ehca_create_slab_caches(void) 125static int ehca_create_slab_caches(void)
103{ 126{
104 int ret; 127 int ret;
@@ -133,6 +156,17 @@ static int ehca_create_slab_caches(void)
133 goto create_slab_caches5; 156 goto create_slab_caches5;
134 } 157 }
135 158
159#ifdef CONFIG_PPC_64K_PAGES
160 ctblk_cache = kmem_cache_create("ehca_cache_ctblk",
161 EHCA_PAGESIZE, H_CB_ALIGNMENT,
162 SLAB_HWCACHE_ALIGN,
163 NULL, NULL);
164 if (!ctblk_cache) {
165 ehca_gen_err("Cannot create ctblk SLAB cache.");
166 ehca_cleanup_mrmw_cache();
167 goto create_slab_caches5;
168 }
169#endif
136 return 0; 170 return 0;
137 171
138create_slab_caches5: 172create_slab_caches5:
@@ -157,6 +191,10 @@ static void ehca_destroy_slab_caches(void)
157 ehca_cleanup_qp_cache(); 191 ehca_cleanup_qp_cache();
158 ehca_cleanup_cq_cache(); 192 ehca_cleanup_cq_cache();
159 ehca_cleanup_pd_cache(); 193 ehca_cleanup_pd_cache();
194#ifdef CONFIG_PPC_64K_PAGES
195 if (ctblk_cache)
196 kmem_cache_destroy(ctblk_cache);
197#endif
160} 198}
161 199
162#define EHCA_HCAAVER EHCA_BMASK_IBM(32,39) 200#define EHCA_HCAAVER EHCA_BMASK_IBM(32,39)
@@ -168,7 +206,7 @@ int ehca_sense_attributes(struct ehca_shca *shca)
168 u64 h_ret; 206 u64 h_ret;
169 struct hipz_query_hca *rblock; 207 struct hipz_query_hca *rblock;
170 208
171 rblock = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 209 rblock = ehca_alloc_fw_ctrlblock();
172 if (!rblock) { 210 if (!rblock) {
173 ehca_gen_err("Cannot allocate rblock memory."); 211 ehca_gen_err("Cannot allocate rblock memory.");
174 return -ENOMEM; 212 return -ENOMEM;
@@ -211,7 +249,7 @@ int ehca_sense_attributes(struct ehca_shca *shca)
211 shca->sport[1].rate = IB_RATE_30_GBPS; 249 shca->sport[1].rate = IB_RATE_30_GBPS;
212 250
213num_ports1: 251num_ports1:
214 kfree(rblock); 252 ehca_free_fw_ctrlblock(rblock);
215 return ret; 253 return ret;
216} 254}
217 255
@@ -220,7 +258,7 @@ static int init_node_guid(struct ehca_shca *shca)
220 int ret = 0; 258 int ret = 0;
221 struct hipz_query_hca *rblock; 259 struct hipz_query_hca *rblock;
222 260
223 rblock = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 261 rblock = ehca_alloc_fw_ctrlblock();
224 if (!rblock) { 262 if (!rblock) {
225 ehca_err(&shca->ib_device, "Can't allocate rblock memory."); 263 ehca_err(&shca->ib_device, "Can't allocate rblock memory.");
226 return -ENOMEM; 264 return -ENOMEM;
@@ -235,7 +273,7 @@ static int init_node_guid(struct ehca_shca *shca)
235 memcpy(&shca->ib_device.node_guid, &rblock->node_guid, sizeof(u64)); 273 memcpy(&shca->ib_device.node_guid, &rblock->node_guid, sizeof(u64));
236 274
237init_node_guid1: 275init_node_guid1:
238 kfree(rblock); 276 ehca_free_fw_ctrlblock(rblock);
239 return ret; 277 return ret;
240} 278}
241 279
@@ -431,7 +469,7 @@ static ssize_t ehca_show_##name(struct device *dev, \
431 \ 469 \
432 shca = dev->driver_data; \ 470 shca = dev->driver_data; \
433 \ 471 \
434 rblock = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); \ 472 rblock = ehca_alloc_fw_ctrlblock(); \
435 if (!rblock) { \ 473 if (!rblock) { \
436 dev_err(dev, "Can't allocate rblock memory."); \ 474 dev_err(dev, "Can't allocate rblock memory."); \
437 return 0; \ 475 return 0; \
@@ -439,12 +477,12 @@ static ssize_t ehca_show_##name(struct device *dev, \
439 \ 477 \
440 if (hipz_h_query_hca(shca->ipz_hca_handle, rblock) != H_SUCCESS) { \ 478 if (hipz_h_query_hca(shca->ipz_hca_handle, rblock) != H_SUCCESS) { \
441 dev_err(dev, "Can't query device properties"); \ 479 dev_err(dev, "Can't query device properties"); \
442 kfree(rblock); \ 480 ehca_free_fw_ctrlblock(rblock); \
443 return 0; \ 481 return 0; \
444 } \ 482 } \
445 \ 483 \
446 data = rblock->name; \ 484 data = rblock->name; \
447 kfree(rblock); \ 485 ehca_free_fw_ctrlblock(rblock); \
448 \ 486 \
449 if ((strcmp(#name, "num_ports") == 0) && (ehca_nr_ports == 1)) \ 487 if ((strcmp(#name, "num_ports") == 0) && (ehca_nr_ports == 1)) \
450 return snprintf(buf, 256, "1\n"); \ 488 return snprintf(buf, 256, "1\n"); \
@@ -752,7 +790,7 @@ int __init ehca_module_init(void)
752 int ret; 790 int ret;
753 791
754 printk(KERN_INFO "eHCA Infiniband Device Driver " 792 printk(KERN_INFO "eHCA Infiniband Device Driver "
755 "(Rel.: SVNEHCA_0017)\n"); 793 "(Rel.: SVNEHCA_0019)\n");
756 idr_init(&ehca_qp_idr); 794 idr_init(&ehca_qp_idr);
757 idr_init(&ehca_cq_idr); 795 idr_init(&ehca_cq_idr);
758 spin_lock_init(&ehca_qp_idr_lock); 796 spin_lock_init(&ehca_qp_idr_lock);
diff --git a/drivers/infiniband/hw/ehca/ehca_mrmw.c b/drivers/infiniband/hw/ehca/ehca_mrmw.c
index 5ca65441e1da..0a5e2214cc5f 100644
--- a/drivers/infiniband/hw/ehca/ehca_mrmw.c
+++ b/drivers/infiniband/hw/ehca/ehca_mrmw.c
@@ -53,7 +53,7 @@ static struct ehca_mr *ehca_mr_new(void)
53{ 53{
54 struct ehca_mr *me; 54 struct ehca_mr *me;
55 55
56 me = kmem_cache_alloc(mr_cache, SLAB_KERNEL); 56 me = kmem_cache_alloc(mr_cache, GFP_KERNEL);
57 if (me) { 57 if (me) {
58 memset(me, 0, sizeof(struct ehca_mr)); 58 memset(me, 0, sizeof(struct ehca_mr));
59 spin_lock_init(&me->mrlock); 59 spin_lock_init(&me->mrlock);
@@ -72,7 +72,7 @@ static struct ehca_mw *ehca_mw_new(void)
72{ 72{
73 struct ehca_mw *me; 73 struct ehca_mw *me;
74 74
75 me = kmem_cache_alloc(mw_cache, SLAB_KERNEL); 75 me = kmem_cache_alloc(mw_cache, GFP_KERNEL);
76 if (me) { 76 if (me) {
77 memset(me, 0, sizeof(struct ehca_mw)); 77 memset(me, 0, sizeof(struct ehca_mw));
78 spin_lock_init(&me->mwlock); 78 spin_lock_init(&me->mwlock);
@@ -1013,7 +1013,7 @@ int ehca_reg_mr_rpages(struct ehca_shca *shca,
1013 u32 i; 1013 u32 i;
1014 u64 *kpage; 1014 u64 *kpage;
1015 1015
1016 kpage = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 1016 kpage = ehca_alloc_fw_ctrlblock();
1017 if (!kpage) { 1017 if (!kpage) {
1018 ehca_err(&shca->ib_device, "kpage alloc failed"); 1018 ehca_err(&shca->ib_device, "kpage alloc failed");
1019 ret = -ENOMEM; 1019 ret = -ENOMEM;
@@ -1092,7 +1092,7 @@ int ehca_reg_mr_rpages(struct ehca_shca *shca,
1092 1092
1093 1093
1094ehca_reg_mr_rpages_exit1: 1094ehca_reg_mr_rpages_exit1:
1095 kfree(kpage); 1095 ehca_free_fw_ctrlblock(kpage);
1096ehca_reg_mr_rpages_exit0: 1096ehca_reg_mr_rpages_exit0:
1097 if (ret) 1097 if (ret)
1098 ehca_err(&shca->ib_device, "ret=%x shca=%p e_mr=%p pginfo=%p " 1098 ehca_err(&shca->ib_device, "ret=%x shca=%p e_mr=%p pginfo=%p "
@@ -1124,7 +1124,7 @@ inline int ehca_rereg_mr_rereg1(struct ehca_shca *shca,
1124 ehca_mrmw_map_acl(acl, &hipz_acl); 1124 ehca_mrmw_map_acl(acl, &hipz_acl);
1125 ehca_mrmw_set_pgsize_hipz_acl(&hipz_acl); 1125 ehca_mrmw_set_pgsize_hipz_acl(&hipz_acl);
1126 1126
1127 kpage = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 1127 kpage = ehca_alloc_fw_ctrlblock();
1128 if (!kpage) { 1128 if (!kpage) {
1129 ehca_err(&shca->ib_device, "kpage alloc failed"); 1129 ehca_err(&shca->ib_device, "kpage alloc failed");
1130 ret = -ENOMEM; 1130 ret = -ENOMEM;
@@ -1181,7 +1181,7 @@ inline int ehca_rereg_mr_rereg1(struct ehca_shca *shca,
1181 } 1181 }
1182 1182
1183ehca_rereg_mr_rereg1_exit1: 1183ehca_rereg_mr_rereg1_exit1:
1184 kfree(kpage); 1184 ehca_free_fw_ctrlblock(kpage);
1185ehca_rereg_mr_rereg1_exit0: 1185ehca_rereg_mr_rereg1_exit0:
1186 if ( ret && (ret != -EAGAIN) ) 1186 if ( ret && (ret != -EAGAIN) )
1187 ehca_err(&shca->ib_device, "ret=%x lkey=%x rkey=%x " 1187 ehca_err(&shca->ib_device, "ret=%x lkey=%x rkey=%x "
diff --git a/drivers/infiniband/hw/ehca/ehca_pd.c b/drivers/infiniband/hw/ehca/ehca_pd.c
index 2c3cdc6f7b39..d5345e5b3cd6 100644
--- a/drivers/infiniband/hw/ehca/ehca_pd.c
+++ b/drivers/infiniband/hw/ehca/ehca_pd.c
@@ -50,7 +50,7 @@ struct ib_pd *ehca_alloc_pd(struct ib_device *device,
50{ 50{
51 struct ehca_pd *pd; 51 struct ehca_pd *pd;
52 52
53 pd = kmem_cache_alloc(pd_cache, SLAB_KERNEL); 53 pd = kmem_cache_alloc(pd_cache, GFP_KERNEL);
54 if (!pd) { 54 if (!pd) {
55 ehca_err(device, "device=%p context=%p out of memory", 55 ehca_err(device, "device=%p context=%p out of memory",
56 device, context); 56 device, context);
diff --git a/drivers/infiniband/hw/ehca/ehca_qp.c b/drivers/infiniband/hw/ehca/ehca_qp.c
index 4394123cdbd7..c6c9cef203e3 100644
--- a/drivers/infiniband/hw/ehca/ehca_qp.c
+++ b/drivers/infiniband/hw/ehca/ehca_qp.c
@@ -450,7 +450,7 @@ struct ib_qp *ehca_create_qp(struct ib_pd *pd,
450 if (pd->uobject && udata) 450 if (pd->uobject && udata)
451 context = pd->uobject->context; 451 context = pd->uobject->context;
452 452
453 my_qp = kmem_cache_alloc(qp_cache, SLAB_KERNEL); 453 my_qp = kmem_cache_alloc(qp_cache, GFP_KERNEL);
454 if (!my_qp) { 454 if (!my_qp) {
455 ehca_err(pd->device, "pd=%p not enough memory to alloc qp", pd); 455 ehca_err(pd->device, "pd=%p not enough memory to alloc qp", pd);
456 return ERR_PTR(-ENOMEM); 456 return ERR_PTR(-ENOMEM);
@@ -732,8 +732,7 @@ static int prepare_sqe_rts(struct ehca_qp *my_qp, struct ehca_shca *shca,
732 u64 h_ret; 732 u64 h_ret;
733 struct ipz_queue *squeue; 733 struct ipz_queue *squeue;
734 void *bad_send_wqe_p, *bad_send_wqe_v; 734 void *bad_send_wqe_p, *bad_send_wqe_v;
735 void *squeue_start_p, *squeue_end_p; 735 u64 q_ofs;
736 void *squeue_start_v, *squeue_end_v;
737 struct ehca_wqe *wqe; 736 struct ehca_wqe *wqe;
738 int qp_num = my_qp->ib_qp.qp_num; 737 int qp_num = my_qp->ib_qp.qp_num;
739 738
@@ -755,26 +754,23 @@ static int prepare_sqe_rts(struct ehca_qp *my_qp, struct ehca_shca *shca,
755 if (ehca_debug_level) 754 if (ehca_debug_level)
756 ehca_dmp(bad_send_wqe_v, 32, "qp_num=%x bad_wqe", qp_num); 755 ehca_dmp(bad_send_wqe_v, 32, "qp_num=%x bad_wqe", qp_num);
757 squeue = &my_qp->ipz_squeue; 756 squeue = &my_qp->ipz_squeue;
758 squeue_start_p = (void*)virt_to_abs(ipz_qeit_calc(squeue, 0L)); 757 if (ipz_queue_abs_to_offset(squeue, (u64)bad_send_wqe_p, &q_ofs)) {
759 squeue_end_p = squeue_start_p+squeue->queue_length; 758 ehca_err(&shca->ib_device, "failed to get wqe offset qp_num=%x"
760 squeue_start_v = abs_to_virt((u64)squeue_start_p); 759 " bad_send_wqe_p=%p", qp_num, bad_send_wqe_p);
761 squeue_end_v = abs_to_virt((u64)squeue_end_p); 760 return -EFAULT;
762 ehca_dbg(&shca->ib_device, "qp_num=%x squeue_start_v=%p squeue_end_v=%p", 761 }
763 qp_num, squeue_start_v, squeue_end_v);
764 762
765 /* loop sets wqe's purge bit */ 763 /* loop sets wqe's purge bit */
766 wqe = (struct ehca_wqe*)bad_send_wqe_v; 764 wqe = (struct ehca_wqe*)ipz_qeit_calc(squeue, q_ofs);
767 *bad_wqe_cnt = 0; 765 *bad_wqe_cnt = 0;
768 while (wqe->optype != 0xff && wqe->wqef != 0xff) { 766 while (wqe->optype != 0xff && wqe->wqef != 0xff) {
769 if (ehca_debug_level) 767 if (ehca_debug_level)
770 ehca_dmp(wqe, 32, "qp_num=%x wqe", qp_num); 768 ehca_dmp(wqe, 32, "qp_num=%x wqe", qp_num);
771 wqe->nr_of_data_seg = 0; /* suppress data access */ 769 wqe->nr_of_data_seg = 0; /* suppress data access */
772 wqe->wqef = WQEF_PURGE; /* WQE to be purged */ 770 wqe->wqef = WQEF_PURGE; /* WQE to be purged */
773 wqe = (struct ehca_wqe*)((u8*)wqe+squeue->qe_size); 771 q_ofs = ipz_queue_advance_offset(squeue, q_ofs);
772 wqe = (struct ehca_wqe*)ipz_qeit_calc(squeue, q_ofs);
774 *bad_wqe_cnt = (*bad_wqe_cnt)+1; 773 *bad_wqe_cnt = (*bad_wqe_cnt)+1;
775 if ((void*)wqe >= squeue_end_v) {
776 wqe = squeue_start_v;
777 }
778 } 774 }
779 /* 775 /*
780 * bad wqe will be reprocessed and ignored when pol_cq() is called, 776 * bad wqe will be reprocessed and ignored when pol_cq() is called,
@@ -811,8 +807,8 @@ static int internal_modify_qp(struct ib_qp *ibqp,
811 unsigned long spl_flags = 0; 807 unsigned long spl_flags = 0;
812 808
813 /* do query_qp to obtain current attr values */ 809 /* do query_qp to obtain current attr values */
814 mqpcb = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 810 mqpcb = ehca_alloc_fw_ctrlblock();
815 if (mqpcb == NULL) { 811 if (!mqpcb) {
816 ehca_err(ibqp->device, "Could not get zeroed page for mqpcb " 812 ehca_err(ibqp->device, "Could not get zeroed page for mqpcb "
817 "ehca_qp=%p qp_num=%x ", my_qp, ibqp->qp_num); 813 "ehca_qp=%p qp_num=%x ", my_qp, ibqp->qp_num);
818 return -ENOMEM; 814 return -ENOMEM;
@@ -1225,7 +1221,7 @@ modify_qp_exit2:
1225 } 1221 }
1226 1222
1227modify_qp_exit1: 1223modify_qp_exit1:
1228 kfree(mqpcb); 1224 ehca_free_fw_ctrlblock(mqpcb);
1229 1225
1230 return ret; 1226 return ret;
1231} 1227}
@@ -1277,7 +1273,7 @@ int ehca_query_qp(struct ib_qp *qp,
1277 return -EINVAL; 1273 return -EINVAL;
1278 } 1274 }
1279 1275
1280 qpcb = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL ); 1276 qpcb = ehca_alloc_fw_ctrlblock();
1281 if (!qpcb) { 1277 if (!qpcb) {
1282 ehca_err(qp->device,"Out of memory for qpcb " 1278 ehca_err(qp->device,"Out of memory for qpcb "
1283 "ehca_qp=%p qp_num=%x", my_qp, qp->qp_num); 1279 "ehca_qp=%p qp_num=%x", my_qp, qp->qp_num);
@@ -1401,7 +1397,7 @@ int ehca_query_qp(struct ib_qp *qp,
1401 ehca_dmp(qpcb, 4*70, "qp_num=%x", qp->qp_num); 1397 ehca_dmp(qpcb, 4*70, "qp_num=%x", qp->qp_num);
1402 1398
1403query_qp_exit1: 1399query_qp_exit1:
1404 kfree(qpcb); 1400 ehca_free_fw_ctrlblock(qpcb);
1405 1401
1406 return ret; 1402 return ret;
1407} 1403}
diff --git a/drivers/infiniband/hw/ehca/hipz_hw.h b/drivers/infiniband/hw/ehca/hipz_hw.h
index 3fc92b031c50..fad91368dc5a 100644
--- a/drivers/infiniband/hw/ehca/hipz_hw.h
+++ b/drivers/infiniband/hw/ehca/hipz_hw.h
@@ -45,6 +45,8 @@
45 45
46#include "ehca_tools.h" 46#include "ehca_tools.h"
47 47
48#define EHCA_MAX_MTU 4
49
48/* QP Table Entry Memory Map */ 50/* QP Table Entry Memory Map */
49struct hipz_qptemm { 51struct hipz_qptemm {
50 u64 qpx_hcr; 52 u64 qpx_hcr;
diff --git a/drivers/infiniband/hw/ehca/ipz_pt_fn.c b/drivers/infiniband/hw/ehca/ipz_pt_fn.c
index e028ff1588cc..bf7a40088f61 100644
--- a/drivers/infiniband/hw/ehca/ipz_pt_fn.c
+++ b/drivers/infiniband/hw/ehca/ipz_pt_fn.c
@@ -70,6 +70,19 @@ void *ipz_qeit_eq_get_inc(struct ipz_queue *queue)
70 return ret; 70 return ret;
71} 71}
72 72
73int ipz_queue_abs_to_offset(struct ipz_queue *queue, u64 addr, u64 *q_offset)
74{
75 int i;
76 for (i = 0; i < queue->queue_length / queue->pagesize; i++) {
77 u64 page = (u64)virt_to_abs(queue->queue_pages[i]);
78 if (addr >= page && addr < page + queue->pagesize) {
79 *q_offset = addr - page + i * queue->pagesize;
80 return 0;
81 }
82 }
83 return -EINVAL;
84}
85
73int ipz_queue_ctor(struct ipz_queue *queue, 86int ipz_queue_ctor(struct ipz_queue *queue,
74 const u32 nr_of_pages, 87 const u32 nr_of_pages,
75 const u32 pagesize, const u32 qe_size, const u32 nr_of_sg) 88 const u32 pagesize, const u32 qe_size, const u32 nr_of_sg)
diff --git a/drivers/infiniband/hw/ehca/ipz_pt_fn.h b/drivers/infiniband/hw/ehca/ipz_pt_fn.h
index 2f13509d5257..dc3bda2634b7 100644
--- a/drivers/infiniband/hw/ehca/ipz_pt_fn.h
+++ b/drivers/infiniband/hw/ehca/ipz_pt_fn.h
@@ -150,6 +150,21 @@ static inline void *ipz_qeit_reset(struct ipz_queue *queue)
150 return ipz_qeit_get(queue); 150 return ipz_qeit_get(queue);
151} 151}
152 152
153/*
154 * return the q_offset corresponding to an absolute address
155 */
156int ipz_queue_abs_to_offset(struct ipz_queue *queue, u64 addr, u64 *q_offset);
157
158/*
159 * return the next queue offset. don't modify the queue.
160 */
161static inline u64 ipz_queue_advance_offset(struct ipz_queue *queue, u64 offset)
162{
163 offset += queue->qe_size;
164 if (offset >= queue->queue_length) offset = 0;
165 return offset;
166}
167
153/* struct generic page table */ 168/* struct generic page table */
154struct ipz_pt { 169struct ipz_pt {
155 u64 entries[EHCA_PT_ENTRIES]; 170 u64 entries[EHCA_PT_ENTRIES];
diff --git a/drivers/infiniband/hw/ipath/Kconfig b/drivers/infiniband/hw/ipath/Kconfig
index 574a678e7fdd..90c14543677d 100644
--- a/drivers/infiniband/hw/ipath/Kconfig
+++ b/drivers/infiniband/hw/ipath/Kconfig
@@ -1,6 +1,6 @@
1config INFINIBAND_IPATH 1config INFINIBAND_IPATH
2 tristate "QLogic InfiniPath Driver" 2 tristate "QLogic InfiniPath Driver"
3 depends on PCI_MSI && 64BIT && INFINIBAND 3 depends on (PCI_MSI || HT_IRQ) && 64BIT && INFINIBAND && NET
4 ---help--- 4 ---help---
5 This is a driver for QLogic InfiniPath host channel adapters, 5 This is a driver for QLogic InfiniPath host channel adapters,
6 including InfiniBand verbs support. This driver allows these 6 including InfiniBand verbs support. This driver allows these
diff --git a/drivers/infiniband/hw/ipath/Makefile b/drivers/infiniband/hw/ipath/Makefile
index 5e29cb0095e5..7dc10551cf18 100644
--- a/drivers/infiniband/hw/ipath/Makefile
+++ b/drivers/infiniband/hw/ipath/Makefile
@@ -10,8 +10,6 @@ ib_ipath-y := \
10 ipath_eeprom.o \ 10 ipath_eeprom.o \
11 ipath_file_ops.o \ 11 ipath_file_ops.o \
12 ipath_fs.o \ 12 ipath_fs.o \
13 ipath_iba6110.o \
14 ipath_iba6120.o \
15 ipath_init_chip.o \ 13 ipath_init_chip.o \
16 ipath_intr.o \ 14 ipath_intr.o \
17 ipath_keys.o \ 15 ipath_keys.o \
@@ -31,5 +29,8 @@ ib_ipath-y := \
31 ipath_verbs_mcast.o \ 29 ipath_verbs_mcast.o \
32 ipath_verbs.o 30 ipath_verbs.o
33 31
32ib_ipath-$(CONFIG_HT_IRQ) += ipath_iba6110.o
33ib_ipath-$(CONFIG_PCI_MSI) += ipath_iba6120.o
34
34ib_ipath-$(CONFIG_X86_64) += ipath_wc_x86_64.o 35ib_ipath-$(CONFIG_X86_64) += ipath_wc_x86_64.o
35ib_ipath-$(CONFIG_PPC64) += ipath_wc_ppc64.o 36ib_ipath-$(CONFIG_PPC64) += ipath_wc_ppc64.o
diff --git a/drivers/infiniband/hw/ipath/ipath_driver.c b/drivers/infiniband/hw/ipath/ipath_driver.c
index b4ffaa7bcbb7..1aeddb48e355 100644
--- a/drivers/infiniband/hw/ipath/ipath_driver.c
+++ b/drivers/infiniband/hw/ipath/ipath_driver.c
@@ -304,7 +304,7 @@ static int __devinit ipath_init_one(struct pci_dev *pdev,
304 } 304 }
305 addr = pci_resource_start(pdev, 0); 305 addr = pci_resource_start(pdev, 0);
306 len = pci_resource_len(pdev, 0); 306 len = pci_resource_len(pdev, 0);
307 ipath_cdbg(VERBOSE, "regbase (0) %llx len %d irq %x, vend %x/%x " 307 ipath_cdbg(VERBOSE, "regbase (0) %llx len %d pdev->irq %d, vend %x/%x "
308 "driver_data %lx\n", addr, len, pdev->irq, ent->vendor, 308 "driver_data %lx\n", addr, len, pdev->irq, ent->vendor,
309 ent->device, ent->driver_data); 309 ent->device, ent->driver_data);
310 310
@@ -390,12 +390,16 @@ static int __devinit ipath_init_one(struct pci_dev *pdev,
390 390
391 /* setup the chip-specific functions, as early as possible. */ 391 /* setup the chip-specific functions, as early as possible. */
392 switch (ent->device) { 392 switch (ent->device) {
393#ifdef CONFIG_HT_IRQ
393 case PCI_DEVICE_ID_INFINIPATH_HT: 394 case PCI_DEVICE_ID_INFINIPATH_HT:
394 ipath_init_iba6110_funcs(dd); 395 ipath_init_iba6110_funcs(dd);
395 break; 396 break;
397#endif
398#ifdef CONFIG_PCI_MSI
396 case PCI_DEVICE_ID_INFINIPATH_PE800: 399 case PCI_DEVICE_ID_INFINIPATH_PE800:
397 ipath_init_iba6120_funcs(dd); 400 ipath_init_iba6120_funcs(dd);
398 break; 401 break;
402#endif
399 default: 403 default:
400 ipath_dev_err(dd, "Found unknown QLogic deviceid 0x%x, " 404 ipath_dev_err(dd, "Found unknown QLogic deviceid 0x%x, "
401 "failing\n", ent->device); 405 "failing\n", ent->device);
@@ -467,15 +471,15 @@ static int __devinit ipath_init_one(struct pci_dev *pdev,
467 * check 0 irq after we return from chip-specific bus setup, since 471 * check 0 irq after we return from chip-specific bus setup, since
468 * that can affect this due to setup 472 * that can affect this due to setup
469 */ 473 */
470 if (!pdev->irq) 474 if (!dd->ipath_irq)
471 ipath_dev_err(dd, "irq is 0, BIOS error? Interrupts won't " 475 ipath_dev_err(dd, "irq is 0, BIOS error? Interrupts won't "
472 "work\n"); 476 "work\n");
473 else { 477 else {
474 ret = request_irq(pdev->irq, ipath_intr, IRQF_SHARED, 478 ret = request_irq(dd->ipath_irq, ipath_intr, IRQF_SHARED,
475 IPATH_DRV_NAME, dd); 479 IPATH_DRV_NAME, dd);
476 if (ret) { 480 if (ret) {
477 ipath_dev_err(dd, "Couldn't setup irq handler, " 481 ipath_dev_err(dd, "Couldn't setup irq handler, "
478 "irq=%u: %d\n", pdev->irq, ret); 482 "irq=%d: %d\n", dd->ipath_irq, ret);
479 goto bail_iounmap; 483 goto bail_iounmap;
480 } 484 }
481 } 485 }
@@ -637,11 +641,10 @@ static void __devexit ipath_remove_one(struct pci_dev *pdev)
637 * free up port 0 (kernel) rcvhdr, egr bufs, and eventually tid bufs 641 * free up port 0 (kernel) rcvhdr, egr bufs, and eventually tid bufs
638 * for all versions of the driver, if they were allocated 642 * for all versions of the driver, if they were allocated
639 */ 643 */
640 if (pdev->irq) { 644 if (dd->ipath_irq) {
641 ipath_cdbg(VERBOSE, 645 ipath_cdbg(VERBOSE, "unit %u free irq %d\n",
642 "unit %u free_irq of irq %x\n", 646 dd->ipath_unit, dd->ipath_irq);
643 dd->ipath_unit, pdev->irq); 647 dd->ipath_f_free_irq(dd);
644 free_irq(pdev->irq, dd);
645 } else 648 } else
646 ipath_dbg("irq is 0, not doing free_irq " 649 ipath_dbg("irq is 0, not doing free_irq "
647 "for unit %u\n", dd->ipath_unit); 650 "for unit %u\n", dd->ipath_unit);
diff --git a/drivers/infiniband/hw/ipath/ipath_iba6110.c b/drivers/infiniband/hw/ipath/ipath_iba6110.c
index 9e4e8d4c6e20..e57c7a351cb5 100644
--- a/drivers/infiniband/hw/ipath/ipath_iba6110.c
+++ b/drivers/infiniband/hw/ipath/ipath_iba6110.c
@@ -38,6 +38,7 @@
38 38
39#include <linux/pci.h> 39#include <linux/pci.h>
40#include <linux/delay.h> 40#include <linux/delay.h>
41#include <linux/htirq.h>
41 42
42#include "ipath_kernel.h" 43#include "ipath_kernel.h"
43#include "ipath_registers.h" 44#include "ipath_registers.h"
@@ -913,49 +914,40 @@ static void slave_or_pri_blk(struct ipath_devdata *dd, struct pci_dev *pdev,
913 } 914 }
914} 915}
915 916
916static int set_int_handler(struct ipath_devdata *dd, struct pci_dev *pdev, 917static int ipath_ht_intconfig(struct ipath_devdata *dd)
917 int pos)
918{ 918{
919 u32 int_handler_addr_lower; 919 int ret;
920 u32 int_handler_addr_upper;
921 u64 ihandler;
922 u32 intvec;
923 920
924 /* use indirection register to get the intr handler */ 921 if (dd->ipath_intconfig) {
925 pci_write_config_byte(pdev, pos + HT_INTR_REG_INDEX, 0x10); 922 ipath_write_kreg(dd, dd->ipath_kregs->kr_interruptconfig,
926 pci_read_config_dword(pdev, pos + 4, &int_handler_addr_lower); 923 dd->ipath_intconfig); /* interrupt address */
927 pci_write_config_byte(pdev, pos + HT_INTR_REG_INDEX, 0x11); 924 ret = 0;
928 pci_read_config_dword(pdev, pos + 4, &int_handler_addr_upper); 925 } else {
926 ipath_dev_err(dd, "No interrupts enabled, couldn't setup "
927 "interrupt address\n");
928 ret = -EINVAL;
929 }
929 930
930 ihandler = (u64) int_handler_addr_lower | 931 return ret;
931 ((u64) int_handler_addr_upper << 32); 932}
933
934static void ipath_ht_irq_update(struct pci_dev *dev, int irq,
935 struct ht_irq_msg *msg)
936{
937 struct ipath_devdata *dd = pci_get_drvdata(dev);
938 u64 prev_intconfig = dd->ipath_intconfig;
939
940 dd->ipath_intconfig = msg->address_lo;
941 dd->ipath_intconfig |= ((u64) msg->address_hi) << 32;
932 942
933 /* 943 /*
934 * kernels with CONFIG_PCI_MSI set the vector in the irq field of 944 * If the previous value of dd->ipath_intconfig is zero, we're
935 * struct pci_device, so we use that to program the internal 945 * getting configured for the first time, and must not program the
936 * interrupt register (not config space) with that value. The BIOS 946 * intconfig register here (it will be programmed later, when the
937 * must still have done the basic MSI setup. 947 * hardware is ready). Otherwise, we should.
938 */
939 intvec = pdev->irq;
940 /*
941 * clear any vector bits there; normally not set but we'll overload
942 * this for some debug purposes (setting the HTC debug register
943 * value from software, rather than GPIOs), so it might be set on a
944 * driver reload.
945 */ 948 */
946 ihandler &= ~0xff0000; 949 if (prev_intconfig)
947 /* x86 vector goes in intrinfo[23:16] */ 950 ipath_ht_intconfig(dd);
948 ihandler |= intvec << 16;
949 ipath_cdbg(VERBOSE, "ihandler lower %x, upper %x, intvec %x, "
950 "interruptconfig %llx\n", int_handler_addr_lower,
951 int_handler_addr_upper, intvec,
952 (unsigned long long) ihandler);
953
954 /* can't program yet, so save for interrupt setup */
955 dd->ipath_intconfig = ihandler;
956 /* keep going, so we find link control stuff also */
957
958 return ihandler != 0;
959} 951}
960 952
961/** 953/**
@@ -971,12 +963,19 @@ static int set_int_handler(struct ipath_devdata *dd, struct pci_dev *pdev,
971static int ipath_setup_ht_config(struct ipath_devdata *dd, 963static int ipath_setup_ht_config(struct ipath_devdata *dd,
972 struct pci_dev *pdev) 964 struct pci_dev *pdev)
973{ 965{
974 int pos, ret = 0; 966 int pos, ret;
975 int ihandler = 0; 967
968 ret = __ht_create_irq(pdev, 0, ipath_ht_irq_update);
969 if (ret < 0) {
970 ipath_dev_err(dd, "Couldn't create interrupt handler: "
971 "err %d\n", ret);
972 goto bail;
973 }
974 dd->ipath_irq = ret;
975 ret = 0;
976 976
977 /* 977 /*
978 * Read the capability info to find the interrupt info, and also 978 * Handle clearing CRC errors in linkctrl register if necessary. We
979 * handle clearing CRC errors in linkctrl register if necessary. We
980 * do this early, before we ever enable errors or hardware errors, 979 * do this early, before we ever enable errors or hardware errors,
981 * mostly to avoid causing the chip to enter freeze mode. 980 * mostly to avoid causing the chip to enter freeze mode.
982 */ 981 */
@@ -1000,17 +999,9 @@ static int ipath_setup_ht_config(struct ipath_devdata *dd,
1000 } 999 }
1001 if (!(cap_type & 0xE0)) 1000 if (!(cap_type & 0xE0))
1002 slave_or_pri_blk(dd, pdev, pos, cap_type); 1001 slave_or_pri_blk(dd, pdev, pos, cap_type);
1003 else if (cap_type == HT_INTR_DISC_CONFIG)
1004 ihandler = set_int_handler(dd, pdev, pos);
1005 } while ((pos = pci_find_next_capability(pdev, pos, 1002 } while ((pos = pci_find_next_capability(pdev, pos,
1006 PCI_CAP_ID_HT))); 1003 PCI_CAP_ID_HT)));
1007 1004
1008 if (!ihandler) {
1009 ipath_dev_err(dd, "Couldn't find interrupt handler in "
1010 "config space\n");
1011 ret = -ENODEV;
1012 }
1013
1014bail: 1005bail:
1015 return ret; 1006 return ret;
1016} 1007}
@@ -1360,25 +1351,6 @@ static void ipath_ht_quiet_serdes(struct ipath_devdata *dd)
1360 ipath_write_kreg(dd, dd->ipath_kregs->kr_serdesconfig0, val); 1351 ipath_write_kreg(dd, dd->ipath_kregs->kr_serdesconfig0, val);
1361} 1352}
1362 1353
1363static int ipath_ht_intconfig(struct ipath_devdata *dd)
1364{
1365 int ret;
1366
1367 if (!dd->ipath_intconfig) {
1368 ipath_dev_err(dd, "No interrupts enabled, couldn't setup "
1369 "interrupt address\n");
1370 ret = 1;
1371 goto bail;
1372 }
1373
1374 ipath_write_kreg(dd, dd->ipath_kregs->kr_interruptconfig,
1375 dd->ipath_intconfig); /* interrupt address */
1376 ret = 0;
1377
1378bail:
1379 return ret;
1380}
1381
1382/** 1354/**
1383 * ipath_pe_put_tid - write a TID in chip 1355 * ipath_pe_put_tid - write a TID in chip
1384 * @dd: the infinipath device 1356 * @dd: the infinipath device
@@ -1575,6 +1547,14 @@ static int ipath_ht_get_base_info(struct ipath_portdata *pd, void *kbase)
1575 return 0; 1547 return 0;
1576} 1548}
1577 1549
1550static void ipath_ht_free_irq(struct ipath_devdata *dd)
1551{
1552 free_irq(dd->ipath_irq, dd);
1553 ht_destroy_irq(dd->ipath_irq);
1554 dd->ipath_irq = 0;
1555 dd->ipath_intconfig = 0;
1556}
1557
1578/** 1558/**
1579 * ipath_init_iba6110_funcs - set up the chip-specific function pointers 1559 * ipath_init_iba6110_funcs - set up the chip-specific function pointers
1580 * @dd: the infinipath device 1560 * @dd: the infinipath device
@@ -1598,6 +1578,7 @@ void ipath_init_iba6110_funcs(struct ipath_devdata *dd)
1598 dd->ipath_f_cleanup = ipath_setup_ht_cleanup; 1578 dd->ipath_f_cleanup = ipath_setup_ht_cleanup;
1599 dd->ipath_f_setextled = ipath_setup_ht_setextled; 1579 dd->ipath_f_setextled = ipath_setup_ht_setextled;
1600 dd->ipath_f_get_base_info = ipath_ht_get_base_info; 1580 dd->ipath_f_get_base_info = ipath_ht_get_base_info;
1581 dd->ipath_f_free_irq = ipath_ht_free_irq;
1601 1582
1602 /* 1583 /*
1603 * initialize chip-specific variables 1584 * initialize chip-specific variables
diff --git a/drivers/infiniband/hw/ipath/ipath_iba6120.c b/drivers/infiniband/hw/ipath/ipath_iba6120.c
index a72ab9de386a..6af89683f710 100644
--- a/drivers/infiniband/hw/ipath/ipath_iba6120.c
+++ b/drivers/infiniband/hw/ipath/ipath_iba6120.c
@@ -851,6 +851,7 @@ static int ipath_setup_pe_config(struct ipath_devdata *dd,
851 int pos, ret; 851 int pos, ret;
852 852
853 dd->ipath_msi_lo = 0; /* used as a flag during reset processing */ 853 dd->ipath_msi_lo = 0; /* used as a flag during reset processing */
854 dd->ipath_irq = pdev->irq;
854 ret = pci_enable_msi(dd->pcidev); 855 ret = pci_enable_msi(dd->pcidev);
855 if (ret) 856 if (ret)
856 ipath_dev_err(dd, "pci_enable_msi failed: %d, " 857 ipath_dev_err(dd, "pci_enable_msi failed: %d, "
@@ -1323,6 +1324,12 @@ done:
1323 return 0; 1324 return 0;
1324} 1325}
1325 1326
1327static void ipath_pe_free_irq(struct ipath_devdata *dd)
1328{
1329 free_irq(dd->ipath_irq, dd);
1330 dd->ipath_irq = 0;
1331}
1332
1326/** 1333/**
1327 * ipath_init_iba6120_funcs - set up the chip-specific function pointers 1334 * ipath_init_iba6120_funcs - set up the chip-specific function pointers
1328 * @dd: the infinipath device 1335 * @dd: the infinipath device
@@ -1349,6 +1356,7 @@ void ipath_init_iba6120_funcs(struct ipath_devdata *dd)
1349 dd->ipath_f_cleanup = ipath_setup_pe_cleanup; 1356 dd->ipath_f_cleanup = ipath_setup_pe_cleanup;
1350 dd->ipath_f_setextled = ipath_setup_pe_setextled; 1357 dd->ipath_f_setextled = ipath_setup_pe_setextled;
1351 dd->ipath_f_get_base_info = ipath_pe_get_base_info; 1358 dd->ipath_f_get_base_info = ipath_pe_get_base_info;
1359 dd->ipath_f_free_irq = ipath_pe_free_irq;
1352 1360
1353 /* initialize chip-specific variables */ 1361 /* initialize chip-specific variables */
1354 dd->ipath_f_tidtemplate = ipath_pe_tidtemplate; 1362 dd->ipath_f_tidtemplate = ipath_pe_tidtemplate;
diff --git a/drivers/infiniband/hw/ipath/ipath_intr.c b/drivers/infiniband/hw/ipath/ipath_intr.c
index d9079ee12030..5652a550d442 100644
--- a/drivers/infiniband/hw/ipath/ipath_intr.c
+++ b/drivers/infiniband/hw/ipath/ipath_intr.c
@@ -710,14 +710,14 @@ static void ipath_bad_intr(struct ipath_devdata *dd, u32 * unexpectp)
710 * linuxbios development work, and it may happen in 710 * linuxbios development work, and it may happen in
711 * the future again. 711 * the future again.
712 */ 712 */
713 if (dd->pcidev && dd->pcidev->irq) { 713 if (dd->pcidev && dd->ipath_irq) {
714 ipath_dev_err(dd, "Now %u unexpected " 714 ipath_dev_err(dd, "Now %u unexpected "
715 "interrupts, unregistering " 715 "interrupts, unregistering "
716 "interrupt handler\n", 716 "interrupt handler\n",
717 *unexpectp); 717 *unexpectp);
718 ipath_dbg("free_irq of irq %x\n", 718 ipath_dbg("free_irq of irq %d\n",
719 dd->pcidev->irq); 719 dd->ipath_irq);
720 free_irq(dd->pcidev->irq, dd); 720 dd->ipath_f_free_irq(dd);
721 } 721 }
722 } 722 }
723 if (ipath_read_kreg32(dd, dd->ipath_kregs->kr_intmask)) { 723 if (ipath_read_kreg32(dd, dd->ipath_kregs->kr_intmask)) {
@@ -753,7 +753,7 @@ static void ipath_bad_regread(struct ipath_devdata *dd)
753 if (allbits == 2) { 753 if (allbits == 2) {
754 ipath_dev_err(dd, "Still bad interrupt status, " 754 ipath_dev_err(dd, "Still bad interrupt status, "
755 "unregistering interrupt\n"); 755 "unregistering interrupt\n");
756 free_irq(dd->pcidev->irq, dd); 756 dd->ipath_f_free_irq(dd);
757 } else if (allbits > 2) { 757 } else if (allbits > 2) {
758 if ((allbits % 10000) == 0) 758 if ((allbits % 10000) == 0)
759 printk("."); 759 printk(".");
diff --git a/drivers/infiniband/hw/ipath/ipath_kernel.h b/drivers/infiniband/hw/ipath/ipath_kernel.h
index 06d5020a2f60..986b2125b8f5 100644
--- a/drivers/infiniband/hw/ipath/ipath_kernel.h
+++ b/drivers/infiniband/hw/ipath/ipath_kernel.h
@@ -213,6 +213,8 @@ struct ipath_devdata {
213 void (*ipath_f_setextled)(struct ipath_devdata *, u64, u64); 213 void (*ipath_f_setextled)(struct ipath_devdata *, u64, u64);
214 /* fill out chip-specific fields */ 214 /* fill out chip-specific fields */
215 int (*ipath_f_get_base_info)(struct ipath_portdata *, void *); 215 int (*ipath_f_get_base_info)(struct ipath_portdata *, void *);
216 /* free irq */
217 void (*ipath_f_free_irq)(struct ipath_devdata *);
216 struct ipath_ibdev *verbs_dev; 218 struct ipath_ibdev *verbs_dev;
217 struct timer_list verbs_timer; 219 struct timer_list verbs_timer;
218 /* total dwords sent (summed from counter) */ 220 /* total dwords sent (summed from counter) */
@@ -328,6 +330,8 @@ struct ipath_devdata {
328 /* so we can rewrite it after a chip reset */ 330 /* so we can rewrite it after a chip reset */
329 u32 ipath_pcibar1; 331 u32 ipath_pcibar1;
330 332
333 /* interrupt number */
334 int ipath_irq;
331 /* HT/PCI Vendor ID (here for NodeInfo) */ 335 /* HT/PCI Vendor ID (here for NodeInfo) */
332 u16 ipath_vendorid; 336 u16 ipath_vendorid;
333 /* HT/PCI Device ID (here for NodeInfo) */ 337 /* HT/PCI Device ID (here for NodeInfo) */
diff --git a/drivers/infiniband/hw/ipath/ipath_user_pages.c b/drivers/infiniband/hw/ipath/ipath_user_pages.c
index 413754b1d8a2..8536aeb96af8 100644
--- a/drivers/infiniband/hw/ipath/ipath_user_pages.c
+++ b/drivers/infiniband/hw/ipath/ipath_user_pages.c
@@ -214,9 +214,10 @@ struct ipath_user_pages_work {
214 unsigned long num_pages; 214 unsigned long num_pages;
215}; 215};
216 216
217static void user_pages_account(void *ptr) 217static void user_pages_account(struct work_struct *_work)
218{ 218{
219 struct ipath_user_pages_work *work = ptr; 219 struct ipath_user_pages_work *work =
220 container_of(_work, struct ipath_user_pages_work, work);
220 221
221 down_write(&work->mm->mmap_sem); 222 down_write(&work->mm->mmap_sem);
222 work->mm->locked_vm -= work->num_pages; 223 work->mm->locked_vm -= work->num_pages;
@@ -242,7 +243,7 @@ void ipath_release_user_pages_on_close(struct page **p, size_t num_pages)
242 243
243 goto bail; 244 goto bail;
244 245
245 INIT_WORK(&work->work, user_pages_account, work); 246 INIT_WORK(&work->work, user_pages_account);
246 work->mm = mm; 247 work->mm = mm;
247 work->num_pages = num_pages; 248 work->num_pages = num_pages;
248 249
diff --git a/drivers/infiniband/hw/ipath/ipath_verbs.c b/drivers/infiniband/hw/ipath/ipath_verbs.c
index a5456108dbad..acdee33ee1f8 100644
--- a/drivers/infiniband/hw/ipath/ipath_verbs.c
+++ b/drivers/infiniband/hw/ipath/ipath_verbs.c
@@ -1487,7 +1487,7 @@ int ipath_register_ib_device(struct ipath_devdata *dd)
1487 idev->pma_counter_select[1] = IB_PMA_PORT_RCV_DATA; 1487 idev->pma_counter_select[1] = IB_PMA_PORT_RCV_DATA;
1488 idev->pma_counter_select[2] = IB_PMA_PORT_XMIT_PKTS; 1488 idev->pma_counter_select[2] = IB_PMA_PORT_XMIT_PKTS;
1489 idev->pma_counter_select[3] = IB_PMA_PORT_RCV_PKTS; 1489 idev->pma_counter_select[3] = IB_PMA_PORT_RCV_PKTS;
1490 idev->pma_counter_select[5] = IB_PMA_PORT_XMIT_WAIT; 1490 idev->pma_counter_select[4] = IB_PMA_PORT_XMIT_WAIT;
1491 idev->link_width_enabled = 3; /* 1x or 4x */ 1491 idev->link_width_enabled = 3; /* 1x or 4x */
1492 1492
1493 /* Snapshot current HW counters to "clear" them. */ 1493 /* Snapshot current HW counters to "clear" them. */
diff --git a/drivers/infiniband/hw/mthca/mthca_av.c b/drivers/infiniband/hw/mthca/mthca_av.c
index 69599455aca2..27caf3b0648a 100644
--- a/drivers/infiniband/hw/mthca/mthca_av.c
+++ b/drivers/infiniband/hw/mthca/mthca_av.c
@@ -33,7 +33,6 @@
33 * $Id: mthca_av.c 1349 2004-12-16 21:09:43Z roland $ 33 * $Id: mthca_av.c 1349 2004-12-16 21:09:43Z roland $
34 */ 34 */
35 35
36#include <linux/init.h>
37#include <linux/string.h> 36#include <linux/string.h>
38#include <linux/slab.h> 37#include <linux/slab.h>
39 38
@@ -190,7 +189,7 @@ int mthca_create_ah(struct mthca_dev *dev,
190on_hca_fail: 189on_hca_fail:
191 if (ah->type == MTHCA_AH_PCI_POOL) { 190 if (ah->type == MTHCA_AH_PCI_POOL) {
192 ah->av = pci_pool_alloc(dev->av_table.pool, 191 ah->av = pci_pool_alloc(dev->av_table.pool,
193 SLAB_ATOMIC, &ah->avdma); 192 GFP_ATOMIC, &ah->avdma);
194 if (!ah->av) 193 if (!ah->av)
195 return -ENOMEM; 194 return -ENOMEM;
196 195
@@ -323,7 +322,7 @@ int mthca_ah_query(struct ib_ah *ibah, struct ib_ah_attr *attr)
323 return 0; 322 return 0;
324} 323}
325 324
326int __devinit mthca_init_av_table(struct mthca_dev *dev) 325int mthca_init_av_table(struct mthca_dev *dev)
327{ 326{
328 int err; 327 int err;
329 328
diff --git a/drivers/infiniband/hw/mthca/mthca_catas.c b/drivers/infiniband/hw/mthca/mthca_catas.c
index cd044ea2dfa4..e948158a28d9 100644
--- a/drivers/infiniband/hw/mthca/mthca_catas.c
+++ b/drivers/infiniband/hw/mthca/mthca_catas.c
@@ -57,7 +57,7 @@ static int catas_reset_disable;
57module_param_named(catas_reset_disable, catas_reset_disable, int, 0644); 57module_param_named(catas_reset_disable, catas_reset_disable, int, 0644);
58MODULE_PARM_DESC(catas_reset_disable, "disable reset on catastrophic event if nonzero"); 58MODULE_PARM_DESC(catas_reset_disable, "disable reset on catastrophic event if nonzero");
59 59
60static void catas_reset(void *work_ptr) 60static void catas_reset(struct work_struct *work)
61{ 61{
62 struct mthca_dev *dev, *tmpdev; 62 struct mthca_dev *dev, *tmpdev;
63 LIST_HEAD(tlist); 63 LIST_HEAD(tlist);
@@ -203,7 +203,7 @@ void mthca_stop_catas_poll(struct mthca_dev *dev)
203 203
204int __init mthca_catas_init(void) 204int __init mthca_catas_init(void)
205{ 205{
206 INIT_WORK(&catas_work, catas_reset, NULL); 206 INIT_WORK(&catas_work, catas_reset);
207 207
208 catas_wq = create_singlethread_workqueue("mthca_catas"); 208 catas_wq = create_singlethread_workqueue("mthca_catas");
209 if (!catas_wq) 209 if (!catas_wq)
diff --git a/drivers/infiniband/hw/mthca/mthca_cq.c b/drivers/infiniband/hw/mthca/mthca_cq.c
index 149b36901239..283d50b76c3d 100644
--- a/drivers/infiniband/hw/mthca/mthca_cq.c
+++ b/drivers/infiniband/hw/mthca/mthca_cq.c
@@ -36,7 +36,6 @@
36 * $Id: mthca_cq.c 1369 2004-12-20 16:17:07Z roland $ 36 * $Id: mthca_cq.c 1369 2004-12-20 16:17:07Z roland $
37 */ 37 */
38 38
39#include <linux/init.h>
40#include <linux/hardirq.h> 39#include <linux/hardirq.h>
41 40
42#include <asm/io.h> 41#include <asm/io.h>
@@ -970,7 +969,7 @@ void mthca_free_cq(struct mthca_dev *dev,
970 mthca_free_mailbox(dev, mailbox); 969 mthca_free_mailbox(dev, mailbox);
971} 970}
972 971
973int __devinit mthca_init_cq_table(struct mthca_dev *dev) 972int mthca_init_cq_table(struct mthca_dev *dev)
974{ 973{
975 int err; 974 int err;
976 975
diff --git a/drivers/infiniband/hw/mthca/mthca_eq.c b/drivers/infiniband/hw/mthca/mthca_eq.c
index e284e0613a94..8ec9fa1ff9ea 100644
--- a/drivers/infiniband/hw/mthca/mthca_eq.c
+++ b/drivers/infiniband/hw/mthca/mthca_eq.c
@@ -33,7 +33,6 @@
33 * $Id: mthca_eq.c 1382 2004-12-24 02:21:02Z roland $ 33 * $Id: mthca_eq.c 1382 2004-12-24 02:21:02Z roland $
34 */ 34 */
35 35
36#include <linux/init.h>
37#include <linux/errno.h> 36#include <linux/errno.h>
38#include <linux/interrupt.h> 37#include <linux/interrupt.h>
39#include <linux/pci.h> 38#include <linux/pci.h>
@@ -479,10 +478,10 @@ static irqreturn_t mthca_arbel_msi_x_interrupt(int irq, void *eq_ptr)
479 return IRQ_HANDLED; 478 return IRQ_HANDLED;
480} 479}
481 480
482static int __devinit mthca_create_eq(struct mthca_dev *dev, 481static int mthca_create_eq(struct mthca_dev *dev,
483 int nent, 482 int nent,
484 u8 intr, 483 u8 intr,
485 struct mthca_eq *eq) 484 struct mthca_eq *eq)
486{ 485{
487 int npages; 486 int npages;
488 u64 *dma_list = NULL; 487 u64 *dma_list = NULL;
@@ -664,9 +663,9 @@ static void mthca_free_irqs(struct mthca_dev *dev)
664 dev->eq_table.eq + i); 663 dev->eq_table.eq + i);
665} 664}
666 665
667static int __devinit mthca_map_reg(struct mthca_dev *dev, 666static int mthca_map_reg(struct mthca_dev *dev,
668 unsigned long offset, unsigned long size, 667 unsigned long offset, unsigned long size,
669 void __iomem **map) 668 void __iomem **map)
670{ 669{
671 unsigned long base = pci_resource_start(dev->pdev, 0); 670 unsigned long base = pci_resource_start(dev->pdev, 0);
672 671
@@ -691,7 +690,7 @@ static void mthca_unmap_reg(struct mthca_dev *dev, unsigned long offset,
691 iounmap(map); 690 iounmap(map);
692} 691}
693 692
694static int __devinit mthca_map_eq_regs(struct mthca_dev *dev) 693static int mthca_map_eq_regs(struct mthca_dev *dev)
695{ 694{
696 if (mthca_is_memfree(dev)) { 695 if (mthca_is_memfree(dev)) {
697 /* 696 /*
@@ -781,7 +780,7 @@ static void mthca_unmap_eq_regs(struct mthca_dev *dev)
781 } 780 }
782} 781}
783 782
784int __devinit mthca_map_eq_icm(struct mthca_dev *dev, u64 icm_virt) 783int mthca_map_eq_icm(struct mthca_dev *dev, u64 icm_virt)
785{ 784{
786 int ret; 785 int ret;
787 u8 status; 786 u8 status;
@@ -825,7 +824,7 @@ void mthca_unmap_eq_icm(struct mthca_dev *dev)
825 __free_page(dev->eq_table.icm_page); 824 __free_page(dev->eq_table.icm_page);
826} 825}
827 826
828int __devinit mthca_init_eq_table(struct mthca_dev *dev) 827int mthca_init_eq_table(struct mthca_dev *dev)
829{ 828{
830 int err; 829 int err;
831 u8 status; 830 u8 status;
diff --git a/drivers/infiniband/hw/mthca/mthca_mad.c b/drivers/infiniband/hw/mthca/mthca_mad.c
index 45e106f14807..acfa41d968ee 100644
--- a/drivers/infiniband/hw/mthca/mthca_mad.c
+++ b/drivers/infiniband/hw/mthca/mthca_mad.c
@@ -317,7 +317,7 @@ err:
317 return ret; 317 return ret;
318} 318}
319 319
320void __devexit mthca_free_agents(struct mthca_dev *dev) 320void mthca_free_agents(struct mthca_dev *dev)
321{ 321{
322 struct ib_mad_agent *agent; 322 struct ib_mad_agent *agent;
323 int p, q; 323 int p, q;
diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c
index 47ea02148368..0491ec7a7c0a 100644
--- a/drivers/infiniband/hw/mthca/mthca_main.c
+++ b/drivers/infiniband/hw/mthca/mthca_main.c
@@ -98,7 +98,7 @@ static struct mthca_profile default_profile = {
98 .uarc_size = 1 << 18, /* Arbel only */ 98 .uarc_size = 1 << 18, /* Arbel only */
99}; 99};
100 100
101static int __devinit mthca_tune_pci(struct mthca_dev *mdev) 101static int mthca_tune_pci(struct mthca_dev *mdev)
102{ 102{
103 int cap; 103 int cap;
104 u16 val; 104 u16 val;
@@ -143,7 +143,7 @@ static int __devinit mthca_tune_pci(struct mthca_dev *mdev)
143 return 0; 143 return 0;
144} 144}
145 145
146static int __devinit mthca_dev_lim(struct mthca_dev *mdev, struct mthca_dev_lim *dev_lim) 146static int mthca_dev_lim(struct mthca_dev *mdev, struct mthca_dev_lim *dev_lim)
147{ 147{
148 int err; 148 int err;
149 u8 status; 149 u8 status;
@@ -255,7 +255,7 @@ static int __devinit mthca_dev_lim(struct mthca_dev *mdev, struct mthca_dev_lim
255 return 0; 255 return 0;
256} 256}
257 257
258static int __devinit mthca_init_tavor(struct mthca_dev *mdev) 258static int mthca_init_tavor(struct mthca_dev *mdev)
259{ 259{
260 u8 status; 260 u8 status;
261 int err; 261 int err;
@@ -333,7 +333,7 @@ err_disable:
333 return err; 333 return err;
334} 334}
335 335
336static int __devinit mthca_load_fw(struct mthca_dev *mdev) 336static int mthca_load_fw(struct mthca_dev *mdev)
337{ 337{
338 u8 status; 338 u8 status;
339 int err; 339 int err;
@@ -379,10 +379,10 @@ err_free:
379 return err; 379 return err;
380} 380}
381 381
382static int __devinit mthca_init_icm(struct mthca_dev *mdev, 382static int mthca_init_icm(struct mthca_dev *mdev,
383 struct mthca_dev_lim *dev_lim, 383 struct mthca_dev_lim *dev_lim,
384 struct mthca_init_hca_param *init_hca, 384 struct mthca_init_hca_param *init_hca,
385 u64 icm_size) 385 u64 icm_size)
386{ 386{
387 u64 aux_pages; 387 u64 aux_pages;
388 u8 status; 388 u8 status;
@@ -575,7 +575,7 @@ static void mthca_free_icms(struct mthca_dev *mdev)
575 mthca_free_icm(mdev, mdev->fw.arbel.aux_icm); 575 mthca_free_icm(mdev, mdev->fw.arbel.aux_icm);
576} 576}
577 577
578static int __devinit mthca_init_arbel(struct mthca_dev *mdev) 578static int mthca_init_arbel(struct mthca_dev *mdev)
579{ 579{
580 struct mthca_dev_lim dev_lim; 580 struct mthca_dev_lim dev_lim;
581 struct mthca_profile profile; 581 struct mthca_profile profile;
@@ -683,7 +683,7 @@ static void mthca_close_hca(struct mthca_dev *mdev)
683 mthca_SYS_DIS(mdev, &status); 683 mthca_SYS_DIS(mdev, &status);
684} 684}
685 685
686static int __devinit mthca_init_hca(struct mthca_dev *mdev) 686static int mthca_init_hca(struct mthca_dev *mdev)
687{ 687{
688 u8 status; 688 u8 status;
689 int err; 689 int err;
@@ -720,7 +720,7 @@ err_close:
720 return err; 720 return err;
721} 721}
722 722
723static int __devinit mthca_setup_hca(struct mthca_dev *dev) 723static int mthca_setup_hca(struct mthca_dev *dev)
724{ 724{
725 int err; 725 int err;
726 u8 status; 726 u8 status;
@@ -875,8 +875,7 @@ err_uar_table_free:
875 return err; 875 return err;
876} 876}
877 877
878static int __devinit mthca_request_regions(struct pci_dev *pdev, 878static int mthca_request_regions(struct pci_dev *pdev, int ddr_hidden)
879 int ddr_hidden)
880{ 879{
881 int err; 880 int err;
882 881
@@ -928,7 +927,7 @@ static void mthca_release_regions(struct pci_dev *pdev,
928 MTHCA_HCR_SIZE); 927 MTHCA_HCR_SIZE);
929} 928}
930 929
931static int __devinit mthca_enable_msi_x(struct mthca_dev *mdev) 930static int mthca_enable_msi_x(struct mthca_dev *mdev)
932{ 931{
933 struct msix_entry entries[3]; 932 struct msix_entry entries[3];
934 int err; 933 int err;
@@ -1213,7 +1212,7 @@ int __mthca_restart_one(struct pci_dev *pdev)
1213} 1212}
1214 1213
1215static int __devinit mthca_init_one(struct pci_dev *pdev, 1214static int __devinit mthca_init_one(struct pci_dev *pdev,
1216 const struct pci_device_id *id) 1215 const struct pci_device_id *id)
1217{ 1216{
1218 static int mthca_version_printed = 0; 1217 static int mthca_version_printed = 0;
1219 int ret; 1218 int ret;
diff --git a/drivers/infiniband/hw/mthca/mthca_mcg.c b/drivers/infiniband/hw/mthca/mthca_mcg.c
index 47ca8a9b7247..a8ad072be074 100644
--- a/drivers/infiniband/hw/mthca/mthca_mcg.c
+++ b/drivers/infiniband/hw/mthca/mthca_mcg.c
@@ -32,7 +32,6 @@
32 * $Id: mthca_mcg.c 1349 2004-12-16 21:09:43Z roland $ 32 * $Id: mthca_mcg.c 1349 2004-12-16 21:09:43Z roland $
33 */ 33 */
34 34
35#include <linux/init.h>
36#include <linux/string.h> 35#include <linux/string.h>
37#include <linux/slab.h> 36#include <linux/slab.h>
38 37
@@ -371,7 +370,7 @@ int mthca_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
371 return err; 370 return err;
372} 371}
373 372
374int __devinit mthca_init_mcg_table(struct mthca_dev *dev) 373int mthca_init_mcg_table(struct mthca_dev *dev)
375{ 374{
376 int err; 375 int err;
377 int table_size = dev->limits.num_mgms + dev->limits.num_amgms; 376 int table_size = dev->limits.num_mgms + dev->limits.num_amgms;
diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
index a486dec1707e..f71ffa88db3a 100644
--- a/drivers/infiniband/hw/mthca/mthca_mr.c
+++ b/drivers/infiniband/hw/mthca/mthca_mr.c
@@ -34,7 +34,6 @@
34 */ 34 */
35 35
36#include <linux/slab.h> 36#include <linux/slab.h>
37#include <linux/init.h>
38#include <linux/errno.h> 37#include <linux/errno.h>
39 38
40#include "mthca_dev.h" 39#include "mthca_dev.h"
@@ -135,7 +134,7 @@ static void mthca_buddy_free(struct mthca_buddy *buddy, u32 seg, int order)
135 spin_unlock(&buddy->lock); 134 spin_unlock(&buddy->lock);
136} 135}
137 136
138static int __devinit mthca_buddy_init(struct mthca_buddy *buddy, int max_order) 137static int mthca_buddy_init(struct mthca_buddy *buddy, int max_order)
139{ 138{
140 int i, s; 139 int i, s;
141 140
@@ -759,7 +758,7 @@ void mthca_arbel_fmr_unmap(struct mthca_dev *dev, struct mthca_fmr *fmr)
759 *(u8 *) fmr->mem.arbel.mpt = MTHCA_MPT_STATUS_SW; 758 *(u8 *) fmr->mem.arbel.mpt = MTHCA_MPT_STATUS_SW;
760} 759}
761 760
762int __devinit mthca_init_mr_table(struct mthca_dev *dev) 761int mthca_init_mr_table(struct mthca_dev *dev)
763{ 762{
764 unsigned long addr; 763 unsigned long addr;
765 int err, i; 764 int err, i;
diff --git a/drivers/infiniband/hw/mthca/mthca_pd.c b/drivers/infiniband/hw/mthca/mthca_pd.c
index 59df51614c85..c1e950764bd8 100644
--- a/drivers/infiniband/hw/mthca/mthca_pd.c
+++ b/drivers/infiniband/hw/mthca/mthca_pd.c
@@ -34,7 +34,6 @@
34 * $Id: mthca_pd.c 1349 2004-12-16 21:09:43Z roland $ 34 * $Id: mthca_pd.c 1349 2004-12-16 21:09:43Z roland $
35 */ 35 */
36 36
37#include <linux/init.h>
38#include <linux/errno.h> 37#include <linux/errno.h>
39 38
40#include "mthca_dev.h" 39#include "mthca_dev.h"
@@ -69,7 +68,7 @@ void mthca_pd_free(struct mthca_dev *dev, struct mthca_pd *pd)
69 mthca_free(&dev->pd_table.alloc, pd->pd_num); 68 mthca_free(&dev->pd_table.alloc, pd->pd_num);
70} 69}
71 70
72int __devinit mthca_init_pd_table(struct mthca_dev *dev) 71int mthca_init_pd_table(struct mthca_dev *dev)
73{ 72{
74 return mthca_alloc_init(&dev->pd_table.alloc, 73 return mthca_alloc_init(&dev->pd_table.alloc,
75 dev->limits.num_pds, 74 dev->limits.num_pds,
diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c
index fc67f780581b..21422a3336ad 100644
--- a/drivers/infiniband/hw/mthca/mthca_provider.c
+++ b/drivers/infiniband/hw/mthca/mthca_provider.c
@@ -1100,11 +1100,10 @@ static struct ib_fmr *mthca_alloc_fmr(struct ib_pd *pd, int mr_access_flags,
1100 struct mthca_fmr *fmr; 1100 struct mthca_fmr *fmr;
1101 int err; 1101 int err;
1102 1102
1103 fmr = kmalloc(sizeof *fmr, GFP_KERNEL); 1103 fmr = kmemdup(fmr_attr, sizeof *fmr, GFP_KERNEL);
1104 if (!fmr) 1104 if (!fmr)
1105 return ERR_PTR(-ENOMEM); 1105 return ERR_PTR(-ENOMEM);
1106 1106
1107 memcpy(&fmr->attr, fmr_attr, sizeof *fmr_attr);
1108 err = mthca_fmr_alloc(to_mdev(pd->device), to_mpd(pd)->pd_num, 1107 err = mthca_fmr_alloc(to_mdev(pd->device), to_mpd(pd)->pd_num,
1109 convert_access(mr_access_flags), fmr); 1108 convert_access(mr_access_flags), fmr);
1110 1109
diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c
index 6a7822e0fc19..33e3ba7937f1 100644
--- a/drivers/infiniband/hw/mthca/mthca_qp.c
+++ b/drivers/infiniband/hw/mthca/mthca_qp.c
@@ -35,7 +35,6 @@
35 * $Id: mthca_qp.c 1355 2004-12-17 15:23:43Z roland $ 35 * $Id: mthca_qp.c 1355 2004-12-17 15:23:43Z roland $
36 */ 36 */
37 37
38#include <linux/init.h>
39#include <linux/string.h> 38#include <linux/string.h>
40#include <linux/slab.h> 39#include <linux/slab.h>
41 40
@@ -2241,7 +2240,7 @@ void mthca_free_err_wqe(struct mthca_dev *dev, struct mthca_qp *qp, int is_send,
2241 *new_wqe = 0; 2240 *new_wqe = 0;
2242} 2241}
2243 2242
2244int __devinit mthca_init_qp_table(struct mthca_dev *dev) 2243int mthca_init_qp_table(struct mthca_dev *dev)
2245{ 2244{
2246 int err; 2245 int err;
2247 u8 status; 2246 u8 status;
diff --git a/drivers/infiniband/hw/mthca/mthca_srq.c b/drivers/infiniband/hw/mthca/mthca_srq.c
index f5d7677d1079..34d2c4768962 100644
--- a/drivers/infiniband/hw/mthca/mthca_srq.c
+++ b/drivers/infiniband/hw/mthca/mthca_srq.c
@@ -120,7 +120,7 @@ static void mthca_arbel_init_srq_context(struct mthca_dev *dev,
120 120
121 memset(context, 0, sizeof *context); 121 memset(context, 0, sizeof *context);
122 122
123 logsize = long_log2(srq->max) + srq->wqe_shift; 123 logsize = long_log2(srq->max);
124 context->state_logsize_srqn = cpu_to_be32(logsize << 24 | srq->srqn); 124 context->state_logsize_srqn = cpu_to_be32(logsize << 24 | srq->srqn);
125 context->lkey = cpu_to_be32(srq->mr.ibmr.lkey); 125 context->lkey = cpu_to_be32(srq->mr.ibmr.lkey);
126 context->db_index = cpu_to_be32(srq->db_index); 126 context->db_index = cpu_to_be32(srq->db_index);
@@ -715,7 +715,7 @@ int mthca_max_srq_sge(struct mthca_dev *dev)
715 sizeof (struct mthca_data_seg)); 715 sizeof (struct mthca_data_seg));
716} 716}
717 717
718int __devinit mthca_init_srq_table(struct mthca_dev *dev) 718int mthca_init_srq_table(struct mthca_dev *dev)
719{ 719{
720 int err; 720 int err;
721 721
diff --git a/drivers/infiniband/ulp/ipoib/ipoib.h b/drivers/infiniband/ulp/ipoib/ipoib.h
index 0b8a79d53a00..99547996aba2 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib.h
+++ b/drivers/infiniband/ulp/ipoib/ipoib.h
@@ -136,11 +136,11 @@ struct ipoib_dev_priv {
136 struct list_head multicast_list; 136 struct list_head multicast_list;
137 struct rb_root multicast_tree; 137 struct rb_root multicast_tree;
138 138
139 struct work_struct pkey_task; 139 struct delayed_work pkey_task;
140 struct work_struct mcast_task; 140 struct delayed_work mcast_task;
141 struct work_struct flush_task; 141 struct work_struct flush_task;
142 struct work_struct restart_task; 142 struct work_struct restart_task;
143 struct work_struct ah_reap_task; 143 struct delayed_work ah_reap_task;
144 144
145 struct ib_device *ca; 145 struct ib_device *ca;
146 u8 port; 146 u8 port;
@@ -233,7 +233,7 @@ static inline struct ipoib_neigh **to_ipoib_neigh(struct neighbour *neigh)
233} 233}
234 234
235struct ipoib_neigh *ipoib_neigh_alloc(struct neighbour *neigh); 235struct ipoib_neigh *ipoib_neigh_alloc(struct neighbour *neigh);
236void ipoib_neigh_free(struct ipoib_neigh *neigh); 236void ipoib_neigh_free(struct net_device *dev, struct ipoib_neigh *neigh);
237 237
238extern struct workqueue_struct *ipoib_workqueue; 238extern struct workqueue_struct *ipoib_workqueue;
239 239
@@ -254,13 +254,13 @@ int ipoib_add_pkey_attr(struct net_device *dev);
254 254
255void ipoib_send(struct net_device *dev, struct sk_buff *skb, 255void ipoib_send(struct net_device *dev, struct sk_buff *skb,
256 struct ipoib_ah *address, u32 qpn); 256 struct ipoib_ah *address, u32 qpn);
257void ipoib_reap_ah(void *dev_ptr); 257void ipoib_reap_ah(struct work_struct *work);
258 258
259void ipoib_flush_paths(struct net_device *dev); 259void ipoib_flush_paths(struct net_device *dev);
260struct ipoib_dev_priv *ipoib_intf_alloc(const char *format); 260struct ipoib_dev_priv *ipoib_intf_alloc(const char *format);
261 261
262int ipoib_ib_dev_init(struct net_device *dev, struct ib_device *ca, int port); 262int ipoib_ib_dev_init(struct net_device *dev, struct ib_device *ca, int port);
263void ipoib_ib_dev_flush(void *dev); 263void ipoib_ib_dev_flush(struct work_struct *work);
264void ipoib_ib_dev_cleanup(struct net_device *dev); 264void ipoib_ib_dev_cleanup(struct net_device *dev);
265 265
266int ipoib_ib_dev_open(struct net_device *dev); 266int ipoib_ib_dev_open(struct net_device *dev);
@@ -271,10 +271,10 @@ int ipoib_ib_dev_stop(struct net_device *dev);
271int ipoib_dev_init(struct net_device *dev, struct ib_device *ca, int port); 271int ipoib_dev_init(struct net_device *dev, struct ib_device *ca, int port);
272void ipoib_dev_cleanup(struct net_device *dev); 272void ipoib_dev_cleanup(struct net_device *dev);
273 273
274void ipoib_mcast_join_task(void *dev_ptr); 274void ipoib_mcast_join_task(struct work_struct *work);
275void ipoib_mcast_send(struct net_device *dev, void *mgid, struct sk_buff *skb); 275void ipoib_mcast_send(struct net_device *dev, void *mgid, struct sk_buff *skb);
276 276
277void ipoib_mcast_restart_task(void *dev_ptr); 277void ipoib_mcast_restart_task(struct work_struct *work);
278int ipoib_mcast_start_thread(struct net_device *dev); 278int ipoib_mcast_start_thread(struct net_device *dev);
279int ipoib_mcast_stop_thread(struct net_device *dev, int flush); 279int ipoib_mcast_stop_thread(struct net_device *dev, int flush);
280 280
@@ -312,7 +312,7 @@ void ipoib_event(struct ib_event_handler *handler,
312int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey); 312int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey);
313int ipoib_vlan_delete(struct net_device *pdev, unsigned short pkey); 313int ipoib_vlan_delete(struct net_device *pdev, unsigned short pkey);
314 314
315void ipoib_pkey_poll(void *dev); 315void ipoib_pkey_poll(struct work_struct *work);
316int ipoib_pkey_dev_delay_open(struct net_device *dev); 316int ipoib_pkey_dev_delay_open(struct net_device *dev);
317 317
318#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG 318#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
index 8bf5e9ec7c95..f10fba5d3265 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
@@ -400,10 +400,11 @@ static void __ipoib_reap_ah(struct net_device *dev)
400 spin_unlock_irq(&priv->tx_lock); 400 spin_unlock_irq(&priv->tx_lock);
401} 401}
402 402
403void ipoib_reap_ah(void *dev_ptr) 403void ipoib_reap_ah(struct work_struct *work)
404{ 404{
405 struct net_device *dev = dev_ptr; 405 struct ipoib_dev_priv *priv =
406 struct ipoib_dev_priv *priv = netdev_priv(dev); 406 container_of(work, struct ipoib_dev_priv, ah_reap_task.work);
407 struct net_device *dev = priv->dev;
407 408
408 __ipoib_reap_ah(dev); 409 __ipoib_reap_ah(dev);
409 410
@@ -613,10 +614,11 @@ int ipoib_ib_dev_init(struct net_device *dev, struct ib_device *ca, int port)
613 return 0; 614 return 0;
614} 615}
615 616
616void ipoib_ib_dev_flush(void *_dev) 617void ipoib_ib_dev_flush(struct work_struct *work)
617{ 618{
618 struct net_device *dev = (struct net_device *)_dev; 619 struct ipoib_dev_priv *cpriv, *priv =
619 struct ipoib_dev_priv *priv = netdev_priv(dev), *cpriv; 620 container_of(work, struct ipoib_dev_priv, flush_task);
621 struct net_device *dev = priv->dev;
620 622
621 if (!test_bit(IPOIB_FLAG_INITIALIZED, &priv->flags) ) { 623 if (!test_bit(IPOIB_FLAG_INITIALIZED, &priv->flags) ) {
622 ipoib_dbg(priv, "Not flushing - IPOIB_FLAG_INITIALIZED not set.\n"); 624 ipoib_dbg(priv, "Not flushing - IPOIB_FLAG_INITIALIZED not set.\n");
@@ -638,14 +640,14 @@ void ipoib_ib_dev_flush(void *_dev)
638 */ 640 */
639 if (test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags)) { 641 if (test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags)) {
640 ipoib_ib_dev_up(dev); 642 ipoib_ib_dev_up(dev);
641 ipoib_mcast_restart_task(dev); 643 ipoib_mcast_restart_task(&priv->restart_task);
642 } 644 }
643 645
644 mutex_lock(&priv->vlan_mutex); 646 mutex_lock(&priv->vlan_mutex);
645 647
646 /* Flush any child interfaces too */ 648 /* Flush any child interfaces too */
647 list_for_each_entry(cpriv, &priv->child_intfs, list) 649 list_for_each_entry(cpriv, &priv->child_intfs, list)
648 ipoib_ib_dev_flush(cpriv->dev); 650 ipoib_ib_dev_flush(&cpriv->flush_task);
649 651
650 mutex_unlock(&priv->vlan_mutex); 652 mutex_unlock(&priv->vlan_mutex);
651} 653}
@@ -672,10 +674,11 @@ void ipoib_ib_dev_cleanup(struct net_device *dev)
672 * change async notification is available. 674 * change async notification is available.
673 */ 675 */
674 676
675void ipoib_pkey_poll(void *dev_ptr) 677void ipoib_pkey_poll(struct work_struct *work)
676{ 678{
677 struct net_device *dev = dev_ptr; 679 struct ipoib_dev_priv *priv =
678 struct ipoib_dev_priv *priv = netdev_priv(dev); 680 container_of(work, struct ipoib_dev_priv, pkey_task.work);
681 struct net_device *dev = priv->dev;
679 682
680 ipoib_pkey_dev_check_presence(dev); 683 ipoib_pkey_dev_check_presence(dev);
681 684
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 1eaf00e9862c..c09280243726 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -49,6 +49,8 @@
49 49
50#include <net/dst.h> 50#include <net/dst.h>
51 51
52#define IPOIB_QPN(ha) (be32_to_cpup((__be32 *) ha) & 0xffffff)
53
52MODULE_AUTHOR("Roland Dreier"); 54MODULE_AUTHOR("Roland Dreier");
53MODULE_DESCRIPTION("IP-over-InfiniBand net driver"); 55MODULE_DESCRIPTION("IP-over-InfiniBand net driver");
54MODULE_LICENSE("Dual BSD/GPL"); 56MODULE_LICENSE("Dual BSD/GPL");
@@ -262,7 +264,7 @@ static void path_free(struct net_device *dev, struct ipoib_path *path)
262 if (neigh->ah) 264 if (neigh->ah)
263 ipoib_put_ah(neigh->ah); 265 ipoib_put_ah(neigh->ah);
264 266
265 ipoib_neigh_free(neigh); 267 ipoib_neigh_free(dev, neigh);
266 } 268 }
267 269
268 spin_unlock_irqrestore(&priv->lock, flags); 270 spin_unlock_irqrestore(&priv->lock, flags);
@@ -520,14 +522,14 @@ static void neigh_add_path(struct sk_buff *skb, struct net_device *dev)
520 memcpy(&neigh->dgid.raw, &path->pathrec.dgid.raw, 522 memcpy(&neigh->dgid.raw, &path->pathrec.dgid.raw,
521 sizeof(union ib_gid)); 523 sizeof(union ib_gid));
522 524
523 ipoib_send(dev, skb, path->ah, 525 ipoib_send(dev, skb, path->ah, IPOIB_QPN(skb->dst->neighbour->ha));
524 be32_to_cpup((__be32 *) skb->dst->neighbour->ha));
525 } else { 526 } else {
526 neigh->ah = NULL; 527 neigh->ah = NULL;
527 __skb_queue_tail(&neigh->queue, skb);
528 528
529 if (!path->query && path_rec_start(dev, path)) 529 if (!path->query && path_rec_start(dev, path))
530 goto err_list; 530 goto err_list;
531
532 __skb_queue_tail(&neigh->queue, skb);
531 } 533 }
532 534
533 spin_unlock(&priv->lock); 535 spin_unlock(&priv->lock);
@@ -537,7 +539,7 @@ err_list:
537 list_del(&neigh->list); 539 list_del(&neigh->list);
538 540
539err_path: 541err_path:
540 ipoib_neigh_free(neigh); 542 ipoib_neigh_free(dev, neigh);
541 ++priv->stats.tx_dropped; 543 ++priv->stats.tx_dropped;
542 dev_kfree_skb_any(skb); 544 dev_kfree_skb_any(skb);
543 545
@@ -599,8 +601,7 @@ static void unicast_arp_send(struct sk_buff *skb, struct net_device *dev,
599 ipoib_dbg(priv, "Send unicast ARP to %04x\n", 601 ipoib_dbg(priv, "Send unicast ARP to %04x\n",
600 be16_to_cpu(path->pathrec.dlid)); 602 be16_to_cpu(path->pathrec.dlid));
601 603
602 ipoib_send(dev, skb, path->ah, 604 ipoib_send(dev, skb, path->ah, IPOIB_QPN(phdr->hwaddr));
603 be32_to_cpup((__be32 *) phdr->hwaddr));
604 } else if ((path->query || !path_rec_start(dev, path)) && 605 } else if ((path->query || !path_rec_start(dev, path)) &&
605 skb_queue_len(&path->queue) < IPOIB_MAX_PATH_REC_QUEUE) { 606 skb_queue_len(&path->queue) < IPOIB_MAX_PATH_REC_QUEUE) {
606 /* put pseudoheader back on for next time */ 607 /* put pseudoheader back on for next time */
@@ -655,14 +656,13 @@ static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev)
655 */ 656 */
656 ipoib_put_ah(neigh->ah); 657 ipoib_put_ah(neigh->ah);
657 list_del(&neigh->list); 658 list_del(&neigh->list);
658 ipoib_neigh_free(neigh); 659 ipoib_neigh_free(dev, neigh);
659 spin_unlock(&priv->lock); 660 spin_unlock(&priv->lock);
660 ipoib_path_lookup(skb, dev); 661 ipoib_path_lookup(skb, dev);
661 goto out; 662 goto out;
662 } 663 }
663 664
664 ipoib_send(dev, skb, neigh->ah, 665 ipoib_send(dev, skb, neigh->ah, IPOIB_QPN(skb->dst->neighbour->ha));
665 be32_to_cpup((__be32 *) skb->dst->neighbour->ha));
666 goto out; 666 goto out;
667 } 667 }
668 668
@@ -694,7 +694,7 @@ static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev)
694 IPOIB_GID_FMT "\n", 694 IPOIB_GID_FMT "\n",
695 skb->dst ? "neigh" : "dst", 695 skb->dst ? "neigh" : "dst",
696 be16_to_cpup((__be16 *) skb->data), 696 be16_to_cpup((__be16 *) skb->data),
697 be32_to_cpup((__be32 *) phdr->hwaddr), 697 IPOIB_QPN(phdr->hwaddr),
698 IPOIB_GID_RAW_ARG(phdr->hwaddr + 4)); 698 IPOIB_GID_RAW_ARG(phdr->hwaddr + 4));
699 dev_kfree_skb_any(skb); 699 dev_kfree_skb_any(skb);
700 ++priv->stats.tx_dropped; 700 ++priv->stats.tx_dropped;
@@ -777,7 +777,7 @@ static void ipoib_neigh_destructor(struct neighbour *n)
777 777
778 ipoib_dbg(priv, 778 ipoib_dbg(priv,
779 "neigh_destructor for %06x " IPOIB_GID_FMT "\n", 779 "neigh_destructor for %06x " IPOIB_GID_FMT "\n",
780 be32_to_cpup((__be32 *) n->ha), 780 IPOIB_QPN(n->ha),
781 IPOIB_GID_RAW_ARG(n->ha + 4)); 781 IPOIB_GID_RAW_ARG(n->ha + 4));
782 782
783 spin_lock_irqsave(&priv->lock, flags); 783 spin_lock_irqsave(&priv->lock, flags);
@@ -787,7 +787,7 @@ static void ipoib_neigh_destructor(struct neighbour *n)
787 if (neigh->ah) 787 if (neigh->ah)
788 ah = neigh->ah; 788 ah = neigh->ah;
789 list_del(&neigh->list); 789 list_del(&neigh->list);
790 ipoib_neigh_free(neigh); 790 ipoib_neigh_free(n->dev, neigh);
791 } 791 }
792 792
793 spin_unlock_irqrestore(&priv->lock, flags); 793 spin_unlock_irqrestore(&priv->lock, flags);
@@ -810,9 +810,15 @@ struct ipoib_neigh *ipoib_neigh_alloc(struct neighbour *neighbour)
810 return neigh; 810 return neigh;
811} 811}
812 812
813void ipoib_neigh_free(struct ipoib_neigh *neigh) 813void ipoib_neigh_free(struct net_device *dev, struct ipoib_neigh *neigh)
814{ 814{
815 struct ipoib_dev_priv *priv = netdev_priv(dev);
816 struct sk_buff *skb;
815 *to_ipoib_neigh(neigh->neighbour) = NULL; 817 *to_ipoib_neigh(neigh->neighbour) = NULL;
818 while ((skb = __skb_dequeue(&neigh->queue))) {
819 ++priv->stats.tx_dropped;
820 dev_kfree_skb_any(skb);
821 }
816 kfree(neigh); 822 kfree(neigh);
817} 823}
818 824
@@ -934,11 +940,11 @@ static void ipoib_setup(struct net_device *dev)
934 INIT_LIST_HEAD(&priv->dead_ahs); 940 INIT_LIST_HEAD(&priv->dead_ahs);
935 INIT_LIST_HEAD(&priv->multicast_list); 941 INIT_LIST_HEAD(&priv->multicast_list);
936 942
937 INIT_WORK(&priv->pkey_task, ipoib_pkey_poll, priv->dev); 943 INIT_DELAYED_WORK(&priv->pkey_task, ipoib_pkey_poll);
938 INIT_WORK(&priv->mcast_task, ipoib_mcast_join_task, priv->dev); 944 INIT_DELAYED_WORK(&priv->mcast_task, ipoib_mcast_join_task);
939 INIT_WORK(&priv->flush_task, ipoib_ib_dev_flush, priv->dev); 945 INIT_WORK(&priv->flush_task, ipoib_ib_dev_flush);
940 INIT_WORK(&priv->restart_task, ipoib_mcast_restart_task, priv->dev); 946 INIT_WORK(&priv->restart_task, ipoib_mcast_restart_task);
941 INIT_WORK(&priv->ah_reap_task, ipoib_reap_ah, priv->dev); 947 INIT_DELAYED_WORK(&priv->ah_reap_task, ipoib_reap_ah);
942} 948}
943 949
944struct ipoib_dev_priv *ipoib_intf_alloc(const char *name) 950struct ipoib_dev_priv *ipoib_intf_alloc(const char *name)
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
index 3faa1820f0e9..b04b72ca32ed 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
@@ -114,7 +114,7 @@ static void ipoib_mcast_free(struct ipoib_mcast *mcast)
114 */ 114 */
115 if (neigh->ah) 115 if (neigh->ah)
116 ipoib_put_ah(neigh->ah); 116 ipoib_put_ah(neigh->ah);
117 ipoib_neigh_free(neigh); 117 ipoib_neigh_free(dev, neigh);
118 } 118 }
119 119
120 spin_unlock_irqrestore(&priv->lock, flags); 120 spin_unlock_irqrestore(&priv->lock, flags);
@@ -399,7 +399,8 @@ static void ipoib_mcast_join_complete(int status,
399 mcast->backoff = 1; 399 mcast->backoff = 1;
400 mutex_lock(&mcast_mutex); 400 mutex_lock(&mcast_mutex);
401 if (test_bit(IPOIB_MCAST_RUN, &priv->flags)) 401 if (test_bit(IPOIB_MCAST_RUN, &priv->flags))
402 queue_work(ipoib_workqueue, &priv->mcast_task); 402 queue_delayed_work(ipoib_workqueue,
403 &priv->mcast_task, 0);
403 mutex_unlock(&mcast_mutex); 404 mutex_unlock(&mcast_mutex);
404 complete(&mcast->done); 405 complete(&mcast->done);
405 return; 406 return;
@@ -435,7 +436,8 @@ static void ipoib_mcast_join_complete(int status,
435 436
436 if (test_bit(IPOIB_MCAST_RUN, &priv->flags)) { 437 if (test_bit(IPOIB_MCAST_RUN, &priv->flags)) {
437 if (status == -ETIMEDOUT) 438 if (status == -ETIMEDOUT)
438 queue_work(ipoib_workqueue, &priv->mcast_task); 439 queue_delayed_work(ipoib_workqueue, &priv->mcast_task,
440 0);
439 else 441 else
440 queue_delayed_work(ipoib_workqueue, &priv->mcast_task, 442 queue_delayed_work(ipoib_workqueue, &priv->mcast_task,
441 mcast->backoff * HZ); 443 mcast->backoff * HZ);
@@ -517,10 +519,11 @@ static void ipoib_mcast_join(struct net_device *dev, struct ipoib_mcast *mcast,
517 mcast->query_id = ret; 519 mcast->query_id = ret;
518} 520}
519 521
520void ipoib_mcast_join_task(void *dev_ptr) 522void ipoib_mcast_join_task(struct work_struct *work)
521{ 523{
522 struct net_device *dev = dev_ptr; 524 struct ipoib_dev_priv *priv =
523 struct ipoib_dev_priv *priv = netdev_priv(dev); 525 container_of(work, struct ipoib_dev_priv, mcast_task.work);
526 struct net_device *dev = priv->dev;
524 527
525 if (!test_bit(IPOIB_MCAST_RUN, &priv->flags)) 528 if (!test_bit(IPOIB_MCAST_RUN, &priv->flags))
526 return; 529 return;
@@ -610,7 +613,7 @@ int ipoib_mcast_start_thread(struct net_device *dev)
610 613
611 mutex_lock(&mcast_mutex); 614 mutex_lock(&mcast_mutex);
612 if (!test_and_set_bit(IPOIB_MCAST_RUN, &priv->flags)) 615 if (!test_and_set_bit(IPOIB_MCAST_RUN, &priv->flags))
613 queue_work(ipoib_workqueue, &priv->mcast_task); 616 queue_delayed_work(ipoib_workqueue, &priv->mcast_task, 0);
614 mutex_unlock(&mcast_mutex); 617 mutex_unlock(&mcast_mutex);
615 618
616 spin_lock_irq(&priv->lock); 619 spin_lock_irq(&priv->lock);
@@ -818,10 +821,11 @@ void ipoib_mcast_dev_flush(struct net_device *dev)
818 } 821 }
819} 822}
820 823
821void ipoib_mcast_restart_task(void *dev_ptr) 824void ipoib_mcast_restart_task(struct work_struct *work)
822{ 825{
823 struct net_device *dev = dev_ptr; 826 struct ipoib_dev_priv *priv =
824 struct ipoib_dev_priv *priv = netdev_priv(dev); 827 container_of(work, struct ipoib_dev_priv, restart_task);
828 struct net_device *dev = priv->dev;
825 struct dev_mc_list *mclist; 829 struct dev_mc_list *mclist;
826 struct ipoib_mcast *mcast, *tmcast; 830 struct ipoib_mcast *mcast, *tmcast;
827 LIST_HEAD(remove_list); 831 LIST_HEAD(remove_list);
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.h b/drivers/infiniband/ulp/iser/iscsi_iser.h
index 9c53916f28c2..234e5b061a75 100644
--- a/drivers/infiniband/ulp/iser/iscsi_iser.h
+++ b/drivers/infiniband/ulp/iser/iscsi_iser.h
@@ -283,7 +283,7 @@ struct iser_global {
283 struct mutex connlist_mutex; 283 struct mutex connlist_mutex;
284 struct list_head connlist; /* all iSER IB connections */ 284 struct list_head connlist; /* all iSER IB connections */
285 285
286 kmem_cache_t *desc_cache; 286 struct kmem_cache *desc_cache;
287}; 287};
288 288
289extern struct iser_global ig; 289extern struct iser_global ig;
diff --git a/drivers/infiniband/ulp/iser/iser_memory.c b/drivers/infiniband/ulp/iser/iser_memory.c
index 0606744c3f84..5e122501fd80 100644
--- a/drivers/infiniband/ulp/iser/iser_memory.c
+++ b/drivers/infiniband/ulp/iser/iser_memory.c
@@ -35,6 +35,7 @@
35#include <linux/kernel.h> 35#include <linux/kernel.h>
36#include <linux/slab.h> 36#include <linux/slab.h>
37#include <linux/mm.h> 37#include <linux/mm.h>
38#include <linux/highmem.h>
38#include <asm/io.h> 39#include <asm/io.h>
39#include <asm/scatterlist.h> 40#include <asm/scatterlist.h>
40#include <linux/scatterlist.h> 41#include <linux/scatterlist.h>
diff --git a/drivers/infiniband/ulp/iser/iser_verbs.c b/drivers/infiniband/ulp/iser/iser_verbs.c
index 18a000034996..693b77002897 100644
--- a/drivers/infiniband/ulp/iser/iser_verbs.c
+++ b/drivers/infiniband/ulp/iser/iser_verbs.c
@@ -48,7 +48,7 @@
48 48
49static void iser_cq_tasklet_fn(unsigned long data); 49static void iser_cq_tasklet_fn(unsigned long data);
50static void iser_cq_callback(struct ib_cq *cq, void *cq_context); 50static void iser_cq_callback(struct ib_cq *cq, void *cq_context);
51static void iser_comp_error_worker(void *data); 51static void iser_comp_error_worker(struct work_struct *work);
52 52
53static void iser_cq_event_callback(struct ib_event *cause, void *context) 53static void iser_cq_event_callback(struct ib_event *cause, void *context)
54{ 54{
@@ -480,8 +480,7 @@ int iser_conn_init(struct iser_conn **ibconn)
480 init_waitqueue_head(&ib_conn->wait); 480 init_waitqueue_head(&ib_conn->wait);
481 atomic_set(&ib_conn->post_recv_buf_count, 0); 481 atomic_set(&ib_conn->post_recv_buf_count, 0);
482 atomic_set(&ib_conn->post_send_buf_count, 0); 482 atomic_set(&ib_conn->post_send_buf_count, 0);
483 INIT_WORK(&ib_conn->comperror_work, iser_comp_error_worker, 483 INIT_WORK(&ib_conn->comperror_work, iser_comp_error_worker);
484 ib_conn);
485 INIT_LIST_HEAD(&ib_conn->conn_list); 484 INIT_LIST_HEAD(&ib_conn->conn_list);
486 spin_lock_init(&ib_conn->lock); 485 spin_lock_init(&ib_conn->lock);
487 486
@@ -754,9 +753,10 @@ int iser_post_send(struct iser_desc *tx_desc)
754 return ret_val; 753 return ret_val;
755} 754}
756 755
757static void iser_comp_error_worker(void *data) 756static void iser_comp_error_worker(struct work_struct *work)
758{ 757{
759 struct iser_conn *ib_conn = data; 758 struct iser_conn *ib_conn =
759 container_of(work, struct iser_conn, comperror_work);
760 760
761 /* getting here when the state is UP means that the conn is being * 761 /* getting here when the state is UP means that the conn is being *
762 * terminated asynchronously from the iSCSI layer's perspective. */ 762 * terminated asynchronously from the iSCSI layer's perspective. */
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 4b09147f438f..a6289595557b 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -390,9 +390,10 @@ static void srp_disconnect_target(struct srp_target_port *target)
390 wait_for_completion(&target->done); 390 wait_for_completion(&target->done);
391} 391}
392 392
393static void srp_remove_work(void *target_ptr) 393static void srp_remove_work(struct work_struct *work)
394{ 394{
395 struct srp_target_port *target = target_ptr; 395 struct srp_target_port *target =
396 container_of(work, struct srp_target_port, work);
396 397
397 spin_lock_irq(target->scsi_host->host_lock); 398 spin_lock_irq(target->scsi_host->host_lock);
398 if (target->state != SRP_TARGET_DEAD) { 399 if (target->state != SRP_TARGET_DEAD) {
@@ -575,7 +576,7 @@ err:
575 spin_lock_irq(target->scsi_host->host_lock); 576 spin_lock_irq(target->scsi_host->host_lock);
576 if (target->state == SRP_TARGET_CONNECTING) { 577 if (target->state == SRP_TARGET_CONNECTING) {
577 target->state = SRP_TARGET_DEAD; 578 target->state = SRP_TARGET_DEAD;
578 INIT_WORK(&target->work, srp_remove_work, target); 579 INIT_WORK(&target->work, srp_remove_work);
579 schedule_work(&target->work); 580 schedule_work(&target->work);
580 } 581 }
581 spin_unlock_irq(target->scsi_host->host_lock); 582 spin_unlock_irq(target->scsi_host->host_lock);
@@ -1176,9 +1177,11 @@ static int srp_cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event)
1176 break; 1177 break;
1177 } 1178 }
1178 1179
1179 target->status = srp_alloc_iu_bufs(target); 1180 if (!target->rx_ring[0]) {
1180 if (target->status) 1181 target->status = srp_alloc_iu_bufs(target);
1181 break; 1182 if (target->status)
1183 break;
1184 }
1182 1185
1183 qp_attr = kmalloc(sizeof *qp_attr, GFP_KERNEL); 1186 qp_attr = kmalloc(sizeof *qp_attr, GFP_KERNEL);
1184 if (!qp_attr) { 1187 if (!qp_attr) {
@@ -1716,7 +1719,8 @@ static ssize_t srp_create_target(struct class_device *class_dev,
1716 if (!target_host) 1719 if (!target_host)
1717 return -ENOMEM; 1720 return -ENOMEM;
1718 1721
1719 target_host->max_lun = SRP_MAX_LUN; 1722 target_host->max_lun = SRP_MAX_LUN;
1723 target_host->max_cmd_len = sizeof ((struct srp_cmd *) (void *) 0L)->cdb;
1720 1724
1721 target = host_to_target(target_host); 1725 target = host_to_target(target_host);
1722 1726
diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
index bba5894fcecd..a00fe470a829 100644
--- a/drivers/input/gameport/gameport.c
+++ b/drivers/input/gameport/gameport.c
@@ -23,6 +23,7 @@
23#include <linux/kthread.h> 23#include <linux/kthread.h>
24#include <linux/sched.h> /* HZ */ 24#include <linux/sched.h> /* HZ */
25#include <linux/mutex.h> 25#include <linux/mutex.h>
26#include <linux/freezer.h>
26 27
27/*#include <asm/io.h>*/ 28/*#include <asm/io.h>*/
28 29
diff --git a/drivers/input/joystick/iforce/iforce-usb.c b/drivers/input/joystick/iforce/iforce-usb.c
index 105112fb7b57..80cdebcbcb99 100644
--- a/drivers/input/joystick/iforce/iforce-usb.c
+++ b/drivers/input/joystick/iforce/iforce-usb.c
@@ -178,9 +178,9 @@ static int iforce_usb_probe(struct usb_interface *intf,
178 178
179fail: 179fail:
180 if (iforce) { 180 if (iforce) {
181 if (iforce->irq) usb_free_urb(iforce->irq); 181 usb_free_urb(iforce->irq);
182 if (iforce->out) usb_free_urb(iforce->out); 182 usb_free_urb(iforce->out);
183 if (iforce->ctrl) usb_free_urb(iforce->ctrl); 183 usb_free_urb(iforce->ctrl);
184 kfree(iforce); 184 kfree(iforce);
185 } 185 }
186 186
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index 498e64a00e3c..c621a9177a56 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -567,9 +567,9 @@ static int atkbd_set_leds(struct atkbd *atkbd)
567 * interrupt context. 567 * interrupt context.
568 */ 568 */
569 569
570static void atkbd_event_work(void *data) 570static void atkbd_event_work(struct work_struct *work)
571{ 571{
572 struct atkbd *atkbd = data; 572 struct atkbd *atkbd = container_of(work, struct atkbd, event_work);
573 573
574 mutex_lock(&atkbd->event_mutex); 574 mutex_lock(&atkbd->event_mutex);
575 575
@@ -943,7 +943,7 @@ static int atkbd_connect(struct serio *serio, struct serio_driver *drv)
943 943
944 atkbd->dev = dev; 944 atkbd->dev = dev;
945 ps2_init(&atkbd->ps2dev, serio); 945 ps2_init(&atkbd->ps2dev, serio);
946 INIT_WORK(&atkbd->event_work, atkbd_event_work, atkbd); 946 INIT_WORK(&atkbd->event_work, atkbd_event_work);
947 mutex_init(&atkbd->event_mutex); 947 mutex_init(&atkbd->event_mutex);
948 948
949 switch (serio->id.type) { 949 switch (serio->id.type) {
diff --git a/drivers/input/keyboard/lkkbd.c b/drivers/input/keyboard/lkkbd.c
index 1789785813ee..3d4d0a0ede28 100644
--- a/drivers/input/keyboard/lkkbd.c
+++ b/drivers/input/keyboard/lkkbd.c
@@ -59,11 +59,6 @@
59 * You should have received a copy of the GNU General Public License 59 * You should have received a copy of the GNU General Public License
60 * along with this program; if not, write to the Free Software 60 * along with this program; if not, write to the Free Software
61 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 61 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
62 *
63 * Should you need to contact me, the author, you can do so either by
64 * email or by paper mail:
65 * Jan-Benedict Glaw, Lilienstraße 16, 33790 Hörste (near Halle/Westf.),
66 * Germany.
67 */ 62 */
68 63
69#include <linux/delay.h> 64#include <linux/delay.h>
@@ -577,9 +572,9 @@ lkkbd_event (struct input_dev *dev, unsigned int type, unsigned int code,
577 * were in. 572 * were in.
578 */ 573 */
579static void 574static void
580lkkbd_reinit (void *data) 575lkkbd_reinit (struct work_struct *work)
581{ 576{
582 struct lkkbd *lk = data; 577 struct lkkbd *lk = container_of(work, struct lkkbd, tq);
583 int division; 578 int division;
584 unsigned char leds_on = 0; 579 unsigned char leds_on = 0;
585 unsigned char leds_off = 0; 580 unsigned char leds_off = 0;
@@ -656,7 +651,7 @@ lkkbd_connect (struct serio *serio, struct serio_driver *drv)
656 651
657 lk->serio = serio; 652 lk->serio = serio;
658 lk->dev = input_dev; 653 lk->dev = input_dev;
659 INIT_WORK (&lk->tq, lkkbd_reinit, lk); 654 INIT_WORK (&lk->tq, lkkbd_reinit);
660 lk->bell_volume = bell_volume; 655 lk->bell_volume = bell_volume;
661 lk->keyclick_volume = keyclick_volume; 656 lk->keyclick_volume = keyclick_volume;
662 lk->ctrlclick_volume = ctrlclick_volume; 657 lk->ctrlclick_volume = ctrlclick_volume;
diff --git a/drivers/input/keyboard/sunkbd.c b/drivers/input/keyboard/sunkbd.c
index d6ab6d4b1fa8..3826db9403e6 100644
--- a/drivers/input/keyboard/sunkbd.c
+++ b/drivers/input/keyboard/sunkbd.c
@@ -208,9 +208,9 @@ static int sunkbd_initialize(struct sunkbd *sunkbd)
208 * were in. 208 * were in.
209 */ 209 */
210 210
211static void sunkbd_reinit(void *data) 211static void sunkbd_reinit(struct work_struct *work)
212{ 212{
213 struct sunkbd *sunkbd = data; 213 struct sunkbd *sunkbd = container_of(work, struct sunkbd, tq);
214 214
215 wait_event_interruptible_timeout(sunkbd->wait, sunkbd->reset >= 0, HZ); 215 wait_event_interruptible_timeout(sunkbd->wait, sunkbd->reset >= 0, HZ);
216 216
@@ -248,7 +248,7 @@ static int sunkbd_connect(struct serio *serio, struct serio_driver *drv)
248 sunkbd->serio = serio; 248 sunkbd->serio = serio;
249 sunkbd->dev = input_dev; 249 sunkbd->dev = input_dev;
250 init_waitqueue_head(&sunkbd->wait); 250 init_waitqueue_head(&sunkbd->wait);
251 INIT_WORK(&sunkbd->tq, sunkbd_reinit, sunkbd); 251 INIT_WORK(&sunkbd->tq, sunkbd_reinit);
252 snprintf(sunkbd->phys, sizeof(sunkbd->phys), "%s/input0", serio->phys); 252 snprintf(sunkbd->phys, sizeof(sunkbd->phys), "%s/input0", serio->phys);
253 253
254 serio_set_drvdata(serio, sunkbd); 254 serio_set_drvdata(serio, sunkbd);
diff --git a/drivers/input/misc/hp_sdc_rtc.c b/drivers/input/misc/hp_sdc_rtc.c
index ab4da79ee560..31d5a13bfd6b 100644
--- a/drivers/input/misc/hp_sdc_rtc.c
+++ b/drivers/input/misc/hp_sdc_rtc.c
@@ -695,7 +695,9 @@ static int __init hp_sdc_rtc_init(void)
695 695
696 if ((ret = hp_sdc_request_timer_irq(&hp_sdc_rtc_isr))) 696 if ((ret = hp_sdc_request_timer_irq(&hp_sdc_rtc_isr)))
697 return ret; 697 return ret;
698 misc_register(&hp_sdc_rtc_dev); 698 if (misc_register(&hp_sdc_rtc_dev) != 0)
699 printk(KERN_INFO "Could not register misc. dev for i8042 rtc\n");
700
699 create_proc_read_entry ("driver/rtc", 0, NULL, 701 create_proc_read_entry ("driver/rtc", 0, NULL,
700 hp_sdc_rtc_read_proc, NULL); 702 hp_sdc_rtc_read_proc, NULL);
701 703
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index e626b1e737fa..a0e4a033e2db 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -888,9 +888,10 @@ static int psmouse_poll(struct psmouse *psmouse)
888 * psmouse_resync() attempts to re-validate current protocol. 888 * psmouse_resync() attempts to re-validate current protocol.
889 */ 889 */
890 890
891static void psmouse_resync(void *p) 891static void psmouse_resync(struct work_struct *work)
892{ 892{
893 struct psmouse *psmouse = p, *parent = NULL; 893 struct psmouse *parent = NULL, *psmouse =
894 container_of(work, struct psmouse, resync_work);
894 struct serio *serio = psmouse->ps2dev.serio; 895 struct serio *serio = psmouse->ps2dev.serio;
895 psmouse_ret_t rc = PSMOUSE_GOOD_DATA; 896 psmouse_ret_t rc = PSMOUSE_GOOD_DATA;
896 int failed = 0, enabled = 0; 897 int failed = 0, enabled = 0;
@@ -1121,7 +1122,7 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv)
1121 goto err_free; 1122 goto err_free;
1122 1123
1123 ps2_init(&psmouse->ps2dev, serio); 1124 ps2_init(&psmouse->ps2dev, serio);
1124 INIT_WORK(&psmouse->resync_work, psmouse_resync, psmouse); 1125 INIT_WORK(&psmouse->resync_work, psmouse_resync);
1125 psmouse->dev = input_dev; 1126 psmouse->dev = input_dev;
1126 snprintf(psmouse->phys, sizeof(psmouse->phys), "%s/input0", serio->phys); 1127 snprintf(psmouse->phys, sizeof(psmouse->phys), "%s/input0", serio->phys);
1127 1128
diff --git a/drivers/input/serio/libps2.c b/drivers/input/serio/libps2.c
index e5b1b60757bb..b3e84d3bb7f7 100644
--- a/drivers/input/serio/libps2.c
+++ b/drivers/input/serio/libps2.c
@@ -251,9 +251,9 @@ EXPORT_SYMBOL(ps2_command);
251 * ps2_schedule_command(), to a PS/2 device (keyboard, mouse, etc.) 251 * ps2_schedule_command(), to a PS/2 device (keyboard, mouse, etc.)
252 */ 252 */
253 253
254static void ps2_execute_scheduled_command(void *data) 254static void ps2_execute_scheduled_command(struct work_struct *work)
255{ 255{
256 struct ps2work *ps2work = data; 256 struct ps2work *ps2work = container_of(work, struct ps2work, work);
257 257
258 ps2_command(ps2work->ps2dev, ps2work->param, ps2work->command); 258 ps2_command(ps2work->ps2dev, ps2work->param, ps2work->command);
259 kfree(ps2work); 259 kfree(ps2work);
@@ -278,7 +278,7 @@ int ps2_schedule_command(struct ps2dev *ps2dev, unsigned char *param, int comman
278 ps2work->ps2dev = ps2dev; 278 ps2work->ps2dev = ps2dev;
279 ps2work->command = command; 279 ps2work->command = command;
280 memcpy(ps2work->param, param, send); 280 memcpy(ps2work->param, param, send);
281 INIT_WORK(&ps2work->work, ps2_execute_scheduled_command, ps2work); 281 INIT_WORK(&ps2work->work, ps2_execute_scheduled_command);
282 282
283 if (!schedule_work(&ps2work->work)) { 283 if (!schedule_work(&ps2work->work)) {
284 kfree(ps2work); 284 kfree(ps2work);
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
index 8c717042f611..f0ce822c1028 100644
--- a/drivers/input/serio/serio.c
+++ b/drivers/input/serio/serio.c
@@ -35,6 +35,7 @@
35#include <linux/slab.h> 35#include <linux/slab.h>
36#include <linux/kthread.h> 36#include <linux/kthread.h>
37#include <linux/mutex.h> 37#include <linux/mutex.h>
38#include <linux/freezer.h>
38 39
39MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); 40MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
40MODULE_DESCRIPTION("Serio abstraction core"); 41MODULE_DESCRIPTION("Serio abstraction core");
diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
index 0e343a6cacc9..088ebc348ba3 100644
--- a/drivers/input/serio/serio_raw.c
+++ b/drivers/input/serio/serio_raw.c
@@ -297,7 +297,7 @@ static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
297 297
298 serio_raw->dev.minor = PSMOUSE_MINOR; 298 serio_raw->dev.minor = PSMOUSE_MINOR;
299 serio_raw->dev.name = serio_raw->name; 299 serio_raw->dev.name = serio_raw->name;
300 serio_raw->dev.dev = &serio->dev; 300 serio_raw->dev.parent = &serio->dev;
301 serio_raw->dev.fops = &serio_raw_fops; 301 serio_raw->dev.fops = &serio_raw_fops;
302 302
303 err = misc_register(&serio_raw->dev); 303 err = misc_register(&serio_raw->dev);
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 8f56af8cd7a0..c6164b6f476a 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -190,7 +190,7 @@ static int ads7846_read12_ser(struct device *dev, unsigned command)
190{ 190{
191 struct spi_device *spi = to_spi_device(dev); 191 struct spi_device *spi = to_spi_device(dev);
192 struct ads7846 *ts = dev_get_drvdata(dev); 192 struct ads7846 *ts = dev_get_drvdata(dev);
193 struct ser_req *req = kzalloc(sizeof *req, SLAB_KERNEL); 193 struct ser_req *req = kzalloc(sizeof *req, GFP_KERNEL);
194 int status; 194 int status;
195 int sample; 195 int sample;
196 int i; 196 int i;
diff --git a/drivers/isdn/act2000/capi.c b/drivers/isdn/act2000/capi.c
index 6ae6eb322111..946c38cf6f8a 100644
--- a/drivers/isdn/act2000/capi.c
+++ b/drivers/isdn/act2000/capi.c
@@ -627,8 +627,10 @@ handle_ack(act2000_card *card, act2000_chan *chan, __u8 blocknr) {
627} 627}
628 628
629void 629void
630actcapi_dispatch(act2000_card *card) 630actcapi_dispatch(struct work_struct *work)
631{ 631{
632 struct act2000_card *card =
633 container_of(work, struct act2000_card, rcv_tq);
632 struct sk_buff *skb; 634 struct sk_buff *skb;
633 actcapi_msg *msg; 635 actcapi_msg *msg;
634 __u16 ccmd; 636 __u16 ccmd;
diff --git a/drivers/isdn/act2000/capi.h b/drivers/isdn/act2000/capi.h
index 49f453c53c64..e55f6a931f66 100644
--- a/drivers/isdn/act2000/capi.h
+++ b/drivers/isdn/act2000/capi.h
@@ -356,7 +356,7 @@ extern int actcapi_connect_req(act2000_card *, act2000_chan *, char *, char, int
356extern void actcapi_select_b2_protocol_req(act2000_card *, act2000_chan *); 356extern void actcapi_select_b2_protocol_req(act2000_card *, act2000_chan *);
357extern void actcapi_disconnect_b3_req(act2000_card *, act2000_chan *); 357extern void actcapi_disconnect_b3_req(act2000_card *, act2000_chan *);
358extern void actcapi_connect_resp(act2000_card *, act2000_chan *, __u8); 358extern void actcapi_connect_resp(act2000_card *, act2000_chan *, __u8);
359extern void actcapi_dispatch(act2000_card *); 359extern void actcapi_dispatch(struct work_struct *);
360#ifdef DEBUG_MSG 360#ifdef DEBUG_MSG
361extern void actcapi_debug_msg(struct sk_buff *skb, int); 361extern void actcapi_debug_msg(struct sk_buff *skb, int);
362#else 362#else
diff --git a/drivers/isdn/act2000/module.c b/drivers/isdn/act2000/module.c
index d89dcde4eade..90593e2ef872 100644
--- a/drivers/isdn/act2000/module.c
+++ b/drivers/isdn/act2000/module.c
@@ -192,8 +192,11 @@ act2000_set_msn(act2000_card *card, char *eazmsn)
192} 192}
193 193
194static void 194static void
195act2000_transmit(struct act2000_card *card) 195act2000_transmit(struct work_struct *work)
196{ 196{
197 struct act2000_card *card =
198 container_of(work, struct act2000_card, snd_tq);
199
197 switch (card->bus) { 200 switch (card->bus) {
198 case ACT2000_BUS_ISA: 201 case ACT2000_BUS_ISA:
199 act2000_isa_send(card); 202 act2000_isa_send(card);
@@ -207,8 +210,11 @@ act2000_transmit(struct act2000_card *card)
207} 210}
208 211
209static void 212static void
210act2000_receive(struct act2000_card *card) 213act2000_receive(struct work_struct *work)
211{ 214{
215 struct act2000_card *card =
216 container_of(work, struct act2000_card, poll_tq);
217
212 switch (card->bus) { 218 switch (card->bus) {
213 case ACT2000_BUS_ISA: 219 case ACT2000_BUS_ISA:
214 act2000_isa_receive(card); 220 act2000_isa_receive(card);
@@ -227,7 +233,7 @@ act2000_poll(unsigned long data)
227 act2000_card * card = (act2000_card *)data; 233 act2000_card * card = (act2000_card *)data;
228 unsigned long flags; 234 unsigned long flags;
229 235
230 act2000_receive(card); 236 act2000_receive(&card->poll_tq);
231 spin_lock_irqsave(&card->lock, flags); 237 spin_lock_irqsave(&card->lock, flags);
232 mod_timer(&card->ptimer, jiffies+3); 238 mod_timer(&card->ptimer, jiffies+3);
233 spin_unlock_irqrestore(&card->lock, flags); 239 spin_unlock_irqrestore(&card->lock, flags);
@@ -578,9 +584,9 @@ act2000_alloccard(int bus, int port, int irq, char *id)
578 skb_queue_head_init(&card->sndq); 584 skb_queue_head_init(&card->sndq);
579 skb_queue_head_init(&card->rcvq); 585 skb_queue_head_init(&card->rcvq);
580 skb_queue_head_init(&card->ackq); 586 skb_queue_head_init(&card->ackq);
581 INIT_WORK(&card->snd_tq, (void *) (void *) act2000_transmit, card); 587 INIT_WORK(&card->snd_tq, act2000_transmit);
582 INIT_WORK(&card->rcv_tq, (void *) (void *) actcapi_dispatch, card); 588 INIT_WORK(&card->rcv_tq, actcapi_dispatch);
583 INIT_WORK(&card->poll_tq, (void *) (void *) act2000_receive, card); 589 INIT_WORK(&card->poll_tq, act2000_receive);
584 init_timer(&card->ptimer); 590 init_timer(&card->ptimer);
585 card->interface.owner = THIS_MODULE; 591 card->interface.owner = THIS_MODULE;
586 card->interface.channels = ACT2000_BCH; 592 card->interface.channels = ACT2000_BCH;
diff --git a/drivers/isdn/capi/kcapi.c b/drivers/isdn/capi/kcapi.c
index 8c4fcb9027b3..783a25526315 100644
--- a/drivers/isdn/capi/kcapi.c
+++ b/drivers/isdn/capi/kcapi.c
@@ -208,9 +208,10 @@ static void notify_down(u32 contr)
208 } 208 }
209} 209}
210 210
211static void notify_handler(void *data) 211static void notify_handler(struct work_struct *work)
212{ 212{
213 struct capi_notifier *np = data; 213 struct capi_notifier *np =
214 container_of(work, struct capi_notifier, work);
214 215
215 switch (np->cmd) { 216 switch (np->cmd) {
216 case KCI_CONTRUP: 217 case KCI_CONTRUP:
@@ -235,7 +236,7 @@ static int notify_push(unsigned int cmd, u32 controller, u16 applid, u32 ncci)
235 if (!np) 236 if (!np)
236 return -ENOMEM; 237 return -ENOMEM;
237 238
238 INIT_WORK(&np->work, notify_handler, np); 239 INIT_WORK(&np->work, notify_handler);
239 np->cmd = cmd; 240 np->cmd = cmd;
240 np->controller = controller; 241 np->controller = controller;
241 np->applid = applid; 242 np->applid = applid;
@@ -248,10 +249,11 @@ static int notify_push(unsigned int cmd, u32 controller, u16 applid, u32 ncci)
248 249
249/* -------- Receiver ------------------------------------------ */ 250/* -------- Receiver ------------------------------------------ */
250 251
251static void recv_handler(void *_ap) 252static void recv_handler(struct work_struct *work)
252{ 253{
253 struct sk_buff *skb; 254 struct sk_buff *skb;
254 struct capi20_appl *ap = (struct capi20_appl *) _ap; 255 struct capi20_appl *ap =
256 container_of(work, struct capi20_appl, recv_work);
255 257
256 if ((!ap) || (ap->release_in_progress)) 258 if ((!ap) || (ap->release_in_progress))
257 return; 259 return;
@@ -527,7 +529,7 @@ u16 capi20_register(struct capi20_appl *ap)
527 ap->callback = NULL; 529 ap->callback = NULL;
528 init_MUTEX(&ap->recv_sem); 530 init_MUTEX(&ap->recv_sem);
529 skb_queue_head_init(&ap->recv_queue); 531 skb_queue_head_init(&ap->recv_queue);
530 INIT_WORK(&ap->recv_work, recv_handler, (void *)ap); 532 INIT_WORK(&ap->recv_work, recv_handler);
531 ap->release_in_progress = 0; 533 ap->release_in_progress = 0;
532 534
533 write_unlock_irqrestore(&application_lock, flags); 535 write_unlock_irqrestore(&application_lock, flags);
diff --git a/drivers/isdn/divert/isdn_divert.c b/drivers/isdn/divert/isdn_divert.c
index 1f5ebe9ee72c..03319ea5aa0c 100644
--- a/drivers/isdn/divert/isdn_divert.c
+++ b/drivers/isdn/divert/isdn_divert.c
@@ -10,6 +10,8 @@
10 */ 10 */
11 11
12#include <linux/proc_fs.h> 12#include <linux/proc_fs.h>
13#include <linux/timer.h>
14#include <linux/jiffies.h>
13 15
14#include "isdn_divert.h" 16#include "isdn_divert.h"
15 17
diff --git a/drivers/isdn/gigaset/bas-gigaset.c b/drivers/isdn/gigaset/bas-gigaset.c
index 0c937325a1b3..63b629b1cdb2 100644
--- a/drivers/isdn/gigaset/bas-gigaset.c
+++ b/drivers/isdn/gigaset/bas-gigaset.c
@@ -572,7 +572,7 @@ static int atread_submit(struct cardstate *cs, int timeout)
572 ucs->rcvbuf, ucs->rcvbuf_size, 572 ucs->rcvbuf, ucs->rcvbuf_size,
573 read_ctrl_callback, cs->inbuf); 573 read_ctrl_callback, cs->inbuf);
574 574
575 if ((ret = usb_submit_urb(ucs->urb_cmd_in, SLAB_ATOMIC)) != 0) { 575 if ((ret = usb_submit_urb(ucs->urb_cmd_in, GFP_ATOMIC)) != 0) {
576 update_basstate(ucs, 0, BS_ATRDPEND); 576 update_basstate(ucs, 0, BS_ATRDPEND);
577 dev_err(cs->dev, "could not submit HD_READ_ATMESSAGE: %s\n", 577 dev_err(cs->dev, "could not submit HD_READ_ATMESSAGE: %s\n",
578 get_usb_rcmsg(ret)); 578 get_usb_rcmsg(ret));
@@ -747,7 +747,7 @@ static void read_int_callback(struct urb *urb)
747 check_pending(ucs); 747 check_pending(ucs);
748 748
749resubmit: 749resubmit:
750 rc = usb_submit_urb(urb, SLAB_ATOMIC); 750 rc = usb_submit_urb(urb, GFP_ATOMIC);
751 if (unlikely(rc != 0 && rc != -ENODEV)) { 751 if (unlikely(rc != 0 && rc != -ENODEV)) {
752 dev_err(cs->dev, "could not resubmit interrupt URB: %s\n", 752 dev_err(cs->dev, "could not resubmit interrupt URB: %s\n",
753 get_usb_rcmsg(rc)); 753 get_usb_rcmsg(rc));
@@ -807,7 +807,7 @@ static void read_iso_callback(struct urb *urb)
807 urb->number_of_packets = BAS_NUMFRAMES; 807 urb->number_of_packets = BAS_NUMFRAMES;
808 gig_dbg(DEBUG_ISO, "%s: isoc read overrun/resubmit", 808 gig_dbg(DEBUG_ISO, "%s: isoc read overrun/resubmit",
809 __func__); 809 __func__);
810 rc = usb_submit_urb(urb, SLAB_ATOMIC); 810 rc = usb_submit_urb(urb, GFP_ATOMIC);
811 if (unlikely(rc != 0 && rc != -ENODEV)) { 811 if (unlikely(rc != 0 && rc != -ENODEV)) {
812 dev_err(bcs->cs->dev, 812 dev_err(bcs->cs->dev,
813 "could not resubmit isochronous read " 813 "could not resubmit isochronous read "
@@ -900,7 +900,7 @@ static int starturbs(struct bc_state *bcs)
900 } 900 }
901 901
902 dump_urb(DEBUG_ISO, "Initial isoc read", urb); 902 dump_urb(DEBUG_ISO, "Initial isoc read", urb);
903 if ((rc = usb_submit_urb(urb, SLAB_ATOMIC)) != 0) 903 if ((rc = usb_submit_urb(urb, GFP_ATOMIC)) != 0)
904 goto error; 904 goto error;
905 } 905 }
906 906
@@ -935,7 +935,7 @@ static int starturbs(struct bc_state *bcs)
935 /* submit two URBs, keep third one */ 935 /* submit two URBs, keep third one */
936 for (k = 0; k < 2; ++k) { 936 for (k = 0; k < 2; ++k) {
937 dump_urb(DEBUG_ISO, "Initial isoc write", urb); 937 dump_urb(DEBUG_ISO, "Initial isoc write", urb);
938 rc = usb_submit_urb(ubc->isoouturbs[k].urb, SLAB_ATOMIC); 938 rc = usb_submit_urb(ubc->isoouturbs[k].urb, GFP_ATOMIC);
939 if (rc != 0) 939 if (rc != 0)
940 goto error; 940 goto error;
941 } 941 }
@@ -1042,7 +1042,7 @@ static int submit_iso_write_urb(struct isow_urbctx_t *ucx)
1042 return 0; /* no data to send */ 1042 return 0; /* no data to send */
1043 urb->number_of_packets = nframe; 1043 urb->number_of_packets = nframe;
1044 1044
1045 rc = usb_submit_urb(urb, SLAB_ATOMIC); 1045 rc = usb_submit_urb(urb, GFP_ATOMIC);
1046 if (unlikely(rc)) { 1046 if (unlikely(rc)) {
1047 if (rc == -ENODEV) 1047 if (rc == -ENODEV)
1048 /* device removed - give up silently */ 1048 /* device removed - give up silently */
@@ -1341,7 +1341,7 @@ static void read_iso_tasklet(unsigned long data)
1341 urb->dev = bcs->cs->hw.bas->udev; 1341 urb->dev = bcs->cs->hw.bas->udev;
1342 urb->transfer_flags = URB_ISO_ASAP; 1342 urb->transfer_flags = URB_ISO_ASAP;
1343 urb->number_of_packets = BAS_NUMFRAMES; 1343 urb->number_of_packets = BAS_NUMFRAMES;
1344 rc = usb_submit_urb(urb, SLAB_ATOMIC); 1344 rc = usb_submit_urb(urb, GFP_ATOMIC);
1345 if (unlikely(rc != 0 && rc != -ENODEV)) { 1345 if (unlikely(rc != 0 && rc != -ENODEV)) {
1346 dev_err(cs->dev, 1346 dev_err(cs->dev,
1347 "could not resubmit isochronous read URB: %s\n", 1347 "could not resubmit isochronous read URB: %s\n",
@@ -1458,7 +1458,7 @@ static void write_ctrl_callback(struct urb *urb)
1458 ucs->retry_ctrl); 1458 ucs->retry_ctrl);
1459 /* urb->dev is clobbered by USB subsystem */ 1459 /* urb->dev is clobbered by USB subsystem */
1460 urb->dev = ucs->udev; 1460 urb->dev = ucs->udev;
1461 rc = usb_submit_urb(urb, SLAB_ATOMIC); 1461 rc = usb_submit_urb(urb, GFP_ATOMIC);
1462 if (unlikely(rc)) { 1462 if (unlikely(rc)) {
1463 dev_err(&ucs->interface->dev, 1463 dev_err(&ucs->interface->dev,
1464 "could not resubmit request 0x%02x: %s\n", 1464 "could not resubmit request 0x%02x: %s\n",
@@ -1517,7 +1517,7 @@ static int req_submit(struct bc_state *bcs, int req, int val, int timeout)
1517 (unsigned char*) &ucs->dr_ctrl, NULL, 0, 1517 (unsigned char*) &ucs->dr_ctrl, NULL, 0,
1518 write_ctrl_callback, ucs); 1518 write_ctrl_callback, ucs);
1519 ucs->retry_ctrl = 0; 1519 ucs->retry_ctrl = 0;
1520 ret = usb_submit_urb(ucs->urb_ctrl, SLAB_ATOMIC); 1520 ret = usb_submit_urb(ucs->urb_ctrl, GFP_ATOMIC);
1521 if (unlikely(ret)) { 1521 if (unlikely(ret)) {
1522 dev_err(bcs->cs->dev, "could not submit request 0x%02x: %s\n", 1522 dev_err(bcs->cs->dev, "could not submit request 0x%02x: %s\n",
1523 req, get_usb_rcmsg(ret)); 1523 req, get_usb_rcmsg(ret));
@@ -1763,7 +1763,7 @@ static int atwrite_submit(struct cardstate *cs, unsigned char *buf, int len)
1763 usb_sndctrlpipe(ucs->udev, 0), 1763 usb_sndctrlpipe(ucs->udev, 0),
1764 (unsigned char*) &ucs->dr_cmd_out, buf, len, 1764 (unsigned char*) &ucs->dr_cmd_out, buf, len,
1765 write_command_callback, cs); 1765 write_command_callback, cs);
1766 rc = usb_submit_urb(ucs->urb_cmd_out, SLAB_ATOMIC); 1766 rc = usb_submit_urb(ucs->urb_cmd_out, GFP_ATOMIC);
1767 if (unlikely(rc)) { 1767 if (unlikely(rc)) {
1768 update_basstate(ucs, 0, BS_ATWRPEND); 1768 update_basstate(ucs, 0, BS_ATWRPEND);
1769 dev_err(cs->dev, "could not submit HD_WRITE_ATMESSAGE: %s\n", 1769 dev_err(cs->dev, "could not submit HD_WRITE_ATMESSAGE: %s\n",
@@ -2218,21 +2218,21 @@ static int gigaset_probe(struct usb_interface *interface,
2218 * - three for the different uses of the default control pipe 2218 * - three for the different uses of the default control pipe
2219 * - three for each isochronous pipe 2219 * - three for each isochronous pipe
2220 */ 2220 */
2221 if (!(ucs->urb_int_in = usb_alloc_urb(0, SLAB_KERNEL)) || 2221 if (!(ucs->urb_int_in = usb_alloc_urb(0, GFP_KERNEL)) ||
2222 !(ucs->urb_cmd_in = usb_alloc_urb(0, SLAB_KERNEL)) || 2222 !(ucs->urb_cmd_in = usb_alloc_urb(0, GFP_KERNEL)) ||
2223 !(ucs->urb_cmd_out = usb_alloc_urb(0, SLAB_KERNEL)) || 2223 !(ucs->urb_cmd_out = usb_alloc_urb(0, GFP_KERNEL)) ||
2224 !(ucs->urb_ctrl = usb_alloc_urb(0, SLAB_KERNEL))) 2224 !(ucs->urb_ctrl = usb_alloc_urb(0, GFP_KERNEL)))
2225 goto allocerr; 2225 goto allocerr;
2226 2226
2227 for (j = 0; j < 2; ++j) { 2227 for (j = 0; j < 2; ++j) {
2228 ubc = cs->bcs[j].hw.bas; 2228 ubc = cs->bcs[j].hw.bas;
2229 for (i = 0; i < BAS_OUTURBS; ++i) 2229 for (i = 0; i < BAS_OUTURBS; ++i)
2230 if (!(ubc->isoouturbs[i].urb = 2230 if (!(ubc->isoouturbs[i].urb =
2231 usb_alloc_urb(BAS_NUMFRAMES, SLAB_KERNEL))) 2231 usb_alloc_urb(BAS_NUMFRAMES, GFP_KERNEL)))
2232 goto allocerr; 2232 goto allocerr;
2233 for (i = 0; i < BAS_INURBS; ++i) 2233 for (i = 0; i < BAS_INURBS; ++i)
2234 if (!(ubc->isoinurbs[i] = 2234 if (!(ubc->isoinurbs[i] =
2235 usb_alloc_urb(BAS_NUMFRAMES, SLAB_KERNEL))) 2235 usb_alloc_urb(BAS_NUMFRAMES, GFP_KERNEL)))
2236 goto allocerr; 2236 goto allocerr;
2237 } 2237 }
2238 2238
@@ -2246,7 +2246,7 @@ static int gigaset_probe(struct usb_interface *interface,
2246 (endpoint->bEndpointAddress) & 0x0f), 2246 (endpoint->bEndpointAddress) & 0x0f),
2247 ucs->int_in_buf, 3, read_int_callback, cs, 2247 ucs->int_in_buf, 3, read_int_callback, cs,
2248 endpoint->bInterval); 2248 endpoint->bInterval);
2249 if ((rc = usb_submit_urb(ucs->urb_int_in, SLAB_KERNEL)) != 0) { 2249 if ((rc = usb_submit_urb(ucs->urb_int_in, GFP_KERNEL)) != 0) {
2250 dev_err(cs->dev, "could not submit interrupt URB: %s\n", 2250 dev_err(cs->dev, "could not submit interrupt URB: %s\n",
2251 get_usb_rcmsg(rc)); 2251 get_usb_rcmsg(rc));
2252 goto error; 2252 goto error;
diff --git a/drivers/isdn/gigaset/common.c b/drivers/isdn/gigaset/common.c
index d8d256dadddf..defd5743dba6 100644
--- a/drivers/isdn/gigaset/common.c
+++ b/drivers/isdn/gigaset/common.c
@@ -616,7 +616,7 @@ static struct bc_state *gigaset_initbcs(struct bc_state *bcs,
616 } else if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL) 616 } else if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL)
617 skb_reserve(bcs->skb, HW_HDR_LEN); 617 skb_reserve(bcs->skb, HW_HDR_LEN);
618 else { 618 else {
619 gig_dbg(DEBUG_INIT, "could not allocate skb\n"); 619 warn("could not allocate skb\n");
620 bcs->inputstate |= INS_skip_frame; 620 bcs->inputstate |= INS_skip_frame;
621 } 621 }
622 622
@@ -702,7 +702,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
702 cs->open_count = 0; 702 cs->open_count = 0;
703 cs->dev = NULL; 703 cs->dev = NULL;
704 cs->tty = NULL; 704 cs->tty = NULL;
705 cs->class = NULL; 705 cs->tty_dev = NULL;
706 cs->cidmode = cidmode != 0; 706 cs->cidmode = cidmode != 0;
707 707
708 //if(onechannel) { //FIXME 708 //if(onechannel) { //FIXME
diff --git a/drivers/isdn/gigaset/gigaset.h b/drivers/isdn/gigaset/gigaset.h
index 884bd72c1bf4..06298cc52bf5 100644
--- a/drivers/isdn/gigaset/gigaset.h
+++ b/drivers/isdn/gigaset/gigaset.h
@@ -444,7 +444,7 @@ struct cardstate {
444 struct gigaset_driver *driver; 444 struct gigaset_driver *driver;
445 unsigned minor_index; 445 unsigned minor_index;
446 struct device *dev; 446 struct device *dev;
447 struct class_device *class; 447 struct device *tty_dev;
448 448
449 const struct gigaset_ops *ops; 449 const struct gigaset_ops *ops;
450 450
diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
index 596f3aebe2f7..7edea015867e 100644
--- a/drivers/isdn/gigaset/interface.c
+++ b/drivers/isdn/gigaset/interface.c
@@ -625,13 +625,13 @@ void gigaset_if_init(struct cardstate *cs)
625 return; 625 return;
626 626
627 tasklet_init(&cs->if_wake_tasklet, &if_wake, (unsigned long) cs); 627 tasklet_init(&cs->if_wake_tasklet, &if_wake, (unsigned long) cs);
628 cs->class = tty_register_device(drv->tty, cs->minor_index, NULL); 628 cs->tty_dev = tty_register_device(drv->tty, cs->minor_index, NULL);
629 629
630 if (!IS_ERR(cs->class)) 630 if (!IS_ERR(cs->tty_dev))
631 class_set_devdata(cs->class, cs); 631 dev_set_drvdata(cs->tty_dev, cs);
632 else { 632 else {
633 warn("could not register device to the tty subsystem"); 633 warn("could not register device to the tty subsystem");
634 cs->class = NULL; 634 cs->tty_dev = NULL;
635 } 635 }
636} 636}
637 637
@@ -645,7 +645,7 @@ void gigaset_if_free(struct cardstate *cs)
645 645
646 tasklet_disable(&cs->if_wake_tasklet); 646 tasklet_disable(&cs->if_wake_tasklet);
647 tasklet_kill(&cs->if_wake_tasklet); 647 tasklet_kill(&cs->if_wake_tasklet);
648 cs->class = NULL; 648 cs->tty_dev = NULL;
649 tty_unregister_device(drv->tty, cs->minor_index); 649 tty_unregister_device(drv->tty, cs->minor_index);
650} 650}
651 651
diff --git a/drivers/isdn/gigaset/proc.c b/drivers/isdn/gigaset/proc.c
index 9ad840e95dbe..e767afa55abf 100644
--- a/drivers/isdn/gigaset/proc.c
+++ b/drivers/isdn/gigaset/proc.c
@@ -16,11 +16,12 @@
16#include "gigaset.h" 16#include "gigaset.h"
17#include <linux/ctype.h> 17#include <linux/ctype.h>
18 18
19static ssize_t show_cidmode(struct class_device *class, char *buf) 19static ssize_t show_cidmode(struct device *dev,
20 struct device_attribute *attr, char *buf)
20{ 21{
21 int ret; 22 int ret;
22 unsigned long flags; 23 unsigned long flags;
23 struct cardstate *cs = class_get_devdata(class); 24 struct cardstate *cs = dev_get_drvdata(dev);
24 25
25 spin_lock_irqsave(&cs->lock, flags); 26 spin_lock_irqsave(&cs->lock, flags);
26 ret = sprintf(buf, "%u\n", cs->cidmode); 27 ret = sprintf(buf, "%u\n", cs->cidmode);
@@ -29,10 +30,10 @@ static ssize_t show_cidmode(struct class_device *class, char *buf)
29 return ret; 30 return ret;
30} 31}
31 32
32static ssize_t set_cidmode(struct class_device *class, 33static ssize_t set_cidmode(struct device *dev, struct device_attribute *attr,
33 const char *buf, size_t count) 34 const char *buf, size_t count)
34{ 35{
35 struct cardstate *cs = class_get_devdata(class); 36 struct cardstate *cs = dev_get_drvdata(dev);
36 long int value; 37 long int value;
37 char *end; 38 char *end;
38 39
@@ -64,25 +65,25 @@ static ssize_t set_cidmode(struct class_device *class,
64 return count; 65 return count;
65} 66}
66 67
67static CLASS_DEVICE_ATTR(cidmode, S_IRUGO|S_IWUSR, show_cidmode, set_cidmode); 68static DEVICE_ATTR(cidmode, S_IRUGO|S_IWUSR, show_cidmode, set_cidmode);
68 69
69/* free sysfs for device */ 70/* free sysfs for device */
70void gigaset_free_dev_sysfs(struct cardstate *cs) 71void gigaset_free_dev_sysfs(struct cardstate *cs)
71{ 72{
72 if (!cs->class) 73 if (!cs->tty_dev)
73 return; 74 return;
74 75
75 gig_dbg(DEBUG_INIT, "removing sysfs entries"); 76 gig_dbg(DEBUG_INIT, "removing sysfs entries");
76 class_device_remove_file(cs->class, &class_device_attr_cidmode); 77 device_remove_file(cs->tty_dev, &dev_attr_cidmode);
77} 78}
78 79
79/* initialize sysfs for device */ 80/* initialize sysfs for device */
80void gigaset_init_dev_sysfs(struct cardstate *cs) 81void gigaset_init_dev_sysfs(struct cardstate *cs)
81{ 82{
82 if (!cs->class) 83 if (!cs->tty_dev)
83 return; 84 return;
84 85
85 gig_dbg(DEBUG_INIT, "setting up sysfs"); 86 gig_dbg(DEBUG_INIT, "setting up sysfs");
86 if (class_device_create_file(cs->class, &class_device_attr_cidmode)) 87 if (device_create_file(cs->tty_dev, &dev_attr_cidmode))
87 dev_err(cs->dev, "could not create sysfs attribute\n"); 88 dev_err(cs->dev, "could not create sysfs attribute\n");
88} 89}
diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c
index 4ffa9eb1c28e..04f2ad7ba8b0 100644
--- a/drivers/isdn/gigaset/usb-gigaset.c
+++ b/drivers/isdn/gigaset/usb-gigaset.c
@@ -410,7 +410,7 @@ static void gigaset_read_int_callback(struct urb *urb)
410 410
411 if (resubmit) { 411 if (resubmit) {
412 spin_lock_irqsave(&cs->lock, flags); 412 spin_lock_irqsave(&cs->lock, flags);
413 r = cs->connected ? usb_submit_urb(urb, SLAB_ATOMIC) : -ENODEV; 413 r = cs->connected ? usb_submit_urb(urb, GFP_ATOMIC) : -ENODEV;
414 spin_unlock_irqrestore(&cs->lock, flags); 414 spin_unlock_irqrestore(&cs->lock, flags);
415 if (r) 415 if (r)
416 dev_err(cs->dev, "error %d when resubmitting urb.\n", 416 dev_err(cs->dev, "error %d when resubmitting urb.\n",
@@ -486,7 +486,7 @@ static int send_cb(struct cardstate *cs, struct cmdbuf_t *cb)
486 atomic_set(&ucs->busy, 1); 486 atomic_set(&ucs->busy, 1);
487 487
488 spin_lock_irqsave(&cs->lock, flags); 488 spin_lock_irqsave(&cs->lock, flags);
489 status = cs->connected ? usb_submit_urb(ucs->bulk_out_urb, SLAB_ATOMIC) : -ENODEV; 489 status = cs->connected ? usb_submit_urb(ucs->bulk_out_urb, GFP_ATOMIC) : -ENODEV;
490 spin_unlock_irqrestore(&cs->lock, flags); 490 spin_unlock_irqrestore(&cs->lock, flags);
491 491
492 if (status) { 492 if (status) {
@@ -664,7 +664,7 @@ static int write_modem(struct cardstate *cs)
664 ucs->bulk_out_endpointAddr & 0x0f), 664 ucs->bulk_out_endpointAddr & 0x0f),
665 ucs->bulk_out_buffer, count, 665 ucs->bulk_out_buffer, count,
666 gigaset_write_bulk_callback, cs); 666 gigaset_write_bulk_callback, cs);
667 ret = usb_submit_urb(ucs->bulk_out_urb, SLAB_ATOMIC); 667 ret = usb_submit_urb(ucs->bulk_out_urb, GFP_ATOMIC);
668 } else { 668 } else {
669 ret = -ENODEV; 669 ret = -ENODEV;
670 } 670 }
@@ -763,7 +763,7 @@ static int gigaset_probe(struct usb_interface *interface,
763 goto error; 763 goto error;
764 } 764 }
765 765
766 ucs->bulk_out_urb = usb_alloc_urb(0, SLAB_KERNEL); 766 ucs->bulk_out_urb = usb_alloc_urb(0, GFP_KERNEL);
767 if (!ucs->bulk_out_urb) { 767 if (!ucs->bulk_out_urb) {
768 dev_err(cs->dev, "Couldn't allocate bulk_out_urb\n"); 768 dev_err(cs->dev, "Couldn't allocate bulk_out_urb\n");
769 retval = -ENOMEM; 769 retval = -ENOMEM;
@@ -774,7 +774,7 @@ static int gigaset_probe(struct usb_interface *interface,
774 774
775 atomic_set(&ucs->busy, 0); 775 atomic_set(&ucs->busy, 0);
776 776
777 ucs->read_urb = usb_alloc_urb(0, SLAB_KERNEL); 777 ucs->read_urb = usb_alloc_urb(0, GFP_KERNEL);
778 if (!ucs->read_urb) { 778 if (!ucs->read_urb) {
779 dev_err(cs->dev, "No free urbs available\n"); 779 dev_err(cs->dev, "No free urbs available\n");
780 retval = -ENOMEM; 780 retval = -ENOMEM;
@@ -797,7 +797,7 @@ static int gigaset_probe(struct usb_interface *interface,
797 gigaset_read_int_callback, 797 gigaset_read_int_callback,
798 cs->inbuf + 0, endpoint->bInterval); 798 cs->inbuf + 0, endpoint->bInterval);
799 799
800 retval = usb_submit_urb(ucs->read_urb, SLAB_KERNEL); 800 retval = usb_submit_urb(ucs->read_urb, GFP_KERNEL);
801 if (retval) { 801 if (retval) {
802 dev_err(cs->dev, "Could not submit URB (error %d)\n", -retval); 802 dev_err(cs->dev, "Could not submit URB (error %d)\n", -retval);
803 goto error; 803 goto error;
@@ -815,14 +815,11 @@ static int gigaset_probe(struct usb_interface *interface,
815 return 0; 815 return 0;
816 816
817error: 817error:
818 if (ucs->read_urb) 818 usb_kill_urb(ucs->read_urb);
819 usb_kill_urb(ucs->read_urb);
820 kfree(ucs->bulk_out_buffer); 819 kfree(ucs->bulk_out_buffer);
821 if (ucs->bulk_out_urb != NULL) 820 usb_free_urb(ucs->bulk_out_urb);
822 usb_free_urb(ucs->bulk_out_urb);
823 kfree(cs->inbuf[0].rcvbuf); 821 kfree(cs->inbuf[0].rcvbuf);
824 if (ucs->read_urb != NULL) 822 usb_free_urb(ucs->read_urb);
825 usb_free_urb(ucs->read_urb);
826 usb_set_intfdata(interface, NULL); 823 usb_set_intfdata(interface, NULL);
827 ucs->read_urb = ucs->bulk_out_urb = NULL; 824 ucs->read_urb = ucs->bulk_out_urb = NULL;
828 cs->inbuf[0].rcvbuf = ucs->bulk_out_buffer = NULL; 825 cs->inbuf[0].rcvbuf = ucs->bulk_out_buffer = NULL;
@@ -850,11 +847,9 @@ static void gigaset_disconnect(struct usb_interface *interface)
850 usb_kill_urb(ucs->bulk_out_urb); /* FIXME: only if active? */ 847 usb_kill_urb(ucs->bulk_out_urb); /* FIXME: only if active? */
851 848
852 kfree(ucs->bulk_out_buffer); 849 kfree(ucs->bulk_out_buffer);
853 if (ucs->bulk_out_urb != NULL) 850 usb_free_urb(ucs->bulk_out_urb);
854 usb_free_urb(ucs->bulk_out_urb);
855 kfree(cs->inbuf[0].rcvbuf); 851 kfree(cs->inbuf[0].rcvbuf);
856 if (ucs->read_urb != NULL) 852 usb_free_urb(ucs->read_urb);
857 usb_free_urb(ucs->read_urb);
858 ucs->read_urb = ucs->bulk_out_urb = NULL; 853 ucs->read_urb = ucs->bulk_out_urb = NULL;
859 cs->inbuf[0].rcvbuf = ucs->bulk_out_buffer = NULL; 854 cs->inbuf[0].rcvbuf = ucs->bulk_out_buffer = NULL;
860 855
diff --git a/drivers/isdn/hardware/avm/avm_cs.c b/drivers/isdn/hardware/avm/avm_cs.c
index 7bbfd85ab793..fd5d7364a487 100644
--- a/drivers/isdn/hardware/avm/avm_cs.c
+++ b/drivers/isdn/hardware/avm/avm_cs.c
@@ -194,41 +194,11 @@ static int avmcs_config(struct pcmcia_device *link)
194 194
195 dev = link->priv; 195 dev = link->priv;
196 196
197 /*
198 This reads the card's CONFIG tuple to find its configuration
199 registers.
200 */
201 do { 197 do {
202 tuple.DesiredTuple = CISTPL_CONFIG;
203 i = pcmcia_get_first_tuple(link, &tuple);
204 if (i != CS_SUCCESS) break;
205 tuple.TupleData = buf;
206 tuple.TupleDataMax = 64;
207 tuple.TupleOffset = 0;
208 i = pcmcia_get_tuple_data(link, &tuple);
209 if (i != CS_SUCCESS) break;
210 i = pcmcia_parse_tuple(link, &tuple, &parse);
211 if (i != CS_SUCCESS) break;
212 link->conf.ConfigBase = parse.config.base;
213 } while (0);
214 if (i != CS_SUCCESS) {
215 cs_error(link, ParseTuple, i);
216 return -ENODEV;
217 }
218
219 do {
220
221 tuple.Attributes = 0;
222 tuple.TupleData = buf;
223 tuple.TupleDataMax = 254;
224 tuple.TupleOffset = 0;
225 tuple.DesiredTuple = CISTPL_VERS_1;
226
227 devname[0] = 0; 198 devname[0] = 0;
228 if( !first_tuple(link, &tuple, &parse) && parse.version_1.ns > 1 ) { 199 if (link->prod_id[1])
229 strlcpy(devname,parse.version_1.str + parse.version_1.ofs[1], 200 strlcpy(devname, link->prod_id[1], sizeof(devname));
230 sizeof(devname)); 201
231 }
232 /* 202 /*
233 * find IO port 203 * find IO port
234 */ 204 */
diff --git a/drivers/isdn/hardware/eicon/os_4bri.c b/drivers/isdn/hardware/eicon/os_4bri.c
index 11e6f937c1e4..7b4ec3f60dbf 100644
--- a/drivers/isdn/hardware/eicon/os_4bri.c
+++ b/drivers/isdn/hardware/eicon/os_4bri.c
@@ -464,7 +464,7 @@ int diva_4bri_init_card(diva_os_xdi_adapter_t * a)
464 464
465/* 465/*
466** Cleanup function will be called for master adapter only 466** Cleanup function will be called for master adapter only
467** this is garanteed by design: cleanup callback is set 467** this is guaranteed by design: cleanup callback is set
468** by master adapter only 468** by master adapter only
469*/ 469*/
470static int diva_4bri_cleanup_adapter(diva_os_xdi_adapter_t * a) 470static int diva_4bri_cleanup_adapter(diva_os_xdi_adapter_t * a)
diff --git a/drivers/isdn/hisax/Kconfig b/drivers/isdn/hisax/Kconfig
index eb57a988e048..cfd2718a490d 100644
--- a/drivers/isdn/hisax/Kconfig
+++ b/drivers/isdn/hisax/Kconfig
@@ -344,7 +344,7 @@ config HISAX_HFC_SX
344 344
345config HISAX_ENTERNOW_PCI 345config HISAX_ENTERNOW_PCI
346 bool "Formula-n enter:now PCI card" 346 bool "Formula-n enter:now PCI card"
347 depends on PCI && (BROKEN || !(SPARC || PPC || PARISC || M68K || FRV)) 347 depends on HISAX_NETJET && PCI && (BROKEN || !(SPARC || PPC || PARISC || M68K || FRV))
348 help 348 help
349 This enables HiSax support for the Formula-n enter:now PCI 349 This enables HiSax support for the Formula-n enter:now PCI
350 ISDN card. 350 ISDN card.
diff --git a/drivers/isdn/hisax/amd7930_fn.c b/drivers/isdn/hisax/amd7930_fn.c
index bec59010bc66..3b19caeba258 100644
--- a/drivers/isdn/hisax/amd7930_fn.c
+++ b/drivers/isdn/hisax/amd7930_fn.c
@@ -232,9 +232,10 @@ Amd7930_new_ph(struct IsdnCardState *cs)
232 232
233 233
234static void 234static void
235Amd7930_bh(struct IsdnCardState *cs) 235Amd7930_bh(struct work_struct *work)
236{ 236{
237 237 struct IsdnCardState *cs =
238 container_of(work, struct IsdnCardState, tqueue);
238 struct PStack *stptr; 239 struct PStack *stptr;
239 240
240 if (!cs) 241 if (!cs)
@@ -789,7 +790,7 @@ Amd7930_init(struct IsdnCardState *cs)
789void __devinit 790void __devinit
790setup_Amd7930(struct IsdnCardState *cs) 791setup_Amd7930(struct IsdnCardState *cs)
791{ 792{
792 INIT_WORK(&cs->tqueue, (void *)(void *) Amd7930_bh, cs); 793 INIT_WORK(&cs->tqueue, Amd7930_bh);
793 cs->dbusytimer.function = (void *) dbusy_timer_handler; 794 cs->dbusytimer.function = (void *) dbusy_timer_handler;
794 cs->dbusytimer.data = (long) cs; 795 cs->dbusytimer.data = (long) cs;
795 init_timer(&cs->dbusytimer); 796 init_timer(&cs->dbusytimer);
diff --git a/drivers/isdn/hisax/avma1_cs.c b/drivers/isdn/hisax/avma1_cs.c
index ac28e3278ad9..876fec6c6be8 100644
--- a/drivers/isdn/hisax/avma1_cs.c
+++ b/drivers/isdn/hisax/avma1_cs.c
@@ -216,41 +216,11 @@ static int avma1cs_config(struct pcmcia_device *link)
216 216
217 DEBUG(0, "avma1cs_config(0x%p)\n", link); 217 DEBUG(0, "avma1cs_config(0x%p)\n", link);
218 218
219 /*
220 This reads the card's CONFIG tuple to find its configuration
221 registers.
222 */
223 do { 219 do {
224 tuple.DesiredTuple = CISTPL_CONFIG;
225 i = pcmcia_get_first_tuple(link, &tuple);
226 if (i != CS_SUCCESS) break;
227 tuple.TupleData = buf;
228 tuple.TupleDataMax = 64;
229 tuple.TupleOffset = 0;
230 i = pcmcia_get_tuple_data(link, &tuple);
231 if (i != CS_SUCCESS) break;
232 i = pcmcia_parse_tuple(link, &tuple, &parse);
233 if (i != CS_SUCCESS) break;
234 link->conf.ConfigBase = parse.config.base;
235 } while (0);
236 if (i != CS_SUCCESS) {
237 cs_error(link, ParseTuple, i);
238 return -ENODEV;
239 }
240
241 do {
242
243 tuple.Attributes = 0;
244 tuple.TupleData = buf;
245 tuple.TupleDataMax = 254;
246 tuple.TupleOffset = 0;
247 tuple.DesiredTuple = CISTPL_VERS_1;
248
249 devname[0] = 0; 220 devname[0] = 0;
250 if( !first_tuple(link, &tuple, &parse) && parse.version_1.ns > 1 ) { 221 if (link->prod_id[1])
251 strlcpy(devname,parse.version_1.str + parse.version_1.ofs[1], 222 strlcpy(devname, link->prod_id[1], sizeof(devname));
252 sizeof(devname)); 223
253 }
254 /* 224 /*
255 * find IO port 225 * find IO port
256 */ 226 */
diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
index 785b08554fca..cede72cdbb31 100644
--- a/drivers/isdn/hisax/config.c
+++ b/drivers/isdn/hisax/config.c
@@ -1137,7 +1137,6 @@ static int checkcard(int cardnr, char *id, int *busy_flag, struct module *lockow
1137 cs->tx_skb = NULL; 1137 cs->tx_skb = NULL;
1138 cs->tx_cnt = 0; 1138 cs->tx_cnt = 0;
1139 cs->event = 0; 1139 cs->event = 0;
1140 cs->tqueue.data = cs;
1141 1140
1142 skb_queue_head_init(&cs->rq); 1141 skb_queue_head_init(&cs->rq);
1143 skb_queue_head_init(&cs->sq); 1142 skb_queue_head_init(&cs->sq);
@@ -1554,7 +1553,7 @@ static void hisax_b_l2l1(struct PStack *st, int pr, void *arg);
1554static int hisax_cardmsg(struct IsdnCardState *cs, int mt, void *arg); 1553static int hisax_cardmsg(struct IsdnCardState *cs, int mt, void *arg);
1555static int hisax_bc_setstack(struct PStack *st, struct BCState *bcs); 1554static int hisax_bc_setstack(struct PStack *st, struct BCState *bcs);
1556static void hisax_bc_close(struct BCState *bcs); 1555static void hisax_bc_close(struct BCState *bcs);
1557static void hisax_bh(struct IsdnCardState *cs); 1556static void hisax_bh(struct work_struct *work);
1558static void EChannel_proc_rcv(struct hisax_d_if *d_if); 1557static void EChannel_proc_rcv(struct hisax_d_if *d_if);
1559 1558
1560int hisax_register(struct hisax_d_if *hisax_d_if, struct hisax_b_if *b_if[], 1559int hisax_register(struct hisax_d_if *hisax_d_if, struct hisax_b_if *b_if[],
@@ -1586,7 +1585,7 @@ int hisax_register(struct hisax_d_if *hisax_d_if, struct hisax_b_if *b_if[],
1586 hisax_d_if->cs = cs; 1585 hisax_d_if->cs = cs;
1587 cs->hw.hisax_d_if = hisax_d_if; 1586 cs->hw.hisax_d_if = hisax_d_if;
1588 cs->cardmsg = hisax_cardmsg; 1587 cs->cardmsg = hisax_cardmsg;
1589 INIT_WORK(&cs->tqueue, (void *)(void *)hisax_bh, cs); 1588 INIT_WORK(&cs->tqueue, hisax_bh);
1590 cs->channel[0].d_st->l2.l2l1 = hisax_d_l2l1; 1589 cs->channel[0].d_st->l2.l2l1 = hisax_d_l2l1;
1591 for (i = 0; i < 2; i++) { 1590 for (i = 0; i < 2; i++) {
1592 cs->bcs[i].BC_SetStack = hisax_bc_setstack; 1591 cs->bcs[i].BC_SetStack = hisax_bc_setstack;
@@ -1618,8 +1617,10 @@ static void hisax_sched_event(struct IsdnCardState *cs, int event)
1618 schedule_work(&cs->tqueue); 1617 schedule_work(&cs->tqueue);
1619} 1618}
1620 1619
1621static void hisax_bh(struct IsdnCardState *cs) 1620static void hisax_bh(struct work_struct *work)
1622{ 1621{
1622 struct IsdnCardState *cs =
1623 container_of(work, struct IsdnCardState, tqueue);
1623 struct PStack *st; 1624 struct PStack *st;
1624 int pr; 1625 int pr;
1625 1626
diff --git a/drivers/isdn/hisax/elsa_cs.c b/drivers/isdn/hisax/elsa_cs.c
index e18e75be8ed3..4e180d210faa 100644
--- a/drivers/isdn/hisax/elsa_cs.c
+++ b/drivers/isdn/hisax/elsa_cs.c
@@ -242,23 +242,6 @@ static int elsa_cs_config(struct pcmcia_device *link)
242 DEBUG(0, "elsa_config(0x%p)\n", link); 242 DEBUG(0, "elsa_config(0x%p)\n", link);
243 dev = link->priv; 243 dev = link->priv;
244 244
245 /*
246 This reads the card's CONFIG tuple to find its configuration
247 registers.
248 */
249 tuple.DesiredTuple = CISTPL_CONFIG;
250 tuple.TupleData = (cisdata_t *)buf;
251 tuple.TupleDataMax = 255;
252 tuple.TupleOffset = 0;
253 tuple.Attributes = 0;
254 i = first_tuple(link, &tuple, &parse);
255 if (i != CS_SUCCESS) {
256 last_fn = ParseTuple;
257 goto cs_failed;
258 }
259 link->conf.ConfigBase = parse.config.base;
260 link->conf.Present = parse.config.rmask[0];
261
262 tuple.TupleData = (cisdata_t *)buf; 245 tuple.TupleData = (cisdata_t *)buf;
263 tuple.TupleOffset = 0; tuple.TupleDataMax = 255; 246 tuple.TupleOffset = 0; tuple.TupleDataMax = 255;
264 tuple.Attributes = 0; 247 tuple.Attributes = 0;
diff --git a/drivers/isdn/hisax/hfc4s8s_l1.c b/drivers/isdn/hisax/hfc4s8s_l1.c
index d852c9d998b2..de9b1a4d6bac 100644
--- a/drivers/isdn/hisax/hfc4s8s_l1.c
+++ b/drivers/isdn/hisax/hfc4s8s_l1.c
@@ -1083,8 +1083,9 @@ tx_b_frame(struct hfc4s8s_btype *bch)
1083/* bottom half handler for interrupt */ 1083/* bottom half handler for interrupt */
1084/*************************************/ 1084/*************************************/
1085static void 1085static void
1086hfc4s8s_bh(hfc4s8s_hw * hw) 1086hfc4s8s_bh(struct work_struct *work)
1087{ 1087{
1088 hfc4s8s_hw *hw = container_of(work, hfc4s8s_hw, tqueue);
1088 u_char b; 1089 u_char b;
1089 struct hfc4s8s_l1 *l1p; 1090 struct hfc4s8s_l1 *l1p;
1090 volatile u_char *fifo_stat; 1091 volatile u_char *fifo_stat;
@@ -1550,7 +1551,7 @@ setup_instance(hfc4s8s_hw * hw)
1550 goto out; 1551 goto out;
1551 } 1552 }
1552 1553
1553 INIT_WORK(&hw->tqueue, (void *) (void *) hfc4s8s_bh, hw); 1554 INIT_WORK(&hw->tqueue, hfc4s8s_bh);
1554 1555
1555 if (request_irq 1556 if (request_irq
1556 (hw->irq, hfc4s8s_interrupt, IRQF_SHARED, hw->card_name, hw)) { 1557 (hw->irq, hfc4s8s_interrupt, IRQF_SHARED, hw->card_name, hw)) {
diff --git a/drivers/isdn/hisax/hfc4s8s_l1.h b/drivers/isdn/hisax/hfc4s8s_l1.h
index e8f9c077fa85..9d5d2a56b4e9 100644
--- a/drivers/isdn/hisax/hfc4s8s_l1.h
+++ b/drivers/isdn/hisax/hfc4s8s_l1.h
@@ -16,7 +16,7 @@
16 16
17/* 17/*
18* include Genero generated HFC-4S/8S header file hfc48scu.h 18* include Genero generated HFC-4S/8S header file hfc48scu.h
19* for comlete register description. This will define _HFC48SCU_H_ 19* for complete register description. This will define _HFC48SCU_H_
20* to prevent redefinitions 20* to prevent redefinitions
21*/ 21*/
22 22
diff --git a/drivers/isdn/hisax/hfc_2bds0.c b/drivers/isdn/hisax/hfc_2bds0.c
index 6360e8214720..8d9864453a23 100644
--- a/drivers/isdn/hisax/hfc_2bds0.c
+++ b/drivers/isdn/hisax/hfc_2bds0.c
@@ -549,10 +549,11 @@ setstack_2b(struct PStack *st, struct BCState *bcs)
549} 549}
550 550
551static void 551static void
552hfcd_bh(struct IsdnCardState *cs) 552hfcd_bh(struct work_struct *work)
553{ 553{
554 if (!cs) 554 struct IsdnCardState *cs =
555 return; 555 container_of(work, struct IsdnCardState, tqueue);
556
556 if (test_and_clear_bit(D_L1STATECHANGE, &cs->event)) { 557 if (test_and_clear_bit(D_L1STATECHANGE, &cs->event)) {
557 switch (cs->dc.hfcd.ph_state) { 558 switch (cs->dc.hfcd.ph_state) {
558 case (0): 559 case (0):
@@ -1072,5 +1073,5 @@ set_cs_func(struct IsdnCardState *cs)
1072 cs->dbusytimer.function = (void *) hfc_dbusy_timer; 1073 cs->dbusytimer.function = (void *) hfc_dbusy_timer;
1073 cs->dbusytimer.data = (long) cs; 1074 cs->dbusytimer.data = (long) cs;
1074 init_timer(&cs->dbusytimer); 1075 init_timer(&cs->dbusytimer);
1075 INIT_WORK(&cs->tqueue, (void *)(void *) hfcd_bh, cs); 1076 INIT_WORK(&cs->tqueue, hfcd_bh);
1076} 1077}
diff --git a/drivers/isdn/hisax/hfc_pci.c b/drivers/isdn/hisax/hfc_pci.c
index 93f60b563515..5db0a85b827f 100644
--- a/drivers/isdn/hisax/hfc_pci.c
+++ b/drivers/isdn/hisax/hfc_pci.c
@@ -1506,8 +1506,10 @@ setstack_2b(struct PStack *st, struct BCState *bcs)
1506/* handle L1 state changes */ 1506/* handle L1 state changes */
1507/***************************/ 1507/***************************/
1508static void 1508static void
1509hfcpci_bh(struct IsdnCardState *cs) 1509hfcpci_bh(struct work_struct *work)
1510{ 1510{
1511 struct IsdnCardState *cs =
1512 container_of(work, struct IsdnCardState, tqueue);
1511 u_long flags; 1513 u_long flags;
1512// struct PStack *stptr; 1514// struct PStack *stptr;
1513 1515
@@ -1722,7 +1724,7 @@ setup_hfcpci(struct IsdnCard *card)
1722 Write_hfc(cs, HFCPCI_INT_M2, cs->hw.hfcpci.int_m2); 1724 Write_hfc(cs, HFCPCI_INT_M2, cs->hw.hfcpci.int_m2);
1723 /* At this point the needed PCI config is done */ 1725 /* At this point the needed PCI config is done */
1724 /* fifos are still not enabled */ 1726 /* fifos are still not enabled */
1725 INIT_WORK(&cs->tqueue, (void *)(void *) hfcpci_bh, cs); 1727 INIT_WORK(&cs->tqueue, hfcpci_bh);
1726 cs->setstack_d = setstack_hfcpci; 1728 cs->setstack_d = setstack_hfcpci;
1727 cs->BC_Send_Data = &hfcpci_send_data; 1729 cs->BC_Send_Data = &hfcpci_send_data;
1728 cs->readisac = NULL; 1730 cs->readisac = NULL;
diff --git a/drivers/isdn/hisax/hfc_sx.c b/drivers/isdn/hisax/hfc_sx.c
index 954d1536db1f..4fd09d21a27f 100644
--- a/drivers/isdn/hisax/hfc_sx.c
+++ b/drivers/isdn/hisax/hfc_sx.c
@@ -1251,8 +1251,10 @@ setstack_2b(struct PStack *st, struct BCState *bcs)
1251/* handle L1 state changes */ 1251/* handle L1 state changes */
1252/***************************/ 1252/***************************/
1253static void 1253static void
1254hfcsx_bh(struct IsdnCardState *cs) 1254hfcsx_bh(struct work_struct *work)
1255{ 1255{
1256 struct IsdnCardState *cs =
1257 container_of(work, struct IsdnCardState, tqueue);
1256 u_long flags; 1258 u_long flags;
1257 1259
1258 if (!cs) 1260 if (!cs)
@@ -1499,7 +1501,7 @@ setup_hfcsx(struct IsdnCard *card)
1499 cs->dbusytimer.function = (void *) hfcsx_dbusy_timer; 1501 cs->dbusytimer.function = (void *) hfcsx_dbusy_timer;
1500 cs->dbusytimer.data = (long) cs; 1502 cs->dbusytimer.data = (long) cs;
1501 init_timer(&cs->dbusytimer); 1503 init_timer(&cs->dbusytimer);
1502 INIT_WORK(&cs->tqueue, (void *)(void *) hfcsx_bh, cs); 1504 INIT_WORK(&cs->tqueue, hfcsx_bh);
1503 cs->readisac = NULL; 1505 cs->readisac = NULL;
1504 cs->writeisac = NULL; 1506 cs->writeisac = NULL;
1505 cs->readisacfifo = NULL; 1507 cs->readisacfifo = NULL;
diff --git a/drivers/isdn/hisax/icc.c b/drivers/isdn/hisax/icc.c
index da706925d54d..682cac32f259 100644
--- a/drivers/isdn/hisax/icc.c
+++ b/drivers/isdn/hisax/icc.c
@@ -77,8 +77,10 @@ icc_new_ph(struct IsdnCardState *cs)
77} 77}
78 78
79static void 79static void
80icc_bh(struct IsdnCardState *cs) 80icc_bh(struct work_struct *work)
81{ 81{
82 struct IsdnCardState *cs =
83 container_of(work, struct IsdnCardState, tqueue);
82 struct PStack *stptr; 84 struct PStack *stptr;
83 85
84 if (!cs) 86 if (!cs)
@@ -674,7 +676,7 @@ clear_pending_icc_ints(struct IsdnCardState *cs)
674void __devinit 676void __devinit
675setup_icc(struct IsdnCardState *cs) 677setup_icc(struct IsdnCardState *cs)
676{ 678{
677 INIT_WORK(&cs->tqueue, (void *)(void *) icc_bh, cs); 679 INIT_WORK(&cs->tqueue, icc_bh);
678 cs->dbusytimer.function = (void *) dbusy_timer_handler; 680 cs->dbusytimer.function = (void *) dbusy_timer_handler;
679 cs->dbusytimer.data = (long) cs; 681 cs->dbusytimer.data = (long) cs;
680 init_timer(&cs->dbusytimer); 682 init_timer(&cs->dbusytimer);
diff --git a/drivers/isdn/hisax/isac.c b/drivers/isdn/hisax/isac.c
index 282f349408bc..4e9f23803dae 100644
--- a/drivers/isdn/hisax/isac.c
+++ b/drivers/isdn/hisax/isac.c
@@ -81,8 +81,10 @@ isac_new_ph(struct IsdnCardState *cs)
81} 81}
82 82
83static void 83static void
84isac_bh(struct IsdnCardState *cs) 84isac_bh(struct work_struct *work)
85{ 85{
86 struct IsdnCardState *cs =
87 container_of(work, struct IsdnCardState, tqueue);
86 struct PStack *stptr; 88 struct PStack *stptr;
87 89
88 if (!cs) 90 if (!cs)
@@ -674,7 +676,7 @@ clear_pending_isac_ints(struct IsdnCardState *cs)
674void __devinit 676void __devinit
675setup_isac(struct IsdnCardState *cs) 677setup_isac(struct IsdnCardState *cs)
676{ 678{
677 INIT_WORK(&cs->tqueue, (void *)(void *) isac_bh, cs); 679 INIT_WORK(&cs->tqueue, isac_bh);
678 cs->dbusytimer.function = (void *) dbusy_timer_handler; 680 cs->dbusytimer.function = (void *) dbusy_timer_handler;
679 cs->dbusytimer.data = (long) cs; 681 cs->dbusytimer.data = (long) cs;
680 init_timer(&cs->dbusytimer); 682 init_timer(&cs->dbusytimer);
diff --git a/drivers/isdn/hisax/isar.c b/drivers/isdn/hisax/isar.c
index 674af673ff96..6f1a6583b17d 100644
--- a/drivers/isdn/hisax/isar.c
+++ b/drivers/isdn/hisax/isar.c
@@ -437,8 +437,10 @@ extern void BChannel_bh(struct BCState *);
437#define B_LL_OK 10 437#define B_LL_OK 10
438 438
439static void 439static void
440isar_bh(struct BCState *bcs) 440isar_bh(struct work_struct *work)
441{ 441{
442 struct BCState *bcs = container_of(work, struct BCState, tqueue);
443
442 BChannel_bh(bcs); 444 BChannel_bh(bcs);
443 if (test_and_clear_bit(B_LL_NOCARRIER, &bcs->event)) 445 if (test_and_clear_bit(B_LL_NOCARRIER, &bcs->event))
444 ll_deliver_faxstat(bcs, ISDN_FAX_CLASS1_NOCARR); 446 ll_deliver_faxstat(bcs, ISDN_FAX_CLASS1_NOCARR);
@@ -1580,7 +1582,7 @@ isar_setup(struct IsdnCardState *cs)
1580 cs->bcs[i].mode = 0; 1582 cs->bcs[i].mode = 0;
1581 cs->bcs[i].hw.isar.dpath = i + 1; 1583 cs->bcs[i].hw.isar.dpath = i + 1;
1582 modeisar(&cs->bcs[i], 0, 0); 1584 modeisar(&cs->bcs[i], 0, 0);
1583 INIT_WORK(&cs->bcs[i].tqueue, (void *)(void *) isar_bh, &cs->bcs[i]); 1585 INIT_WORK(&cs->bcs[i].tqueue, isar_bh);
1584 } 1586 }
1585} 1587}
1586 1588
diff --git a/drivers/isdn/hisax/isdnhdlc.h b/drivers/isdn/hisax/isdnhdlc.h
index 269315988dc8..5655b5f9c48e 100644
--- a/drivers/isdn/hisax/isdnhdlc.h
+++ b/drivers/isdn/hisax/isdnhdlc.h
@@ -41,10 +41,10 @@ struct isdnhdlc_vars {
41 unsigned char shift_reg; 41 unsigned char shift_reg;
42 unsigned char ffvalue; 42 unsigned char ffvalue;
43 43
44 int data_received:1; // set if transferring data 44 unsigned int data_received:1; // set if transferring data
45 int dchannel:1; // set if D channel (send idle instead of flags) 45 unsigned int dchannel:1; // set if D channel (send idle instead of flags)
46 int do_adapt56:1; // set if 56K adaptation 46 unsigned int do_adapt56:1; // set if 56K adaptation
47 int do_closing:1; // set if in closing phase (need to send CRC + flag 47 unsigned int do_closing:1; // set if in closing phase (need to send CRC + flag
48}; 48};
49 49
50 50
diff --git a/drivers/isdn/hisax/isdnl1.c b/drivers/isdn/hisax/isdnl1.c
index bab356886483..a14204ec88ee 100644
--- a/drivers/isdn/hisax/isdnl1.c
+++ b/drivers/isdn/hisax/isdnl1.c
@@ -315,8 +315,10 @@ BChannel_proc_ack(struct BCState *bcs)
315} 315}
316 316
317void 317void
318BChannel_bh(struct BCState *bcs) 318BChannel_bh(struct work_struct *work)
319{ 319{
320 struct BCState *bcs = container_of(work, struct BCState, tqueue);
321
320 if (!bcs) 322 if (!bcs)
321 return; 323 return;
322 if (test_and_clear_bit(B_RCVBUFREADY, &bcs->event)) 324 if (test_and_clear_bit(B_RCVBUFREADY, &bcs->event))
@@ -362,7 +364,7 @@ init_bcstate(struct IsdnCardState *cs, int bc)
362 364
363 bcs->cs = cs; 365 bcs->cs = cs;
364 bcs->channel = bc; 366 bcs->channel = bc;
365 INIT_WORK(&bcs->tqueue, (void *)(void *) BChannel_bh, bcs); 367 INIT_WORK(&bcs->tqueue, BChannel_bh);
366 spin_lock_init(&bcs->aclock); 368 spin_lock_init(&bcs->aclock);
367 bcs->BC_SetStack = NULL; 369 bcs->BC_SetStack = NULL;
368 bcs->BC_Close = NULL; 370 bcs->BC_Close = NULL;
diff --git a/drivers/isdn/hisax/isdnl2.c b/drivers/isdn/hisax/isdnl2.c
index 6d0431725555..cd3b5ad53491 100644
--- a/drivers/isdn/hisax/isdnl2.c
+++ b/drivers/isdn/hisax/isdnl2.c
@@ -1442,7 +1442,7 @@ l2_tei_remove(struct FsmInst *fi, int event, void *arg)
1442} 1442}
1443 1443
1444static void 1444static void
1445l2_st14_persistant_da(struct FsmInst *fi, int event, void *arg) 1445l2_st14_persistent_da(struct FsmInst *fi, int event, void *arg)
1446{ 1446{
1447 struct PStack *st = fi->userdata; 1447 struct PStack *st = fi->userdata;
1448 1448
@@ -1453,7 +1453,7 @@ l2_st14_persistant_da(struct FsmInst *fi, int event, void *arg)
1453} 1453}
1454 1454
1455static void 1455static void
1456l2_st5_persistant_da(struct FsmInst *fi, int event, void *arg) 1456l2_st5_persistent_da(struct FsmInst *fi, int event, void *arg)
1457{ 1457{
1458 struct PStack *st = fi->userdata; 1458 struct PStack *st = fi->userdata;
1459 1459
@@ -1466,7 +1466,7 @@ l2_st5_persistant_da(struct FsmInst *fi, int event, void *arg)
1466} 1466}
1467 1467
1468static void 1468static void
1469l2_st6_persistant_da(struct FsmInst *fi, int event, void *arg) 1469l2_st6_persistent_da(struct FsmInst *fi, int event, void *arg)
1470{ 1470{
1471 struct PStack *st = fi->userdata; 1471 struct PStack *st = fi->userdata;
1472 1472
@@ -1477,7 +1477,7 @@ l2_st6_persistant_da(struct FsmInst *fi, int event, void *arg)
1477} 1477}
1478 1478
1479static void 1479static void
1480l2_persistant_da(struct FsmInst *fi, int event, void *arg) 1480l2_persistent_da(struct FsmInst *fi, int event, void *arg)
1481{ 1481{
1482 struct PStack *st = fi->userdata; 1482 struct PStack *st = fi->userdata;
1483 1483
@@ -1612,14 +1612,14 @@ static struct FsmNode L2FnList[] __initdata =
1612 {ST_L2_6, EV_L2_FRAME_ERROR, l2_frame_error}, 1612 {ST_L2_6, EV_L2_FRAME_ERROR, l2_frame_error},
1613 {ST_L2_7, EV_L2_FRAME_ERROR, l2_frame_error_reest}, 1613 {ST_L2_7, EV_L2_FRAME_ERROR, l2_frame_error_reest},
1614 {ST_L2_8, EV_L2_FRAME_ERROR, l2_frame_error_reest}, 1614 {ST_L2_8, EV_L2_FRAME_ERROR, l2_frame_error_reest},
1615 {ST_L2_1, EV_L1_DEACTIVATE, l2_st14_persistant_da}, 1615 {ST_L2_1, EV_L1_DEACTIVATE, l2_st14_persistent_da},
1616 {ST_L2_2, EV_L1_DEACTIVATE, l2_st24_tei_remove}, 1616 {ST_L2_2, EV_L1_DEACTIVATE, l2_st24_tei_remove},
1617 {ST_L2_3, EV_L1_DEACTIVATE, l2_st3_tei_remove}, 1617 {ST_L2_3, EV_L1_DEACTIVATE, l2_st3_tei_remove},
1618 {ST_L2_4, EV_L1_DEACTIVATE, l2_st14_persistant_da}, 1618 {ST_L2_4, EV_L1_DEACTIVATE, l2_st14_persistent_da},
1619 {ST_L2_5, EV_L1_DEACTIVATE, l2_st5_persistant_da}, 1619 {ST_L2_5, EV_L1_DEACTIVATE, l2_st5_persistent_da},
1620 {ST_L2_6, EV_L1_DEACTIVATE, l2_st6_persistant_da}, 1620 {ST_L2_6, EV_L1_DEACTIVATE, l2_st6_persistent_da},
1621 {ST_L2_7, EV_L1_DEACTIVATE, l2_persistant_da}, 1621 {ST_L2_7, EV_L1_DEACTIVATE, l2_persistent_da},
1622 {ST_L2_8, EV_L1_DEACTIVATE, l2_persistant_da}, 1622 {ST_L2_8, EV_L1_DEACTIVATE, l2_persistent_da},
1623}; 1623};
1624 1624
1625#define L2_FN_COUNT (sizeof(L2FnList)/sizeof(struct FsmNode)) 1625#define L2_FN_COUNT (sizeof(L2FnList)/sizeof(struct FsmNode))
diff --git a/drivers/isdn/hisax/sedlbauer_cs.c b/drivers/isdn/hisax/sedlbauer_cs.c
index f9c14a2970bc..46ed65334c51 100644
--- a/drivers/isdn/hisax/sedlbauer_cs.c
+++ b/drivers/isdn/hisax/sedlbauer_cs.c
@@ -233,20 +233,10 @@ static int sedlbauer_config(struct pcmcia_device *link)
233 233
234 DEBUG(0, "sedlbauer_config(0x%p)\n", link); 234 DEBUG(0, "sedlbauer_config(0x%p)\n", link);
235 235
236 /*
237 This reads the card's CONFIG tuple to find its configuration
238 registers.
239 */
240 tuple.DesiredTuple = CISTPL_CONFIG;
241 tuple.Attributes = 0; 236 tuple.Attributes = 0;
242 tuple.TupleData = buf; 237 tuple.TupleData = buf;
243 tuple.TupleDataMax = sizeof(buf); 238 tuple.TupleDataMax = sizeof(buf);
244 tuple.TupleOffset = 0; 239 tuple.TupleOffset = 0;
245 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
246 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
247 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
248 link->conf.ConfigBase = parse.config.base;
249 link->conf.Present = parse.config.rmask[0];
250 240
251 CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link, &conf)); 241 CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link, &conf));
252 242
diff --git a/drivers/isdn/hisax/teles_cs.c b/drivers/isdn/hisax/teles_cs.c
index afcc2aeadb34..6b754f183796 100644
--- a/drivers/isdn/hisax/teles_cs.c
+++ b/drivers/isdn/hisax/teles_cs.c
@@ -232,23 +232,6 @@ static int teles_cs_config(struct pcmcia_device *link)
232 DEBUG(0, "teles_config(0x%p)\n", link); 232 DEBUG(0, "teles_config(0x%p)\n", link);
233 dev = link->priv; 233 dev = link->priv;
234 234
235 /*
236 This reads the card's CONFIG tuple to find its configuration
237 registers.
238 */
239 tuple.DesiredTuple = CISTPL_CONFIG;
240 tuple.TupleData = (cisdata_t *)buf;
241 tuple.TupleDataMax = 255;
242 tuple.TupleOffset = 0;
243 tuple.Attributes = 0;
244 i = first_tuple(link, &tuple, &parse);
245 if (i != CS_SUCCESS) {
246 last_fn = ParseTuple;
247 goto cs_failed;
248 }
249 link->conf.ConfigBase = parse.config.base;
250 link->conf.Present = parse.config.rmask[0];
251
252 tuple.TupleData = (cisdata_t *)buf; 235 tuple.TupleData = (cisdata_t *)buf;
253 tuple.TupleOffset = 0; tuple.TupleDataMax = 255; 236 tuple.TupleOffset = 0; tuple.TupleDataMax = 255;
254 tuple.Attributes = 0; 237 tuple.Attributes = 0;
diff --git a/drivers/isdn/hisax/w6692.c b/drivers/isdn/hisax/w6692.c
index 1655341797a9..3aeceaf9769e 100644
--- a/drivers/isdn/hisax/w6692.c
+++ b/drivers/isdn/hisax/w6692.c
@@ -101,8 +101,10 @@ W6692_new_ph(struct IsdnCardState *cs)
101} 101}
102 102
103static void 103static void
104W6692_bh(struct IsdnCardState *cs) 104W6692_bh(struct work_struct *work)
105{ 105{
106 struct IsdnCardState *cs =
107 container_of(work, struct IsdnCardState, tqueue);
106 struct PStack *stptr; 108 struct PStack *stptr;
107 109
108 if (!cs) 110 if (!cs)
@@ -1070,7 +1072,7 @@ setup_w6692(struct IsdnCard *card)
1070 id_list[cs->subtyp].card_name, cs->irq, 1072 id_list[cs->subtyp].card_name, cs->irq,
1071 cs->hw.w6692.iobase); 1073 cs->hw.w6692.iobase);
1072 1074
1073 INIT_WORK(&cs->tqueue, (void *)(void *) W6692_bh, cs); 1075 INIT_WORK(&cs->tqueue, W6692_bh);
1074 cs->readW6692 = &ReadW6692; 1076 cs->readW6692 = &ReadW6692;
1075 cs->writeW6692 = &WriteW6692; 1077 cs->writeW6692 = &WriteW6692;
1076 cs->readisacfifo = &ReadISACfifo; 1078 cs->readisacfifo = &ReadISACfifo;
diff --git a/drivers/isdn/hysdn/boardergo.c b/drivers/isdn/hysdn/boardergo.c
index 82e42a80dc4b..a1206498a1cf 100644
--- a/drivers/isdn/hysdn/boardergo.c
+++ b/drivers/isdn/hysdn/boardergo.c
@@ -71,8 +71,9 @@ ergo_interrupt(int intno, void *dev_id)
71/* may be queued from everywhere (interrupts included). */ 71/* may be queued from everywhere (interrupts included). */
72/******************************************************************************/ 72/******************************************************************************/
73static void 73static void
74ergo_irq_bh(hysdn_card * card) 74ergo_irq_bh(struct work_struct *ugli_api)
75{ 75{
76 hysdn_card * card = container_of(ugli_api, hysdn_card, irq_queue);
76 tErgDpram *dpr; 77 tErgDpram *dpr;
77 int again; 78 int again;
78 unsigned long flags; 79 unsigned long flags;
@@ -442,7 +443,7 @@ ergo_inithardware(hysdn_card * card)
442 card->writebootseq = ergo_writebootseq; 443 card->writebootseq = ergo_writebootseq;
443 card->waitpofready = ergo_waitpofready; 444 card->waitpofready = ergo_waitpofready;
444 card->set_errlog_state = ergo_set_errlog_state; 445 card->set_errlog_state = ergo_set_errlog_state;
445 INIT_WORK(&card->irq_queue, (void *) (void *) ergo_irq_bh, card); 446 INIT_WORK(&card->irq_queue, ergo_irq_bh);
446 card->hysdn_lock = SPIN_LOCK_UNLOCKED; 447 card->hysdn_lock = SPIN_LOCK_UNLOCKED;
447 448
448 return (0); 449 return (0);
diff --git a/drivers/isdn/i4l/isdn_net.c b/drivers/isdn/i4l/isdn_net.c
index 1f8d6ae66b41..2e4daebfb7e0 100644
--- a/drivers/isdn/i4l/isdn_net.c
+++ b/drivers/isdn/i4l/isdn_net.c
@@ -984,9 +984,9 @@ void isdn_net_write_super(isdn_net_local *lp, struct sk_buff *skb)
984/* 984/*
985 * called from tq_immediate 985 * called from tq_immediate
986 */ 986 */
987static void isdn_net_softint(void *private) 987static void isdn_net_softint(struct work_struct *work)
988{ 988{
989 isdn_net_local *lp = private; 989 isdn_net_local *lp = container_of(work, isdn_net_local, tqueue);
990 struct sk_buff *skb; 990 struct sk_buff *skb;
991 991
992 spin_lock_bh(&lp->xmit_lock); 992 spin_lock_bh(&lp->xmit_lock);
@@ -2596,7 +2596,7 @@ isdn_net_new(char *name, struct net_device *master)
2596 netdev->local->netdev = netdev; 2596 netdev->local->netdev = netdev;
2597 netdev->local->next = netdev->local; 2597 netdev->local->next = netdev->local;
2598 2598
2599 INIT_WORK(&netdev->local->tqueue, (void *)(void *) isdn_net_softint, netdev->local); 2599 INIT_WORK(&netdev->local->tqueue, isdn_net_softint);
2600 spin_lock_init(&netdev->local->xmit_lock); 2600 spin_lock_init(&netdev->local->xmit_lock);
2601 2601
2602 netdev->local->isdn_device = -1; 2602 netdev->local->isdn_device = -1;
diff --git a/drivers/isdn/pcbit/drv.c b/drivers/isdn/pcbit/drv.c
index 6ead5e1508b7..1966f3410a13 100644
--- a/drivers/isdn/pcbit/drv.c
+++ b/drivers/isdn/pcbit/drv.c
@@ -68,8 +68,6 @@ static void pcbit_set_msn(struct pcbit_dev *dev, char *list);
68static int pcbit_check_msn(struct pcbit_dev *dev, char *msn); 68static int pcbit_check_msn(struct pcbit_dev *dev, char *msn);
69 69
70 70
71extern void pcbit_deliver(void * data);
72
73int pcbit_init_dev(int board, int mem_base, int irq) 71int pcbit_init_dev(int board, int mem_base, int irq)
74{ 72{
75 struct pcbit_dev *dev; 73 struct pcbit_dev *dev;
@@ -129,7 +127,7 @@ int pcbit_init_dev(int board, int mem_base, int irq)
129 memset(dev->b2, 0, sizeof(struct pcbit_chan)); 127 memset(dev->b2, 0, sizeof(struct pcbit_chan));
130 dev->b2->id = 1; 128 dev->b2->id = 1;
131 129
132 INIT_WORK(&dev->qdelivery, pcbit_deliver, dev); 130 INIT_WORK(&dev->qdelivery, pcbit_deliver);
133 131
134 /* 132 /*
135 * interrupts 133 * interrupts
diff --git a/drivers/isdn/pcbit/layer2.c b/drivers/isdn/pcbit/layer2.c
index 937fd2120381..0c9f6df873fc 100644
--- a/drivers/isdn/pcbit/layer2.c
+++ b/drivers/isdn/pcbit/layer2.c
@@ -67,7 +67,6 @@ extern void pcbit_l3_receive(struct pcbit_dev *dev, ulong msg,
67 * Prototypes 67 * Prototypes
68 */ 68 */
69 69
70void pcbit_deliver(void *data);
71static void pcbit_transmit(struct pcbit_dev *dev); 70static void pcbit_transmit(struct pcbit_dev *dev);
72 71
73static void pcbit_recv_ack(struct pcbit_dev *dev, unsigned char ack); 72static void pcbit_recv_ack(struct pcbit_dev *dev, unsigned char ack);
@@ -299,11 +298,12 @@ pcbit_transmit(struct pcbit_dev *dev)
299 */ 298 */
300 299
301void 300void
302pcbit_deliver(void *data) 301pcbit_deliver(struct work_struct *work)
303{ 302{
304 struct frame_buf *frame; 303 struct frame_buf *frame;
305 unsigned long flags, msg; 304 unsigned long flags, msg;
306 struct pcbit_dev *dev = (struct pcbit_dev *) data; 305 struct pcbit_dev *dev =
306 container_of(work, struct pcbit_dev, qdelivery);
307 307
308 spin_lock_irqsave(&dev->lock, flags); 308 spin_lock_irqsave(&dev->lock, flags);
309 309
diff --git a/drivers/isdn/pcbit/pcbit.h b/drivers/isdn/pcbit/pcbit.h
index 388bacefd23a..19c18e88ff16 100644
--- a/drivers/isdn/pcbit/pcbit.h
+++ b/drivers/isdn/pcbit/pcbit.h
@@ -166,4 +166,6 @@ struct pcbit_ioctl {
166#define L2_RUNNING 5 166#define L2_RUNNING 5
167#define L2_ERROR 6 167#define L2_ERROR 6
168 168
169extern void pcbit_deliver(struct work_struct *work);
170
169#endif 171#endif
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 9c39b98d5a5b..176142c61492 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -76,6 +76,12 @@ config LEDS_NET48XX
76 This option enables support for the Soekris net4801 and net4826 error 76 This option enables support for the Soekris net4801 and net4826 error
77 LED. 77 LED.
78 78
79config LEDS_WRAP
80 tristate "LED Support for the WRAP series LEDs"
81 depends on LEDS_CLASS && SCx200_GPIO
82 help
83 This option enables support for the PCEngines WRAP programmable LEDs.
84
79comment "LED Triggers" 85comment "LED Triggers"
80 86
81config LEDS_TRIGGERS 87config LEDS_TRIGGERS
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index 6aa2aed7539d..500de3dc962a 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -13,6 +13,7 @@ obj-$(CONFIG_LEDS_TOSA) += leds-tosa.o
13obj-$(CONFIG_LEDS_S3C24XX) += leds-s3c24xx.o 13obj-$(CONFIG_LEDS_S3C24XX) += leds-s3c24xx.o
14obj-$(CONFIG_LEDS_AMS_DELTA) += leds-ams-delta.o 14obj-$(CONFIG_LEDS_AMS_DELTA) += leds-ams-delta.o
15obj-$(CONFIG_LEDS_NET48XX) += leds-net48xx.o 15obj-$(CONFIG_LEDS_NET48XX) += leds-net48xx.o
16obj-$(CONFIG_LEDS_WRAP) += leds-wrap.o
16 17
17# LED Triggers 18# LED Triggers
18obj-$(CONFIG_LEDS_TRIGGER_TIMER) += ledtrig-timer.o 19obj-$(CONFIG_LEDS_TRIGGER_TIMER) += ledtrig-timer.o
diff --git a/drivers/leds/leds-wrap.c b/drivers/leds/leds-wrap.c
new file mode 100644
index 000000000000..27fb2d8e991f
--- /dev/null
+++ b/drivers/leds/leds-wrap.c
@@ -0,0 +1,142 @@
1/*
2 * LEDs driver for PCEngines WRAP
3 *
4 * Copyright (C) 2006 Kristian Kielhofner <kris@krisk.org>
5 *
6 * Based on leds-net48xx.c
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/platform_device.h>
16#include <linux/leds.h>
17#include <linux/err.h>
18#include <asm/io.h>
19#include <linux/scx200_gpio.h>
20
21#define DRVNAME "wrap-led"
22#define WRAP_ERROR_LED_GPIO 3
23#define WRAP_EXTRA_LED_GPIO 18
24
25static struct platform_device *pdev;
26
27static void wrap_error_led_set(struct led_classdev *led_cdev,
28 enum led_brightness value)
29{
30 if (value)
31 scx200_gpio_set_low(WRAP_ERROR_LED_GPIO);
32 else
33 scx200_gpio_set_high(WRAP_ERROR_LED_GPIO);
34}
35
36static void wrap_extra_led_set(struct led_classdev *led_cdev,
37 enum led_brightness value)
38{
39 if (value)
40 scx200_gpio_set_low(WRAP_EXTRA_LED_GPIO);
41 else
42 scx200_gpio_set_high(WRAP_EXTRA_LED_GPIO);
43}
44
45static struct led_classdev wrap_error_led = {
46 .name = "wrap:error",
47 .brightness_set = wrap_error_led_set,
48};
49
50static struct led_classdev wrap_extra_led = {
51 .name = "wrap:extra",
52 .brightness_set = wrap_extra_led_set,
53};
54
55#ifdef CONFIG_PM
56static int wrap_led_suspend(struct platform_device *dev,
57 pm_message_t state)
58{
59 led_classdev_suspend(&wrap_error_led);
60 led_classdev_suspend(&wrap_extra_led);
61 return 0;
62}
63
64static int wrap_led_resume(struct platform_device *dev)
65{
66 led_classdev_resume(&wrap_error_led);
67 led_classdev_resume(&wrap_extra_led);
68 return 0;
69}
70#else
71#define wrap_led_suspend NULL
72#define wrap_led_resume NULL
73#endif
74
75static int wrap_led_probe(struct platform_device *pdev)
76{
77 int ret;
78
79 ret = led_classdev_register(&pdev->dev, &wrap_error_led);
80 if (ret == 0) {
81 ret = led_classdev_register(&pdev->dev, &wrap_extra_led);
82 if (ret < 0)
83 led_classdev_unregister(&wrap_error_led);
84 }
85 return ret;
86}
87
88static int wrap_led_remove(struct platform_device *pdev)
89{
90 led_classdev_unregister(&wrap_error_led);
91 led_classdev_unregister(&wrap_extra_led);
92 return 0;
93}
94
95static struct platform_driver wrap_led_driver = {
96 .probe = wrap_led_probe,
97 .remove = wrap_led_remove,
98 .suspend = wrap_led_suspend,
99 .resume = wrap_led_resume,
100 .driver = {
101 .name = DRVNAME,
102 .owner = THIS_MODULE,
103 },
104};
105
106static int __init wrap_led_init(void)
107{
108 int ret;
109
110 if (!scx200_gpio_present()) {
111 ret = -ENODEV;
112 goto out;
113 }
114
115 ret = platform_driver_register(&wrap_led_driver);
116 if (ret < 0)
117 goto out;
118
119 pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0);
120 if (IS_ERR(pdev)) {
121 ret = PTR_ERR(pdev);
122 platform_driver_unregister(&wrap_led_driver);
123 goto out;
124 }
125
126out:
127 return ret;
128}
129
130static void __exit wrap_led_exit(void)
131{
132 platform_device_unregister(pdev);
133 platform_driver_unregister(&wrap_led_driver);
134}
135
136module_init(wrap_led_init);
137module_exit(wrap_led_exit);
138
139MODULE_AUTHOR("Kristian Kielhofner <kris@krisk.org>");
140MODULE_DESCRIPTION("PCEngines WRAP LED driver");
141MODULE_LICENSE("GPL");
142
diff --git a/drivers/leds/ledtrig-ide-disk.c b/drivers/leds/ledtrig-ide-disk.c
index fa651886ab4f..54b155c7026f 100644
--- a/drivers/leds/ledtrig-ide-disk.c
+++ b/drivers/leds/ledtrig-ide-disk.c
@@ -12,6 +12,7 @@
12 */ 12 */
13 13
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/jiffies.h>
15#include <linux/kernel.h> 16#include <linux/kernel.h>
16#include <linux/init.h> 17#include <linux/init.h>
17#include <linux/timer.h> 18#include <linux/timer.h>
diff --git a/drivers/leds/ledtrig-timer.c b/drivers/leds/ledtrig-timer.c
index 29a8818a32ec..d756bdb01c59 100644
--- a/drivers/leds/ledtrig-timer.c
+++ b/drivers/leds/ledtrig-timer.c
@@ -12,6 +12,7 @@
12 */ 12 */
13 13
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/jiffies.h>
15#include <linux/kernel.h> 16#include <linux/kernel.h>
16#include <linux/init.h> 17#include <linux/init.h>
17#include <linux/list.h> 18#include <linux/list.h>
diff --git a/drivers/macintosh/Kconfig b/drivers/macintosh/Kconfig
index 31015d55d353..a9e747c39791 100644
--- a/drivers/macintosh/Kconfig
+++ b/drivers/macintosh/Kconfig
@@ -227,4 +227,11 @@ config ANSLCD
227 tristate "Support for ANS LCD display" 227 tristate "Support for ANS LCD display"
228 depends on ADB_CUDA && PPC_PMAC 228 depends on ADB_CUDA && PPC_PMAC
229 229
230config PMAC_RACKMETER
231 tristate "Support for Apple XServe front panel LEDs"
232 depends on PPC_PMAC
233 help
234 This driver procides some support to control the front panel
235 blue LEDs "vu-meter" of the XServer macs.
236
230endmenu 237endmenu
diff --git a/drivers/macintosh/Makefile b/drivers/macintosh/Makefile
index b53d45f87b0b..2dfc3f4eaf42 100644
--- a/drivers/macintosh/Makefile
+++ b/drivers/macintosh/Makefile
@@ -42,3 +42,4 @@ obj-$(CONFIG_WINDFARM_PM112) += windfarm_pm112.o windfarm_smu_sat.o \
42 windfarm_smu_sensors.o \ 42 windfarm_smu_sensors.o \
43 windfarm_max6690_sensor.o \ 43 windfarm_max6690_sensor.o \
44 windfarm_lm75_sensor.o windfarm_pid.o 44 windfarm_lm75_sensor.o windfarm_pid.o
45obj-$(CONFIG_PMAC_RACKMETER) += rack-meter.o
diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
index be0bd34ff6f9..d43ea81d6df9 100644
--- a/drivers/macintosh/adb.c
+++ b/drivers/macintosh/adb.c
@@ -267,12 +267,12 @@ adb_probe_task(void *x)
267} 267}
268 268
269static void 269static void
270__adb_probe_task(void *data) 270__adb_probe_task(struct work_struct *bullshit)
271{ 271{
272 adb_probe_task_pid = kernel_thread(adb_probe_task, NULL, SIGCHLD | CLONE_KERNEL); 272 adb_probe_task_pid = kernel_thread(adb_probe_task, NULL, SIGCHLD | CLONE_KERNEL);
273} 273}
274 274
275static DECLARE_WORK(adb_reset_work, __adb_probe_task, NULL); 275static DECLARE_WORK(adb_reset_work, __adb_probe_task);
276 276
277int 277int
278adb_reset_bus(void) 278adb_reset_bus(void)
diff --git a/drivers/macintosh/apm_emu.c b/drivers/macintosh/apm_emu.c
index 1293876a2ebd..8862a83b8d84 100644
--- a/drivers/macintosh/apm_emu.c
+++ b/drivers/macintosh/apm_emu.c
@@ -529,7 +529,8 @@ static int __init apm_emu_init(void)
529 if (apm_proc) 529 if (apm_proc)
530 apm_proc->owner = THIS_MODULE; 530 apm_proc->owner = THIS_MODULE;
531 531
532 misc_register(&apm_device); 532 if (misc_register(&apm_device) != 0)
533 printk(KERN_INFO "Could not create misc. device for apm\n");
533 534
534 pmu_register_sleep_notifier(&apm_sleep_notifier); 535 pmu_register_sleep_notifier(&apm_sleep_notifier);
535 536
diff --git a/drivers/macintosh/rack-meter.c b/drivers/macintosh/rack-meter.c
new file mode 100644
index 000000000000..5ed41fe84e57
--- /dev/null
+++ b/drivers/macintosh/rack-meter.c
@@ -0,0 +1,616 @@
1/*
2 * RackMac vu-meter driver
3 *
4 * (c) Copyright 2006 Benjamin Herrenschmidt, IBM Corp.
5 * <benh@kernel.crashing.org>
6 *
7 * Released under the term of the GNU GPL v2.
8 *
9 * Support the CPU-meter LEDs of the Xserve G5
10 *
11 * TODO: Implement PWM to do variable intensity and provide userland
12 * interface for fun. Also, the CPU-meter could be made nicer by being
13 * a bit less "immediate" but giving instead a more average load over
14 * time. Patches welcome :-)
15 *
16 */
17#undef DEBUG
18
19#include <linux/types.h>
20#include <linux/kernel.h>
21#include <linux/device.h>
22#include <linux/interrupt.h>
23#include <linux/module.h>
24#include <linux/pci.h>
25#include <linux/dma-mapping.h>
26#include <linux/kernel_stat.h>
27
28#include <asm/io.h>
29#include <asm/prom.h>
30#include <asm/machdep.h>
31#include <asm/pmac_feature.h>
32#include <asm/dbdma.h>
33#include <asm/dbdma.h>
34#include <asm/macio.h>
35#include <asm/keylargo.h>
36
37/* Number of samples in a sample buffer */
38#define SAMPLE_COUNT 256
39
40/* CPU meter sampling rate in ms */
41#define CPU_SAMPLING_RATE 250
42
43struct rackmeter_dma {
44 struct dbdma_cmd cmd[4] ____cacheline_aligned;
45 u32 mark ____cacheline_aligned;
46 u32 buf1[SAMPLE_COUNT] ____cacheline_aligned;
47 u32 buf2[SAMPLE_COUNT] ____cacheline_aligned;
48} ____cacheline_aligned;
49
50struct rackmeter_cpu {
51 struct delayed_work sniffer;
52 struct rackmeter *rm;
53 cputime64_t prev_wall;
54 cputime64_t prev_idle;
55 int zero;
56} ____cacheline_aligned;
57
58struct rackmeter {
59 struct macio_dev *mdev;
60 unsigned int irq;
61 struct device_node *i2s;
62 u8 *ubuf;
63 struct dbdma_regs __iomem *dma_regs;
64 void __iomem *i2s_regs;
65 dma_addr_t dma_buf_p;
66 struct rackmeter_dma *dma_buf_v;
67 int stale_irq;
68 struct rackmeter_cpu cpu[2];
69 int paused;
70 struct mutex sem;
71};
72
73/* To be set as a tunable */
74static int rackmeter_ignore_nice;
75
76/* This GPIO is whacked by the OS X driver when initializing */
77#define RACKMETER_MAGIC_GPIO 0x78
78
79/* This is copied from cpufreq_ondemand, maybe we should put it in
80 * a common header somewhere
81 */
82static inline cputime64_t get_cpu_idle_time(unsigned int cpu)
83{
84 cputime64_t retval;
85
86 retval = cputime64_add(kstat_cpu(cpu).cpustat.idle,
87 kstat_cpu(cpu).cpustat.iowait);
88
89 if (rackmeter_ignore_nice)
90 retval = cputime64_add(retval, kstat_cpu(cpu).cpustat.nice);
91
92 return retval;
93}
94
95static void rackmeter_setup_i2s(struct rackmeter *rm)
96{
97 struct macio_chip *macio = rm->mdev->bus->chip;
98
99 /* First whack magic GPIO */
100 pmac_call_feature(PMAC_FTR_WRITE_GPIO, NULL, RACKMETER_MAGIC_GPIO, 5);
101
102
103 /* Call feature code to enable the sound channel and the proper
104 * clock sources
105 */
106 pmac_call_feature(PMAC_FTR_SOUND_CHIP_ENABLE, rm->i2s, 0, 1);
107
108 /* Power i2s and stop i2s clock. We whack MacIO FCRs directly for now.
109 * This is a bit racy, thus we should add new platform functions to
110 * handle that. snd-aoa needs that too
111 */
112 MACIO_BIS(KEYLARGO_FCR1, KL1_I2S0_ENABLE);
113 MACIO_BIC(KEYLARGO_FCR1, KL1_I2S0_CLK_ENABLE_BIT);
114 (void)MACIO_IN32(KEYLARGO_FCR1);
115 udelay(10);
116
117 /* Then setup i2s. For now, we use the same magic value that
118 * the OS X driver seems to use. We might want to play around
119 * with the clock divisors later
120 */
121 out_le32(rm->i2s_regs + 0x10, 0x01fa0000);
122 (void)in_le32(rm->i2s_regs + 0x10);
123 udelay(10);
124
125 /* Fully restart i2s*/
126 MACIO_BIS(KEYLARGO_FCR1, KL1_I2S0_CELL_ENABLE |
127 KL1_I2S0_CLK_ENABLE_BIT);
128 (void)MACIO_IN32(KEYLARGO_FCR1);
129 udelay(10);
130}
131
132static void rackmeter_set_default_pattern(struct rackmeter *rm)
133{
134 int i;
135
136 for (i = 0; i < 16; i++) {
137 if (i < 8)
138 rm->ubuf[i] = (i & 1) * 255;
139 else
140 rm->ubuf[i] = ((~i) & 1) * 255;
141 }
142}
143
144static void rackmeter_do_pause(struct rackmeter *rm, int pause)
145{
146 struct rackmeter_dma *rdma = rm->dma_buf_v;
147
148 pr_debug("rackmeter: %s\n", pause ? "paused" : "started");
149
150 rm->paused = pause;
151 if (pause) {
152 DBDMA_DO_STOP(rm->dma_regs);
153 return;
154 }
155 memset(rdma->buf1, 0, SAMPLE_COUNT & sizeof(u32));
156 memset(rdma->buf2, 0, SAMPLE_COUNT & sizeof(u32));
157
158 rm->dma_buf_v->mark = 0;
159
160 mb();
161 out_le32(&rm->dma_regs->cmdptr_hi, 0);
162 out_le32(&rm->dma_regs->cmdptr, rm->dma_buf_p);
163 out_le32(&rm->dma_regs->control, (RUN << 16) | RUN);
164}
165
166static void rackmeter_setup_dbdma(struct rackmeter *rm)
167{
168 struct rackmeter_dma *db = rm->dma_buf_v;
169 struct dbdma_cmd *cmd = db->cmd;
170
171 /* Make sure dbdma is reset */
172 DBDMA_DO_RESET(rm->dma_regs);
173
174 pr_debug("rackmeter: mark offset=0x%lx\n",
175 offsetof(struct rackmeter_dma, mark));
176 pr_debug("rackmeter: buf1 offset=0x%lx\n",
177 offsetof(struct rackmeter_dma, buf1));
178 pr_debug("rackmeter: buf2 offset=0x%lx\n",
179 offsetof(struct rackmeter_dma, buf2));
180
181 /* Prepare 4 dbdma commands for the 2 buffers */
182 memset(cmd, 0, 4 * sizeof(struct dbdma_cmd));
183 st_le16(&cmd->req_count, 4);
184 st_le16(&cmd->command, STORE_WORD | INTR_ALWAYS | KEY_SYSTEM);
185 st_le32(&cmd->phy_addr, rm->dma_buf_p +
186 offsetof(struct rackmeter_dma, mark));
187 st_le32(&cmd->cmd_dep, 0x02000000);
188 cmd++;
189
190 st_le16(&cmd->req_count, SAMPLE_COUNT * 4);
191 st_le16(&cmd->command, OUTPUT_MORE);
192 st_le32(&cmd->phy_addr, rm->dma_buf_p +
193 offsetof(struct rackmeter_dma, buf1));
194 cmd++;
195
196 st_le16(&cmd->req_count, 4);
197 st_le16(&cmd->command, STORE_WORD | INTR_ALWAYS | KEY_SYSTEM);
198 st_le32(&cmd->phy_addr, rm->dma_buf_p +
199 offsetof(struct rackmeter_dma, mark));
200 st_le32(&cmd->cmd_dep, 0x01000000);
201 cmd++;
202
203 st_le16(&cmd->req_count, SAMPLE_COUNT * 4);
204 st_le16(&cmd->command, OUTPUT_MORE | BR_ALWAYS);
205 st_le32(&cmd->phy_addr, rm->dma_buf_p +
206 offsetof(struct rackmeter_dma, buf2));
207 st_le32(&cmd->cmd_dep, rm->dma_buf_p);
208
209 rackmeter_do_pause(rm, 0);
210}
211
212static void rackmeter_do_timer(struct work_struct *work)
213{
214 struct rackmeter_cpu *rcpu =
215 container_of(work, struct rackmeter_cpu, sniffer.work);
216 struct rackmeter *rm = rcpu->rm;
217 unsigned int cpu = smp_processor_id();
218 cputime64_t cur_jiffies, total_idle_ticks;
219 unsigned int total_ticks, idle_ticks;
220 int i, offset, load, cumm, pause;
221
222 cur_jiffies = jiffies64_to_cputime64(get_jiffies_64());
223 total_ticks = (unsigned int)cputime64_sub(cur_jiffies,
224 rcpu->prev_wall);
225 rcpu->prev_wall = cur_jiffies;
226
227 total_idle_ticks = get_cpu_idle_time(cpu);
228 idle_ticks = (unsigned int) cputime64_sub(total_idle_ticks,
229 rcpu->prev_idle);
230 rcpu->prev_idle = total_idle_ticks;
231
232 /* We do a very dumb calculation to update the LEDs for now,
233 * we'll do better once we have actual PWM implemented
234 */
235 load = (9 * (total_ticks - idle_ticks)) / total_ticks;
236
237 offset = cpu << 3;
238 cumm = 0;
239 for (i = 0; i < 8; i++) {
240 u8 ub = (load > i) ? 0xff : 0;
241 rm->ubuf[i + offset] = ub;
242 cumm |= ub;
243 }
244 rcpu->zero = (cumm == 0);
245
246 /* Now check if LEDs are all 0, we can stop DMA */
247 pause = (rm->cpu[0].zero && rm->cpu[1].zero);
248 if (pause != rm->paused) {
249 mutex_lock(&rm->sem);
250 pause = (rm->cpu[0].zero && rm->cpu[1].zero);
251 rackmeter_do_pause(rm, pause);
252 mutex_unlock(&rm->sem);
253 }
254 schedule_delayed_work_on(cpu, &rcpu->sniffer,
255 msecs_to_jiffies(CPU_SAMPLING_RATE));
256}
257
258static void __devinit rackmeter_init_cpu_sniffer(struct rackmeter *rm)
259{
260 unsigned int cpu;
261
262 /* This driver works only with 1 or 2 CPUs numbered 0 and 1,
263 * but that's really all we have on Apple Xserve. It doesn't
264 * play very nice with CPU hotplug neither but we don't do that
265 * on those machines yet
266 */
267
268 rm->cpu[0].rm = rm;
269 INIT_DELAYED_WORK(&rm->cpu[0].sniffer, rackmeter_do_timer);
270 rm->cpu[1].rm = rm;
271 INIT_DELAYED_WORK(&rm->cpu[1].sniffer, rackmeter_do_timer);
272
273 for_each_online_cpu(cpu) {
274 struct rackmeter_cpu *rcpu;
275
276 if (cpu > 1)
277 continue;
278 rcpu = &rm->cpu[cpu];;
279 rcpu->prev_idle = get_cpu_idle_time(cpu);
280 rcpu->prev_wall = jiffies64_to_cputime64(get_jiffies_64());
281 schedule_delayed_work_on(cpu, &rm->cpu[cpu].sniffer,
282 msecs_to_jiffies(CPU_SAMPLING_RATE));
283 }
284}
285
286static void __devexit rackmeter_stop_cpu_sniffer(struct rackmeter *rm)
287{
288 cancel_rearming_delayed_work(&rm->cpu[0].sniffer);
289 cancel_rearming_delayed_work(&rm->cpu[1].sniffer);
290}
291
292static int rackmeter_setup(struct rackmeter *rm)
293{
294 pr_debug("rackmeter: setting up i2s..\n");
295 rackmeter_setup_i2s(rm);
296
297 pr_debug("rackmeter: setting up default pattern..\n");
298 rackmeter_set_default_pattern(rm);
299
300 pr_debug("rackmeter: setting up dbdma..\n");
301 rackmeter_setup_dbdma(rm);
302
303 pr_debug("rackmeter: start CPU measurements..\n");
304 rackmeter_init_cpu_sniffer(rm);
305
306 printk(KERN_INFO "RackMeter initialized\n");
307
308 return 0;
309}
310
311/* XXX FIXME: No PWM yet, this is 0/1 */
312static u32 rackmeter_calc_sample(struct rackmeter *rm, unsigned int index)
313{
314 int led;
315 u32 sample = 0;
316
317 for (led = 0; led < 16; led++) {
318 sample >>= 1;
319 sample |= ((rm->ubuf[led] >= 0x80) << 15);
320 }
321 return (sample << 17) | (sample >> 15);
322}
323
324static irqreturn_t rackmeter_irq(int irq, void *arg)
325{
326 struct rackmeter *rm = arg;
327 struct rackmeter_dma *db = rm->dma_buf_v;
328 unsigned int mark, i;
329 u32 *buf;
330
331 /* Flush PCI buffers with an MMIO read. Maybe we could actually
332 * check the status one day ... in case things go wrong, though
333 * this never happened to me
334 */
335 (void)in_le32(&rm->dma_regs->status);
336
337 /* Make sure the CPU gets us in order */
338 rmb();
339
340 /* Read mark */
341 mark = db->mark;
342 if (mark != 1 && mark != 2) {
343 printk(KERN_WARNING "rackmeter: Incorrect DMA mark 0x%08x\n",
344 mark);
345 /* We allow for 3 errors like that (stale DBDMA irqs) */
346 if (++rm->stale_irq > 3) {
347 printk(KERN_ERR "rackmeter: Too many errors,"
348 " stopping DMA\n");
349 DBDMA_DO_RESET(rm->dma_regs);
350 }
351 return IRQ_HANDLED;
352 }
353
354 /* Next buffer we need to fill is mark value */
355 buf = mark == 1 ? db->buf1 : db->buf2;
356
357 /* Fill it now. This routine converts the 8 bits depth sample array
358 * into the PWM bitmap for each LED.
359 */
360 for (i = 0; i < SAMPLE_COUNT; i++)
361 buf[i] = rackmeter_calc_sample(rm, i);
362
363
364 return IRQ_HANDLED;
365}
366
367static int __devinit rackmeter_probe(struct macio_dev* mdev,
368 const struct of_device_id *match)
369{
370 struct device_node *i2s = NULL, *np = NULL;
371 struct rackmeter *rm = NULL;
372 struct resource ri2s, rdma;
373 int rc = -ENODEV;
374
375 pr_debug("rackmeter_probe()\n");
376
377 /* Get i2s-a node */
378 while ((i2s = of_get_next_child(mdev->ofdev.node, i2s)) != NULL)
379 if (strcmp(i2s->name, "i2s-a") == 0)
380 break;
381 if (i2s == NULL) {
382 pr_debug(" i2s-a child not found\n");
383 goto bail;
384 }
385 /* Get lightshow or virtual sound */
386 while ((np = of_get_next_child(i2s, np)) != NULL) {
387 if (strcmp(np->name, "lightshow") == 0)
388 break;
389 if ((strcmp(np->name, "sound") == 0) &&
390 get_property(np, "virtual", NULL) != NULL)
391 break;
392 }
393 if (np == NULL) {
394 pr_debug(" lightshow or sound+virtual child not found\n");
395 goto bail;
396 }
397
398 /* Create and initialize our instance data */
399 rm = kzalloc(sizeof(struct rackmeter), GFP_KERNEL);
400 if (rm == NULL) {
401 printk(KERN_ERR "rackmeter: failed to allocate memory !\n");
402 rc = -ENOMEM;
403 goto bail_release;
404 }
405 rm->mdev = mdev;
406 rm->i2s = i2s;
407 mutex_init(&rm->sem);
408 dev_set_drvdata(&mdev->ofdev.dev, rm);
409 /* Check resources availability. We need at least resource 0 and 1 */
410#if 0 /* Use that when i2s-a is finally an mdev per-se */
411 if (macio_resource_count(mdev) < 2 || macio_irq_count(mdev) < 2) {
412 printk(KERN_ERR
413 "rackmeter: found match but lacks resources: %s"
414 " (%d resources, %d interrupts)\n",
415 mdev->ofdev.node->full_name);
416 rc = -ENXIO;
417 goto bail_free;
418 }
419 if (macio_request_resources(mdev, "rackmeter")) {
420 printk(KERN_ERR
421 "rackmeter: failed to request resources: %s\n",
422 mdev->ofdev.node->full_name);
423 rc = -EBUSY;
424 goto bail_free;
425 }
426 rm->irq = macio_irq(mdev, 1);
427#else
428 rm->irq = irq_of_parse_and_map(i2s, 1);
429 if (rm->irq == NO_IRQ ||
430 of_address_to_resource(i2s, 0, &ri2s) ||
431 of_address_to_resource(i2s, 1, &rdma)) {
432 printk(KERN_ERR
433 "rackmeter: found match but lacks resources: %s",
434 mdev->ofdev.node->full_name);
435 rc = -ENXIO;
436 goto bail_free;
437 }
438#endif
439
440 pr_debug(" i2s @0x%08x\n", (unsigned int)ri2s.start);
441 pr_debug(" dma @0x%08x\n", (unsigned int)rdma.start);
442 pr_debug(" irq %d\n", rm->irq);
443
444 rm->ubuf = (u8 *)__get_free_page(GFP_KERNEL);
445 if (rm->ubuf == NULL) {
446 printk(KERN_ERR
447 "rackmeter: failed to allocate samples page !\n");
448 rc = -ENOMEM;
449 goto bail_release;
450 }
451
452 rm->dma_buf_v = dma_alloc_coherent(&macio_get_pci_dev(mdev)->dev,
453 sizeof(struct rackmeter_dma),
454 &rm->dma_buf_p, GFP_KERNEL);
455 if (rm->dma_buf_v == NULL) {
456 printk(KERN_ERR
457 "rackmeter: failed to allocate dma buffer !\n");
458 rc = -ENOMEM;
459 goto bail_free_samples;
460 }
461#if 0
462 rm->i2s_regs = ioremap(macio_resource_start(mdev, 0), 0x1000);
463#else
464 rm->i2s_regs = ioremap(ri2s.start, 0x1000);
465#endif
466 if (rm->i2s_regs == NULL) {
467 printk(KERN_ERR
468 "rackmeter: failed to map i2s registers !\n");
469 rc = -ENXIO;
470 goto bail_free_dma;
471 }
472#if 0
473 rm->dma_regs = ioremap(macio_resource_start(mdev, 1), 0x100);
474#else
475 rm->dma_regs = ioremap(rdma.start, 0x100);
476#endif
477 if (rm->dma_regs == NULL) {
478 printk(KERN_ERR
479 "rackmeter: failed to map dma registers !\n");
480 rc = -ENXIO;
481 goto bail_unmap_i2s;
482 }
483
484 rc = rackmeter_setup(rm);
485 if (rc) {
486 printk(KERN_ERR
487 "rackmeter: failed to initialize !\n");
488 rc = -ENXIO;
489 goto bail_unmap_dma;
490 }
491
492 rc = request_irq(rm->irq, rackmeter_irq, 0, "rackmeter", rm);
493 if (rc != 0) {
494 printk(KERN_ERR
495 "rackmeter: failed to request interrupt !\n");
496 goto bail_stop_dma;
497 }
498 of_node_put(np);
499 return 0;
500
501 bail_stop_dma:
502 DBDMA_DO_RESET(rm->dma_regs);
503 bail_unmap_dma:
504 iounmap(rm->dma_regs);
505 bail_unmap_i2s:
506 iounmap(rm->i2s_regs);
507 bail_free_dma:
508 dma_free_coherent(&macio_get_pci_dev(mdev)->dev,
509 sizeof(struct rackmeter_dma),
510 rm->dma_buf_v, rm->dma_buf_p);
511 bail_free_samples:
512 free_page((unsigned long)rm->ubuf);
513 bail_release:
514#if 0
515 macio_release_resources(mdev);
516#endif
517 bail_free:
518 kfree(rm);
519 bail:
520 of_node_put(i2s);
521 of_node_put(np);
522 dev_set_drvdata(&mdev->ofdev.dev, NULL);
523 return rc;
524}
525
526static int __devexit rackmeter_remove(struct macio_dev* mdev)
527{
528 struct rackmeter *rm = dev_get_drvdata(&mdev->ofdev.dev);
529
530 /* Stop CPU sniffer timer & work queues */
531 rackmeter_stop_cpu_sniffer(rm);
532
533 /* Clear reference to private data */
534 dev_set_drvdata(&mdev->ofdev.dev, NULL);
535
536 /* Stop/reset dbdma */
537 DBDMA_DO_RESET(rm->dma_regs);
538
539 /* Release the IRQ */
540 free_irq(rm->irq, rm);
541
542 /* Unmap registers */
543 iounmap(rm->dma_regs);
544 iounmap(rm->i2s_regs);
545
546 /* Free DMA */
547 dma_free_coherent(&macio_get_pci_dev(mdev)->dev,
548 sizeof(struct rackmeter_dma),
549 rm->dma_buf_v, rm->dma_buf_p);
550
551 /* Free samples */
552 free_page((unsigned long)rm->ubuf);
553
554#if 0
555 /* Release resources */
556 macio_release_resources(mdev);
557#endif
558
559 /* Get rid of me */
560 kfree(rm);
561
562 return 0;
563}
564
565static int rackmeter_shutdown(struct macio_dev* mdev)
566{
567 struct rackmeter *rm = dev_get_drvdata(&mdev->ofdev.dev);
568
569 if (rm == NULL)
570 return -ENODEV;
571
572 /* Stop CPU sniffer timer & work queues */
573 rackmeter_stop_cpu_sniffer(rm);
574
575 /* Stop/reset dbdma */
576 DBDMA_DO_RESET(rm->dma_regs);
577
578 return 0;
579}
580
581static struct of_device_id rackmeter_match[] = {
582 { .name = "i2s" },
583 { }
584};
585
586static struct macio_driver rackmeter_drv = {
587 .name = "rackmeter",
588 .owner = THIS_MODULE,
589 .match_table = rackmeter_match,
590 .probe = rackmeter_probe,
591 .remove = rackmeter_remove,
592 .shutdown = rackmeter_shutdown,
593};
594
595
596static int __init rackmeter_init(void)
597{
598 pr_debug("rackmeter_init()\n");
599
600 return macio_register_driver(&rackmeter_drv);
601}
602
603static void __exit rackmeter_exit(void)
604{
605 pr_debug("rackmeter_exit()\n");
606
607 macio_unregister_driver(&rackmeter_drv);
608}
609
610module_init(rackmeter_init);
611module_exit(rackmeter_exit);
612
613
614MODULE_LICENSE("GPL");
615MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>");
616MODULE_DESCRIPTION("RackMeter: Support vu-meter on XServe front panel");
diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c
index ade25b3fbb35..6dde27ab79a8 100644
--- a/drivers/macintosh/smu.c
+++ b/drivers/macintosh/smu.c
@@ -46,6 +46,7 @@
46#include <asm/abs_addr.h> 46#include <asm/abs_addr.h>
47#include <asm/uaccess.h> 47#include <asm/uaccess.h>
48#include <asm/of_device.h> 48#include <asm/of_device.h>
49#include <asm/of_platform.h>
49 50
50#define VERSION "0.7" 51#define VERSION "0.7"
51#define AUTHOR "(c) 2005 Benjamin Herrenschmidt, IBM Corp." 52#define AUTHOR "(c) 2005 Benjamin Herrenschmidt, IBM Corp."
@@ -600,7 +601,7 @@ core_initcall(smu_late_init);
600 * sysfs visibility 601 * sysfs visibility
601 */ 602 */
602 603
603static void smu_expose_childs(void *unused) 604static void smu_expose_childs(struct work_struct *unused)
604{ 605{
605 struct device_node *np; 606 struct device_node *np;
606 607
@@ -610,7 +611,7 @@ static void smu_expose_childs(void *unused)
610 &smu->of_dev->dev); 611 &smu->of_dev->dev);
611} 612}
612 613
613static DECLARE_WORK(smu_expose_childs_work, smu_expose_childs, NULL); 614static DECLARE_WORK(smu_expose_childs_work, smu_expose_childs);
614 615
615static int smu_platform_probe(struct of_device* dev, 616static int smu_platform_probe(struct of_device* dev,
616 const struct of_device_id *match) 617 const struct of_device_id *match)
@@ -653,7 +654,7 @@ static int __init smu_init_sysfs(void)
653 * I'm a bit too far from figuring out how that works with those 654 * I'm a bit too far from figuring out how that works with those
654 * new chipsets, but that will come back and bite us 655 * new chipsets, but that will come back and bite us
655 */ 656 */
656 of_register_driver(&smu_of_platform_driver); 657 of_register_platform_driver(&smu_of_platform_driver);
657 return 0; 658 return 0;
658} 659}
659 660
diff --git a/drivers/macintosh/therm_adt746x.c b/drivers/macintosh/therm_adt746x.c
index a0f30d0853ea..3d3bf1643e73 100644
--- a/drivers/macintosh/therm_adt746x.c
+++ b/drivers/macintosh/therm_adt746x.c
@@ -24,13 +24,14 @@
24#include <linux/suspend.h> 24#include <linux/suspend.h>
25#include <linux/kthread.h> 25#include <linux/kthread.h>
26#include <linux/moduleparam.h> 26#include <linux/moduleparam.h>
27#include <linux/freezer.h>
27 28
28#include <asm/prom.h> 29#include <asm/prom.h>
29#include <asm/machdep.h> 30#include <asm/machdep.h>
30#include <asm/io.h> 31#include <asm/io.h>
31#include <asm/system.h> 32#include <asm/system.h>
32#include <asm/sections.h> 33#include <asm/sections.h>
33#include <asm/of_device.h> 34#include <asm/of_platform.h>
34 35
35#undef DEBUG 36#undef DEBUG
36 37
diff --git a/drivers/macintosh/therm_pm72.c b/drivers/macintosh/therm_pm72.c
index d00c0c37a12e..2e4ad44a8636 100644
--- a/drivers/macintosh/therm_pm72.c
+++ b/drivers/macintosh/therm_pm72.c
@@ -129,6 +129,7 @@
129#include <asm/sections.h> 129#include <asm/sections.h>
130#include <asm/of_device.h> 130#include <asm/of_device.h>
131#include <asm/macio.h> 131#include <asm/macio.h>
132#include <asm/of_platform.h>
132 133
133#include "therm_pm72.h" 134#include "therm_pm72.h"
134 135
@@ -2236,14 +2237,14 @@ static int __init therm_pm72_init(void)
2236 return -ENODEV; 2237 return -ENODEV;
2237 } 2238 }
2238 2239
2239 of_register_driver(&fcu_of_platform_driver); 2240 of_register_platform_driver(&fcu_of_platform_driver);
2240 2241
2241 return 0; 2242 return 0;
2242} 2243}
2243 2244
2244static void __exit therm_pm72_exit(void) 2245static void __exit therm_pm72_exit(void)
2245{ 2246{
2246 of_unregister_driver(&fcu_of_platform_driver); 2247 of_unregister_platform_driver(&fcu_of_platform_driver);
2247 2248
2248 if (of_dev) 2249 if (of_dev)
2249 of_device_unregister(of_dev); 2250 of_device_unregister(of_dev);
diff --git a/drivers/macintosh/therm_windtunnel.c b/drivers/macintosh/therm_windtunnel.c
index 738faab1b22c..a1d3a987cb3a 100644
--- a/drivers/macintosh/therm_windtunnel.c
+++ b/drivers/macintosh/therm_windtunnel.c
@@ -36,12 +36,13 @@
36#include <linux/i2c.h> 36#include <linux/i2c.h>
37#include <linux/slab.h> 37#include <linux/slab.h>
38#include <linux/init.h> 38#include <linux/init.h>
39
39#include <asm/prom.h> 40#include <asm/prom.h>
40#include <asm/machdep.h> 41#include <asm/machdep.h>
41#include <asm/io.h> 42#include <asm/io.h>
42#include <asm/system.h> 43#include <asm/system.h>
43#include <asm/sections.h> 44#include <asm/sections.h>
44#include <asm/of_device.h> 45#include <asm/of_platform.h>
45#include <asm/macio.h> 46#include <asm/macio.h>
46 47
47#define LOG_TEMP 0 /* continously log temperature */ 48#define LOG_TEMP 0 /* continously log temperature */
@@ -511,14 +512,14 @@ g4fan_init( void )
511 return -ENODEV; 512 return -ENODEV;
512 } 513 }
513 514
514 of_register_driver( &therm_of_driver ); 515 of_register_platform_driver( &therm_of_driver );
515 return 0; 516 return 0;
516} 517}
517 518
518static void __exit 519static void __exit
519g4fan_exit( void ) 520g4fan_exit( void )
520{ 521{
521 of_unregister_driver( &therm_of_driver ); 522 of_unregister_platform_driver( &therm_of_driver );
522 523
523 if( x.of_dev ) 524 if( x.of_dev )
524 of_device_unregister( x.of_dev ); 525 of_device_unregister( x.of_dev );
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
index e63ea1c1f3c1..c8558d4ed506 100644
--- a/drivers/macintosh/via-pmu.c
+++ b/drivers/macintosh/via-pmu.c
@@ -42,7 +42,7 @@
42#include <linux/interrupt.h> 42#include <linux/interrupt.h>
43#include <linux/device.h> 43#include <linux/device.h>
44#include <linux/sysdev.h> 44#include <linux/sysdev.h>
45#include <linux/suspend.h> 45#include <linux/freezer.h>
46#include <linux/syscalls.h> 46#include <linux/syscalls.h>
47#include <linux/cpu.h> 47#include <linux/cpu.h>
48#include <asm/prom.h> 48#include <asm/prom.h>
diff --git a/drivers/macintosh/windfarm_core.c b/drivers/macintosh/windfarm_core.c
index ab3faa702d58..e947af982f93 100644
--- a/drivers/macintosh/windfarm_core.c
+++ b/drivers/macintosh/windfarm_core.c
@@ -34,6 +34,7 @@
34#include <linux/device.h> 34#include <linux/device.h>
35#include <linux/platform_device.h> 35#include <linux/platform_device.h>
36#include <linux/mutex.h> 36#include <linux/mutex.h>
37#include <linux/freezer.h>
37 38
38#include <asm/prom.h> 39#include <asm/prom.h>
39 40
diff --git a/drivers/macintosh/windfarm_pm112.c b/drivers/macintosh/windfarm_pm112.c
index fa4b13f89369..b3fbb45bc90a 100644
--- a/drivers/macintosh/windfarm_pm112.c
+++ b/drivers/macintosh/windfarm_pm112.c
@@ -685,6 +685,17 @@ static int __init wf_pm112_init(void)
685 ++nr_cores; 685 ++nr_cores;
686 686
687 printk(KERN_INFO "windfarm: initializing for dual-core desktop G5\n"); 687 printk(KERN_INFO "windfarm: initializing for dual-core desktop G5\n");
688
689#ifdef MODULE
690 request_module("windfarm_smu_controls");
691 request_module("windfarm_smu_sensors");
692 request_module("windfarm_smu_sat");
693 request_module("windfarm_lm75_sensor");
694 request_module("windfarm_max6690_sensor");
695 request_module("windfarm_cpufreq_clamp");
696
697#endif /* MODULE */
698
688 platform_driver_register(&wf_pm112_driver); 699 platform_driver_register(&wf_pm112_driver);
689 return 0; 700 return 0;
690} 701}
diff --git a/drivers/macintosh/windfarm_pm81.c b/drivers/macintosh/windfarm_pm81.c
index 2a944851b8e1..f24fa734046a 100644
--- a/drivers/macintosh/windfarm_pm81.c
+++ b/drivers/macintosh/windfarm_pm81.c
@@ -788,6 +788,7 @@ static int __init wf_smu_init(void)
788 request_module("windfarm_smu_controls"); 788 request_module("windfarm_smu_controls");
789 request_module("windfarm_smu_sensors"); 789 request_module("windfarm_smu_sensors");
790 request_module("windfarm_lm75_sensor"); 790 request_module("windfarm_lm75_sensor");
791 request_module("windfarm_cpufreq_clamp");
791 792
792#endif /* MODULE */ 793#endif /* MODULE */
793 platform_driver_register(&wf_smu_driver); 794 platform_driver_register(&wf_smu_driver);
diff --git a/drivers/macintosh/windfarm_pm91.c b/drivers/macintosh/windfarm_pm91.c
index 9961a67b4f85..26eee69ebe6d 100644
--- a/drivers/macintosh/windfarm_pm91.c
+++ b/drivers/macintosh/windfarm_pm91.c
@@ -719,6 +719,7 @@ static int __init wf_smu_init(void)
719 request_module("windfarm_smu_controls"); 719 request_module("windfarm_smu_controls");
720 request_module("windfarm_smu_sensors"); 720 request_module("windfarm_smu_sensors");
721 request_module("windfarm_lm75_sensor"); 721 request_module("windfarm_lm75_sensor");
722 request_module("windfarm_cpufreq_clamp");
722 723
723#endif /* MODULE */ 724#endif /* MODULE */
724 platform_driver_register(&wf_smu_driver); 725 platform_driver_register(&wf_smu_driver);
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 08a40f4e4f60..a1086ee8cccd 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -20,6 +20,7 @@
20#include <asm/atomic.h> 20#include <asm/atomic.h>
21#include <linux/scatterlist.h> 21#include <linux/scatterlist.h>
22#include <asm/page.h> 22#include <asm/page.h>
23#include <asm/unaligned.h>
23 24
24#include "dm.h" 25#include "dm.h"
25 26
@@ -85,7 +86,10 @@ struct crypt_config {
85 */ 86 */
86 struct crypt_iv_operations *iv_gen_ops; 87 struct crypt_iv_operations *iv_gen_ops;
87 char *iv_mode; 88 char *iv_mode;
88 struct crypto_cipher *iv_gen_private; 89 union {
90 struct crypto_cipher *essiv_tfm;
91 int benbi_shift;
92 } iv_gen_private;
89 sector_t iv_offset; 93 sector_t iv_offset;
90 unsigned int iv_size; 94 unsigned int iv_size;
91 95
@@ -101,7 +105,7 @@ struct crypt_config {
101#define MIN_POOL_PAGES 32 105#define MIN_POOL_PAGES 32
102#define MIN_BIO_PAGES 8 106#define MIN_BIO_PAGES 8
103 107
104static kmem_cache_t *_crypt_io_pool; 108static struct kmem_cache *_crypt_io_pool;
105 109
106/* 110/*
107 * Different IV generation algorithms: 111 * Different IV generation algorithms:
@@ -113,6 +117,9 @@ static kmem_cache_t *_crypt_io_pool;
113 * encrypted with the bulk cipher using a salt as key. The salt 117 * encrypted with the bulk cipher using a salt as key. The salt
114 * should be derived from the bulk cipher's key via hashing. 118 * should be derived from the bulk cipher's key via hashing.
115 * 119 *
120 * benbi: the 64-bit "big-endian 'narrow block'-count", starting at 1
121 * (needed for LRW-32-AES and possible other narrow block modes)
122 *
116 * plumb: unimplemented, see: 123 * plumb: unimplemented, see:
117 * http://article.gmane.org/gmane.linux.kernel.device-mapper.dm-crypt/454 124 * http://article.gmane.org/gmane.linux.kernel.device-mapper.dm-crypt/454
118 */ 125 */
@@ -191,21 +198,61 @@ static int crypt_iv_essiv_ctr(struct crypt_config *cc, struct dm_target *ti,
191 } 198 }
192 kfree(salt); 199 kfree(salt);
193 200
194 cc->iv_gen_private = essiv_tfm; 201 cc->iv_gen_private.essiv_tfm = essiv_tfm;
195 return 0; 202 return 0;
196} 203}
197 204
198static void crypt_iv_essiv_dtr(struct crypt_config *cc) 205static void crypt_iv_essiv_dtr(struct crypt_config *cc)
199{ 206{
200 crypto_free_cipher(cc->iv_gen_private); 207 crypto_free_cipher(cc->iv_gen_private.essiv_tfm);
201 cc->iv_gen_private = NULL; 208 cc->iv_gen_private.essiv_tfm = NULL;
202} 209}
203 210
204static int crypt_iv_essiv_gen(struct crypt_config *cc, u8 *iv, sector_t sector) 211static int crypt_iv_essiv_gen(struct crypt_config *cc, u8 *iv, sector_t sector)
205{ 212{
206 memset(iv, 0, cc->iv_size); 213 memset(iv, 0, cc->iv_size);
207 *(u64 *)iv = cpu_to_le64(sector); 214 *(u64 *)iv = cpu_to_le64(sector);
208 crypto_cipher_encrypt_one(cc->iv_gen_private, iv, iv); 215 crypto_cipher_encrypt_one(cc->iv_gen_private.essiv_tfm, iv, iv);
216 return 0;
217}
218
219static int crypt_iv_benbi_ctr(struct crypt_config *cc, struct dm_target *ti,
220 const char *opts)
221{
222 unsigned int bs = crypto_blkcipher_blocksize(cc->tfm);
223 int log = long_log2(bs);
224
225 /* we need to calculate how far we must shift the sector count
226 * to get the cipher block count, we use this shift in _gen */
227
228 if (1 << log != bs) {
229 ti->error = "cypher blocksize is not a power of 2";
230 return -EINVAL;
231 }
232
233 if (log > 9) {
234 ti->error = "cypher blocksize is > 512";
235 return -EINVAL;
236 }
237
238 cc->iv_gen_private.benbi_shift = 9 - log;
239
240 return 0;
241}
242
243static void crypt_iv_benbi_dtr(struct crypt_config *cc)
244{
245}
246
247static int crypt_iv_benbi_gen(struct crypt_config *cc, u8 *iv, sector_t sector)
248{
249 __be64 val;
250
251 memset(iv, 0, cc->iv_size - sizeof(u64)); /* rest is cleared below */
252
253 val = cpu_to_be64(((u64)sector << cc->iv_gen_private.benbi_shift) + 1);
254 put_unaligned(val, (__be64 *)(iv + cc->iv_size - sizeof(u64)));
255
209 return 0; 256 return 0;
210} 257}
211 258
@@ -219,13 +266,18 @@ static struct crypt_iv_operations crypt_iv_essiv_ops = {
219 .generator = crypt_iv_essiv_gen 266 .generator = crypt_iv_essiv_gen
220}; 267};
221 268
269static struct crypt_iv_operations crypt_iv_benbi_ops = {
270 .ctr = crypt_iv_benbi_ctr,
271 .dtr = crypt_iv_benbi_dtr,
272 .generator = crypt_iv_benbi_gen
273};
222 274
223static int 275static int
224crypt_convert_scatterlist(struct crypt_config *cc, struct scatterlist *out, 276crypt_convert_scatterlist(struct crypt_config *cc, struct scatterlist *out,
225 struct scatterlist *in, unsigned int length, 277 struct scatterlist *in, unsigned int length,
226 int write, sector_t sector) 278 int write, sector_t sector)
227{ 279{
228 u8 iv[cc->iv_size]; 280 u8 iv[cc->iv_size] __attribute__ ((aligned(__alignof__(u64))));
229 struct blkcipher_desc desc = { 281 struct blkcipher_desc desc = {
230 .tfm = cc->tfm, 282 .tfm = cc->tfm,
231 .info = iv, 283 .info = iv,
@@ -458,11 +510,11 @@ static void dec_pending(struct crypt_io *io, int error)
458 * interrupt context. 510 * interrupt context.
459 */ 511 */
460static struct workqueue_struct *_kcryptd_workqueue; 512static struct workqueue_struct *_kcryptd_workqueue;
461static void kcryptd_do_work(void *data); 513static void kcryptd_do_work(struct work_struct *work);
462 514
463static void kcryptd_queue_io(struct crypt_io *io) 515static void kcryptd_queue_io(struct crypt_io *io)
464{ 516{
465 INIT_WORK(&io->work, kcryptd_do_work, io); 517 INIT_WORK(&io->work, kcryptd_do_work);
466 queue_work(_kcryptd_workqueue, &io->work); 518 queue_work(_kcryptd_workqueue, &io->work);
467} 519}
468 520
@@ -618,9 +670,9 @@ static void process_read_endio(struct crypt_io *io)
618 dec_pending(io, crypt_convert(cc, &ctx)); 670 dec_pending(io, crypt_convert(cc, &ctx));
619} 671}
620 672
621static void kcryptd_do_work(void *data) 673static void kcryptd_do_work(struct work_struct *work)
622{ 674{
623 struct crypt_io *io = data; 675 struct crypt_io *io = container_of(work, struct crypt_io, work);
624 676
625 if (io->post_process) 677 if (io->post_process)
626 process_read_endio(io); 678 process_read_endio(io);
@@ -768,7 +820,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
768 cc->tfm = tfm; 820 cc->tfm = tfm;
769 821
770 /* 822 /*
771 * Choose ivmode. Valid modes: "plain", "essiv:<esshash>". 823 * Choose ivmode. Valid modes: "plain", "essiv:<esshash>", "benbi".
772 * See comments at iv code 824 * See comments at iv code
773 */ 825 */
774 826
@@ -778,6 +830,8 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
778 cc->iv_gen_ops = &crypt_iv_plain_ops; 830 cc->iv_gen_ops = &crypt_iv_plain_ops;
779 else if (strcmp(ivmode, "essiv") == 0) 831 else if (strcmp(ivmode, "essiv") == 0)
780 cc->iv_gen_ops = &crypt_iv_essiv_ops; 832 cc->iv_gen_ops = &crypt_iv_essiv_ops;
833 else if (strcmp(ivmode, "benbi") == 0)
834 cc->iv_gen_ops = &crypt_iv_benbi_ops;
781 else { 835 else {
782 ti->error = "Invalid IV mode"; 836 ti->error = "Invalid IV mode";
783 goto bad2; 837 goto bad2;
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index d13bb15a8a02..4510ad8f971c 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -606,9 +606,14 @@ static struct hash_cell *__find_device_hash_cell(struct dm_ioctl *param)
606 return __get_name_cell(param->name); 606 return __get_name_cell(param->name);
607 607
608 md = dm_get_md(huge_decode_dev(param->dev)); 608 md = dm_get_md(huge_decode_dev(param->dev));
609 if (md) 609 if (!md)
610 mdptr = dm_get_mdptr(md); 610 goto out;
611 611
612 mdptr = dm_get_mdptr(md);
613 if (!mdptr)
614 dm_put(md);
615
616out:
612 return mdptr; 617 return mdptr;
613} 618}
614 619
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index d754e0bc6e90..cf8bf052138e 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -101,11 +101,11 @@ typedef int (*action_fn) (struct pgpath *pgpath);
101 101
102#define MIN_IOS 256 /* Mempool size */ 102#define MIN_IOS 256 /* Mempool size */
103 103
104static kmem_cache_t *_mpio_cache; 104static struct kmem_cache *_mpio_cache;
105 105
106struct workqueue_struct *kmultipathd; 106struct workqueue_struct *kmultipathd;
107static void process_queued_ios(void *data); 107static void process_queued_ios(struct work_struct *work);
108static void trigger_event(void *data); 108static void trigger_event(struct work_struct *work);
109 109
110 110
111/*----------------------------------------------- 111/*-----------------------------------------------
@@ -173,8 +173,8 @@ static struct multipath *alloc_multipath(struct dm_target *ti)
173 INIT_LIST_HEAD(&m->priority_groups); 173 INIT_LIST_HEAD(&m->priority_groups);
174 spin_lock_init(&m->lock); 174 spin_lock_init(&m->lock);
175 m->queue_io = 1; 175 m->queue_io = 1;
176 INIT_WORK(&m->process_queued_ios, process_queued_ios, m); 176 INIT_WORK(&m->process_queued_ios, process_queued_ios);
177 INIT_WORK(&m->trigger_event, trigger_event, m); 177 INIT_WORK(&m->trigger_event, trigger_event);
178 m->mpio_pool = mempool_create_slab_pool(MIN_IOS, _mpio_cache); 178 m->mpio_pool = mempool_create_slab_pool(MIN_IOS, _mpio_cache);
179 if (!m->mpio_pool) { 179 if (!m->mpio_pool) {
180 kfree(m); 180 kfree(m);
@@ -379,9 +379,10 @@ static void dispatch_queued_ios(struct multipath *m)
379 } 379 }
380} 380}
381 381
382static void process_queued_ios(void *data) 382static void process_queued_ios(struct work_struct *work)
383{ 383{
384 struct multipath *m = (struct multipath *) data; 384 struct multipath *m =
385 container_of(work, struct multipath, process_queued_ios);
385 struct hw_handler *hwh = &m->hw_handler; 386 struct hw_handler *hwh = &m->hw_handler;
386 struct pgpath *pgpath = NULL; 387 struct pgpath *pgpath = NULL;
387 unsigned init_required = 0, must_queue = 1; 388 unsigned init_required = 0, must_queue = 1;
@@ -421,9 +422,10 @@ out:
421 * An event is triggered whenever a path is taken out of use. 422 * An event is triggered whenever a path is taken out of use.
422 * Includes path failure and PG bypass. 423 * Includes path failure and PG bypass.
423 */ 424 */
424static void trigger_event(void *data) 425static void trigger_event(struct work_struct *work)
425{ 426{
426 struct multipath *m = (struct multipath *) data; 427 struct multipath *m =
428 container_of(work, struct multipath, trigger_event);
427 429
428 dm_table_event(m->ti->table); 430 dm_table_event(m->ti->table);
429} 431}
diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
index 659224cb7c53..fc8cbb168e3e 100644
--- a/drivers/md/dm-raid1.c
+++ b/drivers/md/dm-raid1.c
@@ -24,6 +24,7 @@
24 24
25static struct workqueue_struct *_kmirrord_wq; 25static struct workqueue_struct *_kmirrord_wq;
26static struct work_struct _kmirrord_work; 26static struct work_struct _kmirrord_work;
27static DECLARE_WAIT_QUEUE_HEAD(_kmirrord_recovery_stopped);
27 28
28static inline void wake(void) 29static inline void wake(void)
29{ 30{
@@ -83,6 +84,7 @@ struct region_hash {
83 struct list_head *buckets; 84 struct list_head *buckets;
84 85
85 spinlock_t region_lock; 86 spinlock_t region_lock;
87 atomic_t recovery_in_flight;
86 struct semaphore recovery_count; 88 struct semaphore recovery_count;
87 struct list_head clean_regions; 89 struct list_head clean_regions;
88 struct list_head quiesced_regions; 90 struct list_head quiesced_regions;
@@ -191,6 +193,7 @@ static int rh_init(struct region_hash *rh, struct mirror_set *ms,
191 193
192 spin_lock_init(&rh->region_lock); 194 spin_lock_init(&rh->region_lock);
193 sema_init(&rh->recovery_count, 0); 195 sema_init(&rh->recovery_count, 0);
196 atomic_set(&rh->recovery_in_flight, 0);
194 INIT_LIST_HEAD(&rh->clean_regions); 197 INIT_LIST_HEAD(&rh->clean_regions);
195 INIT_LIST_HEAD(&rh->quiesced_regions); 198 INIT_LIST_HEAD(&rh->quiesced_regions);
196 INIT_LIST_HEAD(&rh->recovered_regions); 199 INIT_LIST_HEAD(&rh->recovered_regions);
@@ -382,6 +385,8 @@ static void rh_update_states(struct region_hash *rh)
382 rh->log->type->clear_region(rh->log, reg->key); 385 rh->log->type->clear_region(rh->log, reg->key);
383 rh->log->type->complete_resync_work(rh->log, reg->key, 1); 386 rh->log->type->complete_resync_work(rh->log, reg->key, 1);
384 dispatch_bios(rh->ms, &reg->delayed_bios); 387 dispatch_bios(rh->ms, &reg->delayed_bios);
388 if (atomic_dec_and_test(&rh->recovery_in_flight))
389 wake_up_all(&_kmirrord_recovery_stopped);
385 up(&rh->recovery_count); 390 up(&rh->recovery_count);
386 mempool_free(reg, rh->region_pool); 391 mempool_free(reg, rh->region_pool);
387 } 392 }
@@ -502,11 +507,21 @@ static int __rh_recovery_prepare(struct region_hash *rh)
502 507
503static void rh_recovery_prepare(struct region_hash *rh) 508static void rh_recovery_prepare(struct region_hash *rh)
504{ 509{
505 while (!down_trylock(&rh->recovery_count)) 510 /* Extra reference to avoid race with rh_stop_recovery */
511 atomic_inc(&rh->recovery_in_flight);
512
513 while (!down_trylock(&rh->recovery_count)) {
514 atomic_inc(&rh->recovery_in_flight);
506 if (__rh_recovery_prepare(rh) <= 0) { 515 if (__rh_recovery_prepare(rh) <= 0) {
516 atomic_dec(&rh->recovery_in_flight);
507 up(&rh->recovery_count); 517 up(&rh->recovery_count);
508 break; 518 break;
509 } 519 }
520 }
521
522 /* Drop the extra reference */
523 if (atomic_dec_and_test(&rh->recovery_in_flight))
524 wake_up_all(&_kmirrord_recovery_stopped);
510} 525}
511 526
512/* 527/*
@@ -868,7 +883,7 @@ static void do_mirror(struct mirror_set *ms)
868 do_writes(ms, &writes); 883 do_writes(ms, &writes);
869} 884}
870 885
871static void do_work(void *ignored) 886static void do_work(struct work_struct *ignored)
872{ 887{
873 struct mirror_set *ms; 888 struct mirror_set *ms;
874 889
@@ -1177,6 +1192,11 @@ static void mirror_postsuspend(struct dm_target *ti)
1177 struct dirty_log *log = ms->rh.log; 1192 struct dirty_log *log = ms->rh.log;
1178 1193
1179 rh_stop_recovery(&ms->rh); 1194 rh_stop_recovery(&ms->rh);
1195
1196 /* Wait for all I/O we generated to complete */
1197 wait_event(_kmirrord_recovery_stopped,
1198 !atomic_read(&ms->rh.recovery_in_flight));
1199
1180 if (log->type->suspend && log->type->suspend(log)) 1200 if (log->type->suspend && log->type->suspend(log))
1181 /* FIXME: need better error handling */ 1201 /* FIXME: need better error handling */
1182 DMWARN("log suspend failed"); 1202 DMWARN("log suspend failed");
@@ -1249,7 +1269,7 @@ static int __init dm_mirror_init(void)
1249 dm_dirty_log_exit(); 1269 dm_dirty_log_exit();
1250 return r; 1270 return r;
1251 } 1271 }
1252 INIT_WORK(&_kmirrord_work, do_work, NULL); 1272 INIT_WORK(&_kmirrord_work, do_work);
1253 1273
1254 r = dm_register_target(&mirror_target); 1274 r = dm_register_target(&mirror_target);
1255 if (r < 0) { 1275 if (r < 0) {
diff --git a/drivers/md/dm-round-robin.c b/drivers/md/dm-round-robin.c
index c5a16c550122..6f9fcd4db9b5 100644
--- a/drivers/md/dm-round-robin.c
+++ b/drivers/md/dm-round-robin.c
@@ -136,7 +136,7 @@ static int rr_add_path(struct path_selector *ps, struct path *path,
136 136
137 path->pscontext = pi; 137 path->pscontext = pi;
138 138
139 list_add(&pi->list, &s->valid_paths); 139 list_add_tail(&pi->list, &s->valid_paths);
140 140
141 return 0; 141 return 0;
142} 142}
diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index 5281e0094072..b0ce2ce82278 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -40,7 +40,7 @@
40#define SNAPSHOT_PAGES 256 40#define SNAPSHOT_PAGES 256
41 41
42struct workqueue_struct *ksnapd; 42struct workqueue_struct *ksnapd;
43static void flush_queued_bios(void *data); 43static void flush_queued_bios(struct work_struct *work);
44 44
45struct pending_exception { 45struct pending_exception {
46 struct exception e; 46 struct exception e;
@@ -88,8 +88,8 @@ struct pending_exception {
88 * Hash table mapping origin volumes to lists of snapshots and 88 * Hash table mapping origin volumes to lists of snapshots and
89 * a lock to protect it 89 * a lock to protect it
90 */ 90 */
91static kmem_cache_t *exception_cache; 91static struct kmem_cache *exception_cache;
92static kmem_cache_t *pending_cache; 92static struct kmem_cache *pending_cache;
93static mempool_t *pending_pool; 93static mempool_t *pending_pool;
94 94
95/* 95/*
@@ -228,7 +228,7 @@ static int init_exception_table(struct exception_table *et, uint32_t size)
228 return 0; 228 return 0;
229} 229}
230 230
231static void exit_exception_table(struct exception_table *et, kmem_cache_t *mem) 231static void exit_exception_table(struct exception_table *et, struct kmem_cache *mem)
232{ 232{
233 struct list_head *slot; 233 struct list_head *slot;
234 struct exception *ex, *next; 234 struct exception *ex, *next;
@@ -528,7 +528,7 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
528 } 528 }
529 529
530 bio_list_init(&s->queued_bios); 530 bio_list_init(&s->queued_bios);
531 INIT_WORK(&s->queued_bios_work, flush_queued_bios, s); 531 INIT_WORK(&s->queued_bios_work, flush_queued_bios);
532 532
533 /* Add snapshot to the list of snapshots for this origin */ 533 /* Add snapshot to the list of snapshots for this origin */
534 /* Exceptions aren't triggered till snapshot_resume() is called */ 534 /* Exceptions aren't triggered till snapshot_resume() is called */
@@ -603,9 +603,10 @@ static void flush_bios(struct bio *bio)
603 } 603 }
604} 604}
605 605
606static void flush_queued_bios(void *data) 606static void flush_queued_bios(struct work_struct *work)
607{ 607{
608 struct dm_snapshot *s = (struct dm_snapshot *) data; 608 struct dm_snapshot *s =
609 container_of(work, struct dm_snapshot, queued_bios_work);
609 struct bio *queued_bios; 610 struct bio *queued_bios;
610 unsigned long flags; 611 unsigned long flags;
611 612
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index b5764a86c8b5..7ec1b112a6d5 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -121,8 +121,8 @@ struct mapped_device {
121}; 121};
122 122
123#define MIN_IOS 256 123#define MIN_IOS 256
124static kmem_cache_t *_io_cache; 124static struct kmem_cache *_io_cache;
125static kmem_cache_t *_tio_cache; 125static struct kmem_cache *_tio_cache;
126 126
127static int __init local_init(void) 127static int __init local_init(void)
128{ 128{
@@ -1285,7 +1285,7 @@ int dm_suspend(struct mapped_device *md, int do_lockfs)
1285 down(&md->suspend_lock); 1285 down(&md->suspend_lock);
1286 1286
1287 if (dm_suspended(md)) 1287 if (dm_suspended(md))
1288 goto out; 1288 goto out_unlock;
1289 1289
1290 map = dm_get_table(md); 1290 map = dm_get_table(md);
1291 1291
@@ -1361,6 +1361,8 @@ out:
1361 } 1361 }
1362 1362
1363 dm_table_put(map); 1363 dm_table_put(map);
1364
1365out_unlock:
1364 up(&md->suspend_lock); 1366 up(&md->suspend_lock);
1365 return r; 1367 return r;
1366} 1368}
diff --git a/drivers/md/kcopyd.c b/drivers/md/kcopyd.c
index f1db6eff4857..b46f6c575f7e 100644
--- a/drivers/md/kcopyd.c
+++ b/drivers/md/kcopyd.c
@@ -203,7 +203,7 @@ struct kcopyd_job {
203/* FIXME: this should scale with the number of pages */ 203/* FIXME: this should scale with the number of pages */
204#define MIN_JOBS 512 204#define MIN_JOBS 512
205 205
206static kmem_cache_t *_job_cache; 206static struct kmem_cache *_job_cache;
207static mempool_t *_job_pool; 207static mempool_t *_job_pool;
208 208
209/* 209/*
@@ -417,7 +417,7 @@ static int process_jobs(struct list_head *jobs, int (*fn) (struct kcopyd_job *))
417/* 417/*
418 * kcopyd does this every time it's woken up. 418 * kcopyd does this every time it's woken up.
419 */ 419 */
420static void do_work(void *ignored) 420static void do_work(struct work_struct *ignored)
421{ 421{
422 /* 422 /*
423 * The order that these are called is *very* important. 423 * The order that these are called is *very* important.
@@ -628,7 +628,7 @@ static int kcopyd_init(void)
628 } 628 }
629 629
630 kcopyd_clients++; 630 kcopyd_clients++;
631 INIT_WORK(&_kcopyd_work, do_work, NULL); 631 INIT_WORK(&_kcopyd_work, do_work);
632 mutex_unlock(&kcopyd_init_lock); 632 mutex_unlock(&kcopyd_init_lock);
633 return 0; 633 return 0;
634} 634}
diff --git a/drivers/md/md.c b/drivers/md/md.c
index d11135604403..6c4345bde07e 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -39,10 +39,10 @@
39#include <linux/raid/bitmap.h> 39#include <linux/raid/bitmap.h>
40#include <linux/sysctl.h> 40#include <linux/sysctl.h>
41#include <linux/buffer_head.h> /* for invalidate_bdev */ 41#include <linux/buffer_head.h> /* for invalidate_bdev */
42#include <linux/suspend.h>
43#include <linux/poll.h> 42#include <linux/poll.h>
44#include <linux/mutex.h> 43#include <linux/mutex.h>
45#include <linux/ctype.h> 44#include <linux/ctype.h>
45#include <linux/freezer.h>
46 46
47#include <linux/init.h> 47#include <linux/init.h>
48 48
@@ -3200,7 +3200,7 @@ static int do_md_run(mddev_t * mddev)
3200 3200
3201 mddev->changed = 1; 3201 mddev->changed = 1;
3202 md_new_event(mddev); 3202 md_new_event(mddev);
3203 kobject_uevent(&mddev->gendisk->kobj, KOBJ_ONLINE); 3203 kobject_uevent(&mddev->gendisk->kobj, KOBJ_CHANGE);
3204 return 0; 3204 return 0;
3205} 3205}
3206 3206
@@ -3314,7 +3314,6 @@ static int do_md_stop(mddev_t * mddev, int mode)
3314 3314
3315 module_put(mddev->pers->owner); 3315 module_put(mddev->pers->owner);
3316 mddev->pers = NULL; 3316 mddev->pers = NULL;
3317 kobject_uevent(&mddev->gendisk->kobj, KOBJ_OFFLINE);
3318 if (mddev->ro) 3317 if (mddev->ro)
3319 mddev->ro = 0; 3318 mddev->ro = 0;
3320 } 3319 }
@@ -4487,6 +4486,7 @@ static int md_thread(void * arg)
4487 * many dirty RAID5 blocks. 4486 * many dirty RAID5 blocks.
4488 */ 4487 */
4489 4488
4489 current->flags |= PF_NOFREEZE;
4490 allow_signal(SIGKILL); 4490 allow_signal(SIGKILL);
4491 while (!kthread_should_stop()) { 4491 while (!kthread_should_stop()) {
4492 4492
@@ -4503,7 +4503,6 @@ static int md_thread(void * arg)
4503 test_bit(THREAD_WAKEUP, &thread->flags) 4503 test_bit(THREAD_WAKEUP, &thread->flags)
4504 || kthread_should_stop(), 4504 || kthread_should_stop(),
4505 thread->timeout); 4505 thread->timeout);
4506 try_to_freeze();
4507 4506
4508 clear_bit(THREAD_WAKEUP, &thread->flags); 4507 clear_bit(THREAD_WAKEUP, &thread->flags);
4509 4508
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index e14f45780720..52914d5cec76 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -348,7 +348,7 @@ static int grow_one_stripe(raid5_conf_t *conf)
348 348
349static int grow_stripes(raid5_conf_t *conf, int num) 349static int grow_stripes(raid5_conf_t *conf, int num)
350{ 350{
351 kmem_cache_t *sc; 351 struct kmem_cache *sc;
352 int devs = conf->raid_disks; 352 int devs = conf->raid_disks;
353 353
354 sprintf(conf->cache_name[0], "raid5/%s", mdname(conf->mddev)); 354 sprintf(conf->cache_name[0], "raid5/%s", mdname(conf->mddev));
@@ -397,7 +397,7 @@ static int resize_stripes(raid5_conf_t *conf, int newsize)
397 LIST_HEAD(newstripes); 397 LIST_HEAD(newstripes);
398 struct disk_info *ndisks; 398 struct disk_info *ndisks;
399 int err = 0; 399 int err = 0;
400 kmem_cache_t *sc; 400 struct kmem_cache *sc;
401 int i; 401 int i;
402 402
403 if (newsize <= conf->pool_size) 403 if (newsize <= conf->pool_size)
@@ -3659,7 +3659,7 @@ static void end_reshape(raid5_conf_t *conf)
3659 bdev = bdget_disk(conf->mddev->gendisk, 0); 3659 bdev = bdget_disk(conf->mddev->gendisk, 0);
3660 if (bdev) { 3660 if (bdev) {
3661 mutex_lock(&bdev->bd_inode->i_mutex); 3661 mutex_lock(&bdev->bd_inode->i_mutex);
3662 i_size_write(bdev->bd_inode, conf->mddev->array_size << 10); 3662 i_size_write(bdev->bd_inode, (loff_t)conf->mddev->array_size << 10);
3663 mutex_unlock(&bdev->bd_inode->i_mutex); 3663 mutex_unlock(&bdev->bd_inode->i_mutex);
3664 bdput(bdev); 3664 bdput(bdev);
3665 } 3665 }
diff --git a/drivers/media/common/saa7146_i2c.c b/drivers/media/common/saa7146_i2c.c
index d9953f7a8b6b..5297a365c928 100644
--- a/drivers/media/common/saa7146_i2c.c
+++ b/drivers/media/common/saa7146_i2c.c
@@ -217,11 +217,9 @@ static int saa7146_i2c_writeout(struct saa7146_dev *dev, u32* dword, int short_d
217 } 217 }
218 /* wait until we get a transfer done or error */ 218 /* wait until we get a transfer done or error */
219 timeout = jiffies + HZ/100 + 1; /* 10ms */ 219 timeout = jiffies + HZ/100 + 1; /* 10ms */
220 /* first read usually delivers bogus results... */
221 saa7146_i2c_status(dev);
220 while(1) { 222 while(1) {
221 /**
222 * first read usually delivers bogus results...
223 */
224 saa7146_i2c_status(dev);
225 status = saa7146_i2c_status(dev); 223 status = saa7146_i2c_status(dev);
226 if ((status & 0x3) != 1) 224 if ((status & 0x3) != 1)
227 break; 225 break;
@@ -232,10 +230,10 @@ static int saa7146_i2c_writeout(struct saa7146_dev *dev, u32* dword, int short_d
232 DEB_I2C(("saa7146_i2c_writeout: timed out waiting for end of xfer\n")); 230 DEB_I2C(("saa7146_i2c_writeout: timed out waiting for end of xfer\n"));
233 return -EIO; 231 return -EIO;
234 } 232 }
235 if ((++trial < 20) && short_delay) 233 if (++trial < 50 && short_delay)
236 udelay(10); 234 udelay(10);
237 else 235 else
238 msleep(1); 236 msleep(1);
239 } 237 }
240 } 238 }
241 239
diff --git a/drivers/media/dvb/b2c2/flexcop-pci.c b/drivers/media/dvb/b2c2/flexcop-pci.c
index 06893243f3d4..6e166801505d 100644
--- a/drivers/media/dvb/b2c2/flexcop-pci.c
+++ b/drivers/media/dvb/b2c2/flexcop-pci.c
@@ -63,7 +63,7 @@ struct flexcop_pci {
63 63
64 unsigned long last_irq; 64 unsigned long last_irq;
65 65
66 struct work_struct irq_check_work; 66 struct delayed_work irq_check_work;
67 67
68 struct flexcop_device *fc_dev; 68 struct flexcop_device *fc_dev;
69}; 69};
@@ -97,9 +97,10 @@ static int flexcop_pci_write_ibi_reg(struct flexcop_device *fc, flexcop_ibi_regi
97 return 0; 97 return 0;
98} 98}
99 99
100static void flexcop_pci_irq_check_work(void *data) 100static void flexcop_pci_irq_check_work(struct work_struct *work)
101{ 101{
102 struct flexcop_pci *fc_pci = data; 102 struct flexcop_pci *fc_pci =
103 container_of(work, struct flexcop_pci, irq_check_work.work);
103 struct flexcop_device *fc = fc_pci->fc_dev; 104 struct flexcop_device *fc = fc_pci->fc_dev;
104 105
105 flexcop_ibi_value v = fc->read_ibi_reg(fc,sram_dest_reg_714); 106 flexcop_ibi_value v = fc->read_ibi_reg(fc,sram_dest_reg_714);
@@ -371,7 +372,7 @@ static int flexcop_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
371 if ((ret = flexcop_pci_dma_init(fc_pci)) != 0) 372 if ((ret = flexcop_pci_dma_init(fc_pci)) != 0)
372 goto err_fc_exit; 373 goto err_fc_exit;
373 374
374 INIT_WORK(&fc_pci->irq_check_work, flexcop_pci_irq_check_work, fc_pci); 375 INIT_DELAYED_WORK(&fc_pci->irq_check_work, flexcop_pci_irq_check_work);
375 376
376 return ret; 377 return ret;
377 378
diff --git a/drivers/media/dvb/b2c2/flexcop-usb.c b/drivers/media/dvb/b2c2/flexcop-usb.c
index 2853ea1bdaf1..87fb75f0d1cf 100644
--- a/drivers/media/dvb/b2c2/flexcop-usb.c
+++ b/drivers/media/dvb/b2c2/flexcop-usb.c
@@ -246,7 +246,7 @@ static int flexcop_usb_i2c_req(struct flexcop_usb *fc_usb,
246 wIndex = (chipaddr << 8 ) | addr; 246 wIndex = (chipaddr << 8 ) | addr;
247 247
248 deb_i2c("i2c %2d: %02x %02x %02x %02x %02x %02x\n",func,request_type,req, 248 deb_i2c("i2c %2d: %02x %02x %02x %02x %02x %02x\n",func,request_type,req,
249 ((wValue && 0xff) << 8),wValue >> 8,((wIndex && 0xff) << 8),wIndex >> 8); 249 wValue & 0xff, wValue >> 8, wIndex & 0xff, wIndex >> 8);
250 250
251 len = usb_control_msg(fc_usb->udev,pipe, 251 len = usb_control_msg(fc_usb->udev,pipe,
252 req, 252 req,
diff --git a/drivers/media/dvb/cinergyT2/cinergyT2.c b/drivers/media/dvb/cinergyT2/cinergyT2.c
index ff7d4f56ced3..9123147e376f 100644
--- a/drivers/media/dvb/cinergyT2/cinergyT2.c
+++ b/drivers/media/dvb/cinergyT2/cinergyT2.c
@@ -30,6 +30,7 @@
30#include <linux/input.h> 30#include <linux/input.h>
31#include <linux/dvb/frontend.h> 31#include <linux/dvb/frontend.h>
32#include <linux/mutex.h> 32#include <linux/mutex.h>
33#include <linux/mm.h>
33 34
34#include "dmxdev.h" 35#include "dmxdev.h"
35#include "dvb_demux.h" 36#include "dvb_demux.h"
@@ -127,7 +128,7 @@ struct cinergyt2 {
127 128
128 struct dvbt_set_parameters_msg param; 129 struct dvbt_set_parameters_msg param;
129 struct dvbt_get_status_msg status; 130 struct dvbt_get_status_msg status;
130 struct work_struct query_work; 131 struct delayed_work query_work;
131 132
132 wait_queue_head_t poll_wq; 133 wait_queue_head_t poll_wq;
133 int pending_fe_events; 134 int pending_fe_events;
@@ -141,7 +142,7 @@ struct cinergyt2 {
141#ifdef ENABLE_RC 142#ifdef ENABLE_RC
142 struct input_dev *rc_input_dev; 143 struct input_dev *rc_input_dev;
143 char phys[64]; 144 char phys[64];
144 struct work_struct rc_query_work; 145 struct delayed_work rc_query_work;
145 int rc_input_event; 146 int rc_input_event;
146 u32 rc_last_code; 147 u32 rc_last_code;
147 unsigned long last_event_jiffies; 148 unsigned long last_event_jiffies;
@@ -275,8 +276,7 @@ static void cinergyt2_free_stream_urbs (struct cinergyt2 *cinergyt2)
275 int i; 276 int i;
276 277
277 for (i=0; i<STREAM_URB_COUNT; i++) 278 for (i=0; i<STREAM_URB_COUNT; i++)
278 if (cinergyt2->stream_urb[i]) 279 usb_free_urb(cinergyt2->stream_urb[i]);
279 usb_free_urb(cinergyt2->stream_urb[i]);
280 280
281 usb_buffer_free(cinergyt2->udev, STREAM_URB_COUNT*STREAM_BUF_SIZE, 281 usb_buffer_free(cinergyt2->udev, STREAM_URB_COUNT*STREAM_BUF_SIZE,
282 cinergyt2->streambuf, cinergyt2->streambuf_dmahandle); 282 cinergyt2->streambuf, cinergyt2->streambuf_dmahandle);
@@ -287,7 +287,7 @@ static int cinergyt2_alloc_stream_urbs (struct cinergyt2 *cinergyt2)
287 int i; 287 int i;
288 288
289 cinergyt2->streambuf = usb_buffer_alloc(cinergyt2->udev, STREAM_URB_COUNT*STREAM_BUF_SIZE, 289 cinergyt2->streambuf = usb_buffer_alloc(cinergyt2->udev, STREAM_URB_COUNT*STREAM_BUF_SIZE,
290 SLAB_KERNEL, &cinergyt2->streambuf_dmahandle); 290 GFP_KERNEL, &cinergyt2->streambuf_dmahandle);
291 if (!cinergyt2->streambuf) { 291 if (!cinergyt2->streambuf) {
292 dprintk(1, "failed to alloc consistent stream memory area, bailing out!\n"); 292 dprintk(1, "failed to alloc consistent stream memory area, bailing out!\n");
293 return -ENOMEM; 293 return -ENOMEM;
@@ -320,8 +320,7 @@ static void cinergyt2_stop_stream_xfer (struct cinergyt2 *cinergyt2)
320 cinergyt2_control_stream_transfer(cinergyt2, 0); 320 cinergyt2_control_stream_transfer(cinergyt2, 0);
321 321
322 for (i=0; i<STREAM_URB_COUNT; i++) 322 for (i=0; i<STREAM_URB_COUNT; i++)
323 if (cinergyt2->stream_urb[i]) 323 usb_kill_urb(cinergyt2->stream_urb[i]);
324 usb_kill_urb(cinergyt2->stream_urb[i]);
325} 324}
326 325
327static int cinergyt2_start_stream_xfer (struct cinergyt2 *cinergyt2) 326static int cinergyt2_start_stream_xfer (struct cinergyt2 *cinergyt2)
@@ -724,9 +723,10 @@ static struct dvb_device cinergyt2_fe_template = {
724 723
725#ifdef ENABLE_RC 724#ifdef ENABLE_RC
726 725
727static void cinergyt2_query_rc (void *data) 726static void cinergyt2_query_rc (struct work_struct *work)
728{ 727{
729 struct cinergyt2 *cinergyt2 = data; 728 struct cinergyt2 *cinergyt2 =
729 container_of(work, struct cinergyt2, rc_query_work.work);
730 char buf[1] = { CINERGYT2_EP1_GET_RC_EVENTS }; 730 char buf[1] = { CINERGYT2_EP1_GET_RC_EVENTS };
731 struct cinergyt2_rc_event rc_events[12]; 731 struct cinergyt2_rc_event rc_events[12];
732 int n, len, i; 732 int n, len, i;
@@ -807,7 +807,7 @@ static int cinergyt2_register_rc(struct cinergyt2 *cinergyt2)
807 strlcat(cinergyt2->phys, "/input0", sizeof(cinergyt2->phys)); 807 strlcat(cinergyt2->phys, "/input0", sizeof(cinergyt2->phys));
808 cinergyt2->rc_input_event = KEY_MAX; 808 cinergyt2->rc_input_event = KEY_MAX;
809 cinergyt2->rc_last_code = ~0; 809 cinergyt2->rc_last_code = ~0;
810 INIT_WORK(&cinergyt2->rc_query_work, cinergyt2_query_rc, cinergyt2); 810 INIT_DELAYED_WORK(&cinergyt2->rc_query_work, cinergyt2_query_rc);
811 811
812 input_dev->name = DRIVER_NAME " remote control"; 812 input_dev->name = DRIVER_NAME " remote control";
813 input_dev->phys = cinergyt2->phys; 813 input_dev->phys = cinergyt2->phys;
@@ -848,9 +848,10 @@ static inline void cinergyt2_resume_rc(struct cinergyt2 *cinergyt2) { }
848 848
849#endif /* ENABLE_RC */ 849#endif /* ENABLE_RC */
850 850
851static void cinergyt2_query (void *data) 851static void cinergyt2_query (struct work_struct *work)
852{ 852{
853 struct cinergyt2 *cinergyt2 = (struct cinergyt2 *) data; 853 struct cinergyt2 *cinergyt2 =
854 container_of(work, struct cinergyt2, query_work.work);
854 char cmd [] = { CINERGYT2_EP1_GET_TUNER_STATUS }; 855 char cmd [] = { CINERGYT2_EP1_GET_TUNER_STATUS };
855 struct dvbt_get_status_msg *s = &cinergyt2->status; 856 struct dvbt_get_status_msg *s = &cinergyt2->status;
856 uint8_t lock_bits; 857 uint8_t lock_bits;
@@ -894,7 +895,7 @@ static int cinergyt2_probe (struct usb_interface *intf,
894 895
895 mutex_init(&cinergyt2->sem); 896 mutex_init(&cinergyt2->sem);
896 init_waitqueue_head (&cinergyt2->poll_wq); 897 init_waitqueue_head (&cinergyt2->poll_wq);
897 INIT_WORK(&cinergyt2->query_work, cinergyt2_query, cinergyt2); 898 INIT_DELAYED_WORK(&cinergyt2->query_work, cinergyt2_query);
898 899
899 cinergyt2->udev = interface_to_usbdev(intf); 900 cinergyt2->udev = interface_to_usbdev(intf);
900 cinergyt2->param.cmd = CINERGYT2_EP1_SET_TUNER_PARAMETERS; 901 cinergyt2->param.cmd = CINERGYT2_EP1_SET_TUNER_PARAMETERS;
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c
index 53304e6991ac..e85972222ab4 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.c
@@ -34,7 +34,7 @@
34#include <linux/module.h> 34#include <linux/module.h>
35#include <linux/moduleparam.h> 35#include <linux/moduleparam.h>
36#include <linux/list.h> 36#include <linux/list.h>
37#include <linux/suspend.h> 37#include <linux/freezer.h>
38#include <linux/jiffies.h> 38#include <linux/jiffies.h>
39#include <asm/processor.h> 39#include <asm/processor.h>
40 40
@@ -348,7 +348,7 @@ static int dvb_frontend_swzigzag_autotune(struct dvb_frontend *fe, int check_wra
348 348
349static void dvb_frontend_swzigzag(struct dvb_frontend *fe) 349static void dvb_frontend_swzigzag(struct dvb_frontend *fe)
350{ 350{
351 fe_status_t s; 351 fe_status_t s = 0;
352 struct dvb_frontend_private *fepriv = fe->frontend_priv; 352 struct dvb_frontend_private *fepriv = fe->frontend_priv;
353 353
354 /* if we've got no parameters, just keep idling */ 354 /* if we've got no parameters, just keep idling */
diff --git a/drivers/media/dvb/dvb-core/dvb_net.c b/drivers/media/dvb/dvb-core/dvb_net.c
index 8859ab74f0fe..ebf4dc5190f6 100644
--- a/drivers/media/dvb/dvb-core/dvb_net.c
+++ b/drivers/media/dvb/dvb-core/dvb_net.c
@@ -127,6 +127,7 @@ struct dvb_net_priv {
127 int in_use; 127 int in_use;
128 struct net_device_stats stats; 128 struct net_device_stats stats;
129 u16 pid; 129 u16 pid;
130 struct net_device *net;
130 struct dvb_net *host; 131 struct dvb_net *host;
131 struct dmx_demux *demux; 132 struct dmx_demux *demux;
132 struct dmx_section_feed *secfeed; 133 struct dmx_section_feed *secfeed;
@@ -1123,10 +1124,11 @@ static int dvb_set_mc_filter (struct net_device *dev, struct dev_mc_list *mc)
1123} 1124}
1124 1125
1125 1126
1126static void wq_set_multicast_list (void *data) 1127static void wq_set_multicast_list (struct work_struct *work)
1127{ 1128{
1128 struct net_device *dev = data; 1129 struct dvb_net_priv *priv =
1129 struct dvb_net_priv *priv = dev->priv; 1130 container_of(work, struct dvb_net_priv, set_multicast_list_wq);
1131 struct net_device *dev = priv->net;
1130 1132
1131 dvb_net_feed_stop(dev); 1133 dvb_net_feed_stop(dev);
1132 priv->rx_mode = RX_MODE_UNI; 1134 priv->rx_mode = RX_MODE_UNI;
@@ -1167,9 +1169,11 @@ static void dvb_net_set_multicast_list (struct net_device *dev)
1167} 1169}
1168 1170
1169 1171
1170static void wq_restart_net_feed (void *data) 1172static void wq_restart_net_feed (struct work_struct *work)
1171{ 1173{
1172 struct net_device *dev = data; 1174 struct dvb_net_priv *priv =
1175 container_of(work, struct dvb_net_priv, restart_net_feed_wq);
1176 struct net_device *dev = priv->net;
1173 1177
1174 if (netif_running(dev)) { 1178 if (netif_running(dev)) {
1175 dvb_net_feed_stop(dev); 1179 dvb_net_feed_stop(dev);
@@ -1276,6 +1280,7 @@ static int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid, u8 feedtype)
1276 dvbnet->device[if_num] = net; 1280 dvbnet->device[if_num] = net;
1277 1281
1278 priv = net->priv; 1282 priv = net->priv;
1283 priv->net = net;
1279 priv->demux = dvbnet->demux; 1284 priv->demux = dvbnet->demux;
1280 priv->pid = pid; 1285 priv->pid = pid;
1281 priv->rx_mode = RX_MODE_UNI; 1286 priv->rx_mode = RX_MODE_UNI;
@@ -1284,8 +1289,8 @@ static int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid, u8 feedtype)
1284 priv->feedtype = feedtype; 1289 priv->feedtype = feedtype;
1285 reset_ule(priv); 1290 reset_ule(priv);
1286 1291
1287 INIT_WORK(&priv->set_multicast_list_wq, wq_set_multicast_list, net); 1292 INIT_WORK(&priv->set_multicast_list_wq, wq_set_multicast_list);
1288 INIT_WORK(&priv->restart_net_feed_wq, wq_restart_net_feed, net); 1293 INIT_WORK(&priv->restart_net_feed_wq, wq_restart_net_feed);
1289 mutex_init(&priv->mutex); 1294 mutex_init(&priv->mutex);
1290 1295
1291 net->base_addr = pid; 1296 net->base_addr = pid;
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig
index 2cc5caa26a0a..a263b3f3c21d 100644
--- a/drivers/media/dvb/dvb-usb/Kconfig
+++ b/drivers/media/dvb/dvb-usb/Kconfig
@@ -26,7 +26,7 @@ config DVB_USB_A800
26 tristate "AVerMedia AverTV DVB-T USB 2.0 (A800)" 26 tristate "AVerMedia AverTV DVB-T USB 2.0 (A800)"
27 depends on DVB_USB 27 depends on DVB_USB
28 select DVB_DIB3000MC 28 select DVB_DIB3000MC
29 select DVB_TUNER_MT2060 29 select DVB_TUNER_MT2060 if !DVB_FE_CUSTOMISE
30 help 30 help
31 Say Y here to support the AVerMedia AverTV DVB-T USB 2.0 (A800) receiver. 31 Say Y here to support the AVerMedia AverTV DVB-T USB 2.0 (A800) receiver.
32 32
@@ -34,7 +34,7 @@ config DVB_USB_DIBUSB_MB
34 tristate "DiBcom USB DVB-T devices (based on the DiB3000M-B) (see help for device list)" 34 tristate "DiBcom USB DVB-T devices (based on the DiB3000M-B) (see help for device list)"
35 depends on DVB_USB 35 depends on DVB_USB
36 select DVB_DIB3000MB 36 select DVB_DIB3000MB
37 select DVB_TUNER_MT2060 37 select DVB_TUNER_MT2060 if !DVB_FE_CUSTOMISE
38 help 38 help
39 Support for USB 1.1 and 2.0 DVB-T receivers based on reference designs made by 39 Support for USB 1.1 and 2.0 DVB-T receivers based on reference designs made by
40 DiBcom (<http://www.dibcom.fr>) equipped with a DiB3000M-B demodulator. 40 DiBcom (<http://www.dibcom.fr>) equipped with a DiB3000M-B demodulator.
@@ -55,7 +55,7 @@ config DVB_USB_DIBUSB_MC
55 tristate "DiBcom USB DVB-T devices (based on the DiB3000M-C/P) (see help for device list)" 55 tristate "DiBcom USB DVB-T devices (based on the DiB3000M-C/P) (see help for device list)"
56 depends on DVB_USB 56 depends on DVB_USB
57 select DVB_DIB3000MC 57 select DVB_DIB3000MC
58 select DVB_TUNER_MT2060 58 select DVB_TUNER_MT2060 if !DVB_FE_CUSTOMISE
59 help 59 help
60 Support for USB2.0 DVB-T receivers based on reference designs made by 60 Support for USB2.0 DVB-T receivers based on reference designs made by
61 DiBcom (<http://www.dibcom.fr>) equipped with a DiB3000M-C/P demodulator. 61 DiBcom (<http://www.dibcom.fr>) equipped with a DiB3000M-C/P demodulator.
@@ -70,7 +70,7 @@ config DVB_USB_DIB0700
70 tristate "DiBcom DiB0700 USB DVB devices (see help for supported devices)" 70 tristate "DiBcom DiB0700 USB DVB devices (see help for supported devices)"
71 depends on DVB_USB 71 depends on DVB_USB
72 select DVB_DIB3000MC 72 select DVB_DIB3000MC
73 select DVB_TUNER_MT2060 73 select DVB_TUNER_MT2060 if !DVB_FE_CUSTOMISE
74 help 74 help
75 Support for USB2.0/1.1 DVB receivers based on the DiB0700 USB bridge. The 75 Support for USB2.0/1.1 DVB receivers based on the DiB0700 USB bridge. The
76 USB bridge is also present in devices having the DiB7700 DVB-T-USB 76 USB bridge is also present in devices having the DiB7700 DVB-T-USB
@@ -87,7 +87,7 @@ config DVB_USB_UMT_010
87 tristate "HanfTek UMT-010 DVB-T USB2.0 support" 87 tristate "HanfTek UMT-010 DVB-T USB2.0 support"
88 depends on DVB_USB 88 depends on DVB_USB
89 select DVB_DIB3000MC 89 select DVB_DIB3000MC
90 select DVB_TUNER_MT2060 90 select DVB_TUNER_MT2060 if !DVB_FE_CUSTOMISE
91 help 91 help
92 Say Y here to support the HanfTek UMT-010 USB2.0 stick-sized DVB-T receiver. 92 Say Y here to support the HanfTek UMT-010 USB2.0 stick-sized DVB-T receiver.
93 93
@@ -153,7 +153,7 @@ config DVB_USB_NOVA_T_USB2
153 tristate "Hauppauge WinTV-NOVA-T usb2 DVB-T USB2.0 support" 153 tristate "Hauppauge WinTV-NOVA-T usb2 DVB-T USB2.0 support"
154 depends on DVB_USB 154 depends on DVB_USB
155 select DVB_DIB3000MC 155 select DVB_DIB3000MC
156 select DVB_TUNER_MT2060 156 select DVB_TUNER_MT2060 if !DVB_FE_CUSTOMISE
157 help 157 help
158 Say Y here to support the Hauppauge WinTV-NOVA-T usb2 DVB-T USB2.0 receiver. 158 Say Y here to support the Hauppauge WinTV-NOVA-T usb2 DVB-T USB2.0 receiver.
159 159
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-remote.c b/drivers/media/dvb/dvb-usb/dvb-usb-remote.c
index 0a3a0b6c2350..794e4471561c 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-remote.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-remote.c
@@ -13,9 +13,10 @@
13 * 13 *
14 * TODO: Fix the repeat rate of the input device. 14 * TODO: Fix the repeat rate of the input device.
15 */ 15 */
16static void dvb_usb_read_remote_control(void *data) 16static void dvb_usb_read_remote_control(struct work_struct *work)
17{ 17{
18 struct dvb_usb_device *d = data; 18 struct dvb_usb_device *d =
19 container_of(work, struct dvb_usb_device, rc_query_work.work);
19 u32 event; 20 u32 event;
20 int state; 21 int state;
21 22
@@ -128,7 +129,7 @@ int dvb_usb_remote_init(struct dvb_usb_device *d)
128 129
129 input_register_device(d->rc_input_dev); 130 input_register_device(d->rc_input_dev);
130 131
131 INIT_WORK(&d->rc_query_work, dvb_usb_read_remote_control, d); 132 INIT_DELAYED_WORK(&d->rc_query_work, dvb_usb_read_remote_control);
132 133
133 info("schedule remote query interval to %d msecs.", d->props.rc_interval); 134 info("schedule remote query interval to %d msecs.", d->props.rc_interval);
134 schedule_delayed_work(&d->rc_query_work,msecs_to_jiffies(d->props.rc_interval)); 135 schedule_delayed_work(&d->rc_query_work,msecs_to_jiffies(d->props.rc_interval));
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb.h b/drivers/media/dvb/dvb-usb/dvb-usb.h
index 376c45a8e779..0d721731a524 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb.h
+++ b/drivers/media/dvb/dvb-usb/dvb-usb.h
@@ -369,7 +369,7 @@ struct dvb_usb_device {
369 /* remote control */ 369 /* remote control */
370 struct input_dev *rc_input_dev; 370 struct input_dev *rc_input_dev;
371 char rc_phys[64]; 371 char rc_phys[64];
372 struct work_struct rc_query_work; 372 struct delayed_work rc_query_work;
373 u32 last_event; 373 u32 last_event;
374 int last_state; 374 int last_state;
375 375
diff --git a/drivers/media/dvb/dvb-usb/usb-urb.c b/drivers/media/dvb/dvb-usb/usb-urb.c
index 78035ee824ca..397f51a7b2ad 100644
--- a/drivers/media/dvb/dvb-usb/usb-urb.c
+++ b/drivers/media/dvb/dvb-usb/usb-urb.c
@@ -116,7 +116,7 @@ static int usb_allocate_stream_buffers(struct usb_data_stream *stream, int num,
116 for (stream->buf_num = 0; stream->buf_num < num; stream->buf_num++) { 116 for (stream->buf_num = 0; stream->buf_num < num; stream->buf_num++) {
117 deb_mem("allocating buffer %d\n",stream->buf_num); 117 deb_mem("allocating buffer %d\n",stream->buf_num);
118 if (( stream->buf_list[stream->buf_num] = 118 if (( stream->buf_list[stream->buf_num] =
119 usb_buffer_alloc(stream->udev, size, SLAB_ATOMIC, 119 usb_buffer_alloc(stream->udev, size, GFP_ATOMIC,
120 &stream->dma_addr[stream->buf_num]) ) == NULL) { 120 &stream->dma_addr[stream->buf_num]) ) == NULL) {
121 deb_mem("not enough memory for urb-buffer allocation.\n"); 121 deb_mem("not enough memory for urb-buffer allocation.\n");
122 usb_free_stream_buffers(stream); 122 usb_free_stream_buffers(stream);
diff --git a/drivers/media/dvb/frontends/Kconfig b/drivers/media/dvb/frontends/Kconfig
index 080fa257a0bc..aebb8d6f26f8 100644
--- a/drivers/media/dvb/frontends/Kconfig
+++ b/drivers/media/dvb/frontends/Kconfig
@@ -276,6 +276,8 @@ config DVB_TDA826X
276 276
277config DVB_TUNER_MT2060 277config DVB_TUNER_MT2060
278 tristate "Microtune MT2060 silicon IF tuner" 278 tristate "Microtune MT2060 silicon IF tuner"
279 depends on I2C
280 default m if DVB_FE_CUSTOMISE
279 help 281 help
280 A driver for the silicon IF tuner MT2060 from Microtune. 282 A driver for the silicon IF tuner MT2060 from Microtune.
281 283
diff --git a/drivers/media/dvb/frontends/bcm3510.h b/drivers/media/dvb/frontends/bcm3510.h
index 6dfa839a7022..7e4f95e1734b 100644
--- a/drivers/media/dvb/frontends/bcm3510.h
+++ b/drivers/media/dvb/frontends/bcm3510.h
@@ -34,7 +34,7 @@ struct bcm3510_config
34 int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name); 34 int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name);
35}; 35};
36 36
37#if defined(CONFIG_DVB_BCM3510) || defined(CONFIG_DVB_BCM3510_MODULE) 37#if defined(CONFIG_DVB_BCM3510) || (defined(CONFIG_DVB_BCM3510_MODULE) && defined(MODULE))
38extern struct dvb_frontend* bcm3510_attach(const struct bcm3510_config* config, 38extern struct dvb_frontend* bcm3510_attach(const struct bcm3510_config* config,
39 struct i2c_adapter* i2c); 39 struct i2c_adapter* i2c);
40#else 40#else
diff --git a/drivers/media/dvb/frontends/cx22700.h b/drivers/media/dvb/frontends/cx22700.h
index 10286cc29fb4..7ac33690cdcc 100644
--- a/drivers/media/dvb/frontends/cx22700.h
+++ b/drivers/media/dvb/frontends/cx22700.h
@@ -31,7 +31,7 @@ struct cx22700_config
31 u8 demod_address; 31 u8 demod_address;
32}; 32};
33 33
34#if defined(CONFIG_DVB_CX22700) || defined(CONFIG_DVB_CX22700_MODULE) 34#if defined(CONFIG_DVB_CX22700) || (defined(CONFIG_DVB_CX22700_MODULE) && defined(MODULE))
35extern struct dvb_frontend* cx22700_attach(const struct cx22700_config* config, 35extern struct dvb_frontend* cx22700_attach(const struct cx22700_config* config,
36 struct i2c_adapter* i2c); 36 struct i2c_adapter* i2c);
37#else 37#else
diff --git a/drivers/media/dvb/frontends/cx22702.h b/drivers/media/dvb/frontends/cx22702.h
index bc217ddf02c0..9cd64da6ee40 100644
--- a/drivers/media/dvb/frontends/cx22702.h
+++ b/drivers/media/dvb/frontends/cx22702.h
@@ -41,7 +41,7 @@ struct cx22702_config
41 u8 output_mode; 41 u8 output_mode;
42}; 42};
43 43
44#if defined(CONFIG_DVB_CX22702) || defined(CONFIG_DVB_CX22702_MODULE) 44#if defined(CONFIG_DVB_CX22702) || (defined(CONFIG_DVB_CX22702_MODULE) && defined(MODULE))
45extern struct dvb_frontend* cx22702_attach(const struct cx22702_config* config, 45extern struct dvb_frontend* cx22702_attach(const struct cx22702_config* config,
46 struct i2c_adapter* i2c); 46 struct i2c_adapter* i2c);
47#else 47#else
diff --git a/drivers/media/dvb/frontends/cx24110.h b/drivers/media/dvb/frontends/cx24110.h
index c9d5ae250ebb..0ca3af4db513 100644
--- a/drivers/media/dvb/frontends/cx24110.h
+++ b/drivers/media/dvb/frontends/cx24110.h
@@ -41,7 +41,7 @@ static inline int cx24110_pll_write(struct dvb_frontend *fe, u32 val) {
41 return r; 41 return r;
42} 42}
43 43
44#if defined(CONFIG_DVB_CX24110) || defined(CONFIG_DVB_CX24110_MODULE) 44#if defined(CONFIG_DVB_CX24110) || (defined(CONFIG_DVB_CX24110_MODULE) && defined(MODULE))
45extern struct dvb_frontend* cx24110_attach(const struct cx24110_config* config, 45extern struct dvb_frontend* cx24110_attach(const struct cx24110_config* config,
46 struct i2c_adapter* i2c); 46 struct i2c_adapter* i2c);
47#else 47#else
diff --git a/drivers/media/dvb/frontends/cx24123.h b/drivers/media/dvb/frontends/cx24123.h
index 57a1dae1dc40..84f9e4f5c15e 100644
--- a/drivers/media/dvb/frontends/cx24123.h
+++ b/drivers/media/dvb/frontends/cx24123.h
@@ -35,7 +35,7 @@ struct cx24123_config
35 int lnb_polarity; 35 int lnb_polarity;
36}; 36};
37 37
38#if defined(CONFIG_DVB_CX24123) || defined(CONFIG_DVB_CX24123_MODULE) 38#if defined(CONFIG_DVB_CX24123) || (defined(CONFIG_DVB_CX24123_MODULE) && defined(MODULE))
39extern struct dvb_frontend* cx24123_attach(const struct cx24123_config* config, 39extern struct dvb_frontend* cx24123_attach(const struct cx24123_config* config,
40 struct i2c_adapter* i2c); 40 struct i2c_adapter* i2c);
41#else 41#else
diff --git a/drivers/media/dvb/frontends/dib3000.h b/drivers/media/dvb/frontends/dib3000.h
index 0caac3f0f279..a6d3854a67bc 100644
--- a/drivers/media/dvb/frontends/dib3000.h
+++ b/drivers/media/dvb/frontends/dib3000.h
@@ -41,7 +41,7 @@ struct dib_fe_xfer_ops
41 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl); 41 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
42}; 42};
43 43
44#if defined(CONFIG_DVB_DIB3000MB) || defined(CONFIG_DVB_DIB3000MB_MODULE) 44#if defined(CONFIG_DVB_DIB3000MB) || (defined(CONFIG_DVB_DIB3000MB_MODULE) && defined(MODULE))
45extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config, 45extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
46 struct i2c_adapter* i2c, struct dib_fe_xfer_ops *xfer_ops); 46 struct i2c_adapter* i2c, struct dib_fe_xfer_ops *xfer_ops);
47#else 47#else
diff --git a/drivers/media/dvb/frontends/dib3000mc.h b/drivers/media/dvb/frontends/dib3000mc.h
index 0d6fdef77538..72d4757601d8 100644
--- a/drivers/media/dvb/frontends/dib3000mc.h
+++ b/drivers/media/dvb/frontends/dib3000mc.h
@@ -39,7 +39,7 @@ struct dib3000mc_config {
39#define DEFAULT_DIB3000MC_I2C_ADDRESS 16 39#define DEFAULT_DIB3000MC_I2C_ADDRESS 16
40#define DEFAULT_DIB3000P_I2C_ADDRESS 24 40#define DEFAULT_DIB3000P_I2C_ADDRESS 24
41 41
42#if defined(CONFIG_DVB_DIB3000MC) || defined(CONFIG_DVB_DIB3000MC_MODULE) 42#if defined(CONFIG_DVB_DIB3000MC) || (defined(CONFIG_DVB_DIB3000MC_MODULE) && defined(MODULE))
43extern struct dvb_frontend * dib3000mc_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib3000mc_config *cfg); 43extern struct dvb_frontend * dib3000mc_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib3000mc_config *cfg);
44#else 44#else
45static inline struct dvb_frontend * dib3000mc_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib3000mc_config *cfg) 45static inline struct dvb_frontend * dib3000mc_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib3000mc_config *cfg)
diff --git a/drivers/media/dvb/frontends/isl6421.h b/drivers/media/dvb/frontends/isl6421.h
index 1916e3eb2df3..ea7f78a7d3cd 100644
--- a/drivers/media/dvb/frontends/isl6421.h
+++ b/drivers/media/dvb/frontends/isl6421.h
@@ -39,7 +39,7 @@
39#define ISL6421_ISEL1 0x20 39#define ISL6421_ISEL1 0x20
40#define ISL6421_DCL 0x40 40#define ISL6421_DCL 0x40
41 41
42#if defined(CONFIG_DVB_ISL6421) || defined(CONFIG_DVB_ISL6421_MODULE) 42#if defined(CONFIG_DVB_ISL6421) || (defined(CONFIG_DVB_ISL6421_MODULE) && defined(MODULE))
43/* override_set and override_clear control which system register bits (above) to always set & clear */ 43/* override_set and override_clear control which system register bits (above) to always set & clear */
44extern struct dvb_frontend *isl6421_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 i2c_addr, 44extern struct dvb_frontend *isl6421_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 i2c_addr,
45 u8 override_set, u8 override_clear); 45 u8 override_set, u8 override_clear);
diff --git a/drivers/media/dvb/frontends/l64781.c b/drivers/media/dvb/frontends/l64781.c
index f3bc82e44a28..1aeacb1c4af7 100644
--- a/drivers/media/dvb/frontends/l64781.c
+++ b/drivers/media/dvb/frontends/l64781.c
@@ -36,7 +36,7 @@ struct l64781_state {
36 struct dvb_frontend frontend; 36 struct dvb_frontend frontend;
37 37
38 /* private demodulator data */ 38 /* private demodulator data */
39 int first:1; 39 unsigned int first:1;
40}; 40};
41 41
42#define dprintk(args...) \ 42#define dprintk(args...) \
diff --git a/drivers/media/dvb/frontends/l64781.h b/drivers/media/dvb/frontends/l64781.h
index 21ba4a230760..cd15f76ff28d 100644
--- a/drivers/media/dvb/frontends/l64781.h
+++ b/drivers/media/dvb/frontends/l64781.h
@@ -31,7 +31,7 @@ struct l64781_config
31 u8 demod_address; 31 u8 demod_address;
32}; 32};
33 33
34#if defined(CONFIG_DVB_L64781) || defined(CONFIG_DVB_L64781_MODULE) 34#if defined(CONFIG_DVB_L64781) || (defined(CONFIG_DVB_L64781_MODULE) && defined(MODULE))
35extern struct dvb_frontend* l64781_attach(const struct l64781_config* config, 35extern struct dvb_frontend* l64781_attach(const struct l64781_config* config,
36 struct i2c_adapter* i2c); 36 struct i2c_adapter* i2c);
37#else 37#else
diff --git a/drivers/media/dvb/frontends/lgdt330x.h b/drivers/media/dvb/frontends/lgdt330x.h
index 3f96b485584c..995059004b10 100644
--- a/drivers/media/dvb/frontends/lgdt330x.h
+++ b/drivers/media/dvb/frontends/lgdt330x.h
@@ -52,7 +52,7 @@ struct lgdt330x_config
52 int clock_polarity_flip; 52 int clock_polarity_flip;
53}; 53};
54 54
55#if defined(CONFIG_DVB_LGDT330X) || defined(CONFIG_DVB_LGDT330X_MODULE) 55#if defined(CONFIG_DVB_LGDT330X) || (defined(CONFIG_DVB_LGDT330X_MODULE) && defined(MODULE))
56extern struct dvb_frontend* lgdt330x_attach(const struct lgdt330x_config* config, 56extern struct dvb_frontend* lgdt330x_attach(const struct lgdt330x_config* config,
57 struct i2c_adapter* i2c); 57 struct i2c_adapter* i2c);
58#else 58#else
diff --git a/drivers/media/dvb/frontends/lnbp21.h b/drivers/media/dvb/frontends/lnbp21.h
index 1fe1dd179312..68906acf7d63 100644
--- a/drivers/media/dvb/frontends/lnbp21.h
+++ b/drivers/media/dvb/frontends/lnbp21.h
@@ -39,7 +39,7 @@
39 39
40#include <linux/dvb/frontend.h> 40#include <linux/dvb/frontend.h>
41 41
42#if defined(CONFIG_DVB_LNBP21) || defined(CONFIG_DVB_LNBP21_MODULE) 42#if defined(CONFIG_DVB_LNBP21) || (defined(CONFIG_DVB_LNBP21_MODULE) && defined(MODULE))
43/* override_set and override_clear control which system register bits (above) to always set & clear */ 43/* override_set and override_clear control which system register bits (above) to always set & clear */
44extern struct dvb_frontend *lnbp21_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 override_set, u8 override_clear); 44extern struct dvb_frontend *lnbp21_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 override_set, u8 override_clear);
45#else 45#else
diff --git a/drivers/media/dvb/frontends/mt2060.h b/drivers/media/dvb/frontends/mt2060.h
index 34a37c2b556f..0a86eab3a954 100644
--- a/drivers/media/dvb/frontends/mt2060.h
+++ b/drivers/media/dvb/frontends/mt2060.h
@@ -30,6 +30,14 @@ struct mt2060_config {
30 u8 clock_out; /* 0 = off, 1 = CLK/4, 2 = CLK/2, 3 = CLK/1 */ 30 u8 clock_out; /* 0 = off, 1 = CLK/4, 2 = CLK/2, 3 = CLK/1 */
31}; 31};
32 32
33#if defined(CONFIG_DVB_TUNER_MT2060) || (defined(CONFIG_DVB_TUNER_MT2060_MODULE) && defined(MODULE))
33extern struct dvb_frontend * mt2060_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt2060_config *cfg, u16 if1); 34extern struct dvb_frontend * mt2060_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt2060_config *cfg, u16 if1);
35#else
36static inline struct dvb_frontend * mt2060_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt2060_config *cfg, u16 if1)
37{
38 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
39 return NULL;
40}
41#endif // CONFIG_DVB_TUNER_MT2060
34 42
35#endif 43#endif
diff --git a/drivers/media/dvb/frontends/mt312.h b/drivers/media/dvb/frontends/mt312.h
index 7112fb4d58ac..cf9a1505ad4b 100644
--- a/drivers/media/dvb/frontends/mt312.h
+++ b/drivers/media/dvb/frontends/mt312.h
@@ -34,7 +34,7 @@ struct mt312_config
34 u8 demod_address; 34 u8 demod_address;
35}; 35};
36 36
37#if defined(CONFIG_DVB_MT312) || defined(CONFIG_DVB_MT312_MODULE) 37#if defined(CONFIG_DVB_MT312) || (defined(CONFIG_DVB_MT312_MODULE) && defined(MODULE))
38struct dvb_frontend* vp310_mt312_attach(const struct mt312_config* config, 38struct dvb_frontend* vp310_mt312_attach(const struct mt312_config* config,
39 struct i2c_adapter* i2c); 39 struct i2c_adapter* i2c);
40#else 40#else
diff --git a/drivers/media/dvb/frontends/mt352.h b/drivers/media/dvb/frontends/mt352.h
index 0035c2e2d7c2..e9964081fd84 100644
--- a/drivers/media/dvb/frontends/mt352.h
+++ b/drivers/media/dvb/frontends/mt352.h
@@ -51,7 +51,7 @@ struct mt352_config
51 int (*demod_init)(struct dvb_frontend* fe); 51 int (*demod_init)(struct dvb_frontend* fe);
52}; 52};
53 53
54#if defined(CONFIG_DVB_MT352) || defined(CONFIG_DVB_MT352_MODULE) 54#if defined(CONFIG_DVB_MT352) || (defined(CONFIG_DVB_MT352_MODULE) && defined(MODULE))
55extern struct dvb_frontend* mt352_attach(const struct mt352_config* config, 55extern struct dvb_frontend* mt352_attach(const struct mt352_config* config,
56 struct i2c_adapter* i2c); 56 struct i2c_adapter* i2c);
57#else 57#else
diff --git a/drivers/media/dvb/frontends/nxt200x.h b/drivers/media/dvb/frontends/nxt200x.h
index 2eb220e98062..28bc5591b319 100644
--- a/drivers/media/dvb/frontends/nxt200x.h
+++ b/drivers/media/dvb/frontends/nxt200x.h
@@ -45,7 +45,7 @@ struct nxt200x_config
45 int (*set_ts_params)(struct dvb_frontend* fe, int is_punctured); 45 int (*set_ts_params)(struct dvb_frontend* fe, int is_punctured);
46}; 46};
47 47
48#if defined(CONFIG_DVB_NXT200X) || defined(CONFIG_DVB_NXT200X_MODULE) 48#if defined(CONFIG_DVB_NXT200X) || (defined(CONFIG_DVB_NXT200X_MODULE) && defined(MODULE))
49extern struct dvb_frontend* nxt200x_attach(const struct nxt200x_config* config, 49extern struct dvb_frontend* nxt200x_attach(const struct nxt200x_config* config,
50 struct i2c_adapter* i2c); 50 struct i2c_adapter* i2c);
51#else 51#else
diff --git a/drivers/media/dvb/frontends/nxt6000.h b/drivers/media/dvb/frontends/nxt6000.h
index 9397393a6bd1..13d22518356e 100644
--- a/drivers/media/dvb/frontends/nxt6000.h
+++ b/drivers/media/dvb/frontends/nxt6000.h
@@ -33,7 +33,7 @@ struct nxt6000_config
33 u8 clock_inversion:1; 33 u8 clock_inversion:1;
34}; 34};
35 35
36#if defined(CONFIG_DVB_NXT6000) || defined(CONFIG_DVB_NXT6000_MODULE) 36#if defined(CONFIG_DVB_NXT6000) || (defined(CONFIG_DVB_NXT6000_MODULE) && defined(MODULE))
37extern struct dvb_frontend* nxt6000_attach(const struct nxt6000_config* config, 37extern struct dvb_frontend* nxt6000_attach(const struct nxt6000_config* config,
38 struct i2c_adapter* i2c); 38 struct i2c_adapter* i2c);
39#else 39#else
diff --git a/drivers/media/dvb/frontends/or51132.h b/drivers/media/dvb/frontends/or51132.h
index 9718be4fb835..add24f0a743b 100644
--- a/drivers/media/dvb/frontends/or51132.h
+++ b/drivers/media/dvb/frontends/or51132.h
@@ -34,7 +34,7 @@ struct or51132_config
34 int (*set_ts_params)(struct dvb_frontend* fe, int is_punctured); 34 int (*set_ts_params)(struct dvb_frontend* fe, int is_punctured);
35}; 35};
36 36
37#if defined(CONFIG_DVB_OR51132) || defined(CONFIG_DVB_OR51132_MODULE) 37#if defined(CONFIG_DVB_OR51132) || (defined(CONFIG_DVB_OR51132_MODULE) && defined(MODULE))
38extern struct dvb_frontend* or51132_attach(const struct or51132_config* config, 38extern struct dvb_frontend* or51132_attach(const struct or51132_config* config,
39 struct i2c_adapter* i2c); 39 struct i2c_adapter* i2c);
40#else 40#else
diff --git a/drivers/media/dvb/frontends/or51211.h b/drivers/media/dvb/frontends/or51211.h
index 10a5419f9e00..8aad8402d615 100644
--- a/drivers/media/dvb/frontends/or51211.h
+++ b/drivers/media/dvb/frontends/or51211.h
@@ -37,7 +37,7 @@ struct or51211_config
37 void (*sleep)(struct dvb_frontend * fe); 37 void (*sleep)(struct dvb_frontend * fe);
38}; 38};
39 39
40#if defined(CONFIG_DVB_OR51211) || defined(CONFIG_DVB_OR51211_MODULE) 40#if defined(CONFIG_DVB_OR51211) || (defined(CONFIG_DVB_OR51211_MODULE) && defined(MODULE))
41extern struct dvb_frontend* or51211_attach(const struct or51211_config* config, 41extern struct dvb_frontend* or51211_attach(const struct or51211_config* config,
42 struct i2c_adapter* i2c); 42 struct i2c_adapter* i2c);
43#else 43#else
diff --git a/drivers/media/dvb/frontends/s5h1420.h b/drivers/media/dvb/frontends/s5h1420.h
index efc54d7f3c55..1555870f7226 100644
--- a/drivers/media/dvb/frontends/s5h1420.h
+++ b/drivers/media/dvb/frontends/s5h1420.h
@@ -34,7 +34,7 @@ struct s5h1420_config
34 u8 invert:1; 34 u8 invert:1;
35}; 35};
36 36
37#if defined(CONFIG_DVB_S5H1420) || defined(CONFIG_DVB_S5H1420_MODULE) 37#if defined(CONFIG_DVB_S5H1420) || (defined(CONFIG_DVB_S5H1420_MODULE) && defined(MODULE))
38extern struct dvb_frontend* s5h1420_attach(const struct s5h1420_config* config, 38extern struct dvb_frontend* s5h1420_attach(const struct s5h1420_config* config,
39 struct i2c_adapter* i2c); 39 struct i2c_adapter* i2c);
40#else 40#else
diff --git a/drivers/media/dvb/frontends/sp8870.h b/drivers/media/dvb/frontends/sp8870.h
index 4cf27d3b10f2..909cefe7139e 100644
--- a/drivers/media/dvb/frontends/sp8870.h
+++ b/drivers/media/dvb/frontends/sp8870.h
@@ -35,7 +35,7 @@ struct sp8870_config
35 int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name); 35 int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name);
36}; 36};
37 37
38#if defined(CONFIG_DVB_SP8870) || defined(CONFIG_DVB_SP8870_MODULE) 38#if defined(CONFIG_DVB_SP8870) || (defined(CONFIG_DVB_SP8870_MODULE) && defined(MODULE))
39extern struct dvb_frontend* sp8870_attach(const struct sp8870_config* config, 39extern struct dvb_frontend* sp8870_attach(const struct sp8870_config* config,
40 struct i2c_adapter* i2c); 40 struct i2c_adapter* i2c);
41#else 41#else
diff --git a/drivers/media/dvb/frontends/sp887x.h b/drivers/media/dvb/frontends/sp887x.h
index cab7ea644dfa..7ee78d7d916d 100644
--- a/drivers/media/dvb/frontends/sp887x.h
+++ b/drivers/media/dvb/frontends/sp887x.h
@@ -17,7 +17,7 @@ struct sp887x_config
17 int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name); 17 int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name);
18}; 18};
19 19
20#if defined(CONFIG_DVB_SP887X) || defined(CONFIG_DVB_SP887X_MODULE) 20#if defined(CONFIG_DVB_SP887X) || (defined(CONFIG_DVB_SP887X_MODULE) && defined(MODULE))
21extern struct dvb_frontend* sp887x_attach(const struct sp887x_config* config, 21extern struct dvb_frontend* sp887x_attach(const struct sp887x_config* config,
22 struct i2c_adapter* i2c); 22 struct i2c_adapter* i2c);
23#else 23#else
diff --git a/drivers/media/dvb/frontends/stv0297.h b/drivers/media/dvb/frontends/stv0297.h
index 760b80db43a5..69f4515df2b9 100644
--- a/drivers/media/dvb/frontends/stv0297.h
+++ b/drivers/media/dvb/frontends/stv0297.h
@@ -42,7 +42,7 @@ struct stv0297_config
42 u8 stop_during_read:1; 42 u8 stop_during_read:1;
43}; 43};
44 44
45#if defined(CONFIG_DVB_STV0297) || defined(CONFIG_DVB_STV0297_MODULE) 45#if defined(CONFIG_DVB_STV0297) || (defined(CONFIG_DVB_STV0297_MODULE) && defined(MODULE))
46extern struct dvb_frontend* stv0297_attach(const struct stv0297_config* config, 46extern struct dvb_frontend* stv0297_attach(const struct stv0297_config* config,
47 struct i2c_adapter* i2c); 47 struct i2c_adapter* i2c);
48#else 48#else
diff --git a/drivers/media/dvb/frontends/stv0299.h b/drivers/media/dvb/frontends/stv0299.h
index 7ef25207081d..33df9495908f 100644
--- a/drivers/media/dvb/frontends/stv0299.h
+++ b/drivers/media/dvb/frontends/stv0299.h
@@ -89,7 +89,7 @@ struct stv0299_config
89 int (*set_symbol_rate)(struct dvb_frontend* fe, u32 srate, u32 ratio); 89 int (*set_symbol_rate)(struct dvb_frontend* fe, u32 srate, u32 ratio);
90}; 90};
91 91
92#if defined(CONFIG_DVB_STV0299) || defined(CONFIG_DVB_STV0299_MODULE) 92#if defined(CONFIG_DVB_STV0299) || (defined(CONFIG_DVB_STV0299_MODULE) && defined(MODULE))
93extern struct dvb_frontend* stv0299_attach(const struct stv0299_config* config, 93extern struct dvb_frontend* stv0299_attach(const struct stv0299_config* config,
94 struct i2c_adapter* i2c); 94 struct i2c_adapter* i2c);
95#else 95#else
diff --git a/drivers/media/dvb/frontends/tda10021.h b/drivers/media/dvb/frontends/tda10021.h
index d68ae20c8412..e3da780108f6 100644
--- a/drivers/media/dvb/frontends/tda10021.h
+++ b/drivers/media/dvb/frontends/tda10021.h
@@ -32,7 +32,7 @@ struct tda10021_config
32 u8 demod_address; 32 u8 demod_address;
33}; 33};
34 34
35#if defined(CONFIG_DVB_TDA10021) || defined(CONFIG_DVB_TDA10021_MODULE) 35#if defined(CONFIG_DVB_TDA10021) || (defined(CONFIG_DVB_TDA10021_MODULE) && defined(MODULE))
36extern struct dvb_frontend* tda10021_attach(const struct tda10021_config* config, 36extern struct dvb_frontend* tda10021_attach(const struct tda10021_config* config,
37 struct i2c_adapter* i2c, u8 pwm); 37 struct i2c_adapter* i2c, u8 pwm);
38#else 38#else
diff --git a/drivers/media/dvb/frontends/tda1004x.h b/drivers/media/dvb/frontends/tda1004x.h
index e28fca05734c..605ad2dfc09d 100644
--- a/drivers/media/dvb/frontends/tda1004x.h
+++ b/drivers/media/dvb/frontends/tda1004x.h
@@ -71,7 +71,7 @@ struct tda1004x_config
71 int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name); 71 int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name);
72}; 72};
73 73
74#if defined(CONFIG_DVB_TDA1004X) || defined(CONFIG_DVB_TDA1004X_MODULE) 74#if defined(CONFIG_DVB_TDA1004X) || (defined(CONFIG_DVB_TDA1004X_MODULE) && defined(MODULE))
75extern struct dvb_frontend* tda10045_attach(const struct tda1004x_config* config, 75extern struct dvb_frontend* tda10045_attach(const struct tda1004x_config* config,
76 struct i2c_adapter* i2c); 76 struct i2c_adapter* i2c);
77 77
diff --git a/drivers/media/dvb/frontends/tda10086.c b/drivers/media/dvb/frontends/tda10086.c
index 7456b0b9976b..4c27a2d90a38 100644
--- a/drivers/media/dvb/frontends/tda10086.c
+++ b/drivers/media/dvb/frontends/tda10086.c
@@ -441,6 +441,10 @@ static int tda10086_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_pa
441 441
442 dprintk ("%s\n", __FUNCTION__); 442 dprintk ("%s\n", __FUNCTION__);
443 443
444 // check for invalid symbol rate
445 if (fe_params->u.qpsk.symbol_rate < 500000)
446 return -EINVAL;
447
444 // calculate the updated frequency (note: we convert from Hz->kHz) 448 // calculate the updated frequency (note: we convert from Hz->kHz)
445 tmp64 = tda10086_read_byte(state, 0x52); 449 tmp64 = tda10086_read_byte(state, 0x52);
446 tmp64 |= (tda10086_read_byte(state, 0x51) << 8); 450 tmp64 |= (tda10086_read_byte(state, 0x51) << 8);
diff --git a/drivers/media/dvb/frontends/tda10086.h b/drivers/media/dvb/frontends/tda10086.h
index 18457adee30b..ed584a8f4a89 100644
--- a/drivers/media/dvb/frontends/tda10086.h
+++ b/drivers/media/dvb/frontends/tda10086.h
@@ -35,7 +35,7 @@ struct tda10086_config
35 u8 invert; 35 u8 invert;
36}; 36};
37 37
38#if defined(CONFIG_DVB_TDA10086) || defined(CONFIG_DVB_TDA10086_MODULE) 38#if defined(CONFIG_DVB_TDA10086) || (defined(CONFIG_DVB_TDA10086_MODULE) && defined(MODULE))
39extern struct dvb_frontend* tda10086_attach(const struct tda10086_config* config, 39extern struct dvb_frontend* tda10086_attach(const struct tda10086_config* config,
40 struct i2c_adapter* i2c); 40 struct i2c_adapter* i2c);
41#else 41#else
diff --git a/drivers/media/dvb/frontends/tda8083.h b/drivers/media/dvb/frontends/tda8083.h
index aae15bdce6eb..2d3307999f21 100644
--- a/drivers/media/dvb/frontends/tda8083.h
+++ b/drivers/media/dvb/frontends/tda8083.h
@@ -35,7 +35,7 @@ struct tda8083_config
35 u8 demod_address; 35 u8 demod_address;
36}; 36};
37 37
38#if defined(CONFIG_DVB_TDA8083) || defined(CONFIG_DVB_TDA8083_MODULE) 38#if defined(CONFIG_DVB_TDA8083) || (defined(CONFIG_DVB_TDA8083_MODULE) && defined(MODULE))
39extern struct dvb_frontend* tda8083_attach(const struct tda8083_config* config, 39extern struct dvb_frontend* tda8083_attach(const struct tda8083_config* config,
40 struct i2c_adapter* i2c); 40 struct i2c_adapter* i2c);
41#else 41#else
diff --git a/drivers/media/dvb/frontends/tda826x.c b/drivers/media/dvb/frontends/tda826x.c
index eeab26bd36ed..34815b0b97e4 100644
--- a/drivers/media/dvb/frontends/tda826x.c
+++ b/drivers/media/dvb/frontends/tda826x.c
@@ -121,7 +121,7 @@ static struct dvb_tuner_ops tda826x_tuner_ops = {
121 .info = { 121 .info = {
122 .name = "Philips TDA826X", 122 .name = "Philips TDA826X",
123 .frequency_min = 950000, 123 .frequency_min = 950000,
124 .frequency_min = 2175000 124 .frequency_max = 2175000
125 }, 125 },
126 .release = tda826x_release, 126 .release = tda826x_release,
127 .sleep = tda826x_sleep, 127 .sleep = tda826x_sleep,
diff --git a/drivers/media/dvb/frontends/tda826x.h b/drivers/media/dvb/frontends/tda826x.h
index 83998c001196..ad9981195961 100644
--- a/drivers/media/dvb/frontends/tda826x.h
+++ b/drivers/media/dvb/frontends/tda826x.h
@@ -35,7 +35,7 @@
35 * @param has_loopthrough Set to 1 if the card has a loopthrough RF connector. 35 * @param has_loopthrough Set to 1 if the card has a loopthrough RF connector.
36 * @return FE pointer on success, NULL on failure. 36 * @return FE pointer on success, NULL on failure.
37 */ 37 */
38#if defined(CONFIG_DVB_TDA826X) || defined(CONFIG_DVB_TDA826X_MODULE) 38#if defined(CONFIG_DVB_TDA826X) || (defined(CONFIG_DVB_TDA826X_MODULE) && defined(MODULE))
39extern struct dvb_frontend* tda826x_attach(struct dvb_frontend *fe, int addr, 39extern struct dvb_frontend* tda826x_attach(struct dvb_frontend *fe, int addr,
40 struct i2c_adapter *i2c, 40 struct i2c_adapter *i2c,
41 int has_loopthrough); 41 int has_loopthrough);
diff --git a/drivers/media/dvb/frontends/tua6100.h b/drivers/media/dvb/frontends/tua6100.h
index 8f98033ffa7b..03a665e7df6d 100644
--- a/drivers/media/dvb/frontends/tua6100.h
+++ b/drivers/media/dvb/frontends/tua6100.h
@@ -34,7 +34,7 @@
34#include <linux/i2c.h> 34#include <linux/i2c.h>
35#include "dvb_frontend.h" 35#include "dvb_frontend.h"
36 36
37#if defined(CONFIG_DVB_TUA6100) || defined(CONFIG_DVB_TUA6100_MODULE) 37#if defined(CONFIG_DVB_TUA6100) || (defined(CONFIG_DVB_TUA6100_MODULE) && defined(MODULE))
38extern struct dvb_frontend *tua6100_attach(struct dvb_frontend *fe, int addr, struct i2c_adapter *i2c); 38extern struct dvb_frontend *tua6100_attach(struct dvb_frontend *fe, int addr, struct i2c_adapter *i2c);
39#else 39#else
40static inline struct dvb_frontend* tua6100_attach(struct dvb_frontend *fe, int addr, struct i2c_adapter *i2c) 40static inline struct dvb_frontend* tua6100_attach(struct dvb_frontend *fe, int addr, struct i2c_adapter *i2c)
diff --git a/drivers/media/dvb/frontends/ves1820.h b/drivers/media/dvb/frontends/ves1820.h
index f0c9dded39d7..e4a2a324046a 100644
--- a/drivers/media/dvb/frontends/ves1820.h
+++ b/drivers/media/dvb/frontends/ves1820.h
@@ -41,7 +41,7 @@ struct ves1820_config
41 u8 selagc:1; 41 u8 selagc:1;
42}; 42};
43 43
44#if defined(CONFIG_DVB_VES1820) || defined(CONFIG_DVB_VES1820_MODULE) 44#if defined(CONFIG_DVB_VES1820) || (defined(CONFIG_DVB_VES1820_MODULE) && defined(MODULE))
45extern struct dvb_frontend* ves1820_attach(const struct ves1820_config* config, 45extern struct dvb_frontend* ves1820_attach(const struct ves1820_config* config,
46 struct i2c_adapter* i2c, u8 pwm); 46 struct i2c_adapter* i2c, u8 pwm);
47#else 47#else
diff --git a/drivers/media/dvb/frontends/ves1x93.h b/drivers/media/dvb/frontends/ves1x93.h
index 395fed39b286..d507f8966f81 100644
--- a/drivers/media/dvb/frontends/ves1x93.h
+++ b/drivers/media/dvb/frontends/ves1x93.h
@@ -40,7 +40,7 @@ struct ves1x93_config
40 u8 invert_pwm:1; 40 u8 invert_pwm:1;
41}; 41};
42 42
43#if defined(CONFIG_DVB_VES1X93) || defined(CONFIG_DVB_VES1X93_MODULE) 43#if defined(CONFIG_DVB_VES1X93) || (defined(CONFIG_DVB_VES1X93_MODULE) && defined(MODULE))
44extern struct dvb_frontend* ves1x93_attach(const struct ves1x93_config* config, 44extern struct dvb_frontend* ves1x93_attach(const struct ves1x93_config* config,
45 struct i2c_adapter* i2c); 45 struct i2c_adapter* i2c);
46#else 46#else
diff --git a/drivers/media/dvb/frontends/zl10353.h b/drivers/media/dvb/frontends/zl10353.h
index 79a947215c4d..0bc0109737f1 100644
--- a/drivers/media/dvb/frontends/zl10353.h
+++ b/drivers/media/dvb/frontends/zl10353.h
@@ -36,7 +36,7 @@ struct zl10353_config
36 int parallel_ts; 36 int parallel_ts;
37}; 37};
38 38
39#if defined(CONFIG_DVB_ZL10353) || defined(CONFIG_DVB_ZL10353_MODULE) 39#if defined(CONFIG_DVB_ZL10353) || (defined(CONFIG_DVB_ZL10353_MODULE) && defined(MODULE))
40extern struct dvb_frontend* zl10353_attach(const struct zl10353_config *config, 40extern struct dvb_frontend* zl10353_attach(const struct zl10353_config *config,
41 struct i2c_adapter *i2c); 41 struct i2c_adapter *i2c);
42#else 42#else
diff --git a/drivers/media/dvb/ttpci/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c
index 2a2e9b400613..cd5ec489af1c 100644
--- a/drivers/media/dvb/ttpci/budget-ci.c
+++ b/drivers/media/dvb/ttpci/budget-ci.c
@@ -46,7 +46,14 @@
46#include "bsbe1.h" 46#include "bsbe1.h"
47#include "bsru6.h" 47#include "bsru6.h"
48 48
49#define DEBIADDR_IR 0x1234 49/*
50 * Regarding DEBIADDR_IR:
51 * Some CI modules hang if random addresses are read.
52 * Using address 0x4000 for the IR read means that we
53 * use the same address as for CI version, which should
54 * be a safe default.
55 */
56#define DEBIADDR_IR 0x4000
50#define DEBIADDR_CICONTROL 0x0000 57#define DEBIADDR_CICONTROL 0x0000
51#define DEBIADDR_CIVERSION 0x4000 58#define DEBIADDR_CIVERSION 0x4000
52#define DEBIADDR_IO 0x1000 59#define DEBIADDR_IO 0x1000
@@ -1028,6 +1035,7 @@ static void frontend_init(struct budget_ci *budget_ci)
1028 1035
1029 case 0x1012: // TT DVB-T CI budget (tda10046/Philips tdm1316l(tda6651tt)) 1036 case 0x1012: // TT DVB-T CI budget (tda10046/Philips tdm1316l(tda6651tt))
1030 budget_ci->tuner_pll_address = 0x60; 1037 budget_ci->tuner_pll_address = 0x60;
1038 philips_tdm1316l_config.invert = 1;
1031 budget_ci->budget.dvb_frontend = 1039 budget_ci->budget.dvb_frontend =
1032 dvb_attach(tda10046_attach, &philips_tdm1316l_config, &budget_ci->budget.i2c_adap); 1040 dvb_attach(tda10046_attach, &philips_tdm1316l_config, &budget_ci->budget.i2c_adap);
1033 if (budget_ci->budget.dvb_frontend) { 1041 if (budget_ci->budget.dvb_frontend) {
diff --git a/drivers/media/dvb/ttpci/budget-patch.c b/drivers/media/dvb/ttpci/budget-patch.c
index fc1267b8c892..9a155396d6ac 100644
--- a/drivers/media/dvb/ttpci/budget-patch.c
+++ b/drivers/media/dvb/ttpci/budget-patch.c
@@ -500,14 +500,14 @@ static int budget_patch_attach (struct saa7146_dev* dev, struct saa7146_pci_exte
500 500
501/* New design (By Emard) 501/* New design (By Emard)
502** this rps1 code will copy internal HS event to GPIO3 pin. 502** this rps1 code will copy internal HS event to GPIO3 pin.
503** GPIO3 is in budget-patch hardware connectd to port B VSYNC 503** GPIO3 is in budget-patch hardware connected to port B VSYNC
504 504
505** HS is an internal event of 7146, accessible with RPS 505** HS is an internal event of 7146, accessible with RPS
506** and temporarily raised high every n lines 506** and temporarily raised high every n lines
507** (n in defined in the RPS_THRESH1 counter threshold) 507** (n in defined in the RPS_THRESH1 counter threshold)
508** I think HS is raised high on the beginning of the n-th line 508** I think HS is raised high on the beginning of the n-th line
509** and remains high until this n-th line that triggered 509** and remains high until this n-th line that triggered
510** it is completely received. When the receiption of n-th line 510** it is completely received. When the reception of n-th line
511** ends, HS is lowered. 511** ends, HS is lowered.
512 512
513** To transmit data over DMA, 7146 needs changing state at 513** To transmit data over DMA, 7146 needs changing state at
@@ -541,7 +541,7 @@ static int budget_patch_attach (struct saa7146_dev* dev, struct saa7146_pci_exte
541** hardware debug note: a working budget card (including budget patch) 541** hardware debug note: a working budget card (including budget patch)
542** with vpeirq() interrupt setup in mode "0x90" (every 64K) will 542** with vpeirq() interrupt setup in mode "0x90" (every 64K) will
543** generate 3 interrupts per 25-Hz DMA frame of 2*188*512 bytes 543** generate 3 interrupts per 25-Hz DMA frame of 2*188*512 bytes
544** and that means 3*25=75 Hz of interrupt freqency, as seen by 544** and that means 3*25=75 Hz of interrupt frequency, as seen by
545** watch cat /proc/interrupts 545** watch cat /proc/interrupts
546** 546**
547** If this frequency is 3x lower (and data received in the DMA 547** If this frequency is 3x lower (and data received in the DMA
@@ -550,7 +550,7 @@ static int budget_patch_attach (struct saa7146_dev* dev, struct saa7146_pci_exte
550** this means VSYNC line is not connected in the hardware. 550** this means VSYNC line is not connected in the hardware.
551** (check soldering pcb and pins) 551** (check soldering pcb and pins)
552** The same behaviour of missing VSYNC can be duplicated on budget 552** The same behaviour of missing VSYNC can be duplicated on budget
553** cards, by seting DD1_INIT trigger mode 7 in 3rd nibble. 553** cards, by setting DD1_INIT trigger mode 7 in 3rd nibble.
554*/ 554*/
555 555
556 // Setup RPS1 "program" (p35) 556 // Setup RPS1 "program" (p35)
diff --git a/drivers/media/dvb/ttpci/budget.c b/drivers/media/dvb/ttpci/budget.c
index e58f0391e9d1..56f1c80defc6 100644
--- a/drivers/media/dvb/ttpci/budget.c
+++ b/drivers/media/dvb/ttpci/budget.c
@@ -46,6 +46,10 @@
46#include "lnbp21.h" 46#include "lnbp21.h"
47#include "bsru6.h" 47#include "bsru6.h"
48 48
49static int diseqc_method;
50module_param(diseqc_method, int, 0444);
51MODULE_PARM_DESC(diseqc_method, "Select DiSEqC method for subsystem id 13c2:1003, 0: default, 1: more reliable (for newer revisions only)");
52
49static void Set22K (struct budget *budget, int state) 53static void Set22K (struct budget *budget, int state)
50{ 54{
51 struct saa7146_dev *dev=budget->dev; 55 struct saa7146_dev *dev=budget->dev;
@@ -382,6 +386,11 @@ static void frontend_init(struct budget *budget)
382 if (budget->dvb_frontend) { 386 if (budget->dvb_frontend) {
383 budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params; 387 budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params;
384 budget->dvb_frontend->tuner_priv = &budget->i2c_adap; 388 budget->dvb_frontend->tuner_priv = &budget->i2c_adap;
389 if (budget->dev->pci->subsystem_device == 0x1003 && diseqc_method == 0) {
390 budget->dvb_frontend->ops.diseqc_send_master_cmd = budget_diseqc_send_master_cmd;
391 budget->dvb_frontend->ops.diseqc_send_burst = budget_diseqc_send_burst;
392 budget->dvb_frontend->ops.set_tone = budget_set_tone;
393 }
385 break; 394 break;
386 } 395 }
387 break; 396 break;
diff --git a/drivers/media/dvb/ttusb-dec/ttusb_dec.c b/drivers/media/dvb/ttusb-dec/ttusb_dec.c
index a1c9fa9919ea..10b121ada833 100644
--- a/drivers/media/dvb/ttusb-dec/ttusb_dec.c
+++ b/drivers/media/dvb/ttusb-dec/ttusb_dec.c
@@ -1135,8 +1135,7 @@ static void ttusb_dec_free_iso_urbs(struct ttusb_dec *dec)
1135 dprintk("%s\n", __FUNCTION__); 1135 dprintk("%s\n", __FUNCTION__);
1136 1136
1137 for (i = 0; i < ISO_BUF_COUNT; i++) 1137 for (i = 0; i < ISO_BUF_COUNT; i++)
1138 if (dec->iso_urb[i]) 1138 usb_free_urb(dec->iso_urb[i]);
1139 usb_free_urb(dec->iso_urb[i]);
1140 1139
1141 pci_free_consistent(NULL, 1140 pci_free_consistent(NULL,
1142 ISO_FRAME_SIZE * (FRAMES_PER_ISO_BUF * 1141 ISO_FRAME_SIZE * (FRAMES_PER_ISO_BUF *
@@ -1245,7 +1244,7 @@ static int ttusb_dec_init_usb(struct ttusb_dec *dec)
1245 return -ENOMEM; 1244 return -ENOMEM;
1246 } 1245 }
1247 dec->irq_buffer = usb_buffer_alloc(dec->udev,IRQ_PACKET_SIZE, 1246 dec->irq_buffer = usb_buffer_alloc(dec->udev,IRQ_PACKET_SIZE,
1248 SLAB_ATOMIC, &dec->irq_dma_handle); 1247 GFP_ATOMIC, &dec->irq_dma_handle);
1249 if(!dec->irq_buffer) { 1248 if(!dec->irq_buffer) {
1250 return -ENOMEM; 1249 return -ENOMEM;
1251 } 1250 }
diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig
index 6d96b17a7f81..920b63f8cf05 100644
--- a/drivers/media/radio/Kconfig
+++ b/drivers/media/radio/Kconfig
@@ -173,38 +173,6 @@ config RADIO_MAESTRO
173 To compile this driver as a module, choose M here: the 173 To compile this driver as a module, choose M here: the
174 module will be called radio-maestro. 174 module will be called radio-maestro.
175 175
176config RADIO_MIROPCM20
177 tristate "miroSOUND PCM20 radio"
178 depends on ISA && VIDEO_V4L1 && SOUND_ACI_MIXER
179 ---help---
180 Choose Y here if you have this FM radio card. You also need to say Y
181 to "ACI mixer (miroSOUND PCM1-pro/PCM12/PCM20 radio)" (in "Sound")
182 for this to work.
183
184 In order to control your radio card, you will need to use programs
185 that are compatible with the Video For Linux API. Information on
186 this API and pointers to "v4l" programs may be found at
187 <file:Documentation/video4linux/API.html>.
188
189 To compile this driver as a module, choose M here: the
190 module will be called miropcm20.
191
192config RADIO_MIROPCM20_RDS
193 tristate "miroSOUND PCM20 radio RDS user interface (EXPERIMENTAL)"
194 depends on RADIO_MIROPCM20 && EXPERIMENTAL
195 ---help---
196 Choose Y here if you want to see RDS/RBDS information like
197 RadioText, Programme Service name, Clock Time and date, Programme
198 Type and Traffic Announcement/Programme identification.
199
200 It's not possible to read the raw RDS packets from the device, so
201 the driver cant provide an V4L interface for this. But the
202 availability of RDS is reported over V4L by the basic driver
203 already. Here RDS can be read from files in /dev/v4l/rds.
204
205 To compile this driver as a module, choose M here: the
206 module will be called miropcm20-rds.
207
208config RADIO_SF16FMI 176config RADIO_SF16FMI
209 tristate "SF16FMI Radio" 177 tristate "SF16FMI Radio"
210 depends on ISA && VIDEO_V4L2 178 depends on ISA && VIDEO_V4L2
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index fbe5b6168cc2..b8fde5cf4735 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -24,7 +24,7 @@ config VIDEO_HELPER_CHIPS_AUTO
24 decode audio/video standards. This option will autoselect 24 decode audio/video standards. This option will autoselect
25 all pertinent modules to each selected video module. 25 all pertinent modules to each selected video module.
26 26
27 Unselect this only if you know exaclty what you are doing, since 27 Unselect this only if you know exactly what you are doing, since
28 it may break support on some boards. 28 it may break support on some boards.
29 29
30 In doubt, say Y. 30 In doubt, say Y.
@@ -186,7 +186,7 @@ config VIDEO_KS0127
186 186
187config VIDEO_SAA7110 187config VIDEO_SAA7110
188 tristate "Philips SAA7110 video decoder" 188 tristate "Philips SAA7110 video decoder"
189 depends on VIDEO_V4L1 189 depends on VIDEO_V4L1 && I2C
190 ---help--- 190 ---help---
191 Support for the Philips SAA7110 video decoders. 191 Support for the Philips SAA7110 video decoders.
192 192
diff --git a/drivers/media/video/bt8xx/bttv-cards.c b/drivers/media/video/bt8xx/bttv-cards.c
index a84903e0d810..21ebe8f13815 100644
--- a/drivers/media/video/bt8xx/bttv-cards.c
+++ b/drivers/media/video/bt8xx/bttv-cards.c
@@ -4001,7 +4001,7 @@ static void __devinit init_PXC200(struct bttv *btv)
4001 * - sleep 1ms 4001 * - sleep 1ms
4002 * - write 0x0E 4002 * - write 0x0E
4003 * read from GPIO_DATA into buf (uint_32) 4003 * read from GPIO_DATA into buf (uint_32)
4004 * - if ( buf>>18 & 0x01 ) || ( buf>>19 && 0x01 != 0 ) 4004 * - if ( buf>>18 & 0x01 ) || ( buf>>19 & 0x01 != 0 )
4005 * error. ERROR_CPLD_Check_Failed. 4005 * error. ERROR_CPLD_Check_Failed.
4006 */ 4006 */
4007/* ----------------------------------------------------------------------- */ 4007/* ----------------------------------------------------------------------- */
diff --git a/drivers/media/video/cpia_pp.c b/drivers/media/video/cpia_pp.c
index 41f4b8d17559..b12cec94f4cc 100644
--- a/drivers/media/video/cpia_pp.c
+++ b/drivers/media/video/cpia_pp.c
@@ -82,6 +82,8 @@ struct pp_cam_entry {
82 struct pardevice *pdev; 82 struct pardevice *pdev;
83 struct parport *port; 83 struct parport *port;
84 struct work_struct cb_task; 84 struct work_struct cb_task;
85 void (*cb_func)(void *cbdata);
86 void *cb_data;
85 int open_count; 87 int open_count;
86 wait_queue_head_t wq_stream; 88 wait_queue_head_t wq_stream;
87 /* image state flags */ 89 /* image state flags */
@@ -130,6 +132,20 @@ static void cpia_parport_disable_irq( struct parport *port ) {
130#define PARPORT_CHUNK_SIZE PAGE_SIZE 132#define PARPORT_CHUNK_SIZE PAGE_SIZE
131 133
132 134
135static void cpia_pp_run_callback(struct work_struct *work)
136{
137 void (*cb_func)(void *cbdata);
138 void *cb_data;
139 struct pp_cam_entry *cam;
140
141 cam = container_of(work, struct pp_cam_entry, cb_task);
142 cb_func = cam->cb_func;
143 cb_data = cam->cb_data;
144 work_release(work);
145
146 cb_func(cb_data);
147}
148
133/**************************************************************************** 149/****************************************************************************
134 * 150 *
135 * CPiA-specific low-level parport functions for nibble uploads 151 * CPiA-specific low-level parport functions for nibble uploads
@@ -664,7 +680,9 @@ static int cpia_pp_registerCallback(void *privdata, void (*cb)(void *cbdata), vo
664 int retval = 0; 680 int retval = 0;
665 681
666 if(cam->port->irq != PARPORT_IRQ_NONE) { 682 if(cam->port->irq != PARPORT_IRQ_NONE) {
667 INIT_WORK(&cam->cb_task, cb, cbdata); 683 cam->cb_func = cb;
684 cam->cb_data = cbdata;
685 INIT_WORK_NAR(&cam->cb_task, cpia_pp_run_callback);
668 } else { 686 } else {
669 retval = -1; 687 retval = -1;
670 } 688 }
diff --git a/drivers/media/video/cx88/cx88-input.c b/drivers/media/video/cx88/cx88-input.c
index ee48995a4ab5..e60a0a52e4b2 100644
--- a/drivers/media/video/cx88/cx88-input.c
+++ b/drivers/media/video/cx88/cx88-input.c
@@ -145,9 +145,9 @@ static void ir_timer(unsigned long data)
145 schedule_work(&ir->work); 145 schedule_work(&ir->work);
146} 146}
147 147
148static void cx88_ir_work(void *data) 148static void cx88_ir_work(struct work_struct *work)
149{ 149{
150 struct cx88_IR *ir = data; 150 struct cx88_IR *ir = container_of(work, struct cx88_IR, work);
151 unsigned long timeout; 151 unsigned long timeout;
152 152
153 cx88_ir_handle_key(ir); 153 cx88_ir_handle_key(ir);
@@ -202,13 +202,19 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
202 ir->sampling = 1; 202 ir->sampling = 1;
203 break; 203 break;
204 case CX88_BOARD_WINFAST_DTV2000H: 204 case CX88_BOARD_WINFAST_DTV2000H:
205 case CX88_BOARD_WINFAST2000XP_EXPERT:
206 ir_codes = ir_codes_winfast; 205 ir_codes = ir_codes_winfast;
207 ir->gpio_addr = MO_GP0_IO; 206 ir->gpio_addr = MO_GP0_IO;
208 ir->mask_keycode = 0x8f8; 207 ir->mask_keycode = 0x8f8;
209 ir->mask_keyup = 0x100; 208 ir->mask_keyup = 0x100;
210 ir->polling = 50; /* ms */ 209 ir->polling = 50; /* ms */
211 break; 210 break;
211 case CX88_BOARD_WINFAST2000XP_EXPERT:
212 ir_codes = ir_codes_winfast;
213 ir->gpio_addr = MO_GP0_IO;
214 ir->mask_keycode = 0x8f8;
215 ir->mask_keyup = 0x100;
216 ir->polling = 1; /* ms */
217 break;
212 case CX88_BOARD_IODATA_GVBCTV7E: 218 case CX88_BOARD_IODATA_GVBCTV7E:
213 ir_codes = ir_codes_iodata_bctv7e; 219 ir_codes = ir_codes_iodata_bctv7e;
214 ir->gpio_addr = MO_GP0_IO; 220 ir->gpio_addr = MO_GP0_IO;
@@ -216,7 +222,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
216 ir->mask_keydown = 0x02; 222 ir->mask_keydown = 0x02;
217 ir->polling = 5; /* ms */ 223 ir->polling = 5; /* ms */
218 break; 224 break;
219 case CX88_BOARD_PROLINK_PLAYTVPVR: 225 case CX88_BOARD_PROLINK_PLAYTVPVR:
220 case CX88_BOARD_PIXELVIEW_PLAYTV_ULTRA_PRO: 226 case CX88_BOARD_PIXELVIEW_PLAYTV_ULTRA_PRO:
221 ir_codes = ir_codes_pixelview; 227 ir_codes = ir_codes_pixelview;
222 ir->gpio_addr = MO_GP1_IO; 228 ir->gpio_addr = MO_GP1_IO;
@@ -302,7 +308,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
302 core->ir = ir; 308 core->ir = ir;
303 309
304 if (ir->polling) { 310 if (ir->polling) {
305 INIT_WORK(&ir->work, cx88_ir_work, ir); 311 INIT_WORK(&ir->work, cx88_ir_work);
306 init_timer(&ir->timer); 312 init_timer(&ir->timer);
307 ir->timer.function = ir_timer; 313 ir->timer.function = ir_timer;
308 ir->timer.data = (unsigned long)ir; 314 ir->timer.data = (unsigned long)ir;
diff --git a/drivers/media/video/et61x251/et61x251_core.c b/drivers/media/video/et61x251/et61x251_core.c
index f786ab11d2cd..86e353b26b53 100644
--- a/drivers/media/video/et61x251/et61x251_core.c
+++ b/drivers/media/video/et61x251/et61x251_core.c
@@ -1182,8 +1182,6 @@ static void et61x251_release_resources(struct et61x251_device* cam)
1182 video_set_drvdata(cam->v4ldev, NULL); 1182 video_set_drvdata(cam->v4ldev, NULL);
1183 video_unregister_device(cam->v4ldev); 1183 video_unregister_device(cam->v4ldev);
1184 1184
1185 usb_put_dev(cam->usbdev);
1186
1187 mutex_unlock(&et61x251_sysfs_lock); 1185 mutex_unlock(&et61x251_sysfs_lock);
1188 1186
1189 kfree(cam->control_buffer); 1187 kfree(cam->control_buffer);
@@ -1275,6 +1273,7 @@ static int et61x251_release(struct inode* inode, struct file* filp)
1275 1273
1276 if (cam->state & DEV_DISCONNECTED) { 1274 if (cam->state & DEV_DISCONNECTED) {
1277 et61x251_release_resources(cam); 1275 et61x251_release_resources(cam);
1276 usb_put_dev(cam->usbdev);
1278 mutex_unlock(&cam->dev_mutex); 1277 mutex_unlock(&cam->dev_mutex);
1279 kfree(cam); 1278 kfree(cam);
1280 return 0; 1279 return 0;
diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c
index 1457b1602221..ab87e7bfe84f 100644
--- a/drivers/media/video/ir-kbd-i2c.c
+++ b/drivers/media/video/ir-kbd-i2c.c
@@ -268,9 +268,9 @@ static void ir_timer(unsigned long data)
268 schedule_work(&ir->work); 268 schedule_work(&ir->work);
269} 269}
270 270
271static void ir_work(void *data) 271static void ir_work(struct work_struct *work)
272{ 272{
273 struct IR_i2c *ir = data; 273 struct IR_i2c *ir = container_of(work, struct IR_i2c, work);
274 ir_key_poll(ir); 274 ir_key_poll(ir);
275 mod_timer(&ir->timer, jiffies+HZ/10); 275 mod_timer(&ir->timer, jiffies+HZ/10);
276} 276}
@@ -400,7 +400,7 @@ static int ir_attach(struct i2c_adapter *adap, int addr,
400 ir->input->name,ir->input->phys,adap->name); 400 ir->input->name,ir->input->phys,adap->name);
401 401
402 /* start polling via eventd */ 402 /* start polling via eventd */
403 INIT_WORK(&ir->work, ir_work, ir); 403 INIT_WORK(&ir->work, ir_work);
404 init_timer(&ir->timer); 404 init_timer(&ir->timer);
405 ir->timer.function = ir_timer; 405 ir->timer.function = ir_timer;
406 ir->timer.data = (unsigned long)ir; 406 ir->timer.data = (unsigned long)ir;
diff --git a/drivers/media/video/msp3400-driver.c b/drivers/media/video/msp3400-driver.c
index cf43df3fe708..e1b56dc13c3f 100644
--- a/drivers/media/video/msp3400-driver.c
+++ b/drivers/media/video/msp3400-driver.c
@@ -56,7 +56,7 @@
56#include <media/tvaudio.h> 56#include <media/tvaudio.h>
57#include <media/msp3400.h> 57#include <media/msp3400.h>
58#include <linux/kthread.h> 58#include <linux/kthread.h>
59#include <linux/suspend.h> 59#include <linux/freezer.h>
60#include "msp3400-driver.h" 60#include "msp3400-driver.h"
61 61
62/* ---------------------------------------------------------------------- */ 62/* ---------------------------------------------------------------------- */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-context.c b/drivers/media/video/pvrusb2/pvrusb2-context.c
index f129f316d20e..cf129746205d 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-context.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-context.c
@@ -45,16 +45,21 @@ static void pvr2_context_trigger_poll(struct pvr2_context *mp)
45} 45}
46 46
47 47
48static void pvr2_context_poll(struct pvr2_context *mp) 48static void pvr2_context_poll(struct work_struct *work)
49{ 49{
50 struct pvr2_context *mp =
51 container_of(work, struct pvr2_context, workpoll);
50 pvr2_context_enter(mp); do { 52 pvr2_context_enter(mp); do {
51 pvr2_hdw_poll(mp->hdw); 53 pvr2_hdw_poll(mp->hdw);
52 } while (0); pvr2_context_exit(mp); 54 } while (0); pvr2_context_exit(mp);
53} 55}
54 56
55 57
56static void pvr2_context_setup(struct pvr2_context *mp) 58static void pvr2_context_setup(struct work_struct *work)
57{ 59{
60 struct pvr2_context *mp =
61 container_of(work, struct pvr2_context, workinit);
62
58 pvr2_context_enter(mp); do { 63 pvr2_context_enter(mp); do {
59 if (!pvr2_hdw_dev_ok(mp->hdw)) break; 64 if (!pvr2_hdw_dev_ok(mp->hdw)) break;
60 pvr2_hdw_setup(mp->hdw); 65 pvr2_hdw_setup(mp->hdw);
@@ -92,8 +97,8 @@ struct pvr2_context *pvr2_context_create(
92 } 97 }
93 98
94 mp->workqueue = create_singlethread_workqueue("pvrusb2"); 99 mp->workqueue = create_singlethread_workqueue("pvrusb2");
95 INIT_WORK(&mp->workinit,(void (*)(void*))pvr2_context_setup,mp); 100 INIT_WORK(&mp->workinit, pvr2_context_setup);
96 INIT_WORK(&mp->workpoll,(void (*)(void*))pvr2_context_poll,mp); 101 INIT_WORK(&mp->workpoll, pvr2_context_poll);
97 queue_work(mp->workqueue,&mp->workinit); 102 queue_work(mp->workqueue,&mp->workinit);
98 done: 103 done:
99 return mp; 104 return mp;
diff --git a/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c b/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c
index df8feac16aee..c80c26be6e4d 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c
@@ -221,7 +221,7 @@ static unsigned int decoder_describe(struct pvr2_v4l_cx2584x *ctxt,
221static void decoder_reset(struct pvr2_v4l_cx2584x *ctxt) 221static void decoder_reset(struct pvr2_v4l_cx2584x *ctxt)
222{ 222{
223 int ret; 223 int ret;
224 ret = pvr2_i2c_client_cmd(ctxt->client,VIDIOC_INT_RESET,0); 224 ret = pvr2_i2c_client_cmd(ctxt->client,VIDIOC_INT_RESET,NULL);
225 pvr2_trace(PVR2_TRACE_CHIPS,"i2c cx25840 decoder_reset (ret=%d)",ret); 225 pvr2_trace(PVR2_TRACE_CHIPS,"i2c cx25840 decoder_reset (ret=%d)",ret);
226} 226}
227 227
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
index f920e0ccacd3..1f787333d18c 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -1953,8 +1953,8 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
1953 return hdw; 1953 return hdw;
1954 fail: 1954 fail:
1955 if (hdw) { 1955 if (hdw) {
1956 if (hdw->ctl_read_urb) usb_free_urb(hdw->ctl_read_urb); 1956 usb_free_urb(hdw->ctl_read_urb);
1957 if (hdw->ctl_write_urb) usb_free_urb(hdw->ctl_write_urb); 1957 usb_free_urb(hdw->ctl_write_urb);
1958 if (hdw->ctl_read_buffer) kfree(hdw->ctl_read_buffer); 1958 if (hdw->ctl_read_buffer) kfree(hdw->ctl_read_buffer);
1959 if (hdw->ctl_write_buffer) kfree(hdw->ctl_write_buffer); 1959 if (hdw->ctl_write_buffer) kfree(hdw->ctl_write_buffer);
1960 if (hdw->controls) kfree(hdw->controls); 1960 if (hdw->controls) kfree(hdw->controls);
@@ -2575,12 +2575,10 @@ static void pvr2_ctl_timeout(unsigned long data)
2575 struct pvr2_hdw *hdw = (struct pvr2_hdw *)data; 2575 struct pvr2_hdw *hdw = (struct pvr2_hdw *)data;
2576 if (hdw->ctl_write_pend_flag || hdw->ctl_read_pend_flag) { 2576 if (hdw->ctl_write_pend_flag || hdw->ctl_read_pend_flag) {
2577 hdw->ctl_timeout_flag = !0; 2577 hdw->ctl_timeout_flag = !0;
2578 if (hdw->ctl_write_pend_flag && hdw->ctl_write_urb) { 2578 if (hdw->ctl_write_pend_flag)
2579 usb_unlink_urb(hdw->ctl_write_urb); 2579 usb_unlink_urb(hdw->ctl_write_urb);
2580 } 2580 if (hdw->ctl_read_pend_flag)
2581 if (hdw->ctl_read_pend_flag && hdw->ctl_read_urb) {
2582 usb_unlink_urb(hdw->ctl_read_urb); 2581 usb_unlink_urb(hdw->ctl_read_urb);
2583 }
2584 } 2582 }
2585} 2583}
2586 2584
diff --git a/drivers/media/video/pvrusb2/pvrusb2-io.c b/drivers/media/video/pvrusb2/pvrusb2-io.c
index 70aa63eba0cb..57fb32033543 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-io.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-io.c
@@ -289,7 +289,7 @@ static void pvr2_buffer_done(struct pvr2_buffer *bp)
289 pvr2_buffer_set_none(bp); 289 pvr2_buffer_set_none(bp);
290 bp->signature = 0; 290 bp->signature = 0;
291 bp->stream = NULL; 291 bp->stream = NULL;
292 if (bp->purb) usb_free_urb(bp->purb); 292 usb_free_urb(bp->purb);
293 pvr2_trace(PVR2_TRACE_BUF_POOL,"/*---TRACE_FLOW---*/" 293 pvr2_trace(PVR2_TRACE_BUF_POOL,"/*---TRACE_FLOW---*/"
294 " bufferDone %p",bp); 294 " bufferDone %p",bp);
295} 295}
diff --git a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
index 97e974d9b9c3..bb40e9085977 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
@@ -711,8 +711,8 @@ static void pvr2_v4l2_dev_destroy(struct pvr2_v4l2_dev *dip)
711 dip->devbase.minor,pvr2_config_get_name(dip->config)); 711 dip->devbase.minor,pvr2_config_get_name(dip->config));
712 712
713 /* Paranoia */ 713 /* Paranoia */
714 dip->v4lp = 0; 714 dip->v4lp = NULL;
715 dip->stream = 0; 715 dip->stream = NULL;
716 716
717 /* Actual deallocation happens later when all internal references 717 /* Actual deallocation happens later when all internal references
718 are gone. */ 718 are gone. */
@@ -1076,7 +1076,7 @@ struct pvr2_v4l2 *pvr2_v4l2_create(struct pvr2_context *mnp)
1076 vp->vdev = kmalloc(sizeof(*vp->vdev),GFP_KERNEL); 1076 vp->vdev = kmalloc(sizeof(*vp->vdev),GFP_KERNEL);
1077 if (!vp->vdev) { 1077 if (!vp->vdev) {
1078 kfree(vp); 1078 kfree(vp);
1079 return 0; 1079 return NULL;
1080 } 1080 }
1081 memset(vp->vdev,0,sizeof(*vp->vdev)); 1081 memset(vp->vdev,0,sizeof(*vp->vdev));
1082 pvr2_channel_init(&vp->channel,mnp); 1082 pvr2_channel_init(&vp->channel,mnp);
diff --git a/drivers/media/video/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c
index 46c114830884..a996aad79276 100644
--- a/drivers/media/video/pwc/pwc-if.c
+++ b/drivers/media/video/pwc/pwc-if.c
@@ -866,11 +866,9 @@ int pwc_isoc_init(struct pwc_device *pdev)
866 } 866 }
867 if (ret) { 867 if (ret) {
868 /* De-allocate in reverse order */ 868 /* De-allocate in reverse order */
869 while (i >= 0) { 869 while (i--) {
870 if (pdev->sbuf[i].urb != NULL) 870 usb_free_urb(pdev->sbuf[i].urb);
871 usb_free_urb(pdev->sbuf[i].urb);
872 pdev->sbuf[i].urb = NULL; 871 pdev->sbuf[i].urb = NULL;
873 i--;
874 } 872 }
875 return ret; 873 return ret;
876 } 874 }
@@ -1095,8 +1093,7 @@ static int pwc_video_open(struct inode *inode, struct file *file)
1095 PWC_DEBUG_OPEN(">> video_open called(vdev = 0x%p).\n", vdev); 1093 PWC_DEBUG_OPEN(">> video_open called(vdev = 0x%p).\n", vdev);
1096 1094
1097 pdev = (struct pwc_device *)vdev->priv; 1095 pdev = (struct pwc_device *)vdev->priv;
1098 if (pdev == NULL) 1096 BUG_ON(!pdev);
1099 BUG();
1100 if (pdev->vopen) { 1097 if (pdev->vopen) {
1101 PWC_DEBUG_OPEN("I'm busy, someone is using the device.\n"); 1098 PWC_DEBUG_OPEN("I'm busy, someone is using the device.\n");
1102 return -EBUSY; 1099 return -EBUSY;
diff --git a/drivers/media/video/saa6588.c b/drivers/media/video/saa6588.c
index a81285ca7d5b..92eabf88a09b 100644
--- a/drivers/media/video/saa6588.c
+++ b/drivers/media/video/saa6588.c
@@ -212,8 +212,10 @@ static void read_from_buf(struct saa6588 *s, struct rds_command *a)
212 if (rd_blocks > s->block_count) 212 if (rd_blocks > s->block_count)
213 rd_blocks = s->block_count; 213 rd_blocks = s->block_count;
214 214
215 if (!rd_blocks) 215 if (!rd_blocks) {
216 spin_unlock_irqrestore(&s->lock, flags);
216 return; 217 return;
218 }
217 219
218 for (i = 0; i < rd_blocks; i++) { 220 for (i = 0; i < rd_blocks; i++) {
219 if (block_to_user_buf(s, buf_ptr)) { 221 if (block_to_user_buf(s, buf_ptr)) {
@@ -322,9 +324,9 @@ static void saa6588_timer(unsigned long data)
322 schedule_work(&s->work); 324 schedule_work(&s->work);
323} 325}
324 326
325static void saa6588_work(void *data) 327static void saa6588_work(struct work_struct *work)
326{ 328{
327 struct saa6588 *s = (struct saa6588 *)data; 329 struct saa6588 *s = container_of(work, struct saa6588, work);
328 330
329 saa6588_i2c_poll(s); 331 saa6588_i2c_poll(s);
330 mod_timer(&s->timer, jiffies + msecs_to_jiffies(20)); 332 mod_timer(&s->timer, jiffies + msecs_to_jiffies(20));
@@ -417,7 +419,7 @@ static int saa6588_attach(struct i2c_adapter *adap, int addr, int kind)
417 saa6588_configure(s); 419 saa6588_configure(s);
418 420
419 /* start polling via eventd */ 421 /* start polling via eventd */
420 INIT_WORK(&s->work, saa6588_work, s); 422 INIT_WORK(&s->work, saa6588_work);
421 init_timer(&s->timer); 423 init_timer(&s->timer);
422 s->timer.function = saa6588_timer; 424 s->timer.function = saa6588_timer;
423 s->timer.data = (unsigned long)s; 425 s->timer.data = (unsigned long)s;
diff --git a/drivers/media/video/saa7115.c b/drivers/media/video/saa7115.c
index c5719f7bd1ac..f28398dd9d93 100644
--- a/drivers/media/video/saa7115.c
+++ b/drivers/media/video/saa7115.c
@@ -1464,8 +1464,6 @@ static int saa711x_attach(struct i2c_adapter *adapter, int address, int kind)
1464 client->driver = &i2c_driver_saa711x; 1464 client->driver = &i2c_driver_saa711x;
1465 snprintf(client->name, sizeof(client->name) - 1, "saa7115"); 1465 snprintf(client->name, sizeof(client->name) - 1, "saa7115");
1466 1466
1467 v4l_dbg(1, debug, client, "detecting saa7115 client on address 0x%x\n", address << 1);
1468
1469 for (i=0;i<0x0f;i++) { 1467 for (i=0;i<0x0f;i++) {
1470 saa711x_write(client, 0, i); 1468 saa711x_write(client, 0, i);
1471 name[i] = (saa711x_read(client, 0) &0x0f) +'0'; 1469 name[i] = (saa711x_read(client, 0) &0x0f) +'0';
@@ -1477,6 +1475,13 @@ static int saa711x_attach(struct i2c_adapter *adapter, int address, int kind)
1477 saa711x_write(client, 0, 5); 1475 saa711x_write(client, 0, 5);
1478 chip_id = saa711x_read(client, 0) & 0x0f; 1476 chip_id = saa711x_read(client, 0) & 0x0f;
1479 1477
1478 /* Check whether this chip is part of the saa711x series */
1479 if (memcmp(name, "1f711", 5)) {
1480 v4l_dbg(1, debug, client, "chip found @ 0x%x (ID %s) does not match a known saa711x chip.\n",
1481 address << 1, name);
1482 return 0;
1483 }
1484
1480 snprintf(client->name, sizeof(client->name) - 1, "saa711%d",chip_id); 1485 snprintf(client->name, sizeof(client->name) - 1, "saa711%d",chip_id);
1481 v4l_info(client, "saa711%d found (%s) @ 0x%x (%s)\n", chip_id, name, address << 1, adapter->name); 1486 v4l_info(client, "saa711%d found (%s) @ 0x%x (%s)\n", chip_id, name, address << 1, adapter->name);
1482 1487
diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c
index c9d8e3b9cc37..51f0cfdcb680 100644
--- a/drivers/media/video/saa7134/saa7134-cards.c
+++ b/drivers/media/video/saa7134/saa7134-cards.c
@@ -2969,7 +2969,7 @@ struct saa7134_board saa7134_boards[] = {
2969 /* Petr Baudis <pasky@ucw.cz> */ 2969 /* Petr Baudis <pasky@ucw.cz> */
2970 .name = "AVerMedia TV Hybrid A16AR", 2970 .name = "AVerMedia TV Hybrid A16AR",
2971 .audio_clock = 0x187de7, 2971 .audio_clock = 0x187de7,
2972 .tuner_type = TUNER_PHILIPS_TDA8290, /* untested */ 2972 .tuner_type = TUNER_PHILIPS_TD1316, /* untested */
2973 .radio_type = TUNER_TEA5767, /* untested */ 2973 .radio_type = TUNER_TEA5767, /* untested */
2974 .tuner_addr = ADDR_UNSET, 2974 .tuner_addr = ADDR_UNSET,
2975 .radio_addr = ADDR_UNSET, 2975 .radio_addr = ADDR_UNSET,
@@ -3718,6 +3718,7 @@ int saa7134_board_init1(struct saa7134_dev *dev)
3718 case SAA7134_BOARD_AVERMEDIA_STUDIO_307: 3718 case SAA7134_BOARD_AVERMEDIA_STUDIO_307:
3719 case SAA7134_BOARD_AVERMEDIA_307: 3719 case SAA7134_BOARD_AVERMEDIA_307:
3720 case SAA7134_BOARD_AVERMEDIA_GO_007_FM: 3720 case SAA7134_BOARD_AVERMEDIA_GO_007_FM:
3721 case SAA7134_BOARD_AVERMEDIA_777:
3721/* case SAA7134_BOARD_SABRENT_SBTTVFM: */ /* not finished yet */ 3722/* case SAA7134_BOARD_SABRENT_SBTTVFM: */ /* not finished yet */
3722 case SAA7134_BOARD_VIDEOMATE_TV_PVR: 3723 case SAA7134_BOARD_VIDEOMATE_TV_PVR:
3723 case SAA7134_BOARD_VIDEOMATE_GOLD_PLUS: 3724 case SAA7134_BOARD_VIDEOMATE_GOLD_PLUS:
@@ -3734,6 +3735,7 @@ int saa7134_board_init1(struct saa7134_dev *dev)
3734 case SAA7134_BOARD_FLYDVBT_LR301: 3735 case SAA7134_BOARD_FLYDVBT_LR301:
3735 case SAA7134_BOARD_FLYDVBTDUO: 3736 case SAA7134_BOARD_FLYDVBTDUO:
3736 case SAA7134_BOARD_PROTEUS_2309: 3737 case SAA7134_BOARD_PROTEUS_2309:
3738 case SAA7134_BOARD_AVERMEDIA_A16AR:
3737 dev->has_remote = SAA7134_REMOTE_GPIO; 3739 dev->has_remote = SAA7134_REMOTE_GPIO;
3738 break; 3740 break;
3739 case SAA7134_BOARD_FLYDVBS_LR300: 3741 case SAA7134_BOARD_FLYDVBS_LR300:
@@ -3772,7 +3774,6 @@ int saa7134_board_init1(struct saa7134_dev *dev)
3772 saa_writeb(SAA7134_GPIO_GPMODE3, 0x08); 3774 saa_writeb(SAA7134_GPIO_GPMODE3, 0x08);
3773 saa_writeb(SAA7134_GPIO_GPSTATUS3, 0x00); 3775 saa_writeb(SAA7134_GPIO_GPSTATUS3, 0x00);
3774 break; 3776 break;
3775 case SAA7134_BOARD_AVERMEDIA_A16AR:
3776 case SAA7134_BOARD_AVERMEDIA_CARDBUS: 3777 case SAA7134_BOARD_AVERMEDIA_CARDBUS:
3777 /* power-up tuner chip */ 3778 /* power-up tuner chip */
3778 saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0xffffffff, 0xffffffff); 3779 saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0xffffffff, 0xffffffff);
diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c
index 1ba53b525ad2..6b61d9b2fcb5 100644
--- a/drivers/media/video/saa7134/saa7134-dvb.c
+++ b/drivers/media/video/saa7134/saa7134-dvb.c
@@ -1147,6 +1147,8 @@ static int dvb_init(struct saa7134_dev *dev)
1147 &philips_europa_config, 1147 &philips_europa_config,
1148 &dev->i2c_adap); 1148 &dev->i2c_adap);
1149 if (dev->dvb.frontend) { 1149 if (dev->dvb.frontend) {
1150 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1151 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1150 dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init; 1152 dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1151 dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep; 1153 dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1152 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params; 1154 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
diff --git a/drivers/media/video/saa7134/saa7134-empress.c b/drivers/media/video/saa7134/saa7134-empress.c
index 65d044086ce9..daaae870a2c4 100644
--- a/drivers/media/video/saa7134/saa7134-empress.c
+++ b/drivers/media/video/saa7134/saa7134-empress.c
@@ -343,9 +343,10 @@ static struct video_device saa7134_empress_template =
343 .minor = -1, 343 .minor = -1,
344}; 344};
345 345
346static void empress_signal_update(void* data) 346static void empress_signal_update(struct work_struct *work)
347{ 347{
348 struct saa7134_dev* dev = (struct saa7134_dev*) data; 348 struct saa7134_dev* dev =
349 container_of(work, struct saa7134_dev, empress_workqueue);
349 350
350 if (dev->nosignal) { 351 if (dev->nosignal) {
351 dprintk("no video signal\n"); 352 dprintk("no video signal\n");
@@ -378,7 +379,7 @@ static int empress_init(struct saa7134_dev *dev)
378 "%s empress (%s)", dev->name, 379 "%s empress (%s)", dev->name,
379 saa7134_boards[dev->board].name); 380 saa7134_boards[dev->board].name);
380 381
381 INIT_WORK(&dev->empress_workqueue, empress_signal_update, (void*) dev); 382 INIT_WORK(&dev->empress_workqueue, empress_signal_update);
382 383
383 err = video_register_device(dev->empress_dev,VFL_TYPE_GRABBER, 384 err = video_register_device(dev->empress_dev,VFL_TYPE_GRABBER,
384 empress_nr[dev->nr]); 385 empress_nr[dev->nr]);
@@ -399,7 +400,7 @@ static int empress_init(struct saa7134_dev *dev)
399 sizeof(struct saa7134_buf), 400 sizeof(struct saa7134_buf),
400 dev); 401 dev);
401 402
402 empress_signal_update(dev); 403 empress_signal_update(&dev->empress_workqueue);
403 return 0; 404 return 0;
404} 405}
405 406
diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c
index ff5991136f4e..dee83552e681 100644
--- a/drivers/media/video/saa7134/saa7134-input.c
+++ b/drivers/media/video/saa7134/saa7134-input.c
@@ -185,7 +185,6 @@ int saa7134_input_init1(struct saa7134_dev *dev)
185 case SAA7134_BOARD_AVERMEDIA_STUDIO_305: 185 case SAA7134_BOARD_AVERMEDIA_STUDIO_305:
186 case SAA7134_BOARD_AVERMEDIA_STUDIO_307: 186 case SAA7134_BOARD_AVERMEDIA_STUDIO_307:
187 case SAA7134_BOARD_AVERMEDIA_GO_007_FM: 187 case SAA7134_BOARD_AVERMEDIA_GO_007_FM:
188 case SAA7134_BOARD_AVERMEDIA_A16AR:
189 ir_codes = ir_codes_avermedia; 188 ir_codes = ir_codes_avermedia;
190 mask_keycode = 0x0007C8; 189 mask_keycode = 0x0007C8;
191 mask_keydown = 0x000010; 190 mask_keydown = 0x000010;
@@ -194,6 +193,16 @@ int saa7134_input_init1(struct saa7134_dev *dev)
194 saa_setb(SAA7134_GPIO_GPMODE0, 0x4); 193 saa_setb(SAA7134_GPIO_GPMODE0, 0x4);
195 saa_setb(SAA7134_GPIO_GPSTATUS0, 0x4); 194 saa_setb(SAA7134_GPIO_GPSTATUS0, 0x4);
196 break; 195 break;
196 case SAA7134_BOARD_AVERMEDIA_777:
197 case SAA7134_BOARD_AVERMEDIA_A16AR:
198 ir_codes = ir_codes_avermedia;
199 mask_keycode = 0x02F200;
200 mask_keydown = 0x000400;
201 polling = 50; // ms
202 /* Without this we won't receive key up events */
203 saa_setb(SAA7134_GPIO_GPMODE1, 0x1);
204 saa_setb(SAA7134_GPIO_GPSTATUS1, 0x1);
205 break;
197 case SAA7134_BOARD_KWORLD_TERMINATOR: 206 case SAA7134_BOARD_KWORLD_TERMINATOR:
198 ir_codes = ir_codes_pixelview; 207 ir_codes = ir_codes_pixelview;
199 mask_keycode = 0x00001f; 208 mask_keycode = 0x00001f;
diff --git a/drivers/media/video/sn9c102/sn9c102_core.c b/drivers/media/video/sn9c102/sn9c102_core.c
index a4702d3c2aca..18458d46c0ff 100644
--- a/drivers/media/video/sn9c102/sn9c102_core.c
+++ b/drivers/media/video/sn9c102/sn9c102_core.c
@@ -775,7 +775,7 @@ static int sn9c102_start_transfer(struct sn9c102_device* cam)
775 return 0; 775 return 0;
776 776
777free_urbs: 777free_urbs:
778 for (i = 0; (i < SN9C102_URBS) && cam->urb[i]; i++) 778 for (i = 0; i < SN9C102_URBS; i++)
779 usb_free_urb(cam->urb[i]); 779 usb_free_urb(cam->urb[i]);
780 780
781free_buffers: 781free_buffers:
@@ -1462,8 +1462,6 @@ static void sn9c102_release_resources(struct sn9c102_device* cam)
1462 video_set_drvdata(cam->v4ldev, NULL); 1462 video_set_drvdata(cam->v4ldev, NULL);
1463 video_unregister_device(cam->v4ldev); 1463 video_unregister_device(cam->v4ldev);
1464 1464
1465 usb_put_dev(cam->usbdev);
1466
1467 mutex_unlock(&sn9c102_sysfs_lock); 1465 mutex_unlock(&sn9c102_sysfs_lock);
1468 1466
1469 kfree(cam->control_buffer); 1467 kfree(cam->control_buffer);
@@ -1555,6 +1553,7 @@ static int sn9c102_release(struct inode* inode, struct file* filp)
1555 1553
1556 if (cam->state & DEV_DISCONNECTED) { 1554 if (cam->state & DEV_DISCONNECTED) {
1557 sn9c102_release_resources(cam); 1555 sn9c102_release_resources(cam);
1556 usb_put_dev(cam->usbdev);
1558 mutex_unlock(&cam->dev_mutex); 1557 mutex_unlock(&cam->dev_mutex);
1559 kfree(cam); 1558 kfree(cam);
1560 return 0; 1559 return 0;
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c
index fcaef4bf8289..d506dfaa45a9 100644
--- a/drivers/media/video/tvaudio.c
+++ b/drivers/media/video/tvaudio.c
@@ -29,6 +29,7 @@
29#include <linux/init.h> 29#include <linux/init.h>
30#include <linux/smp_lock.h> 30#include <linux/smp_lock.h>
31#include <linux/kthread.h> 31#include <linux/kthread.h>
32#include <linux/freezer.h>
32 33
33#include <media/tvaudio.h> 34#include <media/tvaudio.h>
34#include <media/v4l2-common.h> 35#include <media/v4l2-common.h>
diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c
index e6baaee038bf..6b9ef731b83a 100644
--- a/drivers/media/video/tveeprom.c
+++ b/drivers/media/video/tveeprom.c
@@ -468,7 +468,7 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee,
468 (eeprom_data[i+6] << 8) + 468 (eeprom_data[i+6] << 8) +
469 (eeprom_data[i+7] << 16); 469 (eeprom_data[i+7] << 16);
470 470
471 if ( (eeprom_data[i + 8] && 0xf0) && 471 if ( (eeprom_data[i + 8] & 0xf0) &&
472 (tvee->serial_number < 0xffffff) ) { 472 (tvee->serial_number < 0xffffff) ) {
473 tvee->MAC_address[0] = 0x00; 473 tvee->MAC_address[0] = 0x00;
474 tvee->MAC_address[1] = 0x0D; 474 tvee->MAC_address[1] = 0x0D;
diff --git a/drivers/media/video/usbvideo/quickcam_messenger.c b/drivers/media/video/usbvideo/quickcam_messenger.c
index 9a26b9484aae..bbf2beeeb449 100644
--- a/drivers/media/video/usbvideo/quickcam_messenger.c
+++ b/drivers/media/video/usbvideo/quickcam_messenger.c
@@ -190,8 +190,7 @@ static int qcm_alloc_int_urb(struct qcm *cam)
190 190
191static void qcm_free_int(struct qcm *cam) 191static void qcm_free_int(struct qcm *cam)
192{ 192{
193 if (cam->button_urb) 193 usb_free_urb(cam->button_urb);
194 usb_free_urb(cam->button_urb);
195} 194}
196#endif /* CONFIG_INPUT */ 195#endif /* CONFIG_INPUT */
197 196
diff --git a/drivers/media/video/video-buf-dvb.c b/drivers/media/video/video-buf-dvb.c
index f53edf1923b7..fcc5467e7636 100644
--- a/drivers/media/video/video-buf-dvb.c
+++ b/drivers/media/video/video-buf-dvb.c
@@ -20,7 +20,7 @@
20#include <linux/fs.h> 20#include <linux/fs.h>
21#include <linux/kthread.h> 21#include <linux/kthread.h>
22#include <linux/file.h> 22#include <linux/file.h>
23#include <linux/suspend.h> 23#include <linux/freezer.h>
24 24
25#include <media/video-buf.h> 25#include <media/video-buf.h>
26#include <media/video-buf-dvb.h> 26#include <media/video-buf-dvb.h>
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c
index 3c8dc72dc8e9..9986de5cb3d6 100644
--- a/drivers/media/video/vivi.c
+++ b/drivers/media/video/vivi.c
@@ -36,6 +36,7 @@
36#include <media/v4l2-common.h> 36#include <media/v4l2-common.h>
37#include <linux/kthread.h> 37#include <linux/kthread.h>
38#include <linux/highmem.h> 38#include <linux/highmem.h>
39#include <linux/freezer.h>
39 40
40/* Wake up at about 30 fps */ 41/* Wake up at about 30 fps */
41#define WAKE_NUMERATOR 30 42#define WAKE_NUMERATOR 30
diff --git a/drivers/media/video/zc0301/zc0301_core.c b/drivers/media/video/zc0301/zc0301_core.c
index 5b5563424422..52d0f759ee00 100644
--- a/drivers/media/video/zc0301/zc0301_core.c
+++ b/drivers/media/video/zc0301/zc0301_core.c
@@ -489,7 +489,7 @@ static int zc0301_start_transfer(struct zc0301_device* cam)
489 return 0; 489 return 0;
490 490
491free_urbs: 491free_urbs:
492 for (i = 0; (i < ZC0301_URBS) && cam->urb[i]; i++) 492 for (i = 0; i < ZC0301_URBS; i++)
493 usb_free_urb(cam->urb[i]); 493 usb_free_urb(cam->urb[i]);
494 494
495free_buffers: 495free_buffers:
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index e5c72719debc..6e068cf1049b 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -347,7 +347,7 @@ mpt_reply(MPT_ADAPTER *ioc, u32 pa)
347} 347}
348 348
349/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 349/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
350/* 350/**
351 * mpt_interrupt - MPT adapter (IOC) specific interrupt handler. 351 * mpt_interrupt - MPT adapter (IOC) specific interrupt handler.
352 * @irq: irq number (not used) 352 * @irq: irq number (not used)
353 * @bus_id: bus identifier cookie == pointer to MPT_ADAPTER structure 353 * @bus_id: bus identifier cookie == pointer to MPT_ADAPTER structure
@@ -387,14 +387,16 @@ mpt_interrupt(int irq, void *bus_id)
387} 387}
388 388
389/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 389/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
390/* 390/**
391 * mpt_base_reply - MPT base driver's callback routine; all base driver 391 * mpt_base_reply - MPT base driver's callback routine
392 * "internal" request/reply processing is routed here.
393 * Currently used for EventNotification and EventAck handling.
394 * @ioc: Pointer to MPT_ADAPTER structure 392 * @ioc: Pointer to MPT_ADAPTER structure
395 * @mf: Pointer to original MPT request frame 393 * @mf: Pointer to original MPT request frame
396 * @reply: Pointer to MPT reply frame (NULL if TurboReply) 394 * @reply: Pointer to MPT reply frame (NULL if TurboReply)
397 * 395 *
396 * MPT base driver's callback routine; all base driver
397 * "internal" request/reply processing is routed here.
398 * Currently used for EventNotification and EventAck handling.
399 *
398 * Returns 1 indicating original alloc'd request frame ptr 400 * Returns 1 indicating original alloc'd request frame ptr
399 * should be freed, or 0 if it shouldn't. 401 * should be freed, or 0 if it shouldn't.
400 */ 402 */
@@ -530,7 +532,7 @@ mpt_base_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *reply)
530 * @dclass: Protocol driver's class (%MPT_DRIVER_CLASS enum value) 532 * @dclass: Protocol driver's class (%MPT_DRIVER_CLASS enum value)
531 * 533 *
532 * This routine is called by a protocol-specific driver (SCSI host, 534 * This routine is called by a protocol-specific driver (SCSI host,
533 * LAN, SCSI target) to register it's reply callback routine. Each 535 * LAN, SCSI target) to register its reply callback routine. Each
534 * protocol-specific driver must do this before it will be able to 536 * protocol-specific driver must do this before it will be able to
535 * use any IOC resources, such as obtaining request frames. 537 * use any IOC resources, such as obtaining request frames.
536 * 538 *
@@ -572,7 +574,7 @@ mpt_register(MPT_CALLBACK cbfunc, MPT_DRIVER_CLASS dclass)
572 * mpt_deregister - Deregister a protocol drivers resources. 574 * mpt_deregister - Deregister a protocol drivers resources.
573 * @cb_idx: previously registered callback handle 575 * @cb_idx: previously registered callback handle
574 * 576 *
575 * Each protocol-specific driver should call this routine when it's 577 * Each protocol-specific driver should call this routine when its
576 * module is unloaded. 578 * module is unloaded.
577 */ 579 */
578void 580void
@@ -617,7 +619,7 @@ mpt_event_register(int cb_idx, MPT_EVHANDLER ev_cbfunc)
617 * 619 *
618 * Each protocol-specific driver should call this routine 620 * Each protocol-specific driver should call this routine
619 * when it does not (or can no longer) handle events, 621 * when it does not (or can no longer) handle events,
620 * or when it's module is unloaded. 622 * or when its module is unloaded.
621 */ 623 */
622void 624void
623mpt_event_deregister(int cb_idx) 625mpt_event_deregister(int cb_idx)
@@ -656,7 +658,7 @@ mpt_reset_register(int cb_idx, MPT_RESETHANDLER reset_func)
656 * 658 *
657 * Each protocol-specific driver should call this routine 659 * Each protocol-specific driver should call this routine
658 * when it does not (or can no longer) handle IOC reset handling, 660 * when it does not (or can no longer) handle IOC reset handling,
659 * or when it's module is unloaded. 661 * or when its module is unloaded.
660 */ 662 */
661void 663void
662mpt_reset_deregister(int cb_idx) 664mpt_reset_deregister(int cb_idx)
@@ -670,6 +672,8 @@ mpt_reset_deregister(int cb_idx)
670/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 672/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
671/** 673/**
672 * mpt_device_driver_register - Register device driver hooks 674 * mpt_device_driver_register - Register device driver hooks
675 * @dd_cbfunc: driver callbacks struct
676 * @cb_idx: MPT protocol driver index
673 */ 677 */
674int 678int
675mpt_device_driver_register(struct mpt_pci_driver * dd_cbfunc, int cb_idx) 679mpt_device_driver_register(struct mpt_pci_driver * dd_cbfunc, int cb_idx)
@@ -696,6 +700,7 @@ mpt_device_driver_register(struct mpt_pci_driver * dd_cbfunc, int cb_idx)
696/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 700/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
697/** 701/**
698 * mpt_device_driver_deregister - DeRegister device driver hooks 702 * mpt_device_driver_deregister - DeRegister device driver hooks
703 * @cb_idx: MPT protocol driver index
699 */ 704 */
700void 705void
701mpt_device_driver_deregister(int cb_idx) 706mpt_device_driver_deregister(int cb_idx)
@@ -887,8 +892,7 @@ mpt_add_sge(char *pAddr, u32 flagslength, dma_addr_t dma_addr)
887 892
888/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 893/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
889/** 894/**
890 * mpt_send_handshake_request - Send MPT request via doorbell 895 * mpt_send_handshake_request - Send MPT request via doorbell handshake method.
891 * handshake method.
892 * @handle: Handle of registered MPT protocol driver 896 * @handle: Handle of registered MPT protocol driver
893 * @ioc: Pointer to MPT adapter structure 897 * @ioc: Pointer to MPT adapter structure
894 * @reqBytes: Size of the request in bytes 898 * @reqBytes: Size of the request in bytes
@@ -981,10 +985,13 @@ mpt_send_handshake_request(int handle, MPT_ADAPTER *ioc, int reqBytes, u32 *req,
981 985
982/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 986/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
983/** 987/**
984 * mpt_host_page_access_control - provides mechanism for the host 988 * mpt_host_page_access_control - control the IOC's Host Page Buffer access
985 * driver to control the IOC's Host Page Buffer access.
986 * @ioc: Pointer to MPT adapter structure 989 * @ioc: Pointer to MPT adapter structure
987 * @access_control_value: define bits below 990 * @access_control_value: define bits below
991 * @sleepFlag: Specifies whether the process can sleep
992 *
993 * Provides mechanism for the host driver to control the IOC's
994 * Host Page Buffer access.
988 * 995 *
989 * Access Control Value - bits[15:12] 996 * Access Control Value - bits[15:12]
990 * 0h Reserved 997 * 0h Reserved
@@ -1022,10 +1029,10 @@ mpt_host_page_access_control(MPT_ADAPTER *ioc, u8 access_control_value, int slee
1022/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1029/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1023/** 1030/**
1024 * mpt_host_page_alloc - allocate system memory for the fw 1031 * mpt_host_page_alloc - allocate system memory for the fw
1025 * If we already allocated memory in past, then resend the same pointer. 1032 * @ioc: Pointer to pointer to IOC adapter
1026 * ioc@: Pointer to pointer to IOC adapter 1033 * @ioc_init: Pointer to ioc init config page
1027 * ioc_init@: Pointer to ioc init config page
1028 * 1034 *
1035 * If we already allocated memory in past, then resend the same pointer.
1029 * Returns 0 for success, non-zero for failure. 1036 * Returns 0 for success, non-zero for failure.
1030 */ 1037 */
1031static int 1038static int
@@ -1091,12 +1098,15 @@ return 0;
1091 1098
1092/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1099/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1093/** 1100/**
1094 * mpt_verify_adapter - Given a unique IOC identifier, set pointer to 1101 * mpt_verify_adapter - Given IOC identifier, set pointer to its adapter structure.
1095 * the associated MPT adapter structure.
1096 * @iocid: IOC unique identifier (integer) 1102 * @iocid: IOC unique identifier (integer)
1097 * @iocpp: Pointer to pointer to IOC adapter 1103 * @iocpp: Pointer to pointer to IOC adapter
1098 * 1104 *
1099 * Returns iocid and sets iocpp. 1105 * Given a unique IOC identifier, set pointer to the associated MPT
1106 * adapter structure.
1107 *
1108 * Returns iocid and sets iocpp if iocid is found.
1109 * Returns -1 if iocid is not found.
1100 */ 1110 */
1101int 1111int
1102mpt_verify_adapter(int iocid, MPT_ADAPTER **iocpp) 1112mpt_verify_adapter(int iocid, MPT_ADAPTER **iocpp)
@@ -1115,9 +1125,10 @@ mpt_verify_adapter(int iocid, MPT_ADAPTER **iocpp)
1115} 1125}
1116 1126
1117/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1127/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1118/* 1128/**
1119 * mpt_attach - Install a PCI intelligent MPT adapter. 1129 * mpt_attach - Install a PCI intelligent MPT adapter.
1120 * @pdev: Pointer to pci_dev structure 1130 * @pdev: Pointer to pci_dev structure
1131 * @id: PCI device ID information
1121 * 1132 *
1122 * This routine performs all the steps necessary to bring the IOC of 1133 * This routine performs all the steps necessary to bring the IOC of
1123 * a MPT adapter to a OPERATIONAL state. This includes registering 1134 * a MPT adapter to a OPERATIONAL state. This includes registering
@@ -1417,10 +1428,9 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1417} 1428}
1418 1429
1419/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1430/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1420/* 1431/**
1421 * mpt_detach - Remove a PCI intelligent MPT adapter. 1432 * mpt_detach - Remove a PCI intelligent MPT adapter.
1422 * @pdev: Pointer to pci_dev structure 1433 * @pdev: Pointer to pci_dev structure
1423 *
1424 */ 1434 */
1425 1435
1426void 1436void
@@ -1466,10 +1476,10 @@ mpt_detach(struct pci_dev *pdev)
1466 */ 1476 */
1467#ifdef CONFIG_PM 1477#ifdef CONFIG_PM
1468/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1478/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1469/* 1479/**
1470 * mpt_suspend - Fusion MPT base driver suspend routine. 1480 * mpt_suspend - Fusion MPT base driver suspend routine.
1471 * 1481 * @pdev: Pointer to pci_dev structure
1472 * 1482 * @state: new state to enter
1473 */ 1483 */
1474int 1484int
1475mpt_suspend(struct pci_dev *pdev, pm_message_t state) 1485mpt_suspend(struct pci_dev *pdev, pm_message_t state)
@@ -1505,10 +1515,9 @@ mpt_suspend(struct pci_dev *pdev, pm_message_t state)
1505} 1515}
1506 1516
1507/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1517/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1508/* 1518/**
1509 * mpt_resume - Fusion MPT base driver resume routine. 1519 * mpt_resume - Fusion MPT base driver resume routine.
1510 * 1520 * @pdev: Pointer to pci_dev structure
1511 *
1512 */ 1521 */
1513int 1522int
1514mpt_resume(struct pci_dev *pdev) 1523mpt_resume(struct pci_dev *pdev)
@@ -1566,7 +1575,7 @@ mpt_signal_reset(int index, MPT_ADAPTER *ioc, int reset_phase)
1566} 1575}
1567 1576
1568/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1577/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1569/* 1578/**
1570 * mpt_do_ioc_recovery - Initialize or recover MPT adapter. 1579 * mpt_do_ioc_recovery - Initialize or recover MPT adapter.
1571 * @ioc: Pointer to MPT adapter structure 1580 * @ioc: Pointer to MPT adapter structure
1572 * @reason: Event word / reason 1581 * @reason: Event word / reason
@@ -1892,13 +1901,15 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
1892} 1901}
1893 1902
1894/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1903/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1895/* 1904/**
1896 * mpt_detect_bound_ports - Search for PCI bus/dev_function 1905 * mpt_detect_bound_ports - Search for matching PCI bus/dev_function
1897 * which matches PCI bus/dev_function (+/-1) for newly discovered 929,
1898 * 929X, 1030 or 1035.
1899 * @ioc: Pointer to MPT adapter structure 1906 * @ioc: Pointer to MPT adapter structure
1900 * @pdev: Pointer to (struct pci_dev) structure 1907 * @pdev: Pointer to (struct pci_dev) structure
1901 * 1908 *
1909 * Search for PCI bus/dev_function which matches
1910 * PCI bus/dev_function (+/-1) for newly discovered 929,
1911 * 929X, 1030 or 1035.
1912 *
1902 * If match on PCI dev_function +/-1 is found, bind the two MPT adapters 1913 * If match on PCI dev_function +/-1 is found, bind the two MPT adapters
1903 * using alt_ioc pointer fields in their %MPT_ADAPTER structures. 1914 * using alt_ioc pointer fields in their %MPT_ADAPTER structures.
1904 */ 1915 */
@@ -1945,9 +1956,9 @@ mpt_detect_bound_ports(MPT_ADAPTER *ioc, struct pci_dev *pdev)
1945} 1956}
1946 1957
1947/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1958/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1948/* 1959/**
1949 * mpt_adapter_disable - Disable misbehaving MPT adapter. 1960 * mpt_adapter_disable - Disable misbehaving MPT adapter.
1950 * @this: Pointer to MPT adapter structure 1961 * @ioc: Pointer to MPT adapter structure
1951 */ 1962 */
1952static void 1963static void
1953mpt_adapter_disable(MPT_ADAPTER *ioc) 1964mpt_adapter_disable(MPT_ADAPTER *ioc)
@@ -2046,9 +2057,8 @@ mpt_adapter_disable(MPT_ADAPTER *ioc)
2046} 2057}
2047 2058
2048/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2059/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2049/* 2060/**
2050 * mpt_adapter_dispose - Free all resources associated with a MPT 2061 * mpt_adapter_dispose - Free all resources associated with an MPT adapter
2051 * adapter.
2052 * @ioc: Pointer to MPT adapter structure 2062 * @ioc: Pointer to MPT adapter structure
2053 * 2063 *
2054 * This routine unregisters h/w resources and frees all alloc'd memory 2064 * This routine unregisters h/w resources and frees all alloc'd memory
@@ -2099,8 +2109,8 @@ mpt_adapter_dispose(MPT_ADAPTER *ioc)
2099} 2109}
2100 2110
2101/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2111/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2102/* 2112/**
2103 * MptDisplayIocCapabilities - Disply IOC's capacilities. 2113 * MptDisplayIocCapabilities - Disply IOC's capabilities.
2104 * @ioc: Pointer to MPT adapter structure 2114 * @ioc: Pointer to MPT adapter structure
2105 */ 2115 */
2106static void 2116static void
@@ -2142,7 +2152,7 @@ MptDisplayIocCapabilities(MPT_ADAPTER *ioc)
2142} 2152}
2143 2153
2144/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2154/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2145/* 2155/**
2146 * MakeIocReady - Get IOC to a READY state, using KickStart if needed. 2156 * MakeIocReady - Get IOC to a READY state, using KickStart if needed.
2147 * @ioc: Pointer to MPT_ADAPTER structure 2157 * @ioc: Pointer to MPT_ADAPTER structure
2148 * @force: Force hard KickStart of IOC 2158 * @force: Force hard KickStart of IOC
@@ -2279,7 +2289,7 @@ MakeIocReady(MPT_ADAPTER *ioc, int force, int sleepFlag)
2279} 2289}
2280 2290
2281/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2291/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2282/* 2292/**
2283 * mpt_GetIocState - Get the current state of a MPT adapter. 2293 * mpt_GetIocState - Get the current state of a MPT adapter.
2284 * @ioc: Pointer to MPT_ADAPTER structure 2294 * @ioc: Pointer to MPT_ADAPTER structure
2285 * @cooked: Request raw or cooked IOC state 2295 * @cooked: Request raw or cooked IOC state
@@ -2304,7 +2314,7 @@ mpt_GetIocState(MPT_ADAPTER *ioc, int cooked)
2304} 2314}
2305 2315
2306/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2316/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2307/* 2317/**
2308 * GetIocFacts - Send IOCFacts request to MPT adapter. 2318 * GetIocFacts - Send IOCFacts request to MPT adapter.
2309 * @ioc: Pointer to MPT_ADAPTER structure 2319 * @ioc: Pointer to MPT_ADAPTER structure
2310 * @sleepFlag: Specifies whether the process can sleep 2320 * @sleepFlag: Specifies whether the process can sleep
@@ -2478,7 +2488,7 @@ GetIocFacts(MPT_ADAPTER *ioc, int sleepFlag, int reason)
2478} 2488}
2479 2489
2480/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2490/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2481/* 2491/**
2482 * GetPortFacts - Send PortFacts request to MPT adapter. 2492 * GetPortFacts - Send PortFacts request to MPT adapter.
2483 * @ioc: Pointer to MPT_ADAPTER structure 2493 * @ioc: Pointer to MPT_ADAPTER structure
2484 * @portnum: Port number 2494 * @portnum: Port number
@@ -2545,7 +2555,7 @@ GetPortFacts(MPT_ADAPTER *ioc, int portnum, int sleepFlag)
2545} 2555}
2546 2556
2547/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2557/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2548/* 2558/**
2549 * SendIocInit - Send IOCInit request to MPT adapter. 2559 * SendIocInit - Send IOCInit request to MPT adapter.
2550 * @ioc: Pointer to MPT_ADAPTER structure 2560 * @ioc: Pointer to MPT_ADAPTER structure
2551 * @sleepFlag: Specifies whether the process can sleep 2561 * @sleepFlag: Specifies whether the process can sleep
@@ -2630,7 +2640,7 @@ SendIocInit(MPT_ADAPTER *ioc, int sleepFlag)
2630 } 2640 }
2631 2641
2632 /* No need to byte swap the multibyte fields in the reply 2642 /* No need to byte swap the multibyte fields in the reply
2633 * since we don't even look at it's contents. 2643 * since we don't even look at its contents.
2634 */ 2644 */
2635 2645
2636 dhsprintk((MYIOC_s_INFO_FMT "Sending PortEnable (req @ %p)\n", 2646 dhsprintk((MYIOC_s_INFO_FMT "Sending PortEnable (req @ %p)\n",
@@ -2672,7 +2682,7 @@ SendIocInit(MPT_ADAPTER *ioc, int sleepFlag)
2672} 2682}
2673 2683
2674/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2684/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2675/* 2685/**
2676 * SendPortEnable - Send PortEnable request to MPT adapter port. 2686 * SendPortEnable - Send PortEnable request to MPT adapter port.
2677 * @ioc: Pointer to MPT_ADAPTER structure 2687 * @ioc: Pointer to MPT_ADAPTER structure
2678 * @portnum: Port number to enable 2688 * @portnum: Port number to enable
@@ -2723,9 +2733,13 @@ SendPortEnable(MPT_ADAPTER *ioc, int portnum, int sleepFlag)
2723 return rc; 2733 return rc;
2724} 2734}
2725 2735
2726/* 2736/**
2727 * ioc: Pointer to MPT_ADAPTER structure 2737 * mpt_alloc_fw_memory - allocate firmware memory
2728 * size - total FW bytes 2738 * @ioc: Pointer to MPT_ADAPTER structure
2739 * @size: total FW bytes
2740 *
2741 * If memory has already been allocated, the same (cached) value
2742 * is returned.
2729 */ 2743 */
2730void 2744void
2731mpt_alloc_fw_memory(MPT_ADAPTER *ioc, int size) 2745mpt_alloc_fw_memory(MPT_ADAPTER *ioc, int size)
@@ -2742,9 +2756,12 @@ mpt_alloc_fw_memory(MPT_ADAPTER *ioc, int size)
2742 ioc->alloc_total += size; 2756 ioc->alloc_total += size;
2743 } 2757 }
2744} 2758}
2745/* 2759/**
2746 * If alt_img is NULL, delete from ioc structure. 2760 * mpt_free_fw_memory - free firmware memory
2747 * Else, delete a secondary image in same format. 2761 * @ioc: Pointer to MPT_ADAPTER structure
2762 *
2763 * If alt_img is NULL, delete from ioc structure.
2764 * Else, delete a secondary image in same format.
2748 */ 2765 */
2749void 2766void
2750mpt_free_fw_memory(MPT_ADAPTER *ioc) 2767mpt_free_fw_memory(MPT_ADAPTER *ioc)
@@ -2763,7 +2780,7 @@ mpt_free_fw_memory(MPT_ADAPTER *ioc)
2763 2780
2764 2781
2765/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2782/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2766/* 2783/**
2767 * mpt_do_upload - Construct and Send FWUpload request to MPT adapter port. 2784 * mpt_do_upload - Construct and Send FWUpload request to MPT adapter port.
2768 * @ioc: Pointer to MPT_ADAPTER structure 2785 * @ioc: Pointer to MPT_ADAPTER structure
2769 * @sleepFlag: Specifies whether the process can sleep 2786 * @sleepFlag: Specifies whether the process can sleep
@@ -2865,10 +2882,10 @@ mpt_do_upload(MPT_ADAPTER *ioc, int sleepFlag)
2865} 2882}
2866 2883
2867/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2884/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2868/* 2885/**
2869 * mpt_downloadboot - DownloadBoot code 2886 * mpt_downloadboot - DownloadBoot code
2870 * @ioc: Pointer to MPT_ADAPTER structure 2887 * @ioc: Pointer to MPT_ADAPTER structure
2871 * @flag: Specify which part of IOC memory is to be uploaded. 2888 * @pFwHeader: Pointer to firmware header info
2872 * @sleepFlag: Specifies whether the process can sleep 2889 * @sleepFlag: Specifies whether the process can sleep
2873 * 2890 *
2874 * FwDownloadBoot requires Programmed IO access. 2891 * FwDownloadBoot requires Programmed IO access.
@@ -3071,7 +3088,7 @@ mpt_downloadboot(MPT_ADAPTER *ioc, MpiFwHeader_t *pFwHeader, int sleepFlag)
3071} 3088}
3072 3089
3073/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 3090/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3074/* 3091/**
3075 * KickStart - Perform hard reset of MPT adapter. 3092 * KickStart - Perform hard reset of MPT adapter.
3076 * @ioc: Pointer to MPT_ADAPTER structure 3093 * @ioc: Pointer to MPT_ADAPTER structure
3077 * @force: Force hard reset 3094 * @force: Force hard reset
@@ -3145,12 +3162,12 @@ KickStart(MPT_ADAPTER *ioc, int force, int sleepFlag)
3145} 3162}
3146 3163
3147/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 3164/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3148/* 3165/**
3149 * mpt_diag_reset - Perform hard reset of the adapter. 3166 * mpt_diag_reset - Perform hard reset of the adapter.
3150 * @ioc: Pointer to MPT_ADAPTER structure 3167 * @ioc: Pointer to MPT_ADAPTER structure
3151 * @ignore: Set if to honor and clear to ignore 3168 * @ignore: Set if to honor and clear to ignore
3152 * the reset history bit 3169 * the reset history bit
3153 * @sleepflag: CAN_SLEEP if called in a non-interrupt thread, 3170 * @sleepFlag: CAN_SLEEP if called in a non-interrupt thread,
3154 * else set to NO_SLEEP (use mdelay instead) 3171 * else set to NO_SLEEP (use mdelay instead)
3155 * 3172 *
3156 * This routine places the adapter in diagnostic mode via the 3173 * This routine places the adapter in diagnostic mode via the
@@ -3436,11 +3453,12 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag)
3436} 3453}
3437 3454
3438/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 3455/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3439/* 3456/**
3440 * SendIocReset - Send IOCReset request to MPT adapter. 3457 * SendIocReset - Send IOCReset request to MPT adapter.
3441 * @ioc: Pointer to MPT_ADAPTER structure 3458 * @ioc: Pointer to MPT_ADAPTER structure
3442 * @reset_type: reset type, expected values are 3459 * @reset_type: reset type, expected values are
3443 * %MPI_FUNCTION_IOC_MESSAGE_UNIT_RESET or %MPI_FUNCTION_IO_UNIT_RESET 3460 * %MPI_FUNCTION_IOC_MESSAGE_UNIT_RESET or %MPI_FUNCTION_IO_UNIT_RESET
3461 * @sleepFlag: Specifies whether the process can sleep
3444 * 3462 *
3445 * Send IOCReset request to the MPT adapter. 3463 * Send IOCReset request to the MPT adapter.
3446 * 3464 *
@@ -3494,11 +3512,12 @@ SendIocReset(MPT_ADAPTER *ioc, u8 reset_type, int sleepFlag)
3494} 3512}
3495 3513
3496/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 3514/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3497/* 3515/**
3498 * initChainBuffers - Allocate memory for and initialize 3516 * initChainBuffers - Allocate memory for and initialize chain buffers
3499 * chain buffers, chain buffer control arrays and spinlock. 3517 * @ioc: Pointer to MPT_ADAPTER structure
3500 * @hd: Pointer to MPT_SCSI_HOST structure 3518 *
3501 * @init: If set, initialize the spin lock. 3519 * Allocates memory for and initializes chain buffers,
3520 * chain buffer control arrays and spinlock.
3502 */ 3521 */
3503static int 3522static int
3504initChainBuffers(MPT_ADAPTER *ioc) 3523initChainBuffers(MPT_ADAPTER *ioc)
@@ -3594,7 +3613,7 @@ initChainBuffers(MPT_ADAPTER *ioc)
3594} 3613}
3595 3614
3596/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 3615/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3597/* 3616/**
3598 * PrimeIocFifos - Initialize IOC request and reply FIFOs. 3617 * PrimeIocFifos - Initialize IOC request and reply FIFOs.
3599 * @ioc: Pointer to MPT_ADAPTER structure 3618 * @ioc: Pointer to MPT_ADAPTER structure
3600 * 3619 *
@@ -3891,15 +3910,15 @@ mpt_handshake_req_reply_wait(MPT_ADAPTER *ioc, int reqBytes, u32 *req,
3891} 3910}
3892 3911
3893/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 3912/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3894/* 3913/**
3895 * WaitForDoorbellAck - Wait for IOC to clear the IOP_DOORBELL_STATUS bit 3914 * WaitForDoorbellAck - Wait for IOC doorbell handshake acknowledge
3896 * in it's IntStatus register.
3897 * @ioc: Pointer to MPT_ADAPTER structure 3915 * @ioc: Pointer to MPT_ADAPTER structure
3898 * @howlong: How long to wait (in seconds) 3916 * @howlong: How long to wait (in seconds)
3899 * @sleepFlag: Specifies whether the process can sleep 3917 * @sleepFlag: Specifies whether the process can sleep
3900 * 3918 *
3901 * This routine waits (up to ~2 seconds max) for IOC doorbell 3919 * This routine waits (up to ~2 seconds max) for IOC doorbell
3902 * handshake ACKnowledge. 3920 * handshake ACKnowledge, indicated by the IOP_DOORBELL_STATUS
3921 * bit in its IntStatus register being clear.
3903 * 3922 *
3904 * Returns a negative value on failure, else wait loop count. 3923 * Returns a negative value on failure, else wait loop count.
3905 */ 3924 */
@@ -3942,14 +3961,14 @@ WaitForDoorbellAck(MPT_ADAPTER *ioc, int howlong, int sleepFlag)
3942} 3961}
3943 3962
3944/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 3963/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3945/* 3964/**
3946 * WaitForDoorbellInt - Wait for IOC to set the HIS_DOORBELL_INTERRUPT bit 3965 * WaitForDoorbellInt - Wait for IOC to set its doorbell interrupt bit
3947 * in it's IntStatus register.
3948 * @ioc: Pointer to MPT_ADAPTER structure 3966 * @ioc: Pointer to MPT_ADAPTER structure
3949 * @howlong: How long to wait (in seconds) 3967 * @howlong: How long to wait (in seconds)
3950 * @sleepFlag: Specifies whether the process can sleep 3968 * @sleepFlag: Specifies whether the process can sleep
3951 * 3969 *
3952 * This routine waits (up to ~2 seconds max) for IOC doorbell interrupt. 3970 * This routine waits (up to ~2 seconds max) for IOC doorbell interrupt
3971 * (MPI_HIS_DOORBELL_INTERRUPT) to be set in the IntStatus register.
3953 * 3972 *
3954 * Returns a negative value on failure, else wait loop count. 3973 * Returns a negative value on failure, else wait loop count.
3955 */ 3974 */
@@ -3991,8 +4010,8 @@ WaitForDoorbellInt(MPT_ADAPTER *ioc, int howlong, int sleepFlag)
3991} 4010}
3992 4011
3993/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 4012/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3994/* 4013/**
3995 * WaitForDoorbellReply - Wait for and capture a IOC handshake reply. 4014 * WaitForDoorbellReply - Wait for and capture an IOC handshake reply.
3996 * @ioc: Pointer to MPT_ADAPTER structure 4015 * @ioc: Pointer to MPT_ADAPTER structure
3997 * @howlong: How long to wait (in seconds) 4016 * @howlong: How long to wait (in seconds)
3998 * @sleepFlag: Specifies whether the process can sleep 4017 * @sleepFlag: Specifies whether the process can sleep
@@ -4077,7 +4096,7 @@ WaitForDoorbellReply(MPT_ADAPTER *ioc, int howlong, int sleepFlag)
4077} 4096}
4078 4097
4079/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 4098/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4080/* 4099/**
4081 * GetLanConfigPages - Fetch LANConfig pages. 4100 * GetLanConfigPages - Fetch LANConfig pages.
4082 * @ioc: Pointer to MPT_ADAPTER structure 4101 * @ioc: Pointer to MPT_ADAPTER structure
4083 * 4102 *
@@ -4188,12 +4207,9 @@ GetLanConfigPages(MPT_ADAPTER *ioc)
4188} 4207}
4189 4208
4190/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 4209/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4191/* 4210/**
4192 * mptbase_sas_persist_operation - Perform operation on SAS Persitent Table 4211 * mptbase_sas_persist_operation - Perform operation on SAS Persistent Table
4193 * @ioc: Pointer to MPT_ADAPTER structure 4212 * @ioc: Pointer to MPT_ADAPTER structure
4194 * @sas_address: 64bit SAS Address for operation.
4195 * @target_id: specified target for operation
4196 * @bus: specified bus for operation
4197 * @persist_opcode: see below 4213 * @persist_opcode: see below
4198 * 4214 *
4199 * MPI_SAS_OP_CLEAR_NOT_PRESENT - Free all persist TargetID mappings for 4215 * MPI_SAS_OP_CLEAR_NOT_PRESENT - Free all persist TargetID mappings for
@@ -4202,7 +4218,7 @@ GetLanConfigPages(MPT_ADAPTER *ioc)
4202 * 4218 *
4203 * NOTE: Don't use not this function during interrupt time. 4219 * NOTE: Don't use not this function during interrupt time.
4204 * 4220 *
4205 * Returns: 0 for success, non-zero error 4221 * Returns 0 for success, non-zero error
4206 */ 4222 */
4207 4223
4208/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 4224/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
@@ -4399,7 +4415,7 @@ mptbase_raid_process_event_data(MPT_ADAPTER *ioc,
4399} 4415}
4400 4416
4401/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 4417/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4402/* 4418/**
4403 * GetIoUnitPage2 - Retrieve BIOS version and boot order information. 4419 * GetIoUnitPage2 - Retrieve BIOS version and boot order information.
4404 * @ioc: Pointer to MPT_ADAPTER structure 4420 * @ioc: Pointer to MPT_ADAPTER structure
4405 * 4421 *
@@ -4457,7 +4473,8 @@ GetIoUnitPage2(MPT_ADAPTER *ioc)
4457} 4473}
4458 4474
4459/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 4475/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4460/* mpt_GetScsiPortSettings - read SCSI Port Page 0 and 2 4476/**
4477 * mpt_GetScsiPortSettings - read SCSI Port Page 0 and 2
4461 * @ioc: Pointer to a Adapter Strucutre 4478 * @ioc: Pointer to a Adapter Strucutre
4462 * @portnum: IOC port number 4479 * @portnum: IOC port number
4463 * 4480 *
@@ -4644,7 +4661,8 @@ mpt_GetScsiPortSettings(MPT_ADAPTER *ioc, int portnum)
4644} 4661}
4645 4662
4646/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 4663/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4647/* mpt_readScsiDevicePageHeaders - save version and length of SDP1 4664/**
4665 * mpt_readScsiDevicePageHeaders - save version and length of SDP1
4648 * @ioc: Pointer to a Adapter Strucutre 4666 * @ioc: Pointer to a Adapter Strucutre
4649 * @portnum: IOC port number 4667 * @portnum: IOC port number
4650 * 4668 *
@@ -4996,9 +5014,8 @@ mpt_read_ioc_pg_1(MPT_ADAPTER *ioc)
4996} 5014}
4997 5015
4998/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 5016/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4999/* 5017/**
5000 * SendEventNotification - Send EventNotification (on or off) request 5018 * SendEventNotification - Send EventNotification (on or off) request to adapter
5001 * to MPT adapter.
5002 * @ioc: Pointer to MPT_ADAPTER structure 5019 * @ioc: Pointer to MPT_ADAPTER structure
5003 * @EvSwitch: Event switch flags 5020 * @EvSwitch: Event switch flags
5004 */ 5021 */
@@ -5062,8 +5079,8 @@ SendEventAck(MPT_ADAPTER *ioc, EventNotificationReply_t *evnp)
5062/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 5079/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5063/** 5080/**
5064 * mpt_config - Generic function to issue config message 5081 * mpt_config - Generic function to issue config message
5065 * @ioc - Pointer to an adapter structure 5082 * @ioc: Pointer to an adapter structure
5066 * @cfg - Pointer to a configuration structure. Struct contains 5083 * @pCfg: Pointer to a configuration structure. Struct contains
5067 * action, page address, direction, physical address 5084 * action, page address, direction, physical address
5068 * and pointer to a configuration page header 5085 * and pointer to a configuration page header
5069 * Page header is updated. 5086 * Page header is updated.
@@ -5188,8 +5205,8 @@ mpt_config(MPT_ADAPTER *ioc, CONFIGPARMS *pCfg)
5188} 5205}
5189 5206
5190/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 5207/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5191/* 5208/**
5192 * mpt_timer_expired - Call back for timer process. 5209 * mpt_timer_expired - Callback for timer process.
5193 * Used only internal config functionality. 5210 * Used only internal config functionality.
5194 * @data: Pointer to MPT_SCSI_HOST recast as an unsigned long 5211 * @data: Pointer to MPT_SCSI_HOST recast as an unsigned long
5195 */ 5212 */
@@ -5214,12 +5231,12 @@ mpt_timer_expired(unsigned long data)
5214} 5231}
5215 5232
5216/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 5233/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5217/* 5234/**
5218 * mpt_ioc_reset - Base cleanup for hard reset 5235 * mpt_ioc_reset - Base cleanup for hard reset
5219 * @ioc: Pointer to the adapter structure 5236 * @ioc: Pointer to the adapter structure
5220 * @reset_phase: Indicates pre- or post-reset functionality 5237 * @reset_phase: Indicates pre- or post-reset functionality
5221 * 5238 *
5222 * Remark: Free's resources with internally generated commands. 5239 * Remark: Frees resources with internally generated commands.
5223 */ 5240 */
5224static int 5241static int
5225mpt_ioc_reset(MPT_ADAPTER *ioc, int reset_phase) 5242mpt_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
@@ -5271,7 +5288,7 @@ mpt_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
5271 * procfs (%MPT_PROCFS_MPTBASEDIR/...) support stuff... 5288 * procfs (%MPT_PROCFS_MPTBASEDIR/...) support stuff...
5272 */ 5289 */
5273/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 5290/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5274/* 5291/**
5275 * procmpt_create - Create %MPT_PROCFS_MPTBASEDIR entries. 5292 * procmpt_create - Create %MPT_PROCFS_MPTBASEDIR entries.
5276 * 5293 *
5277 * Returns 0 for success, non-zero for failure. 5294 * Returns 0 for success, non-zero for failure.
@@ -5297,7 +5314,7 @@ procmpt_create(void)
5297} 5314}
5298 5315
5299/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 5316/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5300/* 5317/**
5301 * procmpt_destroy - Tear down %MPT_PROCFS_MPTBASEDIR entries. 5318 * procmpt_destroy - Tear down %MPT_PROCFS_MPTBASEDIR entries.
5302 * 5319 *
5303 * Returns 0 for success, non-zero for failure. 5320 * Returns 0 for success, non-zero for failure.
@@ -5311,16 +5328,16 @@ procmpt_destroy(void)
5311} 5328}
5312 5329
5313/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 5330/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5314/* 5331/**
5315 * procmpt_summary_read - Handle read request from /proc/mpt/summary 5332 * procmpt_summary_read - Handle read request of a summary file
5316 * or from /proc/mpt/iocN/summary.
5317 * @buf: Pointer to area to write information 5333 * @buf: Pointer to area to write information
5318 * @start: Pointer to start pointer 5334 * @start: Pointer to start pointer
5319 * @offset: Offset to start writing 5335 * @offset: Offset to start writing
5320 * @request: 5336 * @request: Amount of read data requested
5321 * @eof: Pointer to EOF integer 5337 * @eof: Pointer to EOF integer
5322 * @data: Pointer 5338 * @data: Pointer
5323 * 5339 *
5340 * Handles read request from /proc/mpt/summary or /proc/mpt/iocN/summary.
5324 * Returns number of characters written to process performing the read. 5341 * Returns number of characters written to process performing the read.
5325 */ 5342 */
5326static int 5343static int
@@ -5355,12 +5372,12 @@ procmpt_summary_read(char *buf, char **start, off_t offset, int request, int *eo
5355} 5372}
5356 5373
5357/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 5374/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5358/* 5375/**
5359 * procmpt_version_read - Handle read request from /proc/mpt/version. 5376 * procmpt_version_read - Handle read request from /proc/mpt/version.
5360 * @buf: Pointer to area to write information 5377 * @buf: Pointer to area to write information
5361 * @start: Pointer to start pointer 5378 * @start: Pointer to start pointer
5362 * @offset: Offset to start writing 5379 * @offset: Offset to start writing
5363 * @request: 5380 * @request: Amount of read data requested
5364 * @eof: Pointer to EOF integer 5381 * @eof: Pointer to EOF integer
5365 * @data: Pointer 5382 * @data: Pointer
5366 * 5383 *
@@ -5411,12 +5428,12 @@ procmpt_version_read(char *buf, char **start, off_t offset, int request, int *eo
5411} 5428}
5412 5429
5413/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 5430/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5414/* 5431/**
5415 * procmpt_iocinfo_read - Handle read request from /proc/mpt/iocN/info. 5432 * procmpt_iocinfo_read - Handle read request from /proc/mpt/iocN/info.
5416 * @buf: Pointer to area to write information 5433 * @buf: Pointer to area to write information
5417 * @start: Pointer to start pointer 5434 * @start: Pointer to start pointer
5418 * @offset: Offset to start writing 5435 * @offset: Offset to start writing
5419 * @request: 5436 * @request: Amount of read data requested
5420 * @eof: Pointer to EOF integer 5437 * @eof: Pointer to EOF integer
5421 * @data: Pointer 5438 * @data: Pointer
5422 * 5439 *
@@ -5577,16 +5594,17 @@ mpt_print_ioc_summary(MPT_ADAPTER *ioc, char *buffer, int *size, int len, int sh
5577 */ 5594 */
5578/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 5595/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5579/** 5596/**
5580 * mpt_HardResetHandler - Generic reset handler, issue SCSI Task 5597 * mpt_HardResetHandler - Generic reset handler
5581 * Management call based on input arg values. If TaskMgmt fails,
5582 * return associated SCSI request.
5583 * @ioc: Pointer to MPT_ADAPTER structure 5598 * @ioc: Pointer to MPT_ADAPTER structure
5584 * @sleepFlag: Indicates if sleep or schedule must be called. 5599 * @sleepFlag: Indicates if sleep or schedule must be called.
5585 * 5600 *
5601 * Issues SCSI Task Management call based on input arg values.
5602 * If TaskMgmt fails, returns associated SCSI request.
5603 *
5586 * Remark: _HardResetHandler can be invoked from an interrupt thread (timer) 5604 * Remark: _HardResetHandler can be invoked from an interrupt thread (timer)
5587 * or a non-interrupt thread. In the former, must not call schedule(). 5605 * or a non-interrupt thread. In the former, must not call schedule().
5588 * 5606 *
5589 * Remark: A return of -1 is a FATAL error case, as it means a 5607 * Note: A return of -1 is a FATAL error case, as it means a
5590 * FW reload/initialization failed. 5608 * FW reload/initialization failed.
5591 * 5609 *
5592 * Returns 0 for SUCCESS or -1 if FAILED. 5610 * Returns 0 for SUCCESS or -1 if FAILED.
@@ -5935,13 +5953,14 @@ EventDescriptionStr(u8 event, u32 evData0, char *evStr)
5935} 5953}
5936 5954
5937/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 5955/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5938/* 5956/**
5939 * ProcessEventNotification - Route a received EventNotificationReply to 5957 * ProcessEventNotification - Route EventNotificationReply to all event handlers
5940 * all currently regeistered event handlers.
5941 * @ioc: Pointer to MPT_ADAPTER structure 5958 * @ioc: Pointer to MPT_ADAPTER structure
5942 * @pEventReply: Pointer to EventNotification reply frame 5959 * @pEventReply: Pointer to EventNotification reply frame
5943 * @evHandlers: Pointer to integer, number of event handlers 5960 * @evHandlers: Pointer to integer, number of event handlers
5944 * 5961 *
5962 * Routes a received EventNotificationReply to all currently registered
5963 * event handlers.
5945 * Returns sum of event handlers return values. 5964 * Returns sum of event handlers return values.
5946 */ 5965 */
5947static int 5966static int
@@ -6056,7 +6075,7 @@ ProcessEventNotification(MPT_ADAPTER *ioc, EventNotificationReply_t *pEventReply
6056} 6075}
6057 6076
6058/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 6077/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6059/* 6078/**
6060 * mpt_fc_log_info - Log information returned from Fibre Channel IOC. 6079 * mpt_fc_log_info - Log information returned from Fibre Channel IOC.
6061 * @ioc: Pointer to MPT_ADAPTER structure 6080 * @ioc: Pointer to MPT_ADAPTER structure
6062 * @log_info: U32 LogInfo reply word from the IOC 6081 * @log_info: U32 LogInfo reply word from the IOC
@@ -6077,7 +6096,7 @@ mpt_fc_log_info(MPT_ADAPTER *ioc, u32 log_info)
6077} 6096}
6078 6097
6079/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 6098/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6080/* 6099/**
6081 * mpt_spi_log_info - Log information returned from SCSI Parallel IOC. 6100 * mpt_spi_log_info - Log information returned from SCSI Parallel IOC.
6082 * @ioc: Pointer to MPT_ADAPTER structure 6101 * @ioc: Pointer to MPT_ADAPTER structure
6083 * @mr: Pointer to MPT reply frame 6102 * @mr: Pointer to MPT reply frame
@@ -6185,7 +6204,7 @@ mpt_spi_log_info(MPT_ADAPTER *ioc, u32 log_info)
6185 "Abort", /* 12h */ 6204 "Abort", /* 12h */
6186 "IO Not Yet Executed", /* 13h */ 6205 "IO Not Yet Executed", /* 13h */
6187 "IO Executed", /* 14h */ 6206 "IO Executed", /* 14h */
6188 "Persistant Reservation Out Not Affiliation Owner", /* 15h */ 6207 "Persistent Reservation Out Not Affiliation Owner", /* 15h */
6189 "Open Transmit DMA Abort", /* 16h */ 6208 "Open Transmit DMA Abort", /* 16h */
6190 "IO Device Missing Delay Retry", /* 17h */ 6209 "IO Device Missing Delay Retry", /* 17h */
6191 NULL, /* 18h */ 6210 NULL, /* 18h */
@@ -6200,7 +6219,7 @@ mpt_spi_log_info(MPT_ADAPTER *ioc, u32 log_info)
6200 }; 6219 };
6201 6220
6202/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 6221/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6203/* 6222/**
6204 * mpt_sas_log_info - Log information returned from SAS IOC. 6223 * mpt_sas_log_info - Log information returned from SAS IOC.
6205 * @ioc: Pointer to MPT_ADAPTER structure 6224 * @ioc: Pointer to MPT_ADAPTER structure
6206 * @log_info: U32 LogInfo reply word from the IOC 6225 * @log_info: U32 LogInfo reply word from the IOC
@@ -6255,7 +6274,7 @@ union loginfo_type {
6255} 6274}
6256 6275
6257/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 6276/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6258/* 6277/**
6259 * mpt_sp_ioc_info - IOC information returned from SCSI Parallel IOC. 6278 * mpt_sp_ioc_info - IOC information returned from SCSI Parallel IOC.
6260 * @ioc: Pointer to MPT_ADAPTER structure 6279 * @ioc: Pointer to MPT_ADAPTER structure
6261 * @ioc_status: U32 IOCStatus word from IOC 6280 * @ioc_status: U32 IOCStatus word from IOC
@@ -6416,7 +6435,7 @@ EXPORT_SYMBOL(mpt_free_fw_memory);
6416EXPORT_SYMBOL(mptbase_sas_persist_operation); 6435EXPORT_SYMBOL(mptbase_sas_persist_operation);
6417 6436
6418/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 6437/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6419/* 6438/**
6420 * fusion_init - Fusion MPT base driver initialization routine. 6439 * fusion_init - Fusion MPT base driver initialization routine.
6421 * 6440 *
6422 * Returns 0 for success, non-zero for failure. 6441 * Returns 0 for success, non-zero for failure.
@@ -6456,7 +6475,7 @@ fusion_init(void)
6456} 6475}
6457 6476
6458/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 6477/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6459/* 6478/**
6460 * fusion_exit - Perform driver unload cleanup. 6479 * fusion_exit - Perform driver unload cleanup.
6461 * 6480 *
6462 * This routine frees all resources associated with each MPT adapter 6481 * This routine frees all resources associated with each MPT adapter
diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c
index 1dd491773150..ca2f9107f145 100644
--- a/drivers/message/fusion/mptfc.c
+++ b/drivers/message/fusion/mptfc.c
@@ -1018,9 +1018,10 @@ mptfc_init_host_attr(MPT_ADAPTER *ioc,int portnum)
1018} 1018}
1019 1019
1020static void 1020static void
1021mptfc_setup_reset(void *arg) 1021mptfc_setup_reset(struct work_struct *work)
1022{ 1022{
1023 MPT_ADAPTER *ioc = (MPT_ADAPTER *)arg; 1023 MPT_ADAPTER *ioc =
1024 container_of(work, MPT_ADAPTER, fc_setup_reset_work);
1024 u64 pn; 1025 u64 pn;
1025 struct mptfc_rport_info *ri; 1026 struct mptfc_rport_info *ri;
1026 1027
@@ -1043,9 +1044,10 @@ mptfc_setup_reset(void *arg)
1043} 1044}
1044 1045
1045static void 1046static void
1046mptfc_rescan_devices(void *arg) 1047mptfc_rescan_devices(struct work_struct *work)
1047{ 1048{
1048 MPT_ADAPTER *ioc = (MPT_ADAPTER *)arg; 1049 MPT_ADAPTER *ioc =
1050 container_of(work, MPT_ADAPTER, fc_rescan_work);
1049 int ii; 1051 int ii;
1050 u64 pn; 1052 u64 pn;
1051 struct mptfc_rport_info *ri; 1053 struct mptfc_rport_info *ri;
@@ -1154,8 +1156,8 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1154 } 1156 }
1155 1157
1156 spin_lock_init(&ioc->fc_rescan_work_lock); 1158 spin_lock_init(&ioc->fc_rescan_work_lock);
1157 INIT_WORK(&ioc->fc_rescan_work, mptfc_rescan_devices,(void *)ioc); 1159 INIT_WORK(&ioc->fc_rescan_work, mptfc_rescan_devices);
1158 INIT_WORK(&ioc->fc_setup_reset_work, mptfc_setup_reset, (void *)ioc); 1160 INIT_WORK(&ioc->fc_setup_reset_work, mptfc_setup_reset);
1159 1161
1160 spin_lock_irqsave(&ioc->FreeQlock, flags); 1162 spin_lock_irqsave(&ioc->FreeQlock, flags);
1161 1163
@@ -1393,8 +1395,7 @@ mptfc_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
1393 1395
1394/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1396/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1395/** 1397/**
1396 * mptfc_init - Register MPT adapter(s) as SCSI host(s) with 1398 * mptfc_init - Register MPT adapter(s) as SCSI host(s) with SCSI mid-layer.
1397 * linux scsi mid-layer.
1398 * 1399 *
1399 * Returns 0 for success, non-zero for failure. 1400 * Returns 0 for success, non-zero for failure.
1400 */ 1401 */
@@ -1438,7 +1439,7 @@ mptfc_init(void)
1438 1439
1439/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1440/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1440/** 1441/**
1441 * mptfc_remove - Removed fc infrastructure for devices 1442 * mptfc_remove - Remove fc infrastructure for devices
1442 * @pdev: Pointer to pci_dev structure 1443 * @pdev: Pointer to pci_dev structure
1443 * 1444 *
1444 */ 1445 */
diff --git a/drivers/message/fusion/mptlan.c b/drivers/message/fusion/mptlan.c
index 314c3a27585d..b7c4407c5e3f 100644
--- a/drivers/message/fusion/mptlan.c
+++ b/drivers/message/fusion/mptlan.c
@@ -111,7 +111,8 @@ struct mpt_lan_priv {
111 u32 total_received; 111 u32 total_received;
112 struct net_device_stats stats; /* Per device statistics */ 112 struct net_device_stats stats; /* Per device statistics */
113 113
114 struct work_struct post_buckets_task; 114 struct delayed_work post_buckets_task;
115 struct net_device *dev;
115 unsigned long post_buckets_active; 116 unsigned long post_buckets_active;
116}; 117};
117 118
@@ -132,7 +133,7 @@ static int lan_reply (MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf,
132static int mpt_lan_open(struct net_device *dev); 133static int mpt_lan_open(struct net_device *dev);
133static int mpt_lan_reset(struct net_device *dev); 134static int mpt_lan_reset(struct net_device *dev);
134static int mpt_lan_close(struct net_device *dev); 135static int mpt_lan_close(struct net_device *dev);
135static void mpt_lan_post_receive_buckets(void *dev_id); 136static void mpt_lan_post_receive_buckets(struct mpt_lan_priv *priv);
136static void mpt_lan_wake_post_buckets_task(struct net_device *dev, 137static void mpt_lan_wake_post_buckets_task(struct net_device *dev,
137 int priority); 138 int priority);
138static int mpt_lan_receive_post_turbo(struct net_device *dev, u32 tmsg); 139static int mpt_lan_receive_post_turbo(struct net_device *dev, u32 tmsg);
@@ -345,7 +346,7 @@ mpt_lan_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
345 priv->mpt_rxfidx[++priv->mpt_rxfidx_tail] = i; 346 priv->mpt_rxfidx[++priv->mpt_rxfidx_tail] = i;
346 spin_unlock_irqrestore(&priv->rxfidx_lock, flags); 347 spin_unlock_irqrestore(&priv->rxfidx_lock, flags);
347 } else { 348 } else {
348 mpt_lan_post_receive_buckets(dev); 349 mpt_lan_post_receive_buckets(priv);
349 netif_wake_queue(dev); 350 netif_wake_queue(dev);
350 } 351 }
351 352
@@ -441,7 +442,7 @@ mpt_lan_open(struct net_device *dev)
441 442
442 dlprintk((KERN_INFO MYNAM "/lo: Finished initializing RcvCtl\n")); 443 dlprintk((KERN_INFO MYNAM "/lo: Finished initializing RcvCtl\n"));
443 444
444 mpt_lan_post_receive_buckets(dev); 445 mpt_lan_post_receive_buckets(priv);
445 printk(KERN_INFO MYNAM ": %s/%s: interface up & active\n", 446 printk(KERN_INFO MYNAM ": %s/%s: interface up & active\n",
446 IOC_AND_NETDEV_NAMES_s_s(dev)); 447 IOC_AND_NETDEV_NAMES_s_s(dev));
447 448
@@ -854,7 +855,7 @@ mpt_lan_wake_post_buckets_task(struct net_device *dev, int priority)
854 855
855 if (test_and_set_bit(0, &priv->post_buckets_active) == 0) { 856 if (test_and_set_bit(0, &priv->post_buckets_active) == 0) {
856 if (priority) { 857 if (priority) {
857 schedule_work(&priv->post_buckets_task); 858 schedule_delayed_work(&priv->post_buckets_task, 0);
858 } else { 859 } else {
859 schedule_delayed_work(&priv->post_buckets_task, 1); 860 schedule_delayed_work(&priv->post_buckets_task, 1);
860 dioprintk((KERN_INFO MYNAM ": post_buckets queued on " 861 dioprintk((KERN_INFO MYNAM ": post_buckets queued on "
@@ -1188,10 +1189,9 @@ mpt_lan_receive_post_reply(struct net_device *dev,
1188/* Simple SGE's only at the moment */ 1189/* Simple SGE's only at the moment */
1189 1190
1190static void 1191static void
1191mpt_lan_post_receive_buckets(void *dev_id) 1192mpt_lan_post_receive_buckets(struct mpt_lan_priv *priv)
1192{ 1193{
1193 struct net_device *dev = dev_id; 1194 struct net_device *dev = priv->dev;
1194 struct mpt_lan_priv *priv = dev->priv;
1195 MPT_ADAPTER *mpt_dev = priv->mpt_dev; 1195 MPT_ADAPTER *mpt_dev = priv->mpt_dev;
1196 MPT_FRAME_HDR *mf; 1196 MPT_FRAME_HDR *mf;
1197 LANReceivePostRequest_t *pRecvReq; 1197 LANReceivePostRequest_t *pRecvReq;
@@ -1335,6 +1335,13 @@ out:
1335 clear_bit(0, &priv->post_buckets_active); 1335 clear_bit(0, &priv->post_buckets_active);
1336} 1336}
1337 1337
1338static void
1339mpt_lan_post_receive_buckets_work(struct work_struct *work)
1340{
1341 mpt_lan_post_receive_buckets(container_of(work, struct mpt_lan_priv,
1342 post_buckets_task.work));
1343}
1344
1338/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1345/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1339static struct net_device * 1346static struct net_device *
1340mpt_register_lan_device (MPT_ADAPTER *mpt_dev, int pnum) 1347mpt_register_lan_device (MPT_ADAPTER *mpt_dev, int pnum)
@@ -1350,11 +1357,13 @@ mpt_register_lan_device (MPT_ADAPTER *mpt_dev, int pnum)
1350 1357
1351 priv = netdev_priv(dev); 1358 priv = netdev_priv(dev);
1352 1359
1360 priv->dev = dev;
1353 priv->mpt_dev = mpt_dev; 1361 priv->mpt_dev = mpt_dev;
1354 priv->pnum = pnum; 1362 priv->pnum = pnum;
1355 1363
1356 memset(&priv->post_buckets_task, 0, sizeof(struct work_struct)); 1364 memset(&priv->post_buckets_task, 0, sizeof(priv->post_buckets_task));
1357 INIT_WORK(&priv->post_buckets_task, mpt_lan_post_receive_buckets, dev); 1365 INIT_DELAYED_WORK(&priv->post_buckets_task,
1366 mpt_lan_post_receive_buckets_work);
1358 priv->post_buckets_active = 0; 1367 priv->post_buckets_active = 0;
1359 1368
1360 dlprintk((KERN_INFO MYNAM "@%d: bucketlen = %d\n", 1369 dlprintk((KERN_INFO MYNAM "@%d: bucketlen = %d\n",
diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
index b752a479f6db..4f0c530e47b0 100644
--- a/drivers/message/fusion/mptsas.c
+++ b/drivers/message/fusion/mptsas.c
@@ -2006,9 +2006,10 @@ __mptsas_discovery_work(MPT_ADAPTER *ioc)
2006 *(Mutex LOCKED) 2006 *(Mutex LOCKED)
2007 */ 2007 */
2008static void 2008static void
2009mptsas_discovery_work(void * arg) 2009mptsas_discovery_work(struct work_struct *work)
2010{ 2010{
2011 struct mptsas_discovery_event *ev = arg; 2011 struct mptsas_discovery_event *ev =
2012 container_of(work, struct mptsas_discovery_event, work);
2012 MPT_ADAPTER *ioc = ev->ioc; 2013 MPT_ADAPTER *ioc = ev->ioc;
2013 2014
2014 mutex_lock(&ioc->sas_discovery_mutex); 2015 mutex_lock(&ioc->sas_discovery_mutex);
@@ -2068,9 +2069,9 @@ mptsas_find_phyinfo_by_target(MPT_ADAPTER *ioc, u32 id)
2068 * Work queue thread to clear the persitency table 2069 * Work queue thread to clear the persitency table
2069 */ 2070 */
2070static void 2071static void
2071mptsas_persist_clear_table(void * arg) 2072mptsas_persist_clear_table(struct work_struct *work)
2072{ 2073{
2073 MPT_ADAPTER *ioc = (MPT_ADAPTER *)arg; 2074 MPT_ADAPTER *ioc = container_of(work, MPT_ADAPTER, sas_persist_task);
2074 2075
2075 mptbase_sas_persist_operation(ioc, MPI_SAS_OP_CLEAR_NOT_PRESENT); 2076 mptbase_sas_persist_operation(ioc, MPI_SAS_OP_CLEAR_NOT_PRESENT);
2076} 2077}
@@ -2093,9 +2094,10 @@ mptsas_reprobe_target(struct scsi_target *starget, int uld_attach)
2093 * Work queue thread to handle SAS hotplug events 2094 * Work queue thread to handle SAS hotplug events
2094 */ 2095 */
2095static void 2096static void
2096mptsas_hotplug_work(void *arg) 2097mptsas_hotplug_work(struct work_struct *work)
2097{ 2098{
2098 struct mptsas_hotplug_event *ev = arg; 2099 struct mptsas_hotplug_event *ev =
2100 container_of(work, struct mptsas_hotplug_event, work);
2099 MPT_ADAPTER *ioc = ev->ioc; 2101 MPT_ADAPTER *ioc = ev->ioc;
2100 struct mptsas_phyinfo *phy_info; 2102 struct mptsas_phyinfo *phy_info;
2101 struct sas_rphy *rphy; 2103 struct sas_rphy *rphy;
@@ -2341,7 +2343,7 @@ mptsas_send_sas_event(MPT_ADAPTER *ioc,
2341 break; 2343 break;
2342 } 2344 }
2343 2345
2344 INIT_WORK(&ev->work, mptsas_hotplug_work, ev); 2346 INIT_WORK(&ev->work, mptsas_hotplug_work);
2345 ev->ioc = ioc; 2347 ev->ioc = ioc;
2346 ev->handle = le16_to_cpu(sas_event_data->DevHandle); 2348 ev->handle = le16_to_cpu(sas_event_data->DevHandle);
2347 ev->parent_handle = 2349 ev->parent_handle =
@@ -2366,7 +2368,7 @@ mptsas_send_sas_event(MPT_ADAPTER *ioc,
2366 * Persistent table is full. 2368 * Persistent table is full.
2367 */ 2369 */
2368 INIT_WORK(&ioc->sas_persist_task, 2370 INIT_WORK(&ioc->sas_persist_task,
2369 mptsas_persist_clear_table, (void *)ioc); 2371 mptsas_persist_clear_table);
2370 schedule_work(&ioc->sas_persist_task); 2372 schedule_work(&ioc->sas_persist_task);
2371 break; 2373 break;
2372 case MPI_EVENT_SAS_DEV_STAT_RC_SMART_DATA: 2374 case MPI_EVENT_SAS_DEV_STAT_RC_SMART_DATA:
@@ -2395,7 +2397,7 @@ mptsas_send_raid_event(MPT_ADAPTER *ioc,
2395 return; 2397 return;
2396 } 2398 }
2397 2399
2398 INIT_WORK(&ev->work, mptsas_hotplug_work, ev); 2400 INIT_WORK(&ev->work, mptsas_hotplug_work);
2399 ev->ioc = ioc; 2401 ev->ioc = ioc;
2400 ev->id = raid_event_data->VolumeID; 2402 ev->id = raid_event_data->VolumeID;
2401 ev->event_type = MPTSAS_IGNORE_EVENT; 2403 ev->event_type = MPTSAS_IGNORE_EVENT;
@@ -2474,7 +2476,7 @@ mptsas_send_discovery_event(MPT_ADAPTER *ioc,
2474 ev = kzalloc(sizeof(*ev), GFP_ATOMIC); 2476 ev = kzalloc(sizeof(*ev), GFP_ATOMIC);
2475 if (!ev) 2477 if (!ev)
2476 return; 2478 return;
2477 INIT_WORK(&ev->work, mptsas_discovery_work, ev); 2479 INIT_WORK(&ev->work, mptsas_discovery_work);
2478 ev->ioc = ioc; 2480 ev->ioc = ioc;
2479 schedule_work(&ev->work); 2481 schedule_work(&ev->work);
2480}; 2482};
@@ -2511,8 +2513,7 @@ mptsas_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *reply)
2511 break; 2513 break;
2512 case MPI_EVENT_PERSISTENT_TABLE_FULL: 2514 case MPI_EVENT_PERSISTENT_TABLE_FULL:
2513 INIT_WORK(&ioc->sas_persist_task, 2515 INIT_WORK(&ioc->sas_persist_task,
2514 mptsas_persist_clear_table, 2516 mptsas_persist_clear_table);
2515 (void *)ioc);
2516 schedule_work(&ioc->sas_persist_task); 2517 schedule_work(&ioc->sas_persist_task);
2517 break; 2518 break;
2518 case MPI_EVENT_SAS_DISCOVERY: 2519 case MPI_EVENT_SAS_DISCOVERY:
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index 30524dc54b16..2c72c36b8171 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -1230,15 +1230,15 @@ mptscsih_host_info(MPT_ADAPTER *ioc, char *pbuf, off_t offset, int len)
1230/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1230/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1231/** 1231/**
1232 * mptscsih_proc_info - Return information about MPT adapter 1232 * mptscsih_proc_info - Return information about MPT adapter
1233 * @host: scsi host struct
1234 * @buffer: if write, user data; if read, buffer for user
1235 * @start: returns the buffer address
1236 * @offset: if write, 0; if read, the current offset into the buffer from
1237 * the previous read.
1238 * @length: if write, return length;
1239 * @func: write = 1; read = 0
1233 * 1240 *
1234 * (linux scsi_host_template.info routine) 1241 * (linux scsi_host_template.info routine)
1235 *
1236 * buffer: if write, user data; if read, buffer for user
1237 * length: if write, return length;
1238 * offset: if write, 0; if read, the current offset into the buffer from
1239 * the previous read.
1240 * hostno: scsi host number
1241 * func: if write = 1; if read = 0
1242 */ 1242 */
1243int 1243int
1244mptscsih_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, 1244mptscsih_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset,
@@ -1902,8 +1902,7 @@ mptscsih_bus_reset(struct scsi_cmnd * SCpnt)
1902 1902
1903/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1903/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1904/** 1904/**
1905 * mptscsih_host_reset - Perform a SCSI host adapter RESET! 1905 * mptscsih_host_reset - Perform a SCSI host adapter RESET (new_eh variant)
1906 * new_eh variant
1907 * @SCpnt: Pointer to scsi_cmnd structure, IO which reset is due to 1906 * @SCpnt: Pointer to scsi_cmnd structure, IO which reset is due to
1908 * 1907 *
1909 * (linux scsi_host_template.eh_host_reset_handler routine) 1908 * (linux scsi_host_template.eh_host_reset_handler routine)
@@ -1949,8 +1948,7 @@ mptscsih_host_reset(struct scsi_cmnd *SCpnt)
1949 1948
1950/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1949/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1951/** 1950/**
1952 * mptscsih_tm_pending_wait - wait for pending task management request to 1951 * mptscsih_tm_pending_wait - wait for pending task management request to complete
1953 * complete.
1954 * @hd: Pointer to MPT host structure. 1952 * @hd: Pointer to MPT host structure.
1955 * 1953 *
1956 * Returns {SUCCESS,FAILED}. 1954 * Returns {SUCCESS,FAILED}.
@@ -1982,6 +1980,7 @@ mptscsih_tm_pending_wait(MPT_SCSI_HOST * hd)
1982/** 1980/**
1983 * mptscsih_tm_wait_for_completion - wait for completion of TM task 1981 * mptscsih_tm_wait_for_completion - wait for completion of TM task
1984 * @hd: Pointer to MPT host structure. 1982 * @hd: Pointer to MPT host structure.
1983 * @timeout: timeout in seconds
1985 * 1984 *
1986 * Returns {SUCCESS,FAILED}. 1985 * Returns {SUCCESS,FAILED}.
1987 */ 1986 */
@@ -3429,8 +3428,7 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io)
3429/** 3428/**
3430 * mptscsih_synchronize_cache - Send SYNCHRONIZE_CACHE to all disks. 3429 * mptscsih_synchronize_cache - Send SYNCHRONIZE_CACHE to all disks.
3431 * @hd: Pointer to a SCSI HOST structure 3430 * @hd: Pointer to a SCSI HOST structure
3432 * @vtarget: per device private data 3431 * @vdevice: virtual target device
3433 * @lun: lun
3434 * 3432 *
3435 * Uses the ISR, but with special processing. 3433 * Uses the ISR, but with special processing.
3436 * MUST be single-threaded. 3434 * MUST be single-threaded.
diff --git a/drivers/message/fusion/mptspi.c b/drivers/message/fusion/mptspi.c
index e4cc3dd5fc9f..36641da59289 100644
--- a/drivers/message/fusion/mptspi.c
+++ b/drivers/message/fusion/mptspi.c
@@ -646,9 +646,10 @@ struct work_queue_wrapper {
646 int disk; 646 int disk;
647}; 647};
648 648
649static void mpt_work_wrapper(void *data) 649static void mpt_work_wrapper(struct work_struct *work)
650{ 650{
651 struct work_queue_wrapper *wqw = (struct work_queue_wrapper *)data; 651 struct work_queue_wrapper *wqw =
652 container_of(work, struct work_queue_wrapper, work);
652 struct _MPT_SCSI_HOST *hd = wqw->hd; 653 struct _MPT_SCSI_HOST *hd = wqw->hd;
653 struct Scsi_Host *shost = hd->ioc->sh; 654 struct Scsi_Host *shost = hd->ioc->sh;
654 struct scsi_device *sdev; 655 struct scsi_device *sdev;
@@ -695,7 +696,7 @@ static void mpt_dv_raid(struct _MPT_SCSI_HOST *hd, int disk)
695 disk); 696 disk);
696 return; 697 return;
697 } 698 }
698 INIT_WORK(&wqw->work, mpt_work_wrapper, wqw); 699 INIT_WORK(&wqw->work, mpt_work_wrapper);
699 wqw->hd = hd; 700 wqw->hd = hd;
700 wqw->disk = disk; 701 wqw->disk = disk;
701 702
@@ -784,9 +785,10 @@ MODULE_DEVICE_TABLE(pci, mptspi_pci_table);
784 * renegotiate for a given target 785 * renegotiate for a given target
785 */ 786 */
786static void 787static void
787mptspi_dv_renegotiate_work(void *data) 788mptspi_dv_renegotiate_work(struct work_struct *work)
788{ 789{
789 struct work_queue_wrapper *wqw = (struct work_queue_wrapper *)data; 790 struct work_queue_wrapper *wqw =
791 container_of(work, struct work_queue_wrapper, work);
790 struct _MPT_SCSI_HOST *hd = wqw->hd; 792 struct _MPT_SCSI_HOST *hd = wqw->hd;
791 struct scsi_device *sdev; 793 struct scsi_device *sdev;
792 794
@@ -804,7 +806,7 @@ mptspi_dv_renegotiate(struct _MPT_SCSI_HOST *hd)
804 if (!wqw) 806 if (!wqw)
805 return; 807 return;
806 808
807 INIT_WORK(&wqw->work, mptspi_dv_renegotiate_work, wqw); 809 INIT_WORK(&wqw->work, mptspi_dv_renegotiate_work);
808 wqw->hd = hd; 810 wqw->hd = hd;
809 811
810 schedule_work(&wqw->work); 812 schedule_work(&wqw->work);
@@ -1098,8 +1100,7 @@ static struct pci_driver mptspi_driver = {
1098 1100
1099/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1101/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1100/** 1102/**
1101 * mptspi_init - Register MPT adapter(s) as SCSI host(s) with 1103 * mptspi_init - Register MPT adapter(s) as SCSI host(s) with SCSI mid-layer.
1102 * linux scsi mid-layer.
1103 * 1104 *
1104 * Returns 0 for success, non-zero for failure. 1105 * Returns 0 for success, non-zero for failure.
1105 */ 1106 */
@@ -1133,7 +1134,6 @@ mptspi_init(void)
1133/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1134/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1134/** 1135/**
1135 * mptspi_exit - Unregisters MPT adapter(s) 1136 * mptspi_exit - Unregisters MPT adapter(s)
1136 *
1137 */ 1137 */
1138static void __exit 1138static void __exit
1139mptspi_exit(void) 1139mptspi_exit(void)
diff --git a/drivers/message/i2o/bus-osm.c b/drivers/message/i2o/bus-osm.c
index d96c687aee93..c463dc2efc09 100644
--- a/drivers/message/i2o/bus-osm.c
+++ b/drivers/message/i2o/bus-osm.c
@@ -56,6 +56,9 @@ static int i2o_bus_scan(struct i2o_device *dev)
56/** 56/**
57 * i2o_bus_store_scan - Scan the I2O Bus Adapter 57 * i2o_bus_store_scan - Scan the I2O Bus Adapter
58 * @d: device which should be scanned 58 * @d: device which should be scanned
59 * @attr: device_attribute
60 * @buf: output buffer
61 * @count: buffer size
59 * 62 *
60 * Returns count. 63 * Returns count.
61 */ 64 */
diff --git a/drivers/message/i2o/device.c b/drivers/message/i2o/device.c
index ee183053fa23..b9df143e4ff1 100644
--- a/drivers/message/i2o/device.c
+++ b/drivers/message/i2o/device.c
@@ -54,8 +54,8 @@ static inline int i2o_device_issue_claim(struct i2o_device *dev, u32 cmd,
54 * @dev: I2O device to claim 54 * @dev: I2O device to claim
55 * @drv: I2O driver which wants to claim the device 55 * @drv: I2O driver which wants to claim the device
56 * 56 *
57 * Do the leg work to assign a device to a given OSM. If the claim succeed 57 * Do the leg work to assign a device to a given OSM. If the claim succeeds,
58 * the owner of the rimary. If the attempt fails a negative errno code 58 * the owner is the primary. If the attempt fails a negative errno code
59 * is returned. On success zero is returned. 59 * is returned. On success zero is returned.
60 */ 60 */
61int i2o_device_claim(struct i2o_device *dev) 61int i2o_device_claim(struct i2o_device *dev)
@@ -208,24 +208,23 @@ static struct i2o_device *i2o_device_alloc(void)
208 208
209/** 209/**
210 * i2o_device_add - allocate a new I2O device and add it to the IOP 210 * i2o_device_add - allocate a new I2O device and add it to the IOP
211 * @iop: I2O controller where the device is on 211 * @c: I2O controller that the device is on
212 * @entry: LCT entry of the I2O device 212 * @entry: LCT entry of the I2O device
213 * 213 *
214 * Allocate a new I2O device and initialize it with the LCT entry. The 214 * Allocate a new I2O device and initialize it with the LCT entry. The
215 * device is appended to the device list of the controller. 215 * device is appended to the device list of the controller.
216 * 216 *
217 * Returns a pointer to the I2O device on success or negative error code 217 * Returns zero on success, or a -ve errno.
218 * on failure.
219 */ 218 */
220static struct i2o_device *i2o_device_add(struct i2o_controller *c, 219static int i2o_device_add(struct i2o_controller *c, i2o_lct_entry *entry)
221 i2o_lct_entry * entry)
222{ 220{
223 struct i2o_device *i2o_dev, *tmp; 221 struct i2o_device *i2o_dev, *tmp;
222 int rc;
224 223
225 i2o_dev = i2o_device_alloc(); 224 i2o_dev = i2o_device_alloc();
226 if (IS_ERR(i2o_dev)) { 225 if (IS_ERR(i2o_dev)) {
227 printk(KERN_ERR "i2o: unable to allocate i2o device\n"); 226 printk(KERN_ERR "i2o: unable to allocate i2o device\n");
228 return i2o_dev; 227 return PTR_ERR(i2o_dev);
229 } 228 }
230 229
231 i2o_dev->lct_data = *entry; 230 i2o_dev->lct_data = *entry;
@@ -236,7 +235,9 @@ static struct i2o_device *i2o_device_add(struct i2o_controller *c,
236 i2o_dev->iop = c; 235 i2o_dev->iop = c;
237 i2o_dev->device.parent = &c->device; 236 i2o_dev->device.parent = &c->device;
238 237
239 device_register(&i2o_dev->device); 238 rc = device_register(&i2o_dev->device);
239 if (rc)
240 goto err;
240 241
241 list_add_tail(&i2o_dev->list, &c->devices); 242 list_add_tail(&i2o_dev->list, &c->devices);
242 243
@@ -270,12 +271,16 @@ static struct i2o_device *i2o_device_add(struct i2o_controller *c,
270 271
271 pr_debug("i2o: device %s added\n", i2o_dev->device.bus_id); 272 pr_debug("i2o: device %s added\n", i2o_dev->device.bus_id);
272 273
273 return i2o_dev; 274 return 0;
275
276err:
277 kfree(i2o_dev);
278 return rc;
274} 279}
275 280
276/** 281/**
277 * i2o_device_remove - remove an I2O device from the I2O core 282 * i2o_device_remove - remove an I2O device from the I2O core
278 * @dev: I2O device which should be released 283 * @i2o_dev: I2O device which should be released
279 * 284 *
280 * Is used on I2O controller removal or LCT modification, when the device 285 * Is used on I2O controller removal or LCT modification, when the device
281 * is removed from the system. Note that the device could still hang 286 * is removed from the system. Note that the device could still hang
diff --git a/drivers/message/i2o/driver.c b/drivers/message/i2o/driver.c
index 64130227574f..9104b65ff70f 100644
--- a/drivers/message/i2o/driver.c
+++ b/drivers/message/i2o/driver.c
@@ -34,9 +34,7 @@ static spinlock_t i2o_drivers_lock;
34static struct i2o_driver **i2o_drivers; 34static struct i2o_driver **i2o_drivers;
35 35
36/** 36/**
37 * i2o_bus_match - Tell if a I2O device class id match the class ids of 37 * i2o_bus_match - Tell if I2O device class id matches the class ids of the I2O driver (OSM)
38 * the I2O driver (OSM)
39 *
40 * @dev: device which should be verified 38 * @dev: device which should be verified
41 * @drv: the driver to match against 39 * @drv: the driver to match against
42 * 40 *
@@ -232,7 +230,7 @@ int i2o_driver_dispatch(struct i2o_controller *c, u32 m)
232 break; 230 break;
233 } 231 }
234 232
235 INIT_WORK(&evt->work, (void (*)(void *))drv->event, evt); 233 INIT_WORK(&evt->work, drv->event);
236 queue_work(drv->event_queue, &evt->work); 234 queue_work(drv->event_queue, &evt->work);
237 return 1; 235 return 1;
238 } 236 }
@@ -248,7 +246,7 @@ int i2o_driver_dispatch(struct i2o_controller *c, u32 m)
248 246
249/** 247/**
250 * i2o_driver_notify_controller_add_all - Send notify of added controller 248 * i2o_driver_notify_controller_add_all - Send notify of added controller
251 * to all I2O drivers 249 * @c: newly added controller
252 * 250 *
253 * Send notifications to all registered drivers that a new controller was 251 * Send notifications to all registered drivers that a new controller was
254 * added. 252 * added.
@@ -267,8 +265,8 @@ void i2o_driver_notify_controller_add_all(struct i2o_controller *c)
267} 265}
268 266
269/** 267/**
270 * i2o_driver_notify_controller_remove_all - Send notify of removed 268 * i2o_driver_notify_controller_remove_all - Send notify of removed controller
271 * controller to all I2O drivers 269 * @c: controller that is being removed
272 * 270 *
273 * Send notifications to all registered drivers that a controller was 271 * Send notifications to all registered drivers that a controller was
274 * removed. 272 * removed.
@@ -287,8 +285,8 @@ void i2o_driver_notify_controller_remove_all(struct i2o_controller *c)
287} 285}
288 286
289/** 287/**
290 * i2o_driver_notify_device_add_all - Send notify of added device to all 288 * i2o_driver_notify_device_add_all - Send notify of added device
291 * I2O drivers 289 * @i2o_dev: newly added I2O device
292 * 290 *
293 * Send notifications to all registered drivers that a device was added. 291 * Send notifications to all registered drivers that a device was added.
294 */ 292 */
@@ -306,8 +304,8 @@ void i2o_driver_notify_device_add_all(struct i2o_device *i2o_dev)
306} 304}
307 305
308/** 306/**
309 * i2o_driver_notify_device_remove_all - Send notify of removed device to 307 * i2o_driver_notify_device_remove_all - Send notify of removed device
310 * all I2O drivers 308 * @i2o_dev: device that is being removed
311 * 309 *
312 * Send notifications to all registered drivers that a device was removed. 310 * Send notifications to all registered drivers that a device was removed.
313 */ 311 */
@@ -362,7 +360,7 @@ int __init i2o_driver_init(void)
362/** 360/**
363 * i2o_driver_exit - clean up I2O drivers (OSMs) 361 * i2o_driver_exit - clean up I2O drivers (OSMs)
364 * 362 *
365 * Unregisters the I2O bus and free driver array. 363 * Unregisters the I2O bus and frees driver array.
366 */ 364 */
367void __exit i2o_driver_exit(void) 365void __exit i2o_driver_exit(void)
368{ 366{
diff --git a/drivers/message/i2o/exec-osm.c b/drivers/message/i2o/exec-osm.c
index a2350640384b..902753b2c661 100644
--- a/drivers/message/i2o/exec-osm.c
+++ b/drivers/message/i2o/exec-osm.c
@@ -94,8 +94,8 @@ static struct i2o_exec_wait *i2o_exec_wait_alloc(void)
94}; 94};
95 95
96/** 96/**
97 * i2o_exec_wait_free - Free a i2o_exec_wait struct 97 * i2o_exec_wait_free - Free an i2o_exec_wait struct
98 * @i2o_exec_wait: I2O wait data which should be cleaned up 98 * @wait: I2O wait data which should be cleaned up
99 */ 99 */
100static void i2o_exec_wait_free(struct i2o_exec_wait *wait) 100static void i2o_exec_wait_free(struct i2o_exec_wait *wait)
101{ 101{
@@ -105,7 +105,7 @@ static void i2o_exec_wait_free(struct i2o_exec_wait *wait)
105/** 105/**
106 * i2o_msg_post_wait_mem - Post and wait a message with DMA buffers 106 * i2o_msg_post_wait_mem - Post and wait a message with DMA buffers
107 * @c: controller 107 * @c: controller
108 * @m: message to post 108 * @msg: message to post
109 * @timeout: time in seconds to wait 109 * @timeout: time in seconds to wait
110 * @dma: i2o_dma struct of the DMA buffer to free on failure 110 * @dma: i2o_dma struct of the DMA buffer to free on failure
111 * 111 *
@@ -269,6 +269,7 @@ static int i2o_msg_post_wait_complete(struct i2o_controller *c, u32 m,
269/** 269/**
270 * i2o_exec_show_vendor_id - Displays Vendor ID of controller 270 * i2o_exec_show_vendor_id - Displays Vendor ID of controller
271 * @d: device of which the Vendor ID should be displayed 271 * @d: device of which the Vendor ID should be displayed
272 * @attr: device_attribute to display
272 * @buf: buffer into which the Vendor ID should be printed 273 * @buf: buffer into which the Vendor ID should be printed
273 * 274 *
274 * Returns number of bytes printed into buffer. 275 * Returns number of bytes printed into buffer.
@@ -290,6 +291,7 @@ static ssize_t i2o_exec_show_vendor_id(struct device *d,
290/** 291/**
291 * i2o_exec_show_product_id - Displays Product ID of controller 292 * i2o_exec_show_product_id - Displays Product ID of controller
292 * @d: device of which the Product ID should be displayed 293 * @d: device of which the Product ID should be displayed
294 * @attr: device_attribute to display
293 * @buf: buffer into which the Product ID should be printed 295 * @buf: buffer into which the Product ID should be printed
294 * 296 *
295 * Returns number of bytes printed into buffer. 297 * Returns number of bytes printed into buffer.
@@ -365,14 +367,16 @@ static int i2o_exec_remove(struct device *dev)
365 367
366/** 368/**
367 * i2o_exec_lct_modified - Called on LCT NOTIFY reply 369 * i2o_exec_lct_modified - Called on LCT NOTIFY reply
368 * @c: I2O controller on which the LCT has modified 370 * @work: work struct for a specific controller
369 * 371 *
370 * This function handles asynchronus LCT NOTIFY replies. It parses the 372 * This function handles asynchronus LCT NOTIFY replies. It parses the
371 * new LCT and if the buffer for the LCT was to small sends a LCT NOTIFY 373 * new LCT and if the buffer for the LCT was to small sends a LCT NOTIFY
372 * again, otherwise send LCT NOTIFY to get informed on next LCT change. 374 * again, otherwise send LCT NOTIFY to get informed on next LCT change.
373 */ 375 */
374static void i2o_exec_lct_modified(struct i2o_exec_lct_notify_work *work) 376static void i2o_exec_lct_modified(struct work_struct *_work)
375{ 377{
378 struct i2o_exec_lct_notify_work *work =
379 container_of(_work, struct i2o_exec_lct_notify_work, work);
376 u32 change_ind = 0; 380 u32 change_ind = 0;
377 struct i2o_controller *c = work->c; 381 struct i2o_controller *c = work->c;
378 382
@@ -439,8 +443,7 @@ static int i2o_exec_reply(struct i2o_controller *c, u32 m,
439 443
440 work->c = c; 444 work->c = c;
441 445
442 INIT_WORK(&work->work, (void (*)(void *))i2o_exec_lct_modified, 446 INIT_WORK(&work->work, i2o_exec_lct_modified);
443 work);
444 queue_work(i2o_exec_driver.event_queue, &work->work); 447 queue_work(i2o_exec_driver.event_queue, &work->work);
445 return 1; 448 return 1;
446 } 449 }
@@ -460,13 +463,15 @@ static int i2o_exec_reply(struct i2o_controller *c, u32 m,
460 463
461/** 464/**
462 * i2o_exec_event - Event handling function 465 * i2o_exec_event - Event handling function
463 * @evt: Event which occurs 466 * @work: Work item in occurring event
464 * 467 *
465 * Handles events send by the Executive device. At the moment does not do 468 * Handles events send by the Executive device. At the moment does not do
466 * anything useful. 469 * anything useful.
467 */ 470 */
468static void i2o_exec_event(struct i2o_event *evt) 471static void i2o_exec_event(struct work_struct *work)
469{ 472{
473 struct i2o_event *evt = container_of(work, struct i2o_event, work);
474
470 if (likely(evt->i2o_dev)) 475 if (likely(evt->i2o_dev))
471 osm_debug("Event received from device: %d\n", 476 osm_debug("Event received from device: %d\n",
472 evt->i2o_dev->lct_data.tid); 477 evt->i2o_dev->lct_data.tid);
diff --git a/drivers/message/i2o/i2o_block.c b/drivers/message/i2o/i2o_block.c
index eaba81bf2eca..da9859f2caf2 100644
--- a/drivers/message/i2o/i2o_block.c
+++ b/drivers/message/i2o/i2o_block.c
@@ -259,7 +259,7 @@ static int i2o_block_device_unlock(struct i2o_device *dev, u32 media_id)
259/** 259/**
260 * i2o_block_device_power - Power management for device dev 260 * i2o_block_device_power - Power management for device dev
261 * @dev: I2O device which should receive the power management request 261 * @dev: I2O device which should receive the power management request
262 * @operation: Operation which should be send 262 * @op: Operation to send
263 * 263 *
264 * Send a power management request to the device dev. 264 * Send a power management request to the device dev.
265 * 265 *
@@ -315,7 +315,7 @@ static inline struct i2o_block_request *i2o_block_request_alloc(void)
315 * i2o_block_request_free - Frees a I2O block request 315 * i2o_block_request_free - Frees a I2O block request
316 * @ireq: I2O block request which should be freed 316 * @ireq: I2O block request which should be freed
317 * 317 *
318 * Fres the allocated memory (give it back to the request mempool). 318 * Frees the allocated memory (give it back to the request mempool).
319 */ 319 */
320static inline void i2o_block_request_free(struct i2o_block_request *ireq) 320static inline void i2o_block_request_free(struct i2o_block_request *ireq)
321{ 321{
@@ -326,6 +326,7 @@ static inline void i2o_block_request_free(struct i2o_block_request *ireq)
326 * i2o_block_sglist_alloc - Allocate the SG list and map it 326 * i2o_block_sglist_alloc - Allocate the SG list and map it
327 * @c: I2O controller to which the request belongs 327 * @c: I2O controller to which the request belongs
328 * @ireq: I2O block request 328 * @ireq: I2O block request
329 * @mptr: message body pointer
329 * 330 *
330 * Builds the SG list and map it to be accessable by the controller. 331 * Builds the SG list and map it to be accessable by the controller.
331 * 332 *
@@ -419,16 +420,18 @@ static int i2o_block_prep_req_fn(struct request_queue *q, struct request *req)
419 420
420/** 421/**
421 * i2o_block_delayed_request_fn - delayed request queue function 422 * i2o_block_delayed_request_fn - delayed request queue function
422 * delayed_request: the delayed request with the queue to start 423 * @work: the delayed request with the queue to start
423 * 424 *
424 * If the request queue is stopped for a disk, and there is no open 425 * If the request queue is stopped for a disk, and there is no open
425 * request, a new event is created, which calls this function to start 426 * request, a new event is created, which calls this function to start
426 * the queue after I2O_BLOCK_REQUEST_TIME. Otherwise the queue will never 427 * the queue after I2O_BLOCK_REQUEST_TIME. Otherwise the queue will never
427 * be started again. 428 * be started again.
428 */ 429 */
429static void i2o_block_delayed_request_fn(void *delayed_request) 430static void i2o_block_delayed_request_fn(struct work_struct *work)
430{ 431{
431 struct i2o_block_delayed_request *dreq = delayed_request; 432 struct i2o_block_delayed_request *dreq =
433 container_of(work, struct i2o_block_delayed_request,
434 work.work);
432 struct request_queue *q = dreq->queue; 435 struct request_queue *q = dreq->queue;
433 unsigned long flags; 436 unsigned long flags;
434 437
@@ -488,7 +491,7 @@ static void i2o_block_end_request(struct request *req, int uptodate,
488 * i2o_block_reply - Block OSM reply handler. 491 * i2o_block_reply - Block OSM reply handler.
489 * @c: I2O controller from which the message arrives 492 * @c: I2O controller from which the message arrives
490 * @m: message id of reply 493 * @m: message id of reply
491 * qmsg: the actuall I2O message reply 494 * @msg: the actual I2O message reply
492 * 495 *
493 * This function gets all the message replies. 496 * This function gets all the message replies.
494 * 497 *
@@ -538,8 +541,9 @@ static int i2o_block_reply(struct i2o_controller *c, u32 m,
538 return 1; 541 return 1;
539}; 542};
540 543
541static void i2o_block_event(struct i2o_event *evt) 544static void i2o_block_event(struct work_struct *work)
542{ 545{
546 struct i2o_event *evt = container_of(work, struct i2o_event, work);
543 osm_debug("event received\n"); 547 osm_debug("event received\n");
544 kfree(evt); 548 kfree(evt);
545}; 549};
@@ -599,6 +603,8 @@ static void i2o_block_biosparam(unsigned long capacity, unsigned short *cyls,
599 603
600/** 604/**
601 * i2o_block_open - Open the block device 605 * i2o_block_open - Open the block device
606 * @inode: inode for block device being opened
607 * @file: file to open
602 * 608 *
603 * Power up the device, mount and lock the media. This function is called, 609 * Power up the device, mount and lock the media. This function is called,
604 * if the block device is opened for access. 610 * if the block device is opened for access.
@@ -626,6 +632,8 @@ static int i2o_block_open(struct inode *inode, struct file *file)
626 632
627/** 633/**
628 * i2o_block_release - Release the I2O block device 634 * i2o_block_release - Release the I2O block device
635 * @inode: inode for block device being released
636 * @file: file to close
629 * 637 *
630 * Unlock and unmount the media, and power down the device. Gets called if 638 * Unlock and unmount the media, and power down the device. Gets called if
631 * the block device is closed. 639 * the block device is closed.
@@ -672,6 +680,8 @@ static int i2o_block_getgeo(struct block_device *bdev, struct hd_geometry *geo)
672 680
673/** 681/**
674 * i2o_block_ioctl - Issue device specific ioctl calls. 682 * i2o_block_ioctl - Issue device specific ioctl calls.
683 * @inode: inode for block device ioctl
684 * @file: file for ioctl
675 * @cmd: ioctl command 685 * @cmd: ioctl command
676 * @arg: arg 686 * @arg: arg
677 * 687 *
@@ -899,7 +909,7 @@ static int i2o_block_transfer(struct request *req)
899 909
900/** 910/**
901 * i2o_block_request_fn - request queue handling function 911 * i2o_block_request_fn - request queue handling function
902 * q: request queue from which the request could be fetched 912 * @q: request queue from which the request could be fetched
903 * 913 *
904 * Takes the next request from the queue, transfers it and if no error 914 * Takes the next request from the queue, transfers it and if no error
905 * occurs dequeue it from the queue. On arrival of the reply the message 915 * occurs dequeue it from the queue. On arrival of the reply the message
@@ -938,8 +948,8 @@ static void i2o_block_request_fn(struct request_queue *q)
938 continue; 948 continue;
939 949
940 dreq->queue = q; 950 dreq->queue = q;
941 INIT_WORK(&dreq->work, i2o_block_delayed_request_fn, 951 INIT_DELAYED_WORK(&dreq->work,
942 dreq); 952 i2o_block_delayed_request_fn);
943 953
944 if (!queue_delayed_work(i2o_block_driver.event_queue, 954 if (!queue_delayed_work(i2o_block_driver.event_queue,
945 &dreq->work, 955 &dreq->work,
diff --git a/drivers/message/i2o/i2o_block.h b/drivers/message/i2o/i2o_block.h
index 4fdaa5bda412..67f921b4419b 100644
--- a/drivers/message/i2o/i2o_block.h
+++ b/drivers/message/i2o/i2o_block.h
@@ -64,7 +64,7 @@
64 64
65/* I2O Block OSM mempool struct */ 65/* I2O Block OSM mempool struct */
66struct i2o_block_mempool { 66struct i2o_block_mempool {
67 kmem_cache_t *slab; 67 struct kmem_cache *slab;
68 mempool_t *pool; 68 mempool_t *pool;
69}; 69};
70 70
@@ -96,7 +96,7 @@ struct i2o_block_request {
96 96
97/* I2O Block device delayed request */ 97/* I2O Block device delayed request */
98struct i2o_block_delayed_request { 98struct i2o_block_delayed_request {
99 struct work_struct work; 99 struct delayed_work work;
100 struct request_queue *queue; 100 struct request_queue *queue;
101}; 101};
102 102
diff --git a/drivers/message/i2o/i2o_config.c b/drivers/message/i2o/i2o_config.c
index 7d23e082bf26..1de30d711671 100644
--- a/drivers/message/i2o/i2o_config.c
+++ b/drivers/message/i2o/i2o_config.c
@@ -265,7 +265,11 @@ static int i2o_cfg_swdl(unsigned long arg)
265 return -ENOMEM; 265 return -ENOMEM;
266 } 266 }
267 267
268 __copy_from_user(buffer.virt, kxfer.buf, fragsize); 268 if (__copy_from_user(buffer.virt, kxfer.buf, fragsize)) {
269 i2o_msg_nop(c, msg);
270 i2o_dma_free(&c->pdev->dev, &buffer);
271 return -EFAULT;
272 }
269 273
270 msg->u.head[0] = cpu_to_le32(NINE_WORD_MSG_SIZE | SGL_OFFSET_7); 274 msg->u.head[0] = cpu_to_le32(NINE_WORD_MSG_SIZE | SGL_OFFSET_7);
271 msg->u.head[1] = 275 msg->u.head[1] =
@@ -516,7 +520,6 @@ static int i2o_cfg_evt_get(unsigned long arg, struct file *fp)
516 return 0; 520 return 0;
517} 521}
518 522
519#ifdef CONFIG_I2O_EXT_ADAPTEC
520#ifdef CONFIG_COMPAT 523#ifdef CONFIG_COMPAT
521static int i2o_cfg_passthru32(struct file *file, unsigned cmnd, 524static int i2o_cfg_passthru32(struct file *file, unsigned cmnd,
522 unsigned long arg) 525 unsigned long arg)
@@ -759,6 +762,7 @@ static long i2o_cfg_compat_ioctl(struct file *file, unsigned cmd,
759 762
760#endif 763#endif
761 764
765#ifdef CONFIG_I2O_EXT_ADAPTEC
762static int i2o_cfg_passthru(unsigned long arg) 766static int i2o_cfg_passthru(unsigned long arg)
763{ 767{
764 struct i2o_cmd_passthru __user *cmd = 768 struct i2o_cmd_passthru __user *cmd =
diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
index 3d2e76eea93e..a61cb17c5c12 100644
--- a/drivers/message/i2o/i2o_proc.c
+++ b/drivers/message/i2o/i2o_proc.c
@@ -163,7 +163,7 @@ static int print_serial_number(struct seq_file *seq, u8 * serialno, int max_len)
163 * i2o_get_class_name - do i2o class name lookup 163 * i2o_get_class_name - do i2o class name lookup
164 * @class: class number 164 * @class: class number
165 * 165 *
166 * Return a descriptive string for an i2o class 166 * Return a descriptive string for an i2o class.
167 */ 167 */
168static const char *i2o_get_class_name(int class) 168static const char *i2o_get_class_name(int class)
169{ 169{
diff --git a/drivers/message/i2o/i2o_scsi.c b/drivers/message/i2o/i2o_scsi.c
index 6ebf38213f9f..1045c8a518bb 100644
--- a/drivers/message/i2o/i2o_scsi.c
+++ b/drivers/message/i2o/i2o_scsi.c
@@ -220,7 +220,7 @@ static int i2o_scsi_probe(struct device *dev)
220 u32 id = -1; 220 u32 id = -1;
221 u64 lun = -1; 221 u64 lun = -1;
222 int channel = -1; 222 int channel = -1;
223 int i; 223 int i, rc;
224 224
225 i2o_shost = i2o_scsi_get_host(c); 225 i2o_shost = i2o_scsi_get_host(c);
226 if (!i2o_shost) 226 if (!i2o_shost)
@@ -304,14 +304,20 @@ static int i2o_scsi_probe(struct device *dev)
304 return PTR_ERR(scsi_dev); 304 return PTR_ERR(scsi_dev);
305 } 305 }
306 306
307 sysfs_create_link(&i2o_dev->device.kobj, &scsi_dev->sdev_gendev.kobj, 307 rc = sysfs_create_link(&i2o_dev->device.kobj,
308 "scsi"); 308 &scsi_dev->sdev_gendev.kobj, "scsi");
309 if (rc)
310 goto err;
309 311
310 osm_info("device added (TID: %03x) channel: %d, id: %d, lun: %ld\n", 312 osm_info("device added (TID: %03x) channel: %d, id: %d, lun: %ld\n",
311 i2o_dev->lct_data.tid, channel, le32_to_cpu(id), 313 i2o_dev->lct_data.tid, channel, le32_to_cpu(id),
312 (long unsigned int)le64_to_cpu(lun)); 314 (long unsigned int)le64_to_cpu(lun));
313 315
314 return 0; 316 return 0;
317
318err:
319 scsi_remove_device(scsi_dev);
320 return rc;
315}; 321};
316 322
317static const char *i2o_scsi_info(struct Scsi_Host *SChost) 323static const char *i2o_scsi_info(struct Scsi_Host *SChost)
@@ -405,8 +411,7 @@ static void i2o_scsi_notify_device_add(struct i2o_device *i2o_dev)
405}; 411};
406 412
407/** 413/**
408 * i2o_scsi_notify_device_remove - Retrieve notifications of removed 414 * i2o_scsi_notify_device_remove - Retrieve notifications of removed devices
409 * devices
410 * @i2o_dev: the I2O device which was removed 415 * @i2o_dev: the I2O device which was removed
411 * 416 *
412 * If a I2O device is removed, we catch the notification to remove the 417 * If a I2O device is removed, we catch the notification to remove the
@@ -426,8 +431,7 @@ static void i2o_scsi_notify_device_remove(struct i2o_device *i2o_dev)
426}; 431};
427 432
428/** 433/**
429 * i2o_scsi_notify_controller_add - Retrieve notifications of added 434 * i2o_scsi_notify_controller_add - Retrieve notifications of added controllers
430 * controllers
431 * @c: the controller which was added 435 * @c: the controller which was added
432 * 436 *
433 * If a I2O controller is added, we catch the notification to add a 437 * If a I2O controller is added, we catch the notification to add a
@@ -457,8 +461,7 @@ static void i2o_scsi_notify_controller_add(struct i2o_controller *c)
457}; 461};
458 462
459/** 463/**
460 * i2o_scsi_notify_controller_remove - Retrieve notifications of removed 464 * i2o_scsi_notify_controller_remove - Retrieve notifications of removed controllers
461 * controllers
462 * @c: the controller which was removed 465 * @c: the controller which was removed
463 * 466 *
464 * If a I2O controller is removed, we catch the notification to remove the 467 * If a I2O controller is removed, we catch the notification to remove the
@@ -745,7 +748,7 @@ static int i2o_scsi_abort(struct scsi_cmnd *SCpnt)
745 * @capacity: size in sectors 748 * @capacity: size in sectors
746 * @ip: geometry array 749 * @ip: geometry array
747 * 750 *
748 * This is anyones guess quite frankly. We use the same rules everyone 751 * This is anyone's guess quite frankly. We use the same rules everyone
749 * else appears to and hope. It seems to work. 752 * else appears to and hope. It seems to work.
750 */ 753 */
751 754
diff --git a/drivers/message/i2o/pci.c b/drivers/message/i2o/pci.c
index 62f1ac08332c..3661e6e065d2 100644
--- a/drivers/message/i2o/pci.c
+++ b/drivers/message/i2o/pci.c
@@ -259,6 +259,7 @@ static irqreturn_t i2o_pci_interrupt(int irq, void *dev_id)
259 259
260/** 260/**
261 * i2o_pci_irq_enable - Allocate interrupt for I2O controller 261 * i2o_pci_irq_enable - Allocate interrupt for I2O controller
262 * @c: i2o_controller that the request is for
262 * 263 *
263 * Allocate an interrupt for the I2O controller, and activate interrupts 264 * Allocate an interrupt for the I2O controller, and activate interrupts
264 * on the I2O controller. 265 * on the I2O controller.
@@ -305,7 +306,7 @@ static void i2o_pci_irq_disable(struct i2o_controller *c)
305 306
306/** 307/**
307 * i2o_pci_probe - Probe the PCI device for an I2O controller 308 * i2o_pci_probe - Probe the PCI device for an I2O controller
308 * @dev: PCI device to test 309 * @pdev: PCI device to test
309 * @id: id which matched with the PCI device id table 310 * @id: id which matched with the PCI device id table
310 * 311 *
311 * Probe the PCI device for any device which is a memory of the 312 * Probe the PCI device for any device which is a memory of the
@@ -320,7 +321,6 @@ static int __devinit i2o_pci_probe(struct pci_dev *pdev,
320 struct i2o_controller *c; 321 struct i2o_controller *c;
321 int rc; 322 int rc;
322 struct pci_dev *i960 = NULL; 323 struct pci_dev *i960 = NULL;
323 int enabled = pdev->is_enabled;
324 324
325 printk(KERN_INFO "i2o: Checking for PCI I2O controllers...\n"); 325 printk(KERN_INFO "i2o: Checking for PCI I2O controllers...\n");
326 326
@@ -330,12 +330,11 @@ static int __devinit i2o_pci_probe(struct pci_dev *pdev,
330 return -ENODEV; 330 return -ENODEV;
331 } 331 }
332 332
333 if (!enabled) 333 if ((rc = pci_enable_device(pdev))) {
334 if ((rc = pci_enable_device(pdev))) { 334 printk(KERN_WARNING "i2o: couldn't enable device %s\n",
335 printk(KERN_WARNING "i2o: couldn't enable device %s\n", 335 pci_name(pdev));
336 pci_name(pdev)); 336 return rc;
337 return rc; 337 }
338 }
339 338
340 if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) { 339 if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) {
341 printk(KERN_WARNING "i2o: no suitable DMA found for %s\n", 340 printk(KERN_WARNING "i2o: no suitable DMA found for %s\n",
@@ -442,15 +441,14 @@ static int __devinit i2o_pci_probe(struct pci_dev *pdev,
442 i2o_iop_free(c); 441 i2o_iop_free(c);
443 442
444 disable: 443 disable:
445 if (!enabled) 444 pci_disable_device(pdev);
446 pci_disable_device(pdev);
447 445
448 return rc; 446 return rc;
449} 447}
450 448
451/** 449/**
452 * i2o_pci_remove - Removes a I2O controller from the system 450 * i2o_pci_remove - Removes a I2O controller from the system
453 * pdev: I2O controller which should be removed 451 * @pdev: I2O controller which should be removed
454 * 452 *
455 * Reset the I2O controller, disable interrupts and remove all allocated 453 * Reset the I2O controller, disable interrupts and remove all allocated
456 * resources. 454 * resources.
diff --git a/drivers/mfd/ucb1x00-ts.c b/drivers/mfd/ucb1x00-ts.c
index 82938ad6ddbd..ce1a48108210 100644
--- a/drivers/mfd/ucb1x00-ts.c
+++ b/drivers/mfd/ucb1x00-ts.c
@@ -28,7 +28,7 @@
28#include <linux/string.h> 28#include <linux/string.h>
29#include <linux/input.h> 29#include <linux/input.h>
30#include <linux/device.h> 30#include <linux/device.h>
31#include <linux/suspend.h> 31#include <linux/freezer.h>
32#include <linux/slab.h> 32#include <linux/slab.h>
33#include <linux/kthread.h> 33#include <linux/kthread.h>
34 34
diff --git a/drivers/misc/lkdtm.c b/drivers/misc/lkdtm.c
index 46a9c35943bd..db9d7df75ae0 100644
--- a/drivers/misc/lkdtm.c
+++ b/drivers/misc/lkdtm.c
@@ -157,8 +157,8 @@ void jp_ll_rw_block(int rw, int nr, struct buffer_head *bhs[])
157 157
158struct scan_control; 158struct scan_control;
159 159
160unsigned long jp_shrink_page_list(struct list_head *page_list, 160unsigned long jp_shrink_inactive_list(unsigned long max_scan,
161 struct scan_control *sc) 161 struct zone *zone, struct scan_control *sc)
162{ 162{
163 lkdtm_handler(); 163 lkdtm_handler();
164 jprobe_return(); 164 jprobe_return();
@@ -297,8 +297,8 @@ int lkdtm_module_init(void)
297 lkdtm.entry = (kprobe_opcode_t*) jp_ll_rw_block; 297 lkdtm.entry = (kprobe_opcode_t*) jp_ll_rw_block;
298 break; 298 break;
299 case MEM_SWAPOUT: 299 case MEM_SWAPOUT:
300 lkdtm.kp.symbol_name = "shrink_page_list"; 300 lkdtm.kp.symbol_name = "shrink_inactive_list";
301 lkdtm.entry = (kprobe_opcode_t*) jp_shrink_page_list; 301 lkdtm.entry = (kprobe_opcode_t*) jp_shrink_inactive_list;
302 break; 302 break;
303 case TIMERADD: 303 case TIMERADD:
304 lkdtm.kp.symbol_name = "hrtimer_start"; 304 lkdtm.kp.symbol_name = "hrtimer_start";
diff --git a/drivers/misc/tifm_7xx1.c b/drivers/misc/tifm_7xx1.c
index 1ba8754e9383..2ab7add78f94 100644
--- a/drivers/misc/tifm_7xx1.c
+++ b/drivers/misc/tifm_7xx1.c
@@ -33,9 +33,10 @@ static void tifm_7xx1_eject(struct tifm_adapter *fm, struct tifm_dev *sock)
33 spin_unlock_irqrestore(&fm->lock, flags); 33 spin_unlock_irqrestore(&fm->lock, flags);
34} 34}
35 35
36static void tifm_7xx1_remove_media(void *adapter) 36static void tifm_7xx1_remove_media(struct work_struct *work)
37{ 37{
38 struct tifm_adapter *fm = adapter; 38 struct tifm_adapter *fm =
39 container_of(work, struct tifm_adapter, media_remover);
39 unsigned long flags; 40 unsigned long flags;
40 int cnt; 41 int cnt;
41 struct tifm_dev *sock; 42 struct tifm_dev *sock;
@@ -169,9 +170,10 @@ tifm_7xx1_sock_addr(char __iomem *base_addr, unsigned int sock_num)
169 return base_addr + ((sock_num + 1) << 10); 170 return base_addr + ((sock_num + 1) << 10);
170} 171}
171 172
172static void tifm_7xx1_insert_media(void *adapter) 173static void tifm_7xx1_insert_media(struct work_struct *work)
173{ 174{
174 struct tifm_adapter *fm = adapter; 175 struct tifm_adapter *fm =
176 container_of(work, struct tifm_adapter, media_inserter);
175 unsigned long flags; 177 unsigned long flags;
176 tifm_media_id media_id; 178 tifm_media_id media_id;
177 char *card_name = "xx"; 179 char *card_name = "xx";
@@ -261,7 +263,7 @@ static int tifm_7xx1_suspend(struct pci_dev *dev, pm_message_t state)
261 spin_unlock_irqrestore(&fm->lock, flags); 263 spin_unlock_irqrestore(&fm->lock, flags);
262 flush_workqueue(fm->wq); 264 flush_workqueue(fm->wq);
263 265
264 tifm_7xx1_remove_media(fm); 266 tifm_7xx1_remove_media(&fm->media_remover);
265 267
266 pci_set_power_state(dev, PCI_D3hot); 268 pci_set_power_state(dev, PCI_D3hot);
267 pci_disable_device(dev); 269 pci_disable_device(dev);
@@ -328,8 +330,8 @@ static int tifm_7xx1_probe(struct pci_dev *dev,
328 if (!fm->sockets) 330 if (!fm->sockets)
329 goto err_out_free; 331 goto err_out_free;
330 332
331 INIT_WORK(&fm->media_inserter, tifm_7xx1_insert_media, fm); 333 INIT_WORK(&fm->media_inserter, tifm_7xx1_insert_media);
332 INIT_WORK(&fm->media_remover, tifm_7xx1_remove_media, fm); 334 INIT_WORK(&fm->media_remover, tifm_7xx1_remove_media);
333 fm->eject = tifm_7xx1_eject; 335 fm->eject = tifm_7xx1_eject;
334 pci_set_drvdata(dev, fm); 336 pci_set_drvdata(dev, fm);
335 337
@@ -384,7 +386,7 @@ static void tifm_7xx1_remove(struct pci_dev *dev)
384 386
385 flush_workqueue(fm->wq); 387 flush_workqueue(fm->wq);
386 388
387 tifm_7xx1_remove_media(fm); 389 tifm_7xx1_remove_media(&fm->media_remover);
388 390
389 writel(TIFM_IRQ_SETALL, fm->addr + FM_CLEAR_INTERRUPT_ENABLE); 391 writel(TIFM_IRQ_SETALL, fm->addr + FM_CLEAR_INTERRUPT_ENABLE);
390 free_irq(dev->irq, fm); 392 free_irq(dev->irq, fm);
diff --git a/drivers/misc/tifm_core.c b/drivers/misc/tifm_core.c
index ee326136d03b..d61df5c3ac36 100644
--- a/drivers/misc/tifm_core.c
+++ b/drivers/misc/tifm_core.c
@@ -219,8 +219,9 @@ static int tifm_device_remove(struct device *dev)
219 struct tifm_driver *drv = fm_dev->drv; 219 struct tifm_driver *drv = fm_dev->drv;
220 220
221 if (drv) { 221 if (drv) {
222 if (drv->remove) drv->remove(fm_dev); 222 if (drv->remove)
223 fm_dev->drv = 0; 223 drv->remove(fm_dev);
224 fm_dev->drv = NULL;
224 } 225 }
225 226
226 put_device(dev); 227 put_device(dev);
diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index ea41852ec8cd..4224686fdf2a 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -40,7 +40,7 @@ config MMC_ARMMMCI
40 If unsure, say N. 40 If unsure, say N.
41 41
42config MMC_PXA 42config MMC_PXA
43 tristate "Intel PXA255 Multimedia Card Interface support" 43 tristate "Intel PXA25x/26x/27x Multimedia Card Interface support"
44 depends on ARCH_PXA && MMC 44 depends on ARCH_PXA && MMC
45 help 45 help
46 This selects the Intel(R) PXA(R) Multimedia card Interface. 46 This selects the Intel(R) PXA(R) Multimedia card Interface.
@@ -91,11 +91,11 @@ config MMC_AU1X
91 91
92 If unsure, say N. 92 If unsure, say N.
93 93
94config MMC_AT91RM9200 94config MMC_AT91
95 tristate "AT91RM9200 SD/MMC Card Interface support" 95 tristate "AT91 SD/MMC Card Interface support"
96 depends on ARCH_AT91RM9200 && MMC 96 depends on ARCH_AT91 && MMC
97 help 97 help
98 This selects the AT91RM9200 MCI controller. 98 This selects the AT91 MCI controller.
99 99
100 If unsure, say N. 100 If unsure, say N.
101 101
diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile
index acfd4de0aba5..83ffb9326a54 100644
--- a/drivers/mmc/Makefile
+++ b/drivers/mmc/Makefile
@@ -22,7 +22,7 @@ obj-$(CONFIG_MMC_SDHCI) += sdhci.o
22obj-$(CONFIG_MMC_WBSD) += wbsd.o 22obj-$(CONFIG_MMC_WBSD) += wbsd.o
23obj-$(CONFIG_MMC_AU1X) += au1xmmc.o 23obj-$(CONFIG_MMC_AU1X) += au1xmmc.o
24obj-$(CONFIG_MMC_OMAP) += omap.o 24obj-$(CONFIG_MMC_OMAP) += omap.o
25obj-$(CONFIG_MMC_AT91RM9200) += at91_mci.o 25obj-$(CONFIG_MMC_AT91) += at91_mci.o
26obj-$(CONFIG_MMC_TIFM_SD) += tifm_sd.o 26obj-$(CONFIG_MMC_TIFM_SD) += tifm_sd.o
27 27
28mmc_core-y := mmc.o mmc_sysfs.o 28mmc_core-y := mmc.o mmc_sysfs.o
diff --git a/drivers/mmc/at91_mci.c b/drivers/mmc/at91_mci.c
index 494b23fb0a01..4633dbc9a90f 100644
--- a/drivers/mmc/at91_mci.c
+++ b/drivers/mmc/at91_mci.c
@@ -73,8 +73,8 @@
73#include <asm/mach/mmc.h> 73#include <asm/mach/mmc.h>
74#include <asm/arch/board.h> 74#include <asm/arch/board.h>
75#include <asm/arch/gpio.h> 75#include <asm/arch/gpio.h>
76#include <asm/arch/at91rm9200_mci.h> 76#include <asm/arch/at91_mci.h>
77#include <asm/arch/at91rm9200_pdc.h> 77#include <asm/arch/at91_pdc.h>
78 78
79#define DRIVER_NAME "at91_mci" 79#define DRIVER_NAME "at91_mci"
80 80
@@ -793,7 +793,7 @@ int at91_mci_get_ro(struct mmc_host *mmc)
793 return read_only; 793 return read_only;
794} 794}
795 795
796static struct mmc_host_ops at91_mci_ops = { 796static const struct mmc_host_ops at91_mci_ops = {
797 .request = at91_mci_request, 797 .request = at91_mci_request,
798 .set_ios = at91_mci_set_ios, 798 .set_ios = at91_mci_set_ios,
799 .get_ro = at91_mci_get_ro, 799 .get_ro = at91_mci_get_ro,
diff --git a/drivers/mmc/au1xmmc.c b/drivers/mmc/au1xmmc.c
index 53ffcbb14a97..447fba5825fd 100644
--- a/drivers/mmc/au1xmmc.c
+++ b/drivers/mmc/au1xmmc.c
@@ -875,7 +875,7 @@ static void au1xmmc_init_dma(struct au1xmmc_host *host)
875 host->rx_chan = rxchan; 875 host->rx_chan = rxchan;
876} 876}
877 877
878struct mmc_host_ops au1xmmc_ops = { 878struct const mmc_host_ops au1xmmc_ops = {
879 .request = au1xmmc_request, 879 .request = au1xmmc_request,
880 .set_ios = au1xmmc_set_ios, 880 .set_ios = au1xmmc_set_ios,
881}; 881};
diff --git a/drivers/mmc/imxmmc.c b/drivers/mmc/imxmmc.c
index 659d4a822cc5..06e7fcd19221 100644
--- a/drivers/mmc/imxmmc.c
+++ b/drivers/mmc/imxmmc.c
@@ -877,7 +877,7 @@ static void imxmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
877 } 877 }
878} 878}
879 879
880static struct mmc_host_ops imxmci_ops = { 880static const struct mmc_host_ops imxmci_ops = {
881 .request = imxmci_request, 881 .request = imxmci_request,
882 .set_ios = imxmci_set_ios, 882 .set_ios = imxmci_set_ios,
883}; 883};
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index ee8863c123e3..6f2a282e2b97 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -4,6 +4,7 @@
4 * Copyright (C) 2003-2004 Russell King, All Rights Reserved. 4 * Copyright (C) 2003-2004 Russell King, All Rights Reserved.
5 * SD support Copyright (C) 2004 Ian Molton, All Rights Reserved. 5 * SD support Copyright (C) 2004 Ian Molton, All Rights Reserved.
6 * SD support Copyright (C) 2005 Pierre Ossman, All Rights Reserved. 6 * SD support Copyright (C) 2005 Pierre Ossman, All Rights Reserved.
7 * MMCv4 support Copyright (C) 2006 Philip Langdale, All Rights Reserved.
7 * 8 *
8 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as 10 * it under the terms of the GNU General Public License version 2 as
@@ -396,23 +397,23 @@ static int mmc_select_card(struct mmc_host *host, struct mmc_card *card)
396 return err; 397 return err;
397 398
398 /* 399 /*
399 * Default bus width is 1 bit. 400 * We can only change the bus width of SD cards when
400 */ 401 * they are selected so we have to put the handling
401 host->ios.bus_width = MMC_BUS_WIDTH_1;
402
403 /*
404 * We can only change the bus width of the selected
405 * card so therefore we have to put the handling
406 * here. 402 * here.
403 *
404 * The card is in 1 bit mode by default so
405 * we only need to change if it supports the
406 * wider version.
407 */ 407 */
408 if (host->caps & MMC_CAP_4_BIT_DATA) { 408 if (mmc_card_sd(card) &&
409 (card->scr.bus_widths & SD_SCR_BUS_WIDTH_4)) {
410
409 /* 411 /*
410 * The card is in 1 bit mode by default so 412 * Default bus width is 1 bit.
411 * we only need to change if it supports the 413 */
412 * wider version. 414 host->ios.bus_width = MMC_BUS_WIDTH_1;
413 */ 415
414 if (mmc_card_sd(card) && 416 if (host->caps & MMC_CAP_4_BIT_DATA) {
415 (card->scr.bus_widths & SD_SCR_BUS_WIDTH_4)) {
416 struct mmc_command cmd; 417 struct mmc_command cmd;
417 cmd.opcode = SD_APP_SET_BUS_WIDTH; 418 cmd.opcode = SD_APP_SET_BUS_WIDTH;
418 cmd.arg = SD_BUS_WIDTH_4; 419 cmd.arg = SD_BUS_WIDTH_4;
@@ -453,11 +454,11 @@ static void mmc_deselect_cards(struct mmc_host *host)
453 454
454static inline void mmc_delay(unsigned int ms) 455static inline void mmc_delay(unsigned int ms)
455{ 456{
456 if (ms < HZ / 1000) { 457 if (ms < 1000 / HZ) {
457 yield(); 458 cond_resched();
458 mdelay(ms); 459 mdelay(ms);
459 } else { 460 } else {
460 msleep_interruptible (ms); 461 msleep(ms);
461 } 462 }
462} 463}
463 464
@@ -475,7 +476,7 @@ static u32 mmc_select_voltage(struct mmc_host *host, u32 ocr)
475 if (bit) { 476 if (bit) {
476 bit -= 1; 477 bit -= 1;
477 478
478 ocr = 3 << bit; 479 ocr &= 3 << bit;
479 480
480 host->ios.vdd = bit; 481 host->ios.vdd = bit;
481 mmc_set_ios(host); 482 mmc_set_ios(host);
@@ -953,6 +954,137 @@ static void mmc_read_csds(struct mmc_host *host)
953 } 954 }
954} 955}
955 956
957static void mmc_process_ext_csds(struct mmc_host *host)
958{
959 int err;
960 struct mmc_card *card;
961
962 struct mmc_request mrq;
963 struct mmc_command cmd;
964 struct mmc_data data;
965
966 struct scatterlist sg;
967
968 /*
969 * As the ext_csd is so large and mostly unused, we don't store the
970 * raw block in mmc_card.
971 */
972 u8 *ext_csd;
973 ext_csd = kmalloc(512, GFP_KERNEL);
974 if (!ext_csd) {
975 printk("%s: could not allocate a buffer to receive the ext_csd."
976 "mmc v4 cards will be treated as v3.\n",
977 mmc_hostname(host));
978 return;
979 }
980
981 list_for_each_entry(card, &host->cards, node) {
982 if (card->state & (MMC_STATE_DEAD|MMC_STATE_PRESENT))
983 continue;
984 if (mmc_card_sd(card))
985 continue;
986 if (card->csd.mmca_vsn < CSD_SPEC_VER_4)
987 continue;
988
989 err = mmc_select_card(host, card);
990 if (err != MMC_ERR_NONE) {
991 mmc_card_set_dead(card);
992 continue;
993 }
994
995 memset(&cmd, 0, sizeof(struct mmc_command));
996
997 cmd.opcode = MMC_SEND_EXT_CSD;
998 cmd.arg = 0;
999 cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC;
1000
1001 memset(&data, 0, sizeof(struct mmc_data));
1002
1003 mmc_set_data_timeout(&data, card, 0);
1004
1005 data.blksz = 512;
1006 data.blocks = 1;
1007 data.flags = MMC_DATA_READ;
1008 data.sg = &sg;
1009 data.sg_len = 1;
1010
1011 memset(&mrq, 0, sizeof(struct mmc_request));
1012
1013 mrq.cmd = &cmd;
1014 mrq.data = &data;
1015
1016 sg_init_one(&sg, ext_csd, 512);
1017
1018 mmc_wait_for_req(host, &mrq);
1019
1020 if (cmd.error != MMC_ERR_NONE || data.error != MMC_ERR_NONE) {
1021 mmc_card_set_dead(card);
1022 continue;
1023 }
1024
1025 switch (ext_csd[EXT_CSD_CARD_TYPE]) {
1026 case EXT_CSD_CARD_TYPE_52 | EXT_CSD_CARD_TYPE_26:
1027 card->ext_csd.hs_max_dtr = 52000000;
1028 break;
1029 case EXT_CSD_CARD_TYPE_26:
1030 card->ext_csd.hs_max_dtr = 26000000;
1031 break;
1032 default:
1033 /* MMC v4 spec says this cannot happen */
1034 printk("%s: card is mmc v4 but doesn't support "
1035 "any high-speed modes.\n",
1036 mmc_hostname(card->host));
1037 mmc_card_set_bad(card);
1038 continue;
1039 }
1040
1041 /* Activate highspeed support. */
1042 cmd.opcode = MMC_SWITCH;
1043 cmd.arg = (MMC_SWITCH_MODE_WRITE_BYTE << 24) |
1044 (EXT_CSD_HS_TIMING << 16) |
1045 (1 << 8) |
1046 EXT_CSD_CMD_SET_NORMAL;
1047 cmd.flags = MMC_RSP_R1B | MMC_CMD_AC;
1048
1049 err = mmc_wait_for_cmd(host, &cmd, CMD_RETRIES);
1050 if (err != MMC_ERR_NONE) {
1051 printk("%s: failed to switch card to mmc v4 "
1052 "high-speed mode.\n",
1053 mmc_hostname(card->host));
1054 continue;
1055 }
1056
1057 mmc_card_set_highspeed(card);
1058
1059 /* Check for host support for wide-bus modes. */
1060 if (!(host->caps & MMC_CAP_4_BIT_DATA)) {
1061 continue;
1062 }
1063
1064 /* Activate 4-bit support. */
1065 cmd.opcode = MMC_SWITCH;
1066 cmd.arg = (MMC_SWITCH_MODE_WRITE_BYTE << 24) |
1067 (EXT_CSD_BUS_WIDTH << 16) |
1068 (EXT_CSD_BUS_WIDTH_4 << 8) |
1069 EXT_CSD_CMD_SET_NORMAL;
1070 cmd.flags = MMC_RSP_R1B | MMC_CMD_AC;
1071
1072 err = mmc_wait_for_cmd(host, &cmd, CMD_RETRIES);
1073 if (err != MMC_ERR_NONE) {
1074 printk("%s: failed to switch card to "
1075 "mmc v4 4-bit bus mode.\n",
1076 mmc_hostname(card->host));
1077 continue;
1078 }
1079
1080 host->ios.bus_width = MMC_BUS_WIDTH_4;
1081 }
1082
1083 kfree(ext_csd);
1084
1085 mmc_deselect_cards(host);
1086}
1087
956static void mmc_read_scrs(struct mmc_host *host) 1088static void mmc_read_scrs(struct mmc_host *host)
957{ 1089{
958 int err; 1090 int err;
@@ -1025,14 +1157,133 @@ static void mmc_read_scrs(struct mmc_host *host)
1025 mmc_deselect_cards(host); 1157 mmc_deselect_cards(host);
1026} 1158}
1027 1159
1160static void mmc_read_switch_caps(struct mmc_host *host)
1161{
1162 int err;
1163 struct mmc_card *card;
1164 struct mmc_request mrq;
1165 struct mmc_command cmd;
1166 struct mmc_data data;
1167 unsigned char *status;
1168 struct scatterlist sg;
1169
1170 status = kmalloc(64, GFP_KERNEL);
1171 if (!status) {
1172 printk(KERN_WARNING "%s: Unable to allocate buffer for "
1173 "reading switch capabilities.\n",
1174 mmc_hostname(host));
1175 return;
1176 }
1177
1178 list_for_each_entry(card, &host->cards, node) {
1179 if (card->state & (MMC_STATE_DEAD|MMC_STATE_PRESENT))
1180 continue;
1181 if (!mmc_card_sd(card))
1182 continue;
1183 if (card->scr.sda_vsn < SCR_SPEC_VER_1)
1184 continue;
1185
1186 err = mmc_select_card(host, card);
1187 if (err != MMC_ERR_NONE) {
1188 mmc_card_set_dead(card);
1189 continue;
1190 }
1191
1192 memset(&cmd, 0, sizeof(struct mmc_command));
1193
1194 cmd.opcode = SD_SWITCH;
1195 cmd.arg = 0x00FFFFF1;
1196 cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC;
1197
1198 memset(&data, 0, sizeof(struct mmc_data));
1199
1200 mmc_set_data_timeout(&data, card, 0);
1201
1202 data.blksz = 64;
1203 data.blocks = 1;
1204 data.flags = MMC_DATA_READ;
1205 data.sg = &sg;
1206 data.sg_len = 1;
1207
1208 memset(&mrq, 0, sizeof(struct mmc_request));
1209
1210 mrq.cmd = &cmd;
1211 mrq.data = &data;
1212
1213 sg_init_one(&sg, status, 64);
1214
1215 mmc_wait_for_req(host, &mrq);
1216
1217 if (cmd.error != MMC_ERR_NONE || data.error != MMC_ERR_NONE) {
1218 mmc_card_set_dead(card);
1219 continue;
1220 }
1221
1222 if (status[13] & 0x02)
1223 card->sw_caps.hs_max_dtr = 50000000;
1224
1225 memset(&cmd, 0, sizeof(struct mmc_command));
1226
1227 cmd.opcode = SD_SWITCH;
1228 cmd.arg = 0x80FFFFF1;
1229 cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC;
1230
1231 memset(&data, 0, sizeof(struct mmc_data));
1232
1233 mmc_set_data_timeout(&data, card, 0);
1234
1235 data.blksz = 64;
1236 data.blocks = 1;
1237 data.flags = MMC_DATA_READ;
1238 data.sg = &sg;
1239 data.sg_len = 1;
1240
1241 memset(&mrq, 0, sizeof(struct mmc_request));
1242
1243 mrq.cmd = &cmd;
1244 mrq.data = &data;
1245
1246 sg_init_one(&sg, status, 64);
1247
1248 mmc_wait_for_req(host, &mrq);
1249
1250 if (cmd.error != MMC_ERR_NONE || data.error != MMC_ERR_NONE) {
1251 mmc_card_set_dead(card);
1252 continue;
1253 }
1254
1255 if ((status[16] & 0xF) != 1) {
1256 printk(KERN_WARNING "%s: Problem switching card "
1257 "into high-speed mode!\n",
1258 mmc_hostname(host));
1259 continue;
1260 }
1261
1262 mmc_card_set_highspeed(card);
1263 }
1264
1265 kfree(status);
1266
1267 mmc_deselect_cards(host);
1268}
1269
1028static unsigned int mmc_calculate_clock(struct mmc_host *host) 1270static unsigned int mmc_calculate_clock(struct mmc_host *host)
1029{ 1271{
1030 struct mmc_card *card; 1272 struct mmc_card *card;
1031 unsigned int max_dtr = host->f_max; 1273 unsigned int max_dtr = host->f_max;
1032 1274
1033 list_for_each_entry(card, &host->cards, node) 1275 list_for_each_entry(card, &host->cards, node)
1034 if (!mmc_card_dead(card) && max_dtr > card->csd.max_dtr) 1276 if (!mmc_card_dead(card)) {
1035 max_dtr = card->csd.max_dtr; 1277 if (mmc_card_highspeed(card) && mmc_card_sd(card)) {
1278 if (max_dtr > card->sw_caps.hs_max_dtr)
1279 max_dtr = card->sw_caps.hs_max_dtr;
1280 } else if (mmc_card_highspeed(card) && !mmc_card_sd(card)) {
1281 if (max_dtr > card->ext_csd.hs_max_dtr)
1282 max_dtr = card->ext_csd.hs_max_dtr;
1283 } else if (max_dtr > card->csd.max_dtr) {
1284 max_dtr = card->csd.max_dtr;
1285 }
1286 }
1036 1287
1037 pr_debug("%s: selected %d.%03dMHz transfer rate\n", 1288 pr_debug("%s: selected %d.%03dMHz transfer rate\n",
1038 mmc_hostname(host), 1289 mmc_hostname(host),
@@ -1150,8 +1401,11 @@ static void mmc_setup(struct mmc_host *host)
1150 1401
1151 mmc_read_csds(host); 1402 mmc_read_csds(host);
1152 1403
1153 if (host->mode == MMC_MODE_SD) 1404 if (host->mode == MMC_MODE_SD) {
1154 mmc_read_scrs(host); 1405 mmc_read_scrs(host);
1406 mmc_read_switch_caps(host);
1407 } else
1408 mmc_process_ext_csds(host);
1155} 1409}
1156 1410
1157 1411
@@ -1165,27 +1419,40 @@ static void mmc_setup(struct mmc_host *host)
1165 */ 1419 */
1166void mmc_detect_change(struct mmc_host *host, unsigned long delay) 1420void mmc_detect_change(struct mmc_host *host, unsigned long delay)
1167{ 1421{
1168 if (delay) 1422 mmc_schedule_delayed_work(&host->detect, delay);
1169 mmc_schedule_delayed_work(&host->detect, delay);
1170 else
1171 mmc_schedule_work(&host->detect);
1172} 1423}
1173 1424
1174EXPORT_SYMBOL(mmc_detect_change); 1425EXPORT_SYMBOL(mmc_detect_change);
1175 1426
1176 1427
1177static void mmc_rescan(void *data) 1428static void mmc_rescan(struct work_struct *work)
1178{ 1429{
1179 struct mmc_host *host = data; 1430 struct mmc_host *host =
1431 container_of(work, struct mmc_host, detect.work);
1180 struct list_head *l, *n; 1432 struct list_head *l, *n;
1433 unsigned char power_mode;
1181 1434
1182 mmc_claim_host(host); 1435 mmc_claim_host(host);
1183 1436
1184 if (host->ios.power_mode == MMC_POWER_ON) 1437 /*
1438 * Check for removed cards and newly inserted ones. We check for
1439 * removed cards first so we can intelligently re-select the VDD.
1440 */
1441 power_mode = host->ios.power_mode;
1442 if (power_mode == MMC_POWER_ON)
1185 mmc_check_cards(host); 1443 mmc_check_cards(host);
1186 1444
1187 mmc_setup(host); 1445 mmc_setup(host);
1188 1446
1447 /*
1448 * Some broken cards process CMD1 even in stand-by state. There is
1449 * no reply, but an ILLEGAL_COMMAND error is cached and returned
1450 * after next command. We poll for card status here to clear any
1451 * possibly pending error.
1452 */
1453 if (power_mode == MMC_POWER_ON)
1454 mmc_check_cards(host);
1455
1189 if (!list_empty(&host->cards)) { 1456 if (!list_empty(&host->cards)) {
1190 /* 1457 /*
1191 * (Re-)calculate the fastest clock rate which the 1458 * (Re-)calculate the fastest clock rate which the
@@ -1244,7 +1511,7 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev)
1244 spin_lock_init(&host->lock); 1511 spin_lock_init(&host->lock);
1245 init_waitqueue_head(&host->wq); 1512 init_waitqueue_head(&host->wq);
1246 INIT_LIST_HEAD(&host->cards); 1513 INIT_LIST_HEAD(&host->cards);
1247 INIT_WORK(&host->detect, mmc_rescan, host); 1514 INIT_DELAYED_WORK(&host->detect, mmc_rescan);
1248 1515
1249 /* 1516 /*
1250 * By default, hosts do not support SGIO or large requests. 1517 * By default, hosts do not support SGIO or large requests.
@@ -1342,7 +1609,7 @@ EXPORT_SYMBOL(mmc_suspend_host);
1342 */ 1609 */
1343int mmc_resume_host(struct mmc_host *host) 1610int mmc_resume_host(struct mmc_host *host)
1344{ 1611{
1345 mmc_rescan(host); 1612 mmc_rescan(&host->detect.work);
1346 1613
1347 return 0; 1614 return 0;
1348} 1615}
diff --git a/drivers/mmc/mmc.h b/drivers/mmc/mmc.h
index cd5e0ab3d84b..149affe0b686 100644
--- a/drivers/mmc/mmc.h
+++ b/drivers/mmc/mmc.h
@@ -20,6 +20,6 @@ void mmc_remove_host_sysfs(struct mmc_host *host);
20void mmc_free_host_sysfs(struct mmc_host *host); 20void mmc_free_host_sysfs(struct mmc_host *host);
21 21
22int mmc_schedule_work(struct work_struct *work); 22int mmc_schedule_work(struct work_struct *work);
23int mmc_schedule_delayed_work(struct work_struct *work, unsigned long delay); 23int mmc_schedule_delayed_work(struct delayed_work *work, unsigned long delay);
24void mmc_flush_scheduled_work(void); 24void mmc_flush_scheduled_work(void);
25#endif 25#endif
diff --git a/drivers/mmc/mmc_block.c b/drivers/mmc/mmc_block.c
index f9027c8db792..87713572293f 100644
--- a/drivers/mmc/mmc_block.c
+++ b/drivers/mmc/mmc_block.c
@@ -83,7 +83,6 @@ static void mmc_blk_put(struct mmc_blk_data *md)
83 md->usage--; 83 md->usage--;
84 if (md->usage == 0) { 84 if (md->usage == 0) {
85 put_disk(md->disk); 85 put_disk(md->disk);
86 mmc_cleanup_queue(&md->queue);
87 kfree(md); 86 kfree(md);
88 } 87 }
89 mutex_unlock(&open_lock); 88 mutex_unlock(&open_lock);
@@ -225,10 +224,10 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
225 struct mmc_blk_data *md = mq->data; 224 struct mmc_blk_data *md = mq->data;
226 struct mmc_card *card = md->queue.card; 225 struct mmc_card *card = md->queue.card;
227 struct mmc_blk_request brq; 226 struct mmc_blk_request brq;
228 int ret; 227 int ret = 1;
229 228
230 if (mmc_card_claim_host(card)) 229 if (mmc_card_claim_host(card))
231 goto cmd_err; 230 goto flush_queue;
232 231
233 do { 232 do {
234 struct mmc_command cmd; 233 struct mmc_command cmd;
@@ -345,8 +344,6 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
345 return 1; 344 return 1;
346 345
347 cmd_err: 346 cmd_err:
348 ret = 1;
349
350 /* 347 /*
351 * If this is an SD card and we're writing, we can first 348 * If this is an SD card and we're writing, we can first
352 * mark the known good sectors as ok. 349 * mark the known good sectors as ok.
@@ -380,6 +377,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
380 377
381 mmc_card_release_host(card); 378 mmc_card_release_host(card);
382 379
380flush_queue:
383 spin_lock_irq(&md->lock); 381 spin_lock_irq(&md->lock);
384 while (ret) { 382 while (ret) {
385 ret = end_that_request_chunk(req, 0, 383 ret = end_that_request_chunk(req, 0,
@@ -553,12 +551,11 @@ static void mmc_blk_remove(struct mmc_card *card)
553 if (md) { 551 if (md) {
554 int devidx; 552 int devidx;
555 553
554 /* Stop new requests from getting into the queue */
556 del_gendisk(md->disk); 555 del_gendisk(md->disk);
557 556
558 /* 557 /* Then flush out any already in there */
559 * I think this is needed. 558 mmc_cleanup_queue(&md->queue);
560 */
561 md->disk->queue = NULL;
562 559
563 devidx = md->disk->first_minor >> MMC_SHIFT; 560 devidx = md->disk->first_minor >> MMC_SHIFT;
564 __clear_bit(devidx, dev_use); 561 __clear_bit(devidx, dev_use);
diff --git a/drivers/mmc/mmc_queue.c b/drivers/mmc/mmc_queue.c
index 4ccdd82b680f..a17423a4ed8f 100644
--- a/drivers/mmc/mmc_queue.c
+++ b/drivers/mmc/mmc_queue.c
@@ -10,13 +10,13 @@
10 */ 10 */
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/blkdev.h> 12#include <linux/blkdev.h>
13#include <linux/kthread.h>
13 14
14#include <linux/mmc/card.h> 15#include <linux/mmc/card.h>
15#include <linux/mmc/host.h> 16#include <linux/mmc/host.h>
16#include "mmc_queue.h" 17#include "mmc_queue.h"
17 18
18#define MMC_QUEUE_EXIT (1 << 0) 19#define MMC_QUEUE_SUSPENDED (1 << 0)
19#define MMC_QUEUE_SUSPENDED (1 << 1)
20 20
21/* 21/*
22 * Prepare a MMC request. Essentially, this means passing the 22 * Prepare a MMC request. Essentially, this means passing the
@@ -59,7 +59,6 @@ static int mmc_queue_thread(void *d)
59{ 59{
60 struct mmc_queue *mq = d; 60 struct mmc_queue *mq = d;
61 struct request_queue *q = mq->queue; 61 struct request_queue *q = mq->queue;
62 DECLARE_WAITQUEUE(wait, current);
63 62
64 /* 63 /*
65 * Set iothread to ensure that we aren't put to sleep by 64 * Set iothread to ensure that we aren't put to sleep by
@@ -67,12 +66,7 @@ static int mmc_queue_thread(void *d)
67 */ 66 */
68 current->flags |= PF_MEMALLOC|PF_NOFREEZE; 67 current->flags |= PF_MEMALLOC|PF_NOFREEZE;
69 68
70 daemonize("mmcqd");
71
72 complete(&mq->thread_complete);
73
74 down(&mq->thread_sem); 69 down(&mq->thread_sem);
75 add_wait_queue(&mq->thread_wq, &wait);
76 do { 70 do {
77 struct request *req = NULL; 71 struct request *req = NULL;
78 72
@@ -84,7 +78,7 @@ static int mmc_queue_thread(void *d)
84 spin_unlock_irq(q->queue_lock); 78 spin_unlock_irq(q->queue_lock);
85 79
86 if (!req) { 80 if (!req) {
87 if (mq->flags & MMC_QUEUE_EXIT) 81 if (kthread_should_stop())
88 break; 82 break;
89 up(&mq->thread_sem); 83 up(&mq->thread_sem);
90 schedule(); 84 schedule();
@@ -95,10 +89,8 @@ static int mmc_queue_thread(void *d)
95 89
96 mq->issue_fn(mq, req); 90 mq->issue_fn(mq, req);
97 } while (1); 91 } while (1);
98 remove_wait_queue(&mq->thread_wq, &wait);
99 up(&mq->thread_sem); 92 up(&mq->thread_sem);
100 93
101 complete_and_exit(&mq->thread_complete, 0);
102 return 0; 94 return 0;
103} 95}
104 96
@@ -111,9 +103,22 @@ static int mmc_queue_thread(void *d)
111static void mmc_request(request_queue_t *q) 103static void mmc_request(request_queue_t *q)
112{ 104{
113 struct mmc_queue *mq = q->queuedata; 105 struct mmc_queue *mq = q->queuedata;
106 struct request *req;
107 int ret;
108
109 if (!mq) {
110 printk(KERN_ERR "MMC: killing requests for dead queue\n");
111 while ((req = elv_next_request(q)) != NULL) {
112 do {
113 ret = end_that_request_chunk(req, 0,
114 req->current_nr_sectors << 9);
115 } while (ret);
116 }
117 return;
118 }
114 119
115 if (!mq->req) 120 if (!mq->req)
116 wake_up(&mq->thread_wq); 121 wake_up_process(mq->thread);
117} 122}
118 123
119/** 124/**
@@ -130,8 +135,8 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, spinlock_t *lock
130 u64 limit = BLK_BOUNCE_HIGH; 135 u64 limit = BLK_BOUNCE_HIGH;
131 int ret; 136 int ret;
132 137
133 if (host->dev->dma_mask && *host->dev->dma_mask) 138 if (mmc_dev(host)->dma_mask && *mmc_dev(host)->dma_mask)
134 limit = *host->dev->dma_mask; 139 limit = *mmc_dev(host)->dma_mask;
135 140
136 mq->card = card; 141 mq->card = card;
137 mq->queue = blk_init_queue(mmc_request, lock); 142 mq->queue = blk_init_queue(mmc_request, lock);
@@ -152,36 +157,40 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, spinlock_t *lock
152 GFP_KERNEL); 157 GFP_KERNEL);
153 if (!mq->sg) { 158 if (!mq->sg) {
154 ret = -ENOMEM; 159 ret = -ENOMEM;
155 goto cleanup; 160 goto cleanup_queue;
156 } 161 }
157 162
158 init_completion(&mq->thread_complete);
159 init_waitqueue_head(&mq->thread_wq);
160 init_MUTEX(&mq->thread_sem); 163 init_MUTEX(&mq->thread_sem);
161 164
162 ret = kernel_thread(mmc_queue_thread, mq, CLONE_KERNEL); 165 mq->thread = kthread_run(mmc_queue_thread, mq, "mmcqd");
163 if (ret >= 0) { 166 if (IS_ERR(mq->thread)) {
164 wait_for_completion(&mq->thread_complete); 167 ret = PTR_ERR(mq->thread);
165 init_completion(&mq->thread_complete); 168 goto free_sg;
166 ret = 0;
167 goto out;
168 } 169 }
169 170
170 cleanup: 171 return 0;
172
173 free_sg:
171 kfree(mq->sg); 174 kfree(mq->sg);
172 mq->sg = NULL; 175 mq->sg = NULL;
173 176 cleanup_queue:
174 blk_cleanup_queue(mq->queue); 177 blk_cleanup_queue(mq->queue);
175 out:
176 return ret; 178 return ret;
177} 179}
178EXPORT_SYMBOL(mmc_init_queue); 180EXPORT_SYMBOL(mmc_init_queue);
179 181
180void mmc_cleanup_queue(struct mmc_queue *mq) 182void mmc_cleanup_queue(struct mmc_queue *mq)
181{ 183{
182 mq->flags |= MMC_QUEUE_EXIT; 184 request_queue_t *q = mq->queue;
183 wake_up(&mq->thread_wq); 185 unsigned long flags;
184 wait_for_completion(&mq->thread_complete); 186
187 /* Mark that we should start throwing out stragglers */
188 spin_lock_irqsave(q->queue_lock, flags);
189 q->queuedata = NULL;
190 spin_unlock_irqrestore(q->queue_lock, flags);
191
192 /* Then terminate our worker thread */
193 kthread_stop(mq->thread);
185 194
186 kfree(mq->sg); 195 kfree(mq->sg);
187 mq->sg = NULL; 196 mq->sg = NULL;
diff --git a/drivers/mmc/mmc_queue.h b/drivers/mmc/mmc_queue.h
index 7182d2f69b4e..c9f139e764f6 100644
--- a/drivers/mmc/mmc_queue.h
+++ b/drivers/mmc/mmc_queue.h
@@ -6,8 +6,7 @@ struct task_struct;
6 6
7struct mmc_queue { 7struct mmc_queue {
8 struct mmc_card *card; 8 struct mmc_card *card;
9 struct completion thread_complete; 9 struct task_struct *thread;
10 wait_queue_head_t thread_wq;
11 struct semaphore thread_sem; 10 struct semaphore thread_sem;
12 unsigned int flags; 11 unsigned int flags;
13 struct request *req; 12 struct request *req;
diff --git a/drivers/mmc/mmc_sysfs.c b/drivers/mmc/mmc_sysfs.c
index 10cc9734eaa0..e334acd045bc 100644
--- a/drivers/mmc/mmc_sysfs.c
+++ b/drivers/mmc/mmc_sysfs.c
@@ -199,7 +199,7 @@ void mmc_init_card(struct mmc_card *card, struct mmc_host *host)
199 memset(card, 0, sizeof(struct mmc_card)); 199 memset(card, 0, sizeof(struct mmc_card));
200 card->host = host; 200 card->host = host;
201 device_initialize(&card->dev); 201 device_initialize(&card->dev);
202 card->dev.parent = card->host->dev; 202 card->dev.parent = mmc_dev(host);
203 card->dev.bus = &mmc_bus_type; 203 card->dev.bus = &mmc_bus_type;
204 card->dev.release = mmc_release_card; 204 card->dev.release = mmc_release_card;
205} 205}
@@ -242,7 +242,7 @@ void mmc_remove_card(struct mmc_card *card)
242} 242}
243 243
244 244
245static void mmc_host_classdev_release(struct class_device *dev) 245static void mmc_host_classdev_release(struct device *dev)
246{ 246{
247 struct mmc_host *host = cls_dev_to_mmc_host(dev); 247 struct mmc_host *host = cls_dev_to_mmc_host(dev);
248 kfree(host); 248 kfree(host);
@@ -250,7 +250,7 @@ static void mmc_host_classdev_release(struct class_device *dev)
250 250
251static struct class mmc_host_class = { 251static struct class mmc_host_class = {
252 .name = "mmc_host", 252 .name = "mmc_host",
253 .release = mmc_host_classdev_release, 253 .dev_release = mmc_host_classdev_release,
254}; 254};
255 255
256static DEFINE_IDR(mmc_host_idr); 256static DEFINE_IDR(mmc_host_idr);
@@ -267,10 +267,10 @@ struct mmc_host *mmc_alloc_host_sysfs(int extra, struct device *dev)
267 if (host) { 267 if (host) {
268 memset(host, 0, sizeof(struct mmc_host) + extra); 268 memset(host, 0, sizeof(struct mmc_host) + extra);
269 269
270 host->dev = dev; 270 host->parent = dev;
271 host->class_dev.dev = host->dev; 271 host->class_dev.parent = dev;
272 host->class_dev.class = &mmc_host_class; 272 host->class_dev.class = &mmc_host_class;
273 class_device_initialize(&host->class_dev); 273 device_initialize(&host->class_dev);
274 } 274 }
275 275
276 return host; 276 return host;
@@ -292,10 +292,10 @@ int mmc_add_host_sysfs(struct mmc_host *host)
292 if (err) 292 if (err)
293 return err; 293 return err;
294 294
295 snprintf(host->class_dev.class_id, BUS_ID_SIZE, 295 snprintf(host->class_dev.bus_id, BUS_ID_SIZE,
296 "mmc%d", host->index); 296 "mmc%d", host->index);
297 297
298 return class_device_add(&host->class_dev); 298 return device_add(&host->class_dev);
299} 299}
300 300
301/* 301/*
@@ -303,7 +303,7 @@ int mmc_add_host_sysfs(struct mmc_host *host)
303 */ 303 */
304void mmc_remove_host_sysfs(struct mmc_host *host) 304void mmc_remove_host_sysfs(struct mmc_host *host)
305{ 305{
306 class_device_del(&host->class_dev); 306 device_del(&host->class_dev);
307 307
308 spin_lock(&mmc_host_lock); 308 spin_lock(&mmc_host_lock);
309 idr_remove(&mmc_host_idr, host->index); 309 idr_remove(&mmc_host_idr, host->index);
@@ -315,23 +315,15 @@ void mmc_remove_host_sysfs(struct mmc_host *host)
315 */ 315 */
316void mmc_free_host_sysfs(struct mmc_host *host) 316void mmc_free_host_sysfs(struct mmc_host *host)
317{ 317{
318 class_device_put(&host->class_dev); 318 put_device(&host->class_dev);
319} 319}
320 320
321static struct workqueue_struct *workqueue; 321static struct workqueue_struct *workqueue;
322 322
323/* 323/*
324 * Internal function. Schedule work in the MMC work queue.
325 */
326int mmc_schedule_work(struct work_struct *work)
327{
328 return queue_work(workqueue, work);
329}
330
331/*
332 * Internal function. Schedule delayed work in the MMC work queue. 324 * Internal function. Schedule delayed work in the MMC work queue.
333 */ 325 */
334int mmc_schedule_delayed_work(struct work_struct *work, unsigned long delay) 326int mmc_schedule_delayed_work(struct delayed_work *work, unsigned long delay)
335{ 327{
336 return queue_delayed_work(workqueue, work, delay); 328 return queue_delayed_work(workqueue, work, delay);
337} 329}
diff --git a/drivers/mmc/mmci.c b/drivers/mmc/mmci.c
index 828503c4ee62..e9b80e920266 100644
--- a/drivers/mmc/mmci.c
+++ b/drivers/mmc/mmci.c
@@ -443,7 +443,7 @@ static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
443 } 443 }
444} 444}
445 445
446static struct mmc_host_ops mmci_ops = { 446static const struct mmc_host_ops mmci_ops = {
447 .request = mmci_request, 447 .request = mmci_request,
448 .set_ios = mmci_set_ios, 448 .set_ios = mmci_set_ios,
449}; 449};
diff --git a/drivers/mmc/omap.c b/drivers/mmc/omap.c
index 762fa2895891..435d331e772a 100644
--- a/drivers/mmc/omap.c
+++ b/drivers/mmc/omap.c
@@ -38,7 +38,57 @@
38#include <asm/arch/fpga.h> 38#include <asm/arch/fpga.h>
39#include <asm/arch/tps65010.h> 39#include <asm/arch/tps65010.h>
40 40
41#include "omap.h" 41#define OMAP_MMC_REG_CMD 0x00
42#define OMAP_MMC_REG_ARGL 0x04
43#define OMAP_MMC_REG_ARGH 0x08
44#define OMAP_MMC_REG_CON 0x0c
45#define OMAP_MMC_REG_STAT 0x10
46#define OMAP_MMC_REG_IE 0x14
47#define OMAP_MMC_REG_CTO 0x18
48#define OMAP_MMC_REG_DTO 0x1c
49#define OMAP_MMC_REG_DATA 0x20
50#define OMAP_MMC_REG_BLEN 0x24
51#define OMAP_MMC_REG_NBLK 0x28
52#define OMAP_MMC_REG_BUF 0x2c
53#define OMAP_MMC_REG_SDIO 0x34
54#define OMAP_MMC_REG_REV 0x3c
55#define OMAP_MMC_REG_RSP0 0x40
56#define OMAP_MMC_REG_RSP1 0x44
57#define OMAP_MMC_REG_RSP2 0x48
58#define OMAP_MMC_REG_RSP3 0x4c
59#define OMAP_MMC_REG_RSP4 0x50
60#define OMAP_MMC_REG_RSP5 0x54
61#define OMAP_MMC_REG_RSP6 0x58
62#define OMAP_MMC_REG_RSP7 0x5c
63#define OMAP_MMC_REG_IOSR 0x60
64#define OMAP_MMC_REG_SYSC 0x64
65#define OMAP_MMC_REG_SYSS 0x68
66
67#define OMAP_MMC_STAT_CARD_ERR (1 << 14)
68#define OMAP_MMC_STAT_CARD_IRQ (1 << 13)
69#define OMAP_MMC_STAT_OCR_BUSY (1 << 12)
70#define OMAP_MMC_STAT_A_EMPTY (1 << 11)
71#define OMAP_MMC_STAT_A_FULL (1 << 10)
72#define OMAP_MMC_STAT_CMD_CRC (1 << 8)
73#define OMAP_MMC_STAT_CMD_TOUT (1 << 7)
74#define OMAP_MMC_STAT_DATA_CRC (1 << 6)
75#define OMAP_MMC_STAT_DATA_TOUT (1 << 5)
76#define OMAP_MMC_STAT_END_BUSY (1 << 4)
77#define OMAP_MMC_STAT_END_OF_DATA (1 << 3)
78#define OMAP_MMC_STAT_CARD_BUSY (1 << 2)
79#define OMAP_MMC_STAT_END_OF_CMD (1 << 0)
80
81#define OMAP_MMC_READ(host, reg) __raw_readw((host)->virt_base + OMAP_MMC_REG_##reg)
82#define OMAP_MMC_WRITE(host, reg, val) __raw_writew((val), (host)->virt_base + OMAP_MMC_REG_##reg)
83
84/*
85 * Command types
86 */
87#define OMAP_MMC_CMDTYPE_BC 0
88#define OMAP_MMC_CMDTYPE_BCR 1
89#define OMAP_MMC_CMDTYPE_AC 2
90#define OMAP_MMC_CMDTYPE_ADTC 3
91
42 92
43#define DRIVER_NAME "mmci-omap" 93#define DRIVER_NAME "mmci-omap"
44#define RSP_TYPE(x) ((x) & ~(MMC_RSP_BUSY|MMC_RSP_OPCODE)) 94#define RSP_TYPE(x) ((x) & ~(MMC_RSP_BUSY|MMC_RSP_OPCODE))
@@ -60,8 +110,9 @@ struct mmc_omap_host {
60 unsigned char id; /* 16xx chips have 2 MMC blocks */ 110 unsigned char id; /* 16xx chips have 2 MMC blocks */
61 struct clk * iclk; 111 struct clk * iclk;
62 struct clk * fclk; 112 struct clk * fclk;
63 struct resource *res; 113 struct resource *mem_res;
64 void __iomem *base; 114 void __iomem *virt_base;
115 unsigned int phys_base;
65 int irq; 116 int irq;
66 unsigned char bus_mode; 117 unsigned char bus_mode;
67 unsigned char hw_bus_mode; 118 unsigned char hw_bus_mode;
@@ -191,16 +242,16 @@ mmc_omap_start_command(struct mmc_omap_host *host, struct mmc_command *cmd)
191 242
192 clk_enable(host->fclk); 243 clk_enable(host->fclk);
193 244
194 OMAP_MMC_WRITE(host->base, CTO, 200); 245 OMAP_MMC_WRITE(host, CTO, 200);
195 OMAP_MMC_WRITE(host->base, ARGL, cmd->arg & 0xffff); 246 OMAP_MMC_WRITE(host, ARGL, cmd->arg & 0xffff);
196 OMAP_MMC_WRITE(host->base, ARGH, cmd->arg >> 16); 247 OMAP_MMC_WRITE(host, ARGH, cmd->arg >> 16);
197 OMAP_MMC_WRITE(host->base, IE, 248 OMAP_MMC_WRITE(host, IE,
198 OMAP_MMC_STAT_A_EMPTY | OMAP_MMC_STAT_A_FULL | 249 OMAP_MMC_STAT_A_EMPTY | OMAP_MMC_STAT_A_FULL |
199 OMAP_MMC_STAT_CMD_CRC | OMAP_MMC_STAT_CMD_TOUT | 250 OMAP_MMC_STAT_CMD_CRC | OMAP_MMC_STAT_CMD_TOUT |
200 OMAP_MMC_STAT_DATA_CRC | OMAP_MMC_STAT_DATA_TOUT | 251 OMAP_MMC_STAT_DATA_CRC | OMAP_MMC_STAT_DATA_TOUT |
201 OMAP_MMC_STAT_END_OF_CMD | OMAP_MMC_STAT_CARD_ERR | 252 OMAP_MMC_STAT_END_OF_CMD | OMAP_MMC_STAT_CARD_ERR |
202 OMAP_MMC_STAT_END_OF_DATA); 253 OMAP_MMC_STAT_END_OF_DATA);
203 OMAP_MMC_WRITE(host->base, CMD, cmdreg); 254 OMAP_MMC_WRITE(host, CMD, cmdreg);
204} 255}
205 256
206static void 257static void
@@ -296,22 +347,22 @@ mmc_omap_cmd_done(struct mmc_omap_host *host, struct mmc_command *cmd)
296 if (cmd->flags & MMC_RSP_136) { 347 if (cmd->flags & MMC_RSP_136) {
297 /* response type 2 */ 348 /* response type 2 */
298 cmd->resp[3] = 349 cmd->resp[3] =
299 OMAP_MMC_READ(host->base, RSP0) | 350 OMAP_MMC_READ(host, RSP0) |
300 (OMAP_MMC_READ(host->base, RSP1) << 16); 351 (OMAP_MMC_READ(host, RSP1) << 16);
301 cmd->resp[2] = 352 cmd->resp[2] =
302 OMAP_MMC_READ(host->base, RSP2) | 353 OMAP_MMC_READ(host, RSP2) |
303 (OMAP_MMC_READ(host->base, RSP3) << 16); 354 (OMAP_MMC_READ(host, RSP3) << 16);
304 cmd->resp[1] = 355 cmd->resp[1] =
305 OMAP_MMC_READ(host->base, RSP4) | 356 OMAP_MMC_READ(host, RSP4) |
306 (OMAP_MMC_READ(host->base, RSP5) << 16); 357 (OMAP_MMC_READ(host, RSP5) << 16);
307 cmd->resp[0] = 358 cmd->resp[0] =
308 OMAP_MMC_READ(host->base, RSP6) | 359 OMAP_MMC_READ(host, RSP6) |
309 (OMAP_MMC_READ(host->base, RSP7) << 16); 360 (OMAP_MMC_READ(host, RSP7) << 16);
310 } else { 361 } else {
311 /* response types 1, 1b, 3, 4, 5, 6 */ 362 /* response types 1, 1b, 3, 4, 5, 6 */
312 cmd->resp[0] = 363 cmd->resp[0] =
313 OMAP_MMC_READ(host->base, RSP6) | 364 OMAP_MMC_READ(host, RSP6) |
314 (OMAP_MMC_READ(host->base, RSP7) << 16); 365 (OMAP_MMC_READ(host, RSP7) << 16);
315 } 366 }
316 } 367 }
317 368
@@ -354,9 +405,9 @@ mmc_omap_xfer_data(struct mmc_omap_host *host, int write)
354 host->data->bytes_xfered += n; 405 host->data->bytes_xfered += n;
355 406
356 if (write) { 407 if (write) {
357 __raw_writesw(host->base + OMAP_MMC_REG_DATA, host->buffer, n); 408 __raw_writesw(host->virt_base + OMAP_MMC_REG_DATA, host->buffer, n);
358 } else { 409 } else {
359 __raw_readsw(host->base + OMAP_MMC_REG_DATA, host->buffer, n); 410 __raw_readsw(host->virt_base + OMAP_MMC_REG_DATA, host->buffer, n);
360 } 411 }
361} 412}
362 413
@@ -386,11 +437,11 @@ static irqreturn_t mmc_omap_irq(int irq, void *dev_id)
386 int transfer_error; 437 int transfer_error;
387 438
388 if (host->cmd == NULL && host->data == NULL) { 439 if (host->cmd == NULL && host->data == NULL) {
389 status = OMAP_MMC_READ(host->base, STAT); 440 status = OMAP_MMC_READ(host, STAT);
390 dev_info(mmc_dev(host->mmc),"spurious irq 0x%04x\n", status); 441 dev_info(mmc_dev(host->mmc),"spurious irq 0x%04x\n", status);
391 if (status != 0) { 442 if (status != 0) {
392 OMAP_MMC_WRITE(host->base, STAT, status); 443 OMAP_MMC_WRITE(host, STAT, status);
393 OMAP_MMC_WRITE(host->base, IE, 0); 444 OMAP_MMC_WRITE(host, IE, 0);
394 } 445 }
395 return IRQ_HANDLED; 446 return IRQ_HANDLED;
396 } 447 }
@@ -399,8 +450,8 @@ static irqreturn_t mmc_omap_irq(int irq, void *dev_id)
399 end_transfer = 0; 450 end_transfer = 0;
400 transfer_error = 0; 451 transfer_error = 0;
401 452
402 while ((status = OMAP_MMC_READ(host->base, STAT)) != 0) { 453 while ((status = OMAP_MMC_READ(host, STAT)) != 0) {
403 OMAP_MMC_WRITE(host->base, STAT, status); 454 OMAP_MMC_WRITE(host, STAT, status);
404#ifdef CONFIG_MMC_DEBUG 455#ifdef CONFIG_MMC_DEBUG
405 dev_dbg(mmc_dev(host->mmc), "MMC IRQ %04x (CMD %d): ", 456 dev_dbg(mmc_dev(host->mmc), "MMC IRQ %04x (CMD %d): ",
406 status, host->cmd != NULL ? host->cmd->opcode : -1); 457 status, host->cmd != NULL ? host->cmd->opcode : -1);
@@ -470,8 +521,8 @@ static irqreturn_t mmc_omap_irq(int irq, void *dev_id)
470 521
471 if (status & OMAP_MMC_STAT_CARD_ERR) { 522 if (status & OMAP_MMC_STAT_CARD_ERR) {
472 if (host->cmd && host->cmd->opcode == MMC_STOP_TRANSMISSION) { 523 if (host->cmd && host->cmd->opcode == MMC_STOP_TRANSMISSION) {
473 u32 response = OMAP_MMC_READ(host->base, RSP6) 524 u32 response = OMAP_MMC_READ(host, RSP6)
474 | (OMAP_MMC_READ(host->base, RSP7) << 16); 525 | (OMAP_MMC_READ(host, RSP7) << 16);
475 /* STOP sometimes sets must-ignore bits */ 526 /* STOP sometimes sets must-ignore bits */
476 if (!(response & (R1_CC_ERROR 527 if (!(response & (R1_CC_ERROR
477 | R1_ILLEGAL_COMMAND 528 | R1_ILLEGAL_COMMAND
@@ -530,12 +581,6 @@ static void mmc_omap_switch_timer(unsigned long arg)
530 schedule_work(&host->switch_work); 581 schedule_work(&host->switch_work);
531} 582}
532 583
533/* FIXME: Handle card insertion and removal properly. Maybe use a mask
534 * for MMC state? */
535static void mmc_omap_switch_callback(unsigned long data, u8 mmc_mask)
536{
537}
538
539static void mmc_omap_switch_handler(void *data) 584static void mmc_omap_switch_handler(void *data)
540{ 585{
541 struct mmc_omap_host *host = (struct mmc_omap_host *) data; 586 struct mmc_omap_host *host = (struct mmc_omap_host *) data;
@@ -581,7 +626,7 @@ mmc_omap_prepare_dma(struct mmc_omap_host *host, struct mmc_data *data)
581 int dst_port = 0; 626 int dst_port = 0;
582 int sync_dev = 0; 627 int sync_dev = 0;
583 628
584 data_addr = io_v2p((u32) host->base) + OMAP_MMC_REG_DATA; 629 data_addr = host->phys_base + OMAP_MMC_REG_DATA;
585 frame = data->blksz; 630 frame = data->blksz;
586 count = sg_dma_len(sg); 631 count = sg_dma_len(sg);
587 632
@@ -640,10 +685,9 @@ mmc_omap_prepare_dma(struct mmc_omap_host *host, struct mmc_data *data)
640 } 685 }
641 686
642 /* Max limit for DMA frame count is 0xffff */ 687 /* Max limit for DMA frame count is 0xffff */
643 if (unlikely(count > 0xffff)) 688 BUG_ON(count > 0xffff);
644 BUG();
645 689
646 OMAP_MMC_WRITE(host->base, BUF, buf); 690 OMAP_MMC_WRITE(host, BUF, buf);
647 omap_set_dma_transfer_params(dma_ch, OMAP_DMA_DATA_TYPE_S16, 691 omap_set_dma_transfer_params(dma_ch, OMAP_DMA_DATA_TYPE_S16,
648 frame, count, OMAP_DMA_SYNC_FRAME, 692 frame, count, OMAP_DMA_SYNC_FRAME,
649 sync_dev, 0); 693 sync_dev, 0);
@@ -728,11 +772,11 @@ static inline void set_cmd_timeout(struct mmc_omap_host *host, struct mmc_reques
728{ 772{
729 u16 reg; 773 u16 reg;
730 774
731 reg = OMAP_MMC_READ(host->base, SDIO); 775 reg = OMAP_MMC_READ(host, SDIO);
732 reg &= ~(1 << 5); 776 reg &= ~(1 << 5);
733 OMAP_MMC_WRITE(host->base, SDIO, reg); 777 OMAP_MMC_WRITE(host, SDIO, reg);
734 /* Set maximum timeout */ 778 /* Set maximum timeout */
735 OMAP_MMC_WRITE(host->base, CTO, 0xff); 779 OMAP_MMC_WRITE(host, CTO, 0xff);
736} 780}
737 781
738static inline void set_data_timeout(struct mmc_omap_host *host, struct mmc_request *req) 782static inline void set_data_timeout(struct mmc_omap_host *host, struct mmc_request *req)
@@ -746,14 +790,14 @@ static inline void set_data_timeout(struct mmc_omap_host *host, struct mmc_reque
746 timeout = req->data->timeout_clks + req->data->timeout_ns / 500; 790 timeout = req->data->timeout_clks + req->data->timeout_ns / 500;
747 791
748 /* Check if we need to use timeout multiplier register */ 792 /* Check if we need to use timeout multiplier register */
749 reg = OMAP_MMC_READ(host->base, SDIO); 793 reg = OMAP_MMC_READ(host, SDIO);
750 if (timeout > 0xffff) { 794 if (timeout > 0xffff) {
751 reg |= (1 << 5); 795 reg |= (1 << 5);
752 timeout /= 1024; 796 timeout /= 1024;
753 } else 797 } else
754 reg &= ~(1 << 5); 798 reg &= ~(1 << 5);
755 OMAP_MMC_WRITE(host->base, SDIO, reg); 799 OMAP_MMC_WRITE(host, SDIO, reg);
756 OMAP_MMC_WRITE(host->base, DTO, timeout); 800 OMAP_MMC_WRITE(host, DTO, timeout);
757} 801}
758 802
759static void 803static void
@@ -765,19 +809,18 @@ mmc_omap_prepare_data(struct mmc_omap_host *host, struct mmc_request *req)
765 809
766 host->data = data; 810 host->data = data;
767 if (data == NULL) { 811 if (data == NULL) {
768 OMAP_MMC_WRITE(host->base, BLEN, 0); 812 OMAP_MMC_WRITE(host, BLEN, 0);
769 OMAP_MMC_WRITE(host->base, NBLK, 0); 813 OMAP_MMC_WRITE(host, NBLK, 0);
770 OMAP_MMC_WRITE(host->base, BUF, 0); 814 OMAP_MMC_WRITE(host, BUF, 0);
771 host->dma_in_use = 0; 815 host->dma_in_use = 0;
772 set_cmd_timeout(host, req); 816 set_cmd_timeout(host, req);
773 return; 817 return;
774 } 818 }
775 819
776
777 block_size = data->blksz; 820 block_size = data->blksz;
778 821
779 OMAP_MMC_WRITE(host->base, NBLK, data->blocks - 1); 822 OMAP_MMC_WRITE(host, NBLK, data->blocks - 1);
780 OMAP_MMC_WRITE(host->base, BLEN, block_size - 1); 823 OMAP_MMC_WRITE(host, BLEN, block_size - 1);
781 set_data_timeout(host, req); 824 set_data_timeout(host, req);
782 825
783 /* cope with calling layer confusion; it issues "single 826 /* cope with calling layer confusion; it issues "single
@@ -819,7 +862,7 @@ mmc_omap_prepare_data(struct mmc_omap_host *host, struct mmc_request *req)
819 862
820 /* Revert to PIO? */ 863 /* Revert to PIO? */
821 if (!use_dma) { 864 if (!use_dma) {
822 OMAP_MMC_WRITE(host->base, BUF, 0x1f1f); 865 OMAP_MMC_WRITE(host, BUF, 0x1f1f);
823 host->total_bytes_left = data->blocks * block_size; 866 host->total_bytes_left = data->blocks * block_size;
824 host->sg_len = sg_len; 867 host->sg_len = sg_len;
825 mmc_omap_sg_to_buf(host); 868 mmc_omap_sg_to_buf(host);
@@ -845,7 +888,6 @@ static void mmc_omap_request(struct mmc_host *mmc, struct mmc_request *req)
845static void innovator_fpga_socket_power(int on) 888static void innovator_fpga_socket_power(int on)
846{ 889{
847#if defined(CONFIG_MACH_OMAP_INNOVATOR) && defined(CONFIG_ARCH_OMAP15XX) 890#if defined(CONFIG_MACH_OMAP_INNOVATOR) && defined(CONFIG_ARCH_OMAP15XX)
848
849 if (on) { 891 if (on) {
850 fpga_write(fpga_read(OMAP1510_FPGA_POWER) | (1 << 3), 892 fpga_write(fpga_read(OMAP1510_FPGA_POWER) | (1 << 3),
851 OMAP1510_FPGA_POWER); 893 OMAP1510_FPGA_POWER);
@@ -871,8 +913,8 @@ static void mmc_omap_power(struct mmc_omap_host *host, int on)
871 /* GPIO 4 of TPS65010 sends SD_EN signal */ 913 /* GPIO 4 of TPS65010 sends SD_EN signal */
872 tps65010_set_gpio_out_value(GPIO4, HIGH); 914 tps65010_set_gpio_out_value(GPIO4, HIGH);
873 else if (cpu_is_omap24xx()) { 915 else if (cpu_is_omap24xx()) {
874 u16 reg = OMAP_MMC_READ(host->base, CON); 916 u16 reg = OMAP_MMC_READ(host, CON);
875 OMAP_MMC_WRITE(host->base, CON, reg | (1 << 11)); 917 OMAP_MMC_WRITE(host, CON, reg | (1 << 11));
876 } else 918 } else
877 if (host->power_pin >= 0) 919 if (host->power_pin >= 0)
878 omap_set_gpio_dataout(host->power_pin, 1); 920 omap_set_gpio_dataout(host->power_pin, 1);
@@ -884,8 +926,8 @@ static void mmc_omap_power(struct mmc_omap_host *host, int on)
884 else if (machine_is_omap_h3()) 926 else if (machine_is_omap_h3())
885 tps65010_set_gpio_out_value(GPIO4, LOW); 927 tps65010_set_gpio_out_value(GPIO4, LOW);
886 else if (cpu_is_omap24xx()) { 928 else if (cpu_is_omap24xx()) {
887 u16 reg = OMAP_MMC_READ(host->base, CON); 929 u16 reg = OMAP_MMC_READ(host, CON);
888 OMAP_MMC_WRITE(host->base, CON, reg & ~(1 << 11)); 930 OMAP_MMC_WRITE(host, CON, reg & ~(1 << 11));
889 } else 931 } else
890 if (host->power_pin >= 0) 932 if (host->power_pin >= 0)
891 omap_set_gpio_dataout(host->power_pin, 0); 933 omap_set_gpio_dataout(host->power_pin, 0);
@@ -927,7 +969,7 @@ static void mmc_omap_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
927 case MMC_POWER_UP: 969 case MMC_POWER_UP:
928 case MMC_POWER_ON: 970 case MMC_POWER_ON:
929 mmc_omap_power(host, 1); 971 mmc_omap_power(host, 1);
930 dsor |= 1<<11; 972 dsor |= 1 << 11;
931 break; 973 break;
932 } 974 }
933 975
@@ -941,14 +983,14 @@ static void mmc_omap_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
941 * which results in the while loop below getting stuck. 983 * which results in the while loop below getting stuck.
942 * Writing to the CON register twice seems to do the trick. */ 984 * Writing to the CON register twice seems to do the trick. */
943 for (i = 0; i < 2; i++) 985 for (i = 0; i < 2; i++)
944 OMAP_MMC_WRITE(host->base, CON, dsor); 986 OMAP_MMC_WRITE(host, CON, dsor);
945 if (ios->power_mode == MMC_POWER_UP) { 987 if (ios->power_mode == MMC_POWER_UP) {
946 /* Send clock cycles, poll completion */ 988 /* Send clock cycles, poll completion */
947 OMAP_MMC_WRITE(host->base, IE, 0); 989 OMAP_MMC_WRITE(host, IE, 0);
948 OMAP_MMC_WRITE(host->base, STAT, 0xffff); 990 OMAP_MMC_WRITE(host, STAT, 0xffff);
949 OMAP_MMC_WRITE(host->base, CMD, 1<<7); 991 OMAP_MMC_WRITE(host, CMD, 1 << 7);
950 while (0 == (OMAP_MMC_READ(host->base, STAT) & 1)); 992 while ((OMAP_MMC_READ(host, STAT) & 1) == 0);
951 OMAP_MMC_WRITE(host->base, STAT, 1); 993 OMAP_MMC_WRITE(host, STAT, 1);
952 } 994 }
953 clk_disable(host->fclk); 995 clk_disable(host->fclk);
954} 996}
@@ -960,7 +1002,7 @@ static int mmc_omap_get_ro(struct mmc_host *mmc)
960 return host->wp_pin && omap_get_gpio_datain(host->wp_pin); 1002 return host->wp_pin && omap_get_gpio_datain(host->wp_pin);
961} 1003}
962 1004
963static struct mmc_host_ops mmc_omap_ops = { 1005static const struct mmc_host_ops mmc_omap_ops = {
964 .request = mmc_omap_request, 1006 .request = mmc_omap_request,
965 .set_ios = mmc_omap_set_ios, 1007 .set_ios = mmc_omap_set_ios,
966 .get_ro = mmc_omap_get_ro, 1008 .get_ro = mmc_omap_get_ro,
@@ -971,25 +1013,29 @@ static int __init mmc_omap_probe(struct platform_device *pdev)
971 struct omap_mmc_conf *minfo = pdev->dev.platform_data; 1013 struct omap_mmc_conf *minfo = pdev->dev.platform_data;
972 struct mmc_host *mmc; 1014 struct mmc_host *mmc;
973 struct mmc_omap_host *host = NULL; 1015 struct mmc_omap_host *host = NULL;
974 struct resource *r; 1016 struct resource *res;
975 int ret = 0; 1017 int ret = 0;
976 int irq; 1018 int irq;
977 1019
978 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1020 if (minfo == NULL) {
1021 dev_err(&pdev->dev, "platform data missing\n");
1022 return -ENXIO;
1023 }
1024
1025 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
979 irq = platform_get_irq(pdev, 0); 1026 irq = platform_get_irq(pdev, 0);
980 if (!r || irq < 0) 1027 if (res == NULL || irq < 0)
981 return -ENXIO; 1028 return -ENXIO;
982 1029
983 r = request_mem_region(pdev->resource[0].start, 1030 res = request_mem_region(res->start, res->end - res->start + 1,
984 pdev->resource[0].end - pdev->resource[0].start + 1, 1031 pdev->name);
985 pdev->name); 1032 if (res == NULL)
986 if (!r)
987 return -EBUSY; 1033 return -EBUSY;
988 1034
989 mmc = mmc_alloc_host(sizeof(struct mmc_omap_host), &pdev->dev); 1035 mmc = mmc_alloc_host(sizeof(struct mmc_omap_host), &pdev->dev);
990 if (!mmc) { 1036 if (mmc == NULL) {
991 ret = -ENOMEM; 1037 ret = -ENOMEM;
992 goto out; 1038 goto err_free_mem_region;
993 } 1039 }
994 1040
995 host = mmc_priv(mmc); 1041 host = mmc_priv(mmc);
@@ -1001,13 +1047,13 @@ static int __init mmc_omap_probe(struct platform_device *pdev)
1001 host->dma_timer.data = (unsigned long) host; 1047 host->dma_timer.data = (unsigned long) host;
1002 1048
1003 host->id = pdev->id; 1049 host->id = pdev->id;
1004 host->res = r; 1050 host->mem_res = res;
1005 host->irq = irq; 1051 host->irq = irq;
1006 1052
1007 if (cpu_is_omap24xx()) { 1053 if (cpu_is_omap24xx()) {
1008 host->iclk = clk_get(&pdev->dev, "mmc_ick"); 1054 host->iclk = clk_get(&pdev->dev, "mmc_ick");
1009 if (IS_ERR(host->iclk)) 1055 if (IS_ERR(host->iclk))
1010 goto out; 1056 goto err_free_mmc_host;
1011 clk_enable(host->iclk); 1057 clk_enable(host->iclk);
1012 } 1058 }
1013 1059
@@ -1018,7 +1064,7 @@ static int __init mmc_omap_probe(struct platform_device *pdev)
1018 1064
1019 if (IS_ERR(host->fclk)) { 1065 if (IS_ERR(host->fclk)) {
1020 ret = PTR_ERR(host->fclk); 1066 ret = PTR_ERR(host->fclk);
1021 goto out; 1067 goto err_free_iclk;
1022 } 1068 }
1023 1069
1024 /* REVISIT: 1070 /* REVISIT:
@@ -1031,14 +1077,15 @@ static int __init mmc_omap_probe(struct platform_device *pdev)
1031 host->use_dma = 1; 1077 host->use_dma = 1;
1032 host->dma_ch = -1; 1078 host->dma_ch = -1;
1033 1079
1034 host->irq = pdev->resource[1].start; 1080 host->irq = irq;
1035 host->base = (void __iomem*)IO_ADDRESS(r->start); 1081 host->phys_base = host->mem_res->start;
1082 host->virt_base = (void __iomem *) IO_ADDRESS(host->phys_base);
1036 1083
1037 mmc->ops = &mmc_omap_ops; 1084 mmc->ops = &mmc_omap_ops;
1038 mmc->f_min = 400000; 1085 mmc->f_min = 400000;
1039 mmc->f_max = 24000000; 1086 mmc->f_max = 24000000;
1040 mmc->ocr_avail = MMC_VDD_32_33|MMC_VDD_33_34; 1087 mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
1041 mmc->caps = MMC_CAP_BYTEBLOCK; 1088 mmc->caps = MMC_CAP_MULTIWRITE | MMC_CAP_BYTEBLOCK;
1042 1089
1043 if (minfo->wire4) 1090 if (minfo->wire4)
1044 mmc->caps |= MMC_CAP_4_BIT_DATA; 1091 mmc->caps |= MMC_CAP_4_BIT_DATA;
@@ -1056,20 +1103,18 @@ static int __init mmc_omap_probe(struct platform_device *pdev)
1056 if ((ret = omap_request_gpio(host->power_pin)) != 0) { 1103 if ((ret = omap_request_gpio(host->power_pin)) != 0) {
1057 dev_err(mmc_dev(host->mmc), 1104 dev_err(mmc_dev(host->mmc),
1058 "Unable to get GPIO pin for MMC power\n"); 1105 "Unable to get GPIO pin for MMC power\n");
1059 goto out; 1106 goto err_free_fclk;
1060 } 1107 }
1061 omap_set_gpio_direction(host->power_pin, 0); 1108 omap_set_gpio_direction(host->power_pin, 0);
1062 } 1109 }
1063 1110
1064 ret = request_irq(host->irq, mmc_omap_irq, 0, DRIVER_NAME, host); 1111 ret = request_irq(host->irq, mmc_omap_irq, 0, DRIVER_NAME, host);
1065 if (ret) 1112 if (ret)
1066 goto out; 1113 goto err_free_power_gpio;
1067 1114
1068 host->dev = &pdev->dev; 1115 host->dev = &pdev->dev;
1069 platform_set_drvdata(pdev, host); 1116 platform_set_drvdata(pdev, host);
1070 1117
1071 mmc_add_host(mmc);
1072
1073 if (host->switch_pin >= 0) { 1118 if (host->switch_pin >= 0) {
1074 INIT_WORK(&host->switch_work, mmc_omap_switch_handler, host); 1119 INIT_WORK(&host->switch_work, mmc_omap_switch_handler, host);
1075 init_timer(&host->switch_timer); 1120 init_timer(&host->switch_timer);
@@ -1107,10 +1152,11 @@ static int __init mmc_omap_probe(struct platform_device *pdev)
1107 schedule_work(&host->switch_work); 1152 schedule_work(&host->switch_work);
1108 } 1153 }
1109 1154
1110no_switch: 1155 mmc_add_host(mmc);
1156
1111 return 0; 1157 return 0;
1112 1158
1113out: 1159no_switch:
1114 /* FIXME: Free other resources too. */ 1160 /* FIXME: Free other resources too. */
1115 if (host) { 1161 if (host) {
1116 if (host->iclk && !IS_ERR(host->iclk)) 1162 if (host->iclk && !IS_ERR(host->iclk))
@@ -1119,6 +1165,20 @@ out:
1119 clk_put(host->fclk); 1165 clk_put(host->fclk);
1120 mmc_free_host(host->mmc); 1166 mmc_free_host(host->mmc);
1121 } 1167 }
1168err_free_power_gpio:
1169 if (host->power_pin >= 0)
1170 omap_free_gpio(host->power_pin);
1171err_free_fclk:
1172 clk_put(host->fclk);
1173err_free_iclk:
1174 if (host->iclk != NULL) {
1175 clk_disable(host->iclk);
1176 clk_put(host->iclk);
1177 }
1178err_free_mmc_host:
1179 mmc_free_host(host->mmc);
1180err_free_mem_region:
1181 release_mem_region(res->start, res->end - res->start + 1);
1122 return ret; 1182 return ret;
1123} 1183}
1124 1184
@@ -1128,30 +1188,31 @@ static int mmc_omap_remove(struct platform_device *pdev)
1128 1188
1129 platform_set_drvdata(pdev, NULL); 1189 platform_set_drvdata(pdev, NULL);
1130 1190
1131 if (host) { 1191 BUG_ON(host == NULL);
1132 mmc_remove_host(host->mmc); 1192
1133 free_irq(host->irq, host); 1193 mmc_remove_host(host->mmc);
1134 1194 free_irq(host->irq, host);
1135 if (host->power_pin >= 0) 1195
1136 omap_free_gpio(host->power_pin); 1196 if (host->power_pin >= 0)
1137 if (host->switch_pin >= 0) { 1197 omap_free_gpio(host->power_pin);
1138 device_remove_file(&pdev->dev, &dev_attr_enable_poll); 1198 if (host->switch_pin >= 0) {
1139 device_remove_file(&pdev->dev, &dev_attr_cover_switch); 1199 device_remove_file(&pdev->dev, &dev_attr_enable_poll);
1140 free_irq(OMAP_GPIO_IRQ(host->switch_pin), host); 1200 device_remove_file(&pdev->dev, &dev_attr_cover_switch);
1141 omap_free_gpio(host->switch_pin); 1201 free_irq(OMAP_GPIO_IRQ(host->switch_pin), host);
1142 host->switch_pin = -1; 1202 omap_free_gpio(host->switch_pin);
1143 del_timer_sync(&host->switch_timer); 1203 host->switch_pin = -1;
1144 flush_scheduled_work(); 1204 del_timer_sync(&host->switch_timer);
1145 } 1205 flush_scheduled_work();
1146 if (host->iclk && !IS_ERR(host->iclk))
1147 clk_put(host->iclk);
1148 if (host->fclk && !IS_ERR(host->fclk))
1149 clk_put(host->fclk);
1150 mmc_free_host(host->mmc);
1151 } 1206 }
1207 if (host->iclk && !IS_ERR(host->iclk))
1208 clk_put(host->iclk);
1209 if (host->fclk && !IS_ERR(host->fclk))
1210 clk_put(host->fclk);
1152 1211
1153 release_mem_region(pdev->resource[0].start, 1212 release_mem_region(pdev->resource[0].start,
1154 pdev->resource[0].end - pdev->resource[0].start + 1); 1213 pdev->resource[0].end - pdev->resource[0].start + 1);
1214
1215 mmc_free_host(host->mmc);
1155 1216
1156 return 0; 1217 return 0;
1157} 1218}
diff --git a/drivers/mmc/omap.h b/drivers/mmc/omap.h
deleted file mode 100644
index c954d355a5e3..000000000000
--- a/drivers/mmc/omap.h
+++ /dev/null
@@ -1,55 +0,0 @@
1#ifndef DRIVERS_MEDIA_MMC_OMAP_H
2#define DRIVERS_MEDIA_MMC_OMAP_H
3
4#define OMAP_MMC_REG_CMD 0x00
5#define OMAP_MMC_REG_ARGL 0x04
6#define OMAP_MMC_REG_ARGH 0x08
7#define OMAP_MMC_REG_CON 0x0c
8#define OMAP_MMC_REG_STAT 0x10
9#define OMAP_MMC_REG_IE 0x14
10#define OMAP_MMC_REG_CTO 0x18
11#define OMAP_MMC_REG_DTO 0x1c
12#define OMAP_MMC_REG_DATA 0x20
13#define OMAP_MMC_REG_BLEN 0x24
14#define OMAP_MMC_REG_NBLK 0x28
15#define OMAP_MMC_REG_BUF 0x2c
16#define OMAP_MMC_REG_SDIO 0x34
17#define OMAP_MMC_REG_REV 0x3c
18#define OMAP_MMC_REG_RSP0 0x40
19#define OMAP_MMC_REG_RSP1 0x44
20#define OMAP_MMC_REG_RSP2 0x48
21#define OMAP_MMC_REG_RSP3 0x4c
22#define OMAP_MMC_REG_RSP4 0x50
23#define OMAP_MMC_REG_RSP5 0x54
24#define OMAP_MMC_REG_RSP6 0x58
25#define OMAP_MMC_REG_RSP7 0x5c
26#define OMAP_MMC_REG_IOSR 0x60
27#define OMAP_MMC_REG_SYSC 0x64
28#define OMAP_MMC_REG_SYSS 0x68
29
30#define OMAP_MMC_STAT_CARD_ERR (1 << 14)
31#define OMAP_MMC_STAT_CARD_IRQ (1 << 13)
32#define OMAP_MMC_STAT_OCR_BUSY (1 << 12)
33#define OMAP_MMC_STAT_A_EMPTY (1 << 11)
34#define OMAP_MMC_STAT_A_FULL (1 << 10)
35#define OMAP_MMC_STAT_CMD_CRC (1 << 8)
36#define OMAP_MMC_STAT_CMD_TOUT (1 << 7)
37#define OMAP_MMC_STAT_DATA_CRC (1 << 6)
38#define OMAP_MMC_STAT_DATA_TOUT (1 << 5)
39#define OMAP_MMC_STAT_END_BUSY (1 << 4)
40#define OMAP_MMC_STAT_END_OF_DATA (1 << 3)
41#define OMAP_MMC_STAT_CARD_BUSY (1 << 2)
42#define OMAP_MMC_STAT_END_OF_CMD (1 << 0)
43
44#define OMAP_MMC_READ(base, reg) __raw_readw((base) + OMAP_MMC_REG_##reg)
45#define OMAP_MMC_WRITE(base, reg, val) __raw_writew((val), (base) + OMAP_MMC_REG_##reg)
46
47/*
48 * Command types
49 */
50#define OMAP_MMC_CMDTYPE_BC 0
51#define OMAP_MMC_CMDTYPE_BCR 1
52#define OMAP_MMC_CMDTYPE_AC 2
53#define OMAP_MMC_CMDTYPE_ADTC 3
54
55#endif
diff --git a/drivers/mmc/pxamci.c b/drivers/mmc/pxamci.c
index a526698b8c91..471e9f4e0530 100644
--- a/drivers/mmc/pxamci.c
+++ b/drivers/mmc/pxamci.c
@@ -393,7 +393,7 @@ static void pxamci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
393 host->clkrt, host->cmdat); 393 host->clkrt, host->cmdat);
394} 394}
395 395
396static struct mmc_host_ops pxamci_ops = { 396static const struct mmc_host_ops pxamci_ops = {
397 .request = pxamci_request, 397 .request = pxamci_request,
398 .get_ro = pxamci_get_ro, 398 .get_ro = pxamci_get_ro,
399 .set_ios = pxamci_set_ios, 399 .set_ios = pxamci_set_ios,
diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
index 9a7d39b7cdbf..cd98117632d3 100644
--- a/drivers/mmc/sdhci.c
+++ b/drivers/mmc/sdhci.c
@@ -616,6 +616,7 @@ static void sdhci_finish_command(struct sdhci_host *host)
616static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock) 616static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
617{ 617{
618 int div; 618 int div;
619 u8 ctrl;
619 u16 clk; 620 u16 clk;
620 unsigned long timeout; 621 unsigned long timeout;
621 622
@@ -624,6 +625,13 @@ static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
624 625
625 writew(0, host->ioaddr + SDHCI_CLOCK_CONTROL); 626 writew(0, host->ioaddr + SDHCI_CLOCK_CONTROL);
626 627
628 ctrl = readb(host->ioaddr + SDHCI_HOST_CONTROL);
629 if (clock > 25000000)
630 ctrl |= SDHCI_CTRL_HISPD;
631 else
632 ctrl &= ~SDHCI_CTRL_HISPD;
633 writeb(ctrl, host->ioaddr + SDHCI_HOST_CONTROL);
634
627 if (clock == 0) 635 if (clock == 0)
628 goto out; 636 goto out;
629 637
@@ -784,7 +792,7 @@ static int sdhci_get_ro(struct mmc_host *mmc)
784 return !(present & SDHCI_WRITE_PROTECT); 792 return !(present & SDHCI_WRITE_PROTECT);
785} 793}
786 794
787static struct mmc_host_ops sdhci_ops = { 795static const struct mmc_host_ops sdhci_ops = {
788 .request = sdhci_request, 796 .request = sdhci_request,
789 .set_ios = sdhci_set_ios, 797 .set_ios = sdhci_set_ios,
790 .get_ro = sdhci_get_ro, 798 .get_ro = sdhci_get_ro,
@@ -1291,6 +1299,13 @@ static int __devinit sdhci_probe_slot(struct pci_dev *pdev, int slot)
1291 else if (caps & SDHCI_CAN_VDD_180) 1299 else if (caps & SDHCI_CAN_VDD_180)
1292 mmc->ocr_avail |= MMC_VDD_17_18|MMC_VDD_18_19; 1300 mmc->ocr_avail |= MMC_VDD_17_18|MMC_VDD_18_19;
1293 1301
1302 if ((host->max_clk > 25000000) && !(caps & SDHCI_CAN_DO_HISPD)) {
1303 printk(KERN_ERR "%s: Controller reports > 25 MHz base clock,"
1304 " but no high speed support.\n",
1305 host->slot_descr);
1306 mmc->f_max = 25000000;
1307 }
1308
1294 if (mmc->ocr_avail == 0) { 1309 if (mmc->ocr_avail == 0) {
1295 printk(KERN_ERR "%s: Hardware doesn't report any " 1310 printk(KERN_ERR "%s: Hardware doesn't report any "
1296 "support voltages.\n", host->slot_descr); 1311 "support voltages.\n", host->slot_descr);
diff --git a/drivers/mmc/sdhci.h b/drivers/mmc/sdhci.h
index 72a67937afe0..f9d1a0a6f03a 100644
--- a/drivers/mmc/sdhci.h
+++ b/drivers/mmc/sdhci.h
@@ -71,6 +71,7 @@
71#define SDHCI_HOST_CONTROL 0x28 71#define SDHCI_HOST_CONTROL 0x28
72#define SDHCI_CTRL_LED 0x01 72#define SDHCI_CTRL_LED 0x01
73#define SDHCI_CTRL_4BITBUS 0x02 73#define SDHCI_CTRL_4BITBUS 0x02
74#define SDHCI_CTRL_HISPD 0x04
74 75
75#define SDHCI_POWER_CONTROL 0x29 76#define SDHCI_POWER_CONTROL 0x29
76#define SDHCI_POWER_ON 0x01 77#define SDHCI_POWER_ON 0x01
@@ -138,6 +139,7 @@
138#define SDHCI_CLOCK_BASE_SHIFT 8 139#define SDHCI_CLOCK_BASE_SHIFT 8
139#define SDHCI_MAX_BLOCK_MASK 0x00030000 140#define SDHCI_MAX_BLOCK_MASK 0x00030000
140#define SDHCI_MAX_BLOCK_SHIFT 16 141#define SDHCI_MAX_BLOCK_SHIFT 16
142#define SDHCI_CAN_DO_HISPD 0x00200000
141#define SDHCI_CAN_DO_DMA 0x00400000 143#define SDHCI_CAN_DO_DMA 0x00400000
142#define SDHCI_CAN_VDD_330 0x01000000 144#define SDHCI_CAN_VDD_330 0x01000000
143#define SDHCI_CAN_VDD_300 0x02000000 145#define SDHCI_CAN_VDD_300 0x02000000
diff --git a/drivers/mmc/tifm_sd.c b/drivers/mmc/tifm_sd.c
index 0fdc55b08a6d..e846499a004c 100644
--- a/drivers/mmc/tifm_sd.c
+++ b/drivers/mmc/tifm_sd.c
@@ -99,7 +99,7 @@ struct tifm_sd {
99 99
100 struct mmc_request *req; 100 struct mmc_request *req;
101 struct work_struct cmd_handler; 101 struct work_struct cmd_handler;
102 struct work_struct abort_handler; 102 struct delayed_work abort_handler;
103 wait_queue_head_t can_eject; 103 wait_queue_head_t can_eject;
104 104
105 size_t written_blocks; 105 size_t written_blocks;
@@ -496,9 +496,9 @@ err_out:
496 mmc_request_done(mmc, mrq); 496 mmc_request_done(mmc, mrq);
497} 497}
498 498
499static void tifm_sd_end_cmd(void *data) 499static void tifm_sd_end_cmd(struct work_struct *work)
500{ 500{
501 struct tifm_sd *host = data; 501 struct tifm_sd *host = container_of(work, struct tifm_sd, cmd_handler);
502 struct tifm_dev *sock = host->dev; 502 struct tifm_dev *sock = host->dev;
503 struct mmc_host *mmc = tifm_get_drvdata(sock); 503 struct mmc_host *mmc = tifm_get_drvdata(sock);
504 struct mmc_request *mrq; 504 struct mmc_request *mrq;
@@ -608,9 +608,9 @@ err_out:
608 mmc_request_done(mmc, mrq); 608 mmc_request_done(mmc, mrq);
609} 609}
610 610
611static void tifm_sd_end_cmd_nodma(void *data) 611static void tifm_sd_end_cmd_nodma(struct work_struct *work)
612{ 612{
613 struct tifm_sd *host = (struct tifm_sd*)data; 613 struct tifm_sd *host = container_of(work, struct tifm_sd, cmd_handler);
614 struct tifm_dev *sock = host->dev; 614 struct tifm_dev *sock = host->dev;
615 struct mmc_host *mmc = tifm_get_drvdata(sock); 615 struct mmc_host *mmc = tifm_get_drvdata(sock);
616 struct mmc_request *mrq; 616 struct mmc_request *mrq;
@@ -661,11 +661,14 @@ static void tifm_sd_end_cmd_nodma(void *data)
661 mmc_request_done(mmc, mrq); 661 mmc_request_done(mmc, mrq);
662} 662}
663 663
664static void tifm_sd_abort(void *data) 664static void tifm_sd_abort(struct work_struct *work)
665{ 665{
666 struct tifm_sd *host =
667 container_of(work, struct tifm_sd, abort_handler.work);
668
666 printk(KERN_ERR DRIVER_NAME 669 printk(KERN_ERR DRIVER_NAME
667 ": card failed to respond for a long period of time"); 670 ": card failed to respond for a long period of time");
668 tifm_eject(((struct tifm_sd*)data)->dev); 671 tifm_eject(host->dev);
669} 672}
670 673
671static void tifm_sd_ios(struct mmc_host *mmc, struct mmc_ios *ios) 674static void tifm_sd_ios(struct mmc_host *mmc, struct mmc_ios *ios)
@@ -762,9 +765,9 @@ static struct mmc_host_ops tifm_sd_ops = {
762 .get_ro = tifm_sd_ro 765 .get_ro = tifm_sd_ro
763}; 766};
764 767
765static void tifm_sd_register_host(void *data) 768static void tifm_sd_register_host(struct work_struct *work)
766{ 769{
767 struct tifm_sd *host = (struct tifm_sd*)data; 770 struct tifm_sd *host = container_of(work, struct tifm_sd, cmd_handler);
768 struct tifm_dev *sock = host->dev; 771 struct tifm_dev *sock = host->dev;
769 struct mmc_host *mmc = tifm_get_drvdata(sock); 772 struct mmc_host *mmc = tifm_get_drvdata(sock);
770 unsigned long flags; 773 unsigned long flags;
@@ -772,8 +775,7 @@ static void tifm_sd_register_host(void *data)
772 spin_lock_irqsave(&sock->lock, flags); 775 spin_lock_irqsave(&sock->lock, flags);
773 host->flags |= HOST_REG; 776 host->flags |= HOST_REG;
774 PREPARE_WORK(&host->cmd_handler, 777 PREPARE_WORK(&host->cmd_handler,
775 no_dma ? tifm_sd_end_cmd_nodma : tifm_sd_end_cmd, 778 no_dma ? tifm_sd_end_cmd_nodma : tifm_sd_end_cmd);
776 data);
777 spin_unlock_irqrestore(&sock->lock, flags); 779 spin_unlock_irqrestore(&sock->lock, flags);
778 dev_dbg(&sock->dev, "adding host\n"); 780 dev_dbg(&sock->dev, "adding host\n");
779 mmc_add_host(mmc); 781 mmc_add_host(mmc);
@@ -799,8 +801,8 @@ static int tifm_sd_probe(struct tifm_dev *sock)
799 host->dev = sock; 801 host->dev = sock;
800 host->clk_div = 61; 802 host->clk_div = 61;
801 init_waitqueue_head(&host->can_eject); 803 init_waitqueue_head(&host->can_eject);
802 INIT_WORK(&host->cmd_handler, tifm_sd_register_host, host); 804 INIT_WORK(&host->cmd_handler, tifm_sd_register_host);
803 INIT_WORK(&host->abort_handler, tifm_sd_abort, host); 805 INIT_DELAYED_WORK(&host->abort_handler, tifm_sd_abort);
804 806
805 tifm_set_drvdata(sock, mmc); 807 tifm_set_drvdata(sock, mmc);
806 sock->signal_irq = tifm_sd_signal_irq; 808 sock->signal_irq = tifm_sd_signal_irq;
diff --git a/drivers/mmc/wbsd.c b/drivers/mmc/wbsd.c
index ced309b37a8f..7a282672f8e9 100644
--- a/drivers/mmc/wbsd.c
+++ b/drivers/mmc/wbsd.c
@@ -1021,7 +1021,7 @@ static int wbsd_get_ro(struct mmc_host *mmc)
1021 return csr & WBSD_WRPT; 1021 return csr & WBSD_WRPT;
1022} 1022}
1023 1023
1024static struct mmc_host_ops wbsd_ops = { 1024static const struct mmc_host_ops wbsd_ops = {
1025 .request = wbsd_request, 1025 .request = wbsd_request,
1026 .set_ios = wbsd_set_ios, 1026 .set_ios = wbsd_set_ios,
1027 .get_ro = wbsd_get_ro, 1027 .get_ro = wbsd_get_ro,
@@ -1488,7 +1488,7 @@ static void __devinit wbsd_request_dma(struct wbsd_host *host, int dma)
1488 /* 1488 /*
1489 * Translate the address to a physical address. 1489 * Translate the address to a physical address.
1490 */ 1490 */
1491 host->dma_addr = dma_map_single(host->mmc->dev, host->dma_buffer, 1491 host->dma_addr = dma_map_single(mmc_dev(host->mmc), host->dma_buffer,
1492 WBSD_DMA_SIZE, DMA_BIDIRECTIONAL); 1492 WBSD_DMA_SIZE, DMA_BIDIRECTIONAL);
1493 1493
1494 /* 1494 /*
@@ -1512,7 +1512,7 @@ kfree:
1512 */ 1512 */
1513 BUG_ON(1); 1513 BUG_ON(1);
1514 1514
1515 dma_unmap_single(host->mmc->dev, host->dma_addr, 1515 dma_unmap_single(mmc_dev(host->mmc), host->dma_addr,
1516 WBSD_DMA_SIZE, DMA_BIDIRECTIONAL); 1516 WBSD_DMA_SIZE, DMA_BIDIRECTIONAL);
1517 host->dma_addr = (dma_addr_t)NULL; 1517 host->dma_addr = (dma_addr_t)NULL;
1518 1518
@@ -1530,7 +1530,7 @@ err:
1530static void __devexit wbsd_release_dma(struct wbsd_host *host) 1530static void __devexit wbsd_release_dma(struct wbsd_host *host)
1531{ 1531{
1532 if (host->dma_addr) { 1532 if (host->dma_addr) {
1533 dma_unmap_single(host->mmc->dev, host->dma_addr, 1533 dma_unmap_single(mmc_dev(host->mmc), host->dma_addr,
1534 WBSD_DMA_SIZE, DMA_BIDIRECTIONAL); 1534 WBSD_DMA_SIZE, DMA_BIDIRECTIONAL);
1535 } 1535 }
1536 kfree(host->dma_buffer); 1536 kfree(host->dma_buffer);
diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c
index 7ea49a0d5ec3..296159ec5189 100644
--- a/drivers/mtd/chips/cfi_cmdset_0001.c
+++ b/drivers/mtd/chips/cfi_cmdset_0001.c
@@ -1087,7 +1087,7 @@ static int inval_cache_and_wait_for_operation(
1087 } 1087 }
1088 spin_lock(chip->mutex); 1088 spin_lock(chip->mutex);
1089 1089
1090 if (chip->state != chip_state) { 1090 while (chip->state != chip_state) {
1091 /* Someone's suspended the operation: sleep */ 1091 /* Someone's suspended the operation: sleep */
1092 DECLARE_WAITQUEUE(wait, current); 1092 DECLARE_WAITQUEUE(wait, current);
1093 set_current_state(TASK_UNINTERRUPTIBLE); 1093 set_current_state(TASK_UNINTERRUPTIBLE);
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index ef4a731ca5c2..334e078ffaff 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -451,7 +451,7 @@ static int __devinit m25p_probe(struct spi_device *spi)
451 return -ENODEV; 451 return -ENODEV;
452 } 452 }
453 453
454 flash = kzalloc(sizeof *flash, SLAB_KERNEL); 454 flash = kzalloc(sizeof *flash, GFP_KERNEL);
455 if (!flash) 455 if (!flash)
456 return -ENOMEM; 456 return -ENOMEM;
457 457
diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig
index 24747bdc3e19..d132ed571f13 100644
--- a/drivers/mtd/maps/Kconfig
+++ b/drivers/mtd/maps/Kconfig
@@ -607,7 +607,7 @@ config MTD_BAST_MAXSIZE
607 default "4" 607 default "4"
608 608
609config MTD_SHARP_SL 609config MTD_SHARP_SL
610 bool "ROM maped on Sharp SL Series" 610 bool "ROM mapped on Sharp SL Series"
611 depends on MTD && ARCH_PXA 611 depends on MTD && ARCH_PXA
612 help 612 help
613 This enables access to the flash chip on the Sharp SL Series of PDAs. 613 This enables access to the flash chip on the Sharp SL Series of PDAs.
diff --git a/drivers/mtd/maps/cfi_flagadm.c b/drivers/mtd/maps/cfi_flagadm.c
index 92b5d883d7b0..65e5ee552010 100644
--- a/drivers/mtd/maps/cfi_flagadm.c
+++ b/drivers/mtd/maps/cfi_flagadm.c
@@ -80,7 +80,7 @@ struct mtd_partition flagadm_parts[] = {
80 .size = FLASH_PARTITION2_SIZE 80 .size = FLASH_PARTITION2_SIZE
81 }, 81 },
82 { 82 {
83 .name = "Persistant storage", 83 .name = "Persistent storage",
84 .offset = FLASH_PARTITION3_ADDR, 84 .offset = FLASH_PARTITION3_ADDR,
85 .size = FLASH_PARTITION3_SIZE 85 .size = FLASH_PARTITION3_SIZE
86 } 86 }
diff --git a/drivers/net/3c501.c b/drivers/net/3c501.c
index 11d170afa9c3..06e33786078d 100644
--- a/drivers/net/3c501.c
+++ b/drivers/net/3c501.c
@@ -922,7 +922,7 @@ int __init init_module(void)
922 * and then free up the resources we took when the card was found. 922 * and then free up the resources we took when the card was found.
923 */ 923 */
924 924
925void cleanup_module(void) 925void __exit cleanup_module(void)
926{ 926{
927 struct net_device *dev = dev_3c501; 927 struct net_device *dev = dev_3c501;
928 unregister_netdev(dev); 928 unregister_netdev(dev);
diff --git a/drivers/net/3c503.c b/drivers/net/3c503.c
index a34b2206132d..7e34c4f07b70 100644
--- a/drivers/net/3c503.c
+++ b/drivers/net/3c503.c
@@ -726,7 +726,7 @@ static void cleanup_card(struct net_device *dev)
726 iounmap(ei_status.mem); 726 iounmap(ei_status.mem);
727} 727}
728 728
729void 729void __exit
730cleanup_module(void) 730cleanup_module(void)
731{ 731{
732 int this_dev; 732 int this_dev;
diff --git a/drivers/net/3c505.c b/drivers/net/3c505.c
index 458cb9cbe915..702bfb2a5e99 100644
--- a/drivers/net/3c505.c
+++ b/drivers/net/3c505.c
@@ -1670,7 +1670,7 @@ int __init init_module(void)
1670 return 0; 1670 return 0;
1671} 1671}
1672 1672
1673void cleanup_module(void) 1673void __exit cleanup_module(void)
1674{ 1674{
1675 int this_dev; 1675 int this_dev;
1676 1676
diff --git a/drivers/net/3c507.c b/drivers/net/3c507.c
index aa43563610ae..54e1d5aebed3 100644
--- a/drivers/net/3c507.c
+++ b/drivers/net/3c507.c
@@ -940,7 +940,7 @@ int __init init_module(void)
940 return IS_ERR(dev_3c507) ? PTR_ERR(dev_3c507) : 0; 940 return IS_ERR(dev_3c507) ? PTR_ERR(dev_3c507) : 0;
941} 941}
942 942
943void 943void __exit
944cleanup_module(void) 944cleanup_module(void)
945{ 945{
946 struct net_device *dev = dev_3c507; 946 struct net_device *dev = dev_3c507;
diff --git a/drivers/net/3c523.c b/drivers/net/3c523.c
index 91849469b4f4..17d61eb0a7e5 100644
--- a/drivers/net/3c523.c
+++ b/drivers/net/3c523.c
@@ -1302,7 +1302,7 @@ int __init init_module(void)
1302 } else return 0; 1302 } else return 0;
1303} 1303}
1304 1304
1305void cleanup_module(void) 1305void __exit cleanup_module(void)
1306{ 1306{
1307 int this_dev; 1307 int this_dev;
1308 for (this_dev=0; this_dev<MAX_3C523_CARDS; this_dev++) { 1308 for (this_dev=0; this_dev<MAX_3C523_CARDS; this_dev++) {
diff --git a/drivers/net/3c527.c b/drivers/net/3c527.c
index f4aca5386add..6c7437e60bd2 100644
--- a/drivers/net/3c527.c
+++ b/drivers/net/3c527.c
@@ -1659,7 +1659,7 @@ int __init init_module(void)
1659 * transmit operations are allowed to start scribbling into memory. 1659 * transmit operations are allowed to start scribbling into memory.
1660 */ 1660 */
1661 1661
1662void cleanup_module(void) 1662void __exit cleanup_module(void)
1663{ 1663{
1664 unregister_netdev(this_device); 1664 unregister_netdev(this_device);
1665 cleanup_card(this_device); 1665 cleanup_card(this_device);
diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c
index d02ed51abfcc..931028f672de 100644
--- a/drivers/net/8139too.c
+++ b/drivers/net/8139too.c
@@ -594,7 +594,7 @@ struct rtl8139_private {
594 u32 rx_config; 594 u32 rx_config;
595 struct rtl_extra_stats xstats; 595 struct rtl_extra_stats xstats;
596 596
597 struct work_struct thread; 597 struct delayed_work thread;
598 598
599 struct mii_if_info mii; 599 struct mii_if_info mii;
600 unsigned int regs_len; 600 unsigned int regs_len;
@@ -636,8 +636,8 @@ static struct net_device_stats *rtl8139_get_stats (struct net_device *dev);
636static void rtl8139_set_rx_mode (struct net_device *dev); 636static void rtl8139_set_rx_mode (struct net_device *dev);
637static void __set_rx_mode (struct net_device *dev); 637static void __set_rx_mode (struct net_device *dev);
638static void rtl8139_hw_start (struct net_device *dev); 638static void rtl8139_hw_start (struct net_device *dev);
639static void rtl8139_thread (void *_data); 639static void rtl8139_thread (struct work_struct *work);
640static void rtl8139_tx_timeout_task(void *_data); 640static void rtl8139_tx_timeout_task(struct work_struct *work);
641static const struct ethtool_ops rtl8139_ethtool_ops; 641static const struct ethtool_ops rtl8139_ethtool_ops;
642 642
643/* write MMIO register, with flush */ 643/* write MMIO register, with flush */
@@ -1010,7 +1010,7 @@ static int __devinit rtl8139_init_one (struct pci_dev *pdev,
1010 (debug < 0 ? RTL8139_DEF_MSG_ENABLE : ((1 << debug) - 1)); 1010 (debug < 0 ? RTL8139_DEF_MSG_ENABLE : ((1 << debug) - 1));
1011 spin_lock_init (&tp->lock); 1011 spin_lock_init (&tp->lock);
1012 spin_lock_init (&tp->rx_lock); 1012 spin_lock_init (&tp->rx_lock);
1013 INIT_WORK(&tp->thread, rtl8139_thread, dev); 1013 INIT_DELAYED_WORK(&tp->thread, rtl8139_thread);
1014 tp->mii.dev = dev; 1014 tp->mii.dev = dev;
1015 tp->mii.mdio_read = mdio_read; 1015 tp->mii.mdio_read = mdio_read;
1016 tp->mii.mdio_write = mdio_write; 1016 tp->mii.mdio_write = mdio_write;
@@ -1596,15 +1596,16 @@ static inline void rtl8139_thread_iter (struct net_device *dev,
1596 RTL_R8 (Config1)); 1596 RTL_R8 (Config1));
1597} 1597}
1598 1598
1599static void rtl8139_thread (void *_data) 1599static void rtl8139_thread (struct work_struct *work)
1600{ 1600{
1601 struct net_device *dev = _data; 1601 struct rtl8139_private *tp =
1602 struct rtl8139_private *tp = netdev_priv(dev); 1602 container_of(work, struct rtl8139_private, thread.work);
1603 struct net_device *dev = tp->mii.dev;
1603 unsigned long thr_delay = next_tick; 1604 unsigned long thr_delay = next_tick;
1604 1605
1605 if (tp->watchdog_fired) { 1606 if (tp->watchdog_fired) {
1606 tp->watchdog_fired = 0; 1607 tp->watchdog_fired = 0;
1607 rtl8139_tx_timeout_task(_data); 1608 rtl8139_tx_timeout_task(work);
1608 } else if (rtnl_trylock()) { 1609 } else if (rtnl_trylock()) {
1609 rtl8139_thread_iter (dev, tp, tp->mmio_addr); 1610 rtl8139_thread_iter (dev, tp, tp->mmio_addr);
1610 rtnl_unlock (); 1611 rtnl_unlock ();
@@ -1646,10 +1647,11 @@ static inline void rtl8139_tx_clear (struct rtl8139_private *tp)
1646 /* XXX account for unsent Tx packets in tp->stats.tx_dropped */ 1647 /* XXX account for unsent Tx packets in tp->stats.tx_dropped */
1647} 1648}
1648 1649
1649static void rtl8139_tx_timeout_task (void *_data) 1650static void rtl8139_tx_timeout_task (struct work_struct *work)
1650{ 1651{
1651 struct net_device *dev = _data; 1652 struct rtl8139_private *tp =
1652 struct rtl8139_private *tp = netdev_priv(dev); 1653 container_of(work, struct rtl8139_private, thread.work);
1654 struct net_device *dev = tp->mii.dev;
1653 void __iomem *ioaddr = tp->mmio_addr; 1655 void __iomem *ioaddr = tp->mmio_addr;
1654 int i; 1656 int i;
1655 u8 tmp8; 1657 u8 tmp8;
@@ -1695,7 +1697,7 @@ static void rtl8139_tx_timeout (struct net_device *dev)
1695 struct rtl8139_private *tp = netdev_priv(dev); 1697 struct rtl8139_private *tp = netdev_priv(dev);
1696 1698
1697 if (!tp->have_thread) { 1699 if (!tp->have_thread) {
1698 INIT_WORK(&tp->thread, rtl8139_tx_timeout_task, dev); 1700 INIT_DELAYED_WORK(&tp->thread, rtl8139_tx_timeout_task);
1699 schedule_delayed_work(&tp->thread, next_tick); 1701 schedule_delayed_work(&tp->thread, next_tick);
1700 } else 1702 } else
1701 tp->watchdog_fired = 1; 1703 tp->watchdog_fired = 1;
diff --git a/drivers/net/8390.c b/drivers/net/8390.c
index 3d1c599ac3cb..a82807641dcf 100644
--- a/drivers/net/8390.c
+++ b/drivers/net/8390.c
@@ -1,1104 +1,40 @@
1/* 8390.c: A general NS8390 ethernet driver core for linux. */ 1/* 8390 core for usual drivers */
2/*
3 Written 1992-94 by Donald Becker.
4
5 Copyright 1993 United States Government as represented by the
6 Director, National Security Agency.
7
8 This software may be used and distributed according to the terms
9 of the GNU General Public License, incorporated herein by reference.
10
11 The author may be reached as becker@scyld.com, or C/O
12 Scyld Computing Corporation
13 410 Severn Ave., Suite 210
14 Annapolis MD 21403
15
16
17 This is the chip-specific code for many 8390-based ethernet adaptors.
18 This is not a complete driver, it must be combined with board-specific
19 code such as ne.c, wd.c, 3c503.c, etc.
20
21 Seeing how at least eight drivers use this code, (not counting the
22 PCMCIA ones either) it is easy to break some card by what seems like
23 a simple innocent change. Please contact me or Donald if you think
24 you have found something that needs changing. -- PG
25
26
27 Changelog:
28
29 Paul Gortmaker : remove set_bit lock, other cleanups.
30 Paul Gortmaker : add ei_get_8390_hdr() so we can pass skb's to
31 ei_block_input() for eth_io_copy_and_sum().
32 Paul Gortmaker : exchange static int ei_pingpong for a #define,
33 also add better Tx error handling.
34 Paul Gortmaker : rewrite Rx overrun handling as per NS specs.
35 Alexey Kuznetsov : use the 8390's six bit hash multicast filter.
36 Paul Gortmaker : tweak ANK's above multicast changes a bit.
37 Paul Gortmaker : update packet statistics for v2.1.x
38 Alan Cox : support arbitary stupid port mappings on the
39 68K Macintosh. Support >16bit I/O spaces
40 Paul Gortmaker : add kmod support for auto-loading of the 8390
41 module by all drivers that require it.
42 Alan Cox : Spinlocking work, added 'BUG_83C690'
43 Paul Gortmaker : Separate out Tx timeout code from Tx path.
44 Paul Gortmaker : Remove old unused single Tx buffer code.
45 Hayato Fujiwara : Add m32r support.
46 Paul Gortmaker : use skb_padto() instead of stack scratch area
47
48 Sources:
49 The National Semiconductor LAN Databook, and the 3Com 3c503 databook.
50
51 */
52 2
53static const char version[] = 3static const char version[] =
54 "8390.c:v1.10cvs 9/23/94 Donald Becker (becker@cesdis.gsfc.nasa.gov)\n"; 4 "8390.c:v1.10cvs 9/23/94 Donald Becker (becker@cesdis.gsfc.nasa.gov)\n";
55 5
56#include <linux/module.h> 6#include "lib8390.c"
57#include <linux/kernel.h>
58#include <linux/jiffies.h>
59#include <linux/fs.h>
60#include <linux/types.h>
61#include <linux/string.h>
62#include <linux/bitops.h>
63#include <asm/system.h>
64#include <asm/uaccess.h>
65#include <asm/io.h>
66#include <asm/irq.h>
67#include <linux/delay.h>
68#include <linux/errno.h>
69#include <linux/fcntl.h>
70#include <linux/in.h>
71#include <linux/interrupt.h>
72#include <linux/init.h>
73#include <linux/crc32.h>
74
75#include <linux/netdevice.h>
76#include <linux/etherdevice.h>
77
78#define NS8390_CORE
79#include "8390.h"
80
81#define BUG_83C690
82
83/* These are the operational function interfaces to board-specific
84 routines.
85 void reset_8390(struct net_device *dev)
86 Resets the board associated with DEV, including a hardware reset of
87 the 8390. This is only called when there is a transmit timeout, and
88 it is always followed by 8390_init().
89 void block_output(struct net_device *dev, int count, const unsigned char *buf,
90 int start_page)
91 Write the COUNT bytes of BUF to the packet buffer at START_PAGE. The
92 "page" value uses the 8390's 256-byte pages.
93 void get_8390_hdr(struct net_device *dev, struct e8390_hdr *hdr, int ring_page)
94 Read the 4 byte, page aligned 8390 header. *If* there is a
95 subsequent read, it will be of the rest of the packet.
96 void block_input(struct net_device *dev, int count, struct sk_buff *skb, int ring_offset)
97 Read COUNT bytes from the packet buffer into the skb data area. Start
98 reading from RING_OFFSET, the address as the 8390 sees it. This will always
99 follow the read of the 8390 header.
100*/
101#define ei_reset_8390 (ei_local->reset_8390)
102#define ei_block_output (ei_local->block_output)
103#define ei_block_input (ei_local->block_input)
104#define ei_get_8390_hdr (ei_local->get_8390_hdr)
105
106/* use 0 for production, 1 for verification, >2 for debug */
107#ifndef ei_debug
108int ei_debug = 1;
109#endif
110
111/* Index to functions. */
112static void ei_tx_intr(struct net_device *dev);
113static void ei_tx_err(struct net_device *dev);
114static void ei_tx_timeout(struct net_device *dev);
115static void ei_receive(struct net_device *dev);
116static void ei_rx_overrun(struct net_device *dev);
117
118/* Routines generic to NS8390-based boards. */
119static void NS8390_trigger_send(struct net_device *dev, unsigned int length,
120 int start_page);
121static void set_multicast_list(struct net_device *dev);
122static void do_set_multicast_list(struct net_device *dev);
123
124/*
125 * SMP and the 8390 setup.
126 *
127 * The 8390 isnt exactly designed to be multithreaded on RX/TX. There is
128 * a page register that controls bank and packet buffer access. We guard
129 * this with ei_local->page_lock. Nobody should assume or set the page other
130 * than zero when the lock is not held. Lock holders must restore page 0
131 * before unlocking. Even pure readers must take the lock to protect in
132 * page 0.
133 *
134 * To make life difficult the chip can also be very slow. We therefore can't
135 * just use spinlocks. For the longer lockups we disable the irq the device
136 * sits on and hold the lock. We must hold the lock because there is a dual
137 * processor case other than interrupts (get stats/set multicast list in
138 * parallel with each other and transmit).
139 *
140 * Note: in theory we can just disable the irq on the card _but_ there is
141 * a latency on SMP irq delivery. So we can easily go "disable irq" "sync irqs"
142 * enter lock, take the queued irq. So we waddle instead of flying.
143 *
144 * Finally by special arrangement for the purpose of being generally
145 * annoying the transmit function is called bh atomic. That places
146 * restrictions on the user context callers as disable_irq won't save
147 * them.
148 */
149
150
151 7
152/**
153 * ei_open - Open/initialize the board.
154 * @dev: network device to initialize
155 *
156 * This routine goes all-out, setting everything
157 * up anew at each open, even though many of these registers should only
158 * need to be set once at boot.
159 */
160int ei_open(struct net_device *dev) 8int ei_open(struct net_device *dev)
161{ 9{
162 unsigned long flags; 10 return __ei_open(dev);
163 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
164
165 /* The card I/O part of the driver (e.g. 3c503) can hook a Tx timeout
166 wrapper that does e.g. media check & then calls ei_tx_timeout. */
167 if (dev->tx_timeout == NULL)
168 dev->tx_timeout = ei_tx_timeout;
169 if (dev->watchdog_timeo <= 0)
170 dev->watchdog_timeo = TX_TIMEOUT;
171
172 /*
173 * Grab the page lock so we own the register set, then call
174 * the init function.
175 */
176
177 spin_lock_irqsave(&ei_local->page_lock, flags);
178 NS8390_init(dev, 1);
179 /* Set the flag before we drop the lock, That way the IRQ arrives
180 after its set and we get no silly warnings */
181 netif_start_queue(dev);
182 spin_unlock_irqrestore(&ei_local->page_lock, flags);
183 ei_local->irqlock = 0;
184 return 0;
185} 11}
186 12
187/**
188 * ei_close - shut down network device
189 * @dev: network device to close
190 *
191 * Opposite of ei_open(). Only used when "ifconfig <devname> down" is done.
192 */
193int ei_close(struct net_device *dev) 13int ei_close(struct net_device *dev)
194{ 14{
195 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev); 15 return __ei_close(dev);
196 unsigned long flags;
197
198 /*
199 * Hold the page lock during close
200 */
201
202 spin_lock_irqsave(&ei_local->page_lock, flags);
203 NS8390_init(dev, 0);
204 spin_unlock_irqrestore(&ei_local->page_lock, flags);
205 netif_stop_queue(dev);
206 return 0;
207}
208
209/**
210 * ei_tx_timeout - handle transmit time out condition
211 * @dev: network device which has apparently fallen asleep
212 *
213 * Called by kernel when device never acknowledges a transmit has
214 * completed (or failed) - i.e. never posted a Tx related interrupt.
215 */
216
217void ei_tx_timeout(struct net_device *dev)
218{
219 long e8390_base = dev->base_addr;
220 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
221 int txsr, isr, tickssofar = jiffies - dev->trans_start;
222 unsigned long flags;
223
224#if defined(CONFIG_M32R) && defined(CONFIG_SMP)
225 unsigned long icucr;
226
227 local_irq_save(flags);
228 icucr = inl(M32R_ICU_CR1_PORTL);
229 icucr |= M32R_ICUCR_ISMOD11;
230 outl(icucr, M32R_ICU_CR1_PORTL);
231 local_irq_restore(flags);
232#endif
233 ei_local->stat.tx_errors++;
234
235 spin_lock_irqsave(&ei_local->page_lock, flags);
236 txsr = inb(e8390_base+EN0_TSR);
237 isr = inb(e8390_base+EN0_ISR);
238 spin_unlock_irqrestore(&ei_local->page_lock, flags);
239
240 printk(KERN_DEBUG "%s: Tx timed out, %s TSR=%#2x, ISR=%#2x, t=%d.\n",
241 dev->name, (txsr & ENTSR_ABT) ? "excess collisions." :
242 (isr) ? "lost interrupt?" : "cable problem?", txsr, isr, tickssofar);
243
244 if (!isr && !ei_local->stat.tx_packets)
245 {
246 /* The 8390 probably hasn't gotten on the cable yet. */
247 ei_local->interface_num ^= 1; /* Try a different xcvr. */
248 }
249
250 /* Ugly but a reset can be slow, yet must be protected */
251
252 disable_irq_nosync_lockdep(dev->irq);
253 spin_lock(&ei_local->page_lock);
254
255 /* Try to restart the card. Perhaps the user has fixed something. */
256 ei_reset_8390(dev);
257 NS8390_init(dev, 1);
258
259 spin_unlock(&ei_local->page_lock);
260 enable_irq_lockdep(dev->irq);
261 netif_wake_queue(dev);
262}
263
264/**
265 * ei_start_xmit - begin packet transmission
266 * @skb: packet to be sent
267 * @dev: network device to which packet is sent
268 *
269 * Sends a packet to an 8390 network device.
270 */
271
272static int ei_start_xmit(struct sk_buff *skb, struct net_device *dev)
273{
274 long e8390_base = dev->base_addr;
275 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
276 int send_length = skb->len, output_page;
277 unsigned long flags;
278 char buf[ETH_ZLEN];
279 char *data = skb->data;
280
281 if (skb->len < ETH_ZLEN) {
282 memset(buf, 0, ETH_ZLEN); /* more efficient than doing just the needed bits */
283 memcpy(buf, data, skb->len);
284 send_length = ETH_ZLEN;
285 data = buf;
286 }
287
288 /* Mask interrupts from the ethercard.
289 SMP: We have to grab the lock here otherwise the IRQ handler
290 on another CPU can flip window and race the IRQ mask set. We end
291 up trashing the mcast filter not disabling irqs if we don't lock */
292
293 spin_lock_irqsave(&ei_local->page_lock, flags);
294 outb_p(0x00, e8390_base + EN0_IMR);
295 spin_unlock_irqrestore(&ei_local->page_lock, flags);
296
297
298 /*
299 * Slow phase with lock held.
300 */
301
302 disable_irq_nosync_lockdep_irqsave(dev->irq, &flags);
303
304 spin_lock(&ei_local->page_lock);
305
306 ei_local->irqlock = 1;
307
308 /*
309 * We have two Tx slots available for use. Find the first free
310 * slot, and then perform some sanity checks. With two Tx bufs,
311 * you get very close to transmitting back-to-back packets. With
312 * only one Tx buf, the transmitter sits idle while you reload the
313 * card, leaving a substantial gap between each transmitted packet.
314 */
315
316 if (ei_local->tx1 == 0)
317 {
318 output_page = ei_local->tx_start_page;
319 ei_local->tx1 = send_length;
320 if (ei_debug && ei_local->tx2 > 0)
321 printk(KERN_DEBUG "%s: idle transmitter tx2=%d, lasttx=%d, txing=%d.\n",
322 dev->name, ei_local->tx2, ei_local->lasttx, ei_local->txing);
323 }
324 else if (ei_local->tx2 == 0)
325 {
326 output_page = ei_local->tx_start_page + TX_PAGES/2;
327 ei_local->tx2 = send_length;
328 if (ei_debug && ei_local->tx1 > 0)
329 printk(KERN_DEBUG "%s: idle transmitter, tx1=%d, lasttx=%d, txing=%d.\n",
330 dev->name, ei_local->tx1, ei_local->lasttx, ei_local->txing);
331 }
332 else
333 { /* We should never get here. */
334 if (ei_debug)
335 printk(KERN_DEBUG "%s: No Tx buffers free! tx1=%d tx2=%d last=%d\n",
336 dev->name, ei_local->tx1, ei_local->tx2, ei_local->lasttx);
337 ei_local->irqlock = 0;
338 netif_stop_queue(dev);
339 outb_p(ENISR_ALL, e8390_base + EN0_IMR);
340 spin_unlock(&ei_local->page_lock);
341 enable_irq_lockdep_irqrestore(dev->irq, &flags);
342 ei_local->stat.tx_errors++;
343 return 1;
344 }
345
346 /*
347 * Okay, now upload the packet and trigger a send if the transmitter
348 * isn't already sending. If it is busy, the interrupt handler will
349 * trigger the send later, upon receiving a Tx done interrupt.
350 */
351
352 ei_block_output(dev, send_length, data, output_page);
353
354 if (! ei_local->txing)
355 {
356 ei_local->txing = 1;
357 NS8390_trigger_send(dev, send_length, output_page);
358 dev->trans_start = jiffies;
359 if (output_page == ei_local->tx_start_page)
360 {
361 ei_local->tx1 = -1;
362 ei_local->lasttx = -1;
363 }
364 else
365 {
366 ei_local->tx2 = -1;
367 ei_local->lasttx = -2;
368 }
369 }
370 else ei_local->txqueue++;
371
372 if (ei_local->tx1 && ei_local->tx2)
373 netif_stop_queue(dev);
374 else
375 netif_start_queue(dev);
376
377 /* Turn 8390 interrupts back on. */
378 ei_local->irqlock = 0;
379 outb_p(ENISR_ALL, e8390_base + EN0_IMR);
380
381 spin_unlock(&ei_local->page_lock);
382 enable_irq_lockdep_irqrestore(dev->irq, &flags);
383
384 dev_kfree_skb (skb);
385 ei_local->stat.tx_bytes += send_length;
386
387 return 0;
388} 16}
389 17
390/**
391 * ei_interrupt - handle the interrupts from an 8390
392 * @irq: interrupt number
393 * @dev_id: a pointer to the net_device
394 *
395 * Handle the ether interface interrupts. We pull packets from
396 * the 8390 via the card specific functions and fire them at the networking
397 * stack. We also handle transmit completions and wake the transmit path if
398 * necessary. We also update the counters and do other housekeeping as
399 * needed.
400 */
401
402irqreturn_t ei_interrupt(int irq, void *dev_id) 18irqreturn_t ei_interrupt(int irq, void *dev_id)
403{ 19{
404 struct net_device *dev = dev_id; 20 return __ei_interrupt(irq, dev_id);
405 long e8390_base;
406 int interrupts, nr_serviced = 0;
407 struct ei_device *ei_local;
408
409 e8390_base = dev->base_addr;
410 ei_local = netdev_priv(dev);
411
412 /*
413 * Protect the irq test too.
414 */
415
416 spin_lock(&ei_local->page_lock);
417
418 if (ei_local->irqlock)
419 {
420#if 1 /* This might just be an interrupt for a PCI device sharing this line */
421 /* The "irqlock" check is only for testing. */
422 printk(ei_local->irqlock
423 ? "%s: Interrupted while interrupts are masked! isr=%#2x imr=%#2x.\n"
424 : "%s: Reentering the interrupt handler! isr=%#2x imr=%#2x.\n",
425 dev->name, inb_p(e8390_base + EN0_ISR),
426 inb_p(e8390_base + EN0_IMR));
427#endif
428 spin_unlock(&ei_local->page_lock);
429 return IRQ_NONE;
430 }
431
432 /* Change to page 0 and read the intr status reg. */
433 outb_p(E8390_NODMA+E8390_PAGE0, e8390_base + E8390_CMD);
434 if (ei_debug > 3)
435 printk(KERN_DEBUG "%s: interrupt(isr=%#2.2x).\n", dev->name,
436 inb_p(e8390_base + EN0_ISR));
437
438 /* !!Assumption!! -- we stay in page 0. Don't break this. */
439 while ((interrupts = inb_p(e8390_base + EN0_ISR)) != 0
440 && ++nr_serviced < MAX_SERVICE)
441 {
442 if (!netif_running(dev)) {
443 printk(KERN_WARNING "%s: interrupt from stopped card\n", dev->name);
444 /* rmk - acknowledge the interrupts */
445 outb_p(interrupts, e8390_base + EN0_ISR);
446 interrupts = 0;
447 break;
448 }
449 if (interrupts & ENISR_OVER)
450 ei_rx_overrun(dev);
451 else if (interrupts & (ENISR_RX+ENISR_RX_ERR))
452 {
453 /* Got a good (?) packet. */
454 ei_receive(dev);
455 }
456 /* Push the next to-transmit packet through. */
457 if (interrupts & ENISR_TX)
458 ei_tx_intr(dev);
459 else if (interrupts & ENISR_TX_ERR)
460 ei_tx_err(dev);
461
462 if (interrupts & ENISR_COUNTERS)
463 {
464 ei_local->stat.rx_frame_errors += inb_p(e8390_base + EN0_COUNTER0);
465 ei_local->stat.rx_crc_errors += inb_p(e8390_base + EN0_COUNTER1);
466 ei_local->stat.rx_missed_errors+= inb_p(e8390_base + EN0_COUNTER2);
467 outb_p(ENISR_COUNTERS, e8390_base + EN0_ISR); /* Ack intr. */
468 }
469
470 /* Ignore any RDC interrupts that make it back to here. */
471 if (interrupts & ENISR_RDC)
472 {
473 outb_p(ENISR_RDC, e8390_base + EN0_ISR);
474 }
475
476 outb_p(E8390_NODMA+E8390_PAGE0+E8390_START, e8390_base + E8390_CMD);
477 }
478
479 if (interrupts && ei_debug)
480 {
481 outb_p(E8390_NODMA+E8390_PAGE0+E8390_START, e8390_base + E8390_CMD);
482 if (nr_serviced >= MAX_SERVICE)
483 {
484 /* 0xFF is valid for a card removal */
485 if(interrupts!=0xFF)
486 printk(KERN_WARNING "%s: Too much work at interrupt, status %#2.2x\n",
487 dev->name, interrupts);
488 outb_p(ENISR_ALL, e8390_base + EN0_ISR); /* Ack. most intrs. */
489 } else {
490 printk(KERN_WARNING "%s: unknown interrupt %#2x\n", dev->name, interrupts);
491 outb_p(0xff, e8390_base + EN0_ISR); /* Ack. all intrs. */
492 }
493 }
494 spin_unlock(&ei_local->page_lock);
495 return IRQ_RETVAL(nr_serviced > 0);
496} 21}
497 22
498#ifdef CONFIG_NET_POLL_CONTROLLER 23#ifdef CONFIG_NET_POLL_CONTROLLER
499void ei_poll(struct net_device *dev) 24void ei_poll(struct net_device *dev)
500{ 25{
501 disable_irq_lockdep(dev->irq); 26 __ei_poll(dev);
502 ei_interrupt(dev->irq, dev);
503 enable_irq_lockdep(dev->irq);
504} 27}
505#endif 28#endif
506 29
507/**
508 * ei_tx_err - handle transmitter error
509 * @dev: network device which threw the exception
510 *
511 * A transmitter error has happened. Most likely excess collisions (which
512 * is a fairly normal condition). If the error is one where the Tx will
513 * have been aborted, we try and send another one right away, instead of
514 * letting the failed packet sit and collect dust in the Tx buffer. This
515 * is a much better solution as it avoids kernel based Tx timeouts, and
516 * an unnecessary card reset.
517 *
518 * Called with lock held.
519 */
520
521static void ei_tx_err(struct net_device *dev)
522{
523 long e8390_base = dev->base_addr;
524 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
525 unsigned char txsr = inb_p(e8390_base+EN0_TSR);
526 unsigned char tx_was_aborted = txsr & (ENTSR_ABT+ENTSR_FU);
527
528#ifdef VERBOSE_ERROR_DUMP
529 printk(KERN_DEBUG "%s: transmitter error (%#2x): ", dev->name, txsr);
530 if (txsr & ENTSR_ABT)
531 printk("excess-collisions ");
532 if (txsr & ENTSR_ND)
533 printk("non-deferral ");
534 if (txsr & ENTSR_CRS)
535 printk("lost-carrier ");
536 if (txsr & ENTSR_FU)
537 printk("FIFO-underrun ");
538 if (txsr & ENTSR_CDH)
539 printk("lost-heartbeat ");
540 printk("\n");
541#endif
542
543 outb_p(ENISR_TX_ERR, e8390_base + EN0_ISR); /* Ack intr. */
544
545 if (tx_was_aborted)
546 ei_tx_intr(dev);
547 else
548 {
549 ei_local->stat.tx_errors++;
550 if (txsr & ENTSR_CRS) ei_local->stat.tx_carrier_errors++;
551 if (txsr & ENTSR_CDH) ei_local->stat.tx_heartbeat_errors++;
552 if (txsr & ENTSR_OWC) ei_local->stat.tx_window_errors++;
553 }
554}
555
556/**
557 * ei_tx_intr - transmit interrupt handler
558 * @dev: network device for which tx intr is handled
559 *
560 * We have finished a transmit: check for errors and then trigger the next
561 * packet to be sent. Called with lock held.
562 */
563
564static void ei_tx_intr(struct net_device *dev)
565{
566 long e8390_base = dev->base_addr;
567 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
568 int status = inb(e8390_base + EN0_TSR);
569
570 outb_p(ENISR_TX, e8390_base + EN0_ISR); /* Ack intr. */
571
572 /*
573 * There are two Tx buffers, see which one finished, and trigger
574 * the send of another one if it exists.
575 */
576 ei_local->txqueue--;
577
578 if (ei_local->tx1 < 0)
579 {
580 if (ei_local->lasttx != 1 && ei_local->lasttx != -1)
581 printk(KERN_ERR "%s: bogus last_tx_buffer %d, tx1=%d.\n",
582 ei_local->name, ei_local->lasttx, ei_local->tx1);
583 ei_local->tx1 = 0;
584 if (ei_local->tx2 > 0)
585 {
586 ei_local->txing = 1;
587 NS8390_trigger_send(dev, ei_local->tx2, ei_local->tx_start_page + 6);
588 dev->trans_start = jiffies;
589 ei_local->tx2 = -1,
590 ei_local->lasttx = 2;
591 }
592 else ei_local->lasttx = 20, ei_local->txing = 0;
593 }
594 else if (ei_local->tx2 < 0)
595 {
596 if (ei_local->lasttx != 2 && ei_local->lasttx != -2)
597 printk("%s: bogus last_tx_buffer %d, tx2=%d.\n",
598 ei_local->name, ei_local->lasttx, ei_local->tx2);
599 ei_local->tx2 = 0;
600 if (ei_local->tx1 > 0)
601 {
602 ei_local->txing = 1;
603 NS8390_trigger_send(dev, ei_local->tx1, ei_local->tx_start_page);
604 dev->trans_start = jiffies;
605 ei_local->tx1 = -1;
606 ei_local->lasttx = 1;
607 }
608 else
609 ei_local->lasttx = 10, ei_local->txing = 0;
610 }
611// else printk(KERN_WARNING "%s: unexpected TX-done interrupt, lasttx=%d.\n",
612// dev->name, ei_local->lasttx);
613
614 /* Minimize Tx latency: update the statistics after we restart TXing. */
615 if (status & ENTSR_COL)
616 ei_local->stat.collisions++;
617 if (status & ENTSR_PTX)
618 ei_local->stat.tx_packets++;
619 else
620 {
621 ei_local->stat.tx_errors++;
622 if (status & ENTSR_ABT)
623 {
624 ei_local->stat.tx_aborted_errors++;
625 ei_local->stat.collisions += 16;
626 }
627 if (status & ENTSR_CRS)
628 ei_local->stat.tx_carrier_errors++;
629 if (status & ENTSR_FU)
630 ei_local->stat.tx_fifo_errors++;
631 if (status & ENTSR_CDH)
632 ei_local->stat.tx_heartbeat_errors++;
633 if (status & ENTSR_OWC)
634 ei_local->stat.tx_window_errors++;
635 }
636 netif_wake_queue(dev);
637}
638
639/**
640 * ei_receive - receive some packets
641 * @dev: network device with which receive will be run
642 *
643 * We have a good packet(s), get it/them out of the buffers.
644 * Called with lock held.
645 */
646
647static void ei_receive(struct net_device *dev)
648{
649 long e8390_base = dev->base_addr;
650 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
651 unsigned char rxing_page, this_frame, next_frame;
652 unsigned short current_offset;
653 int rx_pkt_count = 0;
654 struct e8390_pkt_hdr rx_frame;
655 int num_rx_pages = ei_local->stop_page-ei_local->rx_start_page;
656
657 while (++rx_pkt_count < 10)
658 {
659 int pkt_len, pkt_stat;
660
661 /* Get the rx page (incoming packet pointer). */
662 outb_p(E8390_NODMA+E8390_PAGE1, e8390_base + E8390_CMD);
663 rxing_page = inb_p(e8390_base + EN1_CURPAG);
664 outb_p(E8390_NODMA+E8390_PAGE0, e8390_base + E8390_CMD);
665
666 /* Remove one frame from the ring. Boundary is always a page behind. */
667 this_frame = inb_p(e8390_base + EN0_BOUNDARY) + 1;
668 if (this_frame >= ei_local->stop_page)
669 this_frame = ei_local->rx_start_page;
670
671 /* Someday we'll omit the previous, iff we never get this message.
672 (There is at least one clone claimed to have a problem.)
673
674 Keep quiet if it looks like a card removal. One problem here
675 is that some clones crash in roughly the same way.
676 */
677 if (ei_debug > 0 && this_frame != ei_local->current_page && (this_frame!=0x0 || rxing_page!=0xFF))
678 printk(KERN_ERR "%s: mismatched read page pointers %2x vs %2x.\n",
679 dev->name, this_frame, ei_local->current_page);
680
681 if (this_frame == rxing_page) /* Read all the frames? */
682 break; /* Done for now */
683
684 current_offset = this_frame << 8;
685 ei_get_8390_hdr(dev, &rx_frame, this_frame);
686
687 pkt_len = rx_frame.count - sizeof(struct e8390_pkt_hdr);
688 pkt_stat = rx_frame.status;
689
690 next_frame = this_frame + 1 + ((pkt_len+4)>>8);
691
692 /* Check for bogosity warned by 3c503 book: the status byte is never
693 written. This happened a lot during testing! This code should be
694 cleaned up someday. */
695 if (rx_frame.next != next_frame
696 && rx_frame.next != next_frame + 1
697 && rx_frame.next != next_frame - num_rx_pages
698 && rx_frame.next != next_frame + 1 - num_rx_pages) {
699 ei_local->current_page = rxing_page;
700 outb(ei_local->current_page-1, e8390_base+EN0_BOUNDARY);
701 ei_local->stat.rx_errors++;
702 continue;
703 }
704
705 if (pkt_len < 60 || pkt_len > 1518)
706 {
707 if (ei_debug)
708 printk(KERN_DEBUG "%s: bogus packet size: %d, status=%#2x nxpg=%#2x.\n",
709 dev->name, rx_frame.count, rx_frame.status,
710 rx_frame.next);
711 ei_local->stat.rx_errors++;
712 ei_local->stat.rx_length_errors++;
713 }
714 else if ((pkt_stat & 0x0F) == ENRSR_RXOK)
715 {
716 struct sk_buff *skb;
717
718 skb = dev_alloc_skb(pkt_len+2);
719 if (skb == NULL)
720 {
721 if (ei_debug > 1)
722 printk(KERN_DEBUG "%s: Couldn't allocate a sk_buff of size %d.\n",
723 dev->name, pkt_len);
724 ei_local->stat.rx_dropped++;
725 break;
726 }
727 else
728 {
729 skb_reserve(skb,2); /* IP headers on 16 byte boundaries */
730 skb->dev = dev;
731 skb_put(skb, pkt_len); /* Make room */
732 ei_block_input(dev, pkt_len, skb, current_offset + sizeof(rx_frame));
733 skb->protocol=eth_type_trans(skb,dev);
734 netif_rx(skb);
735 dev->last_rx = jiffies;
736 ei_local->stat.rx_packets++;
737 ei_local->stat.rx_bytes += pkt_len;
738 if (pkt_stat & ENRSR_PHY)
739 ei_local->stat.multicast++;
740 }
741 }
742 else
743 {
744 if (ei_debug)
745 printk(KERN_DEBUG "%s: bogus packet: status=%#2x nxpg=%#2x size=%d\n",
746 dev->name, rx_frame.status, rx_frame.next,
747 rx_frame.count);
748 ei_local->stat.rx_errors++;
749 /* NB: The NIC counts CRC, frame and missed errors. */
750 if (pkt_stat & ENRSR_FO)
751 ei_local->stat.rx_fifo_errors++;
752 }
753 next_frame = rx_frame.next;
754
755 /* This _should_ never happen: it's here for avoiding bad clones. */
756 if (next_frame >= ei_local->stop_page) {
757 printk("%s: next frame inconsistency, %#2x\n", dev->name,
758 next_frame);
759 next_frame = ei_local->rx_start_page;
760 }
761 ei_local->current_page = next_frame;
762 outb_p(next_frame-1, e8390_base+EN0_BOUNDARY);
763 }
764
765 /* We used to also ack ENISR_OVER here, but that would sometimes mask
766 a real overrun, leaving the 8390 in a stopped state with rec'vr off. */
767 outb_p(ENISR_RX+ENISR_RX_ERR, e8390_base+EN0_ISR);
768 return;
769}
770
771/**
772 * ei_rx_overrun - handle receiver overrun
773 * @dev: network device which threw exception
774 *
775 * We have a receiver overrun: we have to kick the 8390 to get it started
776 * again. Problem is that you have to kick it exactly as NS prescribes in
777 * the updated datasheets, or "the NIC may act in an unpredictable manner."
778 * This includes causing "the NIC to defer indefinitely when it is stopped
779 * on a busy network." Ugh.
780 * Called with lock held. Don't call this with the interrupts off or your
781 * computer will hate you - it takes 10ms or so.
782 */
783
784static void ei_rx_overrun(struct net_device *dev)
785{
786 long e8390_base = dev->base_addr;
787 unsigned char was_txing, must_resend = 0;
788 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
789
790 /*
791 * Record whether a Tx was in progress and then issue the
792 * stop command.
793 */
794 was_txing = inb_p(e8390_base+E8390_CMD) & E8390_TRANS;
795 outb_p(E8390_NODMA+E8390_PAGE0+E8390_STOP, e8390_base+E8390_CMD);
796
797 if (ei_debug > 1)
798 printk(KERN_DEBUG "%s: Receiver overrun.\n", dev->name);
799 ei_local->stat.rx_over_errors++;
800
801 /*
802 * Wait a full Tx time (1.2ms) + some guard time, NS says 1.6ms total.
803 * Early datasheets said to poll the reset bit, but now they say that
804 * it "is not a reliable indicator and subsequently should be ignored."
805 * We wait at least 10ms.
806 */
807
808 mdelay(10);
809
810 /*
811 * Reset RBCR[01] back to zero as per magic incantation.
812 */
813 outb_p(0x00, e8390_base+EN0_RCNTLO);
814 outb_p(0x00, e8390_base+EN0_RCNTHI);
815
816 /*
817 * See if any Tx was interrupted or not. According to NS, this
818 * step is vital, and skipping it will cause no end of havoc.
819 */
820
821 if (was_txing)
822 {
823 unsigned char tx_completed = inb_p(e8390_base+EN0_ISR) & (ENISR_TX+ENISR_TX_ERR);
824 if (!tx_completed)
825 must_resend = 1;
826 }
827
828 /*
829 * Have to enter loopback mode and then restart the NIC before
830 * you are allowed to slurp packets up off the ring.
831 */
832 outb_p(E8390_TXOFF, e8390_base + EN0_TXCR);
833 outb_p(E8390_NODMA + E8390_PAGE0 + E8390_START, e8390_base + E8390_CMD);
834
835 /*
836 * Clear the Rx ring of all the debris, and ack the interrupt.
837 */
838 ei_receive(dev);
839 outb_p(ENISR_OVER, e8390_base+EN0_ISR);
840
841 /*
842 * Leave loopback mode, and resend any packet that got stopped.
843 */
844 outb_p(E8390_TXCONFIG, e8390_base + EN0_TXCR);
845 if (must_resend)
846 outb_p(E8390_NODMA + E8390_PAGE0 + E8390_START + E8390_TRANS, e8390_base + E8390_CMD);
847}
848
849/*
850 * Collect the stats. This is called unlocked and from several contexts.
851 */
852
853static struct net_device_stats *get_stats(struct net_device *dev)
854{
855 long ioaddr = dev->base_addr;
856 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
857 unsigned long flags;
858
859 /* If the card is stopped, just return the present stats. */
860 if (!netif_running(dev))
861 return &ei_local->stat;
862
863 spin_lock_irqsave(&ei_local->page_lock,flags);
864 /* Read the counter registers, assuming we are in page 0. */
865 ei_local->stat.rx_frame_errors += inb_p(ioaddr + EN0_COUNTER0);
866 ei_local->stat.rx_crc_errors += inb_p(ioaddr + EN0_COUNTER1);
867 ei_local->stat.rx_missed_errors+= inb_p(ioaddr + EN0_COUNTER2);
868 spin_unlock_irqrestore(&ei_local->page_lock, flags);
869
870 return &ei_local->stat;
871}
872
873/*
874 * Form the 64 bit 8390 multicast table from the linked list of addresses
875 * associated with this dev structure.
876 */
877
878static inline void make_mc_bits(u8 *bits, struct net_device *dev)
879{
880 struct dev_mc_list *dmi;
881
882 for (dmi=dev->mc_list; dmi; dmi=dmi->next)
883 {
884 u32 crc;
885 if (dmi->dmi_addrlen != ETH_ALEN)
886 {
887 printk(KERN_INFO "%s: invalid multicast address length given.\n", dev->name);
888 continue;
889 }
890 crc = ether_crc(ETH_ALEN, dmi->dmi_addr);
891 /*
892 * The 8390 uses the 6 most significant bits of the
893 * CRC to index the multicast table.
894 */
895 bits[crc>>29] |= (1<<((crc>>26)&7));
896 }
897}
898
899/**
900 * do_set_multicast_list - set/clear multicast filter
901 * @dev: net device for which multicast filter is adjusted
902 *
903 * Set or clear the multicast filter for this adaptor. May be called
904 * from a BH in 2.1.x. Must be called with lock held.
905 */
906
907static void do_set_multicast_list(struct net_device *dev)
908{
909 long e8390_base = dev->base_addr;
910 int i;
911 struct ei_device *ei_local = (struct ei_device*)netdev_priv(dev);
912
913 if (!(dev->flags&(IFF_PROMISC|IFF_ALLMULTI)))
914 {
915 memset(ei_local->mcfilter, 0, 8);
916 if (dev->mc_list)
917 make_mc_bits(ei_local->mcfilter, dev);
918 }
919 else
920 memset(ei_local->mcfilter, 0xFF, 8); /* mcast set to accept-all */
921
922 /*
923 * DP8390 manuals don't specify any magic sequence for altering
924 * the multicast regs on an already running card. To be safe, we
925 * ensure multicast mode is off prior to loading up the new hash
926 * table. If this proves to be not enough, we can always resort
927 * to stopping the NIC, loading the table and then restarting.
928 *
929 * Bug Alert! The MC regs on the SMC 83C690 (SMC Elite and SMC
930 * Elite16) appear to be write-only. The NS 8390 data sheet lists
931 * them as r/w so this is a bug. The SMC 83C790 (SMC Ultra and
932 * Ultra32 EISA) appears to have this bug fixed.
933 */
934
935 if (netif_running(dev))
936 outb_p(E8390_RXCONFIG, e8390_base + EN0_RXCR);
937 outb_p(E8390_NODMA + E8390_PAGE1, e8390_base + E8390_CMD);
938 for(i = 0; i < 8; i++)
939 {
940 outb_p(ei_local->mcfilter[i], e8390_base + EN1_MULT_SHIFT(i));
941#ifndef BUG_83C690
942 if(inb_p(e8390_base + EN1_MULT_SHIFT(i))!=ei_local->mcfilter[i])
943 printk(KERN_ERR "Multicast filter read/write mismap %d\n",i);
944#endif
945 }
946 outb_p(E8390_NODMA + E8390_PAGE0, e8390_base + E8390_CMD);
947
948 if(dev->flags&IFF_PROMISC)
949 outb_p(E8390_RXCONFIG | 0x18, e8390_base + EN0_RXCR);
950 else if(dev->flags&IFF_ALLMULTI || dev->mc_list)
951 outb_p(E8390_RXCONFIG | 0x08, e8390_base + EN0_RXCR);
952 else
953 outb_p(E8390_RXCONFIG, e8390_base + EN0_RXCR);
954 }
955
956/*
957 * Called without lock held. This is invoked from user context and may
958 * be parallel to just about everything else. Its also fairly quick and
959 * not called too often. Must protect against both bh and irq users
960 */
961
962static void set_multicast_list(struct net_device *dev)
963{
964 unsigned long flags;
965 struct ei_device *ei_local = (struct ei_device*)netdev_priv(dev);
966
967 spin_lock_irqsave(&ei_local->page_lock, flags);
968 do_set_multicast_list(dev);
969 spin_unlock_irqrestore(&ei_local->page_lock, flags);
970}
971
972/**
973 * ethdev_setup - init rest of 8390 device struct
974 * @dev: network device structure to init
975 *
976 * Initialize the rest of the 8390 device structure. Do NOT __init
977 * this, as it is used by 8390 based modular drivers too.
978 */
979
980static void ethdev_setup(struct net_device *dev)
981{
982 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
983 if (ei_debug > 1)
984 printk(version);
985
986 dev->hard_start_xmit = &ei_start_xmit;
987 dev->get_stats = get_stats;
988 dev->set_multicast_list = &set_multicast_list;
989
990 ether_setup(dev);
991
992 spin_lock_init(&ei_local->page_lock);
993}
994
995/**
996 * alloc_ei_netdev - alloc_etherdev counterpart for 8390
997 * @size: extra bytes to allocate
998 *
999 * Allocate 8390-specific net_device.
1000 */
1001struct net_device *__alloc_ei_netdev(int size) 30struct net_device *__alloc_ei_netdev(int size)
1002{ 31{
1003 return alloc_netdev(sizeof(struct ei_device) + size, "eth%d", 32 return ____alloc_ei_netdev(size);
1004 ethdev_setup);
1005} 33}
1006 34
1007
1008
1009
1010/* This page of functions should be 8390 generic */
1011/* Follow National Semi's recommendations for initializing the "NIC". */
1012
1013/**
1014 * NS8390_init - initialize 8390 hardware
1015 * @dev: network device to initialize
1016 * @startp: boolean. non-zero value to initiate chip processing
1017 *
1018 * Must be called with lock held.
1019 */
1020
1021void NS8390_init(struct net_device *dev, int startp) 35void NS8390_init(struct net_device *dev, int startp)
1022{ 36{
1023 long e8390_base = dev->base_addr; 37 return __NS8390_init(dev, startp);
1024 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
1025 int i;
1026 int endcfg = ei_local->word16
1027 ? (0x48 | ENDCFG_WTS | (ei_local->bigendian ? ENDCFG_BOS : 0))
1028 : 0x48;
1029
1030 if(sizeof(struct e8390_pkt_hdr)!=4)
1031 panic("8390.c: header struct mispacked\n");
1032 /* Follow National Semi's recommendations for initing the DP83902. */
1033 outb_p(E8390_NODMA+E8390_PAGE0+E8390_STOP, e8390_base+E8390_CMD); /* 0x21 */
1034 outb_p(endcfg, e8390_base + EN0_DCFG); /* 0x48 or 0x49 */
1035 /* Clear the remote byte count registers. */
1036 outb_p(0x00, e8390_base + EN0_RCNTLO);
1037 outb_p(0x00, e8390_base + EN0_RCNTHI);
1038 /* Set to monitor and loopback mode -- this is vital!. */
1039 outb_p(E8390_RXOFF, e8390_base + EN0_RXCR); /* 0x20 */
1040 outb_p(E8390_TXOFF, e8390_base + EN0_TXCR); /* 0x02 */
1041 /* Set the transmit page and receive ring. */
1042 outb_p(ei_local->tx_start_page, e8390_base + EN0_TPSR);
1043 ei_local->tx1 = ei_local->tx2 = 0;
1044 outb_p(ei_local->rx_start_page, e8390_base + EN0_STARTPG);
1045 outb_p(ei_local->stop_page-1, e8390_base + EN0_BOUNDARY); /* 3c503 says 0x3f,NS0x26*/
1046 ei_local->current_page = ei_local->rx_start_page; /* assert boundary+1 */
1047 outb_p(ei_local->stop_page, e8390_base + EN0_STOPPG);
1048 /* Clear the pending interrupts and mask. */
1049 outb_p(0xFF, e8390_base + EN0_ISR);
1050 outb_p(0x00, e8390_base + EN0_IMR);
1051
1052 /* Copy the station address into the DS8390 registers. */
1053
1054 outb_p(E8390_NODMA + E8390_PAGE1 + E8390_STOP, e8390_base+E8390_CMD); /* 0x61 */
1055 for(i = 0; i < 6; i++)
1056 {
1057 outb_p(dev->dev_addr[i], e8390_base + EN1_PHYS_SHIFT(i));
1058 if (ei_debug > 1 && inb_p(e8390_base + EN1_PHYS_SHIFT(i))!=dev->dev_addr[i])
1059 printk(KERN_ERR "Hw. address read/write mismap %d\n",i);
1060 }
1061
1062 outb_p(ei_local->rx_start_page, e8390_base + EN1_CURPAG);
1063 outb_p(E8390_NODMA+E8390_PAGE0+E8390_STOP, e8390_base+E8390_CMD);
1064
1065 netif_start_queue(dev);
1066 ei_local->tx1 = ei_local->tx2 = 0;
1067 ei_local->txing = 0;
1068
1069 if (startp)
1070 {
1071 outb_p(0xff, e8390_base + EN0_ISR);
1072 outb_p(ENISR_ALL, e8390_base + EN0_IMR);
1073 outb_p(E8390_NODMA+E8390_PAGE0+E8390_START, e8390_base+E8390_CMD);
1074 outb_p(E8390_TXCONFIG, e8390_base + EN0_TXCR); /* xmit on. */
1075 /* 3c503 TechMan says rxconfig only after the NIC is started. */
1076 outb_p(E8390_RXCONFIG, e8390_base + EN0_RXCR); /* rx on, */
1077 do_set_multicast_list(dev); /* (re)load the mcast table */
1078 }
1079}
1080
1081/* Trigger a transmit start, assuming the length is valid.
1082 Always called with the page lock held */
1083
1084static void NS8390_trigger_send(struct net_device *dev, unsigned int length,
1085 int start_page)
1086{
1087 long e8390_base = dev->base_addr;
1088 struct ei_device *ei_local __attribute((unused)) = (struct ei_device *) netdev_priv(dev);
1089
1090 outb_p(E8390_NODMA+E8390_PAGE0, e8390_base+E8390_CMD);
1091
1092 if (inb_p(e8390_base + E8390_CMD) & E8390_TRANS)
1093 {
1094 printk(KERN_WARNING "%s: trigger_send() called with the transmitter busy.\n",
1095 dev->name);
1096 return;
1097 }
1098 outb_p(length & 0xff, e8390_base + EN0_TCNTLO);
1099 outb_p(length >> 8, e8390_base + EN0_TCNTHI);
1100 outb_p(start_page, e8390_base + EN0_TPSR);
1101 outb_p(E8390_NODMA+E8390_TRANS+E8390_START, e8390_base+E8390_CMD);
1102} 38}
1103 39
1104EXPORT_SYMBOL(ei_open); 40EXPORT_SYMBOL(ei_open);
diff --git a/drivers/net/8390.h b/drivers/net/8390.h
index f44f1220b3a5..414de5bd228f 100644
--- a/drivers/net/8390.h
+++ b/drivers/net/8390.h
@@ -107,35 +107,14 @@ struct ei_device {
107 * - removed AMIGA_PCMCIA from this list, handled as ISA io now 107 * - removed AMIGA_PCMCIA from this list, handled as ISA io now
108 */ 108 */
109 109
110#if defined(CONFIG_MAC) || \ 110#ifndef ei_inb
111 defined(CONFIG_ZORRO8390) || defined(CONFIG_ZORRO8390_MODULE) || \ 111#define ei_inb(_p) inb(_p)
112 defined(CONFIG_HYDRA) || defined(CONFIG_HYDRA_MODULE) 112#define ei_outb(_v,_p) outb(_v,_p)
113#define EI_SHIFT(x) (ei_local->reg_offset[x]) 113#define ei_inb_p(_p) inb_p(_p)
114#undef inb 114#define ei_outb_p(_v,_p) outb_p(_v,_p)
115#undef inb_p 115#endif
116#undef outb 116
117#undef outb_p 117#ifndef EI_SHIFT
118
119#define inb(port) in_8(port)
120#define outb(val,port) out_8(port,val)
121#define inb_p(port) in_8(port)
122#define outb_p(val,port) out_8(port,val)
123
124#elif defined(CONFIG_ARM_ETHERH) || defined(CONFIG_ARM_ETHERH_MODULE)
125#define EI_SHIFT(x) (ei_local->reg_offset[x])
126#undef inb
127#undef inb_p
128#undef outb
129#undef outb_p
130
131#define inb(_p) readb(_p)
132#define outb(_v,_p) writeb(_v,_p)
133#define inb_p(_p) inb(_p)
134#define outb_p(_v,_p) outb(_v,_p)
135
136#elif defined(CONFIG_NE_H8300) || defined(CONFIG_NE_H8300_MODULE)
137#define EI_SHIFT(x) (ei_local->reg_offset[x])
138#else
139#define EI_SHIFT(x) (x) 118#define EI_SHIFT(x) (x)
140#endif 119#endif
141 120
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 28c17d1ca5cb..9de0eed6755b 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -32,7 +32,7 @@ config IFB
32 tristate "Intermediate Functional Block support" 32 tristate "Intermediate Functional Block support"
33 depends on NET_CLS_ACT 33 depends on NET_CLS_ACT
34 ---help--- 34 ---help---
35 This is an intermidiate driver that allows sharing of 35 This is an intermediate driver that allows sharing of
36 resources. 36 resources.
37 To compile this driver as a module, choose M here: the module 37 To compile this driver as a module, choose M here: the module
38 will be called ifb. If you want to use more than one ifb 38 will be called ifb. If you want to use more than one ifb
@@ -188,6 +188,17 @@ config MII
188 or internal device. It is safe to say Y or M here even if your 188 or internal device. It is safe to say Y or M here even if your
189 ethernet card lack MII. 189 ethernet card lack MII.
190 190
191config MACB
192 tristate "Atmel MACB support"
193 depends on NET_ETHERNET && AVR32
194 select MII
195 help
196 The Atmel MACB ethernet interface is found on many AT32 and AT91
197 parts. Say Y to include support for the MACB chip.
198
199 To compile this driver as a module, choose M here: the module
200 will be called macb.
201
191source "drivers/net/arm/Kconfig" 202source "drivers/net/arm/Kconfig"
192 203
193config MACE 204config MACE
@@ -486,7 +497,7 @@ config SGI_IOC3_ETH_HW_TX_CSUM
486 497
487config MIPS_SIM_NET 498config MIPS_SIM_NET
488 tristate "MIPS simulator Network device (EXPERIMENTAL)" 499 tristate "MIPS simulator Network device (EXPERIMENTAL)"
489 depends on NETDEVICES && MIPS_SIM && EXPERIMENTAL 500 depends on MIPS_SIM && EXPERIMENTAL
490 help 501 help
491 The MIPSNET device is a simple Ethernet network device which is 502 The MIPSNET device is a simple Ethernet network device which is
492 emulated by the MIPS Simulator. 503 emulated by the MIPS Simulator.
@@ -1769,8 +1780,8 @@ config VIA_RHINE_NAPI
1769 information. 1780 information.
1770 1781
1771config LAN_SAA9730 1782config LAN_SAA9730
1772 bool "Philips SAA9730 Ethernet support (EXPERIMENTAL)" 1783 bool "Philips SAA9730 Ethernet support"
1773 depends on NET_PCI && EXPERIMENTAL && MIPS 1784 depends on NET_PCI && PCI && MIPS_ATLAS
1774 help 1785 help
1775 The SAA9730 is a combined multimedia and peripheral controller used 1786 The SAA9730 is a combined multimedia and peripheral controller used
1776 in thin clients, Internet access terminals, and diskless 1787 in thin clients, Internet access terminals, and diskless
@@ -2136,7 +2147,7 @@ config SK98LIN
2136 This driver supports the original Yukon chipset. A cleaner driver is 2147 This driver supports the original Yukon chipset. A cleaner driver is
2137 also available (skge) which seems to work better than this one. 2148 also available (skge) which seems to work better than this one.
2138 2149
2139 This driver does not support the newer Yukon2 chipset. A seperate 2150 This driver does not support the newer Yukon2 chipset. A separate
2140 driver, sky2, is provided to support Yukon2-based adapters. 2151 driver, sky2, is provided to support Yukon2-based adapters.
2141 2152
2142 The following adapters are supported by this driver: 2153 The following adapters are supported by this driver:
@@ -2251,6 +2262,14 @@ config SPIDER_NET
2251 This driver supports the Gigabit Ethernet chips present on the 2262 This driver supports the Gigabit Ethernet chips present on the
2252 Cell Processor-Based Blades from IBM. 2263 Cell Processor-Based Blades from IBM.
2253 2264
2265config TSI108_ETH
2266 tristate "Tundra TSI108 gigabit Ethernet support"
2267 depends on TSI108_BRIDGE
2268 help
2269 This driver supports Tundra TSI108 gigabit Ethernet ports.
2270 To compile this driver as a module, choose M here: the module
2271 will be called tsi108_eth.
2272
2254config GIANFAR 2273config GIANFAR
2255 tristate "Gianfar Ethernet" 2274 tristate "Gianfar Ethernet"
2256 depends on 85xx || 83xx || PPC_86xx 2275 depends on 85xx || 83xx || PPC_86xx
@@ -2341,10 +2360,11 @@ menu "Ethernet (10000 Mbit)"
2341config CHELSIO_T1 2360config CHELSIO_T1
2342 tristate "Chelsio 10Gb Ethernet support" 2361 tristate "Chelsio 10Gb Ethernet support"
2343 depends on PCI 2362 depends on PCI
2363 select CRC32
2344 help 2364 help
2345 This driver supports Chelsio N110 and N210 models 10Gb Ethernet 2365 This driver supports Chelsio gigabit and 10-gigabit
2346 cards. More information about adapter features and performance 2366 Ethernet cards. More information about adapter features and
2347 tuning is in <file:Documentation/networking/cxgb.txt>. 2367 performance tuning is in <file:Documentation/networking/cxgb.txt>.
2348 2368
2349 For general information about Chelsio and our products, visit 2369 For general information about Chelsio and our products, visit
2350 our website at <http://www.chelsio.com>. 2370 our website at <http://www.chelsio.com>.
@@ -2357,6 +2377,13 @@ config CHELSIO_T1
2357 To compile this driver as a module, choose M here: the module 2377 To compile this driver as a module, choose M here: the module
2358 will be called cxgb. 2378 will be called cxgb.
2359 2379
2380config CHELSIO_T1_1G
2381 bool "Chelsio gigabit Ethernet support"
2382 depends on CHELSIO_T1
2383 help
2384 Enables support for Chelsio's gigabit Ethernet PCI cards. If you
2385 are using only 10G cards say 'N' here.
2386
2360config EHEA 2387config EHEA
2361 tristate "eHEA Ethernet support" 2388 tristate "eHEA Ethernet support"
2362 depends on IBMEBUS 2389 depends on IBMEBUS
@@ -2447,6 +2474,12 @@ config MYRI10GE
2447 <file:Documentation/networking/net-modules.txt>. The module 2474 <file:Documentation/networking/net-modules.txt>. The module
2448 will be called myri10ge. 2475 will be called myri10ge.
2449 2476
2477config NETXEN_NIC
2478 tristate "NetXen Multi port (1/10) Gigabit Ethernet NIC"
2479 depends on PCI
2480 help
2481 This enables the support for NetXen's Gigabit Ethernet card.
2482
2450endmenu 2483endmenu
2451 2484
2452source "drivers/net/tokenring/Kconfig" 2485source "drivers/net/tokenring/Kconfig"
@@ -2467,7 +2500,7 @@ config ISERIES_VETH
2467 2500
2468config RIONET 2501config RIONET
2469 tristate "RapidIO Ethernet over messaging driver support" 2502 tristate "RapidIO Ethernet over messaging driver support"
2470 depends on NETDEVICES && RAPIDIO 2503 depends on RAPIDIO
2471 2504
2472config RIONET_TX_SIZE 2505config RIONET_TX_SIZE
2473 int "Number of outbound queue entries" 2506 int "Number of outbound queue entries"
@@ -2833,7 +2866,7 @@ config NET_FC
2833 "SCSI generic support". 2866 "SCSI generic support".
2834 2867
2835config SHAPER 2868config SHAPER
2836 tristate "Traffic Shaper (EXPERIMENTAL)" 2869 tristate "Traffic Shaper (OBSOLETE)"
2837 depends on EXPERIMENTAL 2870 depends on EXPERIMENTAL
2838 ---help--- 2871 ---help---
2839 The traffic shaper is a virtual network device that allows you to 2872 The traffic shaper is a virtual network device that allows you to
@@ -2842,9 +2875,9 @@ config SHAPER
2842 these virtual devices. See 2875 these virtual devices. See
2843 <file:Documentation/networking/shaper.txt> for more information. 2876 <file:Documentation/networking/shaper.txt> for more information.
2844 2877
2845 An alternative to this traffic shaper is the experimental 2878 An alternative to this traffic shaper are traffic schedulers which
2846 Class-Based Queuing (CBQ) scheduling support which you get if you 2879 you'll get if you say Y to "QoS and/or fair queuing" in
2847 say Y to "QoS and/or fair queuing" above. 2880 "Networking options".
2848 2881
2849 To compile this driver as a module, choose M here: the module 2882 To compile this driver as a module, choose M here: the module
2850 will be called shaper. If unsure, say N. 2883 will be called shaper. If unsure, say N.
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index f270bc49e571..4c0d4e5ce42b 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -82,7 +82,7 @@ obj-$(CONFIG_HAMACHI) += hamachi.o
82obj-$(CONFIG_NET) += Space.o loopback.o 82obj-$(CONFIG_NET) += Space.o loopback.o
83obj-$(CONFIG_SEEQ8005) += seeq8005.o 83obj-$(CONFIG_SEEQ8005) += seeq8005.o
84obj-$(CONFIG_NET_SB1000) += sb1000.o 84obj-$(CONFIG_NET_SB1000) += sb1000.o
85obj-$(CONFIG_MAC8390) += mac8390.o 8390.o 85obj-$(CONFIG_MAC8390) += mac8390.o
86obj-$(CONFIG_APNE) += apne.o 8390.o 86obj-$(CONFIG_APNE) += apne.o 8390.o
87obj-$(CONFIG_PCMCIA_PCNET) += 8390.o 87obj-$(CONFIG_PCMCIA_PCNET) += 8390.o
88obj-$(CONFIG_SHAPER) += shaper.o 88obj-$(CONFIG_SHAPER) += shaper.o
@@ -90,7 +90,6 @@ obj-$(CONFIG_HP100) += hp100.o
90obj-$(CONFIG_SMC9194) += smc9194.o 90obj-$(CONFIG_SMC9194) += smc9194.o
91obj-$(CONFIG_FEC) += fec.o 91obj-$(CONFIG_FEC) += fec.o
92obj-$(CONFIG_68360_ENET) += 68360enet.o 92obj-$(CONFIG_68360_ENET) += 68360enet.o
93obj-$(CONFIG_ARM_ETHERH) += 8390.o
94obj-$(CONFIG_WD80x3) += wd.o 8390.o 93obj-$(CONFIG_WD80x3) += wd.o 8390.o
95obj-$(CONFIG_EL2) += 3c503.o 8390.o 94obj-$(CONFIG_EL2) += 3c503.o 8390.o
96obj-$(CONFIG_NE2000) += ne.o 8390.o 95obj-$(CONFIG_NE2000) += ne.o 8390.o
@@ -107,8 +106,9 @@ obj-$(CONFIG_NE3210) += ne3210.o 8390.o
107obj-$(CONFIG_NET_SB1250_MAC) += sb1250-mac.o 106obj-$(CONFIG_NET_SB1250_MAC) += sb1250-mac.o
108obj-$(CONFIG_B44) += b44.o 107obj-$(CONFIG_B44) += b44.o
109obj-$(CONFIG_FORCEDETH) += forcedeth.o 108obj-$(CONFIG_FORCEDETH) += forcedeth.o
110obj-$(CONFIG_NE_H8300) += ne-h8300.o 8390.o 109obj-$(CONFIG_NE_H8300) += ne-h8300.o
111 110
111obj-$(CONFIG_TSI108_ETH) += tsi108_eth.o
112obj-$(CONFIG_MV643XX_ETH) += mv643xx_eth.o 112obj-$(CONFIG_MV643XX_ETH) += mv643xx_eth.o
113obj-$(CONFIG_QLA3XXX) += qla3xxx.o 113obj-$(CONFIG_QLA3XXX) += qla3xxx.o
114 114
@@ -165,7 +165,7 @@ obj-$(CONFIG_BVME6000_NET) += 82596.o
165obj-$(CONFIG_LP486E) += lp486e.o 165obj-$(CONFIG_LP486E) += lp486e.o
166 166
167obj-$(CONFIG_ETH16I) += eth16i.o 167obj-$(CONFIG_ETH16I) += eth16i.o
168obj-$(CONFIG_ZORRO8390) += zorro8390.o 8390.o 168obj-$(CONFIG_ZORRO8390) += zorro8390.o
169obj-$(CONFIG_HPLANCE) += hplance.o 7990.o 169obj-$(CONFIG_HPLANCE) += hplance.o 7990.o
170obj-$(CONFIG_MVME147_NET) += mvme147.o 7990.o 170obj-$(CONFIG_MVME147_NET) += mvme147.o 7990.o
171obj-$(CONFIG_EQUALIZER) += eql.o 171obj-$(CONFIG_EQUALIZER) += eql.o
@@ -178,7 +178,7 @@ obj-$(CONFIG_ATARILANCE) += atarilance.o
178obj-$(CONFIG_ATARI_BIONET) += atari_bionet.o 178obj-$(CONFIG_ATARI_BIONET) += atari_bionet.o
179obj-$(CONFIG_ATARI_PAMSNET) += atari_pamsnet.o 179obj-$(CONFIG_ATARI_PAMSNET) += atari_pamsnet.o
180obj-$(CONFIG_A2065) += a2065.o 180obj-$(CONFIG_A2065) += a2065.o
181obj-$(CONFIG_HYDRA) += hydra.o 8390.o 181obj-$(CONFIG_HYDRA) += hydra.o
182obj-$(CONFIG_ARIADNE) += ariadne.o 182obj-$(CONFIG_ARIADNE) += ariadne.o
183obj-$(CONFIG_CS89x0) += cs89x0.o 183obj-$(CONFIG_CS89x0) += cs89x0.o
184obj-$(CONFIG_MACSONIC) += macsonic.o 184obj-$(CONFIG_MACSONIC) += macsonic.o
@@ -197,6 +197,8 @@ obj-$(CONFIG_SMC911X) += smc911x.o
197obj-$(CONFIG_DM9000) += dm9000.o 197obj-$(CONFIG_DM9000) += dm9000.o
198obj-$(CONFIG_FEC_8XX) += fec_8xx/ 198obj-$(CONFIG_FEC_8XX) += fec_8xx/
199 199
200obj-$(CONFIG_MACB) += macb.o
201
200obj-$(CONFIG_ARM) += arm/ 202obj-$(CONFIG_ARM) += arm/
201obj-$(CONFIG_DEV_APPLETALK) += appletalk/ 203obj-$(CONFIG_DEV_APPLETALK) += appletalk/
202obj-$(CONFIG_TR) += tokenring/ 204obj-$(CONFIG_TR) += tokenring/
@@ -214,3 +216,4 @@ obj-$(CONFIG_NETCONSOLE) += netconsole.o
214 216
215obj-$(CONFIG_FS_ENET) += fs_enet/ 217obj-$(CONFIG_FS_ENET) += fs_enet/
216 218
219obj-$(CONFIG_NETXEN_NIC) += netxen/
diff --git a/drivers/net/Space.c b/drivers/net/Space.c
index a67f5efc983f..602ed31a5dd9 100644
--- a/drivers/net/Space.c
+++ b/drivers/net/Space.c
@@ -33,7 +33,6 @@
33#include <linux/errno.h> 33#include <linux/errno.h>
34#include <linux/init.h> 34#include <linux/init.h>
35#include <linux/netlink.h> 35#include <linux/netlink.h>
36#include <linux/divert.h>
37 36
38/* A unified ethernet device probe. This is the easiest way to have every 37/* A unified ethernet device probe. This is the easiest way to have every
39 ethernet adaptor have the name "eth[0123...]". 38 ethernet adaptor have the name "eth[0123...]".
diff --git a/drivers/net/ac3200.c b/drivers/net/ac3200.c
index 0dca8bb9d2c7..c01f87f5bed7 100644
--- a/drivers/net/ac3200.c
+++ b/drivers/net/ac3200.c
@@ -405,7 +405,7 @@ static void cleanup_card(struct net_device *dev)
405 iounmap(ei_status.mem); 405 iounmap(ei_status.mem);
406} 406}
407 407
408void 408void __exit
409cleanup_module(void) 409cleanup_module(void)
410{ 410{
411 int this_dev; 411 int this_dev;
diff --git a/drivers/net/amd8111e.c b/drivers/net/amd8111e.c
index ef65e5917c8f..18896f24d407 100644
--- a/drivers/net/amd8111e.c
+++ b/drivers/net/amd8111e.c
@@ -1490,32 +1490,7 @@ static void amd8111e_read_regs(struct amd8111e_priv *lp, u32 *buf)
1490 buf[12] = readl(mmio + STAT0); 1490 buf[12] = readl(mmio + STAT0);
1491} 1491}
1492 1492
1493/*
1494amd8111e crc generator implementation is different from the kernel
1495ether_crc() function.
1496*/
1497static int amd8111e_ether_crc(int len, char* mac_addr)
1498{
1499 int i,byte;
1500 unsigned char octet;
1501 u32 crc= INITCRC;
1502
1503 for(byte=0; byte < len; byte++){
1504 octet = mac_addr[byte];
1505 for( i=0;i < 8; i++){
1506 /*If the next bit form the input stream is 1,subtract the divisor (CRC32) from the dividend(crc).*/
1507 if( (octet & 0x1) ^ (crc & 0x1) ){
1508 crc >>= 1;
1509 crc ^= CRC32;
1510 }
1511 else
1512 crc >>= 1;
1513 1493
1514 octet >>= 1;
1515 }
1516 }
1517 return crc;
1518}
1519/* 1494/*
1520This function sets promiscuos mode, all-multi mode or the multicast address 1495This function sets promiscuos mode, all-multi mode or the multicast address
1521list to the device. 1496list to the device.
@@ -1556,7 +1531,7 @@ static void amd8111e_set_multicast_list(struct net_device *dev)
1556 mc_filter[1] = mc_filter[0] = 0; 1531 mc_filter[1] = mc_filter[0] = 0;
1557 for (i = 0, mc_ptr = dev->mc_list; mc_ptr && i < dev->mc_count; 1532 for (i = 0, mc_ptr = dev->mc_list; mc_ptr && i < dev->mc_count;
1558 i++, mc_ptr = mc_ptr->next) { 1533 i++, mc_ptr = mc_ptr->next) {
1559 bit_num = ( amd8111e_ether_crc(ETH_ALEN,mc_ptr->dmi_addr) >> 26 ) & 0x3f; 1534 bit_num = (ether_crc_le(ETH_ALEN, mc_ptr->dmi_addr) >> 26) & 0x3f;
1560 mc_filter[bit_num >> 5] |= 1 << (bit_num & 31); 1535 mc_filter[bit_num >> 5] |= 1 << (bit_num & 31);
1561 } 1536 }
1562 amd8111e_writeq(*(u64*)mc_filter,lp->mmio+ LADRF); 1537 amd8111e_writeq(*(u64*)mc_filter,lp->mmio+ LADRF);
diff --git a/drivers/net/amd8111e.h b/drivers/net/amd8111e.h
index 7727d328f65e..2007510c4eb6 100644
--- a/drivers/net/amd8111e.h
+++ b/drivers/net/amd8111e.h
@@ -651,10 +651,6 @@ typedef enum {
651/* driver ioctl parameters */ 651/* driver ioctl parameters */
652#define AMD8111E_REG_DUMP_LEN 13*sizeof(u32) 652#define AMD8111E_REG_DUMP_LEN 13*sizeof(u32)
653 653
654/* crc generator constants */
655#define CRC32 0xedb88320
656#define INITCRC 0xFFFFFFFF
657
658/* amd8111e desriptor format */ 654/* amd8111e desriptor format */
659 655
660struct amd8111e_tx_dr{ 656struct amd8111e_tx_dr{
diff --git a/drivers/net/apne.c b/drivers/net/apne.c
index 9164d8cd670e..d4e408169073 100644
--- a/drivers/net/apne.c
+++ b/drivers/net/apne.c
@@ -568,7 +568,7 @@ static irqreturn_t apne_interrupt(int irq, void *dev_id)
568#ifdef MODULE 568#ifdef MODULE
569static struct net_device *apne_dev; 569static struct net_device *apne_dev;
570 570
571int init_module(void) 571int __init init_module(void)
572{ 572{
573 apne_dev = apne_probe(-1); 573 apne_dev = apne_probe(-1);
574 if (IS_ERR(apne_dev)) 574 if (IS_ERR(apne_dev))
@@ -576,7 +576,7 @@ int init_module(void)
576 return 0; 576 return 0;
577} 577}
578 578
579void cleanup_module(void) 579void __exit cleanup_module(void)
580{ 580{
581 unregister_netdev(apne_dev); 581 unregister_netdev(apne_dev);
582 582
diff --git a/drivers/net/appletalk/cops.c b/drivers/net/appletalk/cops.c
index cc1a27ed197f..dba5e5165452 100644
--- a/drivers/net/appletalk/cops.c
+++ b/drivers/net/appletalk/cops.c
@@ -1041,7 +1041,7 @@ int __init init_module(void)
1041 return 0; 1041 return 0;
1042} 1042}
1043 1043
1044void cleanup_module(void) 1044void __exit cleanup_module(void)
1045{ 1045{
1046 unregister_netdev(cops_dev); 1046 unregister_netdev(cops_dev);
1047 cleanup_card(cops_dev); 1047 cleanup_card(cops_dev);
diff --git a/drivers/net/arcnet/com20020.c b/drivers/net/arcnet/com20020.c
index 0dc70c7b7940..aa9dd8f11269 100644
--- a/drivers/net/arcnet/com20020.c
+++ b/drivers/net/arcnet/com20020.c
@@ -337,13 +337,16 @@ static void com20020_set_mc_list(struct net_device *dev)
337 } 337 }
338} 338}
339 339
340#ifdef MODULE 340#if defined(CONFIG_ARCNET_COM20020_PCI_MODULE) || \
341 341 defined(CONFIG_ARCNET_COM20020_ISA_MODULE)
342EXPORT_SYMBOL(com20020_check); 342EXPORT_SYMBOL(com20020_check);
343EXPORT_SYMBOL(com20020_found); 343EXPORT_SYMBOL(com20020_found);
344#endif
344 345
345MODULE_LICENSE("GPL"); 346MODULE_LICENSE("GPL");
346 347
348#ifdef MODULE
349
347int init_module(void) 350int init_module(void)
348{ 351{
349 BUGLVL(D_NORMAL) printk(VERSION); 352 BUGLVL(D_NORMAL) printk(VERSION);
diff --git a/drivers/net/arm/at91_ether.c b/drivers/net/arm/at91_ether.c
index b54b857e357e..fada15d959de 100644
--- a/drivers/net/arm/at91_ether.c
+++ b/drivers/net/arm/at91_ether.c
@@ -41,9 +41,6 @@
41#define DRV_NAME "at91_ether" 41#define DRV_NAME "at91_ether"
42#define DRV_VERSION "1.0" 42#define DRV_VERSION "1.0"
43 43
44static struct net_device *at91_dev;
45
46static struct timer_list check_timer;
47#define LINK_POLL_INTERVAL (HZ) 44#define LINK_POLL_INTERVAL (HZ)
48 45
49/* ..................................................................... */ 46/* ..................................................................... */
@@ -146,7 +143,7 @@ static void read_phy(unsigned char phy_addr, unsigned char address, unsigned int
146 */ 143 */
147static void update_linkspeed(struct net_device *dev, int silent) 144static void update_linkspeed(struct net_device *dev, int silent)
148{ 145{
149 struct at91_private *lp = (struct at91_private *) dev->priv; 146 struct at91_private *lp = netdev_priv(dev);
150 unsigned int bmsr, bmcr, lpa, mac_cfg; 147 unsigned int bmsr, bmcr, lpa, mac_cfg;
151 unsigned int speed, duplex; 148 unsigned int speed, duplex;
152 149
@@ -199,7 +196,7 @@ static void update_linkspeed(struct net_device *dev, int silent)
199static irqreturn_t at91ether_phy_interrupt(int irq, void *dev_id) 196static irqreturn_t at91ether_phy_interrupt(int irq, void *dev_id)
200{ 197{
201 struct net_device *dev = (struct net_device *) dev_id; 198 struct net_device *dev = (struct net_device *) dev_id;
202 struct at91_private *lp = (struct at91_private *) dev->priv; 199 struct at91_private *lp = netdev_priv(dev);
203 unsigned int phy; 200 unsigned int phy;
204 201
205 /* 202 /*
@@ -242,7 +239,7 @@ done:
242 */ 239 */
243static void enable_phyirq(struct net_device *dev) 240static void enable_phyirq(struct net_device *dev)
244{ 241{
245 struct at91_private *lp = (struct at91_private *) dev->priv; 242 struct at91_private *lp = netdev_priv(dev);
246 unsigned int dsintr, irq_number; 243 unsigned int dsintr, irq_number;
247 int status; 244 int status;
248 245
@@ -252,8 +249,7 @@ static void enable_phyirq(struct net_device *dev)
252 * PHY doesn't have an IRQ pin (RTL8201, DP83847, AC101L), 249 * PHY doesn't have an IRQ pin (RTL8201, DP83847, AC101L),
253 * or board does not have it connected. 250 * or board does not have it connected.
254 */ 251 */
255 check_timer.expires = jiffies + LINK_POLL_INTERVAL; 252 mod_timer(&lp->check_timer, jiffies + LINK_POLL_INTERVAL);
256 add_timer(&check_timer);
257 return; 253 return;
258 } 254 }
259 255
@@ -294,13 +290,13 @@ static void enable_phyirq(struct net_device *dev)
294 */ 290 */
295static void disable_phyirq(struct net_device *dev) 291static void disable_phyirq(struct net_device *dev)
296{ 292{
297 struct at91_private *lp = (struct at91_private *) dev->priv; 293 struct at91_private *lp = netdev_priv(dev);
298 unsigned int dsintr; 294 unsigned int dsintr;
299 unsigned int irq_number; 295 unsigned int irq_number;
300 296
301 irq_number = lp->board_data.phy_irq_pin; 297 irq_number = lp->board_data.phy_irq_pin;
302 if (!irq_number) { 298 if (!irq_number) {
303 del_timer_sync(&check_timer); 299 del_timer_sync(&lp->check_timer);
304 return; 300 return;
305 } 301 }
306 302
@@ -340,7 +336,7 @@ static void disable_phyirq(struct net_device *dev)
340#if 0 336#if 0
341static void reset_phy(struct net_device *dev) 337static void reset_phy(struct net_device *dev)
342{ 338{
343 struct at91_private *lp = (struct at91_private *) dev->priv; 339 struct at91_private *lp = netdev_priv(dev);
344 unsigned int bmcr; 340 unsigned int bmcr;
345 341
346 spin_lock_irq(&lp->lock); 342 spin_lock_irq(&lp->lock);
@@ -362,13 +358,13 @@ static void reset_phy(struct net_device *dev)
362static void at91ether_check_link(unsigned long dev_id) 358static void at91ether_check_link(unsigned long dev_id)
363{ 359{
364 struct net_device *dev = (struct net_device *) dev_id; 360 struct net_device *dev = (struct net_device *) dev_id;
361 struct at91_private *lp = netdev_priv(dev);
365 362
366 enable_mdi(); 363 enable_mdi();
367 update_linkspeed(dev, 1); 364 update_linkspeed(dev, 1);
368 disable_mdi(); 365 disable_mdi();
369 366
370 check_timer.expires = jiffies + LINK_POLL_INTERVAL; 367 mod_timer(&lp->check_timer, jiffies + LINK_POLL_INTERVAL);
371 add_timer(&check_timer);
372} 368}
373 369
374/* ......................... ADDRESS MANAGEMENT ........................ */ 370/* ......................... ADDRESS MANAGEMENT ........................ */
@@ -590,7 +586,7 @@ static void mdio_write(struct net_device *dev, int phy_id, int location, int val
590 586
591static int at91ether_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) 587static int at91ether_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
592{ 588{
593 struct at91_private *lp = (struct at91_private *) dev->priv; 589 struct at91_private *lp = netdev_priv(dev);
594 int ret; 590 int ret;
595 591
596 spin_lock_irq(&lp->lock); 592 spin_lock_irq(&lp->lock);
@@ -611,7 +607,7 @@ static int at91ether_get_settings(struct net_device *dev, struct ethtool_cmd *cm
611 607
612static int at91ether_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) 608static int at91ether_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
613{ 609{
614 struct at91_private *lp = (struct at91_private *) dev->priv; 610 struct at91_private *lp = netdev_priv(dev);
615 int ret; 611 int ret;
616 612
617 spin_lock_irq(&lp->lock); 613 spin_lock_irq(&lp->lock);
@@ -627,7 +623,7 @@ static int at91ether_set_settings(struct net_device *dev, struct ethtool_cmd *cm
627 623
628static int at91ether_nwayreset(struct net_device *dev) 624static int at91ether_nwayreset(struct net_device *dev)
629{ 625{
630 struct at91_private *lp = (struct at91_private *) dev->priv; 626 struct at91_private *lp = netdev_priv(dev);
631 int ret; 627 int ret;
632 628
633 spin_lock_irq(&lp->lock); 629 spin_lock_irq(&lp->lock);
@@ -658,7 +654,7 @@ static const struct ethtool_ops at91ether_ethtool_ops = {
658 654
659static int at91ether_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) 655static int at91ether_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
660{ 656{
661 struct at91_private *lp = (struct at91_private *) dev->priv; 657 struct at91_private *lp = netdev_priv(dev);
662 int res; 658 int res;
663 659
664 if (!netif_running(dev)) 660 if (!netif_running(dev))
@@ -680,7 +676,7 @@ static int at91ether_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
680 */ 676 */
681static void at91ether_start(struct net_device *dev) 677static void at91ether_start(struct net_device *dev)
682{ 678{
683 struct at91_private *lp = (struct at91_private *) dev->priv; 679 struct at91_private *lp = netdev_priv(dev);
684 struct recv_desc_bufs *dlist, *dlist_phys; 680 struct recv_desc_bufs *dlist, *dlist_phys;
685 int i; 681 int i;
686 unsigned long ctl; 682 unsigned long ctl;
@@ -712,7 +708,7 @@ static void at91ether_start(struct net_device *dev)
712 */ 708 */
713static int at91ether_open(struct net_device *dev) 709static int at91ether_open(struct net_device *dev)
714{ 710{
715 struct at91_private *lp = (struct at91_private *) dev->priv; 711 struct at91_private *lp = netdev_priv(dev);
716 unsigned long ctl; 712 unsigned long ctl;
717 713
718 if (!is_valid_ether_addr(dev->dev_addr)) 714 if (!is_valid_ether_addr(dev->dev_addr))
@@ -752,7 +748,7 @@ static int at91ether_open(struct net_device *dev)
752 */ 748 */
753static int at91ether_close(struct net_device *dev) 749static int at91ether_close(struct net_device *dev)
754{ 750{
755 struct at91_private *lp = (struct at91_private *) dev->priv; 751 struct at91_private *lp = netdev_priv(dev);
756 unsigned long ctl; 752 unsigned long ctl;
757 753
758 /* Disable Receiver and Transmitter */ 754 /* Disable Receiver and Transmitter */
@@ -779,7 +775,7 @@ static int at91ether_close(struct net_device *dev)
779 */ 775 */
780static int at91ether_tx(struct sk_buff *skb, struct net_device *dev) 776static int at91ether_tx(struct sk_buff *skb, struct net_device *dev)
781{ 777{
782 struct at91_private *lp = (struct at91_private *) dev->priv; 778 struct at91_private *lp = netdev_priv(dev);
783 779
784 if (at91_emac_read(AT91_EMAC_TSR) & AT91_EMAC_TSR_BNQ) { 780 if (at91_emac_read(AT91_EMAC_TSR) & AT91_EMAC_TSR_BNQ) {
785 netif_stop_queue(dev); 781 netif_stop_queue(dev);
@@ -811,7 +807,7 @@ static int at91ether_tx(struct sk_buff *skb, struct net_device *dev)
811 */ 807 */
812static struct net_device_stats *at91ether_stats(struct net_device *dev) 808static struct net_device_stats *at91ether_stats(struct net_device *dev)
813{ 809{
814 struct at91_private *lp = (struct at91_private *) dev->priv; 810 struct at91_private *lp = netdev_priv(dev);
815 int ale, lenerr, seqe, lcol, ecol; 811 int ale, lenerr, seqe, lcol, ecol;
816 812
817 if (netif_running(dev)) { 813 if (netif_running(dev)) {
@@ -847,7 +843,7 @@ static struct net_device_stats *at91ether_stats(struct net_device *dev)
847 */ 843 */
848static void at91ether_rx(struct net_device *dev) 844static void at91ether_rx(struct net_device *dev)
849{ 845{
850 struct at91_private *lp = (struct at91_private *) dev->priv; 846 struct at91_private *lp = netdev_priv(dev);
851 struct recv_desc_bufs *dlist; 847 struct recv_desc_bufs *dlist;
852 unsigned char *p_recv; 848 unsigned char *p_recv;
853 struct sk_buff *skb; 849 struct sk_buff *skb;
@@ -857,14 +853,13 @@ static void at91ether_rx(struct net_device *dev)
857 while (dlist->descriptors[lp->rxBuffIndex].addr & EMAC_DESC_DONE) { 853 while (dlist->descriptors[lp->rxBuffIndex].addr & EMAC_DESC_DONE) {
858 p_recv = dlist->recv_buf[lp->rxBuffIndex]; 854 p_recv = dlist->recv_buf[lp->rxBuffIndex];
859 pktlen = dlist->descriptors[lp->rxBuffIndex].size & 0x7ff; /* Length of frame including FCS */ 855 pktlen = dlist->descriptors[lp->rxBuffIndex].size & 0x7ff; /* Length of frame including FCS */
860 skb = alloc_skb(pktlen + 2, GFP_ATOMIC); 856 skb = dev_alloc_skb(pktlen + 2);
861 if (skb != NULL) { 857 if (skb != NULL) {
862 skb_reserve(skb, 2); 858 skb_reserve(skb, 2);
863 memcpy(skb_put(skb, pktlen), p_recv, pktlen); 859 memcpy(skb_put(skb, pktlen), p_recv, pktlen);
864 860
865 skb->dev = dev; 861 skb->dev = dev;
866 skb->protocol = eth_type_trans(skb, dev); 862 skb->protocol = eth_type_trans(skb, dev);
867 skb->len = pktlen;
868 dev->last_rx = jiffies; 863 dev->last_rx = jiffies;
869 lp->stats.rx_bytes += pktlen; 864 lp->stats.rx_bytes += pktlen;
870 netif_rx(skb); 865 netif_rx(skb);
@@ -891,7 +886,7 @@ static void at91ether_rx(struct net_device *dev)
891static irqreturn_t at91ether_interrupt(int irq, void *dev_id) 886static irqreturn_t at91ether_interrupt(int irq, void *dev_id)
892{ 887{
893 struct net_device *dev = (struct net_device *) dev_id; 888 struct net_device *dev = (struct net_device *) dev_id;
894 struct at91_private *lp = (struct at91_private *) dev->priv; 889 struct at91_private *lp = netdev_priv(dev);
895 unsigned long intstatus, ctl; 890 unsigned long intstatus, ctl;
896 891
897 /* MAC Interrupt Status register indicates what interrupts are pending. 892 /* MAC Interrupt Status register indicates what interrupts are pending.
@@ -927,6 +922,17 @@ static irqreturn_t at91ether_interrupt(int irq, void *dev_id)
927 return IRQ_HANDLED; 922 return IRQ_HANDLED;
928} 923}
929 924
925#ifdef CONFIG_NET_POLL_CONTROLLER
926static void at91ether_poll_controller(struct net_device *dev)
927{
928 unsigned long flags;
929
930 local_irq_save(flags);
931 at91ether_interrupt(dev->irq, dev);
932 local_irq_restore(flags);
933}
934#endif
935
930/* 936/*
931 * Initialize the ethernet interface 937 * Initialize the ethernet interface
932 */ 938 */
@@ -939,9 +945,6 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add
939 unsigned int val; 945 unsigned int val;
940 int res; 946 int res;
941 947
942 if (at91_dev) /* already initialized */
943 return 0;
944
945 dev = alloc_etherdev(sizeof(struct at91_private)); 948 dev = alloc_etherdev(sizeof(struct at91_private));
946 if (!dev) 949 if (!dev)
947 return -ENOMEM; 950 return -ENOMEM;
@@ -957,7 +960,7 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add
957 } 960 }
958 961
959 /* Allocate memory for DMA Receive descriptors */ 962 /* Allocate memory for DMA Receive descriptors */
960 lp = (struct at91_private *)dev->priv; 963 lp = netdev_priv(dev);
961 lp->dlist = (struct recv_desc_bufs *) dma_alloc_coherent(NULL, sizeof(struct recv_desc_bufs), (dma_addr_t *) &lp->dlist_phys, GFP_KERNEL); 964 lp->dlist = (struct recv_desc_bufs *) dma_alloc_coherent(NULL, sizeof(struct recv_desc_bufs), (dma_addr_t *) &lp->dlist_phys, GFP_KERNEL);
962 if (lp->dlist == NULL) { 965 if (lp->dlist == NULL) {
963 free_irq(dev->irq, dev); 966 free_irq(dev->irq, dev);
@@ -979,6 +982,9 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add
979 dev->set_mac_address = set_mac_address; 982 dev->set_mac_address = set_mac_address;
980 dev->ethtool_ops = &at91ether_ethtool_ops; 983 dev->ethtool_ops = &at91ether_ethtool_ops;
981 dev->do_ioctl = at91ether_ioctl; 984 dev->do_ioctl = at91ether_ioctl;
985#ifdef CONFIG_NET_POLL_CONTROLLER
986 dev->poll_controller = at91ether_poll_controller;
987#endif
982 988
983 SET_NETDEV_DEV(dev, &pdev->dev); 989 SET_NETDEV_DEV(dev, &pdev->dev);
984 990
@@ -1024,7 +1030,6 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add
1024 dma_free_coherent(NULL, sizeof(struct recv_desc_bufs), lp->dlist, (dma_addr_t)lp->dlist_phys); 1030 dma_free_coherent(NULL, sizeof(struct recv_desc_bufs), lp->dlist, (dma_addr_t)lp->dlist_phys);
1025 return res; 1031 return res;
1026 } 1032 }
1027 at91_dev = dev;
1028 1033
1029 /* Determine current link speed */ 1034 /* Determine current link speed */
1030 spin_lock_irq(&lp->lock); 1035 spin_lock_irq(&lp->lock);
@@ -1036,9 +1041,9 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add
1036 1041
1037 /* If board has no PHY IRQ, use a timer to poll the PHY */ 1042 /* If board has no PHY IRQ, use a timer to poll the PHY */
1038 if (!lp->board_data.phy_irq_pin) { 1043 if (!lp->board_data.phy_irq_pin) {
1039 init_timer(&check_timer); 1044 init_timer(&lp->check_timer);
1040 check_timer.data = (unsigned long)dev; 1045 lp->check_timer.data = (unsigned long)dev;
1041 check_timer.function = at91ether_check_link; 1046 lp->check_timer.function = at91ether_check_link;
1042 } 1047 }
1043 1048
1044 /* Display ethernet banner */ 1049 /* Display ethernet banner */
@@ -1115,15 +1120,16 @@ static int __init at91ether_probe(struct platform_device *pdev)
1115 1120
1116static int __devexit at91ether_remove(struct platform_device *pdev) 1121static int __devexit at91ether_remove(struct platform_device *pdev)
1117{ 1122{
1118 struct at91_private *lp = (struct at91_private *) at91_dev->priv; 1123 struct net_device *dev = platform_get_drvdata(pdev);
1124 struct at91_private *lp = netdev_priv(dev);
1119 1125
1120 unregister_netdev(at91_dev); 1126 unregister_netdev(dev);
1121 free_irq(at91_dev->irq, at91_dev); 1127 free_irq(dev->irq, dev);
1122 dma_free_coherent(NULL, sizeof(struct recv_desc_bufs), lp->dlist, (dma_addr_t)lp->dlist_phys); 1128 dma_free_coherent(NULL, sizeof(struct recv_desc_bufs), lp->dlist, (dma_addr_t)lp->dlist_phys);
1123 clk_put(lp->ether_clk); 1129 clk_put(lp->ether_clk);
1124 1130
1125 free_netdev(at91_dev); 1131 platform_set_drvdata(pdev, NULL);
1126 at91_dev = NULL; 1132 free_netdev(dev);
1127 return 0; 1133 return 0;
1128} 1134}
1129 1135
@@ -1131,8 +1137,8 @@ static int __devexit at91ether_remove(struct platform_device *pdev)
1131 1137
1132static int at91ether_suspend(struct platform_device *pdev, pm_message_t mesg) 1138static int at91ether_suspend(struct platform_device *pdev, pm_message_t mesg)
1133{ 1139{
1134 struct at91_private *lp = (struct at91_private *) at91_dev->priv;
1135 struct net_device *net_dev = platform_get_drvdata(pdev); 1140 struct net_device *net_dev = platform_get_drvdata(pdev);
1141 struct at91_private *lp = netdev_priv(net_dev);
1136 int phy_irq = lp->board_data.phy_irq_pin; 1142 int phy_irq = lp->board_data.phy_irq_pin;
1137 1143
1138 if (netif_running(net_dev)) { 1144 if (netif_running(net_dev)) {
@@ -1149,8 +1155,8 @@ static int at91ether_suspend(struct platform_device *pdev, pm_message_t mesg)
1149 1155
1150static int at91ether_resume(struct platform_device *pdev) 1156static int at91ether_resume(struct platform_device *pdev)
1151{ 1157{
1152 struct at91_private *lp = (struct at91_private *) at91_dev->priv;
1153 struct net_device *net_dev = platform_get_drvdata(pdev); 1158 struct net_device *net_dev = platform_get_drvdata(pdev);
1159 struct at91_private *lp = netdev_priv(net_dev);
1154 int phy_irq = lp->board_data.phy_irq_pin; 1160 int phy_irq = lp->board_data.phy_irq_pin;
1155 1161
1156 if (netif_running(net_dev)) { 1162 if (netif_running(net_dev)) {
diff --git a/drivers/net/arm/at91_ether.h b/drivers/net/arm/at91_ether.h
index d1e72e02be3a..b6b665de2ea0 100644
--- a/drivers/net/arm/at91_ether.h
+++ b/drivers/net/arm/at91_ether.h
@@ -87,6 +87,7 @@ struct at91_private
87 spinlock_t lock; /* lock for MDI interface */ 87 spinlock_t lock; /* lock for MDI interface */
88 short phy_media; /* media interface type */ 88 short phy_media; /* media interface type */
89 unsigned short phy_address; /* 5-bit MDI address of PHY (0..31) */ 89 unsigned short phy_address; /* 5-bit MDI address of PHY (0..31) */
90 struct timer_list check_timer; /* Poll link status */
90 91
91 /* Transmit */ 92 /* Transmit */
92 struct sk_buff *skb; /* holds skb until xmit interrupt completes */ 93 struct sk_buff *skb; /* holds skb until xmit interrupt completes */
diff --git a/drivers/net/arm/ether1.c b/drivers/net/arm/ether1.c
index f3478a30e778..d6da3ce9ad79 100644
--- a/drivers/net/arm/ether1.c
+++ b/drivers/net/arm/ether1.c
@@ -254,7 +254,7 @@ ether1_readbuffer (struct net_device *dev, void *data, unsigned int start, unsig
254 } while (thislen); 254 } while (thislen);
255} 255}
256 256
257static int __init 257static int __devinit
258ether1_ramtest(struct net_device *dev, unsigned char byte) 258ether1_ramtest(struct net_device *dev, unsigned char byte)
259{ 259{
260 unsigned char *buffer = kmalloc (BUFFER_SIZE, GFP_KERNEL); 260 unsigned char *buffer = kmalloc (BUFFER_SIZE, GFP_KERNEL);
@@ -308,7 +308,7 @@ ether1_reset (struct net_device *dev)
308 return BUS_16; 308 return BUS_16;
309} 309}
310 310
311static int __init 311static int __devinit
312ether1_init_2(struct net_device *dev) 312ether1_init_2(struct net_device *dev)
313{ 313{
314 int i; 314 int i;
@@ -986,7 +986,7 @@ ether1_setmulticastlist (struct net_device *dev)
986 986
987/* ------------------------------------------------------------------------- */ 987/* ------------------------------------------------------------------------- */
988 988
989static void __init ether1_banner(void) 989static void __devinit ether1_banner(void)
990{ 990{
991 static unsigned int version_printed = 0; 991 static unsigned int version_printed = 0;
992 992
diff --git a/drivers/net/arm/ether3.c b/drivers/net/arm/ether3.c
index 84686c8a5bc2..4fc234785d56 100644
--- a/drivers/net/arm/ether3.c
+++ b/drivers/net/arm/ether3.c
@@ -198,7 +198,7 @@ static inline void ether3_ledon(struct net_device *dev)
198 * Read the ethernet address string from the on board rom. 198 * Read the ethernet address string from the on board rom.
199 * This is an ascii string!!! 199 * This is an ascii string!!!
200 */ 200 */
201static int __init 201static int __devinit
202ether3_addr(char *addr, struct expansion_card *ec) 202ether3_addr(char *addr, struct expansion_card *ec)
203{ 203{
204 struct in_chunk_dir cd; 204 struct in_chunk_dir cd;
@@ -223,7 +223,7 @@ ether3_addr(char *addr, struct expansion_card *ec)
223 223
224/* --------------------------------------------------------------------------- */ 224/* --------------------------------------------------------------------------- */
225 225
226static int __init 226static int __devinit
227ether3_ramtest(struct net_device *dev, unsigned char byte) 227ether3_ramtest(struct net_device *dev, unsigned char byte)
228{ 228{
229 unsigned char *buffer = kmalloc(RX_END, GFP_KERNEL); 229 unsigned char *buffer = kmalloc(RX_END, GFP_KERNEL);
@@ -272,7 +272,7 @@ ether3_ramtest(struct net_device *dev, unsigned char byte)
272 272
273/* ------------------------------------------------------------------------------- */ 273/* ------------------------------------------------------------------------------- */
274 274
275static int __init ether3_init_2(struct net_device *dev) 275static int __devinit ether3_init_2(struct net_device *dev)
276{ 276{
277 int i; 277 int i;
278 278
@@ -765,7 +765,7 @@ static void ether3_tx(struct net_device *dev)
765 } 765 }
766} 766}
767 767
768static void __init ether3_banner(void) 768static void __devinit ether3_banner(void)
769{ 769{
770 static unsigned version_printed = 0; 770 static unsigned version_printed = 0;
771 771
diff --git a/drivers/net/arm/etherh.c b/drivers/net/arm/etherh.c
index 4ae98970b282..f3faa4fe58e7 100644
--- a/drivers/net/arm/etherh.c
+++ b/drivers/net/arm/etherh.c
@@ -52,7 +52,12 @@
52#include <asm/ecard.h> 52#include <asm/ecard.h>
53#include <asm/io.h> 53#include <asm/io.h>
54 54
55#include "../8390.h" 55#define EI_SHIFT(x) (ei_local->reg_offset[x])
56
57#define ei_inb(_p) readb((void __iomem *)_p)
58#define ei_outb(_v,_p) writeb(_v,(void __iomem *)_p)
59#define ei_inb_p(_p) readb((void __iomem *)_p)
60#define ei_outb_p(_v,_p) writeb(_v,(void __iomem *)_p)
56 61
57#define NET_DEBUG 0 62#define NET_DEBUG 0
58#define DEBUG_INIT 2 63#define DEBUG_INIT 2
@@ -60,6 +65,11 @@
60#define DRV_NAME "etherh" 65#define DRV_NAME "etherh"
61#define DRV_VERSION "1.11" 66#define DRV_VERSION "1.11"
62 67
68static char version[] __initdata =
69 "EtherH/EtherM Driver (c) 2002-2004 Russell King " DRV_VERSION "\n";
70
71#include "../lib8390.c"
72
63static unsigned int net_debug = NET_DEBUG; 73static unsigned int net_debug = NET_DEBUG;
64 74
65struct etherh_priv { 75struct etherh_priv {
@@ -87,9 +97,6 @@ MODULE_AUTHOR("Russell King");
87MODULE_DESCRIPTION("EtherH/EtherM driver"); 97MODULE_DESCRIPTION("EtherH/EtherM driver");
88MODULE_LICENSE("GPL"); 98MODULE_LICENSE("GPL");
89 99
90static char version[] __initdata =
91 "EtherH/EtherM Driver (c) 2002-2004 Russell King " DRV_VERSION "\n";
92
93#define ETHERH500_DATAPORT 0x800 /* MEMC */ 100#define ETHERH500_DATAPORT 0x800 /* MEMC */
94#define ETHERH500_NS8390 0x000 /* MEMC */ 101#define ETHERH500_NS8390 0x000 /* MEMC */
95#define ETHERH500_CTRLPORT 0x800 /* IOC */ 102#define ETHERH500_CTRLPORT 0x800 /* IOC */
@@ -177,7 +184,7 @@ etherh_setif(struct net_device *dev)
177 switch (etherh_priv(dev)->id) { 184 switch (etherh_priv(dev)->id) {
178 case PROD_I3_ETHERLAN600: 185 case PROD_I3_ETHERLAN600:
179 case PROD_I3_ETHERLAN600A: 186 case PROD_I3_ETHERLAN600A:
180 addr = (void *)dev->base_addr + EN0_RCNTHI; 187 addr = (void __iomem *)dev->base_addr + EN0_RCNTHI;
181 188
182 switch (dev->if_port) { 189 switch (dev->if_port) {
183 case IF_PORT_10BASE2: 190 case IF_PORT_10BASE2:
@@ -218,7 +225,7 @@ etherh_getifstat(struct net_device *dev)
218 switch (etherh_priv(dev)->id) { 225 switch (etherh_priv(dev)->id) {
219 case PROD_I3_ETHERLAN600: 226 case PROD_I3_ETHERLAN600:
220 case PROD_I3_ETHERLAN600A: 227 case PROD_I3_ETHERLAN600A:
221 addr = (void *)dev->base_addr + EN0_RCNTHI; 228 addr = (void __iomem *)dev->base_addr + EN0_RCNTHI;
222 switch (dev->if_port) { 229 switch (dev->if_port) {
223 case IF_PORT_10BASE2: 230 case IF_PORT_10BASE2:
224 stat = 1; 231 stat = 1;
@@ -281,7 +288,7 @@ static void
281etherh_reset(struct net_device *dev) 288etherh_reset(struct net_device *dev)
282{ 289{
283 struct ei_device *ei_local = netdev_priv(dev); 290 struct ei_device *ei_local = netdev_priv(dev);
284 void __iomem *addr = (void *)dev->base_addr; 291 void __iomem *addr = (void __iomem *)dev->base_addr;
285 292
286 writeb(E8390_NODMA+E8390_PAGE0+E8390_STOP, addr); 293 writeb(E8390_NODMA+E8390_PAGE0+E8390_STOP, addr);
287 294
@@ -327,7 +334,7 @@ etherh_block_output (struct net_device *dev, int count, const unsigned char *buf
327 334
328 ei_local->dmaing = 1; 335 ei_local->dmaing = 1;
329 336
330 addr = (void *)dev->base_addr; 337 addr = (void __iomem *)dev->base_addr;
331 dma_base = etherh_priv(dev)->dma_base; 338 dma_base = etherh_priv(dev)->dma_base;
332 339
333 count = (count + 1) & ~1; 340 count = (count + 1) & ~1;
@@ -360,7 +367,7 @@ etherh_block_output (struct net_device *dev, int count, const unsigned char *buf
360 printk(KERN_ERR "%s: timeout waiting for TX RDC\n", 367 printk(KERN_ERR "%s: timeout waiting for TX RDC\n",
361 dev->name); 368 dev->name);
362 etherh_reset (dev); 369 etherh_reset (dev);
363 NS8390_init (dev, 1); 370 __NS8390_init (dev, 1);
364 break; 371 break;
365 } 372 }
366 373
@@ -387,7 +394,7 @@ etherh_block_input (struct net_device *dev, int count, struct sk_buff *skb, int
387 394
388 ei_local->dmaing = 1; 395 ei_local->dmaing = 1;
389 396
390 addr = (void *)dev->base_addr; 397 addr = (void __iomem *)dev->base_addr;
391 dma_base = etherh_priv(dev)->dma_base; 398 dma_base = etherh_priv(dev)->dma_base;
392 399
393 buf = skb->data; 400 buf = skb->data;
@@ -427,7 +434,7 @@ etherh_get_header (struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_p
427 434
428 ei_local->dmaing = 1; 435 ei_local->dmaing = 1;
429 436
430 addr = (void *)dev->base_addr; 437 addr = (void __iomem *)dev->base_addr;
431 dma_base = etherh_priv(dev)->dma_base; 438 dma_base = etherh_priv(dev)->dma_base;
432 439
433 writeb (E8390_NODMA | E8390_PAGE0 | E8390_START, addr + E8390_CMD); 440 writeb (E8390_NODMA | E8390_PAGE0 | E8390_START, addr + E8390_CMD);
@@ -465,7 +472,7 @@ etherh_open(struct net_device *dev)
465 return -EINVAL; 472 return -EINVAL;
466 } 473 }
467 474
468 if (request_irq(dev->irq, ei_interrupt, 0, dev->name, dev)) 475 if (request_irq(dev->irq, __ei_interrupt, 0, dev->name, dev))
469 return -EAGAIN; 476 return -EAGAIN;
470 477
471 /* 478 /*
@@ -491,7 +498,7 @@ etherh_open(struct net_device *dev)
491 etherh_setif(dev); 498 etherh_setif(dev);
492 499
493 etherh_reset(dev); 500 etherh_reset(dev);
494 ei_open(dev); 501 __ei_open(dev);
495 502
496 return 0; 503 return 0;
497} 504}
@@ -502,7 +509,7 @@ etherh_open(struct net_device *dev)
502static int 509static int
503etherh_close(struct net_device *dev) 510etherh_close(struct net_device *dev)
504{ 511{
505 ei_close (dev); 512 __ei_close (dev);
506 free_irq (dev->irq, dev); 513 free_irq (dev->irq, dev);
507 return 0; 514 return 0;
508} 515}
@@ -650,7 +657,7 @@ etherh_probe(struct expansion_card *ec, const struct ecard_id *id)
650 if (ret) 657 if (ret)
651 goto out; 658 goto out;
652 659
653 dev = __alloc_ei_netdev(sizeof(struct etherh_priv)); 660 dev = ____alloc_ei_netdev(sizeof(struct etherh_priv));
654 if (!dev) { 661 if (!dev) {
655 ret = -ENOMEM; 662 ret = -ENOMEM;
656 goto release; 663 goto release;
@@ -736,7 +743,7 @@ etherh_probe(struct expansion_card *ec, const struct ecard_id *id)
736 ei_local->interface_num = 0; 743 ei_local->interface_num = 0;
737 744
738 etherh_reset(dev); 745 etherh_reset(dev);
739 NS8390_init(dev, 0); 746 __NS8390_init(dev, 0);
740 747
741 ret = register_netdev(dev); 748 ret = register_netdev(dev);
742 if (ret) 749 if (ret)
diff --git a/drivers/net/at1700.c b/drivers/net/at1700.c
index 8620a5b470f5..56ae8babd919 100644
--- a/drivers/net/at1700.c
+++ b/drivers/net/at1700.c
@@ -908,7 +908,7 @@ int __init init_module(void)
908 return 0; 908 return 0;
909} 909}
910 910
911void 911void __exit
912cleanup_module(void) 912cleanup_module(void)
913{ 913{
914 unregister_netdev(dev_at1700); 914 unregister_netdev(dev_at1700);
diff --git a/drivers/net/atarilance.c b/drivers/net/atarilance.c
index d79489e46249..7e37ac86a69a 100644
--- a/drivers/net/atarilance.c
+++ b/drivers/net/atarilance.c
@@ -1179,7 +1179,7 @@ static int lance_set_mac_address( struct net_device *dev, void *addr )
1179#ifdef MODULE 1179#ifdef MODULE
1180static struct net_device *atarilance_dev; 1180static struct net_device *atarilance_dev;
1181 1181
1182int init_module(void) 1182int __init init_module(void)
1183{ 1183{
1184 atarilance_dev = atarilance_probe(-1); 1184 atarilance_dev = atarilance_probe(-1);
1185 if (IS_ERR(atarilance_dev)) 1185 if (IS_ERR(atarilance_dev))
@@ -1187,7 +1187,7 @@ int init_module(void)
1187 return 0; 1187 return 0;
1188} 1188}
1189 1189
1190void cleanup_module(void) 1190void __exit cleanup_module(void)
1191{ 1191{
1192 unregister_netdev(atarilance_dev); 1192 unregister_netdev(atarilance_dev);
1193 free_irq(atarilance_dev->irq, atarilance_dev); 1193 free_irq(atarilance_dev->irq, atarilance_dev);
diff --git a/drivers/net/au1000_eth.c b/drivers/net/au1000_eth.c
index 7db3c8af0894..f0b6879a1c7d 100644
--- a/drivers/net/au1000_eth.c
+++ b/drivers/net/au1000_eth.c
@@ -360,7 +360,8 @@ static int mii_probe (struct net_device *dev)
360 BUG_ON(!phydev); 360 BUG_ON(!phydev);
361 BUG_ON(phydev->attached_dev); 361 BUG_ON(phydev->attached_dev);
362 362
363 phydev = phy_connect(dev, phydev->dev.bus_id, &au1000_adjust_link, 0); 363 phydev = phy_connect(dev, phydev->dev.bus_id, &au1000_adjust_link, 0,
364 PHY_INTERFACE_MODE_MII);
364 365
365 if (IS_ERR(phydev)) { 366 if (IS_ERR(phydev)) {
366 printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name); 367 printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name);
diff --git a/drivers/net/b44.c b/drivers/net/b44.c
index 1ec217433b4c..474a4e3438db 100644
--- a/drivers/net/b44.c
+++ b/drivers/net/b44.c
@@ -908,8 +908,9 @@ static irqreturn_t b44_interrupt(int irq, void *dev_id)
908 istat = br32(bp, B44_ISTAT); 908 istat = br32(bp, B44_ISTAT);
909 imask = br32(bp, B44_IMASK); 909 imask = br32(bp, B44_IMASK);
910 910
911 /* ??? What the fuck is the purpose of the interrupt mask 911 /* The interrupt mask register controls which interrupt bits
912 * ??? register if we have to mask it out by hand anyways? 912 * will actually raise an interrupt to the CPU when set by hw/firmware,
913 * but doesn't mask off the bits.
913 */ 914 */
914 istat &= imask; 915 istat &= imask;
915 if (istat) { 916 if (istat) {
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 01b76d3aa42f..5bacb7587df4 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -53,11 +53,12 @@
53 53
54#include "bnx2.h" 54#include "bnx2.h"
55#include "bnx2_fw.h" 55#include "bnx2_fw.h"
56#include "bnx2_fw2.h"
56 57
57#define DRV_MODULE_NAME "bnx2" 58#define DRV_MODULE_NAME "bnx2"
58#define PFX DRV_MODULE_NAME ": " 59#define PFX DRV_MODULE_NAME ": "
59#define DRV_MODULE_VERSION "1.4.45" 60#define DRV_MODULE_VERSION "1.5.1"
60#define DRV_MODULE_RELDATE "September 29, 2006" 61#define DRV_MODULE_RELDATE "November 15, 2006"
61 62
62#define RUN_AT(x) (jiffies + (x)) 63#define RUN_AT(x) (jiffies + (x))
63 64
@@ -85,6 +86,7 @@ typedef enum {
85 NC370F, 86 NC370F,
86 BCM5708, 87 BCM5708,
87 BCM5708S, 88 BCM5708S,
89 BCM5709,
88} board_t; 90} board_t;
89 91
90/* indexed by board_t, above */ 92/* indexed by board_t, above */
@@ -98,6 +100,7 @@ static const struct {
98 { "HP NC370F Multifunction Gigabit Server Adapter" }, 100 { "HP NC370F Multifunction Gigabit Server Adapter" },
99 { "Broadcom NetXtreme II BCM5708 1000Base-T" }, 101 { "Broadcom NetXtreme II BCM5708 1000Base-T" },
100 { "Broadcom NetXtreme II BCM5708 1000Base-SX" }, 102 { "Broadcom NetXtreme II BCM5708 1000Base-SX" },
103 { "Broadcom NetXtreme II BCM5709 1000Base-T" },
101 }; 104 };
102 105
103static struct pci_device_id bnx2_pci_tbl[] = { 106static struct pci_device_id bnx2_pci_tbl[] = {
@@ -115,6 +118,8 @@ static struct pci_device_id bnx2_pci_tbl[] = {
115 PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5706S }, 118 PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5706S },
116 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_NX2_5708S, 119 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_NX2_5708S,
117 PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5708S }, 120 PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5708S },
121 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_NX2_5709,
122 PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5709 },
118 { 0, } 123 { 0, }
119}; 124};
120 125
@@ -236,8 +241,23 @@ static void
236bnx2_ctx_wr(struct bnx2 *bp, u32 cid_addr, u32 offset, u32 val) 241bnx2_ctx_wr(struct bnx2 *bp, u32 cid_addr, u32 offset, u32 val)
237{ 242{
238 offset += cid_addr; 243 offset += cid_addr;
239 REG_WR(bp, BNX2_CTX_DATA_ADR, offset); 244 if (CHIP_NUM(bp) == CHIP_NUM_5709) {
240 REG_WR(bp, BNX2_CTX_DATA, val); 245 int i;
246
247 REG_WR(bp, BNX2_CTX_CTX_DATA, val);
248 REG_WR(bp, BNX2_CTX_CTX_CTRL,
249 offset | BNX2_CTX_CTX_CTRL_WRITE_REQ);
250 for (i = 0; i < 5; i++) {
251 u32 val;
252 val = REG_RD(bp, BNX2_CTX_CTX_CTRL);
253 if ((val & BNX2_CTX_CTX_CTRL_WRITE_REQ) == 0)
254 break;
255 udelay(5);
256 }
257 } else {
258 REG_WR(bp, BNX2_CTX_DATA_ADR, offset);
259 REG_WR(bp, BNX2_CTX_DATA, val);
260 }
241} 261}
242 262
243static int 263static int
@@ -403,6 +423,14 @@ bnx2_free_mem(struct bnx2 *bp)
403{ 423{
404 int i; 424 int i;
405 425
426 for (i = 0; i < bp->ctx_pages; i++) {
427 if (bp->ctx_blk[i]) {
428 pci_free_consistent(bp->pdev, BCM_PAGE_SIZE,
429 bp->ctx_blk[i],
430 bp->ctx_blk_mapping[i]);
431 bp->ctx_blk[i] = NULL;
432 }
433 }
406 if (bp->status_blk) { 434 if (bp->status_blk) {
407 pci_free_consistent(bp->pdev, bp->status_stats_size, 435 pci_free_consistent(bp->pdev, bp->status_stats_size,
408 bp->status_blk, bp->status_blk_mapping); 436 bp->status_blk, bp->status_blk_mapping);
@@ -481,6 +509,18 @@ bnx2_alloc_mem(struct bnx2 *bp)
481 509
482 bp->stats_blk_mapping = bp->status_blk_mapping + status_blk_size; 510 bp->stats_blk_mapping = bp->status_blk_mapping + status_blk_size;
483 511
512 if (CHIP_NUM(bp) == CHIP_NUM_5709) {
513 bp->ctx_pages = 0x2000 / BCM_PAGE_SIZE;
514 if (bp->ctx_pages == 0)
515 bp->ctx_pages = 1;
516 for (i = 0; i < bp->ctx_pages; i++) {
517 bp->ctx_blk[i] = pci_alloc_consistent(bp->pdev,
518 BCM_PAGE_SIZE,
519 &bp->ctx_blk_mapping[i]);
520 if (bp->ctx_blk[i] == NULL)
521 goto alloc_mem_err;
522 }
523 }
484 return 0; 524 return 0;
485 525
486alloc_mem_err: 526alloc_mem_err:
@@ -803,13 +843,13 @@ bnx2_set_mac_link(struct bnx2 *bp)
803 843
804 val &= ~(BNX2_EMAC_MODE_PORT | BNX2_EMAC_MODE_HALF_DUPLEX | 844 val &= ~(BNX2_EMAC_MODE_PORT | BNX2_EMAC_MODE_HALF_DUPLEX |
805 BNX2_EMAC_MODE_MAC_LOOP | BNX2_EMAC_MODE_FORCE_LINK | 845 BNX2_EMAC_MODE_MAC_LOOP | BNX2_EMAC_MODE_FORCE_LINK |
806 BNX2_EMAC_MODE_25G); 846 BNX2_EMAC_MODE_25G_MODE);
807 847
808 if (bp->link_up) { 848 if (bp->link_up) {
809 switch (bp->line_speed) { 849 switch (bp->line_speed) {
810 case SPEED_10: 850 case SPEED_10:
811 if (CHIP_NUM(bp) == CHIP_NUM_5708) { 851 if (CHIP_NUM(bp) != CHIP_NUM_5706) {
812 val |= BNX2_EMAC_MODE_PORT_MII_10; 852 val |= BNX2_EMAC_MODE_PORT_MII_10M;
813 break; 853 break;
814 } 854 }
815 /* fall through */ 855 /* fall through */
@@ -817,7 +857,7 @@ bnx2_set_mac_link(struct bnx2 *bp)
817 val |= BNX2_EMAC_MODE_PORT_MII; 857 val |= BNX2_EMAC_MODE_PORT_MII;
818 break; 858 break;
819 case SPEED_2500: 859 case SPEED_2500:
820 val |= BNX2_EMAC_MODE_25G; 860 val |= BNX2_EMAC_MODE_25G_MODE;
821 /* fall through */ 861 /* fall through */
822 case SPEED_1000: 862 case SPEED_1000:
823 val |= BNX2_EMAC_MODE_PORT_GMII; 863 val |= BNX2_EMAC_MODE_PORT_GMII;
@@ -860,7 +900,7 @@ bnx2_set_link(struct bnx2 *bp)
860 u32 bmsr; 900 u32 bmsr;
861 u8 link_up; 901 u8 link_up;
862 902
863 if (bp->loopback == MAC_LOOPBACK) { 903 if (bp->loopback == MAC_LOOPBACK || bp->loopback == PHY_LOOPBACK) {
864 bp->link_up = 1; 904 bp->link_up = 1;
865 return 0; 905 return 0;
866 } 906 }
@@ -902,6 +942,7 @@ bnx2_set_link(struct bnx2 *bp)
902 u32 bmcr; 942 u32 bmcr;
903 943
904 bnx2_read_phy(bp, MII_BMCR, &bmcr); 944 bnx2_read_phy(bp, MII_BMCR, &bmcr);
945 bmcr &= ~BCM5708S_BMCR_FORCE_2500;
905 if (!(bmcr & BMCR_ANENABLE)) { 946 if (!(bmcr & BMCR_ANENABLE)) {
906 bnx2_write_phy(bp, MII_BMCR, bmcr | 947 bnx2_write_phy(bp, MII_BMCR, bmcr |
907 BMCR_ANENABLE); 948 BMCR_ANENABLE);
@@ -988,7 +1029,21 @@ bnx2_setup_serdes_phy(struct bnx2 *bp)
988 u32 new_bmcr; 1029 u32 new_bmcr;
989 int force_link_down = 0; 1030 int force_link_down = 0;
990 1031
991 if (CHIP_NUM(bp) == CHIP_NUM_5708) { 1032 bnx2_read_phy(bp, MII_ADVERTISE, &adv);
1033 adv &= ~(ADVERTISE_1000XFULL | ADVERTISE_1000XHALF);
1034
1035 bnx2_read_phy(bp, MII_BMCR, &bmcr);
1036 new_bmcr = bmcr & ~(BMCR_ANENABLE | BCM5708S_BMCR_FORCE_2500);
1037 new_bmcr |= BMCR_SPEED1000;
1038 if (bp->req_line_speed == SPEED_2500) {
1039 new_bmcr |= BCM5708S_BMCR_FORCE_2500;
1040 bnx2_read_phy(bp, BCM5708S_UP1, &up1);
1041 if (!(up1 & BCM5708S_UP1_2G5)) {
1042 up1 |= BCM5708S_UP1_2G5;
1043 bnx2_write_phy(bp, BCM5708S_UP1, up1);
1044 force_link_down = 1;
1045 }
1046 } else if (CHIP_NUM(bp) == CHIP_NUM_5708) {
992 bnx2_read_phy(bp, BCM5708S_UP1, &up1); 1047 bnx2_read_phy(bp, BCM5708S_UP1, &up1);
993 if (up1 & BCM5708S_UP1_2G5) { 1048 if (up1 & BCM5708S_UP1_2G5) {
994 up1 &= ~BCM5708S_UP1_2G5; 1049 up1 &= ~BCM5708S_UP1_2G5;
@@ -997,12 +1052,6 @@ bnx2_setup_serdes_phy(struct bnx2 *bp)
997 } 1052 }
998 } 1053 }
999 1054
1000 bnx2_read_phy(bp, MII_ADVERTISE, &adv);
1001 adv &= ~(ADVERTISE_1000XFULL | ADVERTISE_1000XHALF);
1002
1003 bnx2_read_phy(bp, MII_BMCR, &bmcr);
1004 new_bmcr = bmcr & ~BMCR_ANENABLE;
1005 new_bmcr |= BMCR_SPEED1000;
1006 if (bp->req_duplex == DUPLEX_FULL) { 1055 if (bp->req_duplex == DUPLEX_FULL) {
1007 adv |= ADVERTISE_1000XFULL; 1056 adv |= ADVERTISE_1000XFULL;
1008 new_bmcr |= BMCR_FULLDPLX; 1057 new_bmcr |= BMCR_FULLDPLX;
@@ -1023,6 +1072,7 @@ bnx2_setup_serdes_phy(struct bnx2 *bp)
1023 bp->link_up = 0; 1072 bp->link_up = 0;
1024 netif_carrier_off(bp->dev); 1073 netif_carrier_off(bp->dev);
1025 bnx2_write_phy(bp, MII_BMCR, new_bmcr); 1074 bnx2_write_phy(bp, MII_BMCR, new_bmcr);
1075 bnx2_report_link(bp);
1026 } 1076 }
1027 bnx2_write_phy(bp, MII_ADVERTISE, adv); 1077 bnx2_write_phy(bp, MII_ADVERTISE, adv);
1028 bnx2_write_phy(bp, MII_BMCR, new_bmcr); 1078 bnx2_write_phy(bp, MII_BMCR, new_bmcr);
@@ -1048,30 +1098,26 @@ bnx2_setup_serdes_phy(struct bnx2 *bp)
1048 if ((adv != new_adv) || ((bmcr & BMCR_ANENABLE) == 0)) { 1098 if ((adv != new_adv) || ((bmcr & BMCR_ANENABLE) == 0)) {
1049 /* Force a link down visible on the other side */ 1099 /* Force a link down visible on the other side */
1050 if (bp->link_up) { 1100 if (bp->link_up) {
1051 int i;
1052
1053 bnx2_write_phy(bp, MII_BMCR, BMCR_LOOPBACK); 1101 bnx2_write_phy(bp, MII_BMCR, BMCR_LOOPBACK);
1054 for (i = 0; i < 110; i++) { 1102 spin_unlock_bh(&bp->phy_lock);
1055 udelay(100); 1103 msleep(20);
1056 } 1104 spin_lock_bh(&bp->phy_lock);
1057 } 1105 }
1058 1106
1059 bnx2_write_phy(bp, MII_ADVERTISE, new_adv); 1107 bnx2_write_phy(bp, MII_ADVERTISE, new_adv);
1060 bnx2_write_phy(bp, MII_BMCR, bmcr | BMCR_ANRESTART | 1108 bnx2_write_phy(bp, MII_BMCR, bmcr | BMCR_ANRESTART |
1061 BMCR_ANENABLE); 1109 BMCR_ANENABLE);
1062 if (CHIP_NUM(bp) == CHIP_NUM_5706) { 1110 /* Speed up link-up time when the link partner
1063 /* Speed up link-up time when the link partner 1111 * does not autonegotiate which is very common
1064 * does not autonegotiate which is very common 1112 * in blade servers. Some blade servers use
1065 * in blade servers. Some blade servers use 1113 * IPMI for kerboard input and it's important
1066 * IPMI for kerboard input and it's important 1114 * to minimize link disruptions. Autoneg. involves
1067 * to minimize link disruptions. Autoneg. involves 1115 * exchanging base pages plus 3 next pages and
1068 * exchanging base pages plus 3 next pages and 1116 * normally completes in about 120 msec.
1069 * normally completes in about 120 msec. 1117 */
1070 */ 1118 bp->current_interval = SERDES_AN_TIMEOUT;
1071 bp->current_interval = SERDES_AN_TIMEOUT; 1119 bp->serdes_an_pending = 1;
1072 bp->serdes_an_pending = 1; 1120 mod_timer(&bp->timer, jiffies + bp->current_interval);
1073 mod_timer(&bp->timer, jiffies + bp->current_interval);
1074 }
1075 } 1121 }
1076 1122
1077 return 0; 1123 return 0;
@@ -1153,7 +1199,6 @@ bnx2_setup_copper_phy(struct bnx2 *bp)
1153 } 1199 }
1154 if (new_bmcr != bmcr) { 1200 if (new_bmcr != bmcr) {
1155 u32 bmsr; 1201 u32 bmsr;
1156 int i = 0;
1157 1202
1158 bnx2_read_phy(bp, MII_BMSR, &bmsr); 1203 bnx2_read_phy(bp, MII_BMSR, &bmsr);
1159 bnx2_read_phy(bp, MII_BMSR, &bmsr); 1204 bnx2_read_phy(bp, MII_BMSR, &bmsr);
@@ -1161,12 +1206,12 @@ bnx2_setup_copper_phy(struct bnx2 *bp)
1161 if (bmsr & BMSR_LSTATUS) { 1206 if (bmsr & BMSR_LSTATUS) {
1162 /* Force link down */ 1207 /* Force link down */
1163 bnx2_write_phy(bp, MII_BMCR, BMCR_LOOPBACK); 1208 bnx2_write_phy(bp, MII_BMCR, BMCR_LOOPBACK);
1164 do { 1209 spin_unlock_bh(&bp->phy_lock);
1165 udelay(100); 1210 msleep(50);
1166 bnx2_read_phy(bp, MII_BMSR, &bmsr); 1211 spin_lock_bh(&bp->phy_lock);
1167 bnx2_read_phy(bp, MII_BMSR, &bmsr); 1212
1168 i++; 1213 bnx2_read_phy(bp, MII_BMSR, &bmsr);
1169 } while ((bmsr & BMSR_LSTATUS) && (i < 620)); 1214 bnx2_read_phy(bp, MII_BMSR, &bmsr);
1170 } 1215 }
1171 1216
1172 bnx2_write_phy(bp, MII_BMCR, new_bmcr); 1217 bnx2_write_phy(bp, MII_BMCR, new_bmcr);
@@ -1258,9 +1303,8 @@ bnx2_init_5706s_phy(struct bnx2 *bp)
1258{ 1303{
1259 bp->phy_flags &= ~PHY_PARALLEL_DETECT_FLAG; 1304 bp->phy_flags &= ~PHY_PARALLEL_DETECT_FLAG;
1260 1305
1261 if (CHIP_NUM(bp) == CHIP_NUM_5706) { 1306 if (CHIP_NUM(bp) == CHIP_NUM_5706)
1262 REG_WR(bp, BNX2_MISC_UNUSED0, 0x300); 1307 REG_WR(bp, BNX2_MISC_GP_HW_CTL0, 0x300);
1263 }
1264 1308
1265 if (bp->dev->mtu > 1500) { 1309 if (bp->dev->mtu > 1500) {
1266 u32 val; 1310 u32 val;
@@ -1397,13 +1441,13 @@ bnx2_set_phy_loopback(struct bnx2 *bp)
1397 for (i = 0; i < 10; i++) { 1441 for (i = 0; i < 10; i++) {
1398 if (bnx2_test_link(bp) == 0) 1442 if (bnx2_test_link(bp) == 0)
1399 break; 1443 break;
1400 udelay(10); 1444 msleep(100);
1401 } 1445 }
1402 1446
1403 mac_mode = REG_RD(bp, BNX2_EMAC_MODE); 1447 mac_mode = REG_RD(bp, BNX2_EMAC_MODE);
1404 mac_mode &= ~(BNX2_EMAC_MODE_PORT | BNX2_EMAC_MODE_HALF_DUPLEX | 1448 mac_mode &= ~(BNX2_EMAC_MODE_PORT | BNX2_EMAC_MODE_HALF_DUPLEX |
1405 BNX2_EMAC_MODE_MAC_LOOP | BNX2_EMAC_MODE_FORCE_LINK | 1449 BNX2_EMAC_MODE_MAC_LOOP | BNX2_EMAC_MODE_FORCE_LINK |
1406 BNX2_EMAC_MODE_25G); 1450 BNX2_EMAC_MODE_25G_MODE);
1407 1451
1408 mac_mode |= BNX2_EMAC_MODE_PORT_GMII; 1452 mac_mode |= BNX2_EMAC_MODE_PORT_GMII;
1409 REG_WR(bp, BNX2_EMAC_MODE, mac_mode); 1453 REG_WR(bp, BNX2_EMAC_MODE, mac_mode);
@@ -1454,6 +1498,40 @@ bnx2_fw_sync(struct bnx2 *bp, u32 msg_data, int silent)
1454 return 0; 1498 return 0;
1455} 1499}
1456 1500
1501static int
1502bnx2_init_5709_context(struct bnx2 *bp)
1503{
1504 int i, ret = 0;
1505 u32 val;
1506
1507 val = BNX2_CTX_COMMAND_ENABLED | BNX2_CTX_COMMAND_MEM_INIT | (1 << 12);
1508 val |= (BCM_PAGE_BITS - 8) << 16;
1509 REG_WR(bp, BNX2_CTX_COMMAND, val);
1510 for (i = 0; i < bp->ctx_pages; i++) {
1511 int j;
1512
1513 REG_WR(bp, BNX2_CTX_HOST_PAGE_TBL_DATA0,
1514 (bp->ctx_blk_mapping[i] & 0xffffffff) |
1515 BNX2_CTX_HOST_PAGE_TBL_DATA0_VALID);
1516 REG_WR(bp, BNX2_CTX_HOST_PAGE_TBL_DATA1,
1517 (u64) bp->ctx_blk_mapping[i] >> 32);
1518 REG_WR(bp, BNX2_CTX_HOST_PAGE_TBL_CTRL, i |
1519 BNX2_CTX_HOST_PAGE_TBL_CTRL_WRITE_REQ);
1520 for (j = 0; j < 10; j++) {
1521
1522 val = REG_RD(bp, BNX2_CTX_HOST_PAGE_TBL_CTRL);
1523 if (!(val & BNX2_CTX_HOST_PAGE_TBL_CTRL_WRITE_REQ))
1524 break;
1525 udelay(5);
1526 }
1527 if (val & BNX2_CTX_HOST_PAGE_TBL_CTRL_WRITE_REQ) {
1528 ret = -EBUSY;
1529 break;
1530 }
1531 }
1532 return ret;
1533}
1534
1457static void 1535static void
1458bnx2_init_context(struct bnx2 *bp) 1536bnx2_init_context(struct bnx2 *bp)
1459{ 1537{
@@ -1576,9 +1654,8 @@ bnx2_alloc_rx_skb(struct bnx2 *bp, u16 index)
1576 return -ENOMEM; 1654 return -ENOMEM;
1577 } 1655 }
1578 1656
1579 if (unlikely((align = (unsigned long) skb->data & 0x7))) { 1657 if (unlikely((align = (unsigned long) skb->data & (BNX2_RX_ALIGN - 1))))
1580 skb_reserve(skb, 8 - align); 1658 skb_reserve(skb, BNX2_RX_ALIGN - align);
1581 }
1582 1659
1583 mapping = pci_map_single(bp->pdev, skb->data, bp->rx_buf_use_size, 1660 mapping = pci_map_single(bp->pdev, skb->data, bp->rx_buf_use_size,
1584 PCI_DMA_FROMDEVICE); 1661 PCI_DMA_FROMDEVICE);
@@ -2040,7 +2117,8 @@ bnx2_set_rx_mode(struct net_device *dev)
2040 if (dev->flags & IFF_PROMISC) { 2117 if (dev->flags & IFF_PROMISC) {
2041 /* Promiscuous mode. */ 2118 /* Promiscuous mode. */
2042 rx_mode |= BNX2_EMAC_RX_MODE_PROMISCUOUS; 2119 rx_mode |= BNX2_EMAC_RX_MODE_PROMISCUOUS;
2043 sort_mode |= BNX2_RPM_SORT_USER0_PROM_EN; 2120 sort_mode |= BNX2_RPM_SORT_USER0_PROM_EN |
2121 BNX2_RPM_SORT_USER0_PROM_VLAN;
2044 } 2122 }
2045 else if (dev->flags & IFF_ALLMULTI) { 2123 else if (dev->flags & IFF_ALLMULTI) {
2046 for (i = 0; i < NUM_MC_HASH_REGISTERS; i++) { 2124 for (i = 0; i < NUM_MC_HASH_REGISTERS; i++) {
@@ -2208,11 +2286,12 @@ load_rv2p_fw(struct bnx2 *bp, u32 *rv2p_code, u32 rv2p_code_len,
2208 } 2286 }
2209} 2287}
2210 2288
2211static void 2289static int
2212load_cpu_fw(struct bnx2 *bp, struct cpu_reg *cpu_reg, struct fw_info *fw) 2290load_cpu_fw(struct bnx2 *bp, struct cpu_reg *cpu_reg, struct fw_info *fw)
2213{ 2291{
2214 u32 offset; 2292 u32 offset;
2215 u32 val; 2293 u32 val;
2294 int rc;
2216 2295
2217 /* Halt the CPU. */ 2296 /* Halt the CPU. */
2218 val = REG_RD_IND(bp, cpu_reg->mode); 2297 val = REG_RD_IND(bp, cpu_reg->mode);
@@ -2222,7 +2301,18 @@ load_cpu_fw(struct bnx2 *bp, struct cpu_reg *cpu_reg, struct fw_info *fw)
2222 2301
2223 /* Load the Text area. */ 2302 /* Load the Text area. */
2224 offset = cpu_reg->spad_base + (fw->text_addr - cpu_reg->mips_view_base); 2303 offset = cpu_reg->spad_base + (fw->text_addr - cpu_reg->mips_view_base);
2225 if (fw->text) { 2304 if (fw->gz_text) {
2305 u32 text_len;
2306 void *text;
2307
2308 rc = bnx2_gunzip(bp, fw->gz_text, fw->gz_text_len, &text,
2309 &text_len);
2310 if (rc)
2311 return rc;
2312
2313 fw->text = text;
2314 }
2315 if (fw->gz_text) {
2226 int j; 2316 int j;
2227 2317
2228 for (j = 0; j < (fw->text_len / 4); j++, offset += 4) { 2318 for (j = 0; j < (fw->text_len / 4); j++, offset += 4) {
@@ -2280,13 +2370,15 @@ load_cpu_fw(struct bnx2 *bp, struct cpu_reg *cpu_reg, struct fw_info *fw)
2280 val &= ~cpu_reg->mode_value_halt; 2370 val &= ~cpu_reg->mode_value_halt;
2281 REG_WR_IND(bp, cpu_reg->state, cpu_reg->state_value_clear); 2371 REG_WR_IND(bp, cpu_reg->state, cpu_reg->state_value_clear);
2282 REG_WR_IND(bp, cpu_reg->mode, val); 2372 REG_WR_IND(bp, cpu_reg->mode, val);
2373
2374 return 0;
2283} 2375}
2284 2376
2285static int 2377static int
2286bnx2_init_cpus(struct bnx2 *bp) 2378bnx2_init_cpus(struct bnx2 *bp)
2287{ 2379{
2288 struct cpu_reg cpu_reg; 2380 struct cpu_reg cpu_reg;
2289 struct fw_info fw; 2381 struct fw_info *fw;
2290 int rc = 0; 2382 int rc = 0;
2291 void *text; 2383 void *text;
2292 u32 text_len; 2384 u32 text_len;
@@ -2323,44 +2415,15 @@ bnx2_init_cpus(struct bnx2 *bp)
2323 cpu_reg.spad_base = BNX2_RXP_SCRATCH; 2415 cpu_reg.spad_base = BNX2_RXP_SCRATCH;
2324 cpu_reg.mips_view_base = 0x8000000; 2416 cpu_reg.mips_view_base = 0x8000000;
2325 2417
2326 fw.ver_major = bnx2_RXP_b06FwReleaseMajor; 2418 if (CHIP_NUM(bp) == CHIP_NUM_5709)
2327 fw.ver_minor = bnx2_RXP_b06FwReleaseMinor; 2419 fw = &bnx2_rxp_fw_09;
2328 fw.ver_fix = bnx2_RXP_b06FwReleaseFix; 2420 else
2329 fw.start_addr = bnx2_RXP_b06FwStartAddr; 2421 fw = &bnx2_rxp_fw_06;
2330
2331 fw.text_addr = bnx2_RXP_b06FwTextAddr;
2332 fw.text_len = bnx2_RXP_b06FwTextLen;
2333 fw.text_index = 0;
2334 2422
2335 rc = bnx2_gunzip(bp, bnx2_RXP_b06FwText, sizeof(bnx2_RXP_b06FwText), 2423 rc = load_cpu_fw(bp, &cpu_reg, fw);
2336 &text, &text_len);
2337 if (rc) 2424 if (rc)
2338 goto init_cpu_err; 2425 goto init_cpu_err;
2339 2426
2340 fw.text = text;
2341
2342 fw.data_addr = bnx2_RXP_b06FwDataAddr;
2343 fw.data_len = bnx2_RXP_b06FwDataLen;
2344 fw.data_index = 0;
2345 fw.data = bnx2_RXP_b06FwData;
2346
2347 fw.sbss_addr = bnx2_RXP_b06FwSbssAddr;
2348 fw.sbss_len = bnx2_RXP_b06FwSbssLen;
2349 fw.sbss_index = 0;
2350 fw.sbss = bnx2_RXP_b06FwSbss;
2351
2352 fw.bss_addr = bnx2_RXP_b06FwBssAddr;
2353 fw.bss_len = bnx2_RXP_b06FwBssLen;
2354 fw.bss_index = 0;
2355 fw.bss = bnx2_RXP_b06FwBss;
2356
2357 fw.rodata_addr = bnx2_RXP_b06FwRodataAddr;
2358 fw.rodata_len = bnx2_RXP_b06FwRodataLen;
2359 fw.rodata_index = 0;
2360 fw.rodata = bnx2_RXP_b06FwRodata;
2361
2362 load_cpu_fw(bp, &cpu_reg, &fw);
2363
2364 /* Initialize the TX Processor. */ 2427 /* Initialize the TX Processor. */
2365 cpu_reg.mode = BNX2_TXP_CPU_MODE; 2428 cpu_reg.mode = BNX2_TXP_CPU_MODE;
2366 cpu_reg.mode_value_halt = BNX2_TXP_CPU_MODE_SOFT_HALT; 2429 cpu_reg.mode_value_halt = BNX2_TXP_CPU_MODE_SOFT_HALT;
@@ -2375,44 +2438,15 @@ bnx2_init_cpus(struct bnx2 *bp)
2375 cpu_reg.spad_base = BNX2_TXP_SCRATCH; 2438 cpu_reg.spad_base = BNX2_TXP_SCRATCH;
2376 cpu_reg.mips_view_base = 0x8000000; 2439 cpu_reg.mips_view_base = 0x8000000;
2377 2440
2378 fw.ver_major = bnx2_TXP_b06FwReleaseMajor; 2441 if (CHIP_NUM(bp) == CHIP_NUM_5709)
2379 fw.ver_minor = bnx2_TXP_b06FwReleaseMinor; 2442 fw = &bnx2_txp_fw_09;
2380 fw.ver_fix = bnx2_TXP_b06FwReleaseFix; 2443 else
2381 fw.start_addr = bnx2_TXP_b06FwStartAddr; 2444 fw = &bnx2_txp_fw_06;
2382
2383 fw.text_addr = bnx2_TXP_b06FwTextAddr;
2384 fw.text_len = bnx2_TXP_b06FwTextLen;
2385 fw.text_index = 0;
2386 2445
2387 rc = bnx2_gunzip(bp, bnx2_TXP_b06FwText, sizeof(bnx2_TXP_b06FwText), 2446 rc = load_cpu_fw(bp, &cpu_reg, fw);
2388 &text, &text_len);
2389 if (rc) 2447 if (rc)
2390 goto init_cpu_err; 2448 goto init_cpu_err;
2391 2449
2392 fw.text = text;
2393
2394 fw.data_addr = bnx2_TXP_b06FwDataAddr;
2395 fw.data_len = bnx2_TXP_b06FwDataLen;
2396 fw.data_index = 0;
2397 fw.data = bnx2_TXP_b06FwData;
2398
2399 fw.sbss_addr = bnx2_TXP_b06FwSbssAddr;
2400 fw.sbss_len = bnx2_TXP_b06FwSbssLen;
2401 fw.sbss_index = 0;
2402 fw.sbss = bnx2_TXP_b06FwSbss;
2403
2404 fw.bss_addr = bnx2_TXP_b06FwBssAddr;
2405 fw.bss_len = bnx2_TXP_b06FwBssLen;
2406 fw.bss_index = 0;
2407 fw.bss = bnx2_TXP_b06FwBss;
2408
2409 fw.rodata_addr = bnx2_TXP_b06FwRodataAddr;
2410 fw.rodata_len = bnx2_TXP_b06FwRodataLen;
2411 fw.rodata_index = 0;
2412 fw.rodata = bnx2_TXP_b06FwRodata;
2413
2414 load_cpu_fw(bp, &cpu_reg, &fw);
2415
2416 /* Initialize the TX Patch-up Processor. */ 2450 /* Initialize the TX Patch-up Processor. */
2417 cpu_reg.mode = BNX2_TPAT_CPU_MODE; 2451 cpu_reg.mode = BNX2_TPAT_CPU_MODE;
2418 cpu_reg.mode_value_halt = BNX2_TPAT_CPU_MODE_SOFT_HALT; 2452 cpu_reg.mode_value_halt = BNX2_TPAT_CPU_MODE_SOFT_HALT;
@@ -2427,44 +2461,15 @@ bnx2_init_cpus(struct bnx2 *bp)
2427 cpu_reg.spad_base = BNX2_TPAT_SCRATCH; 2461 cpu_reg.spad_base = BNX2_TPAT_SCRATCH;
2428 cpu_reg.mips_view_base = 0x8000000; 2462 cpu_reg.mips_view_base = 0x8000000;
2429 2463
2430 fw.ver_major = bnx2_TPAT_b06FwReleaseMajor; 2464 if (CHIP_NUM(bp) == CHIP_NUM_5709)
2431 fw.ver_minor = bnx2_TPAT_b06FwReleaseMinor; 2465 fw = &bnx2_tpat_fw_09;
2432 fw.ver_fix = bnx2_TPAT_b06FwReleaseFix; 2466 else
2433 fw.start_addr = bnx2_TPAT_b06FwStartAddr; 2467 fw = &bnx2_tpat_fw_06;
2434
2435 fw.text_addr = bnx2_TPAT_b06FwTextAddr;
2436 fw.text_len = bnx2_TPAT_b06FwTextLen;
2437 fw.text_index = 0;
2438 2468
2439 rc = bnx2_gunzip(bp, bnx2_TPAT_b06FwText, sizeof(bnx2_TPAT_b06FwText), 2469 rc = load_cpu_fw(bp, &cpu_reg, fw);
2440 &text, &text_len);
2441 if (rc) 2470 if (rc)
2442 goto init_cpu_err; 2471 goto init_cpu_err;
2443 2472
2444 fw.text = text;
2445
2446 fw.data_addr = bnx2_TPAT_b06FwDataAddr;
2447 fw.data_len = bnx2_TPAT_b06FwDataLen;
2448 fw.data_index = 0;
2449 fw.data = bnx2_TPAT_b06FwData;
2450
2451 fw.sbss_addr = bnx2_TPAT_b06FwSbssAddr;
2452 fw.sbss_len = bnx2_TPAT_b06FwSbssLen;
2453 fw.sbss_index = 0;
2454 fw.sbss = bnx2_TPAT_b06FwSbss;
2455
2456 fw.bss_addr = bnx2_TPAT_b06FwBssAddr;
2457 fw.bss_len = bnx2_TPAT_b06FwBssLen;
2458 fw.bss_index = 0;
2459 fw.bss = bnx2_TPAT_b06FwBss;
2460
2461 fw.rodata_addr = bnx2_TPAT_b06FwRodataAddr;
2462 fw.rodata_len = bnx2_TPAT_b06FwRodataLen;
2463 fw.rodata_index = 0;
2464 fw.rodata = bnx2_TPAT_b06FwRodata;
2465
2466 load_cpu_fw(bp, &cpu_reg, &fw);
2467
2468 /* Initialize the Completion Processor. */ 2473 /* Initialize the Completion Processor. */
2469 cpu_reg.mode = BNX2_COM_CPU_MODE; 2474 cpu_reg.mode = BNX2_COM_CPU_MODE;
2470 cpu_reg.mode_value_halt = BNX2_COM_CPU_MODE_SOFT_HALT; 2475 cpu_reg.mode_value_halt = BNX2_COM_CPU_MODE_SOFT_HALT;
@@ -2479,44 +2484,36 @@ bnx2_init_cpus(struct bnx2 *bp)
2479 cpu_reg.spad_base = BNX2_COM_SCRATCH; 2484 cpu_reg.spad_base = BNX2_COM_SCRATCH;
2480 cpu_reg.mips_view_base = 0x8000000; 2485 cpu_reg.mips_view_base = 0x8000000;
2481 2486
2482 fw.ver_major = bnx2_COM_b06FwReleaseMajor; 2487 if (CHIP_NUM(bp) == CHIP_NUM_5709)
2483 fw.ver_minor = bnx2_COM_b06FwReleaseMinor; 2488 fw = &bnx2_com_fw_09;
2484 fw.ver_fix = bnx2_COM_b06FwReleaseFix; 2489 else
2485 fw.start_addr = bnx2_COM_b06FwStartAddr; 2490 fw = &bnx2_com_fw_06;
2486
2487 fw.text_addr = bnx2_COM_b06FwTextAddr;
2488 fw.text_len = bnx2_COM_b06FwTextLen;
2489 fw.text_index = 0;
2490 2491
2491 rc = bnx2_gunzip(bp, bnx2_COM_b06FwText, sizeof(bnx2_COM_b06FwText), 2492 rc = load_cpu_fw(bp, &cpu_reg, fw);
2492 &text, &text_len);
2493 if (rc) 2493 if (rc)
2494 goto init_cpu_err; 2494 goto init_cpu_err;
2495 2495
2496 fw.text = text; 2496 /* Initialize the Command Processor. */
2497 2497 cpu_reg.mode = BNX2_CP_CPU_MODE;
2498 fw.data_addr = bnx2_COM_b06FwDataAddr; 2498 cpu_reg.mode_value_halt = BNX2_CP_CPU_MODE_SOFT_HALT;
2499 fw.data_len = bnx2_COM_b06FwDataLen; 2499 cpu_reg.mode_value_sstep = BNX2_CP_CPU_MODE_STEP_ENA;
2500 fw.data_index = 0; 2500 cpu_reg.state = BNX2_CP_CPU_STATE;
2501 fw.data = bnx2_COM_b06FwData; 2501 cpu_reg.state_value_clear = 0xffffff;
2502 2502 cpu_reg.gpr0 = BNX2_CP_CPU_REG_FILE;
2503 fw.sbss_addr = bnx2_COM_b06FwSbssAddr; 2503 cpu_reg.evmask = BNX2_CP_CPU_EVENT_MASK;
2504 fw.sbss_len = bnx2_COM_b06FwSbssLen; 2504 cpu_reg.pc = BNX2_CP_CPU_PROGRAM_COUNTER;
2505 fw.sbss_index = 0; 2505 cpu_reg.inst = BNX2_CP_CPU_INSTRUCTION;
2506 fw.sbss = bnx2_COM_b06FwSbss; 2506 cpu_reg.bp = BNX2_CP_CPU_HW_BREAKPOINT;
2507 2507 cpu_reg.spad_base = BNX2_CP_SCRATCH;
2508 fw.bss_addr = bnx2_COM_b06FwBssAddr; 2508 cpu_reg.mips_view_base = 0x8000000;
2509 fw.bss_len = bnx2_COM_b06FwBssLen;
2510 fw.bss_index = 0;
2511 fw.bss = bnx2_COM_b06FwBss;
2512
2513 fw.rodata_addr = bnx2_COM_b06FwRodataAddr;
2514 fw.rodata_len = bnx2_COM_b06FwRodataLen;
2515 fw.rodata_index = 0;
2516 fw.rodata = bnx2_COM_b06FwRodata;
2517 2509
2518 load_cpu_fw(bp, &cpu_reg, &fw); 2510 if (CHIP_NUM(bp) == CHIP_NUM_5709) {
2511 fw = &bnx2_cp_fw_09;
2519 2512
2513 load_cpu_fw(bp, &cpu_reg, fw);
2514 if (rc)
2515 goto init_cpu_err;
2516 }
2520init_cpu_err: 2517init_cpu_err:
2521 bnx2_gunzip_end(bp); 2518 bnx2_gunzip_end(bp);
2522 return rc; 2519 return rc;
@@ -3288,31 +3285,44 @@ bnx2_reset_chip(struct bnx2 *bp, u32 reset_code)
3288 * before we issue a reset. */ 3285 * before we issue a reset. */
3289 val = REG_RD(bp, BNX2_MISC_ID); 3286 val = REG_RD(bp, BNX2_MISC_ID);
3290 3287
3291 val = BNX2_PCICFG_MISC_CONFIG_CORE_RST_REQ | 3288 if (CHIP_NUM(bp) == CHIP_NUM_5709) {
3292 BNX2_PCICFG_MISC_CONFIG_REG_WINDOW_ENA | 3289 REG_WR(bp, BNX2_MISC_COMMAND, BNX2_MISC_COMMAND_SW_RESET);
3293 BNX2_PCICFG_MISC_CONFIG_TARGET_MB_WORD_SWAP; 3290 REG_RD(bp, BNX2_MISC_COMMAND);
3291 udelay(5);
3294 3292
3295 /* Chip reset. */ 3293 val = BNX2_PCICFG_MISC_CONFIG_REG_WINDOW_ENA |
3296 REG_WR(bp, BNX2_PCICFG_MISC_CONFIG, val); 3294 BNX2_PCICFG_MISC_CONFIG_TARGET_MB_WORD_SWAP;
3297 3295
3298 if ((CHIP_ID(bp) == CHIP_ID_5706_A0) || 3296 pci_write_config_dword(bp->pdev, BNX2_PCICFG_MISC_CONFIG, val);
3299 (CHIP_ID(bp) == CHIP_ID_5706_A1))
3300 msleep(15);
3301 3297
3302 /* Reset takes approximate 30 usec */ 3298 } else {
3303 for (i = 0; i < 10; i++) { 3299 val = BNX2_PCICFG_MISC_CONFIG_CORE_RST_REQ |
3304 val = REG_RD(bp, BNX2_PCICFG_MISC_CONFIG); 3300 BNX2_PCICFG_MISC_CONFIG_REG_WINDOW_ENA |
3305 if ((val & (BNX2_PCICFG_MISC_CONFIG_CORE_RST_REQ | 3301 BNX2_PCICFG_MISC_CONFIG_TARGET_MB_WORD_SWAP;
3306 BNX2_PCICFG_MISC_CONFIG_CORE_RST_BSY)) == 0) { 3302
3307 break; 3303 /* Chip reset. */
3304 REG_WR(bp, BNX2_PCICFG_MISC_CONFIG, val);
3305
3306 if ((CHIP_ID(bp) == CHIP_ID_5706_A0) ||
3307 (CHIP_ID(bp) == CHIP_ID_5706_A1)) {
3308 current->state = TASK_UNINTERRUPTIBLE;
3309 schedule_timeout(HZ / 50);
3308 } 3310 }
3309 udelay(10);
3310 }
3311 3311
3312 if (val & (BNX2_PCICFG_MISC_CONFIG_CORE_RST_REQ | 3312 /* Reset takes approximate 30 usec */
3313 BNX2_PCICFG_MISC_CONFIG_CORE_RST_BSY)) { 3313 for (i = 0; i < 10; i++) {
3314 printk(KERN_ERR PFX "Chip reset did not complete\n"); 3314 val = REG_RD(bp, BNX2_PCICFG_MISC_CONFIG);
3315 return -EBUSY; 3315 if ((val & (BNX2_PCICFG_MISC_CONFIG_CORE_RST_REQ |
3316 BNX2_PCICFG_MISC_CONFIG_CORE_RST_BSY)) == 0)
3317 break;
3318 udelay(10);
3319 }
3320
3321 if (val & (BNX2_PCICFG_MISC_CONFIG_CORE_RST_REQ |
3322 BNX2_PCICFG_MISC_CONFIG_CORE_RST_BSY)) {
3323 printk(KERN_ERR PFX "Chip reset did not complete\n");
3324 return -EBUSY;
3325 }
3316 } 3326 }
3317 3327
3318 /* Make sure byte swapping is properly configured. */ 3328 /* Make sure byte swapping is properly configured. */
@@ -3390,7 +3400,10 @@ bnx2_init_chip(struct bnx2 *bp)
3390 3400
3391 /* Initialize context mapping and zero out the quick contexts. The 3401 /* Initialize context mapping and zero out the quick contexts. The
3392 * context block must have already been enabled. */ 3402 * context block must have already been enabled. */
3393 bnx2_init_context(bp); 3403 if (CHIP_NUM(bp) == CHIP_NUM_5709)
3404 bnx2_init_5709_context(bp);
3405 else
3406 bnx2_init_context(bp);
3394 3407
3395 if ((rc = bnx2_init_cpus(bp)) != 0) 3408 if ((rc = bnx2_init_cpus(bp)) != 0)
3396 return rc; 3409 return rc;
@@ -3501,12 +3514,40 @@ bnx2_init_chip(struct bnx2 *bp)
3501 return rc; 3514 return rc;
3502} 3515}
3503 3516
3517static void
3518bnx2_init_tx_context(struct bnx2 *bp, u32 cid)
3519{
3520 u32 val, offset0, offset1, offset2, offset3;
3521
3522 if (CHIP_NUM(bp) == CHIP_NUM_5709) {
3523 offset0 = BNX2_L2CTX_TYPE_XI;
3524 offset1 = BNX2_L2CTX_CMD_TYPE_XI;
3525 offset2 = BNX2_L2CTX_TBDR_BHADDR_HI_XI;
3526 offset3 = BNX2_L2CTX_TBDR_BHADDR_LO_XI;
3527 } else {
3528 offset0 = BNX2_L2CTX_TYPE;
3529 offset1 = BNX2_L2CTX_CMD_TYPE;
3530 offset2 = BNX2_L2CTX_TBDR_BHADDR_HI;
3531 offset3 = BNX2_L2CTX_TBDR_BHADDR_LO;
3532 }
3533 val = BNX2_L2CTX_TYPE_TYPE_L2 | BNX2_L2CTX_TYPE_SIZE_L2;
3534 CTX_WR(bp, GET_CID_ADDR(cid), offset0, val);
3535
3536 val = BNX2_L2CTX_CMD_TYPE_TYPE_L2 | (8 << 16);
3537 CTX_WR(bp, GET_CID_ADDR(cid), offset1, val);
3538
3539 val = (u64) bp->tx_desc_mapping >> 32;
3540 CTX_WR(bp, GET_CID_ADDR(cid), offset2, val);
3541
3542 val = (u64) bp->tx_desc_mapping & 0xffffffff;
3543 CTX_WR(bp, GET_CID_ADDR(cid), offset3, val);
3544}
3504 3545
3505static void 3546static void
3506bnx2_init_tx_ring(struct bnx2 *bp) 3547bnx2_init_tx_ring(struct bnx2 *bp)
3507{ 3548{
3508 struct tx_bd *txbd; 3549 struct tx_bd *txbd;
3509 u32 val; 3550 u32 cid;
3510 3551
3511 bp->tx_wake_thresh = bp->tx_ring_size / 2; 3552 bp->tx_wake_thresh = bp->tx_ring_size / 2;
3512 3553
@@ -3520,19 +3561,11 @@ bnx2_init_tx_ring(struct bnx2 *bp)
3520 bp->hw_tx_cons = 0; 3561 bp->hw_tx_cons = 0;
3521 bp->tx_prod_bseq = 0; 3562 bp->tx_prod_bseq = 0;
3522 3563
3523 val = BNX2_L2CTX_TYPE_TYPE_L2; 3564 cid = TX_CID;
3524 val |= BNX2_L2CTX_TYPE_SIZE_L2; 3565 bp->tx_bidx_addr = MB_GET_CID_ADDR(cid) + BNX2_L2CTX_TX_HOST_BIDX;
3525 CTX_WR(bp, GET_CID_ADDR(TX_CID), BNX2_L2CTX_TYPE, val); 3566 bp->tx_bseq_addr = MB_GET_CID_ADDR(cid) + BNX2_L2CTX_TX_HOST_BSEQ;
3526 3567
3527 val = BNX2_L2CTX_CMD_TYPE_TYPE_L2; 3568 bnx2_init_tx_context(bp, cid);
3528 val |= 8 << 16;
3529 CTX_WR(bp, GET_CID_ADDR(TX_CID), BNX2_L2CTX_CMD_TYPE, val);
3530
3531 val = (u64) bp->tx_desc_mapping >> 32;
3532 CTX_WR(bp, GET_CID_ADDR(TX_CID), BNX2_L2CTX_TBDR_BHADDR_HI, val);
3533
3534 val = (u64) bp->tx_desc_mapping & 0xffffffff;
3535 CTX_WR(bp, GET_CID_ADDR(TX_CID), BNX2_L2CTX_TBDR_BHADDR_LO, val);
3536} 3569}
3537 3570
3538static void 3571static void
@@ -3545,8 +3578,8 @@ bnx2_init_rx_ring(struct bnx2 *bp)
3545 3578
3546 /* 8 for CRC and VLAN */ 3579 /* 8 for CRC and VLAN */
3547 bp->rx_buf_use_size = bp->dev->mtu + ETH_HLEN + bp->rx_offset + 8; 3580 bp->rx_buf_use_size = bp->dev->mtu + ETH_HLEN + bp->rx_offset + 8;
3548 /* 8 for alignment */ 3581 /* hw alignment */
3549 bp->rx_buf_size = bp->rx_buf_use_size + 8; 3582 bp->rx_buf_size = bp->rx_buf_use_size + BNX2_RX_ALIGN;
3550 3583
3551 ring_prod = prod = bp->rx_prod = 0; 3584 ring_prod = prod = bp->rx_prod = 0;
3552 bp->rx_cons = 0; 3585 bp->rx_cons = 0;
@@ -3712,7 +3745,9 @@ bnx2_init_nic(struct bnx2 *bp)
3712 if ((rc = bnx2_reset_nic(bp, BNX2_DRV_MSG_CODE_RESET)) != 0) 3745 if ((rc = bnx2_reset_nic(bp, BNX2_DRV_MSG_CODE_RESET)) != 0)
3713 return rc; 3746 return rc;
3714 3747
3748 spin_lock_bh(&bp->phy_lock);
3715 bnx2_init_phy(bp); 3749 bnx2_init_phy(bp);
3750 spin_unlock_bh(&bp->phy_lock);
3716 bnx2_set_link(bp); 3751 bnx2_set_link(bp);
3717 return 0; 3752 return 0;
3718} 3753}
@@ -3952,7 +3987,7 @@ bnx2_run_loopback(struct bnx2 *bp, int loopback_mode)
3952 bnx2_set_mac_loopback(bp); 3987 bnx2_set_mac_loopback(bp);
3953 } 3988 }
3954 else if (loopback_mode == BNX2_PHY_LOOPBACK) { 3989 else if (loopback_mode == BNX2_PHY_LOOPBACK) {
3955 bp->loopback = 0; 3990 bp->loopback = PHY_LOOPBACK;
3956 bnx2_set_phy_loopback(bp); 3991 bnx2_set_phy_loopback(bp);
3957 } 3992 }
3958 else 3993 else
@@ -3992,8 +4027,8 @@ bnx2_run_loopback(struct bnx2 *bp, int loopback_mode)
3992 bp->tx_prod = NEXT_TX_BD(bp->tx_prod); 4027 bp->tx_prod = NEXT_TX_BD(bp->tx_prod);
3993 bp->tx_prod_bseq += pkt_size; 4028 bp->tx_prod_bseq += pkt_size;
3994 4029
3995 REG_WR16(bp, MB_TX_CID_ADDR + BNX2_L2CTX_TX_HOST_BIDX, bp->tx_prod); 4030 REG_WR16(bp, bp->tx_bidx_addr, bp->tx_prod);
3996 REG_WR(bp, MB_TX_CID_ADDR + BNX2_L2CTX_TX_HOST_BSEQ, bp->tx_prod_bseq); 4031 REG_WR(bp, bp->tx_bseq_addr, bp->tx_prod_bseq);
3997 4032
3998 udelay(100); 4033 udelay(100);
3999 4034
@@ -4162,80 +4197,117 @@ bnx2_test_intr(struct bnx2 *bp)
4162} 4197}
4163 4198
4164static void 4199static void
4165bnx2_timer(unsigned long data) 4200bnx2_5706_serdes_timer(struct bnx2 *bp)
4166{ 4201{
4167 struct bnx2 *bp = (struct bnx2 *) data; 4202 spin_lock(&bp->phy_lock);
4168 u32 msg; 4203 if (bp->serdes_an_pending)
4204 bp->serdes_an_pending--;
4205 else if ((bp->link_up == 0) && (bp->autoneg & AUTONEG_SPEED)) {
4206 u32 bmcr;
4169 4207
4170 if (!netif_running(bp->dev)) 4208 bp->current_interval = bp->timer_interval;
4171 return;
4172 4209
4173 if (atomic_read(&bp->intr_sem) != 0) 4210 bnx2_read_phy(bp, MII_BMCR, &bmcr);
4174 goto bnx2_restart_timer;
4175 4211
4176 msg = (u32) ++bp->fw_drv_pulse_wr_seq; 4212 if (bmcr & BMCR_ANENABLE) {
4177 REG_WR_IND(bp, bp->shmem_base + BNX2_DRV_PULSE_MB, msg); 4213 u32 phy1, phy2;
4178 4214
4179 bp->stats_blk->stat_FwRxDrop = REG_RD_IND(bp, BNX2_FW_RX_DROP_COUNT); 4215 bnx2_write_phy(bp, 0x1c, 0x7c00);
4216 bnx2_read_phy(bp, 0x1c, &phy1);
4180 4217
4181 if ((bp->phy_flags & PHY_SERDES_FLAG) && 4218 bnx2_write_phy(bp, 0x17, 0x0f01);
4182 (CHIP_NUM(bp) == CHIP_NUM_5706)) { 4219 bnx2_read_phy(bp, 0x15, &phy2);
4220 bnx2_write_phy(bp, 0x17, 0x0f01);
4221 bnx2_read_phy(bp, 0x15, &phy2);
4183 4222
4184 spin_lock(&bp->phy_lock); 4223 if ((phy1 & 0x10) && /* SIGNAL DETECT */
4185 if (bp->serdes_an_pending) { 4224 !(phy2 & 0x20)) { /* no CONFIG */
4186 bp->serdes_an_pending--; 4225
4226 bmcr &= ~BMCR_ANENABLE;
4227 bmcr |= BMCR_SPEED1000 | BMCR_FULLDPLX;
4228 bnx2_write_phy(bp, MII_BMCR, bmcr);
4229 bp->phy_flags |= PHY_PARALLEL_DETECT_FLAG;
4230 }
4187 } 4231 }
4188 else if ((bp->link_up == 0) && (bp->autoneg & AUTONEG_SPEED)) { 4232 }
4189 u32 bmcr; 4233 else if ((bp->link_up) && (bp->autoneg & AUTONEG_SPEED) &&
4234 (bp->phy_flags & PHY_PARALLEL_DETECT_FLAG)) {
4235 u32 phy2;
4190 4236
4191 bp->current_interval = bp->timer_interval; 4237 bnx2_write_phy(bp, 0x17, 0x0f01);
4238 bnx2_read_phy(bp, 0x15, &phy2);
4239 if (phy2 & 0x20) {
4240 u32 bmcr;
4192 4241
4193 bnx2_read_phy(bp, MII_BMCR, &bmcr); 4242 bnx2_read_phy(bp, MII_BMCR, &bmcr);
4243 bmcr |= BMCR_ANENABLE;
4244 bnx2_write_phy(bp, MII_BMCR, bmcr);
4194 4245
4195 if (bmcr & BMCR_ANENABLE) { 4246 bp->phy_flags &= ~PHY_PARALLEL_DETECT_FLAG;
4196 u32 phy1, phy2; 4247 }
4248 } else
4249 bp->current_interval = bp->timer_interval;
4197 4250
4198 bnx2_write_phy(bp, 0x1c, 0x7c00); 4251 spin_unlock(&bp->phy_lock);
4199 bnx2_read_phy(bp, 0x1c, &phy1); 4252}
4200 4253
4201 bnx2_write_phy(bp, 0x17, 0x0f01); 4254static void
4202 bnx2_read_phy(bp, 0x15, &phy2); 4255bnx2_5708_serdes_timer(struct bnx2 *bp)
4203 bnx2_write_phy(bp, 0x17, 0x0f01); 4256{
4204 bnx2_read_phy(bp, 0x15, &phy2); 4257 if ((bp->phy_flags & PHY_2_5G_CAPABLE_FLAG) == 0) {
4258 bp->serdes_an_pending = 0;
4259 return;
4260 }
4205 4261
4206 if ((phy1 & 0x10) && /* SIGNAL DETECT */ 4262 spin_lock(&bp->phy_lock);
4207 !(phy2 & 0x20)) { /* no CONFIG */ 4263 if (bp->serdes_an_pending)
4264 bp->serdes_an_pending--;
4265 else if ((bp->link_up == 0) && (bp->autoneg & AUTONEG_SPEED)) {
4266 u32 bmcr;
4208 4267
4209 bmcr &= ~BMCR_ANENABLE; 4268 bnx2_read_phy(bp, MII_BMCR, &bmcr);
4210 bmcr |= BMCR_SPEED1000 | 4269
4211 BMCR_FULLDPLX; 4270 if (bmcr & BMCR_ANENABLE) {
4212 bnx2_write_phy(bp, MII_BMCR, bmcr); 4271 bmcr &= ~BMCR_ANENABLE;
4213 bp->phy_flags |= 4272 bmcr |= BMCR_FULLDPLX | BCM5708S_BMCR_FORCE_2500;
4214 PHY_PARALLEL_DETECT_FLAG; 4273 bnx2_write_phy(bp, MII_BMCR, bmcr);
4215 } 4274 bp->current_interval = SERDES_FORCED_TIMEOUT;
4216 } 4275 } else {
4276 bmcr &= ~(BMCR_FULLDPLX | BCM5708S_BMCR_FORCE_2500);
4277 bmcr |= BMCR_ANENABLE;
4278 bnx2_write_phy(bp, MII_BMCR, bmcr);
4279 bp->serdes_an_pending = 2;
4280 bp->current_interval = bp->timer_interval;
4217 } 4281 }
4218 else if ((bp->link_up) && (bp->autoneg & AUTONEG_SPEED) &&
4219 (bp->phy_flags & PHY_PARALLEL_DETECT_FLAG)) {
4220 u32 phy2;
4221 4282
4222 bnx2_write_phy(bp, 0x17, 0x0f01); 4283 } else
4223 bnx2_read_phy(bp, 0x15, &phy2); 4284 bp->current_interval = bp->timer_interval;
4224 if (phy2 & 0x20) {
4225 u32 bmcr;
4226 4285
4227 bnx2_read_phy(bp, MII_BMCR, &bmcr); 4286 spin_unlock(&bp->phy_lock);
4228 bmcr |= BMCR_ANENABLE; 4287}
4229 bnx2_write_phy(bp, MII_BMCR, bmcr); 4288
4289static void
4290bnx2_timer(unsigned long data)
4291{
4292 struct bnx2 *bp = (struct bnx2 *) data;
4293 u32 msg;
4230 4294
4231 bp->phy_flags &= ~PHY_PARALLEL_DETECT_FLAG; 4295 if (!netif_running(bp->dev))
4296 return;
4232 4297
4233 } 4298 if (atomic_read(&bp->intr_sem) != 0)
4234 } 4299 goto bnx2_restart_timer;
4235 else
4236 bp->current_interval = bp->timer_interval;
4237 4300
4238 spin_unlock(&bp->phy_lock); 4301 msg = (u32) ++bp->fw_drv_pulse_wr_seq;
4302 REG_WR_IND(bp, bp->shmem_base + BNX2_DRV_PULSE_MB, msg);
4303
4304 bp->stats_blk->stat_FwRxDrop = REG_RD_IND(bp, BNX2_FW_RX_DROP_COUNT);
4305
4306 if (bp->phy_flags & PHY_SERDES_FLAG) {
4307 if (CHIP_NUM(bp) == CHIP_NUM_5706)
4308 bnx2_5706_serdes_timer(bp);
4309 else if (CHIP_NUM(bp) == CHIP_NUM_5708)
4310 bnx2_5708_serdes_timer(bp);
4239 } 4311 }
4240 4312
4241bnx2_restart_timer: 4313bnx2_restart_timer:
@@ -4339,9 +4411,9 @@ bnx2_open(struct net_device *dev)
4339} 4411}
4340 4412
4341static void 4413static void
4342bnx2_reset_task(void *data) 4414bnx2_reset_task(struct work_struct *work)
4343{ 4415{
4344 struct bnx2 *bp = data; 4416 struct bnx2 *bp = container_of(work, struct bnx2, reset_task);
4345 4417
4346 if (!netif_running(bp->dev)) 4418 if (!netif_running(bp->dev))
4347 return; 4419 return;
@@ -4508,8 +4580,8 @@ bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev)
4508 prod = NEXT_TX_BD(prod); 4580 prod = NEXT_TX_BD(prod);
4509 bp->tx_prod_bseq += skb->len; 4581 bp->tx_prod_bseq += skb->len;
4510 4582
4511 REG_WR16(bp, MB_TX_CID_ADDR + BNX2_L2CTX_TX_HOST_BIDX, prod); 4583 REG_WR16(bp, bp->tx_bidx_addr, prod);
4512 REG_WR(bp, MB_TX_CID_ADDR + BNX2_L2CTX_TX_HOST_BSEQ, bp->tx_prod_bseq); 4584 REG_WR(bp, bp->tx_bseq_addr, bp->tx_prod_bseq);
4513 4585
4514 mmiowb(); 4586 mmiowb();
4515 4587
@@ -4743,10 +4815,14 @@ bnx2_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
4743 } 4815 }
4744 else { 4816 else {
4745 if (bp->phy_flags & PHY_SERDES_FLAG) { 4817 if (bp->phy_flags & PHY_SERDES_FLAG) {
4746 if ((cmd->speed != SPEED_1000) || 4818 if ((cmd->speed != SPEED_1000 &&
4747 (cmd->duplex != DUPLEX_FULL)) { 4819 cmd->speed != SPEED_2500) ||
4820 (cmd->duplex != DUPLEX_FULL))
4821 return -EINVAL;
4822
4823 if (cmd->speed == SPEED_2500 &&
4824 !(bp->phy_flags & PHY_2_5G_CAPABLE_FLAG))
4748 return -EINVAL; 4825 return -EINVAL;
4749 }
4750 } 4826 }
4751 else if (cmd->speed == SPEED_1000) { 4827 else if (cmd->speed == SPEED_1000) {
4752 return -EINVAL; 4828 return -EINVAL;
@@ -4903,11 +4979,10 @@ bnx2_nway_reset(struct net_device *dev)
4903 msleep(20); 4979 msleep(20);
4904 4980
4905 spin_lock_bh(&bp->phy_lock); 4981 spin_lock_bh(&bp->phy_lock);
4906 if (CHIP_NUM(bp) == CHIP_NUM_5706) { 4982
4907 bp->current_interval = SERDES_AN_TIMEOUT; 4983 bp->current_interval = SERDES_AN_TIMEOUT;
4908 bp->serdes_an_pending = 1; 4984 bp->serdes_an_pending = 1;
4909 mod_timer(&bp->timer, jiffies + bp->current_interval); 4985 mod_timer(&bp->timer, jiffies + bp->current_interval);
4910 }
4911 } 4986 }
4912 4987
4913 bnx2_read_phy(bp, MII_BMCR, &bmcr); 4988 bnx2_read_phy(bp, MII_BMCR, &bmcr);
@@ -5288,6 +5363,8 @@ bnx2_self_test(struct net_device *dev, struct ethtool_test *etest, u64 *buf)
5288 5363
5289 memset(buf, 0, sizeof(u64) * BNX2_NUM_TESTS); 5364 memset(buf, 0, sizeof(u64) * BNX2_NUM_TESTS);
5290 if (etest->flags & ETH_TEST_FL_OFFLINE) { 5365 if (etest->flags & ETH_TEST_FL_OFFLINE) {
5366 int i;
5367
5291 bnx2_netif_stop(bp); 5368 bnx2_netif_stop(bp);
5292 bnx2_reset_chip(bp, BNX2_DRV_MSG_CODE_DIAG); 5369 bnx2_reset_chip(bp, BNX2_DRV_MSG_CODE_DIAG);
5293 bnx2_free_skbs(bp); 5370 bnx2_free_skbs(bp);
@@ -5312,9 +5389,11 @@ bnx2_self_test(struct net_device *dev, struct ethtool_test *etest, u64 *buf)
5312 } 5389 }
5313 5390
5314 /* wait for link up */ 5391 /* wait for link up */
5315 msleep_interruptible(3000); 5392 for (i = 0; i < 7; i++) {
5316 if ((!bp->link_up) && !(bp->phy_flags & PHY_SERDES_FLAG)) 5393 if (bp->link_up)
5317 msleep_interruptible(4000); 5394 break;
5395 msleep_interruptible(1000);
5396 }
5318 } 5397 }
5319 5398
5320 if (bnx2_test_nvram(bp) != 0) { 5399 if (bnx2_test_nvram(bp) != 0) {
@@ -5604,13 +5683,6 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
5604 goto err_out_release; 5683 goto err_out_release;
5605 } 5684 }
5606 5685
5607 bp->pcix_cap = pci_find_capability(pdev, PCI_CAP_ID_PCIX);
5608 if (bp->pcix_cap == 0) {
5609 dev_err(&pdev->dev, "Cannot find PCIX capability, aborting.\n");
5610 rc = -EIO;
5611 goto err_out_release;
5612 }
5613
5614 if (pci_set_dma_mask(pdev, DMA_64BIT_MASK) == 0) { 5686 if (pci_set_dma_mask(pdev, DMA_64BIT_MASK) == 0) {
5615 bp->flags |= USING_DAC_FLAG; 5687 bp->flags |= USING_DAC_FLAG;
5616 if (pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK) != 0) { 5688 if (pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK) != 0) {
@@ -5630,10 +5702,10 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
5630 bp->pdev = pdev; 5702 bp->pdev = pdev;
5631 5703
5632 spin_lock_init(&bp->phy_lock); 5704 spin_lock_init(&bp->phy_lock);
5633 INIT_WORK(&bp->reset_task, bnx2_reset_task, bp); 5705 INIT_WORK(&bp->reset_task, bnx2_reset_task);
5634 5706
5635 dev->base_addr = dev->mem_start = pci_resource_start(pdev, 0); 5707 dev->base_addr = dev->mem_start = pci_resource_start(pdev, 0);
5636 mem_len = MB_GET_CID_ADDR(17); 5708 mem_len = MB_GET_CID_ADDR(TX_TSS_CID + 1);
5637 dev->mem_end = dev->mem_start + mem_len; 5709 dev->mem_end = dev->mem_start + mem_len;
5638 dev->irq = pdev->irq; 5710 dev->irq = pdev->irq;
5639 5711
@@ -5657,6 +5729,16 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
5657 5729
5658 bp->chip_id = REG_RD(bp, BNX2_MISC_ID); 5730 bp->chip_id = REG_RD(bp, BNX2_MISC_ID);
5659 5731
5732 if (CHIP_NUM(bp) != CHIP_NUM_5709) {
5733 bp->pcix_cap = pci_find_capability(pdev, PCI_CAP_ID_PCIX);
5734 if (bp->pcix_cap == 0) {
5735 dev_err(&pdev->dev,
5736 "Cannot find PCIX capability, aborting.\n");
5737 rc = -EIO;
5738 goto err_out_unmap;
5739 }
5740 }
5741
5660 /* Get bus information. */ 5742 /* Get bus information. */
5661 reg = REG_RD(bp, BNX2_PCICFG_MISC_STATUS); 5743 reg = REG_RD(bp, BNX2_PCICFG_MISC_STATUS);
5662 if (reg & BNX2_PCICFG_MISC_STATUS_PCIX_DET) { 5744 if (reg & BNX2_PCICFG_MISC_STATUS_PCIX_DET) {
@@ -5776,10 +5858,15 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
5776 bp->phy_addr = 1; 5858 bp->phy_addr = 1;
5777 5859
5778 /* Disable WOL support if we are running on a SERDES chip. */ 5860 /* Disable WOL support if we are running on a SERDES chip. */
5779 if (CHIP_BOND_ID(bp) & CHIP_BOND_ID_SERDES_BIT) { 5861 if (CHIP_NUM(bp) == CHIP_NUM_5709) {
5862 if (CHIP_BOND_ID(bp) != BNX2_MISC_DUAL_MEDIA_CTRL_BOND_ID_C)
5863 bp->phy_flags |= PHY_SERDES_FLAG;
5864 } else if (CHIP_BOND_ID(bp) & CHIP_BOND_ID_SERDES_BIT)
5780 bp->phy_flags |= PHY_SERDES_FLAG; 5865 bp->phy_flags |= PHY_SERDES_FLAG;
5866
5867 if (bp->phy_flags & PHY_SERDES_FLAG) {
5781 bp->flags |= NO_WOL_FLAG; 5868 bp->flags |= NO_WOL_FLAG;
5782 if (CHIP_NUM(bp) == CHIP_NUM_5708) { 5869 if (CHIP_NUM(bp) != CHIP_NUM_5706) {
5783 bp->phy_addr = 2; 5870 bp->phy_addr = 2;
5784 reg = REG_RD_IND(bp, bp->shmem_base + 5871 reg = REG_RD_IND(bp, bp->shmem_base +
5785 BNX2_SHARED_HW_CFG_CONFIG); 5872 BNX2_SHARED_HW_CFG_CONFIG);
diff --git a/drivers/net/bnx2.h b/drivers/net/bnx2.h
index ca31904893ea..13b6f9b11e01 100644
--- a/drivers/net/bnx2.h
+++ b/drivers/net/bnx2.h
@@ -56,6 +56,7 @@ struct rx_bd {
56 56
57}; 57};
58 58
59#define BNX2_RX_ALIGN 16
59 60
60/* 61/*
61 * status_block definition 62 * status_block definition
@@ -90,6 +91,7 @@ struct status_block {
90 #define STATUS_ATTN_BITS_DMAE_ABORT (1L<<25) 91 #define STATUS_ATTN_BITS_DMAE_ABORT (1L<<25)
91 #define STATUS_ATTN_BITS_FLSH_ABORT (1L<<26) 92 #define STATUS_ATTN_BITS_FLSH_ABORT (1L<<26)
92 #define STATUS_ATTN_BITS_GRC_ABORT (1L<<27) 93 #define STATUS_ATTN_BITS_GRC_ABORT (1L<<27)
94 #define STATUS_ATTN_BITS_EPB_ERROR (1L<<30)
93 #define STATUS_ATTN_BITS_PARITY_ERROR (1L<<31) 95 #define STATUS_ATTN_BITS_PARITY_ERROR (1L<<31)
94 96
95 u32 status_attn_bits_ack; 97 u32 status_attn_bits_ack;
@@ -117,7 +119,8 @@ struct status_block {
117 u16 status_completion_producer_index; 119 u16 status_completion_producer_index;
118 u16 status_cmd_consumer_index; 120 u16 status_cmd_consumer_index;
119 u16 status_idx; 121 u16 status_idx;
120 u16 status_unused; 122 u8 status_unused;
123 u8 status_blk_num;
121#elif defined(__LITTLE_ENDIAN) 124#elif defined(__LITTLE_ENDIAN)
122 u16 status_tx_quick_consumer_index1; 125 u16 status_tx_quick_consumer_index1;
123 u16 status_tx_quick_consumer_index0; 126 u16 status_tx_quick_consumer_index0;
@@ -141,7 +144,8 @@ struct status_block {
141 u16 status_rx_quick_consumer_index14; 144 u16 status_rx_quick_consumer_index14;
142 u16 status_cmd_consumer_index; 145 u16 status_cmd_consumer_index;
143 u16 status_completion_producer_index; 146 u16 status_completion_producer_index;
144 u16 status_unused; 147 u8 status_blk_num;
148 u8 status_unused;
145 u16 status_idx; 149 u16 status_idx;
146#endif 150#endif
147}; 151};
@@ -301,6 +305,10 @@ struct l2_fhdr {
301#define BNX2_L2CTX_TXP_BIDX 0x000000a8 305#define BNX2_L2CTX_TXP_BIDX 0x000000a8
302#define BNX2_L2CTX_TXP_BSEQ 0x000000ac 306#define BNX2_L2CTX_TXP_BSEQ 0x000000ac
303 307
308#define BNX2_L2CTX_TYPE_XI 0x00000080
309#define BNX2_L2CTX_CMD_TYPE_XI 0x00000240
310#define BNX2_L2CTX_TBDR_BHADDR_HI_XI 0x00000258
311#define BNX2_L2CTX_TBDR_BHADDR_LO_XI 0x0000025c
304 312
305/* 313/*
306 * l2_bd_chain_context definition 314 * l2_bd_chain_context definition
@@ -328,11 +336,15 @@ struct l2_fhdr {
328#define BNX2_PCICFG_MISC_CONFIG 0x00000068 336#define BNX2_PCICFG_MISC_CONFIG 0x00000068
329#define BNX2_PCICFG_MISC_CONFIG_TARGET_BYTE_SWAP (1L<<2) 337#define BNX2_PCICFG_MISC_CONFIG_TARGET_BYTE_SWAP (1L<<2)
330#define BNX2_PCICFG_MISC_CONFIG_TARGET_MB_WORD_SWAP (1L<<3) 338#define BNX2_PCICFG_MISC_CONFIG_TARGET_MB_WORD_SWAP (1L<<3)
339#define BNX2_PCICFG_MISC_CONFIG_RESERVED1 (1L<<4)
331#define BNX2_PCICFG_MISC_CONFIG_CLOCK_CTL_ENA (1L<<5) 340#define BNX2_PCICFG_MISC_CONFIG_CLOCK_CTL_ENA (1L<<5)
332#define BNX2_PCICFG_MISC_CONFIG_TARGET_GRC_WORD_SWAP (1L<<6) 341#define BNX2_PCICFG_MISC_CONFIG_TARGET_GRC_WORD_SWAP (1L<<6)
333#define BNX2_PCICFG_MISC_CONFIG_REG_WINDOW_ENA (1L<<7) 342#define BNX2_PCICFG_MISC_CONFIG_REG_WINDOW_ENA (1L<<7)
334#define BNX2_PCICFG_MISC_CONFIG_CORE_RST_REQ (1L<<8) 343#define BNX2_PCICFG_MISC_CONFIG_CORE_RST_REQ (1L<<8)
335#define BNX2_PCICFG_MISC_CONFIG_CORE_RST_BSY (1L<<9) 344#define BNX2_PCICFG_MISC_CONFIG_CORE_RST_BSY (1L<<9)
345#define BNX2_PCICFG_MISC_CONFIG_GRC_WIN1_SWAP_EN (1L<<10)
346#define BNX2_PCICFG_MISC_CONFIG_GRC_WIN2_SWAP_EN (1L<<11)
347#define BNX2_PCICFG_MISC_CONFIG_GRC_WIN3_SWAP_EN (1L<<12)
336#define BNX2_PCICFG_MISC_CONFIG_ASIC_METAL_REV (0xffL<<16) 348#define BNX2_PCICFG_MISC_CONFIG_ASIC_METAL_REV (0xffL<<16)
337#define BNX2_PCICFG_MISC_CONFIG_ASIC_BASE_REV (0xfL<<24) 349#define BNX2_PCICFG_MISC_CONFIG_ASIC_BASE_REV (0xfL<<24)
338#define BNX2_PCICFG_MISC_CONFIG_ASIC_ID (0xfL<<28) 350#define BNX2_PCICFG_MISC_CONFIG_ASIC_ID (0xfL<<28)
@@ -347,6 +359,7 @@ struct l2_fhdr {
347#define BNX2_PCICFG_MISC_STATUS_PCIX_SPEED_100 (1L<<4) 359#define BNX2_PCICFG_MISC_STATUS_PCIX_SPEED_100 (1L<<4)
348#define BNX2_PCICFG_MISC_STATUS_PCIX_SPEED_133 (2L<<4) 360#define BNX2_PCICFG_MISC_STATUS_PCIX_SPEED_133 (2L<<4)
349#define BNX2_PCICFG_MISC_STATUS_PCIX_SPEED_PCI_MODE (3L<<4) 361#define BNX2_PCICFG_MISC_STATUS_PCIX_SPEED_PCI_MODE (3L<<4)
362#define BNX2_PCICFG_MISC_STATUS_BAD_MEM_WRITE_BE (1L<<8)
350 363
351#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS 0x00000070 364#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS 0x00000070
352#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET (0xfL<<0) 365#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET (0xfL<<0)
@@ -366,7 +379,7 @@ struct l2_fhdr {
366#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_ALT_SRC_12 (1L<<8) 379#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_ALT_SRC_12 (1L<<8)
367#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_ALT_SRC_6 (2L<<8) 380#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_ALT_SRC_6 (2L<<8)
368#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_ALT_SRC_62 (4L<<8) 381#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_ALT_SRC_62 (4L<<8)
369#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PLAY_DEAD (1L<<11) 382#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_MIN_POWER (1L<<11)
370#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED (0xfL<<12) 383#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED (0xfL<<12)
371#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_100 (0L<<12) 384#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_100 (0L<<12)
372#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_80 (1L<<12) 385#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_80 (1L<<12)
@@ -374,18 +387,21 @@ struct l2_fhdr {
374#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_40 (4L<<12) 387#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_40 (4L<<12)
375#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_25 (8L<<12) 388#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_25 (8L<<12)
376#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_PLL_STOP (1L<<16) 389#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_PLL_STOP (1L<<16)
377#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_PLL_STOP (1L<<17) 390#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_RESERVED_17 (1L<<17)
378#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_RESERVED_18 (1L<<18) 391#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_RESERVED_18 (1L<<18)
379#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_USE_SPD_DET (1L<<19) 392#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_RESERVED_19 (1L<<19)
380#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_RESERVED (0xfffL<<20) 393#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_RESERVED (0xfffL<<20)
381 394
382#define BNX2_PCICFG_REG_WINDOW_ADDRESS 0x00000078 395#define BNX2_PCICFG_REG_WINDOW_ADDRESS 0x00000078
396#define BNX2_PCICFG_REG_WINDOW_ADDRESS_VAL (0xfffffL<<2)
397
383#define BNX2_PCICFG_REG_WINDOW 0x00000080 398#define BNX2_PCICFG_REG_WINDOW 0x00000080
384#define BNX2_PCICFG_INT_ACK_CMD 0x00000084 399#define BNX2_PCICFG_INT_ACK_CMD 0x00000084
385#define BNX2_PCICFG_INT_ACK_CMD_INDEX (0xffffL<<0) 400#define BNX2_PCICFG_INT_ACK_CMD_INDEX (0xffffL<<0)
386#define BNX2_PCICFG_INT_ACK_CMD_INDEX_VALID (1L<<16) 401#define BNX2_PCICFG_INT_ACK_CMD_INDEX_VALID (1L<<16)
387#define BNX2_PCICFG_INT_ACK_CMD_USE_INT_HC_PARAM (1L<<17) 402#define BNX2_PCICFG_INT_ACK_CMD_USE_INT_HC_PARAM (1L<<17)
388#define BNX2_PCICFG_INT_ACK_CMD_MASK_INT (1L<<18) 403#define BNX2_PCICFG_INT_ACK_CMD_MASK_INT (1L<<18)
404#define BNX2_PCICFG_INT_ACK_CMD_INTERRUPT_NUM (0xfL<<24)
389 405
390#define BNX2_PCICFG_STATUS_BIT_SET_CMD 0x00000088 406#define BNX2_PCICFG_STATUS_BIT_SET_CMD 0x00000088
391#define BNX2_PCICFG_STATUS_BIT_CLEAR_CMD 0x0000008c 407#define BNX2_PCICFG_STATUS_BIT_CLEAR_CMD 0x0000008c
@@ -398,9 +414,11 @@ struct l2_fhdr {
398 * offset: 0x400 414 * offset: 0x400
399 */ 415 */
400#define BNX2_PCI_GRC_WINDOW_ADDR 0x00000400 416#define BNX2_PCI_GRC_WINDOW_ADDR 0x00000400
401#define BNX2_PCI_GRC_WINDOW_ADDR_PCI_GRC_WINDOW_ADDR_VALUE (0x3ffffL<<8) 417#define BNX2_PCI_GRC_WINDOW_ADDR_VALUE (0x1ffL<<13)
418#define BNX2_PCI_GRC_WINDOW_ADDR_SEP_WIN (1L<<31)
402 419
403#define BNX2_PCI_CONFIG_1 0x00000404 420#define BNX2_PCI_CONFIG_1 0x00000404
421#define BNX2_PCI_CONFIG_1_RESERVED0 (0xffL<<0)
404#define BNX2_PCI_CONFIG_1_READ_BOUNDARY (0x7L<<8) 422#define BNX2_PCI_CONFIG_1_READ_BOUNDARY (0x7L<<8)
405#define BNX2_PCI_CONFIG_1_READ_BOUNDARY_OFF (0L<<8) 423#define BNX2_PCI_CONFIG_1_READ_BOUNDARY_OFF (0L<<8)
406#define BNX2_PCI_CONFIG_1_READ_BOUNDARY_16 (1L<<8) 424#define BNX2_PCI_CONFIG_1_READ_BOUNDARY_16 (1L<<8)
@@ -419,6 +437,7 @@ struct l2_fhdr {
419#define BNX2_PCI_CONFIG_1_WRITE_BOUNDARY_256 (5L<<11) 437#define BNX2_PCI_CONFIG_1_WRITE_BOUNDARY_256 (5L<<11)
420#define BNX2_PCI_CONFIG_1_WRITE_BOUNDARY_512 (6L<<11) 438#define BNX2_PCI_CONFIG_1_WRITE_BOUNDARY_512 (6L<<11)
421#define BNX2_PCI_CONFIG_1_WRITE_BOUNDARY_1024 (7L<<11) 439#define BNX2_PCI_CONFIG_1_WRITE_BOUNDARY_1024 (7L<<11)
440#define BNX2_PCI_CONFIG_1_RESERVED1 (0x3ffffL<<14)
422 441
423#define BNX2_PCI_CONFIG_2 0x00000408 442#define BNX2_PCI_CONFIG_2 0x00000408
424#define BNX2_PCI_CONFIG_2_BAR1_SIZE (0xfL<<0) 443#define BNX2_PCI_CONFIG_2_BAR1_SIZE (0xfL<<0)
@@ -468,9 +487,13 @@ struct l2_fhdr {
468#define BNX2_PCI_CONFIG_2_FORCE_32_BIT_MSTR (1L<<23) 487#define BNX2_PCI_CONFIG_2_FORCE_32_BIT_MSTR (1L<<23)
469#define BNX2_PCI_CONFIG_2_FORCE_32_BIT_TGT (1L<<24) 488#define BNX2_PCI_CONFIG_2_FORCE_32_BIT_TGT (1L<<24)
470#define BNX2_PCI_CONFIG_2_KEEP_REQ_ASSERT (1L<<25) 489#define BNX2_PCI_CONFIG_2_KEEP_REQ_ASSERT (1L<<25)
490#define BNX2_PCI_CONFIG_2_RESERVED0 (0x3fL<<26)
491#define BNX2_PCI_CONFIG_2_BAR_PREFETCH_XI (1L<<16)
492#define BNX2_PCI_CONFIG_2_RESERVED0_XI (0x7fffL<<17)
471 493
472#define BNX2_PCI_CONFIG_3 0x0000040c 494#define BNX2_PCI_CONFIG_3 0x0000040c
473#define BNX2_PCI_CONFIG_3_STICKY_BYTE (0xffL<<0) 495#define BNX2_PCI_CONFIG_3_STICKY_BYTE (0xffL<<0)
496#define BNX2_PCI_CONFIG_3_REG_STICKY_BYTE (0xffL<<8)
474#define BNX2_PCI_CONFIG_3_FORCE_PME (1L<<24) 497#define BNX2_PCI_CONFIG_3_FORCE_PME (1L<<24)
475#define BNX2_PCI_CONFIG_3_PME_STATUS (1L<<25) 498#define BNX2_PCI_CONFIG_3_PME_STATUS (1L<<25)
476#define BNX2_PCI_CONFIG_3_PME_ENABLE (1L<<26) 499#define BNX2_PCI_CONFIG_3_PME_ENABLE (1L<<26)
@@ -501,8 +524,10 @@ struct l2_fhdr {
501#define BNX2_PCI_VPD_INTF_INTF_REQ (1L<<0) 524#define BNX2_PCI_VPD_INTF_INTF_REQ (1L<<0)
502 525
503#define BNX2_PCI_VPD_ADDR_FLAG 0x0000042c 526#define BNX2_PCI_VPD_ADDR_FLAG 0x0000042c
504#define BNX2_PCI_VPD_ADDR_FLAG_ADDRESS (0x1fff<<2) 527#define BNX2_PCI_VPD_ADDR_FLAG_MSK 0x0000ffff
505#define BNX2_PCI_VPD_ADDR_FLAG_WR (1<<15) 528#define BNX2_PCI_VPD_ADDR_FLAG_SL 0L
529#define BNX2_PCI_VPD_ADDR_FLAG_ADDRESS (0x1fffL<<2)
530#define BNX2_PCI_VPD_ADDR_FLAG_WR (1L<<15)
506 531
507#define BNX2_PCI_VPD_DATA 0x00000430 532#define BNX2_PCI_VPD_DATA 0x00000430
508#define BNX2_PCI_ID_VAL1 0x00000434 533#define BNX2_PCI_ID_VAL1 0x00000434
@@ -535,19 +560,26 @@ struct l2_fhdr {
535#define BNX2_PCI_ID_VAL4_CAP_ENA_13 (13L<<0) 560#define BNX2_PCI_ID_VAL4_CAP_ENA_13 (13L<<0)
536#define BNX2_PCI_ID_VAL4_CAP_ENA_14 (14L<<0) 561#define BNX2_PCI_ID_VAL4_CAP_ENA_14 (14L<<0)
537#define BNX2_PCI_ID_VAL4_CAP_ENA_15 (15L<<0) 562#define BNX2_PCI_ID_VAL4_CAP_ENA_15 (15L<<0)
563#define BNX2_PCI_ID_VAL4_RESERVED0 (0x3L<<4)
538#define BNX2_PCI_ID_VAL4_PM_SCALE_PRG (0x3L<<6) 564#define BNX2_PCI_ID_VAL4_PM_SCALE_PRG (0x3L<<6)
539#define BNX2_PCI_ID_VAL4_PM_SCALE_PRG_0 (0L<<6) 565#define BNX2_PCI_ID_VAL4_PM_SCALE_PRG_0 (0L<<6)
540#define BNX2_PCI_ID_VAL4_PM_SCALE_PRG_1 (1L<<6) 566#define BNX2_PCI_ID_VAL4_PM_SCALE_PRG_1 (1L<<6)
541#define BNX2_PCI_ID_VAL4_PM_SCALE_PRG_2 (2L<<6) 567#define BNX2_PCI_ID_VAL4_PM_SCALE_PRG_2 (2L<<6)
542#define BNX2_PCI_ID_VAL4_PM_SCALE_PRG_3 (3L<<6) 568#define BNX2_PCI_ID_VAL4_PM_SCALE_PRG_3 (3L<<6)
569#define BNX2_PCI_ID_VAL4_MSI_PV_MASK_CAP (1L<<8)
543#define BNX2_PCI_ID_VAL4_MSI_LIMIT (0x7L<<9) 570#define BNX2_PCI_ID_VAL4_MSI_LIMIT (0x7L<<9)
544#define BNX2_PCI_ID_VAL4_MSI_ADVERTIZE (0x7L<<12) 571#define BNX2_PCI_ID_VAL4_MULTI_MSG_CAP (0x7L<<12)
545#define BNX2_PCI_ID_VAL4_MSI_ENABLE (1L<<15) 572#define BNX2_PCI_ID_VAL4_MSI_ENABLE (1L<<15)
546#define BNX2_PCI_ID_VAL4_MAX_64_ADVERTIZE (1L<<16) 573#define BNX2_PCI_ID_VAL4_MAX_64_ADVERTIZE (1L<<16)
547#define BNX2_PCI_ID_VAL4_MAX_133_ADVERTIZE (1L<<17) 574#define BNX2_PCI_ID_VAL4_MAX_133_ADVERTIZE (1L<<17)
548#define BNX2_PCI_ID_VAL4_MAX_MEM_READ_SIZE (0x3L<<21) 575#define BNX2_PCI_ID_VAL4_RESERVED2 (0x7L<<18)
549#define BNX2_PCI_ID_VAL4_MAX_SPLIT_SIZE (0x7L<<23) 576#define BNX2_PCI_ID_VAL4_MAX_CUMULATIVE_SIZE_B21 (0x3L<<21)
550#define BNX2_PCI_ID_VAL4_MAX_CUMULATIVE_SIZE (0x7L<<26) 577#define BNX2_PCI_ID_VAL4_MAX_SPLIT_SIZE_B21 (0x3L<<23)
578#define BNX2_PCI_ID_VAL4_MAX_CUMULATIVE_SIZE_B0 (1L<<25)
579#define BNX2_PCI_ID_VAL4_MAX_MEM_READ_SIZE_B10 (0x3L<<26)
580#define BNX2_PCI_ID_VAL4_MAX_SPLIT_SIZE_B0 (1L<<28)
581#define BNX2_PCI_ID_VAL4_RESERVED3 (0x7L<<29)
582#define BNX2_PCI_ID_VAL4_RESERVED3_XI (0xffffL<<16)
551 583
552#define BNX2_PCI_ID_VAL5 0x00000444 584#define BNX2_PCI_ID_VAL5 0x00000444
553#define BNX2_PCI_ID_VAL5_D1_SUPPORT (1L<<0) 585#define BNX2_PCI_ID_VAL5_D1_SUPPORT (1L<<0)
@@ -556,6 +588,10 @@ struct l2_fhdr {
556#define BNX2_PCI_ID_VAL5_PME_IN_D1 (1L<<3) 588#define BNX2_PCI_ID_VAL5_PME_IN_D1 (1L<<3)
557#define BNX2_PCI_ID_VAL5_PME_IN_D2 (1L<<4) 589#define BNX2_PCI_ID_VAL5_PME_IN_D2 (1L<<4)
558#define BNX2_PCI_ID_VAL5_PME_IN_D3_HOT (1L<<5) 590#define BNX2_PCI_ID_VAL5_PME_IN_D3_HOT (1L<<5)
591#define BNX2_PCI_ID_VAL5_RESERVED0_TE (0x3ffffffL<<6)
592#define BNX2_PCI_ID_VAL5_PM_VERSION_XI (0x7L<<6)
593#define BNX2_PCI_ID_VAL5_NO_SOFT_RESET_XI (1L<<9)
594#define BNX2_PCI_ID_VAL5_RESERVED0_XI (0x3fffffL<<10)
559 595
560#define BNX2_PCI_PCIX_EXTENDED_STATUS 0x00000448 596#define BNX2_PCI_PCIX_EXTENDED_STATUS 0x00000448
561#define BNX2_PCI_PCIX_EXTENDED_STATUS_NO_SNOOP (1L<<8) 597#define BNX2_PCI_PCIX_EXTENDED_STATUS_NO_SNOOP (1L<<8)
@@ -567,12 +603,91 @@ struct l2_fhdr {
567#define BNX2_PCI_ID_VAL6_MAX_LAT (0xffL<<0) 603#define BNX2_PCI_ID_VAL6_MAX_LAT (0xffL<<0)
568#define BNX2_PCI_ID_VAL6_MIN_GNT (0xffL<<8) 604#define BNX2_PCI_ID_VAL6_MIN_GNT (0xffL<<8)
569#define BNX2_PCI_ID_VAL6_BIST (0xffL<<16) 605#define BNX2_PCI_ID_VAL6_BIST (0xffL<<16)
606#define BNX2_PCI_ID_VAL6_RESERVED0 (0xffL<<24)
570 607
571#define BNX2_PCI_MSI_DATA 0x00000450 608#define BNX2_PCI_MSI_DATA 0x00000450
572#define BNX2_PCI_MSI_DATA_PCI_MSI_DATA (0xffffL<<0) 609#define BNX2_PCI_MSI_DATA_MSI_DATA (0xffffL<<0)
573 610
574#define BNX2_PCI_MSI_ADDR_H 0x00000454 611#define BNX2_PCI_MSI_ADDR_H 0x00000454
575#define BNX2_PCI_MSI_ADDR_L 0x00000458 612#define BNX2_PCI_MSI_ADDR_L 0x00000458
613#define BNX2_PCI_MSI_ADDR_L_VAL (0x3fffffffL<<2)
614
615#define BNX2_PCI_CFG_ACCESS_CMD 0x0000045c
616#define BNX2_PCI_CFG_ACCESS_CMD_ADR (0x3fL<<2)
617#define BNX2_PCI_CFG_ACCESS_CMD_RD_REQ (1L<<27)
618#define BNX2_PCI_CFG_ACCESS_CMD_WR_REQ (0xfL<<28)
619
620#define BNX2_PCI_CFG_ACCESS_DATA 0x00000460
621#define BNX2_PCI_MSI_MASK 0x00000464
622#define BNX2_PCI_MSI_MASK_MSI_MASK (0xffffffffL<<0)
623
624#define BNX2_PCI_MSI_PEND 0x00000468
625#define BNX2_PCI_MSI_PEND_MSI_PEND (0xffffffffL<<0)
626
627#define BNX2_PCI_PM_DATA_C 0x0000046c
628#define BNX2_PCI_PM_DATA_C_PM_DATA_8_PRG (0xffL<<0)
629#define BNX2_PCI_PM_DATA_C_RESERVED0 (0xffffffL<<8)
630
631#define BNX2_PCI_MSIX_CONTROL 0x000004c0
632#define BNX2_PCI_MSIX_CONTROL_MSIX_TBL_SIZ (0x7ffL<<0)
633#define BNX2_PCI_MSIX_CONTROL_RESERVED0 (0x1fffffL<<11)
634
635#define BNX2_PCI_MSIX_TBL_OFF_BIR 0x000004c4
636#define BNX2_PCI_MSIX_TBL_OFF_BIR_MSIX_TBL_BIR (0x7L<<0)
637#define BNX2_PCI_MSIX_TBL_OFF_BIR_MSIX_TBL_OFF (0x1fffffffL<<3)
638
639#define BNX2_PCI_MSIX_PBA_OFF_BIT 0x000004c8
640#define BNX2_PCI_MSIX_PBA_OFF_BIT_MSIX_PBA_BIR (0x7L<<0)
641#define BNX2_PCI_MSIX_PBA_OFF_BIT_MSIX_PBA_OFF (0x1fffffffL<<3)
642
643#define BNX2_PCI_PCIE_CAPABILITY 0x000004d0
644#define BNX2_PCI_PCIE_CAPABILITY_INTERRUPT_MSG_NUM (0x1fL<<0)
645#define BNX2_PCI_PCIE_CAPABILITY_COMPLY_PCIE_1_1 (1L<<5)
646
647#define BNX2_PCI_DEVICE_CAPABILITY 0x000004d4
648#define BNX2_PCI_DEVICE_CAPABILITY_MAX_PL_SIZ_SUPPORTED (0x7L<<0)
649#define BNX2_PCI_DEVICE_CAPABILITY_EXTENDED_TAG_SUPPORT (1L<<5)
650#define BNX2_PCI_DEVICE_CAPABILITY_L0S_ACCEPTABLE_LATENCY (0x7L<<6)
651#define BNX2_PCI_DEVICE_CAPABILITY_L1_ACCEPTABLE_LATENCY (0x7L<<9)
652#define BNX2_PCI_DEVICE_CAPABILITY_ROLE_BASED_ERR_RPT (1L<<15)
653
654#define BNX2_PCI_LINK_CAPABILITY 0x000004dc
655#define BNX2_PCI_LINK_CAPABILITY_MAX_LINK_SPEED (0xfL<<0)
656#define BNX2_PCI_LINK_CAPABILITY_MAX_LINK_SPEED_0001 (1L<<0)
657#define BNX2_PCI_LINK_CAPABILITY_MAX_LINK_SPEED_0010 (1L<<0)
658#define BNX2_PCI_LINK_CAPABILITY_MAX_LINK_WIDTH (0x1fL<<4)
659#define BNX2_PCI_LINK_CAPABILITY_CLK_POWER_MGMT (1L<<9)
660#define BNX2_PCI_LINK_CAPABILITY_ASPM_SUPPORT (0x3L<<10)
661#define BNX2_PCI_LINK_CAPABILITY_L0S_EXIT_LAT (0x7L<<12)
662#define BNX2_PCI_LINK_CAPABILITY_L0S_EXIT_LAT_101 (5L<<12)
663#define BNX2_PCI_LINK_CAPABILITY_L0S_EXIT_LAT_110 (6L<<12)
664#define BNX2_PCI_LINK_CAPABILITY_L1_EXIT_LAT (0x7L<<15)
665#define BNX2_PCI_LINK_CAPABILITY_L1_EXIT_LAT_001 (1L<<15)
666#define BNX2_PCI_LINK_CAPABILITY_L1_EXIT_LAT_010 (2L<<15)
667#define BNX2_PCI_LINK_CAPABILITY_L0S_EXIT_COMM_LAT (0x7L<<18)
668#define BNX2_PCI_LINK_CAPABILITY_L0S_EXIT_COMM_LAT_101 (5L<<18)
669#define BNX2_PCI_LINK_CAPABILITY_L0S_EXIT_COMM_LAT_110 (6L<<18)
670#define BNX2_PCI_LINK_CAPABILITY_L1_EXIT_COMM_LAT (0x7L<<21)
671#define BNX2_PCI_LINK_CAPABILITY_L1_EXIT_COMM_LAT_001 (1L<<21)
672#define BNX2_PCI_LINK_CAPABILITY_L1_EXIT_COMM_LAT_010 (2L<<21)
673#define BNX2_PCI_LINK_CAPABILITY_PORT_NUM (0xffL<<24)
674
675#define BNX2_PCI_PCIE_DEVICE_CAPABILITY_2 0x000004e4
676#define BNX2_PCI_PCIE_DEVICE_CAPABILITY_2_CMPL_TO_RANGE_SUPP (0xfL<<0)
677#define BNX2_PCI_PCIE_DEVICE_CAPABILITY_2_CMPL_TO_DISABL_SUPP (1L<<4)
678#define BNX2_PCI_PCIE_DEVICE_CAPABILITY_2_RESERVED (0x7ffffffL<<5)
679
680#define BNX2_PCI_PCIE_LINK_CAPABILITY_2 0x000004e8
681#define BNX2_PCI_PCIE_LINK_CAPABILITY_2_RESERVED (0xffffffffL<<0)
682
683#define BNX2_PCI_GRC_WINDOW1_ADDR 0x00000610
684#define BNX2_PCI_GRC_WINDOW1_ADDR_VALUE (0x1ffL<<13)
685
686#define BNX2_PCI_GRC_WINDOW2_ADDR 0x00000614
687#define BNX2_PCI_GRC_WINDOW2_ADDR_VALUE (0x1ffL<<13)
688
689#define BNX2_PCI_GRC_WINDOW3_ADDR 0x00000618
690#define BNX2_PCI_GRC_WINDOW3_ADDR_VALUE (0x1ffL<<13)
576 691
577 692
578/* 693/*
@@ -582,13 +697,23 @@ struct l2_fhdr {
582#define BNX2_MISC_COMMAND 0x00000800 697#define BNX2_MISC_COMMAND 0x00000800
583#define BNX2_MISC_COMMAND_ENABLE_ALL (1L<<0) 698#define BNX2_MISC_COMMAND_ENABLE_ALL (1L<<0)
584#define BNX2_MISC_COMMAND_DISABLE_ALL (1L<<1) 699#define BNX2_MISC_COMMAND_DISABLE_ALL (1L<<1)
585#define BNX2_MISC_COMMAND_CORE_RESET (1L<<4) 700#define BNX2_MISC_COMMAND_SW_RESET (1L<<4)
586#define BNX2_MISC_COMMAND_HARD_RESET (1L<<5) 701#define BNX2_MISC_COMMAND_POR_RESET (1L<<5)
702#define BNX2_MISC_COMMAND_HD_RESET (1L<<6)
703#define BNX2_MISC_COMMAND_CMN_SW_RESET (1L<<7)
587#define BNX2_MISC_COMMAND_PAR_ERROR (1L<<8) 704#define BNX2_MISC_COMMAND_PAR_ERROR (1L<<8)
705#define BNX2_MISC_COMMAND_CS16_ERR (1L<<9)
706#define BNX2_MISC_COMMAND_CS16_ERR_LOC (0xfL<<12)
588#define BNX2_MISC_COMMAND_PAR_ERR_RAM (0x7fL<<16) 707#define BNX2_MISC_COMMAND_PAR_ERR_RAM (0x7fL<<16)
708#define BNX2_MISC_COMMAND_POWERDOWN_EVENT (1L<<23)
709#define BNX2_MISC_COMMAND_SW_SHUTDOWN (1L<<24)
710#define BNX2_MISC_COMMAND_SHUTDOWN_EN (1L<<25)
711#define BNX2_MISC_COMMAND_DINTEG_ATTN_EN (1L<<26)
712#define BNX2_MISC_COMMAND_PCIE_LINK_IN_L23 (1L<<27)
713#define BNX2_MISC_COMMAND_PCIE_DIS (1L<<28)
589 714
590#define BNX2_MISC_CFG 0x00000804 715#define BNX2_MISC_CFG 0x00000804
591#define BNX2_MISC_CFG_PCI_GRC_TMOUT (1L<<0) 716#define BNX2_MISC_CFG_GRC_TMOUT (1L<<0)
592#define BNX2_MISC_CFG_NVM_WR_EN (0x3L<<1) 717#define BNX2_MISC_CFG_NVM_WR_EN (0x3L<<1)
593#define BNX2_MISC_CFG_NVM_WR_EN_PROTECT (0L<<1) 718#define BNX2_MISC_CFG_NVM_WR_EN_PROTECT (0L<<1)
594#define BNX2_MISC_CFG_NVM_WR_EN_PCI (1L<<1) 719#define BNX2_MISC_CFG_NVM_WR_EN_PCI (1L<<1)
@@ -596,16 +721,45 @@ struct l2_fhdr {
596#define BNX2_MISC_CFG_NVM_WR_EN_ALLOW2 (3L<<1) 721#define BNX2_MISC_CFG_NVM_WR_EN_ALLOW2 (3L<<1)
597#define BNX2_MISC_CFG_BIST_EN (1L<<3) 722#define BNX2_MISC_CFG_BIST_EN (1L<<3)
598#define BNX2_MISC_CFG_CK25_OUT_ALT_SRC (1L<<4) 723#define BNX2_MISC_CFG_CK25_OUT_ALT_SRC (1L<<4)
599#define BNX2_MISC_CFG_BYPASS_BSCAN (1L<<5) 724#define BNX2_MISC_CFG_RESERVED5_TE (1L<<5)
600#define BNX2_MISC_CFG_BYPASS_EJTAG (1L<<6) 725#define BNX2_MISC_CFG_RESERVED6_TE (1L<<6)
601#define BNX2_MISC_CFG_CLK_CTL_OVERRIDE (1L<<7) 726#define BNX2_MISC_CFG_CLK_CTL_OVERRIDE (1L<<7)
602#define BNX2_MISC_CFG_LEDMODE (0x3L<<8) 727#define BNX2_MISC_CFG_LEDMODE (0x7L<<8)
603#define BNX2_MISC_CFG_LEDMODE_MAC (0L<<8) 728#define BNX2_MISC_CFG_LEDMODE_MAC (0L<<8)
604#define BNX2_MISC_CFG_LEDMODE_GPHY1 (1L<<8) 729#define BNX2_MISC_CFG_LEDMODE_PHY1_TE (1L<<8)
605#define BNX2_MISC_CFG_LEDMODE_GPHY2 (2L<<8) 730#define BNX2_MISC_CFG_LEDMODE_PHY2_TE (2L<<8)
731#define BNX2_MISC_CFG_LEDMODE_PHY3_TE (3L<<8)
732#define BNX2_MISC_CFG_LEDMODE_PHY4_TE (4L<<8)
733#define BNX2_MISC_CFG_LEDMODE_PHY5_TE (5L<<8)
734#define BNX2_MISC_CFG_LEDMODE_PHY6_TE (6L<<8)
735#define BNX2_MISC_CFG_LEDMODE_PHY7_TE (7L<<8)
736#define BNX2_MISC_CFG_MCP_GRC_TMOUT_TE (1L<<11)
737#define BNX2_MISC_CFG_DBU_GRC_TMOUT_TE (1L<<12)
738#define BNX2_MISC_CFG_LEDMODE_XI (0xfL<<8)
739#define BNX2_MISC_CFG_LEDMODE_MAC_XI (0L<<8)
740#define BNX2_MISC_CFG_LEDMODE_PHY1_XI (1L<<8)
741#define BNX2_MISC_CFG_LEDMODE_PHY2_XI (2L<<8)
742#define BNX2_MISC_CFG_LEDMODE_PHY3_XI (3L<<8)
743#define BNX2_MISC_CFG_LEDMODE_MAC2_XI (4L<<8)
744#define BNX2_MISC_CFG_LEDMODE_PHY4_XI (5L<<8)
745#define BNX2_MISC_CFG_LEDMODE_PHY5_XI (6L<<8)
746#define BNX2_MISC_CFG_LEDMODE_PHY6_XI (7L<<8)
747#define BNX2_MISC_CFG_LEDMODE_MAC3_XI (8L<<8)
748#define BNX2_MISC_CFG_LEDMODE_PHY7_XI (9L<<8)
749#define BNX2_MISC_CFG_LEDMODE_PHY8_XI (10L<<8)
750#define BNX2_MISC_CFG_LEDMODE_PHY9_XI (11L<<8)
751#define BNX2_MISC_CFG_LEDMODE_MAC4_XI (12L<<8)
752#define BNX2_MISC_CFG_LEDMODE_PHY10_XI (13L<<8)
753#define BNX2_MISC_CFG_LEDMODE_PHY11_XI (14L<<8)
754#define BNX2_MISC_CFG_LEDMODE_UNUSED_XI (15L<<8)
755#define BNX2_MISC_CFG_PORT_SELECT_XI (1L<<13)
756#define BNX2_MISC_CFG_PARITY_MODE_XI (1L<<14)
606 757
607#define BNX2_MISC_ID 0x00000808 758#define BNX2_MISC_ID 0x00000808
608#define BNX2_MISC_ID_BOND_ID (0xfL<<0) 759#define BNX2_MISC_ID_BOND_ID (0xfL<<0)
760#define BNX2_MISC_ID_BOND_ID_X (0L<<0)
761#define BNX2_MISC_ID_BOND_ID_C (3L<<0)
762#define BNX2_MISC_ID_BOND_ID_S (12L<<0)
609#define BNX2_MISC_ID_CHIP_METAL (0xffL<<4) 763#define BNX2_MISC_ID_CHIP_METAL (0xffL<<4)
610#define BNX2_MISC_ID_CHIP_REV (0xfL<<12) 764#define BNX2_MISC_ID_CHIP_REV (0xfL<<12)
611#define BNX2_MISC_ID_CHIP_NUM (0xffffL<<16) 765#define BNX2_MISC_ID_CHIP_NUM (0xffffL<<16)
@@ -639,6 +793,8 @@ struct l2_fhdr {
639#define BNX2_MISC_ENABLE_STATUS_BITS_TIMER_ENABLE (1L<<25) 793#define BNX2_MISC_ENABLE_STATUS_BITS_TIMER_ENABLE (1L<<25)
640#define BNX2_MISC_ENABLE_STATUS_BITS_DMA_ENGINE_ENABLE (1L<<26) 794#define BNX2_MISC_ENABLE_STATUS_BITS_DMA_ENGINE_ENABLE (1L<<26)
641#define BNX2_MISC_ENABLE_STATUS_BITS_UMP_ENABLE (1L<<27) 795#define BNX2_MISC_ENABLE_STATUS_BITS_UMP_ENABLE (1L<<27)
796#define BNX2_MISC_ENABLE_STATUS_BITS_RV2P_CMD_SCHEDULER_ENABLE (1L<<28)
797#define BNX2_MISC_ENABLE_STATUS_BITS_RSVD_FUTURE_ENABLE (0x7L<<29)
642 798
643#define BNX2_MISC_ENABLE_SET_BITS 0x00000810 799#define BNX2_MISC_ENABLE_SET_BITS 0x00000810
644#define BNX2_MISC_ENABLE_SET_BITS_TX_SCHEDULER_ENABLE (1L<<0) 800#define BNX2_MISC_ENABLE_SET_BITS_TX_SCHEDULER_ENABLE (1L<<0)
@@ -669,6 +825,8 @@ struct l2_fhdr {
669#define BNX2_MISC_ENABLE_SET_BITS_TIMER_ENABLE (1L<<25) 825#define BNX2_MISC_ENABLE_SET_BITS_TIMER_ENABLE (1L<<25)
670#define BNX2_MISC_ENABLE_SET_BITS_DMA_ENGINE_ENABLE (1L<<26) 826#define BNX2_MISC_ENABLE_SET_BITS_DMA_ENGINE_ENABLE (1L<<26)
671#define BNX2_MISC_ENABLE_SET_BITS_UMP_ENABLE (1L<<27) 827#define BNX2_MISC_ENABLE_SET_BITS_UMP_ENABLE (1L<<27)
828#define BNX2_MISC_ENABLE_SET_BITS_RV2P_CMD_SCHEDULER_ENABLE (1L<<28)
829#define BNX2_MISC_ENABLE_SET_BITS_RSVD_FUTURE_ENABLE (0x7L<<29)
672 830
673#define BNX2_MISC_ENABLE_CLR_BITS 0x00000814 831#define BNX2_MISC_ENABLE_CLR_BITS 0x00000814
674#define BNX2_MISC_ENABLE_CLR_BITS_TX_SCHEDULER_ENABLE (1L<<0) 832#define BNX2_MISC_ENABLE_CLR_BITS_TX_SCHEDULER_ENABLE (1L<<0)
@@ -699,6 +857,8 @@ struct l2_fhdr {
699#define BNX2_MISC_ENABLE_CLR_BITS_TIMER_ENABLE (1L<<25) 857#define BNX2_MISC_ENABLE_CLR_BITS_TIMER_ENABLE (1L<<25)
700#define BNX2_MISC_ENABLE_CLR_BITS_DMA_ENGINE_ENABLE (1L<<26) 858#define BNX2_MISC_ENABLE_CLR_BITS_DMA_ENGINE_ENABLE (1L<<26)
701#define BNX2_MISC_ENABLE_CLR_BITS_UMP_ENABLE (1L<<27) 859#define BNX2_MISC_ENABLE_CLR_BITS_UMP_ENABLE (1L<<27)
860#define BNX2_MISC_ENABLE_CLR_BITS_RV2P_CMD_SCHEDULER_ENABLE (1L<<28)
861#define BNX2_MISC_ENABLE_CLR_BITS_RSVD_FUTURE_ENABLE (0x7L<<29)
702 862
703#define BNX2_MISC_CLOCK_CONTROL_BITS 0x00000818 863#define BNX2_MISC_CLOCK_CONTROL_BITS 0x00000818
704#define BNX2_MISC_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET (0xfL<<0) 864#define BNX2_MISC_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET (0xfL<<0)
@@ -718,30 +878,41 @@ struct l2_fhdr {
718#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_ALT_SRC_12 (1L<<8) 878#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_ALT_SRC_12 (1L<<8)
719#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_ALT_SRC_6 (2L<<8) 879#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_ALT_SRC_6 (2L<<8)
720#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_ALT_SRC_62 (4L<<8) 880#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_ALT_SRC_62 (4L<<8)
721#define BNX2_MISC_CLOCK_CONTROL_BITS_PLAY_DEAD (1L<<11) 881#define BNX2_MISC_CLOCK_CONTROL_BITS_RESERVED0_XI (0x7L<<8)
882#define BNX2_MISC_CLOCK_CONTROL_BITS_MIN_POWER (1L<<11)
722#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED (0xfL<<12) 883#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED (0xfL<<12)
723#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_100 (0L<<12) 884#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_100 (0L<<12)
724#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_80 (1L<<12) 885#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_80 (1L<<12)
725#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_50 (2L<<12) 886#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_50 (2L<<12)
726#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_40 (4L<<12) 887#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_40 (4L<<12)
727#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_25 (8L<<12) 888#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_25 (8L<<12)
889#define BNX2_MISC_CLOCK_CONTROL_BITS_RESERVED1_XI (0xfL<<12)
728#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_PLL_STOP (1L<<16) 890#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_PLL_STOP (1L<<16)
729#define BNX2_MISC_CLOCK_CONTROL_BITS_PCI_PLL_STOP (1L<<17) 891#define BNX2_MISC_CLOCK_CONTROL_BITS_RESERVED_17_TE (1L<<17)
730#define BNX2_MISC_CLOCK_CONTROL_BITS_RESERVED_18 (1L<<18) 892#define BNX2_MISC_CLOCK_CONTROL_BITS_RESERVED_18_TE (1L<<18)
731#define BNX2_MISC_CLOCK_CONTROL_BITS_USE_SPD_DET (1L<<19) 893#define BNX2_MISC_CLOCK_CONTROL_BITS_RESERVED_19_TE (1L<<19)
732#define BNX2_MISC_CLOCK_CONTROL_BITS_RESERVED (0xfffL<<20) 894#define BNX2_MISC_CLOCK_CONTROL_BITS_RESERVED_TE (0xfffL<<20)
733 895#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_ALT_MGMT_XI (1L<<17)
734#define BNX2_MISC_GPIO 0x0000081c 896#define BNX2_MISC_CLOCK_CONTROL_BITS_RESERVED2_XI (0x3fL<<18)
735#define BNX2_MISC_GPIO_VALUE (0xffL<<0) 897#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_PLL_VCO_XI (0x7L<<24)
736#define BNX2_MISC_GPIO_SET (0xffL<<8) 898#define BNX2_MISC_CLOCK_CONTROL_BITS_RESERVED3_XI (1L<<27)
737#define BNX2_MISC_GPIO_CLR (0xffL<<16) 899#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_XI (0xfL<<28)
738#define BNX2_MISC_GPIO_FLOAT (0xffL<<24) 900
739 901#define BNX2_MISC_SPIO 0x0000081c
740#define BNX2_MISC_GPIO_INT 0x00000820 902#define BNX2_MISC_SPIO_VALUE (0xffL<<0)
741#define BNX2_MISC_GPIO_INT_INT_STATE (0xfL<<0) 903#define BNX2_MISC_SPIO_SET (0xffL<<8)
742#define BNX2_MISC_GPIO_INT_OLD_VALUE (0xfL<<8) 904#define BNX2_MISC_SPIO_CLR (0xffL<<16)
743#define BNX2_MISC_GPIO_INT_OLD_SET (0xfL<<16) 905#define BNX2_MISC_SPIO_FLOAT (0xffL<<24)
744#define BNX2_MISC_GPIO_INT_OLD_CLR (0xfL<<24) 906
907#define BNX2_MISC_SPIO_INT 0x00000820
908#define BNX2_MISC_SPIO_INT_INT_STATE_TE (0xfL<<0)
909#define BNX2_MISC_SPIO_INT_OLD_VALUE_TE (0xfL<<8)
910#define BNX2_MISC_SPIO_INT_OLD_SET_TE (0xfL<<16)
911#define BNX2_MISC_SPIO_INT_OLD_CLR_TE (0xfL<<24)
912#define BNX2_MISC_SPIO_INT_INT_STATE_XI (0xffL<<0)
913#define BNX2_MISC_SPIO_INT_OLD_VALUE_XI (0xffL<<8)
914#define BNX2_MISC_SPIO_INT_OLD_SET_XI (0xffL<<16)
915#define BNX2_MISC_SPIO_INT_OLD_CLR_XI (0xffL<<24)
745 916
746#define BNX2_MISC_CONFIG_LFSR 0x00000824 917#define BNX2_MISC_CONFIG_LFSR 0x00000824
747#define BNX2_MISC_CONFIG_LFSR_DIV (0xffffL<<0) 918#define BNX2_MISC_CONFIG_LFSR_DIV (0xffffL<<0)
@@ -775,6 +946,8 @@ struct l2_fhdr {
775#define BNX2_MISC_LFSR_MASK_BITS_TIMER_ENABLE (1L<<25) 946#define BNX2_MISC_LFSR_MASK_BITS_TIMER_ENABLE (1L<<25)
776#define BNX2_MISC_LFSR_MASK_BITS_DMA_ENGINE_ENABLE (1L<<26) 947#define BNX2_MISC_LFSR_MASK_BITS_DMA_ENGINE_ENABLE (1L<<26)
777#define BNX2_MISC_LFSR_MASK_BITS_UMP_ENABLE (1L<<27) 948#define BNX2_MISC_LFSR_MASK_BITS_UMP_ENABLE (1L<<27)
949#define BNX2_MISC_LFSR_MASK_BITS_RV2P_CMD_SCHEDULER_ENABLE (1L<<28)
950#define BNX2_MISC_LFSR_MASK_BITS_RSVD_FUTURE_ENABLE (0x7L<<29)
778 951
779#define BNX2_MISC_ARB_REQ0 0x0000082c 952#define BNX2_MISC_ARB_REQ0 0x0000082c
780#define BNX2_MISC_ARB_REQ1 0x00000830 953#define BNX2_MISC_ARB_REQ1 0x00000830
@@ -831,22 +1004,12 @@ struct l2_fhdr {
831#define BNX2_MISC_ARB_GNT3_30 (0x7L<<24) 1004#define BNX2_MISC_ARB_GNT3_30 (0x7L<<24)
832#define BNX2_MISC_ARB_GNT3_31 (0x7L<<28) 1005#define BNX2_MISC_ARB_GNT3_31 (0x7L<<28)
833 1006
834#define BNX2_MISC_PRBS_CONTROL 0x00000878 1007#define BNX2_MISC_RESERVED1 0x00000878
835#define BNX2_MISC_PRBS_CONTROL_EN (1L<<0) 1008#define BNX2_MISC_RESERVED1_MISC_RESERVED1_VALUE (0x3fL<<0)
836#define BNX2_MISC_PRBS_CONTROL_RSTB (1L<<1) 1009
837#define BNX2_MISC_PRBS_CONTROL_INV (1L<<2) 1010#define BNX2_MISC_RESERVED2 0x0000087c
838#define BNX2_MISC_PRBS_CONTROL_ERR_CLR (1L<<3) 1011#define BNX2_MISC_RESERVED2_PCIE_DIS (1L<<0)
839#define BNX2_MISC_PRBS_CONTROL_ORDER (0x3L<<4) 1012#define BNX2_MISC_RESERVED2_LINK_IN_L23 (1L<<1)
840#define BNX2_MISC_PRBS_CONTROL_ORDER_7TH (0L<<4)
841#define BNX2_MISC_PRBS_CONTROL_ORDER_15TH (1L<<4)
842#define BNX2_MISC_PRBS_CONTROL_ORDER_23RD (2L<<4)
843#define BNX2_MISC_PRBS_CONTROL_ORDER_31ST (3L<<4)
844
845#define BNX2_MISC_PRBS_STATUS 0x0000087c
846#define BNX2_MISC_PRBS_STATUS_LOCK (1L<<0)
847#define BNX2_MISC_PRBS_STATUS_STKY (1L<<1)
848#define BNX2_MISC_PRBS_STATUS_ERRORS (0x3fffL<<2)
849#define BNX2_MISC_PRBS_STATUS_STATE (0xfL<<16)
850 1013
851#define BNX2_MISC_SM_ASF_CONTROL 0x00000880 1014#define BNX2_MISC_SM_ASF_CONTROL 0x00000880
852#define BNX2_MISC_SM_ASF_CONTROL_ASF_RST (1L<<0) 1015#define BNX2_MISC_SM_ASF_CONTROL_ASF_RST (1L<<0)
@@ -857,13 +1020,15 @@ struct l2_fhdr {
857#define BNX2_MISC_SM_ASF_CONTROL_PL_TO (1L<<5) 1020#define BNX2_MISC_SM_ASF_CONTROL_PL_TO (1L<<5)
858#define BNX2_MISC_SM_ASF_CONTROL_RT_TO (1L<<6) 1021#define BNX2_MISC_SM_ASF_CONTROL_RT_TO (1L<<6)
859#define BNX2_MISC_SM_ASF_CONTROL_SMB_EVENT (1L<<7) 1022#define BNX2_MISC_SM_ASF_CONTROL_SMB_EVENT (1L<<7)
860#define BNX2_MISC_SM_ASF_CONTROL_RES (0xfL<<8) 1023#define BNX2_MISC_SM_ASF_CONTROL_STRETCH_EN (1L<<8)
1024#define BNX2_MISC_SM_ASF_CONTROL_STRETCH_PULSE (1L<<9)
1025#define BNX2_MISC_SM_ASF_CONTROL_RES (0x3L<<10)
861#define BNX2_MISC_SM_ASF_CONTROL_SMB_EN (1L<<12) 1026#define BNX2_MISC_SM_ASF_CONTROL_SMB_EN (1L<<12)
862#define BNX2_MISC_SM_ASF_CONTROL_SMB_BB_EN (1L<<13) 1027#define BNX2_MISC_SM_ASF_CONTROL_SMB_BB_EN (1L<<13)
863#define BNX2_MISC_SM_ASF_CONTROL_SMB_NO_ADDR_FILT (1L<<14) 1028#define BNX2_MISC_SM_ASF_CONTROL_SMB_NO_ADDR_FILT (1L<<14)
864#define BNX2_MISC_SM_ASF_CONTROL_SMB_AUTOREAD (1L<<15) 1029#define BNX2_MISC_SM_ASF_CONTROL_SMB_AUTOREAD (1L<<15)
865#define BNX2_MISC_SM_ASF_CONTROL_NIC_SMB_ADDR1 (0x3fL<<16) 1030#define BNX2_MISC_SM_ASF_CONTROL_NIC_SMB_ADDR1 (0x7fL<<16)
866#define BNX2_MISC_SM_ASF_CONTROL_NIC_SMB_ADDR2 (0x3fL<<24) 1031#define BNX2_MISC_SM_ASF_CONTROL_NIC_SMB_ADDR2 (0x7fL<<23)
867#define BNX2_MISC_SM_ASF_CONTROL_EN_NIC_SMB_ADDR_0 (1L<<30) 1032#define BNX2_MISC_SM_ASF_CONTROL_EN_NIC_SMB_ADDR_0 (1L<<30)
868#define BNX2_MISC_SM_ASF_CONTROL_SMB_EARLY_ATTN (1L<<31) 1033#define BNX2_MISC_SM_ASF_CONTROL_SMB_EARLY_ATTN (1L<<31)
869 1034
@@ -891,13 +1056,13 @@ struct l2_fhdr {
891#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS (0xfL<<20) 1056#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS (0xfL<<20)
892#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_OK (0L<<20) 1057#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_OK (0L<<20)
893#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_FIRST_NACK (1L<<20) 1058#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_FIRST_NACK (1L<<20)
894#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_SUB_NACK (9L<<20)
895#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_UFLOW (2L<<20) 1059#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_UFLOW (2L<<20)
896#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_STOP (3L<<20) 1060#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_STOP (3L<<20)
897#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_TIMEOUT (4L<<20) 1061#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_TIMEOUT (4L<<20)
898#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_FIRST_LOST (5L<<20) 1062#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_FIRST_LOST (5L<<20)
1063#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_BADACK (6L<<20)
1064#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_SUB_NACK (9L<<20)
899#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_SUB_LOST (0xdL<<20) 1065#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_SUB_LOST (0xdL<<20)
900#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_BADACK (0x6L<<20)
901#define BNX2_MISC_SMB_OUT_SMB_OUT_SLAVEMODE (1L<<24) 1066#define BNX2_MISC_SMB_OUT_SMB_OUT_SLAVEMODE (1L<<24)
902#define BNX2_MISC_SMB_OUT_SMB_OUT_DAT_EN (1L<<25) 1067#define BNX2_MISC_SMB_OUT_SMB_OUT_DAT_EN (1L<<25)
903#define BNX2_MISC_SMB_OUT_SMB_OUT_DAT_IN (1L<<26) 1068#define BNX2_MISC_SMB_OUT_SMB_OUT_DAT_IN (1L<<26)
@@ -955,6 +1120,38 @@ struct l2_fhdr {
955#define BNX2_MISC_PERR_ENA0_RDE_MISC_RPC (1L<<29) 1120#define BNX2_MISC_PERR_ENA0_RDE_MISC_RPC (1L<<29)
956#define BNX2_MISC_PERR_ENA0_RDE_MISC_RPM (1L<<30) 1121#define BNX2_MISC_PERR_ENA0_RDE_MISC_RPM (1L<<30)
957#define BNX2_MISC_PERR_ENA0_RV2P_MISC_CB0REGS (1L<<31) 1122#define BNX2_MISC_PERR_ENA0_RV2P_MISC_CB0REGS (1L<<31)
1123#define BNX2_MISC_PERR_ENA0_COM_DMAE_PERR_EN_XI (1L<<0)
1124#define BNX2_MISC_PERR_ENA0_CP_DMAE_PERR_EN_XI (1L<<1)
1125#define BNX2_MISC_PERR_ENA0_RPM_ACPIBEMEM_PERR_EN_XI (1L<<2)
1126#define BNX2_MISC_PERR_ENA0_CTX_USAGE_CNT_PERR_EN_XI (1L<<3)
1127#define BNX2_MISC_PERR_ENA0_CTX_PGTBL_PERR_EN_XI (1L<<4)
1128#define BNX2_MISC_PERR_ENA0_CTX_CACHE_PERR_EN_XI (1L<<5)
1129#define BNX2_MISC_PERR_ENA0_CTX_MIRROR_PERR_EN_XI (1L<<6)
1130#define BNX2_MISC_PERR_ENA0_COM_CTXC_PERR_EN_XI (1L<<7)
1131#define BNX2_MISC_PERR_ENA0_COM_SCPAD_PERR_EN_XI (1L<<8)
1132#define BNX2_MISC_PERR_ENA0_CP_CTXC_PERR_EN_XI (1L<<9)
1133#define BNX2_MISC_PERR_ENA0_CP_SCPAD_PERR_EN_XI (1L<<10)
1134#define BNX2_MISC_PERR_ENA0_RXP_RBUFC_PERR_EN_XI (1L<<11)
1135#define BNX2_MISC_PERR_ENA0_RXP_CTXC_PERR_EN_XI (1L<<12)
1136#define BNX2_MISC_PERR_ENA0_RXP_SCPAD_PERR_EN_XI (1L<<13)
1137#define BNX2_MISC_PERR_ENA0_TPAT_SCPAD_PERR_EN_XI (1L<<14)
1138#define BNX2_MISC_PERR_ENA0_TXP_CTXC_PERR_EN_XI (1L<<15)
1139#define BNX2_MISC_PERR_ENA0_TXP_SCPAD_PERR_EN_XI (1L<<16)
1140#define BNX2_MISC_PERR_ENA0_CS_TMEM_PERR_EN_XI (1L<<17)
1141#define BNX2_MISC_PERR_ENA0_MQ_CTX_PERR_EN_XI (1L<<18)
1142#define BNX2_MISC_PERR_ENA0_RPM_DFIFOMEM_PERR_EN_XI (1L<<19)
1143#define BNX2_MISC_PERR_ENA0_RPC_DFIFOMEM_PERR_EN_XI (1L<<20)
1144#define BNX2_MISC_PERR_ENA0_RBUF_PTRMEM_PERR_EN_XI (1L<<21)
1145#define BNX2_MISC_PERR_ENA0_RBUF_DATAMEM_PERR_EN_XI (1L<<22)
1146#define BNX2_MISC_PERR_ENA0_RV2P_P2IRAM_PERR_EN_XI (1L<<23)
1147#define BNX2_MISC_PERR_ENA0_RV2P_P1IRAM_PERR_EN_XI (1L<<24)
1148#define BNX2_MISC_PERR_ENA0_RV2P_CB1REGS_PERR_EN_XI (1L<<25)
1149#define BNX2_MISC_PERR_ENA0_RV2P_CB0REGS_PERR_EN_XI (1L<<26)
1150#define BNX2_MISC_PERR_ENA0_TPBUF_PERR_EN_XI (1L<<27)
1151#define BNX2_MISC_PERR_ENA0_THBUF_PERR_EN_XI (1L<<28)
1152#define BNX2_MISC_PERR_ENA0_TDMA_PERR_EN_XI (1L<<29)
1153#define BNX2_MISC_PERR_ENA0_TBDC_PERR_EN_XI (1L<<30)
1154#define BNX2_MISC_PERR_ENA0_TSCH_LR_PERR_EN_XI (1L<<31)
958 1155
959#define BNX2_MISC_PERR_ENA1 0x000008a8 1156#define BNX2_MISC_PERR_ENA1 0x000008a8
960#define BNX2_MISC_PERR_ENA1_RV2P_MISC_CB1REGS (1L<<0) 1157#define BNX2_MISC_PERR_ENA1_RV2P_MISC_CB1REGS (1L<<0)
@@ -989,6 +1186,35 @@ struct l2_fhdr {
989#define BNX2_MISC_PERR_ENA1_RXPQ_MISC (1L<<29) 1186#define BNX2_MISC_PERR_ENA1_RXPQ_MISC (1L<<29)
990#define BNX2_MISC_PERR_ENA1_RXPCQ_MISC (1L<<30) 1187#define BNX2_MISC_PERR_ENA1_RXPCQ_MISC (1L<<30)
991#define BNX2_MISC_PERR_ENA1_RLUPQ_MISC (1L<<31) 1188#define BNX2_MISC_PERR_ENA1_RLUPQ_MISC (1L<<31)
1189#define BNX2_MISC_PERR_ENA1_RBDC_PERR_EN_XI (1L<<0)
1190#define BNX2_MISC_PERR_ENA1_RDMA_DFIFO_PERR_EN_XI (1L<<2)
1191#define BNX2_MISC_PERR_ENA1_HC_STATS_PERR_EN_XI (1L<<3)
1192#define BNX2_MISC_PERR_ENA1_HC_MSIX_PERR_EN_XI (1L<<4)
1193#define BNX2_MISC_PERR_ENA1_HC_PRODUCSTB_PERR_EN_XI (1L<<5)
1194#define BNX2_MISC_PERR_ENA1_HC_CONSUMSTB_PERR_EN_XI (1L<<6)
1195#define BNX2_MISC_PERR_ENA1_TPATQ_PERR_EN_XI (1L<<7)
1196#define BNX2_MISC_PERR_ENA1_MCPQ_PERR_EN_XI (1L<<8)
1197#define BNX2_MISC_PERR_ENA1_TDMAQ_PERR_EN_XI (1L<<9)
1198#define BNX2_MISC_PERR_ENA1_TXPQ_PERR_EN_XI (1L<<10)
1199#define BNX2_MISC_PERR_ENA1_COMTQ_PERR_EN_XI (1L<<11)
1200#define BNX2_MISC_PERR_ENA1_COMQ_PERR_EN_XI (1L<<12)
1201#define BNX2_MISC_PERR_ENA1_RLUPQ_PERR_EN_XI (1L<<13)
1202#define BNX2_MISC_PERR_ENA1_RXPQ_PERR_EN_XI (1L<<14)
1203#define BNX2_MISC_PERR_ENA1_RV2PPQ_PERR_EN_XI (1L<<15)
1204#define BNX2_MISC_PERR_ENA1_RDMAQ_PERR_EN_XI (1L<<16)
1205#define BNX2_MISC_PERR_ENA1_TASQ_PERR_EN_XI (1L<<17)
1206#define BNX2_MISC_PERR_ENA1_TBDRQ_PERR_EN_XI (1L<<18)
1207#define BNX2_MISC_PERR_ENA1_TSCHQ_PERR_EN_XI (1L<<19)
1208#define BNX2_MISC_PERR_ENA1_COMXQ_PERR_EN_XI (1L<<20)
1209#define BNX2_MISC_PERR_ENA1_RXPCQ_PERR_EN_XI (1L<<21)
1210#define BNX2_MISC_PERR_ENA1_RV2PTQ_PERR_EN_XI (1L<<22)
1211#define BNX2_MISC_PERR_ENA1_RV2PMQ_PERR_EN_XI (1L<<23)
1212#define BNX2_MISC_PERR_ENA1_CPQ_PERR_EN_XI (1L<<24)
1213#define BNX2_MISC_PERR_ENA1_CSQ_PERR_EN_XI (1L<<25)
1214#define BNX2_MISC_PERR_ENA1_RLUP_CID_PERR_EN_XI (1L<<26)
1215#define BNX2_MISC_PERR_ENA1_RV2PCS_TMEM_PERR_EN_XI (1L<<27)
1216#define BNX2_MISC_PERR_ENA1_RV2PCSQ_PERR_EN_XI (1L<<28)
1217#define BNX2_MISC_PERR_ENA1_MQ_IDX_PERR_EN_XI (1L<<29)
992 1218
993#define BNX2_MISC_PERR_ENA2 0x000008ac 1219#define BNX2_MISC_PERR_ENA2 0x000008ac
994#define BNX2_MISC_PERR_ENA2_COMQ_MISC (1L<<0) 1220#define BNX2_MISC_PERR_ENA2_COMQ_MISC (1L<<0)
@@ -1000,19 +1226,498 @@ struct l2_fhdr {
1000#define BNX2_MISC_PERR_ENA2_TDMAQ_MISC (1L<<6) 1226#define BNX2_MISC_PERR_ENA2_TDMAQ_MISC (1L<<6)
1001#define BNX2_MISC_PERR_ENA2_TPATQ_MISC (1L<<7) 1227#define BNX2_MISC_PERR_ENA2_TPATQ_MISC (1L<<7)
1002#define BNX2_MISC_PERR_ENA2_TASQ_MISC (1L<<8) 1228#define BNX2_MISC_PERR_ENA2_TASQ_MISC (1L<<8)
1229#define BNX2_MISC_PERR_ENA2_TGT_FIFO_PERR_EN_XI (1L<<0)
1230#define BNX2_MISC_PERR_ENA2_UMP_TX_PERR_EN_XI (1L<<1)
1231#define BNX2_MISC_PERR_ENA2_UMP_RX_PERR_EN_XI (1L<<2)
1232#define BNX2_MISC_PERR_ENA2_MCP_ROM_PERR_EN_XI (1L<<3)
1233#define BNX2_MISC_PERR_ENA2_MCP_SCPAD_PERR_EN_XI (1L<<4)
1234#define BNX2_MISC_PERR_ENA2_HB_MEM_PERR_EN_XI (1L<<5)
1235#define BNX2_MISC_PERR_ENA2_PCIE_REPLAY_PERR_EN_XI (1L<<6)
1003 1236
1004#define BNX2_MISC_DEBUG_VECTOR_SEL 0x000008b0 1237#define BNX2_MISC_DEBUG_VECTOR_SEL 0x000008b0
1005#define BNX2_MISC_DEBUG_VECTOR_SEL_0 (0xfffL<<0) 1238#define BNX2_MISC_DEBUG_VECTOR_SEL_0 (0xfffL<<0)
1006#define BNX2_MISC_DEBUG_VECTOR_SEL_1 (0xfffL<<12) 1239#define BNX2_MISC_DEBUG_VECTOR_SEL_1 (0xfffL<<12)
1240#define BNX2_MISC_DEBUG_VECTOR_SEL_1_XI (0xfffL<<15)
1007 1241
1008#define BNX2_MISC_VREG_CONTROL 0x000008b4 1242#define BNX2_MISC_VREG_CONTROL 0x000008b4
1009#define BNX2_MISC_VREG_CONTROL_1_2 (0xfL<<0) 1243#define BNX2_MISC_VREG_CONTROL_1_2 (0xfL<<0)
1244#define BNX2_MISC_VREG_CONTROL_1_0_MAIN_XI (0xfL<<0)
1245#define BNX2_MISC_VREG_CONTROL_1_0_MAIN_PLUS14_XI (0L<<0)
1246#define BNX2_MISC_VREG_CONTROL_1_0_MAIN_PLUS12_XI (1L<<0)
1247#define BNX2_MISC_VREG_CONTROL_1_0_MAIN_PLUS10_XI (2L<<0)
1248#define BNX2_MISC_VREG_CONTROL_1_0_MAIN_PLUS8_XI (3L<<0)
1249#define BNX2_MISC_VREG_CONTROL_1_0_MAIN_PLUS6_XI (4L<<0)
1250#define BNX2_MISC_VREG_CONTROL_1_0_MAIN_PLUS4_XI (5L<<0)
1251#define BNX2_MISC_VREG_CONTROL_1_0_MAIN_PLUS2_XI (6L<<0)
1252#define BNX2_MISC_VREG_CONTROL_1_0_MAIN_NOM_XI (7L<<0)
1253#define BNX2_MISC_VREG_CONTROL_1_0_MAIN_MINUS2_XI (8L<<0)
1254#define BNX2_MISC_VREG_CONTROL_1_0_MAIN_MINUS4_XI (9L<<0)
1255#define BNX2_MISC_VREG_CONTROL_1_0_MAIN_MINUS6_XI (10L<<0)
1256#define BNX2_MISC_VREG_CONTROL_1_0_MAIN_MINUS8_XI (11L<<0)
1257#define BNX2_MISC_VREG_CONTROL_1_0_MAIN_MINUS10_XI (12L<<0)
1258#define BNX2_MISC_VREG_CONTROL_1_0_MAIN_MINUS12_XI (13L<<0)
1259#define BNX2_MISC_VREG_CONTROL_1_0_MAIN_MINUS14_XI (14L<<0)
1260#define BNX2_MISC_VREG_CONTROL_1_0_MAIN_MINUS16_XI (15L<<0)
1010#define BNX2_MISC_VREG_CONTROL_2_5 (0xfL<<4) 1261#define BNX2_MISC_VREG_CONTROL_2_5 (0xfL<<4)
1262#define BNX2_MISC_VREG_CONTROL_2_5_PLUS14 (0L<<4)
1263#define BNX2_MISC_VREG_CONTROL_2_5_PLUS12 (1L<<4)
1264#define BNX2_MISC_VREG_CONTROL_2_5_PLUS10 (2L<<4)
1265#define BNX2_MISC_VREG_CONTROL_2_5_PLUS8 (3L<<4)
1266#define BNX2_MISC_VREG_CONTROL_2_5_PLUS6 (4L<<4)
1267#define BNX2_MISC_VREG_CONTROL_2_5_PLUS4 (5L<<4)
1268#define BNX2_MISC_VREG_CONTROL_2_5_PLUS2 (6L<<4)
1269#define BNX2_MISC_VREG_CONTROL_2_5_NOM (7L<<4)
1270#define BNX2_MISC_VREG_CONTROL_2_5_MINUS2 (8L<<4)
1271#define BNX2_MISC_VREG_CONTROL_2_5_MINUS4 (9L<<4)
1272#define BNX2_MISC_VREG_CONTROL_2_5_MINUS6 (10L<<4)
1273#define BNX2_MISC_VREG_CONTROL_2_5_MINUS8 (11L<<4)
1274#define BNX2_MISC_VREG_CONTROL_2_5_MINUS10 (12L<<4)
1275#define BNX2_MISC_VREG_CONTROL_2_5_MINUS12 (13L<<4)
1276#define BNX2_MISC_VREG_CONTROL_2_5_MINUS14 (14L<<4)
1277#define BNX2_MISC_VREG_CONTROL_2_5_MINUS16 (15L<<4)
1278#define BNX2_MISC_VREG_CONTROL_1_0_MGMT (0xfL<<8)
1279#define BNX2_MISC_VREG_CONTROL_1_0_MGMT_PLUS14 (0L<<8)
1280#define BNX2_MISC_VREG_CONTROL_1_0_MGMT_PLUS12 (1L<<8)
1281#define BNX2_MISC_VREG_CONTROL_1_0_MGMT_PLUS10 (2L<<8)
1282#define BNX2_MISC_VREG_CONTROL_1_0_MGMT_PLUS8 (3L<<8)
1283#define BNX2_MISC_VREG_CONTROL_1_0_MGMT_PLUS6 (4L<<8)
1284#define BNX2_MISC_VREG_CONTROL_1_0_MGMT_PLUS4 (5L<<8)
1285#define BNX2_MISC_VREG_CONTROL_1_0_MGMT_PLUS2 (6L<<8)
1286#define BNX2_MISC_VREG_CONTROL_1_0_MGMT_NOM (7L<<8)
1287#define BNX2_MISC_VREG_CONTROL_1_0_MGMT_MINUS2 (8L<<8)
1288#define BNX2_MISC_VREG_CONTROL_1_0_MGMT_MINUS4 (9L<<8)
1289#define BNX2_MISC_VREG_CONTROL_1_0_MGMT_MINUS6 (10L<<8)
1290#define BNX2_MISC_VREG_CONTROL_1_0_MGMT_MINUS8 (11L<<8)
1291#define BNX2_MISC_VREG_CONTROL_1_0_MGMT_MINUS10 (12L<<8)
1292#define BNX2_MISC_VREG_CONTROL_1_0_MGMT_MINUS12 (13L<<8)
1293#define BNX2_MISC_VREG_CONTROL_1_0_MGMT_MINUS14 (14L<<8)
1294#define BNX2_MISC_VREG_CONTROL_1_0_MGMT_MINUS16 (15L<<8)
1011 1295
1012#define BNX2_MISC_FINAL_CLK_CTL_VAL 0x000008b8 1296#define BNX2_MISC_FINAL_CLK_CTL_VAL 0x000008b8
1013#define BNX2_MISC_FINAL_CLK_CTL_VAL_MISC_FINAL_CLK_CTL_VAL (0x3ffffffL<<6) 1297#define BNX2_MISC_FINAL_CLK_CTL_VAL_MISC_FINAL_CLK_CTL_VAL (0x3ffffffL<<6)
1014 1298
1015#define BNX2_MISC_UNUSED0 0x000008bc 1299#define BNX2_MISC_GP_HW_CTL0 0x000008bc
1300#define BNX2_MISC_GP_HW_CTL0_TX_DRIVE (1L<<0)
1301#define BNX2_MISC_GP_HW_CTL0_RMII_MODE (1L<<1)
1302#define BNX2_MISC_GP_HW_CTL0_RMII_CRSDV_SEL (1L<<2)
1303#define BNX2_MISC_GP_HW_CTL0_RVMII_MODE (1L<<3)
1304#define BNX2_MISC_GP_HW_CTL0_FLASH_SAMP_SCLK_NEGEDGE_TE (1L<<4)
1305#define BNX2_MISC_GP_HW_CTL0_HIDDEN_REVISION_ID_TE (1L<<5)
1306#define BNX2_MISC_GP_HW_CTL0_HC_CNTL_TMOUT_CTR_RST_TE (1L<<6)
1307#define BNX2_MISC_GP_HW_CTL0_RESERVED1_XI (0x7L<<4)
1308#define BNX2_MISC_GP_HW_CTL0_ENA_CORE_RST_ON_MAIN_PWR_GOING_AWAY (1L<<7)
1309#define BNX2_MISC_GP_HW_CTL0_ENA_SEL_VAUX_B_IN_L2_TE (1L<<8)
1310#define BNX2_MISC_GP_HW_CTL0_GRC_BNK_FREE_FIX_TE (1L<<9)
1311#define BNX2_MISC_GP_HW_CTL0_LED_ACT_SEL_TE (1L<<10)
1312#define BNX2_MISC_GP_HW_CTL0_RESERVED2_XI (0x7L<<8)
1313#define BNX2_MISC_GP_HW_CTL0_UP1_DEF0 (1L<<11)
1314#define BNX2_MISC_GP_HW_CTL0_FIBER_MODE_DIS_DEF (1L<<12)
1315#define BNX2_MISC_GP_HW_CTL0_FORCE2500_DEF (1L<<13)
1316#define BNX2_MISC_GP_HW_CTL0_AUTODETECT_DIS_DEF (1L<<14)
1317#define BNX2_MISC_GP_HW_CTL0_PARALLEL_DETECT_DEF (1L<<15)
1318#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_DAI (0xfL<<16)
1319#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_DAI_3MA (0L<<16)
1320#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_DAI_2P5MA (1L<<16)
1321#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_DAI_2P0MA (3L<<16)
1322#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_DAI_1P5MA (5L<<16)
1323#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_DAI_1P0MA (7L<<16)
1324#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_DAI_PWRDN (15L<<16)
1325#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_PRE2DIS (1L<<20)
1326#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_PRE1DIS (1L<<21)
1327#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_CTAT (0x3L<<22)
1328#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_CTAT_M6P (0L<<22)
1329#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_CTAT_M0P (1L<<22)
1330#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_CTAT_P0P (2L<<22)
1331#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_CTAT_P6P (3L<<22)
1332#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_PTAT (0x3L<<24)
1333#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_PTAT_M6P (0L<<24)
1334#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_PTAT_M0P (1L<<24)
1335#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_PTAT_P0P (2L<<24)
1336#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_PTAT_P6P (3L<<24)
1337#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_IAMP_ADJ (0x3L<<26)
1338#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_IAMP_ADJ_240UA (0L<<26)
1339#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_IAMP_ADJ_160UA (1L<<26)
1340#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_IAMP_ADJ_400UA (2L<<26)
1341#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_IAMP_ADJ_320UA (3L<<26)
1342#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_ICBUF_ADJ (0x3L<<28)
1343#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_ICBUF_ADJ_240UA (0L<<28)
1344#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_ICBUF_ADJ_160UA (1L<<28)
1345#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_ICBUF_ADJ_400UA (2L<<28)
1346#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_ICBUF_ADJ_320UA (3L<<28)
1347#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_XTAL_ADJ (0x3L<<30)
1348#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_XTAL_ADJ_1P57 (0L<<30)
1349#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_XTAL_ADJ_1P45 (1L<<30)
1350#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_XTAL_ADJ_1P62 (2L<<30)
1351#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_XTAL_ADJ_1P66 (3L<<30)
1352
1353#define BNX2_MISC_GP_HW_CTL1 0x000008c0
1354#define BNX2_MISC_GP_HW_CTL1_1_ATTN_BTN_PRSNT_TE (1L<<0)
1355#define BNX2_MISC_GP_HW_CTL1_1_ATTN_IND_PRSNT_TE (1L<<1)
1356#define BNX2_MISC_GP_HW_CTL1_1_PWR_IND_PRSNT_TE (1L<<2)
1357#define BNX2_MISC_GP_HW_CTL1_0_PCIE_LOOPBACK_TE (1L<<3)
1358#define BNX2_MISC_GP_HW_CTL1_RESERVED_SOFT_XI (0xffffL<<0)
1359#define BNX2_MISC_GP_HW_CTL1_RESERVED_HARD_XI (0xffffL<<16)
1360
1361#define BNX2_MISC_NEW_HW_CTL 0x000008c4
1362#define BNX2_MISC_NEW_HW_CTL_MAIN_POR_BYPASS (1L<<0)
1363#define BNX2_MISC_NEW_HW_CTL_RINGOSC_ENABLE (1L<<1)
1364#define BNX2_MISC_NEW_HW_CTL_RINGOSC_SEL0 (1L<<2)
1365#define BNX2_MISC_NEW_HW_CTL_RINGOSC_SEL1 (1L<<3)
1366#define BNX2_MISC_NEW_HW_CTL_RESERVED_SHARED (0xfffL<<4)
1367#define BNX2_MISC_NEW_HW_CTL_RESERVED_SPLIT (0xffffL<<16)
1368
1369#define BNX2_MISC_NEW_CORE_CTL 0x000008c8
1370#define BNX2_MISC_NEW_CORE_CTL_LINK_HOLDOFF_SUCCESS (1L<<0)
1371#define BNX2_MISC_NEW_CORE_CTL_LINK_HOLDOFF_REQ (1L<<1)
1372#define BNX2_MISC_NEW_CORE_CTL_RESERVED_CMN (0x3fffL<<2)
1373#define BNX2_MISC_NEW_CORE_CTL_RESERVED_TC (0xffffL<<16)
1374
1375#define BNX2_MISC_ECO_HW_CTL 0x000008cc
1376#define BNX2_MISC_ECO_HW_CTL_LARGE_GRC_TMOUT_EN (1L<<0)
1377#define BNX2_MISC_ECO_HW_CTL_RESERVED_SOFT (0x7fffL<<1)
1378#define BNX2_MISC_ECO_HW_CTL_RESERVED_HARD (0xffffL<<16)
1379
1380#define BNX2_MISC_ECO_CORE_CTL 0x000008d0
1381#define BNX2_MISC_ECO_CORE_CTL_RESERVED_SOFT (0xffffL<<0)
1382#define BNX2_MISC_ECO_CORE_CTL_RESERVED_HARD (0xffffL<<16)
1383
1384#define BNX2_MISC_PPIO 0x000008d4
1385#define BNX2_MISC_PPIO_VALUE (0xfL<<0)
1386#define BNX2_MISC_PPIO_SET (0xfL<<8)
1387#define BNX2_MISC_PPIO_CLR (0xfL<<16)
1388#define BNX2_MISC_PPIO_FLOAT (0xfL<<24)
1389
1390#define BNX2_MISC_PPIO_INT 0x000008d8
1391#define BNX2_MISC_PPIO_INT_INT_STATE (0xfL<<0)
1392#define BNX2_MISC_PPIO_INT_OLD_VALUE (0xfL<<8)
1393#define BNX2_MISC_PPIO_INT_OLD_SET (0xfL<<16)
1394#define BNX2_MISC_PPIO_INT_OLD_CLR (0xfL<<24)
1395
1396#define BNX2_MISC_RESET_NUMS 0x000008dc
1397#define BNX2_MISC_RESET_NUMS_NUM_HARD_RESETS (0x7L<<0)
1398#define BNX2_MISC_RESET_NUMS_NUM_PCIE_RESETS (0x7L<<4)
1399#define BNX2_MISC_RESET_NUMS_NUM_PERSTB_RESETS (0x7L<<8)
1400#define BNX2_MISC_RESET_NUMS_NUM_CMN_RESETS (0x7L<<12)
1401#define BNX2_MISC_RESET_NUMS_NUM_PORT_RESETS (0x7L<<16)
1402
1403#define BNX2_MISC_CS16_ERR 0x000008e0
1404#define BNX2_MISC_CS16_ERR_ENA_PCI (1L<<0)
1405#define BNX2_MISC_CS16_ERR_ENA_RDMA (1L<<1)
1406#define BNX2_MISC_CS16_ERR_ENA_TDMA (1L<<2)
1407#define BNX2_MISC_CS16_ERR_ENA_EMAC (1L<<3)
1408#define BNX2_MISC_CS16_ERR_ENA_CTX (1L<<4)
1409#define BNX2_MISC_CS16_ERR_ENA_TBDR (1L<<5)
1410#define BNX2_MISC_CS16_ERR_ENA_RBDC (1L<<6)
1411#define BNX2_MISC_CS16_ERR_ENA_COM (1L<<7)
1412#define BNX2_MISC_CS16_ERR_ENA_CP (1L<<8)
1413#define BNX2_MISC_CS16_ERR_STA_PCI (1L<<16)
1414#define BNX2_MISC_CS16_ERR_STA_RDMA (1L<<17)
1415#define BNX2_MISC_CS16_ERR_STA_TDMA (1L<<18)
1416#define BNX2_MISC_CS16_ERR_STA_EMAC (1L<<19)
1417#define BNX2_MISC_CS16_ERR_STA_CTX (1L<<20)
1418#define BNX2_MISC_CS16_ERR_STA_TBDR (1L<<21)
1419#define BNX2_MISC_CS16_ERR_STA_RBDC (1L<<22)
1420#define BNX2_MISC_CS16_ERR_STA_COM (1L<<23)
1421#define BNX2_MISC_CS16_ERR_STA_CP (1L<<24)
1422
1423#define BNX2_MISC_SPIO_EVENT 0x000008e4
1424#define BNX2_MISC_SPIO_EVENT_ENABLE (0xffL<<0)
1425
1426#define BNX2_MISC_PPIO_EVENT 0x000008e8
1427#define BNX2_MISC_PPIO_EVENT_ENABLE (0xfL<<0)
1428
1429#define BNX2_MISC_DUAL_MEDIA_CTRL 0x000008ec
1430#define BNX2_MISC_DUAL_MEDIA_CTRL_BOND_ID (0xffL<<0)
1431#define BNX2_MISC_DUAL_MEDIA_CTRL_BOND_ID_X (0L<<0)
1432#define BNX2_MISC_DUAL_MEDIA_CTRL_BOND_ID_C (3L<<0)
1433#define BNX2_MISC_DUAL_MEDIA_CTRL_BOND_ID_S (12L<<0)
1434#define BNX2_MISC_DUAL_MEDIA_CTRL_PHY_CTRL_STRAP (0x7L<<8)
1435#define BNX2_MISC_DUAL_MEDIA_CTRL_PORT_SWAP_PIN (1L<<11)
1436#define BNX2_MISC_DUAL_MEDIA_CTRL_SERDES1_SIGDET (1L<<12)
1437#define BNX2_MISC_DUAL_MEDIA_CTRL_SERDES0_SIGDET (1L<<13)
1438#define BNX2_MISC_DUAL_MEDIA_CTRL_PHY1_SIGDET (1L<<14)
1439#define BNX2_MISC_DUAL_MEDIA_CTRL_PHY0_SIGDET (1L<<15)
1440#define BNX2_MISC_DUAL_MEDIA_CTRL_LCPLL_RST (1L<<16)
1441#define BNX2_MISC_DUAL_MEDIA_CTRL_SERDES1_RST (1L<<17)
1442#define BNX2_MISC_DUAL_MEDIA_CTRL_SERDES0_RST (1L<<18)
1443#define BNX2_MISC_DUAL_MEDIA_CTRL_PHY1_RST (1L<<19)
1444#define BNX2_MISC_DUAL_MEDIA_CTRL_PHY0_RST (1L<<20)
1445#define BNX2_MISC_DUAL_MEDIA_CTRL_PHY_CTRL (0x7L<<21)
1446#define BNX2_MISC_DUAL_MEDIA_CTRL_PORT_SWAP (1L<<24)
1447#define BNX2_MISC_DUAL_MEDIA_CTRL_STRAP_OVERRIDE (1L<<25)
1448#define BNX2_MISC_DUAL_MEDIA_CTRL_PHY_SERDES_IDDQ (0xfL<<26)
1449#define BNX2_MISC_DUAL_MEDIA_CTRL_PHY_SERDES_IDDQ_SER1_IDDQ (1L<<26)
1450#define BNX2_MISC_DUAL_MEDIA_CTRL_PHY_SERDES_IDDQ_SER0_IDDQ (2L<<26)
1451#define BNX2_MISC_DUAL_MEDIA_CTRL_PHY_SERDES_IDDQ_PHY1_IDDQ (4L<<26)
1452#define BNX2_MISC_DUAL_MEDIA_CTRL_PHY_SERDES_IDDQ_PHY0_IDDQ (8L<<26)
1453
1454#define BNX2_MISC_OTP_CMD1 0x000008f0
1455#define BNX2_MISC_OTP_CMD1_FMODE (0x7L<<0)
1456#define BNX2_MISC_OTP_CMD1_FMODE_IDLE (0L<<0)
1457#define BNX2_MISC_OTP_CMD1_FMODE_WRITE (1L<<0)
1458#define BNX2_MISC_OTP_CMD1_FMODE_INIT (2L<<0)
1459#define BNX2_MISC_OTP_CMD1_FMODE_SET (3L<<0)
1460#define BNX2_MISC_OTP_CMD1_FMODE_RST (4L<<0)
1461#define BNX2_MISC_OTP_CMD1_FMODE_VERIFY (5L<<0)
1462#define BNX2_MISC_OTP_CMD1_FMODE_RESERVED0 (6L<<0)
1463#define BNX2_MISC_OTP_CMD1_FMODE_RESERVED1 (7L<<0)
1464#define BNX2_MISC_OTP_CMD1_USEPINS (1L<<8)
1465#define BNX2_MISC_OTP_CMD1_PROGSEL (1L<<9)
1466#define BNX2_MISC_OTP_CMD1_PROGSTART (1L<<10)
1467#define BNX2_MISC_OTP_CMD1_PCOUNT (0x7L<<16)
1468#define BNX2_MISC_OTP_CMD1_PBYP (1L<<19)
1469#define BNX2_MISC_OTP_CMD1_VSEL (0xfL<<20)
1470#define BNX2_MISC_OTP_CMD1_TM (0x7L<<27)
1471#define BNX2_MISC_OTP_CMD1_SADBYP (1L<<30)
1472#define BNX2_MISC_OTP_CMD1_DEBUG (1L<<31)
1473
1474#define BNX2_MISC_OTP_CMD2 0x000008f4
1475#define BNX2_MISC_OTP_CMD2_OTP_ROM_ADDR (0x3ffL<<0)
1476#define BNX2_MISC_OTP_CMD2_DOSEL (0x7fL<<16)
1477#define BNX2_MISC_OTP_CMD2_DOSEL_0 (0L<<16)
1478#define BNX2_MISC_OTP_CMD2_DOSEL_1 (1L<<16)
1479#define BNX2_MISC_OTP_CMD2_DOSEL_127 (127L<<16)
1480
1481#define BNX2_MISC_OTP_STATUS 0x000008f8
1482#define BNX2_MISC_OTP_STATUS_DATA (0xffL<<0)
1483#define BNX2_MISC_OTP_STATUS_VALID (1L<<8)
1484#define BNX2_MISC_OTP_STATUS_BUSY (1L<<9)
1485#define BNX2_MISC_OTP_STATUS_BUSYSM (1L<<10)
1486#define BNX2_MISC_OTP_STATUS_DONE (1L<<11)
1487
1488#define BNX2_MISC_OTP_SHIFT1_CMD 0x000008fc
1489#define BNX2_MISC_OTP_SHIFT1_CMD_RESET_MODE_N (1L<<0)
1490#define BNX2_MISC_OTP_SHIFT1_CMD_SHIFT_DONE (1L<<1)
1491#define BNX2_MISC_OTP_SHIFT1_CMD_SHIFT_START (1L<<2)
1492#define BNX2_MISC_OTP_SHIFT1_CMD_LOAD_DATA (1L<<3)
1493#define BNX2_MISC_OTP_SHIFT1_CMD_SHIFT_SELECT (0x1fL<<8)
1494
1495#define BNX2_MISC_OTP_SHIFT1_DATA 0x00000900
1496#define BNX2_MISC_OTP_SHIFT2_CMD 0x00000904
1497#define BNX2_MISC_OTP_SHIFT2_CMD_RESET_MODE_N (1L<<0)
1498#define BNX2_MISC_OTP_SHIFT2_CMD_SHIFT_DONE (1L<<1)
1499#define BNX2_MISC_OTP_SHIFT2_CMD_SHIFT_START (1L<<2)
1500#define BNX2_MISC_OTP_SHIFT2_CMD_LOAD_DATA (1L<<3)
1501#define BNX2_MISC_OTP_SHIFT2_CMD_SHIFT_SELECT (0x1fL<<8)
1502
1503#define BNX2_MISC_OTP_SHIFT2_DATA 0x00000908
1504#define BNX2_MISC_BIST_CS0 0x0000090c
1505#define BNX2_MISC_BIST_CS0_MBIST_EN (1L<<0)
1506#define BNX2_MISC_BIST_CS0_BIST_SETUP (0x3L<<1)
1507#define BNX2_MISC_BIST_CS0_MBIST_ASYNC_RESET (1L<<3)
1508#define BNX2_MISC_BIST_CS0_MBIST_DONE (1L<<8)
1509#define BNX2_MISC_BIST_CS0_MBIST_GO (1L<<9)
1510#define BNX2_MISC_BIST_CS0_BIST_OVERRIDE (1L<<31)
1511
1512#define BNX2_MISC_BIST_MEMSTATUS0 0x00000910
1513#define BNX2_MISC_BIST_CS1 0x00000914
1514#define BNX2_MISC_BIST_CS1_MBIST_EN (1L<<0)
1515#define BNX2_MISC_BIST_CS1_BIST_SETUP (0x3L<<1)
1516#define BNX2_MISC_BIST_CS1_MBIST_ASYNC_RESET (1L<<3)
1517#define BNX2_MISC_BIST_CS1_MBIST_DONE (1L<<8)
1518#define BNX2_MISC_BIST_CS1_MBIST_GO (1L<<9)
1519
1520#define BNX2_MISC_BIST_MEMSTATUS1 0x00000918
1521#define BNX2_MISC_BIST_CS2 0x0000091c
1522#define BNX2_MISC_BIST_CS2_MBIST_EN (1L<<0)
1523#define BNX2_MISC_BIST_CS2_BIST_SETUP (0x3L<<1)
1524#define BNX2_MISC_BIST_CS2_MBIST_ASYNC_RESET (1L<<3)
1525#define BNX2_MISC_BIST_CS2_MBIST_DONE (1L<<8)
1526#define BNX2_MISC_BIST_CS2_MBIST_GO (1L<<9)
1527
1528#define BNX2_MISC_BIST_MEMSTATUS2 0x00000920
1529#define BNX2_MISC_BIST_CS3 0x00000924
1530#define BNX2_MISC_BIST_CS3_MBIST_EN (1L<<0)
1531#define BNX2_MISC_BIST_CS3_BIST_SETUP (0x3L<<1)
1532#define BNX2_MISC_BIST_CS3_MBIST_ASYNC_RESET (1L<<3)
1533#define BNX2_MISC_BIST_CS3_MBIST_DONE (1L<<8)
1534#define BNX2_MISC_BIST_CS3_MBIST_GO (1L<<9)
1535
1536#define BNX2_MISC_BIST_MEMSTATUS3 0x00000928
1537#define BNX2_MISC_BIST_CS4 0x0000092c
1538#define BNX2_MISC_BIST_CS4_MBIST_EN (1L<<0)
1539#define BNX2_MISC_BIST_CS4_BIST_SETUP (0x3L<<1)
1540#define BNX2_MISC_BIST_CS4_MBIST_ASYNC_RESET (1L<<3)
1541#define BNX2_MISC_BIST_CS4_MBIST_DONE (1L<<8)
1542#define BNX2_MISC_BIST_CS4_MBIST_GO (1L<<9)
1543
1544#define BNX2_MISC_BIST_MEMSTATUS4 0x00000930
1545#define BNX2_MISC_BIST_CS5 0x00000934
1546#define BNX2_MISC_BIST_CS5_MBIST_EN (1L<<0)
1547#define BNX2_MISC_BIST_CS5_BIST_SETUP (0x3L<<1)
1548#define BNX2_MISC_BIST_CS5_MBIST_ASYNC_RESET (1L<<3)
1549#define BNX2_MISC_BIST_CS5_MBIST_DONE (1L<<8)
1550#define BNX2_MISC_BIST_CS5_MBIST_GO (1L<<9)
1551
1552#define BNX2_MISC_BIST_MEMSTATUS5 0x00000938
1553#define BNX2_MISC_MEM_TM0 0x0000093c
1554#define BNX2_MISC_MEM_TM0_PCIE_REPLAY_TM (0xfL<<0)
1555#define BNX2_MISC_MEM_TM0_MCP_SCPAD (0xfL<<8)
1556#define BNX2_MISC_MEM_TM0_UMP_TM (0xffL<<16)
1557#define BNX2_MISC_MEM_TM0_HB_MEM_TM (0xfL<<24)
1558
1559#define BNX2_MISC_USPLL_CTRL 0x00000940
1560#define BNX2_MISC_USPLL_CTRL_PH_DET_DIS (1L<<0)
1561#define BNX2_MISC_USPLL_CTRL_FREQ_DET_DIS (1L<<1)
1562#define BNX2_MISC_USPLL_CTRL_LCPX (0x3fL<<2)
1563#define BNX2_MISC_USPLL_CTRL_RX (0x3L<<8)
1564#define BNX2_MISC_USPLL_CTRL_VC_EN (1L<<10)
1565#define BNX2_MISC_USPLL_CTRL_VCO_MG (0x3L<<11)
1566#define BNX2_MISC_USPLL_CTRL_KVCO_XF (0x7L<<13)
1567#define BNX2_MISC_USPLL_CTRL_KVCO_XS (0x7L<<16)
1568#define BNX2_MISC_USPLL_CTRL_TESTD_EN (1L<<19)
1569#define BNX2_MISC_USPLL_CTRL_TESTD_SEL (0x7L<<20)
1570#define BNX2_MISC_USPLL_CTRL_TESTA_EN (1L<<23)
1571#define BNX2_MISC_USPLL_CTRL_TESTA_SEL (0x3L<<24)
1572#define BNX2_MISC_USPLL_CTRL_ATTEN_FREF (1L<<26)
1573#define BNX2_MISC_USPLL_CTRL_DIGITAL_RST (1L<<27)
1574#define BNX2_MISC_USPLL_CTRL_ANALOG_RST (1L<<28)
1575#define BNX2_MISC_USPLL_CTRL_LOCK (1L<<29)
1576
1577#define BNX2_MISC_PERR_STATUS0 0x00000944
1578#define BNX2_MISC_PERR_STATUS0_COM_DMAE_PERR (1L<<0)
1579#define BNX2_MISC_PERR_STATUS0_CP_DMAE_PERR (1L<<1)
1580#define BNX2_MISC_PERR_STATUS0_RPM_ACPIBEMEM_PERR (1L<<2)
1581#define BNX2_MISC_PERR_STATUS0_CTX_USAGE_CNT_PERR (1L<<3)
1582#define BNX2_MISC_PERR_STATUS0_CTX_PGTBL_PERR (1L<<4)
1583#define BNX2_MISC_PERR_STATUS0_CTX_CACHE_PERR (1L<<5)
1584#define BNX2_MISC_PERR_STATUS0_CTX_MIRROR_PERR (1L<<6)
1585#define BNX2_MISC_PERR_STATUS0_COM_CTXC_PERR (1L<<7)
1586#define BNX2_MISC_PERR_STATUS0_COM_SCPAD_PERR (1L<<8)
1587#define BNX2_MISC_PERR_STATUS0_CP_CTXC_PERR (1L<<9)
1588#define BNX2_MISC_PERR_STATUS0_CP_SCPAD_PERR (1L<<10)
1589#define BNX2_MISC_PERR_STATUS0_RXP_RBUFC_PERR (1L<<11)
1590#define BNX2_MISC_PERR_STATUS0_RXP_CTXC_PERR (1L<<12)
1591#define BNX2_MISC_PERR_STATUS0_RXP_SCPAD_PERR (1L<<13)
1592#define BNX2_MISC_PERR_STATUS0_TPAT_SCPAD_PERR (1L<<14)
1593#define BNX2_MISC_PERR_STATUS0_TXP_CTXC_PERR (1L<<15)
1594#define BNX2_MISC_PERR_STATUS0_TXP_SCPAD_PERR (1L<<16)
1595#define BNX2_MISC_PERR_STATUS0_CS_TMEM_PERR (1L<<17)
1596#define BNX2_MISC_PERR_STATUS0_MQ_CTX_PERR (1L<<18)
1597#define BNX2_MISC_PERR_STATUS0_RPM_DFIFOMEM_PERR (1L<<19)
1598#define BNX2_MISC_PERR_STATUS0_RPC_DFIFOMEM_PERR (1L<<20)
1599#define BNX2_MISC_PERR_STATUS0_RBUF_PTRMEM_PERR (1L<<21)
1600#define BNX2_MISC_PERR_STATUS0_RBUF_DATAMEM_PERR (1L<<22)
1601#define BNX2_MISC_PERR_STATUS0_RV2P_P2IRAM_PERR (1L<<23)
1602#define BNX2_MISC_PERR_STATUS0_RV2P_P1IRAM_PERR (1L<<24)
1603#define BNX2_MISC_PERR_STATUS0_RV2P_CB1REGS_PERR (1L<<25)
1604#define BNX2_MISC_PERR_STATUS0_RV2P_CB0REGS_PERR (1L<<26)
1605#define BNX2_MISC_PERR_STATUS0_TPBUF_PERR (1L<<27)
1606#define BNX2_MISC_PERR_STATUS0_THBUF_PERR (1L<<28)
1607#define BNX2_MISC_PERR_STATUS0_TDMA_PERR (1L<<29)
1608#define BNX2_MISC_PERR_STATUS0_TBDC_PERR (1L<<30)
1609#define BNX2_MISC_PERR_STATUS0_TSCH_LR_PERR (1L<<31)
1610
1611#define BNX2_MISC_PERR_STATUS1 0x00000948
1612#define BNX2_MISC_PERR_STATUS1_RBDC_PERR (1L<<0)
1613#define BNX2_MISC_PERR_STATUS1_RDMA_DFIFO_PERR (1L<<2)
1614#define BNX2_MISC_PERR_STATUS1_HC_STATS_PERR (1L<<3)
1615#define BNX2_MISC_PERR_STATUS1_HC_MSIX_PERR (1L<<4)
1616#define BNX2_MISC_PERR_STATUS1_HC_PRODUCSTB_PERR (1L<<5)
1617#define BNX2_MISC_PERR_STATUS1_HC_CONSUMSTB_PERR (1L<<6)
1618#define BNX2_MISC_PERR_STATUS1_TPATQ_PERR (1L<<7)
1619#define BNX2_MISC_PERR_STATUS1_MCPQ_PERR (1L<<8)
1620#define BNX2_MISC_PERR_STATUS1_TDMAQ_PERR (1L<<9)
1621#define BNX2_MISC_PERR_STATUS1_TXPQ_PERR (1L<<10)
1622#define BNX2_MISC_PERR_STATUS1_COMTQ_PERR (1L<<11)
1623#define BNX2_MISC_PERR_STATUS1_COMQ_PERR (1L<<12)
1624#define BNX2_MISC_PERR_STATUS1_RLUPQ_PERR (1L<<13)
1625#define BNX2_MISC_PERR_STATUS1_RXPQ_PERR (1L<<14)
1626#define BNX2_MISC_PERR_STATUS1_RV2PPQ_PERR (1L<<15)
1627#define BNX2_MISC_PERR_STATUS1_RDMAQ_PERR (1L<<16)
1628#define BNX2_MISC_PERR_STATUS1_TASQ_PERR (1L<<17)
1629#define BNX2_MISC_PERR_STATUS1_TBDRQ_PERR (1L<<18)
1630#define BNX2_MISC_PERR_STATUS1_TSCHQ_PERR (1L<<19)
1631#define BNX2_MISC_PERR_STATUS1_COMXQ_PERR (1L<<20)
1632#define BNX2_MISC_PERR_STATUS1_RXPCQ_PERR (1L<<21)
1633#define BNX2_MISC_PERR_STATUS1_RV2PTQ_PERR (1L<<22)
1634#define BNX2_MISC_PERR_STATUS1_RV2PMQ_PERR (1L<<23)
1635#define BNX2_MISC_PERR_STATUS1_CPQ_PERR (1L<<24)
1636#define BNX2_MISC_PERR_STATUS1_CSQ_PERR (1L<<25)
1637#define BNX2_MISC_PERR_STATUS1_RLUP_CID_PERR (1L<<26)
1638#define BNX2_MISC_PERR_STATUS1_RV2PCS_TMEM_PERR (1L<<27)
1639#define BNX2_MISC_PERR_STATUS1_RV2PCSQ_PERR (1L<<28)
1640#define BNX2_MISC_PERR_STATUS1_MQ_IDX_PERR (1L<<29)
1641
1642#define BNX2_MISC_PERR_STATUS2 0x0000094c
1643#define BNX2_MISC_PERR_STATUS2_TGT_FIFO_PERR (1L<<0)
1644#define BNX2_MISC_PERR_STATUS2_UMP_TX_PERR (1L<<1)
1645#define BNX2_MISC_PERR_STATUS2_UMP_RX_PERR (1L<<2)
1646#define BNX2_MISC_PERR_STATUS2_MCP_ROM_PERR (1L<<3)
1647#define BNX2_MISC_PERR_STATUS2_MCP_SCPAD_PERR (1L<<4)
1648#define BNX2_MISC_PERR_STATUS2_HB_MEM_PERR (1L<<5)
1649#define BNX2_MISC_PERR_STATUS2_PCIE_REPLAY_PERR (1L<<6)
1650
1651#define BNX2_MISC_LCPLL_CTRL0 0x00000950
1652#define BNX2_MISC_LCPLL_CTRL0_OAC (0x7L<<0)
1653#define BNX2_MISC_LCPLL_CTRL0_OAC_NEGTWENTY (0L<<0)
1654#define BNX2_MISC_LCPLL_CTRL0_OAC_ZERO (1L<<0)
1655#define BNX2_MISC_LCPLL_CTRL0_OAC_TWENTY (3L<<0)
1656#define BNX2_MISC_LCPLL_CTRL0_OAC_FORTY (7L<<0)
1657#define BNX2_MISC_LCPLL_CTRL0_ICP_CTRL (0x7L<<3)
1658#define BNX2_MISC_LCPLL_CTRL0_ICP_CTRL_360 (0L<<3)
1659#define BNX2_MISC_LCPLL_CTRL0_ICP_CTRL_480 (1L<<3)
1660#define BNX2_MISC_LCPLL_CTRL0_ICP_CTRL_600 (3L<<3)
1661#define BNX2_MISC_LCPLL_CTRL0_ICP_CTRL_720 (7L<<3)
1662#define BNX2_MISC_LCPLL_CTRL0_BIAS_CTRL (0x3L<<6)
1663#define BNX2_MISC_LCPLL_CTRL0_PLL_OBSERVE (0x7L<<8)
1664#define BNX2_MISC_LCPLL_CTRL0_VTH_CTRL (0x3L<<11)
1665#define BNX2_MISC_LCPLL_CTRL0_VTH_CTRL_0 (0L<<11)
1666#define BNX2_MISC_LCPLL_CTRL0_VTH_CTRL_1 (1L<<11)
1667#define BNX2_MISC_LCPLL_CTRL0_VTH_CTRL_2 (2L<<11)
1668#define BNX2_MISC_LCPLL_CTRL0_PLLSEQSTART (1L<<13)
1669#define BNX2_MISC_LCPLL_CTRL0_RESERVED (1L<<14)
1670#define BNX2_MISC_LCPLL_CTRL0_CAPRETRY_EN (1L<<15)
1671#define BNX2_MISC_LCPLL_CTRL0_FREQMONITOR_EN (1L<<16)
1672#define BNX2_MISC_LCPLL_CTRL0_FREQDETRESTART_EN (1L<<17)
1673#define BNX2_MISC_LCPLL_CTRL0_FREQDETRETRY_EN (1L<<18)
1674#define BNX2_MISC_LCPLL_CTRL0_PLLFORCEFDONE_EN (1L<<19)
1675#define BNX2_MISC_LCPLL_CTRL0_PLLFORCEFDONE (1L<<20)
1676#define BNX2_MISC_LCPLL_CTRL0_PLLFORCEFPASS (1L<<21)
1677#define BNX2_MISC_LCPLL_CTRL0_PLLFORCECAPDONE_EN (1L<<22)
1678#define BNX2_MISC_LCPLL_CTRL0_PLLFORCECAPDONE (1L<<23)
1679#define BNX2_MISC_LCPLL_CTRL0_PLLFORCECAPPASS_EN (1L<<24)
1680#define BNX2_MISC_LCPLL_CTRL0_PLLFORCECAPPASS (1L<<25)
1681#define BNX2_MISC_LCPLL_CTRL0_CAPRESTART (1L<<26)
1682#define BNX2_MISC_LCPLL_CTRL0_CAPSELECTM_EN (1L<<27)
1683
1684#define BNX2_MISC_LCPLL_CTRL1 0x00000954
1685#define BNX2_MISC_LCPLL_CTRL1_CAPSELECTM (0x1fL<<0)
1686#define BNX2_MISC_LCPLL_CTRL1_CAPFORCESLOWDOWN_EN (1L<<5)
1687#define BNX2_MISC_LCPLL_CTRL1_CAPFORCESLOWDOWN (1L<<6)
1688#define BNX2_MISC_LCPLL_CTRL1_SLOWDN_XOR (1L<<7)
1689
1690#define BNX2_MISC_LCPLL_STATUS 0x00000958
1691#define BNX2_MISC_LCPLL_STATUS_FREQDONE_SM (1L<<0)
1692#define BNX2_MISC_LCPLL_STATUS_FREQPASS_SM (1L<<1)
1693#define BNX2_MISC_LCPLL_STATUS_PLLSEQDONE (1L<<2)
1694#define BNX2_MISC_LCPLL_STATUS_PLLSEQPASS (1L<<3)
1695#define BNX2_MISC_LCPLL_STATUS_PLLSTATE (0x7L<<4)
1696#define BNX2_MISC_LCPLL_STATUS_CAPSTATE (0x7L<<7)
1697#define BNX2_MISC_LCPLL_STATUS_CAPSELECT (0x1fL<<10)
1698#define BNX2_MISC_LCPLL_STATUS_SLOWDN_INDICATOR (1L<<15)
1699#define BNX2_MISC_LCPLL_STATUS_SLOWDN_INDICATOR_0 (0L<<15)
1700#define BNX2_MISC_LCPLL_STATUS_SLOWDN_INDICATOR_1 (1L<<15)
1701
1702#define BNX2_MISC_OSCFUNDS_CTRL 0x0000095c
1703#define BNX2_MISC_OSCFUNDS_CTRL_FREQ_MON (1L<<5)
1704#define BNX2_MISC_OSCFUNDS_CTRL_FREQ_MON_OFF (0L<<5)
1705#define BNX2_MISC_OSCFUNDS_CTRL_FREQ_MON_ON (1L<<5)
1706#define BNX2_MISC_OSCFUNDS_CTRL_XTAL_ADJCM (0x3L<<6)
1707#define BNX2_MISC_OSCFUNDS_CTRL_XTAL_ADJCM_0 (0L<<6)
1708#define BNX2_MISC_OSCFUNDS_CTRL_XTAL_ADJCM_1 (1L<<6)
1709#define BNX2_MISC_OSCFUNDS_CTRL_XTAL_ADJCM_2 (2L<<6)
1710#define BNX2_MISC_OSCFUNDS_CTRL_XTAL_ADJCM_3 (3L<<6)
1711#define BNX2_MISC_OSCFUNDS_CTRL_ICBUF_ADJ (0x3L<<8)
1712#define BNX2_MISC_OSCFUNDS_CTRL_ICBUF_ADJ_0 (0L<<8)
1713#define BNX2_MISC_OSCFUNDS_CTRL_ICBUF_ADJ_1 (1L<<8)
1714#define BNX2_MISC_OSCFUNDS_CTRL_ICBUF_ADJ_2 (2L<<8)
1715#define BNX2_MISC_OSCFUNDS_CTRL_ICBUF_ADJ_3 (3L<<8)
1716#define BNX2_MISC_OSCFUNDS_CTRL_IAMP_ADJ (0x3L<<10)
1717#define BNX2_MISC_OSCFUNDS_CTRL_IAMP_ADJ_0 (0L<<10)
1718#define BNX2_MISC_OSCFUNDS_CTRL_IAMP_ADJ_1 (1L<<10)
1719#define BNX2_MISC_OSCFUNDS_CTRL_IAMP_ADJ_2 (2L<<10)
1720#define BNX2_MISC_OSCFUNDS_CTRL_IAMP_ADJ_3 (3L<<10)
1016 1721
1017 1722
1018/* 1723/*
@@ -1031,11 +1736,35 @@ struct l2_fhdr {
1031#define BNX2_NVM_COMMAND_WRDI (1L<<17) 1736#define BNX2_NVM_COMMAND_WRDI (1L<<17)
1032#define BNX2_NVM_COMMAND_EWSR (1L<<18) 1737#define BNX2_NVM_COMMAND_EWSR (1L<<18)
1033#define BNX2_NVM_COMMAND_WRSR (1L<<19) 1738#define BNX2_NVM_COMMAND_WRSR (1L<<19)
1739#define BNX2_NVM_COMMAND_RD_ID (1L<<20)
1740#define BNX2_NVM_COMMAND_RD_STATUS (1L<<21)
1741#define BNX2_NVM_COMMAND_MODE_256 (1L<<22)
1034 1742
1035#define BNX2_NVM_STATUS 0x00006404 1743#define BNX2_NVM_STATUS 0x00006404
1036#define BNX2_NVM_STATUS_PI_FSM_STATE (0xfL<<0) 1744#define BNX2_NVM_STATUS_PI_FSM_STATE (0xfL<<0)
1037#define BNX2_NVM_STATUS_EE_FSM_STATE (0xfL<<4) 1745#define BNX2_NVM_STATUS_EE_FSM_STATE (0xfL<<4)
1038#define BNX2_NVM_STATUS_EQ_FSM_STATE (0xfL<<8) 1746#define BNX2_NVM_STATUS_EQ_FSM_STATE (0xfL<<8)
1747#define BNX2_NVM_STATUS_SPI_FSM_STATE_XI (0x1fL<<0)
1748#define BNX2_NVM_STATUS_SPI_FSM_STATE_SPI_IDLE_XI (0L<<0)
1749#define BNX2_NVM_STATUS_SPI_FSM_STATE_SPI_CMD0_XI (1L<<0)
1750#define BNX2_NVM_STATUS_SPI_FSM_STATE_SPI_CMD1_XI (2L<<0)
1751#define BNX2_NVM_STATUS_SPI_FSM_STATE_SPI_CMD_FINISH0_XI (3L<<0)
1752#define BNX2_NVM_STATUS_SPI_FSM_STATE_SPI_CMD_FINISH1_XI (4L<<0)
1753#define BNX2_NVM_STATUS_SPI_FSM_STATE_SPI_ADDR0_XI (5L<<0)
1754#define BNX2_NVM_STATUS_SPI_FSM_STATE_SPI_WRITE_DATA0_XI (6L<<0)
1755#define BNX2_NVM_STATUS_SPI_FSM_STATE_SPI_WRITE_DATA1_XI (7L<<0)
1756#define BNX2_NVM_STATUS_SPI_FSM_STATE_SPI_WRITE_DATA2_XI (8L<<0)
1757#define BNX2_NVM_STATUS_SPI_FSM_STATE_SPI_READ_DATA0_XI (9L<<0)
1758#define BNX2_NVM_STATUS_SPI_FSM_STATE_SPI_READ_DATA1_XI (10L<<0)
1759#define BNX2_NVM_STATUS_SPI_FSM_STATE_SPI_READ_DATA2_XI (11L<<0)
1760#define BNX2_NVM_STATUS_SPI_FSM_STATE_SPI_READ_STATUS_RDID0_XI (12L<<0)
1761#define BNX2_NVM_STATUS_SPI_FSM_STATE_SPI_READ_STATUS_RDID1_XI (13L<<0)
1762#define BNX2_NVM_STATUS_SPI_FSM_STATE_SPI_READ_STATUS_RDID2_XI (14L<<0)
1763#define BNX2_NVM_STATUS_SPI_FSM_STATE_SPI_READ_STATUS_RDID3_XI (15L<<0)
1764#define BNX2_NVM_STATUS_SPI_FSM_STATE_SPI_READ_STATUS_RDID4_XI (16L<<0)
1765#define BNX2_NVM_STATUS_SPI_FSM_STATE_SPI_CHECK_BUSY0_XI (17L<<0)
1766#define BNX2_NVM_STATUS_SPI_FSM_STATE_SPI_ST_WREN_XI (18L<<0)
1767#define BNX2_NVM_STATUS_SPI_FSM_STATE_SPI_WAIT_XI (19L<<0)
1039 1768
1040#define BNX2_NVM_WRITE 0x00006408 1769#define BNX2_NVM_WRITE 0x00006408
1041#define BNX2_NVM_WRITE_NVM_WRITE_VALUE (0xffffffffL<<0) 1770#define BNX2_NVM_WRITE_NVM_WRITE_VALUE (0xffffffffL<<0)
@@ -1046,6 +1775,10 @@ struct l2_fhdr {
1046#define BNX2_NVM_WRITE_NVM_WRITE_VALUE_CS_B (8L<<0) 1775#define BNX2_NVM_WRITE_NVM_WRITE_VALUE_CS_B (8L<<0)
1047#define BNX2_NVM_WRITE_NVM_WRITE_VALUE_SO (16L<<0) 1776#define BNX2_NVM_WRITE_NVM_WRITE_VALUE_SO (16L<<0)
1048#define BNX2_NVM_WRITE_NVM_WRITE_VALUE_SI (32L<<0) 1777#define BNX2_NVM_WRITE_NVM_WRITE_VALUE_SI (32L<<0)
1778#define BNX2_NVM_WRITE_NVM_WRITE_VALUE_SI_XI (1L<<0)
1779#define BNX2_NVM_WRITE_NVM_WRITE_VALUE_SO_XI (2L<<0)
1780#define BNX2_NVM_WRITE_NVM_WRITE_VALUE_CS_B_XI (4L<<0)
1781#define BNX2_NVM_WRITE_NVM_WRITE_VALUE_SCLK_XI (8L<<0)
1049 1782
1050#define BNX2_NVM_ADDR 0x0000640c 1783#define BNX2_NVM_ADDR 0x0000640c
1051#define BNX2_NVM_ADDR_NVM_ADDR_VALUE (0xffffffL<<0) 1784#define BNX2_NVM_ADDR_NVM_ADDR_VALUE (0xffffffL<<0)
@@ -1056,6 +1789,10 @@ struct l2_fhdr {
1056#define BNX2_NVM_ADDR_NVM_ADDR_VALUE_CS_B (8L<<0) 1789#define BNX2_NVM_ADDR_NVM_ADDR_VALUE_CS_B (8L<<0)
1057#define BNX2_NVM_ADDR_NVM_ADDR_VALUE_SO (16L<<0) 1790#define BNX2_NVM_ADDR_NVM_ADDR_VALUE_SO (16L<<0)
1058#define BNX2_NVM_ADDR_NVM_ADDR_VALUE_SI (32L<<0) 1791#define BNX2_NVM_ADDR_NVM_ADDR_VALUE_SI (32L<<0)
1792#define BNX2_NVM_ADDR_NVM_ADDR_VALUE_SI_XI (1L<<0)
1793#define BNX2_NVM_ADDR_NVM_ADDR_VALUE_SO_XI (2L<<0)
1794#define BNX2_NVM_ADDR_NVM_ADDR_VALUE_CS_B_XI (4L<<0)
1795#define BNX2_NVM_ADDR_NVM_ADDR_VALUE_SCLK_XI (8L<<0)
1059 1796
1060#define BNX2_NVM_READ 0x00006410 1797#define BNX2_NVM_READ 0x00006410
1061#define BNX2_NVM_READ_NVM_READ_VALUE (0xffffffffL<<0) 1798#define BNX2_NVM_READ_NVM_READ_VALUE (0xffffffffL<<0)
@@ -1066,6 +1803,10 @@ struct l2_fhdr {
1066#define BNX2_NVM_READ_NVM_READ_VALUE_CS_B (8L<<0) 1803#define BNX2_NVM_READ_NVM_READ_VALUE_CS_B (8L<<0)
1067#define BNX2_NVM_READ_NVM_READ_VALUE_SO (16L<<0) 1804#define BNX2_NVM_READ_NVM_READ_VALUE_SO (16L<<0)
1068#define BNX2_NVM_READ_NVM_READ_VALUE_SI (32L<<0) 1805#define BNX2_NVM_READ_NVM_READ_VALUE_SI (32L<<0)
1806#define BNX2_NVM_READ_NVM_READ_VALUE_SI_XI (1L<<0)
1807#define BNX2_NVM_READ_NVM_READ_VALUE_SO_XI (2L<<0)
1808#define BNX2_NVM_READ_NVM_READ_VALUE_CS_B_XI (4L<<0)
1809#define BNX2_NVM_READ_NVM_READ_VALUE_SCLK_XI (8L<<0)
1069 1810
1070#define BNX2_NVM_CFG1 0x00006414 1811#define BNX2_NVM_CFG1 0x00006414
1071#define BNX2_NVM_CFG1_FLASH_MODE (1L<<0) 1812#define BNX2_NVM_CFG1_FLASH_MODE (1L<<0)
@@ -1077,14 +1818,21 @@ struct l2_fhdr {
1077#define BNX2_NVM_CFG1_STATUS_BIT_BUFFER_RDY (7L<<4) 1818#define BNX2_NVM_CFG1_STATUS_BIT_BUFFER_RDY (7L<<4)
1078#define BNX2_NVM_CFG1_SPI_CLK_DIV (0xfL<<7) 1819#define BNX2_NVM_CFG1_SPI_CLK_DIV (0xfL<<7)
1079#define BNX2_NVM_CFG1_SEE_CLK_DIV (0x7ffL<<11) 1820#define BNX2_NVM_CFG1_SEE_CLK_DIV (0x7ffL<<11)
1821#define BNX2_NVM_CFG1_STRAP_CONTROL_0 (1L<<23)
1080#define BNX2_NVM_CFG1_PROTECT_MODE (1L<<24) 1822#define BNX2_NVM_CFG1_PROTECT_MODE (1L<<24)
1081#define BNX2_NVM_CFG1_FLASH_SIZE (1L<<25) 1823#define BNX2_NVM_CFG1_FLASH_SIZE (1L<<25)
1824#define BNX2_NVM_CFG1_FW_USTRAP_1 (1L<<26)
1825#define BNX2_NVM_CFG1_FW_USTRAP_0 (1L<<27)
1826#define BNX2_NVM_CFG1_FW_USTRAP_2 (1L<<28)
1827#define BNX2_NVM_CFG1_FW_USTRAP_3 (1L<<29)
1828#define BNX2_NVM_CFG1_FW_FLASH_TYPE_EN (1L<<30)
1082#define BNX2_NVM_CFG1_COMPAT_BYPASSS (1L<<31) 1829#define BNX2_NVM_CFG1_COMPAT_BYPASSS (1L<<31)
1083 1830
1084#define BNX2_NVM_CFG2 0x00006418 1831#define BNX2_NVM_CFG2 0x00006418
1085#define BNX2_NVM_CFG2_ERASE_CMD (0xffL<<0) 1832#define BNX2_NVM_CFG2_ERASE_CMD (0xffL<<0)
1086#define BNX2_NVM_CFG2_DUMMY (0xffL<<8) 1833#define BNX2_NVM_CFG2_DUMMY (0xffL<<8)
1087#define BNX2_NVM_CFG2_STATUS_CMD (0xffL<<16) 1834#define BNX2_NVM_CFG2_STATUS_CMD (0xffL<<16)
1835#define BNX2_NVM_CFG2_READ_ID (0xffL<<24)
1088 1836
1089#define BNX2_NVM_CFG3 0x0000641c 1837#define BNX2_NVM_CFG3 0x0000641c
1090#define BNX2_NVM_CFG3_BUFFER_RD_CMD (0xffL<<0) 1838#define BNX2_NVM_CFG3_BUFFER_RD_CMD (0xffL<<0)
@@ -1119,6 +1867,35 @@ struct l2_fhdr {
1119#define BNX2_NVM_WRITE1_WRDI_CMD (0xffL<<8) 1867#define BNX2_NVM_WRITE1_WRDI_CMD (0xffL<<8)
1120#define BNX2_NVM_WRITE1_SR_DATA (0xffL<<16) 1868#define BNX2_NVM_WRITE1_SR_DATA (0xffL<<16)
1121 1869
1870#define BNX2_NVM_CFG4 0x0000642c
1871#define BNX2_NVM_CFG4_FLASH_SIZE (0x7L<<0)
1872#define BNX2_NVM_CFG4_FLASH_SIZE_1MBIT (0L<<0)
1873#define BNX2_NVM_CFG4_FLASH_SIZE_2MBIT (1L<<0)
1874#define BNX2_NVM_CFG4_FLASH_SIZE_4MBIT (2L<<0)
1875#define BNX2_NVM_CFG4_FLASH_SIZE_8MBIT (3L<<0)
1876#define BNX2_NVM_CFG4_FLASH_SIZE_16MBIT (4L<<0)
1877#define BNX2_NVM_CFG4_FLASH_SIZE_32MBIT (5L<<0)
1878#define BNX2_NVM_CFG4_FLASH_SIZE_64MBIT (6L<<0)
1879#define BNX2_NVM_CFG4_FLASH_SIZE_128MBIT (7L<<0)
1880#define BNX2_NVM_CFG4_FLASH_VENDOR (1L<<3)
1881#define BNX2_NVM_CFG4_FLASH_VENDOR_ST (0L<<3)
1882#define BNX2_NVM_CFG4_FLASH_VENDOR_ATMEL (1L<<3)
1883#define BNX2_NVM_CFG4_MODE_256_EMPTY_BIT_LOC (0x3L<<4)
1884#define BNX2_NVM_CFG4_MODE_256_EMPTY_BIT_LOC_BIT8 (0L<<4)
1885#define BNX2_NVM_CFG4_MODE_256_EMPTY_BIT_LOC_BIT9 (1L<<4)
1886#define BNX2_NVM_CFG4_MODE_256_EMPTY_BIT_LOC_BIT10 (2L<<4)
1887#define BNX2_NVM_CFG4_MODE_256_EMPTY_BIT_LOC_BIT11 (3L<<4)
1888#define BNX2_NVM_CFG4_STATUS_BIT_POLARITY (1L<<6)
1889#define BNX2_NVM_CFG4_RESERVED (0x1ffffffL<<7)
1890
1891#define BNX2_NVM_RECONFIG 0x00006430
1892#define BNX2_NVM_RECONFIG_ORIG_STRAP_VALUE (0xfL<<0)
1893#define BNX2_NVM_RECONFIG_ORIG_STRAP_VALUE_ST (0L<<0)
1894#define BNX2_NVM_RECONFIG_ORIG_STRAP_VALUE_ATMEL (1L<<0)
1895#define BNX2_NVM_RECONFIG_RECONFIG_STRAP_VALUE (0xfL<<4)
1896#define BNX2_NVM_RECONFIG_RESERVED (0x7fffffL<<8)
1897#define BNX2_NVM_RECONFIG_RECONFIG_DONE (1L<<31)
1898
1122 1899
1123 1900
1124/* 1901/*
@@ -1140,6 +1917,8 @@ struct l2_fhdr {
1140#define BNX2_DMA_STATUS_BIG_WRITE_TRANSFERS_STAT (1L<<23) 1917#define BNX2_DMA_STATUS_BIG_WRITE_TRANSFERS_STAT (1L<<23)
1141#define BNX2_DMA_STATUS_BIG_WRITE_DELAY_PCI_CLKS_STAT (1L<<24) 1918#define BNX2_DMA_STATUS_BIG_WRITE_DELAY_PCI_CLKS_STAT (1L<<24)
1142#define BNX2_DMA_STATUS_BIG_WRITE_RETRY_AFTER_DATA_STAT (1L<<25) 1919#define BNX2_DMA_STATUS_BIG_WRITE_RETRY_AFTER_DATA_STAT (1L<<25)
1920#define BNX2_DMA_STATUS_GLOBAL_ERR_XI (1L<<0)
1921#define BNX2_DMA_STATUS_BME_XI (1L<<4)
1143 1922
1144#define BNX2_DMA_CONFIG 0x00000c08 1923#define BNX2_DMA_CONFIG 0x00000c08
1145#define BNX2_DMA_CONFIG_DATA_BYTE_SWAP (1L<<0) 1924#define BNX2_DMA_CONFIG_DATA_BYTE_SWAP (1L<<0)
@@ -1161,85 +1940,315 @@ struct l2_fhdr {
1161#define BNX2_DMA_CONFIG_BIG_SIZE_128 (0x2L<<24) 1940#define BNX2_DMA_CONFIG_BIG_SIZE_128 (0x2L<<24)
1162#define BNX2_DMA_CONFIG_BIG_SIZE_256 (0x4L<<24) 1941#define BNX2_DMA_CONFIG_BIG_SIZE_256 (0x4L<<24)
1163#define BNX2_DMA_CONFIG_BIG_SIZE_512 (0x8L<<24) 1942#define BNX2_DMA_CONFIG_BIG_SIZE_512 (0x8L<<24)
1943#define BNX2_DMA_CONFIG_DAT_WBSWAP_MODE_XI (0x3L<<0)
1944#define BNX2_DMA_CONFIG_CTL_WBSWAP_MODE_XI (0x3L<<4)
1945#define BNX2_DMA_CONFIG_MAX_PL_XI (0x7L<<12)
1946#define BNX2_DMA_CONFIG_MAX_PL_128B_XI (0L<<12)
1947#define BNX2_DMA_CONFIG_MAX_PL_256B_XI (1L<<12)
1948#define BNX2_DMA_CONFIG_MAX_PL_512B_XI (2L<<12)
1949#define BNX2_DMA_CONFIG_MAX_PL_EN_XI (1L<<15)
1950#define BNX2_DMA_CONFIG_MAX_RRS_XI (0x7L<<16)
1951#define BNX2_DMA_CONFIG_MAX_RRS_128B_XI (0L<<16)
1952#define BNX2_DMA_CONFIG_MAX_RRS_256B_XI (1L<<16)
1953#define BNX2_DMA_CONFIG_MAX_RRS_512B_XI (2L<<16)
1954#define BNX2_DMA_CONFIG_MAX_RRS_1024B_XI (3L<<16)
1955#define BNX2_DMA_CONFIG_MAX_RRS_2048B_XI (4L<<16)
1956#define BNX2_DMA_CONFIG_MAX_RRS_4096B_XI (5L<<16)
1957#define BNX2_DMA_CONFIG_MAX_RRS_EN_XI (1L<<19)
1958#define BNX2_DMA_CONFIG_NO_64SWAP_EN_XI (1L<<31)
1164 1959
1165#define BNX2_DMA_BLACKOUT 0x00000c0c 1960#define BNX2_DMA_BLACKOUT 0x00000c0c
1166#define BNX2_DMA_BLACKOUT_RD_RETRY_BLACKOUT (0xffL<<0) 1961#define BNX2_DMA_BLACKOUT_RD_RETRY_BLACKOUT (0xffL<<0)
1167#define BNX2_DMA_BLACKOUT_2ND_RD_RETRY_BLACKOUT (0xffL<<8) 1962#define BNX2_DMA_BLACKOUT_2ND_RD_RETRY_BLACKOUT (0xffL<<8)
1168#define BNX2_DMA_BLACKOUT_WR_RETRY_BLACKOUT (0xffL<<16) 1963#define BNX2_DMA_BLACKOUT_WR_RETRY_BLACKOUT (0xffL<<16)
1169 1964
1170#define BNX2_DMA_RCHAN_STAT 0x00000c30 1965#define BNX2_DMA_READ_MASTER_SETTING_0 0x00000c10
1171#define BNX2_DMA_RCHAN_STAT_COMP_CODE_0 (0x7L<<0) 1966#define BNX2_DMA_READ_MASTER_SETTING_0_TBDC_NO_SNOOP (1L<<0)
1172#define BNX2_DMA_RCHAN_STAT_PAR_ERR_0 (1L<<3) 1967#define BNX2_DMA_READ_MASTER_SETTING_0_TBDC_RELAX_ORDER (1L<<1)
1173#define BNX2_DMA_RCHAN_STAT_COMP_CODE_1 (0x7L<<4) 1968#define BNX2_DMA_READ_MASTER_SETTING_0_TBDC_PRIORITY (1L<<2)
1174#define BNX2_DMA_RCHAN_STAT_PAR_ERR_1 (1L<<7) 1969#define BNX2_DMA_READ_MASTER_SETTING_0_TBDC_TRAFFIC_CLASS (0x7L<<4)
1175#define BNX2_DMA_RCHAN_STAT_COMP_CODE_2 (0x7L<<8) 1970#define BNX2_DMA_READ_MASTER_SETTING_0_TBDC_PARAM_EN (1L<<7)
1176#define BNX2_DMA_RCHAN_STAT_PAR_ERR_2 (1L<<11) 1971#define BNX2_DMA_READ_MASTER_SETTING_0_RBDC_NO_SNOOP (1L<<8)
1177#define BNX2_DMA_RCHAN_STAT_COMP_CODE_3 (0x7L<<12) 1972#define BNX2_DMA_READ_MASTER_SETTING_0_RBDC_RELAX_ORDER (1L<<9)
1178#define BNX2_DMA_RCHAN_STAT_PAR_ERR_3 (1L<<15) 1973#define BNX2_DMA_READ_MASTER_SETTING_0_RBDC_PRIORITY (1L<<10)
1179#define BNX2_DMA_RCHAN_STAT_COMP_CODE_4 (0x7L<<16) 1974#define BNX2_DMA_READ_MASTER_SETTING_0_RBDC_TRAFFIC_CLASS (0x7L<<12)
1180#define BNX2_DMA_RCHAN_STAT_PAR_ERR_4 (1L<<19) 1975#define BNX2_DMA_READ_MASTER_SETTING_0_RBDC_PARAM_EN (1L<<15)
1181#define BNX2_DMA_RCHAN_STAT_COMP_CODE_5 (0x7L<<20) 1976#define BNX2_DMA_READ_MASTER_SETTING_0_TDMA_NO_SNOOP (1L<<16)
1182#define BNX2_DMA_RCHAN_STAT_PAR_ERR_5 (1L<<23) 1977#define BNX2_DMA_READ_MASTER_SETTING_0_TDMA_RELAX_ORDER (1L<<17)
1183#define BNX2_DMA_RCHAN_STAT_COMP_CODE_6 (0x7L<<24) 1978#define BNX2_DMA_READ_MASTER_SETTING_0_TDMA_PRIORITY (1L<<18)
1184#define BNX2_DMA_RCHAN_STAT_PAR_ERR_6 (1L<<27) 1979#define BNX2_DMA_READ_MASTER_SETTING_0_TDMA_TRAFFIC_CLASS (0x7L<<20)
1185#define BNX2_DMA_RCHAN_STAT_COMP_CODE_7 (0x7L<<28) 1980#define BNX2_DMA_READ_MASTER_SETTING_0_TDMA_PARAM_EN (1L<<23)
1186#define BNX2_DMA_RCHAN_STAT_PAR_ERR_7 (1L<<31) 1981#define BNX2_DMA_READ_MASTER_SETTING_0_CTX_NO_SNOOP (1L<<24)
1187 1982#define BNX2_DMA_READ_MASTER_SETTING_0_CTX_RELAX_ORDER (1L<<25)
1188#define BNX2_DMA_WCHAN_STAT 0x00000c34 1983#define BNX2_DMA_READ_MASTER_SETTING_0_CTX_PRIORITY (1L<<26)
1189#define BNX2_DMA_WCHAN_STAT_COMP_CODE_0 (0x7L<<0) 1984#define BNX2_DMA_READ_MASTER_SETTING_0_CTX_TRAFFIC_CLASS (0x7L<<28)
1190#define BNX2_DMA_WCHAN_STAT_PAR_ERR_0 (1L<<3) 1985#define BNX2_DMA_READ_MASTER_SETTING_0_CTX_PARAM_EN (1L<<31)
1191#define BNX2_DMA_WCHAN_STAT_COMP_CODE_1 (0x7L<<4) 1986
1192#define BNX2_DMA_WCHAN_STAT_PAR_ERR_1 (1L<<7) 1987#define BNX2_DMA_READ_MASTER_SETTING_1 0x00000c14
1193#define BNX2_DMA_WCHAN_STAT_COMP_CODE_2 (0x7L<<8) 1988#define BNX2_DMA_READ_MASTER_SETTING_1_COM_NO_SNOOP (1L<<0)
1194#define BNX2_DMA_WCHAN_STAT_PAR_ERR_2 (1L<<11) 1989#define BNX2_DMA_READ_MASTER_SETTING_1_COM_RELAX_ORDER (1L<<1)
1195#define BNX2_DMA_WCHAN_STAT_COMP_CODE_3 (0x7L<<12) 1990#define BNX2_DMA_READ_MASTER_SETTING_1_COM_PRIORITY (1L<<2)
1196#define BNX2_DMA_WCHAN_STAT_PAR_ERR_3 (1L<<15) 1991#define BNX2_DMA_READ_MASTER_SETTING_1_COM_TRAFFIC_CLASS (0x7L<<4)
1197#define BNX2_DMA_WCHAN_STAT_COMP_CODE_4 (0x7L<<16) 1992#define BNX2_DMA_READ_MASTER_SETTING_1_COM_PARAM_EN (1L<<7)
1198#define BNX2_DMA_WCHAN_STAT_PAR_ERR_4 (1L<<19) 1993#define BNX2_DMA_READ_MASTER_SETTING_1_CP_NO_SNOOP (1L<<8)
1199#define BNX2_DMA_WCHAN_STAT_COMP_CODE_5 (0x7L<<20) 1994#define BNX2_DMA_READ_MASTER_SETTING_1_CP_RELAX_ORDER (1L<<9)
1200#define BNX2_DMA_WCHAN_STAT_PAR_ERR_5 (1L<<23) 1995#define BNX2_DMA_READ_MASTER_SETTING_1_CP_PRIORITY (1L<<10)
1201#define BNX2_DMA_WCHAN_STAT_COMP_CODE_6 (0x7L<<24) 1996#define BNX2_DMA_READ_MASTER_SETTING_1_CP_TRAFFIC_CLASS (0x7L<<12)
1202#define BNX2_DMA_WCHAN_STAT_PAR_ERR_6 (1L<<27) 1997#define BNX2_DMA_READ_MASTER_SETTING_1_CP_PARAM_EN (1L<<15)
1203#define BNX2_DMA_WCHAN_STAT_COMP_CODE_7 (0x7L<<28) 1998
1204#define BNX2_DMA_WCHAN_STAT_PAR_ERR_7 (1L<<31) 1999#define BNX2_DMA_WRITE_MASTER_SETTING_0 0x00000c18
1205 2000#define BNX2_DMA_WRITE_MASTER_SETTING_0_HC_NO_SNOOP (1L<<0)
1206#define BNX2_DMA_RCHAN_ASSIGNMENT 0x00000c38 2001#define BNX2_DMA_WRITE_MASTER_SETTING_0_HC_RELAX_ORDER (1L<<1)
1207#define BNX2_DMA_RCHAN_ASSIGNMENT_0 (0xfL<<0) 2002#define BNX2_DMA_WRITE_MASTER_SETTING_0_HC_PRIORITY (1L<<2)
1208#define BNX2_DMA_RCHAN_ASSIGNMENT_1 (0xfL<<4) 2003#define BNX2_DMA_WRITE_MASTER_SETTING_0_HC_CS_VLD (1L<<3)
1209#define BNX2_DMA_RCHAN_ASSIGNMENT_2 (0xfL<<8) 2004#define BNX2_DMA_WRITE_MASTER_SETTING_0_HC_TRAFFIC_CLASS (0x7L<<4)
1210#define BNX2_DMA_RCHAN_ASSIGNMENT_3 (0xfL<<12) 2005#define BNX2_DMA_WRITE_MASTER_SETTING_0_HC_PARAM_EN (1L<<7)
1211#define BNX2_DMA_RCHAN_ASSIGNMENT_4 (0xfL<<16) 2006#define BNX2_DMA_WRITE_MASTER_SETTING_0_RDMA_NO_SNOOP (1L<<8)
1212#define BNX2_DMA_RCHAN_ASSIGNMENT_5 (0xfL<<20) 2007#define BNX2_DMA_WRITE_MASTER_SETTING_0_RDMA_RELAX_ORDER (1L<<9)
1213#define BNX2_DMA_RCHAN_ASSIGNMENT_6 (0xfL<<24) 2008#define BNX2_DMA_WRITE_MASTER_SETTING_0_RDMA_PRIORITY (1L<<10)
1214#define BNX2_DMA_RCHAN_ASSIGNMENT_7 (0xfL<<28) 2009#define BNX2_DMA_WRITE_MASTER_SETTING_0_RDMA_CS_VLD (1L<<11)
1215 2010#define BNX2_DMA_WRITE_MASTER_SETTING_0_RDMA_TRAFFIC_CLASS (0x7L<<12)
1216#define BNX2_DMA_WCHAN_ASSIGNMENT 0x00000c3c 2011#define BNX2_DMA_WRITE_MASTER_SETTING_0_RDMA_PARAM_EN (1L<<15)
1217#define BNX2_DMA_WCHAN_ASSIGNMENT_0 (0xfL<<0) 2012#define BNX2_DMA_WRITE_MASTER_SETTING_0_CTX_NO_SNOOP (1L<<24)
1218#define BNX2_DMA_WCHAN_ASSIGNMENT_1 (0xfL<<4) 2013#define BNX2_DMA_WRITE_MASTER_SETTING_0_CTX_RELAX_ORDER (1L<<25)
1219#define BNX2_DMA_WCHAN_ASSIGNMENT_2 (0xfL<<8) 2014#define BNX2_DMA_WRITE_MASTER_SETTING_0_CTX_PRIORITY (1L<<26)
1220#define BNX2_DMA_WCHAN_ASSIGNMENT_3 (0xfL<<12) 2015#define BNX2_DMA_WRITE_MASTER_SETTING_0_CTX_CS_VLD (1L<<27)
1221#define BNX2_DMA_WCHAN_ASSIGNMENT_4 (0xfL<<16) 2016#define BNX2_DMA_WRITE_MASTER_SETTING_0_CTX_TRAFFIC_CLASS (0x7L<<28)
1222#define BNX2_DMA_WCHAN_ASSIGNMENT_5 (0xfL<<20) 2017#define BNX2_DMA_WRITE_MASTER_SETTING_0_CTX_PARAM_EN (1L<<31)
1223#define BNX2_DMA_WCHAN_ASSIGNMENT_6 (0xfL<<24) 2018
1224#define BNX2_DMA_WCHAN_ASSIGNMENT_7 (0xfL<<28) 2019#define BNX2_DMA_WRITE_MASTER_SETTING_1 0x00000c1c
1225 2020#define BNX2_DMA_WRITE_MASTER_SETTING_1_COM_NO_SNOOP (1L<<0)
1226#define BNX2_DMA_RCHAN_STAT_00 0x00000c40 2021#define BNX2_DMA_WRITE_MASTER_SETTING_1_COM_RELAX_ORDER (1L<<1)
1227#define BNX2_DMA_RCHAN_STAT_00_RCHAN_STA_HOST_ADDR_LOW (0xffffffffL<<0) 2022#define BNX2_DMA_WRITE_MASTER_SETTING_1_COM_PRIORITY (1L<<2)
1228 2023#define BNX2_DMA_WRITE_MASTER_SETTING_1_COM_CS_VLD (1L<<3)
1229#define BNX2_DMA_RCHAN_STAT_01 0x00000c44 2024#define BNX2_DMA_WRITE_MASTER_SETTING_1_COM_TRAFFIC_CLASS (0x7L<<4)
1230#define BNX2_DMA_RCHAN_STAT_01_RCHAN_STA_HOST_ADDR_HIGH (0xffffffffL<<0) 2025#define BNX2_DMA_WRITE_MASTER_SETTING_1_COM_PARAM_EN (1L<<7)
1231 2026#define BNX2_DMA_WRITE_MASTER_SETTING_1_CP_NO_SNOOP (1L<<8)
1232#define BNX2_DMA_RCHAN_STAT_02 0x00000c48 2027#define BNX2_DMA_WRITE_MASTER_SETTING_1_CP_RELAX_ORDER (1L<<9)
1233#define BNX2_DMA_RCHAN_STAT_02_LENGTH (0xffffL<<0) 2028#define BNX2_DMA_WRITE_MASTER_SETTING_1_CP_PRIORITY (1L<<10)
1234#define BNX2_DMA_RCHAN_STAT_02_WORD_SWAP (1L<<16) 2029#define BNX2_DMA_WRITE_MASTER_SETTING_1_CP_CS_VLD (1L<<11)
1235#define BNX2_DMA_RCHAN_STAT_02_BYTE_SWAP (1L<<17) 2030#define BNX2_DMA_WRITE_MASTER_SETTING_1_CP_TRAFFIC_CLASS (0x7L<<12)
1236#define BNX2_DMA_RCHAN_STAT_02_PRIORITY_LVL (1L<<18) 2031#define BNX2_DMA_WRITE_MASTER_SETTING_1_CP_PARAM_EN (1L<<15)
1237 2032
1238#define BNX2_DMA_RCHAN_STAT_10 0x00000c4c 2033#define BNX2_DMA_ARBITER 0x00000c20
1239#define BNX2_DMA_RCHAN_STAT_11 0x00000c50 2034#define BNX2_DMA_ARBITER_NUM_READS (0x7L<<0)
1240#define BNX2_DMA_RCHAN_STAT_12 0x00000c54 2035#define BNX2_DMA_ARBITER_WR_ARB_MODE (1L<<4)
1241#define BNX2_DMA_RCHAN_STAT_20 0x00000c58 2036#define BNX2_DMA_ARBITER_WR_ARB_MODE_STRICT (0L<<4)
1242#define BNX2_DMA_RCHAN_STAT_21 0x00000c5c 2037#define BNX2_DMA_ARBITER_WR_ARB_MODE_RND_RBN (1L<<4)
2038#define BNX2_DMA_ARBITER_RD_ARB_MODE (0x3L<<5)
2039#define BNX2_DMA_ARBITER_RD_ARB_MODE_STRICT (0L<<5)
2040#define BNX2_DMA_ARBITER_RD_ARB_MODE_RND_RBN (1L<<5)
2041#define BNX2_DMA_ARBITER_RD_ARB_MODE_WGT_RND_RBN (2L<<5)
2042#define BNX2_DMA_ARBITER_ALT_MODE_EN (1L<<8)
2043#define BNX2_DMA_ARBITER_RR_MODE (1L<<9)
2044#define BNX2_DMA_ARBITER_TIMER_MODE (1L<<10)
2045#define BNX2_DMA_ARBITER_OUSTD_READ_REQ (0xfL<<12)
2046
2047#define BNX2_DMA_ARB_TIMERS 0x00000c24
2048#define BNX2_DMA_ARB_TIMERS_RD_DRR_WAIT_TIME (0xffL<<0)
2049#define BNX2_DMA_ARB_TIMERS_TM_MIN_TIMEOUT (0xffL<<12)
2050#define BNX2_DMA_ARB_TIMERS_TM_MAX_TIMEOUT (0xfffL<<20)
2051
2052#define BNX2_DMA_DEBUG_VECT_PEEK 0x00000c2c
2053#define BNX2_DMA_DEBUG_VECT_PEEK_1_VALUE (0x7ffL<<0)
2054#define BNX2_DMA_DEBUG_VECT_PEEK_1_PEEK_EN (1L<<11)
2055#define BNX2_DMA_DEBUG_VECT_PEEK_1_SEL (0xfL<<12)
2056#define BNX2_DMA_DEBUG_VECT_PEEK_2_VALUE (0x7ffL<<16)
2057#define BNX2_DMA_DEBUG_VECT_PEEK_2_PEEK_EN (1L<<27)
2058#define BNX2_DMA_DEBUG_VECT_PEEK_2_SEL (0xfL<<28)
2059
2060#define BNX2_DMA_TAG_RAM_00 0x00000c30
2061#define BNX2_DMA_TAG_RAM_00_CHANNEL (0xfL<<0)
2062#define BNX2_DMA_TAG_RAM_00_MASTER (0x7L<<4)
2063#define BNX2_DMA_TAG_RAM_00_MASTER_CTX (0L<<4)
2064#define BNX2_DMA_TAG_RAM_00_MASTER_RBDC (1L<<4)
2065#define BNX2_DMA_TAG_RAM_00_MASTER_TBDC (2L<<4)
2066#define BNX2_DMA_TAG_RAM_00_MASTER_COM (3L<<4)
2067#define BNX2_DMA_TAG_RAM_00_MASTER_CP (4L<<4)
2068#define BNX2_DMA_TAG_RAM_00_MASTER_TDMA (5L<<4)
2069#define BNX2_DMA_TAG_RAM_00_SWAP (0x3L<<7)
2070#define BNX2_DMA_TAG_RAM_00_SWAP_CONFIG (0L<<7)
2071#define BNX2_DMA_TAG_RAM_00_SWAP_DATA (1L<<7)
2072#define BNX2_DMA_TAG_RAM_00_SWAP_CONTROL (2L<<7)
2073#define BNX2_DMA_TAG_RAM_00_FUNCTION (1L<<9)
2074#define BNX2_DMA_TAG_RAM_00_VALID (1L<<10)
2075
2076#define BNX2_DMA_TAG_RAM_01 0x00000c34
2077#define BNX2_DMA_TAG_RAM_01_CHANNEL (0xfL<<0)
2078#define BNX2_DMA_TAG_RAM_01_MASTER (0x7L<<4)
2079#define BNX2_DMA_TAG_RAM_01_MASTER_CTX (0L<<4)
2080#define BNX2_DMA_TAG_RAM_01_MASTER_RBDC (1L<<4)
2081#define BNX2_DMA_TAG_RAM_01_MASTER_TBDC (2L<<4)
2082#define BNX2_DMA_TAG_RAM_01_MASTER_COM (3L<<4)
2083#define BNX2_DMA_TAG_RAM_01_MASTER_CP (4L<<4)
2084#define BNX2_DMA_TAG_RAM_01_MASTER_TDMA (5L<<4)
2085#define BNX2_DMA_TAG_RAM_01_SWAP (0x3L<<7)
2086#define BNX2_DMA_TAG_RAM_01_SWAP_CONFIG (0L<<7)
2087#define BNX2_DMA_TAG_RAM_01_SWAP_DATA (1L<<7)
2088#define BNX2_DMA_TAG_RAM_01_SWAP_CONTROL (2L<<7)
2089#define BNX2_DMA_TAG_RAM_01_FUNCTION (1L<<9)
2090#define BNX2_DMA_TAG_RAM_01_VALID (1L<<10)
2091
2092#define BNX2_DMA_TAG_RAM_02 0x00000c38
2093#define BNX2_DMA_TAG_RAM_02_CHANNEL (0xfL<<0)
2094#define BNX2_DMA_TAG_RAM_02_MASTER (0x7L<<4)
2095#define BNX2_DMA_TAG_RAM_02_MASTER_CTX (0L<<4)
2096#define BNX2_DMA_TAG_RAM_02_MASTER_RBDC (1L<<4)
2097#define BNX2_DMA_TAG_RAM_02_MASTER_TBDC (2L<<4)
2098#define BNX2_DMA_TAG_RAM_02_MASTER_COM (3L<<4)
2099#define BNX2_DMA_TAG_RAM_02_MASTER_CP (4L<<4)
2100#define BNX2_DMA_TAG_RAM_02_MASTER_TDMA (5L<<4)
2101#define BNX2_DMA_TAG_RAM_02_SWAP (0x3L<<7)
2102#define BNX2_DMA_TAG_RAM_02_SWAP_CONFIG (0L<<7)
2103#define BNX2_DMA_TAG_RAM_02_SWAP_DATA (1L<<7)
2104#define BNX2_DMA_TAG_RAM_02_SWAP_CONTROL (2L<<7)
2105#define BNX2_DMA_TAG_RAM_02_FUNCTION (1L<<9)
2106#define BNX2_DMA_TAG_RAM_02_VALID (1L<<10)
2107
2108#define BNX2_DMA_TAG_RAM_03 0x00000c3c
2109#define BNX2_DMA_TAG_RAM_03_CHANNEL (0xfL<<0)
2110#define BNX2_DMA_TAG_RAM_03_MASTER (0x7L<<4)
2111#define BNX2_DMA_TAG_RAM_03_MASTER_CTX (0L<<4)
2112#define BNX2_DMA_TAG_RAM_03_MASTER_RBDC (1L<<4)
2113#define BNX2_DMA_TAG_RAM_03_MASTER_TBDC (2L<<4)
2114#define BNX2_DMA_TAG_RAM_03_MASTER_COM (3L<<4)
2115#define BNX2_DMA_TAG_RAM_03_MASTER_CP (4L<<4)
2116#define BNX2_DMA_TAG_RAM_03_MASTER_TDMA (5L<<4)
2117#define BNX2_DMA_TAG_RAM_03_SWAP (0x3L<<7)
2118#define BNX2_DMA_TAG_RAM_03_SWAP_CONFIG (0L<<7)
2119#define BNX2_DMA_TAG_RAM_03_SWAP_DATA (1L<<7)
2120#define BNX2_DMA_TAG_RAM_03_SWAP_CONTROL (2L<<7)
2121#define BNX2_DMA_TAG_RAM_03_FUNCTION (1L<<9)
2122#define BNX2_DMA_TAG_RAM_03_VALID (1L<<10)
2123
2124#define BNX2_DMA_TAG_RAM_04 0x00000c40
2125#define BNX2_DMA_TAG_RAM_04_CHANNEL (0xfL<<0)
2126#define BNX2_DMA_TAG_RAM_04_MASTER (0x7L<<4)
2127#define BNX2_DMA_TAG_RAM_04_MASTER_CTX (0L<<4)
2128#define BNX2_DMA_TAG_RAM_04_MASTER_RBDC (1L<<4)
2129#define BNX2_DMA_TAG_RAM_04_MASTER_TBDC (2L<<4)
2130#define BNX2_DMA_TAG_RAM_04_MASTER_COM (3L<<4)
2131#define BNX2_DMA_TAG_RAM_04_MASTER_CP (4L<<4)
2132#define BNX2_DMA_TAG_RAM_04_MASTER_TDMA (5L<<4)
2133#define BNX2_DMA_TAG_RAM_04_SWAP (0x3L<<7)
2134#define BNX2_DMA_TAG_RAM_04_SWAP_CONFIG (0L<<7)
2135#define BNX2_DMA_TAG_RAM_04_SWAP_DATA (1L<<7)
2136#define BNX2_DMA_TAG_RAM_04_SWAP_CONTROL (2L<<7)
2137#define BNX2_DMA_TAG_RAM_04_FUNCTION (1L<<9)
2138#define BNX2_DMA_TAG_RAM_04_VALID (1L<<10)
2139
2140#define BNX2_DMA_TAG_RAM_05 0x00000c44
2141#define BNX2_DMA_TAG_RAM_05_CHANNEL (0xfL<<0)
2142#define BNX2_DMA_TAG_RAM_05_MASTER (0x7L<<4)
2143#define BNX2_DMA_TAG_RAM_05_MASTER_CTX (0L<<4)
2144#define BNX2_DMA_TAG_RAM_05_MASTER_RBDC (1L<<4)
2145#define BNX2_DMA_TAG_RAM_05_MASTER_TBDC (2L<<4)
2146#define BNX2_DMA_TAG_RAM_05_MASTER_COM (3L<<4)
2147#define BNX2_DMA_TAG_RAM_05_MASTER_CP (4L<<4)
2148#define BNX2_DMA_TAG_RAM_05_MASTER_TDMA (5L<<4)
2149#define BNX2_DMA_TAG_RAM_05_SWAP (0x3L<<7)
2150#define BNX2_DMA_TAG_RAM_05_SWAP_CONFIG (0L<<7)
2151#define BNX2_DMA_TAG_RAM_05_SWAP_DATA (1L<<7)
2152#define BNX2_DMA_TAG_RAM_05_SWAP_CONTROL (2L<<7)
2153#define BNX2_DMA_TAG_RAM_05_FUNCTION (1L<<9)
2154#define BNX2_DMA_TAG_RAM_05_VALID (1L<<10)
2155
2156#define BNX2_DMA_TAG_RAM_06 0x00000c48
2157#define BNX2_DMA_TAG_RAM_06_CHANNEL (0xfL<<0)
2158#define BNX2_DMA_TAG_RAM_06_MASTER (0x7L<<4)
2159#define BNX2_DMA_TAG_RAM_06_MASTER_CTX (0L<<4)
2160#define BNX2_DMA_TAG_RAM_06_MASTER_RBDC (1L<<4)
2161#define BNX2_DMA_TAG_RAM_06_MASTER_TBDC (2L<<4)
2162#define BNX2_DMA_TAG_RAM_06_MASTER_COM (3L<<4)
2163#define BNX2_DMA_TAG_RAM_06_MASTER_CP (4L<<4)
2164#define BNX2_DMA_TAG_RAM_06_MASTER_TDMA (5L<<4)
2165#define BNX2_DMA_TAG_RAM_06_SWAP (0x3L<<7)
2166#define BNX2_DMA_TAG_RAM_06_SWAP_CONFIG (0L<<7)
2167#define BNX2_DMA_TAG_RAM_06_SWAP_DATA (1L<<7)
2168#define BNX2_DMA_TAG_RAM_06_SWAP_CONTROL (2L<<7)
2169#define BNX2_DMA_TAG_RAM_06_FUNCTION (1L<<9)
2170#define BNX2_DMA_TAG_RAM_06_VALID (1L<<10)
2171
2172#define BNX2_DMA_TAG_RAM_07 0x00000c4c
2173#define BNX2_DMA_TAG_RAM_07_CHANNEL (0xfL<<0)
2174#define BNX2_DMA_TAG_RAM_07_MASTER (0x7L<<4)
2175#define BNX2_DMA_TAG_RAM_07_MASTER_CTX (0L<<4)
2176#define BNX2_DMA_TAG_RAM_07_MASTER_RBDC (1L<<4)
2177#define BNX2_DMA_TAG_RAM_07_MASTER_TBDC (2L<<4)
2178#define BNX2_DMA_TAG_RAM_07_MASTER_COM (3L<<4)
2179#define BNX2_DMA_TAG_RAM_07_MASTER_CP (4L<<4)
2180#define BNX2_DMA_TAG_RAM_07_MASTER_TDMA (5L<<4)
2181#define BNX2_DMA_TAG_RAM_07_SWAP (0x3L<<7)
2182#define BNX2_DMA_TAG_RAM_07_SWAP_CONFIG (0L<<7)
2183#define BNX2_DMA_TAG_RAM_07_SWAP_DATA (1L<<7)
2184#define BNX2_DMA_TAG_RAM_07_SWAP_CONTROL (2L<<7)
2185#define BNX2_DMA_TAG_RAM_07_FUNCTION (1L<<9)
2186#define BNX2_DMA_TAG_RAM_07_VALID (1L<<10)
2187
2188#define BNX2_DMA_TAG_RAM_08 0x00000c50
2189#define BNX2_DMA_TAG_RAM_08_CHANNEL (0xfL<<0)
2190#define BNX2_DMA_TAG_RAM_08_MASTER (0x7L<<4)
2191#define BNX2_DMA_TAG_RAM_08_MASTER_CTX (0L<<4)
2192#define BNX2_DMA_TAG_RAM_08_MASTER_RBDC (1L<<4)
2193#define BNX2_DMA_TAG_RAM_08_MASTER_TBDC (2L<<4)
2194#define BNX2_DMA_TAG_RAM_08_MASTER_COM (3L<<4)
2195#define BNX2_DMA_TAG_RAM_08_MASTER_CP (4L<<4)
2196#define BNX2_DMA_TAG_RAM_08_MASTER_TDMA (5L<<4)
2197#define BNX2_DMA_TAG_RAM_08_SWAP (0x3L<<7)
2198#define BNX2_DMA_TAG_RAM_08_SWAP_CONFIG (0L<<7)
2199#define BNX2_DMA_TAG_RAM_08_SWAP_DATA (1L<<7)
2200#define BNX2_DMA_TAG_RAM_08_SWAP_CONTROL (2L<<7)
2201#define BNX2_DMA_TAG_RAM_08_FUNCTION (1L<<9)
2202#define BNX2_DMA_TAG_RAM_08_VALID (1L<<10)
2203
2204#define BNX2_DMA_TAG_RAM_09 0x00000c54
2205#define BNX2_DMA_TAG_RAM_09_CHANNEL (0xfL<<0)
2206#define BNX2_DMA_TAG_RAM_09_MASTER (0x7L<<4)
2207#define BNX2_DMA_TAG_RAM_09_MASTER_CTX (0L<<4)
2208#define BNX2_DMA_TAG_RAM_09_MASTER_RBDC (1L<<4)
2209#define BNX2_DMA_TAG_RAM_09_MASTER_TBDC (2L<<4)
2210#define BNX2_DMA_TAG_RAM_09_MASTER_COM (3L<<4)
2211#define BNX2_DMA_TAG_RAM_09_MASTER_CP (4L<<4)
2212#define BNX2_DMA_TAG_RAM_09_MASTER_TDMA (5L<<4)
2213#define BNX2_DMA_TAG_RAM_09_SWAP (0x3L<<7)
2214#define BNX2_DMA_TAG_RAM_09_SWAP_CONFIG (0L<<7)
2215#define BNX2_DMA_TAG_RAM_09_SWAP_DATA (1L<<7)
2216#define BNX2_DMA_TAG_RAM_09_SWAP_CONTROL (2L<<7)
2217#define BNX2_DMA_TAG_RAM_09_FUNCTION (1L<<9)
2218#define BNX2_DMA_TAG_RAM_09_VALID (1L<<10)
2219
2220#define BNX2_DMA_TAG_RAM_10 0x00000c58
2221#define BNX2_DMA_TAG_RAM_10_CHANNEL (0xfL<<0)
2222#define BNX2_DMA_TAG_RAM_10_MASTER (0x7L<<4)
2223#define BNX2_DMA_TAG_RAM_10_MASTER_CTX (0L<<4)
2224#define BNX2_DMA_TAG_RAM_10_MASTER_RBDC (1L<<4)
2225#define BNX2_DMA_TAG_RAM_10_MASTER_TBDC (2L<<4)
2226#define BNX2_DMA_TAG_RAM_10_MASTER_COM (3L<<4)
2227#define BNX2_DMA_TAG_RAM_10_MASTER_CP (4L<<4)
2228#define BNX2_DMA_TAG_RAM_10_MASTER_TDMA (5L<<4)
2229#define BNX2_DMA_TAG_RAM_10_SWAP (0x3L<<7)
2230#define BNX2_DMA_TAG_RAM_10_SWAP_CONFIG (0L<<7)
2231#define BNX2_DMA_TAG_RAM_10_SWAP_DATA (1L<<7)
2232#define BNX2_DMA_TAG_RAM_10_SWAP_CONTROL (2L<<7)
2233#define BNX2_DMA_TAG_RAM_10_FUNCTION (1L<<9)
2234#define BNX2_DMA_TAG_RAM_10_VALID (1L<<10)
2235
2236#define BNX2_DMA_TAG_RAM_11 0x00000c5c
2237#define BNX2_DMA_TAG_RAM_11_CHANNEL (0xfL<<0)
2238#define BNX2_DMA_TAG_RAM_11_MASTER (0x7L<<4)
2239#define BNX2_DMA_TAG_RAM_11_MASTER_CTX (0L<<4)
2240#define BNX2_DMA_TAG_RAM_11_MASTER_RBDC (1L<<4)
2241#define BNX2_DMA_TAG_RAM_11_MASTER_TBDC (2L<<4)
2242#define BNX2_DMA_TAG_RAM_11_MASTER_COM (3L<<4)
2243#define BNX2_DMA_TAG_RAM_11_MASTER_CP (4L<<4)
2244#define BNX2_DMA_TAG_RAM_11_MASTER_TDMA (5L<<4)
2245#define BNX2_DMA_TAG_RAM_11_SWAP (0x3L<<7)
2246#define BNX2_DMA_TAG_RAM_11_SWAP_CONFIG (0L<<7)
2247#define BNX2_DMA_TAG_RAM_11_SWAP_DATA (1L<<7)
2248#define BNX2_DMA_TAG_RAM_11_SWAP_CONTROL (2L<<7)
2249#define BNX2_DMA_TAG_RAM_11_FUNCTION (1L<<9)
2250#define BNX2_DMA_TAG_RAM_11_VALID (1L<<10)
2251
1243#define BNX2_DMA_RCHAN_STAT_22 0x00000c60 2252#define BNX2_DMA_RCHAN_STAT_22 0x00000c60
1244#define BNX2_DMA_RCHAN_STAT_30 0x00000c64 2253#define BNX2_DMA_RCHAN_STAT_30 0x00000c64
1245#define BNX2_DMA_RCHAN_STAT_31 0x00000c68 2254#define BNX2_DMA_RCHAN_STAT_31 0x00000c68
@@ -1336,6 +2345,25 @@ struct l2_fhdr {
1336 */ 2345 */
1337#define BNX2_CTX_COMMAND 0x00001000 2346#define BNX2_CTX_COMMAND 0x00001000
1338#define BNX2_CTX_COMMAND_ENABLED (1L<<0) 2347#define BNX2_CTX_COMMAND_ENABLED (1L<<0)
2348#define BNX2_CTX_COMMAND_DISABLE_USAGE_CNT (1L<<1)
2349#define BNX2_CTX_COMMAND_DISABLE_PLRU (1L<<2)
2350#define BNX2_CTX_COMMAND_DISABLE_COMBINE_READ (1L<<3)
2351#define BNX2_CTX_COMMAND_FLUSH_AHEAD (0x1fL<<8)
2352#define BNX2_CTX_COMMAND_MEM_INIT (1L<<13)
2353#define BNX2_CTX_COMMAND_PAGE_SIZE (0xfL<<16)
2354#define BNX2_CTX_COMMAND_PAGE_SIZE_256 (0L<<16)
2355#define BNX2_CTX_COMMAND_PAGE_SIZE_512 (1L<<16)
2356#define BNX2_CTX_COMMAND_PAGE_SIZE_1K (2L<<16)
2357#define BNX2_CTX_COMMAND_PAGE_SIZE_2K (3L<<16)
2358#define BNX2_CTX_COMMAND_PAGE_SIZE_4K (4L<<16)
2359#define BNX2_CTX_COMMAND_PAGE_SIZE_8K (5L<<16)
2360#define BNX2_CTX_COMMAND_PAGE_SIZE_16K (6L<<16)
2361#define BNX2_CTX_COMMAND_PAGE_SIZE_32K (7L<<16)
2362#define BNX2_CTX_COMMAND_PAGE_SIZE_64K (8L<<16)
2363#define BNX2_CTX_COMMAND_PAGE_SIZE_128K (9L<<16)
2364#define BNX2_CTX_COMMAND_PAGE_SIZE_256K (10L<<16)
2365#define BNX2_CTX_COMMAND_PAGE_SIZE_512K (11L<<16)
2366#define BNX2_CTX_COMMAND_PAGE_SIZE_1M (12L<<16)
1339 2367
1340#define BNX2_CTX_STATUS 0x00001004 2368#define BNX2_CTX_STATUS 0x00001004
1341#define BNX2_CTX_STATUS_LOCK_WAIT (1L<<0) 2369#define BNX2_CTX_STATUS_LOCK_WAIT (1L<<0)
@@ -1343,6 +2371,13 @@ struct l2_fhdr {
1343#define BNX2_CTX_STATUS_WRITE_STAT (1L<<17) 2371#define BNX2_CTX_STATUS_WRITE_STAT (1L<<17)
1344#define BNX2_CTX_STATUS_ACC_STALL_STAT (1L<<18) 2372#define BNX2_CTX_STATUS_ACC_STALL_STAT (1L<<18)
1345#define BNX2_CTX_STATUS_LOCK_STALL_STAT (1L<<19) 2373#define BNX2_CTX_STATUS_LOCK_STALL_STAT (1L<<19)
2374#define BNX2_CTX_STATUS_EXT_READ_STAT (1L<<20)
2375#define BNX2_CTX_STATUS_EXT_WRITE_STAT (1L<<21)
2376#define BNX2_CTX_STATUS_MISS_STAT (1L<<22)
2377#define BNX2_CTX_STATUS_HIT_STAT (1L<<23)
2378#define BNX2_CTX_STATUS_DEAD_LOCK (1L<<24)
2379#define BNX2_CTX_STATUS_USAGE_CNT_ERR (1L<<25)
2380#define BNX2_CTX_STATUS_INVALID_PAGE (1L<<26)
1346 2381
1347#define BNX2_CTX_VIRT_ADDR 0x00001008 2382#define BNX2_CTX_VIRT_ADDR 0x00001008
1348#define BNX2_CTX_VIRT_ADDR_VIRT_ADDR (0x7fffL<<6) 2383#define BNX2_CTX_VIRT_ADDR_VIRT_ADDR (0x7fffL<<6)
@@ -1357,10 +2392,15 @@ struct l2_fhdr {
1357#define BNX2_CTX_LOCK 0x00001018 2392#define BNX2_CTX_LOCK 0x00001018
1358#define BNX2_CTX_LOCK_TYPE (0x7L<<0) 2393#define BNX2_CTX_LOCK_TYPE (0x7L<<0)
1359#define BNX2_CTX_LOCK_TYPE_LOCK_TYPE_VOID (0x0L<<0) 2394#define BNX2_CTX_LOCK_TYPE_LOCK_TYPE_VOID (0x0L<<0)
1360#define BNX2_CTX_LOCK_TYPE_LOCK_TYPE_COMPLETE (0x7L<<0)
1361#define BNX2_CTX_LOCK_TYPE_LOCK_TYPE_PROTOCOL (0x1L<<0) 2395#define BNX2_CTX_LOCK_TYPE_LOCK_TYPE_PROTOCOL (0x1L<<0)
1362#define BNX2_CTX_LOCK_TYPE_LOCK_TYPE_TX (0x2L<<0) 2396#define BNX2_CTX_LOCK_TYPE_LOCK_TYPE_TX (0x2L<<0)
1363#define BNX2_CTX_LOCK_TYPE_LOCK_TYPE_TIMER (0x4L<<0) 2397#define BNX2_CTX_LOCK_TYPE_LOCK_TYPE_TIMER (0x4L<<0)
2398#define BNX2_CTX_LOCK_TYPE_LOCK_TYPE_COMPLETE (0x7L<<0)
2399#define BNX2_CTX_LOCK_TYPE_VOID_XI (0L<<0)
2400#define BNX2_CTX_LOCK_TYPE_PROTOCOL_XI (1L<<0)
2401#define BNX2_CTX_LOCK_TYPE_TX_XI (2L<<0)
2402#define BNX2_CTX_LOCK_TYPE_TIMER_XI (4L<<0)
2403#define BNX2_CTX_LOCK_TYPE_COMPLETE_XI (7L<<0)
1364#define BNX2_CTX_LOCK_CID_VALUE (0x3fffL<<7) 2404#define BNX2_CTX_LOCK_CID_VALUE (0x3fffL<<7)
1365#define BNX2_CTX_LOCK_GRANTED (1L<<26) 2405#define BNX2_CTX_LOCK_GRANTED (1L<<26)
1366#define BNX2_CTX_LOCK_MODE (0x7L<<27) 2406#define BNX2_CTX_LOCK_MODE (0x7L<<27)
@@ -1370,21 +2410,89 @@ struct l2_fhdr {
1370#define BNX2_CTX_LOCK_STATUS (1L<<30) 2410#define BNX2_CTX_LOCK_STATUS (1L<<30)
1371#define BNX2_CTX_LOCK_REQ (1L<<31) 2411#define BNX2_CTX_LOCK_REQ (1L<<31)
1372 2412
2413#define BNX2_CTX_CTX_CTRL 0x0000101c
2414#define BNX2_CTX_CTX_CTRL_CTX_ADDR (0x7ffffL<<2)
2415#define BNX2_CTX_CTX_CTRL_MOD_USAGE_CNT (0x3L<<21)
2416#define BNX2_CTX_CTX_CTRL_NO_RAM_ACC (1L<<23)
2417#define BNX2_CTX_CTX_CTRL_PREFETCH_SIZE (0x3L<<24)
2418#define BNX2_CTX_CTX_CTRL_ATTR (1L<<26)
2419#define BNX2_CTX_CTX_CTRL_WRITE_REQ (1L<<30)
2420#define BNX2_CTX_CTX_CTRL_READ_REQ (1L<<31)
2421
2422#define BNX2_CTX_CTX_DATA 0x00001020
1373#define BNX2_CTX_ACCESS_STATUS 0x00001040 2423#define BNX2_CTX_ACCESS_STATUS 0x00001040
1374#define BNX2_CTX_ACCESS_STATUS_MASTERENCODED (0xfL<<0) 2424#define BNX2_CTX_ACCESS_STATUS_MASTERENCODED (0xfL<<0)
1375#define BNX2_CTX_ACCESS_STATUS_ACCESSMEMORYSM (0x3L<<10) 2425#define BNX2_CTX_ACCESS_STATUS_ACCESSMEMORYSM (0x3L<<10)
1376#define BNX2_CTX_ACCESS_STATUS_PAGETABLEINITSM (0x3L<<12) 2426#define BNX2_CTX_ACCESS_STATUS_PAGETABLEINITSM (0x3L<<12)
1377#define BNX2_CTX_ACCESS_STATUS_ACCESSMEMORYINITSM (0x3L<<14) 2427#define BNX2_CTX_ACCESS_STATUS_ACCESSMEMORYINITSM (0x3L<<14)
1378#define BNX2_CTX_ACCESS_STATUS_QUALIFIED_REQUEST (0x7ffL<<17) 2428#define BNX2_CTX_ACCESS_STATUS_QUALIFIED_REQUEST (0x7ffL<<17)
2429#define BNX2_CTX_ACCESS_STATUS_CAMMASTERENCODED_XI (0x1fL<<0)
2430#define BNX2_CTX_ACCESS_STATUS_CACHEMASTERENCODED_XI (0x1fL<<5)
2431#define BNX2_CTX_ACCESS_STATUS_REQUEST_XI (0x3fffffL<<10)
1379 2432
1380#define BNX2_CTX_DBG_LOCK_STATUS 0x00001044 2433#define BNX2_CTX_DBG_LOCK_STATUS 0x00001044
1381#define BNX2_CTX_DBG_LOCK_STATUS_SM (0x3ffL<<0) 2434#define BNX2_CTX_DBG_LOCK_STATUS_SM (0x3ffL<<0)
1382#define BNX2_CTX_DBG_LOCK_STATUS_MATCH (0x3ffL<<22) 2435#define BNX2_CTX_DBG_LOCK_STATUS_MATCH (0x3ffL<<22)
1383 2436
2437#define BNX2_CTX_CACHE_CTRL_STATUS 0x00001048
2438#define BNX2_CTX_CACHE_CTRL_STATUS_RFIFO_OVERFLOW (1L<<0)
2439#define BNX2_CTX_CACHE_CTRL_STATUS_INVALID_READ_COMP (1L<<1)
2440#define BNX2_CTX_CACHE_CTRL_STATUS_FLUSH_START (1L<<6)
2441#define BNX2_CTX_CACHE_CTRL_STATUS_FREE_ENTRY_CNT (0x3fL<<7)
2442#define BNX2_CTX_CACHE_CTRL_STATUS_CACHE_ENTRY_NEEDED (0x3fL<<13)
2443#define BNX2_CTX_CACHE_CTRL_STATUS_RD_CHAN0_ACTIVE (1L<<19)
2444#define BNX2_CTX_CACHE_CTRL_STATUS_RD_CHAN1_ACTIVE (1L<<20)
2445#define BNX2_CTX_CACHE_CTRL_STATUS_RD_CHAN2_ACTIVE (1L<<21)
2446#define BNX2_CTX_CACHE_CTRL_STATUS_RD_CHAN3_ACTIVE (1L<<22)
2447#define BNX2_CTX_CACHE_CTRL_STATUS_RD_CHAN4_ACTIVE (1L<<23)
2448#define BNX2_CTX_CACHE_CTRL_STATUS_RD_CHAN5_ACTIVE (1L<<24)
2449#define BNX2_CTX_CACHE_CTRL_STATUS_RD_CHAN6_ACTIVE (1L<<25)
2450#define BNX2_CTX_CACHE_CTRL_STATUS_RD_CHAN7_ACTIVE (1L<<26)
2451#define BNX2_CTX_CACHE_CTRL_STATUS_RD_CHAN8_ACTIVE (1L<<27)
2452#define BNX2_CTX_CACHE_CTRL_STATUS_RD_CHAN9_ACTIVE (1L<<28)
2453#define BNX2_CTX_CACHE_CTRL_STATUS_RD_CHAN10_ACTIVE (1L<<29)
2454
2455#define BNX2_CTX_CACHE_CTRL_SM_STATUS 0x0000104c
2456#define BNX2_CTX_CACHE_CTRL_SM_STATUS_CS_DWC (0x7L<<0)
2457#define BNX2_CTX_CACHE_CTRL_SM_STATUS_CS_WFIFOC (0x7L<<3)
2458#define BNX2_CTX_CACHE_CTRL_SM_STATUS_CS_RTAGC (0x7L<<6)
2459#define BNX2_CTX_CACHE_CTRL_SM_STATUS_CS_RFIFOC (0x7L<<9)
2460#define BNX2_CTX_CACHE_CTRL_SM_STATUS_INVALID_BLK_ADDR (0x7fffL<<16)
2461
2462#define BNX2_CTX_CACHE_STATUS 0x00001050
2463#define BNX2_CTX_CACHE_STATUS_HELD_ENTRIES (0x3ffL<<0)
2464#define BNX2_CTX_CACHE_STATUS_MAX_HELD_ENTRIES (0x3ffL<<16)
2465
2466#define BNX2_CTX_DMA_STATUS 0x00001054
2467#define BNX2_CTX_DMA_STATUS_RD_CHAN0_STATUS (0x3L<<0)
2468#define BNX2_CTX_DMA_STATUS_RD_CHAN1_STATUS (0x3L<<2)
2469#define BNX2_CTX_DMA_STATUS_RD_CHAN2_STATUS (0x3L<<4)
2470#define BNX2_CTX_DMA_STATUS_RD_CHAN3_STATUS (0x3L<<6)
2471#define BNX2_CTX_DMA_STATUS_RD_CHAN4_STATUS (0x3L<<8)
2472#define BNX2_CTX_DMA_STATUS_RD_CHAN5_STATUS (0x3L<<10)
2473#define BNX2_CTX_DMA_STATUS_RD_CHAN6_STATUS (0x3L<<12)
2474#define BNX2_CTX_DMA_STATUS_RD_CHAN7_STATUS (0x3L<<14)
2475#define BNX2_CTX_DMA_STATUS_RD_CHAN8_STATUS (0x3L<<16)
2476#define BNX2_CTX_DMA_STATUS_RD_CHAN9_STATUS (0x3L<<18)
2477#define BNX2_CTX_DMA_STATUS_RD_CHAN10_STATUS (0x3L<<20)
2478
2479#define BNX2_CTX_REP_STATUS 0x00001058
2480#define BNX2_CTX_REP_STATUS_ERROR_ENTRY (0x3ffL<<0)
2481#define BNX2_CTX_REP_STATUS_ERROR_CLIENT_ID (0x1fL<<10)
2482#define BNX2_CTX_REP_STATUS_USAGE_CNT_MAX_ERR (1L<<16)
2483#define BNX2_CTX_REP_STATUS_USAGE_CNT_MIN_ERR (1L<<17)
2484#define BNX2_CTX_REP_STATUS_USAGE_CNT_MISS_ERR (1L<<18)
2485
2486#define BNX2_CTX_CKSUM_ERROR_STATUS 0x0000105c
2487#define BNX2_CTX_CKSUM_ERROR_STATUS_CALCULATED (0xffffL<<0)
2488#define BNX2_CTX_CKSUM_ERROR_STATUS_EXPECTED (0xffffL<<16)
2489
1384#define BNX2_CTX_CHNL_LOCK_STATUS_0 0x00001080 2490#define BNX2_CTX_CHNL_LOCK_STATUS_0 0x00001080
1385#define BNX2_CTX_CHNL_LOCK_STATUS_0_CID (0x3fffL<<0) 2491#define BNX2_CTX_CHNL_LOCK_STATUS_0_CID (0x3fffL<<0)
1386#define BNX2_CTX_CHNL_LOCK_STATUS_0_TYPE (0x3L<<14) 2492#define BNX2_CTX_CHNL_LOCK_STATUS_0_TYPE (0x3L<<14)
1387#define BNX2_CTX_CHNL_LOCK_STATUS_0_MODE (1L<<16) 2493#define BNX2_CTX_CHNL_LOCK_STATUS_0_MODE (1L<<16)
2494#define BNX2_CTX_CHNL_LOCK_STATUS_0_MODE_XI (1L<<14)
2495#define BNX2_CTX_CHNL_LOCK_STATUS_0_TYPE_XI (0x7L<<15)
1388 2496
1389#define BNX2_CTX_CHNL_LOCK_STATUS_1 0x00001084 2497#define BNX2_CTX_CHNL_LOCK_STATUS_1 0x00001084
1390#define BNX2_CTX_CHNL_LOCK_STATUS_2 0x00001088 2498#define BNX2_CTX_CHNL_LOCK_STATUS_2 0x00001088
@@ -1394,6 +2502,26 @@ struct l2_fhdr {
1394#define BNX2_CTX_CHNL_LOCK_STATUS_6 0x00001098 2502#define BNX2_CTX_CHNL_LOCK_STATUS_6 0x00001098
1395#define BNX2_CTX_CHNL_LOCK_STATUS_7 0x0000109c 2503#define BNX2_CTX_CHNL_LOCK_STATUS_7 0x0000109c
1396#define BNX2_CTX_CHNL_LOCK_STATUS_8 0x000010a0 2504#define BNX2_CTX_CHNL_LOCK_STATUS_8 0x000010a0
2505#define BNX2_CTX_CHNL_LOCK_STATUS_9 0x000010a4
2506
2507#define BNX2_CTX_CACHE_DATA 0x000010c4
2508#define BNX2_CTX_HOST_PAGE_TBL_CTRL 0x000010c8
2509#define BNX2_CTX_HOST_PAGE_TBL_CTRL_PAGE_TBL_ADDR (0x1ffL<<0)
2510#define BNX2_CTX_HOST_PAGE_TBL_CTRL_WRITE_REQ (1L<<30)
2511#define BNX2_CTX_HOST_PAGE_TBL_CTRL_READ_REQ (1L<<31)
2512
2513#define BNX2_CTX_HOST_PAGE_TBL_DATA0 0x000010cc
2514#define BNX2_CTX_HOST_PAGE_TBL_DATA0_VALID (1L<<0)
2515#define BNX2_CTX_HOST_PAGE_TBL_DATA0_VALUE (0xffffffL<<8)
2516
2517#define BNX2_CTX_HOST_PAGE_TBL_DATA1 0x000010d0
2518#define BNX2_CTX_CAM_CTRL 0x000010d4
2519#define BNX2_CTX_CAM_CTRL_CAM_ADDR (0x3ffL<<0)
2520#define BNX2_CTX_CAM_CTRL_RESET (1L<<27)
2521#define BNX2_CTX_CAM_CTRL_INVALIDATE (1L<<28)
2522#define BNX2_CTX_CAM_CTRL_SEARCH (1L<<29)
2523#define BNX2_CTX_CAM_CTRL_WRITE_REQ (1L<<30)
2524#define BNX2_CTX_CAM_CTRL_READ_REQ (1L<<31)
1397 2525
1398 2526
1399/* 2527/*
@@ -1407,14 +2535,16 @@ struct l2_fhdr {
1407#define BNX2_EMAC_MODE_PORT_NONE (0L<<2) 2535#define BNX2_EMAC_MODE_PORT_NONE (0L<<2)
1408#define BNX2_EMAC_MODE_PORT_MII (1L<<2) 2536#define BNX2_EMAC_MODE_PORT_MII (1L<<2)
1409#define BNX2_EMAC_MODE_PORT_GMII (2L<<2) 2537#define BNX2_EMAC_MODE_PORT_GMII (2L<<2)
1410#define BNX2_EMAC_MODE_PORT_MII_10 (3L<<2) 2538#define BNX2_EMAC_MODE_PORT_MII_10M (3L<<2)
1411#define BNX2_EMAC_MODE_MAC_LOOP (1L<<4) 2539#define BNX2_EMAC_MODE_MAC_LOOP (1L<<4)
1412#define BNX2_EMAC_MODE_25G (1L<<5) 2540#define BNX2_EMAC_MODE_25G_MODE (1L<<5)
1413#define BNX2_EMAC_MODE_TAGGED_MAC_CTL (1L<<7) 2541#define BNX2_EMAC_MODE_TAGGED_MAC_CTL (1L<<7)
1414#define BNX2_EMAC_MODE_TX_BURST (1L<<8) 2542#define BNX2_EMAC_MODE_TX_BURST (1L<<8)
1415#define BNX2_EMAC_MODE_MAX_DEFER_DROP_ENA (1L<<9) 2543#define BNX2_EMAC_MODE_MAX_DEFER_DROP_ENA (1L<<9)
1416#define BNX2_EMAC_MODE_EXT_LINK_POL (1L<<10) 2544#define BNX2_EMAC_MODE_EXT_LINK_POL (1L<<10)
1417#define BNX2_EMAC_MODE_FORCE_LINK (1L<<11) 2545#define BNX2_EMAC_MODE_FORCE_LINK (1L<<11)
2546#define BNX2_EMAC_MODE_SERDES_MODE (1L<<12)
2547#define BNX2_EMAC_MODE_BOND_OVRD (1L<<13)
1418#define BNX2_EMAC_MODE_MPKT (1L<<18) 2548#define BNX2_EMAC_MODE_MPKT (1L<<18)
1419#define BNX2_EMAC_MODE_MPKT_RCVD (1L<<19) 2549#define BNX2_EMAC_MODE_MPKT_RCVD (1L<<19)
1420#define BNX2_EMAC_MODE_ACPI_RCVD (1L<<20) 2550#define BNX2_EMAC_MODE_ACPI_RCVD (1L<<20)
@@ -1422,6 +2552,11 @@ struct l2_fhdr {
1422#define BNX2_EMAC_STATUS 0x00001404 2552#define BNX2_EMAC_STATUS 0x00001404
1423#define BNX2_EMAC_STATUS_LINK (1L<<11) 2553#define BNX2_EMAC_STATUS_LINK (1L<<11)
1424#define BNX2_EMAC_STATUS_LINK_CHANGE (1L<<12) 2554#define BNX2_EMAC_STATUS_LINK_CHANGE (1L<<12)
2555#define BNX2_EMAC_STATUS_SERDES_AUTONEG_COMPLETE (1L<<13)
2556#define BNX2_EMAC_STATUS_SERDES_AUTONEG_CHANGE (1L<<14)
2557#define BNX2_EMAC_STATUS_SERDES_NXT_PG_CHANGE (1L<<16)
2558#define BNX2_EMAC_STATUS_SERDES_RX_CONFIG_IS_0 (1L<<17)
2559#define BNX2_EMAC_STATUS_SERDES_RX_CONFIG_IS_0_CHANGE (1L<<18)
1425#define BNX2_EMAC_STATUS_MI_COMPLETE (1L<<22) 2560#define BNX2_EMAC_STATUS_MI_COMPLETE (1L<<22)
1426#define BNX2_EMAC_STATUS_MI_INT (1L<<23) 2561#define BNX2_EMAC_STATUS_MI_INT (1L<<23)
1427#define BNX2_EMAC_STATUS_AP_ERROR (1L<<24) 2562#define BNX2_EMAC_STATUS_AP_ERROR (1L<<24)
@@ -1429,6 +2564,9 @@ struct l2_fhdr {
1429 2564
1430#define BNX2_EMAC_ATTENTION_ENA 0x00001408 2565#define BNX2_EMAC_ATTENTION_ENA 0x00001408
1431#define BNX2_EMAC_ATTENTION_ENA_LINK (1L<<11) 2566#define BNX2_EMAC_ATTENTION_ENA_LINK (1L<<11)
2567#define BNX2_EMAC_ATTENTION_ENA_AUTONEG_CHANGE (1L<<14)
2568#define BNX2_EMAC_ATTENTION_ENA_NXT_PG_CHANGE (1L<<16)
2569#define BNX2_EMAC_ATTENTION_ENA_SERDES_RX_CONFIG_IS_0_CHANGE (1L<<18)
1432#define BNX2_EMAC_ATTENTION_ENA_MI_COMPLETE (1L<<22) 2570#define BNX2_EMAC_ATTENTION_ENA_MI_COMPLETE (1L<<22)
1433#define BNX2_EMAC_ATTENTION_ENA_MI_INT (1L<<23) 2571#define BNX2_EMAC_ATTENTION_ENA_MI_INT (1L<<23)
1434#define BNX2_EMAC_ATTENTION_ENA_AP_ERROR (1L<<24) 2572#define BNX2_EMAC_ATTENTION_ENA_AP_ERROR (1L<<24)
@@ -1445,6 +2583,13 @@ struct l2_fhdr {
1445#define BNX2_EMAC_LED_100MB (1L<<8) 2583#define BNX2_EMAC_LED_100MB (1L<<8)
1446#define BNX2_EMAC_LED_10MB (1L<<9) 2584#define BNX2_EMAC_LED_10MB (1L<<9)
1447#define BNX2_EMAC_LED_TRAFFIC_STAT (1L<<10) 2585#define BNX2_EMAC_LED_TRAFFIC_STAT (1L<<10)
2586#define BNX2_EMAC_LED_2500MB (1L<<11)
2587#define BNX2_EMAC_LED_2500MB_OVERRIDE (1L<<12)
2588#define BNX2_EMAC_LED_ACTIVITY_SEL (0x3L<<17)
2589#define BNX2_EMAC_LED_ACTIVITY_SEL_0 (0L<<17)
2590#define BNX2_EMAC_LED_ACTIVITY_SEL_1 (1L<<17)
2591#define BNX2_EMAC_LED_ACTIVITY_SEL_2 (2L<<17)
2592#define BNX2_EMAC_LED_ACTIVITY_SEL_3 (3L<<17)
1448#define BNX2_EMAC_LED_BLNK_RATE (0xfffL<<19) 2593#define BNX2_EMAC_LED_BLNK_RATE (0xfffL<<19)
1449#define BNX2_EMAC_LED_BLNK_RATE_ENA (1L<<31) 2594#define BNX2_EMAC_LED_BLNK_RATE_ENA (1L<<31)
1450 2595
@@ -1515,9 +2660,15 @@ struct l2_fhdr {
1515#define BNX2_EMAC_MDIO_COMM_PHY_ADDR (0x1fL<<21) 2660#define BNX2_EMAC_MDIO_COMM_PHY_ADDR (0x1fL<<21)
1516#define BNX2_EMAC_MDIO_COMM_COMMAND (0x3L<<26) 2661#define BNX2_EMAC_MDIO_COMM_COMMAND (0x3L<<26)
1517#define BNX2_EMAC_MDIO_COMM_COMMAND_UNDEFINED_0 (0L<<26) 2662#define BNX2_EMAC_MDIO_COMM_COMMAND_UNDEFINED_0 (0L<<26)
2663#define BNX2_EMAC_MDIO_COMM_COMMAND_ADDRESS (0L<<26)
1518#define BNX2_EMAC_MDIO_COMM_COMMAND_WRITE (1L<<26) 2664#define BNX2_EMAC_MDIO_COMM_COMMAND_WRITE (1L<<26)
1519#define BNX2_EMAC_MDIO_COMM_COMMAND_READ (2L<<26) 2665#define BNX2_EMAC_MDIO_COMM_COMMAND_READ (2L<<26)
2666#define BNX2_EMAC_MDIO_COMM_COMMAND_WRITE_22_XI (1L<<26)
2667#define BNX2_EMAC_MDIO_COMM_COMMAND_WRITE_45_XI (1L<<26)
2668#define BNX2_EMAC_MDIO_COMM_COMMAND_READ_22_XI (2L<<26)
2669#define BNX2_EMAC_MDIO_COMM_COMMAND_READ_INC_45_XI (2L<<26)
1520#define BNX2_EMAC_MDIO_COMM_COMMAND_UNDEFINED_3 (3L<<26) 2670#define BNX2_EMAC_MDIO_COMM_COMMAND_UNDEFINED_3 (3L<<26)
2671#define BNX2_EMAC_MDIO_COMM_COMMAND_READ_45 (3L<<26)
1521#define BNX2_EMAC_MDIO_COMM_FAIL (1L<<28) 2672#define BNX2_EMAC_MDIO_COMM_FAIL (1L<<28)
1522#define BNX2_EMAC_MDIO_COMM_START_BUSY (1L<<29) 2673#define BNX2_EMAC_MDIO_COMM_START_BUSY (1L<<29)
1523#define BNX2_EMAC_MDIO_COMM_DISEXT (1L<<30) 2674#define BNX2_EMAC_MDIO_COMM_DISEXT (1L<<30)
@@ -1534,13 +2685,17 @@ struct l2_fhdr {
1534#define BNX2_EMAC_MDIO_MODE_MDIO_OE (1L<<10) 2685#define BNX2_EMAC_MDIO_MODE_MDIO_OE (1L<<10)
1535#define BNX2_EMAC_MDIO_MODE_MDC (1L<<11) 2686#define BNX2_EMAC_MDIO_MODE_MDC (1L<<11)
1536#define BNX2_EMAC_MDIO_MODE_MDINT (1L<<12) 2687#define BNX2_EMAC_MDIO_MODE_MDINT (1L<<12)
2688#define BNX2_EMAC_MDIO_MODE_EXT_MDINT (1L<<13)
1537#define BNX2_EMAC_MDIO_MODE_CLOCK_CNT (0x1fL<<16) 2689#define BNX2_EMAC_MDIO_MODE_CLOCK_CNT (0x1fL<<16)
2690#define BNX2_EMAC_MDIO_MODE_CLOCK_CNT_XI (0x3fL<<16)
2691#define BNX2_EMAC_MDIO_MODE_CLAUSE_45_XI (1L<<31)
1538 2692
1539#define BNX2_EMAC_MDIO_AUTO_STATUS 0x000014b8 2693#define BNX2_EMAC_MDIO_AUTO_STATUS 0x000014b8
1540#define BNX2_EMAC_MDIO_AUTO_STATUS_AUTO_ERR (1L<<0) 2694#define BNX2_EMAC_MDIO_AUTO_STATUS_AUTO_ERR (1L<<0)
1541 2695
1542#define BNX2_EMAC_TX_MODE 0x000014bc 2696#define BNX2_EMAC_TX_MODE 0x000014bc
1543#define BNX2_EMAC_TX_MODE_RESET (1L<<0) 2697#define BNX2_EMAC_TX_MODE_RESET (1L<<0)
2698#define BNX2_EMAC_TX_MODE_CS16_TEST (1L<<2)
1544#define BNX2_EMAC_TX_MODE_EXT_PAUSE_EN (1L<<3) 2699#define BNX2_EMAC_TX_MODE_EXT_PAUSE_EN (1L<<3)
1545#define BNX2_EMAC_TX_MODE_FLOW_EN (1L<<4) 2700#define BNX2_EMAC_TX_MODE_FLOW_EN (1L<<4)
1546#define BNX2_EMAC_TX_MODE_BIG_BACKOFF (1L<<5) 2701#define BNX2_EMAC_TX_MODE_BIG_BACKOFF (1L<<5)
@@ -1553,6 +2708,7 @@ struct l2_fhdr {
1553#define BNX2_EMAC_TX_STATUS_XON_SENT (1L<<2) 2708#define BNX2_EMAC_TX_STATUS_XON_SENT (1L<<2)
1554#define BNX2_EMAC_TX_STATUS_LINK_UP (1L<<3) 2709#define BNX2_EMAC_TX_STATUS_LINK_UP (1L<<3)
1555#define BNX2_EMAC_TX_STATUS_UNDERRUN (1L<<4) 2710#define BNX2_EMAC_TX_STATUS_UNDERRUN (1L<<4)
2711#define BNX2_EMAC_TX_STATUS_CS16_ERROR (1L<<5)
1556 2712
1557#define BNX2_EMAC_TX_LENGTHS 0x000014c4 2713#define BNX2_EMAC_TX_LENGTHS 0x000014c4
1558#define BNX2_EMAC_TX_LENGTHS_SLOT (0xffL<<0) 2714#define BNX2_EMAC_TX_LENGTHS_SLOT (0xffL<<0)
@@ -1586,6 +2742,10 @@ struct l2_fhdr {
1586#define BNX2_EMAC_MULTICAST_HASH5 0x000014e4 2742#define BNX2_EMAC_MULTICAST_HASH5 0x000014e4
1587#define BNX2_EMAC_MULTICAST_HASH6 0x000014e8 2743#define BNX2_EMAC_MULTICAST_HASH6 0x000014e8
1588#define BNX2_EMAC_MULTICAST_HASH7 0x000014ec 2744#define BNX2_EMAC_MULTICAST_HASH7 0x000014ec
2745#define BNX2_EMAC_CKSUM_ERROR_STATUS 0x000014f0
2746#define BNX2_EMAC_CKSUM_ERROR_STATUS_CALCULATED (0xffffL<<0)
2747#define BNX2_EMAC_CKSUM_ERROR_STATUS_EXPECTED (0xffffL<<16)
2748
1589#define BNX2_EMAC_RX_STAT_IFHCINOCTETS 0x00001500 2749#define BNX2_EMAC_RX_STAT_IFHCINOCTETS 0x00001500
1590#define BNX2_EMAC_RX_STAT_IFHCINBADOCTETS 0x00001504 2750#define BNX2_EMAC_RX_STAT_IFHCINBADOCTETS 0x00001504
1591#define BNX2_EMAC_RX_STAT_ETHERSTATSFRAGMENTS 0x00001508 2751#define BNX2_EMAC_RX_STAT_ETHERSTATSFRAGMENTS 0x00001508
@@ -1608,7 +2768,7 @@ struct l2_fhdr {
1608#define BNX2_EMAC_RX_STAT_ETHERSTATSPKTS256OCTETSTO511OCTETS 0x0000154c 2768#define BNX2_EMAC_RX_STAT_ETHERSTATSPKTS256OCTETSTO511OCTETS 0x0000154c
1609#define BNX2_EMAC_RX_STAT_ETHERSTATSPKTS512OCTETSTO1023OCTETS 0x00001550 2769#define BNX2_EMAC_RX_STAT_ETHERSTATSPKTS512OCTETSTO1023OCTETS 0x00001550
1610#define BNX2_EMAC_RX_STAT_ETHERSTATSPKTS1024OCTETSTO1522OCTETS 0x00001554 2770#define BNX2_EMAC_RX_STAT_ETHERSTATSPKTS1024OCTETSTO1522OCTETS 0x00001554
1611#define BNX2_EMAC_RX_STAT_ETHERSTATSPKTS1523OCTETSTO9022OCTETS 0x00001558 2771#define BNX2_EMAC_RX_STAT_ETHERSTATSPKTSOVER1522OCTETS 0x00001558
1612#define BNX2_EMAC_RXMAC_DEBUG0 0x0000155c 2772#define BNX2_EMAC_RXMAC_DEBUG0 0x0000155c
1613#define BNX2_EMAC_RXMAC_DEBUG1 0x00001560 2773#define BNX2_EMAC_RXMAC_DEBUG1 0x00001560
1614#define BNX2_EMAC_RXMAC_DEBUG1_LENGTH_NE_BYTE_COUNT (1L<<0) 2774#define BNX2_EMAC_RXMAC_DEBUG1_LENGTH_NE_BYTE_COUNT (1L<<0)
@@ -1661,9 +2821,9 @@ struct l2_fhdr {
1661#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_UMAC2 (0x1L<<16) 2821#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_UMAC2 (0x1L<<16)
1662#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_UMAC3 (0x2L<<16) 2822#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_UMAC3 (0x2L<<16)
1663#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_UNI (0x3L<<16) 2823#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_UNI (0x3L<<16)
1664#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_MMAC2 (0x7L<<16)
1665#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_MMAC3 (0x5L<<16) 2824#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_MMAC3 (0x5L<<16)
1666#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_PSA1 (0x6L<<16) 2825#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_PSA1 (0x6L<<16)
2826#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_MMAC2 (0x7L<<16)
1667#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_PSA2 (0x7L<<16) 2827#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_PSA2 (0x7L<<16)
1668#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_PSA3 (0x8L<<16) 2828#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_PSA3 (0x8L<<16)
1669#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_MC2 (0x9L<<16) 2829#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_MC2 (0x9L<<16)
@@ -1701,7 +2861,7 @@ struct l2_fhdr {
1701#define BNX2_EMAC_RXMAC_DEBUG4_SLOT_FILLED (1L<<23) 2861#define BNX2_EMAC_RXMAC_DEBUG4_SLOT_FILLED (1L<<23)
1702#define BNX2_EMAC_RXMAC_DEBUG4_FALSE_CARRIER (1L<<24) 2862#define BNX2_EMAC_RXMAC_DEBUG4_FALSE_CARRIER (1L<<24)
1703#define BNX2_EMAC_RXMAC_DEBUG4_LAST_DATA (1L<<25) 2863#define BNX2_EMAC_RXMAC_DEBUG4_LAST_DATA (1L<<25)
1704#define BNX2_EMAC_RXMAC_DEBUG4_sfd_FOUND (1L<<26) 2864#define BNX2_EMAC_RXMAC_DEBUG4_SFD_FOUND (1L<<26)
1705#define BNX2_EMAC_RXMAC_DEBUG4_ADVANCE (1L<<27) 2865#define BNX2_EMAC_RXMAC_DEBUG4_ADVANCE (1L<<27)
1706#define BNX2_EMAC_RXMAC_DEBUG4_START (1L<<28) 2866#define BNX2_EMAC_RXMAC_DEBUG4_START (1L<<28)
1707 2867
@@ -1733,6 +2893,7 @@ struct l2_fhdr {
1733#define BNX2_EMAC_RXMAC_DEBUG5_IDI_RPM_ACCEPT (1L<<19) 2893#define BNX2_EMAC_RXMAC_DEBUG5_IDI_RPM_ACCEPT (1L<<19)
1734#define BNX2_EMAC_RXMAC_DEBUG5_FMLEN (0xfffL<<20) 2894#define BNX2_EMAC_RXMAC_DEBUG5_FMLEN (0xfffL<<20)
1735 2895
2896#define BNX2_EMAC_RX_STAT_FALSECARRIERERRORS 0x00001574
1736#define BNX2_EMAC_RX_STAT_AC0 0x00001580 2897#define BNX2_EMAC_RX_STAT_AC0 0x00001580
1737#define BNX2_EMAC_RX_STAT_AC1 0x00001584 2898#define BNX2_EMAC_RX_STAT_AC1 0x00001584
1738#define BNX2_EMAC_RX_STAT_AC2 0x00001588 2899#define BNX2_EMAC_RX_STAT_AC2 0x00001588
@@ -1757,6 +2918,7 @@ struct l2_fhdr {
1757#define BNX2_EMAC_RX_STAT_AC21 0x000015d4 2918#define BNX2_EMAC_RX_STAT_AC21 0x000015d4
1758#define BNX2_EMAC_RX_STAT_AC22 0x000015d8 2919#define BNX2_EMAC_RX_STAT_AC22 0x000015d8
1759#define BNX2_EMAC_RXMAC_SUC_DBG_OVERRUNVEC 0x000015dc 2920#define BNX2_EMAC_RXMAC_SUC_DBG_OVERRUNVEC 0x000015dc
2921#define BNX2_EMAC_RX_STAT_AC_28 0x000015f4
1760#define BNX2_EMAC_TX_STAT_IFHCOUTOCTETS 0x00001600 2922#define BNX2_EMAC_TX_STAT_IFHCOUTOCTETS 0x00001600
1761#define BNX2_EMAC_TX_STAT_IFHCOUTBADOCTETS 0x00001604 2923#define BNX2_EMAC_TX_STAT_IFHCOUTBADOCTETS 0x00001604
1762#define BNX2_EMAC_TX_STAT_ETHERSTATSCOLLISIONS 0x00001608 2924#define BNX2_EMAC_TX_STAT_ETHERSTATSCOLLISIONS 0x00001608
@@ -1777,7 +2939,7 @@ struct l2_fhdr {
1777#define BNX2_EMAC_TX_STAT_ETHERSTATSPKTS256OCTETSTO511OCTETS 0x00001644 2939#define BNX2_EMAC_TX_STAT_ETHERSTATSPKTS256OCTETSTO511OCTETS 0x00001644
1778#define BNX2_EMAC_TX_STAT_ETHERSTATSPKTS512OCTETSTO1023OCTETS 0x00001648 2940#define BNX2_EMAC_TX_STAT_ETHERSTATSPKTS512OCTETSTO1023OCTETS 0x00001648
1779#define BNX2_EMAC_TX_STAT_ETHERSTATSPKTS1024OCTETSTO1522OCTETS 0x0000164c 2941#define BNX2_EMAC_TX_STAT_ETHERSTATSPKTS1024OCTETSTO1522OCTETS 0x0000164c
1780#define BNX2_EMAC_TX_STAT_ETHERSTATSPKTS1523OCTETSTO9022OCTETS 0x00001650 2942#define BNX2_EMAC_TX_STAT_ETHERSTATSPKTSOVER1522OCTETS 0x00001650
1781#define BNX2_EMAC_TX_STAT_DOT3STATSINTERNALMACTRANSMITERRORS 0x00001654 2943#define BNX2_EMAC_TX_STAT_DOT3STATSINTERNALMACTRANSMITERRORS 0x00001654
1782#define BNX2_EMAC_TXMAC_DEBUG0 0x00001658 2944#define BNX2_EMAC_TXMAC_DEBUG0 0x00001658
1783#define BNX2_EMAC_TXMAC_DEBUG1 0x0000165c 2945#define BNX2_EMAC_TXMAC_DEBUG1 0x0000165c
@@ -1843,16 +3005,16 @@ struct l2_fhdr {
1843#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_IDLE (0x0L<<16) 3005#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_IDLE (0x0L<<16)
1844#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_MCA1 (0x2L<<16) 3006#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_MCA1 (0x2L<<16)
1845#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_MCA2 (0x3L<<16) 3007#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_MCA2 (0x3L<<16)
3008#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_SRC3 (0x4L<<16)
3009#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_SRC2 (0x5L<<16)
1846#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_MCA3 (0x6L<<16) 3010#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_MCA3 (0x6L<<16)
1847#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_SRC1 (0x7L<<16) 3011#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_SRC1 (0x7L<<16)
1848#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_SRC2 (0x5L<<16)
1849#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_SRC3 (0x4L<<16)
1850#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_TYPE (0xcL<<16)
1851#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_CMD (0xeL<<16)
1852#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_TIME (0xaL<<16)
1853#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_CRC1 (0x8L<<16) 3012#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_CRC1 (0x8L<<16)
1854#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_CRC2 (0x9L<<16) 3013#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_CRC2 (0x9L<<16)
3014#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_TIME (0xaL<<16)
3015#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_TYPE (0xcL<<16)
1855#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_WAIT (0xdL<<16) 3016#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_WAIT (0xdL<<16)
3017#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_CMD (0xeL<<16)
1856#define BNX2_EMAC_TXMAC_DEBUG4_STATS0_VALID (1L<<20) 3018#define BNX2_EMAC_TXMAC_DEBUG4_STATS0_VALID (1L<<20)
1857#define BNX2_EMAC_TXMAC_DEBUG4_APPEND_CRC (1L<<21) 3019#define BNX2_EMAC_TXMAC_DEBUG4_APPEND_CRC (1L<<21)
1858#define BNX2_EMAC_TXMAC_DEBUG4_SLOT_FILLED (1L<<22) 3020#define BNX2_EMAC_TXMAC_DEBUG4_SLOT_FILLED (1L<<22)
@@ -1887,8 +3049,11 @@ struct l2_fhdr {
1887#define BNX2_EMAC_TX_STAT_AC18 0x000016c8 3049#define BNX2_EMAC_TX_STAT_AC18 0x000016c8
1888#define BNX2_EMAC_TX_STAT_AC19 0x000016cc 3050#define BNX2_EMAC_TX_STAT_AC19 0x000016cc
1889#define BNX2_EMAC_TX_STAT_AC20 0x000016d0 3051#define BNX2_EMAC_TX_STAT_AC20 0x000016d0
1890#define BNX2_EMAC_TX_STAT_AC21 0x000016d4
1891#define BNX2_EMAC_TXMAC_SUC_DBG_OVERRUNVEC 0x000016d8 3052#define BNX2_EMAC_TXMAC_SUC_DBG_OVERRUNVEC 0x000016d8
3053#define BNX2_EMAC_TX_RATE_LIMIT_CTRL 0x000016fc
3054#define BNX2_EMAC_TX_RATE_LIMIT_CTRL_TX_THROTTLE_INC (0x7fL<<0)
3055#define BNX2_EMAC_TX_RATE_LIMIT_CTRL_TX_THROTTLE_NUM (0x7fL<<16)
3056#define BNX2_EMAC_TX_RATE_LIMIT_CTRL_RATE_LIMITER_EN (1L<<31)
1892 3057
1893 3058
1894/* 3059/*
@@ -1909,8 +3074,15 @@ struct l2_fhdr {
1909#define BNX2_RPM_CONFIG_ACPI_KEEP (1L<<2) 3074#define BNX2_RPM_CONFIG_ACPI_KEEP (1L<<2)
1910#define BNX2_RPM_CONFIG_MP_KEEP (1L<<3) 3075#define BNX2_RPM_CONFIG_MP_KEEP (1L<<3)
1911#define BNX2_RPM_CONFIG_SORT_VECT_VAL (0xfL<<4) 3076#define BNX2_RPM_CONFIG_SORT_VECT_VAL (0xfL<<4)
3077#define BNX2_RPM_CONFIG_DISABLE_WOL_ASSERT (1L<<30)
1912#define BNX2_RPM_CONFIG_IGNORE_VLAN (1L<<31) 3078#define BNX2_RPM_CONFIG_IGNORE_VLAN (1L<<31)
1913 3079
3080#define BNX2_RPM_MGMT_PKT_CTRL 0x0000180c
3081#define BNX2_RPM_MGMT_PKT_CTRL_MGMT_SORT (0xfL<<0)
3082#define BNX2_RPM_MGMT_PKT_CTRL_MGMT_RULE (0xfL<<4)
3083#define BNX2_RPM_MGMT_PKT_CTRL_MGMT_DISCARD_EN (1L<<30)
3084#define BNX2_RPM_MGMT_PKT_CTRL_MGMT_EN (1L<<31)
3085
1914#define BNX2_RPM_VLAN_MATCH0 0x00001810 3086#define BNX2_RPM_VLAN_MATCH0 0x00001810
1915#define BNX2_RPM_VLAN_MATCH0_RPM_VLAN_MTCH0_VALUE (0xfffL<<0) 3087#define BNX2_RPM_VLAN_MATCH0_RPM_VLAN_MTCH0_VALUE (0xfffL<<0)
1916 3088
@@ -1931,6 +3103,7 @@ struct l2_fhdr {
1931#define BNX2_RPM_SORT_USER0_PROM_EN (1L<<19) 3103#define BNX2_RPM_SORT_USER0_PROM_EN (1L<<19)
1932#define BNX2_RPM_SORT_USER0_VLAN_EN (0xfL<<20) 3104#define BNX2_RPM_SORT_USER0_VLAN_EN (0xfL<<20)
1933#define BNX2_RPM_SORT_USER0_PROM_VLAN (1L<<24) 3105#define BNX2_RPM_SORT_USER0_PROM_VLAN (1L<<24)
3106#define BNX2_RPM_SORT_USER0_VLAN_NOTMATCH (1L<<25)
1934#define BNX2_RPM_SORT_USER0_ENA (1L<<31) 3107#define BNX2_RPM_SORT_USER0_ENA (1L<<31)
1935 3108
1936#define BNX2_RPM_SORT_USER1 0x00001824 3109#define BNX2_RPM_SORT_USER1 0x00001824
@@ -1968,11 +3141,187 @@ struct l2_fhdr {
1968#define BNX2_RPM_STAT_IFINFTQDISCARDS 0x00001848 3141#define BNX2_RPM_STAT_IFINFTQDISCARDS 0x00001848
1969#define BNX2_RPM_STAT_IFINMBUFDISCARD 0x0000184c 3142#define BNX2_RPM_STAT_IFINMBUFDISCARD 0x0000184c
1970#define BNX2_RPM_STAT_RULE_CHECKER_P4_HIT 0x00001850 3143#define BNX2_RPM_STAT_RULE_CHECKER_P4_HIT 0x00001850
3144#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION0 0x00001854
3145#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION0_NEXT_HEADER_LEN (0xffL<<0)
3146#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION0_NEXT_HEADER (0xffL<<16)
3147#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION0_NEXT_HEADER_LEN_TYPE (1L<<30)
3148#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION0_NEXT_HEADER_EN (1L<<31)
3149
3150#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION1 0x00001858
3151#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION1_NEXT_HEADER_LEN (0xffL<<0)
3152#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION1_NEXT_HEADER (0xffL<<16)
3153#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION1_NEXT_HEADER_LEN_TYPE (1L<<30)
3154#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION1_NEXT_HEADER_EN (1L<<31)
3155
3156#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION2 0x0000185c
3157#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION2_NEXT_HEADER_LEN (0xffL<<0)
3158#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION2_NEXT_HEADER (0xffL<<16)
3159#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION2_NEXT_HEADER_LEN_TYPE (1L<<30)
3160#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION2_NEXT_HEADER_EN (1L<<31)
3161
3162#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION3 0x00001860
3163#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION3_NEXT_HEADER_LEN (0xffL<<0)
3164#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION3_NEXT_HEADER (0xffL<<16)
3165#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION3_NEXT_HEADER_LEN_TYPE (1L<<30)
3166#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION3_NEXT_HEADER_EN (1L<<31)
3167
3168#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION4 0x00001864
3169#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION4_NEXT_HEADER_LEN (0xffL<<0)
3170#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION4_NEXT_HEADER (0xffL<<16)
3171#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION4_NEXT_HEADER_LEN_TYPE (1L<<30)
3172#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION4_NEXT_HEADER_EN (1L<<31)
3173
3174#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION5 0x00001868
3175#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION5_NEXT_HEADER_LEN (0xffL<<0)
3176#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION5_NEXT_HEADER (0xffL<<16)
3177#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION5_NEXT_HEADER_LEN_TYPE (1L<<30)
3178#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION5_NEXT_HEADER_EN (1L<<31)
3179
3180#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION6 0x0000186c
3181#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION6_NEXT_HEADER_LEN (0xffL<<0)
3182#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION6_NEXT_HEADER (0xffL<<16)
3183#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION6_NEXT_HEADER_LEN_TYPE (1L<<30)
3184#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION6_NEXT_HEADER_EN (1L<<31)
3185
3186#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION7 0x00001870
3187#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION7_NEXT_HEADER_LEN (0xffL<<0)
3188#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION7_NEXT_HEADER (0xffL<<16)
3189#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION7_NEXT_HEADER_LEN_TYPE (1L<<30)
3190#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION7_NEXT_HEADER_EN (1L<<31)
3191
1971#define BNX2_RPM_STAT_AC0 0x00001880 3192#define BNX2_RPM_STAT_AC0 0x00001880
1972#define BNX2_RPM_STAT_AC1 0x00001884 3193#define BNX2_RPM_STAT_AC1 0x00001884
1973#define BNX2_RPM_STAT_AC2 0x00001888 3194#define BNX2_RPM_STAT_AC2 0x00001888
1974#define BNX2_RPM_STAT_AC3 0x0000188c 3195#define BNX2_RPM_STAT_AC3 0x0000188c
1975#define BNX2_RPM_STAT_AC4 0x00001890 3196#define BNX2_RPM_STAT_AC4 0x00001890
3197#define BNX2_RPM_RC_CNTL_16 0x000018e0
3198#define BNX2_RPM_RC_CNTL_16_OFFSET (0xffL<<0)
3199#define BNX2_RPM_RC_CNTL_16_CLASS (0x7L<<8)
3200#define BNX2_RPM_RC_CNTL_16_PRIORITY (1L<<11)
3201#define BNX2_RPM_RC_CNTL_16_P4 (1L<<12)
3202#define BNX2_RPM_RC_CNTL_16_HDR_TYPE (0x7L<<13)
3203#define BNX2_RPM_RC_CNTL_16_HDR_TYPE_START (0L<<13)
3204#define BNX2_RPM_RC_CNTL_16_HDR_TYPE_IP (1L<<13)
3205#define BNX2_RPM_RC_CNTL_16_HDR_TYPE_TCP (2L<<13)
3206#define BNX2_RPM_RC_CNTL_16_HDR_TYPE_UDP (3L<<13)
3207#define BNX2_RPM_RC_CNTL_16_HDR_TYPE_DATA (4L<<13)
3208#define BNX2_RPM_RC_CNTL_16_HDR_TYPE_TCP_UDP (5L<<13)
3209#define BNX2_RPM_RC_CNTL_16_HDR_TYPE_ICMPV6 (6L<<13)
3210#define BNX2_RPM_RC_CNTL_16_COMP (0x3L<<16)
3211#define BNX2_RPM_RC_CNTL_16_COMP_EQUAL (0L<<16)
3212#define BNX2_RPM_RC_CNTL_16_COMP_NEQUAL (1L<<16)
3213#define BNX2_RPM_RC_CNTL_16_COMP_GREATER (2L<<16)
3214#define BNX2_RPM_RC_CNTL_16_COMP_LESS (3L<<16)
3215#define BNX2_RPM_RC_CNTL_16_MAP (1L<<18)
3216#define BNX2_RPM_RC_CNTL_16_SBIT (1L<<19)
3217#define BNX2_RPM_RC_CNTL_16_CMDSEL (0x1fL<<20)
3218#define BNX2_RPM_RC_CNTL_16_DISCARD (1L<<25)
3219#define BNX2_RPM_RC_CNTL_16_MASK (1L<<26)
3220#define BNX2_RPM_RC_CNTL_16_P1 (1L<<27)
3221#define BNX2_RPM_RC_CNTL_16_P2 (1L<<28)
3222#define BNX2_RPM_RC_CNTL_16_P3 (1L<<29)
3223#define BNX2_RPM_RC_CNTL_16_NBIT (1L<<30)
3224
3225#define BNX2_RPM_RC_VALUE_MASK_16 0x000018e4
3226#define BNX2_RPM_RC_VALUE_MASK_16_VALUE (0xffffL<<0)
3227#define BNX2_RPM_RC_VALUE_MASK_16_MASK (0xffffL<<16)
3228
3229#define BNX2_RPM_RC_CNTL_17 0x000018e8
3230#define BNX2_RPM_RC_CNTL_17_OFFSET (0xffL<<0)
3231#define BNX2_RPM_RC_CNTL_17_CLASS (0x7L<<8)
3232#define BNX2_RPM_RC_CNTL_17_PRIORITY (1L<<11)
3233#define BNX2_RPM_RC_CNTL_17_P4 (1L<<12)
3234#define BNX2_RPM_RC_CNTL_17_HDR_TYPE (0x7L<<13)
3235#define BNX2_RPM_RC_CNTL_17_HDR_TYPE_START (0L<<13)
3236#define BNX2_RPM_RC_CNTL_17_HDR_TYPE_IP (1L<<13)
3237#define BNX2_RPM_RC_CNTL_17_HDR_TYPE_TCP (2L<<13)
3238#define BNX2_RPM_RC_CNTL_17_HDR_TYPE_UDP (3L<<13)
3239#define BNX2_RPM_RC_CNTL_17_HDR_TYPE_DATA (4L<<13)
3240#define BNX2_RPM_RC_CNTL_17_HDR_TYPE_TCP_UDP (5L<<13)
3241#define BNX2_RPM_RC_CNTL_17_HDR_TYPE_ICMPV6 (6L<<13)
3242#define BNX2_RPM_RC_CNTL_17_COMP (0x3L<<16)
3243#define BNX2_RPM_RC_CNTL_17_COMP_EQUAL (0L<<16)
3244#define BNX2_RPM_RC_CNTL_17_COMP_NEQUAL (1L<<16)
3245#define BNX2_RPM_RC_CNTL_17_COMP_GREATER (2L<<16)
3246#define BNX2_RPM_RC_CNTL_17_COMP_LESS (3L<<16)
3247#define BNX2_RPM_RC_CNTL_17_MAP (1L<<18)
3248#define BNX2_RPM_RC_CNTL_17_SBIT (1L<<19)
3249#define BNX2_RPM_RC_CNTL_17_CMDSEL (0x1fL<<20)
3250#define BNX2_RPM_RC_CNTL_17_DISCARD (1L<<25)
3251#define BNX2_RPM_RC_CNTL_17_MASK (1L<<26)
3252#define BNX2_RPM_RC_CNTL_17_P1 (1L<<27)
3253#define BNX2_RPM_RC_CNTL_17_P2 (1L<<28)
3254#define BNX2_RPM_RC_CNTL_17_P3 (1L<<29)
3255#define BNX2_RPM_RC_CNTL_17_NBIT (1L<<30)
3256
3257#define BNX2_RPM_RC_VALUE_MASK_17 0x000018ec
3258#define BNX2_RPM_RC_VALUE_MASK_17_VALUE (0xffffL<<0)
3259#define BNX2_RPM_RC_VALUE_MASK_17_MASK (0xffffL<<16)
3260
3261#define BNX2_RPM_RC_CNTL_18 0x000018f0
3262#define BNX2_RPM_RC_CNTL_18_OFFSET (0xffL<<0)
3263#define BNX2_RPM_RC_CNTL_18_CLASS (0x7L<<8)
3264#define BNX2_RPM_RC_CNTL_18_PRIORITY (1L<<11)
3265#define BNX2_RPM_RC_CNTL_18_P4 (1L<<12)
3266#define BNX2_RPM_RC_CNTL_18_HDR_TYPE (0x7L<<13)
3267#define BNX2_RPM_RC_CNTL_18_HDR_TYPE_START (0L<<13)
3268#define BNX2_RPM_RC_CNTL_18_HDR_TYPE_IP (1L<<13)
3269#define BNX2_RPM_RC_CNTL_18_HDR_TYPE_TCP (2L<<13)
3270#define BNX2_RPM_RC_CNTL_18_HDR_TYPE_UDP (3L<<13)
3271#define BNX2_RPM_RC_CNTL_18_HDR_TYPE_DATA (4L<<13)
3272#define BNX2_RPM_RC_CNTL_18_HDR_TYPE_TCP_UDP (5L<<13)
3273#define BNX2_RPM_RC_CNTL_18_HDR_TYPE_ICMPV6 (6L<<13)
3274#define BNX2_RPM_RC_CNTL_18_COMP (0x3L<<16)
3275#define BNX2_RPM_RC_CNTL_18_COMP_EQUAL (0L<<16)
3276#define BNX2_RPM_RC_CNTL_18_COMP_NEQUAL (1L<<16)
3277#define BNX2_RPM_RC_CNTL_18_COMP_GREATER (2L<<16)
3278#define BNX2_RPM_RC_CNTL_18_COMP_LESS (3L<<16)
3279#define BNX2_RPM_RC_CNTL_18_MAP (1L<<18)
3280#define BNX2_RPM_RC_CNTL_18_SBIT (1L<<19)
3281#define BNX2_RPM_RC_CNTL_18_CMDSEL (0x1fL<<20)
3282#define BNX2_RPM_RC_CNTL_18_DISCARD (1L<<25)
3283#define BNX2_RPM_RC_CNTL_18_MASK (1L<<26)
3284#define BNX2_RPM_RC_CNTL_18_P1 (1L<<27)
3285#define BNX2_RPM_RC_CNTL_18_P2 (1L<<28)
3286#define BNX2_RPM_RC_CNTL_18_P3 (1L<<29)
3287#define BNX2_RPM_RC_CNTL_18_NBIT (1L<<30)
3288
3289#define BNX2_RPM_RC_VALUE_MASK_18 0x000018f4
3290#define BNX2_RPM_RC_VALUE_MASK_18_VALUE (0xffffL<<0)
3291#define BNX2_RPM_RC_VALUE_MASK_18_MASK (0xffffL<<16)
3292
3293#define BNX2_RPM_RC_CNTL_19 0x000018f8
3294#define BNX2_RPM_RC_CNTL_19_OFFSET (0xffL<<0)
3295#define BNX2_RPM_RC_CNTL_19_CLASS (0x7L<<8)
3296#define BNX2_RPM_RC_CNTL_19_PRIORITY (1L<<11)
3297#define BNX2_RPM_RC_CNTL_19_P4 (1L<<12)
3298#define BNX2_RPM_RC_CNTL_19_HDR_TYPE (0x7L<<13)
3299#define BNX2_RPM_RC_CNTL_19_HDR_TYPE_START (0L<<13)
3300#define BNX2_RPM_RC_CNTL_19_HDR_TYPE_IP (1L<<13)
3301#define BNX2_RPM_RC_CNTL_19_HDR_TYPE_TCP (2L<<13)
3302#define BNX2_RPM_RC_CNTL_19_HDR_TYPE_UDP (3L<<13)
3303#define BNX2_RPM_RC_CNTL_19_HDR_TYPE_DATA (4L<<13)
3304#define BNX2_RPM_RC_CNTL_19_HDR_TYPE_TCP_UDP (5L<<13)
3305#define BNX2_RPM_RC_CNTL_19_HDR_TYPE_ICMPV6 (6L<<13)
3306#define BNX2_RPM_RC_CNTL_19_COMP (0x3L<<16)
3307#define BNX2_RPM_RC_CNTL_19_COMP_EQUAL (0L<<16)
3308#define BNX2_RPM_RC_CNTL_19_COMP_NEQUAL (1L<<16)
3309#define BNX2_RPM_RC_CNTL_19_COMP_GREATER (2L<<16)
3310#define BNX2_RPM_RC_CNTL_19_COMP_LESS (3L<<16)
3311#define BNX2_RPM_RC_CNTL_19_MAP (1L<<18)
3312#define BNX2_RPM_RC_CNTL_19_SBIT (1L<<19)
3313#define BNX2_RPM_RC_CNTL_19_CMDSEL (0x1fL<<20)
3314#define BNX2_RPM_RC_CNTL_19_DISCARD (1L<<25)
3315#define BNX2_RPM_RC_CNTL_19_MASK (1L<<26)
3316#define BNX2_RPM_RC_CNTL_19_P1 (1L<<27)
3317#define BNX2_RPM_RC_CNTL_19_P2 (1L<<28)
3318#define BNX2_RPM_RC_CNTL_19_P3 (1L<<29)
3319#define BNX2_RPM_RC_CNTL_19_NBIT (1L<<30)
3320
3321#define BNX2_RPM_RC_VALUE_MASK_19 0x000018fc
3322#define BNX2_RPM_RC_VALUE_MASK_19_VALUE (0xffffL<<0)
3323#define BNX2_RPM_RC_VALUE_MASK_19_MASK (0xffffL<<16)
3324
1976#define BNX2_RPM_RC_CNTL_0 0x00001900 3325#define BNX2_RPM_RC_CNTL_0 0x00001900
1977#define BNX2_RPM_RC_CNTL_0_OFFSET (0xffL<<0) 3326#define BNX2_RPM_RC_CNTL_0_OFFSET (0xffL<<0)
1978#define BNX2_RPM_RC_CNTL_0_CLASS (0x7L<<8) 3327#define BNX2_RPM_RC_CNTL_0_CLASS (0x7L<<8)
@@ -1984,14 +3333,18 @@ struct l2_fhdr {
1984#define BNX2_RPM_RC_CNTL_0_HDR_TYPE_TCP (2L<<13) 3333#define BNX2_RPM_RC_CNTL_0_HDR_TYPE_TCP (2L<<13)
1985#define BNX2_RPM_RC_CNTL_0_HDR_TYPE_UDP (3L<<13) 3334#define BNX2_RPM_RC_CNTL_0_HDR_TYPE_UDP (3L<<13)
1986#define BNX2_RPM_RC_CNTL_0_HDR_TYPE_DATA (4L<<13) 3335#define BNX2_RPM_RC_CNTL_0_HDR_TYPE_DATA (4L<<13)
3336#define BNX2_RPM_RC_CNTL_0_HDR_TYPE_TCP_UDP (5L<<13)
3337#define BNX2_RPM_RC_CNTL_0_HDR_TYPE_ICMPV6 (6L<<13)
1987#define BNX2_RPM_RC_CNTL_0_COMP (0x3L<<16) 3338#define BNX2_RPM_RC_CNTL_0_COMP (0x3L<<16)
1988#define BNX2_RPM_RC_CNTL_0_COMP_EQUAL (0L<<16) 3339#define BNX2_RPM_RC_CNTL_0_COMP_EQUAL (0L<<16)
1989#define BNX2_RPM_RC_CNTL_0_COMP_NEQUAL (1L<<16) 3340#define BNX2_RPM_RC_CNTL_0_COMP_NEQUAL (1L<<16)
1990#define BNX2_RPM_RC_CNTL_0_COMP_GREATER (2L<<16) 3341#define BNX2_RPM_RC_CNTL_0_COMP_GREATER (2L<<16)
1991#define BNX2_RPM_RC_CNTL_0_COMP_LESS (3L<<16) 3342#define BNX2_RPM_RC_CNTL_0_COMP_LESS (3L<<16)
3343#define BNX2_RPM_RC_CNTL_0_MAP_XI (1L<<18)
1992#define BNX2_RPM_RC_CNTL_0_SBIT (1L<<19) 3344#define BNX2_RPM_RC_CNTL_0_SBIT (1L<<19)
1993#define BNX2_RPM_RC_CNTL_0_CMDSEL (0xfL<<20) 3345#define BNX2_RPM_RC_CNTL_0_CMDSEL (0xfL<<20)
1994#define BNX2_RPM_RC_CNTL_0_MAP (1L<<24) 3346#define BNX2_RPM_RC_CNTL_0_MAP (1L<<24)
3347#define BNX2_RPM_RC_CNTL_0_CMDSEL_XI (0x1fL<<20)
1995#define BNX2_RPM_RC_CNTL_0_DISCARD (1L<<25) 3348#define BNX2_RPM_RC_CNTL_0_DISCARD (1L<<25)
1996#define BNX2_RPM_RC_CNTL_0_MASK (1L<<26) 3349#define BNX2_RPM_RC_CNTL_0_MASK (1L<<26)
1997#define BNX2_RPM_RC_CNTL_0_P1 (1L<<27) 3350#define BNX2_RPM_RC_CNTL_0_P1 (1L<<27)
@@ -2006,81 +3359,518 @@ struct l2_fhdr {
2006#define BNX2_RPM_RC_CNTL_1 0x00001908 3359#define BNX2_RPM_RC_CNTL_1 0x00001908
2007#define BNX2_RPM_RC_CNTL_1_A (0x3ffffL<<0) 3360#define BNX2_RPM_RC_CNTL_1_A (0x3ffffL<<0)
2008#define BNX2_RPM_RC_CNTL_1_B (0xfffL<<19) 3361#define BNX2_RPM_RC_CNTL_1_B (0xfffL<<19)
3362#define BNX2_RPM_RC_CNTL_1_OFFSET_XI (0xffL<<0)
3363#define BNX2_RPM_RC_CNTL_1_CLASS_XI (0x7L<<8)
3364#define BNX2_RPM_RC_CNTL_1_PRIORITY_XI (1L<<11)
3365#define BNX2_RPM_RC_CNTL_1_P4_XI (1L<<12)
3366#define BNX2_RPM_RC_CNTL_1_HDR_TYPE_XI (0x7L<<13)
3367#define BNX2_RPM_RC_CNTL_1_HDR_TYPE_START_XI (0L<<13)
3368#define BNX2_RPM_RC_CNTL_1_HDR_TYPE_IP_XI (1L<<13)
3369#define BNX2_RPM_RC_CNTL_1_HDR_TYPE_TCP_XI (2L<<13)
3370#define BNX2_RPM_RC_CNTL_1_HDR_TYPE_UDP_XI (3L<<13)
3371#define BNX2_RPM_RC_CNTL_1_HDR_TYPE_DATA_XI (4L<<13)
3372#define BNX2_RPM_RC_CNTL_1_HDR_TYPE_TCP_UDP_XI (5L<<13)
3373#define BNX2_RPM_RC_CNTL_1_HDR_TYPE_ICMPV6_XI (6L<<13)
3374#define BNX2_RPM_RC_CNTL_1_COMP_XI (0x3L<<16)
3375#define BNX2_RPM_RC_CNTL_1_COMP_EQUAL_XI (0L<<16)
3376#define BNX2_RPM_RC_CNTL_1_COMP_NEQUAL_XI (1L<<16)
3377#define BNX2_RPM_RC_CNTL_1_COMP_GREATER_XI (2L<<16)
3378#define BNX2_RPM_RC_CNTL_1_COMP_LESS_XI (3L<<16)
3379#define BNX2_RPM_RC_CNTL_1_MAP_XI (1L<<18)
3380#define BNX2_RPM_RC_CNTL_1_SBIT_XI (1L<<19)
3381#define BNX2_RPM_RC_CNTL_1_CMDSEL_XI (0x1fL<<20)
3382#define BNX2_RPM_RC_CNTL_1_DISCARD_XI (1L<<25)
3383#define BNX2_RPM_RC_CNTL_1_MASK_XI (1L<<26)
3384#define BNX2_RPM_RC_CNTL_1_P1_XI (1L<<27)
3385#define BNX2_RPM_RC_CNTL_1_P2_XI (1L<<28)
3386#define BNX2_RPM_RC_CNTL_1_P3_XI (1L<<29)
3387#define BNX2_RPM_RC_CNTL_1_NBIT_XI (1L<<30)
2009 3388
2010#define BNX2_RPM_RC_VALUE_MASK_1 0x0000190c 3389#define BNX2_RPM_RC_VALUE_MASK_1 0x0000190c
3390#define BNX2_RPM_RC_VALUE_MASK_1_VALUE (0xffffL<<0)
3391#define BNX2_RPM_RC_VALUE_MASK_1_MASK (0xffffL<<16)
3392
2011#define BNX2_RPM_RC_CNTL_2 0x00001910 3393#define BNX2_RPM_RC_CNTL_2 0x00001910
2012#define BNX2_RPM_RC_CNTL_2_A (0x3ffffL<<0) 3394#define BNX2_RPM_RC_CNTL_2_A (0x3ffffL<<0)
2013#define BNX2_RPM_RC_CNTL_2_B (0xfffL<<19) 3395#define BNX2_RPM_RC_CNTL_2_B (0xfffL<<19)
3396#define BNX2_RPM_RC_CNTL_2_OFFSET_XI (0xffL<<0)
3397#define BNX2_RPM_RC_CNTL_2_CLASS_XI (0x7L<<8)
3398#define BNX2_RPM_RC_CNTL_2_PRIORITY_XI (1L<<11)
3399#define BNX2_RPM_RC_CNTL_2_P4_XI (1L<<12)
3400#define BNX2_RPM_RC_CNTL_2_HDR_TYPE_XI (0x7L<<13)
3401#define BNX2_RPM_RC_CNTL_2_HDR_TYPE_START_XI (0L<<13)
3402#define BNX2_RPM_RC_CNTL_2_HDR_TYPE_IP_XI (1L<<13)
3403#define BNX2_RPM_RC_CNTL_2_HDR_TYPE_TCP_XI (2L<<13)
3404#define BNX2_RPM_RC_CNTL_2_HDR_TYPE_UDP_XI (3L<<13)
3405#define BNX2_RPM_RC_CNTL_2_HDR_TYPE_DATA_XI (4L<<13)
3406#define BNX2_RPM_RC_CNTL_2_HDR_TYPE_TCP_UDP_XI (5L<<13)
3407#define BNX2_RPM_RC_CNTL_2_HDR_TYPE_ICMPV6_XI (6L<<13)
3408#define BNX2_RPM_RC_CNTL_2_COMP_XI (0x3L<<16)
3409#define BNX2_RPM_RC_CNTL_2_COMP_EQUAL_XI (0L<<16)
3410#define BNX2_RPM_RC_CNTL_2_COMP_NEQUAL_XI (1L<<16)
3411#define BNX2_RPM_RC_CNTL_2_COMP_GREATER_XI (2L<<16)
3412#define BNX2_RPM_RC_CNTL_2_COMP_LESS_XI (3L<<16)
3413#define BNX2_RPM_RC_CNTL_2_MAP_XI (1L<<18)
3414#define BNX2_RPM_RC_CNTL_2_SBIT_XI (1L<<19)
3415#define BNX2_RPM_RC_CNTL_2_CMDSEL_XI (0x1fL<<20)
3416#define BNX2_RPM_RC_CNTL_2_DISCARD_XI (1L<<25)
3417#define BNX2_RPM_RC_CNTL_2_MASK_XI (1L<<26)
3418#define BNX2_RPM_RC_CNTL_2_P1_XI (1L<<27)
3419#define BNX2_RPM_RC_CNTL_2_P2_XI (1L<<28)
3420#define BNX2_RPM_RC_CNTL_2_P3_XI (1L<<29)
3421#define BNX2_RPM_RC_CNTL_2_NBIT_XI (1L<<30)
2014 3422
2015#define BNX2_RPM_RC_VALUE_MASK_2 0x00001914 3423#define BNX2_RPM_RC_VALUE_MASK_2 0x00001914
3424#define BNX2_RPM_RC_VALUE_MASK_2_VALUE (0xffffL<<0)
3425#define BNX2_RPM_RC_VALUE_MASK_2_MASK (0xffffL<<16)
3426
2016#define BNX2_RPM_RC_CNTL_3 0x00001918 3427#define BNX2_RPM_RC_CNTL_3 0x00001918
2017#define BNX2_RPM_RC_CNTL_3_A (0x3ffffL<<0) 3428#define BNX2_RPM_RC_CNTL_3_A (0x3ffffL<<0)
2018#define BNX2_RPM_RC_CNTL_3_B (0xfffL<<19) 3429#define BNX2_RPM_RC_CNTL_3_B (0xfffL<<19)
3430#define BNX2_RPM_RC_CNTL_3_OFFSET_XI (0xffL<<0)
3431#define BNX2_RPM_RC_CNTL_3_CLASS_XI (0x7L<<8)
3432#define BNX2_RPM_RC_CNTL_3_PRIORITY_XI (1L<<11)
3433#define BNX2_RPM_RC_CNTL_3_P4_XI (1L<<12)
3434#define BNX2_RPM_RC_CNTL_3_HDR_TYPE_XI (0x7L<<13)
3435#define BNX2_RPM_RC_CNTL_3_HDR_TYPE_START_XI (0L<<13)
3436#define BNX2_RPM_RC_CNTL_3_HDR_TYPE_IP_XI (1L<<13)
3437#define BNX2_RPM_RC_CNTL_3_HDR_TYPE_TCP_XI (2L<<13)
3438#define BNX2_RPM_RC_CNTL_3_HDR_TYPE_UDP_XI (3L<<13)
3439#define BNX2_RPM_RC_CNTL_3_HDR_TYPE_DATA_XI (4L<<13)
3440#define BNX2_RPM_RC_CNTL_3_HDR_TYPE_TCP_UDP_XI (5L<<13)
3441#define BNX2_RPM_RC_CNTL_3_HDR_TYPE_ICMPV6_XI (6L<<13)
3442#define BNX2_RPM_RC_CNTL_3_COMP_XI (0x3L<<16)
3443#define BNX2_RPM_RC_CNTL_3_COMP_EQUAL_XI (0L<<16)
3444#define BNX2_RPM_RC_CNTL_3_COMP_NEQUAL_XI (1L<<16)
3445#define BNX2_RPM_RC_CNTL_3_COMP_GREATER_XI (2L<<16)
3446#define BNX2_RPM_RC_CNTL_3_COMP_LESS_XI (3L<<16)
3447#define BNX2_RPM_RC_CNTL_3_MAP_XI (1L<<18)
3448#define BNX2_RPM_RC_CNTL_3_SBIT_XI (1L<<19)
3449#define BNX2_RPM_RC_CNTL_3_CMDSEL_XI (0x1fL<<20)
3450#define BNX2_RPM_RC_CNTL_3_DISCARD_XI (1L<<25)
3451#define BNX2_RPM_RC_CNTL_3_MASK_XI (1L<<26)
3452#define BNX2_RPM_RC_CNTL_3_P1_XI (1L<<27)
3453#define BNX2_RPM_RC_CNTL_3_P2_XI (1L<<28)
3454#define BNX2_RPM_RC_CNTL_3_P3_XI (1L<<29)
3455#define BNX2_RPM_RC_CNTL_3_NBIT_XI (1L<<30)
2019 3456
2020#define BNX2_RPM_RC_VALUE_MASK_3 0x0000191c 3457#define BNX2_RPM_RC_VALUE_MASK_3 0x0000191c
3458#define BNX2_RPM_RC_VALUE_MASK_3_VALUE (0xffffL<<0)
3459#define BNX2_RPM_RC_VALUE_MASK_3_MASK (0xffffL<<16)
3460
2021#define BNX2_RPM_RC_CNTL_4 0x00001920 3461#define BNX2_RPM_RC_CNTL_4 0x00001920
2022#define BNX2_RPM_RC_CNTL_4_A (0x3ffffL<<0) 3462#define BNX2_RPM_RC_CNTL_4_A (0x3ffffL<<0)
2023#define BNX2_RPM_RC_CNTL_4_B (0xfffL<<19) 3463#define BNX2_RPM_RC_CNTL_4_B (0xfffL<<19)
3464#define BNX2_RPM_RC_CNTL_4_OFFSET_XI (0xffL<<0)
3465#define BNX2_RPM_RC_CNTL_4_CLASS_XI (0x7L<<8)
3466#define BNX2_RPM_RC_CNTL_4_PRIORITY_XI (1L<<11)
3467#define BNX2_RPM_RC_CNTL_4_P4_XI (1L<<12)
3468#define BNX2_RPM_RC_CNTL_4_HDR_TYPE_XI (0x7L<<13)
3469#define BNX2_RPM_RC_CNTL_4_HDR_TYPE_START_XI (0L<<13)
3470#define BNX2_RPM_RC_CNTL_4_HDR_TYPE_IP_XI (1L<<13)
3471#define BNX2_RPM_RC_CNTL_4_HDR_TYPE_TCP_XI (2L<<13)
3472#define BNX2_RPM_RC_CNTL_4_HDR_TYPE_UDP_XI (3L<<13)
3473#define BNX2_RPM_RC_CNTL_4_HDR_TYPE_DATA_XI (4L<<13)
3474#define BNX2_RPM_RC_CNTL_4_HDR_TYPE_TCP_UDP_XI (5L<<13)
3475#define BNX2_RPM_RC_CNTL_4_HDR_TYPE_ICMPV6_XI (6L<<13)
3476#define BNX2_RPM_RC_CNTL_4_COMP_XI (0x3L<<16)
3477#define BNX2_RPM_RC_CNTL_4_COMP_EQUAL_XI (0L<<16)
3478#define BNX2_RPM_RC_CNTL_4_COMP_NEQUAL_XI (1L<<16)
3479#define BNX2_RPM_RC_CNTL_4_COMP_GREATER_XI (2L<<16)
3480#define BNX2_RPM_RC_CNTL_4_COMP_LESS_XI (3L<<16)
3481#define BNX2_RPM_RC_CNTL_4_MAP_XI (1L<<18)
3482#define BNX2_RPM_RC_CNTL_4_SBIT_XI (1L<<19)
3483#define BNX2_RPM_RC_CNTL_4_CMDSEL_XI (0x1fL<<20)
3484#define BNX2_RPM_RC_CNTL_4_DISCARD_XI (1L<<25)
3485#define BNX2_RPM_RC_CNTL_4_MASK_XI (1L<<26)
3486#define BNX2_RPM_RC_CNTL_4_P1_XI (1L<<27)
3487#define BNX2_RPM_RC_CNTL_4_P2_XI (1L<<28)
3488#define BNX2_RPM_RC_CNTL_4_P3_XI (1L<<29)
3489#define BNX2_RPM_RC_CNTL_4_NBIT_XI (1L<<30)
2024 3490
2025#define BNX2_RPM_RC_VALUE_MASK_4 0x00001924 3491#define BNX2_RPM_RC_VALUE_MASK_4 0x00001924
3492#define BNX2_RPM_RC_VALUE_MASK_4_VALUE (0xffffL<<0)
3493#define BNX2_RPM_RC_VALUE_MASK_4_MASK (0xffffL<<16)
3494
2026#define BNX2_RPM_RC_CNTL_5 0x00001928 3495#define BNX2_RPM_RC_CNTL_5 0x00001928
2027#define BNX2_RPM_RC_CNTL_5_A (0x3ffffL<<0) 3496#define BNX2_RPM_RC_CNTL_5_A (0x3ffffL<<0)
2028#define BNX2_RPM_RC_CNTL_5_B (0xfffL<<19) 3497#define BNX2_RPM_RC_CNTL_5_B (0xfffL<<19)
3498#define BNX2_RPM_RC_CNTL_5_OFFSET_XI (0xffL<<0)
3499#define BNX2_RPM_RC_CNTL_5_CLASS_XI (0x7L<<8)
3500#define BNX2_RPM_RC_CNTL_5_PRIORITY_XI (1L<<11)
3501#define BNX2_RPM_RC_CNTL_5_P4_XI (1L<<12)
3502#define BNX2_RPM_RC_CNTL_5_HDR_TYPE_XI (0x7L<<13)
3503#define BNX2_RPM_RC_CNTL_5_HDR_TYPE_START_XI (0L<<13)
3504#define BNX2_RPM_RC_CNTL_5_HDR_TYPE_IP_XI (1L<<13)
3505#define BNX2_RPM_RC_CNTL_5_HDR_TYPE_TCP_XI (2L<<13)
3506#define BNX2_RPM_RC_CNTL_5_HDR_TYPE_UDP_XI (3L<<13)
3507#define BNX2_RPM_RC_CNTL_5_HDR_TYPE_DATA_XI (4L<<13)
3508#define BNX2_RPM_RC_CNTL_5_HDR_TYPE_TCP_UDP_XI (5L<<13)
3509#define BNX2_RPM_RC_CNTL_5_HDR_TYPE_ICMPV6_XI (6L<<13)
3510#define BNX2_RPM_RC_CNTL_5_COMP_XI (0x3L<<16)
3511#define BNX2_RPM_RC_CNTL_5_COMP_EQUAL_XI (0L<<16)
3512#define BNX2_RPM_RC_CNTL_5_COMP_NEQUAL_XI (1L<<16)
3513#define BNX2_RPM_RC_CNTL_5_COMP_GREATER_XI (2L<<16)
3514#define BNX2_RPM_RC_CNTL_5_COMP_LESS_XI (3L<<16)
3515#define BNX2_RPM_RC_CNTL_5_MAP_XI (1L<<18)
3516#define BNX2_RPM_RC_CNTL_5_SBIT_XI (1L<<19)
3517#define BNX2_RPM_RC_CNTL_5_CMDSEL_XI (0x1fL<<20)
3518#define BNX2_RPM_RC_CNTL_5_DISCARD_XI (1L<<25)
3519#define BNX2_RPM_RC_CNTL_5_MASK_XI (1L<<26)
3520#define BNX2_RPM_RC_CNTL_5_P1_XI (1L<<27)
3521#define BNX2_RPM_RC_CNTL_5_P2_XI (1L<<28)
3522#define BNX2_RPM_RC_CNTL_5_P3_XI (1L<<29)
3523#define BNX2_RPM_RC_CNTL_5_NBIT_XI (1L<<30)
2029 3524
2030#define BNX2_RPM_RC_VALUE_MASK_5 0x0000192c 3525#define BNX2_RPM_RC_VALUE_MASK_5 0x0000192c
3526#define BNX2_RPM_RC_VALUE_MASK_5_VALUE (0xffffL<<0)
3527#define BNX2_RPM_RC_VALUE_MASK_5_MASK (0xffffL<<16)
3528
2031#define BNX2_RPM_RC_CNTL_6 0x00001930 3529#define BNX2_RPM_RC_CNTL_6 0x00001930
2032#define BNX2_RPM_RC_CNTL_6_A (0x3ffffL<<0) 3530#define BNX2_RPM_RC_CNTL_6_A (0x3ffffL<<0)
2033#define BNX2_RPM_RC_CNTL_6_B (0xfffL<<19) 3531#define BNX2_RPM_RC_CNTL_6_B (0xfffL<<19)
3532#define BNX2_RPM_RC_CNTL_6_OFFSET_XI (0xffL<<0)
3533#define BNX2_RPM_RC_CNTL_6_CLASS_XI (0x7L<<8)
3534#define BNX2_RPM_RC_CNTL_6_PRIORITY_XI (1L<<11)
3535#define BNX2_RPM_RC_CNTL_6_P4_XI (1L<<12)
3536#define BNX2_RPM_RC_CNTL_6_HDR_TYPE_XI (0x7L<<13)
3537#define BNX2_RPM_RC_CNTL_6_HDR_TYPE_START_XI (0L<<13)
3538#define BNX2_RPM_RC_CNTL_6_HDR_TYPE_IP_XI (1L<<13)
3539#define BNX2_RPM_RC_CNTL_6_HDR_TYPE_TCP_XI (2L<<13)
3540#define BNX2_RPM_RC_CNTL_6_HDR_TYPE_UDP_XI (3L<<13)
3541#define BNX2_RPM_RC_CNTL_6_HDR_TYPE_DATA_XI (4L<<13)
3542#define BNX2_RPM_RC_CNTL_6_HDR_TYPE_TCP_UDP_XI (5L<<13)
3543#define BNX2_RPM_RC_CNTL_6_HDR_TYPE_ICMPV6_XI (6L<<13)
3544#define BNX2_RPM_RC_CNTL_6_COMP_XI (0x3L<<16)
3545#define BNX2_RPM_RC_CNTL_6_COMP_EQUAL_XI (0L<<16)
3546#define BNX2_RPM_RC_CNTL_6_COMP_NEQUAL_XI (1L<<16)
3547#define BNX2_RPM_RC_CNTL_6_COMP_GREATER_XI (2L<<16)
3548#define BNX2_RPM_RC_CNTL_6_COMP_LESS_XI (3L<<16)
3549#define BNX2_RPM_RC_CNTL_6_MAP_XI (1L<<18)
3550#define BNX2_RPM_RC_CNTL_6_SBIT_XI (1L<<19)
3551#define BNX2_RPM_RC_CNTL_6_CMDSEL_XI (0x1fL<<20)
3552#define BNX2_RPM_RC_CNTL_6_DISCARD_XI (1L<<25)
3553#define BNX2_RPM_RC_CNTL_6_MASK_XI (1L<<26)
3554#define BNX2_RPM_RC_CNTL_6_P1_XI (1L<<27)
3555#define BNX2_RPM_RC_CNTL_6_P2_XI (1L<<28)
3556#define BNX2_RPM_RC_CNTL_6_P3_XI (1L<<29)
3557#define BNX2_RPM_RC_CNTL_6_NBIT_XI (1L<<30)
2034 3558
2035#define BNX2_RPM_RC_VALUE_MASK_6 0x00001934 3559#define BNX2_RPM_RC_VALUE_MASK_6 0x00001934
3560#define BNX2_RPM_RC_VALUE_MASK_6_VALUE (0xffffL<<0)
3561#define BNX2_RPM_RC_VALUE_MASK_6_MASK (0xffffL<<16)
3562
2036#define BNX2_RPM_RC_CNTL_7 0x00001938 3563#define BNX2_RPM_RC_CNTL_7 0x00001938
2037#define BNX2_RPM_RC_CNTL_7_A (0x3ffffL<<0) 3564#define BNX2_RPM_RC_CNTL_7_A (0x3ffffL<<0)
2038#define BNX2_RPM_RC_CNTL_7_B (0xfffL<<19) 3565#define BNX2_RPM_RC_CNTL_7_B (0xfffL<<19)
3566#define BNX2_RPM_RC_CNTL_7_OFFSET_XI (0xffL<<0)
3567#define BNX2_RPM_RC_CNTL_7_CLASS_XI (0x7L<<8)
3568#define BNX2_RPM_RC_CNTL_7_PRIORITY_XI (1L<<11)
3569#define BNX2_RPM_RC_CNTL_7_P4_XI (1L<<12)
3570#define BNX2_RPM_RC_CNTL_7_HDR_TYPE_XI (0x7L<<13)
3571#define BNX2_RPM_RC_CNTL_7_HDR_TYPE_START_XI (0L<<13)
3572#define BNX2_RPM_RC_CNTL_7_HDR_TYPE_IP_XI (1L<<13)
3573#define BNX2_RPM_RC_CNTL_7_HDR_TYPE_TCP_XI (2L<<13)
3574#define BNX2_RPM_RC_CNTL_7_HDR_TYPE_UDP_XI (3L<<13)
3575#define BNX2_RPM_RC_CNTL_7_HDR_TYPE_DATA_XI (4L<<13)
3576#define BNX2_RPM_RC_CNTL_7_HDR_TYPE_TCP_UDP_XI (5L<<13)
3577#define BNX2_RPM_RC_CNTL_7_HDR_TYPE_ICMPV6_XI (6L<<13)
3578#define BNX2_RPM_RC_CNTL_7_COMP_XI (0x3L<<16)
3579#define BNX2_RPM_RC_CNTL_7_COMP_EQUAL_XI (0L<<16)
3580#define BNX2_RPM_RC_CNTL_7_COMP_NEQUAL_XI (1L<<16)
3581#define BNX2_RPM_RC_CNTL_7_COMP_GREATER_XI (2L<<16)
3582#define BNX2_RPM_RC_CNTL_7_COMP_LESS_XI (3L<<16)
3583#define BNX2_RPM_RC_CNTL_7_MAP_XI (1L<<18)
3584#define BNX2_RPM_RC_CNTL_7_SBIT_XI (1L<<19)
3585#define BNX2_RPM_RC_CNTL_7_CMDSEL_XI (0x1fL<<20)
3586#define BNX2_RPM_RC_CNTL_7_DISCARD_XI (1L<<25)
3587#define BNX2_RPM_RC_CNTL_7_MASK_XI (1L<<26)
3588#define BNX2_RPM_RC_CNTL_7_P1_XI (1L<<27)
3589#define BNX2_RPM_RC_CNTL_7_P2_XI (1L<<28)
3590#define BNX2_RPM_RC_CNTL_7_P3_XI (1L<<29)
3591#define BNX2_RPM_RC_CNTL_7_NBIT_XI (1L<<30)
2039 3592
2040#define BNX2_RPM_RC_VALUE_MASK_7 0x0000193c 3593#define BNX2_RPM_RC_VALUE_MASK_7 0x0000193c
3594#define BNX2_RPM_RC_VALUE_MASK_7_VALUE (0xffffL<<0)
3595#define BNX2_RPM_RC_VALUE_MASK_7_MASK (0xffffL<<16)
3596
2041#define BNX2_RPM_RC_CNTL_8 0x00001940 3597#define BNX2_RPM_RC_CNTL_8 0x00001940
2042#define BNX2_RPM_RC_CNTL_8_A (0x3ffffL<<0) 3598#define BNX2_RPM_RC_CNTL_8_A (0x3ffffL<<0)
2043#define BNX2_RPM_RC_CNTL_8_B (0xfffL<<19) 3599#define BNX2_RPM_RC_CNTL_8_B (0xfffL<<19)
3600#define BNX2_RPM_RC_CNTL_8_OFFSET_XI (0xffL<<0)
3601#define BNX2_RPM_RC_CNTL_8_CLASS_XI (0x7L<<8)
3602#define BNX2_RPM_RC_CNTL_8_PRIORITY_XI (1L<<11)
3603#define BNX2_RPM_RC_CNTL_8_P4_XI (1L<<12)
3604#define BNX2_RPM_RC_CNTL_8_HDR_TYPE_XI (0x7L<<13)
3605#define BNX2_RPM_RC_CNTL_8_HDR_TYPE_START_XI (0L<<13)
3606#define BNX2_RPM_RC_CNTL_8_HDR_TYPE_IP_XI (1L<<13)
3607#define BNX2_RPM_RC_CNTL_8_HDR_TYPE_TCP_XI (2L<<13)
3608#define BNX2_RPM_RC_CNTL_8_HDR_TYPE_UDP_XI (3L<<13)
3609#define BNX2_RPM_RC_CNTL_8_HDR_TYPE_DATA_XI (4L<<13)
3610#define BNX2_RPM_RC_CNTL_8_HDR_TYPE_TCP_UDP_XI (5L<<13)
3611#define BNX2_RPM_RC_CNTL_8_HDR_TYPE_ICMPV6_XI (6L<<13)
3612#define BNX2_RPM_RC_CNTL_8_COMP_XI (0x3L<<16)
3613#define BNX2_RPM_RC_CNTL_8_COMP_EQUAL_XI (0L<<16)
3614#define BNX2_RPM_RC_CNTL_8_COMP_NEQUAL_XI (1L<<16)
3615#define BNX2_RPM_RC_CNTL_8_COMP_GREATER_XI (2L<<16)
3616#define BNX2_RPM_RC_CNTL_8_COMP_LESS_XI (3L<<16)
3617#define BNX2_RPM_RC_CNTL_8_MAP_XI (1L<<18)
3618#define BNX2_RPM_RC_CNTL_8_SBIT_XI (1L<<19)
3619#define BNX2_RPM_RC_CNTL_8_CMDSEL_XI (0x1fL<<20)
3620#define BNX2_RPM_RC_CNTL_8_DISCARD_XI (1L<<25)
3621#define BNX2_RPM_RC_CNTL_8_MASK_XI (1L<<26)
3622#define BNX2_RPM_RC_CNTL_8_P1_XI (1L<<27)
3623#define BNX2_RPM_RC_CNTL_8_P2_XI (1L<<28)
3624#define BNX2_RPM_RC_CNTL_8_P3_XI (1L<<29)
3625#define BNX2_RPM_RC_CNTL_8_NBIT_XI (1L<<30)
2044 3626
2045#define BNX2_RPM_RC_VALUE_MASK_8 0x00001944 3627#define BNX2_RPM_RC_VALUE_MASK_8 0x00001944
3628#define BNX2_RPM_RC_VALUE_MASK_8_VALUE (0xffffL<<0)
3629#define BNX2_RPM_RC_VALUE_MASK_8_MASK (0xffffL<<16)
3630
2046#define BNX2_RPM_RC_CNTL_9 0x00001948 3631#define BNX2_RPM_RC_CNTL_9 0x00001948
2047#define BNX2_RPM_RC_CNTL_9_A (0x3ffffL<<0) 3632#define BNX2_RPM_RC_CNTL_9_A (0x3ffffL<<0)
2048#define BNX2_RPM_RC_CNTL_9_B (0xfffL<<19) 3633#define BNX2_RPM_RC_CNTL_9_B (0xfffL<<19)
3634#define BNX2_RPM_RC_CNTL_9_OFFSET_XI (0xffL<<0)
3635#define BNX2_RPM_RC_CNTL_9_CLASS_XI (0x7L<<8)
3636#define BNX2_RPM_RC_CNTL_9_PRIORITY_XI (1L<<11)
3637#define BNX2_RPM_RC_CNTL_9_P4_XI (1L<<12)
3638#define BNX2_RPM_RC_CNTL_9_HDR_TYPE_XI (0x7L<<13)
3639#define BNX2_RPM_RC_CNTL_9_HDR_TYPE_START_XI (0L<<13)
3640#define BNX2_RPM_RC_CNTL_9_HDR_TYPE_IP_XI (1L<<13)
3641#define BNX2_RPM_RC_CNTL_9_HDR_TYPE_TCP_XI (2L<<13)
3642#define BNX2_RPM_RC_CNTL_9_HDR_TYPE_UDP_XI (3L<<13)
3643#define BNX2_RPM_RC_CNTL_9_HDR_TYPE_DATA_XI (4L<<13)
3644#define BNX2_RPM_RC_CNTL_9_HDR_TYPE_TCP_UDP_XI (5L<<13)
3645#define BNX2_RPM_RC_CNTL_9_HDR_TYPE_ICMPV6_XI (6L<<13)
3646#define BNX2_RPM_RC_CNTL_9_COMP_XI (0x3L<<16)
3647#define BNX2_RPM_RC_CNTL_9_COMP_EQUAL_XI (0L<<16)
3648#define BNX2_RPM_RC_CNTL_9_COMP_NEQUAL_XI (1L<<16)
3649#define BNX2_RPM_RC_CNTL_9_COMP_GREATER_XI (2L<<16)
3650#define BNX2_RPM_RC_CNTL_9_COMP_LESS_XI (3L<<16)
3651#define BNX2_RPM_RC_CNTL_9_MAP_XI (1L<<18)
3652#define BNX2_RPM_RC_CNTL_9_SBIT_XI (1L<<19)
3653#define BNX2_RPM_RC_CNTL_9_CMDSEL_XI (0x1fL<<20)
3654#define BNX2_RPM_RC_CNTL_9_DISCARD_XI (1L<<25)
3655#define BNX2_RPM_RC_CNTL_9_MASK_XI (1L<<26)
3656#define BNX2_RPM_RC_CNTL_9_P1_XI (1L<<27)
3657#define BNX2_RPM_RC_CNTL_9_P2_XI (1L<<28)
3658#define BNX2_RPM_RC_CNTL_9_P3_XI (1L<<29)
3659#define BNX2_RPM_RC_CNTL_9_NBIT_XI (1L<<30)
2049 3660
2050#define BNX2_RPM_RC_VALUE_MASK_9 0x0000194c 3661#define BNX2_RPM_RC_VALUE_MASK_9 0x0000194c
3662#define BNX2_RPM_RC_VALUE_MASK_9_VALUE (0xffffL<<0)
3663#define BNX2_RPM_RC_VALUE_MASK_9_MASK (0xffffL<<16)
3664
2051#define BNX2_RPM_RC_CNTL_10 0x00001950 3665#define BNX2_RPM_RC_CNTL_10 0x00001950
2052#define BNX2_RPM_RC_CNTL_10_A (0x3ffffL<<0) 3666#define BNX2_RPM_RC_CNTL_10_A (0x3ffffL<<0)
2053#define BNX2_RPM_RC_CNTL_10_B (0xfffL<<19) 3667#define BNX2_RPM_RC_CNTL_10_B (0xfffL<<19)
3668#define BNX2_RPM_RC_CNTL_10_OFFSET_XI (0xffL<<0)
3669#define BNX2_RPM_RC_CNTL_10_CLASS_XI (0x7L<<8)
3670#define BNX2_RPM_RC_CNTL_10_PRIORITY_XI (1L<<11)
3671#define BNX2_RPM_RC_CNTL_10_P4_XI (1L<<12)
3672#define BNX2_RPM_RC_CNTL_10_HDR_TYPE_XI (0x7L<<13)
3673#define BNX2_RPM_RC_CNTL_10_HDR_TYPE_START_XI (0L<<13)
3674#define BNX2_RPM_RC_CNTL_10_HDR_TYPE_IP_XI (1L<<13)
3675#define BNX2_RPM_RC_CNTL_10_HDR_TYPE_TCP_XI (2L<<13)
3676#define BNX2_RPM_RC_CNTL_10_HDR_TYPE_UDP_XI (3L<<13)
3677#define BNX2_RPM_RC_CNTL_10_HDR_TYPE_DATA_XI (4L<<13)
3678#define BNX2_RPM_RC_CNTL_10_HDR_TYPE_TCP_UDP_XI (5L<<13)
3679#define BNX2_RPM_RC_CNTL_10_HDR_TYPE_ICMPV6_XI (6L<<13)
3680#define BNX2_RPM_RC_CNTL_10_COMP_XI (0x3L<<16)
3681#define BNX2_RPM_RC_CNTL_10_COMP_EQUAL_XI (0L<<16)
3682#define BNX2_RPM_RC_CNTL_10_COMP_NEQUAL_XI (1L<<16)
3683#define BNX2_RPM_RC_CNTL_10_COMP_GREATER_XI (2L<<16)
3684#define BNX2_RPM_RC_CNTL_10_COMP_LESS_XI (3L<<16)
3685#define BNX2_RPM_RC_CNTL_10_MAP_XI (1L<<18)
3686#define BNX2_RPM_RC_CNTL_10_SBIT_XI (1L<<19)
3687#define BNX2_RPM_RC_CNTL_10_CMDSEL_XI (0x1fL<<20)
3688#define BNX2_RPM_RC_CNTL_10_DISCARD_XI (1L<<25)
3689#define BNX2_RPM_RC_CNTL_10_MASK_XI (1L<<26)
3690#define BNX2_RPM_RC_CNTL_10_P1_XI (1L<<27)
3691#define BNX2_RPM_RC_CNTL_10_P2_XI (1L<<28)
3692#define BNX2_RPM_RC_CNTL_10_P3_XI (1L<<29)
3693#define BNX2_RPM_RC_CNTL_10_NBIT_XI (1L<<30)
2054 3694
2055#define BNX2_RPM_RC_VALUE_MASK_10 0x00001954 3695#define BNX2_RPM_RC_VALUE_MASK_10 0x00001954
3696#define BNX2_RPM_RC_VALUE_MASK_10_VALUE (0xffffL<<0)
3697#define BNX2_RPM_RC_VALUE_MASK_10_MASK (0xffffL<<16)
3698
2056#define BNX2_RPM_RC_CNTL_11 0x00001958 3699#define BNX2_RPM_RC_CNTL_11 0x00001958
2057#define BNX2_RPM_RC_CNTL_11_A (0x3ffffL<<0) 3700#define BNX2_RPM_RC_CNTL_11_A (0x3ffffL<<0)
2058#define BNX2_RPM_RC_CNTL_11_B (0xfffL<<19) 3701#define BNX2_RPM_RC_CNTL_11_B (0xfffL<<19)
3702#define BNX2_RPM_RC_CNTL_11_OFFSET_XI (0xffL<<0)
3703#define BNX2_RPM_RC_CNTL_11_CLASS_XI (0x7L<<8)
3704#define BNX2_RPM_RC_CNTL_11_PRIORITY_XI (1L<<11)
3705#define BNX2_RPM_RC_CNTL_11_P4_XI (1L<<12)
3706#define BNX2_RPM_RC_CNTL_11_HDR_TYPE_XI (0x7L<<13)
3707#define BNX2_RPM_RC_CNTL_11_HDR_TYPE_START_XI (0L<<13)
3708#define BNX2_RPM_RC_CNTL_11_HDR_TYPE_IP_XI (1L<<13)
3709#define BNX2_RPM_RC_CNTL_11_HDR_TYPE_TCP_XI (2L<<13)
3710#define BNX2_RPM_RC_CNTL_11_HDR_TYPE_UDP_XI (3L<<13)
3711#define BNX2_RPM_RC_CNTL_11_HDR_TYPE_DATA_XI (4L<<13)
3712#define BNX2_RPM_RC_CNTL_11_HDR_TYPE_TCP_UDP_XI (5L<<13)
3713#define BNX2_RPM_RC_CNTL_11_HDR_TYPE_ICMPV6_XI (6L<<13)
3714#define BNX2_RPM_RC_CNTL_11_COMP_XI (0x3L<<16)
3715#define BNX2_RPM_RC_CNTL_11_COMP_EQUAL_XI (0L<<16)
3716#define BNX2_RPM_RC_CNTL_11_COMP_NEQUAL_XI (1L<<16)
3717#define BNX2_RPM_RC_CNTL_11_COMP_GREATER_XI (2L<<16)
3718#define BNX2_RPM_RC_CNTL_11_COMP_LESS_XI (3L<<16)
3719#define BNX2_RPM_RC_CNTL_11_MAP_XI (1L<<18)
3720#define BNX2_RPM_RC_CNTL_11_SBIT_XI (1L<<19)
3721#define BNX2_RPM_RC_CNTL_11_CMDSEL_XI (0x1fL<<20)
3722#define BNX2_RPM_RC_CNTL_11_DISCARD_XI (1L<<25)
3723#define BNX2_RPM_RC_CNTL_11_MASK_XI (1L<<26)
3724#define BNX2_RPM_RC_CNTL_11_P1_XI (1L<<27)
3725#define BNX2_RPM_RC_CNTL_11_P2_XI (1L<<28)
3726#define BNX2_RPM_RC_CNTL_11_P3_XI (1L<<29)
3727#define BNX2_RPM_RC_CNTL_11_NBIT_XI (1L<<30)
2059 3728
2060#define BNX2_RPM_RC_VALUE_MASK_11 0x0000195c 3729#define BNX2_RPM_RC_VALUE_MASK_11 0x0000195c
3730#define BNX2_RPM_RC_VALUE_MASK_11_VALUE (0xffffL<<0)
3731#define BNX2_RPM_RC_VALUE_MASK_11_MASK (0xffffL<<16)
3732
2061#define BNX2_RPM_RC_CNTL_12 0x00001960 3733#define BNX2_RPM_RC_CNTL_12 0x00001960
2062#define BNX2_RPM_RC_CNTL_12_A (0x3ffffL<<0) 3734#define BNX2_RPM_RC_CNTL_12_A (0x3ffffL<<0)
2063#define BNX2_RPM_RC_CNTL_12_B (0xfffL<<19) 3735#define BNX2_RPM_RC_CNTL_12_B (0xfffL<<19)
3736#define BNX2_RPM_RC_CNTL_12_OFFSET_XI (0xffL<<0)
3737#define BNX2_RPM_RC_CNTL_12_CLASS_XI (0x7L<<8)
3738#define BNX2_RPM_RC_CNTL_12_PRIORITY_XI (1L<<11)
3739#define BNX2_RPM_RC_CNTL_12_P4_XI (1L<<12)
3740#define BNX2_RPM_RC_CNTL_12_HDR_TYPE_XI (0x7L<<13)
3741#define BNX2_RPM_RC_CNTL_12_HDR_TYPE_START_XI (0L<<13)
3742#define BNX2_RPM_RC_CNTL_12_HDR_TYPE_IP_XI (1L<<13)
3743#define BNX2_RPM_RC_CNTL_12_HDR_TYPE_TCP_XI (2L<<13)
3744#define BNX2_RPM_RC_CNTL_12_HDR_TYPE_UDP_XI (3L<<13)
3745#define BNX2_RPM_RC_CNTL_12_HDR_TYPE_DATA_XI (4L<<13)
3746#define BNX2_RPM_RC_CNTL_12_HDR_TYPE_TCP_UDP_XI (5L<<13)
3747#define BNX2_RPM_RC_CNTL_12_HDR_TYPE_ICMPV6_XI (6L<<13)
3748#define BNX2_RPM_RC_CNTL_12_COMP_XI (0x3L<<16)
3749#define BNX2_RPM_RC_CNTL_12_COMP_EQUAL_XI (0L<<16)
3750#define BNX2_RPM_RC_CNTL_12_COMP_NEQUAL_XI (1L<<16)
3751#define BNX2_RPM_RC_CNTL_12_COMP_GREATER_XI (2L<<16)
3752#define BNX2_RPM_RC_CNTL_12_COMP_LESS_XI (3L<<16)
3753#define BNX2_RPM_RC_CNTL_12_MAP_XI (1L<<18)
3754#define BNX2_RPM_RC_CNTL_12_SBIT_XI (1L<<19)
3755#define BNX2_RPM_RC_CNTL_12_CMDSEL_XI (0x1fL<<20)
3756#define BNX2_RPM_RC_CNTL_12_DISCARD_XI (1L<<25)
3757#define BNX2_RPM_RC_CNTL_12_MASK_XI (1L<<26)
3758#define BNX2_RPM_RC_CNTL_12_P1_XI (1L<<27)
3759#define BNX2_RPM_RC_CNTL_12_P2_XI (1L<<28)
3760#define BNX2_RPM_RC_CNTL_12_P3_XI (1L<<29)
3761#define BNX2_RPM_RC_CNTL_12_NBIT_XI (1L<<30)
2064 3762
2065#define BNX2_RPM_RC_VALUE_MASK_12 0x00001964 3763#define BNX2_RPM_RC_VALUE_MASK_12 0x00001964
3764#define BNX2_RPM_RC_VALUE_MASK_12_VALUE (0xffffL<<0)
3765#define BNX2_RPM_RC_VALUE_MASK_12_MASK (0xffffL<<16)
3766
2066#define BNX2_RPM_RC_CNTL_13 0x00001968 3767#define BNX2_RPM_RC_CNTL_13 0x00001968
2067#define BNX2_RPM_RC_CNTL_13_A (0x3ffffL<<0) 3768#define BNX2_RPM_RC_CNTL_13_A (0x3ffffL<<0)
2068#define BNX2_RPM_RC_CNTL_13_B (0xfffL<<19) 3769#define BNX2_RPM_RC_CNTL_13_B (0xfffL<<19)
3770#define BNX2_RPM_RC_CNTL_13_OFFSET_XI (0xffL<<0)
3771#define BNX2_RPM_RC_CNTL_13_CLASS_XI (0x7L<<8)
3772#define BNX2_RPM_RC_CNTL_13_PRIORITY_XI (1L<<11)
3773#define BNX2_RPM_RC_CNTL_13_P4_XI (1L<<12)
3774#define BNX2_RPM_RC_CNTL_13_HDR_TYPE_XI (0x7L<<13)
3775#define BNX2_RPM_RC_CNTL_13_HDR_TYPE_START_XI (0L<<13)
3776#define BNX2_RPM_RC_CNTL_13_HDR_TYPE_IP_XI (1L<<13)
3777#define BNX2_RPM_RC_CNTL_13_HDR_TYPE_TCP_XI (2L<<13)
3778#define BNX2_RPM_RC_CNTL_13_HDR_TYPE_UDP_XI (3L<<13)
3779#define BNX2_RPM_RC_CNTL_13_HDR_TYPE_DATA_XI (4L<<13)
3780#define BNX2_RPM_RC_CNTL_13_HDR_TYPE_TCP_UDP_XI (5L<<13)
3781#define BNX2_RPM_RC_CNTL_13_HDR_TYPE_ICMPV6_XI (6L<<13)
3782#define BNX2_RPM_RC_CNTL_13_COMP_XI (0x3L<<16)
3783#define BNX2_RPM_RC_CNTL_13_COMP_EQUAL_XI (0L<<16)
3784#define BNX2_RPM_RC_CNTL_13_COMP_NEQUAL_XI (1L<<16)
3785#define BNX2_RPM_RC_CNTL_13_COMP_GREATER_XI (2L<<16)
3786#define BNX2_RPM_RC_CNTL_13_COMP_LESS_XI (3L<<16)
3787#define BNX2_RPM_RC_CNTL_13_MAP_XI (1L<<18)
3788#define BNX2_RPM_RC_CNTL_13_SBIT_XI (1L<<19)
3789#define BNX2_RPM_RC_CNTL_13_CMDSEL_XI (0x1fL<<20)
3790#define BNX2_RPM_RC_CNTL_13_DISCARD_XI (1L<<25)
3791#define BNX2_RPM_RC_CNTL_13_MASK_XI (1L<<26)
3792#define BNX2_RPM_RC_CNTL_13_P1_XI (1L<<27)
3793#define BNX2_RPM_RC_CNTL_13_P2_XI (1L<<28)
3794#define BNX2_RPM_RC_CNTL_13_P3_XI (1L<<29)
3795#define BNX2_RPM_RC_CNTL_13_NBIT_XI (1L<<30)
2069 3796
2070#define BNX2_RPM_RC_VALUE_MASK_13 0x0000196c 3797#define BNX2_RPM_RC_VALUE_MASK_13 0x0000196c
3798#define BNX2_RPM_RC_VALUE_MASK_13_VALUE (0xffffL<<0)
3799#define BNX2_RPM_RC_VALUE_MASK_13_MASK (0xffffL<<16)
3800
2071#define BNX2_RPM_RC_CNTL_14 0x00001970 3801#define BNX2_RPM_RC_CNTL_14 0x00001970
2072#define BNX2_RPM_RC_CNTL_14_A (0x3ffffL<<0) 3802#define BNX2_RPM_RC_CNTL_14_A (0x3ffffL<<0)
2073#define BNX2_RPM_RC_CNTL_14_B (0xfffL<<19) 3803#define BNX2_RPM_RC_CNTL_14_B (0xfffL<<19)
3804#define BNX2_RPM_RC_CNTL_14_OFFSET_XI (0xffL<<0)
3805#define BNX2_RPM_RC_CNTL_14_CLASS_XI (0x7L<<8)
3806#define BNX2_RPM_RC_CNTL_14_PRIORITY_XI (1L<<11)
3807#define BNX2_RPM_RC_CNTL_14_P4_XI (1L<<12)
3808#define BNX2_RPM_RC_CNTL_14_HDR_TYPE_XI (0x7L<<13)
3809#define BNX2_RPM_RC_CNTL_14_HDR_TYPE_START_XI (0L<<13)
3810#define BNX2_RPM_RC_CNTL_14_HDR_TYPE_IP_XI (1L<<13)
3811#define BNX2_RPM_RC_CNTL_14_HDR_TYPE_TCP_XI (2L<<13)
3812#define BNX2_RPM_RC_CNTL_14_HDR_TYPE_UDP_XI (3L<<13)
3813#define BNX2_RPM_RC_CNTL_14_HDR_TYPE_DATA_XI (4L<<13)
3814#define BNX2_RPM_RC_CNTL_14_HDR_TYPE_TCP_UDP_XI (5L<<13)
3815#define BNX2_RPM_RC_CNTL_14_HDR_TYPE_ICMPV6_XI (6L<<13)
3816#define BNX2_RPM_RC_CNTL_14_COMP_XI (0x3L<<16)
3817#define BNX2_RPM_RC_CNTL_14_COMP_EQUAL_XI (0L<<16)
3818#define BNX2_RPM_RC_CNTL_14_COMP_NEQUAL_XI (1L<<16)
3819#define BNX2_RPM_RC_CNTL_14_COMP_GREATER_XI (2L<<16)
3820#define BNX2_RPM_RC_CNTL_14_COMP_LESS_XI (3L<<16)
3821#define BNX2_RPM_RC_CNTL_14_MAP_XI (1L<<18)
3822#define BNX2_RPM_RC_CNTL_14_SBIT_XI (1L<<19)
3823#define BNX2_RPM_RC_CNTL_14_CMDSEL_XI (0x1fL<<20)
3824#define BNX2_RPM_RC_CNTL_14_DISCARD_XI (1L<<25)
3825#define BNX2_RPM_RC_CNTL_14_MASK_XI (1L<<26)
3826#define BNX2_RPM_RC_CNTL_14_P1_XI (1L<<27)
3827#define BNX2_RPM_RC_CNTL_14_P2_XI (1L<<28)
3828#define BNX2_RPM_RC_CNTL_14_P3_XI (1L<<29)
3829#define BNX2_RPM_RC_CNTL_14_NBIT_XI (1L<<30)
2074 3830
2075#define BNX2_RPM_RC_VALUE_MASK_14 0x00001974 3831#define BNX2_RPM_RC_VALUE_MASK_14 0x00001974
3832#define BNX2_RPM_RC_VALUE_MASK_14_VALUE (0xffffL<<0)
3833#define BNX2_RPM_RC_VALUE_MASK_14_MASK (0xffffL<<16)
3834
2076#define BNX2_RPM_RC_CNTL_15 0x00001978 3835#define BNX2_RPM_RC_CNTL_15 0x00001978
2077#define BNX2_RPM_RC_CNTL_15_A (0x3ffffL<<0) 3836#define BNX2_RPM_RC_CNTL_15_A (0x3ffffL<<0)
2078#define BNX2_RPM_RC_CNTL_15_B (0xfffL<<19) 3837#define BNX2_RPM_RC_CNTL_15_B (0xfffL<<19)
3838#define BNX2_RPM_RC_CNTL_15_OFFSET_XI (0xffL<<0)
3839#define BNX2_RPM_RC_CNTL_15_CLASS_XI (0x7L<<8)
3840#define BNX2_RPM_RC_CNTL_15_PRIORITY_XI (1L<<11)
3841#define BNX2_RPM_RC_CNTL_15_P4_XI (1L<<12)
3842#define BNX2_RPM_RC_CNTL_15_HDR_TYPE_XI (0x7L<<13)
3843#define BNX2_RPM_RC_CNTL_15_HDR_TYPE_START_XI (0L<<13)
3844#define BNX2_RPM_RC_CNTL_15_HDR_TYPE_IP_XI (1L<<13)
3845#define BNX2_RPM_RC_CNTL_15_HDR_TYPE_TCP_XI (2L<<13)
3846#define BNX2_RPM_RC_CNTL_15_HDR_TYPE_UDP_XI (3L<<13)
3847#define BNX2_RPM_RC_CNTL_15_HDR_TYPE_DATA_XI (4L<<13)
3848#define BNX2_RPM_RC_CNTL_15_HDR_TYPE_TCP_UDP_XI (5L<<13)
3849#define BNX2_RPM_RC_CNTL_15_HDR_TYPE_ICMPV6_XI (6L<<13)
3850#define BNX2_RPM_RC_CNTL_15_COMP_XI (0x3L<<16)
3851#define BNX2_RPM_RC_CNTL_15_COMP_EQUAL_XI (0L<<16)
3852#define BNX2_RPM_RC_CNTL_15_COMP_NEQUAL_XI (1L<<16)
3853#define BNX2_RPM_RC_CNTL_15_COMP_GREATER_XI (2L<<16)
3854#define BNX2_RPM_RC_CNTL_15_COMP_LESS_XI (3L<<16)
3855#define BNX2_RPM_RC_CNTL_15_MAP_XI (1L<<18)
3856#define BNX2_RPM_RC_CNTL_15_SBIT_XI (1L<<19)
3857#define BNX2_RPM_RC_CNTL_15_CMDSEL_XI (0x1fL<<20)
3858#define BNX2_RPM_RC_CNTL_15_DISCARD_XI (1L<<25)
3859#define BNX2_RPM_RC_CNTL_15_MASK_XI (1L<<26)
3860#define BNX2_RPM_RC_CNTL_15_P1_XI (1L<<27)
3861#define BNX2_RPM_RC_CNTL_15_P2_XI (1L<<28)
3862#define BNX2_RPM_RC_CNTL_15_P3_XI (1L<<29)
3863#define BNX2_RPM_RC_CNTL_15_NBIT_XI (1L<<30)
2079 3864
2080#define BNX2_RPM_RC_VALUE_MASK_15 0x0000197c 3865#define BNX2_RPM_RC_VALUE_MASK_15 0x0000197c
3866#define BNX2_RPM_RC_VALUE_MASK_15_VALUE (0xffffL<<0)
3867#define BNX2_RPM_RC_VALUE_MASK_15_MASK (0xffffL<<16)
3868
2081#define BNX2_RPM_RC_CONFIG 0x00001980 3869#define BNX2_RPM_RC_CONFIG 0x00001980
2082#define BNX2_RPM_RC_CONFIG_RULE_ENABLE (0xffffL<<0) 3870#define BNX2_RPM_RC_CONFIG_RULE_ENABLE (0xffffL<<0)
3871#define BNX2_RPM_RC_CONFIG_RULE_ENABLE_XI (0xfffffL<<0)
2083#define BNX2_RPM_RC_CONFIG_DEF_CLASS (0x7L<<24) 3872#define BNX2_RPM_RC_CONFIG_DEF_CLASS (0x7L<<24)
3873#define BNX2_RPM_RC_CONFIG_KNUM_OVERWRITE (1L<<31)
2084 3874
2085#define BNX2_RPM_DEBUG0 0x00001984 3875#define BNX2_RPM_DEBUG0 0x00001984
2086#define BNX2_RPM_DEBUG0_FM_BCNT (0xffffL<<0) 3876#define BNX2_RPM_DEBUG0_FM_BCNT (0xffffL<<0)
@@ -2236,6 +4026,16 @@ struct l2_fhdr {
2236#define BNX2_RPM_DEBUG9_INFIFO_OVERRUN_OCCURRED (1L<<29) 4026#define BNX2_RPM_DEBUG9_INFIFO_OVERRUN_OCCURRED (1L<<29)
2237#define BNX2_RPM_DEBUG9_ACPI_MATCH_INT (1L<<30) 4027#define BNX2_RPM_DEBUG9_ACPI_MATCH_INT (1L<<30)
2238#define BNX2_RPM_DEBUG9_ACPI_ENABLE_SYN (1L<<31) 4028#define BNX2_RPM_DEBUG9_ACPI_ENABLE_SYN (1L<<31)
4029#define BNX2_RPM_DEBUG9_BEMEM_R_XI (0x1fL<<0)
4030#define BNX2_RPM_DEBUG9_EO_XI (1L<<5)
4031#define BNX2_RPM_DEBUG9_AEOF_DE_XI (1L<<6)
4032#define BNX2_RPM_DEBUG9_SO_XI (1L<<7)
4033#define BNX2_RPM_DEBUG9_WD64_CT_XI (0x1fL<<8)
4034#define BNX2_RPM_DEBUG9_EOF_VLDBYTE_XI (0x7L<<13)
4035#define BNX2_RPM_DEBUG9_ACPI_RDE_PAT_ID_XI (0xfL<<16)
4036#define BNX2_RPM_DEBUG9_CALCRC_RESULT_XI (0x3ffL<<20)
4037#define BNX2_RPM_DEBUG9_DATA_IN_VL_XI (1L<<30)
4038#define BNX2_RPM_DEBUG9_CALCRC_BUFFER_VLD_XI (1L<<31)
2239 4039
2240#define BNX2_RPM_ACPI_DBG_BUF_W00 0x000019c0 4040#define BNX2_RPM_ACPI_DBG_BUF_W00 0x000019c0
2241#define BNX2_RPM_ACPI_DBG_BUF_W01 0x000019c4 4041#define BNX2_RPM_ACPI_DBG_BUF_W01 0x000019c4
@@ -2253,6 +4053,56 @@ struct l2_fhdr {
2253#define BNX2_RPM_ACPI_DBG_BUF_W31 0x000019f4 4053#define BNX2_RPM_ACPI_DBG_BUF_W31 0x000019f4
2254#define BNX2_RPM_ACPI_DBG_BUF_W32 0x000019f8 4054#define BNX2_RPM_ACPI_DBG_BUF_W32 0x000019f8
2255#define BNX2_RPM_ACPI_DBG_BUF_W33 0x000019fc 4055#define BNX2_RPM_ACPI_DBG_BUF_W33 0x000019fc
4056#define BNX2_RPM_ACPI_BYTE_ENABLE_CTRL 0x00001a00
4057#define BNX2_RPM_ACPI_BYTE_ENABLE_CTRL_BYTE_ADDRESS (0xffffL<<0)
4058#define BNX2_RPM_ACPI_BYTE_ENABLE_CTRL_DEBUGRD (1L<<28)
4059#define BNX2_RPM_ACPI_BYTE_ENABLE_CTRL_MODE (1L<<29)
4060#define BNX2_RPM_ACPI_BYTE_ENABLE_CTRL_INIT (1L<<30)
4061#define BNX2_RPM_ACPI_BYTE_ENABLE_CTRL_WR (1L<<31)
4062
4063#define BNX2_RPM_ACPI_PATTERN_CTRL 0x00001a04
4064#define BNX2_RPM_ACPI_PATTERN_CTRL_PATTERN_ID (0xfL<<0)
4065#define BNX2_RPM_ACPI_PATTERN_CTRL_CRC_SM_CLR (1L<<30)
4066#define BNX2_RPM_ACPI_PATTERN_CTRL_WR (1L<<31)
4067
4068#define BNX2_RPM_ACPI_DATA 0x00001a08
4069#define BNX2_RPM_ACPI_DATA_PATTERN_BE (0xffffffffL<<0)
4070
4071#define BNX2_RPM_ACPI_PATTERN_LEN0 0x00001a0c
4072#define BNX2_RPM_ACPI_PATTERN_LEN0_PATTERN_LEN3 (0xffL<<0)
4073#define BNX2_RPM_ACPI_PATTERN_LEN0_PATTERN_LEN2 (0xffL<<8)
4074#define BNX2_RPM_ACPI_PATTERN_LEN0_PATTERN_LEN1 (0xffL<<16)
4075#define BNX2_RPM_ACPI_PATTERN_LEN0_PATTERN_LEN0 (0xffL<<24)
4076
4077#define BNX2_RPM_ACPI_PATTERN_LEN1 0x00001a10
4078#define BNX2_RPM_ACPI_PATTERN_LEN1_PATTERN_LEN7 (0xffL<<0)
4079#define BNX2_RPM_ACPI_PATTERN_LEN1_PATTERN_LEN6 (0xffL<<8)
4080#define BNX2_RPM_ACPI_PATTERN_LEN1_PATTERN_LEN5 (0xffL<<16)
4081#define BNX2_RPM_ACPI_PATTERN_LEN1_PATTERN_LEN4 (0xffL<<24)
4082
4083#define BNX2_RPM_ACPI_PATTERN_CRC0 0x00001a18
4084#define BNX2_RPM_ACPI_PATTERN_CRC0_PATTERN_CRC0 (0xffffffffL<<0)
4085
4086#define BNX2_RPM_ACPI_PATTERN_CRC1 0x00001a1c
4087#define BNX2_RPM_ACPI_PATTERN_CRC1_PATTERN_CRC1 (0xffffffffL<<0)
4088
4089#define BNX2_RPM_ACPI_PATTERN_CRC2 0x00001a20
4090#define BNX2_RPM_ACPI_PATTERN_CRC2_PATTERN_CRC2 (0xffffffffL<<0)
4091
4092#define BNX2_RPM_ACPI_PATTERN_CRC3 0x00001a24
4093#define BNX2_RPM_ACPI_PATTERN_CRC3_PATTERN_CRC3 (0xffffffffL<<0)
4094
4095#define BNX2_RPM_ACPI_PATTERN_CRC4 0x00001a28
4096#define BNX2_RPM_ACPI_PATTERN_CRC4_PATTERN_CRC4 (0xffffffffL<<0)
4097
4098#define BNX2_RPM_ACPI_PATTERN_CRC5 0x00001a2c
4099#define BNX2_RPM_ACPI_PATTERN_CRC5_PATTERN_CRC5 (0xffffffffL<<0)
4100
4101#define BNX2_RPM_ACPI_PATTERN_CRC6 0x00001a30
4102#define BNX2_RPM_ACPI_PATTERN_CRC6_PATTERN_CRC6 (0xffffffffL<<0)
4103
4104#define BNX2_RPM_ACPI_PATTERN_CRC7 0x00001a34
4105#define BNX2_RPM_ACPI_PATTERN_CRC7_PATTERN_CRC7 (0xffffffffL<<0)
2256 4106
2257 4107
2258/* 4108/*
@@ -2263,15 +4113,20 @@ struct l2_fhdr {
2263#define BNX2_RBUF_COMMAND_ENABLED (1L<<0) 4113#define BNX2_RBUF_COMMAND_ENABLED (1L<<0)
2264#define BNX2_RBUF_COMMAND_FREE_INIT (1L<<1) 4114#define BNX2_RBUF_COMMAND_FREE_INIT (1L<<1)
2265#define BNX2_RBUF_COMMAND_RAM_INIT (1L<<2) 4115#define BNX2_RBUF_COMMAND_RAM_INIT (1L<<2)
4116#define BNX2_RBUF_COMMAND_PKT_OFFSET_OVFL (1L<<3)
2266#define BNX2_RBUF_COMMAND_OVER_FREE (1L<<4) 4117#define BNX2_RBUF_COMMAND_OVER_FREE (1L<<4)
2267#define BNX2_RBUF_COMMAND_ALLOC_REQ (1L<<5) 4118#define BNX2_RBUF_COMMAND_ALLOC_REQ (1L<<5)
4119#define BNX2_RBUF_COMMAND_EN_PRI_CHNGE_TE (1L<<6)
4120#define BNX2_RBUF_COMMAND_CU_ISOLATE_XI (1L<<5)
4121#define BNX2_RBUF_COMMAND_EN_PRI_CHANGE_XI (1L<<6)
4122#define BNX2_RBUF_COMMAND_GRC_ENDIAN_CONV_DIS_XI (1L<<7)
2268 4123
2269#define BNX2_RBUF_STATUS1 0x00200004 4124#define BNX2_RBUF_STATUS1 0x00200004
2270#define BNX2_RBUF_STATUS1_FREE_COUNT (0x3ffL<<0) 4125#define BNX2_RBUF_STATUS1_FREE_COUNT (0x3ffL<<0)
2271 4126
2272#define BNX2_RBUF_STATUS2 0x00200008 4127#define BNX2_RBUF_STATUS2 0x00200008
2273#define BNX2_RBUF_STATUS2_FREE_TAIL (0x3ffL<<0) 4128#define BNX2_RBUF_STATUS2_FREE_TAIL (0x1ffL<<0)
2274#define BNX2_RBUF_STATUS2_FREE_HEAD (0x3ffL<<16) 4129#define BNX2_RBUF_STATUS2_FREE_HEAD (0x1ffL<<16)
2275 4130
2276#define BNX2_RBUF_CONFIG 0x0020000c 4131#define BNX2_RBUF_CONFIG 0x0020000c
2277#define BNX2_RBUF_CONFIG_XOFF_TRIP (0x3ffL<<0) 4132#define BNX2_RBUF_CONFIG_XOFF_TRIP (0x3ffL<<0)
@@ -2279,16 +4134,21 @@ struct l2_fhdr {
2279 4134
2280#define BNX2_RBUF_FW_BUF_ALLOC 0x00200010 4135#define BNX2_RBUF_FW_BUF_ALLOC 0x00200010
2281#define BNX2_RBUF_FW_BUF_ALLOC_VALUE (0x1ffL<<7) 4136#define BNX2_RBUF_FW_BUF_ALLOC_VALUE (0x1ffL<<7)
4137#define BNX2_RBUF_FW_BUF_ALLOC_TYPE (1L<<16)
4138#define BNX2_RBUF_FW_BUF_ALLOC_ALLOC_REQ (1L<<31)
2282 4139
2283#define BNX2_RBUF_FW_BUF_FREE 0x00200014 4140#define BNX2_RBUF_FW_BUF_FREE 0x00200014
2284#define BNX2_RBUF_FW_BUF_FREE_COUNT (0x7fL<<0) 4141#define BNX2_RBUF_FW_BUF_FREE_COUNT (0x7fL<<0)
2285#define BNX2_RBUF_FW_BUF_FREE_TAIL (0x1ffL<<7) 4142#define BNX2_RBUF_FW_BUF_FREE_TAIL (0x1ffL<<7)
2286#define BNX2_RBUF_FW_BUF_FREE_HEAD (0x1ffL<<16) 4143#define BNX2_RBUF_FW_BUF_FREE_HEAD (0x1ffL<<16)
4144#define BNX2_RBUF_FW_BUF_FREE_TYPE (1L<<25)
4145#define BNX2_RBUF_FW_BUF_FREE_FREE_REQ (1L<<31)
2287 4146
2288#define BNX2_RBUF_FW_BUF_SEL 0x00200018 4147#define BNX2_RBUF_FW_BUF_SEL 0x00200018
2289#define BNX2_RBUF_FW_BUF_SEL_COUNT (0x7fL<<0) 4148#define BNX2_RBUF_FW_BUF_SEL_COUNT (0x7fL<<0)
2290#define BNX2_RBUF_FW_BUF_SEL_TAIL (0x1ffL<<7) 4149#define BNX2_RBUF_FW_BUF_SEL_TAIL (0x1ffL<<7)
2291#define BNX2_RBUF_FW_BUF_SEL_HEAD (0x1ffL<<16) 4150#define BNX2_RBUF_FW_BUF_SEL_HEAD (0x1ffL<<16)
4151#define BNX2_RBUF_FW_BUF_SEL_SEL_REQ (1L<<31)
2292 4152
2293#define BNX2_RBUF_CONFIG2 0x0020001c 4153#define BNX2_RBUF_CONFIG2 0x0020001c
2294#define BNX2_RBUF_CONFIG2_MAC_DROP_TRIP (0x3ffL<<0) 4154#define BNX2_RBUF_CONFIG2_MAC_DROP_TRIP (0x3ffL<<0)
@@ -2376,6 +4236,8 @@ struct l2_fhdr {
2376#define BNX2_RV2P_INSTR_HIGH_HIGH (0x1fL<<0) 4236#define BNX2_RV2P_INSTR_HIGH_HIGH (0x1fL<<0)
2377 4237
2378#define BNX2_RV2P_INSTR_LOW 0x00002834 4238#define BNX2_RV2P_INSTR_LOW 0x00002834
4239#define BNX2_RV2P_INSTR_LOW_LOW (0xffffffffL<<0)
4240
2379#define BNX2_RV2P_PROC1_ADDR_CMD 0x00002838 4241#define BNX2_RV2P_PROC1_ADDR_CMD 0x00002838
2380#define BNX2_RV2P_PROC1_ADDR_CMD_ADD (0x3ffL<<0) 4242#define BNX2_RV2P_PROC1_ADDR_CMD_ADD (0x3ffL<<0)
2381#define BNX2_RV2P_PROC1_ADDR_CMD_RDWR (1L<<31) 4243#define BNX2_RV2P_PROC1_ADDR_CMD_RDWR (1L<<31)
@@ -2395,7 +4257,29 @@ struct l2_fhdr {
2395#define BNX2_RV2P_DEBUG_VECT_PEEK_2_PEEK_EN (1L<<27) 4257#define BNX2_RV2P_DEBUG_VECT_PEEK_2_PEEK_EN (1L<<27)
2396#define BNX2_RV2P_DEBUG_VECT_PEEK_2_SEL (0xfL<<28) 4258#define BNX2_RV2P_DEBUG_VECT_PEEK_2_SEL (0xfL<<28)
2397 4259
2398#define BNX2_RV2P_PFTQ_DATA 0x00002b40 4260#define BNX2_RV2P_MPFE_PFE_CTL 0x00002afc
4261#define BNX2_RV2P_MPFE_PFE_CTL_INC_USAGE_CNT (1L<<0)
4262#define BNX2_RV2P_MPFE_PFE_CTL_PFE_SIZE (0xfL<<4)
4263#define BNX2_RV2P_MPFE_PFE_CTL_PFE_SIZE_0 (0L<<4)
4264#define BNX2_RV2P_MPFE_PFE_CTL_PFE_SIZE_1 (1L<<4)
4265#define BNX2_RV2P_MPFE_PFE_CTL_PFE_SIZE_2 (2L<<4)
4266#define BNX2_RV2P_MPFE_PFE_CTL_PFE_SIZE_3 (3L<<4)
4267#define BNX2_RV2P_MPFE_PFE_CTL_PFE_SIZE_4 (4L<<4)
4268#define BNX2_RV2P_MPFE_PFE_CTL_PFE_SIZE_5 (5L<<4)
4269#define BNX2_RV2P_MPFE_PFE_CTL_PFE_SIZE_6 (6L<<4)
4270#define BNX2_RV2P_MPFE_PFE_CTL_PFE_SIZE_7 (7L<<4)
4271#define BNX2_RV2P_MPFE_PFE_CTL_PFE_SIZE_8 (8L<<4)
4272#define BNX2_RV2P_MPFE_PFE_CTL_PFE_SIZE_9 (9L<<4)
4273#define BNX2_RV2P_MPFE_PFE_CTL_PFE_SIZE_10 (10L<<4)
4274#define BNX2_RV2P_MPFE_PFE_CTL_PFE_SIZE_11 (11L<<4)
4275#define BNX2_RV2P_MPFE_PFE_CTL_PFE_SIZE_12 (12L<<4)
4276#define BNX2_RV2P_MPFE_PFE_CTL_PFE_SIZE_13 (13L<<4)
4277#define BNX2_RV2P_MPFE_PFE_CTL_PFE_SIZE_14 (14L<<4)
4278#define BNX2_RV2P_MPFE_PFE_CTL_PFE_SIZE_15 (15L<<4)
4279#define BNX2_RV2P_MPFE_PFE_CTL_PFE_COUNT (0xfL<<12)
4280#define BNX2_RV2P_MPFE_PFE_CTL_OFFSET (0x1ffL<<16)
4281
4282#define BNX2_RV2P_RV2PPQ 0x00002b40
2399#define BNX2_RV2P_PFTQ_CMD 0x00002b78 4283#define BNX2_RV2P_PFTQ_CMD 0x00002b78
2400#define BNX2_RV2P_PFTQ_CMD_OFFSET (0x3ffL<<0) 4284#define BNX2_RV2P_PFTQ_CMD_OFFSET (0x3ffL<<0)
2401#define BNX2_RV2P_PFTQ_CMD_WR_TOP (1L<<10) 4285#define BNX2_RV2P_PFTQ_CMD_WR_TOP (1L<<10)
@@ -2416,7 +4300,7 @@ struct l2_fhdr {
2416#define BNX2_RV2P_PFTQ_CTL_MAX_DEPTH (0x3ffL<<12) 4300#define BNX2_RV2P_PFTQ_CTL_MAX_DEPTH (0x3ffL<<12)
2417#define BNX2_RV2P_PFTQ_CTL_CUR_DEPTH (0x3ffL<<22) 4301#define BNX2_RV2P_PFTQ_CTL_CUR_DEPTH (0x3ffL<<22)
2418 4302
2419#define BNX2_RV2P_TFTQ_DATA 0x00002b80 4303#define BNX2_RV2P_RV2PTQ 0x00002b80
2420#define BNX2_RV2P_TFTQ_CMD 0x00002bb8 4304#define BNX2_RV2P_TFTQ_CMD 0x00002bb8
2421#define BNX2_RV2P_TFTQ_CMD_OFFSET (0x3ffL<<0) 4305#define BNX2_RV2P_TFTQ_CMD_OFFSET (0x3ffL<<0)
2422#define BNX2_RV2P_TFTQ_CMD_WR_TOP (1L<<10) 4306#define BNX2_RV2P_TFTQ_CMD_WR_TOP (1L<<10)
@@ -2437,7 +4321,7 @@ struct l2_fhdr {
2437#define BNX2_RV2P_TFTQ_CTL_MAX_DEPTH (0x3ffL<<12) 4321#define BNX2_RV2P_TFTQ_CTL_MAX_DEPTH (0x3ffL<<12)
2438#define BNX2_RV2P_TFTQ_CTL_CUR_DEPTH (0x3ffL<<22) 4322#define BNX2_RV2P_TFTQ_CTL_CUR_DEPTH (0x3ffL<<22)
2439 4323
2440#define BNX2_RV2P_MFTQ_DATA 0x00002bc0 4324#define BNX2_RV2P_RV2PMQ 0x00002bc0
2441#define BNX2_RV2P_MFTQ_CMD 0x00002bf8 4325#define BNX2_RV2P_MFTQ_CMD 0x00002bf8
2442#define BNX2_RV2P_MFTQ_CMD_OFFSET (0x3ffL<<0) 4326#define BNX2_RV2P_MFTQ_CMD_OFFSET (0x3ffL<<0)
2443#define BNX2_RV2P_MFTQ_CMD_WR_TOP (1L<<10) 4327#define BNX2_RV2P_MFTQ_CMD_WR_TOP (1L<<10)
@@ -2466,18 +4350,26 @@ struct l2_fhdr {
2466 */ 4350 */
2467#define BNX2_MQ_COMMAND 0x00003c00 4351#define BNX2_MQ_COMMAND 0x00003c00
2468#define BNX2_MQ_COMMAND_ENABLED (1L<<0) 4352#define BNX2_MQ_COMMAND_ENABLED (1L<<0)
4353#define BNX2_MQ_COMMAND_INIT (1L<<1)
2469#define BNX2_MQ_COMMAND_OVERFLOW (1L<<4) 4354#define BNX2_MQ_COMMAND_OVERFLOW (1L<<4)
2470#define BNX2_MQ_COMMAND_WR_ERROR (1L<<5) 4355#define BNX2_MQ_COMMAND_WR_ERROR (1L<<5)
2471#define BNX2_MQ_COMMAND_RD_ERROR (1L<<6) 4356#define BNX2_MQ_COMMAND_RD_ERROR (1L<<6)
4357#define BNX2_MQ_COMMAND_IDB_CFG_ERROR (1L<<7)
4358#define BNX2_MQ_COMMAND_IDB_OVERFLOW (1L<<10)
4359#define BNX2_MQ_COMMAND_NO_BIN_ERROR (1L<<11)
4360#define BNX2_MQ_COMMAND_NO_MAP_ERROR (1L<<12)
2472 4361
2473#define BNX2_MQ_STATUS 0x00003c04 4362#define BNX2_MQ_STATUS 0x00003c04
2474#define BNX2_MQ_STATUS_CTX_ACCESS_STAT (1L<<16) 4363#define BNX2_MQ_STATUS_CTX_ACCESS_STAT (1L<<16)
2475#define BNX2_MQ_STATUS_CTX_ACCESS64_STAT (1L<<17) 4364#define BNX2_MQ_STATUS_CTX_ACCESS64_STAT (1L<<17)
2476#define BNX2_MQ_STATUS_PCI_STALL_STAT (1L<<18) 4365#define BNX2_MQ_STATUS_PCI_STALL_STAT (1L<<18)
4366#define BNX2_MQ_STATUS_IDB_OFLOW_STAT (1L<<19)
2477 4367
2478#define BNX2_MQ_CONFIG 0x00003c08 4368#define BNX2_MQ_CONFIG 0x00003c08
2479#define BNX2_MQ_CONFIG_TX_HIGH_PRI (1L<<0) 4369#define BNX2_MQ_CONFIG_TX_HIGH_PRI (1L<<0)
2480#define BNX2_MQ_CONFIG_HALT_DIS (1L<<1) 4370#define BNX2_MQ_CONFIG_HALT_DIS (1L<<1)
4371#define BNX2_MQ_CONFIG_BIN_MQ_MODE (1L<<2)
4372#define BNX2_MQ_CONFIG_DIS_IDB_DROP (1L<<3)
2481#define BNX2_MQ_CONFIG_KNL_BYP_BLK_SIZE (0x7L<<4) 4373#define BNX2_MQ_CONFIG_KNL_BYP_BLK_SIZE (0x7L<<4)
2482#define BNX2_MQ_CONFIG_KNL_BYP_BLK_SIZE_256 (0L<<4) 4374#define BNX2_MQ_CONFIG_KNL_BYP_BLK_SIZE_256 (0L<<4)
2483#define BNX2_MQ_CONFIG_KNL_BYP_BLK_SIZE_512 (1L<<4) 4375#define BNX2_MQ_CONFIG_KNL_BYP_BLK_SIZE_512 (1L<<4)
@@ -2533,6 +4425,7 @@ struct l2_fhdr {
2533 4425
2534#define BNX2_MQ_MEM_WR_DATA2 0x00003c80 4426#define BNX2_MQ_MEM_WR_DATA2 0x00003c80
2535#define BNX2_MQ_MEM_WR_DATA2_VALUE (0x3fffffffL<<0) 4427#define BNX2_MQ_MEM_WR_DATA2_VALUE (0x3fffffffL<<0)
4428#define BNX2_MQ_MEM_WR_DATA2_VALUE_XI (0x7fffffffL<<0)
2536 4429
2537#define BNX2_MQ_MEM_RD_ADDR 0x00003c84 4430#define BNX2_MQ_MEM_RD_ADDR 0x00003c84
2538#define BNX2_MQ_MEM_RD_ADDR_VALUE (0x3fL<<0) 4431#define BNX2_MQ_MEM_RD_ADDR_VALUE (0x3fL<<0)
@@ -2545,6 +4438,16 @@ struct l2_fhdr {
2545 4438
2546#define BNX2_MQ_MEM_RD_DATA2 0x00003c90 4439#define BNX2_MQ_MEM_RD_DATA2 0x00003c90
2547#define BNX2_MQ_MEM_RD_DATA2_VALUE (0x3fffffffL<<0) 4440#define BNX2_MQ_MEM_RD_DATA2_VALUE (0x3fffffffL<<0)
4441#define BNX2_MQ_MEM_RD_DATA2_VALUE_XI (0x7fffffffL<<0)
4442
4443
4444/*
4445 * tsch_reg definition
4446 * offset: 0x4c00
4447 */
4448#define BNX2_TSCH_TSS_CFG 0x00004c1c
4449#define BNX2_TSCH_TSS_CFG_TSS_START_CID (0x7ffL<<8)
4450#define BNX2_TSCH_TSS_CFG_NUM_OF_TSS_CON (0xfL<<24)
2548 4451
2549 4452
2550 4453
@@ -2594,7 +4497,11 @@ struct l2_fhdr {
2594#define BNX2_TBDR_DEBUG_VECT_PEEK_2_PEEK_EN (1L<<27) 4497#define BNX2_TBDR_DEBUG_VECT_PEEK_2_PEEK_EN (1L<<27)
2595#define BNX2_TBDR_DEBUG_VECT_PEEK_2_SEL (0xfL<<28) 4498#define BNX2_TBDR_DEBUG_VECT_PEEK_2_SEL (0xfL<<28)
2596 4499
2597#define BNX2_TBDR_FTQ_DATA 0x000053c0 4500#define BNX2_TBDR_CKSUM_ERROR_STATUS 0x00005010
4501#define BNX2_TBDR_CKSUM_ERROR_STATUS_CALCULATED (0xffffL<<0)
4502#define BNX2_TBDR_CKSUM_ERROR_STATUS_EXPECTED (0xffffL<<16)
4503
4504#define BNX2_TBDR_TBDRQ 0x000053c0
2598#define BNX2_TBDR_FTQ_CMD 0x000053f8 4505#define BNX2_TBDR_FTQ_CMD 0x000053f8
2599#define BNX2_TBDR_FTQ_CMD_OFFSET (0x3ffL<<0) 4506#define BNX2_TBDR_FTQ_CMD_OFFSET (0x3ffL<<0)
2600#define BNX2_TBDR_FTQ_CMD_WR_TOP (1L<<10) 4507#define BNX2_TBDR_FTQ_CMD_WR_TOP (1L<<10)
@@ -2624,7 +4531,15 @@ struct l2_fhdr {
2624#define BNX2_TDMA_COMMAND 0x00005c00 4531#define BNX2_TDMA_COMMAND 0x00005c00
2625#define BNX2_TDMA_COMMAND_ENABLED (1L<<0) 4532#define BNX2_TDMA_COMMAND_ENABLED (1L<<0)
2626#define BNX2_TDMA_COMMAND_MASTER_ABORT (1L<<4) 4533#define BNX2_TDMA_COMMAND_MASTER_ABORT (1L<<4)
4534#define BNX2_TDMA_COMMAND_CS16_ERR (1L<<5)
2627#define BNX2_TDMA_COMMAND_BAD_L2_LENGTH_ABORT (1L<<7) 4535#define BNX2_TDMA_COMMAND_BAD_L2_LENGTH_ABORT (1L<<7)
4536#define BNX2_TDMA_COMMAND_MASK_CS1 (1L<<20)
4537#define BNX2_TDMA_COMMAND_MASK_CS2 (1L<<21)
4538#define BNX2_TDMA_COMMAND_MASK_CS3 (1L<<22)
4539#define BNX2_TDMA_COMMAND_MASK_CS4 (1L<<23)
4540#define BNX2_TDMA_COMMAND_FORCE_ILOCK_CKERR (1L<<24)
4541#define BNX2_TDMA_COMMAND_OFIFO_CLR (1L<<30)
4542#define BNX2_TDMA_COMMAND_IFIFO_CLR (1L<<31)
2628 4543
2629#define BNX2_TDMA_STATUS 0x00005c04 4544#define BNX2_TDMA_STATUS 0x00005c04
2630#define BNX2_TDMA_STATUS_DMA_WAIT (1L<<0) 4545#define BNX2_TDMA_STATUS_DMA_WAIT (1L<<0)
@@ -2633,10 +4548,18 @@ struct l2_fhdr {
2633#define BNX2_TDMA_STATUS_LOCK_WAIT (1L<<3) 4548#define BNX2_TDMA_STATUS_LOCK_WAIT (1L<<3)
2634#define BNX2_TDMA_STATUS_FTQ_ENTRY_CNT (1L<<16) 4549#define BNX2_TDMA_STATUS_FTQ_ENTRY_CNT (1L<<16)
2635#define BNX2_TDMA_STATUS_BURST_CNT (1L<<17) 4550#define BNX2_TDMA_STATUS_BURST_CNT (1L<<17)
4551#define BNX2_TDMA_STATUS_MAX_IFIFO_DEPTH (0x3fL<<20)
4552#define BNX2_TDMA_STATUS_OFIFO_OVERFLOW (1L<<30)
4553#define BNX2_TDMA_STATUS_IFIFO_OVERFLOW (1L<<31)
2636 4554
2637#define BNX2_TDMA_CONFIG 0x00005c08 4555#define BNX2_TDMA_CONFIG 0x00005c08
2638#define BNX2_TDMA_CONFIG_ONE_DMA (1L<<0) 4556#define BNX2_TDMA_CONFIG_ONE_DMA (1L<<0)
2639#define BNX2_TDMA_CONFIG_ONE_RECORD (1L<<1) 4557#define BNX2_TDMA_CONFIG_ONE_RECORD (1L<<1)
4558#define BNX2_TDMA_CONFIG_NUM_DMA_CHAN (0x3L<<2)
4559#define BNX2_TDMA_CONFIG_NUM_DMA_CHAN_0 (0L<<2)
4560#define BNX2_TDMA_CONFIG_NUM_DMA_CHAN_1 (1L<<2)
4561#define BNX2_TDMA_CONFIG_NUM_DMA_CHAN_2 (2L<<2)
4562#define BNX2_TDMA_CONFIG_NUM_DMA_CHAN_3 (3L<<2)
2640#define BNX2_TDMA_CONFIG_LIMIT_SZ (0xfL<<4) 4563#define BNX2_TDMA_CONFIG_LIMIT_SZ (0xfL<<4)
2641#define BNX2_TDMA_CONFIG_LIMIT_SZ_64 (0L<<4) 4564#define BNX2_TDMA_CONFIG_LIMIT_SZ_64 (0L<<4)
2642#define BNX2_TDMA_CONFIG_LIMIT_SZ_128 (0x4L<<4) 4565#define BNX2_TDMA_CONFIG_LIMIT_SZ_128 (0x4L<<4)
@@ -2649,7 +4572,35 @@ struct l2_fhdr {
2649#define BNX2_TDMA_CONFIG_LINE_SZ_512 (8L<<8) 4572#define BNX2_TDMA_CONFIG_LINE_SZ_512 (8L<<8)
2650#define BNX2_TDMA_CONFIG_ALIGN_ENA (1L<<15) 4573#define BNX2_TDMA_CONFIG_ALIGN_ENA (1L<<15)
2651#define BNX2_TDMA_CONFIG_CHK_L2_BD (1L<<16) 4574#define BNX2_TDMA_CONFIG_CHK_L2_BD (1L<<16)
4575#define BNX2_TDMA_CONFIG_CMPL_ENTRY (1L<<17)
4576#define BNX2_TDMA_CONFIG_OFIFO_CMP (1L<<19)
4577#define BNX2_TDMA_CONFIG_OFIFO_CMP_3 (0L<<19)
4578#define BNX2_TDMA_CONFIG_OFIFO_CMP_2 (1L<<19)
2652#define BNX2_TDMA_CONFIG_FIFO_CMP (0xfL<<20) 4579#define BNX2_TDMA_CONFIG_FIFO_CMP (0xfL<<20)
4580#define BNX2_TDMA_CONFIG_IFIFO_DEPTH_XI (0x7L<<20)
4581#define BNX2_TDMA_CONFIG_IFIFO_DEPTH_0_XI (0L<<20)
4582#define BNX2_TDMA_CONFIG_IFIFO_DEPTH_4_XI (1L<<20)
4583#define BNX2_TDMA_CONFIG_IFIFO_DEPTH_8_XI (2L<<20)
4584#define BNX2_TDMA_CONFIG_IFIFO_DEPTH_16_XI (3L<<20)
4585#define BNX2_TDMA_CONFIG_IFIFO_DEPTH_32_XI (4L<<20)
4586#define BNX2_TDMA_CONFIG_IFIFO_DEPTH_64_XI (5L<<20)
4587#define BNX2_TDMA_CONFIG_FIFO_CMP_EN_XI (1L<<23)
4588#define BNX2_TDMA_CONFIG_BYTES_OST_XI (0x7L<<24)
4589#define BNX2_TDMA_CONFIG_BYTES_OST_512_XI (0L<<24)
4590#define BNX2_TDMA_CONFIG_BYTES_OST_1024_XI (1L<<24)
4591#define BNX2_TDMA_CONFIG_BYTES_OST_2048_XI (2L<<24)
4592#define BNX2_TDMA_CONFIG_BYTES_OST_4096_XI (3L<<24)
4593#define BNX2_TDMA_CONFIG_BYTES_OST_8192_XI (4L<<24)
4594#define BNX2_TDMA_CONFIG_BYTES_OST_16384_XI (5L<<24)
4595#define BNX2_TDMA_CONFIG_HC_BYPASS_XI (1L<<27)
4596#define BNX2_TDMA_CONFIG_LCL_MRRS_XI (0x7L<<28)
4597#define BNX2_TDMA_CONFIG_LCL_MRRS_128_XI (0L<<28)
4598#define BNX2_TDMA_CONFIG_LCL_MRRS_256_XI (1L<<28)
4599#define BNX2_TDMA_CONFIG_LCL_MRRS_512_XI (2L<<28)
4600#define BNX2_TDMA_CONFIG_LCL_MRRS_1024_XI (3L<<28)
4601#define BNX2_TDMA_CONFIG_LCL_MRRS_2048_XI (4L<<28)
4602#define BNX2_TDMA_CONFIG_LCL_MRRS_4096_XI (5L<<28)
4603#define BNX2_TDMA_CONFIG_LCL_MRRS_EN_XI (1L<<31)
2653 4604
2654#define BNX2_TDMA_PAYLOAD_PROD 0x00005c0c 4605#define BNX2_TDMA_PAYLOAD_PROD 0x00005c0c
2655#define BNX2_TDMA_PAYLOAD_PROD_VALUE (0x1fffL<<3) 4606#define BNX2_TDMA_PAYLOAD_PROD_VALUE (0x1fffL<<3)
@@ -2685,7 +4636,22 @@ struct l2_fhdr {
2685#define BNX2_TDMA_DR_INTF_STATUS_NXT_PNTR (0xfL<<12) 4636#define BNX2_TDMA_DR_INTF_STATUS_NXT_PNTR (0xfL<<12)
2686#define BNX2_TDMA_DR_INTF_STATUS_BYTE_COUNT (0x7L<<16) 4637#define BNX2_TDMA_DR_INTF_STATUS_BYTE_COUNT (0x7L<<16)
2687 4638
2688#define BNX2_TDMA_FTQ_DATA 0x00005fc0 4639#define BNX2_TDMA_PUSH_FSM 0x00005c90
4640#define BNX2_TDMA_BD_IF_DEBUG 0x00005c94
4641#define BNX2_TDMA_DMAD_IF_DEBUG 0x00005c98
4642#define BNX2_TDMA_CTX_IF_DEBUG 0x00005c9c
4643#define BNX2_TDMA_TPBUF_IF_DEBUG 0x00005ca0
4644#define BNX2_TDMA_DR_IF_DEBUG 0x00005ca4
4645#define BNX2_TDMA_TPATQ_IF_DEBUG 0x00005ca8
4646#define BNX2_TDMA_TDMA_ILOCK_CKSUM 0x00005cac
4647#define BNX2_TDMA_TDMA_ILOCK_CKSUM_CALCULATED (0xffffL<<0)
4648#define BNX2_TDMA_TDMA_ILOCK_CKSUM_EXPECTED (0xffffL<<16)
4649
4650#define BNX2_TDMA_TDMA_PCIE_CKSUM 0x00005cb0
4651#define BNX2_TDMA_TDMA_PCIE_CKSUM_CALCULATED (0xffffL<<0)
4652#define BNX2_TDMA_TDMA_PCIE_CKSUM_EXPECTED (0xffffL<<16)
4653
4654#define BNX2_TDMA_TDMAQ 0x00005fc0
2689#define BNX2_TDMA_FTQ_CMD 0x00005ff8 4655#define BNX2_TDMA_FTQ_CMD 0x00005ff8
2690#define BNX2_TDMA_FTQ_CMD_OFFSET (0x3ffL<<0) 4656#define BNX2_TDMA_FTQ_CMD_OFFSET (0x3ffL<<0)
2691#define BNX2_TDMA_FTQ_CMD_WR_TOP (1L<<10) 4657#define BNX2_TDMA_FTQ_CMD_WR_TOP (1L<<10)
@@ -2724,6 +4690,8 @@ struct l2_fhdr {
2724#define BNX2_HC_COMMAND_FORCE_INT_LOW (2L<<19) 4690#define BNX2_HC_COMMAND_FORCE_INT_LOW (2L<<19)
2725#define BNX2_HC_COMMAND_FORCE_INT_FREE (3L<<19) 4691#define BNX2_HC_COMMAND_FORCE_INT_FREE (3L<<19)
2726#define BNX2_HC_COMMAND_CLR_STAT_NOW (1L<<21) 4692#define BNX2_HC_COMMAND_CLR_STAT_NOW (1L<<21)
4693#define BNX2_HC_COMMAND_MAIN_PWR_INT (1L<<22)
4694#define BNX2_HC_COMMAND_COAL_ON_NEXT_EVENT (1L<<27)
2727 4695
2728#define BNX2_HC_STATUS 0x00006804 4696#define BNX2_HC_STATUS 0x00006804
2729#define BNX2_HC_STATUS_MASTER_ABORT (1L<<0) 4697#define BNX2_HC_STATUS_MASTER_ABORT (1L<<0)
@@ -2746,6 +4714,23 @@ struct l2_fhdr {
2746#define BNX2_HC_CONFIG_STATISTIC_PRIORITY (1L<<5) 4714#define BNX2_HC_CONFIG_STATISTIC_PRIORITY (1L<<5)
2747#define BNX2_HC_CONFIG_STATUS_PRIORITY (1L<<6) 4715#define BNX2_HC_CONFIG_STATUS_PRIORITY (1L<<6)
2748#define BNX2_HC_CONFIG_STAT_MEM_ADDR (0xffL<<8) 4716#define BNX2_HC_CONFIG_STAT_MEM_ADDR (0xffL<<8)
4717#define BNX2_HC_CONFIG_PER_MODE (1L<<16)
4718#define BNX2_HC_CONFIG_ONE_SHOT (1L<<17)
4719#define BNX2_HC_CONFIG_USE_INT_PARAM (1L<<18)
4720#define BNX2_HC_CONFIG_SET_MASK_AT_RD (1L<<19)
4721#define BNX2_HC_CONFIG_PER_COLLECT_LIMIT (0xfL<<20)
4722#define BNX2_HC_CONFIG_SB_ADDR_INC (0x7L<<24)
4723#define BNX2_HC_CONFIG_SB_ADDR_INC_64B (0L<<24)
4724#define BNX2_HC_CONFIG_SB_ADDR_INC_128B (1L<<24)
4725#define BNX2_HC_CONFIG_SB_ADDR_INC_256B (2L<<24)
4726#define BNX2_HC_CONFIG_SB_ADDR_INC_512B (3L<<24)
4727#define BNX2_HC_CONFIG_SB_ADDR_INC_1024B (4L<<24)
4728#define BNX2_HC_CONFIG_SB_ADDR_INC_2048B (5L<<24)
4729#define BNX2_HC_CONFIG_SB_ADDR_INC_4096B (6L<<24)
4730#define BNX2_HC_CONFIG_SB_ADDR_INC_8192B (7L<<24)
4731#define BNX2_HC_CONFIG_GEN_STAT_AVG_INTR (1L<<29)
4732#define BNX2_HC_CONFIG_UNMASK_ALL (1L<<30)
4733#define BNX2_HC_CONFIG_TX_SEL (1L<<31)
2749 4734
2750#define BNX2_HC_ATTN_BITS_ENABLE 0x0000680c 4735#define BNX2_HC_ATTN_BITS_ENABLE 0x0000680c
2751#define BNX2_HC_STATUS_ADDR_L 0x00006810 4736#define BNX2_HC_STATUS_ADDR_L 0x00006810
@@ -2782,6 +4767,7 @@ struct l2_fhdr {
2782 4767
2783#define BNX2_HC_PERIODIC_TICKS 0x0000683c 4768#define BNX2_HC_PERIODIC_TICKS 0x0000683c
2784#define BNX2_HC_PERIODIC_TICKS_HC_PERIODIC_TICKS (0xffffL<<0) 4769#define BNX2_HC_PERIODIC_TICKS_HC_PERIODIC_TICKS (0xffffL<<0)
4770#define BNX2_HC_PERIODIC_TICKS_HC_INT_PERIODIC_TICKS (0xffffL<<16)
2785 4771
2786#define BNX2_HC_STAT_COLLECT_TICKS 0x00006840 4772#define BNX2_HC_STAT_COLLECT_TICKS 0x00006840
2787#define BNX2_HC_STAT_COLLECT_TICKS_HC_STAT_COLL_TICKS (0xffL<<4) 4773#define BNX2_HC_STAT_COLLECT_TICKS_HC_STAT_COLL_TICKS (0xffL<<4)
@@ -2789,6 +4775,10 @@ struct l2_fhdr {
2789#define BNX2_HC_STATS_TICKS 0x00006844 4775#define BNX2_HC_STATS_TICKS 0x00006844
2790#define BNX2_HC_STATS_TICKS_HC_STAT_TICKS (0xffffL<<8) 4776#define BNX2_HC_STATS_TICKS_HC_STAT_TICKS (0xffffL<<8)
2791 4777
4778#define BNX2_HC_STATS_INTERRUPT_STATUS 0x00006848
4779#define BNX2_HC_STATS_INTERRUPT_STATUS_SB_STATUS (0x1ffL<<0)
4780#define BNX2_HC_STATS_INTERRUPT_STATUS_INT_STATUS (0x1ffL<<16)
4781
2792#define BNX2_HC_STAT_MEM_DATA 0x0000684c 4782#define BNX2_HC_STAT_MEM_DATA 0x0000684c
2793#define BNX2_HC_STAT_GEN_SEL_0 0x00006850 4783#define BNX2_HC_STAT_GEN_SEL_0 0x00006850
2794#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0 (0x7fL<<0) 4784#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0 (0x7fL<<0)
@@ -2917,24 +4907,108 @@ struct l2_fhdr {
2917#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_1 (0x7fL<<8) 4907#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_1 (0x7fL<<8)
2918#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_2 (0x7fL<<16) 4908#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_2 (0x7fL<<16)
2919#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_3 (0x7fL<<24) 4909#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_3 (0x7fL<<24)
4910#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_XI (0xffL<<0)
4911#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_UMP_RX_FRAME_DROP_XI (52L<<0)
4912#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_UNUSED_S0_XI (57L<<0)
4913#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_UNUSED_S1_XI (58L<<0)
4914#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_UNUSED_S2_XI (85L<<0)
4915#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_UNUSED_S3_XI (86L<<0)
4916#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_UNUSED_S4_XI (87L<<0)
4917#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_UNUSED_S5_XI (88L<<0)
4918#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_UNUSED_S6_XI (89L<<0)
4919#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_UNUSED_S7_XI (90L<<0)
4920#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_UNUSED_S8_XI (91L<<0)
4921#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_UNUSED_S9_XI (92L<<0)
4922#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_UNUSED_S10_XI (93L<<0)
4923#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_MQ_IDB_OFLOW_XI (94L<<0)
4924#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_CTX_BLK_RD_CNT_XI (123L<<0)
4925#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_CTX_BLK_WR_CNT_XI (124L<<0)
4926#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_CTX_HITS_XI (125L<<0)
4927#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_CTX_MISSES_XI (126L<<0)
4928#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_STATUS_BLOCKS_VEC1_XI (128L<<0)
4929#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_INT_GEN_VEC1_XI (129L<<0)
4930#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_INT_MBOX_WR_VEC1_XI (130L<<0)
4931#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_TO_HW_INTACK_VEC1_XI (131L<<0)
4932#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_TO_SW_INTACK_VEC1_XI (132L<<0)
4933#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_DURING_SW_INTACK_VEC1_XI (133L<<0)
4934#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_STATUS_BLOCKS_VEC2_XI (134L<<0)
4935#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_INT_GEN_VEC2_XI (135L<<0)
4936#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_INT_MBOX_WR_VEC2_XI (136L<<0)
4937#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_TO_HW_INTACK_VEC2_XI (137L<<0)
4938#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_TO_SW_INTACK_VEC2_XI (138L<<0)
4939#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_DURING_SW_INTACK_VEC2_XI (139L<<0)
4940#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_STATUS_BLOCKS_VEC3_XI (140L<<0)
4941#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_INT_GEN_VEC3_XI (141L<<0)
4942#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_INT_MBOX_WR_VEC3_XI (142L<<0)
4943#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_TO_HW_INTACK_VEC3_XI (143L<<0)
4944#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_TO_SW_INTACK_VEC3_XI (144L<<0)
4945#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_DURING_SW_INTACK_VEC3_XI (145L<<0)
4946#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_STATUS_BLOCKS_VEC4_XI (146L<<0)
4947#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_INT_GEN_VEC4_XI (147L<<0)
4948#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_INT_MBOX_WR_VEC4_XI (148L<<0)
4949#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_TO_HW_INTACK_VEC4_XI (149L<<0)
4950#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_TO_SW_INTACK_VEC4_XI (150L<<0)
4951#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_DURING_SW_INTACK_VEC4_XI (151L<<0)
4952#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_STATUS_BLOCKS_VEC5_XI (152L<<0)
4953#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_INT_GEN_VEC5_XI (153L<<0)
4954#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_INT_MBOX_WR_VEC5_XI (154L<<0)
4955#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_TO_HW_INTACK_VEC5_XI (155L<<0)
4956#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_TO_SW_INTACK_VEC5_XI (156L<<0)
4957#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_DURING_SW_INTACK_VEC5_XI (157L<<0)
4958#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_STATUS_BLOCKS_VEC6_XI (158L<<0)
4959#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_INT_GEN_VEC6_XI (159L<<0)
4960#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_INT_MBOX_WR_VEC6_XI (160L<<0)
4961#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_TO_HW_INTACK_VEC6_XI (161L<<0)
4962#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_TO_SW_INTACK_VEC6_XI (162L<<0)
4963#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_DURING_SW_INTACK_VEC6_XI (163L<<0)
4964#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_STATUS_BLOCKS_VEC7_XI (164L<<0)
4965#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_INT_GEN_VEC7_XI (165L<<0)
4966#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_INT_MBOX_WR_VEC7_XI (166L<<0)
4967#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_TO_HW_INTACK_VEC7_XI (167L<<0)
4968#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_TO_SW_INTACK_VEC7_XI (168L<<0)
4969#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_DURING_SW_INTACK_VEC7_XI (169L<<0)
4970#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_STATUS_BLOCKS_VEC8_XI (170L<<0)
4971#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_INT_GEN_VEC8_XI (171L<<0)
4972#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_INT_MBOX_WR_VEC8_XI (172L<<0)
4973#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_TO_HW_INTACK_VEC8_XI (173L<<0)
4974#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_TO_SW_INTACK_VEC8_XI (174L<<0)
4975#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_DURING_SW_INTACK_VEC8_XI (175L<<0)
4976#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_RV2PCS_CMD_CNT_XI (176L<<0)
4977#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_RV2PCS_SLOT_CNT_XI (177L<<0)
4978#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_RV2PCSQ_VALID_CNT_XI (178L<<0)
4979#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_1_XI (0xffL<<8)
4980#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_2_XI (0xffL<<16)
4981#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_3_XI (0xffL<<24)
2920 4982
2921#define BNX2_HC_STAT_GEN_SEL_1 0x00006854 4983#define BNX2_HC_STAT_GEN_SEL_1 0x00006854
2922#define BNX2_HC_STAT_GEN_SEL_1_GEN_SEL_4 (0x7fL<<0) 4984#define BNX2_HC_STAT_GEN_SEL_1_GEN_SEL_4 (0x7fL<<0)
2923#define BNX2_HC_STAT_GEN_SEL_1_GEN_SEL_5 (0x7fL<<8) 4985#define BNX2_HC_STAT_GEN_SEL_1_GEN_SEL_5 (0x7fL<<8)
2924#define BNX2_HC_STAT_GEN_SEL_1_GEN_SEL_6 (0x7fL<<16) 4986#define BNX2_HC_STAT_GEN_SEL_1_GEN_SEL_6 (0x7fL<<16)
2925#define BNX2_HC_STAT_GEN_SEL_1_GEN_SEL_7 (0x7fL<<24) 4987#define BNX2_HC_STAT_GEN_SEL_1_GEN_SEL_7 (0x7fL<<24)
4988#define BNX2_HC_STAT_GEN_SEL_1_GEN_SEL_4_XI (0xffL<<0)
4989#define BNX2_HC_STAT_GEN_SEL_1_GEN_SEL_5_XI (0xffL<<8)
4990#define BNX2_HC_STAT_GEN_SEL_1_GEN_SEL_6_XI (0xffL<<16)
4991#define BNX2_HC_STAT_GEN_SEL_1_GEN_SEL_7_XI (0xffL<<24)
2926 4992
2927#define BNX2_HC_STAT_GEN_SEL_2 0x00006858 4993#define BNX2_HC_STAT_GEN_SEL_2 0x00006858
2928#define BNX2_HC_STAT_GEN_SEL_2_GEN_SEL_8 (0x7fL<<0) 4994#define BNX2_HC_STAT_GEN_SEL_2_GEN_SEL_8 (0x7fL<<0)
2929#define BNX2_HC_STAT_GEN_SEL_2_GEN_SEL_9 (0x7fL<<8) 4995#define BNX2_HC_STAT_GEN_SEL_2_GEN_SEL_9 (0x7fL<<8)
2930#define BNX2_HC_STAT_GEN_SEL_2_GEN_SEL_10 (0x7fL<<16) 4996#define BNX2_HC_STAT_GEN_SEL_2_GEN_SEL_10 (0x7fL<<16)
2931#define BNX2_HC_STAT_GEN_SEL_2_GEN_SEL_11 (0x7fL<<24) 4997#define BNX2_HC_STAT_GEN_SEL_2_GEN_SEL_11 (0x7fL<<24)
4998#define BNX2_HC_STAT_GEN_SEL_2_GEN_SEL_8_XI (0xffL<<0)
4999#define BNX2_HC_STAT_GEN_SEL_2_GEN_SEL_9_XI (0xffL<<8)
5000#define BNX2_HC_STAT_GEN_SEL_2_GEN_SEL_10_XI (0xffL<<16)
5001#define BNX2_HC_STAT_GEN_SEL_2_GEN_SEL_11_XI (0xffL<<24)
2932 5002
2933#define BNX2_HC_STAT_GEN_SEL_3 0x0000685c 5003#define BNX2_HC_STAT_GEN_SEL_3 0x0000685c
2934#define BNX2_HC_STAT_GEN_SEL_3_GEN_SEL_12 (0x7fL<<0) 5004#define BNX2_HC_STAT_GEN_SEL_3_GEN_SEL_12 (0x7fL<<0)
2935#define BNX2_HC_STAT_GEN_SEL_3_GEN_SEL_13 (0x7fL<<8) 5005#define BNX2_HC_STAT_GEN_SEL_3_GEN_SEL_13 (0x7fL<<8)
2936#define BNX2_HC_STAT_GEN_SEL_3_GEN_SEL_14 (0x7fL<<16) 5006#define BNX2_HC_STAT_GEN_SEL_3_GEN_SEL_14 (0x7fL<<16)
2937#define BNX2_HC_STAT_GEN_SEL_3_GEN_SEL_15 (0x7fL<<24) 5007#define BNX2_HC_STAT_GEN_SEL_3_GEN_SEL_15 (0x7fL<<24)
5008#define BNX2_HC_STAT_GEN_SEL_3_GEN_SEL_12_XI (0xffL<<0)
5009#define BNX2_HC_STAT_GEN_SEL_3_GEN_SEL_13_XI (0xffL<<8)
5010#define BNX2_HC_STAT_GEN_SEL_3_GEN_SEL_14_XI (0xffL<<16)
5011#define BNX2_HC_STAT_GEN_SEL_3_GEN_SEL_15_XI (0xffL<<24)
2938 5012
2939#define BNX2_HC_STAT_GEN_STAT0 0x00006888 5013#define BNX2_HC_STAT_GEN_STAT0 0x00006888
2940#define BNX2_HC_STAT_GEN_STAT1 0x0000688c 5014#define BNX2_HC_STAT_GEN_STAT1 0x0000688c
@@ -2968,6 +5042,7 @@ struct l2_fhdr {
2968#define BNX2_HC_STAT_GEN_STAT_AC13 0x000068fc 5042#define BNX2_HC_STAT_GEN_STAT_AC13 0x000068fc
2969#define BNX2_HC_STAT_GEN_STAT_AC14 0x00006900 5043#define BNX2_HC_STAT_GEN_STAT_AC14 0x00006900
2970#define BNX2_HC_STAT_GEN_STAT_AC15 0x00006904 5044#define BNX2_HC_STAT_GEN_STAT_AC15 0x00006904
5045#define BNX2_HC_STAT_GEN_STAT_AC 0x000068c8
2971#define BNX2_HC_VIS 0x00006908 5046#define BNX2_HC_VIS 0x00006908
2972#define BNX2_HC_VIS_STAT_BUILD_STATE (0xfL<<0) 5047#define BNX2_HC_VIS_STAT_BUILD_STATE (0xfL<<0)
2973#define BNX2_HC_VIS_STAT_BUILD_STATE_IDLE (0L<<0) 5048#define BNX2_HC_VIS_STAT_BUILD_STATE_IDLE (0L<<0)
@@ -3038,6 +5113,349 @@ struct l2_fhdr {
3038#define BNX2_HC_DEBUG_VECT_PEEK_2_PEEK_EN (1L<<27) 5113#define BNX2_HC_DEBUG_VECT_PEEK_2_PEEK_EN (1L<<27)
3039#define BNX2_HC_DEBUG_VECT_PEEK_2_SEL (0xfL<<28) 5114#define BNX2_HC_DEBUG_VECT_PEEK_2_SEL (0xfL<<28)
3040 5115
5116#define BNX2_HC_COALESCE_NOW 0x00006914
5117#define BNX2_HC_COALESCE_NOW_COAL_NOW (0x1ffL<<1)
5118#define BNX2_HC_COALESCE_NOW_COAL_NOW_WO_INT (0x1ffL<<11)
5119#define BNX2_HC_COALESCE_NOW_COAL_ON_NXT_EVENT (0x1ffL<<21)
5120
5121#define BNX2_HC_MSIX_BIT_VECTOR 0x00006918
5122#define BNX2_HC_MSIX_BIT_VECTOR_VAL (0x1ffL<<0)
5123
5124#define BNX2_HC_SB_CONFIG_1 0x00006a00
5125#define BNX2_HC_SB_CONFIG_1_RX_TMR_MODE (1L<<1)
5126#define BNX2_HC_SB_CONFIG_1_TX_TMR_MODE (1L<<2)
5127#define BNX2_HC_SB_CONFIG_1_COM_TMR_MODE (1L<<3)
5128#define BNX2_HC_SB_CONFIG_1_CMD_TMR_MODE (1L<<4)
5129#define BNX2_HC_SB_CONFIG_1_PER_MODE (1L<<16)
5130#define BNX2_HC_SB_CONFIG_1_ONE_SHOT (1L<<17)
5131#define BNX2_HC_SB_CONFIG_1_USE_INT_PARAM (1L<<18)
5132#define BNX2_HC_SB_CONFIG_1_PER_COLLECT_LIMIT (0xfL<<20)
5133
5134#define BNX2_HC_TX_QUICK_CONS_TRIP_1 0x00006a04
5135#define BNX2_HC_TX_QUICK_CONS_TRIP_1_VALUE (0xffL<<0)
5136#define BNX2_HC_TX_QUICK_CONS_TRIP_1_INT (0xffL<<16)
5137
5138#define BNX2_HC_COMP_PROD_TRIP_1 0x00006a08
5139#define BNX2_HC_COMP_PROD_TRIP_1_VALUE (0xffL<<0)
5140#define BNX2_HC_COMP_PROD_TRIP_1_INT (0xffL<<16)
5141
5142#define BNX2_HC_RX_QUICK_CONS_TRIP_1 0x00006a0c
5143#define BNX2_HC_RX_QUICK_CONS_TRIP_1_VALUE (0xffL<<0)
5144#define BNX2_HC_RX_QUICK_CONS_TRIP_1_INT (0xffL<<16)
5145
5146#define BNX2_HC_RX_TICKS_1 0x00006a10
5147#define BNX2_HC_RX_TICKS_1_VALUE (0x3ffL<<0)
5148#define BNX2_HC_RX_TICKS_1_INT (0x3ffL<<16)
5149
5150#define BNX2_HC_TX_TICKS_1 0x00006a14
5151#define BNX2_HC_TX_TICKS_1_VALUE (0x3ffL<<0)
5152#define BNX2_HC_TX_TICKS_1_INT (0x3ffL<<16)
5153
5154#define BNX2_HC_COM_TICKS_1 0x00006a18
5155#define BNX2_HC_COM_TICKS_1_VALUE (0x3ffL<<0)
5156#define BNX2_HC_COM_TICKS_1_INT (0x3ffL<<16)
5157
5158#define BNX2_HC_CMD_TICKS_1 0x00006a1c
5159#define BNX2_HC_CMD_TICKS_1_VALUE (0x3ffL<<0)
5160#define BNX2_HC_CMD_TICKS_1_INT (0x3ffL<<16)
5161
5162#define BNX2_HC_PERIODIC_TICKS_1 0x00006a20
5163#define BNX2_HC_PERIODIC_TICKS_1_HC_PERIODIC_TICKS (0xffffL<<0)
5164#define BNX2_HC_PERIODIC_TICKS_1_HC_INT_PERIODIC_TICKS (0xffffL<<16)
5165
5166#define BNX2_HC_SB_CONFIG_2 0x00006a24
5167#define BNX2_HC_SB_CONFIG_2_RX_TMR_MODE (1L<<1)
5168#define BNX2_HC_SB_CONFIG_2_TX_TMR_MODE (1L<<2)
5169#define BNX2_HC_SB_CONFIG_2_COM_TMR_MODE (1L<<3)
5170#define BNX2_HC_SB_CONFIG_2_CMD_TMR_MODE (1L<<4)
5171#define BNX2_HC_SB_CONFIG_2_PER_MODE (1L<<16)
5172#define BNX2_HC_SB_CONFIG_2_ONE_SHOT (1L<<17)
5173#define BNX2_HC_SB_CONFIG_2_USE_INT_PARAM (1L<<18)
5174#define BNX2_HC_SB_CONFIG_2_PER_COLLECT_LIMIT (0xfL<<20)
5175
5176#define BNX2_HC_TX_QUICK_CONS_TRIP_2 0x00006a28
5177#define BNX2_HC_TX_QUICK_CONS_TRIP_2_VALUE (0xffL<<0)
5178#define BNX2_HC_TX_QUICK_CONS_TRIP_2_INT (0xffL<<16)
5179
5180#define BNX2_HC_COMP_PROD_TRIP_2 0x00006a2c
5181#define BNX2_HC_COMP_PROD_TRIP_2_VALUE (0xffL<<0)
5182#define BNX2_HC_COMP_PROD_TRIP_2_INT (0xffL<<16)
5183
5184#define BNX2_HC_RX_QUICK_CONS_TRIP_2 0x00006a30
5185#define BNX2_HC_RX_QUICK_CONS_TRIP_2_VALUE (0xffL<<0)
5186#define BNX2_HC_RX_QUICK_CONS_TRIP_2_INT (0xffL<<16)
5187
5188#define BNX2_HC_RX_TICKS_2 0x00006a34
5189#define BNX2_HC_RX_TICKS_2_VALUE (0x3ffL<<0)
5190#define BNX2_HC_RX_TICKS_2_INT (0x3ffL<<16)
5191
5192#define BNX2_HC_TX_TICKS_2 0x00006a38
5193#define BNX2_HC_TX_TICKS_2_VALUE (0x3ffL<<0)
5194#define BNX2_HC_TX_TICKS_2_INT (0x3ffL<<16)
5195
5196#define BNX2_HC_COM_TICKS_2 0x00006a3c
5197#define BNX2_HC_COM_TICKS_2_VALUE (0x3ffL<<0)
5198#define BNX2_HC_COM_TICKS_2_INT (0x3ffL<<16)
5199
5200#define BNX2_HC_CMD_TICKS_2 0x00006a40
5201#define BNX2_HC_CMD_TICKS_2_VALUE (0x3ffL<<0)
5202#define BNX2_HC_CMD_TICKS_2_INT (0x3ffL<<16)
5203
5204#define BNX2_HC_PERIODIC_TICKS_2 0x00006a44
5205#define BNX2_HC_PERIODIC_TICKS_2_HC_PERIODIC_TICKS (0xffffL<<0)
5206#define BNX2_HC_PERIODIC_TICKS_2_HC_INT_PERIODIC_TICKS (0xffffL<<16)
5207
5208#define BNX2_HC_SB_CONFIG_3 0x00006a48
5209#define BNX2_HC_SB_CONFIG_3_RX_TMR_MODE (1L<<1)
5210#define BNX2_HC_SB_CONFIG_3_TX_TMR_MODE (1L<<2)
5211#define BNX2_HC_SB_CONFIG_3_COM_TMR_MODE (1L<<3)
5212#define BNX2_HC_SB_CONFIG_3_CMD_TMR_MODE (1L<<4)
5213#define BNX2_HC_SB_CONFIG_3_PER_MODE (1L<<16)
5214#define BNX2_HC_SB_CONFIG_3_ONE_SHOT (1L<<17)
5215#define BNX2_HC_SB_CONFIG_3_USE_INT_PARAM (1L<<18)
5216#define BNX2_HC_SB_CONFIG_3_PER_COLLECT_LIMIT (0xfL<<20)
5217
5218#define BNX2_HC_TX_QUICK_CONS_TRIP_3 0x00006a4c
5219#define BNX2_HC_TX_QUICK_CONS_TRIP_3_VALUE (0xffL<<0)
5220#define BNX2_HC_TX_QUICK_CONS_TRIP_3_INT (0xffL<<16)
5221
5222#define BNX2_HC_COMP_PROD_TRIP_3 0x00006a50
5223#define BNX2_HC_COMP_PROD_TRIP_3_VALUE (0xffL<<0)
5224#define BNX2_HC_COMP_PROD_TRIP_3_INT (0xffL<<16)
5225
5226#define BNX2_HC_RX_QUICK_CONS_TRIP_3 0x00006a54
5227#define BNX2_HC_RX_QUICK_CONS_TRIP_3_VALUE (0xffL<<0)
5228#define BNX2_HC_RX_QUICK_CONS_TRIP_3_INT (0xffL<<16)
5229
5230#define BNX2_HC_RX_TICKS_3 0x00006a58
5231#define BNX2_HC_RX_TICKS_3_VALUE (0x3ffL<<0)
5232#define BNX2_HC_RX_TICKS_3_INT (0x3ffL<<16)
5233
5234#define BNX2_HC_TX_TICKS_3 0x00006a5c
5235#define BNX2_HC_TX_TICKS_3_VALUE (0x3ffL<<0)
5236#define BNX2_HC_TX_TICKS_3_INT (0x3ffL<<16)
5237
5238#define BNX2_HC_COM_TICKS_3 0x00006a60
5239#define BNX2_HC_COM_TICKS_3_VALUE (0x3ffL<<0)
5240#define BNX2_HC_COM_TICKS_3_INT (0x3ffL<<16)
5241
5242#define BNX2_HC_CMD_TICKS_3 0x00006a64
5243#define BNX2_HC_CMD_TICKS_3_VALUE (0x3ffL<<0)
5244#define BNX2_HC_CMD_TICKS_3_INT (0x3ffL<<16)
5245
5246#define BNX2_HC_PERIODIC_TICKS_3 0x00006a68
5247#define BNX2_HC_PERIODIC_TICKS_3_HC_PERIODIC_TICKS (0xffffL<<0)
5248#define BNX2_HC_PERIODIC_TICKS_3_HC_INT_PERIODIC_TICKS (0xffffL<<16)
5249
5250#define BNX2_HC_SB_CONFIG_4 0x00006a6c
5251#define BNX2_HC_SB_CONFIG_4_RX_TMR_MODE (1L<<1)
5252#define BNX2_HC_SB_CONFIG_4_TX_TMR_MODE (1L<<2)
5253#define BNX2_HC_SB_CONFIG_4_COM_TMR_MODE (1L<<3)
5254#define BNX2_HC_SB_CONFIG_4_CMD_TMR_MODE (1L<<4)
5255#define BNX2_HC_SB_CONFIG_4_PER_MODE (1L<<16)
5256#define BNX2_HC_SB_CONFIG_4_ONE_SHOT (1L<<17)
5257#define BNX2_HC_SB_CONFIG_4_USE_INT_PARAM (1L<<18)
5258#define BNX2_HC_SB_CONFIG_4_PER_COLLECT_LIMIT (0xfL<<20)
5259
5260#define BNX2_HC_TX_QUICK_CONS_TRIP_4 0x00006a70
5261#define BNX2_HC_TX_QUICK_CONS_TRIP_4_VALUE (0xffL<<0)
5262#define BNX2_HC_TX_QUICK_CONS_TRIP_4_INT (0xffL<<16)
5263
5264#define BNX2_HC_COMP_PROD_TRIP_4 0x00006a74
5265#define BNX2_HC_COMP_PROD_TRIP_4_VALUE (0xffL<<0)
5266#define BNX2_HC_COMP_PROD_TRIP_4_INT (0xffL<<16)
5267
5268#define BNX2_HC_RX_QUICK_CONS_TRIP_4 0x00006a78
5269#define BNX2_HC_RX_QUICK_CONS_TRIP_4_VALUE (0xffL<<0)
5270#define BNX2_HC_RX_QUICK_CONS_TRIP_4_INT (0xffL<<16)
5271
5272#define BNX2_HC_RX_TICKS_4 0x00006a7c
5273#define BNX2_HC_RX_TICKS_4_VALUE (0x3ffL<<0)
5274#define BNX2_HC_RX_TICKS_4_INT (0x3ffL<<16)
5275
5276#define BNX2_HC_TX_TICKS_4 0x00006a80
5277#define BNX2_HC_TX_TICKS_4_VALUE (0x3ffL<<0)
5278#define BNX2_HC_TX_TICKS_4_INT (0x3ffL<<16)
5279
5280#define BNX2_HC_COM_TICKS_4 0x00006a84
5281#define BNX2_HC_COM_TICKS_4_VALUE (0x3ffL<<0)
5282#define BNX2_HC_COM_TICKS_4_INT (0x3ffL<<16)
5283
5284#define BNX2_HC_CMD_TICKS_4 0x00006a88
5285#define BNX2_HC_CMD_TICKS_4_VALUE (0x3ffL<<0)
5286#define BNX2_HC_CMD_TICKS_4_INT (0x3ffL<<16)
5287
5288#define BNX2_HC_PERIODIC_TICKS_4 0x00006a8c
5289#define BNX2_HC_PERIODIC_TICKS_4_HC_PERIODIC_TICKS (0xffffL<<0)
5290#define BNX2_HC_PERIODIC_TICKS_4_HC_INT_PERIODIC_TICKS (0xffffL<<16)
5291
5292#define BNX2_HC_SB_CONFIG_5 0x00006a90
5293#define BNX2_HC_SB_CONFIG_5_RX_TMR_MODE (1L<<1)
5294#define BNX2_HC_SB_CONFIG_5_TX_TMR_MODE (1L<<2)
5295#define BNX2_HC_SB_CONFIG_5_COM_TMR_MODE (1L<<3)
5296#define BNX2_HC_SB_CONFIG_5_CMD_TMR_MODE (1L<<4)
5297#define BNX2_HC_SB_CONFIG_5_PER_MODE (1L<<16)
5298#define BNX2_HC_SB_CONFIG_5_ONE_SHOT (1L<<17)
5299#define BNX2_HC_SB_CONFIG_5_USE_INT_PARAM (1L<<18)
5300#define BNX2_HC_SB_CONFIG_5_PER_COLLECT_LIMIT (0xfL<<20)
5301
5302#define BNX2_HC_TX_QUICK_CONS_TRIP_5 0x00006a94
5303#define BNX2_HC_TX_QUICK_CONS_TRIP_5_VALUE (0xffL<<0)
5304#define BNX2_HC_TX_QUICK_CONS_TRIP_5_INT (0xffL<<16)
5305
5306#define BNX2_HC_COMP_PROD_TRIP_5 0x00006a98
5307#define BNX2_HC_COMP_PROD_TRIP_5_VALUE (0xffL<<0)
5308#define BNX2_HC_COMP_PROD_TRIP_5_INT (0xffL<<16)
5309
5310#define BNX2_HC_RX_QUICK_CONS_TRIP_5 0x00006a9c
5311#define BNX2_HC_RX_QUICK_CONS_TRIP_5_VALUE (0xffL<<0)
5312#define BNX2_HC_RX_QUICK_CONS_TRIP_5_INT (0xffL<<16)
5313
5314#define BNX2_HC_RX_TICKS_5 0x00006aa0
5315#define BNX2_HC_RX_TICKS_5_VALUE (0x3ffL<<0)
5316#define BNX2_HC_RX_TICKS_5_INT (0x3ffL<<16)
5317
5318#define BNX2_HC_TX_TICKS_5 0x00006aa4
5319#define BNX2_HC_TX_TICKS_5_VALUE (0x3ffL<<0)
5320#define BNX2_HC_TX_TICKS_5_INT (0x3ffL<<16)
5321
5322#define BNX2_HC_COM_TICKS_5 0x00006aa8
5323#define BNX2_HC_COM_TICKS_5_VALUE (0x3ffL<<0)
5324#define BNX2_HC_COM_TICKS_5_INT (0x3ffL<<16)
5325
5326#define BNX2_HC_CMD_TICKS_5 0x00006aac
5327#define BNX2_HC_CMD_TICKS_5_VALUE (0x3ffL<<0)
5328#define BNX2_HC_CMD_TICKS_5_INT (0x3ffL<<16)
5329
5330#define BNX2_HC_PERIODIC_TICKS_5 0x00006ab0
5331#define BNX2_HC_PERIODIC_TICKS_5_HC_PERIODIC_TICKS (0xffffL<<0)
5332#define BNX2_HC_PERIODIC_TICKS_5_HC_INT_PERIODIC_TICKS (0xffffL<<16)
5333
5334#define BNX2_HC_SB_CONFIG_6 0x00006ab4
5335#define BNX2_HC_SB_CONFIG_6_RX_TMR_MODE (1L<<1)
5336#define BNX2_HC_SB_CONFIG_6_TX_TMR_MODE (1L<<2)
5337#define BNX2_HC_SB_CONFIG_6_COM_TMR_MODE (1L<<3)
5338#define BNX2_HC_SB_CONFIG_6_CMD_TMR_MODE (1L<<4)
5339#define BNX2_HC_SB_CONFIG_6_PER_MODE (1L<<16)
5340#define BNX2_HC_SB_CONFIG_6_ONE_SHOT (1L<<17)
5341#define BNX2_HC_SB_CONFIG_6_USE_INT_PARAM (1L<<18)
5342#define BNX2_HC_SB_CONFIG_6_PER_COLLECT_LIMIT (0xfL<<20)
5343
5344#define BNX2_HC_TX_QUICK_CONS_TRIP_6 0x00006ab8
5345#define BNX2_HC_TX_QUICK_CONS_TRIP_6_VALUE (0xffL<<0)
5346#define BNX2_HC_TX_QUICK_CONS_TRIP_6_INT (0xffL<<16)
5347
5348#define BNX2_HC_COMP_PROD_TRIP_6 0x00006abc
5349#define BNX2_HC_COMP_PROD_TRIP_6_VALUE (0xffL<<0)
5350#define BNX2_HC_COMP_PROD_TRIP_6_INT (0xffL<<16)
5351
5352#define BNX2_HC_RX_QUICK_CONS_TRIP_6 0x00006ac0
5353#define BNX2_HC_RX_QUICK_CONS_TRIP_6_VALUE (0xffL<<0)
5354#define BNX2_HC_RX_QUICK_CONS_TRIP_6_INT (0xffL<<16)
5355
5356#define BNX2_HC_RX_TICKS_6 0x00006ac4
5357#define BNX2_HC_RX_TICKS_6_VALUE (0x3ffL<<0)
5358#define BNX2_HC_RX_TICKS_6_INT (0x3ffL<<16)
5359
5360#define BNX2_HC_TX_TICKS_6 0x00006ac8
5361#define BNX2_HC_TX_TICKS_6_VALUE (0x3ffL<<0)
5362#define BNX2_HC_TX_TICKS_6_INT (0x3ffL<<16)
5363
5364#define BNX2_HC_COM_TICKS_6 0x00006acc
5365#define BNX2_HC_COM_TICKS_6_VALUE (0x3ffL<<0)
5366#define BNX2_HC_COM_TICKS_6_INT (0x3ffL<<16)
5367
5368#define BNX2_HC_CMD_TICKS_6 0x00006ad0
5369#define BNX2_HC_CMD_TICKS_6_VALUE (0x3ffL<<0)
5370#define BNX2_HC_CMD_TICKS_6_INT (0x3ffL<<16)
5371
5372#define BNX2_HC_PERIODIC_TICKS_6 0x00006ad4
5373#define BNX2_HC_PERIODIC_TICKS_6_HC_PERIODIC_TICKS (0xffffL<<0)
5374#define BNX2_HC_PERIODIC_TICKS_6_HC_INT_PERIODIC_TICKS (0xffffL<<16)
5375
5376#define BNX2_HC_SB_CONFIG_7 0x00006ad8
5377#define BNX2_HC_SB_CONFIG_7_RX_TMR_MODE (1L<<1)
5378#define BNX2_HC_SB_CONFIG_7_TX_TMR_MODE (1L<<2)
5379#define BNX2_HC_SB_CONFIG_7_COM_TMR_MODE (1L<<3)
5380#define BNX2_HC_SB_CONFIG_7_CMD_TMR_MODE (1L<<4)
5381#define BNX2_HC_SB_CONFIG_7_PER_MODE (1L<<16)
5382#define BNX2_HC_SB_CONFIG_7_ONE_SHOT (1L<<17)
5383#define BNX2_HC_SB_CONFIG_7_USE_INT_PARAM (1L<<18)
5384#define BNX2_HC_SB_CONFIG_7_PER_COLLECT_LIMIT (0xfL<<20)
5385
5386#define BNX2_HC_TX_QUICK_CONS_TRIP_7 0x00006adc
5387#define BNX2_HC_TX_QUICK_CONS_TRIP_7_VALUE (0xffL<<0)
5388#define BNX2_HC_TX_QUICK_CONS_TRIP_7_INT (0xffL<<16)
5389
5390#define BNX2_HC_COMP_PROD_TRIP_7 0x00006ae0
5391#define BNX2_HC_COMP_PROD_TRIP_7_VALUE (0xffL<<0)
5392#define BNX2_HC_COMP_PROD_TRIP_7_INT (0xffL<<16)
5393
5394#define BNX2_HC_RX_QUICK_CONS_TRIP_7 0x00006ae4
5395#define BNX2_HC_RX_QUICK_CONS_TRIP_7_VALUE (0xffL<<0)
5396#define BNX2_HC_RX_QUICK_CONS_TRIP_7_INT (0xffL<<16)
5397
5398#define BNX2_HC_RX_TICKS_7 0x00006ae8
5399#define BNX2_HC_RX_TICKS_7_VALUE (0x3ffL<<0)
5400#define BNX2_HC_RX_TICKS_7_INT (0x3ffL<<16)
5401
5402#define BNX2_HC_TX_TICKS_7 0x00006aec
5403#define BNX2_HC_TX_TICKS_7_VALUE (0x3ffL<<0)
5404#define BNX2_HC_TX_TICKS_7_INT (0x3ffL<<16)
5405
5406#define BNX2_HC_COM_TICKS_7 0x00006af0
5407#define BNX2_HC_COM_TICKS_7_VALUE (0x3ffL<<0)
5408#define BNX2_HC_COM_TICKS_7_INT (0x3ffL<<16)
5409
5410#define BNX2_HC_CMD_TICKS_7 0x00006af4
5411#define BNX2_HC_CMD_TICKS_7_VALUE (0x3ffL<<0)
5412#define BNX2_HC_CMD_TICKS_7_INT (0x3ffL<<16)
5413
5414#define BNX2_HC_PERIODIC_TICKS_7 0x00006af8
5415#define BNX2_HC_PERIODIC_TICKS_7_HC_PERIODIC_TICKS (0xffffL<<0)
5416#define BNX2_HC_PERIODIC_TICKS_7_HC_INT_PERIODIC_TICKS (0xffffL<<16)
5417
5418#define BNX2_HC_SB_CONFIG_8 0x00006afc
5419#define BNX2_HC_SB_CONFIG_8_RX_TMR_MODE (1L<<1)
5420#define BNX2_HC_SB_CONFIG_8_TX_TMR_MODE (1L<<2)
5421#define BNX2_HC_SB_CONFIG_8_COM_TMR_MODE (1L<<3)
5422#define BNX2_HC_SB_CONFIG_8_CMD_TMR_MODE (1L<<4)
5423#define BNX2_HC_SB_CONFIG_8_PER_MODE (1L<<16)
5424#define BNX2_HC_SB_CONFIG_8_ONE_SHOT (1L<<17)
5425#define BNX2_HC_SB_CONFIG_8_USE_INT_PARAM (1L<<18)
5426#define BNX2_HC_SB_CONFIG_8_PER_COLLECT_LIMIT (0xfL<<20)
5427
5428#define BNX2_HC_TX_QUICK_CONS_TRIP_8 0x00006b00
5429#define BNX2_HC_TX_QUICK_CONS_TRIP_8_VALUE (0xffL<<0)
5430#define BNX2_HC_TX_QUICK_CONS_TRIP_8_INT (0xffL<<16)
5431
5432#define BNX2_HC_COMP_PROD_TRIP_8 0x00006b04
5433#define BNX2_HC_COMP_PROD_TRIP_8_VALUE (0xffL<<0)
5434#define BNX2_HC_COMP_PROD_TRIP_8_INT (0xffL<<16)
5435
5436#define BNX2_HC_RX_QUICK_CONS_TRIP_8 0x00006b08
5437#define BNX2_HC_RX_QUICK_CONS_TRIP_8_VALUE (0xffL<<0)
5438#define BNX2_HC_RX_QUICK_CONS_TRIP_8_INT (0xffL<<16)
5439
5440#define BNX2_HC_RX_TICKS_8 0x00006b0c
5441#define BNX2_HC_RX_TICKS_8_VALUE (0x3ffL<<0)
5442#define BNX2_HC_RX_TICKS_8_INT (0x3ffL<<16)
5443
5444#define BNX2_HC_TX_TICKS_8 0x00006b10
5445#define BNX2_HC_TX_TICKS_8_VALUE (0x3ffL<<0)
5446#define BNX2_HC_TX_TICKS_8_INT (0x3ffL<<16)
5447
5448#define BNX2_HC_COM_TICKS_8 0x00006b14
5449#define BNX2_HC_COM_TICKS_8_VALUE (0x3ffL<<0)
5450#define BNX2_HC_COM_TICKS_8_INT (0x3ffL<<16)
5451
5452#define BNX2_HC_CMD_TICKS_8 0x00006b18
5453#define BNX2_HC_CMD_TICKS_8_VALUE (0x3ffL<<0)
5454#define BNX2_HC_CMD_TICKS_8_INT (0x3ffL<<16)
5455
5456#define BNX2_HC_PERIODIC_TICKS_8 0x00006b1c
5457#define BNX2_HC_PERIODIC_TICKS_8_HC_PERIODIC_TICKS (0xffffL<<0)
5458#define BNX2_HC_PERIODIC_TICKS_8_HC_INT_PERIODIC_TICKS (0xffffL<<16)
3041 5459
3042 5460
3043/* 5461/*
@@ -3063,7 +5481,7 @@ struct l2_fhdr {
3063#define BNX2_TXP_CPU_STATE_PAGE_0_DATA_HALTED (1L<<3) 5481#define BNX2_TXP_CPU_STATE_PAGE_0_DATA_HALTED (1L<<3)
3064#define BNX2_TXP_CPU_STATE_PAGE_0_INST_HALTED (1L<<4) 5482#define BNX2_TXP_CPU_STATE_PAGE_0_INST_HALTED (1L<<4)
3065#define BNX2_TXP_CPU_STATE_BAD_DATA_ADDR_HALTED (1L<<5) 5483#define BNX2_TXP_CPU_STATE_BAD_DATA_ADDR_HALTED (1L<<5)
3066#define BNX2_TXP_CPU_STATE_BAD_pc_HALTED (1L<<6) 5484#define BNX2_TXP_CPU_STATE_BAD_PC_HALTED (1L<<6)
3067#define BNX2_TXP_CPU_STATE_ALIGN_HALTED (1L<<7) 5485#define BNX2_TXP_CPU_STATE_ALIGN_HALTED (1L<<7)
3068#define BNX2_TXP_CPU_STATE_FIO_ABORT_HALTED (1L<<8) 5486#define BNX2_TXP_CPU_STATE_FIO_ABORT_HALTED (1L<<8)
3069#define BNX2_TXP_CPU_STATE_SOFT_HALTED (1L<<10) 5487#define BNX2_TXP_CPU_STATE_SOFT_HALTED (1L<<10)
@@ -3111,7 +5529,7 @@ struct l2_fhdr {
3111#define BNX2_TXP_CPU_LAST_BRANCH_ADDR_LBA (0x3fffffffL<<2) 5529#define BNX2_TXP_CPU_LAST_BRANCH_ADDR_LBA (0x3fffffffL<<2)
3112 5530
3113#define BNX2_TXP_CPU_REG_FILE 0x00045200 5531#define BNX2_TXP_CPU_REG_FILE 0x00045200
3114#define BNX2_TXP_FTQ_DATA 0x000453c0 5532#define BNX2_TXP_TXPQ 0x000453c0
3115#define BNX2_TXP_FTQ_CMD 0x000453f8 5533#define BNX2_TXP_FTQ_CMD 0x000453f8
3116#define BNX2_TXP_FTQ_CMD_OFFSET (0x3ffL<<0) 5534#define BNX2_TXP_FTQ_CMD_OFFSET (0x3ffL<<0)
3117#define BNX2_TXP_FTQ_CMD_WR_TOP (1L<<10) 5535#define BNX2_TXP_FTQ_CMD_WR_TOP (1L<<10)
@@ -3158,7 +5576,7 @@ struct l2_fhdr {
3158#define BNX2_TPAT_CPU_STATE_PAGE_0_DATA_HALTED (1L<<3) 5576#define BNX2_TPAT_CPU_STATE_PAGE_0_DATA_HALTED (1L<<3)
3159#define BNX2_TPAT_CPU_STATE_PAGE_0_INST_HALTED (1L<<4) 5577#define BNX2_TPAT_CPU_STATE_PAGE_0_INST_HALTED (1L<<4)
3160#define BNX2_TPAT_CPU_STATE_BAD_DATA_ADDR_HALTED (1L<<5) 5578#define BNX2_TPAT_CPU_STATE_BAD_DATA_ADDR_HALTED (1L<<5)
3161#define BNX2_TPAT_CPU_STATE_BAD_pc_HALTED (1L<<6) 5579#define BNX2_TPAT_CPU_STATE_BAD_PC_HALTED (1L<<6)
3162#define BNX2_TPAT_CPU_STATE_ALIGN_HALTED (1L<<7) 5580#define BNX2_TPAT_CPU_STATE_ALIGN_HALTED (1L<<7)
3163#define BNX2_TPAT_CPU_STATE_FIO_ABORT_HALTED (1L<<8) 5581#define BNX2_TPAT_CPU_STATE_FIO_ABORT_HALTED (1L<<8)
3164#define BNX2_TPAT_CPU_STATE_SOFT_HALTED (1L<<10) 5582#define BNX2_TPAT_CPU_STATE_SOFT_HALTED (1L<<10)
@@ -3206,7 +5624,7 @@ struct l2_fhdr {
3206#define BNX2_TPAT_CPU_LAST_BRANCH_ADDR_LBA (0x3fffffffL<<2) 5624#define BNX2_TPAT_CPU_LAST_BRANCH_ADDR_LBA (0x3fffffffL<<2)
3207 5625
3208#define BNX2_TPAT_CPU_REG_FILE 0x00085200 5626#define BNX2_TPAT_CPU_REG_FILE 0x00085200
3209#define BNX2_TPAT_FTQ_DATA 0x000853c0 5627#define BNX2_TPAT_TPATQ 0x000853c0
3210#define BNX2_TPAT_FTQ_CMD 0x000853f8 5628#define BNX2_TPAT_FTQ_CMD 0x000853f8
3211#define BNX2_TPAT_FTQ_CMD_OFFSET (0x3ffL<<0) 5629#define BNX2_TPAT_FTQ_CMD_OFFSET (0x3ffL<<0)
3212#define BNX2_TPAT_FTQ_CMD_WR_TOP (1L<<10) 5630#define BNX2_TPAT_FTQ_CMD_WR_TOP (1L<<10)
@@ -3253,7 +5671,7 @@ struct l2_fhdr {
3253#define BNX2_RXP_CPU_STATE_PAGE_0_DATA_HALTED (1L<<3) 5671#define BNX2_RXP_CPU_STATE_PAGE_0_DATA_HALTED (1L<<3)
3254#define BNX2_RXP_CPU_STATE_PAGE_0_INST_HALTED (1L<<4) 5672#define BNX2_RXP_CPU_STATE_PAGE_0_INST_HALTED (1L<<4)
3255#define BNX2_RXP_CPU_STATE_BAD_DATA_ADDR_HALTED (1L<<5) 5673#define BNX2_RXP_CPU_STATE_BAD_DATA_ADDR_HALTED (1L<<5)
3256#define BNX2_RXP_CPU_STATE_BAD_pc_HALTED (1L<<6) 5674#define BNX2_RXP_CPU_STATE_BAD_PC_HALTED (1L<<6)
3257#define BNX2_RXP_CPU_STATE_ALIGN_HALTED (1L<<7) 5675#define BNX2_RXP_CPU_STATE_ALIGN_HALTED (1L<<7)
3258#define BNX2_RXP_CPU_STATE_FIO_ABORT_HALTED (1L<<8) 5676#define BNX2_RXP_CPU_STATE_FIO_ABORT_HALTED (1L<<8)
3259#define BNX2_RXP_CPU_STATE_SOFT_HALTED (1L<<10) 5677#define BNX2_RXP_CPU_STATE_SOFT_HALTED (1L<<10)
@@ -3301,7 +5719,29 @@ struct l2_fhdr {
3301#define BNX2_RXP_CPU_LAST_BRANCH_ADDR_LBA (0x3fffffffL<<2) 5719#define BNX2_RXP_CPU_LAST_BRANCH_ADDR_LBA (0x3fffffffL<<2)
3302 5720
3303#define BNX2_RXP_CPU_REG_FILE 0x000c5200 5721#define BNX2_RXP_CPU_REG_FILE 0x000c5200
3304#define BNX2_RXP_CFTQ_DATA 0x000c5380 5722#define BNX2_RXP_PFE_PFE_CTL 0x000c537c
5723#define BNX2_RXP_PFE_PFE_CTL_INC_USAGE_CNT (1L<<0)
5724#define BNX2_RXP_PFE_PFE_CTL_PFE_SIZE (0xfL<<4)
5725#define BNX2_RXP_PFE_PFE_CTL_PFE_SIZE_0 (0L<<4)
5726#define BNX2_RXP_PFE_PFE_CTL_PFE_SIZE_1 (1L<<4)
5727#define BNX2_RXP_PFE_PFE_CTL_PFE_SIZE_2 (2L<<4)
5728#define BNX2_RXP_PFE_PFE_CTL_PFE_SIZE_3 (3L<<4)
5729#define BNX2_RXP_PFE_PFE_CTL_PFE_SIZE_4 (4L<<4)
5730#define BNX2_RXP_PFE_PFE_CTL_PFE_SIZE_5 (5L<<4)
5731#define BNX2_RXP_PFE_PFE_CTL_PFE_SIZE_6 (6L<<4)
5732#define BNX2_RXP_PFE_PFE_CTL_PFE_SIZE_7 (7L<<4)
5733#define BNX2_RXP_PFE_PFE_CTL_PFE_SIZE_8 (8L<<4)
5734#define BNX2_RXP_PFE_PFE_CTL_PFE_SIZE_9 (9L<<4)
5735#define BNX2_RXP_PFE_PFE_CTL_PFE_SIZE_10 (10L<<4)
5736#define BNX2_RXP_PFE_PFE_CTL_PFE_SIZE_11 (11L<<4)
5737#define BNX2_RXP_PFE_PFE_CTL_PFE_SIZE_12 (12L<<4)
5738#define BNX2_RXP_PFE_PFE_CTL_PFE_SIZE_13 (13L<<4)
5739#define BNX2_RXP_PFE_PFE_CTL_PFE_SIZE_14 (14L<<4)
5740#define BNX2_RXP_PFE_PFE_CTL_PFE_SIZE_15 (15L<<4)
5741#define BNX2_RXP_PFE_PFE_CTL_PFE_COUNT (0xfL<<12)
5742#define BNX2_RXP_PFE_PFE_CTL_OFFSET (0x1ffL<<16)
5743
5744#define BNX2_RXP_RXPCQ 0x000c5380
3305#define BNX2_RXP_CFTQ_CMD 0x000c53b8 5745#define BNX2_RXP_CFTQ_CMD 0x000c53b8
3306#define BNX2_RXP_CFTQ_CMD_OFFSET (0x3ffL<<0) 5746#define BNX2_RXP_CFTQ_CMD_OFFSET (0x3ffL<<0)
3307#define BNX2_RXP_CFTQ_CMD_WR_TOP (1L<<10) 5747#define BNX2_RXP_CFTQ_CMD_WR_TOP (1L<<10)
@@ -3322,7 +5762,7 @@ struct l2_fhdr {
3322#define BNX2_RXP_CFTQ_CTL_MAX_DEPTH (0x3ffL<<12) 5762#define BNX2_RXP_CFTQ_CTL_MAX_DEPTH (0x3ffL<<12)
3323#define BNX2_RXP_CFTQ_CTL_CUR_DEPTH (0x3ffL<<22) 5763#define BNX2_RXP_CFTQ_CTL_CUR_DEPTH (0x3ffL<<22)
3324 5764
3325#define BNX2_RXP_FTQ_DATA 0x000c53c0 5765#define BNX2_RXP_RXPQ 0x000c53c0
3326#define BNX2_RXP_FTQ_CMD 0x000c53f8 5766#define BNX2_RXP_FTQ_CMD 0x000c53f8
3327#define BNX2_RXP_FTQ_CMD_OFFSET (0x3ffL<<0) 5767#define BNX2_RXP_FTQ_CMD_OFFSET (0x3ffL<<0)
3328#define BNX2_RXP_FTQ_CMD_WR_TOP (1L<<10) 5768#define BNX2_RXP_FTQ_CMD_WR_TOP (1L<<10)
@@ -3350,6 +5790,10 @@ struct l2_fhdr {
3350 * com_reg definition 5790 * com_reg definition
3351 * offset: 0x100000 5791 * offset: 0x100000
3352 */ 5792 */
5793#define BNX2_COM_CKSUM_ERROR_STATUS 0x00100000
5794#define BNX2_COM_CKSUM_ERROR_STATUS_CALCULATED (0xffffL<<0)
5795#define BNX2_COM_CKSUM_ERROR_STATUS_EXPECTED (0xffffL<<16)
5796
3353#define BNX2_COM_CPU_MODE 0x00105000 5797#define BNX2_COM_CPU_MODE 0x00105000
3354#define BNX2_COM_CPU_MODE_LOCAL_RST (1L<<0) 5798#define BNX2_COM_CPU_MODE_LOCAL_RST (1L<<0)
3355#define BNX2_COM_CPU_MODE_STEP_ENA (1L<<1) 5799#define BNX2_COM_CPU_MODE_STEP_ENA (1L<<1)
@@ -3369,7 +5813,7 @@ struct l2_fhdr {
3369#define BNX2_COM_CPU_STATE_PAGE_0_DATA_HALTED (1L<<3) 5813#define BNX2_COM_CPU_STATE_PAGE_0_DATA_HALTED (1L<<3)
3370#define BNX2_COM_CPU_STATE_PAGE_0_INST_HALTED (1L<<4) 5814#define BNX2_COM_CPU_STATE_PAGE_0_INST_HALTED (1L<<4)
3371#define BNX2_COM_CPU_STATE_BAD_DATA_ADDR_HALTED (1L<<5) 5815#define BNX2_COM_CPU_STATE_BAD_DATA_ADDR_HALTED (1L<<5)
3372#define BNX2_COM_CPU_STATE_BAD_pc_HALTED (1L<<6) 5816#define BNX2_COM_CPU_STATE_BAD_PC_HALTED (1L<<6)
3373#define BNX2_COM_CPU_STATE_ALIGN_HALTED (1L<<7) 5817#define BNX2_COM_CPU_STATE_ALIGN_HALTED (1L<<7)
3374#define BNX2_COM_CPU_STATE_FIO_ABORT_HALTED (1L<<8) 5818#define BNX2_COM_CPU_STATE_FIO_ABORT_HALTED (1L<<8)
3375#define BNX2_COM_CPU_STATE_SOFT_HALTED (1L<<10) 5819#define BNX2_COM_CPU_STATE_SOFT_HALTED (1L<<10)
@@ -3417,7 +5861,29 @@ struct l2_fhdr {
3417#define BNX2_COM_CPU_LAST_BRANCH_ADDR_LBA (0x3fffffffL<<2) 5861#define BNX2_COM_CPU_LAST_BRANCH_ADDR_LBA (0x3fffffffL<<2)
3418 5862
3419#define BNX2_COM_CPU_REG_FILE 0x00105200 5863#define BNX2_COM_CPU_REG_FILE 0x00105200
3420#define BNX2_COM_COMXQ_FTQ_DATA 0x00105340 5864#define BNX2_COM_COMTQ_PFE_PFE_CTL 0x001052bc
5865#define BNX2_COM_COMTQ_PFE_PFE_CTL_INC_USAGE_CNT (1L<<0)
5866#define BNX2_COM_COMTQ_PFE_PFE_CTL_PFE_SIZE (0xfL<<4)
5867#define BNX2_COM_COMTQ_PFE_PFE_CTL_PFE_SIZE_0 (0L<<4)
5868#define BNX2_COM_COMTQ_PFE_PFE_CTL_PFE_SIZE_1 (1L<<4)
5869#define BNX2_COM_COMTQ_PFE_PFE_CTL_PFE_SIZE_2 (2L<<4)
5870#define BNX2_COM_COMTQ_PFE_PFE_CTL_PFE_SIZE_3 (3L<<4)
5871#define BNX2_COM_COMTQ_PFE_PFE_CTL_PFE_SIZE_4 (4L<<4)
5872#define BNX2_COM_COMTQ_PFE_PFE_CTL_PFE_SIZE_5 (5L<<4)
5873#define BNX2_COM_COMTQ_PFE_PFE_CTL_PFE_SIZE_6 (6L<<4)
5874#define BNX2_COM_COMTQ_PFE_PFE_CTL_PFE_SIZE_7 (7L<<4)
5875#define BNX2_COM_COMTQ_PFE_PFE_CTL_PFE_SIZE_8 (8L<<4)
5876#define BNX2_COM_COMTQ_PFE_PFE_CTL_PFE_SIZE_9 (9L<<4)
5877#define BNX2_COM_COMTQ_PFE_PFE_CTL_PFE_SIZE_10 (10L<<4)
5878#define BNX2_COM_COMTQ_PFE_PFE_CTL_PFE_SIZE_11 (11L<<4)
5879#define BNX2_COM_COMTQ_PFE_PFE_CTL_PFE_SIZE_12 (12L<<4)
5880#define BNX2_COM_COMTQ_PFE_PFE_CTL_PFE_SIZE_13 (13L<<4)
5881#define BNX2_COM_COMTQ_PFE_PFE_CTL_PFE_SIZE_14 (14L<<4)
5882#define BNX2_COM_COMTQ_PFE_PFE_CTL_PFE_SIZE_15 (15L<<4)
5883#define BNX2_COM_COMTQ_PFE_PFE_CTL_PFE_COUNT (0xfL<<12)
5884#define BNX2_COM_COMTQ_PFE_PFE_CTL_OFFSET (0x1ffL<<16)
5885
5886#define BNX2_COM_COMXQ 0x00105340
3421#define BNX2_COM_COMXQ_FTQ_CMD 0x00105378 5887#define BNX2_COM_COMXQ_FTQ_CMD 0x00105378
3422#define BNX2_COM_COMXQ_FTQ_CMD_OFFSET (0x3ffL<<0) 5888#define BNX2_COM_COMXQ_FTQ_CMD_OFFSET (0x3ffL<<0)
3423#define BNX2_COM_COMXQ_FTQ_CMD_WR_TOP (1L<<10) 5889#define BNX2_COM_COMXQ_FTQ_CMD_WR_TOP (1L<<10)
@@ -3438,7 +5904,7 @@ struct l2_fhdr {
3438#define BNX2_COM_COMXQ_FTQ_CTL_MAX_DEPTH (0x3ffL<<12) 5904#define BNX2_COM_COMXQ_FTQ_CTL_MAX_DEPTH (0x3ffL<<12)
3439#define BNX2_COM_COMXQ_FTQ_CTL_CUR_DEPTH (0x3ffL<<22) 5905#define BNX2_COM_COMXQ_FTQ_CTL_CUR_DEPTH (0x3ffL<<22)
3440 5906
3441#define BNX2_COM_COMTQ_FTQ_DATA 0x00105380 5907#define BNX2_COM_COMTQ 0x00105380
3442#define BNX2_COM_COMTQ_FTQ_CMD 0x001053b8 5908#define BNX2_COM_COMTQ_FTQ_CMD 0x001053b8
3443#define BNX2_COM_COMTQ_FTQ_CMD_OFFSET (0x3ffL<<0) 5909#define BNX2_COM_COMTQ_FTQ_CMD_OFFSET (0x3ffL<<0)
3444#define BNX2_COM_COMTQ_FTQ_CMD_WR_TOP (1L<<10) 5910#define BNX2_COM_COMTQ_FTQ_CMD_WR_TOP (1L<<10)
@@ -3459,7 +5925,7 @@ struct l2_fhdr {
3459#define BNX2_COM_COMTQ_FTQ_CTL_MAX_DEPTH (0x3ffL<<12) 5925#define BNX2_COM_COMTQ_FTQ_CTL_MAX_DEPTH (0x3ffL<<12)
3460#define BNX2_COM_COMTQ_FTQ_CTL_CUR_DEPTH (0x3ffL<<22) 5926#define BNX2_COM_COMTQ_FTQ_CTL_CUR_DEPTH (0x3ffL<<22)
3461 5927
3462#define BNX2_COM_COMQ_FTQ_DATA 0x001053c0 5928#define BNX2_COM_COMQ 0x001053c0
3463#define BNX2_COM_COMQ_FTQ_CMD 0x001053f8 5929#define BNX2_COM_COMQ_FTQ_CMD 0x001053f8
3464#define BNX2_COM_COMQ_FTQ_CMD_OFFSET (0x3ffL<<0) 5930#define BNX2_COM_COMQ_FTQ_CMD_OFFSET (0x3ffL<<0)
3465#define BNX2_COM_COMQ_FTQ_CMD_WR_TOP (1L<<10) 5931#define BNX2_COM_COMQ_FTQ_CMD_WR_TOP (1L<<10)
@@ -3489,6 +5955,10 @@ struct l2_fhdr {
3489 * cp_reg definition 5955 * cp_reg definition
3490 * offset: 0x180000 5956 * offset: 0x180000
3491 */ 5957 */
5958#define BNX2_CP_CKSUM_ERROR_STATUS 0x00180000
5959#define BNX2_CP_CKSUM_ERROR_STATUS_CALCULATED (0xffffL<<0)
5960#define BNX2_CP_CKSUM_ERROR_STATUS_EXPECTED (0xffffL<<16)
5961
3492#define BNX2_CP_CPU_MODE 0x00185000 5962#define BNX2_CP_CPU_MODE 0x00185000
3493#define BNX2_CP_CPU_MODE_LOCAL_RST (1L<<0) 5963#define BNX2_CP_CPU_MODE_LOCAL_RST (1L<<0)
3494#define BNX2_CP_CPU_MODE_STEP_ENA (1L<<1) 5964#define BNX2_CP_CPU_MODE_STEP_ENA (1L<<1)
@@ -3508,7 +5978,7 @@ struct l2_fhdr {
3508#define BNX2_CP_CPU_STATE_PAGE_0_DATA_HALTED (1L<<3) 5978#define BNX2_CP_CPU_STATE_PAGE_0_DATA_HALTED (1L<<3)
3509#define BNX2_CP_CPU_STATE_PAGE_0_INST_HALTED (1L<<4) 5979#define BNX2_CP_CPU_STATE_PAGE_0_INST_HALTED (1L<<4)
3510#define BNX2_CP_CPU_STATE_BAD_DATA_ADDR_HALTED (1L<<5) 5980#define BNX2_CP_CPU_STATE_BAD_DATA_ADDR_HALTED (1L<<5)
3511#define BNX2_CP_CPU_STATE_BAD_pc_HALTED (1L<<6) 5981#define BNX2_CP_CPU_STATE_BAD_PC_HALTED (1L<<6)
3512#define BNX2_CP_CPU_STATE_ALIGN_HALTED (1L<<7) 5982#define BNX2_CP_CPU_STATE_ALIGN_HALTED (1L<<7)
3513#define BNX2_CP_CPU_STATE_FIO_ABORT_HALTED (1L<<8) 5983#define BNX2_CP_CPU_STATE_FIO_ABORT_HALTED (1L<<8)
3514#define BNX2_CP_CPU_STATE_SOFT_HALTED (1L<<10) 5984#define BNX2_CP_CPU_STATE_SOFT_HALTED (1L<<10)
@@ -3556,7 +6026,29 @@ struct l2_fhdr {
3556#define BNX2_CP_CPU_LAST_BRANCH_ADDR_LBA (0x3fffffffL<<2) 6026#define BNX2_CP_CPU_LAST_BRANCH_ADDR_LBA (0x3fffffffL<<2)
3557 6027
3558#define BNX2_CP_CPU_REG_FILE 0x00185200 6028#define BNX2_CP_CPU_REG_FILE 0x00185200
3559#define BNX2_CP_CPQ_FTQ_DATA 0x001853c0 6029#define BNX2_CP_CPQ_PFE_PFE_CTL 0x001853bc
6030#define BNX2_CP_CPQ_PFE_PFE_CTL_INC_USAGE_CNT (1L<<0)
6031#define BNX2_CP_CPQ_PFE_PFE_CTL_PFE_SIZE (0xfL<<4)
6032#define BNX2_CP_CPQ_PFE_PFE_CTL_PFE_SIZE_0 (0L<<4)
6033#define BNX2_CP_CPQ_PFE_PFE_CTL_PFE_SIZE_1 (1L<<4)
6034#define BNX2_CP_CPQ_PFE_PFE_CTL_PFE_SIZE_2 (2L<<4)
6035#define BNX2_CP_CPQ_PFE_PFE_CTL_PFE_SIZE_3 (3L<<4)
6036#define BNX2_CP_CPQ_PFE_PFE_CTL_PFE_SIZE_4 (4L<<4)
6037#define BNX2_CP_CPQ_PFE_PFE_CTL_PFE_SIZE_5 (5L<<4)
6038#define BNX2_CP_CPQ_PFE_PFE_CTL_PFE_SIZE_6 (6L<<4)
6039#define BNX2_CP_CPQ_PFE_PFE_CTL_PFE_SIZE_7 (7L<<4)
6040#define BNX2_CP_CPQ_PFE_PFE_CTL_PFE_SIZE_8 (8L<<4)
6041#define BNX2_CP_CPQ_PFE_PFE_CTL_PFE_SIZE_9 (9L<<4)
6042#define BNX2_CP_CPQ_PFE_PFE_CTL_PFE_SIZE_10 (10L<<4)
6043#define BNX2_CP_CPQ_PFE_PFE_CTL_PFE_SIZE_11 (11L<<4)
6044#define BNX2_CP_CPQ_PFE_PFE_CTL_PFE_SIZE_12 (12L<<4)
6045#define BNX2_CP_CPQ_PFE_PFE_CTL_PFE_SIZE_13 (13L<<4)
6046#define BNX2_CP_CPQ_PFE_PFE_CTL_PFE_SIZE_14 (14L<<4)
6047#define BNX2_CP_CPQ_PFE_PFE_CTL_PFE_SIZE_15 (15L<<4)
6048#define BNX2_CP_CPQ_PFE_PFE_CTL_PFE_COUNT (0xfL<<12)
6049#define BNX2_CP_CPQ_PFE_PFE_CTL_OFFSET (0x1ffL<<16)
6050
6051#define BNX2_CP_CPQ 0x001853c0
3560#define BNX2_CP_CPQ_FTQ_CMD 0x001853f8 6052#define BNX2_CP_CPQ_FTQ_CMD 0x001853f8
3561#define BNX2_CP_CPQ_FTQ_CMD_OFFSET (0x3ffL<<0) 6053#define BNX2_CP_CPQ_FTQ_CMD_OFFSET (0x3ffL<<0)
3562#define BNX2_CP_CPQ_FTQ_CMD_WR_TOP (1L<<10) 6054#define BNX2_CP_CPQ_FTQ_CMD_WR_TOP (1L<<10)
@@ -3584,6 +6076,59 @@ struct l2_fhdr {
3584 * mcp_reg definition 6076 * mcp_reg definition
3585 * offset: 0x140000 6077 * offset: 0x140000
3586 */ 6078 */
6079#define BNX2_MCP_MCP_CONTROL 0x00140080
6080#define BNX2_MCP_MCP_CONTROL_SMBUS_SEL (1L<<30)
6081#define BNX2_MCP_MCP_CONTROL_MCP_ISOLATE (1L<<31)
6082
6083#define BNX2_MCP_MCP_ATTENTION_STATUS 0x00140084
6084#define BNX2_MCP_MCP_ATTENTION_STATUS_DRV_DOORBELL (1L<<29)
6085#define BNX2_MCP_MCP_ATTENTION_STATUS_WATCHDOG_TIMEOUT (1L<<30)
6086#define BNX2_MCP_MCP_ATTENTION_STATUS_CPU_EVENT (1L<<31)
6087
6088#define BNX2_MCP_MCP_HEARTBEAT_CONTROL 0x00140088
6089#define BNX2_MCP_MCP_HEARTBEAT_CONTROL_MCP_HEARTBEAT_ENABLE (1L<<31)
6090
6091#define BNX2_MCP_MCP_HEARTBEAT_STATUS 0x0014008c
6092#define BNX2_MCP_MCP_HEARTBEAT_STATUS_MCP_HEARTBEAT_PERIOD (0x7ffL<<0)
6093#define BNX2_MCP_MCP_HEARTBEAT_STATUS_VALID (1L<<31)
6094
6095#define BNX2_MCP_MCP_HEARTBEAT 0x00140090
6096#define BNX2_MCP_MCP_HEARTBEAT_MCP_HEARTBEAT_COUNT (0x3fffffffL<<0)
6097#define BNX2_MCP_MCP_HEARTBEAT_MCP_HEARTBEAT_INC (1L<<30)
6098#define BNX2_MCP_MCP_HEARTBEAT_MCP_HEARTBEAT_RESET (1L<<31)
6099
6100#define BNX2_MCP_WATCHDOG_RESET 0x00140094
6101#define BNX2_MCP_WATCHDOG_RESET_WATCHDOG_RESET (1L<<31)
6102
6103#define BNX2_MCP_WATCHDOG_CONTROL 0x00140098
6104#define BNX2_MCP_WATCHDOG_CONTROL_WATCHDOG_TIMEOUT (0xfffffffL<<0)
6105#define BNX2_MCP_WATCHDOG_CONTROL_WATCHDOG_ATTN (1L<<29)
6106#define BNX2_MCP_WATCHDOG_CONTROL_MCP_RST_ENABLE (1L<<30)
6107#define BNX2_MCP_WATCHDOG_CONTROL_WATCHDOG_ENABLE (1L<<31)
6108
6109#define BNX2_MCP_ACCESS_LOCK 0x0014009c
6110#define BNX2_MCP_ACCESS_LOCK_LOCK (1L<<31)
6111
6112#define BNX2_MCP_TOE_ID 0x001400a0
6113#define BNX2_MCP_TOE_ID_FUNCTION_ID (1L<<31)
6114
6115#define BNX2_MCP_MAILBOX_CFG 0x001400a4
6116#define BNX2_MCP_MAILBOX_CFG_MAILBOX_OFFSET (0x3fffL<<0)
6117#define BNX2_MCP_MAILBOX_CFG_MAILBOX_SIZE (0xfffL<<20)
6118
6119#define BNX2_MCP_MAILBOX_CFG_OTHER_FUNC 0x001400a8
6120#define BNX2_MCP_MAILBOX_CFG_OTHER_FUNC_MAILBOX_OFFSET (0x3fffL<<0)
6121#define BNX2_MCP_MAILBOX_CFG_OTHER_FUNC_MAILBOX_SIZE (0xfffL<<20)
6122
6123#define BNX2_MCP_MCP_DOORBELL 0x001400ac
6124#define BNX2_MCP_MCP_DOORBELL_MCP_DOORBELL (1L<<31)
6125
6126#define BNX2_MCP_DRIVER_DOORBELL 0x001400b0
6127#define BNX2_MCP_DRIVER_DOORBELL_DRIVER_DOORBELL (1L<<31)
6128
6129#define BNX2_MCP_DRIVER_DOORBELL_OTHER_FUNC 0x001400b4
6130#define BNX2_MCP_DRIVER_DOORBELL_OTHER_FUNC_DRIVER_DOORBELL (1L<<31)
6131
3587#define BNX2_MCP_CPU_MODE 0x00145000 6132#define BNX2_MCP_CPU_MODE 0x00145000
3588#define BNX2_MCP_CPU_MODE_LOCAL_RST (1L<<0) 6133#define BNX2_MCP_CPU_MODE_LOCAL_RST (1L<<0)
3589#define BNX2_MCP_CPU_MODE_STEP_ENA (1L<<1) 6134#define BNX2_MCP_CPU_MODE_STEP_ENA (1L<<1)
@@ -3603,7 +6148,7 @@ struct l2_fhdr {
3603#define BNX2_MCP_CPU_STATE_PAGE_0_DATA_HALTED (1L<<3) 6148#define BNX2_MCP_CPU_STATE_PAGE_0_DATA_HALTED (1L<<3)
3604#define BNX2_MCP_CPU_STATE_PAGE_0_INST_HALTED (1L<<4) 6149#define BNX2_MCP_CPU_STATE_PAGE_0_INST_HALTED (1L<<4)
3605#define BNX2_MCP_CPU_STATE_BAD_DATA_ADDR_HALTED (1L<<5) 6150#define BNX2_MCP_CPU_STATE_BAD_DATA_ADDR_HALTED (1L<<5)
3606#define BNX2_MCP_CPU_STATE_BAD_pc_HALTED (1L<<6) 6151#define BNX2_MCP_CPU_STATE_BAD_PC_HALTED (1L<<6)
3607#define BNX2_MCP_CPU_STATE_ALIGN_HALTED (1L<<7) 6152#define BNX2_MCP_CPU_STATE_ALIGN_HALTED (1L<<7)
3608#define BNX2_MCP_CPU_STATE_FIO_ABORT_HALTED (1L<<8) 6153#define BNX2_MCP_CPU_STATE_FIO_ABORT_HALTED (1L<<8)
3609#define BNX2_MCP_CPU_STATE_SOFT_HALTED (1L<<10) 6154#define BNX2_MCP_CPU_STATE_SOFT_HALTED (1L<<10)
@@ -3651,7 +6196,7 @@ struct l2_fhdr {
3651#define BNX2_MCP_CPU_LAST_BRANCH_ADDR_LBA (0x3fffffffL<<2) 6196#define BNX2_MCP_CPU_LAST_BRANCH_ADDR_LBA (0x3fffffffL<<2)
3652 6197
3653#define BNX2_MCP_CPU_REG_FILE 0x00145200 6198#define BNX2_MCP_CPU_REG_FILE 0x00145200
3654#define BNX2_MCP_MCPQ_FTQ_DATA 0x001453c0 6199#define BNX2_MCP_MCPQ 0x001453c0
3655#define BNX2_MCP_MCPQ_FTQ_CMD 0x001453f8 6200#define BNX2_MCP_MCPQ_FTQ_CMD 0x001453f8
3656#define BNX2_MCP_MCPQ_FTQ_CMD_OFFSET (0x3ffL<<0) 6201#define BNX2_MCP_MCPQ_FTQ_CMD_OFFSET (0x3ffL<<0)
3657#define BNX2_MCP_MCPQ_FTQ_CMD_WR_TOP (1L<<10) 6202#define BNX2_MCP_MCPQ_FTQ_CMD_WR_TOP (1L<<10)
@@ -3696,6 +6241,8 @@ struct l2_fhdr {
3696 6241
3697/* 5708 Serdes PHY registers */ 6242/* 5708 Serdes PHY registers */
3698 6243
6244#define BCM5708S_BMCR_FORCE_2500 0x20
6245
3699#define BCM5708S_UP1 0xb 6246#define BCM5708S_UP1 0xb
3700 6247
3701#define BCM5708S_UP1_2G5 0x1 6248#define BCM5708S_UP1_2G5 0x1
@@ -3804,6 +6351,7 @@ struct l2_fhdr {
3804#define INVALID_CID_ADDR 0xffffffff 6351#define INVALID_CID_ADDR 0xffffffff
3805 6352
3806#define TX_CID 16 6353#define TX_CID 16
6354#define TX_TSS_CID 32
3807#define RX_CID 0 6355#define RX_CID 0
3808 6356
3809#define MB_TX_CID_ADDR MB_GET_CID_ADDR(TX_CID) 6357#define MB_TX_CID_ADDR MB_GET_CID_ADDR(TX_CID)
@@ -3889,6 +6437,8 @@ struct bnx2 {
3889 6437
3890 u32 tx_prod_bseq __attribute__((aligned(L1_CACHE_BYTES))); 6438 u32 tx_prod_bseq __attribute__((aligned(L1_CACHE_BYTES)));
3891 u16 tx_prod; 6439 u16 tx_prod;
6440 u32 tx_bidx_addr;
6441 u32 tx_bseq_addr;
3892 6442
3893 u16 tx_cons __attribute__((aligned(L1_CACHE_BYTES))); 6443 u16 tx_cons __attribute__((aligned(L1_CACHE_BYTES)));
3894 u16 hw_tx_cons; 6444 u16 hw_tx_cons;
@@ -3945,6 +6495,7 @@ struct bnx2 {
3945#define CHIP_NUM(bp) (((bp)->chip_id) & 0xffff0000) 6495#define CHIP_NUM(bp) (((bp)->chip_id) & 0xffff0000)
3946#define CHIP_NUM_5706 0x57060000 6496#define CHIP_NUM_5706 0x57060000
3947#define CHIP_NUM_5708 0x57080000 6497#define CHIP_NUM_5708 0x57080000
6498#define CHIP_NUM_5709 0x57090000
3948 6499
3949#define CHIP_REV(bp) (((bp)->chip_id) & 0x0000f000) 6500#define CHIP_REV(bp) (((bp)->chip_id) & 0x0000f000)
3950#define CHIP_REV_Ax 0x00000000 6501#define CHIP_REV_Ax 0x00000000
@@ -4007,6 +6558,10 @@ struct bnx2 {
4007 struct statistics_block *stats_blk; 6558 struct statistics_block *stats_blk;
4008 dma_addr_t stats_blk_mapping; 6559 dma_addr_t stats_blk_mapping;
4009 6560
6561 int ctx_pages;
6562 void *ctx_blk[4];
6563 dma_addr_t ctx_blk_mapping[4];
6564
4010 u32 hc_cmd; 6565 u32 hc_cmd;
4011 u32 rx_mode; 6566 u32 rx_mode;
4012 6567
@@ -4038,6 +6593,7 @@ struct bnx2 {
4038 6593
4039 u8 serdes_an_pending; 6594 u8 serdes_an_pending;
4040#define SERDES_AN_TIMEOUT (HZ / 3) 6595#define SERDES_AN_TIMEOUT (HZ / 3)
6596#define SERDES_FORCED_TIMEOUT (HZ / 10)
4041 6597
4042 u8 mac_addr[8]; 6598 u8 mac_addr[8];
4043 6599
@@ -4104,41 +6660,43 @@ struct cpu_reg {
4104}; 6660};
4105 6661
4106struct fw_info { 6662struct fw_info {
4107 u32 ver_major; 6663 const u32 ver_major;
4108 u32 ver_minor; 6664 const u32 ver_minor;
4109 u32 ver_fix; 6665 const u32 ver_fix;
4110 6666
4111 u32 start_addr; 6667 const u32 start_addr;
4112 6668
4113 /* Text section. */ 6669 /* Text section. */
4114 u32 text_addr; 6670 const u32 text_addr;
4115 u32 text_len; 6671 const u32 text_len;
4116 u32 text_index; 6672 const u32 text_index;
4117 u32 *text; 6673 u32 *text;
6674 u8 *gz_text;
6675 const u32 gz_text_len;
4118 6676
4119 /* Data section. */ 6677 /* Data section. */
4120 u32 data_addr; 6678 const u32 data_addr;
4121 u32 data_len; 6679 const u32 data_len;
4122 u32 data_index; 6680 const u32 data_index;
4123 u32 *data; 6681 const u32 *data;
4124 6682
4125 /* SBSS section. */ 6683 /* SBSS section. */
4126 u32 sbss_addr; 6684 const u32 sbss_addr;
4127 u32 sbss_len; 6685 const u32 sbss_len;
4128 u32 sbss_index; 6686 const u32 sbss_index;
4129 u32 *sbss; 6687 const u32 *sbss;
4130 6688
4131 /* BSS section. */ 6689 /* BSS section. */
4132 u32 bss_addr; 6690 const u32 bss_addr;
4133 u32 bss_len; 6691 const u32 bss_len;
4134 u32 bss_index; 6692 const u32 bss_index;
4135 u32 *bss; 6693 const u32 *bss;
4136 6694
4137 /* Read-only section. */ 6695 /* Read-only section. */
4138 u32 rodata_addr; 6696 const u32 rodata_addr;
4139 u32 rodata_len; 6697 const u32 rodata_len;
4140 u32 rodata_index; 6698 const u32 rodata_index;
4141 u32 *rodata; 6699 const u32 *rodata;
4142}; 6700};
4143 6701
4144#define RV2P_PROC1 0 6702#define RV2P_PROC1 0
diff --git a/drivers/net/bnx2_fw.h b/drivers/net/bnx2_fw.h
index 2d753dca0d75..21d368ff424d 100644
--- a/drivers/net/bnx2_fw.h
+++ b/drivers/net/bnx2_fw.h
@@ -14,20 +14,6 @@
14 * accompanying it. 14 * accompanying it.
15 */ 15 */
16 16
17static const int bnx2_COM_b06FwReleaseMajor = 0x1;
18static const int bnx2_COM_b06FwReleaseMinor = 0x0;
19static const int bnx2_COM_b06FwReleaseFix = 0x0;
20static const u32 bnx2_COM_b06FwStartAddr = 0x080008b4;
21static const u32 bnx2_COM_b06FwTextAddr = 0x08000000;
22static const int bnx2_COM_b06FwTextLen = 0x57bc;
23static const u32 bnx2_COM_b06FwDataAddr = 0x08005840;
24static const int bnx2_COM_b06FwDataLen = 0x0;
25static const u32 bnx2_COM_b06FwRodataAddr = 0x080057c0;
26static const int bnx2_COM_b06FwRodataLen = 0x58;
27static const u32 bnx2_COM_b06FwBssAddr = 0x08005860;
28static const int bnx2_COM_b06FwBssLen = 0x88;
29static const u32 bnx2_COM_b06FwSbssAddr = 0x08005840;
30static const int bnx2_COM_b06FwSbssLen = 0x1c;
31static u8 bnx2_COM_b06FwText[] = { 17static u8 bnx2_COM_b06FwText[] = {
32 0x1f, 0x8b, 0x08, 0x08, 0x09, 0x83, 0x41, 0x44, 0x00, 0x03, 0x74, 0x65, 18 0x1f, 0x8b, 0x08, 0x08, 0x09, 0x83, 0x41, 0x44, 0x00, 0x03, 0x74, 0x65,
33 0x73, 0x74, 0x31, 0x2e, 0x62, 0x69, 0x6e, 0x00, 0xec, 0x5b, 0x7d, 0x6c, 19 0x73, 0x74, 0x31, 0x2e, 0x62, 0x69, 0x6e, 0x00, 0xec, 0x5b, 0x7d, 0x6c,
@@ -673,389 +659,752 @@ static u32 bnx2_COM_b06FwRodata[(0x58/4) + 1] = {
673static u32 bnx2_COM_b06FwBss[(0x88/4) + 1] = { 0x0 }; 659static u32 bnx2_COM_b06FwBss[(0x88/4) + 1] = { 0x0 };
674static u32 bnx2_COM_b06FwSbss[(0x1c/4) + 1] = { 0x0 }; 660static u32 bnx2_COM_b06FwSbss[(0x1c/4) + 1] = { 0x0 };
675 661
676static int bnx2_RXP_b06FwReleaseMajor = 0x1; 662static struct fw_info bnx2_com_fw_06 = {
677static int bnx2_RXP_b06FwReleaseMinor = 0x0; 663 .ver_major = 0x1,
678static int bnx2_RXP_b06FwReleaseFix = 0x0; 664 .ver_minor = 0x0,
679static u32 bnx2_RXP_b06FwStartAddr = 0x08003184; 665 .ver_fix = 0x0,
680static u32 bnx2_RXP_b06FwTextAddr = 0x08000000; 666
681static int bnx2_RXP_b06FwTextLen = 0x588c; 667 .start_addr = 0x080008b4,
682static u32 bnx2_RXP_b06FwDataAddr = 0x080058e0; 668
683static int bnx2_RXP_b06FwDataLen = 0x0; 669 .text_addr = 0x08000000,
684static u32 bnx2_RXP_b06FwRodataAddr = 0x08005890; 670 .text_len = 0x57bc,
685static int bnx2_RXP_b06FwRodataLen = 0x28; 671 .text_index = 0x0,
686static u32 bnx2_RXP_b06FwBssAddr = 0x08005900; 672 .gz_text = bnx2_COM_b06FwText,
687static int bnx2_RXP_b06FwBssLen = 0x13a4; 673 .gz_text_len = sizeof(bnx2_COM_b06FwText),
688static u32 bnx2_RXP_b06FwSbssAddr = 0x080058e0; 674
689static int bnx2_RXP_b06FwSbssLen = 0x1c; 675 .data_addr = 0x08005840,
676 .data_len = 0x0,
677 .data_index = 0x0,
678 .data = bnx2_COM_b06FwData,
679
680 .sbss_addr = 0x08005840,
681 .sbss_len = 0x1c,
682 .sbss_index = 0x0,
683 .sbss = bnx2_COM_b06FwSbss,
684
685 .bss_addr = 0x08005860,
686 .bss_len = 0x88,
687 .bss_index = 0x0,
688 .bss = bnx2_COM_b06FwBss,
689
690 .rodata_addr = 0x080057c0,
691 .rodata_len = 0x58,
692 .rodata_index = 0x0,
693 .rodata = bnx2_COM_b06FwRodata,
694};
695
690static u8 bnx2_RXP_b06FwText[] = { 696static u8 bnx2_RXP_b06FwText[] = {
691 0x1f, 0x8b, 0x08, 0x08, 0x07, 0x87, 0x41, 0x44, 0x00, 0x03, 0x74, 0x65, 697 0x1f, 0x8b, 0x08, 0x08, 0xcb, 0xa3, 0x46, 0x45, 0x00, 0x03, 0x74, 0x65,
692 0x73, 0x74, 0x31, 0x2e, 0x62, 0x69, 0x6e, 0x00, 0xed, 0x5c, 0x5d, 0x6c, 698 0x73, 0x74, 0x31, 0x2e, 0x62, 0x69, 0x6e, 0x00, 0xec, 0x5c, 0x6f, 0x6c,
693 0x1c, 0xd7, 0x75, 0x3e, 0xf3, 0x43, 0x71, 0x49, 0x91, 0xd4, 0x70, 0xb9, 699 0x1c, 0xc7, 0x75, 0x7f, 0x3b, 0xbb, 0xa4, 0x4e, 0xd4, 0x91, 0x5c, 0x1e,
694 0x62, 0x57, 0x12, 0x65, 0xed, 0x8a, 0x43, 0x71, 0x6d, 0x31, 0xce, 0x50, 700 0x4f, 0xf4, 0x49, 0x66, 0x94, 0x5d, 0x71, 0x25, 0x5e, 0x2d, 0xc6, 0x5d,
695 0x58, 0xdb, 0x82, 0xb1, 0x48, 0xc7, 0xb3, 0xa4, 0xc8, 0x24, 0x02, 0x42, 701 0x31, 0x57, 0x9b, 0x08, 0xce, 0xf1, 0x79, 0xef, 0x64, 0xb1, 0x86, 0x0a,
696 0x1b, 0x42, 0xab, 0xa4, 0xa9, 0xc1, 0x90, 0x72, 0x91, 0x22, 0x2c, 0xa0, 702 0x51, 0x0d, 0x1d, 0x1b, 0x85, 0x6b, 0xb0, 0x47, 0x39, 0xae, 0xdb, 0x7e,
697 0x1a, 0x79, 0xf0, 0x43, 0x10, 0x2f, 0x56, 0x3f, 0xa6, 0xd1, 0x8d, 0x96, 703 0x90, 0x65, 0x1b, 0x30, 0xda, 0x10, 0xbe, 0x1c, 0xe9, 0x46, 0x75, 0x2f,
698 0xb6, 0x1c, 0x53, 0x08, 0x82, 0x82, 0xe5, 0x52, 0x52, 0x0b, 0x2c, 0xb4, 704 0xdc, 0x8b, 0xc4, 0x98, 0x06, 0xfa, 0x07, 0x57, 0x92, 0xfa, 0x83, 0xe0,
699 0x96, 0xed, 0x36, 0x7e, 0xa8, 0x23, 0x9a, 0x92, 0x8d, 0xa6, 0x68, 0x81, 705 0xa0, 0x93, 0xe2, 0x26, 0xf5, 0x17, 0x57, 0x84, 0x2a, 0xc7, 0xf9, 0xe0,
700 0x22, 0xad, 0xd1, 0xf4, 0x4d, 0x95, 0x9a, 0x4a, 0x75, 0x5f, 0xd4, 0xa2, 706 0x02, 0x4e, 0x63, 0x20, 0x06, 0xea, 0x16, 0xaa, 0xec, 0xd8, 0x46, 0x81,
701 0x48, 0xda, 0x46, 0xcd, 0xf4, 0xfb, 0xee, 0xcc, 0x88, 0xd4, 0x9a, 0xb2, 707 0xa2, 0x42, 0x1c, 0xd8, 0x46, 0xfc, 0x67, 0xfb, 0x7b, 0x33, 0xbb, 0xd4,
702 0x2c, 0x3b, 0x0d, 0x62, 0x74, 0x0e, 0x30, 0xd8, 0xb9, 0x7f, 0xe7, 0xef, 708 0x91, 0x96, 0x6d, 0xa0, 0x1f, 0xfa, 0xa5, 0x3b, 0xc0, 0x61, 0x67, 0x66,
703 0x9e, 0x73, 0xee, 0x39, 0x77, 0x28, 0x7d, 0xa5, 0x43, 0xda, 0x25, 0x84, 709 0xe7, 0xbd, 0x79, 0xf3, 0xfe, 0xbf, 0x59, 0x4a, 0x7f, 0x90, 0xa4, 0x2e,
704 0x4e, 0x3c, 0x99, 0xc3, 0xcf, 0x3c, 0xfd, 0xe0, 0xc3, 0x0f, 0xee, 0xc1, 710 0x0a, 0x5b, 0x37, 0x7e, 0xd6, 0x91, 0xc7, 0x8f, 0xde, 0x3c, 0x76, 0xf3,
705 0xeb, 0xb0, 0xa1, 0x6d, 0xd0, 0xa3, 0xfe, 0x18, 0x62, 0x88, 0x21, 0x86, 711 0x28, 0xd1, 0x97, 0x47, 0xf5, 0x1b, 0x12, 0x22, 0x9a, 0x8f, 0x5b, 0xdc,
706 0x18, 0x62, 0x88, 0x21, 0x86, 0x18, 0x62, 0x88, 0x21, 0x86, 0x18, 0x62, 712 0xe2, 0x16, 0xb7, 0xb8, 0xc5, 0x2d, 0x6e, 0x71, 0x8b, 0x5b, 0xdc, 0xe2,
707 0x88, 0x21, 0x86, 0x18, 0x62, 0x88, 0x21, 0x86, 0x18, 0x62, 0x88, 0x21, 713 0x16, 0xb7, 0xb8, 0xc5, 0x2d, 0x6e, 0x71, 0x8b, 0x5b, 0xdc, 0xe2, 0x16,
708 0x86, 0x18, 0x62, 0x88, 0x21, 0x86, 0x18, 0x62, 0x88, 0x21, 0x86, 0x18, 714 0xb7, 0xb8, 0xc5, 0x2d, 0x6e, 0x71, 0x8b, 0x5b, 0xdc, 0xe2, 0x16, 0xb7,
709 0x62, 0x88, 0x21, 0x86, 0x18, 0x62, 0x88, 0x21, 0x86, 0x18, 0x62, 0x88, 715 0xb8, 0xc5, 0x2d, 0x6e, 0x71, 0x8b, 0x5b, 0xdc, 0xe2, 0x16, 0xb7, 0xb8,
710 0x21, 0x86, 0x18, 0x62, 0x88, 0x21, 0x86, 0xff, 0xef, 0x60, 0x88, 0x58, 716 0xc5, 0x2d, 0x6e, 0x71, 0x8b, 0x5b, 0xdc, 0xe2, 0x16, 0xb7, 0xb8, 0xc5,
711 0xfc, 0xed, 0x0c, 0x1f, 0x49, 0xe8, 0x85, 0xcb, 0x07, 0x3d, 0x5b, 0x12, 717 0x2d, 0x6e, 0x71, 0xfb, 0xff, 0xde, 0x74, 0x22, 0x93, 0x9f, 0xdd, 0xe1,
712 0x46, 0x61, 0x69, 0x66, 0xda, 0x16, 0x71, 0xeb, 0xbb, 0x33, 0x45, 0xf9, 718 0x8f, 0x12, 0x22, 0xbf, 0xfa, 0x90, 0xe7, 0x50, 0x42, 0xcf, 0xbf, 0x34,
713 0x1f, 0xbf, 0x94, 0x32, 0x85, 0xfd, 0xdb, 0x0b, 0x37, 0x9f, 0x7d, 0xf3, 719 0x33, 0xed, 0x10, 0x15, 0x9a, 0x7b, 0xac, 0x22, 0x7d, 0x14, 0x54, 0xd2,
714 0x91, 0xec, 0x8d, 0x05, 0x43, 0x12, 0x56, 0xe1, 0xe8, 0xb0, 0xb5, 0x4b, 720 0x06, 0xf1, 0xfc, 0x17, 0xf2, 0x1f, 0x3e, 0xf1, 0xfc, 0xad, 0xf6, 0xd5,
715 0x12, 0x7d, 0x58, 0xf3, 0xdd, 0xc1, 0xcf, 0x59, 0xd2, 0x15, 0xe1, 0xba, 721 0x86, 0x4e, 0x09, 0x33, 0x3f, 0xb7, 0xd7, 0xdc, 0x4d, 0x89, 0x41, 0xc0,
716 0xee, 0xbf, 0x39, 0x68, 0xc9, 0x2b, 0x8d, 0x94, 0x5c, 0x68, 0x6c, 0xdf, 722 0xfc, 0xf5, 0xf0, 0x7f, 0xf4, 0x50, 0x0f, 0x5d, 0xc3, 0xe3, 0x24, 0xe8,
717 0x24, 0x5d, 0xd9, 0x52, 0x09, 0xfd, 0x6e, 0x8a, 0xe3, 0x96, 0x94, 0xab, 723 0xb2, 0xfe, 0x9c, 0xe6, 0xb5, 0x82, 0xe0, 0xa4, 0x1b, 0x04, 0x3f, 0xc6,
718 0x2d, 0xe2, 0x2a, 0xba, 0x7d, 0x5a, 0x71, 0xfe, 0x3e, 0xcd, 0x9b, 0x7f, 724 0xef, 0x2d, 0x17, 0x63, 0xff, 0xe3, 0xa0, 0x60, 0xe8, 0x24, 0x9c, 0xbf,
719 0x9e, 0xff, 0x1e, 0x24, 0xa5, 0xcb, 0x7d, 0x68, 0xf7, 0xa1, 0xcd, 0xf7, 725 0xd4, 0xbc, 0xe5, 0x2e, 0xaa, 0x2e, 0x1a, 0x34, 0xeb, 0xa7, 0xe9, 0x98,
720 0x81, 0xf4, 0x94, 0x98, 0x72, 0xa4, 0x91, 0x90, 0xa3, 0xd5, 0x8c, 0xe8, 726 0x5f, 0xd1, 0x4a, 0xad, 0x9a, 0xb6, 0xef, 0xf4, 0xbc, 0x76, 0xe7, 0xe9,
721 0x05, 0x71, 0xbd, 0xbc, 0x9d, 0x2e, 0xa3, 0x6f, 0xea, 0x00, 0xdb, 0x29, 727 0x63, 0xda, 0xfe, 0xd3, 0x75, 0xcd, 0x3b, 0x4d, 0x15, 0xb1, 0x37, 0x49,
722 0xe0, 0xf9, 0x0e, 0xd7, 0x59, 0x5e, 0x5e, 0x4a, 0xb7, 0xc6, 0x14, 0x0d, 728 0x05, 0xf3, 0x8c, 0x56, 0x6c, 0x0d, 0x68, 0xde, 0x89, 0x0f, 0xc9, 0x73,
723 0x8e, 0xb1, 0x0f, 0xbf, 0x58, 0x5f, 0xae, 0x76, 0x00, 0x6f, 0xd6, 0x71, 729 0x6d, 0xf3, 0xf7, 0xc8, 0x28, 0x80, 0x16, 0xf2, 0x6a, 0x41, 0xe0, 0xb9,
724 0x41, 0xdc, 0x73, 0x2c, 0xd0, 0xf6, 0xfd, 0xdf, 0x75, 0x32, 0xb2, 0xe2, 730 0x06, 0x15, 0xd2, 0x41, 0x20, 0xf2, 0xc1, 0x13, 0x5e, 0xce, 0x31, 0x85,
725 0x74, 0x81, 0xa7, 0x16, 0x69, 0xb5, 0xc5, 0xd2, 0x0b, 0xb6, 0xb5, 0x22, 731 0x96, 0xa6, 0x6a, 0x6b, 0x00, 0x78, 0x93, 0x5a, 0x71, 0xd1, 0xd0, 0x4a,
726 0x6d, 0x1c, 0xeb, 0x34, 0x0a, 0xbe, 0x3f, 0x9d, 0x97, 0xae, 0xa0, 0x6f, 732 0x7e, 0x70, 0xc1, 0x73, 0x69, 0x50, 0xa7, 0x20, 0x98, 0x73, 0x77, 0x65,
727 0xb7, 0xe2, 0x63, 0x72, 0x42, 0xc3, 0xbc, 0x57, 0x49, 0x0f, 0x3a, 0xe2, 733 0x0e, 0xd3, 0x29, 0xe0, 0x6d, 0x02, 0x1f, 0x99, 0x22, 0xcf, 0xf4, 0x31,
728 0x3b, 0x7f, 0xf3, 0x52, 0xac, 0x6c, 0x97, 0xc9, 0x54, 0xf6, 0xa0, 0x1b, 734 0x9d, 0x4c, 0x72, 0x45, 0x2b, 0x0e, 0x47, 0xf4, 0x91, 0xc5, 0xf4, 0x97,
729 0xd0, 0x74, 0x3d, 0x67, 0x2b, 0x70, 0x6a, 0xe0, 0x4f, 0xdb, 0x81, 0xf5, 735 0x57, 0x04, 0xe8, 0xdc, 0x42, 0xe5, 0x86, 0x49, 0x53, 0x2b, 0x1b, 0xd7,
730 0xee, 0x0a, 0x68, 0x1a, 0x85, 0xcd, 0x62, 0x6c, 0x66, 0x9f, 0xe8, 0x3b, 736 0x5f, 0x0e, 0x9e, 0x1f, 0x36, 0xe9, 0x5c, 0xcb, 0xae, 0x54, 0x28, 0x41,
731 0x87, 0x93, 0xe1, 0x78, 0x97, 0x36, 0x32, 0x6f, 0x88, 0x6e, 0xff, 0x81, 737 0x73, 0xbe, 0x45, 0x22, 0x4f, 0x05, 0x2f, 0x37, 0x48, 0x17, 0x5a, 0x19,
732 0xe6, 0xd5, 0x7a, 0xe5, 0xd8, 0xbc, 0x8e, 0x77, 0x5d, 0xae, 0xe6, 0x4b, 738 0xfa, 0x41, 0xcb, 0xc9, 0x54, 0x69, 0x13, 0x95, 0xd3, 0x69, 0x3a, 0xdf,
733 0x9a, 0xdb, 0xa8, 0x68, 0xde, 0xd9, 0x59, 0xad, 0x78, 0xd6, 0x94, 0xa3, 739 0x4a, 0xe3, 0x8c, 0xc1, 0x05, 0xe1, 0x38, 0x66, 0x15, 0x6b, 0xab, 0xad,
734 0xb6, 0x7f, 0xe1, 0xb4, 0x73, 0x42, 0x1b, 0x39, 0x7b, 0x46, 0x1b, 0x3d, 740 0x97, 0xf8, 0xdf, 0xbf, 0x98, 0xd3, 0x39, 0x09, 0x53, 0x01, 0xdd, 0xe1,
735 0xfb, 0x86, 0x36, 0xde, 0xd8, 0xb2, 0x49, 0xda, 0xb3, 0xd0, 0x1e, 0x71, 741 0x5a, 0x3e, 0x87, 0x5c, 0x2b, 0xcf, 0xa2, 0xd6, 0x52, 0x65, 0x3a, 0x87,
736 0x90, 0xbf, 0x4f, 0x87, 0xba, 0xec, 0xa2, 0xde, 0x4a, 0xe4, 0x7d, 0x9f, 742 0xb9, 0xd6, 0x1d, 0x6b, 0xfc, 0x2d, 0xa4, 0xf9, 0x69, 0x52, 0xd5, 0xef,
737 0xf3, 0x86, 0xe6, 0x55, 0x6d, 0x8b, 0xfb, 0xe6, 0xa6, 0x22, 0x1a, 0xed, 743 0x00, 0x6f, 0xb8, 0x3f, 0x88, 0xb3, 0xee, 0xd0, 0xbc, 0xc5, 0x7f, 0x65,
738 0x72, 0x74, 0xde, 0x94, 0x63, 0xd5, 0x94, 0x3c, 0x57, 0x2d, 0x29, 0x5a, 744 0xbc, 0x69, 0x41, 0x3b, 0x30, 0x1e, 0xc4, 0x98, 0xfb, 0xbb, 0x32, 0x65,
739 0x86, 0x5d, 0xd2, 0xbc, 0x06, 0xc7, 0x2b, 0xa0, 0x75, 0x42, 0xdb, 0x07, 745 0x02, 0x8f, 0x5b, 0x49, 0x8c, 0x99, 0xce, 0x20, 0xd8, 0xef, 0x92, 0x59,
740 0x9a, 0xde, 0x59, 0x29, 0x5d, 0x71, 0xe6, 0x40, 0xaf, 0x03, 0x78, 0xff, 746 0x75, 0x7b, 0x01, 0x6b, 0x51, 0xd5, 0xed, 0x01, 0xbe, 0x0e, 0xea, 0x73,
741 0x58, 0x1b, 0x6d, 0xf4, 0x6a, 0xde, 0xc9, 0x9b, 0xe2, 0x39, 0x59, 0xeb, 747 0xf8, 0x7c, 0xbc, 0xe7, 0x66, 0xcc, 0x07, 0xdd, 0x7a, 0x3e, 0x08, 0xa6,
742 0x4b, 0x62, 0xba, 0xb0, 0x01, 0xc8, 0x0c, 0xfd, 0x38, 0xd0, 0x49, 0xca, 748 0x73, 0xd4, 0xa3, 0xe6, 0xf6, 0x48, 0x1c, 0x53, 0x13, 0x1a, 0xd6, 0xbd,
743 0xf7, 0xf5, 0x82, 0xff, 0x2c, 0x74, 0x6f, 0x5d, 0xa1, 0xfc, 0x8d, 0x5e, 749 0xc3, 0x7b, 0x24, 0x52, 0x79, 0xee, 0xf3, 0x33, 0x47, 0xde, 0xfc, 0x8e,
744 0x29, 0xcf, 0x53, 0xd7, 0xa6, 0x36, 0x52, 0xf5, 0x2f, 0x78, 0x8e, 0xf4, 750 0x90, 0xa6, 0x0c, 0x68, 0xba, 0x31, 0xec, 0x43, 0x0e, 0x3e, 0xf8, 0xe1,
745 0x19, 0xe2, 0xfb, 0x47, 0x9d, 0x81, 0xf4, 0x21, 0x39, 0x03, 0xdc, 0x75, 751 0xde, 0x80, 0xb1, 0xf6, 0x45, 0xe0, 0xc9, 0x56, 0x89, 0xf7, 0xe8, 0xa7,
746 0xad, 0xd8, 0xa0, 0xae, 0xc1, 0xdf, 0x2d, 0x39, 0x02, 0xbd, 0x15, 0x9d, 752 0xa5, 0x34, 0x89, 0x2b, 0x6e, 0x5f, 0xb8, 0xae, 0x07, 0xb4, 0x46, 0xfa,
747 0x5e, 0x99, 0xb4, 0xb2, 0x2e, 0xf6, 0x68, 0x53, 0x20, 0x57, 0x32, 0xb4, 753 0x30, 0x40, 0x73, 0x8b, 0xcc, 0xf3, 0x1a, 0x64, 0x24, 0x68, 0xe7, 0x2d,
748 0x17, 0xd2, 0xe7, 0xde, 0x67, 0xd3, 0x9e, 0xa1, 0xcb, 0x53, 0x2f, 0x3d, 754 0x15, 0xad, 0xd0, 0x3a, 0x86, 0xbe, 0x41, 0xd3, 0x4e, 0x70, 0x61, 0xce,
749 0xdf, 0xb3, 0x38, 0xb4, 0x91, 0x32, 0x43, 0xff, 0xf2, 0x45, 0xcf, 0xf6, 755 0x9d, 0xd7, 0x8a, 0xa7, 0x4f, 0x69, 0xa5, 0xd3, 0xcf, 0x69, 0xfb, 0x5a,
750 0xb6, 0xb4, 0x48, 0x29, 0x6d, 0x48, 0x16, 0xfb, 0xb4, 0x43, 0x4e, 0x3b, 756 0x2f, 0x76, 0x53, 0x97, 0x8d, 0xd3, 0x27, 0xe8, 0x49, 0x5f, 0x23, 0xa6,
751 0x22, 0x87, 0x2a, 0xd0, 0x8d, 0x6d, 0x5a, 0x8b, 0x62, 0x67, 0xca, 0x32, 757 0x73, 0x09, 0x3c, 0x2c, 0x98, 0x15, 0x32, 0x9c, 0x1e, 0xed, 0x4e, 0xe0,
752 0x50, 0x32, 0x75, 0x74, 0x26, 0x49, 0x97, 0x3a, 0xd2, 0xe5, 0x7a, 0x9e, 758 0xe9, 0x70, 0xfe, 0x2c, 0x49, 0x3d, 0x3a, 0x6d, 0x72, 0xa2, 0xb5, 0x69,
753 0x7a, 0xa2, 0x3d, 0x7f, 0x28, 0x5d, 0x69, 0xab, 0xba, 0x5a, 0xd5, 0xd3, 759 0xfa, 0x73, 0xd0, 0x74, 0xd1, 0xdd, 0xca, 0x7c, 0xeb, 0x55, 0x30, 0xa9,
754 0xf8, 0x2f, 0x5d, 0x4f, 0xd4, 0xc9, 0x72, 0x28, 0xb7, 0x03, 0xdc, 0x8f, 760 0x90, 0x0e, 0xd6, 0x2f, 0x96, 0x9f, 0x6d, 0x7a, 0xba, 0xa0, 0xd2, 0xc2,
755 0x40, 0x5f, 0xe2, 0xea, 0xc3, 0x0f, 0xb1, 0x6f, 0x93, 0x51, 0xb0, 0xd3, 761 0x5f, 0xf4, 0x57, 0x47, 0xb6, 0xf0, 0x3a, 0xd8, 0xc2, 0xd5, 0x87, 0xa6,
756 0x17, 0x61, 0x14, 0x7a, 0x61, 0x37, 0x64, 0x19, 0xa6, 0xee, 0xe0, 0xc3, 762 0x1d, 0xaf, 0xcf, 0xa0, 0x8a, 0x29, 0xc8, 0x36, 0x8b, 0xf4, 0x45, 0x9a,
757 0x1f, 0x49, 0x5e, 0xf9, 0xd5, 0x90, 0x97, 0xfc, 0xdb, 0x32, 0x55, 0x49, 763 0x73, 0x89, 0x8a, 0x35, 0xec, 0xeb, 0x18, 0xe0, 0x8f, 0x03, 0xfe, 0xec,
758 0x80, 0x06, 0x65, 0xd4, 0xe5, 0xbd, 0x7c, 0x64, 0x1b, 0x7b, 0x20, 0x5f, 764 0xaa, 0xe8, 0xe2, 0x1e, 0xa0, 0xa9, 0x68, 0x46, 0xc8, 0xcb, 0x25, 0xba,
759 0x5e, 0xa6, 0xbe, 0x45, 0x7f, 0xa2, 0xfd, 0xf3, 0x9d, 0xb2, 0xfe, 0xcc, 765 0x4b, 0xc2, 0x8b, 0xbc, 0x0b, 0x5d, 0xed, 0xe2, 0x3e, 0xf6, 0x4e, 0xc8,
760 0xbf, 0xee, 0x7c, 0x92, 0xf6, 0x96, 0x7c, 0x27, 0xe4, 0x78, 0x35, 0xc9, 766 0xbd, 0xf5, 0xbc, 0x93, 0x59, 0x26, 0xd2, 0x44, 0x7e, 0x0f, 0xf0, 0xb1,
761 0x3d, 0xd4, 0x56, 0x54, 0x6c, 0x8a, 0x64, 0x14, 0xdd, 0x28, 0x74, 0x48, 767 0x0e, 0xf3, 0xba, 0x79, 0xd0, 0xc9, 0xf4, 0x73, 0xdf, 0x01, 0x4c, 0x02,
762 0x51, 0xed, 0xf7, 0x5e, 0xd0, 0x43, 0x2c, 0xa8, 0xf2, 0xbd, 0xa0, 0x64, 768 0xfa, 0xde, 0xdd, 0x46, 0x2b, 0xe8, 0x49, 0x33, 0xbf, 0x99, 0x7f, 0xf2,
763 0x9b, 0xb6, 0xed, 0xcc, 0x11, 0xc9, 0xc2, 0xbe, 0x45, 0x8e, 0xcc, 0x99, 769 0xac, 0xda, 0xb5, 0xb3, 0x7e, 0x10, 0x0c, 0x8f, 0x1a, 0xf4, 0x63, 0x79,
764 0x32, 0x6d, 0xff, 0x63, 0xa7, 0xb4, 0x2f, 0xdf, 0x6f, 0xa8, 0xb8, 0xae, 770 0x66, 0xb6, 0x37, 0x5e, 0x97, 0x0e, 0xf5, 0x23, 0x01, 0x9d, 0x22, 0xad,
765 0xf7, 0x6e, 0x90, 0x4d, 0xe0, 0x77, 0xf9, 0x7e, 0x5d, 0xe4, 0xa6, 0x59, 771 0xec, 0x9a, 0x6b, 0xb8, 0xca, 0x44, 0x42, 0xcf, 0x27, 0xa9, 0x28, 0xe9,
766 0xc8, 0x5a, 0x23, 0x08, 0xf6, 0x46, 0x81, 0xb1, 0x4c, 0x43, 0x2c, 0x93, 772 0x1b, 0xc3, 0x5e, 0x6c, 0x87, 0xb0, 0x27, 0x87, 0xcf, 0xc2, 0x73, 0x79,
767 0x44, 0x8b, 0x4d, 0x7d, 0xf9, 0xfe, 0xf8, 0xf0, 0xdd, 0xf5, 0x75, 0x64, 773 0xd8, 0xbb, 0xcd, 0x7d, 0x2a, 0xd7, 0xd9, 0xf6, 0x99, 0xb6, 0x55, 0x5b,
768 0x9e, 0xb4, 0xa9, 0x2f, 0xc6, 0xa8, 0x12, 0xf4, 0xc1, 0xf8, 0x74, 0xbb, 774 0xfe, 0xd3, 0x2c, 0x89, 0x4f, 0x0c, 0xe8, 0xd4, 0x4b, 0x13, 0xee, 0x87,
769 0xae, 0x8a, 0xa1, 0xae, 0x46, 0xfe, 0xef, 0xed, 0xc2, 0xf5, 0xaa, 0xa2, 775 0x81, 0xd8, 0x8d, 0xf7, 0x23, 0x19, 0xd0, 0x66, 0x5b, 0xb0, 0xca, 0x94,
770 0x79, 0xce, 0xbb, 0xa1, 0x2f, 0xd8, 0x32, 0x02, 0x7f, 0x37, 0xec, 0x4f, 776 0x4e, 0x1a, 0xe8, 0xde, 0x93, 0x31, 0xc9, 0xc1, 0xd9, 0xc0, 0xdf, 0x89,
771 0xcb, 0x91, 0x54, 0x76, 0xc2, 0x95, 0xc0, 0xe6, 0xaf, 0xad, 0xb1, 0xf9, 777 0x55, 0x30, 0xff, 0xd3, 0xe8, 0x54, 0x78, 0x41, 0x66, 0xc1, 0x03, 0x8d,
772 0xd1, 0xbb, 0xc8, 0x75, 0x3c, 0x94, 0xcb, 0x0d, 0xe5, 0x1a, 0x85, 0x5c, 778 0x9e, 0xfb, 0x65, 0xc9, 0x33, 0x13, 0xe7, 0xd7, 0xe7, 0x99, 0xbf, 0x5d,
773 0x63, 0x90, 0x6b, 0xe5, 0x23, 0xc8, 0xb5, 0xf2, 0x91, 0xe5, 0xd2, 0xa4, 779 0xb0, 0x0b, 0x8d, 0xca, 0x2e, 0xe3, 0x8e, 0x70, 0x08, 0x1a, 0xbe, 0xa5,
774 0xec, 0x3c, 0x08, 0x5a, 0xa6, 0xfc, 0xab, 0x13, 0xd8, 0xf2, 0xbf, 0x38, 780 0x1d, 0x47, 0x24, 0x5f, 0xd6, 0x5d, 0x83, 0x46, 0x47, 0x79, 0x2d, 0xaf,
775 0x9f, 0x14, 0x19, 0x7c, 0x7f, 0x70, 0xd8, 0x16, 0xef, 0x5b, 0xe0, 0xd5, 781 0xe3, 0xf5, 0xf6, 0x98, 0x25, 0x3e, 0x08, 0xf6, 0xae, 0xdb, 0xd3, 0x21,
776 0x71, 0x40, 0x8b, 0xef, 0xef, 0x97, 0xe1, 0x6e, 0xfe, 0x38, 0x8b, 0x7d, 782 0x31, 0x0f, 0x9a, 0x95, 0x2c, 0xc0, 0xc3, 0xcf, 0x5b, 0xcb, 0x72, 0xd8,
777 0x5d, 0xcf, 0x1f, 0x29, 0x87, 0x3e, 0x7c, 0xef, 0xfe, 0xa8, 0x6b, 0x1f, 783 0xc8, 0x6f, 0x5e, 0xdb, 0xbe, 0x0e, 0xfa, 0x3c, 0xc0, 0x34, 0x9c, 0x4c,
778 0x55, 0x0e, 0xc6, 0x9c, 0x4f, 0x35, 0x9d, 0xab, 0x1f, 0x56, 0x86, 0xf5, 784 0x2a, 0x3b, 0x8d, 0x68, 0x8a, 0x64, 0xa9, 0x85, 0x38, 0x3e, 0xeb, 0x1c,
779 0x63, 0xca, 0x2f, 0x4f, 0x86, 0xc7, 0x64, 0x72, 0x33, 0xed, 0xa9, 0xa4, 785 0xbc, 0x1e, 0xfe, 0xc3, 0x87, 0xff, 0x80, 0x4f, 0x3c, 0xef, 0xc3, 0xbf,
780 0x8d, 0x0c, 0x92, 0xef, 0xb5, 0xfc, 0x4a, 0x26, 0xe0, 0x0d, 0x39, 0xd1, 786 0xf8, 0xec, 0x6f, 0x2c, 0x7a, 0x7e, 0x18, 0xfe, 0xf1, 0x9a, 0x7f, 0x42,
781 0xd2, 0x46, 0x39, 0xb2, 0x60, 0x49, 0x69, 0xe9, 0x4e, 0x71, 0x57, 0x03, 787 0x1b, 0x47, 0x5f, 0x90, 0x0e, 0xff, 0x34, 0xdb, 0x10, 0xb0, 0x73, 0xf8,
782 0x6f, 0xb4, 0x47, 0xf6, 0x7d, 0xd2, 0x7c, 0x2a, 0xc8, 0x2b, 0x2e, 0x54, 788 0x8a, 0x15, 0x9e, 0x83, 0x5f, 0x58, 0x29, 0xe1, 0xe9, 0x50, 0xb5, 0xc9,
783 0x91, 0x83, 0x56, 0x13, 0x72, 0xd9, 0x48, 0xcb, 0x9b, 0x83, 0x87, 0xe5, 789 0x7a, 0x18, 0xf9, 0x61, 0xf6, 0x57, 0x19, 0xf8, 0x26, 0xf6, 0x47, 0xec,
784 0xf3, 0xd5, 0x24, 0xe8, 0x31, 0x9f, 0x2c, 0xe7, 0x10, 0x17, 0xb5, 0xb2, 790 0xb7, 0x78, 0x6d, 0x10, 0x94, 0x5c, 0x86, 0x0d, 0x20, 0x47, 0xb6, 0xbb,
785 0x63, 0x08, 0x79, 0xaf, 0xd9, 0x9c, 0x13, 0xc4, 0x96, 0x72, 0x10, 0x83, 791 0x24, 0x89, 0x54, 0x45, 0x3b, 0x34, 0x0c, 0x7b, 0xbc, 0x89, 0x7d, 0x0b,
786 0x5d, 0x6f, 0x50, 0xe5, 0x14, 0x90, 0x4f, 0x64, 0x0c, 0xb1, 0xb7, 0x66, 792 0xdb, 0xe5, 0x8d, 0x44, 0x9d, 0xbc, 0xdf, 0xaf, 0xbb, 0xd5, 0xbf, 0xd9,
787 0xb3, 0xcd, 0xfe, 0xa0, 0xef, 0xb3, 0x95, 0x5e, 0xad, 0xc8, 0xbc, 0x64, 793 0xdb, 0x84, 0x35, 0xf2, 0xd9, 0xa3, 0xc6, 0x66, 0xe8, 0x97, 0xf8, 0xbd,
788 0xf0, 0xa6, 0x4c, 0x3b, 0x41, 0xdf, 0xe7, 0x2a, 0xa3, 0x9b, 0x98, 0x1f, 794 0x6d, 0x15, 0x68, 0x57, 0x38, 0xe6, 0xfe, 0x1a, 0xbd, 0xae, 0xb8, 0x25,
789 0x1a, 0x05, 0xc9, 0x94, 0x9d, 0xf7, 0x7c, 0xd7, 0xba, 0x7d, 0xcd, 0xfa, 795 0x41, 0x3b, 0x4f, 0x29, 0x7f, 0xba, 0x73, 0x09, 0x9a, 0x71, 0x4a, 0xd1,
790 0x78, 0xb2, 0x13, 0x81, 0xce, 0x45, 0xfb, 0xaa, 0xad, 0xf7, 0xb6, 0x4a, 796 0xb8, 0xf3, 0x6c, 0xe4, 0x57, 0x93, 0xc0, 0x07, 0xfa, 0xfc, 0xb5, 0x18,
791 0x09, 0x27, 0x5d, 0xd6, 0x1a, 0x47, 0xe7, 0xbe, 0x4a, 0x79, 0x5b, 0xab, 797 0x82, 0xf6, 0x9e, 0x06, 0xd3, 0xc2, 0xdc, 0x46, 0x5e, 0xb0, 0x2f, 0x67,
792 0xdc, 0x34, 0x80, 0x3f, 0x6d, 0x68, 0x62, 0x1e, 0xaa, 0x94, 0xbb, 0xd9, 798 0xfb, 0x34, 0xdb, 0xed, 0x73, 0x2f, 0xec, 0xd3, 0xed, 0x24, 0xdb, 0xfd,
793 0xa6, 0xbe, 0x74, 0x4d, 0x12, 0xa3, 0x15, 0x5f, 0xae, 0x3a, 0x41, 0xee, 799 0x27, 0xd8, 0xe7, 0xb7, 0x5d, 0x0d, 0xbc, 0x21, 0xba, 0x54, 0xcb, 0xc0,
794 0x63, 0x68, 0x7a, 0x6f, 0x5b, 0xb8, 0x56, 0xd7, 0x76, 0x39, 0x97, 0x44, 800 0x3f, 0x18, 0x99, 0xd7, 0x69, 0x97, 0x35, 0x0b, 0xbd, 0x3c, 0xc9, 0x73,
795 0x3a, 0x0e, 0x55, 0xc4, 0x2a, 0x56, 0x76, 0x39, 0x6f, 0x4b, 0xb9, 0xa7, 801 0x4d, 0xcc, 0x49, 0x3f, 0xae, 0xfc, 0xc7, 0x65, 0xfd, 0xbb, 0xa0, 0x2b,
796 0x6d, 0x75, 0x5d, 0x8a, 0xeb, 0x76, 0x0e, 0xaf, 0x9d, 0xbb, 0xcb, 0xb9, 802 0x08, 0x66, 0x81, 0xb3, 0x3c, 0xa2, 0x87, 0xb6, 0x18, 0xcd, 0x5f, 0x45,
797 0x28, 0xe5, 0x2d, 0x6d, 0xab, 0xb4, 0xd2, 0x58, 0xdb, 0x17, 0xac, 0xe5, 803 0x3c, 0xf4, 0x7e, 0x43, 0xa7, 0x4a, 0xb6, 0x83, 0xec, 0xec, 0x12, 0x70,
798 0xf8, 0x66, 0x71, 0xbb, 0x39, 0x47, 0xef, 0x6d, 0xbf, 0x45, 0x43, 0x32, 804 0x4f, 0xbb, 0xca, 0xee, 0xd9, 0x36, 0x96, 0x81, 0x7f, 0xce, 0x1f, 0x86,
799 0xc5, 0x4a, 0xb9, 0xa7, 0x7d, 0x15, 0xaf, 0x4d, 0xbc, 0xde, 0x1a, 0xbc, 805 0x5f, 0x60, 0xbb, 0x01, 0x5d, 0xc0, 0xbf, 0x0c, 0xfc, 0x73, 0xad, 0x0e,
800 0xc4, 0xd9, 0xbe, 0x8a, 0x33, 0x07, 0x9c, 0x43, 0xab, 0x38, 0x39, 0x7e, 806 0xfa, 0x96, 0x11, 0xc5, 0xd9, 0xe8, 0x3c, 0xdb, 0xb0, 0x2c, 0xda, 0xf7,
801 0x58, 0x8a, 0x38, 0xd3, 0x5a, 0x0a, 0x32, 0xbc, 0x54, 0xc9, 0x48, 0x79, 807 0x08, 0xdd, 0xe5, 0xa7, 0xe0, 0x73, 0xd8, 0x27, 0x57, 0xb3, 0xb0, 0x2b,
802 0x28, 0x01, 0xdd, 0xf7, 0x1f, 0xfc, 0x9a, 0xaa, 0x43, 0xcc, 0x61, 0x0f, 808 0xad, 0xea, 0xf2, 0xde, 0x3a, 0x2d, 0xaf, 0xad, 0xa1, 0x42, 0x55, 0xd9,
803 0xba, 0x32, 0x55, 0x5e, 0x87, 0xd8, 0x08, 0xdb, 0xf8, 0x5a, 0x5d, 0x86, 809 0x6c, 0xc1, 0x1b, 0xae, 0x64, 0x74, 0xe9, 0x7b, 0x88, 0xee, 0x84, 0xad,
804 0x17, 0xeb, 0xa6, 0x1c, 0x6f, 0x70, 0xbf, 0x98, 0xe3, 0x05, 0x75, 0xc6, 810 0x2e, 0x3b, 0x3c, 0xe6, 0x79, 0x35, 0x37, 0x5e, 0x1b, 0xd0, 0x8a, 0xec,
805 0x85, 0x46, 0x4e, 0xdb, 0x87, 0xbd, 0x66, 0x9d, 0xb0, 0xaf, 0x61, 0x6a, 811 0xbf, 0x86, 0x3f, 0x04, 0x7d, 0x6a, 0xee, 0xb7, 0x6b, 0x0f, 0xb1, 0x8c,
806 0xa3, 0x3c, 0x1f, 0x80, 0x97, 0x76, 0x7e, 0xac, 0x41, 0xdb, 0x79, 0x03, 812 0x70, 0x16, 0xb2, 0xaa, 0xee, 0x7f, 0x06, 0xd0, 0xdf, 0x75, 0x30, 0xd7,
807 0xb6, 0x41, 0xce, 0xa3, 0x9c, 0xbd, 0x95, 0xb9, 0x53, 0x66, 0xd1, 0x51, 813 0xc7, 0x63, 0x8f, 0x2b, 0x9d, 0x25, 0x6d, 0xbf, 0x23, 0x06, 0x3a, 0x43,
808 0x75, 0x88, 0x56, 0xcb, 0x77, 0x20, 0x07, 0x4d, 0xa0, 0xd6, 0x80, 0xcd, 814 0x9f, 0xb7, 0x1f, 0x93, 0xfb, 0x6a, 0xd5, 0xfe, 0x4e, 0xfa, 0x50, 0xe7,
809 0xdb, 0x78, 0x6f, 0x70, 0xde, 0x32, 0xe6, 0x6d, 0xe0, 0x3c, 0xec, 0xcd, 815 0x18, 0x7c, 0x85, 0xc8, 0xf0, 0x6a, 0xbb, 0xc1, 0x8f, 0x6a, 0x5f, 0xdb,
810 0x25, 0xe5, 0x0f, 0xa6, 0xcd, 0xf1, 0x77, 0xb1, 0xc7, 0x68, 0xd7, 0x59, 816 0x5c, 0xa2, 0x54, 0x0b, 0xe8, 0xa2, 0xab, 0x60, 0x30, 0x4e, 0x16, 0x6b,
811 0x57, 0x58, 0x02, 0x5f, 0xc1, 0x3e, 0xa2, 0x6e, 0x48, 0xed, 0x60, 0x7e, 817 0x62, 0x20, 0x41, 0x6b, 0x63, 0x93, 0x61, 0x56, 0x68, 0x77, 0x76, 0x99,
812 0x8f, 0xb9, 0x19, 0xcc, 0xcd, 0x66, 0x18, 0xcf, 0x3d, 0xfb, 0x99, 0x0e, 818 0x24, 0x6c, 0x7f, 0xe2, 0x1a, 0x6c, 0xba, 0x54, 0xab, 0xf6, 0xb5, 0x8d,
813 0xe9, 0x42, 0xbb, 0xce, 0x35, 0xd9, 0x0c, 0x72, 0x5b, 0xdf, 0xcb, 0xb7, 819 0x33, 0x45, 0xe0, 0x12, 0x7b, 0xd7, 0x60, 0x07, 0xaf, 0xc1, 0x6e, 0x25,
814 0xc9, 0x4a, 0xca, 0xbf, 0x60, 0xd8, 0xd1, 0xdc, 0x08, 0x6f, 0xf3, 0x5c, 820 0xab, 0x8f, 0xe1, 0xc5, 0xc0, 0xe6, 0x6b, 0xb8, 0xad, 0x90, 0x9e, 0xfe,
815 0xe6, 0xc5, 0xc4, 0xbd, 0x21, 0xcc, 0x83, 0xc7, 0xc5, 0x6d, 0xfc, 0x49, 821 0xcd, 0xd7, 0x70, 0x38, 0x8c, 0xb3, 0x6d, 0x9c, 0x65, 0x9c, 0x3b, 0xaf,
816 0xb7, 0x74, 0xb9, 0xf8, 0x8d, 0xe6, 0x4c, 0x6f, 0x0e, 0x6a, 0x2e, 0xbe, 822 0xe1, 0x1c, 0x59, 0x4f, 0xcf, 0x11, 0x82, 0x0f, 0x4a, 0x74, 0xe6, 0x69,
817 0xb7, 0x50, 0x3e, 0x17, 0xe7, 0xa1, 0x56, 0xac, 0x66, 0x26, 0x59, 0x1f, 823 0xef, 0xa5, 0xda, 0xd0, 0xc4, 0x5d, 0x84, 0xf8, 0x38, 0xb2, 0x29, 0xf4,
818 0x15, 0xeb, 0x6c, 0xef, 0x85, 0x3f, 0x04, 0x75, 0xd7, 0x85, 0x5b, 0xbe, 824 0xe1, 0xc6, 0x5e, 0x0f, 0xbc, 0x32, 0x88, 0x7d, 0xa2, 0x46, 0x55, 0xc8,
819 0x70, 0x19, 0x7a, 0x4b, 0x43, 0x6f, 0x29, 0x39, 0xdf, 0x60, 0x9d, 0xe6, 825 0xf9, 0x8f, 0x9a, 0xb4, 0xf7, 0x62, 0xd3, 0x08, 0x75, 0x89, 0x75, 0xe2,
820 0x42, 0x5f, 0x19, 0xf1, 0x1a, 0xe3, 0x58, 0x2b, 0x87, 0x81, 0x03, 0x3a, 826 0x6d, 0xd8, 0x58, 0x72, 0xca, 0x40, 0x0c, 0xbf, 0x20, 0x6d, 0x8c, 0x26,
821 0x17, 0x47, 0x2f, 0x64, 0x65, 0xca, 0xda, 0x1d, 0xf1, 0x00, 0x5c, 0x88, 827 0xaa, 0x35, 0xaa, 0x6c, 0xcf, 0x3f, 0x11, 0x40, 0x17, 0xa7, 0xe0, 0xd3,
822 0x1f, 0x85, 0x36, 0xf4, 0xf1, 0x1d, 0x9a, 0x53, 0xff, 0x86, 0x7f, 0x94, 828 0xc0, 0xe3, 0xe4, 0x98, 0x97, 0xc3, 0x7c, 0x93, 0x6d, 0x0b, 0x7e, 0x05,
823 0xed, 0x09, 0xbd, 0x30, 0xd6, 0xd4, 0xbf, 0x6e, 0xfc, 0xa1, 0x1c, 0x68, 829 0xb0, 0xd0, 0xb5, 0x84, 0x3e, 0xbf, 0xeb, 0x55, 0x4f, 0xe7, 0x7d, 0x2c,
824 0x33, 0x06, 0x31, 0xfe, 0xe8, 0xa8, 0xf3, 0x18, 0x8b, 0x48, 0xd7, 0x92, 830 0xe4, 0x5c, 0x89, 0x84, 0x98, 0xbf, 0x1a, 0xb0, 0x9e, 0x4d, 0x8f, 0x5c,
825 0x23, 0x4b, 0x23, 0xdc, 0x37, 0x8b, 0xf1, 0xa7, 0x5c, 0xe7, 0x9e, 0x29, 831 0x45, 0x8e, 0x63, 0x92, 0x37, 0x06, 0xff, 0x01, 0x7d, 0x9f, 0x6d, 0x11,
826 0x5c, 0xc0, 0x19, 0xad, 0xf1, 0xfd, 0x11, 0x87, 0x6b, 0x7c, 0x99, 0x70, 832 0x72, 0x82, 0x3f, 0xed, 0x55, 0x36, 0xf6, 0x9d, 0xad, 0xea, 0x49, 0x06,
827 0x3a, 0xc4, 0x48, 0x96, 0xb4, 0xc7, 0x07, 0x11, 0x7b, 0x1e, 0xe0, 0x3e, 833 0xfb, 0xf2, 0xe9, 0x1c, 0xe7, 0x0f, 0x9d, 0x09, 0x2f, 0x37, 0xbe, 0x4d,
828 0x32, 0x06, 0x6d, 0x17, 0xb0, 0xea, 0xb4, 0x3c, 0x3c, 0xc8, 0x75, 0xa0, 834 0x3f, 0x7b, 0x60, 0x9b, 0x38, 0x5b, 0xd9, 0x26, 0x10, 0x03, 0x60, 0x53,
829 0xdd, 0x2a, 0x7a, 0x92, 0x34, 0xf3, 0x21, 0x4f, 0x43, 0xdd, 0x81, 0xbe, 835 0xc2, 0xcb, 0xa1, 0x7f, 0x36, 0xb2, 0xa1, 0x0c, 0x6c, 0x88, 0x69, 0x65,
830 0x06, 0xac, 0x40, 0x7f, 0x9f, 0xe9, 0x5e, 0xd5, 0x1f, 0xd7, 0x35, 0xf3, 836 0x3a, 0x7f, 0x04, 0x7b, 0x95, 0xb4, 0xd2, 0x84, 0x0f, 0x9a, 0x46, 0x3f,
831 0xcb, 0x18, 0x96, 0x90, 0x81, 0x33, 0x1b, 0x65, 0xe7, 0xa2, 0x25, 0xf6, 837 0x82, 0x9e, 0xe0, 0x2c, 0xf0, 0x81, 0x05, 0x70, 0x49, 0x8c, 0xfe, 0x2a,
832 0x99, 0x55, 0xfe, 0x76, 0x9e, 0x5b, 0xcb, 0x5f, 0xf4, 0x7f, 0x15, 0x5c, 838 0xb4, 0x67, 0xee, 0xbf, 0x1b, 0xa8, 0x78, 0x72, 0x30, 0xdc, 0xff, 0x17,
833 0xd0, 0xc5, 0x8e, 0xfa, 0x1e, 0x4b, 0x05, 0xb8, 0xa3, 0xf6, 0x7b, 0xe1, 839 0xa1, 0x0f, 0x88, 0x70, 0x31, 0x9e, 0xac, 0x36, 0x81, 0x5c, 0x68, 0xa2,
834 0x5e, 0xf1, 0xfd, 0x99, 0x70, 0x4f, 0xb0, 0x07, 0x88, 0x95, 0xe7, 0x6f, 840 0x65, 0x68, 0xec, 0xcf, 0x8b, 0x3e, 0xe7, 0x30, 0x9c, 0xbf, 0x3c, 0x1e,
835 0xc5, 0xa9, 0x0c, 0xf6, 0x06, 0xb6, 0xa7, 0xe2, 0x11, 0xe3, 0x18, 0xed, 841 0xfa, 0x45, 0xce, 0x5b, 0x92, 0x21, 0x4f, 0x73, 0x51, 0x5c, 0x94, 0xf6,
836 0xbb, 0x63, 0xd2, 0x2c, 0xb0, 0x8e, 0xe6, 0x3e, 0xc9, 0x44, 0xb9, 0x22, 842 0x86, 0x18, 0x65, 0x95, 0x5d, 0x99, 0xd3, 0x68, 0xd3, 0xb9, 0x24, 0xd6,
837 0xa5, 0xad, 0x85, 0x67, 0x7d, 0xd8, 0xcf, 0xa4, 0xa5, 0x6c, 0xaf, 0x63, 843 0x61, 0xae, 0x85, 0x73, 0xc3, 0x2f, 0x21, 0x0f, 0xe2, 0xdc, 0x14, 0xeb,
838 0xaf, 0x97, 0x37, 0xa0, 0x1b, 0x8c, 0xc1, 0x26, 0xf5, 0x42, 0x42, 0x8a, 844 0x3b, 0x43, 0x9b, 0xbf, 0x44, 0x65, 0xf8, 0x54, 0xc3, 0xe1, 0xf7, 0x5e,
839 0x8d, 0x44, 0xc2, 0x3c, 0x31, 0xf0, 0x23, 0xcf, 0x48, 0x24, 0xf4, 0x13, 845 0x2f, 0x75, 0x61, 0xdc, 0xc4, 0x5e, 0xf0, 0x13, 0xba, 0xe4, 0x33, 0x62,
840 0x81, 0x9d, 0x4d, 0xd6, 0x6f, 0x20, 0x56, 0x6a, 0x72, 0x74, 0xe8, 0x86, 846 0x41, 0xfa, 0x06, 0xce, 0xaf, 0xb0, 0xd6, 0xc2, 0x5a, 0xf6, 0xbb, 0xbc,
841 0xcf, 0x1a, 0xd8, 0xdb, 0x0b, 0x9b, 0x1b, 0x82, 0xcf, 0x80, 0x8f, 0x72, 847 0xf6, 0x3c, 0xe8, 0xc0, 0xb8, 0xc9, 0x30, 0xec, 0xa3, 0x82, 0xf7, 0xbc,
842 0xa3, 0xa3, 0x37, 0xe0, 0xed, 0x2b, 0x11, 0x8f, 0xa6, 0x8e, 0xdc, 0xd3, 848 0xdc, 0x1e, 0x73, 0x82, 0x12, 0x21, 0x5e, 0xab, 0x0d, 0xef, 0xc6, 0xb5,
843 0xcb, 0xfb, 0xbe, 0x51, 0xd8, 0x90, 0x98, 0xce, 0x8f, 0x6f, 0xd1, 0xcf, 849 0x9c, 0xd3, 0x04, 0x17, 0x74, 0x87, 0xf1, 0x47, 0x79, 0x18, 0xd1, 0xf4,
844 0xed, 0xdf, 0x62, 0x9c, 0x2b, 0x6d, 0x01, 0x3e, 0xdd, 0xcb, 0xe3, 0xf7, 850 0x09, 0xe4, 0x71, 0x4e, 0x07, 0xe2, 0x14, 0x8f, 0x86, 0x4c, 0x75, 0xce,
845 0x9c, 0xc8, 0x44, 0x15, 0x3a, 0xdf, 0x03, 0x3d, 0x59, 0xf0, 0xc5, 0x3d, 851 0x08, 0xe6, 0x81, 0xfe, 0xf5, 0xe3, 0xbb, 0x53, 0xd7, 0xfc, 0x23, 0x5b,
846 0xa6, 0xca, 0xd1, 0xf5, 0x3d, 0x2f, 0x6e, 0x0a, 0x70, 0xf0, 0xfd, 0x27, 852 0x17, 0x15, 0x10, 0x1f, 0xc0, 0x27, 0x6b, 0x8a, 0x73, 0xbf, 0x62, 0x53,
847 0x7e, 0x70, 0x86, 0x5e, 0x0e, 0xfb, 0x7e, 0x3f, 0xdc, 0x87, 0x5f, 0x45, 853 0xa2, 0xc4, 0xdc, 0x18, 0x7c, 0xa2, 0xca, 0xa3, 0x2e, 0xf8, 0x1b, 0xe5,
848 0xb9, 0x78, 0x5e, 0x44, 0xb2, 0xad, 0x3d, 0x37, 0xb2, 0xe3, 0x25, 0x9c, 854 0x66, 0x82, 0xd7, 0x05, 0xf0, 0xd7, 0x82, 0xfe, 0x8c, 0x03, 0x96, 0x8e,
849 0x33, 0xa7, 0x1d, 0xdf, 0x7f, 0x07, 0xcf, 0x35, 0xa7, 0xd9, 0x46, 0xde, 855 0x00, 0x07, 0xc7, 0x6a, 0x57, 0xe4, 0x53, 0x54, 0x36, 0x39, 0xa7, 0xe8,
850 0x7f, 0xf6, 0x31, 0x07, 0xf8, 0x2c, 0xce, 0xbd, 0xd1, 0xa6, 0xb3, 0xff, 856 0x64, 0xfa, 0x0a, 0x6c, 0xfb, 0x22, 0xbf, 0x19, 0x73, 0xdc, 0x7f, 0xac,
851 0x5e, 0xcf, 0xbd, 0x7b, 0x3f, 0xfb, 0xc9, 0xf3, 0x1d, 0x7d, 0xef, 0x03, 857 0x57, 0xc9, 0xab, 0x9b, 0xc7, 0x13, 0x22, 0xdf, 0xbb, 0x61, 0xfe, 0x9f,
852 0xce, 0xfe, 0x0f, 0x5c, 0x77, 0x0f, 0x3e, 0x1b, 0xd8, 0x6d, 0xb1, 0xd1, 858 0xbb, 0x15, 0x6d, 0x72, 0x8c, 0xf9, 0x7f, 0xdb, 0x30, 0xfe, 0xe3, 0xd4,
853 0x1c, 0x5f, 0xee, 0xd5, 0x7f, 0x7f, 0xad, 0xfb, 0x76, 0xff, 0xb5, 0xbb, 859 0xfa, 0xf1, 0xdd, 0xdb, 0x42, 0xfd, 0x43, 0xff, 0xf1, 0x90, 0x5e, 0xd0,
854 0x6f, 0xf7, 0xdf, 0xcd, 0xdd, 0xbf, 0x18, 0xff, 0xcd, 0x01, 0x0f, 0x7d, 860 0xb6, 0x46, 0x6b, 0x94, 0x2b, 0x53, 0x5d, 0x20, 0x5f, 0xf4, 0x72, 0xbb,
855 0x70, 0xad, 0xff, 0xae, 0xe7, 0x93, 0xd4, 0xf7, 0xf3, 0x3d, 0xe5, 0xa1, 861 0xac, 0x2a, 0x6c, 0xaa, 0xd4, 0x02, 0xdd, 0x6b, 0x71, 0x6c, 0x6d, 0x4d,
856 0xce, 0x30, 0x1f, 0x52, 0xe7, 0xf5, 0x17, 0xa7, 0x6d, 0xef, 0x7e, 0x53, 862 0xe5, 0xda, 0x1a, 0xe5, 0xe7, 0x4b, 0xad, 0x00, 0x79, 0x56, 0x7b, 0xcc,
857 0x4a, 0xb9, 0x16, 0xc9, 0xe6, 0x6a, 0xb2, 0x43, 0x8e, 0x3b, 0x22, 0x4b, 863 0xcb, 0xa2, 0x5f, 0xc1, 0x3e, 0x05, 0x9a, 0xf6, 0x2f, 0x16, 0x84, 0x73,
858 0xaa, 0x16, 0x31, 0x51, 0x8b, 0x0f, 0xa0, 0x3e, 0x0b, 0xf4, 0xba, 0xa4, 864 0x4c, 0xe6, 0x89, 0xc2, 0x79, 0x4a, 0x2b, 0x2d, 0x73, 0xfe, 0x08, 0x5b,
859 0xf4, 0xf2, 0x02, 0x78, 0x89, 0xf0, 0x74, 0xdd, 0x05, 0x0f, 0x71, 0x10, 865 0x72, 0x64, 0xdd, 0x80, 0x98, 0x72, 0x5c, 0x2b, 0x9c, 0x5e, 0x40, 0xfe,
860 0x17, 0xf1, 0x0c, 0xe2, 0x7c, 0xb7, 0xd7, 0xc1, 0x85, 0x73, 0xea, 0x25, 866 0xb8, 0x82, 0xdf, 0x19, 0xfc, 0x9a, 0xf8, 0x45, 0xf9, 0xfb, 0x33, 0xc8,
861 0xd4, 0x64, 0xb6, 0xde, 0xa3, 0x07, 0x67, 0xb2, 0x5b, 0x96, 0xdd, 0xe9, 867 0xff, 0xa5, 0x7f, 0x45, 0x2c, 0x50, 0xfb, 0xff, 0x62, 0x05, 0x3a, 0xb6,
862 0xeb, 0xf2, 0x05, 0x9e, 0x59, 0x0a, 0xae, 0xce, 0x21, 0x56, 0x0f, 0x8d, 868 0x90, 0xa6, 0x6f, 0x3b, 0xa2, 0x5f, 0x28, 0x9f, 0x52, 0x40, 0xde, 0x6b,
863 0x85, 0x75, 0xd2, 0xdc, 0x41, 0xcf, 0x8e, 0xee, 0x49, 0x78, 0x47, 0x92, 869 0xbe, 0x4d, 0xbf, 0x13, 0xe6, 0x50, 0x44, 0xaf, 0xd7, 0xc1, 0xc7, 0x91,
864 0x90, 0x92, 0x9a, 0xb5, 0x04, 0x1d, 0x68, 0x72, 0x0d, 0x67, 0xd0, 0xd5, 870 0xfd, 0xa1, 0xbe, 0x66, 0x1f, 0xf4, 0xa4, 0xef, 0x0c, 0x73, 0x24, 0xe4,
865 0xb9, 0x76, 0xe0, 0x45, 0xee, 0x77, 0x20, 0xbb, 0x57, 0xb4, 0x7e, 0xab, 871 0x6a, 0x05, 0xb9, 0xea, 0xfb, 0xe0, 0x8d, 0x46, 0x6f, 0x41, 0x7f, 0x5e,
866 0x55, 0x6b, 0x87, 0x2f, 0x65, 0xc4, 0x55, 0x6d, 0x9e, 0xd3, 0xa7, 0x66, 872 0xaf, 0x77, 0x81, 0x1e, 0x87, 0xca, 0x93, 0xf6, 0x18, 0x69, 0x43, 0xe6,
867 0x16, 0x2b, 0xc8, 0x03, 0x6d, 0x9c, 0xaf, 0x79, 0xbc, 0xd7, 0x49, 0x43, 873 0x26, 0xad, 0x0b, 0x36, 0x0c, 0xfb, 0x96, 0x63, 0x4a, 0x74, 0xe4, 0xcf,
868 0x93, 0x2b, 0x73, 0xba, 0xfc, 0xd3, 0x9c, 0x21, 0xff, 0x8c, 0x3a, 0xf4, 874 0xcd, 0x2c, 0xd5, 0x04, 0xd6, 0x22, 0xef, 0xc9, 0xa1, 0x0f, 0xd9, 0x5f,
869 0x9a, 0x7d, 0x6a, 0xe6, 0xb4, 0x2d, 0xf7, 0x81, 0xd5, 0xf0, 0x0e, 0x4f, 875 0xa9, 0x33, 0x9c, 0xa0, 0x37, 0xea, 0x3a, 0xbd, 0x89, 0xbc, 0xeb, 0x2d,
870 0x76, 0x9a, 0x42, 0x5b, 0x1d, 0x48, 0xff, 0x8e, 0x20, 0xff, 0xc1, 0x9a, 876 0xe7, 0xdc, 0x0c, 0x62, 0xd6, 0x00, 0xe2, 0x03, 0x6a, 0x98, 0x5d, 0xec,
871 0x2b, 0x73, 0xa4, 0xb5, 0x76, 0x8d, 0xf4, 0x22, 0x1f, 0x83, 0x5d, 0x0f, 877 0xa3, 0x77, 0x1a, 0x78, 0x96, 0xf0, 0xbb, 0x13, 0x79, 0xe3, 0xf5, 0x61,
872 0x30, 0x27, 0xe2, 0x7c, 0xd4, 0xab, 0x03, 0xd6, 0x3e, 0xc5, 0x5b, 0x42, 878 0x3e, 0x6d, 0x3d, 0xd3, 0x96, 0x00, 0x0c, 0xaf, 0x37, 0x40, 0x5b, 0x0f,
873 0x16, 0xeb, 0x9c, 0x6f, 0x82, 0xb7, 0x2e, 0x9c, 0x31, 0x59, 0x6b, 0x52, 879 0xe4, 0x6f, 0x9b, 0x53, 0xf4, 0xcb, 0x5e, 0x99, 0xab, 0x68, 0x3c, 0xaf,
874 0xfe, 0xb0, 0x5b, 0xe5, 0xaa, 0x1a, 0xfb, 0x0d, 0xb5, 0xc7, 0xef, 0xef, 880 0xfc, 0xd2, 0x27, 0xe7, 0x99, 0xcf, 0x3a, 0x74, 0x9c, 0xc7, 0xfc, 0x8e,
875 0xe7, 0xde, 0x1b, 0x32, 0x95, 0x62, 0x9b, 0x63, 0x59, 0xd4, 0x9c, 0xc4, 881 0xfd, 0x27, 0xe3, 0xb3, 0xc7, 0x0a, 0x38, 0xcc, 0x95, 0xba, 0xea, 0x47,
876 0x97, 0xdd, 0xeb, 0x0a, 0x79, 0x0e, 0xde, 0xaf, 0x08, 0x65, 0xdb, 0x6d, 882 0x73, 0xa4, 0x45, 0x31, 0x8c, 0xfd, 0x62, 0x89, 0x0a, 0x92, 0xef, 0x13,
877 0x5d, 0x97, 0xd7, 0x7d, 0xf7, 0x00, 0xe5, 0x89, 0x72, 0x8b, 0x39, 0x9f, 883 0x24, 0x65, 0xb0, 0x4e, 0x9e, 0x94, 0x30, 0xf2, 0xf5, 0x99, 0x39, 0x87,
878 0xb1, 0xd8, 0x28, 0xcc, 0xc0, 0x8e, 0xbf, 0x2a, 0xdf, 0x6f, 0x1c, 0x92, 884 0xe5, 0x0a, 0xff, 0x56, 0x8b, 0xe4, 0xca, 0x32, 0xea, 0xa4, 0x6a, 0xfd,
879 0xef, 0x35, 0x26, 0xe5, 0xcf, 0x1a, 0x5f, 0x96, 0x3f, 0x6d, 0x1c, 0x94, 885 0x29, 0xc8, 0x55, 0x84, 0xf5, 0x01, 0xec, 0x7b, 0x81, 0xe5, 0x8b, 0xba,
880 0xd7, 0x1b, 0x07, 0xe4, 0xb5, 0xc6, 0x84, 0xbc, 0xda, 0xd8, 0x0f, 0x1b, 886 0xb1, 0x8e, 0xbc, 0xa7, 0x4e, 0x29, 0x55, 0xdf, 0x1c, 0x47, 0x5d, 0x00,
881 0x1f, 0x87, 0x8d, 0x9f, 0x9a, 0x99, 0xac, 0xf7, 0xcb, 0xd4, 0x49, 0xc4, 887 0xf9, 0xd5, 0x16, 0x80, 0x03, 0x36, 0x5a, 0x5b, 0xc1, 0x13, 0xb5, 0x48,
882 0x20, 0xe7, 0x1b, 0xba, 0xba, 0xe3, 0xb3, 0xe9, 0xe7, 0x2d, 0x32, 0xad, 888 0xed, 0x0c, 0x9e, 0x83, 0x78, 0x36, 0x59, 0x37, 0xc3, 0x3c, 0xe3, 0x13,
883 0xee, 0xaf, 0x34, 0xe4, 0x89, 0x2d, 0xbc, 0x2b, 0x7c, 0xc5, 0x33, 0x2e, 889 0xf4, 0xc0, 0x9e, 0x4a, 0x6c, 0x4f, 0xf4, 0x8f, 0xad, 0x3c, 0xfd, 0x43,
884 0x87, 0xf1, 0xe8, 0xe1, 0x94, 0xb4, 0x03, 0xbf, 0xca, 0x4b, 0x4d, 0x9e, 890 0x6b, 0x8c, 0x7e, 0xd4, 0xca, 0xd1, 0x0f, 0x5b, 0x2e, 0xfd, 0x7d, 0x6b,
885 0xdb, 0x62, 0x86, 0xf7, 0x9c, 0x87, 0x24, 0xc9, 0xfb, 0xb0, 0x9c, 0x67, 891 0x84, 0x9e, 0x6d, 0x65, 0xb9, 0x96, 0x43, 0xce, 0x64, 0x71, 0xce, 0x44,
886 0xa0, 0xde, 0x5e, 0xd7, 0x27, 0x73, 0xb4, 0x65, 0xe8, 0xc6, 0x95, 0x43, 892 0x0f, 0xfa, 0xb7, 0xc3, 0xde, 0x59, 0xfe, 0xe7, 0x66, 0x0a, 0xcd, 0x21,
887 0xb0, 0x53, 0xc3, 0x7e, 0xcb, 0xa5, 0x1e, 0x16, 0x97, 0x28, 0xf7, 0x46, 893 0x2a, 0x9f, 0x80, 0x6f, 0x76, 0x6f, 0xe3, 0x1a, 0x94, 0x1e, 0x73, 0xb9,
888 0x59, 0x5c, 0xa0, 0x6f, 0xff, 0x1b, 0x64, 0x6c, 0x97, 0xda, 0x82, 0x89, 894 0x86, 0xe8, 0xe0, 0xf7, 0xa8, 0x23, 0xe0, 0xbb, 0xe1, 0xcb, 0xa6, 0xd2,
889 0xb9, 0x6e, 0x98, 0xab, 0x6c, 0xa7, 0x3d, 0x00, 0x1f, 0xf1, 0x7e, 0x10, 895 0xf6, 0x39, 0x4f, 0x1f, 0x08, 0x7d, 0xc0, 0x5d, 0x29, 0xea, 0xc2, 0x5e,
890 0x4e, 0xab, 0x09, 0x27, 0xf1, 0x24, 0x54, 0x0c, 0x08, 0x70, 0x5b, 0x52, 896 0xf0, 0x7f, 0x17, 0x9f, 0x86, 0x0d, 0xc8, 0x1a, 0x28, 0x01, 0x5f, 0xc3,
891 0x5b, 0x4a, 0xca, 0xc2, 0x42, 0x0f, 0x9e, 0x94, 0x2c, 0xd4, 0x6d, 0x3c, 897 0x79, 0x80, 0xc1, 0x76, 0xcc, 0xf5, 0x87, 0xe5, 0xe9, 0x5c, 0x17, 0xb2,
892 0x39, 0x3c, 0x43, 0x78, 0xd2, 0xb0, 0x53, 0xca, 0xc8, 0xd8, 0x12, 0xc9, 898 0x3d, 0xeb, 0x08, 0x1a, 0x0c, 0x37, 0x69, 0xb2, 0xdc, 0x0c, 0x87, 0x7d,
893 0x88, 0x78, 0x5c, 0xed, 0x0d, 0x6b, 0x2a, 0xf2, 0xa3, 0x85, 0xfc, 0x74, 899 0x6a, 0x21, 0xf4, 0x6f, 0x89, 0x50, 0x2f, 0x4d, 0xcc, 0x3f, 0x15, 0xfa,
894 0x87, 0x7d, 0x1d, 0x52, 0xab, 0x38, 0x32, 0x55, 0xfd, 0x94, 0x3e, 0xa5, 900 0xe3, 0x8d, 0xfb, 0x20, 0x56, 0x20, 0x97, 0x54, 0xeb, 0x18, 0x56, 0x0b,
895 0x74, 0x07, 0xfc, 0x95, 0x21, 0xb4, 0xef, 0x0f, 0xdb, 0x8f, 0xca, 0xf4, 901 0x61, 0xfb, 0xc3, 0xb9, 0x24, 0xf8, 0xed, 0x52, 0xd9, 0x7f, 0x43, 0xe3,
896 0xbc, 0xc8, 0xca, 0xcb, 0x03, 0x7a, 0x51, 0xb5, 0xf7, 0xa2, 0xad, 0xa3, 902 0x1c, 0x5b, 0x38, 0xcc, 0xff, 0x11, 0x8c, 0x2f, 0x87, 0xe3, 0xaf, 0xd0,
897 0x9d, 0x0d, 0xdb, 0xcc, 0x8f, 0x0e, 0xe0, 0x71, 0xd5, 0xf3, 0xf5, 0xea, 903 0xf4, 0x22, 0x81, 0xd6, 0xd7, 0xb4, 0xa2, 0x1c, 0x8f, 0x61, 0x2c, 0x30,
898 0xb8, 0x3c, 0x55, 0xed, 0x77, 0x5e, 0x87, 0xcd, 0xbd, 0x65, 0x46, 0xf7, 904 0xd6, 0xb9, 0x6e, 0xe0, 0x0c, 0x23, 0xc5, 0xba, 0x2e, 0x9c, 0x71, 0xf0,
899 0xd2, 0x04, 0x24, 0x79, 0xf6, 0x56, 0x75, 0xf7, 0xf1, 0x04, 0xe2, 0xad, 905 0x71, 0x12, 0xbf, 0x82, 0xfc, 0x3d, 0xe2, 0x0f, 0x15, 0xde, 0x41, 0xbc,
900 0x9b, 0x34, 0xe5, 0x6f, 0x4f, 0x64, 0xad, 0xa7, 0xf5, 0x5c, 0x52, 0xda, 906 0xd0, 0x3a, 0xa2, 0xdc, 0x67, 0x3b, 0x6a, 0xcf, 0x20, 0x38, 0x84, 0x5a,
901 0x7d, 0xff, 0x71, 0x3b, 0x3b, 0x3b, 0xa9, 0x77, 0xca, 0xdf, 0xbf, 0x98, 907 0xdd, 0x4a, 0x19, 0xf4, 0x2f, 0xf3, 0xb6, 0x79, 0x48, 0xcc, 0xe1, 0x4c,
902 0x91, 0x85, 0xb3, 0x5b, 0x65, 0xa1, 0x06, 0x99, 0x1a, 0xbf, 0x8e, 0x7d, 908 0x41, 0x30, 0xe1, 0xd8, 0x95, 0x82, 0xe8, 0xa6, 0x9f, 0x1f, 0xe7, 0xb8,
903 0x35, 0xe5, 0xea, 0x9e, 0x47, 0xb1, 0x27, 0x8c, 0x5d, 0x49, 0xe4, 0x6c, 909 0x5b, 0x9f, 0x79, 0x01, 0xba, 0xd7, 0x58, 0xe9, 0xa4, 0x46, 0xc3, 0xa0,
904 0x1b, 0xc4, 0xec, 0x25, 0x5d, 0x49, 0x98, 0x85, 0x9c, 0x1c, 0x81, 0xdf, 910 0x2b, 0xa3, 0x43, 0xa0, 0xd3, 0xa4, 0x46, 0x33, 0x85, 0x5c, 0x6e, 0x33,
905 0x4f, 0xdb, 0xb9, 0x1e, 0x69, 0xc7, 0x7b, 0x7d, 0x04, 0x7c, 0x5b, 0x32, 911 0xa1, 0x3c, 0x94, 0x0e, 0x43, 0xcf, 0x67, 0xa5, 0x8f, 0xf6, 0x1c, 0x3c,
906 0xd5, 0x6b, 0xc9, 0x99, 0xc1, 0x68, 0xff, 0xb6, 0x62, 0x6e, 0x46, 0x16, 912 0x9b, 0x1f, 0xf4, 0xae, 0x3f, 0x73, 0x09, 0xf4, 0xf7, 0xa0, 0x0a, 0xd9,
907 0xcf, 0x66, 0xf0, 0x9b, 0x83, 0xfd, 0xec, 0x94, 0x57, 0x6a, 0xfd, 0xb2, 913 0x2e, 0xe5, 0x5c, 0xf6, 0x87, 0x4c, 0x4f, 0x20, 0x6e, 0x19, 0x43, 0xe6,
908 0x54, 0xdb, 0x2a, 0x8b, 0xb5, 0xe6, 0x7d, 0xe8, 0xec, 0x09, 0xe2, 0x1d, 914 0x7e, 0xf1, 0xab, 0xe0, 0x0e, 0x83, 0x65, 0xf7, 0xaa, 0xac, 0x77, 0x64,
909 0xf1, 0xf4, 0x5b, 0x53, 0xfa, 0x56, 0x71, 0xcd, 0x7e, 0xeb, 0x29, 0xfd, 915 0x9c, 0xc3, 0x7e, 0x4b, 0x2b, 0xaf, 0x81, 0x16, 0x93, 0x9e, 0x6d, 0x6e,
910 0x1f, 0xe4, 0x31, 0x33, 0xa0, 0xa9, 0x17, 0x7e, 0xa4, 0xee, 0x84, 0x26, 916 0x0f, 0xc7, 0x96, 0xe4, 0xc5, 0xb3, 0xcd, 0x2e, 0xfa, 0x61, 0x63, 0x0b,
911 0x79, 0xf6, 0x2a, 0xbc, 0x4f, 0x26, 0x49, 0xfb, 0xf5, 0xc6, 0x07, 0xd1, 917 0x2d, 0x37, 0xf8, 0x7d, 0x27, 0x2d, 0x35, 0x86, 0xae, 0x1e, 0x15, 0x03,
912 0x59, 0xcb, 0xcf, 0x9d, 0x68, 0x52, 0x06, 0xe2, 0xec, 0xbf, 0x71, 0x52, 918 0xb4, 0x7a, 0xe3, 0x4d, 0xe6, 0x57, 0x05, 0xf2, 0x82, 0xc9, 0x8f, 0xe9,
913 0xef, 0x95, 0xe5, 0x6d, 0x0f, 0x58, 0x4f, 0xea, 0xad, 0x88, 0x01, 0x3f, 919 0xbd, 0xd1, 0x5e, 0xfa, 0xe9, 0x3d, 0x76, 0xfd, 0x7e, 0x01, 0x1b, 0x18,
914 0x97, 0x9f, 0xee, 0xd9, 0x24, 0x3f, 0xfc, 0xcd, 0xec, 0xa9, 0x6f, 0x22, 920 0x4d, 0xb2, 0x6d, 0xa3, 0xcf, 0xf3, 0xf6, 0x55, 0x4b, 0xb0, 0x6e, 0xff,
915 0xd9, 0xbf, 0xb2, 0xa7, 0x83, 0x71, 0x01, 0xef, 0xec, 0xcf, 0xde, 0x70, 921 0x04, 0x3c, 0xb5, 0x8f, 0x29, 0x3b, 0x60, 0xdc, 0x8c, 0x17, 0xba, 0xe1,
916 0x75, 0xea, 0xe1, 0x2f, 0xa0, 0x87, 0xec, 0x9c, 0xba, 0x9b, 0x56, 0x3c, 922 0xbc, 0x08, 0x9c, 0x78, 0xd7, 0x1c, 0x02, 0xae, 0x17, 0x25, 0x2f, 0x0e,
917 0x90, 0x3e, 0xf5, 0x52, 0x06, 0x6f, 0x18, 0xab, 0xf7, 0x03, 0x57, 0x59, 923 0xb9, 0xf6, 0x55, 0x42, 0x0e, 0x79, 0xc5, 0x19, 0xca, 0x0a, 0xb1, 0x9d,
918 0xe9, 0xf9, 0x09, 0x27, 0x7b, 0x03, 0xe9, 0xb0, 0xbf, 0x68, 0xf7, 0xa7, 924 0x1a, 0x99, 0x9b, 0xcc, 0xf3, 0xf0, 0xff, 0xa8, 0xab, 0x2a, 0x97, 0xa9,
919 0x77, 0xea, 0x3b, 0x64, 0x32, 0xfd, 0x80, 0xf5, 0xb4, 0x6c, 0x21, 0xce, 925 0x3e, 0x73, 0xc9, 0x61, 0xfd, 0x67, 0xbf, 0xf1, 0x12, 0xf2, 0x4e, 0x93,
920 0xd9, 0x05, 0xc1, 0xda, 0x79, 0xe2, 0xfb, 0x2b, 0xe0, 0x0b, 0x70, 0x28, 926 0x4e, 0x34, 0xd9, 0x5f, 0x32, 0x2e, 0xce, 0xfd, 0x77, 0x9b, 0x5f, 0x13,
921 0xff, 0x51, 0x38, 0x77, 0x59, 0x5f, 0xd7, 0x79, 0xc6, 0x63, 0x0c, 0x71, 927 0x9c, 0x23, 0xe0, 0x1d, 0xe6, 0xf5, 0x2f, 0xb1, 0x9c, 0x3b, 0x18, 0x36,
922 0xe1, 0xe2, 0x10, 0x65, 0x40, 0x82, 0x95, 0xca, 0xa6, 0x5d, 0xfd, 0xc3, 928 0x6b, 0x89, 0x60, 0x03, 0x8f, 0x86, 0xcc, 0x5d, 0x82, 0xf7, 0xfb, 0x6f,
923 0xc8, 0x47, 0xfc, 0xfd, 0x56, 0x51, 0x27, 0x0f, 0xe7, 0xc0, 0xcb, 0x4f, 929 0xec, 0xfb, 0x2e, 0x68, 0x1d, 0x02, 0x2c, 0xe2, 0x65, 0xa6, 0x7d, 0x8f,
924 0xc0, 0x7f, 0x3f, 0x70, 0xa2, 0xf6, 0x48, 0x47, 0x74, 0xff, 0x4e, 0xd1, 930 0x57, 0xe4, 0x1e, 0xc7, 0x9b, 0xc8, 0xf3, 0xd6, 0xf6, 0xc0, 0x5c, 0x53,
925 0x7d, 0xad, 0x21, 0xe6, 0x2a, 0x5d, 0xf4, 0xd5, 0x75, 0xc8, 0xdd, 0x07, 931 0xe0, 0x9c, 0x86, 0x94, 0xcb, 0x95, 0x51, 0xe6, 0xef, 0x6d, 0x7d, 0x9c,
926 0x7b, 0xb5, 0xf0, 0xcb, 0xbd, 0xe9, 0x0c, 0xf7, 0x98, 0xeb, 0x22, 0xba, 932 0x63, 0xea, 0xf9, 0xbf, 0x09, 0xa2, 0x5a, 0xf3, 0x95, 0xf9, 0x49, 0xf8,
927 0x11, 0xbf, 0x5c, 0x73, 0x27, 0x1e, 0xee, 0x75, 0x3e, 0xea, 0xd4, 0x03, 933 0xe7, 0x20, 0xa8, 0xee, 0x1e, 0x52, 0x71, 0x68, 0x90, 0xdf, 0x1f, 0x90,
928 0x09, 0x79, 0xf7, 0x44, 0xb4, 0x37, 0x07, 0x64, 0xba, 0x0a, 0xdd, 0xed, 934 0xb2, 0xa8, 0x8a, 0x4e, 0xba, 0xc3, 0xb0, 0x00, 0xcb, 0x73, 0x2f, 0x87,
929 0xea, 0x0f, 0xfc, 0x27, 0x1d, 0xf1, 0x40, 0xde, 0xff, 0x06, 0xbc, 0x07, 935 0x72, 0x84, 0x11, 0x75, 0xa1, 0xdf, 0x8c, 0xf4, 0x32, 0x05, 0x1d, 0xdb,
930 0xb8, 0x5b, 0x0b, 0xcd, 0xba, 0xc3, 0x58, 0x3d, 0xa0, 0x31, 0xb6, 0x0e, 936 0x63, 0x1e, 0x0a, 0x63, 0x32, 0xc7, 0xb4, 0x9f, 0x42, 0xe7, 0xac, 0x14,
931 0x4f, 0x57, 0xf6, 0x44, 0xbe, 0x98, 0x84, 0x5f, 0xed, 0xb6, 0x9e, 0x10, 937 0xeb, 0x4d, 0xaa, 0xef, 0x9a, 0xde, 0xf0, 0xbb, 0xfa, 0x8c, 0x07, 0xda,
932 0xd6, 0x63, 0xc4, 0x9b, 0x94, 0x1f, 0xbe, 0x0c, 0x1e, 0x92, 0xf4, 0x93, 938 0x8a, 0x0b, 0x9d, 0x54, 0xaa, 0x27, 0x90, 0x03, 0x19, 0x34, 0x97, 0xc3,
933 0x7f, 0x5f, 0xe3, 0x27, 0x1c, 0xdb, 0x2a, 0x35, 0xd4, 0xd4, 0x5e, 0xde, 939 0x18, 0x3a, 0x54, 0x6a, 0xb0, 0xce, 0x57, 0x42, 0x9d, 0x4f, 0x86, 0xb8,
934 0x94, 0x69, 0x25, 0x03, 0xda, 0x35, 0xfa, 0x77, 0x29, 0xf4, 0xef, 0x47, 940 0x4f, 0x82, 0x17, 0xb6, 0xb5, 0x2a, 0xb8, 0x76, 0xda, 0x26, 0xeb, 0x5f,
935 0x80, 0xa3, 0x5d, 0x8c, 0x47, 0x1f, 0xc7, 0x59, 0x9d, 0xcd, 0x2c, 0xeb, 941 0x1d, 0xb6, 0x5c, 0xae, 0x71, 0xed, 0x89, 0xfc, 0xdb, 0x3c, 0x37, 0x33,
936 0xcc, 0x03, 0x76, 0x4b, 0x51, 0xdd, 0x4f, 0xdf, 0x8b, 0xee, 0xa2, 0xd8, 942 0xed, 0x18, 0xa0, 0x6b, 0x44, 0x2b, 0xb7, 0x1c, 0xad, 0xec, 0x33, 0x7d,
937 0x94, 0x96, 0x8b, 0x95, 0x28, 0x2e, 0xa5, 0x71, 0x9e, 0xb4, 0xcb, 0xa5, 943 0xbb, 0x41, 0xb7, 0x26, 0x6b, 0xdc, 0xa5, 0xd6, 0x7b, 0xc1, 0xd2, 0xee,
938 0xb9, 0x28, 0xe6, 0xb5, 0xcb, 0x12, 0xf2, 0x9a, 0x95, 0x97, 0x2c, 0x8c, 944 0x4d, 0xe8, 0x43, 0xe7, 0x27, 0x58, 0xae, 0x5f, 0x60, 0xba, 0xac, 0x82,
939 0x25, 0xe5, 0xe2, 0x5c, 0x12, 0x31, 0xab, 0x47, 0x56, 0xe6, 0x7a, 0x30, 945 0x60, 0x3e, 0xa7, 0xe9, 0xd4, 0xf0, 0xdf, 0xf5, 0x72, 0x3e, 0x75, 0x7a,
940 0x96, 0xc2, 0xba, 0x14, 0xe6, 0xdb, 0xb2, 0x52, 0xb1, 0x81, 0x27, 0x87, 946 0x98, 0xf1, 0x83, 0x8e, 0x74, 0x9a, 0x96, 0x7d, 0xde, 0xa3, 0x3e, 0xc3,
941 0x76, 0x0e, 0xed, 0x21, 0xb9, 0xa4, 0xbe, 0x17, 0x30, 0x2f, 0x18, 0x42, 947 0x3c, 0x2c, 0x2f, 0x98, 0xf4, 0x88, 0x94, 0xdb, 0x6b, 0xd2, 0xa6, 0xcb,
942 0xdc, 0x62, 0x5e, 0x30, 0x82, 0x18, 0x32, 0x81, 0x27, 0x8a, 0x5d, 0xa7, 948 0x2b, 0xb0, 0xa5, 0xd4, 0x90, 0x79, 0x94, 0xec, 0xab, 0x17, 0x75, 0xbb,
943 0x66, 0xa6, 0x2a, 0xbc, 0x73, 0x84, 0x0e, 0xac, 0x53, 0x33, 0xd3, 0xb6, 949 0x3e, 0x05, 0x7b, 0x5e, 0x5a, 0xd4, 0x69, 0xa7, 0xac, 0xb1, 0x58, 0x36,
944 0x89, 0xba, 0xed, 0x1b, 0xda, 0x54, 0x83, 0x72, 0x41, 0xb7, 0x43, 0x1d, 950 0xf6, 0x31, 0x58, 0x7c, 0x78, 0xf6, 0x43, 0x6d, 0x67, 0xef, 0xa1, 0x4b,
945 0xa2, 0x3f, 0x4a, 0x9b, 0xe4, 0x79, 0x67, 0x20, 0xc6, 0x77, 0x01, 0x9f, 951 0x4f, 0xff, 0x16, 0x7c, 0x0d, 0xf3, 0xd5, 0xb0, 0x0e, 0x23, 0x9f, 0x58,
946 0x23, 0xfa, 0x6f, 0xd0, 0x17, 0xa0, 0xc3, 0x27, 0xba, 0xe4, 0xd2, 0xcb, 952 0x40, 0xee, 0x51, 0x45, 0x6e, 0x5c, 0xc8, 0x30, 0x6c, 0xc4, 0xef, 0xad,
947 0x8c, 0x35, 0xae, 0xbc, 0x7a, 0x96, 0x3a, 0x2c, 0xf6, 0xac, 0xea, 0x90, 953 0x92, 0xff, 0x42, 0xf2, 0x7f, 0x07, 0x55, 0xa5, 0x0d, 0x65, 0xe4, 0x3b,
948 0x63, 0x0f, 0xe1, 0x8c, 0xd8, 0x0f, 0x7b, 0x32, 0x33, 0x87, 0x90, 0xcb, 954 0x01, 0x1c, 0xea, 0x1d, 0x8f, 0x91, 0x2b, 0xc9, 0x77, 0xf7, 0x2a, 0x38,
949 0x7c, 0x1b, 0xf6, 0x59, 0x66, 0xcd, 0x9d, 0x0e, 0x6a, 0x84, 0x20, 0x06, 955 0xf6, 0x11, 0x19, 0x7e, 0x77, 0x14, 0x7b, 0x32, 0x8f, 0xa3, 0xf9, 0x6e,
950 0xa0, 0xdd, 0x47, 0x5d, 0xb1, 0xdd, 0x07, 0xbb, 0xe3, 0x58, 0x9f, 0x1a, 956 0x52, 0x36, 0x14, 0xf1, 0x1d, 0x89, 0x44, 0x33, 0x4d, 0xbf, 0x8b, 0x9a,
951 0x5b, 0x04, 0x8e, 0x60, 0x8c, 0xed, 0xcd, 0xb2, 0xa8, 0xc6, 0x0e, 0xaa, 957 0x67, 0xb2, 0x39, 0x48, 0xa5, 0xa6, 0x05, 0x19, 0xcc, 0xf4, 0xf1, 0xd9,
952 0xb1, 0xb2, 0xb2, 0x0f, 0x8e, 0x1d, 0x52, 0xb1, 0xe9, 0x7c, 0x23, 0xea, 958 0x8a, 0x2b, 0x38, 0x8f, 0x60, 0x5a, 0xef, 0xa5, 0xc3, 0x7e, 0x44, 0x4f,
953 0xdf, 0x88, 0x58, 0xc2, 0x7e, 0xf6, 0xe5, 0x61, 0xeb, 0x7b, 0x71, 0xae, 959 0x32, 0xa4, 0x6f, 0x32, 0x1c, 0x27, 0x42, 0x1a, 0xda, 0xf1, 0x25, 0x81,
954 0x15, 0x64, 0xa9, 0x81, 0x3a, 0x30, 0xff, 0x7b, 0x98, 0xcb, 0x3d, 0xc8, 960 0x0b, 0x31, 0x3e, 0xf7, 0x57, 0x21, 0x1e, 0xf6, 0x1f, 0xa0, 0x75, 0x32,
955 0x9e, 0x2a, 0xe9, 0xe4, 0xf1, 0x20, 0xce, 0x83, 0xfd, 0x21, 0xad, 0xb6, 961 0x43, 0x2b, 0x3e, 0xd3, 0xb1, 0x85, 0xaa, 0x69, 0xee, 0x1f, 0x80, 0x9e,
956 0x90, 0xaf, 0x03, 0x61, 0xbb, 0x25, 0xa4, 0x4d, 0x3c, 0x36, 0x70, 0x1c, 962 0x31, 0x9e, 0x4d, 0x9c, 0xc7, 0xac, 0xe3, 0xf1, 0x91, 0x66, 0x05, 0x3c,
957 0xc3, 0x5a, 0x17, 0x38, 0x18, 0x63, 0x11, 0x23, 0x52, 0x29, 0xe8, 0x82, 963 0x66, 0xfe, 0xf2, 0xba, 0x24, 0x2d, 0x7d, 0x85, 0xe5, 0xb7, 0x07, 0xf9,
958 0x34, 0xdb, 0xa4, 0xac, 0xde, 0xf7, 0xc3, 0x76, 0xb9, 0x16, 0x3a, 0xb4, 964 0x3b, 0xeb, 0xc2, 0x96, 0x50, 0xaf, 0xd4, 0x9e, 0xa5, 0x85, 0x1e, 0xc8,
959 0xa2, 0x75, 0xa5, 0x70, 0xcf, 0x53, 0xea, 0x9c, 0xd1, 0x93, 0x9b, 0xc3, 965 0x8a, 0xf7, 0xed, 0xa2, 0xbb, 0x61, 0xef, 0xc5, 0x06, 0xef, 0x3f, 0x09,
960 0x9c, 0x10, 0x7a, 0x45, 0x9c, 0xd5, 0x93, 0x8c, 0x37, 0xef, 0x84, 0x76, 966 0x3d, 0x7a, 0x59, 0xee, 0x5f, 0x5a, 0x19, 0x08, 0xe1, 0x19, 0xb6, 0x67,
961 0xda, 0x8b, 0xbe, 0x87, 0x44, 0xef, 0x65, 0xdf, 0x51, 0xe0, 0x61, 0xed, 967 0x03, 0x6c, 0x27, 0xed, 0xab, 0x9b, 0xd7, 0x81, 0xff, 0x7d, 0xc0, 0x0b,
962 0x3c, 0x0c, 0x99, 0xd9, 0xe6, 0xfa, 0x6c, 0xd3, 0xfa, 0xc4, 0x3a, 0xeb, 968 0x3a, 0x99, 0x63, 0x78, 0xc6, 0x83, 0x75, 0x8d, 0xf4, 0x67, 0xe0, 0x49,
963 0x3b, 0x9a, 0xfa, 0x32, 0x52, 0x9b, 0xef, 0x52, 0xf1, 0xf2, 0x7c, 0x18, 969 0xc9, 0x5a, 0xbe, 0xd8, 0xe8, 0xa4, 0x62, 0x3d, 0xc2, 0xc5, 0x78, 0x3e,
964 0x2f, 0x17, 0x6b, 0x94, 0x05, 0x7e, 0x96, 0x7f, 0x5b, 0xe9, 0xa2, 0x76, 970 0x46, 0xad, 0x7b, 0x9f, 0xc4, 0x35, 0x2d, 0x71, 0xe1, 0x7d, 0x83, 0x7d,
965 0x36, 0xb0, 0xf5, 0xa5, 0x93, 0x3c, 0x17, 0x57, 0xe7, 0xd5, 0xd4, 0xbc, 971 0xcd, 0xad, 0x80, 0x47, 0xbd, 0xee, 0x80, 0xb6, 0x54, 0x37, 0x2d, 0xc9,
966 0xdf, 0x06, 0xff, 0xba, 0x1c, 0x55, 0x32, 0x70, 0x3e, 0xe6, 0xd5, 0x02, 972 0x7a, 0xbd, 0x4b, 0xf9, 0x98, 0xd4, 0x66, 0xbc, 0xdf, 0x02, 0x5b, 0xdf,
967 0xbf, 0x31, 0x6c, 0xce, 0xa1, 0x8f, 0x44, 0x6b, 0x38, 0xff, 0xe7, 0xa8, 973 0x83, 0x3c, 0xa6, 0x07, 0x73, 0xd6, 0x86, 0xb9, 0x8d, 0xf4, 0x27, 0x36,
968 0x55, 0xbe, 0xac, 0xd6, 0xac, 0xfa, 0x0c, 0xf9, 0x71, 0x42, 0x9e, 0x7b, 974 0xd0, 0xdf, 0x89, 0x75, 0xfd, 0xd8, 0x53, 0xad, 0x2b, 0x61, 0xdd, 0xec,
969 0xc0, 0x5f, 0x67, 0x28, 0x43, 0x7b, 0x28, 0x03, 0xf1, 0xfd, 0x27, 0x70, 975 0x02, 0x6c, 0x82, 0x73, 0xf3, 0x34, 0xc7, 0xe4, 0x1b, 0x25, 0x2d, 0xb3,
970 0xb7, 0x61, 0x1e, 0x79, 0xdd, 0x86, 0x3e, 0xbe, 0xff, 0x17, 0xfa, 0x76, 976 0x2b, 0xef, 0xe1, 0x5c, 0x03, 0x80, 0x8d, 0xc6, 0x8a, 0x0f, 0x75, 0xe0,
971 0x23, 0xff, 0x23, 0x6f, 0x89, 0x26, 0xde, 0xfe, 0x03, 0x63, 0x3d, 0x4a, 977 0xf9, 0x5e, 0x43, 0xde, 0x4b, 0x40, 0x06, 0x9b, 0x53, 0x7c, 0xf6, 0x6a,
972 0xb7, 0x35, 0xd4, 0x26, 0x53, 0xbc, 0xef, 0x48, 0xe1, 0x1c, 0x38, 0xb9, 978 0xe3, 0xf3, 0x78, 0x76, 0x63, 0x1b, 0xbf, 0x98, 0x57, 0x4c, 0x2f, 0xd3,
973 0x4d, 0xd1, 0xad, 0x9d, 0xbd, 0x86, 0xf1, 0x5e, 0xac, 0x89, 0xda, 0xcd, 979 0x0a, 0x3d, 0x25, 0xd8, 0x9b, 0x8b, 0x9a, 0x2f, 0xa5, 0x53, 0x29, 0x87,
974 0xb2, 0xe9, 0x58, 0xfb, 0x53, 0x25, 0xcf, 0x62, 0xed, 0x4e, 0xf2, 0x6f, 980 0x78, 0xee, 0xf3, 0x5d, 0x2d, 0xdb, 0xe5, 0xa0, 0xaa, 0x0b, 0x1c, 0x8e,
975 0x5b, 0x23, 0x3b, 0xe5, 0x26, 0x4f, 0xe4, 0xa7, 0x1f, 0x4f, 0x2b, 0x72, 981 0xeb, 0x86, 0x3c, 0xfb, 0xe1, 0x15, 0xbe, 0xaf, 0xb5, 0x10, 0x4f, 0xed,
976 0x21, 0xd8, 0x6d, 0xd2, 0x90, 0xd1, 0x7c, 0x9a, 0xdf, 0xf9, 0x12, 0xbc, 982 0x2c, 0xe1, 0xec, 0x0f, 0xaf, 0x38, 0xf4, 0x68, 0x33, 0x4b, 0x47, 0x9b,
977 0x17, 0x1d, 0x19, 0xe4, 0x9e, 0xa1, 0xdd, 0x60, 0x4e, 0x47, 0x7f, 0x4b, 983 0xb6, 0x79, 0x3f, 0x7c, 0x40, 0x79, 0xed, 0x1e, 0x77, 0x57, 0x8a, 0xfd,
978 0xc8, 0x31, 0xd4, 0x24, 0xe5, 0x85, 0x8c, 0x56, 0x3c, 0x99, 0x45, 0x16, 984 0x96, 0x81, 0x9c, 0xb3, 0xc3, 0x51, 0x39, 0x48, 0x95, 0xeb, 0xb1, 0x05,
979 0xad, 0xbe, 0xd5, 0xc9, 0x8b, 0x4b, 0xb6, 0x7c, 0x1b, 0x7e, 0x7a, 0xb2, 985 0x9b, 0xef, 0x68, 0xcc, 0x06, 0x6d, 0xcc, 0x53, 0xfe, 0x2f, 0x73, 0x14,
980 0x9e, 0x4d, 0x7f, 0x13, 0xf9, 0xc1, 0x91, 0x25, 0xe6, 0x13, 0x3d, 0x29, 986 0xde, 0x9f, 0xfd, 0x34, 0x72, 0x12, 0x1f, 0x39, 0x89, 0x8f, 0x9c, 0xc4,
981 0x65, 0x9b, 0xf3, 0x9a, 0x6c, 0x60, 0x4c, 0x9b, 0x47, 0x7e, 0x6a, 0xdd, 987 0x47, 0x4e, 0xe2, 0x23, 0x27, 0xf1, 0x91, 0x93, 0xf8, 0xc8, 0x49, 0x7c,
982 0x2d, 0x47, 0x82, 0x9f, 0x57, 0xd7, 0xc6, 0x0c, 0xca, 0xb1, 0x36, 0x66, 988 0xe4, 0x24, 0xc8, 0xff, 0x55, 0x5d, 0x30, 0x8e, 0x5c, 0x1b, 0xfe, 0xcb,
983 0x10, 0x0f, 0x63, 0xc6, 0x4e, 0xec, 0x13, 0x63, 0x06, 0xf6, 0xff, 0x24, 989 0xff, 0x6a, 0x98, 0x53, 0x44, 0x31, 0x99, 0xe7, 0x56, 0x37, 0x79, 0x6e,
984 0x63, 0x86, 0x8d, 0x75, 0x8c, 0x19, 0x79, 0x59, 0xac, 0x32, 0x66, 0xec, 990 0x74, 0x4f, 0x7c, 0x00, 0x73, 0x13, 0x61, 0xee, 0xc3, 0x6b, 0xa2, 0x98,
985 0x45, 0x9b, 0x31, 0xa3, 0x80, 0x76, 0x10, 0x2f, 0x16, 0x55, 0xbc, 0xc8, 991 0xcd, 0xeb, 0x68, 0xcc, 0x43, 0xbd, 0x59, 0x98, 0xe4, 0xdc, 0x48, 0xc5,
986 0x5a, 0xcb, 0xc2, 0x38, 0x81, 0x3c, 0xb1, 0x8a, 0x3c, 0xb1, 0x8a, 0x3c, 992 0x2a, 0x95, 0x97, 0xbf, 0x8a, 0xfc, 0xc8, 0x42, 0x7e, 0x34, 0x88, 0x5c,
987 0xb1, 0x8a, 0x3c, 0xb1, 0x8a, 0x3c, 0x11, 0xb6, 0xfe, 0x5a, 0x15, 0x79, 993 0x88, 0xef, 0xb5, 0xa3, 0xfb, 0xa3, 0x82, 0x76, 0xc8, 0x1f, 0xd7, 0xbe,
988 0x22, 0xfc, 0xe7, 0x3c, 0x72, 0x92, 0xa0, 0xa6, 0x38, 0x8c, 0x9a, 0xc2, 994 0xe6, 0x73, 0xde, 0xee, 0x58, 0x65, 0x21, 0x16, 0xfa, 0x29, 0xa0, 0xe2,
989 0xd5, 0xc6, 0xaa, 0xe3, 0xda, 0xbe, 0x2a, 0x6a, 0x43, 0xf5, 0x9d, 0x58, 995 0xe8, 0xb7, 0x90, 0x23, 0x7f, 0x4f, 0xde, 0x95, 0x4d, 0x0c, 0xb3, 0xcc,
990 0x1f, 0xda, 0x80, 0xba, 0xa8, 0xe6, 0x6c, 0x01, 0x5f, 0xd7, 0xe0, 0x1b, 996 0x27, 0x3e, 0x25, 0x4f, 0x8e, 0xf8, 0xab, 0xee, 0xf8, 0xc4, 0x12, 0xf3,
991 0xd4, 0xd3, 0x56, 0x99, 0xca, 0xed, 0x80, 0x7c, 0xd8, 0x7f, 0xfb, 0xfb, 997 0x8f, 0xa8, 0xef, 0x2c, 0x18, 0x7e, 0x36, 0x41, 0xa9, 0x53, 0x5b, 0x30,
992 0xe8, 0x43, 0x3e, 0x9f, 0x63, 0x0d, 0xc2, 0x78, 0xb5, 0x0f, 0x6d, 0x1d, 998 0x67, 0x52, 0xbf, 0xbc, 0x27, 0x82, 0x28, 0xcf, 0xfe, 0x1a, 0xf2, 0x72,
993 0x6d, 0xec, 0xe9, 0x04, 0x7c, 0xc4, 0x7e, 0x90, 0xf9, 0x62, 0x7a, 0x41, 999 0x48, 0x9c, 0xe5, 0xdb, 0x04, 0xc6, 0xcb, 0xfe, 0xb5, 0x32, 0x53, 0x6c,
994 0x9e, 0xdc, 0x1c, 0xd8, 0xf4, 0x6f, 0x31, 0x27, 0x5e, 0xd3, 0xde, 0x88, 1000 0x54, 0xa4, 0x4e, 0x1d, 0x6a, 0x96, 0x90, 0x3f, 0xf5, 0xf6, 0x53, 0x97,
995 0x39, 0xf0, 0x17, 0xd8, 0x97, 0x5a, 0x03, 0x5c, 0xba, 0xfd, 0xe7, 0xc4, 1001 0x81, 0x1a, 0x2a, 0xc2, 0xcd, 0x38, 0x7f, 0x99, 0x92, 0xb5, 0xcd, 0xd9,
996 0xd1, 0xb7, 0xe1, 0xd6, 0x1c, 0xda, 0xd5, 0xf7, 0x9a, 0xfa, 0xb2, 0x98, 1002 0x35, 0x79, 0x42, 0xd6, 0xbc, 0x4f, 0x65, 0xa6, 0x5a, 0xb7, 0x33, 0x5c,
997 0xcf, 0xef, 0xe2, 0x3b, 0xf0, 0xfb, 0x16, 0x7e, 0x61, 0x77, 0xf6, 0x05, 1003 0xd7, 0x82, 0xd6, 0x99, 0x27, 0x81, 0x63, 0x19, 0x39, 0x81, 0x2e, 0xf7,
998 0xcc, 0xe9, 0xc3, 0xef, 0x77, 0x9a, 0xe6, 0x42, 0x0a, 0xfb, 0x2f, 0xd1, 1004 0xae, 0xcc, 0xcc, 0xd6, 0xd5, 0x5d, 0x95, 0xa2, 0x01, 0xf1, 0x2f, 0xd7,
999 0x77, 0x31, 0xa4, 0xc1, 0x6f, 0x89, 0x5f, 0x6a, 0xe2, 0xe3, 0x07, 0xe8, 1005 0x45, 0xfa, 0x92, 0xba, 0xb3, 0x12, 0x12, 0x96, 0xe1, 0x18, 0xde, 0x00,
1000 0xfb, 0x6b, 0xf4, 0xf9, 0xfe, 0xdb, 0x4e, 0xd4, 0x27, 0xa5, 0x96, 0x70, 1006 0x1c, 0xcb, 0x2d, 0x0b, 0x58, 0x96, 0x1d, 0xd3, 0x50, 0x99, 0xa9, 0x34,
1001 0xef, 0x46, 0xd5, 0xde, 0x69, 0xca, 0xe6, 0x8f, 0x2c, 0xe9, 0xaa, 0x0e, 1007 0xda, 0x69, 0x60, 0x3c, 0x8c, 0x37, 0x3a, 0x0f, 0x9f, 0x25, 0x45, 0xe2,
1002 0x7a, 0xae, 0x8e, 0xea, 0x08, 0x71, 0xbe, 0xbc, 0x10, 0xd4, 0xad, 0xc7, 1008 0x54, 0x10, 0x94, 0x47, 0x07, 0xc3, 0x3a, 0x12, 0xf5, 0xe3, 0x09, 0x43,
1003 0x51, 0x73, 0x16, 0xab, 0xb4, 0x91, 0x1c, 0xfa, 0x6d, 0x9c, 0x69, 0x32, 1009 0xea, 0xb9, 0x1a, 0x7f, 0x53, 0xc6, 0x29, 0x4b, 0xf0, 0x3c, 0x3f, 0xf1,
1004 0x69, 0xdc, 0xaa, 0x63, 0x13, 0x89, 0xc9, 0x7a, 0x9b, 0x48, 0x37, 0x69, 1010 0x2e, 0xf7, 0x24, 0xe6, 0x30, 0x5e, 0x8e, 0xd6, 0x8a, 0x70, 0x6d, 0x77,
1005 0x32, 0x4f, 0x22, 0x8e, 0xd9, 0x99, 0xe2, 0xc2, 0xec, 0x8c, 0x07, 0x9c, 1011 0x1b, 0x3f, 0x3b, 0xc2, 0xfd, 0x98, 0x26, 0x3e, 0xe7, 0x65, 0xec, 0xc5,
1006 0x63, 0x75, 0xae, 0xe5, 0x3c, 0x93, 0xf7, 0x63, 0x4d, 0x74, 0x69, 0x13, 1012 0x74, 0xf1, 0x1a, 0x13, 0xb4, 0x41, 0x96, 0xfe, 0xff, 0x96, 0xf7, 0xed,
1007 0x60, 0x06, 0xf4, 0x9e, 0xab, 0x93, 0x7e, 0x40, 0xb3, 0xac, 0x68, 0xda, 1013 0x67, 0x62, 0x9e, 0x1a, 0x80, 0xe1, 0xf5, 0x8c, 0x23, 0x82, 0xc1, 0x8b,
1008 0xe8, 0x8f, 0xea, 0xc7, 0x1c, 0x6a, 0x5d, 0x99, 0x64, 0xed, 0x5c, 0x0c, 1014 0xb3, 0x0a, 0x4e, 0xac, 0xdd, 0xed, 0x7d, 0xd6, 0xbe, 0xed, 0xb4, 0x46,
1009 0x69, 0xba, 0x75, 0x49, 0x24, 0x0a, 0xcd, 0xf8, 0x82, 0x8c, 0xf3, 0xb9, 1015 0xfb, 0x47, 0x78, 0xb2, 0x4a, 0x6e, 0x6b, 0xf0, 0xf2, 0xff, 0x0a, 0xc3,
1010 0xfa, 0xec, 0x8c, 0xfe, 0x42, 0x36, 0xc7, 0x3b, 0x11, 0xd7, 0x9a, 0x9d, 1016 0x13, 0xba, 0xf8, 0x89, 0x3b, 0xd2, 0x6c, 0x5b, 0x6d, 0x1c, 0xdd, 0x35,
1011 0x69, 0x1d, 0x48, 0xc8, 0x8f, 0x91, 0xbb, 0x1d, 0x53, 0x34, 0x66, 0x67, 1017 0x70, 0xcd, 0xcf, 0x35, 0x3c, 0x7f, 0x47, 0x68, 0xaf, 0x4b, 0x4b, 0x61,
1012 0x8c, 0x17, 0x02, 0x5b, 0x0c, 0xe8, 0xe0, 0x3c, 0xc9, 0xb7, 0x43, 0x4e, 1018 0x2c, 0x83, 0x2e, 0xaa, 0xbb, 0xd4, 0x70, 0x6c, 0x70, 0x6c, 0x43, 0xe3,
1013 0xd2, 0x62, 0x4d, 0x1d, 0x8c, 0x4f, 0xaa, 0x7a, 0xd1, 0x94, 0x2b, 0x15, 1019 0x1c, 0x3f, 0xb2, 0x91, 0xf6, 0x7b, 0x42, 0x95, 0x9b, 0x9c, 0x59, 0x8c,
1014 0x45, 0x3b, 0xac, 0xdb, 0xc9, 0xc3, 0xec, 0x8c, 0xfc, 0xd1, 0x2d, 0x1e, 1020 0x7c, 0x0e, 0xfc, 0xc1, 0xb0, 0x11, 0xfa, 0xed, 0x24, 0xfc, 0x56, 0x0f,
1015 0xd6, 0x91, 0x87, 0x78, 0x49, 0x27, 0xd0, 0x5b, 0xc0, 0x7f, 0x12, 0xf5, 1021 0xed, 0x83, 0xbf, 0xb9, 0x13, 0xfe, 0x66, 0x3f, 0xea, 0xca, 0xf1, 0x95,
1016 0x7b, 0x54, 0xab, 0xfb, 0xfe, 0x8a, 0x93, 0x43, 0x5c, 0xe0, 0x3e, 0xb6, 1022 0xf6, 0xfb, 0x57, 0xae, 0x65, 0xab, 0x74, 0x58, 0xca, 0xae, 0x12, 0xe8,
1017 0xa8, 0x3c, 0xd7, 0x73, 0x32, 0xbc, 0xef, 0x9b, 0xe3, 0xdf, 0x39, 0x78, 1023 0xce, 0xc7, 0x90, 0xdf, 0x2e, 0x99, 0xa3, 0x29, 0x79, 0xc2, 0x57, 0xba,
1018 0xf9, 0x01, 0xd4, 0x4d, 0xbc, 0x1b, 0xa4, 0x7f, 0xe1, 0xf7, 0x36, 0xff, 1024 0xfc, 0x2d, 0x62, 0xe3, 0x3d, 0x6f, 0x16, 0x7a, 0xdd, 0x55, 0x10, 0x32,
1019 0xe2, 0x7c, 0xf6, 0x93, 0xe7, 0x81, 0xf4, 0x55, 0xf0, 0xe7, 0xe5, 0xd1, 1025 0xff, 0x52, 0x7c, 0xab, 0x36, 0x14, 0xdf, 0xe0, 0x53, 0x81, 0xdf, 0xa0,
1020 0x87, 0x58, 0x51, 0x6c, 0x44, 0xb8, 0x78, 0xc7, 0xce, 0x39, 0x2a, 0xff, 1026 0x4a, 0xd3, 0xa4, 0x0a, 0xf6, 0xad, 0x60, 0xdf, 0x0a, 0xea, 0xc1, 0xd9,
1021 0x6e, 0xf2, 0xd1, 0x96, 0xf0, 0xdc, 0xa5, 0x8e, 0xc8, 0x27, 0xf9, 0xe9, 1027 0x66, 0xfb, 0x77, 0xaa, 0xee, 0xb0, 0xc6, 0x66, 0xd8, 0xa8, 0x6f, 0x86,
1022 0x84, 0x4d, 0x90, 0x17, 0xce, 0x8f, 0xee, 0x25, 0xd8, 0xfe, 0xb8, 0x36, 1028 0xe7, 0xd2, 0xda, 0x9e, 0xc7, 0xc0, 0xbb, 0x47, 0xc1, 0xbb, 0x23, 0xa8,
1023 0x12, 0xdd, 0xa9, 0x7d, 0x9c, 0x3d, 0x8f, 0x74, 0x76, 0x37, 0x7e, 0x88, 1029 0x83, 0xfe, 0x04, 0x75, 0xd0, 0x1f, 0xa2, 0x0e, 0x3a, 0x8c, 0x3a, 0x68,
1024 0x83, 0xb4, 0x23, 0xbe, 0x22, 0x9e, 0x88, 0x8f, 0xfc, 0x44, 0xbc, 0x28, 1030 0x0a, 0x75, 0xd0, 0x7d, 0xb0, 0xfd, 0x7b, 0x61, 0xfb, 0x93, 0xb0, 0xfd,
1025 0x1b, 0x5d, 0x97, 0x9f, 0x60, 0x5d, 0xc0, 0x4f, 0x69, 0x21, 0x0d, 0x9d, 1031 0x09, 0x79, 0xc7, 0x73, 0xc8, 0xdf, 0x78, 0xef, 0x11, 0xed, 0xc5, 0xed,
1026 0x90, 0xa7, 0x11, 0x6d, 0xa4, 0xba, 0xde, 0x1d, 0xc7, 0x0f, 0x5c, 0xc6, 1032 0x4d, 0x22, 0x88, 0xaf, 0x7c, 0x62, 0x9c, 0x1a, 0x2d, 0xae, 0x87, 0x5c,
1027 0xd5, 0xb1, 0x06, 0xef, 0xa1, 0x48, 0x97, 0x7f, 0x3b, 0xb2, 0xa4, 0x8d, 1033 0x79, 0x7f, 0x35, 0xed, 0x4e, 0x6a, 0x53, 0xc8, 0xb9, 0xef, 0x1f, 0xe1,
1028 0x34, 0xf8, 0x9d, 0xa9, 0xae, 0xb9, 0x8d, 0x88, 0xde, 0x5a, 0x9d, 0x46, 1034 0x3a, 0x29, 0xa5, 0xee, 0x2b, 0x73, 0xf6, 0x73, 0x1e, 0xd2, 0x2e, 0xe4,
1029 0xbf, 0xbc, 0x2b, 0xff, 0x0c, 0xf6, 0xa9, 0x3b, 0xf8, 0xbb, 0x14, 0x55, 1035 0x6d, 0x38, 0xb3, 0x7d, 0xa6, 0xa8, 0x47, 0x35, 0x4a, 0xdf, 0x5a, 0x8d,
1030 0x47, 0xb1, 0x6f, 0xb9, 0xd5, 0x73, 0xa2, 0xbf, 0xd3, 0xd9, 0x1f, 0xe6, 1036 0xb2, 0x3c, 0xcf, 0x35, 0xca, 0xab, 0x6b, 0x35, 0xca, 0xf2, 0x3c, 0xd7,
1031 0x43, 0x51, 0x6d, 0x1c, 0xd5, 0x59, 0xea, 0x9e, 0x7d, 0xaf, 0xe7, 0x68, 1037 0x28, 0xaf, 0xac, 0xab, 0x51, 0xae, 0x3c, 0xfd, 0xf2, 0xba, 0x1a, 0xe5,
1032 0xc8, 0x4f, 0x99, 0x33, 0x05, 0x3a, 0x08, 0xf1, 0xde, 0x91, 0xcf, 0x91, 1038 0xca, 0xd3, 0x2f, 0x85, 0x63, 0xa6, 0x03, 0x7e, 0xc9, 0x0d, 0x69, 0x35,
1033 0x26, 0x3e, 0x47, 0xc1, 0xe7, 0x3e, 0xf0, 0x39, 0x76, 0x8b, 0xcf, 0x5b, 1039 0x5d, 0x3c, 0x7b, 0xc3, 0x7c, 0xe1, 0xfb, 0xfd, 0xeb, 0xff, 0x1f, 0x3a,
1034 0xb6, 0x97, 0x29, 0xc3, 0xf6, 0x46, 0xd6, 0xb5, 0xbd, 0x55, 0x3a, 0xab, 1040 0x6e, 0x9d, 0x1a, 0x39, 0xdf, 0xd8, 0xaa, 0xea, 0x9a, 0xf6, 0xf9, 0xde,
1035 0x73, 0x83, 0xfb, 0x9a, 0x91, 0x86, 0x2f, 0xc7, 0x9d, 0x8f, 0x53, 0x37, 1041 0xb6, 0xf9, 0x55, 0xf9, 0x6d, 0xb4, 0x5c, 0xdb, 0xfc, 0x3e, 0xbc, 0x27,
1036 0xb7, 0xcb, 0x99, 0x85, 0xbb, 0xd5, 0xb7, 0x11, 0xaf, 0x2a, 0x77, 0x94, 1042 0xad, 0x0c, 0xdb, 0xf5, 0x02, 0x7d, 0x1c, 0xf0, 0xf7, 0x3d, 0x4f, 0x74,
1037 0x4b, 0xf5, 0x80, 0x9f, 0x1f, 0x2f, 0xb1, 0x3d, 0x12, 0xea, 0x8a, 0x3a, 1043 0xc9, 0xef, 0x6a, 0x9e, 0xcc, 0x91, 0x61, 0xa3, 0xa3, 0x47, 0xb7, 0x2a,
1038 0xcb, 0x3a, 0x25, 0xb9, 0x1b, 0x2f, 0xbf, 0xf8, 0x9c, 0x76, 0xa5, 0x12, 1044 0x3b, 0xe6, 0x7e, 0x5a, 0x53, 0xbe, 0xf9, 0x41, 0xe0, 0x01, 0xaf, 0x7d,
1039 0x9d, 0x4f, 0x5a, 0x78, 0xc6, 0xae, 0xe5, 0x29, 0xfa, 0x6e, 0x32, 0x66, 1045 0x43, 0xde, 0xe1, 0xa8, 0xf3, 0xaa, 0xbb, 0x6c, 0x23, 0xbf, 0x8a, 0x38,
1040 0x45, 0xf7, 0x67, 0x22, 0xfc, 0xfe, 0xc0, 0xef, 0x75, 0x6b, 0xbf, 0x13, 1046 0x03, 0x59, 0x4b, 0xdc, 0x5c, 0xf3, 0x71, 0x9d, 0x18, 0xf9, 0xef, 0x08,
1041 0xf0, 0x7c, 0x8a, 0x78, 0xd7, 0x53, 0x3c, 0x9f, 0xc6, 0x9c, 0x66, 0x19, 1047 0xd7, 0xcf, 0xd2, 0x8a, 0xee, 0xdb, 0x50, 0xef, 0xf1, 0x9a, 0x68, 0xdc,
1042 0x5c, 0xd8, 0xa4, 0x9e, 0xe4, 0x98, 0xe7, 0xd0, 0x2f, 0x4c, 0xd0, 0x0c, 1048 0x5e, 0x1f, 0x26, 0xc3, 0xfb, 0xac, 0x55, 0x95, 0x13, 0x49, 0x7c, 0x46,
1043 0xee, 0xdd, 0x6a, 0x4b, 0xbe, 0x5c, 0x74, 0x36, 0x06, 0xe7, 0x28, 0x64, 1049 0x88, 0xef, 0xbf, 0x02, 0xe5, 0x37, 0x18, 0xde, 0x6c, 0x83, 0x1f, 0x47,
1044 0xba, 0x6c, 0xf1, 0xfe, 0x0a, 0x31, 0x8c, 0x67, 0x83, 0xb2, 0xb5, 0x16, 1050 0x9e, 0xc6, 0x77, 0x2b, 0x9c, 0x6f, 0x19, 0xf4, 0xee, 0x7c, 0x37, 0xbd,
1045 0xf5, 0x5c, 0x39, 0xd0, 0x0e, 0x1d, 0xb3, 0xdd, 0xd6, 0xcb, 0xfb, 0x0a, 1051 0x73, 0x1c, 0xf9, 0xa6, 0x6b, 0x67, 0x5f, 0x46, 0xbd, 0x70, 0x8a, 0xf3,
1046 0xca, 0xbc, 0xa0, 0xf6, 0x21, 0xd2, 0x71, 0xf4, 0x7d, 0xae, 0x55, 0x96, 1052 0xe2, 0x51, 0xa6, 0x73, 0xc8, 0x9a, 0x25, 0xab, 0x5f, 0xe5, 0xd1, 0x47,
1047 0xc3, 0xbb, 0xad, 0xc5, 0x8a, 0xef, 0xbf, 0x83, 0x3c, 0xfc, 0x34, 0x74, 1053 0xb4, 0x4f, 0xd2, 0x2d, 0xc2, 0x7d, 0x7e, 0xd6, 0xb6, 0x8f, 0xd5, 0xb6,
1048 0x5f, 0xae, 0xff, 0xcc, 0x5f, 0x4e, 0xf1, 0x6f, 0xa5, 0x22, 0x9b, 0xd8, 1054 0x4f, 0x81, 0xed, 0xad, 0xf1, 0x75, 0x9c, 0xb9, 0xb2, 0xfd, 0x26, 0x33,
1049 0xd1, 0xcb, 0x7b, 0x20, 0xf8, 0x96, 0x1c, 0xaf, 0x87, 0x65, 0xbf, 0x70, 1055 0x1d, 0xd6, 0x52, 0x8f, 0x8c, 0x6e, 0xa6, 0xfa, 0x80, 0x7d, 0xee, 0x15,
1050 0x9c, 0x7d, 0xff, 0x0d, 0xbe, 0x7d, 0xff, 0xf4, 0xaa, 0x9d, 0x02, 0xfe, 1056 0xe4, 0xda, 0xe5, 0x51, 0xcc, 0xa5, 0x87, 0xf0, 0x8e, 0xe7, 0xed, 0x06,
1051 0x17, 0x33, 0xe1, 0x9b, 0xdd, 0x90, 0x58, 0x00, 0x00, 0x00 }; 1057 0x09, 0xfb, 0x5c, 0x83, 0x90, 0x4c, 0x77, 0xd9, 0x15, 0xbe, 0x63, 0x4b,
1058 0x0b, 0xee, 0x4b, 0xda, 0x1a, 0xa1, 0xfd, 0x66, 0x2e, 0xe2, 0xcc, 0x53,
1059 0xa8, 0x99, 0x8e, 0xa8, 0xbb, 0xaf, 0x70, 0x9f, 0x5b, 0xb4, 0x8b, 0x32,
1060 0xaf, 0xcd, 0x69, 0x95, 0xb4, 0x3a, 0xe3, 0x37, 0x60, 0xeb, 0xba, 0x60,
1061 0xd8, 0x77, 0x81, 0x5b, 0xa3, 0xa5, 0xe3, 0xba, 0xbc, 0xeb, 0x2c, 0x8f,
1062 0xb2, 0xac, 0xf9, 0x79, 0x3d, 0xde, 0x45, 0x67, 0xfa, 0xdb, 0xf0, 0x4c,
1063 0x5f, 0x0a, 0x6b, 0xed, 0xe8, 0x4c, 0x09, 0x7a, 0x63, 0xde, 0x04, 0xec,
1064 0x08, 0xf8, 0x51, 0xa2, 0x95, 0x96, 0xf5, 0x39, 0x78, 0x6a, 0x6d, 0xbc,
1065 0x31, 0x36, 0xc8, 0x30, 0xaa, 0x59, 0xc0, 0x83, 0x89, 0x0c, 0xec, 0x70,
1066 0xba, 0x3f, 0xba, 0x83, 0xd5, 0x1d, 0xa1, 0xa9, 0xda, 0x9b, 0xe7, 0x07,
1067 0x61, 0x8b, 0x16, 0xec, 0x93, 0xf3, 0x9d, 0x12, 0xd7, 0x19, 0xe1, 0xf7,
1068 0x4b, 0xdb, 0x9c, 0xa4, 0x2c, 0x6a, 0x15, 0x3e, 0x7f, 0x9e, 0x96, 0x5b,
1069 0x11, 0x0d, 0x39, 0xd8, 0xe3, 0x18, 0x7e, 0x23, 0x78, 0xe7, 0xe2, 0xc7,
1070 0x75, 0x4e, 0x81, 0x1e, 0x93, 0x79, 0x34, 0xf2, 0xe4, 0x61, 0xa6, 0xef,
1071 0x00, 0xd6, 0xb3, 0x3e, 0xb3, 0x9e, 0x1e, 0x20, 0x6f, 0x80, 0x7d, 0x45,
1072 0x06, 0xb8, 0x01, 0xe3, 0xbf, 0x0e, 0x5b, 0x1f, 0xc4, 0xd3, 0x36, 0xcb,
1073 0xcc, 0x5b, 0x89, 0x3f, 0x08, 0xf4, 0x1c, 0x7f, 0x3b, 0x18, 0x0f, 0xc7,
1074 0x43, 0xe6, 0xdd, 0xac, 0x7b, 0x99, 0x1d, 0x74, 0x6e, 0x31, 0x8a, 0x61,
1075 0x33, 0xb0, 0x41, 0xbe, 0x53, 0x1d, 0x07, 0x5f, 0x78, 0xac, 0x85, 0xb1,
1076 0x0c, 0xf3, 0xcb, 0x0b, 0x38, 0x77, 0x9e, 0x4e, 0xa1, 0x66, 0xa7, 0x01,
1077 0x7e, 0x22, 0x57, 0xf5, 0xb7, 0x84, 0xfa, 0xbe, 0x1e, 0x5e, 0x77, 0xb8,
1078 0x3f, 0x0e, 0xfa, 0x8c, 0x36, 0x78, 0x86, 0x51, 0xb5, 0xc5, 0x45, 0x42,
1079 0x2c, 0xcd, 0x04, 0xb7, 0x8b, 0xfc, 0x7d, 0xf4, 0x80, 0x3c, 0x53, 0x9e,
1080 0x0e, 0x2f, 0x06, 0x81, 0x97, 0x1b, 0xca, 0x2e, 0x93, 0x9d, 0x7d, 0x92,
1081 0xf6, 0x98, 0xfb, 0x48, 0x97, 0xdf, 0xe0, 0x50, 0x13, 0xdf, 0xde, 0x91,
1082 0x0f, 0x82, 0x93, 0xa0, 0xfd, 0x05, 0xb9, 0xcf, 0x7d, 0xa0, 0x1f, 0xbc,
1083 0x92, 0xf5, 0x04, 0xd3, 0x0a, 0xde, 0xa4, 0x99, 0xde, 0x24, 0x1d, 0x6e,
1084 0x9d, 0x0f, 0x65, 0xf3, 0x28, 0x79, 0xfe, 0xdb, 0x3a, 0xdf, 0x47, 0x97,
1085 0x5b, 0x4f, 0x86, 0xb4, 0xe5, 0x41, 0x2f, 0xf6, 0x6f, 0xbd, 0x90, 0x66,
1086 0xdf, 0xc0, 0x32, 0xf7, 0x90, 0xf1, 0x79, 0xa3, 0xcf, 0x40, 0x07, 0x3f,
1087 0xcd, 0x0f, 0xa4, 0x68, 0xbd, 0x1f, 0x60, 0xb8, 0xd4, 0x75, 0x74, 0x85,
1088 0xe9, 0x20, 0xe9, 0x3f, 0x85, 0xb3, 0x19, 0xf4, 0x30, 0x3e, 0x7d, 0x83,
1089 0x2f, 0xa8, 0xc8, 0xe7, 0xaa, 0xce, 0xbe, 0x89, 0xe3, 0x14, 0xeb, 0x70,
1090 0x0f, 0xfc, 0x1f, 0x74, 0x10, 0x76, 0x5c, 0x5c, 0xe4, 0x3b, 0x85, 0x61,
1091 0xbe, 0x87, 0x3a, 0x53, 0x82, 0x6c, 0x97, 0xf8, 0xbb, 0x60, 0x5a, 0xe5,
1092 0x82, 0xaa, 0x76, 0xb2, 0xd8, 0x17, 0x32, 0xaf, 0xa5, 0x9f, 0x2c, 0xc9,
1093 0xef, 0x80, 0x29, 0xac, 0x09, 0xf0, 0x6c, 0xff, 0x9b, 0x88, 0x9f, 0x14,
1094 0xd4, 0xdf, 0x44, 0x84, 0xdf, 0x64, 0x1b, 0x2a, 0x07, 0x78, 0xb8, 0x69,
1095 0xd0, 0x54, 0x33, 0xfa, 0x1b, 0x09, 0x96, 0x83, 0x83, 0x3a, 0x3e, 0x8a,
1096 0xfb, 0x81, 0x8c, 0x2f, 0xd5, 0x75, 0xb2, 0xfc, 0x66, 0x98, 0xcf, 0x70,
1097 0xfe, 0xce, 0x3c, 0xc4, 0x78, 0x59, 0xc9, 0x6f, 0x49, 0xec, 0x84, 0xfc,
1098 0xc0, 0x73, 0xdf, 0x80, 0x2d, 0x65, 0xc2, 0x98, 0x6c, 0x72, 0x7d, 0x18,
1099 0xd6, 0xac, 0xdb, 0xa9, 0x3a, 0xc9, 0xef, 0x13, 0xf4, 0xfa, 0xfc, 0xa0,
1100 0x7c, 0x5f, 0xa6, 0x44, 0xf8, 0x9e, 0xc7, 0x29, 0x2a, 0xcb, 0xf7, 0xf7,
1101 0x86, 0xf8, 0x50, 0x63, 0xdd, 0x1b, 0x8d, 0x33, 0x90, 0xa3, 0x82, 0x9b,
1102 0x46, 0x2c, 0x7b, 0x0c, 0x71, 0x6c, 0x1a, 0x7c, 0x2f, 0x4e, 0x54, 0x68,
1103 0x87, 0xc3, 0x3a, 0x0e, 0x99, 0xa5, 0x58, 0xc7, 0x58, 0xbf, 0x18, 0xa6,
1104 0x17, 0x79, 0x26, 0xce, 0x3b, 0x4a, 0x53, 0x7a, 0xfe, 0xfd, 0x83, 0xe5,
1105 0x9a, 0x6d, 0x16, 0xe8, 0xa3, 0xc0, 0x33, 0x78, 0xbc, 0x7a, 0xf0, 0x61,
1106 0x75, 0x4f, 0x2f, 0x44, 0xfe, 0xd2, 0xc1, 0xb2, 0xea, 0xe3, 0xcc, 0xef,
1107 0x87, 0x7d, 0x86, 0xd3, 0xe5, 0xf7, 0xd3, 0x7f, 0xbf, 0xd5, 0xa0, 0x8b,
1108 0xb7, 0x06, 0xc1, 0xfd, 0xfc, 0x0d, 0x27, 0xac, 0x41, 0xd5, 0x77, 0x71,
1109 0x8e, 0x13, 0xa8, 0x37, 0x46, 0x2d, 0xad, 0x04, 0xdb, 0x3d, 0xe5, 0xa3,
1110 0x5e, 0x11, 0xf6, 0xd8, 0xaa, 0x30, 0x11, 0x7f, 0xb9, 0x96, 0xff, 0xcd,
1111 0x7e, 0xfe, 0x26, 0x3c, 0xe7, 0xf2, 0x9a, 0x6d, 0xea, 0xae, 0xea, 0xe6,
1112 0xdb, 0xa4, 0xcf, 0x25, 0x0a, 0xe3, 0xd0, 0xcd, 0xed, 0xf6, 0xd1, 0x9e,
1113 0x23, 0xb2, 0x5d, 0xd0, 0x94, 0x01, 0x7a, 0xaa, 0xb5, 0x28, 0xdf, 0xe2,
1114 0xef, 0xfd, 0xab, 0x07, 0xbf, 0xdb, 0xbc, 0x74, 0x70, 0x16, 0xf2, 0xe1,
1115 0x33, 0xcd, 0x36, 0x23, 0xfd, 0x8b, 0x72, 0x7e, 0xee, 0x23, 0xfe, 0xfb,
1116 0x88, 0xff, 0x3e, 0xe2, 0xbf, 0x8f, 0xf8, 0xef, 0x23, 0xfe, 0xfb, 0x88,
1117 0xff, 0xe0, 0xe1, 0x0f, 0xa0, 0x2f, 0xe7, 0xfd, 0x89, 0x30, 0xdf, 0x7a,
1118 0x7c, 0x2d, 0xdf, 0x3a, 0xd7, 0xe2, 0x6f, 0x3f, 0x92, 0x96, 0x4a, 0x85,
1119 0x54, 0xbe, 0x4a, 0x82, 0xf3, 0x9b, 0x28, 0x5f, 0xbd, 0xfe, 0x37, 0x0c,
1120 0x05, 0xc7, 0xb9, 0x1a, 0xc3, 0x55, 0x34, 0xe1, 0x30, 0x9c, 0xca, 0xd7,
1121 0xb8, 0x46, 0x5a, 0x0f, 0xc3, 0xdf, 0xc9, 0xd8, 0xb7, 0xa9, 0x6f, 0x34,
1122 0xea, 0x7b, 0xd0, 0xe3, 0x5f, 0xf7, 0x10, 0x8b, 0xcb, 0x4d, 0x19, 0x8f,
1123 0x31, 0x7e, 0x06, 0x63, 0x83, 0xf5, 0x8f, 0xdf, 0xdd, 0xc3, 0x75, 0x41,
1124 0xb9, 0x89, 0xbc, 0x68, 0x39, 0xca, 0x85, 0x00, 0xe7, 0xbf, 0xa9, 0x95,
1125 0xea, 0x2c, 0x67, 0x41, 0xb3, 0x69, 0x30, 0xc5, 0x69, 0xaf, 0x75, 0x5e,
1126 0x96, 0xb5, 0x8e, 0xfa, 0x9b, 0x9e, 0x11, 0xd0, 0x16, 0xdd, 0xfd, 0x12,
1127 0xe9, 0xf3, 0x69, 0xf9, 0x77, 0x00, 0x29, 0x67, 0x58, 0xfe, 0x3d, 0x42,
1128 0x1f, 0xf6, 0x11, 0xf3, 0x3b, 0xdb, 0xee, 0x56, 0xa9, 0xa0, 0x7c, 0x76,
1129 0xa7, 0xfa, 0x3b, 0x08, 0x91, 0x86, 0xed, 0xde, 0xb6, 0x0d, 0x67, 0x83,
1130 0x5c, 0x5f, 0xdd, 0x2a, 0xf3, 0x67, 0xf8, 0xd1, 0x93, 0xc3, 0x7d, 0x03,
1131 0xd4, 0xb3, 0x9d, 0x4e, 0x0d, 0x73, 0xad, 0xb5, 0x19, 0xf8, 0x78, 0xad,
1132 0x9d, 0x2d, 0x88, 0xed, 0x74, 0x7a, 0x11, 0x7e, 0x76, 0xd1, 0x76, 0x59,
1133 0x97, 0x97, 0x86, 0xd3, 0xf0, 0xcf, 0x63, 0x03, 0x1c, 0x9f, 0x97, 0x5b,
1134 0xac, 0x2b, 0x7d, 0x80, 0x1f, 0x84, 0x5e, 0x6e, 0x82, 0x3d, 0x09, 0xec,
1135 0x1f, 0xe1, 0xfe, 0xb9, 0xc4, 0xdd, 0xe7, 0xec, 0xd9, 0x26, 0x75, 0x43,
1136 0xd8, 0xa6, 0x25, 0x40, 0xfb, 0x27, 0x6a, 0x44, 0x97, 0xf8, 0x6c, 0xb3,
1137 0x7e, 0xfb, 0xb7, 0xba, 0x37, 0xb5, 0x72, 0x9d, 0xff, 0x0e, 0x61, 0x98,
1138 0xf6, 0x41, 0xbf, 0x4c, 0xe7, 0x4d, 0xed, 0x81, 0xc6, 0xff, 0x14, 0x6e,
1139 0x75, 0xb1, 0x71, 0x5c, 0x55, 0xf8, 0xdc, 0x59, 0xaf, 0xed, 0x38, 0x6b,
1140 0x67, 0xe2, 0x6c, 0xec, 0xb5, 0x15, 0xc4, 0xce, 0x7a, 0x12, 0x4f, 0xb5,
1141 0x8e, 0x3a, 0xb6, 0x12, 0xb4, 0x42, 0x96, 0x58, 0xed, 0x7a, 0x5d, 0x87,
1142 0x92, 0xb2, 0x85, 0x50, 0x05, 0x09, 0x55, 0x96, 0x9d, 0xd2, 0x54, 0x80,
1143 0x90, 0xfa, 0x80, 0x78, 0xcb, 0x6a, 0x6d, 0x87, 0xa4, 0xec, 0x76, 0x6d,
1144 0x62, 0xd7, 0x2f, 0x3c, 0x2c, 0xeb, 0x75, 0x6a, 0xbb, 0x9b, 0xac, 0x42,
1145 0xfb, 0x50, 0x9e, 0x62, 0x99, 0x92, 0xc2, 0x4b, 0x85, 0xc4, 0x03, 0x02,
1146 0x54, 0xa9, 0x4a, 0xda, 0x34, 0x0f, 0x25, 0x11, 0xbc, 0x50, 0x0a, 0xd2,
1147 0xf0, 0x7d, 0x77, 0x66, 0x1d, 0x27, 0x50, 0x61, 0x69, 0x35, 0x77, 0xee,
1148 0xdc, 0x3b, 0x73, 0x7f, 0xce, 0xf9, 0xce, 0x77, 0xce, 0x3d, 0x66, 0x1b,
1149 0x1b, 0x65, 0xfa, 0xd3, 0xab, 0x6a, 0xa6, 0xda, 0x2b, 0x0b, 0x90, 0xe3,
1150 0xe2, 0x48, 0x38, 0x88, 0x97, 0x76, 0x05, 0xfa, 0x0c, 0xc7, 0xdf, 0xb7,
1151 0x57, 0x9a, 0x57, 0x16, 0xcd, 0x4e, 0xcd, 0xab, 0x1e, 0x7d, 0x76, 0x0a,
1152 0x63, 0x8a, 0x61, 0x1d, 0xba, 0xfb, 0x34, 0x36, 0x19, 0xbc, 0xef, 0x7f,
1153 0xec, 0xbe, 0xef, 0xb1, 0xfb, 0xc3, 0xff, 0xa3, 0x3d, 0xcb, 0x8f, 0xcb,
1154 0x03, 0xc7, 0x69, 0xa5, 0xf8, 0x95, 0x62, 0xc9, 0x36, 0x66, 0x4b, 0x56,
1155 0x9a, 0xbc, 0x20, 0x2b, 0x9e, 0xca, 0xba, 0xed, 0xc0, 0xbb, 0x76, 0x99,
1156 0x5f, 0x86, 0xcc, 0x63, 0x1e, 0x1d, 0x36, 0xcf, 0xb4, 0x13, 0x7d, 0xd4,
1157 0x99, 0x4e, 0x6c, 0x83, 0x61, 0x0f, 0xc5, 0xd0, 0xce, 0x7b, 0xc9, 0x4d,
1158 0x9a, 0xe7, 0x74, 0x1c, 0x86, 0x7c, 0xc6, 0x53, 0x45, 0x9d, 0x9f, 0xc1,
1159 0x36, 0x6d, 0x72, 0xc7, 0xce, 0xf4, 0x06, 0xf9, 0x3e, 0xf0, 0x5b, 0xc7,
1160 0xfa, 0xc8, 0x35, 0x5e, 0x74, 0x77, 0xeb, 0xcc, 0xdb, 0xc2, 0x3c, 0x2a,
1161 0x08, 0xcd, 0xb3, 0x22, 0xd5, 0xba, 0xc8, 0xeb, 0xf8, 0xfd, 0xae, 0x1e,
1162 0xf8, 0x0a, 0x8a, 0x3e, 0xf3, 0xb8, 0x6c, 0x55, 0xbe, 0x2c, 0x0d, 0xd8,
1163 0x9f, 0x4d, 0xd7, 0xf3, 0xee, 0xb9, 0x71, 0xbd, 0xe6, 0x3f, 0x29, 0x29,
1164 0x49, 0x8c, 0xd2, 0xbe, 0xb5, 0xcb, 0x4f, 0x97, 0xdb, 0x64, 0xdb, 0xb4,
1165 0xcc, 0x7b, 0xc2, 0x5c, 0xb6, 0x98, 0x4c, 0x45, 0x43, 0x9a, 0xa3, 0xca,
1166 0xb7, 0xc0, 0xa0, 0xf1, 0xec, 0xee, 0xf2, 0x33, 0x7d, 0x8c, 0x9d, 0x7c,
1167 0xb4, 0xcc, 0x7b, 0x03, 0x57, 0x43, 0x76, 0xec, 0x10, 0xb8, 0x2c, 0x40,
1168 0xc8, 0xe4, 0xba, 0x73, 0xbe, 0xcf, 0x71, 0x6c, 0xa8, 0xa3, 0x2f, 0xda,
1169 0x2e, 0xc5, 0xa3, 0xc0, 0x44, 0x35, 0xa4, 0x73, 0x8a, 0x76, 0xa2, 0x1a,
1170 0xa3, 0x43, 0x35, 0xe6, 0xc8, 0x99, 0xfb, 0x35, 0x5e, 0x67, 0xae, 0x7d,
1171 0x5f, 0xcf, 0x05, 0xe5, 0x42, 0xcd, 0xa5, 0xac, 0x9a, 0xb2, 0x09, 0x5d,
1172 0xdb, 0x68, 0x2e, 0xf5, 0x73, 0xaf, 0xb6, 0x9a, 0x3f, 0xe8, 0xf3, 0x7d,
1173 0x2d, 0xd6, 0xfd, 0xb0, 0xcf, 0xaf, 0x8b, 0x07, 0xbe, 0x13, 0x7d, 0xac,
1174 0x2a, 0xe6, 0xf6, 0xb2, 0x34, 0x57, 0x7f, 0x2c, 0x6f, 0x57, 0x7e, 0x24,
1175 0xbf, 0x5a, 0x3d, 0x0b, 0xfe, 0x61, 0x55, 0x0b, 0xb0, 0x27, 0x37, 0x9a,
1176 0x9e, 0x77, 0xc3, 0x3d, 0x03, 0x5f, 0xc1, 0xf3, 0xfe, 0xe0, 0x6e, 0x4b,
1177 0x62, 0xec, 0x3b, 0x98, 0x73, 0x1e, 0x3a, 0x44, 0x2c, 0x9c, 0x82, 0xbc,
1178 0x25, 0xfb, 0xa5, 0x2b, 0xa2, 0xe5, 0x64, 0x68, 0x2c, 0x8c, 0x39, 0x18,
1179 0x01, 0x27, 0xe7, 0x5c, 0x46, 0xfa, 0x29, 0x33, 0x46, 0xf3, 0x15, 0x7c,
1180 0x3f, 0x0c, 0xbd, 0xd8, 0x8f, 0x9f, 0x92, 0x7b, 0xa3, 0x18, 0xeb, 0x28,
1181 0x65, 0x2f, 0x2c, 0x89, 0x27, 0x31, 0x8f, 0x7c, 0x9b, 0xdc, 0x2f, 0x5d,
1182 0xe9, 0x63, 0x5c, 0xee, 0x7e, 0x89, 0x65, 0xe3, 0x4b, 0x3d, 0xe2, 0x49,
1183 0x1b, 0x6c, 0xf9, 0xfc, 0x09, 0x9f, 0x37, 0xfd, 0x5a, 0x0d, 0xa3, 0xbd,
1184 0x5d, 0x78, 0x47, 0x91, 0xe7, 0x15, 0xbc, 0x30, 0x78, 0x79, 0x0e, 0x7c,
1185 0x28, 0xd3, 0xbc, 0x20, 0x3b, 0xa3, 0x11, 0xb4, 0x21, 0x5f, 0xd1, 0x58,
1186 0x22, 0xd9, 0x12, 0x73, 0xb0, 0x98, 0x0f, 0x85, 0x31, 0x9e, 0x21, 0x6e,
1187 0x70, 0x8c, 0xed, 0x3c, 0xb7, 0x0b, 0xea, 0x6c, 0xc8, 0x08, 0xeb, 0x28,
1188 0xdf, 0x69, 0xcd, 0xa9, 0x60, 0x43, 0xf1, 0xbe, 0x11, 0xc9, 0xe8, 0x72,
1189 0x0f, 0xde, 0x77, 0x41, 0xe7, 0x25, 0xfa, 0xef, 0x4c, 0xa1, 0x0d, 0x71,
1190 0x26, 0x05, 0x2e, 0xf1, 0xa1, 0x9a, 0x00, 0xbd, 0x99, 0x29, 0xf5, 0xc9,
1191 0x84, 0xb9, 0x6f, 0xcf, 0x1c, 0x0b, 0xda, 0x57, 0x30, 0x8c, 0x91, 0x60,
1192 0x4c, 0x3d, 0x7b, 0xc6, 0xc4, 0xfe, 0xf8, 0xc1, 0xc7, 0xcd, 0x2c, 0x2f,
1193 0x02, 0xa7, 0x16, 0x7f, 0x9b, 0x71, 0x9f, 0x97, 0x6c, 0xb4, 0x5d, 0xfb,
1194 0x36, 0x35, 0xec, 0x4b, 0xb6, 0xc4, 0x78, 0xd4, 0xb7, 0x81, 0x43, 0xfb,
1195 0x82, 0x3a, 0xb6, 0x15, 0x23, 0x83, 0xb5, 0x4f, 0x6b, 0x3d, 0x64, 0xdd,
1196 0x17, 0x25, 0xb3, 0x98, 0x97, 0x49, 0xdd, 0x8f, 0x6b, 0x38, 0xa8, 0x79,
1197 0x08, 0x75, 0x35, 0x71, 0x08, 0x6b, 0x99, 0x0c, 0x07, 0x6d, 0xf7, 0x91,
1198 0xc9, 0xe3, 0xef, 0xd3, 0x40, 0x67, 0xf1, 0xec, 0x10, 0xf7, 0xa8, 0x5d,
1199 0x12, 0xdf, 0x84, 0xbd, 0x2c, 0xb5, 0xea, 0x23, 0xf2, 0x49, 0xe9, 0xb3,
1200 0x3e, 0x9e, 0x93, 0xfc, 0xb5, 0x64, 0xca, 0x47, 0x25, 0x7d, 0x7e, 0x3a,
1201 0x1d, 0x12, 0xeb, 0xbc, 0xef, 0x67, 0x1f, 0x9d, 0x9e, 0x57, 0x7c, 0x7e,
1202 0xf4, 0xfc, 0xba, 0xea, 0x44, 0xdb, 0x08, 0xda, 0x71, 0x1c, 0xa6, 0xe4,
1203 0x4a, 0x7f, 0xf7, 0x66, 0x8e, 0x79, 0xde, 0xa4, 0xce, 0xe1, 0x4a, 0x9a,
1204 0xf3, 0xaa, 0xc5, 0xcf, 0x1d, 0x29, 0x45, 0x3b, 0xf0, 0xad, 0xa4, 0xb9,
1205 0xae, 0x8e, 0x62, 0x3c, 0x2c, 0x1f, 0xa2, 0x4e, 0xc4, 0xb6, 0x85, 0xef,
1206 0xb7, 0xa6, 0xd6, 0x54, 0x32, 0x3e, 0xa4, 0xac, 0x74, 0x11, 0xbf, 0x36,
1207 0xa5, 0xcf, 0x1e, 0x63, 0x71, 0x05, 0xdd, 0xc5, 0x9c, 0xec, 0xe3, 0x9e,
1208 0x37, 0x65, 0xb3, 0x3e, 0x69, 0x46, 0x14, 0xe3, 0x26, 0x5d, 0xfa, 0x8c,
1209 0xf2, 0xd2, 0xe1, 0xa4, 0x79, 0x5c, 0x1d, 0x0c, 0xee, 0x53, 0xc0, 0xcc,
1210 0xdd, 0xf7, 0x9d, 0x5d, 0x53, 0xa6, 0x5c, 0x2e, 0x25, 0xe3, 0xb3, 0xca,
1211 0xca, 0xe3, 0x9d, 0xf9, 0x09, 0x45, 0xdc, 0x48, 0x9a, 0x5d, 0x8a, 0xb1,
1212 0xcd, 0x0e, 0x3d, 0xef, 0x29, 0xf4, 0x4f, 0xaa, 0xb6, 0x60, 0x3c, 0xdc,
1213 0xaf, 0xcb, 0xfd, 0xbe, 0xce, 0x10, 0x73, 0x06, 0x8c, 0x99, 0x45, 0xe6,
1214 0x83, 0xe9, 0x3c, 0x84, 0x74, 0x62, 0x8c, 0xf7, 0x86, 0x3c, 0x38, 0xf9,
1215 0x0f, 0xd4, 0xa1, 0x5c, 0x65, 0x9d, 0x13, 0xe8, 0xdb, 0x31, 0xcd, 0x9f,
1216 0x1f, 0x9c, 0x2c, 0xe8, 0xfc, 0xc4, 0x1d, 0x95, 0x08, 0xe6, 0xbd, 0xbb,
1217 0x67, 0xf1, 0x8c, 0xfb, 0x05, 0xbe, 0x67, 0x31, 0x34, 0xde, 0x21, 0xcc,
1218 0x07, 0xcd, 0x55, 0x5a, 0xb2, 0xc1, 0xd8, 0x00, 0xcf, 0xf7, 0x5b, 0x67,
1219 0xe5, 0x17, 0xc4, 0x18, 0xeb, 0xdc, 0x23, 0x27, 0xe0, 0x9d, 0xe0, 0xab,
1220 0x75, 0xbc, 0xa7, 0xb8, 0x2c, 0x05, 0xbf, 0xbf, 0x74, 0x32, 0xff, 0xb4,
1221 0x58, 0xff, 0xbc, 0x77, 0xf8, 0x36, 0x30, 0x87, 0xfb, 0x07, 0x27, 0x29,
1222 0x9f, 0x5c, 0x9b, 0xb8, 0x9a, 0xbc, 0xc2, 0xf1, 0x0c, 0x4a, 0x6e, 0x19,
1223 0xdc, 0x08, 0xbf, 0xf9, 0x65, 0x7f, 0xdf, 0xd6, 0xc1, 0xb3, 0x73, 0x25,
1224 0x53, 0xeb, 0xeb, 0xac, 0xcb, 0xb3, 0x0f, 0xe8, 0x8a, 0xce, 0x7b, 0x62,
1225 0x5f, 0xe6, 0x0a, 0x1e, 0xa1, 0x7d, 0x74, 0x6a, 0x12, 0x45, 0x5b, 0x72,
1226 0x56, 0xd6, 0x83, 0xbf, 0xc3, 0x66, 0x16, 0x5f, 0x8d, 0x08, 0x30, 0x39,
1227 0x15, 0x0f, 0x1d, 0x90, 0x79, 0xd7, 0x95, 0x46, 0xf3, 0x84, 0x5c, 0x6b,
1228 0x3a, 0xfa, 0x19, 0xed, 0xd9, 0xc2, 0x6b, 0xfa, 0x5c, 0x3a, 0xfe, 0xa1,
1229 0xb2, 0x9c, 0xab, 0xf0, 0x6b, 0xbe, 0x7b, 0x8c, 0x79, 0xc2, 0xe1, 0x81,
1230 0x87, 0x79, 0x70, 0xc0, 0x0e, 0x70, 0x8e, 0xb7, 0xc0, 0x39, 0xde, 0x04,
1231 0xe7, 0xf8, 0x25, 0x38, 0xf6, 0x8d, 0xca, 0x54, 0x80, 0xff, 0xd3, 0xc0,
1232 0x21, 0xda, 0x6a, 0xeb, 0x2c, 0xf6, 0x74, 0xba, 0x00, 0x19, 0xfc, 0x00,
1233 0xfe, 0xc7, 0x56, 0x25, 0x23, 0x1b, 0xab, 0x93, 0xb2, 0xb9, 0xea, 0xe7,
1234 0x1c, 0xbf, 0xcb, 0x3c, 0xad, 0x51, 0xee, 0x93, 0x03, 0x1c, 0xda, 0x27,
1235 0x89, 0xe3, 0xc4, 0x8f, 0x4e, 0x59, 0x2b, 0xaf, 0x69, 0x1c, 0x5a, 0x2b,
1236 0xb3, 0x1c, 0x12, 0x9d, 0xf3, 0x75, 0x66, 0x5b, 0x6a, 0xee, 0x16, 0xea,
1237 0xbb, 0x99, 0xdb, 0x15, 0xc4, 0xd6, 0x89, 0x97, 0x7f, 0x0e, 0xf6, 0x5e,
1238 0xe9, 0x5c, 0xb8, 0x19, 0xf3, 0x00, 0xda, 0xb5, 0xb0, 0x6b, 0xc8, 0x3f,
1239 0x27, 0x57, 0x7f, 0x41, 0x1b, 0x7c, 0x03, 0x9c, 0xf1, 0x2a, 0x6c, 0xc8,
1240 0x8e, 0x73, 0x40, 0x73, 0xbf, 0x1d, 0xe7, 0x88, 0xce, 0xad, 0xe5, 0x7b,
1241 0x8a, 0x65, 0x5b, 0xe6, 0xca, 0x56, 0xbc, 0x00, 0xf9, 0xbb, 0x06, 0xbf,
1242 0x6d, 0x03, 0x7b, 0xb0, 0x89, 0xb5, 0xd8, 0x6a, 0xd2, 0xce, 0xbf, 0xaf,
1243 0xb1, 0x77, 0xad, 0xf9, 0x27, 0xbc, 0xc7, 0x3a, 0x9b, 0x96, 0x3f, 0xf6,
1244 0x13, 0x03, 0x99, 0x8f, 0x97, 0xd5, 0xfd, 0xfd, 0x7e, 0x1b, 0x68, 0xbb,
1245 0xd9, 0x24, 0x1e, 0x8b, 0x5c, 0x2c, 0xd9, 0xb0, 0x25, 0x17, 0x63, 0xe4,
1246 0x00, 0x55, 0xd5, 0xea, 0xe7, 0x05, 0x63, 0xf6, 0xbc, 0xfd, 0x36, 0xc7,
1247 0xe5, 0x04, 0xb8, 0x4d, 0xdb, 0xbf, 0xad, 0xb9, 0x4d, 0xa9, 0xf2, 0xbc,
1248 0x5c, 0x5f, 0x4d, 0x05, 0x1c, 0x27, 0x2f, 0x6f, 0x80, 0xe3, 0x35, 0x2b,
1249 0xad, 0x1c, 0xed, 0x71, 0xac, 0x53, 0x45, 0xcd, 0x2d, 0x75, 0xc9, 0xa5,
1250 0x95, 0xa2, 0xba, 0xbc, 0x52, 0x52, 0xaf, 0x2c, 0x95, 0x55, 0x71, 0xc9,
1251 0xf3, 0xfe, 0xe9, 0xce, 0xc8, 0xdb, 0xab, 0x9e, 0x9c, 0x76, 0x8d, 0x81,
1252 0x90, 0xb4, 0xf2, 0xdf, 0x3c, 0xaf, 0x13, 0xd8, 0xbc, 0x75, 0xd8, 0xf3,
1253 0x9e, 0x18, 0x1d, 0x15, 0xe7, 0x30, 0x39, 0xca, 0x70, 0x8c, 0x39, 0xac,
1254 0xc4, 0x9c, 0x8c, 0x6d, 0x9f, 0xaf, 0x29, 0x05, 0x7c, 0x3b, 0xe0, 0xf3,
1255 0x97, 0x27, 0xbb, 0x83, 0x33, 0x8f, 0xb3, 0x2f, 0x31, 0x26, 0x1c, 0xfb,
1256 0xaf, 0x98, 0xb0, 0x29, 0xe7, 0xca, 0x58, 0x88, 0xae, 0xa8, 0x7c, 0xaf,
1257 0x1c, 0x79, 0xac, 0x6c, 0xe2, 0xea, 0x18, 0xc5, 0xf2, 0x7d, 0x6f, 0x48,
1258 0xc7, 0xfe, 0xc1, 0x49, 0x4c, 0xcf, 0x9b, 0x75, 0xf9, 0xbd, 0x03, 0x8c,
1259 0xc9, 0x98, 0xdd, 0xb0, 0xff, 0xa7, 0xb5, 0x7d, 0xae, 0xaa, 0x8c, 0x4d,
1260 0xfd, 0x8e, 0xca, 0x44, 0x19, 0x36, 0x5e, 0x31, 0x2f, 0x94, 0x5c, 0xc1,
1261 0x8a, 0xcd, 0x02, 0x3b, 0x66, 0x80, 0x37, 0x4f, 0xeb, 0xb3, 0xd1, 0x43,
1262 0x1a, 0x7b, 0xe6, 0x58, 0xce, 0x4b, 0xba, 0xe6, 0xf6, 0xea, 0xf5, 0xbb,
1263 0x7d, 0xad, 0x18, 0xf3, 0xf7, 0x1c, 0x7a, 0x9c, 0xe7, 0xf9, 0x40, 0xaf,
1264 0x64, 0xd7, 0xcf, 0x40, 0x27, 0x62, 0x58, 0xdb, 0xb0, 0xd6, 0x87, 0x1d,
1265 0xd8, 0xef, 0x1d, 0x27, 0x1c, 0x60, 0x6a, 0x27, 0xee, 0xd9, 0x6e, 0x12,
1266 0xfd, 0x3a, 0x24, 0xb3, 0xd4, 0xae, 0x71, 0xf5, 0xd1, 0xba, 0x34, 0x78,
1267 0x48, 0x0e, 0xe5, 0x10, 0xea, 0xe2, 0x41, 0x99, 0xdc, 0x6b, 0x1a, 0xe5,
1268 0x36, 0x5c, 0xd9, 0xe6, 0x28, 0x78, 0x05, 0xae, 0xbf, 0xc0, 0xfb, 0x46,
1269 0x31, 0xe6, 0xbc, 0x29, 0xef, 0x9d, 0xa4, 0x2d, 0x71, 0x0c, 0xe6, 0x1a,
1270 0xcf, 0xda, 0xb8, 0x36, 0xca, 0x2a, 0xbb, 0xc8, 0x32, 0xae, 0x55, 0xff,
1271 0xf9, 0x23, 0x98, 0x84, 0x3e, 0x99, 0x15, 0x1f, 0x93, 0xde, 0xdb, 0xc5,
1272 0x24, 0xd6, 0x75, 0xc8, 0xc4, 0x52, 0x5c, 0x9d, 0xba, 0x62, 0x42, 0xde,
1273 0xba, 0x24, 0xbb, 0x12, 0xd5, 0x7c, 0xb4, 0x06, 0x59, 0x5c, 0x87, 0x5c,
1274 0xad, 0x41, 0xa6, 0x32, 0x65, 0x2b, 0x35, 0xad, 0xe2, 0x3a, 0x2e, 0x30,
1275 0x05, 0x79, 0x0d, 0xbf, 0x4a, 0x2e, 0x4a, 0xfd, 0x75, 0xd0, 0x46, 0x68,
1276 0x47, 0xd3, 0x61, 0x65, 0x43, 0x0e, 0x21, 0x97, 0x65, 0x5f, 0x7f, 0xdf,
1277 0x51, 0x1a, 0x57, 0x53, 0x77, 0x24, 0xe9, 0xdc, 0x11, 0xcb, 0xdd, 0xc1,
1278 0xef, 0x37, 0xe2, 0xca, 0x55, 0xe8, 0xfb, 0xeb, 0xf8, 0x4e, 0xf8, 0x35,
1279 0x43, 0x8e, 0x0d, 0x6b, 0x9d, 0x4e, 0x49, 0xc8, 0x72, 0x36, 0xc5, 0xd7,
1280 0xf1, 0x75, 0xad, 0xe3, 0x90, 0x37, 0x60, 0x90, 0xaf, 0xd3, 0xe9, 0x40,
1281 0x46, 0xbf, 0x01, 0xfd, 0xb5, 0xe0, 0x95, 0xc5, 0x65, 0x1e, 0xfa, 0x7f,
1282 0x15, 0xcf, 0x6f, 0x36, 0x3f, 0x56, 0x73, 0x8b, 0x2a, 0xc8, 0x3f, 0x79,
1283 0x0e, 0x3c, 0xf9, 0xf7, 0x58, 0xbb, 0x1e, 0xcd, 0xdd, 0x13, 0xa3, 0x3c,
1284 0x07, 0xfb, 0xb7, 0xba, 0x64, 0x1f, 0x97, 0xdb, 0x23, 0x27, 0x50, 0xee,
1285 0xc6, 0xd5, 0xc0, 0x3a, 0x44, 0xf4, 0xf9, 0xf5, 0x5a, 0x69, 0xc4, 0x28,
1286 0xea, 0x33, 0xe6, 0x31, 0xf4, 0x25, 0x96, 0x1d, 0xc6, 0x73, 0xc6, 0x65,
1287 0x38, 0x37, 0x70, 0x26, 0x15, 0xd3, 0x39, 0xa1, 0x35, 0x70, 0x89, 0x75,
1288 0xbc, 0xef, 0x16, 0xe3, 0x7a, 0x0d, 0xe8, 0xf0, 0xc8, 0x67, 0x5e, 0x3a,
1289 0xca, 0xbc, 0xf3, 0xf7, 0x63, 0xbe, 0xfd, 0xfb, 0xc4, 0xbb, 0x6d, 0xcf,
1290 0xa5, 0x0c, 0xdc, 0x7c, 0x60, 0x02, 0xef, 0xc8, 0xdb, 0x61, 0x8b, 0xaa,
1291 0x5a, 0x7e, 0xd9, 0xce, 0xef, 0x5b, 0x6c, 0x24, 0xcd, 0x77, 0xc5, 0xef,
1292 0x3b, 0x6f, 0xd3, 0xee, 0x74, 0x00, 0x5f, 0xe2, 0x9a, 0x57, 0xde, 0xb2,
1293 0x0b, 0x40, 0x05, 0x2b, 0x3e, 0x05, 0x19, 0x6d, 0x17, 0xcb, 0xc9, 0xc9,
1294 0xc3, 0xef, 0xce, 0xea, 0xbe, 0x6c, 0xdb, 0xea, 0xdb, 0xfa, 0x2e, 0xc7,
1295 0xcf, 0xb9, 0x70, 0x0e, 0xf0, 0x6d, 0x4c, 0x53, 0xcb, 0xe8, 0x4e, 0xc3,
1296 0x18, 0xf0, 0x65, 0xb4, 0x35, 0x8f, 0xe8, 0xff, 0x99, 0x07, 0xe5, 0x64,
1297 0xc4, 0xf0, 0xcf, 0xdb, 0x71, 0x6d, 0x70, 0x3d, 0x3f, 0x06, 0xbf, 0xdf,
1298 0x2b, 0x3f, 0xad, 0x38, 0xa3, 0x2f, 0x3f, 0x4f, 0xec, 0xca, 0x0f, 0x7d,
1299 0xd4, 0x2e, 0xc9, 0xad, 0xd8, 0x32, 0x59, 0xd6, 0xfb, 0x0d, 0xae, 0xc9,
1300 0xf8, 0xd1, 0x09, 0xc8, 0x0d, 0x65, 0x9d, 0xba, 0x65, 0x4a, 0x15, 0x72,
1301 0x54, 0x05, 0x3e, 0x55, 0x21, 0x53, 0xe4, 0x40, 0x55, 0xe0, 0x5b, 0xb5,
1302 0x69, 0x39, 0x75, 0xcc, 0x99, 0x36, 0x7b, 0x1d, 0x72, 0x74, 0xb5, 0xc9,
1303 0xfd, 0xd7, 0x63, 0x36, 0x69, 0x07, 0x6f, 0xee, 0xee, 0xfd, 0xa7, 0xd8,
1304 0xfb, 0x23, 0x72, 0x0d, 0x7e, 0xcb, 0xf5, 0xca, 0x08, 0x30, 0x49, 0x80,
1305 0x51, 0x2e, 0x64, 0x23, 0x25, 0x1b, 0x95, 0x71, 0xd9, 0x84, 0x7d, 0xda,
1306 0x5a, 0x4d, 0x80, 0x4f, 0x03, 0x47, 0xaf, 0x1c, 0x93, 0x37, 0x56, 0x95,
1307 0xcc, 0xd8, 0xb0, 0x33, 0x6b, 0x8c, 0xc1, 0x43, 0x9e, 0xab, 0x5d, 0xfa,
1308 0xbc, 0x7d, 0xa2, 0xee, 0xc7, 0xe2, 0x73, 0xf5, 0x1e, 0x99, 0xac, 0x9b,
1309 0xf2, 0x54, 0xbd, 0x57, 0xbe, 0x5a, 0x8f, 0xca, 0xe9, 0x46, 0x4c, 0xbe,
1310 0x56, 0x1f, 0x94, 0xa7, 0xeb, 0x47, 0xe4, 0x99, 0x46, 0x5c, 0xbe, 0x0e,
1311 0xbf, 0x30, 0xdf, 0x70, 0x64, 0xaa, 0x31, 0x22, 0xa7, 0x1a, 0x8c, 0xb1,
1312 0xe3, 0x7b, 0xf8, 0x65, 0x77, 0x63, 0x17, 0x1c, 0x57, 0x27, 0xc6, 0xe5,
1313 0xa8, 0x9c, 0x3e, 0x6f, 0x94, 0xbc, 0x1f, 0xff, 0x10, 0x79, 0x01, 0x7d,
1314 0x17, 0xae, 0x28, 0xa9, 0xe9, 0xef, 0xb7, 0xfe, 0x47, 0x24, 0xa2, 0x7d,
1315 0xa3, 0x17, 0xaa, 0x83, 0x68, 0x63, 0xd3, 0x27, 0x09, 0xe2, 0x20, 0xad,
1316 0xf8, 0x7f, 0xcb, 0xf7, 0x32, 0x74, 0x0c, 0xfb, 0x26, 0x7d, 0x2f, 0xbd,
1317 0xf6, 0xc4, 0x0f, 0xfa, 0x39, 0xf4, 0xb5, 0xf6, 0x9e, 0x51, 0xb4, 0xbe,
1318 0xbb, 0x90, 0x7f, 0xf4, 0x7f, 0x51, 0xfc, 0xb3, 0xa6, 0x73, 0x8d, 0x41,
1319 0xfe, 0x4f, 0x0a, 0xc6, 0xf2, 0xf9, 0xf9, 0xdd, 0x93, 0x95, 0x09, 0xf5,
1320 0x54, 0x85, 0x8c, 0xc6, 0x93, 0x85, 0xdd, 0x3c, 0xba, 0xaf, 0xc8, 0x9a,
1321 0x1b, 0xd1, 0x63, 0xf0, 0xe3, 0xf6, 0x69, 0x9d, 0x53, 0x37, 0x31, 0x4c,
1322 0xf9, 0xe3, 0x19, 0x5a, 0x4f, 0x70, 0xb6, 0x00, 0x6e, 0xeb, 0x9a, 0x72,
1323 0xb1, 0xee, 0xc7, 0xaf, 0xe6, 0xb4, 0xbc, 0x5c, 0x87, 0xcc, 0xf1, 0xfc,
1324 0xc1, 0xbf, 0x16, 0xaa, 0x7e, 0xdf, 0xec, 0xb0, 0x43, 0x7f, 0x1c, 0xf3,
1325 0x35, 0x7a, 0xf9, 0x2d, 0xfe, 0x4f, 0x0e, 0xca, 0xc1, 0x78, 0x99, 0x0f,
1326 0x6c, 0x6b, 0x59, 0xf4, 0xcf, 0x67, 0x1d, 0x79, 0x11, 0x7b, 0x51, 0x33,
1327 0x39, 0xfe, 0x4e, 0xa9, 0x39, 0xf4, 0x6d, 0x89, 0xdf, 0xc3, 0x52, 0xc5,
1328 0x77, 0x6a, 0x4e, 0x2b, 0x36, 0xe6, 0xe3, 0x6c, 0xcd, 0x7c, 0xf8, 0xdd,
1329 0xe9, 0xea, 0x41, 0xdc, 0xa3, 0xce, 0x01, 0x67, 0x3a, 0xc3, 0xfb, 0x05,
1330 0x94, 0x19, 0x1b, 0x99, 0xc3, 0x35, 0x16, 0xd4, 0xfd, 0x7c, 0x40, 0x73,
1331 0xf5, 0xf1, 0x87, 0xfd, 0x66, 0xaa, 0x56, 0x21, 0x13, 0xba, 0xab, 0x8c,
1332 0x9f, 0xad, 0x0f, 0x10, 0x73, 0x0f, 0xda, 0xfc, 0x45, 0xe4, 0x6f, 0xa6,
1333 0x8e, 0x29, 0x04, 0xcf, 0xf6, 0xc9, 0xb3, 0x26, 0x73, 0xcd, 0xd3, 0x6a,
1334 0xa2, 0xf2, 0x72, 0x90, 0x57, 0x7b, 0x57, 0x1d, 0xac, 0x35, 0x07, 0xfc,
1335 0xbc, 0x74, 0xbe, 0x7b, 0x6f, 0x2e, 0xfa, 0x5e, 0x39, 0x61, 0x4e, 0x7a,
1336 0x07, 0x78, 0xab, 0x36, 0x62, 0xd0, 0x41, 0xe0, 0x9d, 0xdd, 0xa6, 0xf5,
1337 0xb1, 0xd8, 0xf8, 0x97, 0xb7, 0xad, 0xf5, 0xb9, 0x15, 0x63, 0xb8, 0x35,
1338 0x40, 0xdf, 0x96, 0xb8, 0x71, 0xd1, 0x8f, 0x1b, 0x69, 0x1f, 0x1a, 0x58,
1339 0x81, 0x3a, 0xea, 0x2a, 0xf4, 0x64, 0xb7, 0x2d, 0xff, 0xfe, 0x03, 0x7d,
1340 0xe7, 0x95, 0xf0, 0x2c, 0x67, 0x00, 0x00, 0x00 };
1052 1341
1053static u32 bnx2_RXP_b06FwData[(0x0/4) + 1] = { 0x0 }; 1342static u32 bnx2_RXP_b06FwData[(0x0/4) + 1] = { 0x0 };
1054static u32 bnx2_RXP_b06FwRodata[(0x28/4) + 1] = { 1343static u32 bnx2_RXP_b06FwRodata[(0x278/4) + 1] = {
1055 0x0800468c, 0x0800458c, 0x08004630, 0x08004648, 0x08004660, 0x08004680, 1344 0x08003fdc, 0x08003edc, 0x08003f80, 0x08003f98, 0x08003fb0, 0x08003fd0,
1056 0x0800468c, 0x0800468c, 0x08004594, 0x00000000, 0x00000000 }; 1345 0x08003fdc, 0x08003fdc, 0x08003ee4, 0x00000000, 0x08004a04, 0x08004a3c,
1057static u32 bnx2_RXP_b06FwBss[(0x13a4/4) + 1] = { 0x0 }; 1346 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004a74, 0x08004c38,
1058static u32 bnx2_RXP_b06FwSbss[(0x1c/4) + 1] = { 0x0 }; 1347 0x08004b80, 0x08004bb8, 0x08004c38, 0x08004b08, 0x08004c38, 0x08004c38,
1348 0x08004bb8, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38,
1349 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004bf8,
1350 0x08004c38, 0x08004bf8, 0x08004b80, 0x08004c38, 0x08004c38, 0x08004bf8,
1351 0x08004bf8, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38,
1352 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38,
1353 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38,
1354 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38,
1355 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38,
1356 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38,
1357 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38,
1358 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38,
1359 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38,
1360 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38,
1361 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38,
1362 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38,
1363 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38,
1364 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38,
1365 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38,
1366 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38,
1367 0x08004ae4, 0x00000000, 0x08006018, 0x08006030, 0x08006030, 0x08006030,
1368 0x08006018, 0x08006030, 0x08006030, 0x08006030, 0x08006018, 0x08006030,
1369 0x08006030, 0x08006030, 0x08006018, 0x08006030, 0x08006030, 0x08006030,
1370 0x08006024, 0x00000000, 0x00000000 };
1371
1372static u32 bnx2_RXP_b06FwBss[(0x13dc/4) + 1] = { 0x0 };
1373static u32 bnx2_RXP_b06FwSbss[(0x2c/4) + 1] = { 0x0 };
1374
1375static struct fw_info bnx2_rxp_fw_06 = {
1376 .ver_major = 0x2,
1377 .ver_minor = 0x8,
1378 .ver_fix = 0x17,
1379
1380 .start_addr = 0x08003184,
1381
1382 .text_addr = 0x08000000,
1383 .text_len = 0x6728,
1384 .text_index = 0x0,
1385 .gz_text = bnx2_RXP_b06FwText,
1386 .gz_text_len = sizeof(bnx2_RXP_b06FwText),
1387
1388 .data_addr = 0x080069c0,
1389 .data_len = 0x0,
1390 .data_index = 0x0,
1391 .data = bnx2_RXP_b06FwData,
1392
1393 .sbss_addr = 0x080069c0,
1394 .sbss_len = 0x2c,
1395 .sbss_index = 0x0,
1396 .sbss = bnx2_RXP_b06FwSbss,
1397
1398 .bss_addr = 0x080069f0,
1399 .bss_len = 0x13dc,
1400 .bss_index = 0x0,
1401 .bss = bnx2_RXP_b06FwBss,
1402
1403 .rodata_addr = 0x08006728,
1404 .rodata_len = 0x278,
1405 .rodata_index = 0x0,
1406 .rodata = bnx2_RXP_b06FwRodata,
1407};
1059 1408
1060static u8 bnx2_rv2p_proc1[] = { 1409static u8 bnx2_rv2p_proc1[] = {
1061 0x1f, 0x8b, 0x08, 0x08, 0x5e, 0xd0, 0x41, 0x44, 0x00, 0x03, 0x74, 0x65, 1410 0x1f, 0x8b, 0x08, 0x08, 0x5e, 0xd0, 0x41, 0x44, 0x00, 0x03, 0x74, 0x65,
@@ -1316,20 +1665,6 @@ static u8 bnx2_rv2p_proc2[] = {
1316 0x63, 0xd6, 0x11, 0x8f, 0x47, 0xd5, 0x5f, 0x3f, 0x97, 0x8f, 0x31, 0xd8, 1665 0x63, 0xd6, 0x11, 0x8f, 0x47, 0xd5, 0x5f, 0x3f, 0x97, 0x8f, 0x31, 0xd8,
1317 0x17, 0x00, 0x00, 0x00 }; 1666 0x17, 0x00, 0x00, 0x00 };
1318 1667
1319static const int bnx2_TPAT_b06FwReleaseMajor = 0x1;
1320static const int bnx2_TPAT_b06FwReleaseMinor = 0x0;
1321static const int bnx2_TPAT_b06FwReleaseFix = 0x0;
1322static const u32 bnx2_TPAT_b06FwStartAddr = 0x08000860;
1323static const u32 bnx2_TPAT_b06FwTextAddr = 0x08000800;
1324static const int bnx2_TPAT_b06FwTextLen = 0x122c;
1325static const u32 bnx2_TPAT_b06FwDataAddr = 0x08001a60;
1326static const int bnx2_TPAT_b06FwDataLen = 0x0;
1327static const u32 bnx2_TPAT_b06FwRodataAddr = 0x00000000;
1328static const int bnx2_TPAT_b06FwRodataLen = 0x0;
1329static const u32 bnx2_TPAT_b06FwBssAddr = 0x08001aa0;
1330static const int bnx2_TPAT_b06FwBssLen = 0x250;
1331static const u32 bnx2_TPAT_b06FwSbssAddr = 0x08001a60;
1332static const int bnx2_TPAT_b06FwSbssLen = 0x34;
1333static u8 bnx2_TPAT_b06FwText[] = { 1668static u8 bnx2_TPAT_b06FwText[] = {
1334 0x1f, 0x8b, 0x08, 0x08, 0x47, 0xd2, 0x41, 0x44, 0x00, 0x03, 0x74, 0x65, 1669 0x1f, 0x8b, 0x08, 0x08, 0x47, 0xd2, 0x41, 0x44, 0x00, 0x03, 0x74, 0x65,
1335 0x73, 0x74, 0x31, 0x2e, 0x62, 0x69, 0x6e, 0x00, 0xc5, 0x57, 0x4d, 0x68, 1670 0x73, 0x74, 0x31, 0x2e, 0x62, 0x69, 0x6e, 0x00, 0xc5, 0x57, 0x4d, 0x68,
@@ -1529,20 +1864,40 @@ static u32 bnx2_TPAT_b06FwRodata[(0x0/4) + 1] = { 0x0 };
1529static u32 bnx2_TPAT_b06FwBss[(0x250/4) + 1] = { 0x0 }; 1864static u32 bnx2_TPAT_b06FwBss[(0x250/4) + 1] = { 0x0 };
1530static u32 bnx2_TPAT_b06FwSbss[(0x34/4) + 1] = { 0x0 }; 1865static u32 bnx2_TPAT_b06FwSbss[(0x34/4) + 1] = { 0x0 };
1531 1866
1532static const int bnx2_TXP_b06FwReleaseMajor = 0x1; 1867static struct fw_info bnx2_tpat_fw_06 = {
1533static const int bnx2_TXP_b06FwReleaseMinor = 0x0; 1868 .ver_major = 0x1,
1534static const int bnx2_TXP_b06FwReleaseFix = 0x0; 1869 .ver_minor = 0x0,
1535static const u32 bnx2_TXP_b06FwStartAddr = 0x080034b0; 1870 .ver_fix = 0x0,
1536static const u32 bnx2_TXP_b06FwTextAddr = 0x08000000; 1871
1537static const int bnx2_TXP_b06FwTextLen = 0x5748; 1872 .start_addr = 0x08000860,
1538static const u32 bnx2_TXP_b06FwDataAddr = 0x08005760; 1873
1539static const int bnx2_TXP_b06FwDataLen = 0x0; 1874 .text_addr = 0x08000800,
1540static const u32 bnx2_TXP_b06FwRodataAddr = 0x00000000; 1875 .text_len = 0x122c,
1541static const int bnx2_TXP_b06FwRodataLen = 0x0; 1876 .text_index = 0x0,
1542static const u32 bnx2_TXP_b06FwBssAddr = 0x080057a0; 1877 .gz_text = bnx2_TPAT_b06FwText,
1543static const int bnx2_TXP_b06FwBssLen = 0x1c4; 1878 .gz_text_len = sizeof(bnx2_TPAT_b06FwText),
1544static const u32 bnx2_TXP_b06FwSbssAddr = 0x08005760; 1879
1545static const int bnx2_TXP_b06FwSbssLen = 0x38; 1880 .data_addr = 0x08001a60,
1881 .data_len = 0x0,
1882 .data_index = 0x0,
1883 .data = bnx2_TPAT_b06FwData,
1884
1885 .sbss_addr = 0x08001a60,
1886 .sbss_len = 0x34,
1887 .sbss_index = 0x0,
1888 .sbss = bnx2_TPAT_b06FwSbss,
1889
1890 .bss_addr = 0x08001aa0,
1891 .bss_len = 0x250,
1892 .bss_index = 0x0,
1893 .bss = bnx2_TPAT_b06FwBss,
1894
1895 .rodata_addr = 0x00000000,
1896 .rodata_len = 0x0,
1897 .rodata_index = 0x0,
1898 .rodata = bnx2_TPAT_b06FwRodata,
1899};
1900
1546static u8 bnx2_TXP_b06FwText[] = { 1901static u8 bnx2_TXP_b06FwText[] = {
1547 0x1f, 0x8b, 0x08, 0x08, 0x21, 0xd3, 0x41, 0x44, 0x00, 0x03, 0x74, 0x65, 1902 0x1f, 0x8b, 0x08, 0x08, 0x21, 0xd3, 0x41, 0x44, 0x00, 0x03, 0x74, 0x65,
1548 0x73, 0x74, 0x31, 0x2e, 0x62, 0x69, 0x6e, 0x00, 0xed, 0x5c, 0x6d, 0x6c, 1903 0x73, 0x74, 0x31, 0x2e, 0x62, 0x69, 0x6e, 0x00, 0xed, 0x5c, 0x6d, 0x6c,
@@ -1964,3 +2319,38 @@ static u32 bnx2_TXP_b06FwData[(0x0/4) + 1] = { 0x0 };
1964static u32 bnx2_TXP_b06FwRodata[(0x0/4) + 1] = { 0x0 }; 2319static u32 bnx2_TXP_b06FwRodata[(0x0/4) + 1] = { 0x0 };
1965static u32 bnx2_TXP_b06FwBss[(0x1c4/4) + 1] = { 0x0 }; 2320static u32 bnx2_TXP_b06FwBss[(0x1c4/4) + 1] = { 0x0 };
1966static u32 bnx2_TXP_b06FwSbss[(0x38/4) + 1] = { 0x0 }; 2321static u32 bnx2_TXP_b06FwSbss[(0x38/4) + 1] = { 0x0 };
2322
2323static struct fw_info bnx2_txp_fw_06 = {
2324 .ver_major = 0x1,
2325 .ver_minor = 0x0,
2326 .ver_fix = 0x0,
2327
2328 .start_addr = 0x080034b0,
2329
2330 .text_addr = 0x08000000,
2331 .text_len = 0x5748,
2332 .text_index = 0x0,
2333 .gz_text = bnx2_TXP_b06FwText,
2334 .gz_text_len = sizeof(bnx2_TXP_b06FwText),
2335
2336 .data_addr = 0x08005760,
2337 .data_len = 0x0,
2338 .data_index = 0x0,
2339 .data = bnx2_TXP_b06FwData,
2340
2341 .sbss_addr = 0x08005760,
2342 .sbss_len = 0x38,
2343 .sbss_index = 0x0,
2344 .sbss = bnx2_TXP_b06FwSbss,
2345
2346 .bss_addr = 0x080057a0,
2347 .bss_len = 0x1c4,
2348 .bss_index = 0x0,
2349 .bss = bnx2_TXP_b06FwBss,
2350
2351 .rodata_addr = 0x00000000,
2352 .rodata_len = 0x0,
2353 .rodata_index = 0x0,
2354 .rodata = bnx2_TXP_b06FwRodata,
2355};
2356
diff --git a/drivers/net/bnx2_fw2.h b/drivers/net/bnx2_fw2.h
new file mode 100644
index 000000000000..680c769a3fc0
--- /dev/null
+++ b/drivers/net/bnx2_fw2.h
@@ -0,0 +1,4086 @@
1/* bnx2_fw2.h: Broadcom NX2 network driver.
2 *
3 * Copyright (c) 2006 Broadcom Corporation
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, except as noted below.
8 *
9 * This file contains firmware data derived from proprietary unpublished
10 * source code, Copyright (c) 2006 Broadcom Corporation.
11 *
12 * Permission is hereby granted for the distribution of this firmware data
13 * in hexadecimal or equivalent format, provided this copyright notice is
14 * accompanying it.
15 */
16
17static u8 bnx2_COM_b09FwText[] = {
18 0x1f, 0x8b, 0x08, 0x08, 0xac, 0xfb, 0x2f, 0x45, 0x00, 0x03, 0x74, 0x65,
19 0x73, 0x74, 0x31, 0x2e, 0x62, 0x69, 0x6e, 0x00, 0xdc, 0x5b, 0x6b, 0x70,
20 0x1b, 0xd7, 0x75, 0x3e, 0xfb, 0x00, 0x09, 0x91, 0x10, 0xb5, 0xa4, 0x60,
21 0x1a, 0x96, 0x68, 0x07, 0x20, 0x57, 0x22, 0x6a, 0xb1, 0x29, 0x4c, 0x33,
22 0x16, 0x9b, 0xc2, 0x12, 0x02, 0x50, 0xae, 0x26, 0xc3, 0x3a, 0x94, 0xcd,
23 0xd8, 0x4a, 0xaa, 0xc9, 0x30, 0x00, 0xa5, 0xf4, 0x61, 0xb7, 0x92, 0xab,
24 0xa9, 0x5d, 0xd7, 0xaa, 0x21, 0x92, 0x6a, 0xf5, 0x83, 0xe5, 0x2a, 0x16,
25 0x43, 0xa9, 0xd3, 0x74, 0xc2, 0x12, 0x56, 0xac, 0x4e, 0x31, 0x85, 0xfc,
26 0xd6, 0x38, 0xb1, 0xc9, 0x4a, 0x76, 0xeb, 0xf4, 0xe1, 0xa6, 0x33, 0xcd,
27 0xa3, 0x9d, 0x36, 0xf6, 0xa8, 0x3f, 0xea, 0xe9, 0xd3, 0x33, 0x6e, 0xa7,
28 0xea, 0xd8, 0x0e, 0xfa, 0x7d, 0x77, 0x77, 0x81, 0x25, 0x48, 0xbd, 0xfc,
29 0xc8, 0x8f, 0x70, 0x06, 0xb3, 0x7b, 0xef, 0xde, 0xbd, 0xf7, 0xdc, 0xf3,
30 0xf8, 0xce, 0x63, 0x2f, 0xfb, 0x44, 0x5a, 0xc4, 0xfb, 0x5b, 0x8b, 0x5f,
31 0xfc, 0xfe, 0x5f, 0x2d, 0x7c, 0x7c, 0xf0, 0xe3, 0xfd, 0x22, 0xb7, 0xdc,
32 0xa2, 0xb7, 0x86, 0x75, 0xf6, 0x1b, 0xf8, 0x45, 0xf1, 0xeb, 0xf7, 0xee,
33 0x57, 0xfb, 0xb3, 0xf0, 0x7b, 0x13, 0x0f, 0xc7, 0xfe, 0x55, 0x44, 0xbb,
34 0xc4, 0x98, 0xe0, 0x5f, 0xb5, 0x7a, 0xf9, 0xe7, 0x5c, 0x38, 0x7e, 0x89,
35 0x67, 0x86, 0xbb, 0x9c, 0xa2, 0x97, 0x3f, 0x09, 0xeb, 0x69, 0x39, 0x94,
36 0xb5, 0x25, 0x6c, 0xa4, 0xdf, 0x3c, 0x54, 0xb0, 0x45, 0x32, 0xe5, 0x2d,
37 0xf1, 0x9c, 0xbc, 0x57, 0x2d, 0x46, 0x4d, 0x61, 0xff, 0x8d, 0xe9, 0x77,
38 0xbf, 0xf6, 0xe2, 0xd6, 0xc4, 0x5b, 0xf3, 0x86, 0x84, 0xad, 0xf4, 0x19,
39 0xb1, 0x36, 0x4b, 0xb8, 0x0b, 0xef, 0x7c, 0xb5, 0xf7, 0x3d, 0x91, 0x36,
40 0x7f, 0xae, 0x37, 0xab, 0x2f, 0xf6, 0x4a, 0x71, 0x43, 0x3a, 0x2c, 0x7a,
41 0x7a, 0xd3, 0xf7, 0xb3, 0x86, 0x35, 0x66, 0xa4, 0x2d, 0x59, 0xac, 0xc8,
42 0xc8, 0xde, 0x69, 0x09, 0x87, 0xd3, 0x47, 0x9b, 0x9b, 0x37, 0x49, 0xd8,
43 0x4c, 0x8f, 0x1d, 0xfa, 0x6d, 0xfb, 0xd1, 0xaa, 0x6e, 0xdb, 0xc9, 0x05,
44 0x89, 0x0c, 0x9e, 0x1a, 0xc0, 0xf3, 0x72, 0x22, 0x29, 0xb2, 0x55, 0x74,
45 0xbb, 0x18, 0x31, 0xec, 0xb0, 0x64, 0x2b, 0xb6, 0xe4, 0x2a, 0x22, 0x7f,
46 0x5e, 0xd6, 0xe4, 0x94, 0xdd, 0x29, 0x0b, 0x7d, 0xef, 0x56, 0x33, 0xa0,
47 0xe5, 0xcf, 0xec, 0xb1, 0x43, 0x53, 0x36, 0xe9, 0x9d, 0x6d, 0x76, 0xe9,
48 0x9d, 0x6a, 0x2a, 0xd8, 0xa6, 0x4c, 0x94, 0xd9, 0x37, 0xa2, 0xb3, 0x2f,
49 0x94, 0x7e, 0x68, 0xcd, 0x29, 0x3b, 0xe2, 0xf5, 0xed, 0xdc, 0x9e, 0xc5,
50 0x7c, 0x93, 0x65, 0x8e, 0x3d, 0x93, 0x2a, 0xd8, 0x51, 0xaf, 0x3f, 0x79,
51 0x5b, 0xd6, 0x8e, 0xa1, 0xbf, 0xcb, 0x7b, 0x76, 0xf2, 0xbe, 0x82, 0x6d,
52 0x7b, 0xcf, 0xbe, 0x8a, 0xb9, 0x93, 0x5e, 0xff, 0x7d, 0xdb, 0x0a, 0x76,
53 0x9f, 0xd7, 0x3f, 0xbd, 0x2d, 0x6b, 0xa7, 0xbc, 0xfe, 0xe4, 0xee, 0x82,
54 0x3d, 0xe0, 0xf5, 0x9f, 0xbd, 0x3d, 0x6b, 0x0f, 0x7a, 0xfd, 0x0f, 0x6d,
55 0x2d, 0xd8, 0x69, 0xf4, 0x1f, 0x6d, 0xd6, 0x37, 0x59, 0x72, 0xa4, 0x1c,
56 0xc7, 0x2f, 0x83, 0x67, 0x43, 0xe8, 0xdb, 0x89, 0xdf, 0x30, 0x7e, 0xbf,
57 0xb8, 0x4e, 0xda, 0x46, 0x70, 0xfd, 0xc6, 0x46, 0x97, 0x77, 0xe0, 0x91,
58 0x13, 0x96, 0x37, 0x8c, 0x98, 0xbc, 0xd8, 0xfb, 0x06, 0x78, 0x68, 0xc9,
59 0x99, 0x8a, 0x68, 0x23, 0xbd, 0x31, 0xf0, 0x2e, 0x2a, 0x4f, 0x56, 0x5a,
60 0xc5, 0x78, 0xcc, 0x00, 0x6f, 0x3e, 0x2f, 0xf9, 0x68, 0x58, 0xda, 0xe7,
61 0x34, 0xe9, 0xee, 0x0f, 0x4b, 0xc6, 0x52, 0x72, 0x13, 0x7d, 0x26, 0x2a,
62 0xc6, 0x5c, 0x66, 0xbd, 0x2e, 0x9b, 0xac, 0x9c, 0x14, 0xc1, 0xbb, 0xef,
63 0x51, 0x27, 0xf1, 0x2c, 0x2e, 0xb9, 0xe9, 0x9b, 0x65, 0xcc, 0x22, 0x5d,
64 0x3b, 0x6f, 0x74, 0xd7, 0x0a, 0x6b, 0xd9, 0x13, 0x23, 0x72, 0xc4, 0x89,
65 0x68, 0xb9, 0x13, 0xdb, 0x24, 0x9b, 0x92, 0x28, 0xde, 0x8b, 0xe5, 0xf1,
66 0xa4, 0x54, 0x1e, 0x91, 0x29, 0x47, 0xb4, 0xac, 0x43, 0x7e, 0x76, 0xe2,
67 0x79, 0x9b, 0x1a, 0x8b, 0xbe, 0x2e, 0x43, 0xcd, 0x1d, 0x46, 0xbf, 0x85,
68 0xfe, 0x0e, 0x6d, 0x48, 0xcd, 0xa1, 0xfa, 0xe3, 0x93, 0x12, 0x91, 0xc7,
69 0xcb, 0x51, 0x6f, 0x6c, 0xb5, 0x9a, 0x4d, 0x59, 0x18, 0x37, 0x22, 0x93,
70 0x4e, 0x54, 0xc6, 0x70, 0x9d, 0x70, 0xb8, 0x7e, 0x0c, 0x3a, 0xf5, 0xda,
71 0xa1, 0xfc, 0xac, 0x9a, 0x2f, 0x6e, 0xa4, 0x39, 0x5f, 0x17, 0xc6, 0x4d,
72 0x80, 0x2e, 0x4d, 0x4c, 0x25, 0xcb, 0x8c, 0xe4, 0xa7, 0x35, 0xe8, 0x1b,
73 0xae, 0x8a, 0xaf, 0x43, 0xa0, 0xdf, 0x14, 0xbb, 0x5f, 0x93, 0x02, 0x64,
74 0x55, 0xb4, 0xd0, 0x2e, 0x9f, 0xd5, 0xb3, 0x4e, 0xb3, 0xe4, 0xcc, 0xb8,
75 0x18, 0x33, 0x4a, 0x97, 0x64, 0x12, 0xef, 0xe8, 0x36, 0xc7, 0x5c, 0xc4,
76 0xbe, 0xc7, 0x94, 0x1c, 0x9a, 0xd2, 0x45, 0x3d, 0x57, 0xe9, 0x14, 0x7d,
77 0x6e, 0x8f, 0xbc, 0x3c, 0x2d, 0x96, 0x91, 0x7e, 0xb7, 0x9a, 0xb5, 0xa7,
78 0xf4, 0xec, 0x13, 0xa6, 0x84, 0x66, 0x34, 0x99, 0xb2, 0x13, 0xb0, 0x80,
79 0xa3, 0xfa, 0x8e, 0xca, 0x59, 0x8c, 0xe3, 0x7b, 0x18, 0x57, 0xd6, 0xc1,
80 0x57, 0xde, 0x6f, 0xb1, 0x74, 0xa5, 0xcf, 0x1c, 0x03, 0x19, 0x60, 0x1f,
81 0x4f, 0x3a, 0x90, 0x89, 0x92, 0x51, 0x1c, 0x32, 0x7a, 0x15, 0x32, 0x1a,
82 0x80, 0x6c, 0x52, 0xf2, 0x52, 0xa5, 0x4f, 0x9e, 0xaf, 0x24, 0xe5, 0x39,
83 0xe8, 0xeb, 0xb3, 0x95, 0xb8, 0x3c, 0x53, 0xe9, 0x92, 0xa7, 0x2b, 0x31,
84 0x79, 0x4a, 0xc9, 0x2d, 0x07, 0xdb, 0x50, 0xb2, 0x0c, 0x5f, 0x9f, 0x96,
85 0x70, 0x27, 0xe4, 0xd1, 0x01, 0xfd, 0x69, 0x87, 0x6e, 0x7e, 0xa5, 0x37,
86 0x2c, 0xb3, 0xbd, 0x92, 0x59, 0x8f, 0xfe, 0x9b, 0xd2, 0xa6, 0xe2, 0x91,
87 0x89, 0xe7, 0x93, 0xd3, 0x21, 0xc9, 0x59, 0x8f, 0xcb, 0x85, 0x19, 0x53,
88 0x26, 0x2b, 0xdb, 0x6f, 0x72, 0x65, 0xc6, 0xf6, 0xbc, 0x9c, 0x9f, 0x69,
89 0xc2, 0xb3, 0x79, 0x79, 0x79, 0xb3, 0x2e, 0x13, 0xb3, 0x6f, 0x89, 0x09,
90 0x1e, 0x0e, 0x29, 0x79, 0x3f, 0x2e, 0xff, 0xfc, 0x27, 0x22, 0x23, 0xe0,
91 0x8b, 0xde, 0xff, 0xef, 0xd5, 0x8c, 0x05, 0x7e, 0xf4, 0xf7, 0x41, 0x3f,
92 0x74, 0x5c, 0x29, 0xcf, 0x38, 0xc6, 0x98, 0x5a, 0xce, 0x39, 0x0d, 0x9b,
93 0x6a, 0xd5, 0xb2, 0xc7, 0x45, 0x0a, 0xc7, 0xab, 0x52, 0x48, 0x85, 0xe4,
94 0x01, 0xab, 0x2a, 0x43, 0xa9, 0x26, 0x39, 0x60, 0x75, 0xca, 0x44, 0xdf,
95 0xcf, 0x68, 0x3e, 0x96, 0x7d, 0xa5, 0x92, 0xc6, 0x3d, 0xfb, 0x44, 0x66,
96 0xd5, 0xbd, 0xdb, 0x5f, 0xac, 0x84, 0x24, 0x13, 0x2d, 0xc6, 0x4c, 0xb9,
97 0xa0, 0xb9, 0xb4, 0xed, 0xf4, 0x9f, 0x41, 0x5e, 0x63, 0xc0, 0x90, 0x84,
98 0xd2, 0xa5, 0xfc, 0xf4, 0x9a, 0x8b, 0x19, 0xd5, 0x1d, 0x52, 0x7a, 0x6a,
99 0xa4, 0x4d, 0xd2, 0x31, 0xa6, 0xa5, 0xa3, 0xd2, 0xad, 0xec, 0x64, 0x00,
100 0x63, 0x06, 0xb5, 0xbb, 0x2b, 0x94, 0x37, 0xee, 0xcb, 0xa4, 0x75, 0x03,
101 0xc6, 0x9a, 0xb8, 0x66, 0x3c, 0x9a, 0x83, 0x74, 0x72, 0x2e, 0xd2, 0xc9,
102 0xeb, 0xde, 0x00, 0x9d, 0xfb, 0x6a, 0xf7, 0xb3, 0x81, 0xfb, 0x62, 0xe5,
103 0xd7, 0x5b, 0x5c, 0xfa, 0xc8, 0xd7, 0x41, 0x99, 0x98, 0x7e, 0xc8, 0x5b,
104 0x0b, 0xf7, 0x65, 0xae, 0xb1, 0x00, 0x3e, 0xa9, 0x91, 0x57, 0x58, 0xab,
105 0x18, 0x58, 0xeb, 0x70, 0x60, 0xad, 0xc3, 0x81, 0xb5, 0x8a, 0xe0, 0xad,
106 0xac, 0xd3, 0x81, 0x33, 0x79, 0xc2, 0xbc, 0x1c, 0xc5, 0x9c, 0x6f, 0x88,
107 0x91, 0xa6, 0x2d, 0xf8, 0x36, 0xf9, 0x07, 0x18, 0x9f, 0x96, 0x73, 0x0e,
108 0x78, 0x73, 0x3c, 0x24, 0x77, 0xa9, 0x71, 0xff, 0xb1, 0xc6, 0xa5, 0x31,
109 0xf8, 0x2c, 0x2c, 0xbb, 0xa2, 0xbc, 0xf7, 0x9f, 0x99, 0xe0, 0x37, 0xdb,
110 0x93, 0x37, 0xb8, 0x6d, 0xde, 0x9f, 0xf5, 0xf6, 0xd2, 0xee, 0xbe, 0x57,
111 0x79, 0x53, 0x61, 0xc6, 0x62, 0x85, 0xb6, 0x2d, 0x29, 0xc3, 0x96, 0xfd,
112 0x43, 0xa9, 0x4e, 0x99, 0xb4, 0xb4, 0xd4, 0x44, 0xb2, 0x99, 0xfc, 0xcf,
113 0xe8, 0x76, 0x2b, 0xec, 0x47, 0xe2, 0x3a, 0x71, 0x51, 0xed, 0xeb, 0x5b,
114 0x1e, 0xfd, 0x16, 0xdb, 0x23, 0xba, 0xdd, 0xd1, 0xd0, 0x4f, 0xfd, 0xff,
115 0x4b, 0xdc, 0xd3, 0x06, 0xfa, 0x75, 0x77, 0xed, 0xbf, 0x42, 0x9b, 0x58,
116 0x15, 0xf1, 0xda, 0xfe, 0xf3, 0xff, 0x32, 0x96, 0xb7, 0x8f, 0x6d, 0x5c,
117 0xde, 0xf6, 0x6d, 0x29, 0x88, 0x73, 0xdc, 0x2b, 0x6c, 0xd8, 0xa6, 0xfe,
118 0x85, 0x40, 0x6b, 0x0a, 0x36, 0xdc, 0xec, 0xd1, 0xf0, 0xba, 0x47, 0x03,
119 0x68, 0xc5, 0xb8, 0x89, 0x0a, 0xdf, 0x51, 0xa2, 0x6c, 0x68, 0x93, 0xf7,
120 0xfe, 0xfd, 0x5a, 0xf5, 0xfc, 0x0d, 0x83, 0xeb, 0xf8, 0x57, 0xd1, 0x86,
121 0x60, 0x67, 0x93, 0xb3, 0xa6, 0xe4, 0x53, 0x31, 0x65, 0x0f, 0xf9, 0x54,
122 0x1d, 0x3f, 0x26, 0xa7, 0x1b, 0xf1, 0x83, 0xef, 0x11, 0x3f, 0x5c, 0xec,
123 0x98, 0x98, 0x25, 0x8e, 0xd4, 0x71, 0xe3, 0xc8, 0xb4, 0x8f, 0x25, 0x9c,
124 0x9b, 0x18, 0xe2, 0xe3, 0x07, 0xdf, 0x23, 0x7e, 0x18, 0x90, 0x15, 0xe7,
125 0xf4, 0xd7, 0x9f, 0x6a, 0x98, 0x7b, 0x4a, 0x61, 0x93, 0x8b, 0xcb, 0x6f,
126 0x06, 0x70, 0xbe, 0x0b, 0x18, 0x1d, 0x85, 0xfc, 0x7c, 0x8c, 0x26, 0x76,
127 0xc6, 0x80, 0xeb, 0xe0, 0x91, 0xc2, 0xe4, 0x08, 0x70, 0xcc, 0xf4, 0x30,
128 0x35, 0xec, 0x61, 0x6a, 0x04, 0x78, 0xca, 0xb6, 0xe5, 0xb5, 0xa3, 0x5e,
129 0x3b, 0x86, 0x36, 0xfc, 0xef, 0x1c, 0x6d, 0xec, 0xb5, 0x43, 0xe3, 0xb3,
130 0x0a, 0xa7, 0x89, 0xf1, 0xc0, 0x0a, 0xe2, 0x2c, 0xf1, 0xb6, 0x4b, 0x16,
131 0xca, 0x58, 0xaf, 0x86, 0x69, 0x94, 0x47, 0x90, 0x1e, 0xd2, 0xb2, 0x46,
132 0xf4, 0xc7, 0xdc, 0xfd, 0xe8, 0xe9, 0xcf, 0xeb, 0xd2, 0xc2, 0x7d, 0x90,
133 0xee, 0x1b, 0x41, 0x2b, 0xf7, 0xf6, 0xa3, 0xa4, 0x95, 0xeb, 0x35, 0xd2,
134 0x7b, 0x1a, 0xf4, 0x66, 0x80, 0xb7, 0xa2, 0x8d, 0xf6, 0x8e, 0x82, 0xde,
135 0x11, 0x60, 0xf1, 0x30, 0xb0, 0x78, 0x27, 0xb0, 0x78, 0x08, 0x58, 0x9c,
136 0x06, 0x0e, 0x0f, 0x02, 0x87, 0x07, 0x80, 0xc3, 0x29, 0xec, 0x2b, 0x2a,
137 0xf3, 0xc0, 0xe5, 0x79, 0xe0, 0xf3, 0x3c, 0xe4, 0x35, 0x31, 0x27, 0xda,
138 0x17, 0xb0, 0xfe, 0x63, 0x33, 0x89, 0xd3, 0xd0, 0xcd, 0x58, 0x51, 0x87,
139 0x3d, 0xa5, 0x06, 0xa1, 0x23, 0x49, 0x29, 0x55, 0x46, 0xa5, 0x40, 0x3f,
140 0xb6, 0xb9, 0x07, 0xb6, 0x0b, 0xfb, 0x89, 0xf9, 0x71, 0xd3, 0x5a, 0xef,
141 0xfa, 0xf7, 0x22, 0xf6, 0x1f, 0x83, 0x27, 0x89, 0xb8, 0xc8, 0xb0, 0xe4,
142 0x9d, 0x1e, 0x2b, 0xab, 0x27, 0x31, 0x8e, 0xed, 0xb8, 0xb6, 0xf7, 0x78,
143 0x42, 0x1b, 0x3f, 0xce, 0x3d, 0x4d, 0x03, 0xe3, 0xaa, 0x32, 0x95, 0xa2,
144 0xad, 0x56, 0xe5, 0x54, 0x2a, 0x31, 0x58, 0x94, 0x56, 0x39, 0x12, 0x9d,
145 0x56, 0xfe, 0xcd, 0x4c, 0x1f, 0x53, 0xfa, 0x51, 0xb0, 0x71, 0x2d, 0x77,
146 0x6b, 0xf9, 0xe3, 0xf4, 0x3b, 0x3d, 0xf8, 0x85, 0x40, 0x0b, 0xe7, 0x37,
147 0x65, 0x68, 0x40, 0xb4, 0x7d, 0xbd, 0x45, 0xa0, 0x62, 0xc2, 0x3a, 0x87,
148 0x95, 0x73, 0xd3, 0x3d, 0xb1, 0x9c, 0x6e, 0xca, 0x98, 0xa9, 0xc9, 0x04,
149 0xec, 0x65, 0x28, 0xf5, 0x7f, 0xd5, 0x23, 0x51, 0x3e, 0x6f, 0x96, 0xdf,
150 0x51, 0x38, 0x8b, 0xb5, 0x4b, 0xb3, 0x58, 0x37, 0x04, 0xfe, 0x71, 0x5d,
151 0xce, 0x83, 0x36, 0x30, 0xcf, 0xb4, 0x13, 0xa7, 0x8b, 0xb2, 0x1d, 0x76,
152 0xb7, 0x4e, 0xb2, 0x7d, 0x4d, 0x92, 0x19, 0x89, 0xcb, 0xc4, 0xcc, 0x76,
153 0xe0, 0x1e, 0x64, 0x60, 0xb7, 0x48, 0x7e, 0x34, 0x2e, 0x5f, 0x9e, 0x61,
154 0x5f, 0x06, 0xfb, 0x4f, 0x1c, 0xcd, 0x08, 0xf7, 0x1f, 0x52, 0xfb, 0x8a,
155 0xeb, 0x19, 0x39, 0xe0, 0xbc, 0xa4, 0xbb, 0x76, 0xe9, 0xb6, 0xf7, 0x42,
156 0x1e, 0xa7, 0xc0, 0xef, 0xbc, 0x63, 0xcb, 0x02, 0xfc, 0x4a, 0xee, 0x38,
157 0x70, 0xd5, 0x6e, 0x03, 0x06, 0x26, 0xce, 0xd2, 0x3e, 0x0c, 0xc4, 0x5a,
158 0x25, 0xc5, 0xeb, 0x2e, 0x39, 0x3e, 0xa3, 0xcb, 0xb3, 0xb7, 0xc5, 0xd1,
159 0x06, 0xd6, 0xa6, 0x12, 0x67, 0xc6, 0xf4, 0x2e, 0xb9, 0xb5, 0x23, 0x86,
160 0xf7, 0x52, 0x5a, 0xde, 0xf9, 0x37, 0xf2, 0xf2, 0x64, 0x5c, 0xe7, 0x58,
161 0x5d, 0x72, 0x29, 0x03, 0x3a, 0x56, 0xc4, 0xf8, 0x7f, 0x40, 0x7f, 0x97,
162 0xcc, 0x21, 0xbe, 0x99, 0x03, 0x4d, 0xd9, 0x14, 0xb1, 0x30, 0x71, 0x72,
163 0x49, 0x07, 0x66, 0xcd, 0x41, 0x37, 0x47, 0x11, 0x3f, 0xcc, 0xfc, 0x37,
164 0xc6, 0xc4, 0x21, 0xd3, 0x1e, 0x6b, 0x02, 0xf8, 0x92, 0xe9, 0xe2, 0x3d,
165 0xe7, 0xb4, 0xe5, 0x94, 0x43, 0x1d, 0x8a, 0xcb, 0xe3, 0x15, 0xbe, 0xd7,
166 0x73, 0xf6, 0x69, 0xb1, 0xe5, 0x41, 0xe7, 0x7f, 0x30, 0xfe, 0x1d, 0xc4,
167 0x9e, 0x96, 0x94, 0x20, 0xb7, 0x02, 0x78, 0x99, 0x89, 0xb9, 0xed, 0x89,
168 0xb9, 0xc4, 0xd9, 0x0b, 0x3a, 0xef, 0xed, 0xe2, 0x82, 0x7e, 0xb3, 0x48,
169 0x07, 0xf9, 0x99, 0x02, 0x2f, 0x6d, 0x4b, 0xd7, 0x37, 0x7b, 0xf1, 0x16,
170 0x6d, 0xc0, 0x06, 0x7d, 0xa6, 0x2c, 0xf4, 0x07, 0x6d, 0x80, 0x7e, 0xd6,
171 0xb7, 0x81, 0x44, 0x6c, 0x49, 0xd7, 0xf1, 0xdc, 0x94, 0x63, 0xaa, 0xad,
172 0x81, 0xd6, 0x44, 0x8c, 0xfb, 0x9b, 0x2c, 0x27, 0xe5, 0x71, 0x87, 0xe3,
173 0xc1, 0xe7, 0xe9, 0x88, 0x37, 0x1e, 0xf1, 0x8e, 0xc3, 0x98, 0x29, 0x09,
174 0x9a, 0x5d, 0xbb, 0x58, 0x98, 0x8e, 0xaa, 0x67, 0x47, 0x1c, 0x37, 0x36,
175 0xd2, 0x11, 0x3f, 0xcd, 0x23, 0x7e, 0xca, 0x29, 0x1b, 0xb1, 0x32, 0x88,
176 0xaf, 0xe1, 0x67, 0x5d, 0xfb, 0x28, 0x95, 0x49, 0xcb, 0x3d, 0xa0, 0x2f,
177 0x51, 0x04, 0x31, 0xc7, 0x74, 0xb8, 0xeb, 0xec, 0x80, 0x14, 0x19, 0x63,
178 0x9d, 0x33, 0x1e, 0x91, 0xb1, 0x12, 0xfd, 0x1b, 0x7e, 0x8e, 0x6d, 0x31,
179 0xa6, 0xcf, 0x28, 0xdf, 0xd3, 0x03, 0x3d, 0x80, 0x5f, 0x4a, 0xb5, 0x8b,
180 0xeb, 0x07, 0xf7, 0x40, 0x9e, 0xc3, 0x90, 0x7b, 0x5a, 0xc6, 0x4f, 0x8c,
181 0x53, 0xa7, 0x93, 0x25, 0x49, 0x24, 0x8f, 0xc8, 0x16, 0x6b, 0x01, 0xbe,
182 0x30, 0x33, 0x5a, 0xdd, 0xae, 0xa7, 0xf9, 0xce, 0xa3, 0x78, 0x07, 0xd7,
183 0xd2, 0xb8, 0x3c, 0x50, 0x61, 0xdf, 0x9d, 0x86, 0xb4, 0xc0, 0x56, 0x06,
184 0xf6, 0x78, 0x76, 0x80, 0xf9, 0x4c, 0x7f, 0xbe, 0x71, 0x6f, 0x3e, 0x8e,
185 0xe3, 0x18, 0xbe, 0x53, 0x9f, 0x77, 0x07, 0x7d, 0x1b, 0xb0, 0x64, 0x87,
186 0x5e, 0xdd, 0x1e, 0xc2, 0xf3, 0x53, 0x03, 0xbc, 0xc7, 0x3c, 0xf0, 0x6d,
187 0x96, 0x3d, 0x8c, 0xb1, 0xa3, 0x98, 0x73, 0x8d, 0x64, 0x3b, 0x7d, 0x7a,
188 0xa9, 0x03, 0x8c, 0x3f, 0xd8, 0x8e, 0xae, 0x77, 0x79, 0xff, 0x25, 0xc3,
189 0xd5, 0xc9, 0x11, 0xb4, 0x69, 0x7f, 0x07, 0x25, 0xe7, 0x24, 0xb0, 0x4f,
190 0xf0, 0xb6, 0x32, 0xe1, 0xed, 0x11, 0xfc, 0x1f, 0x39, 0x0c, 0x3e, 0x48,
191 0xd1, 0xe5, 0x0d, 0xf9, 0x42, 0x9e, 0xfc, 0x16, 0x74, 0xff, 0x61, 0x8c,
192 0x81, 0x7f, 0x50, 0x3c, 0x58, 0xea, 0x70, 0x63, 0xd1, 0x44, 0x31, 0xc3,
193 0xfc, 0xa9, 0x83, 0x98, 0x07, 0xfc, 0xa9, 0x40, 0xb1, 0x30, 0xf7, 0x92,
194 0xbe, 0x86, 0xf4, 0xc6, 0x97, 0x0c, 0x83, 0xed, 0xe4, 0x12, 0x74, 0xb8,
195 0x04, 0xf9, 0x64, 0xfb, 0x68, 0xb3, 0x36, 0xe4, 0x31, 0x63, 0x50, 0x5f,
196 0x4b, 0x88, 0x05, 0xf3, 0xce, 0x16, 0xeb, 0x5e, 0xf2, 0xcd, 0xb2, 0xe4,
197 0x69, 0x27, 0x88, 0x1d, 0x3b, 0x30, 0x94, 0x7a, 0x18, 0x85, 0x1e, 0x98,
198 0xf0, 0xc9, 0x31, 0xc8, 0xfc, 0xc5, 0x0e, 0x77, 0x2f, 0xbc, 0x37, 0x65,
199 0xde, 0xc2, 0x9a, 0xce, 0xef, 0xaf, 0x73, 0xfb, 0x78, 0xcf, 0xb8, 0xc8,
200 0x97, 0xab, 0x4f, 0x3b, 0xe5, 0xdb, 0x28, 0xd3, 0x43, 0xd8, 0x0b, 0xfb,
201 0x71, 0x2d, 0x1d, 0x94, 0x71, 0xd0, 0x56, 0x18, 0xd8, 0x14, 0x3b, 0x8f,
202 0xf1, 0x39, 0xe0, 0x79, 0xd1, 0xe4, 0xb3, 0x8b, 0x5a, 0xfd, 0x1d, 0xc4,
203 0x5c, 0x36, 0xfd, 0xd9, 0x92, 0xf6, 0x85, 0xca, 0xcb, 0x5a, 0xb6, 0x74,
204 0x51, 0xcb, 0x41, 0x4f, 0x4a, 0x0e, 0x73, 0x06, 0xda, 0x8f, 0x85, 0xb5,
205 0x13, 0xb1, 0xb7, 0xf5, 0x9e, 0xf8, 0x02, 0xb0, 0x60, 0x2f, 0x6c, 0x3a,
206 0x67, 0xee, 0x94, 0x02, 0xb0, 0x35, 0x7f, 0x62, 0x0b, 0xec, 0x2d, 0x1e,
207 0xa0, 0x8b, 0x78, 0x56, 0xa4, 0x4f, 0xd5, 0x76, 0x38, 0x52, 0x6c, 0x4a,
208 0x13, 0xd7, 0x36, 0x41, 0x77, 0xd0, 0x57, 0xae, 0xeb, 0xdf, 0x1d, 0x2b,
209 0x68, 0x45, 0x7e, 0x39, 0xb0, 0x9c, 0xde, 0x92, 0x5c, 0x99, 0xde, 0x1d,
210 0x35, 0x7a, 0x89, 0x19, 0xc0, 0x7f, 0xd8, 0xcd, 0x4b, 0xd0, 0xdf, 0xe7,
211 0x1d, 0xe0, 0xbf, 0x03, 0xfc, 0x87, 0x4d, 0x3d, 0x03, 0xdd, 0x7b, 0xda,
212 0x81, 0x0f, 0x70, 0xe0, 0x03, 0x1c, 0xf8, 0x00, 0x27, 0x0b, 0x39, 0x11,
213 0xe7, 0xe9, 0x43, 0x76, 0xd7, 0x7c, 0x9e, 0x1b, 0x37, 0xdd, 0xe0, 0xc5,
214 0x22, 0xa3, 0x88, 0x45, 0x36, 0xc8, 0x44, 0xf2, 0x7a, 0xec, 0xad, 0x05,
215 0xd7, 0x56, 0x5c, 0xb1, 0x46, 0xf2, 0x76, 0xcf, 0x4e, 0x1e, 0x06, 0x5d,
216 0x88, 0xbf, 0x93, 0x3f, 0x0d, 0x3d, 0x6c, 0x02, 0x3d, 0x3f, 0xe5, 0xc5,
217 0x2c, 0x0f, 0x9a, 0xae, 0x1e, 0xb6, 0xa2, 0xef, 0x93, 0xe8, 0x6b, 0xc5,
218 0x98, 0x03, 0x18, 0xc3, 0x98, 0xa7, 0xcd, 0xeb, 0x0b, 0x8e, 0x63, 0xec,
219 0xf3, 0x19, 0xac, 0x95, 0xc0, 0xb8, 0x36, 0xcc, 0xdd, 0x85, 0x31, 0xdb,
220 0x30, 0xe6, 0x46, 0xb4, 0x19, 0x33, 0x6f, 0x44, 0xfb, 0x13, 0x0d, 0xef,
221 0x7c, 0x0c, 0x7d, 0xb7, 0x37, 0xf4, 0x9d, 0x43, 0x1f, 0xf2, 0x50, 0xeb,
222 0xbc, 0xf7, 0x5e, 0x11, 0xed, 0xce, 0x86, 0x31, 0xaf, 0xa2, 0x0f, 0x71,
223 0xaf, 0xf5, 0x2d, 0x5c, 0x91, 0x7f, 0x5a, 0xa4, 0xc9, 0x7f, 0xc6, 0xb8,
224 0x37, 0x8e, 0xfe, 0x90, 0x17, 0xbb, 0xfe, 0xa6, 0x09, 0xbd, 0xd3, 0x86,
225 0x9c, 0xdf, 0x30, 0xdd, 0x58, 0xef, 0x4e, 0xcb, 0xd5, 0x43, 0xbf, 0xfd,
226 0x70, 0x43, 0x9b, 0x63, 0x17, 0x1a, 0xfa, 0xfe, 0xa5, 0xa1, 0xfd, 0xdd,
227 0xd0, 0xca, 0x77, 0x06, 0xdb, 0x97, 0xf7, 0x15, 0x3a, 0x96, 0xb7, 0xed,
228 0xa6, 0x95, 0xef, 0xe8, 0xeb, 0x96, 0xf7, 0xdd, 0xb8, 0xbe, 0x61, 0x0c,
229 0x74, 0x2a, 0x8a, 0x1c, 0xc9, 0x1f, 0x1f, 0xbe, 0xce, 0x7d, 0x4e, 0xfe,
230 0x36, 0xea, 0x92, 0xda, 0x3a, 0xda, 0x3a, 0xe4, 0xb0, 0xa4, 0xc1, 0x9e,
231 0x2c, 0x3d, 0xfd, 0xb2, 0x96, 0x83, 0x4e, 0x65, 0x2b, 0xfe, 0x7c, 0xb4,
232 0xd9, 0xc6, 0xdc, 0xdc, 0xcf, 0xc9, 0x19, 0x2b, 0x45, 0xa0, 0x37, 0xf7,
233 0xd0, 0x27, 0x1d, 0x2d, 0x4a, 0xdd, 0x3e, 0xbb, 0xf5, 0x4b, 0xd9, 0xe7,
234 0xed, 0x1e, 0x46, 0x1d, 0x06, 0x9d, 0x55, 0x19, 0x49, 0x35, 0xd3, 0xc7,
235 0x78, 0xd8, 0x45, 0xdc, 0xa9, 0x56, 0x8d, 0xcd, 0x55, 0xd9, 0x9f, 0x7a,
236 0xa7, 0x2a, 0x0a, 0xf3, 0x06, 0x15, 0xee, 0xc4, 0xf5, 0x1e, 0xc8, 0xc8,
237 0x42, 0x6e, 0x82, 0x7c, 0x3a, 0x4a, 0x9f, 0x74, 0x90, 0xf1, 0xc9, 0xa3,
238 0x2e, 0xa6, 0x12, 0x77, 0xd0, 0x46, 0x5e, 0x96, 0x3f, 0xce, 0xf5, 0x71,
239 0x2d, 0x11, 0xc7, 0x47, 0x95, 0x4f, 0xc9, 0x5b, 0x9c, 0x77, 0x35, 0x6c,
240 0x3c, 0x6b, 0x32, 0xa6, 0x33, 0xed, 0xd3, 0xf0, 0x6f, 0x7c, 0xc6, 0x58,
241 0xe1, 0x34, 0xe3, 0x92, 0x00, 0x56, 0x6d, 0x35, 0xe0, 0x32, 0x8b, 0xcb,
242 0xf7, 0xb5, 0x81, 0x79, 0xc4, 0x55, 0xec, 0x75, 0x75, 0x2c, 0xea, 0xd1,
243 0xaf, 0x6c, 0xdb, 0xbb, 0x6a, 0xb6, 0xed, 0xeb, 0xde, 0x6a, 0x39, 0xf8,
244 0xf7, 0x95, 0x2c, 0x9e, 0xaa, 0x24, 0x8e, 0x15, 0x61, 0x4b, 0x8b, 0x2a,
245 0xef, 0xf6, 0xe5, 0xc2, 0x18, 0x27, 0x71, 0x72, 0x1e, 0x6f, 0x8e, 0xab,
246 0x1c, 0x83, 0xf9, 0x45, 0x55, 0x76, 0xa4, 0x5a, 0xa3, 0xe4, 0x43, 0x46,
247 0xff, 0x76, 0x88, 0x31, 0xc3, 0xa2, 0x43, 0x9e, 0xa5, 0xf0, 0x3c, 0x05,
248 0x4c, 0xf8, 0x27, 0xc9, 0x45, 0xd9, 0xf7, 0x76, 0x75, 0x01, 0x71, 0x95,
249 0x8a, 0x8f, 0x94, 0xbf, 0x67, 0x7c, 0xb7, 0x1f, 0xfc, 0x22, 0x4f, 0x47,
250 0xc0, 0x67, 0x3f, 0x06, 0x78, 0x8d, 0x75, 0x15, 0x59, 0x1e, 0x07, 0x8b,
251 0x3c, 0x50, 0x7e, 0x19, 0x73, 0xea, 0x6e, 0xac, 0xc2, 0x3c, 0xdc, 0x66,
252 0x7f, 0x47, 0x88, 0xb1, 0x9c, 0xeb, 0xeb, 0x0d, 0xac, 0x87, 0xdc, 0xbe,
253 0xfc, 0x8f, 0x2a, 0x6e, 0x2a, 0x28, 0x79, 0x20, 0x86, 0xaa, 0xf0, 0x19,
254 0xfb, 0xc2, 0x5e, 0xec, 0x1c, 0xf1, 0x62, 0x65, 0xcb, 0x8b, 0x95, 0x49,
255 0x07, 0x6b, 0x6f, 0x7e, 0x5c, 0x40, 0x99, 0x2d, 0x1d, 0xd2, 0x37, 0x33,
256 0x2e, 0x68, 0x93, 0xd5, 0xe3, 0x02, 0x9f, 0xa6, 0x6d, 0xa0, 0x89, 0x71,
257 0x9e, 0xaa, 0xbd, 0x74, 0xb8, 0xf5, 0x1e, 0xd2, 0xe0, 0xfb, 0x47, 0xe5,
258 0x87, 0x8f, 0xc2, 0xe5, 0x61, 0x6f, 0x69, 0xd0, 0xba, 0x53, 0xb2, 0xd3,
259 0xdb, 0x3c, 0x7f, 0xcb, 0x1c, 0x80, 0xf1, 0xb7, 0xab, 0xb3, 0xd9, 0xd4,
260 0x84, 0x3f, 0x4f, 0x27, 0x3c, 0x64, 0xa0, 0x2e, 0xc4, 0xb5, 0x18, 0xc7,
261 0xf8, 0x31, 0xcd, 0x4e, 0x2f, 0xa6, 0x19, 0x96, 0xfd, 0x8e, 0x1b, 0xf3,
262 0x8f, 0xa0, 0x3f, 0xef, 0x28, 0xda, 0x63, 0x8c, 0x2d, 0x75, 0xc4, 0xdc,
263 0x99, 0x3d, 0x09, 0x24, 0x0f, 0xee, 0x5e, 0xba, 0xb1, 0x97, 0x52, 0x6d,
264 0x2f, 0xad, 0x4b, 0xcb, 0xf7, 0x32, 0xaa, 0xde, 0x9d, 0x5a, 0xf1, 0xae,
265 0x60, 0x1f, 0xbb, 0x2f, 0xf1, 0x8c, 0x7b, 0x64, 0xdc, 0x60, 0x79, 0x7b,
266 0xf4, 0xe5, 0x74, 0x00, 0x7b, 0x4c, 0x6a, 0x79, 0x15, 0x6b, 0xed, 0x51,
267 0x3c, 0xcf, 0x97, 0xc7, 0x70, 0xa5, 0x7d, 0xa8, 0x79, 0x94, 0x8d, 0x4c,
268 0x28, 0x3e, 0x8f, 0xab, 0x7d, 0x2c, 0x94, 0x7f, 0x41, 0x0a, 0x27, 0x7e,
269 0x09, 0x7e, 0x2f, 0x58, 0x0f, 0x63, 0x2d, 0x91, 0xfc, 0x28, 0x06, 0xf0,
270 0x93, 0x7b, 0x65, 0xad, 0xeb, 0x0f, 0x43, 0x6e, 0x7e, 0x10, 0x81, 0x8c,
271 0x35, 0xf7, 0xb9, 0x5a, 0xdf, 0xe7, 0x6b, 0x53, 0x80, 0x9e, 0x2a, 0x62,
272 0xce, 0x18, 0x68, 0x08, 0xbe, 0x73, 0x50, 0x86, 0x1c, 0xca, 0xa3, 0x27,
273 0x36, 0x2e, 0xb6, 0x95, 0x17, 0x3f, 0xce, 0xe0, 0xfa, 0xb4, 0xf9, 0x5c,
274 0xcc, 0x10, 0xd6, 0x2f, 0x7d, 0xde, 0xf9, 0x7c, 0x8b, 0x2c, 0x35, 0xea,
275 0xc0, 0x14, 0xe8, 0x29, 0x38, 0xe4, 0x93, 0xaf, 0x9b, 0xfe, 0xda, 0xaf,
276 0xaa, 0xfd, 0x4c, 0xaa, 0x9a, 0xdd, 0x73, 0x35, 0x1d, 0x9d, 0x40, 0x0c,
277 0xe2, 0xea, 0xdc, 0x7d, 0x1e, 0x6f, 0x7c, 0xdd, 0x8c, 0x78, 0x72, 0x66,
278 0x1e, 0x47, 0xdb, 0xf1, 0xf5, 0x60, 0x93, 0x75, 0xb7, 0xe2, 0x05, 0x9f,
279 0x11, 0x53, 0x5c, 0x59, 0x8e, 0xd5, 0x64, 0xb9, 0xb6, 0x41, 0x2f, 0xbf,
280 0xb7, 0xce, 0xb5, 0x43, 0xda, 0x1b, 0xec, 0x16, 0xf4, 0x3d, 0xb5, 0xcc,
281 0xbe, 0x93, 0x97, 0xa8, 0x83, 0x46, 0xc4, 0x98, 0xfb, 0x53, 0xf0, 0xf2,
282 0x63, 0xc8, 0x55, 0x44, 0xcc, 0x19, 0xe2, 0x10, 0xe3, 0x8d, 0x7a, 0xbc,
283 0xbb, 0x20, 0xab, 0xc5, 0xba, 0x57, 0x8a, 0x35, 0x7e, 0xf2, 0x2a, 0x63,
284 0x8d, 0x78, 0x93, 0xb4, 0x10, 0x8b, 0x86, 0x11, 0xdb, 0x6a, 0xd2, 0x64,
285 0x3f, 0x08, 0x1f, 0x76, 0xc6, 0x6c, 0xb6, 0x7d, 0x4c, 0x88, 0x48, 0xfb,
286 0xdc, 0x06, 0x85, 0x0b, 0xd6, 0x4c, 0x1d, 0x17, 0x26, 0xc0, 0xfb, 0x11,
287 0xb7, 0xb6, 0x1a, 0x6d, 0x97, 0xab, 0xcd, 0x8d, 0xeb, 0x71, 0xff, 0x58,
288 0x2d, 0xee, 0xbf, 0xa1, 0x81, 0x8f, 0xab, 0xe1, 0xe2, 0x19, 0xf0, 0x2d,
289 0x8d, 0xfc, 0x97, 0x79, 0xed, 0x10, 0xf2, 0x61, 0xe6, 0x62, 0x19, 0xe4,
290 0xc4, 0x89, 0x33, 0xc0, 0x2a, 0xe4, 0xc8, 0x89, 0xb7, 0xe0, 0x57, 0x90,
291 0x37, 0x27, 0xe6, 0x99, 0xbb, 0x2e, 0x22, 0x3f, 0x7e, 0x1a, 0xf9, 0xf1,
292 0x53, 0x95, 0x3e, 0xf0, 0x37, 0xa9, 0xb0, 0x73, 0xef, 0x71, 0xd1, 0xee,
293 0x52, 0xf5, 0x61, 0xda, 0x73, 0x14, 0x7e, 0xb4, 0x5a, 0x3d, 0x90, 0xea,
294 0x41, 0x4e, 0x1e, 0x97, 0x4f, 0x99, 0xcc, 0x63, 0x35, 0xb3, 0xbb, 0x7f,
295 0xc1, 0x08, 0xc6, 0xa4, 0xd9, 0x2b, 0xfa, 0x81, 0x95, 0xbc, 0xcf, 0x29,
296 0x5f, 0x70, 0xcc, 0xb8, 0x1c, 0xef, 0xef, 0xaa, 0xf1, 0xfe, 0xc2, 0x1a,
297 0x69, 0x19, 0x56, 0x35, 0x80, 0xee, 0xfe, 0x03, 0xc4, 0xab, 0x14, 0xfc,
298 0x3a, 0xfc, 0x6f, 0x55, 0xee, 0x48, 0x5d, 0xac, 0x9e, 0xb7, 0xd7, 0x49,
299 0xbe, 0xef, 0x8b, 0x1e, 0x66, 0x8f, 0x3d, 0x92, 0xb5, 0x8b, 0xb0, 0x0f,
300 0xb7, 0x16, 0x39, 0x3e, 0x1d, 0x46, 0x14, 0xca, 0xbf, 0x0e, 0x59, 0x18,
301 0xfc, 0x1b, 0xc8, 0x70, 0xcb, 0x69, 0x16, 0xb0, 0x74, 0xe0, 0xf0, 0x42,
302 0x34, 0xa2, 0xea, 0x33, 0xd7, 0xd9, 0xec, 0xb7, 0x20, 0xd3, 0x51, 0x59,
303 0x40, 0xfc, 0x50, 0x1a, 0x04, 0x8d, 0x7d, 0x9d, 0x18, 0x4f, 0xbb, 0x23,
304 0xcf, 0x47, 0xe1, 0x7b, 0xc9, 0xd3, 0x28, 0xc6, 0xef, 0xc2, 0x98, 0x0e,
305 0x5c, 0xbf, 0x68, 0x2c, 0x58, 0xcc, 0x9d, 0x7f, 0x0e, 0x6d, 0xce, 0x11,
306 0xf4, 0x9d, 0x9f, 0x0e, 0x89, 0x9a, 0x93, 0xef, 0x74, 0x2a, 0xfb, 0xaf,
307 0xaf, 0xc5, 0x75, 0xf8, 0xec, 0xbd, 0xea, 0x2d, 0xfd, 0x83, 0x81, 0xf5,
308 0xda, 0x02, 0xeb, 0x0d, 0x06, 0xd6, 0x23, 0x9d, 0x1d, 0x01, 0x3a, 0x3b,
309 0xf0, 0x7e, 0x0e, 0x6b, 0x0f, 0xab, 0x98, 0xa7, 0xbe, 0xe6, 0xfd, 0x81,
310 0x35, 0xfd, 0xfd, 0x75, 0x06, 0xde, 0x7b, 0x07, 0xeb, 0xb1, 0x2f, 0x1a,
311 0xe8, 0x23, 0x0d, 0xeb, 0xd1, 0xc7, 0x76, 0x47, 0x80, 0x2e, 0xd2, 0xba,
312 0x16, 0xfd, 0x2a, 0x7e, 0x02, 0x9f, 0x5b, 0xe0, 0xb7, 0x74, 0xf8, 0x0e,
313 0xd6, 0xa0, 0x1b, 0xf7, 0xfa, 0x65, 0xac, 0xeb, 0xcf, 0x17, 0xc5, 0x1c,
314 0x1c, 0xcf, 0xb1, 0x86, 0xf7, 0x3e, 0xfb, 0xf9, 0xfc, 0x1b, 0xd5, 0xaf,
315 0x2b, 0xbe, 0xad, 0x07, 0xed, 0xaa, 0xee, 0x22, 0xf3, 0x1d, 0x26, 0xe4,
316 0xc9, 0xfc, 0x58, 0x93, 0x9b, 0x6c, 0x5d, 0xeb, 0xe9, 0xa7, 0xec, 0xd7,
317 0x79, 0x58, 0xda, 0xa2, 0x65, 0x8f, 0xb3, 0x5e, 0xd0, 0xea, 0xe5, 0x7c,
318 0xc8, 0x3d, 0x94, 0x8f, 0x31, 0xbd, 0xe7, 0xf4, 0x31, 0x8c, 0x5b, 0xe8,
319 0x3f, 0x33, 0xde, 0x3d, 0xae, 0xd0, 0xe1, 0x7d, 0xa5, 0x0e, 0x39, 0xaf,
320 0x78, 0x6a, 0xc9, 0xb9, 0x1a, 0x4f, 0x43, 0xde, 0xb7, 0x90, 0x83, 0xde,
321 0x77, 0x06, 0x03, 0x71, 0x11, 0xee, 0xcb, 0x19, 0xd0, 0x10, 0x97, 0x9e,
322 0x7e, 0xe6, 0x6e, 0x45, 0x5c, 0x59, 0xa7, 0xd0, 0x70, 0x75, 0xeb, 0x17,
323 0x3d, 0xfd, 0xf0, 0x4b, 0xc0, 0xa1, 0x9e, 0xfe, 0xef, 0xa8, 0x7c, 0xae,
324 0x54, 0xb1, 0xb4, 0x3b, 0x1c, 0xb7, 0x46, 0x74, 0xce, 0xbe, 0x5c, 0x8d,
325 0x68, 0xa0, 0x99, 0x75, 0x0d, 0xbf, 0x46, 0x74, 0x4e, 0x54, 0x8d, 0xe8,
326 0xe4, 0x15, 0x6a, 0x44, 0x99, 0xab, 0xaf, 0x11, 0x71, 0x7e, 0x53, 0xee,
327 0x1e, 0x10, 0xed, 0x4b, 0x5e, 0x8d, 0xe8, 0x82, 0xb8, 0x35, 0xa2, 0xf3,
328 0xb2, 0x7a, 0x8d, 0xe8, 0x68, 0x43, 0x8d, 0x68, 0xbd, 0xaa, 0x11, 0x71,
329 0x1e, 0xb7, 0x46, 0xc4, 0x76, 0xbe, 0x7f, 0x30, 0x50, 0xeb, 0x00, 0xfe,
330 0x3a, 0xb7, 0x82, 0x6f, 0x96, 0x36, 0xea, 0xf8, 0x98, 0x46, 0xec, 0xbf,
331 0xbe, 0xe6, 0xbf, 0xea, 0xf8, 0xa6, 0x29, 0x9d, 0xbb, 0x12, 0xbe, 0x8d,
332 0xba, 0x71, 0xc9, 0x32, 0x6c, 0x9b, 0xaa, 0xc5, 0x2e, 0xbf, 0xdc, 0xcc,
333 0x1c, 0x7a, 0xb2, 0x5c, 0x9f, 0x77, 0x12, 0xf2, 0x1e, 0xab, 0xd5, 0x49,
334 0x2e, 0x15, 0x1f, 0x45, 0xe5, 0xe0, 0xaa, 0xdf, 0x9a, 0x62, 0x99, 0x95,
335 0xdf, 0x9a, 0x34, 0x89, 0x82, 0xce, 0x7c, 0x7f, 0x5e, 0xe5, 0x5d, 0x0b,
336 0xce, 0xcf, 0xcb, 0xd2, 0xbd, 0x16, 0xf0, 0xc7, 0xaf, 0x9f, 0x50, 0xbe,
337 0x75, 0x9f, 0x92, 0xd5, 0x3f, 0xba, 0x1a, 0xca, 0x3e, 0x55, 0x43, 0xf9,
338 0x5a, 0x73, 0xb0, 0x86, 0x72, 0x4e, 0x2e, 0x5f, 0x43, 0xd9, 0xb7, 0x4a,
339 0x0d, 0xe5, 0x15, 0xa9, 0xd7, 0x50, 0x5e, 0x11, 0xbf, 0x86, 0x62, 0xc8,
340 0xd2, 0x7a, 0xce, 0xb3, 0x1f, 0xef, 0x8c, 0xe0, 0x37, 0x8c, 0x9f, 0x5b,
341 0x53, 0x39, 0x57, 0xa3, 0x7f, 0xb5, 0x9a, 0xca, 0x37, 0x9b, 0xdf, 0x4f,
342 0x4d, 0xc5, 0xf5, 0x01, 0x7e, 0x4d, 0xa5, 0x05, 0xf1, 0x0e, 0x7c, 0x8e,
343 0x1e, 0xac, 0xa9, 0xfc, 0x2d, 0xed, 0x01, 0x7d, 0x2a, 0x46, 0x40, 0x3f,
344 0xec, 0x02, 0x7e, 0x29, 0xa3, 0x6a, 0x1c, 0x9f, 0xf6, 0x78, 0xb8, 0x1b,
345 0x7b, 0x8e, 0x43, 0x16, 0xe4, 0x63, 0x8f, 0x8a, 0x2d, 0x33, 0x66, 0x4c,
346 0xcb, 0xf6, 0xc2, 0x9b, 0x4d, 0xf3, 0x5b, 0x74, 0x4c, 0xc6, 0x2b, 0xd4,
347 0xf1, 0x2e, 0xc4, 0xe2, 0x26, 0xfa, 0x76, 0xa3, 0xed, 0xc7, 0x54, 0xfd,
348 0xb5, 0x39, 0x68, 0x9b, 0x0b, 0xc0, 0x59, 0xe0, 0xc4, 0x55, 0xf8, 0xa8,
349 0x6d, 0xa0, 0x39, 0xb8, 0x8f, 0x22, 0xfc, 0x13, 0xfa, 0x94, 0xcc, 0x19,
350 0x5b, 0xfa, 0xb4, 0xc4, 0x69, 0xe7, 0x57, 0x31, 0x1f, 0xfb, 0xb6, 0xa9,
351 0x7c, 0xac, 0x30, 0xc0, 0xbd, 0xd2, 0xd7, 0x2d, 0x82, 0x3e, 0xf4, 0x95,
352 0x98, 0x03, 0xd2, 0xef, 0xf9, 0x39, 0x5a, 0x44, 0xe5, 0x68, 0x9d, 0x8a,
353 0x1f, 0xe4, 0xf5, 0x8d, 0x61, 0x62, 0x65, 0xa7, 0xcd, 0x3d, 0x0c, 0x7b,
354 0x58, 0xc7, 0xb6, 0x9b, 0x0b, 0x66, 0x74, 0xde, 0x3f, 0x02, 0xb9, 0xb2,
355 0x4e, 0xe3, 0xcb, 0xef, 0x21, 0x6f, 0xdf, 0x83, 0x52, 0xec, 0x94, 0xf0,
356 0x7a, 0xd0, 0x93, 0x9f, 0x61, 0xdc, 0xfd, 0x09, 0x95, 0x83, 0x44, 0xed,
357 0x4b, 0xdb, 0xed, 0x5d, 0xd7, 0x60, 0xb7, 0x23, 0x97, 0xb5, 0xdb, 0xcf,
358 0x85, 0x83, 0x76, 0x7b, 0xd7, 0x35, 0xd8, 0xed, 0xfe, 0x6b, 0xb2, 0x5b,
359 0xee, 0x8d, 0x98, 0xe4, 0xd7, 0xc4, 0x56, 0xc6, 0x59, 0xfe, 0xba, 0x13,
360 0x58, 0x33, 0x73, 0x89, 0x35, 0xc7, 0x2e, 0x59, 0x5b, 0x6d, 0x8c, 0xb1,
361 0xae, 0x46, 0xde, 0xcc, 0xad, 0xe8, 0x6f, 0x23, 0x9e, 0x5f, 0xba, 0xdd,
362 0xcb, 0xe7, 0xfd, 0xbc, 0x3e, 0x68, 0x3f, 0xd4, 0x0b, 0xea, 0xc2, 0x63,
363 0xe0, 0x17, 0xf5, 0xc1, 0xb7, 0xb9, 0x9e, 0x06, 0x1d, 0x5c, 0x44, 0xbe,
364 0xdf, 0xe3, 0xe9, 0x20, 0x65, 0xdd, 0xab, 0xbe, 0x11, 0x95, 0x9c, 0x47,
365 0xdc, 0x3c, 0x1f, 0x3a, 0x90, 0x2f, 0xf9, 0xb6, 0x06, 0x9e, 0x44, 0xfd,
366 0x67, 0xe4, 0xa3, 0x8d, 0x98, 0x67, 0x0b, 0xe2, 0x35, 0xf0, 0x48, 0xf5,
367 0x2f, 0xaf, 0x09, 0x5f, 0x1e, 0xcf, 0xa4, 0x18, 0xc2, 0xd8, 0x53, 0x03,
368 0xb0, 0xf1, 0x01, 0x62, 0x54, 0x1a, 0x79, 0x0f, 0xf5, 0x90, 0xba, 0xb9,
369 0x29, 0xb9, 0x43, 0x67, 0x4c, 0xb5, 0x07, 0xb6, 0x47, 0x7d, 0x8d, 0xcb,
370 0x8e, 0xca, 0xa6, 0x33, 0xe7, 0x74, 0xae, 0x51, 0xad, 0xe6, 0x99, 0x2b,
371 0x5a, 0xa2, 0x77, 0xf7, 0xff, 0x45, 0x98, 0x7e, 0xe9, 0x7a, 0xdb, 0xf0,
372 0x74, 0x2d, 0x83, 0x7b, 0xea, 0xed, 0xeb, 0xf0, 0xf7, 0xfc, 0xc6, 0xfe,
373 0x03, 0xf4, 0xc7, 0x60, 0xf3, 0xf4, 0xef, 0xcc, 0x47, 0xb6, 0x7a, 0xe3,
374 0x7a, 0xd4, 0xf7, 0xcf, 0x6c, 0xea, 0x56, 0xef, 0xbb, 0x13, 0xfd, 0x4f,
375 0x82, 0x3e, 0x7b, 0x99, 0x9c, 0x79, 0x46, 0x21, 0xa7, 0xf2, 0x19, 0xbe,
376 0xaf, 0x74, 0x12, 0x39, 0x88, 0x19, 0xa8, 0xa5, 0x87, 0xbd, 0xdc, 0x8d,
377 0x36, 0x16, 0x81, 0x0c, 0xb7, 0x7b, 0xb9, 0x0a, 0xf3, 0xd7, 0xe5, 0x67,
378 0x13, 0x56, 0xd7, 0x81, 0x0d, 0xef, 0x43, 0x07, 0x1a, 0xe5, 0x17, 0x86,
379 0xed, 0xfb, 0xf2, 0xf3, 0xe3, 0x98, 0x79, 0x6f, 0xdf, 0x3d, 0xae, 0x0c,
380 0x7f, 0x2c, 0xf6, 0xa9, 0x05, 0xf6, 0xe9, 0xe3, 0xd1, 0x3e, 0x6f, 0x9f,
381 0x5b, 0x1b, 0xf0, 0x68, 0xa4, 0xc1, 0x66, 0x3f, 0x4a, 0x3c, 0x3a, 0xb4,
382 0xe6, 0xa3, 0xc7, 0x23, 0xee, 0x6b, 0xe3, 0xaa, 0x38, 0xe4, 0xee, 0xe3,
383 0x77, 0x45, 0x4f, 0x7f, 0x98, 0xf9, 0xde, 0xfb, 0x91, 0x4f, 0x10, 0x47,
384 0x28, 0x93, 0x36, 0x15, 0xc3, 0xba, 0xb6, 0x07, 0x5f, 0x5e, 0x0a, 0xc9,
385 0x1b, 0xf7, 0x84, 0xe5, 0x7f, 0x6f, 0xe3, 0xf7, 0x30, 0xd3, 0xab, 0x69,
386 0xb1, 0xfd, 0xc2, 0x1a, 0xd7, 0x0f, 0xbd, 0xd0, 0xee, 0xfa, 0x1d, 0xbe,
387 0xe3, 0xdb, 0xb3, 0x85, 0xe7, 0x7c, 0xb6, 0x91, 0x5f, 0x4c, 0xae, 0x21,
388 0x07, 0xdc, 0x64, 0x5d, 0xd0, 0x57, 0xcb, 0x01, 0x2f, 0x5f, 0x0f, 0xac,
389 0xe7, 0x80, 0xc4, 0xd9, 0x0e, 0xa5, 0x1b, 0xf9, 0x28, 0x73, 0x1f, 0xc3,
390 0xc3, 0x4e, 0xde, 0x23, 0xb7, 0x75, 0x90, 0xef, 0x42, 0xb6, 0xcf, 0x21,
391 0x5e, 0x7a, 0xd6, 0x41, 0x8e, 0xeb, 0x20, 0xb7, 0x75, 0x90, 0xdb, 0x3a,
392 0xc8, 0x6d, 0x9d, 0xa4, 0x97, 0x23, 0x8f, 0x78, 0x75, 0x7f, 0x7e, 0xe3,
393 0x66, 0x7d, 0xa1, 0x08, 0x5f, 0x32, 0xc5, 0x73, 0x13, 0x7a, 0x36, 0xb5,
394 0xc6, 0xdb, 0x9f, 0x5f, 0x13, 0xef, 0xf2, 0x6a, 0x36, 0xdf, 0x54, 0x75,
395 0x43, 0xd1, 0x1f, 0x68, 0x71, 0xbf, 0x83, 0xf3, 0x7c, 0xc7, 0xaf, 0x21,
396 0x2e, 0x51, 0x67, 0x88, 0x68, 0xa3, 0x55, 0x3d, 0xcd, 0x9a, 0x8c, 0xe8,
397 0x7a, 0xfa, 0x16, 0xbc, 0xb3, 0xc5, 0xcd, 0x09, 0xa2, 0x62, 0xe8, 0xe9,
398 0x56, 0xf2, 0x54, 0xd3, 0xd3, 0x6b, 0xbd, 0xb9, 0xf6, 0xb7, 0xb8, 0xb1,
399 0x55, 0x2f, 0xdb, 0xa6, 0xce, 0x38, 0x41, 0xc5, 0xda, 0x7e, 0xff, 0xc5,
400 0xf6, 0xe5, 0x6b, 0x85, 0x14, 0xbe, 0x67, 0x53, 0xf7, 0x62, 0x3e, 0xb6,
401 0xeb, 0xfc, 0xd6, 0x2f, 0xc9, 0xef, 0x90, 0xc7, 0x6f, 0x97, 0xc7, 0x06,
402 0xc7, 0xa9, 0xba, 0x30, 0x79, 0xed, 0xcf, 0xa7, 0xea, 0x7a, 0x58, 0x47,
403 0x9d, 0xcd, 0xc0, 0xf5, 0x07, 0xa6, 0xb4, 0x8d, 0xee, 0x0e, 0xd9, 0xc1,
404 0x75, 0xfd, 0x6f, 0xe2, 0x57, 0xb3, 0x66, 0x8f, 0xfa, 0x8e, 0xe6, 0xfa,
405 0x8c, 0x90, 0xd2, 0x41, 0x33, 0xcd, 0x7d, 0xfd, 0x50, 0x9d, 0xa9, 0xa1,
406 0xfe, 0xe5, 0x90, 0xc7, 0x4c, 0x0d, 0x6c, 0x8a, 0x9b, 0xfa, 0x48, 0x0b,
407 0xeb, 0xaf, 0x43, 0x15, 0x1f, 0xf7, 0xb8, 0x5e, 0xa3, 0x1f, 0x67, 0x5d,
408 0xcd, 0xc7, 0x33, 0xd9, 0xe0, 0xd6, 0xdb, 0x3e, 0x88, 0x2d, 0xb5, 0x34,
409 0xd8, 0x92, 0xbf, 0x4f, 0xee, 0x9f, 0xd7, 0xd5, 0xcf, 0x43, 0x2c, 0x56,
410 0x02, 0xdf, 0x47, 0x6a, 0xba, 0xc1, 0xb3, 0x2a, 0x9f, 0x85, 0x0e, 0xf2,
411 0xdb, 0xc0, 0x4e, 0xd8, 0x51, 0xb5, 0x3a, 0xc4, 0x1a, 0x73, 0xdf, 0x67,
412 0x54, 0x7e, 0xa9, 0xa7, 0xe7, 0x55, 0xfd, 0xc1, 0x5c, 0x51, 0x7f, 0x18,
413 0x82, 0xae, 0x20, 0x06, 0x70, 0xda, 0x54, 0x4c, 0xa7, 0xe2, 0x85, 0x4a,
414 0xe3, 0xf7, 0x97, 0xfb, 0x5b, 0x5d, 0x3e, 0xfc, 0x5d, 0x8b, 0xfb, 0x0d,
415 0xe2, 0x8f, 0xa2, 0xcb, 0xdb, 0x7c, 0xff, 0xaf, 0x5b, 0xfc, 0xb3, 0x3b,
416 0x85, 0x13, 0x43, 0xd0, 0x45, 0xe4, 0xe4, 0x6a, 0x3e, 0xc4, 0xbb, 0x4f,
417 0xcc, 0x76, 0x2c, 0x1f, 0x8f, 0xbe, 0x13, 0xfe, 0xf8, 0x8e, 0x86, 0xf1,
418 0x1d, 0x18, 0xff, 0x7b, 0x0d, 0xe3, 0x3b, 0x02, 0xe3, 0xa3, 0x0d, 0xe3,
419 0xa3, 0x18, 0xff, 0x7c, 0xc3, 0xf8, 0x68, 0x60, 0x7c, 0x67, 0xc3, 0xf8,
420 0x4e, 0x8c, 0x7f, 0xa1, 0x61, 0x3c, 0xfa, 0x4e, 0x34, 0x79, 0xdf, 0xc5,
421 0x88, 0xb1, 0xfb, 0xbd, 0x5c, 0x1c, 0xd7, 0x72, 0xe3, 0xb7, 0x16, 0xea,
422 0x5d, 0x17, 0x64, 0xe0, 0x9f, 0xa7, 0xa3, 0xbd, 0x66, 0x60, 0xaf, 0xf5,
423 0x58, 0xc6, 0xd5, 0xc7, 0xa0, 0x2e, 0x12, 0x1f, 0x8a, 0x62, 0xd8, 0xd0,
424 0x9d, 0x12, 0x74, 0xa8, 0xe4, 0xfb, 0x24, 0x9e, 0x83, 0xe2, 0x19, 0x53,
425 0xd7, 0xf7, 0x86, 0xec, 0x45, 0x2f, 0x07, 0x7b, 0x9b, 0xb4, 0x03, 0x2f,
426 0x7d, 0xcc, 0x94, 0x63, 0xae, 0xdd, 0x50, 0x7f, 0x39, 0xbf, 0x67, 0x3f,
427 0xd4, 0x55, 0x6f, 0x9d, 0xa1, 0x15, 0xb8, 0x16, 0x5f, 0x51, 0xdb, 0x32,
428 0xae, 0x02, 0xd7, 0x46, 0x6a, 0xb8, 0xf6, 0x59, 0x99, 0xaf, 0xe5, 0xdb,
429 0xc3, 0x72, 0xc0, 0xd9, 0xc5, 0x33, 0x36, 0xc7, 0x32, 0xf2, 0xe1, 0xe4,
430 0xdb, 0xbb, 0x6a, 0x7e, 0x92, 0x67, 0x3a, 0x96, 0x0e, 0x31, 0x87, 0xf2,
431 0x6b, 0xb3, 0x53, 0xce, 0xcf, 0xb6, 0x42, 0x2e, 0xb0, 0x8d, 0x6b, 0xcd,
432 0xb7, 0x39, 0x5f, 0x54, 0x0e, 0xb8, 0xe7, 0x1d, 0x6a, 0xf3, 0x16, 0x6b,
433 0xf3, 0xc6, 0x3c, 0x7b, 0xa3, 0x0f, 0xae, 0xfb, 0xcb, 0x1c, 0xfc, 0xe5,
434 0x18, 0x72, 0xee, 0x45, 0x67, 0xb5, 0xfa, 0xe8, 0xb5, 0xfa, 0xcb, 0xc6,
435 0x3a, 0x73, 0xa3, 0xbf, 0xe4, 0x3a, 0x8d, 0xb5, 0xe5, 0x78, 0x03, 0xfe,
436 0x53, 0x9f, 0x0e, 0x7b, 0x31, 0x35, 0xae, 0xa5, 0xc3, 0xb0, 0x47, 0x5d,
437 0xc6, 0x94, 0xfe, 0xb2, 0xed, 0xe7, 0x96, 0xbb, 0x6b, 0xb9, 0x65, 0x3d,
438 0x1f, 0x44, 0xec, 0x9a, 0xfc, 0xa4, 0x87, 0x8f, 0x8c, 0x91, 0xa7, 0xd0,
439 0x7f, 0x0c, 0x3a, 0xc0, 0x67, 0xac, 0x97, 0xde, 0x2c, 0x9f, 0x32, 0x5d,
440 0xff, 0xe4, 0xd6, 0xa6, 0x76, 0xab, 0xf8, 0x9f, 0xdf, 0x0b, 0x0a, 0xa9,
441 0x76, 0x2f, 0xde, 0xbb, 0x12, 0xae, 0x2e, 0xcf, 0x4d, 0x75, 0xfd, 0x51,
442 0xbc, 0xcb, 0xdc, 0xd4, 0x8c, 0x10, 0x43, 0xb3, 0x95, 0xcb, 0xbe, 0x5f,
443 0xa4, 0x7f, 0x29, 0xa8, 0xef, 0x82, 0x2a, 0x0f, 0xc5, 0xb8, 0x45, 0xef,
444 0x7d, 0x37, 0x0f, 0xcd, 0x56, 0xbe, 0xdd, 0xea, 0xe2, 0xe0, 0xe5, 0x72,
445 0x96, 0x9f, 0x88, 0xb0, 0xae, 0xb7, 0xe8, 0x5c, 0x89, 0xd6, 0x95, 0x79,
446 0xaf, 0xb1, 0x22, 0xef, 0x1d, 0xf5, 0xf2, 0xda, 0xcf, 0xa9, 0xbc, 0xd7,
447 0xe5, 0x31, 0xf7, 0x12, 0xcc, 0xa3, 0x6c, 0x60, 0x21, 0xbf, 0xa9, 0x10,
448 0x1f, 0x26, 0x94, 0xdf, 0xca, 0x4f, 0xdf, 0x09, 0x3e, 0x47, 0x57, 0xd1,
449 0x9b, 0x8f, 0xda, 0x4f, 0xf8, 0x7b, 0x3f, 0x2c, 0x6e, 0xbd, 0x6e, 0x27,
450 0x68, 0x61, 0x6e, 0x15, 0xf2, 0xf4, 0xe1, 0xbb, 0xde, 0x39, 0x53, 0x7f,
451 0x9c, 0x9f, 0xc7, 0xd7, 0xbe, 0xbb, 0x16, 0x33, 0xcb, 0xea, 0x27, 0x1b,
452 0x09, 0xc3, 0x90, 0x7b, 0xe6, 0x1a, 0xbe, 0x5b, 0x7c, 0x90, 0xf3, 0x11,
453 0x8d, 0x7e, 0x8d, 0xdf, 0x4d, 0xf9, 0xad, 0x54, 0xb4, 0xbb, 0x7b, 0x6d,
454 0xd8, 0x00, 0xcf, 0x2c, 0x07, 0xf1, 0x35, 0x2c, 0xf9, 0x39, 0x09, 0x47,
455 0xd3, 0xfc, 0x06, 0x40, 0xff, 0xff, 0xba, 0xb7, 0xcf, 0x98, 0xec, 0x9f,
456 0x71, 0x6b, 0x9e, 0xfa, 0x65, 0xcf, 0xc5, 0x1d, 0x00, 0x1f, 0x12, 0x47,
457 0xfd, 0x9a, 0xa7, 0xee, 0x9e, 0x8b, 0x3b, 0xfa, 0xe1, 0x9d, 0x8b, 0xe3,
458 0xfc, 0xa6, 0xec, 0x5a, 0xe5, 0x5c, 0x9c, 0x71, 0x95, 0xe7, 0xe2, 0xda,
459 0x55, 0xcd, 0x93, 0xf3, 0xb8, 0x35, 0x4f, 0xb6, 0xbb, 0xfb, 0x59, 0x2b,
460 0xe1, 0xd9, 0xb7, 0x01, 0x75, 0x06, 0xb9, 0xbb, 0xff, 0x47, 0x91, 0xa3,
461 0x7c, 0x3d, 0xf2, 0xd1, 0xe7, 0x28, 0xdc, 0xcb, 0xaf, 0xb8, 0xdf, 0x77,
462 0xe5, 0x5a, 0xea, 0x00, 0x1f, 0xac, 0xae, 0xb9, 0x5f, 0xd5, 0x35, 0xbf,
463 0x13, 0x09, 0xd6, 0x35, 0xf5, 0x2b, 0x9c, 0x0d, 0xdb, 0xbf, 0x4a, 0x5d,
464 0x33, 0x14, 0x38, 0x1b, 0x16, 0xf2, 0xce, 0x86, 0xb5, 0xdb, 0xc8, 0x25,
465 0xbd, 0x3a, 0xa6, 0x7e, 0xd9, 0xb3, 0x61, 0xff, 0x19, 0xf9, 0xe0, 0x75,
466 0xcc, 0x15, 0x67, 0xc3, 0xe0, 0xeb, 0x36, 0x48, 0xfc, 0x9a, 0xf2, 0x9e,
467 0x0f, 0x92, 0xf3, 0xf0, 0xbc, 0x7e, 0x13, 0xf6, 0x1c, 0x92, 0x5d, 0x51,
468 0xea, 0x27, 0xcf, 0x36, 0xf6, 0xc2, 0x16, 0x70, 0xad, 0xb0, 0x9d, 0xa4,
469 0x8c, 0xb4, 0x91, 0xde, 0xe5, 0xe7, 0x10, 0xea, 0xe7, 0x71, 0xc3, 0xb5,
470 0xf3, 0xb8, 0x47, 0xa0, 0x37, 0xfa, 0x4c, 0x58, 0x16, 0x02, 0x3a, 0x35,
471 0x85, 0x78, 0x4f, 0x9f, 0xb3, 0xbc, 0xe7, 0xfc, 0x9f, 0x8a, 0x28, 0x30,
472 0x8f, 0x67, 0x78, 0xdb, 0xc4, 0x98, 0x73, 0xbf, 0x59, 0xba, 0xff, 0x57,
473 0x12, 0xc3, 0x18, 0x9e, 0xf1, 0x0c, 0xc9, 0x01, 0x55, 0xb3, 0xf0, 0x75,
474 0x79, 0xc7, 0x5a, 0x69, 0x59, 0x9f, 0xa9, 0xb7, 0xa3, 0xab, 0xf8, 0x7d,
475 0xc4, 0x91, 0x33, 0xd4, 0xe7, 0x5b, 0x25, 0xe7, 0xd5, 0x83, 0x0a, 0x95,
476 0x6d, 0x5e, 0x7e, 0xa1, 0xbe, 0xed, 0x80, 0x97, 0xdd, 0x9e, 0x0f, 0xc6,
477 0xb5, 0xd4, 0x4d, 0x9f, 0x87, 0x35, 0x4e, 0xca, 0xd0, 0xf4, 0x96, 0xd8,
478 0x38, 0xf0, 0x6e, 0x4c, 0xad, 0x79, 0x2d, 0x3c, 0xd7, 0x2e, 0xf1, 0xbd,
479 0xf1, 0x6a, 0xf9, 0xee, 0xc7, 0xc7, 0x8f, 0x62, 0x7f, 0xdd, 0xd0, 0x8f,
480 0x87, 0x25, 0x77, 0xe2, 0x66, 0x19, 0x9a, 0x4d, 0x80, 0x9e, 0x1f, 0x56,
481 0x0b, 0x29, 0xc4, 0xd2, 0x4f, 0xf0, 0xdc, 0x18, 0x30, 0x14, 0x7c, 0x7b,
482 0x66, 0xc5, 0x77, 0xec, 0xe0, 0x59, 0xb3, 0x64, 0xed, 0xec, 0xd0, 0x53,
483 0x15, 0x09, 0x77, 0x90, 0xe6, 0x99, 0xfa, 0xd9, 0xef, 0xc5, 0xca, 0x0e,
484 0xe5, 0xdb, 0x9e, 0xac, 0x2c, 0xab, 0xfd, 0x28, 0x19, 0x4e, 0x94, 0x9f,
485 0x04, 0x2f, 0x5e, 0x51, 0xfe, 0xed, 0x88, 0x23, 0x37, 0x19, 0x42, 0x79,
486 0x88, 0x06, 0x1e, 0xa8, 0x33, 0x1c, 0xee, 0xf7, 0xfd, 0x2e, 0x25, 0x57,
487 0x17, 0x2b, 0x76, 0x06, 0xce, 0x60, 0xd4, 0x65, 0xeb, 0x9e, 0xcd, 0x70,
488 0x65, 0xe1, 0x9e, 0x1f, 0x21, 0x3f, 0x97, 0x0e, 0xed, 0xb2, 0xdd, 0xf3,
489 0x23, 0x3d, 0x73, 0xec, 0xeb, 0x6c, 0xf0, 0x7d, 0x61, 0xe8, 0x00, 0xcf,
490 0x1d, 0xf1, 0xcc, 0x37, 0x69, 0x56, 0xb5, 0x8e, 0x55, 0xbf, 0x6d, 0x5f,
491 0x5b, 0xcd, 0xd5, 0x5d, 0xb3, 0x5b, 0xad, 0x79, 0x9d, 0x87, 0x59, 0xfe,
492 0x59, 0xef, 0x94, 0xf6, 0xff, 0xd4, 0x5d, 0x7b, 0x6c, 0x1b, 0xf7, 0x7d,
493 0xff, 0xf2, 0x48, 0x3d, 0xac, 0xe7, 0x49, 0xa6, 0x64, 0x5a, 0x52, 0x94,
494 0x3b, 0xe9, 0x64, 0x29, 0xb1, 0x12, 0x70, 0x9e, 0xba, 0x0a, 0x88, 0x9a,
495 0xb0, 0x24, 0xfd, 0x58, 0x10, 0x0c, 0xb4, 0xad, 0x64, 0xee, 0x92, 0xad,
496 0x0e, 0x25, 0xa7, 0x1d, 0x30, 0x60, 0x6e, 0xd6, 0x02, 0x69, 0x07, 0xc7,
497 0x0c, 0x65, 0x27, 0xc6, 0xaa, 0x88, 0x4c, 0xcc, 0x6a, 0x1d, 0xb0, 0x62,
498 0x1c, 0xa5, 0x38, 0x69, 0xa7, 0x80, 0x69, 0xda, 0x04, 0xc5, 0xfe, 0xb1,
499 0x26, 0x3b, 0x7b, 0x61, 0x7f, 0x04, 0xdb, 0x80, 0x1a, 0x5b, 0x81, 0xba,
500 0x76, 0x8a, 0x65, 0x1b, 0xe0, 0x34, 0xdb, 0xb0, 0x75, 0x58, 0x0b, 0xee,
501 0xfb, 0xf9, 0x3d, 0xc8, 0x23, 0x79, 0xd4, 0xc3, 0x71, 0x06, 0x4c, 0x80,
502 0x40, 0xde, 0xf1, 0x77, 0x77, 0xbf, 0xdf, 0xf7, 0xf7, 0x7d, 0xbf, 0x6e,
503 0x2e, 0x33, 0x1e, 0xf2, 0x33, 0x7e, 0xcf, 0x15, 0x61, 0x5f, 0x37, 0xd2,
504 0xe1, 0x36, 0x83, 0x67, 0xa4, 0x0e, 0x9e, 0xd5, 0x34, 0xc1, 0xf6, 0x78,
505 0x99, 0x77, 0x4b, 0xd8, 0xc9, 0xf3, 0xc8, 0x63, 0xd7, 0x39, 0x0e, 0x12,
506 0x76, 0x65, 0x1a, 0x5a, 0x72, 0xe7, 0x37, 0x54, 0x60, 0x77, 0xb2, 0x0c,
507 0xbb, 0x3d, 0xff, 0x8f, 0x60, 0x77, 0x4d, 0xe8, 0xbf, 0xdf, 0x2e, 0x22,
508 0x6f, 0x4d, 0xeb, 0x00, 0xba, 0x6e, 0x09, 0x70, 0x04, 0x3f, 0xb5, 0xf3,
509 0xeb, 0x04, 0x9e, 0x8a, 0xbc, 0xe2, 0x52, 0xe9, 0x3b, 0xe1, 0xb2, 0x9f,
510 0x92, 0xed, 0x12, 0xd8, 0x27, 0xf0, 0xe7, 0x35, 0x96, 0x91, 0x47, 0x6f,
511 0x4b, 0x46, 0x42, 0x57, 0xaa, 0xb5, 0x4f, 0x7e, 0xbb, 0xcb, 0x6d, 0x9f,
512 0x1c, 0xdd, 0xa1, 0x7d, 0x72, 0x5a, 0xda, 0x27, 0xa9, 0xed, 0xdb, 0x27,
513 0x03, 0x75, 0x79, 0x5d, 0x95, 0xf5, 0xec, 0xdc, 0x3e, 0x31, 0x36, 0xb5,
514 0x4f, 0x46, 0x5d, 0xbe, 0x18, 0xcc, 0xf7, 0x57, 0x29, 0x75, 0x0c, 0x3c,
515 0x4e, 0xc3, 0x19, 0x30, 0x3e, 0x56, 0xe3, 0x17, 0xfe, 0x38, 0x61, 0xfd,
516 0xd7, 0xff, 0xc7, 0xb0, 0x1e, 0xac, 0xf3, 0x79, 0x57, 0xd6, 0x03, 0x21,
517 0xfe, 0x51, 0x60, 0x3d, 0xd8, 0xd0, 0x77, 0xda, 0x38, 0x67, 0xb1, 0xda,
518 0x77, 0x3a, 0x62, 0x34, 0xe2, 0xed, 0x7f, 0xe4, 0xf2, 0xa9, 0xba, 0xf9,
519 0x3b, 0x68, 0x8a, 0x7c, 0x47, 0xc7, 0xf5, 0xb3, 0x40, 0x4b, 0x76, 0x2a,
520 0x45, 0xb0, 0x99, 0xf0, 0xbc, 0x90, 0xa0, 0xb5, 0x1a, 0x7d, 0x8b, 0x9f,
521 0xc7, 0xeb, 0x7b, 0xf5, 0x09, 0x21, 0xa7, 0xa4, 0xff, 0x01, 0xe3, 0x27,
522 0x7c, 0xf3, 0x62, 0xac, 0xcc, 0x6f, 0x52, 0xfe, 0x08, 0xa5, 0xfb, 0x37,
523 0xf2, 0x43, 0xd4, 0xcb, 0xbc, 0x9d, 0xd9, 0x0a, 0x9a, 0xc6, 0xef, 0xe6,
524 0x7d, 0x09, 0x55, 0xd9, 0x5a, 0xe0, 0x9f, 0xa7, 0x59, 0x2f, 0x18, 0x29,
525 0xeb, 0x04, 0xd5, 0x7b, 0x73, 0x4e, 0xd8, 0x74, 0x9a, 0x77, 0x26, 0x64,
526 0xee, 0xa9, 0x38, 0x0f, 0x3d, 0x4d, 0xf3, 0xce, 0x5a, 0x3d, 0xf8, 0x6e,
527 0x0f, 0xbc, 0xf0, 0xca, 0x69, 0x2a, 0xef, 0x9d, 0x85, 0x9c, 0xf3, 0xb8,
528 0xe7, 0xde, 0x95, 0x6b, 0xc2, 0x52, 0x95, 0xb1, 0xf2, 0xfa, 0xb8, 0x58,
529 0xd7, 0x0f, 0x8e, 0x44, 0x51, 0xfb, 0x56, 0xae, 0x17, 0xab, 0xad, 0x77,
530 0x82, 0x1c, 0xd0, 0x74, 0xa8, 0x6b, 0xa2, 0x01, 0x8b, 0x61, 0x8f, 0x7a,
531 0x27, 0xb7, 0x2c, 0xc1, 0x75, 0xb5, 0xb0, 0xa8, 0xc8, 0x91, 0xf3, 0x4a,
532 0x8e, 0x14, 0x5c, 0x7c, 0xbc, 0x5e, 0x6f, 0xef, 0xf5, 0xd0, 0xdb, 0xbd,
533 0x6a, 0x9e, 0x30, 0xa7, 0x67, 0x58, 0x0f, 0xb9, 0x1f, 0x7a, 0x88, 0x89,
534 0xba, 0x25, 0xa9, 0x8b, 0xe0, 0x77, 0x96, 0x35, 0xaf, 0x86, 0x18, 0x57,
535 0x8e, 0xd0, 0x53, 0xac, 0x6b, 0x5f, 0xa2, 0x7b, 0x94, 0x7d, 0x16, 0x71,
536 0xe5, 0x99, 0x22, 0x8f, 0xdf, 0x47, 0xa9, 0x27, 0xec, 0x89, 0x08, 0x1d,
537 0xa1, 0x53, 0x22, 0x67, 0x06, 0xf1, 0x3d, 0xe4, 0x1c, 0xdc, 0x2b, 0x9e,
538 0x2f, 0x7d, 0x19, 0x77, 0x22, 0xa7, 0x6e, 0xfb, 0xf9, 0xfb, 0xba, 0x56,
539 0x2f, 0x2a, 0x9e, 0xb9, 0xaa, 0x68, 0x4a, 0x9c, 0xe3, 0xeb, 0x9f, 0x31,
540 0xea, 0xaf, 0x8f, 0x18, 0xf1, 0x62, 0xdc, 0x88, 0xae, 0x60, 0xdc, 0x33,
541 0x46, 0xac, 0x08, 0x1b, 0x52, 0xe3, 0x88, 0x1d, 0x06, 0xbd, 0x6d, 0xd0,
542 0xd6, 0xb1, 0x88, 0x02, 0xd5, 0xd4, 0x49, 0x6c, 0x63, 0xde, 0x87, 0xaa,
543 0xe6, 0xad, 0xe1, 0x8b, 0xef, 0xf0, 0xf7, 0x44, 0x18, 0xa6, 0x5a, 0xaf,
544 0x6d, 0x83, 0x7f, 0x7d, 0x22, 0x45, 0x9b, 0xe9, 0xb5, 0x76, 0x9d, 0x5e,
545 0x5b, 0xd8, 0x72, 0xde, 0x1f, 0x95, 0xc6, 0x65, 0x3d, 0xa2, 0xdf, 0x11,
546 0xfa, 0x2b, 0xcf, 0xbb, 0x4a, 0xb7, 0xad, 0xc1, 0x29, 0x8c, 0xd1, 0x7e,
547 0x70, 0xed, 0x07, 0xeb, 0x52, 0xf9, 0xc0, 0x3a, 0x3f, 0xa1, 0x0d, 0xf5,
548 0x5e, 0xa6, 0xcc, 0x6b, 0x85, 0x8d, 0xb5, 0xce, 0xf3, 0x83, 0xbd, 0xf5,
549 0xa0, 0x98, 0x23, 0xdb, 0x5b, 0x56, 0x8c, 0xa4, 0xaf, 0x7b, 0xbe, 0x58,
550 0x55, 0xff, 0xe9, 0x51, 0x07, 0x39, 0xe2, 0x51, 0x07, 0xe9, 0xa6, 0xb5,
551 0x80, 0x8b, 0xd6, 0x42, 0x2e, 0xbd, 0x6d, 0x88, 0xed, 0x96, 0x0e, 0xe6,
552 0x21, 0xb0, 0x5b, 0xda, 0xc8, 0xff, 0xb2, 0xdb, 0x6e, 0xa9, 0xad, 0x45,
553 0x07, 0xdd, 0x41, 0x37, 0x93, 0x36, 0x4c, 0x3c, 0x57, 0xae, 0x63, 0xe7,
554 0x75, 0x57, 0x6a, 0x0e, 0x57, 0xea, 0xea, 0x23, 0xbd, 0xe6, 0x3b, 0x5c,
555 0x37, 0x5f, 0xc8, 0xaf, 0x48, 0x43, 0x9d, 0xce, 0xcb, 0xae, 0xba, 0x53,
556 0xf3, 0xab, 0xe5, 0x67, 0x78, 0xd6, 0x88, 0xf0, 0x79, 0xa7, 0xca, 0xbc,
557 0x6c, 0x5a, 0xce, 0x37, 0x53, 0x6d, 0x67, 0xf8, 0x97, 0x48, 0xc1, 0xce,
558 0x9b, 0xb7, 0xef, 0xcc, 0x7f, 0xd6, 0x5e, 0x23, 0x77, 0xdf, 0x33, 0xa5,
559 0x5f, 0xac, 0x49, 0xe5, 0x61, 0xf7, 0x29, 0x7b, 0x6f, 0x2b, 0x7c, 0xc7,
560 0xb9, 0x26, 0xe5, 0x4b, 0xb4, 0xad, 0x3c, 0x01, 0xcf, 0x8f, 0x9d, 0x68,
561 0x72, 0x4c, 0x15, 0xcb, 0x42, 0xbc, 0x0a, 0x78, 0xaf, 0xef, 0x0f, 0x9e,
562 0xbd, 0x9d, 0x3d, 0xb3, 0xea, 0xf6, 0x4c, 0xe2, 0x15, 0x6c, 0x2d, 0xe4,
563 0x17, 0x4f, 0xd6, 0xe4, 0x78, 0x7f, 0x14, 0x58, 0x74, 0x79, 0xe4, 0x3d,
564 0x23, 0x6f, 0xb9, 0xd1, 0x3c, 0xaf, 0xbb, 0xf4, 0x72, 0xcc, 0xb7, 0x54,
565 0x7a, 0x23, 0x3c, 0x20, 0x65, 0x71, 0xd1, 0x5b, 0x47, 0x32, 0xb7, 0x3d,
566 0xbf, 0x5a, 0xd9, 0xbb, 0x77, 0x9b, 0xb2, 0x57, 0xf4, 0xf4, 0xf0, 0x1d,
567 0x14, 0x3c, 0xa0, 0x83, 0x56, 0x72, 0xc8, 0xbf, 0xfe, 0x05, 0xd0, 0x3c,
568 0xf3, 0x59, 0x57, 0x4d, 0x9a, 0xf7, 0x3e, 0x96, 0x63, 0x2a, 0x81, 0x19,
569 0xc4, 0xfe, 0x90, 0x5b, 0xd2, 0xcb, 0xbc, 0x07, 0xe3, 0xc7, 0xac, 0xab,
570 0xf0, 0xf7, 0x2a, 0xff, 0x53, 0x5c, 0xc9, 0x97, 0x83, 0xdb, 0x88, 0xad,
571 0xec, 0x8c, 0x4f, 0xdb, 0xd6, 0x3a, 0x21, 0xee, 0x83, 0x7c, 0xe1, 0xfb,
572 0xba, 0xa8, 0xeb, 0x33, 0x2d, 0x2d, 0xce, 0x97, 0x7a, 0x64, 0x2c, 0x0a,
573 0xbf, 0x75, 0xd0, 0x2b, 0x39, 0xe4, 0x72, 0xe3, 0xb7, 0xdf, 0xe0, 0xdf,
574 0xbc, 0x78, 0x94, 0xce, 0x45, 0x87, 0x2e, 0x27, 0xf7, 0x27, 0x4f, 0xb0,
575 0x95, 0x4a, 0xf4, 0xb7, 0xe1, 0x5f, 0x94, 0xf1, 0x8c, 0xe2, 0x9d, 0x8e,
576 0xd5, 0x78, 0xf9, 0x0b, 0xdf, 0xec, 0xb9, 0xdd, 0xdc, 0xc8, 0x2f, 0x6c,
577 0xcb, 0x5f, 0x88, 0x38, 0xff, 0x76, 0x62, 0x26, 0x3a, 0x36, 0x3c, 0x25,
578 0x6a, 0x4e, 0xdd, 0x78, 0x70, 0x67, 0xe2, 0xc3, 0xc0, 0x87, 0xe1, 0x3a,
579 0x5e, 0xf5, 0xd1, 0xfd, 0xfd, 0xb5, 0x70, 0x6d, 0xf3, 0xf4, 0x55, 0x79,
580 0xc7, 0x81, 0x11, 0xf3, 0x87, 0x9f, 0xfa, 0x21, 0x9a, 0xbf, 0x08, 0x1c,
581 0x36, 0x18, 0xdb, 0x46, 0x69, 0x21, 0x88, 0xba, 0x22, 0x51, 0x9b, 0xa3,
582 0xe2, 0x86, 0xb2, 0x56, 0x68, 0x5e, 0xd4, 0x40, 0x8e, 0x85, 0x6e, 0xf2,
583 0xbc, 0xe7, 0x8b, 0x29, 0x3a, 0xc5, 0x32, 0xf6, 0xd4, 0x4a, 0x45, 0x77,
584 0xaf, 0xaf, 0x83, 0xac, 0xc6, 0xf1, 0x9b, 0x02, 0xc7, 0x87, 0x36, 0xc5,
585 0xf1, 0xc3, 0x65, 0x1c, 0xff, 0x44, 0xaf, 0xc4, 0xe7, 0x67, 0xf9, 0x5e,
586 0x5d, 0x74, 0x50, 0xdc, 0x37, 0xc5, 0xdf, 0xdb, 0xe9, 0xa0, 0xec, 0x61,
587 0xc1, 0xcf, 0x66, 0x1e, 0x9f, 0x49, 0xd1, 0x53, 0x17, 0x53, 0xbe, 0xb8,
588 0xa8, 0x5f, 0x70, 0xf7, 0xe8, 0xd0, 0xd7, 0x63, 0x5c, 0x23, 0xfc, 0xd7,
589 0x7c, 0x49, 0xd6, 0x5c, 0xe5, 0x25, 0x7f, 0xa2, 0x77, 0xc3, 0x83, 0x35,
590 0xf8, 0x5f, 0x6d, 0x3b, 0x9e, 0x56, 0x32, 0xf0, 0xd8, 0x26, 0x7e, 0x8d,
591 0x7a, 0xbc, 0xec, 0xf1, 0xd0, 0x87, 0x7f, 0xbd, 0x57, 0xc6, 0xa9, 0x36,
592 0xf3, 0x6b, 0xb8, 0x71, 0xb4, 0x2a, 0x6e, 0xcf, 0x7c, 0xff, 0xbf, 0x55,
593 0x1c, 0xfd, 0xa5, 0x5e, 0x29, 0x2f, 0x50, 0x1f, 0x98, 0x60, 0x38, 0x9c,
594 0x64, 0x5d, 0x65, 0x90, 0x9a, 0x5f, 0xd6, 0x6b, 0x1d, 0x14, 0xfc, 0xd6,
595 0xed, 0xa7, 0x39, 0xa7, 0x6a, 0xbb, 0xd3, 0xae, 0x35, 0x9d, 0x13, 0x36,
596 0x4e, 0x63, 0x7a, 0x6b, 0x9c, 0x73, 0x35, 0x54, 0x23, 0x13, 0x6a, 0xf1,
597 0x0d, 0xbd, 0x4f, 0xb0, 0xbf, 0x64, 0x48, 0x3d, 0x78, 0x9a, 0xf5, 0xdb,
598 0x9d, 0xc6, 0x8b, 0x3e, 0xaa, 0x8e, 0x58, 0xdb, 0x53, 0xa3, 0xf6, 0x3b,
599 0xf6, 0x41, 0xda, 0x1c, 0xc9, 0x57, 0x1f, 0x12, 0xbc, 0xe0, 0xdc, 0x64,
600 0x89, 0x62, 0xe1, 0x4e, 0x4a, 0x4e, 0xf2, 0xb3, 0xa7, 0x1d, 0xb6, 0xbd,
601 0xfc, 0x94, 0x62, 0xfa, 0x4d, 0x4e, 0xee, 0x52, 0xfa, 0xa2, 0xf6, 0xa7,
602 0xb7, 0xa8, 0x3c, 0x87, 0x67, 0x45, 0x5c, 0x52, 0xf6, 0xc6, 0xe0, 0xef,
603 0x2b, 0xfa, 0xde, 0xcf, 0x8a, 0xf8, 0x68, 0xf2, 0x62, 0xb3, 0x1a, 0xd7,
604 0xee, 0x1a, 0x87, 0x31, 0xed, 0x6a, 0x2c, 0xee, 0xa9, 0x75, 0x8a, 0x56,
605 0xc5, 0x6f, 0x1f, 0x11, 0x75, 0x60, 0xb2, 0x56, 0x0f, 0xbf, 0x9f, 0xa6,
606 0xb9, 0xf2, 0x5a, 0xda, 0x79, 0xec, 0xcf, 0x4a, 0x11, 0x61, 0xcb, 0xb5,
607 0xb3, 0xce, 0x8b, 0x79, 0xd7, 0xcf, 0x09, 0x6b, 0xf1, 0x8b, 0xf8, 0x10,
608 0x7f, 0x57, 0xcf, 0x39, 0x59, 0x9e, 0x13, 0x72, 0x34, 0xec, 0x90, 0xbc,
609 0x97, 0x1e, 0xd7, 0xee, 0x1a, 0xa7, 0x79, 0x85, 0x8e, 0x3f, 0xfc, 0x80,
610 0xe7, 0xf1, 0x37, 0x2a, 0x87, 0xd7, 0x14, 0xf1, 0x53, 0x99, 0xa3, 0xa1,
611 0xbf, 0xc3, 0xbf, 0x8c, 0x9c, 0x0a, 0xe4, 0x49, 0xb8, 0xf9, 0x8d, 0x5c,
612 0x6f, 0x00, 0xb2, 0xa8, 0x88, 0xb8, 0x29, 0xe2, 0x15, 0x8d, 0x74, 0xe7,
613 0xbd, 0xc8, 0xcd, 0xdf, 0x81, 0x0e, 0xba, 0x1d, 0xfa, 0xb3, 0x3c, 0xe8,
614 0xcf, 0xfd, 0x7c, 0xd4, 0xc1, 0xa1, 0x1e, 0x2e, 0x35, 0x61, 0x50, 0x89,
615 0x6d, 0x05, 0x83, 0xf2, 0xa6, 0x8f, 0x9e, 0x72, 0xec, 0xf0, 0x0a, 0xc9,
616 0x9a, 0xc9, 0xd8, 0xa2, 0x3d, 0xb1, 0x4e, 0xfb, 0x45, 0xcd, 0x38, 0x7a,
617 0x1f, 0xe4, 0x59, 0x06, 0x9f, 0xa4, 0x09, 0xb6, 0x8f, 0xd8, 0xfe, 0x9c,
618 0x45, 0xbc, 0x45, 0xef, 0x0b, 0x6a, 0xe0, 0xf1, 0x39, 0xc1, 0x70, 0x7a,
619 0x6c, 0x37, 0xb5, 0x45, 0xf8, 0x9e, 0x13, 0xe0, 0x4f, 0xe8, 0xe7, 0x45,
620 0x51, 0xb6, 0x93, 0x60, 0xb3, 0x9e, 0x9c, 0xb5, 0xcd, 0x3c, 0x19, 0x3c,
621 0x16, 0xb6, 0x2b, 0xee, 0x83, 0xeb, 0x23, 0x66, 0x13, 0xd5, 0xd6, 0xe4,
622 0x3e, 0x2b, 0xea, 0x14, 0xdf, 0x0d, 0xdf, 0x47, 0x46, 0x3f, 0xf8, 0x15,
623 0xf6, 0xed, 0x5e, 0x15, 0x27, 0x3a, 0xcb, 0xdf, 0xc7, 0xd5, 0xf7, 0xaf,
624 0x88, 0xfd, 0x94, 0xdf, 0x35, 0x7e, 0xe3, 0xef, 0x5f, 0x5a, 0xc8, 0xf9,
625 0xa1, 0xca, 0x59, 0xa9, 0xca, 0x05, 0x09, 0x8d, 0x1a, 0x5f, 0xa1, 0xd3,
626 0x2b, 0x9b, 0xf9, 0x5f, 0xbc, 0x6a, 0x5d, 0xbb, 0xb7, 0x59, 0xeb, 0xfa,
627 0x07, 0xbb, 0x65, 0x6d, 0x99, 0x7b, 0x2e, 0xff, 0xc9, 0x73, 0xf1, 0xd2,
628 0xc9, 0xea, 0xf4, 0x44, 0x5e, 0x6f, 0x89, 0xfe, 0x29, 0xfc, 0x49, 0xba,
629 0x1e, 0x0c, 0xa9, 0x9c, 0x25, 0xe4, 0x28, 0xdd, 0xa7, 0xf0, 0x5a, 0xf3,
630 0x7e, 0xf2, 0xe0, 0xfd, 0x8f, 0x89, 0x5c, 0x4d, 0x29, 0x3b, 0x06, 0x15,
631 0x3c, 0x00, 0xb3, 0x90, 0x0b, 0x66, 0x7d, 0x2e, 0x98, 0x19, 0xea, 0x7b,
632 0xa7, 0x38, 0x3e, 0xbd, 0xf2, 0x99, 0x6e, 0x59, 0x2f, 0x8e, 0x58, 0xe2,
633 0xbc, 0xfa, 0xbe, 0xd5, 0x7a, 0x7f, 0xce, 0x6b, 0x15, 0xfe, 0x26, 0xd7,
634 0x5a, 0x5f, 0x27, 0x72, 0x5a, 0x82, 0xf5, 0x30, 0xf8, 0x8e, 0xeb, 0x3c,
635 0xe6, 0x38, 0xe6, 0x9a, 0xe3, 0x88, 0x6b, 0x8e, 0x77, 0x37, 0x98, 0x23,
636 0xf3, 0xf8, 0xe2, 0x69, 0xfe, 0xbf, 0xdd, 0xb9, 0xca, 0x79, 0xce, 0x0b,
637 0x78, 0xb6, 0x53, 0x3a, 0x18, 0x52, 0xb2, 0xe3, 0xfb, 0xaa, 0x16, 0xdd,
638 0x6b, 0xce, 0xff, 0x40, 0x8d, 0xf7, 0xcd, 0x8d, 0xab, 0xee, 0xfa, 0xe3,
639 0x97, 0x28, 0x26, 0xeb, 0xc8, 0x15, 0x6d, 0x7f, 0xb5, 0x81, 0x1f, 0xfa,
640 0x41, 0xa1, 0xff, 0xcc, 0xcb, 0x78, 0xd0, 0x80, 0xec, 0xbf, 0x16, 0xa0,
641 0xd5, 0x72, 0x2d, 0xaf, 0x5f, 0xd5, 0xee, 0xdc, 0x1f, 0xbc, 0xb3, 0x75,
642 0xbc, 0x38, 0xff, 0x88, 0xf0, 0xe5, 0xc9, 0xf8, 0x51, 0x42, 0xd5, 0x23,
643 0xdb, 0x16, 0x72, 0x03, 0x0a, 0x6b, 0xf0, 0xbf, 0x36, 0xaa, 0xdd, 0xc5,
644 0xb5, 0xf0, 0x03, 0x6a, 0x3b, 0xfe, 0x84, 0xe0, 0x89, 0xd2, 0x3f, 0x26,
645 0xeb, 0x6f, 0x0b, 0x6b, 0x27, 0x45, 0xcd, 0x6b, 0x54, 0xd5, 0xf1, 0x26,
646 0xa9, 0x43, 0xe8, 0xb9, 0xb7, 0x5f, 0x7f, 0xfb, 0x5c, 0x70, 0xe7, 0xf5,
647 0xb7, 0xee, 0x6b, 0x76, 0x56, 0x7f, 0x6b, 0xf2, 0xda, 0x8d, 0x65, 0x59,
648 0x7f, 0x5b, 0x1d, 0x93, 0x91, 0xfe, 0xc0, 0xa4, 0x4b, 0x7f, 0x90, 0xfa,
649 0xfa, 0x6f, 0xb9, 0xf2, 0xb7, 0x65, 0x6d, 0x6d, 0xa1, 0xac, 0xb3, 0xca,
650 0xda, 0x5a, 0x99, 0xef, 0xed, 0xee, 0x03, 0x23, 0x63, 0x3f, 0xf2, 0x39,
651 0x9d, 0x35, 0xb1, 0x1f, 0x59, 0x53, 0x6b, 0x19, 0x8d, 0x6c, 0x38, 0xd1,
652 0xe7, 0xa2, 0x8f, 0xba, 0x22, 0x8c, 0xbb, 0xed, 0x0d, 0xfa, 0x21, 0x44,
653 0x1a, 0xf4, 0x43, 0x70, 0xf3, 0x7e, 0xb7, 0x8e, 0x05, 0x9d, 0x18, 0xb2,
654 0x11, 0xba, 0x30, 0xfa, 0x19, 0x84, 0xe9, 0x74, 0x59, 0xf7, 0xbc, 0x8f,
655 0x12, 0x4a, 0xf7, 0x3c, 0xbd, 0xa2, 0xf9, 0xd1, 0x48, 0x0d, 0x3f, 0xf2,
656 0xd2, 0x45, 0x6d, 0x95, 0xe7, 0xa3, 0xe9, 0x35, 0xe5, 0xa2, 0xd7, 0x94,
657 0x07, 0xbd, 0x8a, 0x67, 0x34, 0x98, 0xf7, 0xf7, 0xd5, 0x35, 0xf8, 0x4f,
658 0x84, 0xd0, 0xb3, 0x85, 0x79, 0x6a, 0x50, 0xe9, 0x7f, 0x2e, 0x7a, 0x3d,
659 0xc5, 0xf4, 0xaa, 0xcf, 0x63, 0xbe, 0x0d, 0x73, 0x41, 0x95, 0xce, 0x38,
660 0xe8, 0x3b, 0x74, 0xf1, 0x1b, 0x22, 0x4f, 0xaa, 0xda, 0x5e, 0xd4, 0xfa,
661 0xc4, 0x3e, 0x41, 0x4b, 0xd7, 0xfd, 0xc8, 0x5b, 0xd1, 0xe7, 0x4c, 0xe5,
662 0x27, 0xd3, 0xb0, 0x68, 0xae, 0xd2, 0x39, 0x2a, 0xfa, 0x86, 0xc8, 0xf1,
663 0x75, 0xcd, 0xed, 0x43, 0x9e, 0x9b, 0x3e, 0xaf, 0x65, 0xe6, 0xb5, 0x2a,
664 0x7f, 0xc6, 0xe5, 0xaa, 0x9e, 0x83, 0xf0, 0x1d, 0x75, 0x26, 0x0c, 0x27,
665 0x2e, 0x72, 0x4c, 0x7b, 0x1c, 0xf8, 0xc9, 0xa2, 0x4c, 0xfb, 0x3d, 0x09,
666 0xe4, 0x33, 0xf7, 0x2c, 0x59, 0x74, 0x3c, 0x73, 0xff, 0x5d, 0x12, 0x57,
667 0xce, 0x8a, 0x3e, 0x92, 0xe8, 0x67, 0x16, 0x63, 0xf9, 0x1c, 0xf5, 0x4f,
668 0xd3, 0xf9, 0x62, 0x0b, 0x15, 0x58, 0xbb, 0xf7, 0x3b, 0x79, 0xe1, 0xeb,
669 0x63, 0x9e, 0x94, 0x45, 0x2f, 0x51, 0x63, 0xb9, 0x99, 0xef, 0xdb, 0x4f,
670 0xab, 0xb9, 0x31, 0xd1, 0x13, 0x4a, 0xf6, 0x17, 0xc1, 0x58, 0x1f, 0xf5,
671 0x3a, 0x07, 0xfb, 0xa8, 0xed, 0xb3, 0x22, 0xc7, 0xb2, 0x90, 0x3d, 0x2b,
672 0x3f, 0xf3, 0x0f, 0xa8, 0x67, 0xf0, 0xf3, 0x8a, 0x7f, 0x4a, 0x91, 0x5e,
673 0xcb, 0x65, 0xcb, 0xb9, 0xff, 0xbc, 0xf5, 0x95, 0xa3, 0x3b, 0xd2, 0x57,
674 0x52, 0x89, 0x8a, 0xbe, 0xe2, 0xbe, 0x77, 0x39, 0x07, 0xa6, 0x5f, 0xf6,
675 0x7b, 0x00, 0x0c, 0xda, 0xa1, 0x8b, 0x25, 0x00, 0x4b, 0x63, 0xc6, 0x0e,
676 0x45, 0xfd, 0x53, 0xb4, 0x50, 0x1c, 0x32, 0x92, 0x59, 0xe8, 0xcc, 0xfc,
677 0x99, 0x8f, 0xee, 0x91, 0x3e, 0x1a, 0x7d, 0x0d, 0xf8, 0xca, 0x6e, 0x1e,
678 0xff, 0x7a, 0xbf, 0xcc, 0xcb, 0x76, 0x9f, 0xef, 0xe2, 0xf3, 0x7b, 0x42,
679 0xd5, 0xe7, 0x77, 0xf1, 0xf9, 0xde, 0x04, 0xf6, 0xd0, 0x58, 0x82, 0x5f,
680 0xd2, 0xa1, 0x34, 0xef, 0xcd, 0x42, 0x91, 0x65, 0xeb, 0xcb, 0xcc, 0x47,
681 0x57, 0xf4, 0xb8, 0x3e, 0xd4, 0xec, 0x88, 0x3d, 0x31, 0x78, 0xcc, 0xb9,
682 0xcc, 0x04, 0x8f, 0x1b, 0x24, 0xff, 0xcb, 0x6c, 0x8b, 0xae, 0x68, 0x5c,
683 0xd5, 0xf9, 0xf6, 0xdf, 0xe8, 0x93, 0x39, 0x55, 0xdf, 0xdd, 0x23, 0xe1,
684 0xe7, 0x08, 0x9e, 0x72, 0x9e, 0xe1, 0xf2, 0xbc, 0xc0, 0x43, 0x7b, 0xda,
685 0x2a, 0x3f, 0xbf, 0x13, 0x78, 0xd5, 0x8a, 0xbc, 0xd9, 0xc0, 0x12, 0xf3,
686 0xc5, 0x19, 0xc7, 0x4c, 0x97, 0x73, 0xd5, 0x1e, 0x1f, 0x90, 0xd7, 0xbf,
687 0xd9, 0x27, 0xfb, 0x83, 0x7e, 0x6b, 0x40, 0xf7, 0x48, 0x94, 0x32, 0x07,
688 0xf9, 0xcb, 0x3e, 0x01, 0x1b, 0xff, 0x32, 0xf8, 0xa5, 0xc1, 0xdf, 0x79,
689 0x3d, 0x09, 0xcc, 0xf1, 0x4a, 0x9f, 0xee, 0x17, 0x23, 0xd7, 0x15, 0xe7,
690 0xf9, 0x46, 0x78, 0x5d, 0xfa, 0xfc, 0x0c, 0x1f, 0x7b, 0xed, 0x2f, 0xee,
691 0xd5, 0x96, 0x90, 0xfd, 0xc5, 0xda, 0x12, 0xc9, 0x09, 0xb9, 0xcf, 0x15,
692 0x9f, 0x6e, 0xa8, 0xec, 0xd3, 0x3d, 0x9f, 0xb9, 0xd5, 0x07, 0xff, 0x86,
693 0xb1, 0xc4, 0xfb, 0x1d, 0x7c, 0x9e, 0xc7, 0xa2, 0x56, 0x21, 0xcd, 0x9f,
694 0x1d, 0x2a, 0xaf, 0xa7, 0x1e, 0x57, 0x64, 0x9e, 0x84, 0x96, 0x5b, 0xb8,
695 0xf6, 0x43, 0xbe, 0x87, 0x94, 0x5d, 0x8d, 0x9f, 0x43, 0x75, 0x79, 0x30,
696 0xf5, 0x38, 0xb6, 0x99, 0x1f, 0x56, 0xc4, 0x13, 0x3d, 0xf0, 0x6c, 0xb3,
697 0x7e, 0x06, 0xd7, 0x84, 0x1f, 0x2d, 0x56, 0x47, 0xaf, 0xa0, 0xe3, 0x00,
698 0xfd, 0xce, 0x62, 0x8a, 0x76, 0xf1, 0x5e, 0xfd, 0xa6, 0xf1, 0x00, 0xe2,
699 0xed, 0x24, 0x73, 0x9e, 0x18, 0xc6, 0x19, 0x67, 0xe2, 0x94, 0x11, 0x01,
700 0xbf, 0x2c, 0x05, 0x9c, 0x0e, 0x6a, 0x66, 0x5a, 0xfd, 0x65, 0x1a, 0x65,
701 0xfb, 0x0f, 0x34, 0xeb, 0x84, 0xe2, 0x04, 0x7a, 0xb3, 0xcd, 0x43, 0xac,
702 0x13, 0xc7, 0x8a, 0xc0, 0x67, 0x83, 0x3e, 0x9f, 0x23, 0xfa, 0x5c, 0x6e,
703 0xd4, 0xfc, 0x26, 0x39, 0x56, 0xe5, 0x77, 0xdb, 0x8c, 0xf2, 0x3c, 0xe2,
704 0xc5, 0x2f, 0xd3, 0xfb, 0xa2, 0xcf, 0x09, 0xe0, 0xa8, 0xf7, 0xfd, 0x4b,
705 0x74, 0x32, 0x81, 0x79, 0x6f, 0x9f, 0x3e, 0x8f, 0xef, 0x88, 0x3e, 0xdb,
706 0x3c, 0xe8, 0xf3, 0xc5, 0x7e, 0x89, 0x37, 0x25, 0xc6, 0xd1, 0x36, 0x9a,
707 0xcb, 0x22, 0x07, 0xec, 0xd3, 0xe8, 0x3b, 0x95, 0x4d, 0x32, 0x5f, 0x4a,
708 0x56, 0xf8, 0xd2, 0x85, 0x28, 0x1b, 0xc3, 0x4c, 0xe3, 0xe8, 0xcb, 0xa6,
709 0xf2, 0x7e, 0xb0, 0x8e, 0x01, 0x1a, 0x5d, 0x6e, 0xe7, 0x6b, 0x69, 0x3d,
710 0x3a, 0x15, 0x51, 0xb5, 0xfe, 0xb6, 0x15, 0x63, 0xfe, 0x78, 0x9e, 0x69,
711 0x39, 0x9d, 0xbd, 0x97, 0x0a, 0xc1, 0x21, 0x1a, 0x59, 0xd6, 0xfd, 0x4d,
712 0x44, 0xce, 0xc6, 0xa0, 0xe4, 0x49, 0x7a, 0xdd, 0x9f, 0x10, 0xbe, 0x0b,
713 0xeb, 0xd2, 0xc7, 0xb5, 0xee, 0xf6, 0x2d, 0xf8, 0xd2, 0x25, 0x45, 0xb3,
714 0xa5, 0xcb, 0xd1, 0x30, 0xa5, 0xa2, 0x53, 0xaf, 0xf4, 0x03, 0xff, 0x47,
715 0x2e, 0xc1, 0x0f, 0x07, 0x1e, 0x6d, 0x51, 0x22, 0x53, 0x0b, 0x8b, 0x21,
716 0x5e, 0x37, 0x7e, 0x2f, 0x7d, 0x30, 0x17, 0x7e, 0x40, 0xc8, 0xfe, 0xd1,
717 0x4b, 0x3c, 0x4e, 0xca, 0x26, 0xc5, 0x37, 0xbc, 0xf0, 0x50, 0xf7, 0xc5,
718 0xd4, 0xb8, 0x28, 0x73, 0x3d, 0x59, 0x7f, 0x33, 0x13, 0xfe, 0x5a, 0x9c,
719 0xbc, 0xe6, 0x3b, 0xba, 0x68, 0xd1, 0xb1, 0x8c, 0xfd, 0xf5, 0x14, 0x4d,
720 0x31, 0x5d, 0xbb, 0xe5, 0x05, 0x8f, 0x27, 0xe0, 0xd9, 0x34, 0xd3, 0x3e,
721 0xdb, 0xcd, 0x59, 0x4b, 0xe6, 0xdd, 0x89, 0xde, 0x73, 0x38, 0x46, 0xdd,
722 0xf1, 0x5f, 0xf5, 0x6b, 0x79, 0x90, 0xcc, 0xa2, 0x8e, 0x90, 0x3f, 0xf3,
723 0x3c, 0x1e, 0xb9, 0xff, 0x39, 0xdc, 0x07, 0xf2, 0x0e, 0x73, 0xe7, 0xe3,
724 0x55, 0xb9, 0xaf, 0x23, 0x7c, 0x6f, 0xd4, 0xdd, 0x1f, 0x2b, 0x4e, 0xf2,
725 0xfe, 0x76, 0x09, 0xde, 0x2c, 0xf7, 0x73, 0x9a, 0xce, 0x79, 0xf2, 0x15,
726 0xb9, 0x2f, 0x49, 0x17, 0x7d, 0x27, 0x05, 0x7d, 0x4f, 0x8b, 0xfd, 0x48,
727 0xe6, 0x0c, 0xd6, 0xd7, 0xb4, 0xef, 0x81, 0xed, 0xec, 0x5c, 0x40, 0xe7,
728 0x06, 0xf2, 0xf7, 0x0f, 0xfb, 0x45, 0x5e, 0x22, 0xec, 0xef, 0x1c, 0x3e,
729 0xa7, 0xe9, 0x79, 0x96, 0xeb, 0x2f, 0x64, 0x5a, 0xe8, 0x6a, 0xb6, 0x85,
730 0xde, 0xc9, 0x0e, 0xd1, 0x95, 0xc5, 0x6e, 0x3a, 0xc7, 0x3a, 0xf3, 0x39,
731 0x27, 0x60, 0xa5, 0xa9, 0x1b, 0xf1, 0x45, 0xe4, 0x0c, 0x31, 0xdd, 0x61,
732 0x3c, 0xf4, 0xbf, 0xe8, 0x5e, 0xc6, 0x39, 0xd6, 0xbd, 0x5b, 0xe9, 0x3d,
733 0x7e, 0x66, 0x3a, 0xa3, 0x73, 0x1d, 0xe0, 0x93, 0x1f, 0x2b, 0xeb, 0xaf,
734 0x5b, 0xe3, 0x88, 0xb9, 0x05, 0x8e, 0x4c, 0x8b, 0xf8, 0xd6, 0xc2, 0x22,
735 0xff, 0xbe, 0x08, 0xff, 0x39, 0xc3, 0x9b, 0xf9, 0xf3, 0x93, 0x01, 0x8c,
736 0xc7, 0x39, 0x47, 0xe6, 0x4a, 0x8a, 0xb5, 0x85, 0xf8, 0xd8, 0x27, 0x6a,
737 0xa4, 0x25, 0x1c, 0x5a, 0x79, 0x7d, 0x3e, 0x31, 0x3e, 0xb9, 0xda, 0x4a,
738 0xf3, 0x39, 0xd6, 0x41, 0x72, 0x7e, 0xb6, 0x61, 0x30, 0xf6, 0xef, 0x54,
739 0x6f, 0x61, 0xdc, 0xbf, 0x8b, 0xd2, 0x62, 0x1c, 0x7f, 0xae, 0x76, 0xd1,
740 0x42, 0xae, 0x43, 0x1d, 0xdf, 0x2b, 0x72, 0xdc, 0x65, 0x1f, 0x23, 0xfc,
741 0xb6, 0x19, 0x7f, 0x7b, 0x97, 0x71, 0x0a, 0x32, 0x55, 0xda, 0xa5, 0xe0,
742 0x35, 0x97, 0xeb, 0x7a, 0x22, 0x03, 0xe7, 0xa6, 0xe8, 0x25, 0x96, 0xb7,
743 0x23, 0x2f, 0xc3, 0x7f, 0xfc, 0x38, 0xf0, 0x26, 0x9f, 0xa2, 0x41, 0x3e,
744 0x46, 0x5f, 0x24, 0xbf, 0xa8, 0x73, 0x8a, 0x05, 0x27, 0x44, 0x6d, 0x88,
745 0xa4, 0xd1, 0x59, 0xd1, 0x8b, 0xee, 0x2d, 0xc1, 0x9b, 0xec, 0x94, 0x65,
746 0x40, 0x1f, 0x81, 0x0f, 0x46, 0xe6, 0x60, 0x1d, 0x77, 0x7a, 0xde, 0xed,
747 0x9b, 0x19, 0xa7, 0x48, 0x3f, 0xf0, 0x5e, 0xd2, 0xac, 0xea, 0x2f, 0x20,
748 0xf8, 0xbd, 0xb9, 0x4f, 0xd7, 0x4b, 0xea, 0x63, 0x2d, 0x2b, 0xf4, 0x71,
749 0x47, 0xcd, 0xef, 0x66, 0xcd, 0xef, 0xe5, 0x7c, 0x39, 0x96, 0x79, 0x2c,
750 0xe7, 0x49, 0xf6, 0x28, 0x4a, 0x2e, 0x4b, 0xfc, 0x33, 0xf7, 0x8d, 0x99,
751 0x8f, 0x2a, 0x1d, 0x3c, 0xb9, 0x36, 0x1a, 0xea, 0x31, 0x26, 0x8c, 0xe4,
752 0xe4, 0x3f, 0x96, 0x22, 0x09, 0xe8, 0x45, 0x4f, 0xee, 0x51, 0xf9, 0xa7,
753 0x3c, 0xaf, 0x54, 0x18, 0xaa, 0xdb, 0xec, 0x5a, 0x07, 0xad, 0x8b, 0x9e,
754 0x5c, 0x42, 0xc7, 0xe0, 0xeb, 0x71, 0x9f, 0x94, 0xd9, 0x44, 0xe8, 0x73,
755 0x0e, 0x1a, 0xdf, 0x1f, 0xba, 0xc4, 0xfb, 0x19, 0x5f, 0xfb, 0x69, 0xe9,
756 0xa4, 0xe8, 0x71, 0x83, 0xb1, 0x5d, 0x34, 0x27, 0x74, 0x7e, 0xd6, 0x5f,
757 0xaa, 0xec, 0xaa, 0x29, 0xcc, 0x33, 0x85, 0xd8, 0x8a, 0xe1, 0xfc, 0xbe,
758 0x2f, 0x99, 0x97, 0xb1, 0xf2, 0x78, 0x4d, 0xac, 0x7c, 0x56, 0xc4, 0xca,
759 0x11, 0x27, 0x07, 0x5c, 0x01, 0x4b, 0xaf, 0x9c, 0x16, 0xec, 0x63, 0x98,
760 0x90, 0x1b, 0x7e, 0xee, 0xa2, 0xe0, 0x37, 0xe1, 0x98, 0x5f, 0xe6, 0x57,
761 0xc7, 0x79, 0xc6, 0x06, 0x5d, 0x60, 0x7c, 0xb0, 0x27, 0x36, 0x58, 0x97,
762 0x58, 0xc9, 0x7e, 0x99, 0xae, 0xe4, 0x9b, 0x58, 0xd7, 0x5b, 0xa0, 0x8d,
763 0x3c, 0xb1, 0x4e, 0xd8, 0x4d, 0x0b, 0x61, 0xc6, 0xb1, 0x89, 0x36, 0xde,
764 0x4f, 0xd6, 0x6b, 0x27, 0x98, 0xee, 0x78, 0xee, 0x2b, 0xb9, 0xd2, 0x8f,
765 0xd2, 0xe1, 0x88, 0x15, 0x9d, 0xea, 0x60, 0xbb, 0xc5, 0xe4, 0x7f, 0x87,
766 0xff, 0x77, 0x85, 0x00, 0x93, 0xc2, 0x2a, 0x7e, 0x67, 0x9d, 0x27, 0x53,
767 0xfa, 0xd1, 0x1c, 0x8f, 0x99, 0x9b, 0x82, 0xfd, 0x03, 0x3b, 0xcf, 0xe1,
768 0x7f, 0x39, 0x66, 0x65, 0x95, 0xf1, 0xfb, 0x62, 0x2a, 0x64, 0x08, 0xde,
769 0xbe, 0xce, 0x3c, 0xfe, 0x02, 0xcd, 0xf1, 0x1c, 0xae, 0x10, 0xae, 0xb5,
770 0x28, 0x19, 0xde, 0xc7, 0x78, 0xdf, 0xcd, 0x9f, 0xa8, 0xbf, 0x6a, 0xa7,
771 0x85, 0xc9, 0x31, 0x55, 0x7f, 0xf5, 0xbd, 0x06, 0xf5, 0x57, 0xb8, 0x8e,
772 0xe5, 0xfe, 0x62, 0xe9, 0xe6, 0x5c, 0xd8, 0xfd, 0x3c, 0x32, 0x92, 0xe1,
773 0x4e, 0xa1, 0x23, 0xad, 0xac, 0xfa, 0xf8, 0xd9, 0x11, 0x2b, 0x39, 0xc5,
774 0x73, 0xcc, 0xb9, 0xe7, 0x5d, 0xba, 0x19, 0x0b, 0x63, 0x9c, 0xbf, 0x66,
775 0x1c, 0xdb, 0xca, 0x53, 0x72, 0x3d, 0x85, 0x5c, 0xe9, 0xe7, 0xd1, 0xb0,
776 0x5e, 0x9f, 0xfb, 0x5a, 0xac, 0x03, 0xf4, 0xc4, 0x9f, 0x2b, 0x5d, 0xbe,
777 0x2b, 0x59, 0xd8, 0xdf, 0x06, 0xe3, 0x39, 0x66, 0x34, 0x44, 0xa9, 0x15,
778 0xa6, 0xef, 0x8b, 0x1d, 0xbe, 0x8d, 0xec, 0x95, 0x52, 0xb2, 0x2a, 0x97,
779 0xa5, 0xda, 0xef, 0x2e, 0x6d, 0xae, 0x21, 0x72, 0x96, 0x20, 0x33, 0x21,
780 0x2f, 0x53, 0x25, 0xbf, 0x03, 0xfd, 0x0e, 0xb6, 0xd0, 0x59, 0xe6, 0x57,
781 0x32, 0x1f, 0x89, 0x79, 0x27, 0xf3, 0x2c, 0x49, 0x2f, 0xf1, 0xaa, 0xd7,
782 0x0d, 0x48, 0x9c, 0x1d, 0xa9, 0xe4, 0x41, 0xba, 0xe2, 0xe9, 0x01, 0x57,
783 0x3c, 0xdd, 0x74, 0xe5, 0x41, 0x06, 0x85, 0x3e, 0x56, 0xd1, 0xa1, 0x82,
784 0x4a, 0x87, 0x82, 0xae, 0x25, 0x79, 0x59, 0xa1, 0xcc, 0xcb, 0x76, 0x6f,
785 0xc1, 0xcb, 0xbc, 0x6c, 0xd3, 0x75, 0xc5, 0x37, 0xec, 0x30, 0xe4, 0xfc,
786 0xe5, 0xe2, 0x34, 0xbd, 0xcd, 0x3c, 0xe2, 0xad, 0x62, 0x98, 0xf9, 0xc6,
787 0x24, 0xf3, 0x8d, 0x09, 0xe6, 0x1b, 0x0e, 0xc3, 0xc0, 0xe2, 0xb5, 0x5f,
788 0xf3, 0x5d, 0x59, 0x84, 0xbc, 0x98, 0xa2, 0xe7, 0x8b, 0xe0, 0xc1, 0x93,
789 0xac, 0xf3, 0x5c, 0xf3, 0x6d, 0x2c, 0x76, 0x31, 0xbe, 0x4a, 0x3d, 0xa7,
790 0xda, 0x8e, 0x41, 0xaf, 0x15, 0xf8, 0x87, 0xaf, 0x82, 0xcf, 0xbc, 0x91,
791 0xa2, 0x4e, 0x86, 0x3d, 0xe0, 0xbc, 0x8e, 0xde, 0x14, 0xaf, 0x81, 0x96,
792 0xd1, 0x13, 0xf8, 0xbb, 0xe3, 0x53, 0x3c, 0xf7, 0x4e, 0xdf, 0x02, 0xef,
793 0xcb, 0xd3, 0xe1, 0x94, 0xd9, 0xcb, 0x38, 0x7f, 0xac, 0x82, 0xf3, 0xa9,
794 0x34, 0xaf, 0xa0, 0x67, 0xb9, 0x9b, 0xc6, 0x0e, 0x44, 0xf7, 0xf6, 0x30,
795 0x9d, 0x22, 0x37, 0xa2, 0xd2, 0xa7, 0xc7, 0x4f, 0x27, 0x83, 0x6d, 0xaa,
796 0xbf, 0x8f, 0xc5, 0xf2, 0xf1, 0x03, 0xbe, 0xcf, 0x2d, 0x5f, 0x3a, 0xfb,
797 0x2a, 0x3f, 0x03, 0xc7, 0x5f, 0x85, 0xff, 0x93, 0xed, 0x83, 0x56, 0xe1,
798 0x3f, 0x2a, 0x88, 0xb1, 0x38, 0xb6, 0x27, 0x98, 0x97, 0x85, 0xd7, 0x0d,
799 0x7b, 0x3a, 0x62, 0x30, 0xd1, 0x75, 0x99, 0xbc, 0xde, 0xd2, 0xa0, 0x8c,
800 0xc1, 0xed, 0xdd, 0x2b, 0xf9, 0x06, 0xe3, 0x66, 0x30, 0x22, 0x6c, 0xb4,
801 0xa6, 0x25, 0x29, 0x27, 0x0b, 0xbc, 0xcf, 0x2b, 0xe1, 0x09, 0xde, 0xe7,
802 0x0e, 0x25, 0x23, 0x53, 0xfc, 0xbb, 0x90, 0xbf, 0x2c, 0x2b, 0x87, 0xd0,
803 0xb3, 0xda, 0x14, 0xfd, 0x20, 0x66, 0xd1, 0x6f, 0xa7, 0x83, 0xef, 0x6b,
804 0x33, 0xd6, 0x82, 0x4f, 0x7c, 0xe0, 0x4b, 0x66, 0xf1, 0x5c, 0xe0, 0x21,
805 0x7f, 0xcf, 0x4f, 0xd1, 0x85, 0x8c, 0x9e, 0xc3, 0x80, 0x61, 0xbc, 0x84,
806 0x79, 0xf8, 0x68, 0xb7, 0xf3, 0x43, 0x86, 0x17, 0x1f, 0xff, 0x71, 0xed,
807 0x9c, 0x86, 0xd5, 0x9c, 0xd0, 0xd3, 0xb2, 0x05, 0x3d, 0x7c, 0x08, 0xbd,
808 0x8f, 0x0a, 0xa2, 0xe7, 0x64, 0xb3, 0xb0, 0x4d, 0x0b, 0xc2, 0xc6, 0x28,
809 0x85, 0x2a, 0x7d, 0x30, 0xef, 0xa9, 0x39, 0xf7, 0x13, 0x5f, 0x7a, 0xf1,
810 0xa0, 0xd0, 0xc5, 0x46, 0x0e, 0xec, 0x55, 0xf5, 0xa7, 0x5d, 0xe2, 0xbe,
811 0xc6, 0x32, 0x7e, 0x7b, 0x50, 0xfd, 0xf6, 0x49, 0xa1, 0x03, 0x23, 0x2f,
812 0x2e, 0xb0, 0x24, 0xf0, 0x9c, 0xf7, 0xd7, 0x99, 0x60, 0x3c, 0x0f, 0xad,
813 0xc0, 0x77, 0x2f, 0xe0, 0xa9, 0xe1, 0x01, 0x58, 0x00, 0xf7, 0x3b, 0x14,
814 0xde, 0xdb, 0x56, 0xdc, 0xaf, 0xd7, 0xdd, 0x08, 0xce, 0xac, 0xd3, 0x64,
815 0xb0, 0x56, 0xac, 0x69, 0x8f, 0x2f, 0x92, 0xb7, 0x8c, 0xf4, 0x22, 0x6c,
816 0x1a, 0xd4, 0xb5, 0xdc, 0x85, 0xbc, 0x29, 0x9e, 0xc3, 0x1e, 0x8a, 0x24,
817 0x30, 0x2f, 0x8c, 0xd3, 0x30, 0xf8, 0xb7, 0x1a, 0x58, 0xb8, 0xaf, 0xeb,
818 0x56, 0xd7, 0xb5, 0x8a, 0xbd, 0x20, 0x03, 0xcf, 0xd1, 0xcf, 0xc6, 0x73,
819 0xf1, 0x7c, 0x5c, 0x87, 0xfb, 0xc9, 0xfb, 0xf6, 0x31, 0x7f, 0x8e, 0x4e,
820 0xc9, 0x7b, 0x19, 0x97, 0xe4, 0x6f, 0x7d, 0x8e, 0xf7, 0x7c, 0xe5, 0xfe,
821 0xf9, 0x54, 0xbf, 0x1e, 0xec, 0x5f, 0x37, 0xe5, 0x85, 0x8f, 0x13, 0xbf,
822 0x75, 0x8a, 0xdf, 0xa2, 0x4e, 0xa7, 0xd8, 0xd7, 0xf3, 0x7c, 0x3c, 0x9f,
823 0xed, 0xf2, 0xc1, 0x36, 0x4f, 0x27, 0x3a, 0x7d, 0xf9, 0x3c, 0xd6, 0xdb,
824 0xe9, 0x8b, 0x33, 0xee, 0xc7, 0xb2, 0xf1, 0xd2, 0x82, 0xe0, 0x31, 0xac,
825 0xd3, 0xf6, 0xda, 0xe6, 0x49, 0xe3, 0x4f, 0x86, 0x64, 0x6f, 0x5b, 0x7c,
826 0x67, 0xfa, 0xcb, 0x30, 0xfd, 0x65, 0x98, 0xfe, 0x32, 0x4c, 0x7f, 0x19,
827 0xa6, 0x3f, 0xb6, 0x4b, 0xdf, 0x64, 0x99, 0xf1, 0x6d, 0x96, 0x19, 0x92,
828 0x66, 0x23, 0xca, 0x8f, 0xa9, 0x69, 0xb6, 0xb6, 0x3e, 0x53, 0xd3, 0x28,
829 0xe4, 0x34, 0xf9, 0x0e, 0x8f, 0x57, 0xd3, 0xea, 0x55, 0xa6, 0xd5, 0xa6,
830 0x99, 0x7e, 0xba, 0x91, 0xc3, 0x9e, 0xd9, 0xd6, 0x79, 0xe6, 0xd1, 0x71,
831 0x3f, 0x74, 0xaa, 0x00, 0xd3, 0x13, 0x74, 0x4a, 0x9b, 0xe1, 0xde, 0x4f,
832 0x37, 0x99, 0x4f, 0xdf, 0xc8, 0x81, 0x76, 0xef, 0x52, 0xc7, 0x19, 0xa6,
833 0x5d, 0xc8, 0xb9, 0x25, 0xdf, 0xd5, 0xac, 0xc1, 0xba, 0x57, 0xc0, 0x4c,
834 0x12, 0xf8, 0xa8, 0xd0, 0xc7, 0x78, 0xdf, 0xd7, 0x99, 0xdf, 0xc3, 0x57,
835 0x87, 0xbe, 0x5f, 0x79, 0x1f, 0xcb, 0x89, 0xd0, 0x15, 0xe6, 0xa3, 0xa7,
836 0x73, 0x4b, 0x4c, 0xef, 0xbd, 0xf4, 0x85, 0x1c, 0xe4, 0x31, 0x60, 0xc4,
837 0xc7, 0x79, 0x12, 0x3e, 0x30, 0x63, 0x06, 0x6b, 0x1f, 0x4b, 0x19, 0x02,
838 0x4f, 0x9e, 0x01, 0x1c, 0x18, 0xf6, 0x67, 0xf6, 0xa2, 0x67, 0x7d, 0xc4,
839 0x68, 0x56, 0x3e, 0x45, 0x7c, 0xc7, 0x78, 0x8c, 0x05, 0xdc, 0x70, 0xdc,
840 0x28, 0xfe, 0x88, 0xf7, 0x42, 0x84, 0x19, 0x1e, 0xb5, 0x7c, 0xeb, 0x02,
841 0x7a, 0x91, 0x02, 0x5e, 0xd3, 0x51, 0x3f, 0x6a, 0xc5, 0xe9, 0x39, 0xbc,
842 0xff, 0xe0, 0x85, 0x22, 0xe6, 0xbd, 0x48, 0x0b, 0x41, 0xf0, 0x21, 0x3b,
843 0x7c, 0x9d, 0x24, 0xec, 0x5a, 0x59, 0xbf, 0xfc, 0xbc, 0x37, 0x6f, 0xb3,
844 0xa2, 0x42, 0x1f, 0x6e, 0x61, 0xfb, 0x06, 0xb0, 0x79, 0x8b, 0x71, 0x2d,
845 0x0c, 0x9b, 0x5f, 0xf1, 0xb5, 0x37, 0x99, 0xe7, 0x60, 0xcf, 0x3a, 0x85,
846 0x8c, 0xf1, 0xe2, 0x65, 0x1b, 0x8a, 0x97, 0x39, 0x2e, 0x5e, 0x96, 0x2e,
847 0xf3, 0x32, 0xc6, 0x09, 0xc1, 0xc3, 0xc0, 0xa3, 0x66, 0x59, 0x4f, 0x94,
848 0xdf, 0xa1, 0xff, 0xed, 0x16, 0x3c, 0x8b, 0x79, 0x3d, 0xdb, 0x0d, 0x85,
849 0x62, 0xca, 0x77, 0x48, 0xf0, 0x0e, 0x8d, 0xd7, 0xff, 0xa3, 0xe8, 0xa1,
850 0x55, 0xf0, 0x81, 0xf4, 0x2c, 0xf8, 0x95, 0xd7, 0xf8, 0xff, 0x02, 0x6c,
851 0x79, 0xbc, 0x13, 0x7a, 0x8d, 0xf9, 0x58, 0x21, 0x0c, 0x9b, 0xb5, 0x43,
852 0xd9, 0x36, 0xe8, 0xbb, 0xb5, 0x07, 0xb9, 0x96, 0x56, 0xb4, 0xcc, 0xc7,
853 0x76, 0x2b, 0xbf, 0x05, 0xfc, 0x8c, 0xd8, 0xeb, 0x3a, 0x5d, 0xc0, 0x82,
854 0x2e, 0xc0, 0x63, 0x03, 0x0c, 0x1f, 0xd1, 0x1b, 0x9c, 0xe8, 0x16, 0xc3,
855 0x01, 0xfb, 0x7c, 0x0b, 0xfb, 0xcc, 0xba, 0x2c, 0x05, 0xe6, 0xa6, 0x02,
856 0x03, 0x98, 0xdf, 0xc2, 0x6a, 0x85, 0x1f, 0x9e, 0xcf, 0x0c, 0x18, 0x85,
857 0xac, 0x9c, 0xe3, 0xca, 0xb8, 0xe4, 0x79, 0x85, 0x3c, 0x7a, 0x7b, 0x89,
858 0xb9, 0xf2, 0x1c, 0xf5, 0xfa, 0x04, 0xff, 0x52, 0x74, 0xbf, 0x1d, 0x5a,
859 0x4b, 0x30, 0x5d, 0x61, 0x4f, 0x52, 0x2e, 0x9c, 0x79, 0x94, 0x9f, 0x8f,
860 0x73, 0x8d, 0xd7, 0x71, 0xb3, 0xbc, 0x8e, 0x08, 0xaf, 0x03, 0x63, 0x6f,
861 0xf9, 0x6e, 0xa8, 0x75, 0xdc, 0x28, 0xaf, 0x63, 0x56, 0xad, 0x83, 0xd2,
862 0xc6, 0xcc, 0x6e, 0xa5, 0xc7, 0x6f, 0x79, 0xcf, 0xd6, 0x28, 0xeb, 0x27,
863 0xe9, 0x55, 0xc0, 0xf3, 0x1e, 0x85, 0x2f, 0x6e, 0x7f, 0xa8, 0x7b, 0x6e,
864 0xf6, 0xc4, 0x75, 0xfa, 0x5d, 0xba, 0x29, 0xf4, 0x93, 0x61, 0xd6, 0x4f,
865 0x70, 0x9e, 0x16, 0xc0, 0x87, 0xd3, 0x41, 0xf4, 0x9b, 0x1d, 0x64, 0x98,
866 0xb1, 0x5d, 0x35, 0xc5, 0x9f, 0xc2, 0x4f, 0x86, 0xfb, 0xe8, 0xeb, 0xbf,
867 0x48, 0x37, 0x17, 0xc1, 0xab, 0xa1, 0x8f, 0xca, 0x9e, 0xb4, 0x37, 0xd7,
868 0xa4, 0x9f, 0x36, 0xee, 0xe9, 0xa7, 0x85, 0x8f, 0x36, 0x0c, 0x7d, 0xdd,
869 0x84, 0x3f, 0x37, 0x26, 0xde, 0x67, 0xc1, 0xc7, 0x45, 0xdc, 0xcb, 0x8b,
870 0xef, 0x4c, 0xbb, 0x72, 0xdc, 0x90, 0x73, 0x92, 0x62, 0x3e, 0xe2, 0x98,
871 0x4d, 0x86, 0xac, 0x9d, 0xb9, 0x5c, 0xd4, 0x3a, 0x51, 0x9c, 0xf7, 0xc8,
872 0x09, 0x1b, 0x46, 0x44, 0xf8, 0x0c, 0x5a, 0x9d, 0x0e, 0x6a, 0x61, 0x39,
873 0x79, 0x8a, 0xd0, 0x13, 0xcd, 0xb6, 0xe0, 0xcb, 0xbf, 0xc0, 0xb8, 0xb7,
874 0x10, 0xb6, 0x43, 0x9f, 0x13, 0xf6, 0x25, 0xe4, 0x07, 0xde, 0xa7, 0x02,
875 0x18, 0x63, 0x0e, 0xfc, 0x7d, 0x15, 0xfd, 0x30, 0xc3, 0xbc, 0x7e, 0xf8,
876 0x81, 0x47, 0xad, 0x77, 0x58, 0xee, 0x5c, 0x10, 0xfe, 0x95, 0xb3, 0x94,
877 0x66, 0x3a, 0x3c, 0x2c, 0xe8, 0xd0, 0x18, 0x66, 0x6a, 0x61, 0xfa, 0x41,
878 0x8e, 0xc1, 0x98, 0xe8, 0xbf, 0x23, 0x6d, 0x16, 0x5e, 0xe5, 0x9a, 0xea,
879 0x6b, 0x90, 0x00, 0x6f, 0xd8, 0xbe, 0x6f, 0x21, 0xf1, 0x91, 0x7d, 0x2a,
880 0x6e, 0x5d, 0xab, 0xd6, 0x87, 0x0d, 0xfb, 0xcc, 0x12, 0x7d, 0x1f, 0x01,
881 0x3b, 0xe1, 0x17, 0x34, 0x26, 0x19, 0x6e, 0xfa, 0xdd, 0x35, 0x6e, 0xfb,
882 0xff, 0x29, 0x51, 0x9f, 0xff, 0x46, 0x51, 0xca, 0xd8, 0x34, 0xdb, 0xe6,
883 0x0b, 0x07, 0xdc, 0x3a, 0x87, 0x9d, 0x8d, 0x09, 0x9f, 0xcc, 0x00, 0x45,
884 0x97, 0x27, 0xe9, 0xb1, 0x0c, 0x78, 0x14, 0x5d, 0x8f, 0x3a, 0x78, 0xc3,
885 0x06, 0x68, 0x79, 0x92, 0xe2, 0x45, 0xc0, 0xc8, 0x47, 0x0b, 0x2c, 0x05,
886 0xd2, 0x59, 0xc4, 0xee, 0xf9, 0x7b, 0x1e, 0xef, 0x57, 0xf9, 0x15, 0xe5,
887 0xf7, 0x1e, 0xa2, 0xd8, 0x32, 0xa5, 0x92, 0xe1, 0x87, 0x45, 0xcf, 0xea,
888 0x64, 0x78, 0x5c, 0xf9, 0x68, 0x42, 0x7c, 0x1e, 0x7e, 0x2f, 0x8b, 0x1e,
889 0xcd, 0xd8, 0xa9, 0x24, 0x49, 0xdf, 0x03, 0xf1, 0x1c, 0x0c, 0x96, 0xad,
890 0xbb, 0x99, 0x57, 0x1c, 0x17, 0xfe, 0x07, 0xd6, 0x44, 0x16, 0x31, 0x1e,
891 0xbe, 0x83, 0x5e, 0x82, 0xbd, 0x95, 0xcc, 0x3e, 0xa0, 0xc6, 0x96, 0xc8,
892 0x64, 0x5c, 0x30, 0x7f, 0xc9, 0x49, 0x85, 0x8d, 0xca, 0xf5, 0xf0, 0x5d,
893 0x1c, 0x17, 0xfa, 0xe1, 0x30, 0xdb, 0x30, 0x62, 0x5c, 0x69, 0x4e, 0xf8,
894 0x21, 0xf8, 0x38, 0xff, 0xd3, 0x01, 0xfd, 0x6e, 0x03, 0x9c, 0x97, 0xfe,
895 0x09, 0xbe, 0x67, 0x9e, 0xe7, 0x51, 0x95, 0x17, 0x3f, 0x44, 0x91, 0x1d,
896 0xf8, 0x8b, 0x66, 0xef, 0xa8, 0xbf, 0x88, 0x61, 0xcd, 0xb2, 0xe5, 0x32,
897 0xd3, 0xc6, 0xdb, 0x5b, 0xda, 0x71, 0xef, 0x6b, 0x19, 0xcd, 0xb0, 0x32,
898 0xc5, 0xfb, 0x2f, 0xd0, 0xeb, 0x73, 0xa1, 0xf8, 0x29, 0xbc, 0x47, 0xc6,
899 0x97, 0x10, 0x3a, 0x6f, 0x88, 0x75, 0x17, 0xe8, 0x30, 0xa3, 0x22, 0xbe,
900 0x15, 0x79, 0xc2, 0x32, 0x16, 0xd6, 0xfa, 0xc9, 0x0f, 0xbf, 0x9a, 0xa3,
901 0x73, 0x22, 0x5a, 0x45, 0xfe, 0xba, 0x8c, 0x2b, 0x42, 0xfe, 0x82, 0x07,
902 0xfe, 0xc4, 0x97, 0x5c, 0xf3, 0xf7, 0xe9, 0x7c, 0xb7, 0x48, 0xb0, 0x9c,
903 0x4f, 0xa3, 0x78, 0x8a, 0xc6, 0x3d, 0x1d, 0xb3, 0x70, 0xbf, 0xd7, 0x0a,
904 0xb4, 0xeb, 0xd6, 0x19, 0xe0, 0x67, 0x12, 0x7b, 0x74, 0x01, 0x71, 0x5c,
905 0xa3, 0x2a, 0x1e, 0xd1, 0xc2, 0xfb, 0x04, 0x3b, 0x0f, 0xfe, 0xbb, 0xcf,
906 0xf2, 0x27, 0xe2, 0x0a, 0x27, 0x07, 0xa1, 0x27, 0xf5, 0x38, 0x8c, 0x33,
907 0x53, 0x38, 0xee, 0x67, 0xbb, 0x4b, 0xeb, 0xb5, 0xd2, 0xa7, 0xc4, 0xb6,
908 0x98, 0xda, 0x2f, 0xf8, 0x93, 0x46, 0x54, 0xbf, 0x01, 0x9b, 0xac, 0x5e,
909 0xc0, 0xe9, 0xe3, 0xa2, 0xc7, 0xad, 0x62, 0x10, 0xdb, 0xc9, 0x59, 0xc2,
910 0x3b, 0xb7, 0xd0, 0x77, 0xf3, 0x6e, 0xc0, 0x9e, 0xf7, 0xc8, 0x1d, 0xa3,
911 0xf8, 0x94, 0x7a, 0xff, 0xcf, 0x9d, 0xda, 0xb7, 0x5d, 0x1e, 0xfb, 0xf6,
912 0xbd, 0x41, 0x19, 0x03, 0xbb, 0x4b, 0x8d, 0xf1, 0xca, 0x53, 0xfd, 0xfb,
913 0xa7, 0xe1, 0x4f, 0xaa, 0xd4, 0x51, 0x5c, 0x13, 0x7c, 0xa5, 0xde, 0xa7,
914 0x1d, 0x62, 0x7e, 0x2a, 0xe9, 0xf8, 0xb8, 0x07, 0x1d, 0xf7, 0xce, 0x40,
915 0x2f, 0xb9, 0x7d, 0x3a, 0x3e, 0xd6, 0x90, 0x8e, 0xff, 0x75, 0x50, 0xfa,
916 0x54, 0xeb, 0xe9, 0x18, 0xb5, 0x3c, 0xc7, 0x8b, 0x8d, 0xfc, 0x57, 0xd8,
917 0x07, 0xd4, 0xa4, 0xc3, 0xe7, 0x01, 0x58, 0x69, 0xbf, 0x07, 0xe2, 0x7e,
918 0xc0, 0x47, 0xc4, 0x4e, 0xfe, 0x90, 0xe2, 0x8b, 0xb5, 0xb1, 0xd0, 0xcd,
919 0xae, 0xf9, 0x96, 0xc7, 0x35, 0xd0, 0xc5, 0x41, 0x0b, 0x76, 0x48, 0xda,
920 0xf4, 0x1a, 0x5e, 0xef, 0xf9, 0x0e, 0xe5, 0xec, 0x54, 0x9e, 0xe0, 0xa3,
921 0x0e, 0xd2, 0x53, 0x88, 0x2b, 0x2b, 0x1f, 0xf0, 0xd1, 0x8c, 0x5c, 0xb7,
922 0x79, 0x40, 0xe0, 0x03, 0xf4, 0xd5, 0x50, 0xc2, 0x9f, 0xe0, 0x3d, 0x95,
923 0xfe, 0xdf, 0xe4, 0x6a, 0x48, 0xed, 0x13, 0x8f, 0xc5, 0xfd, 0x3c, 0xeb,
924 0xfc, 0xb0, 0x3f, 0xf6, 0xd7, 0xd7, 0xcb, 0x79, 0xc5, 0x90, 0x05, 0x25,
925 0xfa, 0x0f, 0x96, 0x73, 0xfe, 0x03, 0xa6, 0xe8, 0xb9, 0x70, 0xb9, 0x78,
926 0x80, 0xf5, 0x47, 0xec, 0x21, 0x7c, 0x87, 0xda, 0xb7, 0xfb, 0xf6, 0x30,
927 0x75, 0xed, 0x67, 0xa9, 0x6f, 0x90, 0xc3, 0x7a, 0xa3, 0x71, 0x00, 0xf9,
928 0xe1, 0x16, 0x5f, 0x83, 0x5e, 0x51, 0x63, 0x56, 0x9c, 0x3a, 0xe0, 0x4f,
929 0x40, 0x0f, 0x68, 0x2b, 0x5d, 0x45, 0x53, 0xb3, 0x82, 0xa6, 0xe2, 0x6b,
930 0xb3, 0x8a, 0xa6, 0x66, 0x95, 0xff, 0x7c, 0x56, 0xd1, 0xd4, 0xac, 0xa2,
931 0xa9, 0x59, 0x45, 0x53, 0xb3, 0x8c, 0xd7, 0xa3, 0xac, 0xaf, 0x42, 0xf7,
932 0xd0, 0xfe, 0xcb, 0x2e, 0x4a, 0xe6, 0x70, 0x1e, 0xf2, 0xb8, 0x96, 0xae,
933 0x7e, 0x6d, 0x58, 0xfb, 0x47, 0x0b, 0x32, 0xcf, 0x8e, 0x9f, 0x85, 0x3d,
934 0x78, 0x98, 0xe1, 0x77, 0xcd, 0x37, 0xbf, 0x88, 0xb9, 0xfa, 0x28, 0x26,
935 0x7a, 0xc0, 0x36, 0x51, 0xd4, 0xad, 0xe3, 0x9a, 0xa8, 0xeb, 0x92, 0xb6,
936 0x5c, 0xaa, 0x61, 0x8d, 0x97, 0xc6, 0x8b, 0x69, 0xb5, 0x5f, 0xb5, 0x76,
937 0x4e, 0x0b, 0x25, 0xb2, 0x80, 0x2b, 0x72, 0x21, 0x2d, 0xde, 0x1b, 0x01,
938 0xa7, 0x94, 0xe9, 0x01, 0x83, 0xa3, 0x0a, 0x06, 0x4f, 0x8b, 0x35, 0x22,
939 0x97, 0x10, 0x3e, 0xc8, 0xc6, 0x70, 0x48, 0x67, 0x46, 0xf9, 0x3e, 0x8c,
940 0xfb, 0x07, 0x42, 0xcc, 0x83, 0xb6, 0x0b, 0x07, 0xf7, 0xda, 0x1b, 0xf1,
941 0x9a, 0xed, 0xd6, 0xd3, 0x5c, 0x77, 0xc9, 0x8e, 0x90, 0x92, 0x1b, 0x52,
942 0xef, 0xdd, 0xe5, 0xd8, 0x89, 0x14, 0xcf, 0xed, 0x2f, 0xc2, 0x7f, 0x39,
943 0x44, 0x6d, 0x25, 0x3a, 0x12, 0x06, 0x3e, 0x77, 0xb1, 0x5d, 0xc9, 0x73,
944 0x18, 0x2b, 0xd1, 0x85, 0xf0, 0x3e, 0xb6, 0x5d, 0xf6, 0xb3, 0x0e, 0x3a,
945 0xca, 0xff, 0x4e, 0xc4, 0xef, 0xc3, 0xbc, 0x3a, 0xf8, 0xda, 0x7e, 0x32,
946 0x7a, 0x52, 0x66, 0x2b, 0xeb, 0x07, 0x47, 0x2a, 0xf6, 0x88, 0x05, 0xff,
947 0x1c, 0xeb, 0xb6, 0xc6, 0x5c, 0xb8, 0x5b, 0xd5, 0x9c, 0xc1, 0x87, 0x8d,
948 0xf8, 0xd6, 0x3f, 0x97, 0x64, 0xaf, 0x80, 0x21, 0x75, 0xfc, 0xe3, 0x52,
949 0x64, 0x08, 0xc7, 0x78, 0xe7, 0x90, 0x3d, 0x11, 0xf1, 0xfd, 0x58, 0xea,
950 0xf2, 0x3e, 0xfb, 0x88, 0x7c, 0x3f, 0x80, 0x6d, 0x5a, 0x3e, 0x2f, 0xbc,
951 0x97, 0x3a, 0x4f, 0x25, 0x5f, 0x15, 0x74, 0x50, 0xa2, 0x7f, 0x67, 0x9a,
952 0x35, 0x09, 0xb1, 0x8c, 0x29, 0x51, 0x0b, 0x8d, 0x7c, 0xe5, 0xf9, 0x45,
953 0x3d, 0x2f, 0x47, 0xed, 0xf5, 0xfd, 0xc8, 0x37, 0xcb, 0x16, 0x68, 0x73,
954 0x99, 0x01, 0x3f, 0xda, 0xe8, 0xf2, 0x46, 0x4f, 0x50, 0xd4, 0x66, 0x77,
955 0xb3, 0x8e, 0xa3, 0xf3, 0x92, 0xc7, 0xf8, 0xfe, 0x01, 0xf1, 0xbe, 0xb9,
956 0xd8, 0x12, 0xc6, 0x35, 0xd3, 0xc8, 0x72, 0xe9, 0x21, 0xfe, 0x5d, 0xc4,
957 0x11, 0x93, 0xd4, 0xaa, 0x62, 0x04, 0x1d, 0x2a, 0xae, 0x14, 0x62, 0x5a,
958 0xaa, 0xd4, 0x1c, 0x8f, 0x94, 0x7d, 0x6d, 0xc0, 0xf1, 0x5a, 0x5f, 0xdb,
959 0x73, 0x5b, 0xc8, 0x9b, 0xad, 0xf0, 0x1a, 0x39, 0xa5, 0x2d, 0xa4, 0x7c,
960 0x88, 0xd6, 0x02, 0x6d, 0xb7, 0xb6, 0x6e, 0xc7, 0xd7, 0xb4, 0x36, 0xcf,
961 0xac, 0x9f, 0x79, 0xc7, 0x69, 0x53, 0xf8, 0xd4, 0x4c, 0xf3, 0xb9, 0x36,
962 0x96, 0xd9, 0xa8, 0x97, 0x02, 0xbc, 0xfc, 0x43, 0xa8, 0x37, 0x79, 0x32,
963 0xd0, 0x4c, 0xab, 0xab, 0xc8, 0x79, 0x78, 0xfc, 0x2e, 0x99, 0xe7, 0xfb,
964 0x08, 0xc3, 0x65, 0x3f, 0xcb, 0x37, 0x43, 0xc5, 0x70, 0x70, 0x0e, 0xbc,
965 0x41, 0xf4, 0xfd, 0x0c, 0x3c, 0x3c, 0xde, 0xc6, 0x7a, 0xbd, 0x8c, 0x01,
966 0x1c, 0xe4, 0x7b, 0x7f, 0x33, 0xf7, 0x08, 0xfc, 0x59, 0xe6, 0x61, 0xbe,
967 0x7f, 0x8c, 0xf5, 0x81, 0x08, 0x35, 0xd3, 0xca, 0x6a, 0x33, 0xeb, 0xf5,
968 0xcd, 0xac, 0x0f, 0x8c, 0x9a, 0x23, 0x3e, 0xf1, 0x2c, 0x51, 0xdb, 0xf2,
969 0xe9, 0xc0, 0x7e, 0xc6, 0x41, 0x3c, 0xeb, 0x8b, 0xea, 0x59, 0xb5, 0xcf,
970 0xb8, 0x55, 0xc2, 0xf1, 0x61, 0xff, 0xfa, 0x99, 0xab, 0x78, 0x2f, 0xd4,
971 0xe2, 0x34, 0xeb, 0xbe, 0x41, 0xf1, 0x6e, 0x46, 0x63, 0x66, 0x86, 0xed,
972 0x80, 0x30, 0x1f, 0x1f, 0xa1, 0x54, 0x31, 0x41, 0xbf, 0x57, 0x74, 0xfb,
973 0x6a, 0x8f, 0xf0, 0x9c, 0x65, 0x6d, 0x7d, 0x0b, 0xcf, 0xeb, 0x7d, 0xa7,
974 0x96, 0x67, 0xb4, 0x91, 0xff, 0x6b, 0x41, 0x6a, 0x7e, 0x11, 0xbe, 0x91,
975 0x12, 0x65, 0xc3, 0xf6, 0x85, 0xeb, 0xe2, 0xbd, 0x1b, 0x16, 0xbd, 0x22,
976 0xf2, 0x5b, 0xf9, 0x7a, 0xbe, 0xe7, 0x79, 0x8c, 0x7b, 0xc5, 0xa2, 0x2b,
977 0x8e, 0x84, 0xf7, 0x9f, 0x05, 0x82, 0xe4, 0x7f, 0x1d, 0x39, 0x48, 0xd0,
978 0xb5, 0xd6, 0xcf, 0x38, 0xfb, 0x98, 0x5f, 0xbf, 0x88, 0xeb, 0xf8, 0xf3,
979 0x75, 0x1c, 0xb7, 0xf1, 0x3a, 0x21, 0x6f, 0x91, 0x77, 0x02, 0x3e, 0xb7,
980 0x3f, 0x64, 0x0a, 0xfc, 0x3b, 0xc2, 0x38, 0xd5, 0x24, 0x7c, 0x81, 0xbd,
981 0x18, 0xeb, 0x0c, 0xb2, 0x6e, 0xb0, 0x7e, 0x66, 0x7c, 0x1f, 0x8e, 0x23,
982 0x3d, 0x7e, 0x86, 0x91, 0xc4, 0xa1, 0xb0, 0x78, 0xff, 0xa1, 0xeb, 0x2f,
983 0x70, 0x70, 0x9c, 0x78, 0x3f, 0xa1, 0x3f, 0xf0, 0x7e, 0x9a, 0xe8, 0xb3,
984 0xd4, 0x46, 0x71, 0x7e, 0x46, 0x2c, 0x27, 0xd7, 0x7d, 0xbe, 0xe8, 0x27,
985 0xe9, 0x47, 0x6a, 0x1e, 0xd6, 0xef, 0x29, 0xa4, 0x7e, 0xdc, 0x5b, 0xd3,
986 0x0a, 0xbe, 0x77, 0xd1, 0x8d, 0x5c, 0x07, 0xdd, 0x54, 0xb1, 0xa5, 0x1b,
987 0xc2, 0xae, 0x62, 0x9e, 0x9c, 0xe8, 0xa2, 0xeb, 0xab, 0x4d, 0x44, 0xbd,
988 0x6d, 0x22, 0xf6, 0x7b, 0x23, 0x97, 0xc7, 0xf3, 0x87, 0xa5, 0xdf, 0xa5,
989 0x82, 0x23, 0x37, 0x3c, 0x70, 0xe4, 0x3d, 0x81, 0x23, 0xef, 0x6d, 0x81,
990 0x23, 0x7b, 0x95, 0x2d, 0xd1, 0x46, 0xcd, 0x0a, 0x3f, 0x5e, 0x63, 0xfc,
991 0x78, 0x81, 0xf1, 0xe3, 0x50, 0x03, 0xfc, 0x30, 0x6a, 0xf0, 0xe3, 0xb0,
992 0xc0, 0x8f, 0x9f, 0x6d, 0x8a, 0x1f, 0x87, 0xfc, 0x9b, 0xf9, 0x82, 0x34,
993 0x6e, 0x0e, 0xd0, 0x4a, 0xce, 0xa1, 0xd5, 0x45, 0x9b, 0x2d, 0x7b, 0xd8,
994 0xe6, 0x88, 0x19, 0xce, 0x88, 0x7a, 0x97, 0x82, 0xc0, 0x2b, 0x96, 0xe3,
995 0x33, 0xa8, 0x69, 0xaa, 0xdb, 0x03, 0x12, 0xef, 0xa5, 0x14, 0xf0, 0x97,
996 0x7b, 0x12, 0xcb, 0xac, 0x9f, 0xf9, 0x73, 0xde, 0xc7, 0x2b, 0x6b, 0x81,
997 0x00, 0x7e, 0xf3, 0xcf, 0x04, 0x69, 0x63, 0x8d, 0xed, 0x54, 0xc6, 0xb1,
998 0xab, 0xb9, 0x21, 0xba, 0x92, 0x1b, 0xa0, 0x8d, 0xdc, 0x30, 0xbd, 0x93,
999 0xc3, 0x33, 0x00, 0x73, 0x3e, 0x16, 0x30, 0x37, 0xe8, 0x60, 0x90, 0xc7,
1000 0xac, 0x0e, 0xd0, 0xfa, 0xaa, 0xc6, 0x57, 0xe0, 0x2a, 0xf6, 0x3f, 0xd2,
1001 0x23, 0xeb, 0xd0, 0xea, 0x71, 0x20, 0x56, 0x85, 0x03, 0xf2, 0x1a, 0xec,
1002 0xfd, 0x42, 0x7d, 0x0d, 0x6d, 0xab, 0x39, 0x83, 0x1c, 0xb8, 0x36, 0xb6,
1003 0xc9, 0x6d, 0xe1, 0x73, 0x3d, 0xe8, 0x87, 0x4e, 0x6b, 0xdc, 0x4d, 0x5d,
1004 0xbc, 0x07, 0x0e, 0xf2, 0x87, 0x86, 0x59, 0x3f, 0xed, 0x16, 0xfa, 0x68,
1005 0xd4, 0x09, 0x84, 0x62, 0x54, 0x3a, 0x6b, 0x38, 0xe8, 0x93, 0xf8, 0x08,
1006 0xdf, 0xcf, 0x50, 0x7e, 0x9e, 0x4e, 0x17, 0x3e, 0xd5, 0xea, 0x9e, 0x88,
1007 0xd1, 0x9e, 0xe0, 0x39, 0x43, 0x4e, 0x56, 0xe2, 0x22, 0x54, 0x8e, 0x8b,
1008 0xb4, 0xf2, 0xba, 0x25, 0x2d, 0xcd, 0x39, 0x3c, 0xae, 0xc8, 0xe3, 0x8a,
1009 0x88, 0xa9, 0xf1, 0xf9, 0x55, 0xc4, 0x73, 0x87, 0x68, 0x63, 0x11, 0x34,
1010 0x07, 0xff, 0x44, 0x25, 0x86, 0xba, 0xb1, 0x86, 0xf3, 0xf0, 0x51, 0x54,
1011 0x62, 0xa8, 0x1b, 0x2a, 0x86, 0xba, 0xb1, 0x36, 0x2d, 0xf8, 0xf0, 0x42,
1012 0x8e, 0x79, 0x40, 0xce, 0xaf, 0xf2, 0x07, 0xf7, 0xa9, 0x77, 0xf6, 0x9c,
1013 0x10, 0x3e, 0xe4, 0x1e, 0x67, 0x73, 0x18, 0x1e, 0xac, 0x83, 0xe1, 0xb4,
1014 0xd0, 0x83, 0xe2, 0x7c, 0xcf, 0x58, 0xee, 0x04, 0xc3, 0x73, 0x96, 0x69,
1015 0x69, 0xb7, 0xa2, 0x25, 0x1d, 0x93, 0xed, 0x26, 0xf5, 0xfe, 0x1f, 0xa1,
1016 0xeb, 0x4b, 0xfe, 0x33, 0x54, 0xc3, 0x7f, 0x28, 0x10, 0x1d, 0x97, 0xd7,
1017 0xa7, 0x8b, 0xaf, 0x0c, 0x6b, 0xff, 0x5b, 0x9a, 0xef, 0xbb, 0x90, 0xdb,
1018 0x49, 0x4c, 0x97, 0xe5, 0xa6, 0x67, 0xce, 0xe0, 0x76, 0x9f, 0xad, 0x71,
1019 0xe1, 0xc4, 0x6d, 0xe0, 0x93, 0xbc, 0x47, 0x05, 0x9f, 0xfe, 0x77, 0x16,
1020 0xc0, 0xb2, 0x93, 0x05, 0x98, 0x57, 0x84, 0x80, 0xf5, 0x03, 0x03, 0xb4,
1021 0x8e, 0x39, 0x00, 0x1e, 0x53, 0x68, 0x02, 0xe6, 0x19, 0xa7, 0xf5, 0x40,
1022 0xfb, 0xfb, 0x95, 0xc1, 0xeb, 0x5d, 0x1b, 0xa0, 0x67, 0x4f, 0x2d, 0xea,
1023 0x79, 0x2c, 0x07, 0xca, 0xa3, 0x4e, 0x2a, 0x0c, 0x24, 0xe6, 0x27, 0x90,
1024 0xff, 0x80, 0xfe, 0x00, 0xf9, 0x11, 0x98, 0x9f, 0x9c, 0x81, 0x72, 0xa0,
1025 0x35, 0x53, 0xcd, 0x6b, 0x40, 0xfa, 0x40, 0x61, 0x08, 0x2a, 0x53, 0x41,
1026 0x63, 0x1d, 0x40, 0xf6, 0x12, 0x21, 0x68, 0xd8, 0x01, 0x69, 0x20, 0xbb,
1027 0x79, 0x8a, 0x08, 0x98, 0x9f, 0x14, 0x20, 0xc4, 0xd0, 0x00, 0xcf, 0x4f,
1028 0xec, 0x40, 0x97, 0xc2, 0xdc, 0xf4, 0xff, 0xff, 0x31, 0x15, 0x16, 0x60,
1029 0xda, 0x03, 0xad, 0xf9, 0xfc, 0xfd, 0xff, 0x80, 0x08, 0x0b, 0x43, 0x0b,
1030 0x7c, 0xed, 0x9e, 0xb0, 0x3c, 0xa8, 0x9c, 0x5b, 0x00, 0x64, 0xb5, 0xc1,
1031 0xeb, 0x6d, 0x16, 0xf0, 0x7d, 0xc4, 0x0b, 0x18, 0x7e, 0x01, 0xcb, 0x95,
1032 0xff, 0xff, 0x97, 0xc2, 0xd5, 0x82, 0x00, 0x00, 0xd4, 0xc2, 0xcb, 0x42,
1033 0x60, 0x7c, 0x00, 0x00, 0x00 };
1034static u32 bnx2_COM_b09FwData[(0x0/4) + 1] = { 0x0 };
1035static u32 bnx2_COM_b09FwRodata[(0x88/4) + 1] = {
1036 0x08001ad8, 0x08001b14, 0x08001b14, 0x08001b14, 0x08001b14, 0x08001b14,
1037 0x08001a24, 0x08001b14, 0x08001a98, 0x08001b14, 0x080019ac, 0x08001b14,
1038 0x08001b14, 0x08001b14, 0x080019b8, 0x0, 0x08002a2c, 0x08002a7c,
1039 0x08002aac, 0x08002adc, 0x08002b0c, 0x0, 0x08005fac, 0x08005fac,
1040 0x08005fac, 0x08005fac, 0x08005fac, 0x08005fd8, 0x08005fd8, 0x08006018,
1041 0x08006024, 0x08006024, 0x08005fac, 0x0, 0x0 };
1042static u32 bnx2_COM_b09FwBss[(0x88/4) + 1] = { 0x0 };
1043static u32 bnx2_COM_b09FwSbss[(0x5c/4) + 1] = { 0x0 };
1044
1045static struct fw_info bnx2_com_fw_09 = {
1046 .ver_major = 0x1,
1047 .ver_minor = 0x0,
1048 .ver_fix = 0x0,
1049
1050 .start_addr = 0x080000b0,
1051
1052 .text_addr = 0x08000000,
1053 .text_len = 0x7c5c,
1054 .text_index = 0x0,
1055 .gz_text = bnx2_COM_b09FwText,
1056 .gz_text_len = sizeof(bnx2_COM_b09FwText),
1057
1058 .data_addr = 0x08007d00,
1059 .data_len = 0x0,
1060 .data_index = 0x0,
1061 .data = bnx2_COM_b09FwData,
1062
1063 .sbss_addr = 0x08007d00,
1064 .sbss_len = 0x5c,
1065 .sbss_index = 0x0,
1066 .sbss = bnx2_COM_b09FwSbss,
1067
1068 .bss_addr = 0x08007d60,
1069 .bss_len = 0x88,
1070 .bss_index = 0x0,
1071 .bss = bnx2_COM_b09FwBss,
1072
1073 .rodata_addr = 0x08007c60,
1074 .rodata_len = 0x88,
1075 .rodata_index = 0x0,
1076 .rodata = bnx2_COM_b09FwRodata,
1077};
1078
1079static u8 bnx2_CP_b09FwText[] = {
1080 0x1f, 0x8b, 0x08, 0x08, 0x8e, 0xfc, 0x2f, 0x45, 0x00, 0x03, 0x74, 0x65,
1081 0x73, 0x74, 0x31, 0x2e, 0x62, 0x69, 0x6e, 0x00, 0xbd, 0x7d, 0x0d, 0x74,
1082 0x5c, 0x57, 0x7d, 0xe7, 0xff, 0xdd, 0x79, 0x92, 0xc6, 0xb2, 0x2c, 0x3f,
1083 0xcb, 0x63, 0x65, 0x22, 0x0b, 0x7b, 0x46, 0x7a, 0xb2, 0x95, 0x58, 0x64,
1084 0xc7, 0xae, 0x00, 0x6d, 0x3b, 0x85, 0xe9, 0x48, 0xb2, 0x9d, 0x0f, 0x8a,
1085 0x4c, 0x44, 0x4f, 0x5a, 0xe8, 0x22, 0xc6, 0x76, 0x48, 0x80, 0xb2, 0x4e,
1086 0x09, 0x69, 0x80, 0x04, 0x0f, 0x23, 0xf9, 0x83, 0x74, 0xec, 0x51, 0x12,
1087 0xc5, 0x76, 0x4f, 0x73, 0x58, 0x55, 0x92, 0x1d, 0x43, 0xa7, 0x1e, 0x27,
1088 0x71, 0x68, 0xf6, 0x6c, 0x68, 0xb4, 0x4a, 0xe2, 0xa6, 0x3d, 0xd9, 0xd6,
1089 0xf4, 0x84, 0x6e, 0xda, 0x43, 0x77, 0x85, 0x71, 0x88, 0x4b, 0xb3, 0x4b,
1090 0xf8, 0x68, 0x61, 0xa1, 0xe5, 0xed, 0xef, 0x77, 0xef, 0x7d, 0xd2, 0xe8,
1091 0xc3, 0x09, 0xa1, 0xbb, 0xf5, 0x39, 0xcf, 0x6f, 0xde, 0xfd, 0xfc, 0xdf,
1092 0xff, 0xfd, 0x7f, 0xdf, 0x0f, 0xad, 0x17, 0xa9, 0x17, 0xfb, 0x6f, 0x15,
1093 0x9e, 0x6d, 0x89, 0x7d, 0xbb, 0xb7, 0x5e, 0xd7, 0x73, 0x1d, 0x7e, 0x6e,
1094 0x75, 0x57, 0x46, 0x95, 0xbc, 0x89, 0x7f, 0x89, 0x9f, 0xa1, 0x4c, 0x44,
1095 0xc4, 0x0b, 0xfb, 0xe2, 0x23, 0x51, 0x95, 0x1e, 0xfc, 0x64, 0xd6, 0x97,
1096 0x68, 0x24, 0x7d, 0xf6, 0xb3, 0xbb, 0x7d, 0x91, 0x4c, 0x79, 0x4b, 0xa2,
1097 0x57, 0xfe, 0x25, 0xc8, 0xc7, 0x5c, 0x61, 0xfa, 0x5b, 0xd2, 0xff, 0xfc,
1098 0x9f, 0xbe, 0xf2, 0x8e, 0xe4, 0x6b, 0xe3, 0x11, 0x89, 0x7a, 0xe9, 0x8f,
1099 0x89, 0xb7, 0x49, 0xa2, 0xad, 0xe9, 0x81, 0x4f, 0x3e, 0xbc, 0xf9, 0x6f,
1100 0x44, 0x1a, 0xc3, 0xb6, 0x2e, 0x07, 0x5f, 0xd9, 0x2c, 0xf9, 0x96, 0x74,
1101 0x7c, 0xc8, 0x4d, 0x7b, 0xf2, 0x74, 0x45, 0x06, 0x0a, 0xc5, 0xa8, 0x44,
1102 0xd2, 0x1d, 0x2f, 0xf5, 0x46, 0xf6, 0x07, 0x11, 0xdf, 0xf7, 0x7a, 0xa5,
1103 0xa1, 0x27, 0xdb, 0x8d, 0xf4, 0xf2, 0x56, 0x51, 0x7e, 0x54, 0xb2, 0x15,
1104 0x69, 0x50, 0xbe, 0x8f, 0x77, 0xbd, 0xa8, 0x74, 0xd2, 0xcb, 0x46, 0x5c,
1105 0x29, 0x54, 0x2e, 0xac, 0x30, 0x6d, 0x96, 0xec, 0xfb, 0x6f, 0xa2, 0xe6,
1106 0x8d, 0x36, 0x4b, 0x51, 0x99, 0x8d, 0xc4, 0x05, 0xfd, 0x00, 0xe6, 0x06,
1107 0x19, 0x2e, 0x25, 0x24, 0x5b, 0x64, 0xbf, 0xae, 0xe4, 0x3c, 0xf6, 0xd9,
1108 0x80, 0xfa, 0x2b, 0x9d, 0xe5, 0xcb, 0xb3, 0xec, 0x4b, 0x28, 0x9b, 0x40,
1109 0xb9, 0x56, 0x79, 0xbc, 0x12, 0x97, 0xc7, 0x2a, 0x31, 0x79, 0xb4, 0x72,
1110 0x87, 0x64, 0x50, 0xf7, 0x6c, 0x05, 0x7d, 0x97, 0x6a, 0xa5, 0x77, 0xac,
1111 0x5e, 0xb2, 0x63, 0xed, 0xf1, 0x9c, 0x04, 0xc1, 0x27, 0x52, 0x1f, 0x95,
1112 0xa1, 0x26, 0x94, 0x2f, 0x31, 0x2f, 0xbe, 0x20, 0x2f, 0x97, 0xda, 0xe2,
1113 0xe5, 0x94, 0x23, 0x99, 0xc1, 0x64, 0x7c, 0x48, 0xf1, 0xbb, 0x46, 0xb2,
1114 0x5d, 0xf8, 0x1e, 0x70, 0x25, 0xe2, 0x07, 0xc1, 0x1d, 0xa9, 0x26, 0xc0,
1115 0x91, 0x4c, 0x24, 0x14, 0xeb, 0xb2, 0x5e, 0x32, 0x9f, 0x50, 0x51, 0xc9,
1116 0x57, 0xae, 0x93, 0x44, 0x53, 0x10, 0xbc, 0x37, 0xe5, 0x21, 0x5d, 0xa4,
1117 0xb7, 0x28, 0xfb, 0x54, 0xda, 0x47, 0x9b, 0x92, 0x52, 0xe9, 0xb5, 0x18,
1118 0xc7, 0x16, 0xe0, 0xa9, 0x56, 0x32, 0x31, 0xc9, 0xa8, 0xb4, 0x24, 0x54,
1119 0x7a, 0x05, 0xd2, 0x1c, 0xa9, 0xf1, 0xa7, 0x2c, 0x9d, 0xac, 0xc6, 0xb7,
1120 0x0c, 0xa8, 0x74, 0xd3, 0xa2, 0xf4, 0x64, 0x42, 0xd4, 0x8f, 0xea, 0xd0,
1121 0x67, 0x67, 0x46, 0x31, 0x0d, 0x6f, 0x9d, 0x76, 0xfd, 0x32, 0x69, 0x1f,
1122 0x74, 0x16, 0xa6, 0x3d, 0xb5, 0x8a, 0xb0, 0x8a, 0xe2, 0xef, 0x28, 0xe0,
1123 0x6a, 0x41, 0xff, 0xed, 0x5e, 0x0d, 0xc6, 0x35, 0x90, 0x4a, 0x7a, 0xfd,
1124 0xea, 0xc5, 0x40, 0x9a, 0x09, 0x33, 0xf3, 0x14, 0xf2, 0x50, 0x34, 0x9d,
1125 0xc2, 0xbc, 0xb9, 0x72, 0x08, 0x63, 0xbb, 0x38, 0x96, 0xf4, 0xda, 0x14,
1126 0xde, 0x53, 0xfc, 0xdd, 0x34, 0x14, 0x49, 0x07, 0x41, 0x36, 0x35, 0x2e,
1127 0xb9, 0x72, 0xd2, 0x9b, 0x05, 0x70, 0xbd, 0x63, 0x71, 0x8c, 0x1f, 0xe3,
1128 0x88, 0x65, 0x92, 0x6b, 0xa4, 0xcb, 0xce, 0xcf, 0x5f, 0xa2, 0xef, 0x76,
1129 0xef, 0x0e, 0xd5, 0xee, 0xa5, 0x54, 0xd2, 0x9b, 0x90, 0x3f, 0xc4, 0x77,
1130 0x10, 0xec, 0x4a, 0x25, 0xe3, 0x79, 0xcc, 0xdd, 0xa5, 0x62, 0x4c, 0x5e,
1131 0x2e, 0x26, 0x41, 0xa9, 0xc9, 0xce, 0x49, 0xd9, 0x92, 0x9a, 0x04, 0xdc,
1132 0x05, 0x3c, 0x07, 0x99, 0x57, 0x46, 0x5e, 0x99, 0x75, 0x83, 0xe0, 0xe6,
1133 0xd4, 0x89, 0x60, 0xa8, 0xd9, 0xd0, 0xfe, 0xd3, 0x25, 0xcc, 0x2b, 0xe6,
1134 0xe9, 0xb1, 0x12, 0xe6, 0xb5, 0x84, 0x39, 0xd5, 0xf3, 0xdf, 0x89, 0xf9,
1135 0x27, 0x8d, 0x90, 0x3e, 0xb6, 0x59, 0x7a, 0x7d, 0xb7, 0x7d, 0x8b, 0x64,
1136 0x4b, 0x8e, 0x64, 0x53, 0x3f, 0x09, 0x32, 0x9a, 0x27, 0xc4, 0xe9, 0x2d,
1137 0x91, 0x26, 0x6b, 0x00, 0x2b, 0x3f, 0x7f, 0xdd, 0x96, 0x8b, 0x3a, 0x18,
1138 0x06, 0xe7, 0x83, 0xf9, 0x51, 0xe5, 0xd7, 0xd9, 0xfc, 0x90, 0xf6, 0xf9,
1139 0x0f, 0x74, 0xe7, 0xcf, 0x97, 0xcb, 0x92, 0x36, 0x2b, 0x22, 0xb9, 0x07,
1140 0x03, 0xe9, 0x4d, 0x01, 0x5f, 0x6c, 0xd3, 0x4b, 0x89, 0xae, 0xeb, 0xb1,
1141 0x8c, 0x2e, 0x8b, 0x7f, 0x3f, 0xae, 0x41, 0x1f, 0x4e, 0x5f, 0x69, 0xbe,
1142 0x6e, 0x5f, 0xe9, 0x85, 0x98, 0x85, 0x0f, 0xdf, 0x3d, 0x4e, 0xb6, 0xf2,
1143 0x77, 0x76, 0x8e, 0xc3, 0x71, 0x74, 0x2d, 0x43, 0xe3, 0x2e, 0xf8, 0xc1,
1144 0x93, 0x5c, 0xb1, 0x07, 0xfd, 0xc6, 0xf0, 0x0e, 0x82, 0x91, 0x54, 0x26,
1145 0xe9, 0x4a, 0x1a, 0xdf, 0x03, 0x98, 0xaf, 0x0e, 0xe0, 0x4f, 0xdc, 0xec,
1146 0xe6, 0x94, 0xf4, 0x55, 0x40, 0x7b, 0x95, 0x37, 0x96, 0x14, 0x7a, 0x0c,
1147 0xa9, 0x7f, 0xb1, 0xb8, 0x61, 0x3f, 0x7c, 0xbb, 0x32, 0x02, 0xfa, 0x28,
1148 0x8c, 0xf9, 0x32, 0x5c, 0x9c, 0xf6, 0x94, 0x24, 0x41, 0xbb, 0x69, 0xe9,
1149 0xad, 0xf8, 0x52, 0x28, 0xe2, 0x5d, 0x6a, 0x07, 0xfd, 0xba, 0x92, 0x89,
1150 0x9b, 0x39, 0x29, 0x14, 0x7f, 0x09, 0xe3, 0x02, 0x8e, 0x7d, 0xfe, 0xee,
1151 0xb1, 0xb0, 0x80, 0xf7, 0xbb, 0x53, 0x1a, 0x3f, 0x6f, 0x0e, 0x06, 0xf6,
1152 0x8d, 0x31, 0x60, 0x9c, 0x85, 0xb2, 0x8b, 0x77, 0x0c, 0xef, 0x90, 0x16,
1153 0xe3, 0x80, 0xa9, 0x55, 0x86, 0x41, 0x8b, 0xbd, 0x82, 0xdf, 0x53, 0x84,
1154 0x91, 0xfd, 0xb6, 0xe8, 0xdf, 0xc3, 0x63, 0x1b, 0xf4, 0x77, 0x6e, 0xa0,
1155 0x45, 0xf2, 0x53, 0xe1, 0x58, 0x28, 0x0f, 0x28, 0x03, 0x92, 0x87, 0x45,
1156 0x28, 0x13, 0x82, 0xe0, 0xc1, 0x14, 0xe5, 0x42, 0x10, 0x3c, 0x96, 0xa2,
1157 0x9c, 0x38, 0x07, 0xfe, 0xa7, 0x6c, 0x20, 0xaf, 0xae, 0x55, 0x9c, 0x83,
1158 0x6c, 0x11, 0x7d, 0x40, 0x4e, 0xe4, 0xba, 0x4e, 0x40, 0x6e, 0x50, 0xae,
1159 0x5c, 0xf8, 0x44, 0xd6, 0xcf, 0xc7, 0x23, 0x1a, 0x0f, 0x98, 0x6f, 0xc8,
1160 0xbc, 0x8c, 0x86, 0xbc, 0x4d, 0x0a, 0x5d, 0xa3, 0xb6, 0xcc, 0x65, 0x5d,
1161 0xc6, 0x5d, 0x52, 0xe6, 0x76, 0x65, 0xf8, 0xae, 0x15, 0xf3, 0xb1, 0x42,
1162 0x11, 0x4f, 0x6d, 0x9b, 0xf8, 0x2d, 0xd1, 0x9a, 0xf4, 0x97, 0x90, 0x37,
1163 0x7d, 0xd7, 0x49, 0x7f, 0xb9, 0xbc, 0x59, 0x77, 0x69, 0xde, 0x88, 0xb8,
1164 0x7e, 0xb2, 0x73, 0x97, 0x9a, 0x01, 0x3d, 0x05, 0xc1, 0xc9, 0x54, 0x98,
1165 0xfe, 0x8f, 0xee, 0xd2, 0x3e, 0x12, 0x35, 0x4b, 0xd3, 0xee, 0x5d, 0x26,
1166 0xed, 0xc4, 0x32, 0x69, 0x1b, 0x6a, 0x97, 0xa6, 0xbd, 0x7f, 0x99, 0xb4,
1167 0xfb, 0x97, 0x49, 0xfb, 0x5f, 0xcb, 0xa4, 0x7d, 0x67, 0x99, 0xb4, 0xef,
1168 0x2d, 0x93, 0xd6, 0x52, 0xb7, 0x34, 0xcd, 0x05, 0x3f, 0x6d, 0x92, 0x42,
1169 0xec, 0x73, 0x1c, 0xbb, 0xc5, 0xcd, 0xfe, 0xc8, 0x52, 0xdc, 0xd4, 0xa0,
1170 0x5c, 0xeb, 0xa2, 0x72, 0x53, 0xcb, 0x94, 0xab, 0x45, 0xb9, 0xa6, 0x45,
1171 0xe5, 0x92, 0xcb, 0xe0, 0xba, 0x4e, 0xeb, 0xaf, 0x85, 0xe5, 0x0a, 0xcb,
1172 0x94, 0x63, 0xfa, 0x1e, 0xdb, 0xcf, 0x16, 0x68, 0x99, 0xd7, 0x9b, 0xaf,
1173 0x5a, 0x91, 0x66, 0xa6, 0xb7, 0x42, 0x47, 0xac, 0x50, 0x86, 0xdf, 0x29,
1174 0x5b, 0x98, 0xe6, 0x81, 0xee, 0xa3, 0xa0, 0x3b, 0xca, 0x47, 0xf0, 0x91,
1175 0x4f, 0xfe, 0x5d, 0x25, 0x43, 0xb1, 0x2d, 0xde, 0x2f, 0xa8, 0x06, 0xd0,
1176 0x58, 0xd2, 0x4b, 0x28, 0xf2, 0x97, 0xe4, 0x23, 0x69, 0x3f, 0xdf, 0x2b,
1177 0x2a, 0xa6, 0x24, 0x90, 0xbe, 0x94, 0x6a, 0x52, 0xb2, 0x1f, 0xfc, 0x93,
1178 0x81, 0x4e, 0xda, 0x15, 0xf4, 0x6a, 0x1e, 0x32, 0x65, 0xaf, 0x2c, 0x2b,
1179 0x7d, 0x39, 0x48, 0x19, 0x97, 0xce, 0xdc, 0x95, 0xf5, 0xa7, 0x7b, 0x6a,
1180 0x41, 0xb3, 0x17, 0x51, 0x67, 0x07, 0x6a, 0xee, 0x2d, 0xbb, 0xd2, 0x57,
1181 0xee, 0x04, 0x2f, 0x38, 0x72, 0xde, 0x5f, 0x2d, 0xe7, 0x53, 0x28, 0x5b,
1182 0x89, 0xc8, 0x4c, 0xcc, 0x91, 0x19, 0x7c, 0x67, 0x53, 0xc8, 0xab, 0x84,
1183 0xbc, 0xd5, 0x29, 0x07, 0x4a, 0xbe, 0x1c, 0x2e, 0xfd, 0x92, 0x0a, 0xf5,
1184 0x56, 0x7f, 0x6a, 0xa5, 0x9c, 0xf6, 0x4c, 0xdb, 0x3b, 0xfc, 0x69, 0x68,
1185 0x4c, 0x57, 0x2e, 0xfa, 0xc9, 0xf8, 0x8c, 0xe6, 0x89, 0x1f, 0x06, 0x7d,
1186 0x68, 0x67, 0xc2, 0x4f, 0x7a, 0x7f, 0x8a, 0xef, 0xa1, 0x32, 0xed, 0x90,
1187 0xf9, 0xb6, 0x86, 0xd1, 0xd6, 0xa1, 0xd2, 0x2a, 0xf9, 0xb0, 0xad, 0xbf,
1188 0xdd, 0x9f, 0xee, 0x04, 0xcf, 0x79, 0xa7, 0x28, 0x23, 0x8a, 0x80, 0x6b,
1189 0x10, 0xbc, 0x8d, 0xba, 0xcf, 0x69, 0x39, 0x05, 0xbb, 0xa5, 0xb8, 0x1a,
1190 0x72, 0xf7, 0x1f, 0x83, 0x0f, 0xc7, 0x58, 0x9e, 0x69, 0xd4, 0x25, 0x32,
1191 0xaa, 0xd2, 0x90, 0x09, 0xdd, 0x94, 0x85, 0x09, 0xc8, 0x41, 0xc8, 0x96,
1192 0xd2, 0x4f, 0x83, 0x8c, 0x5b, 0x2d, 0xdf, 0x24, 0x3f, 0x5f, 0x86, 0x69,
1193 0x09, 0x23, 0x2f, 0x4b, 0xb3, 0x73, 0xb2, 0x22, 0x0f, 0xf9, 0xf2, 0x74,
1194 0x85, 0x72, 0xe1, 0x7a, 0xf0, 0x68, 0xab, 0xf4, 0x15, 0x93, 0xf9, 0x8c,
1195 0x6c, 0xc2, 0xfc, 0x7d, 0x1e, 0x73, 0xea, 0xe2, 0xb9, 0xaf, 0x5e, 0x1a,
1196 0x53, 0xd0, 0xcd, 0x4c, 0x47, 0xa3, 0xcd, 0x51, 0xc8, 0xa8, 0xdf, 0x03,
1197 0x1e, 0x86, 0x39, 0xe7, 0xf1, 0x6c, 0xc4, 0x19, 0xa0, 0x3d, 0x32, 0x40,
1198 0xfd, 0x50, 0x66, 0xdb, 0x84, 0x37, 0x6e, 0x7f, 0x47, 0xb5, 0x8c, 0x31,
1199 0xbf, 0x1b, 0xf0, 0x3b, 0x61, 0x7f, 0x7b, 0xf8, 0xed, 0xdb, 0xdf, 0x31,
1200 0xfc, 0xee, 0xb4, 0xbf, 0xa1, 0x5b, 0x8b, 0x5d, 0xfa, 0xf7, 0x48, 0x69,
1201 0xfb, 0x76, 0xe5, 0x5f, 0x27, 0xb9, 0xa9, 0x56, 0x39, 0x50, 0xf4, 0xad,
1202 0x6c, 0xc1, 0x23, 0x4f, 0x3a, 0x66, 0x9c, 0x80, 0x9b, 0xb2, 0xb3, 0x94,
1203 0x77, 0x06, 0x08, 0x3f, 0x68, 0xa0, 0xb7, 0xb8, 0xc5, 0x5b, 0x23, 0xa4,
1204 0x81, 0x11, 0xa7, 0xb7, 0xe2, 0x64, 0x60, 0xaf, 0xc5, 0x87, 0xe5, 0x30,
1205 0x7e, 0x8b, 0x17, 0x49, 0x3f, 0x89, 0xb7, 0xc1, 0x01, 0xf5, 0xce, 0x70,
1206 0x89, 0xf2, 0xd2, 0xc7, 0xd8, 0x13, 0x72, 0x6e, 0x81, 0x0d, 0x45, 0x5c,
1207 0x28, 0xc9, 0x8d, 0x25, 0x4f, 0xe4, 0x25, 0x99, 0x1f, 0x07, 0x43, 0xec,
1208 0x4a, 0xb9, 0xf2, 0xde, 0x14, 0x68, 0xf7, 0x3a, 0x47, 0xb6, 0x5f, 0xe7,
1209 0xc2, 0xe6, 0xf1, 0xc7, 0xb7, 0x83, 0xfe, 0x31, 0xcf, 0x9a, 0x1e, 0xd4,
1210 0x19, 0x81, 0x9d, 0x08, 0x6c, 0x9f, 0xe9, 0xea, 0x1b, 0x2e, 0xe6, 0x3e,
1211 0xa6, 0xd2, 0xfb, 0x3e, 0x95, 0xed, 0xbe, 0x46, 0x72, 0x83, 0x0a, 0x38,
1212 0x6a, 0x1e, 0x82, 0x1e, 0xc4, 0xb8, 0x82, 0x00, 0xf4, 0x0c, 0x79, 0x7e,
1213 0xf3, 0xcd, 0x91, 0x74, 0x8d, 0xf4, 0x0e, 0x36, 0xa3, 0x0e, 0xf3, 0x88,
1214 0xaf, 0xaf, 0xa2, 0x9d, 0x64, 0xa2, 0x4f, 0xe4, 0x9e, 0x91, 0xee, 0x59,
1215 0x67, 0x78, 0xf4, 0x37, 0xc0, 0x93, 0x5b, 0x51, 0xff, 0x01, 0xd4, 0x7f,
1216 0xcd, 0x29, 0x8c, 0xfd, 0xc8, 0x19, 0x1e, 0xfb, 0x9e, 0x33, 0x32, 0xb6,
1217 0x61, 0x43, 0x7f, 0xcf, 0x86, 0x0d, 0xbb, 0x7b, 0x5c, 0x99, 0x00, 0x8f,
1218 0x65, 0xbc, 0x0d, 0x1b, 0x46, 0x7a, 0xba, 0x80, 0x83, 0x2d, 0x5e, 0x9f,
1219 0xf8, 0xde, 0x76, 0x01, 0xff, 0xc4, 0xd8, 0x67, 0x14, 0xf9, 0x49, 0xe4,
1220 0xb3, 0x7e, 0x5c, 0xe7, 0xf7, 0xca, 0x96, 0x78, 0x93, 0xb0, 0xff, 0x88,
1221 0x2d, 0x53, 0x13, 0x91, 0xfa, 0x07, 0xec, 0xfc, 0x66, 0x9c, 0x1a, 0x9f,
1222 0xe9, 0x1c, 0x0b, 0xd3, 0x39, 0xb7, 0x7f, 0x67, 0x6d, 0xd5, 0xd5, 0x48,
1223 0xe7, 0x37, 0x71, 0x46, 0xbc, 0xd0, 0xc6, 0xa8, 0xd1, 0xb6, 0x61, 0xae,
1224 0x48, 0x9a, 0x71, 0x65, 0x4f, 0xd1, 0x41, 0x1d, 0xd0, 0xc5, 0x19, 0xfb,
1225 0x1c, 0x05, 0x6c, 0x83, 0x68, 0xeb, 0xe8, 0x21, 0xd4, 0xa3, 0xcc, 0x48,
1226 0x76, 0x8a, 0xfa, 0x00, 0xca, 0x6c, 0xf1, 0xd6, 0x0a, 0x6d, 0x89, 0x3b,
1227 0x25, 0x57, 0x22, 0x7f, 0x77, 0x00, 0x9e, 0xa8, 0x24, 0x9a, 0xf1, 0x5d,
1228 0x81, 0x4d, 0xf1, 0x60, 0x8d, 0x58, 0xdb, 0x45, 0xe6, 0x6d, 0x91, 0x3b,
1229 0x94, 0xc0, 0xde, 0x18, 0x9a, 0x5c, 0x8f, 0x72, 0x0e, 0xf0, 0x42, 0xfb,
1230 0x03, 0xb4, 0x36, 0x99, 0x91, 0xec, 0x26, 0xf0, 0xc9, 0xa4, 0x87, 0x6f,
1231 0xc0, 0x35, 0xf9, 0x16, 0xbc, 0x23, 0xfa, 0xdb, 0xc0, 0x09, 0xbc, 0xa6,
1232 0x22, 0x56, 0x67, 0x75, 0xa1, 0xef, 0xf7, 0x48, 0x76, 0x34, 0x4e, 0x5b,
1233 0x62, 0x75, 0xd6, 0xcf, 0x40, 0xd7, 0x2b, 0x28, 0x41, 0x8c, 0x61, 0xd2,
1234 0x81, 0x3c, 0xa9, 0x95, 0xdd, 0x8f, 0xe0, 0xf7, 0x83, 0xc6, 0xe6, 0xdd,
1235 0x3d, 0xc9, 0x7e, 0x1a, 0x00, 0x13, 0x6c, 0x90, 0x47, 0x60, 0x9b, 0x3e,
1236 0x02, 0x1b, 0xe4, 0x91, 0x66, 0x3c, 0x1c, 0x1b, 0xdb, 0x9f, 0x59, 0x03,
1237 0x31, 0xa9, 0xbf, 0x73, 0xa4, 0x57, 0xd8, 0xea, 0xb9, 0x62, 0xca, 0x94,
1238 0x2f, 0x76, 0xeb, 0xb7, 0xa1, 0xeb, 0x1e, 0xfb, 0x3b, 0xae, 0xf9, 0x3a,
1239 0xdf, 0x04, 0x9a, 0xaf, 0x74, 0x69, 0x99, 0x93, 0xf5, 0xf1, 0x86, 0xcd,
1240 0x99, 0x69, 0xe2, 0x18, 0xe3, 0x36, 0x2d, 0xae, 0xd3, 0x12, 0x4d, 0xd6,
1241 0xde, 0x28, 0x59, 0x5b, 0x03, 0xb8, 0x19, 0x6a, 0x06, 0xc4, 0x94, 0xcf,
1242 0x12, 0xe2, 0x93, 0x32, 0x00, 0xf4, 0x0b, 0x9b, 0xe2, 0xdc, 0x15, 0xe5,
1243 0xdf, 0xac, 0xb6, 0xb1, 0xce, 0x56, 0x48, 0xc7, 0xa4, 0xed, 0x20, 0xb8,
1244 0x3f, 0x55, 0x87, 0xf6, 0xc9, 0xf3, 0xb0, 0x40, 0x8e, 0x02, 0x26, 0x60,
1245 0xa2, 0xc6, 0x3f, 0xab, 0x69, 0xa0, 0xd6, 0x27, 0x0d, 0x57, 0xf3, 0x97,
1246 0xe8, 0xf1, 0x9e, 0x05, 0x8f, 0xc1, 0xbe, 0x81, 0xfd, 0xd6, 0x01, 0xdb,
1247 0x98, 0x7d, 0x1c, 0xe6, 0xb7, 0xa7, 0xc0, 0x53, 0xd9, 0x39, 0x9e, 0x12,
1248 0x99, 0x28, 0x12, 0x37, 0xa1, 0x5d, 0xc7, 0x79, 0x26, 0x7e, 0x32, 0x18,
1249 0x33, 0xdf, 0x7d, 0x16, 0x4f, 0x3b, 0x2d, 0x9e, 0x6e, 0xb2, 0xef, 0x11,
1250 0xbc, 0x69, 0xe3, 0x0d, 0xe0, 0xcd, 0xf9, 0x19, 0xc4, 0x9b, 0xbc, 0x75,
1251 0x0b, 0xde, 0x28, 0x5b, 0xca, 0xc8, 0x6e, 0x6d, 0x87, 0x45, 0xe4, 0x57,
1252 0xb4, 0x6c, 0xfb, 0x02, 0xe6, 0xb2, 0x48, 0xfa, 0x95, 0x7c, 0x2c, 0x02,
1253 0x9c, 0x14, 0xf0, 0xfb, 0x4e, 0xd7, 0xd0, 0x2a, 0x71, 0xb2, 0xc0, 0x57,
1254 0xaa, 0x82, 0x29, 0x66, 0xe5, 0x5c, 0x42, 0xdb, 0xfa, 0xb9, 0xe2, 0x07,
1255 0x34, 0x5c, 0xb7, 0x42, 0xde, 0xe5, 0x45, 0x35, 0x43, 0x37, 0x80, 0x16,
1256 0x54, 0x0c, 0x9a, 0x2b, 0x78, 0x06, 0x7a, 0x29, 0x37, 0x49, 0xdb, 0xb8,
1257 0x8d, 0x7e, 0x49, 0x34, 0xd7, 0xd5, 0x48, 0x3a, 0x52, 0x0a, 0xf6, 0x17,
1258 0xbe, 0x55, 0xae, 0x4b, 0xd3, 0xa9, 0xa3, 0xfc, 0x98, 0xb6, 0x7f, 0x5d,
1259 0x1f, 0xd2, 0xd6, 0xf8, 0xbd, 0xae, 0xf2, 0xd7, 0x2e, 0x4e, 0x4b, 0x50,
1260 0x0f, 0xa3, 0x5e, 0x22, 0xd7, 0xd5, 0x4c, 0x1e, 0xf3, 0x40, 0xbf, 0x19,
1261 0xe5, 0x6b, 0xdf, 0x27, 0xaf, 0xba, 0x57, 0x2f, 0x2a, 0xaf, 0xdf, 0x8e,
1262 0xfd, 0x76, 0xed, 0xdb, 0xb3, 0xef, 0x84, 0x7d, 0xe7, 0xdd, 0x6e, 0xbe,
1263 0x1d, 0x71, 0xd3, 0x7c, 0x83, 0x92, 0xd3, 0x6c, 0x43, 0xf3, 0x95, 0x95,
1264 0x33, 0x1d, 0x5e, 0x41, 0xc8, 0x57, 0x9f, 0x93, 0x5b, 0x27, 0x8d, 0xfc,
1265 0xdd, 0x0e, 0x19, 0x04, 0xff, 0xcc, 0x9b, 0x11, 0xc0, 0x3f, 0x98, 0x96,
1266 0x5b, 0x2b, 0xc4, 0xdb, 0xef, 0x02, 0x7f, 0x60, 0xe2, 0x7a, 0xea, 0x74,
1267 0xca, 0xdd, 0x3b, 0x61, 0xf7, 0xa2, 0x7c, 0x91, 0x38, 0x1f, 0xd2, 0x73,
1268 0x53, 0x28, 0xee, 0xd1, 0x73, 0x73, 0xb0, 0x38, 0x03, 0xfc, 0xdc, 0x06,
1269 0xba, 0x0f, 0x82, 0x99, 0x54, 0x01, 0x94, 0xf3, 0x11, 0xfc, 0x86, 0x1d,
1270 0x50, 0xfc, 0x18, 0xf2, 0x1b, 0xa5, 0x30, 0x4a, 0x9e, 0x73, 0x2d, 0x0f,
1271 0xbf, 0x13, 0xfc, 0x14, 0x45, 0xbb, 0x48, 0xeb, 0xe6, 0xef, 0x9f, 0x20,
1272 0x0f, 0xef, 0x49, 0x4c, 0x62, 0x33, 0x6d, 0x1d, 0xf6, 0xcd, 0xb9, 0xe3,
1273 0x9c, 0xc5, 0xb4, 0x2c, 0x3f, 0x3b, 0x37, 0x6f, 0x97, 0xe7, 0xe8, 0x36,
1274 0x4f, 0x1f, 0x8f, 0xf9, 0x1a, 0x56, 0xd2, 0xfd, 0xb7, 0xb4, 0x5c, 0x72,
1275 0x8f, 0xce, 0xac, 0x30, 0xef, 0xc5, 0x75, 0x39, 0xe7, 0xd5, 0x34, 0x48,
1276 0xbf, 0x25, 0xd9, 0x93, 0x07, 0x3f, 0x61, 0x9c, 0xd2, 0xa7, 0x7d, 0x1d,
1277 0xd2, 0x04, 0x69, 0x60, 0xdc, 0xd2, 0xe6, 0x94, 0xa5, 0xcd, 0x27, 0xf1,
1278 0xc6, 0x53, 0xba, 0x60, 0x69, 0xf3, 0x29, 0xbc, 0xf1, 0x94, 0x5e, 0x9c,
1279 0xe3, 0xe3, 0x5e, 0xf8, 0x72, 0xdb, 0xa1, 0xdf, 0x76, 0x57, 0x40, 0xbf,
1280 0xe0, 0xbb, 0x1c, 0x7c, 0x80, 0x5c, 0x69, 0x1f, 0xde, 0xec, 0x67, 0xa3,
1281 0x6d, 0x3f, 0x23, 0x7b, 0x4a, 0x01, 0xc6, 0x78, 0x37, 0xc6, 0xfb, 0x39,
1282 0xbc, 0x3f, 0xa3, 0xe5, 0x8c, 0xf2, 0x0f, 0x5b, 0x79, 0xf5, 0x79, 0xbc,
1283 0xdb, 0xe3, 0x07, 0xa5, 0xdd, 0x8b, 0xc8, 0x34, 0xda, 0xfa, 0xba, 0xec,
1284 0xa9, 0xcc, 0xe2, 0xb9, 0x84, 0xe7, 0x55, 0x3c, 0x97, 0xd1, 0xde, 0x0b,
1285 0x48, 0x5f, 0x29, 0xd3, 0x5e, 0x3d, 0xca, 0xbf, 0x86, 0xdf, 0xcf, 0xcb,
1286 0xd0, 0x23, 0x2f, 0xe1, 0xf9, 0x01, 0xf2, 0x9f, 0x45, 0xfd, 0x60, 0xf5,
1287 0x8c, 0x4f, 0x19, 0xf6, 0x9c, 0x6d, 0x3b, 0xe5, 0xe4, 0x2a, 0xa0, 0xe9,
1288 0xd2, 0x00, 0xfa, 0xde, 0xa3, 0x79, 0xa6, 0x0f, 0x32, 0x3f, 0x07, 0x19,
1289 0x37, 0xa4, 0x61, 0x6a, 0x07, 0x7c, 0x79, 0xcc, 0x05, 0xde, 0x93, 0xb5,
1290 0x32, 0x1b, 0xa3, 0x1d, 0x79, 0x93, 0x2e, 0x9f, 0x2b, 0x35, 0x69, 0xbb,
1291 0x7a, 0x7c, 0x09, 0xff, 0xd0, 0xef, 0x0a, 0xe5, 0x81, 0x91, 0xc6, 0x13,
1292 0x45, 0xca, 0x02, 0xe8, 0x9f, 0xe2, 0x08, 0xde, 0xb5, 0x5a, 0x26, 0x14,
1293 0x24, 0x94, 0x07, 0xac, 0x47, 0x99, 0x50, 0x2d, 0x77, 0x28, 0x6b, 0x28,
1294 0x7b, 0x28, 0x4b, 0xcc, 0x7c, 0xec, 0x7e, 0x90, 0x32, 0x1c, 0xb4, 0x10,
1295 0xa3, 0xfd, 0xe1, 0x19, 0x1f, 0x64, 0xec, 0x3e, 0x2b, 0x4f, 0x47, 0xf5,
1296 0x5c, 0xec, 0x29, 0xaa, 0x98, 0x2b, 0xa7, 0x91, 0x86, 0xe7, 0xf8, 0xc3,
1297 0x78, 0x7f, 0x49, 0xf6, 0xe0, 0xc9, 0x1d, 0xff, 0x02, 0x7e, 0x73, 0x6e,
1298 0xca, 0x28, 0x87, 0xa7, 0x74, 0x02, 0x6f, 0x3c, 0xa5, 0x31, 0x2b, 0x47,
1299 0xc6, 0xad, 0x1c, 0xe1, 0x9c, 0xde, 0x04, 0x3c, 0x70, 0x7c, 0x4a, 0xc7,
1300 0x17, 0xc0, 0xcf, 0x4e, 0x6e, 0xf2, 0x5d, 0xd6, 0x8f, 0x6d, 0x14, 0xc3,
1301 0x83, 0x78, 0x3a, 0xc9, 0xcf, 0x0d, 0xda, 0x0e, 0xce, 0x69, 0xda, 0xfd,
1302 0x2b, 0xd7, 0xf0, 0x62, 0xcc, 0xe8, 0x14, 0xaf, 0x59, 0x34, 0xef, 0xcf,
1303 0xe1, 0x31, 0x63, 0xf1, 0xc8, 0xdf, 0xca, 0xfe, 0x86, 0xdc, 0x82, 0x4d,
1304 0x9b, 0xf5, 0x7d, 0xcc, 0x03, 0xc6, 0x72, 0x7c, 0x14, 0x7d, 0x3b, 0xb2,
1305 0xdb, 0xa7, 0x0c, 0x67, 0x0c, 0x81, 0xe3, 0x63, 0xbb, 0x48, 0xd7, 0x38,
1306 0x48, 0xc9, 0xbc, 0x6f, 0x7e, 0x13, 0xe6, 0x2c, 0x23, 0x7b, 0x4b, 0xf7,
1307 0x6a, 0x5f, 0xb9, 0xf6, 0x68, 0x93, 0xf5, 0x73, 0xc2, 0x72, 0xa0, 0xd5,
1308 0x18, 0x6d, 0x9b, 0x2f, 0xc5, 0x0c, 0xcd, 0xf3, 0x37, 0xe5, 0x73, 0xb5,
1309 0xbc, 0x37, 0x76, 0x4d, 0x61, 0x81, 0xac, 0xa3, 0x6d, 0x81, 0x39, 0x2b,
1310 0x57, 0xe3, 0x9d, 0xbe, 0x3b, 0xf9, 0x8a, 0xfc, 0x74, 0x10, 0x3c, 0xf1,
1311 0x5d, 0xcb, 0xfb, 0xf4, 0x35, 0xd8, 0xe7, 0x62, 0x7e, 0xf2, 0x60, 0xfb,
1312 0xba, 0x72, 0x0a, 0xb6, 0xdb, 0xf6, 0xb9, 0x36, 0xae, 0x06, 0x3c, 0x51,
1313 0x79, 0xa4, 0xd8, 0x20, 0x93, 0x45, 0xd5, 0x1c, 0xb1, 0xb2, 0x33, 0x22,
1314 0x09, 0x4d, 0xdf, 0xb4, 0xef, 0x7a, 0xc7, 0x22, 0x96, 0xee, 0xd6, 0xd5,
1315 0x48, 0xfd, 0xef, 0x42, 0xc7, 0xa6, 0xa1, 0x63, 0x1b, 0xa1, 0x83, 0x17,
1316 0xcb, 0x88, 0x35, 0x35, 0x4b, 0x65, 0x04, 0xeb, 0x24, 0xe1, 0x75, 0x1f,
1317 0x44, 0xbd, 0x90, 0xfe, 0xa2, 0x9a, 0xd6, 0x72, 0x92, 0x77, 0xb6, 0x57,
1318 0x46, 0x9c, 0x1d, 0x95, 0xc5, 0x3a, 0x68, 0x8b, 0xe7, 0x8a, 0x81, 0xf5,
1319 0x91, 0x22, 0x6d, 0xd4, 0x64, 0x2a, 0x0b, 0x9c, 0xec, 0x00, 0xcc, 0xcf,
1320 0x8c, 0xc2, 0x4f, 0xa7, 0x5c, 0x06, 0xcc, 0xa7, 0x01, 0xf3, 0xc4, 0xa8,
1321 0x13, 0xda, 0x06, 0xc2, 0xa0, 0xc8, 0xc4, 0x58, 0x97, 0xcc, 0x4c, 0x91,
1322 0x0e, 0x21, 0x03, 0x46, 0x31, 0x9f, 0xa9, 0x15, 0xb0, 0x03, 0xd8, 0x3f,
1323 0xe4, 0xf6, 0x58, 0x8b, 0xce, 0x33, 0xfa, 0xbc, 0x55, 0x66, 0xca, 0x69,
1324 0x0b, 0xdb, 0xe1, 0x2a, 0xd8, 0x56, 0xcc, 0xc1, 0xb6, 0x03, 0xb0, 0xed,
1325 0x5c, 0x16, 0xb6, 0xe5, 0x74, 0x71, 0x1b, 0x6c, 0x1a, 0xa3, 0x8b, 0x0d,
1326 0x5e, 0x9b, 0x2d, 0x3d, 0xbc, 0xdf, 0xda, 0xbb, 0xb4, 0x89, 0x7e, 0x0a,
1327 0x78, 0x48, 0x63, 0xf8, 0x3d, 0x79, 0x2f, 0x65, 0x19, 0xd2, 0xf9, 0xbd,
1328 0x07, 0x65, 0xf0, 0x3d, 0xf9, 0x67, 0x2b, 0x4c, 0xd9, 0xbb, 0x2d, 0x2c,
1329 0xb4, 0x13, 0x32, 0xb0, 0x89, 0xfb, 0x9c, 0xec, 0x24, 0x61, 0xf8, 0x8f,
1330 0x80, 0x17, 0x79, 0x95, 0xea, 0x36, 0xf9, 0x66, 0xbb, 0xd7, 0xda, 0x76,
1331 0xd8, 0x76, 0x38, 0x96, 0x95, 0x56, 0xcf, 0x87, 0xf4, 0x15, 0xda, 0xd7,
1332 0x23, 0x4e, 0x66, 0xc9, 0xb8, 0xaa, 0x69, 0x8e, 0xf2, 0xd6, 0x95, 0x7e,
1333 0xd0, 0x49, 0xff, 0x02, 0x5a, 0x33, 0x72, 0xc3, 0xd0, 0xf1, 0x0a, 0x3b,
1334 0xbe, 0x1a, 0xc3, 0x37, 0xa9, 0x28, 0xf4, 0x21, 0xe5, 0xcd, 0x0e, 0xe3,
1335 0x9b, 0xcb, 0x43, 0x80, 0x35, 0xfc, 0x3e, 0xa8, 0x6d, 0xce, 0xa7, 0x4b,
1336 0x94, 0x49, 0xf3, 0xb4, 0x68, 0x7c, 0x97, 0x56, 0xf4, 0x55, 0x6d, 0xaf,
1337 0xbb, 0x32, 0x60, 0xe6, 0xfc, 0x30, 0xe7, 0x9c, 0xbe, 0x48, 0xfb, 0x03,
1338 0x03, 0x96, 0xbf, 0x92, 0xa3, 0x79, 0x79, 0xbb, 0x1d, 0xfb, 0x1f, 0x2e,
1339 0x33, 0x77, 0x8d, 0x73, 0x73, 0x37, 0x50, 0x59, 0x3c, 0x46, 0x91, 0xb6,
1340 0x07, 0x58, 0xcf, 0x85, 0x8d, 0x94, 0x92, 0x5a, 0x9f, 0xf2, 0x93, 0xb6,
1341 0x12, 0xd2, 0x27, 0xb6, 0x78, 0x4d, 0xf0, 0x01, 0x9e, 0x5e, 0x62, 0x77,
1342 0x25, 0xac, 0xdc, 0xa4, 0x1f, 0x1c, 0xf6, 0x91, 0xb7, 0x72, 0x32, 0x8f,
1343 0xf6, 0x47, 0x9c, 0xfe, 0xca, 0x72, 0xf2, 0x32, 0x94, 0x93, 0x1c, 0x8f,
1344 0x23, 0x77, 0x3c, 0x48, 0x1e, 0x7d, 0xbf, 0xb6, 0xaf, 0xb7, 0x6e, 0xab,
1345 0x01, 0xfe, 0x08, 0xc7, 0xcc, 0x1a, 0xa2, 0x33, 0xf7, 0x08, 0x6c, 0x22,
1346 0x3b, 0x6f, 0xbb, 0xe7, 0xe6, 0x5f, 0xd3, 0x05, 0x7e, 0x33, 0x8e, 0x6a,
1347 0x68, 0xa4, 0xc6, 0x77, 0x34, 0x2d, 0xd4, 0x2e, 0xb1, 0x65, 0x39, 0x06,
1348 0xda, 0xb3, 0xb5, 0xc6, 0x16, 0x2c, 0xd1, 0xfe, 0xa4, 0xec, 0xa2, 0xfd,
1349 0xf9, 0x43, 0xe0, 0x88, 0xe3, 0xe9, 0xb2, 0x69, 0xb4, 0x53, 0x17, 0x8f,
1350 0x6f, 0xb1, 0xff, 0x48, 0x38, 0x09, 0xb7, 0xa1, 0xad, 0x84, 0x22, 0x6c,
1351 0x81, 0x0c, 0x80, 0x97, 0x39, 0x07, 0x8a, 0xb6, 0xeb, 0xb6, 0xbf, 0xa8,
1352 0x31, 0x31, 0xe4, 0xd5, 0xb5, 0x52, 0xcf, 0x3e, 0xc9, 0x7f, 0x7c, 0xaf,
1353 0xd2, 0xf6, 0xef, 0x52, 0x59, 0x56, 0xad, 0x7b, 0xae, 0x9e, 0xc3, 0x5f,
1354 0xff, 0x82, 0x39, 0x0a, 0xf1, 0x17, 0xd2, 0x45, 0x35, 0x0e, 0x49, 0x13,
1355 0x86, 0x16, 0x0c, 0x2d, 0x6e, 0xb4, 0xfa, 0x26, 0xa4, 0xbd, 0xab, 0x40,
1356 0x7b, 0xf7, 0x81, 0xc6, 0x28, 0xc3, 0x19, 0x97, 0x5b, 0x8b, 0xef, 0x23,
1357 0xf8, 0x0e, 0xf9, 0xe4, 0x4a, 0x32, 0x9c, 0xf2, 0x9b, 0x75, 0xb2, 0x56,
1358 0xee, 0x87, 0x7e, 0x2e, 0xeb, 0x70, 0xdc, 0x94, 0xff, 0xff, 0x15, 0xed,
1359 0xac, 0xad, 0x35, 0xf6, 0xca, 0x8d, 0xb5, 0x94, 0xaf, 0x6b, 0xe4, 0x60,
1360 0x55, 0xda, 0x95, 0xe4, 0x77, 0xf5, 0x98, 0xd7, 0xff, 0x3f, 0x18, 0x73,
1361 0x7c, 0xd1, 0x98, 0x3d, 0x3b, 0xe6, 0x77, 0x21, 0xbf, 0xc9, 0xf8, 0x38,
1362 0x1e, 0xf9, 0x2e, 0x1c, 0xb3, 0xc5, 0x85, 0x1e, 0x57, 0xb5, 0x9c, 0x08,
1363 0x65, 0x04, 0xc7, 0x35, 0x60, 0xc7, 0xf0, 0xb9, 0xaa, 0x71, 0x0d, 0xbc,
1364 0x89, 0x71, 0xb5, 0x2e, 0x18, 0xd7, 0xf6, 0x2b, 0x8e, 0x6b, 0x39, 0x1e,
1365 0x27, 0x2f, 0x87, 0xe3, 0x8b, 0xca, 0xae, 0x22, 0xc7, 0xd8, 0x8f, 0x31,
1366 0x1e, 0xd4, 0xfe, 0x80, 0x19, 0x63, 0xda, 0x8e, 0x51, 0x54, 0xdb, 0xb6,
1367 0x7f, 0x8f, 0xdf, 0xd5, 0xe3, 0xa3, 0xee, 0xff, 0x3e, 0x68, 0xba, 0x4e,
1368 0xb2, 0x5d, 0x75, 0x56, 0xfe, 0xdf, 0x24, 0x1f, 0x2e, 0x71, 0xae, 0x93,
1369 0x19, 0x91, 0x51, 0xe8, 0xe0, 0xff, 0x5c, 0xcb, 0xd8, 0xfd, 0xf6, 0x94,
1370 0xd5, 0x63, 0xd0, 0x17, 0x3b, 0x60, 0xf3, 0xf5, 0x17, 0x55, 0x77, 0x44,
1371 0x82, 0xe0, 0xb6, 0xd4, 0xa7, 0xd1, 0xf7, 0x7e, 0xed, 0xab, 0x2e, 0x8d,
1372 0x9b, 0x3f, 0x57, 0x2b, 0x3e, 0xed, 0x0d, 0xea, 0x73, 0xe8, 0xbb, 0xe3,
1373 0xb4, 0xc1, 0xb2, 0xb0, 0x93, 0x33, 0xf1, 0x88, 0xb6, 0xc5, 0xa8, 0x13,
1374 0x93, 0xf1, 0x8c, 0xa4, 0xd1, 0x5f, 0x26, 0xae, 0x84, 0x7d, 0xc0, 0x56,
1375 0x83, 0x0d, 0xf9, 0xe1, 0xca, 0x3e, 0x3c, 0x0f, 0xcb, 0xad, 0xb0, 0x77,
1376 0x6e, 0x7d, 0xe4, 0x0b, 0x72, 0x1b, 0x6c, 0x9d, 0xdb, 0x1e, 0x19, 0x93,
1377 0xbd, 0xb0, 0x6d, 0xf6, 0xc2, 0xce, 0xd9, 0x5b, 0xa1, 0xed, 0x39, 0x8e,
1378 0xb2, 0xad, 0x55, 0xb4, 0x46, 0x1b, 0x87, 0xe3, 0x23, 0xee, 0x0f, 0x72,
1379 0x0e, 0x52, 0x09, 0xf5, 0x8a, 0x9e, 0x97, 0xa6, 0x05, 0x69, 0xaf, 0x27,
1380 0xab, 0x42, 0xfd, 0xb4, 0xca, 0xc6, 0x8d, 0x8c, 0x0d, 0x78, 0x65, 0xda,
1381 0x22, 0x8d, 0x78, 0xc0, 0x33, 0xf1, 0x47, 0xda, 0xaa, 0x1e, 0x7f, 0x63,
1382 0x9d, 0xf8, 0x2b, 0xeb, 0xa4, 0xfe, 0x73, 0x90, 0xaf, 0xd5, 0x34, 0xc5,
1383 0xb7, 0x67, 0x75, 0x0d, 0x69, 0x8b, 0x32, 0x38, 0xa4, 0x87, 0x8d, 0xaf,
1384 0x23, 0x7f, 0xaf, 0x48, 0x4f, 0xfb, 0xb9, 0x2e, 0xb3, 0xbb, 0x5b, 0x56,
1385 0x33, 0x1e, 0x90, 0xad, 0xcc, 0xc7, 0x04, 0x94, 0x5f, 0x1d, 0x13, 0xa0,
1386 0x9f, 0xf5, 0x01, 0xe0, 0xec, 0x16, 0x3c, 0xfb, 0x64, 0x88, 0x71, 0x87,
1387 0x4a, 0x68, 0x97, 0x7f, 0xd5, 0xda, 0xe5, 0x21, 0x1c, 0x09, 0xc0, 0x61,
1388 0xe4, 0xf3, 0x52, 0x3d, 0xb7, 0x50, 0x7f, 0xe7, 0xe7, 0x6c, 0xda, 0x84,
1389 0xec, 0x2a, 0x71, 0xdc, 0x94, 0xc1, 0xc4, 0x4d, 0xb5, 0x0c, 0x8e, 0x5b,
1390 0x3b, 0x0a, 0x65, 0xb4, 0xfc, 0x5c, 0x2a, 0x3b, 0x29, 0xf7, 0x18, 0x9f,
1391 0x7f, 0x20, 0x45, 0x5a, 0x7f, 0xb7, 0x64, 0xe6, 0xe2, 0xf3, 0x02, 0x7a,
1392 0x93, 0x54, 0x24, 0xad, 0xd7, 0xd3, 0xbc, 0x09, 0xd9, 0x21, 0xbd, 0x31,
1393 0xc6, 0x3a, 0x19, 0xcf, 0xf3, 0xf3, 0x13, 0xb0, 0x1f, 0x86, 0x4b, 0x0a,
1394 0x16, 0x7c, 0xad, 0x0c, 0x79, 0x81, 0x6c, 0x4f, 0x39, 0x3a, 0x76, 0x6c,
1395 0x74, 0x6d, 0xa9, 0xce, 0xd8, 0xae, 0x8e, 0x8e, 0xff, 0xce, 0x80, 0xfa,
1396 0x66, 0xb4, 0x7d, 0xab, 0xb4, 0xfe, 0x9d, 0xd6, 0x65, 0x46, 0xeb, 0xc2,
1397 0x38, 0xe6, 0x8c, 0x17, 0xb1, 0xe5, 0xaa, 0xd3, 0xa7, 0xea, 0x42, 0x5b,
1398 0xb0, 0x50, 0x09, 0xd3, 0x9e, 0x5c, 0x26, 0xed, 0x85, 0x65, 0xd2, 0xfe,
1399 0x76, 0x99, 0x34, 0x13, 0x17, 0xec, 0x2f, 0x5e, 0x46, 0xde, 0x88, 0xe6,
1400 0x55, 0x69, 0x36, 0xf6, 0x75, 0x7e, 0xae, 0xcc, 0x2a, 0xeb, 0x97, 0x31,
1401 0x46, 0x6c, 0x62, 0xc3, 0x39, 0x1d, 0x1b, 0xde, 0xe2, 0x6d, 0x53, 0x8c,
1402 0x75, 0x11, 0x17, 0x09, 0xd9, 0xab, 0xf1, 0x42, 0x9c, 0x7c, 0x85, 0x31,
1403 0xe0, 0x3c, 0xd7, 0x5a, 0x13, 0xea, 0x4a, 0xb4, 0x3d, 0x6f, 0x9b, 0x98,
1404 0x79, 0x8b, 0xe9, 0x75, 0xd5, 0x3e, 0xd8, 0x0a, 0xfd, 0xc5, 0x26, 0xd9,
1405 0x3e, 0x96, 0x58, 0x41, 0xbd, 0xb5, 0x63, 0xcc, 0xf8, 0x83, 0x7b, 0xc1,
1406 0x57, 0x19, 0x21, 0x8c, 0xc9, 0x94, 0x08, 0x6d, 0xe2, 0xa5, 0xb6, 0xf0,
1407 0xeb, 0xb7, 0xd7, 0x7b, 0x85, 0xf6, 0x1c, 0xd8, 0x0e, 0x3f, 0x6b, 0x7b,
1408 0xf5, 0xd2, 0x37, 0x16, 0xe2, 0x4a, 0xfd, 0x9c, 0xf5, 0x22, 0x57, 0xa8,
1409 0xa7, 0xed, 0x12, 0x79, 0x66, 0x4e, 0x16, 0x6f, 0x84, 0xcd, 0x24, 0x41,
1410 0xb6, 0x5b, 0x5a, 0x23, 0xa2, 0x63, 0x3c, 0x29, 0x23, 0x9b, 0x3b, 0xb8,
1411 0xb6, 0x03, 0xfa, 0x37, 0xb6, 0x8a, 0x89, 0x9b, 0x86, 0x76, 0xca, 0x72,
1412 0xb4, 0x7b, 0xbd, 0xa5, 0x5d, 0xae, 0xa9, 0xee, 0xa0, 0xcc, 0xc5, 0x9c,
1413 0x18, 0x3a, 0xde, 0x5e, 0x94, 0x44, 0x48, 0xc7, 0x33, 0xf0, 0x8b, 0xab,
1414 0xe9, 0x78, 0x46, 0x52, 0x9a, 0x8e, 0x6b, 0x17, 0xd0, 0x71, 0xab, 0xa5,
1415 0xe3, 0x77, 0x44, 0x0d, 0x5d, 0x28, 0xad, 0xa7, 0x48, 0xa7, 0x86, 0x8e,
1416 0x1d, 0x4d, 0xc7, 0x33, 0x78, 0xbb, 0x7e, 0x8f, 0x2d, 0x13, 0xb1, 0x69,
1417 0xfc, 0x1d, 0xa6, 0x51, 0x2e, 0xfe, 0x66, 0xd4, 0xe8, 0xa5, 0x14, 0xe8,
1418 0x28, 0x4c, 0xff, 0x60, 0xd4, 0xd0, 0x67, 0x75, 0x9a, 0x89, 0x8f, 0xf4,
1419 0x17, 0xdf, 0x13, 0x5d, 0x48, 0x9f, 0x29, 0xd0, 0x67, 0x58, 0xe6, 0xf5,
1420 0xe8, 0xb3, 0xde, 0xae, 0x5b, 0x44, 0xf5, 0xba, 0x7b, 0x26, 0x66, 0x68,
1421 0xf5, 0x56, 0x3d, 0x76, 0x8e, 0xfb, 0xd9, 0x9f, 0x81, 0x56, 0xcd, 0xdc,
1422 0x9c, 0x9f, 0xf7, 0xb7, 0x19, 0x8b, 0x4a, 0x98, 0x18, 0x36, 0xe3, 0xa4,
1423 0x57, 0xb2, 0x1d, 0x8d, 0x7c, 0xaa, 0xd1, 0xf2, 0xa9, 0x71, 0x48, 0xa5,
1424 0xab, 0x65, 0x76, 0x37, 0x74, 0x05, 0x6d, 0x6c, 0x2d, 0xa7, 0x91, 0xd7,
1425 0x9a, 0xc8, 0x16, 0xff, 0xd9, 0xee, 0x5f, 0xe0, 0xba, 0x80, 0x0c, 0x39,
1426 0x48, 0x6b, 0x2b, 0x9b, 0x71, 0x29, 0xbf, 0x11, 0xdf, 0xdd, 0xd2, 0x56,
1427 0x56, 0x72, 0xfb, 0x58, 0x83, 0xec, 0x2b, 0xba, 0xf2, 0x51, 0xd4, 0xff,
1428 0x48, 0xd1, 0x83, 0x3f, 0x3e, 0x1e, 0xa5, 0x5d, 0xb8, 0xb7, 0xc8, 0xf5,
1429 0x49, 0xc7, 0xac, 0x19, 0x2d, 0x58, 0xf3, 0x8c, 0x48, 0x5b, 0x47, 0x01,
1430 0x9e, 0x8a, 0xb8, 0x3b, 0x01, 0x47, 0x5d, 0x3a, 0x2d, 0xaf, 0x74, 0x0f,
1431 0x38, 0xda, 0x97, 0x70, 0x7a, 0xe4, 0xc6, 0x4a, 0x5a, 0x6e, 0xa8, 0x98,
1432 0x75, 0xd2, 0xf9, 0x75, 0xd0, 0xa4, 0x37, 0x0d, 0x9d, 0x93, 0xf1, 0x82,
1433 0xe0, 0x3c, 0xe4, 0xb7, 0x3a, 0xe2, 0x4a, 0xb4, 0x23, 0x19, 0x9f, 0x16,
1434 0xf3, 0x7d, 0xb1, 0xfc, 0xe3, 0x60, 0x28, 0xe6, 0xca, 0x2b, 0x3e, 0xc7,
1435 0xd5, 0x23, 0xd7, 0x97, 0xab, 0xfb, 0xe3, 0x5a, 0xe9, 0x13, 0x51, 0xae,
1436 0x4d, 0x64, 0x2b, 0xe5, 0x28, 0xe3, 0xe7, 0x22, 0x79, 0x69, 0x7b, 0x2b,
1437 0x7c, 0x37, 0x48, 0xeb, 0xb6, 0xb7, 0x82, 0x56, 0x62, 0xd0, 0xf3, 0x5b,
1438 0x01, 0xd7, 0x56, 0xc6, 0xbb, 0x18, 0xe7, 0xe2, 0xf7, 0x5f, 0xa2, 0x5f,
1439 0xd6, 0xfd, 0x5d, 0xbd, 0x66, 0x25, 0x8a, 0x73, 0x6e, 0xf8, 0x65, 0x79,
1440 0x5d, 0xd3, 0x38, 0x14, 0x4d, 0x8b, 0x13, 0x7d, 0x5b, 0x5c, 0x56, 0xf8,
1441 0xd5, 0xfd, 0x73, 0xed, 0x57, 0x14, 0x70, 0xe8, 0xee, 0xd8, 0xdc, 0x23,
1442 0x7d, 0x18, 0x5f, 0xff, 0x92, 0xf1, 0xed, 0x17, 0xc6, 0x54, 0x2f, 0x16,
1443 0x39, 0x86, 0xf9, 0x71, 0xa9, 0x3f, 0x32, 0xe3, 0x8a, 0x76, 0x2c, 0x1e,
1444 0x8f, 0xae, 0xaf, 0x4e, 0x01, 0x96, 0xe7, 0xf4, 0x1e, 0x81, 0x20, 0xb8,
1445 0xa6, 0xe3, 0x62, 0x90, 0x58, 0x97, 0xec, 0x9c, 0x9e, 0x5f, 0xd3, 0x19,
1446 0x8a, 0xa4, 0x33, 0x1a, 0xff, 0xf8, 0x4e, 0xe4, 0xca, 0xdd, 0x98, 0x3b,
1447 0x71, 0x73, 0x5d, 0xae, 0xe6, 0x8d, 0x9c, 0xdf, 0x6d, 0xd7, 0xad, 0x42,
1448 0xbf, 0x29, 0x08, 0x94, 0xbf, 0x58, 0x56, 0x50, 0x47, 0x61, 0xec, 0xb2,
1449 0xdb, 0xee, 0x4b, 0x49, 0x31, 0x6e, 0x38, 0xe4, 0xa6, 0xa3, 0x89, 0x42,
1450 0xb9, 0x0b, 0xbf, 0x1b, 0xf0, 0xfe, 0x45, 0xd8, 0x28, 0x3d, 0xb0, 0x61,
1451 0x24, 0xa6, 0x8c, 0x3c, 0x00, 0xfd, 0x76, 0xe4, 0x95, 0x22, 0x3f, 0x7a,
1452 0x89, 0xe1, 0x72, 0x2c, 0x31, 0x5a, 0xde, 0xcb, 0xfa, 0x28, 0x7b, 0xa5,
1453 0xf8, 0x1d, 0xfb, 0x62, 0x1f, 0xf4, 0x79, 0x7f, 0x96, 0x3e, 0x5c, 0xdb,
1454 0x36, 0xdb, 0x0c, 0xf1, 0xe2, 0xd2, 0x0d, 0xc7, 0xbf, 0x6e, 0xeb, 0x8f,
1455 0x70, 0x7c, 0x7b, 0x2d, 0xdc, 0x8b, 0xfb, 0x7d, 0x49, 0xdb, 0x2c, 0x8f,
1456 0x55, 0x68, 0x27, 0x72, 0x4d, 0x27, 0x79, 0x62, 0x5c, 0x08, 0x47, 0x10,
1457 0x5c, 0x48, 0x19, 0x7d, 0xfd, 0x74, 0x85, 0xeb, 0x1a, 0x41, 0xf0, 0x5d,
1458 0xda, 0xc2, 0x83, 0x25, 0xf4, 0x17, 0xe2, 0x60, 0x63, 0xde, 0x85, 0x2c,
1459 0x1c, 0xe9, 0x26, 0x7e, 0x05, 0x5e, 0x69, 0x87, 0xb7, 0x4b, 0xa2, 0x89,
1460 0xdf, 0x2e, 0x37, 0x24, 0x3e, 0x51, 0xf6, 0x80, 0x67, 0x8e, 0x3b, 0x96,
1461 0xd8, 0x63, 0xc7, 0xcc, 0xfd, 0x20, 0xaf, 0xbf, 0x4f, 0xe3, 0xa5, 0x05,
1462 0x3e, 0x12, 0x61, 0x9a, 0x87, 0x85, 0xb0, 0x25, 0x2c, 0x6e, 0x82, 0xe0,
1463 0xfb, 0x29, 0xf6, 0xd9, 0xcd, 0xfd, 0x00, 0x23, 0xe8, 0x37, 0xbf, 0x56,
1464 0x11, 0x0f, 0xd1, 0xc4, 0x1d, 0xe8, 0xfb, 0xb7, 0xd1, 0xf7, 0xbe, 0x32,
1465 0xfb, 0x83, 0x7c, 0xc0, 0xd8, 0x47, 0x2a, 0x21, 0xbc, 0xcb, 0xf5, 0x1d,
1466 0xce, 0x79, 0xa7, 0xb5, 0xeb, 0xc2, 0x6f, 0x8d, 0x48, 0x4f, 0xc1, 0x97,
1467 0xcb, 0x56, 0x66, 0xd6, 0xb8, 0xf2, 0x2e, 0xc8, 0xda, 0x40, 0x4e, 0x42,
1468 0x86, 0xcd, 0x68, 0xba, 0xc9, 0xae, 0xe7, 0xff, 0x11, 0xf9, 0xe4, 0x0a,
1469 0xc6, 0x94, 0x7b, 0x7d, 0xda, 0xab, 0xb3, 0xc1, 0x8c, 0x4f, 0x99, 0xbc,
1470 0x4a, 0xc6, 0xbd, 0x7c, 0x27, 0xf4, 0x03, 0xd2, 0x1a, 0xe9, 0x63, 0x27,
1471 0xb2, 0x91, 0x64, 0x62, 0x58, 0xb8, 0xc7, 0x89, 0xfb, 0x13, 0xb8, 0xef,
1472 0x87, 0xf2, 0xc0, 0x85, 0x9c, 0xe3, 0x1c, 0x9a, 0xfe, 0x86, 0xcb, 0xf3,
1473 0x65, 0x0f, 0x08, 0xd7, 0x09, 0x93, 0xf1, 0xbd, 0xda, 0x26, 0x01, 0xd5,
1474 0x15, 0x59, 0x76, 0x33, 0x2c, 0x12, 0xbf, 0xaa, 0xbc, 0xde, 0x73, 0x05,
1475 0x3e, 0x67, 0x1c, 0x21, 0x1a, 0xcd, 0x16, 0xe5, 0xb5, 0x48, 0xb7, 0xbc,
1476 0x96, 0x4d, 0xd5, 0x4b, 0xaf, 0x96, 0xf9, 0xcc, 0xd3, 0xe9, 0xb3, 0x26,
1477 0xdd, 0x85, 0x2e, 0xe1, 0x9c, 0xf4, 0x40, 0x46, 0x4f, 0x00, 0x6e, 0xe2,
1478 0xb0, 0x87, 0x32, 0x89, 0xf3, 0xa7, 0x54, 0x3a, 0x16, 0xcd, 0x95, 0xa5,
1479 0x2f, 0x57, 0xb4, 0xb1, 0x9e, 0x01, 0x8e, 0x7f, 0x95, 0xc5, 0x43, 0xa3,
1480 0xb8, 0x80, 0xad, 0x2f, 0x92, 0x70, 0xe0, 0x2b, 0x43, 0xd7, 0x3f, 0xba,
1481 0x4a, 0x1a, 0x89, 0x9b, 0x1e, 0xf0, 0x52, 0x0d, 0x74, 0xd1, 0xfd, 0xcd,
1482 0x5c, 0x37, 0xd5, 0x36, 0x64, 0xec, 0x63, 0xbf, 0xac, 0xd2, 0x7f, 0x1b,
1483 0x57, 0xe9, 0x51, 0x2b, 0x2f, 0xa3, 0x7d, 0x94, 0x97, 0x4f, 0x97, 0x08,
1484 0x8f, 0x78, 0x11, 0x3f, 0xd1, 0xd7, 0x5b, 0x16, 0x15, 0x49, 0x7b, 0xd1,
1485 0xde, 0xf2, 0x42, 0xfa, 0x7f, 0xba, 0xf2, 0x61, 0x6b, 0x0b, 0x56, 0xc7,
1486 0x54, 0xab, 0xf3, 0xc8, 0x83, 0xcb, 0xe5, 0x11, 0x26, 0x89, 0xae, 0x48,
1487 0x5f, 0xf8, 0x54, 0x7b, 0x47, 0xde, 0xab, 0x15, 0xe2, 0x39, 0x80, 0xdc,
1488 0x06, 0xae, 0xcb, 0x5c, 0xaf, 0xde, 0x8f, 0x79, 0xfb, 0x3f, 0x41, 0x26,
1489 0xc6, 0x7c, 0x4f, 0xea, 0xe0, 0xdb, 0xbe, 0x0c, 0xdd, 0xf9, 0x8a, 0x7f,
1490 0xe1, 0x53, 0x9d, 0x1d, 0x41, 0xf0, 0xac, 0x9f, 0x4f, 0xb8, 0x90, 0x1f,
1491 0x87, 0x2d, 0xbe, 0x87, 0x81, 0xef, 0x89, 0x39, 0x7c, 0x27, 0xe4, 0x62,
1492 0xd7, 0xf7, 0x03, 0xae, 0xf5, 0x0d, 0x97, 0x6f, 0xbd, 0x55, 0xa5, 0x3f,
1493 0xfe, 0xa1, 0x6c, 0x37, 0xfb, 0x1b, 0x91, 0xc3, 0x95, 0x9b, 0x88, 0xbf,
1494 0x28, 0xc6, 0x7a, 0x4f, 0x9f, 0x6f, 0xfa, 0xed, 0x5b, 0xd0, 0x2f, 0xe9,
1495 0xe5, 0x47, 0xac, 0x8b, 0x32, 0xd5, 0x75, 0x33, 0xa0, 0xcb, 0xbc, 0xad,
1496 0x3b, 0x70, 0x85, 0xba, 0xde, 0x15, 0xea, 0x1e, 0x46, 0xdd, 0x3d, 0xb6,
1497 0xee, 0x85, 0xcf, 0xbc, 0xb9, 0x7e, 0x07, 0xb8, 0xc7, 0x0e, 0x3e, 0x80,
1498 0xb8, 0x11, 0xff, 0x36, 0xfc, 0xbe, 0x85, 0xed, 0x28, 0xda, 0xf7, 0x23,
1499 0x95, 0x21, 0x19, 0xae, 0xec, 0xc4, 0x33, 0x88, 0xb4, 0x3e, 0x3c, 0xfb,
1500 0xf0, 0x3b, 0x8d, 0x47, 0xa2, 0x6e, 0xfa, 0xc2, 0x5d, 0xc3, 0x7e, 0x88,
1501 0x57, 0xae, 0xcd, 0xb3, 0x0f, 0xd8, 0x17, 0x5d, 0x3f, 0x41, 0x1f, 0x61,
1502 0xfa, 0x07, 0x50, 0x67, 0x1a, 0x69, 0x2b, 0x69, 0x7b, 0x62, 0xae, 0xab,
1503 0xeb, 0x54, 0xc3, 0x36, 0x1d, 0xce, 0x05, 0xf2, 0x0d, 0x8d, 0xf6, 0x16,
1504 0x43, 0x18, 0xef, 0x44, 0x1b, 0xe3, 0x57, 0x29, 0xff, 0x1e, 0xc2, 0x15,
1505 0x57, 0xfe, 0xc7, 0xf0, 0x7e, 0x2d, 0xd8, 0x9d, 0x62, 0x4c, 0x9e, 0xf3,
1506 0x7e, 0xdd, 0xaa, 0xa5, 0x7b, 0x9f, 0x42, 0x1a, 0xe8, 0x84, 0x4e, 0x69,
1507 0xb0, 0x74, 0x5a, 0x80, 0xe5, 0x43, 0x1a, 0xe5, 0x98, 0x17, 0x97, 0x4d,
1508 0x76, 0xe6, 0xa5, 0x07, 0xba, 0x8c, 0xb2, 0xf6, 0xd3, 0xf5, 0x26, 0x0e,
1509 0x03, 0xcb, 0xd1, 0xef, 0x04, 0x3d, 0x37, 0x88, 0x87, 0xfa, 0x03, 0x11,
1510 0x0f, 0x34, 0x18, 0xd6, 0x4f, 0x7a, 0x03, 0x11, 0x8e, 0x19, 0x1c, 0x5f,
1511 0xe6, 0xba, 0x34, 0x6d, 0x6b, 0xd6, 0x0f, 0x6d, 0x1c, 0xfe, 0x7b, 0x59,
1512 0xc4, 0x67, 0x1a, 0xdb, 0x0b, 0xde, 0x55, 0xe3, 0x2f, 0x59, 0x63, 0xc1,
1513 0x38, 0xf3, 0x49, 0x68, 0x30, 0xaf, 0x4f, 0xcb, 0xe9, 0xfc, 0x35, 0x35,
1514 0xd2, 0xe0, 0xf5, 0xeb, 0xdf, 0x2c, 0xd3, 0xe0, 0x81, 0x4f, 0x17, 0x95,
1515 0x61, 0x1a, 0xf3, 0x0a, 0x6b, 0x94, 0xde, 0xab, 0xa4, 0xf7, 0x28, 0xc9,
1516 0x83, 0xa9, 0x64, 0x62, 0x48, 0x25, 0xbd, 0x71, 0xd9, 0x0f, 0xb9, 0x43,
1517 0x39, 0x39, 0x73, 0x7f, 0x44, 0xb8, 0x9f, 0xef, 0x5d, 0x92, 0xf5, 0x29,
1518 0x3f, 0x0b, 0x9f, 0x57, 0x94, 0x75, 0x95, 0x97, 0x1a, 0xcc, 0xd8, 0xb8,
1519 0x0f, 0x01, 0x70, 0x36, 0xd1, 0x86, 0xbb, 0xb5, 0x81, 0x3c, 0x94, 0x50,
1520 0x11, 0xd9, 0x45, 0x3f, 0x5f, 0x7d, 0xb1, 0x5e, 0xea, 0xa7, 0xd7, 0x78,
1521 0x52, 0xd1, 0xe9, 0x66, 0x7f, 0x60, 0xb2, 0x73, 0x48, 0x89, 0x1e, 0x7b,
1522 0x46, 0xbd, 0x91, 0xcc, 0x9e, 0xb5, 0xfa, 0x23, 0x90, 0xc7, 0xb4, 0xbe,
1523 0x98, 0xf9, 0xbc, 0x2b, 0x17, 0x82, 0xb6, 0x4d, 0x17, 0xda, 0xb3, 0x5d,
1524 0xb4, 0x73, 0x57, 0xd9, 0xfd, 0x95, 0x8c, 0x63, 0xbd, 0x4b, 0x9e, 0xf3,
1525 0x0b, 0x18, 0xf7, 0x7e, 0xb9, 0xe0, 0xb3, 0xbf, 0x99, 0xcf, 0x79, 0xc2,
1526 0x74, 0xc2, 0x6e, 0xfa, 0x13, 0xf5, 0xa7, 0x80, 0x87, 0x7d, 0x52, 0x07,
1527 0x5f, 0xc9, 0xee, 0x4b, 0x0e, 0xe4, 0x45, 0xcf, 0x4b, 0x8f, 0xa0, 0xad,
1528 0x15, 0x3e, 0xf8, 0x10, 0x76, 0x73, 0xcd, 0x91, 0xab, 0x21, 0x77, 0x1d,
1529 0xbd, 0xc7, 0x02, 0x93, 0xe1, 0x4d, 0x61, 0xde, 0x33, 0x03, 0x2c, 0x57,
1530 0x2f, 0xd3, 0x31, 0xf2, 0xba, 0xe6, 0x97, 0x4f, 0x65, 0xfd, 0x76, 0x4f,
1531 0x39, 0xc3, 0x8c, 0x31, 0x00, 0xaf, 0xa4, 0xcd, 0x54, 0x6c, 0xbb, 0xcf,
1532 0xb6, 0x58, 0xe6, 0x2a, 0xf9, 0xf6, 0xc0, 0x85, 0x7f, 0x78, 0xd6, 0xff,
1533 0x7b, 0xc0, 0x91, 0x81, 0x4c, 0xe0, 0xf3, 0x6a, 0x90, 0x8f, 0x31, 0xa6,
1534 0xf5, 0xbf, 0xeb, 0xad, 0x9d, 0xac, 0x79, 0x7f, 0x58, 0xef, 0x93, 0x79,
1535 0xfe, 0x33, 0x59, 0xae, 0x77, 0xc0, 0x36, 0xc9, 0x69, 0xb9, 0x18, 0xfd,
1536 0x69, 0x0e, 0xf0, 0x14, 0x2a, 0xb4, 0x43, 0xfe, 0x06, 0x76, 0x88, 0xd6,
1537 0x93, 0xf2, 0xed, 0x41, 0xe6, 0xb1, 0xdd, 0xec, 0xd5, 0xae, 0xd6, 0x0b,
1538 0x21, 0x2c, 0xc9, 0xce, 0x1c, 0xf2, 0x47, 0xb4, 0x1d, 0xef, 0xc9, 0xac,
1539 0xe7, 0xea, 0x7d, 0x27, 0xf9, 0xc1, 0x20, 0x78, 0xc5, 0x77, 0xe5, 0xa4,
1540 0x86, 0xf9, 0x05, 0xf4, 0xe1, 0xc8, 0xc4, 0x80, 0xfb, 0xd3, 0x93, 0x3e,
1541 0xc7, 0xc7, 0x3c, 0xae, 0x2b, 0x6d, 0x8e, 0x1b, 0xf8, 0x68, 0x9b, 0x7e,
1542 0x2f, 0x98, 0x8d, 0x71, 0xdd, 0x02, 0x3c, 0x5d, 0x6a, 0xf7, 0x6e, 0x90,
1543 0xdb, 0xe6, 0x6c, 0x9a, 0x69, 0x31, 0x36, 0xa3, 0xd1, 0x69, 0x17, 0xfe,
1544 0x61, 0xc4, 0xbf, 0xb0, 0xba, 0x80, 0xb9, 0x81, 0x0e, 0x5b, 0x0c, 0x4b,
1545 0x8a, 0xb0, 0x0c, 0x6b, 0x58, 0x62, 0xc0, 0xa5, 0x0b, 0xd9, 0x77, 0x9b,
1546 0x1c, 0x02, 0xde, 0x87, 0x06, 0x45, 0x9e, 0x85, 0x4d, 0x76, 0xbe, 0x0a,
1547 0x9e, 0x19, 0xc0, 0x73, 0xde, 0xe7, 0x5e, 0x00, 0xe6, 0xf9, 0xde, 0xb0,
1548 0x70, 0x2f, 0x00, 0x71, 0xd8, 0x81, 0xdf, 0x22, 0x33, 0xd0, 0xbf, 0x27,
1549 0xfd, 0xd7, 0x82, 0xf1, 0x18, 0x75, 0x23, 0xda, 0x99, 0xdb, 0x1b, 0x14,
1550 0xc8, 0xe7, 0x53, 0xd4, 0x43, 0xb5, 0xd2, 0xb6, 0x8e, 0x7e, 0x88, 0x91,
1551 0x9f, 0x37, 0xf8, 0x19, 0xf4, 0xf5, 0x5b, 0x2b, 0xa5, 0x3e, 0x2f, 0xfd,
1552 0x1d, 0x75, 0xc8, 0x73, 0x6d, 0xde, 0x80, 0xce, 0xeb, 0xef, 0x38, 0x8c,
1553 0xfc, 0x8f, 0xaf, 0x64, 0xbc, 0xdb, 0xf5, 0xd7, 0x4b, 0xdb, 0x1a, 0xe6,
1554 0x55, 0xf3, 0xe0, 0xab, 0xdc, 0x83, 0x69, 0x75, 0x38, 0x64, 0x59, 0x29,
1555 0xef, 0x71, 0xa7, 0xdd, 0x21, 0xcc, 0xc5, 0x6e, 0x9f, 0xb2, 0xed, 0xbf,
1556 0xa3, 0x6e, 0x4a, 0x6e, 0xf4, 0x07, 0x91, 0x37, 0x8d, 0xbc, 0xc3, 0x36,
1557 0x6f, 0xd0, 0xe6, 0x6d, 0x43, 0xde, 0x3e, 0xe0, 0xef, 0x6e, 0x9d, 0x9e,
1558 0xe5, 0x6f, 0x53, 0xc7, 0x5b, 0xd9, 0x71, 0xe1, 0x33, 0x37, 0xf8, 0x84,
1559 0x0b, 0x79, 0x25, 0xae, 0x8b, 0xde, 0x26, 0x79, 0x2f, 0x79, 0x0b, 0x7b,
1560 0xfd, 0x66, 0xb1, 0x0e, 0xb2, 0x89, 0x7b, 0x80, 0x69, 0xb3, 0x6e, 0xf1,
1561 0x5e, 0x96, 0xff, 0x40, 0xba, 0xeb, 0xc9, 0x38, 0x5f, 0x5b, 0xc9, 0xb8,
1562 0xd8, 0x88, 0x4f, 0xfb, 0x3a, 0x90, 0x9c, 0x5e, 0x3f, 0xa1, 0x7f, 0x5b,
1563 0x44, 0x3a, 0xe9, 0x41, 0x35, 0x45, 0xf4, 0x3e, 0x2d, 0x7e, 0x47, 0x61,
1564 0xf7, 0x06, 0x42, 0x9f, 0x8f, 0x36, 0x5d, 0xc6, 0xe3, 0xda, 0x50, 0x98,
1565 0xe7, 0x21, 0x4f, 0x6d, 0x8a, 0xc0, 0x26, 0xaa, 0xf5, 0x1d, 0x1d, 0xa3,
1566 0x2e, 0xe8, 0x75, 0x00, 0xc6, 0xdf, 0x32, 0xf0, 0x63, 0x02, 0xe9, 0x47,
1567 0xdf, 0xa4, 0xfd, 0x68, 0x87, 0xef, 0x1d, 0x10, 0xee, 0x67, 0x65, 0x7a,
1568 0xbb, 0xf7, 0x6d, 0x99, 0xa7, 0xf3, 0x19, 0x49, 0x66, 0x94, 0x03, 0xff,
1569 0x75, 0xab, 0x23, 0xf5, 0xb0, 0x3d, 0x6e, 0x30, 0xfa, 0xcd, 0xe3, 0x9e,
1570 0xc4, 0x8b, 0xda, 0x56, 0x6b, 0xb4, 0xf3, 0x91, 0x05, 0x6e, 0xb8, 0x1f,
1571 0x7c, 0xe0, 0x9e, 0xdd, 0x7e, 0x21, 0x09, 0x6a, 0xd4, 0xba, 0x71, 0x18,
1572 0xb4, 0x91, 0x4d, 0x19, 0xdd, 0x78, 0xc3, 0x9c, 0x6e, 0xfc, 0xf3, 0x95,
1573 0xe4, 0x89, 0xe1, 0x72, 0x1c, 0x75, 0xf5, 0x3a, 0x4a, 0x82, 0x75, 0x6b,
1574 0x31, 0x9f, 0xe7, 0xfd, 0xec, 0x35, 0xa0, 0x2f, 0xc8, 0xe1, 0x64, 0xe7,
1575 0x29, 0xd4, 0x2d, 0xa0, 0xee, 0xe4, 0x5c, 0x5d, 0x47, 0x46, 0x7c, 0xbd,
1576 0xef, 0x59, 0x26, 0xcb, 0x21, 0x1d, 0x26, 0xe3, 0xb7, 0x6a, 0x5e, 0xe0,
1577 0x7e, 0x30, 0x37, 0x71, 0x9f, 0x6c, 0xd6, 0xb4, 0xdd, 0x27, 0xdc, 0x27,
1578 0xc5, 0xb6, 0xef, 0x0b, 0xda, 0xd6, 0x10, 0xbe, 0x12, 0xde, 0xa4, 0x8d,
1579 0x31, 0xbc, 0xc3, 0xf9, 0x37, 0xf3, 0x3e, 0xe4, 0x10, 0xdf, 0xbf, 0x1f,
1580 0xe4, 0x07, 0x39, 0x2f, 0xfc, 0x9e, 0xa7, 0xb9, 0x11, 0xd0, 0x5c, 0xc4,
1581 0x7f, 0xbb, 0x0c, 0xeb, 0x3d, 0x10, 0x29, 0x99, 0xd0, 0xf1, 0xcc, 0x0b,
1582 0xc1, 0x23, 0x0b, 0xe4, 0xf8, 0x47, 0x94, 0xa1, 0x21, 0xfe, 0x2e, 0x24,
1583 0xea, 0x64, 0x66, 0x4d, 0x9d, 0xde, 0xf1, 0x41, 0x7c, 0x8c, 0xde, 0x73,
1584 0x3b, 0xf8, 0xf5, 0xfa, 0xb9, 0xb1, 0x00, 0xdf, 0xc0, 0xe3, 0x4e, 0x63,
1585 0xeb, 0x63, 0x1c, 0x19, 0xed, 0xbf, 0x67, 0x8b, 0x4a, 0xef, 0x0b, 0xa2,
1586 0x8e, 0x3f, 0x00, 0x9d, 0x6a, 0xf6, 0xa4, 0xe0, 0x5d, 0xe1, 0xbc, 0x29,
1587 0xed, 0x73, 0x1c, 0x04, 0x0f, 0x1f, 0xf4, 0xb3, 0x6b, 0x6a, 0x75, 0xdb,
1588 0x49, 0xef, 0x7a, 0x6d, 0x13, 0x6e, 0x94, 0x99, 0x14, 0xdb, 0x23, 0x5e,
1589 0xfe, 0x47, 0x30, 0xe4, 0xcd, 0xa0, 0x7f, 0x43, 0xff, 0x59, 0x5f, 0xb5,
1590 0xd4, 0x49, 0xf5, 0x3e, 0x53, 0xe2, 0xc9, 0x85, 0xbd, 0xd2, 0x01, 0xfc,
1591 0x18, 0x78, 0x73, 0xe5, 0xb7, 0x49, 0x21, 0xe6, 0xda, 0xb1, 0x45, 0xb4,
1592 0x2f, 0x37, 0x91, 0xaa, 0x83, 0x2d, 0xf8, 0x17, 0xc1, 0xe4, 0x82, 0x31,
1593 0x1e, 0xac, 0x1a, 0xe3, 0x4c, 0x02, 0xd8, 0x68, 0x89, 0xcc, 0xc9, 0x01,
1594 0xf6, 0x65, 0x64, 0x52, 0x38, 0xc6, 0x3a, 0x8c, 0x71, 0xc7, 0xdc, 0x18,
1595 0x0f, 0x2f, 0x1a, 0xe3, 0x61, 0x8c, 0x11, 0xf6, 0x42, 0x29, 0xd3, 0xe9,
1596 0xce, 0xcf, 0xfb, 0xd5, 0x35, 0x73, 0xf3, 0x29, 0xdc, 0xeb, 0x84, 0xf1,
1597 0xd3, 0xa6, 0xd8, 0x08, 0x78, 0x74, 0x5b, 0x90, 0x71, 0x0e, 0x64, 0x5b,
1598 0x76, 0x4d, 0x8d, 0x1d, 0xff, 0x76, 0x96, 0x2b, 0x1b, 0x1c, 0x9c, 0x4c,
1599 0xb9, 0x9d, 0x8f, 0xa0, 0xbf, 0xbd, 0x76, 0x5c, 0xbd, 0xe5, 0xab, 0x31,
1600 0xae, 0x0b, 0xdf, 0xc1, 0x18, 0xe0, 0xb3, 0x9d, 0xa0, 0x0f, 0x9c, 0x18,
1601 0x92, 0x05, 0xb2, 0xeb, 0x33, 0xf3, 0x72, 0xd4, 0xc0, 0x4c, 0xdb, 0xba,
1602 0x30, 0x07, 0xf3, 0xdd, 0x8b, 0x60, 0xbe, 0x1b, 0x30, 0xef, 0xb3, 0xf3,
1603 0xb2, 0xaf, 0x6a, 0xcf, 0x62, 0x48, 0x47, 0xfc, 0xfd, 0xbc, 0xf5, 0x45,
1604 0x3e, 0x20, 0xf7, 0x97, 0x3a, 0xe5, 0xcb, 0x95, 0xe4, 0x59, 0xc6, 0xd1,
1605 0xcf, 0x55, 0x92, 0xe3, 0x22, 0x5d, 0xf2, 0xc7, 0xb0, 0x73, 0xae, 0x82,
1606 0x6f, 0xf1, 0x34, 0xfc, 0xd7, 0x3f, 0xa9, 0xf8, 0xf2, 0xc4, 0xdc, 0x7e,
1607 0x38, 0xea, 0xba, 0xb4, 0x9c, 0x84, 0x4f, 0xbb, 0xed, 0x68, 0x1b, 0xf7,
1608 0x2a, 0x11, 0xbe, 0xbb, 0xa8, 0x73, 0xda, 0x94, 0xe6, 0xc5, 0xef, 0x62,
1609 0xbc, 0xa7, 0xa9, 0x6b, 0xd6, 0xfa, 0xbe, 0x77, 0xb3, 0x5a, 0x47, 0x99,
1610 0x90, 0xff, 0x5a, 0xe4, 0x03, 0xf5, 0x26, 0xc6, 0x92, 0xf1, 0x9a, 0xc9,
1611 0x1b, 0xdb, 0x3a, 0x12, 0x7d, 0x42, 0x5b, 0x82, 0xfe, 0x36, 0x6c, 0xa1,
1612 0xd2, 0xe6, 0xf8, 0x5a, 0xa1, 0x4c, 0xa2, 0x5d, 0x94, 0x96, 0x09, 0xc0,
1613 0x3e, 0x06, 0x89, 0x50, 0x68, 0xf6, 0x47, 0x7b, 0xd5, 0x44, 0x03, 0x79,
1614 0x70, 0xdb, 0x19, 0xd0, 0xd7, 0x36, 0x8c, 0xa9, 0x2b, 0x79, 0x76, 0x46,
1615 0x65, 0x4e, 0xac, 0x95, 0x57, 0x82, 0xa1, 0x66, 0x47, 0x9e, 0xd8, 0xc4,
1616 0x3c, 0x2d, 0xb7, 0x3f, 0xd5, 0x0b, 0xf9, 0xd4, 0xce, 0x73, 0x0b, 0x03,
1617 0xf2, 0x2f, 0x77, 0x80, 0x06, 0x7f, 0xb8, 0xe9, 0x6b, 0xc1, 0x6c, 0xb3,
1618 0x2b, 0x5b, 0x37, 0x25, 0xbd, 0xbc, 0xc2, 0x78, 0x4a, 0x18, 0x4f, 0x09,
1619 0xe3, 0xe3, 0x98, 0x4b, 0x18, 0xd7, 0x15, 0xf7, 0x4a, 0xf5, 0x2c, 0x88,
1620 0xcb, 0x1a, 0x3f, 0x2d, 0x93, 0x77, 0x65, 0x83, 0xdd, 0x2b, 0x35, 0x5c,
1621 0x1f, 0xae, 0xb1, 0x65, 0x64, 0x3c, 0x28, 0xf8, 0x7f, 0x70, 0x55, 0xb6,
1622 0x2b, 0xb6, 0x58, 0xe7, 0xdc, 0x35, 0xaf, 0x73, 0x44, 0x9e, 0x33, 0xf3,
1623 0x86, 0x39, 0xf3, 0xbd, 0x49, 0x6e, 0x86, 0x87, 0x0e, 0xdc, 0xaa, 0xf7,
1624 0x3c, 0x77, 0xe0, 0x9b, 0x36, 0xd5, 0xa7, 0xf5, 0x3a, 0xe2, 0x4c, 0xf9,
1625 0x1e, 0x3b, 0x77, 0xf7, 0x68, 0x3d, 0xbb, 0x75, 0xd3, 0xa5, 0x80, 0xfb,
1626 0xdc, 0xbc, 0x4d, 0xcb, 0xc5, 0x22, 0x68, 0xef, 0xd5, 0x69, 0xde, 0xe7,
1627 0x7a, 0x76, 0x41, 0x9f, 0x13, 0x01, 0xde, 0xe6, 0xe2, 0x62, 0xf5, 0x48,
1628 0xa3, 0xbe, 0xf8, 0x69, 0x83, 0x59, 0x47, 0xa5, 0x6c, 0x58, 0x83, 0x34,
1629 0xd7, 0xec, 0x05, 0x5e, 0x90, 0xf7, 0xdf, 0xea, 0xcd, 0x9e, 0x8f, 0xea,
1630 0xb2, 0xe0, 0x31, 0xbd, 0x2f, 0x84, 0xfb, 0x03, 0x7f, 0x79, 0xa5, 0xb1,
1631 0x4d, 0xc3, 0x7c, 0xa6, 0xff, 0x38, 0x98, 0xd0, 0x31, 0x36, 0xf6, 0xf5,
1632 0x43, 0xfc, 0x5e, 0xbc, 0x5f, 0x24, 0xb4, 0x5d, 0xeb, 0x40, 0xf7, 0xda,
1633 0x5f, 0x16, 0x94, 0x89, 0xe7, 0x25, 0x22, 0x13, 0x55, 0x30, 0x4e, 0x10,
1634 0xee, 0x52, 0xd7, 0xaa, 0xf9, 0xd8, 0xdd, 0x6a, 0xa4, 0x11, 0xc6, 0x75,
1635 0x8b, 0xf2, 0xc8, 0x1b, 0xad, 0x2b, 0x49, 0x37, 0xd3, 0xc2, 0xb4, 0xf9,
1636 0x31, 0xcd, 0x68, 0xfb, 0xb9, 0x6d, 0x95, 0xde, 0xfb, 0xc4, 0x35, 0x46,
1637 0xc6, 0x08, 0x63, 0x26, 0xdf, 0xf5, 0xff, 0x56, 0xd7, 0x19, 0x9a, 0xab,
1638 0xa3, 0xe7, 0x02, 0xf9, 0x6e, 0x55, 0x5e, 0x35, 0xdc, 0xd4, 0x5f, 0x43,
1639 0x9d, 0x75, 0xd0, 0x89, 0x17, 0x53, 0xab, 0xc3, 0xbd, 0xf0, 0xb0, 0x21,
1640 0xb2, 0xd7, 0xd4, 0x5a, 0x99, 0x3f, 0x81, 0x79, 0x7d, 0x26, 0x65, 0x78,
1641 0x51, 0xf3, 0x61, 0xf1, 0x36, 0xf8, 0xeb, 0xa1, 0xde, 0xa0, 0x9c, 0x26,
1642 0x6f, 0x22, 0xad, 0x42, 0x9f, 0xe0, 0xc2, 0xea, 0x99, 0xae, 0x57, 0x03,
1643 0xee, 0xb3, 0x7c, 0x45, 0xdb, 0x51, 0x43, 0xb2, 0xb0, 0xed, 0xd1, 0x7b,
1644 0x5e, 0xbf, 0xed, 0xa1, 0x65, 0xda, 0x1e, 0xb2, 0x6d, 0x8b, 0x6b, 0xda,
1645 0x8e, 0x5e, 0xa1, 0xed, 0x81, 0x37, 0x68, 0x7b, 0x70, 0x99, 0xb6, 0x07,
1646 0xc3, 0xb6, 0x95, 0x69, 0xdb, 0x0b, 0xdb, 0x4e, 0x2c, 0xc2, 0xc9, 0x67,
1647 0x5e, 0xbf, 0xed, 0x7d, 0xcb, 0xb4, 0xbd, 0x6f, 0x11, 0xdc, 0xc4, 0x49,
1648 0x2d, 0x74, 0xff, 0x3d, 0xda, 0xe6, 0xac, 0x03, 0xdf, 0x5c, 0x84, 0xfc,
1649 0x36, 0xfe, 0xc8, 0x85, 0xbb, 0x66, 0xcb, 0xe0, 0x2b, 0xf8, 0xd7, 0x99,
1650 0x72, 0x03, 0x9e, 0x71, 0xd8, 0x33, 0x28, 0x07, 0x7b, 0xbc, 0x26, 0x1d,
1651 0xc8, 0xc9, 0x6e, 0x96, 0xcd, 0xc7, 0x6b, 0xe7, 0xf4, 0xc6, 0x3d, 0xe8,
1652 0x8f, 0x6d, 0xfb, 0x5e, 0xbf, 0xbc, 0xa6, 0xfb, 0xcb, 0x95, 0xe9, 0x8f,
1653 0x21, 0xbd, 0x42, 0x1f, 0x97, 0xf5, 0x42, 0x19, 0x58, 0x67, 0xd7, 0x3e,
1654 0x68, 0x6b, 0x32, 0x0e, 0xa7, 0xed, 0x51, 0x29, 0x94, 0x7f, 0x12, 0x4c,
1655 0x83, 0x2e, 0x46, 0xe6, 0x74, 0xc8, 0x93, 0xab, 0x68, 0xb3, 0x8f, 0x53,
1656 0xb3, 0x54, 0xc5, 0xa0, 0x46, 0x7c, 0xa6, 0xfd, 0x98, 0x6d, 0xc2, 0x0e,
1657 0x0c, 0xcb, 0x32, 0x6e, 0x6c, 0x62, 0x4e, 0x67, 0x21, 0x33, 0xcd, 0x9e,
1658 0x0e, 0xfa, 0x2a, 0x4f, 0x81, 0x97, 0xf7, 0x43, 0x76, 0x24, 0xf3, 0x22,
1659 0x3d, 0x8d, 0xe6, 0xac, 0x45, 0x4c, 0x72, 0x5d, 0xbf, 0x69, 0xf1, 0xb8,
1660 0xef, 0xce, 0xe5, 0xcf, 0x59, 0x40, 0x3e, 0x38, 0x94, 0x91, 0xd7, 0x37,
1661 0x9a, 0x75, 0xbb, 0xb7, 0x36, 0x32, 0x1e, 0xa3, 0x36, 0x75, 0xaf, 0xd6,
1662 0xf2, 0xc7, 0x09, 0xbf, 0xbf, 0xb2, 0xe8, 0x3b, 0xac, 0xf7, 0x93, 0xd5,
1663 0x0b, 0xeb, 0x85, 0xe9, 0x70, 0x4d, 0x16, 0xa4, 0x1f, 0x58, 0xb3, 0xb0,
1664 0x7e, 0xac, 0x69, 0xe1, 0xf7, 0xe0, 0xa2, 0xef, 0xcf, 0x2c, 0xfa, 0x7e,
1665 0x61, 0xd1, 0xf7, 0x75, 0x6b, 0x17, 0x95, 0x5f, 0xf4, 0xfd, 0xe5, 0xb5,
1666 0xcb, 0xc3, 0xfb, 0x57, 0x6b, 0x17, 0xc2, 0xf5, 0x94, 0x5e, 0x73, 0x1d,
1667 0xaf, 0xb8, 0xb2, 0xbd, 0x88, 0x7c, 0xe7, 0xd6, 0x18, 0xf2, 0xe1, 0xcb,
1668 0x54, 0xe7, 0x73, 0x8d, 0xe3, 0x1d, 0xb1, 0x85, 0xed, 0xcd, 0xd7, 0xdb,
1669 0x31, 0x5f, 0x2f, 0x35, 0x5f, 0xcf, 0xf8, 0x23, 0x13, 0x15, 0xe6, 0x31,
1670 0x3d, 0x6c, 0xd7, 0xd4, 0x1d, 0x29, 0x79, 0xfa, 0x3c, 0xc2, 0x80, 0x3e,
1671 0x8f, 0x90, 0x80, 0x6f, 0xf4, 0x94, 0x8e, 0xeb, 0xaf, 0x51, 0x48, 0xaf,
1672 0x34, 0xea, 0xd8, 0xbe, 0xe8, 0x33, 0x09, 0x03, 0xb0, 0xb9, 0x78, 0x0e,
1673 0x21, 0x90, 0x9d, 0x29, 0xf3, 0x36, 0xe7, 0x12, 0x0e, 0x07, 0xbd, 0x5e,
1674 0x10, 0x0c, 0xfb, 0x67, 0xad, 0x2c, 0xc7, 0xbb, 0x62, 0xea, 0xd0, 0xd7,
1675 0x7c, 0x14, 0xfa, 0x66, 0xde, 0xc7, 0x7c, 0x8a, 0xf6, 0x3a, 0x68, 0xa6,
1676 0x1b, 0x7a, 0x37, 0xf9, 0xa4, 0x68, 0xdd, 0xd1, 0x05, 0x9d, 0xeb, 0xdd,
1677 0xfb, 0x3e, 0xd8, 0x3a, 0x5f, 0x06, 0xad, 0x1f, 0x4b, 0xf5, 0x68, 0xff,
1678 0xff, 0x1c, 0x74, 0x31, 0xe3, 0x84, 0x8f, 0x69, 0xda, 0x22, 0x8d, 0x35,
1679 0xe8, 0xb3, 0x50, 0x27, 0x53, 0x4e, 0x34, 0xdb, 0x75, 0xde, 0xc4, 0xcd,
1680 0x53, 0xed, 0xde, 0x73, 0xe0, 0xb5, 0x7e, 0x7f, 0x03, 0x6c, 0x66, 0xd1,
1681 0x3a, 0xbf, 0x50, 0x5a, 0x6f, 0x6d, 0x83, 0x66, 0x19, 0x77, 0xb9, 0x56,
1682 0x93, 0xec, 0x19, 0x32, 0x3e, 0x66, 0x3c, 0xa1, 0x18, 0x23, 0xe6, 0xfa,
1683 0x05, 0xcf, 0x39, 0x70, 0x9d, 0x9b, 0xf1, 0x90, 0xf1, 0x7b, 0x47, 0xfc,
1684 0xbc, 0x17, 0xb1, 0x67, 0x23, 0xb2, 0x45, 0x43, 0x9b, 0x7b, 0xb4, 0xad,
1685 0x1a, 0x05, 0x3f, 0x7d, 0x0f, 0x74, 0xcf, 0xba, 0xa4, 0xfd, 0xef, 0x04,
1686 0x93, 0xae, 0x89, 0x4f, 0x29, 0xd4, 0xcb, 0x6a, 0x5c, 0x3d, 0x25, 0x07,
1687 0x4a, 0xe4, 0xff, 0xa8, 0x96, 0xe5, 0xbb, 0x53, 0x94, 0x07, 0x51, 0xe0,
1688 0x71, 0x0a, 0xf8, 0x6b, 0x90, 0xdd, 0x5d, 0x45, 0x94, 0x89, 0xc8, 0xd0,
1689 0x40, 0x03, 0x78, 0x8f, 0x76, 0x09, 0xdf, 0x2e, 0xca, 0x7b, 0x32, 0x55,
1690 0x1c, 0xd7, 0x7b, 0x9e, 0x1f, 0x43, 0xdd, 0xc7, 0xf1, 0x4c, 0x14, 0xcb,
1691 0xa8, 0xf3, 0xb0, 0x2e, 0x3f, 0x31, 0xca, 0x73, 0x22, 0x02, 0x7b, 0xff,
1692 0x49, 0x29, 0x4c, 0xb6, 0xc1, 0x2f, 0x99, 0x1e, 0x77, 0xe7, 0xe2, 0xe4,
1693 0xff, 0xa5, 0x91, 0xeb, 0xcc, 0x85, 0xeb, 0xb8, 0x27, 0x47, 0xdc, 0x81,
1694 0xcd, 0xaa, 0xb3, 0x49, 0xaf, 0xf9, 0xf4, 0x48, 0x3f, 0x6c, 0x8a, 0x9b,
1695 0x2b, 0xcf, 0xc4, 0xcc, 0xda, 0xc0, 0x82, 0xf5, 0x86, 0xc3, 0xc4, 0x8a,
1696 0x3a, 0xea, 0xf2, 0xdc, 0xa7, 0x4c, 0x9c, 0x81, 0xf6, 0x39, 0x1a, 0xae,
1697 0xe7, 0x30, 0xcd, 0x93, 0xb6, 0xeb, 0x00, 0xd7, 0x99, 0x7f, 0xd2, 0xf2,
1698 0xf5, 0x89, 0x4d, 0x61, 0x5f, 0xf9, 0x60, 0x6c, 0x53, 0x5e, 0x3e, 0x81,
1699 0x27, 0x77, 0x5d, 0x72, 0x34, 0xab, 0xd8, 0xef, 0x37, 0x02, 0xc6, 0x02,
1700 0x54, 0xba, 0x55, 0xf2, 0x4d, 0xd5, 0xfd, 0x33, 0xad, 0xc3, 0x2b, 0xa8,
1701 0xd7, 0x83, 0x63, 0x26, 0x11, 0x03, 0x0e, 0xf2, 0x6f, 0x08, 0xcf, 0x16,
1702 0xcf, 0x57, 0xcb, 0xc1, 0x73, 0xc2, 0xae, 0xd7, 0x70, 0x0d, 0x66, 0x05,
1703 0xf0, 0xd2, 0x80, 0xf4, 0x09, 0x19, 0x39, 0xfe, 0x3b, 0x31, 0xee, 0x17,
1704 0xaa, 0xd1, 0x7e, 0xf5, 0x7d, 0xf5, 0x26, 0x06, 0xf2, 0x2c, 0xca, 0x30,
1705 0x7f, 0x1c, 0x75, 0x92, 0xf9, 0x6c, 0x64, 0xad, 0x0c, 0xe9, 0x7e, 0x83,
1706 0x48, 0xdb, 0xb6, 0x7a, 0xbd, 0x4f, 0x5f, 0xce, 0x30, 0x6e, 0x11, 0xd6,
1707 0x7d, 0x56, 0xef, 0x83, 0x73, 0xd3, 0xc9, 0x7c, 0x5f, 0x84, 0xf2, 0xa9,
1708 0x53, 0x7a, 0xb9, 0xce, 0x73, 0x66, 0x5c, 0xd3, 0x76, 0xfb, 0x26, 0x9e,
1709 0x07, 0xdd, 0x02, 0xfb, 0xef, 0x3b, 0x80, 0x89, 0x30, 0x9e, 0x40, 0x3a,
1710 0x7c, 0xc2, 0xd7, 0x85, 0x61, 0xfa, 0x4d, 0xc2, 0x30, 0xfd, 0x26, 0x61,
1711 0x20, 0x2e, 0x00, 0x47, 0xa5, 0x7d, 0x75, 0x68, 0x53, 0x5c, 0x85, 0x71,
1712 0x1c, 0x2c, 0x4d, 0xc3, 0xbf, 0xd5, 0x31, 0x94, 0xce, 0x69, 0x45, 0x9e,
1713 0xf7, 0xc0, 0x73, 0xe0, 0xad, 0x12, 0x78, 0x0f, 0xb6, 0xe1, 0x97, 0x61,
1714 0x1b, 0x3e, 0x01, 0xdb, 0xf0, 0x1c, 0x6c, 0xc3, 0xc7, 0x31, 0x37, 0x8f,
1715 0x2d, 0xe0, 0xd5, 0x8c, 0xe6, 0xd5, 0x42, 0xe9, 0x02, 0x78, 0xb5, 0xeb,
1716 0x0a, 0xfc, 0xe8, 0xc2, 0xc6, 0xa7, 0x0d, 0xed, 0xc0, 0x96, 0xff, 0xb8,
1717 0xf6, 0x8b, 0x1f, 0x4c, 0x8d, 0xb1, 0x0e, 0x68, 0x38, 0x49, 0x9f, 0x16,
1718 0xf2, 0x3f, 0x99, 0x07, 0xef, 0x61, 0xac, 0x8e, 0xa3, 0xae, 0x5b, 0x23,
1719 0xd4, 0x1f, 0xee, 0x36, 0xee, 0xef, 0xe6, 0x58, 0x13, 0x8b, 0xf0, 0x64,
1720 0xf8, 0x73, 0x8f, 0x4f, 0x3d, 0x42, 0xbe, 0x4c, 0x7c, 0x76, 0xc4, 0xaf,
1721 0xe6, 0xc5, 0x1d, 0x1c, 0x5f, 0xe0, 0x6d, 0x5a, 0xae, 0xee, 0x7c, 0xf9,
1722 0x35, 0x73, 0xe5, 0x75, 0xff, 0xa3, 0xe4, 0x37, 0xe8, 0x6e, 0xe2, 0x3e,
1723 0x91, 0x8d, 0x6c, 0xb0, 0xb8, 0xdf, 0x2f, 0x6d, 0xdb, 0x60, 0xaf, 0x0f,
1724 0x82, 0x7e, 0xa7, 0x02, 0xf1, 0xb7, 0x85, 0x6d, 0xce, 0xb7, 0xe3, 0xd9,
1725 0x76, 0x76, 0xc3, 0x96, 0xed, 0xdb, 0xc4, 0xb5, 0x5e, 0xd8, 0xf2, 0xa9,
1726 0x70, 0x3e, 0x60, 0xf9, 0xea, 0x39, 0xa7, 0x0c, 0xa5, 0xec, 0x6c, 0xb0,
1727 0xf1, 0x7e, 0xb6, 0x77, 0x61, 0xd1, 0x3c, 0x5d, 0x0a, 0x78, 0xce, 0x76,
1728 0xc4, 0x1f, 0xab, 0xa2, 0x95, 0xbf, 0xb2, 0xb4, 0xa2, 0x16, 0x8d, 0xe3,
1729 0x9c, 0xa5, 0x95, 0x10, 0xde, 0x58, 0x48, 0x2b, 0x75, 0x21, 0xad, 0xe4,
1730 0xc7, 0x43, 0x5a, 0x61, 0xdd, 0x73, 0x21, 0xad, 0x24, 0xaa, 0x69, 0x25,
1731 0x3f, 0xee, 0xe0, 0x59, 0x0c, 0x07, 0xe9, 0x85, 0xed, 0x90, 0x5e, 0x00,
1732 0x4b, 0xa5, 0x32, 0x47, 0x2f, 0x31, 0xb4, 0x73, 0xa8, 0xa4, 0x34, 0xad,
1733 0x0c, 0xa9, 0x50, 0x47, 0x78, 0x98, 0x73, 0xcc, 0xfd, 0x15, 0x69, 0x24,
1734 0x65, 0x69, 0x64, 0xfe, 0x2c, 0xd1, 0x22, 0xda, 0x00, 0xee, 0x79, 0x5e,
1735 0x60, 0xb3, 0xa6, 0x8d, 0xfb, 0x53, 0x2f, 0xa0, 0xec, 0x28, 0x68, 0x23,
1736 0xc4, 0xc1, 0x03, 0x16, 0x07, 0x8b, 0xe7, 0xf2, 0xb4, 0xc5, 0xc1, 0xa8,
1737 0xc5, 0x81, 0xe6, 0x97, 0x3c, 0xe7, 0x4c, 0x69, 0x1c, 0xd4, 0x69, 0x1c,
1738 0x88, 0x0a, 0xeb, 0x9e, 0x5e, 0x06, 0x07, 0x2c, 0x33, 0xaa, 0xc7, 0x1f,
1739 0xc1, 0xf8, 0xf7, 0x61, 0xfc, 0x4a, 0x8f, 0x9f, 0xf3, 0xc0, 0xf1, 0x03,
1740 0x96, 0xca, 0x77, 0xe6, 0xc6, 0xdf, 0x84, 0x36, 0x0e, 0x6a, 0xdb, 0x99,
1741 0xf1, 0x54, 0xea, 0x46, 0x33, 0xfe, 0xc7, 0x2a, 0xe6, 0x8c, 0xc9, 0x63,
1742 0x4b, 0xf4, 0xd8, 0x0b, 0x96, 0x37, 0x7c, 0xbd, 0xce, 0xc6, 0x73, 0x6d,
1743 0xe7, 0xa0, 0xbb, 0xc6, 0x52, 0x09, 0x7b, 0xe6, 0xd4, 0xd8, 0x43, 0x5f,
1744 0x4d, 0x91, 0x77, 0x3e, 0xaa, 0xf7, 0xfa, 0x9d, 0xa5, 0x5d, 0x54, 0x6a,
1745 0x92, 0xbe, 0xb1, 0x6a, 0xb8, 0x09, 0x6f, 0x3e, 0x50, 0x3e, 0x63, 0x37,
1746 0xfb, 0xa1, 0x3b, 0x4c, 0xdc, 0x1a, 0xb4, 0x84, 0xf4, 0x64, 0xbe, 0x37,
1747 0x52, 0x27, 0xea, 0x81, 0x0f, 0x60, 0xcc, 0x2e, 0x7c, 0xcc, 0x76, 0x6f,
1748 0x9b, 0xa2, 0xae, 0xbb, 0xba, 0x4a, 0xd7, 0x35, 0x5b, 0x5d, 0xb7, 0x86,
1749 0xba, 0x0e, 0x70, 0x3f, 0x25, 0x87, 0x4b, 0x9c, 0xbf, 0x7c, 0xa2, 0x4e,
1750 0xc7, 0x40, 0x1d, 0x1b, 0xe7, 0x4b, 0xc6, 0x0f, 0x6b, 0x5a, 0xa6, 0xce,
1751 0x4a, 0xea, 0xb8, 0xe4, 0x4c, 0xd7, 0x3f, 0xd9, 0x75, 0x10, 0xea, 0xb5,
1752 0xef, 0x07, 0x7f, 0xb0, 0x8c, 0x5e, 0x83, 0xfe, 0xd1, 0xf6, 0x59, 0x0d,
1753 0x64, 0xad, 0x9c, 0x6a, 0xc6, 0xb3, 0x9a, 0xe7, 0xc1, 0x3a, 0x3b, 0x54,
1754 0xbd, 0xd4, 0x9c, 0x6a, 0x94, 0x3d, 0x63, 0x7a, 0xdd, 0x5c, 0xd4, 0x29,
1755 0xe0, 0xff, 0x14, 0xcf, 0x14, 0x88, 0x3e, 0x03, 0x95, 0x1b, 0x85, 0x3f,
1756 0x33, 0xf1, 0x94, 0xd9, 0x1b, 0x38, 0x56, 0xa3, 0x7f, 0xd3, 0xc6, 0x28,
1757 0xa4, 0x32, 0xfa, 0xec, 0xd0, 0x1e, 0xb4, 0xd9, 0xbe, 0xa9, 0x16, 0x63,
1758 0x8e, 0xa1, 0x2e, 0xf7, 0x16, 0xaa, 0x36, 0x57, 0x6a, 0xc5, 0x9d, 0x88,
1759 0xea, 0xf3, 0x4b, 0x3c, 0x7f, 0x9f, 0xed, 0x69, 0x42, 0x5e, 0x44, 0xaf,
1760 0x15, 0xd4, 0x9c, 0x9a, 0x3f, 0xa7, 0xae, 0x8e, 0x8a, 0x5d, 0xc3, 0x4f,
1761 0x6b, 0xbd, 0x12, 0x39, 0x4a, 0x9d, 0xc3, 0xfd, 0x55, 0x3d, 0x98, 0xf7,
1762 0xe5, 0xf4, 0x8d, 0x31, 0x62, 0xb3, 0x98, 0x3f, 0x75, 0x86, 0x67, 0x8d,
1763 0x5b, 0xf1, 0x0e, 0xdb, 0x0b, 0xf5, 0x08, 0x74, 0xdf, 0xdb, 0x3f, 0xe1,
1764 0x49, 0x3d, 0xf0, 0x3d, 0xa1, 0x80, 0x6b, 0x57, 0xd3, 0x42, 0x5e, 0x85,
1765 0xb1, 0x69, 0x43, 0x0f, 0x8f, 0xbf, 0x21, 0x3f, 0x90, 0x26, 0x3a, 0x6d,
1766 0x6c, 0xc1, 0xb7, 0x31, 0x7e, 0xd2, 0xb6, 0xa1, 0x87, 0x47, 0x53, 0x19,
1767 0xc5, 0xbd, 0x51, 0x66, 0x1d, 0x94, 0xb4, 0x41, 0x9a, 0x4f, 0xe8, 0xf5,
1768 0xd1, 0x8c, 0xbc, 0x2c, 0x99, 0xa6, 0x76, 0xd8, 0x5d, 0xff, 0xb6, 0x73,
1769 0x6c, 0xee, 0x2e, 0xd0, 0x34, 0x07, 0xdd, 0xc4, 0x7d, 0xca, 0x9d, 0xf2,
1770 0x5e, 0x9e, 0x57, 0x98, 0x70, 0xa0, 0x94, 0x9f, 0xd2, 0x7b, 0xbf, 0x77,
1771 0x14, 0x57, 0xcb, 0xad, 0xa9, 0xa8, 0x5d, 0xe7, 0xac, 0x05, 0x1d, 0x40,
1772 0x50, 0x9f, 0xaa, 0xc5, 0x13, 0x75, 0x38, 0x7f, 0x17, 0x53, 0x99, 0xa4,
1773 0x22, 0xb3, 0xc3, 0xe7, 0x9f, 0x91, 0x2d, 0xde, 0x1e, 0x7d, 0xce, 0x4e,
1774 0x9c, 0xba, 0x53, 0x7f, 0xe9, 0xd1, 0x06, 0x25, 0xfd, 0xcc, 0xf8, 0xb5,
1775 0x7a, 0x5d, 0xab, 0x3f, 0x15, 0x04, 0x39, 0xcc, 0x5f, 0x41, 0x4c, 0xfc,
1776 0x6c, 0xc2, 0x67, 0x1a, 0xfd, 0xda, 0x06, 0xa7, 0xf6, 0x4c, 0xa3, 0x63,
1777 0x68, 0x45, 0x22, 0x2a, 0x5d, 0xef, 0xd4, 0x9c, 0xba, 0x93, 0x73, 0x06,
1778 0xba, 0xf2, 0x1c, 0x43, 0x57, 0x31, 0x67, 0x9e, 0xae, 0xd6, 0xd9, 0xdf,
1779 0x2a, 0x5d, 0x27, 0x99, 0x64, 0x1d, 0xc6, 0xdb, 0x5b, 0x0c, 0x61, 0x3c,
1780 0x0c, 0xb8, 0x08, 0xcf, 0xdd, 0x18, 0xc3, 0x30, 0x9e, 0x3c, 0x60, 0x01,
1781 0xb3, 0x9f, 0x2a, 0x00, 0xe6, 0x83, 0x78, 0x18, 0x27, 0x6b, 0x76, 0x22,
1782 0x13, 0xd5, 0xf0, 0x12, 0xc6, 0x1f, 0x5b, 0x78, 0x5f, 0x0f, 0x56, 0x4f,
1783 0x66, 0xba, 0x8b, 0x80, 0x87, 0x70, 0xde, 0x07, 0x18, 0x69, 0x97, 0x8e,
1784 0xe2, 0xdb, 0x03, 0x7c, 0x63, 0x16, 0x26, 0xd0, 0xe3, 0xd8, 0x43, 0xf3,
1785 0xbf, 0x8b, 0xb4, 0x93, 0x8f, 0xd9, 0xef, 0xd6, 0x45, 0x32, 0xe0, 0x15,
1786 0x87, 0x78, 0x1e, 0x29, 0xbd, 0xe6, 0xc0, 0x0e, 0x00, 0xdf, 0xbf, 0xe4,
1787 0x44, 0xce, 0xc4, 0xe5, 0x50, 0x91, 0x31, 0x84, 0xe3, 0x0e, 0xe7, 0x41,
1788 0xf9, 0x57, 0xa1, 0x4c, 0x5c, 0xc9, 0xc4, 0xd5, 0x78, 0xde, 0x82, 0x67,
1789 0x03, 0x9e, 0x8d, 0x78, 0xd6, 0xe3, 0x69, 0xc5, 0xf3, 0x2d, 0x94, 0x53,
1790 0xb1, 0x3a, 0xe1, 0x7e, 0xd5, 0x16, 0xa5, 0x34, 0x1f, 0x71, 0xcf, 0xc2,
1791 0x65, 0xc0, 0xe5, 0x2b, 0xd0, 0x3b, 0x1e, 0x9e, 0xf1, 0xf8, 0x3a, 0xfa,
1792 0x98, 0xc5, 0xd3, 0xa9, 0xe4, 0x4c, 0x17, 0x9e, 0x14, 0x9e, 0x6e, 0x3c,
1793 0x3d, 0x78, 0xd2, 0x78, 0x5e, 0x75, 0x0c, 0xcf, 0x5d, 0x02, 0xbe, 0x42,
1794 0x1e, 0x01, 0xce, 0x17, 0xf0, 0x9c, 0xe7, 0xbc, 0x09, 0x9e, 0x73, 0x2c,
1795 0xcf, 0x39, 0xf3, 0x3c, 0x57, 0xeb, 0xa8, 0x63, 0xf5, 0x4e, 0xe4, 0x18,
1796 0x7d, 0x85, 0x5a, 0xc7, 0xf0, 0x7f, 0x44, 0x7a, 0x07, 0x41, 0x4b, 0xc7,
1797 0x30, 0x67, 0xc7, 0x48, 0x57, 0x2e, 0xd2, 0xc7, 0x16, 0xf5, 0x3b, 0xfa,
1798 0x26, 0xfa, 0x3d, 0x61, 0xfb, 0x7d, 0xb8, 0xaa, 0xdf, 0x83, 0x68, 0xfb,
1799 0x3e, 0xdb, 0xef, 0xc1, 0xaa, 0x7e, 0x41, 0x2b, 0xc7, 0xf2, 0x78, 0x48,
1800 0x17, 0x23, 0x48, 0x0f, 0x65, 0xc2, 0xdd, 0x6b, 0xa4, 0xbe, 0x46, 0x9f,
1801 0x27, 0x8d, 0xf9, 0x35, 0x73, 0xba, 0x31, 0x53, 0xa5, 0x1f, 0x7e, 0x16,
1802 0xfd, 0x38, 0x5c, 0xa2, 0x8d, 0x38, 0x5d, 0x25, 0x17, 0xe8, 0xfb, 0x04,
1803 0x72, 0x5c, 0xfb, 0x39, 0xf4, 0x79, 0xe8, 0xff, 0x2c, 0xb6, 0xad, 0x3e,
1804 0xae, 0xf7, 0xe7, 0xde, 0x55, 0x6c, 0x95, 0x4f, 0x14, 0x69, 0x13, 0x92,
1805 0x5e, 0x82, 0x60, 0xcf, 0x36, 0xda, 0xa7, 0xf9, 0x60, 0x9d, 0x9f, 0xd4,
1806 0xb1, 0xb5, 0x4f, 0x2e, 0xd5, 0x19, 0xa3, 0xbd, 0xf0, 0xcd, 0xb3, 0x47,
1807 0x3f, 0x08, 0x9d, 0x51, 0x03, 0xb8, 0x9f, 0xd2, 0x77, 0x80, 0xec, 0x1a,
1808 0x55, 0x23, 0x6b, 0x25, 0x2e, 0x37, 0x17, 0x6b, 0x61, 0xf7, 0x30, 0x56,
1809 0x5e, 0x2f, 0xed, 0xdb, 0xa2, 0xe6, 0x6c, 0x8d, 0x17, 0xc3, 0x6f, 0xcf,
1810 0x9c, 0xf5, 0x89, 0xc5, 0x91, 0x1f, 0x69, 0xa2, 0x1c, 0x8c, 0xf9, 0xef,
1811 0xd4, 0xfb, 0x26, 0xdb, 0xb6, 0xd1, 0x6e, 0xb9, 0x41, 0xeb, 0x70, 0x77,
1812 0x89, 0x9d, 0xa4, 0x5a, 0x3c, 0x99, 0xb7, 0xd1, 0x76, 0x17, 0x93, 0x09,
1813 0xc2, 0xf5, 0x90, 0x70, 0x3f, 0xc1, 0x7e, 0x29, 0xa4, 0x1a, 0x25, 0x92,
1814 0xe6, 0xba, 0x5c, 0xb2, 0x93, 0xb6, 0xd1, 0xc4, 0x98, 0x67, 0xcf, 0x9e,
1815 0xac, 0x96, 0x0b, 0xba, 0x9f, 0x5a, 0x0d, 0xa3, 0x39, 0x8f, 0xc6, 0x35,
1816 0x2f, 0x9e, 0x81, 0x72, 0xf1, 0x6e, 0xd0, 0x7a, 0x67, 0xa2, 0xcc, 0xb3,
1817 0x4e, 0xf0, 0x97, 0xca, 0x31, 0x7d, 0xc6, 0xd4, 0x7b, 0x3b, 0xfc, 0xd8,
1818 0xf2, 0x06, 0xd9, 0x3d, 0xb6, 0x82, 0xeb, 0x28, 0xb1, 0xb5, 0xd0, 0x1f,
1819 0xac, 0xd3, 0xb6, 0x0d, 0xfe, 0xdf, 0xf8, 0x46, 0x79, 0x7c, 0x9c, 0x6d,
1820 0xb7, 0xc8, 0xe4, 0x94, 0x38, 0xde, 0xdb, 0x57, 0xa2, 0x8c, 0xc7, 0xf1,
1821 0x08, 0xf7, 0x3c, 0xb5, 0x6d, 0x13, 0xe5, 0xbd, 0xdd, 0x95, 0xf3, 0xdd,
1822 0x11, 0xbd, 0x26, 0xe3, 0x82, 0x4e, 0xd8, 0xde, 0xf9, 0xee, 0x56, 0x39,
1823 0x3b, 0x05, 0x9a, 0x80, 0xdc, 0xef, 0x3b, 0x45, 0x98, 0x44, 0xb6, 0x4f,
1824 0xc0, 0x5e, 0x90, 0x76, 0x3c, 0xa0, 0x0f, 0xc8, 0xef, 0x5b, 0xbb, 0xd9,
1825 0x17, 0xf4, 0x12, 0x74, 0x5c, 0xdb, 0x36, 0x23, 0x0b, 0x32, 0x13, 0x35,
1826 0x48, 0x67, 0xbb, 0xf0, 0x0f, 0x07, 0xd9, 0x4e, 0x58, 0x57, 0x61, 0x4c,
1827 0xb5, 0x9a, 0x5e, 0x66, 0x17, 0xe9, 0x8f, 0x73, 0x3f, 0x97, 0xfd, 0xcd,
1828 0x36, 0x3a, 0x41, 0x2b, 0xbe, 0xde, 0xc3, 0x63, 0x6c, 0x2b, 0xce, 0x09,
1829 0x6d, 0x22, 0xda, 0x55, 0xd7, 0x6a, 0xfb, 0x62, 0xb2, 0xc2, 0x19, 0xe4,
1830 0xda, 0x48, 0x38, 0x47, 0x71, 0x39, 0x59, 0x9a, 0x9b, 0xa7, 0x0d, 0x35,
1831 0x0b, 0xe7, 0x89, 0xb4, 0x92, 0x1a, 0xb2, 0xb6, 0xc7, 0x8c, 0x3c, 0x0f,
1832 0xbb, 0xac, 0x53, 0xcf, 0xd9, 0x0c, 0x6c, 0x59, 0x3b, 0x67, 0xda, 0x9e,
1833 0x2d, 0x84, 0x73, 0x36, 0x00, 0x8d, 0x53, 0xbe, 0x41, 0xcf, 0x99, 0x07,
1834 0xba, 0xc9, 0x03, 0xef, 0x79, 0xcc, 0x53, 0x1e, 0x73, 0x94, 0x2f, 0xb7,
1835 0xc8, 0xc4, 0x71, 0xd5, 0x5a, 0x23, 0x92, 0xd8, 0xed, 0xb7, 0xc8, 0xf0,
1836 0x14, 0x63, 0x05, 0x1b, 0x60, 0x83, 0x6d, 0xc4, 0xd3, 0x8a, 0x6f, 0xd6,
1837 0xe3, 0x1d, 0x1f, 0x0a, 0x75, 0xeb, 0x96, 0xd8, 0x59, 0x67, 0xd1, 0xf7,
1838 0xd3, 0xc0, 0xc3, 0xa3, 0xc0, 0xc3, 0x3c, 0xef, 0xbc, 0x50, 0x15, 0x5f,
1839 0xe2, 0x58, 0xb5, 0x0e, 0xc5, 0x78, 0x63, 0x7a, 0x3e, 0x75, 0x9c, 0xa9,
1840 0x54, 0xfb, 0x66, 0xec, 0xa9, 0x38, 0xed, 0xa9, 0xdc, 0xa8, 0x67, 0xce,
1841 0x60, 0x0d, 0xc0, 0x77, 0xf2, 0xf7, 0x69, 0x5a, 0x1f, 0x1a, 0x27, 0x5c,
1842 0xd1, 0x10, 0xae, 0x05, 0x73, 0xc6, 0x33, 0xb3, 0x4b, 0xe3, 0x18, 0x2f,
1843 0xcc, 0xed, 0x11, 0x87, 0x2e, 0x97, 0xd1, 0x14, 0xe3, 0x24, 0xad, 0xcb,
1844 0xc0, 0xf4, 0x94, 0xb6, 0x61, 0x45, 0x9d, 0x96, 0x03, 0x25, 0x9e, 0xb7,
1845 0xe5, 0x1a, 0xcc, 0xef, 0x31, 0x7e, 0xd4, 0x39, 0x21, 0xc7, 0xd0, 0x37,
1846 0xd7, 0xc5, 0x95, 0x8d, 0xcf, 0xac, 0xb2, 0x7b, 0xf2, 0xaa, 0x63, 0x34,
1847 0x66, 0xdd, 0x7c, 0xe1, 0xd9, 0x93, 0xe4, 0xc0, 0xac, 0x5e, 0x77, 0xe5,
1848 0x9a, 0xa1, 0x8c, 0x46, 0xa0, 0xfd, 0x76, 0x77, 0x27, 0x7b, 0xcc, 0x59,
1849 0xc3, 0x84, 0xf4, 0x97, 0xcc, 0xf8, 0x2f, 0xea, 0x7d, 0x93, 0x66, 0x7f,
1850 0xb8, 0xd9, 0x53, 0xb9, 0x5f, 0x2e, 0xa6, 0xa2, 0x55, 0x73, 0x5b, 0x27,
1851 0xc3, 0xc0, 0x85, 0x5e, 0xcb, 0x84, 0x5d, 0x9c, 0xeb, 0x7e, 0xbc, 0x89,
1852 0x67, 0xd1, 0xa2, 0x98, 0x9f, 0xc2, 0x38, 0xcf, 0xa7, 0xb3, 0xdd, 0x2b,
1853 0xb5, 0x45, 0x31, 0xcb, 0xb3, 0x4e, 0x90, 0x95, 0x6f, 0xdd, 0x12, 0xaf,
1854 0xd7, 0xf9, 0x2b, 0xec, 0x99, 0x16, 0xd8, 0x0d, 0xbb, 0x02, 0xf9, 0x33,
1855 0xe8, 0xc9, 0xd3, 0x76, 0x4c, 0x09, 0x1d, 0x93, 0x92, 0xe0, 0x7c, 0x2a,
1856 0x6e, 0xe3, 0xce, 0x1c, 0xcb, 0x98, 0xa5, 0x6f, 0x63, 0xff, 0xcc, 0xdb,
1857 0xd0, 0x5d, 0x9a, 0xd6, 0x1f, 0xd7, 0xb2, 0xb0, 0xcb, 0xda, 0xce, 0x3a,
1858 0x8e, 0x73, 0x42, 0xf4, 0x1e, 0xac, 0xd0, 0x37, 0xea, 0xa8, 0xf2, 0x0b,
1859 0x8c, 0x2f, 0x57, 0x18, 0x5b, 0x4e, 0x46, 0xcd, 0xfb, 0x84, 0xf4, 0xe5,
1860 0xf6, 0x6c, 0xe2, 0xdd, 0x30, 0xa1, 0x2f, 0xd7, 0x65, 0x7d, 0xb9, 0x46,
1861 0xed, 0xcb, 0x99, 0xd8, 0x43, 0xe3, 0x9c, 0x2f, 0x57, 0x18, 0xcb, 0x83,
1862 0x56, 0x6a, 0xed, 0x59, 0x09, 0x63, 0x0b, 0x0d, 0x17, 0x5d, 0xbd, 0x6f,
1863 0x24, 0x37, 0xa0, 0xe0, 0x37, 0x18, 0x1f, 0x8b, 0xb1, 0x0a, 0xa5, 0xfe,
1864 0xce, 0xfa, 0x17, 0x1b, 0x24, 0xd3, 0xbc, 0x02, 0xe3, 0x7e, 0x4a, 0xcf,
1865 0xb9, 0x59, 0xc3, 0x82, 0x5c, 0x1b, 0x64, 0xcc, 0x87, 0x67, 0x47, 0x35,
1866 0x7f, 0x25, 0x7a, 0x23, 0x9d, 0xc6, 0x9e, 0xf5, 0x13, 0x6b, 0xa5, 0xfe,
1867 0xb8, 0x53, 0x18, 0x8f, 0xda, 0x7e, 0x13, 0x80, 0xa9, 0x06, 0x73, 0xf3,
1868 0x4e, 0x2b, 0x93, 0xd9, 0xf7, 0x3b, 0xea, 0x18, 0x1b, 0x98, 0x2a, 0x9a,
1869 0x18, 0x60, 0x5f, 0x31, 0x12, 0x9e, 0x5b, 0x57, 0x5c, 0x47, 0xce, 0x0c,
1870 0xae, 0x00, 0x2c, 0x2b, 0x96, 0xb5, 0x59, 0x1f, 0x7b, 0x43, 0x1d, 0x45,
1871 0x9a, 0x7a, 0x4a, 0xef, 0x2f, 0x5c, 0xd9, 0x9d, 0xdc, 0xa9, 0xcf, 0x23,
1872 0xe9, 0x58, 0x62, 0x5e, 0xb8, 0x7f, 0xf7, 0x9b, 0xf2, 0x36, 0x2d, 0xfb,
1873 0x0f, 0xa4, 0xa8, 0xc7, 0xb6, 0xe9, 0xdf, 0xb5, 0xe9, 0x20, 0x38, 0xdf,
1874 0xfd, 0x2c, 0x6c, 0x16, 0xdf, 0xfb, 0x96, 0xb4, 0xc7, 0x7b, 0xb5, 0x0d,
1875 0x85, 0xb9, 0x1a, 0xac, 0x97, 0x15, 0xfe, 0xb8, 0xdd, 0xab, 0x68, 0xd6,
1876 0x03, 0x0b, 0xc2, 0xfb, 0x17, 0x3a, 0x6c, 0x5e, 0x3e, 0xa8, 0x07, 0x3d,
1877 0x7d, 0x44, 0x8c, 0xac, 0xc9, 0xcd, 0xcb, 0x1a, 0xee, 0xa7, 0xcb, 0x90,
1878 0xa0, 0xdd, 0x23, 0x92, 0xe4, 0xdd, 0x49, 0xec, 0xbb, 0x20, 0x57, 0x41,
1879 0x3f, 0xb3, 0x1e, 0x6d, 0x56, 0x7e, 0x73, 0x0f, 0x8a, 0xef, 0x1d, 0x84,
1880 0x8e, 0xb9, 0x61, 0xa9, 0x8e, 0x89, 0xd3, 0xbf, 0xcf, 0x8d, 0xd2, 0x47,
1881 0x5c, 0x89, 0x3a, 0x2d, 0xf2, 0xd1, 0xb1, 0xdf, 0x5a, 0x4b, 0x1e, 0x1b,
1882 0x82, 0x7c, 0x57, 0xf7, 0x87, 0xe7, 0x2e, 0x99, 0xc6, 0x7c, 0xb6, 0x5b,
1883 0x27, 0x89, 0xf7, 0x79, 0xf2, 0xc5, 0x4a, 0x32, 0x31, 0x0b, 0x1d, 0x35,
1884 0xe4, 0x0c, 0xb7, 0x9a, 0xd8, 0xe9, 0xa7, 0xd6, 0x9a, 0x73, 0x5a, 0xf5,
1885 0xc0, 0x69, 0x18, 0x4f, 0xad, 0xa6, 0xdd, 0x59, 0x2b, 0x97, 0x83, 0xa0,
1886 0xbe, 0x5b, 0xcb, 0xe2, 0x9d, 0x94, 0xc5, 0x07, 0x52, 0x1d, 0x86, 0x07,
1887 0xb4, 0xef, 0xc4, 0x3d, 0x00, 0xc0, 0x43, 0xb7, 0xcb, 0xbd, 0xd0, 0x96,
1888 0x4f, 0xfd, 0xcc, 0x8c, 0x95, 0x4f, 0xca, 0x59, 0xca, 0x9f, 0x6a, 0x6b,
1889 0x74, 0x81, 0xec, 0x3d, 0x34, 0x46, 0xbd, 0x9c, 0x9a, 0xfe, 0x26, 0xe4,
1890 0x55, 0x4e, 0xe3, 0xa1, 0x45, 0xee, 0x1b, 0x93, 0xcc, 0x45, 0xe8, 0xac,
1891 0xc2, 0xd4, 0x42, 0x1e, 0x5d, 0xda, 0x1e, 0xc7, 0x7a, 0x7a, 0xad, 0xf1,
1892 0x71, 0x17, 0x8e, 0x75, 0x9a, 0x7b, 0x8c, 0xf4, 0x58, 0xb9, 0x37, 0xff,
1893 0x9c, 0x1d, 0xeb, 0xca, 0x70, 0xac, 0x3d, 0x0b, 0xc7, 0x1a, 0xfa, 0xf8,
1894 0xa1, 0xfc, 0x4d, 0xe8, 0xb3, 0x49, 0xfa, 0x4c, 0xcc, 0xd8, 0x4a, 0xe9,
1895 0x1d, 0x6d, 0xb4, 0x72, 0xd3, 0x83, 0x0e, 0xe2, 0x79, 0xa1, 0xe9, 0xcf,
1896 0x79, 0x62, 0x71, 0xa6, 0x88, 0x07, 0xca, 0xdc, 0x26, 0x7d, 0x9e, 0x71,
1897 0x02, 0x7e, 0xd6, 0x87, 0x8b, 0x2c, 0x1b, 0xe6, 0x5f, 0x29, 0x46, 0x1c,
1898 0xfa, 0xd6, 0xf4, 0x9f, 0x3a, 0x97, 0xc4, 0x16, 0x4c, 0x1c, 0x98, 0xf1,
1899 0x5f, 0x73, 0xcf, 0x02, 0xf7, 0x7d, 0xdf, 0x01, 0xde, 0xfa, 0xed, 0x62,
1900 0xb2, 0x27, 0x1b, 0xa1, 0x3c, 0x9d, 0x95, 0x43, 0x95, 0x3e, 0x69, 0xd3,
1901 0x67, 0xed, 0xdf, 0x30, 0x46, 0x9c, 0xa9, 0x8e, 0x11, 0x8b, 0x63, 0x62,
1902 0xc4, 0x3b, 0x7f, 0x8e, 0x18, 0xb1, 0x38, 0x26, 0x46, 0xbc, 0x9c, 0x9f,
1903 0x35, 0x52, 0x9a, 0xc5, 0xb8, 0xea, 0x21, 0x53, 0x94, 0x93, 0x9b, 0x6a,
1904 0xc0, 0xbb, 0x16, 0x6f, 0xc0, 0x32, 0x56, 0xc0, 0xdb, 0xc3, 0xfb, 0x20,
1905 0xde, 0x31, 0x19, 0x99, 0xd3, 0x1d, 0xb3, 0x90, 0x1f, 0xd4, 0x69, 0xac,
1906 0x6b, 0xfc, 0x82, 0xc9, 0x72, 0x33, 0xca, 0x5d, 0x72, 0x26, 0x58, 0xaf,
1907 0xd4, 0x28, 0xc3, 0x63, 0x94, 0xdd, 0x4d, 0x32, 0x3a, 0x16, 0xda, 0xb8,
1908 0x9f, 0x5d, 0xcf, 0xb5, 0x81, 0x21, 0x09, 0x6d, 0xd8, 0x67, 0xd6, 0x9b,
1909 0xb5, 0xdb, 0x2d, 0x31, 0xa9, 0x5f, 0x8d, 0x39, 0x38, 0xee, 0x5c, 0x1c,
1910 0x5f, 0xbd, 0xc0, 0x96, 0x4d, 0xd8, 0xd8, 0xe0, 0xb8, 0xd5, 0xc1, 0xcb,
1911 0xcb, 0x88, 0xea, 0xf9, 0x8f, 0xdb, 0x73, 0xbc, 0x51, 0x7b, 0xd7, 0x5f,
1912 0x42, 0xcf, 0xcf, 0x40, 0x65, 0x16, 0xfd, 0xad, 0x57, 0x99, 0x71, 0x8e,
1913 0x73, 0xee, 0x7e, 0x1e, 0xc8, 0xc5, 0x56, 0x35, 0x34, 0xbe, 0x80, 0x2e,
1914 0x41, 0xb7, 0x1c, 0x9b, 0x03, 0xda, 0xbd, 0x57, 0x26, 0x46, 0x09, 0x5f,
1915 0x47, 0x3c, 0xa2, 0xcf, 0xf5, 0xe2, 0x7b, 0xdc, 0x9c, 0x27, 0xea, 0xad,
1916 0x84, 0x67, 0x7a, 0xd7, 0x00, 0xde, 0xc5, 0xe7, 0x7a, 0xad, 0x9e, 0xd6,
1917 0x36, 0x04, 0xcf, 0xf7, 0x86, 0x63, 0x58, 0x8e, 0x9e, 0x02, 0x19, 0xd6,
1918 0xfb, 0x7d, 0xd7, 0xca, 0xe9, 0x07, 0xe7, 0xce, 0x17, 0x34, 0xc1, 0x56,
1919 0x69, 0x85, 0xa9, 0x3c, 0xe0, 0xa6, 0xb9, 0xef, 0x82, 0xfb, 0x0b, 0x3a,
1920 0xe2, 0xb7, 0xe9, 0x73, 0x1f, 0xf3, 0x67, 0xac, 0xe7, 0xcf, 0x7e, 0x84,
1921 0x67, 0x5a, 0xe3, 0xd2, 0x07, 0x3a, 0xec, 0xd7, 0xe9, 0x31, 0x8c, 0x87,
1922 0x6b, 0xbe, 0x1a, 0x0f, 0x90, 0x3d, 0x5c, 0xfb, 0xc5, 0xd8, 0x2b, 0x2d,
1923 0x2a, 0xa7, 0xcf, 0x58, 0x47, 0x2d, 0x8d, 0x5d, 0x76, 0xf6, 0x94, 0x13,
1924 0x6a, 0x4f, 0xd9, 0x57, 0x7b, 0xcb, 0x36, 0xaf, 0xfb, 0x01, 0xcc, 0x07,
1925 0x7e, 0x8f, 0x17, 0x9d, 0x21, 0xe0, 0xab, 0x50, 0x3a, 0xe2, 0x64, 0xf4,
1926 0xfb, 0xa8, 0x7d, 0x43, 0x0e, 0x60, 0xae, 0x7a, 0xc7, 0xa3, 0x5a, 0xde,
1927 0xcf, 0xdf, 0xd3, 0x17, 0xce, 0xeb, 0x0b, 0x7a, 0x0d, 0x68, 0x5a, 0x88,
1928 0x6b, 0xcf, 0xda, 0x10, 0xc7, 0x9d, 0x9c, 0xc6, 0x3d, 0xcb, 0x7c, 0x4b,
1929 0xff, 0x06, 0x9d, 0x2b, 0xd3, 0x5e, 0x2b, 0xde, 0x8b, 0xf7, 0x4d, 0x86,
1930 0xfa, 0x86, 0x70, 0xdf, 0x09, 0xbd, 0x16, 0xec, 0x37, 0xf2, 0x6a, 0x56,
1931 0x46, 0x2a, 0x5c, 0xc3, 0x64, 0x3b, 0x48, 0x2f, 0xd7, 0xc0, 0x1e, 0x58,
1932 0x78, 0xbe, 0xba, 0x7f, 0x7e, 0x1e, 0x12, 0xe3, 0x42, 0x58, 0xee, 0xd6,
1933 0x67, 0x17, 0xab, 0xef, 0x1e, 0xb9, 0xf2, 0xbf, 0x70, 0xfd, 0xd0, 0xc8,
1934 0x50, 0x0b, 0x47, 0x86, 0xf2, 0xce, 0xc8, 0x95, 0xaf, 0xcb, 0x41, 0xe0,
1935 0xf1, 0x30, 0x60, 0x52, 0xf7, 0xf3, 0xce, 0xab, 0x57, 0xa5, 0x30, 0x59,
1936 0x2f, 0xea, 0xa1, 0x82, 0xe3, 0x3e, 0x54, 0x2b, 0x91, 0x87, 0x94, 0x53,
1937 0xf3, 0x50, 0xbb, 0xf6, 0xcf, 0x77, 0xa4, 0xda, 0xe3, 0x7b, 0xe5, 0xb8,
1938 0xe3, 0xde, 0xaf, 0xf4, 0x59, 0xdb, 0x82, 0xc7, 0x58, 0xdf, 0x71, 0x27,
1939 0x72, 0x7f, 0xd4, 0x9e, 0xd3, 0x37, 0xf1, 0xbd, 0x59, 0xcd, 0xf7, 0xdf,
1940 0x58, 0x47, 0x9c, 0xcd, 0x0a, 0xf1, 0xf1, 0x59, 0xc8, 0xad, 0x4f, 0x4b,
1941 0x76, 0x34, 0x31, 0x57, 0xc6, 0xec, 0xb3, 0xdf, 0xb0, 0xce, 0xf0, 0x0b,
1942 0xcb, 0xbc, 0xe2, 0xf0, 0xce, 0x1c, 0xa3, 0x33, 0x3e, 0xdf, 0x12, 0xee,
1943 0xb9, 0x37, 0x73, 0xca, 0xfc, 0xc6, 0x75, 0x52, 0xff, 0x0a, 0xe6, 0x8b,
1944 0xfd, 0x11, 0x57, 0xab, 0xf4, 0x3d, 0x05, 0x9e, 0x6c, 0x89, 0xd7, 0xcd,
1945 0xd9, 0x43, 0x46, 0xf6, 0xd6, 0x01, 0x6e, 0xc0, 0x6f, 0xec, 0x3b, 0x21,
1946 0x9d, 0x0a, 0x24, 0x37, 0x69, 0xb6, 0xa3, 0x67, 0x87, 0x98, 0x39, 0x33,
1947 0x34, 0xb3, 0xc2, 0xd8, 0x91, 0xf8, 0x36, 0x74, 0xa1, 0x64, 0xfb, 0xd8,
1948 0x4b, 0x4e, 0x3f, 0xcf, 0x3c, 0x8a, 0xb6, 0x1b, 0x97, 0xb3, 0x09, 0xc1,
1949 0x4b, 0xcf, 0x5b, 0xff, 0x32, 0x08, 0xc6, 0x52, 0x29, 0xde, 0x2b, 0xb8,
1950 0x8c, 0x4f, 0xb9, 0xca, 0x99, 0x1c, 0x6d, 0x70, 0x26, 0x46, 0x03, 0xd9,
1951 0x93, 0xe2, 0x9d, 0x49, 0xdc, 0x93, 0xa0, 0xe3, 0xe3, 0x48, 0x6b, 0x87,
1952 0x6e, 0x7d, 0xc7, 0x3a, 0xee, 0x71, 0xbb, 0xd9, 0x6f, 0xb4, 0xe5, 0x88,
1953 0x63, 0xfa, 0xca, 0xed, 0x27, 0x72, 0xc2, 0xbb, 0x8b, 0xb6, 0xc4, 0x63,
1954 0x7a, 0x7f, 0xe2, 0x17, 0x50, 0x0f, 0x7d, 0x94, 0xd8, 0xaf, 0xeb, 0x4c,
1955 0x40, 0x9e, 0x4d, 0x8e, 0xf1, 0xbe, 0x14, 0x9e, 0x63, 0x88, 0xb4, 0x2a,
1956 0xb9, 0xd6, 0x1b, 0xb6, 0xf7, 0x69, 0xe6, 0xe1, 0x0a, 0x45, 0x74, 0xda,
1957 0x16, 0x6f, 0xf7, 0xdc, 0x1d, 0x9b, 0x61, 0x5a, 0x78, 0xd7, 0xa6, 0xd2,
1958 0x67, 0x56, 0xe0, 0xd3, 0x9e, 0x1e, 0x92, 0xb8, 0x33, 0x55, 0x6c, 0x75,
1959 0x4e, 0x16, 0x33, 0x5b, 0xd7, 0x81, 0x3e, 0xce, 0xa7, 0x3e, 0x46, 0xf9,
1960 0x05, 0xdb, 0xef, 0x45, 0xc9, 0x57, 0x3e, 0x24, 0xe3, 0x2d, 0xed, 0xde,
1961 0xfd, 0x7a, 0x6e, 0x2e, 0x03, 0x67, 0x2d, 0x2a, 0x3b, 0xfa, 0xc4, 0x3a,
1962 0xea, 0xb7, 0xdd, 0x45, 0x05, 0x5e, 0x56, 0xbf, 0x88, 0x07, 0x36, 0x6e,
1963 0xad, 0xb6, 0x51, 0xf6, 0xa6, 0x58, 0xae, 0xc1, 0xe9, 0x1d, 0x5d, 0x85,
1964 0x79, 0xdc, 0x05, 0xfd, 0xe9, 0xc0, 0x46, 0x22, 0xae, 0x1b, 0x9c, 0x3d,
1965 0xa3, 0x79, 0xf4, 0xc8, 0x7d, 0xd6, 0xbc, 0xf7, 0xf0, 0x30, 0xc6, 0xa8,
1966 0xe5, 0x2b, 0x78, 0xf7, 0x12, 0xd7, 0xdb, 0x83, 0x49, 0xd8, 0x06, 0xb9,
1967 0xae, 0x7f, 0x67, 0xd7, 0xab, 0xa7, 0xaf, 0xb0, 0x5e, 0xed, 0xc9, 0x23,
1968 0x15, 0x7d, 0x6f, 0x48, 0xe7, 0xb8, 0xe2, 0x3a, 0x6e, 0xf3, 0x55, 0x7a,
1969 0x7e, 0x54, 0x87, 0xdd, 0x1b, 0x78, 0x72, 0x9d, 0xbd, 0xd3, 0x06, 0x70,
1970 0x5c, 0x05, 0x18, 0x36, 0x62, 0xfc, 0x84, 0xc1, 0xd4, 0x11, 0x75, 0x4b,
1971 0x9c, 0x3a, 0x70, 0x56, 0x4e, 0xaf, 0x0b, 0xf7, 0x7b, 0xa0, 0x1d, 0xc8,
1972 0xb5, 0x47, 0xe3, 0x46, 0x37, 0xae, 0x5d, 0xa6, 0x9d, 0x70, 0x3c, 0x8e,
1973 0x1d, 0x0f, 0x69, 0x75, 0x43, 0x0b, 0xfd, 0x89, 0x59, 0xa9, 0x5b, 0x54,
1974 0x9e, 0xf1, 0xfc, 0x5d, 0xad, 0x66, 0xdf, 0x11, 0xcb, 0x7a, 0xb0, 0x4b,
1975 0x69, 0xe3, 0x12, 0x77, 0x7a, 0xae, 0x8a, 0xdc, 0x5b, 0x9c, 0xf3, 0x2f,
1976 0x43, 0x9e, 0x5c, 0xeb, 0xbd, 0x4d, 0x91, 0xf6, 0x42, 0xfc, 0x12, 0xb7,
1977 0x09, 0xe0, 0x95, 0x71, 0x95, 0xd3, 0x41, 0x66, 0x80, 0x7c, 0xc5, 0x36,
1978 0x98, 0xff, 0xa2, 0x8e, 0xe5, 0x0e, 0xa6, 0x18, 0x27, 0x6a, 0x3f, 0x71,
1979 0x87, 0x0a, 0x65, 0xd3, 0x2c, 0xd7, 0x10, 0x1c, 0xde, 0x21, 0xba, 0x0b,
1980 0x1d, 0x5e, 0x9c, 0x52, 0xce, 0x37, 0xc7, 0x5c, 0x7c, 0xd7, 0xd8, 0xfb,
1981 0x42, 0x8d, 0x6e, 0x12, 0xf9, 0xeb, 0x70, 0xbc, 0xf1, 0x3c, 0xe6, 0xfb,
1982 0x12, 0xe6, 0x7b, 0xf9, 0xfb, 0x41, 0x91, 0x57, 0x46, 0x5e, 0xf9, 0x43,
1983 0x41, 0xa6, 0x89, 0xf4, 0x47, 0x9a, 0x7b, 0x3d, 0x9f, 0x59, 0xef, 0x63,
1984 0x02, 0x6c, 0x67, 0xc1, 0x0b, 0x19, 0xae, 0x25, 0x07, 0xc7, 0x52, 0x37,
1985 0x81, 0x17, 0x76, 0xca, 0x9f, 0xc0, 0x16, 0xf8, 0xe3, 0x4a, 0x1a, 0x3c,
1986 0xd1, 0x03, 0x1e, 0xe9, 0x06, 0x5f, 0xa4, 0xb4, 0x5d, 0xfc, 0x28, 0x74,
1987 0xde, 0xd9, 0x4a, 0xc9, 0xd9, 0x3b, 0x5a, 0x74, 0x72, 0xa3, 0x47, 0x41,
1988 0x17, 0xdc, 0x03, 0xab, 0xae, 0xa9, 0x11, 0x37, 0x3e, 0x29, 0xa4, 0xff,
1989 0x76, 0xee, 0xed, 0x68, 0x06, 0xae, 0xce, 0x10, 0x57, 0x93, 0x95, 0x2d,
1990 0xde, 0x3a, 0xf0, 0x41, 0xb3, 0xe6, 0x83, 0x46, 0x27, 0xe3, 0xdd, 0x64,
1991 0xf9, 0x60, 0x04, 0x7c, 0x50, 0x58, 0xc2, 0x07, 0xcf, 0x58, 0x9a, 0x9f,
1992 0xae, 0xe2, 0x83, 0x49, 0x9b, 0x36, 0x7e, 0x05, 0x3e, 0xb8, 0xca, 0x4f,
1993 0x3e, 0x39, 0x24, 0x27, 0xc0, 0x07, 0x0f, 0x6b, 0x3e, 0xb8, 0x4a, 0xf3,
1994 0x01, 0xe3, 0x46, 0xe4, 0x85, 0x56, 0xc8, 0x0e, 0xf2, 0xc2, 0xb3, 0x32,
1995 0x0b, 0x5e, 0x78, 0x51, 0xb1, 0xef, 0xcb, 0xb4, 0x0f, 0x46, 0xe9, 0x8f,
1996 0x9d, 0x2a, 0x15, 0xc1, 0xbb, 0x4a, 0xbe, 0x30, 0x16, 0x04, 0x33, 0xf0,
1997 0xd1, 0x1f, 0x84, 0x0d, 0xef, 0xea, 0x3b, 0x69, 0xa7, 0x61, 0xbb, 0x10,
1998 0x36, 0xda, 0xe4, 0xe3, 0x0e, 0xe8, 0xfd, 0xf0, 0x04, 0xc6, 0xb0, 0x47,
1999 0xfd, 0x3e, 0xfc, 0x60, 0x0f, 0xf3, 0x4a, 0xdb, 0xfe, 0xb8, 0xe6, 0x9b,
2000 0x1a, 0xe8, 0x80, 0x93, 0xdd, 0x8c, 0x33, 0xf9, 0xde, 0x5e, 0xd5, 0x9e,
2001 0xef, 0x03, 0xcc, 0x11, 0x75, 0xbf, 0x30, 0xc6, 0xd1, 0xb4, 0xc8, 0xb6,
2002 0xa7, 0x5c, 0x18, 0x90, 0xfb, 0x6c, 0x5e, 0x3e, 0xa8, 0x83, 0x1d, 0x5a,
2003 0xa7, 0x8c, 0x5d, 0xae, 0xb6, 0x25, 0xbd, 0xdf, 0x80, 0xd0, 0xac, 0x4d,
2004 0x9b, 0x3d, 0x81, 0x7d, 0xc5, 0x6a, 0xbb, 0xfe, 0x5e, 0xd8, 0xf5, 0xac,
2005 0x23, 0xae, 0xb1, 0xeb, 0xef, 0xb2, 0xbc, 0xc6, 0xdf, 0x9e, 0xb6, 0xf1,
2006 0x0f, 0x00, 0xbe, 0x1d, 0x73, 0x36, 0x3e, 0xdb, 0xa0, 0xad, 0x21, 0x72,
2007 0x03, 0xec, 0xbc, 0x1b, 0xc1, 0x83, 0x37, 0xc1, 0x8f, 0x7a, 0x77, 0xd1,
2008 0x93, 0x9d, 0xc5, 0x66, 0xf8, 0xdb, 0xad, 0xf2, 0xab, 0x63, 0x1b, 0xa5,
2009 0x7f, 0xf4, 0x77, 0x9a, 0xa1, 0x57, 0x61, 0x97, 0xbe, 0x08, 0x38, 0x23,
2010 0x56, 0x56, 0x47, 0xc1, 0x03, 0xed, 0x89, 0x1f, 0xa8, 0x44, 0xab, 0x91,
2011 0xed, 0x3c, 0x4b, 0xbe, 0x5c, 0x3b, 0x31, 0xd4, 0x67, 0x1c, 0xa5, 0x45,
2012 0xce, 0x1c, 0xa7, 0xe7, 0x95, 0x80, 0x2d, 0x9e, 0x82, 0x1d, 0xb2, 0x01,
2013 0xed, 0x31, 0x96, 0xbc, 0x5a, 0x9e, 0xd9, 0xea, 0xde, 0x9d, 0xd3, 0x7c,
2014 0x78, 0xc9, 0xc9, 0x8e, 0xdd, 0x24, 0x85, 0xc1, 0x28, 0xc6, 0xa0, 0x9a,
2015 0xd7, 0xca, 0xf5, 0xd2, 0xaf, 0xc7, 0x73, 0x59, 0x0e, 0x42, 0x1f, 0xff,
2016 0x69, 0xb1, 0x5f, 0x66, 0x07, 0x9a, 0xf0, 0x1d, 0x95, 0x67, 0x8a, 0x5b,
2017 0xe0, 0xef, 0xfc, 0x0a, 0x70, 0x54, 0x8b, 0xef, 0x5a, 0xe9, 0x5d, 0x47,
2018 0x5e, 0x6d, 0x90, 0x19, 0xa4, 0xdf, 0x28, 0xbf, 0x64, 0xd3, 0x99, 0x46,
2019 0xde, 0x68, 0x40, 0xdd, 0xa8, 0x9c, 0x2f, 0xd2, 0x96, 0xd4, 0x3c, 0xd1,
2020 0xf3, 0xb2, 0x6c, 0xc9, 0xbc, 0x0c, 0xdb, 0xf4, 0x59, 0x3c, 0xcf, 0x4b,
2021 0x72, 0xe7, 0x6e, 0x67, 0x4b, 0xa2, 0xdd, 0x81, 0xbe, 0xc4, 0xe3, 0x3a,
2022 0x5b, 0xbc, 0x5a, 0xe7, 0x5a, 0xdb, 0x46, 0x8d, 0x3c, 0x3f, 0xa8, 0xe2,
2023 0x0d, 0x98, 0x93, 0xcd, 0x4e, 0x87, 0x4d, 0xe3, 0xb7, 0xbe, 0x2f, 0x51,
2024 0xda, 0xcf, 0xa8, 0x0d, 0xab, 0x44, 0xda, 0x1a, 0x60, 0xe7, 0xec, 0x11,
2025 0xd5, 0xdc, 0x20, 0xae, 0xb4, 0x4f, 0xa8, 0x56, 0xa4, 0xf9, 0x36, 0x2d,
2026 0xd6, 0x00, 0x9d, 0x80, 0xb4, 0x16, 0xa4, 0x6d, 0xb2, 0x69, 0x4d, 0x0d,
2027 0x52, 0x8b, 0xb4, 0xcb, 0x9a, 0xe7, 0x2f, 0x76, 0xf8, 0x5e, 0xce, 0xa9,
2028 0x97, 0xb6, 0x53, 0x0d, 0x90, 0x0d, 0xab, 0x65, 0x66, 0x6b, 0x9d, 0xb4,
2029 0x21, 0x8f, 0x31, 0xee, 0xd4, 0xa9, 0xa8, 0xbc, 0xf3, 0x54, 0x7b, 0xfc,
2030 0xa3, 0x18, 0x43, 0xfb, 0x19, 0xc6, 0xbc, 0xff, 0xac, 0x99, 0x31, 0x9f,
2031 0xb6, 0x33, 0x7c, 0xd7, 0x69, 0xf9, 0x43, 0x7c, 0x98, 0x3b, 0xdf, 0x60,
2032 0x63, 0x94, 0x8e, 0x3b, 0xc3, 0xa3, 0xd4, 0xdb, 0xed, 0xf6, 0x7e, 0xa2,
2033 0xff, 0xd9, 0x4c, 0x5f, 0x6d, 0x82, 0x36, 0x54, 0x89, 0xfc, 0x48, 0xdd,
2034 0x83, 0xf7, 0xb8, 0x23, 0x85, 0x79, 0x99, 0x35, 0x45, 0xbe, 0x3a, 0xae,
2035 0xb8, 0x4f, 0x05, 0x69, 0x95, 0x77, 0x05, 0x66, 0x8e, 0xc9, 0x0b, 0x46,
2036 0x2e, 0xfd, 0x9a, 0x91, 0x4b, 0xa7, 0xcf, 0x2d, 0x90, 0x4b, 0x05, 0x2d,
2037 0x97, 0x06, 0x05, 0xef, 0xa9, 0x02, 0xe4, 0xd2, 0x08, 0xbe, 0x3d, 0x2d,
2038 0x97, 0x62, 0x62, 0x6d, 0x64, 0x89, 0x5e, 0xc5, 0xfe, 0x27, 0x4b, 0xae,
2039 0xb6, 0xa5, 0x0a, 0xe3, 0xb0, 0x43, 0x4a, 0x23, 0x56, 0x67, 0x4b, 0xba,
2040 0x49, 0x3a, 0x7a, 0x7e, 0x2a, 0xa1, 0x9d, 0x39, 0xdb, 0xcc, 0x3b, 0x8f,
2041 0x5f, 0x54, 0x94, 0x61, 0x27, 0x20, 0xc3, 0x1e, 0xbe, 0x82, 0x0c, 0x43,
2042 0x5e, 0x19, 0x79, 0x65, 0xb6, 0xfb, 0xdd, 0x9f, 0x0e, 0x79, 0x94, 0x1f,
2043 0x94, 0x19, 0x90, 0x49, 0x25, 0xc8, 0xa4, 0x12, 0xe4, 0x54, 0x09, 0x72,
2044 0xa9, 0x04, 0xb9, 0x54, 0x82, 0x5c, 0x2a, 0x41, 0x2e, 0x41, 0xc6, 0x3d,
2045 0x0a, 0x19, 0x67, 0x64, 0xda, 0x00, 0xed, 0x35, 0xb9, 0xcf, 0xea, 0x77,
2046 0x13, 0x27, 0xe9, 0xb2, 0x7e, 0x91, 0xd9, 0xb3, 0x7a, 0xae, 0x2a, 0x2e,
2047 0xb8, 0xeb, 0x88, 0xe6, 0x77, 0xcf, 0x57, 0xd7, 0x3a, 0xdc, 0x1f, 0xf3,
2048 0x03, 0xed, 0xb3, 0x6f, 0xe6, 0x6f, 0xa9, 0x03, 0x5f, 0xbf, 0x62, 0xf9,
2049 0x7a, 0xf3, 0x1c, 0x5f, 0x27, 0x1d, 0xc6, 0x89, 0x97, 0xe7, 0xeb, 0x16,
2050 0x9b, 0x97, 0x0f, 0x56, 0x80, 0xaf, 0x57, 0x2c, 0xe2, 0xeb, 0x28, 0xf8,
2051 0x7a, 0xe7, 0x12, 0xbe, 0x5e, 0xe5, 0xf4, 0xea, 0x3a, 0x3c, 0x83, 0xc6,
2052 0xef, 0x5a, 0x67, 0x9e, 0xaf, 0xf7, 0x6b, 0xbe, 0x3e, 0x04, 0xbe, 0xbe,
2053 0xbe, 0x8a, 0xaf, 0x77, 0x4a, 0xf2, 0x96, 0x6c, 0x64, 0xa3, 0xec, 0xbe,
2054 0x5f, 0x35, 0xaf, 0x91, 0x7f, 0x11, 0x53, 0xdf, 0xf0, 0x58, 0xef, 0x58,
2055 0xb3, 0xe4, 0x1e, 0xfa, 0x11, 0xd7, 0x06, 0xc8, 0x23, 0x43, 0x19, 0xc7,
2056 0x93, 0x83, 0x47, 0x7e, 0x20, 0xd3, 0x9a, 0xb7, 0x44, 0xf6, 0x1c, 0x89,
2057 0xca, 0xf0, 0x11, 0xc6, 0x1e, 0xbe, 0x63, 0xe9, 0xbd, 0x4e, 0x86, 0x07,
2058 0xb9, 0x5f, 0xd2, 0x95, 0xdd, 0x47, 0xe0, 0x63, 0x1d, 0x61, 0xec, 0xe1,
2059 0xf2, 0x1c, 0x8f, 0x4d, 0x43, 0xb6, 0xec, 0x3e, 0xa2, 0xe7, 0x1a, 0xed,
2060 0x34, 0xc8, 0xa1, 0x23, 0x22, 0xb7, 0x1d, 0x71, 0xe5, 0xf6, 0x23, 0x73,
2061 0xbc, 0x36, 0x10, 0xf2, 0xda, 0x9f, 0x83, 0xd7, 0xda, 0x2d, 0xaf, 0xa9,
2062 0x39, 0x5e, 0xfb, 0x5a, 0x15, 0xaf, 0xb1, 0x3e, 0x79, 0xed, 0x82, 0x4d,
2063 0xe3, 0xb7, 0x2b, 0x7b, 0x8f, 0xb4, 0xca, 0xee, 0x87, 0xde, 0x22, 0x7b,
2064 0xee, 0x27, 0xac, 0xe6, 0x9e, 0x3c, 0xda, 0x5f, 0xe3, 0x95, 0x76, 0xb4,
2065 0x1f, 0xee, 0x0f, 0xd2, 0x77, 0x65, 0x75, 0x4e, 0x48, 0x32, 0xcf, 0xfe,
2066 0x6a, 0xe1, 0x3b, 0x9f, 0x82, 0x4f, 0xb1, 0x17, 0x30, 0xdd, 0x7a, 0x44,
2067 0x92, 0xae, 0xbc, 0x26, 0x23, 0xa9, 0x47, 0x5b, 0x8d, 0x3d, 0x71, 0x09,
2068 0xbc, 0x42, 0xfa, 0xcf, 0x48, 0xee, 0xed, 0x81, 0xf6, 0x2b, 0x46, 0xcb,
2069 0x42, 0xff, 0x9f, 0x31, 0x73, 0xc7, 0xdc, 0x77, 0xc7, 0xf3, 0xbe, 0x35,
2070 0xfa, 0xbc, 0x9b, 0x8e, 0xd7, 0x76, 0x33, 0xbf, 0x46, 0xef, 0x37, 0xcd,
2071 0xe9, 0xb3, 0xdc, 0xac, 0xcf, 0x76, 0x62, 0x3a, 0x9e, 0x5e, 0x28, 0xf3,
2072 0x8e, 0x30, 0xde, 0xbd, 0xcc, 0xbb, 0x06, 0xff, 0xf8, 0x2a, 0x13, 0x9b,
2073 0x25, 0xdf, 0x7d, 0xdd, 0xc9, 0x15, 0x2f, 0xe9, 0x7d, 0x85, 0x59, 0x1f,
2074 0xbf, 0xcb, 0xfc, 0x66, 0xf9, 0x4b, 0x8c, 0x71, 0x24, 0x12, 0xea, 0x81,
2075 0x56, 0xee, 0x3b, 0x18, 0x9c, 0x32, 0x76, 0x94, 0xe1, 0xd1, 0x06, 0xed,
2076 0x6b, 0x8c, 0xe0, 0x7b, 0xf7, 0x68, 0xa3, 0x53, 0xa0, 0x6d, 0x32, 0xd0,
2077 0xe0, 0xe4, 0xc7, 0xf7, 0xb4, 0x1a, 0x9b, 0x79, 0x20, 0xce, 0x3d, 0x85,
2078 0x19, 0xb5, 0x54, 0x26, 0x9f, 0x92, 0x50, 0x26, 0x27, 0x6f, 0xc9, 0xc0,
2079 0xb6, 0xce, 0x1d, 0xd1, 0xf7, 0xf7, 0x25, 0xda, 0x15, 0xc7, 0xf4, 0x09,
2080 0xc8, 0xd7, 0x90, 0x16, 0xe2, 0xf2, 0xf1, 0x23, 0xa4, 0x07, 0x15, 0x6b,
2081 0x94, 0xdf, 0xb2, 0xf4, 0x70, 0x59, 0x8a, 0x90, 0x3b, 0x47, 0x8e, 0xdc,
2082 0x2e, 0xe3, 0xbb, 0x16, 0xd3, 0xc3, 0x9e, 0x79, 0x7a, 0x88, 0xc1, 0x3e,
2083 0x73, 0xaa, 0xe9, 0xe1, 0x37, 0xe7, 0xe8, 0x61, 0xdc, 0xf9, 0xd7, 0xd2,
2084 0xc3, 0x0d, 0x0b, 0xe8, 0x61, 0x44, 0xd3, 0x43, 0xff, 0x1c, 0x3d, 0x8c,
2085 0x1c, 0x61, 0xbf, 0x7a, 0x5d, 0xd4, 0x9b, 0x71, 0x38, 0xe7, 0x73, 0xb4,
2086 0x90, 0x18, 0xd6, 0xfb, 0x44, 0x93, 0x79, 0x9e, 0x25, 0x5d, 0xa5, 0x18,
2087 0x1b, 0x99, 0x9f, 0xff, 0xc6, 0x7f, 0xd3, 0xf9, 0x7f, 0x47, 0xfc, 0xff,
2088 0xef, 0xfc, 0x5f, 0x8f, 0xf6, 0x29, 0x8b, 0x43, 0x79, 0x1c, 0xd2, 0xc3,
2089 0x7b, 0xe2, 0x46, 0x2f, 0x70, 0x8e, 0xf9, 0x6d, 0xf6, 0xac, 0x9f, 0x83,
2090 0xfc, 0x7b, 0x1c, 0xf2, 0xef, 0xb1, 0x05, 0xeb, 0x01, 0x3d, 0x36, 0x06,
2091 0x11, 0xc8, 0xc1, 0xd4, 0x3c, 0x3e, 0x66, 0xba, 0x89, 0x0f, 0xb3, 0xf7,
2092 0xe4, 0x6c, 0x65, 0x31, 0x4e, 0x5c, 0xbd, 0xdf, 0xe8, 0x64, 0xaa, 0x1a,
2093 0x27, 0x84, 0x7b, 0xb6, 0x6a, 0x8c, 0xf8, 0x5d, 0xe6, 0xf7, 0x65, 0xbd,
2094 0x87, 0xa4, 0xa0, 0xd7, 0x9f, 0x88, 0x17, 0xae, 0x3f, 0x11, 0x27, 0xae,
2095 0xb6, 0xf7, 0x0b, 0xe5, 0x3a, 0xbd, 0x2f, 0xfc, 0xc0, 0x54, 0x4c, 0x66,
2096 0x62, 0x8c, 0xeb, 0xf1, 0xde, 0x57, 0xfa, 0xca, 0x7e, 0xbc, 0x20, 0x79,
2097 0x7b, 0xd6, 0x67, 0x95, 0xa5, 0x6d, 0xc6, 0x03, 0x79, 0x27, 0x42, 0xb8,
2098 0x0e, 0xd1, 0x69, 0x65, 0x5d, 0x43, 0x55, 0x9c, 0x12, 0x78, 0x1f, 0x93,
2099 0x44, 0xb6, 0x1b, 0xef, 0x29, 0xf6, 0xfd, 0xa4, 0x8c, 0x3c, 0x58, 0x86,
2100 0x2d, 0xf7, 0x30, 0x74, 0x8e, 0x23, 0x10, 0x93, 0xfa, 0x2e, 0x14, 0xc2,
2101 0x30, 0xa1, 0xef, 0xf5, 0xa3, 0xdf, 0x47, 0x7a, 0x88, 0xe3, 0xfb, 0xb2,
2102 0x8d, 0x25, 0xc5, 0xa5, 0x50, 0xfc, 0x01, 0xe0, 0xe7, 0x1d, 0x94, 0x3f,
2103 0xc2, 0xfb, 0x8d, 0xe6, 0xc3, 0xf8, 0x21, 0x03, 0xfa, 0xcd, 0xb9, 0x79,
2104 0xcd, 0xc9, 0x94, 0xcd, 0xfe, 0x96, 0xaa, 0xfb, 0xf5, 0xe5, 0xb0, 0xb6,
2105 0x9f, 0xd3, 0x76, 0x5f, 0x0b, 0xcf, 0xe7, 0x19, 0x1b, 0xfa, 0xcb, 0xb0,
2106 0xa1, 0x9f, 0xa8, 0x64, 0xf4, 0x1a, 0xd6, 0x63, 0xb0, 0xa1, 0x1f, 0x85,
2107 0xee, 0xa1, 0xce, 0x89, 0x59, 0x9d, 0x33, 0xa2, 0x76, 0x69, 0x9d, 0xf3,
2108 0xd7, 0x5a, 0xe7, 0xfc, 0xea, 0x12, 0x9d, 0x73, 0x48, 0xb5, 0x8f, 0x52,
2109 0xe7, 0xf4, 0xaa, 0x9d, 0x0e, 0xed, 0xc5, 0xb5, 0xcb, 0xe8, 0x9c, 0xf7,
2110 0xca, 0xaf, 0xd8, 0xbc, 0xfd, 0xf2, 0xbe, 0x6d, 0x7a, 0xdd, 0xc6, 0x9b,
2111 0x50, 0xbc, 0xcb, 0xce, 0xe8, 0xa0, 0xeb, 0x55, 0xa7, 0x5e, 0xef, 0xfd,
2112 0x6a, 0x95, 0xce, 0x69, 0x53, 0xdd, 0x4e, 0xaf, 0xae, 0xc3, 0x78, 0x04,
2113 0xbf, 0x53, 0x4e, 0x66, 0xa0, 0x0e, 0xdf, 0x71, 0x89, 0x1c, 0xc1, 0xd8,
2114 0xcd, 0x7d, 0x7b, 0xca, 0xe4, 0x5d, 0x63, 0xf3, 0x54, 0x98, 0xee, 0x9a,
2115 0xf4, 0x76, 0x9b, 0x6e, 0x74, 0x55, 0x9b, 0x6a, 0xd5, 0xba, 0x6a, 0x33,
2116 0x18, 0x6a, 0x02, 0xfa, 0x75, 0xa2, 0x14, 0xea, 0x2c, 0xfe, 0x66, 0xbc,
2117 0x99, 0x71, 0x89, 0x30, 0x6e, 0x9d, 0x40, 0x19, 0x3c, 0xa5, 0xd0, 0xa6,
2118 0xe4, 0x6f, 0xf8, 0x0a, 0x78, 0xa6, 0x80, 0xd7, 0x5b, 0xc0, 0x3f, 0xbf,
2119 0x5e, 0x64, 0xdc, 0xb3, 0x59, 0x8e, 0x8e, 0x55, 0xe7, 0xb5, 0xca, 0xbb,
2120 0xc7, 0x36, 0xc8, 0xbe, 0x51, 0xff, 0x6a, 0xa9, 0xdf, 0x28, 0x23, 0xa3,
2121 0x2f, 0xea, 0xfb, 0x40, 0xd6, 0xe8, 0x7b, 0x92, 0x78, 0x7f, 0x98, 0x91,
2122 0x91, 0xfd, 0x8e, 0x91, 0x91, 0x19, 0x35, 0x6f, 0xb3, 0x86, 0x6d, 0xf2,
2123 0x6e, 0xa6, 0xbe, 0xd1, 0xb8, 0xbe, 0x43, 0x7a, 0xa2, 0x72, 0xad, 0xfc,
2124 0xd1, 0x71, 0x75, 0xa7, 0x9a, 0xbf, 0x4b, 0x41, 0xdb, 0xac, 0x93, 0x0b,
2125 0x6c, 0xd6, 0xbf, 0x97, 0x99, 0xf7, 0x45, 0x31, 0x4e, 0xd0, 0xf0, 0x75,
2126 0x2f, 0x73, 0x1d, 0xb4, 0x39, 0x26, 0x97, 0xa4, 0x4f, 0xe3, 0x8f, 0xf2,
2127 0xb4, 0x01, 0x72, 0x70, 0x56, 0xeb, 0xd7, 0xb5, 0xbc, 0xf3, 0xf8, 0x08,
2128 0x6d, 0xd7, 0xaf, 0x6b, 0x79, 0xb6, 0xd6, 0xda, 0xae, 0xd3, 0x90, 0xd3,
2129 0x94, 0xa3, 0x37, 0xca, 0x5f, 0xdb, 0x74, 0xa6, 0x25, 0xe3, 0xb3, 0x42,
2130 0x7d, 0x17, 0x83, 0x0c, 0xa5, 0x3c, 0xfd, 0x59, 0x6d, 0xd7, 0xe7, 0x6c,
2131 0x1b, 0x94, 0x9f, 0x46, 0x76, 0x6f, 0x76, 0xa6, 0x6d, 0x1a, 0xbf, 0xc3,
2132 0x18, 0xba, 0x9f, 0xc9, 0x59, 0x3e, 0x53, 0xce, 0x93, 0xc8, 0x5f, 0x83,
2133 0x7c, 0xf2, 0xd9, 0x63, 0x9a, 0xcf, 0xb4, 0x7d, 0xe2, 0x74, 0xd9, 0x35,
2134 0x85, 0xb9, 0xf5, 0x80, 0x3c, 0xf9, 0x4c, 0x1d, 0xf5, 0xa6, 0x8d, 0x3c,
2135 0xf0, 0x90, 0xfe, 0x45, 0xe8, 0x0e, 0xd6, 0x45, 0xfa, 0xb1, 0x0c, 0xe6,
2136 0xf0, 0x24, 0xfc, 0x9f, 0x46, 0x7c, 0x37, 0xe3, 0x7b, 0x42, 0x7e, 0x75,
2137 0x30, 0xaa, 0xc7, 0x3d, 0x82, 0x71, 0x1c, 0x38, 0x82, 0x31, 0x39, 0xc6,
2138 0x76, 0x76, 0xcf, 0xb8, 0x52, 0x73, 0x86, 0x7c, 0xc7, 0x33, 0x86, 0x41,
2139 0xb0, 0xb7, 0x8b, 0x74, 0x9b, 0xf4, 0xfa, 0xf5, 0xf9, 0xb7, 0xcd, 0xf1,
2140 0x08, 0x70, 0x72, 0x00, 0xf3, 0x31, 0x52, 0xf4, 0xbd, 0xac, 0xe3, 0xc7,
2141 0x31, 0x4e, 0xd8, 0x80, 0xed, 0xb0, 0x05, 0xdb, 0x61, 0x07, 0xb6, 0xc3,
2142 0x0e, 0x5c, 0x2d, 0xa7, 0xb6, 0x72, 0x7f, 0x49, 0xfe, 0x9d, 0xbc, 0x77,
2143 0xf9, 0x1b, 0x3a, 0x36, 0x5f, 0x7b, 0x4b, 0x1f, 0x7c, 0x76, 0xf1, 0x92,
2144 0x03, 0xdc, 0x63, 0x3f, 0xeb, 0xd5, 0xde, 0xd2, 0x2f, 0xed, 0x3d, 0xc8,
2145 0xef, 0xb9, 0x24, 0x1d, 0xb7, 0x7c, 0xd8, 0xa9, 0x1d, 0xe8, 0x03, 0x1e,
2146 0x33, 0x4e, 0x32, 0x3e, 0xe4, 0x30, 0x4e, 0x91, 0xdd, 0x1c, 0xd1, 0x67,
2147 0xc4, 0xa6, 0x19, 0x8b, 0xb8, 0xa5, 0x3d, 0xb2, 0x25, 0xb1, 0xdb, 0x49,
2148 0x0e, 0xa8, 0x48, 0x72, 0xa0, 0xcf, 0x09, 0xcb, 0xf1, 0x0e, 0x6a, 0xc8,
2149 0x19, 0xc0, 0x7a, 0xa0, 0xf4, 0x75, 0xd0, 0xd3, 0x79, 0x29, 0x1c, 0x6f,
2150 0x90, 0xa9, 0x62, 0xbb, 0x97, 0x55, 0x31, 0xe1, 0xbe, 0x12, 0x75, 0x0a,
2151 0x44, 0x7f, 0x26, 0x2a, 0x13, 0xa3, 0x1b, 0x45, 0x69, 0xdb, 0xbd, 0x45,
2152 0xb2, 0x63, 0xa3, 0x72, 0xbe, 0x5b, 0x9a, 0x14, 0xda, 0xe7, 0xdd, 0xde,
2153 0xea, 0x14, 0xd7, 0x11, 0x43, 0x5e, 0x58, 0x4f, 0x3e, 0x19, 0x05, 0x0e,
2154 0x41, 0xb7, 0x8c, 0xeb, 0xd6, 0x09, 0xe5, 0xde, 0xed, 0x3a, 0x66, 0xca,
2155 0x38, 0x6d, 0xf5, 0x7a, 0x03, 0xf9, 0x23, 0xba, 0x2c, 0x7f, 0x4c, 0x96,
2156 0xb8, 0x36, 0x23, 0x79, 0x97, 0x71, 0x61, 0x1f, 0xbf, 0xc7, 0x59, 0xb6,
2157 0x4e, 0x46, 0xba, 0xf3, 0x76, 0x8f, 0xc7, 0x37, 0xc1, 0x07, 0x1c, 0x9f,
2158 0x5e, 0x27, 0x01, 0xaf, 0x2f, 0x5e, 0xcf, 0x88, 0x56, 0xc9, 0x03, 0x47,
2159 0x66, 0x46, 0xc3, 0xf5, 0x0f, 0xb6, 0x87, 0xef, 0x71, 0x23, 0x6f, 0xb3,
2160 0x4b, 0xea, 0x11, 0x2e, 0xae, 0x55, 0x2e, 0x94, 0xb1, 0x4a, 0x9f, 0x13,
2161 0xf6, 0xb4, 0x7c, 0x3d, 0x5d, 0x31, 0xb2, 0x75, 0xbc, 0x12, 0xea, 0x96,
2162 0xa8, 0xd1, 0xa5, 0x4b, 0xf4, 0x89, 0x89, 0x60, 0xce, 0xeb, 0x93, 0x4b,
2163 0x3a, 0x46, 0xf7, 0x6b, 0x53, 0x2d, 0xe2, 0x1e, 0x93, 0xd9, 0x11, 0xff,
2164 0x54, 0x2b, 0xf7, 0x69, 0x8c, 0xa4, 0xde, 0x8c, 0x7e, 0x8c, 0xb5, 0x50,
2165 0x1f, 0x0e, 0xa9, 0xb5, 0x78, 0xaf, 0xd1, 0xf4, 0x07, 0x9e, 0xc2, 0xb7,
2166 0xf1, 0x13, 0xbe, 0x0c, 0x3f, 0xe1, 0x09, 0xe8, 0xba, 0x73, 0xf0, 0x13,
2167 0x1e, 0x87, 0x9f, 0xf0, 0x18, 0xfc, 0x84, 0x47, 0xa1, 0x27, 0xab, 0xfd,
2168 0x83, 0xe1, 0x05, 0xfe, 0x41, 0xa0, 0xf9, 0x9f, 0x31, 0xc0, 0xc7, 0xab,
2169 0x7c, 0x83, 0xbd, 0x46, 0x5f, 0xc1, 0xef, 0x37, 0x7c, 0xd4, 0xa6, 0x6e,
2170 0xd6, 0xfa, 0xd1, 0xec, 0xd9, 0x1d, 0x98, 0xd3, 0x57, 0x6d, 0xca, 0xe8,
2171 0xab, 0x89, 0x79, 0x7d, 0x65, 0xf8, 0xe8, 0xd8, 0xa8, 0x44, 0xfc, 0xd1,
2172 0xe9, 0x6c, 0x6a, 0xbb, 0xe6, 0xa1, 0x26, 0x7f, 0xa3, 0x44, 0x1e, 0x50,
2173 0xcd, 0x35, 0x92, 0xb5, 0xdf, 0xa0, 0xaf, 0xa3, 0x5f, 0x47, 0x5b, 0xef,
2174 0x94, 0x9c, 0xb6, 0xcf, 0xae, 0x8c, 0xef, 0x47, 0x17, 0xe1, 0xbb, 0x50,
2175 0x7a, 0x56, 0xe3, 0xfc, 0x7e, 0x7d, 0x26, 0xbf, 0x41, 0x86, 0xcb, 0x21,
2176 0xce, 0x79, 0x06, 0x8e, 0xfb, 0x30, 0x5a, 0x25, 0x72, 0xac, 0x45, 0xfa,
2177 0x53, 0xa2, 0x72, 0xa9, 0x95, 0x7a, 0xff, 0xca, 0xa9, 0x6e, 0x89, 0xe7,
2178 0xba, 0x49, 0xab, 0xf7, 0xc9, 0x84, 0x9e, 0x8b, 0x16, 0xa9, 0x39, 0x46,
2179 0x1b, 0x25, 0x5c, 0xc3, 0xbb, 0xbd, 0xc5, 0xde, 0x41, 0x1d, 0x35, 0xe5,
2180 0x44, 0x0e, 0xea, 0xf9, 0x9a, 0xd5, 0x7b, 0x0c, 0x6f, 0x9e, 0x62, 0x2c,
2181 0x9e, 0xf7, 0xfd, 0x31, 0x0e, 0xff, 0xaf, 0x99, 0xbf, 0x42, 0x8b, 0xb1,
2182 0x67, 0xd6, 0x58, 0x3b, 0xc6, 0xc4, 0xa9, 0x96, 0xb7, 0x61, 0xd8, 0x4e,
2183 0xf5, 0x1d, 0xb5, 0xab, 0xe0, 0x03, 0x37, 0xa0, 0x4d, 0xae, 0x63, 0xdb,
2184 0xbf, 0x17, 0xe4, 0xfd, 0xb3, 0x73, 0xc0, 0x5f, 0x85, 0xb4, 0x06, 0xe4,
2185 0x31, 0x66, 0xf3, 0x85, 0x16, 0xc6, 0x65, 0xb3, 0x7e, 0xa3, 0x4d, 0x5b,
2186 0xe5, 0x8c, 0x8c, 0xb6, 0xc3, 0x37, 0xe7, 0x39, 0x76, 0xe6, 0xf7, 0x73,
2187 0xee, 0x84, 0x7f, 0xab, 0x69, 0x12, 0xf2, 0x67, 0x8f, 0x5c, 0x6b, 0xe3,
2188 0xce, 0xd4, 0xc3, 0xbf, 0xb8, 0x60, 0xbd, 0xf6, 0x10, 0xf4, 0xd8, 0xad,
2189 0x90, 0x47, 0xd4, 0xc3, 0x87, 0xe4, 0x17, 0x2c, 0x3d, 0x2f, 0xd4, 0xc3,
2190 0x17, 0x85, 0xb1, 0xe1, 0x2e, 0xe4, 0xe5, 0x83, 0x28, 0xe8, 0xe1, 0x70,
2191 0x95, 0xaf, 0x46, 0xbf, 0xaf, 0x2e, 0x6d, 0xd6, 0xc0, 0x16, 0xfa, 0x7d,
2192 0x90, 0x03, 0xb1, 0xd0, 0xcf, 0xab, 0x9d, 0x5b, 0xa3, 0xdd, 0x69, 0xeb,
2193 0x8e, 0xa4, 0x5e, 0x22, 0x8e, 0x12, 0x87, 0xe4, 0xf6, 0xf5, 0xbc, 0x26,
2194 0xcf, 0xf5, 0xbf, 0xa5, 0x71, 0x26, 0x8a, 0xb4, 0xb7, 0x46, 0xc3, 0x68,
2195 0xe5, 0x7c, 0x22, 0xdc, 0xbf, 0x51, 0xb0, 0x75, 0xf7, 0xd8, 0xf5, 0xf8,
2196 0x82, 0x7c, 0x9b, 0x71, 0xce, 0x44, 0x5f, 0x64, 0x25, 0xcf, 0x64, 0xa3,
2197 0xee, 0xed, 0xda, 0x6f, 0xcf, 0x48, 0xd8, 0x16, 0xbf, 0x6b, 0xaa, 0xda,
2198 0xa6, 0x1d, 0xc5, 0xf7, 0xe2, 0xfb, 0x1b, 0x9e, 0xd7, 0x6b, 0x8b, 0xe6,
2199 0x6e, 0x9a, 0x90, 0x4f, 0xc8, 0x3b, 0x09, 0x7d, 0x8e, 0xc9, 0x3f, 0x46,
2200 0xbb, 0x87, 0xeb, 0xae, 0xde, 0xf4, 0x70, 0xea, 0x23, 0xfa, 0x0e, 0xd5,
2201 0x71, 0x11, 0xa7, 0x90, 0xda, 0xab, 0xf7, 0x9d, 0x14, 0x74, 0x7c, 0x39,
2202 0x8f, 0xf7, 0xbc, 0x8f, 0xda, 0x76, 0x8c, 0x7f, 0x0b, 0x88, 0x69, 0x1f,
2203 0x04, 0x6c, 0xd4, 0x21, 0x94, 0xbd, 0x31, 0x69, 0x3b, 0xfa, 0x7e, 0xcd,
2204 0x0b, 0x6b, 0xe1, 0x0b, 0xf4, 0x1e, 0x85, 0xae, 0x3e, 0x1a, 0x97, 0xfe,
2205 0xa3, 0x5a, 0x37, 0x66, 0x96, 0xc6, 0x0a, 0xb6, 0x78, 0x2e, 0xfd, 0x89,
2206 0x98, 0x27, 0xd7, 0x1c, 0x8d, 0xc8, 0xe1, 0xd8, 0x16, 0xaf, 0xc3, 0xb9,
2207 0xd1, 0xea, 0x42, 0x43, 0x7f, 0xa0, 0x15, 0xd4, 0x37, 0xeb, 0x90, 0xbd,
2208 0xf3, 0xb1, 0x6b, 0xd4, 0x7f, 0x49, 0x46, 0xc8, 0x4b, 0x95, 0x88, 0x8c,
2209 0x0f, 0xb6, 0x02, 0x9e, 0xb7, 0xae, 0x07, 0x0e, 0x40, 0x53, 0x98, 0x1f,
2210 0xfd, 0xf7, 0x3c, 0xdc, 0x38, 0xe5, 0x57, 0x1b, 0xfa, 0xef, 0x3b, 0x4a,
2211 0x1d, 0xe6, 0x6b, 0xbe, 0x46, 0xbf, 0x5e, 0x8d, 0xf6, 0x3d, 0xc8, 0x8b,
2212 0x6f, 0x11, 0xff, 0x01, 0xc8, 0xb5, 0xa3, 0x51, 0xe9, 0x38, 0xda, 0x20,
2213 0x9b, 0x8e, 0xd2, 0xf7, 0xa8, 0xf6, 0x45, 0x69, 0x8b, 0x5e, 0xc2, 0xb8,
2214 0x6e, 0x34, 0xf7, 0x0d, 0x4e, 0x45, 0x65, 0x1f, 0xf9, 0x15, 0x65, 0x73,
2215 0xb0, 0x93, 0xb3, 0x47, 0x3d, 0xbd, 0x16, 0x9a, 0xc5, 0x38, 0xf9, 0x37,
2216 0x2c, 0xfa, 0x8e, 0x1a, 0x39, 0x53, 0xa0, 0x6f, 0x32, 0xd0, 0x02, 0xbc,
2217 0x3e, 0x60, 0xf9, 0xe5, 0x3d, 0xeb, 0x2d, 0x5f, 0xfe, 0x9c, 0xfc, 0x96,
2218 0x5b, 0x6f, 0xe4, 0xe5, 0x87, 0xd6, 0x73, 0x2f, 0xd2, 0x5a, 0x9f, 0xef,
2219 0x3a, 0x6d, 0x43, 0x18, 0xb9, 0xf9, 0x7a, 0xfc, 0x27, 0xc0, 0x51, 0xb8,
2220 0xfe, 0x44, 0x3e, 0xe4, 0x1a, 0xb2, 0x3e, 0xb3, 0x92, 0x9a, 0xd1, 0x7f,
2221 0x53, 0x89, 0x6b, 0x61, 0xf3, 0xf7, 0x59, 0x6d, 0xaf, 0x30, 0x36, 0xfe,
2222 0x4c, 0xf8, 0x37, 0x9c, 0xaa, 0xf6, 0x19, 0x56, 0xaf, 0x75, 0x31, 0xbe,
2223 0x34, 0xb7, 0x17, 0x28, 0x18, 0xd5, 0x77, 0xc2, 0xc5, 0x9c, 0x8b, 0xc5,
2224 0x5a, 0xe7, 0x9b, 0x63, 0x12, 0xb8, 0x7e, 0xdc, 0xf9, 0x96, 0xcf, 0xb5,
2225 0x71, 0xcf, 0x79, 0xb9, 0xe8, 0x83, 0xf7, 0xfe, 0x02, 0xe3, 0x68, 0x75,
2226 0x5e, 0xc1, 0x9c, 0x1e, 0x2c, 0x65, 0x92, 0x9e, 0x8d, 0x83, 0x3f, 0x5b,
2227 0x6c, 0x75, 0x9e, 0x9b, 0x8f, 0x21, 0xf5, 0x84, 0x74, 0x71, 0x88, 0x79,
2228 0x65, 0xe4, 0x95, 0x19, 0xeb, 0xad, 0x77, 0x26, 0xc7, 0xec, 0x7e, 0x12,
2229 0xa3, 0x8b, 0xe6, 0xd6, 0x5f, 0x06, 0xf4, 0xfa, 0x84, 0xeb, 0x4c, 0x4e,
2230 0x4d, 0xaf, 0x37, 0xfb, 0x8a, 0x6a, 0x91, 0x67, 0xf6, 0x58, 0x4e, 0x4c,
2231 0xd5, 0xa2, 0x4c, 0xbd, 0x33, 0xa1, 0x63, 0x5e, 0xda, 0xf6, 0x70, 0xc6,
2232 0xa7, 0xea, 0x9d, 0x29, 0xbd, 0xd6, 0x1c, 0x75, 0x4e, 0x8e, 0xb1, 0xed,
2233 0x28, 0xca, 0x88, 0x73, 0x0a, 0xed, 0x4d, 0x8d, 0xb5, 0xc7, 0xf7, 0x49,
2234 0x3b, 0x6c, 0x01, 0xfe, 0x8d, 0x34, 0xde, 0x17, 0xe0, 0x3a, 0x53, 0x73,
2235 0xed, 0x2a, 0xb4, 0xc3, 0xb2, 0xa4, 0x41, 0xf6, 0xeb, 0xa2, 0xfd, 0xa5,
2236 0x6b, 0x52, 0x4b, 0x71, 0x32, 0x06, 0x9c, 0x1c, 0xb4, 0x38, 0x39, 0x61,
2237 0x71, 0x32, 0x5a, 0x85, 0x93, 0x87, 0x17, 0xe1, 0xe4, 0x04, 0x70, 0xf2,
2238 0xf0, 0x15, 0x70, 0x82, 0xbc, 0xf2, 0xc3, 0x16, 0x27, 0xf7, 0x2d, 0xc2,
2239 0x49, 0x7e, 0x2e, 0x16, 0x6f, 0x70, 0x32, 0x02, 0x9c, 0xd4, 0xb4, 0x1a,
2240 0xd8, 0x0f, 0x5a, 0x9c, 0xe0, 0x3d, 0x75, 0x10, 0x65, 0xee, 0xab, 0xc2,
2241 0xc9, 0x41, 0xe0, 0xe4, 0x3e, 0x8b, 0x93, 0xc3, 0x16, 0x27, 0x87, 0x51,
2242 0x26, 0x0f, 0x9c, 0x14, 0x96, 0xc1, 0xc9, 0x08, 0x70, 0x12, 0xb6, 0x5b,
2243 0x40, 0x3b, 0x87, 0xab, 0x70, 0x32, 0xb2, 0x0c, 0x4e, 0xb8, 0xe6, 0x1a,
2244 0xee, 0xe1, 0xbe, 0xfc, 0x06, 0x7b, 0xb8, 0x53, 0x9f, 0x7d, 0xe3, 0x3d,
2245 0xdc, 0x2c, 0x73, 0xb9, 0xea, 0xcc, 0xfb, 0xb3, 0x76, 0x4f, 0x9a, 0xd9,
2246 0xfb, 0x37, 0x7f, 0x0f, 0x5e, 0x3b, 0xf8, 0xbc, 0x90, 0xf7, 0xc4, 0xec,
2247 0x21, 0x75, 0xb7, 0x4d, 0x81, 0xd7, 0x8e, 0xca, 0x81, 0xe3, 0xb5, 0x87,
2248 0x73, 0x36, 0xcd, 0xdf, 0xd6, 0x9e, 0x57, 0x8a, 0x79, 0xe1, 0xde, 0x83,
2249 0x17, 0xcd, 0x5d, 0x50, 0x31, 0x9e, 0xc7, 0xa8, 0x5e, 0x7b, 0x7e, 0xd1,
2250 0xde, 0x55, 0xe4, 0xdd, 0x9b, 0xf5, 0xa7, 0x13, 0xdc, 0x57, 0x55, 0xd0,
2251 0xf0, 0x72, 0x2d, 0xad, 0x47, 0xef, 0xa5, 0xca, 0x16, 0x69, 0x67, 0x27,
2252 0xb8, 0x27, 0x0d, 0xf6, 0x31, 0xf7, 0xed, 0x9a, 0x7d, 0xba, 0xbd, 0x0b,
2253 0xf6, 0xe9, 0x56, 0x9f, 0xef, 0x26, 0xdf, 0xcd, 0xd3, 0xcd, 0xc1, 0xb9,
2254 0xbb, 0x57, 0x8f, 0x3b, 0xcf, 0xe8, 0xf8, 0x70, 0x3d, 0xe6, 0x27, 0x08,
2255 0x4e, 0xa7, 0x4c, 0x5c, 0x76, 0x46, 0xc7, 0x65, 0x05, 0x1e, 0xf8, 0xb0,
2256 0x8d, 0xcd, 0x76, 0xf4, 0x5c, 0x9e, 0x8b, 0xcb, 0x2e, 0xd8, 0xa3, 0xa3,
2257 0xef, 0xff, 0xc8, 0x8e, 0x5e, 0xd2, 0x7b, 0x71, 0xfa, 0x52, 0x8e, 0x14,
2258 0x20, 0x23, 0xf6, 0x8c, 0xbf, 0x2a, 0xc3, 0x0f, 0xf2, 0x9b, 0x3a, 0x2d,
2259 0x02, 0xbd, 0x45, 0xb9, 0x9d, 0x97, 0x6c, 0x0f, 0xd3, 0x4c, 0x9d, 0x3e,
2260 0xed, 0x23, 0x1f, 0x77, 0x7a, 0xe7, 0xfa, 0x27, 0x7e, 0xc3, 0x35, 0x70,
2261 0xfe, 0xa6, 0x9d, 0x93, 0x71, 0xb2, 0x15, 0xe6, 0x87, 0x6b, 0xe1, 0x77,
2262 0xdb, 0xfb, 0x08, 0x99, 0x5f, 0x7d, 0xff, 0xb5, 0xe1, 0xd3, 0xac, 0xfe,
2263 0x3b, 0x22, 0x23, 0x4e, 0x1f, 0xea, 0x4c, 0x7b, 0x0d, 0x03, 0x2a, 0x7d,
2264 0xd3, 0x00, 0xcf, 0xca, 0x4d, 0x2c, 0xf9, 0xfb, 0x01, 0xf3, 0xba, 0xb0,
2265 0xa0, 0xe7, 0x94, 0xfb, 0xb0, 0xa6, 0x41, 0x8b, 0x9a, 0xb6, 0x34, 0xfd,
2266 0x1f, 0x98, 0xd3, 0x91, 0xd4, 0xad, 0xd4, 0x93, 0xa1, 0x8e, 0x4c, 0xc6,
2267 0xfb, 0x78, 0x7f, 0x84, 0xa6, 0x71, 0x7b, 0x97, 0xc4, 0xd4, 0x39, 0xad,
2268 0xdf, 0x47, 0x52, 0xbc, 0x5f, 0x66, 0x99, 0xb2, 0xa3, 0x55, 0x65, 0xf5,
2269 0xb8, 0x3d, 0xf9, 0x43, 0xcc, 0xcd, 0x17, 0x61, 0x6f, 0xf6, 0x8e, 0xbd,
2270 0x0a, 0x9f, 0x31, 0x2e, 0x5f, 0x2a, 0xbd, 0x04, 0x7a, 0xcd, 0xaf, 0xb5,
2271 0x77, 0xe1, 0x65, 0x01, 0x37, 0xcf, 0x38, 0xeb, 0xfd, 0xc3, 0x91, 0x3f,
2272 0x02, 0x5d, 0xfc, 0xc1, 0x4b, 0xec, 0x03, 0xb0, 0x44, 0x60, 0xcf, 0xc3,
2273 0x36, 0x18, 0x7f, 0x49, 0xef, 0x95, 0xbb, 0xbe, 0xfc, 0x92, 0x8e, 0x53,
2274 0xf4, 0x97, 0x5b, 0x65, 0x7b, 0xb9, 0x41, 0x76, 0x40, 0x2f, 0xec, 0x28,
2275 0xfb, 0x78, 0xa2, 0x72, 0x63, 0xd9, 0xcc, 0xd3, 0x47, 0xca, 0x9c, 0xef,
2276 0x6d, 0x32, 0x71, 0xbc, 0x9a, 0x66, 0xa7, 0xed, 0xde, 0x31, 0xd2, 0x0f,
2277 0x9e, 0x52, 0x32, 0x3f, 0xad, 0xc7, 0xce, 0x5d, 0xac, 0xc9, 0xc3, 0xb3,
2278 0xc2, 0xbd, 0xf8, 0xfc, 0x1b, 0x74, 0xdf, 0x68, 0xe5, 0x19, 0x77, 0xde,
2279 0x8f, 0xd8, 0x5f, 0x09, 0xf7, 0x86, 0xbf, 0xfe, 0x19, 0x10, 0xfd, 0x77,
2280 0x5d, 0xf4, 0xde, 0x70, 0x4d, 0x7b, 0xd2, 0x76, 0x26, 0xa6, 0x75, 0x84,
2281 0xa1, 0xf1, 0xf9, 0xbf, 0xe7, 0x22, 0xf2, 0x7f, 0x01, 0x95, 0xf6, 0x2d,
2282 0x58, 0xd0, 0x73, 0x00, 0x00, 0x00 };
2283static u32 bnx2_CP_b09FwData[(0x50/4) + 1] = {
2284 0x00010030, 0x00000030, 0x00000000, 0x00000001, 0x00010fd0, 0x00000fd0,
2285 0x00001430, 0x0000007f, 0x00030400, 0x00001000, 0x00000030, 0x00000020,
2286 0x00050200, 0x00001000, 0x00000030, 0x00000010, 0x00010400, 0x00000400,
2287 0x00001030, 0x00000020, 0x00000000 };
2288static u32 bnx2_CP_b09FwRodata[(0x118/4) + 1] = {
2289 0x080005d8, 0x080007f8, 0x0800073c, 0x08000764, 0x0800078c, 0x080007b4,
2290 0x08000610, 0x080005fc, 0x08000820, 0x08000820, 0x0800062c, 0x08000648,
2291 0x08000648, 0x08000820, 0x08000660, 0x08000674, 0x08000820, 0x08000688,
2292 0x08000820, 0x08000820, 0x0800069c, 0x08000820, 0x08000820, 0x08000820,
2293 0x08000820, 0x08000820, 0x08000820, 0x08000820, 0x08000820, 0x08000820,
2294 0x08000820, 0x080006b0, 0x08000820, 0x080006c4, 0x080006d8, 0x080006ec,
2295 0x08000820, 0x08000700, 0x08000714, 0x08000728, 0x08003740, 0x08003758,
2296 0x08003768, 0x08003778, 0x08003790, 0x080037a8, 0x080037b8, 0x080037c8,
2297 0x080037e8, 0x080037f8, 0x08003808, 0x08003898, 0x080037d8, 0x08003818,
2298 0x08003828, 0x08003840, 0x08003860, 0x08003898, 0x08003878, 0x08003878,
2299 0x080055f0, 0x080055f0, 0x080055f0, 0x080055f0, 0x080055f0, 0x08005618,
2300 0x08005618, 0x08005640, 0x08005690, 0x08005660, 0x00000000 };
2301static u32 bnx2_CP_b09FwBss[(0x870/4) + 1] = { 0x0 };
2302static u32 bnx2_CP_b09FwSbss[(0xe9/4) + 1] = { 0x0 };
2303
2304static struct fw_info bnx2_cp_fw_09 = {
2305 .ver_major = 0x1,
2306 .ver_minor = 0x0,
2307 .ver_fix = 0x0,
2308
2309 .start_addr = 0x0800006c,
2310
2311 .text_addr = 0x08000000,
2312 .text_len = 0x73cc,
2313 .text_index = 0x0,
2314 .gz_text = bnx2_CP_b09FwText,
2315 .gz_text_len = sizeof(bnx2_CP_b09FwText),
2316
2317 .data_addr = 0x08007500,
2318 .data_len = 0x50,
2319 .data_index = 0x0,
2320 .data = bnx2_CP_b09FwData,
2321
2322 .sbss_addr = 0x08007554,
2323 .sbss_len = 0xe9,
2324 .sbss_index = 0x0,
2325 .sbss = bnx2_CP_b09FwSbss,
2326
2327 .bss_addr = 0x08007640,
2328 .bss_len = 0x870,
2329 .bss_index = 0x0,
2330 .bss = bnx2_CP_b09FwBss,
2331
2332 .rodata_addr = 0x080073d0,
2333 .rodata_len = 0x118,
2334 .rodata_index = 0x0,
2335 .rodata = bnx2_CP_b09FwRodata,
2336};
2337
2338static u8 bnx2_RXP_b09FwText[] = {
2339 0x1f, 0x8b, 0x08, 0x08, 0x19, 0xfd, 0x2f, 0x45, 0x00, 0x03, 0x74, 0x65,
2340 0x73, 0x74, 0x31, 0x2e, 0x62, 0x69, 0x6e, 0x00, 0xec, 0x5c, 0x6b, 0x6c,
2341 0x1c, 0xd7, 0x75, 0x3e, 0xf3, 0x20, 0xb5, 0xa2, 0xf8, 0x18, 0x2e, 0x57,
2342 0xcc, 0x4a, 0x66, 0xec, 0x5d, 0x71, 0x24, 0xb2, 0x16, 0x6b, 0x8c, 0xd8,
2343 0xad, 0x4d, 0x04, 0x6b, 0x7b, 0x33, 0xbb, 0x92, 0x98, 0x54, 0x85, 0x29,
2344 0x87, 0x75, 0x0c, 0xc3, 0x75, 0xd9, 0xa5, 0x1a, 0xbb, 0xae, 0x51, 0xc8,
2345 0x8f, 0xc4, 0x06, 0x6a, 0xd6, 0x9b, 0x25, 0xdd, 0xa8, 0xe9, 0x82, 0x43,
2346 0x4b, 0xaa, 0xe9, 0x02, 0x69, 0xbb, 0x20, 0xa9, 0xc7, 0x8f, 0x85, 0x56,
2347 0x76, 0x52, 0xc7, 0xf9, 0xe1, 0x48, 0x50, 0x95, 0x20, 0x28, 0x0c, 0x43,
2348 0x48, 0x8d, 0xd6, 0x3f, 0xda, 0x40, 0x95, 0x9f, 0x68, 0x92, 0x42, 0x41,
2349 0x0b, 0xc7, 0x68, 0x6c, 0x4f, 0xbf, 0xef, 0xce, 0x0c, 0xb9, 0xa4, 0x5f,
2350 0x40, 0x7f, 0xf4, 0x4f, 0xe7, 0x02, 0x8b, 0xb9, 0xf7, 0xce, 0x3d, 0xe7,
2351 0x9e, 0x7b, 0xde, 0xe7, 0x0e, 0xa5, 0xdf, 0xef, 0x94, 0x0e, 0x09, 0x5b,
2352 0x17, 0x7e, 0x99, 0xc3, 0x8f, 0x3d, 0x74, 0xc3, 0xd8, 0x0d, 0xa3, 0x22,
2353 0x7b, 0xf6, 0x18, 0x5b, 0x12, 0x7a, 0x34, 0x1f, 0xb7, 0xb8, 0xc5, 0x2d,
2354 0x6e, 0x71, 0x8b, 0x5b, 0xdc, 0xe2, 0x16, 0xb7, 0xb8, 0xc5, 0x2d, 0x6e,
2355 0x71, 0x8b, 0x5b, 0xdc, 0xe2, 0x16, 0xb7, 0xb8, 0xc5, 0x2d, 0x6e, 0x71,
2356 0x8b, 0x5b, 0xdc, 0xe2, 0x16, 0xb7, 0xb8, 0xc5, 0x2d, 0x6e, 0x71, 0x8b,
2357 0x5b, 0xdc, 0xe2, 0x16, 0xb7, 0xb8, 0xc5, 0x2d, 0x6e, 0x71, 0x8b, 0x5b,
2358 0xdc, 0xe2, 0x16, 0xb7, 0xb8, 0xc5, 0x2d, 0x6e, 0x71, 0x8b, 0x5b, 0xdc,
2359 0xe2, 0xf6, 0xff, 0xbd, 0x19, 0x22, 0x16, 0x9f, 0x5d, 0xe1, 0x4f, 0x12,
2360 0x7a, 0xfe, 0xf2, 0x1f, 0xba, 0xb6, 0x24, 0x8c, 0xfc, 0xcf, 0x66, 0xa6,
2361 0x6d, 0x91, 0x42, 0x63, 0x77, 0xa6, 0x28, 0xef, 0xfb, 0x95, 0x94, 0x29,
2362 0x9c, 0xff, 0x6c, 0xfe, 0xbd, 0xbf, 0x7d, 0xf1, 0xa6, 0xec, 0xd5, 0xba,
2363 0x21, 0x09, 0x2b, 0x3f, 0xb7, 0xc7, 0xda, 0x25, 0x89, 0x01, 0xc0, 0x7c,
2364 0x6b, 0xe8, 0xc7, 0xdd, 0xd2, 0x2d, 0x6b, 0x78, 0xec, 0x84, 0x5c, 0x36,
2365 0x5e, 0xd0, 0xdc, 0xa6, 0xef, 0x9f, 0x70, 0x7c, 0xff, 0x87, 0xf8, 0xbd,
2366 0xe5, 0x60, 0xec, 0x7d, 0xe0, 0x17, 0x4c, 0x43, 0x74, 0xfb, 0x2f, 0x34,
2367 0x77, 0xb9, 0x43, 0xaa, 0x8b, 0xa6, 0xcc, 0x7a, 0x29, 0x39, 0xe2, 0x55,
2368 0xb4, 0x52, 0xb3, 0xa6, 0xed, 0x3d, 0x35, 0xaf, 0xed, 0x3b, 0x75, 0x44,
2369 0xdb, 0x7f, 0x6a, 0x41, 0x73, 0x4f, 0x49, 0x45, 0xdf, 0xd3, 0x29, 0x05,
2370 0xeb, 0xb4, 0x56, 0x6c, 0xf6, 0x6b, 0xee, 0xe2, 0x7b, 0xbe, 0xeb, 0x64,
2371 0xad, 0xbb, 0xc4, 0x2c, 0x80, 0x16, 0x71, 0x6b, 0x3e, 0xc6, 0xa6, 0x14,
2372 0x52, 0xbe, 0xaf, 0xe7, 0xfd, 0x27, 0xdc, 0x9c, 0x6d, 0xe9, 0x5a, 0x4a,
2373 0xaa, 0xcd, 0x7e, 0xe0, 0xed, 0xd4, 0x8a, 0x8b, 0xa6, 0x56, 0xf2, 0xfc,
2374 0x73, 0xae, 0x23, 0x03, 0x86, 0xf8, 0xfe, 0x9c, 0xb3, 0x33, 0x7d, 0x48,
2375 0x4e, 0x02, 0x6f, 0x03, 0xf8, 0xc4, 0xd2, 0xf3, 0xa4, 0x8f, 0x74, 0x92,
2376 0xe4, 0x8a, 0x56, 0x1c, 0x8a, 0xe8, 0x93, 0x0c, 0xe9, 0x2f, 0xaf, 0xe8,
2377 0xa0, 0x73, 0x8b, 0x94, 0xeb, 0x96, 0x4c, 0xad, 0x6c, 0x5c, 0x7f, 0xd9,
2378 0x7f, 0x71, 0x28, 0x25, 0xcf, 0x36, 0xb3, 0x47, 0x2a, 0x92, 0x90, 0x39,
2379 0x2f, 0x23, 0x7a, 0x5e, 0x0a, 0x6e, 0x6e, 0x40, 0xce, 0x35, 0xd3, 0xf2,
2380 0x5c, 0xd3, 0x4e, 0x57, 0x65, 0x93, 0x94, 0x53, 0x96, 0x9c, 0x6d, 0xa6,
2381 0x70, 0x46, 0xff, 0x9c, 0x6e, 0xdb, 0x56, 0x15, 0x6b, 0xab, 0xcd, 0x97,
2382 0xf8, 0xef, 0x5f, 0xac, 0xe9, 0x9c, 0x82, 0xa9, 0x80, 0xee, 0x70, 0x2d,
2383 0xcf, 0xa1, 0xd6, 0xaa, 0xb3, 0x04, 0x6b, 0xa5, 0x32, 0x9d, 0xc3, 0x5c,
2384 0x73, 0x34, 0xe4, 0xef, 0x16, 0x9c, 0x97, 0x4f, 0x4b, 0xaa, 0x9e, 0x01,
2385 0xde, 0xb0, 0xff, 0xcf, 0xc0, 0x37, 0x80, 0xf3, 0x5e, 0xab, 0x7e, 0xee,
2386 0xa2, 0xa4, 0x74, 0xd9, 0x99, 0x2e, 0x0b, 0x78, 0xdb, 0xec, 0xc4, 0x98,
2387 0xf4, 0xf9, 0xfe, 0x7e, 0x47, 0xac, 0xaa, 0xd3, 0x03, 0x98, 0x8c, 0x54,
2388 0x9d, 0x6e, 0xe0, 0x69, 0x13, 0xcb, 0xe6, 0xb9, 0xb8, 0xd7, 0x66, 0xcc,
2389 0xfb, 0x5d, 0x46, 0xde, 0xf7, 0xa7, 0x73, 0xd2, 0x1d, 0xcc, 0xed, 0x56,
2390 0x38, 0xa6, 0x26, 0x34, 0xac, 0xfb, 0x05, 0x69, 0x4e, 0x24, 0xf3, 0xec,
2391 0xf3, 0x99, 0x13, 0x77, 0xfe, 0xda, 0x90, 0x96, 0x34, 0x68, 0xb9, 0x26,
2392 0xec, 0x83, 0xff, 0x1e, 0xf8, 0xe0, 0x7c, 0x06, 0x63, 0xed, 0x3a, 0xe0,
2393 0x19, 0xae, 0x0a, 0xf7, 0xe8, 0x93, 0xa5, 0x94, 0xe8, 0x57, 0x9c, 0xde,
2394 0x70, 0x5d, 0x37, 0x68, 0x8d, 0xf4, 0xa0, 0x5f, 0xe6, 0x16, 0xc9, 0xeb,
2395 0x1a, 0x64, 0x83, 0xe7, 0x8d, 0x15, 0xad, 0xd0, 0x3c, 0x82, 0xbe, 0x29,
2396 0xd3, 0xb6, 0x7f, 0x6e, 0xce, 0x99, 0xd7, 0x8a, 0xa7, 0x4e, 0x6a, 0xa5,
2397 0x53, 0x2f, 0x68, 0x7b, 0x9b, 0x2f, 0x74, 0x49, 0x47, 0x16, 0xa7, 0x4e,
2398 0xc8, 0x93, 0x9e, 0x26, 0xa4, 0x73, 0x09, 0xbc, 0x2b, 0x58, 0x15, 0x31,
2399 0xed, 0x6e, 0x6d, 0x1f, 0xf0, 0xb4, 0xd9, 0x7f, 0xd2, 0x29, 0xdd, 0x86,
2400 0x6c, 0xb2, 0xa3, 0xb5, 0x29, 0xf9, 0x33, 0xd0, 0x74, 0xc1, 0x49, 0x91,
2401 0x5f, 0x3d, 0x01, 0x4c, 0x44, 0x07, 0xf5, 0x8a, 0x3a, 0xa5, 0x17, 0x4a,
2402 0xc7, 0xff, 0xbc, 0xaf, 0x3a, 0xb2, 0x85, 0x6b, 0xa0, 0xff, 0xd6, 0xfd,
2403 0xd3, 0xb6, 0xdb, 0x6b, 0x4a, 0xc5, 0xd2, 0x25, 0x6b, 0x15, 0xe5, 0x3a,
2404 0x99, 0x73, 0x44, 0x8a, 0x35, 0xec, 0x69, 0x9b, 0xe0, 0x8d, 0x0d, 0xde,
2405 0xec, 0x3c, 0x32, 0xa8, 0xff, 0x96, 0x64, 0xfa, 0x2b, 0x9a, 0x19, 0xf2,
2406 0x71, 0x49, 0x6e, 0x51, 0xf0, 0x7a, 0xde, 0x81, 0x7e, 0x76, 0xb0, 0x8f,
2407 0x7d, 0x13, 0x6a, 0x5f, 0x23, 0x6f, 0xa7, 0x97, 0x45, 0x34, 0x3d, 0xbf,
2408 0x1b, 0xf8, 0xa8, 0xb7, 0x5c, 0xf7, 0x04, 0x68, 0x24, 0xed, 0xec, 0xdb,
2409 0x80, 0x49, 0x88, 0xeb, 0x74, 0xb5, 0xd0, 0x49, 0x79, 0x93, 0xd7, 0xe4,
2410 0x9d, 0x3a, 0xa7, 0xb6, 0x76, 0xce, 0x5f, 0xf9, 0x9b, 0x46, 0x4d, 0xf9,
2411 0xa1, 0x3a, 0x2f, 0x6d, 0x8c, 0xeb, 0x52, 0xa1, 0x4e, 0x24, 0xa0, 0x47,
2412 0xa2, 0x95, 0x1d, 0x6b, 0x15, 0x57, 0x59, 0x44, 0x37, 0xf2, 0x9d, 0x52,
2413 0x54, 0xf4, 0x8d, 0x61, 0x2f, 0xda, 0x1e, 0x6c, 0xc8, 0xe6, 0x59, 0x38,
2414 0x97, 0x87, 0x8d, 0x67, 0xd9, 0x97, 0xf2, 0x02, 0xed, 0x9d, 0xb4, 0x9d,
2415 0xcf, 0xaa, 0x7f, 0x8e, 0x45, 0x5d, 0x3c, 0xd6, 0x03, 0xda, 0x38, 0x86,
2416 0x1d, 0xda, 0x78, 0x3f, 0xa2, 0x89, 0x3b, 0x36, 0x08, 0xfe, 0x70, 0x9d,
2417 0x9d, 0x81, 0x9c, 0x0b, 0x2e, 0xf6, 0x74, 0x9d, 0xdf, 0x50, 0x3c, 0xe8,
2418 0xc5, 0x79, 0x06, 0xe7, 0xc9, 0xaf, 0x0e, 0xe8, 0xb6, 0x26, 0x65, 0x27,
2419 0x9b, 0xa1, 0xdc, 0x03, 0xda, 0x75, 0xd9, 0x74, 0x63, 0x2b, 0xed, 0x91,
2420 0xac, 0xa8, 0x87, 0xa6, 0x24, 0x47, 0xb9, 0x96, 0xeb, 0xb8, 0x3e, 0x3b,
2421 0x26, 0xfa, 0xaf, 0x7c, 0x6b, 0xdd, 0x59, 0x6d, 0xd9, 0x31, 0x0f, 0x1a,
2422 0x02, 0xde, 0x82, 0x27, 0x9f, 0xb6, 0x96, 0x7c, 0xdd, 0xc8, 0x3f, 0xae,
2423 0x6d, 0x5d, 0x07, 0x9d, 0xe8, 0x27, 0x0d, 0x27, 0x3a, 0x03, 0x5b, 0x8b,
2424 0x68, 0x8a, 0x64, 0xa3, 0x85, 0x38, 0x3e, 0xe9, 0x1c, 0x5c, 0x0f, 0x1f,
2425 0xe0, 0xc1, 0x07, 0xc0, 0xaf, 0x3d, 0xeb, 0xc1, 0xfe, 0x3d, 0xfa, 0x8c,
2426 0x8c, 0xbc, 0x38, 0x04, 0x1f, 0xb7, 0xe6, 0x63, 0xd0, 0xc6, 0xd1, 0xd7,
2427 0xc5, 0x80, 0x8f, 0x99, 0xad, 0xeb, 0xb0, 0x59, 0xf0, 0x78, 0x85, 0x73,
2428 0xb0, 0xed, 0x95, 0x12, 0x9e, 0xb6, 0x54, 0x1b, 0xd4, 0xab, 0xc8, 0x97,
2429 0xd2, 0xe7, 0xa4, 0xe1, 0x5f, 0xe8, 0x77, 0xe8, 0x57, 0xb8, 0xd6, 0xf7,
2430 0x4b, 0x0e, 0x61, 0x7d, 0x99, 0x70, 0x68, 0x43, 0x9d, 0xa2, 0x27, 0x2b,
2431 0xda, 0xc1, 0x21, 0xd8, 0xd6, 0xf5, 0x6d, 0xa0, 0x95, 0x36, 0x76, 0x8d,
2432 0x48, 0x3b, 0xf7, 0xfb, 0x69, 0x57, 0xf0, 0xef, 0xee, 0x36, 0x61, 0x0d,
2433 0x9f, 0xef, 0x86, 0x63, 0x2d, 0xf4, 0x2d, 0x7c, 0x9f, 0xcd, 0x14, 0xa4,
2434 0x3f, 0x1c, 0xb3, 0xbf, 0x4a, 0xaf, 0xa3, 0xdf, 0x98, 0x90, 0x1d, 0x27,
2435 0x03, 0x9f, 0xb8, 0x63, 0xc9, 0x12, 0xfb, 0x64, 0x40, 0xe3, 0x8e, 0x33,
2436 0x91, 0x6f, 0x7c, 0x1f, 0xf0, 0xa0, 0xcf, 0x5b, 0x8d, 0x03, 0x68, 0x3f,
2437 0xd3, 0x60, 0x2a, 0x98, 0xdb, 0xc8, 0x0b, 0xfa, 0x63, 0xda, 0x9b, 0xd5,
2438 0x6a, 0x6f, 0x7b, 0x60, 0x6f, 0x4e, 0xbb, 0x64, 0x9d, 0xbf, 0x87, 0xbd,
2439 0x7d, 0xc3, 0xd1, 0xc0, 0x1b, 0x91, 0x8b, 0xb5, 0x34, 0x6c, 0xdd, 0x4c,
2440 0xbf, 0x26, 0x3b, 0x33, 0xb3, 0xa2, 0xc9, 0x09, 0xce, 0x35, 0x30, 0xa7,
2441 0x7c, 0x71, 0xe0, 0x0b, 0x2e, 0x1b, 0x4f, 0x81, 0x2e, 0xdf, 0x9f, 0x05,
2442 0xce, 0xf2, 0x88, 0x11, 0xda, 0x56, 0x34, 0x6f, 0xdd, 0xef, 0xda, 0xee,
2443 0xaf, 0x19, 0x52, 0x19, 0x6e, 0x93, 0xec, 0xf0, 0x12, 0x70, 0x4f, 0x3b,
2444 0x81, 0x1d, 0x53, 0xd7, 0x97, 0x81, 0x7f, 0xce, 0x1b, 0x82, 0x1e, 0xd3,
2445 0x0e, 0x40, 0x17, 0xf0, 0x2f, 0x03, 0xff, 0x5c, 0xb3, 0x4d, 0xbe, 0x6e,
2446 0x46, 0xb1, 0x32, 0x3a, 0x4f, 0x37, 0x96, 0x45, 0xfb, 0x1e, 0x96, 0x2f,
2447 0x7a, 0x49, 0xcd, 0x3d, 0x46, 0xff, 0x5a, 0x1d, 0x86, 0x9d, 0x68, 0x55,
2448 0x87, 0x7b, 0x1b, 0xb2, 0xbc, 0xba, 0x46, 0x0a, 0xd5, 0xc0, 0x06, 0x0b,
2449 0xee, 0x50, 0x25, 0x6d, 0x28, 0x5f, 0x22, 0xb2, 0x0f, 0xb6, 0xb7, 0x6c,
2450 0x73, 0xcc, 0xf9, 0x60, 0x6e, 0xbc, 0xd6, 0x0f, 0x9f, 0xc8, 0xf1, 0x7b,
2451 0xfe, 0xb4, 0x13, 0xcc, 0x7d, 0xa1, 0x76, 0x57, 0x37, 0xfd, 0x2e, 0xe2,
2452 0x44, 0xa6, 0xea, 0xfc, 0xbb, 0x0f, 0xfd, 0x5d, 0x07, 0xf3, 0xd1, 0x78,
2453 0xb2, 0xe3, 0x81, 0xce, 0x8a, 0xb6, 0xdf, 0xd6, 0xfb, 0xdb, 0x43, 0x1f,
2454 0xb6, 0x1f, 0x93, 0x7b, 0x6b, 0xd5, 0xbe, 0x76, 0x79, 0xcf, 0x60, 0x1c,
2455 0xbd, 0x22, 0x62, 0xba, 0xb5, 0x5d, 0xe0, 0x47, 0xb5, 0xb7, 0x65, 0x2e,
2456 0x51, 0xaa, 0xf9, 0x72, 0xc1, 0x09, 0x60, 0x30, 0xee, 0x2c, 0xd6, 0xf4,
2457 0xfe, 0x84, 0xac, 0x8e, 0x2d, 0xc2, 0xac, 0xc8, 0xae, 0xe1, 0x65, 0x51,
2458 0xb0, 0x7d, 0x89, 0x35, 0xd8, 0x54, 0xa9, 0x56, 0xed, 0x6d, 0x19, 0xa7,
2459 0x8b, 0xc0, 0xa5, 0xef, 0x59, 0x85, 0x1d, 0x58, 0x83, 0xdd, 0x2a, 0x99,
2460 0x5e, 0xc2, 0xeb, 0xfd, 0x9b, 0xd7, 0x70, 0x67, 0x42, 0x7a, 0xfa, 0x36,
2461 0xaf, 0xe1, 0xb0, 0x89, 0xb3, 0x65, 0x3c, 0x4c, 0x9c, 0x3b, 0xd6, 0x70,
2462 0x8e, 0xac, 0xa7, 0xe7, 0xb0, 0xc0, 0x07, 0x25, 0xda, 0xf3, 0xb2, 0xe7,
2463 0x62, 0x6d, 0x70, 0xe2, 0x8b, 0x82, 0x58, 0x37, 0xb2, 0x29, 0xf4, 0xc9,
2464 0xe6, 0x1e, 0x17, 0xbc, 0x32, 0x85, 0x3e, 0x4e, 0x93, 0x2a, 0xe4, 0x7c,
2465 0x7f, 0x43, 0xf6, 0x5c, 0x68, 0x98, 0xa1, 0x2e, 0x51, 0x27, 0xde, 0x86,
2466 0x8d, 0x75, 0x4e, 0x99, 0x88, 0xc3, 0xe7, 0x94, 0x8d, 0xc9, 0x44, 0xb5,
2467 0x26, 0x95, 0xed, 0xf9, 0x27, 0x7c, 0xe8, 0xe2, 0x94, 0x05, 0x3f, 0x5a,
2468 0x94, 0xce, 0x31, 0x37, 0x87, 0xf9, 0x06, 0x6d, 0x0b, 0x7e, 0x05, 0xb0,
2469 0xd0, 0xb5, 0x84, 0x31, 0xbf, 0xf3, 0x55, 0xd7, 0xe0, 0x3e, 0x19, 0xe4,
2470 0x4d, 0x89, 0x84, 0x3e, 0x7f, 0xd5, 0xa7, 0x9e, 0x4d, 0x8f, 0x5c, 0x45,
2471 0x9e, 0x62, 0xc1, 0x57, 0xc2, 0x7f, 0x40, 0xdf, 0x67, 0x9b, 0x82, 0xb8,
2472 0xfe, 0x40, 0x4f, 0x60, 0x63, 0x47, 0xb7, 0x06, 0x4f, 0x31, 0xe9, 0x9b,
2473 0xa7, 0x73, 0xcc, 0x01, 0xda, 0x13, 0x6e, 0x6e, 0x7c, 0x9b, 0x71, 0xe6,
2474 0xc0, 0x36, 0xfd, 0x4c, 0x65, 0x9b, 0x0e, 0x9f, 0x0e, 0x9b, 0xd2, 0xdd,
2475 0x1c, 0xfa, 0x67, 0x22, 0x1b, 0x4a, 0xc3, 0x86, 0xde, 0x56, 0x39, 0xc8,
2476 0xb9, 0xe6, 0x29, 0xd8, 0xab, 0xa2, 0x55, 0x26, 0x90, 0x13, 0xe8, 0xa3,
2477 0xef, 0x43, 0x4f, 0x70, 0x16, 0xf8, 0xc0, 0x02, 0xb8, 0xa4, 0x8f, 0xbe,
2478 0x11, 0xda, 0x33, 0xfb, 0xef, 0xf8, 0x41, 0x7c, 0xf8, 0x7c, 0xb8, 0xff,
2479 0x3f, 0x75, 0x07, 0x3e, 0x20, 0xc2, 0x45, 0x3c, 0xc3, 0xda, 0x04, 0xf2,
2480 0x99, 0x89, 0xa6, 0xa9, 0xd1, 0x9f, 0x17, 0x3d, 0xe6, 0x21, 0xcc, 0x41,
2481 0x1e, 0x0b, 0xfd, 0x22, 0x73, 0x8f, 0xce, 0x90, 0xa7, 0xb9, 0x28, 0xce,
2482 0x29, 0x7b, 0x43, 0xcc, 0xc9, 0x94, 0x9d, 0x36, 0xe5, 0x93, 0xa7, 0x73,
2483 0x9d, 0x58, 0x87, 0xb9, 0x26, 0xce, 0x0d, 0xbf, 0x84, 0x5c, 0x06, 0x6b,
2484 0xce, 0x63, 0x7d, 0x7b, 0x68, 0xf3, 0x17, 0xa5, 0x0c, 0x9f, 0x6a, 0xda,
2485 0x7c, 0x9f, 0xeb, 0x91, 0x0e, 0x8c, 0x1b, 0xd8, 0x0b, 0x7e, 0xc2, 0x50,
2486 0x7c, 0x46, 0x2c, 0x48, 0x5d, 0xc7, 0x1c, 0x09, 0x6b, 0x33, 0x58, 0x4b,
2487 0xbf, 0xcb, 0xb5, 0xcf, 0x82, 0x0e, 0x8c, 0x1b, 0x84, 0xa1, 0x8f, 0x12,
2488 0xdf, 0xcd, 0x6d, 0x86, 0x26, 0xf9, 0xe7, 0x0c, 0x3b, 0x5a, 0x1b, 0xe1,
2489 0xdd, 0xb8, 0x96, 0xf9, 0x09, 0x71, 0xf7, 0x84, 0xf1, 0x7f, 0x5c, 0x0a,
2490 0xcd, 0x02, 0x7e, 0x22, 0xd3, 0xc7, 0x90, 0x8f, 0xd9, 0x6d, 0x88, 0x55,
2491 0x9c, 0xdf, 0x6a, 0x05, 0x67, 0x8d, 0xe0, 0xee, 0xef, 0x5b, 0x3f, 0xfe,
2492 0x42, 0x72, 0xcd, 0x47, 0xd2, 0xc2, 0xa4, 0x80, 0x18, 0x01, 0x5e, 0x65,
2493 0xa6, 0x98, 0xc3, 0x15, 0x1b, 0x4a, 0xa6, 0x98, 0x1b, 0x83, 0x5f, 0x0c,
2494 0xf2, 0xa2, 0x73, 0xde, 0x46, 0xd9, 0x59, 0xe0, 0x77, 0x01, 0x3c, 0xce,
2495 0x40, 0x87, 0xc6, 0x01, 0x2b, 0x87, 0x81, 0x83, 0xf1, 0xd7, 0xd1, 0xf3,
2496 0x49, 0x29, 0x5b, 0xcc, 0x13, 0xda, 0x49, 0x67, 0x81, 0xf6, 0xaf, 0xe7,
2497 0x37, 0x63, 0x8e, 0xfd, 0x7b, 0x7b, 0x02, 0x99, 0x75, 0x71, 0x3c, 0xa1,
2498 0xe7, 0x7b, 0x36, 0xcc, 0x7f, 0xbf, 0x2b, 0xa0, 0x4d, 0x8d, 0x31, 0xff,
2499 0xf2, 0x86, 0xf1, 0xef, 0x25, 0xd7, 0x8f, 0xef, 0xda, 0x16, 0xea, 0x20,
2500 0xfa, 0x8f, 0x85, 0xf4, 0x82, 0xb6, 0x55, 0x5a, 0xa3, 0x9c, 0x57, 0x16,
2501 0x74, 0xe4, 0x7f, 0x6e, 0x6e, 0x27, 0x62, 0x7d, 0x46, 0x4a, 0x4d, 0xd0,
2502 0xbd, 0x1a, 0xcb, 0x56, 0xd7, 0x54, 0xd6, 0xd6, 0x04, 0xbe, 0xbe, 0xd4,
2503 0xf4, 0x91, 0x3b, 0xb5, 0xc6, 0xbd, 0x61, 0xf4, 0x2b, 0xd8, 0xa7, 0x20,
2504 0xd3, 0xde, 0x85, 0x82, 0x6e, 0x1f, 0x09, 0xf2, 0x3e, 0xfb, 0x9b, 0x5a,
2505 0x69, 0x99, 0xf9, 0x20, 0xec, 0xc9, 0x56, 0xf9, 0x3f, 0xe2, 0xca, 0x51,
2506 0xad, 0x70, 0xea, 0x38, 0xf2, 0xc1, 0x15, 0xfc, 0x4e, 0xe3, 0xd7, 0xc0,
2507 0x2f, 0xca, 0xc3, 0x9f, 0x41, 0x1e, 0xaf, 0x7c, 0x2c, 0xe2, 0x41, 0xb0,
2508 0xff, 0x1b, 0x2b, 0xd0, 0xb3, 0xe3, 0x29, 0xf9, 0x86, 0xad, 0xf7, 0xe9,
2509 0x81, 0x5f, 0x29, 0x20, 0x8f, 0xb5, 0xde, 0x96, 0xdf, 0x0e, 0xf3, 0x22,
2510 0x91, 0xd7, 0x16, 0xc0, 0xc7, 0x91, 0xfd, 0xa1, 0xce, 0x16, 0xee, 0x75,
2511 0x95, 0xff, 0x0c, 0xf3, 0x1e, 0xe4, 0x5f, 0x05, 0xb5, 0xea, 0x5b, 0xe0,
2512 0x8d, 0x26, 0x6f, 0x41, 0x87, 0x5e, 0x5b, 0xe8, 0x00, 0x3d, 0xb6, 0x94,
2513 0x27, 0x91, 0x2f, 0x68, 0x83, 0xd6, 0x26, 0xad, 0x03, 0x76, 0x0c, 0x1b,
2514 0x57, 0x63, 0x49, 0xb4, 0xe5, 0x2f, 0xcd, 0x2c, 0xd5, 0x74, 0xac, 0x45,
2515 0xee, 0x93, 0x43, 0x1f, 0xb2, 0xbf, 0xb2, 0x40, 0x38, 0x5d, 0x5e, 0x5f,
2516 0x30, 0xe4, 0x4d, 0xe4, 0x52, 0x6f, 0xd9, 0x97, 0x66, 0x10, 0xb7, 0xfa,
2517 0x11, 0x23, 0x50, 0x8b, 0xec, 0xa4, 0x9f, 0xde, 0x61, 0xe2, 0x59, 0xc2,
2518 0x6f, 0x1f, 0x72, 0xc1, 0x8f, 0x86, 0xf9, 0xb8, 0xf5, 0xa4, 0x2d, 0x01,
2519 0x18, 0xae, 0x37, 0x41, 0x5b, 0x37, 0xe4, 0x9f, 0xb5, 0xa6, 0xe4, 0xf5,
2520 0x1e, 0x95, 0xaf, 0x68, 0x9c, 0x0f, 0x7c, 0xd3, 0x87, 0xe7, 0xc9, 0x67,
2521 0x03, 0x3a, 0xce, 0x31, 0xdf, 0xd1, 0x87, 0x12, 0x5f, 0x76, 0xac, 0x80,
2522 0xc3, 0x5c, 0x59, 0x08, 0xfa, 0xd1, 0x9c, 0x68, 0x51, 0x1c, 0xa3, 0x6f,
2523 0x2c, 0xc1, 0x4e, 0x38, 0x9e, 0x10, 0x25, 0x83, 0x75, 0xf2, 0x94, 0x84,
2524 0x99, 0x3f, 0x3b, 0x33, 0x67, 0x53, 0xae, 0xf0, 0x71, 0xb5, 0x48, 0xae,
2525 0x94, 0x51, 0xbb, 0x54, 0x17, 0xbe, 0x09, 0xb9, 0xea, 0x61, 0xbe, 0x0f,
2526 0x1b, 0x3f, 0x4e, 0xf9, 0xa2, 0xfe, 0x5b, 0x40, 0xee, 0xb3, 0x20, 0xc9,
2527 0xa0, 0x5e, 0x39, 0x8a, 0x3c, 0x1f, 0xf2, 0xab, 0x1d, 0x07, 0x0e, 0xd8,
2528 0x69, 0x6d, 0x05, 0x4f, 0xd4, 0x16, 0xb5, 0xd3, 0x78, 0x0e, 0xe0, 0xd9,
2529 0xa0, 0x6e, 0x86, 0xb9, 0xc6, 0x87, 0xe8, 0x81, 0x3d, 0x95, 0x68, 0x4f,
2530 0xf2, 0xfd, 0x66, 0x5e, 0xbe, 0xdb, 0x1c, 0x93, 0xe7, 0x9b, 0x39, 0xf9,
2531 0xbb, 0xa6, 0x23, 0xdf, 0x69, 0x8e, 0xc8, 0xb7, 0x9b, 0xc3, 0xac, 0xc9,
2532 0x90, 0x37, 0x65, 0x98, 0x37, 0xc9, 0xbd, 0xde, 0xad, 0xb0, 0x77, 0xca,
2533 0xff, 0xd2, 0x4c, 0xa1, 0x31, 0x28, 0xe5, 0x63, 0xf0, 0xcf, 0xce, 0xcd,
2534 0xac, 0x25, 0xe5, 0x11, 0x87, 0x35, 0x41, 0x1b, 0xdf, 0xa3, 0xce, 0x84,
2535 0xff, 0x86, 0x3f, 0x9b, 0x4a, 0x65, 0x4f, 0xbb, 0x46, 0x47, 0xe8, 0x03,
2536 0x6e, 0x49, 0x4a, 0x07, 0xf6, 0x82, 0x0f, 0x5c, 0x7a, 0x1a, 0x36, 0xa0,
2537 0x6a, 0x9a, 0x04, 0xfc, 0x0d, 0x73, 0x01, 0x93, 0x76, 0x8c, 0x3a, 0x30,
2538 0x9b, 0x71, 0x0d, 0xd6, 0x77, 0xb4, 0x67, 0x03, 0x81, 0x83, 0x70, 0xfb,
2539 0x2c, 0xca, 0xcd, 0xb4, 0xe9, 0x57, 0x0b, 0xa1, 0x8f, 0x4b, 0x84, 0x7a,
2540 0x69, 0x61, 0xfe, 0xf1, 0xd0, 0x27, 0x6f, 0xdc, 0x07, 0xf1, 0x02, 0xf9,
2541 0x64, 0xb0, 0x8e, 0xb0, 0x5a, 0x08, 0xdb, 0x17, 0xce, 0x75, 0x82, 0xdf,
2542 0x8e, 0x94, 0xbd, 0x37, 0x35, 0xe6, 0xd9, 0xc8, 0x77, 0x30, 0x1e, 0xc1,
2543 0xf8, 0x4a, 0x38, 0xfe, 0x9c, 0x4c, 0x2f, 0x0a, 0x68, 0xfd, 0x89, 0x56,
2544 0x54, 0xe3, 0x31, 0x8c, 0x75, 0x8c, 0x0d, 0xd6, 0x02, 0x68, 0x37, 0x27,
2545 0xa9, 0xeb, 0xba, 0x4d, 0x5f, 0x38, 0x19, 0xfa, 0xc3, 0x82, 0x1c, 0xf6,
2546 0x06, 0x0b, 0x57, 0x11, 0x33, 0xb4, 0xb6, 0x28, 0xff, 0xd9, 0x0e, 0xbe,
2547 0xf8, 0xfe, 0xed, 0xac, 0xb9, 0x93, 0xa6, 0x7c, 0x7b, 0x3e, 0x6b, 0x3d,
2548 0xa4, 0x7f, 0x0d, 0x67, 0xf2, 0xfd, 0x83, 0x76, 0xf6, 0xc8, 0x94, 0xde,
2549 0x25, 0xdf, 0x3d, 0xca, 0xd8, 0x7b, 0x76, 0xe6, 0x07, 0xd0, 0xbd, 0xfa,
2550 0x4a, 0xbb, 0xd4, 0xeb, 0xa6, 0x5c, 0x19, 0x1d, 0x04, 0x9d, 0x96, 0xd4,
2551 0x1b, 0x49, 0xe4, 0x73, 0x9b, 0x65, 0xb6, 0x5f, 0x19, 0x18, 0xfc, 0xf4,
2552 0xb0, 0xf2, 0xd3, 0xae, 0x8d, 0x67, 0xe3, 0xe7, 0x3d, 0xeb, 0xcf, 0x5c,
2553 0x02, 0xfd, 0xd0, 0xeb, 0xe4, 0x76, 0x25, 0xe7, 0xb2, 0x37, 0x68, 0x95,
2554 0x75, 0xc4, 0x2e, 0x73, 0xd0, 0xba, 0x57, 0xff, 0x2f, 0xff, 0xf3, 0x26,
2555 0x65, 0xf7, 0xaa, 0xaa, 0x61, 0x54, 0xac, 0xc3, 0x7e, 0x4b, 0x2b, 0x2f,
2556 0x83, 0x16, 0xf8, 0xd8, 0xc6, 0xf6, 0x70, 0x9c, 0x51, 0xbc, 0x38, 0xdb,
2557 0xe8, 0x90, 0xef, 0xd4, 0xb7, 0xc8, 0x72, 0x9d, 0xef, 0xdb, 0x65, 0xa9,
2558 0x3e, 0x78, 0xb5, 0x4f, 0xef, 0x97, 0xf3, 0xd7, 0x5c, 0x6f, 0xdd, 0xa3,
2559 0x23, 0x37, 0x98, 0xfc, 0x40, 0x7e, 0x39, 0xda, 0x23, 0x3f, 0xfe, 0x72,
2560 0xf6, 0x99, 0x3f, 0xd5, 0x61, 0x03, 0xa3, 0x9d, 0xb4, 0x6d, 0xf4, 0x39,
2561 0x9f, 0xbd, 0x5a, 0xd0, 0xa9, 0xdb, 0x3f, 0x02, 0x4f, 0xb3, 0x0b, 0x81,
2562 0x1d, 0x10, 0x37, 0xf1, 0x42, 0x37, 0xec, 0xef, 0x01, 0x27, 0xde, 0x35,
2563 0x06, 0x81, 0xeb, 0x7b, 0x8a, 0x17, 0xb7, 0x3b, 0xd9, 0xab, 0x08, 0x49,
2564 0xfe, 0x15, 0x7b, 0x70, 0x78, 0x87, 0xbe, 0x5d, 0xea, 0xe9, 0xeb, 0xad,
2565 0xe7, 0xe0, 0xff, 0x0b, 0xa9, 0xec, 0x91, 0xcb, 0x72, 0x76, 0xe6, 0xa2,
2566 0x4d, 0xfd, 0xa7, 0xdf, 0x78, 0x09, 0xb9, 0xa7, 0x25, 0x0b, 0x0d, 0xfa,
2567 0x4b, 0xe2, 0x62, 0xfe, 0xbf, 0xcb, 0x3a, 0xac, 0x33, 0x4f, 0xc0, 0x3b,
2568 0xcc, 0x1b, 0xbf, 0x4e, 0x39, 0xb7, 0x11, 0x76, 0xb8, 0xa0, 0xff, 0x62,
2569 0x03, 0x8f, 0x06, 0xad, 0xbd, 0x3a, 0xf7, 0xfb, 0x37, 0xec, 0xfb, 0x0e,
2570 0x68, 0x1d, 0x04, 0x2c, 0x62, 0x66, 0xba, 0x75, 0x8f, 0x57, 0xd4, 0x1e,
2571 0xc7, 0x1a, 0xc8, 0xf5, 0x56, 0xf7, 0xc0, 0x5c, 0x43, 0xc7, 0x39, 0x4d,
2572 0x25, 0x97, 0x2b, 0xa3, 0xe4, 0xef, 0x9e, 0x5e, 0xe6, 0x99, 0x46, 0xfe,
2573 0xaf, 0xfd, 0xa8, 0x7e, 0x7c, 0x7e, 0x7e, 0x12, 0xfe, 0xd9, 0xf7, 0x2f,
2574 0xec, 0x1a, 0x04, 0x0d, 0xa8, 0x43, 0xd3, 0xe4, 0xf9, 0xd9, 0x19, 0x17,
2575 0x38, 0x8a, 0x0a, 0xf7, 0x25, 0x59, 0x01, 0xee, 0x09, 0xf2, 0x01, 0xb8,
2576 0xe7, 0x38, 0xaf, 0x64, 0x80, 0xf9, 0x46, 0x06, 0x78, 0x23, 0xfd, 0x4c,
2577 0x42, 0xd7, 0x76, 0x5b, 0xb7, 0x07, 0xba, 0x9e, 0x60, 0x6c, 0x7b, 0x0e,
2578 0xba, 0x57, 0x48, 0x52, 0x7f, 0xda, 0x7b, 0xd7, 0xf4, 0xa7, 0x15, 0x7f,
2579 0xbb, 0x94, 0x16, 0x12, 0xc0, 0x6b, 0xca, 0x5c, 0x8e, 0x78, 0x31, 0xae,
2580 0x53, 0xf7, 0x2b, 0xa1, 0xee, 0x77, 0x86, 0xb8, 0x17, 0xc1, 0x93, 0x6c,
2581 0xa6, 0xae, 0xb3, 0x8e, 0xda, 0xa6, 0x6a, 0x5b, 0x03, 0x36, 0x5d, 0xae,
2582 0xb1, 0x0e, 0xe5, 0xfd, 0xc8, 0xa5, 0x99, 0x69, 0xd4, 0xaa, 0xe5, 0xda,
2583 0x88, 0x56, 0x6e, 0xda, 0x5a, 0xd9, 0xa3, 0xbe, 0xed, 0xb2, 0x2e, 0x28,
2584 0x1e, 0xa7, 0x65, 0xa9, 0xf9, 0x4b, 0xbf, 0xba, 0x6b, 0x13, 0xfa, 0xd0,
2585 0xfd, 0x09, 0xca, 0xf7, 0xb3, 0xa4, 0x0b, 0x41, 0x9c, 0xfc, 0x4e, 0xc9,
2586 0xc9, 0x21, 0x14, 0xbd, 0xc8, 0xad, 0x4e, 0x0d, 0x11, 0x3f, 0xe8, 0x48,
2587 0xa5, 0x64, 0xd9, 0xe3, 0x1e, 0x67, 0x67, 0xc8, 0xcb, 0xf2, 0x71, 0x4b,
2588 0x0e, 0x2b, 0xf9, 0xbd, 0xac, 0x6c, 0xbb, 0xbc, 0x62, 0xc8, 0x74, 0x72,
2589 0xd0, 0x7a, 0x58, 0xb2, 0x57, 0x2f, 0x18, 0xd9, 0x67, 0xa6, 0x60, 0xd7,
2590 0x4b, 0x8b, 0x86, 0xb8, 0xaa, 0xde, 0xa2, 0x8c, 0xb2, 0x0b, 0xb0, 0xfc,
2591 0xf0, 0xec, 0x7b, 0x5b, 0xce, 0xde, 0x2d, 0x2b, 0x4f, 0xff, 0x26, 0x7c,
2592 0xce, 0x01, 0xc8, 0xc2, 0xcc, 0x1c, 0x42, 0x5e, 0xf1, 0xb4, 0x0c, 0x5a,
2593 0x55, 0xe4, 0xc9, 0xe0, 0x3b, 0xda, 0x01, 0x65, 0x03, 0x17, 0x74, 0x8c,
2594 0x07, 0xc8, 0x27, 0x8e, 0xaf, 0x95, 0x0b, 0xca, 0x96, 0xd2, 0xea, 0xdd,
2595 0x0e, 0xe0, 0x08, 0xde, 0x71, 0xfc, 0x19, 0xd9, 0xa1, 0xde, 0xdd, 0xa9,
2596 0xde, 0x55, 0xe9, 0x2b, 0x94, 0xfc, 0xbe, 0x82, 0x3d, 0xc9, 0xe3, 0x68,
2597 0xbe, 0x4b, 0x02, 0x5b, 0x8a, 0xf8, 0x6e, 0xc9, 0xc1, 0x46, 0x4a, 0xbe,
2598 0x84, 0xfa, 0xe7, 0x8e, 0xc6, 0x80, 0x94, 0x20, 0xc7, 0xe9, 0xdc, 0x83,
2599 0xbd, 0x3c, 0x5b, 0x71, 0x25, 0xfb, 0x8c, 0xe8, 0xa4, 0xf5, 0x4e, 0x39,
2600 0xe4, 0x45, 0xf4, 0x74, 0x86, 0xf4, 0x4d, 0x86, 0xe3, 0x44, 0x48, 0x43,
2601 0x2b, 0xbe, 0x4e, 0xe0, 0x42, 0xac, 0xcf, 0x79, 0x21, 0x1e, 0xfa, 0x11,
2602 0xd0, 0x3a, 0x99, 0x96, 0x15, 0x8f, 0x74, 0x6c, 0x91, 0x6a, 0x8a, 0xfd,
2603 0x03, 0xd0, 0x37, 0xe2, 0xd9, 0xc4, 0x7c, 0x66, 0x1d, 0x8f, 0x1f, 0x6c,
2604 0x54, 0xc0, 0x63, 0xf2, 0x97, 0xeb, 0x10, 0x23, 0x3e, 0x47, 0xf9, 0xed,
2605 0x46, 0x2e, 0x6f, 0x07, 0xba, 0x69, 0xad, 0xed, 0x59, 0x3a, 0xde, 0x0d,
2606 0x59, 0x71, 0xdf, 0x0e, 0x99, 0x84, 0xdd, 0x17, 0xeb, 0xdc, 0x7f, 0x12,
2607 0x7a, 0x74, 0x51, 0xed, 0x5f, 0x5a, 0xe9, 0x0f, 0xe1, 0x09, 0xdb, 0xbd,
2608 0x01, 0xb6, 0x5d, 0xf6, 0x2e, 0x58, 0x1f, 0x01, 0xff, 0xbb, 0x80, 0xd7,
2609 0xe5, 0x44, 0x8e, 0xf0, 0xc4, 0x83, 0x75, 0xf5, 0xd4, 0x27, 0xe0, 0x49,
2610 0xaa, 0xba, 0xbe, 0x58, 0x6f, 0x97, 0xe2, 0x42, 0x84, 0x8b, 0x78, 0x3e,
2611 0x40, 0xdd, 0x7b, 0xb7, 0xc2, 0x35, 0xad, 0x70, 0xe1, 0x7d, 0x9d, 0x3e,
2612 0xe7, 0x26, 0xc0, 0xa3, 0x76, 0xb7, 0x41, 0x5b, 0xb2, 0x4b, 0xaa, 0xaa,
2613 0x76, 0xef, 0x50, 0xbe, 0xa6, 0x9a, 0xdc, 0x8c, 0xf7, 0x3e, 0xf6, 0xdc,
2614 0x8d, 0x7c, 0xa6, 0x1b, 0x73, 0x99, 0x0d, 0x73, 0x1b, 0xe9, 0x4f, 0x6c,
2615 0xa0, 0xff, 0xbf, 0x7b, 0x19, 0x52, 0xe6, 0x72, 0xc1, 0xba, 0x12, 0xd6,
2616 0xcd, 0x1e, 0x87, 0x4d, 0x30, 0x4f, 0x4f, 0x31, 0x36, 0x5f, 0xa3, 0x68,
2617 0x99, 0x5d, 0xf9, 0x29, 0xd6, 0xf5, 0x03, 0x36, 0x1a, 0x07, 0x7c, 0x78,
2618 0x0a, 0x78, 0x8e, 0xd7, 0xd5, 0x1d, 0x05, 0x64, 0xf0, 0xbe, 0x3a, 0x7b,
2619 0xb5, 0xfe, 0x69, 0x3c, 0xbb, 0xa6, 0x85, 0x5f, 0xe4, 0x15, 0xe9, 0x25,
2620 0xad, 0xbc, 0x2f, 0x82, 0xbd, 0x39, 0xd0, 0xe3, 0xa4, 0x21, 0xa5, 0x1c,
2621 0xe2, 0xba, 0xc7, 0xbb, 0x57, 0xda, 0xe5, 0x40, 0x50, 0x23, 0xd8, 0x8c,
2622 0xef, 0xa6, 0x3a, 0xfb, 0xa1, 0x15, 0xde, 0xbf, 0x66, 0x78, 0x47, 0x37,
2623 0x8c, 0xda, 0x5b, 0x1e, 0x5a, 0xb1, 0xe5, 0x6b, 0x8d, 0x61, 0x79, 0xb8,
2624 0x91, 0xb5, 0xee, 0x81, 0x0f, 0x28, 0xaf, 0xde, 0xcb, 0x6e, 0x4b, 0xd2,
2625 0x7f, 0x99, 0xc8, 0x3d, 0xdb, 0xec, 0x20, 0x17, 0xa9, 0xb2, 0x36, 0x3b,
2626 0x9e, 0xe5, 0x7d, 0x8d, 0x55, 0x97, 0x8d, 0xf9, 0xca, 0xff, 0x65, 0xae,
2627 0xc2, 0xfd, 0xe9, 0xaf, 0x91, 0x9b, 0x78, 0xc8, 0x4d, 0x3c, 0xe4, 0x26,
2628 0x1e, 0x72, 0x13, 0x0f, 0xb9, 0x89, 0x87, 0xdc, 0xc4, 0x43, 0x6e, 0xe2,
2629 0x21, 0x37, 0x41, 0x1d, 0x10, 0xd4, 0x07, 0xe3, 0xc8, 0xb9, 0xe1, 0xbf,
2630 0xbc, 0x5b, 0xc2, 0xdc, 0x22, 0x8a, 0xcd, 0x9c, 0x3b, 0xbf, 0xc9, 0x0d,
2631 0xea, 0x2b, 0xe5, 0x13, 0x0a, 0xcd, 0x89, 0x30, 0x07, 0xe2, 0x9a, 0x28,
2632 0x76, 0x73, 0x9d, 0x8c, 0xb9, 0xa8, 0x3d, 0x0b, 0x93, 0xcc, 0x91, 0x82,
2633 0x98, 0x15, 0xe4, 0xe7, 0xaf, 0x22, 0x4f, 0xca, 0x20, 0x4f, 0x1a, 0x40,
2634 0x4e, 0xc4, 0x7b, 0xea, 0xe8, 0x2e, 0xa9, 0xa0, 0x1d, 0xf4, 0xc6, 0xb5,
2635 0x2f, 0x79, 0xcc, 0xdf, 0xed, 0x4c, 0x59, 0xd7, 0x8f, 0xf7, 0x89, 0x2f,
2636 0xc5, 0xd1, 0xaf, 0x23, 0x57, 0xfe, 0x4b, 0x75, 0x6f, 0x36, 0x31, 0x44,
2637 0x99, 0xdf, 0xf7, 0x31, 0xf9, 0x72, 0xc4, 0xdf, 0xe0, 0xbe, 0x4f, 0x5f,
2638 0x22, 0xff, 0x44, 0x7a, 0xcf, 0x80, 0xe1, 0x67, 0x12, 0x92, 0x3c, 0xb9,
2639 0x05, 0x73, 0x96, 0xf4, 0xa9, 0x3b, 0x23, 0x88, 0xf2, 0xcc, 0x7f, 0x40,
2640 0x5e, 0xb6, 0xe8, 0x67, 0x78, 0xb3, 0x40, 0xbc, 0xf4, 0xaf, 0xf5, 0x99,
2641 0x62, 0xbd, 0xae, 0x74, 0xea, 0x60, 0xa3, 0x84, 0x3c, 0xca, 0xe8, 0x93,
2642 0x0e, 0x13, 0xb5, 0x54, 0x84, 0x9b, 0x38, 0xdf, 0x4c, 0xaa, 0x1a, 0xe7,
2643 0xcc, 0xaa, 0x3c, 0x21, 0x6b, 0xee, 0x53, 0x9f, 0xa9, 0x2e, 0x64, 0xd3,
2644 0xac, 0x71, 0x0b, 0x56, 0x7d, 0xe6, 0x49, 0xe0, 0x58, 0x46, 0x6e, 0x60,
2645 0xa8, 0xbd, 0xeb, 0x33, 0xb3, 0x0b, 0xc1, 0xbd, 0x55, 0x40, 0x03, 0xe3,
2646 0x55, 0x87, 0x18, 0x4b, 0xc1, 0xfd, 0x95, 0xae, 0x60, 0x09, 0x47, 0x78,
2647 0x13, 0x70, 0x94, 0xdb, 0x30, 0x60, 0x29, 0x3b, 0xd2, 0x50, 0x9f, 0xa9,
2648 0xd4, 0x5b, 0x69, 0x20, 0x1e, 0xe2, 0x8d, 0xce, 0xc3, 0xb3, 0x24, 0x45,
2649 0x3f, 0xe9, 0xfb, 0xe5, 0xd1, 0x81, 0xb0, 0xae, 0x44, 0x1d, 0x79, 0xcc,
2650 0x0c, 0xf4, 0x5c, 0x8d, 0xff, 0x58, 0xc5, 0xa9, 0x8c, 0xce, 0x79, 0x3e,
2651 0xf1, 0x2e, 0xf7, 0x28, 0xe6, 0x30, 0x5e, 0x8e, 0xd6, 0xea, 0xe1, 0xda,
2652 0xae, 0x16, 0x7e, 0xb6, 0x85, 0xfb, 0x91, 0x26, 0x9e, 0xf3, 0x15, 0xec,
2653 0x45, 0xba, 0xb8, 0xc6, 0x04, 0x6d, 0x90, 0xa5, 0xf7, 0xbf, 0xe5, 0x7d,
2654 0xeb, 0x99, 0xc8, 0x53, 0x13, 0x30, 0x5c, 0x4f, 0x1c, 0x11, 0x0c, 0x5e,
2655 0x9c, 0x09, 0xe0, 0xf4, 0xd5, 0x7b, 0xbe, 0x4f, 0xda, 0xb7, 0x95, 0xd6,
2656 0x68, 0xff, 0x08, 0xcf, 0x70, 0x20, 0xb7, 0x55, 0x78, 0xf5, 0x7f, 0x7f,
2657 0xe1, 0x09, 0x5d, 0xfc, 0xd0, 0x7d, 0xe9, 0x70, 0x4b, 0x8d, 0x1c, 0xdd,
2658 0x3b, 0xb0, 0xfe, 0x67, 0x3d, 0xcf, 0xef, 0x03, 0xad, 0xf5, 0x69, 0x29,
2659 0x8c, 0x65, 0xdb, 0xa4, 0x60, 0xb2, 0x56, 0x19, 0x0f, 0xc7, 0x5b, 0x11,
2660 0xdb, 0x38, 0xbe, 0x15, 0xfc, 0x85, 0x2e, 0x3b, 0x1d, 0x61, 0xad, 0x94,
2661 0x0c, 0xbe, 0xeb, 0x0c, 0xd3, 0x8e, 0x58, 0x6b, 0x6e, 0x0e, 0xe7, 0x22,
2662 0x3b, 0xa2, 0x1f, 0x36, 0xc3, 0x39, 0xfa, 0x5b, 0x1d, 0xf5, 0x12, 0xfb,
2663 0xc0, 0xb3, 0xdc, 0x6a, 0x4b, 0xd1, 0x33, 0x29, 0xa7, 0x17, 0x23, 0xbf,
2664 0x05, 0x9f, 0x32, 0x64, 0x86, 0xbe, 0xbf, 0x13, 0xbe, 0xaf, 0x5b, 0xf6,
2665 0xc2, 0x67, 0xed, 0x83, 0xcf, 0xda, 0x8f, 0x1a, 0x75, 0x7c, 0xa5, 0xf5,
2666 0x3e, 0x97, 0x75, 0x71, 0x55, 0x0e, 0x29, 0xf9, 0x57, 0x7c, 0xc3, 0xfe,
2667 0x00, 0x3a, 0xb0, 0x53, 0xe5, 0x7b, 0x81, 0x4e, 0xc0, 0xdf, 0x3a, 0x49,
2668 0xe8, 0xc4, 0xc6, 0x7b, 0xe3, 0x61, 0xd8, 0x46, 0x47, 0x41, 0xc5, 0x86,
2669 0x95, 0x80, 0xf7, 0xd5, 0x7a, 0xc0, 0x7b, 0xf8, 0x65, 0xe0, 0x37, 0xa5,
2670 0xd2, 0xb0, 0xa4, 0x82, 0x7d, 0x2b, 0xd8, 0xb7, 0x82, 0xda, 0x72, 0xb6,
2671 0xd1, 0xfa, 0xed, 0xaa, 0x2b, 0xa4, 0x9d, 0xb0, 0x51, 0xdf, 0x6a, 0x39,
2672 0x7f, 0xf4, 0x3c, 0x02, 0xfe, 0x3f, 0x02, 0xfe, 0x1f, 0x46, 0x4d, 0xf5,
2673 0x00, 0x6a, 0xaa, 0xfb, 0x50, 0x53, 0x1d, 0x42, 0x4d, 0x35, 0x85, 0x9a,
2674 0xea, 0x6e, 0xf8, 0x8f, 0x3b, 0xe1, 0x3f, 0x26, 0xe1, 0x3f, 0x26, 0xd4,
2675 0x9d, 0xd1, 0x41, 0x6f, 0xe3, 0x1d, 0x4a, 0xb4, 0x17, 0xdb, 0x1b, 0x22,
2676 0x50, 0x81, 0xf2, 0xb1, 0x71, 0xa9, 0x37, 0x59, 0x5b, 0x39, 0xea, 0x3e,
2677 0x6c, 0xda, 0x99, 0xd4, 0xa6, 0x90, 0xbf, 0xdf, 0x33, 0xc2, 0x9a, 0x2b,
2678 0xa9, 0x15, 0x55, 0xcd, 0x95, 0x7d, 0xc1, 0x45, 0x8a, 0x84, 0xdc, 0x0f,
2679 0x67, 0xce, 0x9e, 0x2e, 0x1a, 0x51, 0xbd, 0xd3, 0xbb, 0x5a, 0xef, 0x2c,
2680 0xcf, 0xb3, 0xde, 0x79, 0x75, 0xb5, 0xde, 0x59, 0x9e, 0x67, 0xbd, 0xf3,
2681 0xca, 0xba, 0x7a, 0xe7, 0xca, 0xd3, 0x97, 0xd6, 0xd5, 0x3b, 0x57, 0x9e,
2682 0x7e, 0x29, 0x1c, 0x4b, 0xa8, 0x0f, 0x21, 0xad, 0x96, 0x83, 0x67, 0x4f,
2683 0x98, 0x73, 0x34, 0xfb, 0xd6, 0xff, 0xdf, 0x74, 0xca, 0x96, 0x35, 0xb1,
2684 0xff, 0x68, 0x6b, 0x50, 0x23, 0xb5, 0xce, 0x77, 0xb7, 0xcc, 0x5f, 0x56,
2685 0xdf, 0x4b, 0xcb, 0xb5, 0xcd, 0xef, 0xc2, 0x03, 0xcb, 0xca, 0x10, 0xf3,
2686 0xbc, 0x0f, 0x7c, 0x7e, 0xf3, 0x73, 0xf5, 0x0e, 0xf5, 0xcd, 0xcd, 0x55,
2687 0xf9, 0x36, 0xec, 0x7c, 0xf4, 0xd1, 0xad, 0x81, 0x2f, 0x60, 0x3f, 0xa5,
2688 0x05, 0xfe, 0xfd, 0x01, 0xe0, 0x01, 0xaf, 0x3d, 0x53, 0xdd, 0x07, 0x05,
2689 0xe7, 0x0d, 0xee, 0xc6, 0xcd, 0xfc, 0xe5, 0x19, 0xe6, 0xd6, 0x55, 0x85,
2690 0x9b, 0xf5, 0x23, 0x6b, 0xce, 0x28, 0x06, 0x44, 0xb8, 0x5e, 0x4d, 0x05,
2691 0x74, 0xbb, 0xa8, 0x1d, 0xb9, 0x26, 0x1a, 0xb7, 0xd6, 0x9a, 0x9d, 0xe1,
2692 0xbd, 0xdb, 0xe5, 0x20, 0xaf, 0x52, 0xf8, 0xcc, 0x10, 0xdf, 0xcf, 0xfd,
2693 0xc0, 0xf7, 0x10, 0xde, 0x6a, 0x81, 0x1f, 0x47, 0xae, 0xc7, 0x7b, 0x1a,
2694 0xe6, 0x6c, 0xa6, 0xbc, 0x33, 0xdf, 0x25, 0xff, 0x79, 0xd4, 0xf7, 0x27,
2695 0x9c, 0xec, 0xf0, 0x25, 0xd4, 0x1e, 0x27, 0x69, 0x27, 0xa3, 0xa4, 0x73,
2696 0x30, 0x33, 0x2b, 0xa9, 0x3e, 0xd2, 0x72, 0x5e, 0x3f, 0xac, 0x7d, 0x98,
2697 0x6e, 0x3d, 0xdc, 0xe7, 0x1f, 0x5b, 0xf6, 0xc9, 0xb4, 0xec, 0x53, 0xa0,
2698 0xcd, 0xd6, 0xef, 0xc0, 0x99, 0x2b, 0xdb, 0xaf, 0xb7, 0x52, 0x61, 0x5d,
2699 0xf6, 0xf0, 0xe8, 0x66, 0x59, 0xe8, 0xcf, 0x9e, 0x7d, 0x05, 0xf9, 0x7a,
2700 0x79, 0x14, 0x73, 0xa9, 0x41, 0xbc, 0xe3, 0x7c, 0xb6, 0x8e, 0x5c, 0xf4,
2701 0x6c, 0x5d, 0xb6, 0x01, 0x3e, 0x5b, 0x11, 0xe1, 0x3c, 0xfb, 0x8a, 0xb6,
2702 0x7a, 0xe8, 0x03, 0xd2, 0x17, 0x70, 0xe6, 0x29, 0xd4, 0x5f, 0x87, 0x83,
2703 0x7b, 0xb4, 0x70, 0x9f, 0x1b, 0xb5, 0x20, 0x6f, 0xce, 0x69, 0x95, 0xf0,
2704 0x0e, 0xf0, 0x2b, 0xf0, 0x17, 0x86, 0x4e, 0xd8, 0x77, 0x80, 0x5b, 0x93,
2705 0xa5, 0xa3, 0x86, 0xba, 0x3b, 0x2d, 0x8f, 0x52, 0xd6, 0x7c, 0x7e, 0x14,
2706 0xef, 0xa2, 0x33, 0xfd, 0x4d, 0x78, 0xa6, 0xd1, 0xb0, 0x6e, 0x8f, 0xce,
2707 0x94, 0x90, 0xd7, 0xe7, 0x2d, 0xc0, 0x8e, 0x80, 0x1f, 0x25, 0x59, 0x69,
2708 0x66, 0x3e, 0x05, 0x4f, 0xad, 0x85, 0x37, 0xe6, 0x06, 0x19, 0x46, 0x75,
2709 0x0f, 0x78, 0x30, 0x91, 0x86, 0x1d, 0xde, 0xd7, 0x17, 0xdd, 0xe9, 0x1a,
2710 0xb6, 0xae, 0x05, 0x75, 0x3c, 0xe7, 0x07, 0x60, 0x8b, 0x19, 0xd8, 0x27,
2711 0x73, 0xa6, 0x12, 0x6b, 0x15, 0xda, 0x93, 0xe5, 0x1a, 0x59, 0x6b, 0x52,
2712 0x86, 0x51, 0xef, 0xf0, 0xfc, 0x79, 0x59, 0x6e, 0x46, 0x34, 0xe4, 0x60,
2713 0x8f, 0x63, 0xf8, 0x8d, 0xe0, 0x9d, 0x83, 0x1f, 0x6b, 0xa5, 0x82, 0x7c,
2714 0x55, 0xe5, 0xe2, 0xc8, 0xb5, 0x87, 0x48, 0xdf, 0x01, 0xac, 0xa7, 0x3e,
2715 0x53, 0x4f, 0x0f, 0x88, 0xdb, 0x4f, 0x5f, 0x91, 0x06, 0x6e, 0xc0, 0x78,
2716 0xaf, 0xc1, 0xd6, 0x07, 0xf0, 0xcc, 0x5a, 0x65, 0xf2, 0x56, 0xe1, 0xf7,
2717 0x7d, 0x23, 0xc7, 0x6f, 0x11, 0xe3, 0xe1, 0x78, 0xd0, 0xfa, 0x1d, 0xea,
2718 0x5e, 0xfa, 0x5a, 0x39, 0xbb, 0x18, 0xc5, 0xc1, 0x19, 0xd8, 0x20, 0xef,
2719 0x68, 0xc7, 0xc1, 0x17, 0x8e, 0xb5, 0x30, 0x1e, 0x62, 0x7e, 0xf9, 0xaf,
2720 0x70, 0xee, 0xbc, 0x9c, 0x44, 0xfd, 0x2f, 0xfd, 0x7c, 0x66, 0x80, 0x7f,
2721 0x4b, 0xa8, 0xef, 0xeb, 0xe1, 0x0d, 0x9b, 0xfd, 0x71, 0xd0, 0x67, 0xb6,
2722 0xc0, 0x13, 0x26, 0xac, 0x4f, 0x04, 0xf1, 0x38, 0xed, 0xdf, 0xaa, 0xe7,
2723 0xef, 0x96, 0x3f, 0x50, 0x67, 0xca, 0xcb, 0xa1, 0x45, 0xdf, 0x77, 0x73,
2724 0x83, 0xc3, 0xcb, 0x92, 0x1d, 0x7e, 0x52, 0x76, 0x5b, 0x7b, 0x59, 0x8f,
2725 0x59, 0xc4, 0xe3, 0xdf, 0xda, 0x96, 0xf7, 0xfd, 0x13, 0xa0, 0xfd, 0x07,
2726 0x6a, 0x9f, 0xbb, 0x41, 0x3f, 0x78, 0xa5, 0x6a, 0x12, 0xd2, 0x0a, 0xde,
2727 0xa4, 0x48, 0x6f, 0xa7, 0x1c, 0x6a, 0x3e, 0x1f, 0xca, 0xe6, 0x11, 0x71,
2728 0xbd, 0xb7, 0x0d, 0xde, 0x6f, 0x97, 0x9b, 0x8f, 0x86, 0xb4, 0xe5, 0x41,
2729 0x2f, 0xf6, 0x6f, 0xfe, 0x43, 0x8a, 0xbe, 0x81, 0x32, 0x77, 0x91, 0x35,
2730 0xba, 0xa3, 0xcf, 0x40, 0x07, 0x3f, 0xce, 0x0f, 0x24, 0x65, 0xbd, 0x1f,
2731 0x20, 0x5c, 0xf2, 0x23, 0x74, 0x85, 0x74, 0x88, 0xf2, 0x9f, 0x2a, 0x6e,
2732 0x29, 0x7c, 0xc6, 0x06, 0x5f, 0xf0, 0xa4, 0x7a, 0x9e, 0x37, 0xe8, 0x9b,
2733 0x18, 0xff, 0xa8, 0xc3, 0xdd, 0xf0, 0x7f, 0xd0, 0x41, 0xd8, 0x71, 0x71,
2734 0x91, 0xf7, 0x13, 0x43, 0xea, 0x4e, 0xab, 0x04, 0xd9, 0x2e, 0xf1, 0x3b,
2735 0x63, 0x2a, 0xc8, 0x27, 0x83, 0xfa, 0x2b, 0x43, 0x5f, 0x88, 0xf6, 0xb8,
2736 0xf2, 0x93, 0x25, 0xf5, 0x5d, 0x31, 0x89, 0x35, 0x3e, 0x9e, 0xad, 0x7f,
2737 0x27, 0xf1, 0xa3, 0x42, 0xf0, 0x77, 0x12, 0xe1, 0x37, 0xde, 0x7a, 0x90,
2738 0x47, 0x3c, 0xd8, 0x30, 0x65, 0xaa, 0x11, 0xfd, 0xdd, 0x04, 0xe5, 0x60,
2739 0x4b, 0xb9, 0x11, 0xe5, 0x0e, 0x7e, 0x50, 0xd3, 0xac, 0x93, 0xe5, 0xe3,
2740 0x61, 0x4e, 0xc4, 0x1a, 0x80, 0x3c, 0xc4, 0x78, 0x39, 0x90, 0xdf, 0x92,
2741 0xbe, 0x03, 0xf2, 0x03, 0xcf, 0x3d, 0x13, 0xb6, 0x94, 0x0e, 0xe3, 0xba,
2742 0xc5, 0x1a, 0x33, 0xac, 0x7b, 0xb7, 0x4b, 0x75, 0x92, 0xef, 0x13, 0xf2,
2743 0xda, 0xfc, 0x40, 0x70, 0x4f, 0x24, 0x89, 0xf0, 0x3d, 0xc7, 0x49, 0x29,
2744 0xab, 0xf7, 0x77, 0x86, 0xf8, 0x50, 0xa7, 0xdd, 0x19, 0x8d, 0xd3, 0x90,
2745 0x63, 0x00, 0x37, 0x8d, 0x58, 0xf6, 0x55, 0xc4, 0xb1, 0x69, 0xf0, 0xbd,
2746 0x38, 0x51, 0x91, 0x6b, 0x6d, 0x4b, 0xc5, 0x7d, 0x37, 0x49, 0x1d, 0xa3,
2747 0x7e, 0x11, 0xa6, 0x07, 0xb9, 0x2a, 0xce, 0x3b, 0x2a, 0x53, 0x46, 0xfe,
2748 0xdd, 0xdb, 0xca, 0xb5, 0xac, 0x55, 0x90, 0xf7, 0x7d, 0xd7, 0xe4, 0xf8,
2749 0xfc, 0x6d, 0x0f, 0x06, 0x77, 0xfe, 0xba, 0x9e, 0xbf, 0x78, 0x5b, 0x39,
2750 0xe8, 0xe3, 0xcc, 0xef, 0x86, 0x7d, 0xc2, 0x19, 0xea, 0x7b, 0xec, 0x4f,
2751 0x6e, 0x32, 0xe5, 0xc2, 0x4d, 0xbe, 0x7f, 0x0f, 0xbf, 0x09, 0x85, 0x75,
2752 0xac, 0xa5, 0xea, 0xd8, 0x0e, 0x95, 0x8f, 0xb8, 0xa3, 0x19, 0xad, 0x04,
2753 0xdb, 0x3d, 0xe9, 0xa1, 0xe6, 0xd1, 0xb3, 0x63, 0xe7, 0x75, 0x0b, 0xf1,
2754 0x37, 0x9b, 0x39, 0x2e, 0xb9, 0x3e, 0x7e, 0x63, 0x9e, 0x73, 0xb8, 0x66,
2755 0x5b, 0x70, 0xef, 0x75, 0x83, 0xab, 0x7c, 0xae, 0x48, 0x18, 0x87, 0x6e,
2756 0x68, 0xb5, 0x8f, 0xd6, 0x3c, 0x93, 0x76, 0x21, 0x53, 0x26, 0xe8, 0xa9,
2757 0xd6, 0xa2, 0x9c, 0x8d, 0x7f, 0x0f, 0x70, 0xfe, 0xb6, 0xa7, 0x1a, 0x17,
2758 0x6f, 0x9b, 0x85, 0x7c, 0x78, 0xa6, 0xd9, 0x46, 0xa4, 0x7f, 0x51, 0xdd,
2759 0xc0, 0x3e, 0xe2, 0xbf, 0x87, 0xf8, 0xef, 0x21, 0xfe, 0x7b, 0x88, 0xff,
2760 0x1e, 0xe2, 0xbf, 0x87, 0xf8, 0x0f, 0x1e, 0x3e, 0x07, 0x7d, 0x79, 0xd6,
2761 0x9b, 0x08, 0x73, 0xb6, 0xc7, 0x56, 0x73, 0x36, 0xfe, 0xcd, 0xcb, 0xb9,
2762 0xa6, 0xa2, 0xa5, 0x52, 0x91, 0x20, 0xe7, 0x15, 0x9d, 0xf9, 0x4d, 0x94,
2763 0xf3, 0x7e, 0xf4, 0xf7, 0x90, 0x00, 0x8e, 0xf9, 0x1e, 0xe1, 0x2a, 0x9a,
2764 0x6e, 0x13, 0x2e, 0xc8, 0xf9, 0x58, 0x67, 0xad, 0x87, 0xe1, 0x77, 0x37,
2765 0xfa, 0xb6, 0xe0, 0x9b, 0x4f, 0xf0, 0x7d, 0xa9, 0x76, 0x87, 0x8b, 0x58,
2766 0x5c, 0x6e, 0xa8, 0x78, 0x8c, 0x71, 0xe3, 0x0e, 0xfe, 0xad, 0x02, 0x64,
2767 0xc0, 0x77, 0x5f, 0x66, 0x6d, 0x51, 0x6e, 0x20, 0x2f, 0x5a, 0x8e, 0x72,
2768 0x21, 0xc0, 0x79, 0x6f, 0x6a, 0xa5, 0x05, 0xca, 0x59, 0x97, 0xd9, 0x14,
2769 0x98, 0x62, 0xb7, 0xe6, 0x78, 0x97, 0x54, 0xbd, 0x74, 0xb6, 0x49, 0x7a,
2770 0x46, 0x40, 0x5b, 0x74, 0x8f, 0x2c, 0x62, 0xcc, 0xa7, 0x44, 0x9f, 0x47,
2771 0x7e, 0x6b, 0x0f, 0xa9, 0xbf, 0x6f, 0xe8, 0xc5, 0x3e, 0xfa, 0xfc, 0x8e,
2772 0x96, 0x7b, 0x5a, 0x29, 0x04, 0x3e, 0x9b, 0xb1, 0x87, 0xe7, 0x48, 0xc1,
2773 0x76, 0xdd, 0x6d, 0x38, 0x1b, 0xe4, 0xfa, 0xaf, 0x5b, 0x55, 0x0e, 0x0e,
2774 0x3f, 0x7a, 0x62, 0xa8, 0xbf, 0x5f, 0xba, 0xb7, 0xcb, 0xc9, 0x21, 0xd6,
2775 0x6b, 0x9b, 0x81, 0x8f, 0x6b, 0x79, 0xff, 0xb4, 0x5d, 0x4e, 0x2d, 0xc2,
2776 0xcf, 0x2e, 0x66, 0x1d, 0xea, 0xf2, 0xd2, 0x50, 0x0a, 0xfe, 0xf9, 0xe6,
2777 0x7e, 0xc6, 0xe7, 0xe5, 0x26, 0x75, 0xa5, 0x17, 0xf0, 0x03, 0xd0, 0xcb,
2778 0x4d, 0xb0, 0x27, 0x1d, 0xfb, 0x47, 0xb8, 0xff, 0x45, 0xe1, 0xee, 0xb5,
2779 0x9d, 0x6d, 0x4a, 0x37, 0xf4, 0xac, 0x95, 0xd1, 0x41, 0xfb, 0xff, 0x14,
2780 0x6e, 0x6d, 0x31, 0x71, 0x5c, 0x67, 0xf8, 0x3f, 0xb3, 0xdc, 0x8c, 0xd7,
2781 0x30, 0x86, 0xf5, 0xb2, 0x58, 0xae, 0xba, 0x03, 0x63, 0x33, 0xd1, 0x62,
2782 0x65, 0xb0, 0xec, 0x16, 0x55, 0x96, 0xba, 0xda, 0x05, 0x42, 0xe2, 0x3a,
2783 0xdd, 0x24, 0xb4, 0x72, 0xd5, 0x2a, 0x42, 0x60, 0x37, 0x8e, 0xfa, 0xd2,
2784 0x46, 0x55, 0xdb, 0x37, 0xaf, 0x16, 0xec, 0x38, 0xcd, 0xac, 0x17, 0x37,
2785 0x38, 0xf4, 0x71, 0xb3, 0x2c, 0x0e, 0x90, 0x75, 0x56, 0x6e, 0xf2, 0x90,
2786 0x3e, 0x19, 0x6d, 0xa2, 0x24, 0x55, 0xa5, 0xbc, 0x54, 0x7d, 0xab, 0x5a,
2787 0x0b, 0x27, 0xc4, 0x0f, 0xa9, 0xad, 0xf6, 0xa5, 0x77, 0x4d, 0xbf, 0xef,
2788 0xcc, 0x2c, 0xc6, 0xa4, 0x51, 0x91, 0x56, 0x73, 0xe6, 0xcc, 0xb9, 0x9f,
2789 0xff, 0xf2, 0xfd, 0x17, 0x3e, 0x67, 0x67, 0xba, 0xc2, 0xbd, 0xcd, 0x95,
2790 0x76, 0xc6, 0xfe, 0xb6, 0xd4, 0xcc, 0x02, 0xf3, 0x1a, 0x86, 0x64, 0xdc,
2791 0x64, 0xae, 0xcf, 0x96, 0x3a, 0x57, 0x66, 0x1b, 0x1b, 0x65, 0xda, 0xe4,
2792 0x4b, 0x6a, 0xa6, 0xdc, 0x23, 0x17, 0x41, 0xc7, 0x85, 0xe1, 0xd6, 0xd0,
2793 0xf7, 0xda, 0x19, 0xf2, 0x73, 0x77, 0x3c, 0xd4, 0x57, 0x1a, 0x57, 0x16,
2794 0x34, 0xb6, 0xee, 0xde, 0xf5, 0xed, 0x49, 0xac, 0x29, 0x41, 0x5f, 0x79,
2795 0x5c, 0xcb, 0x26, 0x83, 0xef, 0x7d, 0xbb, 0xde, 0xe3, 0xbb, 0xde, 0x0f,
2796 0xfc, 0x8f, 0xf6, 0x2c, 0xef, 0xa6, 0x07, 0xae, 0xd3, 0x1a, 0xe5, 0x2c,
2797 0x05, 0xcf, 0x36, 0x66, 0x3d, 0x2b, 0x4d, 0x5c, 0x90, 0x15, 0x5f, 0x65,
2798 0xdd, 0x36, 0xc8, 0xbb, 0x36, 0x99, 0x5f, 0x04, 0xcd, 0x63, 0x1f, 0xed,
2799 0x36, 0x63, 0xe4, 0x43, 0x71, 0xf2, 0x4c, 0x07, 0xae, 0xc1, 0xb0, 0x07,
2800 0x13, 0x68, 0xe7, 0x3f, 0xef, 0xa6, 0xcc, 0xb3, 0xda, 0x97, 0x43, 0x3c,
2801 0xe3, 0xab, 0x82, 0xce, 0xf7, 0x60, 0x9b, 0x16, 0xb9, 0x63, 0x67, 0x7a,
2802 0xc2, 0x7c, 0x20, 0xd8, 0xbe, 0x5f, 0x8d, 0x13, 0x6b, 0x3c, 0xe7, 0x6e,
2803 0xd7, 0x99, 0x9b, 0xc2, 0x1c, 0x2b, 0x10, 0xcd, 0x53, 0x22, 0xe5, 0xaa,
2804 0xc8, 0xeb, 0xf8, 0xfd, 0xa6, 0x1a, 0xc6, 0x4f, 0x14, 0xed, 0xee, 0x93,
2805 0xb2, 0x5e, 0xfa, 0x9a, 0xd4, 0xa0, 0x7f, 0xd6, 0x5c, 0xdf, 0xbf, 0xeb,
2806 0x26, 0xf5, 0x99, 0xbf, 0xe8, 0x29, 0x19, 0x18, 0xa1, 0x7e, 0x6b, 0x93,
2807 0x97, 0x17, 0x5b, 0x64, 0xc3, 0xb4, 0xcc, 0xbb, 0x44, 0x01, 0x5e, 0x42,
2808 0x26, 0x63, 0x11, 0x8d, 0x51, 0xe5, 0x5b, 0x22, 0x5b, 0xf8, 0xb6, 0xb5,
2809 0xf8, 0x4c, 0x9c, 0xfe, 0x97, 0x4f, 0x16, 0xf9, 0x6e, 0xe0, 0x69, 0x48,
2810 0xc3, 0x8e, 0x00, 0xcb, 0x42, 0x08, 0x99, 0x3c, 0x77, 0xee, 0xf7, 0xbb,
2811 0x5c, 0x1b, 0xea, 0x68, 0xcf, 0xb6, 0x49, 0xe1, 0x30, 0x64, 0xa2, 0x1a,
2812 0xd4, 0x39, 0x47, 0x8d, 0x98, 0x96, 0xd1, 0x91, 0x0a, 0x7d, 0xf8, 0xe6,
2813 0x5e, 0x2d, 0xaf, 0x33, 0x37, 0x7e, 0xa4, 0xf7, 0x82, 0x72, 0xbe, 0xe2,
2814 0x92, 0x56, 0x4d, 0x59, 0x03, 0xaf, 0xad, 0xd6, 0x5f, 0xed, 0xe3, 0x5d,
2815 0xad, 0xd7, 0x5f, 0x88, 0x07, 0xf6, 0x1a, 0xeb, 0x7e, 0x1c, 0x0f, 0xea,
2816 0x92, 0xa1, 0xfd, 0x45, 0x3b, 0xad, 0x8c, 0xbd, 0xbd, 0x20, 0xf5, 0xa5,
2817 0x9f, 0xc9, 0x3b, 0xa5, 0x9f, 0xc8, 0xaf, 0x97, 0xce, 0x00, 0x7f, 0x58,
2818 0xe5, 0x3c, 0xf4, 0xc9, 0xcd, 0xba, 0xef, 0xdf, 0x74, 0xa7, 0x60, 0x2b,
2819 0xf8, 0xfe, 0xef, 0xdc, 0x0d, 0x19, 0x38, 0xf6, 0x3d, 0xec, 0x39, 0x07,
2820 0x1e, 0xa2, 0x2c, 0x9c, 0x04, 0xbd, 0xb9, 0x7d, 0xd2, 0x19, 0xd5, 0x74,
2821 0x32, 0x78, 0xac, 0x15, 0x7b, 0x30, 0x42, 0x4c, 0xce, 0xbd, 0x8c, 0xf4,
2822 0x91, 0x66, 0x8c, 0x7a, 0x09, 0xf3, 0xb7, 0x82, 0x2f, 0xf6, 0xe2, 0xa7,
2823 0xe4, 0xee, 0x08, 0xd6, 0x3a, 0x42, 0xda, 0x6b, 0x95, 0x81, 0x47, 0xb1,
2824 0x8f, 0x5c, 0x8b, 0xdc, 0xf3, 0x7e, 0x19, 0xa7, 0x6f, 0xef, 0x9e, 0xc7,
2825 0xb2, 0xf1, 0x95, 0x2e, 0xf1, 0xa5, 0x05, 0xba, 0x7c, 0xfe, 0x78, 0x80,
2826 0x9b, 0xde, 0x55, 0x43, 0x68, 0x6f, 0xe7, 0xdf, 0x53, 0xc4, 0x79, 0x79,
2827 0xbf, 0x15, 0xb8, 0x7c, 0x1c, 0x78, 0x28, 0x53, 0xbf, 0x20, 0x8d, 0x91,
2828 0x28, 0xda, 0x10, 0xaf, 0x68, 0x59, 0x22, 0x59, 0x8f, 0x39, 0x5a, 0xcc,
2829 0x97, 0xc2, 0x1a, 0xa7, 0x74, 0x2e, 0x57, 0x1f, 0xcf, 0x9c, 0x58, 0x3e,
2830 0xa8, 0xb3, 0x41, 0x23, 0xac, 0x23, 0x7d, 0xa7, 0x35, 0xa6, 0x82, 0x0e,
2831 0xc5, 0x78, 0xc3, 0x92, 0xd1, 0xe5, 0x2e, 0x8c, 0x77, 0x41, 0x32, 0x6e,
2832 0x73, 0xcc, 0x51, 0xb4, 0xa1, 0x9c, 0x19, 0x05, 0x96, 0xf8, 0x58, 0x8d,
2833 0x2d, 0xc6, 0xa0, 0xcb, 0xe3, 0x32, 0x66, 0xee, 0xd9, 0xb1, 0xc7, 0xbc,
2834 0xb6, 0x15, 0x0c, 0x63, 0x38, 0x5c, 0x53, 0xd7, 0x8e, 0x35, 0xb1, 0x3f,
2835 0x7e, 0xb0, 0x93, 0x33, 0x8b, 0x0b, 0x90, 0x53, 0x0b, 0x1f, 0x66, 0xdc,
2836 0x67, 0x25, 0x1b, 0x6b, 0xd3, 0xb6, 0x4d, 0x05, 0xf7, 0x92, 0xf5, 0xe8,
2837 0xd3, 0xfa, 0x0e, 0xe4, 0xd0, 0x9e, 0xb0, 0x8e, 0x6d, 0xc5, 0xc8, 0xe0,
2838 0xec, 0x03, 0x1b, 0x97, 0x75, 0x5f, 0x96, 0xcc, 0x42, 0x4e, 0x26, 0x74,
2839 0x3f, 0x9e, 0xe1, 0x41, 0x8d, 0x43, 0xc8, 0xab, 0x03, 0xbd, 0x38, 0xcb,
2840 0xd4, 0x03, 0x7b, 0x38, 0xd9, 0x4b, 0x2e, 0xfa, 0x4f, 0xc8, 0xb3, 0xf8,
2841 0xd6, 0xcb, 0x3b, 0x6a, 0x93, 0x81, 0x67, 0xa0, 0x2f, 0xbd, 0x66, 0x7d,
2842 0x54, 0x3e, 0xf3, 0xfc, 0x38, 0x63, 0x2e, 0x7f, 0xf6, 0x4c, 0xf9, 0xc4,
2843 0xd3, 0xb1, 0xd8, 0xe9, 0x88, 0x58, 0xe7, 0x03, 0x5b, 0xfd, 0xf0, 0xf4,
2844 0xbc, 0xe2, 0xf7, 0xc3, 0xe7, 0x57, 0x54, 0x07, 0xda, 0x46, 0xd1, 0x8e,
2845 0xeb, 0x30, 0x65, 0xdc, 0xfb, 0xab, 0x3f, 0x73, 0xc4, 0xf7, 0x27, 0x74,
2846 0x4e, 0x58, 0xca, 0x9c, 0x57, 0x4d, 0x7c, 0xee, 0x88, 0x17, 0x6b, 0xc7,
2847 0x5c, 0x29, 0x73, 0x45, 0x1d, 0xc6, 0x7a, 0x58, 0xee, 0x25, 0x4f, 0x24,
2848 0x36, 0x84, 0xe3, 0x5b, 0x93, 0xcb, 0x2a, 0x95, 0x1c, 0x54, 0x56, 0xba,
2849 0x80, 0x5f, 0x8b, 0xd2, 0x71, 0xcc, 0x44, 0x52, 0x81, 0x77, 0xb1, 0x27,
2850 0xfb, 0xa8, 0xef, 0x4f, 0xda, 0xac, 0x4f, 0x99, 0x51, 0x45, 0xdf, 0x4b,
2851 0xa7, 0x8e, 0x77, 0x5e, 0x3e, 0x90, 0x32, 0x8f, 0xaa, 0xfd, 0xe1, 0xfb,
2852 0x28, 0x64, 0xe6, 0xf6, 0x78, 0x67, 0x96, 0x95, 0x29, 0x2f, 0x79, 0xa9,
2853 0xe4, 0xac, 0xb2, 0x72, 0x18, 0x33, 0x37, 0xa6, 0x28, 0x37, 0x52, 0x66,
2854 0xa7, 0xa2, 0x7f, 0xb4, 0x5d, 0xef, 0x7b, 0x12, 0xfd, 0x53, 0xaa, 0x25,
2855 0x5c, 0x0f, 0xef, 0xeb, 0x4a, 0x5f, 0xc0, 0x33, 0x94, 0x39, 0xfd, 0xc6,
2856 0xcc, 0x02, 0xf3, 0xcb, 0x74, 0x5e, 0x43, 0x7a, 0xe0, 0x18, 0xdf, 0x0d,
2857 0xb9, 0x7f, 0xe2, 0x6f, 0xa8, 0x43, 0xb9, 0xcc, 0x3a, 0x27, 0xe4, 0xb7,
2858 0x23, 0x1a, 0x3f, 0xdf, 0x3f, 0x91, 0xd7, 0xb9, 0x8b, 0x0d, 0x35, 0x10,
2859 0xee, 0x7b, 0xfb, 0xce, 0x92, 0x19, 0xf7, 0x4b, 0x1c, 0x67, 0x21, 0x72,
2860 0xb2, 0x5d, 0x98, 0x23, 0x3a, 0x5e, 0x6a, 0xd2, 0x06, 0x7d, 0x03, 0xcc,
2861 0x15, 0x68, 0xc6, 0xdd, 0x2f, 0x88, 0x71, 0xac, 0x63, 0x07, 0x9d, 0x00,
2862 0x77, 0x02, 0xaf, 0x56, 0x31, 0x4e, 0x61, 0x51, 0xf2, 0x41, 0x7f, 0xe9,
2863 0x60, 0x4e, 0x6a, 0xa1, 0xfa, 0x45, 0x63, 0x04, 0x3a, 0x70, 0x1c, 0xef,
2864 0xf7, 0x4f, 0x90, 0x3e, 0x79, 0x36, 0x49, 0x35, 0xbe, 0xc4, 0xf5, 0x1c,
2865 0x94, 0x89, 0x45, 0x60, 0x23, 0xfc, 0xe6, 0x17, 0x83, 0x7b, 0xbb, 0x0e,
2866 0x9c, 0x3d, 0xe1, 0x99, 0x9a, 0x5f, 0x67, 0x5d, 0xc6, 0x4f, 0xc0, 0x2b,
2867 0x3a, 0x8f, 0x8a, 0x7d, 0x99, 0x4b, 0x78, 0x88, 0xfa, 0xd1, 0x6d, 0x48,
2868 0x0c, 0x6d, 0x89, 0x59, 0x59, 0x6f, 0x8d, 0x26, 0x23, 0xdd, 0x32, 0x0f,
2869 0x79, 0x57, 0x81, 0xee, 0x2c, 0x5c, 0x89, 0xca, 0xac, 0xa7, 0xe3, 0xd9,
2870 0xc9, 0x8f, 0x95, 0x2b, 0xb5, 0xfa, 0x71, 0xb9, 0x51, 0x77, 0xf4, 0x37,
2871 0xea, 0xb5, 0xc2, 0xab, 0x86, 0x7c, 0xff, 0x88, 0xce, 0xa5, 0x73, 0x2a,
2872 0xd2, 0xd9, 0x4f, 0xcc, 0xb3, 0xa2, 0xf3, 0xea, 0x20, 0x3b, 0x80, 0x39,
2873 0xde, 0x06, 0xe6, 0x78, 0x0b, 0x98, 0xe3, 0x57, 0xc0, 0xd8, 0x37, 0x4b,
2874 0x93, 0xa1, 0xfc, 0x9f, 0x86, 0x1c, 0xa2, 0xae, 0xb6, 0xce, 0xe0, 0x4e,
2875 0xa7, 0xf3, 0xa0, 0xc1, 0xdb, 0xb0, 0x3f, 0xd6, 0x4b, 0x19, 0x59, 0x5d,
2876 0x9a, 0x90, 0xb5, 0xa5, 0x20, 0x0f, 0xf9, 0x03, 0xe6, 0x7d, 0x8d, 0xf0,
2877 0x9e, 0x1c, 0xc8, 0xa1, 0x3d, 0x32, 0x70, 0x94, 0xf2, 0xa3, 0x43, 0x96,
2878 0x8b, 0xab, 0x5a, 0x0e, 0x2d, 0x17, 0x59, 0x8e, 0x88, 0xce, 0x21, 0x9b,
2879 0xda, 0x90, 0x8a, 0x5b, 0x47, 0xfd, 0x3e, 0xed, 0x0f, 0x0a, 0xfc, 0xf3,
2880 0x94, 0x97, 0x7f, 0x0a, 0xef, 0x5e, 0xe9, 0xdc, 0xba, 0x19, 0xb3, 0x1b,
2881 0xed, 0x9a, 0xb2, 0x6b, 0x30, 0x88, 0xb9, 0xab, 0xdb, 0x68, 0x83, 0x39,
2882 0x80, 0x19, 0xaf, 0x43, 0x87, 0x34, 0x9c, 0x6e, 0x8d, 0xfd, 0x1a, 0xce,
2883 0x21, 0x9d, 0x77, 0xcb, 0x71, 0x0a, 0x45, 0x5b, 0xe6, 0x8a, 0x56, 0x32,
2884 0x0f, 0xfa, 0xbb, 0x01, 0xbb, 0x6d, 0x15, 0x77, 0xb0, 0x86, 0x33, 0x58,
2885 0xaf, 0x53, 0xcf, 0x6f, 0x6a, 0xd9, 0xbb, 0x5c, 0xff, 0x23, 0xc6, 0xb1,
2886 0xce, 0xa4, 0xe5, 0x0f, 0x7d, 0x94, 0x81, 0xf4, 0x4d, 0x65, 0x75, 0xff,
2887 0xa0, 0xdf, 0x2a, 0xda, 0xae, 0xd5, 0x29, 0x8f, 0x45, 0x2e, 0x79, 0x36,
2888 0x74, 0xc9, 0xcb, 0x09, 0x62, 0x80, 0xb2, 0x6a, 0xf6, 0xf3, 0xc3, 0x35,
2889 0xfb, 0xfe, 0x5e, 0x9b, 0xeb, 0x72, 0x42, 0xb9, 0x4d, 0xdd, 0xbf, 0xa1,
2890 0xb1, 0x8d, 0x57, 0x7a, 0x56, 0xde, 0xc4, 0x7d, 0x07, 0x18, 0x27, 0x27,
2891 0x6f, 0x00, 0xe3, 0xd5, 0x4b, 0xcd, 0xbc, 0xed, 0x93, 0x38, 0xa7, 0x92,
2892 0x9a, 0xbb, 0xda, 0x29, 0x97, 0xaf, 0x15, 0xd4, 0x4b, 0xd7, 0x3c, 0xf5,
2893 0xf3, 0xab, 0x45, 0x55, 0xb8, 0xea, 0xfb, 0xff, 0x70, 0x67, 0xe4, 0x9d,
2894 0x25, 0x5f, 0x4e, 0xbb, 0x46, 0x7f, 0x44, 0x9a, 0xf9, 0x74, 0xbe, 0xdf,
2895 0x01, 0xd9, 0xbc, 0x7e, 0xc0, 0xf7, 0x1f, 0x19, 0x19, 0x11, 0xe7, 0x00,
2896 0x31, 0xca, 0x70, 0x82, 0x39, 0xae, 0x94, 0x39, 0x19, 0xdb, 0x3e, 0x5f,
2897 0x51, 0x0a, 0xf2, 0xad, 0x3b, 0xc0, 0x2f, 0x8f, 0xee, 0x0b, 0xe3, 0x26,
2898 0x3f, 0x7c, 0x9e, 0x7e, 0xe5, 0xc4, 0xe7, 0xfc, 0xca, 0xa6, 0x9c, 0x2d,
2899 0xf6, 0xa2, 0x7f, 0x4c, 0x7e, 0x50, 0x8c, 0xee, 0x2a, 0x9b, 0x78, 0x3a,
2900 0x46, 0xa1, 0x78, 0xcf, 0x1f, 0xd4, 0xf1, 0x03, 0x60, 0x12, 0xd3, 0xf7,
2901 0x67, 0x5d, 0xce, 0xd7, 0x8d, 0xf9, 0x36, 0xcc, 0x7d, 0xd0, 0xff, 0xa7,
2902 0xb5, 0x7e, 0x2e, 0x2b, 0xd8, 0xc1, 0xe0, 0xef, 0x98, 0x8c, 0x15, 0xa1,
2903 0xe3, 0x15, 0xf3, 0x4c, 0x89, 0x15, 0xac, 0xc4, 0x2c, 0x64, 0xc7, 0x0c,
2904 0xe4, 0xcd, 0x29, 0x1d, 0x67, 0xed, 0xd5, 0xb2, 0x67, 0x8e, 0xe5, 0x9c,
2905 0xa4, 0x2b, 0x6e, 0x8f, 0x3e, 0xbf, 0xcd, 0x1b, 0x2f, 0x26, 0x82, 0x3b,
2906 0x07, 0x1f, 0xe7, 0x94, 0xb4, 0xc1, 0x1e, 0xca, 0xae, 0x4c, 0x81, 0x27,
2907 0x12, 0x38, 0xdb, 0x56, 0xcd, 0x0f, 0x0d, 0xe8, 0xef, 0x86, 0xf6, 0x29,
2908 0x06, 0xb1, 0x8b, 0x86, 0xc9, 0x76, 0xa7, 0xd0, 0xaf, 0x5d, 0x32, 0x57,
2909 0xdb, 0xb4, 0x5c, 0x7d, 0xb8, 0x2e, 0x0d, 0x1c, 0xf2, 0x04, 0xca, 0x11,
2910 0xd4, 0x25, 0xc3, 0xb2, 0x81, 0xf2, 0x34, 0xca, 0x2d, 0x78, 0xb2, 0xcd,
2911 0x61, 0xe0, 0x0a, 0x3c, 0x5f, 0xc3, 0x78, 0x23, 0x58, 0x73, 0xce, 0x94,
2912 0x8f, 0x4e, 0x50, 0x97, 0x38, 0x06, 0x73, 0x91, 0x67, 0x6d, 0x3c, 0x6b,
2913 0x45, 0x95, 0x5d, 0x60, 0x19, 0xcf, 0x72, 0xf0, 0xfd, 0x21, 0x99, 0x84,
2914 0x3e, 0x99, 0x6b, 0x81, 0x4c, 0xfa, 0x68, 0x5b, 0x26, 0xb1, 0xae, 0x5d,
2915 0xc6, 0xae, 0x92, 0xd7, 0x4d, 0xd0, 0x5b, 0xa7, 0x64, 0xaf, 0xc5, 0x34,
2916 0x1e, 0xad, 0x80, 0x16, 0xaf, 0x83, 0xae, 0x96, 0x41, 0x53, 0x99, 0xa2,
2917 0x35, 0x3a, 0xad, 0x92, 0xda, 0x2f, 0xf0, 0x38, 0xe8, 0xb5, 0xe3, 0x0a,
2918 0xb1, 0x28, 0x79, 0xd9, 0x01, 0xed, 0x89, 0xdf, 0x61, 0xdb, 0x93, 0x8e,
2919 0xb2, 0x41, 0x83, 0xa0, 0xcb, 0x62, 0xc0, 0xd3, 0xef, 0x29, 0x2d, 0x57,
2920 0x47, 0xef, 0x48, 0x2a, 0x7d, 0x47, 0x2c, 0xc8, 0x02, 0xcb, 0xfd, 0x50,
2921 0x5c, 0x8c, 0x79, 0x5c, 0x5e, 0xc7, 0x3c, 0x06, 0xf8, 0xfb, 0xc8, 0x90,
2922 0xe6, 0xef, 0x51, 0x89, 0xec, 0xe6, 0x71, 0xd0, 0x1b, 0x64, 0x50, 0xc0,
2923 0xd3, 0xe9, 0x90, 0x46, 0x9f, 0x06, 0xff, 0x5a, 0xb0, 0xca, 0x92, 0x32,
2924 0x0f, 0xfe, 0xbf, 0x8e, 0xef, 0xb7, 0xea, 0x9f, 0xaa, 0xb9, 0x05, 0x15,
2925 0xe6, 0xb2, 0x7c, 0x1b, 0x38, 0xf9, 0xf7, 0x38, 0xbb, 0x2e, 0x8d, 0xdd,
2926 0x07, 0x46, 0x18, 0x4b, 0xfb, 0xb7, 0xba, 0x6c, 0x1f, 0x95, 0xcd, 0xe1,
2927 0xe3, 0x28, 0xef, 0xc3, 0xd3, 0xc0, 0x39, 0x44, 0x75, 0x2c, 0x7c, 0xd9,
2928 0x1b, 0x36, 0x0a, 0x3a, 0xef, 0xe0, 0x98, 0xce, 0xcf, 0x37, 0xec, 0x03,
2929 0xf8, 0x4e, 0xbf, 0x0c, 0xf7, 0x06, 0xcc, 0xa4, 0x12, 0x3a, 0xc7, 0xb4,
2930 0x02, 0x2c, 0xb1, 0x82, 0xf1, 0xde, 0xa7, 0x5f, 0xaf, 0x06, 0x1e, 0x1e,
2931 0xfe, 0xa7, 0x9f, 0x8e, 0x31, 0x27, 0x7d, 0x33, 0x11, 0xe8, 0xbf, 0xcf,
2932 0xfc, 0x4d, 0x7b, 0x6e, 0xd4, 0xc0, 0xcb, 0x6d, 0x33, 0x86, 0xb6, 0xd0,
2933 0x65, 0xd0, 0x45, 0x65, 0x4d, 0xbf, 0x6c, 0x17, 0xf4, 0x2d, 0xd4, 0x52,
2934 0xe6, 0x07, 0x12, 0xf4, 0x9d, 0xb7, 0xa9, 0x77, 0xda, 0x21, 0x5f, 0x92,
2935 0x1a, 0x57, 0xbe, 0x6f, 0xe7, 0x21, 0x15, 0xac, 0xe4, 0x24, 0x68, 0xb4,
2936 0x4d, 0x2c, 0x67, 0x5c, 0x1e, 0xcc, 0x3b, 0xab, 0xfb, 0xb2, 0x6d, 0xb3,
2937 0x6f, 0x73, 0x5e, 0xae, 0x9f, 0x7b, 0xe1, 0x1e, 0xe8, 0xa7, 0x36, 0x35,
2938 0x8d, 0x36, 0x6a, 0xed, 0xfd, 0x01, 0x8d, 0x36, 0xf7, 0x11, 0xfb, 0x3f,
2939 0xfb, 0x20, 0x9d, 0x0c, 0x1b, 0x41, 0x0e, 0x06, 0x9e, 0x35, 0x9e, 0xe7,
2940 0xa7, 0xc0, 0xf7, 0x3b, 0xe9, 0xa7, 0xe9, 0x67, 0x0c, 0xe8, 0xe7, 0x91,
2941 0x6d, 0xfa, 0x21, 0xdd, 0x74, 0xca, 0xd8, 0x35, 0x5b, 0x26, 0x8a, 0xfa,
2942 0xbe, 0x81, 0x35, 0xe9, 0x3f, 0x3a, 0x0e, 0xba, 0x21, 0xad, 0x93, 0xb7,
2943 0x4c, 0x29, 0x83, 0x8e, 0xca, 0x90, 0x4f, 0x65, 0xd0, 0x14, 0x31, 0x50,
2944 0x19, 0xf2, 0xad, 0x5c, 0xb7, 0x9c, 0x2a, 0xf6, 0x4c, 0x9d, 0xbd, 0x02,
2945 0x3a, 0xba, 0x5e, 0xe7, 0xfd, 0xeb, 0x35, 0x9b, 0xd4, 0x83, 0xb7, 0xb6,
2946 0xef, 0xfe, 0xef, 0xb8, 0xfb, 0x43, 0x72, 0x03, 0x76, 0xcb, 0x9b, 0xa5,
2947 0x61, 0xc8, 0x24, 0x21, 0x5e, 0x04, 0x6d, 0x8c, 0xca, 0x6a, 0xe9, 0xa4,
2948 0xac, 0x41, 0x3f, 0xad, 0x2f, 0x0d, 0x00, 0x4f, 0x43, 0x8e, 0xbe, 0x72,
2949 0x44, 0xde, 0x58, 0x52, 0x32, 0x63, 0x43, 0xbf, 0x2c, 0xd3, 0x07, 0x0f,
2950 0x7a, 0x2e, 0x77, 0xea, 0x98, 0xfd, 0x58, 0x35, 0xf0, 0xc5, 0x8f, 0x57,
2951 0xbb, 0x64, 0xa2, 0x6a, 0xca, 0x63, 0xd5, 0x1e, 0x79, 0xa2, 0x1a, 0x93,
2952 0xd3, 0xb5, 0x84, 0x7c, 0xa3, 0x7a, 0x50, 0x4e, 0x55, 0x0f, 0xc9, 0x93,
2953 0xb5, 0xa4, 0x7c, 0x13, 0x76, 0x61, 0xae, 0xe6, 0xc8, 0x64, 0x6d, 0x58,
2954 0x1e, 0xaf, 0xd1, 0xc7, 0x8e, 0xf9, 0xf0, 0xcb, 0x6e, 0xfb, 0x2e, 0xb8,
2955 0xae, 0x0e, 0xac, 0xcb, 0x51, 0xe3, 0x3a, 0x66, 0x29, 0xb9, 0xc0, 0xff,
2956 0x21, 0x72, 0x0e, 0x7d, 0x2f, 0xbe, 0xa2, 0xa4, 0xa2, 0xe7, 0x6f, 0xfe,
2957 0xdf, 0x48, 0x54, 0xdb, 0x46, 0xe7, 0xca, 0x07, 0xd1, 0xc6, 0xa6, 0x4d,
2958 0x12, 0xfa, 0x41, 0x9a, 0xfe, 0xff, 0xa6, 0xed, 0x65, 0x68, 0x1f, 0xf6,
2959 0x2d, 0xda, 0x5e, 0xfa, 0xec, 0x29, 0x3f, 0x68, 0xe7, 0xd0, 0xd6, 0xda,
2960 0x19, 0xe7, 0x68, 0xce, 0x7b, 0x31, 0xf7, 0xf0, 0xff, 0xa7, 0x04, 0xf1,
2961 0xaa, 0xb3, 0xb5, 0x83, 0xfc, 0x3f, 0x15, 0xac, 0xe5, 0x8b, 0xf3, 0xc5,
2962 0x27, 0x4a, 0x63, 0xea, 0xb1, 0x12, 0x11, 0x8d, 0x2f, 0x17, 0xb7, 0x73,
2963 0xf2, 0xbe, 0x2e, 0xcb, 0x6e, 0x54, 0xaf, 0x21, 0xf0, 0xdb, 0xa7, 0x75,
2964 0x7e, 0xde, 0xd8, 0x10, 0xe9, 0x8f, 0x71, 0xb8, 0xae, 0x30, 0xb6, 0x00,
2965 0x6c, 0xeb, 0x9a, 0x72, 0xa9, 0x1a, 0xf8, 0xaf, 0xe6, 0x34, 0xbd, 0xbc,
2966 0x05, 0x9a, 0x63, 0xfc, 0x21, 0x78, 0xe6, 0xcb, 0x41, 0xdf, 0xec, 0x90,
2967 0x43, 0x7b, 0x1c, 0xfb, 0x35, 0x7a, 0x38, 0x17, 0xff, 0x4f, 0x07, 0xe5,
2968 0x70, 0xbd, 0xcc, 0x2f, 0xb6, 0x35, 0x2d, 0x06, 0x31, 0x5e, 0x47, 0x9e,
2969 0xc3, 0x5d, 0x54, 0x4c, 0xae, 0xbf, 0x43, 0x2a, 0x0e, 0x6d, 0x5b, 0xca,
2970 0xef, 0x21, 0x29, 0x63, 0x9e, 0x8a, 0xd3, 0xf4, 0x8d, 0x05, 0x72, 0xb6,
2971 0x62, 0x3e, 0x98, 0x77, 0xba, 0xbc, 0x1f, 0xef, 0xa8, 0x73, 0x80, 0x99,
2972 0xa6, 0xf8, 0x7e, 0x11, 0x65, 0xfa, 0x46, 0xe6, 0xf0, 0x4c, 0x84, 0x75,
2973 0xaf, 0xf5, 0x6b, 0xac, 0x7e, 0xf2, 0x41, 0xbf, 0x99, 0xb2, 0x95, 0xcf,
2974 0x44, 0xb6, 0x94, 0xf1, 0x8b, 0xf5, 0x7e, 0xca, 0xdc, 0xfd, 0x36, 0x7f,
2975 0x51, 0xf9, 0x8b, 0xa9, 0x7d, 0x0a, 0xe1, 0xb7, 0x3d, 0xf2, 0x94, 0xc9,
2976 0xdc, 0xf5, 0xb4, 0x1a, 0x2b, 0xfd, 0x34, 0xcc, 0xd3, 0xdd, 0x52, 0xfb,
2977 0x2b, 0x6f, 0xf7, 0x07, 0x79, 0xee, 0x1c, 0x7b, 0x67, 0x6e, 0xfb, 0x4e,
2978 0x3a, 0x61, 0x8e, 0x7b, 0x3b, 0x70, 0xab, 0x56, 0x62, 0xe0, 0x41, 0xc8,
2979 0x3b, 0xbb, 0x45, 0xf3, 0x63, 0xa1, 0xf6, 0x2f, 0x7f, 0x43, 0xf3, 0x73,
2980 0xd3, 0xc7, 0xf0, 0xdb, 0x7e, 0xda, 0xb6, 0x94, 0x1b, 0x97, 0x02, 0xbf,
2981 0x91, 0xb6, 0xa1, 0x21, 0x2b, 0x50, 0x47, 0x5e, 0x05, 0x9f, 0x6c, 0xb7,
2982 0xe5, 0xdf, 0x7f, 0x01, 0x99, 0xe7, 0xd3, 0x46, 0x40, 0x67, 0x00, 0x00,
2983 0x00 };
2984static u32 bnx2_RXP_b09FwData[(0x0/4) + 1] = { 0x0 };
2985static u32 bnx2_RXP_b09FwRodata[(0x278/4) + 1] = {
2986 0x08003fa4, 0x08003ea4, 0x08003f48, 0x08003f60, 0x08003f78, 0x08003f98,
2987 0x08003fa4, 0x08003fa4, 0x08003eac, 0x00000000, 0x080049d4, 0x08004a0c,
2988 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004a44, 0x08004c08,
2989 0x08004b50, 0x08004b88, 0x08004c08, 0x08004ad8, 0x08004c08, 0x08004c08,
2990 0x08004b88, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08,
2991 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004bc8,
2992 0x08004c08, 0x08004bc8, 0x08004b50, 0x08004c08, 0x08004c08, 0x08004bc8,
2993 0x08004bc8, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08,
2994 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08,
2995 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08,
2996 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08,
2997 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08,
2998 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08,
2999 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08,
3000 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08,
3001 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08,
3002 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08,
3003 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08,
3004 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08,
3005 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08,
3006 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08,
3007 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08,
3008 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08,
3009 0x08004ab4, 0x00000000, 0x0800602c, 0x08006044, 0x08006044, 0x08006044,
3010 0x0800602c, 0x08006044, 0x08006044, 0x08006044, 0x0800602c, 0x08006044,
3011 0x08006044, 0x08006044, 0x0800602c, 0x08006044, 0x08006044, 0x08006044,
3012 0x08006038, 0x00000000, 0x00000000 };
3013static u32 bnx2_RXP_b09FwBss[(0x13dc/4) + 1] = { 0x0 };
3014static u32 bnx2_RXP_b09FwSbss[(0x2c/4) + 1] = { 0x0 };
3015
3016static struct fw_info bnx2_rxp_fw_09 = {
3017 .ver_major = 0x1,
3018 .ver_minor = 0x0,
3019 .ver_fix = 0x0,
3020
3021 .start_addr = 0x08003184,
3022
3023 .text_addr = 0x08000000,
3024 .text_len = 0x673c,
3025 .text_index = 0x0,
3026 .gz_text = bnx2_RXP_b09FwText,
3027 .gz_text_len = sizeof(bnx2_RXP_b09FwText),
3028
3029 .data_addr = 0x080069e0,
3030 .data_len = 0x0,
3031 .data_index = 0x0,
3032 .data = bnx2_RXP_b09FwData,
3033
3034 .sbss_addr = 0x080069e0,
3035 .sbss_len = 0x2c,
3036 .sbss_index = 0x0,
3037 .sbss = bnx2_RXP_b09FwSbss,
3038
3039 .bss_addr = 0x08006a10,
3040 .bss_len = 0x13dc,
3041 .bss_index = 0x0,
3042 .bss = bnx2_RXP_b09FwBss,
3043
3044 .rodata_addr = 0x08006740,
3045 .rodata_len = 0x278,
3046 .rodata_index = 0x0,
3047 .rodata = bnx2_RXP_b09FwRodata,
3048};
3049
3050static u8 bnx2_TPAT_b09FwText[] = {
3051 0x1f, 0x8b, 0x08, 0x08, 0xdb, 0xfd, 0x2f, 0x45, 0x00, 0x03, 0x74, 0x65,
3052 0x73, 0x74, 0x31, 0x2e, 0x62, 0x69, 0x6e, 0x00, 0xc5, 0x58, 0x5d, 0x6c,
3053 0x1c, 0x57, 0x15, 0x3e, 0xf3, 0xbb, 0x13, 0x77, 0xed, 0xbd, 0x49, 0x97,
3054 0x6a, 0x13, 0xb9, 0x74, 0xc6, 0x1e, 0x3b, 0x8b, 0x1c, 0x35, 0x93, 0xb0,
3055 0x24, 0x16, 0x5a, 0xd1, 0xc9, 0xcc, 0xae, 0x6b, 0xe5, 0x29, 0x86, 0xbc,
3056 0xf1, 0xb2, 0xac, 0xed, 0x46, 0x54, 0x48, 0x4d, 0x51, 0x84, 0x22, 0x81,
3057 0x94, 0x65, 0x76, 0x53, 0x40, 0x5a, 0x65, 0xc1, 0xa0, 0x04, 0x21, 0x84,
3058 0x22, 0x9b, 0x66, 0x91, 0x58, 0x3c, 0x4d, 0xe9, 0x6b, 0x94, 0xbc, 0x90,
3059 0x96, 0x17, 0x9e, 0x4b, 0x9e, 0xac, 0x02, 0x12, 0x0f, 0xa8, 0x8a, 0x78,
3060 0x40, 0x15, 0x0d, 0x1e, 0xbe, 0x33, 0x3f, 0x9b, 0x5d, 0xd7, 0x29, 0x79,
3061 0xa8, 0x84, 0xa5, 0xf1, 0xcc, 0xfd, 0x39, 0xf7, 0xe7, 0x7c, 0xdf, 0x77,
3062 0xee, 0xb9, 0x5b, 0x92, 0x69, 0x82, 0xd2, 0xbf, 0x49, 0x3c, 0x97, 0xbe,
3063 0x71, 0xf1, 0xd2, 0xe2, 0x8b, 0x27, 0x4d, 0x3a, 0x71, 0xe2, 0x45, 0xe9,
3064 0x19, 0x43, 0xa6, 0xcf, 0xe0, 0x4f, 0x21, 0x12, 0xd9, 0xf8, 0xfc, 0x90,
3065 0x21, 0x57, 0x6f, 0x4e, 0x7b, 0x36, 0x19, 0x4a, 0xd5, 0x79, 0x61, 0xd5,
3066 0x26, 0x72, 0x07, 0x0b, 0xa6, 0x4f, 0xff, 0x89, 0x5a, 0x45, 0x95, 0xb8,
3067 0xfe, 0xf9, 0xea, 0xa3, 0xe3, 0x77, 0x4e, 0x5b, 0x0f, 0x6f, 0x2a, 0x64,
3068 0x88, 0x6a, 0xc3, 0x10, 0xf3, 0x64, 0x4c, 0xc3, 0xe6, 0x97, 0x47, 0x57,
3069 0x34, 0x9a, 0xca, 0xc6, 0x12, 0x14, 0xf4, 0x0c, 0xaa, 0x77, 0x31, 0x8e,
3070 0x7d, 0x59, 0xf2, 0x43, 0x55, 0xf2, 0x6f, 0x18, 0x24, 0x57, 0x5d, 0xc9,
3071 0x0b, 0x6d, 0xb4, 0x49, 0xe4, 0x39, 0x39, 0x72, 0x45, 0x14, 0x7d, 0xd3,
3072 0x91, 0x49, 0xb6, 0x77, 0xa3, 0xd9, 0xb9, 0x25, 0xc9, 0xeb, 0x2f, 0x4b,
3073 0x7e, 0xdf, 0xe3, 0x7d, 0x63, 0x1d, 0x4b, 0x92, 0xdb, 0xe7, 0x77, 0xd5,
3074 0xf0, 0xbb, 0x53, 0xd4, 0x28, 0x52, 0x41, 0xb6, 0xd9, 0xd6, 0x24, 0xdf,
3075 0x59, 0x28, 0x29, 0x34, 0x8b, 0xe7, 0x00, 0xad, 0x3b, 0x94, 0xf7, 0x1c,
3076 0x52, 0x15, 0x5b, 0x26, 0xbf, 0x28, 0xd1, 0xaf, 0x2b, 0x1a, 0x9e, 0xb3,
3077 0x52, 0xad, 0xbf, 0x96, 0x8e, 0x53, 0xa4, 0x36, 0xd6, 0xd2, 0x2c, 0xf2,
3078 0xda, 0x12, 0x7b, 0xcf, 0x59, 0x10, 0x32, 0xcd, 0xe2, 0x99, 0xc4, 0x77,
3079 0x13, 0xfd, 0x34, 0xf2, 0x2a, 0x7b, 0xdb, 0x0e, 0xe0, 0x1b, 0xeb, 0xc4,
3080 0x58, 0x5e, 0xbc, 0x0e, 0x13, 0xeb, 0xb0, 0xa9, 0xd3, 0x5b, 0xc6, 0x3e,
3081 0xe6, 0x4a, 0x4d, 0xd2, 0xa9, 0x13, 0xaf, 0x7d, 0x92, 0x02, 0xa1, 0x50,
3082 0x70, 0x4c, 0x23, 0xf7, 0x9c, 0x8a, 0xf2, 0x21, 0x6a, 0x09, 0x09, 0x7d,
3083 0x3a, 0x29, 0x7e, 0x39, 0xb4, 0xeb, 0xa8, 0x2f, 0x50, 0x50, 0x3c, 0x28,
3084 0xc9, 0xd5, 0xef, 0xa1, 0x7e, 0x4e, 0x34, 0xe9, 0xbb, 0x78, 0x4b, 0x28,
3085 0x1f, 0xe4, 0xf1, 0x50, 0x96, 0x48, 0xb1, 0x49, 0x78, 0xa1, 0x49, 0xed,
3086 0x30, 0xb3, 0xe5, 0xfa, 0xa4, 0xae, 0x15, 0xee, 0xc5, 0x0e, 0xfd, 0x7a,
3087 0x75, 0x6a, 0x08, 0x6a, 0xa9, 0x55, 0xf4, 0xe9, 0xd9, 0xa2, 0x06, 0x9c,
3088 0xdc, 0x18, 0xcf, 0x97, 0xb8, 0x9e, 0xff, 0x50, 0x6f, 0x92, 0x52, 0xb5,
3089 0x85, 0x4f, 0x5f, 0xa6, 0xa4, 0x8d, 0xf7, 0x29, 0x63, 0x6f, 0xa7, 0xd2,
3090 0x72, 0x51, 0x78, 0x37, 0xbe, 0x48, 0x6e, 0xec, 0x1f, 0x03, 0xdf, 0x02,
3091 0x7b, 0xd4, 0x81, 0x75, 0xe0, 0xca, 0xd4, 0x2a, 0x19, 0x64, 0x2d, 0xae,
3092 0xa1, 0xe5, 0x6f, 0x5d, 0x05, 0x7e, 0x67, 0xdc, 0xd4, 0xd4, 0x8e, 0x71,
3093 0xfe, 0x23, 0xd6, 0xd9, 0x12, 0x06, 0xf0, 0x6e, 0x9c, 0x8f, 0xa2, 0x37,
3094 0x9d, 0x28, 0xd2, 0xab, 0x76, 0xf9, 0x16, 0x2d, 0x94, 0x34, 0x9a, 0x17,
3095 0x78, 0xc3, 0x8f, 0x36, 0x7c, 0xa5, 0x65, 0xeb, 0xc9, 0x78, 0x86, 0xbf,
3096 0xcb, 0x12, 0x96, 0x42, 0x1f, 0x74, 0xdf, 0x63, 0x7f, 0x94, 0x97, 0x62,
3097 0x9b, 0x28, 0xda, 0x5c, 0xfc, 0x34, 0x9b, 0xef, 0xa7, 0x36, 0x51, 0x54,
3098 0xaf, 0xf0, 0xbc, 0x16, 0xf6, 0xcc, 0x5c, 0x25, 0xaa, 0x0f, 0x1c, 0xa3,
3099 0xd9, 0xc5, 0xfa, 0x6c, 0xbc, 0x07, 0x25, 0xec, 0xc1, 0x2a, 0x9b, 0x92,
3100 0x41, 0x81, 0x1d, 0xbd, 0x00, 0x7e, 0xb8, 0xbe, 0x6d, 0xbd, 0xef, 0x2b,
3101 0x05, 0xda, 0x72, 0xf2, 0xd4, 0x09, 0x4b, 0x14, 0x84, 0x1d, 0xf2, 0x42,
3102 0x19, 0x73, 0x14, 0x68, 0xd3, 0x7e, 0x18, 0xd5, 0x1d, 0x07, 0x7e, 0x21,
3103 0xb6, 0x2b, 0xd5, 0x69, 0x1a, 0xed, 0x0b, 0x62, 0x8d, 0x1c, 0x60, 0x21,
3104 0xc3, 0x37, 0xb3, 0xf1, 0x77, 0x10, 0x3a, 0x68, 0xa7, 0x96, 0x5c, 0xb1,
3105 0x44, 0x40, 0x56, 0xc9, 0x53, 0x48, 0xc8, 0x55, 0x81, 0x3e, 0x2d, 0xaa,
3106 0x85, 0x06, 0xed, 0x28, 0x97, 0x63, 0x7e, 0xb7, 0x7b, 0x3b, 0xd1, 0x9d,
3107 0xa3, 0x25, 0xba, 0x1b, 0x16, 0xe9, 0x76, 0x48, 0x72, 0xd3, 0x01, 0x37,
3108 0x8a, 0x82, 0xde, 0x0a, 0x47, 0xf7, 0xf2, 0x1b, 0xec, 0x25, 0x38, 0xa2,
3109 0x40, 0x83, 0xab, 0xce, 0x3d, 0x30, 0xc8, 0x02, 0x46, 0x2d, 0xec, 0x3d,
3110 0x7b, 0xf3, 0xbe, 0x76, 0xa6, 0x57, 0x6d, 0xeb, 0x87, 0x3e, 0xa3, 0x76,
3111 0x4d, 0x43, 0xed, 0x5e, 0x7f, 0x0c, 0x30, 0x86, 0xa0, 0xab, 0xd0, 0x93,
3112 0x0c, 0xbf, 0xcc, 0x6c, 0x1b, 0xd4, 0xef, 0xe6, 0xc8, 0xdc, 0x54, 0xa9,
3113 0xd9, 0x2b, 0x92, 0x33, 0x6f, 0x99, 0x24, 0xcb, 0x45, 0x99, 0x54, 0x9a,
3114 0xd9, 0x8c, 0x68, 0x09, 0xeb, 0xb8, 0x6f, 0xff, 0x48, 0xa7, 0xa9, 0xc0,
3115 0xd1, 0x89, 0xfb, 0x18, 0x34, 0x73, 0xcb, 0x90, 0xfc, 0x1e, 0xef, 0x83,
3116 0x7d, 0x6e, 0xa4, 0x3e, 0x57, 0x25, 0xef, 0x46, 0x8e, 0x66, 0x37, 0xfe,
3117 0x11, 0x79, 0x36, 0x7c, 0x0d, 0x9e, 0xaf, 0x56, 0xbe, 0xa0, 0xd0, 0x04,
3118 0xea, 0x36, 0xb9, 0xed, 0x61, 0x5a, 0xcf, 0x63, 0x44, 0x91, 0xe7, 0x3c,
3119 0x4b, 0x1e, 0xf3, 0xff, 0x3c, 0xdb, 0xe4, 0x68, 0x66, 0x83, 0x75, 0x83,
3120 0xf7, 0x26, 0x97, 0x79, 0x6d, 0x07, 0xa8, 0x89, 0x1d, 0x35, 0xcb, 0x45,
3121 0xf8, 0x41, 0x8e, 0x35, 0xd2, 0xc4, 0x8e, 0x65, 0x7b, 0x02, 0x6f, 0x9e,
3122 0xef, 0xac, 0x92, 0xf0, 0x9d, 0xe3, 0x46, 0x9e, 0x7c, 0xe0, 0xab, 0x62,
3123 0x3d, 0x6b, 0x34, 0x57, 0x5a, 0x8f, 0xdb, 0x50, 0x37, 0xe0, 0x36, 0xb1,
3124 0xa7, 0x0d, 0xe5, 0x41, 0xb6, 0x06, 0x70, 0xda, 0x6e, 0x63, 0x16, 0x2d,
3125 0xde, 0x6b, 0xdd, 0xe1, 0xfe, 0xdc, 0xb7, 0x55, 0xd6, 0xc8, 0x2a, 0x6f,
3126 0x62, 0xf4, 0x7e, 0x17, 0xfb, 0xbd, 0xce, 0xb1, 0xc8, 0x36, 0xff, 0x4a,
3127 0xdc, 0x7f, 0x16, 0x7b, 0x9e, 0x5b, 0x6c, 0x73, 0xdb, 0x40, 0x23, 0x7b,
3128 0xa3, 0x25, 0x54, 0xf8, 0x5f, 0x86, 0xf3, 0xfd, 0x1f, 0xff, 0x2b, 0xd2,
3129 0xaa, 0xe0, 0x74, 0xa5, 0x00, 0x7c, 0x2c, 0xb3, 0x0d, 0xbd, 0xdb, 0x18,
3130 0x37, 0x70, 0x14, 0xd8, 0x25, 0x38, 0x71, 0xbf, 0xa5, 0x6e, 0x44, 0xed,
3131 0x78, 0xae, 0x2b, 0x3c, 0x17, 0x62, 0x92, 0xbd, 0xf8, 0x07, 0x70, 0xa3,
3132 0x49, 0x79, 0x9a, 0xdf, 0xce, 0xd3, 0x85, 0x41, 0x9e, 0x66, 0xae, 0xe9,
3133 0xf0, 0x43, 0x14, 0x75, 0x2a, 0xac, 0x51, 0xe0, 0x6d, 0x73, 0x3f, 0xab,
3134 0xa4, 0xc8, 0xbc, 0x0e, 0xb4, 0x6f, 0x13, 0xad, 0x0d, 0x74, 0xf8, 0x4d,
3135 0x1d, 0x19, 0x5b, 0xa6, 0x97, 0x7f, 0x46, 0xf4, 0xf2, 0x80, 0x6d, 0x79,
3136 0xfc, 0xc4, 0xa6, 0x89, 0x3d, 0xcb, 0xc0, 0xfc, 0xc2, 0x40, 0x46, 0xbc,
3137 0x40, 0x3c, 0xed, 0x7b, 0x88, 0x93, 0x35, 0x3c, 0x4b, 0x88, 0x9d, 0x8c,
3138 0x0d, 0xc7, 0x91, 0x5d, 0xe0, 0xb3, 0x8c, 0xb6, 0xb3, 0xa8, 0x4b, 0xf4,
3139 0xae, 0xd8, 0x3a, 0xd5, 0x9c, 0x49, 0x6a, 0x67, 0xb1, 0x4a, 0x70, 0xac,
3140 0x3a, 0x08, 0x4e, 0x1d, 0x40, 0xfc, 0xf9, 0x9d, 0x32, 0x1e, 0xab, 0x10,
3141 0xd3, 0x8a, 0x87, 0x11, 0x9b, 0xfa, 0xa8, 0xe7, 0xf1, 0x6e, 0xe1, 0x7d,
3142 0x00, 0xe5, 0xc3, 0xe8, 0x3b, 0x1a, 0xa7, 0x32, 0xbb, 0x27, 0xc5, 0x28,
3143 0xf0, 0x6e, 0xc3, 0x40, 0x7f, 0x13, 0xba, 0x61, 0x7f, 0xe7, 0x10, 0x3f,
3144 0xd8, 0xe7, 0x39, 0xf8, 0x54, 0xc7, 0xdc, 0x82, 0x66, 0xb7, 0xa9, 0xa5,
3145 0xa4, 0xf1, 0xcb, 0x1f, 0xc6, 0xaf, 0x52, 0xcc, 0x83, 0x20, 0x14, 0xb0,
3146 0x61, 0xfd, 0x66, 0x7a, 0x65, 0xec, 0xc8, 0xf5, 0xa0, 0x65, 0x4f, 0x89,
3147 0xa2, 0x55, 0xa7, 0x40, 0x4d, 0xe0, 0xee, 0x42, 0xc3, 0x4d, 0x68, 0xd8,
3148 0x1f, 0xd1, 0xb0, 0xff, 0x3f, 0x35, 0x0c, 0x7d, 0x42, 0x23, 0xb7, 0xc1,
3149 0xa9, 0xb7, 0x7a, 0xfb, 0xe9, 0x99, 0xb5, 0xcc, 0x9a, 0x36, 0xe9, 0xce,
3150 0xd1, 0xa7, 0xd5, 0x74, 0x49, 0x7e, 0x4a, 0x4d, 0xb7, 0x58, 0xd3, 0x2a,
3151 0x6b, 0xba, 0xb8, 0x57, 0xd3, 0xd3, 0x18, 0x23, 0xd1, 0xe6, 0x19, 0xb5,
3152 0x48, 0xda, 0x3c, 0xf0, 0xd8, 0xc8, 0x93, 0x72, 0xed, 0x31, 0xef, 0x98,
3153 0xcb, 0xfe, 0x00, 0xff, 0xb6, 0x35, 0xb4, 0x49, 0xe3, 0xf5, 0x88, 0x81,
3154 0x6a, 0xd5, 0x2a, 0xad, 0xc5, 0x7d, 0x54, 0xd2, 0xe1, 0xff, 0xd7, 0x8f,
3155 0x5a, 0xa6, 0x29, 0x8f, 0x6a, 0x1f, 0xea, 0xdf, 0x88, 0xae, 0x68, 0x55,
3156 0x9e, 0xa7, 0x65, 0x82, 0xf3, 0xe6, 0x4f, 0x80, 0x55, 0xbb, 0xcb, 0x7c,
3157 0xb7, 0x45, 0x3d, 0xe6, 0x19, 0xca, 0xd0, 0x84, 0x06, 0xde, 0xe6, 0xd0,
3158 0x4f, 0xdd, 0x48, 0x74, 0x74, 0x1b, 0xe3, 0x6e, 0x75, 0x99, 0x67, 0x06,
3159 0xe9, 0xd7, 0xed, 0xd2, 0x85, 0x38, 0x06, 0xcf, 0x8a, 0x25, 0x62, 0x0d,
3160 0xf2, 0xb9, 0x88, 0xf6, 0x41, 0x8e, 0x94, 0x58, 0xf7, 0x13, 0xa9, 0xee,
3161 0x9f, 0x87, 0xaf, 0x26, 0x50, 0x66, 0xed, 0x1f, 0x4e, 0xb5, 0x3f, 0x85,
3162 0x37, 0xd7, 0xad, 0xa8, 0x09, 0x87, 0xc0, 0xc7, 0x0d, 0xc6, 0x37, 0x8f,
3163 0x58, 0xc7, 0xf3, 0xff, 0x33, 0x5a, 0xb5, 0x19, 0x63, 0xdb, 0xfc, 0x01,
3164 0xcd, 0x41, 0x7f, 0xa8, 0xdf, 0xe6, 0xbe, 0x6c, 0x93, 0xf5, 0x15, 0x69,
3165 0xdf, 0x0f, 0xf7, 0xf4, 0x45, 0xfd, 0x36, 0xf7, 0x63, 0x7d, 0x1c, 0x22,
3166 0xe5, 0x3a, 0x9f, 0xdb, 0x1e, 0xeb, 0x03, 0x76, 0x35, 0xd4, 0x71, 0x6e,
3167 0xc1, 0xf6, 0x7c, 0x86, 0xf3, 0x3a, 0x39, 0xef, 0xe0, 0x73, 0x7e, 0xcf,
3168 0x79, 0x3e, 0xd4, 0xc8, 0x19, 0xf0, 0xfe, 0x3b, 0xea, 0x27, 0x35, 0xb2,
3169 0x02, 0x4d, 0x5c, 0x54, 0x13, 0x8d, 0xbc, 0x86, 0xf7, 0x19, 0x94, 0x57,
3170 0xf6, 0x68, 0x24, 0xb3, 0x7b, 0xf2, 0x39, 0x1e, 0xf4, 0x4a, 0xf1, 0x99,
3171 0xcb, 0xf3, 0x29, 0x1b, 0xd4, 0xd2, 0x52, 0x3d, 0xd4, 0x87, 0x7a, 0x98,
3172 0x40, 0xcc, 0xc8, 0xa5, 0x5c, 0xc7, 0xdb, 0xfe, 0x48, 0xf1, 0x1d, 0x4b,
3173 0xb4, 0x89, 0xb5, 0x31, 0x7a, 0x9e, 0xfd, 0xbf, 0xf4, 0x41, 0xe0, 0x51,
3174 0x3c, 0x37, 0x72, 0x11, 0x3e, 0x17, 0xa2, 0xe8, 0x15, 0x07, 0xed, 0x59,
3175 0x4e, 0x12, 0x63, 0x9f, 0xc3, 0xd9, 0xcb, 0x78, 0x20, 0x0f, 0xb4, 0x67,
3176 0xa1, 0x07, 0x8e, 0x05, 0xbb, 0xd1, 0x96, 0xed, 0xa1, 0xae, 0x06, 0xff,
3177 0x33, 0x26, 0xcb, 0xd2, 0x52, 0xdf, 0x60, 0x3b, 0xe8, 0x6d, 0xbf, 0x5c,
3178 0x4c, 0x87, 0xae, 0x1e, 0xe3, 0xc4, 0x3c, 0x6a, 0x8e, 0xe0, 0xd4, 0x88,
3179 0x71, 0xda, 0x19, 0xe2, 0xd4, 0x4c, 0x71, 0x6a, 0xc6, 0x38, 0x3d, 0x48,
3180 0x71, 0xfa, 0xf3, 0x13, 0x70, 0xda, 0x79, 0x0a, 0x9c, 0x0c, 0xda, 0xb2,
3181 0x4b, 0x38, 0x6f, 0xf5, 0x38, 0x77, 0xbd, 0xef, 0xec, 0x97, 0x7b, 0xb1,
3182 0xdf, 0xc7, 0xb0, 0x8a, 0x18, 0xab, 0x2d, 0x1a, 0xcd, 0x43, 0x2c, 0xf3,
3183 0x1e, 0x15, 0x70, 0x6e, 0xe4, 0xe9, 0xea, 0x9e, 0x5c, 0x24, 0x00, 0x4e,
3184 0xb5, 0x14, 0xa7, 0xab, 0xc0, 0xa9, 0x96, 0xe2, 0xb4, 0x3e, 0x82, 0xd3,
3185 0xfa, 0x18, 0x4e, 0x1c, 0x53, 0x2a, 0xc6, 0x7a, 0x37, 0xc3, 0x28, 0xc3,
3186 0x47, 0xa7, 0x9b, 0x62, 0x0a, 0xfb, 0x3f, 0x4e, 0xed, 0x9f, 0xaa, 0x9c,
3187 0xff, 0x02, 0xbb, 0x97, 0x54, 0x39, 0x3e, 0x17, 0xf8, 0xfb, 0x71, 0xbe,
3188 0x82, 0xb9, 0x5c, 0xcf, 0xe1, 0x3d, 0x21, 0xcf, 0xb5, 0x47, 0x63, 0xd1,
3189 0x07, 0x88, 0x45, 0x5c, 0xc7, 0xfd, 0x54, 0xa9, 0x06, 0xcd, 0x2b, 0xc8,
3190 0xe1, 0xfd, 0x61, 0x0e, 0x9f, 0xf8, 0xe1, 0x6a, 0x9a, 0xc3, 0x6f, 0xd9,
3191 0x9c, 0xc3, 0x9f, 0xd0, 0x68, 0x62, 0x39, 0xc5, 0x93, 0x79, 0x3d, 0x89,
3192 0xb6, 0xb3, 0x31, 0xee, 0x6d, 0xc4, 0xf2, 0x55, 0xf8, 0xa0, 0x19, 0xf3,
3193 0x13, 0x79, 0x57, 0xca, 0x5d, 0xe4, 0xbb, 0xe4, 0x87, 0x09, 0x4f, 0x3f,
3194 0xdb, 0x5c, 0xec, 0xef, 0x88, 0xd9, 0x46, 0x43, 0xc5, 0x1d, 0xe0, 0x6e,
3195 0x18, 0xc7, 0xea, 0x73, 0x41, 0x97, 0x5a, 0x47, 0xaa, 0x57, 0x22, 0xe0,
3196 0xee, 0x7e, 0xfd, 0x34, 0x9f, 0x39, 0xf9, 0x45, 0xaf, 0x82, 0xfa, 0x81,
3197 0x41, 0xc8, 0x83, 0x70, 0xa7, 0xa1, 0x96, 0x77, 0x5a, 0x42, 0xbe, 0x83,
3198 0x32, 0x6c, 0x82, 0x70, 0xba, 0x21, 0x57, 0x4b, 0xe0, 0x43, 0x8b, 0x5c,
3199 0xac, 0xd3, 0x0d, 0xe3, 0x7b, 0x4d, 0x43, 0xa9, 0x1a, 0xc8, 0x37, 0xc9,
3200 0xc0, 0x99, 0x0f, 0x9f, 0x98, 0x46, 0x7b, 0x80, 0x9c, 0x08, 0x79, 0x80,
3201 0xb7, 0x08, 0xbf, 0x1c, 0x03, 0x76, 0xa1, 0x0a, 0xdb, 0x6f, 0xe9, 0xc9,
3202 0x9d, 0x88, 0xc8, 0x8b, 0xfd, 0xf5, 0x71, 0xca, 0x91, 0x38, 0xe7, 0x92,
3203 0x6a, 0x3d, 0x32, 0x9b, 0x0e, 0xb8, 0x8e, 0x33, 0xa5, 0x13, 0x72, 0x5e,
3204 0x7d, 0xcc, 0x90, 0xaf, 0x71, 0x3c, 0x7f, 0x00, 0x1f, 0xe2, 0x7b, 0x9b,
3205 0xcf, 0x19, 0x85, 0x73, 0x73, 0xdc, 0x7d, 0xca, 0x88, 0x37, 0x34, 0x89,
3206 0xd8, 0x87, 0xd8, 0x3b, 0xcd, 0x58, 0xb9, 0xc9, 0x19, 0xc4, 0xe3, 0x1d,
3207 0x97, 0x93, 0x79, 0xfe, 0xa4, 0x25, 0x1c, 0xc6, 0x7d, 0x07, 0xfe, 0x5b,
3208 0xed, 0x39, 0x1c, 0x73, 0x3f, 0xaf, 0xd0, 0x43, 0x8a, 0x39, 0x29, 0x4e,
3209 0x20, 0x16, 0x9f, 0x86, 0x8d, 0x1b, 0xeb, 0x31, 0xc9, 0xbd, 0x32, 0x9b,
3210 0x0f, 0xf7, 0x8c, 0xf1, 0x17, 0x65, 0xbc, 0xec, 0x82, 0xd3, 0x95, 0x74,
3211 0xbe, 0x51, 0x8e, 0x2c, 0x20, 0xe5, 0x79, 0xa0, 0x0d, 0xf3, 0xb7, 0xa2,
3212 0x8e, 0x7e, 0xbc, 0x46, 0xd6, 0x25, 0xdb, 0x1c, 0xd1, 0xc6, 0xc7, 0x99,
3213 0xdd, 0x67, 0x8c, 0xea, 0xc8, 0x18, 0x45, 0xde, 0x9b, 0x68, 0x3a, 0xcf,
3214 0xa4, 0xf7, 0x0c, 0x8e, 0x2d, 0x02, 0x3a, 0x95, 0x9f, 0x93, 0xb1, 0x0f,
3215 0x0f, 0x7b, 0xf6, 0xe3, 0xfa, 0x5f, 0xe9, 0xe3, 0xe3, 0xfe, 0x56, 0x4d,
3216 0xca, 0xc7, 0x12, 0x6e, 0xda, 0x78, 0x87, 0x0f, 0x46, 0xd6, 0xae, 0xed,
3217 0x33, 0xef, 0xd7, 0x38, 0x5d, 0x43, 0xbc, 0x21, 0x57, 0xc1, 0x1d, 0xcc,
3218 0x27, 0x7c, 0x87, 0xaf, 0x67, 0x3e, 0x04, 0x6f, 0xe8, 0x5c, 0x3b, 0xe5,
3219 0x8b, 0x9c, 0xf0, 0x85, 0xf3, 0xba, 0xc5, 0x55, 0xf0, 0xa5, 0x0d, 0xbe,
3220 0xc0, 0xae, 0xa1, 0x55, 0xa7, 0xc1, 0x05, 0x8e, 0x4d, 0x28, 0x87, 0xcc,
3221 0x1d, 0xe6, 0x0a, 0xf3, 0xe6, 0x31, 0x5f, 0x5e, 0xe9, 0x1a, 0xc6, 0xe6,
3222 0xa7, 0x70, 0xe5, 0x8d, 0x98, 0x2b, 0xcc, 0xd9, 0x24, 0x7e, 0x74, 0x80,
3223 0x55, 0x90, 0xc6, 0x8f, 0x00, 0xf1, 0xa3, 0xc6, 0xf9, 0x4f, 0x1c, 0x0b,
3224 0x12, 0xfd, 0xac, 0x41, 0x3f, 0x35, 0x85, 0xf3, 0x23, 0xd6, 0x0e, 0xdb,
3225 0xb1, 0x7e, 0xd8, 0xae, 0x90, 0xda, 0x8d, 0xc7, 0x91, 0x76, 0xcf, 0x32,
3226 0xb3, 0x38, 0xd2, 0x86, 0x76, 0x3a, 0xa9, 0x8e, 0xda, 0xa9, 0x8e, 0xd0,
3227 0xa7, 0xa5, 0x54, 0xf8, 0x4c, 0xb0, 0x4c, 0x1f, 0xf1, 0xa3, 0x13, 0x8f,
3228 0xd9, 0xa2, 0xe4, 0x2e, 0xc3, 0xda, 0xe6, 0xb8, 0x3b, 0x12, 0x6f, 0xd3,
3229 0x7b, 0x6e, 0x23, 0xbe, 0xe7, 0x7e, 0x45, 0x1f, 0x8f, 0xb7, 0x38, 0x6b,
3230 0xe2, 0x7b, 0xee, 0x29, 0x9d, 0xef, 0xb9, 0x01, 0x7d, 0x49, 0x1f, 0xbd,
3231 0xe7, 0x06, 0x63, 0xf7, 0xdc, 0xcc, 0x96, 0xeb, 0xf7, 0x8b, 0xbb, 0x99,
3232 0x4f, 0x38, 0xf6, 0x32, 0x9f, 0xf6, 0xcb, 0x15, 0xb3, 0x3e, 0x1c, 0x93,
3233 0x58, 0xef, 0x1c, 0xcb, 0x92, 0xdc, 0xec, 0x6e, 0x98, 0xe9, 0xe2, 0x55,
3234 0xcc, 0x83, 0x72, 0x6f, 0x3f, 0x5d, 0x18, 0xa9, 0x2e, 0x26, 0x13, 0x9b,
3235 0xde, 0xa8, 0x36, 0x5e, 0xd5, 0xc7, 0xb5, 0x91, 0x8d, 0x93, 0x69, 0x23,
3236 0x19, 0x73, 0x47, 0x29, 0xe1, 0x0c, 0x2c, 0x23, 0x1e, 0x09, 0xbe, 0xa3,
3237 0x21, 0x5e, 0x54, 0xf3, 0xb8, 0xa7, 0x14, 0x78, 0xec, 0x76, 0xf8, 0x2c,
3238 0x35, 0x8a, 0x8c, 0x0b, 0xaf, 0xff, 0x61, 0x7c, 0x7f, 0xc0, 0xba, 0x0b,
3239 0x01, 0xff, 0xfe, 0xf1, 0x09, 0x3e, 0xbe, 0x06, 0x3e, 0x66, 0xfb, 0x19,
3240 0xad, 0xbf, 0x34, 0x52, 0x5f, 0x4e, 0x31, 0x4f, 0x7c, 0x7e, 0x2f, 0xd5,
3241 0xc8, 0x26, 0x72, 0xb7, 0xfb, 0xc8, 0x8b, 0xde, 0x44, 0xfc, 0x0e, 0x06,
3242 0x1f, 0x47, 0xf7, 0x8a, 0x2a, 0x75, 0x86, 0x36, 0xbf, 0xc0, 0xba, 0x2d,
3243 0x71, 0x13, 0x5f, 0x6f, 0x0c, 0xb2, 0xb1, 0xb9, 0x9d, 0xeb, 0xfe, 0x8d,
3244 0xf3, 0x19, 0x79, 0xdf, 0xb0, 0xef, 0xfb, 0x11, 0xe7, 0xbb, 0x77, 0x81,
3245 0xc5, 0x3b, 0xe1, 0x34, 0xfd, 0x1e, 0x1c, 0x7b, 0x3b, 0xce, 0x79, 0x93,
3246 0x5c, 0x17, 0xfe, 0xc3, 0x99, 0xc7, 0x67, 0xbd, 0xf7, 0x39, 0x99, 0x2e,
3247 0xd3, 0x57, 0x1d, 0xae, 0x93, 0xa9, 0x7e, 0x2a, 0x8a, 0x2e, 0xe2, 0xdc,
3248 0x5f, 0x19, 0x3b, 0xf7, 0x71, 0x07, 0x3c, 0xc9, 0xf9, 0x7f, 0x96, 0xf3,
3249 0xef, 0x46, 0x33, 0xf3, 0xd6, 0x4d, 0x97, 0x5c, 0xa9, 0xde, 0xe7, 0x7c,
3250 0x6c, 0x98, 0x8b, 0x11, 0x1d, 0x7a, 0x14, 0xc9, 0xf3, 0x7c, 0x36, 0xbd,
3251 0x9b, 0xfa, 0x1c, 0x6d, 0x37, 0x1e, 0xe1, 0x1e, 0x53, 0x8b, 0x7f, 0x17,
3252 0x72, 0xfb, 0x3c, 0x0f, 0x97, 0xf1, 0x0e, 0x39, 0x47, 0x78, 0xd2, 0x6f,
3253 0x35, 0x2a, 0xf0, 0xb5, 0xcc, 0x75, 0x85, 0xe2, 0x7b, 0x21, 0xee, 0x6e,
3254 0x3f, 0x6f, 0x53, 0x12, 0x3b, 0x6a, 0xce, 0x39, 0xac, 0x05, 0x98, 0x88,
3255 0x06, 0x30, 0x9e, 0x47, 0xac, 0xb2, 0xcc, 0x93, 0x72, 0xf2, 0x5b, 0xd5,
3256 0x1a, 0xc6, 0x56, 0x4e, 0x72, 0x2e, 0xf9, 0x51, 0xb4, 0x36, 0x88, 0xcf,
3257 0x44, 0x87, 0xb9, 0xe6, 0x87, 0x07, 0x65, 0x7e, 0xbb, 0x21, 0x7f, 0xeb,
3258 0x98, 0xc7, 0x7c, 0x02, 0x0f, 0x8b, 0xa2, 0x76, 0xc3, 0x14, 0xf5, 0x9e,
3259 0x29, 0x96, 0x7a, 0x32, 0x54, 0x52, 0xc8, 0xd1, 0x14, 0xe7, 0x08, 0x3a,
3260 0xd1, 0x73, 0x58, 0xcb, 0x2d, 0x53, 0xf8, 0xc8, 0xa3, 0xbe, 0xad, 0x58,
3261 0x62, 0x85, 0x76, 0xb1, 0xc7, 0x47, 0x51, 0x72, 0xa7, 0x35, 0x45, 0x6d,
3262 0x38, 0xf7, 0x23, 0xcc, 0xcd, 0x6b, 0x62, 0x2d, 0xf3, 0x79, 0xb6, 0x2c,
3263 0x9d, 0x83, 0x8f, 0xce, 0xf7, 0x77, 0x11, 0x43, 0xf9, 0x3c, 0xcb, 0x23,
3264 0xe6, 0x59, 0x26, 0x5f, 0xf6, 0xef, 0x62, 0xff, 0xef, 0xf4, 0x80, 0x0f,
3265 0x72, 0xc7, 0xb7, 0x87, 0x79, 0x1a, 0x63, 0x58, 0x06, 0x17, 0xd9, 0x3e,
3266 0x8a, 0x82, 0xc5, 0x38, 0x47, 0xc1, 0x5a, 0xe6, 0xca, 0xb7, 0x90, 0xa7,
3267 0xd7, 0x69, 0xa1, 0x5c, 0x8f, 0xdf, 0x11, 0x72, 0x12, 0xfe, 0x5d, 0xc0,
3268 0x12, 0x4d, 0x7c, 0xd7, 0xd2, 0xef, 0x80, 0x73, 0xf8, 0x45, 0x1e, 0x83,
3269 0x73, 0x79, 0xd6, 0xe1, 0x7f, 0x01, 0x17, 0xc6, 0xf1, 0xb2, 0x84, 0x14,
3270 0x00, 0x00, 0x00 };
3271static u32 bnx2_TPAT_b09FwData[(0x0/4) + 1] = { 0x0 };
3272static u32 bnx2_TPAT_b09FwRodata[(0x0/4) + 1] = { 0x0 };
3273static u32 bnx2_TPAT_b09FwBss[(0x250/4) + 1] = { 0x0 };
3274static u32 bnx2_TPAT_b09FwSbss[(0x34/4) + 1] = { 0x0 };
3275
3276static struct fw_info bnx2_tpat_fw_09 = {
3277 .ver_major = 0x1,
3278 .ver_minor = 0x0,
3279 .ver_fix = 0x0,
3280
3281 .start_addr = 0x08000860,
3282
3283 .text_addr = 0x08000800,
3284 .text_len = 0x1480,
3285 .text_index = 0x0,
3286 .gz_text = bnx2_TPAT_b09FwText,
3287 .gz_text_len = sizeof(bnx2_TPAT_b09FwText),
3288
3289 .data_addr = 0x08001ca0,
3290 .data_len = 0x0,
3291 .data_index = 0x0,
3292 .data = bnx2_TPAT_b09FwData,
3293
3294 .sbss_addr = 0x08001ca0,
3295 .sbss_len = 0x34,
3296 .sbss_index = 0x0,
3297 .sbss = bnx2_TPAT_b09FwSbss,
3298
3299 .bss_addr = 0x08001ce0,
3300 .bss_len = 0x250,
3301 .bss_index = 0x0,
3302 .bss = bnx2_TPAT_b09FwBss,
3303
3304 .rodata_addr = 0x00000000,
3305 .rodata_len = 0x0,
3306 .rodata_index = 0x0,
3307 .rodata = bnx2_TPAT_b09FwRodata,
3308};
3309
3310static u8 bnx2_TXP_b09FwText[] = {
3311 0x1f, 0x8b, 0x08, 0x08, 0x51, 0xfe, 0x2f, 0x45, 0x00, 0x03, 0x74, 0x65,
3312 0x73, 0x74, 0x31, 0x2e, 0x62, 0x69, 0x6e, 0x00, 0xcd, 0x7b, 0x7f, 0x70,
3313 0x1b, 0xe7, 0x99, 0xde, 0xbb, 0x0b, 0x80, 0x04, 0x29, 0x8a, 0x5a, 0x31,
3314 0x30, 0x83, 0x38, 0xb4, 0x8d, 0x15, 0x17, 0x34, 0x6d, 0xf2, 0x1c, 0x58,
3315 0xe5, 0xf9, 0xd8, 0x06, 0xb5, 0xd7, 0xc0, 0x92, 0xa2, 0x63, 0x26, 0x47,
3316 0xbb, 0xcc, 0x9d, 0x92, 0x51, 0x7d, 0x28, 0x48, 0x29, 0x6e, 0xe3, 0xb4,
3317 0xaa, 0xe3, 0x3f, 0x34, 0x4d, 0x5b, 0xc3, 0x00, 0x25, 0xcb, 0x2e, 0x44,
3318 0xd0, 0x16, 0x63, 0xa5, 0x33, 0x37, 0x53, 0x18, 0x80, 0x28, 0xe7, 0xba,
3319 0x24, 0xdc, 0xe4, 0x2e, 0xe9, 0x1f, 0xc9, 0x99, 0xa5, 0x6c, 0xc5, 0x6d,
3320 0xae, 0x33, 0xbe, 0x3f, 0xda, 0xa6, 0x37, 0xd7, 0x19, 0x8d, 0xfc, 0x23,
3321 0xce, 0x8f, 0xb9, 0xb8, 0x69, 0x7a, 0x56, 0x5b, 0xd9, 0xe8, 0xf3, 0x7c,
3322 0xbb, 0x4b, 0x82, 0x32, 0x15, 0x5b, 0xd7, 0x76, 0xa6, 0x9c, 0xc1, 0x10,
3323 0xfb, 0xed, 0xb7, 0xdf, 0xf7, 0xfe, 0x7e, 0xdf, 0xe7, 0xfd, 0x16, 0x71,
3324 0x91, 0x6e, 0xf1, 0xff, 0x76, 0xe3, 0x93, 0x38, 0x7a, 0xec, 0xb1, 0x3b,
3325 0xc6, 0xef, 0xd8, 0x2f, 0x72, 0xe7, 0x9d, 0xb2, 0x2b, 0xaa, 0xf3, 0xe6,
3326 0xdb, 0x21, 0x91, 0xdc, 0x4f, 0xe5, 0xaf, 0xfc, 0x87, 0xc7, 0x8d, 0x60,
3327 0x7d, 0x7e, 0x24, 0xaa, 0xa7, 0x5f, 0xcc, 0x64, 0x2c, 0x89, 0x86, 0xd2,
3328 0x33, 0x9f, 0x9d, 0xb3, 0x44, 0x6c, 0x77, 0x24, 0x91, 0x95, 0xf7, 0x5a,
3329 0x85, 0x58, 0x58, 0x38, 0x7e, 0x53, 0xfa, 0xca, 0xe3, 0xdf, 0xff, 0x2d,
3330 0xf3, 0x9d, 0x6a, 0x48, 0xa2, 0x46, 0x3a, 0x27, 0xc6, 0x90, 0x44, 0x07,
3331 0xf0, 0xcc, 0xef, 0xdf, 0x3a, 0xa5, 0x4b, 0x6f, 0xb0, 0x56, 0x5c, 0x16,
3332 0x2a, 0x6f, 0xb7, 0xbe, 0x7f, 0x6b, 0x4c, 0xfe, 0x55, 0xd3, 0x90, 0x17,
3333 0x9b, 0x61, 0x6d, 0xb2, 0xd2, 0x23, 0xa5, 0x8a, 0x2b, 0xc7, 0xcb, 0x05,
3334 0xc9, 0x36, 0x5f, 0x90, 0xe2, 0xb2, 0xd1, 0x9b, 0x39, 0xf7, 0x07, 0x52,
3335 0x5a, 0xee, 0xeb, 0xcd, 0x9e, 0x73, 0xa5, 0x58, 0x8e, 0xf7, 0x66, 0x9a,
3336 0x46, 0x6f, 0xf6, 0x4c, 0x0c, 0xd7, 0x7d, 0xbd, 0x99, 0x33, 0x66, 0x41,
3337 0xa4, 0x1f, 0x73, 0xe2, 0xbd, 0xd9, 0x8a, 0x99, 0x13, 0x19, 0x4c, 0xbd,
3338 0x22, 0x03, 0xbd, 0xd9, 0x66, 0x4d, 0x5b, 0x37, 0x34, 0x29, 0xfe, 0x86,
3339 0x18, 0xbd, 0xe9, 0xcb, 0xad, 0x4f, 0x58, 0x86, 0xec, 0xb5, 0x64, 0xcf,
3340 0x1e, 0x4b, 0x9e, 0x88, 0xa7, 0xa3, 0x92, 0x3f, 0xdd, 0x25, 0xb6, 0xe2,
3341 0xc9, 0x90, 0xfc, 0x99, 0x11, 0x63, 0x43, 0x22, 0x62, 0xc7, 0x82, 0xeb,
3342 0x56, 0x2b, 0x93, 0xfa, 0x02, 0xe5, 0x8a, 0xbd, 0xa4, 0x77, 0xb2, 0x29,
3343 0x92, 0xa9, 0x44, 0x25, 0x93, 0x7a, 0xaf, 0xe5, 0x3d, 0x13, 0xc5, 0xbe,
3344 0xe1, 0xde, 0x89, 0x4a, 0xab, 0xe5, 0xa4, 0xb0, 0x47, 0x2a, 0x78, 0x36,
3345 0x22, 0xd5, 0x98, 0x5d, 0x2d, 0xa5, 0x4c, 0xdd, 0xd3, 0x09, 0x79, 0xe4,
3346 0xb5, 0x2d, 0xba, 0xf5, 0xdb, 0x92, 0x8f, 0x49, 0xb5, 0x98, 0xba, 0x4b,
3347 0x9e, 0x4e, 0x19, 0x72, 0x12, 0xeb, 0x3d, 0x95, 0x82, 0x1c, 0xad, 0x63,
3348 0x5a, 0xa6, 0x69, 0xc6, 0x45, 0x7b, 0x5a, 0x32, 0x67, 0x06, 0x8d, 0xac,
3349 0x60, 0x6f, 0xab, 0x75, 0x4b, 0x26, 0x85, 0xfd, 0x46, 0xff, 0x67, 0xcb,
3350 0x8e, 0x99, 0xb9, 0xaa, 0x0c, 0x48, 0xb1, 0x32, 0x98, 0xfa, 0x13, 0xd1,
3351 0xa4, 0xd3, 0xa2, 0x7c, 0x5a, 0x72, 0x3f, 0xf6, 0xcd, 0x58, 0x18, 0x6f,
3352 0x8a, 0xad, 0x27, 0x23, 0xf2, 0x0f, 0x0c, 0x33, 0x91, 0x09, 0xf5, 0x4b,
3353 0xf1, 0x74, 0x27, 0xe8, 0xb4, 0xfb, 0x74, 0xcc, 0x3d, 0x30, 0x26, 0xb1,
3354 0x5d, 0x22, 0x5a, 0x28, 0x9d, 0xc4, 0xba, 0x22, 0x45, 0x77, 0x00, 0xcf,
3355 0x26, 0xc7, 0x7f, 0x2a, 0x7b, 0x24, 0xb1, 0x37, 0x2c, 0x25, 0xb7, 0x1b,
3356 0x72, 0x34, 0xa0, 0x83, 0xe4, 0xf8, 0x5f, 0x40, 0x29, 0xba, 0x95, 0x8c,
3357 0x1f, 0x93, 0x9c, 0x96, 0x6d, 0x76, 0x48, 0x29, 0x19, 0x95, 0x05, 0xd0,
3358 0xb1, 0x90, 0xfa, 0xa2, 0x96, 0x39, 0x77, 0x50, 0xcb, 0x9e, 0xc3, 0xbc,
3359 0x66, 0xdd, 0xb7, 0x35, 0x03, 0xeb, 0xe8, 0x52, 0x4c, 0x1e, 0xc4, 0xbd,
3360 0xa8, 0xcc, 0x61, 0xde, 0x1c, 0x78, 0x2a, 0x35, 0xf7, 0xc8, 0xfa, 0x6c,
3361 0xac, 0x37, 0x03, 0x1d, 0x16, 0x71, 0xff, 0xb7, 0x67, 0x34, 0x31, 0x2c,
3362 0x5b, 0x7e, 0x3c, 0x06, 0x1d, 0x9e, 0x81, 0xfe, 0xce, 0xc4, 0xe5, 0x78,
3363 0x45, 0x62, 0xba, 0x24, 0xe3, 0x79, 0x79, 0x41, 0xea, 0x2e, 0xf5, 0x0f,
3364 0x7d, 0x42, 0xdf, 0x45, 0x97, 0xcf, 0x41, 0x6f, 0x15, 0x07, 0xf2, 0x98,
3365 0x02, 0x0d, 0x0f, 0x6a, 0xf7, 0xd7, 0x67, 0xb5, 0x03, 0xcd, 0x1f, 0x6b,
3366 0xd2, 0x7d, 0x4c, 0xfb, 0x5c, 0xf3, 0x88, 0xe6, 0xcb, 0x1e, 0xba, 0x8b,
3367 0x8a, 0x3d, 0x13, 0x95, 0x95, 0xa6, 0xa7, 0xbb, 0x1a, 0xec, 0xd3, 0x36,
3368 0x6c, 0xe8, 0xe1, 0x6f, 0x6f, 0xce, 0x59, 0x69, 0xc6, 0x64, 0x01, 0xb4,
3369 0x1d, 0x6f, 0x72, 0xfe, 0xef, 0x41, 0x3f, 0x51, 0x71, 0x6f, 0xed, 0x91,
3370 0x1c, 0xc6, 0x8b, 0x67, 0xc4, 0xce, 0xa4, 0x74, 0x3c, 0xd3, 0x2b, 0x21,
3371 0xab, 0x1f, 0x9f, 0x6e, 0x99, 0xab, 0x77, 0xda, 0x21, 0x2b, 0x26, 0x73,
3372 0x4d, 0xca, 0x10, 0xff, 0x2b, 0x81, 0x1c, 0x49, 0x2b, 0xc7, 0xf9, 0x1c,
3373 0xc7, 0x0d, 0x8c, 0xb7, 0x8f, 0xd1, 0x2e, 0x7a, 0x41, 0x8f, 0x39, 0x2c,
3374 0x18, 0xcb, 0x57, 0x92, 0xc6, 0xe7, 0xf8, 0xbf, 0x49, 0xd9, 0x06, 0x32,
3375 0x0d, 0x63, 0xae, 0x2e, 0xf9, 0x3a, 0xf6, 0x39, 0x7d, 0xa5, 0x15, 0x19,
3376 0xc3, 0xb5, 0xf5, 0x4b, 0xc8, 0x92, 0xfb, 0x86, 0x41, 0x93, 0x2e, 0xb9,
3377 0x3a, 0xd7, 0xe2, 0x7d, 0x81, 0xee, 0x8b, 0x7b, 0x75, 0x19, 0x86, 0x7e,
3378 0x4d, 0xec, 0xd3, 0x85, 0x39, 0x3d, 0x90, 0x1f, 0x78, 0x3d, 0x87, 0xef,
3379 0xe0, 0x5d, 0xb7, 0x74, 0x3c, 0xdf, 0x29, 0x73, 0x29, 0xda, 0x0b, 0xe9,
3380 0xdc, 0x85, 0xb5, 0xbb, 0x64, 0xfe, 0x34, 0xe5, 0x01, 0xbb, 0xaa, 0xc4,
3381 0xa4, 0x74, 0xc6, 0x34, 0x1c, 0x31, 0x21, 0x1b, 0x1b, 0xf3, 0x3a, 0x25,
3382 0x67, 0xb4, 0x5a, 0x13, 0xa9, 0x11, 0xe3, 0x9b, 0xca, 0xce, 0x47, 0x8c,
3383 0xa4, 0x26, 0x85, 0x8e, 0xf4, 0x10, 0x64, 0x6b, 0x1e, 0x14, 0xe1, 0xf5,
3384 0x0f, 0xc4, 0x9e, 0xa5, 0xff, 0xc4, 0xb8, 0x17, 0xfc, 0xa9, 0x1f, 0xf4,
3385 0xd3, 0xe7, 0x06, 0xa0, 0x97, 0xb8, 0xf2, 0x83, 0x89, 0x1d, 0xfd, 0xc0,
3386 0x9c, 0xaa, 0x82, 0xdf, 0xe2, 0xb9, 0x30, 0xfd, 0x2f, 0x05, 0x73, 0x93,
3387 0x5d, 0x56, 0x14, 0xb6, 0x40, 0x5a, 0xc6, 0xb1, 0x7e, 0xab, 0xf5, 0xd9,
3388 0x94, 0x47, 0x53, 0xf1, 0x8c, 0x8d, 0x67, 0xc3, 0x90, 0xbb, 0xf9, 0x70,
3389 0x42, 0xed, 0x3f, 0xee, 0xef, 0x6f, 0xc8, 0x1c, 0xe8, 0x2e, 0x56, 0x42,
3390 0x92, 0x35, 0xb8, 0xc6, 0x9f, 0x71, 0x3c, 0xe7, 0xad, 0x05, 0xbb, 0x3d,
3391 0x35, 0x68, 0xdc, 0x07, 0x5f, 0xa2, 0x8f, 0x15, 0x57, 0x29, 0x63, 0xac,
3392 0x33, 0x46, 0x19, 0x1b, 0x8a, 0xc6, 0xcc, 0x19, 0xda, 0x91, 0x0c, 0x84,
3393 0x84, 0x76, 0x8e, 0x98, 0x01, 0xbb, 0x2a, 0xf9, 0x76, 0x95, 0x77, 0xa9,
3394 0xff, 0xbb, 0x7d, 0xff, 0xd4, 0x65, 0x28, 0x49, 0x7b, 0x7f, 0x5a, 0xb2,
3395 0xf0, 0xf1, 0x39, 0xec, 0x54, 0x07, 0x4f, 0xb5, 0xca, 0x20, 0x64, 0x15,
3396 0xf8, 0x1d, 0xf4, 0x3b, 0xfa, 0x6e, 0x2b, 0x88, 0x05, 0xc5, 0x0a, 0x7d,
3397 0xa6, 0x68, 0xe8, 0x52, 0xc0, 0x07, 0x76, 0x63, 0x99, 0xc3, 0x99, 0x90,
3398 0x39, 0x93, 0x03, 0x6d, 0xb0, 0x7b, 0xc9, 0xdc, 0x49, 0x7b, 0xc6, 0x9c,
3399 0xa6, 0xec, 0x0f, 0xfc, 0xac, 0xe6, 0x52, 0x4f, 0xdd, 0xd8, 0x37, 0xa0,
3400 0x29, 0x8c, 0x31, 0xae, 0x13, 0x85, 0xcd, 0x07, 0x36, 0x43, 0xfb, 0x33,
3401 0xed, 0x75, 0xe9, 0x90, 0xe1, 0x24, 0x62, 0xd9, 0x19, 0x1d, 0xfa, 0x1b,
3402 0x40, 0x4c, 0x09, 0xcb, 0x11, 0xc8, 0xea, 0x4b, 0x15, 0xd2, 0xe7, 0xc0,
3403 0xef, 0x10, 0xdb, 0xce, 0x4c, 0xc2, 0xcf, 0xa6, 0xb4, 0x09, 0xf8, 0xc4,
3404 0x67, 0xea, 0xa4, 0xa9, 0x25, 0xf4, 0x4b, 0xe7, 0x5c, 0x4e, 0x9b, 0x6c,
3405 0x1e, 0xd4, 0xa6, 0xce, 0xd1, 0x4f, 0xe8, 0x23, 0xa6, 0xf1, 0x80, 0x78,
3406 0x3c, 0x14, 0x9b, 0xaf, 0x68, 0xf4, 0xd5, 0xe2, 0xa9, 0x2e, 0xd0, 0xb1,
3407 0x0b, 0xf4, 0x18, 0xf0, 0x3d, 0xd8, 0x97, 0x65, 0xce, 0xd0, 0x66, 0x9c,
3408 0xa4, 0x95, 0xf8, 0xe7, 0xf2, 0x41, 0x39, 0x4c, 0x6c, 0xca, 0x61, 0x04,
3409 0x32, 0xd9, 0x2e, 0x87, 0x85, 0x0f, 0xca, 0xc1, 0x2e, 0x40, 0x0e, 0x0b,
3410 0x88, 0x43, 0x0b, 0x4d, 0xf2, 0xdc, 0x12, 0xfd, 0x4e, 0x81, 0x75, 0xca,
3411 0xbd, 0x7a, 0x9a, 0x36, 0x4a, 0x3f, 0x49, 0x26, 0x4a, 0x58, 0xa1, 0xe1,
3412 0xf6, 0x28, 0xdf, 0x98, 0x54, 0xb2, 0xf8, 0x30, 0x7e, 0xc9, 0xdf, 0x16,
3413 0xcf, 0x53, 0x75, 0xc6, 0x1b, 0xd8, 0x79, 0xd2, 0x32, 0xbe, 0x20, 0x5b,
3414 0x7c, 0xdf, 0xb7, 0xc5, 0x37, 0xf6, 0x09, 0x62, 0x10, 0x79, 0x0e, 0xe2,
3415 0x31, 0x6d, 0xe5, 0xa5, 0x56, 0xc8, 0xb2, 0xa0, 0x03, 0xda, 0x0b, 0x69,
3416 0x30, 0x8d, 0xcf, 0x0a, 0xfe, 0x23, 0x2e, 0xd0, 0x97, 0x72, 0x6a, 0x5e,
3417 0x87, 0xe4, 0xf6, 0x7a, 0xf3, 0xe7, 0x2a, 0xad, 0x5f, 0xe8, 0xe9, 0xf7,
3418 0x5b, 0x99, 0x31, 0xcb, 0xf7, 0xf1, 0xa8, 0x7c, 0xb9, 0x6e, 0xe6, 0x12,
3419 0x5a, 0x8f, 0x14, 0x6e, 0x40, 0x5c, 0xa9, 0xd0, 0x3f, 0xfa, 0xaf, 0x11,
3420 0xcb, 0x06, 0xfc, 0x58, 0xf6, 0x13, 0xc8, 0x9e, 0xb9, 0xe7, 0xf0, 0xfb,
3421 0xeb, 0x31, 0xfe, 0x4f, 0x1a, 0x33, 0xf2, 0x05, 0xe6, 0x9b, 0x3d, 0xba,
3422 0x8a, 0xdf, 0x16, 0x73, 0x41, 0x21, 0x9c, 0xee, 0x96, 0xc2, 0x5e, 0x29,
3423 0x84, 0xd2, 0xf4, 0x23, 0xfa, 0x46, 0x87, 0x4f, 0x77, 0x90, 0x3b, 0xf8,
3424 0x77, 0x4c, 0x17, 0x8b, 0x73, 0x90, 0x27, 0x2a, 0xe4, 0xe3, 0xbd, 0x40,
3425 0x27, 0x78, 0x46, 0x22, 0x9e, 0xcd, 0x4d, 0x23, 0x66, 0x52, 0xa6, 0xed,
3426 0xf6, 0xc2, 0x58, 0x2a, 0x09, 0xdd, 0x62, 0x2c, 0x15, 0x23, 0x94, 0x7e,
3427 0x50, 0xb3, 0xeb, 0x5f, 0xd4, 0x6c, 0xc8, 0xce, 0x86, 0xec, 0x6c, 0xc8,
3428 0x2e, 0x03, 0xd9, 0x65, 0x9b, 0xa4, 0x87, 0xb4, 0x78, 0xeb, 0x3b, 0xde,
3429 0xfa, 0xa0, 0xb3, 0x5f, 0xf2, 0xca, 0xc7, 0xc9, 0x2f, 0x62, 0xb2, 0x8a,
3430 0x07, 0x93, 0x9a, 0x17, 0x0f, 0xb8, 0xde, 0x14, 0x9e, 0xbf, 0x1b, 0x79,
3431 0xce, 0xd6, 0x75, 0x6b, 0x4b, 0x26, 0x0b, 0x6d, 0x32, 0x29, 0xb9, 0x94,
3432 0x11, 0xe7, 0xd3, 0x97, 0x5d, 0xe8, 0x3d, 0x90, 0xcb, 0x34, 0x68, 0xe8,
3433 0x24, 0xef, 0x3e, 0x1f, 0x5c, 0xbf, 0xcf, 0x5f, 0xff, 0xd3, 0x58, 0x93,
3434 0xbe, 0xbb, 0xd3, 0xbe, 0xdc, 0x93, 0xb9, 0xf4, 0xd7, 0xf1, 0x83, 0x5a,
3435 0x02, 0x31, 0xfa, 0x45, 0xf8, 0xda, 0xc5, 0x50, 0x5c, 0xbe, 0x7f, 0xeb,
3436 0x6b, 0xa8, 0x2f, 0xa4, 0x70, 0x63, 0xba, 0x95, 0x08, 0xa7, 0xdf, 0x6b,
3437 0x2d, 0x8c, 0x21, 0x7e, 0xa6, 0xcd, 0x78, 0x26, 0x34, 0x2a, 0x2f, 0x35,
3438 0x87, 0xe5, 0x3b, 0x4d, 0x4b, 0xfe, 0xa8, 0x99, 0x90, 0x3f, 0x6c, 0x0e,
3439 0xc8, 0xb7, 0x9b, 0x71, 0xf9, 0x56, 0x33, 0xa8, 0x45, 0xe2, 0xb4, 0xa5,
3440 0x5e, 0xa7, 0xb9, 0x53, 0x3d, 0x04, 0x3b, 0xc7, 0x5a, 0x99, 0xb1, 0x70,
3441 0x2e, 0x94, 0x56, 0x35, 0xc2, 0xcc, 0xd1, 0xf2, 0xe3, 0x2d, 0xdd, 0xb2,
3442 0x0a, 0xba, 0xde, 0x33, 0x6e, 0xdc, 0x25, 0x39, 0x3d, 0x8d, 0x31, 0x77,
3443 0x3c, 0xec, 0x94, 0xbb, 0x90, 0x5f, 0xa2, 0xa8, 0x65, 0x06, 0xa4, 0x80,
3444 0x75, 0x0b, 0xcd, 0x56, 0x6b, 0x29, 0xf5, 0x0f, 0x3f, 0x65, 0xfc, 0x8d,
3445 0x7f, 0xd9, 0x29, 0xbd, 0xdf, 0x5e, 0x37, 0x86, 0xfe, 0xbb, 0x5f, 0x0f,
3446 0xa1, 0xc6, 0xea, 0x57, 0x8b, 0xe7, 0xb4, 0xf4, 0xa8, 0x93, 0x70, 0x37,
3447 0x70, 0x5f, 0xa2, 0xfd, 0xd6, 0xcf, 0x51, 0x85, 0xc8, 0xee, 0x98, 0xc5,
3448 0x9a, 0x6b, 0x26, 0xfb, 0x79, 0xfc, 0xff, 0x58, 0x5a, 0xf6, 0xf4, 0xe1,
3449 0xff, 0xde, 0x34, 0x4c, 0x2a, 0xcd, 0x98, 0xac, 0xb5, 0xc5, 0x64, 0xd1,
3450 0x1c, 0xe4, 0xdf, 0x05, 0xf0, 0xe4, 0x40, 0x1e, 0xbf, 0xd3, 0x8c, 0x6a,
3451 0xd9, 0xd3, 0xfd, 0x52, 0xaa, 0x33, 0xaf, 0x71, 0x5e, 0xd4, 0xaf, 0x7b,
3452 0x78, 0xdd, 0x81, 0x6b, 0x41, 0xae, 0xf9, 0x94, 0x48, 0xaf, 0xf9, 0xa3,
3453 0xcf, 0x4b, 0xdd, 0xaf, 0x5b, 0x22, 0xb2, 0xac, 0x6c, 0x8c, 0xe3, 0xaf,
3454 0x65, 0xbf, 0x36, 0xb4, 0x35, 0xfe, 0xec, 0xe6, 0xf8, 0x3b, 0xd9, 0x4f,
3455 0x6f, 0x8e, 0x77, 0x87, 0x3d, 0x1e, 0xc6, 0xb5, 0x99, 0x66, 0xc1, 0x1f,
3456 0xbb, 0x0c, 0xb9, 0xb7, 0x5a, 0x0b, 0xc8, 0x3d, 0x45, 0xeb, 0x32, 0xea,
3457 0x24, 0xc6, 0x9f, 0xeb, 0x89, 0x37, 0xdb, 0x62, 0x8d, 0x91, 0x09, 0x51,
3458 0x9f, 0x51, 0xf1, 0xd6, 0xe4, 0xfd, 0x4e, 0xc4, 0x9d, 0xcb, 0xf8, 0xce,
3459 0x3c, 0x17, 0xc4, 0x3c, 0xce, 0xe1, 0xf3, 0x6f, 0x5f, 0x43, 0xe7, 0x31,
3460 0xe8, 0xfc, 0xff, 0x1b, 0xdd, 0xe2, 0x4f, 0xe9, 0x56, 0xc5, 0x9d, 0x97,
3461 0xb6, 0xd9, 0x2c, 0xe9, 0xef, 0xf6, 0x69, 0x96, 0x68, 0x38, 0x6d, 0x38,
3462 0x0b, 0xd6, 0x8d, 0x12, 0x41, 0x0d, 0x4b, 0x9b, 0x2d, 0x35, 0xbf, 0x8b,
3463 0xe7, 0x99, 0x27, 0x25, 0x1a, 0x49, 0xd3, 0x2e, 0xd6, 0x07, 0x32, 0xd6,
3464 0x31, 0xa7, 0xe6, 0x1e, 0x73, 0xce, 0x2a, 0x3b, 0x59, 0xbf, 0xc9, 0xab,
3465 0xcd, 0x7f, 0x74, 0x13, 0x6a, 0x73, 0x3c, 0xcf, 0x98, 0xcb, 0xf1, 0x46,
3466 0x4f, 0xc6, 0x62, 0x0e, 0x5a, 0x72, 0x8a, 0xf8, 0x2c, 0xa8, 0xb9, 0xaf,
3467 0x0e, 0x70, 0x6e, 0x67, 0x3a, 0x76, 0xd3, 0x8f, 0xf1, 0xbf, 0x23, 0xfd,
3468 0xce, 0x4d, 0x17, 0x2c, 0xae, 0x3b, 0x75, 0xd3, 0x59, 0xb5, 0x46, 0x18,
3469 0xf1, 0x8c, 0xf3, 0x2e, 0xdf, 0xc4, 0x67, 0x9f, 0x44, 0x1c, 0x3f, 0xe1,
3470 0x42, 0x97, 0xee, 0x8b, 0x4e, 0x1e, 0x9f, 0x39, 0xd2, 0x54, 0xe1, 0x7d,
3471 0xe3, 0xe6, 0x8c, 0x15, 0x56, 0xf9, 0xf6, 0x4b, 0x98, 0x73, 0x04, 0x73,
3472 0x0e, 0xbb, 0x01, 0x3f, 0xea, 0xbe, 0x93, 0xc5, 0xfd, 0xc3, 0x65, 0xc3,
3473 0x71, 0xca, 0xe6, 0x38, 0x6a, 0x8e, 0xf8, 0x71, 0xe4, 0xe3, 0x1c, 0x72,
3474 0xa0, 0x2d, 0xe6, 0x70, 0x41, 0xd2, 0x5d, 0x93, 0xa8, 0xe5, 0x56, 0x90,
3475 0x4f, 0x50, 0x87, 0xa4, 0xaa, 0x32, 0xd8, 0x95, 0x39, 0xad, 0xc3, 0x3e,
3476 0xef, 0x80, 0xbd, 0x1a, 0x8e, 0x9e, 0x44, 0x5c, 0x47, 0xdc, 0x5c, 0xa8,
3477 0x58, 0x5a, 0xb6, 0x3c, 0x68, 0x94, 0xe4, 0x56, 0x59, 0x37, 0xcc, 0xf8,
3478 0xa4, 0xec, 0x92, 0x6c, 0x18, 0xf3, 0x86, 0x3f, 0x2e, 0xb9, 0xb8, 0x86,
3479 0xd8, 0x70, 0x03, 0xe2, 0x16, 0xeb, 0xe4, 0xf6, 0x18, 0xfa, 0x0b, 0x11,
3480 0xeb, 0x8b, 0x21, 0xc6, 0x9e, 0x4e, 0x8b, 0x75, 0x3f, 0xe7, 0xed, 0x92,
3481 0x8d, 0x0f, 0xcc, 0x7b, 0xb7, 0x6d, 0x5e, 0xfb, 0xf8, 0x7b, 0x18, 0xdf,
3482 0x25, 0x17, 0x41, 0x47, 0x38, 0x39, 0x26, 0x25, 0xf0, 0x10, 0x39, 0xd5,
3483 0x6a, 0x5d, 0x00, 0x3f, 0x3a, 0xf8, 0x2f, 0x56, 0x59, 0x0b, 0x84, 0xa4,
3484 0x6a, 0xe0, 0x9e, 0xdb, 0x6a, 0xd5, 0x10, 0x46, 0xf5, 0x55, 0xd2, 0x1c,
3485 0x95, 0x49, 0x77, 0x48, 0xec, 0x06, 0xe5, 0x60, 0xc2, 0xeb, 0xfe, 0xac,
3486 0x2b, 0x7b, 0x86, 0x39, 0x13, 0x16, 0xb1, 0xfa, 0xe7, 0x5d, 0x19, 0xe4,
3487 0x3e, 0x7d, 0xf5, 0x62, 0x57, 0x16, 0x7a, 0x0f, 0xad, 0xfe, 0xe7, 0x2e,
3488 0xe7, 0x34, 0xe9, 0x0a, 0x21, 0xf7, 0xdd, 0x22, 0x45, 0xa3, 0x25, 0xdf,
3489 0x44, 0x8d, 0x50, 0x1c, 0x46, 0x2e, 0x83, 0x17, 0xe8, 0xa0, 0xbb, 0x60,
3490 0x48, 0xb4, 0x3b, 0xfd, 0x7d, 0xd0, 0x37, 0x06, 0xd9, 0xec, 0xc2, 0x9c,
3491 0x10, 0xc6, 0x87, 0xf0, 0xbf, 0x7d, 0xfc, 0x8d, 0x2e, 0xe4, 0x05, 0xc4,
3492 0x60, 0x89, 0x66, 0xc6, 0x7a, 0xb0, 0xfe, 0xf7, 0x30, 0x8e, 0x09, 0xc9,
3493 0xcd, 0xf1, 0x27, 0xbc, 0xf1, 0xb7, 0x41, 0x0b, 0x9f, 0x63, 0x8d, 0x22,
3494 0xd1, 0xb9, 0x31, 0x03, 0x34, 0x70, 0x6e, 0x4c, 0xcd, 0x75, 0xce, 0xd0,
3495 0x06, 0x0c, 0xa7, 0x66, 0xdd, 0x2c, 0xd9, 0xe5, 0x7e, 0x99, 0x5c, 0xee,
3496 0x93, 0x03, 0xcb, 0xe6, 0x4c, 0x95, 0xd8, 0x0f, 0x3c, 0x0b, 0xea, 0x30,
3497 0x7d, 0x55, 0x20, 0x01, 0x33, 0x7e, 0x44, 0x06, 0xe3, 0x5f, 0x92, 0x5f,
3498 0xb6, 0x90, 0xef, 0x91, 0xeb, 0x7b, 0x24, 0xac, 0xd6, 0x89, 0x07, 0x7b,
3499 0xd2, 0x46, 0xb7, 0xed, 0xeb, 0x9c, 0xb9, 0xd6, 0xba, 0x70, 0xfe, 0xd5,
3500 0xf8, 0x55, 0xeb, 0xfe, 0x85, 0xbf, 0xae, 0x81, 0x75, 0x07, 0xb0, 0x26,
3501 0x79, 0x34, 0xbb, 0x26, 0x4e, 0x8b, 0xdd, 0x09, 0xfa, 0x9c, 0xe4, 0x8d,
3502 0xc0, 0x86, 0xfd, 0x72, 0x62, 0x99, 0xf1, 0x42, 0xfa, 0xf1, 0x19, 0x8d,
3503 0x48, 0x72, 0xf8, 0x1c, 0xea, 0xae, 0x09, 0xb5, 0x86, 0x57, 0x93, 0xe9,
3504 0xab, 0x29, 0xd4, 0xc4, 0x3f, 0x05, 0x3d, 0xac, 0x15, 0xc8, 0x73, 0x18,
3505 0xfc, 0xa6, 0x50, 0x8b, 0x11, 0x47, 0xb5, 0x1e, 0xcf, 0xa4, 0xf0, 0xfd,
3506 0x5c, 0xa2, 0x2b, 0x8b, 0x98, 0x08, 0xff, 0xbe, 0x39, 0xa4, 0x72, 0x18,
3507 0xf5, 0x32, 0xda, 0x45, 0x3c, 0x83, 0xe7, 0xa1, 0x27, 0xca, 0x68, 0xbc,
3508 0xcb, 0xa9, 0x50, 0x46, 0x02, 0x7a, 0x2c, 0xd8, 0x64, 0x58, 0x61, 0x29,
3509 0x7d, 0xd5, 0xc6, 0xbc, 0xb7, 0x42, 0xac, 0x77, 0x33, 0x16, 0xbf, 0x23,
3510 0xe6, 0xac, 0x4e, 0x61, 0x2e, 0xbf, 0xdf, 0x85, 0x75, 0x07, 0x87, 0x8b,
3511 0xd2, 0x31, 0x7c, 0x18, 0xf1, 0x4e, 0x1f, 0x1b, 0x01, 0x6d, 0xb4, 0xf3,
3512 0x16, 0xb0, 0xc0, 0x6f, 0x81, 0x1f, 0xf8, 0x46, 0xd2, 0x92, 0xf9, 0x25,
3513 0xca, 0x55, 0x3e, 0x0e, 0x1e, 0xc0, 0x7f, 0x12, 0x71, 0x8d, 0x3c, 0x70,
3514 0x6f, 0x41, 0x8e, 0xbe, 0x5b, 0xf2, 0x4b, 0x51, 0x55, 0xeb, 0xdb, 0x06,
3515 0xf7, 0xd7, 0x34, 0x3d, 0xdd, 0x0d, 0x1d, 0x93, 0xb7, 0x1c, 0x68, 0x7b,
3516 0x0c, 0x79, 0x80, 0xbc, 0x91, 0x2f, 0xfa, 0xca, 0x28, 0xfc, 0x84, 0xf4,
3517 0xfb, 0xb6, 0xa7, 0xad, 0x23, 0xa6, 0xa8, 0x38, 0x98, 0xca, 0x20, 0xb0,
3518 0xbd, 0xd4, 0x1c, 0x97, 0x3f, 0x6e, 0x8e, 0xc9, 0x77, 0x9b, 0x29, 0xe4,
3519 0xc0, 0x51, 0xe4, 0xc0, 0x61, 0xe4, 0x40, 0x0b, 0x39, 0x30, 0x81, 0x1c,
3520 0x38, 0x80, 0x1c, 0x18, 0x47, 0x9c, 0x14, 0x39, 0xa1, 0xf2, 0x6d, 0x2c,
3521 0x0a, 0xcc, 0x1d, 0xb5, 0x9b, 0x0e, 0x78, 0x99, 0xc1, 0x5e, 0xb3, 0xe0,
3522 0xeb, 0x50, 0xd7, 0x44, 0x65, 0x1c, 0x31, 0xd7, 0x42, 0x3c, 0x4a, 0x20,
3523 0xdf, 0x8c, 0x01, 0x6b, 0x89, 0x6c, 0x2c, 0x25, 0x10, 0x13, 0x5b, 0xe2,
3524 0x00, 0x13, 0x97, 0x8c, 0x14, 0x9e, 0xdd, 0xab, 0xec, 0x33, 0x94, 0xbe,
3525 0x3b, 0x2c, 0xdd, 0xa3, 0x92, 0x2f, 0x9f, 0xc4, 0x58, 0x1c, 0xeb, 0x75,
3526 0x21, 0x2f, 0x31, 0x2e, 0x30, 0x06, 0x2c, 0x39, 0xbf, 0x6b, 0xd1, 0xd7,
3527 0xba, 0xb5, 0xcc, 0xe9, 0x82, 0x30, 0x96, 0x23, 0x0f, 0xc0, 0x1e, 0x38,
3528 0x36, 0x89, 0xe7, 0xf8, 0xfd, 0x2f, 0xfd, 0x98, 0xf9, 0xb1, 0x4e, 0x81,
3529 0xd1, 0xbe, 0xc4, 0x9c, 0x67, 0x61, 0x3d, 0xb7, 0xdd, 0x4f, 0x9f, 0x47,
3530 0xad, 0x14, 0xdc, 0x27, 0xae, 0x66, 0x3f, 0xe1, 0x24, 0x68, 0x1e, 0x04,
3531 0xbe, 0x47, 0x6d, 0x75, 0xb0, 0x8a, 0xef, 0xed, 0xf3, 0x5d, 0xcc, 0x57,
3532 0x63, 0x51, 0x23, 0x6d, 0xb1, 0x9e, 0x43, 0xac, 0x3c, 0x86, 0xb8, 0x68,
3533 0x3b, 0xfa, 0x5a, 0x03, 0x7c, 0x42, 0x8e, 0x65, 0xdb, 0x09, 0x0f, 0xbd,
3534 0xd6, 0x7a, 0xd6, 0x1a, 0x96, 0x89, 0xb5, 0x31, 0xc9, 0xae, 0x0d, 0xc6,
3535 0xcf, 0x4b, 0xd7, 0x65, 0x5b, 0x5e, 0x6b, 0x95, 0x5c, 0xf3, 0xa4, 0x0d,
3536 0xbb, 0xdc, 0xb7, 0xdf, 0x90, 0x1a, 0x30, 0xdc, 0xbe, 0xfd, 0x9d, 0xac,
3537 0xe9, 0x5f, 0x14, 0x3d, 0x21, 0x99, 0x45, 0x5b, 0xc6, 0xf6, 0x07, 0xb5,
3538 0xe7, 0x2f, 0x3b, 0xa4, 0x1b, 0x63, 0x6b, 0x09, 0xcc, 0x61, 0xdd, 0xaf,
3539 0xfa, 0x27, 0xe0, 0x59, 0xf3, 0x9e, 0x51, 0x39, 0x8f, 0x98, 0x19, 0xbc,
3540 0x37, 0x6d, 0xe7, 0xfc, 0x22, 0x70, 0x0d, 0xe4, 0x99, 0x59, 0x24, 0xee,
3541 0xda, 0x05, 0x39, 0x45, 0x60, 0x23, 0xd4, 0xfd, 0x20, 0x9e, 0x6d, 0xc9,
3542 0x57, 0x53, 0xb4, 0x87, 0xc7, 0x20, 0x4b, 0xac, 0x15, 0x0e, 0xf8, 0xf9,
3543 0x9a, 0xcc, 0x2d, 0x51, 0x7e, 0x71, 0xd4, 0x96, 0xdc, 0x5b, 0xa2, 0x5d,
3544 0xe9, 0xab, 0xeb, 0x46, 0xdb, 0xd9, 0x58, 0xc4, 0xfa, 0x43, 0xc4, 0xd8,
3545 0x88, 0xd5, 0x65, 0xf6, 0x06, 0x58, 0x53, 0x1d, 0x80, 0x4e, 0xa6, 0x15,
3546 0xe6, 0xce, 0xd4, 0x53, 0x62, 0x9d, 0x62, 0xac, 0x92, 0x44, 0xc8, 0x22,
3547 0xbe, 0x17, 0x43, 0x4f, 0xcf, 0xe2, 0x1e, 0xe5, 0xc9, 0x5a, 0x1f, 0xf7,
3548 0x57, 0xff, 0xa3, 0xd2, 0x49, 0x08, 0xba, 0xcb, 0xef, 0x67, 0x11, 0x22,
3549 0x4b, 0xa1, 0x34, 0x62, 0xe0, 0x18, 0x79, 0x50, 0x7b, 0xa3, 0x9e, 0xa4,
3550 0xdf, 0x81, 0x67, 0xd8, 0x46, 0x5b, 0x5d, 0xa9, 0xfe, 0x4a, 0x95, 0x08,
3551 0x6c, 0x59, 0x0a, 0x91, 0x34, 0x78, 0x1a, 0xc3, 0x77, 0x38, 0xff, 0x09,
3552 0xe8, 0xf3, 0x2c, 0x9e, 0x5f, 0x00, 0x5f, 0x1b, 0x65, 0xd2, 0x9d, 0x4c,
3553 0x1c, 0x57, 0xbe, 0x8b, 0x6b, 0x97, 0xb5, 0xcc, 0xd7, 0xe4, 0xbc, 0xe2,
3554 0xef, 0x13, 0xac, 0x9d, 0xa1, 0xa7, 0xeb, 0xe1, 0x6f, 0xf2, 0x3a, 0xf9,
3555 0xf3, 0xd6, 0x67, 0xce, 0xca, 0x58, 0x09, 0xc9, 0x96, 0x5f, 0x6a, 0x85,
3556 0x2d, 0x2b, 0x3e, 0xef, 0xeb, 0x31, 0xeb, 0x46, 0x41, 0x07, 0xfb, 0x00,
3557 0xfb, 0x95, 0x2e, 0x41, 0x07, 0x6d, 0xa7, 0x10, 0x4d, 0x3f, 0x2e, 0x2b,
3558 0x4b, 0xff, 0x54, 0x6a, 0x4b, 0x05, 0xa9, 0x2f, 0xfd, 0x23, 0x39, 0xb7,
3559 0xd4, 0x92, 0x0b, 0x29, 0x15, 0x93, 0xac, 0x0e, 0xe5, 0xcf, 0x72, 0xa3,
3560 0x87, 0x07, 0x93, 0xe3, 0x97, 0x20, 0xc0, 0x95, 0xaa, 0x47, 0xfb, 0x54,
3561 0x1b, 0xed, 0x17, 0x60, 0x6b, 0xaf, 0x58, 0xa4, 0x7f, 0x4c, 0x6a, 0x65,
3562 0xd2, 0xfe, 0xa0, 0xa2, 0xfd, 0xc0, 0x26, 0xed, 0x92, 0x0b, 0x59, 0xa4,
3563 0x7f, 0x27, 0xda, 0x81, 0xf3, 0xfb, 0x49, 0x7f, 0x02, 0xcf, 0x7e, 0xd0,
3564 0xfe, 0x6a, 0xee, 0x6b, 0xad, 0x8d, 0x72, 0x44, 0xd1, 0x1c, 0x4a, 0x8f,
3565 0x41, 0x3e, 0xaf, 0xb5, 0xd6, 0x5d, 0xfa, 0x11, 0xbe, 0xbb, 0xf7, 0x20,
3566 0x46, 0xf5, 0x61, 0xaf, 0x5e, 0xc9, 0xcf, 0x46, 0x11, 0x27, 0xc7, 0xa1,
3567 0xdb, 0x2e, 0xe5, 0x87, 0x08, 0x17, 0xd0, 0xd9, 0x34, 0xe6, 0x1f, 0xa2,
3568 0xbf, 0x29, 0xb9, 0x38, 0x90, 0x4b, 0xb1, 0x9c, 0x8e, 0xa0, 0xfe, 0xc7,
3569 0x3e, 0x86, 0x93, 0x73, 0xf9, 0xcc, 0x00, 0x62, 0x1a, 0xff, 0x7f, 0x64,
3570 0x7b, 0x28, 0x20, 0xd6, 0x42, 0xe7, 0x3d, 0x90, 0x1f, 0xe8, 0x18, 0x9b,
3571 0x41, 0x6e, 0x4d, 0x0e, 0xd7, 0x54, 0x7f, 0x91, 0x71, 0xe5, 0x28, 0xf2,
3572 0xe9, 0x21, 0x7c, 0xbc, 0xfd, 0x26, 0x9a, 0xdc, 0x73, 0x3b, 0x4f, 0x45,
3573 0x77, 0x7d, 0x2f, 0x01, 0x52, 0xa6, 0xc9, 0x7d, 0x0b, 0x12, 0x4a, 0x87,
3574 0xb0, 0x2f, 0xc7, 0x7a, 0x10, 0x63, 0x06, 0xa2, 0xd9, 0xe6, 0xcf, 0x31,
3575 0x4e, 0x5f, 0x66, 0x7c, 0x0f, 0x68, 0x1f, 0xc5, 0x9a, 0x8c, 0xbb, 0x63,
3576 0xe0, 0x99, 0x35, 0x26, 0xe3, 0x26, 0xf2, 0x48, 0xe3, 0x47, 0xcc, 0x2d,
3577 0xf8, 0x3e, 0xe0, 0x7f, 0xe7, 0x7d, 0x89, 0xde, 0x9c, 0x36, 0xab, 0x05,
3578 0x31, 0xb1, 0x27, 0x74, 0x6e, 0xc5, 0xa5, 0xd8, 0x30, 0x5f, 0x20, 0x66,
3579 0xd4, 0x29, 0x83, 0x35, 0xca, 0x89, 0xfd, 0x27, 0xd4, 0x7f, 0xb5, 0xe7,
3580 0x21, 0x8f, 0xa8, 0xec, 0xb5, 0x0e, 0x22, 0xa6, 0x80, 0xfe, 0xca, 0x18,
3581 0x78, 0x63, 0x8f, 0x66, 0x10, 0xf9, 0x2b, 0x04, 0x21, 0xa0, 0x96, 0x5a,
3582 0x0b, 0xc9, 0xbd, 0xe1, 0x11, 0xa3, 0x28, 0x8f, 0x46, 0x58, 0x36, 0x17,
3583 0xd6, 0x98, 0x07, 0xc2, 0xb2, 0xb0, 0x26, 0x72, 0x69, 0x91, 0x71, 0x45,
3584 0xfd, 0x41, 0xe6, 0x86, 0x33, 0x8f, 0x3c, 0x5b, 0x5a, 0x62, 0x8c, 0x61,
3585 0x9c, 0xb8, 0x01, 0xba, 0x48, 0x7e, 0xe3, 0xab, 0xc8, 0x49, 0xa5, 0xf2,
3586 0x20, 0x62, 0xa6, 0xac, 0xeb, 0x90, 0x29, 0x72, 0x19, 0x6b, 0xd4, 0x1d,
3587 0xfa, 0x32, 0x41, 0x4f, 0x26, 0x2a, 0xc5, 0x45, 0xf6, 0x63, 0xa2, 0xa0,
3588 0x85, 0x35, 0x76, 0x48, 0xd5, 0x3f, 0x37, 0xa8, 0xd8, 0xca, 0xff, 0xe1,
3589 0xb6, 0x7d, 0x93, 0x27, 0xf7, 0xe9, 0x8c, 0x63, 0x37, 0x8b, 0x3d, 0x63,
3590 0x77, 0x1d, 0xa8, 0x74, 0x48, 0xb5, 0x8f, 0x76, 0x49, 0xfd, 0xbf, 0xa0,
3591 0x62, 0xed, 0x02, 0x78, 0x2a, 0x2e, 0x12, 0xe3, 0x86, 0x31, 0x2f, 0xe6,
3592 0xcf, 0xa3, 0x5c, 0xff, 0x89, 0xcc, 0xed, 0x7f, 0x17, 0x74, 0x79, 0x71,
3593 0x2d, 0xbf, 0x1f, 0xf1, 0x76, 0x46, 0x97, 0x3b, 0xef, 0x1a, 0xc7, 0xb3,
3594 0xcc, 0x81, 0xef, 0xf8, 0x78, 0x92, 0x63, 0xec, 0x61, 0x81, 0xbe, 0x15,
3595 0x03, 0xff, 0xfb, 0xa4, 0xb0, 0x12, 0x85, 0x1c, 0x90, 0x4b, 0x6b, 0xde,
3596 0x5a, 0xac, 0x77, 0x4f, 0x42, 0x47, 0xfa, 0xa9, 0xa8, 0x44, 0x4e, 0xf5,
3597 0x49, 0xf8, 0xeb, 0xdd, 0xd2, 0xf1, 0xf5, 0x21, 0x09, 0x7d, 0xdd, 0x64,
3598 0x4e, 0x4f, 0x9c, 0x80, 0xbe, 0xe6, 0x65, 0x5c, 0x9e, 0x44, 0xde, 0x62,
3599 0x5e, 0x57, 0x76, 0x6a, 0xf4, 0x4b, 0x08, 0x05, 0xab, 0xfe, 0x8c, 0x2d,
3600 0x8f, 0xee, 0xff, 0x85, 0xea, 0x33, 0x01, 0xc3, 0x8b, 0xfe, 0xfc, 0x94,
3601 0xd8, 0xcd, 0x77, 0x21, 0x6b, 0xc3, 0x79, 0xed, 0xd6, 0xa0, 0xa6, 0x1c,
3602 0x56, 0xfd, 0xc2, 0x47, 0xf7, 0x7b, 0x35, 0x25, 0xf0, 0xb8, 0xe6, 0xa8,
3603 0x9a, 0x12, 0xf1, 0x35, 0xcc, 0x79, 0xfd, 0xa2, 0x63, 0xaf, 0xbc, 0x0c,
3604 0x42, 0x4f, 0xb7, 0x88, 0x7d, 0x08, 0x7e, 0xf1, 0x9c, 0x2c, 0xe9, 0x69,
3605 0x4d, 0xad, 0x19, 0x7a, 0x86, 0x71, 0x8a, 0xf1, 0x8b, 0x36, 0x9e, 0x4c,
3606 0x14, 0x61, 0x7f, 0xa1, 0xe7, 0x19, 0xa3, 0x3c, 0xdb, 0x9e, 0x68, 0x8b,
3607 0x75, 0x0b, 0x95, 0x7b, 0xa0, 0x43, 0xd4, 0xf2, 0x16, 0xe2, 0x9c, 0x81,
3608 0x5c, 0x6e, 0xf1, 0xda, 0xeb, 0xe1, 0xe5, 0x63, 0x31, 0x75, 0x5d, 0xac,
3609 0x7a, 0x18, 0xdc, 0x5b, 0x9f, 0x75, 0x07, 0x62, 0x4c, 0x93, 0x74, 0x70,
3610 0xdf, 0x01, 0x09, 0x3d, 0x17, 0x93, 0xf0, 0x73, 0xb4, 0x3f, 0x33, 0xe1,
3611 0x40, 0x7e, 0x0b, 0x16, 0x31, 0xd0, 0x0a, 0xb0, 0xc5, 0xcd, 0xa2, 0xaf,
3612 0x0c, 0xc0, 0x77, 0xcc, 0x78, 0x55, 0x92, 0x12, 0xaa, 0x45, 0xe5, 0xad,
3613 0x45, 0x33, 0x41, 0x7b, 0x39, 0x6b, 0x61, 0xbc, 0xd9, 0x75, 0x79, 0x5d,
3614 0x51, 0xc1, 0xb1, 0x2f, 0x87, 0x80, 0x19, 0x86, 0x6d, 0xbd, 0x47, 0x5e,
3615 0x87, 0xbe, 0x73, 0x6a, 0xec, 0x66, 0xac, 0x0b, 0x1a, 0x9e, 0x33, 0xc1,
3616 0x03, 0xd7, 0xfd, 0x1e, 0xd6, 0x54, 0xf8, 0xca, 0xd9, 0x60, 0x4d, 0xba,
3617 0x48, 0xdb, 0xed, 0x83, 0xdd, 0xe1, 0xba, 0xd9, 0x21, 0xb9, 0xd9, 0x84,
3618 0xe8, 0x8b, 0x9f, 0x91, 0xc1, 0xfd, 0xba, 0xc7, 0x8f, 0xe2, 0x91, 0x63,
3619 0xec, 0xc7, 0xdd, 0xae, 0xfc, 0x51, 0x5f, 0x83, 0xcd, 0x3c, 0x48, 0x1d,
3620 0x23, 0xf7, 0x23, 0x8f, 0x31, 0x8e, 0x85, 0x90, 0xc7, 0xb2, 0x4d, 0x4f,
3621 0xef, 0xd5, 0x07, 0xfb, 0xe5, 0xc9, 0xe7, 0x68, 0x4f, 0xb8, 0xb7, 0x69,
3622 0x53, 0x41, 0x0f, 0x98, 0xf7, 0x2c, 0x39, 0xf9, 0x6c, 0x50, 0x73, 0xb0,
3623 0xbe, 0x32, 0xe3, 0x07, 0xc0, 0x8f, 0x7e, 0x27, 0xe3, 0x81, 0xae, 0x6c,
3624 0x37, 0x6f, 0x59, 0x5e, 0xdd, 0x51, 0x49, 0xb0, 0x2f, 0x6e, 0xb0, 0x4e,
3625 0xb3, 0xe3, 0x9e, 0xbc, 0x8b, 0x18, 0x2b, 0x35, 0x67, 0x11, 0xa3, 0x23,
3626 0x72, 0x71, 0xd6, 0x86, 0xee, 0x3f, 0x0b, 0xba, 0x0e, 0x75, 0x11, 0x23,
3627 0x5f, 0x9c, 0x75, 0x70, 0x7d, 0x48, 0xd5, 0x66, 0xa1, 0x3b, 0x61, 0xc7,
3628 0xcd, 0x7e, 0xfa, 0x91, 0xaf, 0xa7, 0x84, 0x56, 0x5c, 0x32, 0xb5, 0x12,
3629 0x62, 0xf6, 0x64, 0x8a, 0x39, 0xbe, 0x53, 0xf5, 0x4d, 0xd9, 0xaf, 0xc9,
3630 0x2b, 0xbc, 0xb0, 0x4f, 0x2b, 0x56, 0x19, 0xe7, 0x0b, 0xf1, 0x0e, 0x21,
3631 0x0e, 0x11, 0xad, 0x66, 0x51, 0x27, 0x9a, 0x9c, 0x57, 0xbd, 0x58, 0x11,
3632 0xc7, 0x3d, 0x42, 0x19, 0x68, 0xf5, 0xea, 0x3e, 0xad, 0x50, 0x0d, 0xc9,
3633 0xc5, 0x18, 0xe9, 0x4e, 0xa8, 0xfa, 0x7d, 0xbf, 0xb2, 0xb5, 0x1e, 0xe4,
3634 0x12, 0xd8, 0x4c, 0xea, 0x93, 0xd8, 0x57, 0x8d, 0xc1, 0xa6, 0xa8, 0x7b,
3635 0xea, 0x5d, 0xc5, 0x48, 0x5f, 0xf7, 0x3b, 0xe5, 0x4c, 0xd0, 0x51, 0x26,
3636 0x7e, 0xef, 0xf4, 0xf1, 0xfb, 0xa2, 0x5f, 0x0f, 0x3d, 0x26, 0xac, 0x53,
3637 0x16, 0x2a, 0xa4, 0x05, 0xf1, 0xd6, 0xdd, 0xc9, 0x96, 0x28, 0x47, 0x2f,
3638 0xa6, 0x1c, 0x45, 0x1d, 0xa3, 0xaf, 0x19, 0xbe, 0x0d, 0xf0, 0x6f, 0x14,
3639 0xf7, 0xbc, 0x5a, 0xaa, 0xd8, 0x8c, 0xc0, 0xdf, 0xa7, 0x21, 0x23, 0xea,
3640 0x06, 0xfa, 0x5b, 0xe3, 0x99, 0x0a, 0xf4, 0xb7, 0xf6, 0xf2, 0xfb, 0x76,
3641 0x1f, 0x63, 0xde, 0xb0, 0x3c, 0x89, 0xf1, 0x13, 0x67, 0x48, 0xcf, 0xb8,
3642 0x8f, 0xc7, 0x12, 0x90, 0x09, 0x63, 0xfc, 0xa8, 0xbc, 0xd5, 0x70, 0x14,
3643 0xfe, 0xdb, 0xb7, 0x7f, 0x46, 0xe6, 0xdd, 0x59, 0xe0, 0x3f, 0xc8, 0xdf,
3644 0x48, 0xc0, 0x3f, 0xe3, 0x2a, 0x3e, 0x1e, 0xfe, 0x68, 0x35, 0x49, 0xd8,
3645 0xcb, 0xd9, 0xf7, 0x5e, 0x67, 0xce, 0xde, 0x0d, 0xfc, 0xf5, 0x91, 0xd6,
3646 0x0f, 0x79, 0xeb, 0xff, 0x17, 0xe8, 0xea, 0x73, 0xd8, 0x23, 0x0a, 0xfa,
3647 0xfa, 0x29, 0xd3, 0x0f, 0x7b, 0x4e, 0xf7, 0x9e, 0xbb, 0xff, 0x3a, 0xe9,
3648 0x32, 0xa4, 0x01, 0x8c, 0x50, 0x50, 0x79, 0x94, 0xb5, 0x62, 0xc4, 0xd7,
3649 0xdf, 0x31, 0x60, 0x67, 0xae, 0x1b, 0xc4, 0xde, 0x4e, 0x29, 0xf4, 0x05,
3650 0xf5, 0x27, 0x62, 0xf6, 0xe6, 0x78, 0x50, 0xcf, 0xf2, 0xf9, 0x94, 0x93,
3651 0x2f, 0xb3, 0x4f, 0xc8, 0x5c, 0xc0, 0x31, 0x65, 0x87, 0x1f, 0x42, 0xb7,
3652 0x09, 0xcf, 0x20, 0xdd, 0xf7, 0x29, 0xba, 0x1d, 0x45, 0x37, 0xfd, 0x8b,
3653 0x67, 0x3a, 0xec, 0xa3, 0x05, 0x7d, 0x33, 0xae, 0x07, 0x4c, 0x00, 0x7d,
3654 0x7f, 0x17, 0x3a, 0xfe, 0x4e, 0x05, 0x98, 0xa0, 0x02, 0x4c, 0x80, 0x3d,
3655 0xbe, 0x0d, 0x1d, 0x7f, 0xab, 0x02, 0x4c, 0x50, 0x89, 0xfb, 0x3d, 0x0a,
3656 0x9b, 0x98, 0xfe, 0x23, 0xda, 0x6e, 0xd0, 0x93, 0xb9, 0xda, 0x2e, 0x39,
3657 0xce, 0xf9, 0x01, 0x36, 0x8e, 0xc2, 0x8e, 0x78, 0x6e, 0x11, 0xf4, 0x3b,
3658 0xfc, 0x1c, 0xd1, 0xe0, 0xb9, 0x00, 0x72, 0x44, 0x83, 0xe7, 0x18, 0x23,
3659 0xf1, 0x10, 0x30, 0x61, 0x48, 0xe2, 0xc2, 0x5e, 0xef, 0xdc, 0x18, 0xd6,
3660 0x1a, 0x1d, 0x84, 0x27, 0x75, 0xa8, 0xbe, 0xd6, 0x71, 0xd5, 0x6f, 0x40,
3661 0x5c, 0xa8, 0x06, 0xb5, 0x5b, 0x52, 0x26, 0x96, 0x88, 0x33, 0x65, 0xaf,
3662 0x9e, 0x86, 0x0e, 0x5c, 0x62, 0xc3, 0xcd, 0xbe, 0xf4, 0x70, 0x1d, 0x7b,
3663 0x16, 0x2d, 0x8f, 0xbe, 0xe3, 0xee, 0xd6, 0x33, 0x07, 0x10, 0x9f, 0xa7,
3664 0xca, 0x09, 0x99, 0x2c, 0x7b, 0x98, 0x00, 0xf5, 0xcf, 0x55, 0xfd, 0x51,
3665 0x9b, 0x7a, 0x80, 0xfe, 0x36, 0x6d, 0x23, 0x71, 0x3e, 0x45, 0x19, 0x53,
3666 0xff, 0xd3, 0xaa, 0x67, 0x7d, 0xa0, 0xee, 0xf5, 0xe5, 0x27, 0x95, 0x2d,
3667 0x84, 0x19, 0x67, 0xa8, 0x3f, 0xcf, 0x87, 0x61, 0x17, 0x79, 0x37, 0x90,
3668 0x4b, 0x3b, 0x1e, 0xf9, 0xbc, 0x26, 0xd6, 0x4e, 0xe3, 0xb9, 0xb6, 0xf1,
3669 0xcd, 0xfb, 0x3e, 0xbd, 0x88, 0x7d, 0x9b, 0x3d, 0x06, 0xc6, 0xa9, 0xad,
3670 0xf1, 0x10, 0xea, 0x87, 0xb0, 0xba, 0x8f, 0x18, 0xde, 0x88, 0x49, 0xb6,
3671 0x61, 0x89, 0x53, 0xe5, 0x3c, 0xf6, 0x2d, 0x18, 0x8f, 0x9e, 0x90, 0xec,
3672 0x52, 0xaf, 0xe4, 0x62, 0x66, 0xca, 0x96, 0xbf, 0x27, 0x1b, 0xcb, 0x85,
3673 0x04, 0xcf, 0x0d, 0x0b, 0x33, 0x1a, 0x9e, 0x7b, 0x18, 0xd7, 0xa4, 0xd9,
3674 0x92, 0xc3, 0x65, 0xe6, 0x9d, 0x91, 0x78, 0x03, 0xf7, 0x72, 0xb3, 0xec,
3675 0xd5, 0x54, 0x61, 0x93, 0x66, 0xa2, 0x8a, 0x78, 0xf0, 0x72, 0x99, 0xfb,
3676 0x01, 0x1b, 0x95, 0xd9, 0xcf, 0x09, 0xee, 0x3f, 0x01, 0x1c, 0x88, 0x58,
3677 0x1d, 0xf3, 0xe7, 0x28, 0x5e, 0x6d, 0x23, 0x2c, 0x81, 0xae, 0x3b, 0x65,
3678 0xdd, 0x8f, 0xbb, 0xb5, 0xb2, 0xd7, 0x47, 0x39, 0x4b, 0x7a, 0xdc, 0xff,
3679 0xd5, 0x5a, 0x8f, 0xa1, 0x16, 0xda, 0xe4, 0xf5, 0x8f, 0xb9, 0x8f, 0x81,
3680 0xb0, 0x2b, 0x27, 0xdc, 0x40, 0x26, 0xbc, 0xcf, 0x31, 0x9e, 0x8d, 0xb6,
3681 0x5a, 0x67, 0xad, 0xf6, 0x9e, 0xdf, 0xf5, 0xf4, 0xcc, 0xde, 0xb8, 0x2d,
3682 0x63, 0xbd, 0xe6, 0xa0, 0x26, 0xf6, 0x7b, 0x66, 0x87, 0x46, 0xbc, 0x9e,
3683 0xd9, 0xfc, 0xc8, 0xf6, 0x9e, 0xd9, 0xcf, 0x6f, 0xf3, 0x7a, 0x66, 0x17,
3684 0x9d, 0x22, 0x3e, 0x5e, 0xcf, 0x6c, 0xf8, 0x76, 0xaf, 0x67, 0xf6, 0xf0,
3685 0xed, 0x5e, 0xcf, 0xec, 0x91, 0x11, 0xaf, 0x67, 0xf6, 0xfb, 0xb7, 0x6f,
3686 0xef, 0x99, 0x3d, 0x36, 0xb2, 0xbd, 0x67, 0x26, 0x13, 0xc8, 0x77, 0x13,
3687 0x5b, 0x3d, 0xb3, 0xf2, 0xc8, 0xb5, 0x7b, 0x66, 0xaf, 0x06, 0x78, 0x1d,
3688 0xfc, 0x8c, 0x81, 0x87, 0x14, 0xf0, 0xfa, 0x28, 0xf0, 0xfa, 0xaf, 0xeb,
3689 0x59, 0x87, 0xc1, 0xe7, 0xcd, 0x7e, 0x5e, 0xb8, 0x1e, 0xdc, 0x7e, 0xbb,
3690 0xff, 0x8c, 0xa0, 0xde, 0x4d, 0xf8, 0xb5, 0x0a, 0xb1, 0xfb, 0x1e, 0xbf,
3691 0x66, 0xfb, 0x6b, 0xd1, 0xad, 0xf3, 0xec, 0xf6, 0xff, 0x37, 0xa0, 0xf4,
3692 0x0e, 0xf0, 0x3c, 0xf9, 0x79, 0x0d, 0xb5, 0x1f, 0xf9, 0x47, 0xa2, 0xef,
3693 0xbe, 0xe8, 0x7c, 0xd5, 0x22, 0xc6, 0x7f, 0x1c, 0xbe, 0x6a, 0xef, 0x0d,
3694 0xc9, 0x3a, 0xfc, 0x96, 0x39, 0xea, 0xa4, 0x64, 0x31, 0x3f, 0xab, 0xe6,
3695 0x27, 0x26, 0xb6, 0xe6, 0xa7, 0x26, 0xbe, 0xaa, 0x6a, 0x52, 0xf3, 0x5f,
3696 0xe3, 0xf3, 0x0d, 0x65, 0xdf, 0x96, 0x87, 0xe1, 0x9d, 0x4a, 0x80, 0xb7,
3697 0xc2, 0x3e, 0x76, 0x36, 0x1c, 0xdb, 0x9d, 0xc0, 0x33, 0xe6, 0x8b, 0xb6,
3698 0x34, 0x14, 0x7e, 0x0f, 0xa5, 0xcd, 0x17, 0x73, 0xaa, 0x5e, 0x33, 0x9c,
3699 0xbc, 0x1b, 0xd4, 0xdf, 0xa8, 0xa1, 0x86, 0x06, 0xd5, 0xf9, 0x9b, 0xbe,
3700 0x36, 0x8c, 0x3c, 0xd6, 0x5e, 0x63, 0xb3, 0xae, 0xd6, 0xfd, 0xba, 0xda,
3701 0x90, 0xbb, 0xf7, 0xb7, 0x63, 0x73, 0x99, 0xf8, 0x5b, 0x0a, 0x9b, 0xef,
3702 0x42, 0x6d, 0x4e, 0xec, 0x4d, 0x1c, 0x43, 0x0c, 0x41, 0x7c, 0xce, 0x7e,
3703 0x01, 0xeb, 0x19, 0xe6, 0x46, 0xd6, 0x37, 0x31, 0x7c, 0xf8, 0xbe, 0x41,
3704 0x80, 0xd1, 0x3b, 0xfc, 0xf8, 0xce, 0xba, 0x28, 0xc0, 0x2a, 0x77, 0x75,
3705 0x7b, 0xb5, 0xd1, 0x2e, 0xcd, 0xab, 0x3f, 0x13, 0xfe, 0x9c, 0xf0, 0x26,
3706 0x16, 0x0e, 0x6f, 0x62, 0xe1, 0x6d, 0xe7, 0x30, 0xa2, 0xde, 0x6d, 0x50,
3707 0xe7, 0x39, 0x3c, 0xdf, 0x11, 0x4d, 0x4f, 0xf3, 0x8c, 0x07, 0x38, 0xc7,
3708 0xe2, 0x99, 0x0f, 0x7d, 0xe9, 0x41, 0x2d, 0x5b, 0x37, 0x10, 0xef, 0x99,
3709 0x7f, 0x90, 0x6b, 0xcb, 0xc1, 0xd9, 0x62, 0xa0, 0x27, 0xca, 0x8e, 0x63,
3710 0x7f, 0xaa, 0xa1, 0xe6, 0x4d, 0x45, 0xac, 0x43, 0xa0, 0x65, 0x0a, 0xff,
3711 0x03, 0x99, 0xde, 0xa3, 0x72, 0x5f, 0x27, 0x6c, 0xf6, 0x78, 0x85, 0xd8,
3712 0xf5, 0x71, 0x69, 0xf8, 0xf8, 0x75, 0x65, 0xc9, 0xc3, 0xae, 0xe1, 0xed,
3713 0xd8, 0x35, 0xb5, 0x21, 0x1e, 0x8d, 0x07, 0x76, 0xa4, 0xd1, 0x70, 0x5e,
3714 0x19, 0x22, 0x66, 0x25, 0x9d, 0xcc, 0x3d, 0xd3, 0x88, 0x81, 0xcc, 0x39,
3715 0xcc, 0x37, 0xc4, 0xa5, 0xd7, 0xa2, 0x4f, 0x8d, 0x1d, 0xed, 0xb0, 0xa2,
3716 0xf8, 0xcc, 0x83, 0x8e, 0x19, 0x3c, 0x93, 0x96, 0x85, 0xd3, 0x5f, 0xd1,
3717 0x9c, 0xfa, 0x3c, 0xe8, 0x99, 0x42, 0xae, 0xa3, 0x2d, 0x15, 0x0c, 0xcf,
3718 0x8e, 0xd6, 0x11, 0xf7, 0x5d, 0xc6, 0x02, 0xd4, 0xae, 0xa8, 0x47, 0xca,
3719 0x8c, 0xbd, 0x3c, 0xeb, 0x0a, 0x62, 0x2e, 0xfb, 0x26, 0xa8, 0x59, 0x59,
3720 0xbb, 0x2e, 0x72, 0xdf, 0xed, 0xba, 0xa8, 0xb9, 0xc4, 0x5d, 0x86, 0xb3,
3721 0xbe, 0x46, 0xdc, 0xf8, 0x51, 0x31, 0xa4, 0xe1, 0xbc, 0x3c, 0x44, 0x1c,
3722 0x79, 0x3d, 0xf8, 0xd1, 0x84, 0x34, 0xcd, 0x17, 0xd6, 0xf5, 0x76, 0xfc,
3723 0xe8, 0x61, 0xc7, 0xcc, 0xda, 0x41, 0xac, 0xc9, 0xda, 0x8c, 0x38, 0xd1,
3724 0x44, 0x98, 0x1b, 0xc4, 0xb3, 0x83, 0xe0, 0xc7, 0xc3, 0x8a, 0x59, 0x60,
3725 0xc5, 0xbf, 0x03, 0xac, 0x58, 0x92, 0xf7, 0xa2, 0xc4, 0x8a, 0xb6, 0x8f,
3726 0x15, 0x1d, 0xd8, 0x71, 0x7e, 0x9b, 0x1d, 0x6b, 0xaa, 0x07, 0xc5, 0x7b,
3727 0x79, 0x60, 0xbd, 0xec, 0xa2, 0x79, 0x1d, 0xf8, 0x50, 0x93, 0x98, 0x3a,
3728 0xaf, 0x0f, 0xb7, 0xad, 0x19, 0xe0, 0xc0, 0x7d, 0x0a, 0xdf, 0xdd, 0x57,
3729 0xd9, 0x85, 0xda, 0x44, 0xe1, 0x3d, 0xff, 0x9c, 0x2f, 0x7c, 0xd5, 0xd9,
3730 0x67, 0xb8, 0xed, 0xec, 0x73, 0x0b, 0x17, 0xe2, 0x39, 0xbf, 0xc7, 0x17,
3731 0x81, 0xde, 0xfe, 0x07, 0x69, 0x82, 0x5f, 0xd1, 0x07, 0x34, 0xcf, 0x4f,
3732 0xb6, 0xe1, 0xc3, 0xff, 0x7a, 0x15, 0x3e, 0x44, 0xce, 0x5a, 0x89, 0x49,
3733 0x06, 0xd8, 0xd0, 0x5e, 0xe3, 0x5a, 0xf4, 0xe5, 0x51, 0xe9, 0x00, 0x7f,
3734 0x9d, 0x8b, 0x7d, 0xc0, 0x44, 0xdd, 0x12, 0x05, 0x36, 0x8a, 0x28, 0x6c,
3735 0x34, 0x44, 0x0c, 0x33, 0x7c, 0x18, 0x98, 0xa6, 0xb1, 0x89, 0x8f, 0xcc,
3736 0xd4, 0x0f, 0xa0, 0x97, 0x87, 0x95, 0xad, 0x8c, 0xcb, 0x53, 0x88, 0x9d,
3737 0x1d, 0x6b, 0xc0, 0x75, 0x2b, 0x1e, 0x6e, 0x8a, 0x5c, 0x85, 0x9b, 0x8e,
3738 0xec, 0x88, 0x9b, 0x54, 0xbf, 0x7e, 0x9c, 0x32, 0x79, 0xdd, 0xf5, 0xfa,
3739 0xf5, 0x97, 0x5c, 0xaf, 0x5f, 0xff, 0xba, 0xdb, 0xde, 0xaf, 0xbf, 0x49,
3740 0x8a, 0x86, 0x69, 0x5f, 0x94, 0xab, 0xfa, 0xf5, 0x33, 0xec, 0x7f, 0x57,
3741 0xbb, 0xbc, 0xbe, 0x7c, 0xb7, 0xdf, 0xaf, 0x37, 0xa5, 0xb8, 0x6d, 0xdc,
3742 0x90, 0xb7, 0xad, 0xa0, 0x5f, 0xff, 0x2f, 0x30, 0xd6, 0x83, 0x3d, 0xb6,
3743 0xf7, 0xea, 0x2f, 0xb9, 0xec, 0xd5, 0xc7, 0x38, 0xcf, 0xef, 0xd5, 0x73,
3744 0x1e, 0x6a, 0x78, 0x97, 0x7d, 0xfa, 0x9b, 0x21, 0x8b, 0x7e, 0xc8, 0xa1,
3745 0x4f, 0x3a, 0x9e, 0x8b, 0x73, 0x8e, 0xea, 0xcf, 0x5f, 0x74, 0x63, 0x78,
3746 0xce, 0xeb, 0xa3, 0x1f, 0x86, 0x5d, 0x1d, 0xd9, 0xec, 0xcf, 0x7b, 0x7b,
3747 0xbc, 0xe1, 0x6e, 0x5f, 0x7f, 0xfb, 0x3a, 0x03, 0xfe, 0x3a, 0x31, 0xac,
3748 0x13, 0xbf, 0x6a, 0x9d, 0xad, 0x7e, 0xfc, 0x1b, 0xae, 0xd7, 0x8b, 0x77,
3749 0x4e, 0x8b, 0xdd, 0x81, 0x98, 0xfc, 0xe2, 0xd0, 0x8d, 0xfe, 0x1a, 0x9b,
3750 0xbd, 0x78, 0xc6, 0x0e, 0xe0, 0x75, 0xc6, 0x0f, 0x3e, 0xff, 0xff, 0xbe,
3751 0x17, 0xcf, 0x3e, 0xbc, 0x77, 0x9e, 0x42, 0xff, 0x04, 0x2e, 0x7f, 0xd6,
3752 0xeb, 0xc1, 0x4f, 0x54, 0x82, 0xde, 0x3a, 0xeb, 0xc6, 0xe0, 0xbd, 0x8c,
3753 0xc1, 0xc4, 0x71, 0xa1, 0xad, 0x90, 0x3e, 0xae, 0xdb, 0x23, 0x73, 0x0a,
3754 0x17, 0xc1, 0xa6, 0x92, 0xd7, 0xc6, 0xc6, 0xb5, 0xc5, 0x00, 0x1b, 0xc7,
3755 0x14, 0x36, 0xae, 0xad, 0x05, 0xd8, 0x38, 0x73, 0x0d, 0x6c, 0xfc, 0xdf,
3756 0xba, 0xbc, 0xf8, 0x1f, 0x95, 0x82, 0xc2, 0xc6, 0xd7, 0x7a, 0xc7, 0x86,
3757 0xf7, 0xba, 0x89, 0x03, 0xc4, 0x3b, 0x17, 0xef, 0xbb, 0x86, 0xaf, 0x05,
3758 0x78, 0x99, 0xb9, 0xbe, 0x5f, 0x66, 0x9e, 0xdb, 0xc2, 0xcb, 0x1e, 0x26,
3759 0x36, 0x13, 0x47, 0x55, 0x2e, 0x04, 0x3e, 0x68, 0xb2, 0xef, 0x7d, 0x48,
3760 0xd9, 0x6e, 0xa9, 0x32, 0xab, 0x70, 0x59, 0x1e, 0xb5, 0x6d, 0x51, 0xe1,
3761 0x60, 0x62, 0xe0, 0x2e, 0x91, 0xbe, 0x20, 0x17, 0x05, 0x18, 0x33, 0xec,
3762 0xc7, 0x67, 0x9e, 0x29, 0xbc, 0x1d, 0xca, 0x10, 0x03, 0xbb, 0x41, 0x8d,
3763 0x40, 0x39, 0x0f, 0x23, 0x76, 0x19, 0xbe, 0xac, 0x3c, 0x9f, 0xdd, 0xb7,
3764 0xff, 0x87, 0xef, 0xdb, 0x06, 0xe3, 0x5a, 0x80, 0x11, 0x51, 0x03, 0x55,
3765 0xc6, 0xd5, 0xbb, 0x0e, 0x1e, 0x46, 0xf4, 0xf0, 0x61, 0xd6, 0x9d, 0x01,
3766 0x4e, 0x9e, 0x95, 0x09, 0xe0, 0xf3, 0xf5, 0xdf, 0x65, 0xef, 0x29, 0xc0,
3767 0x44, 0x36, 0xfe, 0xb7, 0xf7, 0xa2, 0x78, 0xdd, 0xa1, 0xce, 0xfe, 0xce,
3768 0x0f, 0x45, 0xdb, 0xc6, 0xff, 0x3e, 0xe2, 0x37, 0xea, 0xa1, 0x0a, 0x73,
3769 0x1d, 0xb1, 0xd0, 0x6f, 0x40, 0x07, 0x63, 0xd7, 0xc0, 0x42, 0x57, 0xe7,
3770 0x26, 0xe6, 0xcb, 0xad, 0xbc, 0xe4, 0x6c, 0xe6, 0x25, 0xee, 0xf1, 0xeb,
3771 0x72, 0x27, 0xc7, 0x6c, 0x23, 0x62, 0x4d, 0xe1, 0x33, 0x8f, 0x7c, 0xbd,
3772 0x3d, 0x37, 0xcd, 0x5d, 0x47, 0x6e, 0x9a, 0x50, 0xb9, 0x89, 0xf4, 0xa2,
3773 0x9e, 0x83, 0x4c, 0xbe, 0x0b, 0x59, 0x7e, 0x07, 0xb4, 0xff, 0x11, 0xf8,
3774 0xf9, 0x43, 0x60, 0xac, 0x6f, 0x03, 0x63, 0x7d, 0xab, 0xd2, 0xfe, 0x0e,
3775 0xc3, 0xb8, 0xb0, 0x0e, 0xf4, 0xea, 0x66, 0x0f, 0xc3, 0x1f, 0x86, 0x57,
3776 0x35, 0xca, 0x86, 0x33, 0x57, 0x1e, 0x31, 0xe6, 0xbd, 0xf3, 0xd2, 0x44,
3777 0x4e, 0xd2, 0x88, 0x11, 0xcc, 0x15, 0xea, 0x3a, 0xce, 0x7e, 0x25, 0xb1,
3778 0x42, 0x5d, 0xd5, 0x93, 0x43, 0x52, 0x6d, 0x78, 0xf8, 0x6a, 0xe1, 0x8c,
3779 0xb7, 0xc6, 0x9c, 0x8f, 0xaf, 0xf2, 0x3e, 0xbe, 0xca, 0x35, 0x36, 0x12,
3780 0xac, 0xcf, 0x17, 0x52, 0xdb, 0x31, 0xd5, 0x61, 0x1f, 0x53, 0xcd, 0xff,
3781 0x15, 0x31, 0x15, 0xf7, 0xca, 0xe3, 0x99, 0xc9, 0xa5, 0x84, 0x1c, 0x80,
3782 0x7c, 0x27, 0xca, 0xd4, 0x93, 0x69, 0xc3, 0x6e, 0x3e, 0x44, 0x57, 0x8e,
3783 0xd2, 0x4b, 0x28, 0xe9, 0xe9, 0x69, 0x12, 0x7a, 0x9a, 0xf8, 0xb5, 0xf5,
3784 0x8d, 0x1a, 0x33, 0xde, 0x1c, 0x8b, 0xe2, 0xf3, 0x7f, 0xaa, 0x23, 0xd2,
3785 0x4f, 0x3d, 0x5d, 0x8d, 0xb9, 0xae, 0x07, 0x7b, 0x6d, 0xc7, 0x5d, 0xb6,
3786 0xc2, 0x5d, 0x1d, 0xfe, 0x9c, 0x99, 0x89, 0x49, 0xe8, 0xf0, 0xdf, 0x63,
3787 0xce, 0x9f, 0xc0, 0xb7, 0x7e, 0x88, 0x78, 0xfd, 0xef, 0xa0, 0x8b, 0x7f,
3788 0x8b, 0xda, 0xe0, 0x55, 0xe4, 0x9f, 0x1f, 0x60, 0x6c, 0x0b, 0xc7, 0xa8,
3789 0x33, 0xfa, 0xd1, 0x8c, 0x95, 0x98, 0x28, 0xba, 0x89, 0x09, 0x0f, 0x7f,
3790 0xfc, 0xea, 0x6f, 0x66, 0xac, 0x29, 0xbe, 0xc3, 0x00, 0xf9, 0xfe, 0xf9,
3791 0xdd, 0x73, 0x0a, 0x7b, 0x04, 0x98, 0x23, 0x67, 0x73, 0xff, 0x92, 0x9b,
3792 0x9a, 0xa8, 0xe1, 0xe3, 0x61, 0x9b, 0xef, 0xd9, 0x1e, 0xb6, 0x59, 0xfa,
3793 0xeb, 0xd4, 0xbb, 0x87, 0x6b, 0x1e, 0x4e, 0xd3, 0xaf, 0xeb, 0xc0, 0x1c,
3794 0x35, 0xf8, 0x64, 0xa1, 0x69, 0xab, 0xcf, 0xf1, 0x8a, 0x6d, 0x46, 0x20,
3795 0x1f, 0xf6, 0x58, 0x4f, 0xd1, 0x0b, 0x5d, 0xd3, 0x28, 0x13, 0x81, 0xba,
3796 0x66, 0xfc, 0x9f, 0xf9, 0xd7, 0x4f, 0xfb, 0xd7, 0x4f, 0xf9, 0xd7, 0x27,
3797 0x91, 0x77, 0x9f, 0x54, 0xb9, 0x93, 0xe3, 0x1c, 0x83, 0x72, 0x5d, 0xac,
3798 0x85, 0xf5, 0xce, 0x8e, 0xfe, 0xb4, 0x55, 0x8d, 0x79, 0xfe, 0x5c, 0x68,
3799 0x3a, 0xf8, 0xfc, 0x63, 0x7c, 0x0e, 0xe2, 0x33, 0x8d, 0xcf, 0x63, 0xf8,
3800 0x6c, 0xca, 0x54, 0xcb, 0x56, 0xa8, 0xa3, 0x61, 0xc9, 0x62, 0xbc, 0x88,
3801 0x3a, 0x34, 0x93, 0x7a, 0x44, 0x8a, 0xf5, 0x92, 0x94, 0x96, 0x34, 0xe9,
3802 0xb6, 0xd2, 0x52, 0xaa, 0x1f, 0x93, 0xe3, 0x4b, 0xde, 0xb9, 0x61, 0x57,
3803 0xda, 0xc6, 0xdc, 0x96, 0x3c, 0x9c, 0x7a, 0x5c, 0xf4, 0x3b, 0x8f, 0x61,
3804 0x9e, 0xe8, 0xc5, 0xd1, 0xdb, 0xd4, 0xf9, 0x58, 0x3d, 0xe5, 0xc9, 0xf8,
3805 0x80, 0x65, 0x9b, 0xc8, 0x5b, 0xc3, 0x4f, 0x62, 0xed, 0x8c, 0x7a, 0x3f,
3806 0x30, 0x2d, 0x27, 0x4e, 0x6f, 0xec, 0xf5, 0x62, 0xa9, 0x69, 0xbc, 0x81,
3807 0x4d, 0xeb, 0xe0, 0xc3, 0x46, 0xec, 0x9b, 0x82, 0x9d, 0x1f, 0x71, 0xc3,
3808 0xda, 0x04, 0x62, 0xe0, 0x84, 0xab, 0x6a, 0x3d, 0xc4, 0x2a, 0xc3, 0x49,
3809 0x9e, 0x8a, 0xe1, 0x9a, 0xef, 0xd0, 0x20, 0x0f, 0x2a, 0x5b, 0xd9, 0x00,
3810 0x8e, 0xd1, 0x54, 0xbf, 0xaf, 0xb4, 0x79, 0x0e, 0xa4, 0xfa, 0xff, 0x4e,
3811 0x32, 0xa9, 0x4b, 0x7e, 0x8c, 0x38, 0xd6, 0x56, 0xb9, 0xa8, 0x51, 0xb6,
3812 0x3f, 0xc1, 0xda, 0xf0, 0x75, 0x61, 0x5e, 0xbb, 0x07, 0xf3, 0x06, 0x10,
3813 0x7f, 0x71, 0xaf, 0x09, 0x5e, 0x4e, 0x93, 0x57, 0x3e, 0x83, 0xda, 0xb6,
3814 0xfa, 0x49, 0xbd, 0xb8, 0xe4, 0xd7, 0x44, 0xaa, 0x76, 0x48, 0x48, 0x7d,
3815 0xf3, 0xcc, 0xc9, 0xeb, 0x93, 0xd4, 0xdd, 0x00, 0x3b, 0xf4, 0x60, 0x0e,
3816 0xeb, 0x08, 0xc8, 0xc8, 0x3b, 0x27, 0x53, 0x67, 0x64, 0x45, 0xf7, 0x93,
3817 0x7a, 0x69, 0x29, 0x83, 0x71, 0xf6, 0xa4, 0xf1, 0xbd, 0xaa, 0x2b, 0xec,
3818 0x7f, 0x31, 0x74, 0x58, 0x1a, 0xd5, 0x16, 0xe8, 0x45, 0x8e, 0xdd, 0x7b,
3819 0x58, 0x6a, 0xd5, 0x79, 0x79, 0xa1, 0xba, 0xb1, 0x0b, 0xd8, 0x09, 0x32,
3820 0x25, 0xfd, 0x3d, 0x3e, 0xfd, 0x54, 0x41, 0x30, 0x0e, 0x79, 0x9e, 0x2e,
3821 0xc4, 0xbd, 0xba, 0x96, 0xb8, 0xed, 0x24, 0xdf, 0x1b, 0x8c, 0xf3, 0x3d,
3822 0xbe, 0x23, 0xcb, 0xb4, 0xc9, 0x8b, 0xf7, 0x2e, 0x58, 0x9f, 0x92, 0x0b,
3823 0xa9, 0x3d, 0xb2, 0x91, 0x52, 0xf5, 0x2f, 0xf1, 0x01, 0x7c, 0xdb, 0x34,
3824 0xd6, 0xe5, 0x6e, 0x39, 0x01, 0x3f, 0xbd, 0x90, 0xca, 0xa9, 0xf3, 0x9b,
3825 0xe3, 0x4d, 0x62, 0xfb, 0x79, 0xd6, 0x54, 0xb2, 0xae, 0x7a, 0x60, 0xad,
3826 0xd6, 0x64, 0x8a, 0xb1, 0xa7, 0x43, 0x36, 0x14, 0xd6, 0xf2, 0x7a, 0xe3,
3827 0x1b, 0xb3, 0x9e, 0x6f, 0x84, 0x94, 0xbd, 0xff, 0x1b, 0xd0, 0x71, 0x0c,
3828 0x36, 0x1b, 0x51, 0x73, 0x42, 0xe9, 0x4e, 0x7f, 0x8e, 0xc2, 0x66, 0x6d,
3829 0x73, 0xc6, 0xc7, 0x33, 0x96, 0xf1, 0xa9, 0x8c, 0x35, 0x36, 0xe1, 0xf5,
3830 0x53, 0x4c, 0xc3, 0xd6, 0x2e, 0xb6, 0x82, 0xf7, 0x4d, 0xa6, 0xe0, 0x4f,
3831 0x2f, 0x6d, 0x62, 0x63, 0x18, 0xe7, 0xf3, 0x0b, 0xd0, 0x6b, 0x58, 0x3a,
3832 0x4e, 0xb5, 0xee, 0x99, 0x4b, 0x8d, 0x24, 0x8e, 0x08, 0xdf, 0x30, 0x62,
3833 0xfd, 0x6c, 0x82, 0xda, 0x05, 0xe4, 0xc3, 0x2b, 0xc4, 0x08, 0xc3, 0xe7,
3834 0xe5, 0xca, 0x3d, 0x99, 0xd4, 0x7e, 0xad, 0x36, 0x8b, 0xea, 0xe4, 0xf9,
3835 0x29, 0xe6, 0xd3, 0xa3, 0xec, 0x7d, 0x86, 0x4e, 0xbd, 0xad, 0x39, 0x65,
3836 0xf5, 0x8e, 0x39, 0xf4, 0xd2, 0xd2, 0xe6, 0x21, 0x37, 0x3c, 0x3f, 0xc3,
3837 0x04, 0xa8, 0x5b, 0x83, 0x09, 0x47, 0x72, 0xec, 0x71, 0x49, 0x7e, 0x59,
3838 0xf6, 0x65, 0x10, 0x47, 0xed, 0x99, 0x0e, 0x99, 0x6f, 0x18, 0xce, 0xe0,
3839 0xe2, 0x51, 0xac, 0x31, 0x87, 0xb5, 0xa6, 0x51, 0x83, 0xcc, 0x22, 0x27,
3840 0x53, 0xae, 0x8c, 0xd5, 0x0f, 0x43, 0x46, 0x37, 0xf1, 0xcc, 0x78, 0x3c,
3841 0x27, 0xe6, 0x4c, 0x41, 0xad, 0xfb, 0x9e, 0x96, 0x1f, 0xfd, 0x18, 0x72,
3842 0x5a, 0x58, 0x0e, 0x24, 0x45, 0x9f, 0x4e, 0x86, 0xdf, 0x9f, 0xb3, 0x38,
3843 0x16, 0xe5, 0x98, 0x8e, 0xb1, 0xf0, 0xe7, 0x92, 0x51, 0x3d, 0x93, 0x34,
3844 0xc7, 0xd9, 0xef, 0x0d, 0x59, 0x73, 0x12, 0x7a, 0xbe, 0xb7, 0x47, 0xba,
3845 0xa7, 0xa5, 0x77, 0xd5, 0x1c, 0x7f, 0x1d, 0xb4, 0x84, 0x55, 0x6c, 0x9f,
3846 0x13, 0xdd, 0x1f, 0xef, 0xd9, 0x1c, 0x0f, 0xfb, 0xe3, 0xd3, 0xd2, 0xbd,
3847 0x3a, 0x62, 0xbc, 0x29, 0x87, 0xb1, 0x66, 0x48, 0x2e, 0xa1, 0xa6, 0xb1,
3848 0x86, 0xe6, 0xe0, 0x73, 0x0f, 0x91, 0x96, 0x83, 0xc0, 0x14, 0xf0, 0x09,
3849 0xd4, 0xd9, 0xd6, 0x27, 0xe5, 0x4b, 0x46, 0x97, 0xe4, 0x55, 0x4d, 0x1b,
3850 0xf6, 0x7a, 0xa5, 0xb0, 0xf3, 0x5b, 0x87, 0xa6, 0x77, 0x7b, 0xfd, 0x00,
3851 0x9e, 0x67, 0x8c, 0x62, 0xec, 0x4a, 0x6b, 0xc5, 0xe2, 0x18, 0xef, 0x5d,
3852 0x69, 0xd5, 0xad, 0x11, 0x23, 0xab, 0x45, 0xfd, 0x73, 0xed, 0x79, 0xc5,
3853 0x7b, 0xa1, 0x3a, 0x68, 0xd4, 0xe4, 0x16, 0x2d, 0x7b, 0x03, 0xf2, 0x83,
3854 0xfb, 0x19, 0xcc, 0xbd, 0xd2, 0xca, 0x58, 0xf3, 0xaa, 0x7f, 0x5f, 0x93,
3855 0xe0, 0x9a, 0xeb, 0x8c, 0x18, 0x93, 0xea, 0xd9, 0x11, 0xe3, 0x84, 0xd6,
3856 0xfe, 0xac, 0xa1, 0x4d, 0x6e, 0x7b, 0xb6, 0x5b, 0xc9, 0x28, 0x64, 0x79,
3857 0x73, 0x4a, 0xd5, 0x69, 0x79, 0xda, 0xe5, 0xbc, 0x2b, 0xad, 0xac, 0x15,
3858 0xd1, 0x4e, 0xdc, 0xc0, 0x18, 0xc8, 0xb9, 0x97, 0xaf, 0xda, 0x87, 0xd7,
3859 0xd7, 0xda, 0xe3, 0x5d, 0xd9, 0xbe, 0xc7, 0x2e, 0x35, 0xe7, 0x82, 0x9a,
3860 0x13, 0x56, 0xb2, 0xde, 0xbe, 0xcf, 0xcf, 0x64, 0xfb, 0x3e, 0xdd, 0x9b,
3861 0x3c, 0x97, 0xb0, 0xe6, 0x93, 0x98, 0x5b, 0x76, 0x07, 0xe3, 0x75, 0xb9,
3862 0xdc, 0xca, 0x5b, 0x17, 0xe5, 0xc2, 0xe6, 0xda, 0xbf, 0xc2, 0x75, 0x3b,
3863 0x4d, 0xbf, 0xf2, 0x69, 0xe4, 0x77, 0x8e, 0x3d, 0xaa, 0xe4, 0xbd, 0xdb,
3864 0x1a, 0x3c, 0x58, 0xd3, 0xcc, 0xf1, 0x9f, 0x09, 0x75, 0x75, 0x44, 0xc5,
3865 0x98, 0xdb, 0xa0, 0xa7, 0x7d, 0xcf, 0xc0, 0x67, 0x47, 0x6d, 0x35, 0xe7,
3866 0x92, 0x35, 0x2d, 0xfb, 0x4e, 0x0d, 0x1a, 0x97, 0x10, 0xdb, 0x9c, 0x18,
3867 0xaf, 0x51, 0x2b, 0x59, 0x7c, 0x27, 0xfe, 0x4e, 0xd6, 0x01, 0xd0, 0xe5,
3868 0xe0, 0xf0, 0xcf, 0xe4, 0xa8, 0x9c, 0xa8, 0x1c, 0x43, 0x2e, 0x9c, 0x93,
3869 0xe1, 0x67, 0x90, 0x37, 0x2a, 0x05, 0x3c, 0x49, 0x9f, 0xf5, 0x72, 0xe0,
3870 0x9c, 0x7a, 0xcf, 0xfc, 0x24, 0xea, 0x64, 0xd8, 0x6e, 0x79, 0x70, 0x78,
3871 0x05, 0xcf, 0xbc, 0xa0, 0x70, 0xa8, 0x2b, 0x0d, 0xf8, 0x40, 0xe2, 0xf9,
3872 0x3d, 0xb2, 0xfb, 0x01, 0xda, 0x22, 0x32, 0xfd, 0x6d, 0x11, 0xf5, 0xee,
3873 0xbd, 0x6e, 0x75, 0x8a, 0xec, 0xa5, 0xdd, 0x34, 0x61, 0x63, 0x73, 0xde,
3874 0x99, 0xd6, 0xb6, 0x6b, 0x73, 0xe6, 0xa2, 0xac, 0x2a, 0xfb, 0xbb, 0x7d,
3875 0xd5, 0xfb, 0x3f, 0xba, 0x8a, 0x72, 0x38, 0x39, 0x2d, 0x77, 0xac, 0x7a,
3876 0xf6, 0x56, 0x5a, 0x3a, 0xaa, 0xe4, 0x3a, 0xa7, 0xe4, 0xda, 0x92, 0xc3,
3877 0x29, 0xca, 0x9c, 0xbc, 0xf0, 0xbd, 0x40, 0x4f, 0x16, 0xf7, 0xfb, 0xf6,
3878 0x33, 0xf8, 0x0c, 0x7f, 0x57, 0x42, 0xd9, 0xb0, 0xee, 0xbe, 0x7f, 0x37,
3879 0xcf, 0x59, 0xf7, 0xad, 0x92, 0xcf, 0x1b, 0xb7, 0xf1, 0xf9, 0x14, 0x62,
3880 0xea, 0xd0, 0x90, 0xc7, 0xeb, 0xab, 0x4b, 0x1f, 0xce, 0xeb, 0x37, 0x37,
3881 0x79, 0x0d, 0x49, 0x43, 0xd5, 0xaf, 0x5d, 0xbd, 0xd2, 0x8d, 0xa8, 0x07,
3882 0x7b, 0xf8, 0x09, 0xf6, 0x9a, 0x12, 0xd2, 0xe0, 0xed, 0xb7, 0xe1, 0x92,
3883 0x96, 0x80, 0x76, 0xd2, 0x73, 0x9f, 0xaf, 0x2f, 0xee, 0x7f, 0x74, 0xc7,
3884 0x7b, 0x97, 0xc4, 0x70, 0x86, 0x31, 0xa6, 0x2b, 0x9d, 0x65, 0x7d, 0xff,
3885 0x9a, 0x16, 0x5d, 0xe9, 0xcc, 0xde, 0xd4, 0xd9, 0xeb, 0xd0, 0x59, 0x5d,
3886 0x7e, 0x13, 0xbc, 0xc0, 0x9f, 0x9f, 0x19, 0x31, 0x0e, 0x13, 0x5b, 0x18,
3887 0x5c, 0x0f, 0x31, 0xd4, 0xd7, 0x5d, 0xc7, 0x47, 0xd0, 0xdd, 0x9b, 0xa2,
3888 0xf4, 0x07, 0x7e, 0x90, 0x7f, 0xd4, 0xf3, 0x8c, 0x61, 0xe4, 0xa9, 0x43,
3889 0xf9, 0x3e, 0x69, 0x53, 0x67, 0xfc, 0x33, 0x9e, 0x3e, 0x95, 0x6f, 0xfb,
3890 0xfa, 0xcc, 0xcd, 0x50, 0x67, 0xe6, 0x6e, 0x4f, 0x7f, 0x9d, 0x6a, 0xce,
3891 0x62, 0x32, 0xa1, 0xfc, 0xda, 0x1a, 0xba, 0x65, 0x37, 0x75, 0xf8, 0xb4,
3892 0xeb, 0xfd, 0x2f, 0xbb, 0xd3, 0xb2, 0xe8, 0x7e, 0x98, 0x1e, 0x3d, 0x1d,
3893 0x4e, 0x88, 0xe7, 0x3f, 0x57, 0xeb, 0x4f, 0x5f, 0x0d, 0x2b, 0x5b, 0x9d,
3894 0x80, 0xec, 0x4e, 0x56, 0x3e, 0xe6, 0xdb, 0xb7, 0xc7, 0xeb, 0xd0, 0x87,
3895 0xf0, 0x7a, 0xb8, 0x3c, 0x68, 0xbc, 0x8d, 0xb5, 0x26, 0x15, 0x86, 0x8b,
3896 0x88, 0xe3, 0xf3, 0x9a, 0xd8, 0xe4, 0x35, 0xa0, 0xcd, 0x9b, 0x97, 0x65,
3897 0x5d, 0xea, 0x32, 0x3e, 0x3d, 0xaa, 0xde, 0xbf, 0x7f, 0xa3, 0xcc, 0xb8,
3898 0x0c, 0xcc, 0x13, 0xeb, 0x93, 0x4b, 0x8d, 0x84, 0x5c, 0x22, 0x96, 0x18,
3899 0xc3, 0x7f, 0xf7, 0x98, 0x9f, 0x9b, 0xa3, 0xf2, 0x66, 0xb9, 0xbd, 0x56,
3900 0x1c, 0x95, 0xd7, 0xcb, 0x41, 0xbd, 0x48, 0x2c, 0xcb, 0xfc, 0x3f, 0x27,
3901 0x6f, 0x2d, 0x0d, 0xca, 0xfa, 0x0c, 0xf2, 0xf8, 0x10, 0x65, 0x30, 0x62,
3902 0x7c, 0x46, 0xfd, 0xbe, 0xe2, 0x4a, 0xeb, 0xbc, 0x85, 0x75, 0x97, 0x5b,
3903 0x72, 0x84, 0xe7, 0xd0, 0xfc, 0xde, 0xf8, 0x04, 0x56, 0xe1, 0xbc, 0x3e,
3904 0xa9, 0x2d, 0xa3, 0x2e, 0x2f, 0x73, 0x5d, 0xca, 0x69, 0x5a, 0x7d, 0x9f,
3905 0xc4, 0x3e, 0xf7, 0xf3, 0xbd, 0xf4, 0x18, 0x75, 0x71, 0xa5, 0xb5, 0x61,
3906 0xf1, 0x1c, 0x72, 0x4e, 0x1a, 0xd0, 0xd7, 0x97, 0x93, 0x3c, 0x27, 0xcf,
3907 0x0b, 0x7f, 0x9f, 0x52, 0x6b, 0xcc, 0xa0, 0x16, 0xb8, 0xd2, 0x5a, 0xb0,
3908 0x9e, 0x52, 0x7a, 0x6a, 0x54, 0x1f, 0xf0, 0xc7, 0x79, 0xcd, 0x7b, 0x86,
3909 0xb3, 0x6f, 0x88, 0xf5, 0xe7, 0x03, 0xc8, 0xff, 0xac, 0x3d, 0x89, 0xb7,
3910 0x28, 0x8b, 0x04, 0x6a, 0x5c, 0xae, 0xc5, 0xdf, 0x04, 0x25, 0x87, 0xf3,
3911 0x32, 0x09, 0x7a, 0x80, 0xcb, 0x5c, 0xc6, 0xfd, 0x5b, 0x65, 0x23, 0xe6,
3912 0xc5, 0x77, 0xbe, 0xaf, 0xb5, 0x81, 0x98, 0xbf, 0xb1, 0x19, 0xf3, 0xfb,
3913 0x71, 0x6d, 0x38, 0xa9, 0xa1, 0xff, 0x84, 0xf5, 0xd9, 0x77, 0x61, 0xcc,
3914 0x1f, 0xc7, 0x7c, 0x8e, 0xf5, 0x49, 0x69, 0x59, 0x6c, 0xf6, 0x99, 0x6a,
3915 0xc2, 0x77, 0x31, 0x72, 0xb2, 0xd8, 0x18, 0x8c, 0x9f, 0xd7, 0x1c, 0xf5,
3916 0xce, 0x46, 0x72, 0x88, 0x7d, 0xb7, 0x3e, 0x69, 0x2c, 0x4b, 0x22, 0x94,
3917 0x7e, 0x48, 0xdc, 0x86, 0x87, 0xb9, 0x17, 0x34, 0xf6, 0xdf, 0x6c, 0x69,
3918 0x6c, 0x9f, 0x63, 0x84, 0xd2, 0x87, 0xe4, 0x0f, 0xfc, 0x39, 0x8e, 0x9a,
3919 0xf3, 0x1f, 0x76, 0xf3, 0xec, 0xab, 0xe1, 0xf6, 0x82, 0x06, 0xd2, 0x76,
3920 0x63, 0xfb, 0xbe, 0x89, 0xad, 0x7d, 0xb9, 0x27, 0x6a, 0x98, 0xbd, 0x36,
3921 0xf6, 0x7d, 0x15, 0xcf, 0x3c, 0x04, 0x3a, 0xae, 0x84, 0x74, 0xeb, 0x21,
3922 0x29, 0x36, 0xae, 0xde, 0xa3, 0x9d, 0x06, 0x3e, 0xc3, 0xf5, 0xb9, 0xcf,
3923 0x21, 0xd0, 0x77, 0x45, 0xd3, 0xad, 0x43, 0x90, 0xa5, 0xb7, 0x47, 0xe8,
3924 0x39, 0xd3, 0xf8, 0xa1, 0x0c, 0x89, 0xbe, 0xa2, 0x29, 0xf9, 0xeb, 0xb5,
3925 0x51, 0x38, 0xc4, 0x94, 0x74, 0xaf, 0xcd, 0x4a, 0x68, 0x8d, 0x3d, 0x00,
3926 0xda, 0x22, 0xf5, 0xb8, 0x0b, 0x7e, 0x2c, 0x76, 0xd8, 0x22, 0xde, 0x67,
3927 0x1f, 0x77, 0xb5, 0x57, 0x7a, 0x89, 0xf7, 0x59, 0x0f, 0x1c, 0xc4, 0x7f,
3928 0xd6, 0x04, 0x2f, 0xb5, 0x32, 0xa9, 0x77, 0x54, 0xde, 0xcc, 0x37, 0x78,
3929 0xdf, 0x4c, 0x88, 0xf0, 0x1e, 0xe3, 0x43, 0x9f, 0x44, 0xbe, 0x3e, 0x8c,
3930 0x98, 0x90, 0x03, 0x76, 0xc6, 0xba, 0xa7, 0x86, 0x24, 0xec, 0xbd, 0xeb,
3931 0xa0, 0xfa, 0x25, 0x6f, 0x2d, 0x9b, 0xfe, 0xef, 0x53, 0x64, 0xdf, 0xf9,
3932 0x14, 0x7b, 0x9a, 0x03, 0xb0, 0x53, 0xd6, 0x23, 0xa2, 0x6f, 0xa0, 0xde,
3933 0xbc, 0xd4, 0x88, 0xf6, 0xf2, 0x7d, 0xcb, 0xd7, 0x5d, 0x5c, 0x13, 0xbb,
3934 0xc7, 0x14, 0x56, 0xf4, 0xef, 0xf1, 0x3b, 0xea, 0xa0, 0x6d, 0x98, 0x32,
3935 0x01, 0x4c, 0xc9, 0x3a, 0x69, 0xca, 0x7f, 0xe7, 0xcd, 0x70, 0x4e, 0x6c,
3936 0xab, 0x95, 0x86, 0x65, 0x03, 0x38, 0x6b, 0xdd, 0xb5, 0x10, 0x07, 0xdf,
3937 0xd6, 0xea, 0x65, 0xf5, 0xbb, 0x34, 0xed, 0x01, 0x60, 0xac, 0x44, 0x9f,
3938 0xaa, 0x75, 0x4e, 0x3e, 0x20, 0x9e, 0xbd, 0xc3, 0xca, 0x54, 0xcc, 0x5a,
3939 0xaf, 0x7a, 0xb5, 0xc5, 0x46, 0x75, 0x4a, 0xfe, 0xd4, 0x5d, 0x50, 0xbd,
3940 0xd2, 0x25, 0xd4, 0x1b, 0xe1, 0x45, 0x55, 0x6b, 0xb5, 0xe1, 0x54, 0xc4,
3941 0xb7, 0x67, 0x8f, 0xc0, 0x07, 0x4d, 0xf5, 0x6e, 0x81, 0xbe, 0xd2, 0x6a,
3942 0x65, 0x11, 0x2f, 0x74, 0xcb, 0x32, 0x8a, 0xc8, 0x73, 0x59, 0xf5, 0x7e,
3943 0x0a, 0xfd, 0xf7, 0xf7, 0x54, 0x1c, 0x96, 0x1a, 0x64, 0xf3, 0x5c, 0x02,
3944 0xeb, 0x68, 0xca, 0x3e, 0x43, 0x4a, 0x0f, 0x0f, 0x28, 0xec, 0x1a, 0x5a,
3945 0x41, 0x80, 0x5a, 0x1b, 0x12, 0x59, 0x81, 0xbf, 0xc2, 0x77, 0xc3, 0x6b,
3946 0xd4, 0x01, 0x65, 0x3b, 0x2b, 0x11, 0xc8, 0x9e, 0x58, 0x22, 0xb4, 0x48,
3947 0x19, 0xc7, 0x61, 0x17, 0x5c, 0x07, 0x32, 0xe6, 0xbb, 0x2c, 0xcb, 0x1d,
3948 0xf2, 0x4c, 0xc3, 0xf4, 0xdf, 0x3d, 0x7f, 0x89, 0xef, 0xa3, 0xeb, 0x73,
3949 0x63, 0x03, 0xc4, 0x4f, 0x52, 0x6a, 0x00, 0x63, 0x9c, 0x66, 0x0d, 0xce,
3950 0x18, 0x50, 0x88, 0x47, 0x94, 0xaf, 0xb3, 0x06, 0xf6, 0x7c, 0x9f, 0xf8,
3951 0x3a, 0x62, 0x11, 0xdb, 0x8e, 0x62, 0x8f, 0x9d, 0xe4, 0xea, 0xd5, 0x9e,
3952 0x93, 0xa0, 0xf3, 0xfc, 0x92, 0x39, 0x55, 0x90, 0x14, 0xdf, 0x71, 0x9e,
3953 0xb1, 0xc1, 0xf7, 0x06, 0xe2, 0xe4, 0x42, 0x85, 0xef, 0x33, 0x17, 0xe1,
3954 0x59, 0x53, 0x72, 0xbe, 0xcc, 0x1a, 0xf0, 0x76, 0xe8, 0x8b, 0xd7, 0xc5,
3955 0xf1, 0x10, 0xfc, 0xff, 0xa2, 0xc1, 0xdf, 0x91, 0xf1, 0x77, 0x41, 0x66,
3956 0x2a, 0xa1, 0x1d, 0x84, 0x8e, 0x0b, 0x46, 0xc4, 0xb7, 0x03, 0xa7, 0x4c,
3957 0x8c, 0x35, 0x62, 0x9c, 0xc3, 0xf7, 0x97, 0xdd, 0xcb, 0x2d, 0xd6, 0x3f,
3958 0x17, 0x10, 0xe7, 0xa6, 0x92, 0x53, 0xb0, 0x9d, 0x42, 0xbc, 0x13, 0xb4,
3959 0xfe, 0x5d, 0xdc, 0xcb, 0xbb, 0xdc, 0xc7, 0x4c, 0x5d, 0x94, 0x22, 0x30,
3960 0xfd, 0x48, 0xe2, 0x65, 0xd9, 0x83, 0x3a, 0x55, 0x93, 0x37, 0x2d, 0x73,
3961 0x5c, 0x34, 0xb5, 0xde, 0xf0, 0x7d, 0xb0, 0xbd, 0x37, 0x10, 0xdf, 0x3a,
3962 0xfc, 0xda, 0x3d, 0x5b, 0x26, 0x16, 0x3a, 0xaa, 0xde, 0x05, 0xb8, 0x60,
3963 0xb1, 0x7f, 0xc7, 0xdf, 0x44, 0xfe, 0xa5, 0xda, 0x63, 0xeb, 0x8c, 0x8d,
3964 0xfd, 0x63, 0xd2, 0xe7, 0xf1, 0x78, 0xc0, 0xf2, 0x68, 0xe4, 0x3a, 0x91,
3965 0xb6, 0x75, 0xce, 0xfb, 0xeb, 0x9c, 0xf5, 0xd7, 0xa9, 0xf9, 0xeb, 0x5c,
3966 0xd8, 0x5c, 0xe7, 0x6e, 0xe8, 0xbf, 0xd5, 0x7a, 0x0a, 0xf8, 0x21, 0x93,
3967 0x6a, 0xb5, 0x1c, 0xd4, 0x59, 0xa5, 0xd1, 0x79, 0x75, 0x46, 0xaa, 0xa7,
3968 0xbf, 0x71, 0x6f, 0xc6, 0x2a, 0xc4, 0xc3, 0x0a, 0x7b, 0xa0, 0x92, 0x82,
3969 0x1d, 0x16, 0xc4, 0xc3, 0xdc, 0x3c, 0xb7, 0xf3, 0xce, 0xf5, 0xba, 0xa1,
3970 0xc3, 0x1c, 0x72, 0x86, 0x91, 0x39, 0x67, 0x49, 0x61, 0xdf, 0x6f, 0xea,
3971 0xb0, 0xf3, 0x5e, 0xe4, 0x87, 0x9f, 0xc0, 0x66, 0x8c, 0x4c, 0xbd, 0x91,
3972 0x43, 0xbd, 0xc3, 0xf9, 0x77, 0x40, 0x8f, 0x85, 0x4c, 0xad, 0x51, 0xc8,
3973 0x9c, 0xe5, 0x79, 0x0e, 0xe6, 0xd5, 0x1a, 0x3d, 0x90, 0x7b, 0x8f, 0xea,
3974 0x8b, 0xbc, 0x5c, 0x8e, 0x31, 0x06, 0xc1, 0xd6, 0x63, 0x18, 0x8b, 0xab,
3975 0xdf, 0x68, 0xd5, 0xdd, 0x65, 0xf8, 0x74, 0x02, 0xe3, 0xd5, 0xae, 0x49,
3976 0x85, 0x47, 0x2d, 0x59, 0x71, 0x7f, 0xa5, 0x15, 0xcb, 0x97, 0xb5, 0x52,
3977 0x79, 0x18, 0x73, 0x46, 0xf9, 0x5b, 0x9f, 0x3d, 0xc0, 0x49, 0x53, 0xd5,
3978 0x1d, 0x69, 0x4a, 0x80, 0x26, 0xbd, 0x8d, 0xa6, 0x04, 0xe8, 0x41, 0xcc,
3979 0x3c, 0xc5, 0xde, 0xf1, 0xa8, 0x9c, 0x28, 0xf3, 0x9d, 0x26, 0xfe, 0x46,
3980 0xd5, 0x90, 0x30, 0xb0, 0x65, 0xe4, 0x94, 0x19, 0x5f, 0x57, 0xbd, 0x1a,
3981 0x73, 0xb8, 0x2e, 0x23, 0xa9, 0xba, 0xa8, 0xfc, 0x92, 0x38, 0x81, 0x7c,
3982 0xf5, 0x86, 0xdb, 0x23, 0x6f, 0xfa, 0x7b, 0x5d, 0x14, 0x9e, 0x33, 0x6e,
3983 0xdf, 0xeb, 0xc9, 0x4a, 0x2a, 0xf3, 0x8a, 0x15, 0xf2, 0xf9, 0xea, 0xc3,
3984 0x5e, 0x7b, 0x30, 0x37, 0x95, 0x39, 0xdf, 0xd8, 0x69, 0xae, 0x83, 0xb9,
3985 0x91, 0xb6, 0xb9, 0x0e, 0xe6, 0xf5, 0x20, 0xef, 0xf5, 0x28, 0x9e, 0x4a,
3986 0xa0, 0xeb, 0x52, 0x99, 0x3c, 0xf1, 0x0c, 0x82, 0x7b, 0x1a, 0xc4, 0xc6,
3987 0x53, 0xe2, 0x9f, 0xd9, 0xf2, 0xf7, 0x7a, 0x57, 0xf5, 0x6b, 0x94, 0x0d,
3988 0x4c, 0x58, 0x3c, 0x9b, 0x99, 0xd1, 0xb2, 0xf5, 0x3c, 0x72, 0xd5, 0x8d,
3989 0xc4, 0x43, 0x29, 0x1b, 0xb9, 0x92, 0xe7, 0x3c, 0x8d, 0x72, 0x81, 0xef,
3990 0x3d, 0xc3, 0x2e, 0xde, 0x21, 0x5e, 0xbe, 0x31, 0xa4, 0xde, 0x43, 0x70,
3991 0xfc, 0x73, 0x20, 0x31, 0x32, 0x63, 0x7c, 0xf7, 0xe0, 0x6e, 0xa9, 0x2f,
3992 0x7f, 0x11, 0x63, 0x19, 0xe4, 0xc5, 0x43, 0x5a, 0xe6, 0xdc, 0x24, 0xae,
3993 0x1f, 0xc2, 0x35, 0xe2, 0xf0, 0x72, 0x0e, 0xf7, 0x1f, 0xc2, 0xf5, 0xbc,
3994 0x96, 0x6d, 0xe6, 0x70, 0xfd, 0x30, 0xae, 0x27, 0x48, 0x9b, 0xf3, 0x8a,
3995 0x35, 0xa5, 0xd9, 0x58, 0xcb, 0x3e, 0x37, 0x89, 0x4f, 0xfb, 0x7a, 0xbc,
3996 0x07, 0x3d, 0x95, 0x79, 0x3e, 0x96, 0x04, 0x4d, 0x0f, 0x6a, 0x4e, 0xbd,
3997 0x1b, 0x6b, 0x0c, 0xe1, 0x79, 0xda, 0x54, 0xfb, 0x39, 0xd4, 0x6d, 0xaa,
3998 0x67, 0x14, 0x4a, 0xa7, 0x81, 0x77, 0x1f, 0x41, 0xde, 0xd7, 0xc4, 0xb1,
3999 0x1e, 0x97, 0x62, 0x2a, 0x2d, 0x0b, 0xf5, 0x90, 0x64, 0x63, 0x05, 0x7c,
4000 0x2f, 0x48, 0x66, 0x1c, 0xf7, 0xeb, 0xb4, 0x05, 0xce, 0x2b, 0x49, 0xb1,
4001 0x4a, 0xfc, 0xce, 0x7e, 0xd1, 0x57, 0xc0, 0x37, 0xfb, 0x44, 0x79, 0xc8,
4002 0x20, 0x46, 0xfb, 0xdd, 0xa1, 0xa7, 0xe5, 0xbd, 0xd3, 0x8c, 0x7c, 0xac,
4003 0x65, 0xea, 0xfe, 0x59, 0x9d, 0xc5, 0xdf, 0x2b, 0xb1, 0x47, 0x25, 0xc5,
4004 0x50, 0x9a, 0x7d, 0x0e, 0xd5, 0x17, 0x4f, 0x79, 0x67, 0x7a, 0xed, 0xef,
4005 0x90, 0x04, 0xfe, 0xc2, 0x7d, 0xbf, 0x82, 0xe7, 0xbd, 0xbe, 0x54, 0xb6,
4006 0xf9, 0x41, 0x5d, 0xf0, 0x5d, 0xfd, 0x15, 0xe8, 0xe2, 0xfc, 0x87, 0xf6,
4007 0xb9, 0xd8, 0xe3, 0x9a, 0x47, 0x2c, 0x62, 0x7f, 0x2c, 0x90, 0xdf, 0xd5,
4008 0x34, 0x92, 0xbe, 0xc3, 0x58, 0x4b, 0x52, 0x8c, 0xb3, 0xb9, 0x58, 0x42,
4009 0xd5, 0xbe, 0x1b, 0x4b, 0xf2, 0xc4, 0x16, 0xbd, 0xa4, 0x95, 0x72, 0x78,
4010 0x04, 0xf5, 0x1a, 0x7f, 0xff, 0xf0, 0xb8, 0xe4, 0x53, 0xec, 0xd1, 0x84,
4011 0x90, 0x0b, 0x0b, 0xf8, 0xbe, 0x25, 0xb7, 0x92, 0x2f, 0xb7, 0x7c, 0xf5,
4012 0x5b, 0x4a, 0x77, 0x35, 0x8b, 0xfb, 0x05, 0xbd, 0x8b, 0x69, 0xa5, 0xb3,
4013 0x9a, 0x7a, 0xcf, 0x36, 0xe0, 0x3d, 0xe8, 0xbf, 0xed, 0x6c, 0x73, 0x93,
4014 0x16, 0x69, 0xfb, 0x38, 0xdf, 0x5b, 0x18, 0xb6, 0x85, 0xf4, 0x93, 0x0f,
4015 0xe6, 0xac, 0xe0, 0x5c, 0x34, 0xe0, 0x21, 0xe0, 0xf3, 0xa3, 0xca, 0x85,
4016 0x74, 0xee, 0x31, 0xa4, 0x7b, 0xca, 0x08, 0x59, 0xcc, 0x01, 0x9f, 0xf6,
4017 0xfb, 0xf8, 0xff, 0x37, 0xe5, 0xea, 0xf1, 0x1e, 0x86, 0xa8, 0xfc, 0xdf,
4018 0x8b, 0xee, 0xa0, 0xf7, 0xab, 0xcf, 0x80, 0x0d, 0xe7, 0xac, 0xb5, 0xc5,
4019 0x67, 0x6d, 0x07, 0x3e, 0x6b, 0x3e, 0x9f, 0x1f, 0x7e, 0x4e, 0xea, 0xd1,
4020 0x59, 0x5b, 0xb2, 0xc1, 0x23, 0x6d, 0x6a, 0x27, 0x7b, 0xe3, 0x6f, 0x9c,
4021 0xd4, 0xef, 0xad, 0xa2, 0xb6, 0x7b, 0xad, 0x5e, 0x27, 0xeb, 0x64, 0xcf,
4022 0xee, 0xce, 0x22, 0xd7, 0x55, 0xab, 0x5e, 0xcd, 0x5c, 0x75, 0xd9, 0x6b,
4023 0xde, 0x69, 0x6f, 0x0d, 0x34, 0xff, 0x8e, 0x7a, 0xef, 0xa4, 0xe4, 0x7a,
4024 0x7d, 0xa9, 0x6a, 0xb5, 0x3d, 0x57, 0xde, 0xc0, 0x3c, 0x39, 0x5c, 0x90,
4025 0x19, 0xe8, 0x31, 0x89, 0xeb, 0x9b, 0xe5, 0xe5, 0x65, 0x75, 0x86, 0xe4,
4026 0x9f, 0xd5, 0xf0, 0x0c, 0x46, 0x9d, 0x43, 0x23, 0x5e, 0xcd, 0xaa, 0x78,
4027 0xbd, 0xb1, 0xac, 0xee, 0xa9, 0xdf, 0x3c, 0xd4, 0xdd, 0x19, 0xc4, 0x73,
4028 0xd4, 0x06, 0xd6, 0x6e, 0x29, 0xa2, 0x86, 0x3e, 0x6b, 0xcd, 0x18, 0xc4,
4029 0x29, 0x5c, 0x6b, 0x03, 0x6b, 0x9d, 0x5f, 0x96, 0xbd, 0x7c, 0xa7, 0xa3,
4030 0xaa, 0xce, 0xbd, 0xbc, 0x7e, 0xf5, 0xbc, 0x04, 0xbf, 0xd7, 0x8d, 0xfa,
4031 0x39, 0x8e, 0xef, 0x95, 0xf0, 0xb7, 0xa7, 0x8c, 0x01, 0xa8, 0x6b, 0x66,
4032 0x0a, 0x58, 0xaf, 0xd5, 0xf2, 0xfa, 0xd9, 0x2d, 0xd8, 0x7d, 0x84, 0xbf,
4033 0x65, 0xc0, 0xdf, 0x23, 0xb0, 0x13, 0xf8, 0xc1, 0xe6, 0x38, 0xaf, 0x59,
4034 0x4b, 0x04, 0xd7, 0x4c, 0x58, 0xff, 0x1b, 0xed, 0xcc, 0xfa, 0xa1, 0x98,
4035 0x41, 0x00, 0x00, 0x00 };
4036static u32 bnx2_TXP_b09FwData[(0xd0/4) + 1] = {
4037 0x00000000, 0x00000014, 0x00000014, 0x00000014, 0x00000014, 0x00000010,
4038 0x00000030, 0x00000030, 0x00000000, 0x00000000, 0x00000000, 0x00000010,
4039 0x00008000, 0x00000000, 0x00000000, 0x00000000, 0x00008002, 0x00000000,
4040 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000000, 0x00000000,
4041 0x00000000, 0x00000005, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
4042 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000006,
4043 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
4044 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
4045 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 };
4046static u32 bnx2_TXP_b09FwRodata[(0x30/4) + 1] = {
4047 0x08003be8, 0x08003c14, 0x08003c5c, 0x08003c5c, 0x08003ae8, 0x08003b14,
4048 0x08003b14, 0x08003c5c, 0x08003c5c, 0x08003c5c, 0x08003b7c, 0x00000000,
4049 0x00000000 };
4050static u32 bnx2_TXP_b09FwBss[(0xa20/4) + 1] = { 0x0 };
4051static u32 bnx2_TXP_b09FwSbss[(0x80/4) + 1] = { 0x0 };
4052
4053static struct fw_info bnx2_txp_fw_09 = {
4054 .ver_major = 0x1,
4055 .ver_minor = 0x0,
4056 .ver_fix = 0x0,
4057
4058 .start_addr = 0x08000060,
4059
4060 .text_addr = 0x08000000,
4061 .text_len = 0x4194,
4062 .text_index = 0x0,
4063 .gz_text = bnx2_TXP_b09FwText,
4064 .gz_text_len = sizeof(bnx2_TXP_b09FwText),
4065
4066 .data_addr = 0x080041e0,
4067 .data_len = 0xd0,
4068 .data_index = 0x0,
4069 .data = bnx2_TXP_b09FwData,
4070
4071 .sbss_addr = 0x080042b0,
4072 .sbss_len = 0x80,
4073 .sbss_index = 0x0,
4074 .sbss = bnx2_TXP_b09FwSbss,
4075
4076 .bss_addr = 0x08004330,
4077 .bss_len = 0xa20,
4078 .bss_index = 0x0,
4079 .bss = bnx2_TXP_b09FwBss,
4080
4081 .rodata_addr = 0x08004198,
4082 .rodata_len = 0x30,
4083 .rodata_index = 0x0,
4084 .rodata = bnx2_TXP_b09FwRodata,
4085};
4086
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index c0bbddae4ec4..6482aed4bb7c 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1336,6 +1336,13 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1336 goto err_undo_flags; 1336 goto err_undo_flags;
1337 } 1337 }
1338 1338
1339 if (slave_dev->get_stats == NULL) {
1340 printk(KERN_NOTICE DRV_NAME
1341 ": %s: the driver for slave device %s does not provide "
1342 "get_stats function, network statistics will be "
1343 "inaccurate.\n", bond_dev->name, slave_dev->name);
1344 }
1345
1339 new_slave = kmalloc(sizeof(struct slave), GFP_KERNEL); 1346 new_slave = kmalloc(sizeof(struct slave), GFP_KERNEL);
1340 if (!new_slave) { 1347 if (!new_slave) {
1341 res = -ENOMEM; 1348 res = -ENOMEM;
@@ -3605,33 +3612,35 @@ static struct net_device_stats *bond_get_stats(struct net_device *bond_dev)
3605 read_lock_bh(&bond->lock); 3612 read_lock_bh(&bond->lock);
3606 3613
3607 bond_for_each_slave(bond, slave, i) { 3614 bond_for_each_slave(bond, slave, i) {
3608 sstats = slave->dev->get_stats(slave->dev); 3615 if (slave->dev->get_stats) {
3609 3616 sstats = slave->dev->get_stats(slave->dev);
3610 stats->rx_packets += sstats->rx_packets; 3617
3611 stats->rx_bytes += sstats->rx_bytes; 3618 stats->rx_packets += sstats->rx_packets;
3612 stats->rx_errors += sstats->rx_errors; 3619 stats->rx_bytes += sstats->rx_bytes;
3613 stats->rx_dropped += sstats->rx_dropped; 3620 stats->rx_errors += sstats->rx_errors;
3614 3621 stats->rx_dropped += sstats->rx_dropped;
3615 stats->tx_packets += sstats->tx_packets; 3622
3616 stats->tx_bytes += sstats->tx_bytes; 3623 stats->tx_packets += sstats->tx_packets;
3617 stats->tx_errors += sstats->tx_errors; 3624 stats->tx_bytes += sstats->tx_bytes;
3618 stats->tx_dropped += sstats->tx_dropped; 3625 stats->tx_errors += sstats->tx_errors;
3619 3626 stats->tx_dropped += sstats->tx_dropped;
3620 stats->multicast += sstats->multicast; 3627
3621 stats->collisions += sstats->collisions; 3628 stats->multicast += sstats->multicast;
3622 3629 stats->collisions += sstats->collisions;
3623 stats->rx_length_errors += sstats->rx_length_errors; 3630
3624 stats->rx_over_errors += sstats->rx_over_errors; 3631 stats->rx_length_errors += sstats->rx_length_errors;
3625 stats->rx_crc_errors += sstats->rx_crc_errors; 3632 stats->rx_over_errors += sstats->rx_over_errors;
3626 stats->rx_frame_errors += sstats->rx_frame_errors; 3633 stats->rx_crc_errors += sstats->rx_crc_errors;
3627 stats->rx_fifo_errors += sstats->rx_fifo_errors; 3634 stats->rx_frame_errors += sstats->rx_frame_errors;
3628 stats->rx_missed_errors += sstats->rx_missed_errors; 3635 stats->rx_fifo_errors += sstats->rx_fifo_errors;
3629 3636 stats->rx_missed_errors += sstats->rx_missed_errors;
3630 stats->tx_aborted_errors += sstats->tx_aborted_errors; 3637
3631 stats->tx_carrier_errors += sstats->tx_carrier_errors; 3638 stats->tx_aborted_errors += sstats->tx_aborted_errors;
3632 stats->tx_fifo_errors += sstats->tx_fifo_errors; 3639 stats->tx_carrier_errors += sstats->tx_carrier_errors;
3633 stats->tx_heartbeat_errors += sstats->tx_heartbeat_errors; 3640 stats->tx_fifo_errors += sstats->tx_fifo_errors;
3634 stats->tx_window_errors += sstats->tx_window_errors; 3641 stats->tx_heartbeat_errors += sstats->tx_heartbeat_errors;
3642 stats->tx_window_errors += sstats->tx_window_errors;
3643 }
3635 } 3644 }
3636 3645
3637 read_unlock_bh(&bond->lock); 3646 read_unlock_bh(&bond->lock);
@@ -3675,7 +3684,7 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
3675 mii->val_out = 0; 3684 mii->val_out = 0;
3676 read_lock_bh(&bond->lock); 3685 read_lock_bh(&bond->lock);
3677 read_lock(&bond->curr_slave_lock); 3686 read_lock(&bond->curr_slave_lock);
3678 if (bond->curr_active_slave) { 3687 if (netif_carrier_ok(bond->dev)) {
3679 mii->val_out = BMSR_LSTATUS; 3688 mii->val_out = BMSR_LSTATUS;
3680 } 3689 }
3681 read_unlock(&bond->curr_slave_lock); 3690 read_unlock(&bond->curr_slave_lock);
@@ -4692,6 +4701,8 @@ static int bond_check_params(struct bond_params *params)
4692 return 0; 4701 return 0;
4693} 4702}
4694 4703
4704static struct lock_class_key bonding_netdev_xmit_lock_key;
4705
4695/* Create a new bond based on the specified name and bonding parameters. 4706/* Create a new bond based on the specified name and bonding parameters.
4696 * Caller must NOT hold rtnl_lock; we need to release it here before we 4707 * Caller must NOT hold rtnl_lock; we need to release it here before we
4697 * set up our sysfs entries. 4708 * set up our sysfs entries.
@@ -4727,6 +4738,9 @@ int bond_create(char *name, struct bond_params *params, struct bonding **newbond
4727 if (res < 0) { 4738 if (res < 0) {
4728 goto out_bond; 4739 goto out_bond;
4729 } 4740 }
4741
4742 lockdep_set_class(&bond_dev->_xmit_lock, &bonding_netdev_xmit_lock_key);
4743
4730 if (newbond) 4744 if (newbond)
4731 *newbond = bond_dev->priv; 4745 *newbond = bond_dev->priv;
4732 4746
diff --git a/drivers/net/cassini.c b/drivers/net/cassini.c
index 521c5b71023c..c8126484c2be 100644
--- a/drivers/net/cassini.c
+++ b/drivers/net/cassini.c
@@ -2825,7 +2825,7 @@ static inline int cas_xmit_tx_ringN(struct cas *cp, int ring,
2825 u64 csum_start_off, csum_stuff_off; 2825 u64 csum_start_off, csum_stuff_off;
2826 2826
2827 csum_start_off = (u64) (skb->h.raw - skb->data); 2827 csum_start_off = (u64) (skb->h.raw - skb->data);
2828 csum_stuff_off = (u64) ((skb->h.raw + skb->csum) - skb->data); 2828 csum_stuff_off = csum_start_off + skb->csum_offset;
2829 2829
2830 ctrl = TX_DESC_CSUM_EN | 2830 ctrl = TX_DESC_CSUM_EN |
2831 CAS_BASE(TX_DESC_CSUM_START, csum_start_off) | 2831 CAS_BASE(TX_DESC_CSUM_START, csum_start_off) |
@@ -4066,9 +4066,9 @@ static int cas_alloc_rxds(struct cas *cp)
4066 return 0; 4066 return 0;
4067} 4067}
4068 4068
4069static void cas_reset_task(void *data) 4069static void cas_reset_task(struct work_struct *work)
4070{ 4070{
4071 struct cas *cp = (struct cas *) data; 4071 struct cas *cp = container_of(work, struct cas, reset_task);
4072#if 0 4072#if 0
4073 int pending = atomic_read(&cp->reset_task_pending); 4073 int pending = atomic_read(&cp->reset_task_pending);
4074#else 4074#else
@@ -5006,7 +5006,7 @@ static int __devinit cas_init_one(struct pci_dev *pdev,
5006 atomic_set(&cp->reset_task_pending_spare, 0); 5006 atomic_set(&cp->reset_task_pending_spare, 0);
5007 atomic_set(&cp->reset_task_pending_mtu, 0); 5007 atomic_set(&cp->reset_task_pending_mtu, 0);
5008#endif 5008#endif
5009 INIT_WORK(&cp->reset_task, cas_reset_task, cp); 5009 INIT_WORK(&cp->reset_task, cas_reset_task);
5010 5010
5011 /* Default link parameters */ 5011 /* Default link parameters */
5012 if (link_mode >= 0 && link_mode <= 6) 5012 if (link_mode >= 0 && link_mode <= 6)
diff --git a/drivers/net/chelsio/Makefile b/drivers/net/chelsio/Makefile
index 54c78d94f48b..382d23f810ab 100644
--- a/drivers/net/chelsio/Makefile
+++ b/drivers/net/chelsio/Makefile
@@ -1,11 +1,11 @@
1# 1#
2# Chelsio 10Gb NIC driver for Linux. 2# Chelsio T1 driver
3# 3#
4 4
5obj-$(CONFIG_CHELSIO_T1) += cxgb.o 5obj-$(CONFIG_CHELSIO_T1) += cxgb.o
6 6
7EXTRA_CFLAGS += -Idrivers/net/chelsio $(DEBUG_FLAGS) 7cxgb-$(CONFIG_CHELSIO_T1_1G) += ixf1010.o mac.o mv88e1xxx.o vsc7326.o vsc8244.o
8cxgb-objs := cxgb2.o espi.o tp.o pm3393.o sge.o subr.o \
9 mv88x201x.o my3126.o $(cxgb-y)
8 10
9 11
10cxgb-objs := cxgb2.o espi.o pm3393.o sge.o subr.o mv88x201x.o
11
diff --git a/drivers/net/chelsio/common.h b/drivers/net/chelsio/common.h
index 5d9dd14427c5..74758d2c7af8 100644
--- a/drivers/net/chelsio/common.h
+++ b/drivers/net/chelsio/common.h
@@ -45,6 +45,7 @@
45#include <linux/delay.h> 45#include <linux/delay.h>
46#include <linux/pci.h> 46#include <linux/pci.h>
47#include <linux/ethtool.h> 47#include <linux/ethtool.h>
48#include <linux/if_vlan.h>
48#include <linux/mii.h> 49#include <linux/mii.h>
49#include <linux/crc32.h> 50#include <linux/crc32.h>
50#include <linux/init.h> 51#include <linux/init.h>
@@ -53,13 +54,30 @@
53 54
54#define DRV_DESCRIPTION "Chelsio 10Gb Ethernet Driver" 55#define DRV_DESCRIPTION "Chelsio 10Gb Ethernet Driver"
55#define DRV_NAME "cxgb" 56#define DRV_NAME "cxgb"
56#define DRV_VERSION "2.1.1" 57#define DRV_VERSION "2.2"
57#define PFX DRV_NAME ": " 58#define PFX DRV_NAME ": "
58 59
59#define CH_ERR(fmt, ...) printk(KERN_ERR PFX fmt, ## __VA_ARGS__) 60#define CH_ERR(fmt, ...) printk(KERN_ERR PFX fmt, ## __VA_ARGS__)
60#define CH_WARN(fmt, ...) printk(KERN_WARNING PFX fmt, ## __VA_ARGS__) 61#define CH_WARN(fmt, ...) printk(KERN_WARNING PFX fmt, ## __VA_ARGS__)
61#define CH_ALERT(fmt, ...) printk(KERN_ALERT PFX fmt, ## __VA_ARGS__) 62#define CH_ALERT(fmt, ...) printk(KERN_ALERT PFX fmt, ## __VA_ARGS__)
62 63
64/*
65 * More powerful macro that selectively prints messages based on msg_enable.
66 * For info and debugging messages.
67 */
68#define CH_MSG(adapter, level, category, fmt, ...) do { \
69 if ((adapter)->msg_enable & NETIF_MSG_##category) \
70 printk(KERN_##level PFX "%s: " fmt, (adapter)->name, \
71 ## __VA_ARGS__); \
72} while (0)
73
74#ifdef DEBUG
75# define CH_DBG(adapter, category, fmt, ...) \
76 CH_MSG(adapter, DEBUG, category, fmt, ## __VA_ARGS__)
77#else
78# define CH_DBG(fmt, ...)
79#endif
80
63#define CH_DEVICE(devid, ssid, idx) \ 81#define CH_DEVICE(devid, ssid, idx) \
64 { PCI_VENDOR_ID_CHELSIO, devid, PCI_ANY_ID, ssid, 0, 0, idx } 82 { PCI_VENDOR_ID_CHELSIO, devid, PCI_ANY_ID, ssid, 0, 0, idx }
65 83
@@ -71,10 +89,6 @@
71 89
72typedef struct adapter adapter_t; 90typedef struct adapter adapter_t;
73 91
74void t1_elmer0_ext_intr(adapter_t *adapter);
75void t1_link_changed(adapter_t *adapter, int port_id, int link_status,
76 int speed, int duplex, int fc);
77
78struct t1_rx_mode { 92struct t1_rx_mode {
79 struct net_device *dev; 93 struct net_device *dev;
80 u32 idx; 94 u32 idx;
@@ -97,26 +111,53 @@ static inline u8 *t1_get_next_mcaddr(struct t1_rx_mode *rm)
97} 111}
98 112
99#define MAX_NPORTS 4 113#define MAX_NPORTS 4
114#define PORT_MASK ((1 << MAX_NPORTS) - 1)
115#define NMTUS 8
116#define TCB_SIZE 128
100 117
101#define SPEED_INVALID 0xffff 118#define SPEED_INVALID 0xffff
102#define DUPLEX_INVALID 0xff 119#define DUPLEX_INVALID 0xff
103 120
104enum { 121enum {
105 CHBT_BOARD_N110, 122 CHBT_BOARD_N110,
106 CHBT_BOARD_N210 123 CHBT_BOARD_N210,
124 CHBT_BOARD_7500,
125 CHBT_BOARD_8000,
126 CHBT_BOARD_CHT101,
127 CHBT_BOARD_CHT110,
128 CHBT_BOARD_CHT210,
129 CHBT_BOARD_CHT204,
130 CHBT_BOARD_CHT204V,
131 CHBT_BOARD_CHT204E,
132 CHBT_BOARD_CHN204,
133 CHBT_BOARD_COUGAR,
134 CHBT_BOARD_6800,
135 CHBT_BOARD_SIMUL,
107}; 136};
108 137
109enum { 138enum {
139 CHBT_TERM_FPGA,
110 CHBT_TERM_T1, 140 CHBT_TERM_T1,
111 CHBT_TERM_T2 141 CHBT_TERM_T2,
142 CHBT_TERM_T3
112}; 143};
113 144
114enum { 145enum {
146 CHBT_MAC_CHELSIO_A,
147 CHBT_MAC_IXF1010,
115 CHBT_MAC_PM3393, 148 CHBT_MAC_PM3393,
149 CHBT_MAC_VSC7321,
150 CHBT_MAC_DUMMY
116}; 151};
117 152
118enum { 153enum {
154 CHBT_PHY_88E1041,
155 CHBT_PHY_88E1111,
119 CHBT_PHY_88X2010, 156 CHBT_PHY_88X2010,
157 CHBT_PHY_XPAK,
158 CHBT_PHY_MY3126,
159 CHBT_PHY_8244,
160 CHBT_PHY_DUMMY
120}; 161};
121 162
122enum { 163enum {
@@ -150,16 +191,44 @@ struct chelsio_pci_params {
150 unsigned char is_pcix; 191 unsigned char is_pcix;
151}; 192};
152 193
194struct tp_params {
195 unsigned int pm_size;
196 unsigned int cm_size;
197 unsigned int pm_rx_base;
198 unsigned int pm_tx_base;
199 unsigned int pm_rx_pg_size;
200 unsigned int pm_tx_pg_size;
201 unsigned int pm_rx_num_pgs;
202 unsigned int pm_tx_num_pgs;
203 unsigned int rx_coalescing_size;
204 unsigned int use_5tuple_mode;
205};
206
207struct mc5_params {
208 unsigned int mode; /* selects MC5 width */
209 unsigned int nservers; /* size of server region */
210 unsigned int nroutes; /* size of routing region */
211};
212
213/* Default MC5 region sizes */
214#define DEFAULT_SERVER_REGION_LEN 256
215#define DEFAULT_RT_REGION_LEN 1024
216
153struct adapter_params { 217struct adapter_params {
154 struct sge_params sge; 218 struct sge_params sge;
219 struct mc5_params mc5;
220 struct tp_params tp;
155 struct chelsio_pci_params pci; 221 struct chelsio_pci_params pci;
156 222
157 const struct board_info *brd_info; 223 const struct board_info *brd_info;
158 224
225 unsigned short mtus[NMTUS];
159 unsigned int nports; /* # of ethernet ports */ 226 unsigned int nports; /* # of ethernet ports */
160 unsigned int stats_update_period; 227 unsigned int stats_update_period;
161 unsigned short chip_revision; 228 unsigned short chip_revision;
162 unsigned char chip_version; 229 unsigned char chip_version;
230 unsigned char is_asic;
231 unsigned char has_msi;
163}; 232};
164 233
165struct link_config { 234struct link_config {
@@ -207,17 +276,20 @@ struct adapter {
207 /* Terminator modules. */ 276 /* Terminator modules. */
208 struct sge *sge; 277 struct sge *sge;
209 struct peespi *espi; 278 struct peespi *espi;
279 struct petp *tp;
210 280
211 struct port_info port[MAX_NPORTS]; 281 struct port_info port[MAX_NPORTS];
212 struct work_struct stats_update_task; 282 struct delayed_work stats_update_task;
213 struct timer_list stats_update_timer; 283 struct timer_list stats_update_timer;
214 284
215 struct semaphore mib_mutex;
216 spinlock_t tpi_lock; 285 spinlock_t tpi_lock;
217 spinlock_t work_lock; 286 spinlock_t work_lock;
287 spinlock_t mac_lock;
288
218 /* guards async operations */ 289 /* guards async operations */
219 spinlock_t async_lock ____cacheline_aligned; 290 spinlock_t async_lock ____cacheline_aligned;
220 u32 slow_intr_mask; 291 u32 slow_intr_mask;
292 int t1powersave;
221}; 293};
222 294
223enum { /* adapter flags */ 295enum { /* adapter flags */
@@ -256,6 +328,11 @@ struct board_info {
256 const char *desc; 328 const char *desc;
257}; 329};
258 330
331static inline int t1_is_asic(const adapter_t *adapter)
332{
333 return adapter->params.is_asic;
334}
335
259extern struct pci_device_id t1_pci_tbl[]; 336extern struct pci_device_id t1_pci_tbl[];
260 337
261static inline int adapter_matches_type(const adapter_t *adapter, 338static inline int adapter_matches_type(const adapter_t *adapter,
@@ -285,13 +362,15 @@ static inline unsigned int core_ticks_per_usec(const adapter_t *adap)
285 return board_info(adap)->clock_core / 1000000; 362 return board_info(adap)->clock_core / 1000000;
286} 363}
287 364
365extern int __t1_tpi_read(adapter_t *adapter, u32 addr, u32 *valp);
366extern int __t1_tpi_write(adapter_t *adapter, u32 addr, u32 value);
288extern int t1_tpi_write(adapter_t *adapter, u32 addr, u32 value); 367extern int t1_tpi_write(adapter_t *adapter, u32 addr, u32 value);
289extern int t1_tpi_read(adapter_t *adapter, u32 addr, u32 *value); 368extern int t1_tpi_read(adapter_t *adapter, u32 addr, u32 *value);
290 369
291extern void t1_interrupts_enable(adapter_t *adapter); 370extern void t1_interrupts_enable(adapter_t *adapter);
292extern void t1_interrupts_disable(adapter_t *adapter); 371extern void t1_interrupts_disable(adapter_t *adapter);
293extern void t1_interrupts_clear(adapter_t *adapter); 372extern void t1_interrupts_clear(adapter_t *adapter);
294extern int elmer0_ext_intr_handler(adapter_t *adapter); 373extern int t1_elmer0_ext_intr_handler(adapter_t *adapter);
295extern int t1_slow_intr_handler(adapter_t *adapter); 374extern int t1_slow_intr_handler(adapter_t *adapter);
296 375
297extern int t1_link_start(struct cphy *phy, struct cmac *mac, struct link_config *lc); 376extern int t1_link_start(struct cphy *phy, struct cmac *mac, struct link_config *lc);
@@ -305,9 +384,7 @@ extern int t1_init_hw_modules(adapter_t *adapter);
305extern int t1_init_sw_modules(adapter_t *adapter, const struct board_info *bi); 384extern int t1_init_sw_modules(adapter_t *adapter, const struct board_info *bi);
306extern void t1_free_sw_modules(adapter_t *adapter); 385extern void t1_free_sw_modules(adapter_t *adapter);
307extern void t1_fatal_err(adapter_t *adapter); 386extern void t1_fatal_err(adapter_t *adapter);
308 387extern void t1_link_changed(adapter_t *adapter, int port_id);
309extern void t1_tp_set_udp_checksum_offload(adapter_t *adapter, int enable); 388extern void t1_link_negotiated(adapter_t *adapter, int port_id, int link_stat,
310extern void t1_tp_set_tcp_checksum_offload(adapter_t *adapter, int enable); 389 int speed, int duplex, int pause);
311extern void t1_tp_set_ip_checksum_offload(adapter_t *adapter, int enable);
312
313#endif /* _CXGB_COMMON_H_ */ 390#endif /* _CXGB_COMMON_H_ */
diff --git a/drivers/net/chelsio/cphy.h b/drivers/net/chelsio/cphy.h
index 3412342f7345..cf9143499882 100644
--- a/drivers/net/chelsio/cphy.h
+++ b/drivers/net/chelsio/cphy.h
@@ -52,7 +52,14 @@ struct mdio_ops {
52/* PHY interrupt types */ 52/* PHY interrupt types */
53enum { 53enum {
54 cphy_cause_link_change = 0x1, 54 cphy_cause_link_change = 0x1,
55 cphy_cause_error = 0x2 55 cphy_cause_error = 0x2,
56 cphy_cause_fifo_error = 0x3
57};
58
59enum {
60 PHY_LINK_UP = 0x1,
61 PHY_AUTONEG_RDY = 0x2,
62 PHY_AUTONEG_EN = 0x4
56}; 63};
57 64
58struct cphy; 65struct cphy;
@@ -81,7 +88,18 @@ struct cphy_ops {
81/* A PHY instance */ 88/* A PHY instance */
82struct cphy { 89struct cphy {
83 int addr; /* PHY address */ 90 int addr; /* PHY address */
91 int state; /* Link status state machine */
84 adapter_t *adapter; /* associated adapter */ 92 adapter_t *adapter; /* associated adapter */
93
94 struct delayed_work phy_update;
95
96 u16 bmsr;
97 int count;
98 int act_count;
99 int act_on;
100
101 u32 elmer_gpo;
102
85 struct cphy_ops *ops; /* PHY operations */ 103 struct cphy_ops *ops; /* PHY operations */
86 int (*mdio_read)(adapter_t *adapter, int phy_addr, int mmd_addr, 104 int (*mdio_read)(adapter_t *adapter, int phy_addr, int mmd_addr,
87 int reg_addr, unsigned int *val); 105 int reg_addr, unsigned int *val);
@@ -142,6 +160,10 @@ struct gphy {
142 int (*reset)(adapter_t *adapter); 160 int (*reset)(adapter_t *adapter);
143}; 161};
144 162
163extern struct gphy t1_my3126_ops;
164extern struct gphy t1_mv88e1xxx_ops;
165extern struct gphy t1_vsc8244_ops;
166extern struct gphy t1_xpak_ops;
145extern struct gphy t1_mv88x201x_ops; 167extern struct gphy t1_mv88x201x_ops;
146extern struct gphy t1_dummy_phy_ops; 168extern struct gphy t1_dummy_phy_ops;
147 169
diff --git a/drivers/net/chelsio/cpl5_cmd.h b/drivers/net/chelsio/cpl5_cmd.h
index 5b357d9e88d6..35f565be4fd3 100644
--- a/drivers/net/chelsio/cpl5_cmd.h
+++ b/drivers/net/chelsio/cpl5_cmd.h
@@ -46,24 +46,385 @@
46#endif 46#endif
47 47
48enum CPL_opcode { 48enum CPL_opcode {
49 CPL_PASS_OPEN_REQ = 0x1,
50 CPL_PASS_OPEN_RPL = 0x2,
51 CPL_PASS_ESTABLISH = 0x3,
52 CPL_PASS_ACCEPT_REQ = 0xE,
53 CPL_PASS_ACCEPT_RPL = 0x4,
54 CPL_ACT_OPEN_REQ = 0x5,
55 CPL_ACT_OPEN_RPL = 0x6,
56 CPL_CLOSE_CON_REQ = 0x7,
57 CPL_CLOSE_CON_RPL = 0x8,
58 CPL_CLOSE_LISTSRV_REQ = 0x9,
59 CPL_CLOSE_LISTSRV_RPL = 0xA,
60 CPL_ABORT_REQ = 0xB,
61 CPL_ABORT_RPL = 0xC,
62 CPL_PEER_CLOSE = 0xD,
63 CPL_ACT_ESTABLISH = 0x17,
64
65 CPL_GET_TCB = 0x24,
66 CPL_GET_TCB_RPL = 0x25,
67 CPL_SET_TCB = 0x26,
68 CPL_SET_TCB_FIELD = 0x27,
69 CPL_SET_TCB_RPL = 0x28,
70 CPL_PCMD = 0x29,
71
72 CPL_PCMD_READ = 0x31,
73 CPL_PCMD_READ_RPL = 0x32,
74
75
76 CPL_RX_DATA = 0xA0,
77 CPL_RX_DATA_DDP = 0xA1,
78 CPL_RX_DATA_ACK = 0xA3,
49 CPL_RX_PKT = 0xAD, 79 CPL_RX_PKT = 0xAD,
80 CPL_RX_ISCSI_HDR = 0xAF,
81 CPL_TX_DATA_ACK = 0xB0,
82 CPL_TX_DATA = 0xB1,
50 CPL_TX_PKT = 0xB2, 83 CPL_TX_PKT = 0xB2,
51 CPL_TX_PKT_LSO = 0xB6, 84 CPL_TX_PKT_LSO = 0xB6,
85
86 CPL_RTE_DELETE_REQ = 0xC0,
87 CPL_RTE_DELETE_RPL = 0xC1,
88 CPL_RTE_WRITE_REQ = 0xC2,
89 CPL_RTE_WRITE_RPL = 0xD3,
90 CPL_RTE_READ_REQ = 0xC3,
91 CPL_RTE_READ_RPL = 0xC4,
92 CPL_L2T_WRITE_REQ = 0xC5,
93 CPL_L2T_WRITE_RPL = 0xD4,
94 CPL_L2T_READ_REQ = 0xC6,
95 CPL_L2T_READ_RPL = 0xC7,
96 CPL_SMT_WRITE_REQ = 0xC8,
97 CPL_SMT_WRITE_RPL = 0xD5,
98 CPL_SMT_READ_REQ = 0xC9,
99 CPL_SMT_READ_RPL = 0xCA,
100 CPL_ARP_MISS_REQ = 0xCD,
101 CPL_ARP_MISS_RPL = 0xCE,
102 CPL_MIGRATE_C2T_REQ = 0xDC,
103 CPL_MIGRATE_C2T_RPL = 0xDD,
104 CPL_ERROR = 0xD7,
105
106 /* internal: driver -> TOM */
107 CPL_MSS_CHANGE = 0xE1
52}; 108};
53 109
54enum { /* TX_PKT_LSO ethernet types */ 110#define NUM_CPL_CMDS 256
111
112enum CPL_error {
113 CPL_ERR_NONE = 0,
114 CPL_ERR_TCAM_PARITY = 1,
115 CPL_ERR_TCAM_FULL = 3,
116 CPL_ERR_CONN_RESET = 20,
117 CPL_ERR_CONN_EXIST = 22,
118 CPL_ERR_ARP_MISS = 23,
119 CPL_ERR_BAD_SYN = 24,
120 CPL_ERR_CONN_TIMEDOUT = 30,
121 CPL_ERR_XMIT_TIMEDOUT = 31,
122 CPL_ERR_PERSIST_TIMEDOUT = 32,
123 CPL_ERR_FINWAIT2_TIMEDOUT = 33,
124 CPL_ERR_KEEPALIVE_TIMEDOUT = 34,
125 CPL_ERR_ABORT_FAILED = 42,
126 CPL_ERR_GENERAL = 99
127};
128
129enum {
130 CPL_CONN_POLICY_AUTO = 0,
131 CPL_CONN_POLICY_ASK = 1,
132 CPL_CONN_POLICY_DENY = 3
133};
134
135enum {
136 ULP_MODE_NONE = 0,
137 ULP_MODE_TCPDDP = 1,
138 ULP_MODE_ISCSI = 2,
139 ULP_MODE_IWARP = 3,
140 ULP_MODE_SSL = 4
141};
142
143enum {
144 CPL_PASS_OPEN_ACCEPT,
145 CPL_PASS_OPEN_REJECT
146};
147
148enum {
149 CPL_ABORT_SEND_RST = 0,
150 CPL_ABORT_NO_RST,
151 CPL_ABORT_POST_CLOSE_REQ = 2
152};
153
154enum { // TX_PKT_LSO ethernet types
55 CPL_ETH_II, 155 CPL_ETH_II,
56 CPL_ETH_II_VLAN, 156 CPL_ETH_II_VLAN,
57 CPL_ETH_802_3, 157 CPL_ETH_802_3,
58 CPL_ETH_802_3_VLAN 158 CPL_ETH_802_3_VLAN
59}; 159};
60 160
61struct cpl_rx_data { 161union opcode_tid {
162 u32 opcode_tid;
163 u8 opcode;
164};
165
166#define S_OPCODE 24
167#define V_OPCODE(x) ((x) << S_OPCODE)
168#define G_OPCODE(x) (((x) >> S_OPCODE) & 0xFF)
169#define G_TID(x) ((x) & 0xFFFFFF)
170
171/* tid is assumed to be 24-bits */
172#define MK_OPCODE_TID(opcode, tid) (V_OPCODE(opcode) | (tid))
173
174#define OPCODE_TID(cmd) ((cmd)->ot.opcode_tid)
175
176/* extract the TID from a CPL command */
177#define GET_TID(cmd) (G_TID(ntohl(OPCODE_TID(cmd))))
178
179struct tcp_options {
180 u16 mss;
181 u8 wsf;
182#if defined(__LITTLE_ENDIAN_BITFIELD)
183 u8 rsvd:4;
184 u8 ecn:1;
185 u8 sack:1;
186 u8 tstamp:1;
187#else
188 u8 tstamp:1;
189 u8 sack:1;
190 u8 ecn:1;
191 u8 rsvd:4;
192#endif
193};
194
195struct cpl_pass_open_req {
196 union opcode_tid ot;
197 u16 local_port;
198 u16 peer_port;
199 u32 local_ip;
200 u32 peer_ip;
201 u32 opt0h;
202 u32 opt0l;
203 u32 peer_netmask;
204 u32 opt1;
205};
206
207struct cpl_pass_open_rpl {
208 union opcode_tid ot;
209 u16 local_port;
210 u16 peer_port;
211 u32 local_ip;
212 u32 peer_ip;
213 u8 resvd[7];
214 u8 status;
215};
216
217struct cpl_pass_establish {
218 union opcode_tid ot;
219 u16 local_port;
220 u16 peer_port;
221 u32 local_ip;
222 u32 peer_ip;
223 u32 tos_tid;
224 u8 l2t_idx;
225 u8 rsvd[3];
226 u32 snd_isn;
227 u32 rcv_isn;
228};
229
230struct cpl_pass_accept_req {
231 union opcode_tid ot;
232 u16 local_port;
233 u16 peer_port;
234 u32 local_ip;
235 u32 peer_ip;
236 u32 tos_tid;
237 struct tcp_options tcp_options;
238 u8 dst_mac[6];
239 u16 vlan_tag;
240 u8 src_mac[6];
241 u8 rsvd[2];
242 u32 rcv_isn;
243 u32 unknown_tcp_options;
244};
245
246struct cpl_pass_accept_rpl {
247 union opcode_tid ot;
248 u32 rsvd0;
249 u32 rsvd1;
250 u32 peer_ip;
251 u32 opt0h;
252 union {
253 u32 opt0l;
254 struct {
255 u8 rsvd[3];
256 u8 status;
257 };
258 };
259};
260
261struct cpl_act_open_req {
262 union opcode_tid ot;
263 u16 local_port;
264 u16 peer_port;
265 u32 local_ip;
266 u32 peer_ip;
267 u32 opt0h;
268 u32 opt0l;
269 u32 iff_vlantag;
270 u32 rsvd;
271};
272
273struct cpl_act_open_rpl {
274 union opcode_tid ot;
275 u16 local_port;
276 u16 peer_port;
277 u32 local_ip;
278 u32 peer_ip;
279 u32 new_tid;
280 u8 rsvd[3];
281 u8 status;
282};
283
284struct cpl_act_establish {
285 union opcode_tid ot;
286 u16 local_port;
287 u16 peer_port;
288 u32 local_ip;
289 u32 peer_ip;
290 u32 tos_tid;
291 u32 rsvd;
292 u32 snd_isn;
293 u32 rcv_isn;
294};
295
296struct cpl_get_tcb {
297 union opcode_tid ot;
298 u32 rsvd;
299};
300
301struct cpl_get_tcb_rpl {
302 union opcode_tid ot;
303 u16 len;
304 u8 rsvd;
305 u8 status;
306};
307
308struct cpl_set_tcb {
309 union opcode_tid ot;
310 u16 len;
311 u16 rsvd;
312};
313
314struct cpl_set_tcb_field {
315 union opcode_tid ot;
316 u8 rsvd[3];
317 u8 offset;
318 u32 mask;
319 u32 val;
320};
321
322struct cpl_set_tcb_rpl {
323 union opcode_tid ot;
324 u8 rsvd[3];
325 u8 status;
326};
327
328struct cpl_pcmd {
329 union opcode_tid ot;
330 u16 dlen_in;
331 u16 dlen_out;
332 u32 pcmd_parm[2];
333};
334
335struct cpl_pcmd_read {
336 union opcode_tid ot;
337 u32 rsvd1;
338 u16 rsvd2;
339 u32 addr;
340 u16 len;
341};
342
343struct cpl_pcmd_read_rpl {
344 union opcode_tid ot;
345 u16 len;
346};
347
348struct cpl_close_con_req {
349 union opcode_tid ot;
350 u32 rsvd;
351};
352
353struct cpl_close_con_rpl {
354 union opcode_tid ot;
355 u8 rsvd[3];
356 u8 status;
357 u32 snd_nxt;
358 u32 rcv_nxt;
359};
360
361struct cpl_close_listserv_req {
362 union opcode_tid ot;
363 u32 rsvd;
364};
365
366struct cpl_close_listserv_rpl {
367 union opcode_tid ot;
368 u8 rsvd[3];
369 u8 status;
370};
371
372struct cpl_abort_req {
373 union opcode_tid ot;
62 u32 rsvd0; 374 u32 rsvd0;
375 u8 rsvd1;
376 u8 cmd;
377 u8 rsvd2[6];
378};
379
380struct cpl_abort_rpl {
381 union opcode_tid ot;
382 u32 rsvd0;
383 u8 rsvd1;
384 u8 status;
385 u8 rsvd2[6];
386};
387
388struct cpl_peer_close {
389 union opcode_tid ot;
390 u32 rsvd;
391};
392
393struct cpl_tx_data {
394 union opcode_tid ot;
395 u32 len;
396 u32 rsvd0;
397 u16 urg;
398 u16 flags;
399};
400
401struct cpl_tx_data_ack {
402 union opcode_tid ot;
403 u32 ack_seq;
404};
405
406struct cpl_rx_data {
407 union opcode_tid ot;
63 u32 len; 408 u32 len;
64 u32 seq; 409 u32 seq;
65 u16 urg; 410 u16 urg;
66 u8 rsvd1; 411 u8 rsvd;
412 u8 status;
413};
414
415struct cpl_rx_data_ack {
416 union opcode_tid ot;
417 u32 credit;
418};
419
420struct cpl_rx_data_ddp {
421 union opcode_tid ot;
422 u32 len;
423 u32 seq;
424 u32 nxt_seq;
425 u32 ulp_crc;
426 u16 ddp_status;
427 u8 rsvd;
67 u8 status; 428 u8 status;
68}; 429};
69 430
@@ -99,9 +460,9 @@ struct cpl_tx_pkt_lso {
99 u8 ip_csum_dis:1; 460 u8 ip_csum_dis:1;
100 u8 l4_csum_dis:1; 461 u8 l4_csum_dis:1;
101 u8 vlan_valid:1; 462 u8 vlan_valid:1;
102 u8 rsvd:1; 463 u8 :1;
103#else 464#else
104 u8 rsvd:1; 465 u8 :1;
105 u8 vlan_valid:1; 466 u8 vlan_valid:1;
106 u8 l4_csum_dis:1; 467 u8 l4_csum_dis:1;
107 u8 ip_csum_dis:1; 468 u8 ip_csum_dis:1;
@@ -110,8 +471,7 @@ struct cpl_tx_pkt_lso {
110 u16 vlan; 471 u16 vlan;
111 __be32 len; 472 __be32 len;
112 473
113 u32 rsvd2; 474 u8 rsvd[5];
114 u8 rsvd3;
115#if defined(__LITTLE_ENDIAN_BITFIELD) 475#if defined(__LITTLE_ENDIAN_BITFIELD)
116 u8 tcp_hdr_words:4; 476 u8 tcp_hdr_words:4;
117 u8 ip_hdr_words:4; 477 u8 ip_hdr_words:4;
@@ -138,8 +498,142 @@ struct cpl_rx_pkt {
138 u8 iff:4; 498 u8 iff:4;
139#endif 499#endif
140 u16 csum; 500 u16 csum;
141 __be16 vlan; 501 u16 vlan;
142 u16 len; 502 u16 len;
143}; 503};
144 504
505struct cpl_l2t_write_req {
506 union opcode_tid ot;
507 u32 params;
508 u8 rsvd1[2];
509 u8 dst_mac[6];
510};
511
512struct cpl_l2t_write_rpl {
513 union opcode_tid ot;
514 u8 status;
515 u8 rsvd[3];
516};
517
518struct cpl_l2t_read_req {
519 union opcode_tid ot;
520 u8 rsvd[3];
521 u8 l2t_idx;
522};
523
524struct cpl_l2t_read_rpl {
525 union opcode_tid ot;
526 u32 params;
527 u8 rsvd1[2];
528 u8 dst_mac[6];
529};
530
531struct cpl_smt_write_req {
532 union opcode_tid ot;
533 u8 rsvd0;
534#if defined(__LITTLE_ENDIAN_BITFIELD)
535 u8 rsvd1:1;
536 u8 mtu_idx:3;
537 u8 iff:4;
538#else
539 u8 iff:4;
540 u8 mtu_idx:3;
541 u8 rsvd1:1;
542#endif
543 u16 rsvd2;
544 u16 rsvd3;
545 u8 src_mac1[6];
546 u16 rsvd4;
547 u8 src_mac0[6];
548};
549
550struct cpl_smt_write_rpl {
551 union opcode_tid ot;
552 u8 status;
553 u8 rsvd[3];
554};
555
556struct cpl_smt_read_req {
557 union opcode_tid ot;
558 u8 rsvd0;
559#if defined(__LITTLE_ENDIAN_BITFIELD)
560 u8 rsvd1:4;
561 u8 iff:4;
562#else
563 u8 iff:4;
564 u8 rsvd1:4;
565#endif
566 u16 rsvd2;
567};
568
569struct cpl_smt_read_rpl {
570 union opcode_tid ot;
571 u8 status;
572#if defined(__LITTLE_ENDIAN_BITFIELD)
573 u8 rsvd1:1;
574 u8 mtu_idx:3;
575 u8 rsvd0:4;
576#else
577 u8 rsvd0:4;
578 u8 mtu_idx:3;
579 u8 rsvd1:1;
580#endif
581 u16 rsvd2;
582 u16 rsvd3;
583 u8 src_mac1[6];
584 u16 rsvd4;
585 u8 src_mac0[6];
586};
587
588struct cpl_rte_delete_req {
589 union opcode_tid ot;
590 u32 params;
591};
592
593struct cpl_rte_delete_rpl {
594 union opcode_tid ot;
595 u8 status;
596 u8 rsvd[3];
597};
598
599struct cpl_rte_write_req {
600 union opcode_tid ot;
601 u32 params;
602 u32 netmask;
603 u32 faddr;
604};
605
606struct cpl_rte_write_rpl {
607 union opcode_tid ot;
608 u8 status;
609 u8 rsvd[3];
610};
611
612struct cpl_rte_read_req {
613 union opcode_tid ot;
614 u32 params;
615};
616
617struct cpl_rte_read_rpl {
618 union opcode_tid ot;
619 u8 status;
620 u8 rsvd0[2];
621 u8 l2t_idx;
622#if defined(__LITTLE_ENDIAN_BITFIELD)
623 u8 rsvd1:7;
624 u8 select:1;
625#else
626 u8 select:1;
627 u8 rsvd1:7;
628#endif
629 u8 rsvd2[3];
630 u32 addr;
631};
632
633struct cpl_mss_change {
634 union opcode_tid ot;
635 u32 mss;
636};
637
145#endif /* _CXGB_CPL5_CMD_H_ */ 638#endif /* _CXGB_CPL5_CMD_H_ */
639
diff --git a/drivers/net/chelsio/cxgb2.c b/drivers/net/chelsio/cxgb2.c
index ad7ff9641a7e..de48eadddbc4 100644
--- a/drivers/net/chelsio/cxgb2.c
+++ b/drivers/net/chelsio/cxgb2.c
@@ -45,7 +45,6 @@
45#include <linux/if_vlan.h> 45#include <linux/if_vlan.h>
46#include <linux/mii.h> 46#include <linux/mii.h>
47#include <linux/sockios.h> 47#include <linux/sockios.h>
48#include <linux/proc_fs.h>
49#include <linux/dma-mapping.h> 48#include <linux/dma-mapping.h>
50#include <asm/uaccess.h> 49#include <asm/uaccess.h>
51 50
@@ -54,36 +53,10 @@
54#include "gmac.h" 53#include "gmac.h"
55#include "cphy.h" 54#include "cphy.h"
56#include "sge.h" 55#include "sge.h"
56#include "tp.h"
57#include "espi.h" 57#include "espi.h"
58#include "elmer0.h"
58 59
59#ifdef work_struct
60#include <linux/tqueue.h>
61#define INIT_WORK INIT_TQUEUE
62#define schedule_work schedule_task
63#define flush_scheduled_work flush_scheduled_tasks
64
65static inline void schedule_mac_stats_update(struct adapter *ap, int secs)
66{
67 mod_timer(&ap->stats_update_timer, jiffies + secs * HZ);
68}
69
70static inline void cancel_mac_stats_update(struct adapter *ap)
71{
72 del_timer_sync(&ap->stats_update_timer);
73 flush_scheduled_tasks();
74}
75
76/*
77 * Stats update timer for 2.4. It schedules a task to do the actual update as
78 * we need to access MAC statistics in process context.
79 */
80static void mac_stats_timer(unsigned long data)
81{
82 struct adapter *ap = (struct adapter *)data;
83
84 schedule_task(&ap->stats_update_task);
85}
86#else
87#include <linux/workqueue.h> 60#include <linux/workqueue.h>
88 61
89static inline void schedule_mac_stats_update(struct adapter *ap, int secs) 62static inline void schedule_mac_stats_update(struct adapter *ap, int secs)
@@ -95,7 +68,6 @@ static inline void cancel_mac_stats_update(struct adapter *ap)
95{ 68{
96 cancel_delayed_work(&ap->stats_update_task); 69 cancel_delayed_work(&ap->stats_update_task);
97} 70}
98#endif
99 71
100#define MAX_CMDQ_ENTRIES 16384 72#define MAX_CMDQ_ENTRIES 16384
101#define MAX_CMDQ1_ENTRIES 1024 73#define MAX_CMDQ1_ENTRIES 1024
@@ -103,10 +75,9 @@ static inline void cancel_mac_stats_update(struct adapter *ap)
103#define MAX_RX_JUMBO_BUFFERS 16384 75#define MAX_RX_JUMBO_BUFFERS 16384
104#define MAX_TX_BUFFERS_HIGH 16384U 76#define MAX_TX_BUFFERS_HIGH 16384U
105#define MAX_TX_BUFFERS_LOW 1536U 77#define MAX_TX_BUFFERS_LOW 1536U
78#define MAX_TX_BUFFERS 1460U
106#define MIN_FL_ENTRIES 32 79#define MIN_FL_ENTRIES 32
107 80
108#define PORT_MASK ((1 << MAX_NPORTS) - 1)
109
110#define DFLT_MSG_ENABLE (NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK | \ 81#define DFLT_MSG_ENABLE (NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK | \
111 NETIF_MSG_TIMER | NETIF_MSG_IFDOWN | NETIF_MSG_IFUP |\ 82 NETIF_MSG_TIMER | NETIF_MSG_IFDOWN | NETIF_MSG_IFUP |\
112 NETIF_MSG_RX_ERR | NETIF_MSG_TX_ERR) 83 NETIF_MSG_RX_ERR | NETIF_MSG_TX_ERR)
@@ -124,8 +95,21 @@ MODULE_LICENSE("GPL");
124static int dflt_msg_enable = DFLT_MSG_ENABLE; 95static int dflt_msg_enable = DFLT_MSG_ENABLE;
125 96
126module_param(dflt_msg_enable, int, 0); 97module_param(dflt_msg_enable, int, 0);
127MODULE_PARM_DESC(dflt_msg_enable, "Chelsio T1 message enable bitmap"); 98MODULE_PARM_DESC(dflt_msg_enable, "Chelsio T1 default message enable bitmap");
99
100#define HCLOCK 0x0
101#define LCLOCK 0x1
102
103/* T1 cards powersave mode */
104static int t1_clock(struct adapter *adapter, int mode);
105static int t1powersave = 1; /* HW default is powersave mode. */
128 106
107module_param(t1powersave, int, 0);
108MODULE_PARM_DESC(t1powersave, "Enable/Disable T1 powersaving mode");
109
110static int disable_msi = 0;
111module_param(disable_msi, int, 0);
112MODULE_PARM_DESC(disable_msi, "Disable Message Signaled Interrupt (MSI)");
129 113
130static const char pci_speed[][4] = { 114static const char pci_speed[][4] = {
131 "33", "66", "100", "133" 115 "33", "66", "100", "133"
@@ -149,7 +133,7 @@ static void t1_set_rxmode(struct net_device *dev)
149static void link_report(struct port_info *p) 133static void link_report(struct port_info *p)
150{ 134{
151 if (!netif_carrier_ok(p->dev)) 135 if (!netif_carrier_ok(p->dev))
152 printk(KERN_INFO "%s: link down\n", p->dev->name); 136 printk(KERN_INFO "%s: link down\n", p->dev->name);
153 else { 137 else {
154 const char *s = "10Mbps"; 138 const char *s = "10Mbps";
155 139
@@ -159,13 +143,13 @@ static void link_report(struct port_info *p)
159 case SPEED_100: s = "100Mbps"; break; 143 case SPEED_100: s = "100Mbps"; break;
160 } 144 }
161 145
162 printk(KERN_INFO "%s: link up, %s, %s-duplex\n", 146 printk(KERN_INFO "%s: link up, %s, %s-duplex\n",
163 p->dev->name, s, 147 p->dev->name, s,
164 p->link_config.duplex == DUPLEX_FULL ? "full" : "half"); 148 p->link_config.duplex == DUPLEX_FULL ? "full" : "half");
165 } 149 }
166} 150}
167 151
168void t1_link_changed(struct adapter *adapter, int port_id, int link_stat, 152void t1_link_negotiated(struct adapter *adapter, int port_id, int link_stat,
169 int speed, int duplex, int pause) 153 int speed, int duplex, int pause)
170{ 154{
171 struct port_info *p = &adapter->port[port_id]; 155 struct port_info *p = &adapter->port[port_id];
@@ -177,6 +161,22 @@ void t1_link_changed(struct adapter *adapter, int port_id, int link_stat,
177 netif_carrier_off(p->dev); 161 netif_carrier_off(p->dev);
178 link_report(p); 162 link_report(p);
179 163
164 /* multi-ports: inform toe */
165 if ((speed > 0) && (adapter->params.nports > 1)) {
166 unsigned int sched_speed = 10;
167 switch (speed) {
168 case SPEED_1000:
169 sched_speed = 1000;
170 break;
171 case SPEED_100:
172 sched_speed = 100;
173 break;
174 case SPEED_10:
175 sched_speed = 10;
176 break;
177 }
178 t1_sched_update_parms(adapter->sge, port_id, 0, sched_speed);
179 }
180 } 180 }
181} 181}
182 182
@@ -195,8 +195,10 @@ static void link_start(struct port_info *p)
195static void enable_hw_csum(struct adapter *adapter) 195static void enable_hw_csum(struct adapter *adapter)
196{ 196{
197 if (adapter->flags & TSO_CAPABLE) 197 if (adapter->flags & TSO_CAPABLE)
198 t1_tp_set_ip_checksum_offload(adapter, 1); /* for TSO only */ 198 t1_tp_set_ip_checksum_offload(adapter->tp, 1); /* for TSO only */
199 t1_tp_set_tcp_checksum_offload(adapter, 1); 199 if (adapter->flags & UDP_CSUM_CAPABLE)
200 t1_tp_set_udp_checksum_offload(adapter->tp, 1);
201 t1_tp_set_tcp_checksum_offload(adapter->tp, 1);
200} 202}
201 203
202/* 204/*
@@ -217,11 +219,19 @@ static int cxgb_up(struct adapter *adapter)
217 } 219 }
218 220
219 t1_interrupts_clear(adapter); 221 t1_interrupts_clear(adapter);
220 if ((err = request_irq(adapter->pdev->irq, 222
221 t1_select_intr_handler(adapter), IRQF_SHARED, 223 adapter->params.has_msi = !disable_msi && pci_enable_msi(adapter->pdev) == 0;
222 adapter->name, adapter))) { 224 err = request_irq(adapter->pdev->irq,
225 t1_select_intr_handler(adapter),
226 adapter->params.has_msi ? 0 : IRQF_SHARED,
227 adapter->name, adapter);
228 if (err) {
229 if (adapter->params.has_msi)
230 pci_disable_msi(adapter->pdev);
231
223 goto out_err; 232 goto out_err;
224 } 233 }
234
225 t1_sge_start(adapter->sge); 235 t1_sge_start(adapter->sge);
226 t1_interrupts_enable(adapter); 236 t1_interrupts_enable(adapter);
227 out_err: 237 out_err:
@@ -236,6 +246,8 @@ static void cxgb_down(struct adapter *adapter)
236 t1_sge_stop(adapter->sge); 246 t1_sge_stop(adapter->sge);
237 t1_interrupts_disable(adapter); 247 t1_interrupts_disable(adapter);
238 free_irq(adapter->pdev->irq, adapter); 248 free_irq(adapter->pdev->irq, adapter);
249 if (adapter->params.has_msi)
250 pci_disable_msi(adapter->pdev);
239} 251}
240 252
241static int cxgb_open(struct net_device *dev) 253static int cxgb_open(struct net_device *dev)
@@ -290,7 +302,7 @@ static struct net_device_stats *t1_get_stats(struct net_device *dev)
290 302
291 /* Do a full update of the MAC stats */ 303 /* Do a full update of the MAC stats */
292 pstats = p->mac->ops->statistics_update(p->mac, 304 pstats = p->mac->ops->statistics_update(p->mac,
293 MAC_STATS_UPDATE_FULL); 305 MAC_STATS_UPDATE_FULL);
294 306
295 ns->tx_packets = pstats->TxUnicastFramesOK + 307 ns->tx_packets = pstats->TxUnicastFramesOK +
296 pstats->TxMulticastFramesOK + pstats->TxBroadcastFramesOK; 308 pstats->TxMulticastFramesOK + pstats->TxBroadcastFramesOK;
@@ -344,47 +356,53 @@ static void set_msglevel(struct net_device *dev, u32 val)
344} 356}
345 357
346static char stats_strings[][ETH_GSTRING_LEN] = { 358static char stats_strings[][ETH_GSTRING_LEN] = {
347 "TxOctetsOK", 359 "TxOctetsOK",
348 "TxOctetsBad", 360 "TxOctetsBad",
349 "TxUnicastFramesOK", 361 "TxUnicastFramesOK",
350 "TxMulticastFramesOK", 362 "TxMulticastFramesOK",
351 "TxBroadcastFramesOK", 363 "TxBroadcastFramesOK",
352 "TxPauseFrames", 364 "TxPauseFrames",
353 "TxFramesWithDeferredXmissions", 365 "TxFramesWithDeferredXmissions",
354 "TxLateCollisions", 366 "TxLateCollisions",
355 "TxTotalCollisions", 367 "TxTotalCollisions",
356 "TxFramesAbortedDueToXSCollisions", 368 "TxFramesAbortedDueToXSCollisions",
357 "TxUnderrun", 369 "TxUnderrun",
358 "TxLengthErrors", 370 "TxLengthErrors",
359 "TxInternalMACXmitError", 371 "TxInternalMACXmitError",
360 "TxFramesWithExcessiveDeferral", 372 "TxFramesWithExcessiveDeferral",
361 "TxFCSErrors", 373 "TxFCSErrors",
362 374
363 "RxOctetsOK", 375 "RxOctetsOK",
364 "RxOctetsBad", 376 "RxOctetsBad",
365 "RxUnicastFramesOK", 377 "RxUnicastFramesOK",
366 "RxMulticastFramesOK", 378 "RxMulticastFramesOK",
367 "RxBroadcastFramesOK", 379 "RxBroadcastFramesOK",
368 "RxPauseFrames", 380 "RxPauseFrames",
369 "RxFCSErrors", 381 "RxFCSErrors",
370 "RxAlignErrors", 382 "RxAlignErrors",
371 "RxSymbolErrors", 383 "RxSymbolErrors",
372 "RxDataErrors", 384 "RxDataErrors",
373 "RxSequenceErrors", 385 "RxSequenceErrors",
374 "RxRuntErrors", 386 "RxRuntErrors",
375 "RxJabberErrors", 387 "RxJabberErrors",
376 "RxInternalMACRcvError", 388 "RxInternalMACRcvError",
377 "RxInRangeLengthErrors", 389 "RxInRangeLengthErrors",
378 "RxOutOfRangeLengthField", 390 "RxOutOfRangeLengthField",
379 "RxFrameTooLongErrors", 391 "RxFrameTooLongErrors",
380 392
381 "TSO", 393 /* Port stats */
382 "VLANextractions", 394 "RxPackets",
383 "VLANinsertions",
384 "RxCsumGood", 395 "RxCsumGood",
396 "TxPackets",
385 "TxCsumOffload", 397 "TxCsumOffload",
386 "RxDrops" 398 "TxTso",
387 399 "RxVlan",
400 "TxVlan",
401
402 /* Interrupt stats */
403 "rx drops",
404 "pure_rsps",
405 "unhandled irqs",
388 "respQ_empty", 406 "respQ_empty",
389 "respQ_overflow", 407 "respQ_overflow",
390 "freelistQ_empty", 408 "freelistQ_empty",
@@ -392,11 +410,7 @@ static char stats_strings[][ETH_GSTRING_LEN] = {
392 "pkt_mismatch", 410 "pkt_mismatch",
393 "cmdQ_full0", 411 "cmdQ_full0",
394 "cmdQ_full1", 412 "cmdQ_full1",
395 "tx_ipfrags", 413
396 "tx_reg_pkts",
397 "tx_lso_pkts",
398 "tx_do_cksum",
399
400 "espi_DIP2ParityErr", 414 "espi_DIP2ParityErr",
401 "espi_DIP4Err", 415 "espi_DIP4Err",
402 "espi_RxDrops", 416 "espi_RxDrops",
@@ -404,7 +418,7 @@ static char stats_strings[][ETH_GSTRING_LEN] = {
404 "espi_RxOvfl", 418 "espi_RxOvfl",
405 "espi_ParityErr" 419 "espi_ParityErr"
406}; 420};
407 421
408#define T2_REGMAP_SIZE (3 * 1024) 422#define T2_REGMAP_SIZE (3 * 1024)
409 423
410static int get_regs_len(struct net_device *dev) 424static int get_regs_len(struct net_device *dev)
@@ -439,65 +453,77 @@ static void get_stats(struct net_device *dev, struct ethtool_stats *stats,
439 struct adapter *adapter = dev->priv; 453 struct adapter *adapter = dev->priv;
440 struct cmac *mac = adapter->port[dev->if_port].mac; 454 struct cmac *mac = adapter->port[dev->if_port].mac;
441 const struct cmac_statistics *s; 455 const struct cmac_statistics *s;
442 const struct sge_port_stats *ss;
443 const struct sge_intr_counts *t; 456 const struct sge_intr_counts *t;
457 struct sge_port_stats ss;
444 458
445 s = mac->ops->statistics_update(mac, MAC_STATS_UPDATE_FULL); 459 s = mac->ops->statistics_update(mac, MAC_STATS_UPDATE_FULL);
446 ss = t1_sge_get_port_stats(adapter->sge, dev->if_port);
447 t = t1_sge_get_intr_counts(adapter->sge);
448 460
449 *data++ = s->TxOctetsOK; 461 *data++ = s->TxOctetsOK;
450 *data++ = s->TxOctetsBad; 462 *data++ = s->TxOctetsBad;
451 *data++ = s->TxUnicastFramesOK; 463 *data++ = s->TxUnicastFramesOK;
452 *data++ = s->TxMulticastFramesOK; 464 *data++ = s->TxMulticastFramesOK;
453 *data++ = s->TxBroadcastFramesOK; 465 *data++ = s->TxBroadcastFramesOK;
454 *data++ = s->TxPauseFrames; 466 *data++ = s->TxPauseFrames;
455 *data++ = s->TxFramesWithDeferredXmissions; 467 *data++ = s->TxFramesWithDeferredXmissions;
456 *data++ = s->TxLateCollisions; 468 *data++ = s->TxLateCollisions;
457 *data++ = s->TxTotalCollisions; 469 *data++ = s->TxTotalCollisions;
458 *data++ = s->TxFramesAbortedDueToXSCollisions; 470 *data++ = s->TxFramesAbortedDueToXSCollisions;
459 *data++ = s->TxUnderrun; 471 *data++ = s->TxUnderrun;
460 *data++ = s->TxLengthErrors; 472 *data++ = s->TxLengthErrors;
461 *data++ = s->TxInternalMACXmitError; 473 *data++ = s->TxInternalMACXmitError;
462 *data++ = s->TxFramesWithExcessiveDeferral; 474 *data++ = s->TxFramesWithExcessiveDeferral;
463 *data++ = s->TxFCSErrors; 475 *data++ = s->TxFCSErrors;
464 476
465 *data++ = s->RxOctetsOK; 477 *data++ = s->RxOctetsOK;
466 *data++ = s->RxOctetsBad; 478 *data++ = s->RxOctetsBad;
467 *data++ = s->RxUnicastFramesOK; 479 *data++ = s->RxUnicastFramesOK;
468 *data++ = s->RxMulticastFramesOK; 480 *data++ = s->RxMulticastFramesOK;
469 *data++ = s->RxBroadcastFramesOK; 481 *data++ = s->RxBroadcastFramesOK;
470 *data++ = s->RxPauseFrames; 482 *data++ = s->RxPauseFrames;
471 *data++ = s->RxFCSErrors; 483 *data++ = s->RxFCSErrors;
472 *data++ = s->RxAlignErrors; 484 *data++ = s->RxAlignErrors;
473 *data++ = s->RxSymbolErrors; 485 *data++ = s->RxSymbolErrors;
474 *data++ = s->RxDataErrors; 486 *data++ = s->RxDataErrors;
475 *data++ = s->RxSequenceErrors; 487 *data++ = s->RxSequenceErrors;
476 *data++ = s->RxRuntErrors; 488 *data++ = s->RxRuntErrors;
477 *data++ = s->RxJabberErrors; 489 *data++ = s->RxJabberErrors;
478 *data++ = s->RxInternalMACRcvError; 490 *data++ = s->RxInternalMACRcvError;
479 *data++ = s->RxInRangeLengthErrors; 491 *data++ = s->RxInRangeLengthErrors;
480 *data++ = s->RxOutOfRangeLengthField; 492 *data++ = s->RxOutOfRangeLengthField;
481 *data++ = s->RxFrameTooLongErrors; 493 *data++ = s->RxFrameTooLongErrors;
482 494
483 *data++ = ss->tso; 495 t1_sge_get_port_stats(adapter->sge, dev->if_port, &ss);
484 *data++ = ss->vlan_xtract; 496 *data++ = ss.rx_packets;
485 *data++ = ss->vlan_insert; 497 *data++ = ss.rx_cso_good;
486 *data++ = ss->rx_cso_good; 498 *data++ = ss.tx_packets;
487 *data++ = ss->tx_cso; 499 *data++ = ss.tx_cso;
488 *data++ = ss->rx_drops; 500 *data++ = ss.tx_tso;
489 501 *data++ = ss.vlan_xtract;
490 *data++ = (u64)t->respQ_empty; 502 *data++ = ss.vlan_insert;
491 *data++ = (u64)t->respQ_overflow; 503
492 *data++ = (u64)t->freelistQ_empty; 504 t = t1_sge_get_intr_counts(adapter->sge);
493 *data++ = (u64)t->pkt_too_big; 505 *data++ = t->rx_drops;
494 *data++ = (u64)t->pkt_mismatch; 506 *data++ = t->pure_rsps;
495 *data++ = (u64)t->cmdQ_full[0]; 507 *data++ = t->unhandled_irqs;
496 *data++ = (u64)t->cmdQ_full[1]; 508 *data++ = t->respQ_empty;
497 *data++ = (u64)t->tx_ipfrags; 509 *data++ = t->respQ_overflow;
498 *data++ = (u64)t->tx_reg_pkts; 510 *data++ = t->freelistQ_empty;
499 *data++ = (u64)t->tx_lso_pkts; 511 *data++ = t->pkt_too_big;
500 *data++ = (u64)t->tx_do_cksum; 512 *data++ = t->pkt_mismatch;
513 *data++ = t->cmdQ_full[0];
514 *data++ = t->cmdQ_full[1];
515
516 if (adapter->espi) {
517 const struct espi_intr_counts *e;
518
519 e = t1_espi_get_intr_counts(adapter->espi);
520 *data++ = e->DIP2_parity_err;
521 *data++ = e->DIP4_err;
522 *data++ = e->rx_drops;
523 *data++ = e->tx_drops;
524 *data++ = e->rx_ovflw;
525 *data++ = e->parity_err;
526 }
501} 527}
502 528
503static inline void reg_block_dump(struct adapter *ap, void *buf, 529static inline void reg_block_dump(struct adapter *ap, void *buf,
@@ -521,6 +547,15 @@ static void get_regs(struct net_device *dev, struct ethtool_regs *regs,
521 547
522 memset(buf, 0, T2_REGMAP_SIZE); 548 memset(buf, 0, T2_REGMAP_SIZE);
523 reg_block_dump(ap, buf, 0, A_SG_RESPACCUTIMER); 549 reg_block_dump(ap, buf, 0, A_SG_RESPACCUTIMER);
550 reg_block_dump(ap, buf, A_MC3_CFG, A_MC4_INT_CAUSE);
551 reg_block_dump(ap, buf, A_TPI_ADDR, A_TPI_PAR);
552 reg_block_dump(ap, buf, A_TP_IN_CONFIG, A_TP_TX_DROP_COUNT);
553 reg_block_dump(ap, buf, A_RAT_ROUTE_CONTROL, A_RAT_INTR_CAUSE);
554 reg_block_dump(ap, buf, A_CSPI_RX_AE_WM, A_CSPI_INTR_ENABLE);
555 reg_block_dump(ap, buf, A_ESPI_SCH_TOKEN0, A_ESPI_GOSTAT);
556 reg_block_dump(ap, buf, A_ULP_ULIMIT, A_ULP_PIO_CTRL);
557 reg_block_dump(ap, buf, A_PL_ENABLE, A_PL_CAUSE);
558 reg_block_dump(ap, buf, A_MC5_CONFIG, A_MC5_MASK_WRITE_CMD);
524} 559}
525 560
526static int get_settings(struct net_device *dev, struct ethtool_cmd *cmd) 561static int get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
@@ -539,12 +574,12 @@ static int get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
539 cmd->duplex = -1; 574 cmd->duplex = -1;
540 } 575 }
541 576
542 cmd->port = (cmd->supported & SUPPORTED_TP) ? PORT_TP : PORT_FIBRE; 577 cmd->port = (cmd->supported & SUPPORTED_TP) ? PORT_TP : PORT_FIBRE;
543 cmd->phy_address = p->phy->addr; 578 cmd->phy_address = p->phy->addr;
544 cmd->transceiver = XCVR_EXTERNAL; 579 cmd->transceiver = XCVR_EXTERNAL;
545 cmd->autoneg = p->link_config.autoneg; 580 cmd->autoneg = p->link_config.autoneg;
546 cmd->maxtxpkt = 0; 581 cmd->maxtxpkt = 0;
547 cmd->maxrxpkt = 0; 582 cmd->maxrxpkt = 0;
548 return 0; 583 return 0;
549} 584}
550 585
@@ -715,7 +750,7 @@ static int set_sge_param(struct net_device *dev, struct ethtool_ringparam *e)
715 return -EINVAL; 750 return -EINVAL;
716 751
717 if (adapter->flags & FULL_INIT_DONE) 752 if (adapter->flags & FULL_INIT_DONE)
718 return -EBUSY; 753 return -EBUSY;
719 754
720 adapter->params.sge.freelQ_size[!jumbo_fl] = e->rx_pending; 755 adapter->params.sge.freelQ_size[!jumbo_fl] = e->rx_pending;
721 adapter->params.sge.freelQ_size[jumbo_fl] = e->rx_jumbo_pending; 756 adapter->params.sge.freelQ_size[jumbo_fl] = e->rx_jumbo_pending;
@@ -759,7 +794,9 @@ static int get_coalesce(struct net_device *dev, struct ethtool_coalesce *c)
759 794
760static int get_eeprom_len(struct net_device *dev) 795static int get_eeprom_len(struct net_device *dev)
761{ 796{
762 return EEPROM_SIZE; 797 struct adapter *adapter = dev->priv;
798
799 return t1_is_asic(adapter) ? EEPROM_SIZE : 0;
763} 800}
764 801
765#define EEPROM_MAGIC(ap) \ 802#define EEPROM_MAGIC(ap) \
@@ -809,47 +846,36 @@ static const struct ethtool_ops t1_ethtool_ops = {
809 .set_tso = set_tso, 846 .set_tso = set_tso,
810}; 847};
811 848
812static void cxgb_proc_cleanup(struct adapter *adapter,
813 struct proc_dir_entry *dir)
814{
815 const char *name;
816 name = adapter->name;
817 remove_proc_entry(name, dir);
818}
819//#define chtoe_setup_toedev(adapter) NULL
820#define update_mtu_tab(adapter)
821#define write_smt_entry(adapter, idx)
822
823static int t1_ioctl(struct net_device *dev, struct ifreq *req, int cmd) 849static int t1_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
824{ 850{
825 struct adapter *adapter = dev->priv; 851 struct adapter *adapter = dev->priv;
826 struct mii_ioctl_data *data = if_mii(req); 852 struct mii_ioctl_data *data = if_mii(req);
827 853
828 switch (cmd) { 854 switch (cmd) {
829 case SIOCGMIIPHY: 855 case SIOCGMIIPHY:
830 data->phy_id = adapter->port[dev->if_port].phy->addr; 856 data->phy_id = adapter->port[dev->if_port].phy->addr;
831 /* FALLTHRU */ 857 /* FALLTHRU */
832 case SIOCGMIIREG: { 858 case SIOCGMIIREG: {
833 struct cphy *phy = adapter->port[dev->if_port].phy; 859 struct cphy *phy = adapter->port[dev->if_port].phy;
834 u32 val; 860 u32 val;
835 861
836 if (!phy->mdio_read) 862 if (!phy->mdio_read)
837 return -EOPNOTSUPP; 863 return -EOPNOTSUPP;
838 phy->mdio_read(adapter, data->phy_id, 0, data->reg_num & 0x1f, 864 phy->mdio_read(adapter, data->phy_id, 0, data->reg_num & 0x1f,
839 &val); 865 &val);
840 data->val_out = val; 866 data->val_out = val;
841 break; 867 break;
842 } 868 }
843 case SIOCSMIIREG: { 869 case SIOCSMIIREG: {
844 struct cphy *phy = adapter->port[dev->if_port].phy; 870 struct cphy *phy = adapter->port[dev->if_port].phy;
845 871
846 if (!capable(CAP_NET_ADMIN)) 872 if (!capable(CAP_NET_ADMIN))
847 return -EPERM; 873 return -EPERM;
848 if (!phy->mdio_write) 874 if (!phy->mdio_write)
849 return -EOPNOTSUPP; 875 return -EOPNOTSUPP;
850 phy->mdio_write(adapter, data->phy_id, 0, data->reg_num & 0x1f, 876 phy->mdio_write(adapter, data->phy_id, 0, data->reg_num & 0x1f,
851 data->val_in); 877 data->val_in);
852 break; 878 break;
853 } 879 }
854 880
855 default: 881 default:
@@ -865,9 +891,9 @@ static int t1_change_mtu(struct net_device *dev, int new_mtu)
865 struct cmac *mac = adapter->port[dev->if_port].mac; 891 struct cmac *mac = adapter->port[dev->if_port].mac;
866 892
867 if (!mac->ops->set_mtu) 893 if (!mac->ops->set_mtu)
868 return -EOPNOTSUPP; 894 return -EOPNOTSUPP;
869 if (new_mtu < 68) 895 if (new_mtu < 68)
870 return -EINVAL; 896 return -EINVAL;
871 if ((ret = mac->ops->set_mtu(mac, new_mtu))) 897 if ((ret = mac->ops->set_mtu(mac, new_mtu)))
872 return ret; 898 return ret;
873 dev->mtu = new_mtu; 899 dev->mtu = new_mtu;
@@ -918,7 +944,7 @@ static void t1_netpoll(struct net_device *dev)
918 struct adapter *adapter = dev->priv; 944 struct adapter *adapter = dev->priv;
919 945
920 local_irq_save(flags); 946 local_irq_save(flags);
921 t1_select_intr_handler(adapter)(adapter->pdev->irq, adapter); 947 t1_select_intr_handler(adapter)(adapter->pdev->irq, adapter);
922 local_irq_restore(flags); 948 local_irq_restore(flags);
923} 949}
924#endif 950#endif
@@ -927,10 +953,11 @@ static void t1_netpoll(struct net_device *dev)
927 * Periodic accumulation of MAC statistics. This is used only if the MAC 953 * Periodic accumulation of MAC statistics. This is used only if the MAC
928 * does not have any other way to prevent stats counter overflow. 954 * does not have any other way to prevent stats counter overflow.
929 */ 955 */
930static void mac_stats_task(void *data) 956static void mac_stats_task(struct work_struct *work)
931{ 957{
932 int i; 958 int i;
933 struct adapter *adapter = data; 959 struct adapter *adapter =
960 container_of(work, struct adapter, stats_update_task.work);
934 961
935 for_each_port(adapter, i) { 962 for_each_port(adapter, i) {
936 struct port_info *p = &adapter->port[i]; 963 struct port_info *p = &adapter->port[i];
@@ -951,18 +978,19 @@ static void mac_stats_task(void *data)
951/* 978/*
952 * Processes elmer0 external interrupts in process context. 979 * Processes elmer0 external interrupts in process context.
953 */ 980 */
954static void ext_intr_task(void *data) 981static void ext_intr_task(struct work_struct *work)
955{ 982{
956 struct adapter *adapter = data; 983 struct adapter *adapter =
984 container_of(work, struct adapter, ext_intr_handler_task);
957 985
958 elmer0_ext_intr_handler(adapter); 986 t1_elmer0_ext_intr_handler(adapter);
959 987
960 /* Now reenable external interrupts */ 988 /* Now reenable external interrupts */
961 spin_lock_irq(&adapter->async_lock); 989 spin_lock_irq(&adapter->async_lock);
962 adapter->slow_intr_mask |= F_PL_INTR_EXT; 990 adapter->slow_intr_mask |= F_PL_INTR_EXT;
963 writel(F_PL_INTR_EXT, adapter->regs + A_PL_CAUSE); 991 writel(F_PL_INTR_EXT, adapter->regs + A_PL_CAUSE);
964 writel(adapter->slow_intr_mask | F_PL_INTR_SGE_DATA, 992 writel(adapter->slow_intr_mask | F_PL_INTR_SGE_DATA,
965 adapter->regs + A_PL_ENABLE); 993 adapter->regs + A_PL_ENABLE);
966 spin_unlock_irq(&adapter->async_lock); 994 spin_unlock_irq(&adapter->async_lock);
967} 995}
968 996
@@ -978,7 +1006,7 @@ void t1_elmer0_ext_intr(struct adapter *adapter)
978 */ 1006 */
979 adapter->slow_intr_mask &= ~F_PL_INTR_EXT; 1007 adapter->slow_intr_mask &= ~F_PL_INTR_EXT;
980 writel(adapter->slow_intr_mask | F_PL_INTR_SGE_DATA, 1008 writel(adapter->slow_intr_mask | F_PL_INTR_SGE_DATA,
981 adapter->regs + A_PL_ENABLE); 1009 adapter->regs + A_PL_ENABLE);
982 schedule_work(&adapter->ext_intr_handler_task); 1010 schedule_work(&adapter->ext_intr_handler_task);
983} 1011}
984 1012
@@ -1011,7 +1039,7 @@ static int __devinit init_one(struct pci_dev *pdev,
1011 1039
1012 err = pci_enable_device(pdev); 1040 err = pci_enable_device(pdev);
1013 if (err) 1041 if (err)
1014 return err; 1042 return err;
1015 1043
1016 if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) { 1044 if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) {
1017 CH_ERR("%s: cannot find PCI device memory base address\n", 1045 CH_ERR("%s: cannot find PCI device memory base address\n",
@@ -1043,7 +1071,7 @@ static int __devinit init_one(struct pci_dev *pdev,
1043 1071
1044 pci_set_master(pdev); 1072 pci_set_master(pdev);
1045 1073
1046 mmio_start = pci_resource_start(pdev, 0); 1074 mmio_start = pci_resource_start(pdev, 0);
1047 mmio_len = pci_resource_len(pdev, 0); 1075 mmio_len = pci_resource_len(pdev, 0);
1048 bi = t1_get_board_info(ent->driver_data); 1076 bi = t1_get_board_info(ent->driver_data);
1049 1077
@@ -1081,21 +1109,15 @@ static int __devinit init_one(struct pci_dev *pdev,
1081 adapter->msg_enable = dflt_msg_enable; 1109 adapter->msg_enable = dflt_msg_enable;
1082 adapter->mmio_len = mmio_len; 1110 adapter->mmio_len = mmio_len;
1083 1111
1084 init_MUTEX(&adapter->mib_mutex);
1085 spin_lock_init(&adapter->tpi_lock); 1112 spin_lock_init(&adapter->tpi_lock);
1086 spin_lock_init(&adapter->work_lock); 1113 spin_lock_init(&adapter->work_lock);
1087 spin_lock_init(&adapter->async_lock); 1114 spin_lock_init(&adapter->async_lock);
1115 spin_lock_init(&adapter->mac_lock);
1088 1116
1089 INIT_WORK(&adapter->ext_intr_handler_task, 1117 INIT_WORK(&adapter->ext_intr_handler_task,
1090 ext_intr_task, adapter); 1118 ext_intr_task);
1091 INIT_WORK(&adapter->stats_update_task, mac_stats_task, 1119 INIT_DELAYED_WORK(&adapter->stats_update_task,
1092 adapter); 1120 mac_stats_task);
1093#ifdef work_struct
1094 init_timer(&adapter->stats_update_timer);
1095 adapter->stats_update_timer.function = mac_stats_timer;
1096 adapter->stats_update_timer.data =
1097 (unsigned long)adapter;
1098#endif
1099 1121
1100 pci_set_drvdata(pdev, netdev); 1122 pci_set_drvdata(pdev, netdev);
1101 } 1123 }
@@ -1122,16 +1144,19 @@ static int __devinit init_one(struct pci_dev *pdev,
1122 netdev->vlan_rx_register = vlan_rx_register; 1144 netdev->vlan_rx_register = vlan_rx_register;
1123 netdev->vlan_rx_kill_vid = vlan_rx_kill_vid; 1145 netdev->vlan_rx_kill_vid = vlan_rx_kill_vid;
1124#endif 1146#endif
1125 adapter->flags |= TSO_CAPABLE; 1147
1126 netdev->features |= NETIF_F_TSO; 1148 /* T204: disable TSO */
1149 if (!(is_T2(adapter)) || bi->port_number != 4) {
1150 adapter->flags |= TSO_CAPABLE;
1151 netdev->features |= NETIF_F_TSO;
1152 }
1127 } 1153 }
1128 1154
1129 netdev->open = cxgb_open; 1155 netdev->open = cxgb_open;
1130 netdev->stop = cxgb_close; 1156 netdev->stop = cxgb_close;
1131 netdev->hard_start_xmit = t1_start_xmit; 1157 netdev->hard_start_xmit = t1_start_xmit;
1132 netdev->hard_header_len += (adapter->flags & TSO_CAPABLE) ? 1158 netdev->hard_header_len += (adapter->flags & TSO_CAPABLE) ?
1133 sizeof(struct cpl_tx_pkt_lso) : 1159 sizeof(struct cpl_tx_pkt_lso) : sizeof(struct cpl_tx_pkt);
1134 sizeof(struct cpl_tx_pkt);
1135 netdev->get_stats = t1_get_stats; 1160 netdev->get_stats = t1_get_stats;
1136 netdev->set_multicast_list = t1_set_rxmode; 1161 netdev->set_multicast_list = t1_set_rxmode;
1137 netdev->do_ioctl = t1_ioctl; 1162 netdev->do_ioctl = t1_ioctl;
@@ -1142,7 +1167,7 @@ static int __devinit init_one(struct pci_dev *pdev,
1142#endif 1167#endif
1143 netdev->weight = 64; 1168 netdev->weight = 64;
1144 1169
1145 SET_ETHTOOL_OPS(netdev, &t1_ethtool_ops); 1170 SET_ETHTOOL_OPS(netdev, &t1_ethtool_ops);
1146 } 1171 }
1147 1172
1148 if (t1_init_sw_modules(adapter, bi) < 0) { 1173 if (t1_init_sw_modules(adapter, bi) < 0) {
@@ -1169,7 +1194,7 @@ static int __devinit init_one(struct pci_dev *pdev,
1169 if (!adapter->registered_device_map) 1194 if (!adapter->registered_device_map)
1170 adapter->name = adapter->port[i].dev->name; 1195 adapter->name = adapter->port[i].dev->name;
1171 1196
1172 __set_bit(i, &adapter->registered_device_map); 1197 __set_bit(i, &adapter->registered_device_map);
1173 } 1198 }
1174 } 1199 }
1175 if (!adapter->registered_device_map) { 1200 if (!adapter->registered_device_map) {
@@ -1182,18 +1207,28 @@ static int __devinit init_one(struct pci_dev *pdev,
1182 bi->desc, adapter->params.chip_revision, 1207 bi->desc, adapter->params.chip_revision,
1183 adapter->params.pci.is_pcix ? "PCIX" : "PCI", 1208 adapter->params.pci.is_pcix ? "PCIX" : "PCI",
1184 adapter->params.pci.speed, adapter->params.pci.width); 1209 adapter->params.pci.speed, adapter->params.pci.width);
1210
1211 /*
1212 * Set the T1B ASIC and memory clocks.
1213 */
1214 if (t1powersave)
1215 adapter->t1powersave = LCLOCK; /* HW default is powersave mode. */
1216 else
1217 adapter->t1powersave = HCLOCK;
1218 if (t1_is_T1B(adapter))
1219 t1_clock(adapter, t1powersave);
1220
1185 return 0; 1221 return 0;
1186 1222
1187 out_release_adapter_res: 1223 out_release_adapter_res:
1188 t1_free_sw_modules(adapter); 1224 t1_free_sw_modules(adapter);
1189 out_free_dev: 1225 out_free_dev:
1190 if (adapter) { 1226 if (adapter) {
1191 if (adapter->regs) iounmap(adapter->regs); 1227 if (adapter->regs)
1228 iounmap(adapter->regs);
1192 for (i = bi->port_number - 1; i >= 0; --i) 1229 for (i = bi->port_number - 1; i >= 0; --i)
1193 if (adapter->port[i].dev) { 1230 if (adapter->port[i].dev)
1194 cxgb_proc_cleanup(adapter, proc_root_driver); 1231 free_netdev(adapter->port[i].dev);
1195 kfree(adapter->port[i].dev);
1196 }
1197 } 1232 }
1198 pci_release_regions(pdev); 1233 pci_release_regions(pdev);
1199 out_disable_pdev: 1234 out_disable_pdev:
@@ -1202,6 +1237,155 @@ static int __devinit init_one(struct pci_dev *pdev,
1202 return err; 1237 return err;
1203} 1238}
1204 1239
1240static void bit_bang(struct adapter *adapter, int bitdata, int nbits)
1241{
1242 int data;
1243 int i;
1244 u32 val;
1245
1246 enum {
1247 S_CLOCK = 1 << 3,
1248 S_DATA = 1 << 4
1249 };
1250
1251 for (i = (nbits - 1); i > -1; i--) {
1252
1253 udelay(50);
1254
1255 data = ((bitdata >> i) & 0x1);
1256 __t1_tpi_read(adapter, A_ELMER0_GPO, &val);
1257
1258 if (data)
1259 val |= S_DATA;
1260 else
1261 val &= ~S_DATA;
1262
1263 udelay(50);
1264
1265 /* Set SCLOCK low */
1266 val &= ~S_CLOCK;
1267 __t1_tpi_write(adapter, A_ELMER0_GPO, val);
1268
1269 udelay(50);
1270
1271 /* Write SCLOCK high */
1272 val |= S_CLOCK;
1273 __t1_tpi_write(adapter, A_ELMER0_GPO, val);
1274
1275 }
1276}
1277
1278static int t1_clock(struct adapter *adapter, int mode)
1279{
1280 u32 val;
1281 int M_CORE_VAL;
1282 int M_MEM_VAL;
1283
1284 enum {
1285 M_CORE_BITS = 9,
1286 T_CORE_VAL = 0,
1287 T_CORE_BITS = 2,
1288 N_CORE_VAL = 0,
1289 N_CORE_BITS = 2,
1290 M_MEM_BITS = 9,
1291 T_MEM_VAL = 0,
1292 T_MEM_BITS = 2,
1293 N_MEM_VAL = 0,
1294 N_MEM_BITS = 2,
1295 NP_LOAD = 1 << 17,
1296 S_LOAD_MEM = 1 << 5,
1297 S_LOAD_CORE = 1 << 6,
1298 S_CLOCK = 1 << 3
1299 };
1300
1301 if (!t1_is_T1B(adapter))
1302 return -ENODEV; /* Can't re-clock this chip. */
1303
1304 if (mode & 2) {
1305 return 0; /* show current mode. */
1306 }
1307
1308 if ((adapter->t1powersave & 1) == (mode & 1))
1309 return -EALREADY; /* ASIC already running in mode. */
1310
1311 if ((mode & 1) == HCLOCK) {
1312 M_CORE_VAL = 0x14;
1313 M_MEM_VAL = 0x18;
1314 adapter->t1powersave = HCLOCK; /* overclock */
1315 } else {
1316 M_CORE_VAL = 0xe;
1317 M_MEM_VAL = 0x10;
1318 adapter->t1powersave = LCLOCK; /* underclock */
1319 }
1320
1321 /* Don't interrupt this serial stream! */
1322 spin_lock(&adapter->tpi_lock);
1323
1324 /* Initialize for ASIC core */
1325 __t1_tpi_read(adapter, A_ELMER0_GPO, &val);
1326 val |= NP_LOAD;
1327 udelay(50);
1328 __t1_tpi_write(adapter, A_ELMER0_GPO, val);
1329 udelay(50);
1330 __t1_tpi_read(adapter, A_ELMER0_GPO, &val);
1331 val &= ~S_LOAD_CORE;
1332 val &= ~S_CLOCK;
1333 __t1_tpi_write(adapter, A_ELMER0_GPO, val);
1334 udelay(50);
1335
1336 /* Serial program the ASIC clock synthesizer */
1337 bit_bang(adapter, T_CORE_VAL, T_CORE_BITS);
1338 bit_bang(adapter, N_CORE_VAL, N_CORE_BITS);
1339 bit_bang(adapter, M_CORE_VAL, M_CORE_BITS);
1340 udelay(50);
1341
1342 /* Finish ASIC core */
1343 __t1_tpi_read(adapter, A_ELMER0_GPO, &val);
1344 val |= S_LOAD_CORE;
1345 udelay(50);
1346 __t1_tpi_write(adapter, A_ELMER0_GPO, val);
1347 udelay(50);
1348 __t1_tpi_read(adapter, A_ELMER0_GPO, &val);
1349 val &= ~S_LOAD_CORE;
1350 udelay(50);
1351 __t1_tpi_write(adapter, A_ELMER0_GPO, val);
1352 udelay(50);
1353
1354 /* Initialize for memory */
1355 __t1_tpi_read(adapter, A_ELMER0_GPO, &val);
1356 val |= NP_LOAD;
1357 udelay(50);
1358 __t1_tpi_write(adapter, A_ELMER0_GPO, val);
1359 udelay(50);
1360 __t1_tpi_read(adapter, A_ELMER0_GPO, &val);
1361 val &= ~S_LOAD_MEM;
1362 val &= ~S_CLOCK;
1363 udelay(50);
1364 __t1_tpi_write(adapter, A_ELMER0_GPO, val);
1365 udelay(50);
1366
1367 /* Serial program the memory clock synthesizer */
1368 bit_bang(adapter, T_MEM_VAL, T_MEM_BITS);
1369 bit_bang(adapter, N_MEM_VAL, N_MEM_BITS);
1370 bit_bang(adapter, M_MEM_VAL, M_MEM_BITS);
1371 udelay(50);
1372
1373 /* Finish memory */
1374 __t1_tpi_read(adapter, A_ELMER0_GPO, &val);
1375 val |= S_LOAD_MEM;
1376 udelay(50);
1377 __t1_tpi_write(adapter, A_ELMER0_GPO, val);
1378 udelay(50);
1379 __t1_tpi_read(adapter, A_ELMER0_GPO, &val);
1380 val &= ~S_LOAD_MEM;
1381 udelay(50);
1382 __t1_tpi_write(adapter, A_ELMER0_GPO, val);
1383
1384 spin_unlock(&adapter->tpi_lock);
1385
1386 return 0;
1387}
1388
1205static inline void t1_sw_reset(struct pci_dev *pdev) 1389static inline void t1_sw_reset(struct pci_dev *pdev)
1206{ 1390{
1207 pci_write_config_dword(pdev, A_PCICFG_PM_CSR, 3); 1391 pci_write_config_dword(pdev, A_PCICFG_PM_CSR, 3);
@@ -1223,10 +1407,9 @@ static void __devexit remove_one(struct pci_dev *pdev)
1223 t1_free_sw_modules(adapter); 1407 t1_free_sw_modules(adapter);
1224 iounmap(adapter->regs); 1408 iounmap(adapter->regs);
1225 while (--i >= 0) 1409 while (--i >= 0)
1226 if (adapter->port[i].dev) { 1410 if (adapter->port[i].dev)
1227 cxgb_proc_cleanup(adapter, proc_root_driver); 1411 free_netdev(adapter->port[i].dev);
1228 kfree(adapter->port[i].dev); 1412
1229 }
1230 pci_release_regions(pdev); 1413 pci_release_regions(pdev);
1231 pci_disable_device(pdev); 1414 pci_disable_device(pdev);
1232 pci_set_drvdata(pdev, NULL); 1415 pci_set_drvdata(pdev, NULL);
diff --git a/drivers/net/chelsio/elmer0.h b/drivers/net/chelsio/elmer0.h
index 5590cb2dac19..9ebecaa97d31 100644
--- a/drivers/net/chelsio/elmer0.h
+++ b/drivers/net/chelsio/elmer0.h
@@ -39,6 +39,12 @@
39#ifndef _CXGB_ELMER0_H_ 39#ifndef _CXGB_ELMER0_H_
40#define _CXGB_ELMER0_H_ 40#define _CXGB_ELMER0_H_
41 41
42/* ELMER0 flavors */
43enum {
44 ELMER0_XC2S300E_6FT256_C,
45 ELMER0_XC2S100E_6TQ144_C
46};
47
42/* ELMER0 registers */ 48/* ELMER0 registers */
43#define A_ELMER0_VERSION 0x100000 49#define A_ELMER0_VERSION 0x100000
44#define A_ELMER0_PHY_CFG 0x100004 50#define A_ELMER0_PHY_CFG 0x100004
@@ -149,3 +155,4 @@
149#define MI1_OP_INDIRECT_READ 3 155#define MI1_OP_INDIRECT_READ 3
150 156
151#endif /* _CXGB_ELMER0_H_ */ 157#endif /* _CXGB_ELMER0_H_ */
158
diff --git a/drivers/net/chelsio/espi.c b/drivers/net/chelsio/espi.c
index 542e5e065c6f..4192f0f5b3ee 100644
--- a/drivers/net/chelsio/espi.c
+++ b/drivers/net/chelsio/espi.c
@@ -81,46 +81,36 @@ static int tricn_write(adapter_t *adapter, int bundle_addr, int module_addr,
81 return busy; 81 return busy;
82} 82}
83 83
84/* 1. Deassert rx_reset_core. */
85/* 2. Program TRICN_CNFG registers. */
86/* 3. Deassert rx_reset_link */
87static int tricn_init(adapter_t *adapter) 84static int tricn_init(adapter_t *adapter)
88{ 85{
89 int i = 0; 86 int i, sme = 1;
90 int stat = 0;
91 int timeout = 0;
92 int is_ready = 0;
93 87
94 /* 1 */ 88 if (!(readl(adapter->regs + A_ESPI_RX_RESET) & F_RX_CLK_STATUS)) {
95 timeout=1000; 89 CH_ERR("%s: ESPI clock not ready\n", adapter->name);
96 do { 90 return -1;
97 stat = readl(adapter->regs + A_ESPI_RX_RESET);
98 is_ready = (stat & 0x4);
99 timeout--;
100 udelay(5);
101 } while (!is_ready || (timeout==0));
102 writel(0x2, adapter->regs + A_ESPI_RX_RESET);
103 if (timeout==0)
104 {
105 CH_ERR("ESPI : ERROR : Timeout tricn_init() \n");
106 t1_fatal_err(adapter);
107 } 91 }
108 92
109 /* 2 */ 93 writel(F_ESPI_RX_CORE_RST, adapter->regs + A_ESPI_RX_RESET);
110 tricn_write(adapter, 0, 0, 0, TRICN_CNFG, 0x81); 94
111 tricn_write(adapter, 0, 1, 0, TRICN_CNFG, 0x81); 95 if (sme) {
112 tricn_write(adapter, 0, 2, 0, TRICN_CNFG, 0x81); 96 tricn_write(adapter, 0, 0, 0, TRICN_CNFG, 0x81);
113 for (i=1; i<= 8; i++) tricn_write(adapter, 0, 0, i, TRICN_CNFG, 0xf1); 97 tricn_write(adapter, 0, 1, 0, TRICN_CNFG, 0x81);
114 for (i=1; i<= 2; i++) tricn_write(adapter, 0, 1, i, TRICN_CNFG, 0xf1); 98 tricn_write(adapter, 0, 2, 0, TRICN_CNFG, 0x81);
115 for (i=1; i<= 3; i++) tricn_write(adapter, 0, 2, i, TRICN_CNFG, 0xe1); 99 }
116 for (i=4; i<= 4; i++) tricn_write(adapter, 0, 2, i, TRICN_CNFG, 0xf1); 100 for (i = 1; i <= 8; i++)
117 for (i=5; i<= 5; i++) tricn_write(adapter, 0, 2, i, TRICN_CNFG, 0xe1); 101 tricn_write(adapter, 0, 0, i, TRICN_CNFG, 0xf1);
118 for (i=6; i<= 6; i++) tricn_write(adapter, 0, 2, i, TRICN_CNFG, 0xf1); 102 for (i = 1; i <= 2; i++)
119 for (i=7; i<= 7; i++) tricn_write(adapter, 0, 2, i, TRICN_CNFG, 0x80); 103 tricn_write(adapter, 0, 1, i, TRICN_CNFG, 0xf1);
120 for (i=8; i<= 8; i++) tricn_write(adapter, 0, 2, i, TRICN_CNFG, 0xf1); 104 for (i = 1; i <= 3; i++)
121 105 tricn_write(adapter, 0, 2, i, TRICN_CNFG, 0xe1);
122 /* 3 */ 106 tricn_write(adapter, 0, 2, 4, TRICN_CNFG, 0xf1);
123 writel(0x3, adapter->regs + A_ESPI_RX_RESET); 107 tricn_write(adapter, 0, 2, 5, TRICN_CNFG, 0xe1);
108 tricn_write(adapter, 0, 2, 6, TRICN_CNFG, 0xf1);
109 tricn_write(adapter, 0, 2, 7, TRICN_CNFG, 0x80);
110 tricn_write(adapter, 0, 2, 8, TRICN_CNFG, 0xf1);
111
112 writel(F_ESPI_RX_CORE_RST | F_ESPI_RX_LNK_RST,
113 adapter->regs + A_ESPI_RX_RESET);
124 114
125 return 0; 115 return 0;
126} 116}
@@ -143,6 +133,7 @@ void t1_espi_intr_enable(struct peespi *espi)
143 133
144void t1_espi_intr_clear(struct peespi *espi) 134void t1_espi_intr_clear(struct peespi *espi)
145{ 135{
136 readl(espi->adapter->regs + A_ESPI_DIP2_ERR_COUNT);
146 writel(0xffffffff, espi->adapter->regs + A_ESPI_INTR_STATUS); 137 writel(0xffffffff, espi->adapter->regs + A_ESPI_INTR_STATUS);
147 writel(F_PL_INTR_ESPI, espi->adapter->regs + A_PL_CAUSE); 138 writel(F_PL_INTR_ESPI, espi->adapter->regs + A_PL_CAUSE);
148} 139}
@@ -157,7 +148,6 @@ void t1_espi_intr_disable(struct peespi *espi)
157 148
158int t1_espi_intr_handler(struct peespi *espi) 149int t1_espi_intr_handler(struct peespi *espi)
159{ 150{
160 u32 cnt;
161 u32 status = readl(espi->adapter->regs + A_ESPI_INTR_STATUS); 151 u32 status = readl(espi->adapter->regs + A_ESPI_INTR_STATUS);
162 152
163 if (status & F_DIP4ERR) 153 if (status & F_DIP4ERR)
@@ -177,7 +167,7 @@ int t1_espi_intr_handler(struct peespi *espi)
177 * Must read the error count to clear the interrupt 167 * Must read the error count to clear the interrupt
178 * that it causes. 168 * that it causes.
179 */ 169 */
180 cnt = readl(espi->adapter->regs + A_ESPI_DIP2_ERR_COUNT); 170 readl(espi->adapter->regs + A_ESPI_DIP2_ERR_COUNT);
181 } 171 }
182 172
183 /* 173 /*
@@ -192,7 +182,7 @@ int t1_espi_intr_handler(struct peespi *espi)
192 182
193const struct espi_intr_counts *t1_espi_get_intr_counts(struct peespi *espi) 183const struct espi_intr_counts *t1_espi_get_intr_counts(struct peespi *espi)
194{ 184{
195 return &espi->intr_cnt; 185 return &espi->intr_cnt;
196} 186}
197 187
198static void espi_setup_for_pm3393(adapter_t *adapter) 188static void espi_setup_for_pm3393(adapter_t *adapter)
@@ -210,17 +200,45 @@ static void espi_setup_for_pm3393(adapter_t *adapter)
210 writel(V_RX_NPORTS(1) | V_TX_NPORTS(1), adapter->regs + A_PORT_CONFIG); 200 writel(V_RX_NPORTS(1) | V_TX_NPORTS(1), adapter->regs + A_PORT_CONFIG);
211} 201}
212 202
213/* T2 Init part -- */ 203static void espi_setup_for_vsc7321(adapter_t *adapter)
214/* 1. Set T_ESPI_MISCCTRL_ADDR */ 204{
215/* 2. Init ESPI registers. */ 205 writel(0x1f4, adapter->regs + A_ESPI_SCH_TOKEN0);
216/* 3. Init TriCN Hard Macro */ 206 writel(0x1f401f4, adapter->regs + A_ESPI_SCH_TOKEN1);
217int t1_espi_init(struct peespi *espi, int mac_type, int nports) 207 writel(0x1f4, adapter->regs + A_ESPI_SCH_TOKEN2);
208 writel(0xa00, adapter->regs + A_ESPI_RX_FIFO_ALMOST_FULL_WATERMARK);
209 writel(0x1ff, adapter->regs + A_ESPI_RX_FIFO_ALMOST_EMPTY_WATERMARK);
210 writel(1, adapter->regs + A_ESPI_CALENDAR_LENGTH);
211 writel(V_RX_NPORTS(4) | V_TX_NPORTS(4), adapter->regs + A_PORT_CONFIG);
212
213 writel(0x08000008, adapter->regs + A_ESPI_TRAIN);
214}
215
216/*
217 * Note that T1B requires at least 2 ports for IXF1010 due to a HW bug.
218 */
219static void espi_setup_for_ixf1010(adapter_t *adapter, int nports)
218{ 220{
219 u32 cnt; 221 writel(1, adapter->regs + A_ESPI_CALENDAR_LENGTH);
222 if (nports == 4) {
223 if (is_T2(adapter)) {
224 writel(0xf00, adapter->regs + A_ESPI_RX_FIFO_ALMOST_FULL_WATERMARK);
225 writel(0x3c0, adapter->regs + A_ESPI_RX_FIFO_ALMOST_EMPTY_WATERMARK);
226 } else {
227 writel(0x7ff, adapter->regs + A_ESPI_RX_FIFO_ALMOST_FULL_WATERMARK);
228 writel(0x1ff, adapter->regs + A_ESPI_RX_FIFO_ALMOST_EMPTY_WATERMARK);
229 }
230 } else {
231 writel(0x1fff, adapter->regs + A_ESPI_RX_FIFO_ALMOST_FULL_WATERMARK);
232 writel(0x7ff, adapter->regs + A_ESPI_RX_FIFO_ALMOST_EMPTY_WATERMARK);
233 }
234 writel(V_RX_NPORTS(nports) | V_TX_NPORTS(nports), adapter->regs + A_PORT_CONFIG);
220 235
236}
237
238int t1_espi_init(struct peespi *espi, int mac_type, int nports)
239{
221 u32 status_enable_extra = 0; 240 u32 status_enable_extra = 0;
222 adapter_t *adapter = espi->adapter; 241 adapter_t *adapter = espi->adapter;
223 u32 status, burstval = 0x800100;
224 242
225 /* Disable ESPI training. MACs that can handle it enable it below. */ 243 /* Disable ESPI training. MACs that can handle it enable it below. */
226 writel(0, adapter->regs + A_ESPI_TRAIN); 244 writel(0, adapter->regs + A_ESPI_TRAIN);
@@ -229,38 +247,20 @@ int t1_espi_init(struct peespi *espi, int mac_type, int nports)
229 writel(V_OUT_OF_SYNC_COUNT(4) | 247 writel(V_OUT_OF_SYNC_COUNT(4) |
230 V_DIP2_PARITY_ERR_THRES(3) | 248 V_DIP2_PARITY_ERR_THRES(3) |
231 V_DIP4_THRES(1), adapter->regs + A_ESPI_MISC_CONTROL); 249 V_DIP4_THRES(1), adapter->regs + A_ESPI_MISC_CONTROL);
232 if (nports == 4) { 250 writel(nports == 4 ? 0x200040 : 0x1000080,
233 /* T204: maxburst1 = 0x40, maxburst2 = 0x20 */ 251 adapter->regs + A_ESPI_MAXBURST1_MAXBURST2);
234 burstval = 0x200040; 252 } else
235 } 253 writel(0x800100, adapter->regs + A_ESPI_MAXBURST1_MAXBURST2);
236 }
237 writel(burstval, adapter->regs + A_ESPI_MAXBURST1_MAXBURST2);
238 254
239 switch (mac_type) { 255 if (mac_type == CHBT_MAC_PM3393)
240 case CHBT_MAC_PM3393:
241 espi_setup_for_pm3393(adapter); 256 espi_setup_for_pm3393(adapter);
242 break; 257 else if (mac_type == CHBT_MAC_VSC7321)
243 default: 258 espi_setup_for_vsc7321(adapter);
259 else if (mac_type == CHBT_MAC_IXF1010) {
260 status_enable_extra = F_INTEL1010MODE;
261 espi_setup_for_ixf1010(adapter, nports);
262 } else
244 return -1; 263 return -1;
245 }
246
247 /*
248 * Make sure any pending interrupts from the SPI are
249 * Cleared before enabling the interrupt.
250 */
251 writel(ESPI_INTR_MASK, espi->adapter->regs + A_ESPI_INTR_ENABLE);
252 status = readl(espi->adapter->regs + A_ESPI_INTR_STATUS);
253 if (status & F_DIP2PARITYERR) {
254 cnt = readl(espi->adapter->regs + A_ESPI_DIP2_ERR_COUNT);
255 }
256
257 /*
258 * For T1B we need to write 1 to clear ESPI interrupts. For T2+ we
259 * write the status as is.
260 */
261 if (status && t1_is_T1B(espi->adapter))
262 status = 1;
263 writel(status, espi->adapter->regs + A_ESPI_INTR_STATUS);
264 264
265 writel(status_enable_extra | F_RXSTATUSENABLE, 265 writel(status_enable_extra | F_RXSTATUSENABLE,
266 adapter->regs + A_ESPI_FIFO_STATUS_ENABLE); 266 adapter->regs + A_ESPI_FIFO_STATUS_ENABLE);
@@ -271,9 +271,11 @@ int t1_espi_init(struct peespi *espi, int mac_type, int nports)
271 * Always position the control at the 1st port egress IN 271 * Always position the control at the 1st port egress IN
272 * (sop,eop) counter to reduce PIOs for T/N210 workaround. 272 * (sop,eop) counter to reduce PIOs for T/N210 workaround.
273 */ 273 */
274 espi->misc_ctrl = (readl(adapter->regs + A_ESPI_MISC_CONTROL) 274 espi->misc_ctrl = readl(adapter->regs + A_ESPI_MISC_CONTROL);
275 & ~MON_MASK) | (F_MONITORED_DIRECTION 275 espi->misc_ctrl &= ~MON_MASK;
276 | F_MONITORED_INTERFACE); 276 espi->misc_ctrl |= F_MONITORED_DIRECTION;
277 if (adapter->params.nports == 1)
278 espi->misc_ctrl |= F_MONITORED_INTERFACE;
277 writel(espi->misc_ctrl, adapter->regs + A_ESPI_MISC_CONTROL); 279 writel(espi->misc_ctrl, adapter->regs + A_ESPI_MISC_CONTROL);
278 spin_lock_init(&espi->lock); 280 spin_lock_init(&espi->lock);
279 } 281 }
@@ -299,8 +301,7 @@ void t1_espi_set_misc_ctrl(adapter_t *adapter, u32 val)
299{ 301{
300 struct peespi *espi = adapter->espi; 302 struct peespi *espi = adapter->espi;
301 303
302 if (!is_T2(adapter)) 304 if (!is_T2(adapter)) return;
303 return;
304 spin_lock(&espi->lock); 305 spin_lock(&espi->lock);
305 espi->misc_ctrl = (val & ~MON_MASK) | 306 espi->misc_ctrl = (val & ~MON_MASK) |
306 (espi->misc_ctrl & MON_MASK); 307 (espi->misc_ctrl & MON_MASK);
@@ -310,27 +311,61 @@ void t1_espi_set_misc_ctrl(adapter_t *adapter, u32 val)
310 311
311u32 t1_espi_get_mon(adapter_t *adapter, u32 addr, u8 wait) 312u32 t1_espi_get_mon(adapter_t *adapter, u32 addr, u8 wait)
312{ 313{
313 u32 sel;
314
315 struct peespi *espi = adapter->espi; 314 struct peespi *espi = adapter->espi;
315 u32 sel;
316 316
317 if (!is_T2(adapter)) 317 if (!is_T2(adapter))
318 return 0; 318 return 0;
319
319 sel = V_MONITORED_PORT_NUM((addr & 0x3c) >> 2); 320 sel = V_MONITORED_PORT_NUM((addr & 0x3c) >> 2);
320 if (!wait) { 321 if (!wait) {
321 if (!spin_trylock(&espi->lock)) 322 if (!spin_trylock(&espi->lock))
322 return 0; 323 return 0;
323 } 324 } else
324 else
325 spin_lock(&espi->lock); 325 spin_lock(&espi->lock);
326
326 if ((sel != (espi->misc_ctrl & MON_MASK))) { 327 if ((sel != (espi->misc_ctrl & MON_MASK))) {
327 writel(((espi->misc_ctrl & ~MON_MASK) | sel), 328 writel(((espi->misc_ctrl & ~MON_MASK) | sel),
328 adapter->regs + A_ESPI_MISC_CONTROL); 329 adapter->regs + A_ESPI_MISC_CONTROL);
329 sel = readl(adapter->regs + A_ESPI_SCH_TOKEN3); 330 sel = readl(adapter->regs + A_ESPI_SCH_TOKEN3);
330 writel(espi->misc_ctrl, adapter->regs + A_ESPI_MISC_CONTROL); 331 writel(espi->misc_ctrl, adapter->regs + A_ESPI_MISC_CONTROL);
331 } 332 } else
332 else
333 sel = readl(adapter->regs + A_ESPI_SCH_TOKEN3); 333 sel = readl(adapter->regs + A_ESPI_SCH_TOKEN3);
334 spin_unlock(&espi->lock); 334 spin_unlock(&espi->lock);
335 return sel; 335 return sel;
336} 336}
337
338/*
339 * This function is for T204 only.
340 * compare with t1_espi_get_mon(), it reads espiInTxSop[0 ~ 3] in
341 * one shot, since there is no per port counter on the out side.
342 */
343int
344t1_espi_get_mon_t204(adapter_t *adapter, u32 *valp, u8 wait)
345{
346 struct peespi *espi = adapter->espi;
347 u8 i, nport = (u8)adapter->params.nports;
348
349 if (!wait) {
350 if (!spin_trylock(&espi->lock))
351 return -1;
352 } else
353 spin_lock(&espi->lock);
354
355 if ( (espi->misc_ctrl & MON_MASK) != F_MONITORED_DIRECTION ) {
356 espi->misc_ctrl = (espi->misc_ctrl & ~MON_MASK) |
357 F_MONITORED_DIRECTION;
358 writel(espi->misc_ctrl, adapter->regs + A_ESPI_MISC_CONTROL);
359 }
360 for (i = 0 ; i < nport; i++, valp++) {
361 if (i) {
362 writel(espi->misc_ctrl | V_MONITORED_PORT_NUM(i),
363 adapter->regs + A_ESPI_MISC_CONTROL);
364 }
365 *valp = readl(adapter->regs + A_ESPI_SCH_TOKEN3);
366 }
367
368 writel(espi->misc_ctrl, adapter->regs + A_ESPI_MISC_CONTROL);
369 spin_unlock(&espi->lock);
370 return 0;
371}
diff --git a/drivers/net/chelsio/espi.h b/drivers/net/chelsio/espi.h
index c90e37f8457c..84f2c98bc4cc 100644
--- a/drivers/net/chelsio/espi.h
+++ b/drivers/net/chelsio/espi.h
@@ -64,5 +64,6 @@ const struct espi_intr_counts *t1_espi_get_intr_counts(struct peespi *espi);
64 64
65void t1_espi_set_misc_ctrl(adapter_t *adapter, u32 val); 65void t1_espi_set_misc_ctrl(adapter_t *adapter, u32 val);
66u32 t1_espi_get_mon(adapter_t *adapter, u32 addr, u8 wait); 66u32 t1_espi_get_mon(adapter_t *adapter, u32 addr, u8 wait);
67int t1_espi_get_mon_t204(adapter_t *, u32 *, u8);
67 68
68#endif /* _CXGB_ESPI_H_ */ 69#endif /* _CXGB_ESPI_H_ */
diff --git a/drivers/net/chelsio/fpga_defs.h b/drivers/net/chelsio/fpga_defs.h
new file mode 100644
index 000000000000..17a3c2ba36a3
--- /dev/null
+++ b/drivers/net/chelsio/fpga_defs.h
@@ -0,0 +1,232 @@
1/* $Date: 2005/03/07 23:59:05 $ $RCSfile: fpga_defs.h,v $ $Revision: 1.4 $ */
2
3/*
4 * FPGA specific definitions
5 */
6
7#ifndef __CHELSIO_FPGA_DEFS_H__
8#define __CHELSIO_FPGA_DEFS_H__
9
10#define FPGA_PCIX_ADDR_VERSION 0xA08
11#define FPGA_PCIX_ADDR_STAT 0xA0C
12
13/* FPGA master interrupt Cause/Enable bits */
14#define FPGA_PCIX_INTERRUPT_SGE_ERROR 0x1
15#define FPGA_PCIX_INTERRUPT_SGE_DATA 0x2
16#define FPGA_PCIX_INTERRUPT_TP 0x4
17#define FPGA_PCIX_INTERRUPT_MC3 0x8
18#define FPGA_PCIX_INTERRUPT_GMAC 0x10
19#define FPGA_PCIX_INTERRUPT_PCIX 0x20
20
21/* TP interrupt register addresses */
22#define FPGA_TP_ADDR_INTERRUPT_ENABLE 0xA10
23#define FPGA_TP_ADDR_INTERRUPT_CAUSE 0xA14
24#define FPGA_TP_ADDR_VERSION 0xA18
25
26/* TP interrupt Cause/Enable bits */
27#define FPGA_TP_INTERRUPT_MC4 0x1
28#define FPGA_TP_INTERRUPT_MC5 0x2
29
30/*
31 * PM interrupt register addresses
32 */
33#define FPGA_MC3_REG_INTRENABLE 0xA20
34#define FPGA_MC3_REG_INTRCAUSE 0xA24
35#define FPGA_MC3_REG_VERSION 0xA28
36
37/*
38 * GMAC interrupt register addresses
39 */
40#define FPGA_GMAC_ADDR_INTERRUPT_ENABLE 0xA30
41#define FPGA_GMAC_ADDR_INTERRUPT_CAUSE 0xA34
42#define FPGA_GMAC_ADDR_VERSION 0xA38
43
44/* GMAC Cause/Enable bits */
45#define FPGA_GMAC_INTERRUPT_PORT0 0x1
46#define FPGA_GMAC_INTERRUPT_PORT1 0x2
47#define FPGA_GMAC_INTERRUPT_PORT2 0x4
48#define FPGA_GMAC_INTERRUPT_PORT3 0x8
49
50/* MI0 registers */
51#define A_MI0_CLK 0xb00
52
53#define S_MI0_CLK_DIV 0
54#define M_MI0_CLK_DIV 0xff
55#define V_MI0_CLK_DIV(x) ((x) << S_MI0_CLK_DIV)
56#define G_MI0_CLK_DIV(x) (((x) >> S_MI0_CLK_DIV) & M_MI0_CLK_DIV)
57
58#define S_MI0_CLK_CNT 8
59#define M_MI0_CLK_CNT 0xff
60#define V_MI0_CLK_CNT(x) ((x) << S_MI0_CLK_CNT)
61#define G_MI0_CLK_CNT(x) (((x) >> S_MI0_CLK_CNT) & M_MI0_CLK_CNT)
62
63#define A_MI0_CSR 0xb04
64
65#define S_MI0_CSR_POLL 0
66#define V_MI0_CSR_POLL(x) ((x) << S_MI0_CSR_POLL)
67#define F_MI0_CSR_POLL V_MI0_CSR_POLL(1U)
68
69#define S_MI0_PREAMBLE 1
70#define V_MI0_PREAMBLE(x) ((x) << S_MI0_PREAMBLE)
71#define F_MI0_PREAMBLE V_MI0_PREAMBLE(1U)
72
73#define S_MI0_INTR_ENABLE 2
74#define V_MI0_INTR_ENABLE(x) ((x) << S_MI0_INTR_ENABLE)
75#define F_MI0_INTR_ENABLE V_MI0_INTR_ENABLE(1U)
76
77#define S_MI0_BUSY 3
78#define V_MI0_BUSY(x) ((x) << S_MI0_BUSY)
79#define F_MI0_BUSY V_MI0_BUSY(1U)
80
81#define S_MI0_MDIO 4
82#define V_MI0_MDIO(x) ((x) << S_MI0_MDIO)
83#define F_MI0_MDIO V_MI0_MDIO(1U)
84
85#define A_MI0_ADDR 0xb08
86
87#define S_MI0_PHY_REG_ADDR 0
88#define M_MI0_PHY_REG_ADDR 0x1f
89#define V_MI0_PHY_REG_ADDR(x) ((x) << S_MI0_PHY_REG_ADDR)
90#define G_MI0_PHY_REG_ADDR(x) (((x) >> S_MI0_PHY_REG_ADDR) & M_MI0_PHY_REG_ADDR)
91
92#define S_MI0_PHY_ADDR 5
93#define M_MI0_PHY_ADDR 0x1f
94#define V_MI0_PHY_ADDR(x) ((x) << S_MI0_PHY_ADDR)
95#define G_MI0_PHY_ADDR(x) (((x) >> S_MI0_PHY_ADDR) & M_MI0_PHY_ADDR)
96
97#define A_MI0_DATA_EXT 0xb0c
98#define A_MI0_DATA_INT 0xb10
99
100/* GMAC registers */
101#define A_GMAC_MACID_LO 0x28
102#define A_GMAC_MACID_HI 0x2c
103#define A_GMAC_CSR 0x30
104
105#define S_INTERFACE 0
106#define M_INTERFACE 0x3
107#define V_INTERFACE(x) ((x) << S_INTERFACE)
108#define G_INTERFACE(x) (((x) >> S_INTERFACE) & M_INTERFACE)
109
110#define S_MAC_TX_ENABLE 2
111#define V_MAC_TX_ENABLE(x) ((x) << S_MAC_TX_ENABLE)
112#define F_MAC_TX_ENABLE V_MAC_TX_ENABLE(1U)
113
114#define S_MAC_RX_ENABLE 3
115#define V_MAC_RX_ENABLE(x) ((x) << S_MAC_RX_ENABLE)
116#define F_MAC_RX_ENABLE V_MAC_RX_ENABLE(1U)
117
118#define S_MAC_LB_ENABLE 4
119#define V_MAC_LB_ENABLE(x) ((x) << S_MAC_LB_ENABLE)
120#define F_MAC_LB_ENABLE V_MAC_LB_ENABLE(1U)
121
122#define S_MAC_SPEED 5
123#define M_MAC_SPEED 0x3
124#define V_MAC_SPEED(x) ((x) << S_MAC_SPEED)
125#define G_MAC_SPEED(x) (((x) >> S_MAC_SPEED) & M_MAC_SPEED)
126
127#define S_MAC_HD_FC_ENABLE 7
128#define V_MAC_HD_FC_ENABLE(x) ((x) << S_MAC_HD_FC_ENABLE)
129#define F_MAC_HD_FC_ENABLE V_MAC_HD_FC_ENABLE(1U)
130
131#define S_MAC_HALF_DUPLEX 8
132#define V_MAC_HALF_DUPLEX(x) ((x) << S_MAC_HALF_DUPLEX)
133#define F_MAC_HALF_DUPLEX V_MAC_HALF_DUPLEX(1U)
134
135#define S_MAC_PROMISC 9
136#define V_MAC_PROMISC(x) ((x) << S_MAC_PROMISC)
137#define F_MAC_PROMISC V_MAC_PROMISC(1U)
138
139#define S_MAC_MC_ENABLE 10
140#define V_MAC_MC_ENABLE(x) ((x) << S_MAC_MC_ENABLE)
141#define F_MAC_MC_ENABLE V_MAC_MC_ENABLE(1U)
142
143#define S_MAC_RESET 11
144#define V_MAC_RESET(x) ((x) << S_MAC_RESET)
145#define F_MAC_RESET V_MAC_RESET(1U)
146
147#define S_MAC_RX_PAUSE_ENABLE 12
148#define V_MAC_RX_PAUSE_ENABLE(x) ((x) << S_MAC_RX_PAUSE_ENABLE)
149#define F_MAC_RX_PAUSE_ENABLE V_MAC_RX_PAUSE_ENABLE(1U)
150
151#define S_MAC_TX_PAUSE_ENABLE 13
152#define V_MAC_TX_PAUSE_ENABLE(x) ((x) << S_MAC_TX_PAUSE_ENABLE)
153#define F_MAC_TX_PAUSE_ENABLE V_MAC_TX_PAUSE_ENABLE(1U)
154
155#define S_MAC_LWM_ENABLE 14
156#define V_MAC_LWM_ENABLE(x) ((x) << S_MAC_LWM_ENABLE)
157#define F_MAC_LWM_ENABLE V_MAC_LWM_ENABLE(1U)
158
159#define S_MAC_MAGIC_PKT_ENABLE 15
160#define V_MAC_MAGIC_PKT_ENABLE(x) ((x) << S_MAC_MAGIC_PKT_ENABLE)
161#define F_MAC_MAGIC_PKT_ENABLE V_MAC_MAGIC_PKT_ENABLE(1U)
162
163#define S_MAC_ISL_ENABLE 16
164#define V_MAC_ISL_ENABLE(x) ((x) << S_MAC_ISL_ENABLE)
165#define F_MAC_ISL_ENABLE V_MAC_ISL_ENABLE(1U)
166
167#define S_MAC_JUMBO_ENABLE 17
168#define V_MAC_JUMBO_ENABLE(x) ((x) << S_MAC_JUMBO_ENABLE)
169#define F_MAC_JUMBO_ENABLE V_MAC_JUMBO_ENABLE(1U)
170
171#define S_MAC_RX_PAD_ENABLE 18
172#define V_MAC_RX_PAD_ENABLE(x) ((x) << S_MAC_RX_PAD_ENABLE)
173#define F_MAC_RX_PAD_ENABLE V_MAC_RX_PAD_ENABLE(1U)
174
175#define S_MAC_RX_CRC_ENABLE 19
176#define V_MAC_RX_CRC_ENABLE(x) ((x) << S_MAC_RX_CRC_ENABLE)
177#define F_MAC_RX_CRC_ENABLE V_MAC_RX_CRC_ENABLE(1U)
178
179#define A_GMAC_IFS 0x34
180
181#define S_MAC_IFS2 0
182#define M_MAC_IFS2 0x3f
183#define V_MAC_IFS2(x) ((x) << S_MAC_IFS2)
184#define G_MAC_IFS2(x) (((x) >> S_MAC_IFS2) & M_MAC_IFS2)
185
186#define S_MAC_IFS1 8
187#define M_MAC_IFS1 0x7f
188#define V_MAC_IFS1(x) ((x) << S_MAC_IFS1)
189#define G_MAC_IFS1(x) (((x) >> S_MAC_IFS1) & M_MAC_IFS1)
190
191#define A_GMAC_JUMBO_FRAME_LEN 0x38
192#define A_GMAC_LNK_DLY 0x3c
193#define A_GMAC_PAUSETIME 0x40
194#define A_GMAC_MCAST_LO 0x44
195#define A_GMAC_MCAST_HI 0x48
196#define A_GMAC_MCAST_MASK_LO 0x4c
197#define A_GMAC_MCAST_MASK_HI 0x50
198#define A_GMAC_RMT_CNT 0x54
199#define A_GMAC_RMT_DATA 0x58
200#define A_GMAC_BACKOFF_SEED 0x5c
201#define A_GMAC_TXF_THRES 0x60
202
203#define S_TXF_READ_THRESHOLD 0
204#define M_TXF_READ_THRESHOLD 0xff
205#define V_TXF_READ_THRESHOLD(x) ((x) << S_TXF_READ_THRESHOLD)
206#define G_TXF_READ_THRESHOLD(x) (((x) >> S_TXF_READ_THRESHOLD) & M_TXF_READ_THRESHOLD)
207
208#define S_TXF_WRITE_THRESHOLD 16
209#define M_TXF_WRITE_THRESHOLD 0xff
210#define V_TXF_WRITE_THRESHOLD(x) ((x) << S_TXF_WRITE_THRESHOLD)
211#define G_TXF_WRITE_THRESHOLD(x) (((x) >> S_TXF_WRITE_THRESHOLD) & M_TXF_WRITE_THRESHOLD)
212
213#define MAC_REG_BASE 0x600
214#define MAC_REG_ADDR(idx, reg) (MAC_REG_BASE + (idx) * 128 + (reg))
215
216#define MAC_REG_IDLO(idx) MAC_REG_ADDR(idx, A_GMAC_MACID_LO)
217#define MAC_REG_IDHI(idx) MAC_REG_ADDR(idx, A_GMAC_MACID_HI)
218#define MAC_REG_CSR(idx) MAC_REG_ADDR(idx, A_GMAC_CSR)
219#define MAC_REG_IFS(idx) MAC_REG_ADDR(idx, A_GMAC_IFS)
220#define MAC_REG_LARGEFRAMELENGTH(idx) MAC_REG_ADDR(idx, A_GMAC_JUMBO_FRAME_LEN)
221#define MAC_REG_LINKDLY(idx) MAC_REG_ADDR(idx, A_GMAC_LNK_DLY)
222#define MAC_REG_PAUSETIME(idx) MAC_REG_ADDR(idx, A_GMAC_PAUSETIME)
223#define MAC_REG_CASTLO(idx) MAC_REG_ADDR(idx, A_GMAC_MCAST_LO)
224#define MAC_REG_MCASTHI(idx) MAC_REG_ADDR(idx, A_GMAC_MCAST_HI)
225#define MAC_REG_CASTMASKLO(idx) MAC_REG_ADDR(idx, A_GMAC_MCAST_MASK_LO)
226#define MAC_REG_MCASTMASKHI(idx) MAC_REG_ADDR(idx, A_GMAC_MCAST_MASK_HI)
227#define MAC_REG_RMCNT(idx) MAC_REG_ADDR(idx, A_GMAC_RMT_CNT)
228#define MAC_REG_RMDATA(idx) MAC_REG_ADDR(idx, A_GMAC_RMT_DATA)
229#define MAC_REG_GMRANDBACKOFFSEED(idx) MAC_REG_ADDR(idx, A_GMAC_BACKOFF_SEED)
230#define MAC_REG_TXFTHRESHOLDS(idx) MAC_REG_ADDR(idx, A_GMAC_TXF_THRES)
231
232#endif
diff --git a/drivers/net/chelsio/gmac.h b/drivers/net/chelsio/gmac.h
index 746b0eeea964..a2b8ad9b5535 100644
--- a/drivers/net/chelsio/gmac.h
+++ b/drivers/net/chelsio/gmac.h
@@ -62,6 +62,8 @@ struct cmac_statistics {
62 u64 TxInternalMACXmitError; 62 u64 TxInternalMACXmitError;
63 u64 TxFramesWithExcessiveDeferral; 63 u64 TxFramesWithExcessiveDeferral;
64 u64 TxFCSErrors; 64 u64 TxFCSErrors;
65 u64 TxJumboFramesOK;
66 u64 TxJumboOctetsOK;
65 67
66 /* Receive */ 68 /* Receive */
67 u64 RxOctetsOK; 69 u64 RxOctetsOK;
@@ -81,6 +83,8 @@ struct cmac_statistics {
81 u64 RxInRangeLengthErrors; 83 u64 RxInRangeLengthErrors;
82 u64 RxOutOfRangeLengthField; 84 u64 RxOutOfRangeLengthField;
83 u64 RxFrameTooLongErrors; 85 u64 RxFrameTooLongErrors;
86 u64 RxJumboFramesOK;
87 u64 RxJumboOctetsOK;
84}; 88};
85 89
86struct cmac_ops { 90struct cmac_ops {
@@ -128,6 +132,7 @@ struct gmac {
128extern struct gmac t1_pm3393_ops; 132extern struct gmac t1_pm3393_ops;
129extern struct gmac t1_chelsio_mac_ops; 133extern struct gmac t1_chelsio_mac_ops;
130extern struct gmac t1_vsc7321_ops; 134extern struct gmac t1_vsc7321_ops;
135extern struct gmac t1_vsc7326_ops;
131extern struct gmac t1_ixf1010_ops; 136extern struct gmac t1_ixf1010_ops;
132extern struct gmac t1_dummy_mac_ops; 137extern struct gmac t1_dummy_mac_ops;
133 138
diff --git a/drivers/net/chelsio/ixf1010.c b/drivers/net/chelsio/ixf1010.c
new file mode 100644
index 000000000000..5b8f144e83d4
--- /dev/null
+++ b/drivers/net/chelsio/ixf1010.c
@@ -0,0 +1,485 @@
1/* $Date: 2005/11/12 02:13:49 $ $RCSfile: ixf1010.c,v $ $Revision: 1.36 $ */
2#include "gmac.h"
3#include "elmer0.h"
4
5/* Update fast changing statistics every 15 seconds */
6#define STATS_TICK_SECS 15
7/* 30 minutes for full statistics update */
8#define MAJOR_UPDATE_TICKS (1800 / STATS_TICK_SECS)
9
10/*
11 * The IXF1010 can handle frames up to 16383 bytes but it's optimized for
12 * frames up to 9831 (0x2667) bytes, so we limit jumbo frame size to this.
13 * This length includes ethernet header and FCS.
14 */
15#define MAX_FRAME_SIZE 0x2667
16
17/* MAC registers */
18enum {
19 /* Per-port registers */
20 REG_MACADDR_LOW = 0,
21 REG_MACADDR_HIGH = 0x4,
22 REG_FDFC_TYPE = 0xC,
23 REG_FC_TX_TIMER_VALUE = 0x1c,
24 REG_IPG_RX_TIME1 = 0x28,
25 REG_IPG_RX_TIME2 = 0x2c,
26 REG_IPG_TX_TIME = 0x30,
27 REG_PAUSE_THRES = 0x38,
28 REG_MAX_FRAME_SIZE = 0x3c,
29 REG_RGMII_SPEED = 0x40,
30 REG_FC_ENABLE = 0x48,
31 REG_DISCARD_CTRL_FRAMES = 0x54,
32 REG_DIVERSE_CONFIG = 0x60,
33 REG_RX_FILTER = 0x64,
34 REG_MC_ADDR_LOW = 0x68,
35 REG_MC_ADDR_HIGH = 0x6c,
36
37 REG_RX_OCTETS_OK = 0x80,
38 REG_RX_OCTETS_BAD = 0x84,
39 REG_RX_UC_PKTS = 0x88,
40 REG_RX_MC_PKTS = 0x8c,
41 REG_RX_BC_PKTS = 0x90,
42 REG_RX_FCS_ERR = 0xb0,
43 REG_RX_TAGGED = 0xb4,
44 REG_RX_DATA_ERR = 0xb8,
45 REG_RX_ALIGN_ERR = 0xbc,
46 REG_RX_LONG_ERR = 0xc0,
47 REG_RX_JABBER_ERR = 0xc4,
48 REG_RX_PAUSE_FRAMES = 0xc8,
49 REG_RX_UNKNOWN_CTRL_FRAMES = 0xcc,
50 REG_RX_VERY_LONG_ERR = 0xd0,
51 REG_RX_RUNT_ERR = 0xd4,
52 REG_RX_SHORT_ERR = 0xd8,
53 REG_RX_SYMBOL_ERR = 0xe4,
54
55 REG_TX_OCTETS_OK = 0x100,
56 REG_TX_OCTETS_BAD = 0x104,
57 REG_TX_UC_PKTS = 0x108,
58 REG_TX_MC_PKTS = 0x10c,
59 REG_TX_BC_PKTS = 0x110,
60 REG_TX_EXCESSIVE_LEN_DROP = 0x14c,
61 REG_TX_UNDERRUN = 0x150,
62 REG_TX_TAGGED = 0x154,
63 REG_TX_PAUSE_FRAMES = 0x15C,
64
65 /* Global registers */
66 REG_PORT_ENABLE = 0x1400,
67
68 REG_JTAG_ID = 0x1430,
69
70 RX_FIFO_HIGH_WATERMARK_BASE = 0x1600,
71 RX_FIFO_LOW_WATERMARK_BASE = 0x1628,
72 RX_FIFO_FRAMES_REMOVED_BASE = 0x1650,
73
74 REG_RX_ERR_DROP = 0x167c,
75 REG_RX_FIFO_OVERFLOW_EVENT = 0x1680,
76
77 TX_FIFO_HIGH_WATERMARK_BASE = 0x1800,
78 TX_FIFO_LOW_WATERMARK_BASE = 0x1828,
79 TX_FIFO_XFER_THRES_BASE = 0x1850,
80
81 REG_TX_FIFO_OVERFLOW_EVENT = 0x1878,
82 REG_TX_FIFO_OOS_EVENT = 0x1884,
83
84 TX_FIFO_FRAMES_REMOVED_BASE = 0x1888,
85
86 REG_SPI_RX_BURST = 0x1c00,
87 REG_SPI_RX_TRAINING = 0x1c04,
88 REG_SPI_RX_CALENDAR = 0x1c08,
89 REG_SPI_TX_SYNC = 0x1c0c
90};
91
92enum { /* RMON registers */
93 REG_RxOctetsTotalOK = 0x80,
94 REG_RxOctetsBad = 0x84,
95 REG_RxUCPkts = 0x88,
96 REG_RxMCPkts = 0x8c,
97 REG_RxBCPkts = 0x90,
98 REG_RxJumboPkts = 0xac,
99 REG_RxFCSErrors = 0xb0,
100 REG_RxDataErrors = 0xb8,
101 REG_RxAlignErrors = 0xbc,
102 REG_RxLongErrors = 0xc0,
103 REG_RxJabberErrors = 0xc4,
104 REG_RxPauseMacControlCounter = 0xc8,
105 REG_RxVeryLongErrors = 0xd0,
106 REG_RxRuntErrors = 0xd4,
107 REG_RxShortErrors = 0xd8,
108 REG_RxSequenceErrors = 0xe0,
109 REG_RxSymbolErrors = 0xe4,
110
111 REG_TxOctetsTotalOK = 0x100,
112 REG_TxOctetsBad = 0x104,
113 REG_TxUCPkts = 0x108,
114 REG_TxMCPkts = 0x10c,
115 REG_TxBCPkts = 0x110,
116 REG_TxJumboPkts = 0x12C,
117 REG_TxTotalCollisions = 0x134,
118 REG_TxExcessiveLengthDrop = 0x14c,
119 REG_TxUnderrun = 0x150,
120 REG_TxCRCErrors = 0x158,
121 REG_TxPauseFrames = 0x15c
122};
123
124enum {
125 DIVERSE_CONFIG_PAD_ENABLE = 0x80,
126 DIVERSE_CONFIG_CRC_ADD = 0x40
127};
128
129#define MACREG_BASE 0
130#define MACREG(mac, mac_reg) ((mac)->instance->mac_base + (mac_reg))
131
132struct _cmac_instance {
133 u32 mac_base;
134 u32 index;
135 u32 version;
136 u32 ticks;
137};
138
139static void disable_port(struct cmac *mac)
140{
141 u32 val;
142
143 t1_tpi_read(mac->adapter, REG_PORT_ENABLE, &val);
144 val &= ~(1 << mac->instance->index);
145 t1_tpi_write(mac->adapter, REG_PORT_ENABLE, val);
146}
147
148#define RMON_UPDATE(mac, name, stat_name) \
149 t1_tpi_read((mac)->adapter, MACREG(mac, REG_##name), &val); \
150 (mac)->stats.stat_name += val;
151
152/*
153 * Read the current values of the RMON counters and add them to the cumulative
154 * port statistics. The HW RMON counters are cleared by this operation.
155 */
156static void port_stats_update(struct cmac *mac)
157{
158 u32 val;
159
160 /* Rx stats */
161 RMON_UPDATE(mac, RxOctetsTotalOK, RxOctetsOK);
162 RMON_UPDATE(mac, RxOctetsBad, RxOctetsBad);
163 RMON_UPDATE(mac, RxUCPkts, RxUnicastFramesOK);
164 RMON_UPDATE(mac, RxMCPkts, RxMulticastFramesOK);
165 RMON_UPDATE(mac, RxBCPkts, RxBroadcastFramesOK);
166 RMON_UPDATE(mac, RxJumboPkts, RxJumboFramesOK);
167 RMON_UPDATE(mac, RxFCSErrors, RxFCSErrors);
168 RMON_UPDATE(mac, RxAlignErrors, RxAlignErrors);
169 RMON_UPDATE(mac, RxLongErrors, RxFrameTooLongErrors);
170 RMON_UPDATE(mac, RxVeryLongErrors, RxFrameTooLongErrors);
171 RMON_UPDATE(mac, RxPauseMacControlCounter, RxPauseFrames);
172 RMON_UPDATE(mac, RxDataErrors, RxDataErrors);
173 RMON_UPDATE(mac, RxJabberErrors, RxJabberErrors);
174 RMON_UPDATE(mac, RxRuntErrors, RxRuntErrors);
175 RMON_UPDATE(mac, RxShortErrors, RxRuntErrors);
176 RMON_UPDATE(mac, RxSequenceErrors, RxSequenceErrors);
177 RMON_UPDATE(mac, RxSymbolErrors, RxSymbolErrors);
178
179 /* Tx stats (skip collision stats as we are full-duplex only) */
180 RMON_UPDATE(mac, TxOctetsTotalOK, TxOctetsOK);
181 RMON_UPDATE(mac, TxOctetsBad, TxOctetsBad);
182 RMON_UPDATE(mac, TxUCPkts, TxUnicastFramesOK);
183 RMON_UPDATE(mac, TxMCPkts, TxMulticastFramesOK);
184 RMON_UPDATE(mac, TxBCPkts, TxBroadcastFramesOK);
185 RMON_UPDATE(mac, TxJumboPkts, TxJumboFramesOK);
186 RMON_UPDATE(mac, TxPauseFrames, TxPauseFrames);
187 RMON_UPDATE(mac, TxExcessiveLengthDrop, TxLengthErrors);
188 RMON_UPDATE(mac, TxUnderrun, TxUnderrun);
189 RMON_UPDATE(mac, TxCRCErrors, TxFCSErrors);
190}
191
192/* No-op interrupt operation as this MAC does not support interrupts */
193static int mac_intr_op(struct cmac *mac)
194{
195 return 0;
196}
197
198/* Expect MAC address to be in network byte order. */
199static int mac_set_address(struct cmac *mac, u8 addr[6])
200{
201 u32 addr_lo, addr_hi;
202
203 addr_lo = addr[2];
204 addr_lo = (addr_lo << 8) | addr[3];
205 addr_lo = (addr_lo << 8) | addr[4];
206 addr_lo = (addr_lo << 8) | addr[5];
207
208 addr_hi = addr[0];
209 addr_hi = (addr_hi << 8) | addr[1];
210
211 t1_tpi_write(mac->adapter, MACREG(mac, REG_MACADDR_LOW), addr_lo);
212 t1_tpi_write(mac->adapter, MACREG(mac, REG_MACADDR_HIGH), addr_hi);
213 return 0;
214}
215
216static int mac_get_address(struct cmac *mac, u8 addr[6])
217{
218 u32 addr_lo, addr_hi;
219
220 t1_tpi_read(mac->adapter, MACREG(mac, REG_MACADDR_LOW), &addr_lo);
221 t1_tpi_read(mac->adapter, MACREG(mac, REG_MACADDR_HIGH), &addr_hi);
222
223 addr[0] = (u8) (addr_hi >> 8);
224 addr[1] = (u8) addr_hi;
225 addr[2] = (u8) (addr_lo >> 24);
226 addr[3] = (u8) (addr_lo >> 16);
227 addr[4] = (u8) (addr_lo >> 8);
228 addr[5] = (u8) addr_lo;
229 return 0;
230}
231
232/* This is intended to reset a port, not the whole MAC */
233static int mac_reset(struct cmac *mac)
234{
235 return 0;
236}
237
238static int mac_set_rx_mode(struct cmac *mac, struct t1_rx_mode *rm)
239{
240 u32 val, new_mode;
241 adapter_t *adapter = mac->adapter;
242 u32 addr_lo, addr_hi;
243 u8 *addr;
244
245 t1_tpi_read(adapter, MACREG(mac, REG_RX_FILTER), &val);
246 new_mode = val & ~7;
247 if (!t1_rx_mode_promisc(rm) && mac->instance->version > 0)
248 new_mode |= 1; /* only set if version > 0 due to erratum */
249 if (!t1_rx_mode_promisc(rm) && !t1_rx_mode_allmulti(rm)
250 && t1_rx_mode_mc_cnt(rm) <= 1)
251 new_mode |= 2;
252 if (new_mode != val)
253 t1_tpi_write(adapter, MACREG(mac, REG_RX_FILTER), new_mode);
254 switch (t1_rx_mode_mc_cnt(rm)) {
255 case 0:
256 t1_tpi_write(adapter, MACREG(mac, REG_MC_ADDR_LOW), 0);
257 t1_tpi_write(adapter, MACREG(mac, REG_MC_ADDR_HIGH), 0);
258 break;
259 case 1:
260 addr = t1_get_next_mcaddr(rm);
261 addr_lo = (addr[2] << 24) | (addr[3] << 16) | (addr[4] << 8) |
262 addr[5];
263 addr_hi = (addr[0] << 8) | addr[1];
264 t1_tpi_write(adapter, MACREG(mac, REG_MC_ADDR_LOW), addr_lo);
265 t1_tpi_write(adapter, MACREG(mac, REG_MC_ADDR_HIGH), addr_hi);
266 break;
267 default:
268 break;
269 }
270 return 0;
271}
272
273static int mac_set_mtu(struct cmac *mac, int mtu)
274{
275 /* MAX_FRAME_SIZE inludes header + FCS, mtu doesn't */
276 if (mtu > (MAX_FRAME_SIZE - 14 - 4)) return -EINVAL;
277 t1_tpi_write(mac->adapter, MACREG(mac, REG_MAX_FRAME_SIZE),
278 mtu + 14 + 4);
279 return 0;
280}
281
282static int mac_set_speed_duplex_fc(struct cmac *mac, int speed, int duplex,
283 int fc)
284{
285 u32 val;
286
287 if (speed >= 0 && speed != SPEED_100 && speed != SPEED_1000)
288 return -1;
289 if (duplex >= 0 && duplex != DUPLEX_FULL)
290 return -1;
291
292 if (speed >= 0) {
293 val = speed == SPEED_100 ? 1 : 2;
294 t1_tpi_write(mac->adapter, MACREG(mac, REG_RGMII_SPEED), val);
295 }
296
297 t1_tpi_read(mac->adapter, MACREG(mac, REG_FC_ENABLE), &val);
298 val &= ~3;
299 if (fc & PAUSE_RX)
300 val |= 1;
301 if (fc & PAUSE_TX)
302 val |= 2;
303 t1_tpi_write(mac->adapter, MACREG(mac, REG_FC_ENABLE), val);
304 return 0;
305}
306
307static int mac_get_speed_duplex_fc(struct cmac *mac, int *speed, int *duplex,
308 int *fc)
309{
310 u32 val;
311
312 if (duplex)
313 *duplex = DUPLEX_FULL;
314 if (speed) {
315 t1_tpi_read(mac->adapter, MACREG(mac, REG_RGMII_SPEED),
316 &val);
317 *speed = (val & 2) ? SPEED_1000 : SPEED_100;
318 }
319 if (fc) {
320 t1_tpi_read(mac->adapter, MACREG(mac, REG_FC_ENABLE), &val);
321 *fc = 0;
322 if (val & 1)
323 *fc |= PAUSE_RX;
324 if (val & 2)
325 *fc |= PAUSE_TX;
326 }
327 return 0;
328}
329
330static void enable_port(struct cmac *mac)
331{
332 u32 val;
333 u32 index = mac->instance->index;
334 adapter_t *adapter = mac->adapter;
335
336 t1_tpi_read(adapter, MACREG(mac, REG_DIVERSE_CONFIG), &val);
337 val |= DIVERSE_CONFIG_CRC_ADD | DIVERSE_CONFIG_PAD_ENABLE;
338 t1_tpi_write(adapter, MACREG(mac, REG_DIVERSE_CONFIG), val);
339 if (mac->instance->version > 0)
340 t1_tpi_write(adapter, MACREG(mac, REG_RX_FILTER), 3);
341 else /* Don't enable unicast address filtering due to IXF1010 bug */
342 t1_tpi_write(adapter, MACREG(mac, REG_RX_FILTER), 2);
343
344 t1_tpi_read(adapter, REG_RX_ERR_DROP, &val);
345 val |= (1 << index);
346 t1_tpi_write(adapter, REG_RX_ERR_DROP, val);
347
348 /*
349 * Clear the port RMON registers by adding their current values to the
350 * cumulatice port stats and then clearing the stats. Really.
351 */
352 port_stats_update(mac);
353 memset(&mac->stats, 0, sizeof(struct cmac_statistics));
354 mac->instance->ticks = 0;
355
356 t1_tpi_read(adapter, REG_PORT_ENABLE, &val);
357 val |= (1 << index);
358 t1_tpi_write(adapter, REG_PORT_ENABLE, val);
359
360 index <<= 2;
361 if (is_T2(adapter)) {
362 /* T204: set the Fifo water level & threshold */
363 t1_tpi_write(adapter, RX_FIFO_HIGH_WATERMARK_BASE + index, 0x740);
364 t1_tpi_write(adapter, RX_FIFO_LOW_WATERMARK_BASE + index, 0x730);
365 t1_tpi_write(adapter, TX_FIFO_HIGH_WATERMARK_BASE + index, 0x600);
366 t1_tpi_write(adapter, TX_FIFO_LOW_WATERMARK_BASE + index, 0x1d0);
367 t1_tpi_write(adapter, TX_FIFO_XFER_THRES_BASE + index, 0x1100);
368 } else {
369 /*
370 * Set the TX Fifo Threshold to 0x400 instead of 0x100 to work around
371 * Underrun problem. Intel has blessed this solution.
372 */
373 t1_tpi_write(adapter, TX_FIFO_XFER_THRES_BASE + index, 0x400);
374 }
375}
376
377/* IXF1010 ports do not have separate enables for TX and RX */
378static int mac_enable(struct cmac *mac, int which)
379{
380 if (which & (MAC_DIRECTION_RX | MAC_DIRECTION_TX))
381 enable_port(mac);
382 return 0;
383}
384
385static int mac_disable(struct cmac *mac, int which)
386{
387 if (which & (MAC_DIRECTION_RX | MAC_DIRECTION_TX))
388 disable_port(mac);
389 return 0;
390}
391
392/*
393 * This function is called periodically to accumulate the current values of the
394 * RMON counters into the port statistics. Since the counters are only 32 bits
395 * some of them can overflow in less than a minute at GigE speeds, so this
396 * function should be called every 30 seconds or so.
397 *
398 * To cut down on reading costs we update only the octet counters at each tick
399 * and do a full update at major ticks, which can be every 30 minutes or more.
400 */
401static const struct cmac_statistics *mac_update_statistics(struct cmac *mac,
402 int flag)
403{
404 if (flag == MAC_STATS_UPDATE_FULL ||
405 MAJOR_UPDATE_TICKS <= mac->instance->ticks) {
406 port_stats_update(mac);
407 mac->instance->ticks = 0;
408 } else {
409 u32 val;
410
411 RMON_UPDATE(mac, RxOctetsTotalOK, RxOctetsOK);
412 RMON_UPDATE(mac, TxOctetsTotalOK, TxOctetsOK);
413 mac->instance->ticks++;
414 }
415 return &mac->stats;
416}
417
418static void mac_destroy(struct cmac *mac)
419{
420 kfree(mac);
421}
422
423static struct cmac_ops ixf1010_ops = {
424 .destroy = mac_destroy,
425 .reset = mac_reset,
426 .interrupt_enable = mac_intr_op,
427 .interrupt_disable = mac_intr_op,
428 .interrupt_clear = mac_intr_op,
429 .enable = mac_enable,
430 .disable = mac_disable,
431 .set_mtu = mac_set_mtu,
432 .set_rx_mode = mac_set_rx_mode,
433 .set_speed_duplex_fc = mac_set_speed_duplex_fc,
434 .get_speed_duplex_fc = mac_get_speed_duplex_fc,
435 .statistics_update = mac_update_statistics,
436 .macaddress_get = mac_get_address,
437 .macaddress_set = mac_set_address,
438};
439
440static int ixf1010_mac_reset(adapter_t *adapter)
441{
442 u32 val;
443
444 t1_tpi_read(adapter, A_ELMER0_GPO, &val);
445 if ((val & 1) != 0) {
446 val &= ~1;
447 t1_tpi_write(adapter, A_ELMER0_GPO, val);
448 udelay(2);
449 }
450 val |= 1;
451 t1_tpi_write(adapter, A_ELMER0_GPO, val);
452 udelay(2);
453
454 t1_tpi_write(adapter, REG_PORT_ENABLE, 0);
455 return 0;
456}
457
458static struct cmac *ixf1010_mac_create(adapter_t *adapter, int index)
459{
460 struct cmac *mac;
461 u32 val;
462
463 if (index > 9) return NULL;
464
465 mac = kzalloc(sizeof(*mac) + sizeof(cmac_instance), GFP_KERNEL);
466 if (!mac) return NULL;
467
468 mac->ops = &ixf1010_ops;
469 mac->instance = (cmac_instance *)(mac + 1);
470
471 mac->instance->mac_base = MACREG_BASE + (index * 0x200);
472 mac->instance->index = index;
473 mac->adapter = adapter;
474 mac->instance->ticks = 0;
475
476 t1_tpi_read(adapter, REG_JTAG_ID, &val);
477 mac->instance->version = val >> 28;
478 return mac;
479}
480
481struct gmac t1_ixf1010_ops = {
482 STATS_TICK_SECS,
483 ixf1010_mac_create,
484 ixf1010_mac_reset
485};
diff --git a/drivers/net/chelsio/mac.c b/drivers/net/chelsio/mac.c
new file mode 100644
index 000000000000..6af39dc70459
--- /dev/null
+++ b/drivers/net/chelsio/mac.c
@@ -0,0 +1,368 @@
1/* $Date: 2005/10/22 00:42:59 $ $RCSfile: mac.c,v $ $Revision: 1.32 $ */
2#include "gmac.h"
3#include "regs.h"
4#include "fpga_defs.h"
5
6#define MAC_CSR_INTERFACE_GMII 0x0
7#define MAC_CSR_INTERFACE_TBI 0x1
8#define MAC_CSR_INTERFACE_MII 0x2
9#define MAC_CSR_INTERFACE_RMII 0x3
10
11/* Chelsio's MAC statistics. */
12struct mac_statistics {
13
14 /* Transmit */
15 u32 TxFramesTransmittedOK;
16 u32 TxReserved1;
17 u32 TxReserved2;
18 u32 TxOctetsTransmittedOK;
19 u32 TxFramesWithDeferredXmissions;
20 u32 TxLateCollisions;
21 u32 TxFramesAbortedDueToXSCollisions;
22 u32 TxFramesLostDueToIntMACXmitError;
23 u32 TxReserved3;
24 u32 TxMulticastFrameXmittedOK;
25 u32 TxBroadcastFramesXmittedOK;
26 u32 TxFramesWithExcessiveDeferral;
27 u32 TxPAUSEMACCtrlFramesTransmitted;
28
29 /* Receive */
30 u32 RxFramesReceivedOK;
31 u32 RxFrameCheckSequenceErrors;
32 u32 RxAlignmentErrors;
33 u32 RxOctetsReceivedOK;
34 u32 RxFramesLostDueToIntMACRcvError;
35 u32 RxMulticastFramesReceivedOK;
36 u32 RxBroadcastFramesReceivedOK;
37 u32 RxInRangeLengthErrors;
38 u32 RxTxOutOfRangeLengthField;
39 u32 RxFrameTooLongErrors;
40 u32 RxPAUSEMACCtrlFramesReceived;
41};
42
43static int static_aPorts[] = {
44 FPGA_GMAC_INTERRUPT_PORT0,
45 FPGA_GMAC_INTERRUPT_PORT1,
46 FPGA_GMAC_INTERRUPT_PORT2,
47 FPGA_GMAC_INTERRUPT_PORT3
48};
49
50struct _cmac_instance {
51 u32 index;
52};
53
54static int mac_intr_enable(struct cmac *mac)
55{
56 u32 mac_intr;
57
58 if (t1_is_asic(mac->adapter)) {
59 /* ASIC */
60
61 /* We don't use the on chip MAC for ASIC products. */
62 } else {
63 /* FPGA */
64
65 /* Set parent gmac interrupt. */
66 mac_intr = readl(mac->adapter->regs + A_PL_ENABLE);
67 mac_intr |= FPGA_PCIX_INTERRUPT_GMAC;
68 writel(mac_intr, mac->adapter->regs + A_PL_ENABLE);
69
70 mac_intr = readl(mac->adapter->regs + FPGA_GMAC_ADDR_INTERRUPT_ENABLE);
71 mac_intr |= static_aPorts[mac->instance->index];
72 writel(mac_intr,
73 mac->adapter->regs + FPGA_GMAC_ADDR_INTERRUPT_ENABLE);
74 }
75
76 return 0;
77}
78
79static int mac_intr_disable(struct cmac *mac)
80{
81 u32 mac_intr;
82
83 if (t1_is_asic(mac->adapter)) {
84 /* ASIC */
85
86 /* We don't use the on chip MAC for ASIC products. */
87 } else {
88 /* FPGA */
89
90 /* Set parent gmac interrupt. */
91 mac_intr = readl(mac->adapter->regs + A_PL_ENABLE);
92 mac_intr &= ~FPGA_PCIX_INTERRUPT_GMAC;
93 writel(mac_intr, mac->adapter->regs + A_PL_ENABLE);
94
95 mac_intr = readl(mac->adapter->regs + FPGA_GMAC_ADDR_INTERRUPT_ENABLE);
96 mac_intr &= ~(static_aPorts[mac->instance->index]);
97 writel(mac_intr,
98 mac->adapter->regs + FPGA_GMAC_ADDR_INTERRUPT_ENABLE);
99 }
100
101 return 0;
102}
103
104static int mac_intr_clear(struct cmac *mac)
105{
106 u32 mac_intr;
107
108 if (t1_is_asic(mac->adapter)) {
109 /* ASIC */
110
111 /* We don't use the on chip MAC for ASIC products. */
112 } else {
113 /* FPGA */
114
115 /* Set parent gmac interrupt. */
116 writel(FPGA_PCIX_INTERRUPT_GMAC,
117 mac->adapter->regs + A_PL_CAUSE);
118 mac_intr = readl(mac->adapter->regs + FPGA_GMAC_ADDR_INTERRUPT_CAUSE);
119 mac_intr |= (static_aPorts[mac->instance->index]);
120 writel(mac_intr,
121 mac->adapter->regs + FPGA_GMAC_ADDR_INTERRUPT_CAUSE);
122 }
123
124 return 0;
125}
126
127static int mac_get_address(struct cmac *mac, u8 addr[6])
128{
129 u32 data32_lo, data32_hi;
130
131 data32_lo = readl(mac->adapter->regs
132 + MAC_REG_IDLO(mac->instance->index));
133 data32_hi = readl(mac->adapter->regs
134 + MAC_REG_IDHI(mac->instance->index));
135
136 addr[0] = (u8) ((data32_hi >> 8) & 0xFF);
137 addr[1] = (u8) ((data32_hi) & 0xFF);
138 addr[2] = (u8) ((data32_lo >> 24) & 0xFF);
139 addr[3] = (u8) ((data32_lo >> 16) & 0xFF);
140 addr[4] = (u8) ((data32_lo >> 8) & 0xFF);
141 addr[5] = (u8) ((data32_lo) & 0xFF);
142 return 0;
143}
144
145static int mac_reset(struct cmac *mac)
146{
147 u32 data32;
148 int mac_in_reset, time_out = 100;
149 int idx = mac->instance->index;
150
151 data32 = readl(mac->adapter->regs + MAC_REG_CSR(idx));
152 writel(data32 | F_MAC_RESET,
153 mac->adapter->regs + MAC_REG_CSR(idx));
154
155 do {
156 data32 = readl(mac->adapter->regs + MAC_REG_CSR(idx));
157
158 mac_in_reset = data32 & F_MAC_RESET;
159 if (mac_in_reset)
160 udelay(1);
161 } while (mac_in_reset && --time_out);
162
163 if (mac_in_reset) {
164 CH_ERR("%s: MAC %d reset timed out\n",
165 mac->adapter->name, idx);
166 return 2;
167 }
168
169 return 0;
170}
171
172static int mac_set_rx_mode(struct cmac *mac, struct t1_rx_mode *rm)
173{
174 u32 val;
175
176 val = readl(mac->adapter->regs
177 + MAC_REG_CSR(mac->instance->index));
178 val &= ~(F_MAC_PROMISC | F_MAC_MC_ENABLE);
179 val |= V_MAC_PROMISC(t1_rx_mode_promisc(rm) != 0);
180 val |= V_MAC_MC_ENABLE(t1_rx_mode_allmulti(rm) != 0);
181 writel(val,
182 mac->adapter->regs + MAC_REG_CSR(mac->instance->index));
183
184 return 0;
185}
186
187static int mac_set_speed_duplex_fc(struct cmac *mac, int speed, int duplex,
188 int fc)
189{
190 u32 data32;
191
192 data32 = readl(mac->adapter->regs
193 + MAC_REG_CSR(mac->instance->index));
194 data32 &= ~(F_MAC_HALF_DUPLEX | V_MAC_SPEED(M_MAC_SPEED) |
195 V_INTERFACE(M_INTERFACE) | F_MAC_TX_PAUSE_ENABLE |
196 F_MAC_RX_PAUSE_ENABLE);
197
198 switch (speed) {
199 case SPEED_10:
200 case SPEED_100:
201 data32 |= V_INTERFACE(MAC_CSR_INTERFACE_MII);
202 data32 |= V_MAC_SPEED(speed == SPEED_10 ? 0 : 1);
203 break;
204 case SPEED_1000:
205 data32 |= V_INTERFACE(MAC_CSR_INTERFACE_GMII);
206 data32 |= V_MAC_SPEED(2);
207 break;
208 }
209
210 if (duplex >= 0)
211 data32 |= V_MAC_HALF_DUPLEX(duplex == DUPLEX_HALF);
212
213 if (fc >= 0) {
214 data32 |= V_MAC_RX_PAUSE_ENABLE((fc & PAUSE_RX) != 0);
215 data32 |= V_MAC_TX_PAUSE_ENABLE((fc & PAUSE_TX) != 0);
216 }
217
218 writel(data32,
219 mac->adapter->regs + MAC_REG_CSR(mac->instance->index));
220 return 0;
221}
222
223static int mac_enable(struct cmac *mac, int which)
224{
225 u32 val;
226
227 val = readl(mac->adapter->regs
228 + MAC_REG_CSR(mac->instance->index));
229 if (which & MAC_DIRECTION_RX)
230 val |= F_MAC_RX_ENABLE;
231 if (which & MAC_DIRECTION_TX)
232 val |= F_MAC_TX_ENABLE;
233 writel(val,
234 mac->adapter->regs + MAC_REG_CSR(mac->instance->index));
235 return 0;
236}
237
238static int mac_disable(struct cmac *mac, int which)
239{
240 u32 val;
241
242 val = readl(mac->adapter->regs
243 + MAC_REG_CSR(mac->instance->index));
244 if (which & MAC_DIRECTION_RX)
245 val &= ~F_MAC_RX_ENABLE;
246 if (which & MAC_DIRECTION_TX)
247 val &= ~F_MAC_TX_ENABLE;
248 writel(val,
249 mac->adapter->regs + MAC_REG_CSR(mac->instance->index));
250 return 0;
251}
252
253#if 0
254static int mac_set_ifs(struct cmac *mac, u32 mode)
255{
256 t1_write_reg_4(mac->adapter,
257 MAC_REG_IFS(mac->instance->index),
258 mode);
259 return 0;
260}
261
262static int mac_enable_isl(struct cmac *mac)
263{
264 u32 data32 = readl(mac->adapter->regs
265 + MAC_REG_CSR(mac->instance->index));
266 data32 |= F_MAC_RX_ENABLE | F_MAC_TX_ENABLE;
267 t1_write_reg_4(mac->adapter,
268 MAC_REG_CSR(mac->instance->index),
269 data32);
270 return 0;
271}
272#endif
273
274static int mac_set_mtu(struct cmac *mac, int mtu)
275{
276 if (mtu > 9600)
277 return -EINVAL;
278 writel(mtu + ETH_HLEN + VLAN_HLEN,
279 mac->adapter->regs + MAC_REG_LARGEFRAMELENGTH(mac->instance->index));
280
281 return 0;
282}
283
284static const struct cmac_statistics *mac_update_statistics(struct cmac *mac,
285 int flag)
286{
287 struct mac_statistics st;
288 u32 *p = (u32 *) & st, i;
289
290 writel(0,
291 mac->adapter->regs + MAC_REG_RMCNT(mac->instance->index));
292
293 for (i = 0; i < sizeof(st) / sizeof(u32); i++)
294 *p++ = readl(mac->adapter->regs
295 + MAC_REG_RMDATA(mac->instance->index));
296
297 /* XXX convert stats */
298 return &mac->stats;
299}
300
301static void mac_destroy(struct cmac *mac)
302{
303 kfree(mac);
304}
305
306static struct cmac_ops chelsio_mac_ops = {
307 .destroy = mac_destroy,
308 .reset = mac_reset,
309 .interrupt_enable = mac_intr_enable,
310 .interrupt_disable = mac_intr_disable,
311 .interrupt_clear = mac_intr_clear,
312 .enable = mac_enable,
313 .disable = mac_disable,
314 .set_mtu = mac_set_mtu,
315 .set_rx_mode = mac_set_rx_mode,
316 .set_speed_duplex_fc = mac_set_speed_duplex_fc,
317 .macaddress_get = mac_get_address,
318 .statistics_update = mac_update_statistics,
319};
320
321static struct cmac *mac_create(adapter_t *adapter, int index)
322{
323 struct cmac *mac;
324 u32 data32;
325
326 if (index >= 4)
327 return NULL;
328
329 mac = kzalloc(sizeof(*mac) + sizeof(cmac_instance), GFP_KERNEL);
330 if (!mac)
331 return NULL;
332
333 mac->ops = &chelsio_mac_ops;
334 mac->instance = (cmac_instance *) (mac + 1);
335
336 mac->instance->index = index;
337 mac->adapter = adapter;
338
339 data32 = readl(adapter->regs + MAC_REG_CSR(mac->instance->index));
340 data32 &= ~(F_MAC_RESET | F_MAC_PROMISC | F_MAC_PROMISC |
341 F_MAC_LB_ENABLE | F_MAC_RX_ENABLE | F_MAC_TX_ENABLE);
342 data32 |= F_MAC_JUMBO_ENABLE;
343 writel(data32, adapter->regs + MAC_REG_CSR(mac->instance->index));
344
345 /* Initialize the random backoff seed. */
346 data32 = 0x55aa + (3 * index);
347 writel(data32,
348 adapter->regs + MAC_REG_GMRANDBACKOFFSEED(mac->instance->index));
349
350 /* Check to see if the mac address needs to be set manually. */
351 data32 = readl(adapter->regs + MAC_REG_IDLO(mac->instance->index));
352 if (data32 == 0 || data32 == 0xffffffff) {
353 /*
354 * Add a default MAC address if we can't read one.
355 */
356 writel(0x43FFFFFF - index,
357 adapter->regs + MAC_REG_IDLO(mac->instance->index));
358 writel(0x0007,
359 adapter->regs + MAC_REG_IDHI(mac->instance->index));
360 }
361
362 (void) mac_set_mtu(mac, 1500);
363 return mac;
364}
365
366struct gmac t1_chelsio_mac_ops = {
367 .create = mac_create
368};
diff --git a/drivers/net/chelsio/mv88e1xxx.c b/drivers/net/chelsio/mv88e1xxx.c
new file mode 100644
index 000000000000..28ac93ff7c4f
--- /dev/null
+++ b/drivers/net/chelsio/mv88e1xxx.c
@@ -0,0 +1,397 @@
1/* $Date: 2005/10/24 23:18:13 $ $RCSfile: mv88e1xxx.c,v $ $Revision: 1.49 $ */
2#include "common.h"
3#include "mv88e1xxx.h"
4#include "cphy.h"
5#include "elmer0.h"
6
7/* MV88E1XXX MDI crossover register values */
8#define CROSSOVER_MDI 0
9#define CROSSOVER_MDIX 1
10#define CROSSOVER_AUTO 3
11
12#define INTR_ENABLE_MASK 0x6CA0
13
14/*
15 * Set the bits given by 'bitval' in PHY register 'reg'.
16 */
17static void mdio_set_bit(struct cphy *cphy, int reg, u32 bitval)
18{
19 u32 val;
20
21 (void) simple_mdio_read(cphy, reg, &val);
22 (void) simple_mdio_write(cphy, reg, val | bitval);
23}
24
25/*
26 * Clear the bits given by 'bitval' in PHY register 'reg'.
27 */
28static void mdio_clear_bit(struct cphy *cphy, int reg, u32 bitval)
29{
30 u32 val;
31
32 (void) simple_mdio_read(cphy, reg, &val);
33 (void) simple_mdio_write(cphy, reg, val & ~bitval);
34}
35
36/*
37 * NAME: phy_reset
38 *
39 * DESC: Reset the given PHY's port. NOTE: This is not a global
40 * chip reset.
41 *
42 * PARAMS: cphy - Pointer to PHY instance data.
43 *
44 * RETURN: 0 - Successfull reset.
45 * -1 - Timeout.
46 */
47static int mv88e1xxx_reset(struct cphy *cphy, int wait)
48{
49 u32 ctl;
50 int time_out = 1000;
51
52 mdio_set_bit(cphy, MII_BMCR, BMCR_RESET);
53
54 do {
55 (void) simple_mdio_read(cphy, MII_BMCR, &ctl);
56 ctl &= BMCR_RESET;
57 if (ctl)
58 udelay(1);
59 } while (ctl && --time_out);
60
61 return ctl ? -1 : 0;
62}
63
64static int mv88e1xxx_interrupt_enable(struct cphy *cphy)
65{
66 /* Enable PHY interrupts. */
67 (void) simple_mdio_write(cphy, MV88E1XXX_INTERRUPT_ENABLE_REGISTER,
68 INTR_ENABLE_MASK);
69
70 /* Enable Marvell interrupts through Elmer0. */
71 if (t1_is_asic(cphy->adapter)) {
72 u32 elmer;
73
74 t1_tpi_read(cphy->adapter, A_ELMER0_INT_ENABLE, &elmer);
75 elmer |= ELMER0_GP_BIT1;
76 if (is_T2(cphy->adapter)) {
77 elmer |= ELMER0_GP_BIT2|ELMER0_GP_BIT3|ELMER0_GP_BIT4;
78 }
79 t1_tpi_write(cphy->adapter, A_ELMER0_INT_ENABLE, elmer);
80 }
81 return 0;
82}
83
84static int mv88e1xxx_interrupt_disable(struct cphy *cphy)
85{
86 /* Disable all phy interrupts. */
87 (void) simple_mdio_write(cphy, MV88E1XXX_INTERRUPT_ENABLE_REGISTER, 0);
88
89 /* Disable Marvell interrupts through Elmer0. */
90 if (t1_is_asic(cphy->adapter)) {
91 u32 elmer;
92
93 t1_tpi_read(cphy->adapter, A_ELMER0_INT_ENABLE, &elmer);
94 elmer &= ~ELMER0_GP_BIT1;
95 if (is_T2(cphy->adapter)) {
96 elmer &= ~(ELMER0_GP_BIT2|ELMER0_GP_BIT3|ELMER0_GP_BIT4);
97 }
98 t1_tpi_write(cphy->adapter, A_ELMER0_INT_ENABLE, elmer);
99 }
100 return 0;
101}
102
103static int mv88e1xxx_interrupt_clear(struct cphy *cphy)
104{
105 u32 elmer;
106
107 /* Clear PHY interrupts by reading the register. */
108 (void) simple_mdio_read(cphy,
109 MV88E1XXX_INTERRUPT_STATUS_REGISTER, &elmer);
110
111 /* Clear Marvell interrupts through Elmer0. */
112 if (t1_is_asic(cphy->adapter)) {
113 t1_tpi_read(cphy->adapter, A_ELMER0_INT_CAUSE, &elmer);
114 elmer |= ELMER0_GP_BIT1;
115 if (is_T2(cphy->adapter)) {
116 elmer |= ELMER0_GP_BIT2|ELMER0_GP_BIT3|ELMER0_GP_BIT4;
117 }
118 t1_tpi_write(cphy->adapter, A_ELMER0_INT_CAUSE, elmer);
119 }
120 return 0;
121}
122
123/*
124 * Set the PHY speed and duplex. This also disables auto-negotiation, except
125 * for 1Gb/s, where auto-negotiation is mandatory.
126 */
127static int mv88e1xxx_set_speed_duplex(struct cphy *phy, int speed, int duplex)
128{
129 u32 ctl;
130
131 (void) simple_mdio_read(phy, MII_BMCR, &ctl);
132 if (speed >= 0) {
133 ctl &= ~(BMCR_SPEED100 | BMCR_SPEED1000 | BMCR_ANENABLE);
134 if (speed == SPEED_100)
135 ctl |= BMCR_SPEED100;
136 else if (speed == SPEED_1000)
137 ctl |= BMCR_SPEED1000;
138 }
139 if (duplex >= 0) {
140 ctl &= ~(BMCR_FULLDPLX | BMCR_ANENABLE);
141 if (duplex == DUPLEX_FULL)
142 ctl |= BMCR_FULLDPLX;
143 }
144 if (ctl & BMCR_SPEED1000) /* auto-negotiation required for 1Gb/s */
145 ctl |= BMCR_ANENABLE;
146 (void) simple_mdio_write(phy, MII_BMCR, ctl);
147 return 0;
148}
149
150static int mv88e1xxx_crossover_set(struct cphy *cphy, int crossover)
151{
152 u32 data32;
153
154 (void) simple_mdio_read(cphy,
155 MV88E1XXX_SPECIFIC_CNTRL_REGISTER, &data32);
156 data32 &= ~V_PSCR_MDI_XOVER_MODE(M_PSCR_MDI_XOVER_MODE);
157 data32 |= V_PSCR_MDI_XOVER_MODE(crossover);
158 (void) simple_mdio_write(cphy,
159 MV88E1XXX_SPECIFIC_CNTRL_REGISTER, data32);
160 return 0;
161}
162
163static int mv88e1xxx_autoneg_enable(struct cphy *cphy)
164{
165 u32 ctl;
166
167 (void) mv88e1xxx_crossover_set(cphy, CROSSOVER_AUTO);
168
169 (void) simple_mdio_read(cphy, MII_BMCR, &ctl);
170 /* restart autoneg for change to take effect */
171 ctl |= BMCR_ANENABLE | BMCR_ANRESTART;
172 (void) simple_mdio_write(cphy, MII_BMCR, ctl);
173 return 0;
174}
175
176static int mv88e1xxx_autoneg_disable(struct cphy *cphy)
177{
178 u32 ctl;
179
180 /*
181 * Crossover *must* be set to manual in order to disable auto-neg.
182 * The Alaska FAQs document highlights this point.
183 */
184 (void) mv88e1xxx_crossover_set(cphy, CROSSOVER_MDI);
185
186 /*
187 * Must include autoneg reset when disabling auto-neg. This
188 * is described in the Alaska FAQ document.
189 */
190 (void) simple_mdio_read(cphy, MII_BMCR, &ctl);
191 ctl &= ~BMCR_ANENABLE;
192 (void) simple_mdio_write(cphy, MII_BMCR, ctl | BMCR_ANRESTART);
193 return 0;
194}
195
196static int mv88e1xxx_autoneg_restart(struct cphy *cphy)
197{
198 mdio_set_bit(cphy, MII_BMCR, BMCR_ANRESTART);
199 return 0;
200}
201
202static int mv88e1xxx_advertise(struct cphy *phy, unsigned int advertise_map)
203{
204 u32 val = 0;
205
206 if (advertise_map &
207 (ADVERTISED_1000baseT_Half | ADVERTISED_1000baseT_Full)) {
208 (void) simple_mdio_read(phy, MII_GBCR, &val);
209 val &= ~(GBCR_ADV_1000HALF | GBCR_ADV_1000FULL);
210 if (advertise_map & ADVERTISED_1000baseT_Half)
211 val |= GBCR_ADV_1000HALF;
212 if (advertise_map & ADVERTISED_1000baseT_Full)
213 val |= GBCR_ADV_1000FULL;
214 }
215 (void) simple_mdio_write(phy, MII_GBCR, val);
216
217 val = 1;
218 if (advertise_map & ADVERTISED_10baseT_Half)
219 val |= ADVERTISE_10HALF;
220 if (advertise_map & ADVERTISED_10baseT_Full)
221 val |= ADVERTISE_10FULL;
222 if (advertise_map & ADVERTISED_100baseT_Half)
223 val |= ADVERTISE_100HALF;
224 if (advertise_map & ADVERTISED_100baseT_Full)
225 val |= ADVERTISE_100FULL;
226 if (advertise_map & ADVERTISED_PAUSE)
227 val |= ADVERTISE_PAUSE;
228 if (advertise_map & ADVERTISED_ASYM_PAUSE)
229 val |= ADVERTISE_PAUSE_ASYM;
230 (void) simple_mdio_write(phy, MII_ADVERTISE, val);
231 return 0;
232}
233
234static int mv88e1xxx_set_loopback(struct cphy *cphy, int on)
235{
236 if (on)
237 mdio_set_bit(cphy, MII_BMCR, BMCR_LOOPBACK);
238 else
239 mdio_clear_bit(cphy, MII_BMCR, BMCR_LOOPBACK);
240 return 0;
241}
242
243static int mv88e1xxx_get_link_status(struct cphy *cphy, int *link_ok,
244 int *speed, int *duplex, int *fc)
245{
246 u32 status;
247 int sp = -1, dplx = -1, pause = 0;
248
249 (void) simple_mdio_read(cphy,
250 MV88E1XXX_SPECIFIC_STATUS_REGISTER, &status);
251 if ((status & V_PSSR_STATUS_RESOLVED) != 0) {
252 if (status & V_PSSR_RX_PAUSE)
253 pause |= PAUSE_RX;
254 if (status & V_PSSR_TX_PAUSE)
255 pause |= PAUSE_TX;
256 dplx = (status & V_PSSR_DUPLEX) ? DUPLEX_FULL : DUPLEX_HALF;
257 sp = G_PSSR_SPEED(status);
258 if (sp == 0)
259 sp = SPEED_10;
260 else if (sp == 1)
261 sp = SPEED_100;
262 else
263 sp = SPEED_1000;
264 }
265 if (link_ok)
266 *link_ok = (status & V_PSSR_LINK) != 0;
267 if (speed)
268 *speed = sp;
269 if (duplex)
270 *duplex = dplx;
271 if (fc)
272 *fc = pause;
273 return 0;
274}
275
276static int mv88e1xxx_downshift_set(struct cphy *cphy, int downshift_enable)
277{
278 u32 val;
279
280 (void) simple_mdio_read(cphy,
281 MV88E1XXX_EXT_PHY_SPECIFIC_CNTRL_REGISTER, &val);
282
283 /*
284 * Set the downshift counter to 2 so we try to establish Gb link
285 * twice before downshifting.
286 */
287 val &= ~(V_DOWNSHIFT_ENABLE | V_DOWNSHIFT_CNT(M_DOWNSHIFT_CNT));
288
289 if (downshift_enable)
290 val |= V_DOWNSHIFT_ENABLE | V_DOWNSHIFT_CNT(2);
291 (void) simple_mdio_write(cphy,
292 MV88E1XXX_EXT_PHY_SPECIFIC_CNTRL_REGISTER, val);
293 return 0;
294}
295
296static int mv88e1xxx_interrupt_handler(struct cphy *cphy)
297{
298 int cphy_cause = 0;
299 u32 status;
300
301 /*
302 * Loop until cause reads zero. Need to handle bouncing interrupts.
303 */
304 while (1) {
305 u32 cause;
306
307 (void) simple_mdio_read(cphy,
308 MV88E1XXX_INTERRUPT_STATUS_REGISTER,
309 &cause);
310 cause &= INTR_ENABLE_MASK;
311 if (!cause) break;
312
313 if (cause & MV88E1XXX_INTR_LINK_CHNG) {
314 (void) simple_mdio_read(cphy,
315 MV88E1XXX_SPECIFIC_STATUS_REGISTER, &status);
316
317 if (status & MV88E1XXX_INTR_LINK_CHNG) {
318 cphy->state |= PHY_LINK_UP;
319 } else {
320 cphy->state &= ~PHY_LINK_UP;
321 if (cphy->state & PHY_AUTONEG_EN)
322 cphy->state &= ~PHY_AUTONEG_RDY;
323 cphy_cause |= cphy_cause_link_change;
324 }
325 }
326
327 if (cause & MV88E1XXX_INTR_AUTONEG_DONE)
328 cphy->state |= PHY_AUTONEG_RDY;
329
330 if ((cphy->state & (PHY_LINK_UP | PHY_AUTONEG_RDY)) ==
331 (PHY_LINK_UP | PHY_AUTONEG_RDY))
332 cphy_cause |= cphy_cause_link_change;
333 }
334 return cphy_cause;
335}
336
337static void mv88e1xxx_destroy(struct cphy *cphy)
338{
339 kfree(cphy);
340}
341
342static struct cphy_ops mv88e1xxx_ops = {
343 .destroy = mv88e1xxx_destroy,
344 .reset = mv88e1xxx_reset,
345 .interrupt_enable = mv88e1xxx_interrupt_enable,
346 .interrupt_disable = mv88e1xxx_interrupt_disable,
347 .interrupt_clear = mv88e1xxx_interrupt_clear,
348 .interrupt_handler = mv88e1xxx_interrupt_handler,
349 .autoneg_enable = mv88e1xxx_autoneg_enable,
350 .autoneg_disable = mv88e1xxx_autoneg_disable,
351 .autoneg_restart = mv88e1xxx_autoneg_restart,
352 .advertise = mv88e1xxx_advertise,
353 .set_loopback = mv88e1xxx_set_loopback,
354 .set_speed_duplex = mv88e1xxx_set_speed_duplex,
355 .get_link_status = mv88e1xxx_get_link_status,
356};
357
358static struct cphy *mv88e1xxx_phy_create(adapter_t *adapter, int phy_addr,
359 struct mdio_ops *mdio_ops)
360{
361 struct cphy *cphy = kzalloc(sizeof(*cphy), GFP_KERNEL);
362
363 if (!cphy) return NULL;
364
365 cphy_init(cphy, adapter, phy_addr, &mv88e1xxx_ops, mdio_ops);
366
367 /* Configure particular PHY's to run in a different mode. */
368 if ((board_info(adapter)->caps & SUPPORTED_TP) &&
369 board_info(adapter)->chip_phy == CHBT_PHY_88E1111) {
370 /*
371 * Configure the PHY transmitter as class A to reduce EMI.
372 */
373 (void) simple_mdio_write(cphy,
374 MV88E1XXX_EXTENDED_ADDR_REGISTER, 0xB);
375 (void) simple_mdio_write(cphy,
376 MV88E1XXX_EXTENDED_REGISTER, 0x8004);
377 }
378 (void) mv88e1xxx_downshift_set(cphy, 1); /* Enable downshift */
379
380 /* LED */
381 if (is_T2(adapter)) {
382 (void) simple_mdio_write(cphy,
383 MV88E1XXX_LED_CONTROL_REGISTER, 0x1);
384 }
385
386 return cphy;
387}
388
389static int mv88e1xxx_phy_reset(adapter_t* adapter)
390{
391 return 0;
392}
393
394struct gphy t1_mv88e1xxx_ops = {
395 mv88e1xxx_phy_create,
396 mv88e1xxx_phy_reset
397};
diff --git a/drivers/net/chelsio/mv88e1xxx.h b/drivers/net/chelsio/mv88e1xxx.h
new file mode 100644
index 000000000000..967cc4286359
--- /dev/null
+++ b/drivers/net/chelsio/mv88e1xxx.h
@@ -0,0 +1,127 @@
1/* $Date: 2005/03/07 23:59:05 $ $RCSfile: mv88e1xxx.h,v $ $Revision: 1.13 $ */
2#ifndef CHELSIO_MV8E1XXX_H
3#define CHELSIO_MV8E1XXX_H
4
5#ifndef BMCR_SPEED1000
6# define BMCR_SPEED1000 0x40
7#endif
8
9#ifndef ADVERTISE_PAUSE
10# define ADVERTISE_PAUSE 0x400
11#endif
12#ifndef ADVERTISE_PAUSE_ASYM
13# define ADVERTISE_PAUSE_ASYM 0x800
14#endif
15
16/* Gigabit MII registers */
17#define MII_GBCR 9 /* 1000Base-T control register */
18#define MII_GBSR 10 /* 1000Base-T status register */
19
20/* 1000Base-T control register fields */
21#define GBCR_ADV_1000HALF 0x100
22#define GBCR_ADV_1000FULL 0x200
23#define GBCR_PREFER_MASTER 0x400
24#define GBCR_MANUAL_AS_MASTER 0x800
25#define GBCR_MANUAL_CONFIG_ENABLE 0x1000
26
27/* 1000Base-T status register fields */
28#define GBSR_LP_1000HALF 0x400
29#define GBSR_LP_1000FULL 0x800
30#define GBSR_REMOTE_OK 0x1000
31#define GBSR_LOCAL_OK 0x2000
32#define GBSR_LOCAL_MASTER 0x4000
33#define GBSR_MASTER_FAULT 0x8000
34
35/* Marvell PHY interrupt status bits. */
36#define MV88E1XXX_INTR_JABBER 0x0001
37#define MV88E1XXX_INTR_POLARITY_CHNG 0x0002
38#define MV88E1XXX_INTR_ENG_DETECT_CHNG 0x0010
39#define MV88E1XXX_INTR_DOWNSHIFT 0x0020
40#define MV88E1XXX_INTR_MDI_XOVER_CHNG 0x0040
41#define MV88E1XXX_INTR_FIFO_OVER_UNDER 0x0080
42#define MV88E1XXX_INTR_FALSE_CARRIER 0x0100
43#define MV88E1XXX_INTR_SYMBOL_ERROR 0x0200
44#define MV88E1XXX_INTR_LINK_CHNG 0x0400
45#define MV88E1XXX_INTR_AUTONEG_DONE 0x0800
46#define MV88E1XXX_INTR_PAGE_RECV 0x1000
47#define MV88E1XXX_INTR_DUPLEX_CHNG 0x2000
48#define MV88E1XXX_INTR_SPEED_CHNG 0x4000
49#define MV88E1XXX_INTR_AUTONEG_ERR 0x8000
50
51/* Marvell PHY specific registers. */
52#define MV88E1XXX_SPECIFIC_CNTRL_REGISTER 16
53#define MV88E1XXX_SPECIFIC_STATUS_REGISTER 17
54#define MV88E1XXX_INTERRUPT_ENABLE_REGISTER 18
55#define MV88E1XXX_INTERRUPT_STATUS_REGISTER 19
56#define MV88E1XXX_EXT_PHY_SPECIFIC_CNTRL_REGISTER 20
57#define MV88E1XXX_RECV_ERR_CNTR_REGISTER 21
58#define MV88E1XXX_RES_REGISTER 22
59#define MV88E1XXX_GLOBAL_STATUS_REGISTER 23
60#define MV88E1XXX_LED_CONTROL_REGISTER 24
61#define MV88E1XXX_MANUAL_LED_OVERRIDE_REGISTER 25
62#define MV88E1XXX_EXT_PHY_SPECIFIC_CNTRL_2_REGISTER 26
63#define MV88E1XXX_EXT_PHY_SPECIFIC_STATUS_REGISTER 27
64#define MV88E1XXX_VIRTUAL_CABLE_TESTER_REGISTER 28
65#define MV88E1XXX_EXTENDED_ADDR_REGISTER 29
66#define MV88E1XXX_EXTENDED_REGISTER 30
67
68/* PHY specific control register fields */
69#define S_PSCR_MDI_XOVER_MODE 5
70#define M_PSCR_MDI_XOVER_MODE 0x3
71#define V_PSCR_MDI_XOVER_MODE(x) ((x) << S_PSCR_MDI_XOVER_MODE)
72#define G_PSCR_MDI_XOVER_MODE(x) (((x) >> S_PSCR_MDI_XOVER_MODE) & M_PSCR_MDI_XOVER_MODE)
73
74/* Extended PHY specific control register fields */
75#define S_DOWNSHIFT_ENABLE 8
76#define V_DOWNSHIFT_ENABLE (1 << S_DOWNSHIFT_ENABLE)
77
78#define S_DOWNSHIFT_CNT 9
79#define M_DOWNSHIFT_CNT 0x7
80#define V_DOWNSHIFT_CNT(x) ((x) << S_DOWNSHIFT_CNT)
81#define G_DOWNSHIFT_CNT(x) (((x) >> S_DOWNSHIFT_CNT) & M_DOWNSHIFT_CNT)
82
83/* PHY specific status register fields */
84#define S_PSSR_JABBER 0
85#define V_PSSR_JABBER (1 << S_PSSR_JABBER)
86
87#define S_PSSR_POLARITY 1
88#define V_PSSR_POLARITY (1 << S_PSSR_POLARITY)
89
90#define S_PSSR_RX_PAUSE 2
91#define V_PSSR_RX_PAUSE (1 << S_PSSR_RX_PAUSE)
92
93#define S_PSSR_TX_PAUSE 3
94#define V_PSSR_TX_PAUSE (1 << S_PSSR_TX_PAUSE)
95
96#define S_PSSR_ENERGY_DETECT 4
97#define V_PSSR_ENERGY_DETECT (1 << S_PSSR_ENERGY_DETECT)
98
99#define S_PSSR_DOWNSHIFT_STATUS 5
100#define V_PSSR_DOWNSHIFT_STATUS (1 << S_PSSR_DOWNSHIFT_STATUS)
101
102#define S_PSSR_MDI 6
103#define V_PSSR_MDI (1 << S_PSSR_MDI)
104
105#define S_PSSR_CABLE_LEN 7
106#define M_PSSR_CABLE_LEN 0x7
107#define V_PSSR_CABLE_LEN(x) ((x) << S_PSSR_CABLE_LEN)
108#define G_PSSR_CABLE_LEN(x) (((x) >> S_PSSR_CABLE_LEN) & M_PSSR_CABLE_LEN)
109
110#define S_PSSR_LINK 10
111#define V_PSSR_LINK (1 << S_PSSR_LINK)
112
113#define S_PSSR_STATUS_RESOLVED 11
114#define V_PSSR_STATUS_RESOLVED (1 << S_PSSR_STATUS_RESOLVED)
115
116#define S_PSSR_PAGE_RECEIVED 12
117#define V_PSSR_PAGE_RECEIVED (1 << S_PSSR_PAGE_RECEIVED)
118
119#define S_PSSR_DUPLEX 13
120#define V_PSSR_DUPLEX (1 << S_PSSR_DUPLEX)
121
122#define S_PSSR_SPEED 14
123#define M_PSSR_SPEED 0x3
124#define V_PSSR_SPEED(x) ((x) << S_PSSR_SPEED)
125#define G_PSSR_SPEED(x) (((x) >> S_PSSR_SPEED) & M_PSSR_SPEED)
126
127#endif
diff --git a/drivers/net/chelsio/mv88x201x.c b/drivers/net/chelsio/mv88x201x.c
index db5034282782..c8e89480d906 100644
--- a/drivers/net/chelsio/mv88x201x.c
+++ b/drivers/net/chelsio/mv88x201x.c
@@ -85,29 +85,33 @@ static int mv88x201x_reset(struct cphy *cphy, int wait)
85 85
86static int mv88x201x_interrupt_enable(struct cphy *cphy) 86static int mv88x201x_interrupt_enable(struct cphy *cphy)
87{ 87{
88 u32 elmer;
89
90 /* Enable PHY LASI interrupts. */ 88 /* Enable PHY LASI interrupts. */
91 mdio_write(cphy, 0x1, 0x9002, 0x1); 89 mdio_write(cphy, 0x1, 0x9002, 0x1);
92 90
93 /* Enable Marvell interrupts through Elmer0. */ 91 /* Enable Marvell interrupts through Elmer0. */
94 t1_tpi_read(cphy->adapter, A_ELMER0_INT_ENABLE, &elmer); 92 if (t1_is_asic(cphy->adapter)) {
95 elmer |= ELMER0_GP_BIT6; 93 u32 elmer;
96 t1_tpi_write(cphy->adapter, A_ELMER0_INT_ENABLE, elmer); 94
95 t1_tpi_read(cphy->adapter, A_ELMER0_INT_ENABLE, &elmer);
96 elmer |= ELMER0_GP_BIT6;
97 t1_tpi_write(cphy->adapter, A_ELMER0_INT_ENABLE, elmer);
98 }
97 return 0; 99 return 0;
98} 100}
99 101
100static int mv88x201x_interrupt_disable(struct cphy *cphy) 102static int mv88x201x_interrupt_disable(struct cphy *cphy)
101{ 103{
102 u32 elmer;
103
104 /* Disable PHY LASI interrupts. */ 104 /* Disable PHY LASI interrupts. */
105 mdio_write(cphy, 0x1, 0x9002, 0x0); 105 mdio_write(cphy, 0x1, 0x9002, 0x0);
106 106
107 /* Disable Marvell interrupts through Elmer0. */ 107 /* Disable Marvell interrupts through Elmer0. */
108 t1_tpi_read(cphy->adapter, A_ELMER0_INT_ENABLE, &elmer); 108 if (t1_is_asic(cphy->adapter)) {
109 elmer &= ~ELMER0_GP_BIT6; 109 u32 elmer;
110 t1_tpi_write(cphy->adapter, A_ELMER0_INT_ENABLE, elmer); 110
111 t1_tpi_read(cphy->adapter, A_ELMER0_INT_ENABLE, &elmer);
112 elmer &= ~ELMER0_GP_BIT6;
113 t1_tpi_write(cphy->adapter, A_ELMER0_INT_ENABLE, elmer);
114 }
111 return 0; 115 return 0;
112} 116}
113 117
@@ -140,9 +144,11 @@ static int mv88x201x_interrupt_clear(struct cphy *cphy)
140#endif 144#endif
141 145
142 /* Clear Marvell interrupts through Elmer0. */ 146 /* Clear Marvell interrupts through Elmer0. */
143 t1_tpi_read(cphy->adapter, A_ELMER0_INT_CAUSE, &elmer); 147 if (t1_is_asic(cphy->adapter)) {
144 elmer |= ELMER0_GP_BIT6; 148 t1_tpi_read(cphy->adapter, A_ELMER0_INT_CAUSE, &elmer);
145 t1_tpi_write(cphy->adapter, A_ELMER0_INT_CAUSE, elmer); 149 elmer |= ELMER0_GP_BIT6;
150 t1_tpi_write(cphy->adapter, A_ELMER0_INT_CAUSE, elmer);
151 }
146 return 0; 152 return 0;
147} 153}
148 154
@@ -205,11 +211,11 @@ static struct cphy *mv88x201x_phy_create(adapter_t *adapter, int phy_addr,
205 struct mdio_ops *mdio_ops) 211 struct mdio_ops *mdio_ops)
206{ 212{
207 u32 val; 213 u32 val;
208 struct cphy *cphy = kmalloc(sizeof(*cphy), GFP_KERNEL); 214 struct cphy *cphy = kzalloc(sizeof(*cphy), GFP_KERNEL);
209 215
210 if (!cphy) 216 if (!cphy)
211 return NULL; 217 return NULL;
212 memset(cphy, 0, sizeof(*cphy)); 218
213 cphy_init(cphy, adapter, phy_addr, &mv88x201x_ops, mdio_ops); 219 cphy_init(cphy, adapter, phy_addr, &mv88x201x_ops, mdio_ops);
214 220
215 /* Commands the PHY to enable XFP's clock. */ 221 /* Commands the PHY to enable XFP's clock. */
diff --git a/drivers/net/chelsio/my3126.c b/drivers/net/chelsio/my3126.c
new file mode 100644
index 000000000000..c7731b6f9de3
--- /dev/null
+++ b/drivers/net/chelsio/my3126.c
@@ -0,0 +1,206 @@
1/* $Date: 2005/11/12 02:13:49 $ $RCSfile: my3126.c,v $ $Revision: 1.15 $ */
2#include "cphy.h"
3#include "elmer0.h"
4#include "suni1x10gexp_regs.h"
5
6/* Port Reset */
7static int my3126_reset(struct cphy *cphy, int wait)
8{
9 /*
10 * This can be done through registers. It is not required since
11 * a full chip reset is used.
12 */
13 return (0);
14}
15
16static int my3126_interrupt_enable(struct cphy *cphy)
17{
18 schedule_delayed_work(&cphy->phy_update, HZ/30);
19 t1_tpi_read(cphy->adapter, A_ELMER0_GPO, &cphy->elmer_gpo);
20 return (0);
21}
22
23static int my3126_interrupt_disable(struct cphy *cphy)
24{
25 cancel_rearming_delayed_work(&cphy->phy_update);
26 return (0);
27}
28
29static int my3126_interrupt_clear(struct cphy *cphy)
30{
31 return (0);
32}
33
34#define OFFSET(REG_ADDR) (REG_ADDR << 2)
35
36static int my3126_interrupt_handler(struct cphy *cphy)
37{
38 u32 val;
39 u16 val16;
40 u16 status;
41 u32 act_count;
42 adapter_t *adapter;
43 adapter = cphy->adapter;
44
45 if (cphy->count == 50) {
46 mdio_read(cphy, 0x1, 0x1, &val);
47 val16 = (u16) val;
48 status = cphy->bmsr ^ val16;
49
50 if (status & BMSR_LSTATUS)
51 t1_link_changed(adapter, 0);
52 cphy->bmsr = val16;
53
54 /* We have only enabled link change interrupts so it
55 must be that
56 */
57 cphy->count = 0;
58 }
59
60 t1_tpi_write(adapter, OFFSET(SUNI1x10GEXP_REG_MSTAT_CONTROL),
61 SUNI1x10GEXP_BITMSK_MSTAT_SNAP);
62 t1_tpi_read(adapter,
63 OFFSET(SUNI1x10GEXP_REG_MSTAT_COUNTER_1_LOW), &act_count);
64 t1_tpi_read(adapter,
65 OFFSET(SUNI1x10GEXP_REG_MSTAT_COUNTER_33_LOW), &val);
66 act_count += val;
67
68 /* Populate elmer_gpo with the register value */
69 t1_tpi_read(adapter, A_ELMER0_GPO, &val);
70 cphy->elmer_gpo = val;
71
72 if ( (val & (1 << 8)) || (val & (1 << 19)) ||
73 (cphy->act_count == act_count) || cphy->act_on ) {
74 if (is_T2(adapter))
75 val |= (1 << 9);
76 else if (t1_is_T1B(adapter))
77 val |= (1 << 20);
78 cphy->act_on = 0;
79 } else {
80 if (is_T2(adapter))
81 val &= ~(1 << 9);
82 else if (t1_is_T1B(adapter))
83 val &= ~(1 << 20);
84 cphy->act_on = 1;
85 }
86
87 t1_tpi_write(adapter, A_ELMER0_GPO, val);
88
89 cphy->elmer_gpo = val;
90 cphy->act_count = act_count;
91 cphy->count++;
92
93 return cphy_cause_link_change;
94}
95
96static void my3216_poll(struct work_struct *work)
97{
98 struct cphy *cphy = container_of(work, struct cphy, phy_update.work);
99
100 my3126_interrupt_handler(cphy);
101}
102
103static int my3126_set_loopback(struct cphy *cphy, int on)
104{
105 return (0);
106}
107
108/* To check the activity LED */
109static int my3126_get_link_status(struct cphy *cphy,
110 int *link_ok, int *speed, int *duplex, int *fc)
111{
112 u32 val;
113 u16 val16;
114 adapter_t *adapter;
115
116 adapter = cphy->adapter;
117 mdio_read(cphy, 0x1, 0x1, &val);
118 val16 = (u16) val;
119
120 /* Populate elmer_gpo with the register value */
121 t1_tpi_read(adapter, A_ELMER0_GPO, &val);
122 cphy->elmer_gpo = val;
123
124 *link_ok = (val16 & BMSR_LSTATUS);
125
126 if (*link_ok) {
127 /* Turn on the LED. */
128 if (is_T2(adapter))
129 val &= ~(1 << 8);
130 else if (t1_is_T1B(adapter))
131 val &= ~(1 << 19);
132 } else {
133 /* Turn off the LED. */
134 if (is_T2(adapter))
135 val |= (1 << 8);
136 else if (t1_is_T1B(adapter))
137 val |= (1 << 19);
138 }
139
140 t1_tpi_write(adapter, A_ELMER0_GPO, val);
141 cphy->elmer_gpo = val;
142 *speed = SPEED_10000;
143 *duplex = DUPLEX_FULL;
144
145 /* need to add flow control */
146 if (fc)
147 *fc = PAUSE_RX | PAUSE_TX;
148
149 return (0);
150}
151
152static void my3126_destroy(struct cphy *cphy)
153{
154 kfree(cphy);
155}
156
157static struct cphy_ops my3126_ops = {
158 .destroy = my3126_destroy,
159 .reset = my3126_reset,
160 .interrupt_enable = my3126_interrupt_enable,
161 .interrupt_disable = my3126_interrupt_disable,
162 .interrupt_clear = my3126_interrupt_clear,
163 .interrupt_handler = my3126_interrupt_handler,
164 .get_link_status = my3126_get_link_status,
165 .set_loopback = my3126_set_loopback,
166};
167
168static struct cphy *my3126_phy_create(adapter_t *adapter,
169 int phy_addr, struct mdio_ops *mdio_ops)
170{
171 struct cphy *cphy = kzalloc(sizeof (*cphy), GFP_KERNEL);
172
173 if (cphy)
174 cphy_init(cphy, adapter, phy_addr, &my3126_ops, mdio_ops);
175
176 INIT_DELAYED_WORK(&cphy->phy_update, my3216_poll);
177 cphy->bmsr = 0;
178
179 return (cphy);
180}
181
182/* Chip Reset */
183static int my3126_phy_reset(adapter_t * adapter)
184{
185 u32 val;
186
187 t1_tpi_read(adapter, A_ELMER0_GPO, &val);
188 val &= ~4;
189 t1_tpi_write(adapter, A_ELMER0_GPO, val);
190 msleep(100);
191
192 t1_tpi_write(adapter, A_ELMER0_GPO, val | 4);
193 msleep(1000);
194
195 /* Now lets enable the Laser. Delay 100us */
196 t1_tpi_read(adapter, A_ELMER0_GPO, &val);
197 val |= 0x8000;
198 t1_tpi_write(adapter, A_ELMER0_GPO, val);
199 udelay(100);
200 return (0);
201}
202
203struct gphy t1_my3126_ops = {
204 my3126_phy_create,
205 my3126_phy_reset
206};
diff --git a/drivers/net/chelsio/pm3393.c b/drivers/net/chelsio/pm3393.c
index 04a1404fc65e..63cabeb98afe 100644
--- a/drivers/net/chelsio/pm3393.c
+++ b/drivers/net/chelsio/pm3393.c
@@ -43,21 +43,7 @@
43#include "elmer0.h" 43#include "elmer0.h"
44#include "suni1x10gexp_regs.h" 44#include "suni1x10gexp_regs.h"
45 45
46/* 802.3ae 10Gb/s MDIO Manageable Device(MMD) 46#include <linux/crc32.h>
47 */
48enum {
49 MMD_RESERVED,
50 MMD_PMAPMD,
51 MMD_WIS,
52 MMD_PCS,
53 MMD_PHY_XGXS, /* XGMII Extender Sublayer */
54 MMD_DTE_XGXS,
55};
56
57enum {
58 PHY_XGXS_CTRL_1,
59 PHY_XGXS_STATUS_1
60};
61 47
62#define OFFSET(REG_ADDR) (REG_ADDR << 2) 48#define OFFSET(REG_ADDR) (REG_ADDR << 2)
63 49
@@ -88,6 +74,8 @@ enum { /* RMON registers */
88 RxJabbers = SUNI1x10GEXP_REG_MSTAT_COUNTER_16_LOW, 74 RxJabbers = SUNI1x10GEXP_REG_MSTAT_COUNTER_16_LOW,
89 RxFragments = SUNI1x10GEXP_REG_MSTAT_COUNTER_17_LOW, 75 RxFragments = SUNI1x10GEXP_REG_MSTAT_COUNTER_17_LOW,
90 RxUndersizedFrames = SUNI1x10GEXP_REG_MSTAT_COUNTER_18_LOW, 76 RxUndersizedFrames = SUNI1x10GEXP_REG_MSTAT_COUNTER_18_LOW,
77 RxJumboFramesReceivedOK = SUNI1x10GEXP_REG_MSTAT_COUNTER_25_LOW,
78 RxJumboOctetsReceivedOK = SUNI1x10GEXP_REG_MSTAT_COUNTER_26_LOW,
91 79
92 TxOctetsTransmittedOK = SUNI1x10GEXP_REG_MSTAT_COUNTER_33_LOW, 80 TxOctetsTransmittedOK = SUNI1x10GEXP_REG_MSTAT_COUNTER_33_LOW,
93 TxFramesLostDueToInternalMACTransmissionError = SUNI1x10GEXP_REG_MSTAT_COUNTER_35_LOW, 81 TxFramesLostDueToInternalMACTransmissionError = SUNI1x10GEXP_REG_MSTAT_COUNTER_35_LOW,
@@ -95,7 +83,9 @@ enum { /* RMON registers */
95 TxUnicastFramesTransmittedOK = SUNI1x10GEXP_REG_MSTAT_COUNTER_38_LOW, 83 TxUnicastFramesTransmittedOK = SUNI1x10GEXP_REG_MSTAT_COUNTER_38_LOW,
96 TxMulticastFramesTransmittedOK = SUNI1x10GEXP_REG_MSTAT_COUNTER_40_LOW, 84 TxMulticastFramesTransmittedOK = SUNI1x10GEXP_REG_MSTAT_COUNTER_40_LOW,
97 TxBroadcastFramesTransmittedOK = SUNI1x10GEXP_REG_MSTAT_COUNTER_42_LOW, 85 TxBroadcastFramesTransmittedOK = SUNI1x10GEXP_REG_MSTAT_COUNTER_42_LOW,
98 TxPAUSEMACCtrlFramesTransmitted = SUNI1x10GEXP_REG_MSTAT_COUNTER_43_LOW 86 TxPAUSEMACCtrlFramesTransmitted = SUNI1x10GEXP_REG_MSTAT_COUNTER_43_LOW,
87 TxJumboFramesReceivedOK = SUNI1x10GEXP_REG_MSTAT_COUNTER_51_LOW,
88 TxJumboOctetsReceivedOK = SUNI1x10GEXP_REG_MSTAT_COUNTER_52_LOW
99}; 89};
100 90
101struct _cmac_instance { 91struct _cmac_instance {
@@ -124,12 +114,12 @@ static int pm3393_reset(struct cmac *cmac)
124 114
125/* 115/*
126 * Enable interrupts for the PM3393 116 * Enable interrupts for the PM3393
127 117 *
128 1. Enable PM3393 BLOCK interrupts. 118 * 1. Enable PM3393 BLOCK interrupts.
129 2. Enable PM3393 Master Interrupt bit(INTE) 119 * 2. Enable PM3393 Master Interrupt bit(INTE)
130 3. Enable ELMER's PM3393 bit. 120 * 3. Enable ELMER's PM3393 bit.
131 4. Enable Terminator external interrupt. 121 * 4. Enable Terminator external interrupt.
132*/ 122 */
133static int pm3393_interrupt_enable(struct cmac *cmac) 123static int pm3393_interrupt_enable(struct cmac *cmac)
134{ 124{
135 u32 pl_intr; 125 u32 pl_intr;
@@ -257,14 +247,12 @@ static int pm3393_interrupt_clear(struct cmac *cmac)
257static int pm3393_interrupt_handler(struct cmac *cmac) 247static int pm3393_interrupt_handler(struct cmac *cmac)
258{ 248{
259 u32 master_intr_status; 249 u32 master_intr_status;
260/* 250
261 1. Read master interrupt register.
262 2. Read BLOCK's interrupt status registers.
263 3. Handle BLOCK interrupts.
264*/
265 /* Read the master interrupt status register. */ 251 /* Read the master interrupt status register. */
266 pmread(cmac, SUNI1x10GEXP_REG_MASTER_INTERRUPT_STATUS, 252 pmread(cmac, SUNI1x10GEXP_REG_MASTER_INTERRUPT_STATUS,
267 &master_intr_status); 253 &master_intr_status);
254 CH_DBG(cmac->adapter, INTR, "PM3393 intr cause 0x%x\n",
255 master_intr_status);
268 256
269 /* TBD XXX Lets just clear everything for now */ 257 /* TBD XXX Lets just clear everything for now */
270 pm3393_interrupt_clear(cmac); 258 pm3393_interrupt_clear(cmac);
@@ -307,11 +295,7 @@ static int pm3393_enable_port(struct cmac *cmac, int which)
307 * The PHY doesn't give us link status indication on its own so have 295 * The PHY doesn't give us link status indication on its own so have
308 * the link management code query it instead. 296 * the link management code query it instead.
309 */ 297 */
310 { 298 t1_link_changed(cmac->adapter, 0);
311 extern void link_changed(adapter_t *adapter, int port_id);
312
313 link_changed(cmac->adapter, 0);
314 }
315 return 0; 299 return 0;
316} 300}
317 301
@@ -363,33 +347,6 @@ static int pm3393_set_mtu(struct cmac *cmac, int mtu)
363 return 0; 347 return 0;
364} 348}
365 349
366static u32 calc_crc(u8 *b, int len)
367{
368 int i;
369 u32 crc = (u32)~0;
370
371 /* calculate crc one bit at a time */
372 while (len--) {
373 crc ^= *b++;
374 for (i = 0; i < 8; i++) {
375 if (crc & 0x1)
376 crc = (crc >> 1) ^ 0xedb88320;
377 else
378 crc = (crc >> 1);
379 }
380 }
381
382 /* reverse bits */
383 crc = ((crc >> 4) & 0x0f0f0f0f) | ((crc << 4) & 0xf0f0f0f0);
384 crc = ((crc >> 2) & 0x33333333) | ((crc << 2) & 0xcccccccc);
385 crc = ((crc >> 1) & 0x55555555) | ((crc << 1) & 0xaaaaaaaa);
386 /* swap bytes */
387 crc = (crc >> 16) | (crc << 16);
388 crc = (crc >> 8 & 0x00ff00ff) | (crc << 8 & 0xff00ff00);
389
390 return crc;
391}
392
393static int pm3393_set_rx_mode(struct cmac *cmac, struct t1_rx_mode *rm) 350static int pm3393_set_rx_mode(struct cmac *cmac, struct t1_rx_mode *rm)
394{ 351{
395 int enabled = cmac->instance->enabled & MAC_DIRECTION_RX; 352 int enabled = cmac->instance->enabled & MAC_DIRECTION_RX;
@@ -423,7 +380,7 @@ static int pm3393_set_rx_mode(struct cmac *cmac, struct t1_rx_mode *rm)
423 u16 mc_filter[4] = { 0, }; 380 u16 mc_filter[4] = { 0, };
424 381
425 while ((addr = t1_get_next_mcaddr(rm))) { 382 while ((addr = t1_get_next_mcaddr(rm))) {
426 bit = (calc_crc(addr, ETH_ALEN) >> 23) & 0x3f; /* bit[23:28] */ 383 bit = (ether_crc(ETH_ALEN, addr) >> 23) & 0x3f; /* bit[23:28] */
427 mc_filter[bit >> 4] |= 1 << (bit & 0xf); 384 mc_filter[bit >> 4] |= 1 << (bit & 0xf);
428 } 385 }
429 pmwrite(cmac, SUNI1x10GEXP_REG_RXXG_MULTICAST_HASH_LOW, mc_filter[0]); 386 pmwrite(cmac, SUNI1x10GEXP_REG_RXXG_MULTICAST_HASH_LOW, mc_filter[0]);
@@ -471,20 +428,29 @@ static int pm3393_set_speed_duplex_fc(struct cmac *cmac, int speed, int duplex,
471 return 0; 428 return 0;
472} 429}
473 430
431static void pm3393_rmon_update(struct adapter *adapter, u32 offs, u64 *val,
432 int over)
433{
434 u32 val0, val1, val2;
435
436 t1_tpi_read(adapter, offs, &val0);
437 t1_tpi_read(adapter, offs + 4, &val1);
438 t1_tpi_read(adapter, offs + 8, &val2);
439
440 *val &= ~0ull << 40;
441 *val |= val0 & 0xffff;
442 *val |= (val1 & 0xffff) << 16;
443 *val |= (u64)(val2 & 0xff) << 32;
444
445 if (over)
446 *val += 1ull << 40;
447}
448
474#define RMON_UPDATE(mac, name, stat_name) \ 449#define RMON_UPDATE(mac, name, stat_name) \
475 { \ 450 pm3393_rmon_update((mac)->adapter, OFFSET(name), \
476 t1_tpi_read((mac)->adapter, OFFSET(name), &val0); \ 451 &(mac)->stats.stat_name, \
477 t1_tpi_read((mac)->adapter, OFFSET(((name)+1)), &val1); \ 452 (ro &((name - SUNI1x10GEXP_REG_MSTAT_COUNTER_0_LOW) >> 2)))
478 t1_tpi_read((mac)->adapter, OFFSET(((name)+2)), &val2); \ 453
479 (mac)->stats.stat_name = ((u64)val0 & 0xffff) | \
480 (((u64)val1 & 0xffff) << 16) | \
481 (((u64)val2 & 0xff) << 32) | \
482 ((mac)->stats.stat_name & \
483 (~(u64)0 << 40)); \
484 if (ro & \
485 ((name - SUNI1x10GEXP_REG_MSTAT_COUNTER_0_LOW) >> 2)) \
486 (mac)->stats.stat_name += ((u64)1 << 40); \
487 }
488 454
489static const struct cmac_statistics *pm3393_update_statistics(struct cmac *mac, 455static const struct cmac_statistics *pm3393_update_statistics(struct cmac *mac,
490 int flag) 456 int flag)
@@ -519,6 +485,8 @@ static const struct cmac_statistics *pm3393_update_statistics(struct cmac *mac,
519 RMON_UPDATE(mac, RxJabbers, RxJabberErrors); 485 RMON_UPDATE(mac, RxJabbers, RxJabberErrors);
520 RMON_UPDATE(mac, RxFragments, RxRuntErrors); 486 RMON_UPDATE(mac, RxFragments, RxRuntErrors);
521 RMON_UPDATE(mac, RxUndersizedFrames, RxRuntErrors); 487 RMON_UPDATE(mac, RxUndersizedFrames, RxRuntErrors);
488 RMON_UPDATE(mac, RxJumboFramesReceivedOK, RxJumboFramesOK);
489 RMON_UPDATE(mac, RxJumboOctetsReceivedOK, RxJumboOctetsOK);
522 490
523 /* Tx stats */ 491 /* Tx stats */
524 RMON_UPDATE(mac, TxOctetsTransmittedOK, TxOctetsOK); 492 RMON_UPDATE(mac, TxOctetsTransmittedOK, TxOctetsOK);
@@ -529,6 +497,8 @@ static const struct cmac_statistics *pm3393_update_statistics(struct cmac *mac,
529 RMON_UPDATE(mac, TxMulticastFramesTransmittedOK, TxMulticastFramesOK); 497 RMON_UPDATE(mac, TxMulticastFramesTransmittedOK, TxMulticastFramesOK);
530 RMON_UPDATE(mac, TxBroadcastFramesTransmittedOK, TxBroadcastFramesOK); 498 RMON_UPDATE(mac, TxBroadcastFramesTransmittedOK, TxBroadcastFramesOK);
531 RMON_UPDATE(mac, TxPAUSEMACCtrlFramesTransmitted, TxPauseFrames); 499 RMON_UPDATE(mac, TxPAUSEMACCtrlFramesTransmitted, TxPauseFrames);
500 RMON_UPDATE(mac, TxJumboFramesReceivedOK, TxJumboFramesOK);
501 RMON_UPDATE(mac, TxJumboOctetsReceivedOK, TxJumboOctetsOK);
532 502
533 return &mac->stats; 503 return &mac->stats;
534} 504}
@@ -631,10 +601,9 @@ static struct cmac *pm3393_mac_create(adapter_t *adapter, int index)
631{ 601{
632 struct cmac *cmac; 602 struct cmac *cmac;
633 603
634 cmac = kmalloc(sizeof(*cmac) + sizeof(cmac_instance), GFP_KERNEL); 604 cmac = kzalloc(sizeof(*cmac) + sizeof(cmac_instance), GFP_KERNEL);
635 if (!cmac) 605 if (!cmac)
636 return NULL; 606 return NULL;
637 memset(cmac, 0, sizeof(*cmac));
638 607
639 cmac->ops = &pm3393_ops; 608 cmac->ops = &pm3393_ops;
640 cmac->instance = (cmac_instance *) (cmac + 1); 609 cmac->instance = (cmac_instance *) (cmac + 1);
@@ -815,6 +784,12 @@ static int pm3393_mac_reset(adapter_t * adapter)
815 784
816 successful_reset = (is_pl4_reset_finished && !is_pl4_outof_lock 785 successful_reset = (is_pl4_reset_finished && !is_pl4_outof_lock
817 && is_xaui_mabc_pll_locked); 786 && is_xaui_mabc_pll_locked);
787
788 CH_DBG(adapter, HW,
789 "PM3393 HW reset %d: pl4_reset 0x%x, val 0x%x, "
790 "is_pl4_outof_lock 0x%x, xaui_locked 0x%x\n",
791 i, is_pl4_reset_finished, val, is_pl4_outof_lock,
792 is_xaui_mabc_pll_locked);
818 } 793 }
819 return successful_reset ? 0 : 1; 794 return successful_reset ? 0 : 1;
820} 795}
diff --git a/drivers/net/chelsio/regs.h b/drivers/net/chelsio/regs.h
index b90e11f40d1f..c80bf4d6d0a6 100644
--- a/drivers/net/chelsio/regs.h
+++ b/drivers/net/chelsio/regs.h
@@ -71,6 +71,10 @@
71#define V_CMDQ_PRIORITY(x) ((x) << S_CMDQ_PRIORITY) 71#define V_CMDQ_PRIORITY(x) ((x) << S_CMDQ_PRIORITY)
72#define G_CMDQ_PRIORITY(x) (((x) >> S_CMDQ_PRIORITY) & M_CMDQ_PRIORITY) 72#define G_CMDQ_PRIORITY(x) (((x) >> S_CMDQ_PRIORITY) & M_CMDQ_PRIORITY)
73 73
74#define S_DISABLE_CMDQ0_GTS 8
75#define V_DISABLE_CMDQ0_GTS(x) ((x) << S_DISABLE_CMDQ0_GTS)
76#define F_DISABLE_CMDQ0_GTS V_DISABLE_CMDQ0_GTS(1U)
77
74#define S_DISABLE_CMDQ1_GTS 9 78#define S_DISABLE_CMDQ1_GTS 9
75#define V_DISABLE_CMDQ1_GTS(x) ((x) << S_DISABLE_CMDQ1_GTS) 79#define V_DISABLE_CMDQ1_GTS(x) ((x) << S_DISABLE_CMDQ1_GTS)
76#define F_DISABLE_CMDQ1_GTS V_DISABLE_CMDQ1_GTS(1U) 80#define F_DISABLE_CMDQ1_GTS V_DISABLE_CMDQ1_GTS(1U)
@@ -87,12 +91,18 @@
87#define V_ENABLE_BIG_ENDIAN(x) ((x) << S_ENABLE_BIG_ENDIAN) 91#define V_ENABLE_BIG_ENDIAN(x) ((x) << S_ENABLE_BIG_ENDIAN)
88#define F_ENABLE_BIG_ENDIAN V_ENABLE_BIG_ENDIAN(1U) 92#define F_ENABLE_BIG_ENDIAN V_ENABLE_BIG_ENDIAN(1U)
89 93
94#define S_FL_SELECTION_CRITERIA 13
95#define V_FL_SELECTION_CRITERIA(x) ((x) << S_FL_SELECTION_CRITERIA)
96#define F_FL_SELECTION_CRITERIA V_FL_SELECTION_CRITERIA(1U)
97
90#define S_ISCSI_COALESCE 14 98#define S_ISCSI_COALESCE 14
91#define V_ISCSI_COALESCE(x) ((x) << S_ISCSI_COALESCE) 99#define V_ISCSI_COALESCE(x) ((x) << S_ISCSI_COALESCE)
92#define F_ISCSI_COALESCE V_ISCSI_COALESCE(1U) 100#define F_ISCSI_COALESCE V_ISCSI_COALESCE(1U)
93 101
94#define S_RX_PKT_OFFSET 15 102#define S_RX_PKT_OFFSET 15
103#define M_RX_PKT_OFFSET 0x7
95#define V_RX_PKT_OFFSET(x) ((x) << S_RX_PKT_OFFSET) 104#define V_RX_PKT_OFFSET(x) ((x) << S_RX_PKT_OFFSET)
105#define G_RX_PKT_OFFSET(x) (((x) >> S_RX_PKT_OFFSET) & M_RX_PKT_OFFSET)
96 106
97#define S_VLAN_XTRACT 18 107#define S_VLAN_XTRACT 18
98#define V_VLAN_XTRACT(x) ((x) << S_VLAN_XTRACT) 108#define V_VLAN_XTRACT(x) ((x) << S_VLAN_XTRACT)
@@ -108,16 +118,114 @@
108#define A_SG_FL1BASELWR 0x20 118#define A_SG_FL1BASELWR 0x20
109#define A_SG_FL1BASEUPR 0x24 119#define A_SG_FL1BASEUPR 0x24
110#define A_SG_CMD0SIZE 0x28 120#define A_SG_CMD0SIZE 0x28
121
122#define S_CMDQ0_SIZE 0
123#define M_CMDQ0_SIZE 0x1ffff
124#define V_CMDQ0_SIZE(x) ((x) << S_CMDQ0_SIZE)
125#define G_CMDQ0_SIZE(x) (((x) >> S_CMDQ0_SIZE) & M_CMDQ0_SIZE)
126
111#define A_SG_FL0SIZE 0x2c 127#define A_SG_FL0SIZE 0x2c
128
129#define S_FL0_SIZE 0
130#define M_FL0_SIZE 0x1ffff
131#define V_FL0_SIZE(x) ((x) << S_FL0_SIZE)
132#define G_FL0_SIZE(x) (((x) >> S_FL0_SIZE) & M_FL0_SIZE)
133
112#define A_SG_RSPSIZE 0x30 134#define A_SG_RSPSIZE 0x30
135
136#define S_RESPQ_SIZE 0
137#define M_RESPQ_SIZE 0x1ffff
138#define V_RESPQ_SIZE(x) ((x) << S_RESPQ_SIZE)
139#define G_RESPQ_SIZE(x) (((x) >> S_RESPQ_SIZE) & M_RESPQ_SIZE)
140
113#define A_SG_RSPBASELWR 0x34 141#define A_SG_RSPBASELWR 0x34
114#define A_SG_RSPBASEUPR 0x38 142#define A_SG_RSPBASEUPR 0x38
115#define A_SG_FLTHRESHOLD 0x3c 143#define A_SG_FLTHRESHOLD 0x3c
144
145#define S_FL_THRESHOLD 0
146#define M_FL_THRESHOLD 0xffff
147#define V_FL_THRESHOLD(x) ((x) << S_FL_THRESHOLD)
148#define G_FL_THRESHOLD(x) (((x) >> S_FL_THRESHOLD) & M_FL_THRESHOLD)
149
116#define A_SG_RSPQUEUECREDIT 0x40 150#define A_SG_RSPQUEUECREDIT 0x40
151
152#define S_RESPQ_CREDIT 0
153#define M_RESPQ_CREDIT 0x1ffff
154#define V_RESPQ_CREDIT(x) ((x) << S_RESPQ_CREDIT)
155#define G_RESPQ_CREDIT(x) (((x) >> S_RESPQ_CREDIT) & M_RESPQ_CREDIT)
156
117#define A_SG_SLEEPING 0x48 157#define A_SG_SLEEPING 0x48
158
159#define S_SLEEPING 0
160#define M_SLEEPING 0xffff
161#define V_SLEEPING(x) ((x) << S_SLEEPING)
162#define G_SLEEPING(x) (((x) >> S_SLEEPING) & M_SLEEPING)
163
118#define A_SG_INTRTIMER 0x4c 164#define A_SG_INTRTIMER 0x4c
165
166#define S_INTERRUPT_TIMER_COUNT 0
167#define M_INTERRUPT_TIMER_COUNT 0xffffff
168#define V_INTERRUPT_TIMER_COUNT(x) ((x) << S_INTERRUPT_TIMER_COUNT)
169#define G_INTERRUPT_TIMER_COUNT(x) (((x) >> S_INTERRUPT_TIMER_COUNT) & M_INTERRUPT_TIMER_COUNT)
170
171#define A_SG_CMD0PTR 0x50
172
173#define S_CMDQ0_POINTER 0
174#define M_CMDQ0_POINTER 0xffff
175#define V_CMDQ0_POINTER(x) ((x) << S_CMDQ0_POINTER)
176#define G_CMDQ0_POINTER(x) (((x) >> S_CMDQ0_POINTER) & M_CMDQ0_POINTER)
177
178#define S_CURRENT_GENERATION_BIT 16
179#define V_CURRENT_GENERATION_BIT(x) ((x) << S_CURRENT_GENERATION_BIT)
180#define F_CURRENT_GENERATION_BIT V_CURRENT_GENERATION_BIT(1U)
181
182#define A_SG_CMD1PTR 0x54
183
184#define S_CMDQ1_POINTER 0
185#define M_CMDQ1_POINTER 0xffff
186#define V_CMDQ1_POINTER(x) ((x) << S_CMDQ1_POINTER)
187#define G_CMDQ1_POINTER(x) (((x) >> S_CMDQ1_POINTER) & M_CMDQ1_POINTER)
188
189#define A_SG_FL0PTR 0x58
190
191#define S_FL0_POINTER 0
192#define M_FL0_POINTER 0xffff
193#define V_FL0_POINTER(x) ((x) << S_FL0_POINTER)
194#define G_FL0_POINTER(x) (((x) >> S_FL0_POINTER) & M_FL0_POINTER)
195
196#define A_SG_FL1PTR 0x5c
197
198#define S_FL1_POINTER 0
199#define M_FL1_POINTER 0xffff
200#define V_FL1_POINTER(x) ((x) << S_FL1_POINTER)
201#define G_FL1_POINTER(x) (((x) >> S_FL1_POINTER) & M_FL1_POINTER)
202
203#define A_SG_VERSION 0x6c
204
205#define S_DAY 0
206#define M_DAY 0x1f
207#define V_DAY(x) ((x) << S_DAY)
208#define G_DAY(x) (((x) >> S_DAY) & M_DAY)
209
210#define S_MONTH 5
211#define M_MONTH 0xf
212#define V_MONTH(x) ((x) << S_MONTH)
213#define G_MONTH(x) (((x) >> S_MONTH) & M_MONTH)
214
119#define A_SG_CMD1SIZE 0xb0 215#define A_SG_CMD1SIZE 0xb0
216
217#define S_CMDQ1_SIZE 0
218#define M_CMDQ1_SIZE 0x1ffff
219#define V_CMDQ1_SIZE(x) ((x) << S_CMDQ1_SIZE)
220#define G_CMDQ1_SIZE(x) (((x) >> S_CMDQ1_SIZE) & M_CMDQ1_SIZE)
221
120#define A_SG_FL1SIZE 0xb4 222#define A_SG_FL1SIZE 0xb4
223
224#define S_FL1_SIZE 0
225#define M_FL1_SIZE 0x1ffff
226#define V_FL1_SIZE(x) ((x) << S_FL1_SIZE)
227#define G_FL1_SIZE(x) (((x) >> S_FL1_SIZE) & M_FL1_SIZE)
228
121#define A_SG_INT_ENABLE 0xb8 229#define A_SG_INT_ENABLE 0xb8
122 230
123#define S_RESPQ_EXHAUSTED 0 231#define S_RESPQ_EXHAUSTED 0
@@ -144,21 +252,369 @@
144#define A_SG_RESPACCUTIMER 0xc0 252#define A_SG_RESPACCUTIMER 0xc0
145 253
146/* MC3 registers */ 254/* MC3 registers */
255#define A_MC3_CFG 0x100
256
257#define S_CLK_ENABLE 0
258#define V_CLK_ENABLE(x) ((x) << S_CLK_ENABLE)
259#define F_CLK_ENABLE V_CLK_ENABLE(1U)
147 260
148#define S_READY 1 261#define S_READY 1
149#define V_READY(x) ((x) << S_READY) 262#define V_READY(x) ((x) << S_READY)
150#define F_READY V_READY(1U) 263#define F_READY V_READY(1U)
151 264
152/* MC4 registers */ 265#define S_READ_TO_WRITE_DELAY 2
266#define M_READ_TO_WRITE_DELAY 0x7
267#define V_READ_TO_WRITE_DELAY(x) ((x) << S_READ_TO_WRITE_DELAY)
268#define G_READ_TO_WRITE_DELAY(x) (((x) >> S_READ_TO_WRITE_DELAY) & M_READ_TO_WRITE_DELAY)
269
270#define S_WRITE_TO_READ_DELAY 5
271#define M_WRITE_TO_READ_DELAY 0x7
272#define V_WRITE_TO_READ_DELAY(x) ((x) << S_WRITE_TO_READ_DELAY)
273#define G_WRITE_TO_READ_DELAY(x) (((x) >> S_WRITE_TO_READ_DELAY) & M_WRITE_TO_READ_DELAY)
153 274
275#define S_MC3_BANK_CYCLE 8
276#define M_MC3_BANK_CYCLE 0xf
277#define V_MC3_BANK_CYCLE(x) ((x) << S_MC3_BANK_CYCLE)
278#define G_MC3_BANK_CYCLE(x) (((x) >> S_MC3_BANK_CYCLE) & M_MC3_BANK_CYCLE)
279
280#define S_REFRESH_CYCLE 12
281#define M_REFRESH_CYCLE 0xf
282#define V_REFRESH_CYCLE(x) ((x) << S_REFRESH_CYCLE)
283#define G_REFRESH_CYCLE(x) (((x) >> S_REFRESH_CYCLE) & M_REFRESH_CYCLE)
284
285#define S_PRECHARGE_CYCLE 16
286#define M_PRECHARGE_CYCLE 0x3
287#define V_PRECHARGE_CYCLE(x) ((x) << S_PRECHARGE_CYCLE)
288#define G_PRECHARGE_CYCLE(x) (((x) >> S_PRECHARGE_CYCLE) & M_PRECHARGE_CYCLE)
289
290#define S_ACTIVE_TO_READ_WRITE_DELAY 18
291#define V_ACTIVE_TO_READ_WRITE_DELAY(x) ((x) << S_ACTIVE_TO_READ_WRITE_DELAY)
292#define F_ACTIVE_TO_READ_WRITE_DELAY V_ACTIVE_TO_READ_WRITE_DELAY(1U)
293
294#define S_ACTIVE_TO_PRECHARGE_DELAY 19
295#define M_ACTIVE_TO_PRECHARGE_DELAY 0x7
296#define V_ACTIVE_TO_PRECHARGE_DELAY(x) ((x) << S_ACTIVE_TO_PRECHARGE_DELAY)
297#define G_ACTIVE_TO_PRECHARGE_DELAY(x) (((x) >> S_ACTIVE_TO_PRECHARGE_DELAY) & M_ACTIVE_TO_PRECHARGE_DELAY)
298
299#define S_WRITE_RECOVERY_DELAY 22
300#define M_WRITE_RECOVERY_DELAY 0x3
301#define V_WRITE_RECOVERY_DELAY(x) ((x) << S_WRITE_RECOVERY_DELAY)
302#define G_WRITE_RECOVERY_DELAY(x) (((x) >> S_WRITE_RECOVERY_DELAY) & M_WRITE_RECOVERY_DELAY)
303
304#define S_DENSITY 24
305#define M_DENSITY 0x3
306#define V_DENSITY(x) ((x) << S_DENSITY)
307#define G_DENSITY(x) (((x) >> S_DENSITY) & M_DENSITY)
308
309#define S_ORGANIZATION 26
310#define V_ORGANIZATION(x) ((x) << S_ORGANIZATION)
311#define F_ORGANIZATION V_ORGANIZATION(1U)
312
313#define S_BANKS 27
314#define V_BANKS(x) ((x) << S_BANKS)
315#define F_BANKS V_BANKS(1U)
316
317#define S_UNREGISTERED 28
318#define V_UNREGISTERED(x) ((x) << S_UNREGISTERED)
319#define F_UNREGISTERED V_UNREGISTERED(1U)
320
321#define S_MC3_WIDTH 29
322#define M_MC3_WIDTH 0x3
323#define V_MC3_WIDTH(x) ((x) << S_MC3_WIDTH)
324#define G_MC3_WIDTH(x) (((x) >> S_MC3_WIDTH) & M_MC3_WIDTH)
325
326#define S_MC3_SLOW 31
327#define V_MC3_SLOW(x) ((x) << S_MC3_SLOW)
328#define F_MC3_SLOW V_MC3_SLOW(1U)
329
330#define A_MC3_MODE 0x104
331
332#define S_MC3_MODE 0
333#define M_MC3_MODE 0x3fff
334#define V_MC3_MODE(x) ((x) << S_MC3_MODE)
335#define G_MC3_MODE(x) (((x) >> S_MC3_MODE) & M_MC3_MODE)
336
337#define S_BUSY 31
338#define V_BUSY(x) ((x) << S_BUSY)
339#define F_BUSY V_BUSY(1U)
340
341#define A_MC3_EXT_MODE 0x108
342
343#define S_MC3_EXTENDED_MODE 0
344#define M_MC3_EXTENDED_MODE 0x3fff
345#define V_MC3_EXTENDED_MODE(x) ((x) << S_MC3_EXTENDED_MODE)
346#define G_MC3_EXTENDED_MODE(x) (((x) >> S_MC3_EXTENDED_MODE) & M_MC3_EXTENDED_MODE)
347
348#define A_MC3_PRECHARG 0x10c
349#define A_MC3_REFRESH 0x110
350
351#define S_REFRESH_ENABLE 0
352#define V_REFRESH_ENABLE(x) ((x) << S_REFRESH_ENABLE)
353#define F_REFRESH_ENABLE V_REFRESH_ENABLE(1U)
354
355#define S_REFRESH_DIVISOR 1
356#define M_REFRESH_DIVISOR 0x3fff
357#define V_REFRESH_DIVISOR(x) ((x) << S_REFRESH_DIVISOR)
358#define G_REFRESH_DIVISOR(x) (((x) >> S_REFRESH_DIVISOR) & M_REFRESH_DIVISOR)
359
360#define A_MC3_STROBE 0x114
361
362#define S_MASTER_DLL_RESET 0
363#define V_MASTER_DLL_RESET(x) ((x) << S_MASTER_DLL_RESET)
364#define F_MASTER_DLL_RESET V_MASTER_DLL_RESET(1U)
365
366#define S_MASTER_DLL_TAP_COUNT 1
367#define M_MASTER_DLL_TAP_COUNT 0xff
368#define V_MASTER_DLL_TAP_COUNT(x) ((x) << S_MASTER_DLL_TAP_COUNT)
369#define G_MASTER_DLL_TAP_COUNT(x) (((x) >> S_MASTER_DLL_TAP_COUNT) & M_MASTER_DLL_TAP_COUNT)
370
371#define S_MASTER_DLL_LOCKED 9
372#define V_MASTER_DLL_LOCKED(x) ((x) << S_MASTER_DLL_LOCKED)
373#define F_MASTER_DLL_LOCKED V_MASTER_DLL_LOCKED(1U)
374
375#define S_MASTER_DLL_MAX_TAP_COUNT 10
376#define V_MASTER_DLL_MAX_TAP_COUNT(x) ((x) << S_MASTER_DLL_MAX_TAP_COUNT)
377#define F_MASTER_DLL_MAX_TAP_COUNT V_MASTER_DLL_MAX_TAP_COUNT(1U)
378
379#define S_MASTER_DLL_TAP_COUNT_OFFSET 11
380#define M_MASTER_DLL_TAP_COUNT_OFFSET 0x3f
381#define V_MASTER_DLL_TAP_COUNT_OFFSET(x) ((x) << S_MASTER_DLL_TAP_COUNT_OFFSET)
382#define G_MASTER_DLL_TAP_COUNT_OFFSET(x) (((x) >> S_MASTER_DLL_TAP_COUNT_OFFSET) & M_MASTER_DLL_TAP_COUNT_OFFSET)
383
384#define S_SLAVE_DLL_RESET 11
385#define V_SLAVE_DLL_RESET(x) ((x) << S_SLAVE_DLL_RESET)
386#define F_SLAVE_DLL_RESET V_SLAVE_DLL_RESET(1U)
387
388#define S_SLAVE_DLL_DELTA 12
389#define M_SLAVE_DLL_DELTA 0xf
390#define V_SLAVE_DLL_DELTA(x) ((x) << S_SLAVE_DLL_DELTA)
391#define G_SLAVE_DLL_DELTA(x) (((x) >> S_SLAVE_DLL_DELTA) & M_SLAVE_DLL_DELTA)
392
393#define S_SLAVE_DELAY_LINE_MANUAL_TAP_COUNT 17
394#define M_SLAVE_DELAY_LINE_MANUAL_TAP_COUNT 0x3f
395#define V_SLAVE_DELAY_LINE_MANUAL_TAP_COUNT(x) ((x) << S_SLAVE_DELAY_LINE_MANUAL_TAP_COUNT)
396#define G_SLAVE_DELAY_LINE_MANUAL_TAP_COUNT(x) (((x) >> S_SLAVE_DELAY_LINE_MANUAL_TAP_COUNT) & M_SLAVE_DELAY_LINE_MANUAL_TAP_COUNT)
397
398#define S_SLAVE_DELAY_LINE_MANUAL_TAP_COUNT_ENABLE 23
399#define V_SLAVE_DELAY_LINE_MANUAL_TAP_COUNT_ENABLE(x) ((x) << S_SLAVE_DELAY_LINE_MANUAL_TAP_COUNT_ENABLE)
400#define F_SLAVE_DELAY_LINE_MANUAL_TAP_COUNT_ENABLE V_SLAVE_DELAY_LINE_MANUAL_TAP_COUNT_ENABLE(1U)
401
402#define S_SLAVE_DELAY_LINE_TAP_COUNT 24
403#define M_SLAVE_DELAY_LINE_TAP_COUNT 0x3f
404#define V_SLAVE_DELAY_LINE_TAP_COUNT(x) ((x) << S_SLAVE_DELAY_LINE_TAP_COUNT)
405#define G_SLAVE_DELAY_LINE_TAP_COUNT(x) (((x) >> S_SLAVE_DELAY_LINE_TAP_COUNT) & M_SLAVE_DELAY_LINE_TAP_COUNT)
406
407#define A_MC3_ECC_CNTL 0x118
408
409#define S_ECC_GENERATION_ENABLE 0
410#define V_ECC_GENERATION_ENABLE(x) ((x) << S_ECC_GENERATION_ENABLE)
411#define F_ECC_GENERATION_ENABLE V_ECC_GENERATION_ENABLE(1U)
412
413#define S_ECC_CHECK_ENABLE 1
414#define V_ECC_CHECK_ENABLE(x) ((x) << S_ECC_CHECK_ENABLE)
415#define F_ECC_CHECK_ENABLE V_ECC_CHECK_ENABLE(1U)
416
417#define S_CORRECTABLE_ERROR_COUNT 2
418#define M_CORRECTABLE_ERROR_COUNT 0xff
419#define V_CORRECTABLE_ERROR_COUNT(x) ((x) << S_CORRECTABLE_ERROR_COUNT)
420#define G_CORRECTABLE_ERROR_COUNT(x) (((x) >> S_CORRECTABLE_ERROR_COUNT) & M_CORRECTABLE_ERROR_COUNT)
421
422#define S_UNCORRECTABLE_ERROR_COUNT 10
423#define M_UNCORRECTABLE_ERROR_COUNT 0xff
424#define V_UNCORRECTABLE_ERROR_COUNT(x) ((x) << S_UNCORRECTABLE_ERROR_COUNT)
425#define G_UNCORRECTABLE_ERROR_COUNT(x) (((x) >> S_UNCORRECTABLE_ERROR_COUNT) & M_UNCORRECTABLE_ERROR_COUNT)
426
427#define A_MC3_CE_ADDR 0x11c
428
429#define S_MC3_CE_ADDR 4
430#define M_MC3_CE_ADDR 0xfffffff
431#define V_MC3_CE_ADDR(x) ((x) << S_MC3_CE_ADDR)
432#define G_MC3_CE_ADDR(x) (((x) >> S_MC3_CE_ADDR) & M_MC3_CE_ADDR)
433
434#define A_MC3_CE_DATA0 0x120
435#define A_MC3_CE_DATA1 0x124
436#define A_MC3_CE_DATA2 0x128
437#define A_MC3_CE_DATA3 0x12c
438#define A_MC3_CE_DATA4 0x130
439#define A_MC3_UE_ADDR 0x134
440
441#define S_MC3_UE_ADDR 4
442#define M_MC3_UE_ADDR 0xfffffff
443#define V_MC3_UE_ADDR(x) ((x) << S_MC3_UE_ADDR)
444#define G_MC3_UE_ADDR(x) (((x) >> S_MC3_UE_ADDR) & M_MC3_UE_ADDR)
445
446#define A_MC3_UE_DATA0 0x138
447#define A_MC3_UE_DATA1 0x13c
448#define A_MC3_UE_DATA2 0x140
449#define A_MC3_UE_DATA3 0x144
450#define A_MC3_UE_DATA4 0x148
451#define A_MC3_BD_ADDR 0x14c
452#define A_MC3_BD_DATA0 0x150
453#define A_MC3_BD_DATA1 0x154
454#define A_MC3_BD_DATA2 0x158
455#define A_MC3_BD_DATA3 0x15c
456#define A_MC3_BD_DATA4 0x160
457#define A_MC3_BD_OP 0x164
458
459#define S_BACK_DOOR_OPERATION 0
460#define V_BACK_DOOR_OPERATION(x) ((x) << S_BACK_DOOR_OPERATION)
461#define F_BACK_DOOR_OPERATION V_BACK_DOOR_OPERATION(1U)
462
463#define A_MC3_BIST_ADDR_BEG 0x168
464#define A_MC3_BIST_ADDR_END 0x16c
465#define A_MC3_BIST_DATA 0x170
466#define A_MC3_BIST_OP 0x174
467
468#define S_OP 0
469#define V_OP(x) ((x) << S_OP)
470#define F_OP V_OP(1U)
471
472#define S_DATA_PATTERN 1
473#define M_DATA_PATTERN 0x3
474#define V_DATA_PATTERN(x) ((x) << S_DATA_PATTERN)
475#define G_DATA_PATTERN(x) (((x) >> S_DATA_PATTERN) & M_DATA_PATTERN)
476
477#define S_CONTINUOUS 3
478#define V_CONTINUOUS(x) ((x) << S_CONTINUOUS)
479#define F_CONTINUOUS V_CONTINUOUS(1U)
480
481#define A_MC3_INT_ENABLE 0x178
482
483#define S_MC3_CORR_ERR 0
484#define V_MC3_CORR_ERR(x) ((x) << S_MC3_CORR_ERR)
485#define F_MC3_CORR_ERR V_MC3_CORR_ERR(1U)
486
487#define S_MC3_UNCORR_ERR 1
488#define V_MC3_UNCORR_ERR(x) ((x) << S_MC3_UNCORR_ERR)
489#define F_MC3_UNCORR_ERR V_MC3_UNCORR_ERR(1U)
490
491#define S_MC3_PARITY_ERR 2
492#define M_MC3_PARITY_ERR 0xff
493#define V_MC3_PARITY_ERR(x) ((x) << S_MC3_PARITY_ERR)
494#define G_MC3_PARITY_ERR(x) (((x) >> S_MC3_PARITY_ERR) & M_MC3_PARITY_ERR)
495
496#define S_MC3_ADDR_ERR 10
497#define V_MC3_ADDR_ERR(x) ((x) << S_MC3_ADDR_ERR)
498#define F_MC3_ADDR_ERR V_MC3_ADDR_ERR(1U)
499
500#define A_MC3_INT_CAUSE 0x17c
501
502/* MC4 registers */
154#define A_MC4_CFG 0x180 503#define A_MC4_CFG 0x180
504
505#define S_POWER_UP 0
506#define V_POWER_UP(x) ((x) << S_POWER_UP)
507#define F_POWER_UP V_POWER_UP(1U)
508
509#define S_MC4_BANK_CYCLE 8
510#define M_MC4_BANK_CYCLE 0x7
511#define V_MC4_BANK_CYCLE(x) ((x) << S_MC4_BANK_CYCLE)
512#define G_MC4_BANK_CYCLE(x) (((x) >> S_MC4_BANK_CYCLE) & M_MC4_BANK_CYCLE)
513
514#define S_MC4_NARROW 24
515#define V_MC4_NARROW(x) ((x) << S_MC4_NARROW)
516#define F_MC4_NARROW V_MC4_NARROW(1U)
517
155#define S_MC4_SLOW 25 518#define S_MC4_SLOW 25
156#define V_MC4_SLOW(x) ((x) << S_MC4_SLOW) 519#define V_MC4_SLOW(x) ((x) << S_MC4_SLOW)
157#define F_MC4_SLOW V_MC4_SLOW(1U) 520#define F_MC4_SLOW V_MC4_SLOW(1U)
158 521
159/* TPI registers */ 522#define S_MC4A_WIDTH 24
523#define M_MC4A_WIDTH 0x3
524#define V_MC4A_WIDTH(x) ((x) << S_MC4A_WIDTH)
525#define G_MC4A_WIDTH(x) (((x) >> S_MC4A_WIDTH) & M_MC4A_WIDTH)
526
527#define S_MC4A_SLOW 26
528#define V_MC4A_SLOW(x) ((x) << S_MC4A_SLOW)
529#define F_MC4A_SLOW V_MC4A_SLOW(1U)
530
531#define A_MC4_MODE 0x184
532
533#define S_MC4_MODE 0
534#define M_MC4_MODE 0x7fff
535#define V_MC4_MODE(x) ((x) << S_MC4_MODE)
536#define G_MC4_MODE(x) (((x) >> S_MC4_MODE) & M_MC4_MODE)
537
538#define A_MC4_EXT_MODE 0x188
539
540#define S_MC4_EXTENDED_MODE 0
541#define M_MC4_EXTENDED_MODE 0x7fff
542#define V_MC4_EXTENDED_MODE(x) ((x) << S_MC4_EXTENDED_MODE)
543#define G_MC4_EXTENDED_MODE(x) (((x) >> S_MC4_EXTENDED_MODE) & M_MC4_EXTENDED_MODE)
544
545#define A_MC4_REFRESH 0x190
546#define A_MC4_STROBE 0x194
547#define A_MC4_ECC_CNTL 0x198
548#define A_MC4_CE_ADDR 0x19c
549
550#define S_MC4_CE_ADDR 4
551#define M_MC4_CE_ADDR 0xffffff
552#define V_MC4_CE_ADDR(x) ((x) << S_MC4_CE_ADDR)
553#define G_MC4_CE_ADDR(x) (((x) >> S_MC4_CE_ADDR) & M_MC4_CE_ADDR)
554
555#define A_MC4_CE_DATA0 0x1a0
556#define A_MC4_CE_DATA1 0x1a4
557#define A_MC4_CE_DATA2 0x1a8
558#define A_MC4_CE_DATA3 0x1ac
559#define A_MC4_CE_DATA4 0x1b0
560#define A_MC4_UE_ADDR 0x1b4
561
562#define S_MC4_UE_ADDR 4
563#define M_MC4_UE_ADDR 0xffffff
564#define V_MC4_UE_ADDR(x) ((x) << S_MC4_UE_ADDR)
565#define G_MC4_UE_ADDR(x) (((x) >> S_MC4_UE_ADDR) & M_MC4_UE_ADDR)
566
567#define A_MC4_UE_DATA0 0x1b8
568#define A_MC4_UE_DATA1 0x1bc
569#define A_MC4_UE_DATA2 0x1c0
570#define A_MC4_UE_DATA3 0x1c4
571#define A_MC4_UE_DATA4 0x1c8
572#define A_MC4_BD_ADDR 0x1cc
573
574#define S_MC4_BACK_DOOR_ADDR 0
575#define M_MC4_BACK_DOOR_ADDR 0xfffffff
576#define V_MC4_BACK_DOOR_ADDR(x) ((x) << S_MC4_BACK_DOOR_ADDR)
577#define G_MC4_BACK_DOOR_ADDR(x) (((x) >> S_MC4_BACK_DOOR_ADDR) & M_MC4_BACK_DOOR_ADDR)
578
579#define A_MC4_BD_DATA0 0x1d0
580#define A_MC4_BD_DATA1 0x1d4
581#define A_MC4_BD_DATA2 0x1d8
582#define A_MC4_BD_DATA3 0x1dc
583#define A_MC4_BD_DATA4 0x1e0
584#define A_MC4_BD_OP 0x1e4
585
586#define S_OPERATION 0
587#define V_OPERATION(x) ((x) << S_OPERATION)
588#define F_OPERATION V_OPERATION(1U)
589
590#define A_MC4_BIST_ADDR_BEG 0x1e8
591#define A_MC4_BIST_ADDR_END 0x1ec
592#define A_MC4_BIST_DATA 0x1f0
593#define A_MC4_BIST_OP 0x1f4
594#define A_MC4_INT_ENABLE 0x1f8
595
596#define S_MC4_CORR_ERR 0
597#define V_MC4_CORR_ERR(x) ((x) << S_MC4_CORR_ERR)
598#define F_MC4_CORR_ERR V_MC4_CORR_ERR(1U)
599
600#define S_MC4_UNCORR_ERR 1
601#define V_MC4_UNCORR_ERR(x) ((x) << S_MC4_UNCORR_ERR)
602#define F_MC4_UNCORR_ERR V_MC4_UNCORR_ERR(1U)
603
604#define S_MC4_ADDR_ERR 2
605#define V_MC4_ADDR_ERR(x) ((x) << S_MC4_ADDR_ERR)
606#define F_MC4_ADDR_ERR V_MC4_ADDR_ERR(1U)
607
608#define A_MC4_INT_CAUSE 0x1fc
160 609
610/* TPI registers */
161#define A_TPI_ADDR 0x280 611#define A_TPI_ADDR 0x280
612
613#define S_TPI_ADDRESS 0
614#define M_TPI_ADDRESS 0xffffff
615#define V_TPI_ADDRESS(x) ((x) << S_TPI_ADDRESS)
616#define G_TPI_ADDRESS(x) (((x) >> S_TPI_ADDRESS) & M_TPI_ADDRESS)
617
162#define A_TPI_WR_DATA 0x284 618#define A_TPI_WR_DATA 0x284
163#define A_TPI_RD_DATA 0x288 619#define A_TPI_RD_DATA 0x288
164#define A_TPI_CSR 0x28c 620#define A_TPI_CSR 0x28c
@@ -171,6 +627,10 @@
171#define V_TPIRDY(x) ((x) << S_TPIRDY) 627#define V_TPIRDY(x) ((x) << S_TPIRDY)
172#define F_TPIRDY V_TPIRDY(1U) 628#define F_TPIRDY V_TPIRDY(1U)
173 629
630#define S_INT_DIR 31
631#define V_INT_DIR(x) ((x) << S_INT_DIR)
632#define F_INT_DIR V_INT_DIR(1U)
633
174#define A_TPI_PAR 0x29c 634#define A_TPI_PAR 0x29c
175 635
176#define S_TPIPAR 0 636#define S_TPIPAR 0
@@ -178,14 +638,26 @@
178#define V_TPIPAR(x) ((x) << S_TPIPAR) 638#define V_TPIPAR(x) ((x) << S_TPIPAR)
179#define G_TPIPAR(x) (((x) >> S_TPIPAR) & M_TPIPAR) 639#define G_TPIPAR(x) (((x) >> S_TPIPAR) & M_TPIPAR)
180 640
181/* TP registers */
182 641
642/* TP registers */
183#define A_TP_IN_CONFIG 0x300 643#define A_TP_IN_CONFIG 0x300
184 644
645#define S_TP_IN_CSPI_TUNNEL 0
646#define V_TP_IN_CSPI_TUNNEL(x) ((x) << S_TP_IN_CSPI_TUNNEL)
647#define F_TP_IN_CSPI_TUNNEL V_TP_IN_CSPI_TUNNEL(1U)
648
649#define S_TP_IN_CSPI_ETHERNET 1
650#define V_TP_IN_CSPI_ETHERNET(x) ((x) << S_TP_IN_CSPI_ETHERNET)
651#define F_TP_IN_CSPI_ETHERNET V_TP_IN_CSPI_ETHERNET(1U)
652
185#define S_TP_IN_CSPI_CPL 3 653#define S_TP_IN_CSPI_CPL 3
186#define V_TP_IN_CSPI_CPL(x) ((x) << S_TP_IN_CSPI_CPL) 654#define V_TP_IN_CSPI_CPL(x) ((x) << S_TP_IN_CSPI_CPL)
187#define F_TP_IN_CSPI_CPL V_TP_IN_CSPI_CPL(1U) 655#define F_TP_IN_CSPI_CPL V_TP_IN_CSPI_CPL(1U)
188 656
657#define S_TP_IN_CSPI_POS 4
658#define V_TP_IN_CSPI_POS(x) ((x) << S_TP_IN_CSPI_POS)
659#define F_TP_IN_CSPI_POS V_TP_IN_CSPI_POS(1U)
660
189#define S_TP_IN_CSPI_CHECK_IP_CSUM 5 661#define S_TP_IN_CSPI_CHECK_IP_CSUM 5
190#define V_TP_IN_CSPI_CHECK_IP_CSUM(x) ((x) << S_TP_IN_CSPI_CHECK_IP_CSUM) 662#define V_TP_IN_CSPI_CHECK_IP_CSUM(x) ((x) << S_TP_IN_CSPI_CHECK_IP_CSUM)
191#define F_TP_IN_CSPI_CHECK_IP_CSUM V_TP_IN_CSPI_CHECK_IP_CSUM(1U) 663#define F_TP_IN_CSPI_CHECK_IP_CSUM V_TP_IN_CSPI_CHECK_IP_CSUM(1U)
@@ -194,10 +666,22 @@
194#define V_TP_IN_CSPI_CHECK_TCP_CSUM(x) ((x) << S_TP_IN_CSPI_CHECK_TCP_CSUM) 666#define V_TP_IN_CSPI_CHECK_TCP_CSUM(x) ((x) << S_TP_IN_CSPI_CHECK_TCP_CSUM)
195#define F_TP_IN_CSPI_CHECK_TCP_CSUM V_TP_IN_CSPI_CHECK_TCP_CSUM(1U) 667#define F_TP_IN_CSPI_CHECK_TCP_CSUM V_TP_IN_CSPI_CHECK_TCP_CSUM(1U)
196 668
669#define S_TP_IN_ESPI_TUNNEL 7
670#define V_TP_IN_ESPI_TUNNEL(x) ((x) << S_TP_IN_ESPI_TUNNEL)
671#define F_TP_IN_ESPI_TUNNEL V_TP_IN_ESPI_TUNNEL(1U)
672
197#define S_TP_IN_ESPI_ETHERNET 8 673#define S_TP_IN_ESPI_ETHERNET 8
198#define V_TP_IN_ESPI_ETHERNET(x) ((x) << S_TP_IN_ESPI_ETHERNET) 674#define V_TP_IN_ESPI_ETHERNET(x) ((x) << S_TP_IN_ESPI_ETHERNET)
199#define F_TP_IN_ESPI_ETHERNET V_TP_IN_ESPI_ETHERNET(1U) 675#define F_TP_IN_ESPI_ETHERNET V_TP_IN_ESPI_ETHERNET(1U)
200 676
677#define S_TP_IN_ESPI_CPL 10
678#define V_TP_IN_ESPI_CPL(x) ((x) << S_TP_IN_ESPI_CPL)
679#define F_TP_IN_ESPI_CPL V_TP_IN_ESPI_CPL(1U)
680
681#define S_TP_IN_ESPI_POS 11
682#define V_TP_IN_ESPI_POS(x) ((x) << S_TP_IN_ESPI_POS)
683#define F_TP_IN_ESPI_POS V_TP_IN_ESPI_POS(1U)
684
201#define S_TP_IN_ESPI_CHECK_IP_CSUM 12 685#define S_TP_IN_ESPI_CHECK_IP_CSUM 12
202#define V_TP_IN_ESPI_CHECK_IP_CSUM(x) ((x) << S_TP_IN_ESPI_CHECK_IP_CSUM) 686#define V_TP_IN_ESPI_CHECK_IP_CSUM(x) ((x) << S_TP_IN_ESPI_CHECK_IP_CSUM)
203#define F_TP_IN_ESPI_CHECK_IP_CSUM V_TP_IN_ESPI_CHECK_IP_CSUM(1U) 687#define F_TP_IN_ESPI_CHECK_IP_CSUM V_TP_IN_ESPI_CHECK_IP_CSUM(1U)
@@ -212,14 +696,42 @@
212 696
213#define A_TP_OUT_CONFIG 0x304 697#define A_TP_OUT_CONFIG 0x304
214 698
699#define S_TP_OUT_C_ETH 0
700#define V_TP_OUT_C_ETH(x) ((x) << S_TP_OUT_C_ETH)
701#define F_TP_OUT_C_ETH V_TP_OUT_C_ETH(1U)
702
215#define S_TP_OUT_CSPI_CPL 2 703#define S_TP_OUT_CSPI_CPL 2
216#define V_TP_OUT_CSPI_CPL(x) ((x) << S_TP_OUT_CSPI_CPL) 704#define V_TP_OUT_CSPI_CPL(x) ((x) << S_TP_OUT_CSPI_CPL)
217#define F_TP_OUT_CSPI_CPL V_TP_OUT_CSPI_CPL(1U) 705#define F_TP_OUT_CSPI_CPL V_TP_OUT_CSPI_CPL(1U)
218 706
707#define S_TP_OUT_CSPI_POS 3
708#define V_TP_OUT_CSPI_POS(x) ((x) << S_TP_OUT_CSPI_POS)
709#define F_TP_OUT_CSPI_POS V_TP_OUT_CSPI_POS(1U)
710
711#define S_TP_OUT_CSPI_GENERATE_IP_CSUM 4
712#define V_TP_OUT_CSPI_GENERATE_IP_CSUM(x) ((x) << S_TP_OUT_CSPI_GENERATE_IP_CSUM)
713#define F_TP_OUT_CSPI_GENERATE_IP_CSUM V_TP_OUT_CSPI_GENERATE_IP_CSUM(1U)
714
715#define S_TP_OUT_CSPI_GENERATE_TCP_CSUM 5
716#define V_TP_OUT_CSPI_GENERATE_TCP_CSUM(x) ((x) << S_TP_OUT_CSPI_GENERATE_TCP_CSUM)
717#define F_TP_OUT_CSPI_GENERATE_TCP_CSUM V_TP_OUT_CSPI_GENERATE_TCP_CSUM(1U)
718
219#define S_TP_OUT_ESPI_ETHERNET 6 719#define S_TP_OUT_ESPI_ETHERNET 6
220#define V_TP_OUT_ESPI_ETHERNET(x) ((x) << S_TP_OUT_ESPI_ETHERNET) 720#define V_TP_OUT_ESPI_ETHERNET(x) ((x) << S_TP_OUT_ESPI_ETHERNET)
221#define F_TP_OUT_ESPI_ETHERNET V_TP_OUT_ESPI_ETHERNET(1U) 721#define F_TP_OUT_ESPI_ETHERNET V_TP_OUT_ESPI_ETHERNET(1U)
222 722
723#define S_TP_OUT_ESPI_TAG_ETHERNET 7
724#define V_TP_OUT_ESPI_TAG_ETHERNET(x) ((x) << S_TP_OUT_ESPI_TAG_ETHERNET)
725#define F_TP_OUT_ESPI_TAG_ETHERNET V_TP_OUT_ESPI_TAG_ETHERNET(1U)
726
727#define S_TP_OUT_ESPI_CPL 8
728#define V_TP_OUT_ESPI_CPL(x) ((x) << S_TP_OUT_ESPI_CPL)
729#define F_TP_OUT_ESPI_CPL V_TP_OUT_ESPI_CPL(1U)
730
731#define S_TP_OUT_ESPI_POS 9
732#define V_TP_OUT_ESPI_POS(x) ((x) << S_TP_OUT_ESPI_POS)
733#define F_TP_OUT_ESPI_POS V_TP_OUT_ESPI_POS(1U)
734
223#define S_TP_OUT_ESPI_GENERATE_IP_CSUM 10 735#define S_TP_OUT_ESPI_GENERATE_IP_CSUM 10
224#define V_TP_OUT_ESPI_GENERATE_IP_CSUM(x) ((x) << S_TP_OUT_ESPI_GENERATE_IP_CSUM) 736#define V_TP_OUT_ESPI_GENERATE_IP_CSUM(x) ((x) << S_TP_OUT_ESPI_GENERATE_IP_CSUM)
225#define F_TP_OUT_ESPI_GENERATE_IP_CSUM V_TP_OUT_ESPI_GENERATE_IP_CSUM(1U) 737#define F_TP_OUT_ESPI_GENERATE_IP_CSUM V_TP_OUT_ESPI_GENERATE_IP_CSUM(1U)
@@ -233,6 +745,16 @@
233#define S_IP_TTL 0 745#define S_IP_TTL 0
234#define M_IP_TTL 0xff 746#define M_IP_TTL 0xff
235#define V_IP_TTL(x) ((x) << S_IP_TTL) 747#define V_IP_TTL(x) ((x) << S_IP_TTL)
748#define G_IP_TTL(x) (((x) >> S_IP_TTL) & M_IP_TTL)
749
750#define S_TCAM_SERVER_REGION_USAGE 8
751#define M_TCAM_SERVER_REGION_USAGE 0x3
752#define V_TCAM_SERVER_REGION_USAGE(x) ((x) << S_TCAM_SERVER_REGION_USAGE)
753#define G_TCAM_SERVER_REGION_USAGE(x) (((x) >> S_TCAM_SERVER_REGION_USAGE) & M_TCAM_SERVER_REGION_USAGE)
754
755#define S_QOS_MAPPING 10
756#define V_QOS_MAPPING(x) ((x) << S_QOS_MAPPING)
757#define F_QOS_MAPPING V_QOS_MAPPING(1U)
236 758
237#define S_TCP_CSUM 11 759#define S_TCP_CSUM 11
238#define V_TCP_CSUM(x) ((x) << S_TCP_CSUM) 760#define V_TCP_CSUM(x) ((x) << S_TCP_CSUM)
@@ -246,31 +768,476 @@
246#define V_IP_CSUM(x) ((x) << S_IP_CSUM) 768#define V_IP_CSUM(x) ((x) << S_IP_CSUM)
247#define F_IP_CSUM V_IP_CSUM(1U) 769#define F_IP_CSUM V_IP_CSUM(1U)
248 770
771#define S_IP_ID_SPLIT 14
772#define V_IP_ID_SPLIT(x) ((x) << S_IP_ID_SPLIT)
773#define F_IP_ID_SPLIT V_IP_ID_SPLIT(1U)
774
249#define S_PATH_MTU 15 775#define S_PATH_MTU 15
250#define V_PATH_MTU(x) ((x) << S_PATH_MTU) 776#define V_PATH_MTU(x) ((x) << S_PATH_MTU)
251#define F_PATH_MTU V_PATH_MTU(1U) 777#define F_PATH_MTU V_PATH_MTU(1U)
252 778
253#define S_5TUPLE_LOOKUP 17 779#define S_5TUPLE_LOOKUP 17
780#define M_5TUPLE_LOOKUP 0x3
254#define V_5TUPLE_LOOKUP(x) ((x) << S_5TUPLE_LOOKUP) 781#define V_5TUPLE_LOOKUP(x) ((x) << S_5TUPLE_LOOKUP)
782#define G_5TUPLE_LOOKUP(x) (((x) >> S_5TUPLE_LOOKUP) & M_5TUPLE_LOOKUP)
783
784#define S_IP_FRAGMENT_DROP 19
785#define V_IP_FRAGMENT_DROP(x) ((x) << S_IP_FRAGMENT_DROP)
786#define F_IP_FRAGMENT_DROP V_IP_FRAGMENT_DROP(1U)
787
788#define S_PING_DROP 20
789#define V_PING_DROP(x) ((x) << S_PING_DROP)
790#define F_PING_DROP V_PING_DROP(1U)
791
792#define S_PROTECT_MODE 21
793#define V_PROTECT_MODE(x) ((x) << S_PROTECT_MODE)
794#define F_PROTECT_MODE V_PROTECT_MODE(1U)
795
796#define S_SYN_COOKIE_ALGORITHM 22
797#define V_SYN_COOKIE_ALGORITHM(x) ((x) << S_SYN_COOKIE_ALGORITHM)
798#define F_SYN_COOKIE_ALGORITHM V_SYN_COOKIE_ALGORITHM(1U)
799
800#define S_ATTACK_FILTER 23
801#define V_ATTACK_FILTER(x) ((x) << S_ATTACK_FILTER)
802#define F_ATTACK_FILTER V_ATTACK_FILTER(1U)
803
804#define S_INTERFACE_TYPE 24
805#define V_INTERFACE_TYPE(x) ((x) << S_INTERFACE_TYPE)
806#define F_INTERFACE_TYPE V_INTERFACE_TYPE(1U)
807
808#define S_DISABLE_RX_FLOW_CONTROL 25
809#define V_DISABLE_RX_FLOW_CONTROL(x) ((x) << S_DISABLE_RX_FLOW_CONTROL)
810#define F_DISABLE_RX_FLOW_CONTROL V_DISABLE_RX_FLOW_CONTROL(1U)
255 811
256#define S_SYN_COOKIE_PARAMETER 26 812#define S_SYN_COOKIE_PARAMETER 26
813#define M_SYN_COOKIE_PARAMETER 0x3f
257#define V_SYN_COOKIE_PARAMETER(x) ((x) << S_SYN_COOKIE_PARAMETER) 814#define V_SYN_COOKIE_PARAMETER(x) ((x) << S_SYN_COOKIE_PARAMETER)
815#define G_SYN_COOKIE_PARAMETER(x) (((x) >> S_SYN_COOKIE_PARAMETER) & M_SYN_COOKIE_PARAMETER)
816
817#define A_TP_GLOBAL_RX_CREDITS 0x30c
818#define A_TP_CM_SIZE 0x310
819#define A_TP_CM_MM_BASE 0x314
820
821#define S_CM_MEMMGR_BASE 0
822#define M_CM_MEMMGR_BASE 0xfffffff
823#define V_CM_MEMMGR_BASE(x) ((x) << S_CM_MEMMGR_BASE)
824#define G_CM_MEMMGR_BASE(x) (((x) >> S_CM_MEMMGR_BASE) & M_CM_MEMMGR_BASE)
825
826#define A_TP_CM_TIMER_BASE 0x318
827
828#define S_CM_TIMER_BASE 0
829#define M_CM_TIMER_BASE 0xfffffff
830#define V_CM_TIMER_BASE(x) ((x) << S_CM_TIMER_BASE)
831#define G_CM_TIMER_BASE(x) (((x) >> S_CM_TIMER_BASE) & M_CM_TIMER_BASE)
832
833#define A_TP_PM_SIZE 0x31c
834#define A_TP_PM_TX_BASE 0x320
835#define A_TP_PM_DEFRAG_BASE 0x324
836#define A_TP_PM_RX_BASE 0x328
837#define A_TP_PM_RX_PG_SIZE 0x32c
838#define A_TP_PM_RX_MAX_PGS 0x330
839#define A_TP_PM_TX_PG_SIZE 0x334
840#define A_TP_PM_TX_MAX_PGS 0x338
841#define A_TP_TCP_OPTIONS 0x340
842
843#define S_TIMESTAMP 0
844#define M_TIMESTAMP 0x3
845#define V_TIMESTAMP(x) ((x) << S_TIMESTAMP)
846#define G_TIMESTAMP(x) (((x) >> S_TIMESTAMP) & M_TIMESTAMP)
847
848#define S_WINDOW_SCALE 2
849#define M_WINDOW_SCALE 0x3
850#define V_WINDOW_SCALE(x) ((x) << S_WINDOW_SCALE)
851#define G_WINDOW_SCALE(x) (((x) >> S_WINDOW_SCALE) & M_WINDOW_SCALE)
852
853#define S_SACK 4
854#define M_SACK 0x3
855#define V_SACK(x) ((x) << S_SACK)
856#define G_SACK(x) (((x) >> S_SACK) & M_SACK)
857
858#define S_ECN 6
859#define M_ECN 0x3
860#define V_ECN(x) ((x) << S_ECN)
861#define G_ECN(x) (((x) >> S_ECN) & M_ECN)
862
863#define S_SACK_ALGORITHM 8
864#define M_SACK_ALGORITHM 0x3
865#define V_SACK_ALGORITHM(x) ((x) << S_SACK_ALGORITHM)
866#define G_SACK_ALGORITHM(x) (((x) >> S_SACK_ALGORITHM) & M_SACK_ALGORITHM)
867
868#define S_MSS 10
869#define V_MSS(x) ((x) << S_MSS)
870#define F_MSS V_MSS(1U)
871
872#define S_DEFAULT_PEER_MSS 16
873#define M_DEFAULT_PEER_MSS 0xffff
874#define V_DEFAULT_PEER_MSS(x) ((x) << S_DEFAULT_PEER_MSS)
875#define G_DEFAULT_PEER_MSS(x) (((x) >> S_DEFAULT_PEER_MSS) & M_DEFAULT_PEER_MSS)
876
877#define A_TP_DACK_CONFIG 0x344
878
879#define S_DACK_MODE 0
880#define V_DACK_MODE(x) ((x) << S_DACK_MODE)
881#define F_DACK_MODE V_DACK_MODE(1U)
882
883#define S_DACK_AUTO_MGMT 1
884#define V_DACK_AUTO_MGMT(x) ((x) << S_DACK_AUTO_MGMT)
885#define F_DACK_AUTO_MGMT V_DACK_AUTO_MGMT(1U)
886
887#define S_DACK_AUTO_CAREFUL 2
888#define V_DACK_AUTO_CAREFUL(x) ((x) << S_DACK_AUTO_CAREFUL)
889#define F_DACK_AUTO_CAREFUL V_DACK_AUTO_CAREFUL(1U)
890
891#define S_DACK_MSS_SELECTOR 3
892#define M_DACK_MSS_SELECTOR 0x3
893#define V_DACK_MSS_SELECTOR(x) ((x) << S_DACK_MSS_SELECTOR)
894#define G_DACK_MSS_SELECTOR(x) (((x) >> S_DACK_MSS_SELECTOR) & M_DACK_MSS_SELECTOR)
895
896#define S_DACK_BYTE_THRESHOLD 5
897#define M_DACK_BYTE_THRESHOLD 0xfffff
898#define V_DACK_BYTE_THRESHOLD(x) ((x) << S_DACK_BYTE_THRESHOLD)
899#define G_DACK_BYTE_THRESHOLD(x) (((x) >> S_DACK_BYTE_THRESHOLD) & M_DACK_BYTE_THRESHOLD)
258 900
259#define A_TP_PC_CONFIG 0x348 901#define A_TP_PC_CONFIG 0x348
902
903#define S_TP_ACCESS_LATENCY 0
904#define M_TP_ACCESS_LATENCY 0xf
905#define V_TP_ACCESS_LATENCY(x) ((x) << S_TP_ACCESS_LATENCY)
906#define G_TP_ACCESS_LATENCY(x) (((x) >> S_TP_ACCESS_LATENCY) & M_TP_ACCESS_LATENCY)
907
908#define S_HELD_FIN_DISABLE 4
909#define V_HELD_FIN_DISABLE(x) ((x) << S_HELD_FIN_DISABLE)
910#define F_HELD_FIN_DISABLE V_HELD_FIN_DISABLE(1U)
911
912#define S_DDP_FC_ENABLE 5
913#define V_DDP_FC_ENABLE(x) ((x) << S_DDP_FC_ENABLE)
914#define F_DDP_FC_ENABLE V_DDP_FC_ENABLE(1U)
915
916#define S_RDMA_ERR_ENABLE 6
917#define V_RDMA_ERR_ENABLE(x) ((x) << S_RDMA_ERR_ENABLE)
918#define F_RDMA_ERR_ENABLE V_RDMA_ERR_ENABLE(1U)
919
920#define S_FAST_PDU_DELIVERY 7
921#define V_FAST_PDU_DELIVERY(x) ((x) << S_FAST_PDU_DELIVERY)
922#define F_FAST_PDU_DELIVERY V_FAST_PDU_DELIVERY(1U)
923
924#define S_CLEAR_FIN 8
925#define V_CLEAR_FIN(x) ((x) << S_CLEAR_FIN)
926#define F_CLEAR_FIN V_CLEAR_FIN(1U)
927
260#define S_DIS_TX_FILL_WIN_PUSH 12 928#define S_DIS_TX_FILL_WIN_PUSH 12
261#define V_DIS_TX_FILL_WIN_PUSH(x) ((x) << S_DIS_TX_FILL_WIN_PUSH) 929#define V_DIS_TX_FILL_WIN_PUSH(x) ((x) << S_DIS_TX_FILL_WIN_PUSH)
262#define F_DIS_TX_FILL_WIN_PUSH V_DIS_TX_FILL_WIN_PUSH(1U) 930#define F_DIS_TX_FILL_WIN_PUSH V_DIS_TX_FILL_WIN_PUSH(1U)
263 931
264#define S_TP_PC_REV 30 932#define S_TP_PC_REV 30
265#define M_TP_PC_REV 0x3 933#define M_TP_PC_REV 0x3
934#define V_TP_PC_REV(x) ((x) << S_TP_PC_REV)
266#define G_TP_PC_REV(x) (((x) >> S_TP_PC_REV) & M_TP_PC_REV) 935#define G_TP_PC_REV(x) (((x) >> S_TP_PC_REV) & M_TP_PC_REV)
936
937#define A_TP_BACKOFF0 0x350
938
939#define S_ELEMENT0 0
940#define M_ELEMENT0 0xff
941#define V_ELEMENT0(x) ((x) << S_ELEMENT0)
942#define G_ELEMENT0(x) (((x) >> S_ELEMENT0) & M_ELEMENT0)
943
944#define S_ELEMENT1 8
945#define M_ELEMENT1 0xff
946#define V_ELEMENT1(x) ((x) << S_ELEMENT1)
947#define G_ELEMENT1(x) (((x) >> S_ELEMENT1) & M_ELEMENT1)
948
949#define S_ELEMENT2 16
950#define M_ELEMENT2 0xff
951#define V_ELEMENT2(x) ((x) << S_ELEMENT2)
952#define G_ELEMENT2(x) (((x) >> S_ELEMENT2) & M_ELEMENT2)
953
954#define S_ELEMENT3 24
955#define M_ELEMENT3 0xff
956#define V_ELEMENT3(x) ((x) << S_ELEMENT3)
957#define G_ELEMENT3(x) (((x) >> S_ELEMENT3) & M_ELEMENT3)
958
959#define A_TP_BACKOFF1 0x354
960#define A_TP_BACKOFF2 0x358
961#define A_TP_BACKOFF3 0x35c
962#define A_TP_PARA_REG0 0x360
963
964#define S_VAR_MULT 0
965#define M_VAR_MULT 0xf
966#define V_VAR_MULT(x) ((x) << S_VAR_MULT)
967#define G_VAR_MULT(x) (((x) >> S_VAR_MULT) & M_VAR_MULT)
968
969#define S_VAR_GAIN 4
970#define M_VAR_GAIN 0xf
971#define V_VAR_GAIN(x) ((x) << S_VAR_GAIN)
972#define G_VAR_GAIN(x) (((x) >> S_VAR_GAIN) & M_VAR_GAIN)
973
974#define S_SRTT_GAIN 8
975#define M_SRTT_GAIN 0xf
976#define V_SRTT_GAIN(x) ((x) << S_SRTT_GAIN)
977#define G_SRTT_GAIN(x) (((x) >> S_SRTT_GAIN) & M_SRTT_GAIN)
978
979#define S_RTTVAR_INIT 12
980#define M_RTTVAR_INIT 0xf
981#define V_RTTVAR_INIT(x) ((x) << S_RTTVAR_INIT)
982#define G_RTTVAR_INIT(x) (((x) >> S_RTTVAR_INIT) & M_RTTVAR_INIT)
983
984#define S_DUP_THRESH 20
985#define M_DUP_THRESH 0xf
986#define V_DUP_THRESH(x) ((x) << S_DUP_THRESH)
987#define G_DUP_THRESH(x) (((x) >> S_DUP_THRESH) & M_DUP_THRESH)
988
989#define S_INIT_CONG_WIN 24
990#define M_INIT_CONG_WIN 0x7
991#define V_INIT_CONG_WIN(x) ((x) << S_INIT_CONG_WIN)
992#define G_INIT_CONG_WIN(x) (((x) >> S_INIT_CONG_WIN) & M_INIT_CONG_WIN)
993
994#define A_TP_PARA_REG1 0x364
995
996#define S_INITIAL_SLOW_START_THRESHOLD 0
997#define M_INITIAL_SLOW_START_THRESHOLD 0xffff
998#define V_INITIAL_SLOW_START_THRESHOLD(x) ((x) << S_INITIAL_SLOW_START_THRESHOLD)
999#define G_INITIAL_SLOW_START_THRESHOLD(x) (((x) >> S_INITIAL_SLOW_START_THRESHOLD) & M_INITIAL_SLOW_START_THRESHOLD)
1000
1001#define S_RECEIVE_BUFFER_SIZE 16
1002#define M_RECEIVE_BUFFER_SIZE 0xffff
1003#define V_RECEIVE_BUFFER_SIZE(x) ((x) << S_RECEIVE_BUFFER_SIZE)
1004#define G_RECEIVE_BUFFER_SIZE(x) (((x) >> S_RECEIVE_BUFFER_SIZE) & M_RECEIVE_BUFFER_SIZE)
1005
1006#define A_TP_PARA_REG2 0x368
1007
1008#define S_RX_COALESCE_SIZE 0
1009#define M_RX_COALESCE_SIZE 0xffff
1010#define V_RX_COALESCE_SIZE(x) ((x) << S_RX_COALESCE_SIZE)
1011#define G_RX_COALESCE_SIZE(x) (((x) >> S_RX_COALESCE_SIZE) & M_RX_COALESCE_SIZE)
1012
1013#define S_MAX_RX_SIZE 16
1014#define M_MAX_RX_SIZE 0xffff
1015#define V_MAX_RX_SIZE(x) ((x) << S_MAX_RX_SIZE)
1016#define G_MAX_RX_SIZE(x) (((x) >> S_MAX_RX_SIZE) & M_MAX_RX_SIZE)
1017
1018#define A_TP_PARA_REG3 0x36c
1019
1020#define S_RX_COALESCING_PSH_DELIVER 0
1021#define V_RX_COALESCING_PSH_DELIVER(x) ((x) << S_RX_COALESCING_PSH_DELIVER)
1022#define F_RX_COALESCING_PSH_DELIVER V_RX_COALESCING_PSH_DELIVER(1U)
1023
1024#define S_RX_COALESCING_ENABLE 1
1025#define V_RX_COALESCING_ENABLE(x) ((x) << S_RX_COALESCING_ENABLE)
1026#define F_RX_COALESCING_ENABLE V_RX_COALESCING_ENABLE(1U)
1027
1028#define S_TAHOE_ENABLE 2
1029#define V_TAHOE_ENABLE(x) ((x) << S_TAHOE_ENABLE)
1030#define F_TAHOE_ENABLE V_TAHOE_ENABLE(1U)
1031
1032#define S_MAX_REORDER_FRAGMENTS 12
1033#define M_MAX_REORDER_FRAGMENTS 0x7
1034#define V_MAX_REORDER_FRAGMENTS(x) ((x) << S_MAX_REORDER_FRAGMENTS)
1035#define G_MAX_REORDER_FRAGMENTS(x) (((x) >> S_MAX_REORDER_FRAGMENTS) & M_MAX_REORDER_FRAGMENTS)
1036
1037#define A_TP_TIMER_RESOLUTION 0x390
1038
1039#define S_DELAYED_ACK_TIMER_RESOLUTION 0
1040#define M_DELAYED_ACK_TIMER_RESOLUTION 0x3f
1041#define V_DELAYED_ACK_TIMER_RESOLUTION(x) ((x) << S_DELAYED_ACK_TIMER_RESOLUTION)
1042#define G_DELAYED_ACK_TIMER_RESOLUTION(x) (((x) >> S_DELAYED_ACK_TIMER_RESOLUTION) & M_DELAYED_ACK_TIMER_RESOLUTION)
1043
1044#define S_GENERIC_TIMER_RESOLUTION 16
1045#define M_GENERIC_TIMER_RESOLUTION 0x3f
1046#define V_GENERIC_TIMER_RESOLUTION(x) ((x) << S_GENERIC_TIMER_RESOLUTION)
1047#define G_GENERIC_TIMER_RESOLUTION(x) (((x) >> S_GENERIC_TIMER_RESOLUTION) & M_GENERIC_TIMER_RESOLUTION)
1048
1049#define A_TP_2MSL 0x394
1050
1051#define S_2MSL 0
1052#define M_2MSL 0x3fffffff
1053#define V_2MSL(x) ((x) << S_2MSL)
1054#define G_2MSL(x) (((x) >> S_2MSL) & M_2MSL)
1055
1056#define A_TP_RXT_MIN 0x398
1057
1058#define S_RETRANSMIT_TIMER_MIN 0
1059#define M_RETRANSMIT_TIMER_MIN 0xffff
1060#define V_RETRANSMIT_TIMER_MIN(x) ((x) << S_RETRANSMIT_TIMER_MIN)
1061#define G_RETRANSMIT_TIMER_MIN(x) (((x) >> S_RETRANSMIT_TIMER_MIN) & M_RETRANSMIT_TIMER_MIN)
1062
1063#define A_TP_RXT_MAX 0x39c
1064
1065#define S_RETRANSMIT_TIMER_MAX 0
1066#define M_RETRANSMIT_TIMER_MAX 0x3fffffff
1067#define V_RETRANSMIT_TIMER_MAX(x) ((x) << S_RETRANSMIT_TIMER_MAX)
1068#define G_RETRANSMIT_TIMER_MAX(x) (((x) >> S_RETRANSMIT_TIMER_MAX) & M_RETRANSMIT_TIMER_MAX)
1069
1070#define A_TP_PERS_MIN 0x3a0
1071
1072#define S_PERSIST_TIMER_MIN 0
1073#define M_PERSIST_TIMER_MIN 0xffff
1074#define V_PERSIST_TIMER_MIN(x) ((x) << S_PERSIST_TIMER_MIN)
1075#define G_PERSIST_TIMER_MIN(x) (((x) >> S_PERSIST_TIMER_MIN) & M_PERSIST_TIMER_MIN)
1076
1077#define A_TP_PERS_MAX 0x3a4
1078
1079#define S_PERSIST_TIMER_MAX 0
1080#define M_PERSIST_TIMER_MAX 0x3fffffff
1081#define V_PERSIST_TIMER_MAX(x) ((x) << S_PERSIST_TIMER_MAX)
1082#define G_PERSIST_TIMER_MAX(x) (((x) >> S_PERSIST_TIMER_MAX) & M_PERSIST_TIMER_MAX)
1083
1084#define A_TP_KEEP_IDLE 0x3ac
1085
1086#define S_KEEP_ALIVE_IDLE_TIME 0
1087#define M_KEEP_ALIVE_IDLE_TIME 0x3fffffff
1088#define V_KEEP_ALIVE_IDLE_TIME(x) ((x) << S_KEEP_ALIVE_IDLE_TIME)
1089#define G_KEEP_ALIVE_IDLE_TIME(x) (((x) >> S_KEEP_ALIVE_IDLE_TIME) & M_KEEP_ALIVE_IDLE_TIME)
1090
1091#define A_TP_KEEP_INTVL 0x3b0
1092
1093#define S_KEEP_ALIVE_INTERVAL_TIME 0
1094#define M_KEEP_ALIVE_INTERVAL_TIME 0x3fffffff
1095#define V_KEEP_ALIVE_INTERVAL_TIME(x) ((x) << S_KEEP_ALIVE_INTERVAL_TIME)
1096#define G_KEEP_ALIVE_INTERVAL_TIME(x) (((x) >> S_KEEP_ALIVE_INTERVAL_TIME) & M_KEEP_ALIVE_INTERVAL_TIME)
1097
1098#define A_TP_INIT_SRTT 0x3b4
1099
1100#define S_INITIAL_SRTT 0
1101#define M_INITIAL_SRTT 0xffff
1102#define V_INITIAL_SRTT(x) ((x) << S_INITIAL_SRTT)
1103#define G_INITIAL_SRTT(x) (((x) >> S_INITIAL_SRTT) & M_INITIAL_SRTT)
1104
1105#define A_TP_DACK_TIME 0x3b8
1106
1107#define S_DELAYED_ACK_TIME 0
1108#define M_DELAYED_ACK_TIME 0x7ff
1109#define V_DELAYED_ACK_TIME(x) ((x) << S_DELAYED_ACK_TIME)
1110#define G_DELAYED_ACK_TIME(x) (((x) >> S_DELAYED_ACK_TIME) & M_DELAYED_ACK_TIME)
1111
1112#define A_TP_FINWAIT2_TIME 0x3bc
1113
1114#define S_FINWAIT2_TIME 0
1115#define M_FINWAIT2_TIME 0x3fffffff
1116#define V_FINWAIT2_TIME(x) ((x) << S_FINWAIT2_TIME)
1117#define G_FINWAIT2_TIME(x) (((x) >> S_FINWAIT2_TIME) & M_FINWAIT2_TIME)
1118
1119#define A_TP_FAST_FINWAIT2_TIME 0x3c0
1120
1121#define S_FAST_FINWAIT2_TIME 0
1122#define M_FAST_FINWAIT2_TIME 0x3fffffff
1123#define V_FAST_FINWAIT2_TIME(x) ((x) << S_FAST_FINWAIT2_TIME)
1124#define G_FAST_FINWAIT2_TIME(x) (((x) >> S_FAST_FINWAIT2_TIME) & M_FAST_FINWAIT2_TIME)
1125
1126#define A_TP_SHIFT_CNT 0x3c4
1127
1128#define S_KEEPALIVE_MAX 0
1129#define M_KEEPALIVE_MAX 0xff
1130#define V_KEEPALIVE_MAX(x) ((x) << S_KEEPALIVE_MAX)
1131#define G_KEEPALIVE_MAX(x) (((x) >> S_KEEPALIVE_MAX) & M_KEEPALIVE_MAX)
1132
1133#define S_WINDOWPROBE_MAX 8
1134#define M_WINDOWPROBE_MAX 0xff
1135#define V_WINDOWPROBE_MAX(x) ((x) << S_WINDOWPROBE_MAX)
1136#define G_WINDOWPROBE_MAX(x) (((x) >> S_WINDOWPROBE_MAX) & M_WINDOWPROBE_MAX)
1137
1138#define S_RETRANSMISSION_MAX 16
1139#define M_RETRANSMISSION_MAX 0xff
1140#define V_RETRANSMISSION_MAX(x) ((x) << S_RETRANSMISSION_MAX)
1141#define G_RETRANSMISSION_MAX(x) (((x) >> S_RETRANSMISSION_MAX) & M_RETRANSMISSION_MAX)
1142
1143#define S_SYN_MAX 24
1144#define M_SYN_MAX 0xff
1145#define V_SYN_MAX(x) ((x) << S_SYN_MAX)
1146#define G_SYN_MAX(x) (((x) >> S_SYN_MAX) & M_SYN_MAX)
1147
1148#define A_TP_QOS_REG0 0x3e0
1149
1150#define S_L3_VALUE 0
1151#define M_L3_VALUE 0x3f
1152#define V_L3_VALUE(x) ((x) << S_L3_VALUE)
1153#define G_L3_VALUE(x) (((x) >> S_L3_VALUE) & M_L3_VALUE)
1154
1155#define A_TP_QOS_REG1 0x3e4
1156#define A_TP_QOS_REG2 0x3e8
1157#define A_TP_QOS_REG3 0x3ec
1158#define A_TP_QOS_REG4 0x3f0
1159#define A_TP_QOS_REG5 0x3f4
1160#define A_TP_QOS_REG6 0x3f8
1161#define A_TP_QOS_REG7 0x3fc
1162#define A_TP_MTU_REG0 0x404
1163#define A_TP_MTU_REG1 0x408
1164#define A_TP_MTU_REG2 0x40c
1165#define A_TP_MTU_REG3 0x410
1166#define A_TP_MTU_REG4 0x414
1167#define A_TP_MTU_REG5 0x418
1168#define A_TP_MTU_REG6 0x41c
1169#define A_TP_MTU_REG7 0x420
267#define A_TP_RESET 0x44c 1170#define A_TP_RESET 0x44c
1171
268#define S_TP_RESET 0 1172#define S_TP_RESET 0
269#define V_TP_RESET(x) ((x) << S_TP_RESET) 1173#define V_TP_RESET(x) ((x) << S_TP_RESET)
270#define F_TP_RESET V_TP_RESET(1U) 1174#define F_TP_RESET V_TP_RESET(1U)
271 1175
1176#define S_CM_MEMMGR_INIT 1
1177#define V_CM_MEMMGR_INIT(x) ((x) << S_CM_MEMMGR_INIT)
1178#define F_CM_MEMMGR_INIT V_CM_MEMMGR_INIT(1U)
1179
1180#define A_TP_MIB_INDEX 0x450
1181#define A_TP_MIB_DATA 0x454
1182#define A_TP_SYNC_TIME_HI 0x458
1183#define A_TP_SYNC_TIME_LO 0x45c
1184#define A_TP_CM_MM_RX_FLST_BASE 0x460
1185
1186#define S_CM_MEMMGR_RX_FREE_LIST_BASE 0
1187#define M_CM_MEMMGR_RX_FREE_LIST_BASE 0xfffffff
1188#define V_CM_MEMMGR_RX_FREE_LIST_BASE(x) ((x) << S_CM_MEMMGR_RX_FREE_LIST_BASE)
1189#define G_CM_MEMMGR_RX_FREE_LIST_BASE(x) (((x) >> S_CM_MEMMGR_RX_FREE_LIST_BASE) & M_CM_MEMMGR_RX_FREE_LIST_BASE)
1190
1191#define A_TP_CM_MM_TX_FLST_BASE 0x464
1192
1193#define S_CM_MEMMGR_TX_FREE_LIST_BASE 0
1194#define M_CM_MEMMGR_TX_FREE_LIST_BASE 0xfffffff
1195#define V_CM_MEMMGR_TX_FREE_LIST_BASE(x) ((x) << S_CM_MEMMGR_TX_FREE_LIST_BASE)
1196#define G_CM_MEMMGR_TX_FREE_LIST_BASE(x) (((x) >> S_CM_MEMMGR_TX_FREE_LIST_BASE) & M_CM_MEMMGR_TX_FREE_LIST_BASE)
1197
1198#define A_TP_CM_MM_P_FLST_BASE 0x468
1199
1200#define S_CM_MEMMGR_PSTRUCT_FREE_LIST_BASE 0
1201#define M_CM_MEMMGR_PSTRUCT_FREE_LIST_BASE 0xfffffff
1202#define V_CM_MEMMGR_PSTRUCT_FREE_LIST_BASE(x) ((x) << S_CM_MEMMGR_PSTRUCT_FREE_LIST_BASE)
1203#define G_CM_MEMMGR_PSTRUCT_FREE_LIST_BASE(x) (((x) >> S_CM_MEMMGR_PSTRUCT_FREE_LIST_BASE) & M_CM_MEMMGR_PSTRUCT_FREE_LIST_BASE)
1204
1205#define A_TP_CM_MM_MAX_P 0x46c
1206
1207#define S_CM_MEMMGR_MAX_PSTRUCT 0
1208#define M_CM_MEMMGR_MAX_PSTRUCT 0xfffffff
1209#define V_CM_MEMMGR_MAX_PSTRUCT(x) ((x) << S_CM_MEMMGR_MAX_PSTRUCT)
1210#define G_CM_MEMMGR_MAX_PSTRUCT(x) (((x) >> S_CM_MEMMGR_MAX_PSTRUCT) & M_CM_MEMMGR_MAX_PSTRUCT)
1211
272#define A_TP_INT_ENABLE 0x470 1212#define A_TP_INT_ENABLE 0x470
1213
1214#define S_TX_FREE_LIST_EMPTY 0
1215#define V_TX_FREE_LIST_EMPTY(x) ((x) << S_TX_FREE_LIST_EMPTY)
1216#define F_TX_FREE_LIST_EMPTY V_TX_FREE_LIST_EMPTY(1U)
1217
1218#define S_RX_FREE_LIST_EMPTY 1
1219#define V_RX_FREE_LIST_EMPTY(x) ((x) << S_RX_FREE_LIST_EMPTY)
1220#define F_RX_FREE_LIST_EMPTY V_RX_FREE_LIST_EMPTY(1U)
1221
273#define A_TP_INT_CAUSE 0x474 1222#define A_TP_INT_CAUSE 0x474
1223#define A_TP_TIMER_SEPARATOR 0x4a4
1224
1225#define S_DISABLE_PAST_TIMER_INSERTION 0
1226#define V_DISABLE_PAST_TIMER_INSERTION(x) ((x) << S_DISABLE_PAST_TIMER_INSERTION)
1227#define F_DISABLE_PAST_TIMER_INSERTION V_DISABLE_PAST_TIMER_INSERTION(1U)
1228
1229#define S_MODULATION_TIMER_SEPARATOR 1
1230#define M_MODULATION_TIMER_SEPARATOR 0x7fff
1231#define V_MODULATION_TIMER_SEPARATOR(x) ((x) << S_MODULATION_TIMER_SEPARATOR)
1232#define G_MODULATION_TIMER_SEPARATOR(x) (((x) >> S_MODULATION_TIMER_SEPARATOR) & M_MODULATION_TIMER_SEPARATOR)
1233
1234#define S_GLOBAL_TIMER_SEPARATOR 16
1235#define M_GLOBAL_TIMER_SEPARATOR 0xffff
1236#define V_GLOBAL_TIMER_SEPARATOR(x) ((x) << S_GLOBAL_TIMER_SEPARATOR)
1237#define G_GLOBAL_TIMER_SEPARATOR(x) (((x) >> S_GLOBAL_TIMER_SEPARATOR) & M_GLOBAL_TIMER_SEPARATOR)
1238
1239#define A_TP_CM_FC_MODE 0x4b0
1240#define A_TP_PC_CONGESTION_CNTL 0x4b4
274#define A_TP_TX_DROP_CONFIG 0x4b8 1241#define A_TP_TX_DROP_CONFIG 0x4b8
275 1242
276#define S_ENABLE_TX_DROP 31 1243#define S_ENABLE_TX_DROP 31
@@ -282,12 +1249,108 @@
282#define F_ENABLE_TX_ERROR V_ENABLE_TX_ERROR(1U) 1249#define F_ENABLE_TX_ERROR V_ENABLE_TX_ERROR(1U)
283 1250
284#define S_DROP_TICKS_CNT 4 1251#define S_DROP_TICKS_CNT 4
1252#define M_DROP_TICKS_CNT 0x3ffffff
285#define V_DROP_TICKS_CNT(x) ((x) << S_DROP_TICKS_CNT) 1253#define V_DROP_TICKS_CNT(x) ((x) << S_DROP_TICKS_CNT)
1254#define G_DROP_TICKS_CNT(x) (((x) >> S_DROP_TICKS_CNT) & M_DROP_TICKS_CNT)
286 1255
287#define S_NUM_PKTS_DROPPED 0 1256#define S_NUM_PKTS_DROPPED 0
1257#define M_NUM_PKTS_DROPPED 0xf
288#define V_NUM_PKTS_DROPPED(x) ((x) << S_NUM_PKTS_DROPPED) 1258#define V_NUM_PKTS_DROPPED(x) ((x) << S_NUM_PKTS_DROPPED)
1259#define G_NUM_PKTS_DROPPED(x) (((x) >> S_NUM_PKTS_DROPPED) & M_NUM_PKTS_DROPPED)
1260
1261#define A_TP_TX_DROP_COUNT 0x4bc
1262
1263/* RAT registers */
1264#define A_RAT_ROUTE_CONTROL 0x580
1265
1266#define S_USE_ROUTE_TABLE 0
1267#define V_USE_ROUTE_TABLE(x) ((x) << S_USE_ROUTE_TABLE)
1268#define F_USE_ROUTE_TABLE V_USE_ROUTE_TABLE(1U)
1269
1270#define S_ENABLE_CSPI 1
1271#define V_ENABLE_CSPI(x) ((x) << S_ENABLE_CSPI)
1272#define F_ENABLE_CSPI V_ENABLE_CSPI(1U)
1273
1274#define S_ENABLE_PCIX 2
1275#define V_ENABLE_PCIX(x) ((x) << S_ENABLE_PCIX)
1276#define F_ENABLE_PCIX V_ENABLE_PCIX(1U)
1277
1278#define A_RAT_ROUTE_TABLE_INDEX 0x584
1279
1280#define S_ROUTE_TABLE_INDEX 0
1281#define M_ROUTE_TABLE_INDEX 0xf
1282#define V_ROUTE_TABLE_INDEX(x) ((x) << S_ROUTE_TABLE_INDEX)
1283#define G_ROUTE_TABLE_INDEX(x) (((x) >> S_ROUTE_TABLE_INDEX) & M_ROUTE_TABLE_INDEX)
1284
1285#define A_RAT_ROUTE_TABLE_DATA 0x588
1286#define A_RAT_NO_ROUTE 0x58c
1287
1288#define S_CPL_OPCODE 0
1289#define M_CPL_OPCODE 0xff
1290#define V_CPL_OPCODE(x) ((x) << S_CPL_OPCODE)
1291#define G_CPL_OPCODE(x) (((x) >> S_CPL_OPCODE) & M_CPL_OPCODE)
1292
1293#define A_RAT_INTR_ENABLE 0x590
1294
1295#define S_ZEROROUTEERROR 0
1296#define V_ZEROROUTEERROR(x) ((x) << S_ZEROROUTEERROR)
1297#define F_ZEROROUTEERROR V_ZEROROUTEERROR(1U)
1298
1299#define S_CSPIFRAMINGERROR 1
1300#define V_CSPIFRAMINGERROR(x) ((x) << S_CSPIFRAMINGERROR)
1301#define F_CSPIFRAMINGERROR V_CSPIFRAMINGERROR(1U)
1302
1303#define S_SGEFRAMINGERROR 2
1304#define V_SGEFRAMINGERROR(x) ((x) << S_SGEFRAMINGERROR)
1305#define F_SGEFRAMINGERROR V_SGEFRAMINGERROR(1U)
1306
1307#define S_TPFRAMINGERROR 3
1308#define V_TPFRAMINGERROR(x) ((x) << S_TPFRAMINGERROR)
1309#define F_TPFRAMINGERROR V_TPFRAMINGERROR(1U)
1310
1311#define A_RAT_INTR_CAUSE 0x594
289 1312
290/* CSPI registers */ 1313/* CSPI registers */
1314#define A_CSPI_RX_AE_WM 0x810
1315#define A_CSPI_RX_AF_WM 0x814
1316#define A_CSPI_CALENDAR_LEN 0x818
1317
1318#define S_CALENDARLENGTH 0
1319#define M_CALENDARLENGTH 0xffff
1320#define V_CALENDARLENGTH(x) ((x) << S_CALENDARLENGTH)
1321#define G_CALENDARLENGTH(x) (((x) >> S_CALENDARLENGTH) & M_CALENDARLENGTH)
1322
1323#define A_CSPI_FIFO_STATUS_ENABLE 0x820
1324
1325#define S_FIFOSTATUSENABLE 0
1326#define V_FIFOSTATUSENABLE(x) ((x) << S_FIFOSTATUSENABLE)
1327#define F_FIFOSTATUSENABLE V_FIFOSTATUSENABLE(1U)
1328
1329#define A_CSPI_MAXBURST1_MAXBURST2 0x828
1330
1331#define S_MAXBURST1 0
1332#define M_MAXBURST1 0xffff
1333#define V_MAXBURST1(x) ((x) << S_MAXBURST1)
1334#define G_MAXBURST1(x) (((x) >> S_MAXBURST1) & M_MAXBURST1)
1335
1336#define S_MAXBURST2 16
1337#define M_MAXBURST2 0xffff
1338#define V_MAXBURST2(x) ((x) << S_MAXBURST2)
1339#define G_MAXBURST2(x) (((x) >> S_MAXBURST2) & M_MAXBURST2)
1340
1341#define A_CSPI_TRAIN 0x82c
1342
1343#define S_CSPI_TRAIN_ALPHA 0
1344#define M_CSPI_TRAIN_ALPHA 0xffff
1345#define V_CSPI_TRAIN_ALPHA(x) ((x) << S_CSPI_TRAIN_ALPHA)
1346#define G_CSPI_TRAIN_ALPHA(x) (((x) >> S_CSPI_TRAIN_ALPHA) & M_CSPI_TRAIN_ALPHA)
1347
1348#define S_CSPI_TRAIN_DATA_MAXT 16
1349#define M_CSPI_TRAIN_DATA_MAXT 0xffff
1350#define V_CSPI_TRAIN_DATA_MAXT(x) ((x) << S_CSPI_TRAIN_DATA_MAXT)
1351#define G_CSPI_TRAIN_DATA_MAXT(x) (((x) >> S_CSPI_TRAIN_DATA_MAXT) & M_CSPI_TRAIN_DATA_MAXT)
1352
1353#define A_CSPI_INTR_STATUS 0x848
291 1354
292#define S_DIP4ERR 0 1355#define S_DIP4ERR 0
293#define V_DIP4ERR(x) ((x) << S_DIP4ERR) 1356#define V_DIP4ERR(x) ((x) << S_DIP4ERR)
@@ -309,22 +1372,63 @@
309#define V_RAMPARITYERR(x) ((x) << S_RAMPARITYERR) 1372#define V_RAMPARITYERR(x) ((x) << S_RAMPARITYERR)
310#define F_RAMPARITYERR V_RAMPARITYERR(1U) 1373#define F_RAMPARITYERR V_RAMPARITYERR(1U)
311 1374
312/* ESPI registers */ 1375#define A_CSPI_INTR_ENABLE 0x84c
313 1376
1377/* ESPI registers */
314#define A_ESPI_SCH_TOKEN0 0x880 1378#define A_ESPI_SCH_TOKEN0 0x880
1379
1380#define S_SCHTOKEN0 0
1381#define M_SCHTOKEN0 0xffff
1382#define V_SCHTOKEN0(x) ((x) << S_SCHTOKEN0)
1383#define G_SCHTOKEN0(x) (((x) >> S_SCHTOKEN0) & M_SCHTOKEN0)
1384
315#define A_ESPI_SCH_TOKEN1 0x884 1385#define A_ESPI_SCH_TOKEN1 0x884
1386
1387#define S_SCHTOKEN1 0
1388#define M_SCHTOKEN1 0xffff
1389#define V_SCHTOKEN1(x) ((x) << S_SCHTOKEN1)
1390#define G_SCHTOKEN1(x) (((x) >> S_SCHTOKEN1) & M_SCHTOKEN1)
1391
316#define A_ESPI_SCH_TOKEN2 0x888 1392#define A_ESPI_SCH_TOKEN2 0x888
1393
1394#define S_SCHTOKEN2 0
1395#define M_SCHTOKEN2 0xffff
1396#define V_SCHTOKEN2(x) ((x) << S_SCHTOKEN2)
1397#define G_SCHTOKEN2(x) (((x) >> S_SCHTOKEN2) & M_SCHTOKEN2)
1398
317#define A_ESPI_SCH_TOKEN3 0x88c 1399#define A_ESPI_SCH_TOKEN3 0x88c
1400
1401#define S_SCHTOKEN3 0
1402#define M_SCHTOKEN3 0xffff
1403#define V_SCHTOKEN3(x) ((x) << S_SCHTOKEN3)
1404#define G_SCHTOKEN3(x) (((x) >> S_SCHTOKEN3) & M_SCHTOKEN3)
1405
318#define A_ESPI_RX_FIFO_ALMOST_EMPTY_WATERMARK 0x890 1406#define A_ESPI_RX_FIFO_ALMOST_EMPTY_WATERMARK 0x890
1407
1408#define S_ALMOSTEMPTY 0
1409#define M_ALMOSTEMPTY 0xffff
1410#define V_ALMOSTEMPTY(x) ((x) << S_ALMOSTEMPTY)
1411#define G_ALMOSTEMPTY(x) (((x) >> S_ALMOSTEMPTY) & M_ALMOSTEMPTY)
1412
319#define A_ESPI_RX_FIFO_ALMOST_FULL_WATERMARK 0x894 1413#define A_ESPI_RX_FIFO_ALMOST_FULL_WATERMARK 0x894
1414
1415#define S_ALMOSTFULL 0
1416#define M_ALMOSTFULL 0xffff
1417#define V_ALMOSTFULL(x) ((x) << S_ALMOSTFULL)
1418#define G_ALMOSTFULL(x) (((x) >> S_ALMOSTFULL) & M_ALMOSTFULL)
1419
320#define A_ESPI_CALENDAR_LENGTH 0x898 1420#define A_ESPI_CALENDAR_LENGTH 0x898
321#define A_PORT_CONFIG 0x89c 1421#define A_PORT_CONFIG 0x89c
322 1422
323#define S_RX_NPORTS 0 1423#define S_RX_NPORTS 0
1424#define M_RX_NPORTS 0xff
324#define V_RX_NPORTS(x) ((x) << S_RX_NPORTS) 1425#define V_RX_NPORTS(x) ((x) << S_RX_NPORTS)
1426#define G_RX_NPORTS(x) (((x) >> S_RX_NPORTS) & M_RX_NPORTS)
325 1427
326#define S_TX_NPORTS 8 1428#define S_TX_NPORTS 8
1429#define M_TX_NPORTS 0xff
327#define V_TX_NPORTS(x) ((x) << S_TX_NPORTS) 1430#define V_TX_NPORTS(x) ((x) << S_TX_NPORTS)
1431#define G_TX_NPORTS(x) (((x) >> S_TX_NPORTS) & M_TX_NPORTS)
328 1432
329#define A_ESPI_FIFO_STATUS_ENABLE 0x8a0 1433#define A_ESPI_FIFO_STATUS_ENABLE 0x8a0
330 1434
@@ -332,12 +1436,124 @@
332#define V_RXSTATUSENABLE(x) ((x) << S_RXSTATUSENABLE) 1436#define V_RXSTATUSENABLE(x) ((x) << S_RXSTATUSENABLE)
333#define F_RXSTATUSENABLE V_RXSTATUSENABLE(1U) 1437#define F_RXSTATUSENABLE V_RXSTATUSENABLE(1U)
334 1438
1439#define S_TXDROPENABLE 1
1440#define V_TXDROPENABLE(x) ((x) << S_TXDROPENABLE)
1441#define F_TXDROPENABLE V_TXDROPENABLE(1U)
1442
1443#define S_RXENDIANMODE 2
1444#define V_RXENDIANMODE(x) ((x) << S_RXENDIANMODE)
1445#define F_RXENDIANMODE V_RXENDIANMODE(1U)
1446
1447#define S_TXENDIANMODE 3
1448#define V_TXENDIANMODE(x) ((x) << S_TXENDIANMODE)
1449#define F_TXENDIANMODE V_TXENDIANMODE(1U)
1450
335#define S_INTEL1010MODE 4 1451#define S_INTEL1010MODE 4
336#define V_INTEL1010MODE(x) ((x) << S_INTEL1010MODE) 1452#define V_INTEL1010MODE(x) ((x) << S_INTEL1010MODE)
337#define F_INTEL1010MODE V_INTEL1010MODE(1U) 1453#define F_INTEL1010MODE V_INTEL1010MODE(1U)
338 1454
339#define A_ESPI_MAXBURST1_MAXBURST2 0x8a8 1455#define A_ESPI_MAXBURST1_MAXBURST2 0x8a8
340#define A_ESPI_TRAIN 0x8ac 1456#define A_ESPI_TRAIN 0x8ac
1457
1458#define S_MAXTRAINALPHA 0
1459#define M_MAXTRAINALPHA 0xffff
1460#define V_MAXTRAINALPHA(x) ((x) << S_MAXTRAINALPHA)
1461#define G_MAXTRAINALPHA(x) (((x) >> S_MAXTRAINALPHA) & M_MAXTRAINALPHA)
1462
1463#define S_MAXTRAINDATA 16
1464#define M_MAXTRAINDATA 0xffff
1465#define V_MAXTRAINDATA(x) ((x) << S_MAXTRAINDATA)
1466#define G_MAXTRAINDATA(x) (((x) >> S_MAXTRAINDATA) & M_MAXTRAINDATA)
1467
1468#define A_RAM_STATUS 0x8b0
1469
1470#define S_RXFIFOPARITYERROR 0
1471#define M_RXFIFOPARITYERROR 0x3ff
1472#define V_RXFIFOPARITYERROR(x) ((x) << S_RXFIFOPARITYERROR)
1473#define G_RXFIFOPARITYERROR(x) (((x) >> S_RXFIFOPARITYERROR) & M_RXFIFOPARITYERROR)
1474
1475#define S_TXFIFOPARITYERROR 10
1476#define M_TXFIFOPARITYERROR 0x3ff
1477#define V_TXFIFOPARITYERROR(x) ((x) << S_TXFIFOPARITYERROR)
1478#define G_TXFIFOPARITYERROR(x) (((x) >> S_TXFIFOPARITYERROR) & M_TXFIFOPARITYERROR)
1479
1480#define S_RXFIFOOVERFLOW 20
1481#define M_RXFIFOOVERFLOW 0x3ff
1482#define V_RXFIFOOVERFLOW(x) ((x) << S_RXFIFOOVERFLOW)
1483#define G_RXFIFOOVERFLOW(x) (((x) >> S_RXFIFOOVERFLOW) & M_RXFIFOOVERFLOW)
1484
1485#define A_TX_DROP_COUNT0 0x8b4
1486
1487#define S_TXPORT0DROPCNT 0
1488#define M_TXPORT0DROPCNT 0xffff
1489#define V_TXPORT0DROPCNT(x) ((x) << S_TXPORT0DROPCNT)
1490#define G_TXPORT0DROPCNT(x) (((x) >> S_TXPORT0DROPCNT) & M_TXPORT0DROPCNT)
1491
1492#define S_TXPORT1DROPCNT 16
1493#define M_TXPORT1DROPCNT 0xffff
1494#define V_TXPORT1DROPCNT(x) ((x) << S_TXPORT1DROPCNT)
1495#define G_TXPORT1DROPCNT(x) (((x) >> S_TXPORT1DROPCNT) & M_TXPORT1DROPCNT)
1496
1497#define A_TX_DROP_COUNT1 0x8b8
1498
1499#define S_TXPORT2DROPCNT 0
1500#define M_TXPORT2DROPCNT 0xffff
1501#define V_TXPORT2DROPCNT(x) ((x) << S_TXPORT2DROPCNT)
1502#define G_TXPORT2DROPCNT(x) (((x) >> S_TXPORT2DROPCNT) & M_TXPORT2DROPCNT)
1503
1504#define S_TXPORT3DROPCNT 16
1505#define M_TXPORT3DROPCNT 0xffff
1506#define V_TXPORT3DROPCNT(x) ((x) << S_TXPORT3DROPCNT)
1507#define G_TXPORT3DROPCNT(x) (((x) >> S_TXPORT3DROPCNT) & M_TXPORT3DROPCNT)
1508
1509#define A_RX_DROP_COUNT0 0x8bc
1510
1511#define S_RXPORT0DROPCNT 0
1512#define M_RXPORT0DROPCNT 0xffff
1513#define V_RXPORT0DROPCNT(x) ((x) << S_RXPORT0DROPCNT)
1514#define G_RXPORT0DROPCNT(x) (((x) >> S_RXPORT0DROPCNT) & M_RXPORT0DROPCNT)
1515
1516#define S_RXPORT1DROPCNT 16
1517#define M_RXPORT1DROPCNT 0xffff
1518#define V_RXPORT1DROPCNT(x) ((x) << S_RXPORT1DROPCNT)
1519#define G_RXPORT1DROPCNT(x) (((x) >> S_RXPORT1DROPCNT) & M_RXPORT1DROPCNT)
1520
1521#define A_RX_DROP_COUNT1 0x8c0
1522
1523#define S_RXPORT2DROPCNT 0
1524#define M_RXPORT2DROPCNT 0xffff
1525#define V_RXPORT2DROPCNT(x) ((x) << S_RXPORT2DROPCNT)
1526#define G_RXPORT2DROPCNT(x) (((x) >> S_RXPORT2DROPCNT) & M_RXPORT2DROPCNT)
1527
1528#define S_RXPORT3DROPCNT 16
1529#define M_RXPORT3DROPCNT 0xffff
1530#define V_RXPORT3DROPCNT(x) ((x) << S_RXPORT3DROPCNT)
1531#define G_RXPORT3DROPCNT(x) (((x) >> S_RXPORT3DROPCNT) & M_RXPORT3DROPCNT)
1532
1533#define A_DIP4_ERROR_COUNT 0x8c4
1534
1535#define S_DIP4ERRORCNT 0
1536#define M_DIP4ERRORCNT 0xfff
1537#define V_DIP4ERRORCNT(x) ((x) << S_DIP4ERRORCNT)
1538#define G_DIP4ERRORCNT(x) (((x) >> S_DIP4ERRORCNT) & M_DIP4ERRORCNT)
1539
1540#define S_DIP4ERRORCNTSHADOW 12
1541#define M_DIP4ERRORCNTSHADOW 0xfff
1542#define V_DIP4ERRORCNTSHADOW(x) ((x) << S_DIP4ERRORCNTSHADOW)
1543#define G_DIP4ERRORCNTSHADOW(x) (((x) >> S_DIP4ERRORCNTSHADOW) & M_DIP4ERRORCNTSHADOW)
1544
1545#define S_TRICN_RX_TRAIN_ERR 24
1546#define V_TRICN_RX_TRAIN_ERR(x) ((x) << S_TRICN_RX_TRAIN_ERR)
1547#define F_TRICN_RX_TRAIN_ERR V_TRICN_RX_TRAIN_ERR(1U)
1548
1549#define S_TRICN_RX_TRAINING 25
1550#define V_TRICN_RX_TRAINING(x) ((x) << S_TRICN_RX_TRAINING)
1551#define F_TRICN_RX_TRAINING V_TRICN_RX_TRAINING(1U)
1552
1553#define S_TRICN_RX_TRAIN_OK 26
1554#define V_TRICN_RX_TRAIN_OK(x) ((x) << S_TRICN_RX_TRAIN_OK)
1555#define F_TRICN_RX_TRAIN_OK V_TRICN_RX_TRAIN_OK(1U)
1556
341#define A_ESPI_INTR_STATUS 0x8c8 1557#define A_ESPI_INTR_STATUS 0x8c8
342 1558
343#define S_DIP2PARITYERR 5 1559#define S_DIP2PARITYERR 5
@@ -347,19 +1563,56 @@
347#define A_ESPI_INTR_ENABLE 0x8cc 1563#define A_ESPI_INTR_ENABLE 0x8cc
348#define A_RX_DROP_THRESHOLD 0x8d0 1564#define A_RX_DROP_THRESHOLD 0x8d0
349#define A_ESPI_RX_RESET 0x8ec 1565#define A_ESPI_RX_RESET 0x8ec
1566
1567#define S_ESPI_RX_LNK_RST 0
1568#define V_ESPI_RX_LNK_RST(x) ((x) << S_ESPI_RX_LNK_RST)
1569#define F_ESPI_RX_LNK_RST V_ESPI_RX_LNK_RST(1U)
1570
1571#define S_ESPI_RX_CORE_RST 1
1572#define V_ESPI_RX_CORE_RST(x) ((x) << S_ESPI_RX_CORE_RST)
1573#define F_ESPI_RX_CORE_RST V_ESPI_RX_CORE_RST(1U)
1574
1575#define S_RX_CLK_STATUS 2
1576#define V_RX_CLK_STATUS(x) ((x) << S_RX_CLK_STATUS)
1577#define F_RX_CLK_STATUS V_RX_CLK_STATUS(1U)
1578
350#define A_ESPI_MISC_CONTROL 0x8f0 1579#define A_ESPI_MISC_CONTROL 0x8f0
351 1580
352#define S_OUT_OF_SYNC_COUNT 0 1581#define S_OUT_OF_SYNC_COUNT 0
1582#define M_OUT_OF_SYNC_COUNT 0xf
353#define V_OUT_OF_SYNC_COUNT(x) ((x) << S_OUT_OF_SYNC_COUNT) 1583#define V_OUT_OF_SYNC_COUNT(x) ((x) << S_OUT_OF_SYNC_COUNT)
1584#define G_OUT_OF_SYNC_COUNT(x) (((x) >> S_OUT_OF_SYNC_COUNT) & M_OUT_OF_SYNC_COUNT)
1585
1586#define S_DIP2_COUNT_MODE_ENABLE 4
1587#define V_DIP2_COUNT_MODE_ENABLE(x) ((x) << S_DIP2_COUNT_MODE_ENABLE)
1588#define F_DIP2_COUNT_MODE_ENABLE V_DIP2_COUNT_MODE_ENABLE(1U)
354 1589
355#define S_DIP2_PARITY_ERR_THRES 5 1590#define S_DIP2_PARITY_ERR_THRES 5
1591#define M_DIP2_PARITY_ERR_THRES 0xf
356#define V_DIP2_PARITY_ERR_THRES(x) ((x) << S_DIP2_PARITY_ERR_THRES) 1592#define V_DIP2_PARITY_ERR_THRES(x) ((x) << S_DIP2_PARITY_ERR_THRES)
1593#define G_DIP2_PARITY_ERR_THRES(x) (((x) >> S_DIP2_PARITY_ERR_THRES) & M_DIP2_PARITY_ERR_THRES)
357 1594
358#define S_DIP4_THRES 9 1595#define S_DIP4_THRES 9
1596#define M_DIP4_THRES 0xfff
359#define V_DIP4_THRES(x) ((x) << S_DIP4_THRES) 1597#define V_DIP4_THRES(x) ((x) << S_DIP4_THRES)
1598#define G_DIP4_THRES(x) (((x) >> S_DIP4_THRES) & M_DIP4_THRES)
1599
1600#define S_DIP4_THRES_ENABLE 21
1601#define V_DIP4_THRES_ENABLE(x) ((x) << S_DIP4_THRES_ENABLE)
1602#define F_DIP4_THRES_ENABLE V_DIP4_THRES_ENABLE(1U)
1603
1604#define S_FORCE_DISABLE_STATUS 22
1605#define V_FORCE_DISABLE_STATUS(x) ((x) << S_FORCE_DISABLE_STATUS)
1606#define F_FORCE_DISABLE_STATUS V_FORCE_DISABLE_STATUS(1U)
1607
1608#define S_DYNAMIC_DESKEW 23
1609#define V_DYNAMIC_DESKEW(x) ((x) << S_DYNAMIC_DESKEW)
1610#define F_DYNAMIC_DESKEW V_DYNAMIC_DESKEW(1U)
360 1611
361#define S_MONITORED_PORT_NUM 25 1612#define S_MONITORED_PORT_NUM 25
1613#define M_MONITORED_PORT_NUM 0x3
362#define V_MONITORED_PORT_NUM(x) ((x) << S_MONITORED_PORT_NUM) 1614#define V_MONITORED_PORT_NUM(x) ((x) << S_MONITORED_PORT_NUM)
1615#define G_MONITORED_PORT_NUM(x) (((x) >> S_MONITORED_PORT_NUM) & M_MONITORED_PORT_NUM)
363 1616
364#define S_MONITORED_DIRECTION 27 1617#define S_MONITORED_DIRECTION 27
365#define V_MONITORED_DIRECTION(x) ((x) << S_MONITORED_DIRECTION) 1618#define V_MONITORED_DIRECTION(x) ((x) << S_MONITORED_DIRECTION)
@@ -370,33 +1623,125 @@
370#define F_MONITORED_INTERFACE V_MONITORED_INTERFACE(1U) 1623#define F_MONITORED_INTERFACE V_MONITORED_INTERFACE(1U)
371 1624
372#define A_ESPI_DIP2_ERR_COUNT 0x8f4 1625#define A_ESPI_DIP2_ERR_COUNT 0x8f4
1626
1627#define S_DIP2_ERR_CNT 0
1628#define M_DIP2_ERR_CNT 0xf
1629#define V_DIP2_ERR_CNT(x) ((x) << S_DIP2_ERR_CNT)
1630#define G_DIP2_ERR_CNT(x) (((x) >> S_DIP2_ERR_CNT) & M_DIP2_ERR_CNT)
1631
373#define A_ESPI_CMD_ADDR 0x8f8 1632#define A_ESPI_CMD_ADDR 0x8f8
374 1633
375#define S_WRITE_DATA 0 1634#define S_WRITE_DATA 0
1635#define M_WRITE_DATA 0xff
376#define V_WRITE_DATA(x) ((x) << S_WRITE_DATA) 1636#define V_WRITE_DATA(x) ((x) << S_WRITE_DATA)
1637#define G_WRITE_DATA(x) (((x) >> S_WRITE_DATA) & M_WRITE_DATA)
377 1638
378#define S_REGISTER_OFFSET 8 1639#define S_REGISTER_OFFSET 8
1640#define M_REGISTER_OFFSET 0xf
379#define V_REGISTER_OFFSET(x) ((x) << S_REGISTER_OFFSET) 1641#define V_REGISTER_OFFSET(x) ((x) << S_REGISTER_OFFSET)
1642#define G_REGISTER_OFFSET(x) (((x) >> S_REGISTER_OFFSET) & M_REGISTER_OFFSET)
380 1643
381#define S_CHANNEL_ADDR 12 1644#define S_CHANNEL_ADDR 12
1645#define M_CHANNEL_ADDR 0xf
382#define V_CHANNEL_ADDR(x) ((x) << S_CHANNEL_ADDR) 1646#define V_CHANNEL_ADDR(x) ((x) << S_CHANNEL_ADDR)
1647#define G_CHANNEL_ADDR(x) (((x) >> S_CHANNEL_ADDR) & M_CHANNEL_ADDR)
383 1648
384#define S_MODULE_ADDR 16 1649#define S_MODULE_ADDR 16
1650#define M_MODULE_ADDR 0x3
385#define V_MODULE_ADDR(x) ((x) << S_MODULE_ADDR) 1651#define V_MODULE_ADDR(x) ((x) << S_MODULE_ADDR)
1652#define G_MODULE_ADDR(x) (((x) >> S_MODULE_ADDR) & M_MODULE_ADDR)
386 1653
387#define S_BUNDLE_ADDR 20 1654#define S_BUNDLE_ADDR 20
1655#define M_BUNDLE_ADDR 0x3
388#define V_BUNDLE_ADDR(x) ((x) << S_BUNDLE_ADDR) 1656#define V_BUNDLE_ADDR(x) ((x) << S_BUNDLE_ADDR)
1657#define G_BUNDLE_ADDR(x) (((x) >> S_BUNDLE_ADDR) & M_BUNDLE_ADDR)
389 1658
390#define S_SPI4_COMMAND 24 1659#define S_SPI4_COMMAND 24
1660#define M_SPI4_COMMAND 0xff
391#define V_SPI4_COMMAND(x) ((x) << S_SPI4_COMMAND) 1661#define V_SPI4_COMMAND(x) ((x) << S_SPI4_COMMAND)
1662#define G_SPI4_COMMAND(x) (((x) >> S_SPI4_COMMAND) & M_SPI4_COMMAND)
392 1663
393#define A_ESPI_GOSTAT 0x8fc 1664#define A_ESPI_GOSTAT 0x8fc
1665
1666#define S_READ_DATA 0
1667#define M_READ_DATA 0xff
1668#define V_READ_DATA(x) ((x) << S_READ_DATA)
1669#define G_READ_DATA(x) (((x) >> S_READ_DATA) & M_READ_DATA)
1670
394#define S_ESPI_CMD_BUSY 8 1671#define S_ESPI_CMD_BUSY 8
395#define V_ESPI_CMD_BUSY(x) ((x) << S_ESPI_CMD_BUSY) 1672#define V_ESPI_CMD_BUSY(x) ((x) << S_ESPI_CMD_BUSY)
396#define F_ESPI_CMD_BUSY V_ESPI_CMD_BUSY(1U) 1673#define F_ESPI_CMD_BUSY V_ESPI_CMD_BUSY(1U)
397 1674
398/* PL registers */ 1675#define S_ERROR_ACK 9
1676#define V_ERROR_ACK(x) ((x) << S_ERROR_ACK)
1677#define F_ERROR_ACK V_ERROR_ACK(1U)
1678
1679#define S_UNMAPPED_ERR 10
1680#define V_UNMAPPED_ERR(x) ((x) << S_UNMAPPED_ERR)
1681#define F_UNMAPPED_ERR V_UNMAPPED_ERR(1U)
1682
1683#define S_TRANSACTION_TIMER 16
1684#define M_TRANSACTION_TIMER 0xff
1685#define V_TRANSACTION_TIMER(x) ((x) << S_TRANSACTION_TIMER)
1686#define G_TRANSACTION_TIMER(x) (((x) >> S_TRANSACTION_TIMER) & M_TRANSACTION_TIMER)
1687
1688
1689/* ULP registers */
1690#define A_ULP_ULIMIT 0x980
1691#define A_ULP_TAGMASK 0x984
1692#define A_ULP_HREG_INDEX 0x988
1693#define A_ULP_HREG_DATA 0x98c
1694#define A_ULP_INT_ENABLE 0x990
1695#define A_ULP_INT_CAUSE 0x994
399 1696
1697#define S_HREG_PAR_ERR 0
1698#define V_HREG_PAR_ERR(x) ((x) << S_HREG_PAR_ERR)
1699#define F_HREG_PAR_ERR V_HREG_PAR_ERR(1U)
1700
1701#define S_EGRS_DATA_PAR_ERR 1
1702#define V_EGRS_DATA_PAR_ERR(x) ((x) << S_EGRS_DATA_PAR_ERR)
1703#define F_EGRS_DATA_PAR_ERR V_EGRS_DATA_PAR_ERR(1U)
1704
1705#define S_INGRS_DATA_PAR_ERR 2
1706#define V_INGRS_DATA_PAR_ERR(x) ((x) << S_INGRS_DATA_PAR_ERR)
1707#define F_INGRS_DATA_PAR_ERR V_INGRS_DATA_PAR_ERR(1U)
1708
1709#define S_PM_INTR 3
1710#define V_PM_INTR(x) ((x) << S_PM_INTR)
1711#define F_PM_INTR V_PM_INTR(1U)
1712
1713#define S_PM_E2C_SYNC_ERR 4
1714#define V_PM_E2C_SYNC_ERR(x) ((x) << S_PM_E2C_SYNC_ERR)
1715#define F_PM_E2C_SYNC_ERR V_PM_E2C_SYNC_ERR(1U)
1716
1717#define S_PM_C2E_SYNC_ERR 5
1718#define V_PM_C2E_SYNC_ERR(x) ((x) << S_PM_C2E_SYNC_ERR)
1719#define F_PM_C2E_SYNC_ERR V_PM_C2E_SYNC_ERR(1U)
1720
1721#define S_PM_E2C_EMPTY_ERR 6
1722#define V_PM_E2C_EMPTY_ERR(x) ((x) << S_PM_E2C_EMPTY_ERR)
1723#define F_PM_E2C_EMPTY_ERR V_PM_E2C_EMPTY_ERR(1U)
1724
1725#define S_PM_C2E_EMPTY_ERR 7
1726#define V_PM_C2E_EMPTY_ERR(x) ((x) << S_PM_C2E_EMPTY_ERR)
1727#define F_PM_C2E_EMPTY_ERR V_PM_C2E_EMPTY_ERR(1U)
1728
1729#define S_PM_PAR_ERR 8
1730#define M_PM_PAR_ERR 0xffff
1731#define V_PM_PAR_ERR(x) ((x) << S_PM_PAR_ERR)
1732#define G_PM_PAR_ERR(x) (((x) >> S_PM_PAR_ERR) & M_PM_PAR_ERR)
1733
1734#define S_PM_E2C_WRT_FULL 24
1735#define V_PM_E2C_WRT_FULL(x) ((x) << S_PM_E2C_WRT_FULL)
1736#define F_PM_E2C_WRT_FULL V_PM_E2C_WRT_FULL(1U)
1737
1738#define S_PM_C2E_WRT_FULL 25
1739#define V_PM_C2E_WRT_FULL(x) ((x) << S_PM_C2E_WRT_FULL)
1740#define F_PM_C2E_WRT_FULL V_PM_C2E_WRT_FULL(1U)
1741
1742#define A_ULP_PIO_CTRL 0x998
1743
1744/* PL registers */
400#define A_PL_ENABLE 0xa00 1745#define A_PL_ENABLE 0xa00
401 1746
402#define S_PL_INTR_SGE_ERR 0 1747#define S_PL_INTR_SGE_ERR 0
@@ -407,14 +1752,38 @@
407#define V_PL_INTR_SGE_DATA(x) ((x) << S_PL_INTR_SGE_DATA) 1752#define V_PL_INTR_SGE_DATA(x) ((x) << S_PL_INTR_SGE_DATA)
408#define F_PL_INTR_SGE_DATA V_PL_INTR_SGE_DATA(1U) 1753#define F_PL_INTR_SGE_DATA V_PL_INTR_SGE_DATA(1U)
409 1754
1755#define S_PL_INTR_MC3 2
1756#define V_PL_INTR_MC3(x) ((x) << S_PL_INTR_MC3)
1757#define F_PL_INTR_MC3 V_PL_INTR_MC3(1U)
1758
1759#define S_PL_INTR_MC4 3
1760#define V_PL_INTR_MC4(x) ((x) << S_PL_INTR_MC4)
1761#define F_PL_INTR_MC4 V_PL_INTR_MC4(1U)
1762
1763#define S_PL_INTR_MC5 4
1764#define V_PL_INTR_MC5(x) ((x) << S_PL_INTR_MC5)
1765#define F_PL_INTR_MC5 V_PL_INTR_MC5(1U)
1766
1767#define S_PL_INTR_RAT 5
1768#define V_PL_INTR_RAT(x) ((x) << S_PL_INTR_RAT)
1769#define F_PL_INTR_RAT V_PL_INTR_RAT(1U)
1770
410#define S_PL_INTR_TP 6 1771#define S_PL_INTR_TP 6
411#define V_PL_INTR_TP(x) ((x) << S_PL_INTR_TP) 1772#define V_PL_INTR_TP(x) ((x) << S_PL_INTR_TP)
412#define F_PL_INTR_TP V_PL_INTR_TP(1U) 1773#define F_PL_INTR_TP V_PL_INTR_TP(1U)
413 1774
1775#define S_PL_INTR_ULP 7
1776#define V_PL_INTR_ULP(x) ((x) << S_PL_INTR_ULP)
1777#define F_PL_INTR_ULP V_PL_INTR_ULP(1U)
1778
414#define S_PL_INTR_ESPI 8 1779#define S_PL_INTR_ESPI 8
415#define V_PL_INTR_ESPI(x) ((x) << S_PL_INTR_ESPI) 1780#define V_PL_INTR_ESPI(x) ((x) << S_PL_INTR_ESPI)
416#define F_PL_INTR_ESPI V_PL_INTR_ESPI(1U) 1781#define F_PL_INTR_ESPI V_PL_INTR_ESPI(1U)
417 1782
1783#define S_PL_INTR_CSPI 9
1784#define V_PL_INTR_CSPI(x) ((x) << S_PL_INTR_CSPI)
1785#define F_PL_INTR_CSPI V_PL_INTR_CSPI(1U)
1786
418#define S_PL_INTR_PCIX 10 1787#define S_PL_INTR_PCIX 10
419#define V_PL_INTR_PCIX(x) ((x) << S_PL_INTR_PCIX) 1788#define V_PL_INTR_PCIX(x) ((x) << S_PL_INTR_PCIX)
420#define F_PL_INTR_PCIX V_PL_INTR_PCIX(1U) 1789#define F_PL_INTR_PCIX V_PL_INTR_PCIX(1U)
@@ -426,43 +1795,374 @@
426#define A_PL_CAUSE 0xa04 1795#define A_PL_CAUSE 0xa04
427 1796
428/* MC5 registers */ 1797/* MC5 registers */
429
430#define A_MC5_CONFIG 0xc04 1798#define A_MC5_CONFIG 0xc04
431 1799
1800#define S_MODE 0
1801#define V_MODE(x) ((x) << S_MODE)
1802#define F_MODE V_MODE(1U)
1803
432#define S_TCAM_RESET 1 1804#define S_TCAM_RESET 1
433#define V_TCAM_RESET(x) ((x) << S_TCAM_RESET) 1805#define V_TCAM_RESET(x) ((x) << S_TCAM_RESET)
434#define F_TCAM_RESET V_TCAM_RESET(1U) 1806#define F_TCAM_RESET V_TCAM_RESET(1U)
435 1807
1808#define S_TCAM_READY 2
1809#define V_TCAM_READY(x) ((x) << S_TCAM_READY)
1810#define F_TCAM_READY V_TCAM_READY(1U)
1811
1812#define S_DBGI_ENABLE 4
1813#define V_DBGI_ENABLE(x) ((x) << S_DBGI_ENABLE)
1814#define F_DBGI_ENABLE V_DBGI_ENABLE(1U)
1815
436#define S_M_BUS_ENABLE 5 1816#define S_M_BUS_ENABLE 5
437#define V_M_BUS_ENABLE(x) ((x) << S_M_BUS_ENABLE) 1817#define V_M_BUS_ENABLE(x) ((x) << S_M_BUS_ENABLE)
438#define F_M_BUS_ENABLE V_M_BUS_ENABLE(1U) 1818#define F_M_BUS_ENABLE V_M_BUS_ENABLE(1U)
439 1819
440/* PCICFG registers */ 1820#define S_PARITY_ENABLE 6
1821#define V_PARITY_ENABLE(x) ((x) << S_PARITY_ENABLE)
1822#define F_PARITY_ENABLE V_PARITY_ENABLE(1U)
1823
1824#define S_SYN_ISSUE_MODE 7
1825#define M_SYN_ISSUE_MODE 0x3
1826#define V_SYN_ISSUE_MODE(x) ((x) << S_SYN_ISSUE_MODE)
1827#define G_SYN_ISSUE_MODE(x) (((x) >> S_SYN_ISSUE_MODE) & M_SYN_ISSUE_MODE)
1828
1829#define S_BUILD 16
1830#define V_BUILD(x) ((x) << S_BUILD)
1831#define F_BUILD V_BUILD(1U)
1832
1833#define S_COMPRESSION_ENABLE 17
1834#define V_COMPRESSION_ENABLE(x) ((x) << S_COMPRESSION_ENABLE)
1835#define F_COMPRESSION_ENABLE V_COMPRESSION_ENABLE(1U)
1836
1837#define S_NUM_LIP 18
1838#define M_NUM_LIP 0x3f
1839#define V_NUM_LIP(x) ((x) << S_NUM_LIP)
1840#define G_NUM_LIP(x) (((x) >> S_NUM_LIP) & M_NUM_LIP)
1841
1842#define S_TCAM_PART_CNT 24
1843#define M_TCAM_PART_CNT 0x3
1844#define V_TCAM_PART_CNT(x) ((x) << S_TCAM_PART_CNT)
1845#define G_TCAM_PART_CNT(x) (((x) >> S_TCAM_PART_CNT) & M_TCAM_PART_CNT)
1846
1847#define S_TCAM_PART_TYPE 26
1848#define M_TCAM_PART_TYPE 0x3
1849#define V_TCAM_PART_TYPE(x) ((x) << S_TCAM_PART_TYPE)
1850#define G_TCAM_PART_TYPE(x) (((x) >> S_TCAM_PART_TYPE) & M_TCAM_PART_TYPE)
1851
1852#define S_TCAM_PART_SIZE 28
1853#define M_TCAM_PART_SIZE 0x3
1854#define V_TCAM_PART_SIZE(x) ((x) << S_TCAM_PART_SIZE)
1855#define G_TCAM_PART_SIZE(x) (((x) >> S_TCAM_PART_SIZE) & M_TCAM_PART_SIZE)
1856
1857#define S_TCAM_PART_TYPE_HI 30
1858#define V_TCAM_PART_TYPE_HI(x) ((x) << S_TCAM_PART_TYPE_HI)
1859#define F_TCAM_PART_TYPE_HI V_TCAM_PART_TYPE_HI(1U)
1860
1861#define A_MC5_SIZE 0xc08
1862
1863#define S_SIZE 0
1864#define M_SIZE 0x3fffff
1865#define V_SIZE(x) ((x) << S_SIZE)
1866#define G_SIZE(x) (((x) >> S_SIZE) & M_SIZE)
1867
1868#define A_MC5_ROUTING_TABLE_INDEX 0xc0c
441 1869
1870#define S_START_OF_ROUTING_TABLE 0
1871#define M_START_OF_ROUTING_TABLE 0x3fffff
1872#define V_START_OF_ROUTING_TABLE(x) ((x) << S_START_OF_ROUTING_TABLE)
1873#define G_START_OF_ROUTING_TABLE(x) (((x) >> S_START_OF_ROUTING_TABLE) & M_START_OF_ROUTING_TABLE)
1874
1875#define A_MC5_SERVER_INDEX 0xc14
1876
1877#define S_START_OF_SERVER_INDEX 0
1878#define M_START_OF_SERVER_INDEX 0x3fffff
1879#define V_START_OF_SERVER_INDEX(x) ((x) << S_START_OF_SERVER_INDEX)
1880#define G_START_OF_SERVER_INDEX(x) (((x) >> S_START_OF_SERVER_INDEX) & M_START_OF_SERVER_INDEX)
1881
1882#define A_MC5_LIP_RAM_ADDR 0xc18
1883
1884#define S_LOCAL_IP_RAM_ADDR 0
1885#define M_LOCAL_IP_RAM_ADDR 0x3f
1886#define V_LOCAL_IP_RAM_ADDR(x) ((x) << S_LOCAL_IP_RAM_ADDR)
1887#define G_LOCAL_IP_RAM_ADDR(x) (((x) >> S_LOCAL_IP_RAM_ADDR) & M_LOCAL_IP_RAM_ADDR)
1888
1889#define S_RAM_WRITE_ENABLE 8
1890#define V_RAM_WRITE_ENABLE(x) ((x) << S_RAM_WRITE_ENABLE)
1891#define F_RAM_WRITE_ENABLE V_RAM_WRITE_ENABLE(1U)
1892
1893#define A_MC5_LIP_RAM_DATA 0xc1c
1894#define A_MC5_RSP_LATENCY 0xc20
1895
1896#define S_SEARCH_RESPONSE_LATENCY 0
1897#define M_SEARCH_RESPONSE_LATENCY 0x1f
1898#define V_SEARCH_RESPONSE_LATENCY(x) ((x) << S_SEARCH_RESPONSE_LATENCY)
1899#define G_SEARCH_RESPONSE_LATENCY(x) (((x) >> S_SEARCH_RESPONSE_LATENCY) & M_SEARCH_RESPONSE_LATENCY)
1900
1901#define S_LEARN_RESPONSE_LATENCY 8
1902#define M_LEARN_RESPONSE_LATENCY 0x1f
1903#define V_LEARN_RESPONSE_LATENCY(x) ((x) << S_LEARN_RESPONSE_LATENCY)
1904#define G_LEARN_RESPONSE_LATENCY(x) (((x) >> S_LEARN_RESPONSE_LATENCY) & M_LEARN_RESPONSE_LATENCY)
1905
1906#define A_MC5_PARITY_LATENCY 0xc24
1907
1908#define S_SRCHLAT 0
1909#define M_SRCHLAT 0x1f
1910#define V_SRCHLAT(x) ((x) << S_SRCHLAT)
1911#define G_SRCHLAT(x) (((x) >> S_SRCHLAT) & M_SRCHLAT)
1912
1913#define S_PARLAT 8
1914#define M_PARLAT 0x1f
1915#define V_PARLAT(x) ((x) << S_PARLAT)
1916#define G_PARLAT(x) (((x) >> S_PARLAT) & M_PARLAT)
1917
1918#define A_MC5_WR_LRN_VERIFY 0xc28
1919
1920#define S_POVEREN 0
1921#define V_POVEREN(x) ((x) << S_POVEREN)
1922#define F_POVEREN V_POVEREN(1U)
1923
1924#define S_LRNVEREN 1
1925#define V_LRNVEREN(x) ((x) << S_LRNVEREN)
1926#define F_LRNVEREN V_LRNVEREN(1U)
1927
1928#define S_VWVEREN 2
1929#define V_VWVEREN(x) ((x) << S_VWVEREN)
1930#define F_VWVEREN V_VWVEREN(1U)
1931
1932#define A_MC5_PART_ID_INDEX 0xc2c
1933
1934#define S_IDINDEX 0
1935#define M_IDINDEX 0xf
1936#define V_IDINDEX(x) ((x) << S_IDINDEX)
1937#define G_IDINDEX(x) (((x) >> S_IDINDEX) & M_IDINDEX)
1938
1939#define A_MC5_RESET_MAX 0xc30
1940
1941#define S_RSTMAX 0
1942#define M_RSTMAX 0x1ff
1943#define V_RSTMAX(x) ((x) << S_RSTMAX)
1944#define G_RSTMAX(x) (((x) >> S_RSTMAX) & M_RSTMAX)
1945
1946#define A_MC5_INT_ENABLE 0xc40
1947
1948#define S_MC5_INT_HIT_OUT_ACTIVE_REGION_ERR 0
1949#define V_MC5_INT_HIT_OUT_ACTIVE_REGION_ERR(x) ((x) << S_MC5_INT_HIT_OUT_ACTIVE_REGION_ERR)
1950#define F_MC5_INT_HIT_OUT_ACTIVE_REGION_ERR V_MC5_INT_HIT_OUT_ACTIVE_REGION_ERR(1U)
1951
1952#define S_MC5_INT_HIT_IN_ACTIVE_REGION_ERR 1
1953#define V_MC5_INT_HIT_IN_ACTIVE_REGION_ERR(x) ((x) << S_MC5_INT_HIT_IN_ACTIVE_REGION_ERR)
1954#define F_MC5_INT_HIT_IN_ACTIVE_REGION_ERR V_MC5_INT_HIT_IN_ACTIVE_REGION_ERR(1U)
1955
1956#define S_MC5_INT_HIT_IN_RT_REGION_ERR 2
1957#define V_MC5_INT_HIT_IN_RT_REGION_ERR(x) ((x) << S_MC5_INT_HIT_IN_RT_REGION_ERR)
1958#define F_MC5_INT_HIT_IN_RT_REGION_ERR V_MC5_INT_HIT_IN_RT_REGION_ERR(1U)
1959
1960#define S_MC5_INT_MISS_ERR 3
1961#define V_MC5_INT_MISS_ERR(x) ((x) << S_MC5_INT_MISS_ERR)
1962#define F_MC5_INT_MISS_ERR V_MC5_INT_MISS_ERR(1U)
1963
1964#define S_MC5_INT_LIP0_ERR 4
1965#define V_MC5_INT_LIP0_ERR(x) ((x) << S_MC5_INT_LIP0_ERR)
1966#define F_MC5_INT_LIP0_ERR V_MC5_INT_LIP0_ERR(1U)
1967
1968#define S_MC5_INT_LIP_MISS_ERR 5
1969#define V_MC5_INT_LIP_MISS_ERR(x) ((x) << S_MC5_INT_LIP_MISS_ERR)
1970#define F_MC5_INT_LIP_MISS_ERR V_MC5_INT_LIP_MISS_ERR(1U)
1971
1972#define S_MC5_INT_PARITY_ERR 6
1973#define V_MC5_INT_PARITY_ERR(x) ((x) << S_MC5_INT_PARITY_ERR)
1974#define F_MC5_INT_PARITY_ERR V_MC5_INT_PARITY_ERR(1U)
1975
1976#define S_MC5_INT_ACTIVE_REGION_FULL 7
1977#define V_MC5_INT_ACTIVE_REGION_FULL(x) ((x) << S_MC5_INT_ACTIVE_REGION_FULL)
1978#define F_MC5_INT_ACTIVE_REGION_FULL V_MC5_INT_ACTIVE_REGION_FULL(1U)
1979
1980#define S_MC5_INT_NFA_SRCH_ERR 8
1981#define V_MC5_INT_NFA_SRCH_ERR(x) ((x) << S_MC5_INT_NFA_SRCH_ERR)
1982#define F_MC5_INT_NFA_SRCH_ERR V_MC5_INT_NFA_SRCH_ERR(1U)
1983
1984#define S_MC5_INT_SYN_COOKIE 9
1985#define V_MC5_INT_SYN_COOKIE(x) ((x) << S_MC5_INT_SYN_COOKIE)
1986#define F_MC5_INT_SYN_COOKIE V_MC5_INT_SYN_COOKIE(1U)
1987
1988#define S_MC5_INT_SYN_COOKIE_BAD 10
1989#define V_MC5_INT_SYN_COOKIE_BAD(x) ((x) << S_MC5_INT_SYN_COOKIE_BAD)
1990#define F_MC5_INT_SYN_COOKIE_BAD V_MC5_INT_SYN_COOKIE_BAD(1U)
1991
1992#define S_MC5_INT_SYN_COOKIE_OFF 11
1993#define V_MC5_INT_SYN_COOKIE_OFF(x) ((x) << S_MC5_INT_SYN_COOKIE_OFF)
1994#define F_MC5_INT_SYN_COOKIE_OFF V_MC5_INT_SYN_COOKIE_OFF(1U)
1995
1996#define S_MC5_INT_UNKNOWN_CMD 15
1997#define V_MC5_INT_UNKNOWN_CMD(x) ((x) << S_MC5_INT_UNKNOWN_CMD)
1998#define F_MC5_INT_UNKNOWN_CMD V_MC5_INT_UNKNOWN_CMD(1U)
1999
2000#define S_MC5_INT_REQUESTQ_PARITY_ERR 16
2001#define V_MC5_INT_REQUESTQ_PARITY_ERR(x) ((x) << S_MC5_INT_REQUESTQ_PARITY_ERR)
2002#define F_MC5_INT_REQUESTQ_PARITY_ERR V_MC5_INT_REQUESTQ_PARITY_ERR(1U)
2003
2004#define S_MC5_INT_DISPATCHQ_PARITY_ERR 17
2005#define V_MC5_INT_DISPATCHQ_PARITY_ERR(x) ((x) << S_MC5_INT_DISPATCHQ_PARITY_ERR)
2006#define F_MC5_INT_DISPATCHQ_PARITY_ERR V_MC5_INT_DISPATCHQ_PARITY_ERR(1U)
2007
2008#define S_MC5_INT_DEL_ACT_EMPTY 18
2009#define V_MC5_INT_DEL_ACT_EMPTY(x) ((x) << S_MC5_INT_DEL_ACT_EMPTY)
2010#define F_MC5_INT_DEL_ACT_EMPTY V_MC5_INT_DEL_ACT_EMPTY(1U)
2011
2012#define A_MC5_INT_CAUSE 0xc44
2013#define A_MC5_INT_TID 0xc48
2014#define A_MC5_INT_PTID 0xc4c
2015#define A_MC5_DBGI_CONFIG 0xc74
2016#define A_MC5_DBGI_REQ_CMD 0xc78
2017
2018#define S_CMDMODE 0
2019#define M_CMDMODE 0x7
2020#define V_CMDMODE(x) ((x) << S_CMDMODE)
2021#define G_CMDMODE(x) (((x) >> S_CMDMODE) & M_CMDMODE)
2022
2023#define S_SADRSEL 4
2024#define V_SADRSEL(x) ((x) << S_SADRSEL)
2025#define F_SADRSEL V_SADRSEL(1U)
2026
2027#define S_WRITE_BURST_SIZE 22
2028#define M_WRITE_BURST_SIZE 0x3ff
2029#define V_WRITE_BURST_SIZE(x) ((x) << S_WRITE_BURST_SIZE)
2030#define G_WRITE_BURST_SIZE(x) (((x) >> S_WRITE_BURST_SIZE) & M_WRITE_BURST_SIZE)
2031
2032#define A_MC5_DBGI_REQ_ADDR0 0xc7c
2033#define A_MC5_DBGI_REQ_ADDR1 0xc80
2034#define A_MC5_DBGI_REQ_ADDR2 0xc84
2035#define A_MC5_DBGI_REQ_DATA0 0xc88
2036#define A_MC5_DBGI_REQ_DATA1 0xc8c
2037#define A_MC5_DBGI_REQ_DATA2 0xc90
2038#define A_MC5_DBGI_REQ_DATA3 0xc94
2039#define A_MC5_DBGI_REQ_DATA4 0xc98
2040#define A_MC5_DBGI_REQ_MASK0 0xc9c
2041#define A_MC5_DBGI_REQ_MASK1 0xca0
2042#define A_MC5_DBGI_REQ_MASK2 0xca4
2043#define A_MC5_DBGI_REQ_MASK3 0xca8
2044#define A_MC5_DBGI_REQ_MASK4 0xcac
2045#define A_MC5_DBGI_RSP_STATUS 0xcb0
2046
2047#define S_DBGI_RSP_VALID 0
2048#define V_DBGI_RSP_VALID(x) ((x) << S_DBGI_RSP_VALID)
2049#define F_DBGI_RSP_VALID V_DBGI_RSP_VALID(1U)
2050
2051#define S_DBGI_RSP_HIT 1
2052#define V_DBGI_RSP_HIT(x) ((x) << S_DBGI_RSP_HIT)
2053#define F_DBGI_RSP_HIT V_DBGI_RSP_HIT(1U)
2054
2055#define S_DBGI_RSP_ERR 2
2056#define V_DBGI_RSP_ERR(x) ((x) << S_DBGI_RSP_ERR)
2057#define F_DBGI_RSP_ERR V_DBGI_RSP_ERR(1U)
2058
2059#define S_DBGI_RSP_ERR_REASON 8
2060#define M_DBGI_RSP_ERR_REASON 0x7
2061#define V_DBGI_RSP_ERR_REASON(x) ((x) << S_DBGI_RSP_ERR_REASON)
2062#define G_DBGI_RSP_ERR_REASON(x) (((x) >> S_DBGI_RSP_ERR_REASON) & M_DBGI_RSP_ERR_REASON)
2063
2064#define A_MC5_DBGI_RSP_DATA0 0xcb4
2065#define A_MC5_DBGI_RSP_DATA1 0xcb8
2066#define A_MC5_DBGI_RSP_DATA2 0xcbc
2067#define A_MC5_DBGI_RSP_DATA3 0xcc0
2068#define A_MC5_DBGI_RSP_DATA4 0xcc4
2069#define A_MC5_DBGI_RSP_LAST_CMD 0xcc8
2070#define A_MC5_POPEN_DATA_WR_CMD 0xccc
2071#define A_MC5_POPEN_MASK_WR_CMD 0xcd0
2072#define A_MC5_AOPEN_SRCH_CMD 0xcd4
2073#define A_MC5_AOPEN_LRN_CMD 0xcd8
2074#define A_MC5_SYN_SRCH_CMD 0xcdc
2075#define A_MC5_SYN_LRN_CMD 0xce0
2076#define A_MC5_ACK_SRCH_CMD 0xce4
2077#define A_MC5_ACK_LRN_CMD 0xce8
2078#define A_MC5_ILOOKUP_CMD 0xcec
2079#define A_MC5_ELOOKUP_CMD 0xcf0
2080#define A_MC5_DATA_WRITE_CMD 0xcf4
2081#define A_MC5_DATA_READ_CMD 0xcf8
2082#define A_MC5_MASK_WRITE_CMD 0xcfc
2083
2084/* PCICFG registers */
442#define A_PCICFG_PM_CSR 0x44 2085#define A_PCICFG_PM_CSR 0x44
443#define A_PCICFG_VPD_ADDR 0x4a 2086#define A_PCICFG_VPD_ADDR 0x4a
444 2087
2088#define S_VPD_ADDR 0
2089#define M_VPD_ADDR 0x7fff
2090#define V_VPD_ADDR(x) ((x) << S_VPD_ADDR)
2091#define G_VPD_ADDR(x) (((x) >> S_VPD_ADDR) & M_VPD_ADDR)
2092
445#define S_VPD_OP_FLAG 15 2093#define S_VPD_OP_FLAG 15
446#define V_VPD_OP_FLAG(x) ((x) << S_VPD_OP_FLAG) 2094#define V_VPD_OP_FLAG(x) ((x) << S_VPD_OP_FLAG)
447#define F_VPD_OP_FLAG V_VPD_OP_FLAG(1U) 2095#define F_VPD_OP_FLAG V_VPD_OP_FLAG(1U)
448 2096
449#define A_PCICFG_VPD_DATA 0x4c 2097#define A_PCICFG_VPD_DATA 0x4c
450 2098#define A_PCICFG_PCIX_CMD 0x60
451#define A_PCICFG_INTR_ENABLE 0xf4 2099#define A_PCICFG_INTR_ENABLE 0xf4
452#define A_PCICFG_INTR_CAUSE 0xf8
453 2100
2101#define S_MASTER_PARITY_ERR 0
2102#define V_MASTER_PARITY_ERR(x) ((x) << S_MASTER_PARITY_ERR)
2103#define F_MASTER_PARITY_ERR V_MASTER_PARITY_ERR(1U)
2104
2105#define S_SIG_TARGET_ABORT 1
2106#define V_SIG_TARGET_ABORT(x) ((x) << S_SIG_TARGET_ABORT)
2107#define F_SIG_TARGET_ABORT V_SIG_TARGET_ABORT(1U)
2108
2109#define S_RCV_TARGET_ABORT 2
2110#define V_RCV_TARGET_ABORT(x) ((x) << S_RCV_TARGET_ABORT)
2111#define F_RCV_TARGET_ABORT V_RCV_TARGET_ABORT(1U)
2112
2113#define S_RCV_MASTER_ABORT 3
2114#define V_RCV_MASTER_ABORT(x) ((x) << S_RCV_MASTER_ABORT)
2115#define F_RCV_MASTER_ABORT V_RCV_MASTER_ABORT(1U)
2116
2117#define S_SIG_SYS_ERR 4
2118#define V_SIG_SYS_ERR(x) ((x) << S_SIG_SYS_ERR)
2119#define F_SIG_SYS_ERR V_SIG_SYS_ERR(1U)
2120
2121#define S_DET_PARITY_ERR 5
2122#define V_DET_PARITY_ERR(x) ((x) << S_DET_PARITY_ERR)
2123#define F_DET_PARITY_ERR V_DET_PARITY_ERR(1U)
2124
2125#define S_PIO_PARITY_ERR 6
2126#define V_PIO_PARITY_ERR(x) ((x) << S_PIO_PARITY_ERR)
2127#define F_PIO_PARITY_ERR V_PIO_PARITY_ERR(1U)
2128
2129#define S_WF_PARITY_ERR 7
2130#define V_WF_PARITY_ERR(x) ((x) << S_WF_PARITY_ERR)
2131#define F_WF_PARITY_ERR V_WF_PARITY_ERR(1U)
2132
2133#define S_RF_PARITY_ERR 8
2134#define M_RF_PARITY_ERR 0x3
2135#define V_RF_PARITY_ERR(x) ((x) << S_RF_PARITY_ERR)
2136#define G_RF_PARITY_ERR(x) (((x) >> S_RF_PARITY_ERR) & M_RF_PARITY_ERR)
2137
2138#define S_CF_PARITY_ERR 10
2139#define M_CF_PARITY_ERR 0x3
2140#define V_CF_PARITY_ERR(x) ((x) << S_CF_PARITY_ERR)
2141#define G_CF_PARITY_ERR(x) (((x) >> S_CF_PARITY_ERR) & M_CF_PARITY_ERR)
2142
2143#define A_PCICFG_INTR_CAUSE 0xf8
454#define A_PCICFG_MODE 0xfc 2144#define A_PCICFG_MODE 0xfc
455 2145
456#define S_PCI_MODE_64BIT 0 2146#define S_PCI_MODE_64BIT 0
457#define V_PCI_MODE_64BIT(x) ((x) << S_PCI_MODE_64BIT) 2147#define V_PCI_MODE_64BIT(x) ((x) << S_PCI_MODE_64BIT)
458#define F_PCI_MODE_64BIT V_PCI_MODE_64BIT(1U) 2148#define F_PCI_MODE_64BIT V_PCI_MODE_64BIT(1U)
459 2149
2150#define S_PCI_MODE_66MHZ 1
2151#define V_PCI_MODE_66MHZ(x) ((x) << S_PCI_MODE_66MHZ)
2152#define F_PCI_MODE_66MHZ V_PCI_MODE_66MHZ(1U)
2153
2154#define S_PCI_MODE_PCIX_INITPAT 2
2155#define M_PCI_MODE_PCIX_INITPAT 0x7
2156#define V_PCI_MODE_PCIX_INITPAT(x) ((x) << S_PCI_MODE_PCIX_INITPAT)
2157#define G_PCI_MODE_PCIX_INITPAT(x) (((x) >> S_PCI_MODE_PCIX_INITPAT) & M_PCI_MODE_PCIX_INITPAT)
2158
460#define S_PCI_MODE_PCIX 5 2159#define S_PCI_MODE_PCIX 5
461#define V_PCI_MODE_PCIX(x) ((x) << S_PCI_MODE_PCIX) 2160#define V_PCI_MODE_PCIX(x) ((x) << S_PCI_MODE_PCIX)
462#define F_PCI_MODE_PCIX V_PCI_MODE_PCIX(1U) 2161#define F_PCI_MODE_PCIX V_PCI_MODE_PCIX(1U)
463 2162
464#define S_PCI_MODE_CLK 6 2163#define S_PCI_MODE_CLK 6
465#define M_PCI_MODE_CLK 0x3 2164#define M_PCI_MODE_CLK 0x3
2165#define V_PCI_MODE_CLK(x) ((x) << S_PCI_MODE_CLK)
466#define G_PCI_MODE_CLK(x) (((x) >> S_PCI_MODE_CLK) & M_PCI_MODE_CLK) 2166#define G_PCI_MODE_CLK(x) (((x) >> S_PCI_MODE_CLK) & M_PCI_MODE_CLK)
467 2167
468#endif /* _CXGB_REGS_H_ */ 2168#endif /* _CXGB_REGS_H_ */
diff --git a/drivers/net/chelsio/sge.c b/drivers/net/chelsio/sge.c
index 9799c12380fc..0ca8d876e16f 100644
--- a/drivers/net/chelsio/sge.c
+++ b/drivers/net/chelsio/sge.c
@@ -42,12 +42,14 @@
42#include <linux/types.h> 42#include <linux/types.h>
43#include <linux/errno.h> 43#include <linux/errno.h>
44#include <linux/pci.h> 44#include <linux/pci.h>
45#include <linux/ktime.h>
45#include <linux/netdevice.h> 46#include <linux/netdevice.h>
46#include <linux/etherdevice.h> 47#include <linux/etherdevice.h>
47#include <linux/if_vlan.h> 48#include <linux/if_vlan.h>
48#include <linux/skbuff.h> 49#include <linux/skbuff.h>
49#include <linux/init.h> 50#include <linux/init.h>
50#include <linux/mm.h> 51#include <linux/mm.h>
52#include <linux/tcp.h>
51#include <linux/ip.h> 53#include <linux/ip.h>
52#include <linux/in.h> 54#include <linux/in.h>
53#include <linux/if_arp.h> 55#include <linux/if_arp.h>
@@ -57,10 +59,8 @@
57#include "regs.h" 59#include "regs.h"
58#include "espi.h" 60#include "espi.h"
59 61
60 62/* This belongs in if_ether.h */
61#ifdef NETIF_F_TSO 63#define ETH_P_CPL5 0xf
62#include <linux/tcp.h>
63#endif
64 64
65#define SGE_CMDQ_N 2 65#define SGE_CMDQ_N 2
66#define SGE_FREELQ_N 2 66#define SGE_FREELQ_N 2
@@ -73,6 +73,7 @@
73#define SGE_INTRTIMER_NRES 1000 73#define SGE_INTRTIMER_NRES 1000
74#define SGE_RX_COPY_THRES 256 74#define SGE_RX_COPY_THRES 256
75#define SGE_RX_SM_BUF_SIZE 1536 75#define SGE_RX_SM_BUF_SIZE 1536
76#define SGE_TX_DESC_MAX_PLEN 16384
76 77
77# define SGE_RX_DROP_THRES 2 78# define SGE_RX_DROP_THRES 2
78 79
@@ -184,17 +185,17 @@ struct cmdQ {
184 unsigned long status; /* HW DMA fetch status */ 185 unsigned long status; /* HW DMA fetch status */
185 unsigned int in_use; /* # of in-use command descriptors */ 186 unsigned int in_use; /* # of in-use command descriptors */
186 unsigned int size; /* # of descriptors */ 187 unsigned int size; /* # of descriptors */
187 unsigned int processed; /* total # of descs HW has processed */ 188 unsigned int processed; /* total # of descs HW has processed */
188 unsigned int cleaned; /* total # of descs SW has reclaimed */ 189 unsigned int cleaned; /* total # of descs SW has reclaimed */
189 unsigned int stop_thres; /* SW TX queue suspend threshold */ 190 unsigned int stop_thres; /* SW TX queue suspend threshold */
190 u16 pidx; /* producer index (SW) */ 191 u16 pidx; /* producer index (SW) */
191 u16 cidx; /* consumer index (HW) */ 192 u16 cidx; /* consumer index (HW) */
192 u8 genbit; /* current generation (=valid) bit */ 193 u8 genbit; /* current generation (=valid) bit */
193 u8 sop; /* is next entry start of packet? */ 194 u8 sop; /* is next entry start of packet? */
194 struct cmdQ_e *entries; /* HW command descriptor Q */ 195 struct cmdQ_e *entries; /* HW command descriptor Q */
195 struct cmdQ_ce *centries; /* SW command context descriptor Q */ 196 struct cmdQ_ce *centries; /* SW command context descriptor Q */
196 spinlock_t lock; /* Lock to protect cmdQ enqueuing */
197 dma_addr_t dma_addr; /* DMA addr HW command descriptor Q */ 197 dma_addr_t dma_addr; /* DMA addr HW command descriptor Q */
198 spinlock_t lock; /* Lock to protect cmdQ enqueuing */
198}; 199};
199 200
200struct freelQ { 201struct freelQ {
@@ -203,8 +204,8 @@ struct freelQ {
203 u16 pidx; /* producer index (SW) */ 204 u16 pidx; /* producer index (SW) */
204 u16 cidx; /* consumer index (HW) */ 205 u16 cidx; /* consumer index (HW) */
205 u16 rx_buffer_size; /* Buffer size on this free list */ 206 u16 rx_buffer_size; /* Buffer size on this free list */
206 u16 dma_offset; /* DMA offset to align IP headers */ 207 u16 dma_offset; /* DMA offset to align IP headers */
207 u16 recycleq_idx; /* skb recycle q to use */ 208 u16 recycleq_idx; /* skb recycle q to use */
208 u8 genbit; /* current generation (=valid) bit */ 209 u8 genbit; /* current generation (=valid) bit */
209 struct freelQ_e *entries; /* HW freelist descriptor Q */ 210 struct freelQ_e *entries; /* HW freelist descriptor Q */
210 struct freelQ_ce *centries; /* SW freelist context descriptor Q */ 211 struct freelQ_ce *centries; /* SW freelist context descriptor Q */
@@ -226,6 +227,29 @@ enum {
226 CMDQ_STAT_LAST_PKT_DB = 2 /* last packet rung the doorbell */ 227 CMDQ_STAT_LAST_PKT_DB = 2 /* last packet rung the doorbell */
227}; 228};
228 229
230/* T204 TX SW scheduler */
231
232/* Per T204 TX port */
233struct sched_port {
234 unsigned int avail; /* available bits - quota */
235 unsigned int drain_bits_per_1024ns; /* drain rate */
236 unsigned int speed; /* drain rate, mbps */
237 unsigned int mtu; /* mtu size */
238 struct sk_buff_head skbq; /* pending skbs */
239};
240
241/* Per T204 device */
242struct sched {
243 ktime_t last_updated; /* last time quotas were computed */
244 unsigned int max_avail; /* max bits to be sent to any port */
245 unsigned int port; /* port index (round robin ports) */
246 unsigned int num; /* num skbs in per port queues */
247 struct sched_port p[MAX_NPORTS];
248 struct tasklet_struct sched_tsk;/* tasklet used to run scheduler */
249};
250static void restart_sched(unsigned long);
251
252
229/* 253/*
230 * Main SGE data structure 254 * Main SGE data structure
231 * 255 *
@@ -243,18 +267,240 @@ struct sge {
243 unsigned int rx_pkt_pad; /* RX padding for L2 packets */ 267 unsigned int rx_pkt_pad; /* RX padding for L2 packets */
244 unsigned int jumbo_fl; /* jumbo freelist Q index */ 268 unsigned int jumbo_fl; /* jumbo freelist Q index */
245 unsigned int intrtimer_nres; /* no-resource interrupt timer */ 269 unsigned int intrtimer_nres; /* no-resource interrupt timer */
246 unsigned int fixed_intrtimer;/* non-adaptive interrupt timer */ 270 unsigned int fixed_intrtimer;/* non-adaptive interrupt timer */
247 struct timer_list tx_reclaim_timer; /* reclaims TX buffers */ 271 struct timer_list tx_reclaim_timer; /* reclaims TX buffers */
248 struct timer_list espibug_timer; 272 struct timer_list espibug_timer;
249 unsigned int espibug_timeout; 273 unsigned long espibug_timeout;
250 struct sk_buff *espibug_skb; 274 struct sk_buff *espibug_skb[MAX_NPORTS];
251 u32 sge_control; /* shadow value of sge control reg */ 275 u32 sge_control; /* shadow value of sge control reg */
252 struct sge_intr_counts stats; 276 struct sge_intr_counts stats;
253 struct sge_port_stats port_stats[MAX_NPORTS]; 277 struct sge_port_stats *port_stats[MAX_NPORTS];
278 struct sched *tx_sched;
254 struct cmdQ cmdQ[SGE_CMDQ_N] ____cacheline_aligned_in_smp; 279 struct cmdQ cmdQ[SGE_CMDQ_N] ____cacheline_aligned_in_smp;
255}; 280};
256 281
257/* 282/*
283 * stop tasklet and free all pending skb's
284 */
285static void tx_sched_stop(struct sge *sge)
286{
287 struct sched *s = sge->tx_sched;
288 int i;
289
290 tasklet_kill(&s->sched_tsk);
291
292 for (i = 0; i < MAX_NPORTS; i++)
293 __skb_queue_purge(&s->p[s->port].skbq);
294}
295
296/*
297 * t1_sched_update_parms() is called when the MTU or link speed changes. It
298 * re-computes scheduler parameters to scope with the change.
299 */
300unsigned int t1_sched_update_parms(struct sge *sge, unsigned int port,
301 unsigned int mtu, unsigned int speed)
302{
303 struct sched *s = sge->tx_sched;
304 struct sched_port *p = &s->p[port];
305 unsigned int max_avail_segs;
306
307 pr_debug("t1_sched_update_params mtu=%d speed=%d\n", mtu, speed);
308 if (speed)
309 p->speed = speed;
310 if (mtu)
311 p->mtu = mtu;
312
313 if (speed || mtu) {
314 unsigned long long drain = 1024ULL * p->speed * (p->mtu - 40);
315 do_div(drain, (p->mtu + 50) * 1000);
316 p->drain_bits_per_1024ns = (unsigned int) drain;
317
318 if (p->speed < 1000)
319 p->drain_bits_per_1024ns =
320 90 * p->drain_bits_per_1024ns / 100;
321 }
322
323 if (board_info(sge->adapter)->board == CHBT_BOARD_CHT204) {
324 p->drain_bits_per_1024ns -= 16;
325 s->max_avail = max(4096U, p->mtu + 16 + 14 + 4);
326 max_avail_segs = max(1U, 4096 / (p->mtu - 40));
327 } else {
328 s->max_avail = 16384;
329 max_avail_segs = max(1U, 9000 / (p->mtu - 40));
330 }
331
332 pr_debug("t1_sched_update_parms: mtu %u speed %u max_avail %u "
333 "max_avail_segs %u drain_bits_per_1024ns %u\n", p->mtu,
334 p->speed, s->max_avail, max_avail_segs,
335 p->drain_bits_per_1024ns);
336
337 return max_avail_segs * (p->mtu - 40);
338}
339
340/*
341 * t1_sched_max_avail_bytes() tells the scheduler the maximum amount of
342 * data that can be pushed per port.
343 */
344void t1_sched_set_max_avail_bytes(struct sge *sge, unsigned int val)
345{
346 struct sched *s = sge->tx_sched;
347 unsigned int i;
348
349 s->max_avail = val;
350 for (i = 0; i < MAX_NPORTS; i++)
351 t1_sched_update_parms(sge, i, 0, 0);
352}
353
354/*
355 * t1_sched_set_drain_bits_per_us() tells the scheduler at which rate a port
356 * is draining.
357 */
358void t1_sched_set_drain_bits_per_us(struct sge *sge, unsigned int port,
359 unsigned int val)
360{
361 struct sched *s = sge->tx_sched;
362 struct sched_port *p = &s->p[port];
363 p->drain_bits_per_1024ns = val * 1024 / 1000;
364 t1_sched_update_parms(sge, port, 0, 0);
365}
366
367
368/*
369 * get_clock() implements a ns clock (see ktime_get)
370 */
371static inline ktime_t get_clock(void)
372{
373 struct timespec ts;
374
375 ktime_get_ts(&ts);
376 return timespec_to_ktime(ts);
377}
378
379/*
380 * tx_sched_init() allocates resources and does basic initialization.
381 */
382static int tx_sched_init(struct sge *sge)
383{
384 struct sched *s;
385 int i;
386
387 s = kzalloc(sizeof (struct sched), GFP_KERNEL);
388 if (!s)
389 return -ENOMEM;
390
391 pr_debug("tx_sched_init\n");
392 tasklet_init(&s->sched_tsk, restart_sched, (unsigned long) sge);
393 sge->tx_sched = s;
394
395 for (i = 0; i < MAX_NPORTS; i++) {
396 skb_queue_head_init(&s->p[i].skbq);
397 t1_sched_update_parms(sge, i, 1500, 1000);
398 }
399
400 return 0;
401}
402
403/*
404 * sched_update_avail() computes the delta since the last time it was called
405 * and updates the per port quota (number of bits that can be sent to the any
406 * port).
407 */
408static inline int sched_update_avail(struct sge *sge)
409{
410 struct sched *s = sge->tx_sched;
411 ktime_t now = get_clock();
412 unsigned int i;
413 long long delta_time_ns;
414
415 delta_time_ns = ktime_to_ns(ktime_sub(now, s->last_updated));
416
417 pr_debug("sched_update_avail delta=%lld\n", delta_time_ns);
418 if (delta_time_ns < 15000)
419 return 0;
420
421 for (i = 0; i < MAX_NPORTS; i++) {
422 struct sched_port *p = &s->p[i];
423 unsigned int delta_avail;
424
425 delta_avail = (p->drain_bits_per_1024ns * delta_time_ns) >> 13;
426 p->avail = min(p->avail + delta_avail, s->max_avail);
427 }
428
429 s->last_updated = now;
430
431 return 1;
432}
433
434/*
435 * sched_skb() is called from two different places. In the tx path, any
436 * packet generating load on an output port will call sched_skb()
437 * (skb != NULL). In addition, sched_skb() is called from the irq/soft irq
438 * context (skb == NULL).
439 * The scheduler only returns a skb (which will then be sent) if the
440 * length of the skb is <= the current quota of the output port.
441 */
442static struct sk_buff *sched_skb(struct sge *sge, struct sk_buff *skb,
443 unsigned int credits)
444{
445 struct sched *s = sge->tx_sched;
446 struct sk_buff_head *skbq;
447 unsigned int i, len, update = 1;
448
449 pr_debug("sched_skb %p\n", skb);
450 if (!skb) {
451 if (!s->num)
452 return NULL;
453 } else {
454 skbq = &s->p[skb->dev->if_port].skbq;
455 __skb_queue_tail(skbq, skb);
456 s->num++;
457 skb = NULL;
458 }
459
460 if (credits < MAX_SKB_FRAGS + 1)
461 goto out;
462
463 again:
464 for (i = 0; i < MAX_NPORTS; i++) {
465 s->port = ++s->port & (MAX_NPORTS - 1);
466 skbq = &s->p[s->port].skbq;
467
468 skb = skb_peek(skbq);
469
470 if (!skb)
471 continue;
472
473 len = skb->len;
474 if (len <= s->p[s->port].avail) {
475 s->p[s->port].avail -= len;
476 s->num--;
477 __skb_unlink(skb, skbq);
478 goto out;
479 }
480 skb = NULL;
481 }
482
483 if (update-- && sched_update_avail(sge))
484 goto again;
485
486 out:
487 /* If there are more pending skbs, we use the hardware to schedule us
488 * again.
489 */
490 if (s->num && !skb) {
491 struct cmdQ *q = &sge->cmdQ[0];
492 clear_bit(CMDQ_STAT_LAST_PKT_DB, &q->status);
493 if (test_and_set_bit(CMDQ_STAT_RUNNING, &q->status) == 0) {
494 set_bit(CMDQ_STAT_LAST_PKT_DB, &q->status);
495 writel(F_CMDQ0_ENABLE, sge->adapter->regs + A_SG_DOORBELL);
496 }
497 }
498 pr_debug("sched_skb ret %p\n", skb);
499
500 return skb;
501}
502
503/*
258 * PIO to indicate that memory mapped Q contains valid descriptor(s). 504 * PIO to indicate that memory mapped Q contains valid descriptor(s).
259 */ 505 */
260static inline void doorbell_pio(struct adapter *adapter, u32 val) 506static inline void doorbell_pio(struct adapter *adapter, u32 val)
@@ -335,10 +581,9 @@ static int alloc_rx_resources(struct sge *sge, struct sge_params *p)
335 goto err_no_mem; 581 goto err_no_mem;
336 memset(q->entries, 0, size); 582 memset(q->entries, 0, size);
337 size = sizeof(struct freelQ_ce) * q->size; 583 size = sizeof(struct freelQ_ce) * q->size;
338 q->centries = kmalloc(size, GFP_KERNEL); 584 q->centries = kzalloc(size, GFP_KERNEL);
339 if (!q->centries) 585 if (!q->centries)
340 goto err_no_mem; 586 goto err_no_mem;
341 memset(q->centries, 0, size);
342 } 587 }
343 588
344 /* 589 /*
@@ -351,8 +596,11 @@ static int alloc_rx_resources(struct sge *sge, struct sge_params *p)
351 sge->freelQ[!sge->jumbo_fl].rx_buffer_size = SGE_RX_SM_BUF_SIZE + 596 sge->freelQ[!sge->jumbo_fl].rx_buffer_size = SGE_RX_SM_BUF_SIZE +
352 sizeof(struct cpl_rx_data) + 597 sizeof(struct cpl_rx_data) +
353 sge->freelQ[!sge->jumbo_fl].dma_offset; 598 sge->freelQ[!sge->jumbo_fl].dma_offset;
354 sge->freelQ[sge->jumbo_fl].rx_buffer_size = (16 * 1024) - 599
355 SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); 600 size = (16 * 1024) -
601 SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
602
603 sge->freelQ[sge->jumbo_fl].rx_buffer_size = size;
356 604
357 /* 605 /*
358 * Setup which skb recycle Q should be used when recycling buffers from 606 * Setup which skb recycle Q should be used when recycling buffers from
@@ -389,17 +637,23 @@ static void free_cmdQ_buffers(struct sge *sge, struct cmdQ *q, unsigned int n)
389 q->in_use -= n; 637 q->in_use -= n;
390 ce = &q->centries[cidx]; 638 ce = &q->centries[cidx];
391 while (n--) { 639 while (n--) {
392 if (q->sop) 640 if (q->sop) {
393 pci_unmap_single(pdev, pci_unmap_addr(ce, dma_addr), 641 if (likely(pci_unmap_len(ce, dma_len))) {
394 pci_unmap_len(ce, dma_len), 642 pci_unmap_single(pdev,
395 PCI_DMA_TODEVICE); 643 pci_unmap_addr(ce, dma_addr),
396 else 644 pci_unmap_len(ce, dma_len),
397 pci_unmap_page(pdev, pci_unmap_addr(ce, dma_addr), 645 PCI_DMA_TODEVICE);
398 pci_unmap_len(ce, dma_len), 646 q->sop = 0;
399 PCI_DMA_TODEVICE); 647 }
400 q->sop = 0; 648 } else {
649 if (likely(pci_unmap_len(ce, dma_len))) {
650 pci_unmap_page(pdev, pci_unmap_addr(ce, dma_addr),
651 pci_unmap_len(ce, dma_len),
652 PCI_DMA_TODEVICE);
653 }
654 }
401 if (ce->skb) { 655 if (ce->skb) {
402 dev_kfree_skb(ce->skb); 656 dev_kfree_skb_any(ce->skb);
403 q->sop = 1; 657 q->sop = 1;
404 } 658 }
405 ce++; 659 ce++;
@@ -463,10 +717,9 @@ static int alloc_tx_resources(struct sge *sge, struct sge_params *p)
463 goto err_no_mem; 717 goto err_no_mem;
464 memset(q->entries, 0, size); 718 memset(q->entries, 0, size);
465 size = sizeof(struct cmdQ_ce) * q->size; 719 size = sizeof(struct cmdQ_ce) * q->size;
466 q->centries = kmalloc(size, GFP_KERNEL); 720 q->centries = kzalloc(size, GFP_KERNEL);
467 if (!q->centries) 721 if (!q->centries)
468 goto err_no_mem; 722 goto err_no_mem;
469 memset(q->centries, 0, size);
470 } 723 }
471 724
472 /* 725 /*
@@ -506,7 +759,7 @@ void t1_set_vlan_accel(struct adapter *adapter, int on_off)
506 sge->sge_control |= F_VLAN_XTRACT; 759 sge->sge_control |= F_VLAN_XTRACT;
507 if (adapter->open_device_map) { 760 if (adapter->open_device_map) {
508 writel(sge->sge_control, adapter->regs + A_SG_CONTROL); 761 writel(sge->sge_control, adapter->regs + A_SG_CONTROL);
509 readl(adapter->regs + A_SG_CONTROL); /* flush */ 762 readl(adapter->regs + A_SG_CONTROL); /* flush */
510 } 763 }
511} 764}
512 765
@@ -540,7 +793,6 @@ static void configure_sge(struct sge *sge, struct sge_params *p)
540 sge->sge_control = F_CMDQ0_ENABLE | F_CMDQ1_ENABLE | F_FL0_ENABLE | 793 sge->sge_control = F_CMDQ0_ENABLE | F_CMDQ1_ENABLE | F_FL0_ENABLE |
541 F_FL1_ENABLE | F_CPL_ENABLE | F_RESPONSE_QUEUE_ENABLE | 794 F_FL1_ENABLE | F_CPL_ENABLE | F_RESPONSE_QUEUE_ENABLE |
542 V_CMDQ_PRIORITY(2) | F_DISABLE_CMDQ1_GTS | F_ISCSI_COALESCE | 795 V_CMDQ_PRIORITY(2) | F_DISABLE_CMDQ1_GTS | F_ISCSI_COALESCE |
543 F_DISABLE_FL0_GTS | F_DISABLE_FL1_GTS |
544 V_RX_PKT_OFFSET(sge->rx_pkt_pad); 796 V_RX_PKT_OFFSET(sge->rx_pkt_pad);
545 797
546#if defined(__BIG_ENDIAN_BITFIELD) 798#if defined(__BIG_ENDIAN_BITFIELD)
@@ -568,9 +820,12 @@ static inline unsigned int jumbo_payload_capacity(const struct sge *sge)
568 */ 820 */
569void t1_sge_destroy(struct sge *sge) 821void t1_sge_destroy(struct sge *sge)
570{ 822{
571 if (sge->espibug_skb) 823 int i;
572 kfree_skb(sge->espibug_skb);
573 824
825 for_each_port(sge->adapter, i)
826 free_percpu(sge->port_stats[i]);
827
828 kfree(sge->tx_sched);
574 free_tx_resources(sge); 829 free_tx_resources(sge);
575 free_rx_resources(sge); 830 free_rx_resources(sge);
576 kfree(sge); 831 kfree(sge);
@@ -735,14 +990,28 @@ int t1_sge_intr_error_handler(struct sge *sge)
735 return 0; 990 return 0;
736} 991}
737 992
738const struct sge_intr_counts *t1_sge_get_intr_counts(struct sge *sge) 993const struct sge_intr_counts *t1_sge_get_intr_counts(const struct sge *sge)
739{ 994{
740 return &sge->stats; 995 return &sge->stats;
741} 996}
742 997
743const struct sge_port_stats *t1_sge_get_port_stats(struct sge *sge, int port) 998void t1_sge_get_port_stats(const struct sge *sge, int port,
999 struct sge_port_stats *ss)
744{ 1000{
745 return &sge->port_stats[port]; 1001 int cpu;
1002
1003 memset(ss, 0, sizeof(*ss));
1004 for_each_possible_cpu(cpu) {
1005 struct sge_port_stats *st = per_cpu_ptr(sge->port_stats[port], cpu);
1006
1007 ss->rx_packets += st->rx_packets;
1008 ss->rx_cso_good += st->rx_cso_good;
1009 ss->tx_packets += st->tx_packets;
1010 ss->tx_cso += st->tx_cso;
1011 ss->tx_tso += st->tx_tso;
1012 ss->vlan_xtract += st->vlan_xtract;
1013 ss->vlan_insert += st->vlan_insert;
1014 }
746} 1015}
747 1016
748/** 1017/**
@@ -856,6 +1125,99 @@ static void unexpected_offload(struct adapter *adapter, struct freelQ *fl)
856} 1125}
857 1126
858/* 1127/*
1128 * T1/T2 SGE limits the maximum DMA size per TX descriptor to
1129 * SGE_TX_DESC_MAX_PLEN (16KB). If the PAGE_SIZE is larger than 16KB, the
1130 * stack might send more than SGE_TX_DESC_MAX_PLEN in a contiguous manner.
1131 * Note that the *_large_page_tx_descs stuff will be optimized out when
1132 * PAGE_SIZE <= SGE_TX_DESC_MAX_PLEN.
1133 *
1134 * compute_large_page_descs() computes how many additional descriptors are
1135 * required to break down the stack's request.
1136 */
1137static inline unsigned int compute_large_page_tx_descs(struct sk_buff *skb)
1138{
1139 unsigned int count = 0;
1140 if (PAGE_SIZE > SGE_TX_DESC_MAX_PLEN) {
1141 unsigned int nfrags = skb_shinfo(skb)->nr_frags;
1142 unsigned int i, len = skb->len - skb->data_len;
1143 while (len > SGE_TX_DESC_MAX_PLEN) {
1144 count++;
1145 len -= SGE_TX_DESC_MAX_PLEN;
1146 }
1147 for (i = 0; nfrags--; i++) {
1148 skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
1149 len = frag->size;
1150 while (len > SGE_TX_DESC_MAX_PLEN) {
1151 count++;
1152 len -= SGE_TX_DESC_MAX_PLEN;
1153 }
1154 }
1155 }
1156 return count;
1157}
1158
1159/*
1160 * Write a cmdQ entry.
1161 *
1162 * Since this function writes the 'flags' field, it must not be used to
1163 * write the first cmdQ entry.
1164 */
1165static inline void write_tx_desc(struct cmdQ_e *e, dma_addr_t mapping,
1166 unsigned int len, unsigned int gen,
1167 unsigned int eop)
1168{
1169 if (unlikely(len > SGE_TX_DESC_MAX_PLEN))
1170 BUG();
1171 e->addr_lo = (u32)mapping;
1172 e->addr_hi = (u64)mapping >> 32;
1173 e->len_gen = V_CMD_LEN(len) | V_CMD_GEN1(gen);
1174 e->flags = F_CMD_DATAVALID | V_CMD_EOP(eop) | V_CMD_GEN2(gen);
1175}
1176
1177/*
1178 * See comment for previous function.
1179 *
1180 * write_tx_descs_large_page() writes additional SGE tx descriptors if
1181 * *desc_len exceeds HW's capability.
1182 */
1183static inline unsigned int write_large_page_tx_descs(unsigned int pidx,
1184 struct cmdQ_e **e,
1185 struct cmdQ_ce **ce,
1186 unsigned int *gen,
1187 dma_addr_t *desc_mapping,
1188 unsigned int *desc_len,
1189 unsigned int nfrags,
1190 struct cmdQ *q)
1191{
1192 if (PAGE_SIZE > SGE_TX_DESC_MAX_PLEN) {
1193 struct cmdQ_e *e1 = *e;
1194 struct cmdQ_ce *ce1 = *ce;
1195
1196 while (*desc_len > SGE_TX_DESC_MAX_PLEN) {
1197 *desc_len -= SGE_TX_DESC_MAX_PLEN;
1198 write_tx_desc(e1, *desc_mapping, SGE_TX_DESC_MAX_PLEN,
1199 *gen, nfrags == 0 && *desc_len == 0);
1200 ce1->skb = NULL;
1201 pci_unmap_len_set(ce1, dma_len, 0);
1202 *desc_mapping += SGE_TX_DESC_MAX_PLEN;
1203 if (*desc_len) {
1204 ce1++;
1205 e1++;
1206 if (++pidx == q->size) {
1207 pidx = 0;
1208 *gen ^= 1;
1209 ce1 = q->centries;
1210 e1 = q->entries;
1211 }
1212 }
1213 }
1214 *e = e1;
1215 *ce = ce1;
1216 }
1217 return pidx;
1218}
1219
1220/*
859 * Write the command descriptors to transmit the given skb starting at 1221 * Write the command descriptors to transmit the given skb starting at
860 * descriptor pidx with the given generation. 1222 * descriptor pidx with the given generation.
861 */ 1223 */
@@ -863,50 +1225,84 @@ static inline void write_tx_descs(struct adapter *adapter, struct sk_buff *skb,
863 unsigned int pidx, unsigned int gen, 1225 unsigned int pidx, unsigned int gen,
864 struct cmdQ *q) 1226 struct cmdQ *q)
865{ 1227{
866 dma_addr_t mapping; 1228 dma_addr_t mapping, desc_mapping;
867 struct cmdQ_e *e, *e1; 1229 struct cmdQ_e *e, *e1;
868 struct cmdQ_ce *ce; 1230 struct cmdQ_ce *ce;
869 unsigned int i, flags, nfrags = skb_shinfo(skb)->nr_frags; 1231 unsigned int i, flags, first_desc_len, desc_len,
1232 nfrags = skb_shinfo(skb)->nr_frags;
870 1233
871 mapping = pci_map_single(adapter->pdev, skb->data, 1234 e = e1 = &q->entries[pidx];
872 skb->len - skb->data_len, PCI_DMA_TODEVICE);
873 ce = &q->centries[pidx]; 1235 ce = &q->centries[pidx];
1236
1237 mapping = pci_map_single(adapter->pdev, skb->data,
1238 skb->len - skb->data_len, PCI_DMA_TODEVICE);
1239
1240 desc_mapping = mapping;
1241 desc_len = skb->len - skb->data_len;
1242
1243 flags = F_CMD_DATAVALID | F_CMD_SOP |
1244 V_CMD_EOP(nfrags == 0 && desc_len <= SGE_TX_DESC_MAX_PLEN) |
1245 V_CMD_GEN2(gen);
1246 first_desc_len = (desc_len <= SGE_TX_DESC_MAX_PLEN) ?
1247 desc_len : SGE_TX_DESC_MAX_PLEN;
1248 e->addr_lo = (u32)desc_mapping;
1249 e->addr_hi = (u64)desc_mapping >> 32;
1250 e->len_gen = V_CMD_LEN(first_desc_len) | V_CMD_GEN1(gen);
1251 ce->skb = NULL;
1252 pci_unmap_len_set(ce, dma_len, 0);
1253
1254 if (PAGE_SIZE > SGE_TX_DESC_MAX_PLEN &&
1255 desc_len > SGE_TX_DESC_MAX_PLEN) {
1256 desc_mapping += first_desc_len;
1257 desc_len -= first_desc_len;
1258 e1++;
1259 ce++;
1260 if (++pidx == q->size) {
1261 pidx = 0;
1262 gen ^= 1;
1263 e1 = q->entries;
1264 ce = q->centries;
1265 }
1266 pidx = write_large_page_tx_descs(pidx, &e1, &ce, &gen,
1267 &desc_mapping, &desc_len,
1268 nfrags, q);
1269
1270 if (likely(desc_len))
1271 write_tx_desc(e1, desc_mapping, desc_len, gen,
1272 nfrags == 0);
1273 }
1274
874 ce->skb = NULL; 1275 ce->skb = NULL;
875 pci_unmap_addr_set(ce, dma_addr, mapping); 1276 pci_unmap_addr_set(ce, dma_addr, mapping);
876 pci_unmap_len_set(ce, dma_len, skb->len - skb->data_len); 1277 pci_unmap_len_set(ce, dma_len, skb->len - skb->data_len);
877 1278
878 flags = F_CMD_DATAVALID | F_CMD_SOP | V_CMD_EOP(nfrags == 0) | 1279 for (i = 0; nfrags--; i++) {
879 V_CMD_GEN2(gen);
880 e = &q->entries[pidx];
881 e->addr_lo = (u32)mapping;
882 e->addr_hi = (u64)mapping >> 32;
883 e->len_gen = V_CMD_LEN(skb->len - skb->data_len) | V_CMD_GEN1(gen);
884 for (e1 = e, i = 0; nfrags--; i++) {
885 skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; 1280 skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
886
887 ce++;
888 e1++; 1281 e1++;
1282 ce++;
889 if (++pidx == q->size) { 1283 if (++pidx == q->size) {
890 pidx = 0; 1284 pidx = 0;
891 gen ^= 1; 1285 gen ^= 1;
892 ce = q->centries;
893 e1 = q->entries; 1286 e1 = q->entries;
1287 ce = q->centries;
894 } 1288 }
895 1289
896 mapping = pci_map_page(adapter->pdev, frag->page, 1290 mapping = pci_map_page(adapter->pdev, frag->page,
897 frag->page_offset, frag->size, 1291 frag->page_offset, frag->size,
898 PCI_DMA_TODEVICE); 1292 PCI_DMA_TODEVICE);
1293 desc_mapping = mapping;
1294 desc_len = frag->size;
1295
1296 pidx = write_large_page_tx_descs(pidx, &e1, &ce, &gen,
1297 &desc_mapping, &desc_len,
1298 nfrags, q);
1299 if (likely(desc_len))
1300 write_tx_desc(e1, desc_mapping, desc_len, gen,
1301 nfrags == 0);
899 ce->skb = NULL; 1302 ce->skb = NULL;
900 pci_unmap_addr_set(ce, dma_addr, mapping); 1303 pci_unmap_addr_set(ce, dma_addr, mapping);
901 pci_unmap_len_set(ce, dma_len, frag->size); 1304 pci_unmap_len_set(ce, dma_len, frag->size);
902
903 e1->addr_lo = (u32)mapping;
904 e1->addr_hi = (u64)mapping >> 32;
905 e1->len_gen = V_CMD_LEN(frag->size) | V_CMD_GEN1(gen);
906 e1->flags = F_CMD_DATAVALID | V_CMD_EOP(nfrags == 0) |
907 V_CMD_GEN2(gen);
908 } 1305 }
909
910 ce->skb = skb; 1306 ce->skb = skb;
911 wmb(); 1307 wmb();
912 e->flags = flags; 1308 e->flags = flags;
@@ -920,26 +1316,56 @@ static inline void reclaim_completed_tx(struct sge *sge, struct cmdQ *q)
920 unsigned int reclaim = q->processed - q->cleaned; 1316 unsigned int reclaim = q->processed - q->cleaned;
921 1317
922 if (reclaim) { 1318 if (reclaim) {
1319 pr_debug("reclaim_completed_tx processed:%d cleaned:%d\n",
1320 q->processed, q->cleaned);
923 free_cmdQ_buffers(sge, q, reclaim); 1321 free_cmdQ_buffers(sge, q, reclaim);
924 q->cleaned += reclaim; 1322 q->cleaned += reclaim;
925 } 1323 }
926} 1324}
927 1325
928#ifndef SET_ETHTOOL_OPS
929# define __netif_rx_complete(dev) netif_rx_complete(dev)
930#endif
931
932/* 1326/*
933 * We cannot use the standard netif_rx_schedule_prep() because we have multiple 1327 * Called from tasklet. Checks the scheduler for any
934 * ports plus the TOE all multiplexing onto a single response queue, therefore 1328 * pending skbs that can be sent.
935 * accepting new responses cannot depend on the state of any particular port.
936 * So define our own equivalent that omits the netif_running() test.
937 */ 1329 */
938static inline int napi_schedule_prep(struct net_device *dev) 1330static void restart_sched(unsigned long arg)
939{ 1331{
940 return !test_and_set_bit(__LINK_STATE_RX_SCHED, &dev->state); 1332 struct sge *sge = (struct sge *) arg;
941} 1333 struct adapter *adapter = sge->adapter;
1334 struct cmdQ *q = &sge->cmdQ[0];
1335 struct sk_buff *skb;
1336 unsigned int credits, queued_skb = 0;
942 1337
1338 spin_lock(&q->lock);
1339 reclaim_completed_tx(sge, q);
1340
1341 credits = q->size - q->in_use;
1342 pr_debug("restart_sched credits=%d\n", credits);
1343 while ((skb = sched_skb(sge, NULL, credits)) != NULL) {
1344 unsigned int genbit, pidx, count;
1345 count = 1 + skb_shinfo(skb)->nr_frags;
1346 count += compute_large_page_tx_descs(skb);
1347 q->in_use += count;
1348 genbit = q->genbit;
1349 pidx = q->pidx;
1350 q->pidx += count;
1351 if (q->pidx >= q->size) {
1352 q->pidx -= q->size;
1353 q->genbit ^= 1;
1354 }
1355 write_tx_descs(adapter, skb, pidx, genbit, q);
1356 credits = q->size - q->in_use;
1357 queued_skb = 1;
1358 }
1359
1360 if (queued_skb) {
1361 clear_bit(CMDQ_STAT_LAST_PKT_DB, &q->status);
1362 if (test_and_set_bit(CMDQ_STAT_RUNNING, &q->status) == 0) {
1363 set_bit(CMDQ_STAT_LAST_PKT_DB, &q->status);
1364 writel(F_CMDQ0_ENABLE, adapter->regs + A_SG_DOORBELL);
1365 }
1366 }
1367 spin_unlock(&q->lock);
1368}
943 1369
944/** 1370/**
945 * sge_rx - process an ingress ethernet packet 1371 * sge_rx - process an ingress ethernet packet
@@ -954,31 +1380,39 @@ static int sge_rx(struct sge *sge, struct freelQ *fl, unsigned int len)
954 struct sk_buff *skb; 1380 struct sk_buff *skb;
955 struct cpl_rx_pkt *p; 1381 struct cpl_rx_pkt *p;
956 struct adapter *adapter = sge->adapter; 1382 struct adapter *adapter = sge->adapter;
1383 struct sge_port_stats *st;
957 1384
958 sge->stats.ethernet_pkts++;
959 skb = get_packet(adapter->pdev, fl, len - sge->rx_pkt_pad, 1385 skb = get_packet(adapter->pdev, fl, len - sge->rx_pkt_pad,
960 sge->rx_pkt_pad, 2, SGE_RX_COPY_THRES, 1386 sge->rx_pkt_pad, 2, SGE_RX_COPY_THRES,
961 SGE_RX_DROP_THRES); 1387 SGE_RX_DROP_THRES);
962 if (!skb) { 1388 if (unlikely(!skb)) {
963 sge->port_stats[0].rx_drops++; /* charge only port 0 for now */ 1389 sge->stats.rx_drops++;
964 return 0; 1390 return 0;
965 } 1391 }
966 1392
967 p = (struct cpl_rx_pkt *)skb->data; 1393 p = (struct cpl_rx_pkt *)skb->data;
968 skb_pull(skb, sizeof(*p)); 1394 skb_pull(skb, sizeof(*p));
1395 if (p->iff >= adapter->params.nports) {
1396 kfree_skb(skb);
1397 return 0;
1398 }
1399
969 skb->dev = adapter->port[p->iff].dev; 1400 skb->dev = adapter->port[p->iff].dev;
970 skb->dev->last_rx = jiffies; 1401 skb->dev->last_rx = jiffies;
1402 st = per_cpu_ptr(sge->port_stats[p->iff], smp_processor_id());
1403 st->rx_packets++;
1404
971 skb->protocol = eth_type_trans(skb, skb->dev); 1405 skb->protocol = eth_type_trans(skb, skb->dev);
972 if ((adapter->flags & RX_CSUM_ENABLED) && p->csum == 0xffff && 1406 if ((adapter->flags & RX_CSUM_ENABLED) && p->csum == 0xffff &&
973 skb->protocol == htons(ETH_P_IP) && 1407 skb->protocol == htons(ETH_P_IP) &&
974 (skb->data[9] == IPPROTO_TCP || skb->data[9] == IPPROTO_UDP)) { 1408 (skb->data[9] == IPPROTO_TCP || skb->data[9] == IPPROTO_UDP)) {
975 sge->port_stats[p->iff].rx_cso_good++; 1409 ++st->rx_cso_good;
976 skb->ip_summed = CHECKSUM_UNNECESSARY; 1410 skb->ip_summed = CHECKSUM_UNNECESSARY;
977 } else 1411 } else
978 skb->ip_summed = CHECKSUM_NONE; 1412 skb->ip_summed = CHECKSUM_NONE;
979 1413
980 if (unlikely(adapter->vlan_grp && p->vlan_valid)) { 1414 if (unlikely(adapter->vlan_grp && p->vlan_valid)) {
981 sge->port_stats[p->iff].vlan_xtract++; 1415 st->vlan_xtract++;
982 if (adapter->params.sge.polling) 1416 if (adapter->params.sge.polling)
983 vlan_hwaccel_receive_skb(skb, adapter->vlan_grp, 1417 vlan_hwaccel_receive_skb(skb, adapter->vlan_grp,
984 ntohs(p->vlan)); 1418 ntohs(p->vlan));
@@ -1039,18 +1473,24 @@ static unsigned int update_tx_info(struct adapter *adapter,
1039 struct cmdQ *cmdq = &sge->cmdQ[0]; 1473 struct cmdQ *cmdq = &sge->cmdQ[0];
1040 1474
1041 cmdq->processed += pr0; 1475 cmdq->processed += pr0;
1042 1476 if (flags & (F_FL0_ENABLE | F_FL1_ENABLE)) {
1477 freelQs_empty(sge);
1478 flags &= ~(F_FL0_ENABLE | F_FL1_ENABLE);
1479 }
1043 if (flags & F_CMDQ0_ENABLE) { 1480 if (flags & F_CMDQ0_ENABLE) {
1044 clear_bit(CMDQ_STAT_RUNNING, &cmdq->status); 1481 clear_bit(CMDQ_STAT_RUNNING, &cmdq->status);
1045 1482
1046 if (cmdq->cleaned + cmdq->in_use != cmdq->processed && 1483 if (cmdq->cleaned + cmdq->in_use != cmdq->processed &&
1047 !test_and_set_bit(CMDQ_STAT_LAST_PKT_DB, &cmdq->status)) { 1484 !test_and_set_bit(CMDQ_STAT_LAST_PKT_DB, &cmdq->status)) {
1048 set_bit(CMDQ_STAT_RUNNING, &cmdq->status); 1485 set_bit(CMDQ_STAT_RUNNING, &cmdq->status);
1049 writel(F_CMDQ0_ENABLE, adapter->regs + A_SG_DOORBELL); 1486 writel(F_CMDQ0_ENABLE, adapter->regs + A_SG_DOORBELL);
1050 } 1487 }
1051 flags &= ~F_CMDQ0_ENABLE; 1488 if (sge->tx_sched)
1489 tasklet_hi_schedule(&sge->tx_sched->sched_tsk);
1490
1491 flags &= ~F_CMDQ0_ENABLE;
1052 } 1492 }
1053 1493
1054 if (unlikely(sge->stopped_tx_queues != 0)) 1494 if (unlikely(sge->stopped_tx_queues != 0))
1055 restart_tx_queues(sge); 1495 restart_tx_queues(sge);
1056 1496
@@ -1241,20 +1681,21 @@ static irqreturn_t t1_interrupt_napi(int irq, void *data)
1241 if (e->GenerationBit == q->genbit) { 1681 if (e->GenerationBit == q->genbit) {
1242 if (e->DataValid || 1682 if (e->DataValid ||
1243 process_pure_responses(adapter, e)) { 1683 process_pure_responses(adapter, e)) {
1244 if (likely(napi_schedule_prep(sge->netdev))) 1684 if (likely(__netif_rx_schedule_prep(sge->netdev)))
1245 __netif_rx_schedule(sge->netdev); 1685 __netif_rx_schedule(sge->netdev);
1246 else 1686 else if (net_ratelimit())
1247 printk(KERN_CRIT 1687 printk(KERN_INFO
1248 "NAPI schedule failure!\n"); 1688 "NAPI schedule failure!\n");
1249 } else 1689 } else
1250 writel(q->cidx, adapter->regs + A_SG_SLEEPING); 1690 writel(q->cidx, adapter->regs + A_SG_SLEEPING);
1691
1251 handled = 1; 1692 handled = 1;
1252 goto unlock; 1693 goto unlock;
1253 } else 1694 } else
1254 writel(q->cidx, adapter->regs + A_SG_SLEEPING); 1695 writel(q->cidx, adapter->regs + A_SG_SLEEPING);
1255 } else 1696 } else if (readl(adapter->regs + A_PL_CAUSE) & F_PL_INTR_SGE_DATA) {
1256 if (readl(adapter->regs + A_PL_CAUSE) & F_PL_INTR_SGE_DATA) 1697 printk(KERN_ERR "data interrupt while NAPI running\n");
1257 printk(KERN_ERR "data interrupt while NAPI running\n"); 1698 }
1258 1699
1259 handled = t1_slow_intr_handler(adapter); 1700 handled = t1_slow_intr_handler(adapter);
1260 if (!handled) 1701 if (!handled)
@@ -1335,34 +1776,59 @@ static int t1_sge_tx(struct sk_buff *skb, struct adapter *adapter,
1335{ 1776{
1336 struct sge *sge = adapter->sge; 1777 struct sge *sge = adapter->sge;
1337 struct cmdQ *q = &sge->cmdQ[qid]; 1778 struct cmdQ *q = &sge->cmdQ[qid];
1338 unsigned int credits, pidx, genbit, count; 1779 unsigned int credits, pidx, genbit, count, use_sched_skb = 0;
1780
1781 if (!spin_trylock(&q->lock))
1782 return NETDEV_TX_LOCKED;
1339 1783
1340 spin_lock(&q->lock);
1341 reclaim_completed_tx(sge, q); 1784 reclaim_completed_tx(sge, q);
1342 1785
1343 pidx = q->pidx; 1786 pidx = q->pidx;
1344 credits = q->size - q->in_use; 1787 credits = q->size - q->in_use;
1345 count = 1 + skb_shinfo(skb)->nr_frags; 1788 count = 1 + skb_shinfo(skb)->nr_frags;
1789 count += compute_large_page_tx_descs(skb);
1346 1790
1347 { /* Ethernet packet */ 1791 /* Ethernet packet */
1348 if (unlikely(credits < count)) { 1792 if (unlikely(credits < count)) {
1793 if (!netif_queue_stopped(dev)) {
1349 netif_stop_queue(dev); 1794 netif_stop_queue(dev);
1350 set_bit(dev->if_port, &sge->stopped_tx_queues); 1795 set_bit(dev->if_port, &sge->stopped_tx_queues);
1351 sge->stats.cmdQ_full[2]++; 1796 sge->stats.cmdQ_full[2]++;
1352 spin_unlock(&q->lock); 1797 CH_ERR("%s: Tx ring full while queue awake!\n",
1353 if (!netif_queue_stopped(dev)) 1798 adapter->name);
1354 CH_ERR("%s: Tx ring full while queue awake!\n",
1355 adapter->name);
1356 return NETDEV_TX_BUSY;
1357 } 1799 }
1358 if (unlikely(credits - count < q->stop_thres)) { 1800 spin_unlock(&q->lock);
1359 sge->stats.cmdQ_full[2]++; 1801 return NETDEV_TX_BUSY;
1360 netif_stop_queue(dev); 1802 }
1361 set_bit(dev->if_port, &sge->stopped_tx_queues); 1803
1804 if (unlikely(credits - count < q->stop_thres)) {
1805 netif_stop_queue(dev);
1806 set_bit(dev->if_port, &sge->stopped_tx_queues);
1807 sge->stats.cmdQ_full[2]++;
1808 }
1809
1810 /* T204 cmdQ0 skbs that are destined for a certain port have to go
1811 * through the scheduler.
1812 */
1813 if (sge->tx_sched && !qid && skb->dev) {
1814 use_sched:
1815 use_sched_skb = 1;
1816 /* Note that the scheduler might return a different skb than
1817 * the one passed in.
1818 */
1819 skb = sched_skb(sge, skb, credits);
1820 if (!skb) {
1821 spin_unlock(&q->lock);
1822 return NETDEV_TX_OK;
1362 } 1823 }
1824 pidx = q->pidx;
1825 count = 1 + skb_shinfo(skb)->nr_frags;
1826 count += compute_large_page_tx_descs(skb);
1363 } 1827 }
1828
1364 q->in_use += count; 1829 q->in_use += count;
1365 genbit = q->genbit; 1830 genbit = q->genbit;
1831 pidx = q->pidx;
1366 q->pidx += count; 1832 q->pidx += count;
1367 if (q->pidx >= q->size) { 1833 if (q->pidx >= q->size) {
1368 q->pidx -= q->size; 1834 q->pidx -= q->size;
@@ -1388,6 +1854,14 @@ static int t1_sge_tx(struct sk_buff *skb, struct adapter *adapter,
1388 writel(F_CMDQ0_ENABLE, adapter->regs + A_SG_DOORBELL); 1854 writel(F_CMDQ0_ENABLE, adapter->regs + A_SG_DOORBELL);
1389 } 1855 }
1390 } 1856 }
1857
1858 if (use_sched_skb) {
1859 if (spin_trylock(&q->lock)) {
1860 credits = q->size - q->in_use;
1861 skb = NULL;
1862 goto use_sched;
1863 }
1864 }
1391 return NETDEV_TX_OK; 1865 return NETDEV_TX_OK;
1392} 1866}
1393 1867
@@ -1412,16 +1886,20 @@ static inline int eth_hdr_len(const void *data)
1412int t1_start_xmit(struct sk_buff *skb, struct net_device *dev) 1886int t1_start_xmit(struct sk_buff *skb, struct net_device *dev)
1413{ 1887{
1414 struct adapter *adapter = dev->priv; 1888 struct adapter *adapter = dev->priv;
1415 struct sge_port_stats *st = &adapter->sge->port_stats[dev->if_port];
1416 struct sge *sge = adapter->sge; 1889 struct sge *sge = adapter->sge;
1890 struct sge_port_stats *st = per_cpu_ptr(sge->port_stats[dev->if_port], smp_processor_id());
1417 struct cpl_tx_pkt *cpl; 1891 struct cpl_tx_pkt *cpl;
1892 struct sk_buff *orig_skb = skb;
1893 int ret;
1894
1895 if (skb->protocol == htons(ETH_P_CPL5))
1896 goto send;
1418 1897
1419#ifdef NETIF_F_TSO 1898 if (skb_shinfo(skb)->gso_size) {
1420 if (skb_is_gso(skb)) {
1421 int eth_type; 1899 int eth_type;
1422 struct cpl_tx_pkt_lso *hdr; 1900 struct cpl_tx_pkt_lso *hdr;
1423 1901
1424 st->tso++; 1902 ++st->tx_tso;
1425 1903
1426 eth_type = skb->nh.raw - skb->data == ETH_HLEN ? 1904 eth_type = skb->nh.raw - skb->data == ETH_HLEN ?
1427 CPL_ETH_II : CPL_ETH_II_VLAN; 1905 CPL_ETH_II : CPL_ETH_II_VLAN;
@@ -1432,13 +1910,10 @@ int t1_start_xmit(struct sk_buff *skb, struct net_device *dev)
1432 hdr->ip_hdr_words = skb->nh.iph->ihl; 1910 hdr->ip_hdr_words = skb->nh.iph->ihl;
1433 hdr->tcp_hdr_words = skb->h.th->doff; 1911 hdr->tcp_hdr_words = skb->h.th->doff;
1434 hdr->eth_type_mss = htons(MK_ETH_TYPE_MSS(eth_type, 1912 hdr->eth_type_mss = htons(MK_ETH_TYPE_MSS(eth_type,
1435 skb_shinfo(skb)->gso_size)); 1913 skb_shinfo(skb)->gso_size));
1436 hdr->len = htonl(skb->len - sizeof(*hdr)); 1914 hdr->len = htonl(skb->len - sizeof(*hdr));
1437 cpl = (struct cpl_tx_pkt *)hdr; 1915 cpl = (struct cpl_tx_pkt *)hdr;
1438 sge->stats.tx_lso_pkts++; 1916 } else {
1439 } else
1440#endif
1441 {
1442 /* 1917 /*
1443 * Packets shorter than ETH_HLEN can break the MAC, drop them 1918 * Packets shorter than ETH_HLEN can break the MAC, drop them
1444 * early. Also, we may get oversized packets because some 1919 * early. Also, we may get oversized packets because some
@@ -1447,6 +1922,8 @@ int t1_start_xmit(struct sk_buff *skb, struct net_device *dev)
1447 */ 1922 */
1448 if (unlikely(skb->len < ETH_HLEN || 1923 if (unlikely(skb->len < ETH_HLEN ||
1449 skb->len > dev->mtu + eth_hdr_len(skb->data))) { 1924 skb->len > dev->mtu + eth_hdr_len(skb->data))) {
1925 pr_debug("%s: packet size %d hdr %d mtu%d\n", dev->name,
1926 skb->len, eth_hdr_len(skb->data), dev->mtu);
1450 dev_kfree_skb_any(skb); 1927 dev_kfree_skb_any(skb);
1451 return NETDEV_TX_OK; 1928 return NETDEV_TX_OK;
1452 } 1929 }
@@ -1456,9 +1933,9 @@ int t1_start_xmit(struct sk_buff *skb, struct net_device *dev)
1456 * components, such as pktgen, do not handle it right. 1933 * components, such as pktgen, do not handle it right.
1457 * Complain when this happens but try to fix things up. 1934 * Complain when this happens but try to fix things up.
1458 */ 1935 */
1459 if (unlikely(skb_headroom(skb) < 1936 if (unlikely(skb_headroom(skb) < dev->hard_header_len - ETH_HLEN)) {
1460 dev->hard_header_len - ETH_HLEN)) { 1937 pr_debug("%s: headroom %d header_len %d\n", dev->name,
1461 struct sk_buff *orig_skb = skb; 1938 skb_headroom(skb), dev->hard_header_len);
1462 1939
1463 if (net_ratelimit()) 1940 if (net_ratelimit())
1464 printk(KERN_ERR "%s: inadequate headroom in " 1941 printk(KERN_ERR "%s: inadequate headroom in "
@@ -1471,19 +1948,21 @@ int t1_start_xmit(struct sk_buff *skb, struct net_device *dev)
1471 1948
1472 if (!(adapter->flags & UDP_CSUM_CAPABLE) && 1949 if (!(adapter->flags & UDP_CSUM_CAPABLE) &&
1473 skb->ip_summed == CHECKSUM_PARTIAL && 1950 skb->ip_summed == CHECKSUM_PARTIAL &&
1474 skb->nh.iph->protocol == IPPROTO_UDP) 1951 skb->nh.iph->protocol == IPPROTO_UDP) {
1475 if (unlikely(skb_checksum_help(skb))) { 1952 if (unlikely(skb_checksum_help(skb))) {
1953 pr_debug("%s: unable to do udp checksum\n", dev->name);
1476 dev_kfree_skb_any(skb); 1954 dev_kfree_skb_any(skb);
1477 return NETDEV_TX_OK; 1955 return NETDEV_TX_OK;
1478 } 1956 }
1957 }
1479 1958
1480 /* Hmmm, assuming to catch the gratious arp... and we'll use 1959 /* Hmmm, assuming to catch the gratious arp... and we'll use
1481 * it to flush out stuck espi packets... 1960 * it to flush out stuck espi packets...
1482 */ 1961 */
1483 if (unlikely(!adapter->sge->espibug_skb)) { 1962 if ((unlikely(!adapter->sge->espibug_skb[dev->if_port]))) {
1484 if (skb->protocol == htons(ETH_P_ARP) && 1963 if (skb->protocol == htons(ETH_P_ARP) &&
1485 skb->nh.arph->ar_op == htons(ARPOP_REQUEST)) { 1964 skb->nh.arph->ar_op == htons(ARPOP_REQUEST)) {
1486 adapter->sge->espibug_skb = skb; 1965 adapter->sge->espibug_skb[dev->if_port] = skb;
1487 /* We want to re-use this skb later. We 1966 /* We want to re-use this skb later. We
1488 * simply bump the reference count and it 1967 * simply bump the reference count and it
1489 * will not be freed... 1968 * will not be freed...
@@ -1499,8 +1978,6 @@ int t1_start_xmit(struct sk_buff *skb, struct net_device *dev)
1499 /* the length field isn't used so don't bother setting it */ 1978 /* the length field isn't used so don't bother setting it */
1500 1979
1501 st->tx_cso += (skb->ip_summed == CHECKSUM_PARTIAL); 1980 st->tx_cso += (skb->ip_summed == CHECKSUM_PARTIAL);
1502 sge->stats.tx_do_cksum += (skb->ip_summed == CHECKSUM_PARTIAL);
1503 sge->stats.tx_reg_pkts++;
1504 } 1981 }
1505 cpl->iff = dev->if_port; 1982 cpl->iff = dev->if_port;
1506 1983
@@ -1513,8 +1990,19 @@ int t1_start_xmit(struct sk_buff *skb, struct net_device *dev)
1513#endif 1990#endif
1514 cpl->vlan_valid = 0; 1991 cpl->vlan_valid = 0;
1515 1992
1993send:
1994 st->tx_packets++;
1516 dev->trans_start = jiffies; 1995 dev->trans_start = jiffies;
1517 return t1_sge_tx(skb, adapter, 0, dev); 1996 ret = t1_sge_tx(skb, adapter, 0, dev);
1997
1998 /* If transmit busy, and we reallocated skb's due to headroom limit,
1999 * then silently discard to avoid leak.
2000 */
2001 if (unlikely(ret != NETDEV_TX_OK && skb != orig_skb)) {
2002 dev_kfree_skb_any(skb);
2003 ret = NETDEV_TX_OK;
2004 }
2005 return ret;
1518} 2006}
1519 2007
1520/* 2008/*
@@ -1532,10 +2020,9 @@ static void sge_tx_reclaim_cb(unsigned long data)
1532 continue; 2020 continue;
1533 2021
1534 reclaim_completed_tx(sge, q); 2022 reclaim_completed_tx(sge, q);
1535 if (i == 0 && q->in_use) /* flush pending credits */ 2023 if (i == 0 && q->in_use) { /* flush pending credits */
1536 writel(F_CMDQ0_ENABLE, 2024 writel(F_CMDQ0_ENABLE, sge->adapter->regs + A_SG_DOORBELL);
1537 sge->adapter->regs + A_SG_DOORBELL); 2025 }
1538
1539 spin_unlock(&q->lock); 2026 spin_unlock(&q->lock);
1540 } 2027 }
1541 mod_timer(&sge->tx_reclaim_timer, jiffies + TX_RECLAIM_PERIOD); 2028 mod_timer(&sge->tx_reclaim_timer, jiffies + TX_RECLAIM_PERIOD);
@@ -1582,11 +2069,20 @@ int t1_sge_configure(struct sge *sge, struct sge_params *p)
1582 */ 2069 */
1583void t1_sge_stop(struct sge *sge) 2070void t1_sge_stop(struct sge *sge)
1584{ 2071{
2072 int i;
1585 writel(0, sge->adapter->regs + A_SG_CONTROL); 2073 writel(0, sge->adapter->regs + A_SG_CONTROL);
1586 (void) readl(sge->adapter->regs + A_SG_CONTROL); /* flush */ 2074 readl(sge->adapter->regs + A_SG_CONTROL); /* flush */
2075
1587 if (is_T2(sge->adapter)) 2076 if (is_T2(sge->adapter))
1588 del_timer_sync(&sge->espibug_timer); 2077 del_timer_sync(&sge->espibug_timer);
2078
1589 del_timer_sync(&sge->tx_reclaim_timer); 2079 del_timer_sync(&sge->tx_reclaim_timer);
2080 if (sge->tx_sched)
2081 tx_sched_stop(sge);
2082
2083 for (i = 0; i < MAX_NPORTS; i++)
2084 if (sge->espibug_skb[i])
2085 kfree_skb(sge->espibug_skb[i]);
1590} 2086}
1591 2087
1592/* 2088/*
@@ -1599,74 +2095,128 @@ void t1_sge_start(struct sge *sge)
1599 2095
1600 writel(sge->sge_control, sge->adapter->regs + A_SG_CONTROL); 2096 writel(sge->sge_control, sge->adapter->regs + A_SG_CONTROL);
1601 doorbell_pio(sge->adapter, F_FL0_ENABLE | F_FL1_ENABLE); 2097 doorbell_pio(sge->adapter, F_FL0_ENABLE | F_FL1_ENABLE);
1602 (void) readl(sge->adapter->regs + A_SG_CONTROL); /* flush */ 2098 readl(sge->adapter->regs + A_SG_CONTROL); /* flush */
1603 2099
1604 mod_timer(&sge->tx_reclaim_timer, jiffies + TX_RECLAIM_PERIOD); 2100 mod_timer(&sge->tx_reclaim_timer, jiffies + TX_RECLAIM_PERIOD);
1605 2101
1606 if (is_T2(sge->adapter)) 2102 if (is_T2(sge->adapter))
1607 mod_timer(&sge->espibug_timer, jiffies + sge->espibug_timeout); 2103 mod_timer(&sge->espibug_timer, jiffies + sge->espibug_timeout);
1608} 2104}
1609 2105
1610/* 2106/*
1611 * Callback for the T2 ESPI 'stuck packet feature' workaorund 2107 * Callback for the T2 ESPI 'stuck packet feature' workaorund
1612 */ 2108 */
1613static void espibug_workaround(void *data) 2109static void espibug_workaround_t204(unsigned long data)
1614{ 2110{
1615 struct adapter *adapter = (struct adapter *)data; 2111 struct adapter *adapter = (struct adapter *)data;
1616 struct sge *sge = adapter->sge; 2112 struct sge *sge = adapter->sge;
2113 unsigned int nports = adapter->params.nports;
2114 u32 seop[MAX_NPORTS];
1617 2115
1618 if (netif_running(adapter->port[0].dev)) { 2116 if (adapter->open_device_map & PORT_MASK) {
1619 struct sk_buff *skb = sge->espibug_skb; 2117 int i;
1620 2118 if (t1_espi_get_mon_t204(adapter, &(seop[0]), 0) < 0) {
1621 u32 seop = t1_espi_get_mon(adapter, 0x930, 0); 2119 return;
1622 2120 }
1623 if ((seop & 0xfff0fff) == 0xfff && skb) { 2121 for (i = 0; i < nports; i++) {
1624 if (!skb->cb[0]) { 2122 struct sk_buff *skb = sge->espibug_skb[i];
1625 u8 ch_mac_addr[ETH_ALEN] = 2123 if ( (netif_running(adapter->port[i].dev)) &&
1626 {0x0, 0x7, 0x43, 0x0, 0x0, 0x0}; 2124 !(netif_queue_stopped(adapter->port[i].dev)) &&
1627 memcpy(skb->data + sizeof(struct cpl_tx_pkt), 2125 (seop[i] && ((seop[i] & 0xfff) == 0)) &&
1628 ch_mac_addr, ETH_ALEN); 2126 skb ) {
1629 memcpy(skb->data + skb->len - 10, ch_mac_addr, 2127 if (!skb->cb[0]) {
1630 ETH_ALEN); 2128 u8 ch_mac_addr[ETH_ALEN] =
1631 skb->cb[0] = 0xff; 2129 {0x0, 0x7, 0x43, 0x0, 0x0, 0x0};
2130 memcpy(skb->data + sizeof(struct cpl_tx_pkt),
2131 ch_mac_addr, ETH_ALEN);
2132 memcpy(skb->data + skb->len - 10,
2133 ch_mac_addr, ETH_ALEN);
2134 skb->cb[0] = 0xff;
2135 }
2136
2137 /* bump the reference count to avoid freeing of
2138 * the skb once the DMA has completed.
2139 */
2140 skb = skb_get(skb);
2141 t1_sge_tx(skb, adapter, 0, adapter->port[i].dev);
1632 } 2142 }
1633
1634 /* bump the reference count to avoid freeing of the
1635 * skb once the DMA has completed.
1636 */
1637 skb = skb_get(skb);
1638 t1_sge_tx(skb, adapter, 0, adapter->port[0].dev);
1639 } 2143 }
1640 } 2144 }
1641 mod_timer(&sge->espibug_timer, jiffies + sge->espibug_timeout); 2145 mod_timer(&sge->espibug_timer, jiffies + sge->espibug_timeout);
1642} 2146}
1643 2147
2148static void espibug_workaround(unsigned long data)
2149{
2150 struct adapter *adapter = (struct adapter *)data;
2151 struct sge *sge = adapter->sge;
2152
2153 if (netif_running(adapter->port[0].dev)) {
2154 struct sk_buff *skb = sge->espibug_skb[0];
2155 u32 seop = t1_espi_get_mon(adapter, 0x930, 0);
2156
2157 if ((seop & 0xfff0fff) == 0xfff && skb) {
2158 if (!skb->cb[0]) {
2159 u8 ch_mac_addr[ETH_ALEN] =
2160 {0x0, 0x7, 0x43, 0x0, 0x0, 0x0};
2161 memcpy(skb->data + sizeof(struct cpl_tx_pkt),
2162 ch_mac_addr, ETH_ALEN);
2163 memcpy(skb->data + skb->len - 10, ch_mac_addr,
2164 ETH_ALEN);
2165 skb->cb[0] = 0xff;
2166 }
2167
2168 /* bump the reference count to avoid freeing of the
2169 * skb once the DMA has completed.
2170 */
2171 skb = skb_get(skb);
2172 t1_sge_tx(skb, adapter, 0, adapter->port[0].dev);
2173 }
2174 }
2175 mod_timer(&sge->espibug_timer, jiffies + sge->espibug_timeout);
2176}
2177
1644/* 2178/*
1645 * Creates a t1_sge structure and returns suggested resource parameters. 2179 * Creates a t1_sge structure and returns suggested resource parameters.
1646 */ 2180 */
1647struct sge * __devinit t1_sge_create(struct adapter *adapter, 2181struct sge * __devinit t1_sge_create(struct adapter *adapter,
1648 struct sge_params *p) 2182 struct sge_params *p)
1649{ 2183{
1650 struct sge *sge = kmalloc(sizeof(*sge), GFP_KERNEL); 2184 struct sge *sge = kzalloc(sizeof(*sge), GFP_KERNEL);
2185 int i;
1651 2186
1652 if (!sge) 2187 if (!sge)
1653 return NULL; 2188 return NULL;
1654 memset(sge, 0, sizeof(*sge));
1655 2189
1656 sge->adapter = adapter; 2190 sge->adapter = adapter;
1657 sge->netdev = adapter->port[0].dev; 2191 sge->netdev = adapter->port[0].dev;
1658 sge->rx_pkt_pad = t1_is_T1B(adapter) ? 0 : 2; 2192 sge->rx_pkt_pad = t1_is_T1B(adapter) ? 0 : 2;
1659 sge->jumbo_fl = t1_is_T1B(adapter) ? 1 : 0; 2193 sge->jumbo_fl = t1_is_T1B(adapter) ? 1 : 0;
1660 2194
2195 for_each_port(adapter, i) {
2196 sge->port_stats[i] = alloc_percpu(struct sge_port_stats);
2197 if (!sge->port_stats[i])
2198 goto nomem_port;
2199 }
2200
1661 init_timer(&sge->tx_reclaim_timer); 2201 init_timer(&sge->tx_reclaim_timer);
1662 sge->tx_reclaim_timer.data = (unsigned long)sge; 2202 sge->tx_reclaim_timer.data = (unsigned long)sge;
1663 sge->tx_reclaim_timer.function = sge_tx_reclaim_cb; 2203 sge->tx_reclaim_timer.function = sge_tx_reclaim_cb;
1664 2204
1665 if (is_T2(sge->adapter)) { 2205 if (is_T2(sge->adapter)) {
1666 init_timer(&sge->espibug_timer); 2206 init_timer(&sge->espibug_timer);
1667 sge->espibug_timer.function = (void *)&espibug_workaround; 2207
2208 if (adapter->params.nports > 1) {
2209 tx_sched_init(sge);
2210 sge->espibug_timer.function = espibug_workaround_t204;
2211 } else {
2212 sge->espibug_timer.function = espibug_workaround;
2213 }
1668 sge->espibug_timer.data = (unsigned long)sge->adapter; 2214 sge->espibug_timer.data = (unsigned long)sge->adapter;
2215
1669 sge->espibug_timeout = 1; 2216 sge->espibug_timeout = 1;
2217 /* for T204, every 10ms */
2218 if (adapter->params.nports > 1)
2219 sge->espibug_timeout = HZ/100;
1670 } 2220 }
1671 2221
1672 2222
@@ -1674,10 +2224,25 @@ struct sge * __devinit t1_sge_create(struct adapter *adapter,
1674 p->cmdQ_size[1] = SGE_CMDQ1_E_N; 2224 p->cmdQ_size[1] = SGE_CMDQ1_E_N;
1675 p->freelQ_size[!sge->jumbo_fl] = SGE_FREEL_SIZE; 2225 p->freelQ_size[!sge->jumbo_fl] = SGE_FREEL_SIZE;
1676 p->freelQ_size[sge->jumbo_fl] = SGE_JUMBO_FREEL_SIZE; 2226 p->freelQ_size[sge->jumbo_fl] = SGE_JUMBO_FREEL_SIZE;
1677 p->rx_coalesce_usecs = 50; 2227 if (sge->tx_sched) {
2228 if (board_info(sge->adapter)->board == CHBT_BOARD_CHT204)
2229 p->rx_coalesce_usecs = 15;
2230 else
2231 p->rx_coalesce_usecs = 50;
2232 } else
2233 p->rx_coalesce_usecs = 50;
2234
1678 p->coalesce_enable = 0; 2235 p->coalesce_enable = 0;
1679 p->sample_interval_usecs = 0; 2236 p->sample_interval_usecs = 0;
1680 p->polling = 0; 2237 p->polling = 0;
1681 2238
1682 return sge; 2239 return sge;
2240nomem_port:
2241 while (i >= 0) {
2242 free_percpu(sge->port_stats[i]);
2243 --i;
2244 }
2245 kfree(sge);
2246 return NULL;
2247
1683} 2248}
diff --git a/drivers/net/chelsio/sge.h b/drivers/net/chelsio/sge.h
index 91af47bab7be..7ceb0117d039 100644
--- a/drivers/net/chelsio/sge.h
+++ b/drivers/net/chelsio/sge.h
@@ -44,6 +44,9 @@
44#include <asm/byteorder.h> 44#include <asm/byteorder.h>
45 45
46struct sge_intr_counts { 46struct sge_intr_counts {
47 unsigned int rx_drops; /* # of packets dropped due to no mem */
48 unsigned int pure_rsps; /* # of non-payload responses */
49 unsigned int unhandled_irqs; /* # of unhandled interrupts */
47 unsigned int respQ_empty; /* # times respQ empty */ 50 unsigned int respQ_empty; /* # times respQ empty */
48 unsigned int respQ_overflow; /* # respQ overflow (fatal) */ 51 unsigned int respQ_overflow; /* # respQ overflow (fatal) */
49 unsigned int freelistQ_empty; /* # times freelist empty */ 52 unsigned int freelistQ_empty; /* # times freelist empty */
@@ -51,24 +54,16 @@ struct sge_intr_counts {
51 unsigned int pkt_mismatch; 54 unsigned int pkt_mismatch;
52 unsigned int cmdQ_full[3]; /* not HW IRQ, host cmdQ[] full */ 55 unsigned int cmdQ_full[3]; /* not HW IRQ, host cmdQ[] full */
53 unsigned int cmdQ_restarted[3];/* # of times cmdQ X was restarted */ 56 unsigned int cmdQ_restarted[3];/* # of times cmdQ X was restarted */
54 unsigned int ethernet_pkts; /* # of Ethernet packets received */
55 unsigned int offload_pkts; /* # of offload packets received */
56 unsigned int offload_bundles; /* # of offload pkt bundles delivered */
57 unsigned int pure_rsps; /* # of non-payload responses */
58 unsigned int unhandled_irqs; /* # of unhandled interrupts */
59 unsigned int tx_ipfrags;
60 unsigned int tx_reg_pkts;
61 unsigned int tx_lso_pkts;
62 unsigned int tx_do_cksum;
63}; 57};
64 58
65struct sge_port_stats { 59struct sge_port_stats {
66 unsigned long rx_cso_good; /* # of successful RX csum offloads */ 60 u64 rx_packets; /* # of Ethernet packets received */
67 unsigned long tx_cso; /* # of TX checksum offloads */ 61 u64 rx_cso_good; /* # of successful RX csum offloads */
68 unsigned long vlan_xtract; /* # of VLAN tag extractions */ 62 u64 tx_packets; /* # of TX packets */
69 unsigned long vlan_insert; /* # of VLAN tag extractions */ 63 u64 tx_cso; /* # of TX checksum offloads */
70 unsigned long tso; /* # of TSO requests */ 64 u64 tx_tso; /* # of TSO requests */
71 unsigned long rx_drops; /* # of packets dropped due to no mem */ 65 u64 vlan_xtract; /* # of VLAN tag extractions */
66 u64 vlan_insert; /* # of VLAN tag insertions */
72}; 67};
73 68
74struct sk_buff; 69struct sk_buff;
@@ -90,7 +85,11 @@ int t1_sge_intr_error_handler(struct sge *);
90void t1_sge_intr_enable(struct sge *); 85void t1_sge_intr_enable(struct sge *);
91void t1_sge_intr_disable(struct sge *); 86void t1_sge_intr_disable(struct sge *);
92void t1_sge_intr_clear(struct sge *); 87void t1_sge_intr_clear(struct sge *);
93const struct sge_intr_counts *t1_sge_get_intr_counts(struct sge *sge); 88const struct sge_intr_counts *t1_sge_get_intr_counts(const struct sge *sge);
94const struct sge_port_stats *t1_sge_get_port_stats(struct sge *sge, int port); 89void t1_sge_get_port_stats(const struct sge *sge, int port, struct sge_port_stats *);
90void t1_sched_set_max_avail_bytes(struct sge *, unsigned int);
91void t1_sched_set_drain_bits_per_us(struct sge *, unsigned int, unsigned int);
92unsigned int t1_sched_update_parms(struct sge *, unsigned int, unsigned int,
93 unsigned int);
95 94
96#endif /* _CXGB_SGE_H_ */ 95#endif /* _CXGB_SGE_H_ */
diff --git a/drivers/net/chelsio/subr.c b/drivers/net/chelsio/subr.c
index 12e4e96dba2d..22ed9a383c08 100644
--- a/drivers/net/chelsio/subr.c
+++ b/drivers/net/chelsio/subr.c
@@ -43,6 +43,7 @@
43#include "gmac.h" 43#include "gmac.h"
44#include "cphy.h" 44#include "cphy.h"
45#include "sge.h" 45#include "sge.h"
46#include "tp.h"
46#include "espi.h" 47#include "espi.h"
47 48
48/** 49/**
@@ -59,7 +60,7 @@
59 * otherwise. 60 * otherwise.
60 */ 61 */
61static int t1_wait_op_done(adapter_t *adapter, int reg, u32 mask, int polarity, 62static int t1_wait_op_done(adapter_t *adapter, int reg, u32 mask, int polarity,
62 int attempts, int delay) 63 int attempts, int delay)
63{ 64{
64 while (1) { 65 while (1) {
65 u32 val = readl(adapter->regs + reg) & mask; 66 u32 val = readl(adapter->regs + reg) & mask;
@@ -78,7 +79,7 @@ static int t1_wait_op_done(adapter_t *adapter, int reg, u32 mask, int polarity,
78/* 79/*
79 * Write a register over the TPI interface (unlocked and locked versions). 80 * Write a register over the TPI interface (unlocked and locked versions).
80 */ 81 */
81static int __t1_tpi_write(adapter_t *adapter, u32 addr, u32 value) 82int __t1_tpi_write(adapter_t *adapter, u32 addr, u32 value)
82{ 83{
83 int tpi_busy; 84 int tpi_busy;
84 85
@@ -98,16 +99,16 @@ int t1_tpi_write(adapter_t *adapter, u32 addr, u32 value)
98{ 99{
99 int ret; 100 int ret;
100 101
101 spin_lock(&(adapter)->tpi_lock); 102 spin_lock(&adapter->tpi_lock);
102 ret = __t1_tpi_write(adapter, addr, value); 103 ret = __t1_tpi_write(adapter, addr, value);
103 spin_unlock(&(adapter)->tpi_lock); 104 spin_unlock(&adapter->tpi_lock);
104 return ret; 105 return ret;
105} 106}
106 107
107/* 108/*
108 * Read a register over the TPI interface (unlocked and locked versions). 109 * Read a register over the TPI interface (unlocked and locked versions).
109 */ 110 */
110static int __t1_tpi_read(adapter_t *adapter, u32 addr, u32 *valp) 111int __t1_tpi_read(adapter_t *adapter, u32 addr, u32 *valp)
111{ 112{
112 int tpi_busy; 113 int tpi_busy;
113 114
@@ -128,18 +129,26 @@ int t1_tpi_read(adapter_t *adapter, u32 addr, u32 *valp)
128{ 129{
129 int ret; 130 int ret;
130 131
131 spin_lock(&(adapter)->tpi_lock); 132 spin_lock(&adapter->tpi_lock);
132 ret = __t1_tpi_read(adapter, addr, valp); 133 ret = __t1_tpi_read(adapter, addr, valp);
133 spin_unlock(&(adapter)->tpi_lock); 134 spin_unlock(&adapter->tpi_lock);
134 return ret; 135 return ret;
135} 136}
136 137
137/* 138/*
139 * Set a TPI parameter.
140 */
141static void t1_tpi_par(adapter_t *adapter, u32 value)
142{
143 writel(V_TPIPAR(value), adapter->regs + A_TPI_PAR);
144}
145
146/*
138 * Called when a port's link settings change to propagate the new values to the 147 * Called when a port's link settings change to propagate the new values to the
139 * associated PHY and MAC. After performing the common tasks it invokes an 148 * associated PHY and MAC. After performing the common tasks it invokes an
140 * OS-specific handler. 149 * OS-specific handler.
141 */ 150 */
142/* static */ void link_changed(adapter_t *adapter, int port_id) 151void t1_link_changed(adapter_t *adapter, int port_id)
143{ 152{
144 int link_ok, speed, duplex, fc; 153 int link_ok, speed, duplex, fc;
145 struct cphy *phy = adapter->port[port_id].phy; 154 struct cphy *phy = adapter->port[port_id].phy;
@@ -159,23 +168,83 @@ int t1_tpi_read(adapter_t *adapter, u32 addr, u32 *valp)
159 mac->ops->set_speed_duplex_fc(mac, speed, duplex, fc); 168 mac->ops->set_speed_duplex_fc(mac, speed, duplex, fc);
160 lc->fc = (unsigned char)fc; 169 lc->fc = (unsigned char)fc;
161 } 170 }
162 t1_link_changed(adapter, port_id, link_ok, speed, duplex, fc); 171 t1_link_negotiated(adapter, port_id, link_ok, speed, duplex, fc);
163} 172}
164 173
165static int t1_pci_intr_handler(adapter_t *adapter) 174static int t1_pci_intr_handler(adapter_t *adapter)
166{ 175{
167 u32 pcix_cause; 176 u32 pcix_cause;
168 177
169 pci_read_config_dword(adapter->pdev, A_PCICFG_INTR_CAUSE, &pcix_cause); 178 pci_read_config_dword(adapter->pdev, A_PCICFG_INTR_CAUSE, &pcix_cause);
170 179
171 if (pcix_cause) { 180 if (pcix_cause) {
172 pci_write_config_dword(adapter->pdev, A_PCICFG_INTR_CAUSE, 181 pci_write_config_dword(adapter->pdev, A_PCICFG_INTR_CAUSE,
173 pcix_cause); 182 pcix_cause);
174 t1_fatal_err(adapter); /* PCI errors are fatal */ 183 t1_fatal_err(adapter); /* PCI errors are fatal */
175 } 184 }
176 return 0; 185 return 0;
177} 186}
178 187
188#ifdef CONFIG_CHELSIO_T1_COUGAR
189#include "cspi.h"
190#endif
191#ifdef CONFIG_CHELSIO_T1_1G
192#include "fpga_defs.h"
193
194/*
195 * PHY interrupt handler for FPGA boards.
196 */
197static int fpga_phy_intr_handler(adapter_t *adapter)
198{
199 int p;
200 u32 cause = readl(adapter->regs + FPGA_GMAC_ADDR_INTERRUPT_CAUSE);
201
202 for_each_port(adapter, p)
203 if (cause & (1 << p)) {
204 struct cphy *phy = adapter->port[p].phy;
205 int phy_cause = phy->ops->interrupt_handler(phy);
206
207 if (phy_cause & cphy_cause_link_change)
208 t1_link_changed(adapter, p);
209 }
210 writel(cause, adapter->regs + FPGA_GMAC_ADDR_INTERRUPT_CAUSE);
211 return 0;
212}
213
214/*
215 * Slow path interrupt handler for FPGAs.
216 */
217static int fpga_slow_intr(adapter_t *adapter)
218{
219 u32 cause = readl(adapter->regs + A_PL_CAUSE);
220
221 cause &= ~F_PL_INTR_SGE_DATA;
222 if (cause & F_PL_INTR_SGE_ERR)
223 t1_sge_intr_error_handler(adapter->sge);
224
225 if (cause & FPGA_PCIX_INTERRUPT_GMAC)
226 fpga_phy_intr_handler(adapter);
227
228 if (cause & FPGA_PCIX_INTERRUPT_TP) {
229 /*
230 * FPGA doesn't support MC4 interrupts and it requires
231 * this odd layer of indirection for MC5.
232 */
233 u32 tp_cause = readl(adapter->regs + FPGA_TP_ADDR_INTERRUPT_CAUSE);
234
235 /* Clear TP interrupt */
236 writel(tp_cause, adapter->regs + FPGA_TP_ADDR_INTERRUPT_CAUSE);
237 }
238 if (cause & FPGA_PCIX_INTERRUPT_PCIX)
239 t1_pci_intr_handler(adapter);
240
241 /* Clear the interrupts just processed. */
242 if (cause)
243 writel(cause, adapter->regs + A_PL_CAUSE);
244
245 return cause != 0;
246}
247#endif
179 248
180/* 249/*
181 * Wait until Elmer's MI1 interface is ready for new operations. 250 * Wait until Elmer's MI1 interface is ready for new operations.
@@ -212,12 +281,62 @@ static void mi1_mdio_init(adapter_t *adapter, const struct board_info *bi)
212 t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_CFG, val); 281 t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_CFG, val);
213} 282}
214 283
284#if defined(CONFIG_CHELSIO_T1_1G) || defined(CONFIG_CHELSIO_T1_COUGAR)
285/*
286 * Elmer MI1 MDIO read/write operations.
287 */
288static int mi1_mdio_read(adapter_t *adapter, int phy_addr, int mmd_addr,
289 int reg_addr, unsigned int *valp)
290{
291 u32 addr = V_MI1_REG_ADDR(reg_addr) | V_MI1_PHY_ADDR(phy_addr);
292
293 if (mmd_addr)
294 return -EINVAL;
295
296 spin_lock(&adapter->tpi_lock);
297 __t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_ADDR, addr);
298 __t1_tpi_write(adapter,
299 A_ELMER0_PORT0_MI1_OP, MI1_OP_DIRECT_READ);
300 mi1_wait_until_ready(adapter, A_ELMER0_PORT0_MI1_OP);
301 __t1_tpi_read(adapter, A_ELMER0_PORT0_MI1_DATA, valp);
302 spin_unlock(&adapter->tpi_lock);
303 return 0;
304}
305
306static int mi1_mdio_write(adapter_t *adapter, int phy_addr, int mmd_addr,
307 int reg_addr, unsigned int val)
308{
309 u32 addr = V_MI1_REG_ADDR(reg_addr) | V_MI1_PHY_ADDR(phy_addr);
310
311 if (mmd_addr)
312 return -EINVAL;
313
314 spin_lock(&adapter->tpi_lock);
315 __t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_ADDR, addr);
316 __t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_DATA, val);
317 __t1_tpi_write(adapter,
318 A_ELMER0_PORT0_MI1_OP, MI1_OP_DIRECT_WRITE);
319 mi1_wait_until_ready(adapter, A_ELMER0_PORT0_MI1_OP);
320 spin_unlock(&adapter->tpi_lock);
321 return 0;
322}
323
324#if defined(CONFIG_CHELSIO_T1_1G) || defined(CONFIG_CHELSIO_T1_COUGAR)
325static struct mdio_ops mi1_mdio_ops = {
326 mi1_mdio_init,
327 mi1_mdio_read,
328 mi1_mdio_write
329};
330#endif
331
332#endif
333
215static int mi1_mdio_ext_read(adapter_t *adapter, int phy_addr, int mmd_addr, 334static int mi1_mdio_ext_read(adapter_t *adapter, int phy_addr, int mmd_addr,
216 int reg_addr, unsigned int *valp) 335 int reg_addr, unsigned int *valp)
217{ 336{
218 u32 addr = V_MI1_REG_ADDR(mmd_addr) | V_MI1_PHY_ADDR(phy_addr); 337 u32 addr = V_MI1_REG_ADDR(mmd_addr) | V_MI1_PHY_ADDR(phy_addr);
219 338
220 spin_lock(&(adapter)->tpi_lock); 339 spin_lock(&adapter->tpi_lock);
221 340
222 /* Write the address we want. */ 341 /* Write the address we want. */
223 __t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_ADDR, addr); 342 __t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_ADDR, addr);
@@ -227,12 +346,13 @@ static int mi1_mdio_ext_read(adapter_t *adapter, int phy_addr, int mmd_addr,
227 mi1_wait_until_ready(adapter, A_ELMER0_PORT0_MI1_OP); 346 mi1_wait_until_ready(adapter, A_ELMER0_PORT0_MI1_OP);
228 347
229 /* Write the operation we want. */ 348 /* Write the operation we want. */
230 __t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_OP, MI1_OP_INDIRECT_READ); 349 __t1_tpi_write(adapter,
350 A_ELMER0_PORT0_MI1_OP, MI1_OP_INDIRECT_READ);
231 mi1_wait_until_ready(adapter, A_ELMER0_PORT0_MI1_OP); 351 mi1_wait_until_ready(adapter, A_ELMER0_PORT0_MI1_OP);
232 352
233 /* Read the data. */ 353 /* Read the data. */
234 __t1_tpi_read(adapter, A_ELMER0_PORT0_MI1_DATA, valp); 354 __t1_tpi_read(adapter, A_ELMER0_PORT0_MI1_DATA, valp);
235 spin_unlock(&(adapter)->tpi_lock); 355 spin_unlock(&adapter->tpi_lock);
236 return 0; 356 return 0;
237} 357}
238 358
@@ -241,7 +361,7 @@ static int mi1_mdio_ext_write(adapter_t *adapter, int phy_addr, int mmd_addr,
241{ 361{
242 u32 addr = V_MI1_REG_ADDR(mmd_addr) | V_MI1_PHY_ADDR(phy_addr); 362 u32 addr = V_MI1_REG_ADDR(mmd_addr) | V_MI1_PHY_ADDR(phy_addr);
243 363
244 spin_lock(&(adapter)->tpi_lock); 364 spin_lock(&adapter->tpi_lock);
245 365
246 /* Write the address we want. */ 366 /* Write the address we want. */
247 __t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_ADDR, addr); 367 __t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_ADDR, addr);
@@ -254,7 +374,7 @@ static int mi1_mdio_ext_write(adapter_t *adapter, int phy_addr, int mmd_addr,
254 __t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_DATA, val); 374 __t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_DATA, val);
255 __t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_OP, MI1_OP_INDIRECT_WRITE); 375 __t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_OP, MI1_OP_INDIRECT_WRITE);
256 mi1_wait_until_ready(adapter, A_ELMER0_PORT0_MI1_OP); 376 mi1_wait_until_ready(adapter, A_ELMER0_PORT0_MI1_OP);
257 spin_unlock(&(adapter)->tpi_lock); 377 spin_unlock(&adapter->tpi_lock);
258 return 0; 378 return 0;
259} 379}
260 380
@@ -265,12 +385,25 @@ static struct mdio_ops mi1_mdio_ext_ops = {
265}; 385};
266 386
267enum { 387enum {
388 CH_BRD_T110_1CU,
268 CH_BRD_N110_1F, 389 CH_BRD_N110_1F,
269 CH_BRD_N210_1F, 390 CH_BRD_N210_1F,
391 CH_BRD_T210_1F,
392 CH_BRD_T210_1CU,
393 CH_BRD_N204_4CU,
270}; 394};
271 395
272static struct board_info t1_board[] = { 396static struct board_info t1_board[] = {
273 397
398{ CHBT_BOARD_CHT110, 1/*ports#*/,
399 SUPPORTED_10000baseT_Full /*caps*/, CHBT_TERM_T1,
400 CHBT_MAC_PM3393, CHBT_PHY_MY3126,
401 125000000/*clk-core*/, 150000000/*clk-mc3*/, 125000000/*clk-mc4*/,
402 1/*espi-ports*/, 0/*clk-cspi*/, 44/*clk-elmer0*/, 1/*mdien*/,
403 1/*mdiinv*/, 1/*mdc*/, 1/*phybaseaddr*/, &t1_pm3393_ops,
404 &t1_my3126_ops, &mi1_mdio_ext_ops,
405 "Chelsio T110 1x10GBase-CX4 TOE" },
406
274{ CHBT_BOARD_N110, 1/*ports#*/, 407{ CHBT_BOARD_N110, 1/*ports#*/,
275 SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE /*caps*/, CHBT_TERM_T1, 408 SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE /*caps*/, CHBT_TERM_T1,
276 CHBT_MAC_PM3393, CHBT_PHY_88X2010, 409 CHBT_MAC_PM3393, CHBT_PHY_88X2010,
@@ -289,12 +422,47 @@ static struct board_info t1_board[] = {
289 &t1_mv88x201x_ops, &mi1_mdio_ext_ops, 422 &t1_mv88x201x_ops, &mi1_mdio_ext_ops,
290 "Chelsio N210 1x10GBaseX NIC" }, 423 "Chelsio N210 1x10GBaseX NIC" },
291 424
425{ CHBT_BOARD_CHT210, 1/*ports#*/,
426 SUPPORTED_10000baseT_Full /*caps*/, CHBT_TERM_T2,
427 CHBT_MAC_PM3393, CHBT_PHY_88X2010,
428 125000000/*clk-core*/, 133000000/*clk-mc3*/, 125000000/*clk-mc4*/,
429 1/*espi-ports*/, 0/*clk-cspi*/, 44/*clk-elmer0*/, 0/*mdien*/,
430 0/*mdiinv*/, 1/*mdc*/, 0/*phybaseaddr*/, &t1_pm3393_ops,
431 &t1_mv88x201x_ops, &mi1_mdio_ext_ops,
432 "Chelsio T210 1x10GBaseX TOE" },
433
434{ CHBT_BOARD_CHT210, 1/*ports#*/,
435 SUPPORTED_10000baseT_Full /*caps*/, CHBT_TERM_T2,
436 CHBT_MAC_PM3393, CHBT_PHY_MY3126,
437 125000000/*clk-core*/, 133000000/*clk-mc3*/, 125000000/*clk-mc4*/,
438 1/*espi-ports*/, 0/*clk-cspi*/, 44/*clk-elmer0*/, 1/*mdien*/,
439 1/*mdiinv*/, 1/*mdc*/, 1/*phybaseaddr*/, &t1_pm3393_ops,
440 &t1_my3126_ops, &mi1_mdio_ext_ops,
441 "Chelsio T210 1x10GBase-CX4 TOE" },
442
443#ifdef CONFIG_CHELSIO_T1_1G
444{ CHBT_BOARD_CHN204, 4/*ports#*/,
445 SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full | SUPPORTED_100baseT_Half |
446 SUPPORTED_100baseT_Full | SUPPORTED_1000baseT_Full | SUPPORTED_Autoneg |
447 SUPPORTED_PAUSE | SUPPORTED_TP /*caps*/, CHBT_TERM_T2, CHBT_MAC_VSC7321, CHBT_PHY_88E1111,
448 100000000/*clk-core*/, 0/*clk-mc3*/, 0/*clk-mc4*/,
449 4/*espi-ports*/, 0/*clk-cspi*/, 44/*clk-elmer0*/, 0/*mdien*/,
450 0/*mdiinv*/, 1/*mdc*/, 4/*phybaseaddr*/, &t1_vsc7326_ops,
451 &t1_mv88e1xxx_ops, &mi1_mdio_ops,
452 "Chelsio N204 4x100/1000BaseT NIC" },
453#endif
454
292}; 455};
293 456
294struct pci_device_id t1_pci_tbl[] = { 457struct pci_device_id t1_pci_tbl[] = {
458 CH_DEVICE(8, 0, CH_BRD_T110_1CU),
459 CH_DEVICE(8, 1, CH_BRD_T110_1CU),
295 CH_DEVICE(7, 0, CH_BRD_N110_1F), 460 CH_DEVICE(7, 0, CH_BRD_N110_1F),
296 CH_DEVICE(10, 1, CH_BRD_N210_1F), 461 CH_DEVICE(10, 1, CH_BRD_N210_1F),
297 { 0, } 462 CH_DEVICE(11, 1, CH_BRD_T210_1F),
463 CH_DEVICE(14, 1, CH_BRD_T210_1CU),
464 CH_DEVICE(16, 1, CH_BRD_N204_4CU),
465 { 0 }
298}; 466};
299 467
300MODULE_DEVICE_TABLE(pci, t1_pci_tbl); 468MODULE_DEVICE_TABLE(pci, t1_pci_tbl);
@@ -390,9 +558,14 @@ int t1_link_start(struct cphy *phy, struct cmac *mac, struct link_config *lc)
390 if (lc->supported & SUPPORTED_Autoneg) { 558 if (lc->supported & SUPPORTED_Autoneg) {
391 lc->advertising &= ~(ADVERTISED_ASYM_PAUSE | ADVERTISED_PAUSE); 559 lc->advertising &= ~(ADVERTISED_ASYM_PAUSE | ADVERTISED_PAUSE);
392 if (fc) { 560 if (fc) {
393 lc->advertising |= ADVERTISED_ASYM_PAUSE; 561 if (fc == ((PAUSE_RX | PAUSE_TX) &
394 if (fc == (PAUSE_RX | PAUSE_TX)) 562 (mac->adapter->params.nports < 2)))
395 lc->advertising |= ADVERTISED_PAUSE; 563 lc->advertising |= ADVERTISED_PAUSE;
564 else {
565 lc->advertising |= ADVERTISED_ASYM_PAUSE;
566 if (fc == PAUSE_RX)
567 lc->advertising |= ADVERTISED_PAUSE;
568 }
396 } 569 }
397 phy->ops->advertise(phy, lc->advertising); 570 phy->ops->advertise(phy, lc->advertising);
398 571
@@ -403,11 +576,15 @@ int t1_link_start(struct cphy *phy, struct cmac *mac, struct link_config *lc)
403 mac->ops->set_speed_duplex_fc(mac, lc->speed, 576 mac->ops->set_speed_duplex_fc(mac, lc->speed,
404 lc->duplex, fc); 577 lc->duplex, fc);
405 /* Also disables autoneg */ 578 /* Also disables autoneg */
579 phy->state = PHY_AUTONEG_RDY;
406 phy->ops->set_speed_duplex(phy, lc->speed, lc->duplex); 580 phy->ops->set_speed_duplex(phy, lc->speed, lc->duplex);
407 phy->ops->reset(phy, 0); 581 phy->ops->reset(phy, 0);
408 } else 582 } else {
583 phy->state = PHY_AUTONEG_EN;
409 phy->ops->autoneg_enable(phy); /* also resets PHY */ 584 phy->ops->autoneg_enable(phy); /* also resets PHY */
585 }
410 } else { 586 } else {
587 phy->state = PHY_AUTONEG_RDY;
411 mac->ops->set_speed_duplex_fc(mac, -1, -1, fc); 588 mac->ops->set_speed_duplex_fc(mac, -1, -1, fc);
412 lc->fc = (unsigned char)fc; 589 lc->fc = (unsigned char)fc;
413 phy->ops->reset(phy, 0); 590 phy->ops->reset(phy, 0);
@@ -418,24 +595,109 @@ int t1_link_start(struct cphy *phy, struct cmac *mac, struct link_config *lc)
418/* 595/*
419 * External interrupt handler for boards using elmer0. 596 * External interrupt handler for boards using elmer0.
420 */ 597 */
421int elmer0_ext_intr_handler(adapter_t *adapter) 598int t1_elmer0_ext_intr_handler(adapter_t *adapter)
422{ 599{
423 struct cphy *phy; 600 struct cphy *phy;
424 int phy_cause; 601 int phy_cause;
425 u32 cause; 602 u32 cause;
426 603
427 t1_tpi_read(adapter, A_ELMER0_INT_CAUSE, &cause); 604 t1_tpi_read(adapter, A_ELMER0_INT_CAUSE, &cause);
428 605
429 switch (board_info(adapter)->board) { 606 switch (board_info(adapter)->board) {
607#ifdef CONFIG_CHELSIO_T1_1G
608 case CHBT_BOARD_CHT204:
609 case CHBT_BOARD_CHT204E:
610 case CHBT_BOARD_CHN204:
611 case CHBT_BOARD_CHT204V: {
612 int i, port_bit;
613 for_each_port(adapter, i) {
614 port_bit = i + 1;
615 if (!(cause & (1 << port_bit))) continue;
616
617 phy = adapter->port[i].phy;
618 phy_cause = phy->ops->interrupt_handler(phy);
619 if (phy_cause & cphy_cause_link_change)
620 t1_link_changed(adapter, i);
621 }
622 break;
623 }
624 case CHBT_BOARD_CHT101:
625 if (cause & ELMER0_GP_BIT1) { /* Marvell 88E1111 interrupt */
626 phy = adapter->port[0].phy;
627 phy_cause = phy->ops->interrupt_handler(phy);
628 if (phy_cause & cphy_cause_link_change)
629 t1_link_changed(adapter, 0);
630 }
631 break;
632 case CHBT_BOARD_7500: {
633 int p;
634 /*
635 * Elmer0's interrupt cause isn't useful here because there is
636 * only one bit that can be set for all 4 ports. This means
637 * we are forced to check every PHY's interrupt status
638 * register to see who initiated the interrupt.
639 */
640 for_each_port(adapter, p) {
641 phy = adapter->port[p].phy;
642 phy_cause = phy->ops->interrupt_handler(phy);
643 if (phy_cause & cphy_cause_link_change)
644 t1_link_changed(adapter, p);
645 }
646 break;
647 }
648#endif
649 case CHBT_BOARD_CHT210:
430 case CHBT_BOARD_N210: 650 case CHBT_BOARD_N210:
431 case CHBT_BOARD_N110: 651 case CHBT_BOARD_N110:
432 if (cause & ELMER0_GP_BIT6) { /* Marvell 88x2010 interrupt */ 652 if (cause & ELMER0_GP_BIT6) { /* Marvell 88x2010 interrupt */
433 phy = adapter->port[0].phy; 653 phy = adapter->port[0].phy;
434 phy_cause = phy->ops->interrupt_handler(phy); 654 phy_cause = phy->ops->interrupt_handler(phy);
435 if (phy_cause & cphy_cause_link_change) 655 if (phy_cause & cphy_cause_link_change)
436 link_changed(adapter, 0); 656 t1_link_changed(adapter, 0);
657 }
658 break;
659 case CHBT_BOARD_8000:
660 case CHBT_BOARD_CHT110:
661 CH_DBG(adapter, INTR, "External interrupt cause 0x%x\n",
662 cause);
663 if (cause & ELMER0_GP_BIT1) { /* PMC3393 INTB */
664 struct cmac *mac = adapter->port[0].mac;
665
666 mac->ops->interrupt_handler(mac);
437 } 667 }
668 if (cause & ELMER0_GP_BIT5) { /* XPAK MOD_DETECT */
669 u32 mod_detect;
670
671 t1_tpi_read(adapter,
672 A_ELMER0_GPI_STAT, &mod_detect);
673 CH_MSG(adapter, INFO, LINK, "XPAK %s\n",
674 mod_detect ? "removed" : "inserted");
675 }
438 break; 676 break;
677#ifdef CONFIG_CHELSIO_T1_COUGAR
678 case CHBT_BOARD_COUGAR:
679 if (adapter->params.nports == 1) {
680 if (cause & ELMER0_GP_BIT1) { /* Vitesse MAC */
681 struct cmac *mac = adapter->port[0].mac;
682 mac->ops->interrupt_handler(mac);
683 }
684 if (cause & ELMER0_GP_BIT5) { /* XPAK MOD_DETECT */
685 }
686 } else {
687 int i, port_bit;
688
689 for_each_port(adapter, i) {
690 port_bit = i ? i + 1 : 0;
691 if (!(cause & (1 << port_bit))) continue;
692
693 phy = adapter->port[i].phy;
694 phy_cause = phy->ops->interrupt_handler(phy);
695 if (phy_cause & cphy_cause_link_change)
696 t1_link_changed(adapter, i);
697 }
698 }
699 break;
700#endif
439 } 701 }
440 t1_tpi_write(adapter, A_ELMER0_INT_CAUSE, cause); 702 t1_tpi_write(adapter, A_ELMER0_INT_CAUSE, cause);
441 return 0; 703 return 0;
@@ -445,11 +707,11 @@ int elmer0_ext_intr_handler(adapter_t *adapter)
445void t1_interrupts_enable(adapter_t *adapter) 707void t1_interrupts_enable(adapter_t *adapter)
446{ 708{
447 unsigned int i; 709 unsigned int i;
448 u32 pl_intr;
449 710
450 adapter->slow_intr_mask = F_PL_INTR_SGE_ERR; 711 adapter->slow_intr_mask = F_PL_INTR_SGE_ERR | F_PL_INTR_TP;
451 712
452 t1_sge_intr_enable(adapter->sge); 713 t1_sge_intr_enable(adapter->sge);
714 t1_tp_intr_enable(adapter->tp);
453 if (adapter->espi) { 715 if (adapter->espi) {
454 adapter->slow_intr_mask |= F_PL_INTR_ESPI; 716 adapter->slow_intr_mask |= F_PL_INTR_ESPI;
455 t1_espi_intr_enable(adapter->espi); 717 t1_espi_intr_enable(adapter->espi);
@@ -462,15 +724,17 @@ void t1_interrupts_enable(adapter_t *adapter)
462 } 724 }
463 725
464 /* Enable PCIX & external chip interrupts on ASIC boards. */ 726 /* Enable PCIX & external chip interrupts on ASIC boards. */
465 pl_intr = readl(adapter->regs + A_PL_ENABLE); 727 if (t1_is_asic(adapter)) {
728 u32 pl_intr = readl(adapter->regs + A_PL_ENABLE);
466 729
467 /* PCI-X interrupts */ 730 /* PCI-X interrupts */
468 pci_write_config_dword(adapter->pdev, A_PCICFG_INTR_ENABLE, 731 pci_write_config_dword(adapter->pdev, A_PCICFG_INTR_ENABLE,
469 0xffffffff); 732 0xffffffff);
470 733
471 adapter->slow_intr_mask |= F_PL_INTR_EXT | F_PL_INTR_PCIX; 734 adapter->slow_intr_mask |= F_PL_INTR_EXT | F_PL_INTR_PCIX;
472 pl_intr |= F_PL_INTR_EXT | F_PL_INTR_PCIX; 735 pl_intr |= F_PL_INTR_EXT | F_PL_INTR_PCIX;
473 writel(pl_intr, adapter->regs + A_PL_ENABLE); 736 writel(pl_intr, adapter->regs + A_PL_ENABLE);
737 }
474} 738}
475 739
476/* Disables all interrupts. */ 740/* Disables all interrupts. */
@@ -479,6 +743,7 @@ void t1_interrupts_disable(adapter_t* adapter)
479 unsigned int i; 743 unsigned int i;
480 744
481 t1_sge_intr_disable(adapter->sge); 745 t1_sge_intr_disable(adapter->sge);
746 t1_tp_intr_disable(adapter->tp);
482 if (adapter->espi) 747 if (adapter->espi)
483 t1_espi_intr_disable(adapter->espi); 748 t1_espi_intr_disable(adapter->espi);
484 749
@@ -489,7 +754,8 @@ void t1_interrupts_disable(adapter_t* adapter)
489 } 754 }
490 755
491 /* Disable PCIX & external chip interrupts. */ 756 /* Disable PCIX & external chip interrupts. */
492 writel(0, adapter->regs + A_PL_ENABLE); 757 if (t1_is_asic(adapter))
758 writel(0, adapter->regs + A_PL_ENABLE);
493 759
494 /* PCI-X interrupts */ 760 /* PCI-X interrupts */
495 pci_write_config_dword(adapter->pdev, A_PCICFG_INTR_ENABLE, 0); 761 pci_write_config_dword(adapter->pdev, A_PCICFG_INTR_ENABLE, 0);
@@ -501,10 +767,9 @@ void t1_interrupts_disable(adapter_t* adapter)
501void t1_interrupts_clear(adapter_t* adapter) 767void t1_interrupts_clear(adapter_t* adapter)
502{ 768{
503 unsigned int i; 769 unsigned int i;
504 u32 pl_intr;
505
506 770
507 t1_sge_intr_clear(adapter->sge); 771 t1_sge_intr_clear(adapter->sge);
772 t1_tp_intr_clear(adapter->tp);
508 if (adapter->espi) 773 if (adapter->espi)
509 t1_espi_intr_clear(adapter->espi); 774 t1_espi_intr_clear(adapter->espi);
510 775
@@ -515,10 +780,12 @@ void t1_interrupts_clear(adapter_t* adapter)
515 } 780 }
516 781
517 /* Enable interrupts for external devices. */ 782 /* Enable interrupts for external devices. */
518 pl_intr = readl(adapter->regs + A_PL_CAUSE); 783 if (t1_is_asic(adapter)) {
784 u32 pl_intr = readl(adapter->regs + A_PL_CAUSE);
519 785
520 writel(pl_intr | F_PL_INTR_EXT | F_PL_INTR_PCIX, 786 writel(pl_intr | F_PL_INTR_EXT | F_PL_INTR_PCIX,
521 adapter->regs + A_PL_CAUSE); 787 adapter->regs + A_PL_CAUSE);
788 }
522 789
523 /* PCI-X interrupts */ 790 /* PCI-X interrupts */
524 pci_write_config_dword(adapter->pdev, A_PCICFG_INTR_CAUSE, 0xffffffff); 791 pci_write_config_dword(adapter->pdev, A_PCICFG_INTR_CAUSE, 0xffffffff);
@@ -527,7 +794,7 @@ void t1_interrupts_clear(adapter_t* adapter)
527/* 794/*
528 * Slow path interrupt handler for ASICs. 795 * Slow path interrupt handler for ASICs.
529 */ 796 */
530int t1_slow_intr_handler(adapter_t *adapter) 797static int asic_slow_intr(adapter_t *adapter)
531{ 798{
532 u32 cause = readl(adapter->regs + A_PL_CAUSE); 799 u32 cause = readl(adapter->regs + A_PL_CAUSE);
533 800
@@ -536,89 +803,54 @@ int t1_slow_intr_handler(adapter_t *adapter)
536 return 0; 803 return 0;
537 if (cause & F_PL_INTR_SGE_ERR) 804 if (cause & F_PL_INTR_SGE_ERR)
538 t1_sge_intr_error_handler(adapter->sge); 805 t1_sge_intr_error_handler(adapter->sge);
806 if (cause & F_PL_INTR_TP)
807 t1_tp_intr_handler(adapter->tp);
539 if (cause & F_PL_INTR_ESPI) 808 if (cause & F_PL_INTR_ESPI)
540 t1_espi_intr_handler(adapter->espi); 809 t1_espi_intr_handler(adapter->espi);
541 if (cause & F_PL_INTR_PCIX) 810 if (cause & F_PL_INTR_PCIX)
542 t1_pci_intr_handler(adapter); 811 t1_pci_intr_handler(adapter);
543 if (cause & F_PL_INTR_EXT) 812 if (cause & F_PL_INTR_EXT)
544 t1_elmer0_ext_intr(adapter); 813 t1_elmer0_ext_intr_handler(adapter);
545 814
546 /* Clear the interrupts just processed. */ 815 /* Clear the interrupts just processed. */
547 writel(cause, adapter->regs + A_PL_CAUSE); 816 writel(cause, adapter->regs + A_PL_CAUSE);
548 (void)readl(adapter->regs + A_PL_CAUSE); /* flush writes */ 817 readl(adapter->regs + A_PL_CAUSE); /* flush writes */
549 return 1; 818 return 1;
550} 819}
551 820
552/* Pause deadlock avoidance parameters */ 821int t1_slow_intr_handler(adapter_t *adapter)
553#define DROP_MSEC 16
554#define DROP_PKTS_CNT 1
555
556static void set_csum_offload(adapter_t *adapter, u32 csum_bit, int enable)
557{
558 u32 val = readl(adapter->regs + A_TP_GLOBAL_CONFIG);
559
560 if (enable)
561 val |= csum_bit;
562 else
563 val &= ~csum_bit;
564 writel(val, adapter->regs + A_TP_GLOBAL_CONFIG);
565}
566
567void t1_tp_set_ip_checksum_offload(adapter_t *adapter, int enable)
568{
569 set_csum_offload(adapter, F_IP_CSUM, enable);
570}
571
572void t1_tp_set_udp_checksum_offload(adapter_t *adapter, int enable)
573{
574 set_csum_offload(adapter, F_UDP_CSUM, enable);
575}
576
577void t1_tp_set_tcp_checksum_offload(adapter_t *adapter, int enable)
578{ 822{
579 set_csum_offload(adapter, F_TCP_CSUM, enable); 823#ifdef CONFIG_CHELSIO_T1_1G
824 if (!t1_is_asic(adapter))
825 return fpga_slow_intr(adapter);
826#endif
827 return asic_slow_intr(adapter);
580} 828}
581 829
582static void t1_tp_reset(adapter_t *adapter, unsigned int tp_clk) 830/* Power sequencing is a work-around for Intel's XPAKs. */
831static void power_sequence_xpak(adapter_t* adapter)
583{ 832{
584 u32 val; 833 u32 mod_detect;
585 834 u32 gpo;
586 val = F_TP_IN_CSPI_CPL | F_TP_IN_CSPI_CHECK_IP_CSUM | 835
587 F_TP_IN_CSPI_CHECK_TCP_CSUM | F_TP_IN_ESPI_ETHERNET; 836 /* Check for XPAK */
588 val |= F_TP_IN_ESPI_CHECK_IP_CSUM | 837 t1_tpi_read(adapter, A_ELMER0_GPI_STAT, &mod_detect);
589 F_TP_IN_ESPI_CHECK_TCP_CSUM; 838 if (!(ELMER0_GP_BIT5 & mod_detect)) {
590 writel(val, adapter->regs + A_TP_IN_CONFIG); 839 /* XPAK is present */
591 writel(F_TP_OUT_CSPI_CPL | 840 t1_tpi_read(adapter, A_ELMER0_GPO, &gpo);
592 F_TP_OUT_ESPI_ETHERNET | 841 gpo |= ELMER0_GP_BIT18;
593 F_TP_OUT_ESPI_GENERATE_IP_CSUM | 842 t1_tpi_write(adapter, A_ELMER0_GPO, gpo);
594 F_TP_OUT_ESPI_GENERATE_TCP_CSUM,
595 adapter->regs + A_TP_OUT_CONFIG);
596
597 val = readl(adapter->regs + A_TP_GLOBAL_CONFIG);
598 val &= ~(F_IP_CSUM | F_UDP_CSUM | F_TCP_CSUM);
599 writel(val, adapter->regs + A_TP_GLOBAL_CONFIG);
600
601 /*
602 * Enable pause frame deadlock prevention.
603 */
604 if (is_T2(adapter)) {
605 u32 drop_ticks = DROP_MSEC * (tp_clk / 1000);
606
607 writel(F_ENABLE_TX_DROP | F_ENABLE_TX_ERROR |
608 V_DROP_TICKS_CNT(drop_ticks) |
609 V_NUM_PKTS_DROPPED(DROP_PKTS_CNT),
610 adapter->regs + A_TP_TX_DROP_CONFIG);
611 } 843 }
612
613 writel(F_TP_RESET, adapter->regs + A_TP_RESET);
614} 844}
615 845
616int __devinit t1_get_board_rev(adapter_t *adapter, const struct board_info *bi, 846int __devinit t1_get_board_rev(adapter_t *adapter, const struct board_info *bi,
617 struct adapter_params *p) 847 struct adapter_params *p)
618{ 848{
619 p->chip_version = bi->chip_term; 849 p->chip_version = bi->chip_term;
850 p->is_asic = (p->chip_version != CHBT_TERM_FPGA);
620 if (p->chip_version == CHBT_TERM_T1 || 851 if (p->chip_version == CHBT_TERM_T1 ||
621 p->chip_version == CHBT_TERM_T2) { 852 p->chip_version == CHBT_TERM_T2 ||
853 p->chip_version == CHBT_TERM_FPGA) {
622 u32 val = readl(adapter->regs + A_TP_PC_CONFIG); 854 u32 val = readl(adapter->regs + A_TP_PC_CONFIG);
623 855
624 val = G_TP_PC_REV(val); 856 val = G_TP_PC_REV(val);
@@ -640,11 +872,38 @@ int __devinit t1_get_board_rev(adapter_t *adapter, const struct board_info *bi,
640static int board_init(adapter_t *adapter, const struct board_info *bi) 872static int board_init(adapter_t *adapter, const struct board_info *bi)
641{ 873{
642 switch (bi->board) { 874 switch (bi->board) {
875 case CHBT_BOARD_8000:
643 case CHBT_BOARD_N110: 876 case CHBT_BOARD_N110:
644 case CHBT_BOARD_N210: 877 case CHBT_BOARD_N210:
645 writel(V_TPIPAR(0xf), adapter->regs + A_TPI_PAR); 878 case CHBT_BOARD_CHT210:
879 case CHBT_BOARD_COUGAR:
880 t1_tpi_par(adapter, 0xf);
646 t1_tpi_write(adapter, A_ELMER0_GPO, 0x800); 881 t1_tpi_write(adapter, A_ELMER0_GPO, 0x800);
647 break; 882 break;
883 case CHBT_BOARD_CHT110:
884 t1_tpi_par(adapter, 0xf);
885 t1_tpi_write(adapter, A_ELMER0_GPO, 0x1800);
886
887 /* TBD XXX Might not need. This fixes a problem
888 * described in the Intel SR XPAK errata.
889 */
890 power_sequence_xpak(adapter);
891 break;
892#ifdef CONFIG_CHELSIO_T1_1G
893 case CHBT_BOARD_CHT204E:
894 /* add config space write here */
895 case CHBT_BOARD_CHT204:
896 case CHBT_BOARD_CHT204V:
897 case CHBT_BOARD_CHN204:
898 t1_tpi_par(adapter, 0xf);
899 t1_tpi_write(adapter, A_ELMER0_GPO, 0x804);
900 break;
901 case CHBT_BOARD_CHT101:
902 case CHBT_BOARD_7500:
903 t1_tpi_par(adapter, 0xf);
904 t1_tpi_write(adapter, A_ELMER0_GPO, 0x1804);
905 break;
906#endif
648 } 907 }
649 return 0; 908 return 0;
650} 909}
@@ -666,11 +925,16 @@ int t1_init_hw_modules(adapter_t *adapter)
666 adapter->regs + A_MC5_CONFIG); 925 adapter->regs + A_MC5_CONFIG);
667 } 926 }
668 927
928#ifdef CONFIG_CHELSIO_T1_COUGAR
929 if (adapter->cspi && t1_cspi_init(adapter->cspi))
930 goto out_err;
931#endif
669 if (adapter->espi && t1_espi_init(adapter->espi, bi->chip_mac, 932 if (adapter->espi && t1_espi_init(adapter->espi, bi->chip_mac,
670 bi->espi_nports)) 933 bi->espi_nports))
671 goto out_err; 934 goto out_err;
672 935
673 t1_tp_reset(adapter, bi->clock_core); 936 if (t1_tp_reset(adapter->tp, &adapter->params.tp, bi->clock_core))
937 goto out_err;
674 938
675 err = t1_sge_configure(adapter->sge, &adapter->params.sge); 939 err = t1_sge_configure(adapter->sge, &adapter->params.sge);
676 if (err) 940 if (err)
@@ -714,8 +978,14 @@ void t1_free_sw_modules(adapter_t *adapter)
714 978
715 if (adapter->sge) 979 if (adapter->sge)
716 t1_sge_destroy(adapter->sge); 980 t1_sge_destroy(adapter->sge);
981 if (adapter->tp)
982 t1_tp_destroy(adapter->tp);
717 if (adapter->espi) 983 if (adapter->espi)
718 t1_espi_destroy(adapter->espi); 984 t1_espi_destroy(adapter->espi);
985#ifdef CONFIG_CHELSIO_T1_COUGAR
986 if (adapter->cspi)
987 t1_cspi_destroy(adapter->cspi);
988#endif
719} 989}
720 990
721static void __devinit init_link_config(struct link_config *lc, 991static void __devinit init_link_config(struct link_config *lc,
@@ -735,6 +1005,13 @@ static void __devinit init_link_config(struct link_config *lc,
735 } 1005 }
736} 1006}
737 1007
1008#ifdef CONFIG_CHELSIO_T1_COUGAR
1009 if (bi->clock_cspi && !(adapter->cspi = t1_cspi_create(adapter))) {
1010 CH_ERR("%s: CSPI initialization failed\n",
1011 adapter->name);
1012 goto error;
1013 }
1014#endif
738 1015
739/* 1016/*
740 * Allocate and initialize the data structures that hold the SW state of 1017 * Allocate and initialize the data structures that hold the SW state of
@@ -762,6 +1039,13 @@ int __devinit t1_init_sw_modules(adapter_t *adapter,
762 goto error; 1039 goto error;
763 } 1040 }
764 1041
1042 adapter->tp = t1_tp_create(adapter, &adapter->params.tp);
1043 if (!adapter->tp) {
1044 CH_ERR("%s: TP initialization failed\n",
1045 adapter->name);
1046 goto error;
1047 }
1048
765 board_init(adapter, bi); 1049 board_init(adapter, bi);
766 bi->mdio_ops->init(adapter, bi); 1050 bi->mdio_ops->init(adapter, bi);
767 if (bi->gphy->reset) 1051 if (bi->gphy->reset)
@@ -793,7 +1077,9 @@ int __devinit t1_init_sw_modules(adapter_t *adapter,
793 * Get the port's MAC addresses either from the EEPROM if one 1077 * Get the port's MAC addresses either from the EEPROM if one
794 * exists or the one hardcoded in the MAC. 1078 * exists or the one hardcoded in the MAC.
795 */ 1079 */
796 if (vpd_macaddress_get(adapter, i, hw_addr)) { 1080 if (!t1_is_asic(adapter) || bi->chip_mac == CHBT_MAC_DUMMY)
1081 mac->ops->macaddress_get(mac, hw_addr);
1082 else if (vpd_macaddress_get(adapter, i, hw_addr)) {
797 CH_ERR("%s: could not read MAC address from VPD ROM\n", 1083 CH_ERR("%s: could not read MAC address from VPD ROM\n",
798 adapter->port[i].dev->name); 1084 adapter->port[i].dev->name);
799 goto error; 1085 goto error;
@@ -806,7 +1092,7 @@ int __devinit t1_init_sw_modules(adapter_t *adapter,
806 t1_interrupts_clear(adapter); 1092 t1_interrupts_clear(adapter);
807 return 0; 1093 return 0;
808 1094
809 error: 1095error:
810 t1_free_sw_modules(adapter); 1096 t1_free_sw_modules(adapter);
811 return -1; 1097 return -1;
812} 1098}
diff --git a/drivers/net/chelsio/suni1x10gexp_regs.h b/drivers/net/chelsio/suni1x10gexp_regs.h
index 81816c2b708a..269d097dd927 100644
--- a/drivers/net/chelsio/suni1x10gexp_regs.h
+++ b/drivers/net/chelsio/suni1x10gexp_regs.h
@@ -32,6 +32,30 @@
32#ifndef _CXGB_SUNI1x10GEXP_REGS_H_ 32#ifndef _CXGB_SUNI1x10GEXP_REGS_H_
33#define _CXGB_SUNI1x10GEXP_REGS_H_ 33#define _CXGB_SUNI1x10GEXP_REGS_H_
34 34
35/*
36** Space allocated for each Exact Match Filter
37** There are 8 filter configurations
38*/
39#define SUNI1x10GEXP_REG_SIZEOF_MAC_FILTER 0x0003
40
41#define mSUNI1x10GEXP_MAC_FILTER_OFFSET(filterId) ( (filterId) * SUNI1x10GEXP_REG_SIZEOF_MAC_FILTER )
42
43/*
44** Space allocated for VLAN-Id Filter
45** There are 8 filter configurations
46*/
47#define SUNI1x10GEXP_REG_SIZEOF_MAC_VID_FILTER 0x0001
48
49#define mSUNI1x10GEXP_MAC_VID_FILTER_OFFSET(filterId) ( (filterId) * SUNI1x10GEXP_REG_SIZEOF_MAC_VID_FILTER )
50
51/*
52** Space allocated for each MSTAT Counter
53*/
54#define SUNI1x10GEXP_REG_SIZEOF_MSTAT_COUNT 0x0004
55
56#define mSUNI1x10GEXP_MSTAT_COUNT_OFFSET(countId) ( (countId) * SUNI1x10GEXP_REG_SIZEOF_MSTAT_COUNT )
57
58
35/******************************************************************************/ 59/******************************************************************************/
36/** S/UNI-1x10GE-XP REGISTER ADDRESS MAP **/ 60/** S/UNI-1x10GE-XP REGISTER ADDRESS MAP **/
37/******************************************************************************/ 61/******************************************************************************/
@@ -39,33 +63,125 @@
39/* to the S/UNI-1x10GE-XP Data Sheet for the signification of each bit */ 63/* to the S/UNI-1x10GE-XP Data Sheet for the signification of each bit */
40/******************************************************************************/ 64/******************************************************************************/
41 65
66
67#define SUNI1x10GEXP_REG_IDENTIFICATION 0x0000
68#define SUNI1x10GEXP_REG_PRODUCT_REVISION 0x0001
69#define SUNI1x10GEXP_REG_CONFIG_AND_RESET_CONTROL 0x0002
70#define SUNI1x10GEXP_REG_LOOPBACK_MISC_CTRL 0x0003
42#define SUNI1x10GEXP_REG_DEVICE_STATUS 0x0004 71#define SUNI1x10GEXP_REG_DEVICE_STATUS 0x0004
72#define SUNI1x10GEXP_REG_GLOBAL_PERFORMANCE_MONITOR_UPDATE 0x0005
73
74#define SUNI1x10GEXP_REG_MDIO_COMMAND 0x0006
75#define SUNI1x10GEXP_REG_MDIO_INTERRUPT_ENABLE 0x0007
76#define SUNI1x10GEXP_REG_MDIO_INTERRUPT_STATUS 0x0008
77#define SUNI1x10GEXP_REG_MMD_PHY_ADDRESS 0x0009
78#define SUNI1x10GEXP_REG_MMD_CONTROL_ADDRESS_DATA 0x000A
79#define SUNI1x10GEXP_REG_MDIO_READ_STATUS_DATA 0x000B
80
81#define SUNI1x10GEXP_REG_OAM_INTF_CTRL 0x000C
43#define SUNI1x10GEXP_REG_MASTER_INTERRUPT_STATUS 0x000D 82#define SUNI1x10GEXP_REG_MASTER_INTERRUPT_STATUS 0x000D
44#define SUNI1x10GEXP_REG_GLOBAL_INTERRUPT_ENABLE 0x000E 83#define SUNI1x10GEXP_REG_GLOBAL_INTERRUPT_ENABLE 0x000E
84#define SUNI1x10GEXP_REG_FREE 0x000F
85
86#define SUNI1x10GEXP_REG_XTEF_MISC_CTRL 0x0010
87#define SUNI1x10GEXP_REG_XRF_MISC_CTRL 0x0011
88
89#define SUNI1x10GEXP_REG_SERDES_3125_CONFIG_1 0x0100
90#define SUNI1x10GEXP_REG_SERDES_3125_CONFIG_2 0x0101
45#define SUNI1x10GEXP_REG_SERDES_3125_INTERRUPT_ENABLE 0x0102 91#define SUNI1x10GEXP_REG_SERDES_3125_INTERRUPT_ENABLE 0x0102
92#define SUNI1x10GEXP_REG_SERDES_3125_INTERRUPT_VISIBLE 0x0103
46#define SUNI1x10GEXP_REG_SERDES_3125_INTERRUPT_STATUS 0x0104 93#define SUNI1x10GEXP_REG_SERDES_3125_INTERRUPT_STATUS 0x0104
94#define SUNI1x10GEXP_REG_SERDES_3125_TEST_CONFIG 0x0107
95
47#define SUNI1x10GEXP_REG_RXXG_CONFIG_1 0x2040 96#define SUNI1x10GEXP_REG_RXXG_CONFIG_1 0x2040
97#define SUNI1x10GEXP_REG_RXXG_CONFIG_2 0x2041
48#define SUNI1x10GEXP_REG_RXXG_CONFIG_3 0x2042 98#define SUNI1x10GEXP_REG_RXXG_CONFIG_3 0x2042
49#define SUNI1x10GEXP_REG_RXXG_INTERRUPT 0x2043 99#define SUNI1x10GEXP_REG_RXXG_INTERRUPT 0x2043
50#define SUNI1x10GEXP_REG_RXXG_MAX_FRAME_LENGTH 0x2045 100#define SUNI1x10GEXP_REG_RXXG_MAX_FRAME_LENGTH 0x2045
51#define SUNI1x10GEXP_REG_RXXG_SA_15_0 0x2046 101#define SUNI1x10GEXP_REG_RXXG_SA_15_0 0x2046
52#define SUNI1x10GEXP_REG_RXXG_SA_31_16 0x2047 102#define SUNI1x10GEXP_REG_RXXG_SA_31_16 0x2047
53#define SUNI1x10GEXP_REG_RXXG_SA_47_32 0x2048 103#define SUNI1x10GEXP_REG_RXXG_SA_47_32 0x2048
104#define SUNI1x10GEXP_REG_RXXG_RECEIVE_FIFO_THRESHOLD 0x2049
105#define mSUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_LOW(filterId) (0x204A + mSUNI1x10GEXP_MAC_FILTER_OFFSET(filterId))
106#define mSUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_MID(filterId) (0x204B + mSUNI1x10GEXP_MAC_FILTER_OFFSET(filterId))
107#define mSUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_HIGH(filterId)(0x204C + mSUNI1x10GEXP_MAC_FILTER_OFFSET(filterId))
108#define mSUNI1x10GEXP_REG_RXXG_EXACT_MATCH_VID(filterId) (0x2062 + mSUNI1x10GEXP_MAC_VID_FILTER_OFFSET(filterId)
109#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_0_LOW 0x204A
110#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_0_MID 0x204B
111#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_0_HIGH 0x204C
54#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_1_LOW 0x204D 112#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_1_LOW 0x204D
55#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_1_MID 0x204E 113#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_1_MID 0x204E
56#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_1_HIGH 0x204F 114#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_1_HIGH 0x204F
115#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_2_LOW 0x2050
116#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_2_MID 0x2051
117#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_2_HIGH 0x2052
118#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_3_LOW 0x2053
119#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_3_MID 0x2054
120#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_3_HIGH 0x2055
121#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_4_LOW 0x2056
122#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_4_MID 0x2057
123#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_4_HIGH 0x2058
124#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_5_LOW 0x2059
125#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_5_MID 0x205A
126#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_5_HIGH 0x205B
127#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_6_LOW 0x205C
128#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_6_MID 0x205D
129#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_6_HIGH 0x205E
130#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_7_LOW 0x205F
131#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_7_MID 0x2060
132#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_7_HIGH 0x2061
133#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_VID_0 0x2062
134#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_VID_1 0x2063
135#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_VID_2 0x2064
136#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_VID_3 0x2065
137#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_VID_4 0x2066
138#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_VID_5 0x2067
139#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_VID_6 0x2068
140#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_VID_7 0x2069
57#define SUNI1x10GEXP_REG_RXXG_MULTICAST_HASH_LOW 0x206A 141#define SUNI1x10GEXP_REG_RXXG_MULTICAST_HASH_LOW 0x206A
58#define SUNI1x10GEXP_REG_RXXG_MULTICAST_HASH_MIDLOW 0x206B 142#define SUNI1x10GEXP_REG_RXXG_MULTICAST_HASH_MIDLOW 0x206B
59#define SUNI1x10GEXP_REG_RXXG_MULTICAST_HASH_MIDHIGH 0x206C 143#define SUNI1x10GEXP_REG_RXXG_MULTICAST_HASH_MIDHIGH 0x206C
60#define SUNI1x10GEXP_REG_RXXG_MULTICAST_HASH_HIGH 0x206D 144#define SUNI1x10GEXP_REG_RXXG_MULTICAST_HASH_HIGH 0x206D
61#define SUNI1x10GEXP_REG_RXXG_ADDRESS_FILTER_CONTROL_0 0x206E 145#define SUNI1x10GEXP_REG_RXXG_ADDRESS_FILTER_CONTROL_0 0x206E
146#define SUNI1x10GEXP_REG_RXXG_ADDRESS_FILTER_CONTROL_1 0x206F
62#define SUNI1x10GEXP_REG_RXXG_ADDRESS_FILTER_CONTROL_2 0x2070 147#define SUNI1x10GEXP_REG_RXXG_ADDRESS_FILTER_CONTROL_2 0x2070
148
149#define SUNI1x10GEXP_REG_XRF_PATTERN_GEN_CTRL 0x2081
150#define SUNI1x10GEXP_REG_XRF_8BTB_ERR_COUNT_LANE_0 0x2084
151#define SUNI1x10GEXP_REG_XRF_8BTB_ERR_COUNT_LANE_1 0x2085
152#define SUNI1x10GEXP_REG_XRF_8BTB_ERR_COUNT_LANE_2 0x2086
153#define SUNI1x10GEXP_REG_XRF_8BTB_ERR_COUNT_LANE_3 0x2087
63#define SUNI1x10GEXP_REG_XRF_INTERRUPT_ENABLE 0x2088 154#define SUNI1x10GEXP_REG_XRF_INTERRUPT_ENABLE 0x2088
64#define SUNI1x10GEXP_REG_XRF_INTERRUPT_STATUS 0x2089 155#define SUNI1x10GEXP_REG_XRF_INTERRUPT_STATUS 0x2089
156#define SUNI1x10GEXP_REG_XRF_ERR_STATUS 0x208A
65#define SUNI1x10GEXP_REG_XRF_DIAG_INTERRUPT_ENABLE 0x208B 157#define SUNI1x10GEXP_REG_XRF_DIAG_INTERRUPT_ENABLE 0x208B
66#define SUNI1x10GEXP_REG_XRF_DIAG_INTERRUPT_STATUS 0x208C 158#define SUNI1x10GEXP_REG_XRF_DIAG_INTERRUPT_STATUS 0x208C
159#define SUNI1x10GEXP_REG_XRF_CODE_ERR_THRES 0x2092
160
161#define SUNI1x10GEXP_REG_RXOAM_CONFIG 0x20C0
162#define SUNI1x10GEXP_REG_RXOAM_FILTER_1_CONFIG 0x20C1
163#define SUNI1x10GEXP_REG_RXOAM_FILTER_2_CONFIG 0x20C2
164#define SUNI1x10GEXP_REG_RXOAM_CONFIG_2 0x20C3
165#define SUNI1x10GEXP_REG_RXOAM_HEC_CONFIG 0x20C4
166#define SUNI1x10GEXP_REG_RXOAM_HEC_ERR_THRES 0x20C5
67#define SUNI1x10GEXP_REG_RXOAM_INTERRUPT_ENABLE 0x20C7 167#define SUNI1x10GEXP_REG_RXOAM_INTERRUPT_ENABLE 0x20C7
68#define SUNI1x10GEXP_REG_RXOAM_INTERRUPT_STATUS 0x20C8 168#define SUNI1x10GEXP_REG_RXOAM_INTERRUPT_STATUS 0x20C8
169#define SUNI1x10GEXP_REG_RXOAM_STATUS 0x20C9
170#define SUNI1x10GEXP_REG_RXOAM_HEC_ERR_COUNT 0x20CA
171#define SUNI1x10GEXP_REG_RXOAM_FIFO_OVERFLOW_COUNT 0x20CB
172#define SUNI1x10GEXP_REG_RXOAM_FILTER_MISMATCH_COUNT_LSB 0x20CC
173#define SUNI1x10GEXP_REG_RXOAM_FILTER_MISMATCH_COUNT_MSB 0x20CD
174#define SUNI1x10GEXP_REG_RXOAM_FILTER_1_MISMATCH_COUNT_LSB 0x20CE
175#define SUNI1x10GEXP_REG_RXOAM_FILTER_1_MISMATCH_COUNT_MSB 0x20CF
176#define SUNI1x10GEXP_REG_RXOAM_FILTER_2_MISMATCH_COUNT_LSB 0x20D0
177#define SUNI1x10GEXP_REG_RXOAM_FILTER_2_MISMATCH_COUNT_MSB 0x20D1
178#define SUNI1x10GEXP_REG_RXOAM_OAM_EXTRACT_COUNT_LSB 0x20D2
179#define SUNI1x10GEXP_REG_RXOAM_OAM_EXTRACT_COUNT_MSB 0x20D3
180#define SUNI1x10GEXP_REG_RXOAM_MINI_PACKET_COUNT_LSB 0x20D4
181#define SUNI1x10GEXP_REG_RXOAM_MINI_PACKET_COUNT_MSB 0x20D5
182#define SUNI1x10GEXP_REG_RXOAM_FILTER_MISMATCH_THRES_LSB 0x20D6
183#define SUNI1x10GEXP_REG_RXOAM_FILTER_MISMATCH_THRES_MSB 0x20D7
184
69#define SUNI1x10GEXP_REG_MSTAT_CONTROL 0x2100 185#define SUNI1x10GEXP_REG_MSTAT_CONTROL 0x2100
70#define SUNI1x10GEXP_REG_MSTAT_COUNTER_ROLLOVER_0 0x2101 186#define SUNI1x10GEXP_REG_MSTAT_COUNTER_ROLLOVER_0 0x2101
71#define SUNI1x10GEXP_REG_MSTAT_COUNTER_ROLLOVER_1 0x2102 187#define SUNI1x10GEXP_REG_MSTAT_COUNTER_ROLLOVER_1 0x2102
@@ -75,50 +191,321 @@
75#define SUNI1x10GEXP_REG_MSTAT_INTERRUPT_MASK_1 0x2106 191#define SUNI1x10GEXP_REG_MSTAT_INTERRUPT_MASK_1 0x2106
76#define SUNI1x10GEXP_REG_MSTAT_INTERRUPT_MASK_2 0x2107 192#define SUNI1x10GEXP_REG_MSTAT_INTERRUPT_MASK_2 0x2107
77#define SUNI1x10GEXP_REG_MSTAT_INTERRUPT_MASK_3 0x2108 193#define SUNI1x10GEXP_REG_MSTAT_INTERRUPT_MASK_3 0x2108
194#define SUNI1x10GEXP_REG_MSTAT_COUNTER_WRITE_ADDRESS 0x2109
195#define SUNI1x10GEXP_REG_MSTAT_COUNTER_WRITE_DATA_LOW 0x210A
196#define SUNI1x10GEXP_REG_MSTAT_COUNTER_WRITE_DATA_MIDDLE 0x210B
197#define SUNI1x10GEXP_REG_MSTAT_COUNTER_WRITE_DATA_HIGH 0x210C
198#define mSUNI1x10GEXP_REG_MSTAT_COUNTER_LOW(countId) (0x2110 + mSUNI1x10GEXP_MSTAT_COUNT_OFFSET(countId))
199#define mSUNI1x10GEXP_REG_MSTAT_COUNTER_MID(countId) (0x2111 + mSUNI1x10GEXP_MSTAT_COUNT_OFFSET(countId))
200#define mSUNI1x10GEXP_REG_MSTAT_COUNTER_HIGH(countId) (0x2112 + mSUNI1x10GEXP_MSTAT_COUNT_OFFSET(countId))
78#define SUNI1x10GEXP_REG_MSTAT_COUNTER_0_LOW 0x2110 201#define SUNI1x10GEXP_REG_MSTAT_COUNTER_0_LOW 0x2110
202#define SUNI1x10GEXP_REG_MSTAT_COUNTER_0_MID 0x2111
203#define SUNI1x10GEXP_REG_MSTAT_COUNTER_0_HIGH 0x2112
204#define SUNI1x10GEXP_REG_MSTAT_COUNTER_0_RESVD 0x2113
79#define SUNI1x10GEXP_REG_MSTAT_COUNTER_1_LOW 0x2114 205#define SUNI1x10GEXP_REG_MSTAT_COUNTER_1_LOW 0x2114
206#define SUNI1x10GEXP_REG_MSTAT_COUNTER_1_MID 0x2115
207#define SUNI1x10GEXP_REG_MSTAT_COUNTER_1_HIGH 0x2116
208#define SUNI1x10GEXP_REG_MSTAT_COUNTER_1_RESVD 0x2117
209#define SUNI1x10GEXP_REG_MSTAT_COUNTER_2_LOW 0x2118
210#define SUNI1x10GEXP_REG_MSTAT_COUNTER_2_MID 0x2119
211#define SUNI1x10GEXP_REG_MSTAT_COUNTER_2_HIGH 0x211A
212#define SUNI1x10GEXP_REG_MSTAT_COUNTER_2_RESVD 0x211B
213#define SUNI1x10GEXP_REG_MSTAT_COUNTER_3_LOW 0x211C
214#define SUNI1x10GEXP_REG_MSTAT_COUNTER_3_MID 0x211D
215#define SUNI1x10GEXP_REG_MSTAT_COUNTER_3_HIGH 0x211E
216#define SUNI1x10GEXP_REG_MSTAT_COUNTER_3_RESVD 0x211F
80#define SUNI1x10GEXP_REG_MSTAT_COUNTER_4_LOW 0x2120 217#define SUNI1x10GEXP_REG_MSTAT_COUNTER_4_LOW 0x2120
218#define SUNI1x10GEXP_REG_MSTAT_COUNTER_4_MID 0x2121
219#define SUNI1x10GEXP_REG_MSTAT_COUNTER_4_HIGH 0x2122
220#define SUNI1x10GEXP_REG_MSTAT_COUNTER_4_RESVD 0x2123
81#define SUNI1x10GEXP_REG_MSTAT_COUNTER_5_LOW 0x2124 221#define SUNI1x10GEXP_REG_MSTAT_COUNTER_5_LOW 0x2124
222#define SUNI1x10GEXP_REG_MSTAT_COUNTER_5_MID 0x2125
223#define SUNI1x10GEXP_REG_MSTAT_COUNTER_5_HIGH 0x2126
224#define SUNI1x10GEXP_REG_MSTAT_COUNTER_5_RESVD 0x2127
82#define SUNI1x10GEXP_REG_MSTAT_COUNTER_6_LOW 0x2128 225#define SUNI1x10GEXP_REG_MSTAT_COUNTER_6_LOW 0x2128
226#define SUNI1x10GEXP_REG_MSTAT_COUNTER_6_MID 0x2129
227#define SUNI1x10GEXP_REG_MSTAT_COUNTER_6_HIGH 0x212A
228#define SUNI1x10GEXP_REG_MSTAT_COUNTER_6_RESVD 0x212B
229#define SUNI1x10GEXP_REG_MSTAT_COUNTER_7_LOW 0x212C
230#define SUNI1x10GEXP_REG_MSTAT_COUNTER_7_MID 0x212D
231#define SUNI1x10GEXP_REG_MSTAT_COUNTER_7_HIGH 0x212E
232#define SUNI1x10GEXP_REG_MSTAT_COUNTER_7_RESVD 0x212F
83#define SUNI1x10GEXP_REG_MSTAT_COUNTER_8_LOW 0x2130 233#define SUNI1x10GEXP_REG_MSTAT_COUNTER_8_LOW 0x2130
234#define SUNI1x10GEXP_REG_MSTAT_COUNTER_8_MID 0x2131
235#define SUNI1x10GEXP_REG_MSTAT_COUNTER_8_HIGH 0x2132
236#define SUNI1x10GEXP_REG_MSTAT_COUNTER_8_RESVD 0x2133
237#define SUNI1x10GEXP_REG_MSTAT_COUNTER_9_LOW 0x2134
238#define SUNI1x10GEXP_REG_MSTAT_COUNTER_9_MID 0x2135
239#define SUNI1x10GEXP_REG_MSTAT_COUNTER_9_HIGH 0x2136
240#define SUNI1x10GEXP_REG_MSTAT_COUNTER_9_RESVD 0x2137
84#define SUNI1x10GEXP_REG_MSTAT_COUNTER_10_LOW 0x2138 241#define SUNI1x10GEXP_REG_MSTAT_COUNTER_10_LOW 0x2138
242#define SUNI1x10GEXP_REG_MSTAT_COUNTER_10_MID 0x2139
243#define SUNI1x10GEXP_REG_MSTAT_COUNTER_10_HIGH 0x213A
244#define SUNI1x10GEXP_REG_MSTAT_COUNTER_10_RESVD 0x213B
85#define SUNI1x10GEXP_REG_MSTAT_COUNTER_11_LOW 0x213C 245#define SUNI1x10GEXP_REG_MSTAT_COUNTER_11_LOW 0x213C
246#define SUNI1x10GEXP_REG_MSTAT_COUNTER_11_MID 0x213D
247#define SUNI1x10GEXP_REG_MSTAT_COUNTER_11_HIGH 0x213E
248#define SUNI1x10GEXP_REG_MSTAT_COUNTER_11_RESVD 0x213F
86#define SUNI1x10GEXP_REG_MSTAT_COUNTER_12_LOW 0x2140 249#define SUNI1x10GEXP_REG_MSTAT_COUNTER_12_LOW 0x2140
250#define SUNI1x10GEXP_REG_MSTAT_COUNTER_12_MID 0x2141
251#define SUNI1x10GEXP_REG_MSTAT_COUNTER_12_HIGH 0x2142
252#define SUNI1x10GEXP_REG_MSTAT_COUNTER_12_RESVD 0x2143
87#define SUNI1x10GEXP_REG_MSTAT_COUNTER_13_LOW 0x2144 253#define SUNI1x10GEXP_REG_MSTAT_COUNTER_13_LOW 0x2144
254#define SUNI1x10GEXP_REG_MSTAT_COUNTER_13_MID 0x2145
255#define SUNI1x10GEXP_REG_MSTAT_COUNTER_13_HIGH 0x2146
256#define SUNI1x10GEXP_REG_MSTAT_COUNTER_13_RESVD 0x2147
257#define SUNI1x10GEXP_REG_MSTAT_COUNTER_14_LOW 0x2148
258#define SUNI1x10GEXP_REG_MSTAT_COUNTER_14_MID 0x2149
259#define SUNI1x10GEXP_REG_MSTAT_COUNTER_14_HIGH 0x214A
260#define SUNI1x10GEXP_REG_MSTAT_COUNTER_14_RESVD 0x214B
88#define SUNI1x10GEXP_REG_MSTAT_COUNTER_15_LOW 0x214C 261#define SUNI1x10GEXP_REG_MSTAT_COUNTER_15_LOW 0x214C
262#define SUNI1x10GEXP_REG_MSTAT_COUNTER_15_MID 0x214D
263#define SUNI1x10GEXP_REG_MSTAT_COUNTER_15_HIGH 0x214E
264#define SUNI1x10GEXP_REG_MSTAT_COUNTER_15_RESVD 0x214F
89#define SUNI1x10GEXP_REG_MSTAT_COUNTER_16_LOW 0x2150 265#define SUNI1x10GEXP_REG_MSTAT_COUNTER_16_LOW 0x2150
266#define SUNI1x10GEXP_REG_MSTAT_COUNTER_16_MID 0x2151
267#define SUNI1x10GEXP_REG_MSTAT_COUNTER_16_HIGH 0x2152
268#define SUNI1x10GEXP_REG_MSTAT_COUNTER_16_RESVD 0x2153
90#define SUNI1x10GEXP_REG_MSTAT_COUNTER_17_LOW 0x2154 269#define SUNI1x10GEXP_REG_MSTAT_COUNTER_17_LOW 0x2154
270#define SUNI1x10GEXP_REG_MSTAT_COUNTER_17_MID 0x2155
271#define SUNI1x10GEXP_REG_MSTAT_COUNTER_17_HIGH 0x2156
272#define SUNI1x10GEXP_REG_MSTAT_COUNTER_17_RESVD 0x2157
91#define SUNI1x10GEXP_REG_MSTAT_COUNTER_18_LOW 0x2158 273#define SUNI1x10GEXP_REG_MSTAT_COUNTER_18_LOW 0x2158
274#define SUNI1x10GEXP_REG_MSTAT_COUNTER_18_MID 0x2159
275#define SUNI1x10GEXP_REG_MSTAT_COUNTER_18_HIGH 0x215A
276#define SUNI1x10GEXP_REG_MSTAT_COUNTER_18_RESVD 0x215B
277#define SUNI1x10GEXP_REG_MSTAT_COUNTER_19_LOW 0x215C
278#define SUNI1x10GEXP_REG_MSTAT_COUNTER_19_MID 0x215D
279#define SUNI1x10GEXP_REG_MSTAT_COUNTER_19_HIGH 0x215E
280#define SUNI1x10GEXP_REG_MSTAT_COUNTER_19_RESVD 0x215F
281#define SUNI1x10GEXP_REG_MSTAT_COUNTER_20_LOW 0x2160
282#define SUNI1x10GEXP_REG_MSTAT_COUNTER_20_MID 0x2161
283#define SUNI1x10GEXP_REG_MSTAT_COUNTER_20_HIGH 0x2162
284#define SUNI1x10GEXP_REG_MSTAT_COUNTER_20_RESVD 0x2163
285#define SUNI1x10GEXP_REG_MSTAT_COUNTER_21_LOW 0x2164
286#define SUNI1x10GEXP_REG_MSTAT_COUNTER_21_MID 0x2165
287#define SUNI1x10GEXP_REG_MSTAT_COUNTER_21_HIGH 0x2166
288#define SUNI1x10GEXP_REG_MSTAT_COUNTER_21_RESVD 0x2167
289#define SUNI1x10GEXP_REG_MSTAT_COUNTER_22_LOW 0x2168
290#define SUNI1x10GEXP_REG_MSTAT_COUNTER_22_MID 0x2169
291#define SUNI1x10GEXP_REG_MSTAT_COUNTER_22_HIGH 0x216A
292#define SUNI1x10GEXP_REG_MSTAT_COUNTER_22_RESVD 0x216B
293#define SUNI1x10GEXP_REG_MSTAT_COUNTER_23_LOW 0x216C
294#define SUNI1x10GEXP_REG_MSTAT_COUNTER_23_MID 0x216D
295#define SUNI1x10GEXP_REG_MSTAT_COUNTER_23_HIGH 0x216E
296#define SUNI1x10GEXP_REG_MSTAT_COUNTER_23_RESVD 0x216F
297#define SUNI1x10GEXP_REG_MSTAT_COUNTER_24_LOW 0x2170
298#define SUNI1x10GEXP_REG_MSTAT_COUNTER_24_MID 0x2171
299#define SUNI1x10GEXP_REG_MSTAT_COUNTER_24_HIGH 0x2172
300#define SUNI1x10GEXP_REG_MSTAT_COUNTER_24_RESVD 0x2173
301#define SUNI1x10GEXP_REG_MSTAT_COUNTER_25_LOW 0x2174
302#define SUNI1x10GEXP_REG_MSTAT_COUNTER_25_MID 0x2175
303#define SUNI1x10GEXP_REG_MSTAT_COUNTER_25_HIGH 0x2176
304#define SUNI1x10GEXP_REG_MSTAT_COUNTER_25_RESVD 0x2177
305#define SUNI1x10GEXP_REG_MSTAT_COUNTER_26_LOW 0x2178
306#define SUNI1x10GEXP_REG_MSTAT_COUNTER_26_MID 0x2179
307#define SUNI1x10GEXP_REG_MSTAT_COUNTER_26_HIGH 0x217a
308#define SUNI1x10GEXP_REG_MSTAT_COUNTER_26_RESVD 0x217b
309#define SUNI1x10GEXP_REG_MSTAT_COUNTER_27_LOW 0x217c
310#define SUNI1x10GEXP_REG_MSTAT_COUNTER_27_MID 0x217d
311#define SUNI1x10GEXP_REG_MSTAT_COUNTER_27_HIGH 0x217e
312#define SUNI1x10GEXP_REG_MSTAT_COUNTER_27_RESVD 0x217f
313#define SUNI1x10GEXP_REG_MSTAT_COUNTER_28_LOW 0x2180
314#define SUNI1x10GEXP_REG_MSTAT_COUNTER_28_MID 0x2181
315#define SUNI1x10GEXP_REG_MSTAT_COUNTER_28_HIGH 0x2182
316#define SUNI1x10GEXP_REG_MSTAT_COUNTER_28_RESVD 0x2183
317#define SUNI1x10GEXP_REG_MSTAT_COUNTER_29_LOW 0x2184
318#define SUNI1x10GEXP_REG_MSTAT_COUNTER_29_MID 0x2185
319#define SUNI1x10GEXP_REG_MSTAT_COUNTER_29_HIGH 0x2186
320#define SUNI1x10GEXP_REG_MSTAT_COUNTER_29_RESVD 0x2187
321#define SUNI1x10GEXP_REG_MSTAT_COUNTER_30_LOW 0x2188
322#define SUNI1x10GEXP_REG_MSTAT_COUNTER_30_MID 0x2189
323#define SUNI1x10GEXP_REG_MSTAT_COUNTER_30_HIGH 0x218A
324#define SUNI1x10GEXP_REG_MSTAT_COUNTER_30_RESVD 0x218B
325#define SUNI1x10GEXP_REG_MSTAT_COUNTER_31_LOW 0x218C
326#define SUNI1x10GEXP_REG_MSTAT_COUNTER_31_MID 0x218D
327#define SUNI1x10GEXP_REG_MSTAT_COUNTER_31_HIGH 0x218E
328#define SUNI1x10GEXP_REG_MSTAT_COUNTER_31_RESVD 0x218F
329#define SUNI1x10GEXP_REG_MSTAT_COUNTER_32_LOW 0x2190
330#define SUNI1x10GEXP_REG_MSTAT_COUNTER_32_MID 0x2191
331#define SUNI1x10GEXP_REG_MSTAT_COUNTER_32_HIGH 0x2192
332#define SUNI1x10GEXP_REG_MSTAT_COUNTER_32_RESVD 0x2193
92#define SUNI1x10GEXP_REG_MSTAT_COUNTER_33_LOW 0x2194 333#define SUNI1x10GEXP_REG_MSTAT_COUNTER_33_LOW 0x2194
334#define SUNI1x10GEXP_REG_MSTAT_COUNTER_33_MID 0x2195
335#define SUNI1x10GEXP_REG_MSTAT_COUNTER_33_HIGH 0x2196
336#define SUNI1x10GEXP_REG_MSTAT_COUNTER_33_RESVD 0x2197
337#define SUNI1x10GEXP_REG_MSTAT_COUNTER_34_LOW 0x2198
338#define SUNI1x10GEXP_REG_MSTAT_COUNTER_34_MID 0x2199
339#define SUNI1x10GEXP_REG_MSTAT_COUNTER_34_HIGH 0x219A
340#define SUNI1x10GEXP_REG_MSTAT_COUNTER_34_RESVD 0x219B
93#define SUNI1x10GEXP_REG_MSTAT_COUNTER_35_LOW 0x219C 341#define SUNI1x10GEXP_REG_MSTAT_COUNTER_35_LOW 0x219C
342#define SUNI1x10GEXP_REG_MSTAT_COUNTER_35_MID 0x219D
343#define SUNI1x10GEXP_REG_MSTAT_COUNTER_35_HIGH 0x219E
344#define SUNI1x10GEXP_REG_MSTAT_COUNTER_35_RESVD 0x219F
94#define SUNI1x10GEXP_REG_MSTAT_COUNTER_36_LOW 0x21A0 345#define SUNI1x10GEXP_REG_MSTAT_COUNTER_36_LOW 0x21A0
346#define SUNI1x10GEXP_REG_MSTAT_COUNTER_36_MID 0x21A1
347#define SUNI1x10GEXP_REG_MSTAT_COUNTER_36_HIGH 0x21A2
348#define SUNI1x10GEXP_REG_MSTAT_COUNTER_36_RESVD 0x21A3
349#define SUNI1x10GEXP_REG_MSTAT_COUNTER_37_LOW 0x21A4
350#define SUNI1x10GEXP_REG_MSTAT_COUNTER_37_MID 0x21A5
351#define SUNI1x10GEXP_REG_MSTAT_COUNTER_37_HIGH 0x21A6
352#define SUNI1x10GEXP_REG_MSTAT_COUNTER_37_RESVD 0x21A7
95#define SUNI1x10GEXP_REG_MSTAT_COUNTER_38_LOW 0x21A8 353#define SUNI1x10GEXP_REG_MSTAT_COUNTER_38_LOW 0x21A8
354#define SUNI1x10GEXP_REG_MSTAT_COUNTER_38_MID 0x21A9
355#define SUNI1x10GEXP_REG_MSTAT_COUNTER_38_HIGH 0x21AA
356#define SUNI1x10GEXP_REG_MSTAT_COUNTER_38_RESVD 0x21AB
357#define SUNI1x10GEXP_REG_MSTAT_COUNTER_39_LOW 0x21AC
358#define SUNI1x10GEXP_REG_MSTAT_COUNTER_39_MID 0x21AD
359#define SUNI1x10GEXP_REG_MSTAT_COUNTER_39_HIGH 0x21AE
360#define SUNI1x10GEXP_REG_MSTAT_COUNTER_39_RESVD 0x21AF
96#define SUNI1x10GEXP_REG_MSTAT_COUNTER_40_LOW 0x21B0 361#define SUNI1x10GEXP_REG_MSTAT_COUNTER_40_LOW 0x21B0
362#define SUNI1x10GEXP_REG_MSTAT_COUNTER_40_MID 0x21B1
363#define SUNI1x10GEXP_REG_MSTAT_COUNTER_40_HIGH 0x21B2
364#define SUNI1x10GEXP_REG_MSTAT_COUNTER_40_RESVD 0x21B3
365#define SUNI1x10GEXP_REG_MSTAT_COUNTER_41_LOW 0x21B4
366#define SUNI1x10GEXP_REG_MSTAT_COUNTER_41_MID 0x21B5
367#define SUNI1x10GEXP_REG_MSTAT_COUNTER_41_HIGH 0x21B6
368#define SUNI1x10GEXP_REG_MSTAT_COUNTER_41_RESVD 0x21B7
97#define SUNI1x10GEXP_REG_MSTAT_COUNTER_42_LOW 0x21B8 369#define SUNI1x10GEXP_REG_MSTAT_COUNTER_42_LOW 0x21B8
370#define SUNI1x10GEXP_REG_MSTAT_COUNTER_42_MID 0x21B9
371#define SUNI1x10GEXP_REG_MSTAT_COUNTER_42_HIGH 0x21BA
372#define SUNI1x10GEXP_REG_MSTAT_COUNTER_42_RESVD 0x21BB
98#define SUNI1x10GEXP_REG_MSTAT_COUNTER_43_LOW 0x21BC 373#define SUNI1x10GEXP_REG_MSTAT_COUNTER_43_LOW 0x21BC
374#define SUNI1x10GEXP_REG_MSTAT_COUNTER_43_MID 0x21BD
375#define SUNI1x10GEXP_REG_MSTAT_COUNTER_43_HIGH 0x21BE
376#define SUNI1x10GEXP_REG_MSTAT_COUNTER_43_RESVD 0x21BF
377#define SUNI1x10GEXP_REG_MSTAT_COUNTER_44_LOW 0x21C0
378#define SUNI1x10GEXP_REG_MSTAT_COUNTER_44_MID 0x21C1
379#define SUNI1x10GEXP_REG_MSTAT_COUNTER_44_HIGH 0x21C2
380#define SUNI1x10GEXP_REG_MSTAT_COUNTER_44_RESVD 0x21C3
381#define SUNI1x10GEXP_REG_MSTAT_COUNTER_45_LOW 0x21C4
382#define SUNI1x10GEXP_REG_MSTAT_COUNTER_45_MID 0x21C5
383#define SUNI1x10GEXP_REG_MSTAT_COUNTER_45_HIGH 0x21C6
384#define SUNI1x10GEXP_REG_MSTAT_COUNTER_45_RESVD 0x21C7
385#define SUNI1x10GEXP_REG_MSTAT_COUNTER_46_LOW 0x21C8
386#define SUNI1x10GEXP_REG_MSTAT_COUNTER_46_MID 0x21C9
387#define SUNI1x10GEXP_REG_MSTAT_COUNTER_46_HIGH 0x21CA
388#define SUNI1x10GEXP_REG_MSTAT_COUNTER_46_RESVD 0x21CB
389#define SUNI1x10GEXP_REG_MSTAT_COUNTER_47_LOW 0x21CC
390#define SUNI1x10GEXP_REG_MSTAT_COUNTER_47_MID 0x21CD
391#define SUNI1x10GEXP_REG_MSTAT_COUNTER_47_HIGH 0x21CE
392#define SUNI1x10GEXP_REG_MSTAT_COUNTER_47_RESVD 0x21CF
393#define SUNI1x10GEXP_REG_MSTAT_COUNTER_48_LOW 0x21D0
394#define SUNI1x10GEXP_REG_MSTAT_COUNTER_48_MID 0x21D1
395#define SUNI1x10GEXP_REG_MSTAT_COUNTER_48_HIGH 0x21D2
396#define SUNI1x10GEXP_REG_MSTAT_COUNTER_48_RESVD 0x21D3
397#define SUNI1x10GEXP_REG_MSTAT_COUNTER_49_LOW 0x21D4
398#define SUNI1x10GEXP_REG_MSTAT_COUNTER_49_MID 0x21D5
399#define SUNI1x10GEXP_REG_MSTAT_COUNTER_49_HIGH 0x21D6
400#define SUNI1x10GEXP_REG_MSTAT_COUNTER_49_RESVD 0x21D7
401#define SUNI1x10GEXP_REG_MSTAT_COUNTER_50_LOW 0x21D8
402#define SUNI1x10GEXP_REG_MSTAT_COUNTER_50_MID 0x21D9
403#define SUNI1x10GEXP_REG_MSTAT_COUNTER_50_HIGH 0x21DA
404#define SUNI1x10GEXP_REG_MSTAT_COUNTER_50_RESVD 0x21DB
405#define SUNI1x10GEXP_REG_MSTAT_COUNTER_51_LOW 0x21DC
406#define SUNI1x10GEXP_REG_MSTAT_COUNTER_51_MID 0x21DD
407#define SUNI1x10GEXP_REG_MSTAT_COUNTER_51_HIGH 0x21DE
408#define SUNI1x10GEXP_REG_MSTAT_COUNTER_51_RESVD 0x21DF
409#define SUNI1x10GEXP_REG_MSTAT_COUNTER_52_LOW 0x21E0
410#define SUNI1x10GEXP_REG_MSTAT_COUNTER_52_MID 0x21E1
411#define SUNI1x10GEXP_REG_MSTAT_COUNTER_52_HIGH 0x21E2
412#define SUNI1x10GEXP_REG_MSTAT_COUNTER_52_RESVD 0x21E3
413#define SUNI1x10GEXP_REG_MSTAT_COUNTER_53_LOW 0x21E4
414#define SUNI1x10GEXP_REG_MSTAT_COUNTER_53_MID 0x21E5
415#define SUNI1x10GEXP_REG_MSTAT_COUNTER_53_HIGH 0x21E6
416#define SUNI1x10GEXP_CNTR_MAC_ETHERNET_NUM 51
417
418#define SUNI1x10GEXP_REG_IFLX_GLOBAL_CONFIG 0x2200
419#define SUNI1x10GEXP_REG_IFLX_CHANNEL_PROVISION 0x2201
99#define SUNI1x10GEXP_REG_IFLX_FIFO_OVERFLOW_ENABLE 0x2209 420#define SUNI1x10GEXP_REG_IFLX_FIFO_OVERFLOW_ENABLE 0x2209
100#define SUNI1x10GEXP_REG_IFLX_FIFO_OVERFLOW_INTERRUPT 0x220A 421#define SUNI1x10GEXP_REG_IFLX_FIFO_OVERFLOW_INTERRUPT 0x220A
422#define SUNI1x10GEXP_REG_IFLX_INDIR_CHANNEL_ADDRESS 0x220D
423#define SUNI1x10GEXP_REG_IFLX_INDIR_LOGICAL_FIFO_LOW_LIMIT_PROVISION 0x220E
424#define SUNI1x10GEXP_REG_IFLX_INDIR_LOGICAL_FIFO_HIGH_LIMIT 0x220F
425#define SUNI1x10GEXP_REG_IFLX_INDIR_FULL_ALMOST_FULL_STATUS_LIMIT 0x2210
426#define SUNI1x10GEXP_REG_IFLX_INDIR_EMPTY_ALMOST_EMPTY_STATUS_LIMIT 0x2211
427
428#define SUNI1x10GEXP_REG_PL4MOS_CONFIG 0x2240
429#define SUNI1x10GEXP_REG_PL4MOS_MASK 0x2241
430#define SUNI1x10GEXP_REG_PL4MOS_FAIRNESS_MASKING 0x2242
431#define SUNI1x10GEXP_REG_PL4MOS_MAXBURST1 0x2243
432#define SUNI1x10GEXP_REG_PL4MOS_MAXBURST2 0x2244
433#define SUNI1x10GEXP_REG_PL4MOS_TRANSFER_SIZE 0x2245
434
435#define SUNI1x10GEXP_REG_PL4ODP_CONFIG 0x2280
101#define SUNI1x10GEXP_REG_PL4ODP_INTERRUPT_MASK 0x2282 436#define SUNI1x10GEXP_REG_PL4ODP_INTERRUPT_MASK 0x2282
102#define SUNI1x10GEXP_REG_PL4ODP_INTERRUPT 0x2283 437#define SUNI1x10GEXP_REG_PL4ODP_INTERRUPT 0x2283
438#define SUNI1x10GEXP_REG_PL4ODP_CONFIG_MAX_T 0x2284
439
103#define SUNI1x10GEXP_REG_PL4IO_LOCK_DETECT_STATUS 0x2300 440#define SUNI1x10GEXP_REG_PL4IO_LOCK_DETECT_STATUS 0x2300
104#define SUNI1x10GEXP_REG_PL4IO_LOCK_DETECT_CHANGE 0x2301 441#define SUNI1x10GEXP_REG_PL4IO_LOCK_DETECT_CHANGE 0x2301
105#define SUNI1x10GEXP_REG_PL4IO_LOCK_DETECT_MASK 0x2302 442#define SUNI1x10GEXP_REG_PL4IO_LOCK_DETECT_MASK 0x2302
443#define SUNI1x10GEXP_REG_PL4IO_LOCK_DETECT_LIMITS 0x2303
444#define SUNI1x10GEXP_REG_PL4IO_CALENDAR_REPETITIONS 0x2304
445#define SUNI1x10GEXP_REG_PL4IO_CONFIG 0x2305
446
106#define SUNI1x10GEXP_REG_TXXG_CONFIG_1 0x3040 447#define SUNI1x10GEXP_REG_TXXG_CONFIG_1 0x3040
448#define SUNI1x10GEXP_REG_TXXG_CONFIG_2 0x3041
107#define SUNI1x10GEXP_REG_TXXG_CONFIG_3 0x3042 449#define SUNI1x10GEXP_REG_TXXG_CONFIG_3 0x3042
108#define SUNI1x10GEXP_REG_TXXG_INTERRUPT 0x3043 450#define SUNI1x10GEXP_REG_TXXG_INTERRUPT 0x3043
451#define SUNI1x10GEXP_REG_TXXG_STATUS 0x3044
109#define SUNI1x10GEXP_REG_TXXG_MAX_FRAME_SIZE 0x3045 452#define SUNI1x10GEXP_REG_TXXG_MAX_FRAME_SIZE 0x3045
453#define SUNI1x10GEXP_REG_TXXG_MIN_FRAME_SIZE 0x3046
110#define SUNI1x10GEXP_REG_TXXG_SA_15_0 0x3047 454#define SUNI1x10GEXP_REG_TXXG_SA_15_0 0x3047
111#define SUNI1x10GEXP_REG_TXXG_SA_31_16 0x3048 455#define SUNI1x10GEXP_REG_TXXG_SA_31_16 0x3048
112#define SUNI1x10GEXP_REG_TXXG_SA_47_32 0x3049 456#define SUNI1x10GEXP_REG_TXXG_SA_47_32 0x3049
457#define SUNI1x10GEXP_REG_TXXG_PAUSE_TIMER 0x304D
458#define SUNI1x10GEXP_REG_TXXG_PAUSE_TIMER_INTERVAL 0x304E
459#define SUNI1x10GEXP_REG_TXXG_FILTER_ERROR_COUNTER 0x3051
460#define SUNI1x10GEXP_REG_TXXG_PAUSE_QUANTUM_CONFIG 0x3052
461
462#define SUNI1x10GEXP_REG_XTEF_CTRL 0x3080
113#define SUNI1x10GEXP_REG_XTEF_INTERRUPT_STATUS 0x3084 463#define SUNI1x10GEXP_REG_XTEF_INTERRUPT_STATUS 0x3084
114#define SUNI1x10GEXP_REG_XTEF_INTERRUPT_ENABLE 0x3085 464#define SUNI1x10GEXP_REG_XTEF_INTERRUPT_ENABLE 0x3085
465#define SUNI1x10GEXP_REG_XTEF_VISIBILITY 0x3086
466
467#define SUNI1x10GEXP_REG_TXOAM_OAM_CONFIG 0x30C0
468#define SUNI1x10GEXP_REG_TXOAM_MINI_RATE_CONFIG 0x30C1
469#define SUNI1x10GEXP_REG_TXOAM_MINI_GAP_FIFO_CONFIG 0x30C2
470#define SUNI1x10GEXP_REG_TXOAM_P1P2_STATIC_VALUES 0x30C3
471#define SUNI1x10GEXP_REG_TXOAM_P3P4_STATIC_VALUES 0x30C4
472#define SUNI1x10GEXP_REG_TXOAM_P5P6_STATIC_VALUES 0x30C5
115#define SUNI1x10GEXP_REG_TXOAM_INTERRUPT_ENABLE 0x30C6 473#define SUNI1x10GEXP_REG_TXOAM_INTERRUPT_ENABLE 0x30C6
116#define SUNI1x10GEXP_REG_TXOAM_INTERRUPT_STATUS 0x30C7 474#define SUNI1x10GEXP_REG_TXOAM_INTERRUPT_STATUS 0x30C7
475#define SUNI1x10GEXP_REG_TXOAM_INSERT_COUNT_LSB 0x30C8
476#define SUNI1x10GEXP_REG_TXOAM_INSERT_COUNT_MSB 0x30C9
477#define SUNI1x10GEXP_REG_TXOAM_OAM_MINI_COUNT_LSB 0x30CA
478#define SUNI1x10GEXP_REG_TXOAM_OAM_MINI_COUNT_MSB 0x30CB
479#define SUNI1x10GEXP_REG_TXOAM_P1P2_MINI_MASK 0x30CC
480#define SUNI1x10GEXP_REG_TXOAM_P3P4_MINI_MASK 0x30CD
481#define SUNI1x10GEXP_REG_TXOAM_P5P6_MINI_MASK 0x30CE
482#define SUNI1x10GEXP_REG_TXOAM_COSET 0x30CF
483#define SUNI1x10GEXP_REG_TXOAM_EMPTY_FIFO_INS_OP_CNT_LSB 0x30D0
484#define SUNI1x10GEXP_REG_TXOAM_EMPTY_FIFO_INS_OP_CNT_MSB 0x30D1
485#define SUNI1x10GEXP_REG_TXOAM_STATIC_VALUE_MINI_COUNT_LSB 0x30D2
486#define SUNI1x10GEXP_REG_TXOAM_STATIC_VALUE_MINI_COUNT_MSB 0x30D3
487
488
489#define SUNI1x10GEXP_REG_EFLX_GLOBAL_CONFIG 0x3200
490#define SUNI1x10GEXP_REG_EFLX_ERCU_GLOBAL_STATUS 0x3201
491#define SUNI1x10GEXP_REG_EFLX_INDIR_CHANNEL_ADDRESS 0x3202
492#define SUNI1x10GEXP_REG_EFLX_INDIR_FIFO_LOW_LIMIT 0x3203
493#define SUNI1x10GEXP_REG_EFLX_INDIR_FIFO_HIGH_LIMIT 0x3204
494#define SUNI1x10GEXP_REG_EFLX_INDIR_FULL_ALMOST_FULL_STATUS_AND_LIMIT 0x3205
495#define SUNI1x10GEXP_REG_EFLX_INDIR_EMPTY_ALMOST_EMPTY_STATUS_AND_LIMIT 0x3206
496#define SUNI1x10GEXP_REG_EFLX_INDIR_FIFO_CUT_THROUGH_THRESHOLD 0x3207
117#define SUNI1x10GEXP_REG_EFLX_FIFO_OVERFLOW_ERROR_ENABLE 0x320C 497#define SUNI1x10GEXP_REG_EFLX_FIFO_OVERFLOW_ERROR_ENABLE 0x320C
118#define SUNI1x10GEXP_REG_EFLX_FIFO_OVERFLOW_ERROR_INDICATION 0x320D 498#define SUNI1x10GEXP_REG_EFLX_FIFO_OVERFLOW_ERROR_INDICATION 0x320D
499#define SUNI1x10GEXP_REG_EFLX_CHANNEL_PROVISION 0x3210
500
501#define SUNI1x10GEXP_REG_PL4IDU_CONFIG 0x3280
119#define SUNI1x10GEXP_REG_PL4IDU_INTERRUPT_MASK 0x3282 502#define SUNI1x10GEXP_REG_PL4IDU_INTERRUPT_MASK 0x3282
120#define SUNI1x10GEXP_REG_PL4IDU_INTERRUPT 0x3283 503#define SUNI1x10GEXP_REG_PL4IDU_INTERRUPT 0x3283
121 504
505
506/*----------------------------------------*/
507#define SUNI1x10GEXP_REG_MAX_OFFSET 0x3480
508
122/******************************************************************************/ 509/******************************************************************************/
123/* -- End register offset definitions -- */ 510/* -- End register offset definitions -- */
124/******************************************************************************/ 511/******************************************************************************/
@@ -127,6 +514,81 @@
127/** SUNI-1x10GE-XP REGISTER BIT MASKS **/ 514/** SUNI-1x10GE-XP REGISTER BIT MASKS **/
128/******************************************************************************/ 515/******************************************************************************/
129 516
517#define SUNI1x10GEXP_BITMSK_BITS_1 0x00001
518#define SUNI1x10GEXP_BITMSK_BITS_2 0x00003
519#define SUNI1x10GEXP_BITMSK_BITS_3 0x00007
520#define SUNI1x10GEXP_BITMSK_BITS_4 0x0000f
521#define SUNI1x10GEXP_BITMSK_BITS_5 0x0001f
522#define SUNI1x10GEXP_BITMSK_BITS_6 0x0003f
523#define SUNI1x10GEXP_BITMSK_BITS_7 0x0007f
524#define SUNI1x10GEXP_BITMSK_BITS_8 0x000ff
525#define SUNI1x10GEXP_BITMSK_BITS_9 0x001ff
526#define SUNI1x10GEXP_BITMSK_BITS_10 0x003ff
527#define SUNI1x10GEXP_BITMSK_BITS_11 0x007ff
528#define SUNI1x10GEXP_BITMSK_BITS_12 0x00fff
529#define SUNI1x10GEXP_BITMSK_BITS_13 0x01fff
530#define SUNI1x10GEXP_BITMSK_BITS_14 0x03fff
531#define SUNI1x10GEXP_BITMSK_BITS_15 0x07fff
532#define SUNI1x10GEXP_BITMSK_BITS_16 0x0ffff
533
534#define mSUNI1x10GEXP_CLR_MSBITS_1(v) ((v) & SUNI1x10GEXP_BITMSK_BITS_15)
535#define mSUNI1x10GEXP_CLR_MSBITS_2(v) ((v) & SUNI1x10GEXP_BITMSK_BITS_14)
536#define mSUNI1x10GEXP_CLR_MSBITS_3(v) ((v) & SUNI1x10GEXP_BITMSK_BITS_13)
537#define mSUNI1x10GEXP_CLR_MSBITS_4(v) ((v) & SUNI1x10GEXP_BITMSK_BITS_12)
538#define mSUNI1x10GEXP_CLR_MSBITS_5(v) ((v) & SUNI1x10GEXP_BITMSK_BITS_11)
539#define mSUNI1x10GEXP_CLR_MSBITS_6(v) ((v) & SUNI1x10GEXP_BITMSK_BITS_10)
540#define mSUNI1x10GEXP_CLR_MSBITS_7(v) ((v) & SUNI1x10GEXP_BITMSK_BITS_9)
541#define mSUNI1x10GEXP_CLR_MSBITS_8(v) ((v) & SUNI1x10GEXP_BITMSK_BITS_8)
542#define mSUNI1x10GEXP_CLR_MSBITS_9(v) ((v) & SUNI1x10GEXP_BITMSK_BITS_7)
543#define mSUNI1x10GEXP_CLR_MSBITS_10(v) ((v) & SUNI1x10GEXP_BITMSK_BITS_6)
544#define mSUNI1x10GEXP_CLR_MSBITS_11(v) ((v) & SUNI1x10GEXP_BITMSK_BITS_5)
545#define mSUNI1x10GEXP_CLR_MSBITS_12(v) ((v) & SUNI1x10GEXP_BITMSK_BITS_4)
546#define mSUNI1x10GEXP_CLR_MSBITS_13(v) ((v) & SUNI1x10GEXP_BITMSK_BITS_3)
547#define mSUNI1x10GEXP_CLR_MSBITS_14(v) ((v) & SUNI1x10GEXP_BITMSK_BITS_2)
548#define mSUNI1x10GEXP_CLR_MSBITS_15(v) ((v) & SUNI1x10GEXP_BITMSK_BITS_1)
549
550#define mSUNI1x10GEXP_GET_BIT(val, bitMsk) (((val)&(bitMsk)) ? 1:0)
551
552
553
554/*----------------------------------------------------------------------------
555 * Register 0x0001: S/UNI-1x10GE-XP Product Revision
556 * Bit 3-0 REVISION
557 *----------------------------------------------------------------------------*/
558#define SUNI1x10GEXP_BITMSK_REVISION 0x000F
559
560/*----------------------------------------------------------------------------
561 * Register 0x0002: S/UNI-1x10GE-XP Configuration and Reset Control
562 * Bit 2 XAUI_ARESETB
563 * Bit 1 PL4_ARESETB
564 * Bit 0 DRESETB
565 *----------------------------------------------------------------------------*/
566#define SUNI1x10GEXP_BITMSK_XAUI_ARESET 0x0004
567#define SUNI1x10GEXP_BITMSK_PL4_ARESET 0x0002
568#define SUNI1x10GEXP_BITMSK_DRESETB 0x0001
569
570/*----------------------------------------------------------------------------
571 * Register 0x0003: S/UNI-1x10GE-XP Loop Back and Miscellaneous Control
572 * Bit 11 PL4IO_OUTCLKSEL
573 * Bit 9 SYSPCSLB
574 * Bit 8 LINEPCSLB
575 * Bit 7 MSTAT_BYPASS
576 * Bit 6 RXXG_BYPASS
577 * Bit 5 TXXG_BYPASS
578 * Bit 4 SOP_PAD_EN
579 * Bit 1 LOS_INV
580 * Bit 0 OVERRIDE_LOS
581 *----------------------------------------------------------------------------*/
582#define SUNI1x10GEXP_BITMSK_PL4IO_OUTCLKSEL 0x0800
583#define SUNI1x10GEXP_BITMSK_SYSPCSLB 0x0200
584#define SUNI1x10GEXP_BITMSK_LINEPCSLB 0x0100
585#define SUNI1x10GEXP_BITMSK_MSTAT_BYPASS 0x0080
586#define SUNI1x10GEXP_BITMSK_RXXG_BYPASS 0x0040
587#define SUNI1x10GEXP_BITMSK_TXXG_BYPASS 0x0020
588#define SUNI1x10GEXP_BITMSK_SOP_PAD_EN 0x0010
589#define SUNI1x10GEXP_BITMSK_LOS_INV 0x0002
590#define SUNI1x10GEXP_BITMSK_OVERRIDE_LOS 0x0001
591
130/*---------------------------------------------------------------------------- 592/*----------------------------------------------------------------------------
131 * Register 0x0004: S/UNI-1x10GE-XP Device Status 593 * Register 0x0004: S/UNI-1x10GE-XP Device Status
132 * Bit 9 TOP_SXRA_EXPIRED 594 * Bit 9 TOP_SXRA_EXPIRED
@@ -141,7 +603,10 @@
141 * Bit 0 TOP_PL4_OUT_ROOL 603 * Bit 0 TOP_PL4_OUT_ROOL
142 *----------------------------------------------------------------------------*/ 604 *----------------------------------------------------------------------------*/
143#define SUNI1x10GEXP_BITMSK_TOP_SXRA_EXPIRED 0x0200 605#define SUNI1x10GEXP_BITMSK_TOP_SXRA_EXPIRED 0x0200
606#define SUNI1x10GEXP_BITMSK_TOP_MDIO_BUSY 0x0100
607#define SUNI1x10GEXP_BITMSK_TOP_DTRB 0x0080
144#define SUNI1x10GEXP_BITMSK_TOP_EXPIRED 0x0040 608#define SUNI1x10GEXP_BITMSK_TOP_EXPIRED 0x0040
609#define SUNI1x10GEXP_BITMSK_TOP_PAUSED 0x0020
145#define SUNI1x10GEXP_BITMSK_TOP_PL4_ID_DOOL 0x0010 610#define SUNI1x10GEXP_BITMSK_TOP_PL4_ID_DOOL 0x0010
146#define SUNI1x10GEXP_BITMSK_TOP_PL4_IS_DOOL 0x0008 611#define SUNI1x10GEXP_BITMSK_TOP_PL4_IS_DOOL 0x0008
147#define SUNI1x10GEXP_BITMSK_TOP_PL4_ID_ROOL 0x0004 612#define SUNI1x10GEXP_BITMSK_TOP_PL4_ID_ROOL 0x0004
@@ -149,12 +614,219 @@
149#define SUNI1x10GEXP_BITMSK_TOP_PL4_OUT_ROOL 0x0001 614#define SUNI1x10GEXP_BITMSK_TOP_PL4_OUT_ROOL 0x0001
150 615
151/*---------------------------------------------------------------------------- 616/*----------------------------------------------------------------------------
617 * Register 0x0005: Global Performance Update and Clock Monitors
618 * Bit 15 TIP
619 * Bit 8 XAUI_REF_CLKA
620 * Bit 7 RXLANE3CLKA
621 * Bit 6 RXLANE2CLKA
622 * Bit 5 RXLANE1CLKA
623 * Bit 4 RXLANE0CLKA
624 * Bit 3 CSUCLKA
625 * Bit 2 TDCLKA
626 * Bit 1 RSCLKA
627 * Bit 0 RDCLKA
628 *----------------------------------------------------------------------------*/
629#define SUNI1x10GEXP_BITMSK_TIP 0x8000
630#define SUNI1x10GEXP_BITMSK_XAUI_REF_CLKA 0x0100
631#define SUNI1x10GEXP_BITMSK_RXLANE3CLKA 0x0080
632#define SUNI1x10GEXP_BITMSK_RXLANE2CLKA 0x0040
633#define SUNI1x10GEXP_BITMSK_RXLANE1CLKA 0x0020
634#define SUNI1x10GEXP_BITMSK_RXLANE0CLKA 0x0010
635#define SUNI1x10GEXP_BITMSK_CSUCLKA 0x0008
636#define SUNI1x10GEXP_BITMSK_TDCLKA 0x0004
637#define SUNI1x10GEXP_BITMSK_RSCLKA 0x0002
638#define SUNI1x10GEXP_BITMSK_RDCLKA 0x0001
639
640/*----------------------------------------------------------------------------
641 * Register 0x0006: MDIO Command
642 * Bit 4 MDIO_RDINC
643 * Bit 3 MDIO_RSTAT
644 * Bit 2 MDIO_LCTLD
645 * Bit 1 MDIO_LCTLA
646 * Bit 0 MDIO_SPRE
647 *----------------------------------------------------------------------------*/
648#define SUNI1x10GEXP_BITMSK_MDIO_RDINC 0x0010
649#define SUNI1x10GEXP_BITMSK_MDIO_RSTAT 0x0008
650#define SUNI1x10GEXP_BITMSK_MDIO_LCTLD 0x0004
651#define SUNI1x10GEXP_BITMSK_MDIO_LCTLA 0x0002
652#define SUNI1x10GEXP_BITMSK_MDIO_SPRE 0x0001
653
654/*----------------------------------------------------------------------------
655 * Register 0x0007: MDIO Interrupt Enable
656 * Bit 0 MDIO_BUSY_EN
657 *----------------------------------------------------------------------------*/
658#define SUNI1x10GEXP_BITMSK_MDIO_BUSY_EN 0x0001
659
660/*----------------------------------------------------------------------------
661 * Register 0x0008: MDIO Interrupt Status
662 * Bit 0 MDIO_BUSYI
663 *----------------------------------------------------------------------------*/
664#define SUNI1x10GEXP_BITMSK_MDIO_BUSYI 0x0001
665
666/*----------------------------------------------------------------------------
667 * Register 0x0009: MMD PHY Address
668 * Bit 12-8 MDIO_DEVADR
669 * Bit 4-0 MDIO_PRTADR
670 *----------------------------------------------------------------------------*/
671#define SUNI1x10GEXP_BITMSK_MDIO_DEVADR 0x1F00
672#define SUNI1x10GEXP_BITOFF_MDIO_DEVADR 8
673#define SUNI1x10GEXP_BITMSK_MDIO_PRTADR 0x001F
674#define SUNI1x10GEXP_BITOFF_MDIO_PRTADR 0
675
676/*----------------------------------------------------------------------------
677 * Register 0x000C: OAM Interface Control
678 * Bit 6 MDO_OD_ENB
679 * Bit 5 MDI_INV
680 * Bit 4 MDI_SEL
681 * Bit 3 RXOAMEN
682 * Bit 2 RXOAMCLKEN
683 * Bit 1 TXOAMEN
684 * Bit 0 TXOAMCLKEN
685 *----------------------------------------------------------------------------*/
686#define SUNI1x10GEXP_BITMSK_MDO_OD_ENB 0x0040
687#define SUNI1x10GEXP_BITMSK_MDI_INV 0x0020
688#define SUNI1x10GEXP_BITMSK_MDI_SEL 0x0010
689#define SUNI1x10GEXP_BITMSK_RXOAMEN 0x0008
690#define SUNI1x10GEXP_BITMSK_RXOAMCLKEN 0x0004
691#define SUNI1x10GEXP_BITMSK_TXOAMEN 0x0002
692#define SUNI1x10GEXP_BITMSK_TXOAMCLKEN 0x0001
693
694/*----------------------------------------------------------------------------
695 * Register 0x000D: S/UNI-1x10GE-XP Master Interrupt Status
696 * Bit 15 TOP_PL4IO_INT
697 * Bit 14 TOP_IRAM_INT
698 * Bit 13 TOP_ERAM_INT
699 * Bit 12 TOP_XAUI_INT
700 * Bit 11 TOP_MSTAT_INT
701 * Bit 10 TOP_RXXG_INT
702 * Bit 9 TOP_TXXG_INT
703 * Bit 8 TOP_XRF_INT
704 * Bit 7 TOP_XTEF_INT
705 * Bit 6 TOP_MDIO_BUSY_INT
706 * Bit 5 TOP_RXOAM_INT
707 * Bit 4 TOP_TXOAM_INT
708 * Bit 3 TOP_IFLX_INT
709 * Bit 2 TOP_EFLX_INT
710 * Bit 1 TOP_PL4ODP_INT
711 * Bit 0 TOP_PL4IDU_INT
712 *----------------------------------------------------------------------------*/
713#define SUNI1x10GEXP_BITMSK_TOP_PL4IO_INT 0x8000
714#define SUNI1x10GEXP_BITMSK_TOP_IRAM_INT 0x4000
715#define SUNI1x10GEXP_BITMSK_TOP_ERAM_INT 0x2000
716#define SUNI1x10GEXP_BITMSK_TOP_XAUI_INT 0x1000
717#define SUNI1x10GEXP_BITMSK_TOP_MSTAT_INT 0x0800
718#define SUNI1x10GEXP_BITMSK_TOP_RXXG_INT 0x0400
719#define SUNI1x10GEXP_BITMSK_TOP_TXXG_INT 0x0200
720#define SUNI1x10GEXP_BITMSK_TOP_XRF_INT 0x0100
721#define SUNI1x10GEXP_BITMSK_TOP_XTEF_INT 0x0080
722#define SUNI1x10GEXP_BITMSK_TOP_MDIO_BUSY_INT 0x0040
723#define SUNI1x10GEXP_BITMSK_TOP_RXOAM_INT 0x0020
724#define SUNI1x10GEXP_BITMSK_TOP_TXOAM_INT 0x0010
725#define SUNI1x10GEXP_BITMSK_TOP_IFLX_INT 0x0008
726#define SUNI1x10GEXP_BITMSK_TOP_EFLX_INT 0x0004
727#define SUNI1x10GEXP_BITMSK_TOP_PL4ODP_INT 0x0002
728#define SUNI1x10GEXP_BITMSK_TOP_PL4IDU_INT 0x0001
729
730/*----------------------------------------------------------------------------
152 * Register 0x000E:PM3393 Global interrupt enable 731 * Register 0x000E:PM3393 Global interrupt enable
153 * Bit 15 TOP_INTE 732 * Bit 15 TOP_INTE
154 *----------------------------------------------------------------------------*/ 733 *----------------------------------------------------------------------------*/
155#define SUNI1x10GEXP_BITMSK_TOP_INTE 0x8000 734#define SUNI1x10GEXP_BITMSK_TOP_INTE 0x8000
156 735
157/*---------------------------------------------------------------------------- 736/*----------------------------------------------------------------------------
737 * Register 0x0010: XTEF Miscellaneous Control
738 * Bit 7 RF_VAL
739 * Bit 6 RF_OVERRIDE
740 * Bit 5 LF_VAL
741 * Bit 4 LF_OVERRIDE
742 *----------------------------------------------------------------------------*/
743#define SUNI1x10GEXP_BITMSK_RF_VAL 0x0080
744#define SUNI1x10GEXP_BITMSK_RF_OVERRIDE 0x0040
745#define SUNI1x10GEXP_BITMSK_LF_VAL 0x0020
746#define SUNI1x10GEXP_BITMSK_LF_OVERRIDE 0x0010
747#define SUNI1x10GEXP_BITMSK_LFRF_OVERRIDE_VAL 0x00F0
748
749/*----------------------------------------------------------------------------
750 * Register 0x0011: XRF Miscellaneous Control
751 * Bit 6-4 EN_IDLE_REP
752 *----------------------------------------------------------------------------*/
753#define SUNI1x10GEXP_BITMSK_EN_IDLE_REP 0x0070
754
755/*----------------------------------------------------------------------------
756 * Register 0x0100: SERDES 3125 Configuration Register 1
757 * Bit 10 RXEQB_3
758 * Bit 8 RXEQB_2
759 * Bit 6 RXEQB_1
760 * Bit 4 RXEQB_0
761 *----------------------------------------------------------------------------*/
762#define SUNI1x10GEXP_BITMSK_RXEQB 0x0FF0
763#define SUNI1x10GEXP_BITOFF_RXEQB_3 10
764#define SUNI1x10GEXP_BITOFF_RXEQB_2 8
765#define SUNI1x10GEXP_BITOFF_RXEQB_1 6
766#define SUNI1x10GEXP_BITOFF_RXEQB_0 4
767
768/*----------------------------------------------------------------------------
769 * Register 0x0101: SERDES 3125 Configuration Register 2
770 * Bit 12 YSEL
771 * Bit 7 PRE_EMPH_3
772 * Bit 6 PRE_EMPH_2
773 * Bit 5 PRE_EMPH_1
774 * Bit 4 PRE_EMPH_0
775 *----------------------------------------------------------------------------*/
776#define SUNI1x10GEXP_BITMSK_YSEL 0x1000
777#define SUNI1x10GEXP_BITMSK_PRE_EMPH 0x00F0
778#define SUNI1x10GEXP_BITMSK_PRE_EMPH_3 0x0080
779#define SUNI1x10GEXP_BITMSK_PRE_EMPH_2 0x0040
780#define SUNI1x10GEXP_BITMSK_PRE_EMPH_1 0x0020
781#define SUNI1x10GEXP_BITMSK_PRE_EMPH_0 0x0010
782
783/*----------------------------------------------------------------------------
784 * Register 0x0102: SERDES 3125 Interrupt Enable Register
785 * Bit 3 LASIE
786 * Bit 2 SPLL_RAE
787 * Bit 1 MPLL_RAE
788 * Bit 0 PLL_LOCKE
789 *----------------------------------------------------------------------------*/
790#define SUNI1x10GEXP_BITMSK_LASIE 0x0008
791#define SUNI1x10GEXP_BITMSK_SPLL_RAE 0x0004
792#define SUNI1x10GEXP_BITMSK_MPLL_RAE 0x0002
793#define SUNI1x10GEXP_BITMSK_PLL_LOCKE 0x0001
794
795/*----------------------------------------------------------------------------
796 * Register 0x0103: SERDES 3125 Interrupt Visibility Register
797 * Bit 3 LASIV
798 * Bit 2 SPLL_RAV
799 * Bit 1 MPLL_RAV
800 * Bit 0 PLL_LOCKV
801 *----------------------------------------------------------------------------*/
802#define SUNI1x10GEXP_BITMSK_LASIV 0x0008
803#define SUNI1x10GEXP_BITMSK_SPLL_RAV 0x0004
804#define SUNI1x10GEXP_BITMSK_MPLL_RAV 0x0002
805#define SUNI1x10GEXP_BITMSK_PLL_LOCKV 0x0001
806
807/*----------------------------------------------------------------------------
808 * Register 0x0104: SERDES 3125 Interrupt Status Register
809 * Bit 3 LASII
810 * Bit 2 SPLL_RAI
811 * Bit 1 MPLL_RAI
812 * Bit 0 PLL_LOCKI
813 *----------------------------------------------------------------------------*/
814#define SUNI1x10GEXP_BITMSK_LASII 0x0008
815#define SUNI1x10GEXP_BITMSK_SPLL_RAI 0x0004
816#define SUNI1x10GEXP_BITMSK_MPLL_RAI 0x0002
817#define SUNI1x10GEXP_BITMSK_PLL_LOCKI 0x0001
818
819/*----------------------------------------------------------------------------
820 * Register 0x0107: SERDES 3125 Test Configuration
821 * Bit 12 DUALTX
822 * Bit 10 HC_1
823 * Bit 9 HC_0
824 *----------------------------------------------------------------------------*/
825#define SUNI1x10GEXP_BITMSK_DUALTX 0x1000
826#define SUNI1x10GEXP_BITMSK_HC 0x0600
827#define SUNI1x10GEXP_BITOFF_HC_0 9
828
829/*----------------------------------------------------------------------------
158 * Register 0x2040: RXXG Configuration 1 830 * Register 0x2040: RXXG Configuration 1
159 * Bit 15 RXXG_RXEN 831 * Bit 15 RXXG_RXEN
160 * Bit 14 RXXG_ROCF 832 * Bit 14 RXXG_ROCF
@@ -168,11 +840,84 @@
168 * Bit 2-0 RXXG_MIFG 840 * Bit 2-0 RXXG_MIFG
169 *----------------------------------------------------------------------------*/ 841 *----------------------------------------------------------------------------*/
170#define SUNI1x10GEXP_BITMSK_RXXG_RXEN 0x8000 842#define SUNI1x10GEXP_BITMSK_RXXG_RXEN 0x8000
843#define SUNI1x10GEXP_BITMSK_RXXG_ROCF 0x4000
844#define SUNI1x10GEXP_BITMSK_RXXG_PAD_STRIP 0x2000
171#define SUNI1x10GEXP_BITMSK_RXXG_PUREP 0x0400 845#define SUNI1x10GEXP_BITMSK_RXXG_PUREP 0x0400
846#define SUNI1x10GEXP_BITMSK_RXXG_LONGP 0x0200
847#define SUNI1x10GEXP_BITMSK_RXXG_PARF 0x0100
172#define SUNI1x10GEXP_BITMSK_RXXG_FLCHK 0x0080 848#define SUNI1x10GEXP_BITMSK_RXXG_FLCHK 0x0080
849#define SUNI1x10GEXP_BITMSK_RXXG_PASS_CTRL 0x0020
173#define SUNI1x10GEXP_BITMSK_RXXG_CRC_STRIP 0x0008 850#define SUNI1x10GEXP_BITMSK_RXXG_CRC_STRIP 0x0008
174 851
175/*---------------------------------------------------------------------------- 852/*----------------------------------------------------------------------------
853 * Register 0x02041: RXXG Configuration 2
854 * Bit 7-0 RXXG_HDRSIZE
855 *----------------------------------------------------------------------------*/
856#define SUNI1x10GEXP_BITMSK_RXXG_HDRSIZE 0x00FF
857
858/*----------------------------------------------------------------------------
859 * Register 0x2042: RXXG Configuration 3
860 * Bit 15 RXXG_MIN_LERRE
861 * Bit 14 RXXG_MAX_LERRE
862 * Bit 12 RXXG_LINE_ERRE
863 * Bit 10 RXXG_RX_OVRE
864 * Bit 9 RXXG_ADR_FILTERE
865 * Bit 8 RXXG_ERR_FILTERE
866 * Bit 5 RXXG_PRMB_ERRE
867 *----------------------------------------------------------------------------*/
868#define SUNI1x10GEXP_BITMSK_RXXG_MIN_LERRE 0x8000
869#define SUNI1x10GEXP_BITMSK_RXXG_MAX_LERRE 0x4000
870#define SUNI1x10GEXP_BITMSK_RXXG_LINE_ERRE 0x1000
871#define SUNI1x10GEXP_BITMSK_RXXG_RX_OVRE 0x0400
872#define SUNI1x10GEXP_BITMSK_RXXG_ADR_FILTERE 0x0200
873#define SUNI1x10GEXP_BITMSK_RXXG_ERR_FILTERRE 0x0100
874#define SUNI1x10GEXP_BITMSK_RXXG_PRMB_ERRE 0x0020
875
876/*----------------------------------------------------------------------------
877 * Register 0x2043: RXXG Interrupt
878 * Bit 15 RXXG_MIN_LERRI
879 * Bit 14 RXXG_MAX_LERRI
880 * Bit 12 RXXG_LINE_ERRI
881 * Bit 10 RXXG_RX_OVRI
882 * Bit 9 RXXG_ADR_FILTERI
883 * Bit 8 RXXG_ERR_FILTERI
884 * Bit 5 RXXG_PRMB_ERRE
885 *----------------------------------------------------------------------------*/
886#define SUNI1x10GEXP_BITMSK_RXXG_MIN_LERRI 0x8000
887#define SUNI1x10GEXP_BITMSK_RXXG_MAX_LERRI 0x4000
888#define SUNI1x10GEXP_BITMSK_RXXG_LINE_ERRI 0x1000
889#define SUNI1x10GEXP_BITMSK_RXXG_RX_OVRI 0x0400
890#define SUNI1x10GEXP_BITMSK_RXXG_ADR_FILTERI 0x0200
891#define SUNI1x10GEXP_BITMSK_RXXG_ERR_FILTERI 0x0100
892#define SUNI1x10GEXP_BITMSK_RXXG_PRMB_ERRE 0x0020
893
894/*----------------------------------------------------------------------------
895 * Register 0x2049: RXXG Receive FIFO Threshold
896 * Bit 2-0 RXXG_CUT_THRU
897 *----------------------------------------------------------------------------*/
898#define SUNI1x10GEXP_BITMSK_RXXG_CUT_THRU 0x0007
899#define SUNI1x10GEXP_BITOFF_RXXG_CUT_THRU 0
900
901/*----------------------------------------------------------------------------
902 * Register 0x2062H - 0x2069: RXXG Exact Match VID
903 * Bit 11-0 RXXG_VID_MATCH
904 *----------------------------------------------------------------------------*/
905#define SUNI1x10GEXP_BITMSK_RXXG_VID_MATCH 0x0FFF
906#define SUNI1x10GEXP_BITOFF_RXXG_VID_MATCH 0
907
908/*----------------------------------------------------------------------------
909 * Register 0x206EH - 0x206F: RXXG Address Filter Control
910 * Bit 3 RXXG_FORWARD_ENABLE
911 * Bit 2 RXXG_VLAN_ENABLE
912 * Bit 1 RXXG_SRC_ADDR
913 * Bit 0 RXXG_MATCH_ENABLE
914 *----------------------------------------------------------------------------*/
915#define SUNI1x10GEXP_BITMSK_RXXG_FORWARD_ENABLE 0x0008
916#define SUNI1x10GEXP_BITMSK_RXXG_VLAN_ENABLE 0x0004
917#define SUNI1x10GEXP_BITMSK_RXXG_SRC_ADDR 0x0002
918#define SUNI1x10GEXP_BITMSK_RXXG_MATCH_ENABLE 0x0001
919
920/*----------------------------------------------------------------------------
176 * Register 0x2070: RXXG Address Filter Control 2 921 * Register 0x2070: RXXG Address Filter Control 2
177 * Bit 1 RXXG_PMODE 922 * Bit 1 RXXG_PMODE
178 * Bit 0 RXXG_MHASH_EN 923 * Bit 0 RXXG_MHASH_EN
@@ -181,15 +926,446 @@
181#define SUNI1x10GEXP_BITMSK_RXXG_MHASH_EN 0x0001 926#define SUNI1x10GEXP_BITMSK_RXXG_MHASH_EN 0x0001
182 927
183/*---------------------------------------------------------------------------- 928/*----------------------------------------------------------------------------
929 * Register 0x2081: XRF Control Register 2
930 * Bit 6 EN_PKT_GEN
931 * Bit 4-2 PATT
932 *----------------------------------------------------------------------------*/
933#define SUNI1x10GEXP_BITMSK_EN_PKT_GEN 0x0040
934#define SUNI1x10GEXP_BITMSK_PATT 0x001C
935#define SUNI1x10GEXP_BITOFF_PATT 2
936
937/*----------------------------------------------------------------------------
938 * Register 0x2088: XRF Interrupt Enable
939 * Bit 12-9 LANE_HICERE
940 * Bit 8-5 HS_SD_LANEE
941 * Bit 4 ALIGN_STATUS_ERRE
942 * Bit 3-0 LANE_SYNC_STAT_ERRE
943 *----------------------------------------------------------------------------*/
944#define SUNI1x10GEXP_BITMSK_LANE_HICERE 0x1E00
945#define SUNI1x10GEXP_BITOFF_LANE_HICERE 9
946#define SUNI1x10GEXP_BITMSK_HS_SD_LANEE 0x01E0
947#define SUNI1x10GEXP_BITOFF_HS_SD_LANEE 5
948#define SUNI1x10GEXP_BITMSK_ALIGN_STATUS_ERRE 0x0010
949#define SUNI1x10GEXP_BITMSK_LANE_SYNC_STAT_ERRE 0x000F
950#define SUNI1x10GEXP_BITOFF_LANE_SYNC_STAT_ERRE 0
951
952/*----------------------------------------------------------------------------
953 * Register 0x2089: XRF Interrupt Status
954 * Bit 12-9 LANE_HICERI
955 * Bit 8-5 HS_SD_LANEI
956 * Bit 4 ALIGN_STATUS_ERRI
957 * Bit 3-0 LANE_SYNC_STAT_ERRI
958 *----------------------------------------------------------------------------*/
959#define SUNI1x10GEXP_BITMSK_LANE_HICERI 0x1E00
960#define SUNI1x10GEXP_BITOFF_LANE_HICERI 9
961#define SUNI1x10GEXP_BITMSK_HS_SD_LANEI 0x01E0
962#define SUNI1x10GEXP_BITOFF_HS_SD_LANEI 5
963#define SUNI1x10GEXP_BITMSK_ALIGN_STATUS_ERRI 0x0010
964#define SUNI1x10GEXP_BITMSK_LANE_SYNC_STAT_ERRI 0x000F
965#define SUNI1x10GEXP_BITOFF_LANE_SYNC_STAT_ERRI 0
966
967/*----------------------------------------------------------------------------
968 * Register 0x208A: XRF Error Status
969 * Bit 8-5 HS_SD_LANE
970 * Bit 4 ALIGN_STATUS_ERR
971 * Bit 3-0 LANE_SYNC_STAT_ERR
972 *----------------------------------------------------------------------------*/
973#define SUNI1x10GEXP_BITMSK_HS_SD_LANE3 0x0100
974#define SUNI1x10GEXP_BITMSK_HS_SD_LANE2 0x0080
975#define SUNI1x10GEXP_BITMSK_HS_SD_LANE1 0x0040
976#define SUNI1x10GEXP_BITMSK_HS_SD_LANE0 0x0020
977#define SUNI1x10GEXP_BITMSK_ALIGN_STATUS_ERR 0x0010
978#define SUNI1x10GEXP_BITMSK_LANE3_SYNC_STAT_ERR 0x0008
979#define SUNI1x10GEXP_BITMSK_LANE2_SYNC_STAT_ERR 0x0004
980#define SUNI1x10GEXP_BITMSK_LANE1_SYNC_STAT_ERR 0x0002
981#define SUNI1x10GEXP_BITMSK_LANE0_SYNC_STAT_ERR 0x0001
982
983/*----------------------------------------------------------------------------
984 * Register 0x208B: XRF Diagnostic Interrupt Enable
985 * Bit 7-4 LANE_OVERRUNE
986 * Bit 3-0 LANE_UNDERRUNE
987 *----------------------------------------------------------------------------*/
988#define SUNI1x10GEXP_BITMSK_LANE_OVERRUNE 0x00F0
989#define SUNI1x10GEXP_BITOFF_LANE_OVERRUNE 4
990#define SUNI1x10GEXP_BITMSK_LANE_UNDERRUNE 0x000F
991#define SUNI1x10GEXP_BITOFF_LANE_UNDERRUNE 0
992
993/*----------------------------------------------------------------------------
994 * Register 0x208C: XRF Diagnostic Interrupt Status
995 * Bit 7-4 LANE_OVERRUNI
996 * Bit 3-0 LANE_UNDERRUNI
997 *----------------------------------------------------------------------------*/
998#define SUNI1x10GEXP_BITMSK_LANE_OVERRUNI 0x00F0
999#define SUNI1x10GEXP_BITOFF_LANE_OVERRUNI 4
1000#define SUNI1x10GEXP_BITMSK_LANE_UNDERRUNI 0x000F
1001#define SUNI1x10GEXP_BITOFF_LANE_UNDERRUNI 0
1002
1003/*----------------------------------------------------------------------------
1004 * Register 0x20C0: RXOAM Configuration
1005 * Bit 15 RXOAM_BUSY
1006 * Bit 14-12 RXOAM_F2_SEL
1007 * Bit 10-8 RXOAM_F1_SEL
1008 * Bit 7-6 RXOAM_FILTER_CTRL
1009 * Bit 5-0 RXOAM_PX_EN
1010 *----------------------------------------------------------------------------*/
1011#define SUNI1x10GEXP_BITMSK_RXOAM_BUSY 0x8000
1012#define SUNI1x10GEXP_BITMSK_RXOAM_F2_SEL 0x7000
1013#define SUNI1x10GEXP_BITOFF_RXOAM_F2_SEL 12
1014#define SUNI1x10GEXP_BITMSK_RXOAM_F1_SEL 0x0700
1015#define SUNI1x10GEXP_BITOFF_RXOAM_F1_SEL 8
1016#define SUNI1x10GEXP_BITMSK_RXOAM_FILTER_CTRL 0x00C0
1017#define SUNI1x10GEXP_BITOFF_RXOAM_FILTER_CTRL 6
1018#define SUNI1x10GEXP_BITMSK_RXOAM_PX_EN 0x003F
1019#define SUNI1x10GEXP_BITOFF_RXOAM_PX_EN 0
1020
1021/*----------------------------------------------------------------------------
1022 * Register 0x20C1,0x20C2: RXOAM Filter Configuration
1023 * Bit 15-8 RXOAM_FX_MASK
1024 * Bit 7-0 RXOAM_FX_VAL
1025 *----------------------------------------------------------------------------*/
1026#define SUNI1x10GEXP_BITMSK_RXOAM_FX_MASK 0xFF00
1027#define SUNI1x10GEXP_BITOFF_RXOAM_FX_MASK 8
1028#define SUNI1x10GEXP_BITMSK_RXOAM_FX_VAL 0x00FF
1029#define SUNI1x10GEXP_BITOFF_RXOAM_FX_VAl 0
1030
1031/*----------------------------------------------------------------------------
1032 * Register 0x20C3: RXOAM Configuration Register 2
1033 * Bit 13 RXOAM_REC_BYTE_VAL
1034 * Bit 11-10 RXOAM_BYPASS_MODE
1035 * Bit 5-0 RXOAM_PX_CLEAR
1036 *----------------------------------------------------------------------------*/
1037#define SUNI1x10GEXP_BITMSK_RXOAM_REC_BYTE_VAL 0x2000
1038#define SUNI1x10GEXP_BITMSK_RXOAM_BYPASS_MODE 0x0C00
1039#define SUNI1x10GEXP_BITOFF_RXOAM_BYPASS_MODE 10
1040#define SUNI1x10GEXP_BITMSK_RXOAM_PX_CLEAR 0x003F
1041#define SUNI1x10GEXP_BITOFF_RXOAM_PX_CLEAR 0
1042
1043/*----------------------------------------------------------------------------
1044 * Register 0x20C4: RXOAM HEC Configuration
1045 * Bit 15-8 RXOAM_COSET
1046 * Bit 2 RXOAM_HEC_ERR_PKT
1047 * Bit 0 RXOAM_HEC_EN
1048 *----------------------------------------------------------------------------*/
1049#define SUNI1x10GEXP_BITMSK_RXOAM_COSET 0xFF00
1050#define SUNI1x10GEXP_BITOFF_RXOAM_COSET 8
1051#define SUNI1x10GEXP_BITMSK_RXOAM_HEC_ERR_PKT 0x0004
1052#define SUNI1x10GEXP_BITMSK_RXOAM_HEC_EN 0x0001
1053
1054/*----------------------------------------------------------------------------
1055 * Register 0x20C7: RXOAM Interrupt Enable
1056 * Bit 10 RXOAM_FILTER_THRSHE
1057 * Bit 9 RXOAM_OAM_ERRE
1058 * Bit 8 RXOAM_HECE_THRSHE
1059 * Bit 7 RXOAM_SOPE
1060 * Bit 6 RXOAM_RFE
1061 * Bit 5 RXOAM_LFE
1062 * Bit 4 RXOAM_DV_ERRE
1063 * Bit 3 RXOAM_DATA_INVALIDE
1064 * Bit 2 RXOAM_FILTER_DROPE
1065 * Bit 1 RXOAM_HECE
1066 * Bit 0 RXOAM_OFLE
1067 *----------------------------------------------------------------------------*/
1068#define SUNI1x10GEXP_BITMSK_RXOAM_FILTER_THRSHE 0x0400
1069#define SUNI1x10GEXP_BITMSK_RXOAM_OAM_ERRE 0x0200
1070#define SUNI1x10GEXP_BITMSK_RXOAM_HECE_THRSHE 0x0100
1071#define SUNI1x10GEXP_BITMSK_RXOAM_SOPE 0x0080
1072#define SUNI1x10GEXP_BITMSK_RXOAM_RFE 0x0040
1073#define SUNI1x10GEXP_BITMSK_RXOAM_LFE 0x0020
1074#define SUNI1x10GEXP_BITMSK_RXOAM_DV_ERRE 0x0010
1075#define SUNI1x10GEXP_BITMSK_RXOAM_DATA_INVALIDE 0x0008
1076#define SUNI1x10GEXP_BITMSK_RXOAM_FILTER_DROPE 0x0004
1077#define SUNI1x10GEXP_BITMSK_RXOAM_HECE 0x0002
1078#define SUNI1x10GEXP_BITMSK_RXOAM_OFLE 0x0001
1079
1080/*----------------------------------------------------------------------------
1081 * Register 0x20C8: RXOAM Interrupt Status
1082 * Bit 10 RXOAM_FILTER_THRSHI
1083 * Bit 9 RXOAM_OAM_ERRI
1084 * Bit 8 RXOAM_HECE_THRSHI
1085 * Bit 7 RXOAM_SOPI
1086 * Bit 6 RXOAM_RFI
1087 * Bit 5 RXOAM_LFI
1088 * Bit 4 RXOAM_DV_ERRI
1089 * Bit 3 RXOAM_DATA_INVALIDI
1090 * Bit 2 RXOAM_FILTER_DROPI
1091 * Bit 1 RXOAM_HECI
1092 * Bit 0 RXOAM_OFLI
1093 *----------------------------------------------------------------------------*/
1094#define SUNI1x10GEXP_BITMSK_RXOAM_FILTER_THRSHI 0x0400
1095#define SUNI1x10GEXP_BITMSK_RXOAM_OAM_ERRI 0x0200
1096#define SUNI1x10GEXP_BITMSK_RXOAM_HECE_THRSHI 0x0100
1097#define SUNI1x10GEXP_BITMSK_RXOAM_SOPI 0x0080
1098#define SUNI1x10GEXP_BITMSK_RXOAM_RFI 0x0040
1099#define SUNI1x10GEXP_BITMSK_RXOAM_LFI 0x0020
1100#define SUNI1x10GEXP_BITMSK_RXOAM_DV_ERRI 0x0010
1101#define SUNI1x10GEXP_BITMSK_RXOAM_DATA_INVALIDI 0x0008
1102#define SUNI1x10GEXP_BITMSK_RXOAM_FILTER_DROPI 0x0004
1103#define SUNI1x10GEXP_BITMSK_RXOAM_HECI 0x0002
1104#define SUNI1x10GEXP_BITMSK_RXOAM_OFLI 0x0001
1105
1106/*----------------------------------------------------------------------------
1107 * Register 0x20C9: RXOAM Status
1108 * Bit 10 RXOAM_FILTER_THRSHV
1109 * Bit 8 RXOAM_HECE_THRSHV
1110 * Bit 6 RXOAM_RFV
1111 * Bit 5 RXOAM_LFV
1112 *----------------------------------------------------------------------------*/
1113#define SUNI1x10GEXP_BITMSK_RXOAM_FILTER_THRSHV 0x0400
1114#define SUNI1x10GEXP_BITMSK_RXOAM_HECE_THRSHV 0x0100
1115#define SUNI1x10GEXP_BITMSK_RXOAM_RFV 0x0040
1116#define SUNI1x10GEXP_BITMSK_RXOAM_LFV 0x0020
1117
1118/*----------------------------------------------------------------------------
184 * Register 0x2100: MSTAT Control 1119 * Register 0x2100: MSTAT Control
185 * Bit 2 MSTAT_WRITE 1120 * Bit 2 MSTAT_WRITE
186 * Bit 1 MSTAT_CLEAR 1121 * Bit 1 MSTAT_CLEAR
187 * Bit 0 MSTAT_SNAP 1122 * Bit 0 MSTAT_SNAP
188 *----------------------------------------------------------------------------*/ 1123 *----------------------------------------------------------------------------*/
1124#define SUNI1x10GEXP_BITMSK_MSTAT_WRITE 0x0004
189#define SUNI1x10GEXP_BITMSK_MSTAT_CLEAR 0x0002 1125#define SUNI1x10GEXP_BITMSK_MSTAT_CLEAR 0x0002
190#define SUNI1x10GEXP_BITMSK_MSTAT_SNAP 0x0001 1126#define SUNI1x10GEXP_BITMSK_MSTAT_SNAP 0x0001
191 1127
192/*---------------------------------------------------------------------------- 1128/*----------------------------------------------------------------------------
1129 * Register 0x2109: MSTAT Counter Write Address
1130 * Bit 5-0 MSTAT_WRITE_ADDRESS
1131 *----------------------------------------------------------------------------*/
1132#define SUNI1x10GEXP_BITMSK_MSTAT_WRITE_ADDRESS 0x003F
1133#define SUNI1x10GEXP_BITOFF_MSTAT_WRITE_ADDRESS 0
1134
1135/*----------------------------------------------------------------------------
1136 * Register 0x2200: IFLX Global Configuration Register
1137 * Bit 15 IFLX_IRCU_ENABLE
1138 * Bit 14 IFLX_IDSWT_ENABLE
1139 * Bit 13-0 IFLX_IFD_CNT
1140 *----------------------------------------------------------------------------*/
1141#define SUNI1x10GEXP_BITMSK_IFLX_IRCU_ENABLE 0x8000
1142#define SUNI1x10GEXP_BITMSK_IFLX_IDSWT_ENABLE 0x4000
1143#define SUNI1x10GEXP_BITMSK_IFLX_IFD_CNT 0x3FFF
1144#define SUNI1x10GEXP_BITOFF_IFLX_IFD_CNT 0
1145
1146/*----------------------------------------------------------------------------
1147 * Register 0x2209: IFLX FIFO Overflow Enable
1148 * Bit 0 IFLX_OVFE
1149 *----------------------------------------------------------------------------*/
1150#define SUNI1x10GEXP_BITMSK_IFLX_OVFE 0x0001
1151
1152/*----------------------------------------------------------------------------
1153 * Register 0x220A: IFLX FIFO Overflow Interrupt
1154 * Bit 0 IFLX_OVFI
1155 *----------------------------------------------------------------------------*/
1156#define SUNI1x10GEXP_BITMSK_IFLX_OVFI 0x0001
1157
1158/*----------------------------------------------------------------------------
1159 * Register 0x220D: IFLX Indirect Channel Address
1160 * Bit 15 IFLX_BUSY
1161 * Bit 14 IFLX_RWB
1162 *----------------------------------------------------------------------------*/
1163#define SUNI1x10GEXP_BITMSK_IFLX_BUSY 0x8000
1164#define SUNI1x10GEXP_BITMSK_IFLX_RWB 0x4000
1165
1166/*----------------------------------------------------------------------------
1167 * Register 0x220E: IFLX Indirect Logical FIFO Low Limit & Provision
1168 * Bit 9-0 IFLX_LOLIM
1169 *----------------------------------------------------------------------------*/
1170#define SUNI1x10GEXP_BITMSK_IFLX_LOLIM 0x03FF
1171#define SUNI1x10GEXP_BITOFF_IFLX_LOLIM 0
1172
1173/*----------------------------------------------------------------------------
1174 * Register 0x220F: IFLX Indirect Logical FIFO High Limit
1175 * Bit 9-0 IFLX_HILIM
1176 *----------------------------------------------------------------------------*/
1177#define SUNI1x10GEXP_BITMSK_IFLX_HILIM 0x03FF
1178#define SUNI1x10GEXP_BITOFF_IFLX_HILIM 0
1179
1180/*----------------------------------------------------------------------------
1181 * Register 0x2210: IFLX Indirect Full/Almost Full Status & Limit
1182 * Bit 15 IFLX_FULL
1183 * Bit 14 IFLX_AFULL
1184 * Bit 13-0 IFLX_AFTH
1185 *----------------------------------------------------------------------------*/
1186#define SUNI1x10GEXP_BITMSK_IFLX_FULL 0x8000
1187#define SUNI1x10GEXP_BITMSK_IFLX_AFULL 0x4000
1188#define SUNI1x10GEXP_BITMSK_IFLX_AFTH 0x3FFF
1189#define SUNI1x10GEXP_BITOFF_IFLX_AFTH 0
1190
1191/*----------------------------------------------------------------------------
1192 * Register 0x2211: IFLX Indirect Empty/Almost Empty Status & Limit
1193 * Bit 15 IFLX_EMPTY
1194 * Bit 14 IFLX_AEMPTY
1195 * Bit 13-0 IFLX_AETH
1196 *----------------------------------------------------------------------------*/
1197#define SUNI1x10GEXP_BITMSK_IFLX_EMPTY 0x8000
1198#define SUNI1x10GEXP_BITMSK_IFLX_AEMPTY 0x4000
1199#define SUNI1x10GEXP_BITMSK_IFLX_AETH 0x3FFF
1200#define SUNI1x10GEXP_BITOFF_IFLX_AETH 0
1201
1202/*----------------------------------------------------------------------------
1203 * Register 0x2240: PL4MOS Configuration Register
1204 * Bit 3 PL4MOS_RE_INIT
1205 * Bit 2 PL4MOS_EN
1206 * Bit 1 PL4MOS_NO_STATUS
1207 *----------------------------------------------------------------------------*/
1208#define SUNI1x10GEXP_BITMSK_PL4MOS_RE_INIT 0x0008
1209#define SUNI1x10GEXP_BITMSK_PL4MOS_EN 0x0004
1210#define SUNI1x10GEXP_BITMSK_PL4MOS_NO_STATUS 0x0002
1211
1212/*----------------------------------------------------------------------------
1213 * Register 0x2243: PL4MOS MaxBurst1 Register
1214 * Bit 11-0 PL4MOS_MAX_BURST1
1215 *----------------------------------------------------------------------------*/
1216#define SUNI1x10GEXP_BITMSK_PL4MOS_MAX_BURST1 0x0FFF
1217#define SUNI1x10GEXP_BITOFF_PL4MOS_MAX_BURST1 0
1218
1219/*----------------------------------------------------------------------------
1220 * Register 0x2244: PL4MOS MaxBurst2 Register
1221 * Bit 11-0 PL4MOS_MAX_BURST2
1222 *----------------------------------------------------------------------------*/
1223#define SUNI1x10GEXP_BITMSK_PL4MOS_MAX_BURST2 0x0FFF
1224#define SUNI1x10GEXP_BITOFF_PL4MOS_MAX_BURST2 0
1225
1226/*----------------------------------------------------------------------------
1227 * Register 0x2245: PL4MOS Transfer Size Register
1228 * Bit 7-0 PL4MOS_MAX_TRANSFER
1229 *----------------------------------------------------------------------------*/
1230#define SUNI1x10GEXP_BITMSK_PL4MOS_MAX_TRANSFER 0x00FF
1231#define SUNI1x10GEXP_BITOFF_PL4MOS_MAX_TRANSFER 0
1232
1233/*----------------------------------------------------------------------------
1234 * Register 0x2280: PL4ODP Configuration
1235 * Bit 15-12 PL4ODP_REPEAT_T
1236 * Bit 8 PL4ODP_SOP_RULE
1237 * Bit 1 PL4ODP_EN_PORTS
1238 * Bit 0 PL4ODP_EN_DFWD
1239 *----------------------------------------------------------------------------*/
1240#define SUNI1x10GEXP_BITMSK_PL4ODP_REPEAT_T 0xF000
1241#define SUNI1x10GEXP_BITOFF_PL4ODP_REPEAT_T 12
1242#define SUNI1x10GEXP_BITMSK_PL4ODP_SOP_RULE 0x0100
1243#define SUNI1x10GEXP_BITMSK_PL4ODP_EN_PORTS 0x0002
1244#define SUNI1x10GEXP_BITMSK_PL4ODP_EN_DFWD 0x0001
1245
1246/*----------------------------------------------------------------------------
1247 * Register 0x2282: PL4ODP Interrupt Mask
1248 * Bit 0 PL4ODP_OUT_DISE
1249 *----------------------------------------------------------------------------*/
1250#define SUNI1x10GEXP_BITMSK_PL4ODP_OUT_DISE 0x0001
1251
1252
1253
1254#define SUNI1x10GEXP_BITMSK_PL4ODP_PPE_EOPEOBE 0x0080
1255#define SUNI1x10GEXP_BITMSK_PL4ODP_PPE_ERREOPE 0x0040
1256#define SUNI1x10GEXP_BITMSK_PL4ODP_PPE_MEOPE 0x0008
1257#define SUNI1x10GEXP_BITMSK_PL4ODP_PPE_MSOPE 0x0004
1258#define SUNI1x10GEXP_BITMSK_PL4ODP_ES_OVRE 0x0002
1259
1260
1261/*----------------------------------------------------------------------------
1262 * Register 0x2283: PL4ODP Interrupt
1263 * Bit 0 PL4ODP_OUT_DISI
1264 *----------------------------------------------------------------------------*/
1265#define SUNI1x10GEXP_BITMSK_PL4ODP_OUT_DISI 0x0001
1266
1267
1268
1269#define SUNI1x10GEXP_BITMSK_PL4ODP_PPE_EOPEOBI 0x0080
1270#define SUNI1x10GEXP_BITMSK_PL4ODP_PPE_ERREOPI 0x0040
1271#define SUNI1x10GEXP_BITMSK_PL4ODP_PPE_MEOPI 0x0008
1272#define SUNI1x10GEXP_BITMSK_PL4ODP_PPE_MSOPI 0x0004
1273#define SUNI1x10GEXP_BITMSK_PL4ODP_ES_OVRI 0x0002
1274
1275/*----------------------------------------------------------------------------
1276 * Register 0x2300: PL4IO Lock Detect Status
1277 * Bit 15 PL4IO_OUT_ROOLV
1278 * Bit 12 PL4IO_IS_ROOLV
1279 * Bit 11 PL4IO_DIP2_ERRV
1280 * Bit 8 PL4IO_ID_ROOLV
1281 * Bit 4 PL4IO_IS_DOOLV
1282 * Bit 0 PL4IO_ID_DOOLV
1283 *----------------------------------------------------------------------------*/
1284#define SUNI1x10GEXP_BITMSK_PL4IO_OUT_ROOLV 0x8000
1285#define SUNI1x10GEXP_BITMSK_PL4IO_IS_ROOLV 0x1000
1286#define SUNI1x10GEXP_BITMSK_PL4IO_DIP2_ERRV 0x0800
1287#define SUNI1x10GEXP_BITMSK_PL4IO_ID_ROOLV 0x0100
1288#define SUNI1x10GEXP_BITMSK_PL4IO_IS_DOOLV 0x0010
1289#define SUNI1x10GEXP_BITMSK_PL4IO_ID_DOOLV 0x0001
1290
1291/*----------------------------------------------------------------------------
1292 * Register 0x2301: PL4IO Lock Detect Change
1293 * Bit 15 PL4IO_OUT_ROOLI
1294 * Bit 12 PL4IO_IS_ROOLI
1295 * Bit 11 PL4IO_DIP2_ERRI
1296 * Bit 8 PL4IO_ID_ROOLI
1297 * Bit 4 PL4IO_IS_DOOLI
1298 * Bit 0 PL4IO_ID_DOOLI
1299 *----------------------------------------------------------------------------*/
1300#define SUNI1x10GEXP_BITMSK_PL4IO_OUT_ROOLI 0x8000
1301#define SUNI1x10GEXP_BITMSK_PL4IO_IS_ROOLI 0x1000
1302#define SUNI1x10GEXP_BITMSK_PL4IO_DIP2_ERRI 0x0800
1303#define SUNI1x10GEXP_BITMSK_PL4IO_ID_ROOLI 0x0100
1304#define SUNI1x10GEXP_BITMSK_PL4IO_IS_DOOLI 0x0010
1305#define SUNI1x10GEXP_BITMSK_PL4IO_ID_DOOLI 0x0001
1306
1307/*----------------------------------------------------------------------------
1308 * Register 0x2302: PL4IO Lock Detect Mask
1309 * Bit 15 PL4IO_OUT_ROOLE
1310 * Bit 12 PL4IO_IS_ROOLE
1311 * Bit 11 PL4IO_DIP2_ERRE
1312 * Bit 8 PL4IO_ID_ROOLE
1313 * Bit 4 PL4IO_IS_DOOLE
1314 * Bit 0 PL4IO_ID_DOOLE
1315 *----------------------------------------------------------------------------*/
1316#define SUNI1x10GEXP_BITMSK_PL4IO_OUT_ROOLE 0x8000
1317#define SUNI1x10GEXP_BITMSK_PL4IO_IS_ROOLE 0x1000
1318#define SUNI1x10GEXP_BITMSK_PL4IO_DIP2_ERRE 0x0800
1319#define SUNI1x10GEXP_BITMSK_PL4IO_ID_ROOLE 0x0100
1320#define SUNI1x10GEXP_BITMSK_PL4IO_IS_DOOLE 0x0010
1321#define SUNI1x10GEXP_BITMSK_PL4IO_ID_DOOLE 0x0001
1322
1323/*----------------------------------------------------------------------------
1324 * Register 0x2303: PL4IO Lock Detect Limits
1325 * Bit 15-8 PL4IO_REF_LIMIT
1326 * Bit 7-0 PL4IO_TRAN_LIMIT
1327 *----------------------------------------------------------------------------*/
1328#define SUNI1x10GEXP_BITMSK_PL4IO_REF_LIMIT 0xFF00
1329#define SUNI1x10GEXP_BITOFF_PL4IO_REF_LIMIT 8
1330#define SUNI1x10GEXP_BITMSK_PL4IO_TRAN_LIMIT 0x00FF
1331#define SUNI1x10GEXP_BITOFF_PL4IO_TRAN_LIMIT 0
1332
1333/*----------------------------------------------------------------------------
1334 * Register 0x2304: PL4IO Calendar Repetitions
1335 * Bit 15-8 PL4IO_IN_MUL
1336 * Bit 7-0 PL4IO_OUT_MUL
1337 *----------------------------------------------------------------------------*/
1338#define SUNI1x10GEXP_BITMSK_PL4IO_IN_MUL 0xFF00
1339#define SUNI1x10GEXP_BITOFF_PL4IO_IN_MUL 8
1340#define SUNI1x10GEXP_BITMSK_PL4IO_OUT_MUL 0x00FF
1341#define SUNI1x10GEXP_BITOFF_PL4IO_OUT_MUL 0
1342
1343/*----------------------------------------------------------------------------
1344 * Register 0x2305: PL4IO Configuration
1345 * Bit 15 PL4IO_DIP2_ERR_CHK
1346 * Bit 11 PL4IO_ODAT_DIS
1347 * Bit 10 PL4IO_TRAIN_DIS
1348 * Bit 9 PL4IO_OSTAT_DIS
1349 * Bit 8 PL4IO_ISTAT_DIS
1350 * Bit 7 PL4IO_NO_ISTAT
1351 * Bit 6 PL4IO_STAT_OUTSEL
1352 * Bit 5 PL4IO_INSEL
1353 * Bit 4 PL4IO_DLSEL
1354 * Bit 1-0 PL4IO_OUTSEL
1355 *----------------------------------------------------------------------------*/
1356#define SUNI1x10GEXP_BITMSK_PL4IO_DIP2_ERR_CHK 0x8000
1357#define SUNI1x10GEXP_BITMSK_PL4IO_ODAT_DIS 0x0800
1358#define SUNI1x10GEXP_BITMSK_PL4IO_TRAIN_DIS 0x0400
1359#define SUNI1x10GEXP_BITMSK_PL4IO_OSTAT_DIS 0x0200
1360#define SUNI1x10GEXP_BITMSK_PL4IO_ISTAT_DIS 0x0100
1361#define SUNI1x10GEXP_BITMSK_PL4IO_NO_ISTAT 0x0080
1362#define SUNI1x10GEXP_BITMSK_PL4IO_STAT_OUTSEL 0x0040
1363#define SUNI1x10GEXP_BITMSK_PL4IO_INSEL 0x0020
1364#define SUNI1x10GEXP_BITMSK_PL4IO_DLSEL 0x0010
1365#define SUNI1x10GEXP_BITMSK_PL4IO_OUTSEL 0x0003
1366#define SUNI1x10GEXP_BITOFF_PL4IO_OUTSEL 0
1367
1368/*----------------------------------------------------------------------------
193 * Register 0x3040: TXXG Configuration Register 1 1369 * Register 0x3040: TXXG Configuration Register 1
194 * Bit 15 TXXG_TXEN0 1370 * Bit 15 TXXG_TXEN0
195 * Bit 13 TXXG_HOSTPAUSE 1371 * Bit 13 TXXG_HOSTPAUSE
@@ -202,12 +1378,266 @@
202 * Bit 0 TXXG_SPRE 1378 * Bit 0 TXXG_SPRE
203 *----------------------------------------------------------------------------*/ 1379 *----------------------------------------------------------------------------*/
204#define SUNI1x10GEXP_BITMSK_TXXG_TXEN0 0x8000 1380#define SUNI1x10GEXP_BITMSK_TXXG_TXEN0 0x8000
1381#define SUNI1x10GEXP_BITMSK_TXXG_HOSTPAUSE 0x2000
1382#define SUNI1x10GEXP_BITMSK_TXXG_IPGT 0x1F80
205#define SUNI1x10GEXP_BITOFF_TXXG_IPGT 7 1383#define SUNI1x10GEXP_BITOFF_TXXG_IPGT 7
206#define SUNI1x10GEXP_BITMSK_TXXG_32BIT_ALIGN 0x0020 1384#define SUNI1x10GEXP_BITMSK_TXXG_32BIT_ALIGN 0x0020
207#define SUNI1x10GEXP_BITMSK_TXXG_CRCEN 0x0010 1385#define SUNI1x10GEXP_BITMSK_TXXG_CRCEN 0x0010
208#define SUNI1x10GEXP_BITMSK_TXXG_FCTX 0x0008 1386#define SUNI1x10GEXP_BITMSK_TXXG_FCTX 0x0008
209#define SUNI1x10GEXP_BITMSK_TXXG_FCRX 0x0004 1387#define SUNI1x10GEXP_BITMSK_TXXG_FCRX 0x0004
210#define SUNI1x10GEXP_BITMSK_TXXG_PADEN 0x0002 1388#define SUNI1x10GEXP_BITMSK_TXXG_PADEN 0x0002
1389#define SUNI1x10GEXP_BITMSK_TXXG_SPRE 0x0001
1390
1391/*----------------------------------------------------------------------------
1392 * Register 0x3041: TXXG Configuration Register 2
1393 * Bit 7-0 TXXG_HDRSIZE
1394 *----------------------------------------------------------------------------*/
1395#define SUNI1x10GEXP_BITMSK_TXXG_HDRSIZE 0x00FF
1396
1397/*----------------------------------------------------------------------------
1398 * Register 0x3042: TXXG Configuration Register 3
1399 * Bit 15 TXXG_FIFO_ERRE
1400 * Bit 14 TXXG_FIFO_UDRE
1401 * Bit 13 TXXG_MAX_LERRE
1402 * Bit 12 TXXG_MIN_LERRE
1403 * Bit 11 TXXG_XFERE
1404 *----------------------------------------------------------------------------*/
1405#define SUNI1x10GEXP_BITMSK_TXXG_FIFO_ERRE 0x8000
1406#define SUNI1x10GEXP_BITMSK_TXXG_FIFO_UDRE 0x4000
1407#define SUNI1x10GEXP_BITMSK_TXXG_MAX_LERRE 0x2000
1408#define SUNI1x10GEXP_BITMSK_TXXG_MIN_LERRE 0x1000
1409#define SUNI1x10GEXP_BITMSK_TXXG_XFERE 0x0800
1410
1411/*----------------------------------------------------------------------------
1412 * Register 0x3043: TXXG Interrupt
1413 * Bit 15 TXXG_FIFO_ERRI
1414 * Bit 14 TXXG_FIFO_UDRI
1415 * Bit 13 TXXG_MAX_LERRI
1416 * Bit 12 TXXG_MIN_LERRI
1417 * Bit 11 TXXG_XFERI
1418 *----------------------------------------------------------------------------*/
1419#define SUNI1x10GEXP_BITMSK_TXXG_FIFO_ERRI 0x8000
1420#define SUNI1x10GEXP_BITMSK_TXXG_FIFO_UDRI 0x4000
1421#define SUNI1x10GEXP_BITMSK_TXXG_MAX_LERRI 0x2000
1422#define SUNI1x10GEXP_BITMSK_TXXG_MIN_LERRI 0x1000
1423#define SUNI1x10GEXP_BITMSK_TXXG_XFERI 0x0800
1424
1425/*----------------------------------------------------------------------------
1426 * Register 0x3044: TXXG Status Register
1427 * Bit 1 TXXG_TXACTIVE
1428 * Bit 0 TXXG_PAUSED
1429 *----------------------------------------------------------------------------*/
1430#define SUNI1x10GEXP_BITMSK_TXXG_TXACTIVE 0x0002
1431#define SUNI1x10GEXP_BITMSK_TXXG_PAUSED 0x0001
1432
1433/*----------------------------------------------------------------------------
1434 * Register 0x3046: TXXG TX_MINFR - Transmit Min Frame Size Register
1435 * Bit 7-0 TXXG_TX_MINFR
1436 *----------------------------------------------------------------------------*/
1437#define SUNI1x10GEXP_BITMSK_TXXG_TX_MINFR 0x00FF
1438#define SUNI1x10GEXP_BITOFF_TXXG_TX_MINFR 0
1439
1440/*----------------------------------------------------------------------------
1441 * Register 0x3052: TXXG Pause Quantum Value Configuration Register
1442 * Bit 7-0 TXXG_FC_PAUSE_QNTM
1443 *----------------------------------------------------------------------------*/
1444#define SUNI1x10GEXP_BITMSK_TXXG_FC_PAUSE_QNTM 0x00FF
1445#define SUNI1x10GEXP_BITOFF_TXXG_FC_PAUSE_QNTM 0
1446
1447/*----------------------------------------------------------------------------
1448 * Register 0x3080: XTEF Control
1449 * Bit 3-0 XTEF_FORCE_PARITY_ERR
1450 *----------------------------------------------------------------------------*/
1451#define SUNI1x10GEXP_BITMSK_XTEF_FORCE_PARITY_ERR 0x000F
1452#define SUNI1x10GEXP_BITOFF_XTEF_FORCE_PARITY_ERR 0
1453
1454/*----------------------------------------------------------------------------
1455 * Register 0x3084: XTEF Interrupt Event Register
1456 * Bit 0 XTEF_LOST_SYNCI
1457 *----------------------------------------------------------------------------*/
1458#define SUNI1x10GEXP_BITMSK_XTEF_LOST_SYNCI 0x0001
1459
1460/*----------------------------------------------------------------------------
1461 * Register 0x3085: XTEF Interrupt Enable Register
1462 * Bit 0 XTEF_LOST_SYNCE
1463 *----------------------------------------------------------------------------*/
1464#define SUNI1x10GEXP_BITMSK_XTEF_LOST_SYNCE 0x0001
1465
1466/*----------------------------------------------------------------------------
1467 * Register 0x3086: XTEF Visibility Register
1468 * Bit 0 XTEF_LOST_SYNCV
1469 *----------------------------------------------------------------------------*/
1470#define SUNI1x10GEXP_BITMSK_XTEF_LOST_SYNCV 0x0001
1471
1472/*----------------------------------------------------------------------------
1473 * Register 0x30C0: TXOAM OAM Configuration
1474 * Bit 15 TXOAM_HEC_EN
1475 * Bit 14 TXOAM_EMPTYCODE_EN
1476 * Bit 13 TXOAM_FORCE_IDLE
1477 * Bit 12 TXOAM_IGNORE_IDLE
1478 * Bit 11-6 TXOAM_PX_OVERWRITE
1479 * Bit 5-0 TXOAM_PX_SEL
1480 *----------------------------------------------------------------------------*/
1481#define SUNI1x10GEXP_BITMSK_TXOAM_HEC_EN 0x8000
1482#define SUNI1x10GEXP_BITMSK_TXOAM_EMPTYCODE_EN 0x4000
1483#define SUNI1x10GEXP_BITMSK_TXOAM_FORCE_IDLE 0x2000
1484#define SUNI1x10GEXP_BITMSK_TXOAM_IGNORE_IDLE 0x1000
1485#define SUNI1x10GEXP_BITMSK_TXOAM_PX_OVERWRITE 0x0FC0
1486#define SUNI1x10GEXP_BITOFF_TXOAM_PX_OVERWRITE 6
1487#define SUNI1x10GEXP_BITMSK_TXOAM_PX_SEL 0x003F
1488#define SUNI1x10GEXP_BITOFF_TXOAM_PX_SEL 0
1489
1490/*----------------------------------------------------------------------------
1491 * Register 0x30C1: TXOAM Mini-Packet Rate Configuration
1492 * Bit 15 TXOAM_MINIDIS
1493 * Bit 14 TXOAM_BUSY
1494 * Bit 13 TXOAM_TRANS_EN
1495 * Bit 10-0 TXOAM_MINIRATE
1496 *----------------------------------------------------------------------------*/
1497#define SUNI1x10GEXP_BITMSK_TXOAM_MINIDIS 0x8000
1498#define SUNI1x10GEXP_BITMSK_TXOAM_BUSY 0x4000
1499#define SUNI1x10GEXP_BITMSK_TXOAM_TRANS_EN 0x2000
1500#define SUNI1x10GEXP_BITMSK_TXOAM_MINIRATE 0x07FF
1501
1502/*----------------------------------------------------------------------------
1503 * Register 0x30C2: TXOAM Mini-Packet Gap and FIFO Configuration
1504 * Bit 13-10 TXOAM_FTHRESH
1505 * Bit 9-6 TXOAM_MINIPOST
1506 * Bit 5-0 TXOAM_MINIPRE
1507 *----------------------------------------------------------------------------*/
1508#define SUNI1x10GEXP_BITMSK_TXOAM_FTHRESH 0x3C00
1509#define SUNI1x10GEXP_BITOFF_TXOAM_FTHRESH 10
1510#define SUNI1x10GEXP_BITMSK_TXOAM_MINIPOST 0x03C0
1511#define SUNI1x10GEXP_BITOFF_TXOAM_MINIPOST 6
1512#define SUNI1x10GEXP_BITMSK_TXOAM_MINIPRE 0x003F
1513
1514/*----------------------------------------------------------------------------
1515 * Register 0x30C6: TXOAM Interrupt Enable
1516 * Bit 2 TXOAM_SOP_ERRE
1517 * Bit 1 TXOAM_OFLE
1518 * Bit 0 TXOAM_ERRE
1519 *----------------------------------------------------------------------------*/
1520#define SUNI1x10GEXP_BITMSK_TXOAM_SOP_ERRE 0x0004
1521#define SUNI1x10GEXP_BITMSK_TXOAM_OFLE 0x0002
1522#define SUNI1x10GEXP_BITMSK_TXOAM_ERRE 0x0001
1523
1524/*----------------------------------------------------------------------------
1525 * Register 0x30C7: TXOAM Interrupt Status
1526 * Bit 2 TXOAM_SOP_ERRI
1527 * Bit 1 TXOAM_OFLI
1528 * Bit 0 TXOAM_ERRI
1529 *----------------------------------------------------------------------------*/
1530#define SUNI1x10GEXP_BITMSK_TXOAM_SOP_ERRI 0x0004
1531#define SUNI1x10GEXP_BITMSK_TXOAM_OFLI 0x0002
1532#define SUNI1x10GEXP_BITMSK_TXOAM_ERRI 0x0001
1533
1534/*----------------------------------------------------------------------------
1535 * Register 0x30CF: TXOAM Coset
1536 * Bit 7-0 TXOAM_COSET
1537 *----------------------------------------------------------------------------*/
1538#define SUNI1x10GEXP_BITMSK_TXOAM_COSET 0x00FF
1539
1540/*----------------------------------------------------------------------------
1541 * Register 0x3200: EFLX Global Configuration
1542 * Bit 15 EFLX_ERCU_EN
1543 * Bit 7 EFLX_EN_EDSWT
1544 *----------------------------------------------------------------------------*/
1545#define SUNI1x10GEXP_BITMSK_EFLX_ERCU_EN 0x8000
1546#define SUNI1x10GEXP_BITMSK_EFLX_EN_EDSWT 0x0080
1547
1548/*----------------------------------------------------------------------------
1549 * Register 0x3201: EFLX ERCU Global Status
1550 * Bit 13 EFLX_OVF_ERR
1551 *----------------------------------------------------------------------------*/
1552#define SUNI1x10GEXP_BITMSK_EFLX_OVF_ERR 0x2000
1553
1554/*----------------------------------------------------------------------------
1555 * Register 0x3202: EFLX Indirect Channel Address
1556 * Bit 15 EFLX_BUSY
1557 * Bit 14 EFLX_RDWRB
1558 *----------------------------------------------------------------------------*/
1559#define SUNI1x10GEXP_BITMSK_EFLX_BUSY 0x8000
1560#define SUNI1x10GEXP_BITMSK_EFLX_RDWRB 0x4000
1561
1562/*----------------------------------------------------------------------------
1563 * Register 0x3203: EFLX Indirect Logical FIFO Low Limit
1564 *----------------------------------------------------------------------------*/
1565#define SUNI1x10GEXP_BITMSK_EFLX_LOLIM 0x03FF
1566#define SUNI1x10GEXP_BITOFF_EFLX_LOLIM 0
1567
1568/*----------------------------------------------------------------------------
1569 * Register 0x3204: EFLX Indirect Logical FIFO High Limit
1570 *----------------------------------------------------------------------------*/
1571#define SUNI1x10GEXP_BITMSK_EFLX_HILIM 0x03FF
1572#define SUNI1x10GEXP_BITOFF_EFLX_HILIM 0
1573
1574/*----------------------------------------------------------------------------
1575 * Register 0x3205: EFLX Indirect Full/Almost-Full Status and Limit
1576 * Bit 15 EFLX_FULL
1577 * Bit 14 EFLX_AFULL
1578 * Bit 13-0 EFLX_AFTH
1579 *----------------------------------------------------------------------------*/
1580#define SUNI1x10GEXP_BITMSK_EFLX_FULL 0x8000
1581#define SUNI1x10GEXP_BITMSK_EFLX_AFULL 0x4000
1582#define SUNI1x10GEXP_BITMSK_EFLX_AFTH 0x3FFF
1583#define SUNI1x10GEXP_BITOFF_EFLX_AFTH 0
1584
1585/*----------------------------------------------------------------------------
1586 * Register 0x3206: EFLX Indirect Empty/Almost-Empty Status and Limit
1587 * Bit 15 EFLX_EMPTY
1588 * Bit 14 EFLX_AEMPTY
1589 * Bit 13-0 EFLX_AETH
1590 *----------------------------------------------------------------------------*/
1591#define SUNI1x10GEXP_BITMSK_EFLX_EMPTY 0x8000
1592#define SUNI1x10GEXP_BITMSK_EFLX_AEMPTY 0x4000
1593#define SUNI1x10GEXP_BITMSK_EFLX_AETH 0x3FFF
1594#define SUNI1x10GEXP_BITOFF_EFLX_AETH 0
1595
1596/*----------------------------------------------------------------------------
1597 * Register 0x3207: EFLX Indirect FIFO Cut-Through Threshold
1598 *----------------------------------------------------------------------------*/
1599#define SUNI1x10GEXP_BITMSK_EFLX_CUT_THRU 0x3FFF
1600#define SUNI1x10GEXP_BITOFF_EFLX_CUT_THRU 0
1601
1602/*----------------------------------------------------------------------------
1603 * Register 0x320C: EFLX FIFO Overflow Error Enable
1604 * Bit 0 EFLX_OVFE
1605 *----------------------------------------------------------------------------*/
1606#define SUNI1x10GEXP_BITMSK_EFLX_OVFE 0x0001
1607
1608/*----------------------------------------------------------------------------
1609 * Register 0x320D: EFLX FIFO Overflow Error Indication
1610 * Bit 0 EFLX_OVFI
1611 *----------------------------------------------------------------------------*/
1612#define SUNI1x10GEXP_BITMSK_EFLX_OVFI 0x0001
1613
1614/*----------------------------------------------------------------------------
1615 * Register 0x3210: EFLX Channel Provision
1616 * Bit 0 EFLX_PROV
1617 *----------------------------------------------------------------------------*/
1618#define SUNI1x10GEXP_BITMSK_EFLX_PROV 0x0001
1619
1620/*----------------------------------------------------------------------------
1621 * Register 0x3280: PL4IDU Configuration
1622 * Bit 2 PL4IDU_SYNCH_ON_TRAIN
1623 * Bit 1 PL4IDU_EN_PORTS
1624 * Bit 0 PL4IDU_EN_DFWD
1625 *----------------------------------------------------------------------------*/
1626#define SUNI1x10GEXP_BITMSK_PL4IDU_SYNCH_ON_TRAIN 0x0004
1627#define SUNI1x10GEXP_BITMSK_PL4IDU_EN_PORTS 0x0002
1628#define SUNI1x10GEXP_BITMSK_PL4IDU_EN_DFWD 0x0001
1629
1630/*----------------------------------------------------------------------------
1631 * Register 0x3282: PL4IDU Interrupt Mask
1632 * Bit 1 PL4IDU_DIP4E
1633 *----------------------------------------------------------------------------*/
1634#define SUNI1x10GEXP_BITMSK_PL4IDU_DIP4E 0x0002
1635
1636/*----------------------------------------------------------------------------
1637 * Register 0x3283: PL4IDU Interrupt
1638 * Bit 1 PL4IDU_DIP4I
1639 *----------------------------------------------------------------------------*/
1640#define SUNI1x10GEXP_BITMSK_PL4IDU_DIP4I 0x0002
211 1641
212#endif /* _CXGB_SUNI1x10GEXP_REGS_H_ */ 1642#endif /* _CXGB_SUNI1x10GEXP_REGS_H_ */
213 1643
diff --git a/drivers/net/chelsio/tp.c b/drivers/net/chelsio/tp.c
new file mode 100644
index 000000000000..0ca0b6e19e43
--- /dev/null
+++ b/drivers/net/chelsio/tp.c
@@ -0,0 +1,178 @@
1/* $Date: 2006/02/07 04:21:54 $ $RCSfile: tp.c,v $ $Revision: 1.73 $ */
2#include "common.h"
3#include "regs.h"
4#include "tp.h"
5#ifdef CONFIG_CHELSIO_T1_1G
6#include "fpga_defs.h"
7#endif
8
9struct petp {
10 adapter_t *adapter;
11};
12
13/* Pause deadlock avoidance parameters */
14#define DROP_MSEC 16
15#define DROP_PKTS_CNT 1
16
17static void tp_init(adapter_t * ap, const struct tp_params *p,
18 unsigned int tp_clk)
19{
20 if (t1_is_asic(ap)) {
21 u32 val;
22
23 val = F_TP_IN_CSPI_CPL | F_TP_IN_CSPI_CHECK_IP_CSUM |
24 F_TP_IN_CSPI_CHECK_TCP_CSUM | F_TP_IN_ESPI_ETHERNET;
25 if (!p->pm_size)
26 val |= F_OFFLOAD_DISABLE;
27 else
28 val |= F_TP_IN_ESPI_CHECK_IP_CSUM |
29 F_TP_IN_ESPI_CHECK_TCP_CSUM;
30 writel(val, ap->regs + A_TP_IN_CONFIG);
31 writel(F_TP_OUT_CSPI_CPL |
32 F_TP_OUT_ESPI_ETHERNET |
33 F_TP_OUT_ESPI_GENERATE_IP_CSUM |
34 F_TP_OUT_ESPI_GENERATE_TCP_CSUM,
35 ap->regs + A_TP_OUT_CONFIG);
36 writel(V_IP_TTL(64) |
37 F_PATH_MTU /* IP DF bit */ |
38 V_5TUPLE_LOOKUP(p->use_5tuple_mode) |
39 V_SYN_COOKIE_PARAMETER(29),
40 ap->regs + A_TP_GLOBAL_CONFIG);
41 /*
42 * Enable pause frame deadlock prevention.
43 */
44 if (is_T2(ap) && ap->params.nports > 1) {
45 u32 drop_ticks = DROP_MSEC * (tp_clk / 1000);
46
47 writel(F_ENABLE_TX_DROP | F_ENABLE_TX_ERROR |
48 V_DROP_TICKS_CNT(drop_ticks) |
49 V_NUM_PKTS_DROPPED(DROP_PKTS_CNT),
50 ap->regs + A_TP_TX_DROP_CONFIG);
51 }
52
53 }
54}
55
56void t1_tp_destroy(struct petp *tp)
57{
58 kfree(tp);
59}
60
61struct petp *__devinit t1_tp_create(adapter_t * adapter, struct tp_params *p)
62{
63 struct petp *tp = kzalloc(sizeof(*tp), GFP_KERNEL);
64 if (!tp)
65 return NULL;
66
67 tp->adapter = adapter;
68
69 return tp;
70}
71
72void t1_tp_intr_enable(struct petp *tp)
73{
74 u32 tp_intr = readl(tp->adapter->regs + A_PL_ENABLE);
75
76#ifdef CONFIG_CHELSIO_T1_1G
77 if (!t1_is_asic(tp->adapter)) {
78 /* FPGA */
79 writel(0xffffffff,
80 tp->adapter->regs + FPGA_TP_ADDR_INTERRUPT_ENABLE);
81 writel(tp_intr | FPGA_PCIX_INTERRUPT_TP,
82 tp->adapter->regs + A_PL_ENABLE);
83 } else
84#endif
85 {
86 /* We don't use any TP interrupts */
87 writel(0, tp->adapter->regs + A_TP_INT_ENABLE);
88 writel(tp_intr | F_PL_INTR_TP,
89 tp->adapter->regs + A_PL_ENABLE);
90 }
91}
92
93void t1_tp_intr_disable(struct petp *tp)
94{
95 u32 tp_intr = readl(tp->adapter->regs + A_PL_ENABLE);
96
97#ifdef CONFIG_CHELSIO_T1_1G
98 if (!t1_is_asic(tp->adapter)) {
99 /* FPGA */
100 writel(0, tp->adapter->regs + FPGA_TP_ADDR_INTERRUPT_ENABLE);
101 writel(tp_intr & ~FPGA_PCIX_INTERRUPT_TP,
102 tp->adapter->regs + A_PL_ENABLE);
103 } else
104#endif
105 {
106 writel(0, tp->adapter->regs + A_TP_INT_ENABLE);
107 writel(tp_intr & ~F_PL_INTR_TP,
108 tp->adapter->regs + A_PL_ENABLE);
109 }
110}
111
112void t1_tp_intr_clear(struct petp *tp)
113{
114#ifdef CONFIG_CHELSIO_T1_1G
115 if (!t1_is_asic(tp->adapter)) {
116 writel(0xffffffff,
117 tp->adapter->regs + FPGA_TP_ADDR_INTERRUPT_CAUSE);
118 writel(FPGA_PCIX_INTERRUPT_TP, tp->adapter->regs + A_PL_CAUSE);
119 return;
120 }
121#endif
122 writel(0xffffffff, tp->adapter->regs + A_TP_INT_CAUSE);
123 writel(F_PL_INTR_TP, tp->adapter->regs + A_PL_CAUSE);
124}
125
126int t1_tp_intr_handler(struct petp *tp)
127{
128 u32 cause;
129
130#ifdef CONFIG_CHELSIO_T1_1G
131 /* FPGA doesn't support TP interrupts. */
132 if (!t1_is_asic(tp->adapter))
133 return 1;
134#endif
135
136 cause = readl(tp->adapter->regs + A_TP_INT_CAUSE);
137 writel(cause, tp->adapter->regs + A_TP_INT_CAUSE);
138 return 0;
139}
140
141static void set_csum_offload(struct petp *tp, u32 csum_bit, int enable)
142{
143 u32 val = readl(tp->adapter->regs + A_TP_GLOBAL_CONFIG);
144
145 if (enable)
146 val |= csum_bit;
147 else
148 val &= ~csum_bit;
149 writel(val, tp->adapter->regs + A_TP_GLOBAL_CONFIG);
150}
151
152void t1_tp_set_ip_checksum_offload(struct petp *tp, int enable)
153{
154 set_csum_offload(tp, F_IP_CSUM, enable);
155}
156
157void t1_tp_set_udp_checksum_offload(struct petp *tp, int enable)
158{
159 set_csum_offload(tp, F_UDP_CSUM, enable);
160}
161
162void t1_tp_set_tcp_checksum_offload(struct petp *tp, int enable)
163{
164 set_csum_offload(tp, F_TCP_CSUM, enable);
165}
166
167/*
168 * Initialize TP state. tp_params contains initial settings for some TP
169 * parameters, particularly the one-time PM and CM settings.
170 */
171int t1_tp_reset(struct petp *tp, struct tp_params *p, unsigned int tp_clk)
172{
173 adapter_t *adapter = tp->adapter;
174
175 tp_init(adapter, p, tp_clk);
176 writel(F_TP_RESET, adapter->regs + A_TP_RESET);
177 return 0;
178}
diff --git a/drivers/net/chelsio/tp.h b/drivers/net/chelsio/tp.h
new file mode 100644
index 000000000000..32fc71e58913
--- /dev/null
+++ b/drivers/net/chelsio/tp.h
@@ -0,0 +1,73 @@
1/* $Date: 2005/03/07 23:59:05 $ $RCSfile: tp.h,v $ $Revision: 1.20 $ */
2#ifndef CHELSIO_TP_H
3#define CHELSIO_TP_H
4
5#include "common.h"
6
7#define TP_MAX_RX_COALESCING_SIZE 16224U
8
9struct tp_mib_statistics {
10
11 /* IP */
12 u32 ipInReceive_hi;
13 u32 ipInReceive_lo;
14 u32 ipInHdrErrors_hi;
15 u32 ipInHdrErrors_lo;
16 u32 ipInAddrErrors_hi;
17 u32 ipInAddrErrors_lo;
18 u32 ipInUnknownProtos_hi;
19 u32 ipInUnknownProtos_lo;
20 u32 ipInDiscards_hi;
21 u32 ipInDiscards_lo;
22 u32 ipInDelivers_hi;
23 u32 ipInDelivers_lo;
24 u32 ipOutRequests_hi;
25 u32 ipOutRequests_lo;
26 u32 ipOutDiscards_hi;
27 u32 ipOutDiscards_lo;
28 u32 ipOutNoRoutes_hi;
29 u32 ipOutNoRoutes_lo;
30 u32 ipReasmTimeout;
31 u32 ipReasmReqds;
32 u32 ipReasmOKs;
33 u32 ipReasmFails;
34
35 u32 reserved[8];
36
37 /* TCP */
38 u32 tcpActiveOpens;
39 u32 tcpPassiveOpens;
40 u32 tcpAttemptFails;
41 u32 tcpEstabResets;
42 u32 tcpOutRsts;
43 u32 tcpCurrEstab;
44 u32 tcpInSegs_hi;
45 u32 tcpInSegs_lo;
46 u32 tcpOutSegs_hi;
47 u32 tcpOutSegs_lo;
48 u32 tcpRetransSeg_hi;
49 u32 tcpRetransSeg_lo;
50 u32 tcpInErrs_hi;
51 u32 tcpInErrs_lo;
52 u32 tcpRtoMin;
53 u32 tcpRtoMax;
54};
55
56struct petp;
57struct tp_params;
58
59struct petp *t1_tp_create(adapter_t *adapter, struct tp_params *p);
60void t1_tp_destroy(struct petp *tp);
61
62void t1_tp_intr_disable(struct petp *tp);
63void t1_tp_intr_enable(struct petp *tp);
64void t1_tp_intr_clear(struct petp *tp);
65int t1_tp_intr_handler(struct petp *tp);
66
67void t1_tp_get_mib_statistics(adapter_t *adap, struct tp_mib_statistics *tps);
68void t1_tp_set_udp_checksum_offload(struct petp *tp, int enable);
69void t1_tp_set_tcp_checksum_offload(struct petp *tp, int enable);
70void t1_tp_set_ip_checksum_offload(struct petp *tp, int enable);
71int t1_tp_set_coalescing_size(struct petp *tp, unsigned int size);
72int t1_tp_reset(struct petp *tp, struct tp_params *p, unsigned int tp_clk);
73#endif
diff --git a/drivers/net/chelsio/vsc7326.c b/drivers/net/chelsio/vsc7326.c
new file mode 100644
index 000000000000..85dc3b1dc309
--- /dev/null
+++ b/drivers/net/chelsio/vsc7326.c
@@ -0,0 +1,725 @@
1/* $Date: 2006/04/28 19:20:06 $ $RCSfile: vsc7326.c,v $ $Revision: 1.19 $ */
2
3/* Driver for Vitesse VSC7326 (Schaumburg) MAC */
4
5#include "gmac.h"
6#include "elmer0.h"
7#include "vsc7326_reg.h"
8
9/* Update fast changing statistics every 15 seconds */
10#define STATS_TICK_SECS 15
11/* 30 minutes for full statistics update */
12#define MAJOR_UPDATE_TICKS (1800 / STATS_TICK_SECS)
13
14#define MAX_MTU 9600
15
16/* The egress WM value 0x01a01fff should be used only when the
17 * interface is down (MAC port disabled). This is a workaround
18 * for disabling the T2/MAC flow-control. When the interface is
19 * enabled, the WM value should be set to 0x014a03F0.
20 */
21#define WM_DISABLE 0x01a01fff
22#define WM_ENABLE 0x014a03F0
23
24struct init_table {
25 u32 addr;
26 u32 data;
27};
28
29struct _cmac_instance {
30 u32 index;
31 u32 ticks;
32};
33
34#define INITBLOCK_SLEEP 0xffffffff
35
36static void vsc_read(adapter_t *adapter, u32 addr, u32 *val)
37{
38 u32 status, vlo, vhi;
39 int i;
40
41 spin_lock_bh(&adapter->mac_lock);
42 t1_tpi_read(adapter, (addr << 2) + 4, &vlo);
43 i = 0;
44 do {
45 t1_tpi_read(adapter, (REG_LOCAL_STATUS << 2) + 4, &vlo);
46 t1_tpi_read(adapter, REG_LOCAL_STATUS << 2, &vhi);
47 status = (vhi << 16) | vlo;
48 i++;
49 } while (((status & 1) == 0) && (i < 50));
50 if (i == 50)
51 CH_ERR("Invalid tpi read from MAC, breaking loop.\n");
52
53 t1_tpi_read(adapter, (REG_LOCAL_DATA << 2) + 4, &vlo);
54 t1_tpi_read(adapter, REG_LOCAL_DATA << 2, &vhi);
55
56 *val = (vhi << 16) | vlo;
57
58 /* CH_ERR("rd: block: 0x%x sublock: 0x%x reg: 0x%x data: 0x%x\n",
59 ((addr&0xe000)>>13), ((addr&0x1e00)>>9),
60 ((addr&0x01fe)>>1), *val); */
61 spin_unlock_bh(&adapter->mac_lock);
62}
63
64static void vsc_write(adapter_t *adapter, u32 addr, u32 data)
65{
66 spin_lock_bh(&adapter->mac_lock);
67 t1_tpi_write(adapter, (addr << 2) + 4, data & 0xFFFF);
68 t1_tpi_write(adapter, addr << 2, (data >> 16) & 0xFFFF);
69 /* CH_ERR("wr: block: 0x%x sublock: 0x%x reg: 0x%x data: 0x%x\n",
70 ((addr&0xe000)>>13), ((addr&0x1e00)>>9),
71 ((addr&0x01fe)>>1), data); */
72 spin_unlock_bh(&adapter->mac_lock);
73}
74
75/* Hard reset the MAC. This wipes out *all* configuration. */
76static void vsc7326_full_reset(adapter_t* adapter)
77{
78 u32 val;
79 u32 result = 0xffff;
80
81 t1_tpi_read(adapter, A_ELMER0_GPO, &val);
82 val &= ~1;
83 t1_tpi_write(adapter, A_ELMER0_GPO, val);
84 udelay(2);
85 val |= 0x1; /* Enable mac MAC itself */
86 val |= 0x800; /* Turn off the red LED */
87 t1_tpi_write(adapter, A_ELMER0_GPO, val);
88 mdelay(1);
89 vsc_write(adapter, REG_SW_RESET, 0x80000001);
90 do {
91 mdelay(1);
92 vsc_read(adapter, REG_SW_RESET, &result);
93 } while (result != 0x0);
94}
95
96static struct init_table vsc7326_reset[] = {
97 { REG_IFACE_MODE, 0x00000000 },
98 { REG_CRC_CFG, 0x00000020 },
99 { REG_PLL_CLK_SPEED, 0x00050c00 },
100 { REG_PLL_CLK_SPEED, 0x00050c00 },
101 { REG_MSCH, 0x00002f14 },
102 { REG_SPI4_MISC, 0x00040409 },
103 { REG_SPI4_DESKEW, 0x00080000 },
104 { REG_SPI4_ING_SETUP2, 0x08080004 },
105 { REG_SPI4_ING_SETUP0, 0x04111004 },
106 { REG_SPI4_EGR_SETUP0, 0x80001a04 },
107 { REG_SPI4_ING_SETUP1, 0x02010000 },
108 { REG_AGE_INC(0), 0x00000000 },
109 { REG_AGE_INC(1), 0x00000000 },
110 { REG_ING_CONTROL, 0x0a200011 },
111 { REG_EGR_CONTROL, 0xa0010091 },
112};
113
114static struct init_table vsc7326_portinit[4][22] = {
115 { /* Port 0 */
116 /* FIFO setup */
117 { REG_DBG(0), 0x000004f0 },
118 { REG_HDX(0), 0x00073101 },
119 { REG_TEST(0,0), 0x00000022 },
120 { REG_TEST(1,0), 0x00000022 },
121 { REG_TOP_BOTTOM(0,0), 0x003f0000 },
122 { REG_TOP_BOTTOM(1,0), 0x00120000 },
123 { REG_HIGH_LOW_WM(0,0), 0x07460757 },
124 { REG_HIGH_LOW_WM(1,0), WM_DISABLE },
125 { REG_CT_THRHLD(0,0), 0x00000000 },
126 { REG_CT_THRHLD(1,0), 0x00000000 },
127 { REG_BUCKE(0), 0x0002ffff },
128 { REG_BUCKI(0), 0x0002ffff },
129 { REG_TEST(0,0), 0x00000020 },
130 { REG_TEST(1,0), 0x00000020 },
131 /* Port config */
132 { REG_MAX_LEN(0), 0x00002710 },
133 { REG_PORT_FAIL(0), 0x00000002 },
134 { REG_NORMALIZER(0), 0x00000a64 },
135 { REG_DENORM(0), 0x00000010 },
136 { REG_STICK_BIT(0), 0x03baa370 },
137 { REG_DEV_SETUP(0), 0x00000083 },
138 { REG_DEV_SETUP(0), 0x00000082 },
139 { REG_MODE_CFG(0), 0x0200259f },
140 },
141 { /* Port 1 */
142 /* FIFO setup */
143 { REG_DBG(1), 0x000004f0 },
144 { REG_HDX(1), 0x00073101 },
145 { REG_TEST(0,1), 0x00000022 },
146 { REG_TEST(1,1), 0x00000022 },
147 { REG_TOP_BOTTOM(0,1), 0x007e003f },
148 { REG_TOP_BOTTOM(1,1), 0x00240012 },
149 { REG_HIGH_LOW_WM(0,1), 0x07460757 },
150 { REG_HIGH_LOW_WM(1,1), WM_DISABLE },
151 { REG_CT_THRHLD(0,1), 0x00000000 },
152 { REG_CT_THRHLD(1,1), 0x00000000 },
153 { REG_BUCKE(1), 0x0002ffff },
154 { REG_BUCKI(1), 0x0002ffff },
155 { REG_TEST(0,1), 0x00000020 },
156 { REG_TEST(1,1), 0x00000020 },
157 /* Port config */
158 { REG_MAX_LEN(1), 0x00002710 },
159 { REG_PORT_FAIL(1), 0x00000002 },
160 { REG_NORMALIZER(1), 0x00000a64 },
161 { REG_DENORM(1), 0x00000010 },
162 { REG_STICK_BIT(1), 0x03baa370 },
163 { REG_DEV_SETUP(1), 0x00000083 },
164 { REG_DEV_SETUP(1), 0x00000082 },
165 { REG_MODE_CFG(1), 0x0200259f },
166 },
167 { /* Port 2 */
168 /* FIFO setup */
169 { REG_DBG(2), 0x000004f0 },
170 { REG_HDX(2), 0x00073101 },
171 { REG_TEST(0,2), 0x00000022 },
172 { REG_TEST(1,2), 0x00000022 },
173 { REG_TOP_BOTTOM(0,2), 0x00bd007e },
174 { REG_TOP_BOTTOM(1,2), 0x00360024 },
175 { REG_HIGH_LOW_WM(0,2), 0x07460757 },
176 { REG_HIGH_LOW_WM(1,2), WM_DISABLE },
177 { REG_CT_THRHLD(0,2), 0x00000000 },
178 { REG_CT_THRHLD(1,2), 0x00000000 },
179 { REG_BUCKE(2), 0x0002ffff },
180 { REG_BUCKI(2), 0x0002ffff },
181 { REG_TEST(0,2), 0x00000020 },
182 { REG_TEST(1,2), 0x00000020 },
183 /* Port config */
184 { REG_MAX_LEN(2), 0x00002710 },
185 { REG_PORT_FAIL(2), 0x00000002 },
186 { REG_NORMALIZER(2), 0x00000a64 },
187 { REG_DENORM(2), 0x00000010 },
188 { REG_STICK_BIT(2), 0x03baa370 },
189 { REG_DEV_SETUP(2), 0x00000083 },
190 { REG_DEV_SETUP(2), 0x00000082 },
191 { REG_MODE_CFG(2), 0x0200259f },
192 },
193 { /* Port 3 */
194 /* FIFO setup */
195 { REG_DBG(3), 0x000004f0 },
196 { REG_HDX(3), 0x00073101 },
197 { REG_TEST(0,3), 0x00000022 },
198 { REG_TEST(1,3), 0x00000022 },
199 { REG_TOP_BOTTOM(0,3), 0x00fc00bd },
200 { REG_TOP_BOTTOM(1,3), 0x00480036 },
201 { REG_HIGH_LOW_WM(0,3), 0x07460757 },
202 { REG_HIGH_LOW_WM(1,3), WM_DISABLE },
203 { REG_CT_THRHLD(0,3), 0x00000000 },
204 { REG_CT_THRHLD(1,3), 0x00000000 },
205 { REG_BUCKE(3), 0x0002ffff },
206 { REG_BUCKI(3), 0x0002ffff },
207 { REG_TEST(0,3), 0x00000020 },
208 { REG_TEST(1,3), 0x00000020 },
209 /* Port config */
210 { REG_MAX_LEN(3), 0x00002710 },
211 { REG_PORT_FAIL(3), 0x00000002 },
212 { REG_NORMALIZER(3), 0x00000a64 },
213 { REG_DENORM(3), 0x00000010 },
214 { REG_STICK_BIT(3), 0x03baa370 },
215 { REG_DEV_SETUP(3), 0x00000083 },
216 { REG_DEV_SETUP(3), 0x00000082 },
217 { REG_MODE_CFG(3), 0x0200259f },
218 },
219};
220
221static void run_table(adapter_t *adapter, struct init_table *ib, int len)
222{
223 int i;
224
225 for (i = 0; i < len; i++) {
226 if (ib[i].addr == INITBLOCK_SLEEP) {
227 udelay( ib[i].data );
228 CH_ERR("sleep %d us\n",ib[i].data);
229 } else {
230 vsc_write( adapter, ib[i].addr, ib[i].data );
231 }
232 }
233}
234
235static int bist_rd(adapter_t *adapter, int moduleid, int address)
236{
237 int data=0;
238 u32 result=0;
239
240 if( (address != 0x0) &&
241 (address != 0x1) &&
242 (address != 0x2) &&
243 (address != 0xd) &&
244 (address != 0xe))
245 CH_ERR("No bist address: 0x%x\n", address);
246
247 data = ((0x00 << 24) | ((address & 0xff) << 16) | (0x00 << 8) |
248 ((moduleid & 0xff) << 0));
249 vsc_write(adapter, REG_RAM_BIST_CMD, data);
250
251 udelay(10);
252
253 vsc_read(adapter, REG_RAM_BIST_RESULT, &result);
254 if((result & (1<<9)) != 0x0)
255 CH_ERR("Still in bist read: 0x%x\n", result);
256 else if((result & (1<<8)) != 0x0)
257 CH_ERR("bist read error: 0x%x\n", result);
258
259 return(result & 0xff);
260}
261
262static int bist_wr(adapter_t *adapter, int moduleid, int address, int value)
263{
264 int data=0;
265 u32 result=0;
266
267 if( (address != 0x0) &&
268 (address != 0x1) &&
269 (address != 0x2) &&
270 (address != 0xd) &&
271 (address != 0xe))
272 CH_ERR("No bist address: 0x%x\n", address);
273
274 if( value>255 )
275 CH_ERR("Suspicious write out of range value: 0x%x\n", value);
276
277 data = ((0x01 << 24) | ((address & 0xff) << 16) | (value << 8) |
278 ((moduleid & 0xff) << 0));
279 vsc_write(adapter, REG_RAM_BIST_CMD, data);
280
281 udelay(5);
282
283 vsc_read(adapter, REG_RAM_BIST_CMD, &result);
284 if((result & (1<<27)) != 0x0)
285 CH_ERR("Still in bist write: 0x%x\n", result);
286 else if((result & (1<<26)) != 0x0)
287 CH_ERR("bist write error: 0x%x\n", result);
288
289 return(0);
290}
291
292static int run_bist(adapter_t *adapter, int moduleid)
293{
294 /*run bist*/
295 (void) bist_wr(adapter,moduleid, 0x00, 0x02);
296 (void) bist_wr(adapter,moduleid, 0x01, 0x01);
297
298 return(0);
299}
300
301static int check_bist(adapter_t *adapter, int moduleid)
302{
303 int result=0;
304 int column=0;
305 /*check bist*/
306 result = bist_rd(adapter,moduleid, 0x02);
307 column = ((bist_rd(adapter,moduleid, 0x0e)<<8) +
308 (bist_rd(adapter,moduleid, 0x0d)));
309 if ((result & 3) != 0x3)
310 CH_ERR("Result: 0x%x BIST error in ram %d, column: 0x%04x\n",
311 result, moduleid, column);
312 return(0);
313}
314
315static int enable_mem(adapter_t *adapter, int moduleid)
316{
317 /*enable mem*/
318 (void) bist_wr(adapter,moduleid, 0x00, 0x00);
319 return(0);
320}
321
322static int run_bist_all(adapter_t *adapter)
323{
324 int port=0;
325 u32 val=0;
326
327 vsc_write(adapter, REG_MEM_BIST, 0x5);
328 vsc_read(adapter, REG_MEM_BIST, &val);
329
330 for(port=0; port<12; port++){
331 vsc_write(adapter, REG_DEV_SETUP(port), 0x0);
332 }
333
334 udelay(300);
335 vsc_write(adapter, REG_SPI4_MISC, 0x00040409);
336 udelay(300);
337
338 (void) run_bist(adapter,13);
339 (void) run_bist(adapter,14);
340 (void) run_bist(adapter,20);
341 (void) run_bist(adapter,21);
342 mdelay(200);
343 (void) check_bist(adapter,13);
344 (void) check_bist(adapter,14);
345 (void) check_bist(adapter,20);
346 (void) check_bist(adapter,21);
347 udelay(100);
348 (void) enable_mem(adapter,13);
349 (void) enable_mem(adapter,14);
350 (void) enable_mem(adapter,20);
351 (void) enable_mem(adapter,21);
352 udelay(300);
353 vsc_write(adapter, REG_SPI4_MISC, 0x60040400);
354 udelay(300);
355 for(port=0; port<12; port++){
356 vsc_write(adapter, REG_DEV_SETUP(port), 0x1);
357 }
358 udelay(300);
359 vsc_write(adapter, REG_MEM_BIST, 0x0);
360 mdelay(10);
361 return(0);
362}
363
364static int mac_intr_handler(struct cmac *mac)
365{
366 return 0;
367}
368
369static int mac_intr_enable(struct cmac *mac)
370{
371 return 0;
372}
373
374static int mac_intr_disable(struct cmac *mac)
375{
376 return 0;
377}
378
379static int mac_intr_clear(struct cmac *mac)
380{
381 return 0;
382}
383
384/* Expect MAC address to be in network byte order. */
385static int mac_set_address(struct cmac* mac, u8 addr[6])
386{
387 u32 val;
388 int port = mac->instance->index;
389
390 vsc_write(mac->adapter, REG_MAC_LOW_ADDR(port),
391 (addr[3] << 16) | (addr[4] << 8) | addr[5]);
392 vsc_write(mac->adapter, REG_MAC_HIGH_ADDR(port),
393 (addr[0] << 16) | (addr[1] << 8) | addr[2]);
394
395 vsc_read(mac->adapter, REG_ING_FFILT_UM_EN, &val);
396 val &= ~0xf0000000;
397 vsc_write(mac->adapter, REG_ING_FFILT_UM_EN, val | (port << 28));
398
399 vsc_write(mac->adapter, REG_ING_FFILT_MASK0,
400 0xffff0000 | (addr[4] << 8) | addr[5]);
401 vsc_write(mac->adapter, REG_ING_FFILT_MASK1,
402 0xffff0000 | (addr[2] << 8) | addr[3]);
403 vsc_write(mac->adapter, REG_ING_FFILT_MASK2,
404 0xffff0000 | (addr[0] << 8) | addr[1]);
405 return 0;
406}
407
408static int mac_get_address(struct cmac *mac, u8 addr[6])
409{
410 u32 addr_lo, addr_hi;
411 int port = mac->instance->index;
412
413 vsc_read(mac->adapter, REG_MAC_LOW_ADDR(port), &addr_lo);
414 vsc_read(mac->adapter, REG_MAC_HIGH_ADDR(port), &addr_hi);
415
416 addr[0] = (u8) (addr_hi >> 16);
417 addr[1] = (u8) (addr_hi >> 8);
418 addr[2] = (u8) addr_hi;
419 addr[3] = (u8) (addr_lo >> 16);
420 addr[4] = (u8) (addr_lo >> 8);
421 addr[5] = (u8) addr_lo;
422 return 0;
423}
424
425/* This is intended to reset a port, not the whole MAC */
426static int mac_reset(struct cmac *mac)
427{
428 int index = mac->instance->index;
429
430 run_table(mac->adapter, vsc7326_portinit[index],
431 ARRAY_SIZE(vsc7326_portinit[index]));
432
433 return 0;
434}
435
436static int mac_set_rx_mode(struct cmac *mac, struct t1_rx_mode *rm)
437{
438 u32 v;
439 int port = mac->instance->index;
440
441 vsc_read(mac->adapter, REG_ING_FFILT_UM_EN, &v);
442 v |= 1 << 12;
443
444 if (t1_rx_mode_promisc(rm))
445 v &= ~(1 << (port + 16));
446 else
447 v |= 1 << (port + 16);
448
449 vsc_write(mac->adapter, REG_ING_FFILT_UM_EN, v);
450 return 0;
451}
452
453static int mac_set_mtu(struct cmac *mac, int mtu)
454{
455 int port = mac->instance->index;
456
457 if (mtu > MAX_MTU)
458 return -EINVAL;
459
460 /* max_len includes header and FCS */
461 vsc_write(mac->adapter, REG_MAX_LEN(port), mtu + 14 + 4);
462 return 0;
463}
464
465static int mac_set_speed_duplex_fc(struct cmac *mac, int speed, int duplex,
466 int fc)
467{
468 u32 v;
469 int enable, port = mac->instance->index;
470
471 if (speed >= 0 && speed != SPEED_10 && speed != SPEED_100 &&
472 speed != SPEED_1000)
473 return -1;
474 if (duplex > 0 && duplex != DUPLEX_FULL)
475 return -1;
476
477 if (speed >= 0) {
478 vsc_read(mac->adapter, REG_MODE_CFG(port), &v);
479 enable = v & 3; /* save tx/rx enables */
480 v &= ~0xf;
481 v |= 4; /* full duplex */
482 if (speed == SPEED_1000)
483 v |= 8; /* GigE */
484 enable |= v;
485 vsc_write(mac->adapter, REG_MODE_CFG(port), v);
486
487 if (speed == SPEED_1000)
488 v = 0x82;
489 else if (speed == SPEED_100)
490 v = 0x84;
491 else /* SPEED_10 */
492 v = 0x86;
493 vsc_write(mac->adapter, REG_DEV_SETUP(port), v | 1); /* reset */
494 vsc_write(mac->adapter, REG_DEV_SETUP(port), v);
495 vsc_read(mac->adapter, REG_DBG(port), &v);
496 v &= ~0xff00;
497 if (speed == SPEED_1000)
498 v |= 0x400;
499 else if (speed == SPEED_100)
500 v |= 0x2000;
501 else /* SPEED_10 */
502 v |= 0xff00;
503 vsc_write(mac->adapter, REG_DBG(port), v);
504
505 vsc_write(mac->adapter, REG_TX_IFG(port),
506 speed == SPEED_1000 ? 5 : 0x11);
507 if (duplex == DUPLEX_HALF)
508 enable = 0x0; /* 100 or 10 */
509 else if (speed == SPEED_1000)
510 enable = 0xc;
511 else /* SPEED_100 or 10 */
512 enable = 0x4;
513 enable |= 0x9 << 10; /* IFG1 */
514 enable |= 0x6 << 6; /* IFG2 */
515 enable |= 0x1 << 4; /* VLAN */
516 enable |= 0x3; /* RX/TX EN */
517 vsc_write(mac->adapter, REG_MODE_CFG(port), enable);
518
519 }
520
521 vsc_read(mac->adapter, REG_PAUSE_CFG(port), &v);
522 v &= 0xfff0ffff;
523 v |= 0x20000; /* xon/xoff */
524 if (fc & PAUSE_RX)
525 v |= 0x40000;
526 if (fc & PAUSE_TX)
527 v |= 0x80000;
528 if (fc == (PAUSE_RX | PAUSE_TX))
529 v |= 0x10000;
530 vsc_write(mac->adapter, REG_PAUSE_CFG(port), v);
531 return 0;
532}
533
534static int mac_enable(struct cmac *mac, int which)
535{
536 u32 val;
537 int port = mac->instance->index;
538
539 /* Write the correct WM value when the port is enabled. */
540 vsc_write(mac->adapter, REG_HIGH_LOW_WM(1,port), WM_ENABLE);
541
542 vsc_read(mac->adapter, REG_MODE_CFG(port), &val);
543 if (which & MAC_DIRECTION_RX)
544 val |= 0x2;
545 if (which & MAC_DIRECTION_TX)
546 val |= 1;
547 vsc_write(mac->adapter, REG_MODE_CFG(port), val);
548 return 0;
549}
550
551static int mac_disable(struct cmac *mac, int which)
552{
553 u32 val;
554 int i, port = mac->instance->index;
555
556 /* Reset the port, this also writes the correct WM value */
557 mac_reset(mac);
558
559 vsc_read(mac->adapter, REG_MODE_CFG(port), &val);
560 if (which & MAC_DIRECTION_RX)
561 val &= ~0x2;
562 if (which & MAC_DIRECTION_TX)
563 val &= ~0x1;
564 vsc_write(mac->adapter, REG_MODE_CFG(port), val);
565 vsc_read(mac->adapter, REG_MODE_CFG(port), &val);
566
567 /* Clear stats */
568 for (i = 0; i <= 0x3a; ++i)
569 vsc_write(mac->adapter, CRA(4, port, i), 0);
570
571 /* Clear sofware counters */
572 memset(&mac->stats, 0, sizeof(struct cmac_statistics));
573
574 return 0;
575}
576
577static void rmon_update(struct cmac *mac, unsigned int addr, u64 *stat)
578{
579 u32 v, lo;
580
581 vsc_read(mac->adapter, addr, &v);
582 lo = *stat;
583 *stat = *stat - lo + v;
584
585 if (v == 0)
586 return;
587
588 if (v < lo)
589 *stat += (1ULL << 32);
590}
591
592static void port_stats_update(struct cmac *mac)
593{
594 int port = mac->instance->index;
595
596 /* Rx stats */
597 rmon_update(mac, REG_RX_OK_BYTES(port), &mac->stats.RxOctetsOK);
598 rmon_update(mac, REG_RX_BAD_BYTES(port), &mac->stats.RxOctetsBad);
599 rmon_update(mac, REG_RX_UNICAST(port), &mac->stats.RxUnicastFramesOK);
600 rmon_update(mac, REG_RX_MULTICAST(port),
601 &mac->stats.RxMulticastFramesOK);
602 rmon_update(mac, REG_RX_BROADCAST(port),
603 &mac->stats.RxBroadcastFramesOK);
604 rmon_update(mac, REG_CRC(port), &mac->stats.RxFCSErrors);
605 rmon_update(mac, REG_RX_ALIGNMENT(port), &mac->stats.RxAlignErrors);
606 rmon_update(mac, REG_RX_OVERSIZE(port),
607 &mac->stats.RxFrameTooLongErrors);
608 rmon_update(mac, REG_RX_PAUSE(port), &mac->stats.RxPauseFrames);
609 rmon_update(mac, REG_RX_JABBERS(port), &mac->stats.RxJabberErrors);
610 rmon_update(mac, REG_RX_FRAGMENTS(port), &mac->stats.RxRuntErrors);
611 rmon_update(mac, REG_RX_UNDERSIZE(port), &mac->stats.RxRuntErrors);
612 rmon_update(mac, REG_RX_SYMBOL_CARRIER(port),
613 &mac->stats.RxSymbolErrors);
614 rmon_update(mac, REG_RX_SIZE_1519_TO_MAX(port),
615 &mac->stats.RxJumboFramesOK);
616
617 /* Tx stats (skip collision stats as we are full-duplex only) */
618 rmon_update(mac, REG_TX_OK_BYTES(port), &mac->stats.TxOctetsOK);
619 rmon_update(mac, REG_TX_UNICAST(port), &mac->stats.TxUnicastFramesOK);
620 rmon_update(mac, REG_TX_MULTICAST(port),
621 &mac->stats.TxMulticastFramesOK);
622 rmon_update(mac, REG_TX_BROADCAST(port),
623 &mac->stats.TxBroadcastFramesOK);
624 rmon_update(mac, REG_TX_PAUSE(port), &mac->stats.TxPauseFrames);
625 rmon_update(mac, REG_TX_UNDERRUN(port), &mac->stats.TxUnderrun);
626 rmon_update(mac, REG_TX_SIZE_1519_TO_MAX(port),
627 &mac->stats.TxJumboFramesOK);
628}
629
630/*
631 * This function is called periodically to accumulate the current values of the
632 * RMON counters into the port statistics. Since the counters are only 32 bits
633 * some of them can overflow in less than a minute at GigE speeds, so this
634 * function should be called every 30 seconds or so.
635 *
636 * To cut down on reading costs we update only the octet counters at each tick
637 * and do a full update at major ticks, which can be every 30 minutes or more.
638 */
639static const struct cmac_statistics *mac_update_statistics(struct cmac *mac,
640 int flag)
641{
642 if (flag == MAC_STATS_UPDATE_FULL ||
643 mac->instance->ticks >= MAJOR_UPDATE_TICKS) {
644 port_stats_update(mac);
645 mac->instance->ticks = 0;
646 } else {
647 int port = mac->instance->index;
648
649 rmon_update(mac, REG_RX_OK_BYTES(port),
650 &mac->stats.RxOctetsOK);
651 rmon_update(mac, REG_RX_BAD_BYTES(port),
652 &mac->stats.RxOctetsBad);
653 rmon_update(mac, REG_TX_OK_BYTES(port),
654 &mac->stats.TxOctetsOK);
655 mac->instance->ticks++;
656 }
657 return &mac->stats;
658}
659
660static void mac_destroy(struct cmac *mac)
661{
662 kfree(mac);
663}
664
665static struct cmac_ops vsc7326_ops = {
666 .destroy = mac_destroy,
667 .reset = mac_reset,
668 .interrupt_handler = mac_intr_handler,
669 .interrupt_enable = mac_intr_enable,
670 .interrupt_disable = mac_intr_disable,
671 .interrupt_clear = mac_intr_clear,
672 .enable = mac_enable,
673 .disable = mac_disable,
674 .set_mtu = mac_set_mtu,
675 .set_rx_mode = mac_set_rx_mode,
676 .set_speed_duplex_fc = mac_set_speed_duplex_fc,
677 .statistics_update = mac_update_statistics,
678 .macaddress_get = mac_get_address,
679 .macaddress_set = mac_set_address,
680};
681
682static struct cmac *vsc7326_mac_create(adapter_t *adapter, int index)
683{
684 struct cmac *mac;
685 u32 val;
686 int i;
687
688 mac = kzalloc(sizeof(*mac) + sizeof(cmac_instance), GFP_KERNEL);
689 if (!mac) return NULL;
690
691 mac->ops = &vsc7326_ops;
692 mac->instance = (cmac_instance *)(mac + 1);
693 mac->adapter = adapter;
694
695 mac->instance->index = index;
696 mac->instance->ticks = 0;
697
698 i = 0;
699 do {
700 u32 vhi, vlo;
701
702 vhi = vlo = 0;
703 t1_tpi_read(adapter, (REG_LOCAL_STATUS << 2) + 4, &vlo);
704 udelay(1);
705 t1_tpi_read(adapter, REG_LOCAL_STATUS << 2, &vhi);
706 udelay(5);
707 val = (vhi << 16) | vlo;
708 } while ((++i < 10000) && (val == 0xffffffff));
709
710 return mac;
711}
712
713static int vsc7326_mac_reset(adapter_t *adapter)
714{
715 vsc7326_full_reset(adapter);
716 (void) run_bist_all(adapter);
717 run_table(adapter, vsc7326_reset, ARRAY_SIZE(vsc7326_reset));
718 return 0;
719}
720
721struct gmac t1_vsc7326_ops = {
722 .stats_update_period = STATS_TICK_SECS,
723 .create = vsc7326_mac_create,
724 .reset = vsc7326_mac_reset,
725};
diff --git a/drivers/net/chelsio/vsc7326_reg.h b/drivers/net/chelsio/vsc7326_reg.h
new file mode 100644
index 000000000000..491bcf75c4fb
--- /dev/null
+++ b/drivers/net/chelsio/vsc7326_reg.h
@@ -0,0 +1,286 @@
1/* $Date: 2006/04/28 19:20:17 $ $RCSfile: vsc7326_reg.h,v $ $Revision: 1.5 $ */
2#ifndef _VSC7321_REG_H_
3#define _VSC7321_REG_H_
4
5/* Register definitions for Vitesse VSC7321 (Meigs II) MAC
6 *
7 * Straight off the data sheet, VMDS-10038 Rev 2.0 and
8 * PD0011-01-14-Meigs-II 2002-12-12
9 */
10
11/* Just 'cause it's in here doesn't mean it's used. */
12
13#define CRA(blk,sub,adr) ((((blk) & 0x7) << 13) | (((sub) & 0xf) << 9) | (((adr) & 0xff) << 1))
14
15/* System and CPU comm's registers */
16#define REG_CHIP_ID CRA(0x7,0xf,0x00) /* Chip ID */
17#define REG_BLADE_ID CRA(0x7,0xf,0x01) /* Blade ID */
18#define REG_SW_RESET CRA(0x7,0xf,0x02) /* Global Soft Reset */
19#define REG_MEM_BIST CRA(0x7,0xf,0x04) /* mem */
20#define REG_IFACE_MODE CRA(0x7,0xf,0x07) /* Interface mode */
21#define REG_MSCH CRA(0x7,0x2,0x06) /* CRC error count */
22#define REG_CRC_CNT CRA(0x7,0x2,0x0a) /* CRC error count */
23#define REG_CRC_CFG CRA(0x7,0x2,0x0b) /* CRC config */
24#define REG_SI_TRANSFER_SEL CRA(0x7,0xf,0x18) /* SI Transfer Select */
25#define REG_PLL_CLK_SPEED CRA(0x7,0xf,0x19) /* Clock Speed Selection */
26#define REG_SYS_CLK_SELECT CRA(0x7,0xf,0x1c) /* System Clock Select */
27#define REG_GPIO_CTRL CRA(0x7,0xf,0x1d) /* GPIO Control */
28#define REG_GPIO_OUT CRA(0x7,0xf,0x1e) /* GPIO Out */
29#define REG_GPIO_IN CRA(0x7,0xf,0x1f) /* GPIO In */
30#define REG_CPU_TRANSFER_SEL CRA(0x7,0xf,0x20) /* CPU Transfer Select */
31#define REG_LOCAL_DATA CRA(0x7,0xf,0xfe) /* Local CPU Data Register */
32#define REG_LOCAL_STATUS CRA(0x7,0xf,0xff) /* Local CPU Status Register */
33
34/* Aggregator registers */
35#define REG_AGGR_SETUP CRA(0x7,0x1,0x00) /* Aggregator Setup */
36#define REG_PMAP_TABLE CRA(0x7,0x1,0x01) /* Port map table */
37#define REG_MPLS_BIT0 CRA(0x7,0x1,0x08) /* MPLS bit0 position */
38#define REG_MPLS_BIT1 CRA(0x7,0x1,0x09) /* MPLS bit1 position */
39#define REG_MPLS_BIT2 CRA(0x7,0x1,0x0a) /* MPLS bit2 position */
40#define REG_MPLS_BIT3 CRA(0x7,0x1,0x0b) /* MPLS bit3 position */
41#define REG_MPLS_BITMASK CRA(0x7,0x1,0x0c) /* MPLS bit mask */
42#define REG_PRE_BIT0POS CRA(0x7,0x1,0x10) /* Preamble bit0 position */
43#define REG_PRE_BIT1POS CRA(0x7,0x1,0x11) /* Preamble bit1 position */
44#define REG_PRE_BIT2POS CRA(0x7,0x1,0x12) /* Preamble bit2 position */
45#define REG_PRE_BIT3POS CRA(0x7,0x1,0x13) /* Preamble bit3 position */
46#define REG_PRE_ERR_CNT CRA(0x7,0x1,0x14) /* Preamble parity error count */
47
48/* BIST registers */
49/*#define REG_RAM_BIST_CMD CRA(0x7,0x2,0x00)*/ /* RAM BIST Command Register */
50/*#define REG_RAM_BIST_RESULT CRA(0x7,0x2,0x01)*/ /* RAM BIST Read Status/Result */
51#define REG_RAM_BIST_CMD CRA(0x7,0x1,0x00) /* RAM BIST Command Register */
52#define REG_RAM_BIST_RESULT CRA(0x7,0x1,0x01) /* RAM BIST Read Status/Result */
53#define BIST_PORT_SELECT 0x00 /* BIST port select */
54#define BIST_COMMAND 0x01 /* BIST enable/disable */
55#define BIST_STATUS 0x02 /* BIST operation status */
56#define BIST_ERR_CNT_LSB 0x03 /* BIST error count lo 8b */
57#define BIST_ERR_CNT_MSB 0x04 /* BIST error count hi 8b */
58#define BIST_ERR_SEL_LSB 0x05 /* BIST error select lo 8b */
59#define BIST_ERR_SEL_MSB 0x06 /* BIST error select hi 8b */
60#define BIST_ERROR_STATE 0x07 /* BIST engine internal state */
61#define BIST_ERR_ADR0 0x08 /* BIST error address lo 8b */
62#define BIST_ERR_ADR1 0x09 /* BIST error address lomid 8b */
63#define BIST_ERR_ADR2 0x0a /* BIST error address himid 8b */
64#define BIST_ERR_ADR3 0x0b /* BIST error address hi 8b */
65
66/* FIFO registers
67 * ie = 0 for ingress, 1 for egress
68 * fn = FIFO number, 0-9
69 */
70#define REG_TEST(ie,fn) CRA(0x2,ie&1,0x00+fn) /* Mode & Test Register */
71#define REG_TOP_BOTTOM(ie,fn) CRA(0x2,ie&1,0x10+fn) /* FIFO Buffer Top & Bottom */
72#define REG_TAIL(ie,fn) CRA(0x2,ie&1,0x20+fn) /* FIFO Write Pointer */
73#define REG_HEAD(ie,fn) CRA(0x2,ie&1,0x30+fn) /* FIFO Read Pointer */
74#define REG_HIGH_LOW_WM(ie,fn) CRA(0x2,ie&1,0x40+fn) /* Flow Control Water Marks */
75#define REG_CT_THRHLD(ie,fn) CRA(0x2,ie&1,0x50+fn) /* Cut Through Threshold */
76#define REG_FIFO_DROP_CNT(ie,fn) CRA(0x2,ie&1,0x60+fn) /* Drop & CRC Error Counter */
77#define REG_DEBUG_BUF_CNT(ie,fn) CRA(0x2,ie&1,0x70+fn) /* Input Side Debug Counter */
78#define REG_BUCKI(fn) CRA(0x2,2,0x20+fn) /* Input Side Debug Counter */
79#define REG_BUCKE(fn) CRA(0x2,3,0x20+fn) /* Input Side Debug Counter */
80
81/* Traffic shaper buckets
82 * ie = 0 for ingress, 1 for egress
83 * bn = bucket number 0-10 (yes, 11 buckets)
84 */
85/* OK, this one's kinda ugly. Some hardware designers are perverse. */
86#define REG_TRAFFIC_SHAPER_BUCKET(ie,bn) CRA(0x2,ie&1,0x0a + (bn>7) | ((bn&7)<<4))
87#define REG_TRAFFIC_SHAPER_CONTROL(ie) CRA(0x2,ie&1,0x3b)
88
89#define REG_SRAM_ADR(ie) CRA(0x2,ie&1,0x0e) /* FIFO SRAM address */
90#define REG_SRAM_WR_STRB(ie) CRA(0x2,ie&1,0x1e) /* FIFO SRAM write strobe */
91#define REG_SRAM_RD_STRB(ie) CRA(0x2,ie&1,0x2e) /* FIFO SRAM read strobe */
92#define REG_SRAM_DATA_0(ie) CRA(0x2,ie&1,0x3e) /* FIFO SRAM data lo 8b */
93#define REG_SRAM_DATA_1(ie) CRA(0x2,ie&1,0x4e) /* FIFO SRAM data lomid 8b */
94#define REG_SRAM_DATA_2(ie) CRA(0x2,ie&1,0x5e) /* FIFO SRAM data himid 8b */
95#define REG_SRAM_DATA_3(ie) CRA(0x2,ie&1,0x6e) /* FIFO SRAM data hi 8b */
96#define REG_SRAM_DATA_BLK_TYPE(ie) CRA(0x2,ie&1,0x7e) /* FIFO SRAM tag */
97/* REG_ING_CONTROL equals REG_CONTROL with ie = 0, likewise REG_EGR_CONTROL is ie = 1 */
98#define REG_CONTROL(ie) CRA(0x2,ie&1,0x0f) /* FIFO control */
99#define REG_ING_CONTROL CRA(0x2,0x0,0x0f) /* Ingress control (alias) */
100#define REG_EGR_CONTROL CRA(0x2,0x1,0x0f) /* Egress control (alias) */
101#define REG_AGE_TIMER(ie) CRA(0x2,ie&1,0x1f) /* Aging timer */
102#define REG_AGE_INC(ie) CRA(0x2,ie&1,0x2f) /* Aging increment */
103#define DEBUG_OUT(ie) CRA(0x2,ie&1,0x3f) /* Output debug counter control */
104#define DEBUG_CNT(ie) CRA(0x2,ie&1,0x4f) /* Output debug counter */
105
106/* SPI4 interface */
107#define REG_SPI4_MISC CRA(0x5,0x0,0x00) /* Misc Register */
108#define REG_SPI4_STATUS CRA(0x5,0x0,0x01) /* CML Status */
109#define REG_SPI4_ING_SETUP0 CRA(0x5,0x0,0x02) /* Ingress Status Channel Setup */
110#define REG_SPI4_ING_SETUP1 CRA(0x5,0x0,0x03) /* Ingress Data Training Setup */
111#define REG_SPI4_ING_SETUP2 CRA(0x5,0x0,0x04) /* Ingress Data Burst Size Setup */
112#define REG_SPI4_EGR_SETUP0 CRA(0x5,0x0,0x05) /* Egress Status Channel Setup */
113#define REG_SPI4_DBG_CNT(n) CRA(0x5,0x0,0x10+n) /* Debug counters 0-9 */
114#define REG_SPI4_DBG_SETUP CRA(0x5,0x0,0x1A) /* Debug counters setup */
115#define REG_SPI4_TEST CRA(0x5,0x0,0x20) /* Test Setup Register */
116#define REG_TPGEN_UP0 CRA(0x5,0x0,0x21) /* Test Pattern generator user pattern 0 */
117#define REG_TPGEN_UP1 CRA(0x5,0x0,0x22) /* Test Pattern generator user pattern 1 */
118#define REG_TPCHK_UP0 CRA(0x5,0x0,0x23) /* Test Pattern checker user pattern 0 */
119#define REG_TPCHK_UP1 CRA(0x5,0x0,0x24) /* Test Pattern checker user pattern 1 */
120#define REG_TPSAM_P0 CRA(0x5,0x0,0x25) /* Sampled pattern 0 */
121#define REG_TPSAM_P1 CRA(0x5,0x0,0x26) /* Sampled pattern 1 */
122#define REG_TPERR_CNT CRA(0x5,0x0,0x27) /* Pattern checker error counter */
123#define REG_SPI4_STICKY CRA(0x5,0x0,0x30) /* Sticky bits register */
124#define REG_SPI4_DBG_INH CRA(0x5,0x0,0x31) /* Core egress & ingress inhibit */
125#define REG_SPI4_DBG_STATUS CRA(0x5,0x0,0x32) /* Sampled ingress status */
126#define REG_SPI4_DBG_GRANT CRA(0x5,0x0,0x33) /* Ingress cranted credit value */
127
128#define REG_SPI4_DESKEW CRA(0x5,0x0,0x43) /* Ingress cranted credit value */
129
130/* 10GbE MAC Block Registers */
131/* Note that those registers that are exactly the same for 10GbE as for
132 * tri-speed are only defined with the version that needs a port number.
133 * Pass 0xa in those cases.
134 *
135 * Also note that despite the presence of a MAC address register, this part
136 * does no ingress MAC address filtering. That register is used only for
137 * pause frame detection and generation.
138 */
139/* 10GbE specific, and different from tri-speed */
140#define REG_MISC_10G CRA(0x1,0xa,0x00) /* Misc 10GbE setup */
141#define REG_PAUSE_10G CRA(0x1,0xa,0x01) /* Pause register */
142#define REG_NORMALIZER_10G CRA(0x1,0xa,0x05) /* 10G normalizer */
143#define REG_STICKY_RX CRA(0x1,0xa,0x06) /* RX debug register */
144#define REG_DENORM_10G CRA(0x1,0xa,0x07) /* Denormalizer */
145#define REG_STICKY_TX CRA(0x1,0xa,0x08) /* TX sticky bits */
146#define REG_MAX_RXHIGH CRA(0x1,0xa,0x0a) /* XGMII lane 0-3 debug */
147#define REG_MAX_RXLOW CRA(0x1,0xa,0x0b) /* XGMII lane 4-7 debug */
148#define REG_MAC_TX_STICKY CRA(0x1,0xa,0x0c) /* MAC Tx state sticky debug */
149#define REG_MAC_TX_RUNNING CRA(0x1,0xa,0x0d) /* MAC Tx state running debug */
150#define REG_TX_ABORT_AGE CRA(0x1,0xa,0x14) /* Aged Tx frames discarded */
151#define REG_TX_ABORT_SHORT CRA(0x1,0xa,0x15) /* Short Tx frames discarded */
152#define REG_TX_ABORT_TAXI CRA(0x1,0xa,0x16) /* Taxi error frames discarded */
153#define REG_TX_ABORT_UNDERRUN CRA(0x1,0xa,0x17) /* Tx Underrun abort counter */
154#define REG_TX_DENORM_DISCARD CRA(0x1,0xa,0x18) /* Tx denormalizer discards */
155#define REG_XAUI_STAT_A CRA(0x1,0xa,0x20) /* XAUI status A */
156#define REG_XAUI_STAT_B CRA(0x1,0xa,0x21) /* XAUI status B */
157#define REG_XAUI_STAT_C CRA(0x1,0xa,0x22) /* XAUI status C */
158#define REG_XAUI_CONF_A CRA(0x1,0xa,0x23) /* XAUI configuration A */
159#define REG_XAUI_CONF_B CRA(0x1,0xa,0x24) /* XAUI configuration B */
160#define REG_XAUI_CODE_GRP_CNT CRA(0x1,0xa,0x25) /* XAUI code group error count */
161#define REG_XAUI_CONF_TEST_A CRA(0x1,0xa,0x26) /* XAUI test register A */
162#define REG_PDERRCNT CRA(0x1,0xa,0x27) /* XAUI test register B */
163
164/* pn = port number 0-9 for tri-speed, 10 for 10GbE */
165/* Both tri-speed and 10GbE */
166#define REG_MAX_LEN(pn) CRA(0x1,pn,0x02) /* Max length */
167#define REG_MAC_HIGH_ADDR(pn) CRA(0x1,pn,0x03) /* Upper 24 bits of MAC addr */
168#define REG_MAC_LOW_ADDR(pn) CRA(0x1,pn,0x04) /* Lower 24 bits of MAC addr */
169
170/* tri-speed only
171 * pn = port number, 0-9
172 */
173#define REG_MODE_CFG(pn) CRA(0x1,pn,0x00) /* Mode configuration */
174#define REG_PAUSE_CFG(pn) CRA(0x1,pn,0x01) /* Pause configuration */
175#define REG_NORMALIZER(pn) CRA(0x1,pn,0x05) /* Normalizer */
176#define REG_TBI_STATUS(pn) CRA(0x1,pn,0x06) /* TBI status */
177#define REG_PCS_STATUS_DBG(pn) CRA(0x1,pn,0x07) /* PCS status debug */
178#define REG_PCS_CTRL(pn) CRA(0x1,pn,0x08) /* PCS control */
179#define REG_TBI_CONFIG(pn) CRA(0x1,pn,0x09) /* TBI configuration */
180#define REG_STICK_BIT(pn) CRA(0x1,pn,0x0a) /* Sticky bits */
181#define REG_DEV_SETUP(pn) CRA(0x1,pn,0x0b) /* MAC clock/reset setup */
182#define REG_DROP_CNT(pn) CRA(0x1,pn,0x0c) /* Drop counter */
183#define REG_PORT_POS(pn) CRA(0x1,pn,0x0d) /* Preamble port position */
184#define REG_PORT_FAIL(pn) CRA(0x1,pn,0x0e) /* Preamble port position */
185#define REG_SERDES_CONF(pn) CRA(0x1,pn,0x0f) /* SerDes configuration */
186#define REG_SERDES_TEST(pn) CRA(0x1,pn,0x10) /* SerDes test */
187#define REG_SERDES_STAT(pn) CRA(0x1,pn,0x11) /* SerDes status */
188#define REG_SERDES_COM_CNT(pn) CRA(0x1,pn,0x12) /* SerDes comma counter */
189#define REG_DENORM(pn) CRA(0x1,pn,0x15) /* Frame denormalization */
190#define REG_DBG(pn) CRA(0x1,pn,0x16) /* Device 1G debug */
191#define REG_TX_IFG(pn) CRA(0x1,pn,0x18) /* Tx IFG config */
192#define REG_HDX(pn) CRA(0x1,pn,0x19) /* Half-duplex config */
193
194/* Statistics */
195/* pn = port number, 0-a, a = 10GbE */
196#define REG_RX_IN_BYTES(pn) CRA(0x4,pn,0x00) /* # Rx in octets */
197#define REG_RX_SYMBOL_CARRIER(pn) CRA(0x4,pn,0x01) /* Frames w/ symbol errors */
198#define REG_RX_PAUSE(pn) CRA(0x4,pn,0x02) /* # pause frames received */
199#define REG_RX_UNSUP_OPCODE(pn) CRA(0x4,pn,0x03) /* # control frames with unsupported opcode */
200#define REG_RX_OK_BYTES(pn) CRA(0x4,pn,0x04) /* # octets in good frames */
201#define REG_RX_BAD_BYTES(pn) CRA(0x4,pn,0x05) /* # octets in bad frames */
202#define REG_RX_UNICAST(pn) CRA(0x4,pn,0x06) /* # good unicast frames */
203#define REG_RX_MULTICAST(pn) CRA(0x4,pn,0x07) /* # good multicast frames */
204#define REG_RX_BROADCAST(pn) CRA(0x4,pn,0x08) /* # good broadcast frames */
205#define REG_CRC(pn) CRA(0x4,pn,0x09) /* # frames w/ bad CRC only */
206#define REG_RX_ALIGNMENT(pn) CRA(0x4,pn,0x0a) /* # frames w/ alignment err */
207#define REG_RX_UNDERSIZE(pn) CRA(0x4,pn,0x0b) /* # frames undersize */
208#define REG_RX_FRAGMENTS(pn) CRA(0x4,pn,0x0c) /* # frames undersize w/ crc err */
209#define REG_RX_IN_RANGE_LENGTH_ERROR(pn) CRA(0x4,pn,0x0d) /* # frames with length error */
210#define REG_RX_OUT_OF_RANGE_ERROR(pn) CRA(0x4,pn,0x0e) /* # frames with illegal length field */
211#define REG_RX_OVERSIZE(pn) CRA(0x4,pn,0x0f) /* # frames oversize */
212#define REG_RX_JABBERS(pn) CRA(0x4,pn,0x10) /* # frames oversize w/ crc err */
213#define REG_RX_SIZE_64(pn) CRA(0x4,pn,0x11) /* # frames 64 octets long */
214#define REG_RX_SIZE_65_TO_127(pn) CRA(0x4,pn,0x12) /* # frames 65-127 octets */
215#define REG_RX_SIZE_128_TO_255(pn) CRA(0x4,pn,0x13) /* # frames 128-255 */
216#define REG_RX_SIZE_256_TO_511(pn) CRA(0x4,pn,0x14) /* # frames 256-511 */
217#define REG_RX_SIZE_512_TO_1023(pn) CRA(0x4,pn,0x15) /* # frames 512-1023 */
218#define REG_RX_SIZE_1024_TO_1518(pn) CRA(0x4,pn,0x16) /* # frames 1024-1518 */
219#define REG_RX_SIZE_1519_TO_MAX(pn) CRA(0x4,pn,0x17) /* # frames 1519-max */
220
221#define REG_TX_OUT_BYTES(pn) CRA(0x4,pn,0x18) /* # octets tx */
222#define REG_TX_PAUSE(pn) CRA(0x4,pn,0x19) /* # pause frames sent */
223#define REG_TX_OK_BYTES(pn) CRA(0x4,pn,0x1a) /* # octets tx OK */
224#define REG_TX_UNICAST(pn) CRA(0x4,pn,0x1b) /* # frames unicast */
225#define REG_TX_MULTICAST(pn) CRA(0x4,pn,0x1c) /* # frames multicast */
226#define REG_TX_BROADCAST(pn) CRA(0x4,pn,0x1d) /* # frames broadcast */
227#define REG_TX_MULTIPLE_COLL(pn) CRA(0x4,pn,0x1e) /* # frames tx after multiple collisions */
228#define REG_TX_LATE_COLL(pn) CRA(0x4,pn,0x1f) /* # late collisions detected */
229#define REG_TX_XCOLL(pn) CRA(0x4,pn,0x20) /* # frames lost, excessive collisions */
230#define REG_TX_DEFER(pn) CRA(0x4,pn,0x21) /* # frames deferred on first tx attempt */
231#define REG_TX_XDEFER(pn) CRA(0x4,pn,0x22) /* # frames excessively deferred */
232#define REG_TX_CSENSE(pn) CRA(0x4,pn,0x23) /* carrier sense errors at frame end */
233#define REG_TX_SIZE_64(pn) CRA(0x4,pn,0x24) /* # frames 64 octets long */
234#define REG_TX_SIZE_65_TO_127(pn) CRA(0x4,pn,0x25) /* # frames 65-127 octets */
235#define REG_TX_SIZE_128_TO_255(pn) CRA(0x4,pn,0x26) /* # frames 128-255 */
236#define REG_TX_SIZE_256_TO_511(pn) CRA(0x4,pn,0x27) /* # frames 256-511 */
237#define REG_TX_SIZE_512_TO_1023(pn) CRA(0x4,pn,0x28) /* # frames 512-1023 */
238#define REG_TX_SIZE_1024_TO_1518(pn) CRA(0x4,pn,0x29) /* # frames 1024-1518 */
239#define REG_TX_SIZE_1519_TO_MAX(pn) CRA(0x4,pn,0x2a) /* # frames 1519-max */
240#define REG_TX_SINGLE_COLL(pn) CRA(0x4,pn,0x2b) /* # frames tx after single collision */
241#define REG_TX_BACKOFF2(pn) CRA(0x4,pn,0x2c) /* # frames tx ok after 2 backoffs/collisions */
242#define REG_TX_BACKOFF3(pn) CRA(0x4,pn,0x2d) /* after 3 backoffs/collisions */
243#define REG_TX_BACKOFF4(pn) CRA(0x4,pn,0x2e) /* after 4 */
244#define REG_TX_BACKOFF5(pn) CRA(0x4,pn,0x2f) /* after 5 */
245#define REG_TX_BACKOFF6(pn) CRA(0x4,pn,0x30) /* after 6 */
246#define REG_TX_BACKOFF7(pn) CRA(0x4,pn,0x31) /* after 7 */
247#define REG_TX_BACKOFF8(pn) CRA(0x4,pn,0x32) /* after 8 */
248#define REG_TX_BACKOFF9(pn) CRA(0x4,pn,0x33) /* after 9 */
249#define REG_TX_BACKOFF10(pn) CRA(0x4,pn,0x34) /* after 10 */
250#define REG_TX_BACKOFF11(pn) CRA(0x4,pn,0x35) /* after 11 */
251#define REG_TX_BACKOFF12(pn) CRA(0x4,pn,0x36) /* after 12 */
252#define REG_TX_BACKOFF13(pn) CRA(0x4,pn,0x37) /* after 13 */
253#define REG_TX_BACKOFF14(pn) CRA(0x4,pn,0x38) /* after 14 */
254#define REG_TX_BACKOFF15(pn) CRA(0x4,pn,0x39) /* after 15 */
255#define REG_TX_UNDERRUN(pn) CRA(0x4,pn,0x3a) /* # frames dropped from underrun */
256#define REG_RX_XGMII_PROT_ERR CRA(0x4,0xa,0x3b) /* # protocol errors detected on XGMII interface */
257#define REG_RX_IPG_SHRINK(pn) CRA(0x4,pn,0x3c) /* # of IPG shrinks detected */
258
259#define REG_STAT_STICKY1G(pn) CRA(0x4,pn,0x3e) /* tri-speed sticky bits */
260#define REG_STAT_STICKY10G CRA(0x4,0xa,0x3e) /* 10GbE sticky bits */
261#define REG_STAT_INIT(pn) CRA(0x4,pn,0x3f) /* Clear all statistics */
262
263/* MII-Management Block registers */
264/* These are for MII-M interface 0, which is the bidirectional LVTTL one. If
265 * we hooked up to the one with separate directions, the middle 0x0 needs to
266 * change to 0x1. And the current errata states that MII-M 1 doesn't work.
267 */
268
269#define REG_MIIM_STATUS CRA(0x3,0x0,0x00) /* MII-M Status */
270#define REG_MIIM_CMD CRA(0x3,0x0,0x01) /* MII-M Command */
271#define REG_MIIM_DATA CRA(0x3,0x0,0x02) /* MII-M Data */
272#define REG_MIIM_PRESCALE CRA(0x3,0x0,0x03) /* MII-M MDC Prescale */
273
274#define REG_ING_FFILT_UM_EN CRA(0x2, 0, 0xd)
275#define REG_ING_FFILT_BE_EN CRA(0x2, 0, 0x1d)
276#define REG_ING_FFILT_VAL0 CRA(0x2, 0, 0x2d)
277#define REG_ING_FFILT_VAL1 CRA(0x2, 0, 0x3d)
278#define REG_ING_FFILT_MASK0 CRA(0x2, 0, 0x4d)
279#define REG_ING_FFILT_MASK1 CRA(0x2, 0, 0x5d)
280#define REG_ING_FFILT_MASK2 CRA(0x2, 0, 0x6d)
281#define REG_ING_FFILT_ETYPE CRA(0x2, 0, 0x7d)
282
283
284/* Whew. */
285
286#endif
diff --git a/drivers/net/chelsio/vsc8244.c b/drivers/net/chelsio/vsc8244.c
new file mode 100644
index 000000000000..c493e783d459
--- /dev/null
+++ b/drivers/net/chelsio/vsc8244.c
@@ -0,0 +1,368 @@
1/*
2 * This file is part of the Chelsio T2 Ethernet driver.
3 *
4 * Copyright (C) 2005 Chelsio Communications. All rights reserved.
5 *
6 * This program is distributed in the hope that it will be useful, but WITHOUT
7 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8 * FITNESS FOR A PARTICULAR PURPOSE. See the LICENSE file included in this
9 * release for licensing terms and conditions.
10 */
11
12#include "common.h"
13#include "cphy.h"
14#include "elmer0.h"
15
16#ifndef ADVERTISE_PAUSE_CAP
17# define ADVERTISE_PAUSE_CAP 0x400
18#endif
19#ifndef ADVERTISE_PAUSE_ASYM
20# define ADVERTISE_PAUSE_ASYM 0x800
21#endif
22
23/* Gigabit MII registers */
24#ifndef MII_CTRL1000
25# define MII_CTRL1000 9
26#endif
27
28#ifndef ADVERTISE_1000FULL
29# define ADVERTISE_1000FULL 0x200
30# define ADVERTISE_1000HALF 0x100
31#endif
32
33/* VSC8244 PHY specific registers. */
34enum {
35 VSC8244_INTR_ENABLE = 25,
36 VSC8244_INTR_STATUS = 26,
37 VSC8244_AUX_CTRL_STAT = 28,
38};
39
40enum {
41 VSC_INTR_RX_ERR = 1 << 0,
42 VSC_INTR_MS_ERR = 1 << 1, /* master/slave resolution error */
43 VSC_INTR_CABLE = 1 << 2, /* cable impairment */
44 VSC_INTR_FALSE_CARR = 1 << 3, /* false carrier */
45 VSC_INTR_MEDIA_CHG = 1 << 4, /* AMS media change */
46 VSC_INTR_RX_FIFO = 1 << 5, /* Rx FIFO over/underflow */
47 VSC_INTR_TX_FIFO = 1 << 6, /* Tx FIFO over/underflow */
48 VSC_INTR_DESCRAMBL = 1 << 7, /* descrambler lock-lost */
49 VSC_INTR_SYMBOL_ERR = 1 << 8, /* symbol error */
50 VSC_INTR_NEG_DONE = 1 << 10, /* autoneg done */
51 VSC_INTR_NEG_ERR = 1 << 11, /* autoneg error */
52 VSC_INTR_LINK_CHG = 1 << 13, /* link change */
53 VSC_INTR_ENABLE = 1 << 15, /* interrupt enable */
54};
55
56#define CFG_CHG_INTR_MASK (VSC_INTR_LINK_CHG | VSC_INTR_NEG_ERR | \
57 VSC_INTR_NEG_DONE)
58#define INTR_MASK (CFG_CHG_INTR_MASK | VSC_INTR_TX_FIFO | VSC_INTR_RX_FIFO | \
59 VSC_INTR_ENABLE)
60
61/* PHY specific auxiliary control & status register fields */
62#define S_ACSR_ACTIPHY_TMR 0
63#define M_ACSR_ACTIPHY_TMR 0x3
64#define V_ACSR_ACTIPHY_TMR(x) ((x) << S_ACSR_ACTIPHY_TMR)
65
66#define S_ACSR_SPEED 3
67#define M_ACSR_SPEED 0x3
68#define G_ACSR_SPEED(x) (((x) >> S_ACSR_SPEED) & M_ACSR_SPEED)
69
70#define S_ACSR_DUPLEX 5
71#define F_ACSR_DUPLEX (1 << S_ACSR_DUPLEX)
72
73#define S_ACSR_ACTIPHY 6
74#define F_ACSR_ACTIPHY (1 << S_ACSR_ACTIPHY)
75
76/*
77 * Reset the PHY. This PHY completes reset immediately so we never wait.
78 */
79static int vsc8244_reset(struct cphy *cphy, int wait)
80{
81 int err;
82 unsigned int ctl;
83
84 err = simple_mdio_read(cphy, MII_BMCR, &ctl);
85 if (err)
86 return err;
87
88 ctl &= ~BMCR_PDOWN;
89 ctl |= BMCR_RESET;
90 return simple_mdio_write(cphy, MII_BMCR, ctl);
91}
92
93static int vsc8244_intr_enable(struct cphy *cphy)
94{
95 simple_mdio_write(cphy, VSC8244_INTR_ENABLE, INTR_MASK);
96
97 /* Enable interrupts through Elmer */
98 if (t1_is_asic(cphy->adapter)) {
99 u32 elmer;
100
101 t1_tpi_read(cphy->adapter, A_ELMER0_INT_ENABLE, &elmer);
102 elmer |= ELMER0_GP_BIT1;
103 if (is_T2(cphy->adapter)) {
104 elmer |= ELMER0_GP_BIT2|ELMER0_GP_BIT3|ELMER0_GP_BIT4;
105 }
106 t1_tpi_write(cphy->adapter, A_ELMER0_INT_ENABLE, elmer);
107 }
108
109 return 0;
110}
111
112static int vsc8244_intr_disable(struct cphy *cphy)
113{
114 simple_mdio_write(cphy, VSC8244_INTR_ENABLE, 0);
115
116 if (t1_is_asic(cphy->adapter)) {
117 u32 elmer;
118
119 t1_tpi_read(cphy->adapter, A_ELMER0_INT_ENABLE, &elmer);
120 elmer &= ~ELMER0_GP_BIT1;
121 if (is_T2(cphy->adapter)) {
122 elmer &= ~(ELMER0_GP_BIT2|ELMER0_GP_BIT3|ELMER0_GP_BIT4);
123 }
124 t1_tpi_write(cphy->adapter, A_ELMER0_INT_ENABLE, elmer);
125 }
126
127 return 0;
128}
129
130static int vsc8244_intr_clear(struct cphy *cphy)
131{
132 u32 val;
133 u32 elmer;
134
135 /* Clear PHY interrupts by reading the register. */
136 simple_mdio_read(cphy, VSC8244_INTR_ENABLE, &val);
137
138 if (t1_is_asic(cphy->adapter)) {
139 t1_tpi_read(cphy->adapter, A_ELMER0_INT_CAUSE, &elmer);
140 elmer |= ELMER0_GP_BIT1;
141 if (is_T2(cphy->adapter)) {
142 elmer |= ELMER0_GP_BIT2|ELMER0_GP_BIT3|ELMER0_GP_BIT4;
143 }
144 t1_tpi_write(cphy->adapter, A_ELMER0_INT_CAUSE, elmer);
145 }
146
147 return 0;
148}
149
150/*
151 * Force the PHY speed and duplex. This also disables auto-negotiation, except
152 * for 1Gb/s, where auto-negotiation is mandatory.
153 */
154static int vsc8244_set_speed_duplex(struct cphy *phy, int speed, int duplex)
155{
156 int err;
157 unsigned int ctl;
158
159 err = simple_mdio_read(phy, MII_BMCR, &ctl);
160 if (err)
161 return err;
162
163 if (speed >= 0) {
164 ctl &= ~(BMCR_SPEED100 | BMCR_SPEED1000 | BMCR_ANENABLE);
165 if (speed == SPEED_100)
166 ctl |= BMCR_SPEED100;
167 else if (speed == SPEED_1000)
168 ctl |= BMCR_SPEED1000;
169 }
170 if (duplex >= 0) {
171 ctl &= ~(BMCR_FULLDPLX | BMCR_ANENABLE);
172 if (duplex == DUPLEX_FULL)
173 ctl |= BMCR_FULLDPLX;
174 }
175 if (ctl & BMCR_SPEED1000) /* auto-negotiation required for 1Gb/s */
176 ctl |= BMCR_ANENABLE;
177 return simple_mdio_write(phy, MII_BMCR, ctl);
178}
179
180int t1_mdio_set_bits(struct cphy *phy, int mmd, int reg, unsigned int bits)
181{
182 int ret;
183 unsigned int val;
184
185 ret = mdio_read(phy, mmd, reg, &val);
186 if (!ret)
187 ret = mdio_write(phy, mmd, reg, val | bits);
188 return ret;
189}
190
191static int vsc8244_autoneg_enable(struct cphy *cphy)
192{
193 return t1_mdio_set_bits(cphy, 0, MII_BMCR,
194 BMCR_ANENABLE | BMCR_ANRESTART);
195}
196
197static int vsc8244_autoneg_restart(struct cphy *cphy)
198{
199 return t1_mdio_set_bits(cphy, 0, MII_BMCR, BMCR_ANRESTART);
200}
201
202static int vsc8244_advertise(struct cphy *phy, unsigned int advertise_map)
203{
204 int err;
205 unsigned int val = 0;
206
207 err = simple_mdio_read(phy, MII_CTRL1000, &val);
208 if (err)
209 return err;
210
211 val &= ~(ADVERTISE_1000HALF | ADVERTISE_1000FULL);
212 if (advertise_map & ADVERTISED_1000baseT_Half)
213 val |= ADVERTISE_1000HALF;
214 if (advertise_map & ADVERTISED_1000baseT_Full)
215 val |= ADVERTISE_1000FULL;
216
217 err = simple_mdio_write(phy, MII_CTRL1000, val);
218 if (err)
219 return err;
220
221 val = 1;
222 if (advertise_map & ADVERTISED_10baseT_Half)
223 val |= ADVERTISE_10HALF;
224 if (advertise_map & ADVERTISED_10baseT_Full)
225 val |= ADVERTISE_10FULL;
226 if (advertise_map & ADVERTISED_100baseT_Half)
227 val |= ADVERTISE_100HALF;
228 if (advertise_map & ADVERTISED_100baseT_Full)
229 val |= ADVERTISE_100FULL;
230 if (advertise_map & ADVERTISED_PAUSE)
231 val |= ADVERTISE_PAUSE_CAP;
232 if (advertise_map & ADVERTISED_ASYM_PAUSE)
233 val |= ADVERTISE_PAUSE_ASYM;
234 return simple_mdio_write(phy, MII_ADVERTISE, val);
235}
236
237static int vsc8244_get_link_status(struct cphy *cphy, int *link_ok,
238 int *speed, int *duplex, int *fc)
239{
240 unsigned int bmcr, status, lpa, adv;
241 int err, sp = -1, dplx = -1, pause = 0;
242
243 err = simple_mdio_read(cphy, MII_BMCR, &bmcr);
244 if (!err)
245 err = simple_mdio_read(cphy, MII_BMSR, &status);
246 if (err)
247 return err;
248
249 if (link_ok) {
250 /*
251 * BMSR_LSTATUS is latch-low, so if it is 0 we need to read it
252 * once more to get the current link state.
253 */
254 if (!(status & BMSR_LSTATUS))
255 err = simple_mdio_read(cphy, MII_BMSR, &status);
256 if (err)
257 return err;
258 *link_ok = (status & BMSR_LSTATUS) != 0;
259 }
260 if (!(bmcr & BMCR_ANENABLE)) {
261 dplx = (bmcr & BMCR_FULLDPLX) ? DUPLEX_FULL : DUPLEX_HALF;
262 if (bmcr & BMCR_SPEED1000)
263 sp = SPEED_1000;
264 else if (bmcr & BMCR_SPEED100)
265 sp = SPEED_100;
266 else
267 sp = SPEED_10;
268 } else if (status & BMSR_ANEGCOMPLETE) {
269 err = simple_mdio_read(cphy, VSC8244_AUX_CTRL_STAT, &status);
270 if (err)
271 return err;
272
273 dplx = (status & F_ACSR_DUPLEX) ? DUPLEX_FULL : DUPLEX_HALF;
274 sp = G_ACSR_SPEED(status);
275 if (sp == 0)
276 sp = SPEED_10;
277 else if (sp == 1)
278 sp = SPEED_100;
279 else
280 sp = SPEED_1000;
281
282 if (fc && dplx == DUPLEX_FULL) {
283 err = simple_mdio_read(cphy, MII_LPA, &lpa);
284 if (!err)
285 err = simple_mdio_read(cphy, MII_ADVERTISE,
286 &adv);
287 if (err)
288 return err;
289
290 if (lpa & adv & ADVERTISE_PAUSE_CAP)
291 pause = PAUSE_RX | PAUSE_TX;
292 else if ((lpa & ADVERTISE_PAUSE_CAP) &&
293 (lpa & ADVERTISE_PAUSE_ASYM) &&
294 (adv & ADVERTISE_PAUSE_ASYM))
295 pause = PAUSE_TX;
296 else if ((lpa & ADVERTISE_PAUSE_ASYM) &&
297 (adv & ADVERTISE_PAUSE_CAP))
298 pause = PAUSE_RX;
299 }
300 }
301 if (speed)
302 *speed = sp;
303 if (duplex)
304 *duplex = dplx;
305 if (fc)
306 *fc = pause;
307 return 0;
308}
309
310static int vsc8244_intr_handler(struct cphy *cphy)
311{
312 unsigned int cause;
313 int err, cphy_cause = 0;
314
315 err = simple_mdio_read(cphy, VSC8244_INTR_STATUS, &cause);
316 if (err)
317 return err;
318
319 cause &= INTR_MASK;
320 if (cause & CFG_CHG_INTR_MASK)
321 cphy_cause |= cphy_cause_link_change;
322 if (cause & (VSC_INTR_RX_FIFO | VSC_INTR_TX_FIFO))
323 cphy_cause |= cphy_cause_fifo_error;
324 return cphy_cause;
325}
326
327static void vsc8244_destroy(struct cphy *cphy)
328{
329 kfree(cphy);
330}
331
332static struct cphy_ops vsc8244_ops = {
333 .destroy = vsc8244_destroy,
334 .reset = vsc8244_reset,
335 .interrupt_enable = vsc8244_intr_enable,
336 .interrupt_disable = vsc8244_intr_disable,
337 .interrupt_clear = vsc8244_intr_clear,
338 .interrupt_handler = vsc8244_intr_handler,
339 .autoneg_enable = vsc8244_autoneg_enable,
340 .autoneg_restart = vsc8244_autoneg_restart,
341 .advertise = vsc8244_advertise,
342 .set_speed_duplex = vsc8244_set_speed_duplex,
343 .get_link_status = vsc8244_get_link_status
344};
345
346static struct cphy* vsc8244_phy_create(adapter_t *adapter, int phy_addr, struct mdio_ops *mdio_ops)
347{
348 struct cphy *cphy = kzalloc(sizeof(*cphy), GFP_KERNEL);
349
350 if (!cphy) return NULL;
351
352 cphy_init(cphy, adapter, phy_addr, &vsc8244_ops, mdio_ops);
353
354 return cphy;
355}
356
357
358static int vsc8244_phy_reset(adapter_t* adapter)
359{
360 return 0;
361}
362
363struct gphy t1_vsc8244_ops = {
364 vsc8244_phy_create,
365 vsc8244_phy_reset
366};
367
368
diff --git a/drivers/net/chelsio/vsc8244_reg.h b/drivers/net/chelsio/vsc8244_reg.h
new file mode 100644
index 000000000000..d3c1829055cb
--- /dev/null
+++ b/drivers/net/chelsio/vsc8244_reg.h
@@ -0,0 +1,172 @@
1/* $Date: 2005/11/23 16:28:53 $ $RCSfile: vsc8244_reg.h,v $ $Revision: 1.1 $ */
2#ifndef CHELSIO_MV8E1XXX_H
3#define CHELSIO_MV8E1XXX_H
4
5#ifndef BMCR_SPEED1000
6# define BMCR_SPEED1000 0x40
7#endif
8
9#ifndef ADVERTISE_PAUSE
10# define ADVERTISE_PAUSE 0x400
11#endif
12#ifndef ADVERTISE_PAUSE_ASYM
13# define ADVERTISE_PAUSE_ASYM 0x800
14#endif
15
16/* Gigabit MII registers */
17#define MII_GBMR 1 /* 1000Base-T mode register */
18#define MII_GBCR 9 /* 1000Base-T control register */
19#define MII_GBSR 10 /* 1000Base-T status register */
20
21/* 1000Base-T control register fields */
22#define GBCR_ADV_1000HALF 0x100
23#define GBCR_ADV_1000FULL 0x200
24#define GBCR_PREFER_MASTER 0x400
25#define GBCR_MANUAL_AS_MASTER 0x800
26#define GBCR_MANUAL_CONFIG_ENABLE 0x1000
27
28/* 1000Base-T status register fields */
29#define GBSR_LP_1000HALF 0x400
30#define GBSR_LP_1000FULL 0x800
31#define GBSR_REMOTE_OK 0x1000
32#define GBSR_LOCAL_OK 0x2000
33#define GBSR_LOCAL_MASTER 0x4000
34#define GBSR_MASTER_FAULT 0x8000
35
36/* Vitesse PHY interrupt status bits. */
37#if 0
38#define VSC8244_INTR_JABBER 0x0001
39#define VSC8244_INTR_POLARITY_CHNG 0x0002
40#define VSC8244_INTR_ENG_DETECT_CHNG 0x0010
41#define VSC8244_INTR_DOWNSHIFT 0x0020
42#define VSC8244_INTR_MDI_XOVER_CHNG 0x0040
43#define VSC8244_INTR_FIFO_OVER_UNDER 0x0080
44#define VSC8244_INTR_FALSE_CARRIER 0x0100
45#define VSC8244_INTR_SYMBOL_ERROR 0x0200
46#define VSC8244_INTR_LINK_CHNG 0x0400
47#define VSC8244_INTR_AUTONEG_DONE 0x0800
48#define VSC8244_INTR_PAGE_RECV 0x1000
49#define VSC8244_INTR_DUPLEX_CHNG 0x2000
50#define VSC8244_INTR_SPEED_CHNG 0x4000
51#define VSC8244_INTR_AUTONEG_ERR 0x8000
52#else
53//#define VSC8244_INTR_JABBER 0x0001
54//#define VSC8244_INTR_POLARITY_CHNG 0x0002
55//#define VSC8244_INTR_BIT2 0x0004
56//#define VSC8244_INTR_BIT3 0x0008
57#define VSC8244_INTR_RX_ERR 0x0001
58#define VSC8244_INTR_MASTER_SLAVE 0x0002
59#define VSC8244_INTR_CABLE_IMPAIRED 0x0004
60#define VSC8244_INTR_FALSE_CARRIER 0x0008
61//#define VSC8244_INTR_ENG_DETECT_CHNG 0x0010
62//#define VSC8244_INTR_DOWNSHIFT 0x0020
63//#define VSC8244_INTR_MDI_XOVER_CHNG 0x0040
64//#define VSC8244_INTR_FIFO_OVER_UNDER 0x0080
65#define VSC8244_INTR_BIT4 0x0010
66#define VSC8244_INTR_FIFO_RX 0x0020
67#define VSC8244_INTR_FIFO_OVER_UNDER 0x0040
68#define VSC8244_INTR_LOCK_LOST 0x0080
69//#define VSC8244_INTR_FALSE_CARRIER 0x0100
70//#define VSC8244_INTR_SYMBOL_ERROR 0x0200
71//#define VSC8244_INTR_LINK_CHNG 0x0400
72//#define VSC8244_INTR_AUTONEG_DONE 0x0800
73#define VSC8244_INTR_SYMBOL_ERROR 0x0100
74#define VSC8244_INTR_ENG_DETECT_CHNG 0x0200
75#define VSC8244_INTR_AUTONEG_DONE 0x0400
76#define VSC8244_INTR_AUTONEG_ERR 0x0800
77//#define VSC8244_INTR_PAGE_RECV 0x1000
78//#define VSC8244_INTR_DUPLEX_CHNG 0x2000
79//#define VSC8244_INTR_SPEED_CHNG 0x4000
80//#define VSC8244_INTR_AUTONEG_ERR 0x8000
81#define VSC8244_INTR_DUPLEX_CHNG 0x1000
82#define VSC8244_INTR_LINK_CHNG 0x2000
83#define VSC8244_INTR_SPEED_CHNG 0x4000
84#define VSC8244_INTR_STATUS 0x8000
85#endif
86
87
88/* Vitesse PHY specific registers. */
89#define VSC8244_SPECIFIC_CNTRL_REGISTER 16
90#define VSC8244_SPECIFIC_STATUS_REGISTER 0x1c
91#define VSC8244_INTERRUPT_ENABLE_REGISTER 0x19
92#define VSC8244_INTERRUPT_STATUS_REGISTER 0x1a
93#define VSC8244_EXT_PHY_SPECIFIC_CNTRL_REGISTER 20
94#define VSC8244_RECV_ERR_CNTR_REGISTER 21
95#define VSC8244_RES_REGISTER 22
96#define VSC8244_GLOBAL_STATUS_REGISTER 23
97#define VSC8244_LED_CONTROL_REGISTER 24
98#define VSC8244_MANUAL_LED_OVERRIDE_REGISTER 25
99#define VSC8244_EXT_PHY_SPECIFIC_CNTRL_2_REGISTER 26
100#define VSC8244_EXT_PHY_SPECIFIC_STATUS_REGISTER 27
101#define VSC8244_VIRTUAL_CABLE_TESTER_REGISTER 28
102#define VSC8244_EXTENDED_ADDR_REGISTER 29
103#define VSC8244_EXTENDED_REGISTER 30
104
105/* PHY specific control register fields */
106#define S_PSCR_MDI_XOVER_MODE 5
107#define M_PSCR_MDI_XOVER_MODE 0x3
108#define V_PSCR_MDI_XOVER_MODE(x) ((x) << S_PSCR_MDI_XOVER_MODE)
109#define G_PSCR_MDI_XOVER_MODE(x) (((x) >> S_PSCR_MDI_XOVER_MODE) & M_PSCR_MDI_XOVER_MODE)
110
111/* Extended PHY specific control register fields */
112#define S_DOWNSHIFT_ENABLE 8
113#define V_DOWNSHIFT_ENABLE (1 << S_DOWNSHIFT_ENABLE)
114
115#define S_DOWNSHIFT_CNT 9
116#define M_DOWNSHIFT_CNT 0x7
117#define V_DOWNSHIFT_CNT(x) ((x) << S_DOWNSHIFT_CNT)
118#define G_DOWNSHIFT_CNT(x) (((x) >> S_DOWNSHIFT_CNT) & M_DOWNSHIFT_CNT)
119
120/* PHY specific status register fields */
121#define S_PSSR_JABBER 0
122#define V_PSSR_JABBER (1 << S_PSSR_JABBER)
123
124#define S_PSSR_POLARITY 1
125#define V_PSSR_POLARITY (1 << S_PSSR_POLARITY)
126
127#define S_PSSR_RX_PAUSE 2
128#define V_PSSR_RX_PAUSE (1 << S_PSSR_RX_PAUSE)
129
130#define S_PSSR_TX_PAUSE 3
131#define V_PSSR_TX_PAUSE (1 << S_PSSR_TX_PAUSE)
132
133#define S_PSSR_ENERGY_DETECT 4
134#define V_PSSR_ENERGY_DETECT (1 << S_PSSR_ENERGY_DETECT)
135
136#define S_PSSR_DOWNSHIFT_STATUS 5
137#define V_PSSR_DOWNSHIFT_STATUS (1 << S_PSSR_DOWNSHIFT_STATUS)
138
139#define S_PSSR_MDI 6
140#define V_PSSR_MDI (1 << S_PSSR_MDI)
141
142#define S_PSSR_CABLE_LEN 7
143#define M_PSSR_CABLE_LEN 0x7
144#define V_PSSR_CABLE_LEN(x) ((x) << S_PSSR_CABLE_LEN)
145#define G_PSSR_CABLE_LEN(x) (((x) >> S_PSSR_CABLE_LEN) & M_PSSR_CABLE_LEN)
146
147//#define S_PSSR_LINK 10
148//#define S_PSSR_LINK 13
149#define S_PSSR_LINK 2
150#define V_PSSR_LINK (1 << S_PSSR_LINK)
151
152//#define S_PSSR_STATUS_RESOLVED 11
153//#define S_PSSR_STATUS_RESOLVED 10
154#define S_PSSR_STATUS_RESOLVED 15
155#define V_PSSR_STATUS_RESOLVED (1 << S_PSSR_STATUS_RESOLVED)
156
157#define S_PSSR_PAGE_RECEIVED 12
158#define V_PSSR_PAGE_RECEIVED (1 << S_PSSR_PAGE_RECEIVED)
159
160//#define S_PSSR_DUPLEX 13
161//#define S_PSSR_DUPLEX 12
162#define S_PSSR_DUPLEX 5
163#define V_PSSR_DUPLEX (1 << S_PSSR_DUPLEX)
164
165//#define S_PSSR_SPEED 14
166//#define S_PSSR_SPEED 14
167#define S_PSSR_SPEED 3
168#define M_PSSR_SPEED 0x3
169#define V_PSSR_SPEED(x) ((x) << S_PSSR_SPEED)
170#define G_PSSR_SPEED(x) (((x) >> S_PSSR_SPEED) & M_PSSR_SPEED)
171
172#endif
diff --git a/drivers/net/cris/eth_v10.c b/drivers/net/cris/eth_v10.c
index 966b563e42bb..a03d781f6d0a 100644
--- a/drivers/net/cris/eth_v10.c
+++ b/drivers/net/cris/eth_v10.c
@@ -509,6 +509,8 @@ etrax_ethernet_init(void)
509 * does not share cacheline with any other data (to avoid cache bug) 509 * does not share cacheline with any other data (to avoid cache bug)
510 */ 510 */
511 RxDescList[i].skb = dev_alloc_skb(MAX_MEDIA_DATA_SIZE + 2 * L1_CACHE_BYTES); 511 RxDescList[i].skb = dev_alloc_skb(MAX_MEDIA_DATA_SIZE + 2 * L1_CACHE_BYTES);
512 if (!RxDescList[i].skb)
513 return -ENOMEM;
512 RxDescList[i].descr.ctrl = 0; 514 RxDescList[i].descr.ctrl = 0;
513 RxDescList[i].descr.sw_len = MAX_MEDIA_DATA_SIZE; 515 RxDescList[i].descr.sw_len = MAX_MEDIA_DATA_SIZE;
514 RxDescList[i].descr.next = virt_to_phys(&RxDescList[i + 1]); 516 RxDescList[i].descr.next = virt_to_phys(&RxDescList[i + 1]);
diff --git a/drivers/net/cs89x0.c b/drivers/net/cs89x0.c
index 4ffc9b44a8e1..4612f71a7106 100644
--- a/drivers/net/cs89x0.c
+++ b/drivers/net/cs89x0.c
@@ -588,10 +588,10 @@ cs89x0_probe1(struct net_device *dev, int ioaddr, int modular)
588 goto out2; 588 goto out2;
589 } 589 }
590 } 590 }
591 printk(KERN_DEBUG "PP_addr at %x[%x]: 0x%x\n",
592 ioaddr, ADD_PORT, readword(ioaddr, ADD_PORT));
593 591
594 ioaddr &= ~3; 592 ioaddr &= ~3;
593 printk(KERN_DEBUG "PP_addr at %x[%x]: 0x%x\n",
594 ioaddr, ADD_PORT, readword(ioaddr, ADD_PORT));
595 writeword(ioaddr, ADD_PORT, PP_ChipID); 595 writeword(ioaddr, ADD_PORT, PP_ChipID);
596 596
597 tmp = readword(ioaddr, DATA_PORT); 597 tmp = readword(ioaddr, DATA_PORT);
@@ -1974,7 +1974,7 @@ out:
1974 return ret; 1974 return ret;
1975} 1975}
1976 1976
1977void 1977void __exit
1978cleanup_module(void) 1978cleanup_module(void)
1979{ 1979{
1980 unregister_netdev(dev_cs89x0); 1980 unregister_netdev(dev_cs89x0);
diff --git a/drivers/net/de600.c b/drivers/net/de600.c
index 690bb40b353d..8396e411f1ce 100644
--- a/drivers/net/de600.c
+++ b/drivers/net/de600.c
@@ -43,7 +43,6 @@ static const char version[] = "de600.c: $Revision: 1.41-2.5 $, Bjorn Ekwall (bj
43 * modify the following "#define": (see <asm/io.h> for more info) 43 * modify the following "#define": (see <asm/io.h> for more info)
44#define REALLY_SLOW_IO 44#define REALLY_SLOW_IO
45 */ 45 */
46#define SLOW_IO_BY_JUMPING /* Looks "better" than dummy write to port 0x80 :-) */
47 46
48/* use 0 for production, 1 for verification, >2 for debug */ 47/* use 0 for production, 1 for verification, >2 for debug */
49#ifdef DE600_DEBUG 48#ifdef DE600_DEBUG
diff --git a/drivers/net/declance.c b/drivers/net/declance.c
index 00e2a8a134d7..4ae0fed7122e 100644
--- a/drivers/net/declance.c
+++ b/drivers/net/declance.c
@@ -40,6 +40,10 @@
40 * 40 *
41 * v0.009: Module support fixes, multiple interfaces support, various 41 * v0.009: Module support fixes, multiple interfaces support, various
42 * bits. macro 42 * bits. macro
43 *
44 * v0.010: Fixes for the PMAD mapping of the LANCE buffer and for the
45 * PMAX requirement to only use halfword accesses to the
46 * buffer. macro
43 */ 47 */
44 48
45#include <linux/crc32.h> 49#include <linux/crc32.h>
@@ -54,6 +58,7 @@
54#include <linux/spinlock.h> 58#include <linux/spinlock.h>
55#include <linux/stddef.h> 59#include <linux/stddef.h>
56#include <linux/string.h> 60#include <linux/string.h>
61#include <linux/types.h>
57 62
58#include <asm/addrspace.h> 63#include <asm/addrspace.h>
59#include <asm/system.h> 64#include <asm/system.h>
@@ -67,7 +72,7 @@
67#include <asm/dec/tc.h> 72#include <asm/dec/tc.h>
68 73
69static char version[] __devinitdata = 74static char version[] __devinitdata =
70"declance.c: v0.009 by Linux MIPS DECstation task force\n"; 75"declance.c: v0.010 by Linux MIPS DECstation task force\n";
71 76
72MODULE_AUTHOR("Linux MIPS DECstation task force"); 77MODULE_AUTHOR("Linux MIPS DECstation task force");
73MODULE_DESCRIPTION("DEC LANCE (DECstation onboard, PMAD-xx) driver"); 78MODULE_DESCRIPTION("DEC LANCE (DECstation onboard, PMAD-xx) driver");
@@ -110,24 +115,25 @@ MODULE_LICENSE("GPL");
110#define LE_C3_BCON 0x1 /* Byte control */ 115#define LE_C3_BCON 0x1 /* Byte control */
111 116
112/* Receive message descriptor 1 */ 117/* Receive message descriptor 1 */
113#define LE_R1_OWN 0x80 /* Who owns the entry */ 118#define LE_R1_OWN 0x8000 /* Who owns the entry */
114#define LE_R1_ERR 0x40 /* Error: if FRA, OFL, CRC or BUF is set */ 119#define LE_R1_ERR 0x4000 /* Error: if FRA, OFL, CRC or BUF is set */
115#define LE_R1_FRA 0x20 /* FRA: Frame error */ 120#define LE_R1_FRA 0x2000 /* FRA: Frame error */
116#define LE_R1_OFL 0x10 /* OFL: Frame overflow */ 121#define LE_R1_OFL 0x1000 /* OFL: Frame overflow */
117#define LE_R1_CRC 0x08 /* CRC error */ 122#define LE_R1_CRC 0x0800 /* CRC error */
118#define LE_R1_BUF 0x04 /* BUF: Buffer error */ 123#define LE_R1_BUF 0x0400 /* BUF: Buffer error */
119#define LE_R1_SOP 0x02 /* Start of packet */ 124#define LE_R1_SOP 0x0200 /* Start of packet */
120#define LE_R1_EOP 0x01 /* End of packet */ 125#define LE_R1_EOP 0x0100 /* End of packet */
121#define LE_R1_POK 0x03 /* Packet is complete: SOP + EOP */ 126#define LE_R1_POK 0x0300 /* Packet is complete: SOP + EOP */
122 127
123#define LE_T1_OWN 0x80 /* Lance owns the packet */ 128/* Transmit message descriptor 1 */
124#define LE_T1_ERR 0x40 /* Error summary */ 129#define LE_T1_OWN 0x8000 /* Lance owns the packet */
125#define LE_T1_EMORE 0x10 /* Error: more than one retry needed */ 130#define LE_T1_ERR 0x4000 /* Error summary */
126#define LE_T1_EONE 0x08 /* Error: one retry needed */ 131#define LE_T1_EMORE 0x1000 /* Error: more than one retry needed */
127#define LE_T1_EDEF 0x04 /* Error: deferred */ 132#define LE_T1_EONE 0x0800 /* Error: one retry needed */
128#define LE_T1_SOP 0x02 /* Start of packet */ 133#define LE_T1_EDEF 0x0400 /* Error: deferred */
129#define LE_T1_EOP 0x01 /* End of packet */ 134#define LE_T1_SOP 0x0200 /* Start of packet */
130#define LE_T1_POK 0x03 /* Packet is complete: SOP + EOP */ 135#define LE_T1_EOP 0x0100 /* End of packet */
136#define LE_T1_POK 0x0300 /* Packet is complete: SOP + EOP */
131 137
132#define LE_T3_BUF 0x8000 /* Buffer error */ 138#define LE_T3_BUF 0x8000 /* Buffer error */
133#define LE_T3_UFL 0x4000 /* Error underflow */ 139#define LE_T3_UFL 0x4000 /* Error underflow */
@@ -156,69 +162,57 @@ MODULE_LICENSE("GPL");
156#undef TEST_HITS 162#undef TEST_HITS
157#define ZERO 0 163#define ZERO 0
158 164
159/* The DS2000/3000 have a linear 64 KB buffer. 165/*
160 166 * The DS2100/3100 have a linear 64 kB buffer which supports halfword
161 * The PMAD-AA has 128 kb buffer on-board. 167 * accesses only. Each halfword of the buffer is word-aligned in the
168 * CPU address space.
162 * 169 *
163 * The IOASIC LANCE devices use a shared memory region. This region as seen 170 * The PMAD-AA has a 128 kB buffer on-board.
164 * from the CPU is (max) 128 KB long and has to be on an 128 KB boundary.
165 * The LANCE sees this as a 64 KB long continuous memory region.
166 * 171 *
167 * The LANCE's DMA address is used as an index in this buffer and DMA takes 172 * The IOASIC LANCE devices use a shared memory region. This region
168 * place in bursts of eight 16-Bit words which are packed into four 32-Bit words 173 * as seen from the CPU is (max) 128 kB long and has to be on an 128 kB
169 * by the IOASIC. This leads to a strange padding: 16 bytes of valid data followed 174 * boundary. The LANCE sees this as a 64 kB long continuous memory
170 * by a 16 byte gap :-(. 175 * region.
176 *
177 * The LANCE's DMA address is used as an index in this buffer and DMA
178 * takes place in bursts of eight 16-bit words which are packed into
179 * four 32-bit words by the IOASIC. This leads to a strange padding:
180 * 16 bytes of valid data followed by a 16 byte gap :-(.
171 */ 181 */
172 182
173struct lance_rx_desc { 183struct lance_rx_desc {
174 unsigned short rmd0; /* low address of packet */ 184 unsigned short rmd0; /* low address of packet */
175 short gap0; 185 unsigned short rmd1; /* high address of packet
176 unsigned char rmd1_hadr; /* high address of packet */ 186 and descriptor bits */
177 unsigned char rmd1_bits; /* descriptor bits */
178 short gap1;
179 short length; /* 2s complement (negative!) 187 short length; /* 2s complement (negative!)
180 of buffer length */ 188 of buffer length */
181 short gap2;
182 unsigned short mblength; /* actual number of bytes received */ 189 unsigned short mblength; /* actual number of bytes received */
183 short gap3;
184}; 190};
185 191
186struct lance_tx_desc { 192struct lance_tx_desc {
187 unsigned short tmd0; /* low address of packet */ 193 unsigned short tmd0; /* low address of packet */
188 short gap0; 194 unsigned short tmd1; /* high address of packet
189 unsigned char tmd1_hadr; /* high address of packet */ 195 and descriptor bits */
190 unsigned char tmd1_bits; /* descriptor bits */
191 short gap1;
192 short length; /* 2s complement (negative!) 196 short length; /* 2s complement (negative!)
193 of buffer length */ 197 of buffer length */
194 short gap2;
195 unsigned short misc; 198 unsigned short misc;
196 short gap3;
197}; 199};
198 200
199 201
200/* First part of the LANCE initialization block, described in databook. */ 202/* First part of the LANCE initialization block, described in databook. */
201struct lance_init_block { 203struct lance_init_block {
202 unsigned short mode; /* pre-set mode (reg. 15) */ 204 unsigned short mode; /* pre-set mode (reg. 15) */
203 short gap0;
204 205
205 unsigned char phys_addr[12]; /* physical ethernet address 206 unsigned short phys_addr[3]; /* physical ethernet address */
206 only 0, 1, 4, 5, 8, 9 are valid 207 unsigned short filter[4]; /* multicast filter */
207 2, 3, 6, 7, 10, 11 are gaps */
208 unsigned short filter[8]; /* multicast filter
209 only 0, 2, 4, 6 are valid
210 1, 3, 5, 7 are gaps */
211 208
212 /* Receive and transmit ring base, along with extra bits. */ 209 /* Receive and transmit ring base, along with extra bits. */
213 unsigned short rx_ptr; /* receive descriptor addr */ 210 unsigned short rx_ptr; /* receive descriptor addr */
214 short gap1;
215 unsigned short rx_len; /* receive len and high addr */ 211 unsigned short rx_len; /* receive len and high addr */
216 short gap2;
217 unsigned short tx_ptr; /* transmit descriptor addr */ 212 unsigned short tx_ptr; /* transmit descriptor addr */
218 short gap3;
219 unsigned short tx_len; /* transmit len and high addr */ 213 unsigned short tx_len; /* transmit len and high addr */
220 short gap4; 214
221 short gap5[8]; 215 short gap[4];
222 216
223 /* The buffer descriptors */ 217 /* The buffer descriptors */
224 struct lance_rx_desc brx_ring[RX_RING_SIZE]; 218 struct lance_rx_desc brx_ring[RX_RING_SIZE];
@@ -226,15 +220,28 @@ struct lance_init_block {
226}; 220};
227 221
228#define BUF_OFFSET_CPU sizeof(struct lance_init_block) 222#define BUF_OFFSET_CPU sizeof(struct lance_init_block)
229#define BUF_OFFSET_LNC (sizeof(struct lance_init_block)>>1) 223#define BUF_OFFSET_LNC sizeof(struct lance_init_block)
230 224
231#define libdesc_offset(rt, elem) \ 225#define shift_off(off, type) \
232((__u32)(((unsigned long)(&(((struct lance_init_block *)0)->rt[elem]))))) 226 (type == ASIC_LANCE || type == PMAX_LANCE ? off << 1 : off)
233 227
234/* 228#define lib_off(rt, type) \
235 * This works *only* for the ring descriptors 229 shift_off(offsetof(struct lance_init_block, rt), type)
236 */ 230
237#define LANCE_ADDR(x) (CPHYSADDR(x) >> 1) 231#define lib_ptr(ib, rt, type) \
232 ((volatile u16 *)((u8 *)(ib) + lib_off(rt, type)))
233
234#define rds_off(rt, type) \
235 shift_off(offsetof(struct lance_rx_desc, rt), type)
236
237#define rds_ptr(rd, rt, type) \
238 ((volatile u16 *)((u8 *)(rd) + rds_off(rt, type)))
239
240#define tds_off(rt, type) \
241 shift_off(offsetof(struct lance_tx_desc, rt), type)
242
243#define tds_ptr(td, rt, type) \
244 ((volatile u16 *)((u8 *)(td) + tds_off(rt, type)))
238 245
239struct lance_private { 246struct lance_private {
240 struct net_device *next; 247 struct net_device *next;
@@ -242,7 +249,6 @@ struct lance_private {
242 int slot; 249 int slot;
243 int dma_irq; 250 int dma_irq;
244 volatile struct lance_regs *ll; 251 volatile struct lance_regs *ll;
245 volatile struct lance_init_block *init_block;
246 252
247 spinlock_t lock; 253 spinlock_t lock;
248 254
@@ -260,8 +266,8 @@ struct lance_private {
260 char *tx_buf_ptr_cpu[TX_RING_SIZE]; 266 char *tx_buf_ptr_cpu[TX_RING_SIZE];
261 267
262 /* Pointers to the ring buffers as seen from the LANCE */ 268 /* Pointers to the ring buffers as seen from the LANCE */
263 char *rx_buf_ptr_lnc[RX_RING_SIZE]; 269 uint rx_buf_ptr_lnc[RX_RING_SIZE];
264 char *tx_buf_ptr_lnc[TX_RING_SIZE]; 270 uint tx_buf_ptr_lnc[TX_RING_SIZE];
265}; 271};
266 272
267#define TX_BUFFS_AVAIL ((lp->tx_old<=lp->tx_new)?\ 273#define TX_BUFFS_AVAIL ((lp->tx_old<=lp->tx_new)?\
@@ -294,7 +300,7 @@ static inline void writereg(volatile unsigned short *regptr, short value)
294static void load_csrs(struct lance_private *lp) 300static void load_csrs(struct lance_private *lp)
295{ 301{
296 volatile struct lance_regs *ll = lp->ll; 302 volatile struct lance_regs *ll = lp->ll;
297 int leptr; 303 uint leptr;
298 304
299 /* The address space as seen from the LANCE 305 /* The address space as seen from the LANCE
300 * begins at address 0. HK 306 * begins at address 0. HK
@@ -316,12 +322,14 @@ static void load_csrs(struct lance_private *lp)
316 * Our specialized copy routines 322 * Our specialized copy routines
317 * 323 *
318 */ 324 */
319void cp_to_buf(const int type, void *to, const void *from, int len) 325static void cp_to_buf(const int type, void *to, const void *from, int len)
320{ 326{
321 unsigned short *tp, *fp, clen; 327 unsigned short *tp, *fp, clen;
322 unsigned char *rtp, *rfp; 328 unsigned char *rtp, *rfp;
323 329
324 if (type == PMAX_LANCE) { 330 if (type == PMAD_LANCE) {
331 memcpy(to, from, len);
332 } else if (type == PMAX_LANCE) {
325 clen = len >> 1; 333 clen = len >> 1;
326 tp = (unsigned short *) to; 334 tp = (unsigned short *) to;
327 fp = (unsigned short *) from; 335 fp = (unsigned short *) from;
@@ -370,12 +378,14 @@ void cp_to_buf(const int type, void *to, const void *from, int len)
370 iob(); 378 iob();
371} 379}
372 380
373void cp_from_buf(const int type, void *to, const void *from, int len) 381static void cp_from_buf(const int type, void *to, const void *from, int len)
374{ 382{
375 unsigned short *tp, *fp, clen; 383 unsigned short *tp, *fp, clen;
376 unsigned char *rtp, *rfp; 384 unsigned char *rtp, *rfp;
377 385
378 if (type == PMAX_LANCE) { 386 if (type == PMAD_LANCE) {
387 memcpy(to, from, len);
388 } else if (type == PMAX_LANCE) {
379 clen = len >> 1; 389 clen = len >> 1;
380 tp = (unsigned short *) to; 390 tp = (unsigned short *) to;
381 fp = (unsigned short *) from; 391 fp = (unsigned short *) from;
@@ -431,12 +441,10 @@ void cp_from_buf(const int type, void *to, const void *from, int len)
431static void lance_init_ring(struct net_device *dev) 441static void lance_init_ring(struct net_device *dev)
432{ 442{
433 struct lance_private *lp = netdev_priv(dev); 443 struct lance_private *lp = netdev_priv(dev);
434 volatile struct lance_init_block *ib; 444 volatile u16 *ib = (volatile u16 *)dev->mem_start;
435 int leptr; 445 uint leptr;
436 int i; 446 int i;
437 447
438 ib = (struct lance_init_block *) (dev->mem_start);
439
440 /* Lock out other processes while setting up hardware */ 448 /* Lock out other processes while setting up hardware */
441 netif_stop_queue(dev); 449 netif_stop_queue(dev);
442 lp->rx_new = lp->tx_new = 0; 450 lp->rx_new = lp->tx_new = 0;
@@ -445,55 +453,64 @@ static void lance_init_ring(struct net_device *dev)
445 /* Copy the ethernet address to the lance init block. 453 /* Copy the ethernet address to the lance init block.
446 * XXX bit 0 of the physical address registers has to be zero 454 * XXX bit 0 of the physical address registers has to be zero
447 */ 455 */
448 ib->phys_addr[0] = dev->dev_addr[0]; 456 *lib_ptr(ib, phys_addr[0], lp->type) = (dev->dev_addr[1] << 8) |
449 ib->phys_addr[1] = dev->dev_addr[1]; 457 dev->dev_addr[0];
450 ib->phys_addr[4] = dev->dev_addr[2]; 458 *lib_ptr(ib, phys_addr[1], lp->type) = (dev->dev_addr[3] << 8) |
451 ib->phys_addr[5] = dev->dev_addr[3]; 459 dev->dev_addr[2];
452 ib->phys_addr[8] = dev->dev_addr[4]; 460 *lib_ptr(ib, phys_addr[2], lp->type) = (dev->dev_addr[5] << 8) |
453 ib->phys_addr[9] = dev->dev_addr[5]; 461 dev->dev_addr[4];
454 /* Setup the initialization block */ 462 /* Setup the initialization block */
455 463
456 /* Setup rx descriptor pointer */ 464 /* Setup rx descriptor pointer */
457 leptr = LANCE_ADDR(libdesc_offset(brx_ring, 0)); 465 leptr = offsetof(struct lance_init_block, brx_ring);
458 ib->rx_len = (LANCE_LOG_RX_BUFFERS << 13) | (leptr >> 16); 466 *lib_ptr(ib, rx_len, lp->type) = (LANCE_LOG_RX_BUFFERS << 13) |
459 ib->rx_ptr = leptr; 467 (leptr >> 16);
468 *lib_ptr(ib, rx_ptr, lp->type) = leptr;
460 if (ZERO) 469 if (ZERO)
461 printk("RX ptr: %8.8x(%8.8x)\n", leptr, libdesc_offset(brx_ring, 0)); 470 printk("RX ptr: %8.8x(%8.8x)\n",
471 leptr, lib_off(brx_ring, lp->type));
462 472
463 /* Setup tx descriptor pointer */ 473 /* Setup tx descriptor pointer */
464 leptr = LANCE_ADDR(libdesc_offset(btx_ring, 0)); 474 leptr = offsetof(struct lance_init_block, btx_ring);
465 ib->tx_len = (LANCE_LOG_TX_BUFFERS << 13) | (leptr >> 16); 475 *lib_ptr(ib, tx_len, lp->type) = (LANCE_LOG_TX_BUFFERS << 13) |
466 ib->tx_ptr = leptr; 476 (leptr >> 16);
477 *lib_ptr(ib, tx_ptr, lp->type) = leptr;
467 if (ZERO) 478 if (ZERO)
468 printk("TX ptr: %8.8x(%8.8x)\n", leptr, libdesc_offset(btx_ring, 0)); 479 printk("TX ptr: %8.8x(%8.8x)\n",
480 leptr, lib_off(btx_ring, lp->type));
469 481
470 if (ZERO) 482 if (ZERO)
471 printk("TX rings:\n"); 483 printk("TX rings:\n");
472 484
473 /* Setup the Tx ring entries */ 485 /* Setup the Tx ring entries */
474 for (i = 0; i < TX_RING_SIZE; i++) { 486 for (i = 0; i < TX_RING_SIZE; i++) {
475 leptr = (int) lp->tx_buf_ptr_lnc[i]; 487 leptr = lp->tx_buf_ptr_lnc[i];
476 ib->btx_ring[i].tmd0 = leptr; 488 *lib_ptr(ib, btx_ring[i].tmd0, lp->type) = leptr;
477 ib->btx_ring[i].tmd1_hadr = leptr >> 16; 489 *lib_ptr(ib, btx_ring[i].tmd1, lp->type) = (leptr >> 16) &
478 ib->btx_ring[i].tmd1_bits = 0; 490 0xff;
479 ib->btx_ring[i].length = 0xf000; /* The ones required by tmd2 */ 491 *lib_ptr(ib, btx_ring[i].length, lp->type) = 0xf000;
480 ib->btx_ring[i].misc = 0; 492 /* The ones required by tmd2 */
493 *lib_ptr(ib, btx_ring[i].misc, lp->type) = 0;
481 if (i < 3 && ZERO) 494 if (i < 3 && ZERO)
482 printk("%d: 0x%8.8x(0x%8.8x)\n", i, leptr, (int) lp->tx_buf_ptr_cpu[i]); 495 printk("%d: 0x%8.8x(0x%8.8x)\n",
496 i, leptr, (uint)lp->tx_buf_ptr_cpu[i]);
483 } 497 }
484 498
485 /* Setup the Rx ring entries */ 499 /* Setup the Rx ring entries */
486 if (ZERO) 500 if (ZERO)
487 printk("RX rings:\n"); 501 printk("RX rings:\n");
488 for (i = 0; i < RX_RING_SIZE; i++) { 502 for (i = 0; i < RX_RING_SIZE; i++) {
489 leptr = (int) lp->rx_buf_ptr_lnc[i]; 503 leptr = lp->rx_buf_ptr_lnc[i];
490 ib->brx_ring[i].rmd0 = leptr; 504 *lib_ptr(ib, brx_ring[i].rmd0, lp->type) = leptr;
491 ib->brx_ring[i].rmd1_hadr = leptr >> 16; 505 *lib_ptr(ib, brx_ring[i].rmd1, lp->type) = ((leptr >> 16) &
492 ib->brx_ring[i].rmd1_bits = LE_R1_OWN; 506 0xff) |
493 ib->brx_ring[i].length = -RX_BUFF_SIZE | 0xf000; 507 LE_R1_OWN;
494 ib->brx_ring[i].mblength = 0; 508 *lib_ptr(ib, brx_ring[i].length, lp->type) = -RX_BUFF_SIZE |
509 0xf000;
510 *lib_ptr(ib, brx_ring[i].mblength, lp->type) = 0;
495 if (i < 3 && ZERO) 511 if (i < 3 && ZERO)
496 printk("%d: 0x%8.8x(0x%8.8x)\n", i, leptr, (int) lp->rx_buf_ptr_cpu[i]); 512 printk("%d: 0x%8.8x(0x%8.8x)\n",
513 i, leptr, (uint)lp->rx_buf_ptr_cpu[i]);
497 } 514 }
498 iob(); 515 iob();
499} 516}
@@ -511,11 +528,13 @@ static int init_restart_lance(struct lance_private *lp)
511 udelay(10); 528 udelay(10);
512 } 529 }
513 if ((i == 100) || (ll->rdp & LE_C0_ERR)) { 530 if ((i == 100) || (ll->rdp & LE_C0_ERR)) {
514 printk("LANCE unopened after %d ticks, csr0=%4.4x.\n", i, ll->rdp); 531 printk("LANCE unopened after %d ticks, csr0=%4.4x.\n",
532 i, ll->rdp);
515 return -1; 533 return -1;
516 } 534 }
517 if ((ll->rdp & LE_C0_ERR)) { 535 if ((ll->rdp & LE_C0_ERR)) {
518 printk("LANCE unopened after %d ticks, csr0=%4.4x.\n", i, ll->rdp); 536 printk("LANCE unopened after %d ticks, csr0=%4.4x.\n",
537 i, ll->rdp);
519 return -1; 538 return -1;
520 } 539 }
521 writereg(&ll->rdp, LE_C0_IDON); 540 writereg(&ll->rdp, LE_C0_IDON);
@@ -528,12 +547,11 @@ static int init_restart_lance(struct lance_private *lp)
528static int lance_rx(struct net_device *dev) 547static int lance_rx(struct net_device *dev)
529{ 548{
530 struct lance_private *lp = netdev_priv(dev); 549 struct lance_private *lp = netdev_priv(dev);
531 volatile struct lance_init_block *ib; 550 volatile u16 *ib = (volatile u16 *)dev->mem_start;
532 volatile struct lance_rx_desc *rd = 0; 551 volatile u16 *rd;
533 unsigned char bits; 552 unsigned short bits;
534 int len = 0; 553 int entry, len;
535 struct sk_buff *skb = 0; 554 struct sk_buff *skb;
536 ib = (struct lance_init_block *) (dev->mem_start);
537 555
538#ifdef TEST_HITS 556#ifdef TEST_HITS
539 { 557 {
@@ -542,19 +560,22 @@ static int lance_rx(struct net_device *dev)
542 printk("["); 560 printk("[");
543 for (i = 0; i < RX_RING_SIZE; i++) { 561 for (i = 0; i < RX_RING_SIZE; i++) {
544 if (i == lp->rx_new) 562 if (i == lp->rx_new)
545 printk("%s", ib->brx_ring[i].rmd1_bits & 563 printk("%s", *lib_ptr(ib, brx_ring[i].rmd1,
564 lp->type) &
546 LE_R1_OWN ? "_" : "X"); 565 LE_R1_OWN ? "_" : "X");
547 else 566 else
548 printk("%s", ib->brx_ring[i].rmd1_bits & 567 printk("%s", *lib_ptr(ib, brx_ring[i].rmd1,
568 lp->type) &
549 LE_R1_OWN ? "." : "1"); 569 LE_R1_OWN ? "." : "1");
550 } 570 }
551 printk("]"); 571 printk("]");
552 } 572 }
553#endif 573#endif
554 574
555 for (rd = &ib->brx_ring[lp->rx_new]; 575 for (rd = lib_ptr(ib, brx_ring[lp->rx_new], lp->type);
556 !((bits = rd->rmd1_bits) & LE_R1_OWN); 576 !((bits = *rds_ptr(rd, rmd1, lp->type)) & LE_R1_OWN);
557 rd = &ib->brx_ring[lp->rx_new]) { 577 rd = lib_ptr(ib, brx_ring[lp->rx_new], lp->type)) {
578 entry = lp->rx_new;
558 579
559 /* We got an incomplete frame? */ 580 /* We got an incomplete frame? */
560 if ((bits & LE_R1_POK) != LE_R1_POK) { 581 if ((bits & LE_R1_POK) != LE_R1_POK) {
@@ -575,16 +596,18 @@ static int lance_rx(struct net_device *dev)
575 if (bits & LE_R1_EOP) 596 if (bits & LE_R1_EOP)
576 lp->stats.rx_errors++; 597 lp->stats.rx_errors++;
577 } else { 598 } else {
578 len = (rd->mblength & 0xfff) - 4; 599 len = (*rds_ptr(rd, mblength, lp->type) & 0xfff) - 4;
579 skb = dev_alloc_skb(len + 2); 600 skb = dev_alloc_skb(len + 2);
580 601
581 if (skb == 0) { 602 if (skb == 0) {
582 printk("%s: Memory squeeze, deferring packet.\n", 603 printk("%s: Memory squeeze, deferring packet.\n",
583 dev->name); 604 dev->name);
584 lp->stats.rx_dropped++; 605 lp->stats.rx_dropped++;
585 rd->mblength = 0; 606 *rds_ptr(rd, mblength, lp->type) = 0;
586 rd->rmd1_bits = LE_R1_OWN; 607 *rds_ptr(rd, rmd1, lp->type) =
587 lp->rx_new = (lp->rx_new + 1) & RX_RING_MOD_MASK; 608 ((lp->rx_buf_ptr_lnc[entry] >> 16) &
609 0xff) | LE_R1_OWN;
610 lp->rx_new = (entry + 1) & RX_RING_MOD_MASK;
588 return 0; 611 return 0;
589 } 612 }
590 lp->stats.rx_bytes += len; 613 lp->stats.rx_bytes += len;
@@ -594,8 +617,7 @@ static int lance_rx(struct net_device *dev)
594 skb_put(skb, len); /* make room */ 617 skb_put(skb, len); /* make room */
595 618
596 cp_from_buf(lp->type, skb->data, 619 cp_from_buf(lp->type, skb->data,
597 (char *)lp->rx_buf_ptr_cpu[lp->rx_new], 620 (char *)lp->rx_buf_ptr_cpu[entry], len);
598 len);
599 621
600 skb->protocol = eth_type_trans(skb, dev); 622 skb->protocol = eth_type_trans(skb, dev);
601 netif_rx(skb); 623 netif_rx(skb);
@@ -604,10 +626,11 @@ static int lance_rx(struct net_device *dev)
604 } 626 }
605 627
606 /* Return the packet to the pool */ 628 /* Return the packet to the pool */
607 rd->mblength = 0; 629 *rds_ptr(rd, mblength, lp->type) = 0;
608 rd->length = -RX_BUFF_SIZE | 0xf000; 630 *rds_ptr(rd, length, lp->type) = -RX_BUFF_SIZE | 0xf000;
609 rd->rmd1_bits = LE_R1_OWN; 631 *rds_ptr(rd, rmd1, lp->type) =
610 lp->rx_new = (lp->rx_new + 1) & RX_RING_MOD_MASK; 632 ((lp->rx_buf_ptr_lnc[entry] >> 16) & 0xff) | LE_R1_OWN;
633 lp->rx_new = (entry + 1) & RX_RING_MOD_MASK;
611 } 634 }
612 return 0; 635 return 0;
613} 636}
@@ -615,24 +638,24 @@ static int lance_rx(struct net_device *dev)
615static void lance_tx(struct net_device *dev) 638static void lance_tx(struct net_device *dev)
616{ 639{
617 struct lance_private *lp = netdev_priv(dev); 640 struct lance_private *lp = netdev_priv(dev);
618 volatile struct lance_init_block *ib; 641 volatile u16 *ib = (volatile u16 *)dev->mem_start;
619 volatile struct lance_regs *ll = lp->ll; 642 volatile struct lance_regs *ll = lp->ll;
620 volatile struct lance_tx_desc *td; 643 volatile u16 *td;
621 int i, j; 644 int i, j;
622 int status; 645 int status;
623 ib = (struct lance_init_block *) (dev->mem_start); 646
624 j = lp->tx_old; 647 j = lp->tx_old;
625 648
626 spin_lock(&lp->lock); 649 spin_lock(&lp->lock);
627 650
628 for (i = j; i != lp->tx_new; i = j) { 651 for (i = j; i != lp->tx_new; i = j) {
629 td = &ib->btx_ring[i]; 652 td = lib_ptr(ib, btx_ring[i], lp->type);
630 /* If we hit a packet not owned by us, stop */ 653 /* If we hit a packet not owned by us, stop */
631 if (td->tmd1_bits & LE_T1_OWN) 654 if (*tds_ptr(td, tmd1, lp->type) & LE_T1_OWN)
632 break; 655 break;
633 656
634 if (td->tmd1_bits & LE_T1_ERR) { 657 if (*tds_ptr(td, tmd1, lp->type) & LE_T1_ERR) {
635 status = td->misc; 658 status = *tds_ptr(td, misc, lp->type);
636 659
637 lp->stats.tx_errors++; 660 lp->stats.tx_errors++;
638 if (status & LE_T3_RTY) 661 if (status & LE_T3_RTY)
@@ -667,18 +690,19 @@ static void lance_tx(struct net_device *dev)
667 init_restart_lance(lp); 690 init_restart_lance(lp);
668 goto out; 691 goto out;
669 } 692 }
670 } else if ((td->tmd1_bits & LE_T1_POK) == LE_T1_POK) { 693 } else if ((*tds_ptr(td, tmd1, lp->type) & LE_T1_POK) ==
694 LE_T1_POK) {
671 /* 695 /*
672 * So we don't count the packet more than once. 696 * So we don't count the packet more than once.
673 */ 697 */
674 td->tmd1_bits &= ~(LE_T1_POK); 698 *tds_ptr(td, tmd1, lp->type) &= ~(LE_T1_POK);
675 699
676 /* One collision before packet was sent. */ 700 /* One collision before packet was sent. */
677 if (td->tmd1_bits & LE_T1_EONE) 701 if (*tds_ptr(td, tmd1, lp->type) & LE_T1_EONE)
678 lp->stats.collisions++; 702 lp->stats.collisions++;
679 703
680 /* More than one collision, be optimistic. */ 704 /* More than one collision, be optimistic. */
681 if (td->tmd1_bits & LE_T1_EMORE) 705 if (*tds_ptr(td, tmd1, lp->type) & LE_T1_EMORE)
682 lp->stats.collisions += 2; 706 lp->stats.collisions += 2;
683 707
684 lp->stats.tx_packets++; 708 lp->stats.tx_packets++;
@@ -752,7 +776,7 @@ struct net_device *last_dev = 0;
752 776
753static int lance_open(struct net_device *dev) 777static int lance_open(struct net_device *dev)
754{ 778{
755 volatile struct lance_init_block *ib = (struct lance_init_block *) (dev->mem_start); 779 volatile u16 *ib = (volatile u16 *)dev->mem_start;
756 struct lance_private *lp = netdev_priv(dev); 780 struct lance_private *lp = netdev_priv(dev);
757 volatile struct lance_regs *ll = lp->ll; 781 volatile struct lance_regs *ll = lp->ll;
758 int status = 0; 782 int status = 0;
@@ -769,11 +793,11 @@ static int lance_open(struct net_device *dev)
769 * 793 *
770 * BTW it is common bug in all lance drivers! --ANK 794 * BTW it is common bug in all lance drivers! --ANK
771 */ 795 */
772 ib->mode = 0; 796 *lib_ptr(ib, mode, lp->type) = 0;
773 ib->filter [0] = 0; 797 *lib_ptr(ib, filter[0], lp->type) = 0;
774 ib->filter [2] = 0; 798 *lib_ptr(ib, filter[1], lp->type) = 0;
775 ib->filter [4] = 0; 799 *lib_ptr(ib, filter[2], lp->type) = 0;
776 ib->filter [6] = 0; 800 *lib_ptr(ib, filter[3], lp->type) = 0;
777 801
778 lance_init_ring(dev); 802 lance_init_ring(dev);
779 load_csrs(lp); 803 load_csrs(lp);
@@ -874,12 +898,10 @@ static int lance_start_xmit(struct sk_buff *skb, struct net_device *dev)
874{ 898{
875 struct lance_private *lp = netdev_priv(dev); 899 struct lance_private *lp = netdev_priv(dev);
876 volatile struct lance_regs *ll = lp->ll; 900 volatile struct lance_regs *ll = lp->ll;
877 volatile struct lance_init_block *ib = (struct lance_init_block *) (dev->mem_start); 901 volatile u16 *ib = (volatile u16 *)dev->mem_start;
878 int entry, skblen, len; 902 int entry, len;
879 903
880 skblen = skb->len; 904 len = skb->len;
881
882 len = skblen;
883 905
884 if (len < ETH_ZLEN) { 906 if (len < ETH_ZLEN) {
885 if (skb_padto(skb, ETH_ZLEN)) 907 if (skb_padto(skb, ETH_ZLEN))
@@ -889,23 +911,17 @@ static int lance_start_xmit(struct sk_buff *skb, struct net_device *dev)
889 911
890 lp->stats.tx_bytes += len; 912 lp->stats.tx_bytes += len;
891 913
892 entry = lp->tx_new & TX_RING_MOD_MASK; 914 entry = lp->tx_new;
893 ib->btx_ring[entry].length = (-len); 915 *lib_ptr(ib, btx_ring[entry].length, lp->type) = (-len);
894 ib->btx_ring[entry].misc = 0; 916 *lib_ptr(ib, btx_ring[entry].misc, lp->type) = 0;
895
896 cp_to_buf(lp->type, (char *)lp->tx_buf_ptr_cpu[entry], skb->data,
897 skblen);
898 917
899 /* Clear the slack of the packet, do I need this? */ 918 cp_to_buf(lp->type, (char *)lp->tx_buf_ptr_cpu[entry], skb->data, len);
900 /* For a firewall it's a good idea - AC */
901/*
902 if (len != skblen)
903 memset ((char *) &ib->tx_buf [entry][skblen], 0, (len - skblen) << 1);
904 */
905 919
906 /* Now, give the packet to the lance */ 920 /* Now, give the packet to the lance */
907 ib->btx_ring[entry].tmd1_bits = (LE_T1_POK | LE_T1_OWN); 921 *lib_ptr(ib, btx_ring[entry].tmd1, lp->type) =
908 lp->tx_new = (lp->tx_new + 1) & TX_RING_MOD_MASK; 922 ((lp->tx_buf_ptr_lnc[entry] >> 16) & 0xff) |
923 (LE_T1_POK | LE_T1_OWN);
924 lp->tx_new = (entry + 1) & TX_RING_MOD_MASK;
909 925
910 if (TX_BUFFS_AVAIL <= 0) 926 if (TX_BUFFS_AVAIL <= 0)
911 netif_stop_queue(dev); 927 netif_stop_queue(dev);
@@ -930,8 +946,8 @@ static struct net_device_stats *lance_get_stats(struct net_device *dev)
930 946
931static void lance_load_multicast(struct net_device *dev) 947static void lance_load_multicast(struct net_device *dev)
932{ 948{
933 volatile struct lance_init_block *ib = (struct lance_init_block *) (dev->mem_start); 949 struct lance_private *lp = netdev_priv(dev);
934 volatile u16 *mcast_table = (u16 *) & ib->filter; 950 volatile u16 *ib = (volatile u16 *)dev->mem_start;
935 struct dev_mc_list *dmi = dev->mc_list; 951 struct dev_mc_list *dmi = dev->mc_list;
936 char *addrs; 952 char *addrs;
937 int i; 953 int i;
@@ -939,17 +955,17 @@ static void lance_load_multicast(struct net_device *dev)
939 955
940 /* set all multicast bits */ 956 /* set all multicast bits */
941 if (dev->flags & IFF_ALLMULTI) { 957 if (dev->flags & IFF_ALLMULTI) {
942 ib->filter[0] = 0xffff; 958 *lib_ptr(ib, filter[0], lp->type) = 0xffff;
943 ib->filter[2] = 0xffff; 959 *lib_ptr(ib, filter[1], lp->type) = 0xffff;
944 ib->filter[4] = 0xffff; 960 *lib_ptr(ib, filter[2], lp->type) = 0xffff;
945 ib->filter[6] = 0xffff; 961 *lib_ptr(ib, filter[3], lp->type) = 0xffff;
946 return; 962 return;
947 } 963 }
948 /* clear the multicast filter */ 964 /* clear the multicast filter */
949 ib->filter[0] = 0; 965 *lib_ptr(ib, filter[0], lp->type) = 0;
950 ib->filter[2] = 0; 966 *lib_ptr(ib, filter[1], lp->type) = 0;
951 ib->filter[4] = 0; 967 *lib_ptr(ib, filter[2], lp->type) = 0;
952 ib->filter[6] = 0; 968 *lib_ptr(ib, filter[3], lp->type) = 0;
953 969
954 /* Add addresses */ 970 /* Add addresses */
955 for (i = 0; i < dev->mc_count; i++) { 971 for (i = 0; i < dev->mc_count; i++) {
@@ -962,7 +978,7 @@ static void lance_load_multicast(struct net_device *dev)
962 978
963 crc = ether_crc_le(ETH_ALEN, addrs); 979 crc = ether_crc_le(ETH_ALEN, addrs);
964 crc = crc >> 26; 980 crc = crc >> 26;
965 mcast_table[2 * (crc >> 4)] |= 1 << (crc & 0xf); 981 *lib_ptr(ib, filter[crc >> 4], lp->type) |= 1 << (crc & 0xf);
966 } 982 }
967 return; 983 return;
968} 984}
@@ -970,11 +986,9 @@ static void lance_load_multicast(struct net_device *dev)
970static void lance_set_multicast(struct net_device *dev) 986static void lance_set_multicast(struct net_device *dev)
971{ 987{
972 struct lance_private *lp = netdev_priv(dev); 988 struct lance_private *lp = netdev_priv(dev);
973 volatile struct lance_init_block *ib; 989 volatile u16 *ib = (volatile u16 *)dev->mem_start;
974 volatile struct lance_regs *ll = lp->ll; 990 volatile struct lance_regs *ll = lp->ll;
975 991
976 ib = (struct lance_init_block *) (dev->mem_start);
977
978 if (!netif_running(dev)) 992 if (!netif_running(dev))
979 return; 993 return;
980 994
@@ -992,9 +1006,9 @@ static void lance_set_multicast(struct net_device *dev)
992 lance_init_ring(dev); 1006 lance_init_ring(dev);
993 1007
994 if (dev->flags & IFF_PROMISC) { 1008 if (dev->flags & IFF_PROMISC) {
995 ib->mode |= LE_MO_PROM; 1009 *lib_ptr(ib, mode, lp->type) |= LE_MO_PROM;
996 } else { 1010 } else {
997 ib->mode &= ~LE_MO_PROM; 1011 *lib_ptr(ib, mode, lp->type) &= ~LE_MO_PROM;
998 lance_load_multicast(dev); 1012 lance_load_multicast(dev);
999 } 1013 }
1000 load_csrs(lp); 1014 load_csrs(lp);
@@ -1051,7 +1065,6 @@ static int __init dec_lance_init(const int type, const int slot)
1051 lp->type = type; 1065 lp->type = type;
1052 lp->slot = slot; 1066 lp->slot = slot;
1053 switch (type) { 1067 switch (type) {
1054#ifdef CONFIG_TC
1055 case ASIC_LANCE: 1068 case ASIC_LANCE:
1056 dev->base_addr = CKSEG1ADDR(dec_kn_slot_base + IOASIC_LANCE); 1069 dev->base_addr = CKSEG1ADDR(dec_kn_slot_base + IOASIC_LANCE);
1057 1070
@@ -1073,20 +1086,20 @@ static int __init dec_lance_init(const int type, const int slot)
1073 */ 1086 */
1074 for (i = 0; i < RX_RING_SIZE; i++) { 1087 for (i = 0; i < RX_RING_SIZE; i++) {
1075 lp->rx_buf_ptr_cpu[i] = 1088 lp->rx_buf_ptr_cpu[i] =
1076 (char *)(dev->mem_start + BUF_OFFSET_CPU + 1089 (char *)(dev->mem_start + 2 * BUF_OFFSET_CPU +
1077 2 * i * RX_BUFF_SIZE); 1090 2 * i * RX_BUFF_SIZE);
1078 lp->rx_buf_ptr_lnc[i] = 1091 lp->rx_buf_ptr_lnc[i] =
1079 (char *)(BUF_OFFSET_LNC + i * RX_BUFF_SIZE); 1092 (BUF_OFFSET_LNC + i * RX_BUFF_SIZE);
1080 } 1093 }
1081 for (i = 0; i < TX_RING_SIZE; i++) { 1094 for (i = 0; i < TX_RING_SIZE; i++) {
1082 lp->tx_buf_ptr_cpu[i] = 1095 lp->tx_buf_ptr_cpu[i] =
1083 (char *)(dev->mem_start + BUF_OFFSET_CPU + 1096 (char *)(dev->mem_start + 2 * BUF_OFFSET_CPU +
1084 2 * RX_RING_SIZE * RX_BUFF_SIZE + 1097 2 * RX_RING_SIZE * RX_BUFF_SIZE +
1085 2 * i * TX_BUFF_SIZE); 1098 2 * i * TX_BUFF_SIZE);
1086 lp->tx_buf_ptr_lnc[i] = 1099 lp->tx_buf_ptr_lnc[i] =
1087 (char *)(BUF_OFFSET_LNC + 1100 (BUF_OFFSET_LNC +
1088 RX_RING_SIZE * RX_BUFF_SIZE + 1101 RX_RING_SIZE * RX_BUFF_SIZE +
1089 i * TX_BUFF_SIZE); 1102 i * TX_BUFF_SIZE);
1090 } 1103 }
1091 1104
1092 /* Setup I/O ASIC LANCE DMA. */ 1105 /* Setup I/O ASIC LANCE DMA. */
@@ -1095,11 +1108,12 @@ static int __init dec_lance_init(const int type, const int slot)
1095 CPHYSADDR(dev->mem_start) << 3); 1108 CPHYSADDR(dev->mem_start) << 3);
1096 1109
1097 break; 1110 break;
1098 1111#ifdef CONFIG_TC
1099 case PMAD_LANCE: 1112 case PMAD_LANCE:
1100 claim_tc_card(slot); 1113 claim_tc_card(slot);
1101 1114
1102 dev->mem_start = CKSEG1ADDR(get_tc_base_addr(slot)); 1115 dev->mem_start = CKSEG1ADDR(get_tc_base_addr(slot));
1116 dev->mem_end = dev->mem_start + 0x100000;
1103 dev->base_addr = dev->mem_start + 0x100000; 1117 dev->base_addr = dev->mem_start + 0x100000;
1104 dev->irq = get_tc_irq_nr(slot); 1118 dev->irq = get_tc_irq_nr(slot);
1105 esar_base = dev->mem_start + 0x1c0002; 1119 esar_base = dev->mem_start + 0x1c0002;
@@ -1110,7 +1124,7 @@ static int __init dec_lance_init(const int type, const int slot)
1110 (char *)(dev->mem_start + BUF_OFFSET_CPU + 1124 (char *)(dev->mem_start + BUF_OFFSET_CPU +
1111 i * RX_BUFF_SIZE); 1125 i * RX_BUFF_SIZE);
1112 lp->rx_buf_ptr_lnc[i] = 1126 lp->rx_buf_ptr_lnc[i] =
1113 (char *)(BUF_OFFSET_LNC + i * RX_BUFF_SIZE); 1127 (BUF_OFFSET_LNC + i * RX_BUFF_SIZE);
1114 } 1128 }
1115 for (i = 0; i < TX_RING_SIZE; i++) { 1129 for (i = 0; i < TX_RING_SIZE; i++) {
1116 lp->tx_buf_ptr_cpu[i] = 1130 lp->tx_buf_ptr_cpu[i] =
@@ -1118,18 +1132,18 @@ static int __init dec_lance_init(const int type, const int slot)
1118 RX_RING_SIZE * RX_BUFF_SIZE + 1132 RX_RING_SIZE * RX_BUFF_SIZE +
1119 i * TX_BUFF_SIZE); 1133 i * TX_BUFF_SIZE);
1120 lp->tx_buf_ptr_lnc[i] = 1134 lp->tx_buf_ptr_lnc[i] =
1121 (char *)(BUF_OFFSET_LNC + 1135 (BUF_OFFSET_LNC +
1122 RX_RING_SIZE * RX_BUFF_SIZE + 1136 RX_RING_SIZE * RX_BUFF_SIZE +
1123 i * TX_BUFF_SIZE); 1137 i * TX_BUFF_SIZE);
1124 } 1138 }
1125 1139
1126 break; 1140 break;
1127#endif 1141#endif
1128
1129 case PMAX_LANCE: 1142 case PMAX_LANCE:
1130 dev->irq = dec_interrupt[DEC_IRQ_LANCE]; 1143 dev->irq = dec_interrupt[DEC_IRQ_LANCE];
1131 dev->base_addr = CKSEG1ADDR(KN01_SLOT_BASE + KN01_LANCE); 1144 dev->base_addr = CKSEG1ADDR(KN01_SLOT_BASE + KN01_LANCE);
1132 dev->mem_start = CKSEG1ADDR(KN01_SLOT_BASE + KN01_LANCE_MEM); 1145 dev->mem_start = CKSEG1ADDR(KN01_SLOT_BASE + KN01_LANCE_MEM);
1146 dev->mem_end = dev->mem_start + KN01_SLOT_SIZE;
1133 esar_base = CKSEG1ADDR(KN01_SLOT_BASE + KN01_ESAR + 1); 1147 esar_base = CKSEG1ADDR(KN01_SLOT_BASE + KN01_ESAR + 1);
1134 lp->dma_irq = -1; 1148 lp->dma_irq = -1;
1135 1149
@@ -1138,20 +1152,20 @@ static int __init dec_lance_init(const int type, const int slot)
1138 */ 1152 */
1139 for (i = 0; i < RX_RING_SIZE; i++) { 1153 for (i = 0; i < RX_RING_SIZE; i++) {
1140 lp->rx_buf_ptr_cpu[i] = 1154 lp->rx_buf_ptr_cpu[i] =
1141 (char *)(dev->mem_start + BUF_OFFSET_CPU + 1155 (char *)(dev->mem_start + 2 * BUF_OFFSET_CPU +
1142 2 * i * RX_BUFF_SIZE); 1156 2 * i * RX_BUFF_SIZE);
1143 lp->rx_buf_ptr_lnc[i] = 1157 lp->rx_buf_ptr_lnc[i] =
1144 (char *)(BUF_OFFSET_LNC + i * RX_BUFF_SIZE); 1158 (BUF_OFFSET_LNC + i * RX_BUFF_SIZE);
1145 } 1159 }
1146 for (i = 0; i < TX_RING_SIZE; i++) { 1160 for (i = 0; i < TX_RING_SIZE; i++) {
1147 lp->tx_buf_ptr_cpu[i] = 1161 lp->tx_buf_ptr_cpu[i] =
1148 (char *)(dev->mem_start + BUF_OFFSET_CPU + 1162 (char *)(dev->mem_start + 2 * BUF_OFFSET_CPU +
1149 2 * RX_RING_SIZE * RX_BUFF_SIZE + 1163 2 * RX_RING_SIZE * RX_BUFF_SIZE +
1150 2 * i * TX_BUFF_SIZE); 1164 2 * i * TX_BUFF_SIZE);
1151 lp->tx_buf_ptr_lnc[i] = 1165 lp->tx_buf_ptr_lnc[i] =
1152 (char *)(BUF_OFFSET_LNC + 1166 (BUF_OFFSET_LNC +
1153 RX_RING_SIZE * RX_BUFF_SIZE + 1167 RX_RING_SIZE * RX_BUFF_SIZE +
1154 i * TX_BUFF_SIZE); 1168 i * TX_BUFF_SIZE);
1155 } 1169 }
1156 1170
1157 break; 1171 break;
@@ -1279,10 +1293,8 @@ static int __init dec_lance_probe(void)
1279 /* Then handle onboard devices. */ 1293 /* Then handle onboard devices. */
1280 if (dec_interrupt[DEC_IRQ_LANCE] >= 0) { 1294 if (dec_interrupt[DEC_IRQ_LANCE] >= 0) {
1281 if (dec_interrupt[DEC_IRQ_LANCE_MERR] >= 0) { 1295 if (dec_interrupt[DEC_IRQ_LANCE_MERR] >= 0) {
1282#ifdef CONFIG_TC
1283 if (dec_lance_init(ASIC_LANCE, -1) >= 0) 1296 if (dec_lance_init(ASIC_LANCE, -1) >= 0)
1284 count++; 1297 count++;
1285#endif
1286 } else if (!TURBOCHANNEL) { 1298 } else if (!TURBOCHANNEL) {
1287 if (dec_lance_init(PMAX_LANCE, -1) >= 0) 1299 if (dec_lance_init(PMAX_LANCE, -1) >= 0)
1288 count++; 1300 count++;
diff --git a/drivers/net/defxx.c b/drivers/net/defxx.c
index 8f514cc0debd..dc3ab3b5c8cb 100644
--- a/drivers/net/defxx.c
+++ b/drivers/net/defxx.c
@@ -192,6 +192,7 @@
192 * 04 Aug 2003 macro Converted to the DMA API. 192 * 04 Aug 2003 macro Converted to the DMA API.
193 * 14 Aug 2004 macro Fix device names reported. 193 * 14 Aug 2004 macro Fix device names reported.
194 * 14 Jun 2005 macro Use irqreturn_t. 194 * 14 Jun 2005 macro Use irqreturn_t.
195 * 23 Oct 2006 macro Big-endian host support.
195 */ 196 */
196 197
197/* Include files */ 198/* Include files */
@@ -218,8 +219,8 @@
218 219
219/* Version information string should be updated prior to each new release! */ 220/* Version information string should be updated prior to each new release! */
220#define DRV_NAME "defxx" 221#define DRV_NAME "defxx"
221#define DRV_VERSION "v1.08" 222#define DRV_VERSION "v1.09"
222#define DRV_RELDATE "2005/06/14" 223#define DRV_RELDATE "2006/10/23"
223 224
224static char version[] __devinitdata = 225static char version[] __devinitdata =
225 DRV_NAME ": " DRV_VERSION " " DRV_RELDATE 226 DRV_NAME ": " DRV_VERSION " " DRV_RELDATE
@@ -859,6 +860,7 @@ static int __devinit dfx_driver_init(struct net_device *dev,
859 print_name); 860 print_name);
860 return(DFX_K_FAILURE); 861 return(DFX_K_FAILURE);
861 } 862 }
863 data = cpu_to_le32(data);
862 memcpy(&bp->factory_mac_addr[0], &data, sizeof(u32)); 864 memcpy(&bp->factory_mac_addr[0], &data, sizeof(u32));
863 865
864 if (dfx_hw_port_ctrl_req(bp, PI_PCTRL_M_MLA, PI_PDATA_A_MLA_K_HI, 0, 866 if (dfx_hw_port_ctrl_req(bp, PI_PCTRL_M_MLA, PI_PDATA_A_MLA_K_HI, 0,
@@ -867,6 +869,7 @@ static int __devinit dfx_driver_init(struct net_device *dev,
867 print_name); 869 print_name);
868 return(DFX_K_FAILURE); 870 return(DFX_K_FAILURE);
869 } 871 }
872 data = cpu_to_le32(data);
870 memcpy(&bp->factory_mac_addr[4], &data, sizeof(u16)); 873 memcpy(&bp->factory_mac_addr[4], &data, sizeof(u16));
871 874
872 /* 875 /*
@@ -1085,27 +1088,23 @@ static int dfx_adap_init(DFX_board_t *bp, int get_buffers)
1085 } 1088 }
1086 1089
1087 /* 1090 /*
1088 * Set base address of Descriptor Block and bring adapter to DMA_AVAILABLE state 1091 * Set the base address of Descriptor Block and bring adapter
1092 * to DMA_AVAILABLE state.
1089 * 1093 *
1090 * Note: We also set the literal and data swapping requirements in this 1094 * Note: We also set the literal and data swapping requirements
1091 * command. Since this driver presently runs on Intel platforms 1095 * in this command.
1092 * which are Little Endian, we'll tell the adapter to byte swap
1093 * data only. This code will need to change when we support
1094 * Big Endian systems (eg. PowerPC).
1095 * 1096 *
1096 * Assumption: 32-bit physical address of descriptor block is 8Kbyte 1097 * Assumption: 32-bit physical address of descriptor block
1097 * aligned. That is, bits 0-12 of the address must be zero. 1098 * is 8Kbyte aligned.
1098 */ 1099 */
1099 1100 if (dfx_hw_port_ctrl_req(bp, PI_PCTRL_M_INIT,
1100 if (dfx_hw_port_ctrl_req(bp, 1101 (u32)(bp->descr_block_phys |
1101 PI_PCTRL_M_INIT, 1102 PI_PDATA_A_INIT_M_BSWAP_INIT),
1102 (u32) (bp->descr_block_phys | PI_PDATA_A_INIT_M_BSWAP_DATA), 1103 0, NULL) != DFX_K_SUCCESS) {
1103 0, 1104 printk("%s: Could not set descriptor block address!\n",
1104 NULL) != DFX_K_SUCCESS) 1105 bp->dev->name);
1105 { 1106 return DFX_K_FAILURE;
1106 printk("%s: Could not set descriptor block address!\n", bp->dev->name); 1107 }
1107 return(DFX_K_FAILURE);
1108 }
1109 1108
1110 /* Set transmit flush timeout value */ 1109 /* Set transmit flush timeout value */
1111 1110
diff --git a/drivers/net/defxx.h b/drivers/net/defxx.h
index 8b1e9a11ca21..2ce8f97253eb 100644
--- a/drivers/net/defxx.h
+++ b/drivers/net/defxx.h
@@ -25,6 +25,7 @@
25 * macros to DEFXX.C. 25 * macros to DEFXX.C.
26 * 12-Sep-96 LVS Removed packet request header pointers. 26 * 12-Sep-96 LVS Removed packet request header pointers.
27 * 04 Aug 2003 macro Converted to the DMA API. 27 * 04 Aug 2003 macro Converted to the DMA API.
28 * 23 Oct 2006 macro Big-endian host support.
28 */ 29 */
29 30
30#ifndef _DEFXX_H_ 31#ifndef _DEFXX_H_
@@ -1344,7 +1345,7 @@ typedef struct
1344 1345
1345/* Register definition structures are defined for both big and little endian systems */ 1346/* Register definition structures are defined for both big and little endian systems */
1346 1347
1347#ifndef BIG_ENDIAN 1348#ifndef __BIG_ENDIAN
1348 1349
1349/* Little endian format of Type 1 Producer register */ 1350/* Little endian format of Type 1 Producer register */
1350 1351
@@ -1402,7 +1403,11 @@ typedef union
1402 } index; 1403 } index;
1403 } PI_TYPE_2_CONSUMER; 1404 } PI_TYPE_2_CONSUMER;
1404 1405
1405#else 1406/* Define swapping required by DMA transfers. */
1407#define PI_PDATA_A_INIT_M_BSWAP_INIT \
1408 (PI_PDATA_A_INIT_M_BSWAP_DATA)
1409
1410#else /* __BIG_ENDIAN */
1406 1411
1407/* Big endian format of Type 1 Producer register */ 1412/* Big endian format of Type 1 Producer register */
1408 1413
@@ -1460,7 +1465,11 @@ typedef union
1460 } index; 1465 } index;
1461 } PI_TYPE_2_CONSUMER; 1466 } PI_TYPE_2_CONSUMER;
1462 1467
1463#endif /* #ifndef BIG_ENDIAN */ 1468/* Define swapping required by DMA transfers. */
1469#define PI_PDATA_A_INIT_M_BSWAP_INIT \
1470 (PI_PDATA_A_INIT_M_BSWAP_DATA | PI_PDATA_A_INIT_M_BSWAP_LITERAL)
1471
1472#endif /* __BIG_ENDIAN */
1464 1473
1465/* Define EISA controller register offsets */ 1474/* Define EISA controller register offsets */
1466 1475
diff --git a/drivers/net/depca.c b/drivers/net/depca.c
index f87f6e3dc721..5113eef755b9 100644
--- a/drivers/net/depca.c
+++ b/drivers/net/depca.c
@@ -1252,24 +1252,22 @@ static void set_multicast_list(struct net_device *dev)
1252 struct depca_private *lp = (struct depca_private *) dev->priv; 1252 struct depca_private *lp = (struct depca_private *) dev->priv;
1253 u_long ioaddr = dev->base_addr; 1253 u_long ioaddr = dev->base_addr;
1254 1254
1255 if (dev) { 1255 netif_stop_queue(dev);
1256 netif_stop_queue(dev); 1256 while (lp->tx_old != lp->tx_new); /* Wait for the ring to empty */
1257 while (lp->tx_old != lp->tx_new); /* Wait for the ring to empty */
1258
1259 STOP_DEPCA; /* Temporarily stop the depca. */
1260 depca_init_ring(dev); /* Initialize the descriptor rings */
1261 1257
1262 if (dev->flags & IFF_PROMISC) { /* Set promiscuous mode */ 1258 STOP_DEPCA; /* Temporarily stop the depca. */
1263 lp->init_block.mode |= PROM; 1259 depca_init_ring(dev); /* Initialize the descriptor rings */
1264 } else {
1265 SetMulticastFilter(dev);
1266 lp->init_block.mode &= ~PROM; /* Unset promiscuous mode */
1267 }
1268 1260
1269 LoadCSRs(dev); /* Reload CSR3 */ 1261 if (dev->flags & IFF_PROMISC) { /* Set promiscuous mode */
1270 InitRestartDepca(dev); /* Resume normal operation. */ 1262 lp->init_block.mode |= PROM;
1271 netif_start_queue(dev); /* Unlock the TX ring */ 1263 } else {
1264 SetMulticastFilter(dev);
1265 lp->init_block.mode &= ~PROM; /* Unset promiscuous mode */
1272 } 1266 }
1267
1268 LoadCSRs(dev); /* Reload CSR3 */
1269 InitRestartDepca(dev); /* Resume normal operation. */
1270 netif_start_queue(dev); /* Unlock the TX ring */
1273} 1271}
1274 1272
1275/* 1273/*
diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index 19ab3441269c..03bf164f9e8d 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -1215,7 +1215,7 @@ static void e100_setup_ucode(struct nic *nic, struct cb *cb, struct sk_buff *skb
1215* the literal in the instruction before the code is loaded, the 1215* the literal in the instruction before the code is loaded, the
1216* driver can change the algorithm. 1216* driver can change the algorithm.
1217* 1217*
1218* INTDELAY - This loads the dead-man timer with its inital value. 1218* INTDELAY - This loads the dead-man timer with its initial value.
1219* When this timer expires the interrupt is asserted, and the 1219* When this timer expires the interrupt is asserted, and the
1220* timer is reset each time a new packet is received. (see 1220* timer is reset each time a new packet is received. (see
1221* BUNDLEMAX below to set the limit on number of chained packets) 1221* BUNDLEMAX below to set the limit on number of chained packets)
@@ -2102,9 +2102,10 @@ static void e100_tx_timeout(struct net_device *netdev)
2102 schedule_work(&nic->tx_timeout_task); 2102 schedule_work(&nic->tx_timeout_task);
2103} 2103}
2104 2104
2105static void e100_tx_timeout_task(struct net_device *netdev) 2105static void e100_tx_timeout_task(struct work_struct *work)
2106{ 2106{
2107 struct nic *nic = netdev_priv(netdev); 2107 struct nic *nic = container_of(work, struct nic, tx_timeout_task);
2108 struct net_device *netdev = nic->netdev;
2108 2109
2109 DPRINTK(TX_ERR, DEBUG, "scb.status=0x%02X\n", 2110 DPRINTK(TX_ERR, DEBUG, "scb.status=0x%02X\n",
2110 readb(&nic->csr->scb.status)); 2111 readb(&nic->csr->scb.status));
@@ -2637,8 +2638,7 @@ static int __devinit e100_probe(struct pci_dev *pdev,
2637 nic->blink_timer.function = e100_blink_led; 2638 nic->blink_timer.function = e100_blink_led;
2638 nic->blink_timer.data = (unsigned long)nic; 2639 nic->blink_timer.data = (unsigned long)nic;
2639 2640
2640 INIT_WORK(&nic->tx_timeout_task, 2641 INIT_WORK(&nic->tx_timeout_task, e100_tx_timeout_task);
2641 (void (*)(void *))e100_tx_timeout_task, netdev);
2642 2642
2643 if((err = e100_alloc(nic))) { 2643 if((err = e100_alloc(nic))) {
2644 DPRINTK(PROBE, ERR, "Cannot alloc driver memory, aborting.\n"); 2644 DPRINTK(PROBE, ERR, "Cannot alloc driver memory, aborting.\n");
diff --git a/drivers/net/e1000/e1000.h b/drivers/net/e1000/e1000.h
index 7ecce438d258..f091042b146e 100644
--- a/drivers/net/e1000/e1000.h
+++ b/drivers/net/e1000/e1000.h
@@ -59,6 +59,9 @@
59#include <linux/capability.h> 59#include <linux/capability.h>
60#include <linux/in.h> 60#include <linux/in.h>
61#include <linux/ip.h> 61#include <linux/ip.h>
62#ifdef NETIF_F_TSO6
63#include <linux/ipv6.h>
64#endif
62#include <linux/tcp.h> 65#include <linux/tcp.h>
63#include <linux/udp.h> 66#include <linux/udp.h>
64#include <net/pkt_sched.h> 67#include <net/pkt_sched.h>
@@ -254,6 +257,17 @@ struct e1000_adapter {
254 spinlock_t tx_queue_lock; 257 spinlock_t tx_queue_lock;
255#endif 258#endif
256 atomic_t irq_sem; 259 atomic_t irq_sem;
260 unsigned int detect_link;
261 unsigned int total_tx_bytes;
262 unsigned int total_tx_packets;
263 unsigned int total_rx_bytes;
264 unsigned int total_rx_packets;
265 /* Interrupt Throttle Rate */
266 uint32_t itr;
267 uint32_t itr_setting;
268 uint16_t tx_itr;
269 uint16_t rx_itr;
270
257 struct work_struct reset_task; 271 struct work_struct reset_task;
258 uint8_t fc_autoneg; 272 uint8_t fc_autoneg;
259 273
@@ -262,6 +276,7 @@ struct e1000_adapter {
262 276
263 /* TX */ 277 /* TX */
264 struct e1000_tx_ring *tx_ring; /* One per active queue */ 278 struct e1000_tx_ring *tx_ring; /* One per active queue */
279 unsigned int restart_queue;
265 unsigned long tx_queue_len; 280 unsigned long tx_queue_len;
266 uint32_t txd_cmd; 281 uint32_t txd_cmd;
267 uint32_t tx_int_delay; 282 uint32_t tx_int_delay;
@@ -310,8 +325,6 @@ struct e1000_adapter {
310 uint64_t gorcl_old; 325 uint64_t gorcl_old;
311 uint16_t rx_ps_bsize0; 326 uint16_t rx_ps_bsize0;
312 327
313 /* Interrupt Throttle Rate */
314 uint32_t itr;
315 328
316 /* OS defined structs */ 329 /* OS defined structs */
317 struct net_device *netdev; 330 struct net_device *netdev;
diff --git a/drivers/net/e1000/e1000_ethtool.c b/drivers/net/e1000/e1000_ethtool.c
index c564adbd669b..da459f7177c6 100644
--- a/drivers/net/e1000/e1000_ethtool.c
+++ b/drivers/net/e1000/e1000_ethtool.c
@@ -85,6 +85,7 @@ static const struct e1000_stats e1000_gstrings_stats[] = {
85 { "tx_single_coll_ok", E1000_STAT(stats.scc) }, 85 { "tx_single_coll_ok", E1000_STAT(stats.scc) },
86 { "tx_multi_coll_ok", E1000_STAT(stats.mcc) }, 86 { "tx_multi_coll_ok", E1000_STAT(stats.mcc) },
87 { "tx_timeout_count", E1000_STAT(tx_timeout_count) }, 87 { "tx_timeout_count", E1000_STAT(tx_timeout_count) },
88 { "tx_restart_queue", E1000_STAT(restart_queue) },
88 { "rx_long_length_errors", E1000_STAT(stats.roc) }, 89 { "rx_long_length_errors", E1000_STAT(stats.roc) },
89 { "rx_short_length_errors", E1000_STAT(stats.ruc) }, 90 { "rx_short_length_errors", E1000_STAT(stats.ruc) },
90 { "rx_align_errors", E1000_STAT(stats.algnerrc) }, 91 { "rx_align_errors", E1000_STAT(stats.algnerrc) },
@@ -133,9 +134,7 @@ e1000_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
133 134
134 if (hw->autoneg == 1) { 135 if (hw->autoneg == 1) {
135 ecmd->advertising |= ADVERTISED_Autoneg; 136 ecmd->advertising |= ADVERTISED_Autoneg;
136
137 /* the e1000 autoneg seems to match ethtool nicely */ 137 /* the e1000 autoneg seems to match ethtool nicely */
138
139 ecmd->advertising |= hw->autoneg_advertised; 138 ecmd->advertising |= hw->autoneg_advertised;
140 } 139 }
141 140
@@ -285,7 +284,7 @@ e1000_set_pauseparam(struct net_device *netdev,
285 e1000_reset(adapter); 284 e1000_reset(adapter);
286 } else 285 } else
287 retval = ((hw->media_type == e1000_media_type_fiber) ? 286 retval = ((hw->media_type == e1000_media_type_fiber) ?
288 e1000_setup_link(hw) : e1000_force_mac_fc(hw)); 287 e1000_setup_link(hw) : e1000_force_mac_fc(hw));
289 288
290 clear_bit(__E1000_RESETTING, &adapter->flags); 289 clear_bit(__E1000_RESETTING, &adapter->flags);
291 return retval; 290 return retval;
@@ -350,6 +349,13 @@ e1000_set_tso(struct net_device *netdev, uint32_t data)
350 else 349 else
351 netdev->features &= ~NETIF_F_TSO; 350 netdev->features &= ~NETIF_F_TSO;
352 351
352#ifdef NETIF_F_TSO6
353 if (data)
354 netdev->features |= NETIF_F_TSO6;
355 else
356 netdev->features &= ~NETIF_F_TSO6;
357#endif
358
353 DPRINTK(PROBE, INFO, "TSO is %s\n", data ? "Enabled" : "Disabled"); 359 DPRINTK(PROBE, INFO, "TSO is %s\n", data ? "Enabled" : "Disabled");
354 adapter->tso_force = TRUE; 360 adapter->tso_force = TRUE;
355 return 0; 361 return 0;
@@ -774,7 +780,7 @@ e1000_reg_test(struct e1000_adapter *adapter, uint64_t *data)
774 /* The status register is Read Only, so a write should fail. 780 /* The status register is Read Only, so a write should fail.
775 * Some bits that get toggled are ignored. 781 * Some bits that get toggled are ignored.
776 */ 782 */
777 switch (adapter->hw.mac_type) { 783 switch (adapter->hw.mac_type) {
778 /* there are several bits on newer hardware that are r/w */ 784 /* there are several bits on newer hardware that are r/w */
779 case e1000_82571: 785 case e1000_82571:
780 case e1000_82572: 786 case e1000_82572:
@@ -802,12 +808,14 @@ e1000_reg_test(struct e1000_adapter *adapter, uint64_t *data)
802 } 808 }
803 /* restore previous status */ 809 /* restore previous status */
804 E1000_WRITE_REG(&adapter->hw, STATUS, before); 810 E1000_WRITE_REG(&adapter->hw, STATUS, before);
811
805 if (adapter->hw.mac_type != e1000_ich8lan) { 812 if (adapter->hw.mac_type != e1000_ich8lan) {
806 REG_PATTERN_TEST(FCAL, 0xFFFFFFFF, 0xFFFFFFFF); 813 REG_PATTERN_TEST(FCAL, 0xFFFFFFFF, 0xFFFFFFFF);
807 REG_PATTERN_TEST(FCAH, 0x0000FFFF, 0xFFFFFFFF); 814 REG_PATTERN_TEST(FCAH, 0x0000FFFF, 0xFFFFFFFF);
808 REG_PATTERN_TEST(FCT, 0x0000FFFF, 0xFFFFFFFF); 815 REG_PATTERN_TEST(FCT, 0x0000FFFF, 0xFFFFFFFF);
809 REG_PATTERN_TEST(VET, 0x0000FFFF, 0xFFFFFFFF); 816 REG_PATTERN_TEST(VET, 0x0000FFFF, 0xFFFFFFFF);
810 } 817 }
818
811 REG_PATTERN_TEST(RDTR, 0x0000FFFF, 0xFFFFFFFF); 819 REG_PATTERN_TEST(RDTR, 0x0000FFFF, 0xFFFFFFFF);
812 REG_PATTERN_TEST(RDBAH, 0xFFFFFFFF, 0xFFFFFFFF); 820 REG_PATTERN_TEST(RDBAH, 0xFFFFFFFF, 0xFFFFFFFF);
813 REG_PATTERN_TEST(RDLEN, 0x000FFF80, 0x000FFFFF); 821 REG_PATTERN_TEST(RDLEN, 0x000FFF80, 0x000FFFFF);
@@ -820,8 +828,9 @@ e1000_reg_test(struct e1000_adapter *adapter, uint64_t *data)
820 REG_PATTERN_TEST(TDLEN, 0x000FFF80, 0x000FFFFF); 828 REG_PATTERN_TEST(TDLEN, 0x000FFF80, 0x000FFFFF);
821 829
822 REG_SET_AND_CHECK(RCTL, 0xFFFFFFFF, 0x00000000); 830 REG_SET_AND_CHECK(RCTL, 0xFFFFFFFF, 0x00000000);
831
823 before = (adapter->hw.mac_type == e1000_ich8lan ? 832 before = (adapter->hw.mac_type == e1000_ich8lan ?
824 0x06C3B33E : 0x06DFB3FE); 833 0x06C3B33E : 0x06DFB3FE);
825 REG_SET_AND_CHECK(RCTL, before, 0x003FFFFB); 834 REG_SET_AND_CHECK(RCTL, before, 0x003FFFFB);
826 REG_SET_AND_CHECK(TCTL, 0xFFFFFFFF, 0x00000000); 835 REG_SET_AND_CHECK(TCTL, 0xFFFFFFFF, 0x00000000);
827 836
@@ -834,10 +843,10 @@ e1000_reg_test(struct e1000_adapter *adapter, uint64_t *data)
834 REG_PATTERN_TEST(TDBAL, 0xFFFFFFF0, 0xFFFFFFFF); 843 REG_PATTERN_TEST(TDBAL, 0xFFFFFFF0, 0xFFFFFFFF);
835 REG_PATTERN_TEST(TIDV, 0x0000FFFF, 0x0000FFFF); 844 REG_PATTERN_TEST(TIDV, 0x0000FFFF, 0x0000FFFF);
836 value = (adapter->hw.mac_type == e1000_ich8lan ? 845 value = (adapter->hw.mac_type == e1000_ich8lan ?
837 E1000_RAR_ENTRIES_ICH8LAN : E1000_RAR_ENTRIES); 846 E1000_RAR_ENTRIES_ICH8LAN : E1000_RAR_ENTRIES);
838 for (i = 0; i < value; i++) { 847 for (i = 0; i < value; i++) {
839 REG_PATTERN_TEST(RA + (((i << 1) + 1) << 2), 0x8003FFFF, 848 REG_PATTERN_TEST(RA + (((i << 1) + 1) << 2), 0x8003FFFF,
840 0xFFFFFFFF); 849 0xFFFFFFFF);
841 } 850 }
842 851
843 } else { 852 } else {
@@ -883,8 +892,7 @@ e1000_eeprom_test(struct e1000_adapter *adapter, uint64_t *data)
883} 892}
884 893
885static irqreturn_t 894static irqreturn_t
886e1000_test_intr(int irq, 895e1000_test_intr(int irq, void *data)
887 void *data)
888{ 896{
889 struct net_device *netdev = (struct net_device *) data; 897 struct net_device *netdev = (struct net_device *) data;
890 struct e1000_adapter *adapter = netdev_priv(netdev); 898 struct e1000_adapter *adapter = netdev_priv(netdev);
@@ -905,11 +913,11 @@ e1000_intr_test(struct e1000_adapter *adapter, uint64_t *data)
905 913
906 /* NOTE: we don't test MSI interrupts here, yet */ 914 /* NOTE: we don't test MSI interrupts here, yet */
907 /* Hook up test interrupt handler just for this test */ 915 /* Hook up test interrupt handler just for this test */
908 if (!request_irq(irq, &e1000_test_intr, IRQF_PROBE_SHARED, 916 if (!request_irq(irq, &e1000_test_intr, IRQF_PROBE_SHARED, netdev->name,
909 netdev->name, netdev)) 917 netdev))
910 shared_int = FALSE; 918 shared_int = FALSE;
911 else if (request_irq(irq, &e1000_test_intr, IRQF_SHARED, 919 else if (request_irq(irq, &e1000_test_intr, IRQF_SHARED,
912 netdev->name, netdev)) { 920 netdev->name, netdev)) {
913 *data = 1; 921 *data = 1;
914 return -1; 922 return -1;
915 } 923 }
@@ -925,6 +933,7 @@ e1000_intr_test(struct e1000_adapter *adapter, uint64_t *data)
925 933
926 if (adapter->hw.mac_type == e1000_ich8lan && i == 8) 934 if (adapter->hw.mac_type == e1000_ich8lan && i == 8)
927 continue; 935 continue;
936
928 /* Interrupt to test */ 937 /* Interrupt to test */
929 mask = 1 << i; 938 mask = 1 << i;
930 939
@@ -1674,7 +1683,7 @@ e1000_diag_test(struct net_device *netdev,
1674 if (e1000_link_test(adapter, &data[4])) 1683 if (e1000_link_test(adapter, &data[4]))
1675 eth_test->flags |= ETH_TEST_FL_FAILED; 1684 eth_test->flags |= ETH_TEST_FL_FAILED;
1676 1685
1677 /* Offline tests aren't run; pass by default */ 1686 /* Online tests aren't run; pass by default */
1678 data[0] = 0; 1687 data[0] = 0;
1679 data[1] = 0; 1688 data[1] = 0;
1680 data[2] = 0; 1689 data[2] = 0;
@@ -1717,6 +1726,7 @@ static int e1000_wol_exclusion(struct e1000_adapter *adapter, struct ethtool_wol
1717 retval = 0; 1726 retval = 0;
1718 break; 1727 break;
1719 case E1000_DEV_ID_82571EB_QUAD_COPPER: 1728 case E1000_DEV_ID_82571EB_QUAD_COPPER:
1729 case E1000_DEV_ID_82571EB_QUAD_COPPER_LOWPROFILE:
1720 case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3: 1730 case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3:
1721 /* quad port adapters only support WoL on port A */ 1731 /* quad port adapters only support WoL on port A */
1722 if (!adapter->quad_port_a) { 1732 if (!adapter->quad_port_a) {
diff --git a/drivers/net/e1000/e1000_hw.c b/drivers/net/e1000/e1000_hw.c
index 65077f39da69..3655d902b0bd 100644
--- a/drivers/net/e1000/e1000_hw.c
+++ b/drivers/net/e1000/e1000_hw.c
@@ -385,6 +385,7 @@ e1000_set_mac_type(struct e1000_hw *hw)
385 case E1000_DEV_ID_82571EB_FIBER: 385 case E1000_DEV_ID_82571EB_FIBER:
386 case E1000_DEV_ID_82571EB_SERDES: 386 case E1000_DEV_ID_82571EB_SERDES:
387 case E1000_DEV_ID_82571EB_QUAD_COPPER: 387 case E1000_DEV_ID_82571EB_QUAD_COPPER:
388 case E1000_DEV_ID_82571EB_QUAD_COPPER_LOWPROFILE:
388 hw->mac_type = e1000_82571; 389 hw->mac_type = e1000_82571;
389 break; 390 break;
390 case E1000_DEV_ID_82572EI_COPPER: 391 case E1000_DEV_ID_82572EI_COPPER:
@@ -408,6 +409,8 @@ e1000_set_mac_type(struct e1000_hw *hw)
408 case E1000_DEV_ID_ICH8_IGP_AMT: 409 case E1000_DEV_ID_ICH8_IGP_AMT:
409 case E1000_DEV_ID_ICH8_IGP_C: 410 case E1000_DEV_ID_ICH8_IGP_C:
410 case E1000_DEV_ID_ICH8_IFE: 411 case E1000_DEV_ID_ICH8_IFE:
412 case E1000_DEV_ID_ICH8_IFE_GT:
413 case E1000_DEV_ID_ICH8_IFE_G:
411 case E1000_DEV_ID_ICH8_IGP_M: 414 case E1000_DEV_ID_ICH8_IGP_M:
412 hw->mac_type = e1000_ich8lan; 415 hw->mac_type = e1000_ich8lan;
413 break; 416 break;
@@ -2367,6 +2370,7 @@ e1000_phy_force_speed_duplex(struct e1000_hw *hw)
2367 2370
2368 /* Need to reset the PHY or these changes will be ignored */ 2371 /* Need to reset the PHY or these changes will be ignored */
2369 mii_ctrl_reg |= MII_CR_RESET; 2372 mii_ctrl_reg |= MII_CR_RESET;
2373
2370 /* Disable MDI-X support for 10/100 */ 2374 /* Disable MDI-X support for 10/100 */
2371 } else if (hw->phy_type == e1000_phy_ife) { 2375 } else if (hw->phy_type == e1000_phy_ife) {
2372 ret_val = e1000_read_phy_reg(hw, IFE_PHY_MDIX_CONTROL, &phy_data); 2376 ret_val = e1000_read_phy_reg(hw, IFE_PHY_MDIX_CONTROL, &phy_data);
@@ -2379,6 +2383,7 @@ e1000_phy_force_speed_duplex(struct e1000_hw *hw)
2379 ret_val = e1000_write_phy_reg(hw, IFE_PHY_MDIX_CONTROL, phy_data); 2383 ret_val = e1000_write_phy_reg(hw, IFE_PHY_MDIX_CONTROL, phy_data);
2380 if (ret_val) 2384 if (ret_val)
2381 return ret_val; 2385 return ret_val;
2386
2382 } else { 2387 } else {
2383 /* Clear Auto-Crossover to force MDI manually. IGP requires MDI 2388 /* Clear Auto-Crossover to force MDI manually. IGP requires MDI
2384 * forced whenever speed or duplex are forced. 2389 * forced whenever speed or duplex are forced.
@@ -3868,7 +3873,7 @@ e1000_phy_hw_reset(struct e1000_hw *hw)
3868* 3873*
3869* hw - Struct containing variables accessed by shared code 3874* hw - Struct containing variables accessed by shared code
3870* 3875*
3871* Sets bit 15 of the MII Control regiser 3876* Sets bit 15 of the MII Control register
3872******************************************************************************/ 3877******************************************************************************/
3873int32_t 3878int32_t
3874e1000_phy_reset(struct e1000_hw *hw) 3879e1000_phy_reset(struct e1000_hw *hw)
@@ -3940,14 +3945,15 @@ e1000_phy_powerdown_workaround(struct e1000_hw *hw)
3940 E1000_WRITE_REG(hw, PHY_CTRL, reg | E1000_PHY_CTRL_GBE_DISABLE | 3945 E1000_WRITE_REG(hw, PHY_CTRL, reg | E1000_PHY_CTRL_GBE_DISABLE |
3941 E1000_PHY_CTRL_NOND0A_GBE_DISABLE); 3946 E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
3942 3947
3943 /* Write VR power-down enable */ 3948 /* Write VR power-down enable - bits 9:8 should be 10b */
3944 e1000_read_phy_reg(hw, IGP3_VR_CTRL, &phy_data); 3949 e1000_read_phy_reg(hw, IGP3_VR_CTRL, &phy_data);
3945 e1000_write_phy_reg(hw, IGP3_VR_CTRL, phy_data | 3950 phy_data |= (1 << 9);
3946 IGP3_VR_CTRL_MODE_SHUT); 3951 phy_data &= ~(1 << 8);
3952 e1000_write_phy_reg(hw, IGP3_VR_CTRL, phy_data);
3947 3953
3948 /* Read it back and test */ 3954 /* Read it back and test */
3949 e1000_read_phy_reg(hw, IGP3_VR_CTRL, &phy_data); 3955 e1000_read_phy_reg(hw, IGP3_VR_CTRL, &phy_data);
3950 if ((phy_data & IGP3_VR_CTRL_MODE_SHUT) || retry) 3956 if (((phy_data & IGP3_VR_CTRL_MODE_MASK) == IGP3_VR_CTRL_MODE_SHUT) || retry)
3951 break; 3957 break;
3952 3958
3953 /* Issue PHY reset and repeat at most one more time */ 3959 /* Issue PHY reset and repeat at most one more time */
@@ -4549,7 +4555,7 @@ e1000_init_eeprom_params(struct e1000_hw *hw)
4549 case e1000_ich8lan: 4555 case e1000_ich8lan:
4550 { 4556 {
4551 int32_t i = 0; 4557 int32_t i = 0;
4552 uint32_t flash_size = E1000_READ_ICH8_REG(hw, ICH8_FLASH_GFPREG); 4558 uint32_t flash_size = E1000_READ_ICH_FLASH_REG(hw, ICH_FLASH_GFPREG);
4553 4559
4554 eeprom->type = e1000_eeprom_ich8; 4560 eeprom->type = e1000_eeprom_ich8;
4555 eeprom->use_eerd = FALSE; 4561 eeprom->use_eerd = FALSE;
@@ -4565,12 +4571,14 @@ e1000_init_eeprom_params(struct e1000_hw *hw)
4565 } 4571 }
4566 } 4572 }
4567 4573
4568 hw->flash_base_addr = (flash_size & ICH8_GFPREG_BASE_MASK) * 4574 hw->flash_base_addr = (flash_size & ICH_GFPREG_BASE_MASK) *
4569 ICH8_FLASH_SECTOR_SIZE; 4575 ICH_FLASH_SECTOR_SIZE;
4576
4577 hw->flash_bank_size = ((flash_size >> 16) & ICH_GFPREG_BASE_MASK) + 1;
4578 hw->flash_bank_size -= (flash_size & ICH_GFPREG_BASE_MASK);
4579
4580 hw->flash_bank_size *= ICH_FLASH_SECTOR_SIZE;
4570 4581
4571 hw->flash_bank_size = ((flash_size >> 16) & ICH8_GFPREG_BASE_MASK) + 1;
4572 hw->flash_bank_size -= (flash_size & ICH8_GFPREG_BASE_MASK);
4573 hw->flash_bank_size *= ICH8_FLASH_SECTOR_SIZE;
4574 hw->flash_bank_size /= 2 * sizeof(uint16_t); 4582 hw->flash_bank_size /= 2 * sizeof(uint16_t);
4575 4583
4576 break; 4584 break;
@@ -5620,8 +5628,8 @@ e1000_commit_shadow_ram(struct e1000_hw *hw)
5620 * signature is valid. We want to do this after the write 5628 * signature is valid. We want to do this after the write
5621 * has completed so that we don't mark the segment valid 5629 * has completed so that we don't mark the segment valid
5622 * while the write is still in progress */ 5630 * while the write is still in progress */
5623 if (i == E1000_ICH8_NVM_SIG_WORD) 5631 if (i == E1000_ICH_NVM_SIG_WORD)
5624 high_byte = E1000_ICH8_NVM_SIG_MASK | high_byte; 5632 high_byte = E1000_ICH_NVM_SIG_MASK | high_byte;
5625 5633
5626 error = e1000_verify_write_ich8_byte(hw, 5634 error = e1000_verify_write_ich8_byte(hw,
5627 (i << 1) + new_bank_offset + 1, high_byte); 5635 (i << 1) + new_bank_offset + 1, high_byte);
@@ -5643,18 +5651,18 @@ e1000_commit_shadow_ram(struct e1000_hw *hw)
5643 * erase as well since these bits are 11 to start with 5651 * erase as well since these bits are 11 to start with
5644 * and we need to change bit 14 to 0b */ 5652 * and we need to change bit 14 to 0b */
5645 e1000_read_ich8_byte(hw, 5653 e1000_read_ich8_byte(hw,
5646 E1000_ICH8_NVM_SIG_WORD * 2 + 1 + new_bank_offset, 5654 E1000_ICH_NVM_SIG_WORD * 2 + 1 + new_bank_offset,
5647 &high_byte); 5655 &high_byte);
5648 high_byte &= 0xBF; 5656 high_byte &= 0xBF;
5649 error = e1000_verify_write_ich8_byte(hw, 5657 error = e1000_verify_write_ich8_byte(hw,
5650 E1000_ICH8_NVM_SIG_WORD * 2 + 1 + new_bank_offset, high_byte); 5658 E1000_ICH_NVM_SIG_WORD * 2 + 1 + new_bank_offset, high_byte);
5651 /* And invalidate the previously valid segment by setting 5659 /* And invalidate the previously valid segment by setting
5652 * its signature word (0x13) high_byte to 0b. This can be 5660 * its signature word (0x13) high_byte to 0b. This can be
5653 * done without an erase because flash erase sets all bits 5661 * done without an erase because flash erase sets all bits
5654 * to 1's. We can write 1's to 0's without an erase */ 5662 * to 1's. We can write 1's to 0's without an erase */
5655 if (error == E1000_SUCCESS) { 5663 if (error == E1000_SUCCESS) {
5656 error = e1000_verify_write_ich8_byte(hw, 5664 error = e1000_verify_write_ich8_byte(hw,
5657 E1000_ICH8_NVM_SIG_WORD * 2 + 1 + old_bank_offset, 0); 5665 E1000_ICH_NVM_SIG_WORD * 2 + 1 + old_bank_offset, 0);
5658 } 5666 }
5659 5667
5660 /* Clear the now not used entry in the cache */ 5668 /* Clear the now not used entry in the cache */
@@ -5841,6 +5849,7 @@ e1000_mta_set(struct e1000_hw *hw,
5841 hash_reg = (hash_value >> 5) & 0x7F; 5849 hash_reg = (hash_value >> 5) & 0x7F;
5842 if (hw->mac_type == e1000_ich8lan) 5850 if (hw->mac_type == e1000_ich8lan)
5843 hash_reg &= 0x1F; 5851 hash_reg &= 0x1F;
5852
5844 hash_bit = hash_value & 0x1F; 5853 hash_bit = hash_value & 0x1F;
5845 5854
5846 mta = E1000_READ_REG_ARRAY(hw, MTA, hash_reg); 5855 mta = E1000_READ_REG_ARRAY(hw, MTA, hash_reg);
@@ -6026,6 +6035,7 @@ e1000_id_led_init(struct e1000_hw * hw)
6026 else 6035 else
6027 eeprom_data = ID_LED_DEFAULT; 6036 eeprom_data = ID_LED_DEFAULT;
6028 } 6037 }
6038
6029 for (i = 0; i < 4; i++) { 6039 for (i = 0; i < 4; i++) {
6030 temp = (eeprom_data >> (i << 2)) & led_mask; 6040 temp = (eeprom_data >> (i << 2)) & led_mask;
6031 switch (temp) { 6041 switch (temp) {
@@ -8486,7 +8496,7 @@ e1000_ich8_cycle_init(struct e1000_hw *hw)
8486 8496
8487 DEBUGFUNC("e1000_ich8_cycle_init"); 8497 DEBUGFUNC("e1000_ich8_cycle_init");
8488 8498
8489 hsfsts.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFSTS); 8499 hsfsts.regval = E1000_READ_ICH_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
8490 8500
8491 /* May be check the Flash Des Valid bit in Hw status */ 8501 /* May be check the Flash Des Valid bit in Hw status */
8492 if (hsfsts.hsf_status.fldesvalid == 0) { 8502 if (hsfsts.hsf_status.fldesvalid == 0) {
@@ -8499,7 +8509,7 @@ e1000_ich8_cycle_init(struct e1000_hw *hw)
8499 hsfsts.hsf_status.flcerr = 1; 8509 hsfsts.hsf_status.flcerr = 1;
8500 hsfsts.hsf_status.dael = 1; 8510 hsfsts.hsf_status.dael = 1;
8501 8511
8502 E1000_WRITE_ICH8_REG16(hw, ICH8_FLASH_HSFSTS, hsfsts.regval); 8512 E1000_WRITE_ICH_FLASH_REG16(hw, ICH_FLASH_HSFSTS, hsfsts.regval);
8503 8513
8504 /* Either we should have a hardware SPI cycle in progress bit to check 8514 /* Either we should have a hardware SPI cycle in progress bit to check
8505 * against, in order to start a new cycle or FDONE bit should be changed 8515 * against, in order to start a new cycle or FDONE bit should be changed
@@ -8514,13 +8524,13 @@ e1000_ich8_cycle_init(struct e1000_hw *hw)
8514 /* There is no cycle running at present, so we can start a cycle */ 8524 /* There is no cycle running at present, so we can start a cycle */
8515 /* Begin by setting Flash Cycle Done. */ 8525 /* Begin by setting Flash Cycle Done. */
8516 hsfsts.hsf_status.flcdone = 1; 8526 hsfsts.hsf_status.flcdone = 1;
8517 E1000_WRITE_ICH8_REG16(hw, ICH8_FLASH_HSFSTS, hsfsts.regval); 8527 E1000_WRITE_ICH_FLASH_REG16(hw, ICH_FLASH_HSFSTS, hsfsts.regval);
8518 error = E1000_SUCCESS; 8528 error = E1000_SUCCESS;
8519 } else { 8529 } else {
8520 /* otherwise poll for sometime so the current cycle has a chance 8530 /* otherwise poll for sometime so the current cycle has a chance
8521 * to end before giving up. */ 8531 * to end before giving up. */
8522 for (i = 0; i < ICH8_FLASH_COMMAND_TIMEOUT; i++) { 8532 for (i = 0; i < ICH_FLASH_COMMAND_TIMEOUT; i++) {
8523 hsfsts.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFSTS); 8533 hsfsts.regval = E1000_READ_ICH_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
8524 if (hsfsts.hsf_status.flcinprog == 0) { 8534 if (hsfsts.hsf_status.flcinprog == 0) {
8525 error = E1000_SUCCESS; 8535 error = E1000_SUCCESS;
8526 break; 8536 break;
@@ -8531,7 +8541,7 @@ e1000_ich8_cycle_init(struct e1000_hw *hw)
8531 /* Successful in waiting for previous cycle to timeout, 8541 /* Successful in waiting for previous cycle to timeout,
8532 * now set the Flash Cycle Done. */ 8542 * now set the Flash Cycle Done. */
8533 hsfsts.hsf_status.flcdone = 1; 8543 hsfsts.hsf_status.flcdone = 1;
8534 E1000_WRITE_ICH8_REG16(hw, ICH8_FLASH_HSFSTS, hsfsts.regval); 8544 E1000_WRITE_ICH_FLASH_REG16(hw, ICH_FLASH_HSFSTS, hsfsts.regval);
8535 } else { 8545 } else {
8536 DEBUGOUT("Flash controller busy, cannot get access"); 8546 DEBUGOUT("Flash controller busy, cannot get access");
8537 } 8547 }
@@ -8553,13 +8563,13 @@ e1000_ich8_flash_cycle(struct e1000_hw *hw, uint32_t timeout)
8553 uint32_t i = 0; 8563 uint32_t i = 0;
8554 8564
8555 /* Start a cycle by writing 1 in Flash Cycle Go in Hw Flash Control */ 8565 /* Start a cycle by writing 1 in Flash Cycle Go in Hw Flash Control */
8556 hsflctl.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFCTL); 8566 hsflctl.regval = E1000_READ_ICH_FLASH_REG16(hw, ICH_FLASH_HSFCTL);
8557 hsflctl.hsf_ctrl.flcgo = 1; 8567 hsflctl.hsf_ctrl.flcgo = 1;
8558 E1000_WRITE_ICH8_REG16(hw, ICH8_FLASH_HSFCTL, hsflctl.regval); 8568 E1000_WRITE_ICH_FLASH_REG16(hw, ICH_FLASH_HSFCTL, hsflctl.regval);
8559 8569
8560 /* wait till FDONE bit is set to 1 */ 8570 /* wait till FDONE bit is set to 1 */
8561 do { 8571 do {
8562 hsfsts.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFSTS); 8572 hsfsts.regval = E1000_READ_ICH_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
8563 if (hsfsts.hsf_status.flcdone == 1) 8573 if (hsfsts.hsf_status.flcdone == 1)
8564 break; 8574 break;
8565 udelay(1); 8575 udelay(1);
@@ -8593,10 +8603,10 @@ e1000_read_ich8_data(struct e1000_hw *hw, uint32_t index,
8593 DEBUGFUNC("e1000_read_ich8_data"); 8603 DEBUGFUNC("e1000_read_ich8_data");
8594 8604
8595 if (size < 1 || size > 2 || data == 0x0 || 8605 if (size < 1 || size > 2 || data == 0x0 ||
8596 index > ICH8_FLASH_LINEAR_ADDR_MASK) 8606 index > ICH_FLASH_LINEAR_ADDR_MASK)
8597 return error; 8607 return error;
8598 8608
8599 flash_linear_address = (ICH8_FLASH_LINEAR_ADDR_MASK & index) + 8609 flash_linear_address = (ICH_FLASH_LINEAR_ADDR_MASK & index) +
8600 hw->flash_base_addr; 8610 hw->flash_base_addr;
8601 8611
8602 do { 8612 do {
@@ -8606,25 +8616,25 @@ e1000_read_ich8_data(struct e1000_hw *hw, uint32_t index,
8606 if (error != E1000_SUCCESS) 8616 if (error != E1000_SUCCESS)
8607 break; 8617 break;
8608 8618
8609 hsflctl.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFCTL); 8619 hsflctl.regval = E1000_READ_ICH_FLASH_REG16(hw, ICH_FLASH_HSFCTL);
8610 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */ 8620 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
8611 hsflctl.hsf_ctrl.fldbcount = size - 1; 8621 hsflctl.hsf_ctrl.fldbcount = size - 1;
8612 hsflctl.hsf_ctrl.flcycle = ICH8_CYCLE_READ; 8622 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_READ;
8613 E1000_WRITE_ICH8_REG16(hw, ICH8_FLASH_HSFCTL, hsflctl.regval); 8623 E1000_WRITE_ICH_FLASH_REG16(hw, ICH_FLASH_HSFCTL, hsflctl.regval);
8614 8624
8615 /* Write the last 24 bits of index into Flash Linear address field in 8625 /* Write the last 24 bits of index into Flash Linear address field in
8616 * Flash Address */ 8626 * Flash Address */
8617 /* TODO: TBD maybe check the index against the size of flash */ 8627 /* TODO: TBD maybe check the index against the size of flash */
8618 8628
8619 E1000_WRITE_ICH8_REG(hw, ICH8_FLASH_FADDR, flash_linear_address); 8629 E1000_WRITE_ICH_FLASH_REG(hw, ICH_FLASH_FADDR, flash_linear_address);
8620 8630
8621 error = e1000_ich8_flash_cycle(hw, ICH8_FLASH_COMMAND_TIMEOUT); 8631 error = e1000_ich8_flash_cycle(hw, ICH_FLASH_COMMAND_TIMEOUT);
8622 8632
8623 /* Check if FCERR is set to 1, if set to 1, clear it and try the whole 8633 /* Check if FCERR is set to 1, if set to 1, clear it and try the whole
8624 * sequence a few more times, else read in (shift in) the Flash Data0, 8634 * sequence a few more times, else read in (shift in) the Flash Data0,
8625 * the order is least significant byte first msb to lsb */ 8635 * the order is least significant byte first msb to lsb */
8626 if (error == E1000_SUCCESS) { 8636 if (error == E1000_SUCCESS) {
8627 flash_data = E1000_READ_ICH8_REG(hw, ICH8_FLASH_FDATA0); 8637 flash_data = E1000_READ_ICH_FLASH_REG(hw, ICH_FLASH_FDATA0);
8628 if (size == 1) { 8638 if (size == 1) {
8629 *data = (uint8_t)(flash_data & 0x000000FF); 8639 *data = (uint8_t)(flash_data & 0x000000FF);
8630 } else if (size == 2) { 8640 } else if (size == 2) {
@@ -8634,9 +8644,9 @@ e1000_read_ich8_data(struct e1000_hw *hw, uint32_t index,
8634 } else { 8644 } else {
8635 /* If we've gotten here, then things are probably completely hosed, 8645 /* If we've gotten here, then things are probably completely hosed,
8636 * but if the error condition is detected, it won't hurt to give 8646 * but if the error condition is detected, it won't hurt to give
8637 * it another try...ICH8_FLASH_CYCLE_REPEAT_COUNT times. 8647 * it another try...ICH_FLASH_CYCLE_REPEAT_COUNT times.
8638 */ 8648 */
8639 hsfsts.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFSTS); 8649 hsfsts.regval = E1000_READ_ICH_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
8640 if (hsfsts.hsf_status.flcerr == 1) { 8650 if (hsfsts.hsf_status.flcerr == 1) {
8641 /* Repeat for some time before giving up. */ 8651 /* Repeat for some time before giving up. */
8642 continue; 8652 continue;
@@ -8645,7 +8655,7 @@ e1000_read_ich8_data(struct e1000_hw *hw, uint32_t index,
8645 break; 8655 break;
8646 } 8656 }
8647 } 8657 }
8648 } while (count++ < ICH8_FLASH_CYCLE_REPEAT_COUNT); 8658 } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
8649 8659
8650 return error; 8660 return error;
8651} 8661}
@@ -8672,10 +8682,10 @@ e1000_write_ich8_data(struct e1000_hw *hw, uint32_t index, uint32_t size,
8672 DEBUGFUNC("e1000_write_ich8_data"); 8682 DEBUGFUNC("e1000_write_ich8_data");
8673 8683
8674 if (size < 1 || size > 2 || data > size * 0xff || 8684 if (size < 1 || size > 2 || data > size * 0xff ||
8675 index > ICH8_FLASH_LINEAR_ADDR_MASK) 8685 index > ICH_FLASH_LINEAR_ADDR_MASK)
8676 return error; 8686 return error;
8677 8687
8678 flash_linear_address = (ICH8_FLASH_LINEAR_ADDR_MASK & index) + 8688 flash_linear_address = (ICH_FLASH_LINEAR_ADDR_MASK & index) +
8679 hw->flash_base_addr; 8689 hw->flash_base_addr;
8680 8690
8681 do { 8691 do {
@@ -8685,34 +8695,34 @@ e1000_write_ich8_data(struct e1000_hw *hw, uint32_t index, uint32_t size,
8685 if (error != E1000_SUCCESS) 8695 if (error != E1000_SUCCESS)
8686 break; 8696 break;
8687 8697
8688 hsflctl.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFCTL); 8698 hsflctl.regval = E1000_READ_ICH_FLASH_REG16(hw, ICH_FLASH_HSFCTL);
8689 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */ 8699 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
8690 hsflctl.hsf_ctrl.fldbcount = size -1; 8700 hsflctl.hsf_ctrl.fldbcount = size -1;
8691 hsflctl.hsf_ctrl.flcycle = ICH8_CYCLE_WRITE; 8701 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_WRITE;
8692 E1000_WRITE_ICH8_REG16(hw, ICH8_FLASH_HSFCTL, hsflctl.regval); 8702 E1000_WRITE_ICH_FLASH_REG16(hw, ICH_FLASH_HSFCTL, hsflctl.regval);
8693 8703
8694 /* Write the last 24 bits of index into Flash Linear address field in 8704 /* Write the last 24 bits of index into Flash Linear address field in
8695 * Flash Address */ 8705 * Flash Address */
8696 E1000_WRITE_ICH8_REG(hw, ICH8_FLASH_FADDR, flash_linear_address); 8706 E1000_WRITE_ICH_FLASH_REG(hw, ICH_FLASH_FADDR, flash_linear_address);
8697 8707
8698 if (size == 1) 8708 if (size == 1)
8699 flash_data = (uint32_t)data & 0x00FF; 8709 flash_data = (uint32_t)data & 0x00FF;
8700 else 8710 else
8701 flash_data = (uint32_t)data; 8711 flash_data = (uint32_t)data;
8702 8712
8703 E1000_WRITE_ICH8_REG(hw, ICH8_FLASH_FDATA0, flash_data); 8713 E1000_WRITE_ICH_FLASH_REG(hw, ICH_FLASH_FDATA0, flash_data);
8704 8714
8705 /* check if FCERR is set to 1 , if set to 1, clear it and try the whole 8715 /* check if FCERR is set to 1 , if set to 1, clear it and try the whole
8706 * sequence a few more times else done */ 8716 * sequence a few more times else done */
8707 error = e1000_ich8_flash_cycle(hw, ICH8_FLASH_COMMAND_TIMEOUT); 8717 error = e1000_ich8_flash_cycle(hw, ICH_FLASH_COMMAND_TIMEOUT);
8708 if (error == E1000_SUCCESS) { 8718 if (error == E1000_SUCCESS) {
8709 break; 8719 break;
8710 } else { 8720 } else {
8711 /* If we're here, then things are most likely completely hosed, 8721 /* If we're here, then things are most likely completely hosed,
8712 * but if the error condition is detected, it won't hurt to give 8722 * but if the error condition is detected, it won't hurt to give
8713 * it another try...ICH8_FLASH_CYCLE_REPEAT_COUNT times. 8723 * it another try...ICH_FLASH_CYCLE_REPEAT_COUNT times.
8714 */ 8724 */
8715 hsfsts.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFSTS); 8725 hsfsts.regval = E1000_READ_ICH_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
8716 if (hsfsts.hsf_status.flcerr == 1) { 8726 if (hsfsts.hsf_status.flcerr == 1) {
8717 /* Repeat for some time before giving up. */ 8727 /* Repeat for some time before giving up. */
8718 continue; 8728 continue;
@@ -8721,7 +8731,7 @@ e1000_write_ich8_data(struct e1000_hw *hw, uint32_t index, uint32_t size,
8721 break; 8731 break;
8722 } 8732 }
8723 } 8733 }
8724 } while (count++ < ICH8_FLASH_CYCLE_REPEAT_COUNT); 8734 } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
8725 8735
8726 return error; 8736 return error;
8727} 8737}
@@ -8840,7 +8850,7 @@ e1000_erase_ich8_4k_segment(struct e1000_hw *hw, uint32_t bank)
8840 int32_t j = 0; 8850 int32_t j = 0;
8841 int32_t error_flag = 0; 8851 int32_t error_flag = 0;
8842 8852
8843 hsfsts.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFSTS); 8853 hsfsts.regval = E1000_READ_ICH_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
8844 8854
8845 /* Determine HW Sector size: Read BERASE bits of Hw flash Status register */ 8855 /* Determine HW Sector size: Read BERASE bits of Hw flash Status register */
8846 /* 00: The Hw sector is 256 bytes, hence we need to erase 16 8856 /* 00: The Hw sector is 256 bytes, hence we need to erase 16
@@ -8853,19 +8863,14 @@ e1000_erase_ich8_4k_segment(struct e1000_hw *hw, uint32_t bank)
8853 * 11: The Hw sector size is 64K bytes */ 8863 * 11: The Hw sector size is 64K bytes */
8854 if (hsfsts.hsf_status.berasesz == 0x0) { 8864 if (hsfsts.hsf_status.berasesz == 0x0) {
8855 /* Hw sector size 256 */ 8865 /* Hw sector size 256 */
8856 sub_sector_size = ICH8_FLASH_SEG_SIZE_256; 8866 sub_sector_size = ICH_FLASH_SEG_SIZE_256;
8857 bank_size = ICH8_FLASH_SECTOR_SIZE; 8867 bank_size = ICH_FLASH_SECTOR_SIZE;
8858 iteration = ICH8_FLASH_SECTOR_SIZE / ICH8_FLASH_SEG_SIZE_256; 8868 iteration = ICH_FLASH_SECTOR_SIZE / ICH_FLASH_SEG_SIZE_256;
8859 } else if (hsfsts.hsf_status.berasesz == 0x1) { 8869 } else if (hsfsts.hsf_status.berasesz == 0x1) {
8860 bank_size = ICH8_FLASH_SEG_SIZE_4K; 8870 bank_size = ICH_FLASH_SEG_SIZE_4K;
8861 iteration = 1;
8862 } else if (hw->mac_type != e1000_ich8lan &&
8863 hsfsts.hsf_status.berasesz == 0x2) {
8864 /* 8K erase size invalid for ICH8 - added in for ICH9 */
8865 bank_size = ICH9_FLASH_SEG_SIZE_8K;
8866 iteration = 1; 8871 iteration = 1;
8867 } else if (hsfsts.hsf_status.berasesz == 0x3) { 8872 } else if (hsfsts.hsf_status.berasesz == 0x3) {
8868 bank_size = ICH8_FLASH_SEG_SIZE_64K; 8873 bank_size = ICH_FLASH_SEG_SIZE_64K;
8869 iteration = 1; 8874 iteration = 1;
8870 } else { 8875 } else {
8871 return error; 8876 return error;
@@ -8883,9 +8888,9 @@ e1000_erase_ich8_4k_segment(struct e1000_hw *hw, uint32_t bank)
8883 8888
8884 /* Write a value 11 (block Erase) in Flash Cycle field in Hw flash 8889 /* Write a value 11 (block Erase) in Flash Cycle field in Hw flash
8885 * Control */ 8890 * Control */
8886 hsflctl.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFCTL); 8891 hsflctl.regval = E1000_READ_ICH_FLASH_REG16(hw, ICH_FLASH_HSFCTL);
8887 hsflctl.hsf_ctrl.flcycle = ICH8_CYCLE_ERASE; 8892 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_ERASE;
8888 E1000_WRITE_ICH8_REG16(hw, ICH8_FLASH_HSFCTL, hsflctl.regval); 8893 E1000_WRITE_ICH_FLASH_REG16(hw, ICH_FLASH_HSFCTL, hsflctl.regval);
8889 8894
8890 /* Write the last 24 bits of an index within the block into Flash 8895 /* Write the last 24 bits of an index within the block into Flash
8891 * Linear address field in Flash Address. This probably needs to 8896 * Linear address field in Flash Address. This probably needs to
@@ -8893,17 +8898,17 @@ e1000_erase_ich8_4k_segment(struct e1000_hw *hw, uint32_t bank)
8893 * the software bank size (4, 8 or 64 KBytes) */ 8898 * the software bank size (4, 8 or 64 KBytes) */
8894 flash_linear_address = bank * bank_size + j * sub_sector_size; 8899 flash_linear_address = bank * bank_size + j * sub_sector_size;
8895 flash_linear_address += hw->flash_base_addr; 8900 flash_linear_address += hw->flash_base_addr;
8896 flash_linear_address &= ICH8_FLASH_LINEAR_ADDR_MASK; 8901 flash_linear_address &= ICH_FLASH_LINEAR_ADDR_MASK;
8897 8902
8898 E1000_WRITE_ICH8_REG(hw, ICH8_FLASH_FADDR, flash_linear_address); 8903 E1000_WRITE_ICH_FLASH_REG(hw, ICH_FLASH_FADDR, flash_linear_address);
8899 8904
8900 error = e1000_ich8_flash_cycle(hw, ICH8_FLASH_ERASE_TIMEOUT); 8905 error = e1000_ich8_flash_cycle(hw, ICH_FLASH_ERASE_TIMEOUT);
8901 /* Check if FCERR is set to 1. If 1, clear it and try the whole 8906 /* Check if FCERR is set to 1. If 1, clear it and try the whole
8902 * sequence a few more times else Done */ 8907 * sequence a few more times else Done */
8903 if (error == E1000_SUCCESS) { 8908 if (error == E1000_SUCCESS) {
8904 break; 8909 break;
8905 } else { 8910 } else {
8906 hsfsts.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFSTS); 8911 hsfsts.regval = E1000_READ_ICH_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
8907 if (hsfsts.hsf_status.flcerr == 1) { 8912 if (hsfsts.hsf_status.flcerr == 1) {
8908 /* repeat for some time before giving up */ 8913 /* repeat for some time before giving up */
8909 continue; 8914 continue;
@@ -8912,7 +8917,7 @@ e1000_erase_ich8_4k_segment(struct e1000_hw *hw, uint32_t bank)
8912 break; 8917 break;
8913 } 8918 }
8914 } 8919 }
8915 } while ((count < ICH8_FLASH_CYCLE_REPEAT_COUNT) && !error_flag); 8920 } while ((count < ICH_FLASH_CYCLE_REPEAT_COUNT) && !error_flag);
8916 if (error_flag == 1) 8921 if (error_flag == 1)
8917 break; 8922 break;
8918 } 8923 }
@@ -9013,5 +9018,3 @@ e1000_init_lcd_from_nvm(struct e1000_hw *hw)
9013 return E1000_SUCCESS; 9018 return E1000_SUCCESS;
9014} 9019}
9015 9020
9016
9017
diff --git a/drivers/net/e1000/e1000_hw.h b/drivers/net/e1000/e1000_hw.h
index 449a60303e07..3321fb13bfa9 100644
--- a/drivers/net/e1000/e1000_hw.h
+++ b/drivers/net/e1000/e1000_hw.h
@@ -128,11 +128,13 @@ typedef enum {
128/* PCI bus widths */ 128/* PCI bus widths */
129typedef enum { 129typedef enum {
130 e1000_bus_width_unknown = 0, 130 e1000_bus_width_unknown = 0,
131 /* These PCIe values should literally match the possible return values
132 * from config space */
133 e1000_bus_width_pciex_1 = 1,
134 e1000_bus_width_pciex_2 = 2,
135 e1000_bus_width_pciex_4 = 4,
131 e1000_bus_width_32, 136 e1000_bus_width_32,
132 e1000_bus_width_64, 137 e1000_bus_width_64,
133 e1000_bus_width_pciex_1,
134 e1000_bus_width_pciex_2,
135 e1000_bus_width_pciex_4,
136 e1000_bus_width_reserved 138 e1000_bus_width_reserved
137} e1000_bus_width; 139} e1000_bus_width;
138 140
@@ -326,6 +328,7 @@ int32_t e1000_phy_hw_reset(struct e1000_hw *hw);
326int32_t e1000_phy_reset(struct e1000_hw *hw); 328int32_t e1000_phy_reset(struct e1000_hw *hw);
327int32_t e1000_phy_get_info(struct e1000_hw *hw, struct e1000_phy_info *phy_info); 329int32_t e1000_phy_get_info(struct e1000_hw *hw, struct e1000_phy_info *phy_info);
328int32_t e1000_validate_mdi_setting(struct e1000_hw *hw); 330int32_t e1000_validate_mdi_setting(struct e1000_hw *hw);
331
329void e1000_phy_powerdown_workaround(struct e1000_hw *hw); 332void e1000_phy_powerdown_workaround(struct e1000_hw *hw);
330 333
331/* EEPROM Functions */ 334/* EEPROM Functions */
@@ -390,7 +393,6 @@ int32_t e1000_mng_write_dhcp_info(struct e1000_hw *hw, uint8_t *buffer,
390 uint16_t length); 393 uint16_t length);
391boolean_t e1000_check_mng_mode(struct e1000_hw *hw); 394boolean_t e1000_check_mng_mode(struct e1000_hw *hw);
392boolean_t e1000_enable_tx_pkt_filtering(struct e1000_hw *hw); 395boolean_t e1000_enable_tx_pkt_filtering(struct e1000_hw *hw);
393
394int32_t e1000_read_eeprom(struct e1000_hw *hw, uint16_t reg, uint16_t words, uint16_t *data); 396int32_t e1000_read_eeprom(struct e1000_hw *hw, uint16_t reg, uint16_t words, uint16_t *data);
395int32_t e1000_validate_eeprom_checksum(struct e1000_hw *hw); 397int32_t e1000_validate_eeprom_checksum(struct e1000_hw *hw);
396int32_t e1000_update_eeprom_checksum(struct e1000_hw *hw); 398int32_t e1000_update_eeprom_checksum(struct e1000_hw *hw);
@@ -473,6 +475,7 @@ int32_t e1000_check_phy_reset_block(struct e1000_hw *hw);
473#define E1000_DEV_ID_82571EB_FIBER 0x105F 475#define E1000_DEV_ID_82571EB_FIBER 0x105F
474#define E1000_DEV_ID_82571EB_SERDES 0x1060 476#define E1000_DEV_ID_82571EB_SERDES 0x1060
475#define E1000_DEV_ID_82571EB_QUAD_COPPER 0x10A4 477#define E1000_DEV_ID_82571EB_QUAD_COPPER 0x10A4
478#define E1000_DEV_ID_82571EB_QUAD_COPPER_LOWPROFILE 0x10BC
476#define E1000_DEV_ID_82572EI_COPPER 0x107D 479#define E1000_DEV_ID_82572EI_COPPER 0x107D
477#define E1000_DEV_ID_82572EI_FIBER 0x107E 480#define E1000_DEV_ID_82572EI_FIBER 0x107E
478#define E1000_DEV_ID_82572EI_SERDES 0x107F 481#define E1000_DEV_ID_82572EI_SERDES 0x107F
@@ -490,6 +493,8 @@ int32_t e1000_check_phy_reset_block(struct e1000_hw *hw);
490#define E1000_DEV_ID_ICH8_IGP_AMT 0x104A 493#define E1000_DEV_ID_ICH8_IGP_AMT 0x104A
491#define E1000_DEV_ID_ICH8_IGP_C 0x104B 494#define E1000_DEV_ID_ICH8_IGP_C 0x104B
492#define E1000_DEV_ID_ICH8_IFE 0x104C 495#define E1000_DEV_ID_ICH8_IFE 0x104C
496#define E1000_DEV_ID_ICH8_IFE_GT 0x10C4
497#define E1000_DEV_ID_ICH8_IFE_G 0x10C5
493#define E1000_DEV_ID_ICH8_IGP_M 0x104D 498#define E1000_DEV_ID_ICH8_IGP_M 0x104D
494 499
495 500
@@ -576,6 +581,7 @@ int32_t e1000_check_phy_reset_block(struct e1000_hw *hw);
576 * E1000_RAR_ENTRIES - 1 multicast addresses. 581 * E1000_RAR_ENTRIES - 1 multicast addresses.
577 */ 582 */
578#define E1000_RAR_ENTRIES 15 583#define E1000_RAR_ENTRIES 15
584
579#define E1000_RAR_ENTRIES_ICH8LAN 6 585#define E1000_RAR_ENTRIES_ICH8LAN 6
580 586
581#define MIN_NUMBER_OF_DESCRIPTORS 8 587#define MIN_NUMBER_OF_DESCRIPTORS 8
@@ -1335,9 +1341,9 @@ struct e1000_hw_stats {
1335 uint64_t gotch; 1341 uint64_t gotch;
1336 uint64_t rnbc; 1342 uint64_t rnbc;
1337 uint64_t ruc; 1343 uint64_t ruc;
1344 uint64_t rfc;
1338 uint64_t roc; 1345 uint64_t roc;
1339 uint64_t rlerrc; 1346 uint64_t rlerrc;
1340 uint64_t rfc;
1341 uint64_t rjc; 1347 uint64_t rjc;
1342 uint64_t mgprc; 1348 uint64_t mgprc;
1343 uint64_t mgpdc; 1349 uint64_t mgpdc;
@@ -1577,8 +1583,8 @@ struct e1000_hw {
1577#define E1000_HICR_FW_RESET 0xC0 1583#define E1000_HICR_FW_RESET 0xC0
1578 1584
1579#define E1000_SHADOW_RAM_WORDS 2048 1585#define E1000_SHADOW_RAM_WORDS 2048
1580#define E1000_ICH8_NVM_SIG_WORD 0x13 1586#define E1000_ICH_NVM_SIG_WORD 0x13
1581#define E1000_ICH8_NVM_SIG_MASK 0xC0 1587#define E1000_ICH_NVM_SIG_MASK 0xC0
1582 1588
1583/* EEPROM Read */ 1589/* EEPROM Read */
1584#define E1000_EERD_START 0x00000001 /* Start Read */ 1590#define E1000_EERD_START 0x00000001 /* Start Read */
@@ -3172,6 +3178,7 @@ struct e1000_host_command_info {
3172#define IGP3_VR_CTRL \ 3178#define IGP3_VR_CTRL \
3173 PHY_REG(776, 18) /* Voltage regulator control register */ 3179 PHY_REG(776, 18) /* Voltage regulator control register */
3174#define IGP3_VR_CTRL_MODE_SHUT 0x0200 /* Enter powerdown, shutdown VRs */ 3180#define IGP3_VR_CTRL_MODE_SHUT 0x0200 /* Enter powerdown, shutdown VRs */
3181#define IGP3_VR_CTRL_MODE_MASK 0x0300 /* Shutdown VR Mask */
3175 3182
3176#define IGP3_CAPABILITY \ 3183#define IGP3_CAPABILITY \
3177 PHY_REG(776, 19) /* IGP3 Capability Register */ 3184 PHY_REG(776, 19) /* IGP3 Capability Register */
@@ -3256,41 +3263,40 @@ struct e1000_host_command_info {
3256#define IFE_PSCL_PROBE_LEDS_OFF 0x0006 /* Force LEDs 0 and 2 off */ 3263#define IFE_PSCL_PROBE_LEDS_OFF 0x0006 /* Force LEDs 0 and 2 off */
3257#define IFE_PSCL_PROBE_LEDS_ON 0x0007 /* Force LEDs 0 and 2 on */ 3264#define IFE_PSCL_PROBE_LEDS_ON 0x0007 /* Force LEDs 0 and 2 on */
3258 3265
3259#define ICH8_FLASH_COMMAND_TIMEOUT 5000 /* 5000 uSecs - adjusted */ 3266#define ICH_FLASH_COMMAND_TIMEOUT 5000 /* 5000 uSecs - adjusted */
3260#define ICH8_FLASH_ERASE_TIMEOUT 3000000 /* Up to 3 seconds - worst case */ 3267#define ICH_FLASH_ERASE_TIMEOUT 3000000 /* Up to 3 seconds - worst case */
3261#define ICH8_FLASH_CYCLE_REPEAT_COUNT 10 /* 10 cycles */ 3268#define ICH_FLASH_CYCLE_REPEAT_COUNT 10 /* 10 cycles */
3262#define ICH8_FLASH_SEG_SIZE_256 256 3269#define ICH_FLASH_SEG_SIZE_256 256
3263#define ICH8_FLASH_SEG_SIZE_4K 4096 3270#define ICH_FLASH_SEG_SIZE_4K 4096
3264#define ICH9_FLASH_SEG_SIZE_8K 8192 3271#define ICH_FLASH_SEG_SIZE_64K 65536
3265#define ICH8_FLASH_SEG_SIZE_64K 65536 3272
3266 3273#define ICH_CYCLE_READ 0x0
3267#define ICH8_CYCLE_READ 0x0 3274#define ICH_CYCLE_RESERVED 0x1
3268#define ICH8_CYCLE_RESERVED 0x1 3275#define ICH_CYCLE_WRITE 0x2
3269#define ICH8_CYCLE_WRITE 0x2 3276#define ICH_CYCLE_ERASE 0x3
3270#define ICH8_CYCLE_ERASE 0x3 3277
3271 3278#define ICH_FLASH_GFPREG 0x0000
3272#define ICH8_FLASH_GFPREG 0x0000 3279#define ICH_FLASH_HSFSTS 0x0004
3273#define ICH8_FLASH_HSFSTS 0x0004 3280#define ICH_FLASH_HSFCTL 0x0006
3274#define ICH8_FLASH_HSFCTL 0x0006 3281#define ICH_FLASH_FADDR 0x0008
3275#define ICH8_FLASH_FADDR 0x0008 3282#define ICH_FLASH_FDATA0 0x0010
3276#define ICH8_FLASH_FDATA0 0x0010 3283#define ICH_FLASH_FRACC 0x0050
3277#define ICH8_FLASH_FRACC 0x0050 3284#define ICH_FLASH_FREG0 0x0054
3278#define ICH8_FLASH_FREG0 0x0054 3285#define ICH_FLASH_FREG1 0x0058
3279#define ICH8_FLASH_FREG1 0x0058 3286#define ICH_FLASH_FREG2 0x005C
3280#define ICH8_FLASH_FREG2 0x005C 3287#define ICH_FLASH_FREG3 0x0060
3281#define ICH8_FLASH_FREG3 0x0060 3288#define ICH_FLASH_FPR0 0x0074
3282#define ICH8_FLASH_FPR0 0x0074 3289#define ICH_FLASH_FPR1 0x0078
3283#define ICH8_FLASH_FPR1 0x0078 3290#define ICH_FLASH_SSFSTS 0x0090
3284#define ICH8_FLASH_SSFSTS 0x0090 3291#define ICH_FLASH_SSFCTL 0x0092
3285#define ICH8_FLASH_SSFCTL 0x0092 3292#define ICH_FLASH_PREOP 0x0094
3286#define ICH8_FLASH_PREOP 0x0094 3293#define ICH_FLASH_OPTYPE 0x0096
3287#define ICH8_FLASH_OPTYPE 0x0096 3294#define ICH_FLASH_OPMENU 0x0098
3288#define ICH8_FLASH_OPMENU 0x0098 3295
3289 3296#define ICH_FLASH_REG_MAPSIZE 0x00A0
3290#define ICH8_FLASH_REG_MAPSIZE 0x00A0 3297#define ICH_FLASH_SECTOR_SIZE 4096
3291#define ICH8_FLASH_SECTOR_SIZE 4096 3298#define ICH_GFPREG_BASE_MASK 0x1FFF
3292#define ICH8_GFPREG_BASE_MASK 0x1FFF 3299#define ICH_FLASH_LINEAR_ADDR_MASK 0x00FFFFFF
3293#define ICH8_FLASH_LINEAR_ADDR_MASK 0x00FFFFFF
3294 3300
3295/* ICH8 GbE Flash Hardware Sequencing Flash Status Register bit breakdown */ 3301/* ICH8 GbE Flash Hardware Sequencing Flash Status Register bit breakdown */
3296/* Offset 04h HSFSTS */ 3302/* Offset 04h HSFSTS */
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 8d04752777a8..73f3a85fd238 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -27,6 +27,7 @@
27*******************************************************************************/ 27*******************************************************************************/
28 28
29#include "e1000.h" 29#include "e1000.h"
30#include <net/ip6_checksum.h>
30 31
31char e1000_driver_name[] = "e1000"; 32char e1000_driver_name[] = "e1000";
32static char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver"; 33static char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver";
@@ -35,7 +36,7 @@ static char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver";
35#else 36#else
36#define DRIVERNAPI "-NAPI" 37#define DRIVERNAPI "-NAPI"
37#endif 38#endif
38#define DRV_VERSION "7.2.9-k4"DRIVERNAPI 39#define DRV_VERSION "7.3.15-k2"DRIVERNAPI
39char e1000_driver_version[] = DRV_VERSION; 40char e1000_driver_version[] = DRV_VERSION;
40static char e1000_copyright[] = "Copyright (c) 1999-2006 Intel Corporation."; 41static char e1000_copyright[] = "Copyright (c) 1999-2006 Intel Corporation.";
41 42
@@ -103,6 +104,9 @@ static struct pci_device_id e1000_pci_tbl[] = {
103 INTEL_E1000_ETHERNET_DEVICE(0x10B9), 104 INTEL_E1000_ETHERNET_DEVICE(0x10B9),
104 INTEL_E1000_ETHERNET_DEVICE(0x10BA), 105 INTEL_E1000_ETHERNET_DEVICE(0x10BA),
105 INTEL_E1000_ETHERNET_DEVICE(0x10BB), 106 INTEL_E1000_ETHERNET_DEVICE(0x10BB),
107 INTEL_E1000_ETHERNET_DEVICE(0x10BC),
108 INTEL_E1000_ETHERNET_DEVICE(0x10C4),
109 INTEL_E1000_ETHERNET_DEVICE(0x10C5),
106 /* required last entry */ 110 /* required last entry */
107 {0,} 111 {0,}
108}; 112};
@@ -154,6 +158,9 @@ static struct net_device_stats * e1000_get_stats(struct net_device *netdev);
154static int e1000_change_mtu(struct net_device *netdev, int new_mtu); 158static int e1000_change_mtu(struct net_device *netdev, int new_mtu);
155static int e1000_set_mac(struct net_device *netdev, void *p); 159static int e1000_set_mac(struct net_device *netdev, void *p);
156static irqreturn_t e1000_intr(int irq, void *data); 160static irqreturn_t e1000_intr(int irq, void *data);
161#ifdef CONFIG_PCI_MSI
162static irqreturn_t e1000_intr_msi(int irq, void *data);
163#endif
157static boolean_t e1000_clean_tx_irq(struct e1000_adapter *adapter, 164static boolean_t e1000_clean_tx_irq(struct e1000_adapter *adapter,
158 struct e1000_tx_ring *tx_ring); 165 struct e1000_tx_ring *tx_ring);
159#ifdef CONFIG_E1000_NAPI 166#ifdef CONFIG_E1000_NAPI
@@ -183,7 +190,7 @@ void e1000_set_ethtool_ops(struct net_device *netdev);
183static void e1000_enter_82542_rst(struct e1000_adapter *adapter); 190static void e1000_enter_82542_rst(struct e1000_adapter *adapter);
184static void e1000_leave_82542_rst(struct e1000_adapter *adapter); 191static void e1000_leave_82542_rst(struct e1000_adapter *adapter);
185static void e1000_tx_timeout(struct net_device *dev); 192static void e1000_tx_timeout(struct net_device *dev);
186static void e1000_reset_task(struct net_device *dev); 193static void e1000_reset_task(struct work_struct *work);
187static void e1000_smartspeed(struct e1000_adapter *adapter); 194static void e1000_smartspeed(struct e1000_adapter *adapter);
188static int e1000_82547_fifo_workaround(struct e1000_adapter *adapter, 195static int e1000_82547_fifo_workaround(struct e1000_adapter *adapter,
189 struct sk_buff *skb); 196 struct sk_buff *skb);
@@ -285,7 +292,7 @@ static int e1000_request_irq(struct e1000_adapter *adapter)
285 292
286 flags = IRQF_SHARED; 293 flags = IRQF_SHARED;
287#ifdef CONFIG_PCI_MSI 294#ifdef CONFIG_PCI_MSI
288 if (adapter->hw.mac_type > e1000_82547_rev_2) { 295 if (adapter->hw.mac_type >= e1000_82571) {
289 adapter->have_msi = TRUE; 296 adapter->have_msi = TRUE;
290 if ((err = pci_enable_msi(adapter->pdev))) { 297 if ((err = pci_enable_msi(adapter->pdev))) {
291 DPRINTK(PROBE, ERR, 298 DPRINTK(PROBE, ERR,
@@ -293,8 +300,14 @@ static int e1000_request_irq(struct e1000_adapter *adapter)
293 adapter->have_msi = FALSE; 300 adapter->have_msi = FALSE;
294 } 301 }
295 } 302 }
296 if (adapter->have_msi) 303 if (adapter->have_msi) {
297 flags &= ~IRQF_SHARED; 304 flags &= ~IRQF_SHARED;
305 err = request_irq(adapter->pdev->irq, &e1000_intr_msi, flags,
306 netdev->name, netdev);
307 if (err)
308 DPRINTK(PROBE, ERR,
309 "Unable to allocate interrupt Error: %d\n", err);
310 } else
298#endif 311#endif
299 if ((err = request_irq(adapter->pdev->irq, &e1000_intr, flags, 312 if ((err = request_irq(adapter->pdev->irq, &e1000_intr, flags,
300 netdev->name, netdev))) 313 netdev->name, netdev)))
@@ -375,7 +388,7 @@ e1000_update_mng_vlan(struct e1000_adapter *adapter)
375 * e1000_release_hw_control resets {CTRL_EXT|FWSM}:DRV_LOAD bit. 388 * e1000_release_hw_control resets {CTRL_EXT|FWSM}:DRV_LOAD bit.
376 * For ASF and Pass Through versions of f/w this means that the 389 * For ASF and Pass Through versions of f/w this means that the
377 * driver is no longer loaded. For AMT version (only with 82573) i 390 * driver is no longer loaded. For AMT version (only with 82573) i
378 * of the f/w this means that the netowrk i/f is closed. 391 * of the f/w this means that the network i/f is closed.
379 * 392 *
380 **/ 393 **/
381 394
@@ -416,7 +429,7 @@ e1000_release_hw_control(struct e1000_adapter *adapter)
416 * e1000_get_hw_control sets {CTRL_EXT|FWSM}:DRV_LOAD bit. 429 * e1000_get_hw_control sets {CTRL_EXT|FWSM}:DRV_LOAD bit.
417 * For ASF and Pass Through versions of f/w this means that 430 * For ASF and Pass Through versions of f/w this means that
418 * the driver is loaded. For AMT version (only with 82573) 431 * the driver is loaded. For AMT version (only with 82573)
419 * of the f/w this means that the netowrk i/f is open. 432 * of the f/w this means that the network i/f is open.
420 * 433 *
421 **/ 434 **/
422 435
@@ -426,6 +439,7 @@ e1000_get_hw_control(struct e1000_adapter *adapter)
426 uint32_t ctrl_ext; 439 uint32_t ctrl_ext;
427 uint32_t swsm; 440 uint32_t swsm;
428 uint32_t extcnf; 441 uint32_t extcnf;
442
429 /* Let firmware know the driver has taken over */ 443 /* Let firmware know the driver has taken over */
430 switch (adapter->hw.mac_type) { 444 switch (adapter->hw.mac_type) {
431 case e1000_82571: 445 case e1000_82571:
@@ -601,9 +615,6 @@ void
601e1000_reset(struct e1000_adapter *adapter) 615e1000_reset(struct e1000_adapter *adapter)
602{ 616{
603 uint32_t pba, manc; 617 uint32_t pba, manc;
604#ifdef DISABLE_MULR
605 uint32_t tctl;
606#endif
607 uint16_t fc_high_water_mark = E1000_FC_HIGH_DIFF; 618 uint16_t fc_high_water_mark = E1000_FC_HIGH_DIFF;
608 619
609 /* Repartition Pba for greater than 9k mtu 620 /* Repartition Pba for greater than 9k mtu
@@ -670,12 +681,7 @@ e1000_reset(struct e1000_adapter *adapter)
670 e1000_reset_hw(&adapter->hw); 681 e1000_reset_hw(&adapter->hw);
671 if (adapter->hw.mac_type >= e1000_82544) 682 if (adapter->hw.mac_type >= e1000_82544)
672 E1000_WRITE_REG(&adapter->hw, WUC, 0); 683 E1000_WRITE_REG(&adapter->hw, WUC, 0);
673#ifdef DISABLE_MULR
674 /* disable Multiple Reads in Transmit Control Register for debugging */
675 tctl = E1000_READ_REG(hw, TCTL);
676 E1000_WRITE_REG(hw, TCTL, tctl & ~E1000_TCTL_MULR);
677 684
678#endif
679 if (e1000_init_hw(&adapter->hw)) 685 if (e1000_init_hw(&adapter->hw))
680 DPRINTK(PROBE, ERR, "Hardware Error\n"); 686 DPRINTK(PROBE, ERR, "Hardware Error\n");
681 e1000_update_mng_vlan(adapter); 687 e1000_update_mng_vlan(adapter);
@@ -851,9 +857,9 @@ e1000_probe(struct pci_dev *pdev,
851 (adapter->hw.mac_type != e1000_82547)) 857 (adapter->hw.mac_type != e1000_82547))
852 netdev->features |= NETIF_F_TSO; 858 netdev->features |= NETIF_F_TSO;
853 859
854#ifdef NETIF_F_TSO_IPV6 860#ifdef NETIF_F_TSO6
855 if (adapter->hw.mac_type > e1000_82547_rev_2) 861 if (adapter->hw.mac_type > e1000_82547_rev_2)
856 netdev->features |= NETIF_F_TSO_IPV6; 862 netdev->features |= NETIF_F_TSO6;
857#endif 863#endif
858#endif 864#endif
859 if (pci_using_dac) 865 if (pci_using_dac)
@@ -908,8 +914,7 @@ e1000_probe(struct pci_dev *pdev,
908 adapter->phy_info_timer.function = &e1000_update_phy_info; 914 adapter->phy_info_timer.function = &e1000_update_phy_info;
909 adapter->phy_info_timer.data = (unsigned long) adapter; 915 adapter->phy_info_timer.data = (unsigned long) adapter;
910 916
911 INIT_WORK(&adapter->reset_task, 917 INIT_WORK(&adapter->reset_task, e1000_reset_task);
912 (void (*)(void *))e1000_reset_task, netdev);
913 918
914 e1000_check_options(adapter); 919 e1000_check_options(adapter);
915 920
@@ -968,6 +973,7 @@ e1000_probe(struct pci_dev *pdev,
968 break; 973 break;
969 case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3: 974 case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3:
970 case E1000_DEV_ID_82571EB_QUAD_COPPER: 975 case E1000_DEV_ID_82571EB_QUAD_COPPER:
976 case E1000_DEV_ID_82571EB_QUAD_COPPER_LOWPROFILE:
971 /* if quad port adapter, disable WoL on all but port A */ 977 /* if quad port adapter, disable WoL on all but port A */
972 if (global_quad_port_a != 0) 978 if (global_quad_port_a != 0)
973 adapter->eeprom_wol = 0; 979 adapter->eeprom_wol = 0;
@@ -1279,12 +1285,10 @@ e1000_open(struct net_device *netdev)
1279 return -EBUSY; 1285 return -EBUSY;
1280 1286
1281 /* allocate transmit descriptors */ 1287 /* allocate transmit descriptors */
1282
1283 if ((err = e1000_setup_all_tx_resources(adapter))) 1288 if ((err = e1000_setup_all_tx_resources(adapter)))
1284 goto err_setup_tx; 1289 goto err_setup_tx;
1285 1290
1286 /* allocate receive descriptors */ 1291 /* allocate receive descriptors */
1287
1288 if ((err = e1000_setup_all_rx_resources(adapter))) 1292 if ((err = e1000_setup_all_rx_resources(adapter)))
1289 goto err_setup_rx; 1293 goto err_setup_rx;
1290 1294
@@ -1569,6 +1573,8 @@ e1000_configure_tx(struct e1000_adapter *adapter)
1569 1573
1570 if (hw->mac_type == e1000_82571 || hw->mac_type == e1000_82572) { 1574 if (hw->mac_type == e1000_82571 || hw->mac_type == e1000_82572) {
1571 tarc = E1000_READ_REG(hw, TARC0); 1575 tarc = E1000_READ_REG(hw, TARC0);
1576 /* set the speed mode bit, we'll clear it if we're not at
1577 * gigabit link later */
1572 tarc |= (1 << 21); 1578 tarc |= (1 << 21);
1573 E1000_WRITE_REG(hw, TARC0, tarc); 1579 E1000_WRITE_REG(hw, TARC0, tarc);
1574 } else if (hw->mac_type == e1000_80003es2lan) { 1580 } else if (hw->mac_type == e1000_80003es2lan) {
@@ -1583,8 +1589,11 @@ e1000_configure_tx(struct e1000_adapter *adapter)
1583 e1000_config_collision_dist(hw); 1589 e1000_config_collision_dist(hw);
1584 1590
1585 /* Setup Transmit Descriptor Settings for eop descriptor */ 1591 /* Setup Transmit Descriptor Settings for eop descriptor */
1586 adapter->txd_cmd = E1000_TXD_CMD_IDE | E1000_TXD_CMD_EOP | 1592 adapter->txd_cmd = E1000_TXD_CMD_EOP | E1000_TXD_CMD_IFCS;
1587 E1000_TXD_CMD_IFCS; 1593
1594 /* only set IDE if we are delaying interrupts using the timers */
1595 if (adapter->tx_int_delay)
1596 adapter->txd_cmd |= E1000_TXD_CMD_IDE;
1588 1597
1589 if (hw->mac_type < e1000_82543) 1598 if (hw->mac_type < e1000_82543)
1590 adapter->txd_cmd |= E1000_TXD_CMD_RPS; 1599 adapter->txd_cmd |= E1000_TXD_CMD_RPS;
@@ -1821,8 +1830,11 @@ e1000_setup_rctl(struct e1000_adapter *adapter)
1821 /* Configure extra packet-split registers */ 1830 /* Configure extra packet-split registers */
1822 rfctl = E1000_READ_REG(&adapter->hw, RFCTL); 1831 rfctl = E1000_READ_REG(&adapter->hw, RFCTL);
1823 rfctl |= E1000_RFCTL_EXTEN; 1832 rfctl |= E1000_RFCTL_EXTEN;
1824 /* disable IPv6 packet split support */ 1833 /* disable packet split support for IPv6 extension headers,
1825 rfctl |= E1000_RFCTL_IPV6_DIS; 1834 * because some malformed IPv6 headers can hang the RX */
1835 rfctl |= (E1000_RFCTL_IPV6_EX_DIS |
1836 E1000_RFCTL_NEW_IPV6_EXT_DIS);
1837
1826 E1000_WRITE_REG(&adapter->hw, RFCTL, rfctl); 1838 E1000_WRITE_REG(&adapter->hw, RFCTL, rfctl);
1827 1839
1828 rctl |= E1000_RCTL_DTYP_PS; 1840 rctl |= E1000_RCTL_DTYP_PS;
@@ -1885,7 +1897,7 @@ e1000_configure_rx(struct e1000_adapter *adapter)
1885 1897
1886 if (hw->mac_type >= e1000_82540) { 1898 if (hw->mac_type >= e1000_82540) {
1887 E1000_WRITE_REG(hw, RADV, adapter->rx_abs_int_delay); 1899 E1000_WRITE_REG(hw, RADV, adapter->rx_abs_int_delay);
1888 if (adapter->itr > 1) 1900 if (adapter->itr_setting != 0)
1889 E1000_WRITE_REG(hw, ITR, 1901 E1000_WRITE_REG(hw, ITR,
1890 1000000000 / (adapter->itr * 256)); 1902 1000000000 / (adapter->itr * 256));
1891 } 1903 }
@@ -1895,11 +1907,11 @@ e1000_configure_rx(struct e1000_adapter *adapter)
1895 /* Reset delay timers after every interrupt */ 1907 /* Reset delay timers after every interrupt */
1896 ctrl_ext |= E1000_CTRL_EXT_INT_TIMER_CLR; 1908 ctrl_ext |= E1000_CTRL_EXT_INT_TIMER_CLR;
1897#ifdef CONFIG_E1000_NAPI 1909#ifdef CONFIG_E1000_NAPI
1898 /* Auto-Mask interrupts upon ICR read. */ 1910 /* Auto-Mask interrupts upon ICR access */
1899 ctrl_ext |= E1000_CTRL_EXT_IAME; 1911 ctrl_ext |= E1000_CTRL_EXT_IAME;
1912 E1000_WRITE_REG(hw, IAM, 0xffffffff);
1900#endif 1913#endif
1901 E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext); 1914 E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
1902 E1000_WRITE_REG(hw, IAM, ~0);
1903 E1000_WRITE_FLUSH(hw); 1915 E1000_WRITE_FLUSH(hw);
1904 } 1916 }
1905 1917
@@ -1938,6 +1950,12 @@ e1000_configure_rx(struct e1000_adapter *adapter)
1938 E1000_WRITE_REG(hw, RXCSUM, rxcsum); 1950 E1000_WRITE_REG(hw, RXCSUM, rxcsum);
1939 } 1951 }
1940 1952
1953 /* enable early receives on 82573, only takes effect if using > 2048
1954 * byte total frame size. for example only for jumbo frames */
1955#define E1000_ERT_2048 0x100
1956 if (hw->mac_type == e1000_82573)
1957 E1000_WRITE_REG(hw, ERT, E1000_ERT_2048);
1958
1941 /* Enable Receives */ 1959 /* Enable Receives */
1942 E1000_WRITE_REG(hw, RCTL, rctl); 1960 E1000_WRITE_REG(hw, RCTL, rctl);
1943} 1961}
@@ -1991,10 +2009,13 @@ e1000_unmap_and_free_tx_resource(struct e1000_adapter *adapter,
1991 buffer_info->dma, 2009 buffer_info->dma,
1992 buffer_info->length, 2010 buffer_info->length,
1993 PCI_DMA_TODEVICE); 2011 PCI_DMA_TODEVICE);
2012 buffer_info->dma = 0;
1994 } 2013 }
1995 if (buffer_info->skb) 2014 if (buffer_info->skb) {
1996 dev_kfree_skb_any(buffer_info->skb); 2015 dev_kfree_skb_any(buffer_info->skb);
1997 memset(buffer_info, 0, sizeof(struct e1000_buffer)); 2016 buffer_info->skb = NULL;
2017 }
2018 /* buffer_info must be completely set up in the transmit path */
1998} 2019}
1999 2020
2000/** 2021/**
@@ -2418,6 +2439,7 @@ e1000_watchdog(unsigned long data)
2418 DPRINTK(LINK, INFO, 2439 DPRINTK(LINK, INFO,
2419 "Gigabit has been disabled, downgrading speed\n"); 2440 "Gigabit has been disabled, downgrading speed\n");
2420 } 2441 }
2442
2421 if (adapter->hw.mac_type == e1000_82573) { 2443 if (adapter->hw.mac_type == e1000_82573) {
2422 e1000_enable_tx_pkt_filtering(&adapter->hw); 2444 e1000_enable_tx_pkt_filtering(&adapter->hw);
2423 if (adapter->mng_vlan_id != adapter->hw.mng_cookie.vlan_id) 2445 if (adapter->mng_vlan_id != adapter->hw.mng_cookie.vlan_id)
@@ -2462,13 +2484,12 @@ e1000_watchdog(unsigned long data)
2462 if ((adapter->hw.mac_type == e1000_82571 || 2484 if ((adapter->hw.mac_type == e1000_82571 ||
2463 adapter->hw.mac_type == e1000_82572) && 2485 adapter->hw.mac_type == e1000_82572) &&
2464 txb2b == 0) { 2486 txb2b == 0) {
2465#define SPEED_MODE_BIT (1 << 21)
2466 uint32_t tarc0; 2487 uint32_t tarc0;
2467 tarc0 = E1000_READ_REG(&adapter->hw, TARC0); 2488 tarc0 = E1000_READ_REG(&adapter->hw, TARC0);
2468 tarc0 &= ~SPEED_MODE_BIT; 2489 tarc0 &= ~(1 << 21);
2469 E1000_WRITE_REG(&adapter->hw, TARC0, tarc0); 2490 E1000_WRITE_REG(&adapter->hw, TARC0, tarc0);
2470 } 2491 }
2471 2492
2472#ifdef NETIF_F_TSO 2493#ifdef NETIF_F_TSO
2473 /* disable TSO for pcie and 10/100 speeds, to avoid 2494 /* disable TSO for pcie and 10/100 speeds, to avoid
2474 * some hardware issues */ 2495 * some hardware issues */
@@ -2480,9 +2501,15 @@ e1000_watchdog(unsigned long data)
2480 DPRINTK(PROBE,INFO, 2501 DPRINTK(PROBE,INFO,
2481 "10/100 speed: disabling TSO\n"); 2502 "10/100 speed: disabling TSO\n");
2482 netdev->features &= ~NETIF_F_TSO; 2503 netdev->features &= ~NETIF_F_TSO;
2504#ifdef NETIF_F_TSO6
2505 netdev->features &= ~NETIF_F_TSO6;
2506#endif
2483 break; 2507 break;
2484 case SPEED_1000: 2508 case SPEED_1000:
2485 netdev->features |= NETIF_F_TSO; 2509 netdev->features |= NETIF_F_TSO;
2510#ifdef NETIF_F_TSO6
2511 netdev->features |= NETIF_F_TSO6;
2512#endif
2486 break; 2513 break;
2487 default: 2514 default:
2488 /* oops */ 2515 /* oops */
@@ -2549,19 +2576,6 @@ e1000_watchdog(unsigned long data)
2549 } 2576 }
2550 } 2577 }
2551 2578
2552 /* Dynamic mode for Interrupt Throttle Rate (ITR) */
2553 if (adapter->hw.mac_type >= e1000_82540 && adapter->itr == 1) {
2554 /* Symmetric Tx/Rx gets a reduced ITR=2000; Total
2555 * asymmetrical Tx or Rx gets ITR=8000; everyone
2556 * else is between 2000-8000. */
2557 uint32_t goc = (adapter->gotcl + adapter->gorcl) / 10000;
2558 uint32_t dif = (adapter->gotcl > adapter->gorcl ?
2559 adapter->gotcl - adapter->gorcl :
2560 adapter->gorcl - adapter->gotcl) / 10000;
2561 uint32_t itr = goc > 0 ? (dif * 6000 / goc + 2000) : 8000;
2562 E1000_WRITE_REG(&adapter->hw, ITR, 1000000000 / (itr * 256));
2563 }
2564
2565 /* Cause software interrupt to ensure rx ring is cleaned */ 2579 /* Cause software interrupt to ensure rx ring is cleaned */
2566 E1000_WRITE_REG(&adapter->hw, ICS, E1000_ICS_RXDMT0); 2580 E1000_WRITE_REG(&adapter->hw, ICS, E1000_ICS_RXDMT0);
2567 2581
@@ -2577,6 +2591,135 @@ e1000_watchdog(unsigned long data)
2577 mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ); 2591 mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ);
2578} 2592}
2579 2593
2594enum latency_range {
2595 lowest_latency = 0,
2596 low_latency = 1,
2597 bulk_latency = 2,
2598 latency_invalid = 255
2599};
2600
2601/**
2602 * e1000_update_itr - update the dynamic ITR value based on statistics
2603 * Stores a new ITR value based on packets and byte
2604 * counts during the last interrupt. The advantage of per interrupt
2605 * computation is faster updates and more accurate ITR for the current
2606 * traffic pattern. Constants in this function were computed
2607 * based on theoretical maximum wire speed and thresholds were set based
2608 * on testing data as well as attempting to minimize response time
2609 * while increasing bulk throughput.
2610 * this functionality is controlled by the InterruptThrottleRate module
2611 * parameter (see e1000_param.c)
2612 * @adapter: pointer to adapter
2613 * @itr_setting: current adapter->itr
2614 * @packets: the number of packets during this measurement interval
2615 * @bytes: the number of bytes during this measurement interval
2616 **/
2617static unsigned int e1000_update_itr(struct e1000_adapter *adapter,
2618 uint16_t itr_setting,
2619 int packets,
2620 int bytes)
2621{
2622 unsigned int retval = itr_setting;
2623 struct e1000_hw *hw = &adapter->hw;
2624
2625 if (unlikely(hw->mac_type < e1000_82540))
2626 goto update_itr_done;
2627
2628 if (packets == 0)
2629 goto update_itr_done;
2630
2631
2632 switch (itr_setting) {
2633 case lowest_latency:
2634 if ((packets < 5) && (bytes > 512))
2635 retval = low_latency;
2636 break;
2637 case low_latency: /* 50 usec aka 20000 ints/s */
2638 if (bytes > 10000) {
2639 if ((packets < 10) ||
2640 ((bytes/packets) > 1200))
2641 retval = bulk_latency;
2642 else if ((packets > 35))
2643 retval = lowest_latency;
2644 } else if (packets <= 2 && bytes < 512)
2645 retval = lowest_latency;
2646 break;
2647 case bulk_latency: /* 250 usec aka 4000 ints/s */
2648 if (bytes > 25000) {
2649 if (packets > 35)
2650 retval = low_latency;
2651 } else {
2652 if (bytes < 6000)
2653 retval = low_latency;
2654 }
2655 break;
2656 }
2657
2658update_itr_done:
2659 return retval;
2660}
2661
2662static void e1000_set_itr(struct e1000_adapter *adapter)
2663{
2664 struct e1000_hw *hw = &adapter->hw;
2665 uint16_t current_itr;
2666 uint32_t new_itr = adapter->itr;
2667
2668 if (unlikely(hw->mac_type < e1000_82540))
2669 return;
2670
2671 /* for non-gigabit speeds, just fix the interrupt rate at 4000 */
2672 if (unlikely(adapter->link_speed != SPEED_1000)) {
2673 current_itr = 0;
2674 new_itr = 4000;
2675 goto set_itr_now;
2676 }
2677
2678 adapter->tx_itr = e1000_update_itr(adapter,
2679 adapter->tx_itr,
2680 adapter->total_tx_packets,
2681 adapter->total_tx_bytes);
2682 adapter->rx_itr = e1000_update_itr(adapter,
2683 adapter->rx_itr,
2684 adapter->total_rx_packets,
2685 adapter->total_rx_bytes);
2686
2687 current_itr = max(adapter->rx_itr, adapter->tx_itr);
2688
2689 /* conservative mode eliminates the lowest_latency setting */
2690 if (current_itr == lowest_latency && (adapter->itr_setting == 3))
2691 current_itr = low_latency;
2692
2693 switch (current_itr) {
2694 /* counts and packets in update_itr are dependent on these numbers */
2695 case lowest_latency:
2696 new_itr = 70000;
2697 break;
2698 case low_latency:
2699 new_itr = 20000; /* aka hwitr = ~200 */
2700 break;
2701 case bulk_latency:
2702 new_itr = 4000;
2703 break;
2704 default:
2705 break;
2706 }
2707
2708set_itr_now:
2709 if (new_itr != adapter->itr) {
2710 /* this attempts to bias the interrupt rate towards Bulk
2711 * by adding intermediate steps when interrupt rate is
2712 * increasing */
2713 new_itr = new_itr > adapter->itr ?
2714 min(adapter->itr + (new_itr >> 2), new_itr) :
2715 new_itr;
2716 adapter->itr = new_itr;
2717 E1000_WRITE_REG(hw, ITR, 1000000000 / (new_itr * 256));
2718 }
2719
2720 return;
2721}
2722
2580#define E1000_TX_FLAGS_CSUM 0x00000001 2723#define E1000_TX_FLAGS_CSUM 0x00000001
2581#define E1000_TX_FLAGS_VLAN 0x00000002 2724#define E1000_TX_FLAGS_VLAN 0x00000002
2582#define E1000_TX_FLAGS_TSO 0x00000004 2725#define E1000_TX_FLAGS_TSO 0x00000004
@@ -2617,7 +2760,7 @@ e1000_tso(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
2617 0); 2760 0);
2618 cmd_length = E1000_TXD_CMD_IP; 2761 cmd_length = E1000_TXD_CMD_IP;
2619 ipcse = skb->h.raw - skb->data - 1; 2762 ipcse = skb->h.raw - skb->data - 1;
2620#ifdef NETIF_F_TSO_IPV6 2763#ifdef NETIF_F_TSO6
2621 } else if (skb->protocol == htons(ETH_P_IPV6)) { 2764 } else if (skb->protocol == htons(ETH_P_IPV6)) {
2622 skb->nh.ipv6h->payload_len = 0; 2765 skb->nh.ipv6h->payload_len = 0;
2623 skb->h.th->check = 2766 skb->h.th->check =
@@ -2653,6 +2796,7 @@ e1000_tso(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
2653 context_desc->cmd_and_length = cpu_to_le32(cmd_length); 2796 context_desc->cmd_and_length = cpu_to_le32(cmd_length);
2654 2797
2655 buffer_info->time_stamp = jiffies; 2798 buffer_info->time_stamp = jiffies;
2799 buffer_info->next_to_watch = i;
2656 2800
2657 if (++i == tx_ring->count) i = 0; 2801 if (++i == tx_ring->count) i = 0;
2658 tx_ring->next_to_use = i; 2802 tx_ring->next_to_use = i;
@@ -2681,12 +2825,13 @@ e1000_tx_csum(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
2681 context_desc = E1000_CONTEXT_DESC(*tx_ring, i); 2825 context_desc = E1000_CONTEXT_DESC(*tx_ring, i);
2682 2826
2683 context_desc->upper_setup.tcp_fields.tucss = css; 2827 context_desc->upper_setup.tcp_fields.tucss = css;
2684 context_desc->upper_setup.tcp_fields.tucso = css + skb->csum; 2828 context_desc->upper_setup.tcp_fields.tucso = css + skb->csum_offset;
2685 context_desc->upper_setup.tcp_fields.tucse = 0; 2829 context_desc->upper_setup.tcp_fields.tucse = 0;
2686 context_desc->tcp_seg_setup.data = 0; 2830 context_desc->tcp_seg_setup.data = 0;
2687 context_desc->cmd_and_length = cpu_to_le32(E1000_TXD_CMD_DEXT); 2831 context_desc->cmd_and_length = cpu_to_le32(E1000_TXD_CMD_DEXT);
2688 2832
2689 buffer_info->time_stamp = jiffies; 2833 buffer_info->time_stamp = jiffies;
2834 buffer_info->next_to_watch = i;
2690 2835
2691 if (unlikely(++i == tx_ring->count)) i = 0; 2836 if (unlikely(++i == tx_ring->count)) i = 0;
2692 tx_ring->next_to_use = i; 2837 tx_ring->next_to_use = i;
@@ -2755,6 +2900,7 @@ e1000_tx_map(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
2755 size, 2900 size,
2756 PCI_DMA_TODEVICE); 2901 PCI_DMA_TODEVICE);
2757 buffer_info->time_stamp = jiffies; 2902 buffer_info->time_stamp = jiffies;
2903 buffer_info->next_to_watch = i;
2758 2904
2759 len -= size; 2905 len -= size;
2760 offset += size; 2906 offset += size;
@@ -2794,6 +2940,7 @@ e1000_tx_map(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
2794 size, 2940 size,
2795 PCI_DMA_TODEVICE); 2941 PCI_DMA_TODEVICE);
2796 buffer_info->time_stamp = jiffies; 2942 buffer_info->time_stamp = jiffies;
2943 buffer_info->next_to_watch = i;
2797 2944
2798 len -= size; 2945 len -= size;
2799 offset += size; 2946 offset += size;
@@ -2859,6 +3006,9 @@ e1000_tx_queue(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
2859 3006
2860 tx_ring->next_to_use = i; 3007 tx_ring->next_to_use = i;
2861 writel(i, adapter->hw.hw_addr + tx_ring->tdt); 3008 writel(i, adapter->hw.hw_addr + tx_ring->tdt);
3009 /* we need this if more than one processor can write to our tail
3010 * at a time, it syncronizes IO on IA64/Altix systems */
3011 mmiowb();
2862} 3012}
2863 3013
2864/** 3014/**
@@ -2952,6 +3102,7 @@ static int __e1000_maybe_stop_tx(struct net_device *netdev, int size)
2952 3102
2953 /* A reprieve! */ 3103 /* A reprieve! */
2954 netif_start_queue(netdev); 3104 netif_start_queue(netdev);
3105 ++adapter->restart_queue;
2955 return 0; 3106 return 0;
2956} 3107}
2957 3108
@@ -3010,9 +3161,9 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
3010 max_per_txd = min(mss << 2, max_per_txd); 3161 max_per_txd = min(mss << 2, max_per_txd);
3011 max_txd_pwr = fls(max_per_txd) - 1; 3162 max_txd_pwr = fls(max_per_txd) - 1;
3012 3163
3013 /* TSO Workaround for 82571/2/3 Controllers -- if skb->data 3164 /* TSO Workaround for 82571/2/3 Controllers -- if skb->data
3014 * points to just header, pull a few bytes of payload from 3165 * points to just header, pull a few bytes of payload from
3015 * frags into skb->data */ 3166 * frags into skb->data */
3016 hdr_len = ((skb->h.raw - skb->data) + (skb->h.th->doff << 2)); 3167 hdr_len = ((skb->h.raw - skb->data) + (skb->h.th->doff << 2));
3017 if (skb->data_len && (hdr_len == (skb->len - skb->data_len))) { 3168 if (skb->data_len && (hdr_len == (skb->len - skb->data_len))) {
3018 switch (adapter->hw.mac_type) { 3169 switch (adapter->hw.mac_type) {
@@ -3154,9 +3305,10 @@ e1000_tx_timeout(struct net_device *netdev)
3154} 3305}
3155 3306
3156static void 3307static void
3157e1000_reset_task(struct net_device *netdev) 3308e1000_reset_task(struct work_struct *work)
3158{ 3309{
3159 struct e1000_adapter *adapter = netdev_priv(netdev); 3310 struct e1000_adapter *adapter =
3311 container_of(work, struct e1000_adapter, reset_task);
3160 3312
3161 e1000_reinit_locked(adapter); 3313 e1000_reinit_locked(adapter);
3162} 3314}
@@ -3316,12 +3468,12 @@ e1000_update_stats(struct e1000_adapter *adapter)
3316 adapter->stats.roc += E1000_READ_REG(hw, ROC); 3468 adapter->stats.roc += E1000_READ_REG(hw, ROC);
3317 3469
3318 if (adapter->hw.mac_type != e1000_ich8lan) { 3470 if (adapter->hw.mac_type != e1000_ich8lan) {
3319 adapter->stats.prc64 += E1000_READ_REG(hw, PRC64); 3471 adapter->stats.prc64 += E1000_READ_REG(hw, PRC64);
3320 adapter->stats.prc127 += E1000_READ_REG(hw, PRC127); 3472 adapter->stats.prc127 += E1000_READ_REG(hw, PRC127);
3321 adapter->stats.prc255 += E1000_READ_REG(hw, PRC255); 3473 adapter->stats.prc255 += E1000_READ_REG(hw, PRC255);
3322 adapter->stats.prc511 += E1000_READ_REG(hw, PRC511); 3474 adapter->stats.prc511 += E1000_READ_REG(hw, PRC511);
3323 adapter->stats.prc1023 += E1000_READ_REG(hw, PRC1023); 3475 adapter->stats.prc1023 += E1000_READ_REG(hw, PRC1023);
3324 adapter->stats.prc1522 += E1000_READ_REG(hw, PRC1522); 3476 adapter->stats.prc1522 += E1000_READ_REG(hw, PRC1522);
3325 } 3477 }
3326 3478
3327 adapter->stats.symerrs += E1000_READ_REG(hw, SYMERRS); 3479 adapter->stats.symerrs += E1000_READ_REG(hw, SYMERRS);
@@ -3352,12 +3504,12 @@ e1000_update_stats(struct e1000_adapter *adapter)
3352 adapter->stats.tpr += E1000_READ_REG(hw, TPR); 3504 adapter->stats.tpr += E1000_READ_REG(hw, TPR);
3353 3505
3354 if (adapter->hw.mac_type != e1000_ich8lan) { 3506 if (adapter->hw.mac_type != e1000_ich8lan) {
3355 adapter->stats.ptc64 += E1000_READ_REG(hw, PTC64); 3507 adapter->stats.ptc64 += E1000_READ_REG(hw, PTC64);
3356 adapter->stats.ptc127 += E1000_READ_REG(hw, PTC127); 3508 adapter->stats.ptc127 += E1000_READ_REG(hw, PTC127);
3357 adapter->stats.ptc255 += E1000_READ_REG(hw, PTC255); 3509 adapter->stats.ptc255 += E1000_READ_REG(hw, PTC255);
3358 adapter->stats.ptc511 += E1000_READ_REG(hw, PTC511); 3510 adapter->stats.ptc511 += E1000_READ_REG(hw, PTC511);
3359 adapter->stats.ptc1023 += E1000_READ_REG(hw, PTC1023); 3511 adapter->stats.ptc1023 += E1000_READ_REG(hw, PTC1023);
3360 adapter->stats.ptc1522 += E1000_READ_REG(hw, PTC1522); 3512 adapter->stats.ptc1522 += E1000_READ_REG(hw, PTC1522);
3361 } 3513 }
3362 3514
3363 adapter->stats.mptc += E1000_READ_REG(hw, MPTC); 3515 adapter->stats.mptc += E1000_READ_REG(hw, MPTC);
@@ -3383,18 +3535,17 @@ e1000_update_stats(struct e1000_adapter *adapter)
3383 adapter->stats.icrxoc += E1000_READ_REG(hw, ICRXOC); 3535 adapter->stats.icrxoc += E1000_READ_REG(hw, ICRXOC);
3384 3536
3385 if (adapter->hw.mac_type != e1000_ich8lan) { 3537 if (adapter->hw.mac_type != e1000_ich8lan) {
3386 adapter->stats.icrxptc += E1000_READ_REG(hw, ICRXPTC); 3538 adapter->stats.icrxptc += E1000_READ_REG(hw, ICRXPTC);
3387 adapter->stats.icrxatc += E1000_READ_REG(hw, ICRXATC); 3539 adapter->stats.icrxatc += E1000_READ_REG(hw, ICRXATC);
3388 adapter->stats.ictxptc += E1000_READ_REG(hw, ICTXPTC); 3540 adapter->stats.ictxptc += E1000_READ_REG(hw, ICTXPTC);
3389 adapter->stats.ictxatc += E1000_READ_REG(hw, ICTXATC); 3541 adapter->stats.ictxatc += E1000_READ_REG(hw, ICTXATC);
3390 adapter->stats.ictxqec += E1000_READ_REG(hw, ICTXQEC); 3542 adapter->stats.ictxqec += E1000_READ_REG(hw, ICTXQEC);
3391 adapter->stats.ictxqmtc += E1000_READ_REG(hw, ICTXQMTC); 3543 adapter->stats.ictxqmtc += E1000_READ_REG(hw, ICTXQMTC);
3392 adapter->stats.icrxdmtc += E1000_READ_REG(hw, ICRXDMTC); 3544 adapter->stats.icrxdmtc += E1000_READ_REG(hw, ICRXDMTC);
3393 } 3545 }
3394 } 3546 }
3395 3547
3396 /* Fill out the OS statistics structure */ 3548 /* Fill out the OS statistics structure */
3397
3398 adapter->net_stats.rx_packets = adapter->stats.gprc; 3549 adapter->net_stats.rx_packets = adapter->stats.gprc;
3399 adapter->net_stats.tx_packets = adapter->stats.gptc; 3550 adapter->net_stats.tx_packets = adapter->stats.gptc;
3400 adapter->net_stats.rx_bytes = adapter->stats.gorcl; 3551 adapter->net_stats.rx_bytes = adapter->stats.gorcl;
@@ -3426,7 +3577,6 @@ e1000_update_stats(struct e1000_adapter *adapter)
3426 /* Tx Dropped needs to be maintained elsewhere */ 3577 /* Tx Dropped needs to be maintained elsewhere */
3427 3578
3428 /* Phy Stats */ 3579 /* Phy Stats */
3429
3430 if (hw->media_type == e1000_media_type_copper) { 3580 if (hw->media_type == e1000_media_type_copper) {
3431 if ((adapter->link_speed == SPEED_1000) && 3581 if ((adapter->link_speed == SPEED_1000) &&
3432 (!e1000_read_phy_reg(hw, PHY_1000T_STATUS, &phy_tmp))) { 3582 (!e1000_read_phy_reg(hw, PHY_1000T_STATUS, &phy_tmp))) {
@@ -3442,6 +3592,95 @@ e1000_update_stats(struct e1000_adapter *adapter)
3442 3592
3443 spin_unlock_irqrestore(&adapter->stats_lock, flags); 3593 spin_unlock_irqrestore(&adapter->stats_lock, flags);
3444} 3594}
3595#ifdef CONFIG_PCI_MSI
3596
3597/**
3598 * e1000_intr_msi - Interrupt Handler
3599 * @irq: interrupt number
3600 * @data: pointer to a network interface device structure
3601 **/
3602
3603static
3604irqreturn_t e1000_intr_msi(int irq, void *data)
3605{
3606 struct net_device *netdev = data;
3607 struct e1000_adapter *adapter = netdev_priv(netdev);
3608 struct e1000_hw *hw = &adapter->hw;
3609#ifndef CONFIG_E1000_NAPI
3610 int i;
3611#endif
3612
3613 /* this code avoids the read of ICR but has to get 1000 interrupts
3614 * at every link change event before it will notice the change */
3615 if (++adapter->detect_link >= 1000) {
3616 uint32_t icr = E1000_READ_REG(hw, ICR);
3617#ifdef CONFIG_E1000_NAPI
3618 /* read ICR disables interrupts using IAM, so keep up with our
3619 * enable/disable accounting */
3620 atomic_inc(&adapter->irq_sem);
3621#endif
3622 adapter->detect_link = 0;
3623 if ((icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC)) &&
3624 (icr & E1000_ICR_INT_ASSERTED)) {
3625 hw->get_link_status = 1;
3626 /* 80003ES2LAN workaround--
3627 * For packet buffer work-around on link down event;
3628 * disable receives here in the ISR and
3629 * reset adapter in watchdog
3630 */
3631 if (netif_carrier_ok(netdev) &&
3632 (adapter->hw.mac_type == e1000_80003es2lan)) {
3633 /* disable receives */
3634 uint32_t rctl = E1000_READ_REG(hw, RCTL);
3635 E1000_WRITE_REG(hw, RCTL, rctl & ~E1000_RCTL_EN);
3636 }
3637 /* guard against interrupt when we're going down */
3638 if (!test_bit(__E1000_DOWN, &adapter->flags))
3639 mod_timer(&adapter->watchdog_timer,
3640 jiffies + 1);
3641 }
3642 } else {
3643 E1000_WRITE_REG(hw, ICR, (0xffffffff & ~(E1000_ICR_RXSEQ |
3644 E1000_ICR_LSC)));
3645 /* bummer we have to flush here, but things break otherwise as
3646 * some event appears to be lost or delayed and throughput
3647 * drops. In almost all tests this flush is un-necessary */
3648 E1000_WRITE_FLUSH(hw);
3649#ifdef CONFIG_E1000_NAPI
3650 /* Interrupt Auto-Mask (IAM)...upon writing ICR, interrupts are
3651 * masked. No need for the IMC write, but it does mean we
3652 * should account for it ASAP. */
3653 atomic_inc(&adapter->irq_sem);
3654#endif
3655 }
3656
3657#ifdef CONFIG_E1000_NAPI
3658 if (likely(netif_rx_schedule_prep(netdev))) {
3659 adapter->total_tx_bytes = 0;
3660 adapter->total_tx_packets = 0;
3661 adapter->total_rx_bytes = 0;
3662 adapter->total_rx_packets = 0;
3663 __netif_rx_schedule(netdev);
3664 } else
3665 e1000_irq_enable(adapter);
3666#else
3667 adapter->total_tx_bytes = 0;
3668 adapter->total_rx_bytes = 0;
3669 adapter->total_tx_packets = 0;
3670 adapter->total_rx_packets = 0;
3671
3672 for (i = 0; i < E1000_MAX_INTR; i++)
3673 if (unlikely(!adapter->clean_rx(adapter, adapter->rx_ring) &
3674 !e1000_clean_tx_irq(adapter, adapter->tx_ring)))
3675 break;
3676
3677 if (likely(adapter->itr_setting & 3))
3678 e1000_set_itr(adapter);
3679#endif
3680
3681 return IRQ_HANDLED;
3682}
3683#endif
3445 3684
3446/** 3685/**
3447 * e1000_intr - Interrupt Handler 3686 * e1000_intr - Interrupt Handler
@@ -3458,7 +3697,17 @@ e1000_intr(int irq, void *data)
3458 uint32_t rctl, icr = E1000_READ_REG(hw, ICR); 3697 uint32_t rctl, icr = E1000_READ_REG(hw, ICR);
3459#ifndef CONFIG_E1000_NAPI 3698#ifndef CONFIG_E1000_NAPI
3460 int i; 3699 int i;
3461#else 3700#endif
3701 if (unlikely(!icr))
3702 return IRQ_NONE; /* Not our interrupt */
3703
3704#ifdef CONFIG_E1000_NAPI
3705 /* IMS will not auto-mask if INT_ASSERTED is not set, and if it is
3706 * not set, then the adapter didn't send an interrupt */
3707 if (unlikely(hw->mac_type >= e1000_82571 &&
3708 !(icr & E1000_ICR_INT_ASSERTED)))
3709 return IRQ_NONE;
3710
3462 /* Interrupt Auto-Mask...upon reading ICR, 3711 /* Interrupt Auto-Mask...upon reading ICR,
3463 * interrupts are masked. No need for the 3712 * interrupts are masked. No need for the
3464 * IMC write, but it does mean we should 3713 * IMC write, but it does mean we should
@@ -3467,14 +3716,6 @@ e1000_intr(int irq, void *data)
3467 atomic_inc(&adapter->irq_sem); 3716 atomic_inc(&adapter->irq_sem);
3468#endif 3717#endif
3469 3718
3470 if (unlikely(!icr)) {
3471#ifdef CONFIG_E1000_NAPI
3472 if (hw->mac_type >= e1000_82571)
3473 e1000_irq_enable(adapter);
3474#endif
3475 return IRQ_NONE; /* Not our interrupt */
3476 }
3477
3478 if (unlikely(icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC))) { 3719 if (unlikely(icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC))) {
3479 hw->get_link_status = 1; 3720 hw->get_link_status = 1;
3480 /* 80003ES2LAN workaround-- 3721 /* 80003ES2LAN workaround--
@@ -3495,13 +3736,20 @@ e1000_intr(int irq, void *data)
3495 3736
3496#ifdef CONFIG_E1000_NAPI 3737#ifdef CONFIG_E1000_NAPI
3497 if (unlikely(hw->mac_type < e1000_82571)) { 3738 if (unlikely(hw->mac_type < e1000_82571)) {
3739 /* disable interrupts, without the synchronize_irq bit */
3498 atomic_inc(&adapter->irq_sem); 3740 atomic_inc(&adapter->irq_sem);
3499 E1000_WRITE_REG(hw, IMC, ~0); 3741 E1000_WRITE_REG(hw, IMC, ~0);
3500 E1000_WRITE_FLUSH(hw); 3742 E1000_WRITE_FLUSH(hw);
3501 } 3743 }
3502 if (likely(netif_rx_schedule_prep(netdev))) 3744 if (likely(netif_rx_schedule_prep(netdev))) {
3745 adapter->total_tx_bytes = 0;
3746 adapter->total_tx_packets = 0;
3747 adapter->total_rx_bytes = 0;
3748 adapter->total_rx_packets = 0;
3503 __netif_rx_schedule(netdev); 3749 __netif_rx_schedule(netdev);
3504 else 3750 } else
3751 /* this really should not happen! if it does it is basically a
3752 * bug, but not a hard error, so enable ints and continue */
3505 e1000_irq_enable(adapter); 3753 e1000_irq_enable(adapter);
3506#else 3754#else
3507 /* Writing IMC and IMS is needed for 82547. 3755 /* Writing IMC and IMS is needed for 82547.
@@ -3519,16 +3767,23 @@ e1000_intr(int irq, void *data)
3519 E1000_WRITE_REG(hw, IMC, ~0); 3767 E1000_WRITE_REG(hw, IMC, ~0);
3520 } 3768 }
3521 3769
3770 adapter->total_tx_bytes = 0;
3771 adapter->total_rx_bytes = 0;
3772 adapter->total_tx_packets = 0;
3773 adapter->total_rx_packets = 0;
3774
3522 for (i = 0; i < E1000_MAX_INTR; i++) 3775 for (i = 0; i < E1000_MAX_INTR; i++)
3523 if (unlikely(!adapter->clean_rx(adapter, adapter->rx_ring) & 3776 if (unlikely(!adapter->clean_rx(adapter, adapter->rx_ring) &
3524 !e1000_clean_tx_irq(adapter, adapter->tx_ring))) 3777 !e1000_clean_tx_irq(adapter, adapter->tx_ring)))
3525 break; 3778 break;
3526 3779
3780 if (likely(adapter->itr_setting & 3))
3781 e1000_set_itr(adapter);
3782
3527 if (hw->mac_type == e1000_82547 || hw->mac_type == e1000_82547_rev_2) 3783 if (hw->mac_type == e1000_82547 || hw->mac_type == e1000_82547_rev_2)
3528 e1000_irq_enable(adapter); 3784 e1000_irq_enable(adapter);
3529 3785
3530#endif 3786#endif
3531
3532 return IRQ_HANDLED; 3787 return IRQ_HANDLED;
3533} 3788}
3534 3789
@@ -3572,6 +3827,8 @@ e1000_clean(struct net_device *poll_dev, int *budget)
3572 if ((!tx_cleaned && (work_done == 0)) || 3827 if ((!tx_cleaned && (work_done == 0)) ||
3573 !netif_running(poll_dev)) { 3828 !netif_running(poll_dev)) {
3574quit_polling: 3829quit_polling:
3830 if (likely(adapter->itr_setting & 3))
3831 e1000_set_itr(adapter);
3575 netif_rx_complete(poll_dev); 3832 netif_rx_complete(poll_dev);
3576 e1000_irq_enable(adapter); 3833 e1000_irq_enable(adapter);
3577 return 0; 3834 return 0;
@@ -3598,6 +3855,7 @@ e1000_clean_tx_irq(struct e1000_adapter *adapter,
3598 unsigned int count = 0; 3855 unsigned int count = 0;
3599#endif 3856#endif
3600 boolean_t cleaned = FALSE; 3857 boolean_t cleaned = FALSE;
3858 unsigned int total_tx_bytes=0, total_tx_packets=0;
3601 3859
3602 i = tx_ring->next_to_clean; 3860 i = tx_ring->next_to_clean;
3603 eop = tx_ring->buffer_info[i].next_to_watch; 3861 eop = tx_ring->buffer_info[i].next_to_watch;
@@ -3609,13 +3867,19 @@ e1000_clean_tx_irq(struct e1000_adapter *adapter,
3609 buffer_info = &tx_ring->buffer_info[i]; 3867 buffer_info = &tx_ring->buffer_info[i];
3610 cleaned = (i == eop); 3868 cleaned = (i == eop);
3611 3869
3870 if (cleaned) {
3871 /* this packet count is wrong for TSO but has a
3872 * tendency to make dynamic ITR change more
3873 * towards bulk */
3874 total_tx_packets++;
3875 total_tx_bytes += buffer_info->skb->len;
3876 }
3612 e1000_unmap_and_free_tx_resource(adapter, buffer_info); 3877 e1000_unmap_and_free_tx_resource(adapter, buffer_info);
3613 memset(tx_desc, 0, sizeof(struct e1000_tx_desc)); 3878 tx_desc->upper.data = 0;
3614 3879
3615 if (unlikely(++i == tx_ring->count)) i = 0; 3880 if (unlikely(++i == tx_ring->count)) i = 0;
3616 } 3881 }
3617 3882
3618
3619 eop = tx_ring->buffer_info[i].next_to_watch; 3883 eop = tx_ring->buffer_info[i].next_to_watch;
3620 eop_desc = E1000_TX_DESC(*tx_ring, eop); 3884 eop_desc = E1000_TX_DESC(*tx_ring, eop);
3621#ifdef CONFIG_E1000_NAPI 3885#ifdef CONFIG_E1000_NAPI
@@ -3634,8 +3898,10 @@ e1000_clean_tx_irq(struct e1000_adapter *adapter,
3634 * sees the new next_to_clean. 3898 * sees the new next_to_clean.
3635 */ 3899 */
3636 smp_mb(); 3900 smp_mb();
3637 if (netif_queue_stopped(netdev)) 3901 if (netif_queue_stopped(netdev)) {
3638 netif_wake_queue(netdev); 3902 netif_wake_queue(netdev);
3903 ++adapter->restart_queue;
3904 }
3639 } 3905 }
3640 3906
3641 if (adapter->detect_tx_hung) { 3907 if (adapter->detect_tx_hung) {
@@ -3673,6 +3939,8 @@ e1000_clean_tx_irq(struct e1000_adapter *adapter,
3673 netif_stop_queue(netdev); 3939 netif_stop_queue(netdev);
3674 } 3940 }
3675 } 3941 }
3942 adapter->total_tx_bytes += total_tx_bytes;
3943 adapter->total_tx_packets += total_tx_packets;
3676 return cleaned; 3944 return cleaned;
3677} 3945}
3678 3946
@@ -3752,6 +4020,7 @@ e1000_clean_rx_irq(struct e1000_adapter *adapter,
3752 unsigned int i; 4020 unsigned int i;
3753 int cleaned_count = 0; 4021 int cleaned_count = 0;
3754 boolean_t cleaned = FALSE; 4022 boolean_t cleaned = FALSE;
4023 unsigned int total_rx_bytes=0, total_rx_packets=0;
3755 4024
3756 i = rx_ring->next_to_clean; 4025 i = rx_ring->next_to_clean;
3757 rx_desc = E1000_RX_DESC(*rx_ring, i); 4026 rx_desc = E1000_RX_DESC(*rx_ring, i);
@@ -3760,6 +4029,7 @@ e1000_clean_rx_irq(struct e1000_adapter *adapter,
3760 while (rx_desc->status & E1000_RXD_STAT_DD) { 4029 while (rx_desc->status & E1000_RXD_STAT_DD) {
3761 struct sk_buff *skb; 4030 struct sk_buff *skb;
3762 u8 status; 4031 u8 status;
4032
3763#ifdef CONFIG_E1000_NAPI 4033#ifdef CONFIG_E1000_NAPI
3764 if (*work_done >= work_to_do) 4034 if (*work_done >= work_to_do)
3765 break; 4035 break;
@@ -3817,6 +4087,10 @@ e1000_clean_rx_irq(struct e1000_adapter *adapter,
3817 * done after the TBI_ACCEPT workaround above */ 4087 * done after the TBI_ACCEPT workaround above */
3818 length -= 4; 4088 length -= 4;
3819 4089
4090 /* probably a little skewed due to removing CRC */
4091 total_rx_bytes += length;
4092 total_rx_packets++;
4093
3820 /* code added for copybreak, this should improve 4094 /* code added for copybreak, this should improve
3821 * performance for small packets with large amounts 4095 * performance for small packets with large amounts
3822 * of reassembly being done in the stack */ 4096 * of reassembly being done in the stack */
@@ -3832,12 +4106,11 @@ e1000_clean_rx_irq(struct e1000_adapter *adapter,
3832 /* save the skb in buffer_info as good */ 4106 /* save the skb in buffer_info as good */
3833 buffer_info->skb = skb; 4107 buffer_info->skb = skb;
3834 skb = new_skb; 4108 skb = new_skb;
3835 skb_put(skb, length);
3836 } 4109 }
3837 } else 4110 /* else just continue with the old one */
3838 skb_put(skb, length); 4111 }
3839
3840 /* end copybreak code */ 4112 /* end copybreak code */
4113 skb_put(skb, length);
3841 4114
3842 /* Receive Checksum Offload */ 4115 /* Receive Checksum Offload */
3843 e1000_rx_checksum(adapter, 4116 e1000_rx_checksum(adapter,
@@ -3886,6 +4159,8 @@ next_desc:
3886 if (cleaned_count) 4159 if (cleaned_count)
3887 adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count); 4160 adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count);
3888 4161
4162 adapter->total_rx_packets += total_rx_packets;
4163 adapter->total_rx_bytes += total_rx_bytes;
3889 return cleaned; 4164 return cleaned;
3890} 4165}
3891 4166
@@ -3915,6 +4190,7 @@ e1000_clean_rx_irq_ps(struct e1000_adapter *adapter,
3915 uint32_t length, staterr; 4190 uint32_t length, staterr;
3916 int cleaned_count = 0; 4191 int cleaned_count = 0;
3917 boolean_t cleaned = FALSE; 4192 boolean_t cleaned = FALSE;
4193 unsigned int total_rx_bytes=0, total_rx_packets=0;
3918 4194
3919 i = rx_ring->next_to_clean; 4195 i = rx_ring->next_to_clean;
3920 rx_desc = E1000_RX_DESC_PS(*rx_ring, i); 4196 rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
@@ -3999,7 +4275,7 @@ e1000_clean_rx_irq_ps(struct e1000_adapter *adapter,
3999 goto copydone; 4275 goto copydone;
4000 } /* if */ 4276 } /* if */
4001 } 4277 }
4002 4278
4003 for (j = 0; j < adapter->rx_ps_pages; j++) { 4279 for (j = 0; j < adapter->rx_ps_pages; j++) {
4004 if (!(length= le16_to_cpu(rx_desc->wb.upper.length[j]))) 4280 if (!(length= le16_to_cpu(rx_desc->wb.upper.length[j])))
4005 break; 4281 break;
@@ -4019,6 +4295,9 @@ e1000_clean_rx_irq_ps(struct e1000_adapter *adapter,
4019 pskb_trim(skb, skb->len - 4); 4295 pskb_trim(skb, skb->len - 4);
4020 4296
4021copydone: 4297copydone:
4298 total_rx_bytes += skb->len;
4299 total_rx_packets++;
4300
4022 e1000_rx_checksum(adapter, staterr, 4301 e1000_rx_checksum(adapter, staterr,
4023 le16_to_cpu(rx_desc->wb.lower.hi_dword.csum_ip.csum), skb); 4302 le16_to_cpu(rx_desc->wb.lower.hi_dword.csum_ip.csum), skb);
4024 skb->protocol = eth_type_trans(skb, netdev); 4303 skb->protocol = eth_type_trans(skb, netdev);
@@ -4067,6 +4346,8 @@ next_desc:
4067 if (cleaned_count) 4346 if (cleaned_count)
4068 adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count); 4347 adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count);
4069 4348
4349 adapter->total_rx_packets += total_rx_packets;
4350 adapter->total_rx_bytes += total_rx_bytes;
4070 return cleaned; 4351 return cleaned;
4071} 4352}
4072 4353
@@ -4234,7 +4515,7 @@ e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter,
4234 } 4515 }
4235 4516
4236 skb = netdev_alloc_skb(netdev, 4517 skb = netdev_alloc_skb(netdev,
4237 adapter->rx_ps_bsize0 + NET_IP_ALIGN); 4518 adapter->rx_ps_bsize0 + NET_IP_ALIGN);
4238 4519
4239 if (unlikely(!skb)) { 4520 if (unlikely(!skb)) {
4240 adapter->alloc_rx_buff_failed++; 4521 adapter->alloc_rx_buff_failed++;
@@ -4511,7 +4792,6 @@ e1000_read_pcie_cap_reg(struct e1000_hw *hw, uint32_t reg, uint16_t *value)
4511 return E1000_SUCCESS; 4792 return E1000_SUCCESS;
4512} 4793}
4513 4794
4514
4515void 4795void
4516e1000_io_write(struct e1000_hw *hw, unsigned long port, uint32_t value) 4796e1000_io_write(struct e1000_hw *hw, unsigned long port, uint32_t value)
4517{ 4797{
@@ -4534,12 +4814,12 @@ e1000_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)
4534 E1000_WRITE_REG(&adapter->hw, CTRL, ctrl); 4814 E1000_WRITE_REG(&adapter->hw, CTRL, ctrl);
4535 4815
4536 if (adapter->hw.mac_type != e1000_ich8lan) { 4816 if (adapter->hw.mac_type != e1000_ich8lan) {
4537 /* enable VLAN receive filtering */ 4817 /* enable VLAN receive filtering */
4538 rctl = E1000_READ_REG(&adapter->hw, RCTL); 4818 rctl = E1000_READ_REG(&adapter->hw, RCTL);
4539 rctl |= E1000_RCTL_VFE; 4819 rctl |= E1000_RCTL_VFE;
4540 rctl &= ~E1000_RCTL_CFIEN; 4820 rctl &= ~E1000_RCTL_CFIEN;
4541 E1000_WRITE_REG(&adapter->hw, RCTL, rctl); 4821 E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
4542 e1000_update_mng_vlan(adapter); 4822 e1000_update_mng_vlan(adapter);
4543 } 4823 }
4544 } else { 4824 } else {
4545 /* disable VLAN tag insert/strip */ 4825 /* disable VLAN tag insert/strip */
@@ -4548,14 +4828,16 @@ e1000_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)
4548 E1000_WRITE_REG(&adapter->hw, CTRL, ctrl); 4828 E1000_WRITE_REG(&adapter->hw, CTRL, ctrl);
4549 4829
4550 if (adapter->hw.mac_type != e1000_ich8lan) { 4830 if (adapter->hw.mac_type != e1000_ich8lan) {
4551 /* disable VLAN filtering */ 4831 /* disable VLAN filtering */
4552 rctl = E1000_READ_REG(&adapter->hw, RCTL); 4832 rctl = E1000_READ_REG(&adapter->hw, RCTL);
4553 rctl &= ~E1000_RCTL_VFE; 4833 rctl &= ~E1000_RCTL_VFE;
4554 E1000_WRITE_REG(&adapter->hw, RCTL, rctl); 4834 E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
4555 if (adapter->mng_vlan_id != (uint16_t)E1000_MNG_VLAN_NONE) { 4835 if (adapter->mng_vlan_id !=
4556 e1000_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id); 4836 (uint16_t)E1000_MNG_VLAN_NONE) {
4557 adapter->mng_vlan_id = E1000_MNG_VLAN_NONE; 4837 e1000_vlan_rx_kill_vid(netdev,
4558 } 4838 adapter->mng_vlan_id);
4839 adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
4840 }
4559 } 4841 }
4560 } 4842 }
4561 4843
@@ -4800,6 +5082,9 @@ e1000_suspend(struct pci_dev *pdev, pm_message_t state)
4800 if (adapter->hw.phy_type == e1000_phy_igp_3) 5082 if (adapter->hw.phy_type == e1000_phy_igp_3)
4801 e1000_phy_powerdown_workaround(&adapter->hw); 5083 e1000_phy_powerdown_workaround(&adapter->hw);
4802 5084
5085 if (netif_running(netdev))
5086 e1000_free_irq(adapter);
5087
4803 /* Release control of h/w to f/w. If f/w is AMT enabled, this 5088 /* Release control of h/w to f/w. If f/w is AMT enabled, this
4804 * would have already happened in close and is redundant. */ 5089 * would have already happened in close and is redundant. */
4805 e1000_release_hw_control(adapter); 5090 e1000_release_hw_control(adapter);
@@ -4830,6 +5115,10 @@ e1000_resume(struct pci_dev *pdev)
4830 pci_enable_wake(pdev, PCI_D3hot, 0); 5115 pci_enable_wake(pdev, PCI_D3hot, 0);
4831 pci_enable_wake(pdev, PCI_D3cold, 0); 5116 pci_enable_wake(pdev, PCI_D3cold, 0);
4832 5117
5118 if (netif_running(netdev) && (err = e1000_request_irq(adapter)))
5119 return err;
5120
5121 e1000_power_up_phy(adapter);
4833 e1000_reset(adapter); 5122 e1000_reset(adapter);
4834 E1000_WRITE_REG(&adapter->hw, WUS, ~0); 5123 E1000_WRITE_REG(&adapter->hw, WUS, ~0);
4835 5124
diff --git a/drivers/net/e1000/e1000_osdep.h b/drivers/net/e1000/e1000_osdep.h
index a464cb290621..18afc0c25dac 100644
--- a/drivers/net/e1000/e1000_osdep.h
+++ b/drivers/net/e1000/e1000_osdep.h
@@ -107,17 +107,16 @@ typedef enum {
107 107
108#define E1000_WRITE_FLUSH(a) E1000_READ_REG(a, STATUS) 108#define E1000_WRITE_FLUSH(a) E1000_READ_REG(a, STATUS)
109 109
110#define E1000_WRITE_ICH8_REG(a, reg, value) ( \ 110#define E1000_WRITE_ICH_FLASH_REG(a, reg, value) ( \
111 writel((value), ((a)->flash_address + reg))) 111 writel((value), ((a)->flash_address + reg)))
112 112
113#define E1000_READ_ICH8_REG(a, reg) ( \ 113#define E1000_READ_ICH_FLASH_REG(a, reg) ( \
114 readl((a)->flash_address + reg)) 114 readl((a)->flash_address + reg))
115 115
116#define E1000_WRITE_ICH8_REG16(a, reg, value) ( \ 116#define E1000_WRITE_ICH_FLASH_REG16(a, reg, value) ( \
117 writew((value), ((a)->flash_address + reg))) 117 writew((value), ((a)->flash_address + reg)))
118 118
119#define E1000_READ_ICH8_REG16(a, reg) ( \ 119#define E1000_READ_ICH_FLASH_REG16(a, reg) ( \
120 readw((a)->flash_address + reg)) 120 readw((a)->flash_address + reg))
121 121
122
123#endif /* _E1000_OSDEP_H_ */ 122#endif /* _E1000_OSDEP_H_ */
diff --git a/drivers/net/e1000/e1000_param.c b/drivers/net/e1000/e1000_param.c
index 9c3c1acefccc..cbfcd7f2889f 100644
--- a/drivers/net/e1000/e1000_param.c
+++ b/drivers/net/e1000/e1000_param.c
@@ -44,16 +44,6 @@
44 */ 44 */
45 45
46#define E1000_PARAM_INIT { [0 ... E1000_MAX_NIC] = OPTION_UNSET } 46#define E1000_PARAM_INIT { [0 ... E1000_MAX_NIC] = OPTION_UNSET }
47/* Module Parameters are always initialized to -1, so that the driver
48 * can tell the difference between no user specified value or the
49 * user asking for the default value.
50 * The true default values are loaded in when e1000_check_options is called.
51 *
52 * This is a GCC extension to ANSI C.
53 * See the item "Labeled Elements in Initializers" in the section
54 * "Extensions to the C Language Family" of the GCC documentation.
55 */
56
57#define E1000_PARAM(X, desc) \ 47#define E1000_PARAM(X, desc) \
58 static int __devinitdata X[E1000_MAX_NIC+1] = E1000_PARAM_INIT; \ 48 static int __devinitdata X[E1000_MAX_NIC+1] = E1000_PARAM_INIT; \
59 static int num_##X = 0; \ 49 static int num_##X = 0; \
@@ -67,7 +57,6 @@
67 * 57 *
68 * Default Value: 256 58 * Default Value: 256
69 */ 59 */
70
71E1000_PARAM(TxDescriptors, "Number of transmit descriptors"); 60E1000_PARAM(TxDescriptors, "Number of transmit descriptors");
72 61
73/* Receive Descriptor Count 62/* Receive Descriptor Count
@@ -77,7 +66,6 @@ E1000_PARAM(TxDescriptors, "Number of transmit descriptors");
77 * 66 *
78 * Default Value: 256 67 * Default Value: 256
79 */ 68 */
80
81E1000_PARAM(RxDescriptors, "Number of receive descriptors"); 69E1000_PARAM(RxDescriptors, "Number of receive descriptors");
82 70
83/* User Specified Speed Override 71/* User Specified Speed Override
@@ -90,7 +78,6 @@ E1000_PARAM(RxDescriptors, "Number of receive descriptors");
90 * 78 *
91 * Default Value: 0 79 * Default Value: 0
92 */ 80 */
93
94E1000_PARAM(Speed, "Speed setting"); 81E1000_PARAM(Speed, "Speed setting");
95 82
96/* User Specified Duplex Override 83/* User Specified Duplex Override
@@ -102,7 +89,6 @@ E1000_PARAM(Speed, "Speed setting");
102 * 89 *
103 * Default Value: 0 90 * Default Value: 0
104 */ 91 */
105
106E1000_PARAM(Duplex, "Duplex setting"); 92E1000_PARAM(Duplex, "Duplex setting");
107 93
108/* Auto-negotiation Advertisement Override 94/* Auto-negotiation Advertisement Override
@@ -119,8 +105,9 @@ E1000_PARAM(Duplex, "Duplex setting");
119 * 105 *
120 * Default Value: 0x2F (copper); 0x20 (fiber) 106 * Default Value: 0x2F (copper); 0x20 (fiber)
121 */ 107 */
122
123E1000_PARAM(AutoNeg, "Advertised auto-negotiation setting"); 108E1000_PARAM(AutoNeg, "Advertised auto-negotiation setting");
109#define AUTONEG_ADV_DEFAULT 0x2F
110#define AUTONEG_ADV_MASK 0x2F
124 111
125/* User Specified Flow Control Override 112/* User Specified Flow Control Override
126 * 113 *
@@ -132,8 +119,8 @@ E1000_PARAM(AutoNeg, "Advertised auto-negotiation setting");
132 * 119 *
133 * Default Value: Read flow control settings from the EEPROM 120 * Default Value: Read flow control settings from the EEPROM
134 */ 121 */
135
136E1000_PARAM(FlowControl, "Flow Control setting"); 122E1000_PARAM(FlowControl, "Flow Control setting");
123#define FLOW_CONTROL_DEFAULT FLOW_CONTROL_FULL
137 124
138/* XsumRX - Receive Checksum Offload Enable/Disable 125/* XsumRX - Receive Checksum Offload Enable/Disable
139 * 126 *
@@ -144,53 +131,54 @@ E1000_PARAM(FlowControl, "Flow Control setting");
144 * 131 *
145 * Default Value: 1 132 * Default Value: 1
146 */ 133 */
147
148E1000_PARAM(XsumRX, "Disable or enable Receive Checksum offload"); 134E1000_PARAM(XsumRX, "Disable or enable Receive Checksum offload");
149 135
150/* Transmit Interrupt Delay in units of 1.024 microseconds 136/* Transmit Interrupt Delay in units of 1.024 microseconds
137 * Tx interrupt delay needs to typically be set to something non zero
151 * 138 *
152 * Valid Range: 0-65535 139 * Valid Range: 0-65535
153 *
154 * Default Value: 64
155 */ 140 */
156
157E1000_PARAM(TxIntDelay, "Transmit Interrupt Delay"); 141E1000_PARAM(TxIntDelay, "Transmit Interrupt Delay");
142#define DEFAULT_TIDV 8
143#define MAX_TXDELAY 0xFFFF
144#define MIN_TXDELAY 0
158 145
159/* Transmit Absolute Interrupt Delay in units of 1.024 microseconds 146/* Transmit Absolute Interrupt Delay in units of 1.024 microseconds
160 * 147 *
161 * Valid Range: 0-65535 148 * Valid Range: 0-65535
162 *
163 * Default Value: 0
164 */ 149 */
165
166E1000_PARAM(TxAbsIntDelay, "Transmit Absolute Interrupt Delay"); 150E1000_PARAM(TxAbsIntDelay, "Transmit Absolute Interrupt Delay");
151#define DEFAULT_TADV 32
152#define MAX_TXABSDELAY 0xFFFF
153#define MIN_TXABSDELAY 0
167 154
168/* Receive Interrupt Delay in units of 1.024 microseconds 155/* Receive Interrupt Delay in units of 1.024 microseconds
156 * hardware will likely hang if you set this to anything but zero.
169 * 157 *
170 * Valid Range: 0-65535 158 * Valid Range: 0-65535
171 *
172 * Default Value: 0
173 */ 159 */
174
175E1000_PARAM(RxIntDelay, "Receive Interrupt Delay"); 160E1000_PARAM(RxIntDelay, "Receive Interrupt Delay");
161#define DEFAULT_RDTR 0
162#define MAX_RXDELAY 0xFFFF
163#define MIN_RXDELAY 0
176 164
177/* Receive Absolute Interrupt Delay in units of 1.024 microseconds 165/* Receive Absolute Interrupt Delay in units of 1.024 microseconds
178 * 166 *
179 * Valid Range: 0-65535 167 * Valid Range: 0-65535
180 *
181 * Default Value: 128
182 */ 168 */
183
184E1000_PARAM(RxAbsIntDelay, "Receive Absolute Interrupt Delay"); 169E1000_PARAM(RxAbsIntDelay, "Receive Absolute Interrupt Delay");
170#define DEFAULT_RADV 8
171#define MAX_RXABSDELAY 0xFFFF
172#define MIN_RXABSDELAY 0
185 173
186/* Interrupt Throttle Rate (interrupts/sec) 174/* Interrupt Throttle Rate (interrupts/sec)
187 * 175 *
188 * Valid Range: 100-100000 (0=off, 1=dynamic) 176 * Valid Range: 100-100000 (0=off, 1=dynamic, 3=dynamic conservative)
189 *
190 * Default Value: 8000
191 */ 177 */
192
193E1000_PARAM(InterruptThrottleRate, "Interrupt Throttling Rate"); 178E1000_PARAM(InterruptThrottleRate, "Interrupt Throttling Rate");
179#define DEFAULT_ITR 3
180#define MAX_ITR 100000
181#define MIN_ITR 100
194 182
195/* Enable Smart Power Down of the PHY 183/* Enable Smart Power Down of the PHY
196 * 184 *
@@ -198,7 +186,6 @@ E1000_PARAM(InterruptThrottleRate, "Interrupt Throttling Rate");
198 * 186 *
199 * Default Value: 0 (disabled) 187 * Default Value: 0 (disabled)
200 */ 188 */
201
202E1000_PARAM(SmartPowerDownEnable, "Enable PHY smart power down"); 189E1000_PARAM(SmartPowerDownEnable, "Enable PHY smart power down");
203 190
204/* Enable Kumeran Lock Loss workaround 191/* Enable Kumeran Lock Loss workaround
@@ -207,33 +194,8 @@ E1000_PARAM(SmartPowerDownEnable, "Enable PHY smart power down");
207 * 194 *
208 * Default Value: 1 (enabled) 195 * Default Value: 1 (enabled)
209 */ 196 */
210
211E1000_PARAM(KumeranLockLoss, "Enable Kumeran lock loss workaround"); 197E1000_PARAM(KumeranLockLoss, "Enable Kumeran lock loss workaround");
212 198
213#define AUTONEG_ADV_DEFAULT 0x2F
214#define AUTONEG_ADV_MASK 0x2F
215#define FLOW_CONTROL_DEFAULT FLOW_CONTROL_FULL
216
217#define DEFAULT_RDTR 0
218#define MAX_RXDELAY 0xFFFF
219#define MIN_RXDELAY 0
220
221#define DEFAULT_RADV 128
222#define MAX_RXABSDELAY 0xFFFF
223#define MIN_RXABSDELAY 0
224
225#define DEFAULT_TIDV 64
226#define MAX_TXDELAY 0xFFFF
227#define MIN_TXDELAY 0
228
229#define DEFAULT_TADV 64
230#define MAX_TXABSDELAY 0xFFFF
231#define MIN_TXABSDELAY 0
232
233#define DEFAULT_ITR 8000
234#define MAX_ITR 100000
235#define MIN_ITR 100
236
237struct e1000_option { 199struct e1000_option {
238 enum { enable_option, range_option, list_option } type; 200 enum { enable_option, range_option, list_option } type;
239 char *name; 201 char *name;
@@ -510,15 +472,27 @@ e1000_check_options(struct e1000_adapter *adapter)
510 break; 472 break;
511 case 1: 473 case 1:
512 DPRINTK(PROBE, INFO, "%s set to dynamic mode\n", 474 DPRINTK(PROBE, INFO, "%s set to dynamic mode\n",
513 opt.name); 475 opt.name);
476 adapter->itr_setting = adapter->itr;
477 adapter->itr = 20000;
478 break;
479 case 3:
480 DPRINTK(PROBE, INFO,
481 "%s set to dynamic conservative mode\n",
482 opt.name);
483 adapter->itr_setting = adapter->itr;
484 adapter->itr = 20000;
514 break; 485 break;
515 default: 486 default:
516 e1000_validate_option(&adapter->itr, &opt, 487 e1000_validate_option(&adapter->itr, &opt,
517 adapter); 488 adapter);
489 /* save the setting, because the dynamic bits change itr */
490 adapter->itr_setting = adapter->itr;
518 break; 491 break;
519 } 492 }
520 } else { 493 } else {
521 adapter->itr = opt.def; 494 adapter->itr_setting = opt.def;
495 adapter->itr = 20000;
522 } 496 }
523 } 497 }
524 { /* Smart Power Down */ 498 { /* Smart Power Down */
diff --git a/drivers/net/e2100.c b/drivers/net/e2100.c
index d39e8480ca56..c62d9c6363c6 100644
--- a/drivers/net/e2100.c
+++ b/drivers/net/e2100.c
@@ -463,7 +463,7 @@ static void cleanup_card(struct net_device *dev)
463 release_region(dev->base_addr, E21_IO_EXTENT); 463 release_region(dev->base_addr, E21_IO_EXTENT);
464} 464}
465 465
466void 466void __exit
467cleanup_module(void) 467cleanup_module(void)
468{ 468{
469 int this_dev; 469 int this_dev;
diff --git a/drivers/net/eepro.c b/drivers/net/eepro.c
index a4eb0dc99ecf..b4463094c93a 100644
--- a/drivers/net/eepro.c
+++ b/drivers/net/eepro.c
@@ -1827,7 +1827,7 @@ int __init init_module(void)
1827 return n_eepro ? 0 : -ENODEV; 1827 return n_eepro ? 0 : -ENODEV;
1828} 1828}
1829 1829
1830void 1830void __exit
1831cleanup_module(void) 1831cleanup_module(void)
1832{ 1832{
1833 int i; 1833 int i;
diff --git a/drivers/net/eexpress.c b/drivers/net/eexpress.c
index e14be020e562..4a50fcb5ad6b 100644
--- a/drivers/net/eexpress.c
+++ b/drivers/net/eexpress.c
@@ -1719,7 +1719,7 @@ int __init init_module(void)
1719 return -ENXIO; 1719 return -ENXIO;
1720} 1720}
1721 1721
1722void cleanup_module(void) 1722void __exit cleanup_module(void)
1723{ 1723{
1724 int this_dev; 1724 int this_dev;
1725 1725
diff --git a/drivers/net/ehea/ehea.h b/drivers/net/ehea/ehea.h
index b40724fc6b74..39ad9f73d1ec 100644
--- a/drivers/net/ehea/ehea.h
+++ b/drivers/net/ehea/ehea.h
@@ -39,7 +39,7 @@
39#include <asm/io.h> 39#include <asm/io.h>
40 40
41#define DRV_NAME "ehea" 41#define DRV_NAME "ehea"
42#define DRV_VERSION "EHEA_0034" 42#define DRV_VERSION "EHEA_0043"
43 43
44#define EHEA_MSG_DEFAULT (NETIF_MSG_LINK | NETIF_MSG_TIMER \ 44#define EHEA_MSG_DEFAULT (NETIF_MSG_LINK | NETIF_MSG_TIMER \
45 | NETIF_MSG_RX_ERR | NETIF_MSG_TX_ERR) 45 | NETIF_MSG_RX_ERR | NETIF_MSG_TX_ERR)
@@ -105,9 +105,6 @@
105#define EHEA_BCMC_VLANID_ALL 0x01 105#define EHEA_BCMC_VLANID_ALL 0x01
106#define EHEA_BCMC_VLANID_SINGLE 0x00 106#define EHEA_BCMC_VLANID_SINGLE 0x00
107 107
108/* Use this define to kmallocate pHYP control blocks */
109#define H_CB_ALIGNMENT 4096
110
111#define EHEA_CACHE_LINE 128 108#define EHEA_CACHE_LINE 128
112 109
113/* Memory Regions */ 110/* Memory Regions */
diff --git a/drivers/net/ehea/ehea_ethtool.c b/drivers/net/ehea/ehea_ethtool.c
index 82eb2fb8c75e..9f57c2e78ced 100644
--- a/drivers/net/ehea/ehea_ethtool.c
+++ b/drivers/net/ehea/ehea_ethtool.c
@@ -238,7 +238,7 @@ static void ehea_get_ethtool_stats(struct net_device *dev,
238 data[i++] = port->port_res[0].swqe_refill_th; 238 data[i++] = port->port_res[0].swqe_refill_th;
239 data[i++] = port->resets; 239 data[i++] = port->resets;
240 240
241 cb6 = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 241 cb6 = kzalloc(PAGE_SIZE, GFP_KERNEL);
242 if (!cb6) { 242 if (!cb6) {
243 ehea_error("no mem for cb6"); 243 ehea_error("no mem for cb6");
244 return; 244 return;
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
index 4538c99733fd..83fa32f72398 100644
--- a/drivers/net/ehea/ehea_main.c
+++ b/drivers/net/ehea/ehea_main.c
@@ -92,7 +92,7 @@ static struct net_device_stats *ehea_get_stats(struct net_device *dev)
92 92
93 memset(stats, 0, sizeof(*stats)); 93 memset(stats, 0, sizeof(*stats));
94 94
95 cb2 = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 95 cb2 = kzalloc(PAGE_SIZE, GFP_KERNEL);
96 if (!cb2) { 96 if (!cb2) {
97 ehea_error("no mem for cb2"); 97 ehea_error("no mem for cb2");
98 goto out; 98 goto out;
@@ -586,8 +586,8 @@ int ehea_sense_port_attr(struct ehea_port *port)
586 u64 hret; 586 u64 hret;
587 struct hcp_ehea_port_cb0 *cb0; 587 struct hcp_ehea_port_cb0 *cb0;
588 588
589 cb0 = kzalloc(H_CB_ALIGNMENT, GFP_ATOMIC); /* May be called via */ 589 cb0 = kzalloc(PAGE_SIZE, GFP_ATOMIC); /* May be called via */
590 if (!cb0) { /* ehea_neq_tasklet() */ 590 if (!cb0) { /* ehea_neq_tasklet() */
591 ehea_error("no mem for cb0"); 591 ehea_error("no mem for cb0");
592 ret = -ENOMEM; 592 ret = -ENOMEM;
593 goto out; 593 goto out;
@@ -670,7 +670,7 @@ int ehea_set_portspeed(struct ehea_port *port, u32 port_speed)
670 u64 hret; 670 u64 hret;
671 int ret = 0; 671 int ret = 0;
672 672
673 cb4 = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 673 cb4 = kzalloc(PAGE_SIZE, GFP_KERNEL);
674 if (!cb4) { 674 if (!cb4) {
675 ehea_error("no mem for cb4"); 675 ehea_error("no mem for cb4");
676 ret = -ENOMEM; 676 ret = -ENOMEM;
@@ -985,7 +985,7 @@ static int ehea_configure_port(struct ehea_port *port)
985 struct hcp_ehea_port_cb0 *cb0; 985 struct hcp_ehea_port_cb0 *cb0;
986 986
987 ret = -ENOMEM; 987 ret = -ENOMEM;
988 cb0 = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 988 cb0 = kzalloc(PAGE_SIZE, GFP_KERNEL);
989 if (!cb0) 989 if (!cb0)
990 goto out; 990 goto out;
991 991
@@ -1443,7 +1443,7 @@ static int ehea_set_mac_addr(struct net_device *dev, void *sa)
1443 goto out; 1443 goto out;
1444 } 1444 }
1445 1445
1446 cb0 = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 1446 cb0 = kzalloc(PAGE_SIZE, GFP_KERNEL);
1447 if (!cb0) { 1447 if (!cb0) {
1448 ehea_error("no mem for cb0"); 1448 ehea_error("no mem for cb0");
1449 ret = -ENOMEM; 1449 ret = -ENOMEM;
@@ -1501,7 +1501,7 @@ static void ehea_promiscuous(struct net_device *dev, int enable)
1501 if ((enable && port->promisc) || (!enable && !port->promisc)) 1501 if ((enable && port->promisc) || (!enable && !port->promisc))
1502 return; 1502 return;
1503 1503
1504 cb7 = kzalloc(H_CB_ALIGNMENT, GFP_ATOMIC); 1504 cb7 = kzalloc(PAGE_SIZE, GFP_ATOMIC);
1505 if (!cb7) { 1505 if (!cb7) {
1506 ehea_error("no mem for cb7"); 1506 ehea_error("no mem for cb7");
1507 goto out; 1507 goto out;
@@ -1870,7 +1870,7 @@ static void ehea_vlan_rx_register(struct net_device *dev,
1870 1870
1871 port->vgrp = grp; 1871 port->vgrp = grp;
1872 1872
1873 cb1 = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 1873 cb1 = kzalloc(PAGE_SIZE, GFP_KERNEL);
1874 if (!cb1) { 1874 if (!cb1) {
1875 ehea_error("no mem for cb1"); 1875 ehea_error("no mem for cb1");
1876 goto out; 1876 goto out;
@@ -1899,7 +1899,7 @@ static void ehea_vlan_rx_add_vid(struct net_device *dev, unsigned short vid)
1899 int index; 1899 int index;
1900 u64 hret; 1900 u64 hret;
1901 1901
1902 cb1 = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 1902 cb1 = kzalloc(PAGE_SIZE, GFP_KERNEL);
1903 if (!cb1) { 1903 if (!cb1) {
1904 ehea_error("no mem for cb1"); 1904 ehea_error("no mem for cb1");
1905 goto out; 1905 goto out;
@@ -1935,7 +1935,7 @@ static void ehea_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
1935 if (port->vgrp) 1935 if (port->vgrp)
1936 port->vgrp->vlan_devices[vid] = NULL; 1936 port->vgrp->vlan_devices[vid] = NULL;
1937 1937
1938 cb1 = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 1938 cb1 = kzalloc(PAGE_SIZE, GFP_KERNEL);
1939 if (!cb1) { 1939 if (!cb1) {
1940 ehea_error("no mem for cb1"); 1940 ehea_error("no mem for cb1");
1941 goto out; 1941 goto out;
@@ -1968,7 +1968,7 @@ int ehea_activate_qp(struct ehea_adapter *adapter, struct ehea_qp *qp)
1968 u64 dummy64 = 0; 1968 u64 dummy64 = 0;
1969 struct hcp_modify_qp_cb0* cb0; 1969 struct hcp_modify_qp_cb0* cb0;
1970 1970
1971 cb0 = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 1971 cb0 = kzalloc(PAGE_SIZE, GFP_KERNEL);
1972 if (!cb0) { 1972 if (!cb0) {
1973 ret = -ENOMEM; 1973 ret = -ENOMEM;
1974 goto out; 1974 goto out;
@@ -2224,11 +2224,12 @@ static int ehea_stop(struct net_device *dev)
2224 return ret; 2224 return ret;
2225} 2225}
2226 2226
2227static void ehea_reset_port(void *data) 2227static void ehea_reset_port(struct work_struct *work)
2228{ 2228{
2229 int ret; 2229 int ret;
2230 struct net_device *dev = data; 2230 struct ehea_port *port =
2231 struct ehea_port *port = netdev_priv(dev); 2231 container_of(work, struct ehea_port, reset_task);
2232 struct net_device *dev = port->netdev;
2232 2233
2233 port->resets++; 2234 port->resets++;
2234 down(&port->port_lock); 2235 down(&port->port_lock);
@@ -2269,7 +2270,7 @@ int ehea_sense_adapter_attr(struct ehea_adapter *adapter)
2269 u64 hret; 2270 u64 hret;
2270 int ret; 2271 int ret;
2271 2272
2272 cb = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 2273 cb = kzalloc(PAGE_SIZE, GFP_KERNEL);
2273 if (!cb) { 2274 if (!cb) {
2274 ret = -ENOMEM; 2275 ret = -ENOMEM;
2275 goto out; 2276 goto out;
@@ -2340,7 +2341,7 @@ static int ehea_setup_single_port(struct ehea_port *port,
2340 goto out; 2341 goto out;
2341 2342
2342 /* Enable Jumbo frames */ 2343 /* Enable Jumbo frames */
2343 cb4 = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 2344 cb4 = kzalloc(PAGE_SIZE, GFP_KERNEL);
2344 if (!cb4) { 2345 if (!cb4) {
2345 ehea_error("no mem for cb4"); 2346 ehea_error("no mem for cb4");
2346 } else { 2347 } else {
@@ -2379,7 +2380,7 @@ static int ehea_setup_single_port(struct ehea_port *port,
2379 dev->tx_timeout = &ehea_tx_watchdog; 2380 dev->tx_timeout = &ehea_tx_watchdog;
2380 dev->watchdog_timeo = EHEA_WATCH_DOG_TIMEOUT; 2381 dev->watchdog_timeo = EHEA_WATCH_DOG_TIMEOUT;
2381 2382
2382 INIT_WORK(&port->reset_task, ehea_reset_port, dev); 2383 INIT_WORK(&port->reset_task, ehea_reset_port);
2383 2384
2384 ehea_set_ethtool_ops(dev); 2385 ehea_set_ethtool_ops(dev);
2385 2386
diff --git a/drivers/net/ehea/ehea_phyp.c b/drivers/net/ehea/ehea_phyp.c
index 0b51a8cea077..0cfc2bc1a27b 100644
--- a/drivers/net/ehea/ehea_phyp.c
+++ b/drivers/net/ehea/ehea_phyp.c
@@ -506,7 +506,7 @@ u64 ehea_h_register_rpage_mr(const u64 adapter_handle, const u64 mr_handle,
506 const u8 pagesize, const u8 queue_type, 506 const u8 pagesize, const u8 queue_type,
507 const u64 log_pageaddr, const u64 count) 507 const u64 log_pageaddr, const u64 count)
508{ 508{
509 if ((count > 1) && (log_pageaddr & 0xfff)) { 509 if ((count > 1) && (log_pageaddr & ~PAGE_MASK)) {
510 ehea_error("not on pageboundary"); 510 ehea_error("not on pageboundary");
511 return H_PARAMETER; 511 return H_PARAMETER;
512 } 512 }
diff --git a/drivers/net/ehea/ehea_phyp.h b/drivers/net/ehea/ehea_phyp.h
index fa51e3b5bb05..919f94b75933 100644
--- a/drivers/net/ehea/ehea_phyp.h
+++ b/drivers/net/ehea/ehea_phyp.h
@@ -81,14 +81,16 @@ static inline u32 get_longbusy_msecs(int long_busy_ret_code)
81static inline void hcp_epas_ctor(struct h_epas *epas, u64 paddr_kernel, 81static inline void hcp_epas_ctor(struct h_epas *epas, u64 paddr_kernel,
82 u64 paddr_user) 82 u64 paddr_user)
83{ 83{
84 epas->kernel.addr = ioremap(paddr_kernel, PAGE_SIZE); 84 /* To support 64k pages we must round to 64k page boundary */
85 epas->kernel.addr = ioremap((paddr_kernel & PAGE_MASK), PAGE_SIZE) +
86 (paddr_kernel & ~PAGE_MASK);
85 epas->user.addr = paddr_user; 87 epas->user.addr = paddr_user;
86} 88}
87 89
88static inline void hcp_epas_dtor(struct h_epas *epas) 90static inline void hcp_epas_dtor(struct h_epas *epas)
89{ 91{
90 if (epas->kernel.addr) 92 if (epas->kernel.addr)
91 iounmap(epas->kernel.addr); 93 iounmap((void __iomem*)((u64)epas->kernel.addr & PAGE_MASK));
92 94
93 epas->user.addr = 0; 95 epas->user.addr = 0;
94 epas->kernel.addr = 0; 96 epas->kernel.addr = 0;
diff --git a/drivers/net/ehea/ehea_qmr.c b/drivers/net/ehea/ehea_qmr.c
index 3e1862326c88..f143e13b229d 100644
--- a/drivers/net/ehea/ehea_qmr.c
+++ b/drivers/net/ehea/ehea_qmr.c
@@ -26,6 +26,7 @@
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 */ 27 */
28 28
29#include <linux/mm.h>
29#include "ehea.h" 30#include "ehea.h"
30#include "ehea_phyp.h" 31#include "ehea_phyp.h"
31#include "ehea_qmr.h" 32#include "ehea_qmr.h"
@@ -209,11 +210,11 @@ int ehea_destroy_cq(struct ehea_cq *cq)
209{ 210{
210 u64 adapter_handle, hret; 211 u64 adapter_handle, hret;
211 212
212 adapter_handle = cq->adapter->handle;
213
214 if (!cq) 213 if (!cq)
215 return 0; 214 return 0;
216 215
216 adapter_handle = cq->adapter->handle;
217
217 /* deregister all previous registered pages */ 218 /* deregister all previous registered pages */
218 hret = ehea_h_free_resource(adapter_handle, cq->fw_handle); 219 hret = ehea_h_free_resource(adapter_handle, cq->fw_handle);
219 if (hret != H_SUCCESS) { 220 if (hret != H_SUCCESS) {
@@ -512,7 +513,7 @@ int ehea_reg_mr_adapter(struct ehea_adapter *adapter)
512 513
513 start = KERNELBASE; 514 start = KERNELBASE;
514 end = (u64)high_memory; 515 end = (u64)high_memory;
515 nr_pages = (end - start) / PAGE_SIZE; 516 nr_pages = (end - start) / EHEA_PAGESIZE;
516 517
517 pt = kzalloc(PAGE_SIZE, GFP_KERNEL); 518 pt = kzalloc(PAGE_SIZE, GFP_KERNEL);
518 if (!pt) { 519 if (!pt) {
@@ -538,9 +539,9 @@ int ehea_reg_mr_adapter(struct ehea_adapter *adapter)
538 if (nr_pages > 1) { 539 if (nr_pages > 1) {
539 u64 num_pages = min(nr_pages, (u64)512); 540 u64 num_pages = min(nr_pages, (u64)512);
540 for (i = 0; i < num_pages; i++) 541 for (i = 0; i < num_pages; i++)
541 pt[i] = virt_to_abs((void*)(((u64)start) 542 pt[i] = virt_to_abs((void*)(((u64)start) +
542 + ((k++) * 543 ((k++) *
543 PAGE_SIZE))); 544 EHEA_PAGESIZE)));
544 545
545 hret = ehea_h_register_rpage_mr(adapter->handle, 546 hret = ehea_h_register_rpage_mr(adapter->handle,
546 adapter->mr.handle, 0, 547 adapter->mr.handle, 0,
@@ -548,8 +549,9 @@ int ehea_reg_mr_adapter(struct ehea_adapter *adapter)
548 num_pages); 549 num_pages);
549 nr_pages -= num_pages; 550 nr_pages -= num_pages;
550 } else { 551 } else {
551 u64 abs_adr = virt_to_abs((void*)(((u64)start) 552 u64 abs_adr = virt_to_abs((void*)(((u64)start) +
552 + (k * PAGE_SIZE))); 553 (k * EHEA_PAGESIZE)));
554
553 hret = ehea_h_register_rpage_mr(adapter->handle, 555 hret = ehea_h_register_rpage_mr(adapter->handle,
554 adapter->mr.handle, 0, 556 adapter->mr.handle, 0,
555 0, abs_adr,1); 557 0, abs_adr,1);
diff --git a/drivers/net/es3210.c b/drivers/net/es3210.c
index fd7b32a24ea4..2d2ea94a00bb 100644
--- a/drivers/net/es3210.c
+++ b/drivers/net/es3210.c
@@ -455,7 +455,7 @@ static void cleanup_card(struct net_device *dev)
455 iounmap(ei_status.mem); 455 iounmap(ei_status.mem);
456} 456}
457 457
458void 458void __exit
459cleanup_module(void) 459cleanup_module(void)
460{ 460{
461 int this_dev; 461 int this_dev;
diff --git a/drivers/net/eth16i.c b/drivers/net/eth16i.c
index b7b8bc2a6307..93283e386f3a 100644
--- a/drivers/net/eth16i.c
+++ b/drivers/net/eth16i.c
@@ -1475,7 +1475,7 @@ int __init init_module(void)
1475 return -ENXIO; 1475 return -ENXIO;
1476} 1476}
1477 1477
1478void cleanup_module(void) 1478void __exit cleanup_module(void)
1479{ 1479{
1480 int this_dev; 1480 int this_dev;
1481 1481
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
index c5ed635bce36..439f41338291 100644
--- a/drivers/net/forcedeth.c
+++ b/drivers/net/forcedeth.c
@@ -110,6 +110,8 @@
110 * 0.55: 22 Mar 2006: Add flow control (pause frame). 110 * 0.55: 22 Mar 2006: Add flow control (pause frame).
111 * 0.56: 22 Mar 2006: Additional ethtool config and moduleparam support. 111 * 0.56: 22 Mar 2006: Additional ethtool config and moduleparam support.
112 * 0.57: 14 May 2006: Mac address set in probe/remove and order corrections. 112 * 0.57: 14 May 2006: Mac address set in probe/remove and order corrections.
113 * 0.58: 30 Oct 2006: Added support for sideband management unit.
114 * 0.59: 30 Oct 2006: Added support for recoverable error.
113 * 115 *
114 * Known bugs: 116 * Known bugs:
115 * We suspect that on some hardware no TX done interrupts are generated. 117 * We suspect that on some hardware no TX done interrupts are generated.
@@ -126,7 +128,7 @@
126#else 128#else
127#define DRIVERNAPI 129#define DRIVERNAPI
128#endif 130#endif
129#define FORCEDETH_VERSION "0.57" 131#define FORCEDETH_VERSION "0.59"
130#define DRV_NAME "forcedeth" 132#define DRV_NAME "forcedeth"
131 133
132#include <linux/module.h> 134#include <linux/module.h>
@@ -174,11 +176,12 @@
174#define DEV_HAS_PAUSEFRAME_TX 0x0200 /* device supports tx pause frames */ 176#define DEV_HAS_PAUSEFRAME_TX 0x0200 /* device supports tx pause frames */
175#define DEV_HAS_STATISTICS 0x0400 /* device supports hw statistics */ 177#define DEV_HAS_STATISTICS 0x0400 /* device supports hw statistics */
176#define DEV_HAS_TEST_EXTENDED 0x0800 /* device supports extended diagnostic test */ 178#define DEV_HAS_TEST_EXTENDED 0x0800 /* device supports extended diagnostic test */
179#define DEV_HAS_MGMT_UNIT 0x1000 /* device supports management unit */
177 180
178enum { 181enum {
179 NvRegIrqStatus = 0x000, 182 NvRegIrqStatus = 0x000,
180#define NVREG_IRQSTAT_MIIEVENT 0x040 183#define NVREG_IRQSTAT_MIIEVENT 0x040
181#define NVREG_IRQSTAT_MASK 0x1ff 184#define NVREG_IRQSTAT_MASK 0x81ff
182 NvRegIrqMask = 0x004, 185 NvRegIrqMask = 0x004,
183#define NVREG_IRQ_RX_ERROR 0x0001 186#define NVREG_IRQ_RX_ERROR 0x0001
184#define NVREG_IRQ_RX 0x0002 187#define NVREG_IRQ_RX 0x0002
@@ -189,15 +192,16 @@ enum {
189#define NVREG_IRQ_LINK 0x0040 192#define NVREG_IRQ_LINK 0x0040
190#define NVREG_IRQ_RX_FORCED 0x0080 193#define NVREG_IRQ_RX_FORCED 0x0080
191#define NVREG_IRQ_TX_FORCED 0x0100 194#define NVREG_IRQ_TX_FORCED 0x0100
195#define NVREG_IRQ_RECOVER_ERROR 0x8000
192#define NVREG_IRQMASK_THROUGHPUT 0x00df 196#define NVREG_IRQMASK_THROUGHPUT 0x00df
193#define NVREG_IRQMASK_CPU 0x0040 197#define NVREG_IRQMASK_CPU 0x0040
194#define NVREG_IRQ_TX_ALL (NVREG_IRQ_TX_ERR|NVREG_IRQ_TX_OK|NVREG_IRQ_TX_FORCED) 198#define NVREG_IRQ_TX_ALL (NVREG_IRQ_TX_ERR|NVREG_IRQ_TX_OK|NVREG_IRQ_TX_FORCED)
195#define NVREG_IRQ_RX_ALL (NVREG_IRQ_RX_ERROR|NVREG_IRQ_RX|NVREG_IRQ_RX_NOBUF|NVREG_IRQ_RX_FORCED) 199#define NVREG_IRQ_RX_ALL (NVREG_IRQ_RX_ERROR|NVREG_IRQ_RX|NVREG_IRQ_RX_NOBUF|NVREG_IRQ_RX_FORCED)
196#define NVREG_IRQ_OTHER (NVREG_IRQ_TIMER|NVREG_IRQ_LINK) 200#define NVREG_IRQ_OTHER (NVREG_IRQ_TIMER|NVREG_IRQ_LINK|NVREG_IRQ_RECOVER_ERROR)
197 201
198#define NVREG_IRQ_UNKNOWN (~(NVREG_IRQ_RX_ERROR|NVREG_IRQ_RX|NVREG_IRQ_RX_NOBUF|NVREG_IRQ_TX_ERR| \ 202#define NVREG_IRQ_UNKNOWN (~(NVREG_IRQ_RX_ERROR|NVREG_IRQ_RX|NVREG_IRQ_RX_NOBUF|NVREG_IRQ_TX_ERR| \
199 NVREG_IRQ_TX_OK|NVREG_IRQ_TIMER|NVREG_IRQ_LINK|NVREG_IRQ_RX_FORCED| \ 203 NVREG_IRQ_TX_OK|NVREG_IRQ_TIMER|NVREG_IRQ_LINK|NVREG_IRQ_RX_FORCED| \
200 NVREG_IRQ_TX_FORCED)) 204 NVREG_IRQ_TX_FORCED|NVREG_IRQ_RECOVER_ERROR))
201 205
202 NvRegUnknownSetupReg6 = 0x008, 206 NvRegUnknownSetupReg6 = 0x008,
203#define NVREG_UNKSETUP6_VAL 3 207#define NVREG_UNKSETUP6_VAL 3
@@ -222,6 +226,15 @@ enum {
222#define NVREG_MAC_RESET_ASSERT 0x0F3 226#define NVREG_MAC_RESET_ASSERT 0x0F3
223 NvRegTransmitterControl = 0x084, 227 NvRegTransmitterControl = 0x084,
224#define NVREG_XMITCTL_START 0x01 228#define NVREG_XMITCTL_START 0x01
229#define NVREG_XMITCTL_MGMT_ST 0x40000000
230#define NVREG_XMITCTL_SYNC_MASK 0x000f0000
231#define NVREG_XMITCTL_SYNC_NOT_READY 0x0
232#define NVREG_XMITCTL_SYNC_PHY_INIT 0x00040000
233#define NVREG_XMITCTL_MGMT_SEMA_MASK 0x00000f00
234#define NVREG_XMITCTL_MGMT_SEMA_FREE 0x0
235#define NVREG_XMITCTL_HOST_SEMA_MASK 0x0000f000
236#define NVREG_XMITCTL_HOST_SEMA_ACQ 0x0000f000
237#define NVREG_XMITCTL_HOST_LOADED 0x00004000
225 NvRegTransmitterStatus = 0x088, 238 NvRegTransmitterStatus = 0x088,
226#define NVREG_XMITSTAT_BUSY 0x01 239#define NVREG_XMITSTAT_BUSY 0x01
227 240
@@ -304,8 +317,8 @@ enum {
304#define NVREG_MIISTAT_LINKCHANGE 0x0008 317#define NVREG_MIISTAT_LINKCHANGE 0x0008
305#define NVREG_MIISTAT_MASK 0x000f 318#define NVREG_MIISTAT_MASK 0x000f
306#define NVREG_MIISTAT_MASK2 0x000f 319#define NVREG_MIISTAT_MASK2 0x000f
307 NvRegUnknownSetupReg4 = 0x184, 320 NvRegMIIMask = 0x184,
308#define NVREG_UNKSETUP4_VAL 8 321#define NVREG_MII_LINKCHANGE 0x0008
309 322
310 NvRegAdapterControl = 0x188, 323 NvRegAdapterControl = 0x188,
311#define NVREG_ADAPTCTL_START 0x02 324#define NVREG_ADAPTCTL_START 0x02
@@ -707,6 +720,7 @@ struct fe_priv {
707 unsigned int phy_model; 720 unsigned int phy_model;
708 u16 gigabit; 721 u16 gigabit;
709 int intr_test; 722 int intr_test;
723 int recover_error;
710 724
711 /* General data: RO fields */ 725 /* General data: RO fields */
712 dma_addr_t ring_addr; 726 dma_addr_t ring_addr;
@@ -719,6 +733,7 @@ struct fe_priv {
719 u32 driver_data; 733 u32 driver_data;
720 u32 register_size; 734 u32 register_size;
721 int rx_csum; 735 int rx_csum;
736 u32 mac_in_use;
722 737
723 void __iomem *base; 738 void __iomem *base;
724 739
@@ -2443,6 +2458,23 @@ static irqreturn_t nv_nic_irq(int foo, void *data)
2443 printk(KERN_DEBUG "%s: received irq with unknown events 0x%x. Please report\n", 2458 printk(KERN_DEBUG "%s: received irq with unknown events 0x%x. Please report\n",
2444 dev->name, events); 2459 dev->name, events);
2445 } 2460 }
2461 if (unlikely(events & NVREG_IRQ_RECOVER_ERROR)) {
2462 spin_lock(&np->lock);
2463 /* disable interrupts on the nic */
2464 if (!(np->msi_flags & NV_MSI_X_ENABLED))
2465 writel(0, base + NvRegIrqMask);
2466 else
2467 writel(np->irqmask, base + NvRegIrqMask);
2468 pci_push(base);
2469
2470 if (!np->in_shutdown) {
2471 np->nic_poll_irq = np->irqmask;
2472 np->recover_error = 1;
2473 mod_timer(&np->nic_poll, jiffies + POLL_WAIT);
2474 }
2475 spin_unlock(&np->lock);
2476 break;
2477 }
2446#ifdef CONFIG_FORCEDETH_NAPI 2478#ifdef CONFIG_FORCEDETH_NAPI
2447 if (events & NVREG_IRQ_RX_ALL) { 2479 if (events & NVREG_IRQ_RX_ALL) {
2448 netif_rx_schedule(dev); 2480 netif_rx_schedule(dev);
@@ -2673,6 +2705,20 @@ static irqreturn_t nv_nic_irq_other(int foo, void *data)
2673 spin_unlock_irqrestore(&np->lock, flags); 2705 spin_unlock_irqrestore(&np->lock, flags);
2674 np->link_timeout = jiffies + LINK_TIMEOUT; 2706 np->link_timeout = jiffies + LINK_TIMEOUT;
2675 } 2707 }
2708 if (events & NVREG_IRQ_RECOVER_ERROR) {
2709 spin_lock_irq(&np->lock);
2710 /* disable interrupts on the nic */
2711 writel(NVREG_IRQ_OTHER, base + NvRegIrqMask);
2712 pci_push(base);
2713
2714 if (!np->in_shutdown) {
2715 np->nic_poll_irq |= NVREG_IRQ_OTHER;
2716 np->recover_error = 1;
2717 mod_timer(&np->nic_poll, jiffies + POLL_WAIT);
2718 }
2719 spin_unlock_irq(&np->lock);
2720 break;
2721 }
2676 if (events & (NVREG_IRQ_UNKNOWN)) { 2722 if (events & (NVREG_IRQ_UNKNOWN)) {
2677 printk(KERN_DEBUG "%s: received irq with unknown events 0x%x. Please report\n", 2723 printk(KERN_DEBUG "%s: received irq with unknown events 0x%x. Please report\n",
2678 dev->name, events); 2724 dev->name, events);
@@ -2902,6 +2948,42 @@ static void nv_do_nic_poll(unsigned long data)
2902 } 2948 }
2903 np->nic_poll_irq = 0; 2949 np->nic_poll_irq = 0;
2904 2950
2951 if (np->recover_error) {
2952 np->recover_error = 0;
2953 printk(KERN_INFO "forcedeth: MAC in recoverable error state\n");
2954 if (netif_running(dev)) {
2955 netif_tx_lock_bh(dev);
2956 spin_lock(&np->lock);
2957 /* stop engines */
2958 nv_stop_rx(dev);
2959 nv_stop_tx(dev);
2960 nv_txrx_reset(dev);
2961 /* drain rx queue */
2962 nv_drain_rx(dev);
2963 nv_drain_tx(dev);
2964 /* reinit driver view of the rx queue */
2965 set_bufsize(dev);
2966 if (nv_init_ring(dev)) {
2967 if (!np->in_shutdown)
2968 mod_timer(&np->oom_kick, jiffies + OOM_REFILL);
2969 }
2970 /* reinit nic view of the rx queue */
2971 writel(np->rx_buf_sz, base + NvRegOffloadConfig);
2972 setup_hw_rings(dev, NV_SETUP_RX_RING | NV_SETUP_TX_RING);
2973 writel( ((np->rx_ring_size-1) << NVREG_RINGSZ_RXSHIFT) + ((np->tx_ring_size-1) << NVREG_RINGSZ_TXSHIFT),
2974 base + NvRegRingSizes);
2975 pci_push(base);
2976 writel(NVREG_TXRXCTL_KICK|np->txrxctl_bits, get_hwbase(dev) + NvRegTxRxControl);
2977 pci_push(base);
2978
2979 /* restart rx engine */
2980 nv_start_rx(dev);
2981 nv_start_tx(dev);
2982 spin_unlock(&np->lock);
2983 netif_tx_unlock_bh(dev);
2984 }
2985 }
2986
2905 /* FIXME: Do we need synchronize_irq(dev->irq) here? */ 2987 /* FIXME: Do we need synchronize_irq(dev->irq) here? */
2906 2988
2907 writel(mask, base + NvRegIrqMask); 2989 writel(mask, base + NvRegIrqMask);
@@ -4030,6 +4112,54 @@ static void nv_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
4030 /* nothing to do */ 4112 /* nothing to do */
4031}; 4113};
4032 4114
4115/* The mgmt unit and driver use a semaphore to access the phy during init */
4116static int nv_mgmt_acquire_sema(struct net_device *dev)
4117{
4118 u8 __iomem *base = get_hwbase(dev);
4119 int i;
4120 u32 tx_ctrl, mgmt_sema;
4121
4122 for (i = 0; i < 10; i++) {
4123 mgmt_sema = readl(base + NvRegTransmitterControl) & NVREG_XMITCTL_MGMT_SEMA_MASK;
4124 if (mgmt_sema == NVREG_XMITCTL_MGMT_SEMA_FREE)
4125 break;
4126 msleep(500);
4127 }
4128
4129 if (mgmt_sema != NVREG_XMITCTL_MGMT_SEMA_FREE)
4130 return 0;
4131
4132 for (i = 0; i < 2; i++) {
4133 tx_ctrl = readl(base + NvRegTransmitterControl);
4134 tx_ctrl |= NVREG_XMITCTL_HOST_SEMA_ACQ;
4135 writel(tx_ctrl, base + NvRegTransmitterControl);
4136
4137 /* verify that semaphore was acquired */
4138 tx_ctrl = readl(base + NvRegTransmitterControl);
4139 if (((tx_ctrl & NVREG_XMITCTL_HOST_SEMA_MASK) == NVREG_XMITCTL_HOST_SEMA_ACQ) &&
4140 ((tx_ctrl & NVREG_XMITCTL_MGMT_SEMA_MASK) == NVREG_XMITCTL_MGMT_SEMA_FREE))
4141 return 1;
4142 else
4143 udelay(50);
4144 }
4145
4146 return 0;
4147}
4148
4149/* Indicate to mgmt unit whether driver is loaded or not */
4150static void nv_mgmt_driver_loaded(struct net_device *dev, int loaded)
4151{
4152 u8 __iomem *base = get_hwbase(dev);
4153 u32 tx_ctrl;
4154
4155 tx_ctrl = readl(base + NvRegTransmitterControl);
4156 if (loaded)
4157 tx_ctrl |= NVREG_XMITCTL_HOST_LOADED;
4158 else
4159 tx_ctrl &= ~NVREG_XMITCTL_HOST_LOADED;
4160 writel(tx_ctrl, base + NvRegTransmitterControl);
4161}
4162
4033static int nv_open(struct net_device *dev) 4163static int nv_open(struct net_device *dev)
4034{ 4164{
4035 struct fe_priv *np = netdev_priv(dev); 4165 struct fe_priv *np = netdev_priv(dev);
@@ -4085,7 +4215,7 @@ static int nv_open(struct net_device *dev)
4085 NV_SETUP5_DELAY, NV_SETUP5_DELAYMAX, 4215 NV_SETUP5_DELAY, NV_SETUP5_DELAYMAX,
4086 KERN_INFO "open: SetupReg5, Bit 31 remained off\n"); 4216 KERN_INFO "open: SetupReg5, Bit 31 remained off\n");
4087 4217
4088 writel(0, base + NvRegUnknownSetupReg4); 4218 writel(0, base + NvRegMIIMask);
4089 writel(NVREG_IRQSTAT_MASK, base + NvRegIrqStatus); 4219 writel(NVREG_IRQSTAT_MASK, base + NvRegIrqStatus);
4090 writel(NVREG_MIISTAT_MASK2, base + NvRegMIIStatus); 4220 writel(NVREG_MIISTAT_MASK2, base + NvRegMIIStatus);
4091 4221
@@ -4111,7 +4241,7 @@ static int nv_open(struct net_device *dev)
4111 writel((np->phyaddr << NVREG_ADAPTCTL_PHYSHIFT)|NVREG_ADAPTCTL_PHYVALID|NVREG_ADAPTCTL_RUNNING, 4241 writel((np->phyaddr << NVREG_ADAPTCTL_PHYSHIFT)|NVREG_ADAPTCTL_PHYVALID|NVREG_ADAPTCTL_RUNNING,
4112 base + NvRegAdapterControl); 4242 base + NvRegAdapterControl);
4113 writel(NVREG_MIISPEED_BIT8|NVREG_MIIDELAY, base + NvRegMIISpeed); 4243 writel(NVREG_MIISPEED_BIT8|NVREG_MIIDELAY, base + NvRegMIISpeed);
4114 writel(NVREG_UNKSETUP4_VAL, base + NvRegUnknownSetupReg4); 4244 writel(NVREG_MII_LINKCHANGE, base + NvRegMIIMask);
4115 if (np->wolenabled) 4245 if (np->wolenabled)
4116 writel(NVREG_WAKEUPFLAGS_ENABLE , base + NvRegWakeUpFlags); 4246 writel(NVREG_WAKEUPFLAGS_ENABLE , base + NvRegWakeUpFlags);
4117 4247
@@ -4230,6 +4360,8 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
4230 u8 __iomem *base; 4360 u8 __iomem *base;
4231 int err, i; 4361 int err, i;
4232 u32 powerstate, txreg; 4362 u32 powerstate, txreg;
4363 u32 phystate_orig = 0, phystate;
4364 int phyinitialized = 0;
4233 4365
4234 dev = alloc_etherdev(sizeof(struct fe_priv)); 4366 dev = alloc_etherdev(sizeof(struct fe_priv));
4235 err = -ENOMEM; 4367 err = -ENOMEM;
@@ -4514,6 +4646,48 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
4514 np->need_linktimer = 0; 4646 np->need_linktimer = 0;
4515 } 4647 }
4516 4648
4649 /* clear phy state and temporarily halt phy interrupts */
4650 writel(0, base + NvRegMIIMask);
4651 phystate = readl(base + NvRegAdapterControl);
4652 if (phystate & NVREG_ADAPTCTL_RUNNING) {
4653 phystate_orig = 1;
4654 phystate &= ~NVREG_ADAPTCTL_RUNNING;
4655 writel(phystate, base + NvRegAdapterControl);
4656 }
4657 writel(NVREG_MIISTAT_MASK, base + NvRegMIIStatus);
4658
4659 if (id->driver_data & DEV_HAS_MGMT_UNIT) {
4660 writel(0x1, base + 0x204); pci_push(base);
4661 msleep(500);
4662 /* management unit running on the mac? */
4663 np->mac_in_use = readl(base + NvRegTransmitterControl) & NVREG_XMITCTL_MGMT_ST;
4664 if (np->mac_in_use) {
4665 u32 mgmt_sync;
4666 /* management unit setup the phy already? */
4667 mgmt_sync = readl(base + NvRegTransmitterControl) & NVREG_XMITCTL_SYNC_MASK;
4668 if (mgmt_sync == NVREG_XMITCTL_SYNC_NOT_READY) {
4669 if (!nv_mgmt_acquire_sema(dev)) {
4670 for (i = 0; i < 5000; i++) {
4671 msleep(1);
4672 mgmt_sync = readl(base + NvRegTransmitterControl) & NVREG_XMITCTL_SYNC_MASK;
4673 if (mgmt_sync == NVREG_XMITCTL_SYNC_NOT_READY)
4674 continue;
4675 if (mgmt_sync == NVREG_XMITCTL_SYNC_PHY_INIT)
4676 phyinitialized = 1;
4677 break;
4678 }
4679 } else {
4680 /* we need to init the phy */
4681 }
4682 } else if (mgmt_sync == NVREG_XMITCTL_SYNC_PHY_INIT) {
4683 /* phy is inited by SMU */
4684 phyinitialized = 1;
4685 } else {
4686 /* we need to init the phy */
4687 }
4688 }
4689 }
4690
4517 /* find a suitable phy */ 4691 /* find a suitable phy */
4518 for (i = 1; i <= 32; i++) { 4692 for (i = 1; i <= 32; i++) {
4519 int id1, id2; 4693 int id1, id2;
@@ -4545,8 +4719,14 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
4545 goto out_error; 4719 goto out_error;
4546 } 4720 }
4547 4721
4548 /* reset it */ 4722 if (!phyinitialized) {
4549 phy_init(dev); 4723 /* reset it */
4724 phy_init(dev);
4725 }
4726
4727 if (id->driver_data & DEV_HAS_MGMT_UNIT) {
4728 nv_mgmt_driver_loaded(dev, 1);
4729 }
4550 4730
4551 /* set default link speed settings */ 4731 /* set default link speed settings */
4552 np->linkspeed = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_10; 4732 np->linkspeed = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_10;
@@ -4565,6 +4745,10 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
4565 return 0; 4745 return 0;
4566 4746
4567out_error: 4747out_error:
4748 if (phystate_orig)
4749 writel(phystate|NVREG_ADAPTCTL_RUNNING, base + NvRegAdapterControl);
4750 if (np->mac_in_use)
4751 nv_mgmt_driver_loaded(dev, 0);
4568 pci_set_drvdata(pci_dev, NULL); 4752 pci_set_drvdata(pci_dev, NULL);
4569out_freering: 4753out_freering:
4570 free_rings(dev); 4754 free_rings(dev);
@@ -4594,6 +4778,9 @@ static void __devexit nv_remove(struct pci_dev *pci_dev)
4594 writel(np->orig_mac[0], base + NvRegMacAddrA); 4778 writel(np->orig_mac[0], base + NvRegMacAddrA);
4595 writel(np->orig_mac[1], base + NvRegMacAddrB); 4779 writel(np->orig_mac[1], base + NvRegMacAddrB);
4596 4780
4781 if (np->mac_in_use)
4782 nv_mgmt_driver_loaded(dev, 0);
4783
4597 /* free all structures */ 4784 /* free all structures */
4598 free_rings(dev); 4785 free_rings(dev);
4599 iounmap(get_hwbase(dev)); 4786 iounmap(get_hwbase(dev));
@@ -4603,6 +4790,50 @@ static void __devexit nv_remove(struct pci_dev *pci_dev)
4603 pci_set_drvdata(pci_dev, NULL); 4790 pci_set_drvdata(pci_dev, NULL);
4604} 4791}
4605 4792
4793#ifdef CONFIG_PM
4794static int nv_suspend(struct pci_dev *pdev, pm_message_t state)
4795{
4796 struct net_device *dev = pci_get_drvdata(pdev);
4797 struct fe_priv *np = netdev_priv(dev);
4798
4799 if (!netif_running(dev))
4800 goto out;
4801
4802 netif_device_detach(dev);
4803
4804 // Gross.
4805 nv_close(dev);
4806
4807 pci_save_state(pdev);
4808 pci_enable_wake(pdev, pci_choose_state(pdev, state), np->wolenabled);
4809 pci_set_power_state(pdev, pci_choose_state(pdev, state));
4810out:
4811 return 0;
4812}
4813
4814static int nv_resume(struct pci_dev *pdev)
4815{
4816 struct net_device *dev = pci_get_drvdata(pdev);
4817 int rc = 0;
4818
4819 if (!netif_running(dev))
4820 goto out;
4821
4822 netif_device_attach(dev);
4823
4824 pci_set_power_state(pdev, PCI_D0);
4825 pci_restore_state(pdev);
4826 pci_enable_wake(pdev, PCI_D0, 0);
4827
4828 rc = nv_open(dev);
4829out:
4830 return rc;
4831}
4832#else
4833#define nv_suspend NULL
4834#define nv_resume NULL
4835#endif /* CONFIG_PM */
4836
4606static struct pci_device_id pci_tbl[] = { 4837static struct pci_device_id pci_tbl[] = {
4607 { /* nForce Ethernet Controller */ 4838 { /* nForce Ethernet Controller */
4608 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_1), 4839 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_1),
@@ -4658,43 +4889,59 @@ static struct pci_device_id pci_tbl[] = {
4658 }, 4889 },
4659 { /* MCP55 Ethernet Controller */ 4890 { /* MCP55 Ethernet Controller */
4660 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_14), 4891 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_14),
4661 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_VLAN|DEV_HAS_MSI|DEV_HAS_MSI_X|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED, 4892 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_VLAN|DEV_HAS_MSI|DEV_HAS_MSI_X|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT,
4662 }, 4893 },
4663 { /* MCP55 Ethernet Controller */ 4894 { /* MCP55 Ethernet Controller */
4664 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_15), 4895 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_15),
4665 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_VLAN|DEV_HAS_MSI|DEV_HAS_MSI_X|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED, 4896 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_VLAN|DEV_HAS_MSI|DEV_HAS_MSI_X|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT,
4666 }, 4897 },
4667 { /* MCP61 Ethernet Controller */ 4898 { /* MCP61 Ethernet Controller */
4668 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_16), 4899 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_16),
4669 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED, 4900 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT,
4670 }, 4901 },
4671 { /* MCP61 Ethernet Controller */ 4902 { /* MCP61 Ethernet Controller */
4672 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_17), 4903 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_17),
4673 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED, 4904 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT,
4674 }, 4905 },
4675 { /* MCP61 Ethernet Controller */ 4906 { /* MCP61 Ethernet Controller */
4676 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_18), 4907 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_18),
4677 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED, 4908 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT,
4678 }, 4909 },
4679 { /* MCP61 Ethernet Controller */ 4910 { /* MCP61 Ethernet Controller */
4680 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_19), 4911 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_19),
4681 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED, 4912 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT,
4682 }, 4913 },
4683 { /* MCP65 Ethernet Controller */ 4914 { /* MCP65 Ethernet Controller */
4684 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_20), 4915 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_20),
4685 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED, 4916 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT,
4686 }, 4917 },
4687 { /* MCP65 Ethernet Controller */ 4918 { /* MCP65 Ethernet Controller */
4688 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_21), 4919 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_21),
4689 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED, 4920 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT,
4690 }, 4921 },
4691 { /* MCP65 Ethernet Controller */ 4922 { /* MCP65 Ethernet Controller */
4692 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_22), 4923 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_22),
4693 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED, 4924 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT,
4694 }, 4925 },
4695 { /* MCP65 Ethernet Controller */ 4926 { /* MCP65 Ethernet Controller */
4696 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_23), 4927 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_23),
4697 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED, 4928 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT,
4929 },
4930 { /* MCP67 Ethernet Controller */
4931 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_24),
4932 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT,
4933 },
4934 { /* MCP67 Ethernet Controller */
4935 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_25),
4936 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT,
4937 },
4938 { /* MCP67 Ethernet Controller */
4939 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_26),
4940 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT,
4941 },
4942 { /* MCP67 Ethernet Controller */
4943 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_27),
4944 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT,
4698 }, 4945 },
4699 {0,}, 4946 {0,},
4700}; 4947};
@@ -4704,9 +4951,10 @@ static struct pci_driver driver = {
4704 .id_table = pci_tbl, 4951 .id_table = pci_tbl,
4705 .probe = nv_probe, 4952 .probe = nv_probe,
4706 .remove = __devexit_p(nv_remove), 4953 .remove = __devexit_p(nv_remove),
4954 .suspend = nv_suspend,
4955 .resume = nv_resume,
4707}; 4956};
4708 4957
4709
4710static int __init init_nic(void) 4958static int __init init_nic(void)
4711{ 4959{
4712 printk(KERN_INFO "forcedeth.c: Reverse Engineered nForce ethernet driver. Version %s.\n", FORCEDETH_VERSION); 4960 printk(KERN_INFO "forcedeth.c: Reverse Engineered nForce ethernet driver. Version %s.\n", FORCEDETH_VERSION);
diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c
index cb3958704a87..889d3a13e95e 100644
--- a/drivers/net/fs_enet/fs_enet-main.c
+++ b/drivers/net/fs_enet/fs_enet-main.c
@@ -779,7 +779,8 @@ static int fs_init_phy(struct net_device *dev)
779 fep->oldspeed = 0; 779 fep->oldspeed = 0;
780 fep->oldduplex = -1; 780 fep->oldduplex = -1;
781 if(fep->fpi->bus_id) 781 if(fep->fpi->bus_id)
782 phydev = phy_connect(dev, fep->fpi->bus_id, &fs_adjust_link, 0); 782 phydev = phy_connect(dev, fep->fpi->bus_id, &fs_adjust_link, 0,
783 PHY_INTERFACE_MODE_MII);
783 else { 784 else {
784 printk("No phy bus ID specified in BSP code\n"); 785 printk("No phy bus ID specified in BSP code\n");
785 return -EINVAL; 786 return -EINVAL;
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index a06d8d1aaceb..baa35144134c 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -9,7 +9,7 @@
9 * Author: Andy Fleming 9 * Author: Andy Fleming
10 * Maintainer: Kumar Gala 10 * Maintainer: Kumar Gala
11 * 11 *
12 * Copyright (c) 2002-2004 Freescale Semiconductor, Inc. 12 * Copyright (c) 2002-2006 Freescale Semiconductor, Inc.
13 * 13 *
14 * This program is free software; you can redistribute it and/or modify it 14 * This program is free software; you can redistribute it and/or modify it
15 * under the terms of the GNU General Public License as published by the 15 * under the terms of the GNU General Public License as published by the
@@ -133,6 +133,9 @@ static void gfar_set_hash_for_addr(struct net_device *dev, u8 *addr);
133#ifdef CONFIG_GFAR_NAPI 133#ifdef CONFIG_GFAR_NAPI
134static int gfar_poll(struct net_device *dev, int *budget); 134static int gfar_poll(struct net_device *dev, int *budget);
135#endif 135#endif
136#ifdef CONFIG_NET_POLL_CONTROLLER
137static void gfar_netpoll(struct net_device *dev);
138#endif
136int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit); 139int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit);
137static int gfar_process_frame(struct net_device *dev, struct sk_buff *skb, int length); 140static int gfar_process_frame(struct net_device *dev, struct sk_buff *skb, int length);
138static void gfar_vlan_rx_register(struct net_device *netdev, 141static void gfar_vlan_rx_register(struct net_device *netdev,
@@ -260,6 +263,9 @@ static int gfar_probe(struct platform_device *pdev)
260 dev->poll = gfar_poll; 263 dev->poll = gfar_poll;
261 dev->weight = GFAR_DEV_WEIGHT; 264 dev->weight = GFAR_DEV_WEIGHT;
262#endif 265#endif
266#ifdef CONFIG_NET_POLL_CONTROLLER
267 dev->poll_controller = gfar_netpoll;
268#endif
263 dev->stop = gfar_close; 269 dev->stop = gfar_close;
264 dev->get_stats = gfar_get_stats; 270 dev->get_stats = gfar_get_stats;
265 dev->change_mtu = gfar_change_mtu; 271 dev->change_mtu = gfar_change_mtu;
@@ -392,6 +398,38 @@ static int gfar_remove(struct platform_device *pdev)
392} 398}
393 399
394 400
401/* Reads the controller's registers to determine what interface
402 * connects it to the PHY.
403 */
404static phy_interface_t gfar_get_interface(struct net_device *dev)
405{
406 struct gfar_private *priv = netdev_priv(dev);
407 u32 ecntrl = gfar_read(&priv->regs->ecntrl);
408
409 if (ecntrl & ECNTRL_SGMII_MODE)
410 return PHY_INTERFACE_MODE_SGMII;
411
412 if (ecntrl & ECNTRL_TBI_MODE) {
413 if (ecntrl & ECNTRL_REDUCED_MODE)
414 return PHY_INTERFACE_MODE_RTBI;
415 else
416 return PHY_INTERFACE_MODE_TBI;
417 }
418
419 if (ecntrl & ECNTRL_REDUCED_MODE) {
420 if (ecntrl & ECNTRL_REDUCED_MII_MODE)
421 return PHY_INTERFACE_MODE_RMII;
422 else
423 return PHY_INTERFACE_MODE_RGMII;
424 }
425
426 if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_GIGABIT)
427 return PHY_INTERFACE_MODE_GMII;
428
429 return PHY_INTERFACE_MODE_MII;
430}
431
432
395/* Initializes driver's PHY state, and attaches to the PHY. 433/* Initializes driver's PHY state, and attaches to the PHY.
396 * Returns 0 on success. 434 * Returns 0 on success.
397 */ 435 */
@@ -403,6 +441,7 @@ static int init_phy(struct net_device *dev)
403 SUPPORTED_1000baseT_Full : 0; 441 SUPPORTED_1000baseT_Full : 0;
404 struct phy_device *phydev; 442 struct phy_device *phydev;
405 char phy_id[BUS_ID_SIZE]; 443 char phy_id[BUS_ID_SIZE];
444 phy_interface_t interface;
406 445
407 priv->oldlink = 0; 446 priv->oldlink = 0;
408 priv->oldspeed = 0; 447 priv->oldspeed = 0;
@@ -410,7 +449,9 @@ static int init_phy(struct net_device *dev)
410 449
411 snprintf(phy_id, BUS_ID_SIZE, PHY_ID_FMT, priv->einfo->bus_id, priv->einfo->phy_id); 450 snprintf(phy_id, BUS_ID_SIZE, PHY_ID_FMT, priv->einfo->bus_id, priv->einfo->phy_id);
412 451
413 phydev = phy_connect(dev, phy_id, &adjust_link, 0); 452 interface = gfar_get_interface(dev);
453
454 phydev = phy_connect(dev, phy_id, &adjust_link, 0, interface);
414 455
415 if (IS_ERR(phydev)) { 456 if (IS_ERR(phydev)) {
416 printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name); 457 printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name);
@@ -1536,6 +1577,33 @@ static int gfar_poll(struct net_device *dev, int *budget)
1536} 1577}
1537#endif 1578#endif
1538 1579
1580#ifdef CONFIG_NET_POLL_CONTROLLER
1581/*
1582 * Polling 'interrupt' - used by things like netconsole to send skbs
1583 * without having to re-enable interrupts. It's not called while
1584 * the interrupt routine is executing.
1585 */
1586static void gfar_netpoll(struct net_device *dev)
1587{
1588 struct gfar_private *priv = netdev_priv(dev);
1589
1590 /* If the device has multiple interrupts, run tx/rx */
1591 if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_MULTI_INTR) {
1592 disable_irq(priv->interruptTransmit);
1593 disable_irq(priv->interruptReceive);
1594 disable_irq(priv->interruptError);
1595 gfar_interrupt(priv->interruptTransmit, dev);
1596 enable_irq(priv->interruptError);
1597 enable_irq(priv->interruptReceive);
1598 enable_irq(priv->interruptTransmit);
1599 } else {
1600 disable_irq(priv->interruptTransmit);
1601 gfar_interrupt(priv->interruptTransmit, dev);
1602 enable_irq(priv->interruptTransmit);
1603 }
1604}
1605#endif
1606
1539/* The interrupt handler for devices with one interrupt */ 1607/* The interrupt handler for devices with one interrupt */
1540static irqreturn_t gfar_interrupt(int irq, void *dev_id) 1608static irqreturn_t gfar_interrupt(int irq, void *dev_id)
1541{ 1609{
diff --git a/drivers/net/gianfar.h b/drivers/net/gianfar.h
index 9e81a50cf2be..39e9e321fcbc 100644
--- a/drivers/net/gianfar.h
+++ b/drivers/net/gianfar.h
@@ -160,7 +160,10 @@ extern const char gfar_driver_version[];
160 160
161#define ECNTRL_INIT_SETTINGS 0x00001000 161#define ECNTRL_INIT_SETTINGS 0x00001000
162#define ECNTRL_TBI_MODE 0x00000020 162#define ECNTRL_TBI_MODE 0x00000020
163#define ECNTRL_REDUCED_MODE 0x00000010
163#define ECNTRL_R100 0x00000008 164#define ECNTRL_R100 0x00000008
165#define ECNTRL_REDUCED_MII_MODE 0x00000004
166#define ECNTRL_SGMII_MODE 0x00000002
164 167
165#define MRBLR_INIT_SETTINGS DEFAULT_RX_BUFFER_SIZE 168#define MRBLR_INIT_SETTINGS DEFAULT_RX_BUFFER_SIZE
166 169
diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
index 86b3bb9bec2d..92420f007b97 100644
--- a/drivers/net/hamradio/6pack.c
+++ b/drivers/net/hamradio/6pack.c
@@ -914,7 +914,7 @@ static void decode_prio_command(struct sixpack *sp, unsigned char cmd)
914 printk(KERN_DEBUG "6pack: protocol violation\n"); 914 printk(KERN_DEBUG "6pack: protocol violation\n");
915 else 915 else
916 sp->status = 0; 916 sp->status = 0;
917 cmd &= !SIXP_RX_DCD_MASK; 917 cmd &= ~SIXP_RX_DCD_MASK;
918 } 918 }
919 sp->status = cmd & SIXP_PRIO_DATA_MASK; 919 sp->status = cmd & SIXP_PRIO_DATA_MASK;
920 } else { /* output watchdog char if idle */ 920 } else { /* output watchdog char if idle */
diff --git a/drivers/net/hamradio/baycom_epp.c b/drivers/net/hamradio/baycom_epp.c
index 1ed9cccd3c11..3c33d6f6a6a6 100644
--- a/drivers/net/hamradio/baycom_epp.c
+++ b/drivers/net/hamradio/baycom_epp.c
@@ -168,8 +168,9 @@ struct baycom_state {
168 int magic; 168 int magic;
169 169
170 struct pardevice *pdev; 170 struct pardevice *pdev;
171 struct net_device *dev;
171 unsigned int work_running; 172 unsigned int work_running;
172 struct work_struct run_work; 173 struct delayed_work run_work;
173 unsigned int modem; 174 unsigned int modem;
174 unsigned int bitrate; 175 unsigned int bitrate;
175 unsigned char stat; 176 unsigned char stat;
@@ -659,16 +660,18 @@ static int receive(struct net_device *dev, int cnt)
659#define GETTICK(x) 660#define GETTICK(x)
660#endif /* __i386__ */ 661#endif /* __i386__ */
661 662
662static void epp_bh(struct net_device *dev) 663static void epp_bh(struct work_struct *work)
663{ 664{
665 struct net_device *dev;
664 struct baycom_state *bc; 666 struct baycom_state *bc;
665 struct parport *pp; 667 struct parport *pp;
666 unsigned char stat; 668 unsigned char stat;
667 unsigned char tmp[2]; 669 unsigned char tmp[2];
668 unsigned int time1 = 0, time2 = 0, time3 = 0; 670 unsigned int time1 = 0, time2 = 0, time3 = 0;
669 int cnt, cnt2; 671 int cnt, cnt2;
670 672
671 bc = netdev_priv(dev); 673 bc = container_of(work, struct baycom_state, run_work.work);
674 dev = bc->dev;
672 if (!bc->work_running) 675 if (!bc->work_running)
673 return; 676 return;
674 baycom_int_freq(bc); 677 baycom_int_freq(bc);
@@ -889,7 +892,7 @@ static int epp_open(struct net_device *dev)
889 return -EBUSY; 892 return -EBUSY;
890 } 893 }
891 dev->irq = /*pp->irq*/ 0; 894 dev->irq = /*pp->irq*/ 0;
892 INIT_WORK(&bc->run_work, (void *)(void *)epp_bh, dev); 895 INIT_DELAYED_WORK(&bc->run_work, epp_bh);
893 bc->work_running = 1; 896 bc->work_running = 1;
894 bc->modem = EPP_CONVENTIONAL; 897 bc->modem = EPP_CONVENTIONAL;
895 if (eppconfig(bc)) 898 if (eppconfig(bc))
@@ -1213,6 +1216,7 @@ static void __init baycom_epp_dev_setup(struct net_device *dev)
1213 /* 1216 /*
1214 * initialize part of the baycom_state struct 1217 * initialize part of the baycom_state struct
1215 */ 1218 */
1219 bc->dev = dev;
1216 bc->magic = BAYCOM_MAGIC; 1220 bc->magic = BAYCOM_MAGIC;
1217 bc->cfg.fclk = 19666600; 1221 bc->cfg.fclk = 19666600;
1218 bc->cfg.bps = 9600; 1222 bc->cfg.bps = 9600;
diff --git a/drivers/net/hamradio/dmascc.c b/drivers/net/hamradio/dmascc.c
index 0f8b9afd55b4..e6e721aff6f6 100644
--- a/drivers/net/hamradio/dmascc.c
+++ b/drivers/net/hamradio/dmascc.c
@@ -252,7 +252,7 @@ static inline void z8530_isr(struct scc_info *info);
252static irqreturn_t scc_isr(int irq, void *dev_id); 252static irqreturn_t scc_isr(int irq, void *dev_id);
253static void rx_isr(struct scc_priv *priv); 253static void rx_isr(struct scc_priv *priv);
254static void special_condition(struct scc_priv *priv, int rc); 254static void special_condition(struct scc_priv *priv, int rc);
255static void rx_bh(void *arg); 255static void rx_bh(struct work_struct *);
256static void tx_isr(struct scc_priv *priv); 256static void tx_isr(struct scc_priv *priv);
257static void es_isr(struct scc_priv *priv); 257static void es_isr(struct scc_priv *priv);
258static void tm_isr(struct scc_priv *priv); 258static void tm_isr(struct scc_priv *priv);
@@ -579,7 +579,7 @@ static int __init setup_adapter(int card_base, int type, int n)
579 priv->param.clocks = TCTRxCP | RCRTxCP; 579 priv->param.clocks = TCTRxCP | RCRTxCP;
580 priv->param.persist = 256; 580 priv->param.persist = 256;
581 priv->param.dma = -1; 581 priv->param.dma = -1;
582 INIT_WORK(&priv->rx_work, rx_bh, priv); 582 INIT_WORK(&priv->rx_work, rx_bh);
583 dev->priv = priv; 583 dev->priv = priv;
584 sprintf(dev->name, "dmascc%i", 2 * n + i); 584 sprintf(dev->name, "dmascc%i", 2 * n + i);
585 dev->base_addr = card_base; 585 dev->base_addr = card_base;
@@ -1272,9 +1272,9 @@ static void special_condition(struct scc_priv *priv, int rc)
1272} 1272}
1273 1273
1274 1274
1275static void rx_bh(void *arg) 1275static void rx_bh(struct work_struct *ugli_api)
1276{ 1276{
1277 struct scc_priv *priv = arg; 1277 struct scc_priv *priv = container_of(ugli_api, struct scc_priv, rx_work);
1278 int i = priv->rx_tail; 1278 int i = priv->rx_tail;
1279 int cb; 1279 int cb;
1280 unsigned long flags; 1280 unsigned long flags;
diff --git a/drivers/net/hp-plus.c b/drivers/net/hp-plus.c
index 6abcfd2a4b28..99a36cc3f8df 100644
--- a/drivers/net/hp-plus.c
+++ b/drivers/net/hp-plus.c
@@ -482,7 +482,7 @@ static void cleanup_card(struct net_device *dev)
482 release_region(dev->base_addr - NIC_OFFSET, HP_IO_EXTENT); 482 release_region(dev->base_addr - NIC_OFFSET, HP_IO_EXTENT);
483} 483}
484 484
485void 485void __exit
486cleanup_module(void) 486cleanup_module(void)
487{ 487{
488 int this_dev; 488 int this_dev;
diff --git a/drivers/net/hp.c b/drivers/net/hp.c
index 29470970aa27..635b13c2e2aa 100644
--- a/drivers/net/hp.c
+++ b/drivers/net/hp.c
@@ -444,7 +444,7 @@ static void cleanup_card(struct net_device *dev)
444 release_region(dev->base_addr - NIC_OFFSET, HP_IO_EXTENT); 444 release_region(dev->base_addr - NIC_OFFSET, HP_IO_EXTENT);
445} 445}
446 446
447void 447void __exit
448cleanup_module(void) 448cleanup_module(void)
449{ 449{
450 int this_dev; 450 int this_dev;
diff --git a/drivers/net/hydra.c b/drivers/net/hydra.c
index 91326ea3e12b..f970bfbb9db2 100644
--- a/drivers/net/hydra.c
+++ b/drivers/net/hydra.c
@@ -31,7 +31,16 @@
31#include <asm/amigahw.h> 31#include <asm/amigahw.h>
32#include <linux/zorro.h> 32#include <linux/zorro.h>
33 33
34#include "8390.h" 34#define EI_SHIFT(x) (ei_local->reg_offset[x])
35#define ei_inb(port) in_8(port)
36#define ei_outb(val,port) out_8(port,val)
37#define ei_inb_p(port) in_8(port)
38#define ei_outb_p(val,port) out_8(port,val)
39
40static const char version[] =
41 "8390.c:v1.10cvs 9/23/94 Donald Becker (becker@cesdis.gsfc.nasa.gov)\n";
42
43#include "lib8390.c"
35 44
36#define NE_EN0_DCFG (0x0e*2) 45#define NE_EN0_DCFG (0x0e*2)
37 46
@@ -100,7 +109,7 @@ static int __devinit hydra_init(struct zorro_dev *z)
100 0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e, 109 0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e,
101 }; 110 };
102 111
103 dev = alloc_ei_netdev(); 112 dev = ____alloc_ei_netdev(0);
104 if (!dev) 113 if (!dev)
105 return -ENOMEM; 114 return -ENOMEM;
106 SET_MODULE_OWNER(dev); 115 SET_MODULE_OWNER(dev);
@@ -117,7 +126,7 @@ static int __devinit hydra_init(struct zorro_dev *z)
117 dev->irq = IRQ_AMIGA_PORTS; 126 dev->irq = IRQ_AMIGA_PORTS;
118 127
119 /* Install the Interrupt handler */ 128 /* Install the Interrupt handler */
120 if (request_irq(IRQ_AMIGA_PORTS, ei_interrupt, IRQF_SHARED, "Hydra Ethernet", 129 if (request_irq(IRQ_AMIGA_PORTS, __ei_interrupt, IRQF_SHARED, "Hydra Ethernet",
121 dev)) { 130 dev)) {
122 free_netdev(dev); 131 free_netdev(dev);
123 return -EAGAIN; 132 return -EAGAIN;
@@ -139,10 +148,10 @@ static int __devinit hydra_init(struct zorro_dev *z)
139 dev->open = &hydra_open; 148 dev->open = &hydra_open;
140 dev->stop = &hydra_close; 149 dev->stop = &hydra_close;
141#ifdef CONFIG_NET_POLL_CONTROLLER 150#ifdef CONFIG_NET_POLL_CONTROLLER
142 dev->poll_controller = ei_poll; 151 dev->poll_controller = __ei_poll;
143#endif 152#endif
144 153
145 NS8390_init(dev, 0); 154 __NS8390_init(dev, 0);
146 155
147 err = register_netdev(dev); 156 err = register_netdev(dev);
148 if (err) { 157 if (err) {
@@ -164,7 +173,7 @@ static int __devinit hydra_init(struct zorro_dev *z)
164 173
165static int hydra_open(struct net_device *dev) 174static int hydra_open(struct net_device *dev)
166{ 175{
167 ei_open(dev); 176 __ei_open(dev);
168 return 0; 177 return 0;
169} 178}
170 179
@@ -172,7 +181,7 @@ static int hydra_close(struct net_device *dev)
172{ 181{
173 if (ei_debug > 1) 182 if (ei_debug > 1)
174 printk(KERN_DEBUG "%s: Shutting down ethercard.\n", dev->name); 183 printk(KERN_DEBUG "%s: Shutting down ethercard.\n", dev->name);
175 ei_close(dev); 184 __ei_close(dev);
176 return 0; 185 return 0;
177} 186}
178 187
diff --git a/drivers/net/ibm_emac/ibm_emac_mal.h b/drivers/net/ibm_emac/ibm_emac_mal.h
index f73f10a0a562..407d2acbf7c7 100644
--- a/drivers/net/ibm_emac/ibm_emac_mal.h
+++ b/drivers/net/ibm_emac/ibm_emac_mal.h
@@ -24,6 +24,7 @@
24#include <linux/netdevice.h> 24#include <linux/netdevice.h>
25 25
26#include <asm/io.h> 26#include <asm/io.h>
27#include <asm/dcr.h>
27 28
28/* 29/*
29 * These MAL "versions" probably aren't the real versions IBM uses for these 30 * These MAL "versions" probably aren't the real versions IBM uses for these
@@ -191,6 +192,7 @@ struct mal_commac {
191 192
192struct ibm_ocp_mal { 193struct ibm_ocp_mal {
193 int dcrbase; 194 int dcrbase;
195 dcr_host_t dcrhost;
194 196
195 struct list_head poll_list; 197 struct list_head poll_list;
196 struct net_device poll_dev; 198 struct net_device poll_dev;
@@ -207,12 +209,12 @@ struct ibm_ocp_mal {
207 209
208static inline u32 get_mal_dcrn(struct ibm_ocp_mal *mal, int reg) 210static inline u32 get_mal_dcrn(struct ibm_ocp_mal *mal, int reg)
209{ 211{
210 return mfdcr(mal->dcrbase + reg); 212 return dcr_read(mal->dcrhost, mal->dcrbase + reg);
211} 213}
212 214
213static inline void set_mal_dcrn(struct ibm_ocp_mal *mal, int reg, u32 val) 215static inline void set_mal_dcrn(struct ibm_ocp_mal *mal, int reg, u32 val)
214{ 216{
215 mtdcr(mal->dcrbase + reg, val); 217 dcr_write(mal->dcrhost, mal->dcrbase + reg, val);
216} 218}
217 219
218/* Register MAL devices */ 220/* Register MAL devices */
diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c
index 44c9f993dcc4..99343b5836b8 100644
--- a/drivers/net/ibmveth.c
+++ b/drivers/net/ibmveth.c
@@ -50,7 +50,6 @@
50#include <asm/semaphore.h> 50#include <asm/semaphore.h>
51#include <asm/hvcall.h> 51#include <asm/hvcall.h>
52#include <asm/atomic.h> 52#include <asm/atomic.h>
53#include <asm/iommu.h>
54#include <asm/vio.h> 53#include <asm/vio.h>
55#include <asm/uaccess.h> 54#include <asm/uaccess.h>
56#include <linux/seq_file.h> 55#include <linux/seq_file.h>
@@ -1000,8 +999,6 @@ static int __devinit ibmveth_probe(struct vio_dev *dev, const struct vio_device_
1000 adapter->mac_addr = 0; 999 adapter->mac_addr = 0;
1001 memcpy(&adapter->mac_addr, mac_addr_p, 6); 1000 memcpy(&adapter->mac_addr, mac_addr_p, 6);
1002 1001
1003 adapter->liobn = dev->iommu_table->it_index;
1004
1005 netdev->irq = dev->irq; 1002 netdev->irq = dev->irq;
1006 netdev->open = ibmveth_open; 1003 netdev->open = ibmveth_open;
1007 netdev->poll = ibmveth_poll; 1004 netdev->poll = ibmveth_poll;
@@ -1115,7 +1112,6 @@ static int ibmveth_seq_show(struct seq_file *seq, void *v)
1115 seq_printf(seq, "%s %s\n\n", ibmveth_driver_string, ibmveth_driver_version); 1112 seq_printf(seq, "%s %s\n\n", ibmveth_driver_string, ibmveth_driver_version);
1116 1113
1117 seq_printf(seq, "Unit Address: 0x%x\n", adapter->vdev->unit_address); 1114 seq_printf(seq, "Unit Address: 0x%x\n", adapter->vdev->unit_address);
1118 seq_printf(seq, "LIOBN: 0x%lx\n", adapter->liobn);
1119 seq_printf(seq, "Current MAC: %02X:%02X:%02X:%02X:%02X:%02X\n", 1115 seq_printf(seq, "Current MAC: %02X:%02X:%02X:%02X:%02X:%02X\n",
1120 current_mac[0], current_mac[1], current_mac[2], 1116 current_mac[0], current_mac[1], current_mac[2],
1121 current_mac[3], current_mac[4], current_mac[5]); 1117 current_mac[3], current_mac[4], current_mac[5]);
diff --git a/drivers/net/ibmveth.h b/drivers/net/ibmveth.h
index f5b25bff1540..bb69ccae8ace 100644
--- a/drivers/net/ibmveth.h
+++ b/drivers/net/ibmveth.h
@@ -118,7 +118,6 @@ struct ibmveth_adapter {
118 struct net_device_stats stats; 118 struct net_device_stats stats;
119 unsigned int mcastFilterSize; 119 unsigned int mcastFilterSize;
120 unsigned long mac_addr; 120 unsigned long mac_addr;
121 unsigned long liobn;
122 void * buffer_list_addr; 121 void * buffer_list_addr;
123 void * filter_list_addr; 122 void * filter_list_addr;
124 dma_addr_t buffer_list_dma; 123 dma_addr_t buffer_list_dma;
diff --git a/drivers/net/ioc3-eth.c b/drivers/net/ioc3-eth.c
index f56b00ee385e..f0d30cf67b5f 100644
--- a/drivers/net/ioc3-eth.c
+++ b/drivers/net/ioc3-eth.c
@@ -57,7 +57,6 @@
57#include <net/ip.h> 57#include <net/ip.h>
58 58
59#include <asm/byteorder.h> 59#include <asm/byteorder.h>
60#include <asm/checksum.h>
61#include <asm/io.h> 60#include <asm/io.h>
62#include <asm/pgtable.h> 61#include <asm/pgtable.h>
63#include <asm/uaccess.h> 62#include <asm/uaccess.h>
diff --git a/drivers/net/irda/irda-usb.c b/drivers/net/irda/irda-usb.c
index 14bda765c2fa..6e95645e7245 100644
--- a/drivers/net/irda/irda-usb.c
+++ b/drivers/net/irda/irda-usb.c
@@ -1793,10 +1793,8 @@ err_out_3:
1793err_out_2: 1793err_out_2:
1794 usb_free_urb(self->tx_urb); 1794 usb_free_urb(self->tx_urb);
1795err_out_1: 1795err_out_1:
1796 for (i = 0; i < self->max_rx_urb; i++) { 1796 for (i = 0; i < self->max_rx_urb; i++)
1797 if (self->rx_urb[i]) 1797 usb_free_urb(self->rx_urb[i]);
1798 usb_free_urb(self->rx_urb[i]);
1799 }
1800 free_netdev(net); 1798 free_netdev(net);
1801err_out: 1799err_out:
1802 return ret; 1800 return ret;
diff --git a/drivers/net/irda/mcs7780.c b/drivers/net/irda/mcs7780.c
index b32c52ed19d7..f0c61f3b2a82 100644
--- a/drivers/net/irda/mcs7780.c
+++ b/drivers/net/irda/mcs7780.c
@@ -560,9 +560,9 @@ static inline int mcs_find_endpoints(struct mcs_cb *mcs,
560 return ret; 560 return ret;
561} 561}
562 562
563static void mcs_speed_work(void *arg) 563static void mcs_speed_work(struct work_struct *work)
564{ 564{
565 struct mcs_cb *mcs = arg; 565 struct mcs_cb *mcs = container_of(work, struct mcs_cb, work);
566 struct net_device *netdev = mcs->netdev; 566 struct net_device *netdev = mcs->netdev;
567 567
568 mcs_speed_change(mcs); 568 mcs_speed_change(mcs);
@@ -927,7 +927,7 @@ static int mcs_probe(struct usb_interface *intf,
927 irda_qos_bits_to_value(&mcs->qos); 927 irda_qos_bits_to_value(&mcs->qos);
928 928
929 /* Speed change work initialisation*/ 929 /* Speed change work initialisation*/
930 INIT_WORK(&mcs->work, mcs_speed_work, mcs); 930 INIT_WORK(&mcs->work, mcs_speed_work);
931 931
932 /* Override the network functions we need to use */ 932 /* Override the network functions we need to use */
933 ndev->hard_start_xmit = mcs_hard_xmit; 933 ndev->hard_start_xmit = mcs_hard_xmit;
diff --git a/drivers/net/irda/pxaficp_ir.c b/drivers/net/irda/pxaficp_ir.c
index f9a1c88a4283..9137e239fac2 100644
--- a/drivers/net/irda/pxaficp_ir.c
+++ b/drivers/net/irda/pxaficp_ir.c
@@ -704,9 +704,9 @@ static int pxa_irda_stop(struct net_device *dev)
704 return 0; 704 return 0;
705} 705}
706 706
707static int pxa_irda_suspend(struct device *_dev, pm_message_t state) 707static int pxa_irda_suspend(struct platform_device *_dev, pm_message_t state)
708{ 708{
709 struct net_device *dev = dev_get_drvdata(_dev); 709 struct net_device *dev = platform_get_drvdata(_dev);
710 struct pxa_irda *si; 710 struct pxa_irda *si;
711 711
712 if (dev && netif_running(dev)) { 712 if (dev && netif_running(dev)) {
@@ -718,9 +718,9 @@ static int pxa_irda_suspend(struct device *_dev, pm_message_t state)
718 return 0; 718 return 0;
719} 719}
720 720
721static int pxa_irda_resume(struct device *_dev) 721static int pxa_irda_resume(struct platform_device *_dev)
722{ 722{
723 struct net_device *dev = dev_get_drvdata(_dev); 723 struct net_device *dev = platform_get_drvdata(_dev);
724 struct pxa_irda *si; 724 struct pxa_irda *si;
725 725
726 if (dev && netif_running(dev)) { 726 if (dev && netif_running(dev)) {
@@ -746,9 +746,8 @@ static int pxa_irda_init_iobuf(iobuff_t *io, int size)
746 return io->head ? 0 : -ENOMEM; 746 return io->head ? 0 : -ENOMEM;
747} 747}
748 748
749static int pxa_irda_probe(struct device *_dev) 749static int pxa_irda_probe(struct platform_device *pdev)
750{ 750{
751 struct platform_device *pdev = to_platform_device(_dev);
752 struct net_device *dev; 751 struct net_device *dev;
753 struct pxa_irda *si; 752 struct pxa_irda *si;
754 unsigned int baudrate_mask; 753 unsigned int baudrate_mask;
@@ -822,9 +821,9 @@ err_mem_1:
822 return err; 821 return err;
823} 822}
824 823
825static int pxa_irda_remove(struct device *_dev) 824static int pxa_irda_remove(struct platform_device *_dev)
826{ 825{
827 struct net_device *dev = dev_get_drvdata(_dev); 826 struct net_device *dev = platform_get_drvdata(_dev);
828 827
829 if (dev) { 828 if (dev) {
830 struct pxa_irda *si = netdev_priv(dev); 829 struct pxa_irda *si = netdev_priv(dev);
@@ -840,9 +839,10 @@ static int pxa_irda_remove(struct device *_dev)
840 return 0; 839 return 0;
841} 840}
842 841
843static struct device_driver pxa_ir_driver = { 842static struct platform_driver pxa_ir_driver = {
844 .name = "pxa2xx-ir", 843 .driver = {
845 .bus = &platform_bus_type, 844 .name = "pxa2xx-ir",
845 },
846 .probe = pxa_irda_probe, 846 .probe = pxa_irda_probe,
847 .remove = pxa_irda_remove, 847 .remove = pxa_irda_remove,
848 .suspend = pxa_irda_suspend, 848 .suspend = pxa_irda_suspend,
@@ -851,12 +851,12 @@ static struct device_driver pxa_ir_driver = {
851 851
852static int __init pxa_irda_init(void) 852static int __init pxa_irda_init(void)
853{ 853{
854 return driver_register(&pxa_ir_driver); 854 return platform_driver_register(&pxa_ir_driver);
855} 855}
856 856
857static void __exit pxa_irda_exit(void) 857static void __exit pxa_irda_exit(void)
858{ 858{
859 driver_unregister(&pxa_ir_driver); 859 platform_driver_unregister(&pxa_ir_driver);
860} 860}
861 861
862module_init(pxa_irda_init); 862module_init(pxa_irda_init);
diff --git a/drivers/net/irda/sir-dev.h b/drivers/net/irda/sir-dev.h
index 9fa294a546d6..2a57bc67ce35 100644
--- a/drivers/net/irda/sir-dev.h
+++ b/drivers/net/irda/sir-dev.h
@@ -22,7 +22,7 @@
22 22
23struct sir_fsm { 23struct sir_fsm {
24 struct semaphore sem; 24 struct semaphore sem;
25 struct work_struct work; 25 struct delayed_work work;
26 unsigned state, substate; 26 unsigned state, substate;
27 int param; 27 int param;
28 int result; 28 int result;
diff --git a/drivers/net/irda/sir_dev.c b/drivers/net/irda/sir_dev.c
index 3b5854d10c17..17b0c3ab6201 100644
--- a/drivers/net/irda/sir_dev.c
+++ b/drivers/net/irda/sir_dev.c
@@ -100,9 +100,9 @@ static int sirdev_tx_complete_fsm(struct sir_dev *dev)
100 * Both must be unlocked/restarted on completion - but only on final exit. 100 * Both must be unlocked/restarted on completion - but only on final exit.
101 */ 101 */
102 102
103static void sirdev_config_fsm(void *data) 103static void sirdev_config_fsm(struct work_struct *work)
104{ 104{
105 struct sir_dev *dev = data; 105 struct sir_dev *dev = container_of(work, struct sir_dev, fsm.work.work);
106 struct sir_fsm *fsm = &dev->fsm; 106 struct sir_fsm *fsm = &dev->fsm;
107 int next_state; 107 int next_state;
108 int ret = -1; 108 int ret = -1;
@@ -309,8 +309,8 @@ int sirdev_schedule_request(struct sir_dev *dev, int initial_state, unsigned par
309 fsm->param = param; 309 fsm->param = param;
310 fsm->result = 0; 310 fsm->result = 0;
311 311
312 INIT_WORK(&fsm->work, sirdev_config_fsm, dev); 312 INIT_DELAYED_WORK(&fsm->work, sirdev_config_fsm);
313 queue_work(irda_sir_wq, &fsm->work); 313 queue_delayed_work(irda_sir_wq, &fsm->work, 0);
314 return 0; 314 return 0;
315} 315}
316 316
diff --git a/drivers/net/irda/stir4200.c b/drivers/net/irda/stir4200.c
index 3b4c47875935..c14a74634fd5 100644
--- a/drivers/net/irda/stir4200.c
+++ b/drivers/net/irda/stir4200.c
@@ -50,6 +50,7 @@
50#include <linux/usb.h> 50#include <linux/usb.h>
51#include <linux/crc32.h> 51#include <linux/crc32.h>
52#include <linux/kthread.h> 52#include <linux/kthread.h>
53#include <linux/freezer.h>
53#include <net/irda/irda.h> 54#include <net/irda/irda.h>
54#include <net/irda/irlap.h> 55#include <net/irda/irlap.h>
55#include <net/irda/irda_device.h> 56#include <net/irda/irda_device.h>
diff --git a/drivers/net/iseries_veth.c b/drivers/net/iseries_veth.c
index 2284e2ce1692..d6f4f185bf37 100644
--- a/drivers/net/iseries_veth.c
+++ b/drivers/net/iseries_veth.c
@@ -166,7 +166,7 @@ struct veth_msg {
166 166
167struct veth_lpar_connection { 167struct veth_lpar_connection {
168 HvLpIndex remote_lp; 168 HvLpIndex remote_lp;
169 struct work_struct statemachine_wq; 169 struct delayed_work statemachine_wq;
170 struct veth_msg *msgs; 170 struct veth_msg *msgs;
171 int num_events; 171 int num_events;
172 struct veth_cap_data local_caps; 172 struct veth_cap_data local_caps;
@@ -456,7 +456,7 @@ static struct kobj_type veth_port_ktype = {
456 456
457static inline void veth_kick_statemachine(struct veth_lpar_connection *cnx) 457static inline void veth_kick_statemachine(struct veth_lpar_connection *cnx)
458{ 458{
459 schedule_work(&cnx->statemachine_wq); 459 schedule_delayed_work(&cnx->statemachine_wq, 0);
460} 460}
461 461
462static void veth_take_cap(struct veth_lpar_connection *cnx, 462static void veth_take_cap(struct veth_lpar_connection *cnx,
@@ -638,9 +638,11 @@ static int veth_process_caps(struct veth_lpar_connection *cnx)
638} 638}
639 639
640/* FIXME: The gotos here are a bit dubious */ 640/* FIXME: The gotos here are a bit dubious */
641static void veth_statemachine(void *p) 641static void veth_statemachine(struct work_struct *work)
642{ 642{
643 struct veth_lpar_connection *cnx = (struct veth_lpar_connection *)p; 643 struct veth_lpar_connection *cnx =
644 container_of(work, struct veth_lpar_connection,
645 statemachine_wq.work);
644 int rlp = cnx->remote_lp; 646 int rlp = cnx->remote_lp;
645 int rc; 647 int rc;
646 648
@@ -827,7 +829,7 @@ static int veth_init_connection(u8 rlp)
827 829
828 cnx->remote_lp = rlp; 830 cnx->remote_lp = rlp;
829 spin_lock_init(&cnx->lock); 831 spin_lock_init(&cnx->lock);
830 INIT_WORK(&cnx->statemachine_wq, veth_statemachine, cnx); 832 INIT_DELAYED_WORK(&cnx->statemachine_wq, veth_statemachine);
831 833
832 init_timer(&cnx->ack_timer); 834 init_timer(&cnx->ack_timer);
833 cnx->ack_timer.function = veth_timed_ack; 835 cnx->ack_timer.function = veth_timed_ack;
diff --git a/drivers/net/ixgb/ixgb_main.c b/drivers/net/ixgb/ixgb_main.c
index e09f575a3a38..e628126c9c49 100644
--- a/drivers/net/ixgb/ixgb_main.c
+++ b/drivers/net/ixgb/ixgb_main.c
@@ -106,7 +106,7 @@ static boolean_t ixgb_clean_rx_irq(struct ixgb_adapter *adapter);
106static void ixgb_alloc_rx_buffers(struct ixgb_adapter *adapter); 106static void ixgb_alloc_rx_buffers(struct ixgb_adapter *adapter);
107void ixgb_set_ethtool_ops(struct net_device *netdev); 107void ixgb_set_ethtool_ops(struct net_device *netdev);
108static void ixgb_tx_timeout(struct net_device *dev); 108static void ixgb_tx_timeout(struct net_device *dev);
109static void ixgb_tx_timeout_task(struct net_device *dev); 109static void ixgb_tx_timeout_task(struct work_struct *work);
110static void ixgb_vlan_rx_register(struct net_device *netdev, 110static void ixgb_vlan_rx_register(struct net_device *netdev,
111 struct vlan_group *grp); 111 struct vlan_group *grp);
112static void ixgb_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid); 112static void ixgb_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid);
@@ -489,8 +489,7 @@ ixgb_probe(struct pci_dev *pdev,
489 adapter->watchdog_timer.function = &ixgb_watchdog; 489 adapter->watchdog_timer.function = &ixgb_watchdog;
490 adapter->watchdog_timer.data = (unsigned long)adapter; 490 adapter->watchdog_timer.data = (unsigned long)adapter;
491 491
492 INIT_WORK(&adapter->tx_timeout_task, 492 INIT_WORK(&adapter->tx_timeout_task, ixgb_tx_timeout_task);
493 (void (*)(void *))ixgb_tx_timeout_task, netdev);
494 493
495 strcpy(netdev->name, "eth%d"); 494 strcpy(netdev->name, "eth%d");
496 if((err = register_netdev(netdev))) 495 if((err = register_netdev(netdev)))
@@ -1249,7 +1248,7 @@ ixgb_tx_csum(struct ixgb_adapter *adapter, struct sk_buff *skb)
1249 if(likely(skb->ip_summed == CHECKSUM_PARTIAL)) { 1248 if(likely(skb->ip_summed == CHECKSUM_PARTIAL)) {
1250 struct ixgb_buffer *buffer_info; 1249 struct ixgb_buffer *buffer_info;
1251 css = skb->h.raw - skb->data; 1250 css = skb->h.raw - skb->data;
1252 cso = (skb->h.raw + skb->csum) - skb->data; 1251 cso = css + skb->csum_offset;
1253 1252
1254 i = adapter->tx_ring.next_to_use; 1253 i = adapter->tx_ring.next_to_use;
1255 context_desc = IXGB_CONTEXT_DESC(adapter->tx_ring, i); 1254 context_desc = IXGB_CONTEXT_DESC(adapter->tx_ring, i);
@@ -1493,9 +1492,10 @@ ixgb_tx_timeout(struct net_device *netdev)
1493} 1492}
1494 1493
1495static void 1494static void
1496ixgb_tx_timeout_task(struct net_device *netdev) 1495ixgb_tx_timeout_task(struct work_struct *work)
1497{ 1496{
1498 struct ixgb_adapter *adapter = netdev_priv(netdev); 1497 struct ixgb_adapter *adapter =
1498 container_of(work, struct ixgb_adapter, tx_timeout_task);
1499 1499
1500 adapter->tx_timeout_count++; 1500 adapter->tx_timeout_count++;
1501 ixgb_down(adapter, TRUE); 1501 ixgb_down(adapter, TRUE);
diff --git a/drivers/net/lance.c b/drivers/net/lance.c
index 6efbd499d752..a3843320dbe1 100644
--- a/drivers/net/lance.c
+++ b/drivers/net/lance.c
@@ -57,6 +57,7 @@ static const char version[] = "lance.c:v1.16 2006/11/09 dplatt@3do.com, becker@c
57#include <linux/netdevice.h> 57#include <linux/netdevice.h>
58#include <linux/etherdevice.h> 58#include <linux/etherdevice.h>
59#include <linux/skbuff.h> 59#include <linux/skbuff.h>
60#include <linux/mm.h>
60#include <linux/bitops.h> 61#include <linux/bitops.h>
61 62
62#include <asm/io.h> 63#include <asm/io.h>
@@ -367,7 +368,7 @@ static void cleanup_card(struct net_device *dev)
367 kfree(lp); 368 kfree(lp);
368} 369}
369 370
370void cleanup_module(void) 371void __exit cleanup_module(void)
371{ 372{
372 int this_dev; 373 int this_dev;
373 374
diff --git a/drivers/net/lasi_82596.c b/drivers/net/lasi_82596.c
index f4d815bca643..ea392f2a5aa2 100644
--- a/drivers/net/lasi_82596.c
+++ b/drivers/net/lasi_82596.c
@@ -119,14 +119,14 @@
119#define DEB(x,y) if (i596_debug & (x)) { y; } 119#define DEB(x,y) if (i596_debug & (x)) { y; }
120 120
121 121
122#define CHECK_WBACK(addr,len) \ 122#define CHECK_WBACK(priv, addr,len) \
123 do { dma_cache_sync((void *)addr, len, DMA_TO_DEVICE); } while (0) 123 do { dma_cache_sync((priv)->dev, (void *)addr, len, DMA_TO_DEVICE); } while (0)
124 124
125#define CHECK_INV(addr,len) \ 125#define CHECK_INV(priv, addr,len) \
126 do { dma_cache_sync((void *)addr, len, DMA_FROM_DEVICE); } while(0) 126 do { dma_cache_sync((priv)->dev, (void *)addr, len, DMA_FROM_DEVICE); } while(0)
127 127
128#define CHECK_WBACK_INV(addr,len) \ 128#define CHECK_WBACK_INV(priv, addr,len) \
129 do { dma_cache_sync((void *)addr, len, DMA_BIDIRECTIONAL); } while (0) 129 do { dma_cache_sync((priv)->dev, (void *)addr, len, DMA_BIDIRECTIONAL); } while (0)
130 130
131 131
132#define PA_I82596_RESET 0 /* Offsets relative to LASI-LAN-Addr.*/ 132#define PA_I82596_RESET 0 /* Offsets relative to LASI-LAN-Addr.*/
@@ -449,10 +449,10 @@ static inline void MPU_PORT(struct net_device *dev, int c, dma_addr_t x)
449 449
450static inline int wait_istat(struct net_device *dev, struct i596_private *lp, int delcnt, char *str) 450static inline int wait_istat(struct net_device *dev, struct i596_private *lp, int delcnt, char *str)
451{ 451{
452 CHECK_INV(&(lp->iscp), sizeof(struct i596_iscp)); 452 CHECK_INV(lp, &(lp->iscp), sizeof(struct i596_iscp));
453 while (--delcnt && lp->iscp.stat) { 453 while (--delcnt && lp->iscp.stat) {
454 udelay(10); 454 udelay(10);
455 CHECK_INV(&(lp->iscp), sizeof(struct i596_iscp)); 455 CHECK_INV(lp, &(lp->iscp), sizeof(struct i596_iscp));
456 } 456 }
457 if (!delcnt) { 457 if (!delcnt) {
458 printk("%s: %s, iscp.stat %04x, didn't clear\n", 458 printk("%s: %s, iscp.stat %04x, didn't clear\n",
@@ -466,10 +466,10 @@ static inline int wait_istat(struct net_device *dev, struct i596_private *lp, in
466 466
467static inline int wait_cmd(struct net_device *dev, struct i596_private *lp, int delcnt, char *str) 467static inline int wait_cmd(struct net_device *dev, struct i596_private *lp, int delcnt, char *str)
468{ 468{
469 CHECK_INV(&(lp->scb), sizeof(struct i596_scb)); 469 CHECK_INV(lp, &(lp->scb), sizeof(struct i596_scb));
470 while (--delcnt && lp->scb.command) { 470 while (--delcnt && lp->scb.command) {
471 udelay(10); 471 udelay(10);
472 CHECK_INV(&(lp->scb), sizeof(struct i596_scb)); 472 CHECK_INV(lp, &(lp->scb), sizeof(struct i596_scb));
473 } 473 }
474 if (!delcnt) { 474 if (!delcnt) {
475 printk("%s: %s, status %4.4x, cmd %4.4x.\n", 475 printk("%s: %s, status %4.4x, cmd %4.4x.\n",
@@ -522,7 +522,7 @@ static void i596_display_data(struct net_device *dev)
522 rbd, rbd->count, rbd->b_next, rbd->b_data, rbd->size); 522 rbd, rbd->count, rbd->b_next, rbd->b_data, rbd->size);
523 rbd = rbd->v_next; 523 rbd = rbd->v_next;
524 } while (rbd != lp->rbd_head); 524 } while (rbd != lp->rbd_head);
525 CHECK_INV(lp, sizeof(struct i596_private)); 525 CHECK_INV(lp, lp, sizeof(struct i596_private));
526} 526}
527 527
528 528
@@ -592,7 +592,7 @@ static inline void init_rx_bufs(struct net_device *dev)
592 rfd->b_next = WSWAPrfd(virt_to_dma(lp,lp->rfds)); 592 rfd->b_next = WSWAPrfd(virt_to_dma(lp,lp->rfds));
593 rfd->cmd = CMD_EOL|CMD_FLEX; 593 rfd->cmd = CMD_EOL|CMD_FLEX;
594 594
595 CHECK_WBACK_INV(lp, sizeof(struct i596_private)); 595 CHECK_WBACK_INV(lp, lp, sizeof(struct i596_private));
596} 596}
597 597
598static inline void remove_rx_bufs(struct net_device *dev) 598static inline void remove_rx_bufs(struct net_device *dev)
@@ -629,7 +629,7 @@ static void rebuild_rx_bufs(struct net_device *dev)
629 lp->rbd_head = lp->rbds; 629 lp->rbd_head = lp->rbds;
630 lp->rfds[0].rbd = WSWAPrbd(virt_to_dma(lp,lp->rbds)); 630 lp->rfds[0].rbd = WSWAPrbd(virt_to_dma(lp,lp->rbds));
631 631
632 CHECK_WBACK_INV(lp, sizeof(struct i596_private)); 632 CHECK_WBACK_INV(lp, lp, sizeof(struct i596_private));
633} 633}
634 634
635 635
@@ -663,8 +663,8 @@ static int init_i596_mem(struct net_device *dev)
663 663
664 DEB(DEB_INIT, printk("%s: starting i82596.\n", dev->name)); 664 DEB(DEB_INIT, printk("%s: starting i82596.\n", dev->name));
665 665
666 CHECK_WBACK(&(lp->scp), sizeof(struct i596_scp)); 666 CHECK_WBACK(lp, &(lp->scp), sizeof(struct i596_scp));
667 CHECK_WBACK(&(lp->iscp), sizeof(struct i596_iscp)); 667 CHECK_WBACK(lp, &(lp->iscp), sizeof(struct i596_iscp));
668 668
669 MPU_PORT(dev, PORT_ALTSCP, virt_to_dma(lp,&lp->scp)); 669 MPU_PORT(dev, PORT_ALTSCP, virt_to_dma(lp,&lp->scp));
670 670
@@ -678,25 +678,25 @@ static int init_i596_mem(struct net_device *dev)
678 rebuild_rx_bufs(dev); 678 rebuild_rx_bufs(dev);
679 679
680 lp->scb.command = 0; 680 lp->scb.command = 0;
681 CHECK_WBACK(&(lp->scb), sizeof(struct i596_scb)); 681 CHECK_WBACK(lp, &(lp->scb), sizeof(struct i596_scb));
682 682
683 enable_irq(dev->irq); /* enable IRQs from LAN */ 683 enable_irq(dev->irq); /* enable IRQs from LAN */
684 684
685 DEB(DEB_INIT, printk("%s: queuing CmdConfigure\n", dev->name)); 685 DEB(DEB_INIT, printk("%s: queuing CmdConfigure\n", dev->name));
686 memcpy(lp->cf_cmd.i596_config, init_setup, 14); 686 memcpy(lp->cf_cmd.i596_config, init_setup, 14);
687 lp->cf_cmd.cmd.command = CmdConfigure; 687 lp->cf_cmd.cmd.command = CmdConfigure;
688 CHECK_WBACK(&(lp->cf_cmd), sizeof(struct cf_cmd)); 688 CHECK_WBACK(lp, &(lp->cf_cmd), sizeof(struct cf_cmd));
689 i596_add_cmd(dev, &lp->cf_cmd.cmd); 689 i596_add_cmd(dev, &lp->cf_cmd.cmd);
690 690
691 DEB(DEB_INIT, printk("%s: queuing CmdSASetup\n", dev->name)); 691 DEB(DEB_INIT, printk("%s: queuing CmdSASetup\n", dev->name));
692 memcpy(lp->sa_cmd.eth_addr, dev->dev_addr, 6); 692 memcpy(lp->sa_cmd.eth_addr, dev->dev_addr, 6);
693 lp->sa_cmd.cmd.command = CmdSASetup; 693 lp->sa_cmd.cmd.command = CmdSASetup;
694 CHECK_WBACK(&(lp->sa_cmd), sizeof(struct sa_cmd)); 694 CHECK_WBACK(lp, &(lp->sa_cmd), sizeof(struct sa_cmd));
695 i596_add_cmd(dev, &lp->sa_cmd.cmd); 695 i596_add_cmd(dev, &lp->sa_cmd.cmd);
696 696
697 DEB(DEB_INIT, printk("%s: queuing CmdTDR\n", dev->name)); 697 DEB(DEB_INIT, printk("%s: queuing CmdTDR\n", dev->name));
698 lp->tdr_cmd.cmd.command = CmdTDR; 698 lp->tdr_cmd.cmd.command = CmdTDR;
699 CHECK_WBACK(&(lp->tdr_cmd), sizeof(struct tdr_cmd)); 699 CHECK_WBACK(lp, &(lp->tdr_cmd), sizeof(struct tdr_cmd));
700 i596_add_cmd(dev, &lp->tdr_cmd.cmd); 700 i596_add_cmd(dev, &lp->tdr_cmd.cmd);
701 701
702 spin_lock_irqsave (&lp->lock, flags); 702 spin_lock_irqsave (&lp->lock, flags);
@@ -708,7 +708,7 @@ static int init_i596_mem(struct net_device *dev)
708 DEB(DEB_INIT, printk("%s: Issuing RX_START\n", dev->name)); 708 DEB(DEB_INIT, printk("%s: Issuing RX_START\n", dev->name));
709 lp->scb.command = RX_START; 709 lp->scb.command = RX_START;
710 lp->scb.rfd = WSWAPrfd(virt_to_dma(lp,lp->rfds)); 710 lp->scb.rfd = WSWAPrfd(virt_to_dma(lp,lp->rfds));
711 CHECK_WBACK(&(lp->scb), sizeof(struct i596_scb)); 711 CHECK_WBACK(lp, &(lp->scb), sizeof(struct i596_scb));
712 712
713 CA(dev); 713 CA(dev);
714 714
@@ -740,13 +740,13 @@ static inline int i596_rx(struct net_device *dev)
740 740
741 rfd = lp->rfd_head; /* Ref next frame to check */ 741 rfd = lp->rfd_head; /* Ref next frame to check */
742 742
743 CHECK_INV(rfd, sizeof(struct i596_rfd)); 743 CHECK_INV(lp, rfd, sizeof(struct i596_rfd));
744 while ((rfd->stat) & STAT_C) { /* Loop while complete frames */ 744 while ((rfd->stat) & STAT_C) { /* Loop while complete frames */
745 if (rfd->rbd == I596_NULL) 745 if (rfd->rbd == I596_NULL)
746 rbd = NULL; 746 rbd = NULL;
747 else if (rfd->rbd == lp->rbd_head->b_addr) { 747 else if (rfd->rbd == lp->rbd_head->b_addr) {
748 rbd = lp->rbd_head; 748 rbd = lp->rbd_head;
749 CHECK_INV(rbd, sizeof(struct i596_rbd)); 749 CHECK_INV(lp, rbd, sizeof(struct i596_rbd));
750 } 750 }
751 else { 751 else {
752 printk("%s: rbd chain broken!\n", dev->name); 752 printk("%s: rbd chain broken!\n", dev->name);
@@ -790,7 +790,7 @@ static inline int i596_rx(struct net_device *dev)
790 dma_addr = dma_map_single(lp->dev, newskb->data, PKT_BUF_SZ, DMA_FROM_DEVICE); 790 dma_addr = dma_map_single(lp->dev, newskb->data, PKT_BUF_SZ, DMA_FROM_DEVICE);
791 rbd->v_data = newskb->data; 791 rbd->v_data = newskb->data;
792 rbd->b_data = WSWAPchar(dma_addr); 792 rbd->b_data = WSWAPchar(dma_addr);
793 CHECK_WBACK_INV(rbd, sizeof(struct i596_rbd)); 793 CHECK_WBACK_INV(lp, rbd, sizeof(struct i596_rbd));
794 } 794 }
795 else 795 else
796 skb = dev_alloc_skb(pkt_len + 2); 796 skb = dev_alloc_skb(pkt_len + 2);
@@ -842,7 +842,7 @@ memory_squeeze:
842 if (rbd != NULL && (rbd->count & 0x4000)) { 842 if (rbd != NULL && (rbd->count & 0x4000)) {
843 rbd->count = 0; 843 rbd->count = 0;
844 lp->rbd_head = rbd->v_next; 844 lp->rbd_head = rbd->v_next;
845 CHECK_WBACK_INV(rbd, sizeof(struct i596_rbd)); 845 CHECK_WBACK_INV(lp, rbd, sizeof(struct i596_rbd));
846 } 846 }
847 847
848 /* Tidy the frame descriptor, marking it as end of list */ 848 /* Tidy the frame descriptor, marking it as end of list */
@@ -860,10 +860,10 @@ memory_squeeze:
860 860
861 lp->scb.rfd = rfd->b_next; 861 lp->scb.rfd = rfd->b_next;
862 lp->rfd_head = rfd->v_next; 862 lp->rfd_head = rfd->v_next;
863 CHECK_WBACK_INV(rfd->v_prev, sizeof(struct i596_rfd)); 863 CHECK_WBACK_INV(lp, rfd->v_prev, sizeof(struct i596_rfd));
864 CHECK_WBACK_INV(rfd, sizeof(struct i596_rfd)); 864 CHECK_WBACK_INV(lp, rfd, sizeof(struct i596_rfd));
865 rfd = lp->rfd_head; 865 rfd = lp->rfd_head;
866 CHECK_INV(rfd, sizeof(struct i596_rfd)); 866 CHECK_INV(lp, rfd, sizeof(struct i596_rfd));
867 } 867 }
868 868
869 DEB(DEB_RXFRAME, printk("frames %d\n", frames)); 869 DEB(DEB_RXFRAME, printk("frames %d\n", frames));
@@ -902,12 +902,12 @@ static inline void i596_cleanup_cmd(struct net_device *dev, struct i596_private
902 ptr->v_next = NULL; 902 ptr->v_next = NULL;
903 ptr->b_next = I596_NULL; 903 ptr->b_next = I596_NULL;
904 } 904 }
905 CHECK_WBACK_INV(ptr, sizeof(struct i596_cmd)); 905 CHECK_WBACK_INV(lp, ptr, sizeof(struct i596_cmd));
906 } 906 }
907 907
908 wait_cmd(dev, lp, 100, "i596_cleanup_cmd timed out"); 908 wait_cmd(dev, lp, 100, "i596_cleanup_cmd timed out");
909 lp->scb.cmd = I596_NULL; 909 lp->scb.cmd = I596_NULL;
910 CHECK_WBACK(&(lp->scb), sizeof(struct i596_scb)); 910 CHECK_WBACK(lp, &(lp->scb), sizeof(struct i596_scb));
911} 911}
912 912
913 913
@@ -925,7 +925,7 @@ static inline void i596_reset(struct net_device *dev, struct i596_private *lp)
925 925
926 /* FIXME: this command might cause an lpmc */ 926 /* FIXME: this command might cause an lpmc */
927 lp->scb.command = CUC_ABORT | RX_ABORT; 927 lp->scb.command = CUC_ABORT | RX_ABORT;
928 CHECK_WBACK(&(lp->scb), sizeof(struct i596_scb)); 928 CHECK_WBACK(lp, &(lp->scb), sizeof(struct i596_scb));
929 CA(dev); 929 CA(dev);
930 930
931 /* wait for shutdown */ 931 /* wait for shutdown */
@@ -951,20 +951,20 @@ static void i596_add_cmd(struct net_device *dev, struct i596_cmd *cmd)
951 cmd->command |= (CMD_EOL | CMD_INTR); 951 cmd->command |= (CMD_EOL | CMD_INTR);
952 cmd->v_next = NULL; 952 cmd->v_next = NULL;
953 cmd->b_next = I596_NULL; 953 cmd->b_next = I596_NULL;
954 CHECK_WBACK(cmd, sizeof(struct i596_cmd)); 954 CHECK_WBACK(lp, cmd, sizeof(struct i596_cmd));
955 955
956 spin_lock_irqsave (&lp->lock, flags); 956 spin_lock_irqsave (&lp->lock, flags);
957 957
958 if (lp->cmd_head != NULL) { 958 if (lp->cmd_head != NULL) {
959 lp->cmd_tail->v_next = cmd; 959 lp->cmd_tail->v_next = cmd;
960 lp->cmd_tail->b_next = WSWAPcmd(virt_to_dma(lp,&cmd->status)); 960 lp->cmd_tail->b_next = WSWAPcmd(virt_to_dma(lp,&cmd->status));
961 CHECK_WBACK(lp->cmd_tail, sizeof(struct i596_cmd)); 961 CHECK_WBACK(lp, lp->cmd_tail, sizeof(struct i596_cmd));
962 } else { 962 } else {
963 lp->cmd_head = cmd; 963 lp->cmd_head = cmd;
964 wait_cmd(dev, lp, 100, "i596_add_cmd timed out"); 964 wait_cmd(dev, lp, 100, "i596_add_cmd timed out");
965 lp->scb.cmd = WSWAPcmd(virt_to_dma(lp,&cmd->status)); 965 lp->scb.cmd = WSWAPcmd(virt_to_dma(lp,&cmd->status));
966 lp->scb.command = CUC_START; 966 lp->scb.command = CUC_START;
967 CHECK_WBACK(&(lp->scb), sizeof(struct i596_scb)); 967 CHECK_WBACK(lp, &(lp->scb), sizeof(struct i596_scb));
968 CA(dev); 968 CA(dev);
969 } 969 }
970 lp->cmd_tail = cmd; 970 lp->cmd_tail = cmd;
@@ -998,12 +998,12 @@ static int i596_test(struct net_device *dev)
998 data = virt_to_dma(lp,tint); 998 data = virt_to_dma(lp,tint);
999 999
1000 tint[1] = -1; 1000 tint[1] = -1;
1001 CHECK_WBACK(tint,PAGE_SIZE); 1001 CHECK_WBACK(lp, tint, PAGE_SIZE);
1002 1002
1003 MPU_PORT(dev, 1, data); 1003 MPU_PORT(dev, 1, data);
1004 1004
1005 for(data = 1000000; data; data--) { 1005 for(data = 1000000; data; data--) {
1006 CHECK_INV(tint,PAGE_SIZE); 1006 CHECK_INV(lp, tint, PAGE_SIZE);
1007 if(tint[1] != -1) 1007 if(tint[1] != -1)
1008 break; 1008 break;
1009 1009
@@ -1061,7 +1061,7 @@ static void i596_tx_timeout (struct net_device *dev)
1061 /* Issue a channel attention signal */ 1061 /* Issue a channel attention signal */
1062 DEB(DEB_ERRORS, printk("Kicking board.\n")); 1062 DEB(DEB_ERRORS, printk("Kicking board.\n"));
1063 lp->scb.command = CUC_START | RX_START; 1063 lp->scb.command = CUC_START | RX_START;
1064 CHECK_WBACK_INV(&(lp->scb), sizeof(struct i596_scb)); 1064 CHECK_WBACK_INV(lp, &(lp->scb), sizeof(struct i596_scb));
1065 CA (dev); 1065 CA (dev);
1066 lp->last_restart = lp->stats.tx_packets; 1066 lp->last_restart = lp->stats.tx_packets;
1067 } 1067 }
@@ -1118,8 +1118,8 @@ static int i596_start_xmit(struct sk_buff *skb, struct net_device *dev)
1118 tbd->data = WSWAPchar(tx_cmd->dma_addr); 1118 tbd->data = WSWAPchar(tx_cmd->dma_addr);
1119 1119
1120 DEB(DEB_TXADDR,print_eth(skb->data, "tx-queued")); 1120 DEB(DEB_TXADDR,print_eth(skb->data, "tx-queued"));
1121 CHECK_WBACK_INV(tx_cmd, sizeof(struct tx_cmd)); 1121 CHECK_WBACK_INV(lp, tx_cmd, sizeof(struct tx_cmd));
1122 CHECK_WBACK_INV(tbd, sizeof(struct i596_tbd)); 1122 CHECK_WBACK_INV(lp, tbd, sizeof(struct i596_tbd));
1123 i596_add_cmd(dev, &tx_cmd->cmd); 1123 i596_add_cmd(dev, &tx_cmd->cmd);
1124 1124
1125 lp->stats.tx_packets++; 1125 lp->stats.tx_packets++;
@@ -1228,7 +1228,7 @@ static int __devinit i82596_probe(struct net_device *dev,
1228 lp->dma_addr = dma_addr; 1228 lp->dma_addr = dma_addr;
1229 lp->dev = gen_dev; 1229 lp->dev = gen_dev;
1230 1230
1231 CHECK_WBACK_INV(dev->mem_start, sizeof(struct i596_private)); 1231 CHECK_WBACK_INV(lp, dev->mem_start, sizeof(struct i596_private));
1232 1232
1233 i = register_netdev(dev); 1233 i = register_netdev(dev);
1234 if (i) { 1234 if (i) {
@@ -1295,7 +1295,7 @@ static irqreturn_t i596_interrupt(int irq, void *dev_id)
1295 DEB(DEB_INTS, printk("%s: i596 interrupt command unit inactive %x.\n", dev->name, status & 0x0700)); 1295 DEB(DEB_INTS, printk("%s: i596 interrupt command unit inactive %x.\n", dev->name, status & 0x0700));
1296 1296
1297 while (lp->cmd_head != NULL) { 1297 while (lp->cmd_head != NULL) {
1298 CHECK_INV(lp->cmd_head, sizeof(struct i596_cmd)); 1298 CHECK_INV(lp, lp->cmd_head, sizeof(struct i596_cmd));
1299 if (!(lp->cmd_head->status & STAT_C)) 1299 if (!(lp->cmd_head->status & STAT_C))
1300 break; 1300 break;
1301 1301
@@ -1358,7 +1358,7 @@ static irqreturn_t i596_interrupt(int irq, void *dev_id)
1358 } 1358 }
1359 ptr->v_next = NULL; 1359 ptr->v_next = NULL;
1360 ptr->b_next = I596_NULL; 1360 ptr->b_next = I596_NULL;
1361 CHECK_WBACK(ptr, sizeof(struct i596_cmd)); 1361 CHECK_WBACK(lp, ptr, sizeof(struct i596_cmd));
1362 lp->last_cmd = jiffies; 1362 lp->last_cmd = jiffies;
1363 } 1363 }
1364 1364
@@ -1372,13 +1372,13 @@ static irqreturn_t i596_interrupt(int irq, void *dev_id)
1372 1372
1373 ptr->command &= 0x1fff; 1373 ptr->command &= 0x1fff;
1374 ptr = ptr->v_next; 1374 ptr = ptr->v_next;
1375 CHECK_WBACK_INV(prev, sizeof(struct i596_cmd)); 1375 CHECK_WBACK_INV(lp, prev, sizeof(struct i596_cmd));
1376 } 1376 }
1377 1377
1378 if ((lp->cmd_head != NULL)) 1378 if ((lp->cmd_head != NULL))
1379 ack_cmd |= CUC_START; 1379 ack_cmd |= CUC_START;
1380 lp->scb.cmd = WSWAPcmd(virt_to_dma(lp,&lp->cmd_head->status)); 1380 lp->scb.cmd = WSWAPcmd(virt_to_dma(lp,&lp->cmd_head->status));
1381 CHECK_WBACK_INV(&lp->scb, sizeof(struct i596_scb)); 1381 CHECK_WBACK_INV(lp, &lp->scb, sizeof(struct i596_scb));
1382 } 1382 }
1383 if ((status & 0x1000) || (status & 0x4000)) { 1383 if ((status & 0x1000) || (status & 0x4000)) {
1384 if ((status & 0x4000)) 1384 if ((status & 0x4000))
@@ -1397,7 +1397,7 @@ static irqreturn_t i596_interrupt(int irq, void *dev_id)
1397 } 1397 }
1398 wait_cmd(dev, lp, 100, "i596 interrupt, timeout"); 1398 wait_cmd(dev, lp, 100, "i596 interrupt, timeout");
1399 lp->scb.command = ack_cmd; 1399 lp->scb.command = ack_cmd;
1400 CHECK_WBACK(&lp->scb, sizeof(struct i596_scb)); 1400 CHECK_WBACK(lp, &lp->scb, sizeof(struct i596_scb));
1401 1401
1402 /* DANGER: I suspect that some kind of interrupt 1402 /* DANGER: I suspect that some kind of interrupt
1403 acknowledgement aside from acking the 82596 might be needed 1403 acknowledgement aside from acking the 82596 might be needed
@@ -1426,7 +1426,7 @@ static int i596_close(struct net_device *dev)
1426 1426
1427 wait_cmd(dev, lp, 100, "close1 timed out"); 1427 wait_cmd(dev, lp, 100, "close1 timed out");
1428 lp->scb.command = CUC_ABORT | RX_ABORT; 1428 lp->scb.command = CUC_ABORT | RX_ABORT;
1429 CHECK_WBACK(&lp->scb, sizeof(struct i596_scb)); 1429 CHECK_WBACK(lp, &lp->scb, sizeof(struct i596_scb));
1430 1430
1431 CA(dev); 1431 CA(dev);
1432 1432
@@ -1486,7 +1486,7 @@ static void set_multicast_list(struct net_device *dev)
1486 dev->name); 1486 dev->name);
1487 else { 1487 else {
1488 lp->cf_cmd.cmd.command = CmdConfigure; 1488 lp->cf_cmd.cmd.command = CmdConfigure;
1489 CHECK_WBACK_INV(&lp->cf_cmd, sizeof(struct cf_cmd)); 1489 CHECK_WBACK_INV(lp, &lp->cf_cmd, sizeof(struct cf_cmd));
1490 i596_add_cmd(dev, &lp->cf_cmd.cmd); 1490 i596_add_cmd(dev, &lp->cf_cmd.cmd);
1491 } 1491 }
1492 } 1492 }
@@ -1514,7 +1514,7 @@ static void set_multicast_list(struct net_device *dev)
1514 DEB(DEB_MULTI, printk("%s: Adding address %02x:%02x:%02x:%02x:%02x:%02x\n", 1514 DEB(DEB_MULTI, printk("%s: Adding address %02x:%02x:%02x:%02x:%02x:%02x\n",
1515 dev->name, cp[0],cp[1],cp[2],cp[3],cp[4],cp[5])); 1515 dev->name, cp[0],cp[1],cp[2],cp[3],cp[4],cp[5]));
1516 } 1516 }
1517 CHECK_WBACK_INV(&lp->mc_cmd, sizeof(struct mc_cmd)); 1517 CHECK_WBACK_INV(lp, &lp->mc_cmd, sizeof(struct mc_cmd));
1518 i596_add_cmd(dev, &cmd->cmd); 1518 i596_add_cmd(dev, &cmd->cmd);
1519 } 1519 }
1520} 1520}
diff --git a/drivers/net/lib8390.c b/drivers/net/lib8390.c
new file mode 100644
index 000000000000..e726c06b8dc6
--- /dev/null
+++ b/drivers/net/lib8390.c
@@ -0,0 +1,1097 @@
1/* 8390.c: A general NS8390 ethernet driver core for linux. */
2/*
3 Written 1992-94 by Donald Becker.
4
5 Copyright 1993 United States Government as represented by the
6 Director, National Security Agency.
7
8 This software may be used and distributed according to the terms
9 of the GNU General Public License, incorporated herein by reference.
10
11 The author may be reached as becker@scyld.com, or C/O
12 Scyld Computing Corporation
13 410 Severn Ave., Suite 210
14 Annapolis MD 21403
15
16
17 This is the chip-specific code for many 8390-based ethernet adaptors.
18 This is not a complete driver, it must be combined with board-specific
19 code such as ne.c, wd.c, 3c503.c, etc.
20
21 Seeing how at least eight drivers use this code, (not counting the
22 PCMCIA ones either) it is easy to break some card by what seems like
23 a simple innocent change. Please contact me or Donald if you think
24 you have found something that needs changing. -- PG
25
26
27 Changelog:
28
29 Paul Gortmaker : remove set_bit lock, other cleanups.
30 Paul Gortmaker : add ei_get_8390_hdr() so we can pass skb's to
31 ei_block_input() for eth_io_copy_and_sum().
32 Paul Gortmaker : exchange static int ei_pingpong for a #define,
33 also add better Tx error handling.
34 Paul Gortmaker : rewrite Rx overrun handling as per NS specs.
35 Alexey Kuznetsov : use the 8390's six bit hash multicast filter.
36 Paul Gortmaker : tweak ANK's above multicast changes a bit.
37 Paul Gortmaker : update packet statistics for v2.1.x
38 Alan Cox : support arbitary stupid port mappings on the
39 68K Macintosh. Support >16bit I/O spaces
40 Paul Gortmaker : add kmod support for auto-loading of the 8390
41 module by all drivers that require it.
42 Alan Cox : Spinlocking work, added 'BUG_83C690'
43 Paul Gortmaker : Separate out Tx timeout code from Tx path.
44 Paul Gortmaker : Remove old unused single Tx buffer code.
45 Hayato Fujiwara : Add m32r support.
46 Paul Gortmaker : use skb_padto() instead of stack scratch area
47
48 Sources:
49 The National Semiconductor LAN Databook, and the 3Com 3c503 databook.
50
51 */
52
53#include <linux/module.h>
54#include <linux/kernel.h>
55#include <linux/jiffies.h>
56#include <linux/fs.h>
57#include <linux/types.h>
58#include <linux/string.h>
59#include <linux/bitops.h>
60#include <asm/system.h>
61#include <asm/uaccess.h>
62#include <asm/io.h>
63#include <asm/irq.h>
64#include <linux/delay.h>
65#include <linux/errno.h>
66#include <linux/fcntl.h>
67#include <linux/in.h>
68#include <linux/interrupt.h>
69#include <linux/init.h>
70#include <linux/crc32.h>
71
72#include <linux/netdevice.h>
73#include <linux/etherdevice.h>
74
75#define NS8390_CORE
76#include "8390.h"
77
78#define BUG_83C690
79
80/* These are the operational function interfaces to board-specific
81 routines.
82 void reset_8390(struct net_device *dev)
83 Resets the board associated with DEV, including a hardware reset of
84 the 8390. This is only called when there is a transmit timeout, and
85 it is always followed by 8390_init().
86 void block_output(struct net_device *dev, int count, const unsigned char *buf,
87 int start_page)
88 Write the COUNT bytes of BUF to the packet buffer at START_PAGE. The
89 "page" value uses the 8390's 256-byte pages.
90 void get_8390_hdr(struct net_device *dev, struct e8390_hdr *hdr, int ring_page)
91 Read the 4 byte, page aligned 8390 header. *If* there is a
92 subsequent read, it will be of the rest of the packet.
93 void block_input(struct net_device *dev, int count, struct sk_buff *skb, int ring_offset)
94 Read COUNT bytes from the packet buffer into the skb data area. Start
95 reading from RING_OFFSET, the address as the 8390 sees it. This will always
96 follow the read of the 8390 header.
97*/
98#define ei_reset_8390 (ei_local->reset_8390)
99#define ei_block_output (ei_local->block_output)
100#define ei_block_input (ei_local->block_input)
101#define ei_get_8390_hdr (ei_local->get_8390_hdr)
102
103/* use 0 for production, 1 for verification, >2 for debug */
104#ifndef ei_debug
105int ei_debug = 1;
106#endif
107
108/* Index to functions. */
109static void ei_tx_intr(struct net_device *dev);
110static void ei_tx_err(struct net_device *dev);
111static void ei_tx_timeout(struct net_device *dev);
112static void ei_receive(struct net_device *dev);
113static void ei_rx_overrun(struct net_device *dev);
114
115/* Routines generic to NS8390-based boards. */
116static void NS8390_trigger_send(struct net_device *dev, unsigned int length,
117 int start_page);
118static void set_multicast_list(struct net_device *dev);
119static void do_set_multicast_list(struct net_device *dev);
120static void __NS8390_init(struct net_device *dev, int startp);
121
122/*
123 * SMP and the 8390 setup.
124 *
125 * The 8390 isnt exactly designed to be multithreaded on RX/TX. There is
126 * a page register that controls bank and packet buffer access. We guard
127 * this with ei_local->page_lock. Nobody should assume or set the page other
128 * than zero when the lock is not held. Lock holders must restore page 0
129 * before unlocking. Even pure readers must take the lock to protect in
130 * page 0.
131 *
132 * To make life difficult the chip can also be very slow. We therefore can't
133 * just use spinlocks. For the longer lockups we disable the irq the device
134 * sits on and hold the lock. We must hold the lock because there is a dual
135 * processor case other than interrupts (get stats/set multicast list in
136 * parallel with each other and transmit).
137 *
138 * Note: in theory we can just disable the irq on the card _but_ there is
139 * a latency on SMP irq delivery. So we can easily go "disable irq" "sync irqs"
140 * enter lock, take the queued irq. So we waddle instead of flying.
141 *
142 * Finally by special arrangement for the purpose of being generally
143 * annoying the transmit function is called bh atomic. That places
144 * restrictions on the user context callers as disable_irq won't save
145 * them.
146 */
147
148
149
150/**
151 * ei_open - Open/initialize the board.
152 * @dev: network device to initialize
153 *
154 * This routine goes all-out, setting everything
155 * up anew at each open, even though many of these registers should only
156 * need to be set once at boot.
157 */
158static int __ei_open(struct net_device *dev)
159{
160 unsigned long flags;
161 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
162
163 /* The card I/O part of the driver (e.g. 3c503) can hook a Tx timeout
164 wrapper that does e.g. media check & then calls ei_tx_timeout. */
165 if (dev->tx_timeout == NULL)
166 dev->tx_timeout = ei_tx_timeout;
167 if (dev->watchdog_timeo <= 0)
168 dev->watchdog_timeo = TX_TIMEOUT;
169
170 /*
171 * Grab the page lock so we own the register set, then call
172 * the init function.
173 */
174
175 spin_lock_irqsave(&ei_local->page_lock, flags);
176 __NS8390_init(dev, 1);
177 /* Set the flag before we drop the lock, That way the IRQ arrives
178 after its set and we get no silly warnings */
179 netif_start_queue(dev);
180 spin_unlock_irqrestore(&ei_local->page_lock, flags);
181 ei_local->irqlock = 0;
182 return 0;
183}
184
185/**
186 * ei_close - shut down network device
187 * @dev: network device to close
188 *
189 * Opposite of ei_open(). Only used when "ifconfig <devname> down" is done.
190 */
191static int __ei_close(struct net_device *dev)
192{
193 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
194 unsigned long flags;
195
196 /*
197 * Hold the page lock during close
198 */
199
200 spin_lock_irqsave(&ei_local->page_lock, flags);
201 __NS8390_init(dev, 0);
202 spin_unlock_irqrestore(&ei_local->page_lock, flags);
203 netif_stop_queue(dev);
204 return 0;
205}
206
207/**
208 * ei_tx_timeout - handle transmit time out condition
209 * @dev: network device which has apparently fallen asleep
210 *
211 * Called by kernel when device never acknowledges a transmit has
212 * completed (or failed) - i.e. never posted a Tx related interrupt.
213 */
214
215static void ei_tx_timeout(struct net_device *dev)
216{
217 unsigned long e8390_base = dev->base_addr;
218 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
219 int txsr, isr, tickssofar = jiffies - dev->trans_start;
220 unsigned long flags;
221
222#if defined(CONFIG_M32R) && defined(CONFIG_SMP)
223 unsigned long icucr;
224
225 local_irq_save(flags);
226 icucr = inl(M32R_ICU_CR1_PORTL);
227 icucr |= M32R_ICUCR_ISMOD11;
228 outl(icucr, M32R_ICU_CR1_PORTL);
229 local_irq_restore(flags);
230#endif
231 ei_local->stat.tx_errors++;
232
233 spin_lock_irqsave(&ei_local->page_lock, flags);
234 txsr = ei_inb(e8390_base+EN0_TSR);
235 isr = ei_inb(e8390_base+EN0_ISR);
236 spin_unlock_irqrestore(&ei_local->page_lock, flags);
237
238 printk(KERN_DEBUG "%s: Tx timed out, %s TSR=%#2x, ISR=%#2x, t=%d.\n",
239 dev->name, (txsr & ENTSR_ABT) ? "excess collisions." :
240 (isr) ? "lost interrupt?" : "cable problem?", txsr, isr, tickssofar);
241
242 if (!isr && !ei_local->stat.tx_packets)
243 {
244 /* The 8390 probably hasn't gotten on the cable yet. */
245 ei_local->interface_num ^= 1; /* Try a different xcvr. */
246 }
247
248 /* Ugly but a reset can be slow, yet must be protected */
249
250 disable_irq_nosync_lockdep(dev->irq);
251 spin_lock(&ei_local->page_lock);
252
253 /* Try to restart the card. Perhaps the user has fixed something. */
254 ei_reset_8390(dev);
255 __NS8390_init(dev, 1);
256
257 spin_unlock(&ei_local->page_lock);
258 enable_irq_lockdep(dev->irq);
259 netif_wake_queue(dev);
260}
261
262/**
263 * ei_start_xmit - begin packet transmission
264 * @skb: packet to be sent
265 * @dev: network device to which packet is sent
266 *
267 * Sends a packet to an 8390 network device.
268 */
269
270static int ei_start_xmit(struct sk_buff *skb, struct net_device *dev)
271{
272 unsigned long e8390_base = dev->base_addr;
273 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
274 int send_length = skb->len, output_page;
275 unsigned long flags;
276 char buf[ETH_ZLEN];
277 char *data = skb->data;
278
279 if (skb->len < ETH_ZLEN) {
280 memset(buf, 0, ETH_ZLEN); /* more efficient than doing just the needed bits */
281 memcpy(buf, data, skb->len);
282 send_length = ETH_ZLEN;
283 data = buf;
284 }
285
286 /* Mask interrupts from the ethercard.
287 SMP: We have to grab the lock here otherwise the IRQ handler
288 on another CPU can flip window and race the IRQ mask set. We end
289 up trashing the mcast filter not disabling irqs if we don't lock */
290
291 spin_lock_irqsave(&ei_local->page_lock, flags);
292 ei_outb_p(0x00, e8390_base + EN0_IMR);
293 spin_unlock_irqrestore(&ei_local->page_lock, flags);
294
295
296 /*
297 * Slow phase with lock held.
298 */
299
300 disable_irq_nosync_lockdep_irqsave(dev->irq, &flags);
301
302 spin_lock(&ei_local->page_lock);
303
304 ei_local->irqlock = 1;
305
306 /*
307 * We have two Tx slots available for use. Find the first free
308 * slot, and then perform some sanity checks. With two Tx bufs,
309 * you get very close to transmitting back-to-back packets. With
310 * only one Tx buf, the transmitter sits idle while you reload the
311 * card, leaving a substantial gap between each transmitted packet.
312 */
313
314 if (ei_local->tx1 == 0)
315 {
316 output_page = ei_local->tx_start_page;
317 ei_local->tx1 = send_length;
318 if (ei_debug && ei_local->tx2 > 0)
319 printk(KERN_DEBUG "%s: idle transmitter tx2=%d, lasttx=%d, txing=%d.\n",
320 dev->name, ei_local->tx2, ei_local->lasttx, ei_local->txing);
321 }
322 else if (ei_local->tx2 == 0)
323 {
324 output_page = ei_local->tx_start_page + TX_PAGES/2;
325 ei_local->tx2 = send_length;
326 if (ei_debug && ei_local->tx1 > 0)
327 printk(KERN_DEBUG "%s: idle transmitter, tx1=%d, lasttx=%d, txing=%d.\n",
328 dev->name, ei_local->tx1, ei_local->lasttx, ei_local->txing);
329 }
330 else
331 { /* We should never get here. */
332 if (ei_debug)
333 printk(KERN_DEBUG "%s: No Tx buffers free! tx1=%d tx2=%d last=%d\n",
334 dev->name, ei_local->tx1, ei_local->tx2, ei_local->lasttx);
335 ei_local->irqlock = 0;
336 netif_stop_queue(dev);
337 ei_outb_p(ENISR_ALL, e8390_base + EN0_IMR);
338 spin_unlock(&ei_local->page_lock);
339 enable_irq_lockdep_irqrestore(dev->irq, &flags);
340 ei_local->stat.tx_errors++;
341 return 1;
342 }
343
344 /*
345 * Okay, now upload the packet and trigger a send if the transmitter
346 * isn't already sending. If it is busy, the interrupt handler will
347 * trigger the send later, upon receiving a Tx done interrupt.
348 */
349
350 ei_block_output(dev, send_length, data, output_page);
351
352 if (! ei_local->txing)
353 {
354 ei_local->txing = 1;
355 NS8390_trigger_send(dev, send_length, output_page);
356 dev->trans_start = jiffies;
357 if (output_page == ei_local->tx_start_page)
358 {
359 ei_local->tx1 = -1;
360 ei_local->lasttx = -1;
361 }
362 else
363 {
364 ei_local->tx2 = -1;
365 ei_local->lasttx = -2;
366 }
367 }
368 else ei_local->txqueue++;
369
370 if (ei_local->tx1 && ei_local->tx2)
371 netif_stop_queue(dev);
372 else
373 netif_start_queue(dev);
374
375 /* Turn 8390 interrupts back on. */
376 ei_local->irqlock = 0;
377 ei_outb_p(ENISR_ALL, e8390_base + EN0_IMR);
378
379 spin_unlock(&ei_local->page_lock);
380 enable_irq_lockdep_irqrestore(dev->irq, &flags);
381
382 dev_kfree_skb (skb);
383 ei_local->stat.tx_bytes += send_length;
384
385 return 0;
386}
387
388/**
389 * ei_interrupt - handle the interrupts from an 8390
390 * @irq: interrupt number
391 * @dev_id: a pointer to the net_device
392 *
393 * Handle the ether interface interrupts. We pull packets from
394 * the 8390 via the card specific functions and fire them at the networking
395 * stack. We also handle transmit completions and wake the transmit path if
396 * necessary. We also update the counters and do other housekeeping as
397 * needed.
398 */
399
400static irqreturn_t __ei_interrupt(int irq, void *dev_id)
401{
402 struct net_device *dev = dev_id;
403 unsigned long e8390_base = dev->base_addr;
404 int interrupts, nr_serviced = 0;
405 struct ei_device *ei_local = netdev_priv(dev);
406
407 /*
408 * Protect the irq test too.
409 */
410
411 spin_lock(&ei_local->page_lock);
412
413 if (ei_local->irqlock)
414 {
415#if 1 /* This might just be an interrupt for a PCI device sharing this line */
416 /* The "irqlock" check is only for testing. */
417 printk(ei_local->irqlock
418 ? "%s: Interrupted while interrupts are masked! isr=%#2x imr=%#2x.\n"
419 : "%s: Reentering the interrupt handler! isr=%#2x imr=%#2x.\n",
420 dev->name, ei_inb_p(e8390_base + EN0_ISR),
421 ei_inb_p(e8390_base + EN0_IMR));
422#endif
423 spin_unlock(&ei_local->page_lock);
424 return IRQ_NONE;
425 }
426
427 /* Change to page 0 and read the intr status reg. */
428 ei_outb_p(E8390_NODMA+E8390_PAGE0, e8390_base + E8390_CMD);
429 if (ei_debug > 3)
430 printk(KERN_DEBUG "%s: interrupt(isr=%#2.2x).\n", dev->name,
431 ei_inb_p(e8390_base + EN0_ISR));
432
433 /* !!Assumption!! -- we stay in page 0. Don't break this. */
434 while ((interrupts = ei_inb_p(e8390_base + EN0_ISR)) != 0
435 && ++nr_serviced < MAX_SERVICE)
436 {
437 if (!netif_running(dev)) {
438 printk(KERN_WARNING "%s: interrupt from stopped card\n", dev->name);
439 /* rmk - acknowledge the interrupts */
440 ei_outb_p(interrupts, e8390_base + EN0_ISR);
441 interrupts = 0;
442 break;
443 }
444 if (interrupts & ENISR_OVER)
445 ei_rx_overrun(dev);
446 else if (interrupts & (ENISR_RX+ENISR_RX_ERR))
447 {
448 /* Got a good (?) packet. */
449 ei_receive(dev);
450 }
451 /* Push the next to-transmit packet through. */
452 if (interrupts & ENISR_TX)
453 ei_tx_intr(dev);
454 else if (interrupts & ENISR_TX_ERR)
455 ei_tx_err(dev);
456
457 if (interrupts & ENISR_COUNTERS)
458 {
459 ei_local->stat.rx_frame_errors += ei_inb_p(e8390_base + EN0_COUNTER0);
460 ei_local->stat.rx_crc_errors += ei_inb_p(e8390_base + EN0_COUNTER1);
461 ei_local->stat.rx_missed_errors+= ei_inb_p(e8390_base + EN0_COUNTER2);
462 ei_outb_p(ENISR_COUNTERS, e8390_base + EN0_ISR); /* Ack intr. */
463 }
464
465 /* Ignore any RDC interrupts that make it back to here. */
466 if (interrupts & ENISR_RDC)
467 {
468 ei_outb_p(ENISR_RDC, e8390_base + EN0_ISR);
469 }
470
471 ei_outb_p(E8390_NODMA+E8390_PAGE0+E8390_START, e8390_base + E8390_CMD);
472 }
473
474 if (interrupts && ei_debug)
475 {
476 ei_outb_p(E8390_NODMA+E8390_PAGE0+E8390_START, e8390_base + E8390_CMD);
477 if (nr_serviced >= MAX_SERVICE)
478 {
479 /* 0xFF is valid for a card removal */
480 if(interrupts!=0xFF)
481 printk(KERN_WARNING "%s: Too much work at interrupt, status %#2.2x\n",
482 dev->name, interrupts);
483 ei_outb_p(ENISR_ALL, e8390_base + EN0_ISR); /* Ack. most intrs. */
484 } else {
485 printk(KERN_WARNING "%s: unknown interrupt %#2x\n", dev->name, interrupts);
486 ei_outb_p(0xff, e8390_base + EN0_ISR); /* Ack. all intrs. */
487 }
488 }
489 spin_unlock(&ei_local->page_lock);
490 return IRQ_RETVAL(nr_serviced > 0);
491}
492
493#ifdef CONFIG_NET_POLL_CONTROLLER
494static void __ei_poll(struct net_device *dev)
495{
496 disable_irq_lockdep(dev->irq);
497 __ei_interrupt(dev->irq, dev);
498 enable_irq_lockdep(dev->irq);
499}
500#endif
501
502/**
503 * ei_tx_err - handle transmitter error
504 * @dev: network device which threw the exception
505 *
506 * A transmitter error has happened. Most likely excess collisions (which
507 * is a fairly normal condition). If the error is one where the Tx will
508 * have been aborted, we try and send another one right away, instead of
509 * letting the failed packet sit and collect dust in the Tx buffer. This
510 * is a much better solution as it avoids kernel based Tx timeouts, and
511 * an unnecessary card reset.
512 *
513 * Called with lock held.
514 */
515
516static void ei_tx_err(struct net_device *dev)
517{
518 unsigned long e8390_base = dev->base_addr;
519 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
520 unsigned char txsr = ei_inb_p(e8390_base+EN0_TSR);
521 unsigned char tx_was_aborted = txsr & (ENTSR_ABT+ENTSR_FU);
522
523#ifdef VERBOSE_ERROR_DUMP
524 printk(KERN_DEBUG "%s: transmitter error (%#2x): ", dev->name, txsr);
525 if (txsr & ENTSR_ABT)
526 printk("excess-collisions ");
527 if (txsr & ENTSR_ND)
528 printk("non-deferral ");
529 if (txsr & ENTSR_CRS)
530 printk("lost-carrier ");
531 if (txsr & ENTSR_FU)
532 printk("FIFO-underrun ");
533 if (txsr & ENTSR_CDH)
534 printk("lost-heartbeat ");
535 printk("\n");
536#endif
537
538 ei_outb_p(ENISR_TX_ERR, e8390_base + EN0_ISR); /* Ack intr. */
539
540 if (tx_was_aborted)
541 ei_tx_intr(dev);
542 else
543 {
544 ei_local->stat.tx_errors++;
545 if (txsr & ENTSR_CRS) ei_local->stat.tx_carrier_errors++;
546 if (txsr & ENTSR_CDH) ei_local->stat.tx_heartbeat_errors++;
547 if (txsr & ENTSR_OWC) ei_local->stat.tx_window_errors++;
548 }
549}
550
551/**
552 * ei_tx_intr - transmit interrupt handler
553 * @dev: network device for which tx intr is handled
554 *
555 * We have finished a transmit: check for errors and then trigger the next
556 * packet to be sent. Called with lock held.
557 */
558
559static void ei_tx_intr(struct net_device *dev)
560{
561 unsigned long e8390_base = dev->base_addr;
562 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
563 int status = ei_inb(e8390_base + EN0_TSR);
564
565 ei_outb_p(ENISR_TX, e8390_base + EN0_ISR); /* Ack intr. */
566
567 /*
568 * There are two Tx buffers, see which one finished, and trigger
569 * the send of another one if it exists.
570 */
571 ei_local->txqueue--;
572
573 if (ei_local->tx1 < 0)
574 {
575 if (ei_local->lasttx != 1 && ei_local->lasttx != -1)
576 printk(KERN_ERR "%s: bogus last_tx_buffer %d, tx1=%d.\n",
577 ei_local->name, ei_local->lasttx, ei_local->tx1);
578 ei_local->tx1 = 0;
579 if (ei_local->tx2 > 0)
580 {
581 ei_local->txing = 1;
582 NS8390_trigger_send(dev, ei_local->tx2, ei_local->tx_start_page + 6);
583 dev->trans_start = jiffies;
584 ei_local->tx2 = -1,
585 ei_local->lasttx = 2;
586 }
587 else ei_local->lasttx = 20, ei_local->txing = 0;
588 }
589 else if (ei_local->tx2 < 0)
590 {
591 if (ei_local->lasttx != 2 && ei_local->lasttx != -2)
592 printk("%s: bogus last_tx_buffer %d, tx2=%d.\n",
593 ei_local->name, ei_local->lasttx, ei_local->tx2);
594 ei_local->tx2 = 0;
595 if (ei_local->tx1 > 0)
596 {
597 ei_local->txing = 1;
598 NS8390_trigger_send(dev, ei_local->tx1, ei_local->tx_start_page);
599 dev->trans_start = jiffies;
600 ei_local->tx1 = -1;
601 ei_local->lasttx = 1;
602 }
603 else
604 ei_local->lasttx = 10, ei_local->txing = 0;
605 }
606// else printk(KERN_WARNING "%s: unexpected TX-done interrupt, lasttx=%d.\n",
607// dev->name, ei_local->lasttx);
608
609 /* Minimize Tx latency: update the statistics after we restart TXing. */
610 if (status & ENTSR_COL)
611 ei_local->stat.collisions++;
612 if (status & ENTSR_PTX)
613 ei_local->stat.tx_packets++;
614 else
615 {
616 ei_local->stat.tx_errors++;
617 if (status & ENTSR_ABT)
618 {
619 ei_local->stat.tx_aborted_errors++;
620 ei_local->stat.collisions += 16;
621 }
622 if (status & ENTSR_CRS)
623 ei_local->stat.tx_carrier_errors++;
624 if (status & ENTSR_FU)
625 ei_local->stat.tx_fifo_errors++;
626 if (status & ENTSR_CDH)
627 ei_local->stat.tx_heartbeat_errors++;
628 if (status & ENTSR_OWC)
629 ei_local->stat.tx_window_errors++;
630 }
631 netif_wake_queue(dev);
632}
633
634/**
635 * ei_receive - receive some packets
636 * @dev: network device with which receive will be run
637 *
638 * We have a good packet(s), get it/them out of the buffers.
639 * Called with lock held.
640 */
641
642static void ei_receive(struct net_device *dev)
643{
644 unsigned long e8390_base = dev->base_addr;
645 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
646 unsigned char rxing_page, this_frame, next_frame;
647 unsigned short current_offset;
648 int rx_pkt_count = 0;
649 struct e8390_pkt_hdr rx_frame;
650 int num_rx_pages = ei_local->stop_page-ei_local->rx_start_page;
651
652 while (++rx_pkt_count < 10)
653 {
654 int pkt_len, pkt_stat;
655
656 /* Get the rx page (incoming packet pointer). */
657 ei_outb_p(E8390_NODMA+E8390_PAGE1, e8390_base + E8390_CMD);
658 rxing_page = ei_inb_p(e8390_base + EN1_CURPAG);
659 ei_outb_p(E8390_NODMA+E8390_PAGE0, e8390_base + E8390_CMD);
660
661 /* Remove one frame from the ring. Boundary is always a page behind. */
662 this_frame = ei_inb_p(e8390_base + EN0_BOUNDARY) + 1;
663 if (this_frame >= ei_local->stop_page)
664 this_frame = ei_local->rx_start_page;
665
666 /* Someday we'll omit the previous, iff we never get this message.
667 (There is at least one clone claimed to have a problem.)
668
669 Keep quiet if it looks like a card removal. One problem here
670 is that some clones crash in roughly the same way.
671 */
672 if (ei_debug > 0 && this_frame != ei_local->current_page && (this_frame!=0x0 || rxing_page!=0xFF))
673 printk(KERN_ERR "%s: mismatched read page pointers %2x vs %2x.\n",
674 dev->name, this_frame, ei_local->current_page);
675
676 if (this_frame == rxing_page) /* Read all the frames? */
677 break; /* Done for now */
678
679 current_offset = this_frame << 8;
680 ei_get_8390_hdr(dev, &rx_frame, this_frame);
681
682 pkt_len = rx_frame.count - sizeof(struct e8390_pkt_hdr);
683 pkt_stat = rx_frame.status;
684
685 next_frame = this_frame + 1 + ((pkt_len+4)>>8);
686
687 /* Check for bogosity warned by 3c503 book: the status byte is never
688 written. This happened a lot during testing! This code should be
689 cleaned up someday. */
690 if (rx_frame.next != next_frame
691 && rx_frame.next != next_frame + 1
692 && rx_frame.next != next_frame - num_rx_pages
693 && rx_frame.next != next_frame + 1 - num_rx_pages) {
694 ei_local->current_page = rxing_page;
695 ei_outb(ei_local->current_page-1, e8390_base+EN0_BOUNDARY);
696 ei_local->stat.rx_errors++;
697 continue;
698 }
699
700 if (pkt_len < 60 || pkt_len > 1518)
701 {
702 if (ei_debug)
703 printk(KERN_DEBUG "%s: bogus packet size: %d, status=%#2x nxpg=%#2x.\n",
704 dev->name, rx_frame.count, rx_frame.status,
705 rx_frame.next);
706 ei_local->stat.rx_errors++;
707 ei_local->stat.rx_length_errors++;
708 }
709 else if ((pkt_stat & 0x0F) == ENRSR_RXOK)
710 {
711 struct sk_buff *skb;
712
713 skb = dev_alloc_skb(pkt_len+2);
714 if (skb == NULL)
715 {
716 if (ei_debug > 1)
717 printk(KERN_DEBUG "%s: Couldn't allocate a sk_buff of size %d.\n",
718 dev->name, pkt_len);
719 ei_local->stat.rx_dropped++;
720 break;
721 }
722 else
723 {
724 skb_reserve(skb,2); /* IP headers on 16 byte boundaries */
725 skb->dev = dev;
726 skb_put(skb, pkt_len); /* Make room */
727 ei_block_input(dev, pkt_len, skb, current_offset + sizeof(rx_frame));
728 skb->protocol=eth_type_trans(skb,dev);
729 netif_rx(skb);
730 dev->last_rx = jiffies;
731 ei_local->stat.rx_packets++;
732 ei_local->stat.rx_bytes += pkt_len;
733 if (pkt_stat & ENRSR_PHY)
734 ei_local->stat.multicast++;
735 }
736 }
737 else
738 {
739 if (ei_debug)
740 printk(KERN_DEBUG "%s: bogus packet: status=%#2x nxpg=%#2x size=%d\n",
741 dev->name, rx_frame.status, rx_frame.next,
742 rx_frame.count);
743 ei_local->stat.rx_errors++;
744 /* NB: The NIC counts CRC, frame and missed errors. */
745 if (pkt_stat & ENRSR_FO)
746 ei_local->stat.rx_fifo_errors++;
747 }
748 next_frame = rx_frame.next;
749
750 /* This _should_ never happen: it's here for avoiding bad clones. */
751 if (next_frame >= ei_local->stop_page) {
752 printk("%s: next frame inconsistency, %#2x\n", dev->name,
753 next_frame);
754 next_frame = ei_local->rx_start_page;
755 }
756 ei_local->current_page = next_frame;
757 ei_outb_p(next_frame-1, e8390_base+EN0_BOUNDARY);
758 }
759
760 /* We used to also ack ENISR_OVER here, but that would sometimes mask
761 a real overrun, leaving the 8390 in a stopped state with rec'vr off. */
762 ei_outb_p(ENISR_RX+ENISR_RX_ERR, e8390_base+EN0_ISR);
763 return;
764}
765
766/**
767 * ei_rx_overrun - handle receiver overrun
768 * @dev: network device which threw exception
769 *
770 * We have a receiver overrun: we have to kick the 8390 to get it started
771 * again. Problem is that you have to kick it exactly as NS prescribes in
772 * the updated datasheets, or "the NIC may act in an unpredictable manner."
773 * This includes causing "the NIC to defer indefinitely when it is stopped
774 * on a busy network." Ugh.
775 * Called with lock held. Don't call this with the interrupts off or your
776 * computer will hate you - it takes 10ms or so.
777 */
778
779static void ei_rx_overrun(struct net_device *dev)
780{
781 unsigned long e8390_base = dev->base_addr;
782 unsigned char was_txing, must_resend = 0;
783 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
784
785 /*
786 * Record whether a Tx was in progress and then issue the
787 * stop command.
788 */
789 was_txing = ei_inb_p(e8390_base+E8390_CMD) & E8390_TRANS;
790 ei_outb_p(E8390_NODMA+E8390_PAGE0+E8390_STOP, e8390_base+E8390_CMD);
791
792 if (ei_debug > 1)
793 printk(KERN_DEBUG "%s: Receiver overrun.\n", dev->name);
794 ei_local->stat.rx_over_errors++;
795
796 /*
797 * Wait a full Tx time (1.2ms) + some guard time, NS says 1.6ms total.
798 * Early datasheets said to poll the reset bit, but now they say that
799 * it "is not a reliable indicator and subsequently should be ignored."
800 * We wait at least 10ms.
801 */
802
803 mdelay(10);
804
805 /*
806 * Reset RBCR[01] back to zero as per magic incantation.
807 */
808 ei_outb_p(0x00, e8390_base+EN0_RCNTLO);
809 ei_outb_p(0x00, e8390_base+EN0_RCNTHI);
810
811 /*
812 * See if any Tx was interrupted or not. According to NS, this
813 * step is vital, and skipping it will cause no end of havoc.
814 */
815
816 if (was_txing)
817 {
818 unsigned char tx_completed = ei_inb_p(e8390_base+EN0_ISR) & (ENISR_TX+ENISR_TX_ERR);
819 if (!tx_completed)
820 must_resend = 1;
821 }
822
823 /*
824 * Have to enter loopback mode and then restart the NIC before
825 * you are allowed to slurp packets up off the ring.
826 */
827 ei_outb_p(E8390_TXOFF, e8390_base + EN0_TXCR);
828 ei_outb_p(E8390_NODMA + E8390_PAGE0 + E8390_START, e8390_base + E8390_CMD);
829
830 /*
831 * Clear the Rx ring of all the debris, and ack the interrupt.
832 */
833 ei_receive(dev);
834 ei_outb_p(ENISR_OVER, e8390_base+EN0_ISR);
835
836 /*
837 * Leave loopback mode, and resend any packet that got stopped.
838 */
839 ei_outb_p(E8390_TXCONFIG, e8390_base + EN0_TXCR);
840 if (must_resend)
841 ei_outb_p(E8390_NODMA + E8390_PAGE0 + E8390_START + E8390_TRANS, e8390_base + E8390_CMD);
842}
843
844/*
845 * Collect the stats. This is called unlocked and from several contexts.
846 */
847
848static struct net_device_stats *get_stats(struct net_device *dev)
849{
850 unsigned long ioaddr = dev->base_addr;
851 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
852 unsigned long flags;
853
854 /* If the card is stopped, just return the present stats. */
855 if (!netif_running(dev))
856 return &ei_local->stat;
857
858 spin_lock_irqsave(&ei_local->page_lock,flags);
859 /* Read the counter registers, assuming we are in page 0. */
860 ei_local->stat.rx_frame_errors += ei_inb_p(ioaddr + EN0_COUNTER0);
861 ei_local->stat.rx_crc_errors += ei_inb_p(ioaddr + EN0_COUNTER1);
862 ei_local->stat.rx_missed_errors+= ei_inb_p(ioaddr + EN0_COUNTER2);
863 spin_unlock_irqrestore(&ei_local->page_lock, flags);
864
865 return &ei_local->stat;
866}
867
868/*
869 * Form the 64 bit 8390 multicast table from the linked list of addresses
870 * associated with this dev structure.
871 */
872
873static inline void make_mc_bits(u8 *bits, struct net_device *dev)
874{
875 struct dev_mc_list *dmi;
876
877 for (dmi=dev->mc_list; dmi; dmi=dmi->next)
878 {
879 u32 crc;
880 if (dmi->dmi_addrlen != ETH_ALEN)
881 {
882 printk(KERN_INFO "%s: invalid multicast address length given.\n", dev->name);
883 continue;
884 }
885 crc = ether_crc(ETH_ALEN, dmi->dmi_addr);
886 /*
887 * The 8390 uses the 6 most significant bits of the
888 * CRC to index the multicast table.
889 */
890 bits[crc>>29] |= (1<<((crc>>26)&7));
891 }
892}
893
894/**
895 * do_set_multicast_list - set/clear multicast filter
896 * @dev: net device for which multicast filter is adjusted
897 *
898 * Set or clear the multicast filter for this adaptor. May be called
899 * from a BH in 2.1.x. Must be called with lock held.
900 */
901
902static void do_set_multicast_list(struct net_device *dev)
903{
904 unsigned long e8390_base = dev->base_addr;
905 int i;
906 struct ei_device *ei_local = (struct ei_device*)netdev_priv(dev);
907
908 if (!(dev->flags&(IFF_PROMISC|IFF_ALLMULTI)))
909 {
910 memset(ei_local->mcfilter, 0, 8);
911 if (dev->mc_list)
912 make_mc_bits(ei_local->mcfilter, dev);
913 }
914 else
915 memset(ei_local->mcfilter, 0xFF, 8); /* mcast set to accept-all */
916
917 /*
918 * DP8390 manuals don't specify any magic sequence for altering
919 * the multicast regs on an already running card. To be safe, we
920 * ensure multicast mode is off prior to loading up the new hash
921 * table. If this proves to be not enough, we can always resort
922 * to stopping the NIC, loading the table and then restarting.
923 *
924 * Bug Alert! The MC regs on the SMC 83C690 (SMC Elite and SMC
925 * Elite16) appear to be write-only. The NS 8390 data sheet lists
926 * them as r/w so this is a bug. The SMC 83C790 (SMC Ultra and
927 * Ultra32 EISA) appears to have this bug fixed.
928 */
929
930 if (netif_running(dev))
931 ei_outb_p(E8390_RXCONFIG, e8390_base + EN0_RXCR);
932 ei_outb_p(E8390_NODMA + E8390_PAGE1, e8390_base + E8390_CMD);
933 for(i = 0; i < 8; i++)
934 {
935 ei_outb_p(ei_local->mcfilter[i], e8390_base + EN1_MULT_SHIFT(i));
936#ifndef BUG_83C690
937 if(ei_inb_p(e8390_base + EN1_MULT_SHIFT(i))!=ei_local->mcfilter[i])
938 printk(KERN_ERR "Multicast filter read/write mismap %d\n",i);
939#endif
940 }
941 ei_outb_p(E8390_NODMA + E8390_PAGE0, e8390_base + E8390_CMD);
942
943 if(dev->flags&IFF_PROMISC)
944 ei_outb_p(E8390_RXCONFIG | 0x18, e8390_base + EN0_RXCR);
945 else if(dev->flags&IFF_ALLMULTI || dev->mc_list)
946 ei_outb_p(E8390_RXCONFIG | 0x08, e8390_base + EN0_RXCR);
947 else
948 ei_outb_p(E8390_RXCONFIG, e8390_base + EN0_RXCR);
949 }
950
951/*
952 * Called without lock held. This is invoked from user context and may
953 * be parallel to just about everything else. Its also fairly quick and
954 * not called too often. Must protect against both bh and irq users
955 */
956
957static void set_multicast_list(struct net_device *dev)
958{
959 unsigned long flags;
960 struct ei_device *ei_local = (struct ei_device*)netdev_priv(dev);
961
962 spin_lock_irqsave(&ei_local->page_lock, flags);
963 do_set_multicast_list(dev);
964 spin_unlock_irqrestore(&ei_local->page_lock, flags);
965}
966
967/**
968 * ethdev_setup - init rest of 8390 device struct
969 * @dev: network device structure to init
970 *
971 * Initialize the rest of the 8390 device structure. Do NOT __init
972 * this, as it is used by 8390 based modular drivers too.
973 */
974
975static void ethdev_setup(struct net_device *dev)
976{
977 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
978 if (ei_debug > 1)
979 printk(version);
980
981 dev->hard_start_xmit = &ei_start_xmit;
982 dev->get_stats = get_stats;
983 dev->set_multicast_list = &set_multicast_list;
984
985 ether_setup(dev);
986
987 spin_lock_init(&ei_local->page_lock);
988}
989
990/**
991 * alloc_ei_netdev - alloc_etherdev counterpart for 8390
992 * @size: extra bytes to allocate
993 *
994 * Allocate 8390-specific net_device.
995 */
996static struct net_device *____alloc_ei_netdev(int size)
997{
998 return alloc_netdev(sizeof(struct ei_device) + size, "eth%d",
999 ethdev_setup);
1000}
1001
1002
1003
1004
1005/* This page of functions should be 8390 generic */
1006/* Follow National Semi's recommendations for initializing the "NIC". */
1007
1008/**
1009 * NS8390_init - initialize 8390 hardware
1010 * @dev: network device to initialize
1011 * @startp: boolean. non-zero value to initiate chip processing
1012 *
1013 * Must be called with lock held.
1014 */
1015
1016static void __NS8390_init(struct net_device *dev, int startp)
1017{
1018 unsigned long e8390_base = dev->base_addr;
1019 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
1020 int i;
1021 int endcfg = ei_local->word16
1022 ? (0x48 | ENDCFG_WTS | (ei_local->bigendian ? ENDCFG_BOS : 0))
1023 : 0x48;
1024
1025 if(sizeof(struct e8390_pkt_hdr)!=4)
1026 panic("8390.c: header struct mispacked\n");
1027 /* Follow National Semi's recommendations for initing the DP83902. */
1028 ei_outb_p(E8390_NODMA+E8390_PAGE0+E8390_STOP, e8390_base+E8390_CMD); /* 0x21 */
1029 ei_outb_p(endcfg, e8390_base + EN0_DCFG); /* 0x48 or 0x49 */
1030 /* Clear the remote byte count registers. */
1031 ei_outb_p(0x00, e8390_base + EN0_RCNTLO);
1032 ei_outb_p(0x00, e8390_base + EN0_RCNTHI);
1033 /* Set to monitor and loopback mode -- this is vital!. */
1034 ei_outb_p(E8390_RXOFF, e8390_base + EN0_RXCR); /* 0x20 */
1035 ei_outb_p(E8390_TXOFF, e8390_base + EN0_TXCR); /* 0x02 */
1036 /* Set the transmit page and receive ring. */
1037 ei_outb_p(ei_local->tx_start_page, e8390_base + EN0_TPSR);
1038 ei_local->tx1 = ei_local->tx2 = 0;
1039 ei_outb_p(ei_local->rx_start_page, e8390_base + EN0_STARTPG);
1040 ei_outb_p(ei_local->stop_page-1, e8390_base + EN0_BOUNDARY); /* 3c503 says 0x3f,NS0x26*/
1041 ei_local->current_page = ei_local->rx_start_page; /* assert boundary+1 */
1042 ei_outb_p(ei_local->stop_page, e8390_base + EN0_STOPPG);
1043 /* Clear the pending interrupts and mask. */
1044 ei_outb_p(0xFF, e8390_base + EN0_ISR);
1045 ei_outb_p(0x00, e8390_base + EN0_IMR);
1046
1047 /* Copy the station address into the DS8390 registers. */
1048
1049 ei_outb_p(E8390_NODMA + E8390_PAGE1 + E8390_STOP, e8390_base+E8390_CMD); /* 0x61 */
1050 for(i = 0; i < 6; i++)
1051 {
1052 ei_outb_p(dev->dev_addr[i], e8390_base + EN1_PHYS_SHIFT(i));
1053 if (ei_debug > 1 && ei_inb_p(e8390_base + EN1_PHYS_SHIFT(i))!=dev->dev_addr[i])
1054 printk(KERN_ERR "Hw. address read/write mismap %d\n",i);
1055 }
1056
1057 ei_outb_p(ei_local->rx_start_page, e8390_base + EN1_CURPAG);
1058 ei_outb_p(E8390_NODMA+E8390_PAGE0+E8390_STOP, e8390_base+E8390_CMD);
1059
1060 netif_start_queue(dev);
1061 ei_local->tx1 = ei_local->tx2 = 0;
1062 ei_local->txing = 0;
1063
1064 if (startp)
1065 {
1066 ei_outb_p(0xff, e8390_base + EN0_ISR);
1067 ei_outb_p(ENISR_ALL, e8390_base + EN0_IMR);
1068 ei_outb_p(E8390_NODMA+E8390_PAGE0+E8390_START, e8390_base+E8390_CMD);
1069 ei_outb_p(E8390_TXCONFIG, e8390_base + EN0_TXCR); /* xmit on. */
1070 /* 3c503 TechMan says rxconfig only after the NIC is started. */
1071 ei_outb_p(E8390_RXCONFIG, e8390_base + EN0_RXCR); /* rx on, */
1072 do_set_multicast_list(dev); /* (re)load the mcast table */
1073 }
1074}
1075
1076/* Trigger a transmit start, assuming the length is valid.
1077 Always called with the page lock held */
1078
1079static void NS8390_trigger_send(struct net_device *dev, unsigned int length,
1080 int start_page)
1081{
1082 unsigned long e8390_base = dev->base_addr;
1083 struct ei_device *ei_local __attribute((unused)) = (struct ei_device *) netdev_priv(dev);
1084
1085 ei_outb_p(E8390_NODMA+E8390_PAGE0, e8390_base+E8390_CMD);
1086
1087 if (ei_inb_p(e8390_base + E8390_CMD) & E8390_TRANS)
1088 {
1089 printk(KERN_WARNING "%s: trigger_send() called with the transmitter busy.\n",
1090 dev->name);
1091 return;
1092 }
1093 ei_outb_p(length & 0xff, e8390_base + EN0_TCNTLO);
1094 ei_outb_p(length >> 8, e8390_base + EN0_TCNTHI);
1095 ei_outb_p(start_page, e8390_base + EN0_TPSR);
1096 ei_outb_p(E8390_NODMA+E8390_TRANS+E8390_START, e8390_base+E8390_CMD);
1097}
diff --git a/drivers/net/lne390.c b/drivers/net/lne390.c
index 5795ee116205..0a08d0c4e7b4 100644
--- a/drivers/net/lne390.c
+++ b/drivers/net/lne390.c
@@ -440,7 +440,7 @@ static void cleanup_card(struct net_device *dev)
440 iounmap(ei_status.mem); 440 iounmap(ei_status.mem);
441} 441}
442 442
443void cleanup_module(void) 443void __exit cleanup_module(void)
444{ 444{
445 int this_dev; 445 int this_dev;
446 446
diff --git a/drivers/net/mac8390.c b/drivers/net/mac8390.c
index ade6ff852e1a..a12bb64e3694 100644
--- a/drivers/net/mac8390.c
+++ b/drivers/net/mac8390.c
@@ -39,7 +39,16 @@
39#include <asm/hwtest.h> 39#include <asm/hwtest.h>
40#include <asm/macints.h> 40#include <asm/macints.h>
41 41
42#include "8390.h" 42static char version[] =
43 "mac8390.c: v0.4 2001-05-15 David Huggins-Daines <dhd@debian.org> and others\n";
44
45#define EI_SHIFT(x) (ei_local->reg_offset[x])
46#define ei_inb(port) in_8(port)
47#define ei_outb(val,port) out_8(port,val)
48#define ei_inb_p(port) in_8(port)
49#define ei_outb_p(val,port) out_8(port,val)
50
51#include "lib8390.c"
43 52
44#define WD_START_PG 0x00 /* First page of TX buffer */ 53#define WD_START_PG 0x00 /* First page of TX buffer */
45#define CABLETRON_RX_START_PG 0x00 /* First page of RX buffer */ 54#define CABLETRON_RX_START_PG 0x00 /* First page of RX buffer */
@@ -116,9 +125,6 @@ static int useresources[] = {
116 1, /* dayna-lc */ 125 1, /* dayna-lc */
117}; 126};
118 127
119static char version[] __initdata =
120 "mac8390.c: v0.4 2001-05-15 David Huggins-Daines <dhd@debian.org> and others\n";
121
122extern enum mac8390_type mac8390_ident(struct nubus_dev * dev); 128extern enum mac8390_type mac8390_ident(struct nubus_dev * dev);
123extern int mac8390_memsize(unsigned long membase); 129extern int mac8390_memsize(unsigned long membase);
124extern int mac8390_memtest(struct net_device * dev); 130extern int mac8390_memtest(struct net_device * dev);
@@ -237,7 +243,7 @@ struct net_device * __init mac8390_probe(int unit)
237 if (!MACH_IS_MAC) 243 if (!MACH_IS_MAC)
238 return ERR_PTR(-ENODEV); 244 return ERR_PTR(-ENODEV);
239 245
240 dev = alloc_ei_netdev(); 246 dev = ____alloc_ei_netdev(0);
241 if (!dev) 247 if (!dev)
242 return ERR_PTR(-ENOMEM); 248 return ERR_PTR(-ENOMEM);
243 249
@@ -438,7 +444,7 @@ static int __init mac8390_initdev(struct net_device * dev, struct nubus_dev * nd
438 dev->open = &mac8390_open; 444 dev->open = &mac8390_open;
439 dev->stop = &mac8390_close; 445 dev->stop = &mac8390_close;
440#ifdef CONFIG_NET_POLL_CONTROLLER 446#ifdef CONFIG_NET_POLL_CONTROLLER
441 dev->poll_controller = ei_poll; 447 dev->poll_controller = __ei_poll;
442#endif 448#endif
443 449
444 /* GAR, ei_status is actually a macro even though it looks global */ 450 /* GAR, ei_status is actually a macro even though it looks global */
@@ -510,7 +516,7 @@ static int __init mac8390_initdev(struct net_device * dev, struct nubus_dev * nd
510 return -ENODEV; 516 return -ENODEV;
511 } 517 }
512 518
513 NS8390_init(dev, 0); 519 __NS8390_init(dev, 0);
514 520
515 /* Good, done, now spit out some messages */ 521 /* Good, done, now spit out some messages */
516 printk(KERN_INFO "%s: %s in slot %X (type %s)\n", 522 printk(KERN_INFO "%s: %s in slot %X (type %s)\n",
@@ -532,8 +538,8 @@ static int __init mac8390_initdev(struct net_device * dev, struct nubus_dev * nd
532 538
533static int mac8390_open(struct net_device *dev) 539static int mac8390_open(struct net_device *dev)
534{ 540{
535 ei_open(dev); 541 __ei_open(dev);
536 if (request_irq(dev->irq, ei_interrupt, 0, "8390 Ethernet", dev)) { 542 if (request_irq(dev->irq, __ei_interrupt, 0, "8390 Ethernet", dev)) {
537 printk ("%s: unable to get IRQ %d.\n", dev->name, dev->irq); 543 printk ("%s: unable to get IRQ %d.\n", dev->name, dev->irq);
538 return -EAGAIN; 544 return -EAGAIN;
539 } 545 }
@@ -543,7 +549,7 @@ static int mac8390_open(struct net_device *dev)
543static int mac8390_close(struct net_device *dev) 549static int mac8390_close(struct net_device *dev)
544{ 550{
545 free_irq(dev->irq, dev); 551 free_irq(dev->irq, dev);
546 ei_close(dev); 552 __ei_close(dev);
547 return 0; 553 return 0;
548} 554}
549 555
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
new file mode 100644
index 000000000000..bd0ce98c939c
--- /dev/null
+++ b/drivers/net/macb.c
@@ -0,0 +1,1210 @@
1/*
2 * Atmel MACB Ethernet Controller driver
3 *
4 * Copyright (C) 2004-2006 Atmel Corporation
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#include <linux/clk.h>
12#include <linux/module.h>
13#include <linux/moduleparam.h>
14#include <linux/kernel.h>
15#include <linux/types.h>
16#include <linux/slab.h>
17#include <linux/init.h>
18#include <linux/netdevice.h>
19#include <linux/etherdevice.h>
20#include <linux/mii.h>
21#include <linux/mutex.h>
22#include <linux/dma-mapping.h>
23#include <linux/ethtool.h>
24#include <linux/platform_device.h>
25
26#include <asm/arch/board.h>
27
28#include "macb.h"
29
30#define to_net_dev(class) container_of(class, struct net_device, class_dev)
31
32#define RX_BUFFER_SIZE 128
33#define RX_RING_SIZE 512
34#define RX_RING_BYTES (sizeof(struct dma_desc) * RX_RING_SIZE)
35
36/* Make the IP header word-aligned (the ethernet header is 14 bytes) */
37#define RX_OFFSET 2
38
39#define TX_RING_SIZE 128
40#define DEF_TX_RING_PENDING (TX_RING_SIZE - 1)
41#define TX_RING_BYTES (sizeof(struct dma_desc) * TX_RING_SIZE)
42
43#define TX_RING_GAP(bp) \
44 (TX_RING_SIZE - (bp)->tx_pending)
45#define TX_BUFFS_AVAIL(bp) \
46 (((bp)->tx_tail <= (bp)->tx_head) ? \
47 (bp)->tx_tail + (bp)->tx_pending - (bp)->tx_head : \
48 (bp)->tx_tail - (bp)->tx_head - TX_RING_GAP(bp))
49#define NEXT_TX(n) (((n) + 1) & (TX_RING_SIZE - 1))
50
51#define NEXT_RX(n) (((n) + 1) & (RX_RING_SIZE - 1))
52
53/* minimum number of free TX descriptors before waking up TX process */
54#define MACB_TX_WAKEUP_THRESH (TX_RING_SIZE / 4)
55
56#define MACB_RX_INT_FLAGS (MACB_BIT(RCOMP) | MACB_BIT(RXUBR) \
57 | MACB_BIT(ISR_ROVR))
58
59static void __macb_set_hwaddr(struct macb *bp)
60{
61 u32 bottom;
62 u16 top;
63
64 bottom = cpu_to_le32(*((u32 *)bp->dev->dev_addr));
65 macb_writel(bp, SA1B, bottom);
66 top = cpu_to_le16(*((u16 *)(bp->dev->dev_addr + 4)));
67 macb_writel(bp, SA1T, top);
68}
69
70static void __init macb_get_hwaddr(struct macb *bp)
71{
72 u32 bottom;
73 u16 top;
74 u8 addr[6];
75
76 bottom = macb_readl(bp, SA1B);
77 top = macb_readl(bp, SA1T);
78
79 addr[0] = bottom & 0xff;
80 addr[1] = (bottom >> 8) & 0xff;
81 addr[2] = (bottom >> 16) & 0xff;
82 addr[3] = (bottom >> 24) & 0xff;
83 addr[4] = top & 0xff;
84 addr[5] = (top >> 8) & 0xff;
85
86 if (is_valid_ether_addr(addr))
87 memcpy(bp->dev->dev_addr, addr, sizeof(addr));
88}
89
90static void macb_enable_mdio(struct macb *bp)
91{
92 unsigned long flags;
93 u32 reg;
94
95 spin_lock_irqsave(&bp->lock, flags);
96 reg = macb_readl(bp, NCR);
97 reg |= MACB_BIT(MPE);
98 macb_writel(bp, NCR, reg);
99 macb_writel(bp, IER, MACB_BIT(MFD));
100 spin_unlock_irqrestore(&bp->lock, flags);
101}
102
103static void macb_disable_mdio(struct macb *bp)
104{
105 unsigned long flags;
106 u32 reg;
107
108 spin_lock_irqsave(&bp->lock, flags);
109 reg = macb_readl(bp, NCR);
110 reg &= ~MACB_BIT(MPE);
111 macb_writel(bp, NCR, reg);
112 macb_writel(bp, IDR, MACB_BIT(MFD));
113 spin_unlock_irqrestore(&bp->lock, flags);
114}
115
116static int macb_mdio_read(struct net_device *dev, int phy_id, int location)
117{
118 struct macb *bp = netdev_priv(dev);
119 int value;
120
121 mutex_lock(&bp->mdio_mutex);
122
123 macb_enable_mdio(bp);
124 macb_writel(bp, MAN, (MACB_BF(SOF, MACB_MAN_SOF)
125 | MACB_BF(RW, MACB_MAN_READ)
126 | MACB_BF(PHYA, phy_id)
127 | MACB_BF(REGA, location)
128 | MACB_BF(CODE, MACB_MAN_CODE)));
129
130 wait_for_completion(&bp->mdio_complete);
131
132 value = MACB_BFEXT(DATA, macb_readl(bp, MAN));
133 macb_disable_mdio(bp);
134 mutex_unlock(&bp->mdio_mutex);
135
136 return value;
137}
138
139static void macb_mdio_write(struct net_device *dev, int phy_id,
140 int location, int val)
141{
142 struct macb *bp = netdev_priv(dev);
143
144 dev_dbg(&bp->pdev->dev, "mdio_write %02x:%02x <- %04x\n",
145 phy_id, location, val);
146
147 mutex_lock(&bp->mdio_mutex);
148 macb_enable_mdio(bp);
149
150 macb_writel(bp, MAN, (MACB_BF(SOF, MACB_MAN_SOF)
151 | MACB_BF(RW, MACB_MAN_WRITE)
152 | MACB_BF(PHYA, phy_id)
153 | MACB_BF(REGA, location)
154 | MACB_BF(CODE, MACB_MAN_CODE)
155 | MACB_BF(DATA, val)));
156
157 wait_for_completion(&bp->mdio_complete);
158
159 macb_disable_mdio(bp);
160 mutex_unlock(&bp->mdio_mutex);
161}
162
163static int macb_phy_probe(struct macb *bp)
164{
165 int phy_address;
166 u16 phyid1, phyid2;
167
168 for (phy_address = 0; phy_address < 32; phy_address++) {
169 phyid1 = macb_mdio_read(bp->dev, phy_address, MII_PHYSID1);
170 phyid2 = macb_mdio_read(bp->dev, phy_address, MII_PHYSID2);
171
172 if (phyid1 != 0xffff && phyid1 != 0x0000
173 && phyid2 != 0xffff && phyid2 != 0x0000)
174 break;
175 }
176
177 if (phy_address == 32)
178 return -ENODEV;
179
180 dev_info(&bp->pdev->dev,
181 "detected PHY at address %d (ID %04x:%04x)\n",
182 phy_address, phyid1, phyid2);
183
184 bp->mii.phy_id = phy_address;
185 return 0;
186}
187
188static void macb_set_media(struct macb *bp, int media)
189{
190 u32 reg;
191
192 spin_lock_irq(&bp->lock);
193 reg = macb_readl(bp, NCFGR);
194 reg &= ~(MACB_BIT(SPD) | MACB_BIT(FD));
195 if (media & (ADVERTISE_100HALF | ADVERTISE_100FULL))
196 reg |= MACB_BIT(SPD);
197 if (media & ADVERTISE_FULL)
198 reg |= MACB_BIT(FD);
199 macb_writel(bp, NCFGR, reg);
200 spin_unlock_irq(&bp->lock);
201}
202
203static void macb_check_media(struct macb *bp, int ok_to_print, int init_media)
204{
205 struct mii_if_info *mii = &bp->mii;
206 unsigned int old_carrier, new_carrier;
207 int advertise, lpa, media, duplex;
208
209 /* if forced media, go no further */
210 if (mii->force_media)
211 return;
212
213 /* check current and old link status */
214 old_carrier = netif_carrier_ok(mii->dev) ? 1 : 0;
215 new_carrier = (unsigned int) mii_link_ok(mii);
216
217 /* if carrier state did not change, assume nothing else did */
218 if (!init_media && old_carrier == new_carrier)
219 return;
220
221 /* no carrier, nothing much to do */
222 if (!new_carrier) {
223 netif_carrier_off(mii->dev);
224 printk(KERN_INFO "%s: link down\n", mii->dev->name);
225 return;
226 }
227
228 /*
229 * we have carrier, see who's on the other end
230 */
231 netif_carrier_on(mii->dev);
232
233 /* get MII advertise and LPA values */
234 if (!init_media && mii->advertising) {
235 advertise = mii->advertising;
236 } else {
237 advertise = mii->mdio_read(mii->dev, mii->phy_id, MII_ADVERTISE);
238 mii->advertising = advertise;
239 }
240 lpa = mii->mdio_read(mii->dev, mii->phy_id, MII_LPA);
241
242 /* figure out media and duplex from advertise and LPA values */
243 media = mii_nway_result(lpa & advertise);
244 duplex = (media & ADVERTISE_FULL) ? 1 : 0;
245
246 if (ok_to_print)
247 printk(KERN_INFO "%s: link up, %sMbps, %s-duplex, lpa 0x%04X\n",
248 mii->dev->name,
249 media & (ADVERTISE_100FULL | ADVERTISE_100HALF) ? "100" : "10",
250 duplex ? "full" : "half", lpa);
251
252 mii->full_duplex = duplex;
253
254 /* Let the MAC know about the new link state */
255 macb_set_media(bp, media);
256}
257
258static void macb_update_stats(struct macb *bp)
259{
260 u32 __iomem *reg = bp->regs + MACB_PFR;
261 u32 *p = &bp->hw_stats.rx_pause_frames;
262 u32 *end = &bp->hw_stats.tx_pause_frames + 1;
263
264 WARN_ON((unsigned long)(end - p - 1) != (MACB_TPF - MACB_PFR) / 4);
265
266 for(; p < end; p++, reg++)
267 *p += readl(reg);
268}
269
270static void macb_periodic_task(void *arg)
271{
272 struct macb *bp = arg;
273
274 macb_update_stats(bp);
275 macb_check_media(bp, 1, 0);
276
277 schedule_delayed_work(&bp->periodic_task, HZ);
278}
279
280static void macb_tx(struct macb *bp)
281{
282 unsigned int tail;
283 unsigned int head;
284 u32 status;
285
286 status = macb_readl(bp, TSR);
287 macb_writel(bp, TSR, status);
288
289 dev_dbg(&bp->pdev->dev, "macb_tx status = %02lx\n",
290 (unsigned long)status);
291
292 if (status & MACB_BIT(UND)) {
293 printk(KERN_ERR "%s: TX underrun, resetting buffers\n",
294 bp->dev->name);
295 bp->tx_head = bp->tx_tail = 0;
296 }
297
298 if (!(status & MACB_BIT(COMP)))
299 /*
300 * This may happen when a buffer becomes complete
301 * between reading the ISR and scanning the
302 * descriptors. Nothing to worry about.
303 */
304 return;
305
306 head = bp->tx_head;
307 for (tail = bp->tx_tail; tail != head; tail = NEXT_TX(tail)) {
308 struct ring_info *rp = &bp->tx_skb[tail];
309 struct sk_buff *skb = rp->skb;
310 u32 bufstat;
311
312 BUG_ON(skb == NULL);
313
314 rmb();
315 bufstat = bp->tx_ring[tail].ctrl;
316
317 if (!(bufstat & MACB_BIT(TX_USED)))
318 break;
319
320 dev_dbg(&bp->pdev->dev, "skb %u (data %p) TX complete\n",
321 tail, skb->data);
322 dma_unmap_single(&bp->pdev->dev, rp->mapping, skb->len,
323 DMA_TO_DEVICE);
324 bp->stats.tx_packets++;
325 bp->stats.tx_bytes += skb->len;
326 rp->skb = NULL;
327 dev_kfree_skb_irq(skb);
328 }
329
330 bp->tx_tail = tail;
331 if (netif_queue_stopped(bp->dev) &&
332 TX_BUFFS_AVAIL(bp) > MACB_TX_WAKEUP_THRESH)
333 netif_wake_queue(bp->dev);
334}
335
336static int macb_rx_frame(struct macb *bp, unsigned int first_frag,
337 unsigned int last_frag)
338{
339 unsigned int len;
340 unsigned int frag;
341 unsigned int offset = 0;
342 struct sk_buff *skb;
343
344 len = MACB_BFEXT(RX_FRMLEN, bp->rx_ring[last_frag].ctrl);
345
346 dev_dbg(&bp->pdev->dev, "macb_rx_frame frags %u - %u (len %u)\n",
347 first_frag, last_frag, len);
348
349 skb = dev_alloc_skb(len + RX_OFFSET);
350 if (!skb) {
351 bp->stats.rx_dropped++;
352 for (frag = first_frag; ; frag = NEXT_RX(frag)) {
353 bp->rx_ring[frag].addr &= ~MACB_BIT(RX_USED);
354 if (frag == last_frag)
355 break;
356 }
357 wmb();
358 return 1;
359 }
360
361 skb_reserve(skb, RX_OFFSET);
362 skb->dev = bp->dev;
363 skb->ip_summed = CHECKSUM_NONE;
364 skb_put(skb, len);
365
366 for (frag = first_frag; ; frag = NEXT_RX(frag)) {
367 unsigned int frag_len = RX_BUFFER_SIZE;
368
369 if (offset + frag_len > len) {
370 BUG_ON(frag != last_frag);
371 frag_len = len - offset;
372 }
373 memcpy(skb->data + offset,
374 bp->rx_buffers + (RX_BUFFER_SIZE * frag),
375 frag_len);
376 offset += RX_BUFFER_SIZE;
377 bp->rx_ring[frag].addr &= ~MACB_BIT(RX_USED);
378 wmb();
379
380 if (frag == last_frag)
381 break;
382 }
383
384 skb->protocol = eth_type_trans(skb, bp->dev);
385
386 bp->stats.rx_packets++;
387 bp->stats.rx_bytes += len;
388 bp->dev->last_rx = jiffies;
389 dev_dbg(&bp->pdev->dev, "received skb of length %u, csum: %08x\n",
390 skb->len, skb->csum);
391 netif_receive_skb(skb);
392
393 return 0;
394}
395
396/* Mark DMA descriptors from begin up to and not including end as unused */
397static void discard_partial_frame(struct macb *bp, unsigned int begin,
398 unsigned int end)
399{
400 unsigned int frag;
401
402 for (frag = begin; frag != end; frag = NEXT_RX(frag))
403 bp->rx_ring[frag].addr &= ~MACB_BIT(RX_USED);
404 wmb();
405
406 /*
407 * When this happens, the hardware stats registers for
408 * whatever caused this is updated, so we don't have to record
409 * anything.
410 */
411}
412
413static int macb_rx(struct macb *bp, int budget)
414{
415 int received = 0;
416 unsigned int tail = bp->rx_tail;
417 int first_frag = -1;
418
419 for (; budget > 0; tail = NEXT_RX(tail)) {
420 u32 addr, ctrl;
421
422 rmb();
423 addr = bp->rx_ring[tail].addr;
424 ctrl = bp->rx_ring[tail].ctrl;
425
426 if (!(addr & MACB_BIT(RX_USED)))
427 break;
428
429 if (ctrl & MACB_BIT(RX_SOF)) {
430 if (first_frag != -1)
431 discard_partial_frame(bp, first_frag, tail);
432 first_frag = tail;
433 }
434
435 if (ctrl & MACB_BIT(RX_EOF)) {
436 int dropped;
437 BUG_ON(first_frag == -1);
438
439 dropped = macb_rx_frame(bp, first_frag, tail);
440 first_frag = -1;
441 if (!dropped) {
442 received++;
443 budget--;
444 }
445 }
446 }
447
448 if (first_frag != -1)
449 bp->rx_tail = first_frag;
450 else
451 bp->rx_tail = tail;
452
453 return received;
454}
455
456static int macb_poll(struct net_device *dev, int *budget)
457{
458 struct macb *bp = netdev_priv(dev);
459 int orig_budget, work_done, retval = 0;
460 u32 status;
461
462 status = macb_readl(bp, RSR);
463 macb_writel(bp, RSR, status);
464
465 if (!status) {
466 /*
467 * This may happen if an interrupt was pending before
468 * this function was called last time, and no packets
469 * have been received since.
470 */
471 netif_rx_complete(dev);
472 goto out;
473 }
474
475 dev_dbg(&bp->pdev->dev, "poll: status = %08lx, budget = %d\n",
476 (unsigned long)status, *budget);
477
478 if (!(status & MACB_BIT(REC))) {
479 dev_warn(&bp->pdev->dev,
480 "No RX buffers complete, status = %02lx\n",
481 (unsigned long)status);
482 netif_rx_complete(dev);
483 goto out;
484 }
485
486 orig_budget = *budget;
487 if (orig_budget > dev->quota)
488 orig_budget = dev->quota;
489
490 work_done = macb_rx(bp, orig_budget);
491 if (work_done < orig_budget) {
492 netif_rx_complete(dev);
493 retval = 0;
494 } else {
495 retval = 1;
496 }
497
498 /*
499 * We've done what we can to clean the buffers. Make sure we
500 * get notified when new packets arrive.
501 */
502out:
503 macb_writel(bp, IER, MACB_RX_INT_FLAGS);
504
505 /* TODO: Handle errors */
506
507 return retval;
508}
509
510static irqreturn_t macb_interrupt(int irq, void *dev_id)
511{
512 struct net_device *dev = dev_id;
513 struct macb *bp = netdev_priv(dev);
514 u32 status;
515
516 status = macb_readl(bp, ISR);
517
518 if (unlikely(!status))
519 return IRQ_NONE;
520
521 spin_lock(&bp->lock);
522
523 while (status) {
524 if (status & MACB_BIT(MFD))
525 complete(&bp->mdio_complete);
526
527 /* close possible race with dev_close */
528 if (unlikely(!netif_running(dev))) {
529 macb_writel(bp, IDR, ~0UL);
530 break;
531 }
532
533 if (status & MACB_RX_INT_FLAGS) {
534 if (netif_rx_schedule_prep(dev)) {
535 /*
536 * There's no point taking any more interrupts
537 * until we have processed the buffers
538 */
539 macb_writel(bp, IDR, MACB_RX_INT_FLAGS);
540 dev_dbg(&bp->pdev->dev, "scheduling RX softirq\n");
541 __netif_rx_schedule(dev);
542 }
543 }
544
545 if (status & (MACB_BIT(TCOMP) | MACB_BIT(ISR_TUND)))
546 macb_tx(bp);
547
548 /*
549 * Link change detection isn't possible with RMII, so we'll
550 * add that if/when we get our hands on a full-blown MII PHY.
551 */
552
553 if (status & MACB_BIT(HRESP)) {
554 /*
555 * TODO: Reset the hardware, and maybe move the printk
556 * to a lower-priority context as well (work queue?)
557 */
558 printk(KERN_ERR "%s: DMA bus error: HRESP not OK\n",
559 dev->name);
560 }
561
562 status = macb_readl(bp, ISR);
563 }
564
565 spin_unlock(&bp->lock);
566
567 return IRQ_HANDLED;
568}
569
570static int macb_start_xmit(struct sk_buff *skb, struct net_device *dev)
571{
572 struct macb *bp = netdev_priv(dev);
573 dma_addr_t mapping;
574 unsigned int len, entry;
575 u32 ctrl;
576
577#ifdef DEBUG
578 int i;
579 dev_dbg(&bp->pdev->dev,
580 "start_xmit: len %u head %p data %p tail %p end %p\n",
581 skb->len, skb->head, skb->data, skb->tail, skb->end);
582 dev_dbg(&bp->pdev->dev,
583 "data:");
584 for (i = 0; i < 16; i++)
585 printk(" %02x", (unsigned int)skb->data[i]);
586 printk("\n");
587#endif
588
589 len = skb->len;
590 spin_lock_irq(&bp->lock);
591
592 /* This is a hard error, log it. */
593 if (TX_BUFFS_AVAIL(bp) < 1) {
594 netif_stop_queue(dev);
595 spin_unlock_irq(&bp->lock);
596 dev_err(&bp->pdev->dev,
597 "BUG! Tx Ring full when queue awake!\n");
598 dev_dbg(&bp->pdev->dev, "tx_head = %u, tx_tail = %u\n",
599 bp->tx_head, bp->tx_tail);
600 return 1;
601 }
602
603 entry = bp->tx_head;
604 dev_dbg(&bp->pdev->dev, "Allocated ring entry %u\n", entry);
605 mapping = dma_map_single(&bp->pdev->dev, skb->data,
606 len, DMA_TO_DEVICE);
607 bp->tx_skb[entry].skb = skb;
608 bp->tx_skb[entry].mapping = mapping;
609 dev_dbg(&bp->pdev->dev, "Mapped skb data %p to DMA addr %08lx\n",
610 skb->data, (unsigned long)mapping);
611
612 ctrl = MACB_BF(TX_FRMLEN, len);
613 ctrl |= MACB_BIT(TX_LAST);
614 if (entry == (TX_RING_SIZE - 1))
615 ctrl |= MACB_BIT(TX_WRAP);
616
617 bp->tx_ring[entry].addr = mapping;
618 bp->tx_ring[entry].ctrl = ctrl;
619 wmb();
620
621 entry = NEXT_TX(entry);
622 bp->tx_head = entry;
623
624 macb_writel(bp, NCR, macb_readl(bp, NCR) | MACB_BIT(TSTART));
625
626 if (TX_BUFFS_AVAIL(bp) < 1)
627 netif_stop_queue(dev);
628
629 spin_unlock_irq(&bp->lock);
630
631 dev->trans_start = jiffies;
632
633 return 0;
634}
635
636static void macb_free_consistent(struct macb *bp)
637{
638 if (bp->tx_skb) {
639 kfree(bp->tx_skb);
640 bp->tx_skb = NULL;
641 }
642 if (bp->rx_ring) {
643 dma_free_coherent(&bp->pdev->dev, RX_RING_BYTES,
644 bp->rx_ring, bp->rx_ring_dma);
645 bp->rx_ring = NULL;
646 }
647 if (bp->tx_ring) {
648 dma_free_coherent(&bp->pdev->dev, TX_RING_BYTES,
649 bp->tx_ring, bp->tx_ring_dma);
650 bp->tx_ring = NULL;
651 }
652 if (bp->rx_buffers) {
653 dma_free_coherent(&bp->pdev->dev,
654 RX_RING_SIZE * RX_BUFFER_SIZE,
655 bp->rx_buffers, bp->rx_buffers_dma);
656 bp->rx_buffers = NULL;
657 }
658}
659
660static int macb_alloc_consistent(struct macb *bp)
661{
662 int size;
663
664 size = TX_RING_SIZE * sizeof(struct ring_info);
665 bp->tx_skb = kmalloc(size, GFP_KERNEL);
666 if (!bp->tx_skb)
667 goto out_err;
668
669 size = RX_RING_BYTES;
670 bp->rx_ring = dma_alloc_coherent(&bp->pdev->dev, size,
671 &bp->rx_ring_dma, GFP_KERNEL);
672 if (!bp->rx_ring)
673 goto out_err;
674 dev_dbg(&bp->pdev->dev,
675 "Allocated RX ring of %d bytes at %08lx (mapped %p)\n",
676 size, (unsigned long)bp->rx_ring_dma, bp->rx_ring);
677
678 size = TX_RING_BYTES;
679 bp->tx_ring = dma_alloc_coherent(&bp->pdev->dev, size,
680 &bp->tx_ring_dma, GFP_KERNEL);
681 if (!bp->tx_ring)
682 goto out_err;
683 dev_dbg(&bp->pdev->dev,
684 "Allocated TX ring of %d bytes at %08lx (mapped %p)\n",
685 size, (unsigned long)bp->tx_ring_dma, bp->tx_ring);
686
687 size = RX_RING_SIZE * RX_BUFFER_SIZE;
688 bp->rx_buffers = dma_alloc_coherent(&bp->pdev->dev, size,
689 &bp->rx_buffers_dma, GFP_KERNEL);
690 if (!bp->rx_buffers)
691 goto out_err;
692 dev_dbg(&bp->pdev->dev,
693 "Allocated RX buffers of %d bytes at %08lx (mapped %p)\n",
694 size, (unsigned long)bp->rx_buffers_dma, bp->rx_buffers);
695
696 return 0;
697
698out_err:
699 macb_free_consistent(bp);
700 return -ENOMEM;
701}
702
703static void macb_init_rings(struct macb *bp)
704{
705 int i;
706 dma_addr_t addr;
707
708 addr = bp->rx_buffers_dma;
709 for (i = 0; i < RX_RING_SIZE; i++) {
710 bp->rx_ring[i].addr = addr;
711 bp->rx_ring[i].ctrl = 0;
712 addr += RX_BUFFER_SIZE;
713 }
714 bp->rx_ring[RX_RING_SIZE - 1].addr |= MACB_BIT(RX_WRAP);
715
716 for (i = 0; i < TX_RING_SIZE; i++) {
717 bp->tx_ring[i].addr = 0;
718 bp->tx_ring[i].ctrl = MACB_BIT(TX_USED);
719 }
720 bp->tx_ring[TX_RING_SIZE - 1].ctrl |= MACB_BIT(TX_WRAP);
721
722 bp->rx_tail = bp->tx_head = bp->tx_tail = 0;
723}
724
725static void macb_reset_hw(struct macb *bp)
726{
727 /* Make sure we have the write buffer for ourselves */
728 wmb();
729
730 /*
731 * Disable RX and TX (XXX: Should we halt the transmission
732 * more gracefully?)
733 */
734 macb_writel(bp, NCR, 0);
735
736 /* Clear the stats registers (XXX: Update stats first?) */
737 macb_writel(bp, NCR, MACB_BIT(CLRSTAT));
738
739 /* Clear all status flags */
740 macb_writel(bp, TSR, ~0UL);
741 macb_writel(bp, RSR, ~0UL);
742
743 /* Disable all interrupts */
744 macb_writel(bp, IDR, ~0UL);
745 macb_readl(bp, ISR);
746}
747
748static void macb_init_hw(struct macb *bp)
749{
750 u32 config;
751
752 macb_reset_hw(bp);
753 __macb_set_hwaddr(bp);
754
755 config = macb_readl(bp, NCFGR) & MACB_BF(CLK, -1L);
756 config |= MACB_BIT(PAE); /* PAuse Enable */
757 config |= MACB_BIT(DRFCS); /* Discard Rx FCS */
758 if (bp->dev->flags & IFF_PROMISC)
759 config |= MACB_BIT(CAF); /* Copy All Frames */
760 if (!(bp->dev->flags & IFF_BROADCAST))
761 config |= MACB_BIT(NBC); /* No BroadCast */
762 macb_writel(bp, NCFGR, config);
763
764 /* Initialize TX and RX buffers */
765 macb_writel(bp, RBQP, bp->rx_ring_dma);
766 macb_writel(bp, TBQP, bp->tx_ring_dma);
767
768 /* Enable TX and RX */
769 macb_writel(bp, NCR, MACB_BIT(RE) | MACB_BIT(TE));
770
771 /* Enable interrupts */
772 macb_writel(bp, IER, (MACB_BIT(RCOMP)
773 | MACB_BIT(RXUBR)
774 | MACB_BIT(ISR_TUND)
775 | MACB_BIT(ISR_RLE)
776 | MACB_BIT(TXERR)
777 | MACB_BIT(TCOMP)
778 | MACB_BIT(ISR_ROVR)
779 | MACB_BIT(HRESP)));
780}
781
782static void macb_init_phy(struct net_device *dev)
783{
784 struct macb *bp = netdev_priv(dev);
785
786 /* Set some reasonable default settings */
787 macb_mdio_write(dev, bp->mii.phy_id, MII_ADVERTISE,
788 ADVERTISE_CSMA | ADVERTISE_ALL);
789 macb_mdio_write(dev, bp->mii.phy_id, MII_BMCR,
790 (BMCR_SPEED100 | BMCR_ANENABLE
791 | BMCR_ANRESTART | BMCR_FULLDPLX));
792}
793
794static int macb_open(struct net_device *dev)
795{
796 struct macb *bp = netdev_priv(dev);
797 int err;
798
799 dev_dbg(&bp->pdev->dev, "open\n");
800
801 if (!is_valid_ether_addr(dev->dev_addr))
802 return -EADDRNOTAVAIL;
803
804 err = macb_alloc_consistent(bp);
805 if (err) {
806 printk(KERN_ERR
807 "%s: Unable to allocate DMA memory (error %d)\n",
808 dev->name, err);
809 return err;
810 }
811
812 macb_init_rings(bp);
813 macb_init_hw(bp);
814 macb_init_phy(dev);
815
816 macb_check_media(bp, 1, 1);
817 netif_start_queue(dev);
818
819 schedule_delayed_work(&bp->periodic_task, HZ);
820
821 return 0;
822}
823
824static int macb_close(struct net_device *dev)
825{
826 struct macb *bp = netdev_priv(dev);
827 unsigned long flags;
828
829 cancel_rearming_delayed_work(&bp->periodic_task);
830
831 netif_stop_queue(dev);
832
833 spin_lock_irqsave(&bp->lock, flags);
834 macb_reset_hw(bp);
835 netif_carrier_off(dev);
836 spin_unlock_irqrestore(&bp->lock, flags);
837
838 macb_free_consistent(bp);
839
840 return 0;
841}
842
843static struct net_device_stats *macb_get_stats(struct net_device *dev)
844{
845 struct macb *bp = netdev_priv(dev);
846 struct net_device_stats *nstat = &bp->stats;
847 struct macb_stats *hwstat = &bp->hw_stats;
848
849 /* Convert HW stats into netdevice stats */
850 nstat->rx_errors = (hwstat->rx_fcs_errors +
851 hwstat->rx_align_errors +
852 hwstat->rx_resource_errors +
853 hwstat->rx_overruns +
854 hwstat->rx_oversize_pkts +
855 hwstat->rx_jabbers +
856 hwstat->rx_undersize_pkts +
857 hwstat->sqe_test_errors +
858 hwstat->rx_length_mismatch);
859 nstat->tx_errors = (hwstat->tx_late_cols +
860 hwstat->tx_excessive_cols +
861 hwstat->tx_underruns +
862 hwstat->tx_carrier_errors);
863 nstat->collisions = (hwstat->tx_single_cols +
864 hwstat->tx_multiple_cols +
865 hwstat->tx_excessive_cols);
866 nstat->rx_length_errors = (hwstat->rx_oversize_pkts +
867 hwstat->rx_jabbers +
868 hwstat->rx_undersize_pkts +
869 hwstat->rx_length_mismatch);
870 nstat->rx_over_errors = hwstat->rx_resource_errors;
871 nstat->rx_crc_errors = hwstat->rx_fcs_errors;
872 nstat->rx_frame_errors = hwstat->rx_align_errors;
873 nstat->rx_fifo_errors = hwstat->rx_overruns;
874 /* XXX: What does "missed" mean? */
875 nstat->tx_aborted_errors = hwstat->tx_excessive_cols;
876 nstat->tx_carrier_errors = hwstat->tx_carrier_errors;
877 nstat->tx_fifo_errors = hwstat->tx_underruns;
878 /* Don't know about heartbeat or window errors... */
879
880 return nstat;
881}
882
883static int macb_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
884{
885 struct macb *bp = netdev_priv(dev);
886 int ret;
887 unsigned long flags;
888
889 spin_lock_irqsave(&bp->lock, flags);
890 ret = mii_ethtool_gset(&bp->mii, cmd);
891 spin_unlock_irqrestore(&bp->lock, flags);
892
893 return ret;
894}
895
896static int macb_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
897{
898 struct macb *bp = netdev_priv(dev);
899 int ret;
900 unsigned long flags;
901
902 spin_lock_irqsave(&bp->lock, flags);
903 ret = mii_ethtool_sset(&bp->mii, cmd);
904 spin_unlock_irqrestore(&bp->lock, flags);
905
906 return ret;
907}
908
909static void macb_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
910{
911 struct macb *bp = netdev_priv(dev);
912
913 strcpy(info->driver, bp->pdev->dev.driver->name);
914 strcpy(info->version, "$Revision: 1.14 $");
915 strcpy(info->bus_info, bp->pdev->dev.bus_id);
916}
917
918static int macb_nway_reset(struct net_device *dev)
919{
920 struct macb *bp = netdev_priv(dev);
921 return mii_nway_restart(&bp->mii);
922}
923
924static struct ethtool_ops macb_ethtool_ops = {
925 .get_settings = macb_get_settings,
926 .set_settings = macb_set_settings,
927 .get_drvinfo = macb_get_drvinfo,
928 .nway_reset = macb_nway_reset,
929 .get_link = ethtool_op_get_link,
930};
931
932static int macb_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
933{
934 struct macb *bp = netdev_priv(dev);
935 int ret;
936 unsigned long flags;
937
938 if (!netif_running(dev))
939 return -EINVAL;
940
941 spin_lock_irqsave(&bp->lock, flags);
942 ret = generic_mii_ioctl(&bp->mii, if_mii(rq), cmd, NULL);
943 spin_unlock_irqrestore(&bp->lock, flags);
944
945 return ret;
946}
947
948static ssize_t macb_mii_show(const struct class_device *cd, char *buf,
949 unsigned long addr)
950{
951 struct net_device *dev = to_net_dev(cd);
952 struct macb *bp = netdev_priv(dev);
953 ssize_t ret = -EINVAL;
954
955 if (netif_running(dev)) {
956 int value;
957 value = macb_mdio_read(dev, bp->mii.phy_id, addr);
958 ret = sprintf(buf, "0x%04x\n", (uint16_t)value);
959 }
960
961 return ret;
962}
963
964#define MII_ENTRY(name, addr) \
965static ssize_t show_##name(struct class_device *cd, char *buf) \
966{ \
967 return macb_mii_show(cd, buf, addr); \
968} \
969static CLASS_DEVICE_ATTR(name, S_IRUGO, show_##name, NULL)
970
971MII_ENTRY(bmcr, MII_BMCR);
972MII_ENTRY(bmsr, MII_BMSR);
973MII_ENTRY(physid1, MII_PHYSID1);
974MII_ENTRY(physid2, MII_PHYSID2);
975MII_ENTRY(advertise, MII_ADVERTISE);
976MII_ENTRY(lpa, MII_LPA);
977MII_ENTRY(expansion, MII_EXPANSION);
978
979static struct attribute *macb_mii_attrs[] = {
980 &class_device_attr_bmcr.attr,
981 &class_device_attr_bmsr.attr,
982 &class_device_attr_physid1.attr,
983 &class_device_attr_physid2.attr,
984 &class_device_attr_advertise.attr,
985 &class_device_attr_lpa.attr,
986 &class_device_attr_expansion.attr,
987 NULL,
988};
989
990static struct attribute_group macb_mii_group = {
991 .name = "mii",
992 .attrs = macb_mii_attrs,
993};
994
995static void macb_unregister_sysfs(struct net_device *net)
996{
997 struct class_device *class_dev = &net->class_dev;
998
999 sysfs_remove_group(&class_dev->kobj, &macb_mii_group);
1000}
1001
1002static int macb_register_sysfs(struct net_device *net)
1003{
1004 struct class_device *class_dev = &net->class_dev;
1005 int ret;
1006
1007 ret = sysfs_create_group(&class_dev->kobj, &macb_mii_group);
1008 if (ret)
1009 printk(KERN_WARNING
1010 "%s: sysfs mii attribute registration failed: %d\n",
1011 net->name, ret);
1012 return ret;
1013}
1014static int __devinit macb_probe(struct platform_device *pdev)
1015{
1016 struct eth_platform_data *pdata;
1017 struct resource *regs;
1018 struct net_device *dev;
1019 struct macb *bp;
1020 unsigned long pclk_hz;
1021 u32 config;
1022 int err = -ENXIO;
1023
1024 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1025 if (!regs) {
1026 dev_err(&pdev->dev, "no mmio resource defined\n");
1027 goto err_out;
1028 }
1029
1030 err = -ENOMEM;
1031 dev = alloc_etherdev(sizeof(*bp));
1032 if (!dev) {
1033 dev_err(&pdev->dev, "etherdev alloc failed, aborting.\n");
1034 goto err_out;
1035 }
1036
1037 SET_MODULE_OWNER(dev);
1038 SET_NETDEV_DEV(dev, &pdev->dev);
1039
1040 /* TODO: Actually, we have some interesting features... */
1041 dev->features |= 0;
1042
1043 bp = netdev_priv(dev);
1044 bp->pdev = pdev;
1045 bp->dev = dev;
1046
1047 spin_lock_init(&bp->lock);
1048
1049 bp->pclk = clk_get(&pdev->dev, "pclk");
1050 if (IS_ERR(bp->pclk)) {
1051 dev_err(&pdev->dev, "failed to get pclk\n");
1052 goto err_out_free_dev;
1053 }
1054 bp->hclk = clk_get(&pdev->dev, "hclk");
1055 if (IS_ERR(bp->hclk)) {
1056 dev_err(&pdev->dev, "failed to get hclk\n");
1057 goto err_out_put_pclk;
1058 }
1059
1060 clk_enable(bp->pclk);
1061 clk_enable(bp->hclk);
1062
1063 bp->regs = ioremap(regs->start, regs->end - regs->start + 1);
1064 if (!bp->regs) {
1065 dev_err(&pdev->dev, "failed to map registers, aborting.\n");
1066 err = -ENOMEM;
1067 goto err_out_disable_clocks;
1068 }
1069
1070 dev->irq = platform_get_irq(pdev, 0);
1071 err = request_irq(dev->irq, macb_interrupt, SA_SAMPLE_RANDOM,
1072 dev->name, dev);
1073 if (err) {
1074 printk(KERN_ERR
1075 "%s: Unable to request IRQ %d (error %d)\n",
1076 dev->name, dev->irq, err);
1077 goto err_out_iounmap;
1078 }
1079
1080 dev->open = macb_open;
1081 dev->stop = macb_close;
1082 dev->hard_start_xmit = macb_start_xmit;
1083 dev->get_stats = macb_get_stats;
1084 dev->do_ioctl = macb_ioctl;
1085 dev->poll = macb_poll;
1086 dev->weight = 64;
1087 dev->ethtool_ops = &macb_ethtool_ops;
1088
1089 dev->base_addr = regs->start;
1090
1091 INIT_WORK(&bp->periodic_task, macb_periodic_task, bp);
1092 mutex_init(&bp->mdio_mutex);
1093 init_completion(&bp->mdio_complete);
1094
1095 /* Set MII management clock divider */
1096 pclk_hz = clk_get_rate(bp->pclk);
1097 if (pclk_hz <= 20000000)
1098 config = MACB_BF(CLK, MACB_CLK_DIV8);
1099 else if (pclk_hz <= 40000000)
1100 config = MACB_BF(CLK, MACB_CLK_DIV16);
1101 else if (pclk_hz <= 80000000)
1102 config = MACB_BF(CLK, MACB_CLK_DIV32);
1103 else
1104 config = MACB_BF(CLK, MACB_CLK_DIV64);
1105 macb_writel(bp, NCFGR, config);
1106
1107 bp->mii.dev = dev;
1108 bp->mii.mdio_read = macb_mdio_read;
1109 bp->mii.mdio_write = macb_mdio_write;
1110 bp->mii.phy_id_mask = 0x1f;
1111 bp->mii.reg_num_mask = 0x1f;
1112
1113 macb_get_hwaddr(bp);
1114 err = macb_phy_probe(bp);
1115 if (err) {
1116 dev_err(&pdev->dev, "Failed to detect PHY, aborting.\n");
1117 goto err_out_free_irq;
1118 }
1119
1120 pdata = pdev->dev.platform_data;
1121 if (pdata && pdata->is_rmii)
1122 macb_writel(bp, USRIO, 0);
1123 else
1124 macb_writel(bp, USRIO, MACB_BIT(MII));
1125
1126 bp->tx_pending = DEF_TX_RING_PENDING;
1127
1128 err = register_netdev(dev);
1129 if (err) {
1130 dev_err(&pdev->dev, "Cannot register net device, aborting.\n");
1131 goto err_out_free_irq;
1132 }
1133
1134 platform_set_drvdata(pdev, dev);
1135
1136 macb_register_sysfs(dev);
1137
1138 printk(KERN_INFO "%s: Atmel MACB at 0x%08lx irq %d "
1139 "(%02x:%02x:%02x:%02x:%02x:%02x)\n",
1140 dev->name, dev->base_addr, dev->irq,
1141 dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
1142 dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]);
1143
1144 return 0;
1145
1146err_out_free_irq:
1147 free_irq(dev->irq, dev);
1148err_out_iounmap:
1149 iounmap(bp->regs);
1150err_out_disable_clocks:
1151 clk_disable(bp->hclk);
1152 clk_disable(bp->pclk);
1153 clk_put(bp->hclk);
1154err_out_put_pclk:
1155 clk_put(bp->pclk);
1156err_out_free_dev:
1157 free_netdev(dev);
1158err_out:
1159 platform_set_drvdata(pdev, NULL);
1160 return err;
1161}
1162
1163static int __devexit macb_remove(struct platform_device *pdev)
1164{
1165 struct net_device *dev;
1166 struct macb *bp;
1167
1168 dev = platform_get_drvdata(pdev);
1169
1170 if (dev) {
1171 bp = netdev_priv(dev);
1172 macb_unregister_sysfs(dev);
1173 unregister_netdev(dev);
1174 free_irq(dev->irq, dev);
1175 iounmap(bp->regs);
1176 clk_disable(bp->hclk);
1177 clk_disable(bp->pclk);
1178 clk_put(bp->hclk);
1179 clk_put(bp->pclk);
1180 free_netdev(dev);
1181 platform_set_drvdata(pdev, NULL);
1182 }
1183
1184 return 0;
1185}
1186
1187static struct platform_driver macb_driver = {
1188 .probe = macb_probe,
1189 .remove = __devexit_p(macb_remove),
1190 .driver = {
1191 .name = "macb",
1192 },
1193};
1194
1195static int __init macb_init(void)
1196{
1197 return platform_driver_register(&macb_driver);
1198}
1199
1200static void __exit macb_exit(void)
1201{
1202 platform_driver_unregister(&macb_driver);
1203}
1204
1205module_init(macb_init);
1206module_exit(macb_exit);
1207
1208MODULE_LICENSE("GPL");
1209MODULE_DESCRIPTION("Atmel MACB Ethernet driver");
1210MODULE_AUTHOR("Haavard Skinnemoen <hskinnemoen@atmel.com>");
diff --git a/drivers/net/macb.h b/drivers/net/macb.h
new file mode 100644
index 000000000000..8c253db69881
--- /dev/null
+++ b/drivers/net/macb.h
@@ -0,0 +1,387 @@
1/*
2 * Atmel MACB Ethernet Controller driver
3 *
4 * Copyright (C) 2004-2006 Atmel Corporation
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#ifndef _MACB_H
11#define _MACB_H
12
13/* MACB register offsets */
14#define MACB_NCR 0x0000
15#define MACB_NCFGR 0x0004
16#define MACB_NSR 0x0008
17#define MACB_TSR 0x0014
18#define MACB_RBQP 0x0018
19#define MACB_TBQP 0x001c
20#define MACB_RSR 0x0020
21#define MACB_ISR 0x0024
22#define MACB_IER 0x0028
23#define MACB_IDR 0x002c
24#define MACB_IMR 0x0030
25#define MACB_MAN 0x0034
26#define MACB_PTR 0x0038
27#define MACB_PFR 0x003c
28#define MACB_FTO 0x0040
29#define MACB_SCF 0x0044
30#define MACB_MCF 0x0048
31#define MACB_FRO 0x004c
32#define MACB_FCSE 0x0050
33#define MACB_ALE 0x0054
34#define MACB_DTF 0x0058
35#define MACB_LCOL 0x005c
36#define MACB_EXCOL 0x0060
37#define MACB_TUND 0x0064
38#define MACB_CSE 0x0068
39#define MACB_RRE 0x006c
40#define MACB_ROVR 0x0070
41#define MACB_RSE 0x0074
42#define MACB_ELE 0x0078
43#define MACB_RJA 0x007c
44#define MACB_USF 0x0080
45#define MACB_STE 0x0084
46#define MACB_RLE 0x0088
47#define MACB_TPF 0x008c
48#define MACB_HRB 0x0090
49#define MACB_HRT 0x0094
50#define MACB_SA1B 0x0098
51#define MACB_SA1T 0x009c
52#define MACB_SA2B 0x00a0
53#define MACB_SA2T 0x00a4
54#define MACB_SA3B 0x00a8
55#define MACB_SA3T 0x00ac
56#define MACB_SA4B 0x00b0
57#define MACB_SA4T 0x00b4
58#define MACB_TID 0x00b8
59#define MACB_TPQ 0x00bc
60#define MACB_USRIO 0x00c0
61#define MACB_WOL 0x00c4
62
63/* Bitfields in NCR */
64#define MACB_LB_OFFSET 0
65#define MACB_LB_SIZE 1
66#define MACB_LLB_OFFSET 1
67#define MACB_LLB_SIZE 1
68#define MACB_RE_OFFSET 2
69#define MACB_RE_SIZE 1
70#define MACB_TE_OFFSET 3
71#define MACB_TE_SIZE 1
72#define MACB_MPE_OFFSET 4
73#define MACB_MPE_SIZE 1
74#define MACB_CLRSTAT_OFFSET 5
75#define MACB_CLRSTAT_SIZE 1
76#define MACB_INCSTAT_OFFSET 6
77#define MACB_INCSTAT_SIZE 1
78#define MACB_WESTAT_OFFSET 7
79#define MACB_WESTAT_SIZE 1
80#define MACB_BP_OFFSET 8
81#define MACB_BP_SIZE 1
82#define MACB_TSTART_OFFSET 9
83#define MACB_TSTART_SIZE 1
84#define MACB_THALT_OFFSET 10
85#define MACB_THALT_SIZE 1
86#define MACB_NCR_TPF_OFFSET 11
87#define MACB_NCR_TPF_SIZE 1
88#define MACB_TZQ_OFFSET 12
89#define MACB_TZQ_SIZE 1
90
91/* Bitfields in NCFGR */
92#define MACB_SPD_OFFSET 0
93#define MACB_SPD_SIZE 1
94#define MACB_FD_OFFSET 1
95#define MACB_FD_SIZE 1
96#define MACB_BIT_RATE_OFFSET 2
97#define MACB_BIT_RATE_SIZE 1
98#define MACB_JFRAME_OFFSET 3
99#define MACB_JFRAME_SIZE 1
100#define MACB_CAF_OFFSET 4
101#define MACB_CAF_SIZE 1
102#define MACB_NBC_OFFSET 5
103#define MACB_NBC_SIZE 1
104#define MACB_NCFGR_MTI_OFFSET 6
105#define MACB_NCFGR_MTI_SIZE 1
106#define MACB_UNI_OFFSET 7
107#define MACB_UNI_SIZE 1
108#define MACB_BIG_OFFSET 8
109#define MACB_BIG_SIZE 1
110#define MACB_EAE_OFFSET 9
111#define MACB_EAE_SIZE 1
112#define MACB_CLK_OFFSET 10
113#define MACB_CLK_SIZE 2
114#define MACB_RTY_OFFSET 12
115#define MACB_RTY_SIZE 1
116#define MACB_PAE_OFFSET 13
117#define MACB_PAE_SIZE 1
118#define MACB_RBOF_OFFSET 14
119#define MACB_RBOF_SIZE 2
120#define MACB_RLCE_OFFSET 16
121#define MACB_RLCE_SIZE 1
122#define MACB_DRFCS_OFFSET 17
123#define MACB_DRFCS_SIZE 1
124#define MACB_EFRHD_OFFSET 18
125#define MACB_EFRHD_SIZE 1
126#define MACB_IRXFCS_OFFSET 19
127#define MACB_IRXFCS_SIZE 1
128
129/* Bitfields in NSR */
130#define MACB_NSR_LINK_OFFSET 0
131#define MACB_NSR_LINK_SIZE 1
132#define MACB_MDIO_OFFSET 1
133#define MACB_MDIO_SIZE 1
134#define MACB_IDLE_OFFSET 2
135#define MACB_IDLE_SIZE 1
136
137/* Bitfields in TSR */
138#define MACB_UBR_OFFSET 0
139#define MACB_UBR_SIZE 1
140#define MACB_COL_OFFSET 1
141#define MACB_COL_SIZE 1
142#define MACB_TSR_RLE_OFFSET 2
143#define MACB_TSR_RLE_SIZE 1
144#define MACB_TGO_OFFSET 3
145#define MACB_TGO_SIZE 1
146#define MACB_BEX_OFFSET 4
147#define MACB_BEX_SIZE 1
148#define MACB_COMP_OFFSET 5
149#define MACB_COMP_SIZE 1
150#define MACB_UND_OFFSET 6
151#define MACB_UND_SIZE 1
152
153/* Bitfields in RSR */
154#define MACB_BNA_OFFSET 0
155#define MACB_BNA_SIZE 1
156#define MACB_REC_OFFSET 1
157#define MACB_REC_SIZE 1
158#define MACB_OVR_OFFSET 2
159#define MACB_OVR_SIZE 1
160
161/* Bitfields in ISR/IER/IDR/IMR */
162#define MACB_MFD_OFFSET 0
163#define MACB_MFD_SIZE 1
164#define MACB_RCOMP_OFFSET 1
165#define MACB_RCOMP_SIZE 1
166#define MACB_RXUBR_OFFSET 2
167#define MACB_RXUBR_SIZE 1
168#define MACB_TXUBR_OFFSET 3
169#define MACB_TXUBR_SIZE 1
170#define MACB_ISR_TUND_OFFSET 4
171#define MACB_ISR_TUND_SIZE 1
172#define MACB_ISR_RLE_OFFSET 5
173#define MACB_ISR_RLE_SIZE 1
174#define MACB_TXERR_OFFSET 6
175#define MACB_TXERR_SIZE 1
176#define MACB_TCOMP_OFFSET 7
177#define MACB_TCOMP_SIZE 1
178#define MACB_ISR_LINK_OFFSET 9
179#define MACB_ISR_LINK_SIZE 1
180#define MACB_ISR_ROVR_OFFSET 10
181#define MACB_ISR_ROVR_SIZE 1
182#define MACB_HRESP_OFFSET 11
183#define MACB_HRESP_SIZE 1
184#define MACB_PFR_OFFSET 12
185#define MACB_PFR_SIZE 1
186#define MACB_PTZ_OFFSET 13
187#define MACB_PTZ_SIZE 1
188
189/* Bitfields in MAN */
190#define MACB_DATA_OFFSET 0
191#define MACB_DATA_SIZE 16
192#define MACB_CODE_OFFSET 16
193#define MACB_CODE_SIZE 2
194#define MACB_REGA_OFFSET 18
195#define MACB_REGA_SIZE 5
196#define MACB_PHYA_OFFSET 23
197#define MACB_PHYA_SIZE 5
198#define MACB_RW_OFFSET 28
199#define MACB_RW_SIZE 2
200#define MACB_SOF_OFFSET 30
201#define MACB_SOF_SIZE 2
202
203/* Bitfields in USRIO */
204#define MACB_MII_OFFSET 0
205#define MACB_MII_SIZE 1
206#define MACB_EAM_OFFSET 1
207#define MACB_EAM_SIZE 1
208#define MACB_TX_PAUSE_OFFSET 2
209#define MACB_TX_PAUSE_SIZE 1
210#define MACB_TX_PAUSE_ZERO_OFFSET 3
211#define MACB_TX_PAUSE_ZERO_SIZE 1
212
213/* Bitfields in WOL */
214#define MACB_IP_OFFSET 0
215#define MACB_IP_SIZE 16
216#define MACB_MAG_OFFSET 16
217#define MACB_MAG_SIZE 1
218#define MACB_ARP_OFFSET 17
219#define MACB_ARP_SIZE 1
220#define MACB_SA1_OFFSET 18
221#define MACB_SA1_SIZE 1
222#define MACB_WOL_MTI_OFFSET 19
223#define MACB_WOL_MTI_SIZE 1
224
225/* Constants for CLK */
226#define MACB_CLK_DIV8 0
227#define MACB_CLK_DIV16 1
228#define MACB_CLK_DIV32 2
229#define MACB_CLK_DIV64 3
230
231/* Constants for MAN register */
232#define MACB_MAN_SOF 1
233#define MACB_MAN_WRITE 1
234#define MACB_MAN_READ 2
235#define MACB_MAN_CODE 2
236
237/* Bit manipulation macros */
238#define MACB_BIT(name) \
239 (1 << MACB_##name##_OFFSET)
240#define MACB_BF(name,value) \
241 (((value) & ((1 << MACB_##name##_SIZE) - 1)) \
242 << MACB_##name##_OFFSET)
243#define MACB_BFEXT(name,value)\
244 (((value) >> MACB_##name##_OFFSET) \
245 & ((1 << MACB_##name##_SIZE) - 1))
246#define MACB_BFINS(name,value,old) \
247 (((old) & ~(((1 << MACB_##name##_SIZE) - 1) \
248 << MACB_##name##_OFFSET)) \
249 | MACB_BF(name,value))
250
251/* Register access macros */
252#define macb_readl(port,reg) \
253 readl((port)->regs + MACB_##reg)
254#define macb_writel(port,reg,value) \
255 writel((value), (port)->regs + MACB_##reg)
256
257struct dma_desc {
258 u32 addr;
259 u32 ctrl;
260};
261
262/* DMA descriptor bitfields */
263#define MACB_RX_USED_OFFSET 0
264#define MACB_RX_USED_SIZE 1
265#define MACB_RX_WRAP_OFFSET 1
266#define MACB_RX_WRAP_SIZE 1
267#define MACB_RX_WADDR_OFFSET 2
268#define MACB_RX_WADDR_SIZE 30
269
270#define MACB_RX_FRMLEN_OFFSET 0
271#define MACB_RX_FRMLEN_SIZE 12
272#define MACB_RX_OFFSET_OFFSET 12
273#define MACB_RX_OFFSET_SIZE 2
274#define MACB_RX_SOF_OFFSET 14
275#define MACB_RX_SOF_SIZE 1
276#define MACB_RX_EOF_OFFSET 15
277#define MACB_RX_EOF_SIZE 1
278#define MACB_RX_CFI_OFFSET 16
279#define MACB_RX_CFI_SIZE 1
280#define MACB_RX_VLAN_PRI_OFFSET 17
281#define MACB_RX_VLAN_PRI_SIZE 3
282#define MACB_RX_PRI_TAG_OFFSET 20
283#define MACB_RX_PRI_TAG_SIZE 1
284#define MACB_RX_VLAN_TAG_OFFSET 21
285#define MACB_RX_VLAN_TAG_SIZE 1
286#define MACB_RX_TYPEID_MATCH_OFFSET 22
287#define MACB_RX_TYPEID_MATCH_SIZE 1
288#define MACB_RX_SA4_MATCH_OFFSET 23
289#define MACB_RX_SA4_MATCH_SIZE 1
290#define MACB_RX_SA3_MATCH_OFFSET 24
291#define MACB_RX_SA3_MATCH_SIZE 1
292#define MACB_RX_SA2_MATCH_OFFSET 25
293#define MACB_RX_SA2_MATCH_SIZE 1
294#define MACB_RX_SA1_MATCH_OFFSET 26
295#define MACB_RX_SA1_MATCH_SIZE 1
296#define MACB_RX_EXT_MATCH_OFFSET 28
297#define MACB_RX_EXT_MATCH_SIZE 1
298#define MACB_RX_UHASH_MATCH_OFFSET 29
299#define MACB_RX_UHASH_MATCH_SIZE 1
300#define MACB_RX_MHASH_MATCH_OFFSET 30
301#define MACB_RX_MHASH_MATCH_SIZE 1
302#define MACB_RX_BROADCAST_OFFSET 31
303#define MACB_RX_BROADCAST_SIZE 1
304
305#define MACB_TX_FRMLEN_OFFSET 0
306#define MACB_TX_FRMLEN_SIZE 11
307#define MACB_TX_LAST_OFFSET 15
308#define MACB_TX_LAST_SIZE 1
309#define MACB_TX_NOCRC_OFFSET 16
310#define MACB_TX_NOCRC_SIZE 1
311#define MACB_TX_BUF_EXHAUSTED_OFFSET 27
312#define MACB_TX_BUF_EXHAUSTED_SIZE 1
313#define MACB_TX_UNDERRUN_OFFSET 28
314#define MACB_TX_UNDERRUN_SIZE 1
315#define MACB_TX_ERROR_OFFSET 29
316#define MACB_TX_ERROR_SIZE 1
317#define MACB_TX_WRAP_OFFSET 30
318#define MACB_TX_WRAP_SIZE 1
319#define MACB_TX_USED_OFFSET 31
320#define MACB_TX_USED_SIZE 1
321
322struct ring_info {
323 struct sk_buff *skb;
324 dma_addr_t mapping;
325};
326
327/*
328 * Hardware-collected statistics. Used when updating the network
329 * device stats by a periodic timer.
330 */
331struct macb_stats {
332 u32 rx_pause_frames;
333 u32 tx_ok;
334 u32 tx_single_cols;
335 u32 tx_multiple_cols;
336 u32 rx_ok;
337 u32 rx_fcs_errors;
338 u32 rx_align_errors;
339 u32 tx_deferred;
340 u32 tx_late_cols;
341 u32 tx_excessive_cols;
342 u32 tx_underruns;
343 u32 tx_carrier_errors;
344 u32 rx_resource_errors;
345 u32 rx_overruns;
346 u32 rx_symbol_errors;
347 u32 rx_oversize_pkts;
348 u32 rx_jabbers;
349 u32 rx_undersize_pkts;
350 u32 sqe_test_errors;
351 u32 rx_length_mismatch;
352 u32 tx_pause_frames;
353};
354
355struct macb {
356 void __iomem *regs;
357
358 unsigned int rx_tail;
359 struct dma_desc *rx_ring;
360 void *rx_buffers;
361
362 unsigned int tx_head, tx_tail;
363 struct dma_desc *tx_ring;
364 struct ring_info *tx_skb;
365
366 spinlock_t lock;
367 struct platform_device *pdev;
368 struct clk *pclk;
369 struct clk *hclk;
370 struct net_device *dev;
371 struct net_device_stats stats;
372 struct macb_stats hw_stats;
373
374 dma_addr_t rx_ring_dma;
375 dma_addr_t tx_ring_dma;
376 dma_addr_t rx_buffers_dma;
377
378 unsigned int rx_pending, tx_pending;
379
380 struct work_struct periodic_task;
381
382 struct mutex mdio_mutex;
383 struct completion mdio_complete;
384 struct mii_if_info mii;
385};
386
387#endif /* _MACB_H */
diff --git a/drivers/net/meth.c b/drivers/net/meth.c
index c1aa60b9a982..e1d97cdf649e 100644
--- a/drivers/net/meth.c
+++ b/drivers/net/meth.c
@@ -33,7 +33,6 @@
33#include <asm/ip32/ip32_ints.h> 33#include <asm/ip32/ip32_ints.h>
34 34
35#include <asm/io.h> 35#include <asm/io.h>
36#include <asm/checksum.h>
37#include <asm/scatterlist.h> 36#include <asm/scatterlist.h>
38#include <linux/dma-mapping.h> 37#include <linux/dma-mapping.h>
39 38
diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index 9997081c6dae..c41ae4286eea 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -277,9 +277,11 @@ static void mv643xx_eth_tx_timeout(struct net_device *dev)
277 * 277 *
278 * Actual routine to reset the adapter when a timeout on Tx has occurred 278 * Actual routine to reset the adapter when a timeout on Tx has occurred
279 */ 279 */
280static void mv643xx_eth_tx_timeout_task(struct net_device *dev) 280static void mv643xx_eth_tx_timeout_task(struct work_struct *ugly)
281{ 281{
282 struct mv643xx_private *mp = netdev_priv(dev); 282 struct mv643xx_private *mp = container_of(ugly, struct mv643xx_private,
283 tx_timeout_task);
284 struct net_device *dev = mp->mii.dev; /* yuck */
283 285
284 if (!netif_running(dev)) 286 if (!netif_running(dev))
285 return; 287 return;
@@ -1098,7 +1100,7 @@ static void eth_tx_fill_frag_descs(struct mv643xx_private *mp,
1098 ETH_TX_ENABLE_INTERRUPT; 1100 ETH_TX_ENABLE_INTERRUPT;
1099 mp->tx_skb[tx_index] = skb; 1101 mp->tx_skb[tx_index] = skb;
1100 } else 1102 } else
1101 mp->tx_skb[tx_index] = 0; 1103 mp->tx_skb[tx_index] = NULL;
1102 1104
1103 desc = &mp->p_tx_desc_area[tx_index]; 1105 desc = &mp->p_tx_desc_area[tx_index];
1104 desc->l4i_chk = 0; 1106 desc->l4i_chk = 0;
@@ -1134,7 +1136,7 @@ static void eth_tx_submit_descs_for_skb(struct mv643xx_private *mp,
1134 eth_tx_fill_frag_descs(mp, skb); 1136 eth_tx_fill_frag_descs(mp, skb);
1135 1137
1136 length = skb_headlen(skb); 1138 length = skb_headlen(skb);
1137 mp->tx_skb[tx_index] = 0; 1139 mp->tx_skb[tx_index] = NULL;
1138 } else { 1140 } else {
1139 cmd_sts |= ETH_ZERO_PADDING | 1141 cmd_sts |= ETH_ZERO_PADDING |
1140 ETH_TX_LAST_DESC | 1142 ETH_TX_LAST_DESC |
@@ -1360,8 +1362,7 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
1360#endif 1362#endif
1361 1363
1362 /* Configure the timeout task */ 1364 /* Configure the timeout task */
1363 INIT_WORK(&mp->tx_timeout_task, 1365 INIT_WORK(&mp->tx_timeout_task, mv643xx_eth_tx_timeout_task);
1364 (void (*)(void *))mv643xx_eth_tx_timeout_task, dev);
1365 1366
1366 spin_lock_init(&mp->lock); 1367 spin_lock_init(&mp->lock);
1367 1368
diff --git a/drivers/net/mvme147.c b/drivers/net/mvme147.c
index 56a82d8ee8f5..e246d00bba6d 100644
--- a/drivers/net/mvme147.c
+++ b/drivers/net/mvme147.c
@@ -184,7 +184,7 @@ static int m147lance_close(struct net_device *dev)
184MODULE_LICENSE("GPL"); 184MODULE_LICENSE("GPL");
185 185
186static struct net_device *dev_mvme147_lance; 186static struct net_device *dev_mvme147_lance;
187int init_module(void) 187int __init init_module(void)
188{ 188{
189 dev_mvme147_lance = mvme147lance_probe(-1); 189 dev_mvme147_lance = mvme147lance_probe(-1);
190 if (IS_ERR(dev_mvme147_lance)) 190 if (IS_ERR(dev_mvme147_lance))
@@ -192,7 +192,7 @@ int init_module(void)
192 return 0; 192 return 0;
193} 193}
194 194
195void cleanup_module(void) 195void __exit cleanup_module(void)
196{ 196{
197 struct m147lance_private *lp = dev_mvme147_lance->priv; 197 struct m147lance_private *lp = dev_mvme147_lance->priv;
198 unregister_netdev(dev_mvme147_lance); 198 unregister_netdev(dev_mvme147_lance);
diff --git a/drivers/net/myri10ge/myri10ge.c b/drivers/net/myri10ge/myri10ge.c
index 806081b59733..81f127a78afa 100644
--- a/drivers/net/myri10ge/myri10ge.c
+++ b/drivers/net/myri10ge/myri10ge.c
@@ -89,7 +89,7 @@ MODULE_LICENSE("Dual BSD/GPL");
89#define MYRI10GE_EEPROM_STRINGS_SIZE 256 89#define MYRI10GE_EEPROM_STRINGS_SIZE 256
90#define MYRI10GE_MAX_SEND_DESC_TSO ((65536 / 2048) * 2) 90#define MYRI10GE_MAX_SEND_DESC_TSO ((65536 / 2048) * 2)
91 91
92#define MYRI10GE_NO_CONFIRM_DATA 0xffffffff 92#define MYRI10GE_NO_CONFIRM_DATA htonl(0xffffffff)
93#define MYRI10GE_NO_RESPONSE_RESULT 0xffffffff 93#define MYRI10GE_NO_RESPONSE_RESULT 0xffffffff
94 94
95struct myri10ge_rx_buffer_state { 95struct myri10ge_rx_buffer_state {
@@ -156,8 +156,8 @@ struct myri10ge_priv {
156 int sram_size; 156 int sram_size;
157 unsigned long board_span; 157 unsigned long board_span;
158 unsigned long iomem_base; 158 unsigned long iomem_base;
159 u32 __iomem *irq_claim; 159 __be32 __iomem *irq_claim;
160 u32 __iomem *irq_deassert; 160 __be32 __iomem *irq_deassert;
161 char *mac_addr_string; 161 char *mac_addr_string;
162 struct mcp_cmd_response *cmd; 162 struct mcp_cmd_response *cmd;
163 dma_addr_t cmd_bus; 163 dma_addr_t cmd_bus;
@@ -165,10 +165,10 @@ struct myri10ge_priv {
165 dma_addr_t fw_stats_bus; 165 dma_addr_t fw_stats_bus;
166 struct pci_dev *pdev; 166 struct pci_dev *pdev;
167 int msi_enabled; 167 int msi_enabled;
168 unsigned int link_state; 168 __be32 link_state;
169 unsigned int rdma_tags_available; 169 unsigned int rdma_tags_available;
170 int intr_coal_delay; 170 int intr_coal_delay;
171 u32 __iomem *intr_coal_delay_ptr; 171 __be32 __iomem *intr_coal_delay_ptr;
172 int mtrr; 172 int mtrr;
173 int wake_queue; 173 int wake_queue;
174 int stop_queue; 174 int stop_queue;
@@ -273,6 +273,11 @@ MODULE_PARM_DESC(myri10ge_debug, "Debug level (0=none,...,16=all)");
273 273
274#define myri10ge_pio_copy(to,from,size) __iowrite64_copy(to,from,size/8) 274#define myri10ge_pio_copy(to,from,size) __iowrite64_copy(to,from,size/8)
275 275
276static inline void put_be32(__be32 val, __be32 __iomem *p)
277{
278 __raw_writel((__force __u32)val, (__force void __iomem *)p);
279}
280
276static int 281static int
277myri10ge_send_cmd(struct myri10ge_priv *mgp, u32 cmd, 282myri10ge_send_cmd(struct myri10ge_priv *mgp, u32 cmd,
278 struct myri10ge_cmd *data, int atomic) 283 struct myri10ge_cmd *data, int atomic)
@@ -296,7 +301,7 @@ myri10ge_send_cmd(struct myri10ge_priv *mgp, u32 cmd,
296 301
297 buf->response_addr.low = htonl(dma_low); 302 buf->response_addr.low = htonl(dma_low);
298 buf->response_addr.high = htonl(dma_high); 303 buf->response_addr.high = htonl(dma_high);
299 response->result = MYRI10GE_NO_RESPONSE_RESULT; 304 response->result = htonl(MYRI10GE_NO_RESPONSE_RESULT);
300 mb(); 305 mb();
301 myri10ge_pio_copy(cmd_addr, buf, sizeof(*buf)); 306 myri10ge_pio_copy(cmd_addr, buf, sizeof(*buf));
302 307
@@ -311,14 +316,14 @@ myri10ge_send_cmd(struct myri10ge_priv *mgp, u32 cmd,
311 * (1ms will be enough for those commands) */ 316 * (1ms will be enough for those commands) */
312 for (sleep_total = 0; 317 for (sleep_total = 0;
313 sleep_total < 1000 318 sleep_total < 1000
314 && response->result == MYRI10GE_NO_RESPONSE_RESULT; 319 && response->result == htonl(MYRI10GE_NO_RESPONSE_RESULT);
315 sleep_total += 10) 320 sleep_total += 10)
316 udelay(10); 321 udelay(10);
317 } else { 322 } else {
318 /* use msleep for most command */ 323 /* use msleep for most command */
319 for (sleep_total = 0; 324 for (sleep_total = 0;
320 sleep_total < 15 325 sleep_total < 15
321 && response->result == MYRI10GE_NO_RESPONSE_RESULT; 326 && response->result == htonl(MYRI10GE_NO_RESPONSE_RESULT);
322 sleep_total++) 327 sleep_total++)
323 msleep(1); 328 msleep(1);
324 } 329 }
@@ -393,7 +398,7 @@ abort:
393static void myri10ge_dummy_rdma(struct myri10ge_priv *mgp, int enable) 398static void myri10ge_dummy_rdma(struct myri10ge_priv *mgp, int enable)
394{ 399{
395 char __iomem *submit; 400 char __iomem *submit;
396 u32 buf[16]; 401 __be32 buf[16];
397 u32 dma_low, dma_high; 402 u32 dma_low, dma_high;
398 int i; 403 int i;
399 404
@@ -410,7 +415,7 @@ static void myri10ge_dummy_rdma(struct myri10ge_priv *mgp, int enable)
410 415
411 buf[0] = htonl(dma_high); /* confirm addr MSW */ 416 buf[0] = htonl(dma_high); /* confirm addr MSW */
412 buf[1] = htonl(dma_low); /* confirm addr LSW */ 417 buf[1] = htonl(dma_low); /* confirm addr LSW */
413 buf[2] = htonl(MYRI10GE_NO_CONFIRM_DATA); /* confirm data */ 418 buf[2] = MYRI10GE_NO_CONFIRM_DATA; /* confirm data */
414 buf[3] = htonl(dma_high); /* dummy addr MSW */ 419 buf[3] = htonl(dma_high); /* dummy addr MSW */
415 buf[4] = htonl(dma_low); /* dummy addr LSW */ 420 buf[4] = htonl(dma_low); /* dummy addr LSW */
416 buf[5] = htonl(enable); /* enable? */ 421 buf[5] = htonl(enable); /* enable? */
@@ -479,7 +484,7 @@ static int myri10ge_load_hotplug_firmware(struct myri10ge_priv *mgp, u32 * size)
479 } 484 }
480 485
481 /* check id */ 486 /* check id */
482 hdr_offset = ntohl(*(u32 *) (fw->data + MCP_HEADER_PTR_OFFSET)); 487 hdr_offset = ntohl(*(__be32 *) (fw->data + MCP_HEADER_PTR_OFFSET));
483 if ((hdr_offset & 3) || hdr_offset + sizeof(*hdr) > fw->size) { 488 if ((hdr_offset & 3) || hdr_offset + sizeof(*hdr) > fw->size) {
484 dev_err(dev, "Bad firmware file\n"); 489 dev_err(dev, "Bad firmware file\n");
485 status = -EINVAL; 490 status = -EINVAL;
@@ -550,7 +555,7 @@ static int myri10ge_adopt_running_firmware(struct myri10ge_priv *mgp)
550static int myri10ge_load_firmware(struct myri10ge_priv *mgp) 555static int myri10ge_load_firmware(struct myri10ge_priv *mgp)
551{ 556{
552 char __iomem *submit; 557 char __iomem *submit;
553 u32 buf[16]; 558 __be32 buf[16];
554 u32 dma_low, dma_high, size; 559 u32 dma_low, dma_high, size;
555 int status, i; 560 int status, i;
556 561
@@ -600,7 +605,7 @@ static int myri10ge_load_firmware(struct myri10ge_priv *mgp)
600 605
601 buf[0] = htonl(dma_high); /* confirm addr MSW */ 606 buf[0] = htonl(dma_high); /* confirm addr MSW */
602 buf[1] = htonl(dma_low); /* confirm addr LSW */ 607 buf[1] = htonl(dma_low); /* confirm addr LSW */
603 buf[2] = htonl(MYRI10GE_NO_CONFIRM_DATA); /* confirm data */ 608 buf[2] = MYRI10GE_NO_CONFIRM_DATA; /* confirm data */
604 609
605 /* FIX: All newest firmware should un-protect the bottom of 610 /* FIX: All newest firmware should un-protect the bottom of
606 * the sram before handoff. However, the very first interfaces 611 * the sram before handoff. However, the very first interfaces
@@ -705,21 +710,21 @@ static int myri10ge_reset(struct myri10ge_priv *mgp)
705 710
706 status |= 711 status |=
707 myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_IRQ_ACK_OFFSET, &cmd, 0); 712 myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_IRQ_ACK_OFFSET, &cmd, 0);
708 mgp->irq_claim = (__iomem u32 *) (mgp->sram + cmd.data0); 713 mgp->irq_claim = (__iomem __be32 *) (mgp->sram + cmd.data0);
709 if (!mgp->msi_enabled) { 714 if (!mgp->msi_enabled) {
710 status |= myri10ge_send_cmd 715 status |= myri10ge_send_cmd
711 (mgp, MXGEFW_CMD_GET_IRQ_DEASSERT_OFFSET, &cmd, 0); 716 (mgp, MXGEFW_CMD_GET_IRQ_DEASSERT_OFFSET, &cmd, 0);
712 mgp->irq_deassert = (__iomem u32 *) (mgp->sram + cmd.data0); 717 mgp->irq_deassert = (__iomem __be32 *) (mgp->sram + cmd.data0);
713 718
714 } 719 }
715 status |= myri10ge_send_cmd 720 status |= myri10ge_send_cmd
716 (mgp, MXGEFW_CMD_GET_INTR_COAL_DELAY_OFFSET, &cmd, 0); 721 (mgp, MXGEFW_CMD_GET_INTR_COAL_DELAY_OFFSET, &cmd, 0);
717 mgp->intr_coal_delay_ptr = (__iomem u32 *) (mgp->sram + cmd.data0); 722 mgp->intr_coal_delay_ptr = (__iomem __be32 *) (mgp->sram + cmd.data0);
718 if (status != 0) { 723 if (status != 0) {
719 dev_err(&mgp->pdev->dev, "failed set interrupt parameters\n"); 724 dev_err(&mgp->pdev->dev, "failed set interrupt parameters\n");
720 return status; 725 return status;
721 } 726 }
722 __raw_writel(htonl(mgp->intr_coal_delay), mgp->intr_coal_delay_ptr); 727 put_be32(htonl(mgp->intr_coal_delay), mgp->intr_coal_delay_ptr);
723 728
724 /* Run a small DMA test. 729 /* Run a small DMA test.
725 * The magic multipliers to the length tell the firmware 730 * The magic multipliers to the length tell the firmware
@@ -786,14 +791,16 @@ static inline void
786myri10ge_submit_8rx(struct mcp_kreq_ether_recv __iomem * dst, 791myri10ge_submit_8rx(struct mcp_kreq_ether_recv __iomem * dst,
787 struct mcp_kreq_ether_recv *src) 792 struct mcp_kreq_ether_recv *src)
788{ 793{
789 u32 low; 794 __be32 low;
790 795
791 low = src->addr_low; 796 low = src->addr_low;
792 src->addr_low = DMA_32BIT_MASK; 797 src->addr_low = htonl(DMA_32BIT_MASK);
793 myri10ge_pio_copy(dst, src, 8 * sizeof(*src)); 798 myri10ge_pio_copy(dst, src, 4 * sizeof(*src));
799 mb();
800 myri10ge_pio_copy(dst + 4, src + 4, 4 * sizeof(*src));
794 mb(); 801 mb();
795 src->addr_low = low; 802 src->addr_low = low;
796 __raw_writel(low, &dst->addr_low); 803 put_be32(low, &dst->addr_low);
797 mb(); 804 mb();
798} 805}
799 806
@@ -939,11 +946,11 @@ done:
939 return retval; 946 return retval;
940} 947}
941 948
942static inline void myri10ge_vlan_ip_csum(struct sk_buff *skb, u16 hw_csum) 949static inline void myri10ge_vlan_ip_csum(struct sk_buff *skb, __wsum hw_csum)
943{ 950{
944 struct vlan_hdr *vh = (struct vlan_hdr *)(skb->data); 951 struct vlan_hdr *vh = (struct vlan_hdr *)(skb->data);
945 952
946 if ((skb->protocol == ntohs(ETH_P_8021Q)) && 953 if ((skb->protocol == htons(ETH_P_8021Q)) &&
947 (vh->h_vlan_encapsulated_proto == htons(ETH_P_IP) || 954 (vh->h_vlan_encapsulated_proto == htons(ETH_P_IP) ||
948 vh->h_vlan_encapsulated_proto == htons(ETH_P_IPV6))) { 955 vh->h_vlan_encapsulated_proto == htons(ETH_P_IPV6))) {
949 skb->csum = hw_csum; 956 skb->csum = hw_csum;
@@ -953,7 +960,7 @@ static inline void myri10ge_vlan_ip_csum(struct sk_buff *skb, u16 hw_csum)
953 960
954static inline unsigned long 961static inline unsigned long
955myri10ge_rx_done(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx, 962myri10ge_rx_done(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx,
956 int bytes, int len, int csum) 963 int bytes, int len, __wsum csum)
957{ 964{
958 dma_addr_t bus; 965 dma_addr_t bus;
959 struct sk_buff *skb; 966 struct sk_buff *skb;
@@ -986,12 +993,12 @@ myri10ge_rx_done(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx,
986 993
987 skb->protocol = eth_type_trans(skb, mgp->dev); 994 skb->protocol = eth_type_trans(skb, mgp->dev);
988 if (mgp->csum_flag) { 995 if (mgp->csum_flag) {
989 if ((skb->protocol == ntohs(ETH_P_IP)) || 996 if ((skb->protocol == htons(ETH_P_IP)) ||
990 (skb->protocol == ntohs(ETH_P_IPV6))) { 997 (skb->protocol == htons(ETH_P_IPV6))) {
991 skb->csum = ntohs((u16) csum); 998 skb->csum = csum;
992 skb->ip_summed = CHECKSUM_COMPLETE; 999 skb->ip_summed = CHECKSUM_COMPLETE;
993 } else 1000 } else
994 myri10ge_vlan_ip_csum(skb, ntohs((u16) csum)); 1001 myri10ge_vlan_ip_csum(skb, csum);
995 } 1002 }
996 1003
997 netif_receive_skb(skb); 1004 netif_receive_skb(skb);
@@ -1060,12 +1067,12 @@ static inline void myri10ge_clean_rx_done(struct myri10ge_priv *mgp, int *limit)
1060 int idx = rx_done->idx; 1067 int idx = rx_done->idx;
1061 int cnt = rx_done->cnt; 1068 int cnt = rx_done->cnt;
1062 u16 length; 1069 u16 length;
1063 u16 checksum; 1070 __wsum checksum;
1064 1071
1065 while (rx_done->entry[idx].length != 0 && *limit != 0) { 1072 while (rx_done->entry[idx].length != 0 && *limit != 0) {
1066 length = ntohs(rx_done->entry[idx].length); 1073 length = ntohs(rx_done->entry[idx].length);
1067 rx_done->entry[idx].length = 0; 1074 rx_done->entry[idx].length = 0;
1068 checksum = ntohs(rx_done->entry[idx].checksum); 1075 checksum = csum_unfold(rx_done->entry[idx].checksum);
1069 if (length <= mgp->small_bytes) 1076 if (length <= mgp->small_bytes)
1070 rx_ok = myri10ge_rx_done(mgp, &mgp->rx_small, 1077 rx_ok = myri10ge_rx_done(mgp, &mgp->rx_small,
1071 mgp->small_bytes, 1078 mgp->small_bytes,
@@ -1142,7 +1149,7 @@ static int myri10ge_poll(struct net_device *netdev, int *budget)
1142 1149
1143 if (rx_done->entry[rx_done->idx].length == 0 || !netif_running(netdev)) { 1150 if (rx_done->entry[rx_done->idx].length == 0 || !netif_running(netdev)) {
1144 netif_rx_complete(netdev); 1151 netif_rx_complete(netdev);
1145 __raw_writel(htonl(3), mgp->irq_claim); 1152 put_be32(htonl(3), mgp->irq_claim);
1146 return 0; 1153 return 0;
1147 } 1154 }
1148 return 1; 1155 return 1;
@@ -1166,7 +1173,7 @@ static irqreturn_t myri10ge_intr(int irq, void *arg)
1166 netif_rx_schedule(mgp->dev); 1173 netif_rx_schedule(mgp->dev);
1167 1174
1168 if (!mgp->msi_enabled) { 1175 if (!mgp->msi_enabled) {
1169 __raw_writel(0, mgp->irq_deassert); 1176 put_be32(0, mgp->irq_deassert);
1170 if (!myri10ge_deassert_wait) 1177 if (!myri10ge_deassert_wait)
1171 stats->valid = 0; 1178 stats->valid = 0;
1172 mb(); 1179 mb();
@@ -1195,7 +1202,7 @@ static irqreturn_t myri10ge_intr(int irq, void *arg)
1195 1202
1196 myri10ge_check_statblock(mgp); 1203 myri10ge_check_statblock(mgp);
1197 1204
1198 __raw_writel(htonl(3), mgp->irq_claim + 1); 1205 put_be32(htonl(3), mgp->irq_claim + 1);
1199 return (IRQ_HANDLED); 1206 return (IRQ_HANDLED);
1200} 1207}
1201 1208
@@ -1233,7 +1240,7 @@ myri10ge_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *coal)
1233 struct myri10ge_priv *mgp = netdev_priv(netdev); 1240 struct myri10ge_priv *mgp = netdev_priv(netdev);
1234 1241
1235 mgp->intr_coal_delay = coal->rx_coalesce_usecs; 1242 mgp->intr_coal_delay = coal->rx_coalesce_usecs;
1236 __raw_writel(htonl(mgp->intr_coal_delay), mgp->intr_coal_delay_ptr); 1243 put_be32(htonl(mgp->intr_coal_delay), mgp->intr_coal_delay_ptr);
1237 return 0; 1244 return 0;
1238} 1245}
1239 1246
@@ -1748,7 +1755,7 @@ static int myri10ge_open(struct net_device *dev)
1748 goto abort_with_rings; 1755 goto abort_with_rings;
1749 } 1756 }
1750 1757
1751 mgp->link_state = -1; 1758 mgp->link_state = htonl(~0U);
1752 mgp->rdma_tags_available = 15; 1759 mgp->rdma_tags_available = 15;
1753 1760
1754 netif_poll_enable(mgp->dev); /* must happen prior to any irq */ 1761 netif_poll_enable(mgp->dev); /* must happen prior to any irq */
@@ -1876,7 +1883,7 @@ myri10ge_submit_req(struct myri10ge_tx_buf *tx, struct mcp_kreq_ether_send *src,
1876 1883
1877 /* re-write the last 32-bits with the valid flags */ 1884 /* re-write the last 32-bits with the valid flags */
1878 src->flags = last_flags; 1885 src->flags = last_flags;
1879 __raw_writel(*((u32 *) src + 3), (u32 __iomem *) dst + 3); 1886 put_be32(*((__be32 *) src + 3), (__be32 __iomem *) dst + 3);
1880 tx->req += cnt; 1887 tx->req += cnt;
1881 mb(); 1888 mb();
1882} 1889}
@@ -1919,7 +1926,8 @@ static int myri10ge_xmit(struct sk_buff *skb, struct net_device *dev)
1919 struct myri10ge_tx_buf *tx = &mgp->tx; 1926 struct myri10ge_tx_buf *tx = &mgp->tx;
1920 struct skb_frag_struct *frag; 1927 struct skb_frag_struct *frag;
1921 dma_addr_t bus; 1928 dma_addr_t bus;
1922 u32 low, high_swapped; 1929 u32 low;
1930 __be32 high_swapped;
1923 unsigned int len; 1931 unsigned int len;
1924 int idx, last_idx, avail, frag_cnt, frag_idx, count, mss, max_segments; 1932 int idx, last_idx, avail, frag_cnt, frag_idx, count, mss, max_segments;
1925 u16 pseudo_hdr_offset, cksum_offset; 1933 u16 pseudo_hdr_offset, cksum_offset;
@@ -1955,7 +1963,7 @@ again:
1955 flags = (MXGEFW_FLAGS_NO_TSO | MXGEFW_FLAGS_FIRST); 1963 flags = (MXGEFW_FLAGS_NO_TSO | MXGEFW_FLAGS_FIRST);
1956 if (likely(skb->ip_summed == CHECKSUM_PARTIAL)) { 1964 if (likely(skb->ip_summed == CHECKSUM_PARTIAL)) {
1957 cksum_offset = (skb->h.raw - skb->data); 1965 cksum_offset = (skb->h.raw - skb->data);
1958 pseudo_hdr_offset = (skb->h.raw + skb->csum) - skb->data; 1966 pseudo_hdr_offset = cksum_offset + skb->csum_offset;
1959 /* If the headers are excessively large, then we must 1967 /* If the headers are excessively large, then we must
1960 * fall back to a software checksum */ 1968 * fall back to a software checksum */
1961 if (unlikely(cksum_offset > 255 || pseudo_hdr_offset > 127)) { 1969 if (unlikely(cksum_offset > 255 || pseudo_hdr_offset > 127)) {
@@ -1964,7 +1972,6 @@ again:
1964 cksum_offset = 0; 1972 cksum_offset = 0;
1965 pseudo_hdr_offset = 0; 1973 pseudo_hdr_offset = 0;
1966 } else { 1974 } else {
1967 pseudo_hdr_offset = htons(pseudo_hdr_offset);
1968 odd_flag = MXGEFW_FLAGS_ALIGN_ODD; 1975 odd_flag = MXGEFW_FLAGS_ALIGN_ODD;
1969 flags |= MXGEFW_FLAGS_CKSUM; 1976 flags |= MXGEFW_FLAGS_CKSUM;
1970 } 1977 }
@@ -1986,7 +1993,7 @@ again:
1986 /* for TSO, pseudo_hdr_offset holds mss. 1993 /* for TSO, pseudo_hdr_offset holds mss.
1987 * The firmware figures out where to put 1994 * The firmware figures out where to put
1988 * the checksum by parsing the header. */ 1995 * the checksum by parsing the header. */
1989 pseudo_hdr_offset = htons(mss); 1996 pseudo_hdr_offset = mss;
1990 } else 1997 } else
1991#endif /*NETIF_F_TSO */ 1998#endif /*NETIF_F_TSO */
1992 /* Mark small packets, and pad out tiny packets */ 1999 /* Mark small packets, and pad out tiny packets */
@@ -2086,7 +2093,7 @@ again:
2086#endif /* NETIF_F_TSO */ 2093#endif /* NETIF_F_TSO */
2087 req->addr_high = high_swapped; 2094 req->addr_high = high_swapped;
2088 req->addr_low = htonl(low); 2095 req->addr_low = htonl(low);
2089 req->pseudo_hdr_offset = pseudo_hdr_offset; 2096 req->pseudo_hdr_offset = htons(pseudo_hdr_offset);
2090 req->pad = 0; /* complete solid 16-byte block; does this matter? */ 2097 req->pad = 0; /* complete solid 16-byte block; does this matter? */
2091 req->rdma_count = 1; 2098 req->rdma_count = 1;
2092 req->length = htons(seglen); 2099 req->length = htons(seglen);
@@ -2199,6 +2206,7 @@ static void myri10ge_set_multicast_list(struct net_device *dev)
2199 struct myri10ge_cmd cmd; 2206 struct myri10ge_cmd cmd;
2200 struct myri10ge_priv *mgp; 2207 struct myri10ge_priv *mgp;
2201 struct dev_mc_list *mc_list; 2208 struct dev_mc_list *mc_list;
2209 __be32 data[2] = {0, 0};
2202 int err; 2210 int err;
2203 2211
2204 mgp = netdev_priv(dev); 2212 mgp = netdev_priv(dev);
@@ -2237,10 +2245,9 @@ static void myri10ge_set_multicast_list(struct net_device *dev)
2237 2245
2238 /* Walk the multicast list, and add each address */ 2246 /* Walk the multicast list, and add each address */
2239 for (mc_list = dev->mc_list; mc_list != NULL; mc_list = mc_list->next) { 2247 for (mc_list = dev->mc_list; mc_list != NULL; mc_list = mc_list->next) {
2240 memcpy(&cmd.data0, &mc_list->dmi_addr, 4); 2248 memcpy(data, &mc_list->dmi_addr, 6);
2241 memcpy(&cmd.data1, ((char *)&mc_list->dmi_addr) + 4, 2); 2249 cmd.data0 = ntohl(data[0]);
2242 cmd.data0 = htonl(cmd.data0); 2250 cmd.data1 = ntohl(data[1]);
2243 cmd.data1 = htonl(cmd.data1);
2244 err = myri10ge_send_cmd(mgp, MXGEFW_JOIN_MULTICAST_GROUP, 2251 err = myri10ge_send_cmd(mgp, MXGEFW_JOIN_MULTICAST_GROUP,
2245 &cmd, 1); 2252 &cmd, 1);
2246 2253
@@ -2615,9 +2622,10 @@ static u32 myri10ge_read_reboot(struct myri10ge_priv *mgp)
2615 * This watchdog is used to check whether the board has suffered 2622 * This watchdog is used to check whether the board has suffered
2616 * from a parity error and needs to be recovered. 2623 * from a parity error and needs to be recovered.
2617 */ 2624 */
2618static void myri10ge_watchdog(void *arg) 2625static void myri10ge_watchdog(struct work_struct *work)
2619{ 2626{
2620 struct myri10ge_priv *mgp = arg; 2627 struct myri10ge_priv *mgp =
2628 container_of(work, struct myri10ge_priv, watchdog_work);
2621 u32 reboot; 2629 u32 reboot;
2622 int status; 2630 int status;
2623 u16 cmd, vendor; 2631 u16 cmd, vendor;
@@ -2887,7 +2895,7 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
2887 (unsigned long)mgp); 2895 (unsigned long)mgp);
2888 2896
2889 SET_ETHTOOL_OPS(netdev, &myri10ge_ethtool_ops); 2897 SET_ETHTOOL_OPS(netdev, &myri10ge_ethtool_ops);
2890 INIT_WORK(&mgp->watchdog_work, myri10ge_watchdog, mgp); 2898 INIT_WORK(&mgp->watchdog_work, myri10ge_watchdog);
2891 status = register_netdev(netdev); 2899 status = register_netdev(netdev);
2892 if (status != 0) { 2900 if (status != 0) {
2893 dev_err(&pdev->dev, "register_netdev failed: %d\n", status); 2901 dev_err(&pdev->dev, "register_netdev failed: %d\n", status);
diff --git a/drivers/net/myri10ge/myri10ge_mcp.h b/drivers/net/myri10ge/myri10ge_mcp.h
index 9519ae7cd5ec..29463b301a84 100644
--- a/drivers/net/myri10ge/myri10ge_mcp.h
+++ b/drivers/net/myri10ge/myri10ge_mcp.h
@@ -6,23 +6,23 @@
6 6
7/* 8 Bytes */ 7/* 8 Bytes */
8struct mcp_dma_addr { 8struct mcp_dma_addr {
9 u32 high; 9 __be32 high;
10 u32 low; 10 __be32 low;
11}; 11};
12 12
13/* 4 Bytes */ 13/* 4 Bytes */
14struct mcp_slot { 14struct mcp_slot {
15 u16 checksum; 15 __sum16 checksum;
16 u16 length; 16 __be16 length;
17}; 17};
18 18
19/* 64 Bytes */ 19/* 64 Bytes */
20struct mcp_cmd { 20struct mcp_cmd {
21 u32 cmd; 21 __be32 cmd;
22 u32 data0; /* will be low portion if data > 32 bits */ 22 __be32 data0; /* will be low portion if data > 32 bits */
23 /* 8 */ 23 /* 8 */
24 u32 data1; /* will be high portion if data > 32 bits */ 24 __be32 data1; /* will be high portion if data > 32 bits */
25 u32 data2; /* currently unused.. */ 25 __be32 data2; /* currently unused.. */
26 /* 16 */ 26 /* 16 */
27 struct mcp_dma_addr response_addr; 27 struct mcp_dma_addr response_addr;
28 /* 24 */ 28 /* 24 */
@@ -31,8 +31,8 @@ struct mcp_cmd {
31 31
32/* 8 Bytes */ 32/* 8 Bytes */
33struct mcp_cmd_response { 33struct mcp_cmd_response {
34 u32 data; 34 __be32 data;
35 u32 result; 35 __be32 result;
36}; 36};
37 37
38/* 38/*
@@ -73,10 +73,10 @@ union mcp_pso_or_cumlen {
73 73
74/* 16 Bytes */ 74/* 16 Bytes */
75struct mcp_kreq_ether_send { 75struct mcp_kreq_ether_send {
76 u32 addr_high; 76 __be32 addr_high;
77 u32 addr_low; 77 __be32 addr_low;
78 u16 pseudo_hdr_offset; 78 __be16 pseudo_hdr_offset;
79 u16 length; 79 __be16 length;
80 u8 pad; 80 u8 pad;
81 u8 rdma_count; 81 u8 rdma_count;
82 u8 cksum_offset; /* where to start computing cksum */ 82 u8 cksum_offset; /* where to start computing cksum */
@@ -85,8 +85,8 @@ struct mcp_kreq_ether_send {
85 85
86/* 8 Bytes */ 86/* 8 Bytes */
87struct mcp_kreq_ether_recv { 87struct mcp_kreq_ether_recv {
88 u32 addr_high; 88 __be32 addr_high;
89 u32 addr_low; 89 __be32 addr_low;
90}; 90};
91 91
92/* Commands */ 92/* Commands */
@@ -219,19 +219,19 @@ enum myri10ge_mcp_cmd_status {
219 219
220struct mcp_irq_data { 220struct mcp_irq_data {
221 /* add new counters at the beginning */ 221 /* add new counters at the beginning */
222 u32 future_use[5]; 222 __be32 future_use[5];
223 u32 dropped_multicast_filtered; 223 __be32 dropped_multicast_filtered;
224 /* 40 Bytes */ 224 /* 40 Bytes */
225 u32 send_done_count; 225 __be32 send_done_count;
226 226
227 u32 link_up; 227 __be32 link_up;
228 u32 dropped_link_overflow; 228 __be32 dropped_link_overflow;
229 u32 dropped_link_error_or_filtered; 229 __be32 dropped_link_error_or_filtered;
230 u32 dropped_runt; 230 __be32 dropped_runt;
231 u32 dropped_overrun; 231 __be32 dropped_overrun;
232 u32 dropped_no_small_buffer; 232 __be32 dropped_no_small_buffer;
233 u32 dropped_no_big_buffer; 233 __be32 dropped_no_big_buffer;
234 u32 rdma_tags_available; 234 __be32 rdma_tags_available;
235 235
236 u8 tx_stopped; 236 u8 tx_stopped;
237 u8 link_down; 237 u8 link_down;
diff --git a/drivers/net/myri10ge/myri10ge_mcp_gen_header.h b/drivers/net/myri10ge/myri10ge_mcp_gen_header.h
index 487f7792fd46..16a810dd6d51 100644
--- a/drivers/net/myri10ge/myri10ge_mcp_gen_header.h
+++ b/drivers/net/myri10ge/myri10ge_mcp_gen_header.h
@@ -36,7 +36,7 @@
36struct mcp_gen_header { 36struct mcp_gen_header {
37 /* the first 4 fields are filled at compile time */ 37 /* the first 4 fields are filled at compile time */
38 unsigned header_length; 38 unsigned header_length;
39 unsigned mcp_type; 39 __be32 mcp_type;
40 char version[128]; 40 char version[128];
41 unsigned mcp_globals; /* pointer to mcp-type specific structure */ 41 unsigned mcp_globals; /* pointer to mcp-type specific structure */
42 42
diff --git a/drivers/net/myri_sbus.c b/drivers/net/myri_sbus.c
index 7747bfd99f91..ee26ef52289f 100644
--- a/drivers/net/myri_sbus.c
+++ b/drivers/net/myri_sbus.c
@@ -39,7 +39,6 @@ static char version[] =
39#include <asm/auxio.h> 39#include <asm/auxio.h>
40#include <asm/pgtable.h> 40#include <asm/pgtable.h>
41#include <asm/irq.h> 41#include <asm/irq.h>
42#include <asm/checksum.h>
43 42
44#include "myri_sbus.h" 43#include "myri_sbus.h"
45#include "myri_code.h" 44#include "myri_code.h"
diff --git a/drivers/net/ne-h8300.c b/drivers/net/ne-h8300.c
index eb893d7e8834..38fd525f0f13 100644
--- a/drivers/net/ne-h8300.c
+++ b/drivers/net/ne-h8300.c
@@ -33,6 +33,8 @@ static const char version1[] =
33#include <asm/io.h> 33#include <asm/io.h>
34#include <asm/irq.h> 34#include <asm/irq.h>
35 35
36#define EI_SHIFT(x) (ei_local->reg_offset[x])
37
36#include "8390.h" 38#include "8390.h"
37 39
38#define DRV_NAME "ne-h8300" 40#define DRV_NAME "ne-h8300"
@@ -52,6 +54,11 @@ static const char version1[] =
52 54
53/* ---- No user-serviceable parts below ---- */ 55/* ---- No user-serviceable parts below ---- */
54 56
57static const char version[] =
58 "8390.c:v1.10cvs 9/23/94 Donald Becker (becker@cesdis.gsfc.nasa.gov)\n";
59
60#include "lib8390.c"
61
55#define NE_BASE (dev->base_addr) 62#define NE_BASE (dev->base_addr)
56#define NE_CMD 0x00 63#define NE_CMD 0x00
57#define NE_DATAPORT (ei_status.word16?0x20:0x10) /* NatSemi-defined port window offset. */ 64#define NE_DATAPORT (ei_status.word16?0x20:0x10) /* NatSemi-defined port window offset. */
@@ -162,7 +169,7 @@ static void cleanup_card(struct net_device *dev)
162#ifndef MODULE 169#ifndef MODULE
163struct net_device * __init ne_probe(int unit) 170struct net_device * __init ne_probe(int unit)
164{ 171{
165 struct net_device *dev = alloc_ei_netdev(); 172 struct net_device *dev = ____alloc_ei_netdev(0);
166 int err; 173 int err;
167 174
168 if (!dev) 175 if (!dev)
@@ -283,7 +290,7 @@ static int __init ne_probe1(struct net_device *dev, int ioaddr)
283 290
284 /* Snarf the interrupt now. There's no point in waiting since we cannot 291 /* Snarf the interrupt now. There's no point in waiting since we cannot
285 share and the board will usually be enabled. */ 292 share and the board will usually be enabled. */
286 ret = request_irq(dev->irq, ei_interrupt, 0, name, dev); 293 ret = request_irq(dev->irq, __ei_interrupt, 0, name, dev);
287 if (ret) { 294 if (ret) {
288 printk (" unable to get IRQ %d (errno=%d).\n", dev->irq, ret); 295 printk (" unable to get IRQ %d (errno=%d).\n", dev->irq, ret);
289 goto err_out; 296 goto err_out;
@@ -318,9 +325,9 @@ static int __init ne_probe1(struct net_device *dev, int ioaddr)
318 dev->open = &ne_open; 325 dev->open = &ne_open;
319 dev->stop = &ne_close; 326 dev->stop = &ne_close;
320#ifdef CONFIG_NET_POLL_CONTROLLER 327#ifdef CONFIG_NET_POLL_CONTROLLER
321 dev->poll_controller = ei_poll; 328 dev->poll_controller = __ei_poll;
322#endif 329#endif
323 NS8390_init(dev, 0); 330 __NS8390_init(dev, 0);
324 331
325 ret = register_netdev(dev); 332 ret = register_netdev(dev);
326 if (ret) 333 if (ret)
@@ -335,7 +342,7 @@ err_out:
335 342
336static int ne_open(struct net_device *dev) 343static int ne_open(struct net_device *dev)
337{ 344{
338 ei_open(dev); 345 __ei_open(dev);
339 return 0; 346 return 0;
340} 347}
341 348
@@ -343,7 +350,7 @@ static int ne_close(struct net_device *dev)
343{ 350{
344 if (ei_debug > 1) 351 if (ei_debug > 1)
345 printk(KERN_DEBUG "%s: Shutting down ethercard.\n", dev->name); 352 printk(KERN_DEBUG "%s: Shutting down ethercard.\n", dev->name);
346 ei_close(dev); 353 __ei_close(dev);
347 return 0; 354 return 0;
348} 355}
349 356
@@ -584,7 +591,7 @@ retry:
584 if (time_after(jiffies, dma_start + 2*HZ/100)) { /* 20ms */ 591 if (time_after(jiffies, dma_start + 2*HZ/100)) { /* 20ms */
585 printk(KERN_WARNING "%s: timeout waiting for Tx RDC.\n", dev->name); 592 printk(KERN_WARNING "%s: timeout waiting for Tx RDC.\n", dev->name);
586 ne_reset_8390(dev); 593 ne_reset_8390(dev);
587 NS8390_init(dev,1); 594 __NS8390_init(dev,1);
588 break; 595 break;
589 } 596 }
590 597
@@ -620,7 +627,7 @@ int init_module(void)
620 int err; 627 int err;
621 628
622 for (this_dev = 0; this_dev < MAX_NE_CARDS; this_dev++) { 629 for (this_dev = 0; this_dev < MAX_NE_CARDS; this_dev++) {
623 struct net_device *dev = alloc_ei_netdev(); 630 struct net_device *dev = ____alloc_ei_netdev(0);
624 if (!dev) 631 if (!dev)
625 break; 632 break;
626 if (io[this_dev]) { 633 if (io[this_dev]) {
diff --git a/drivers/net/ne.c b/drivers/net/ne.c
index 787aa4221528..a5c4199e2754 100644
--- a/drivers/net/ne.c
+++ b/drivers/net/ne.c
@@ -867,7 +867,7 @@ static void cleanup_card(struct net_device *dev)
867 release_region(dev->base_addr, NE_IO_EXTENT); 867 release_region(dev->base_addr, NE_IO_EXTENT);
868} 868}
869 869
870void cleanup_module(void) 870void __exit cleanup_module(void)
871{ 871{
872 int this_dev; 872 int this_dev;
873 873
diff --git a/drivers/net/ne2.c b/drivers/net/ne2.c
index 5fccfea66d87..089b5bb702fc 100644
--- a/drivers/net/ne2.c
+++ b/drivers/net/ne2.c
@@ -813,7 +813,7 @@ static void cleanup_card(struct net_device *dev)
813 release_region(dev->base_addr, NE_IO_EXTENT); 813 release_region(dev->base_addr, NE_IO_EXTENT);
814} 814}
815 815
816void cleanup_module(void) 816void __exit cleanup_module(void)
817{ 817{
818 int this_dev; 818 int this_dev;
819 819
diff --git a/drivers/net/ne3210.c b/drivers/net/ne3210.c
index d66328975425..1a6fed76d4cc 100644
--- a/drivers/net/ne3210.c
+++ b/drivers/net/ne3210.c
@@ -36,6 +36,7 @@
36#include <linux/interrupt.h> 36#include <linux/interrupt.h>
37#include <linux/netdevice.h> 37#include <linux/netdevice.h>
38#include <linux/etherdevice.h> 38#include <linux/etherdevice.h>
39#include <linux/mm.h>
39 40
40#include <asm/io.h> 41#include <asm/io.h>
41#include <asm/system.h> 42#include <asm/system.h>
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index bf58db29e2ed..69233f6aa05c 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -60,7 +60,6 @@ static struct netpoll np = {
60 .local_port = 6665, 60 .local_port = 6665,
61 .remote_port = 6666, 61 .remote_port = 6666,
62 .remote_mac = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, 62 .remote_mac = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
63 .drop = netpoll_queue,
64}; 63};
65static int configured = 0; 64static int configured = 0;
66 65
@@ -102,6 +101,8 @@ __setup("netconsole=", option_setup);
102 101
103static int init_netconsole(void) 102static int init_netconsole(void)
104{ 103{
104 int err;
105
105 if(strlen(config)) 106 if(strlen(config))
106 option_setup(config); 107 option_setup(config);
107 108
@@ -110,8 +111,9 @@ static int init_netconsole(void)
110 return 0; 111 return 0;
111 } 112 }
112 113
113 if(netpoll_setup(&np)) 114 err = netpoll_setup(&np);
114 return -EINVAL; 115 if (err)
116 return err;
115 117
116 register_console(&netconsole); 118 register_console(&netconsole);
117 printk(KERN_INFO "netconsole: network logging started\n"); 119 printk(KERN_INFO "netconsole: network logging started\n");
diff --git a/drivers/net/netxen/Makefile b/drivers/net/netxen/Makefile
new file mode 100644
index 000000000000..a07cdc6f7384
--- /dev/null
+++ b/drivers/net/netxen/Makefile
@@ -0,0 +1,35 @@
1# Copyright (C) 2003 - 2006 NetXen, Inc.
2# All rights reserved.
3#
4# This program is free software; you can redistribute it and/or
5# modify it under the terms of the GNU General Public License
6# as published by the Free Software Foundation; either version 2
7# of the License, or (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful, but
10# WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program; if not, write to the Free Software
16# Foundation, Inc., 59 Temple Place - Suite 330, Boston,
17# MA 02111-1307, USA.
18#
19# The full GNU General Public License is included in this distribution
20# in the file called LICENSE.
21#
22# Contact Information:
23# info@netxen.com
24# NetXen,
25# 3965 Freedom Circle, Fourth floor,
26# Santa Clara, CA 95054
27#
28# Makefile for the NetXen NIC Driver
29#
30
31
32obj-$(CONFIG_NETXEN_NIC) := netxen_nic.o
33
34netxen_nic-y := netxen_nic_hw.o netxen_nic_main.o netxen_nic_init.o \
35 netxen_nic_isr.o netxen_nic_ethtool.o netxen_nic_niu.o
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
new file mode 100644
index 000000000000..b5410bee5f21
--- /dev/null
+++ b/drivers/net/netxen/netxen_nic.h
@@ -0,0 +1,1180 @@
1/*
2 * Copyright (C) 2003 - 2006 NetXen, Inc.
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 * MA 02111-1307, USA.
19 *
20 * The full GNU General Public License is included in this distribution
21 * in the file called LICENSE.
22 *
23 * Contact Information:
24 * info@netxen.com
25 * NetXen,
26 * 3965 Freedom Circle, Fourth floor,
27 * Santa Clara, CA 95054
28 */
29
30#ifndef _NETXEN_NIC_H_
31#define _NETXEN_NIC_H_
32
33#include <linux/module.h>
34#include <linux/kernel.h>
35#include <linux/types.h>
36#include <linux/compiler.h>
37#include <linux/slab.h>
38#include <linux/delay.h>
39#include <linux/init.h>
40#include <linux/ioport.h>
41#include <linux/pci.h>
42#include <linux/netdevice.h>
43#include <linux/etherdevice.h>
44#include <linux/ip.h>
45#include <linux/in.h>
46#include <linux/tcp.h>
47#include <linux/skbuff.h>
48#include <linux/version.h>
49
50#include <linux/ethtool.h>
51#include <linux/mii.h>
52#include <linux/interrupt.h>
53#include <linux/timer.h>
54
55#include <linux/mm.h>
56#include <linux/mman.h>
57
58#include <asm/system.h>
59#include <asm/io.h>
60#include <asm/byteorder.h>
61#include <asm/uaccess.h>
62#include <asm/pgtable.h>
63
64#include "netxen_nic_hw.h"
65
66#define NETXEN_NIC_BUILD_NO "1"
67#define _NETXEN_NIC_LINUX_MAJOR 3
68#define _NETXEN_NIC_LINUX_MINOR 3
69#define _NETXEN_NIC_LINUX_SUBVERSION 2
70#define NETXEN_NIC_LINUX_VERSIONID "3.3.2" "-" NETXEN_NIC_BUILD_NO
71#define NETXEN_NIC_FW_VERSIONID "3.3.2"
72
73#define RCV_DESC_RINGSIZE \
74 (sizeof(struct rcv_desc) * adapter->max_rx_desc_count)
75#define STATUS_DESC_RINGSIZE \
76 (sizeof(struct status_desc)* adapter->max_rx_desc_count)
77#define LRO_DESC_RINGSIZE \
78 (sizeof(rcvDesc_t) * adapter->max_lro_rx_desc_count)
79#define TX_RINGSIZE \
80 (sizeof(struct netxen_cmd_buffer) * adapter->max_tx_desc_count)
81#define RCV_BUFFSIZE \
82 (sizeof(struct netxen_rx_buffer) * rcv_desc->max_rx_desc_count)
83#define find_diff_among(a,b,range) ((a)<(b)?((b)-(a)):((b)+(range)-(a)))
84
85#define NETXEN_NETDEV_STATUS 0x1
86#define NETXEN_RCV_PRODUCER_OFFSET 0
87#define NETXEN_RCV_PEG_DB_ID 2
88#define NETXEN_HOST_DUMMY_DMA_SIZE 1024
89
90#define ADDR_IN_WINDOW1(off) \
91 ((off > NETXEN_CRB_PCIX_HOST2) && (off < NETXEN_CRB_MAX)) ? 1 : 0
92/*
93 * In netxen_nic_down(), we must wait for any pending callback requests into
94 * netxen_watchdog_task() to complete; eg otherwise the watchdog_timer could be
95 * reenabled right after it is deleted in netxen_nic_down(). FLUSH_SCHEDULED_WORK()
96 * does this synchronization.
97 *
98 * Normally, schedule_work()/flush_scheduled_work() could have worked, but
99 * netxen_nic_close() is invoked with kernel rtnl lock held. netif_carrier_off()
100 * call in netxen_nic_close() triggers a schedule_work(&linkwatch_work), and a
101 * subsequent call to flush_scheduled_work() in netxen_nic_down() would cause
102 * linkwatch_event() to be executed which also attempts to acquire the rtnl
103 * lock thus causing a deadlock.
104 */
105
106#define SCHEDULE_WORK(tp) queue_work(netxen_workq, tp)
107#define FLUSH_SCHEDULED_WORK() flush_workqueue(netxen_workq)
108extern struct workqueue_struct *netxen_workq;
109
110/*
111 * normalize a 64MB crb address to 32MB PCI window
112 * To use NETXEN_CRB_NORMALIZE, window _must_ be set to 1
113 */
114#define NETXEN_CRB_NORMAL(reg) \
115 ((reg) - NETXEN_CRB_PCIX_HOST2 + NETXEN_CRB_PCIX_HOST)
116
117#define NETXEN_CRB_NORMALIZE(adapter, reg) \
118 pci_base_offset(adapter, NETXEN_CRB_NORMAL(reg))
119
120#define DB_NORMALIZE(adapter, off) \
121 (adapter->ahw.db_base + (off))
122
123#define NX_P2_C0 0x24
124#define NX_P2_C1 0x25
125
126#define FIRST_PAGE_GROUP_START 0
127#define FIRST_PAGE_GROUP_END 0x100000
128
129#define SECOND_PAGE_GROUP_START 0x4000000
130#define SECOND_PAGE_GROUP_END 0x66BC000
131
132#define THIRD_PAGE_GROUP_START 0x70E4000
133#define THIRD_PAGE_GROUP_END 0x8000000
134
135#define FIRST_PAGE_GROUP_SIZE FIRST_PAGE_GROUP_END - FIRST_PAGE_GROUP_START
136#define SECOND_PAGE_GROUP_SIZE SECOND_PAGE_GROUP_END - SECOND_PAGE_GROUP_START
137#define THIRD_PAGE_GROUP_SIZE THIRD_PAGE_GROUP_END - THIRD_PAGE_GROUP_START
138
139#define MAX_RX_BUFFER_LENGTH 1760
140#define MAX_RX_JUMBO_BUFFER_LENGTH 9046
141#define MAX_RX_LRO_BUFFER_LENGTH ((48*1024)-512)
142#define RX_DMA_MAP_LEN (MAX_RX_BUFFER_LENGTH - 2)
143#define RX_JUMBO_DMA_MAP_LEN \
144 (MAX_RX_JUMBO_BUFFER_LENGTH - 2)
145#define RX_LRO_DMA_MAP_LEN (MAX_RX_LRO_BUFFER_LENGTH - 2)
146#define NETXEN_ROM_ROUNDUP 0x80000000ULL
147
148/*
149 * Maximum number of ring contexts
150 */
151#define MAX_RING_CTX 1
152
153/* Opcodes to be used with the commands */
154enum {
155 TX_ETHER_PKT = 0x01,
156/* The following opcodes are for IP checksum */
157 TX_TCP_PKT,
158 TX_UDP_PKT,
159 TX_IP_PKT,
160 TX_TCP_LSO,
161 TX_IPSEC,
162 TX_IPSEC_CMD
163};
164
165/* The following opcodes are for internal consumption. */
166#define NETXEN_CONTROL_OP 0x10
167#define PEGNET_REQUEST 0x11
168
169#define MAX_NUM_CARDS 4
170
171#define MAX_BUFFERS_PER_CMD 32
172
173/*
174 * Following are the states of the Phantom. Phantom will set them and
175 * Host will read to check if the fields are correct.
176 */
177#define PHAN_INITIALIZE_START 0xff00
178#define PHAN_INITIALIZE_FAILED 0xffff
179#define PHAN_INITIALIZE_COMPLETE 0xff01
180
181/* Host writes the following to notify that it has done the init-handshake */
182#define PHAN_INITIALIZE_ACK 0xf00f
183
184#define NUM_RCV_DESC_RINGS 3 /* No of Rcv Descriptor contexts */
185
186/* descriptor types */
187#define RCV_DESC_NORMAL 0x01
188#define RCV_DESC_JUMBO 0x02
189#define RCV_DESC_LRO 0x04
190#define RCV_DESC_NORMAL_CTXID 0
191#define RCV_DESC_JUMBO_CTXID 1
192#define RCV_DESC_LRO_CTXID 2
193
194#define RCV_DESC_TYPE(ID) \
195 ((ID == RCV_DESC_JUMBO_CTXID) \
196 ? RCV_DESC_JUMBO \
197 : ((ID == RCV_DESC_LRO_CTXID) \
198 ? RCV_DESC_LRO : \
199 (RCV_DESC_NORMAL)))
200
201#define MAX_CMD_DESCRIPTORS 1024
202#define MAX_RCV_DESCRIPTORS 32768
203#define MAX_JUMBO_RCV_DESCRIPTORS 4096
204#define MAX_LRO_RCV_DESCRIPTORS 2048
205#define MAX_RCVSTATUS_DESCRIPTORS MAX_RCV_DESCRIPTORS
206#define MAX_JUMBO_RCV_DESC MAX_JUMBO_RCV_DESCRIPTORS
207#define MAX_RCV_DESC MAX_RCV_DESCRIPTORS
208#define MAX_RCVSTATUS_DESC MAX_RCV_DESCRIPTORS
209#define MAX_EPG_DESCRIPTORS (MAX_CMD_DESCRIPTORS * 8)
210#define NUM_RCV_DESC (MAX_RCV_DESC + MAX_JUMBO_RCV_DESCRIPTORS + \
211 MAX_LRO_RCV_DESCRIPTORS)
212#define MIN_TX_COUNT 4096
213#define MIN_RX_COUNT 4096
214#define NETXEN_CTX_SIGNATURE 0xdee0
215#define NETXEN_RCV_PRODUCER(ringid) (ringid)
216#define MAX_FRAME_SIZE 0x10000 /* 64K MAX size for LSO */
217
218#define PHAN_PEG_RCV_INITIALIZED 0xff01
219#define PHAN_PEG_RCV_START_INITIALIZE 0xff00
220
221#define get_next_index(index, length) \
222 (((index) + 1) & ((length) - 1))
223
224#define get_index_range(index,length,count) \
225 (((index) + (count)) & ((length) - 1))
226
227#define MPORT_SINGLE_FUNCTION_MODE 0x1111
228
229extern unsigned long long netxen_dma_mask;
230
231/*
232 * NetXen host-peg signal message structure
233 *
234 * Bit 0-1 : peg_id => 0x2 for tx and 01 for rx
235 * Bit 2 : priv_id => must be 1
236 * Bit 3-17 : count => for doorbell
237 * Bit 18-27 : ctx_id => Context id
238 * Bit 28-31 : opcode
239 */
240
241typedef u32 netxen_ctx_msg;
242
243#define _netxen_set_bits(config_word, start, bits, val) {\
244 unsigned long long mask = (((1ULL << (bits)) - 1) << (start)); \
245 unsigned long long value = (val); \
246 (config_word) &= ~mask; \
247 (config_word) |= (((value) << (start)) & mask); \
248}
249
250#define netxen_set_msg_peg_id(config_word, val) \
251 _netxen_set_bits(config_word, 0, 2, val)
252#define netxen_set_msg_privid(config_word) \
253 set_bit(2, (unsigned long*)&config_word)
254#define netxen_set_msg_count(config_word, val) \
255 _netxen_set_bits(config_word, 3, 15, val)
256#define netxen_set_msg_ctxid(config_word, val) \
257 _netxen_set_bits(config_word, 18, 10, val)
258#define netxen_set_msg_opcode(config_word, val) \
259 _netxen_set_bits(config_word, 28, 4, val)
260
261struct netxen_rcv_context {
262 u32 rcv_ring_addr_lo;
263 u32 rcv_ring_addr_hi;
264 u32 rcv_ring_size;
265 u32 rsrvd;
266};
267
268struct netxen_ring_ctx {
269
270 /* one command ring */
271 u64 cmd_consumer_offset;
272 u32 cmd_ring_addr_lo;
273 u32 cmd_ring_addr_hi;
274 u32 cmd_ring_size;
275 u32 rsrvd;
276
277 /* three receive rings */
278 struct netxen_rcv_context rcv_ctx[3];
279
280 /* one status ring */
281 u32 sts_ring_addr_lo;
282 u32 sts_ring_addr_hi;
283 u32 sts_ring_size;
284
285 u32 ctx_id;
286} __attribute__ ((aligned(64)));
287
288/*
289 * Following data structures describe the descriptors that will be used.
290 * Added fileds of tcpHdrSize and ipHdrSize, The driver needs to do it only when
291 * we are doing LSO (above the 1500 size packet) only.
292 */
293
294/*
295 * The size of reference handle been changed to 16 bits to pass the MSS fields
296 * for the LSO packet
297 */
298
299#define FLAGS_CHECKSUM_ENABLED 0x01
300#define FLAGS_LSO_ENABLED 0x02
301#define FLAGS_IPSEC_SA_ADD 0x04
302#define FLAGS_IPSEC_SA_DELETE 0x08
303#define FLAGS_VLAN_TAGGED 0x10
304
305#define netxen_set_cmd_desc_port(cmd_desc, var) \
306 ((cmd_desc)->port_ctxid |= ((var) & 0x0F))
307
308#define netxen_set_cmd_desc_flags(cmd_desc, val) \
309 _netxen_set_bits((cmd_desc)->flags_opcode, 0, 7, val)
310#define netxen_set_cmd_desc_opcode(cmd_desc, val) \
311 _netxen_set_bits((cmd_desc)->flags_opcode, 7, 6, val)
312
313#define netxen_set_cmd_desc_num_of_buff(cmd_desc, val) \
314 _netxen_set_bits((cmd_desc)->num_of_buffers_total_length, 0, 8, val);
315#define netxen_set_cmd_desc_totallength(cmd_desc, val) \
316 _netxen_set_bits((cmd_desc)->num_of_buffers_total_length, 8, 24, val);
317
318#define netxen_get_cmd_desc_opcode(cmd_desc) \
319 (((cmd_desc)->flags_opcode >> 7) & 0x003F)
320#define netxen_get_cmd_desc_totallength(cmd_desc) \
321 (((cmd_desc)->num_of_buffers_total_length >> 8) & 0x0FFFFFF)
322
323struct cmd_desc_type0 {
324 u8 tcp_hdr_offset; /* For LSO only */
325 u8 ip_hdr_offset; /* For LSO only */
326 /* Bit pattern: 0-6 flags, 7-12 opcode, 13-15 unused */
327 u16 flags_opcode;
328 /* Bit pattern: 0-7 total number of segments,
329 8-31 Total size of the packet */
330 u32 num_of_buffers_total_length;
331 union {
332 struct {
333 u32 addr_low_part2;
334 u32 addr_high_part2;
335 };
336 u64 addr_buffer2;
337 };
338
339 u16 reference_handle; /* changed to u16 to add mss */
340 u16 mss; /* passed by NDIS_PACKET for LSO */
341 /* Bit pattern 0-3 port, 0-3 ctx id */
342 u8 port_ctxid;
343 u8 total_hdr_length; /* LSO only : MAC+IP+TCP Hdr size */
344 u16 conn_id; /* IPSec offoad only */
345
346 union {
347 struct {
348 u32 addr_low_part3;
349 u32 addr_high_part3;
350 };
351 u64 addr_buffer3;
352 };
353 union {
354 struct {
355 u32 addr_low_part1;
356 u32 addr_high_part1;
357 };
358 u64 addr_buffer1;
359 };
360
361 u16 buffer1_length;
362 u16 buffer2_length;
363 u16 buffer3_length;
364 u16 buffer4_length;
365
366 union {
367 struct {
368 u32 addr_low_part4;
369 u32 addr_high_part4;
370 };
371 u64 addr_buffer4;
372 };
373
374 u64 unused;
375
376} __attribute__ ((aligned(64)));
377
378/* Note: sizeof(rcv_desc) should always be a mutliple of 2 */
379struct rcv_desc {
380 u16 reference_handle;
381 u16 reserved;
382 u32 buffer_length; /* allocated buffer length (usually 2K) */
383 u64 addr_buffer;
384};
385
386/* opcode field in status_desc */
387#define RCV_NIC_PKT (0xA)
388#define STATUS_NIC_PKT ((RCV_NIC_PKT) << 12)
389
390/* for status field in status_desc */
391#define STATUS_NEED_CKSUM (1)
392#define STATUS_CKSUM_OK (2)
393
394/* owner bits of status_desc */
395#define STATUS_OWNER_HOST (0x1)
396#define STATUS_OWNER_PHANTOM (0x2)
397
398#define NETXEN_PROT_IP (1)
399#define NETXEN_PROT_UNKNOWN (0)
400
401/* Note: sizeof(status_desc) should always be a mutliple of 2 */
402
403#define netxen_get_sts_desc_lro_cnt(status_desc) \
404 ((status_desc)->lro & 0x7F)
405#define netxen_get_sts_desc_lro_last_frag(status_desc) \
406 (((status_desc)->lro & 0x80) >> 7)
407
408#define netxen_get_sts_port(status_desc) \
409 ((status_desc)->status_desc_data & 0x0F)
410#define netxen_get_sts_status(status_desc) \
411 (((status_desc)->status_desc_data >> 4) & 0x0F)
412#define netxen_get_sts_type(status_desc) \
413 (((status_desc)->status_desc_data >> 8) & 0x0F)
414#define netxen_get_sts_totallength(status_desc) \
415 (((status_desc)->status_desc_data >> 12) & 0xFFFF)
416#define netxen_get_sts_refhandle(status_desc) \
417 (((status_desc)->status_desc_data >> 28) & 0xFFFF)
418#define netxen_get_sts_prot(status_desc) \
419 (((status_desc)->status_desc_data >> 44) & 0x0F)
420#define netxen_get_sts_owner(status_desc) \
421 (((status_desc)->status_desc_data >> 56) & 0x03)
422#define netxen_get_sts_opcode(status_desc) \
423 (((status_desc)->status_desc_data >> 58) & 0x03F)
424
425#define netxen_clear_sts_owner(status_desc) \
426 ((status_desc)->status_desc_data &= \
427 ~(((unsigned long long)3) << 56 ))
428#define netxen_set_sts_owner(status_desc, val) \
429 ((status_desc)->status_desc_data |= \
430 (((unsigned long long)((val) & 0x3)) << 56 ))
431
432struct status_desc {
433 /* Bit pattern: 0-3 port, 4-7 status, 8-11 type, 12-27 total_length
434 28-43 reference_handle, 44-47 protocol, 48-52 unused
435 53-55 desc_cnt, 56-57 owner, 58-63 opcode
436 */
437 u64 status_desc_data;
438 u32 hash_value;
439 u8 hash_type;
440 u8 msg_type;
441 u8 unused;
442 /* Bit pattern: 0-6 lro_count indicates frag sequence,
443 7 last_frag indicates last frag */
444 u8 lro;
445} __attribute__ ((aligned(8)));
446
447enum {
448 NETXEN_RCV_PEG_0 = 0,
449 NETXEN_RCV_PEG_1
450};
451/* The version of the main data structure */
452#define NETXEN_BDINFO_VERSION 1
453
454/* Magic number to let user know flash is programmed */
455#define NETXEN_BDINFO_MAGIC 0x12345678
456
457/* Max number of Gig ports on a Phantom board */
458#define NETXEN_MAX_PORTS 4
459
460typedef enum {
461 NETXEN_BRDTYPE_P1_BD = 0x0000,
462 NETXEN_BRDTYPE_P1_SB = 0x0001,
463 NETXEN_BRDTYPE_P1_SMAX = 0x0002,
464 NETXEN_BRDTYPE_P1_SOCK = 0x0003,
465
466 NETXEN_BRDTYPE_P2_SOCK_31 = 0x0008,
467 NETXEN_BRDTYPE_P2_SOCK_35 = 0x0009,
468 NETXEN_BRDTYPE_P2_SB35_4G = 0x000a,
469 NETXEN_BRDTYPE_P2_SB31_10G = 0x000b,
470 NETXEN_BRDTYPE_P2_SB31_2G = 0x000c,
471
472 NETXEN_BRDTYPE_P2_SB31_10G_IMEZ = 0x000d,
473 NETXEN_BRDTYPE_P2_SB31_10G_HMEZ = 0x000e,
474 NETXEN_BRDTYPE_P2_SB31_10G_CX4 = 0x000f
475} netxen_brdtype_t;
476
477typedef enum {
478 NETXEN_BRDMFG_INVENTEC = 1
479} netxen_brdmfg;
480
481typedef enum {
482 MEM_ORG_128Mbx4 = 0x0, /* DDR1 only */
483 MEM_ORG_128Mbx8 = 0x1, /* DDR1 only */
484 MEM_ORG_128Mbx16 = 0x2, /* DDR1 only */
485 MEM_ORG_256Mbx4 = 0x3,
486 MEM_ORG_256Mbx8 = 0x4,
487 MEM_ORG_256Mbx16 = 0x5,
488 MEM_ORG_512Mbx4 = 0x6,
489 MEM_ORG_512Mbx8 = 0x7,
490 MEM_ORG_512Mbx16 = 0x8,
491 MEM_ORG_1Gbx4 = 0x9,
492 MEM_ORG_1Gbx8 = 0xa,
493 MEM_ORG_1Gbx16 = 0xb,
494 MEM_ORG_2Gbx4 = 0xc,
495 MEM_ORG_2Gbx8 = 0xd,
496 MEM_ORG_2Gbx16 = 0xe,
497 MEM_ORG_128Mbx32 = 0x10002, /* GDDR only */
498 MEM_ORG_256Mbx32 = 0x10005 /* GDDR only */
499} netxen_mn_mem_org_t;
500
501typedef enum {
502 MEM_ORG_512Kx36 = 0x0,
503 MEM_ORG_1Mx36 = 0x1,
504 MEM_ORG_2Mx36 = 0x2
505} netxen_sn_mem_org_t;
506
507typedef enum {
508 MEM_DEPTH_4MB = 0x1,
509 MEM_DEPTH_8MB = 0x2,
510 MEM_DEPTH_16MB = 0x3,
511 MEM_DEPTH_32MB = 0x4,
512 MEM_DEPTH_64MB = 0x5,
513 MEM_DEPTH_128MB = 0x6,
514 MEM_DEPTH_256MB = 0x7,
515 MEM_DEPTH_512MB = 0x8,
516 MEM_DEPTH_1GB = 0x9,
517 MEM_DEPTH_2GB = 0xa,
518 MEM_DEPTH_4GB = 0xb,
519 MEM_DEPTH_8GB = 0xc,
520 MEM_DEPTH_16GB = 0xd,
521 MEM_DEPTH_32GB = 0xe
522} netxen_mem_depth_t;
523
524struct netxen_board_info {
525 u32 header_version;
526
527 u32 board_mfg;
528 u32 board_type;
529 u32 board_num;
530 u32 chip_id;
531 u32 chip_minor;
532 u32 chip_major;
533 u32 chip_pkg;
534 u32 chip_lot;
535
536 u32 port_mask; /* available niu ports */
537 u32 peg_mask; /* available pegs */
538 u32 icache_ok; /* can we run with icache? */
539 u32 dcache_ok; /* can we run with dcache? */
540 u32 casper_ok;
541
542 u32 mac_addr_lo_0;
543 u32 mac_addr_lo_1;
544 u32 mac_addr_lo_2;
545 u32 mac_addr_lo_3;
546
547 /* MN-related config */
548 u32 mn_sync_mode; /* enable/ sync shift cclk/ sync shift mclk */
549 u32 mn_sync_shift_cclk;
550 u32 mn_sync_shift_mclk;
551 u32 mn_wb_en;
552 u32 mn_crystal_freq; /* in MHz */
553 u32 mn_speed; /* in MHz */
554 u32 mn_org;
555 u32 mn_depth;
556 u32 mn_ranks_0; /* ranks per slot */
557 u32 mn_ranks_1; /* ranks per slot */
558 u32 mn_rd_latency_0;
559 u32 mn_rd_latency_1;
560 u32 mn_rd_latency_2;
561 u32 mn_rd_latency_3;
562 u32 mn_rd_latency_4;
563 u32 mn_rd_latency_5;
564 u32 mn_rd_latency_6;
565 u32 mn_rd_latency_7;
566 u32 mn_rd_latency_8;
567 u32 mn_dll_val[18];
568 u32 mn_mode_reg; /* MIU DDR Mode Register */
569 u32 mn_ext_mode_reg; /* MIU DDR Extended Mode Register */
570 u32 mn_timing_0; /* MIU Memory Control Timing Rgister */
571 u32 mn_timing_1; /* MIU Extended Memory Ctrl Timing Register */
572 u32 mn_timing_2; /* MIU Extended Memory Ctrl Timing2 Register */
573
574 /* SN-related config */
575 u32 sn_sync_mode; /* enable/ sync shift cclk / sync shift mclk */
576 u32 sn_pt_mode; /* pass through mode */
577 u32 sn_ecc_en;
578 u32 sn_wb_en;
579 u32 sn_crystal_freq;
580 u32 sn_speed;
581 u32 sn_org;
582 u32 sn_depth;
583 u32 sn_dll_tap;
584 u32 sn_rd_latency;
585
586 u32 mac_addr_hi_0;
587 u32 mac_addr_hi_1;
588 u32 mac_addr_hi_2;
589 u32 mac_addr_hi_3;
590
591 u32 magic; /* indicates flash has been initialized */
592
593 u32 mn_rdimm;
594 u32 mn_dll_override;
595
596};
597
598#define FLASH_NUM_PORTS (4)
599
600struct netxen_flash_mac_addr {
601 u32 flash_addr[32];
602};
603
604struct netxen_user_old_info {
605 u8 flash_md5[16];
606 u8 crbinit_md5[16];
607 u8 brdcfg_md5[16];
608 /* bootloader */
609 u32 bootld_version;
610 u32 bootld_size;
611 u8 bootld_md5[16];
612 /* image */
613 u32 image_version;
614 u32 image_size;
615 u8 image_md5[16];
616 /* primary image status */
617 u32 primary_status;
618 u32 secondary_present;
619
620 /* MAC address , 4 ports */
621 struct netxen_flash_mac_addr mac_addr[FLASH_NUM_PORTS];
622};
623#define FLASH_NUM_MAC_PER_PORT 32
624struct netxen_user_info {
625 u8 flash_md5[16 * 64];
626 /* bootloader */
627 u32 bootld_version;
628 u32 bootld_size;
629 /* image */
630 u32 image_version;
631 u32 image_size;
632 /* primary image status */
633 u32 primary_status;
634 u32 secondary_present;
635
636 /* MAC address , 4 ports, 32 address per port */
637 u64 mac_addr[FLASH_NUM_PORTS * FLASH_NUM_MAC_PER_PORT];
638 u32 sub_sys_id;
639 u8 serial_num[32];
640
641 /* Any user defined data */
642};
643
644/*
645 * Flash Layout - new format.
646 */
647struct netxen_new_user_info {
648 u8 flash_md5[16 * 64];
649 /* bootloader */
650 u32 bootld_version;
651 u32 bootld_size;
652 /* image */
653 u32 image_version;
654 u32 image_size;
655 /* primary image status */
656 u32 primary_status;
657 u32 secondary_present;
658
659 /* MAC address , 4 ports, 32 address per port */
660 u64 mac_addr[FLASH_NUM_PORTS * FLASH_NUM_MAC_PER_PORT];
661 u32 sub_sys_id;
662 u8 serial_num[32];
663
664 /* Any user defined data */
665};
666
667#define SECONDARY_IMAGE_PRESENT 0xb3b4b5b6
668#define SECONDARY_IMAGE_ABSENT 0xffffffff
669#define PRIMARY_IMAGE_GOOD 0x5a5a5a5a
670#define PRIMARY_IMAGE_BAD 0xffffffff
671
672/* Flash memory map */
673typedef enum {
674 CRBINIT_START = 0, /* Crbinit section */
675 BRDCFG_START = 0x4000, /* board config */
676 INITCODE_START = 0x6000, /* pegtune code */
677 BOOTLD_START = 0x10000, /* bootld */
678 IMAGE_START = 0x43000, /* compressed image */
679 SECONDARY_START = 0x200000, /* backup images */
680 PXE_START = 0x3E0000, /* user defined region */
681 USER_START = 0x3E8000, /* User defined region for new boards */
682 FIXED_START = 0x3F0000 /* backup of crbinit */
683} netxen_flash_map_t;
684
685#define USER_START_OLD PXE_START /* for backward compatibility */
686
687#define FLASH_START (CRBINIT_START)
688#define INIT_SECTOR (0)
689#define PRIMARY_START (BOOTLD_START)
690#define FLASH_CRBINIT_SIZE (0x4000)
691#define FLASH_BRDCFG_SIZE (sizeof(struct netxen_board_info))
692#define FLASH_USER_SIZE (sizeof(struct netxen_user_info)/sizeof(u32))
693#define FLASH_SECONDARY_SIZE (USER_START-SECONDARY_START)
694#define NUM_PRIMARY_SECTORS (0x20)
695#define NUM_CONFIG_SECTORS (1)
696#define PFX "NetXen: "
697extern char netxen_nic_driver_name[];
698
699/* Note: Make sure to not call this before adapter->port is valid */
700#if !defined(NETXEN_DEBUG)
701#define DPRINTK(klevel, fmt, args...) do { \
702 } while (0)
703#else
704#define DPRINTK(klevel, fmt, args...) do { \
705 printk(KERN_##klevel PFX "%s: %s: " fmt, __FUNCTION__,\
706 (adapter != NULL && \
707 adapter->port[0] != NULL && \
708 adapter->port[0]->netdev != NULL) ? \
709 adapter->port[0]->netdev->name : NULL, \
710 ## args); } while(0)
711#endif
712
713/* Number of status descriptors to handle per interrupt */
714#define MAX_STATUS_HANDLE (128)
715
716/*
717 * netxen_skb_frag{} is to contain mapping info for each SG list. This
718 * has to be freed when DMA is complete. This is part of netxen_tx_buffer{}.
719 */
720struct netxen_skb_frag {
721 u64 dma;
722 u32 length;
723};
724
725/* Following defines are for the state of the buffers */
726#define NETXEN_BUFFER_FREE 0
727#define NETXEN_BUFFER_BUSY 1
728
729/*
730 * There will be one netxen_buffer per skb packet. These will be
731 * used to save the dma info for pci_unmap_page()
732 */
733struct netxen_cmd_buffer {
734 struct sk_buff *skb;
735 struct netxen_skb_frag frag_array[MAX_BUFFERS_PER_CMD + 1];
736 u32 total_length;
737 u32 mss;
738 u16 port;
739 u8 cmd;
740 u8 frag_count;
741 unsigned long time_stamp;
742 u32 state;
743};
744
745/* In rx_buffer, we do not need multiple fragments as is a single buffer */
746struct netxen_rx_buffer {
747 struct sk_buff *skb;
748 u64 dma;
749 u16 ref_handle;
750 u16 state;
751 u32 lro_expected_frags;
752 u32 lro_current_frags;
753 u32 lro_length;
754};
755
756/* Board types */
757#define NETXEN_NIC_GBE 0x01
758#define NETXEN_NIC_XGBE 0x02
759
760/*
761 * One hardware_context{} per adapter
762 * contains interrupt info as well shared hardware info.
763 */
764struct netxen_hardware_context {
765 struct pci_dev *pdev;
766 void __iomem *pci_base0;
767 void __iomem *pci_base1;
768 void __iomem *pci_base2;
769 void __iomem *db_base;
770 unsigned long db_len;
771
772 u8 revision_id;
773 u16 board_type;
774 u16 max_ports;
775 struct netxen_board_info boardcfg;
776 u32 xg_linkup;
777 u32 qg_linksup;
778 /* Address of cmd ring in Phantom */
779 struct cmd_desc_type0 *cmd_desc_head;
780 struct pci_dev *cmd_desc_pdev;
781 dma_addr_t cmd_desc_phys_addr;
782 struct netxen_adapter *adapter;
783};
784
785#define RCV_RING_LRO RCV_DESC_LRO
786
787#define MINIMUM_ETHERNET_FRAME_SIZE 64 /* With FCS */
788#define ETHERNET_FCS_SIZE 4
789
790struct netxen_adapter_stats {
791 u64 ints;
792 u64 hostints;
793 u64 otherints;
794 u64 process_rcv;
795 u64 process_xmit;
796 u64 noxmitdone;
797 u64 xmitcsummed;
798 u64 post_called;
799 u64 posted;
800 u64 lastposted;
801 u64 goodskbposts;
802};
803
804/*
805 * Rcv Descriptor Context. One such per Rcv Descriptor. There may
806 * be one Rcv Descriptor for normal packets, one for jumbo and may be others.
807 */
808struct netxen_rcv_desc_ctx {
809 u32 flags;
810 u32 producer;
811 u32 rcv_pending; /* Num of bufs posted in phantom */
812 u32 rcv_free; /* Num of bufs in free list */
813 dma_addr_t phys_addr;
814 struct pci_dev *phys_pdev;
815 struct rcv_desc *desc_head; /* address of rx ring in Phantom */
816 u32 max_rx_desc_count;
817 u32 dma_size;
818 u32 skb_size;
819 struct netxen_rx_buffer *rx_buf_arr; /* rx buffers for receive */
820 int begin_alloc;
821};
822
823/*
824 * Receive context. There is one such structure per instance of the
825 * receive processing. Any state information that is relevant to
826 * the receive, and is must be in this structure. The global data may be
827 * present elsewhere.
828 */
829struct netxen_recv_context {
830 struct netxen_rcv_desc_ctx rcv_desc[NUM_RCV_DESC_RINGS];
831 u32 status_rx_producer;
832 u32 status_rx_consumer;
833 dma_addr_t rcv_status_desc_phys_addr;
834 struct pci_dev *rcv_status_desc_pdev;
835 struct status_desc *rcv_status_desc_head;
836};
837
838#define NETXEN_NIC_MSI_ENABLED 0x02
839#define NETXEN_DMA_MASK 0xfffffffe
840#define NETXEN_DB_MAPSIZE_BYTES 0x1000
841
842struct netxen_dummy_dma {
843 void *addr;
844 dma_addr_t phys_addr;
845};
846
847struct netxen_adapter {
848 struct netxen_hardware_context ahw;
849 int port_count; /* Number of configured ports */
850 int active_ports; /* Number of open ports */
851 struct netxen_port *port[NETXEN_MAX_PORTS]; /* ptr to each port */
852 spinlock_t tx_lock;
853 spinlock_t lock;
854 struct work_struct watchdog_task;
855 struct work_struct tx_timeout_task;
856 struct net_device *netdev;
857 struct timer_list watchdog_timer;
858
859 u32 curr_window;
860
861 u32 cmd_producer;
862 u32 *cmd_consumer;
863
864 u32 last_cmd_consumer;
865 u32 max_tx_desc_count;
866 u32 max_rx_desc_count;
867 u32 max_jumbo_rx_desc_count;
868 u32 max_lro_rx_desc_count;
869 /* Num of instances active on cmd buffer ring */
870 u32 proc_cmd_buf_counter;
871
872 u32 num_threads, total_threads; /*Use to keep track of xmit threads */
873
874 u32 flags;
875 u32 irq;
876 int driver_mismatch;
877 u32 temp;
878
879 struct netxen_adapter_stats stats;
880
881 struct netxen_cmd_buffer *cmd_buf_arr; /* Command buffers for xmit */
882
883 /*
884 * Receive instances. These can be either one per port,
885 * or one per peg, etc.
886 */
887 struct netxen_recv_context recv_ctx[MAX_RCV_CTX];
888
889 int is_up;
890 int number;
891 struct netxen_dummy_dma dummy_dma;
892
893 /* Context interface shared between card and host */
894 struct netxen_ring_ctx *ctx_desc;
895 struct pci_dev *ctx_desc_pdev;
896 dma_addr_t ctx_desc_phys_addr;
897 int (*enable_phy_interrupts) (struct netxen_adapter *, int);
898 int (*disable_phy_interrupts) (struct netxen_adapter *, int);
899 void (*handle_phy_intr) (struct netxen_adapter *);
900 int (*macaddr_set) (struct netxen_port *, netxen_ethernet_macaddr_t);
901 int (*set_mtu) (struct netxen_port *, int);
902 int (*set_promisc) (struct netxen_adapter *, int,
903 netxen_niu_prom_mode_t);
904 int (*unset_promisc) (struct netxen_adapter *, int,
905 netxen_niu_prom_mode_t);
906 int (*phy_read) (struct netxen_adapter *, long phy, long reg, u32 *);
907 int (*phy_write) (struct netxen_adapter *, long phy, long reg, u32 val);
908 int (*init_port) (struct netxen_adapter *, int);
909 void (*init_niu) (struct netxen_adapter *);
910 int (*stop_port) (struct netxen_adapter *, int);
911}; /* netxen_adapter structure */
912
913/* Max number of xmit producer threads that can run simultaneously */
914#define MAX_XMIT_PRODUCERS 16
915
916struct netxen_port_stats {
917 u64 rcvdbadskb;
918 u64 xmitcalled;
919 u64 xmitedframes;
920 u64 xmitfinished;
921 u64 badskblen;
922 u64 nocmddescriptor;
923 u64 polled;
924 u64 uphappy;
925 u64 updropped;
926 u64 uplcong;
927 u64 uphcong;
928 u64 upmcong;
929 u64 updunno;
930 u64 skbfreed;
931 u64 txdropped;
932 u64 txnullskb;
933 u64 csummed;
934 u64 no_rcv;
935 u64 rxbytes;
936 u64 txbytes;
937};
938
939struct netxen_port {
940 struct netxen_adapter *adapter;
941
942 u16 portnum; /* GBE port number */
943 u16 link_speed;
944 u16 link_duplex;
945 u16 link_autoneg;
946
947 int flags;
948
949 struct net_device *netdev;
950 struct pci_dev *pdev;
951 struct net_device_stats net_stats;
952 struct netxen_port_stats stats;
953};
954
955#define PCI_OFFSET_FIRST_RANGE(adapter, off) \
956 ((adapter)->ahw.pci_base0 + (off))
957#define PCI_OFFSET_SECOND_RANGE(adapter, off) \
958 ((adapter)->ahw.pci_base1 + (off) - SECOND_PAGE_GROUP_START)
959#define PCI_OFFSET_THIRD_RANGE(adapter, off) \
960 ((adapter)->ahw.pci_base2 + (off) - THIRD_PAGE_GROUP_START)
961
962static inline void __iomem *pci_base_offset(struct netxen_adapter *adapter,
963 unsigned long off)
964{
965 if ((off < FIRST_PAGE_GROUP_END) && (off >= FIRST_PAGE_GROUP_START)) {
966 return (adapter->ahw.pci_base0 + off);
967 } else if ((off < SECOND_PAGE_GROUP_END) &&
968 (off >= SECOND_PAGE_GROUP_START)) {
969 return (adapter->ahw.pci_base1 + off - SECOND_PAGE_GROUP_START);
970 } else if ((off < THIRD_PAGE_GROUP_END) &&
971 (off >= THIRD_PAGE_GROUP_START)) {
972 return (adapter->ahw.pci_base2 + off - THIRD_PAGE_GROUP_START);
973 }
974 return NULL;
975}
976
977static inline void __iomem *pci_base(struct netxen_adapter *adapter,
978 unsigned long off)
979{
980 if ((off < FIRST_PAGE_GROUP_END) && (off >= FIRST_PAGE_GROUP_START)) {
981 return adapter->ahw.pci_base0;
982 } else if ((off < SECOND_PAGE_GROUP_END) &&
983 (off >= SECOND_PAGE_GROUP_START)) {
984 return adapter->ahw.pci_base1;
985 } else if ((off < THIRD_PAGE_GROUP_END) &&
986 (off >= THIRD_PAGE_GROUP_START)) {
987 return adapter->ahw.pci_base2;
988 }
989 return NULL;
990}
991
992int netxen_niu_xgbe_enable_phy_interrupts(struct netxen_adapter *adapter,
993 int port);
994int netxen_niu_gbe_enable_phy_interrupts(struct netxen_adapter *adapter,
995 int port);
996int netxen_niu_xgbe_disable_phy_interrupts(struct netxen_adapter *adapter,
997 int port);
998int netxen_niu_gbe_disable_phy_interrupts(struct netxen_adapter *adapter,
999 int port);
1000int netxen_niu_xgbe_clear_phy_interrupts(struct netxen_adapter *adapter,
1001 int port);
1002int netxen_niu_gbe_clear_phy_interrupts(struct netxen_adapter *adapter,
1003 int port);
1004void netxen_nic_xgbe_handle_phy_intr(struct netxen_adapter *adapter);
1005void netxen_nic_gbe_handle_phy_intr(struct netxen_adapter *adapter);
1006void netxen_niu_gbe_set_mii_mode(struct netxen_adapter *adapter, int port,
1007 long enable);
1008void netxen_niu_gbe_set_gmii_mode(struct netxen_adapter *adapter, int port,
1009 long enable);
1010int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long phy, long reg,
1011 __le32 * readval);
1012int netxen_niu_gbe_phy_write(struct netxen_adapter *adapter, long phy,
1013 long reg, __le32 val);
1014
1015/* Functions available from netxen_nic_hw.c */
1016int netxen_nic_set_mtu_xgb(struct netxen_port *port, int new_mtu);
1017int netxen_nic_set_mtu_gb(struct netxen_port *port, int new_mtu);
1018void netxen_nic_init_niu_gb(struct netxen_adapter *adapter);
1019void netxen_nic_pci_change_crbwindow(struct netxen_adapter *adapter, u32 wndw);
1020void netxen_nic_reg_write(struct netxen_adapter *adapter, u64 off, u32 val);
1021int netxen_nic_reg_read(struct netxen_adapter *adapter, u64 off);
1022void netxen_nic_write_w0(struct netxen_adapter *adapter, u32 index, u32 value);
1023void netxen_nic_read_w0(struct netxen_adapter *adapter, u32 index, u32 * value);
1024
1025int netxen_nic_get_board_info(struct netxen_adapter *adapter);
1026int netxen_nic_hw_read_wx(struct netxen_adapter *adapter, u64 off, void *data,
1027 int len);
1028int netxen_nic_hw_write_wx(struct netxen_adapter *adapter, u64 off, void *data,
1029 int len);
1030int netxen_nic_hw_read_ioctl(struct netxen_adapter *adapter, u64 off,
1031 void *data, int len);
1032int netxen_nic_hw_write_ioctl(struct netxen_adapter *adapter, u64 off,
1033 void *data, int len);
1034int netxen_nic_pci_mem_write_ioctl(struct netxen_adapter *adapter,
1035 u64 off, void *data, int size);
1036int netxen_nic_pci_mem_read_ioctl(struct netxen_adapter *adapter,
1037 u64 off, void *data, int size);
1038void netxen_crb_writelit_adapter(struct netxen_adapter *adapter,
1039 unsigned long off, int data);
1040
1041/* Functions from netxen_nic_init.c */
1042void netxen_free_adapter_offload(struct netxen_adapter *adapter);
1043int netxen_initialize_adapter_offload(struct netxen_adapter *adapter);
1044void netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val);
1045void netxen_load_firmware(struct netxen_adapter *adapter);
1046int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose);
1047int netxen_rom_fast_read(struct netxen_adapter *adapter, int addr, int *valp);
1048int netxen_rom_fast_write(struct netxen_adapter *adapter, int addr, int data);
1049int netxen_rom_se(struct netxen_adapter *adapter, int addr);
1050int netxen_do_rom_se(struct netxen_adapter *adapter, int addr);
1051
1052/* Functions from netxen_nic_isr.c */
1053void netxen_nic_isr_other(struct netxen_adapter *adapter);
1054void netxen_indicate_link_status(struct netxen_adapter *adapter, u32 port,
1055 u32 link);
1056void netxen_handle_port_int(struct netxen_adapter *adapter, u32 port,
1057 u32 enable);
1058void netxen_nic_stop_all_ports(struct netxen_adapter *adapter);
1059void netxen_initialize_adapter_sw(struct netxen_adapter *adapter);
1060void netxen_initialize_adapter_hw(struct netxen_adapter *adapter);
1061void *netxen_alloc(struct pci_dev *pdev, size_t sz, dma_addr_t * ptr,
1062 struct pci_dev **used_dev);
1063void netxen_initialize_adapter_ops(struct netxen_adapter *adapter);
1064int netxen_init_firmware(struct netxen_adapter *adapter);
1065void netxen_free_hw_resources(struct netxen_adapter *adapter);
1066void netxen_tso_check(struct netxen_adapter *adapter,
1067 struct cmd_desc_type0 *desc, struct sk_buff *skb);
1068int netxen_nic_hw_resources(struct netxen_adapter *adapter);
1069void netxen_nic_clear_stats(struct netxen_adapter *adapter);
1070int
1071netxen_nic_do_ioctl(struct netxen_adapter *adapter, void *u_data,
1072 struct netxen_port *port);
1073int netxen_nic_rx_has_work(struct netxen_adapter *adapter);
1074int netxen_nic_tx_has_work(struct netxen_adapter *adapter);
1075void netxen_watchdog_task(struct work_struct *work);
1076void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx,
1077 u32 ringid);
1078void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, u32 ctx,
1079 u32 ringid);
1080int netxen_process_cmd_ring(unsigned long data);
1081u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctx, int max);
1082void netxen_nic_set_multi(struct net_device *netdev);
1083int netxen_nic_change_mtu(struct net_device *netdev, int new_mtu);
1084int netxen_nic_set_mac(struct net_device *netdev, void *p);
1085struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev);
1086
1087static inline void netxen_nic_disable_int(struct netxen_adapter *adapter)
1088{
1089 /*
1090 * ISR_INT_MASK: Can be read from window 0 or 1.
1091 */
1092 writel(0x7ff, PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_MASK));
1093
1094}
1095
1096static inline void netxen_nic_enable_int(struct netxen_adapter *adapter)
1097{
1098 u32 mask;
1099
1100 switch (adapter->ahw.board_type) {
1101 case NETXEN_NIC_GBE:
1102 mask = 0x77b;
1103 break;
1104 case NETXEN_NIC_XGBE:
1105 mask = 0x77f;
1106 break;
1107 default:
1108 mask = 0x7ff;
1109 break;
1110 }
1111
1112 writel(mask, PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_MASK));
1113
1114 if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) {
1115 mask = 0xbff;
1116 writel(mask, PCI_OFFSET_SECOND_RANGE(adapter,
1117 ISR_INT_TARGET_MASK));
1118 }
1119}
1120
1121/*
1122 * NetXen Board information
1123 */
1124
1125#define NETXEN_MAX_SHORT_NAME 16
1126struct netxen_brdinfo {
1127 netxen_brdtype_t brdtype; /* type of board */
1128 long ports; /* max no of physical ports */
1129 char short_name[NETXEN_MAX_SHORT_NAME];
1130};
1131
1132static const struct netxen_brdinfo netxen_boards[] = {
1133 {NETXEN_BRDTYPE_P2_SB31_10G_CX4, 1, "XGb CX4"},
1134 {NETXEN_BRDTYPE_P2_SB31_10G_HMEZ, 1, "XGb HMEZ"},
1135 {NETXEN_BRDTYPE_P2_SB31_10G_IMEZ, 2, "XGb IMEZ"},
1136 {NETXEN_BRDTYPE_P2_SB31_10G, 1, "XGb XFP"},
1137 {NETXEN_BRDTYPE_P2_SB35_4G, 4, "Quad Gb"},
1138 {NETXEN_BRDTYPE_P2_SB31_2G, 2, "Dual Gb"},
1139};
1140
1141#define NUM_SUPPORTED_BOARDS (sizeof(netxen_boards)/sizeof(struct netxen_brdinfo))
1142
1143static inline void get_brd_port_by_type(u32 type, int *ports)
1144{
1145 int i, found = 0;
1146 for (i = 0; i < NUM_SUPPORTED_BOARDS; ++i) {
1147 if (netxen_boards[i].brdtype == type) {
1148 *ports = netxen_boards[i].ports;
1149 found = 1;
1150 break;
1151 }
1152 }
1153 if (!found)
1154 *ports = 0;
1155}
1156
1157static inline void get_brd_name_by_type(u32 type, char *name)
1158{
1159 int i, found = 0;
1160 for (i = 0; i < NUM_SUPPORTED_BOARDS; ++i) {
1161 if (netxen_boards[i].brdtype == type) {
1162 strcpy(name, netxen_boards[i].short_name);
1163 found = 1;
1164 break;
1165 }
1166
1167 }
1168 if (!found)
1169 name = "Unknown";
1170}
1171
1172int netxen_is_flash_supported(struct netxen_adapter *adapter);
1173int netxen_get_flash_mac_addr(struct netxen_adapter *adapter, u64 mac[]);
1174extern void netxen_change_ringparam(struct netxen_adapter *adapter);
1175extern int netxen_rom_fast_read(struct netxen_adapter *adapter, int addr,
1176 int *valp);
1177
1178extern struct ethtool_ops netxen_nic_ethtool_ops;
1179
1180#endif /* __NETXEN_NIC_H_ */
diff --git a/drivers/net/netxen/netxen_nic_ethtool.c b/drivers/net/netxen/netxen_nic_ethtool.c
new file mode 100644
index 000000000000..2ab4885cc950
--- /dev/null
+++ b/drivers/net/netxen/netxen_nic_ethtool.c
@@ -0,0 +1,742 @@
1/*
2 * Copyright (C) 2003 - 2006 NetXen, Inc.
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 * MA 02111-1307, USA.
19 *
20 * The full GNU General Public License is included in this distribution
21 * in the file called LICENSE.
22 *
23 * Contact Information:
24 * info@netxen.com
25 * NetXen,
26 * 3965 Freedom Circle, Fourth floor,
27 * Santa Clara, CA 95054
28 *
29 *
30 * ethtool support for netxen nic
31 *
32 */
33
34#include <linux/types.h>
35#include <asm/uaccess.h>
36#include <linux/pci.h>
37#include <asm/io.h>
38#include <linux/netdevice.h>
39#include <linux/ethtool.h>
40#include <linux/version.h>
41
42#include "netxen_nic_hw.h"
43#include "netxen_nic.h"
44#include "netxen_nic_phan_reg.h"
45#include "netxen_nic_ioctl.h"
46
47struct netxen_nic_stats {
48 char stat_string[ETH_GSTRING_LEN];
49 int sizeof_stat;
50 int stat_offset;
51};
52
53#define NETXEN_NIC_STAT(m) sizeof(((struct netxen_port *)0)->m), \
54 offsetof(struct netxen_port, m)
55
56#define NETXEN_NIC_PORT_WINDOW 0x10000
57#define NETXEN_NIC_INVALID_DATA 0xDEADBEEF
58
59static const struct netxen_nic_stats netxen_nic_gstrings_stats[] = {
60 {"rcvd_bad_skb", NETXEN_NIC_STAT(stats.rcvdbadskb)},
61 {"xmit_called", NETXEN_NIC_STAT(stats.xmitcalled)},
62 {"xmited_frames", NETXEN_NIC_STAT(stats.xmitedframes)},
63 {"xmit_finished", NETXEN_NIC_STAT(stats.xmitfinished)},
64 {"bad_skb_len", NETXEN_NIC_STAT(stats.badskblen)},
65 {"no_cmd_desc", NETXEN_NIC_STAT(stats.nocmddescriptor)},
66 {"polled", NETXEN_NIC_STAT(stats.polled)},
67 {"uphappy", NETXEN_NIC_STAT(stats.uphappy)},
68 {"updropped", NETXEN_NIC_STAT(stats.updropped)},
69 {"uplcong", NETXEN_NIC_STAT(stats.uplcong)},
70 {"uphcong", NETXEN_NIC_STAT(stats.uphcong)},
71 {"upmcong", NETXEN_NIC_STAT(stats.upmcong)},
72 {"updunno", NETXEN_NIC_STAT(stats.updunno)},
73 {"skb_freed", NETXEN_NIC_STAT(stats.skbfreed)},
74 {"tx_dropped", NETXEN_NIC_STAT(stats.txdropped)},
75 {"tx_null_skb", NETXEN_NIC_STAT(stats.txnullskb)},
76 {"csummed", NETXEN_NIC_STAT(stats.csummed)},
77 {"no_rcv", NETXEN_NIC_STAT(stats.no_rcv)},
78 {"rx_bytes", NETXEN_NIC_STAT(stats.rxbytes)},
79 {"tx_bytes", NETXEN_NIC_STAT(stats.txbytes)},
80};
81
82#define NETXEN_NIC_STATS_LEN \
83 sizeof(netxen_nic_gstrings_stats) / sizeof(struct netxen_nic_stats)
84
85static const char netxen_nic_gstrings_test[][ETH_GSTRING_LEN] = {
86 "Register_Test_offline", "EEPROM_Test_offline",
87 "Interrupt_Test_offline", "Loopback_Test_offline",
88 "Link_Test_on_offline"
89};
90
91#define NETXEN_NIC_TEST_LEN sizeof(netxen_nic_gstrings_test) / ETH_GSTRING_LEN
92
93#define NETXEN_NIC_REGS_COUNT 42
94#define NETXEN_NIC_REGS_LEN (NETXEN_NIC_REGS_COUNT * sizeof(__le32))
95#define NETXEN_MAX_EEPROM_LEN 1024
96
97static int netxen_nic_get_eeprom_len(struct net_device *dev)
98{
99 struct netxen_port *port = netdev_priv(dev);
100 struct netxen_adapter *adapter = port->adapter;
101 int n;
102
103 if ((netxen_rom_fast_read(adapter, 0, &n) == 0)
104 && (n & NETXEN_ROM_ROUNDUP)) {
105 n &= ~NETXEN_ROM_ROUNDUP;
106 if (n < NETXEN_MAX_EEPROM_LEN)
107 return n;
108 }
109 return 0;
110}
111
112static void
113netxen_nic_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo)
114{
115 struct netxen_port *port = netdev_priv(dev);
116 struct netxen_adapter *adapter = port->adapter;
117 u32 fw_major = 0;
118 u32 fw_minor = 0;
119 u32 fw_build = 0;
120
121 strncpy(drvinfo->driver, netxen_nic_driver_name, 32);
122 strncpy(drvinfo->version, NETXEN_NIC_LINUX_VERSIONID, 32);
123 fw_major = readl(NETXEN_CRB_NORMALIZE(adapter,
124 NETXEN_FW_VERSION_MAJOR));
125 fw_minor = readl(NETXEN_CRB_NORMALIZE(adapter,
126 NETXEN_FW_VERSION_MINOR));
127 fw_build = readl(NETXEN_CRB_NORMALIZE(adapter, NETXEN_FW_VERSION_SUB));
128 sprintf(drvinfo->fw_version, "%d.%d.%d", fw_major, fw_minor, fw_build);
129
130 strncpy(drvinfo->bus_info, pci_name(port->pdev), 32);
131 drvinfo->n_stats = NETXEN_NIC_STATS_LEN;
132 drvinfo->testinfo_len = NETXEN_NIC_TEST_LEN;
133 drvinfo->regdump_len = NETXEN_NIC_REGS_LEN;
134 drvinfo->eedump_len = netxen_nic_get_eeprom_len(dev);
135}
136
137static int
138netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
139{
140 struct netxen_port *port = netdev_priv(dev);
141 struct netxen_adapter *adapter = port->adapter;
142 struct netxen_board_info *boardinfo = &adapter->ahw.boardcfg;
143
144 /* read which mode */
145 if (adapter->ahw.board_type == NETXEN_NIC_GBE) {
146 ecmd->supported = (SUPPORTED_10baseT_Half |
147 SUPPORTED_10baseT_Full |
148 SUPPORTED_100baseT_Half |
149 SUPPORTED_100baseT_Full |
150 SUPPORTED_1000baseT_Half |
151 SUPPORTED_1000baseT_Full);
152
153 ecmd->advertising = (ADVERTISED_100baseT_Half |
154 ADVERTISED_100baseT_Full |
155 ADVERTISED_1000baseT_Half |
156 ADVERTISED_1000baseT_Full);
157
158 ecmd->port = PORT_TP;
159
160 if (netif_running(dev)) {
161 ecmd->speed = port->link_speed;
162 ecmd->duplex = port->link_duplex;
163 } else
164 return -EIO; /* link absent */
165 } else if (adapter->ahw.board_type == NETXEN_NIC_XGBE) {
166 ecmd->supported = (SUPPORTED_TP |
167 SUPPORTED_1000baseT_Full |
168 SUPPORTED_10000baseT_Full);
169 ecmd->advertising = (ADVERTISED_TP |
170 ADVERTISED_1000baseT_Full |
171 ADVERTISED_10000baseT_Full);
172 ecmd->port = PORT_TP;
173
174 ecmd->speed = SPEED_10000;
175 ecmd->duplex = DUPLEX_FULL;
176 ecmd->autoneg = AUTONEG_DISABLE;
177 } else
178 return -EIO;
179
180 ecmd->phy_address = port->portnum;
181 ecmd->transceiver = XCVR_EXTERNAL;
182
183 switch ((netxen_brdtype_t) boardinfo->board_type) {
184 case NETXEN_BRDTYPE_P2_SB35_4G:
185 case NETXEN_BRDTYPE_P2_SB31_2G:
186 ecmd->supported |= SUPPORTED_Autoneg;
187 ecmd->advertising |= ADVERTISED_Autoneg;
188 case NETXEN_BRDTYPE_P2_SB31_10G_CX4:
189 ecmd->supported |= SUPPORTED_TP;
190 ecmd->advertising |= ADVERTISED_TP;
191 ecmd->port = PORT_TP;
192 ecmd->autoneg = (boardinfo->board_type ==
193 NETXEN_BRDTYPE_P2_SB31_10G_CX4) ?
194 (AUTONEG_DISABLE) : (port->link_autoneg);
195 break;
196 case NETXEN_BRDTYPE_P2_SB31_10G_HMEZ:
197 case NETXEN_BRDTYPE_P2_SB31_10G_IMEZ:
198 ecmd->supported |= SUPPORTED_MII;
199 ecmd->advertising |= ADVERTISED_MII;
200 ecmd->port = PORT_FIBRE;
201 ecmd->autoneg = AUTONEG_DISABLE;
202 break;
203 case NETXEN_BRDTYPE_P2_SB31_10G:
204 ecmd->supported |= SUPPORTED_FIBRE;
205 ecmd->advertising |= ADVERTISED_FIBRE;
206 ecmd->port = PORT_FIBRE;
207 ecmd->autoneg = AUTONEG_DISABLE;
208 break;
209 default:
210 printk(KERN_ERR "netxen-nic: Unsupported board model %d\n",
211 (netxen_brdtype_t) boardinfo->board_type);
212 return -EIO;
213 }
214
215 return 0;
216}
217
218static int
219netxen_nic_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
220{
221 struct netxen_port *port = netdev_priv(dev);
222 struct netxen_adapter *adapter = port->adapter;
223 __le32 status;
224
225 /* read which mode */
226 if (adapter->ahw.board_type == NETXEN_NIC_GBE) {
227 /* autonegotiation */
228 if (adapter->phy_write
229 && adapter->phy_write(adapter, port->portnum,
230 NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG,
231 (__le32) ecmd->autoneg) != 0)
232 return -EIO;
233 else
234 port->link_autoneg = ecmd->autoneg;
235
236 if (adapter->phy_read
237 && adapter->phy_read(adapter, port->portnum,
238 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
239 &status) != 0)
240 return -EIO;
241
242 /* speed */
243 switch (ecmd->speed) {
244 case SPEED_10:
245 netxen_set_phy_speed(status, 0);
246 break;
247 case SPEED_100:
248 netxen_set_phy_speed(status, 1);
249 break;
250 case SPEED_1000:
251 netxen_set_phy_speed(status, 2);
252 break;
253 }
254 /* set duplex mode */
255 if (ecmd->duplex == DUPLEX_HALF)
256 netxen_clear_phy_duplex(status);
257 if (ecmd->duplex == DUPLEX_FULL)
258 netxen_set_phy_duplex(status);
259 if (adapter->phy_write
260 && adapter->phy_write(adapter, port->portnum,
261 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
262 *((int *)&status)) != 0)
263 return -EIO;
264 else {
265 port->link_speed = ecmd->speed;
266 port->link_duplex = ecmd->duplex;
267 }
268 } else
269 return -EOPNOTSUPP;
270
271 if (netif_running(dev)) {
272 dev->stop(dev);
273 dev->open(dev);
274 }
275 return 0;
276}
277
278static int netxen_nic_get_regs_len(struct net_device *dev)
279{
280 return NETXEN_NIC_REGS_LEN;
281}
282
283struct netxen_niu_regs {
284 __le32 reg[NETXEN_NIC_REGS_COUNT];
285};
286
287static struct netxen_niu_regs niu_registers[] = {
288 {
289 /* GB Mode */
290 {
291 NETXEN_NIU_GB_SERDES_RESET,
292 NETXEN_NIU_GB0_MII_MODE,
293 NETXEN_NIU_GB1_MII_MODE,
294 NETXEN_NIU_GB2_MII_MODE,
295 NETXEN_NIU_GB3_MII_MODE,
296 NETXEN_NIU_GB0_GMII_MODE,
297 NETXEN_NIU_GB1_GMII_MODE,
298 NETXEN_NIU_GB2_GMII_MODE,
299 NETXEN_NIU_GB3_GMII_MODE,
300 NETXEN_NIU_REMOTE_LOOPBACK,
301 NETXEN_NIU_GB0_HALF_DUPLEX,
302 NETXEN_NIU_GB1_HALF_DUPLEX,
303 NETXEN_NIU_RESET_SYS_FIFOS,
304 NETXEN_NIU_GB_CRC_DROP,
305 NETXEN_NIU_GB_DROP_WRONGADDR,
306 NETXEN_NIU_TEST_MUX_CTL,
307
308 NETXEN_NIU_GB_MAC_CONFIG_0(0),
309 NETXEN_NIU_GB_MAC_CONFIG_1(0),
310 NETXEN_NIU_GB_HALF_DUPLEX_CTRL(0),
311 NETXEN_NIU_GB_MAX_FRAME_SIZE(0),
312 NETXEN_NIU_GB_TEST_REG(0),
313 NETXEN_NIU_GB_MII_MGMT_CONFIG(0),
314 NETXEN_NIU_GB_MII_MGMT_COMMAND(0),
315 NETXEN_NIU_GB_MII_MGMT_ADDR(0),
316 NETXEN_NIU_GB_MII_MGMT_CTRL(0),
317 NETXEN_NIU_GB_MII_MGMT_STATUS(0),
318 NETXEN_NIU_GB_MII_MGMT_INDICATE(0),
319 NETXEN_NIU_GB_INTERFACE_CTRL(0),
320 NETXEN_NIU_GB_INTERFACE_STATUS(0),
321 NETXEN_NIU_GB_STATION_ADDR_0(0),
322 NETXEN_NIU_GB_STATION_ADDR_1(0),
323 -1,
324 }
325 },
326 {
327 /* XG Mode */
328 {
329 NETXEN_NIU_XG_SINGLE_TERM,
330 NETXEN_NIU_XG_DRIVE_HI,
331 NETXEN_NIU_XG_DRIVE_LO,
332 NETXEN_NIU_XG_DTX,
333 NETXEN_NIU_XG_DEQ,
334 NETXEN_NIU_XG_WORD_ALIGN,
335 NETXEN_NIU_XG_RESET,
336 NETXEN_NIU_XG_POWER_DOWN,
337 NETXEN_NIU_XG_RESET_PLL,
338 NETXEN_NIU_XG_SERDES_LOOPBACK,
339 NETXEN_NIU_XG_DO_BYTE_ALIGN,
340 NETXEN_NIU_XG_TX_ENABLE,
341 NETXEN_NIU_XG_RX_ENABLE,
342 NETXEN_NIU_XG_STATUS,
343 NETXEN_NIU_XG_PAUSE_THRESHOLD,
344 NETXEN_NIU_XGE_CONFIG_0,
345 NETXEN_NIU_XGE_CONFIG_1,
346 NETXEN_NIU_XGE_IPG,
347 NETXEN_NIU_XGE_STATION_ADDR_0_HI,
348 NETXEN_NIU_XGE_STATION_ADDR_0_1,
349 NETXEN_NIU_XGE_STATION_ADDR_1_LO,
350 NETXEN_NIU_XGE_STATUS,
351 NETXEN_NIU_XGE_MAX_FRAME_SIZE,
352 NETXEN_NIU_XGE_PAUSE_FRAME_VALUE,
353 NETXEN_NIU_XGE_TX_BYTE_CNT,
354 NETXEN_NIU_XGE_TX_FRAME_CNT,
355 NETXEN_NIU_XGE_RX_BYTE_CNT,
356 NETXEN_NIU_XGE_RX_FRAME_CNT,
357 NETXEN_NIU_XGE_AGGR_ERROR_CNT,
358 NETXEN_NIU_XGE_MULTICAST_FRAME_CNT,
359 NETXEN_NIU_XGE_UNICAST_FRAME_CNT,
360 NETXEN_NIU_XGE_CRC_ERROR_CNT,
361 NETXEN_NIU_XGE_OVERSIZE_FRAME_ERR,
362 NETXEN_NIU_XGE_UNDERSIZE_FRAME_ERR,
363 NETXEN_NIU_XGE_LOCAL_ERROR_CNT,
364 NETXEN_NIU_XGE_REMOTE_ERROR_CNT,
365 NETXEN_NIU_XGE_CONTROL_CHAR_CNT,
366 NETXEN_NIU_XGE_PAUSE_FRAME_CNT,
367 -1,
368 }
369 }
370};
371
372static void
373netxen_nic_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p)
374{
375 struct netxen_port *port = netdev_priv(dev);
376 struct netxen_adapter *adapter = port->adapter;
377 __le32 mode, *regs_buff = p;
378 void __iomem *addr;
379 int i, window;
380
381 memset(p, 0, NETXEN_NIC_REGS_LEN);
382 regs->version = (1 << 24) | (adapter->ahw.revision_id << 16) |
383 (port->pdev)->device;
384 /* which mode */
385 NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_MODE, &regs_buff[0]);
386 mode = regs_buff[0];
387
388 /* Common registers to all the modes */
389 NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_STRAP_VALUE_SAVE_HIGHER,
390 &regs_buff[2]);
391 /* GB/XGB Mode */
392 mode = (mode / 2) - 1;
393 window = 0;
394 if (mode <= 1) {
395 for (i = 3; niu_registers[mode].reg[i - 3] != -1; i++) {
396 /* GB: port specific registers */
397 if (mode == 0 && i >= 19)
398 window = port->portnum * NETXEN_NIC_PORT_WINDOW;
399
400 NETXEN_NIC_LOCKED_READ_REG(niu_registers[mode].
401 reg[i - 3] + window,
402 &regs_buff[i]);
403 }
404
405 }
406}
407
408static void
409netxen_nic_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
410{
411 wol->supported = WAKE_UCAST | WAKE_MCAST | WAKE_BCAST | WAKE_MAGIC;
412 /* options can be added depending upon the mode */
413 wol->wolopts = 0;
414}
415
416static u32 netxen_nic_get_link(struct net_device *dev)
417{
418 struct netxen_port *port = netdev_priv(dev);
419 struct netxen_adapter *adapter = port->adapter;
420 __le32 status;
421
422 /* read which mode */
423 if (adapter->ahw.board_type == NETXEN_NIC_GBE) {
424 if (adapter->phy_read
425 && adapter->phy_read(adapter, port->portnum,
426 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
427 &status) != 0)
428 return -EIO;
429 else
430 return (netxen_get_phy_link(status));
431 } else if (adapter->ahw.board_type == NETXEN_NIC_XGBE) {
432 int val = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_XG_STATE));
433 return val == XG_LINK_UP;
434 }
435 return -EIO;
436}
437
438static int
439netxen_nic_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
440 u8 * bytes)
441{
442 struct netxen_port *port = netdev_priv(dev);
443 struct netxen_adapter *adapter = port->adapter;
444 int offset;
445
446 if (eeprom->len == 0)
447 return -EINVAL;
448
449 eeprom->magic = (port->pdev)->vendor | ((port->pdev)->device << 16);
450 for (offset = 0; offset < eeprom->len; offset++)
451 if (netxen_rom_fast_read
452 (adapter, (8 * offset) + 8, (int *)eeprom->data) == -1)
453 return -EIO;
454 return 0;
455}
456
457static void
458netxen_nic_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring)
459{
460 struct netxen_port *port = netdev_priv(dev);
461 struct netxen_adapter *adapter = port->adapter;
462 int i;
463
464 ring->rx_pending = 0;
465 ring->rx_jumbo_pending = 0;
466 for (i = 0; i < MAX_RCV_CTX; ++i) {
467 ring->rx_pending += adapter->recv_ctx[i].
468 rcv_desc[RCV_DESC_NORMAL_CTXID].rcv_pending;
469 ring->rx_jumbo_pending += adapter->recv_ctx[i].
470 rcv_desc[RCV_DESC_JUMBO_CTXID].rcv_pending;
471 }
472
473 ring->rx_max_pending = adapter->max_rx_desc_count;
474 ring->tx_max_pending = adapter->max_tx_desc_count;
475 ring->rx_jumbo_max_pending = adapter->max_jumbo_rx_desc_count;
476 ring->rx_mini_max_pending = 0;
477 ring->rx_mini_pending = 0;
478 ring->rx_jumbo_pending = 0;
479}
480
481static void
482netxen_nic_get_pauseparam(struct net_device *dev,
483 struct ethtool_pauseparam *pause)
484{
485 struct netxen_port *port = netdev_priv(dev);
486 struct netxen_adapter *adapter = port->adapter;
487 __le32 val;
488
489 if (adapter->ahw.board_type == NETXEN_NIC_GBE) {
490 /* get flow control settings */
491 netxen_nic_read_w0(adapter,
492 NETXEN_NIU_GB_MAC_CONFIG_0(port->portnum),
493 (u32 *) & val);
494 pause->rx_pause = netxen_gb_get_rx_flowctl(val);
495 pause->tx_pause = netxen_gb_get_tx_flowctl(val);
496 /* get autoneg settings */
497 pause->autoneg = port->link_autoneg;
498 }
499}
500
501static int
502netxen_nic_set_pauseparam(struct net_device *dev,
503 struct ethtool_pauseparam *pause)
504{
505 struct netxen_port *port = netdev_priv(dev);
506 struct netxen_adapter *adapter = port->adapter;
507 __le32 val;
508 unsigned int autoneg;
509
510 /* read mode */
511 if (adapter->ahw.board_type == NETXEN_NIC_GBE) {
512 /* set flow control */
513 netxen_nic_read_w0(adapter,
514 NETXEN_NIU_GB_MAC_CONFIG_0(port->portnum),
515 (u32 *) & val);
516 if (pause->tx_pause)
517 netxen_gb_tx_flowctl(val);
518 else
519 netxen_gb_unset_tx_flowctl(val);
520 if (pause->rx_pause)
521 netxen_gb_rx_flowctl(val);
522 else
523 netxen_gb_unset_rx_flowctl(val);
524
525 netxen_nic_write_w0(adapter,
526 NETXEN_NIU_GB_MAC_CONFIG_0(port->portnum),
527 *(u32 *) (&val));
528 /* set autoneg */
529 autoneg = pause->autoneg;
530 if (adapter->phy_write
531 && adapter->phy_write(adapter, port->portnum,
532 NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG,
533 (__le32) autoneg) != 0)
534 return -EIO;
535 else {
536 port->link_autoneg = pause->autoneg;
537 return 0;
538 }
539 } else
540 return -EOPNOTSUPP;
541}
542
543static int netxen_nic_reg_test(struct net_device *dev)
544{
545 struct netxen_port *port = netdev_priv(dev);
546 struct netxen_adapter *adapter = port->adapter;
547 u32 data_read, data_written, save;
548 __le32 mode;
549
550 /*
551 * first test the "Read Only" registers by writing which mode
552 */
553 netxen_nic_read_w0(adapter, NETXEN_NIU_MODE, &mode);
554 if (netxen_get_niu_enable_ge(mode)) { /* GB Mode */
555 netxen_nic_read_w0(adapter,
556 NETXEN_NIU_GB_MII_MGMT_STATUS(port->portnum),
557 &data_read);
558
559 save = data_read;
560 if (data_read)
561 data_written = data_read & NETXEN_NIC_INVALID_DATA;
562 else
563 data_written = NETXEN_NIC_INVALID_DATA;
564 netxen_nic_write_w0(adapter,
565 NETXEN_NIU_GB_MII_MGMT_STATUS(port->
566 portnum),
567 data_written);
568 netxen_nic_read_w0(adapter,
569 NETXEN_NIU_GB_MII_MGMT_STATUS(port->portnum),
570 &data_read);
571
572 if (data_written == data_read) {
573 netxen_nic_write_w0(adapter,
574 NETXEN_NIU_GB_MII_MGMT_STATUS(port->
575 portnum),
576 save);
577
578 return 0;
579 }
580
581 /* netxen_niu_gb_mii_mgmt_indicators is read only */
582 netxen_nic_read_w0(adapter,
583 NETXEN_NIU_GB_MII_MGMT_INDICATE(port->
584 portnum),
585 &data_read);
586
587 save = data_read;
588 if (data_read)
589 data_written = data_read & NETXEN_NIC_INVALID_DATA;
590 else
591 data_written = NETXEN_NIC_INVALID_DATA;
592 netxen_nic_write_w0(adapter,
593 NETXEN_NIU_GB_MII_MGMT_INDICATE(port->
594 portnum),
595 data_written);
596
597 netxen_nic_read_w0(adapter,
598 NETXEN_NIU_GB_MII_MGMT_INDICATE(port->
599 portnum),
600 &data_read);
601
602 if (data_written == data_read) {
603 netxen_nic_write_w0(adapter,
604 NETXEN_NIU_GB_MII_MGMT_INDICATE
605 (port->portnum), save);
606 return 0;
607 }
608
609 /* netxen_niu_gb_interface_status is read only */
610 netxen_nic_read_w0(adapter,
611 NETXEN_NIU_GB_INTERFACE_STATUS(port->
612 portnum),
613 &data_read);
614
615 save = data_read;
616 if (data_read)
617 data_written = data_read & NETXEN_NIC_INVALID_DATA;
618 else
619 data_written = NETXEN_NIC_INVALID_DATA;
620 netxen_nic_write_w0(adapter,
621 NETXEN_NIU_GB_INTERFACE_STATUS(port->
622 portnum),
623 data_written);
624
625 netxen_nic_read_w0(adapter,
626 NETXEN_NIU_GB_INTERFACE_STATUS(port->
627 portnum),
628 &data_read);
629
630 if (data_written == data_read) {
631 netxen_nic_write_w0(adapter,
632 NETXEN_NIU_GB_INTERFACE_STATUS
633 (port->portnum), save);
634
635 return 0;
636 }
637 } /* GB Mode */
638 return 1;
639}
640
641static int netxen_nic_diag_test_count(struct net_device *dev)
642{
643 return NETXEN_NIC_TEST_LEN;
644}
645
646static void
647netxen_nic_diag_test(struct net_device *dev, struct ethtool_test *eth_test,
648 u64 * data)
649{
650 if (eth_test->flags == ETH_TEST_FL_OFFLINE) { /* offline tests */
651 /* link test */
652 if (!(data[4] = (u64) netxen_nic_get_link(dev)))
653 eth_test->flags |= ETH_TEST_FL_FAILED;
654
655 if (netif_running(dev))
656 dev->stop(dev);
657
658 /* register tests */
659 if (!(data[0] = netxen_nic_reg_test(dev)))
660 eth_test->flags |= ETH_TEST_FL_FAILED;
661 /* other tests pass as of now */
662 data[1] = data[2] = data[3] = 1;
663 if (netif_running(dev))
664 dev->open(dev);
665 } else { /* online tests */
666 /* link test */
667 if (!(data[4] = (u64) netxen_nic_get_link(dev)))
668 eth_test->flags |= ETH_TEST_FL_FAILED;
669
670 /* other tests pass by default */
671 data[0] = data[1] = data[2] = data[3] = 1;
672 }
673}
674
675static void
676netxen_nic_get_strings(struct net_device *dev, u32 stringset, u8 * data)
677{
678 int index;
679
680 switch (stringset) {
681 case ETH_SS_TEST:
682 memcpy(data, *netxen_nic_gstrings_test,
683 NETXEN_NIC_TEST_LEN * ETH_GSTRING_LEN);
684 break;
685 case ETH_SS_STATS:
686 for (index = 0; index < NETXEN_NIC_STATS_LEN; index++) {
687 memcpy(data + index * ETH_GSTRING_LEN,
688 netxen_nic_gstrings_stats[index].stat_string,
689 ETH_GSTRING_LEN);
690 }
691 break;
692 }
693}
694
695static int netxen_nic_get_stats_count(struct net_device *dev)
696{
697 return NETXEN_NIC_STATS_LEN;
698}
699
700static void
701netxen_nic_get_ethtool_stats(struct net_device *dev,
702 struct ethtool_stats *stats, u64 * data)
703{
704 struct netxen_port *port = netdev_priv(dev);
705 int index;
706
707 for (index = 0; index < NETXEN_NIC_STATS_LEN; index++) {
708 char *p =
709 (char *)port + netxen_nic_gstrings_stats[index].stat_offset;
710 data[index] =
711 (netxen_nic_gstrings_stats[index].sizeof_stat ==
712 sizeof(u64)) ? *(u64 *) p : *(u32 *) p;
713 }
714
715}
716
717struct ethtool_ops netxen_nic_ethtool_ops = {
718 .get_settings = netxen_nic_get_settings,
719 .set_settings = netxen_nic_set_settings,
720 .get_drvinfo = netxen_nic_get_drvinfo,
721 .get_regs_len = netxen_nic_get_regs_len,
722 .get_regs = netxen_nic_get_regs,
723 .get_wol = netxen_nic_get_wol,
724 .get_link = netxen_nic_get_link,
725 .get_eeprom_len = netxen_nic_get_eeprom_len,
726 .get_eeprom = netxen_nic_get_eeprom,
727 .get_ringparam = netxen_nic_get_ringparam,
728 .get_pauseparam = netxen_nic_get_pauseparam,
729 .set_pauseparam = netxen_nic_set_pauseparam,
730 .get_tx_csum = ethtool_op_get_tx_csum,
731 .set_tx_csum = ethtool_op_set_tx_csum,
732 .get_sg = ethtool_op_get_sg,
733 .set_sg = ethtool_op_set_sg,
734 .get_tso = ethtool_op_get_tso,
735 .set_tso = ethtool_op_set_tso,
736 .self_test_count = netxen_nic_diag_test_count,
737 .self_test = netxen_nic_diag_test,
738 .get_strings = netxen_nic_get_strings,
739 .get_stats_count = netxen_nic_get_stats_count,
740 .get_ethtool_stats = netxen_nic_get_ethtool_stats,
741 .get_perm_addr = ethtool_op_get_perm_addr,
742};
diff --git a/drivers/net/netxen/netxen_nic_hdr.h b/drivers/net/netxen/netxen_nic_hdr.h
new file mode 100644
index 000000000000..fe8b675f9e72
--- /dev/null
+++ b/drivers/net/netxen/netxen_nic_hdr.h
@@ -0,0 +1,678 @@
1/*
2 * Copyright (C) 2003 - 2006 NetXen, Inc.
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 * MA 02111-1307, USA.
19 *
20 * The full GNU General Public License is included in this distribution
21 * in the file called LICENSE.
22 *
23 * Contact Information:
24 * info@netxen.com
25 * NetXen,
26 * 3965 Freedom Circle, Fourth floor,
27 * Santa Clara, CA 95054
28 */
29
30#ifndef __NETXEN_NIC_HDR_H_
31#define __NETXEN_NIC_HDR_H_
32
33#include <linux/module.h>
34#include <linux/kernel.h>
35#include <linux/version.h>
36
37#include <asm/semaphore.h>
38#include <linux/spinlock.h>
39#include <asm/irq.h>
40#include <linux/init.h>
41#include <linux/errno.h>
42#include <linux/pci.h>
43#include <linux/types.h>
44#include <asm/uaccess.h>
45#include <asm/string.h> /* for memset */
46
47/*
48 * The basic unit of access when reading/writing control registers.
49 */
50
51typedef __le32 netxen_crbword_t; /* single word in CRB space */
52
53enum {
54 NETXEN_HW_H0_CH_HUB_ADR = 0x05,
55 NETXEN_HW_H1_CH_HUB_ADR = 0x0E,
56 NETXEN_HW_H2_CH_HUB_ADR = 0x03,
57 NETXEN_HW_H3_CH_HUB_ADR = 0x01,
58 NETXEN_HW_H4_CH_HUB_ADR = 0x06,
59 NETXEN_HW_H5_CH_HUB_ADR = 0x07,
60 NETXEN_HW_H6_CH_HUB_ADR = 0x08
61};
62
63/* Hub 0 */
64enum {
65 NETXEN_HW_MN_CRB_AGT_ADR = 0x15,
66 NETXEN_HW_MS_CRB_AGT_ADR = 0x25
67};
68
69/* Hub 1 */
70enum {
71 NETXEN_HW_PS_CRB_AGT_ADR = 0x73,
72 NETXEN_HW_SS_CRB_AGT_ADR = 0x20,
73 NETXEN_HW_RPMX3_CRB_AGT_ADR = 0x0b,
74 NETXEN_HW_QMS_CRB_AGT_ADR = 0x00,
75 NETXEN_HW_SQGS0_CRB_AGT_ADR = 0x01,
76 NETXEN_HW_SQGS1_CRB_AGT_ADR = 0x02,
77 NETXEN_HW_SQGS2_CRB_AGT_ADR = 0x03,
78 NETXEN_HW_SQGS3_CRB_AGT_ADR = 0x04,
79 NETXEN_HW_C2C0_CRB_AGT_ADR = 0x58,
80 NETXEN_HW_C2C1_CRB_AGT_ADR = 0x59,
81 NETXEN_HW_C2C2_CRB_AGT_ADR = 0x5a,
82 NETXEN_HW_RPMX2_CRB_AGT_ADR = 0x0a,
83 NETXEN_HW_RPMX4_CRB_AGT_ADR = 0x0c,
84 NETXEN_HW_RPMX7_CRB_AGT_ADR = 0x0f,
85 NETXEN_HW_RPMX9_CRB_AGT_ADR = 0x12,
86 NETXEN_HW_SMB_CRB_AGT_ADR = 0x18
87};
88
89/* Hub 2 */
90enum {
91 NETXEN_HW_NIU_CRB_AGT_ADR = 0x31,
92 NETXEN_HW_I2C0_CRB_AGT_ADR = 0x19,
93 NETXEN_HW_I2C1_CRB_AGT_ADR = 0x29,
94
95 NETXEN_HW_SN_CRB_AGT_ADR = 0x10,
96 NETXEN_HW_I2Q_CRB_AGT_ADR = 0x20,
97 NETXEN_HW_LPC_CRB_AGT_ADR = 0x22,
98 NETXEN_HW_ROMUSB_CRB_AGT_ADR = 0x21,
99 NETXEN_HW_QM_CRB_AGT_ADR = 0x66,
100 NETXEN_HW_SQG0_CRB_AGT_ADR = 0x60,
101 NETXEN_HW_SQG1_CRB_AGT_ADR = 0x61,
102 NETXEN_HW_SQG2_CRB_AGT_ADR = 0x62,
103 NETXEN_HW_SQG3_CRB_AGT_ADR = 0x63,
104 NETXEN_HW_RPMX1_CRB_AGT_ADR = 0x09,
105 NETXEN_HW_RPMX5_CRB_AGT_ADR = 0x0d,
106 NETXEN_HW_RPMX6_CRB_AGT_ADR = 0x0e,
107 NETXEN_HW_RPMX8_CRB_AGT_ADR = 0x11
108};
109
110/* Hub 3 */
111enum {
112 NETXEN_HW_PH_CRB_AGT_ADR = 0x1A,
113 NETXEN_HW_SRE_CRB_AGT_ADR = 0x50,
114 NETXEN_HW_EG_CRB_AGT_ADR = 0x51,
115 NETXEN_HW_RPMX0_CRB_AGT_ADR = 0x08
116};
117
118/* Hub 4 */
119enum {
120 NETXEN_HW_PEGN0_CRB_AGT_ADR = 0x40,
121 NETXEN_HW_PEGN1_CRB_AGT_ADR,
122 NETXEN_HW_PEGN2_CRB_AGT_ADR,
123 NETXEN_HW_PEGN3_CRB_AGT_ADR,
124 NETXEN_HW_PEGNI_CRB_AGT_ADR,
125 NETXEN_HW_PEGND_CRB_AGT_ADR,
126 NETXEN_HW_PEGNC_CRB_AGT_ADR,
127 NETXEN_HW_PEGR0_CRB_AGT_ADR,
128 NETXEN_HW_PEGR1_CRB_AGT_ADR,
129 NETXEN_HW_PEGR2_CRB_AGT_ADR,
130 NETXEN_HW_PEGR3_CRB_AGT_ADR
131};
132
133/* Hub 5 */
134enum {
135 NETXEN_HW_PEGS0_CRB_AGT_ADR = 0x40,
136 NETXEN_HW_PEGS1_CRB_AGT_ADR,
137 NETXEN_HW_PEGS2_CRB_AGT_ADR,
138 NETXEN_HW_PEGS3_CRB_AGT_ADR,
139 NETXEN_HW_PEGSI_CRB_AGT_ADR,
140 NETXEN_HW_PEGSD_CRB_AGT_ADR,
141 NETXEN_HW_PEGSC_CRB_AGT_ADR
142};
143
144/* Hub 6 */
145enum {
146 NETXEN_HW_CAS0_CRB_AGT_ADR = 0x46,
147 NETXEN_HW_CAS1_CRB_AGT_ADR = 0x47,
148 NETXEN_HW_CAS2_CRB_AGT_ADR = 0x48,
149 NETXEN_HW_CAS3_CRB_AGT_ADR = 0x49,
150 NETXEN_HW_NCM_CRB_AGT_ADR = 0x16,
151 NETXEN_HW_TMR_CRB_AGT_ADR = 0x17,
152 NETXEN_HW_XDMA_CRB_AGT_ADR = 0x05,
153 NETXEN_HW_OCM0_CRB_AGT_ADR = 0x06,
154 NETXEN_HW_OCM1_CRB_AGT_ADR = 0x07
155};
156
157/* Floaters - non existent modules */
158#define NETXEN_HW_EFC_RPMX0_CRB_AGT_ADR 0x67
159
160/* This field defines PCI/X adr [25:20] of agents on the CRB */
161enum {
162 NETXEN_HW_PX_MAP_CRB_PH = 0,
163 NETXEN_HW_PX_MAP_CRB_PS,
164 NETXEN_HW_PX_MAP_CRB_MN,
165 NETXEN_HW_PX_MAP_CRB_MS,
166 NETXEN_HW_PX_MAP_CRB_PGR1,
167 NETXEN_HW_PX_MAP_CRB_SRE,
168 NETXEN_HW_PX_MAP_CRB_NIU,
169 NETXEN_HW_PX_MAP_CRB_QMN,
170 NETXEN_HW_PX_MAP_CRB_SQN0,
171 NETXEN_HW_PX_MAP_CRB_SQN1,
172 NETXEN_HW_PX_MAP_CRB_SQN2,
173 NETXEN_HW_PX_MAP_CRB_SQN3,
174 NETXEN_HW_PX_MAP_CRB_QMS,
175 NETXEN_HW_PX_MAP_CRB_SQS0,
176 NETXEN_HW_PX_MAP_CRB_SQS1,
177 NETXEN_HW_PX_MAP_CRB_SQS2,
178 NETXEN_HW_PX_MAP_CRB_SQS3,
179 NETXEN_HW_PX_MAP_CRB_PGN0,
180 NETXEN_HW_PX_MAP_CRB_PGN1,
181 NETXEN_HW_PX_MAP_CRB_PGN2,
182 NETXEN_HW_PX_MAP_CRB_PGN3,
183 NETXEN_HW_PX_MAP_CRB_PGND,
184 NETXEN_HW_PX_MAP_CRB_PGNI,
185 NETXEN_HW_PX_MAP_CRB_PGS0,
186 NETXEN_HW_PX_MAP_CRB_PGS1,
187 NETXEN_HW_PX_MAP_CRB_PGS2,
188 NETXEN_HW_PX_MAP_CRB_PGS3,
189 NETXEN_HW_PX_MAP_CRB_PGSD,
190 NETXEN_HW_PX_MAP_CRB_PGSI,
191 NETXEN_HW_PX_MAP_CRB_SN,
192 NETXEN_HW_PX_MAP_CRB_PGR2,
193 NETXEN_HW_PX_MAP_CRB_EG,
194 NETXEN_HW_PX_MAP_CRB_PH2,
195 NETXEN_HW_PX_MAP_CRB_PS2,
196 NETXEN_HW_PX_MAP_CRB_CAM,
197 NETXEN_HW_PX_MAP_CRB_CAS0,
198 NETXEN_HW_PX_MAP_CRB_CAS1,
199 NETXEN_HW_PX_MAP_CRB_CAS2,
200 NETXEN_HW_PX_MAP_CRB_C2C0,
201 NETXEN_HW_PX_MAP_CRB_C2C1,
202 NETXEN_HW_PX_MAP_CRB_TIMR,
203 NETXEN_HW_PX_MAP_CRB_PGR3,
204 NETXEN_HW_PX_MAP_CRB_RPMX1,
205 NETXEN_HW_PX_MAP_CRB_RPMX2,
206 NETXEN_HW_PX_MAP_CRB_RPMX3,
207 NETXEN_HW_PX_MAP_CRB_RPMX4,
208 NETXEN_HW_PX_MAP_CRB_RPMX5,
209 NETXEN_HW_PX_MAP_CRB_RPMX6,
210 NETXEN_HW_PX_MAP_CRB_RPMX7,
211 NETXEN_HW_PX_MAP_CRB_XDMA,
212 NETXEN_HW_PX_MAP_CRB_I2Q,
213 NETXEN_HW_PX_MAP_CRB_ROMUSB,
214 NETXEN_HW_PX_MAP_CRB_CAS3,
215 NETXEN_HW_PX_MAP_CRB_RPMX0,
216 NETXEN_HW_PX_MAP_CRB_RPMX8,
217 NETXEN_HW_PX_MAP_CRB_RPMX9,
218 NETXEN_HW_PX_MAP_CRB_OCM0,
219 NETXEN_HW_PX_MAP_CRB_OCM1,
220 NETXEN_HW_PX_MAP_CRB_SMB,
221 NETXEN_HW_PX_MAP_CRB_I2C0,
222 NETXEN_HW_PX_MAP_CRB_I2C1,
223 NETXEN_HW_PX_MAP_CRB_LPC,
224 NETXEN_HW_PX_MAP_CRB_PGNC,
225 NETXEN_HW_PX_MAP_CRB_PGR0
226};
227
228/* This field defines CRB adr [31:20] of the agents */
229
230#define NETXEN_HW_CRB_HUB_AGT_ADR_MN \
231 ((NETXEN_HW_H0_CH_HUB_ADR << 7) | NETXEN_HW_MN_CRB_AGT_ADR)
232#define NETXEN_HW_CRB_HUB_AGT_ADR_PH \
233 ((NETXEN_HW_H0_CH_HUB_ADR << 7) | NETXEN_HW_PH_CRB_AGT_ADR)
234#define NETXEN_HW_CRB_HUB_AGT_ADR_MS \
235 ((NETXEN_HW_H0_CH_HUB_ADR << 7) | NETXEN_HW_MS_CRB_AGT_ADR)
236
237#define NETXEN_HW_CRB_HUB_AGT_ADR_PS \
238 ((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_PS_CRB_AGT_ADR)
239#define NETXEN_HW_CRB_HUB_AGT_ADR_SS \
240 ((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_SS_CRB_AGT_ADR)
241#define NETXEN_HW_CRB_HUB_AGT_ADR_RPMX3 \
242 ((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_RPMX3_CRB_AGT_ADR)
243#define NETXEN_HW_CRB_HUB_AGT_ADR_QMS \
244 ((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_QMS_CRB_AGT_ADR)
245#define NETXEN_HW_CRB_HUB_AGT_ADR_SQS0 \
246 ((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_SQGS0_CRB_AGT_ADR)
247#define NETXEN_HW_CRB_HUB_AGT_ADR_SQS1 \
248 ((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_SQGS1_CRB_AGT_ADR)
249#define NETXEN_HW_CRB_HUB_AGT_ADR_SQS2 \
250 ((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_SQGS2_CRB_AGT_ADR)
251#define NETXEN_HW_CRB_HUB_AGT_ADR_SQS3 \
252 ((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_SQGS3_CRB_AGT_ADR)
253#define NETXEN_HW_CRB_HUB_AGT_ADR_C2C0 \
254 ((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_C2C0_CRB_AGT_ADR)
255#define NETXEN_HW_CRB_HUB_AGT_ADR_C2C1 \
256 ((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_C2C1_CRB_AGT_ADR)
257#define NETXEN_HW_CRB_HUB_AGT_ADR_RPMX2 \
258 ((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_RPMX2_CRB_AGT_ADR)
259#define NETXEN_HW_CRB_HUB_AGT_ADR_RPMX4 \
260 ((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_RPMX4_CRB_AGT_ADR)
261#define NETXEN_HW_CRB_HUB_AGT_ADR_RPMX7 \
262 ((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_RPMX7_CRB_AGT_ADR)
263#define NETXEN_HW_CRB_HUB_AGT_ADR_RPMX9 \
264 ((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_RPMX9_CRB_AGT_ADR)
265#define NETXEN_HW_CRB_HUB_AGT_ADR_SMB \
266 ((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_SMB_CRB_AGT_ADR)
267
268#define NETXEN_HW_CRB_HUB_AGT_ADR_NIU \
269 ((NETXEN_HW_H2_CH_HUB_ADR << 7) | NETXEN_HW_NIU_CRB_AGT_ADR)
270#define NETXEN_HW_CRB_HUB_AGT_ADR_I2C0 \
271 ((NETXEN_HW_H2_CH_HUB_ADR << 7) | NETXEN_HW_I2C0_CRB_AGT_ADR)
272#define NETXEN_HW_CRB_HUB_AGT_ADR_I2C1 \
273 ((NETXEN_HW_H2_CH_HUB_ADR << 7) | NETXEN_HW_I2C1_CRB_AGT_ADR)
274
275#define NETXEN_HW_CRB_HUB_AGT_ADR_SRE \
276 ((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_SRE_CRB_AGT_ADR)
277#define NETXEN_HW_CRB_HUB_AGT_ADR_EG \
278 ((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_EG_CRB_AGT_ADR)
279#define NETXEN_HW_CRB_HUB_AGT_ADR_RPMX0 \
280 ((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_RPMX0_CRB_AGT_ADR)
281#define NETXEN_HW_CRB_HUB_AGT_ADR_QMN \
282 ((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_QM_CRB_AGT_ADR)
283#define NETXEN_HW_CRB_HUB_AGT_ADR_SQN0 \
284 ((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_SQG0_CRB_AGT_ADR)
285#define NETXEN_HW_CRB_HUB_AGT_ADR_SQN1 \
286 ((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_SQG1_CRB_AGT_ADR)
287#define NETXEN_HW_CRB_HUB_AGT_ADR_SQN2 \
288 ((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_SQG2_CRB_AGT_ADR)
289#define NETXEN_HW_CRB_HUB_AGT_ADR_SQN3 \
290 ((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_SQG3_CRB_AGT_ADR)
291#define NETXEN_HW_CRB_HUB_AGT_ADR_RPMX1 \
292 ((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_RPMX1_CRB_AGT_ADR)
293#define NETXEN_HW_CRB_HUB_AGT_ADR_RPMX5 \
294 ((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_RPMX5_CRB_AGT_ADR)
295#define NETXEN_HW_CRB_HUB_AGT_ADR_RPMX6 \
296 ((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_RPMX6_CRB_AGT_ADR)
297#define NETXEN_HW_CRB_HUB_AGT_ADR_RPMX8 \
298 ((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_RPMX8_CRB_AGT_ADR)
299#define NETXEN_HW_CRB_HUB_AGT_ADR_CAS0 \
300 ((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_CAS0_CRB_AGT_ADR)
301#define NETXEN_HW_CRB_HUB_AGT_ADR_CAS1 \
302 ((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_CAS1_CRB_AGT_ADR)
303#define NETXEN_HW_CRB_HUB_AGT_ADR_CAS2 \
304 ((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_CAS2_CRB_AGT_ADR)
305#define NETXEN_HW_CRB_HUB_AGT_ADR_CAS3 \
306 ((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_CAS3_CRB_AGT_ADR)
307
308#define NETXEN_HW_CRB_HUB_AGT_ADR_PGNI \
309 ((NETXEN_HW_H4_CH_HUB_ADR << 7) | NETXEN_HW_PEGNI_CRB_AGT_ADR)
310#define NETXEN_HW_CRB_HUB_AGT_ADR_PGND \
311 ((NETXEN_HW_H4_CH_HUB_ADR << 7) | NETXEN_HW_PEGND_CRB_AGT_ADR)
312#define NETXEN_HW_CRB_HUB_AGT_ADR_PGN0 \
313 ((NETXEN_HW_H4_CH_HUB_ADR << 7) | NETXEN_HW_PEGN0_CRB_AGT_ADR)
314#define NETXEN_HW_CRB_HUB_AGT_ADR_PGN1 \
315 ((NETXEN_HW_H4_CH_HUB_ADR << 7) | NETXEN_HW_PEGN1_CRB_AGT_ADR)
316#define NETXEN_HW_CRB_HUB_AGT_ADR_PGN2 \
317 ((NETXEN_HW_H4_CH_HUB_ADR << 7) | NETXEN_HW_PEGN2_CRB_AGT_ADR)
318#define NETXEN_HW_CRB_HUB_AGT_ADR_PGN3 \
319 ((NETXEN_HW_H4_CH_HUB_ADR << 7) | NETXEN_HW_PEGN3_CRB_AGT_ADR)
320#define NETXEN_HW_CRB_HUB_AGT_ADR_PGNC \
321 ((NETXEN_HW_H4_CH_HUB_ADR << 7) | NETXEN_HW_PEGNC_CRB_AGT_ADR)
322#define NETXEN_HW_CRB_HUB_AGT_ADR_PGR0 \
323 ((NETXEN_HW_H4_CH_HUB_ADR << 7) | NETXEN_HW_PEGR0_CRB_AGT_ADR)
324#define NETXEN_HW_CRB_HUB_AGT_ADR_PGR1 \
325 ((NETXEN_HW_H4_CH_HUB_ADR << 7) | NETXEN_HW_PEGR1_CRB_AGT_ADR)
326#define NETXEN_HW_CRB_HUB_AGT_ADR_PGR2 \
327 ((NETXEN_HW_H4_CH_HUB_ADR << 7) | NETXEN_HW_PEGR2_CRB_AGT_ADR)
328#define NETXEN_HW_CRB_HUB_AGT_ADR_PGR3 \
329 ((NETXEN_HW_H4_CH_HUB_ADR << 7) | NETXEN_HW_PEGR3_CRB_AGT_ADR)
330
331#define NETXEN_HW_CRB_HUB_AGT_ADR_PGSI \
332 ((NETXEN_HW_H5_CH_HUB_ADR << 7) | NETXEN_HW_PEGSI_CRB_AGT_ADR)
333#define NETXEN_HW_CRB_HUB_AGT_ADR_PGSD \
334 ((NETXEN_HW_H5_CH_HUB_ADR << 7) | NETXEN_HW_PEGSD_CRB_AGT_ADR)
335#define NETXEN_HW_CRB_HUB_AGT_ADR_PGS0 \
336 ((NETXEN_HW_H5_CH_HUB_ADR << 7) | NETXEN_HW_PEGS0_CRB_AGT_ADR)
337#define NETXEN_HW_CRB_HUB_AGT_ADR_PGS1 \
338 ((NETXEN_HW_H5_CH_HUB_ADR << 7) | NETXEN_HW_PEGS1_CRB_AGT_ADR)
339#define NETXEN_HW_CRB_HUB_AGT_ADR_PGS2 \
340 ((NETXEN_HW_H5_CH_HUB_ADR << 7) | NETXEN_HW_PEGS2_CRB_AGT_ADR)
341#define NETXEN_HW_CRB_HUB_AGT_ADR_PGS3 \
342 ((NETXEN_HW_H5_CH_HUB_ADR << 7) | NETXEN_HW_PEGS3_CRB_AGT_ADR)
343#define NETXEN_HW_CRB_HUB_AGT_ADR_PGSC \
344 ((NETXEN_HW_H5_CH_HUB_ADR << 7) | NETXEN_HW_PEGSC_CRB_AGT_ADR)
345
346#define NETXEN_HW_CRB_HUB_AGT_ADR_CAM \
347 ((NETXEN_HW_H6_CH_HUB_ADR << 7) | NETXEN_HW_NCM_CRB_AGT_ADR)
348#define NETXEN_HW_CRB_HUB_AGT_ADR_TIMR \
349 ((NETXEN_HW_H6_CH_HUB_ADR << 7) | NETXEN_HW_TMR_CRB_AGT_ADR)
350#define NETXEN_HW_CRB_HUB_AGT_ADR_XDMA \
351 ((NETXEN_HW_H6_CH_HUB_ADR << 7) | NETXEN_HW_XDMA_CRB_AGT_ADR)
352#define NETXEN_HW_CRB_HUB_AGT_ADR_SN \
353 ((NETXEN_HW_H6_CH_HUB_ADR << 7) | NETXEN_HW_SN_CRB_AGT_ADR)
354#define NETXEN_HW_CRB_HUB_AGT_ADR_I2Q \
355 ((NETXEN_HW_H6_CH_HUB_ADR << 7) | NETXEN_HW_I2Q_CRB_AGT_ADR)
356#define NETXEN_HW_CRB_HUB_AGT_ADR_ROMUSB \
357 ((NETXEN_HW_H6_CH_HUB_ADR << 7) | NETXEN_HW_ROMUSB_CRB_AGT_ADR)
358#define NETXEN_HW_CRB_HUB_AGT_ADR_OCM0 \
359 ((NETXEN_HW_H6_CH_HUB_ADR << 7) | NETXEN_HW_OCM0_CRB_AGT_ADR)
360#define NETXEN_HW_CRB_HUB_AGT_ADR_OCM1 \
361 ((NETXEN_HW_H6_CH_HUB_ADR << 7) | NETXEN_HW_OCM1_CRB_AGT_ADR)
362#define NETXEN_HW_CRB_HUB_AGT_ADR_LPC \
363 ((NETXEN_HW_H6_CH_HUB_ADR << 7) | NETXEN_HW_LPC_CRB_AGT_ADR)
364
365/*
366 * MAX_RCV_CTX : The number of receive contexts that are available on
367 * the phantom.
368 */
369#define MAX_RCV_CTX 1
370
371#define NETXEN_SRE_INT_STATUS (NETXEN_CRB_SRE + 0x00034)
372#define NETXEN_SRE_PBI_ACTIVE_STATUS (NETXEN_CRB_SRE + 0x01014)
373#define NETXEN_SRE_L1RE_CTL (NETXEN_CRB_SRE + 0x03000)
374#define NETXEN_SRE_L2RE_CTL (NETXEN_CRB_SRE + 0x05000)
375#define NETXEN_SRE_BUF_CTL (NETXEN_CRB_SRE + 0x01000)
376
377#define NETXEN_DMA_BASE(U) (NETXEN_CRB_PCIX_MD + 0x20000 + ((U)<<16))
378#define NETXEN_DMA_COMMAND(U) (NETXEN_DMA_BASE(U) + 0x00008)
379
380#define NETXEN_I2Q_CLR_PCI_HI (NETXEN_CRB_I2Q + 0x00034)
381
382#define PEG_NETWORK_BASE(N) (NETXEN_CRB_PEG_NET_0 + (((N)&3) << 20))
383#define CRB_REG_EX_PC 0x3c
384
385#define ROMUSB_GLB (NETXEN_CRB_ROMUSB + 0x00000)
386#define ROMUSB_ROM (NETXEN_CRB_ROMUSB + 0x10000)
387
388#define NETXEN_ROMUSB_GLB_STATUS (ROMUSB_GLB + 0x0004)
389#define NETXEN_ROMUSB_GLB_SW_RESET (ROMUSB_GLB + 0x0008)
390#define NETXEN_ROMUSB_GLB_PAD_GPIO_I (ROMUSB_GLB + 0x000c)
391#define NETXEN_ROMUSB_GLB_CAS_RST (ROMUSB_GLB + 0x0038)
392#define NETXEN_ROMUSB_GLB_TEST_MUX_SEL (ROMUSB_GLB + 0x0044)
393#define NETXEN_ROMUSB_GLB_PEGTUNE_DONE (ROMUSB_GLB + 0x005c)
394#define NETXEN_ROMUSB_GLB_CHIP_CLK_CTRL (ROMUSB_GLB + 0x00A8)
395
396#define NETXEN_ROMUSB_GPIO(n) (ROMUSB_GLB + 0x60 + (4 * (n)))
397
398#define NETXEN_ROMUSB_ROM_INSTR_OPCODE (ROMUSB_ROM + 0x0004)
399#define NETXEN_ROMUSB_ROM_ADDRESS (ROMUSB_ROM + 0x0008)
400#define NETXEN_ROMUSB_ROM_WDATA (ROMUSB_ROM + 0x000c)
401#define NETXEN_ROMUSB_ROM_ABYTE_CNT (ROMUSB_ROM + 0x0010)
402#define NETXEN_ROMUSB_ROM_DUMMY_BYTE_CNT (ROMUSB_ROM + 0x0014)
403#define NETXEN_ROMUSB_ROM_RDATA (ROMUSB_ROM + 0x0018)
404
405/* Lock IDs for ROM lock */
406#define ROM_LOCK_DRIVER 0x0d417340
407
408/******************************************************************************
409*
410* Definitions specific to M25P flash
411*
412*******************************************************************************
413* Instructions
414*/
415#define M25P_INSTR_WREN 0x06
416#define M25P_INSTR_WRDI 0x04
417#define M25P_INSTR_RDID 0x9f
418#define M25P_INSTR_RDSR 0x05
419#define M25P_INSTR_WRSR 0x01
420#define M25P_INSTR_READ 0x03
421#define M25P_INSTR_FAST_READ 0x0b
422#define M25P_INSTR_PP 0x02
423#define M25P_INSTR_SE 0xd8
424#define M25P_INSTR_BE 0xc7
425#define M25P_INSTR_DP 0xb9
426#define M25P_INSTR_RES 0xab
427
428/* all are 1MB windows */
429
430#define NETXEN_PCI_CRB_WINDOWSIZE 0x00100000
431#define NETXEN_PCI_CRB_WINDOW(A) \
432 (NETXEN_PCI_CRBSPACE + (A)*NETXEN_PCI_CRB_WINDOWSIZE)
433
434#define NETXEN_CRB_NIU NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_NIU)
435#define NETXEN_CRB_SRE NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_SRE)
436#define NETXEN_CRB_ROMUSB \
437 NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_ROMUSB)
438#define NETXEN_CRB_I2Q NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_I2Q)
439#define NETXEN_CRB_MAX NETXEN_PCI_CRB_WINDOW(64)
440
441#define NETXEN_CRB_PCIX_HOST NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_PH)
442#define NETXEN_CRB_PCIX_HOST2 NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_PH2)
443#define NETXEN_CRB_PEG_NET_0 NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_PGN0)
444#define NETXEN_CRB_PEG_NET_1 NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_PGN1)
445#define NETXEN_CRB_PEG_NET_2 NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_PGN2)
446#define NETXEN_CRB_PEG_NET_3 NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_PGN3)
447#define NETXEN_CRB_PEG_NET_D NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_PGND)
448#define NETXEN_CRB_PEG_NET_I NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_PGNI)
449#define NETXEN_CRB_DDR_NET NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_MN)
450
451#define NETXEN_CRB_PCIX_MD NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_PS)
452#define NETXEN_CRB_PCIE NETXEN_CRB_PCIX_MD
453
454#define ISR_INT_VECTOR (NETXEN_PCIX_PS_REG(PCIX_INT_VECTOR))
455#define ISR_INT_MASK (NETXEN_PCIX_PS_REG(PCIX_INT_MASK))
456#define ISR_INT_MASK_SLOW (NETXEN_PCIX_PS_REG(PCIX_INT_MASK))
457#define ISR_INT_TARGET_STATUS (NETXEN_PCIX_PS_REG(PCIX_TARGET_STATUS))
458#define ISR_INT_TARGET_MASK (NETXEN_PCIX_PS_REG(PCIX_TARGET_MASK))
459
460#define NETXEN_PCI_MAPSIZE 128
461#define NETXEN_PCI_DDR_NET (0x00000000UL)
462#define NETXEN_PCI_QDR_NET (0x04000000UL)
463#define NETXEN_PCI_DIRECT_CRB (0x04400000UL)
464#define NETXEN_PCI_CAMQM_MAX (0x04ffffffUL)
465#define NETXEN_PCI_OCM0 (0x05000000UL)
466#define NETXEN_PCI_OCM0_MAX (0x050fffffUL)
467#define NETXEN_PCI_OCM1 (0x05100000UL)
468#define NETXEN_PCI_OCM1_MAX (0x051fffffUL)
469#define NETXEN_PCI_CRBSPACE (0x06000000UL)
470
471#define NETXEN_CRB_CAM NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_CAM)
472
473#define NETXEN_ADDR_DDR_NET (0x0000000000000000ULL)
474#define NETXEN_ADDR_DDR_NET_MAX (0x000000000fffffffULL)
475#define NETXEN_ADDR_OCM0 (0x0000000200000000ULL)
476#define NETXEN_ADDR_OCM0_MAX (0x00000002000fffffULL)
477#define NETXEN_ADDR_OCM1 (0x0000000200400000ULL)
478#define NETXEN_ADDR_OCM1_MAX (0x00000002004fffffULL)
479#define NETXEN_ADDR_QDR_NET (0x0000000300000000ULL)
480#define NETXEN_ADDR_QDR_NET_MAX (0x00000003003fffffULL)
481
482 /* 200ms delay in each loop */
483#define NETXEN_NIU_PHY_WAITLEN 200000
484 /* 10 seconds before we give up */
485#define NETXEN_NIU_PHY_WAITMAX 50
486#define NETXEN_NIU_MAX_GBE_PORTS 4
487
488#define NETXEN_NIU_MODE (NETXEN_CRB_NIU + 0x00000)
489
490#define NETXEN_NIU_XG_SINGLE_TERM (NETXEN_CRB_NIU + 0x00004)
491#define NETXEN_NIU_XG_DRIVE_HI (NETXEN_CRB_NIU + 0x00008)
492#define NETXEN_NIU_XG_DRIVE_LO (NETXEN_CRB_NIU + 0x0000c)
493#define NETXEN_NIU_XG_DTX (NETXEN_CRB_NIU + 0x00010)
494#define NETXEN_NIU_XG_DEQ (NETXEN_CRB_NIU + 0x00014)
495#define NETXEN_NIU_XG_WORD_ALIGN (NETXEN_CRB_NIU + 0x00018)
496#define NETXEN_NIU_XG_RESET (NETXEN_CRB_NIU + 0x0001c)
497#define NETXEN_NIU_XG_POWER_DOWN (NETXEN_CRB_NIU + 0x00020)
498#define NETXEN_NIU_XG_RESET_PLL (NETXEN_CRB_NIU + 0x00024)
499#define NETXEN_NIU_XG_SERDES_LOOPBACK (NETXEN_CRB_NIU + 0x00028)
500#define NETXEN_NIU_XG_DO_BYTE_ALIGN (NETXEN_CRB_NIU + 0x0002c)
501#define NETXEN_NIU_XG_TX_ENABLE (NETXEN_CRB_NIU + 0x00030)
502#define NETXEN_NIU_XG_RX_ENABLE (NETXEN_CRB_NIU + 0x00034)
503#define NETXEN_NIU_XG_STATUS (NETXEN_CRB_NIU + 0x00038)
504#define NETXEN_NIU_XG_PAUSE_THRESHOLD (NETXEN_CRB_NIU + 0x0003c)
505#define NETXEN_NIU_INT_MASK (NETXEN_CRB_NIU + 0x00040)
506#define NETXEN_NIU_ACTIVE_INT (NETXEN_CRB_NIU + 0x00044)
507#define NETXEN_NIU_MASKABLE_INT (NETXEN_CRB_NIU + 0x00048)
508
509#define NETXEN_NIU_STRAP_VALUE_SAVE_HIGHER (NETXEN_CRB_NIU + 0x0004c)
510
511#define NETXEN_NIU_GB_SERDES_RESET (NETXEN_CRB_NIU + 0x00050)
512#define NETXEN_NIU_GB0_GMII_MODE (NETXEN_CRB_NIU + 0x00054)
513#define NETXEN_NIU_GB0_MII_MODE (NETXEN_CRB_NIU + 0x00058)
514#define NETXEN_NIU_GB1_GMII_MODE (NETXEN_CRB_NIU + 0x0005c)
515#define NETXEN_NIU_GB1_MII_MODE (NETXEN_CRB_NIU + 0x00060)
516#define NETXEN_NIU_GB2_GMII_MODE (NETXEN_CRB_NIU + 0x00064)
517#define NETXEN_NIU_GB2_MII_MODE (NETXEN_CRB_NIU + 0x00068)
518#define NETXEN_NIU_GB3_GMII_MODE (NETXEN_CRB_NIU + 0x0006c)
519#define NETXEN_NIU_GB3_MII_MODE (NETXEN_CRB_NIU + 0x00070)
520#define NETXEN_NIU_REMOTE_LOOPBACK (NETXEN_CRB_NIU + 0x00074)
521#define NETXEN_NIU_GB0_HALF_DUPLEX (NETXEN_CRB_NIU + 0x00078)
522#define NETXEN_NIU_GB1_HALF_DUPLEX (NETXEN_CRB_NIU + 0x0007c)
523#define NETXEN_NIU_RESET_SYS_FIFOS (NETXEN_CRB_NIU + 0x00088)
524#define NETXEN_NIU_GB_CRC_DROP (NETXEN_CRB_NIU + 0x0008c)
525#define NETXEN_NIU_GB_DROP_WRONGADDR (NETXEN_CRB_NIU + 0x00090)
526#define NETXEN_NIU_TEST_MUX_CTL (NETXEN_CRB_NIU + 0x00094)
527#define NETXEN_NIU_XG_PAUSE_CTL (NETXEN_CRB_NIU + 0x00098)
528#define NETXEN_NIU_XG_PAUSE_LEVEL (NETXEN_CRB_NIU + 0x000dc)
529#define NETXEN_NIU_XG_SEL (NETXEN_CRB_NIU + 0x00128)
530
531#define NETXEN_NIU_FULL_LEVEL_XG (NETXEN_CRB_NIU + 0x00450)
532
533#define NETXEN_NIU_XG1_RESET (NETXEN_CRB_NIU + 0x0011c)
534#define NETXEN_NIU_XG1_POWER_DOWN (NETXEN_CRB_NIU + 0x00120)
535#define NETXEN_NIU_XG1_RESET_PLL (NETXEN_CRB_NIU + 0x00124)
536
537#define NETXEN_MAC_ADDR_CNTL_REG (NETXEN_CRB_NIU + 0x1000)
538
539#define NETXEN_MULTICAST_ADDR_HI_0 (NETXEN_CRB_NIU + 0x1010)
540#define NETXEN_MULTICAST_ADDR_HI_1 (NETXEN_CRB_NIU + 0x1014)
541#define NETXEN_MULTICAST_ADDR_HI_2 (NETXEN_CRB_NIU + 0x1018)
542#define NETXEN_MULTICAST_ADDR_HI_3 (NETXEN_CRB_NIU + 0x101c)
543
544#define NETXEN_NIU_GB_MAC_CONFIG_0(I) \
545 (NETXEN_CRB_NIU + 0x30000 + (I)*0x10000)
546#define NETXEN_NIU_GB_MAC_CONFIG_1(I) \
547 (NETXEN_CRB_NIU + 0x30004 + (I)*0x10000)
548#define NETXEN_NIU_GB_MAC_IPG_IFG(I) \
549 (NETXEN_CRB_NIU + 0x30008 + (I)*0x10000)
550#define NETXEN_NIU_GB_HALF_DUPLEX_CTRL(I) \
551 (NETXEN_CRB_NIU + 0x3000c + (I)*0x10000)
552#define NETXEN_NIU_GB_MAX_FRAME_SIZE(I) \
553 (NETXEN_CRB_NIU + 0x30010 + (I)*0x10000)
554#define NETXEN_NIU_GB_TEST_REG(I) \
555 (NETXEN_CRB_NIU + 0x3001c + (I)*0x10000)
556#define NETXEN_NIU_GB_MII_MGMT_CONFIG(I) \
557 (NETXEN_CRB_NIU + 0x30020 + (I)*0x10000)
558#define NETXEN_NIU_GB_MII_MGMT_COMMAND(I) \
559 (NETXEN_CRB_NIU + 0x30024 + (I)*0x10000)
560#define NETXEN_NIU_GB_MII_MGMT_ADDR(I) \
561 (NETXEN_CRB_NIU + 0x30028 + (I)*0x10000)
562#define NETXEN_NIU_GB_MII_MGMT_CTRL(I) \
563 (NETXEN_CRB_NIU + 0x3002c + (I)*0x10000)
564#define NETXEN_NIU_GB_MII_MGMT_STATUS(I) \
565 (NETXEN_CRB_NIU + 0x30030 + (I)*0x10000)
566#define NETXEN_NIU_GB_MII_MGMT_INDICATE(I) \
567 (NETXEN_CRB_NIU + 0x30034 + (I)*0x10000)
568#define NETXEN_NIU_GB_INTERFACE_CTRL(I) \
569 (NETXEN_CRB_NIU + 0x30038 + (I)*0x10000)
570#define NETXEN_NIU_GB_INTERFACE_STATUS(I) \
571 (NETXEN_CRB_NIU + 0x3003c + (I)*0x10000)
572#define NETXEN_NIU_GB_STATION_ADDR_0(I) \
573 (NETXEN_CRB_NIU + 0x30040 + (I)*0x10000)
574#define NETXEN_NIU_GB_STATION_ADDR_1(I) \
575 (NETXEN_CRB_NIU + 0x30044 + (I)*0x10000)
576
577#define NETXEN_NIU_XGE_CONFIG_0 (NETXEN_CRB_NIU + 0x70000)
578#define NETXEN_NIU_XGE_CONFIG_1 (NETXEN_CRB_NIU + 0x70004)
579#define NETXEN_NIU_XGE_IPG (NETXEN_CRB_NIU + 0x70008)
580#define NETXEN_NIU_XGE_STATION_ADDR_0_HI (NETXEN_CRB_NIU + 0x7000c)
581#define NETXEN_NIU_XGE_STATION_ADDR_0_1 (NETXEN_CRB_NIU + 0x70010)
582#define NETXEN_NIU_XGE_STATION_ADDR_1_LO (NETXEN_CRB_NIU + 0x70014)
583#define NETXEN_NIU_XGE_STATUS (NETXEN_CRB_NIU + 0x70018)
584#define NETXEN_NIU_XGE_MAX_FRAME_SIZE (NETXEN_CRB_NIU + 0x7001c)
585#define NETXEN_NIU_XGE_PAUSE_FRAME_VALUE (NETXEN_CRB_NIU + 0x70020)
586#define NETXEN_NIU_XGE_TX_BYTE_CNT (NETXEN_CRB_NIU + 0x70024)
587#define NETXEN_NIU_XGE_TX_FRAME_CNT (NETXEN_CRB_NIU + 0x70028)
588#define NETXEN_NIU_XGE_RX_BYTE_CNT (NETXEN_CRB_NIU + 0x7002c)
589#define NETXEN_NIU_XGE_RX_FRAME_CNT (NETXEN_CRB_NIU + 0x70030)
590#define NETXEN_NIU_XGE_AGGR_ERROR_CNT (NETXEN_CRB_NIU + 0x70034)
591#define NETXEN_NIU_XGE_MULTICAST_FRAME_CNT (NETXEN_CRB_NIU + 0x70038)
592#define NETXEN_NIU_XGE_UNICAST_FRAME_CNT (NETXEN_CRB_NIU + 0x7003c)
593#define NETXEN_NIU_XGE_CRC_ERROR_CNT (NETXEN_CRB_NIU + 0x70040)
594#define NETXEN_NIU_XGE_OVERSIZE_FRAME_ERR (NETXEN_CRB_NIU + 0x70044)
595#define NETXEN_NIU_XGE_UNDERSIZE_FRAME_ERR (NETXEN_CRB_NIU + 0x70048)
596#define NETXEN_NIU_XGE_LOCAL_ERROR_CNT (NETXEN_CRB_NIU + 0x7004c)
597#define NETXEN_NIU_XGE_REMOTE_ERROR_CNT (NETXEN_CRB_NIU + 0x70050)
598#define NETXEN_NIU_XGE_CONTROL_CHAR_CNT (NETXEN_CRB_NIU + 0x70054)
599#define NETXEN_NIU_XGE_PAUSE_FRAME_CNT (NETXEN_CRB_NIU + 0x70058)
600#define NETXEN_NIU_XG1_CONFIG_0 (NETXEN_CRB_NIU + 0x80000)
601#define NETXEN_NIU_XG1_CONFIG_1 (NETXEN_CRB_NIU + 0x80004)
602#define NETXEN_NIU_XG1_IPG (NETXEN_CRB_NIU + 0x80008)
603#define NETXEN_NIU_XG1_STATION_ADDR_0_HI (NETXEN_CRB_NIU + 0x8000c)
604#define NETXEN_NIU_XG1_STATION_ADDR_0_1 (NETXEN_CRB_NIU + 0x80010)
605#define NETXEN_NIU_XG1_STATION_ADDR_1_LO (NETXEN_CRB_NIU + 0x80014)
606#define NETXEN_NIU_XG1_STATUS (NETXEN_CRB_NIU + 0x80018)
607#define NETXEN_NIU_XG1_MAX_FRAME_SIZE (NETXEN_CRB_NIU + 0x8001c)
608#define NETXEN_NIU_XG1_PAUSE_FRAME_VALUE (NETXEN_CRB_NIU + 0x80020)
609#define NETXEN_NIU_XG1_TX_BYTE_CNT (NETXEN_CRB_NIU + 0x80024)
610#define NETXEN_NIU_XG1_TX_FRAME_CNT (NETXEN_CRB_NIU + 0x80028)
611#define NETXEN_NIU_XG1_RX_BYTE_CNT (NETXEN_CRB_NIU + 0x8002c)
612#define NETXEN_NIU_XG1_RX_FRAME_CNT (NETXEN_CRB_NIU + 0x80030)
613#define NETXEN_NIU_XG1_AGGR_ERROR_CNT (NETXEN_CRB_NIU + 0x80034)
614#define NETXEN_NIU_XG1_MULTICAST_FRAME_CNT (NETXEN_CRB_NIU + 0x80038)
615#define NETXEN_NIU_XG1_UNICAST_FRAME_CNT (NETXEN_CRB_NIU + 0x8003c)
616#define NETXEN_NIU_XG1_CRC_ERROR_CNT (NETXEN_CRB_NIU + 0x80040)
617#define NETXEN_NIU_XG1_OVERSIZE_FRAME_ERR (NETXEN_CRB_NIU + 0x80044)
618#define NETXEN_NIU_XG1_UNDERSIZE_FRAME_ERR (NETXEN_CRB_NIU + 0x80048)
619#define NETXEN_NIU_XG1_LOCAL_ERROR_CNT (NETXEN_CRB_NIU + 0x8004c)
620#define NETXEN_NIU_XG1_REMOTE_ERROR_CNT (NETXEN_CRB_NIU + 0x80050)
621#define NETXEN_NIU_XG1_CONTROL_CHAR_CNT (NETXEN_CRB_NIU + 0x80054)
622#define NETXEN_NIU_XG1_PAUSE_FRAME_CNT (NETXEN_CRB_NIU + 0x80058)
623
624/* XG Link status */
625#define XG_LINK_UP 0x10
626#define XG_LINK_DOWN 0x20
627
628#define NETXEN_CAM_RAM_BASE (NETXEN_CRB_CAM + 0x02000)
629#define NETXEN_CAM_RAM(reg) (NETXEN_CAM_RAM_BASE + (reg))
630#define NETXEN_FW_VERSION_MAJOR (NETXEN_CAM_RAM(0x150))
631#define NETXEN_FW_VERSION_MINOR (NETXEN_CAM_RAM(0x154))
632#define NETXEN_FW_VERSION_SUB (NETXEN_CAM_RAM(0x158))
633#define NETXEN_ROM_LOCK_ID (NETXEN_CAM_RAM(0x100))
634
635#define NETXEN_PHY_LOCK_ID (NETXEN_CAM_RAM(0x120))
636
637/* Lock IDs for PHY lock */
638#define PHY_LOCK_DRIVER 0x44524956
639
640/* Used for PS PCI Memory access */
641#define PCIX_PS_OP_ADDR_LO (0x10000)
642/* via CRB (PS side only) */
643#define PCIX_PS_OP_ADDR_HI (0x10004)
644
645#define PCIX_INT_VECTOR (0x10100)
646#define PCIX_INT_MASK (0x10104)
647
648#define PCIX_MN_WINDOW (0x10200)
649#define PCIX_MS_WINDOW (0x10204)
650#define PCIX_SN_WINDOW (0x10208)
651#define PCIX_CRB_WINDOW (0x10210)
652
653#define PCIX_TARGET_STATUS (0x10118)
654#define PCIX_TARGET_MASK (0x10128)
655
656#define PCIX_MSI_F0 (0x13000)
657
658#define PCIX_PS_MEM_SPACE (0x90000)
659
660#define NETXEN_PCIX_PH_REG(reg) (NETXEN_CRB_PCIE + (reg))
661#define NETXEN_PCIX_PS_REG(reg) (NETXEN_CRB_PCIX_MD + (reg))
662
663#define NETXEN_PCIE_REG(reg) (NETXEN_CRB_PCIE + (reg))
664
665#define PCIE_MAX_DMA_XFER_SIZE (0x1404c)
666
667#define PCIE_DCR 0x00d8
668
669#define PCIE_SEM2_LOCK (0x1c010) /* Flash lock */
670#define PCIE_SEM2_UNLOCK (0x1c014) /* Flash unlock */
671#define PCIE_SEM3_LOCK (0x1c018) /* Phy lock */
672#define PCIE_SEM3_UNLOCK (0x1c01c) /* Phy unlock */
673
674#define PCIE_TGT_SPLIT_CHICKEN (0x12080)
675
676#define PCIE_MAX_MASTER_SPLIT (0x14048)
677
678#endif /* __NETXEN_NIC_HDR_H_ */
diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c
new file mode 100644
index 000000000000..9147b6048dfb
--- /dev/null
+++ b/drivers/net/netxen/netxen_nic_hw.c
@@ -0,0 +1,1293 @@
1/*
2 * Copyright (C) 2003 - 2006 NetXen, Inc.
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 * MA 02111-1307, USA.
19 *
20 * The full GNU General Public License is included in this distribution
21 * in the file called LICENSE.
22 *
23 * Contact Information:
24 * info@netxen.com
25 * NetXen,
26 * 3965 Freedom Circle, Fourth floor,
27 * Santa Clara, CA 95054
28 *
29 *
30 * Source file for NIC routines to access the Phantom hardware
31 *
32 */
33
34#include "netxen_nic.h"
35#include "netxen_nic_hw.h"
36#include "netxen_nic_phan_reg.h"
37
38/* PCI Windowing for DDR regions. */
39
40#define ADDR_IN_RANGE(addr, low, high) \
41 (((addr) <= (high)) && ((addr) >= (low)))
42
43#define NETXEN_FLASH_BASE (BOOTLD_START)
44#define NETXEN_PHANTOM_MEM_BASE (NETXEN_FLASH_BASE)
45#define NETXEN_MAX_MTU 8000 + NETXEN_ENET_HEADER_SIZE + NETXEN_ETH_FCS_SIZE
46#define NETXEN_MIN_MTU 64
47#define NETXEN_ETH_FCS_SIZE 4
48#define NETXEN_ENET_HEADER_SIZE 14
49#define NETXEN_WINDOW_ONE 0x2000000 /*CRB Window: bit 25 of CRB address */
50#define NETXEN_FIRMWARE_LEN ((16 * 1024) / 4)
51#define NETXEN_NIU_HDRSIZE (0x1 << 6)
52#define NETXEN_NIU_TLRSIZE (0x1 << 5)
53
54#define lower32(x) ((u32)((x) & 0xffffffff))
55#define upper32(x) \
56 ((u32)(((unsigned long long)(x) >> 32) & 0xffffffff))
57
58#define NETXEN_NIC_ZERO_PAUSE_ADDR 0ULL
59#define NETXEN_NIC_UNIT_PAUSE_ADDR 0x200ULL
60#define NETXEN_NIC_EPG_PAUSE_ADDR1 0x2200010000c28001ULL
61#define NETXEN_NIC_EPG_PAUSE_ADDR2 0x0100088866554433ULL
62
63#define NETXEN_NIC_WINDOW_MARGIN 0x100000
64
65unsigned long netxen_nic_pci_set_window(struct netxen_adapter *adapter,
66 unsigned long long addr);
67void netxen_free_hw_resources(struct netxen_adapter *adapter);
68
69int netxen_nic_set_mac(struct net_device *netdev, void *p)
70{
71 struct netxen_port *port = netdev_priv(netdev);
72 struct netxen_adapter *adapter = port->adapter;
73 struct sockaddr *addr = p;
74
75 if (netif_running(netdev))
76 return -EBUSY;
77
78 if (!is_valid_ether_addr(addr->sa_data))
79 return -EADDRNOTAVAIL;
80
81 DPRINTK(INFO, "valid ether addr\n");
82 memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
83
84 if (adapter->macaddr_set)
85 adapter->macaddr_set(port, addr->sa_data);
86
87 return 0;
88}
89
90/*
91 * netxen_nic_set_multi - Multicast
92 */
93void netxen_nic_set_multi(struct net_device *netdev)
94{
95 struct netxen_port *port = netdev_priv(netdev);
96 struct netxen_adapter *adapter = port->adapter;
97 struct dev_mc_list *mc_ptr;
98 __le32 netxen_mac_addr_cntl_data = 0;
99
100 mc_ptr = netdev->mc_list;
101 if (netdev->flags & IFF_PROMISC) {
102 if (adapter->set_promisc)
103 adapter->set_promisc(adapter,
104 port->portnum,
105 NETXEN_NIU_PROMISC_MODE);
106 } else {
107 if (adapter->unset_promisc &&
108 adapter->ahw.boardcfg.board_type
109 != NETXEN_BRDTYPE_P2_SB31_10G_IMEZ)
110 adapter->unset_promisc(adapter,
111 port->portnum,
112 NETXEN_NIU_NON_PROMISC_MODE);
113 }
114 if (adapter->ahw.board_type == NETXEN_NIC_XGBE) {
115 netxen_nic_mcr_set_mode_select(netxen_mac_addr_cntl_data, 0x03);
116 netxen_nic_mcr_set_id_pool0(netxen_mac_addr_cntl_data, 0x00);
117 netxen_nic_mcr_set_id_pool1(netxen_mac_addr_cntl_data, 0x00);
118 netxen_nic_mcr_set_id_pool2(netxen_mac_addr_cntl_data, 0x00);
119 netxen_nic_mcr_set_id_pool3(netxen_mac_addr_cntl_data, 0x00);
120 netxen_nic_mcr_set_enable_xtnd0(netxen_mac_addr_cntl_data);
121 netxen_nic_mcr_set_enable_xtnd1(netxen_mac_addr_cntl_data);
122 netxen_nic_mcr_set_enable_xtnd2(netxen_mac_addr_cntl_data);
123 netxen_nic_mcr_set_enable_xtnd3(netxen_mac_addr_cntl_data);
124 } else {
125 netxen_nic_mcr_set_mode_select(netxen_mac_addr_cntl_data, 0x00);
126 netxen_nic_mcr_set_id_pool0(netxen_mac_addr_cntl_data, 0x00);
127 netxen_nic_mcr_set_id_pool1(netxen_mac_addr_cntl_data, 0x01);
128 netxen_nic_mcr_set_id_pool2(netxen_mac_addr_cntl_data, 0x02);
129 netxen_nic_mcr_set_id_pool3(netxen_mac_addr_cntl_data, 0x03);
130 }
131 writel(netxen_mac_addr_cntl_data,
132 NETXEN_CRB_NORMALIZE(adapter, NETXEN_MAC_ADDR_CNTL_REG));
133 if (adapter->ahw.board_type == NETXEN_NIC_XGBE) {
134 writel(netxen_mac_addr_cntl_data,
135 NETXEN_CRB_NORMALIZE(adapter,
136 NETXEN_MULTICAST_ADDR_HI_0));
137 } else {
138 writel(netxen_mac_addr_cntl_data,
139 NETXEN_CRB_NORMALIZE(adapter,
140 NETXEN_MULTICAST_ADDR_HI_1));
141 }
142 netxen_mac_addr_cntl_data = 0;
143 writel(netxen_mac_addr_cntl_data,
144 NETXEN_CRB_NORMALIZE(adapter, NETXEN_NIU_GB_DROP_WRONGADDR));
145}
146
147/*
148 * netxen_nic_change_mtu - Change the Maximum Transfer Unit
149 * @returns 0 on success, negative on failure
150 */
151int netxen_nic_change_mtu(struct net_device *netdev, int mtu)
152{
153 struct netxen_port *port = netdev_priv(netdev);
154 struct netxen_adapter *adapter = port->adapter;
155 int eff_mtu = mtu + NETXEN_ENET_HEADER_SIZE + NETXEN_ETH_FCS_SIZE;
156
157 if ((eff_mtu > NETXEN_MAX_MTU) || (eff_mtu < NETXEN_MIN_MTU)) {
158 printk(KERN_ERR "%s: %s %d is not supported.\n",
159 netxen_nic_driver_name, netdev->name, mtu);
160 return -EINVAL;
161 }
162
163 if (adapter->set_mtu)
164 adapter->set_mtu(port, mtu);
165 netdev->mtu = mtu;
166
167 return 0;
168}
169
170/*
171 * check if the firmware has been downloaded and ready to run and
172 * setup the address for the descriptors in the adapter
173 */
174int netxen_nic_hw_resources(struct netxen_adapter *adapter)
175{
176 struct netxen_hardware_context *hw = &adapter->ahw;
177 u32 state = 0;
178 void *addr;
179 int loops = 0, err = 0;
180 int ctx, ring;
181 u32 card_cmdring = 0;
182 struct netxen_recv_context *recv_ctx;
183 struct netxen_rcv_desc_ctx *rcv_desc;
184
185 DPRINTK(INFO, "crb_base: %lx %x", NETXEN_PCI_CRBSPACE,
186 PCI_OFFSET_SECOND_RANGE(adapter, NETXEN_PCI_CRBSPACE));
187 DPRINTK(INFO, "cam base: %lx %x", NETXEN_CRB_CAM,
188 pci_base_offset(adapter, NETXEN_CRB_CAM));
189 DPRINTK(INFO, "cam RAM: %lx %x", NETXEN_CAM_RAM_BASE,
190 pci_base_offset(adapter, NETXEN_CAM_RAM_BASE));
191
192 /* Window 1 call */
193 card_cmdring = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_CMDRING));
194
195 DPRINTK(INFO, "Command Peg sends 0x%x for cmdring base\n",
196 card_cmdring);
197
198 for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) {
199 DPRINTK(INFO, "Command Peg ready..waiting for rcv peg\n");
200 loops = 0;
201 state = 0;
202 /* Window 1 call */
203 state = readl(NETXEN_CRB_NORMALIZE(adapter,
204 recv_crb_registers[ctx].
205 crb_rcvpeg_state));
206 while (state != PHAN_PEG_RCV_INITIALIZED && loops < 20) {
207 udelay(100);
208 /* Window 1 call */
209 state = readl(NETXEN_CRB_NORMALIZE(adapter,
210 recv_crb_registers
211 [ctx].
212 crb_rcvpeg_state));
213 loops++;
214 }
215 if (loops >= 20) {
216 printk(KERN_ERR "Rcv Peg initialization not complete:"
217 "%x.\n", state);
218 err = -EIO;
219 return err;
220 }
221 }
222 DPRINTK(INFO, "Recieve Peg ready too. starting stuff\n");
223
224 addr = netxen_alloc(adapter->ahw.pdev,
225 sizeof(struct netxen_ring_ctx) +
226 sizeof(uint32_t),
227 (dma_addr_t *) & adapter->ctx_desc_phys_addr,
228 &adapter->ctx_desc_pdev);
229
230 printk("ctx_desc_phys_addr: 0x%llx\n",
231 (u64) adapter->ctx_desc_phys_addr);
232 if (addr == NULL) {
233 DPRINTK(ERR, "bad return from pci_alloc_consistent\n");
234 err = -ENOMEM;
235 return err;
236 }
237 memset(addr, 0, sizeof(struct netxen_ring_ctx));
238 adapter->ctx_desc = (struct netxen_ring_ctx *)addr;
239 adapter->ctx_desc->cmd_consumer_offset = adapter->ctx_desc_phys_addr
240 + sizeof(struct netxen_ring_ctx);
241 adapter->cmd_consumer = (uint32_t *) (((char *)addr) +
242 sizeof(struct netxen_ring_ctx));
243
244 addr = pci_alloc_consistent(adapter->ahw.pdev,
245 sizeof(struct cmd_desc_type0) *
246 adapter->max_tx_desc_count,
247 (dma_addr_t *) & hw->cmd_desc_phys_addr);
248 printk("cmd_desc_phys_addr: 0x%llx\n", (u64) hw->cmd_desc_phys_addr);
249
250 if (addr == NULL) {
251 DPRINTK(ERR, "bad return from pci_alloc_consistent\n");
252 netxen_free_hw_resources(adapter);
253 return -ENOMEM;
254 }
255
256 adapter->ctx_desc->cmd_ring_addr_lo =
257 hw->cmd_desc_phys_addr & 0xffffffffUL;
258 adapter->ctx_desc->cmd_ring_addr_hi =
259 ((u64) hw->cmd_desc_phys_addr >> 32);
260 adapter->ctx_desc->cmd_ring_size = adapter->max_tx_desc_count;
261
262 hw->cmd_desc_head = (struct cmd_desc_type0 *)addr;
263
264 for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) {
265 recv_ctx = &adapter->recv_ctx[ctx];
266
267 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) {
268 rcv_desc = &recv_ctx->rcv_desc[ring];
269 addr = netxen_alloc(adapter->ahw.pdev,
270 RCV_DESC_RINGSIZE,
271 &rcv_desc->phys_addr,
272 &rcv_desc->phys_pdev);
273 if (addr == NULL) {
274 DPRINTK(ERR, "bad return from "
275 "pci_alloc_consistent\n");
276 netxen_free_hw_resources(adapter);
277 err = -ENOMEM;
278 return err;
279 }
280 rcv_desc->desc_head = (struct rcv_desc *)addr;
281 adapter->ctx_desc->rcv_ctx[ring].rcv_ring_addr_lo =
282 rcv_desc->phys_addr & 0xffffffffUL;
283 adapter->ctx_desc->rcv_ctx[ring].rcv_ring_addr_hi =
284 ((u64) rcv_desc->phys_addr >> 32);
285 adapter->ctx_desc->rcv_ctx[ring].rcv_ring_size =
286 rcv_desc->max_rx_desc_count;
287 }
288
289 addr = netxen_alloc(adapter->ahw.pdev, STATUS_DESC_RINGSIZE,
290 &recv_ctx->rcv_status_desc_phys_addr,
291 &recv_ctx->rcv_status_desc_pdev);
292 if (addr == NULL) {
293 DPRINTK(ERR, "bad return from"
294 " pci_alloc_consistent\n");
295 netxen_free_hw_resources(adapter);
296 err = -ENOMEM;
297 return err;
298 }
299 recv_ctx->rcv_status_desc_head = (struct status_desc *)addr;
300 adapter->ctx_desc->sts_ring_addr_lo =
301 recv_ctx->rcv_status_desc_phys_addr & 0xffffffffUL;
302 adapter->ctx_desc->sts_ring_addr_hi =
303 ((u64) recv_ctx->rcv_status_desc_phys_addr >> 32);
304 adapter->ctx_desc->sts_ring_size = adapter->max_rx_desc_count;
305
306 }
307 /* Window = 1 */
308
309 writel(lower32(adapter->ctx_desc_phys_addr),
310 NETXEN_CRB_NORMALIZE(adapter, CRB_CTX_ADDR_REG_LO));
311 writel(upper32(adapter->ctx_desc_phys_addr),
312 NETXEN_CRB_NORMALIZE(adapter, CRB_CTX_ADDR_REG_HI));
313 writel(NETXEN_CTX_SIGNATURE,
314 NETXEN_CRB_NORMALIZE(adapter, CRB_CTX_SIGNATURE_REG));
315 return err;
316}
317
318void netxen_free_hw_resources(struct netxen_adapter *adapter)
319{
320 struct netxen_recv_context *recv_ctx;
321 struct netxen_rcv_desc_ctx *rcv_desc;
322 int ctx, ring;
323
324 if (adapter->ctx_desc != NULL) {
325 pci_free_consistent(adapter->ctx_desc_pdev,
326 sizeof(struct netxen_ring_ctx) +
327 sizeof(uint32_t),
328 adapter->ctx_desc,
329 adapter->ctx_desc_phys_addr);
330 adapter->ctx_desc = NULL;
331 }
332
333 if (adapter->ahw.cmd_desc_head != NULL) {
334 pci_free_consistent(adapter->ahw.cmd_desc_pdev,
335 sizeof(struct cmd_desc_type0) *
336 adapter->max_tx_desc_count,
337 adapter->ahw.cmd_desc_head,
338 adapter->ahw.cmd_desc_phys_addr);
339 adapter->ahw.cmd_desc_head = NULL;
340 }
341 /* Special handling: there are 2 ports on this board */
342 if (adapter->ahw.boardcfg.board_type == NETXEN_BRDTYPE_P2_SB31_10G_IMEZ) {
343 adapter->ahw.max_ports = 2;
344 }
345
346 for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) {
347 recv_ctx = &adapter->recv_ctx[ctx];
348 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) {
349 rcv_desc = &recv_ctx->rcv_desc[ring];
350
351 if (rcv_desc->desc_head != NULL) {
352 pci_free_consistent(rcv_desc->phys_pdev,
353 RCV_DESC_RINGSIZE,
354 rcv_desc->desc_head,
355 rcv_desc->phys_addr);
356 rcv_desc->desc_head = NULL;
357 }
358 }
359
360 if (recv_ctx->rcv_status_desc_head != NULL) {
361 pci_free_consistent(recv_ctx->rcv_status_desc_pdev,
362 STATUS_DESC_RINGSIZE,
363 recv_ctx->rcv_status_desc_head,
364 recv_ctx->
365 rcv_status_desc_phys_addr);
366 recv_ctx->rcv_status_desc_head = NULL;
367 }
368 }
369}
370
371void netxen_tso_check(struct netxen_adapter *adapter,
372 struct cmd_desc_type0 *desc, struct sk_buff *skb)
373{
374 if (desc->mss) {
375 desc->total_hdr_length = sizeof(struct ethhdr) +
376 ((skb->nh.iph)->ihl * sizeof(u32)) +
377 ((skb->h.th)->doff * sizeof(u32));
378 netxen_set_cmd_desc_opcode(desc, TX_TCP_LSO);
379 } else if (skb->ip_summed == CHECKSUM_COMPLETE) {
380 if (skb->nh.iph->protocol == IPPROTO_TCP) {
381 netxen_set_cmd_desc_opcode(desc, TX_TCP_PKT);
382 } else if (skb->nh.iph->protocol == IPPROTO_UDP) {
383 netxen_set_cmd_desc_opcode(desc, TX_UDP_PKT);
384 } else {
385 return;
386 }
387 }
388 adapter->stats.xmitcsummed++;
389 desc->tcp_hdr_offset = skb->h.raw - skb->data;
390 netxen_set_cmd_desc_totallength(desc,
391 cpu_to_le32
392 (netxen_get_cmd_desc_totallength
393 (desc)));
394 desc->ip_hdr_offset = skb->nh.raw - skb->data;
395}
396
397int netxen_is_flash_supported(struct netxen_adapter *adapter)
398{
399 const int locs[] = { 0, 0x4, 0x100, 0x4000, 0x4128 };
400 int addr, val01, val02, i, j;
401
402 /* if the flash size less than 4Mb, make huge war cry and die */
403 for (j = 1; j < 4; j++) {
404 addr = j * NETXEN_NIC_WINDOW_MARGIN;
405 for (i = 0; i < (sizeof(locs) / sizeof(locs[0])); i++) {
406 if (netxen_rom_fast_read(adapter, locs[i], &val01) == 0
407 && netxen_rom_fast_read(adapter, (addr + locs[i]),
408 &val02) == 0) {
409 if (val01 == val02)
410 return -1;
411 } else
412 return -1;
413 }
414 }
415
416 return 0;
417}
418
419static int netxen_get_flash_block(struct netxen_adapter *adapter, int base,
420 int size, u32 * buf)
421{
422 int i, addr;
423 u32 *ptr32;
424
425 addr = base;
426 ptr32 = buf;
427 for (i = 0; i < size / sizeof(u32); i++) {
428 if (netxen_rom_fast_read(adapter, addr, ptr32) == -1)
429 return -1;
430 ptr32++;
431 addr += sizeof(u32);
432 }
433 if ((char *)buf + size > (char *)ptr32) {
434 u32 local;
435
436 if (netxen_rom_fast_read(adapter, addr, &local) == -1)
437 return -1;
438 memcpy(ptr32, &local, (char *)buf + size - (char *)ptr32);
439 }
440
441 return 0;
442}
443
444int netxen_get_flash_mac_addr(struct netxen_adapter *adapter, u64 mac[])
445{
446 u32 *pmac = (u32 *) & mac[0];
447
448 if (netxen_get_flash_block(adapter,
449 USER_START +
450 offsetof(struct netxen_new_user_info,
451 mac_addr),
452 FLASH_NUM_PORTS * sizeof(u64), pmac) == -1) {
453 return -1;
454 }
455 if (*mac == ~0ULL) {
456 if (netxen_get_flash_block(adapter,
457 USER_START_OLD +
458 offsetof(struct netxen_user_old_info,
459 mac_addr),
460 FLASH_NUM_PORTS * sizeof(u64),
461 pmac) == -1)
462 return -1;
463 if (*mac == ~0ULL)
464 return -1;
465 }
466 return 0;
467}
468
469/*
470 * Changes the CRB window to the specified window.
471 */
472void netxen_nic_pci_change_crbwindow(struct netxen_adapter *adapter, u32 wndw)
473{
474 void __iomem *offset;
475 u32 tmp;
476 int count = 0;
477
478 if (adapter->curr_window == wndw)
479 return;
480
481 /*
482 * Move the CRB window.
483 * We need to write to the "direct access" region of PCI
484 * to avoid a race condition where the window register has
485 * not been successfully written across CRB before the target
486 * register address is received by PCI. The direct region bypasses
487 * the CRB bus.
488 */
489 offset =
490 PCI_OFFSET_SECOND_RANGE(adapter,
491 NETXEN_PCIX_PH_REG(PCIX_CRB_WINDOW));
492
493 if (wndw & 0x1)
494 wndw = NETXEN_WINDOW_ONE;
495
496 writel(wndw, offset);
497
498 /* MUST make sure window is set before we forge on... */
499 while ((tmp = readl(offset)) != wndw) {
500 printk(KERN_WARNING "%s: %s WARNING: CRB window value not "
501 "registered properly: 0x%08x.\n",
502 netxen_nic_driver_name, __FUNCTION__, tmp);
503 mdelay(1);
504 if (count >= 10)
505 break;
506 count++;
507 }
508
509 adapter->curr_window = wndw;
510}
511
512void netxen_load_firmware(struct netxen_adapter *adapter)
513{
514 int i;
515 long data, size = 0;
516 long flashaddr = NETXEN_FLASH_BASE, memaddr = NETXEN_PHANTOM_MEM_BASE;
517 u64 off;
518 void __iomem *addr;
519
520 size = NETXEN_FIRMWARE_LEN;
521 writel(1, NETXEN_CRB_NORMALIZE(adapter, NETXEN_ROMUSB_GLB_CAS_RST));
522
523 for (i = 0; i < size; i++) {
524 if (netxen_rom_fast_read(adapter, flashaddr, (int *)&data) != 0) {
525 DPRINTK(ERR,
526 "Error in netxen_rom_fast_read(). Will skip"
527 "loading flash image\n");
528 return;
529 }
530 off = netxen_nic_pci_set_window(adapter, memaddr);
531 addr = pci_base_offset(adapter, off);
532 writel(data, addr);
533 flashaddr += 4;
534 memaddr += 4;
535 }
536 udelay(100);
537 /* make sure Casper is powered on */
538 writel(0x3fff,
539 NETXEN_CRB_NORMALIZE(adapter, NETXEN_ROMUSB_GLB_CHIP_CLK_CTRL));
540 writel(0, NETXEN_CRB_NORMALIZE(adapter, NETXEN_ROMUSB_GLB_CAS_RST));
541
542 udelay(100);
543}
544
545int
546netxen_nic_hw_write_wx(struct netxen_adapter *adapter, u64 off, void *data,
547 int len)
548{
549 void __iomem *addr;
550
551 if (ADDR_IN_WINDOW1(off)) {
552 addr = NETXEN_CRB_NORMALIZE(adapter, off);
553 } else { /* Window 0 */
554 addr = pci_base_offset(adapter, off);
555 netxen_nic_pci_change_crbwindow(adapter, 0);
556 }
557
558 DPRINTK(INFO, "writing to base %lx offset %llx addr %p"
559 " data %llx len %d\n",
560 pci_base(adapter, off), off, addr,
561 *(unsigned long long *)data, len);
562 if (!addr) {
563 netxen_nic_pci_change_crbwindow(adapter, 1);
564 return 1;
565 }
566
567 switch (len) {
568 case 1:
569 writeb(*(u8 *) data, addr);
570 break;
571 case 2:
572 writew(*(u16 *) data, addr);
573 break;
574 case 4:
575 writel(*(u32 *) data, addr);
576 break;
577 case 8:
578 writeq(*(u64 *) data, addr);
579 break;
580 default:
581 DPRINTK(INFO,
582 "writing data %lx to offset %llx, num words=%d\n",
583 *(unsigned long *)data, off, (len >> 3));
584
585 netxen_nic_hw_block_write64((u64 __iomem *) data, addr,
586 (len >> 3));
587 break;
588 }
589 if (!ADDR_IN_WINDOW1(off))
590 netxen_nic_pci_change_crbwindow(adapter, 1);
591
592 return 0;
593}
594
595int
596netxen_nic_hw_read_wx(struct netxen_adapter *adapter, u64 off, void *data,
597 int len)
598{
599 void __iomem *addr;
600
601 if (ADDR_IN_WINDOW1(off)) { /* Window 1 */
602 addr = NETXEN_CRB_NORMALIZE(adapter, off);
603 } else { /* Window 0 */
604 addr = pci_base_offset(adapter, off);
605 netxen_nic_pci_change_crbwindow(adapter, 0);
606 }
607
608 DPRINTK(INFO, "reading from base %lx offset %llx addr %p\n",
609 pci_base(adapter, off), off, addr);
610 if (!addr) {
611 netxen_nic_pci_change_crbwindow(adapter, 1);
612 return 1;
613 }
614 switch (len) {
615 case 1:
616 *(u8 *) data = readb(addr);
617 break;
618 case 2:
619 *(u16 *) data = readw(addr);
620 break;
621 case 4:
622 *(u32 *) data = readl(addr);
623 break;
624 case 8:
625 *(u64 *) data = readq(addr);
626 break;
627 default:
628 netxen_nic_hw_block_read64((u64 __iomem *) data, addr,
629 (len >> 3));
630 break;
631 }
632 DPRINTK(INFO, "read %lx\n", *(unsigned long *)data);
633
634 if (!ADDR_IN_WINDOW1(off))
635 netxen_nic_pci_change_crbwindow(adapter, 1);
636
637 return 0;
638}
639
640void netxen_nic_reg_write(struct netxen_adapter *adapter, u64 off, u32 val)
641{ /* Only for window 1 */
642 void __iomem *addr;
643
644 addr = NETXEN_CRB_NORMALIZE(adapter, off);
645 DPRINTK(INFO, "writing to base %lx offset %llx addr %p data %x\n",
646 pci_base(adapter, off), off, addr, val);
647 writel(val, addr);
648
649}
650
651int netxen_nic_reg_read(struct netxen_adapter *adapter, u64 off)
652{ /* Only for window 1 */
653 void __iomem *addr;
654 int val;
655
656 addr = NETXEN_CRB_NORMALIZE(adapter, off);
657 DPRINTK(INFO, "reading from base %lx offset %llx addr %p\n",
658 pci_base(adapter, off), off, addr);
659 val = readl(addr);
660 writel(val, addr);
661
662 return val;
663}
664
665/* Change the window to 0, write and change back to window 1. */
666void netxen_nic_write_w0(struct netxen_adapter *adapter, u32 index, u32 value)
667{
668 void __iomem *addr;
669
670 netxen_nic_pci_change_crbwindow(adapter, 0);
671 addr = pci_base_offset(adapter, index);
672 writel(value, addr);
673 netxen_nic_pci_change_crbwindow(adapter, 1);
674}
675
676/* Change the window to 0, read and change back to window 1. */
677void netxen_nic_read_w0(struct netxen_adapter *adapter, u32 index, u32 * value)
678{
679 void __iomem *addr;
680
681 addr = pci_base_offset(adapter, index);
682
683 netxen_nic_pci_change_crbwindow(adapter, 0);
684 *value = readl(addr);
685 netxen_nic_pci_change_crbwindow(adapter, 1);
686}
687
688int netxen_pci_set_window_warning_count = 0;
689
690unsigned long
691netxen_nic_pci_set_window(struct netxen_adapter *adapter,
692 unsigned long long addr)
693{
694 static int ddr_mn_window = -1;
695 static int qdr_sn_window = -1;
696 int window;
697
698 if (ADDR_IN_RANGE(addr, NETXEN_ADDR_DDR_NET, NETXEN_ADDR_DDR_NET_MAX)) {
699 /* DDR network side */
700 addr -= NETXEN_ADDR_DDR_NET;
701 window = (addr >> 25) & 0x3ff;
702 if (ddr_mn_window != window) {
703 ddr_mn_window = window;
704 writel(window, PCI_OFFSET_SECOND_RANGE(adapter,
705 NETXEN_PCIX_PH_REG
706 (PCIX_MN_WINDOW)));
707 /* MUST make sure window is set before we forge on... */
708 readl(PCI_OFFSET_SECOND_RANGE(adapter,
709 NETXEN_PCIX_PH_REG
710 (PCIX_MN_WINDOW)));
711 }
712 addr -= (window * NETXEN_WINDOW_ONE);
713 addr += NETXEN_PCI_DDR_NET;
714 } else if (ADDR_IN_RANGE(addr, NETXEN_ADDR_OCM0, NETXEN_ADDR_OCM0_MAX)) {
715 addr -= NETXEN_ADDR_OCM0;
716 addr += NETXEN_PCI_OCM0;
717 } else if (ADDR_IN_RANGE(addr, NETXEN_ADDR_OCM1, NETXEN_ADDR_OCM1_MAX)) {
718 addr -= NETXEN_ADDR_OCM1;
719 addr += NETXEN_PCI_OCM1;
720 } else
721 if (ADDR_IN_RANGE
722 (addr, NETXEN_ADDR_QDR_NET, NETXEN_ADDR_QDR_NET_MAX)) {
723 /* QDR network side */
724 addr -= NETXEN_ADDR_QDR_NET;
725 window = (addr >> 22) & 0x3f;
726 if (qdr_sn_window != window) {
727 qdr_sn_window = window;
728 writel((window << 22),
729 PCI_OFFSET_SECOND_RANGE(adapter,
730 NETXEN_PCIX_PH_REG
731 (PCIX_SN_WINDOW)));
732 /* MUST make sure window is set before we forge on... */
733 readl(PCI_OFFSET_SECOND_RANGE(adapter,
734 NETXEN_PCIX_PH_REG
735 (PCIX_SN_WINDOW)));
736 }
737 addr -= (window * 0x400000);
738 addr += NETXEN_PCI_QDR_NET;
739 } else {
740 /*
741 * peg gdb frequently accesses memory that doesn't exist,
742 * this limits the chit chat so debugging isn't slowed down.
743 */
744 if ((netxen_pci_set_window_warning_count++ < 8)
745 || (netxen_pci_set_window_warning_count % 64 == 0))
746 printk("%s: Warning:netxen_nic_pci_set_window()"
747 " Unknown address range!\n",
748 netxen_nic_driver_name);
749
750 }
751 return addr;
752}
753
754int netxen_nic_get_board_info(struct netxen_adapter *adapter)
755{
756 int rv = 0;
757 int addr = BRDCFG_START;
758 struct netxen_board_info *boardinfo;
759 int index;
760 u32 *ptr32;
761
762 boardinfo = &adapter->ahw.boardcfg;
763 ptr32 = (u32 *) boardinfo;
764
765 for (index = 0; index < sizeof(struct netxen_board_info) / sizeof(u32);
766 index++) {
767 if (netxen_rom_fast_read(adapter, addr, ptr32) == -1) {
768 return -EIO;
769 }
770 ptr32++;
771 addr += sizeof(u32);
772 }
773 if (boardinfo->magic != NETXEN_BDINFO_MAGIC) {
774 printk("%s: ERROR reading %s board config."
775 " Read %x, expected %x\n", netxen_nic_driver_name,
776 netxen_nic_driver_name,
777 boardinfo->magic, NETXEN_BDINFO_MAGIC);
778 rv = -1;
779 }
780 if (boardinfo->header_version != NETXEN_BDINFO_VERSION) {
781 printk("%s: Unknown board config version."
782 " Read %x, expected %x\n", netxen_nic_driver_name,
783 boardinfo->header_version, NETXEN_BDINFO_VERSION);
784 rv = -1;
785 }
786
787 DPRINTK(INFO, "Discovered board type:0x%x ", boardinfo->board_type);
788 switch ((netxen_brdtype_t) boardinfo->board_type) {
789 case NETXEN_BRDTYPE_P2_SB35_4G:
790 adapter->ahw.board_type = NETXEN_NIC_GBE;
791 break;
792 case NETXEN_BRDTYPE_P2_SB31_10G:
793 case NETXEN_BRDTYPE_P2_SB31_10G_IMEZ:
794 case NETXEN_BRDTYPE_P2_SB31_10G_HMEZ:
795 case NETXEN_BRDTYPE_P2_SB31_10G_CX4:
796 adapter->ahw.board_type = NETXEN_NIC_XGBE;
797 break;
798 case NETXEN_BRDTYPE_P1_BD:
799 case NETXEN_BRDTYPE_P1_SB:
800 case NETXEN_BRDTYPE_P1_SMAX:
801 case NETXEN_BRDTYPE_P1_SOCK:
802 adapter->ahw.board_type = NETXEN_NIC_GBE;
803 break;
804 default:
805 printk("%s: Unknown(%x)\n", netxen_nic_driver_name,
806 boardinfo->board_type);
807 break;
808 }
809
810 return rv;
811}
812
813/* NIU access sections */
814
815int netxen_nic_set_mtu_gb(struct netxen_port *port, int new_mtu)
816{
817 struct netxen_adapter *adapter = port->adapter;
818 netxen_nic_write_w0(adapter,
819 NETXEN_NIU_GB_MAX_FRAME_SIZE(port->portnum),
820 new_mtu);
821 return 0;
822}
823
824int netxen_nic_set_mtu_xgb(struct netxen_port *port, int new_mtu)
825{
826 struct netxen_adapter *adapter = port->adapter;
827 new_mtu += NETXEN_NIU_HDRSIZE + NETXEN_NIU_TLRSIZE;
828 netxen_nic_write_w0(adapter, NETXEN_NIU_XGE_MAX_FRAME_SIZE, new_mtu);
829 return 0;
830}
831
832void netxen_nic_init_niu_gb(struct netxen_adapter *adapter)
833{
834 int portno;
835 for (portno = 0; portno < NETXEN_NIU_MAX_GBE_PORTS; portno++)
836 netxen_niu_gbe_init_port(adapter, portno);
837}
838
839void netxen_nic_stop_all_ports(struct netxen_adapter *adapter)
840{
841 int port_nr;
842 struct netxen_port *port;
843
844 for (port_nr = 0; port_nr < adapter->ahw.max_ports; port_nr++) {
845 port = adapter->port[port_nr];
846 if (adapter->stop_port)
847 adapter->stop_port(adapter, port->portnum);
848 }
849}
850
851void
852netxen_crb_writelit_adapter(struct netxen_adapter *adapter, unsigned long off,
853 int data)
854{
855 void __iomem *addr;
856
857 if (ADDR_IN_WINDOW1(off)) {
858 writel(data, NETXEN_CRB_NORMALIZE(adapter, off));
859 } else {
860 netxen_nic_pci_change_crbwindow(adapter, 0);
861 addr = pci_base_offset(adapter, off);
862 writel(data, addr);
863 netxen_nic_pci_change_crbwindow(adapter, 1);
864 }
865}
866
867void netxen_nic_set_link_parameters(struct netxen_port *port)
868{
869 struct netxen_adapter *adapter = port->adapter;
870 __le32 status;
871 __le32 autoneg;
872 __le32 mode;
873
874 netxen_nic_read_w0(adapter, NETXEN_NIU_MODE, &mode);
875 if (netxen_get_niu_enable_ge(mode)) { /* Gb 10/100/1000 Mbps mode */
876 if (adapter->phy_read
877 && adapter->
878 phy_read(adapter, port->portnum,
879 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
880 &status) == 0) {
881 if (netxen_get_phy_link(status)) {
882 switch (netxen_get_phy_speed(status)) {
883 case 0:
884 port->link_speed = SPEED_10;
885 break;
886 case 1:
887 port->link_speed = SPEED_100;
888 break;
889 case 2:
890 port->link_speed = SPEED_1000;
891 break;
892 default:
893 port->link_speed = -1;
894 break;
895 }
896 switch (netxen_get_phy_duplex(status)) {
897 case 0:
898 port->link_duplex = DUPLEX_HALF;
899 break;
900 case 1:
901 port->link_duplex = DUPLEX_FULL;
902 break;
903 default:
904 port->link_duplex = -1;
905 break;
906 }
907 if (adapter->phy_read
908 && adapter->
909 phy_read(adapter, port->portnum,
910 NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG,
911 &autoneg) != 0)
912 port->link_autoneg = autoneg;
913 } else
914 goto link_down;
915 } else {
916 link_down:
917 port->link_speed = -1;
918 port->link_duplex = -1;
919 }
920 }
921}
922
923void netxen_nic_flash_print(struct netxen_adapter *adapter)
924{
925 int valid = 1;
926 u32 fw_major = 0;
927 u32 fw_minor = 0;
928 u32 fw_build = 0;
929 char brd_name[NETXEN_MAX_SHORT_NAME];
930 struct netxen_new_user_info user_info;
931 int i, addr = USER_START;
932 u32 *ptr32;
933
934 struct netxen_board_info *board_info = &(adapter->ahw.boardcfg);
935 if (board_info->magic != NETXEN_BDINFO_MAGIC) {
936 printk
937 ("NetXen Unknown board config, Read 0x%x expected as 0x%x\n",
938 board_info->magic, NETXEN_BDINFO_MAGIC);
939 valid = 0;
940 }
941 if (board_info->header_version != NETXEN_BDINFO_VERSION) {
942 printk("NetXen Unknown board config version."
943 " Read %x, expected %x\n",
944 board_info->header_version, NETXEN_BDINFO_VERSION);
945 valid = 0;
946 }
947 if (valid) {
948 ptr32 = (u32 *) & user_info;
949 for (i = 0;
950 i < sizeof(struct netxen_new_user_info) / sizeof(u32);
951 i++) {
952 if (netxen_rom_fast_read(adapter, addr, ptr32) == -1) {
953 printk("%s: ERROR reading %s board userarea.\n",
954 netxen_nic_driver_name,
955 netxen_nic_driver_name);
956 return;
957 }
958 ptr32++;
959 addr += sizeof(u32);
960 }
961 get_brd_name_by_type(board_info->board_type, brd_name);
962
963 printk("NetXen %s Board S/N %s Chip id 0x%x\n",
964 brd_name, user_info.serial_num, board_info->chip_id);
965
966 printk("NetXen %s Board #%d, Chip id 0x%x\n",
967 board_info->board_type == 0x0b ? "XGB" : "GBE",
968 board_info->board_num, board_info->chip_id);
969 fw_major = readl(NETXEN_CRB_NORMALIZE(adapter,
970 NETXEN_FW_VERSION_MAJOR));
971 fw_minor = readl(NETXEN_CRB_NORMALIZE(adapter,
972 NETXEN_FW_VERSION_MINOR));
973 fw_build =
974 readl(NETXEN_CRB_NORMALIZE(adapter, NETXEN_FW_VERSION_SUB));
975
976 printk("NetXen Firmware version %d.%d.%d\n", fw_major, fw_minor,
977 fw_build);
978 }
979 if (fw_major != _NETXEN_NIC_LINUX_MAJOR) {
980 printk(KERN_ERR "The mismatch in driver version and firmware "
981 "version major number\n"
982 "Driver version major number = %d \t"
983 "Firmware version major number = %d \n",
984 _NETXEN_NIC_LINUX_MAJOR, fw_major);
985 adapter->driver_mismatch = 1;
986 }
987 if (fw_minor != _NETXEN_NIC_LINUX_MINOR) {
988 printk(KERN_ERR "The mismatch in driver version and firmware "
989 "version minor number\n"
990 "Driver version minor number = %d \t"
991 "Firmware version minor number = %d \n",
992 _NETXEN_NIC_LINUX_MINOR, fw_minor);
993 adapter->driver_mismatch = 1;
994 }
995 if (adapter->driver_mismatch)
996 printk(KERN_INFO "Use the driver with version no %d.%d.xxx\n",
997 fw_major, fw_minor);
998}
999
1000int netxen_crb_read_val(struct netxen_adapter *adapter, unsigned long off)
1001{
1002 int data;
1003 netxen_nic_hw_read_wx(adapter, off, &data, 4);
1004 return data;
1005}
1006
1007int netxen_nic_hw_write_ioctl(struct netxen_adapter *adapter, u64 off,
1008 void *data, int len)
1009{
1010 void *addr;
1011 u64 offset = off;
1012 u8 *mem_ptr = NULL;
1013 unsigned long mem_base;
1014 unsigned long mem_page;
1015
1016 if (ADDR_IN_WINDOW1(off)) {
1017 addr = NETXEN_CRB_NORMALIZE(adapter, off);
1018 if (!addr) {
1019 mem_base = pci_resource_start(adapter->ahw.pdev, 0);
1020 offset = NETXEN_CRB_NORMAL(off);
1021 mem_page = offset & PAGE_MASK;
1022 if (mem_page != ((offset + len - 1) & PAGE_MASK))
1023 mem_ptr =
1024 ioremap(mem_base + mem_page, PAGE_SIZE * 2);
1025 else
1026 mem_ptr =
1027 ioremap(mem_base + mem_page, PAGE_SIZE);
1028 if (mem_ptr == 0UL) {
1029 return 1;
1030 }
1031 addr = mem_ptr;
1032 addr += offset & (PAGE_SIZE - 1);
1033 }
1034 } else {
1035 addr = pci_base_offset(adapter, off);
1036 if (!addr) {
1037 mem_base = pci_resource_start(adapter->ahw.pdev, 0);
1038 mem_page = off & PAGE_MASK;
1039 if (mem_page != ((off + len - 1) & PAGE_MASK))
1040 mem_ptr =
1041 ioremap(mem_base + mem_page, PAGE_SIZE * 2);
1042 else
1043 mem_ptr =
1044 ioremap(mem_base + mem_page, PAGE_SIZE);
1045 if (mem_ptr == 0UL) {
1046 return 1;
1047 }
1048 addr = mem_ptr;
1049 addr += off & (PAGE_SIZE - 1);
1050 }
1051 netxen_nic_pci_change_crbwindow(adapter, 0);
1052 }
1053 switch (len) {
1054 case 1:
1055 writeb(*(u8 *) data, addr);
1056 break;
1057 case 2:
1058 writew(*(u16 *) data, addr);
1059 break;
1060 case 4:
1061 writel(*(u32 *) data, addr);
1062 break;
1063 case 8:
1064 writeq(*(u64 *) data, addr);
1065 break;
1066 default:
1067 DPRINTK(INFO,
1068 "writing data %lx to offset %llx, num words=%d\n",
1069 *(unsigned long *)data, off, (len >> 3));
1070
1071 netxen_nic_hw_block_write64((u64 __iomem *) data, addr,
1072 (len >> 3));
1073 break;
1074 }
1075
1076 if (!ADDR_IN_WINDOW1(off))
1077 netxen_nic_pci_change_crbwindow(adapter, 1);
1078 if (mem_ptr)
1079 iounmap(mem_ptr);
1080 return 0;
1081}
1082
1083int netxen_nic_hw_read_ioctl(struct netxen_adapter *adapter, u64 off,
1084 void *data, int len)
1085{
1086 void *addr;
1087 u64 offset;
1088 u8 *mem_ptr = NULL;
1089 unsigned long mem_base;
1090 unsigned long mem_page;
1091
1092 if (ADDR_IN_WINDOW1(off)) {
1093 addr = NETXEN_CRB_NORMALIZE(adapter, off);
1094 if (!addr) {
1095 mem_base = pci_resource_start(adapter->ahw.pdev, 0);
1096 offset = NETXEN_CRB_NORMAL(off);
1097 mem_page = offset & PAGE_MASK;
1098 if (mem_page != ((offset + len - 1) & PAGE_MASK))
1099 mem_ptr =
1100 ioremap(mem_base + mem_page, PAGE_SIZE * 2);
1101 else
1102 mem_ptr =
1103 ioremap(mem_base + mem_page, PAGE_SIZE);
1104 if (mem_ptr == 0UL) {
1105 *(u8 *) data = 0;
1106 return 1;
1107 }
1108 addr = mem_ptr;
1109 addr += offset & (PAGE_SIZE - 1);
1110 }
1111 } else {
1112 addr = pci_base_offset(adapter, off);
1113 if (!addr) {
1114 mem_base = pci_resource_start(adapter->ahw.pdev, 0);
1115 mem_page = off & PAGE_MASK;
1116 if (mem_page != ((off + len - 1) & PAGE_MASK))
1117 mem_ptr =
1118 ioremap(mem_base + mem_page, PAGE_SIZE * 2);
1119 else
1120 mem_ptr =
1121 ioremap(mem_base + mem_page, PAGE_SIZE);
1122 if (mem_ptr == 0UL)
1123 return 1;
1124 addr = mem_ptr;
1125 addr += off & (PAGE_SIZE - 1);
1126 }
1127 netxen_nic_pci_change_crbwindow(adapter, 0);
1128 }
1129 switch (len) {
1130 case 1:
1131 *(u8 *) data = readb(addr);
1132 break;
1133 case 2:
1134 *(u16 *) data = readw(addr);
1135 break;
1136 case 4:
1137 *(u32 *) data = readl(addr);
1138 break;
1139 case 8:
1140 *(u64 *) data = readq(addr);
1141 break;
1142 default:
1143 netxen_nic_hw_block_read64((u64 __iomem *) data, addr,
1144 (len >> 3));
1145 break;
1146 }
1147 if (!ADDR_IN_WINDOW1(off))
1148 netxen_nic_pci_change_crbwindow(adapter, 1);
1149 if (mem_ptr)
1150 iounmap(mem_ptr);
1151 return 0;
1152}
1153
1154int netxen_nic_pci_mem_write_ioctl(struct netxen_adapter *adapter, u64 off,
1155 void *data, int size)
1156{
1157 void *addr;
1158 int ret = 0;
1159 u8 *mem_ptr = NULL;
1160 unsigned long mem_base;
1161 unsigned long mem_page;
1162
1163 if (data == NULL || off > (128 * 1024 * 1024)) {
1164 printk(KERN_ERR "%s: data: %p off:%llx\n",
1165 netxen_nic_driver_name, data, off);
1166 return 1;
1167 }
1168 off = netxen_nic_pci_set_window(adapter, off);
1169 /* Corner case : Malicious user tried to break the driver by reading
1170 last few bytes in ranges and tries to read further addresses.
1171 */
1172 if (!pci_base(adapter, off + size - 1) && pci_base(adapter, off)) {
1173 printk(KERN_ERR "%s: Invalid access to memory address range"
1174 " 0x%llx - 0x%llx\n", netxen_nic_driver_name, off,
1175 off + size);
1176 return 1;
1177 }
1178 addr = pci_base_offset(adapter, off);
1179 DPRINTK(INFO, "writing data %llx to offset %llx\n",
1180 *(unsigned long long *)data, off);
1181 if (!addr) {
1182 mem_base = pci_resource_start(adapter->ahw.pdev, 0);
1183 mem_page = off & PAGE_MASK;
1184 /* Map two pages whenever user tries to access addresses in two
1185 consecutive pages.
1186 */
1187 if (mem_page != ((off + size - 1) & PAGE_MASK))
1188 mem_ptr = ioremap(mem_base + mem_page, PAGE_SIZE * 2);
1189 else
1190 mem_ptr = ioremap(mem_base + mem_page, PAGE_SIZE);
1191 if (mem_ptr == 0UL) {
1192 return 1;
1193 }
1194 addr = mem_ptr;
1195 addr += off & (PAGE_SIZE - 1);
1196 }
1197 switch (size) {
1198 case 1:
1199 writeb(*(u8 *) data, addr);
1200 break;
1201 case 2:
1202 writew(*(u16 *) data, addr);
1203 break;
1204 case 4:
1205 writel(*(u32 *) data, addr);
1206 break;
1207 case 8:
1208 writeq(*(u64 *) data, addr);
1209 break;
1210 default:
1211 DPRINTK(INFO,
1212 "writing data %lx to offset %llx, num words=%d\n",
1213 *(unsigned long *)data, off, (size >> 3));
1214
1215 netxen_nic_hw_block_write64((u64 __iomem *) data, addr,
1216 (size >> 3));
1217 break;
1218 }
1219
1220 if (mem_ptr)
1221 iounmap(mem_ptr);
1222 DPRINTK(INFO, "wrote %llx\n", *(unsigned long long *)data);
1223
1224 return ret;
1225}
1226
1227int netxen_nic_pci_mem_read_ioctl(struct netxen_adapter *adapter,
1228 u64 off, void *data, int size)
1229{
1230 void *addr;
1231 int ret = 0;
1232 u8 *mem_ptr = NULL;
1233 unsigned long mem_base;
1234 unsigned long mem_page;
1235
1236 if (data == NULL || off > (128 * 1024 * 1024)) {
1237 printk(KERN_ERR "%s: data: %p off:%llx\n",
1238 netxen_nic_driver_name, data, off);
1239 return 1;
1240 }
1241 off = netxen_nic_pci_set_window(adapter, off);
1242 /* Corner case : Malicious user tried to break the driver by reading
1243 last few bytes in ranges and tries to read further addresses.
1244 */
1245 if (!pci_base(adapter, off + size - 1) && pci_base(adapter, off)) {
1246 printk(KERN_ERR "%s: Invalid access to memory address range"
1247 " 0x%llx - 0x%llx\n", netxen_nic_driver_name, off,
1248 off + size);
1249 return 1;
1250 }
1251 addr = pci_base_offset(adapter, off);
1252 if (!addr) {
1253 mem_base = pci_resource_start(adapter->ahw.pdev, 0);
1254 mem_page = off & PAGE_MASK;
1255 /* Map two pages whenever user tries to access addresses in two
1256 consecutive pages.
1257 */
1258 if (mem_page != ((off + size - 1) & PAGE_MASK))
1259 mem_ptr = ioremap(mem_base + mem_page, PAGE_SIZE * 2);
1260 else
1261 mem_ptr = ioremap(mem_base + mem_page, PAGE_SIZE);
1262 if (mem_ptr == 0UL) {
1263 *(u8 *) data = 0;
1264 return 1;
1265 }
1266 addr = mem_ptr;
1267 addr += off & (PAGE_SIZE - 1);
1268 }
1269 switch (size) {
1270 case 1:
1271 *(u8 *) data = readb(addr);
1272 break;
1273 case 2:
1274 *(u16 *) data = readw(addr);
1275 break;
1276 case 4:
1277 *(u32 *) data = readl(addr);
1278 break;
1279 case 8:
1280 *(u64 *) data = readq(addr);
1281 break;
1282 default:
1283 netxen_nic_hw_block_read64((u64 __iomem *) data, addr,
1284 (size >> 3));
1285 break;
1286 }
1287
1288 if (mem_ptr)
1289 iounmap(mem_ptr);
1290 DPRINTK(INFO, "read %llx\n", *(unsigned long long *)data);
1291
1292 return ret;
1293}
diff --git a/drivers/net/netxen/netxen_nic_hw.h b/drivers/net/netxen/netxen_nic_hw.h
new file mode 100644
index 000000000000..0685633a9c1e
--- /dev/null
+++ b/drivers/net/netxen/netxen_nic_hw.h
@@ -0,0 +1,482 @@
1/*
2 * Copyright (C) 2003 - 2006 NetXen, Inc.
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 * MA 02111-1307, USA.
19 *
20 * The full GNU General Public License is included in this distribution
21 * in the file called LICENSE.
22 *
23 * Contact Information:
24 * info@netxen.com
25 * NetXen,
26 * 3965 Freedom Circle, Fourth floor,
27 * Santa Clara, CA 95054
28 *
29 *
30 * Structures, enums, and macros for the MAC
31 *
32 */
33
34#ifndef __NETXEN_NIC_HW_H_
35#define __NETXEN_NIC_HW_H_
36
37#include "netxen_nic_hdr.h"
38
39/* Hardware memory size of 128 meg */
40#define NETXEN_MEMADDR_MAX (128 * 1024 * 1024)
41
42#ifndef readq
43static inline u64 readq(void __iomem * addr)
44{
45 return readl(addr) | (((u64) readl(addr + 4)) << 32LL);
46}
47#endif
48
49#ifndef writeq
50static inline void writeq(u64 val, void __iomem * addr)
51{
52 writel(((u32) (val)), (addr));
53 writel(((u32) (val >> 32)), (addr + 4));
54}
55#endif
56
57static inline void netxen_nic_hw_block_write64(u64 __iomem * data_ptr,
58 u64 __iomem * addr,
59 int num_words)
60{
61 int num;
62 for (num = 0; num < num_words; num++) {
63 writeq(readq((void __iomem *)data_ptr), addr);
64 addr++;
65 data_ptr++;
66 }
67}
68
69static inline void netxen_nic_hw_block_read64(u64 __iomem * data_ptr,
70 u64 __iomem * addr, int num_words)
71{
72 int num;
73 for (num = 0; num < num_words; num++) {
74 writeq(readq((void __iomem *)addr), data_ptr);
75 addr++;
76 data_ptr++;
77 }
78
79}
80
81struct netxen_adapter;
82
83#define NETXEN_PCI_MAPSIZE_BYTES (NETXEN_PCI_MAPSIZE << 20)
84
85#define NETXEN_NIC_LOCKED_READ_REG(X, Y) \
86 addr = pci_base_offset(adapter, X); \
87 *(u32 *)Y = readl((void __iomem*) addr);
88
89struct netxen_port;
90void netxen_nic_set_link_parameters(struct netxen_port *port);
91void netxen_nic_flash_print(struct netxen_adapter *adapter);
92int netxen_nic_hw_write_wx(struct netxen_adapter *adapter, u64 off,
93 void *data, int len);
94void netxen_crb_writelit_adapter(struct netxen_adapter *adapter,
95 unsigned long off, int data);
96int netxen_nic_hw_read_wx(struct netxen_adapter *adapter, u64 off,
97 void *data, int len);
98
99typedef u8 netxen_ethernet_macaddr_t[6];
100
101/* Nibble or Byte mode for phy interface (GbE mode only) */
102typedef enum {
103 NETXEN_NIU_10_100_MB = 0,
104 NETXEN_NIU_1000_MB
105} netxen_niu_gbe_ifmode_t;
106
107#define _netxen_crb_get_bit(var, bit) ((var >> bit) & 0x1)
108
109/*
110 * NIU GB MAC Config Register 0 (applies to GB0, GB1, GB2, GB3)
111 *
112 * Bit 0 : enable_tx => 1:enable frame xmit, 0:disable
113 * Bit 1 : tx_synced => R/O: xmit enable synched to xmit stream
114 * Bit 2 : enable_rx => 1:enable frame recv, 0:disable
115 * Bit 3 : rx_synced => R/O: recv enable synched to recv stream
116 * Bit 4 : tx_flowctl => 1:enable pause frame generation, 0:disable
117 * Bit 5 : rx_flowctl => 1:act on recv'd pause frames, 0:ignore
118 * Bit 8 : loopback => 1:loop MAC xmits to MAC recvs, 0:normal
119 * Bit 16: tx_reset_pb => 1:reset frame xmit protocol blk, 0:no-op
120 * Bit 17: rx_reset_pb => 1:reset frame recv protocol blk, 0:no-op
121 * Bit 18: tx_reset_mac => 1:reset data/ctl multiplexer blk, 0:no-op
122 * Bit 19: rx_reset_mac => 1:reset ctl frames & timers blk, 0:no-op
123 * Bit 31: soft_reset => 1:reset the MAC and the SERDES, 0:no-op
124 */
125
126#define netxen_gb_enable_tx(config_word) \
127 set_bit(0, (unsigned long*)(&config_word))
128#define netxen_gb_enable_rx(config_word) \
129 set_bit(2, (unsigned long*)(&config_word))
130#define netxen_gb_tx_flowctl(config_word) \
131 set_bit(4, (unsigned long*)(&config_word))
132#define netxen_gb_rx_flowctl(config_word) \
133 set_bit(5, (unsigned long*)(&config_word))
134#define netxen_gb_tx_reset_pb(config_word) \
135 set_bit(16, (unsigned long*)(&config_word))
136#define netxen_gb_rx_reset_pb(config_word) \
137 set_bit(17, (unsigned long*)(&config_word))
138#define netxen_gb_tx_reset_mac(config_word) \
139 set_bit(18, (unsigned long*)(&config_word))
140#define netxen_gb_rx_reset_mac(config_word) \
141 set_bit(19, (unsigned long*)(&config_word))
142#define netxen_gb_soft_reset(config_word) \
143 set_bit(31, (unsigned long*)(&config_word))
144
145#define netxen_gb_unset_tx_flowctl(config_word) \
146 clear_bit(4, (unsigned long *)(&config_word))
147#define netxen_gb_unset_rx_flowctl(config_word) \
148 clear_bit(5, (unsigned long*)(&config_word))
149
150#define netxen_gb_get_tx_synced(config_word) \
151 _netxen_crb_get_bit((config_word), 1)
152#define netxen_gb_get_rx_synced(config_word) \
153 _netxen_crb_get_bit((config_word), 3)
154#define netxen_gb_get_tx_flowctl(config_word) \
155 _netxen_crb_get_bit((config_word), 4)
156#define netxen_gb_get_rx_flowctl(config_word) \
157 _netxen_crb_get_bit((config_word), 5)
158#define netxen_gb_get_soft_reset(config_word) \
159 _netxen_crb_get_bit((config_word), 31)
160
161/*
162 * NIU GB MAC Config Register 1 (applies to GB0, GB1, GB2, GB3)
163 *
164 * Bit 0 : duplex => 1:full duplex mode, 0:half duplex
165 * Bit 1 : crc_enable => 1:append CRC to xmit frames, 0:dont append
166 * Bit 2 : padshort => 1:pad short frames and add CRC, 0:dont pad
167 * Bit 4 : checklength => 1:check framelen with actual,0:dont check
168 * Bit 5 : hugeframes => 1:allow oversize xmit frames, 0:dont allow
169 * Bits 8-9 : intfmode => 01:nibble (10/100), 10:byte (1000)
170 * Bits 12-15 : preamblelen => preamble field length in bytes, default 7
171 */
172
173#define netxen_gb_set_duplex(config_word) \
174 set_bit(0, (unsigned long*)&config_word)
175#define netxen_gb_set_crc_enable(config_word) \
176 set_bit(1, (unsigned long*)&config_word)
177#define netxen_gb_set_padshort(config_word) \
178 set_bit(2, (unsigned long*)&config_word)
179#define netxen_gb_set_checklength(config_word) \
180 set_bit(4, (unsigned long*)&config_word)
181#define netxen_gb_set_hugeframes(config_word) \
182 set_bit(5, (unsigned long*)&config_word)
183#define netxen_gb_set_preamblelen(config_word, val) \
184 ((config_word) |= ((val) << 12) & 0xF000)
185#define netxen_gb_set_intfmode(config_word, val) \
186 ((config_word) |= ((val) << 8) & 0x300)
187
188#define netxen_gb_get_stationaddress_low(config_word) ((config_word) >> 16)
189
190#define netxen_gb_set_mii_mgmt_clockselect(config_word, val) \
191 ((config_word) |= ((val) & 0x07))
192#define netxen_gb_mii_mgmt_reset(config_word) \
193 set_bit(31, (unsigned long*)&config_word)
194#define netxen_gb_mii_mgmt_unset(config_word) \
195 clear_bit(31, (unsigned long*)&config_word)
196
197/*
198 * NIU GB MII Mgmt Command Register (applies to GB0, GB1, GB2, GB3)
199 * Bit 0 : read_cycle => 1:perform single read cycle, 0:no-op
200 * Bit 1 : scan_cycle => 1:perform continuous read cycles, 0:no-op
201 */
202
203#define netxen_gb_mii_mgmt_set_read_cycle(config_word) \
204 set_bit(0, (unsigned long*)&config_word)
205#define netxen_gb_mii_mgmt_reg_addr(config_word, val) \
206 ((config_word) |= ((val) & 0x1F))
207#define netxen_gb_mii_mgmt_phy_addr(config_word, val) \
208 ((config_word) |= (((val) & 0x1F) << 8))
209
210/*
211 * NIU GB MII Mgmt Indicators Register (applies to GB0, GB1, GB2, GB3)
212 * Read-only register.
213 * Bit 0 : busy => 1:performing an MII mgmt cycle, 0:idle
214 * Bit 1 : scanning => 1:scan operation in progress, 0:idle
215 * Bit 2 : notvalid => :mgmt result data not yet valid, 0:idle
216 */
217#define netxen_get_gb_mii_mgmt_busy(config_word) \
218 _netxen_crb_get_bit(config_word, 0)
219#define netxen_get_gb_mii_mgmt_scanning(config_word) \
220 _netxen_crb_get_bit(config_word, 1)
221#define netxen_get_gb_mii_mgmt_notvalid(config_word) \
222 _netxen_crb_get_bit(config_word, 2)
223
224/*
225 * PHY-Specific MII control/status registers.
226 */
227typedef enum {
228 NETXEN_NIU_GB_MII_MGMT_ADDR_CONTROL = 0,
229 NETXEN_NIU_GB_MII_MGMT_ADDR_STATUS = 1,
230 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_ID_0 = 2,
231 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_ID_1 = 3,
232 NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG = 4,
233 NETXEN_NIU_GB_MII_MGMT_ADDR_LNKPART = 5,
234 NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG_MORE = 6,
235 NETXEN_NIU_GB_MII_MGMT_ADDR_NEXTPAGE_XMIT = 7,
236 NETXEN_NIU_GB_MII_MGMT_ADDR_LNKPART_NEXTPAGE = 8,
237 NETXEN_NIU_GB_MII_MGMT_ADDR_1000BT_CONTROL = 9,
238 NETXEN_NIU_GB_MII_MGMT_ADDR_1000BT_STATUS = 10,
239 NETXEN_NIU_GB_MII_MGMT_ADDR_EXTENDED_STATUS = 15,
240 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_CONTROL = 16,
241 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS = 17,
242 NETXEN_NIU_GB_MII_MGMT_ADDR_INT_ENABLE = 18,
243 NETXEN_NIU_GB_MII_MGMT_ADDR_INT_STATUS = 19,
244 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_CONTROL_MORE = 20,
245 NETXEN_NIU_GB_MII_MGMT_ADDR_RECV_ERROR_COUNT = 21,
246 NETXEN_NIU_GB_MII_MGMT_ADDR_LED_CONTROL = 24,
247 NETXEN_NIU_GB_MII_MGMT_ADDR_LED_OVERRIDE = 25,
248 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_CONTROL_MORE_YET = 26,
249 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS_MORE = 27
250} netxen_niu_phy_register_t;
251
252/*
253 * PHY-Specific Status Register (reg 17).
254 *
255 * Bit 0 : jabber => 1:jabber detected, 0:not
256 * Bit 1 : polarity => 1:polarity reversed, 0:normal
257 * Bit 2 : recvpause => 1:receive pause enabled, 0:disabled
258 * Bit 3 : xmitpause => 1:transmit pause enabled, 0:disabled
259 * Bit 4 : energydetect => 1:sleep, 0:active
260 * Bit 5 : downshift => 1:downshift, 0:no downshift
261 * Bit 6 : crossover => 1:MDIX (crossover), 0:MDI (no crossover)
262 * Bits 7-9 : cablelen => not valid in 10Mb/s mode
263 * 0:<50m, 1:50-80m, 2:80-110m, 3:110-140m, 4:>140m
264 * Bit 10 : link => 1:link up, 0:link down
265 * Bit 11 : resolved => 1:speed and duplex resolved, 0:not yet
266 * Bit 12 : pagercvd => 1:page received, 0:page not received
267 * Bit 13 : duplex => 1:full duplex, 0:half duplex
268 * Bits 14-15 : speed => 0:10Mb/s, 1:100Mb/s, 2:1000Mb/s, 3:rsvd
269 */
270
271#define netxen_get_phy_cablelen(config_word) (((config_word) >> 7) & 0x07)
272#define netxen_get_phy_speed(config_word) (((config_word) >> 14) & 0x03)
273
274#define netxen_set_phy_speed(config_word, val) \
275 ((config_word) |= ((val & 0x03) << 14))
276#define netxen_set_phy_duplex(config_word) \
277 set_bit(13, (unsigned long*)&config_word)
278#define netxen_clear_phy_duplex(config_word) \
279 clear_bit(13, (unsigned long*)&config_word)
280
281#define netxen_get_phy_jabber(config_word) \
282 _netxen_crb_get_bit(config_word, 0)
283#define netxen_get_phy_polarity(config_word) \
284 _netxen_crb_get_bit(config_word, 1)
285#define netxen_get_phy_recvpause(config_word) \
286 _netxen_crb_get_bit(config_word, 2)
287#define netxen_get_phy_xmitpause(config_word) \
288 _netxen_crb_get_bit(config_word, 3)
289#define netxen_get_phy_energydetect(config_word) \
290 _netxen_crb_get_bit(config_word, 4)
291#define netxen_get_phy_downshift(config_word) \
292 _netxen_crb_get_bit(config_word, 5)
293#define netxen_get_phy_crossover(config_word) \
294 _netxen_crb_get_bit(config_word, 6)
295#define netxen_get_phy_link(config_word) \
296 _netxen_crb_get_bit(config_word, 10)
297#define netxen_get_phy_resolved(config_word) \
298 _netxen_crb_get_bit(config_word, 11)
299#define netxen_get_phy_pagercvd(config_word) \
300 _netxen_crb_get_bit(config_word, 12)
301#define netxen_get_phy_duplex(config_word) \
302 _netxen_crb_get_bit(config_word, 13)
303
304/*
305 * Interrupt Register definition
306 * This definition applies to registers 18 and 19 (int enable and int status).
307 * Bit 0 : jabber
308 * Bit 1 : polarity_changed
309 * Bit 4 : energy_detect
310 * Bit 5 : downshift
311 * Bit 6 : mdi_xover_changed
312 * Bit 7 : fifo_over_underflow
313 * Bit 8 : false_carrier
314 * Bit 9 : symbol_error
315 * Bit 10: link_status_changed
316 * Bit 11: autoneg_completed
317 * Bit 12: page_received
318 * Bit 13: duplex_changed
319 * Bit 14: speed_changed
320 * Bit 15: autoneg_error
321 */
322
323#define netxen_get_phy_int_jabber(config_word) \
324 _netxen_crb_get_bit(config_word, 0)
325#define netxen_get_phy_int_polarity_changed(config_word) \
326 _netxen_crb_get_bit(config_word, 1)
327#define netxen_get_phy_int_energy_detect(config_word) \
328 _netxen_crb_get_bit(config_word, 4)
329#define netxen_get_phy_int_downshift(config_word) \
330 _netxen_crb_get_bit(config_word, 5)
331#define netxen_get_phy_int_mdi_xover_changed(config_word) \
332 _netxen_crb_get_bit(config_word, 6)
333#define netxen_get_phy_int_fifo_over_underflow(config_word) \
334 _netxen_crb_get_bit(config_word, 7)
335#define netxen_get_phy_int_false_carrier(config_word) \
336 _netxen_crb_get_bit(config_word, 8)
337#define netxen_get_phy_int_symbol_error(config_word) \
338 _netxen_crb_get_bit(config_word, 9)
339#define netxen_get_phy_int_link_status_changed(config_word) \
340 _netxen_crb_get_bit(config_word, 10)
341#define netxen_get_phy_int_autoneg_completed(config_word) \
342 _netxen_crb_get_bit(config_word, 11)
343#define netxen_get_phy_int_page_received(config_word) \
344 _netxen_crb_get_bit(config_word, 12)
345#define netxen_get_phy_int_duplex_changed(config_word) \
346 _netxen_crb_get_bit(config_word, 13)
347#define netxen_get_phy_int_speed_changed(config_word) \
348 _netxen_crb_get_bit(config_word, 14)
349#define netxen_get_phy_int_autoneg_error(config_word) \
350 _netxen_crb_get_bit(config_word, 15)
351
352#define netxen_set_phy_int_link_status_changed(config_word) \
353 set_bit(10, (unsigned long*)&config_word)
354#define netxen_set_phy_int_autoneg_completed(config_word) \
355 set_bit(11, (unsigned long*)&config_word)
356#define netxen_set_phy_int_speed_changed(config_word) \
357 set_bit(14, (unsigned long*)&config_word)
358
359/*
360 * NIU Mode Register.
361 * Bit 0 : enable FibreChannel
362 * Bit 1 : enable 10/100/1000 Ethernet
363 * Bit 2 : enable 10Gb Ethernet
364 */
365
366#define netxen_get_niu_enable_ge(config_word) \
367 _netxen_crb_get_bit(config_word, 1)
368
369/* Promiscous mode options (GbE mode only) */
370typedef enum {
371 NETXEN_NIU_PROMISC_MODE = 0,
372 NETXEN_NIU_NON_PROMISC_MODE
373} netxen_niu_prom_mode_t;
374
375/*
376 * NIU GB Drop CRC Register
377 *
378 * Bit 0 : drop_gb0 => 1:drop pkts with bad CRCs, 0:pass them on
379 * Bit 1 : drop_gb1 => 1:drop pkts with bad CRCs, 0:pass them on
380 * Bit 2 : drop_gb2 => 1:drop pkts with bad CRCs, 0:pass them on
381 * Bit 3 : drop_gb3 => 1:drop pkts with bad CRCs, 0:pass them on
382 */
383
384#define netxen_set_gb_drop_gb0(config_word) \
385 set_bit(0, (unsigned long*)&config_word)
386#define netxen_set_gb_drop_gb1(config_word) \
387 set_bit(1, (unsigned long*)&config_word)
388#define netxen_set_gb_drop_gb2(config_word) \
389 set_bit(2, (unsigned long*)&config_word)
390#define netxen_set_gb_drop_gb3(config_word) \
391 set_bit(3, (unsigned long*)&config_word)
392
393#define netxen_clear_gb_drop_gb0(config_word) \
394 clear_bit(0, (unsigned long*)&config_word)
395#define netxen_clear_gb_drop_gb1(config_word) \
396 clear_bit(1, (unsigned long*)&config_word)
397#define netxen_clear_gb_drop_gb2(config_word) \
398 clear_bit(2, (unsigned long*)&config_word)
399#define netxen_clear_gb_drop_gb3(config_word) \
400 clear_bit(3, (unsigned long*)&config_word)
401
402/*
403 * NIU XG MAC Config Register
404 *
405 * Bit 0 : tx_enable => 1:enable frame xmit, 0:disable
406 * Bit 2 : rx_enable => 1:enable frame recv, 0:disable
407 * Bit 4 : soft_reset => 1:reset the MAC , 0:no-op
408 * Bit 27: xaui_framer_reset
409 * Bit 28: xaui_rx_reset
410 * Bit 29: xaui_tx_reset
411 * Bit 30: xg_ingress_afifo_reset
412 * Bit 31: xg_egress_afifo_reset
413 */
414
415#define netxen_xg_soft_reset(config_word) \
416 set_bit(4, (unsigned long*)&config_word)
417
418/*
419 * MAC Control Register
420 *
421 * Bit 0-1 : id_pool0
422 * Bit 2 : enable_xtnd0
423 * Bit 4-5 : id_pool1
424 * Bit 6 : enable_xtnd1
425 * Bit 8-9 : id_pool2
426 * Bit 10 : enable_xtnd2
427 * Bit 12-13 : id_pool3
428 * Bit 14 : enable_xtnd3
429 * Bit 24-25 : mode_select
430 * Bit 28-31 : enable_pool
431 */
432
433#define netxen_nic_mcr_set_id_pool0(config, val) \
434 ((config) |= ((val) &0x03))
435#define netxen_nic_mcr_set_enable_xtnd0(config) \
436 (set_bit(3, (unsigned long *)&(config)))
437#define netxen_nic_mcr_set_id_pool1(config, val) \
438 ((config) |= (((val) & 0x03) << 4))
439#define netxen_nic_mcr_set_enable_xtnd1(config) \
440 (set_bit(6, (unsigned long *)&(config)))
441#define netxen_nic_mcr_set_id_pool2(config, val) \
442 ((config) |= (((val) & 0x03) << 8))
443#define netxen_nic_mcr_set_enable_xtnd2(config) \
444 (set_bit(10, (unsigned long *)&(config)))
445#define netxen_nic_mcr_set_id_pool3(config, val) \
446 ((config) |= (((val) & 0x03) << 12))
447#define netxen_nic_mcr_set_enable_xtnd3(config) \
448 (set_bit(14, (unsigned long *)&(config)))
449#define netxen_nic_mcr_set_mode_select(config, val) \
450 ((config) |= (((val) & 0x03) << 24))
451#define netxen_nic_mcr_set_enable_pool(config, val) \
452 ((config) |= (((val) & 0x0f) << 28))
453
454/* Set promiscuous mode for a GbE interface */
455int netxen_niu_set_promiscuous_mode(struct netxen_adapter *adapter, int port,
456 netxen_niu_prom_mode_t mode);
457int netxen_niu_xg_set_promiscuous_mode(struct netxen_adapter *adapter,
458 int port, netxen_niu_prom_mode_t mode);
459
460/* get/set the MAC address for a given MAC */
461int netxen_niu_macaddr_get(struct netxen_adapter *adapter, int port,
462 netxen_ethernet_macaddr_t * addr);
463int netxen_niu_macaddr_set(struct netxen_port *port,
464 netxen_ethernet_macaddr_t addr);
465
466/* XG versons */
467int netxen_niu_xg_macaddr_get(struct netxen_adapter *adapter, int port,
468 netxen_ethernet_macaddr_t * addr);
469int netxen_niu_xg_macaddr_set(struct netxen_port *port,
470 netxen_ethernet_macaddr_t addr);
471
472/* Generic enable for GbE ports. Will detect the speed of the link. */
473int netxen_niu_gbe_init_port(struct netxen_adapter *adapter, int port);
474
475int netxen_niu_xg_init_port(struct netxen_adapter *adapter, int port);
476
477/* Disable a GbE interface */
478int netxen_niu_disable_gbe_port(struct netxen_adapter *adapter, int port);
479
480int netxen_niu_disable_xg_port(struct netxen_adapter *adapter, int port);
481
482#endif /* __NETXEN_NIC_HW_H_ */
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c
new file mode 100644
index 000000000000..869725f0bb18
--- /dev/null
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -0,0 +1,1524 @@
1/*
2 * Copyright (C) 2003 - 2006 NetXen, Inc.
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 * MA 02111-1307, USA.
19 *
20 * The full GNU General Public License is included in this distribution
21 * in the file called LICENSE.
22 *
23 * Contact Information:
24 * info@netxen.com
25 * NetXen,
26 * 3965 Freedom Circle, Fourth floor,
27 * Santa Clara, CA 95054
28 *
29 *
30 * Source file for NIC routines to initialize the Phantom Hardware
31 *
32 */
33
34#include <linux/netdevice.h>
35#include <linux/delay.h>
36#include "netxen_nic.h"
37#include "netxen_nic_hw.h"
38#include "netxen_nic_ioctl.h"
39#include "netxen_nic_phan_reg.h"
40
41struct crb_addr_pair {
42 long addr;
43 long data;
44};
45
46#define NETXEN_MAX_CRB_XFORM 60
47static unsigned int crb_addr_xform[NETXEN_MAX_CRB_XFORM];
48#define NETXEN_ADDR_ERROR ((unsigned long ) 0xffffffff )
49
50#define crb_addr_transform(name) \
51 crb_addr_xform[NETXEN_HW_PX_MAP_CRB_##name] = \
52 NETXEN_HW_CRB_HUB_AGT_ADR_##name << 20
53
54#define NETXEN_NIC_XDMA_RESET 0x8000ff
55
56static inline void
57netxen_nic_locked_write_reg(struct netxen_adapter *adapter,
58 unsigned long off, int *data)
59{
60 void __iomem *addr = pci_base_offset(adapter, off);
61 writel(*data, addr);
62}
63
64static void crb_addr_transform_setup(void)
65{
66 crb_addr_transform(XDMA);
67 crb_addr_transform(TIMR);
68 crb_addr_transform(SRE);
69 crb_addr_transform(SQN3);
70 crb_addr_transform(SQN2);
71 crb_addr_transform(SQN1);
72 crb_addr_transform(SQN0);
73 crb_addr_transform(SQS3);
74 crb_addr_transform(SQS2);
75 crb_addr_transform(SQS1);
76 crb_addr_transform(SQS0);
77 crb_addr_transform(RPMX7);
78 crb_addr_transform(RPMX6);
79 crb_addr_transform(RPMX5);
80 crb_addr_transform(RPMX4);
81 crb_addr_transform(RPMX3);
82 crb_addr_transform(RPMX2);
83 crb_addr_transform(RPMX1);
84 crb_addr_transform(RPMX0);
85 crb_addr_transform(ROMUSB);
86 crb_addr_transform(SN);
87 crb_addr_transform(QMN);
88 crb_addr_transform(QMS);
89 crb_addr_transform(PGNI);
90 crb_addr_transform(PGND);
91 crb_addr_transform(PGN3);
92 crb_addr_transform(PGN2);
93 crb_addr_transform(PGN1);
94 crb_addr_transform(PGN0);
95 crb_addr_transform(PGSI);
96 crb_addr_transform(PGSD);
97 crb_addr_transform(PGS3);
98 crb_addr_transform(PGS2);
99 crb_addr_transform(PGS1);
100 crb_addr_transform(PGS0);
101 crb_addr_transform(PS);
102 crb_addr_transform(PH);
103 crb_addr_transform(NIU);
104 crb_addr_transform(I2Q);
105 crb_addr_transform(EG);
106 crb_addr_transform(MN);
107 crb_addr_transform(MS);
108 crb_addr_transform(CAS2);
109 crb_addr_transform(CAS1);
110 crb_addr_transform(CAS0);
111 crb_addr_transform(CAM);
112 crb_addr_transform(C2C1);
113 crb_addr_transform(C2C0);
114}
115
116int netxen_init_firmware(struct netxen_adapter *adapter)
117{
118 u32 state = 0, loops = 0, err = 0;
119
120 /* Window 1 call */
121 state = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE));
122
123 if (state == PHAN_INITIALIZE_ACK)
124 return 0;
125
126 while (state != PHAN_INITIALIZE_COMPLETE && loops < 2000) {
127 udelay(100);
128 /* Window 1 call */
129 state = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE));
130
131 loops++;
132 }
133 if (loops >= 2000) {
134 printk(KERN_ERR "Cmd Peg initialization not complete:%x.\n",
135 state);
136 err = -EIO;
137 return err;
138 }
139 /* Window 1 call */
140 writel(MPORT_SINGLE_FUNCTION_MODE,
141 NETXEN_CRB_NORMALIZE(adapter, CRB_MPORT_MODE));
142 writel(PHAN_INITIALIZE_ACK,
143 NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE));
144
145 return err;
146}
147
148#define NETXEN_ADDR_LIMIT 0xffffffffULL
149
150void *netxen_alloc(struct pci_dev *pdev, size_t sz, dma_addr_t * ptr,
151 struct pci_dev **used_dev)
152{
153 void *addr;
154
155 addr = pci_alloc_consistent(pdev, sz, ptr);
156 if ((unsigned long long)(*ptr) < NETXEN_ADDR_LIMIT) {
157 *used_dev = pdev;
158 return addr;
159 }
160 pci_free_consistent(pdev, sz, addr, *ptr);
161 addr = pci_alloc_consistent(NULL, sz, ptr);
162 *used_dev = NULL;
163 return addr;
164}
165
166void netxen_initialize_adapter_sw(struct netxen_adapter *adapter)
167{
168 int ctxid, ring;
169 u32 i;
170 u32 num_rx_bufs = 0;
171 struct netxen_rcv_desc_ctx *rcv_desc;
172
173 DPRINTK(INFO, "initializing some queues: %p\n", adapter);
174 for (ctxid = 0; ctxid < MAX_RCV_CTX; ++ctxid) {
175 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) {
176 struct netxen_rx_buffer *rx_buf;
177 rcv_desc = &adapter->recv_ctx[ctxid].rcv_desc[ring];
178 rcv_desc->rcv_free = rcv_desc->max_rx_desc_count;
179 rcv_desc->begin_alloc = 0;
180 rx_buf = rcv_desc->rx_buf_arr;
181 num_rx_bufs = rcv_desc->max_rx_desc_count;
182 /*
183 * Now go through all of them, set reference handles
184 * and put them in the queues.
185 */
186 for (i = 0; i < num_rx_bufs; i++) {
187 rx_buf->ref_handle = i;
188 rx_buf->state = NETXEN_BUFFER_FREE;
189 DPRINTK(INFO, "Rx buf:ctx%d i(%d) rx_buf:"
190 "%p\n", ctxid, i, rx_buf);
191 rx_buf++;
192 }
193 }
194 }
195}
196
197void netxen_initialize_adapter_hw(struct netxen_adapter *adapter)
198{
199 int ports = 0;
200 struct netxen_board_info *board_info = &(adapter->ahw.boardcfg);
201
202 if (netxen_nic_get_board_info(adapter) != 0)
203 printk("%s: Error getting board config info.\n",
204 netxen_nic_driver_name);
205 get_brd_port_by_type(board_info->board_type, &ports);
206 if (ports == 0)
207 printk(KERN_ERR "%s: Unknown board type\n",
208 netxen_nic_driver_name);
209 adapter->ahw.max_ports = ports;
210}
211
212void netxen_initialize_adapter_ops(struct netxen_adapter *adapter)
213{
214 switch (adapter->ahw.board_type) {
215 case NETXEN_NIC_GBE:
216 adapter->enable_phy_interrupts =
217 netxen_niu_gbe_enable_phy_interrupts;
218 adapter->disable_phy_interrupts =
219 netxen_niu_gbe_disable_phy_interrupts;
220 adapter->handle_phy_intr = netxen_nic_gbe_handle_phy_intr;
221 adapter->macaddr_set = netxen_niu_macaddr_set;
222 adapter->set_mtu = netxen_nic_set_mtu_gb;
223 adapter->set_promisc = netxen_niu_set_promiscuous_mode;
224 adapter->unset_promisc = netxen_niu_set_promiscuous_mode;
225 adapter->phy_read = netxen_niu_gbe_phy_read;
226 adapter->phy_write = netxen_niu_gbe_phy_write;
227 adapter->init_port = netxen_niu_gbe_init_port;
228 adapter->init_niu = netxen_nic_init_niu_gb;
229 adapter->stop_port = netxen_niu_disable_gbe_port;
230 break;
231
232 case NETXEN_NIC_XGBE:
233 adapter->enable_phy_interrupts =
234 netxen_niu_xgbe_enable_phy_interrupts;
235 adapter->disable_phy_interrupts =
236 netxen_niu_xgbe_disable_phy_interrupts;
237 adapter->handle_phy_intr = netxen_nic_xgbe_handle_phy_intr;
238 adapter->macaddr_set = netxen_niu_xg_macaddr_set;
239 adapter->set_mtu = netxen_nic_set_mtu_xgb;
240 adapter->init_port = netxen_niu_xg_init_port;
241 adapter->set_promisc = netxen_niu_xg_set_promiscuous_mode;
242 adapter->unset_promisc = netxen_niu_xg_set_promiscuous_mode;
243 adapter->stop_port = netxen_niu_disable_xg_port;
244 break;
245
246 default:
247 break;
248 }
249}
250
251/*
252 * netxen_decode_crb_addr(0 - utility to translate from internal Phantom CRB
253 * address to external PCI CRB address.
254 */
255unsigned long netxen_decode_crb_addr(unsigned long addr)
256{
257 int i;
258 unsigned long base_addr, offset, pci_base;
259
260 crb_addr_transform_setup();
261
262 pci_base = NETXEN_ADDR_ERROR;
263 base_addr = addr & 0xfff00000;
264 offset = addr & 0x000fffff;
265
266 for (i = 0; i < NETXEN_MAX_CRB_XFORM; i++) {
267 if (crb_addr_xform[i] == base_addr) {
268 pci_base = i << 20;
269 break;
270 }
271 }
272 if (pci_base == NETXEN_ADDR_ERROR)
273 return pci_base;
274 else
275 return (pci_base + offset);
276}
277
278static long rom_max_timeout = 10000;
279static long rom_lock_timeout = 1000000;
280
281static inline int rom_lock(struct netxen_adapter *adapter)
282{
283 int iter;
284 u32 done = 0;
285 int timeout = 0;
286
287 while (!done) {
288 /* acquire semaphore2 from PCI HW block */
289 netxen_nic_read_w0(adapter, NETXEN_PCIE_REG(PCIE_SEM2_LOCK),
290 &done);
291 if (done == 1)
292 break;
293 if (timeout >= rom_lock_timeout)
294 return -EIO;
295
296 timeout++;
297 /*
298 * Yield CPU
299 */
300 if (!in_atomic())
301 schedule();
302 else {
303 for (iter = 0; iter < 20; iter++)
304 cpu_relax(); /*This a nop instr on i386 */
305 }
306 }
307 netxen_nic_reg_write(adapter, NETXEN_ROM_LOCK_ID, ROM_LOCK_DRIVER);
308 return 0;
309}
310
311int netxen_wait_rom_done(struct netxen_adapter *adapter)
312{
313 long timeout = 0;
314 long done = 0;
315
316 while (done == 0) {
317 done = netxen_nic_reg_read(adapter, NETXEN_ROMUSB_GLB_STATUS);
318 done &= 2;
319 timeout++;
320 if (timeout >= rom_max_timeout) {
321 printk("Timeout reached waiting for rom done");
322 return -EIO;
323 }
324 }
325 return 0;
326}
327
328static inline int netxen_rom_wren(struct netxen_adapter *adapter)
329{
330 /* Set write enable latch in ROM status register */
331 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 0);
332 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_INSTR_OPCODE,
333 M25P_INSTR_WREN);
334 if (netxen_wait_rom_done(adapter)) {
335 return -1;
336 }
337 return 0;
338}
339
340static inline unsigned int netxen_rdcrbreg(struct netxen_adapter *adapter,
341 unsigned int addr)
342{
343 unsigned int data = 0xdeaddead;
344 data = netxen_nic_reg_read(adapter, addr);
345 return data;
346}
347
348static inline int netxen_do_rom_rdsr(struct netxen_adapter *adapter)
349{
350 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_INSTR_OPCODE,
351 M25P_INSTR_RDSR);
352 if (netxen_wait_rom_done(adapter)) {
353 return -1;
354 }
355 return netxen_rdcrbreg(adapter, NETXEN_ROMUSB_ROM_RDATA);
356}
357
358static inline void netxen_rom_unlock(struct netxen_adapter *adapter)
359{
360 u32 val;
361
362 /* release semaphore2 */
363 netxen_nic_read_w0(adapter, NETXEN_PCIE_REG(PCIE_SEM2_UNLOCK), &val);
364
365}
366
367int netxen_rom_wip_poll(struct netxen_adapter *adapter)
368{
369 long timeout = 0;
370 long wip = 1;
371 int val;
372 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 0);
373 while (wip != 0) {
374 val = netxen_do_rom_rdsr(adapter);
375 wip = val & 1;
376 timeout++;
377 if (timeout > rom_max_timeout) {
378 return -1;
379 }
380 }
381 return 0;
382}
383
384static inline int do_rom_fast_write(struct netxen_adapter *adapter, int addr,
385 int data)
386{
387 if (netxen_rom_wren(adapter)) {
388 return -1;
389 }
390 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_WDATA, data);
391 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ADDRESS, addr);
392 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 3);
393 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_INSTR_OPCODE,
394 M25P_INSTR_PP);
395 if (netxen_wait_rom_done(adapter)) {
396 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 0);
397 return -1;
398 }
399
400 return netxen_rom_wip_poll(adapter);
401}
402
403static inline int
404do_rom_fast_read(struct netxen_adapter *adapter, int addr, int *valp)
405{
406 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ADDRESS, addr);
407 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 3);
408 udelay(100); /* prevent bursting on CRB */
409 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_DUMMY_BYTE_CNT, 0);
410 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_INSTR_OPCODE, 0xb);
411 if (netxen_wait_rom_done(adapter)) {
412 printk("Error waiting for rom done\n");
413 return -EIO;
414 }
415 /* reset abyte_cnt and dummy_byte_cnt */
416 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 0);
417 udelay(100); /* prevent bursting on CRB */
418 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_DUMMY_BYTE_CNT, 0);
419
420 *valp = netxen_nic_reg_read(adapter, NETXEN_ROMUSB_ROM_RDATA);
421 return 0;
422}
423
424int netxen_rom_fast_read(struct netxen_adapter *adapter, int addr, int *valp)
425{
426 int ret;
427
428 if (rom_lock(adapter) != 0)
429 return -EIO;
430
431 ret = do_rom_fast_read(adapter, addr, valp);
432 netxen_rom_unlock(adapter);
433 return ret;
434}
435
436int netxen_rom_fast_write(struct netxen_adapter *adapter, int addr, int data)
437{
438 int ret = 0;
439
440 if (rom_lock(adapter) != 0) {
441 return -1;
442 }
443 ret = do_rom_fast_write(adapter, addr, data);
444 netxen_rom_unlock(adapter);
445 return ret;
446}
447int netxen_do_rom_se(struct netxen_adapter *adapter, int addr)
448{
449 netxen_rom_wren(adapter);
450 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ADDRESS, addr);
451 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 3);
452 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_INSTR_OPCODE,
453 M25P_INSTR_SE);
454 if (netxen_wait_rom_done(adapter)) {
455 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 0);
456 return -1;
457 }
458 return netxen_rom_wip_poll(adapter);
459}
460
461int netxen_rom_se(struct netxen_adapter *adapter, int addr)
462{
463 int ret = 0;
464 if (rom_lock(adapter) != 0) {
465 return -1;
466 }
467 ret = netxen_do_rom_se(adapter, addr);
468 netxen_rom_unlock(adapter);
469 return ret;
470}
471
472#define NETXEN_BOARDTYPE 0x4008
473#define NETXEN_BOARDNUM 0x400c
474#define NETXEN_CHIPNUM 0x4010
475#define NETXEN_ROMBUS_RESET 0xFFFFFFFF
476#define NETXEN_ROM_FIRST_BARRIER 0x800000000ULL
477#define NETXEN_ROM_FOUND_INIT 0x400
478
479int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose)
480{
481 int addr, val, status;
482 int n, i;
483 int init_delay = 0;
484 struct crb_addr_pair *buf;
485 unsigned long off;
486
487 /* resetall */
488 status = netxen_nic_get_board_info(adapter);
489 if (status)
490 printk("%s: netxen_pinit_from_rom: Error getting board info\n",
491 netxen_nic_driver_name);
492
493 netxen_crb_writelit_adapter(adapter, NETXEN_ROMUSB_GLB_SW_RESET,
494 NETXEN_ROMBUS_RESET);
495
496 if (verbose) {
497 int val;
498 if (netxen_rom_fast_read(adapter, NETXEN_BOARDTYPE, &val) == 0)
499 printk("P2 ROM board type: 0x%08x\n", val);
500 else
501 printk("Could not read board type\n");
502 if (netxen_rom_fast_read(adapter, NETXEN_BOARDNUM, &val) == 0)
503 printk("P2 ROM board num: 0x%08x\n", val);
504 else
505 printk("Could not read board number\n");
506 if (netxen_rom_fast_read(adapter, NETXEN_CHIPNUM, &val) == 0)
507 printk("P2 ROM chip num: 0x%08x\n", val);
508 else
509 printk("Could not read chip number\n");
510 }
511
512 if (netxen_rom_fast_read(adapter, 0, &n) == 0
513 && (n & NETXEN_ROM_FIRST_BARRIER)) {
514 n &= ~NETXEN_ROM_ROUNDUP;
515 if (n < NETXEN_ROM_FOUND_INIT) {
516 if (verbose)
517 printk("%s: %d CRB init values found"
518 " in ROM.\n", netxen_nic_driver_name, n);
519 } else {
520 printk("%s:n=0x%x Error! NetXen card flash not"
521 " initialized.\n", __FUNCTION__, n);
522 return -EIO;
523 }
524 buf = kcalloc(n, sizeof(struct crb_addr_pair), GFP_KERNEL);
525 if (buf == NULL) {
526 printk("%s: netxen_pinit_from_rom: Unable to calloc "
527 "memory.\n", netxen_nic_driver_name);
528 return -ENOMEM;
529 }
530 for (i = 0; i < n; i++) {
531 if (netxen_rom_fast_read(adapter, 8 * i + 4, &val) != 0
532 || netxen_rom_fast_read(adapter, 8 * i + 8,
533 &addr) != 0)
534 return -EIO;
535
536 buf[i].addr = addr;
537 buf[i].data = val;
538
539 if (verbose)
540 printk("%s: PCI: 0x%08x == 0x%08x\n",
541 netxen_nic_driver_name, (unsigned int)
542 netxen_decode_crb_addr((unsigned long)
543 addr), val);
544 }
545 for (i = 0; i < n; i++) {
546
547 off =
548 netxen_decode_crb_addr((unsigned long)buf[i].addr) +
549 NETXEN_PCI_CRBSPACE;
550 /* skipping cold reboot MAGIC */
551 if (off == NETXEN_CAM_RAM(0x1fc))
552 continue;
553
554 /* After writing this register, HW needs time for CRB */
555 /* to quiet down (else crb_window returns 0xffffffff) */
556 if (off == NETXEN_ROMUSB_GLB_SW_RESET) {
557 init_delay = 1;
558 /* hold xdma in reset also */
559 buf[i].data = NETXEN_NIC_XDMA_RESET;
560 }
561
562 if (ADDR_IN_WINDOW1(off)) {
563 writel(buf[i].data,
564 NETXEN_CRB_NORMALIZE(adapter, off));
565 } else {
566 netxen_nic_pci_change_crbwindow(adapter, 0);
567 writel(buf[i].data,
568 pci_base_offset(adapter, off));
569
570 netxen_nic_pci_change_crbwindow(adapter, 1);
571 }
572 if (init_delay == 1) {
573 ssleep(1);
574 init_delay = 0;
575 }
576 msleep(1);
577 }
578 kfree(buf);
579
580 /* disable_peg_cache_all */
581
582 /* unreset_net_cache */
583 netxen_nic_hw_read_wx(adapter, NETXEN_ROMUSB_GLB_SW_RESET, &val,
584 4);
585 netxen_crb_writelit_adapter(adapter, NETXEN_ROMUSB_GLB_SW_RESET,
586 (val & 0xffffff0f));
587 /* p2dn replyCount */
588 netxen_crb_writelit_adapter(adapter,
589 NETXEN_CRB_PEG_NET_D + 0xec, 0x1e);
590 /* disable_peg_cache 0 */
591 netxen_crb_writelit_adapter(adapter,
592 NETXEN_CRB_PEG_NET_D + 0x4c, 8);
593 /* disable_peg_cache 1 */
594 netxen_crb_writelit_adapter(adapter,
595 NETXEN_CRB_PEG_NET_I + 0x4c, 8);
596
597 /* peg_clr_all */
598
599 /* peg_clr 0 */
600 netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_0 + 0x8,
601 0);
602 netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_0 + 0xc,
603 0);
604 /* peg_clr 1 */
605 netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_1 + 0x8,
606 0);
607 netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_1 + 0xc,
608 0);
609 /* peg_clr 2 */
610 netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_2 + 0x8,
611 0);
612 netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_2 + 0xc,
613 0);
614 /* peg_clr 3 */
615 netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_3 + 0x8,
616 0);
617 netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_3 + 0xc,
618 0);
619 }
620 return 0;
621}
622
623int netxen_initialize_adapter_offload(struct netxen_adapter *adapter)
624{
625 uint64_t addr;
626 uint32_t hi;
627 uint32_t lo;
628
629 adapter->dummy_dma.addr =
630 pci_alloc_consistent(adapter->ahw.pdev,
631 NETXEN_HOST_DUMMY_DMA_SIZE,
632 &adapter->dummy_dma.phys_addr);
633 if (adapter->dummy_dma.addr == NULL) {
634 printk("%s: ERROR: Could not allocate dummy DMA memory\n",
635 __FUNCTION__);
636 return -ENOMEM;
637 }
638
639 addr = (uint64_t) adapter->dummy_dma.phys_addr;
640 hi = (addr >> 32) & 0xffffffff;
641 lo = addr & 0xffffffff;
642
643 writel(hi, NETXEN_CRB_NORMALIZE(adapter, CRB_HOST_DUMMY_BUF_ADDR_HI));
644 writel(lo, NETXEN_CRB_NORMALIZE(adapter, CRB_HOST_DUMMY_BUF_ADDR_LO));
645
646 return 0;
647}
648
649void netxen_free_adapter_offload(struct netxen_adapter *adapter)
650{
651 if (adapter->dummy_dma.addr) {
652 pci_free_consistent(adapter->ahw.pdev,
653 NETXEN_HOST_DUMMY_DMA_SIZE,
654 adapter->dummy_dma.addr,
655 adapter->dummy_dma.phys_addr);
656 adapter->dummy_dma.addr = NULL;
657 }
658}
659
660void netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val)
661{
662 u32 val = 0;
663 int loops = 0;
664
665 if (!pegtune_val) {
666 while (val != PHAN_INITIALIZE_COMPLETE && loops < 200000) {
667 udelay(100);
668 schedule();
669 val =
670 readl(NETXEN_CRB_NORMALIZE
671 (adapter, CRB_CMDPEG_STATE));
672 loops++;
673 }
674 if (val != PHAN_INITIALIZE_COMPLETE)
675 printk("WARNING: Initial boot wait loop failed...\n");
676 }
677}
678
679int netxen_nic_rx_has_work(struct netxen_adapter *adapter)
680{
681 int ctx;
682
683 for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) {
684 struct netxen_recv_context *recv_ctx =
685 &(adapter->recv_ctx[ctx]);
686 u32 consumer;
687 struct status_desc *desc_head;
688 struct status_desc *desc;
689
690 consumer = recv_ctx->status_rx_consumer;
691 desc_head = recv_ctx->rcv_status_desc_head;
692 desc = &desc_head[consumer];
693
694 if (((le16_to_cpu(netxen_get_sts_owner(desc)))
695 & STATUS_OWNER_HOST))
696 return 1;
697 }
698
699 return 0;
700}
701
702static inline int netxen_nic_check_temp(struct netxen_adapter *adapter)
703{
704 int port_num;
705 struct netxen_port *port;
706 struct net_device *netdev;
707 uint32_t temp, temp_state, temp_val;
708 int rv = 0;
709
710 temp = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_TEMP_STATE));
711
712 temp_state = nx_get_temp_state(temp);
713 temp_val = nx_get_temp_val(temp);
714
715 if (temp_state == NX_TEMP_PANIC) {
716 printk(KERN_ALERT
717 "%s: Device temperature %d degrees C exceeds"
718 " maximum allowed. Hardware has been shut down.\n",
719 netxen_nic_driver_name, temp_val);
720 for (port_num = 0; port_num < adapter->ahw.max_ports;
721 port_num++) {
722 port = adapter->port[port_num];
723 netdev = port->netdev;
724
725 netif_carrier_off(netdev);
726 netif_stop_queue(netdev);
727 }
728 rv = 1;
729 } else if (temp_state == NX_TEMP_WARN) {
730 if (adapter->temp == NX_TEMP_NORMAL) {
731 printk(KERN_ALERT
732 "%s: Device temperature %d degrees C "
733 "exceeds operating range."
734 " Immediate action needed.\n",
735 netxen_nic_driver_name, temp_val);
736 }
737 } else {
738 if (adapter->temp == NX_TEMP_WARN) {
739 printk(KERN_INFO
740 "%s: Device temperature is now %d degrees C"
741 " in normal range.\n", netxen_nic_driver_name,
742 temp_val);
743 }
744 }
745 adapter->temp = temp_state;
746 return rv;
747}
748
749void netxen_watchdog_task(struct work_struct *work)
750{
751 int port_num;
752 struct netxen_port *port;
753 struct net_device *netdev;
754 struct netxen_adapter *adapter =
755 container_of(work, struct netxen_adapter, watchdog_task);
756
757 if (netxen_nic_check_temp(adapter))
758 return;
759
760 for (port_num = 0; port_num < adapter->ahw.max_ports; port_num++) {
761 port = adapter->port[port_num];
762 netdev = port->netdev;
763
764 if ((netif_running(netdev)) && !netif_carrier_ok(netdev)) {
765 printk(KERN_INFO "%s port %d, %s carrier is now ok\n",
766 netxen_nic_driver_name, port_num, netdev->name);
767 netif_carrier_on(netdev);
768 }
769
770 if (netif_queue_stopped(netdev))
771 netif_wake_queue(netdev);
772 }
773
774 if (adapter->handle_phy_intr)
775 adapter->handle_phy_intr(adapter);
776 mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ);
777}
778
779/*
780 * netxen_process_rcv() send the received packet to the protocol stack.
781 * and if the number of receives exceeds RX_BUFFERS_REFILL, then we
782 * invoke the routine to send more rx buffers to the Phantom...
783 */
784void
785netxen_process_rcv(struct netxen_adapter *adapter, int ctxid,
786 struct status_desc *desc)
787{
788 struct netxen_port *port = adapter->port[netxen_get_sts_port(desc)];
789 struct pci_dev *pdev = port->pdev;
790 struct net_device *netdev = port->netdev;
791 int index = le16_to_cpu(netxen_get_sts_refhandle(desc));
792 struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctxid]);
793 struct netxen_rx_buffer *buffer;
794 struct sk_buff *skb;
795 u32 length = le16_to_cpu(netxen_get_sts_totallength(desc));
796 u32 desc_ctx;
797 struct netxen_rcv_desc_ctx *rcv_desc;
798 int ret;
799
800 desc_ctx = netxen_get_sts_type(desc);
801 if (unlikely(desc_ctx >= NUM_RCV_DESC_RINGS)) {
802 printk("%s: %s Bad Rcv descriptor ring\n",
803 netxen_nic_driver_name, netdev->name);
804 return;
805 }
806
807 rcv_desc = &recv_ctx->rcv_desc[desc_ctx];
808 if (unlikely(index > rcv_desc->max_rx_desc_count)) {
809 DPRINTK(ERR, "Got a buffer index:%x Max is %x\n",
810 index, rcv_desc->max_rx_desc_count);
811 return;
812 }
813 buffer = &rcv_desc->rx_buf_arr[index];
814 if (desc_ctx == RCV_DESC_LRO_CTXID) {
815 buffer->lro_current_frags++;
816 if (netxen_get_sts_desc_lro_last_frag(desc)) {
817 buffer->lro_expected_frags =
818 netxen_get_sts_desc_lro_cnt(desc);
819 buffer->lro_length = length;
820 }
821 if (buffer->lro_current_frags != buffer->lro_expected_frags) {
822 if (buffer->lro_expected_frags != 0) {
823 printk("LRO: (refhandle:%x) recv frag."
824 "wait for last. flags: %x expected:%d"
825 "have:%d\n", index,
826 netxen_get_sts_desc_lro_last_frag(desc),
827 buffer->lro_expected_frags,
828 buffer->lro_current_frags);
829 }
830 return;
831 }
832 }
833
834 pci_unmap_single(pdev, buffer->dma, rcv_desc->dma_size,
835 PCI_DMA_FROMDEVICE);
836
837 skb = (struct sk_buff *)buffer->skb;
838
839 if (likely(netxen_get_sts_status(desc) == STATUS_CKSUM_OK)) {
840 port->stats.csummed++;
841 skb->ip_summed = CHECKSUM_UNNECESSARY;
842 }
843 skb->dev = netdev;
844 if (desc_ctx == RCV_DESC_LRO_CTXID) {
845 /* True length was only available on the last pkt */
846 skb_put(skb, buffer->lro_length);
847 } else {
848 skb_put(skb, length);
849 }
850
851 skb->protocol = eth_type_trans(skb, netdev);
852
853 ret = netif_receive_skb(skb);
854
855 /*
856 * RH: Do we need these stats on a regular basis. Can we get it from
857 * Linux stats.
858 */
859 switch (ret) {
860 case NET_RX_SUCCESS:
861 port->stats.uphappy++;
862 break;
863
864 case NET_RX_CN_LOW:
865 port->stats.uplcong++;
866 break;
867
868 case NET_RX_CN_MOD:
869 port->stats.upmcong++;
870 break;
871
872 case NET_RX_CN_HIGH:
873 port->stats.uphcong++;
874 break;
875
876 case NET_RX_DROP:
877 port->stats.updropped++;
878 break;
879
880 default:
881 port->stats.updunno++;
882 break;
883 }
884
885 netdev->last_rx = jiffies;
886
887 rcv_desc->rcv_free++;
888 rcv_desc->rcv_pending--;
889
890 /*
891 * We just consumed one buffer so post a buffer.
892 */
893 adapter->stats.post_called++;
894 buffer->skb = NULL;
895 buffer->state = NETXEN_BUFFER_FREE;
896 buffer->lro_current_frags = 0;
897 buffer->lro_expected_frags = 0;
898
899 port->stats.no_rcv++;
900 port->stats.rxbytes += length;
901}
902
903/* Process Receive status ring */
904u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max)
905{
906 struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctxid]);
907 struct status_desc *desc_head = recv_ctx->rcv_status_desc_head;
908 struct status_desc *desc; /* used to read status desc here */
909 u32 consumer = recv_ctx->status_rx_consumer;
910 u32 producer = 0;
911 int count = 0, ring;
912
913 DPRINTK(INFO, "procesing receive\n");
914 /*
915 * we assume in this case that there is only one port and that is
916 * port #1...changes need to be done in firmware to indicate port
917 * number as part of the descriptor. This way we will be able to get
918 * the netdev which is associated with that device.
919 */
920 while (count < max) {
921 desc = &desc_head[consumer];
922 if (!
923 (le16_to_cpu(netxen_get_sts_owner(desc)) &
924 STATUS_OWNER_HOST)) {
925 DPRINTK(ERR, "desc %p ownedby %x\n", desc,
926 netxen_get_sts_owner(desc));
927 break;
928 }
929 netxen_process_rcv(adapter, ctxid, desc);
930 netxen_clear_sts_owner(desc);
931 netxen_set_sts_owner(desc, STATUS_OWNER_PHANTOM);
932 consumer = (consumer + 1) & (adapter->max_rx_desc_count - 1);
933 count++;
934 }
935 if (count) {
936 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) {
937 netxen_post_rx_buffers_nodb(adapter, ctxid, ring);
938 }
939 }
940
941 /* update the consumer index in phantom */
942 if (count) {
943 adapter->stats.process_rcv++;
944 recv_ctx->status_rx_consumer = consumer;
945 recv_ctx->status_rx_producer = producer;
946
947 /* Window = 1 */
948 writel(consumer,
949 NETXEN_CRB_NORMALIZE(adapter,
950 recv_crb_registers[ctxid].
951 crb_rcv_status_consumer));
952 }
953
954 return count;
955}
956
957/* Process Command status ring */
958int netxen_process_cmd_ring(unsigned long data)
959{
960 u32 last_consumer;
961 u32 consumer;
962 struct netxen_adapter *adapter = (struct netxen_adapter *)data;
963 int count1 = 0;
964 int count2 = 0;
965 struct netxen_cmd_buffer *buffer;
966 struct netxen_port *port; /* port #1 */
967 struct netxen_port *nport;
968 struct pci_dev *pdev;
969 struct netxen_skb_frag *frag;
970 u32 i;
971 struct sk_buff *skb = NULL;
972 int p;
973 int done;
974
975 spin_lock(&adapter->tx_lock);
976 last_consumer = adapter->last_cmd_consumer;
977 DPRINTK(INFO, "procesing xmit complete\n");
978 /* we assume in this case that there is only one port and that is
979 * port #1...changes need to be done in firmware to indicate port
980 * number as part of the descriptor. This way we will be able to get
981 * the netdev which is associated with that device.
982 */
983
984 consumer = *(adapter->cmd_consumer);
985 if (last_consumer == consumer) { /* Ring is empty */
986 DPRINTK(INFO, "last_consumer %d == consumer %d\n",
987 last_consumer, consumer);
988 spin_unlock(&adapter->tx_lock);
989 return 1;
990 }
991
992 adapter->proc_cmd_buf_counter++;
993 adapter->stats.process_xmit++;
994 /*
995 * Not needed - does not seem to be used anywhere.
996 * adapter->cmd_consumer = consumer;
997 */
998 spin_unlock(&adapter->tx_lock);
999
1000 while ((last_consumer != consumer) && (count1 < MAX_STATUS_HANDLE)) {
1001 buffer = &adapter->cmd_buf_arr[last_consumer];
1002 port = adapter->port[buffer->port];
1003 pdev = port->pdev;
1004 frag = &buffer->frag_array[0];
1005 skb = buffer->skb;
1006 if (skb && (cmpxchg(&buffer->skb, skb, 0) == skb)) {
1007 pci_unmap_single(pdev, frag->dma, frag->length,
1008 PCI_DMA_TODEVICE);
1009 for (i = 1; i < buffer->frag_count; i++) {
1010 DPRINTK(INFO, "getting fragment no %d\n", i);
1011 frag++; /* Get the next frag */
1012 pci_unmap_page(pdev, frag->dma, frag->length,
1013 PCI_DMA_TODEVICE);
1014 }
1015
1016 port->stats.skbfreed++;
1017 dev_kfree_skb_any(skb);
1018 skb = NULL;
1019 } else if (adapter->proc_cmd_buf_counter == 1) {
1020 port->stats.txnullskb++;
1021 }
1022 if (unlikely(netif_queue_stopped(port->netdev)
1023 && netif_carrier_ok(port->netdev))
1024 && ((jiffies - port->netdev->trans_start) >
1025 port->netdev->watchdog_timeo)) {
1026 SCHEDULE_WORK(&port->adapter->tx_timeout_task);
1027 }
1028
1029 last_consumer = get_next_index(last_consumer,
1030 adapter->max_tx_desc_count);
1031 count1++;
1032 }
1033 adapter->stats.noxmitdone += count1;
1034
1035 count2 = 0;
1036 spin_lock(&adapter->tx_lock);
1037 if ((--adapter->proc_cmd_buf_counter) == 0) {
1038 adapter->last_cmd_consumer = last_consumer;
1039 while ((adapter->last_cmd_consumer != consumer)
1040 && (count2 < MAX_STATUS_HANDLE)) {
1041 buffer =
1042 &adapter->cmd_buf_arr[adapter->last_cmd_consumer];
1043 count2++;
1044 if (buffer->skb)
1045 break;
1046 else
1047 adapter->last_cmd_consumer =
1048 get_next_index(adapter->last_cmd_consumer,
1049 adapter->max_tx_desc_count);
1050 }
1051 }
1052 if (count1 || count2) {
1053 for (p = 0; p < adapter->ahw.max_ports; p++) {
1054 nport = adapter->port[p];
1055 if (netif_queue_stopped(nport->netdev)
1056 && (nport->flags & NETXEN_NETDEV_STATUS)) {
1057 netif_wake_queue(nport->netdev);
1058 nport->flags &= ~NETXEN_NETDEV_STATUS;
1059 }
1060 }
1061 }
1062 /*
1063 * If everything is freed up to consumer then check if the ring is full
1064 * If the ring is full then check if more needs to be freed and
1065 * schedule the call back again.
1066 *
1067 * This happens when there are 2 CPUs. One could be freeing and the
1068 * other filling it. If the ring is full when we get out of here and
1069 * the card has already interrupted the host then the host can miss the
1070 * interrupt.
1071 *
1072 * There is still a possible race condition and the host could miss an
1073 * interrupt. The card has to take care of this.
1074 */
1075 if (adapter->last_cmd_consumer == consumer &&
1076 (((adapter->cmd_producer + 1) %
1077 adapter->max_tx_desc_count) == adapter->last_cmd_consumer)) {
1078 consumer = *(adapter->cmd_consumer);
1079 }
1080 done = (adapter->last_cmd_consumer == consumer);
1081
1082 spin_unlock(&adapter->tx_lock);
1083 DPRINTK(INFO, "last consumer is %d in %s\n", last_consumer,
1084 __FUNCTION__);
1085 return (done);
1086}
1087
1088/*
1089 * netxen_post_rx_buffers puts buffer in the Phantom memory
1090 */
1091void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid)
1092{
1093 struct pci_dev *pdev = adapter->ahw.pdev;
1094 struct sk_buff *skb;
1095 struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctx]);
1096 struct netxen_rcv_desc_ctx *rcv_desc = NULL;
1097 uint producer;
1098 struct rcv_desc *pdesc;
1099 struct netxen_rx_buffer *buffer;
1100 int count = 0;
1101 int index = 0;
1102 netxen_ctx_msg msg = 0;
1103 dma_addr_t dma;
1104
1105 adapter->stats.post_called++;
1106 rcv_desc = &recv_ctx->rcv_desc[ringid];
1107
1108 producer = rcv_desc->producer;
1109 index = rcv_desc->begin_alloc;
1110 buffer = &rcv_desc->rx_buf_arr[index];
1111 /* We can start writing rx descriptors into the phantom memory. */
1112 while (buffer->state == NETXEN_BUFFER_FREE) {
1113 skb = dev_alloc_skb(rcv_desc->skb_size);
1114 if (unlikely(!skb)) {
1115 /*
1116 * TODO
1117 * We need to schedule the posting of buffers to the pegs.
1118 */
1119 rcv_desc->begin_alloc = index;
1120 DPRINTK(ERR, "netxen_post_rx_buffers: "
1121 " allocated only %d buffers\n", count);
1122 break;
1123 }
1124
1125 count++; /* now there should be no failure */
1126 pdesc = &rcv_desc->desc_head[producer];
1127
1128#if defined(XGB_DEBUG)
1129 *(unsigned long *)(skb->head) = 0xc0debabe;
1130 if (skb_is_nonlinear(skb)) {
1131 printk("Allocated SKB @%p is nonlinear\n");
1132 }
1133#endif
1134 skb_reserve(skb, 2);
1135 /* This will be setup when we receive the
1136 * buffer after it has been filled FSL TBD TBD
1137 * skb->dev = netdev;
1138 */
1139 dma = pci_map_single(pdev, skb->data, rcv_desc->dma_size,
1140 PCI_DMA_FROMDEVICE);
1141 pdesc->addr_buffer = dma;
1142 buffer->skb = skb;
1143 buffer->state = NETXEN_BUFFER_BUSY;
1144 buffer->dma = dma;
1145 /* make a rcv descriptor */
1146 pdesc->reference_handle = buffer->ref_handle;
1147 pdesc->buffer_length = rcv_desc->dma_size;
1148 DPRINTK(INFO, "done writing descripter\n");
1149 producer =
1150 get_next_index(producer, rcv_desc->max_rx_desc_count);
1151 index = get_next_index(index, rcv_desc->max_rx_desc_count);
1152 buffer = &rcv_desc->rx_buf_arr[index];
1153 }
1154 /* if we did allocate buffers, then write the count to Phantom */
1155 if (count) {
1156 rcv_desc->begin_alloc = index;
1157 rcv_desc->rcv_pending += count;
1158 adapter->stats.lastposted = count;
1159 adapter->stats.posted += count;
1160 rcv_desc->producer = producer;
1161 if (rcv_desc->rcv_free >= 32) {
1162 rcv_desc->rcv_free = 0;
1163 /* Window = 1 */
1164 writel((producer - 1) &
1165 (rcv_desc->max_rx_desc_count - 1),
1166 NETXEN_CRB_NORMALIZE(adapter,
1167 recv_crb_registers[0].
1168 rcv_desc_crb[ringid].
1169 crb_rcv_producer_offset));
1170 /*
1171 * Write a doorbell msg to tell phanmon of change in
1172 * receive ring producer
1173 */
1174 netxen_set_msg_peg_id(msg, NETXEN_RCV_PEG_DB_ID);
1175 netxen_set_msg_privid(msg);
1176 netxen_set_msg_count(msg,
1177 ((producer -
1178 1) & (rcv_desc->
1179 max_rx_desc_count - 1)));
1180 netxen_set_msg_ctxid(msg, 0);
1181 netxen_set_msg_opcode(msg, NETXEN_RCV_PRODUCER(ringid));
1182 writel(msg,
1183 DB_NORMALIZE(adapter,
1184 NETXEN_RCV_PRODUCER_OFFSET));
1185 }
1186 }
1187}
1188
1189void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, uint32_t ctx,
1190 uint32_t ringid)
1191{
1192 struct pci_dev *pdev = adapter->ahw.pdev;
1193 struct sk_buff *skb;
1194 struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctx]);
1195 struct netxen_rcv_desc_ctx *rcv_desc = NULL;
1196 u32 producer;
1197 struct rcv_desc *pdesc;
1198 struct netxen_rx_buffer *buffer;
1199 int count = 0;
1200 int index = 0;
1201
1202 adapter->stats.post_called++;
1203 rcv_desc = &recv_ctx->rcv_desc[ringid];
1204
1205 producer = rcv_desc->producer;
1206 index = rcv_desc->begin_alloc;
1207 buffer = &rcv_desc->rx_buf_arr[index];
1208 /* We can start writing rx descriptors into the phantom memory. */
1209 while (buffer->state == NETXEN_BUFFER_FREE) {
1210 skb = dev_alloc_skb(rcv_desc->skb_size);
1211 if (unlikely(!skb)) {
1212 /*
1213 * We need to schedule the posting of buffers to the pegs.
1214 */
1215 rcv_desc->begin_alloc = index;
1216 DPRINTK(ERR, "netxen_post_rx_buffers_nodb: "
1217 " allocated only %d buffers\n", count);
1218 break;
1219 }
1220 count++; /* now there should be no failure */
1221 pdesc = &rcv_desc->desc_head[producer];
1222 skb_reserve(skb, 2);
1223 /*
1224 * This will be setup when we receive the
1225 * buffer after it has been filled
1226 * skb->dev = netdev;
1227 */
1228 buffer->skb = skb;
1229 buffer->state = NETXEN_BUFFER_BUSY;
1230 buffer->dma = pci_map_single(pdev, skb->data,
1231 rcv_desc->dma_size,
1232 PCI_DMA_FROMDEVICE);
1233
1234 /* make a rcv descriptor */
1235 pdesc->reference_handle = le16_to_cpu(buffer->ref_handle);
1236 pdesc->buffer_length = le16_to_cpu(rcv_desc->dma_size);
1237 pdesc->addr_buffer = cpu_to_le64(buffer->dma);
1238 DPRINTK(INFO, "done writing descripter\n");
1239 producer =
1240 get_next_index(producer, rcv_desc->max_rx_desc_count);
1241 index = get_next_index(index, rcv_desc->max_rx_desc_count);
1242 buffer = &rcv_desc->rx_buf_arr[index];
1243 }
1244
1245 /* if we did allocate buffers, then write the count to Phantom */
1246 if (count) {
1247 rcv_desc->begin_alloc = index;
1248 rcv_desc->rcv_pending += count;
1249 adapter->stats.lastposted = count;
1250 adapter->stats.posted += count;
1251 rcv_desc->producer = producer;
1252 if (rcv_desc->rcv_free >= 32) {
1253 rcv_desc->rcv_free = 0;
1254 /* Window = 1 */
1255 writel((producer - 1) &
1256 (rcv_desc->max_rx_desc_count - 1),
1257 NETXEN_CRB_NORMALIZE(adapter,
1258 recv_crb_registers[0].
1259 rcv_desc_crb[ringid].
1260 crb_rcv_producer_offset));
1261 wmb();
1262 }
1263 }
1264}
1265
1266int netxen_nic_tx_has_work(struct netxen_adapter *adapter)
1267{
1268 if (find_diff_among(adapter->last_cmd_consumer,
1269 adapter->cmd_producer,
1270 adapter->max_tx_desc_count) > 0)
1271 return 1;
1272
1273 return 0;
1274}
1275
1276int
1277netxen_nic_fill_statistics(struct netxen_adapter *adapter,
1278 struct netxen_port *port,
1279 struct netxen_statistics *netxen_stats)
1280{
1281 void __iomem *addr;
1282
1283 if (adapter->ahw.board_type == NETXEN_NIC_XGBE) {
1284 netxen_nic_pci_change_crbwindow(adapter, 0);
1285 NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_XGE_TX_BYTE_CNT,
1286 &(netxen_stats->tx_bytes));
1287 NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_XGE_TX_FRAME_CNT,
1288 &(netxen_stats->tx_packets));
1289 NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_XGE_RX_BYTE_CNT,
1290 &(netxen_stats->rx_bytes));
1291 NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_XGE_RX_FRAME_CNT,
1292 &(netxen_stats->rx_packets));
1293 NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_XGE_AGGR_ERROR_CNT,
1294 &(netxen_stats->rx_errors));
1295 NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_XGE_CRC_ERROR_CNT,
1296 &(netxen_stats->rx_crc_errors));
1297 NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_XGE_OVERSIZE_FRAME_ERR,
1298 &(netxen_stats->
1299 rx_long_length_error));
1300 NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_XGE_UNDERSIZE_FRAME_ERR,
1301 &(netxen_stats->
1302 rx_short_length_error));
1303
1304 netxen_nic_pci_change_crbwindow(adapter, 1);
1305 } else {
1306 spin_lock_bh(&adapter->tx_lock);
1307 netxen_stats->tx_bytes = port->stats.txbytes;
1308 netxen_stats->tx_packets = port->stats.xmitedframes +
1309 port->stats.xmitfinished;
1310 netxen_stats->rx_bytes = port->stats.rxbytes;
1311 netxen_stats->rx_packets = port->stats.no_rcv;
1312 netxen_stats->rx_errors = port->stats.rcvdbadskb;
1313 netxen_stats->tx_errors = port->stats.nocmddescriptor;
1314 netxen_stats->rx_short_length_error = port->stats.uplcong;
1315 netxen_stats->rx_long_length_error = port->stats.uphcong;
1316 netxen_stats->rx_crc_errors = 0;
1317 netxen_stats->rx_mac_errors = 0;
1318 spin_unlock_bh(&adapter->tx_lock);
1319 }
1320 return 0;
1321}
1322
1323void netxen_nic_clear_stats(struct netxen_adapter *adapter)
1324{
1325 struct netxen_port *port;
1326 int port_num;
1327
1328 memset(&adapter->stats, 0, sizeof(adapter->stats));
1329 for (port_num = 0; port_num < adapter->ahw.max_ports; port_num++) {
1330 port = adapter->port[port_num];
1331 memset(&port->stats, 0, sizeof(port->stats));
1332 }
1333}
1334
1335int
1336netxen_nic_clear_statistics(struct netxen_adapter *adapter,
1337 struct netxen_port *port)
1338{
1339 int data = 0;
1340
1341 netxen_nic_pci_change_crbwindow(adapter, 0);
1342
1343 netxen_nic_locked_write_reg(adapter, NETXEN_NIU_XGE_TX_BYTE_CNT, &data);
1344 netxen_nic_locked_write_reg(adapter, NETXEN_NIU_XGE_TX_FRAME_CNT,
1345 &data);
1346 netxen_nic_locked_write_reg(adapter, NETXEN_NIU_XGE_RX_BYTE_CNT, &data);
1347 netxen_nic_locked_write_reg(adapter, NETXEN_NIU_XGE_RX_FRAME_CNT,
1348 &data);
1349 netxen_nic_locked_write_reg(adapter, NETXEN_NIU_XGE_AGGR_ERROR_CNT,
1350 &data);
1351 netxen_nic_locked_write_reg(adapter, NETXEN_NIU_XGE_CRC_ERROR_CNT,
1352 &data);
1353 netxen_nic_locked_write_reg(adapter, NETXEN_NIU_XGE_OVERSIZE_FRAME_ERR,
1354 &data);
1355 netxen_nic_locked_write_reg(adapter, NETXEN_NIU_XGE_UNDERSIZE_FRAME_ERR,
1356 &data);
1357
1358 netxen_nic_pci_change_crbwindow(adapter, 1);
1359 netxen_nic_clear_stats(adapter);
1360 return 0;
1361}
1362
1363int
1364netxen_nic_do_ioctl(struct netxen_adapter *adapter, void *u_data,
1365 struct netxen_port *port)
1366{
1367 struct netxen_nic_ioctl_data data;
1368 struct netxen_nic_ioctl_data *up_data;
1369 int retval = 0;
1370 struct netxen_statistics netxen_stats;
1371
1372 up_data = (void *)u_data;
1373
1374 DPRINTK(INFO, "doing ioctl for %p\n", adapter);
1375 if (copy_from_user(&data, (void __user *)up_data, sizeof(data))) {
1376 /* evil user tried to crash the kernel */
1377 DPRINTK(ERR, "bad copy from userland: %d\n", (int)sizeof(data));
1378 retval = -EFAULT;
1379 goto error_out;
1380 }
1381
1382 /* Shouldn't access beyond legal limits of "char u[64];" member */
1383 if (!data.ptr && (data.size > sizeof(data.u))) {
1384 /* evil user tried to crash the kernel */
1385 DPRINTK(ERR, "bad size: %d\n", data.size);
1386 retval = -EFAULT;
1387 goto error_out;
1388 }
1389
1390 switch (data.cmd) {
1391 case netxen_nic_cmd_pci_read:
1392 if ((retval = netxen_nic_hw_read_ioctl(adapter, data.off,
1393 &(data.u), data.size)))
1394 goto error_out;
1395 if (copy_to_user
1396 ((void __user *)&(up_data->u), &(data.u), data.size)) {
1397 DPRINTK(ERR, "bad copy to userland: %d\n",
1398 (int)sizeof(data));
1399 retval = -EFAULT;
1400 goto error_out;
1401 }
1402 data.rv = 0;
1403 break;
1404
1405 case netxen_nic_cmd_pci_write:
1406 if ((retval = netxen_nic_hw_write_ioctl(adapter, data.off,
1407 &(data.u), data.size)))
1408 goto error_out;
1409 data.rv = 0;
1410 break;
1411
1412 case netxen_nic_cmd_pci_mem_read:
1413 if (netxen_nic_pci_mem_read_ioctl(adapter, data.off, &(data.u),
1414 data.size)) {
1415 DPRINTK(ERR, "Failed to read the data.\n");
1416 retval = -EFAULT;
1417 goto error_out;
1418 }
1419 if (copy_to_user
1420 ((void __user *)&(up_data->u), &(data.u), data.size)) {
1421 DPRINTK(ERR, "bad copy to userland: %d\n",
1422 (int)sizeof(data));
1423 retval = -EFAULT;
1424 goto error_out;
1425 }
1426 data.rv = 0;
1427 break;
1428
1429 case netxen_nic_cmd_pci_mem_write:
1430 if ((retval = netxen_nic_pci_mem_write_ioctl(adapter, data.off,
1431 &(data.u),
1432 data.size)))
1433 goto error_out;
1434 data.rv = 0;
1435 break;
1436
1437 case netxen_nic_cmd_pci_config_read:
1438 switch (data.size) {
1439 case 1:
1440 data.rv = pci_read_config_byte(adapter->ahw.pdev,
1441 data.off,
1442 (char *)&(data.u));
1443 break;
1444 case 2:
1445 data.rv = pci_read_config_word(adapter->ahw.pdev,
1446 data.off,
1447 (short *)&(data.u));
1448 break;
1449 case 4:
1450 data.rv = pci_read_config_dword(adapter->ahw.pdev,
1451 data.off,
1452 (u32 *) & (data.u));
1453 break;
1454 }
1455 if (copy_to_user
1456 ((void __user *)&(up_data->u), &(data.u), data.size)) {
1457 DPRINTK(ERR, "bad copy to userland: %d\n",
1458 (int)sizeof(data));
1459 retval = -EFAULT;
1460 goto error_out;
1461 }
1462 break;
1463
1464 case netxen_nic_cmd_pci_config_write:
1465 switch (data.size) {
1466 case 1:
1467 data.rv = pci_write_config_byte(adapter->ahw.pdev,
1468 data.off,
1469 *(char *)&(data.u));
1470 break;
1471 case 2:
1472 data.rv = pci_write_config_word(adapter->ahw.pdev,
1473 data.off,
1474 *(short *)&(data.u));
1475 break;
1476 case 4:
1477 data.rv = pci_write_config_dword(adapter->ahw.pdev,
1478 data.off,
1479 *(u32 *) & (data.u));
1480 break;
1481 }
1482 break;
1483
1484 case netxen_nic_cmd_get_stats:
1485 data.rv =
1486 netxen_nic_fill_statistics(adapter, port, &netxen_stats);
1487 if (copy_to_user
1488 ((void __user *)(up_data->ptr), (void *)&netxen_stats,
1489 sizeof(struct netxen_statistics))) {
1490 DPRINTK(ERR, "bad copy to userland: %d\n",
1491 (int)sizeof(netxen_stats));
1492 retval = -EFAULT;
1493 goto error_out;
1494 }
1495 up_data->rv = data.rv;
1496 break;
1497
1498 case netxen_nic_cmd_clear_stats:
1499 data.rv = netxen_nic_clear_statistics(adapter, port);
1500 up_data->rv = data.rv;
1501 break;
1502
1503 case netxen_nic_cmd_get_version:
1504 if (copy_to_user
1505 ((void __user *)&(up_data->u), NETXEN_NIC_LINUX_VERSIONID,
1506 sizeof(NETXEN_NIC_LINUX_VERSIONID))) {
1507 DPRINTK(ERR, "bad copy to userland: %d\n",
1508 (int)sizeof(data));
1509 retval = -EFAULT;
1510 goto error_out;
1511 }
1512 break;
1513
1514 default:
1515 DPRINTK(INFO, "bad command %d for %p\n", data.cmd, adapter);
1516 retval = -EOPNOTSUPP;
1517 goto error_out;
1518 }
1519 put_user(data.rv, (&(up_data->rv)));
1520 DPRINTK(INFO, "done ioctl for %p well.\n", adapter);
1521
1522 error_out:
1523 return retval;
1524}
diff --git a/drivers/net/netxen/netxen_nic_ioctl.h b/drivers/net/netxen/netxen_nic_ioctl.h
new file mode 100644
index 000000000000..1221fa527552
--- /dev/null
+++ b/drivers/net/netxen/netxen_nic_ioctl.h
@@ -0,0 +1,77 @@
1/*
2 * Copyright (C) 2003 - 2006 NetXen, Inc.
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 * MA 02111-1307, USA.
19 *
20 * The full GNU General Public License is included in this distribution
21 * in the file called LICENSE.
22 *
23 * Contact Information:
24 * info@netxen.com
25 * NetXen,
26 * 3965 Freedom Circle, Fourth floor,
27 * Santa Clara, CA 95054
28 */
29
30#ifndef __NETXEN_NIC_IOCTL_H__
31#define __NETXEN_NIC_IOCTL_H__
32
33#include <linux/sockios.h>
34
35#define NETXEN_CMD_START SIOCDEVPRIVATE
36#define NETXEN_NIC_CMD (NETXEN_CMD_START + 1)
37#define NETXEN_NIC_NAME (NETXEN_CMD_START + 2)
38#define NETXEN_NIC_NAME_LEN 16
39#define NETXEN_NIC_NAME_RSP "NETXEN-UNM"
40
41typedef enum {
42 netxen_nic_cmd_none = 0,
43 netxen_nic_cmd_pci_read,
44 netxen_nic_cmd_pci_write,
45 netxen_nic_cmd_pci_mem_read,
46 netxen_nic_cmd_pci_mem_write,
47 netxen_nic_cmd_pci_config_read,
48 netxen_nic_cmd_pci_config_write,
49 netxen_nic_cmd_get_stats,
50 netxen_nic_cmd_clear_stats,
51 netxen_nic_cmd_get_version
52} netxen_nic_ioctl_cmd_t;
53
54struct netxen_nic_ioctl_data {
55 u32 cmd;
56 u32 unused1;
57 u64 off;
58 u32 size;
59 u32 rv;
60 char u[64];
61 void *ptr;
62};
63
64struct netxen_statistics {
65 u64 rx_packets;
66 u64 tx_packets;
67 u64 rx_bytes;
68 u64 rx_errors;
69 u64 tx_bytes;
70 u64 tx_errors;
71 u64 rx_crc_errors;
72 u64 rx_short_length_error;
73 u64 rx_long_length_error;
74 u64 rx_mac_errors;
75};
76
77#endif /* __NETXEN_NIC_IOCTL_H_ */
diff --git a/drivers/net/netxen/netxen_nic_isr.c b/drivers/net/netxen/netxen_nic_isr.c
new file mode 100644
index 000000000000..1b45f50fa6aa
--- /dev/null
+++ b/drivers/net/netxen/netxen_nic_isr.c
@@ -0,0 +1,208 @@
1/*
2 * Copyright (C) 2003 - 2006 NetXen, Inc.
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 * MA 02111-1307, USA.
19 *
20 * The full GNU General Public License is included in this distribution
21 * in the file called LICENSE.
22 *
23 * Contact Information:
24 * info@netxen.com
25 * NetXen,
26 * 3965 Freedom Circle, Fourth floor,
27 * Santa Clara, CA 95054
28 */
29
30#include <linux/netdevice.h>
31#include <linux/delay.h>
32
33#include "netxen_nic.h"
34#include "netxen_nic_hw.h"
35#include "netxen_nic_phan_reg.h"
36
37/*
38 * netxen_nic_get_stats - Get System Network Statistics
39 * @netdev: network interface device structure
40 */
41struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev)
42{
43 struct netxen_port *port = netdev_priv(netdev);
44 struct net_device_stats *stats = &port->net_stats;
45
46 memset(stats, 0, sizeof(*stats));
47
48 /* total packets received */
49 stats->rx_packets = port->stats.no_rcv;
50 /* total packets transmitted */
51 stats->tx_packets = port->stats.xmitedframes + port->stats.xmitfinished;
52 /* total bytes received */
53 stats->rx_bytes = port->stats.rxbytes;
54 /* total bytes transmitted */
55 stats->tx_bytes = port->stats.txbytes;
56 /* bad packets received */
57 stats->rx_errors = port->stats.rcvdbadskb;
58 /* packet transmit problems */
59 stats->tx_errors = port->stats.nocmddescriptor;
60 /* no space in linux buffers */
61 stats->rx_dropped = port->stats.updropped;
62 /* no space available in linux */
63 stats->tx_dropped = port->stats.txdropped;
64
65 return stats;
66}
67
68void netxen_indicate_link_status(struct netxen_adapter *adapter, u32 portno,
69 u32 link)
70{
71 struct net_device *netdev = (adapter->port[portno])->netdev;
72
73 if (link)
74 netif_carrier_on(netdev);
75 else
76 netif_carrier_off(netdev);
77}
78
79void netxen_handle_port_int(struct netxen_adapter *adapter, u32 portno,
80 u32 enable)
81{
82 __le32 int_src;
83 struct netxen_port *port;
84
85 /* This should clear the interrupt source */
86 if (adapter->phy_read)
87 adapter->phy_read(adapter, portno,
88 NETXEN_NIU_GB_MII_MGMT_ADDR_INT_STATUS,
89 &int_src);
90 if (int_src == 0) {
91 DPRINTK(INFO, "No phy interrupts for port #%d\n", portno);
92 return;
93 }
94 if (adapter->disable_phy_interrupts)
95 adapter->disable_phy_interrupts(adapter, portno);
96
97 port = adapter->port[portno];
98
99 if (netxen_get_phy_int_jabber(int_src))
100 DPRINTK(INFO, "Jabber interrupt \n");
101
102 if (netxen_get_phy_int_polarity_changed(int_src))
103 DPRINTK(INFO, "POLARITY CHANGED int \n");
104
105 if (netxen_get_phy_int_energy_detect(int_src))
106 DPRINTK(INFO, "ENERGY DETECT INT \n");
107
108 if (netxen_get_phy_int_downshift(int_src))
109 DPRINTK(INFO, "DOWNSHIFT INT \n");
110 /* write it down later.. */
111 if ((netxen_get_phy_int_speed_changed(int_src))
112 || (netxen_get_phy_int_link_status_changed(int_src))) {
113 __le32 status;
114
115 DPRINTK(INFO, "SPEED CHANGED OR LINK STATUS CHANGED \n");
116
117 if (adapter->phy_read
118 && adapter->phy_read(adapter, portno,
119 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
120 &status) == 0) {
121 if (netxen_get_phy_int_link_status_changed(int_src)) {
122 if (netxen_get_phy_link(status)) {
123 netxen_niu_gbe_init_port(adapter,
124 portno);
125 printk("%s: %s Link UP\n",
126 netxen_nic_driver_name,
127 port->netdev->name);
128
129 } else {
130 printk("%s: %s Link DOWN\n",
131 netxen_nic_driver_name,
132 port->netdev->name);
133 }
134 netxen_indicate_link_status(adapter, portno,
135 netxen_get_phy_link
136 (status));
137 }
138 }
139 }
140 if (adapter->enable_phy_interrupts)
141 adapter->enable_phy_interrupts(adapter, portno);
142}
143
144void netxen_nic_isr_other(struct netxen_adapter *adapter)
145{
146 u32 portno;
147 u32 val, linkup, qg_linksup;
148
149 /* verify the offset */
150 val = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_XG_STATE));
151 if (val == adapter->ahw.qg_linksup)
152 return;
153
154 qg_linksup = adapter->ahw.qg_linksup;
155 adapter->ahw.qg_linksup = val;
156 DPRINTK(INFO, "link update 0x%08x\n", val);
157 for (portno = 0; portno < NETXEN_NIU_MAX_GBE_PORTS; portno++) {
158 linkup = val & 1;
159 if (linkup != (qg_linksup & 1)) {
160 printk(KERN_INFO "%s: PORT %d link %s\n",
161 netxen_nic_driver_name, portno,
162 ((linkup == 0) ? "down" : "up"));
163 netxen_indicate_link_status(adapter, portno, linkup);
164 if (linkup)
165 netxen_nic_set_link_parameters(adapter->
166 port[portno]);
167
168 }
169 val = val >> 1;
170 qg_linksup = qg_linksup >> 1;
171 }
172
173 adapter->stats.otherints++;
174
175}
176
177void netxen_nic_gbe_handle_phy_intr(struct netxen_adapter *adapter)
178{
179 netxen_nic_isr_other(adapter);
180}
181
182void netxen_nic_xgbe_handle_phy_intr(struct netxen_adapter *adapter)
183{
184 struct net_device *netdev = adapter->port[0]->netdev;
185 u32 val;
186
187 /* WINDOW = 1 */
188 val = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_XG_STATE));
189
190 if (adapter->ahw.xg_linkup == 1 && val != XG_LINK_UP) {
191 printk(KERN_INFO "%s: %s NIC Link is down\n",
192 netxen_nic_driver_name, netdev->name);
193 adapter->ahw.xg_linkup = 0;
194 /* read twice to clear sticky bits */
195 /* WINDOW = 0 */
196 netxen_nic_read_w0(adapter, NETXEN_NIU_XG_STATUS, &val);
197 netxen_nic_read_w0(adapter, NETXEN_NIU_XG_STATUS, &val);
198
199 if ((val & 0xffb) != 0xffb) {
200 printk(KERN_INFO "%s ISR: Sync/Align BAD: 0x%08x\n",
201 netxen_nic_driver_name, val);
202 }
203 } else if (adapter->ahw.xg_linkup == 0 && val == XG_LINK_UP) {
204 printk(KERN_INFO "%s: %s NIC Link is up\n",
205 netxen_nic_driver_name, netdev->name);
206 adapter->ahw.xg_linkup = 1;
207 }
208}
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
new file mode 100644
index 000000000000..575b71b67202
--- /dev/null
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -0,0 +1,1210 @@
1/*
2 * Copyright (C) 2003 - 2006 NetXen, Inc.
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 * MA 02111-1307, USA.
19 *
20 * The full GNU General Public License is included in this distribution
21 * in the file called LICENSE.
22 *
23 * Contact Information:
24 * info@netxen.com
25 * NetXen,
26 * 3965 Freedom Circle, Fourth floor,
27 * Santa Clara, CA 95054
28 *
29 *
30 * Main source file for NetXen NIC Driver on Linux
31 *
32 */
33
34#include <linux/vmalloc.h>
35#include <linux/highmem.h>
36#include "netxen_nic_hw.h"
37
38#include "netxen_nic.h"
39#define DEFINE_GLOBAL_RECV_CRB
40#include "netxen_nic_phan_reg.h"
41#include "netxen_nic_ioctl.h"
42
43#include <linux/dma-mapping.h>
44#include <linux/vmalloc.h>
45
46#define PHAN_VENDOR_ID 0x4040
47
48MODULE_DESCRIPTION("NetXen Multi port (1/10) Gigabit Network Driver");
49MODULE_LICENSE("GPL");
50MODULE_VERSION(NETXEN_NIC_LINUX_VERSIONID);
51
52char netxen_nic_driver_name[] = "netxen-nic";
53static char netxen_nic_driver_string[] = "NetXen Network Driver version "
54 NETXEN_NIC_LINUX_VERSIONID;
55
56struct netxen_adapter *g_adapter = NULL;
57
58#define NETXEN_NETDEV_WEIGHT 120
59#define NETXEN_ADAPTER_UP_MAGIC 777
60#define NETXEN_NIC_PEG_TUNE 0
61
62u8 nx_p2_id = NX_P2_C0;
63
64#define DMA_32BIT_MASK 0x00000000ffffffffULL
65#define DMA_35BIT_MASK 0x00000007ffffffffULL
66
67/* Local functions to NetXen NIC driver */
68static int __devinit netxen_nic_probe(struct pci_dev *pdev,
69 const struct pci_device_id *ent);
70static void __devexit netxen_nic_remove(struct pci_dev *pdev);
71static int netxen_nic_open(struct net_device *netdev);
72static int netxen_nic_close(struct net_device *netdev);
73static int netxen_nic_xmit_frame(struct sk_buff *, struct net_device *);
74static void netxen_tx_timeout(struct net_device *netdev);
75static void netxen_tx_timeout_task(struct work_struct *work);
76static void netxen_watchdog(unsigned long);
77static int netxen_handle_int(struct netxen_adapter *, struct net_device *);
78static int netxen_nic_ioctl(struct net_device *netdev,
79 struct ifreq *ifr, int cmd);
80static int netxen_nic_poll(struct net_device *dev, int *budget);
81#ifdef CONFIG_NET_POLL_CONTROLLER
82static void netxen_nic_poll_controller(struct net_device *netdev);
83#endif
84static irqreturn_t netxen_intr(int irq, void *data);
85
86/* PCI Device ID Table */
87static struct pci_device_id netxen_pci_tbl[] __devinitdata = {
88 {PCI_DEVICE(0x4040, 0x0001)},
89 {PCI_DEVICE(0x4040, 0x0002)},
90 {PCI_DEVICE(0x4040, 0x0003)},
91 {PCI_DEVICE(0x4040, 0x0004)},
92 {PCI_DEVICE(0x4040, 0x0005)},
93 {0,}
94};
95
96MODULE_DEVICE_TABLE(pci, netxen_pci_tbl);
97
98struct workqueue_struct *netxen_workq;
99static void netxen_watchdog(unsigned long);
100
101/*
102 * netxen_nic_probe()
103 *
104 * The Linux system will invoke this after identifying the vendor ID and
105 * device Id in the pci_tbl supported by this module.
106 *
107 * A quad port card has one operational PCI config space, (function 0),
108 * which is used to access all four ports.
109 *
110 * This routine will initialize the adapter, and setup the global parameters
111 * along with the port's specific structure.
112 */
113static int __devinit
114netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
115{
116 struct net_device *netdev = NULL;
117 struct netxen_adapter *adapter = NULL;
118 struct netxen_port *port = NULL;
119 void __iomem *mem_ptr0 = NULL;
120 void __iomem *mem_ptr1 = NULL;
121 void __iomem *mem_ptr2 = NULL;
122
123 u8 *db_ptr = NULL;
124 unsigned long mem_base, mem_len, db_base, db_len;
125 int pci_using_dac, i, err;
126 int ring;
127 struct netxen_recv_context *recv_ctx = NULL;
128 struct netxen_rcv_desc_ctx *rcv_desc = NULL;
129 struct netxen_cmd_buffer *cmd_buf_arr = NULL;
130 u64 mac_addr[FLASH_NUM_PORTS + 1];
131 int valid_mac = 0;
132 static int netxen_cards_found = 0;
133
134 printk(KERN_INFO "%s \n", netxen_nic_driver_string);
135 /* In current scheme, we use only PCI function 0 */
136 if (PCI_FUNC(pdev->devfn) != 0) {
137 DPRINTK(ERR, "NetXen function %d will not be enabled.\n",
138 PCI_FUNC(pdev->devfn));
139 return -ENODEV;
140 }
141 if ((err = pci_enable_device(pdev)))
142 return err;
143 if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) {
144 err = -ENODEV;
145 goto err_out_disable_pdev;
146 }
147
148 if ((err = pci_request_regions(pdev, netxen_nic_driver_name)))
149 goto err_out_disable_pdev;
150
151 pci_set_master(pdev);
152 pci_read_config_byte(pdev, PCI_REVISION_ID, &nx_p2_id);
153 if (nx_p2_id == NX_P2_C1 &&
154 (pci_set_dma_mask(pdev, DMA_35BIT_MASK) == 0) &&
155 (pci_set_consistent_dma_mask(pdev, DMA_35BIT_MASK) == 0)) {
156 pci_using_dac = 1;
157 } else {
158 if ((err = pci_set_dma_mask(pdev, DMA_32BIT_MASK)) ||
159 (err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK)))
160 goto err_out_free_res;
161
162 pci_using_dac = 0;
163 }
164
165 /* remap phys address */
166 mem_base = pci_resource_start(pdev, 0); /* 0 is for BAR 0 */
167 mem_len = pci_resource_len(pdev, 0);
168
169 /* 128 Meg of memory */
170 mem_ptr0 = ioremap(mem_base, FIRST_PAGE_GROUP_SIZE);
171 mem_ptr1 =
172 ioremap(mem_base + SECOND_PAGE_GROUP_START, SECOND_PAGE_GROUP_SIZE);
173 mem_ptr2 =
174 ioremap(mem_base + THIRD_PAGE_GROUP_START, THIRD_PAGE_GROUP_SIZE);
175
176 if ((mem_ptr0 == 0UL) || (mem_ptr1 == 0UL) || (mem_ptr2 == 0UL)) {
177 DPRINTK(ERR,
178 "Cannot remap adapter memory aborting.:"
179 "0 -> %p, 1 -> %p, 2 -> %p\n",
180 mem_ptr0, mem_ptr1, mem_ptr2);
181
182 err = -EIO;
183 goto err_out_iounmap;
184 }
185 db_base = pci_resource_start(pdev, 4); /* doorbell is on bar 4 */
186 db_len = pci_resource_len(pdev, 4);
187
188 if (db_len == 0) {
189 printk(KERN_ERR "%s: doorbell is disabled\n",
190 netxen_nic_driver_name);
191 err = -EIO;
192 goto err_out_iounmap;
193 }
194 DPRINTK(INFO, "doorbell ioremap from %lx a size of %lx\n", db_base,
195 db_len);
196
197 db_ptr = ioremap(db_base, NETXEN_DB_MAPSIZE_BYTES);
198 if (db_ptr == 0UL) {
199 printk(KERN_ERR "%s: Failed to allocate doorbell map.",
200 netxen_nic_driver_name);
201 err = -EIO;
202 goto err_out_iounmap;
203 }
204 DPRINTK(INFO, "doorbell ioremaped at %p\n", db_ptr);
205
206/*
207 * Allocate a adapter structure which will manage all the initialization
208 * as well as the common resources for all ports...
209 * all the ports will have pointer to this adapter as well as Adapter
210 * will have pointers of all the ports structures.
211 */
212
213 /* One adapter structure for all 4 ports.... */
214 adapter = kzalloc(sizeof(struct netxen_adapter), GFP_KERNEL);
215 if (adapter == NULL) {
216 printk(KERN_ERR "%s: Could not allocate adapter memory:%d\n",
217 netxen_nic_driver_name,
218 (int)sizeof(struct netxen_adapter));
219 err = -ENOMEM;
220 goto err_out_dbunmap;
221 }
222
223 if (netxen_cards_found == 0) {
224 g_adapter = adapter;
225 }
226 adapter->max_tx_desc_count = MAX_CMD_DESCRIPTORS;
227 adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS;
228 adapter->max_jumbo_rx_desc_count = MAX_JUMBO_RCV_DESCRIPTORS;
229 adapter->max_lro_rx_desc_count = MAX_LRO_RCV_DESCRIPTORS;
230
231 pci_set_drvdata(pdev, adapter);
232
233 cmd_buf_arr = (struct netxen_cmd_buffer *)vmalloc(TX_RINGSIZE);
234 if (cmd_buf_arr == NULL) {
235 printk(KERN_ERR
236 "%s: Could not allocate cmd_buf_arr memory:%d\n",
237 netxen_nic_driver_name, (int)TX_RINGSIZE);
238 err = -ENOMEM;
239 goto err_out_free_adapter;
240 }
241 memset(cmd_buf_arr, 0, TX_RINGSIZE);
242
243 for (i = 0; i < MAX_RCV_CTX; ++i) {
244 recv_ctx = &adapter->recv_ctx[i];
245 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) {
246 rcv_desc = &recv_ctx->rcv_desc[ring];
247 switch (RCV_DESC_TYPE(ring)) {
248 case RCV_DESC_NORMAL:
249 rcv_desc->max_rx_desc_count =
250 adapter->max_rx_desc_count;
251 rcv_desc->flags = RCV_DESC_NORMAL;
252 rcv_desc->dma_size = RX_DMA_MAP_LEN;
253 rcv_desc->skb_size = MAX_RX_BUFFER_LENGTH;
254 break;
255
256 case RCV_DESC_JUMBO:
257 rcv_desc->max_rx_desc_count =
258 adapter->max_jumbo_rx_desc_count;
259 rcv_desc->flags = RCV_DESC_JUMBO;
260 rcv_desc->dma_size = RX_JUMBO_DMA_MAP_LEN;
261 rcv_desc->skb_size = MAX_RX_JUMBO_BUFFER_LENGTH;
262 break;
263
264 case RCV_RING_LRO:
265 rcv_desc->max_rx_desc_count =
266 adapter->max_lro_rx_desc_count;
267 rcv_desc->flags = RCV_DESC_LRO;
268 rcv_desc->dma_size = RX_LRO_DMA_MAP_LEN;
269 rcv_desc->skb_size = MAX_RX_LRO_BUFFER_LENGTH;
270 break;
271
272 }
273 rcv_desc->rx_buf_arr = (struct netxen_rx_buffer *)
274 vmalloc(RCV_BUFFSIZE);
275
276 if (rcv_desc->rx_buf_arr == NULL) {
277 printk(KERN_ERR "%s: Could not allocate"
278 "rcv_desc->rx_buf_arr memory:%d\n",
279 netxen_nic_driver_name,
280 (int)RCV_BUFFSIZE);
281 err = -ENOMEM;
282 goto err_out_free_rx_buffer;
283 }
284 memset(rcv_desc->rx_buf_arr, 0, RCV_BUFFSIZE);
285 }
286
287 }
288
289 adapter->cmd_buf_arr = cmd_buf_arr;
290 adapter->ahw.pci_base0 = mem_ptr0;
291 adapter->ahw.pci_base1 = mem_ptr1;
292 adapter->ahw.pci_base2 = mem_ptr2;
293 adapter->ahw.db_base = db_ptr;
294 adapter->ahw.db_len = db_len;
295 spin_lock_init(&adapter->tx_lock);
296 spin_lock_init(&adapter->lock);
297 netxen_initialize_adapter_sw(adapter); /* initialize the buffers in adapter */
298#ifdef CONFIG_IA64
299 netxen_pinit_from_rom(adapter, 0);
300 udelay(500);
301 netxen_load_firmware(adapter);
302#endif
303
304 /*
305 * Set the CRB window to invalid. If any register in window 0 is
306 * accessed it should set the window to 0 and then reset it to 1.
307 */
308 adapter->curr_window = 255;
309 /*
310 * Adapter in our case is quad port so initialize it before
311 * initializing the ports
312 */
313 netxen_initialize_adapter_hw(adapter); /* initialize the adapter */
314
315 netxen_initialize_adapter_ops(adapter);
316
317 init_timer(&adapter->watchdog_timer);
318 adapter->ahw.xg_linkup = 0;
319 adapter->watchdog_timer.function = &netxen_watchdog;
320 adapter->watchdog_timer.data = (unsigned long)adapter;
321 INIT_WORK(&adapter->watchdog_task, netxen_watchdog_task);
322 adapter->ahw.pdev = pdev;
323 adapter->proc_cmd_buf_counter = 0;
324 adapter->ahw.revision_id = nx_p2_id;
325
326 if (pci_enable_msi(pdev)) {
327 adapter->flags &= ~NETXEN_NIC_MSI_ENABLED;
328 printk(KERN_WARNING "%s: unable to allocate MSI interrupt"
329 " error\n", netxen_nic_driver_name);
330 } else
331 adapter->flags |= NETXEN_NIC_MSI_ENABLED;
332
333 if (netxen_is_flash_supported(adapter) == 0 &&
334 netxen_get_flash_mac_addr(adapter, mac_addr) == 0)
335 valid_mac = 1;
336 else
337 valid_mac = 0;
338
339 /*
340 * Initialize all the CRB registers here.
341 */
342 writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_CMD_PRODUCER_OFFSET));
343 writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_CMD_CONSUMER_OFFSET));
344 writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_HOST_CMD_ADDR_LO));
345
346 /* do this before waking up pegs so that we have valid dummy dma addr */
347 err = netxen_initialize_adapter_offload(adapter);
348 if (err) {
349 goto err_out_free_dev;
350 }
351
352 /* Unlock the HW, prompting the boot sequence */
353 writel(1,
354 NETXEN_CRB_NORMALIZE(adapter, NETXEN_ROMUSB_GLB_PEGTUNE_DONE));
355
356 /* Handshake with the card before we register the devices. */
357 netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE);
358
359 /* initialize the all the ports */
360 adapter->active_ports = 0;
361
362 for (i = 0; i < adapter->ahw.max_ports; i++) {
363 netdev = alloc_etherdev(sizeof(struct netxen_port));
364 if (!netdev) {
365 printk(KERN_ERR "%s: could not allocate netdev for port"
366 " %d\n", netxen_nic_driver_name, i + 1);
367 goto err_out_free_dev;
368 }
369
370 SET_MODULE_OWNER(netdev);
371 SET_NETDEV_DEV(netdev, &pdev->dev);
372
373 port = netdev_priv(netdev);
374 port->netdev = netdev;
375 port->pdev = pdev;
376 port->adapter = adapter;
377 port->portnum = i; /* Gigabit port number from 0-3 */
378
379 netdev->open = netxen_nic_open;
380 netdev->stop = netxen_nic_close;
381 netdev->hard_start_xmit = netxen_nic_xmit_frame;
382 netdev->get_stats = netxen_nic_get_stats;
383 netdev->set_multicast_list = netxen_nic_set_multi;
384 netdev->set_mac_address = netxen_nic_set_mac;
385 netdev->change_mtu = netxen_nic_change_mtu;
386 netdev->do_ioctl = netxen_nic_ioctl;
387 netdev->tx_timeout = netxen_tx_timeout;
388 netdev->watchdog_timeo = HZ;
389
390 SET_ETHTOOL_OPS(netdev, &netxen_nic_ethtool_ops);
391 netdev->poll = netxen_nic_poll;
392 netdev->weight = NETXEN_NETDEV_WEIGHT;
393#ifdef CONFIG_NET_POLL_CONTROLLER
394 netdev->poll_controller = netxen_nic_poll_controller;
395#endif
396 /* ScatterGather support */
397 netdev->features = NETIF_F_SG;
398 netdev->features |= NETIF_F_IP_CSUM;
399 netdev->features |= NETIF_F_TSO;
400
401 if (pci_using_dac)
402 netdev->features |= NETIF_F_HIGHDMA;
403
404 if (valid_mac) {
405 unsigned char *p = (unsigned char *)&mac_addr[i];
406 netdev->dev_addr[0] = *(p + 5);
407 netdev->dev_addr[1] = *(p + 4);
408 netdev->dev_addr[2] = *(p + 3);
409 netdev->dev_addr[3] = *(p + 2);
410 netdev->dev_addr[4] = *(p + 1);
411 netdev->dev_addr[5] = *(p + 0);
412
413 memcpy(netdev->perm_addr, netdev->dev_addr,
414 netdev->addr_len);
415 if (!is_valid_ether_addr(netdev->perm_addr)) {
416 printk(KERN_ERR "%s: Bad MAC address "
417 "%02x:%02x:%02x:%02x:%02x:%02x.\n",
418 netxen_nic_driver_name,
419 netdev->dev_addr[0],
420 netdev->dev_addr[1],
421 netdev->dev_addr[2],
422 netdev->dev_addr[3],
423 netdev->dev_addr[4],
424 netdev->dev_addr[5]);
425 } else {
426 if (adapter->macaddr_set)
427 adapter->macaddr_set(port,
428 netdev->dev_addr);
429 }
430 }
431 adapter->netdev = netdev;
432 INIT_WORK(&adapter->tx_timeout_task, netxen_tx_timeout_task);
433 netif_carrier_off(netdev);
434 netif_stop_queue(netdev);
435
436 if ((err = register_netdev(netdev))) {
437 printk(KERN_ERR "%s: register_netdev failed port #%d"
438 " aborting\n", netxen_nic_driver_name, i + 1);
439 err = -EIO;
440 free_netdev(netdev);
441 goto err_out_free_dev;
442 }
443 adapter->port_count++;
444 adapter->port[i] = port;
445 }
446
447 /*
448 * delay a while to ensure that the Pegs are up & running.
449 * Otherwise, we might see some flaky behaviour.
450 */
451 udelay(100);
452
453 switch (adapter->ahw.board_type) {
454 case NETXEN_NIC_GBE:
455 printk("%s: QUAD GbE board initialized\n",
456 netxen_nic_driver_name);
457 break;
458
459 case NETXEN_NIC_XGBE:
460 printk("%s: XGbE board initialized\n", netxen_nic_driver_name);
461 break;
462 }
463
464 adapter->number = netxen_cards_found;
465 adapter->driver_mismatch = 0;
466
467 return 0;
468
469 err_out_free_dev:
470 if (adapter->flags & NETXEN_NIC_MSI_ENABLED)
471 pci_disable_msi(pdev);
472 for (i = 0; i < adapter->port_count; i++) {
473 port = adapter->port[i];
474 if ((port) && (port->netdev)) {
475 unregister_netdev(port->netdev);
476 free_netdev(port->netdev);
477 }
478 }
479
480 netxen_free_adapter_offload(adapter);
481
482 err_out_free_rx_buffer:
483 for (i = 0; i < MAX_RCV_CTX; ++i) {
484 recv_ctx = &adapter->recv_ctx[i];
485 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) {
486 rcv_desc = &recv_ctx->rcv_desc[ring];
487 if (rcv_desc->rx_buf_arr != NULL) {
488 vfree(rcv_desc->rx_buf_arr);
489 rcv_desc->rx_buf_arr = NULL;
490 }
491 }
492 }
493 vfree(cmd_buf_arr);
494
495 err_out_free_adapter:
496 pci_set_drvdata(pdev, NULL);
497 kfree(adapter);
498
499 err_out_dbunmap:
500 if (db_ptr)
501 iounmap(db_ptr);
502
503 err_out_iounmap:
504 if (mem_ptr0)
505 iounmap(mem_ptr0);
506 if (mem_ptr1)
507 iounmap(mem_ptr1);
508 if (mem_ptr2)
509 iounmap(mem_ptr2);
510
511 err_out_free_res:
512 pci_release_regions(pdev);
513 err_out_disable_pdev:
514 pci_disable_device(pdev);
515 return err;
516}
517
518static void __devexit netxen_nic_remove(struct pci_dev *pdev)
519{
520 struct netxen_adapter *adapter;
521 struct netxen_port *port;
522 struct netxen_rx_buffer *buffer;
523 struct netxen_recv_context *recv_ctx;
524 struct netxen_rcv_desc_ctx *rcv_desc;
525 int i;
526 int ctxid, ring;
527
528 adapter = pci_get_drvdata(pdev);
529 if (adapter == NULL)
530 return;
531
532 netxen_nic_stop_all_ports(adapter);
533 /* leave the hw in the same state as reboot */
534 netxen_load_firmware(adapter);
535 netxen_free_adapter_offload(adapter);
536
537 udelay(500); /* Delay for a while to drain the DMA engines */
538 for (i = 0; i < adapter->port_count; i++) {
539 port = adapter->port[i];
540 if ((port) && (port->netdev)) {
541 unregister_netdev(port->netdev);
542 free_netdev(port->netdev);
543 }
544 }
545
546 if ((adapter->flags & NETXEN_NIC_MSI_ENABLED))
547 pci_disable_msi(pdev);
548 pci_set_drvdata(pdev, NULL);
549 if (adapter->is_up == NETXEN_ADAPTER_UP_MAGIC)
550 netxen_free_hw_resources(adapter);
551
552 iounmap(adapter->ahw.db_base);
553 iounmap(adapter->ahw.pci_base0);
554 iounmap(adapter->ahw.pci_base1);
555 iounmap(adapter->ahw.pci_base2);
556
557 pci_release_regions(pdev);
558 pci_disable_device(pdev);
559
560 for (ctxid = 0; ctxid < MAX_RCV_CTX; ++ctxid) {
561 recv_ctx = &adapter->recv_ctx[ctxid];
562 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) {
563 rcv_desc = &recv_ctx->rcv_desc[ring];
564 for (i = 0; i < rcv_desc->max_rx_desc_count; ++i) {
565 buffer = &(rcv_desc->rx_buf_arr[i]);
566 if (buffer->state == NETXEN_BUFFER_FREE)
567 continue;
568 pci_unmap_single(pdev, buffer->dma,
569 rcv_desc->dma_size,
570 PCI_DMA_FROMDEVICE);
571 if (buffer->skb != NULL)
572 dev_kfree_skb_any(buffer->skb);
573 }
574 vfree(rcv_desc->rx_buf_arr);
575 }
576 }
577
578 vfree(adapter->cmd_buf_arr);
579 kfree(adapter);
580}
581
582/*
583 * Called when a network interface is made active
584 * @returns 0 on success, negative value on failure
585 */
586static int netxen_nic_open(struct net_device *netdev)
587{
588 struct netxen_port *port = netdev_priv(netdev);
589 struct netxen_adapter *adapter = port->adapter;
590 int err = 0;
591 int ctx, ring;
592
593 if (adapter->is_up != NETXEN_ADAPTER_UP_MAGIC) {
594 err = netxen_init_firmware(adapter);
595 if (err != 0) {
596 printk(KERN_ERR "Failed to init firmware\n");
597 return -EIO;
598 }
599 netxen_nic_flash_print(adapter);
600 if (adapter->init_niu)
601 adapter->init_niu(adapter);
602
603 /* setup all the resources for the Phantom... */
604 /* this include the descriptors for rcv, tx, and status */
605 netxen_nic_clear_stats(adapter);
606 err = netxen_nic_hw_resources(adapter);
607 if (err) {
608 printk(KERN_ERR "Error in setting hw resources:%d\n",
609 err);
610 return err;
611 }
612 if (adapter->init_port
613 && adapter->init_port(adapter, port->portnum) != 0) {
614 printk(KERN_ERR "%s: Failed to initialize port %d\n",
615 netxen_nic_driver_name, port->portnum);
616 netxen_free_hw_resources(adapter);
617 return -EIO;
618 }
619 for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) {
620 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++)
621 netxen_post_rx_buffers(adapter, ctx, ring);
622 }
623 adapter->irq = adapter->ahw.pdev->irq;
624 err = request_irq(adapter->ahw.pdev->irq, &netxen_intr,
625 SA_SHIRQ | SA_SAMPLE_RANDOM, netdev->name,
626 adapter);
627 if (err) {
628 printk(KERN_ERR "request_irq failed with: %d\n", err);
629 netxen_free_hw_resources(adapter);
630 return err;
631 }
632
633 adapter->is_up = NETXEN_ADAPTER_UP_MAGIC;
634 }
635 adapter->active_ports++;
636 if (adapter->active_ports == 1) {
637 if (!adapter->driver_mismatch)
638 mod_timer(&adapter->watchdog_timer, jiffies);
639
640 netxen_nic_enable_int(adapter);
641 }
642
643 /* Done here again so that even if phantom sw overwrote it,
644 * we set it */
645 if (adapter->macaddr_set)
646 adapter->macaddr_set(port, netdev->dev_addr);
647 netxen_nic_set_link_parameters(port);
648
649 netxen_nic_set_multi(netdev);
650 if (adapter->set_mtu)
651 adapter->set_mtu(port, netdev->mtu);
652
653 if (!adapter->driver_mismatch)
654 netif_start_queue(netdev);
655
656 return 0;
657}
658
659/*
660 * netxen_nic_close - Disables a network interface entry point
661 */
662static int netxen_nic_close(struct net_device *netdev)
663{
664 struct netxen_port *port = netdev_priv(netdev);
665 struct netxen_adapter *adapter = port->adapter;
666 int i, j;
667 struct netxen_cmd_buffer *cmd_buff;
668 struct netxen_skb_frag *buffrag;
669
670 netif_carrier_off(netdev);
671 netif_stop_queue(netdev);
672
673 adapter->active_ports--;
674
675 if (!adapter->active_ports) {
676 netxen_nic_disable_int(adapter);
677 if (adapter->irq)
678 free_irq(adapter->irq, adapter);
679 cmd_buff = adapter->cmd_buf_arr;
680 for (i = 0; i < adapter->max_tx_desc_count; i++) {
681 buffrag = cmd_buff->frag_array;
682 if (buffrag->dma) {
683 pci_unmap_single(port->pdev, buffrag->dma,
684 buffrag->length,
685 PCI_DMA_TODEVICE);
686 buffrag->dma = (u64) NULL;
687 }
688 for (j = 0; j < cmd_buff->frag_count; j++) {
689 buffrag++;
690 if (buffrag->dma) {
691 pci_unmap_page(port->pdev,
692 buffrag->dma,
693 buffrag->length,
694 PCI_DMA_TODEVICE);
695 buffrag->dma = (u64) NULL;
696 }
697 }
698 /* Free the skb we received in netxen_nic_xmit_frame */
699 if (cmd_buff->skb) {
700 dev_kfree_skb_any(cmd_buff->skb);
701 cmd_buff->skb = NULL;
702 }
703 cmd_buff++;
704 }
705 FLUSH_SCHEDULED_WORK();
706 del_timer_sync(&adapter->watchdog_timer);
707 }
708
709 return 0;
710}
711
712static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
713{
714 struct netxen_port *port = netdev_priv(netdev);
715 struct netxen_adapter *adapter = port->adapter;
716 struct netxen_hardware_context *hw = &adapter->ahw;
717 unsigned int first_seg_len = skb->len - skb->data_len;
718 struct netxen_skb_frag *buffrag;
719 unsigned int i;
720
721 u32 producer = 0;
722 u32 saved_producer = 0;
723 struct cmd_desc_type0 *hwdesc;
724 int k;
725 struct netxen_cmd_buffer *pbuf = NULL;
726 static int dropped_packet = 0;
727 int frag_count;
728 u32 local_producer = 0;
729 u32 max_tx_desc_count = 0;
730 u32 last_cmd_consumer = 0;
731 int no_of_desc;
732
733 port->stats.xmitcalled++;
734 frag_count = skb_shinfo(skb)->nr_frags + 1;
735
736 if (unlikely(skb->len <= 0)) {
737 dev_kfree_skb_any(skb);
738 port->stats.badskblen++;
739 return NETDEV_TX_OK;
740 }
741
742 if (frag_count > MAX_BUFFERS_PER_CMD) {
743 printk("%s: %s netxen_nic_xmit_frame: frag_count (%d)"
744 "too large, can handle only %d frags\n",
745 netxen_nic_driver_name, netdev->name,
746 frag_count, MAX_BUFFERS_PER_CMD);
747 port->stats.txdropped++;
748 if ((++dropped_packet & 0xff) == 0xff)
749 printk("%s: %s droppped packets = %d\n",
750 netxen_nic_driver_name, netdev->name,
751 dropped_packet);
752
753 return NETDEV_TX_OK;
754 }
755
756 /*
757 * Everything is set up. Now, we just need to transmit it out.
758 * Note that we have to copy the contents of buffer over to
759 * right place. Later on, this can be optimized out by de-coupling the
760 * producer index from the buffer index.
761 */
762 retry_getting_window:
763 spin_lock_bh(&adapter->tx_lock);
764 if (adapter->total_threads == MAX_XMIT_PRODUCERS) {
765 spin_unlock_bh(&adapter->tx_lock);
766 /*
767 * Yield CPU
768 */
769 if (!in_atomic())
770 schedule();
771 else {
772 for (i = 0; i < 20; i++)
773 cpu_relax(); /*This a nop instr on i386 */
774 }
775 goto retry_getting_window;
776 }
777 local_producer = adapter->cmd_producer;
778 /* There 4 fragments per descriptor */
779 no_of_desc = (frag_count + 3) >> 2;
780 if (netdev->features & NETIF_F_TSO) {
781 if (skb_shinfo(skb)->gso_size > 0) {
782
783 no_of_desc++;
784 if (((skb->nh.iph)->ihl * sizeof(u32)) +
785 ((skb->h.th)->doff * sizeof(u32)) +
786 sizeof(struct ethhdr) >
787 (sizeof(struct cmd_desc_type0) - 2)) {
788 no_of_desc++;
789 }
790 }
791 }
792 k = adapter->cmd_producer;
793 max_tx_desc_count = adapter->max_tx_desc_count;
794 last_cmd_consumer = adapter->last_cmd_consumer;
795 if ((k + no_of_desc) >=
796 ((last_cmd_consumer <= k) ? last_cmd_consumer + max_tx_desc_count :
797 last_cmd_consumer)) {
798 port->stats.nocmddescriptor++;
799 DPRINTK(ERR, "No command descriptors available,"
800 " producer = %d, consumer = %d count=%llu,"
801 " dropping packet\n", producer,
802 adapter->last_cmd_consumer,
803 port->stats.nocmddescriptor);
804
805 netif_stop_queue(netdev);
806 port->flags |= NETXEN_NETDEV_STATUS;
807 spin_unlock_bh(&adapter->tx_lock);
808 return NETDEV_TX_BUSY;
809 }
810 k = get_index_range(k, max_tx_desc_count, no_of_desc);
811 adapter->cmd_producer = k;
812 adapter->total_threads++;
813 adapter->num_threads++;
814
815 spin_unlock_bh(&adapter->tx_lock);
816 /* Copy the descriptors into the hardware */
817 producer = local_producer;
818 saved_producer = producer;
819 hwdesc = &hw->cmd_desc_head[producer];
820 memset(hwdesc, 0, sizeof(struct cmd_desc_type0));
821 /* Take skb->data itself */
822 pbuf = &adapter->cmd_buf_arr[producer];
823 if ((netdev->features & NETIF_F_TSO) && skb_shinfo(skb)->gso_size > 0) {
824 pbuf->mss = skb_shinfo(skb)->gso_size;
825 hwdesc->mss = skb_shinfo(skb)->gso_size;
826 } else {
827 pbuf->mss = 0;
828 hwdesc->mss = 0;
829 }
830 pbuf->total_length = skb->len;
831 pbuf->skb = skb;
832 pbuf->cmd = TX_ETHER_PKT;
833 pbuf->frag_count = frag_count;
834 pbuf->port = port->portnum;
835 buffrag = &pbuf->frag_array[0];
836 buffrag->dma = pci_map_single(port->pdev, skb->data, first_seg_len,
837 PCI_DMA_TODEVICE);
838 buffrag->length = first_seg_len;
839 netxen_set_cmd_desc_totallength(hwdesc, skb->len);
840 netxen_set_cmd_desc_num_of_buff(hwdesc, frag_count);
841 netxen_set_cmd_desc_opcode(hwdesc, TX_ETHER_PKT);
842
843 netxen_set_cmd_desc_port(hwdesc, port->portnum);
844 hwdesc->buffer1_length = cpu_to_le16(first_seg_len);
845 hwdesc->addr_buffer1 = cpu_to_le64(buffrag->dma);
846
847 for (i = 1, k = 1; i < frag_count; i++, k++) {
848 struct skb_frag_struct *frag;
849 int len, temp_len;
850 unsigned long offset;
851 dma_addr_t temp_dma;
852
853 /* move to next desc. if there is a need */
854 if ((i & 0x3) == 0) {
855 k = 0;
856 producer = get_next_index(producer,
857 adapter->max_tx_desc_count);
858 hwdesc = &hw->cmd_desc_head[producer];
859 memset(hwdesc, 0, sizeof(struct cmd_desc_type0));
860 }
861 frag = &skb_shinfo(skb)->frags[i - 1];
862 len = frag->size;
863 offset = frag->page_offset;
864
865 temp_len = len;
866 temp_dma = pci_map_page(port->pdev, frag->page, offset,
867 len, PCI_DMA_TODEVICE);
868
869 buffrag++;
870 buffrag->dma = temp_dma;
871 buffrag->length = temp_len;
872
873 DPRINTK(INFO, "for loop. i=%d k=%d\n", i, k);
874 switch (k) {
875 case 0:
876 hwdesc->buffer1_length = cpu_to_le16(temp_len);
877 hwdesc->addr_buffer1 = cpu_to_le64(temp_dma);
878 break;
879 case 1:
880 hwdesc->buffer2_length = cpu_to_le16(temp_len);
881 hwdesc->addr_buffer2 = cpu_to_le64(temp_dma);
882 break;
883 case 2:
884 hwdesc->buffer3_length = cpu_to_le16(temp_len);
885 hwdesc->addr_buffer3 = cpu_to_le64(temp_dma);
886 break;
887 case 3:
888 hwdesc->buffer4_length = temp_len;
889 hwdesc->addr_buffer4 = cpu_to_le64(temp_dma);
890 break;
891 }
892 frag++;
893 }
894 producer = get_next_index(producer, adapter->max_tx_desc_count);
895
896 /* might change opcode to TX_TCP_LSO */
897 netxen_tso_check(adapter, &hw->cmd_desc_head[saved_producer], skb);
898
899 /* For LSO, we need to copy the MAC/IP/TCP headers into
900 * the descriptor ring
901 */
902 if (netxen_get_cmd_desc_opcode(&hw->cmd_desc_head[saved_producer])
903 == TX_TCP_LSO) {
904 int hdr_len, first_hdr_len, more_hdr;
905 hdr_len = hw->cmd_desc_head[saved_producer].total_hdr_length;
906 if (hdr_len > (sizeof(struct cmd_desc_type0) - 2)) {
907 first_hdr_len = sizeof(struct cmd_desc_type0) - 2;
908 more_hdr = 1;
909 } else {
910 first_hdr_len = hdr_len;
911 more_hdr = 0;
912 }
913 /* copy the MAC/IP/TCP headers to the cmd descriptor list */
914 hwdesc = &hw->cmd_desc_head[producer];
915
916 /* copy the first 64 bytes */
917 memcpy(((void *)hwdesc) + 2,
918 (void *)(skb->data), first_hdr_len);
919 producer = get_next_index(producer, max_tx_desc_count);
920
921 if (more_hdr) {
922 hwdesc = &hw->cmd_desc_head[producer];
923 /* copy the next 64 bytes - should be enough except
924 * for pathological case
925 */
926 memcpy((void *)hwdesc, (void *)(skb->data) +
927 first_hdr_len, hdr_len - first_hdr_len);
928 producer = get_next_index(producer, max_tx_desc_count);
929 }
930 }
931 spin_lock_bh(&adapter->tx_lock);
932 port->stats.txbytes +=
933 netxen_get_cmd_desc_totallength(&hw->cmd_desc_head[saved_producer]);
934 /* Code to update the adapter considering how many producer threads
935 are currently working */
936 if ((--adapter->num_threads) == 0) {
937 /* This is the last thread */
938 u32 crb_producer = adapter->cmd_producer;
939 writel(crb_producer,
940 NETXEN_CRB_NORMALIZE(adapter, CRB_CMD_PRODUCER_OFFSET));
941 wmb();
942 adapter->total_threads = 0;
943 }
944
945 port->stats.xmitfinished++;
946 spin_unlock_bh(&adapter->tx_lock);
947
948 netdev->trans_start = jiffies;
949
950 DPRINTK(INFO, "wrote CMD producer %x to phantom\n", producer);
951
952 DPRINTK(INFO, "Done. Send\n");
953 return NETDEV_TX_OK;
954}
955
956static void netxen_watchdog(unsigned long v)
957{
958 struct netxen_adapter *adapter = (struct netxen_adapter *)v;
959 if (adapter != g_adapter) {
960 printk("%s: ***BUG*** adapter[%p] != g_adapter[%p]\n",
961 __FUNCTION__, adapter, g_adapter);
962 return;
963 }
964
965 SCHEDULE_WORK(&adapter->watchdog_task);
966}
967
968static void netxen_tx_timeout(struct net_device *netdev)
969{
970 struct netxen_port *port = (struct netxen_port *)netdev_priv(netdev);
971
972 SCHEDULE_WORK(&port->adapter->tx_timeout_task);
973}
974
975static void netxen_tx_timeout_task(struct work_struct *work)
976{
977 struct netxen_adapter *adapter =
978 container_of(work, struct netxen_adapter, tx_timeout_task);
979 struct net_device *netdev = adapter->netdev;
980 unsigned long flags;
981
982 printk(KERN_ERR "%s %s: transmit timeout, resetting.\n",
983 netxen_nic_driver_name, netdev->name);
984
985 spin_lock_irqsave(&adapter->lock, flags);
986 netxen_nic_close(netdev);
987 netxen_nic_open(netdev);
988 spin_unlock_irqrestore(&adapter->lock, flags);
989 netdev->trans_start = jiffies;
990 netif_wake_queue(netdev);
991}
992
993static int
994netxen_handle_int(struct netxen_adapter *adapter, struct net_device *netdev)
995{
996 u32 ret = 0;
997
998 DPRINTK(INFO, "Entered handle ISR\n");
999
1000 adapter->stats.ints++;
1001
1002 if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) {
1003 int count = 0;
1004 u32 mask;
1005 mask = readl(pci_base_offset(adapter, ISR_INT_VECTOR));
1006 if ((mask & 0x80) == 0) {
1007 /* not our interrupt */
1008 return ret;
1009 }
1010 netxen_nic_disable_int(adapter);
1011 /* Window = 0 or 1 */
1012 do {
1013 writel(0xffffffff, PCI_OFFSET_SECOND_RANGE(adapter,
1014 ISR_INT_TARGET_STATUS));
1015 mask = readl(pci_base_offset(adapter, ISR_INT_VECTOR));
1016 } while (((mask & 0x80) != 0) && (++count < 32));
1017 if ((mask & 0x80) != 0)
1018 printk("Could not disable interrupt completely\n");
1019
1020 }
1021 adapter->stats.hostints++;
1022
1023 if (netxen_nic_rx_has_work(adapter) || netxen_nic_tx_has_work(adapter)) {
1024 if (netif_rx_schedule_prep(netdev)) {
1025 /*
1026 * Interrupts are already disabled.
1027 */
1028 __netif_rx_schedule(netdev);
1029 } else {
1030 static unsigned int intcount = 0;
1031 if ((++intcount & 0xfff) == 0xfff)
1032 printk(KERN_ERR
1033 "%s: %s interrupt %d while in poll\n",
1034 netxen_nic_driver_name, netdev->name,
1035 intcount);
1036 }
1037 ret = 1;
1038 }
1039
1040 if (ret == 0) {
1041 netxen_nic_enable_int(adapter);
1042 }
1043
1044 return ret;
1045}
1046
1047/*
1048 * netxen_intr - Interrupt Handler
1049 * @irq: interrupt number
1050 * data points to adapter stucture (which may be handling more than 1 port
1051 */
1052irqreturn_t netxen_intr(int irq, void *data)
1053{
1054 struct netxen_adapter *adapter;
1055 struct netxen_port *port;
1056 struct net_device *netdev;
1057 int i;
1058
1059 if (unlikely(!irq)) {
1060 return IRQ_NONE; /* Not our interrupt */
1061 }
1062
1063 adapter = (struct netxen_adapter *)data;
1064 for (i = 0; i < adapter->ahw.max_ports; i++) {
1065 port = adapter->port[i];
1066 netdev = port->netdev;
1067
1068 /* process our status queue (for all 4 ports) */
1069 if (netif_running(netdev)) {
1070 netxen_handle_int(adapter, netdev);
1071 break;
1072 }
1073 }
1074
1075 return IRQ_HANDLED;
1076}
1077
1078static int netxen_nic_poll(struct net_device *netdev, int *budget)
1079{
1080 struct netxen_port *port = (struct netxen_port *)netdev_priv(netdev);
1081 struct netxen_adapter *adapter = port->adapter;
1082 int work_to_do = min(*budget, netdev->quota);
1083 int done = 1;
1084 int ctx;
1085 int this_work_done;
1086 int work_done = 0;
1087
1088 DPRINTK(INFO, "polling for %d descriptors\n", *budget);
1089 port->stats.polled++;
1090
1091 work_done = 0;
1092 for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) {
1093 /*
1094 * Fairness issue. This will give undue weight to the
1095 * receive context 0.
1096 */
1097
1098 /*
1099 * To avoid starvation, we give each of our receivers,
1100 * a fraction of the quota. Sometimes, it might happen that we
1101 * have enough quota to process every packet, but since all the
1102 * packets are on one context, it gets only half of the quota,
1103 * and ends up not processing it.
1104 */
1105 this_work_done = netxen_process_rcv_ring(adapter, ctx,
1106 work_to_do /
1107 MAX_RCV_CTX);
1108 work_done += this_work_done;
1109 }
1110
1111 netdev->quota -= work_done;
1112 *budget -= work_done;
1113
1114 if (work_done >= work_to_do && netxen_nic_rx_has_work(adapter) != 0)
1115 done = 0;
1116
1117 if (netxen_process_cmd_ring((unsigned long)adapter) == 0)
1118 done = 0;
1119
1120 DPRINTK(INFO, "new work_done: %d work_to_do: %d\n",
1121 work_done, work_to_do);
1122 if (done) {
1123 netif_rx_complete(netdev);
1124 netxen_nic_enable_int(adapter);
1125 }
1126
1127 return !done;
1128}
1129
1130#ifdef CONFIG_NET_POLL_CONTROLLER
1131static void netxen_nic_poll_controller(struct net_device *netdev)
1132{
1133 struct netxen_port *port = netdev_priv(netdev);
1134 struct netxen_adapter *adapter = port->adapter;
1135 disable_irq(adapter->irq);
1136 netxen_intr(adapter->irq, adapter);
1137 enable_irq(adapter->irq);
1138}
1139#endif
1140/*
1141 * netxen_nic_ioctl () We provide the tcl/phanmon support through these
1142 * ioctls.
1143 */
1144static int
1145netxen_nic_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
1146{
1147 int err = 0;
1148 unsigned long nr_bytes = 0;
1149 struct netxen_port *port = netdev_priv(netdev);
1150 struct netxen_adapter *adapter = port->adapter;
1151 char dev_name[NETXEN_NIC_NAME_LEN];
1152
1153 DPRINTK(INFO, "doing ioctl for %s\n", netdev->name);
1154 switch (cmd) {
1155 case NETXEN_NIC_CMD:
1156 err = netxen_nic_do_ioctl(adapter, (void *)ifr->ifr_data, port);
1157 break;
1158
1159 case NETXEN_NIC_NAME:
1160 DPRINTK(INFO, "ioctl cmd for NetXen\n");
1161 if (ifr->ifr_data) {
1162 sprintf(dev_name, "%s-%d", NETXEN_NIC_NAME_RSP,
1163 port->portnum);
1164 nr_bytes =
1165 copy_to_user((char __user *)ifr->ifr_data, dev_name,
1166 NETXEN_NIC_NAME_LEN);
1167 if (nr_bytes)
1168 err = -EIO;
1169
1170 }
1171 break;
1172
1173 default:
1174 DPRINTK(INFO, "ioctl cmd %x not supported\n", cmd);
1175 err = -EOPNOTSUPP;
1176 break;
1177 }
1178
1179 return err;
1180}
1181
1182static struct pci_driver netxen_driver = {
1183 .name = netxen_nic_driver_name,
1184 .id_table = netxen_pci_tbl,
1185 .probe = netxen_nic_probe,
1186 .remove = __devexit_p(netxen_nic_remove)
1187};
1188
1189/* Driver Registration on NetXen card */
1190
1191static int __init netxen_init_module(void)
1192{
1193 if ((netxen_workq = create_singlethread_workqueue("netxen")) == 0)
1194 return -ENOMEM;
1195
1196 return pci_module_init(&netxen_driver);
1197}
1198
1199module_init(netxen_init_module);
1200
1201static void __exit netxen_exit_module(void)
1202{
1203 /*
1204 * Wait for some time to allow the dma to drain, if any.
1205 */
1206 destroy_workqueue(netxen_workq);
1207 pci_unregister_driver(&netxen_driver);
1208}
1209
1210module_exit(netxen_exit_module);
diff --git a/drivers/net/netxen/netxen_nic_niu.c b/drivers/net/netxen/netxen_nic_niu.c
new file mode 100644
index 000000000000..4987dc765d99
--- /dev/null
+++ b/drivers/net/netxen/netxen_nic_niu.c
@@ -0,0 +1,898 @@
1/*
2 * Copyright (C) 2003 - 2006 NetXen, Inc.
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 * MA 02111-1307, USA.
19 *
20 * The full GNU General Public License is included in this distribution
21 * in the file called LICENSE.
22 *
23 * Contact Information:
24 * info@netxen.com
25 * NetXen,
26 * 3965 Freedom Circle, Fourth floor,
27 * Santa Clara, CA 95054
28 *
29 *
30 * Provides access to the Network Interface Unit h/w block.
31 *
32 */
33
34#include "netxen_nic.h"
35
36#define NETXEN_GB_MAC_SOFT_RESET 0x80000000
37#define NETXEN_GB_MAC_RESET_PROT_BLK 0x000F0000
38#define NETXEN_GB_MAC_ENABLE_TX_RX 0x00000005
39#define NETXEN_GB_MAC_PAUSED_FRMS 0x00000020
40
41static long phy_lock_timeout = 100000000;
42
43static inline int phy_lock(struct netxen_adapter *adapter)
44{
45 int i;
46 int done = 0, timeout = 0;
47
48 while (!done) {
49 done =
50 readl(pci_base_offset
51 (adapter, NETXEN_PCIE_REG(PCIE_SEM3_LOCK)));
52 if (done == 1)
53 break;
54 if (timeout >= phy_lock_timeout) {
55 return -1;
56 }
57 timeout++;
58 if (!in_atomic())
59 schedule();
60 else {
61 for (i = 0; i < 20; i++)
62 cpu_relax();
63 }
64 }
65
66 writel(PHY_LOCK_DRIVER,
67 NETXEN_CRB_NORMALIZE(adapter, NETXEN_PHY_LOCK_ID));
68 return 0;
69}
70
71static inline int phy_unlock(struct netxen_adapter *adapter)
72{
73 readl(pci_base_offset(adapter, NETXEN_PCIE_REG(PCIE_SEM3_UNLOCK)));
74
75 return 0;
76}
77
78/*
79 * netxen_niu_gbe_phy_read - read a register from the GbE PHY via
80 * mii management interface.
81 *
82 * Note: The MII management interface goes through port 0.
83 * Individual phys are addressed as follows:
84 * @param phy [15:8] phy id
85 * @param reg [7:0] register number
86 *
87 * @returns 0 on success
88 * -1 on error
89 *
90 */
91int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long phy,
92 long reg, __le32 * readval)
93{
94 long timeout = 0;
95 long result = 0;
96 long restore = 0;
97 __le32 address;
98 __le32 command;
99 __le32 status;
100 __le32 mac_cfg0;
101
102 if (phy_lock(adapter) != 0) {
103 return -1;
104 }
105
106 /*
107 * MII mgmt all goes through port 0 MAC interface,
108 * so it cannot be in reset
109 */
110
111 if (netxen_nic_hw_read_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(0),
112 &mac_cfg0, 4))
113 return -EIO;
114 if (netxen_gb_get_soft_reset(mac_cfg0)) {
115 __le32 temp;
116 temp = 0;
117 netxen_gb_tx_reset_pb(temp);
118 netxen_gb_rx_reset_pb(temp);
119 netxen_gb_tx_reset_mac(temp);
120 netxen_gb_rx_reset_mac(temp);
121 if (netxen_nic_hw_write_wx(adapter,
122 NETXEN_NIU_GB_MAC_CONFIG_0(0),
123 &temp, 4))
124 return -EIO;
125 restore = 1;
126 }
127
128 address = 0;
129 netxen_gb_mii_mgmt_reg_addr(address, reg);
130 netxen_gb_mii_mgmt_phy_addr(address, phy);
131 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_ADDR(0),
132 &address, 4))
133 return -EIO;
134 command = 0; /* turn off any prior activity */
135 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_COMMAND(0),
136 &command, 4))
137 return -EIO;
138 /* send read command */
139 netxen_gb_mii_mgmt_set_read_cycle(command);
140 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_COMMAND(0),
141 &command, 4))
142 return -EIO;
143
144 status = 0;
145 do {
146 if (netxen_nic_hw_read_wx(adapter,
147 NETXEN_NIU_GB_MII_MGMT_INDICATE(0),
148 &status, 4))
149 return -EIO;
150 timeout++;
151 } while ((netxen_get_gb_mii_mgmt_busy(status)
152 || netxen_get_gb_mii_mgmt_notvalid(status))
153 && (timeout++ < NETXEN_NIU_PHY_WAITMAX));
154
155 if (timeout < NETXEN_NIU_PHY_WAITMAX) {
156 if (netxen_nic_hw_read_wx(adapter,
157 NETXEN_NIU_GB_MII_MGMT_STATUS(0),
158 readval, 4))
159 return -EIO;
160 result = 0;
161 } else
162 result = -1;
163
164 if (restore)
165 if (netxen_nic_hw_write_wx(adapter,
166 NETXEN_NIU_GB_MAC_CONFIG_0(0),
167 &mac_cfg0, 4))
168 return -EIO;
169 phy_unlock(adapter);
170 return result;
171}
172
173/*
174 * netxen_niu_gbe_phy_write - write a register to the GbE PHY via
175 * mii management interface.
176 *
177 * Note: The MII management interface goes through port 0.
178 * Individual phys are addressed as follows:
179 * @param phy [15:8] phy id
180 * @param reg [7:0] register number
181 *
182 * @returns 0 on success
183 * -1 on error
184 *
185 */
186int netxen_niu_gbe_phy_write(struct netxen_adapter *adapter,
187 long phy, long reg, __le32 val)
188{
189 long timeout = 0;
190 long result = 0;
191 long restore = 0;
192 __le32 address;
193 __le32 command;
194 __le32 status;
195 __le32 mac_cfg0;
196
197 /*
198 * MII mgmt all goes through port 0 MAC interface, so it
199 * cannot be in reset
200 */
201
202 if (netxen_nic_hw_read_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(0),
203 &mac_cfg0, 4))
204 return -EIO;
205 if (netxen_gb_get_soft_reset(mac_cfg0)) {
206 __le32 temp;
207 temp = 0;
208 netxen_gb_tx_reset_pb(temp);
209 netxen_gb_rx_reset_pb(temp);
210 netxen_gb_tx_reset_mac(temp);
211 netxen_gb_rx_reset_mac(temp);
212
213 if (netxen_nic_hw_write_wx(adapter,
214 NETXEN_NIU_GB_MAC_CONFIG_0(0),
215 &temp, 4))
216 return -EIO;
217 restore = 1;
218 }
219
220 command = 0; /* turn off any prior activity */
221 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_COMMAND(0),
222 &command, 4))
223 return -EIO;
224
225 address = 0;
226 netxen_gb_mii_mgmt_reg_addr(address, reg);
227 netxen_gb_mii_mgmt_phy_addr(address, phy);
228 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_ADDR(0),
229 &address, 4))
230 return -EIO;
231
232 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_CTRL(0),
233 &val, 4))
234 return -EIO;
235
236 status = 0;
237 do {
238 if (netxen_nic_hw_read_wx(adapter,
239 NETXEN_NIU_GB_MII_MGMT_INDICATE(0),
240 &status, 4))
241 return -EIO;
242 timeout++;
243 } while ((netxen_get_gb_mii_mgmt_busy(status))
244 && (timeout++ < NETXEN_NIU_PHY_WAITMAX));
245
246 if (timeout < NETXEN_NIU_PHY_WAITMAX)
247 result = 0;
248 else
249 result = -EIO;
250
251 /* restore the state of port 0 MAC in case we tampered with it */
252 if (restore)
253 if (netxen_nic_hw_write_wx(adapter,
254 NETXEN_NIU_GB_MAC_CONFIG_0(0),
255 &mac_cfg0, 4))
256 return -EIO;
257
258 return result;
259}
260
261int netxen_niu_xgbe_enable_phy_interrupts(struct netxen_adapter *adapter,
262 int port)
263{
264 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_INT_MASK, 0x3f);
265 return 0;
266}
267
268int netxen_niu_gbe_enable_phy_interrupts(struct netxen_adapter *adapter,
269 int port)
270{
271 int result = 0;
272 __le32 enable = 0;
273 netxen_set_phy_int_link_status_changed(enable);
274 netxen_set_phy_int_autoneg_completed(enable);
275 netxen_set_phy_int_speed_changed(enable);
276
277 if (0 !=
278 netxen_niu_gbe_phy_write(adapter, port,
279 NETXEN_NIU_GB_MII_MGMT_ADDR_INT_ENABLE,
280 enable))
281 result = -EIO;
282
283 return result;
284}
285
286int netxen_niu_xgbe_disable_phy_interrupts(struct netxen_adapter *adapter,
287 int port)
288{
289 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_INT_MASK, 0x7f);
290 return 0;
291}
292
293int netxen_niu_gbe_disable_phy_interrupts(struct netxen_adapter *adapter,
294 int port)
295{
296 int result = 0;
297 if (0 !=
298 netxen_niu_gbe_phy_write(adapter, port,
299 NETXEN_NIU_GB_MII_MGMT_ADDR_INT_ENABLE, 0))
300 result = -EIO;
301
302 return result;
303}
304
305int netxen_niu_xgbe_clear_phy_interrupts(struct netxen_adapter *adapter,
306 int port)
307{
308 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_ACTIVE_INT, -1);
309 return 0;
310}
311
312int netxen_niu_gbe_clear_phy_interrupts(struct netxen_adapter *adapter,
313 int port)
314{
315 int result = 0;
316 if (0 !=
317 netxen_niu_gbe_phy_write(adapter, port,
318 NETXEN_NIU_GB_MII_MGMT_ADDR_INT_STATUS,
319 -EIO))
320 result = -EIO;
321
322 return result;
323}
324
325/*
326 * netxen_niu_gbe_set_mii_mode- Set 10/100 Mbit Mode for GbE MAC
327 *
328 */
329void netxen_niu_gbe_set_mii_mode(struct netxen_adapter *adapter,
330 int port, long enable)
331{
332 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_MODE, 0x2);
333 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
334 0x80000000);
335 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
336 0x0000f0025);
337 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB_MAC_CONFIG_1(port),
338 0xf1ff);
339 netxen_crb_writelit_adapter(adapter,
340 NETXEN_NIU_GB0_GMII_MODE + (port << 3), 0);
341 netxen_crb_writelit_adapter(adapter,
342 NETXEN_NIU_GB0_MII_MODE + (port << 3), 1);
343 netxen_crb_writelit_adapter(adapter,
344 (NETXEN_NIU_GB0_HALF_DUPLEX + port * 4), 0);
345 netxen_crb_writelit_adapter(adapter,
346 NETXEN_NIU_GB_MII_MGMT_CONFIG(port), 0x7);
347
348 if (enable) {
349 /*
350 * Do NOT enable flow control until a suitable solution for
351 * shutting down pause frames is found.
352 */
353 netxen_crb_writelit_adapter(adapter,
354 NETXEN_NIU_GB_MAC_CONFIG_0(port),
355 0x5);
356 }
357
358 if (netxen_niu_gbe_enable_phy_interrupts(adapter, port))
359 printk(KERN_ERR PFX "ERROR enabling PHY interrupts\n");
360 if (netxen_niu_gbe_clear_phy_interrupts(adapter, port))
361 printk(KERN_ERR PFX "ERROR clearing PHY interrupts\n");
362}
363
364/*
365 * netxen_niu_gbe_set_gmii_mode- Set GbE Mode for GbE MAC
366 */
367void netxen_niu_gbe_set_gmii_mode(struct netxen_adapter *adapter,
368 int port, long enable)
369{
370 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_MODE, 0x2);
371 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
372 0x80000000);
373 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
374 0x0000f0025);
375 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB_MAC_CONFIG_1(port),
376 0xf2ff);
377 netxen_crb_writelit_adapter(adapter,
378 NETXEN_NIU_GB0_MII_MODE + (port << 3), 0);
379 netxen_crb_writelit_adapter(adapter,
380 NETXEN_NIU_GB0_GMII_MODE + (port << 3), 1);
381 netxen_crb_writelit_adapter(adapter,
382 (NETXEN_NIU_GB0_HALF_DUPLEX + port * 4), 0);
383 netxen_crb_writelit_adapter(adapter,
384 NETXEN_NIU_GB_MII_MGMT_CONFIG(port), 0x7);
385
386 if (enable) {
387 /*
388 * Do NOT enable flow control until a suitable solution for
389 * shutting down pause frames is found.
390 */
391 netxen_crb_writelit_adapter(adapter,
392 NETXEN_NIU_GB_MAC_CONFIG_0(port),
393 0x5);
394 }
395
396 if (netxen_niu_gbe_enable_phy_interrupts(adapter, port))
397 printk(KERN_ERR PFX "ERROR enabling PHY interrupts\n");
398 if (netxen_niu_gbe_clear_phy_interrupts(adapter, port))
399 printk(KERN_ERR PFX "ERROR clearing PHY interrupts\n");
400}
401
402int netxen_niu_gbe_init_port(struct netxen_adapter *adapter, int port)
403{
404 int result = 0;
405 __le32 status;
406 if (adapter->disable_phy_interrupts)
407 adapter->disable_phy_interrupts(adapter, port);
408 mdelay(2);
409
410 if (0 ==
411 netxen_niu_gbe_phy_read(adapter, port,
412 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
413 (__le32 *) & status)) {
414 if (netxen_get_phy_link(status)) {
415 if (netxen_get_phy_speed(status) == 2) {
416 netxen_niu_gbe_set_gmii_mode(adapter, port, 1);
417 } else if ((netxen_get_phy_speed(status) == 1)
418 || (netxen_get_phy_speed(status) == 0)) {
419 netxen_niu_gbe_set_mii_mode(adapter, port, 1);
420 } else {
421 result = -1;
422 }
423
424 } else {
425 /*
426 * We don't have link. Cable must be unconnected.
427 * Enable phy interrupts so we take action when
428 * plugged in.
429 */
430
431 netxen_crb_writelit_adapter(adapter,
432 NETXEN_NIU_GB_MAC_CONFIG_0
433 (port),
434 NETXEN_GB_MAC_SOFT_RESET);
435 netxen_crb_writelit_adapter(adapter,
436 NETXEN_NIU_GB_MAC_CONFIG_0
437 (port),
438 NETXEN_GB_MAC_RESET_PROT_BLK
439 | NETXEN_GB_MAC_ENABLE_TX_RX
440 |
441 NETXEN_GB_MAC_PAUSED_FRMS);
442 if (netxen_niu_gbe_clear_phy_interrupts(adapter, port))
443 printk(KERN_ERR PFX
444 "ERROR clearing PHY interrupts\n");
445 if (netxen_niu_gbe_enable_phy_interrupts(adapter, port))
446 printk(KERN_ERR PFX
447 "ERROR enabling PHY interrupts\n");
448 if (netxen_niu_gbe_clear_phy_interrupts(adapter, port))
449 printk(KERN_ERR PFX
450 "ERROR clearing PHY interrupts\n");
451 result = -1;
452 }
453 } else {
454 result = -EIO;
455 }
456 return result;
457}
458
459int netxen_niu_xg_init_port(struct netxen_adapter *adapter, int port)
460{
461 long reg = 0, ret = 0;
462
463 if (adapter->ahw.boardcfg.board_type == NETXEN_BRDTYPE_P2_SB31_10G_IMEZ) {
464 netxen_crb_writelit_adapter(adapter,
465 NETXEN_NIU_XG1_CONFIG_0, 0x5);
466 /* XXX hack for Mez cards: both ports in promisc mode */
467 netxen_nic_hw_read_wx(adapter,
468 NETXEN_NIU_XGE_CONFIG_1, &reg, 4);
469 reg = (reg | 0x2000UL);
470 netxen_crb_writelit_adapter(adapter,
471 NETXEN_NIU_XGE_CONFIG_1, reg);
472 reg = 0;
473 netxen_nic_hw_read_wx(adapter,
474 NETXEN_NIU_XG1_CONFIG_1, &reg, 4);
475 reg = (reg | 0x2000UL);
476 netxen_crb_writelit_adapter(adapter,
477 NETXEN_NIU_XG1_CONFIG_1, reg);
478 }
479
480 return ret;
481}
482
483/*
484 * netxen_niu_gbe_handle_phy_interrupt - Handles GbE PHY interrupts
485 * @param enable 0 means don't enable the port
486 * 1 means enable (or re-enable) the port
487 */
488int netxen_niu_gbe_handle_phy_interrupt(struct netxen_adapter *adapter,
489 int port, long enable)
490{
491 int result = 0;
492 __le32 int_src;
493
494 printk(KERN_INFO PFX "NETXEN: Handling PHY interrupt on port %d"
495 " (device enable = %d)\n", (int)port, (int)enable);
496
497 /*
498 * The read of the PHY INT status will clear the pending
499 * interrupt status
500 */
501 if (netxen_niu_gbe_phy_read(adapter, port,
502 NETXEN_NIU_GB_MII_MGMT_ADDR_INT_STATUS,
503 &int_src) != 0)
504 result = -EINVAL;
505 else {
506 printk(KERN_INFO PFX "PHY Interrupt source = 0x%x \n", int_src);
507 if (netxen_get_phy_int_jabber(int_src))
508 printk(KERN_INFO PFX "jabber Interrupt ");
509 if (netxen_get_phy_int_polarity_changed(int_src))
510 printk(KERN_INFO PFX "polarity changed ");
511 if (netxen_get_phy_int_energy_detect(int_src))
512 printk(KERN_INFO PFX "energy detect \n");
513 if (netxen_get_phy_int_downshift(int_src))
514 printk(KERN_INFO PFX "downshift \n");
515 if (netxen_get_phy_int_mdi_xover_changed(int_src))
516 printk(KERN_INFO PFX "mdi_xover_changed ");
517 if (netxen_get_phy_int_fifo_over_underflow(int_src))
518 printk(KERN_INFO PFX "fifo_over_underflow ");
519 if (netxen_get_phy_int_false_carrier(int_src))
520 printk(KERN_INFO PFX "false_carrier ");
521 if (netxen_get_phy_int_symbol_error(int_src))
522 printk(KERN_INFO PFX "symbol_error ");
523 if (netxen_get_phy_int_autoneg_completed(int_src))
524 printk(KERN_INFO PFX "autoneg_completed ");
525 if (netxen_get_phy_int_page_received(int_src))
526 printk(KERN_INFO PFX "page_received ");
527 if (netxen_get_phy_int_duplex_changed(int_src))
528 printk(KERN_INFO PFX "duplex_changed ");
529 if (netxen_get_phy_int_autoneg_error(int_src))
530 printk(KERN_INFO PFX "autoneg_error ");
531 if ((netxen_get_phy_int_speed_changed(int_src))
532 || (netxen_get_phy_int_link_status_changed(int_src))) {
533 __le32 status;
534
535 printk(KERN_INFO PFX
536 "speed_changed or link status changed");
537 if (netxen_niu_gbe_phy_read
538 (adapter, port,
539 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
540 &status) == 0) {
541 if (netxen_get_phy_speed(status) == 2) {
542 printk
543 (KERN_INFO PFX "Link speed changed"
544 " to 1000 Mbps\n");
545 netxen_niu_gbe_set_gmii_mode(adapter,
546 port,
547 enable);
548 } else if (netxen_get_phy_speed(status) == 1) {
549 printk
550 (KERN_INFO PFX "Link speed changed"
551 " to 100 Mbps\n");
552 netxen_niu_gbe_set_mii_mode(adapter,
553 port,
554 enable);
555 } else if (netxen_get_phy_speed(status) == 0) {
556 printk
557 (KERN_INFO PFX "Link speed changed"
558 " to 10 Mbps\n");
559 netxen_niu_gbe_set_mii_mode(adapter,
560 port,
561 enable);
562 } else {
563 printk(KERN_ERR PFX "ERROR reading"
564 "PHY status. Illegal speed.\n");
565 result = -1;
566 }
567 } else {
568 printk(KERN_ERR PFX
569 "ERROR reading PHY status.\n");
570 result = -1;
571 }
572
573 }
574 printk(KERN_INFO "\n");
575 }
576 return result;
577}
578
579/*
580 * Return the current station MAC address.
581 * Note that the passed-in value must already be in network byte order.
582 */
583int netxen_niu_macaddr_get(struct netxen_adapter *adapter,
584 int phy, netxen_ethernet_macaddr_t * addr)
585{
586 u64 result = 0;
587 __le32 stationhigh;
588 __le32 stationlow;
589
590 if (addr == NULL)
591 return -EINVAL;
592 if ((phy < 0) || (phy > 3))
593 return -EINVAL;
594
595 if (netxen_nic_hw_read_wx(adapter, NETXEN_NIU_GB_STATION_ADDR_0(phy),
596 &stationhigh, 4))
597 return -EIO;
598 if (netxen_nic_hw_read_wx(adapter, NETXEN_NIU_GB_STATION_ADDR_1(phy),
599 &stationlow, 4))
600 return -EIO;
601
602 result = (u64) netxen_gb_get_stationaddress_low(stationlow);
603 result |= (u64) stationhigh << 16;
604 memcpy(*addr, &result, sizeof(netxen_ethernet_macaddr_t));
605
606 return 0;
607}
608
609/*
610 * Set the station MAC address.
611 * Note that the passed-in value must already be in network byte order.
612 */
613int netxen_niu_macaddr_set(struct netxen_port *port,
614 netxen_ethernet_macaddr_t addr)
615{
616 __le32 temp = 0;
617 struct netxen_adapter *adapter = port->adapter;
618 int phy = port->portnum;
619 unsigned char mac_addr[6];
620 int i;
621
622 for (i = 0; i < 10; i++) {
623 memcpy(&temp, addr, 2);
624 temp <<= 16;
625 if (netxen_nic_hw_write_wx
626 (adapter, NETXEN_NIU_GB_STATION_ADDR_1(phy), &temp, 4))
627 return -EIO;
628
629 temp = 0;
630
631 memcpy(&temp, ((u8 *) addr) + 2, sizeof(__le32));
632 if (netxen_nic_hw_write_wx
633 (adapter, NETXEN_NIU_GB_STATION_ADDR_0(phy), &temp, 4))
634 return -2;
635
636 netxen_niu_macaddr_get(adapter, phy,
637 (netxen_ethernet_macaddr_t *) mac_addr);
638 if (memcmp(mac_addr, addr, 6) == 0)
639 break;
640 }
641
642 if (i == 10) {
643 printk(KERN_ERR "%s: cannot set Mac addr for %s\n",
644 netxen_nic_driver_name, port->netdev->name);
645 printk(KERN_ERR "MAC address set: "
646 "%02x:%02x:%02x:%02x:%02x:%02x.\n",
647 addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
648
649 printk(KERN_ERR "MAC address get: "
650 "%02x:%02x:%02x:%02x:%02x:%02x.\n",
651 mac_addr[0],
652 mac_addr[1],
653 mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]);
654 }
655 return 0;
656}
657
658/* Enable a GbE interface */
659int netxen_niu_enable_gbe_port(struct netxen_adapter *adapter,
660 int port, netxen_niu_gbe_ifmode_t mode)
661{
662 __le32 mac_cfg0;
663 __le32 mac_cfg1;
664 __le32 mii_cfg;
665
666 if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS))
667 return -EINVAL;
668
669 mac_cfg0 = 0;
670 netxen_gb_soft_reset(mac_cfg0);
671 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
672 &mac_cfg0, 4))
673 return -EIO;
674 mac_cfg0 = 0;
675 netxen_gb_enable_tx(mac_cfg0);
676 netxen_gb_enable_rx(mac_cfg0);
677 netxen_gb_unset_rx_flowctl(mac_cfg0);
678 netxen_gb_tx_reset_pb(mac_cfg0);
679 netxen_gb_rx_reset_pb(mac_cfg0);
680 netxen_gb_tx_reset_mac(mac_cfg0);
681 netxen_gb_rx_reset_mac(mac_cfg0);
682
683 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
684 &mac_cfg0, 4))
685 return -EIO;
686 mac_cfg1 = 0;
687 netxen_gb_set_preamblelen(mac_cfg1, 0xf);
688 netxen_gb_set_duplex(mac_cfg1);
689 netxen_gb_set_crc_enable(mac_cfg1);
690 netxen_gb_set_padshort(mac_cfg1);
691 netxen_gb_set_checklength(mac_cfg1);
692 netxen_gb_set_hugeframes(mac_cfg1);
693
694 if (mode == NETXEN_NIU_10_100_MB) {
695 netxen_gb_set_intfmode(mac_cfg1, 1);
696 if (netxen_nic_hw_write_wx(adapter,
697 NETXEN_NIU_GB_MAC_CONFIG_1(port),
698 &mac_cfg1, 4))
699 return -EIO;
700
701 /* set mii mode */
702 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB0_GMII_MODE +
703 (port << 3), 0);
704 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB0_MII_MODE +
705 (port << 3), 1);
706
707 } else if (mode == NETXEN_NIU_1000_MB) {
708 netxen_gb_set_intfmode(mac_cfg1, 2);
709 if (netxen_nic_hw_write_wx(adapter,
710 NETXEN_NIU_GB_MAC_CONFIG_1(port),
711 &mac_cfg1, 4))
712 return -EIO;
713 /* set gmii mode */
714 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB0_MII_MODE +
715 (port << 3), 0);
716 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB0_GMII_MODE +
717 (port << 3), 1);
718 }
719 mii_cfg = 0;
720 netxen_gb_set_mii_mgmt_clockselect(mii_cfg, 7);
721 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_CONFIG(port),
722 &mii_cfg, 4))
723 return -EIO;
724 mac_cfg0 = 0;
725 netxen_gb_enable_tx(mac_cfg0);
726 netxen_gb_enable_rx(mac_cfg0);
727 netxen_gb_unset_rx_flowctl(mac_cfg0);
728 netxen_gb_unset_tx_flowctl(mac_cfg0);
729
730 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
731 &mac_cfg0, 4))
732 return -EIO;
733 return 0;
734}
735
736/* Disable a GbE interface */
737int netxen_niu_disable_gbe_port(struct netxen_adapter *adapter, int port)
738{
739 __le32 mac_cfg0;
740
741 if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS))
742 return -EINVAL;
743
744 mac_cfg0 = 0;
745 netxen_gb_soft_reset(mac_cfg0);
746 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
747 &mac_cfg0, 4))
748 return -EIO;
749 return 0;
750}
751
752/* Disable an XG interface */
753int netxen_niu_disable_xg_port(struct netxen_adapter *adapter, int port)
754{
755 __le32 mac_cfg;
756
757 if (port != 0)
758 return -EINVAL;
759
760 mac_cfg = 0;
761 netxen_xg_soft_reset(mac_cfg);
762 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_XGE_CONFIG_0,
763 &mac_cfg, 4))
764 return -EIO;
765 return 0;
766}
767
768/* Set promiscuous mode for a GbE interface */
769int netxen_niu_set_promiscuous_mode(struct netxen_adapter *adapter, int port,
770 netxen_niu_prom_mode_t mode)
771{
772 __le32 reg;
773
774 if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS))
775 return -EINVAL;
776
777 /* save previous contents */
778 if (netxen_nic_hw_read_wx(adapter, NETXEN_NIU_GB_DROP_WRONGADDR,
779 &reg, 4))
780 return -EIO;
781 if (mode == NETXEN_NIU_PROMISC_MODE) {
782 switch (port) {
783 case 0:
784 netxen_clear_gb_drop_gb0(reg);
785 break;
786 case 1:
787 netxen_clear_gb_drop_gb1(reg);
788 break;
789 case 2:
790 netxen_clear_gb_drop_gb2(reg);
791 break;
792 case 3:
793 netxen_clear_gb_drop_gb3(reg);
794 break;
795 default:
796 return -EIO;
797 }
798 } else {
799 switch (port) {
800 case 0:
801 netxen_set_gb_drop_gb0(reg);
802 break;
803 case 1:
804 netxen_set_gb_drop_gb1(reg);
805 break;
806 case 2:
807 netxen_set_gb_drop_gb2(reg);
808 break;
809 case 3:
810 netxen_set_gb_drop_gb3(reg);
811 break;
812 default:
813 return -EIO;
814 }
815 }
816 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_DROP_WRONGADDR,
817 &reg, 4))
818 return -EIO;
819 return 0;
820}
821
822/*
823 * Set the MAC address for an XG port
824 * Note that the passed-in value must already be in network byte order.
825 */
826int netxen_niu_xg_macaddr_set(struct netxen_port *port,
827 netxen_ethernet_macaddr_t addr)
828{
829 __le32 temp = 0;
830 struct netxen_adapter *adapter = port->adapter;
831
832 memcpy(&temp, addr, 2);
833 temp = cpu_to_le32(temp);
834 temp <<= 16;
835 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_XGE_STATION_ADDR_0_1,
836 &temp, 4))
837 return -EIO;
838
839 temp = 0;
840
841 memcpy(&temp, ((u8 *) addr) + 2, sizeof(__le32));
842 temp = cpu_to_le32(temp);
843 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_XGE_STATION_ADDR_0_HI,
844 &temp, 4))
845 return -EIO;
846
847 return 0;
848}
849
850/*
851 * Return the current station MAC address.
852 * Note that the passed-in value must already be in network byte order.
853 */
854int netxen_niu_xg_macaddr_get(struct netxen_adapter *adapter, int phy,
855 netxen_ethernet_macaddr_t * addr)
856{
857 __le32 stationhigh;
858 __le32 stationlow;
859 u64 result;
860
861 if (addr == NULL)
862 return -EINVAL;
863 if (phy != 0)
864 return -EINVAL;
865
866 if (netxen_nic_hw_read_wx(adapter, NETXEN_NIU_XGE_STATION_ADDR_0_HI,
867 &stationhigh, 4))
868 return -EIO;
869 if (netxen_nic_hw_read_wx(adapter, NETXEN_NIU_XGE_STATION_ADDR_0_1,
870 &stationlow, 4))
871 return -EIO;
872
873 result = ((u64) stationlow) >> 16;
874 result |= (u64) stationhigh << 16;
875 memcpy(*addr, &result, sizeof(netxen_ethernet_macaddr_t));
876
877 return 0;
878}
879
880int netxen_niu_xg_set_promiscuous_mode(struct netxen_adapter *adapter,
881 int port, netxen_niu_prom_mode_t mode)
882{
883 __le32 reg;
884
885 if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS))
886 return -EINVAL;
887
888 if (netxen_nic_hw_read_wx(adapter, NETXEN_NIU_XGE_CONFIG_1, &reg, 4))
889 return -EIO;
890 if (mode == NETXEN_NIU_PROMISC_MODE)
891 reg = (reg | 0x2000UL);
892 else
893 reg = (reg & ~0x2000UL);
894
895 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_XGE_CONFIG_1, reg);
896
897 return 0;
898}
diff --git a/drivers/net/netxen/netxen_nic_phan_reg.h b/drivers/net/netxen/netxen_nic_phan_reg.h
new file mode 100644
index 000000000000..7879f855af0b
--- /dev/null
+++ b/drivers/net/netxen/netxen_nic_phan_reg.h
@@ -0,0 +1,271 @@
1/*
2 * Copyright (C) 2003 - 2006 NetXen, Inc.
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 * MA 02111-1307, USA.
19 *
20 * The full GNU General Public License is included in this distribution
21 * in the file called LICENSE.
22 *
23 * Contact Information:
24 * info@netxen.com
25 * NetXen,
26 * 3965 Freedom Circle, Fourth floor,
27 * Santa Clara, CA 95054
28 */
29
30#ifndef __NIC_PHAN_REG_H_
31#define __NIC_PHAN_REG_H_
32
33/*
34 * CRB Registers or queue message done only at initialization time.
35 */
36#define NIC_CRB_BASE NETXEN_CAM_RAM(0x200)
37#define NETXEN_NIC_REG(X) (NIC_CRB_BASE+(X))
38
39#define CRB_PHAN_CNTRL_LO_OFFSET NETXEN_NIC_REG(0x00)
40#define CRB_PHAN_CNTRL_HI_OFFSET NETXEN_NIC_REG(0x04)
41#define CRB_CMD_PRODUCER_OFFSET NETXEN_NIC_REG(0x08)
42#define CRB_CMD_CONSUMER_OFFSET NETXEN_NIC_REG(0x0c)
43#define CRB_PAUSE_ADDR_LO NETXEN_NIC_REG(0x10) /* C0 EPG BUG */
44#define CRB_PAUSE_ADDR_HI NETXEN_NIC_REG(0x14)
45#define CRB_HOST_CMD_ADDR_HI NETXEN_NIC_REG(0x18) /* host add:cmd ring */
46#define CRB_HOST_CMD_ADDR_LO NETXEN_NIC_REG(0x1c)
47#define CRB_CMD_INTR_LOOP NETXEN_NIC_REG(0x20) /* 4 regs for perf */
48#define CRB_CMD_DMA_LOOP NETXEN_NIC_REG(0x24)
49#define CRB_RCV_INTR_LOOP NETXEN_NIC_REG(0x28)
50#define CRB_RCV_DMA_LOOP NETXEN_NIC_REG(0x2c)
51#define CRB_ENABLE_TX_INTR NETXEN_NIC_REG(0x30) /* phantom init status */
52#define CRB_MMAP_ADDR_3 NETXEN_NIC_REG(0x34)
53#define CRB_CMDPEG_CMDRING NETXEN_NIC_REG(0x38)
54#define CRB_HOST_DUMMY_BUF_ADDR_HI NETXEN_NIC_REG(0x3c)
55#define CRB_HOST_DUMMY_BUF_ADDR_LO NETXEN_NIC_REG(0x40)
56#define CRB_MMAP_ADDR_0 NETXEN_NIC_REG(0x44)
57#define CRB_MMAP_ADDR_1 NETXEN_NIC_REG(0x48)
58#define CRB_MMAP_ADDR_2 NETXEN_NIC_REG(0x4c)
59#define CRB_CMDPEG_STATE NETXEN_NIC_REG(0x50)
60#define CRB_MMAP_SIZE_0 NETXEN_NIC_REG(0x54)
61#define CRB_MMAP_SIZE_1 NETXEN_NIC_REG(0x58)
62#define CRB_MMAP_SIZE_2 NETXEN_NIC_REG(0x5c)
63#define CRB_MMAP_SIZE_3 NETXEN_NIC_REG(0x60)
64#define CRB_GLOBAL_INT_COAL NETXEN_NIC_REG(0x64) /* interrupt coalescing */
65#define CRB_INT_COAL_MODE NETXEN_NIC_REG(0x68)
66#define CRB_MAX_RCV_BUFS NETXEN_NIC_REG(0x6c)
67#define CRB_TX_INT_THRESHOLD NETXEN_NIC_REG(0x70)
68#define CRB_RX_PKT_TIMER NETXEN_NIC_REG(0x74)
69#define CRB_TX_PKT_TIMER NETXEN_NIC_REG(0x78)
70#define CRB_RX_PKT_CNT NETXEN_NIC_REG(0x7c)
71#define CRB_RX_TMR_CNT NETXEN_NIC_REG(0x80)
72#define CRB_RX_LRO_TIMER NETXEN_NIC_REG(0x84)
73#define CRB_RX_LRO_MID_TIMER NETXEN_NIC_REG(0x88)
74#define CRB_DMA_MAX_RCV_BUFS NETXEN_NIC_REG(0x8c)
75#define CRB_MAX_DMA_ENTRIES NETXEN_NIC_REG(0x90)
76#define CRB_XG_STATE NETXEN_NIC_REG(0x94) /* XG Link status */
77#define CRB_AGENT_GO NETXEN_NIC_REG(0x98) /* NIC pkt gen agent */
78#define CRB_AGENT_TX_SIZE NETXEN_NIC_REG(0x9c)
79#define CRB_AGENT_TX_TYPE NETXEN_NIC_REG(0xa0)
80#define CRB_AGENT_TX_ADDR NETXEN_NIC_REG(0xa4)
81#define CRB_AGENT_TX_MSS NETXEN_NIC_REG(0xa8)
82#define CRB_TX_STATE NETXEN_NIC_REG(0xac) /* Debug -performance */
83#define CRB_TX_COUNT NETXEN_NIC_REG(0xb0)
84#define CRB_RX_STATE NETXEN_NIC_REG(0xb4)
85#define CRB_RX_PERF_DEBUG_1 NETXEN_NIC_REG(0xb8)
86#define CRB_RX_LRO_CONTROL NETXEN_NIC_REG(0xbc) /* LRO On/OFF */
87#define CRB_RX_LRO_START_NUM NETXEN_NIC_REG(0xc0)
88#define CRB_MPORT_MODE NETXEN_NIC_REG(0xc4) /* Multiport Mode */
89#define CRB_CMD_RING_SIZE NETXEN_NIC_REG(0xc8)
90#define CRB_INT_VECTOR NETXEN_NIC_REG(0xd4)
91#define CRB_CTX_RESET NETXEN_NIC_REG(0xd8)
92#define CRB_HOST_STS_PROD NETXEN_NIC_REG(0xdc)
93#define CRB_HOST_STS_CONS NETXEN_NIC_REG(0xe0)
94#define CRB_PEG_CMD_PROD NETXEN_NIC_REG(0xe4)
95#define CRB_PEG_CMD_CONS NETXEN_NIC_REG(0xe8)
96#define CRB_HOST_BUFFER_PROD NETXEN_NIC_REG(0xec)
97#define CRB_HOST_BUFFER_CONS NETXEN_NIC_REG(0xf0)
98#define CRB_JUMBO_BUFFER_PROD NETXEN_NIC_REG(0xf4)
99#define CRB_JUMBO_BUFFER_CONS NETXEN_NIC_REG(0xf8)
100
101#define CRB_CMD_PRODUCER_OFFSET_1 NETXEN_NIC_REG(0x1ac)
102#define CRB_CMD_CONSUMER_OFFSET_1 NETXEN_NIC_REG(0x1b0)
103#define CRB_TEMP_STATE NETXEN_NIC_REG(0x1b4)
104
105/*
106 * CrbPortPhanCntrHi/Lo is used to pass the address of HostPhantomIndex address
107 * which can be read by the Phantom host to get producer/consumer indexes from
108 * Phantom/Casper. If it is not HOST_SHARED_MEMORY, then the following
109 * registers will be used for the addresses of the ring's shared memory
110 * on the Phantom.
111 */
112
113#define nx_get_temp_val(x) ((x) >> 16)
114#define nx_get_temp_state(x) ((x) & 0xffff)
115#define nx_encode_temp(val, state) (((val) << 16) | (state))
116
117/* CRB registers per Rcv Descriptor ring */
118struct netxen_rcv_desc_crb {
119 u32 crb_rcv_producer_offset __attribute__ ((aligned(512)));
120 u32 crb_rcv_consumer_offset;
121 u32 crb_globalrcv_ring;
122 u32 crb_rcv_ring_size;
123};
124
125/*
126 * CRB registers used by the receive peg logic.
127 */
128
129struct netxen_recv_crb {
130 struct netxen_rcv_desc_crb rcv_desc_crb[NUM_RCV_DESC_RINGS];
131 u32 crb_rcvstatus_ring;
132 u32 crb_rcv_status_producer;
133 u32 crb_rcv_status_consumer;
134 u32 crb_rcvpeg_state;
135 u32 crb_status_ring_size;
136};
137
138#if defined(DEFINE_GLOBAL_RECV_CRB)
139struct netxen_recv_crb recv_crb_registers[] = {
140 /*
141 * Instance 0.
142 */
143 {
144 /* rcv_desc_crb: */
145 {
146 {
147 /* crb_rcv_producer_offset: */
148 NETXEN_NIC_REG(0x100),
149 /* crb_rcv_consumer_offset: */
150 NETXEN_NIC_REG(0x104),
151 /* crb_gloablrcv_ring: */
152 NETXEN_NIC_REG(0x108),
153 /* crb_rcv_ring_size */
154 NETXEN_NIC_REG(0x10c),
155
156 },
157 /* Jumbo frames */
158 {
159 /* crb_rcv_producer_offset: */
160 NETXEN_NIC_REG(0x110),
161 /* crb_rcv_consumer_offset: */
162 NETXEN_NIC_REG(0x114),
163 /* crb_gloablrcv_ring: */
164 NETXEN_NIC_REG(0x118),
165 /* crb_rcv_ring_size */
166 NETXEN_NIC_REG(0x11c),
167 },
168 /* LRO */
169 {
170 /* crb_rcv_producer_offset: */
171 NETXEN_NIC_REG(0x120),
172 /* crb_rcv_consumer_offset: */
173 NETXEN_NIC_REG(0x124),
174 /* crb_gloablrcv_ring: */
175 NETXEN_NIC_REG(0x128),
176 /* crb_rcv_ring_size */
177 NETXEN_NIC_REG(0x12c),
178 }
179 },
180 /* crb_rcvstatus_ring: */
181 NETXEN_NIC_REG(0x130),
182 /* crb_rcv_status_producer: */
183 NETXEN_NIC_REG(0x134),
184 /* crb_rcv_status_consumer: */
185 NETXEN_NIC_REG(0x138),
186 /* crb_rcvpeg_state: */
187 NETXEN_NIC_REG(0x13c),
188 /* crb_status_ring_size */
189 NETXEN_NIC_REG(0x140),
190
191 },
192 /*
193 * Instance 1,
194 */
195 {
196 /* rcv_desc_crb: */
197 {
198 {
199 /* crb_rcv_producer_offset: */
200 NETXEN_NIC_REG(0x144),
201 /* crb_rcv_consumer_offset: */
202 NETXEN_NIC_REG(0x148),
203 /* crb_globalrcv_ring: */
204 NETXEN_NIC_REG(0x14c),
205 /* crb_rcv_ring_size */
206 NETXEN_NIC_REG(0x150),
207
208 },
209 /* Jumbo frames */
210 {
211 /* crb_rcv_producer_offset: */
212 NETXEN_NIC_REG(0x154),
213 /* crb_rcv_consumer_offset: */
214 NETXEN_NIC_REG(0x158),
215 /* crb_globalrcv_ring: */
216 NETXEN_NIC_REG(0x15c),
217 /* crb_rcv_ring_size */
218 NETXEN_NIC_REG(0x160),
219 },
220 /* LRO */
221 {
222 /* crb_rcv_producer_offset: */
223 NETXEN_NIC_REG(0x164),
224 /* crb_rcv_consumer_offset: */
225 NETXEN_NIC_REG(0x168),
226 /* crb_globalrcv_ring: */
227 NETXEN_NIC_REG(0x16c),
228 /* crb_rcv_ring_size */
229 NETXEN_NIC_REG(0x170),
230 }
231
232 },
233 /* crb_rcvstatus_ring: */
234 NETXEN_NIC_REG(0x174),
235 /* crb_rcv_status_producer: */
236 NETXEN_NIC_REG(0x178),
237 /* crb_rcv_status_consumer: */
238 NETXEN_NIC_REG(0x17c),
239 /* crb_rcvpeg_state: */
240 NETXEN_NIC_REG(0x180),
241 /* crb_status_ring_size */
242 NETXEN_NIC_REG(0x184),
243
244 },
245};
246
247u64 ctx_addr_sig_regs[][3] = {
248 {NETXEN_NIC_REG(0x188), NETXEN_NIC_REG(0x18c), NETXEN_NIC_REG(0x1c0)},
249 {NETXEN_NIC_REG(0x190), NETXEN_NIC_REG(0x194), NETXEN_NIC_REG(0x1c4)},
250 {NETXEN_NIC_REG(0x198), NETXEN_NIC_REG(0x19c), NETXEN_NIC_REG(0x1c8)},
251 {NETXEN_NIC_REG(0x1a0), NETXEN_NIC_REG(0x1a4), NETXEN_NIC_REG(0x1cc)}
252};
253
254#else
255extern struct netxen_recv_crb recv_crb_registers[];
256extern u64 ctx_addr_sig_regs[][3];
257#define CRB_CTX_ADDR_REG_LO (ctx_addr_sig_regs[0][0])
258#define CRB_CTX_ADDR_REG_HI (ctx_addr_sig_regs[0][2])
259#define CRB_CTX_SIGNATURE_REG (ctx_addr_sig_regs[0][1])
260#endif /* DEFINE_GLOBAL_RECEIVE_CRB */
261
262/*
263 * Temperature control.
264 */
265enum {
266 NX_TEMP_NORMAL = 0x1, /* Normal operating range */
267 NX_TEMP_WARN, /* Sound alert, temperature getting high */
268 NX_TEMP_PANIC /* Fatal error, hardware has shut down. */
269};
270
271#endif /* __NIC_PHAN_REG_H_ */
diff --git a/drivers/net/ni52.c b/drivers/net/ni52.c
index 26e42f6e9fb1..196993a29b09 100644
--- a/drivers/net/ni52.c
+++ b/drivers/net/ni52.c
@@ -1335,7 +1335,7 @@ int __init init_module(void)
1335 return 0; 1335 return 0;
1336} 1336}
1337 1337
1338void cleanup_module(void) 1338void __exit cleanup_module(void)
1339{ 1339{
1340 unregister_netdev(dev_ni52); 1340 unregister_netdev(dev_ni52);
1341 release_region(dev_ni52->base_addr, NI52_TOTAL_SIZE); 1341 release_region(dev_ni52->base_addr, NI52_TOTAL_SIZE);
diff --git a/drivers/net/ni65.c b/drivers/net/ni65.c
index 340ad0d5388a..1578f4d98498 100644
--- a/drivers/net/ni65.c
+++ b/drivers/net/ni65.c
@@ -1259,7 +1259,7 @@ int __init init_module(void)
1259 return IS_ERR(dev_ni65) ? PTR_ERR(dev_ni65) : 0; 1259 return IS_ERR(dev_ni65) ? PTR_ERR(dev_ni65) : 0;
1260} 1260}
1261 1261
1262void cleanup_module(void) 1262void __exit cleanup_module(void)
1263{ 1263{
1264 unregister_netdev(dev_ni65); 1264 unregister_netdev(dev_ni65);
1265 cleanup_card(dev_ni65); 1265 cleanup_card(dev_ni65);
diff --git a/drivers/net/ns83820.c b/drivers/net/ns83820.c
index b0127c71a5b6..568daeb3e9d8 100644
--- a/drivers/net/ns83820.c
+++ b/drivers/net/ns83820.c
@@ -414,10 +414,10 @@ struct rx_info {
414 414
415 struct sk_buff *skbs[NR_RX_DESC]; 415 struct sk_buff *skbs[NR_RX_DESC];
416 416
417 u32 *next_rx_desc; 417 __le32 *next_rx_desc;
418 u16 next_rx, next_empty; 418 u16 next_rx, next_empty;
419 419
420 u32 *descs; 420 __le32 *descs;
421 dma_addr_t phy_descs; 421 dma_addr_t phy_descs;
422}; 422};
423 423
@@ -427,6 +427,7 @@ struct ns83820 {
427 u8 __iomem *base; 427 u8 __iomem *base;
428 428
429 struct pci_dev *pci_dev; 429 struct pci_dev *pci_dev;
430 struct net_device *ndev;
430 431
431#ifdef NS83820_VLAN_ACCEL_SUPPORT 432#ifdef NS83820_VLAN_ACCEL_SUPPORT
432 struct vlan_group *vlgrp; 433 struct vlan_group *vlgrp;
@@ -459,7 +460,7 @@ struct ns83820 {
459 struct sk_buff *tx_skbs[NR_TX_DESC]; 460 struct sk_buff *tx_skbs[NR_TX_DESC];
460 461
461 char pad[16] __attribute__((aligned(16))); 462 char pad[16] __attribute__((aligned(16)));
462 u32 *tx_descs; 463 __le32 *tx_descs;
463 dma_addr_t tx_phy_descs; 464 dma_addr_t tx_phy_descs;
464 465
465 struct timer_list tx_watchdog; 466 struct timer_list tx_watchdog;
@@ -533,7 +534,7 @@ static void ns83820_vlan_rx_kill_vid(struct net_device *ndev, unsigned short vid
533 * conditions, still route realtime traffic with as low jitter as 534 * conditions, still route realtime traffic with as low jitter as
534 * possible. 535 * possible.
535 */ 536 */
536static inline void build_rx_desc(struct ns83820 *dev, u32 *desc, dma_addr_t link, dma_addr_t buf, u32 cmdsts, u32 extsts) 537static inline void build_rx_desc(struct ns83820 *dev, __le32 *desc, dma_addr_t link, dma_addr_t buf, u32 cmdsts, u32 extsts)
537{ 538{
538 desc_addr_set(desc + DESC_LINK, link); 539 desc_addr_set(desc + DESC_LINK, link);
539 desc_addr_set(desc + DESC_BUFPTR, buf); 540 desc_addr_set(desc + DESC_BUFPTR, buf);
@@ -547,7 +548,7 @@ static inline int ns83820_add_rx_skb(struct ns83820 *dev, struct sk_buff *skb)
547{ 548{
548 unsigned next_empty; 549 unsigned next_empty;
549 u32 cmdsts; 550 u32 cmdsts;
550 u32 *sg; 551 __le32 *sg;
551 dma_addr_t buf; 552 dma_addr_t buf;
552 553
553 next_empty = dev->rx_info.next_empty; 554 next_empty = dev->rx_info.next_empty;
@@ -631,10 +632,10 @@ static void fastcall rx_refill_atomic(struct net_device *ndev)
631} 632}
632 633
633/* REFILL */ 634/* REFILL */
634static inline void queue_refill(void *_dev) 635static inline void queue_refill(struct work_struct *work)
635{ 636{
636 struct net_device *ndev = _dev; 637 struct ns83820 *dev = container_of(work, struct ns83820, tq_refill);
637 struct ns83820 *dev = PRIV(ndev); 638 struct net_device *ndev = dev->ndev;
638 639
639 rx_refill(ndev, GFP_KERNEL); 640 rx_refill(ndev, GFP_KERNEL);
640 if (dev->rx_info.up) 641 if (dev->rx_info.up)
@@ -874,7 +875,8 @@ static void fastcall rx_irq(struct net_device *ndev)
874 struct rx_info *info = &dev->rx_info; 875 struct rx_info *info = &dev->rx_info;
875 unsigned next_rx; 876 unsigned next_rx;
876 int rx_rc, len; 877 int rx_rc, len;
877 u32 cmdsts, *desc; 878 u32 cmdsts;
879 __le32 *desc;
878 unsigned long flags; 880 unsigned long flags;
879 int nr = 0; 881 int nr = 0;
880 882
@@ -1010,7 +1012,8 @@ static inline void kick_tx(struct ns83820 *dev)
1010static void do_tx_done(struct net_device *ndev) 1012static void do_tx_done(struct net_device *ndev)
1011{ 1013{
1012 struct ns83820 *dev = PRIV(ndev); 1014 struct ns83820 *dev = PRIV(ndev);
1013 u32 cmdsts, tx_done_idx, *desc; 1015 u32 cmdsts, tx_done_idx;
1016 __le32 *desc;
1014 1017
1015 dprintk("do_tx_done(%p)\n", ndev); 1018 dprintk("do_tx_done(%p)\n", ndev);
1016 tx_done_idx = dev->tx_done_idx; 1019 tx_done_idx = dev->tx_done_idx;
@@ -1077,7 +1080,7 @@ static void ns83820_cleanup_tx(struct ns83820 *dev)
1077 struct sk_buff *skb = dev->tx_skbs[i]; 1080 struct sk_buff *skb = dev->tx_skbs[i];
1078 dev->tx_skbs[i] = NULL; 1081 dev->tx_skbs[i] = NULL;
1079 if (skb) { 1082 if (skb) {
1080 u32 *desc = dev->tx_descs + (i * DESC_SIZE); 1083 __le32 *desc = dev->tx_descs + (i * DESC_SIZE);
1081 pci_unmap_single(dev->pci_dev, 1084 pci_unmap_single(dev->pci_dev,
1082 desc_addr_get(desc + DESC_BUFPTR), 1085 desc_addr_get(desc + DESC_BUFPTR),
1083 le32_to_cpu(desc[DESC_CMDSTS]) & CMDSTS_LEN_MASK, 1086 le32_to_cpu(desc[DESC_CMDSTS]) & CMDSTS_LEN_MASK,
@@ -1107,7 +1110,7 @@ static int ns83820_hard_start_xmit(struct sk_buff *skb, struct net_device *ndev)
1107 skb_frag_t *frag; 1110 skb_frag_t *frag;
1108 int stopped = 0; 1111 int stopped = 0;
1109 int do_intr = 0; 1112 int do_intr = 0;
1110 volatile u32 *first_desc; 1113 volatile __le32 *first_desc;
1111 1114
1112 dprintk("ns83820_hard_start_xmit\n"); 1115 dprintk("ns83820_hard_start_xmit\n");
1113 1116
@@ -1180,7 +1183,7 @@ again:
1180 first_desc = dev->tx_descs + (free_idx * DESC_SIZE); 1183 first_desc = dev->tx_descs + (free_idx * DESC_SIZE);
1181 1184
1182 for (;;) { 1185 for (;;) {
1183 volatile u32 *desc = dev->tx_descs + (free_idx * DESC_SIZE); 1186 volatile __le32 *desc = dev->tx_descs + (free_idx * DESC_SIZE);
1184 1187
1185 dprintk("frag[%3u]: %4u @ 0x%08Lx\n", free_idx, len, 1188 dprintk("frag[%3u]: %4u @ 0x%08Lx\n", free_idx, len,
1186 (unsigned long long)buf); 1189 (unsigned long long)buf);
@@ -1455,7 +1458,8 @@ static int ns83820_stop(struct net_device *ndev)
1455static void ns83820_tx_timeout(struct net_device *ndev) 1458static void ns83820_tx_timeout(struct net_device *ndev)
1456{ 1459{
1457 struct ns83820 *dev = PRIV(ndev); 1460 struct ns83820 *dev = PRIV(ndev);
1458 u32 tx_done_idx, *desc; 1461 u32 tx_done_idx;
1462 __le32 *desc;
1459 unsigned long flags; 1463 unsigned long flags;
1460 1464
1461 spin_lock_irqsave(&dev->tx_lock, flags); 1465 spin_lock_irqsave(&dev->tx_lock, flags);
@@ -1841,6 +1845,7 @@ static int __devinit ns83820_init_one(struct pci_dev *pci_dev, const struct pci_
1841 1845
1842 ndev = alloc_etherdev(sizeof(struct ns83820)); 1846 ndev = alloc_etherdev(sizeof(struct ns83820));
1843 dev = PRIV(ndev); 1847 dev = PRIV(ndev);
1848 dev->ndev = ndev;
1844 err = -ENOMEM; 1849 err = -ENOMEM;
1845 if (!dev) 1850 if (!dev)
1846 goto out; 1851 goto out;
@@ -1853,7 +1858,7 @@ static int __devinit ns83820_init_one(struct pci_dev *pci_dev, const struct pci_
1853 SET_MODULE_OWNER(ndev); 1858 SET_MODULE_OWNER(ndev);
1854 SET_NETDEV_DEV(ndev, &pci_dev->dev); 1859 SET_NETDEV_DEV(ndev, &pci_dev->dev);
1855 1860
1856 INIT_WORK(&dev->tq_refill, queue_refill, ndev); 1861 INIT_WORK(&dev->tq_refill, queue_refill);
1857 tasklet_init(&dev->rx_tasklet, rx_action, (unsigned long)ndev); 1862 tasklet_init(&dev->rx_tasklet, rx_action, (unsigned long)ndev);
1858 1863
1859 err = pci_enable_device(pci_dev); 1864 err = pci_enable_device(pci_dev);
diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c
index 046009928526..794cc61819dd 100644
--- a/drivers/net/pcmcia/3c574_cs.c
+++ b/drivers/net/pcmcia/3c574_cs.c
@@ -338,7 +338,6 @@ static int tc574_config(struct pcmcia_device *link)
338 struct net_device *dev = link->priv; 338 struct net_device *dev = link->priv;
339 struct el3_private *lp = netdev_priv(dev); 339 struct el3_private *lp = netdev_priv(dev);
340 tuple_t tuple; 340 tuple_t tuple;
341 cisparse_t parse;
342 unsigned short buf[32]; 341 unsigned short buf[32];
343 int last_fn, last_ret, i, j; 342 int last_fn, last_ret, i, j;
344 kio_addr_t ioaddr; 343 kio_addr_t ioaddr;
@@ -350,17 +349,6 @@ static int tc574_config(struct pcmcia_device *link)
350 349
351 DEBUG(0, "3c574_config(0x%p)\n", link); 350 DEBUG(0, "3c574_config(0x%p)\n", link);
352 351
353 tuple.Attributes = 0;
354 tuple.DesiredTuple = CISTPL_CONFIG;
355 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
356 tuple.TupleData = (cisdata_t *)buf;
357 tuple.TupleDataMax = 64;
358 tuple.TupleOffset = 0;
359 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
360 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
361 link->conf.ConfigBase = parse.config.base;
362 link->conf.Present = parse.config.rmask[0];
363
364 link->io.IOAddrLines = 16; 352 link->io.IOAddrLines = 16;
365 for (i = j = 0; j < 0x400; j += 0x20) { 353 for (i = j = 0; j < 0x400; j += 0x20) {
366 link->io.BasePort1 = j ^ 0x300; 354 link->io.BasePort1 = j ^ 0x300;
@@ -382,6 +370,10 @@ static int tc574_config(struct pcmcia_device *link)
382 /* The 3c574 normally uses an EEPROM for configuration info, including 370 /* The 3c574 normally uses an EEPROM for configuration info, including
383 the hardware address. The future products may include a modem chip 371 the hardware address. The future products may include a modem chip
384 and put the address in the CIS. */ 372 and put the address in the CIS. */
373 tuple.Attributes = 0;
374 tuple.TupleData = (cisdata_t *)buf;
375 tuple.TupleDataMax = 64;
376 tuple.TupleOffset = 0;
385 tuple.DesiredTuple = 0x88; 377 tuple.DesiredTuple = 0x88;
386 if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) { 378 if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) {
387 pcmcia_get_tuple_data(link, &tuple); 379 pcmcia_get_tuple_data(link, &tuple);
@@ -397,12 +389,9 @@ static int tc574_config(struct pcmcia_device *link)
397 goto failed; 389 goto failed;
398 } 390 }
399 } 391 }
400 tuple.DesiredTuple = CISTPL_VERS_1; 392 if (link->prod_id[1])
401 if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS && 393 cardname = link->prod_id[1];
402 pcmcia_get_tuple_data(link, &tuple) == CS_SUCCESS && 394 else
403 pcmcia_parse_tuple(link, &tuple, &parse) == CS_SUCCESS) {
404 cardname = parse.version_1.str + parse.version_1.ofs[1];
405 } else
406 cardname = "3Com 3c574"; 395 cardname = "3Com 3c574";
407 396
408 { 397 {
diff --git a/drivers/net/pcmcia/3c589_cs.c b/drivers/net/pcmcia/3c589_cs.c
index 231fa2c9ec6c..1e73ff7d5d8e 100644
--- a/drivers/net/pcmcia/3c589_cs.c
+++ b/drivers/net/pcmcia/3c589_cs.c
@@ -253,7 +253,6 @@ static int tc589_config(struct pcmcia_device *link)
253 struct net_device *dev = link->priv; 253 struct net_device *dev = link->priv;
254 struct el3_private *lp = netdev_priv(dev); 254 struct el3_private *lp = netdev_priv(dev);
255 tuple_t tuple; 255 tuple_t tuple;
256 cisparse_t parse;
257 u16 buf[32], *phys_addr; 256 u16 buf[32], *phys_addr;
258 int last_fn, last_ret, i, j, multi = 0, fifo; 257 int last_fn, last_ret, i, j, multi = 0, fifo;
259 kio_addr_t ioaddr; 258 kio_addr_t ioaddr;
@@ -263,26 +262,16 @@ static int tc589_config(struct pcmcia_device *link)
263 262
264 phys_addr = (u16 *)dev->dev_addr; 263 phys_addr = (u16 *)dev->dev_addr;
265 tuple.Attributes = 0; 264 tuple.Attributes = 0;
266 tuple.DesiredTuple = CISTPL_CONFIG;
267 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
268 tuple.TupleData = (cisdata_t *)buf; 265 tuple.TupleData = (cisdata_t *)buf;
269 tuple.TupleDataMax = sizeof(buf); 266 tuple.TupleDataMax = sizeof(buf);
270 tuple.TupleOffset = 0; 267 tuple.TupleOffset = 0;
271 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
272 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
273 link->conf.ConfigBase = parse.config.base;
274 link->conf.Present = parse.config.rmask[0];
275
276 /* Is this a 3c562? */
277 tuple.DesiredTuple = CISTPL_MANFID;
278 tuple.Attributes = TUPLE_RETURN_COMMON; 268 tuple.Attributes = TUPLE_RETURN_COMMON;
279 if ((pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) && 269
280 (pcmcia_get_tuple_data(link, &tuple) == CS_SUCCESS)) { 270 /* Is this a 3c562? */
281 if (le16_to_cpu(buf[0]) != MANFID_3COM) 271 if (link->manf_id != MANFID_3COM)
282 printk(KERN_INFO "3c589_cs: hmmm, is this really a " 272 printk(KERN_INFO "3c589_cs: hmmm, is this really a "
283 "3Com card??\n"); 273 "3Com card??\n");
284 multi = (le16_to_cpu(buf[1]) == PRODID_3COM_3C562); 274 multi = (link->card_id == PRODID_3COM_3C562);
285 }
286 275
287 /* For the 3c562, the base address must be xx00-xx7f */ 276 /* For the 3c562, the base address must be xx00-xx7f */
288 link->io.IOAddrLines = 16; 277 link->io.IOAddrLines = 16;
diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c
index 5ddd5742f779..6139048f8117 100644
--- a/drivers/net/pcmcia/axnet_cs.c
+++ b/drivers/net/pcmcia/axnet_cs.c
@@ -299,11 +299,7 @@ static int axnet_config(struct pcmcia_device *link)
299 tuple.TupleData = (cisdata_t *)buf; 299 tuple.TupleData = (cisdata_t *)buf;
300 tuple.TupleDataMax = sizeof(buf); 300 tuple.TupleDataMax = sizeof(buf);
301 tuple.TupleOffset = 0; 301 tuple.TupleOffset = 0;
302 tuple.DesiredTuple = CISTPL_CONFIG; 302
303 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
304 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
305 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
306 link->conf.ConfigBase = parse.config.base;
307 /* don't trust the CIS on this; Linksys got it wrong */ 303 /* don't trust the CIS on this; Linksys got it wrong */
308 link->conf.Present = 0x63; 304 link->conf.Present = 0x63;
309 305
diff --git a/drivers/net/pcmcia/com20020_cs.c b/drivers/net/pcmcia/com20020_cs.c
index 48434d7924eb..91f65e91cd5f 100644
--- a/drivers/net/pcmcia/com20020_cs.c
+++ b/drivers/net/pcmcia/com20020_cs.c
@@ -249,12 +249,9 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
249static int com20020_config(struct pcmcia_device *link) 249static int com20020_config(struct pcmcia_device *link)
250{ 250{
251 struct arcnet_local *lp; 251 struct arcnet_local *lp;
252 tuple_t tuple;
253 cisparse_t parse;
254 com20020_dev_t *info; 252 com20020_dev_t *info;
255 struct net_device *dev; 253 struct net_device *dev;
256 int i, last_ret, last_fn; 254 int i, last_ret, last_fn;
257 u_char buf[64];
258 int ioaddr; 255 int ioaddr;
259 256
260 info = link->priv; 257 info = link->priv;
@@ -264,16 +261,6 @@ static int com20020_config(struct pcmcia_device *link)
264 261
265 DEBUG(0, "com20020_config(0x%p)\n", link); 262 DEBUG(0, "com20020_config(0x%p)\n", link);
266 263
267 tuple.Attributes = 0;
268 tuple.TupleData = buf;
269 tuple.TupleDataMax = 64;
270 tuple.TupleOffset = 0;
271 tuple.DesiredTuple = CISTPL_CONFIG;
272 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
273 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
274 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
275 link->conf.ConfigBase = parse.config.base;
276
277 DEBUG(1,"arcnet: baseport1 is %Xh\n", link->io.BasePort1); 264 DEBUG(1,"arcnet: baseport1 is %Xh\n", link->io.BasePort1);
278 i = !CS_SUCCESS; 265 i = !CS_SUCCESS;
279 if (!link->io.BasePort1) 266 if (!link->io.BasePort1)
diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c
index 65f6fdf43725..0d7de617e535 100644
--- a/drivers/net/pcmcia/fmvj18x_cs.c
+++ b/drivers/net/pcmcia/fmvj18x_cs.c
@@ -342,7 +342,7 @@ static int fmvj18x_config(struct pcmcia_device *link)
342 tuple_t tuple; 342 tuple_t tuple;
343 cisparse_t parse; 343 cisparse_t parse;
344 u_short buf[32]; 344 u_short buf[32];
345 int i, last_fn, last_ret, ret; 345 int i, last_fn = 0, last_ret = 0, ret;
346 kio_addr_t ioaddr; 346 kio_addr_t ioaddr;
347 cardtype_t cardtype; 347 cardtype_t cardtype;
348 char *card_name = "unknown"; 348 char *card_name = "unknown";
@@ -350,21 +350,9 @@ static int fmvj18x_config(struct pcmcia_device *link)
350 350
351 DEBUG(0, "fmvj18x_config(0x%p)\n", link); 351 DEBUG(0, "fmvj18x_config(0x%p)\n", link);
352 352
353 /*
354 This reads the card's CONFIG tuple to find its configuration
355 registers.
356 */
357 tuple.DesiredTuple = CISTPL_CONFIG;
358 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
359 tuple.TupleData = (u_char *)buf; 353 tuple.TupleData = (u_char *)buf;
360 tuple.TupleDataMax = 64; 354 tuple.TupleDataMax = 64;
361 tuple.TupleOffset = 0; 355 tuple.TupleOffset = 0;
362 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
363 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
364
365 link->conf.ConfigBase = parse.config.base;
366 link->conf.Present = parse.config.rmask[0];
367
368 tuple.DesiredTuple = CISTPL_FUNCE; 356 tuple.DesiredTuple = CISTPL_FUNCE;
369 tuple.TupleOffset = 0; 357 tuple.TupleOffset = 0;
370 if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) { 358 if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) {
@@ -374,17 +362,12 @@ static int fmvj18x_config(struct pcmcia_device *link)
374 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 362 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
375 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); 363 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
376 link->conf.ConfigIndex = parse.cftable_entry.index; 364 link->conf.ConfigIndex = parse.cftable_entry.index;
377 tuple.DesiredTuple = CISTPL_MANFID; 365 switch (link->manf_id) {
378 if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS)
379 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
380 else
381 buf[0] = 0xffff;
382 switch (le16_to_cpu(buf[0])) {
383 case MANFID_TDK: 366 case MANFID_TDK:
384 cardtype = TDK; 367 cardtype = TDK;
385 if (le16_to_cpu(buf[1]) == PRODID_TDK_GN3410 368 if (link->card_id == PRODID_TDK_GN3410
386 || le16_to_cpu(buf[1]) == PRODID_TDK_NP9610 369 || link->card_id == PRODID_TDK_NP9610
387 || le16_to_cpu(buf[1]) == PRODID_TDK_MN3200) { 370 || link->card_id == PRODID_TDK_MN3200) {
388 /* MultiFunction Card */ 371 /* MultiFunction Card */
389 link->conf.ConfigBase = 0x800; 372 link->conf.ConfigBase = 0x800;
390 link->conf.ConfigIndex = 0x47; 373 link->conf.ConfigIndex = 0x47;
@@ -395,11 +378,11 @@ static int fmvj18x_config(struct pcmcia_device *link)
395 cardtype = CONTEC; 378 cardtype = CONTEC;
396 break; 379 break;
397 case MANFID_FUJITSU: 380 case MANFID_FUJITSU:
398 if (le16_to_cpu(buf[1]) == PRODID_FUJITSU_MBH10302) 381 if (link->card_id == PRODID_FUJITSU_MBH10302)
399 /* RATOC REX-5588/9822/4886's PRODID are 0004(=MBH10302), 382 /* RATOC REX-5588/9822/4886's PRODID are 0004(=MBH10302),
400 but these are MBH10304 based card. */ 383 but these are MBH10304 based card. */
401 cardtype = MBH10304; 384 cardtype = MBH10304;
402 else if (le16_to_cpu(buf[1]) == PRODID_FUJITSU_MBH10304) 385 else if (link->card_id == PRODID_FUJITSU_MBH10304)
403 cardtype = MBH10304; 386 cardtype = MBH10304;
404 else 387 else
405 cardtype = LA501; 388 cardtype = LA501;
@@ -409,14 +392,9 @@ static int fmvj18x_config(struct pcmcia_device *link)
409 } 392 }
410 } else { 393 } else {
411 /* old type card */ 394 /* old type card */
412 tuple.DesiredTuple = CISTPL_MANFID; 395 switch (link->manf_id) {
413 if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS)
414 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
415 else
416 buf[0] = 0xffff;
417 switch (le16_to_cpu(buf[0])) {
418 case MANFID_FUJITSU: 396 case MANFID_FUJITSU:
419 if (le16_to_cpu(buf[1]) == PRODID_FUJITSU_MBH10304) { 397 if (link->card_id == PRODID_FUJITSU_MBH10304) {
420 cardtype = XXX10304; /* MBH10304 with buggy CIS */ 398 cardtype = XXX10304; /* MBH10304 with buggy CIS */
421 link->conf.ConfigIndex = 0x20; 399 link->conf.ConfigIndex = 0x20;
422 } else { 400 } else {
diff --git a/drivers/net/pcmcia/ibmtr_cs.c b/drivers/net/pcmcia/ibmtr_cs.c
index bc0ca41a0542..a956a51d284f 100644
--- a/drivers/net/pcmcia/ibmtr_cs.c
+++ b/drivers/net/pcmcia/ibmtr_cs.c
@@ -222,24 +222,12 @@ static int ibmtr_config(struct pcmcia_device *link)
222 ibmtr_dev_t *info = link->priv; 222 ibmtr_dev_t *info = link->priv;
223 struct net_device *dev = info->dev; 223 struct net_device *dev = info->dev;
224 struct tok_info *ti = netdev_priv(dev); 224 struct tok_info *ti = netdev_priv(dev);
225 tuple_t tuple;
226 cisparse_t parse;
227 win_req_t req; 225 win_req_t req;
228 memreq_t mem; 226 memreq_t mem;
229 int i, last_ret, last_fn; 227 int i, last_ret, last_fn;
230 u_char buf[64];
231 228
232 DEBUG(0, "ibmtr_config(0x%p)\n", link); 229 DEBUG(0, "ibmtr_config(0x%p)\n", link);
233 230
234 tuple.Attributes = 0;
235 tuple.TupleData = buf;
236 tuple.TupleDataMax = 64;
237 tuple.TupleOffset = 0;
238 tuple.DesiredTuple = CISTPL_CONFIG;
239 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
240 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
241 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
242 link->conf.ConfigBase = parse.config.base;
243 link->conf.ConfigIndex = 0x61; 231 link->conf.ConfigIndex = 0x61;
244 232
245 /* Determine if this is PRIMARY or ALTERNATE. */ 233 /* Determine if this is PRIMARY or ALTERNATE. */
diff --git a/drivers/net/pcmcia/nmclan_cs.c b/drivers/net/pcmcia/nmclan_cs.c
index e77110e4c288..3b707747a811 100644
--- a/drivers/net/pcmcia/nmclan_cs.c
+++ b/drivers/net/pcmcia/nmclan_cs.c
@@ -656,23 +656,12 @@ static int nmclan_config(struct pcmcia_device *link)
656 struct net_device *dev = link->priv; 656 struct net_device *dev = link->priv;
657 mace_private *lp = netdev_priv(dev); 657 mace_private *lp = netdev_priv(dev);
658 tuple_t tuple; 658 tuple_t tuple;
659 cisparse_t parse;
660 u_char buf[64]; 659 u_char buf[64];
661 int i, last_ret, last_fn; 660 int i, last_ret, last_fn;
662 kio_addr_t ioaddr; 661 kio_addr_t ioaddr;
663 662
664 DEBUG(0, "nmclan_config(0x%p)\n", link); 663 DEBUG(0, "nmclan_config(0x%p)\n", link);
665 664
666 tuple.Attributes = 0;
667 tuple.TupleData = buf;
668 tuple.TupleDataMax = 64;
669 tuple.TupleOffset = 0;
670 tuple.DesiredTuple = CISTPL_CONFIG;
671 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
672 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
673 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
674 link->conf.ConfigBase = parse.config.base;
675
676 CS_CHECK(RequestIO, pcmcia_request_io(link, &link->io)); 665 CS_CHECK(RequestIO, pcmcia_request_io(link, &link->io));
677 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 666 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
678 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 667 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
@@ -686,6 +675,7 @@ static int nmclan_config(struct pcmcia_device *link)
686 tuple.TupleData = buf; 675 tuple.TupleData = buf;
687 tuple.TupleDataMax = 64; 676 tuple.TupleDataMax = 64;
688 tuple.TupleOffset = 0; 677 tuple.TupleOffset = 0;
678 tuple.Attributes = 0;
689 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 679 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
690 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 680 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
691 memcpy(dev->dev_addr, tuple.TupleData, ETHER_ADDR_LEN); 681 memcpy(dev->dev_addr, tuple.TupleData, ETHER_ADDR_LEN);
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c
index 0c00d182e7fd..2b1238e2dbdb 100644
--- a/drivers/net/pcmcia/pcnet_cs.c
+++ b/drivers/net/pcmcia/pcnet_cs.c
@@ -519,31 +519,15 @@ static int pcnet_config(struct pcmcia_device *link)
519 tuple_t tuple; 519 tuple_t tuple;
520 cisparse_t parse; 520 cisparse_t parse;
521 int i, last_ret, last_fn, start_pg, stop_pg, cm_offset; 521 int i, last_ret, last_fn, start_pg, stop_pg, cm_offset;
522 int manfid = 0, prodid = 0, has_shmem = 0; 522 int has_shmem = 0;
523 u_short buf[64]; 523 u_short buf[64];
524 hw_info_t *hw_info; 524 hw_info_t *hw_info;
525 525
526 DEBUG(0, "pcnet_config(0x%p)\n", link); 526 DEBUG(0, "pcnet_config(0x%p)\n", link);
527 527
528 tuple.Attributes = 0;
529 tuple.TupleData = (cisdata_t *)buf; 528 tuple.TupleData = (cisdata_t *)buf;
530 tuple.TupleDataMax = sizeof(buf); 529 tuple.TupleDataMax = sizeof(buf);
531 tuple.TupleOffset = 0; 530 tuple.TupleOffset = 0;
532 tuple.DesiredTuple = CISTPL_CONFIG;
533 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
534 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
535 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
536 link->conf.ConfigBase = parse.config.base;
537 link->conf.Present = parse.config.rmask[0];
538
539 tuple.DesiredTuple = CISTPL_MANFID;
540 tuple.Attributes = TUPLE_RETURN_COMMON;
541 if ((pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) &&
542 (pcmcia_get_tuple_data(link, &tuple) == CS_SUCCESS)) {
543 manfid = le16_to_cpu(buf[0]);
544 prodid = le16_to_cpu(buf[1]);
545 }
546
547 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 531 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
548 tuple.Attributes = 0; 532 tuple.Attributes = 0;
549 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 533 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
@@ -589,8 +573,8 @@ static int pcnet_config(struct pcmcia_device *link)
589 link->conf.Attributes |= CONF_ENABLE_SPKR; 573 link->conf.Attributes |= CONF_ENABLE_SPKR;
590 link->conf.Status = CCSR_AUDIO_ENA; 574 link->conf.Status = CCSR_AUDIO_ENA;
591 } 575 }
592 if ((manfid == MANFID_IBM) && 576 if ((link->manf_id == MANFID_IBM) &&
593 (prodid == PRODID_IBM_HOME_AND_AWAY)) 577 (link->card_id == PRODID_IBM_HOME_AND_AWAY))
594 link->conf.ConfigIndex |= 0x10; 578 link->conf.ConfigIndex |= 0x10;
595 579
596 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 580 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
@@ -624,10 +608,10 @@ static int pcnet_config(struct pcmcia_device *link)
624 info->flags = hw_info->flags; 608 info->flags = hw_info->flags;
625 /* Check for user overrides */ 609 /* Check for user overrides */
626 info->flags |= (delay_output) ? DELAY_OUTPUT : 0; 610 info->flags |= (delay_output) ? DELAY_OUTPUT : 0;
627 if ((manfid == MANFID_SOCKET) && 611 if ((link->manf_id == MANFID_SOCKET) &&
628 ((prodid == PRODID_SOCKET_LPE) || 612 ((link->card_id == PRODID_SOCKET_LPE) ||
629 (prodid == PRODID_SOCKET_LPE_CF) || 613 (link->card_id == PRODID_SOCKET_LPE_CF) ||
630 (prodid == PRODID_SOCKET_EIO))) 614 (link->card_id == PRODID_SOCKET_EIO)))
631 info->flags &= ~USE_BIG_BUF; 615 info->flags &= ~USE_BIG_BUF;
632 if (!use_big_buf) 616 if (!use_big_buf)
633 info->flags &= ~USE_BIG_BUF; 617 info->flags &= ~USE_BIG_BUF;
@@ -1096,7 +1080,6 @@ static void ei_watchdog(u_long arg)
1096 1080
1097 /* Check for pending interrupt with expired latency timer: with 1081 /* Check for pending interrupt with expired latency timer: with
1098 this, we can limp along even if the interrupt is blocked */ 1082 this, we can limp along even if the interrupt is blocked */
1099 outb_p(E8390_NODMA+E8390_PAGE0, nic_base + E8390_CMD);
1100 if (info->stale++ && (inb_p(nic_base + EN0_ISR) & ENISR_ALL)) { 1083 if (info->stale++ && (inb_p(nic_base + EN0_ISR) & ENISR_ALL)) {
1101 if (!info->fast_poll) 1084 if (!info->fast_poll)
1102 printk(KERN_INFO "%s: interrupt(s) dropped!\n", dev->name); 1085 printk(KERN_INFO "%s: interrupt(s) dropped!\n", dev->name);
diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c
index 20fcc3576202..530df8883fe5 100644
--- a/drivers/net/pcmcia/smc91c92_cs.c
+++ b/drivers/net/pcmcia/smc91c92_cs.c
@@ -560,16 +560,8 @@ static int mhz_setup(struct pcmcia_device *link)
560 560
561 /* Read the station address from the CIS. It is stored as the last 561 /* Read the station address from the CIS. It is stored as the last
562 (fourth) string in the Version 1 Version/ID tuple. */ 562 (fourth) string in the Version 1 Version/ID tuple. */
563 tuple->DesiredTuple = CISTPL_VERS_1; 563 if (link->prod_id[3]) {
564 if (first_tuple(link, tuple, parse) != CS_SUCCESS) { 564 station_addr = link->prod_id[3];
565 rc = -1;
566 goto free_cfg_mem;
567 }
568 /* Ugh -- the EM1144 card has two VERS_1 tuples!?! */
569 if (next_tuple(link, tuple, parse) != CS_SUCCESS)
570 first_tuple(link, tuple, parse);
571 if (parse->version_1.ns > 3) {
572 station_addr = parse->version_1.str + parse->version_1.ofs[3];
573 if (cvt_ascii_address(dev, station_addr) == 0) { 565 if (cvt_ascii_address(dev, station_addr) == 0) {
574 rc = 0; 566 rc = 0;
575 goto free_cfg_mem; 567 goto free_cfg_mem;
@@ -744,15 +736,12 @@ static int smc_setup(struct pcmcia_device *link)
744 } 736 }
745 } 737 }
746 /* Try the third string in the Version 1 Version/ID tuple. */ 738 /* Try the third string in the Version 1 Version/ID tuple. */
747 tuple->DesiredTuple = CISTPL_VERS_1; 739 if (link->prod_id[2]) {
748 if (first_tuple(link, tuple, parse) != CS_SUCCESS) { 740 station_addr = link->prod_id[2];
749 rc = -1; 741 if (cvt_ascii_address(dev, station_addr) == 0) {
750 goto free_cfg_mem; 742 rc = 0;
751 } 743 goto free_cfg_mem;
752 station_addr = parse->version_1.str + parse->version_1.ofs[2]; 744 }
753 if (cvt_ascii_address(dev, station_addr) == 0) {
754 rc = 0;
755 goto free_cfg_mem;
756 } 745 }
757 746
758 rc = -1; 747 rc = -1;
@@ -970,10 +959,6 @@ static int smc91c92_config(struct pcmcia_device *link)
970{ 959{
971 struct net_device *dev = link->priv; 960 struct net_device *dev = link->priv;
972 struct smc_private *smc = netdev_priv(dev); 961 struct smc_private *smc = netdev_priv(dev);
973 struct smc_cfg_mem *cfg_mem;
974 tuple_t *tuple;
975 cisparse_t *parse;
976 u_char *buf;
977 char *name; 962 char *name;
978 int i, j, rev; 963 int i, j, rev;
979 kio_addr_t ioaddr; 964 kio_addr_t ioaddr;
@@ -981,30 +966,8 @@ static int smc91c92_config(struct pcmcia_device *link)
981 966
982 DEBUG(0, "smc91c92_config(0x%p)\n", link); 967 DEBUG(0, "smc91c92_config(0x%p)\n", link);
983 968
984 cfg_mem = kmalloc(sizeof(struct smc_cfg_mem), GFP_KERNEL); 969 smc->manfid = link->manf_id;
985 if (!cfg_mem) 970 smc->cardid = link->card_id;
986 goto config_failed;
987
988 tuple = &cfg_mem->tuple;
989 parse = &cfg_mem->parse;
990 buf = cfg_mem->buf;
991
992 tuple->Attributes = tuple->TupleOffset = 0;
993 tuple->TupleData = (cisdata_t *)buf;
994 tuple->TupleDataMax = 64;
995
996 tuple->DesiredTuple = CISTPL_CONFIG;
997 i = first_tuple(link, tuple, parse);
998 CS_EXIT_TEST(i, ParseTuple, config_failed);
999 link->conf.ConfigBase = parse->config.base;
1000 link->conf.Present = parse->config.rmask[0];
1001
1002 tuple->DesiredTuple = CISTPL_MANFID;
1003 tuple->Attributes = TUPLE_RETURN_COMMON;
1004 if (first_tuple(link, tuple, parse) == CS_SUCCESS) {
1005 smc->manfid = parse->manfid.manf;
1006 smc->cardid = parse->manfid.card;
1007 }
1008 971
1009 if ((smc->manfid == MANFID_OSITECH) && 972 if ((smc->manfid == MANFID_OSITECH) &&
1010 (smc->cardid != PRODID_OSITECH_SEVEN)) { 973 (smc->cardid != PRODID_OSITECH_SEVEN)) {
@@ -1134,14 +1097,12 @@ static int smc91c92_config(struct pcmcia_device *link)
1134 printk(KERN_NOTICE " No MII transceivers found!\n"); 1097 printk(KERN_NOTICE " No MII transceivers found!\n");
1135 } 1098 }
1136 } 1099 }
1137 kfree(cfg_mem);
1138 return 0; 1100 return 0;
1139 1101
1140config_undo: 1102config_undo:
1141 unregister_netdev(dev); 1103 unregister_netdev(dev);
1142config_failed: /* CS_EXIT_TEST() calls jump to here... */ 1104config_failed: /* CS_EXIT_TEST() calls jump to here... */
1143 smc91c92_release(link); 1105 smc91c92_release(link);
1144 kfree(cfg_mem);
1145 return -ENODEV; 1106 return -ENODEV;
1146} /* smc91c92_config */ 1107} /* smc91c92_config */
1147 1108
diff --git a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c
index f3914f58d67f..8478dca3d8d1 100644
--- a/drivers/net/pcmcia/xirc2ps_cs.c
+++ b/drivers/net/pcmcia/xirc2ps_cs.c
@@ -332,6 +332,7 @@ static irqreturn_t xirc2ps_interrupt(int irq, void *dev_id);
332 */ 332 */
333 333
334typedef struct local_info_t { 334typedef struct local_info_t {
335 struct net_device *dev;
335 struct pcmcia_device *p_dev; 336 struct pcmcia_device *p_dev;
336 dev_node_t node; 337 dev_node_t node;
337 struct net_device_stats stats; 338 struct net_device_stats stats;
@@ -353,7 +354,7 @@ typedef struct local_info_t {
353 */ 354 */
354static int do_start_xmit(struct sk_buff *skb, struct net_device *dev); 355static int do_start_xmit(struct sk_buff *skb, struct net_device *dev);
355static void do_tx_timeout(struct net_device *dev); 356static void do_tx_timeout(struct net_device *dev);
356static void xirc2ps_tx_timeout_task(void *data); 357static void xirc2ps_tx_timeout_task(struct work_struct *work);
357static struct net_device_stats *do_get_stats(struct net_device *dev); 358static struct net_device_stats *do_get_stats(struct net_device *dev);
358static void set_addresses(struct net_device *dev); 359static void set_addresses(struct net_device *dev);
359static void set_multicast_list(struct net_device *dev); 360static void set_multicast_list(struct net_device *dev);
@@ -567,6 +568,7 @@ xirc2ps_probe(struct pcmcia_device *link)
567 if (!dev) 568 if (!dev)
568 return -ENOMEM; 569 return -ENOMEM;
569 local = netdev_priv(dev); 570 local = netdev_priv(dev);
571 local->dev = dev;
570 local->p_dev = link; 572 local->p_dev = link;
571 link->priv = dev; 573 link->priv = dev;
572 574
@@ -591,7 +593,7 @@ xirc2ps_probe(struct pcmcia_device *link)
591#ifdef HAVE_TX_TIMEOUT 593#ifdef HAVE_TX_TIMEOUT
592 dev->tx_timeout = do_tx_timeout; 594 dev->tx_timeout = do_tx_timeout;
593 dev->watchdog_timeo = TX_TIMEOUT; 595 dev->watchdog_timeo = TX_TIMEOUT;
594 INIT_WORK(&local->tx_timeout_task, xirc2ps_tx_timeout_task, dev); 596 INIT_WORK(&local->tx_timeout_task, xirc2ps_tx_timeout_task);
595#endif 597#endif
596 598
597 return xirc2ps_config(link); 599 return xirc2ps_config(link);
@@ -707,22 +709,11 @@ set_card_type(struct pcmcia_device *link, const void *s)
707 * Returns: true if this is a CE2 709 * Returns: true if this is a CE2
708 */ 710 */
709static int 711static int
710has_ce2_string(struct pcmcia_device * link) 712has_ce2_string(struct pcmcia_device * p_dev)
711{ 713{
712 tuple_t tuple; 714 if (p_dev->prod_id[2] && strstr(p_dev->prod_id[2], "CE2"))
713 cisparse_t parse; 715 return 1;
714 u_char buf[256]; 716 return 0;
715
716 tuple.Attributes = 0;
717 tuple.TupleData = buf;
718 tuple.TupleDataMax = 254;
719 tuple.TupleOffset = 0;
720 tuple.DesiredTuple = CISTPL_VERS_1;
721 if (!first_tuple(link, &tuple, &parse) && parse.version_1.ns > 2) {
722 if (strstr(parse.version_1.str + parse.version_1.ofs[2], "CE2"))
723 return 1;
724 }
725 return 0;
726} 717}
727 718
728/**************** 719/****************
@@ -792,13 +783,6 @@ xirc2ps_config(struct pcmcia_device * link)
792 goto failure; 783 goto failure;
793 } 784 }
794 785
795 /* get configuration stuff */
796 tuple.DesiredTuple = CISTPL_CONFIG;
797 if ((err=first_tuple(link, &tuple, &parse)))
798 goto cis_error;
799 link->conf.ConfigBase = parse.config.base;
800 link->conf.Present = parse.config.rmask[0];
801
802 /* get the ethernet address from the CIS */ 786 /* get the ethernet address from the CIS */
803 tuple.DesiredTuple = CISTPL_FUNCE; 787 tuple.DesiredTuple = CISTPL_FUNCE;
804 for (err = first_tuple(link, &tuple, &parse); !err; 788 for (err = first_tuple(link, &tuple, &parse); !err;
@@ -1062,8 +1046,6 @@ xirc2ps_config(struct pcmcia_device * link)
1062 xirc2ps_release(link); 1046 xirc2ps_release(link);
1063 return -ENODEV; 1047 return -ENODEV;
1064 1048
1065 cis_error:
1066 printk(KNOT_XIRC "unable to parse CIS\n");
1067 failure: 1049 failure:
1068 return -ENODEV; 1050 return -ENODEV;
1069} /* xirc2ps_config */ 1051} /* xirc2ps_config */
@@ -1344,9 +1326,11 @@ xirc2ps_interrupt(int irq, void *dev_id)
1344/*====================================================================*/ 1326/*====================================================================*/
1345 1327
1346static void 1328static void
1347xirc2ps_tx_timeout_task(void *data) 1329xirc2ps_tx_timeout_task(struct work_struct *work)
1348{ 1330{
1349 struct net_device *dev = data; 1331 local_info_t *local =
1332 container_of(work, local_info_t, tx_timeout_task);
1333 struct net_device *dev = local->dev;
1350 /* reset the card */ 1334 /* reset the card */
1351 do_reset(dev,1); 1335 do_reset(dev,1);
1352 dev->trans_start = jiffies; 1336 dev->trans_start = jiffies;
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index b79ec0d7480f..f994f129f3d8 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -56,13 +56,19 @@ config SMSC_PHY
56 ---help--- 56 ---help---
57 Currently supports the LAN83C185 PHY 57 Currently supports the LAN83C185 PHY
58 58
59config BROADCOM_PHY
60 tristate "Drivers for Broadcom PHYs"
61 depends on PHYLIB
62 ---help---
63 Currently supports the BCM5411, BCM5421 and BCM5461 PHYs.
64
59config FIXED_PHY 65config FIXED_PHY
60 tristate "Drivers for PHY emulation on fixed speed/link" 66 tristate "Drivers for PHY emulation on fixed speed/link"
61 depends on PHYLIB 67 depends on PHYLIB
62 ---help--- 68 ---help---
63 Adds the driver to PHY layer to cover the boards that do not have any PHY bound, 69 Adds the driver to PHY layer to cover the boards that do not have any PHY bound,
64 but with the ability to manipulate with speed/link in software. The relavant MII 70 but with the ability to manipulate the speed/link in software. The relevant MII
65 speed/duplex parameters could be effectively handled in user-specified fuction. 71 speed/duplex parameters could be effectively handled in a user-specified function.
66 Currently tested with mpc866ads. 72 Currently tested with mpc866ads.
67 73
68config FIXED_MII_10_FDX 74config FIXED_MII_10_FDX
diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
index 320f8323123f..bcd1efbd2a18 100644
--- a/drivers/net/phy/Makefile
+++ b/drivers/net/phy/Makefile
@@ -10,4 +10,5 @@ obj-$(CONFIG_LXT_PHY) += lxt.o
10obj-$(CONFIG_QSEMI_PHY) += qsemi.o 10obj-$(CONFIG_QSEMI_PHY) += qsemi.o
11obj-$(CONFIG_SMSC_PHY) += smsc.o 11obj-$(CONFIG_SMSC_PHY) += smsc.o
12obj-$(CONFIG_VITESSE_PHY) += vitesse.o 12obj-$(CONFIG_VITESSE_PHY) += vitesse.o
13obj-$(CONFIG_BROADCOM_PHY) += broadcom.o
13obj-$(CONFIG_FIXED_PHY) += fixed.o 14obj-$(CONFIG_FIXED_PHY) += fixed.o
diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c
new file mode 100644
index 000000000000..29666c85ed55
--- /dev/null
+++ b/drivers/net/phy/broadcom.c
@@ -0,0 +1,175 @@
1/*
2 * drivers/net/phy/broadcom.c
3 *
4 * Broadcom BCM5411, BCM5421 and BCM5461 Gigabit Ethernet
5 * transceivers.
6 *
7 * Copyright (c) 2006 Maciej W. Rozycki
8 *
9 * Inspired by code written by Amy Fong.
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version
14 * 2 of the License, or (at your option) any later version.
15 */
16
17#include <linux/module.h>
18#include <linux/phy.h>
19
20#define MII_BCM54XX_ECR 0x10 /* BCM54xx extended control register */
21#define MII_BCM54XX_ECR_IM 0x1000 /* Interrupt mask */
22#define MII_BCM54XX_ECR_IF 0x0800 /* Interrupt force */
23
24#define MII_BCM54XX_ESR 0x11 /* BCM54xx extended status register */
25#define MII_BCM54XX_ESR_IS 0x1000 /* Interrupt status */
26
27#define MII_BCM54XX_ISR 0x1a /* BCM54xx interrupt status register */
28#define MII_BCM54XX_IMR 0x1b /* BCM54xx interrupt mask register */
29#define MII_BCM54XX_INT_CRCERR 0x0001 /* CRC error */
30#define MII_BCM54XX_INT_LINK 0x0002 /* Link status changed */
31#define MII_BCM54XX_INT_SPEED 0x0004 /* Link speed change */
32#define MII_BCM54XX_INT_DUPLEX 0x0008 /* Duplex mode changed */
33#define MII_BCM54XX_INT_LRS 0x0010 /* Local receiver status changed */
34#define MII_BCM54XX_INT_RRS 0x0020 /* Remote receiver status changed */
35#define MII_BCM54XX_INT_SSERR 0x0040 /* Scrambler synchronization error */
36#define MII_BCM54XX_INT_UHCD 0x0080 /* Unsupported HCD negotiated */
37#define MII_BCM54XX_INT_NHCD 0x0100 /* No HCD */
38#define MII_BCM54XX_INT_NHCDL 0x0200 /* No HCD link */
39#define MII_BCM54XX_INT_ANPR 0x0400 /* Auto-negotiation page received */
40#define MII_BCM54XX_INT_LC 0x0800 /* All counters below 128 */
41#define MII_BCM54XX_INT_HC 0x1000 /* Counter above 32768 */
42#define MII_BCM54XX_INT_MDIX 0x2000 /* MDIX status change */
43#define MII_BCM54XX_INT_PSERR 0x4000 /* Pair swap error */
44
45MODULE_DESCRIPTION("Broadcom PHY driver");
46MODULE_AUTHOR("Maciej W. Rozycki");
47MODULE_LICENSE("GPL");
48
49static int bcm54xx_config_init(struct phy_device *phydev)
50{
51 int reg, err;
52
53 reg = phy_read(phydev, MII_BCM54XX_ECR);
54 if (reg < 0)
55 return reg;
56
57 /* Mask interrupts globally. */
58 reg |= MII_BCM54XX_ECR_IM;
59 err = phy_write(phydev, MII_BCM54XX_ECR, reg);
60 if (err < 0)
61 return err;
62
63 /* Unmask events we are interested in. */
64 reg = ~(MII_BCM54XX_INT_DUPLEX |
65 MII_BCM54XX_INT_SPEED |
66 MII_BCM54XX_INT_LINK);
67 err = phy_write(phydev, MII_BCM54XX_IMR, reg);
68 if (err < 0)
69 return err;
70 return 0;
71}
72
73static int bcm54xx_ack_interrupt(struct phy_device *phydev)
74{
75 int reg;
76
77 /* Clear pending interrupts. */
78 reg = phy_read(phydev, MII_BCM54XX_ISR);
79 if (reg < 0)
80 return reg;
81
82 return 0;
83}
84
85static int bcm54xx_config_intr(struct phy_device *phydev)
86{
87 int reg, err;
88
89 reg = phy_read(phydev, MII_BCM54XX_ECR);
90 if (reg < 0)
91 return reg;
92
93 if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
94 reg &= ~MII_BCM54XX_ECR_IM;
95 else
96 reg |= MII_BCM54XX_ECR_IM;
97
98 err = phy_write(phydev, MII_BCM54XX_ECR, reg);
99 return err;
100}
101
102static struct phy_driver bcm5411_driver = {
103 .phy_id = 0x00206070,
104 .phy_id_mask = 0xfffffff0,
105 .name = "Broadcom BCM5411",
106 .features = PHY_GBIT_FEATURES,
107 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
108 .config_init = bcm54xx_config_init,
109 .config_aneg = genphy_config_aneg,
110 .read_status = genphy_read_status,
111 .ack_interrupt = bcm54xx_ack_interrupt,
112 .config_intr = bcm54xx_config_intr,
113 .driver = { .owner = THIS_MODULE },
114};
115
116static struct phy_driver bcm5421_driver = {
117 .phy_id = 0x002060e0,
118 .phy_id_mask = 0xfffffff0,
119 .name = "Broadcom BCM5421",
120 .features = PHY_GBIT_FEATURES,
121 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
122 .config_init = bcm54xx_config_init,
123 .config_aneg = genphy_config_aneg,
124 .read_status = genphy_read_status,
125 .ack_interrupt = bcm54xx_ack_interrupt,
126 .config_intr = bcm54xx_config_intr,
127 .driver = { .owner = THIS_MODULE },
128};
129
130static struct phy_driver bcm5461_driver = {
131 .phy_id = 0x002060c0,
132 .phy_id_mask = 0xfffffff0,
133 .name = "Broadcom BCM5461",
134 .features = PHY_GBIT_FEATURES,
135 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
136 .config_init = bcm54xx_config_init,
137 .config_aneg = genphy_config_aneg,
138 .read_status = genphy_read_status,
139 .ack_interrupt = bcm54xx_ack_interrupt,
140 .config_intr = bcm54xx_config_intr,
141 .driver = { .owner = THIS_MODULE },
142};
143
144static int __init broadcom_init(void)
145{
146 int ret;
147
148 ret = phy_driver_register(&bcm5411_driver);
149 if (ret)
150 goto out_5411;
151 ret = phy_driver_register(&bcm5421_driver);
152 if (ret)
153 goto out_5421;
154 ret = phy_driver_register(&bcm5461_driver);
155 if (ret)
156 goto out_5461;
157 return ret;
158
159out_5461:
160 phy_driver_unregister(&bcm5421_driver);
161out_5421:
162 phy_driver_unregister(&bcm5411_driver);
163out_5411:
164 return ret;
165}
166
167static void __exit broadcom_exit(void)
168{
169 phy_driver_unregister(&bcm5461_driver);
170 phy_driver_unregister(&bcm5421_driver);
171 phy_driver_unregister(&bcm5411_driver);
172}
173
174module_init(broadcom_init);
175module_exit(broadcom_exit);
diff --git a/drivers/net/phy/fixed.c b/drivers/net/phy/fixed.c
index f14e99276dba..096d4a100bf2 100644
--- a/drivers/net/phy/fixed.c
+++ b/drivers/net/phy/fixed.c
@@ -254,7 +254,7 @@ static int fixed_mdio_register_device(int number, int speed, int duplex)
254 goto device_create_fail; 254 goto device_create_fail;
255 } 255 }
256 256
257 phydev->irq = -1; 257 phydev->irq = PHY_IGNORE_INTERRUPT;
258 phydev->dev.bus = &mdio_bus_type; 258 phydev->dev.bus = &mdio_bus_type;
259 259
260 if(number) 260 if(number)
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 3af9fcf76c81..e175f3910b18 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -7,6 +7,7 @@
7 * Author: Andy Fleming 7 * Author: Andy Fleming
8 * 8 *
9 * Copyright (c) 2004 Freescale Semiconductor, Inc. 9 * Copyright (c) 2004 Freescale Semiconductor, Inc.
10 * Copyright (c) 2006 Maciej W. Rozycki
10 * 11 *
11 * This program is free software; you can redistribute it and/or modify it 12 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the 13 * under the terms of the GNU General Public License as published by the
@@ -32,6 +33,8 @@
32#include <linux/mii.h> 33#include <linux/mii.h>
33#include <linux/ethtool.h> 34#include <linux/ethtool.h>
34#include <linux/phy.h> 35#include <linux/phy.h>
36#include <linux/timer.h>
37#include <linux/workqueue.h>
35 38
36#include <asm/io.h> 39#include <asm/io.h>
37#include <asm/irq.h> 40#include <asm/irq.h>
@@ -394,7 +397,7 @@ out_unlock:
394EXPORT_SYMBOL(phy_start_aneg); 397EXPORT_SYMBOL(phy_start_aneg);
395 398
396 399
397static void phy_change(void *data); 400static void phy_change(struct work_struct *work);
398static void phy_timer(unsigned long data); 401static void phy_timer(unsigned long data);
399 402
400/* phy_start_machine: 403/* phy_start_machine:
@@ -484,6 +487,9 @@ static irqreturn_t phy_interrupt(int irq, void *phy_dat)
484{ 487{
485 struct phy_device *phydev = phy_dat; 488 struct phy_device *phydev = phy_dat;
486 489
490 if (PHY_HALTED == phydev->state)
491 return IRQ_NONE; /* It can't be ours. */
492
487 /* The MDIO bus is not allowed to be written in interrupt 493 /* The MDIO bus is not allowed to be written in interrupt
488 * context, so we need to disable the irq here. A work 494 * context, so we need to disable the irq here. A work
489 * queue will write the PHY to disable and clear the 495 * queue will write the PHY to disable and clear the
@@ -549,7 +555,7 @@ int phy_start_interrupts(struct phy_device *phydev)
549{ 555{
550 int err = 0; 556 int err = 0;
551 557
552 INIT_WORK(&phydev->phy_queue, phy_change, phydev); 558 INIT_WORK(&phydev->phy_queue, phy_change);
553 559
554 if (request_irq(phydev->irq, phy_interrupt, 560 if (request_irq(phydev->irq, phy_interrupt,
555 IRQF_SHARED, 561 IRQF_SHARED,
@@ -577,6 +583,12 @@ int phy_stop_interrupts(struct phy_device *phydev)
577 if (err) 583 if (err)
578 phy_error(phydev); 584 phy_error(phydev);
579 585
586 /*
587 * Finish any pending work; we might have been scheduled
588 * to be called from keventd ourselves, though.
589 */
590 run_scheduled_work(&phydev->phy_queue);
591
580 free_irq(phydev->irq, phydev); 592 free_irq(phydev->irq, phydev);
581 593
582 return err; 594 return err;
@@ -585,10 +597,11 @@ EXPORT_SYMBOL(phy_stop_interrupts);
585 597
586 598
587/* Scheduled by the phy_interrupt/timer to handle PHY changes */ 599/* Scheduled by the phy_interrupt/timer to handle PHY changes */
588static void phy_change(void *data) 600static void phy_change(struct work_struct *work)
589{ 601{
590 int err; 602 int err;
591 struct phy_device *phydev = data; 603 struct phy_device *phydev =
604 container_of(work, struct phy_device, phy_queue);
592 605
593 err = phy_disable_interrupts(phydev); 606 err = phy_disable_interrupts(phydev);
594 607
@@ -603,7 +616,8 @@ static void phy_change(void *data)
603 enable_irq(phydev->irq); 616 enable_irq(phydev->irq);
604 617
605 /* Reenable interrupts */ 618 /* Reenable interrupts */
606 err = phy_config_interrupt(phydev, PHY_INTERRUPT_ENABLED); 619 if (PHY_HALTED != phydev->state)
620 err = phy_config_interrupt(phydev, PHY_INTERRUPT_ENABLED);
607 621
608 if (err) 622 if (err)
609 goto irq_enable_err; 623 goto irq_enable_err;
@@ -624,18 +638,24 @@ void phy_stop(struct phy_device *phydev)
624 if (PHY_HALTED == phydev->state) 638 if (PHY_HALTED == phydev->state)
625 goto out_unlock; 639 goto out_unlock;
626 640
627 if (phydev->irq != PHY_POLL) { 641 phydev->state = PHY_HALTED;
628 /* Clear any pending interrupts */
629 phy_clear_interrupt(phydev);
630 642
643 if (phydev->irq != PHY_POLL) {
631 /* Disable PHY Interrupts */ 644 /* Disable PHY Interrupts */
632 phy_config_interrupt(phydev, PHY_INTERRUPT_DISABLED); 645 phy_config_interrupt(phydev, PHY_INTERRUPT_DISABLED);
633 }
634 646
635 phydev->state = PHY_HALTED; 647 /* Clear any pending interrupts */
648 phy_clear_interrupt(phydev);
649 }
636 650
637out_unlock: 651out_unlock:
638 spin_unlock(&phydev->lock); 652 spin_unlock(&phydev->lock);
653
654 /*
655 * Cannot call flush_scheduled_work() here as desired because
656 * of rtnl_lock(), but PHY_HALTED shall guarantee phy_change()
657 * will not reenable interrupts.
658 */
639} 659}
640 660
641 661
@@ -693,60 +713,57 @@ static void phy_timer(unsigned long data)
693 713
694 break; 714 break;
695 case PHY_AN: 715 case PHY_AN:
716 err = phy_read_status(phydev);
717
718 if (err < 0)
719 break;
720
721 /* If the link is down, give up on
722 * negotiation for now */
723 if (!phydev->link) {
724 phydev->state = PHY_NOLINK;
725 netif_carrier_off(phydev->attached_dev);
726 phydev->adjust_link(phydev->attached_dev);
727 break;
728 }
729
696 /* Check if negotiation is done. Break 730 /* Check if negotiation is done. Break
697 * if there's an error */ 731 * if there's an error */
698 err = phy_aneg_done(phydev); 732 err = phy_aneg_done(phydev);
699 if (err < 0) 733 if (err < 0)
700 break; 734 break;
701 735
702 /* If auto-negotiation is done, we change to 736 /* If AN is done, we're running */
703 * either RUNNING, or NOLINK */
704 if (err > 0) { 737 if (err > 0) {
705 err = phy_read_status(phydev); 738 phydev->state = PHY_RUNNING;
739 netif_carrier_on(phydev->attached_dev);
740 phydev->adjust_link(phydev->attached_dev);
741
742 } else if (0 == phydev->link_timeout--) {
743 int idx;
706 744
707 if (err) 745 needs_aneg = 1;
746 /* If we have the magic_aneg bit,
747 * we try again */
748 if (phydev->drv->flags & PHY_HAS_MAGICANEG)
708 break; 749 break;
709 750
710 if (phydev->link) { 751 /* The timer expired, and we still
711 phydev->state = PHY_RUNNING; 752 * don't have a setting, so we try
712 netif_carrier_on(phydev->attached_dev); 753 * forcing it until we find one that
713 } else { 754 * works, starting from the fastest speed,
714 phydev->state = PHY_NOLINK; 755 * and working our way down */
715 netif_carrier_off(phydev->attached_dev); 756 idx = phy_find_valid(0, phydev->supported);
716 }
717 757
718 phydev->adjust_link(phydev->attached_dev); 758 phydev->speed = settings[idx].speed;
759 phydev->duplex = settings[idx].duplex;
719 760
720 } else if (0 == phydev->link_timeout--) { 761 phydev->autoneg = AUTONEG_DISABLE;
721 /* The counter expired, so either we
722 * switch to forced mode, or the
723 * magic_aneg bit exists, and we try aneg
724 * again */
725 if (!(phydev->drv->flags & PHY_HAS_MAGICANEG)) {
726 int idx;
727
728 /* We'll start from the
729 * fastest speed, and work
730 * our way down */
731 idx = phy_find_valid(0,
732 phydev->supported);
733
734 phydev->speed = settings[idx].speed;
735 phydev->duplex = settings[idx].duplex;
736
737 phydev->autoneg = AUTONEG_DISABLE;
738 phydev->state = PHY_FORCING;
739 phydev->link_timeout =
740 PHY_FORCE_TIMEOUT;
741
742 pr_info("Trying %d/%s\n",
743 phydev->speed,
744 DUPLEX_FULL ==
745 phydev->duplex ?
746 "FULL" : "HALF");
747 }
748 762
749 needs_aneg = 1; 763 pr_info("Trying %d/%s\n", phydev->speed,
764 DUPLEX_FULL ==
765 phydev->duplex ?
766 "FULL" : "HALF");
750 } 767 }
751 break; 768 break;
752 case PHY_NOLINK: 769 case PHY_NOLINK:
@@ -762,7 +779,7 @@ static void phy_timer(unsigned long data)
762 } 779 }
763 break; 780 break;
764 case PHY_FORCING: 781 case PHY_FORCING:
765 err = phy_read_status(phydev); 782 err = genphy_update_link(phydev);
766 783
767 if (err) 784 if (err)
768 break; 785 break;
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 3bbd5e70c209..b01fc70a57db 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -59,6 +59,7 @@ struct phy_device* phy_device_create(struct mii_bus *bus, int addr, int phy_id)
59 dev->duplex = -1; 59 dev->duplex = -1;
60 dev->pause = dev->asym_pause = 0; 60 dev->pause = dev->asym_pause = 0;
61 dev->link = 1; 61 dev->link = 1;
62 dev->interface = PHY_INTERFACE_MODE_GMII;
62 63
63 dev->autoneg = AUTONEG_ENABLE; 64 dev->autoneg = AUTONEG_ENABLE;
64 65
@@ -137,11 +138,12 @@ void phy_prepare_link(struct phy_device *phydev,
137 * the desired functionality. 138 * the desired functionality.
138 */ 139 */
139struct phy_device * phy_connect(struct net_device *dev, const char *phy_id, 140struct phy_device * phy_connect(struct net_device *dev, const char *phy_id,
140 void (*handler)(struct net_device *), u32 flags) 141 void (*handler)(struct net_device *), u32 flags,
142 u32 interface)
141{ 143{
142 struct phy_device *phydev; 144 struct phy_device *phydev;
143 145
144 phydev = phy_attach(dev, phy_id, flags); 146 phydev = phy_attach(dev, phy_id, flags, interface);
145 147
146 if (IS_ERR(phydev)) 148 if (IS_ERR(phydev))
147 return phydev; 149 return phydev;
@@ -186,7 +188,7 @@ static int phy_compare_id(struct device *dev, void *data)
186} 188}
187 189
188struct phy_device *phy_attach(struct net_device *dev, 190struct phy_device *phy_attach(struct net_device *dev,
189 const char *phy_id, u32 flags) 191 const char *phy_id, u32 flags, u32 interface)
190{ 192{
191 struct bus_type *bus = &mdio_bus_type; 193 struct bus_type *bus = &mdio_bus_type;
192 struct phy_device *phydev; 194 struct phy_device *phydev;
@@ -231,6 +233,20 @@ struct phy_device *phy_attach(struct net_device *dev,
231 233
232 phydev->dev_flags = flags; 234 phydev->dev_flags = flags;
233 235
236 phydev->interface = interface;
237
238 /* Do initial configuration here, now that
239 * we have certain key parameters
240 * (dev_flags and interface) */
241 if (phydev->drv->config_init) {
242 int err;
243
244 err = phydev->drv->config_init(phydev);
245
246 if (err < 0)
247 return ERR_PTR(err);
248 }
249
234 return phydev; 250 return phydev;
235} 251}
236EXPORT_SYMBOL(phy_attach); 252EXPORT_SYMBOL(phy_attach);
@@ -427,6 +443,7 @@ int genphy_update_link(struct phy_device *phydev)
427 443
428 return 0; 444 return 0;
429} 445}
446EXPORT_SYMBOL(genphy_update_link);
430 447
431/* genphy_read_status 448/* genphy_read_status
432 * 449 *
@@ -611,13 +628,8 @@ static int phy_probe(struct device *dev)
611 628
612 spin_unlock(&phydev->lock); 629 spin_unlock(&phydev->lock);
613 630
614 if (err < 0)
615 return err;
616
617 if (phydev->drv->config_init)
618 err = phydev->drv->config_init(phydev);
619
620 return err; 631 return err;
632
621} 633}
622 634
623static int phy_remove(struct device *dev) 635static int phy_remove(struct device *dev)
diff --git a/drivers/net/plip.c b/drivers/net/plip.c
index 71afb274498f..6bb085f54437 100644
--- a/drivers/net/plip.c
+++ b/drivers/net/plip.c
@@ -138,9 +138,9 @@ static const unsigned int net_debug = NET_DEBUG;
138#define PLIP_NIBBLE_WAIT 3000 138#define PLIP_NIBBLE_WAIT 3000
139 139
140/* Bottom halves */ 140/* Bottom halves */
141static void plip_kick_bh(struct net_device *dev); 141static void plip_kick_bh(struct work_struct *work);
142static void plip_bh(struct net_device *dev); 142static void plip_bh(struct work_struct *work);
143static void plip_timer_bh(struct net_device *dev); 143static void plip_timer_bh(struct work_struct *work);
144 144
145/* Interrupt handler */ 145/* Interrupt handler */
146static void plip_interrupt(int irq, void *dev_id); 146static void plip_interrupt(int irq, void *dev_id);
@@ -207,9 +207,10 @@ struct plip_local {
207 207
208struct net_local { 208struct net_local {
209 struct net_device_stats enet_stats; 209 struct net_device_stats enet_stats;
210 struct net_device *dev;
210 struct work_struct immediate; 211 struct work_struct immediate;
211 struct work_struct deferred; 212 struct delayed_work deferred;
212 struct work_struct timer; 213 struct delayed_work timer;
213 struct plip_local snd_data; 214 struct plip_local snd_data;
214 struct plip_local rcv_data; 215 struct plip_local rcv_data;
215 struct pardevice *pardev; 216 struct pardevice *pardev;
@@ -306,11 +307,11 @@ plip_init_netdev(struct net_device *dev)
306 nl->nibble = PLIP_NIBBLE_WAIT; 307 nl->nibble = PLIP_NIBBLE_WAIT;
307 308
308 /* Initialize task queue structures */ 309 /* Initialize task queue structures */
309 INIT_WORK(&nl->immediate, (void (*)(void *))plip_bh, dev); 310 INIT_WORK(&nl->immediate, plip_bh);
310 INIT_WORK(&nl->deferred, (void (*)(void *))plip_kick_bh, dev); 311 INIT_DELAYED_WORK(&nl->deferred, plip_kick_bh);
311 312
312 if (dev->irq == -1) 313 if (dev->irq == -1)
313 INIT_WORK(&nl->timer, (void (*)(void *))plip_timer_bh, dev); 314 INIT_DELAYED_WORK(&nl->timer, plip_timer_bh);
314 315
315 spin_lock_init(&nl->lock); 316 spin_lock_init(&nl->lock);
316} 317}
@@ -319,9 +320,10 @@ plip_init_netdev(struct net_device *dev)
319 This routine is kicked by do_timer(). 320 This routine is kicked by do_timer().
320 Request `plip_bh' to be invoked. */ 321 Request `plip_bh' to be invoked. */
321static void 322static void
322plip_kick_bh(struct net_device *dev) 323plip_kick_bh(struct work_struct *work)
323{ 324{
324 struct net_local *nl = netdev_priv(dev); 325 struct net_local *nl =
326 container_of(work, struct net_local, deferred.work);
325 327
326 if (nl->is_deferred) 328 if (nl->is_deferred)
327 schedule_work(&nl->immediate); 329 schedule_work(&nl->immediate);
@@ -362,9 +364,9 @@ static const plip_func connection_state_table[] =
362 364
363/* Bottom half handler of PLIP. */ 365/* Bottom half handler of PLIP. */
364static void 366static void
365plip_bh(struct net_device *dev) 367plip_bh(struct work_struct *work)
366{ 368{
367 struct net_local *nl = netdev_priv(dev); 369 struct net_local *nl = container_of(work, struct net_local, immediate);
368 struct plip_local *snd = &nl->snd_data; 370 struct plip_local *snd = &nl->snd_data;
369 struct plip_local *rcv = &nl->rcv_data; 371 struct plip_local *rcv = &nl->rcv_data;
370 plip_func f; 372 plip_func f;
@@ -372,20 +374,21 @@ plip_bh(struct net_device *dev)
372 374
373 nl->is_deferred = 0; 375 nl->is_deferred = 0;
374 f = connection_state_table[nl->connection]; 376 f = connection_state_table[nl->connection];
375 if ((r = (*f)(dev, nl, snd, rcv)) != OK 377 if ((r = (*f)(nl->dev, nl, snd, rcv)) != OK
376 && (r = plip_bh_timeout_error(dev, nl, snd, rcv, r)) != OK) { 378 && (r = plip_bh_timeout_error(nl->dev, nl, snd, rcv, r)) != OK) {
377 nl->is_deferred = 1; 379 nl->is_deferred = 1;
378 schedule_delayed_work(&nl->deferred, 1); 380 schedule_delayed_work(&nl->deferred, 1);
379 } 381 }
380} 382}
381 383
382static void 384static void
383plip_timer_bh(struct net_device *dev) 385plip_timer_bh(struct work_struct *work)
384{ 386{
385 struct net_local *nl = netdev_priv(dev); 387 struct net_local *nl =
388 container_of(work, struct net_local, timer.work);
386 389
387 if (!(atomic_read (&nl->kill_timer))) { 390 if (!(atomic_read (&nl->kill_timer))) {
388 plip_interrupt (-1, dev); 391 plip_interrupt (-1, nl->dev);
389 392
390 schedule_delayed_work(&nl->timer, 1); 393 schedule_delayed_work(&nl->timer, 1);
391 } 394 }
@@ -1284,6 +1287,7 @@ static void plip_attach (struct parport *port)
1284 } 1287 }
1285 1288
1286 nl = netdev_priv(dev); 1289 nl = netdev_priv(dev);
1290 nl->dev = dev;
1287 nl->pardev = parport_register_device(port, name, plip_preempt, 1291 nl->pardev = parport_register_device(port, name, plip_preempt,
1288 plip_wakeup, plip_interrupt, 1292 plip_wakeup, plip_interrupt,
1289 0, dev); 1293 0, dev);
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index f5802e7b08e9..c6de566188e4 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -860,7 +860,7 @@ static int __init ppp_init(void)
860 err = PTR_ERR(ppp_class); 860 err = PTR_ERR(ppp_class);
861 goto out_chrdev; 861 goto out_chrdev;
862 } 862 }
863 class_device_create(ppp_class, NULL, MKDEV(PPP_MAJOR, 0), NULL, "ppp"); 863 device_create(ppp_class, NULL, MKDEV(PPP_MAJOR, 0), "ppp");
864 } 864 }
865 865
866out: 866out:
@@ -2675,7 +2675,7 @@ static void __exit ppp_cleanup(void)
2675 cardmap_destroy(&all_ppp_units); 2675 cardmap_destroy(&all_ppp_units);
2676 if (unregister_chrdev(PPP_MAJOR, "ppp") != 0) 2676 if (unregister_chrdev(PPP_MAJOR, "ppp") != 0)
2677 printk(KERN_ERR "PPP: failed to unregister PPP device\n"); 2677 printk(KERN_ERR "PPP: failed to unregister PPP device\n");
2678 class_device_destroy(ppp_class, MKDEV(PPP_MAJOR, 0)); 2678 device_destroy(ppp_class, MKDEV(PPP_MAJOR, 0));
2679 class_destroy(ppp_class); 2679 class_destroy(ppp_class);
2680} 2680}
2681 2681
diff --git a/drivers/net/pppoe.c b/drivers/net/pppoe.c
index 0adee733b761..315d5c3fc66a 100644
--- a/drivers/net/pppoe.c
+++ b/drivers/net/pppoe.c
@@ -393,7 +393,7 @@ static int pppoe_rcv(struct sk_buff *skb,
393 393
394 po = get_item((unsigned long) ph->sid, eth_hdr(skb)->h_source); 394 po = get_item((unsigned long) ph->sid, eth_hdr(skb)->h_source);
395 if (po != NULL) 395 if (po != NULL)
396 return sk_receive_skb(sk_pppox(po), skb); 396 return sk_receive_skb(sk_pppox(po), skb, 0);
397drop: 397drop:
398 kfree_skb(skb); 398 kfree_skb(skb);
399out: 399out:
diff --git a/drivers/net/qla3xxx.c b/drivers/net/qla3xxx.c
index ec640f6229ae..d79d141a601d 100644
--- a/drivers/net/qla3xxx.c
+++ b/drivers/net/qla3xxx.c
@@ -2008,7 +2008,7 @@ static irqreturn_t ql3xxx_isr(int irq, void *dev_id)
2008 "%s: Another function issued a reset to the " 2008 "%s: Another function issued a reset to the "
2009 "chip. ISR value = %x.\n", ndev->name, value); 2009 "chip. ISR value = %x.\n", ndev->name, value);
2010 } 2010 }
2011 queue_work(qdev->workqueue, &qdev->reset_work); 2011 queue_delayed_work(qdev->workqueue, &qdev->reset_work, 0);
2012 spin_unlock(&qdev->adapter_lock); 2012 spin_unlock(&qdev->adapter_lock);
2013 } else if (value & ISP_IMR_DISABLE_CMPL_INT) { 2013 } else if (value & ISP_IMR_DISABLE_CMPL_INT) {
2014 ql_disable_interrupts(qdev); 2014 ql_disable_interrupts(qdev);
@@ -3182,11 +3182,13 @@ static void ql3xxx_tx_timeout(struct net_device *ndev)
3182 /* 3182 /*
3183 * Wake up the worker to process this event. 3183 * Wake up the worker to process this event.
3184 */ 3184 */
3185 queue_work(qdev->workqueue, &qdev->tx_timeout_work); 3185 queue_delayed_work(qdev->workqueue, &qdev->tx_timeout_work, 0);
3186} 3186}
3187 3187
3188static void ql_reset_work(struct ql3_adapter *qdev) 3188static void ql_reset_work(struct work_struct *work)
3189{ 3189{
3190 struct ql3_adapter *qdev =
3191 container_of(work, struct ql3_adapter, reset_work.work);
3190 struct net_device *ndev = qdev->ndev; 3192 struct net_device *ndev = qdev->ndev;
3191 u32 value; 3193 u32 value;
3192 struct ql_tx_buf_cb *tx_cb; 3194 struct ql_tx_buf_cb *tx_cb;
@@ -3278,9 +3280,12 @@ static void ql_reset_work(struct ql3_adapter *qdev)
3278 } 3280 }
3279} 3281}
3280 3282
3281static void ql_tx_timeout_work(struct ql3_adapter *qdev) 3283static void ql_tx_timeout_work(struct work_struct *work)
3282{ 3284{
3283 ql_cycle_adapter(qdev,QL_DO_RESET); 3285 struct ql3_adapter *qdev =
3286 container_of(work, struct ql3_adapter, tx_timeout_work.work);
3287
3288 ql_cycle_adapter(qdev, QL_DO_RESET);
3284} 3289}
3285 3290
3286static void ql_get_board_info(struct ql3_adapter *qdev) 3291static void ql_get_board_info(struct ql3_adapter *qdev)
@@ -3459,9 +3464,8 @@ static int __devinit ql3xxx_probe(struct pci_dev *pdev,
3459 netif_stop_queue(ndev); 3464 netif_stop_queue(ndev);
3460 3465
3461 qdev->workqueue = create_singlethread_workqueue(ndev->name); 3466 qdev->workqueue = create_singlethread_workqueue(ndev->name);
3462 INIT_WORK(&qdev->reset_work, (void (*)(void *))ql_reset_work, qdev); 3467 INIT_DELAYED_WORK(&qdev->reset_work, ql_reset_work);
3463 INIT_WORK(&qdev->tx_timeout_work, 3468 INIT_DELAYED_WORK(&qdev->tx_timeout_work, ql_tx_timeout_work);
3464 (void (*)(void *))ql_tx_timeout_work, qdev);
3465 3469
3466 init_timer(&qdev->adapter_timer); 3470 init_timer(&qdev->adapter_timer);
3467 qdev->adapter_timer.function = ql3xxx_timer; 3471 qdev->adapter_timer.function = ql3xxx_timer;
diff --git a/drivers/net/qla3xxx.h b/drivers/net/qla3xxx.h
index 65da2c0bfda6..ea94de7fd071 100644
--- a/drivers/net/qla3xxx.h
+++ b/drivers/net/qla3xxx.h
@@ -1186,8 +1186,8 @@ struct ql3_adapter {
1186 u32 numPorts; 1186 u32 numPorts;
1187 struct net_device_stats stats; 1187 struct net_device_stats stats;
1188 struct workqueue_struct *workqueue; 1188 struct workqueue_struct *workqueue;
1189 struct work_struct reset_work; 1189 struct delayed_work reset_work;
1190 struct work_struct tx_timeout_work; 1190 struct delayed_work tx_timeout_work;
1191 u32 max_frame_size; 1191 u32 max_frame_size;
1192}; 1192};
1193 1193
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 27f90b2139c0..f83b41d4cb0e 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -225,6 +225,7 @@ MODULE_DEVICE_TABLE(pci, rtl8169_pci_tbl);
225 225
226static int rx_copybreak = 200; 226static int rx_copybreak = 200;
227static int use_dac; 227static int use_dac;
228static int ignore_parity_err;
228static struct { 229static struct {
229 u32 msg_enable; 230 u32 msg_enable;
230} debug = { -1 }; 231} debug = { -1 };
@@ -424,6 +425,7 @@ struct ring_info {
424struct rtl8169_private { 425struct rtl8169_private {
425 void __iomem *mmio_addr; /* memory map physical address */ 426 void __iomem *mmio_addr; /* memory map physical address */
426 struct pci_dev *pci_dev; /* Index of PCI device */ 427 struct pci_dev *pci_dev; /* Index of PCI device */
428 struct net_device *dev;
427 struct net_device_stats stats; /* statistics of net device */ 429 struct net_device_stats stats; /* statistics of net device */
428 spinlock_t lock; /* spin lock flag */ 430 spinlock_t lock; /* spin lock flag */
429 u32 msg_enable; 431 u32 msg_enable;
@@ -455,7 +457,7 @@ struct rtl8169_private {
455 void (*phy_reset_enable)(void __iomem *); 457 void (*phy_reset_enable)(void __iomem *);
456 unsigned int (*phy_reset_pending)(void __iomem *); 458 unsigned int (*phy_reset_pending)(void __iomem *);
457 unsigned int (*link_ok)(void __iomem *); 459 unsigned int (*link_ok)(void __iomem *);
458 struct work_struct task; 460 struct delayed_work task;
459 unsigned wol_enabled : 1; 461 unsigned wol_enabled : 1;
460}; 462};
461 463
@@ -469,6 +471,8 @@ module_param(use_dac, int, 0);
469MODULE_PARM_DESC(use_dac, "Enable PCI DAC. Unsafe on 32 bit PCI slot."); 471MODULE_PARM_DESC(use_dac, "Enable PCI DAC. Unsafe on 32 bit PCI slot.");
470module_param_named(debug, debug.msg_enable, int, 0); 472module_param_named(debug, debug.msg_enable, int, 0);
471MODULE_PARM_DESC(debug, "Debug verbosity level (0=none, ..., 16=all)"); 473MODULE_PARM_DESC(debug, "Debug verbosity level (0=none, ..., 16=all)");
474module_param_named(ignore_parity_err, ignore_parity_err, bool, 0);
475MODULE_PARM_DESC(ignore_parity_err, "Ignore PCI parity error as target. Default: false");
472MODULE_LICENSE("GPL"); 476MODULE_LICENSE("GPL");
473MODULE_VERSION(RTL8169_VERSION); 477MODULE_VERSION(RTL8169_VERSION);
474 478
@@ -571,8 +575,8 @@ static void rtl8169_xmii_reset_enable(void __iomem *ioaddr)
571{ 575{
572 unsigned int val; 576 unsigned int val;
573 577
574 val = (mdio_read(ioaddr, MII_BMCR) | BMCR_RESET) & 0xffff; 578 mdio_write(ioaddr, MII_BMCR, BMCR_RESET);
575 mdio_write(ioaddr, MII_BMCR, val); 579 val = mdio_read(ioaddr, MII_BMCR);
576} 580}
577 581
578static void rtl8169_check_link_status(struct net_device *dev, 582static void rtl8169_check_link_status(struct net_device *dev,
@@ -1283,11 +1287,6 @@ static void rtl8169_hw_phy_config(struct net_device *dev)
1283 /* Shazam ! */ 1287 /* Shazam ! */
1284 1288
1285 if (tp->mac_version == RTL_GIGA_MAC_VER_04) { 1289 if (tp->mac_version == RTL_GIGA_MAC_VER_04) {
1286 mdio_write(ioaddr, 31, 0x0001);
1287 mdio_write(ioaddr, 9, 0x273a);
1288 mdio_write(ioaddr, 14, 0x7bfb);
1289 mdio_write(ioaddr, 27, 0x841e);
1290
1291 mdio_write(ioaddr, 31, 0x0002); 1290 mdio_write(ioaddr, 31, 0x0002);
1292 mdio_write(ioaddr, 1, 0x90d0); 1291 mdio_write(ioaddr, 1, 0x90d0);
1293 mdio_write(ioaddr, 31, 0x0000); 1292 mdio_write(ioaddr, 31, 0x0000);
@@ -1406,6 +1405,22 @@ static void rtl8169_release_board(struct pci_dev *pdev, struct net_device *dev,
1406 free_netdev(dev); 1405 free_netdev(dev);
1407} 1406}
1408 1407
1408static void rtl8169_phy_reset(struct net_device *dev,
1409 struct rtl8169_private *tp)
1410{
1411 void __iomem *ioaddr = tp->mmio_addr;
1412 int i;
1413
1414 tp->phy_reset_enable(ioaddr);
1415 for (i = 0; i < 100; i++) {
1416 if (!tp->phy_reset_pending(ioaddr))
1417 return;
1418 msleep(1);
1419 }
1420 if (netif_msg_link(tp))
1421 printk(KERN_ERR "%s: PHY reset failed.\n", dev->name);
1422}
1423
1409static void rtl8169_init_phy(struct net_device *dev, struct rtl8169_private *tp) 1424static void rtl8169_init_phy(struct net_device *dev, struct rtl8169_private *tp)
1410{ 1425{
1411 void __iomem *ioaddr = tp->mmio_addr; 1426 void __iomem *ioaddr = tp->mmio_addr;
@@ -1434,6 +1449,8 @@ static void rtl8169_init_phy(struct net_device *dev, struct rtl8169_private *tp)
1434 1449
1435 rtl8169_link_option(board_idx, &autoneg, &speed, &duplex); 1450 rtl8169_link_option(board_idx, &autoneg, &speed, &duplex);
1436 1451
1452 rtl8169_phy_reset(dev, tp);
1453
1437 rtl8169_set_speed(dev, autoneg, speed, duplex); 1454 rtl8169_set_speed(dev, autoneg, speed, duplex);
1438 1455
1439 if ((RTL_R8(PHYstatus) & TBI_Enable) && netif_msg_link(tp)) 1456 if ((RTL_R8(PHYstatus) & TBI_Enable) && netif_msg_link(tp))
@@ -1473,8 +1490,8 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1473 struct rtl8169_private *tp; 1490 struct rtl8169_private *tp;
1474 struct net_device *dev; 1491 struct net_device *dev;
1475 void __iomem *ioaddr; 1492 void __iomem *ioaddr;
1476 unsigned int i, pm_cap; 1493 unsigned int pm_cap;
1477 int rc; 1494 int i, rc;
1478 1495
1479 if (netif_msg_drv(&debug)) { 1496 if (netif_msg_drv(&debug)) {
1480 printk(KERN_INFO "%s Gigabit Ethernet driver %s loaded\n", 1497 printk(KERN_INFO "%s Gigabit Ethernet driver %s loaded\n",
@@ -1492,6 +1509,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1492 SET_MODULE_OWNER(dev); 1509 SET_MODULE_OWNER(dev);
1493 SET_NETDEV_DEV(dev, &pdev->dev); 1510 SET_NETDEV_DEV(dev, &pdev->dev);
1494 tp = netdev_priv(dev); 1511 tp = netdev_priv(dev);
1512 tp->dev = dev;
1495 tp->msg_enable = netif_msg_init(debug.msg_enable, R8169_MSG_DEFAULT); 1513 tp->msg_enable = netif_msg_init(debug.msg_enable, R8169_MSG_DEFAULT);
1496 1514
1497 /* enable device (incl. PCI PM wakeup and hotplug setup) */ 1515 /* enable device (incl. PCI PM wakeup and hotplug setup) */
@@ -1764,7 +1782,7 @@ static int rtl8169_open(struct net_device *dev)
1764 if (retval < 0) 1782 if (retval < 0)
1765 goto err_free_rx; 1783 goto err_free_rx;
1766 1784
1767 INIT_WORK(&tp->task, NULL, dev); 1785 INIT_DELAYED_WORK(&tp->task, NULL);
1768 1786
1769 rtl8169_hw_start(dev); 1787 rtl8169_hw_start(dev);
1770 1788
@@ -1797,12 +1815,25 @@ static void rtl8169_hw_reset(void __iomem *ioaddr)
1797 RTL_R8(ChipCmd); 1815 RTL_R8(ChipCmd);
1798} 1816}
1799 1817
1800static void 1818static void rtl8169_set_rx_tx_config_registers(struct rtl8169_private *tp)
1801rtl8169_hw_start(struct net_device *dev) 1819{
1820 void __iomem *ioaddr = tp->mmio_addr;
1821 u32 cfg = rtl8169_rx_config;
1822
1823 cfg |= (RTL_R32(RxConfig) & rtl_chip_info[tp->chipset].RxConfigMask);
1824 RTL_W32(RxConfig, cfg);
1825
1826 /* Set DMA burst size and Interframe Gap Time */
1827 RTL_W32(TxConfig, (TX_DMA_BURST << TxDMAShift) |
1828 (InterFrameGap << TxInterFrameGapShift));
1829}
1830
1831static void rtl8169_hw_start(struct net_device *dev)
1802{ 1832{
1803 struct rtl8169_private *tp = netdev_priv(dev); 1833 struct rtl8169_private *tp = netdev_priv(dev);
1804 void __iomem *ioaddr = tp->mmio_addr; 1834 void __iomem *ioaddr = tp->mmio_addr;
1805 struct pci_dev *pdev = tp->pci_dev; 1835 struct pci_dev *pdev = tp->pci_dev;
1836 u16 cmd;
1806 u32 i; 1837 u32 i;
1807 1838
1808 /* Soft reset the chip. */ 1839 /* Soft reset the chip. */
@@ -1815,6 +1846,11 @@ rtl8169_hw_start(struct net_device *dev)
1815 msleep_interruptible(1); 1846 msleep_interruptible(1);
1816 } 1847 }
1817 1848
1849 if (tp->mac_version == RTL_GIGA_MAC_VER_05) {
1850 RTL_W16(CPlusCmd, RTL_R16(CPlusCmd) | PCIMulRW);
1851 pci_write_config_byte(pdev, PCI_CACHE_LINE_SIZE, 0x08);
1852 }
1853
1818 if (tp->mac_version == RTL_GIGA_MAC_VER_13) { 1854 if (tp->mac_version == RTL_GIGA_MAC_VER_13) {
1819 pci_write_config_word(pdev, 0x68, 0x00); 1855 pci_write_config_word(pdev, 0x68, 0x00);
1820 pci_write_config_word(pdev, 0x69, 0x08); 1856 pci_write_config_word(pdev, 0x69, 0x08);
@@ -1822,8 +1858,6 @@ rtl8169_hw_start(struct net_device *dev)
1822 1858
1823 /* Undocumented stuff. */ 1859 /* Undocumented stuff. */
1824 if (tp->mac_version == RTL_GIGA_MAC_VER_05) { 1860 if (tp->mac_version == RTL_GIGA_MAC_VER_05) {
1825 u16 cmd;
1826
1827 /* Realtek's r1000_n.c driver uses '&& 0x01' here. Well... */ 1861 /* Realtek's r1000_n.c driver uses '&& 0x01' here. Well... */
1828 if ((RTL_R8(Config2) & 0x07) & 0x01) 1862 if ((RTL_R8(Config2) & 0x07) & 0x01)
1829 RTL_W32(0x7c, 0x0007ffff); 1863 RTL_W32(0x7c, 0x0007ffff);
@@ -1835,23 +1869,29 @@ rtl8169_hw_start(struct net_device *dev)
1835 pci_write_config_word(pdev, PCI_COMMAND, cmd); 1869 pci_write_config_word(pdev, PCI_COMMAND, cmd);
1836 } 1870 }
1837 1871
1838
1839 RTL_W8(Cfg9346, Cfg9346_Unlock); 1872 RTL_W8(Cfg9346, Cfg9346_Unlock);
1873 if ((tp->mac_version == RTL_GIGA_MAC_VER_01) ||
1874 (tp->mac_version == RTL_GIGA_MAC_VER_02) ||
1875 (tp->mac_version == RTL_GIGA_MAC_VER_03) ||
1876 (tp->mac_version == RTL_GIGA_MAC_VER_04))
1877 RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb);
1878
1840 RTL_W8(EarlyTxThres, EarlyTxThld); 1879 RTL_W8(EarlyTxThres, EarlyTxThld);
1841 1880
1842 /* Low hurts. Let's disable the filtering. */ 1881 /* Low hurts. Let's disable the filtering. */
1843 RTL_W16(RxMaxSize, 16383); 1882 RTL_W16(RxMaxSize, 16383);
1844 1883
1845 /* Set Rx Config register */ 1884 if ((tp->mac_version == RTL_GIGA_MAC_VER_01) ||
1846 i = rtl8169_rx_config | 1885 (tp->mac_version == RTL_GIGA_MAC_VER_02) ||
1847 (RTL_R32(RxConfig) & rtl_chip_info[tp->chipset].RxConfigMask); 1886 (tp->mac_version == RTL_GIGA_MAC_VER_03) ||
1848 RTL_W32(RxConfig, i); 1887 (tp->mac_version == RTL_GIGA_MAC_VER_04))
1888 RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb);
1889 rtl8169_set_rx_tx_config_registers(tp);
1849 1890
1850 /* Set DMA burst size and Interframe Gap Time */ 1891 cmd = RTL_R16(CPlusCmd);
1851 RTL_W32(TxConfig, (TX_DMA_BURST << TxDMAShift) | 1892 RTL_W16(CPlusCmd, cmd);
1852 (InterFrameGap << TxInterFrameGapShift));
1853 1893
1854 tp->cp_cmd |= RTL_R16(CPlusCmd) | PCIMulRW; 1894 tp->cp_cmd |= cmd | PCIMulRW;
1855 1895
1856 if ((tp->mac_version == RTL_GIGA_MAC_VER_02) || 1896 if ((tp->mac_version == RTL_GIGA_MAC_VER_02) ||
1857 (tp->mac_version == RTL_GIGA_MAC_VER_03)) { 1897 (tp->mac_version == RTL_GIGA_MAC_VER_03)) {
@@ -1877,7 +1917,15 @@ rtl8169_hw_start(struct net_device *dev)
1877 RTL_W32(TxDescStartAddrLow, ((u64) tp->TxPhyAddr & DMA_32BIT_MASK)); 1917 RTL_W32(TxDescStartAddrLow, ((u64) tp->TxPhyAddr & DMA_32BIT_MASK));
1878 RTL_W32(RxDescAddrHigh, ((u64) tp->RxPhyAddr >> 32)); 1918 RTL_W32(RxDescAddrHigh, ((u64) tp->RxPhyAddr >> 32));
1879 RTL_W32(RxDescAddrLow, ((u64) tp->RxPhyAddr & DMA_32BIT_MASK)); 1919 RTL_W32(RxDescAddrLow, ((u64) tp->RxPhyAddr & DMA_32BIT_MASK));
1880 RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb); 1920
1921 if ((tp->mac_version != RTL_GIGA_MAC_VER_01) &&
1922 (tp->mac_version != RTL_GIGA_MAC_VER_02) &&
1923 (tp->mac_version != RTL_GIGA_MAC_VER_03) &&
1924 (tp->mac_version != RTL_GIGA_MAC_VER_04)) {
1925 RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb);
1926 rtl8169_set_rx_tx_config_registers(tp);
1927 }
1928
1881 RTL_W8(Cfg9346, Cfg9346_Lock); 1929 RTL_W8(Cfg9346, Cfg9346_Lock);
1882 1930
1883 /* Initially a 10 us delay. Turned it into a PCI commit. - FR */ 1931 /* Initially a 10 us delay. Turned it into a PCI commit. - FR */
@@ -1972,7 +2020,7 @@ static int rtl8169_alloc_rx_skb(struct pci_dev *pdev, struct sk_buff **sk_buff,
1972 if (!skb) 2020 if (!skb)
1973 goto err_out; 2021 goto err_out;
1974 2022
1975 skb_reserve(skb, align); 2023 skb_reserve(skb, (align - 1) & (u32)skb->data);
1976 *sk_buff = skb; 2024 *sk_buff = skb;
1977 2025
1978 mapping = pci_map_single(pdev, skb->data, rx_buf_sz, 2026 mapping = pci_map_single(pdev, skb->data, rx_buf_sz,
@@ -2087,11 +2135,11 @@ static void rtl8169_tx_clear(struct rtl8169_private *tp)
2087 tp->cur_tx = tp->dirty_tx = 0; 2135 tp->cur_tx = tp->dirty_tx = 0;
2088} 2136}
2089 2137
2090static void rtl8169_schedule_work(struct net_device *dev, void (*task)(void *)) 2138static void rtl8169_schedule_work(struct net_device *dev, work_func_t task)
2091{ 2139{
2092 struct rtl8169_private *tp = netdev_priv(dev); 2140 struct rtl8169_private *tp = netdev_priv(dev);
2093 2141
2094 PREPARE_WORK(&tp->task, task, dev); 2142 PREPARE_DELAYED_WORK(&tp->task, task);
2095 schedule_delayed_work(&tp->task, 4); 2143 schedule_delayed_work(&tp->task, 4);
2096} 2144}
2097 2145
@@ -2110,9 +2158,11 @@ static void rtl8169_wait_for_quiescence(struct net_device *dev)
2110 netif_poll_enable(dev); 2158 netif_poll_enable(dev);
2111} 2159}
2112 2160
2113static void rtl8169_reinit_task(void *_data) 2161static void rtl8169_reinit_task(struct work_struct *work)
2114{ 2162{
2115 struct net_device *dev = _data; 2163 struct rtl8169_private *tp =
2164 container_of(work, struct rtl8169_private, task.work);
2165 struct net_device *dev = tp->dev;
2116 int ret; 2166 int ret;
2117 2167
2118 if (netif_running(dev)) { 2168 if (netif_running(dev)) {
@@ -2135,10 +2185,11 @@ static void rtl8169_reinit_task(void *_data)
2135 } 2185 }
2136} 2186}
2137 2187
2138static void rtl8169_reset_task(void *_data) 2188static void rtl8169_reset_task(struct work_struct *work)
2139{ 2189{
2140 struct net_device *dev = _data; 2190 struct rtl8169_private *tp =
2141 struct rtl8169_private *tp = netdev_priv(dev); 2191 container_of(work, struct rtl8169_private, task.work);
2192 struct net_device *dev = tp->dev;
2142 2193
2143 if (!netif_running(dev)) 2194 if (!netif_running(dev))
2144 return; 2195 return;
@@ -2332,12 +2383,17 @@ static void rtl8169_pcierr_interrupt(struct net_device *dev)
2332 /* 2383 /*
2333 * The recovery sequence below admits a very elaborated explanation: 2384 * The recovery sequence below admits a very elaborated explanation:
2334 * - it seems to work; 2385 * - it seems to work;
2335 * - I did not see what else could be done. 2386 * - I did not see what else could be done;
2387 * - it makes iop3xx happy.
2336 * 2388 *
2337 * Feel free to adjust to your needs. 2389 * Feel free to adjust to your needs.
2338 */ 2390 */
2339 pci_write_config_word(pdev, PCI_COMMAND, 2391 if (ignore_parity_err)
2340 pci_cmd | PCI_COMMAND_SERR | PCI_COMMAND_PARITY); 2392 pci_cmd &= ~PCI_COMMAND_PARITY;
2393 else
2394 pci_cmd |= PCI_COMMAND_SERR | PCI_COMMAND_PARITY;
2395
2396 pci_write_config_word(pdev, PCI_COMMAND, pci_cmd);
2341 2397
2342 pci_write_config_word(pdev, PCI_STATUS, 2398 pci_write_config_word(pdev, PCI_STATUS,
2343 pci_status & (PCI_STATUS_DETECTED_PARITY | 2399 pci_status & (PCI_STATUS_DETECTED_PARITY |
@@ -2351,10 +2407,11 @@ static void rtl8169_pcierr_interrupt(struct net_device *dev)
2351 tp->cp_cmd &= ~PCIDAC; 2407 tp->cp_cmd &= ~PCIDAC;
2352 RTL_W16(CPlusCmd, tp->cp_cmd); 2408 RTL_W16(CPlusCmd, tp->cp_cmd);
2353 dev->features &= ~NETIF_F_HIGHDMA; 2409 dev->features &= ~NETIF_F_HIGHDMA;
2354 rtl8169_schedule_work(dev, rtl8169_reinit_task);
2355 } 2410 }
2356 2411
2357 rtl8169_hw_reset(ioaddr); 2412 rtl8169_hw_reset(ioaddr);
2413
2414 rtl8169_schedule_work(dev, rtl8169_reinit_task);
2358} 2415}
2359 2416
2360static void 2417static void
@@ -2434,7 +2491,7 @@ static inline int rtl8169_try_rx_copy(struct sk_buff **sk_buff, int pkt_size,
2434 2491
2435 skb = dev_alloc_skb(pkt_size + align); 2492 skb = dev_alloc_skb(pkt_size + align);
2436 if (skb) { 2493 if (skb) {
2437 skb_reserve(skb, align); 2494 skb_reserve(skb, (align - 1) & (u32)skb->data);
2438 eth_copy_and_sum(skb, sk_buff[0]->data, pkt_size, 0); 2495 eth_copy_and_sum(skb, sk_buff[0]->data, pkt_size, 0);
2439 *sk_buff = skb; 2496 *sk_buff = skb;
2440 rtl8169_mark_to_asic(desc, rx_buf_sz); 2497 rtl8169_mark_to_asic(desc, rx_buf_sz);
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index 33569ec9dbfc..250cdbeefdfd 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -5872,9 +5872,9 @@ static void s2io_tasklet(unsigned long dev_addr)
5872 * Description: Sets the link status for the adapter 5872 * Description: Sets the link status for the adapter
5873 */ 5873 */
5874 5874
5875static void s2io_set_link(unsigned long data) 5875static void s2io_set_link(struct work_struct *work)
5876{ 5876{
5877 nic_t *nic = (nic_t *) data; 5877 nic_t *nic = container_of(work, nic_t, set_link_task);
5878 struct net_device *dev = nic->dev; 5878 struct net_device *dev = nic->dev;
5879 XENA_dev_config_t __iomem *bar0 = nic->bar0; 5879 XENA_dev_config_t __iomem *bar0 = nic->bar0;
5880 register u64 val64; 5880 register u64 val64;
@@ -6379,10 +6379,10 @@ static int s2io_card_up(nic_t * sp)
6379 * spin lock. 6379 * spin lock.
6380 */ 6380 */
6381 6381
6382static void s2io_restart_nic(unsigned long data) 6382static void s2io_restart_nic(struct work_struct *work)
6383{ 6383{
6384 struct net_device *dev = (struct net_device *) data; 6384 nic_t *sp = container_of(work, nic_t, rst_timer_task);
6385 nic_t *sp = dev->priv; 6385 struct net_device *dev = sp->dev;
6386 6386
6387 s2io_card_down(sp); 6387 s2io_card_down(sp);
6388 if (s2io_card_up(sp)) { 6388 if (s2io_card_up(sp)) {
@@ -6992,10 +6992,8 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
6992 6992
6993 dev->tx_timeout = &s2io_tx_watchdog; 6993 dev->tx_timeout = &s2io_tx_watchdog;
6994 dev->watchdog_timeo = WATCH_DOG_TIMEOUT; 6994 dev->watchdog_timeo = WATCH_DOG_TIMEOUT;
6995 INIT_WORK(&sp->rst_timer_task, 6995 INIT_WORK(&sp->rst_timer_task, s2io_restart_nic);
6996 (void (*)(void *)) s2io_restart_nic, dev); 6996 INIT_WORK(&sp->set_link_task, s2io_set_link);
6997 INIT_WORK(&sp->set_link_task,
6998 (void (*)(void *)) s2io_set_link, sp);
6999 6997
7000 pci_save_state(sp->pdev); 6998 pci_save_state(sp->pdev);
7001 6999
diff --git a/drivers/net/s2io.h b/drivers/net/s2io.h
index 12b719f4d00f..3b0bafd273c8 100644
--- a/drivers/net/s2io.h
+++ b/drivers/net/s2io.h
@@ -1000,7 +1000,7 @@ s2io_msix_fifo_handle(int irq, void *dev_id);
1000static irqreturn_t s2io_isr(int irq, void *dev_id); 1000static irqreturn_t s2io_isr(int irq, void *dev_id);
1001static int verify_xena_quiescence(nic_t *sp, u64 val64, int flag); 1001static int verify_xena_quiescence(nic_t *sp, u64 val64, int flag);
1002static const struct ethtool_ops netdev_ethtool_ops; 1002static const struct ethtool_ops netdev_ethtool_ops;
1003static void s2io_set_link(unsigned long data); 1003static void s2io_set_link(struct work_struct *work);
1004static int s2io_set_swapper(nic_t * sp); 1004static int s2io_set_swapper(nic_t * sp);
1005static void s2io_card_down(nic_t *nic); 1005static void s2io_card_down(nic_t *nic);
1006static int s2io_card_up(nic_t *nic); 1006static int s2io_card_up(nic_t *nic);
diff --git a/drivers/net/seeq8005.c b/drivers/net/seeq8005.c
index d9d0a3a3c558..0d6c95c7aedf 100644
--- a/drivers/net/seeq8005.c
+++ b/drivers/net/seeq8005.c
@@ -750,7 +750,7 @@ int __init init_module(void)
750 return 0; 750 return 0;
751} 751}
752 752
753void cleanup_module(void) 753void __exit cleanup_module(void)
754{ 754{
755 unregister_netdev(dev_seeq); 755 unregister_netdev(dev_seeq);
756 release_region(dev_seeq->base_addr, SEEQ8005_IO_EXTENT); 756 release_region(dev_seeq->base_addr, SEEQ8005_IO_EXTENT);
diff --git a/drivers/net/sis190.c b/drivers/net/sis190.c
index aaba458584fb..b70ed79d4121 100644
--- a/drivers/net/sis190.c
+++ b/drivers/net/sis190.c
@@ -280,6 +280,7 @@ enum sis190_feature {
280struct sis190_private { 280struct sis190_private {
281 void __iomem *mmio_addr; 281 void __iomem *mmio_addr;
282 struct pci_dev *pci_dev; 282 struct pci_dev *pci_dev;
283 struct net_device *dev;
283 struct net_device_stats stats; 284 struct net_device_stats stats;
284 spinlock_t lock; 285 spinlock_t lock;
285 u32 rx_buf_sz; 286 u32 rx_buf_sz;
@@ -897,10 +898,11 @@ static void sis190_hw_start(struct net_device *dev)
897 netif_start_queue(dev); 898 netif_start_queue(dev);
898} 899}
899 900
900static void sis190_phy_task(void * data) 901static void sis190_phy_task(struct work_struct *work)
901{ 902{
902 struct net_device *dev = data; 903 struct sis190_private *tp =
903 struct sis190_private *tp = netdev_priv(dev); 904 container_of(work, struct sis190_private, phy_task);
905 struct net_device *dev = tp->dev;
904 void __iomem *ioaddr = tp->mmio_addr; 906 void __iomem *ioaddr = tp->mmio_addr;
905 int phy_id = tp->mii_if.phy_id; 907 int phy_id = tp->mii_if.phy_id;
906 u16 val; 908 u16 val;
@@ -1047,7 +1049,7 @@ static int sis190_open(struct net_device *dev)
1047 if (rc < 0) 1049 if (rc < 0)
1048 goto err_free_rx_1; 1050 goto err_free_rx_1;
1049 1051
1050 INIT_WORK(&tp->phy_task, sis190_phy_task, dev); 1052 INIT_WORK(&tp->phy_task, sis190_phy_task);
1051 1053
1052 sis190_request_timer(dev); 1054 sis190_request_timer(dev);
1053 1055
@@ -1436,6 +1438,7 @@ static struct net_device * __devinit sis190_init_board(struct pci_dev *pdev)
1436 SET_NETDEV_DEV(dev, &pdev->dev); 1438 SET_NETDEV_DEV(dev, &pdev->dev);
1437 1439
1438 tp = netdev_priv(dev); 1440 tp = netdev_priv(dev);
1441 tp->dev = dev;
1439 tp->msg_enable = netif_msg_init(debug.msg_enable, SIS190_MSG_DEFAULT); 1442 tp->msg_enable = netif_msg_init(debug.msg_enable, SIS190_MSG_DEFAULT);
1440 1443
1441 rc = pci_enable_device(pdev); 1444 rc = pci_enable_device(pdev);
@@ -1798,7 +1801,7 @@ static int __devinit sis190_init_one(struct pci_dev *pdev,
1798 1801
1799 sis190_init_rxfilter(dev); 1802 sis190_init_rxfilter(dev);
1800 1803
1801 INIT_WORK(&tp->phy_task, sis190_phy_task, dev); 1804 INIT_WORK(&tp->phy_task, sis190_phy_task);
1802 1805
1803 dev->open = sis190_open; 1806 dev->open = sis190_open;
1804 dev->stop = sis190_close; 1807 dev->stop = sis190_close;
diff --git a/drivers/net/sk98lin/h/skdrv2nd.h b/drivers/net/sk98lin/h/skdrv2nd.h
index 778d9e618ebd..3fa67171e832 100644
--- a/drivers/net/sk98lin/h/skdrv2nd.h
+++ b/drivers/net/sk98lin/h/skdrv2nd.h
@@ -160,7 +160,7 @@ struct s_IOCTL {
160 160
161/* 161/*
162** Interim definition of SK_DRV_TIMER placed in this file until 162** Interim definition of SK_DRV_TIMER placed in this file until
163** common modules have boon finallized 163** common modules have been finalized
164*/ 164*/
165#define SK_DRV_TIMER 11 165#define SK_DRV_TIMER 11
166#define SK_DRV_MODERATION_TIMER 1 166#define SK_DRV_MODERATION_TIMER 1
diff --git a/drivers/net/sk98lin/skdim.c b/drivers/net/sk98lin/skdim.c
index 07c1b4c8699d..37ce03fb8de3 100644
--- a/drivers/net/sk98lin/skdim.c
+++ b/drivers/net/sk98lin/skdim.c
@@ -252,7 +252,7 @@ SkDimEnableModerationIfNeeded(SK_AC *pAC) {
252 252
253/******************************************************************************* 253/*******************************************************************************
254** Function : SkDimDisplayModerationSettings 254** Function : SkDimDisplayModerationSettings
255** Description : Displays the current settings regaring interrupt moderation 255** Description : Displays the current settings regarding interrupt moderation
256** Programmer : Ralph Roesler 256** Programmer : Ralph Roesler
257** Last Modified: 22-mar-03 257** Last Modified: 22-mar-03
258** Returns : void (!) 258** Returns : void (!)
@@ -510,7 +510,7 @@ EnableIntMod(SK_AC *pAC) {
510 510
511/******************************************************************************* 511/*******************************************************************************
512** Function : DisableIntMod() 512** Function : DisableIntMod()
513** Description : Disbles the interrupt moderation independent of what inter- 513** Description : Disables the interrupt moderation independent of what inter-
514** rupts are running or not 514** rupts are running or not
515** Programmer : Ralph Roesler 515** Programmer : Ralph Roesler
516** Last Modified: 23-mar-03 516** Last Modified: 23-mar-03
diff --git a/drivers/net/sk98lin/skethtool.c b/drivers/net/sk98lin/skethtool.c
index e5cb5b548b88..36460694eb82 100644
--- a/drivers/net/sk98lin/skethtool.c
+++ b/drivers/net/sk98lin/skethtool.c
@@ -581,6 +581,30 @@ static int setRxCsum(struct net_device *dev, u32 data)
581 return 0; 581 return 0;
582} 582}
583 583
584static int getRegsLen(struct net_device *dev)
585{
586 return 0x4000;
587}
588
589/*
590 * Returns copy of whole control register region
591 * Note: skip RAM address register because accessing it will
592 * cause bus hangs!
593 */
594static void getRegs(struct net_device *dev, struct ethtool_regs *regs,
595 void *p)
596{
597 DEV_NET *pNet = netdev_priv(dev);
598 const void __iomem *io = pNet->pAC->IoBase;
599
600 regs->version = 1;
601 memset(p, 0, regs->len);
602 memcpy_fromio(p, io, B3_RAM_ADDR);
603
604 memcpy_fromio(p + B3_RI_WTO_R1, io + B3_RI_WTO_R1,
605 regs->len - B3_RI_WTO_R1);
606}
607
584const struct ethtool_ops SkGeEthtoolOps = { 608const struct ethtool_ops SkGeEthtoolOps = {
585 .get_settings = getSettings, 609 .get_settings = getSettings,
586 .set_settings = setSettings, 610 .set_settings = setSettings,
@@ -599,4 +623,6 @@ const struct ethtool_ops SkGeEthtoolOps = {
599 .set_tx_csum = setTxCsum, 623 .set_tx_csum = setTxCsum,
600 .get_rx_csum = getRxCsum, 624 .get_rx_csum = getRxCsum,
601 .set_rx_csum = setRxCsum, 625 .set_rx_csum = setRxCsum,
626 .get_regs = getRegs,
627 .get_regs_len = getRegsLen,
602}; 628};
diff --git a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
index d4913c3de2a1..92d11b961db8 100644
--- a/drivers/net/sk98lin/skge.c
+++ b/drivers/net/sk98lin/skge.c
@@ -113,6 +113,8 @@
113#include <linux/init.h> 113#include <linux/init.h>
114#include <linux/dma-mapping.h> 114#include <linux/dma-mapping.h>
115#include <linux/ip.h> 115#include <linux/ip.h>
116#include <linux/mii.h>
117#include <linux/mm.h>
116 118
117#include "h/skdrv1st.h" 119#include "h/skdrv1st.h"
118#include "h/skdrv2nd.h" 120#include "h/skdrv2nd.h"
@@ -1561,7 +1563,7 @@ struct sk_buff *pMessage) /* pointer to send-message */
1561 1563
1562 if (pMessage->ip_summed == CHECKSUM_PARTIAL) { 1564 if (pMessage->ip_summed == CHECKSUM_PARTIAL) {
1563 u16 hdrlen = pMessage->h.raw - pMessage->data; 1565 u16 hdrlen = pMessage->h.raw - pMessage->data;
1564 u16 offset = hdrlen + pMessage->csum; 1566 u16 offset = hdrlen + pMessage->csum_offset;
1565 1567
1566 if ((pMessage->h.ipiph->protocol == IPPROTO_UDP ) && 1568 if ((pMessage->h.ipiph->protocol == IPPROTO_UDP ) &&
1567 (pAC->GIni.GIChipRev == 0) && 1569 (pAC->GIni.GIChipRev == 0) &&
@@ -1680,7 +1682,7 @@ struct sk_buff *pMessage) /* pointer to send-message */
1680 */ 1682 */
1681 if (pMessage->ip_summed == CHECKSUM_PARTIAL) { 1683 if (pMessage->ip_summed == CHECKSUM_PARTIAL) {
1682 u16 hdrlen = pMessage->h.raw - pMessage->data; 1684 u16 hdrlen = pMessage->h.raw - pMessage->data;
1683 u16 offset = hdrlen + pMessage->csum; 1685 u16 offset = hdrlen + pMessage->csum_offset;
1684 1686
1685 Control = BMU_STFWD; 1687 Control = BMU_STFWD;
1686 1688
@@ -2843,6 +2845,56 @@ unsigned long Flags; /* for spin lock */
2843 return(&pAC->stats); 2845 return(&pAC->stats);
2844} /* SkGeStats */ 2846} /* SkGeStats */
2845 2847
2848/*
2849 * Basic MII register access
2850 */
2851static int SkGeMiiIoctl(struct net_device *dev,
2852 struct mii_ioctl_data *data, int cmd)
2853{
2854 DEV_NET *pNet = netdev_priv(dev);
2855 SK_AC *pAC = pNet->pAC;
2856 SK_IOC IoC = pAC->IoBase;
2857 int Port = pNet->PortNr;
2858 SK_GEPORT *pPrt = &pAC->GIni.GP[Port];
2859 unsigned long Flags;
2860 int err = 0;
2861 int reg = data->reg_num & 0x1f;
2862 SK_U16 val = data->val_in;
2863
2864 if (!netif_running(dev))
2865 return -ENODEV; /* Phy still in reset */
2866
2867 spin_lock_irqsave(&pAC->SlowPathLock, Flags);
2868 switch(cmd) {
2869 case SIOCGMIIPHY:
2870 data->phy_id = pPrt->PhyAddr;
2871
2872 /* fallthru */
2873 case SIOCGMIIREG:
2874 if (pAC->GIni.GIGenesis)
2875 SkXmPhyRead(pAC, IoC, Port, reg, &val);
2876 else
2877 SkGmPhyRead(pAC, IoC, Port, reg, &val);
2878
2879 data->val_out = val;
2880 break;
2881
2882 case SIOCSMIIREG:
2883 if (!capable(CAP_NET_ADMIN))
2884 err = -EPERM;
2885
2886 else if (pAC->GIni.GIGenesis)
2887 SkXmPhyWrite(pAC, IoC, Port, reg, val);
2888 else
2889 SkGmPhyWrite(pAC, IoC, Port, reg, val);
2890 break;
2891 default:
2892 err = -EOPNOTSUPP;
2893 }
2894 spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
2895 return err;
2896}
2897
2846 2898
2847/***************************************************************************** 2899/*****************************************************************************
2848 * 2900 *
@@ -2876,6 +2928,9 @@ int HeaderLength = sizeof(SK_U32) + sizeof(SK_U32);
2876 pNet = netdev_priv(dev); 2928 pNet = netdev_priv(dev);
2877 pAC = pNet->pAC; 2929 pAC = pNet->pAC;
2878 2930
2931 if (cmd == SIOCGMIIPHY || cmd == SIOCSMIIREG || cmd == SIOCGMIIREG)
2932 return SkGeMiiIoctl(dev, if_mii(rq), cmd);
2933
2879 if(copy_from_user(&Ioctl, rq->ifr_data, sizeof(SK_GE_IOCTL))) { 2934 if(copy_from_user(&Ioctl, rq->ifr_data, sizeof(SK_GE_IOCTL))) {
2880 return -EFAULT; 2935 return -EFAULT;
2881 } 2936 }
diff --git a/drivers/net/sk98lin/skgesirq.c b/drivers/net/sk98lin/skgesirq.c
index ab66d80a4455..3e7aa49afd00 100644
--- a/drivers/net/sk98lin/skgesirq.c
+++ b/drivers/net/sk98lin/skgesirq.c
@@ -1319,7 +1319,7 @@ SK_BOOL AutoNeg) /* Is Auto-negotiation used ? */
1319 SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_INT_STAT, &Isrc); 1319 SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_INT_STAT, &Isrc);
1320 1320
1321#ifdef xDEBUG 1321#ifdef xDEBUG
1322 if ((Isrc & ~(PHY_B_IS_HCT | PHY_B_IS_LCT) == 1322 if ((Isrc & ~(PHY_B_IS_HCT | PHY_B_IS_LCT)) ==
1323 (PHY_B_IS_SCR_S_ER | PHY_B_IS_RRS_CHANGE | PHY_B_IS_LRS_CHANGE)) { 1323 (PHY_B_IS_SCR_S_ER | PHY_B_IS_RRS_CHANGE | PHY_B_IS_LRS_CHANGE)) {
1324 1324
1325 SK_U32 Stat1, Stat2, Stat3; 1325 SK_U32 Stat1, Stat2, Stat3;
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index b2949035f66a..b60f0451f6cd 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -1327,10 +1327,11 @@ static void xm_check_link(struct net_device *dev)
1327 * Since internal PHY is wired to a level triggered pin, can't 1327 * Since internal PHY is wired to a level triggered pin, can't
1328 * get an interrupt when carrier is detected. 1328 * get an interrupt when carrier is detected.
1329 */ 1329 */
1330static void xm_link_timer(void *arg) 1330static void xm_link_timer(struct work_struct *work)
1331{ 1331{
1332 struct net_device *dev = arg; 1332 struct skge_port *skge =
1333 struct skge_port *skge = netdev_priv(arg); 1333 container_of(work, struct skge_port, link_thread.work);
1334 struct net_device *dev = skge->netdev;
1334 struct skge_hw *hw = skge->hw; 1335 struct skge_hw *hw = skge->hw;
1335 int port = skge->port; 1336 int port = skge->port;
1336 1337
@@ -2154,8 +2155,6 @@ static void yukon_link_down(struct skge_port *skge)
2154 int port = skge->port; 2155 int port = skge->port;
2155 u16 ctrl; 2156 u16 ctrl;
2156 2157
2157 gm_phy_write(hw, port, PHY_MARV_INT_MASK, 0);
2158
2159 ctrl = gma_read16(hw, port, GM_GP_CTRL); 2158 ctrl = gma_read16(hw, port, GM_GP_CTRL);
2160 ctrl &= ~(GM_GPCR_RX_ENA | GM_GPCR_TX_ENA); 2159 ctrl &= ~(GM_GPCR_RX_ENA | GM_GPCR_TX_ENA);
2161 gma_write16(hw, port, GM_GP_CTRL, ctrl); 2160 gma_write16(hw, port, GM_GP_CTRL, ctrl);
@@ -2167,7 +2166,6 @@ static void yukon_link_down(struct skge_port *skge)
2167 gm_phy_write(hw, port, PHY_MARV_AUNE_ADV, ctrl); 2166 gm_phy_write(hw, port, PHY_MARV_AUNE_ADV, ctrl);
2168 } 2167 }
2169 2168
2170 yukon_reset(hw, port);
2171 skge_link_down(skge); 2169 skge_link_down(skge);
2172 2170
2173 yukon_init(hw, port); 2171 yukon_init(hw, port);
@@ -2255,6 +2253,7 @@ static void skge_phy_reset(struct skge_port *skge)
2255{ 2253{
2256 struct skge_hw *hw = skge->hw; 2254 struct skge_hw *hw = skge->hw;
2257 int port = skge->port; 2255 int port = skge->port;
2256 struct net_device *dev = hw->dev[port];
2258 2257
2259 netif_stop_queue(skge->netdev); 2258 netif_stop_queue(skge->netdev);
2260 netif_carrier_off(skge->netdev); 2259 netif_carrier_off(skge->netdev);
@@ -2268,6 +2267,8 @@ static void skge_phy_reset(struct skge_port *skge)
2268 yukon_init(hw, port); 2267 yukon_init(hw, port);
2269 } 2268 }
2270 mutex_unlock(&hw->phy_mutex); 2269 mutex_unlock(&hw->phy_mutex);
2270
2271 dev->set_multicast_list(dev);
2271} 2272}
2272 2273
2273/* Basic MII support */ 2274/* Basic MII support */
@@ -2565,7 +2566,7 @@ static int skge_xmit_frame(struct sk_buff *skb, struct net_device *dev)
2565 2566
2566 td->csum_offs = 0; 2567 td->csum_offs = 0;
2567 td->csum_start = offset; 2568 td->csum_start = offset;
2568 td->csum_write = offset + skb->csum; 2569 td->csum_write = offset + skb->csum_offset;
2569 } else 2570 } else
2570 control = BMU_CHECK; 2571 control = BMU_CHECK;
2571 2572
@@ -3072,9 +3073,9 @@ static void skge_error_irq(struct skge_hw *hw)
3072 * because accessing phy registers requires spin wait which might 3073 * because accessing phy registers requires spin wait which might
3073 * cause excess interrupt latency. 3074 * cause excess interrupt latency.
3074 */ 3075 */
3075static void skge_extirq(void *arg) 3076static void skge_extirq(struct work_struct *work)
3076{ 3077{
3077 struct skge_hw *hw = arg; 3078 struct skge_hw *hw = container_of(work, struct skge_hw, phy_work);
3078 int port; 3079 int port;
3079 3080
3080 mutex_lock(&hw->phy_mutex); 3081 mutex_lock(&hw->phy_mutex);
@@ -3456,7 +3457,7 @@ static struct net_device *skge_devinit(struct skge_hw *hw, int port,
3456 skge->port = port; 3457 skge->port = port;
3457 3458
3458 /* Only used for Genesis XMAC */ 3459 /* Only used for Genesis XMAC */
3459 INIT_WORK(&skge->link_thread, xm_link_timer, dev); 3460 INIT_DELAYED_WORK(&skge->link_thread, xm_link_timer);
3460 3461
3461 if (hw->chip_id != CHIP_ID_GENESIS) { 3462 if (hw->chip_id != CHIP_ID_GENESIS) {
3462 dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG; 3463 dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG;
@@ -3543,7 +3544,7 @@ static int __devinit skge_probe(struct pci_dev *pdev,
3543 3544
3544 hw->pdev = pdev; 3545 hw->pdev = pdev;
3545 mutex_init(&hw->phy_mutex); 3546 mutex_init(&hw->phy_mutex);
3546 INIT_WORK(&hw->phy_work, skge_extirq, hw); 3547 INIT_WORK(&hw->phy_work, skge_extirq);
3547 spin_lock_init(&hw->hw_lock); 3548 spin_lock_init(&hw->hw_lock);
3548 3549
3549 hw->regs = ioremap_nocache(pci_resource_start(pdev, 0), 0x4000); 3550 hw->regs = ioremap_nocache(pci_resource_start(pdev, 0), 0x4000);
diff --git a/drivers/net/skge.h b/drivers/net/skge.h
index 537c0aaa1db8..f6223c533c01 100644
--- a/drivers/net/skge.h
+++ b/drivers/net/skge.h
@@ -389,10 +389,10 @@ enum {
389/* Packet Arbiter Registers */ 389/* Packet Arbiter Registers */
390/* B3_PA_CTRL 16 bit Packet Arbiter Ctrl Register */ 390/* B3_PA_CTRL 16 bit Packet Arbiter Ctrl Register */
391enum { 391enum {
392 PA_CLR_TO_TX2 = 1<<13, /* Clear IRQ Packet Timeout TX2 */ 392 PA_CLR_TO_TX2 = 1<<13,/* Clear IRQ Packet Timeout TX2 */
393 PA_CLR_TO_TX1 = 1<<12, /* Clear IRQ Packet Timeout TX1 */ 393 PA_CLR_TO_TX1 = 1<<12,/* Clear IRQ Packet Timeout TX1 */
394 PA_CLR_TO_RX2 = 1<<11, /* Clear IRQ Packet Timeout RX2 */ 394 PA_CLR_TO_RX2 = 1<<11,/* Clear IRQ Packet Timeout RX2 */
395 PA_CLR_TO_RX1 = 1<<10, /* Clear IRQ Packet Timeout RX1 */ 395 PA_CLR_TO_RX1 = 1<<10,/* Clear IRQ Packet Timeout RX1 */
396 PA_ENA_TO_TX2 = 1<<9, /* Enable Timeout Timer TX2 */ 396 PA_ENA_TO_TX2 = 1<<9, /* Enable Timeout Timer TX2 */
397 PA_DIS_TO_TX2 = 1<<8, /* Disable Timeout Timer TX2 */ 397 PA_DIS_TO_TX2 = 1<<8, /* Disable Timeout Timer TX2 */
398 PA_ENA_TO_TX1 = 1<<7, /* Enable Timeout Timer TX1 */ 398 PA_ENA_TO_TX1 = 1<<7, /* Enable Timeout Timer TX1 */
@@ -481,14 +481,14 @@ enum {
481/* RAM Buffer Register Offsets */ 481/* RAM Buffer Register Offsets */
482enum { 482enum {
483 483
484 RB_START = 0x00,/* 32 bit RAM Buffer Start Address */ 484 RB_START= 0x00,/* 32 bit RAM Buffer Start Address */
485 RB_END = 0x04,/* 32 bit RAM Buffer End Address */ 485 RB_END = 0x04,/* 32 bit RAM Buffer End Address */
486 RB_WP = 0x08,/* 32 bit RAM Buffer Write Pointer */ 486 RB_WP = 0x08,/* 32 bit RAM Buffer Write Pointer */
487 RB_RP = 0x0c,/* 32 bit RAM Buffer Read Pointer */ 487 RB_RP = 0x0c,/* 32 bit RAM Buffer Read Pointer */
488 RB_RX_UTPP = 0x10,/* 32 bit Rx Upper Threshold, Pause Packet */ 488 RB_RX_UTPP= 0x10,/* 32 bit Rx Upper Threshold, Pause Packet */
489 RB_RX_LTPP = 0x14,/* 32 bit Rx Lower Threshold, Pause Packet */ 489 RB_RX_LTPP= 0x14,/* 32 bit Rx Lower Threshold, Pause Packet */
490 RB_RX_UTHP = 0x18,/* 32 bit Rx Upper Threshold, High Prio */ 490 RB_RX_UTHP= 0x18,/* 32 bit Rx Upper Threshold, High Prio */
491 RB_RX_LTHP = 0x1c,/* 32 bit Rx Lower Threshold, High Prio */ 491 RB_RX_LTHP= 0x1c,/* 32 bit Rx Lower Threshold, High Prio */
492 /* 0x10 - 0x1f: reserved at Tx RAM Buffer Registers */ 492 /* 0x10 - 0x1f: reserved at Tx RAM Buffer Registers */
493 RB_PC = 0x20,/* 32 bit RAM Buffer Packet Counter */ 493 RB_PC = 0x20,/* 32 bit RAM Buffer Packet Counter */
494 RB_LEV = 0x24,/* 32 bit RAM Buffer Level Register */ 494 RB_LEV = 0x24,/* 32 bit RAM Buffer Level Register */
@@ -532,7 +532,7 @@ enum {
532 PHY_ADDR_MARV = 0, 532 PHY_ADDR_MARV = 0,
533}; 533};
534 534
535#define RB_ADDR(offs, queue) (B16_RAM_REGS + (queue) + (offs)) 535#define RB_ADDR(offs, queue) ((u16)B16_RAM_REGS + (u16)(queue) + (offs))
536 536
537/* Receive MAC FIFO, Receive LED, and Link_Sync regs (GENESIS only) */ 537/* Receive MAC FIFO, Receive LED, and Link_Sync regs (GENESIS only) */
538enum { 538enum {
@@ -578,15 +578,15 @@ enum {
578 MFF_DIS_TIST = 1<<2, /* Disable Time Stamp Gener */ 578 MFF_DIS_TIST = 1<<2, /* Disable Time Stamp Gener */
579 MFF_CLR_INTIST = 1<<1, /* Clear IRQ No Time Stamp */ 579 MFF_CLR_INTIST = 1<<1, /* Clear IRQ No Time Stamp */
580 MFF_CLR_INSTAT = 1<<0, /* Clear IRQ No Status */ 580 MFF_CLR_INSTAT = 1<<0, /* Clear IRQ No Status */
581#define MFF_RX_CTRL_DEF MFF_ENA_TIM_PAT 581 MFF_RX_CTRL_DEF = MFF_ENA_TIM_PAT,
582}; 582};
583 583
584/* TX_MFF_CTRL1 16 bit Transmit MAC FIFO Control Reg 1 */ 584/* TX_MFF_CTRL1 16 bit Transmit MAC FIFO Control Reg 1 */
585enum { 585enum {
586 MFF_CLR_PERR = 1<<15, /* Clear Parity Error IRQ */ 586 MFF_CLR_PERR = 1<<15, /* Clear Parity Error IRQ */
587 /* Bit 14: reserved */ 587
588 MFF_ENA_PKT_REC = 1<<13, /* Enable Packet Recovery */ 588 MFF_ENA_PKT_REC = 1<<13, /* Enable Packet Recovery */
589 MFF_DIS_PKT_REC = 1<<12, /* Disable Packet Recovery */ 589 MFF_DIS_PKT_REC = 1<<12, /* Disable Packet Recovery */
590 590
591 MFF_ENA_W4E = 1<<7, /* Enable Wait for Empty */ 591 MFF_ENA_W4E = 1<<7, /* Enable Wait for Empty */
592 MFF_DIS_W4E = 1<<6, /* Disable Wait for Empty */ 592 MFF_DIS_W4E = 1<<6, /* Disable Wait for Empty */
@@ -595,9 +595,10 @@ enum {
595 MFF_DIS_LOOPB = 1<<2, /* Disable Loopback */ 595 MFF_DIS_LOOPB = 1<<2, /* Disable Loopback */
596 MFF_CLR_MAC_RST = 1<<1, /* Clear XMAC Reset */ 596 MFF_CLR_MAC_RST = 1<<1, /* Clear XMAC Reset */
597 MFF_SET_MAC_RST = 1<<0, /* Set XMAC Reset */ 597 MFF_SET_MAC_RST = 1<<0, /* Set XMAC Reset */
598
599 MFF_TX_CTRL_DEF = MFF_ENA_PKT_REC | (u16) MFF_ENA_TIM_PAT | MFF_ENA_FLUSH,
598}; 600};
599 601
600#define MFF_TX_CTRL_DEF (MFF_ENA_PKT_REC | MFF_ENA_TIM_PAT | MFF_ENA_FLUSH)
601 602
602/* RX_MFF_TST2 8 bit Receive MAC FIFO Test Register 2 */ 603/* RX_MFF_TST2 8 bit Receive MAC FIFO Test Register 2 */
603/* TX_MFF_TST2 8 bit Transmit MAC FIFO Test Register 2 */ 604/* TX_MFF_TST2 8 bit Transmit MAC FIFO Test Register 2 */
@@ -1304,8 +1305,8 @@ enum {
1304 1305
1305/* special defines for FIBER (88E1011S only) */ 1306/* special defines for FIBER (88E1011S only) */
1306enum { 1307enum {
1307 PHY_M_AN_ASP_X = 1<<8, /* Asymmetric Pause */ 1308 PHY_M_AN_ASP_X = 1<<8, /* Asymmetric Pause */
1308 PHY_M_AN_PC_X = 1<<7, /* MAC Pause implemented */ 1309 PHY_M_AN_PC_X = 1<<7, /* MAC Pause implemented */
1309 PHY_M_AN_1000X_AHD = 1<<6, /* Advertise 10000Base-X Half Duplex */ 1310 PHY_M_AN_1000X_AHD = 1<<6, /* Advertise 10000Base-X Half Duplex */
1310 PHY_M_AN_1000X_AFD = 1<<5, /* Advertise 10000Base-X Full Duplex */ 1311 PHY_M_AN_1000X_AFD = 1<<5, /* Advertise 10000Base-X Full Duplex */
1311}; 1312};
@@ -1320,7 +1321,7 @@ enum {
1320 1321
1321/***** PHY_MARV_1000T_CTRL 16 bit r/w 1000Base-T Control Reg *****/ 1322/***** PHY_MARV_1000T_CTRL 16 bit r/w 1000Base-T Control Reg *****/
1322enum { 1323enum {
1323 PHY_M_1000C_TEST = 7<<13,/* Bit 15..13: Test Modes */ 1324 PHY_M_1000C_TEST= 7<<13,/* Bit 15..13: Test Modes */
1324 PHY_M_1000C_MSE = 1<<12, /* Manual Master/Slave Enable */ 1325 PHY_M_1000C_MSE = 1<<12, /* Manual Master/Slave Enable */
1325 PHY_M_1000C_MSC = 1<<11, /* M/S Configuration (1=Master) */ 1326 PHY_M_1000C_MSC = 1<<11, /* M/S Configuration (1=Master) */
1326 PHY_M_1000C_MPD = 1<<10, /* Multi-Port Device */ 1327 PHY_M_1000C_MPD = 1<<10, /* Multi-Port Device */
@@ -1349,7 +1350,7 @@ enum {
1349 PHY_M_PC_EN_DET_PLUS = 3<<8, /* Energy Detect Plus (Mode 2) */ 1350 PHY_M_PC_EN_DET_PLUS = 3<<8, /* Energy Detect Plus (Mode 2) */
1350}; 1351};
1351 1352
1352#define PHY_M_PC_MDI_XMODE(x) (((x)<<5) & PHY_M_PC_MDIX_MSK) 1353#define PHY_M_PC_MDI_XMODE(x) ((((u16)(x)<<5) & PHY_M_PC_MDIX_MSK)
1353 1354
1354enum { 1355enum {
1355 PHY_M_PC_MAN_MDI = 0, /* 00 = Manual MDI configuration */ 1356 PHY_M_PC_MAN_MDI = 0, /* 00 = Manual MDI configuration */
@@ -1432,24 +1433,24 @@ enum {
1432 PHY_M_EC_DIS_LINK_P = 1<<12, /* Disable Link Pulses (88E1111 only) */ 1433 PHY_M_EC_DIS_LINK_P = 1<<12, /* Disable Link Pulses (88E1111 only) */
1433 PHY_M_EC_M_DSC_MSK = 3<<10, /* Bit 11..10: Master Downshift Counter */ 1434 PHY_M_EC_M_DSC_MSK = 3<<10, /* Bit 11..10: Master Downshift Counter */
1434 /* (88E1011 only) */ 1435 /* (88E1011 only) */
1435 PHY_M_EC_S_DSC_MSK = 3<<8,/* Bit 9.. 8: Slave Downshift Counter */ 1436 PHY_M_EC_S_DSC_MSK = 3<<8, /* Bit 9.. 8: Slave Downshift Counter */
1436 /* (88E1011 only) */ 1437 /* (88E1011 only) */
1437 PHY_M_EC_M_DSC_MSK2 = 7<<9,/* Bit 11.. 9: Master Downshift Counter */ 1438 PHY_M_EC_M_DSC_MSK2 = 7<<9, /* Bit 11.. 9: Master Downshift Counter */
1438 /* (88E1111 only) */ 1439 /* (88E1111 only) */
1439 PHY_M_EC_DOWN_S_ENA = 1<<8, /* Downshift Enable (88E1111 only) */ 1440 PHY_M_EC_DOWN_S_ENA = 1<<8, /* Downshift Enable (88E1111 only) */
1440 /* !!! Errata in spec. (1 = disable) */ 1441 /* !!! Errata in spec. (1 = disable) */
1441 PHY_M_EC_RX_TIM_CT = 1<<7, /* RGMII Rx Timing Control*/ 1442 PHY_M_EC_RX_TIM_CT = 1<<7, /* RGMII Rx Timing Control*/
1442 PHY_M_EC_MAC_S_MSK = 7<<4,/* Bit 6.. 4: Def. MAC interface speed */ 1443 PHY_M_EC_MAC_S_MSK = 7<<4, /* Bit 6.. 4: Def. MAC interface speed */
1443 PHY_M_EC_FIB_AN_ENA = 1<<3, /* Fiber Auto-Neg. Enable (88E1011S only) */ 1444 PHY_M_EC_FIB_AN_ENA = 1<<3, /* Fiber Auto-Neg. Enable (88E1011S only) */
1444 PHY_M_EC_DTE_D_ENA = 1<<2, /* DTE Detect Enable (88E1111 only) */ 1445 PHY_M_EC_DTE_D_ENA = 1<<2, /* DTE Detect Enable (88E1111 only) */
1445 PHY_M_EC_TX_TIM_CT = 1<<1, /* RGMII Tx Timing Control */ 1446 PHY_M_EC_TX_TIM_CT = 1<<1, /* RGMII Tx Timing Control */
1446 PHY_M_EC_TRANS_DIS = 1<<0, /* Transmitter Disable (88E1111 only) */}; 1447 PHY_M_EC_TRANS_DIS = 1<<0, /* Transmitter Disable (88E1111 only) */};
1447 1448
1448#define PHY_M_EC_M_DSC(x) ((x)<<10) /* 00=1x; 01=2x; 10=3x; 11=4x */ 1449#define PHY_M_EC_M_DSC(x) ((u16)(x)<<10) /* 00=1x; 01=2x; 10=3x; 11=4x */
1449#define PHY_M_EC_S_DSC(x) ((x)<<8) /* 00=dis; 01=1x; 10=2x; 11=3x */ 1450#define PHY_M_EC_S_DSC(x) ((u16)(x)<<8) /* 00=dis; 01=1x; 10=2x; 11=3x */
1450#define PHY_M_EC_MAC_S(x) ((x)<<4) /* 01X=0; 110=2.5; 111=25 (MHz) */ 1451#define PHY_M_EC_MAC_S(x) ((u16)(x)<<4) /* 01X=0; 110=2.5; 111=25 (MHz) */
1451 1452
1452#define PHY_M_EC_M_DSC_2(x) ((x)<<9) /* 000=1x; 001=2x; 010=3x; 011=4x */ 1453#define PHY_M_EC_M_DSC_2(x) ((u16)(x)<<9) /* 000=1x; 001=2x; 010=3x; 011=4x */
1453 /* 100=5x; 101=6x; 110=7x; 111=8x */ 1454 /* 100=5x; 101=6x; 110=7x; 111=8x */
1454enum { 1455enum {
1455 MAC_TX_CLK_0_MHZ = 2, 1456 MAC_TX_CLK_0_MHZ = 2,
@@ -1468,10 +1469,12 @@ enum {
1468 PHY_M_LEDC_LK_C_MSK = 7<<3,/* Bit 5.. 3: Link Control Mask */ 1469 PHY_M_LEDC_LK_C_MSK = 7<<3,/* Bit 5.. 3: Link Control Mask */
1469 /* (88E1111 only) */ 1470 /* (88E1111 only) */
1470}; 1471};
1472#define PHY_M_LED_PULS_DUR(x) (((u16)(x)<<12) & PHY_M_LEDC_PULS_MSK)
1473#define PHY_M_LED_BLINK_RT(x) (((u16)(x)<<8) & PHY_M_LEDC_BL_R_MSK)
1471 1474
1472enum { 1475enum {
1473 PHY_M_LEDC_LINK_MSK = 3<<3,/* Bit 4.. 3: Link Control Mask */ 1476 PHY_M_LEDC_LINK_MSK = 3<<3, /* Bit 4.. 3: Link Control Mask */
1474 /* (88E1011 only) */ 1477 /* (88E1011 only) */
1475 PHY_M_LEDC_DP_CTRL = 1<<2, /* Duplex Control */ 1478 PHY_M_LEDC_DP_CTRL = 1<<2, /* Duplex Control */
1476 PHY_M_LEDC_DP_C_MSB = 1<<2, /* Duplex Control (MSB, 88E1111 only) */ 1479 PHY_M_LEDC_DP_C_MSB = 1<<2, /* Duplex Control (MSB, 88E1111 only) */
1477 PHY_M_LEDC_RX_CTRL = 1<<1, /* Rx Activity / Link */ 1480 PHY_M_LEDC_RX_CTRL = 1<<1, /* Rx Activity / Link */
@@ -1479,27 +1482,24 @@ enum {
1479 PHY_M_LEDC_TX_C_MSB = 1<<0, /* Tx Control (MSB, 88E1111 only) */ 1482 PHY_M_LEDC_TX_C_MSB = 1<<0, /* Tx Control (MSB, 88E1111 only) */
1480}; 1483};
1481 1484
1482#define PHY_M_LED_PULS_DUR(x) (((x)<<12) & PHY_M_LEDC_PULS_MSK)
1483
1484enum { 1485enum {
1485 PULS_NO_STR = 0,/* no pulse stretching */ 1486 PULS_NO_STR = 0, /* no pulse stretching */
1486 PULS_21MS = 1,/* 21 ms to 42 ms */ 1487 PULS_21MS = 1, /* 21 ms to 42 ms */
1487 PULS_42MS = 2,/* 42 ms to 84 ms */ 1488 PULS_42MS = 2, /* 42 ms to 84 ms */
1488 PULS_84MS = 3,/* 84 ms to 170 ms */ 1489 PULS_84MS = 3, /* 84 ms to 170 ms */
1489 PULS_170MS = 4,/* 170 ms to 340 ms */ 1490 PULS_170MS = 4, /* 170 ms to 340 ms */
1490 PULS_340MS = 5,/* 340 ms to 670 ms */ 1491 PULS_340MS = 5, /* 340 ms to 670 ms */
1491 PULS_670MS = 6,/* 670 ms to 1.3 s */ 1492 PULS_670MS = 6, /* 670 ms to 1.3 s */
1492 PULS_1300MS = 7,/* 1.3 s to 2.7 s */ 1493 PULS_1300MS = 7, /* 1.3 s to 2.7 s */
1493}; 1494};
1494 1495
1495#define PHY_M_LED_BLINK_RT(x) (((x)<<8) & PHY_M_LEDC_BL_R_MSK)
1496 1496
1497enum { 1497enum {
1498 BLINK_42MS = 0,/* 42 ms */ 1498 BLINK_42MS = 0, /* 42 ms */
1499 BLINK_84MS = 1,/* 84 ms */ 1499 BLINK_84MS = 1, /* 84 ms */
1500 BLINK_170MS = 2,/* 170 ms */ 1500 BLINK_170MS = 2, /* 170 ms */
1501 BLINK_340MS = 3,/* 340 ms */ 1501 BLINK_340MS = 3, /* 340 ms */
1502 BLINK_670MS = 4,/* 670 ms */ 1502 BLINK_670MS = 4, /* 670 ms */
1503}; 1503};
1504 1504
1505/***** PHY_MARV_LED_OVER 16 bit r/w Manual LED Override Reg *****/ 1505/***** PHY_MARV_LED_OVER 16 bit r/w Manual LED Override Reg *****/
@@ -1525,7 +1525,7 @@ enum {
1525 PHY_M_EC2_FO_IMPED = 1<<5, /* Fiber Output Impedance */ 1525 PHY_M_EC2_FO_IMPED = 1<<5, /* Fiber Output Impedance */
1526 PHY_M_EC2_FO_M_CLK = 1<<4, /* Fiber Mode Clock Enable */ 1526 PHY_M_EC2_FO_M_CLK = 1<<4, /* Fiber Mode Clock Enable */
1527 PHY_M_EC2_FO_BOOST = 1<<3, /* Fiber Output Boost */ 1527 PHY_M_EC2_FO_BOOST = 1<<3, /* Fiber Output Boost */
1528 PHY_M_EC2_FO_AM_MSK = 7,/* Bit 2.. 0: Fiber Output Amplitude */ 1528 PHY_M_EC2_FO_AM_MSK = 7, /* Bit 2.. 0: Fiber Output Amplitude */
1529}; 1529};
1530 1530
1531/***** PHY_MARV_EXT_P_STAT 16 bit r/w Ext. PHY Specific Status *****/ 1531/***** PHY_MARV_EXT_P_STAT 16 bit r/w Ext. PHY Specific Status *****/
@@ -1550,7 +1550,7 @@ enum {
1550 PHY_M_CABD_DIS_WAIT = 1<<15, /* Disable Waiting Period (Page 1) */ 1550 PHY_M_CABD_DIS_WAIT = 1<<15, /* Disable Waiting Period (Page 1) */
1551 /* (88E1111 only) */ 1551 /* (88E1111 only) */
1552 PHY_M_CABD_STAT_MSK = 3<<13, /* Bit 14..13: Status Mask */ 1552 PHY_M_CABD_STAT_MSK = 3<<13, /* Bit 14..13: Status Mask */
1553 PHY_M_CABD_AMPL_MSK = 0x1f<<8,/* Bit 12.. 8: Amplitude Mask */ 1553 PHY_M_CABD_AMPL_MSK = 0x1f<<8, /* Bit 12.. 8: Amplitude Mask */
1554 /* (88E1111 only) */ 1554 /* (88E1111 only) */
1555 PHY_M_CABD_DIST_MSK = 0xff, /* Bit 7.. 0: Distance Mask */ 1555 PHY_M_CABD_DIST_MSK = 0xff, /* Bit 7.. 0: Distance Mask */
1556}; 1556};
@@ -1605,9 +1605,9 @@ enum {
1605 1605
1606/***** PHY_MARV_PHY_CTRL (page 3) 16 bit r/w LED Control Reg. *****/ 1606/***** PHY_MARV_PHY_CTRL (page 3) 16 bit r/w LED Control Reg. *****/
1607enum { 1607enum {
1608 PHY_M_LEDC_LOS_MSK = 0xf<<12,/* Bit 15..12: LOS LED Ctrl. Mask */ 1608 PHY_M_LEDC_LOS_MSK = 0xf<<12, /* Bit 15..12: LOS LED Ctrl. Mask */
1609 PHY_M_LEDC_INIT_MSK = 0xf<<8, /* Bit 11.. 8: INIT LED Ctrl. Mask */ 1609 PHY_M_LEDC_INIT_MSK = 0xf<<8, /* Bit 11.. 8: INIT LED Ctrl. Mask */
1610 PHY_M_LEDC_STA1_MSK = 0xf<<4,/* Bit 7.. 4: STAT1 LED Ctrl. Mask */ 1610 PHY_M_LEDC_STA1_MSK = 0xf<<4, /* Bit 7.. 4: STAT1 LED Ctrl. Mask */
1611 PHY_M_LEDC_STA0_MSK = 0xf, /* Bit 3.. 0: STAT0 LED Ctrl. Mask */ 1611 PHY_M_LEDC_STA0_MSK = 0xf, /* Bit 3.. 0: STAT0 LED Ctrl. Mask */
1612}; 1612};
1613 1613
@@ -1804,8 +1804,8 @@ enum {
1804 1804
1805/* GM_SMI_CTRL 16 bit r/w SMI Control Register */ 1805/* GM_SMI_CTRL 16 bit r/w SMI Control Register */
1806enum { 1806enum {
1807 GM_SMI_CT_PHY_A_MSK = 0x1f<<11,/* Bit 15..11: PHY Device Address */ 1807 GM_SMI_CT_PHY_A_MSK = 0x1f<<11, /* Bit 15..11: PHY Device Address */
1808 GM_SMI_CT_REG_A_MSK = 0x1f<<6,/* Bit 10.. 6: PHY Register Address */ 1808 GM_SMI_CT_REG_A_MSK = 0x1f<<6, /* Bit 10.. 6: PHY Register Address */
1809 GM_SMI_CT_OP_RD = 1<<5, /* Bit 5: OpCode Read (0=Write)*/ 1809 GM_SMI_CT_OP_RD = 1<<5, /* Bit 5: OpCode Read (0=Write)*/
1810 GM_SMI_CT_RD_VAL = 1<<4, /* Bit 4: Read Valid (Read completed) */ 1810 GM_SMI_CT_RD_VAL = 1<<4, /* Bit 4: Read Valid (Read completed) */
1811 GM_SMI_CT_BUSY = 1<<3, /* Bit 3: Busy (Operation in progress) */ 1811 GM_SMI_CT_BUSY = 1<<3, /* Bit 3: Busy (Operation in progress) */
@@ -1875,9 +1875,9 @@ enum {
1875 1875
1876/* TX_GMF_CTRL_T 32 bit Tx GMAC FIFO Control/Test */ 1876/* TX_GMF_CTRL_T 32 bit Tx GMAC FIFO Control/Test */
1877enum { 1877enum {
1878 GMF_WSP_TST_ON = 1<<18,/* Write Shadow Pointer Test On */ 1878 GMF_WSP_TST_ON = 1<<18, /* Write Shadow Pointer Test On */
1879 GMF_WSP_TST_OFF = 1<<17,/* Write Shadow Pointer Test Off */ 1879 GMF_WSP_TST_OFF = 1<<17, /* Write Shadow Pointer Test Off */
1880 GMF_WSP_STEP = 1<<16,/* Write Shadow Pointer Step/Increment */ 1880 GMF_WSP_STEP = 1<<16, /* Write Shadow Pointer Step/Increment */
1881 1881
1882 GMF_CLI_TX_FU = 1<<6, /* Clear IRQ Tx FIFO Underrun */ 1882 GMF_CLI_TX_FU = 1<<6, /* Clear IRQ Tx FIFO Underrun */
1883 GMF_CLI_TX_FC = 1<<5, /* Clear IRQ Tx Frame Complete */ 1883 GMF_CLI_TX_FC = 1<<5, /* Clear IRQ Tx Frame Complete */
@@ -2111,18 +2111,18 @@ enum {
2111 2111
2112/* XM_MMU_CMD 16 bit r/w MMU Command Register */ 2112/* XM_MMU_CMD 16 bit r/w MMU Command Register */
2113enum { 2113enum {
2114 XM_MMU_PHY_RDY = 1<<12,/* Bit 12: PHY Read Ready */ 2114 XM_MMU_PHY_RDY = 1<<12, /* Bit 12: PHY Read Ready */
2115 XM_MMU_PHY_BUSY = 1<<11,/* Bit 11: PHY Busy */ 2115 XM_MMU_PHY_BUSY = 1<<11, /* Bit 11: PHY Busy */
2116 XM_MMU_IGN_PF = 1<<10,/* Bit 10: Ignore Pause Frame */ 2116 XM_MMU_IGN_PF = 1<<10, /* Bit 10: Ignore Pause Frame */
2117 XM_MMU_MAC_LB = 1<<9, /* Bit 9: Enable MAC Loopback */ 2117 XM_MMU_MAC_LB = 1<<9, /* Bit 9: Enable MAC Loopback */
2118 XM_MMU_FRC_COL = 1<<7, /* Bit 7: Force Collision */ 2118 XM_MMU_FRC_COL = 1<<7, /* Bit 7: Force Collision */
2119 XM_MMU_SIM_COL = 1<<6, /* Bit 6: Simulate Collision */ 2119 XM_MMU_SIM_COL = 1<<6, /* Bit 6: Simulate Collision */
2120 XM_MMU_NO_PRE = 1<<5, /* Bit 5: No MDIO Preamble */ 2120 XM_MMU_NO_PRE = 1<<5, /* Bit 5: No MDIO Preamble */
2121 XM_MMU_GMII_FD = 1<<4, /* Bit 4: GMII uses Full Duplex */ 2121 XM_MMU_GMII_FD = 1<<4, /* Bit 4: GMII uses Full Duplex */
2122 XM_MMU_RAT_CTRL = 1<<3, /* Bit 3: Enable Rate Control */ 2122 XM_MMU_RAT_CTRL = 1<<3, /* Bit 3: Enable Rate Control */
2123 XM_MMU_GMII_LOOP= 1<<2, /* Bit 2: PHY is in Loopback Mode */ 2123 XM_MMU_GMII_LOOP= 1<<2, /* Bit 2: PHY is in Loopback Mode */
2124 XM_MMU_ENA_RX = 1<<1, /* Bit 1: Enable Receiver */ 2124 XM_MMU_ENA_RX = 1<<1, /* Bit 1: Enable Receiver */
2125 XM_MMU_ENA_TX = 1<<0, /* Bit 0: Enable Transmitter */ 2125 XM_MMU_ENA_TX = 1<<0, /* Bit 0: Enable Transmitter */
2126}; 2126};
2127 2127
2128 2128
@@ -2456,7 +2456,7 @@ struct skge_port {
2456 2456
2457 struct net_device_stats net_stats; 2457 struct net_device_stats net_stats;
2458 2458
2459 struct work_struct link_thread; 2459 struct delayed_work link_thread;
2460 enum pause_control flow_control; 2460 enum pause_control flow_control;
2461 enum pause_status flow_status; 2461 enum pause_status flow_status;
2462 u8 rx_csum; 2462 u8 rx_csum;
@@ -2506,7 +2506,7 @@ static inline void skge_write8(const struct skge_hw *hw, int reg, u8 val)
2506} 2506}
2507 2507
2508/* MAC Related Registers inside the device. */ 2508/* MAC Related Registers inside the device. */
2509#define SK_REG(port,reg) (((port)<<7)+(reg)) 2509#define SK_REG(port,reg) (((port)<<7)+(u16)(reg))
2510#define SK_XMAC_REG(port, reg) \ 2510#define SK_XMAC_REG(port, reg) \
2511 ((BASE_XMAC_1 + (port) * (BASE_XMAC_2 - BASE_XMAC_1)) | (reg) << 1) 2511 ((BASE_XMAC_1 + (port) * (BASE_XMAC_2 - BASE_XMAC_1)) | (reg) << 1)
2512 2512
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index 16616f5440d0..fb1d2c30c1bb 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -100,32 +100,32 @@ module_param(idle_timeout, int, 0);
100MODULE_PARM_DESC(idle_timeout, "Watchdog timer for lost interrupts (ms)"); 100MODULE_PARM_DESC(idle_timeout, "Watchdog timer for lost interrupts (ms)");
101 101
102static const struct pci_device_id sky2_id_table[] = { 102static const struct pci_device_id sky2_id_table[] = {
103 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9000) }, 103 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9000) }, /* SK-9Sxx */
104 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9E00) }, 104 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9E00) }, /* SK-9Exx */
105 { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4b00) }, /* DGE-560T */ 105 { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4b00) }, /* DGE-560T */
106 { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4001) }, /* DGE-550SX */ 106 { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4001) }, /* DGE-550SX */
107 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4340) }, 107 { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4B02) }, /* DGE-560SX */
108 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4341) }, 108 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4340) }, /* 88E8021 */
109 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4342) }, 109 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4341) }, /* 88E8022 */
110 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4343) }, 110 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4342) }, /* 88E8061 */
111 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4344) }, 111 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4343) }, /* 88E8062 */
112 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4345) }, 112 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4344) }, /* 88E8021 */
113 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4346) }, 113 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4345) }, /* 88E8022 */
114 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4347) }, 114 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4346) }, /* 88E8061 */
115 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4350) }, 115 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4347) }, /* 88E8062 */
116 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4351) }, 116 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4350) }, /* 88E8035 */
117 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4352) }, 117 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4351) }, /* 88E8036 */
118 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4353) }, 118 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4352) }, /* 88E8038 */
119 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4360) }, 119 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4353) }, /* 88E8039 */
120 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4361) }, 120 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4356) }, /* 88EC033 */
121 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4362) }, 121 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4360) }, /* 88E8052 */
122 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4363) }, 122 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4361) }, /* 88E8050 */
123 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4364) }, 123 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4362) }, /* 88E8053 */
124 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4365) }, 124 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4363) }, /* 88E8055 */
125 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4366) }, 125 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4364) }, /* 88E8056 */
126 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4367) }, 126 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4366) }, /* 88EC036 */
127 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4368) }, 127 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4367) }, /* 88EC032 */
128 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4369) }, 128 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4368) }, /* 88EC034 */
129 { 0 } 129 { 0 }
130}; 130};
131 131
@@ -521,7 +521,7 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
521 /* set Tx LED (LED_TX) to blink mode on Rx OR Tx activity */ 521 /* set Tx LED (LED_TX) to blink mode on Rx OR Tx activity */
522 ledctrl |= PHY_M_LED_BLINK_RT(BLINK_84MS) | PHY_M_LEDC_TX_CTRL; 522 ledctrl |= PHY_M_LED_BLINK_RT(BLINK_84MS) | PHY_M_LEDC_TX_CTRL;
523 /* turn off the Rx LED (LED_RX) */ 523 /* turn off the Rx LED (LED_RX) */
524 ledover |= PHY_M_LED_MO_RX(MO_LED_OFF); 524 ledover &= ~PHY_M_LED_MO_RX;
525 } 525 }
526 526
527 if (hw->chip_id == CHIP_ID_YUKON_EC_U && hw->chip_rev == CHIP_REV_YU_EC_A1) { 527 if (hw->chip_id == CHIP_ID_YUKON_EC_U && hw->chip_rev == CHIP_REV_YU_EC_A1) {
@@ -544,7 +544,7 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
544 544
545 if (sky2->autoneg == AUTONEG_DISABLE || sky2->speed == SPEED_100) { 545 if (sky2->autoneg == AUTONEG_DISABLE || sky2->speed == SPEED_100) {
546 /* turn on 100 Mbps LED (LED_LINK100) */ 546 /* turn on 100 Mbps LED (LED_LINK100) */
547 ledover |= PHY_M_LED_MO_100(MO_LED_ON); 547 ledover |= PHY_M_LED_MO_100;
548 } 548 }
549 549
550 if (ledover) 550 if (ledover)
@@ -676,17 +676,15 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port)
676 /* Flush Rx MAC FIFO on any flow control or error */ 676 /* Flush Rx MAC FIFO on any flow control or error */
677 sky2_write16(hw, SK_REG(port, RX_GMF_FL_MSK), GMR_FS_ANY_ERR); 677 sky2_write16(hw, SK_REG(port, RX_GMF_FL_MSK), GMR_FS_ANY_ERR);
678 678
679 /* Set threshold to 0xa (64 bytes) 679 /* Set threshold to 0xa (64 bytes) + 1 to workaround pause bug */
680 * ASF disabled so no need to do WA dev #4.30 680 sky2_write16(hw, SK_REG(port, RX_GMF_FL_THR), RX_GMF_FL_THR_DEF+1);
681 */
682 sky2_write16(hw, SK_REG(port, RX_GMF_FL_THR), RX_GMF_FL_THR_DEF);
683 681
684 /* Configure Tx MAC FIFO */ 682 /* Configure Tx MAC FIFO */
685 sky2_write8(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_RST_CLR); 683 sky2_write8(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_RST_CLR);
686 sky2_write16(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_OPER_ON); 684 sky2_write16(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_OPER_ON);
687 685
688 if (hw->chip_id == CHIP_ID_YUKON_EC_U) { 686 if (hw->chip_id == CHIP_ID_YUKON_EC_U) {
689 sky2_write8(hw, SK_REG(port, RX_GMF_LP_THR), 512/8); 687 sky2_write8(hw, SK_REG(port, RX_GMF_LP_THR), 768/8);
690 sky2_write8(hw, SK_REG(port, RX_GMF_UP_THR), 1024/8); 688 sky2_write8(hw, SK_REG(port, RX_GMF_UP_THR), 1024/8);
691 if (hw->dev[port]->mtu > ETH_DATA_LEN) { 689 if (hw->dev[port]->mtu > ETH_DATA_LEN) {
692 /* set Tx GMAC FIFO Almost Empty Threshold */ 690 /* set Tx GMAC FIFO Almost Empty Threshold */
@@ -698,10 +696,15 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port)
698 696
699} 697}
700 698
701/* Assign Ram Buffer allocation in units of 64bit (8 bytes) */ 699/* Assign Ram Buffer allocation to queue */
702static void sky2_ramset(struct sky2_hw *hw, u16 q, u32 start, u32 end) 700static void sky2_ramset(struct sky2_hw *hw, u16 q, u32 start, u32 space)
703{ 701{
704 pr_debug(PFX "q %d %#x %#x\n", q, start, end); 702 u32 end;
703
704 /* convert from K bytes to qwords used for hw register */
705 start *= 1024/8;
706 space *= 1024/8;
707 end = start + space - 1;
705 708
706 sky2_write8(hw, RB_ADDR(q, RB_CTRL), RB_RST_CLR); 709 sky2_write8(hw, RB_ADDR(q, RB_CTRL), RB_RST_CLR);
707 sky2_write32(hw, RB_ADDR(q, RB_START), start); 710 sky2_write32(hw, RB_ADDR(q, RB_START), start);
@@ -710,7 +713,6 @@ static void sky2_ramset(struct sky2_hw *hw, u16 q, u32 start, u32 end)
710 sky2_write32(hw, RB_ADDR(q, RB_RP), start); 713 sky2_write32(hw, RB_ADDR(q, RB_RP), start);
711 714
712 if (q == Q_R1 || q == Q_R2) { 715 if (q == Q_R1 || q == Q_R2) {
713 u32 space = end - start + 1;
714 u32 tp = space - space/4; 716 u32 tp = space - space/4;
715 717
716 /* On receive queue's set the thresholds 718 /* On receive queue's set the thresholds
@@ -1060,10 +1062,16 @@ static int sky2_rx_start(struct sky2_port *sky2)
1060 sky2->rx_put = sky2->rx_next = 0; 1062 sky2->rx_put = sky2->rx_next = 0;
1061 sky2_qset(hw, rxq); 1063 sky2_qset(hw, rxq);
1062 1064
1063 if (hw->chip_id == CHIP_ID_YUKON_EC_U && hw->chip_rev >= 2) { 1065 /* On PCI express lowering the watermark gives better performance */
1064 /* MAC Rx RAM Read is controlled by hardware */ 1066 if (pci_find_capability(hw->pdev, PCI_CAP_ID_EXP))
1067 sky2_write32(hw, Q_ADDR(rxq, Q_WM), BMU_WM_PEX);
1068
1069 /* These chips have no ram buffer?
1070 * MAC Rx RAM Read is controlled by hardware */
1071 if (hw->chip_id == CHIP_ID_YUKON_EC_U &&
1072 (hw->chip_rev == CHIP_REV_YU_EC_U_A1
1073 || hw->chip_rev == CHIP_REV_YU_EC_U_B0))
1065 sky2_write32(hw, Q_ADDR(rxq, Q_F), F_M_RX_RAM_DIS); 1074 sky2_write32(hw, Q_ADDR(rxq, Q_F), F_M_RX_RAM_DIS);
1066 }
1067 1075
1068 sky2_prefetch_init(hw, rxq, sky2->rx_le_map, RX_LE_SIZE - 1); 1076 sky2_prefetch_init(hw, rxq, sky2->rx_le_map, RX_LE_SIZE - 1);
1069 1077
@@ -1139,7 +1147,7 @@ static int sky2_up(struct net_device *dev)
1139 struct sky2_port *sky2 = netdev_priv(dev); 1147 struct sky2_port *sky2 = netdev_priv(dev);
1140 struct sky2_hw *hw = sky2->hw; 1148 struct sky2_hw *hw = sky2->hw;
1141 unsigned port = sky2->port; 1149 unsigned port = sky2->port;
1142 u32 ramsize, rxspace, imask; 1150 u32 ramsize, imask;
1143 int cap, err = -ENOMEM; 1151 int cap, err = -ENOMEM;
1144 struct net_device *otherdev = hw->dev[sky2->port^1]; 1152 struct net_device *otherdev = hw->dev[sky2->port^1];
1145 1153
@@ -1192,20 +1200,25 @@ static int sky2_up(struct net_device *dev)
1192 1200
1193 sky2_mac_init(hw, port); 1201 sky2_mac_init(hw, port);
1194 1202
1195 /* Determine available ram buffer space in qwords. */ 1203 /* Register is number of 4K blocks on internal RAM buffer. */
1196 ramsize = sky2_read8(hw, B2_E_0) * 4096/8; 1204 ramsize = sky2_read8(hw, B2_E_0) * 4;
1205 printk(KERN_INFO PFX "%s: ram buffer %dK\n", dev->name, ramsize);
1197 1206
1198 if (ramsize > 6*1024/8) 1207 if (ramsize > 0) {
1199 rxspace = ramsize - (ramsize + 2) / 3; 1208 u32 rxspace;
1200 else
1201 rxspace = ramsize / 2;
1202 1209
1203 sky2_ramset(hw, rxqaddr[port], 0, rxspace-1); 1210 if (ramsize < 16)
1204 sky2_ramset(hw, txqaddr[port], rxspace, ramsize-1); 1211 rxspace = ramsize / 2;
1212 else
1213 rxspace = 8 + (2*(ramsize - 16))/3;
1205 1214
1206 /* Make sure SyncQ is disabled */ 1215 sky2_ramset(hw, rxqaddr[port], 0, rxspace);
1207 sky2_write8(hw, RB_ADDR(port == 0 ? Q_XS1 : Q_XS2, RB_CTRL), 1216 sky2_ramset(hw, txqaddr[port], rxspace, ramsize - rxspace);
1208 RB_RST_SET); 1217
1218 /* Make sure SyncQ is disabled */
1219 sky2_write8(hw, RB_ADDR(port == 0 ? Q_XS1 : Q_XS2, RB_CTRL),
1220 RB_RST_SET);
1221 }
1209 1222
1210 sky2_qset(hw, txqaddr[port]); 1223 sky2_qset(hw, txqaddr[port]);
1211 1224
@@ -1350,7 +1363,7 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev)
1350 u32 tcpsum; 1363 u32 tcpsum;
1351 1364
1352 tcpsum = offset << 16; /* sum start */ 1365 tcpsum = offset << 16; /* sum start */
1353 tcpsum |= offset + skb->csum; /* sum write */ 1366 tcpsum |= offset + skb->csum_offset; /* sum write */
1354 1367
1355 ctrl = CALSUM | WR_SUM | INIT_SUM | LOCK_SUM; 1368 ctrl = CALSUM | WR_SUM | INIT_SUM | LOCK_SUM;
1356 if (skb->nh.iph->protocol == IPPROTO_UDP) 1369 if (skb->nh.iph->protocol == IPPROTO_UDP)
@@ -1453,7 +1466,7 @@ static void sky2_tx_complete(struct sky2_port *sky2, u16 done)
1453 if (unlikely(netif_msg_tx_done(sky2))) 1466 if (unlikely(netif_msg_tx_done(sky2)))
1454 printk(KERN_DEBUG "%s: tx done %u\n", 1467 printk(KERN_DEBUG "%s: tx done %u\n",
1455 dev->name, idx); 1468 dev->name, idx);
1456 dev_kfree_skb(re->skb); 1469 dev_kfree_skb_any(re->skb);
1457 } 1470 }
1458 1471
1459 le->opcode = 0; /* paranoia */ 1472 le->opcode = 0; /* paranoia */
@@ -1509,7 +1522,7 @@ static int sky2_down(struct net_device *dev)
1509 1522
1510 /* WA for dev. #4.209 */ 1523 /* WA for dev. #4.209 */
1511 if (hw->chip_id == CHIP_ID_YUKON_EC_U 1524 if (hw->chip_id == CHIP_ID_YUKON_EC_U
1512 && hw->chip_rev == CHIP_REV_YU_EC_U_A1) 1525 && (hw->chip_rev == CHIP_REV_YU_EC_U_A1 || hw->chip_rev == CHIP_REV_YU_EC_U_B0))
1513 sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T), 1526 sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T),
1514 sky2->speed != SPEED_1000 ? 1527 sky2->speed != SPEED_1000 ?
1515 TX_STFW_ENA : TX_STFW_DIS); 1528 TX_STFW_ENA : TX_STFW_DIS);
@@ -2065,7 +2078,7 @@ static int sky2_status_intr(struct sky2_hw *hw, int to_do)
2065 case OP_RXSTAT: 2078 case OP_RXSTAT:
2066 skb = sky2_receive(dev, length, status); 2079 skb = sky2_receive(dev, length, status);
2067 if (!skb) 2080 if (!skb)
2068 break; 2081 goto force_update;
2069 2082
2070 skb->protocol = eth_type_trans(skb, dev); 2083 skb->protocol = eth_type_trans(skb, dev);
2071 dev->last_rx = jiffies; 2084 dev->last_rx = jiffies;
@@ -2081,8 +2094,8 @@ static int sky2_status_intr(struct sky2_hw *hw, int to_do)
2081 2094
2082 /* Update receiver after 16 frames */ 2095 /* Update receiver after 16 frames */
2083 if (++buf_write[le->link] == RX_BUF_WRITE) { 2096 if (++buf_write[le->link] == RX_BUF_WRITE) {
2084 sky2_put_idx(hw, rxqaddr[le->link], 2097force_update:
2085 sky2->rx_put); 2098 sky2_put_idx(hw, rxqaddr[le->link], sky2->rx_put);
2086 buf_write[le->link] = 0; 2099 buf_write[le->link] = 0;
2087 } 2100 }
2088 2101
@@ -2917,18 +2930,8 @@ static void sky2_led(struct sky2_hw *hw, unsigned port, int on)
2917 2930
2918 default: 2931 default:
2919 gm_phy_write(hw, port, PHY_MARV_LED_CTRL, 0); 2932 gm_phy_write(hw, port, PHY_MARV_LED_CTRL, 0);
2920 gm_phy_write(hw, port, PHY_MARV_LED_OVER, 2933 gm_phy_write(hw, port, PHY_MARV_LED_OVER,
2921 on ? PHY_M_LED_MO_DUP(MO_LED_ON) | 2934 on ? PHY_M_LED_ALL : 0);
2922 PHY_M_LED_MO_10(MO_LED_ON) |
2923 PHY_M_LED_MO_100(MO_LED_ON) |
2924 PHY_M_LED_MO_1000(MO_LED_ON) |
2925 PHY_M_LED_MO_RX(MO_LED_ON)
2926 : PHY_M_LED_MO_DUP(MO_LED_OFF) |
2927 PHY_M_LED_MO_10(MO_LED_OFF) |
2928 PHY_M_LED_MO_100(MO_LED_OFF) |
2929 PHY_M_LED_MO_1000(MO_LED_OFF) |
2930 PHY_M_LED_MO_RX(MO_LED_OFF));
2931
2932 } 2935 }
2933} 2936}
2934 2937
@@ -3311,7 +3314,7 @@ static irqreturn_t __devinit sky2_test_intr(int irq, void *dev_id)
3311 return IRQ_NONE; 3314 return IRQ_NONE;
3312 3315
3313 if (status & Y2_IS_IRQ_SW) { 3316 if (status & Y2_IS_IRQ_SW) {
3314 hw->msi_detected = 1; 3317 hw->msi = 1;
3315 wake_up(&hw->msi_wait); 3318 wake_up(&hw->msi_wait);
3316 sky2_write8(hw, B0_CTST, CS_CL_SW_IRQ); 3319 sky2_write8(hw, B0_CTST, CS_CL_SW_IRQ);
3317 } 3320 }
@@ -3330,7 +3333,7 @@ static int __devinit sky2_test_msi(struct sky2_hw *hw)
3330 3333
3331 sky2_write32(hw, B0_IMSK, Y2_IS_IRQ_SW); 3334 sky2_write32(hw, B0_IMSK, Y2_IS_IRQ_SW);
3332 3335
3333 err = request_irq(pdev->irq, sky2_test_intr, IRQF_SHARED, DRV_NAME, hw); 3336 err = request_irq(pdev->irq, sky2_test_intr, 0, DRV_NAME, hw);
3334 if (err) { 3337 if (err) {
3335 printk(KERN_ERR PFX "%s: cannot assign irq %d\n", 3338 printk(KERN_ERR PFX "%s: cannot assign irq %d\n",
3336 pci_name(pdev), pdev->irq); 3339 pci_name(pdev), pdev->irq);
@@ -3340,9 +3343,9 @@ static int __devinit sky2_test_msi(struct sky2_hw *hw)
3340 sky2_write8(hw, B0_CTST, CS_ST_SW_IRQ); 3343 sky2_write8(hw, B0_CTST, CS_ST_SW_IRQ);
3341 sky2_read8(hw, B0_CTST); 3344 sky2_read8(hw, B0_CTST);
3342 3345
3343 wait_event_timeout(hw->msi_wait, hw->msi_detected, HZ/10); 3346 wait_event_timeout(hw->msi_wait, hw->msi, HZ/10);
3344 3347
3345 if (!hw->msi_detected) { 3348 if (!hw->msi) {
3346 /* MSI test failed, go back to INTx mode */ 3349 /* MSI test failed, go back to INTx mode */
3347 printk(KERN_INFO PFX "%s: No interrupt generated using MSI, " 3350 printk(KERN_INFO PFX "%s: No interrupt generated using MSI, "
3348 "switching to INTx mode.\n", 3351 "switching to INTx mode.\n",
@@ -3475,7 +3478,8 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
3475 goto err_out_free_netdev; 3478 goto err_out_free_netdev;
3476 } 3479 }
3477 3480
3478 err = request_irq(pdev->irq, sky2_intr, IRQF_SHARED, dev->name, hw); 3481 err = request_irq(pdev->irq, sky2_intr, hw->msi ? 0 : IRQF_SHARED,
3482 dev->name, hw);
3479 if (err) { 3483 if (err) {
3480 printk(KERN_ERR PFX "%s: cannot assign irq %d\n", 3484 printk(KERN_ERR PFX "%s: cannot assign irq %d\n",
3481 pci_name(pdev), pdev->irq); 3485 pci_name(pdev), pdev->irq);
@@ -3505,7 +3509,8 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
3505 return 0; 3509 return 0;
3506 3510
3507err_out_unregister: 3511err_out_unregister:
3508 pci_disable_msi(pdev); 3512 if (hw->msi)
3513 pci_disable_msi(pdev);
3509 unregister_netdev(dev); 3514 unregister_netdev(dev);
3510err_out_free_netdev: 3515err_out_free_netdev:
3511 free_netdev(dev); 3516 free_netdev(dev);
@@ -3548,7 +3553,8 @@ static void __devexit sky2_remove(struct pci_dev *pdev)
3548 sky2_read8(hw, B0_CTST); 3553 sky2_read8(hw, B0_CTST);
3549 3554
3550 free_irq(pdev->irq, hw); 3555 free_irq(pdev->irq, hw);
3551 pci_disable_msi(pdev); 3556 if (hw->msi)
3557 pci_disable_msi(pdev);
3552 pci_free_consistent(pdev, STATUS_LE_BYTES, hw->st_le, hw->st_dma); 3558 pci_free_consistent(pdev, STATUS_LE_BYTES, hw->st_le, hw->st_dma);
3553 pci_release_regions(pdev); 3559 pci_release_regions(pdev);
3554 pci_disable_device(pdev); 3560 pci_disable_device(pdev);
diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h
index 6d2a23f66c9a..6ed1d47dbbd3 100644
--- a/drivers/net/sky2.h
+++ b/drivers/net/sky2.h
@@ -383,8 +383,13 @@ enum {
383 CHIP_REV_YU_EC_A2 = 1, /* Chip Rev. for Yukon-EC A2 */ 383 CHIP_REV_YU_EC_A2 = 1, /* Chip Rev. for Yukon-EC A2 */
384 CHIP_REV_YU_EC_A3 = 2, /* Chip Rev. for Yukon-EC A3 */ 384 CHIP_REV_YU_EC_A3 = 2, /* Chip Rev. for Yukon-EC A3 */
385 385
386 CHIP_REV_YU_EC_U_A0 = 0, 386 CHIP_REV_YU_EC_U_A0 = 1,
387 CHIP_REV_YU_EC_U_A1 = 1, 387 CHIP_REV_YU_EC_U_A1 = 2,
388 CHIP_REV_YU_EC_U_B0 = 3,
389
390 CHIP_REV_YU_FE_A1 = 1,
391 CHIP_REV_YU_FE_A2 = 2,
392
388}; 393};
389 394
390/* B2_Y2_CLK_GATE 8 bit Clock Gating (Yukon-2 only) */ 395/* B2_Y2_CLK_GATE 8 bit Clock Gating (Yukon-2 only) */
@@ -603,7 +608,7 @@ enum {
603 PHY_ADDR_MARV = 0, 608 PHY_ADDR_MARV = 0,
604}; 609};
605 610
606#define RB_ADDR(offs, queue) (B16_RAM_REGS + (queue) + (offs)) 611#define RB_ADDR(offs, queue) ((u16) B16_RAM_REGS + (queue) + (offs))
607 612
608 613
609enum { 614enum {
@@ -675,6 +680,7 @@ enum {
675 BMU_FIFO_ENA | BMU_OP_ON, 680 BMU_FIFO_ENA | BMU_OP_ON,
676 681
677 BMU_WM_DEFAULT = 0x600, 682 BMU_WM_DEFAULT = 0x600,
683 BMU_WM_PEX = 0x80,
678}; 684};
679 685
680/* Tx BMU Control / Status Registers (Yukon-2) */ 686/* Tx BMU Control / Status Registers (Yukon-2) */
@@ -1055,7 +1061,7 @@ enum {
1055 PHY_M_PC_EN_DET_PLUS = 3<<8, /* Energy Detect Plus (Mode 2) */ 1061 PHY_M_PC_EN_DET_PLUS = 3<<8, /* Energy Detect Plus (Mode 2) */
1056}; 1062};
1057 1063
1058#define PHY_M_PC_MDI_XMODE(x) (((x)<<5) & PHY_M_PC_MDIX_MSK) 1064#define PHY_M_PC_MDI_XMODE(x) (((u16)(x)<<5) & PHY_M_PC_MDIX_MSK)
1059 1065
1060enum { 1066enum {
1061 PHY_M_PC_MAN_MDI = 0, /* 00 = Manual MDI configuration */ 1067 PHY_M_PC_MAN_MDI = 0, /* 00 = Manual MDI configuration */
@@ -1151,13 +1157,13 @@ enum {
1151 PHY_M_EC_TX_TIM_CT = 1<<1, /* RGMII Tx Timing Control */ 1157 PHY_M_EC_TX_TIM_CT = 1<<1, /* RGMII Tx Timing Control */
1152 PHY_M_EC_TRANS_DIS = 1<<0, /* Transmitter Disable (88E1111 only) */}; 1158 PHY_M_EC_TRANS_DIS = 1<<0, /* Transmitter Disable (88E1111 only) */};
1153 1159
1154#define PHY_M_EC_M_DSC(x) ((x)<<10 & PHY_M_EC_M_DSC_MSK) 1160#define PHY_M_EC_M_DSC(x) ((u16)(x)<<10 & PHY_M_EC_M_DSC_MSK)
1155 /* 00=1x; 01=2x; 10=3x; 11=4x */ 1161 /* 00=1x; 01=2x; 10=3x; 11=4x */
1156#define PHY_M_EC_S_DSC(x) ((x)<<8 & PHY_M_EC_S_DSC_MSK) 1162#define PHY_M_EC_S_DSC(x) ((u16)(x)<<8 & PHY_M_EC_S_DSC_MSK)
1157 /* 00=dis; 01=1x; 10=2x; 11=3x */ 1163 /* 00=dis; 01=1x; 10=2x; 11=3x */
1158#define PHY_M_EC_DSC_2(x) ((x)<<9 & PHY_M_EC_M_DSC_MSK2) 1164#define PHY_M_EC_DSC_2(x) ((u16)(x)<<9 & PHY_M_EC_M_DSC_MSK2)
1159 /* 000=1x; 001=2x; 010=3x; 011=4x */ 1165 /* 000=1x; 001=2x; 010=3x; 011=4x */
1160#define PHY_M_EC_MAC_S(x) ((x)<<4 & PHY_M_EC_MAC_S_MSK) 1166#define PHY_M_EC_MAC_S(x) ((u16)(x)<<4 & PHY_M_EC_MAC_S_MSK)
1161 /* 01X=0; 110=2.5; 111=25 (MHz) */ 1167 /* 01X=0; 110=2.5; 111=25 (MHz) */
1162 1168
1163/* for Yukon-2 Gigabit Ethernet PHY (88E1112 only) */ 1169/* for Yukon-2 Gigabit Ethernet PHY (88E1112 only) */
@@ -1168,7 +1174,7 @@ enum {
1168}; 1174};
1169/* !!! Errata in spec. (1 = disable) */ 1175/* !!! Errata in spec. (1 = disable) */
1170 1176
1171#define PHY_M_PC_DSC(x) (((x)<<12) & PHY_M_PC_DSC_MSK) 1177#define PHY_M_PC_DSC(x) (((u16)(x)<<12) & PHY_M_PC_DSC_MSK)
1172 /* 100=5x; 101=6x; 110=7x; 111=8x */ 1178 /* 100=5x; 101=6x; 110=7x; 111=8x */
1173enum { 1179enum {
1174 MAC_TX_CLK_0_MHZ = 2, 1180 MAC_TX_CLK_0_MHZ = 2,
@@ -1198,7 +1204,7 @@ enum {
1198 PHY_M_LEDC_TX_C_MSB = 1<<0, /* Tx Control (MSB, 88E1111 only) */ 1204 PHY_M_LEDC_TX_C_MSB = 1<<0, /* Tx Control (MSB, 88E1111 only) */
1199}; 1205};
1200 1206
1201#define PHY_M_LED_PULS_DUR(x) (((x)<<12) & PHY_M_LEDC_PULS_MSK) 1207#define PHY_M_LED_PULS_DUR(x) (((u16)(x)<<12) & PHY_M_LEDC_PULS_MSK)
1202 1208
1203/***** PHY_MARV_PHY_STAT (page 3)16 bit r/w Polarity Control Reg. *****/ 1209/***** PHY_MARV_PHY_STAT (page 3)16 bit r/w Polarity Control Reg. *****/
1204enum { 1210enum {
@@ -1228,7 +1234,7 @@ enum {
1228 PULS_1300MS = 7,/* 1.3 s to 2.7 s */ 1234 PULS_1300MS = 7,/* 1.3 s to 2.7 s */
1229}; 1235};
1230 1236
1231#define PHY_M_LED_BLINK_RT(x) (((x)<<8) & PHY_M_LEDC_BL_R_MSK) 1237#define PHY_M_LED_BLINK_RT(x) (((u16)(x)<<8) & PHY_M_LEDC_BL_R_MSK)
1232 1238
1233enum { 1239enum {
1234 BLINK_42MS = 0,/* 42 ms */ 1240 BLINK_42MS = 0,/* 42 ms */
@@ -1238,21 +1244,18 @@ enum {
1238 BLINK_670MS = 4,/* 670 ms */ 1244 BLINK_670MS = 4,/* 670 ms */
1239}; 1245};
1240 1246
1241/***** PHY_MARV_LED_OVER 16 bit r/w Manual LED Override Reg *****/ 1247/**** PHY_MARV_LED_OVER 16 bit r/w LED control */
1242#define PHY_M_LED_MO_SGMII(x) ((x)<<14) /* Bit 15..14: SGMII AN Timer */
1243 /* Bit 13..12: reserved */
1244#define PHY_M_LED_MO_DUP(x) ((x)<<10) /* Bit 11..10: Duplex */
1245#define PHY_M_LED_MO_10(x) ((x)<<8) /* Bit 9.. 8: Link 10 */
1246#define PHY_M_LED_MO_100(x) ((x)<<6) /* Bit 7.. 6: Link 100 */
1247#define PHY_M_LED_MO_1000(x) ((x)<<4) /* Bit 5.. 4: Link 1000 */
1248#define PHY_M_LED_MO_RX(x) ((x)<<2) /* Bit 3.. 2: Rx */
1249#define PHY_M_LED_MO_TX(x) ((x)<<0) /* Bit 1.. 0: Tx */
1250
1251enum { 1248enum {
1252 MO_LED_NORM = 0, 1249 PHY_M_LED_MO_DUP = 3<<10,/* Bit 11..10: Duplex */
1253 MO_LED_BLINK = 1, 1250 PHY_M_LED_MO_10 = 3<<8, /* Bit 9.. 8: Link 10 */
1254 MO_LED_OFF = 2, 1251 PHY_M_LED_MO_100 = 3<<6, /* Bit 7.. 6: Link 100 */
1255 MO_LED_ON = 3, 1252 PHY_M_LED_MO_1000 = 3<<4, /* Bit 5.. 4: Link 1000 */
1253 PHY_M_LED_MO_RX = 3<<2, /* Bit 3.. 2: Rx */
1254 PHY_M_LED_MO_TX = 3<<0, /* Bit 1.. 0: Tx */
1255
1256 PHY_M_LED_ALL = PHY_M_LED_MO_DUP | PHY_M_LED_MO_10
1257 | PHY_M_LED_MO_100 | PHY_M_LED_MO_1000
1258 | PHY_M_LED_MO_RX,
1256}; 1259};
1257 1260
1258/***** PHY_MARV_EXT_CTRL_2 16 bit r/w Ext. PHY Specific Ctrl 2 *****/ 1261/***** PHY_MARV_EXT_CTRL_2 16 bit r/w Ext. PHY Specific Ctrl 2 *****/
@@ -1289,9 +1292,9 @@ enum {
1289 PHY_M_FELP_LED0_MSK = 0xf, /* Bit 3.. 0: LED0 Mask (SPEED) */ 1292 PHY_M_FELP_LED0_MSK = 0xf, /* Bit 3.. 0: LED0 Mask (SPEED) */
1290}; 1293};
1291 1294
1292#define PHY_M_FELP_LED2_CTRL(x) (((x)<<8) & PHY_M_FELP_LED2_MSK) 1295#define PHY_M_FELP_LED2_CTRL(x) (((u16)(x)<<8) & PHY_M_FELP_LED2_MSK)
1293#define PHY_M_FELP_LED1_CTRL(x) (((x)<<4) & PHY_M_FELP_LED1_MSK) 1296#define PHY_M_FELP_LED1_CTRL(x) (((u16)(x)<<4) & PHY_M_FELP_LED1_MSK)
1294#define PHY_M_FELP_LED0_CTRL(x) (((x)<<0) & PHY_M_FELP_LED0_MSK) 1297#define PHY_M_FELP_LED0_CTRL(x) (((u16)(x)<<0) & PHY_M_FELP_LED0_MSK)
1295 1298
1296enum { 1299enum {
1297 LED_PAR_CTRL_COLX = 0x00, 1300 LED_PAR_CTRL_COLX = 0x00,
@@ -1547,8 +1550,8 @@ enum {
1547 GM_SMI_CT_BUSY = 1<<3, /* Bit 3: Busy (Operation in progress) */ 1550 GM_SMI_CT_BUSY = 1<<3, /* Bit 3: Busy (Operation in progress) */
1548}; 1551};
1549 1552
1550#define GM_SMI_CT_PHY_AD(x) (((x)<<11) & GM_SMI_CT_PHY_A_MSK) 1553#define GM_SMI_CT_PHY_AD(x) (((u16)(x)<<11) & GM_SMI_CT_PHY_A_MSK)
1551#define GM_SMI_CT_REG_AD(x) (((x)<<6) & GM_SMI_CT_REG_A_MSK) 1554#define GM_SMI_CT_REG_AD(x) (((u16)(x)<<6) & GM_SMI_CT_REG_A_MSK)
1552 1555
1553/* GM_PHY_ADDR 16 bit r/w GPHY Address Register */ 1556/* GM_PHY_ADDR 16 bit r/w GPHY Address Register */
1554enum { 1557enum {
@@ -1895,7 +1898,7 @@ struct sky2_hw {
1895 dma_addr_t st_dma; 1898 dma_addr_t st_dma;
1896 1899
1897 struct timer_list idle_timer; 1900 struct timer_list idle_timer;
1898 int msi_detected; 1901 int msi;
1899 wait_queue_head_t msi_wait; 1902 wait_queue_head_t msi_wait;
1900}; 1903};
1901 1904
diff --git a/drivers/net/smc-ultra.c b/drivers/net/smc-ultra.c
index 889ef0d7c374..d70bc9795346 100644
--- a/drivers/net/smc-ultra.c
+++ b/drivers/net/smc-ultra.c
@@ -593,7 +593,7 @@ static void cleanup_card(struct net_device *dev)
593 iounmap(ei_status.mem); 593 iounmap(ei_status.mem);
594} 594}
595 595
596void 596void __exit
597cleanup_module(void) 597cleanup_module(void)
598{ 598{
599 int this_dev; 599 int this_dev;
diff --git a/drivers/net/smc-ultra32.c b/drivers/net/smc-ultra32.c
index e10755ec5def..2c5319c62fa5 100644
--- a/drivers/net/smc-ultra32.c
+++ b/drivers/net/smc-ultra32.c
@@ -437,7 +437,7 @@ int __init init_module(void)
437 return -ENXIO; 437 return -ENXIO;
438} 438}
439 439
440void cleanup_module(void) 440void __exit cleanup_module(void)
441{ 441{
442 int this_dev; 442 int this_dev;
443 443
diff --git a/drivers/net/smc9194.c b/drivers/net/smc9194.c
index c0d13d650913..bd6e84506c29 100644
--- a/drivers/net/smc9194.c
+++ b/drivers/net/smc9194.c
@@ -1616,7 +1616,7 @@ int __init init_module(void)
1616 return 0; 1616 return 0;
1617} 1617}
1618 1618
1619void cleanup_module(void) 1619void __exit cleanup_module(void)
1620{ 1620{
1621 unregister_netdev(devSMC9194); 1621 unregister_netdev(devSMC9194);
1622 free_irq(devSMC9194->irq, devSMC9194); 1622 free_irq(devSMC9194->irq, devSMC9194);
diff --git a/drivers/net/smc91x.c b/drivers/net/smc91x.c
index 95b6478f55c6..e62a9586fb95 100644
--- a/drivers/net/smc91x.c
+++ b/drivers/net/smc91x.c
@@ -210,6 +210,7 @@ struct smc_local {
210 210
211 /* work queue */ 211 /* work queue */
212 struct work_struct phy_configure; 212 struct work_struct phy_configure;
213 struct net_device *dev;
213 int work_pending; 214 int work_pending;
214 215
215 spinlock_t lock; 216 spinlock_t lock;
@@ -1114,10 +1115,11 @@ static void smc_phy_check_media(struct net_device *dev, int init)
1114 * of autonegotiation.) If the RPC ANEG bit is cleared, the selection 1115 * of autonegotiation.) If the RPC ANEG bit is cleared, the selection
1115 * is controlled by the RPC SPEED and RPC DPLX bits. 1116 * is controlled by the RPC SPEED and RPC DPLX bits.
1116 */ 1117 */
1117static void smc_phy_configure(void *data) 1118static void smc_phy_configure(struct work_struct *work)
1118{ 1119{
1119 struct net_device *dev = data; 1120 struct smc_local *lp =
1120 struct smc_local *lp = netdev_priv(dev); 1121 container_of(work, struct smc_local, phy_configure);
1122 struct net_device *dev = lp->dev;
1121 void __iomem *ioaddr = lp->base; 1123 void __iomem *ioaddr = lp->base;
1122 int phyaddr = lp->mii.phy_id; 1124 int phyaddr = lp->mii.phy_id;
1123 int my_phy_caps; /* My PHY capabilities */ 1125 int my_phy_caps; /* My PHY capabilities */
@@ -1592,7 +1594,7 @@ smc_open(struct net_device *dev)
1592 1594
1593 /* Configure the PHY, initialize the link state */ 1595 /* Configure the PHY, initialize the link state */
1594 if (lp->phy_type != 0) 1596 if (lp->phy_type != 0)
1595 smc_phy_configure(dev); 1597 smc_phy_configure(&lp->phy_configure);
1596 else { 1598 else {
1597 spin_lock_irq(&lp->lock); 1599 spin_lock_irq(&lp->lock);
1598 smc_10bt_check_media(dev, 1); 1600 smc_10bt_check_media(dev, 1);
@@ -1972,7 +1974,8 @@ static int __init smc_probe(struct net_device *dev, void __iomem *ioaddr)
1972#endif 1974#endif
1973 1975
1974 tasklet_init(&lp->tx_task, smc_hardware_send_pkt, (unsigned long)dev); 1976 tasklet_init(&lp->tx_task, smc_hardware_send_pkt, (unsigned long)dev);
1975 INIT_WORK(&lp->phy_configure, smc_phy_configure, dev); 1977 INIT_WORK(&lp->phy_configure, smc_phy_configure);
1978 lp->dev = dev;
1976 lp->mii.phy_id_mask = 0x1f; 1979 lp->mii.phy_id_mask = 0x1f;
1977 lp->mii.reg_num_mask = 0x1f; 1980 lp->mii.reg_num_mask = 0x1f;
1978 lp->mii.force_media = 0; 1981 lp->mii.force_media = 0;
@@ -2322,7 +2325,7 @@ static int smc_drv_resume(struct platform_device *dev)
2322 smc_reset(ndev); 2325 smc_reset(ndev);
2323 smc_enable(ndev); 2326 smc_enable(ndev);
2324 if (lp->phy_type != 0) 2327 if (lp->phy_type != 0)
2325 smc_phy_configure(ndev); 2328 smc_phy_configure(&lp->phy_configure);
2326 netif_device_attach(ndev); 2329 netif_device_attach(ndev);
2327 } 2330 }
2328 } 2331 }
diff --git a/drivers/net/smc91x.h b/drivers/net/smc91x.h
index a8640169fc77..9367c574477a 100644
--- a/drivers/net/smc91x.h
+++ b/drivers/net/smc91x.h
@@ -238,7 +238,7 @@ SMC_outw(u16 val, void __iomem *ioaddr, int reg)
238#define SMC_CAN_USE_16BIT 1 238#define SMC_CAN_USE_16BIT 1
239#define SMC_CAN_USE_32BIT 0 239#define SMC_CAN_USE_32BIT 0
240 240
241#define SMC_inb(a, r) inb((u32)a) + (r)) 241#define SMC_inb(a, r) inb(((u32)a) + (r))
242#define SMC_inw(a, r) inw(((u32)a) + (r)) 242#define SMC_inw(a, r) inw(((u32)a) + (r))
243#define SMC_outb(v, a, r) outb(v, ((u32)a) + (r)) 243#define SMC_outb(v, a, r) outb(v, ((u32)a) + (r))
244#define SMC_outw(v, a, r) outw(v, ((u32)a) + (r)) 244#define SMC_outw(v, a, r) outw(v, ((u32)a) + (r))
@@ -434,6 +434,24 @@ static inline void LPD7_SMC_outsw (unsigned char* a, int r,
434 434
435#define SMC_IRQ_FLAGS (0) 435#define SMC_IRQ_FLAGS (0)
436 436
437#elif defined(CONFIG_ARCH_VERSATILE)
438
439#define SMC_CAN_USE_8BIT 1
440#define SMC_CAN_USE_16BIT 1
441#define SMC_CAN_USE_32BIT 1
442#define SMC_NOWAIT 1
443
444#define SMC_inb(a, r) readb((a) + (r))
445#define SMC_inw(a, r) readw((a) + (r))
446#define SMC_inl(a, r) readl((a) + (r))
447#define SMC_outb(v, a, r) writeb(v, (a) + (r))
448#define SMC_outw(v, a, r) writew(v, (a) + (r))
449#define SMC_outl(v, a, r) writel(v, (a) + (r))
450#define SMC_insl(a, r, p, l) readsl((a) + (r), p, l)
451#define SMC_outsl(a, r, p, l) writesl((a) + (r), p, l)
452
453#define SMC_IRQ_FLAGS (0)
454
437#else 455#else
438 456
439#define SMC_CAN_USE_8BIT 1 457#define SMC_CAN_USE_8BIT 1
@@ -1216,7 +1234,7 @@ static const char * chip_ids[ 16 ] = {
1216 if (SMC_CAN_USE_32BIT) { \ 1234 if (SMC_CAN_USE_32BIT) { \
1217 void *__ptr = (p); \ 1235 void *__ptr = (p); \
1218 int __len = (l); \ 1236 int __len = (l); \
1219 void *__ioaddr = ioaddr; \ 1237 void __iomem *__ioaddr = ioaddr; \
1220 if (__len >= 2 && (unsigned long)__ptr & 2) { \ 1238 if (__len >= 2 && (unsigned long)__ptr & 2) { \
1221 __len -= 2; \ 1239 __len -= 2; \
1222 SMC_outw(*(u16 *)__ptr, ioaddr, DATA_REG); \ 1240 SMC_outw(*(u16 *)__ptr, ioaddr, DATA_REG); \
@@ -1240,7 +1258,7 @@ static const char * chip_ids[ 16 ] = {
1240 if (SMC_CAN_USE_32BIT) { \ 1258 if (SMC_CAN_USE_32BIT) { \
1241 void *__ptr = (p); \ 1259 void *__ptr = (p); \
1242 int __len = (l); \ 1260 int __len = (l); \
1243 void *__ioaddr = ioaddr; \ 1261 void __iomem *__ioaddr = ioaddr; \
1244 if ((unsigned long)__ptr & 2) { \ 1262 if ((unsigned long)__ptr & 2) { \
1245 /* \ 1263 /* \
1246 * We want 32bit alignment here. \ 1264 * We want 32bit alignment here. \
diff --git a/drivers/net/spider_net.c b/drivers/net/spider_net.c
index 418138dd6c68..ebb6aa39f9c7 100644
--- a/drivers/net/spider_net.c
+++ b/drivers/net/spider_net.c
@@ -88,12 +88,11 @@ MODULE_DEVICE_TABLE(pci, spider_net_pci_tbl);
88static inline u32 88static inline u32
89spider_net_read_reg(struct spider_net_card *card, u32 reg) 89spider_net_read_reg(struct spider_net_card *card, u32 reg)
90{ 90{
91 u32 value; 91 /* We use the powerpc specific variants instead of readl_be() because
92 92 * we know spidernet is not a real PCI device and we can thus avoid the
93 value = readl(card->regs + reg); 93 * performance hit caused by the PCI workarounds.
94 value = le32_to_cpu(value); 94 */
95 95 return in_be32(card->regs + reg);
96 return value;
97} 96}
98 97
99/** 98/**
@@ -105,8 +104,11 @@ spider_net_read_reg(struct spider_net_card *card, u32 reg)
105static inline void 104static inline void
106spider_net_write_reg(struct spider_net_card *card, u32 reg, u32 value) 105spider_net_write_reg(struct spider_net_card *card, u32 reg, u32 value)
107{ 106{
108 value = cpu_to_le32(value); 107 /* We use the powerpc specific variants instead of writel_be() because
109 writel(value, card->regs + reg); 108 * we know spidernet is not a real PCI device and we can thus avoid the
109 * performance hit caused by the PCI workarounds.
110 */
111 out_be32(card->regs + reg, value);
110} 112}
111 113
112/** spider_net_write_phy - write to phy register 114/** spider_net_write_phy - write to phy register
@@ -644,20 +646,12 @@ spider_net_prepare_tx_descr(struct spider_net_card *card,
644 struct spider_net_descr *descr; 646 struct spider_net_descr *descr;
645 dma_addr_t buf; 647 dma_addr_t buf;
646 unsigned long flags; 648 unsigned long flags;
647 int length;
648
649 length = skb->len;
650 if (length < ETH_ZLEN) {
651 if (skb_pad(skb, ETH_ZLEN-length))
652 return 0;
653 length = ETH_ZLEN;
654 }
655 649
656 buf = pci_map_single(card->pdev, skb->data, length, PCI_DMA_TODEVICE); 650 buf = pci_map_single(card->pdev, skb->data, skb->len, PCI_DMA_TODEVICE);
657 if (pci_dma_mapping_error(buf)) { 651 if (pci_dma_mapping_error(buf)) {
658 if (netif_msg_tx_err(card) && net_ratelimit()) 652 if (netif_msg_tx_err(card) && net_ratelimit())
659 pr_err("could not iommu-map packet (%p, %i). " 653 pr_err("could not iommu-map packet (%p, %i). "
660 "Dropping packet\n", skb->data, length); 654 "Dropping packet\n", skb->data, skb->len);
661 card->spider_stats.tx_iommu_map_error++; 655 card->spider_stats.tx_iommu_map_error++;
662 return -ENOMEM; 656 return -ENOMEM;
663 } 657 }
@@ -667,7 +661,7 @@ spider_net_prepare_tx_descr(struct spider_net_card *card,
667 card->tx_chain.head = descr->next; 661 card->tx_chain.head = descr->next;
668 662
669 descr->buf_addr = buf; 663 descr->buf_addr = buf;
670 descr->buf_size = length; 664 descr->buf_size = skb->len;
671 descr->next_descr_addr = 0; 665 descr->next_descr_addr = 0;
672 descr->skb = skb; 666 descr->skb = skb;
673 descr->data_status = 0; 667 descr->data_status = 0;
@@ -802,8 +796,8 @@ spider_net_release_tx_chain(struct spider_net_card *card, int brutal)
802 796
803 /* unmap the skb */ 797 /* unmap the skb */
804 if (skb) { 798 if (skb) {
805 int len = skb->len < ETH_ZLEN ? ETH_ZLEN : skb->len; 799 pci_unmap_single(card->pdev, buf_addr, skb->len,
806 pci_unmap_single(card->pdev, buf_addr, len, PCI_DMA_TODEVICE); 800 PCI_DMA_TODEVICE);
807 dev_kfree_skb(skb); 801 dev_kfree_skb(skb);
808 } 802 }
809 } 803 }
@@ -1641,7 +1635,7 @@ spider_net_enable_card(struct spider_net_card *card)
1641 SPIDER_NET_INT2_MASK_VALUE); 1635 SPIDER_NET_INT2_MASK_VALUE);
1642 1636
1643 spider_net_write_reg(card, SPIDER_NET_GDTDMACCNTR, 1637 spider_net_write_reg(card, SPIDER_NET_GDTDMACCNTR,
1644 SPIDER_NET_GDTBSTA | SPIDER_NET_GDTDCEIDIS); 1638 SPIDER_NET_GDTBSTA);
1645} 1639}
1646 1640
1647/** 1641/**
@@ -1945,10 +1939,11 @@ spider_net_stop(struct net_device *netdev)
1945 * called as task when tx hangs, resets interface (if interface is up) 1939 * called as task when tx hangs, resets interface (if interface is up)
1946 */ 1940 */
1947static void 1941static void
1948spider_net_tx_timeout_task(void *data) 1942spider_net_tx_timeout_task(struct work_struct *work)
1949{ 1943{
1950 struct net_device *netdev = data; 1944 struct spider_net_card *card =
1951 struct spider_net_card *card = netdev_priv(netdev); 1945 container_of(work, struct spider_net_card, tx_timeout_task);
1946 struct net_device *netdev = card->netdev;
1952 1947
1953 if (!(netdev->flags & IFF_UP)) 1948 if (!(netdev->flags & IFF_UP))
1954 goto out; 1949 goto out;
@@ -2122,7 +2117,7 @@ spider_net_alloc_card(void)
2122 card = netdev_priv(netdev); 2117 card = netdev_priv(netdev);
2123 card->netdev = netdev; 2118 card->netdev = netdev;
2124 card->msg_enable = SPIDER_NET_DEFAULT_MSG; 2119 card->msg_enable = SPIDER_NET_DEFAULT_MSG;
2125 INIT_WORK(&card->tx_timeout_task, spider_net_tx_timeout_task, netdev); 2120 INIT_WORK(&card->tx_timeout_task, spider_net_tx_timeout_task);
2126 init_waitqueue_head(&card->waitq); 2121 init_waitqueue_head(&card->waitq);
2127 atomic_set(&card->tx_timeout_task_counter, 0); 2122 atomic_set(&card->tx_timeout_task_counter, 0);
2128 2123
diff --git a/drivers/net/spider_net.h b/drivers/net/spider_net.h
index b3b46119b424..3e196df29790 100644
--- a/drivers/net/spider_net.h
+++ b/drivers/net/spider_net.h
@@ -24,7 +24,7 @@
24#ifndef _SPIDER_NET_H 24#ifndef _SPIDER_NET_H
25#define _SPIDER_NET_H 25#define _SPIDER_NET_H
26 26
27#define VERSION "1.1 A" 27#define VERSION "1.6 A"
28 28
29#include "sungem_phy.h" 29#include "sungem_phy.h"
30 30
@@ -217,8 +217,7 @@ extern char spider_net_driver_name[];
217#define SPIDER_NET_GDTBSTA 0x00000300 217#define SPIDER_NET_GDTBSTA 0x00000300
218#define SPIDER_NET_GDTDCEIDIS 0x00000002 218#define SPIDER_NET_GDTDCEIDIS 0x00000002
219#define SPIDER_NET_DMA_TX_VALUE SPIDER_NET_TX_DMA_EN | \ 219#define SPIDER_NET_DMA_TX_VALUE SPIDER_NET_TX_DMA_EN | \
220 SPIDER_NET_GDTBSTA | \ 220 SPIDER_NET_GDTBSTA
221 SPIDER_NET_GDTDCEIDIS
222 221
223#define SPIDER_NET_DMA_TX_FEND_VALUE 0x00030003 222#define SPIDER_NET_DMA_TX_FEND_VALUE 0x00030003
224 223
@@ -328,7 +327,8 @@ enum spider_net_int2_status {
328 SPIDER_NET_GRISPDNGINT 327 SPIDER_NET_GRISPDNGINT
329}; 328};
330 329
331#define SPIDER_NET_TXINT ( (1 << SPIDER_NET_GDTFDCINT) ) 330#define SPIDER_NET_TXINT ( (1 << SPIDER_NET_GDTFDCINT) | \
331 (1 << SPIDER_NET_GDTDCEINT) )
332 332
333/* We rely on flagged descriptor interrupts */ 333/* We rely on flagged descriptor interrupts */
334#define SPIDER_NET_RXINT ( (1 << SPIDER_NET_GDAFDCINT) ) 334#define SPIDER_NET_RXINT ( (1 << SPIDER_NET_GDAFDCINT) )
diff --git a/drivers/net/starfire.c b/drivers/net/starfire.c
index 7a0aee6c869d..bf873ea25797 100644
--- a/drivers/net/starfire.c
+++ b/drivers/net/starfire.c
@@ -41,6 +41,7 @@
41#include <linux/ethtool.h> 41#include <linux/ethtool.h>
42#include <linux/mii.h> 42#include <linux/mii.h>
43#include <linux/if_vlan.h> 43#include <linux/if_vlan.h>
44#include <linux/mm.h>
44#include <asm/processor.h> /* Processor type for cache alignment. */ 45#include <asm/processor.h> /* Processor type for cache alignment. */
45#include <asm/uaccess.h> 46#include <asm/uaccess.h>
46#include <asm/io.h> 47#include <asm/io.h>
diff --git a/drivers/net/sun3lance.c b/drivers/net/sun3lance.c
index b865db363ba0..c62e85d89f41 100644
--- a/drivers/net/sun3lance.c
+++ b/drivers/net/sun3lance.c
@@ -38,6 +38,7 @@ static char *version = "sun3lance.c: v1.2 1/12/2001 Sam Creasey (sammy@sammy.ne
38#include <linux/skbuff.h> 38#include <linux/skbuff.h>
39#include <linux/bitops.h> 39#include <linux/bitops.h>
40 40
41#include <asm/cacheflush.h>
41#include <asm/setup.h> 42#include <asm/setup.h>
42#include <asm/irq.h> 43#include <asm/irq.h>
43#include <asm/io.h> 44#include <asm/io.h>
@@ -944,7 +945,7 @@ static void set_multicast_list( struct net_device *dev )
944 945
945static struct net_device *sun3lance_dev; 946static struct net_device *sun3lance_dev;
946 947
947int init_module(void) 948int __init init_module(void)
948{ 949{
949 sun3lance_dev = sun3lance_probe(-1); 950 sun3lance_dev = sun3lance_probe(-1);
950 if (IS_ERR(sun3lance_dev)) 951 if (IS_ERR(sun3lance_dev))
@@ -952,7 +953,7 @@ int init_module(void)
952 return 0; 953 return 0;
953} 954}
954 955
955void cleanup_module(void) 956void __exit cleanup_module(void)
956{ 957{
957 unregister_netdev(sun3lance_dev); 958 unregister_netdev(sun3lance_dev);
958#ifdef CONFIG_SUN3 959#ifdef CONFIG_SUN3
diff --git a/drivers/net/sundance.c b/drivers/net/sundance.c
index 41c503d8bac4..c06ecc8002b9 100644
--- a/drivers/net/sundance.c
+++ b/drivers/net/sundance.c
@@ -264,8 +264,6 @@ enum alta_offsets {
264 ASICCtrl = 0x30, 264 ASICCtrl = 0x30,
265 EEData = 0x34, 265 EEData = 0x34,
266 EECtrl = 0x36, 266 EECtrl = 0x36,
267 TxStartThresh = 0x3c,
268 RxEarlyThresh = 0x3e,
269 FlashAddr = 0x40, 267 FlashAddr = 0x40,
270 FlashData = 0x44, 268 FlashData = 0x44,
271 TxStatus = 0x46, 269 TxStatus = 0x46,
@@ -790,6 +788,7 @@ static int netdev_open(struct net_device *dev)
790{ 788{
791 struct netdev_private *np = netdev_priv(dev); 789 struct netdev_private *np = netdev_priv(dev);
792 void __iomem *ioaddr = np->base; 790 void __iomem *ioaddr = np->base;
791 unsigned long flags;
793 int i; 792 int i;
794 793
795 /* Do we need to reset the chip??? */ 794 /* Do we need to reset the chip??? */
@@ -834,6 +833,10 @@ static int netdev_open(struct net_device *dev)
834 iowrite8(0x01, ioaddr + DebugCtrl1); 833 iowrite8(0x01, ioaddr + DebugCtrl1);
835 netif_start_queue(dev); 834 netif_start_queue(dev);
836 835
836 spin_lock_irqsave(&np->lock, flags);
837 reset_tx(dev);
838 spin_unlock_irqrestore(&np->lock, flags);
839
837 iowrite16 (StatsEnable | RxEnable | TxEnable, ioaddr + MACCtrl1); 840 iowrite16 (StatsEnable | RxEnable | TxEnable, ioaddr + MACCtrl1);
838 841
839 if (netif_msg_ifup(np)) 842 if (netif_msg_ifup(np))
@@ -1081,6 +1084,8 @@ reset_tx (struct net_device *dev)
1081 1084
1082 /* free all tx skbuff */ 1085 /* free all tx skbuff */
1083 for (i = 0; i < TX_RING_SIZE; i++) { 1086 for (i = 0; i < TX_RING_SIZE; i++) {
1087 np->tx_ring[i].next_desc = 0;
1088
1084 skb = np->tx_skbuff[i]; 1089 skb = np->tx_skbuff[i];
1085 if (skb) { 1090 if (skb) {
1086 pci_unmap_single(np->pci_dev, 1091 pci_unmap_single(np->pci_dev,
@@ -1096,6 +1101,10 @@ reset_tx (struct net_device *dev)
1096 } 1101 }
1097 np->cur_tx = np->dirty_tx = 0; 1102 np->cur_tx = np->dirty_tx = 0;
1098 np->cur_task = 0; 1103 np->cur_task = 0;
1104
1105 np->last_tx = NULL;
1106 iowrite8(127, ioaddr + TxDMAPollPeriod);
1107
1099 iowrite16 (StatsEnable | RxEnable | TxEnable, ioaddr + MACCtrl1); 1108 iowrite16 (StatsEnable | RxEnable | TxEnable, ioaddr + MACCtrl1);
1100 return 0; 1109 return 0;
1101} 1110}
@@ -1111,6 +1120,7 @@ static irqreturn_t intr_handler(int irq, void *dev_instance)
1111 int tx_cnt; 1120 int tx_cnt;
1112 int tx_status; 1121 int tx_status;
1113 int handled = 0; 1122 int handled = 0;
1123 int i;
1114 1124
1115 1125
1116 do { 1126 do {
@@ -1153,21 +1163,24 @@ static irqreturn_t intr_handler(int irq, void *dev_instance)
1153 np->stats.tx_fifo_errors++; 1163 np->stats.tx_fifo_errors++;
1154 if (tx_status & 0x02) 1164 if (tx_status & 0x02)
1155 np->stats.tx_window_errors++; 1165 np->stats.tx_window_errors++;
1166
1156 /* 1167 /*
1157 ** This reset has been verified on 1168 ** This reset has been verified on
1158 ** DFE-580TX boards ! phdm@macqel.be. 1169 ** DFE-580TX boards ! phdm@macqel.be.
1159 */ 1170 */
1160 if (tx_status & 0x10) { /* TxUnderrun */ 1171 if (tx_status & 0x10) { /* TxUnderrun */
1161 unsigned short txthreshold;
1162
1163 txthreshold = ioread16 (ioaddr + TxStartThresh);
1164 /* Restart Tx FIFO and transmitter */ 1172 /* Restart Tx FIFO and transmitter */
1165 sundance_reset(dev, (NetworkReset|FIFOReset|TxReset) << 16); 1173 sundance_reset(dev, (NetworkReset|FIFOReset|TxReset) << 16);
1166 iowrite16 (txthreshold, ioaddr + TxStartThresh);
1167 /* No need to reset the Tx pointer here */ 1174 /* No need to reset the Tx pointer here */
1168 } 1175 }
1169 /* Restart the Tx. */ 1176 /* Restart the Tx. Need to make sure tx enabled */
1170 iowrite16 (TxEnable, ioaddr + MACCtrl1); 1177 i = 10;
1178 do {
1179 iowrite16(ioread16(ioaddr + MACCtrl1) | TxEnable, ioaddr + MACCtrl1);
1180 if (ioread16(ioaddr + MACCtrl1) & TxEnabled)
1181 break;
1182 mdelay(1);
1183 } while (--i);
1171 } 1184 }
1172 /* Yup, this is a documentation bug. It cost me *hours*. */ 1185 /* Yup, this is a documentation bug. It cost me *hours*. */
1173 iowrite16 (0, ioaddr + TxStatus); 1186 iowrite16 (0, ioaddr + TxStatus);
@@ -1629,6 +1642,14 @@ static int netdev_close(struct net_device *dev)
1629 struct sk_buff *skb; 1642 struct sk_buff *skb;
1630 int i; 1643 int i;
1631 1644
1645 /* Wait and kill tasklet */
1646 tasklet_kill(&np->rx_tasklet);
1647 tasklet_kill(&np->tx_tasklet);
1648 np->cur_tx = 0;
1649 np->dirty_tx = 0;
1650 np->cur_task = 0;
1651 np->last_tx = NULL;
1652
1632 netif_stop_queue(dev); 1653 netif_stop_queue(dev);
1633 1654
1634 if (netif_msg_ifdown(np)) { 1655 if (netif_msg_ifdown(np)) {
@@ -1643,12 +1664,26 @@ static int netdev_close(struct net_device *dev)
1643 /* Disable interrupts by clearing the interrupt mask. */ 1664 /* Disable interrupts by clearing the interrupt mask. */
1644 iowrite16(0x0000, ioaddr + IntrEnable); 1665 iowrite16(0x0000, ioaddr + IntrEnable);
1645 1666
1667 /* Disable Rx and Tx DMA for safely release resource */
1668 iowrite32(0x500, ioaddr + DMACtrl);
1669
1646 /* Stop the chip's Tx and Rx processes. */ 1670 /* Stop the chip's Tx and Rx processes. */
1647 iowrite16(TxDisable | RxDisable | StatsDisable, ioaddr + MACCtrl1); 1671 iowrite16(TxDisable | RxDisable | StatsDisable, ioaddr + MACCtrl1);
1648 1672
1649 /* Wait and kill tasklet */ 1673 for (i = 2000; i > 0; i--) {
1650 tasklet_kill(&np->rx_tasklet); 1674 if ((ioread32(ioaddr + DMACtrl) & 0xc000) == 0)
1651 tasklet_kill(&np->tx_tasklet); 1675 break;
1676 mdelay(1);
1677 }
1678
1679 iowrite16(GlobalReset | DMAReset | FIFOReset | NetworkReset,
1680 ioaddr +ASICCtrl + 2);
1681
1682 for (i = 2000; i > 0; i--) {
1683 if ((ioread16(ioaddr + ASICCtrl +2) & ResetBusy) == 0)
1684 break;
1685 mdelay(1);
1686 }
1652 1687
1653#ifdef __i386__ 1688#ifdef __i386__
1654 if (netif_msg_hw(np)) { 1689 if (netif_msg_hw(np)) {
@@ -1686,6 +1721,7 @@ static int netdev_close(struct net_device *dev)
1686 } 1721 }
1687 } 1722 }
1688 for (i = 0; i < TX_RING_SIZE; i++) { 1723 for (i = 0; i < TX_RING_SIZE; i++) {
1724 np->tx_ring[i].next_desc = 0;
1689 skb = np->tx_skbuff[i]; 1725 skb = np->tx_skbuff[i];
1690 if (skb) { 1726 if (skb) {
1691 pci_unmap_single(np->pci_dev, 1727 pci_unmap_single(np->pci_dev,
diff --git a/drivers/net/sungem.c b/drivers/net/sungem.c
index 253e96e7ad20..785e4a535f9e 100644
--- a/drivers/net/sungem.c
+++ b/drivers/net/sungem.c
@@ -56,6 +56,7 @@
56#include <linux/if_vlan.h> 56#include <linux/if_vlan.h>
57#include <linux/bitops.h> 57#include <linux/bitops.h>
58#include <linux/mutex.h> 58#include <linux/mutex.h>
59#include <linux/mm.h>
59 60
60#include <asm/system.h> 61#include <asm/system.h>
61#include <asm/io.h> 62#include <asm/io.h>
@@ -1030,7 +1031,7 @@ static int gem_start_xmit(struct sk_buff *skb, struct net_device *dev)
1030 u64 csum_start_off, csum_stuff_off; 1031 u64 csum_start_off, csum_stuff_off;
1031 1032
1032 csum_start_off = (u64) (skb->h.raw - skb->data); 1033 csum_start_off = (u64) (skb->h.raw - skb->data);
1033 csum_stuff_off = (u64) ((skb->h.raw + skb->csum) - skb->data); 1034 csum_stuff_off = csum_start_off + skb->csum_offset;
1034 1035
1035 ctrl = (TXDCTRL_CENAB | 1036 ctrl = (TXDCTRL_CENAB |
1036 (csum_start_off << 15) | 1037 (csum_start_off << 15) |
@@ -2281,9 +2282,9 @@ static void gem_do_stop(struct net_device *dev, int wol)
2281 } 2282 }
2282} 2283}
2283 2284
2284static void gem_reset_task(void *data) 2285static void gem_reset_task(struct work_struct *work)
2285{ 2286{
2286 struct gem *gp = (struct gem *) data; 2287 struct gem *gp = container_of(work, struct gem, reset_task);
2287 2288
2288 mutex_lock(&gp->pm_mutex); 2289 mutex_lock(&gp->pm_mutex);
2289 2290
@@ -3043,7 +3044,7 @@ static int __devinit gem_init_one(struct pci_dev *pdev,
3043 gp->link_timer.function = gem_link_timer; 3044 gp->link_timer.function = gem_link_timer;
3044 gp->link_timer.data = (unsigned long) gp; 3045 gp->link_timer.data = (unsigned long) gp;
3045 3046
3046 INIT_WORK(&gp->reset_task, gem_reset_task, gp); 3047 INIT_WORK(&gp->reset_task, gem_reset_task);
3047 3048
3048 gp->lstate = link_down; 3049 gp->lstate = link_down;
3049 gp->timer_ticks = 0; 3050 gp->timer_ticks = 0;
diff --git a/drivers/net/sunhme.c b/drivers/net/sunhme.c
index 9d7cd130c19d..ef671739cfea 100644
--- a/drivers/net/sunhme.c
+++ b/drivers/net/sunhme.c
@@ -32,6 +32,7 @@
32#include <linux/netdevice.h> 32#include <linux/netdevice.h>
33#include <linux/etherdevice.h> 33#include <linux/etherdevice.h>
34#include <linux/skbuff.h> 34#include <linux/skbuff.h>
35#include <linux/mm.h>
35#include <linux/bitops.h> 36#include <linux/bitops.h>
36 37
37#include <asm/system.h> 38#include <asm/system.h>
@@ -2272,7 +2273,7 @@ static int happy_meal_start_xmit(struct sk_buff *skb, struct net_device *dev)
2272 u32 csum_start_off, csum_stuff_off; 2273 u32 csum_start_off, csum_stuff_off;
2273 2274
2274 csum_start_off = (u32) (skb->h.raw - skb->data); 2275 csum_start_off = (u32) (skb->h.raw - skb->data);
2275 csum_stuff_off = (u32) ((skb->h.raw + skb->csum) - skb->data); 2276 csum_stuff_off = csum_start_off + skb->csum_offset;
2276 2277
2277 tx_flags = (TXFLAG_OWN | TXFLAG_CSENABLE | 2278 tx_flags = (TXFLAG_OWN | TXFLAG_CSENABLE |
2278 ((csum_start_off << 14) & TXFLAG_CSBUFBEGIN) | 2279 ((csum_start_off << 14) & TXFLAG_CSBUFBEGIN) |
@@ -3012,6 +3013,11 @@ static int __devinit happy_meal_pci_probe(struct pci_dev *pdev,
3012#endif 3013#endif
3013 3014
3014 err = -ENODEV; 3015 err = -ENODEV;
3016
3017 if (pci_enable_device(pdev))
3018 goto err_out;
3019 pci_set_master(pdev);
3020
3015 if (!strcmp(prom_name, "SUNW,qfe") || !strcmp(prom_name, "qfe")) { 3021 if (!strcmp(prom_name, "SUNW,qfe") || !strcmp(prom_name, "qfe")) {
3016 qp = quattro_pci_find(pdev); 3022 qp = quattro_pci_find(pdev);
3017 if (qp == NULL) 3023 if (qp == NULL)
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 8e398499c045..571320ae87ab 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -68,8 +68,8 @@
68 68
69#define DRV_MODULE_NAME "tg3" 69#define DRV_MODULE_NAME "tg3"
70#define PFX DRV_MODULE_NAME ": " 70#define PFX DRV_MODULE_NAME ": "
71#define DRV_MODULE_VERSION "3.67" 71#define DRV_MODULE_VERSION "3.70"
72#define DRV_MODULE_RELDATE "October 18, 2006" 72#define DRV_MODULE_RELDATE "December 1, 2006"
73 73
74#define TG3_DEF_MAC_MODE 0 74#define TG3_DEF_MAC_MODE 0
75#define TG3_DEF_RX_MODE 0 75#define TG3_DEF_RX_MODE 0
@@ -192,6 +192,7 @@ static struct pci_device_id tg3_pci_tbl[] = {
192 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5786)}, 192 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5786)},
193 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5787)}, 193 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5787)},
194 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5787M)}, 194 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5787M)},
195 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5787F)},
195 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5714)}, 196 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5714)},
196 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5714S)}, 197 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5714S)},
197 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5715)}, 198 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5715)},
@@ -1061,7 +1062,7 @@ static void tg3_frob_aux_power(struct tg3 *tp)
1061{ 1062{
1062 struct tg3 *tp_peer = tp; 1063 struct tg3 *tp_peer = tp;
1063 1064
1064 if ((tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) != 0) 1065 if ((tp->tg3_flags2 & TG3_FLG2_IS_NIC) == 0)
1065 return; 1066 return;
1066 1067
1067 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) || 1068 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) ||
@@ -1212,8 +1213,8 @@ static int tg3_set_power_state(struct tg3 *tp, pci_power_t state)
1212 power_control); 1213 power_control);
1213 udelay(100); /* Delay after power state change */ 1214 udelay(100); /* Delay after power state change */
1214 1215
1215 /* Switch out of Vaux if it is not a LOM */ 1216 /* Switch out of Vaux if it is a NIC */
1216 if (!(tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT)) 1217 if (tp->tg3_flags2 & TG3_FLG2_IS_NIC)
1217 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl, 100); 1218 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl, 100);
1218 1219
1219 return 0; 1220 return 0;
@@ -1401,8 +1402,10 @@ static int tg3_set_power_state(struct tg3 *tp, pci_power_t state)
1401static void tg3_link_report(struct tg3 *tp) 1402static void tg3_link_report(struct tg3 *tp)
1402{ 1403{
1403 if (!netif_carrier_ok(tp->dev)) { 1404 if (!netif_carrier_ok(tp->dev)) {
1404 printk(KERN_INFO PFX "%s: Link is down.\n", tp->dev->name); 1405 if (netif_msg_link(tp))
1405 } else { 1406 printk(KERN_INFO PFX "%s: Link is down.\n",
1407 tp->dev->name);
1408 } else if (netif_msg_link(tp)) {
1406 printk(KERN_INFO PFX "%s: Link is up at %d Mbps, %s duplex.\n", 1409 printk(KERN_INFO PFX "%s: Link is up at %d Mbps, %s duplex.\n",
1407 tp->dev->name, 1410 tp->dev->name,
1408 (tp->link_config.active_speed == SPEED_1000 ? 1411 (tp->link_config.active_speed == SPEED_1000 ?
@@ -1557,12 +1560,6 @@ static void tg3_phy_copper_begin(struct tg3 *tp)
1557 1560
1558 tg3_writephy(tp, MII_ADVERTISE, new_adv); 1561 tg3_writephy(tp, MII_ADVERTISE, new_adv);
1559 } else if (tp->link_config.speed == SPEED_INVALID) { 1562 } else if (tp->link_config.speed == SPEED_INVALID) {
1560 tp->link_config.advertising =
1561 (ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full |
1562 ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full |
1563 ADVERTISED_1000baseT_Half | ADVERTISED_1000baseT_Full |
1564 ADVERTISED_Autoneg | ADVERTISED_MII);
1565
1566 if (tp->tg3_flags & TG3_FLAG_10_100_ONLY) 1563 if (tp->tg3_flags & TG3_FLAG_10_100_ONLY)
1567 tp->link_config.advertising &= 1564 tp->link_config.advertising &=
1568 ~(ADVERTISED_1000baseT_Half | 1565 ~(ADVERTISED_1000baseT_Half |
@@ -1706,25 +1703,36 @@ static int tg3_init_5401phy_dsp(struct tg3 *tp)
1706 return err; 1703 return err;
1707} 1704}
1708 1705
1709static int tg3_copper_is_advertising_all(struct tg3 *tp) 1706static int tg3_copper_is_advertising_all(struct tg3 *tp, u32 mask)
1710{ 1707{
1711 u32 adv_reg, all_mask; 1708 u32 adv_reg, all_mask = 0;
1709
1710 if (mask & ADVERTISED_10baseT_Half)
1711 all_mask |= ADVERTISE_10HALF;
1712 if (mask & ADVERTISED_10baseT_Full)
1713 all_mask |= ADVERTISE_10FULL;
1714 if (mask & ADVERTISED_100baseT_Half)
1715 all_mask |= ADVERTISE_100HALF;
1716 if (mask & ADVERTISED_100baseT_Full)
1717 all_mask |= ADVERTISE_100FULL;
1712 1718
1713 if (tg3_readphy(tp, MII_ADVERTISE, &adv_reg)) 1719 if (tg3_readphy(tp, MII_ADVERTISE, &adv_reg))
1714 return 0; 1720 return 0;
1715 1721
1716 all_mask = (ADVERTISE_10HALF | ADVERTISE_10FULL |
1717 ADVERTISE_100HALF | ADVERTISE_100FULL);
1718 if ((adv_reg & all_mask) != all_mask) 1722 if ((adv_reg & all_mask) != all_mask)
1719 return 0; 1723 return 0;
1720 if (!(tp->tg3_flags & TG3_FLAG_10_100_ONLY)) { 1724 if (!(tp->tg3_flags & TG3_FLAG_10_100_ONLY)) {
1721 u32 tg3_ctrl; 1725 u32 tg3_ctrl;
1722 1726
1727 all_mask = 0;
1728 if (mask & ADVERTISED_1000baseT_Half)
1729 all_mask |= ADVERTISE_1000HALF;
1730 if (mask & ADVERTISED_1000baseT_Full)
1731 all_mask |= ADVERTISE_1000FULL;
1732
1723 if (tg3_readphy(tp, MII_TG3_CTRL, &tg3_ctrl)) 1733 if (tg3_readphy(tp, MII_TG3_CTRL, &tg3_ctrl))
1724 return 0; 1734 return 0;
1725 1735
1726 all_mask = (MII_TG3_CTRL_ADV_1000_HALF |
1727 MII_TG3_CTRL_ADV_1000_FULL);
1728 if ((tg3_ctrl & all_mask) != all_mask) 1736 if ((tg3_ctrl & all_mask) != all_mask)
1729 return 0; 1737 return 0;
1730 } 1738 }
@@ -1884,7 +1892,8 @@ static int tg3_setup_copper_phy(struct tg3 *tp, int force_reset)
1884 /* Force autoneg restart if we are exiting 1892 /* Force autoneg restart if we are exiting
1885 * low power mode. 1893 * low power mode.
1886 */ 1894 */
1887 if (!tg3_copper_is_advertising_all(tp)) 1895 if (!tg3_copper_is_advertising_all(tp,
1896 tp->link_config.advertising))
1888 current_link_up = 0; 1897 current_link_up = 0;
1889 } else { 1898 } else {
1890 current_link_up = 0; 1899 current_link_up = 0;
@@ -3654,9 +3663,9 @@ static void tg3_poll_controller(struct net_device *dev)
3654} 3663}
3655#endif 3664#endif
3656 3665
3657static void tg3_reset_task(void *_data) 3666static void tg3_reset_task(struct work_struct *work)
3658{ 3667{
3659 struct tg3 *tp = _data; 3668 struct tg3 *tp = container_of(work, struct tg3, reset_task);
3660 unsigned int restart_timer; 3669 unsigned int restart_timer;
3661 3670
3662 tg3_full_lock(tp, 0); 3671 tg3_full_lock(tp, 0);
@@ -3703,8 +3712,9 @@ static void tg3_tx_timeout(struct net_device *dev)
3703{ 3712{
3704 struct tg3 *tp = netdev_priv(dev); 3713 struct tg3 *tp = netdev_priv(dev);
3705 3714
3706 printk(KERN_ERR PFX "%s: transmit timed out, resetting\n", 3715 if (netif_msg_tx_err(tp))
3707 dev->name); 3716 printk(KERN_ERR PFX "%s: transmit timed out, resetting\n",
3717 dev->name);
3708 3718
3709 schedule_work(&tp->reset_task); 3719 schedule_work(&tp->reset_task);
3710} 3720}
@@ -4728,10 +4738,11 @@ static int tg3_poll_fw(struct tg3 *tp)
4728 u32 val; 4738 u32 val;
4729 4739
4730 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) { 4740 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) {
4731 for (i = 0; i < 400; i++) { 4741 /* Wait up to 20ms for init done. */
4742 for (i = 0; i < 200; i++) {
4732 if (tr32(VCPU_STATUS) & VCPU_STATUS_INIT_DONE) 4743 if (tr32(VCPU_STATUS) & VCPU_STATUS_INIT_DONE)
4733 return 0; 4744 return 0;
4734 udelay(10); 4745 udelay(100);
4735 } 4746 }
4736 return -ENODEV; 4747 return -ENODEV;
4737 } 4748 }
@@ -6014,7 +6025,7 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
6014 tg3_abort_hw(tp, 1); 6025 tg3_abort_hw(tp, 1);
6015 } 6026 }
6016 6027
6017 if ((tp->tg3_flags2 & TG3_FLG2_MII_SERDES) && reset_phy) 6028 if (reset_phy)
6018 tg3_phy_reset(tp); 6029 tg3_phy_reset(tp);
6019 6030
6020 err = tg3_chip_reset(tp); 6031 err = tg3_chip_reset(tp);
@@ -6395,16 +6406,17 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
6395 udelay(40); 6406 udelay(40);
6396 6407
6397 /* tp->grc_local_ctrl is partially set up during tg3_get_invariants(). 6408 /* tp->grc_local_ctrl is partially set up during tg3_get_invariants().
6398 * If TG3_FLAG_EEPROM_WRITE_PROT is set, we should read the 6409 * If TG3_FLG2_IS_NIC is zero, we should read the
6399 * register to preserve the GPIO settings for LOMs. The GPIOs, 6410 * register to preserve the GPIO settings for LOMs. The GPIOs,
6400 * whether used as inputs or outputs, are set by boot code after 6411 * whether used as inputs or outputs, are set by boot code after
6401 * reset. 6412 * reset.
6402 */ 6413 */
6403 if (tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) { 6414 if (!(tp->tg3_flags2 & TG3_FLG2_IS_NIC)) {
6404 u32 gpio_mask; 6415 u32 gpio_mask;
6405 6416
6406 gpio_mask = GRC_LCLCTRL_GPIO_OE0 | GRC_LCLCTRL_GPIO_OE2 | 6417 gpio_mask = GRC_LCLCTRL_GPIO_OE0 | GRC_LCLCTRL_GPIO_OE1 |
6407 GRC_LCLCTRL_GPIO_OUTPUT0 | GRC_LCLCTRL_GPIO_OUTPUT2; 6418 GRC_LCLCTRL_GPIO_OE2 | GRC_LCLCTRL_GPIO_OUTPUT0 |
6419 GRC_LCLCTRL_GPIO_OUTPUT1 | GRC_LCLCTRL_GPIO_OUTPUT2;
6408 6420
6409 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752) 6421 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752)
6410 gpio_mask |= GRC_LCLCTRL_GPIO_OE3 | 6422 gpio_mask |= GRC_LCLCTRL_GPIO_OE3 |
@@ -6416,8 +6428,9 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
6416 tp->grc_local_ctrl |= tr32(GRC_LOCAL_CTRL) & gpio_mask; 6428 tp->grc_local_ctrl |= tr32(GRC_LOCAL_CTRL) & gpio_mask;
6417 6429
6418 /* GPIO1 must be driven high for eeprom write protect */ 6430 /* GPIO1 must be driven high for eeprom write protect */
6419 tp->grc_local_ctrl |= (GRC_LCLCTRL_GPIO_OE1 | 6431 if (tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT)
6420 GRC_LCLCTRL_GPIO_OUTPUT1); 6432 tp->grc_local_ctrl |= (GRC_LCLCTRL_GPIO_OE1 |
6433 GRC_LCLCTRL_GPIO_OUTPUT1);
6421 } 6434 }
6422 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl); 6435 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl);
6423 udelay(100); 6436 udelay(100);
@@ -6574,7 +6587,7 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
6574 tw32(GRC_LOCAL_CTRL, tp->grc_local_ctrl); 6587 tw32(GRC_LOCAL_CTRL, tp->grc_local_ctrl);
6575 } 6588 }
6576 6589
6577 err = tg3_setup_phy(tp, reset_phy); 6590 err = tg3_setup_phy(tp, 0);
6578 if (err) 6591 if (err)
6579 return err; 6592 return err;
6580 6593
@@ -6978,8 +6991,10 @@ static int tg3_open(struct net_device *dev)
6978 tg3_full_lock(tp, 0); 6991 tg3_full_lock(tp, 0);
6979 6992
6980 err = tg3_set_power_state(tp, PCI_D0); 6993 err = tg3_set_power_state(tp, PCI_D0);
6981 if (err) 6994 if (err) {
6995 tg3_full_unlock(tp);
6982 return err; 6996 return err;
6997 }
6983 6998
6984 tg3_disable_ints(tp); 6999 tg3_disable_ints(tp);
6985 tp->tg3_flags &= ~TG3_FLAG_INIT_COMPLETE; 7000 tp->tg3_flags &= ~TG3_FLAG_INIT_COMPLETE;
@@ -8653,7 +8668,9 @@ static int tg3_test_registers(struct tg3 *tp)
8653 return 0; 8668 return 0;
8654 8669
8655out: 8670out:
8656 printk(KERN_ERR PFX "Register test failed at offset %x\n", offset); 8671 if (netif_msg_hw(tp))
8672 printk(KERN_ERR PFX "Register test failed at offset %x\n",
8673 offset);
8657 tw32(offset, save_val); 8674 tw32(offset, save_val);
8658 return -EIO; 8675 return -EIO;
8659} 8676}
@@ -8778,17 +8795,20 @@ static int tg3_run_loopback(struct tg3 *tp, int loopback_mode)
8778 tg3_writephy(tp, 0x10, phy & ~0x4000); 8795 tg3_writephy(tp, 0x10, phy & ~0x4000);
8779 tg3_writephy(tp, MII_TG3_EPHY_TEST, phytest); 8796 tg3_writephy(tp, MII_TG3_EPHY_TEST, phytest);
8780 } 8797 }
8781 } 8798 val = BMCR_LOOPBACK | BMCR_FULLDPLX | BMCR_SPEED100;
8782 val = BMCR_LOOPBACK | BMCR_FULLDPLX; 8799 } else
8783 if (tp->tg3_flags & TG3_FLAG_10_100_ONLY) 8800 val = BMCR_LOOPBACK | BMCR_FULLDPLX | BMCR_SPEED1000;
8784 val |= BMCR_SPEED100;
8785 else
8786 val |= BMCR_SPEED1000;
8787 8801
8788 tg3_writephy(tp, MII_BMCR, val); 8802 tg3_writephy(tp, MII_BMCR, val);
8789 udelay(40); 8803 udelay(40);
8790 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) 8804
8805 mac_mode = (tp->mac_mode & ~MAC_MODE_PORT_MODE_MASK) |
8806 MAC_MODE_LINK_POLARITY;
8807 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) {
8791 tg3_writephy(tp, MII_TG3_EPHY_PTEST, 0x1800); 8808 tg3_writephy(tp, MII_TG3_EPHY_PTEST, 0x1800);
8809 mac_mode |= MAC_MODE_PORT_MODE_MII;
8810 } else
8811 mac_mode |= MAC_MODE_PORT_MODE_GMII;
8792 8812
8793 /* reset to prevent losing 1st rx packet intermittently */ 8813 /* reset to prevent losing 1st rx packet intermittently */
8794 if (tp->tg3_flags2 & TG3_FLG2_MII_SERDES) { 8814 if (tp->tg3_flags2 & TG3_FLG2_MII_SERDES) {
@@ -8796,12 +8816,6 @@ static int tg3_run_loopback(struct tg3 *tp, int loopback_mode)
8796 udelay(10); 8816 udelay(10);
8797 tw32_f(MAC_RX_MODE, tp->rx_mode); 8817 tw32_f(MAC_RX_MODE, tp->rx_mode);
8798 } 8818 }
8799 mac_mode = (tp->mac_mode & ~MAC_MODE_PORT_MODE_MASK) |
8800 MAC_MODE_LINK_POLARITY;
8801 if (tp->tg3_flags & TG3_FLAG_10_100_ONLY)
8802 mac_mode |= MAC_MODE_PORT_MODE_MII;
8803 else
8804 mac_mode |= MAC_MODE_PORT_MODE_GMII;
8805 if ((tp->phy_id & PHY_ID_MASK) == PHY_ID_BCM5401) { 8819 if ((tp->phy_id & PHY_ID_MASK) == PHY_ID_BCM5401) {
8806 mac_mode &= ~MAC_MODE_LINK_POLARITY; 8820 mac_mode &= ~MAC_MODE_LINK_POLARITY;
8807 tg3_writephy(tp, MII_TG3_EXT_CTRL, 8821 tg3_writephy(tp, MII_TG3_EXT_CTRL,
@@ -9453,16 +9467,12 @@ static void __devinit tg3_get_5906_nvram_info(struct tg3 *tp)
9453/* Chips other than 5700/5701 use the NVRAM for fetching info. */ 9467/* Chips other than 5700/5701 use the NVRAM for fetching info. */
9454static void __devinit tg3_nvram_init(struct tg3 *tp) 9468static void __devinit tg3_nvram_init(struct tg3 *tp)
9455{ 9469{
9456 int j;
9457
9458 tw32_f(GRC_EEPROM_ADDR, 9470 tw32_f(GRC_EEPROM_ADDR,
9459 (EEPROM_ADDR_FSM_RESET | 9471 (EEPROM_ADDR_FSM_RESET |
9460 (EEPROM_DEFAULT_CLOCK_PERIOD << 9472 (EEPROM_DEFAULT_CLOCK_PERIOD <<
9461 EEPROM_ADDR_CLKPERD_SHIFT))); 9473 EEPROM_ADDR_CLKPERD_SHIFT)));
9462 9474
9463 /* XXX schedule_timeout() ... */ 9475 msleep(1);
9464 for (j = 0; j < 100; j++)
9465 udelay(10);
9466 9476
9467 /* Enable seeprom accesses. */ 9477 /* Enable seeprom accesses. */
9468 tw32_f(GRC_LOCAL_CTRL, 9478 tw32_f(GRC_LOCAL_CTRL,
@@ -9523,12 +9533,12 @@ static int tg3_nvram_read_using_eeprom(struct tg3 *tp,
9523 EEPROM_ADDR_ADDR_MASK) | 9533 EEPROM_ADDR_ADDR_MASK) |
9524 EEPROM_ADDR_READ | EEPROM_ADDR_START); 9534 EEPROM_ADDR_READ | EEPROM_ADDR_START);
9525 9535
9526 for (i = 0; i < 10000; i++) { 9536 for (i = 0; i < 1000; i++) {
9527 tmp = tr32(GRC_EEPROM_ADDR); 9537 tmp = tr32(GRC_EEPROM_ADDR);
9528 9538
9529 if (tmp & EEPROM_ADDR_COMPLETE) 9539 if (tmp & EEPROM_ADDR_COMPLETE)
9530 break; 9540 break;
9531 udelay(100); 9541 msleep(1);
9532 } 9542 }
9533 if (!(tmp & EEPROM_ADDR_COMPLETE)) 9543 if (!(tmp & EEPROM_ADDR_COMPLETE))
9534 return -EBUSY; 9544 return -EBUSY;
@@ -9653,12 +9663,12 @@ static int tg3_nvram_write_block_using_eeprom(struct tg3 *tp,
9653 EEPROM_ADDR_START | 9663 EEPROM_ADDR_START |
9654 EEPROM_ADDR_WRITE); 9664 EEPROM_ADDR_WRITE);
9655 9665
9656 for (j = 0; j < 10000; j++) { 9666 for (j = 0; j < 1000; j++) {
9657 val = tr32(GRC_EEPROM_ADDR); 9667 val = tr32(GRC_EEPROM_ADDR);
9658 9668
9659 if (val & EEPROM_ADDR_COMPLETE) 9669 if (val & EEPROM_ADDR_COMPLETE)
9660 break; 9670 break;
9661 udelay(100); 9671 msleep(1);
9662 } 9672 }
9663 if (!(val & EEPROM_ADDR_COMPLETE)) { 9673 if (!(val & EEPROM_ADDR_COMPLETE)) {
9664 rc = -EBUSY; 9674 rc = -EBUSY;
@@ -9962,8 +9972,10 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp)
9962 tp->tg3_flags |= TG3_FLAG_EEPROM_WRITE_PROT; 9972 tp->tg3_flags |= TG3_FLAG_EEPROM_WRITE_PROT;
9963 9973
9964 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) { 9974 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) {
9965 if (!(tr32(PCIE_TRANSACTION_CFG) & PCIE_TRANS_CFG_LOM)) 9975 if (!(tr32(PCIE_TRANSACTION_CFG) & PCIE_TRANS_CFG_LOM)) {
9966 tp->tg3_flags &= ~TG3_FLAG_EEPROM_WRITE_PROT; 9976 tp->tg3_flags &= ~TG3_FLAG_EEPROM_WRITE_PROT;
9977 tp->tg3_flags2 |= TG3_FLG2_IS_NIC;
9978 }
9967 return; 9979 return;
9968 } 9980 }
9969 9981
@@ -10063,10 +10075,17 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp)
10063 tp->pdev->subsystem_vendor == PCI_VENDOR_ID_DELL) 10075 tp->pdev->subsystem_vendor == PCI_VENDOR_ID_DELL)
10064 tp->led_ctrl = LED_CTRL_MODE_PHY_2; 10076 tp->led_ctrl = LED_CTRL_MODE_PHY_2;
10065 10077
10066 if (nic_cfg & NIC_SRAM_DATA_CFG_EEPROM_WP) 10078 if (nic_cfg & NIC_SRAM_DATA_CFG_EEPROM_WP) {
10067 tp->tg3_flags |= TG3_FLAG_EEPROM_WRITE_PROT; 10079 tp->tg3_flags |= TG3_FLAG_EEPROM_WRITE_PROT;
10068 else 10080 if ((tp->pdev->subsystem_vendor ==
10081 PCI_VENDOR_ID_ARIMA) &&
10082 (tp->pdev->subsystem_device == 0x205a ||
10083 tp->pdev->subsystem_device == 0x2063))
10084 tp->tg3_flags &= ~TG3_FLAG_EEPROM_WRITE_PROT;
10085 } else {
10069 tp->tg3_flags &= ~TG3_FLAG_EEPROM_WRITE_PROT; 10086 tp->tg3_flags &= ~TG3_FLAG_EEPROM_WRITE_PROT;
10087 tp->tg3_flags2 |= TG3_FLG2_IS_NIC;
10088 }
10070 10089
10071 if (nic_cfg & NIC_SRAM_DATA_CFG_ASF_ENABLE) { 10090 if (nic_cfg & NIC_SRAM_DATA_CFG_ASF_ENABLE) {
10072 tp->tg3_flags |= TG3_FLAG_ENABLE_ASF; 10091 tp->tg3_flags |= TG3_FLAG_ENABLE_ASF;
@@ -10144,7 +10163,7 @@ static int __devinit tg3_phy_probe(struct tg3 *tp)
10144 10163
10145 if (!(tp->tg3_flags2 & TG3_FLG2_ANY_SERDES) && 10164 if (!(tp->tg3_flags2 & TG3_FLG2_ANY_SERDES) &&
10146 !(tp->tg3_flags & TG3_FLAG_ENABLE_ASF)) { 10165 !(tp->tg3_flags & TG3_FLAG_ENABLE_ASF)) {
10147 u32 bmsr, adv_reg, tg3_ctrl; 10166 u32 bmsr, adv_reg, tg3_ctrl, mask;
10148 10167
10149 tg3_readphy(tp, MII_BMSR, &bmsr); 10168 tg3_readphy(tp, MII_BMSR, &bmsr);
10150 if (!tg3_readphy(tp, MII_BMSR, &bmsr) && 10169 if (!tg3_readphy(tp, MII_BMSR, &bmsr) &&
@@ -10168,7 +10187,10 @@ static int __devinit tg3_phy_probe(struct tg3 *tp)
10168 MII_TG3_CTRL_ENABLE_AS_MASTER); 10187 MII_TG3_CTRL_ENABLE_AS_MASTER);
10169 } 10188 }
10170 10189
10171 if (!tg3_copper_is_advertising_all(tp)) { 10190 mask = (ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full |
10191 ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full |
10192 ADVERTISED_1000baseT_Half | ADVERTISED_1000baseT_Full);
10193 if (!tg3_copper_is_advertising_all(tp, mask)) {
10172 tg3_writephy(tp, MII_ADVERTISE, adv_reg); 10194 tg3_writephy(tp, MII_ADVERTISE, adv_reg);
10173 10195
10174 if (!(tp->tg3_flags & TG3_FLAG_10_100_ONLY)) 10196 if (!(tp->tg3_flags & TG3_FLAG_10_100_ONLY))
@@ -10212,7 +10234,7 @@ skip_phy_reset:
10212static void __devinit tg3_read_partno(struct tg3 *tp) 10234static void __devinit tg3_read_partno(struct tg3 *tp)
10213{ 10235{
10214 unsigned char vpd_data[256]; 10236 unsigned char vpd_data[256];
10215 int i; 10237 unsigned int i;
10216 u32 magic; 10238 u32 magic;
10217 10239
10218 if (tg3_nvram_read_swab(tp, 0x0, &magic)) 10240 if (tg3_nvram_read_swab(tp, 0x0, &magic))
@@ -10258,9 +10280,9 @@ static void __devinit tg3_read_partno(struct tg3 *tp)
10258 } 10280 }
10259 10281
10260 /* Now parse and find the part number. */ 10282 /* Now parse and find the part number. */
10261 for (i = 0; i < 256; ) { 10283 for (i = 0; i < 254; ) {
10262 unsigned char val = vpd_data[i]; 10284 unsigned char val = vpd_data[i];
10263 int block_end; 10285 unsigned int block_end;
10264 10286
10265 if (val == 0x82 || val == 0x91) { 10287 if (val == 0x82 || val == 0x91) {
10266 i = (i + 3 + 10288 i = (i + 3 +
@@ -10276,21 +10298,26 @@ static void __devinit tg3_read_partno(struct tg3 *tp)
10276 (vpd_data[i + 1] + 10298 (vpd_data[i + 1] +
10277 (vpd_data[i + 2] << 8))); 10299 (vpd_data[i + 2] << 8)));
10278 i += 3; 10300 i += 3;
10279 while (i < block_end) { 10301
10302 if (block_end > 256)
10303 goto out_not_found;
10304
10305 while (i < (block_end - 2)) {
10280 if (vpd_data[i + 0] == 'P' && 10306 if (vpd_data[i + 0] == 'P' &&
10281 vpd_data[i + 1] == 'N') { 10307 vpd_data[i + 1] == 'N') {
10282 int partno_len = vpd_data[i + 2]; 10308 int partno_len = vpd_data[i + 2];
10283 10309
10284 if (partno_len > 24) 10310 i += 3;
10311 if (partno_len > 24 || (partno_len + i) > 256)
10285 goto out_not_found; 10312 goto out_not_found;
10286 10313
10287 memcpy(tp->board_part_number, 10314 memcpy(tp->board_part_number,
10288 &vpd_data[i + 3], 10315 &vpd_data[i], partno_len);
10289 partno_len);
10290 10316
10291 /* Success. */ 10317 /* Success. */
10292 return; 10318 return;
10293 } 10319 }
10320 i += 3 + vpd_data[i + 2];
10294 } 10321 }
10295 10322
10296 /* Part number not found. */ 10323 /* Part number not found. */
@@ -10360,7 +10387,7 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
10360 u32 pci_state_reg, grc_misc_cfg; 10387 u32 pci_state_reg, grc_misc_cfg;
10361 u32 val; 10388 u32 val;
10362 u16 pci_cmd; 10389 u16 pci_cmd;
10363 int err; 10390 int err, pcie_cap;
10364 10391
10365 /* Force memory write invalidate off. If we leave it on, 10392 /* Force memory write invalidate off. If we leave it on,
10366 * then on 5700_BX chips we have to enable a workaround. 10393 * then on 5700_BX chips we have to enable a workaround.
@@ -10535,8 +10562,19 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
10535 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5906) 10562 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5906)
10536 tp->tg3_flags2 |= TG3_FLG2_JUMBO_CAPABLE; 10563 tp->tg3_flags2 |= TG3_FLG2_JUMBO_CAPABLE;
10537 10564
10538 if (pci_find_capability(tp->pdev, PCI_CAP_ID_EXP) != 0) 10565 pcie_cap = pci_find_capability(tp->pdev, PCI_CAP_ID_EXP);
10566 if (pcie_cap != 0) {
10539 tp->tg3_flags2 |= TG3_FLG2_PCI_EXPRESS; 10567 tp->tg3_flags2 |= TG3_FLG2_PCI_EXPRESS;
10568 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) {
10569 u16 lnkctl;
10570
10571 pci_read_config_word(tp->pdev,
10572 pcie_cap + PCI_EXP_LNKCTL,
10573 &lnkctl);
10574 if (lnkctl & PCI_EXP_LNKCTL_CLKREQ_EN)
10575 tp->tg3_flags2 &= ~TG3_FLG2_HW_TSO_2;
10576 }
10577 }
10540 10578
10541 /* If we have an AMD 762 or VIA K8T800 chipset, write 10579 /* If we have an AMD 762 or VIA K8T800 chipset, write
10542 * reordering to the mailbox registers done by the host 10580 * reordering to the mailbox registers done by the host
@@ -10676,7 +10714,7 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
10676 tp->tg3_flags |= TG3_FLAG_SRAM_USE_CONFIG; 10714 tp->tg3_flags |= TG3_FLAG_SRAM_USE_CONFIG;
10677 10715
10678 /* Get eeprom hw config before calling tg3_set_power_state(). 10716 /* Get eeprom hw config before calling tg3_set_power_state().
10679 * In particular, the TG3_FLAG_EEPROM_WRITE_PROT flag must be 10717 * In particular, the TG3_FLG2_IS_NIC flag must be
10680 * determined before calling tg3_set_power_state() so that 10718 * determined before calling tg3_set_power_state() so that
10681 * we know whether or not to switch out of Vaux power. 10719 * we know whether or not to switch out of Vaux power.
10682 * When the flag is set, it means that GPIO1 is used for eeprom 10720 * When the flag is set, it means that GPIO1 is used for eeprom
@@ -10843,7 +10881,8 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
10843 tp->pdev->device == PCI_DEVICE_ID_TIGON3_5705F)) || 10881 tp->pdev->device == PCI_DEVICE_ID_TIGON3_5705F)) ||
10844 (tp->pdev->vendor == PCI_VENDOR_ID_BROADCOM && 10882 (tp->pdev->vendor == PCI_VENDOR_ID_BROADCOM &&
10845 (tp->pdev->device == PCI_DEVICE_ID_TIGON3_5751F || 10883 (tp->pdev->device == PCI_DEVICE_ID_TIGON3_5751F ||
10846 tp->pdev->device == PCI_DEVICE_ID_TIGON3_5753F)) || 10884 tp->pdev->device == PCI_DEVICE_ID_TIGON3_5753F ||
10885 tp->pdev->device == PCI_DEVICE_ID_TIGON3_5787F)) ||
10847 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) 10886 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906)
10848 tp->tg3_flags |= TG3_FLAG_10_100_ONLY; 10887 tp->tg3_flags |= TG3_FLAG_10_100_ONLY;
10849 10888
@@ -11715,7 +11754,7 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
11715#endif 11754#endif
11716 spin_lock_init(&tp->lock); 11755 spin_lock_init(&tp->lock);
11717 spin_lock_init(&tp->indirect_lock); 11756 spin_lock_init(&tp->indirect_lock);
11718 INIT_WORK(&tp->reset_task, tg3_reset_task, tp); 11757 INIT_WORK(&tp->reset_task, tg3_reset_task);
11719 11758
11720 tp->regs = ioremap_nocache(tg3reg_base, tg3reg_len); 11759 tp->regs = ioremap_nocache(tg3reg_base, tg3reg_len);
11721 if (tp->regs == 0UL) { 11760 if (tp->regs == 0UL) {
@@ -11803,6 +11842,7 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
11803 else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 || 11842 else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 ||
11804 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701 || 11843 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701 ||
11805 tp->pci_chip_rev_id == CHIPREV_ID_5705_A0 || 11844 tp->pci_chip_rev_id == CHIPREV_ID_5705_A0 ||
11845 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906 ||
11806 (tp->tg3_flags & TG3_FLAG_ENABLE_ASF) != 0) { 11846 (tp->tg3_flags & TG3_FLAG_ENABLE_ASF) != 0) {
11807 tp->tg3_flags2 &= ~TG3_FLG2_TSO_CAPABLE; 11847 tp->tg3_flags2 &= ~TG3_FLG2_TSO_CAPABLE;
11808 } else { 11848 } else {
@@ -11892,13 +11932,15 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
11892 11932
11893 pci_set_drvdata(pdev, dev); 11933 pci_set_drvdata(pdev, dev);
11894 11934
11895 printk(KERN_INFO "%s: Tigon3 [partno(%s) rev %04x PHY(%s)] (%s) %sBaseT Ethernet ", 11935 printk(KERN_INFO "%s: Tigon3 [partno(%s) rev %04x PHY(%s)] (%s) %s Ethernet ",
11896 dev->name, 11936 dev->name,
11897 tp->board_part_number, 11937 tp->board_part_number,
11898 tp->pci_chip_rev_id, 11938 tp->pci_chip_rev_id,
11899 tg3_phy_string(tp), 11939 tg3_phy_string(tp),
11900 tg3_bus_string(tp, str), 11940 tg3_bus_string(tp, str),
11901 (tp->tg3_flags & TG3_FLAG_10_100_ONLY) ? "10/100" : "10/100/1000"); 11941 ((tp->tg3_flags & TG3_FLAG_10_100_ONLY) ? "10/100Base-TX" :
11942 ((tp->tg3_flags2 & TG3_FLG2_ANY_SERDES) ? "1000Base-SX" :
11943 "10/100/1000Base-T")));
11902 11944
11903 for (i = 0; i < 6; i++) 11945 for (i = 0; i < 6; i++)
11904 printk("%2.2x%c", dev->dev_addr[i], 11946 printk("%2.2x%c", dev->dev_addr[i],
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h
index 92f53000bce6..dfaf4ed127bd 100644
--- a/drivers/net/tg3.h
+++ b/drivers/net/tg3.h
@@ -2233,6 +2233,7 @@ struct tg3 {
2233#define TG3_FLG2_PCI_EXPRESS 0x00000200 2233#define TG3_FLG2_PCI_EXPRESS 0x00000200
2234#define TG3_FLG2_ASF_NEW_HANDSHAKE 0x00000400 2234#define TG3_FLG2_ASF_NEW_HANDSHAKE 0x00000400
2235#define TG3_FLG2_HW_AUTONEG 0x00000800 2235#define TG3_FLG2_HW_AUTONEG 0x00000800
2236#define TG3_FLG2_IS_NIC 0x00001000
2236#define TG3_FLG2_PHY_SERDES 0x00002000 2237#define TG3_FLG2_PHY_SERDES 0x00002000
2237#define TG3_FLG2_CAPACITIVE_COUPLING 0x00004000 2238#define TG3_FLG2_CAPACITIVE_COUPLING 0x00004000
2238#define TG3_FLG2_FLASH 0x00008000 2239#define TG3_FLG2_FLASH 0x00008000
diff --git a/drivers/net/tlan.c b/drivers/net/tlan.c
index e14f5a00f65a..f85f00251123 100644
--- a/drivers/net/tlan.c
+++ b/drivers/net/tlan.c
@@ -296,6 +296,7 @@ static void TLan_SetMulticastList( struct net_device *);
296static int TLan_ioctl( struct net_device *dev, struct ifreq *rq, int cmd); 296static int TLan_ioctl( struct net_device *dev, struct ifreq *rq, int cmd);
297static int TLan_probe1( struct pci_dev *pdev, long ioaddr, int irq, int rev, const struct pci_device_id *ent); 297static int TLan_probe1( struct pci_dev *pdev, long ioaddr, int irq, int rev, const struct pci_device_id *ent);
298static void TLan_tx_timeout( struct net_device *dev); 298static void TLan_tx_timeout( struct net_device *dev);
299static void TLan_tx_timeout_work(struct work_struct *work);
299static int tlan_init_one( struct pci_dev *pdev, const struct pci_device_id *ent); 300static int tlan_init_one( struct pci_dev *pdev, const struct pci_device_id *ent);
300 301
301static u32 TLan_HandleInvalid( struct net_device *, u16 ); 302static u32 TLan_HandleInvalid( struct net_device *, u16 );
@@ -562,6 +563,7 @@ static int __devinit TLan_probe1(struct pci_dev *pdev,
562 priv = netdev_priv(dev); 563 priv = netdev_priv(dev);
563 564
564 priv->pciDev = pdev; 565 priv->pciDev = pdev;
566 priv->dev = dev;
565 567
566 /* Is this a PCI device? */ 568 /* Is this a PCI device? */
567 if (pdev) { 569 if (pdev) {
@@ -634,7 +636,7 @@ static int __devinit TLan_probe1(struct pci_dev *pdev,
634 636
635 /* This will be used when we get an adapter error from 637 /* This will be used when we get an adapter error from
636 * within our irq handler */ 638 * within our irq handler */
637 INIT_WORK(&priv->tlan_tqueue, (void *)(void*)TLan_tx_timeout, dev); 639 INIT_WORK(&priv->tlan_tqueue, TLan_tx_timeout_work);
638 640
639 spin_lock_init(&priv->lock); 641 spin_lock_init(&priv->lock);
640 642
@@ -1040,6 +1042,25 @@ static void TLan_tx_timeout(struct net_device *dev)
1040} 1042}
1041 1043
1042 1044
1045 /***************************************************************
1046 * TLan_tx_timeout_work
1047 *
1048 * Returns: nothing
1049 *
1050 * Params:
1051 * work work item of device which timed out
1052 *
1053 **************************************************************/
1054
1055static void TLan_tx_timeout_work(struct work_struct *work)
1056{
1057 TLanPrivateInfo *priv =
1058 container_of(work, TLanPrivateInfo, tlan_tqueue);
1059
1060 TLan_tx_timeout(priv->dev);
1061}
1062
1063
1043 1064
1044 /*************************************************************** 1065 /***************************************************************
1045 * TLan_StartTx 1066 * TLan_StartTx
diff --git a/drivers/net/tlan.h b/drivers/net/tlan.h
index a44e2f2ef62a..41ce0b665937 100644
--- a/drivers/net/tlan.h
+++ b/drivers/net/tlan.h
@@ -170,6 +170,7 @@ typedef u8 TLanBuffer[TLAN_MAX_FRAME_SIZE];
170typedef struct tlan_private_tag { 170typedef struct tlan_private_tag {
171 struct net_device *nextDevice; 171 struct net_device *nextDevice;
172 struct pci_dev *pciDev; 172 struct pci_dev *pciDev;
173 struct net_device *dev;
173 void *dmaStorage; 174 void *dmaStorage;
174 dma_addr_t dmaStorageDMA; 175 dma_addr_t dmaStorageDMA;
175 unsigned int dmaSize; 176 unsigned int dmaSize;
diff --git a/drivers/net/tokenring/ibmtr.c b/drivers/net/tokenring/ibmtr.c
index bfe59865b1dd..0d97e10ccac5 100644
--- a/drivers/net/tokenring/ibmtr.c
+++ b/drivers/net/tokenring/ibmtr.c
@@ -1826,7 +1826,7 @@ static void tr_rx(struct net_device *dev)
1826 skb->protocol = tr_type_trans(skb, dev); 1826 skb->protocol = tr_type_trans(skb, dev);
1827 if (IPv4_p) { 1827 if (IPv4_p) {
1828 skb->csum = chksum; 1828 skb->csum = chksum;
1829 skb->ip_summed = 1; 1829 skb->ip_summed = CHECKSUM_COMPLETE;
1830 } 1830 }
1831 netif_rx(skb); 1831 netif_rx(skb);
1832 dev->last_rx = jiffies; 1832 dev->last_rx = jiffies;
diff --git a/drivers/net/tokenring/olympic.c b/drivers/net/tokenring/olympic.c
index cd142d0302bc..8f4ecc1109cb 100644
--- a/drivers/net/tokenring/olympic.c
+++ b/drivers/net/tokenring/olympic.c
@@ -1771,7 +1771,7 @@ static struct pci_driver olympic_driver = {
1771 1771
1772static int __init olympic_pci_init(void) 1772static int __init olympic_pci_init(void)
1773{ 1773{
1774 return pci_module_init (&olympic_driver) ; 1774 return pci_register_driver(&olympic_driver) ;
1775} 1775}
1776 1776
1777static void __exit olympic_pci_cleanup(void) 1777static void __exit olympic_pci_cleanup(void)
diff --git a/drivers/net/tokenring/smctr.c b/drivers/net/tokenring/smctr.c
index 46dabdb12071..cec282a6f62d 100644
--- a/drivers/net/tokenring/smctr.c
+++ b/drivers/net/tokenring/smctr.c
@@ -5706,7 +5706,7 @@ int __init init_module(void)
5706 return found ? 0 : -ENODEV; 5706 return found ? 0 : -ENODEV;
5707} 5707}
5708 5708
5709void cleanup_module(void) 5709void __exit cleanup_module(void)
5710{ 5710{
5711 int i; 5711 int i;
5712 5712
diff --git a/drivers/net/tsi108_eth.c b/drivers/net/tsi108_eth.c
new file mode 100644
index 000000000000..893808ab3742
--- /dev/null
+++ b/drivers/net/tsi108_eth.c
@@ -0,0 +1,1708 @@
1/*******************************************************************************
2
3 Copyright(c) 2006 Tundra Semiconductor Corporation.
4
5 This program is free software; you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published by the Free
7 Software Foundation; either version 2 of the License, or (at your option)
8 any later version.
9
10 This program is distributed in the hope that it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 more details.
14
15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc., 59
17 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19*******************************************************************************/
20
21/* This driver is based on the driver code originally developed
22 * for the Intel IOC80314 (ForestLake) Gigabit Ethernet by
23 * scott.wood@timesys.com * Copyright (C) 2003 TimeSys Corporation
24 *
25 * Currently changes from original version are:
26 * - porting to Tsi108-based platform and kernel 2.6 (kong.lai@tundra.com)
27 * - modifications to handle two ports independently and support for
28 * additional PHY devices (alexandre.bounine@tundra.com)
29 * - Get hardware information from platform device. (tie-fei.zang@freescale.com)
30 *
31 */
32
33#include <linux/module.h>
34#include <linux/types.h>
35#include <linux/init.h>
36#include <linux/net.h>
37#include <linux/netdevice.h>
38#include <linux/etherdevice.h>
39#include <linux/skbuff.h>
40#include <linux/slab.h>
41#include <linux/sched.h>
42#include <linux/spinlock.h>
43#include <linux/delay.h>
44#include <linux/crc32.h>
45#include <linux/mii.h>
46#include <linux/device.h>
47#include <linux/pci.h>
48#include <linux/rtnetlink.h>
49#include <linux/timer.h>
50#include <linux/platform_device.h>
51#include <linux/etherdevice.h>
52
53#include <asm/system.h>
54#include <asm/io.h>
55#include <asm/tsi108.h>
56
57#include "tsi108_eth.h"
58
59#define MII_READ_DELAY 10000 /* max link wait time in msec */
60
61#define TSI108_RXRING_LEN 256
62
63/* NOTE: The driver currently does not support receiving packets
64 * larger than the buffer size, so don't decrease this (unless you
65 * want to add such support).
66 */
67#define TSI108_RXBUF_SIZE 1536
68
69#define TSI108_TXRING_LEN 256
70
71#define TSI108_TX_INT_FREQ 64
72
73/* Check the phy status every half a second. */
74#define CHECK_PHY_INTERVAL (HZ/2)
75
76static int tsi108_init_one(struct platform_device *pdev);
77static int tsi108_ether_remove(struct platform_device *pdev);
78
79struct tsi108_prv_data {
80 void __iomem *regs; /* Base of normal regs */
81 void __iomem *phyregs; /* Base of register bank used for PHY access */
82
83 unsigned int phy; /* Index of PHY for this interface */
84 unsigned int irq_num;
85 unsigned int id;
86
87 struct timer_list timer;/* Timer that triggers the check phy function */
88 unsigned int rxtail; /* Next entry in rxring to read */
89 unsigned int rxhead; /* Next entry in rxring to give a new buffer */
90 unsigned int rxfree; /* Number of free, allocated RX buffers */
91
92 unsigned int rxpending; /* Non-zero if there are still descriptors
93 * to be processed from a previous descriptor
94 * interrupt condition that has been cleared */
95
96 unsigned int txtail; /* Next TX descriptor to check status on */
97 unsigned int txhead; /* Next TX descriptor to use */
98
99 /* Number of free TX descriptors. This could be calculated from
100 * rxhead and rxtail if one descriptor were left unused to disambiguate
101 * full and empty conditions, but it's simpler to just keep track
102 * explicitly. */
103
104 unsigned int txfree;
105
106 unsigned int phy_ok; /* The PHY is currently powered on. */
107
108 /* PHY status (duplex is 1 for half, 2 for full,
109 * so that the default 0 indicates that neither has
110 * yet been configured). */
111
112 unsigned int link_up;
113 unsigned int speed;
114 unsigned int duplex;
115
116 tx_desc *txring;
117 rx_desc *rxring;
118 struct sk_buff *txskbs[TSI108_TXRING_LEN];
119 struct sk_buff *rxskbs[TSI108_RXRING_LEN];
120
121 dma_addr_t txdma, rxdma;
122
123 /* txlock nests in misclock and phy_lock */
124
125 spinlock_t txlock, misclock;
126
127 /* stats is used to hold the upper bits of each hardware counter,
128 * and tmpstats is used to hold the full values for returning
129 * to the caller of get_stats(). They must be separate in case
130 * an overflow interrupt occurs before the stats are consumed.
131 */
132
133 struct net_device_stats stats;
134 struct net_device_stats tmpstats;
135
136 /* These stats are kept separate in hardware, thus require individual
137 * fields for handling carry. They are combined in get_stats.
138 */
139
140 unsigned long rx_fcs; /* Add to rx_frame_errors */
141 unsigned long rx_short_fcs; /* Add to rx_frame_errors */
142 unsigned long rx_long_fcs; /* Add to rx_frame_errors */
143 unsigned long rx_underruns; /* Add to rx_length_errors */
144 unsigned long rx_overruns; /* Add to rx_length_errors */
145
146 unsigned long tx_coll_abort; /* Add to tx_aborted_errors/collisions */
147 unsigned long tx_pause_drop; /* Add to tx_aborted_errors */
148
149 unsigned long mc_hash[16];
150 u32 msg_enable; /* debug message level */
151 struct mii_if_info mii_if;
152 unsigned int init_media;
153};
154
155/* Structure for a device driver */
156
157static struct platform_driver tsi_eth_driver = {
158 .probe = tsi108_init_one,
159 .remove = tsi108_ether_remove,
160 .driver = {
161 .name = "tsi-ethernet",
162 },
163};
164
165static void tsi108_timed_checker(unsigned long dev_ptr);
166
167static void dump_eth_one(struct net_device *dev)
168{
169 struct tsi108_prv_data *data = netdev_priv(dev);
170
171 printk("Dumping %s...\n", dev->name);
172 printk("intstat %x intmask %x phy_ok %d"
173 " link %d speed %d duplex %d\n",
174 TSI_READ(TSI108_EC_INTSTAT),
175 TSI_READ(TSI108_EC_INTMASK), data->phy_ok,
176 data->link_up, data->speed, data->duplex);
177
178 printk("TX: head %d, tail %d, free %d, stat %x, estat %x, err %x\n",
179 data->txhead, data->txtail, data->txfree,
180 TSI_READ(TSI108_EC_TXSTAT),
181 TSI_READ(TSI108_EC_TXESTAT),
182 TSI_READ(TSI108_EC_TXERR));
183
184 printk("RX: head %d, tail %d, free %d, stat %x,"
185 " estat %x, err %x, pending %d\n\n",
186 data->rxhead, data->rxtail, data->rxfree,
187 TSI_READ(TSI108_EC_RXSTAT),
188 TSI_READ(TSI108_EC_RXESTAT),
189 TSI_READ(TSI108_EC_RXERR), data->rxpending);
190}
191
192/* Synchronization is needed between the thread and up/down events.
193 * Note that the PHY is accessed through the same registers for both
194 * interfaces, so this can't be made interface-specific.
195 */
196
197static DEFINE_SPINLOCK(phy_lock);
198
199static int tsi108_read_mii(struct tsi108_prv_data *data, int reg)
200{
201 unsigned i;
202
203 TSI_WRITE_PHY(TSI108_MAC_MII_ADDR,
204 (data->phy << TSI108_MAC_MII_ADDR_PHY) |
205 (reg << TSI108_MAC_MII_ADDR_REG));
206 TSI_WRITE_PHY(TSI108_MAC_MII_CMD, 0);
207 TSI_WRITE_PHY(TSI108_MAC_MII_CMD, TSI108_MAC_MII_CMD_READ);
208 for (i = 0; i < 100; i++) {
209 if (!(TSI_READ_PHY(TSI108_MAC_MII_IND) &
210 (TSI108_MAC_MII_IND_NOTVALID | TSI108_MAC_MII_IND_BUSY)))
211 break;
212 udelay(10);
213 }
214
215 if (i == 100)
216 return 0xffff;
217 else
218 return (TSI_READ_PHY(TSI108_MAC_MII_DATAIN));
219}
220
221static void tsi108_write_mii(struct tsi108_prv_data *data,
222 int reg, u16 val)
223{
224 unsigned i = 100;
225 TSI_WRITE_PHY(TSI108_MAC_MII_ADDR,
226 (data->phy << TSI108_MAC_MII_ADDR_PHY) |
227 (reg << TSI108_MAC_MII_ADDR_REG));
228 TSI_WRITE_PHY(TSI108_MAC_MII_DATAOUT, val);
229 while (i--) {
230 if(!(TSI_READ_PHY(TSI108_MAC_MII_IND) &
231 TSI108_MAC_MII_IND_BUSY))
232 break;
233 udelay(10);
234 }
235}
236
237static int tsi108_mdio_read(struct net_device *dev, int addr, int reg)
238{
239 struct tsi108_prv_data *data = netdev_priv(dev);
240 return tsi108_read_mii(data, reg);
241}
242
243static void tsi108_mdio_write(struct net_device *dev, int addr, int reg, int val)
244{
245 struct tsi108_prv_data *data = netdev_priv(dev);
246 tsi108_write_mii(data, reg, val);
247}
248
249static inline void tsi108_write_tbi(struct tsi108_prv_data *data,
250 int reg, u16 val)
251{
252 unsigned i = 1000;
253 TSI_WRITE(TSI108_MAC_MII_ADDR,
254 (0x1e << TSI108_MAC_MII_ADDR_PHY)
255 | (reg << TSI108_MAC_MII_ADDR_REG));
256 TSI_WRITE(TSI108_MAC_MII_DATAOUT, val);
257 while(i--) {
258 if(!(TSI_READ(TSI108_MAC_MII_IND) & TSI108_MAC_MII_IND_BUSY))
259 return;
260 udelay(10);
261 }
262 printk(KERN_ERR "%s function time out \n", __FUNCTION__);
263}
264
265static int mii_speed(struct mii_if_info *mii)
266{
267 int advert, lpa, val, media;
268 int lpa2 = 0;
269 int speed;
270
271 if (!mii_link_ok(mii))
272 return 0;
273
274 val = (*mii->mdio_read) (mii->dev, mii->phy_id, MII_BMSR);
275 if ((val & BMSR_ANEGCOMPLETE) == 0)
276 return 0;
277
278 advert = (*mii->mdio_read) (mii->dev, mii->phy_id, MII_ADVERTISE);
279 lpa = (*mii->mdio_read) (mii->dev, mii->phy_id, MII_LPA);
280 media = mii_nway_result(advert & lpa);
281
282 if (mii->supports_gmii)
283 lpa2 = mii->mdio_read(mii->dev, mii->phy_id, MII_STAT1000);
284
285 speed = lpa2 & (LPA_1000FULL | LPA_1000HALF) ? 1000 :
286 (media & (ADVERTISE_100FULL | ADVERTISE_100HALF) ? 100 : 10);
287 return speed;
288}
289
290static void tsi108_check_phy(struct net_device *dev)
291{
292 struct tsi108_prv_data *data = netdev_priv(dev);
293 u32 mac_cfg2_reg, portctrl_reg;
294 u32 duplex;
295 u32 speed;
296 unsigned long flags;
297
298 /* Do a dummy read, as for some reason the first read
299 * after a link becomes up returns link down, even if
300 * it's been a while since the link came up.
301 */
302
303 spin_lock_irqsave(&phy_lock, flags);
304
305 if (!data->phy_ok)
306 goto out;
307
308 tsi108_read_mii(data, MII_BMSR);
309
310 duplex = mii_check_media(&data->mii_if, netif_msg_link(data), data->init_media);
311 data->init_media = 0;
312
313 if (netif_carrier_ok(dev)) {
314
315 speed = mii_speed(&data->mii_if);
316
317 if ((speed != data->speed) || duplex) {
318
319 mac_cfg2_reg = TSI_READ(TSI108_MAC_CFG2);
320 portctrl_reg = TSI_READ(TSI108_EC_PORTCTRL);
321
322 mac_cfg2_reg &= ~TSI108_MAC_CFG2_IFACE_MASK;
323
324 if (speed == 1000) {
325 mac_cfg2_reg |= TSI108_MAC_CFG2_GIG;
326 portctrl_reg &= ~TSI108_EC_PORTCTRL_NOGIG;
327 } else {
328 mac_cfg2_reg |= TSI108_MAC_CFG2_NOGIG;
329 portctrl_reg |= TSI108_EC_PORTCTRL_NOGIG;
330 }
331
332 data->speed = speed;
333
334 if (data->mii_if.full_duplex) {
335 mac_cfg2_reg |= TSI108_MAC_CFG2_FULLDUPLEX;
336 portctrl_reg &= ~TSI108_EC_PORTCTRL_HALFDUPLEX;
337 data->duplex = 2;
338 } else {
339 mac_cfg2_reg &= ~TSI108_MAC_CFG2_FULLDUPLEX;
340 portctrl_reg |= TSI108_EC_PORTCTRL_HALFDUPLEX;
341 data->duplex = 1;
342 }
343
344 TSI_WRITE(TSI108_MAC_CFG2, mac_cfg2_reg);
345 TSI_WRITE(TSI108_EC_PORTCTRL, portctrl_reg);
346
347 if (data->link_up == 0) {
348 /* The manual says it can take 3-4 usecs for the speed change
349 * to take effect.
350 */
351 udelay(5);
352
353 spin_lock(&data->txlock);
354 if (is_valid_ether_addr(dev->dev_addr) && data->txfree)
355 netif_wake_queue(dev);
356
357 data->link_up = 1;
358 spin_unlock(&data->txlock);
359 }
360 }
361
362 } else {
363 if (data->link_up == 1) {
364 netif_stop_queue(dev);
365 data->link_up = 0;
366 printk(KERN_NOTICE "%s : link is down\n", dev->name);
367 }
368
369 goto out;
370 }
371
372
373out:
374 spin_unlock_irqrestore(&phy_lock, flags);
375}
376
377static inline void
378tsi108_stat_carry_one(int carry, int carry_bit, int carry_shift,
379 unsigned long *upper)
380{
381 if (carry & carry_bit)
382 *upper += carry_shift;
383}
384
385static void tsi108_stat_carry(struct net_device *dev)
386{
387 struct tsi108_prv_data *data = netdev_priv(dev);
388 u32 carry1, carry2;
389
390 spin_lock_irq(&data->misclock);
391
392 carry1 = TSI_READ(TSI108_STAT_CARRY1);
393 carry2 = TSI_READ(TSI108_STAT_CARRY2);
394
395 TSI_WRITE(TSI108_STAT_CARRY1, carry1);
396 TSI_WRITE(TSI108_STAT_CARRY2, carry2);
397
398 tsi108_stat_carry_one(carry1, TSI108_STAT_CARRY1_RXBYTES,
399 TSI108_STAT_RXBYTES_CARRY, &data->stats.rx_bytes);
400
401 tsi108_stat_carry_one(carry1, TSI108_STAT_CARRY1_RXPKTS,
402 TSI108_STAT_RXPKTS_CARRY,
403 &data->stats.rx_packets);
404
405 tsi108_stat_carry_one(carry1, TSI108_STAT_CARRY1_RXFCS,
406 TSI108_STAT_RXFCS_CARRY, &data->rx_fcs);
407
408 tsi108_stat_carry_one(carry1, TSI108_STAT_CARRY1_RXMCAST,
409 TSI108_STAT_RXMCAST_CARRY,
410 &data->stats.multicast);
411
412 tsi108_stat_carry_one(carry1, TSI108_STAT_CARRY1_RXALIGN,
413 TSI108_STAT_RXALIGN_CARRY,
414 &data->stats.rx_frame_errors);
415
416 tsi108_stat_carry_one(carry1, TSI108_STAT_CARRY1_RXLENGTH,
417 TSI108_STAT_RXLENGTH_CARRY,
418 &data->stats.rx_length_errors);
419
420 tsi108_stat_carry_one(carry1, TSI108_STAT_CARRY1_RXRUNT,
421 TSI108_STAT_RXRUNT_CARRY, &data->rx_underruns);
422
423 tsi108_stat_carry_one(carry1, TSI108_STAT_CARRY1_RXJUMBO,
424 TSI108_STAT_RXJUMBO_CARRY, &data->rx_overruns);
425
426 tsi108_stat_carry_one(carry1, TSI108_STAT_CARRY1_RXFRAG,
427 TSI108_STAT_RXFRAG_CARRY, &data->rx_short_fcs);
428
429 tsi108_stat_carry_one(carry1, TSI108_STAT_CARRY1_RXJABBER,
430 TSI108_STAT_RXJABBER_CARRY, &data->rx_long_fcs);
431
432 tsi108_stat_carry_one(carry1, TSI108_STAT_CARRY1_RXDROP,
433 TSI108_STAT_RXDROP_CARRY,
434 &data->stats.rx_missed_errors);
435
436 tsi108_stat_carry_one(carry2, TSI108_STAT_CARRY2_TXBYTES,
437 TSI108_STAT_TXBYTES_CARRY, &data->stats.tx_bytes);
438
439 tsi108_stat_carry_one(carry2, TSI108_STAT_CARRY2_TXPKTS,
440 TSI108_STAT_TXPKTS_CARRY,
441 &data->stats.tx_packets);
442
443 tsi108_stat_carry_one(carry2, TSI108_STAT_CARRY2_TXEXDEF,
444 TSI108_STAT_TXEXDEF_CARRY,
445 &data->stats.tx_aborted_errors);
446
447 tsi108_stat_carry_one(carry2, TSI108_STAT_CARRY2_TXEXCOL,
448 TSI108_STAT_TXEXCOL_CARRY, &data->tx_coll_abort);
449
450 tsi108_stat_carry_one(carry2, TSI108_STAT_CARRY2_TXTCOL,
451 TSI108_STAT_TXTCOL_CARRY,
452 &data->stats.collisions);
453
454 tsi108_stat_carry_one(carry2, TSI108_STAT_CARRY2_TXPAUSE,
455 TSI108_STAT_TXPAUSEDROP_CARRY,
456 &data->tx_pause_drop);
457
458 spin_unlock_irq(&data->misclock);
459}
460
461/* Read a stat counter atomically with respect to carries.
462 * data->misclock must be held.
463 */
464static inline unsigned long
465tsi108_read_stat(struct tsi108_prv_data * data, int reg, int carry_bit,
466 int carry_shift, unsigned long *upper)
467{
468 int carryreg;
469 unsigned long val;
470
471 if (reg < 0xb0)
472 carryreg = TSI108_STAT_CARRY1;
473 else
474 carryreg = TSI108_STAT_CARRY2;
475
476 again:
477 val = TSI_READ(reg) | *upper;
478
479 /* Check to see if it overflowed, but the interrupt hasn't
480 * been serviced yet. If so, handle the carry here, and
481 * try again.
482 */
483
484 if (unlikely(TSI_READ(carryreg) & carry_bit)) {
485 *upper += carry_shift;
486 TSI_WRITE(carryreg, carry_bit);
487 goto again;
488 }
489
490 return val;
491}
492
493static struct net_device_stats *tsi108_get_stats(struct net_device *dev)
494{
495 unsigned long excol;
496
497 struct tsi108_prv_data *data = netdev_priv(dev);
498 spin_lock_irq(&data->misclock);
499
500 data->tmpstats.rx_packets =
501 tsi108_read_stat(data, TSI108_STAT_RXPKTS,
502 TSI108_STAT_CARRY1_RXPKTS,
503 TSI108_STAT_RXPKTS_CARRY, &data->stats.rx_packets);
504
505 data->tmpstats.tx_packets =
506 tsi108_read_stat(data, TSI108_STAT_TXPKTS,
507 TSI108_STAT_CARRY2_TXPKTS,
508 TSI108_STAT_TXPKTS_CARRY, &data->stats.tx_packets);
509
510 data->tmpstats.rx_bytes =
511 tsi108_read_stat(data, TSI108_STAT_RXBYTES,
512 TSI108_STAT_CARRY1_RXBYTES,
513 TSI108_STAT_RXBYTES_CARRY, &data->stats.rx_bytes);
514
515 data->tmpstats.tx_bytes =
516 tsi108_read_stat(data, TSI108_STAT_TXBYTES,
517 TSI108_STAT_CARRY2_TXBYTES,
518 TSI108_STAT_TXBYTES_CARRY, &data->stats.tx_bytes);
519
520 data->tmpstats.multicast =
521 tsi108_read_stat(data, TSI108_STAT_RXMCAST,
522 TSI108_STAT_CARRY1_RXMCAST,
523 TSI108_STAT_RXMCAST_CARRY, &data->stats.multicast);
524
525 excol = tsi108_read_stat(data, TSI108_STAT_TXEXCOL,
526 TSI108_STAT_CARRY2_TXEXCOL,
527 TSI108_STAT_TXEXCOL_CARRY,
528 &data->tx_coll_abort);
529
530 data->tmpstats.collisions =
531 tsi108_read_stat(data, TSI108_STAT_TXTCOL,
532 TSI108_STAT_CARRY2_TXTCOL,
533 TSI108_STAT_TXTCOL_CARRY, &data->stats.collisions);
534
535 data->tmpstats.collisions += excol;
536
537 data->tmpstats.rx_length_errors =
538 tsi108_read_stat(data, TSI108_STAT_RXLENGTH,
539 TSI108_STAT_CARRY1_RXLENGTH,
540 TSI108_STAT_RXLENGTH_CARRY,
541 &data->stats.rx_length_errors);
542
543 data->tmpstats.rx_length_errors +=
544 tsi108_read_stat(data, TSI108_STAT_RXRUNT,
545 TSI108_STAT_CARRY1_RXRUNT,
546 TSI108_STAT_RXRUNT_CARRY, &data->rx_underruns);
547
548 data->tmpstats.rx_length_errors +=
549 tsi108_read_stat(data, TSI108_STAT_RXJUMBO,
550 TSI108_STAT_CARRY1_RXJUMBO,
551 TSI108_STAT_RXJUMBO_CARRY, &data->rx_overruns);
552
553 data->tmpstats.rx_frame_errors =
554 tsi108_read_stat(data, TSI108_STAT_RXALIGN,
555 TSI108_STAT_CARRY1_RXALIGN,
556 TSI108_STAT_RXALIGN_CARRY,
557 &data->stats.rx_frame_errors);
558
559 data->tmpstats.rx_frame_errors +=
560 tsi108_read_stat(data, TSI108_STAT_RXFCS,
561 TSI108_STAT_CARRY1_RXFCS, TSI108_STAT_RXFCS_CARRY,
562 &data->rx_fcs);
563
564 data->tmpstats.rx_frame_errors +=
565 tsi108_read_stat(data, TSI108_STAT_RXFRAG,
566 TSI108_STAT_CARRY1_RXFRAG,
567 TSI108_STAT_RXFRAG_CARRY, &data->rx_short_fcs);
568
569 data->tmpstats.rx_missed_errors =
570 tsi108_read_stat(data, TSI108_STAT_RXDROP,
571 TSI108_STAT_CARRY1_RXDROP,
572 TSI108_STAT_RXDROP_CARRY,
573 &data->stats.rx_missed_errors);
574
575 /* These three are maintained by software. */
576 data->tmpstats.rx_fifo_errors = data->stats.rx_fifo_errors;
577 data->tmpstats.rx_crc_errors = data->stats.rx_crc_errors;
578
579 data->tmpstats.tx_aborted_errors =
580 tsi108_read_stat(data, TSI108_STAT_TXEXDEF,
581 TSI108_STAT_CARRY2_TXEXDEF,
582 TSI108_STAT_TXEXDEF_CARRY,
583 &data->stats.tx_aborted_errors);
584
585 data->tmpstats.tx_aborted_errors +=
586 tsi108_read_stat(data, TSI108_STAT_TXPAUSEDROP,
587 TSI108_STAT_CARRY2_TXPAUSE,
588 TSI108_STAT_TXPAUSEDROP_CARRY,
589 &data->tx_pause_drop);
590
591 data->tmpstats.tx_aborted_errors += excol;
592
593 data->tmpstats.tx_errors = data->tmpstats.tx_aborted_errors;
594 data->tmpstats.rx_errors = data->tmpstats.rx_length_errors +
595 data->tmpstats.rx_crc_errors +
596 data->tmpstats.rx_frame_errors +
597 data->tmpstats.rx_fifo_errors + data->tmpstats.rx_missed_errors;
598
599 spin_unlock_irq(&data->misclock);
600 return &data->tmpstats;
601}
602
603static void tsi108_restart_rx(struct tsi108_prv_data * data, struct net_device *dev)
604{
605 TSI_WRITE(TSI108_EC_RXQ_PTRHIGH,
606 TSI108_EC_RXQ_PTRHIGH_VALID);
607
608 TSI_WRITE(TSI108_EC_RXCTRL, TSI108_EC_RXCTRL_GO
609 | TSI108_EC_RXCTRL_QUEUE0);
610}
611
612static void tsi108_restart_tx(struct tsi108_prv_data * data)
613{
614 TSI_WRITE(TSI108_EC_TXQ_PTRHIGH,
615 TSI108_EC_TXQ_PTRHIGH_VALID);
616
617 TSI_WRITE(TSI108_EC_TXCTRL, TSI108_EC_TXCTRL_IDLEINT |
618 TSI108_EC_TXCTRL_GO | TSI108_EC_TXCTRL_QUEUE0);
619}
620
621/* txlock must be held by caller, with IRQs disabled, and
622 * with permission to re-enable them when the lock is dropped.
623 */
624static void tsi108_complete_tx(struct net_device *dev)
625{
626 struct tsi108_prv_data *data = netdev_priv(dev);
627 int tx;
628 struct sk_buff *skb;
629 int release = 0;
630
631 while (!data->txfree || data->txhead != data->txtail) {
632 tx = data->txtail;
633
634 if (data->txring[tx].misc & TSI108_TX_OWN)
635 break;
636
637 skb = data->txskbs[tx];
638
639 if (!(data->txring[tx].misc & TSI108_TX_OK))
640 printk("%s: bad tx packet, misc %x\n",
641 dev->name, data->txring[tx].misc);
642
643 data->txtail = (data->txtail + 1) % TSI108_TXRING_LEN;
644 data->txfree++;
645
646 if (data->txring[tx].misc & TSI108_TX_EOF) {
647 dev_kfree_skb_any(skb);
648 release++;
649 }
650 }
651
652 if (release) {
653 if (is_valid_ether_addr(dev->dev_addr) && data->link_up)
654 netif_wake_queue(dev);
655 }
656}
657
658static int tsi108_send_packet(struct sk_buff * skb, struct net_device *dev)
659{
660 struct tsi108_prv_data *data = netdev_priv(dev);
661 int frags = skb_shinfo(skb)->nr_frags + 1;
662 int i;
663
664 if (!data->phy_ok && net_ratelimit())
665 printk(KERN_ERR "%s: Transmit while PHY is down!\n", dev->name);
666
667 if (!data->link_up) {
668 printk(KERN_ERR "%s: Transmit while link is down!\n",
669 dev->name);
670 netif_stop_queue(dev);
671 return NETDEV_TX_BUSY;
672 }
673
674 if (data->txfree < MAX_SKB_FRAGS + 1) {
675 netif_stop_queue(dev);
676
677 if (net_ratelimit())
678 printk(KERN_ERR "%s: Transmit with full tx ring!\n",
679 dev->name);
680 return NETDEV_TX_BUSY;
681 }
682
683 if (data->txfree - frags < MAX_SKB_FRAGS + 1) {
684 netif_stop_queue(dev);
685 }
686
687 spin_lock_irq(&data->txlock);
688
689 for (i = 0; i < frags; i++) {
690 int misc = 0;
691 int tx = data->txhead;
692
693 /* This is done to mark every TSI108_TX_INT_FREQ tx buffers with
694 * the interrupt bit. TX descriptor-complete interrupts are
695 * enabled when the queue fills up, and masked when there is
696 * still free space. This way, when saturating the outbound
697 * link, the tx interrupts are kept to a reasonable level.
698 * When the queue is not full, reclamation of skbs still occurs
699 * as new packets are transmitted, or on a queue-empty
700 * interrupt.
701 */
702
703 if ((tx % TSI108_TX_INT_FREQ == 0) &&
704 ((TSI108_TXRING_LEN - data->txfree) >= TSI108_TX_INT_FREQ))
705 misc = TSI108_TX_INT;
706
707 data->txskbs[tx] = skb;
708
709 if (i == 0) {
710 data->txring[tx].buf0 = dma_map_single(NULL, skb->data,
711 skb->len - skb->data_len, DMA_TO_DEVICE);
712 data->txring[tx].len = skb->len - skb->data_len;
713 misc |= TSI108_TX_SOF;
714 } else {
715 skb_frag_t *frag = &skb_shinfo(skb)->frags[i - 1];
716
717 data->txring[tx].buf0 =
718 dma_map_page(NULL, frag->page, frag->page_offset,
719 frag->size, DMA_TO_DEVICE);
720 data->txring[tx].len = frag->size;
721 }
722
723 if (i == frags - 1)
724 misc |= TSI108_TX_EOF;
725
726 if (netif_msg_pktdata(data)) {
727 int i;
728 printk("%s: Tx Frame contents (%d)\n", dev->name,
729 skb->len);
730 for (i = 0; i < skb->len; i++)
731 printk(" %2.2x", skb->data[i]);
732 printk(".\n");
733 }
734 data->txring[tx].misc = misc | TSI108_TX_OWN;
735
736 data->txhead = (data->txhead + 1) % TSI108_TXRING_LEN;
737 data->txfree--;
738 }
739
740 tsi108_complete_tx(dev);
741
742 /* This must be done after the check for completed tx descriptors,
743 * so that the tail pointer is correct.
744 */
745
746 if (!(TSI_READ(TSI108_EC_TXSTAT) & TSI108_EC_TXSTAT_QUEUE0))
747 tsi108_restart_tx(data);
748
749 spin_unlock_irq(&data->txlock);
750 return NETDEV_TX_OK;
751}
752
753static int tsi108_complete_rx(struct net_device *dev, int budget)
754{
755 struct tsi108_prv_data *data = netdev_priv(dev);
756 int done = 0;
757
758 while (data->rxfree && done != budget) {
759 int rx = data->rxtail;
760 struct sk_buff *skb;
761
762 if (data->rxring[rx].misc & TSI108_RX_OWN)
763 break;
764
765 skb = data->rxskbs[rx];
766 data->rxtail = (data->rxtail + 1) % TSI108_RXRING_LEN;
767 data->rxfree--;
768 done++;
769
770 if (data->rxring[rx].misc & TSI108_RX_BAD) {
771 spin_lock_irq(&data->misclock);
772
773 if (data->rxring[rx].misc & TSI108_RX_CRC)
774 data->stats.rx_crc_errors++;
775 if (data->rxring[rx].misc & TSI108_RX_OVER)
776 data->stats.rx_fifo_errors++;
777
778 spin_unlock_irq(&data->misclock);
779
780 dev_kfree_skb_any(skb);
781 continue;
782 }
783 if (netif_msg_pktdata(data)) {
784 int i;
785 printk("%s: Rx Frame contents (%d)\n",
786 dev->name, data->rxring[rx].len);
787 for (i = 0; i < data->rxring[rx].len; i++)
788 printk(" %2.2x", skb->data[i]);
789 printk(".\n");
790 }
791
792 skb->dev = dev;
793 skb_put(skb, data->rxring[rx].len);
794 skb->protocol = eth_type_trans(skb, dev);
795 netif_receive_skb(skb);
796 dev->last_rx = jiffies;
797 }
798
799 return done;
800}
801
802static int tsi108_refill_rx(struct net_device *dev, int budget)
803{
804 struct tsi108_prv_data *data = netdev_priv(dev);
805 int done = 0;
806
807 while (data->rxfree != TSI108_RXRING_LEN && done != budget) {
808 int rx = data->rxhead;
809 struct sk_buff *skb;
810
811 data->rxskbs[rx] = skb = dev_alloc_skb(TSI108_RXBUF_SIZE + 2);
812 if (!skb)
813 break;
814
815 skb_reserve(skb, 2); /* Align the data on a 4-byte boundary. */
816
817 data->rxring[rx].buf0 = dma_map_single(NULL, skb->data,
818 TSI108_RX_SKB_SIZE,
819 DMA_FROM_DEVICE);
820
821 /* Sometimes the hardware sets blen to zero after packet
822 * reception, even though the manual says that it's only ever
823 * modified by the driver.
824 */
825
826 data->rxring[rx].blen = TSI108_RX_SKB_SIZE;
827 data->rxring[rx].misc = TSI108_RX_OWN | TSI108_RX_INT;
828
829 data->rxhead = (data->rxhead + 1) % TSI108_RXRING_LEN;
830 data->rxfree++;
831 done++;
832 }
833
834 if (done != 0 && !(TSI_READ(TSI108_EC_RXSTAT) &
835 TSI108_EC_RXSTAT_QUEUE0))
836 tsi108_restart_rx(data, dev);
837
838 return done;
839}
840
841static int tsi108_poll(struct net_device *dev, int *budget)
842{
843 struct tsi108_prv_data *data = netdev_priv(dev);
844 u32 estat = TSI_READ(TSI108_EC_RXESTAT);
845 u32 intstat = TSI_READ(TSI108_EC_INTSTAT);
846 int total_budget = min(*budget, dev->quota);
847 int num_received = 0, num_filled = 0, budget_used;
848
849 intstat &= TSI108_INT_RXQUEUE0 | TSI108_INT_RXTHRESH |
850 TSI108_INT_RXOVERRUN | TSI108_INT_RXERROR | TSI108_INT_RXWAIT;
851
852 TSI_WRITE(TSI108_EC_RXESTAT, estat);
853 TSI_WRITE(TSI108_EC_INTSTAT, intstat);
854
855 if (data->rxpending || (estat & TSI108_EC_RXESTAT_Q0_DESCINT))
856 num_received = tsi108_complete_rx(dev, total_budget);
857
858 /* This should normally fill no more slots than the number of
859 * packets received in tsi108_complete_rx(). The exception
860 * is when we previously ran out of memory for RX SKBs. In that
861 * case, it's helpful to obey the budget, not only so that the
862 * CPU isn't hogged, but so that memory (which may still be low)
863 * is not hogged by one device.
864 *
865 * A work unit is considered to be two SKBs to allow us to catch
866 * up when the ring has shrunk due to out-of-memory but we're
867 * still removing the full budget's worth of packets each time.
868 */
869
870 if (data->rxfree < TSI108_RXRING_LEN)
871 num_filled = tsi108_refill_rx(dev, total_budget * 2);
872
873 if (intstat & TSI108_INT_RXERROR) {
874 u32 err = TSI_READ(TSI108_EC_RXERR);
875 TSI_WRITE(TSI108_EC_RXERR, err);
876
877 if (err) {
878 if (net_ratelimit())
879 printk(KERN_DEBUG "%s: RX error %x\n",
880 dev->name, err);
881
882 if (!(TSI_READ(TSI108_EC_RXSTAT) &
883 TSI108_EC_RXSTAT_QUEUE0))
884 tsi108_restart_rx(data, dev);
885 }
886 }
887
888 if (intstat & TSI108_INT_RXOVERRUN) {
889 spin_lock_irq(&data->misclock);
890 data->stats.rx_fifo_errors++;
891 spin_unlock_irq(&data->misclock);
892 }
893
894 budget_used = max(num_received, num_filled / 2);
895
896 *budget -= budget_used;
897 dev->quota -= budget_used;
898
899 if (budget_used != total_budget) {
900 data->rxpending = 0;
901 netif_rx_complete(dev);
902
903 TSI_WRITE(TSI108_EC_INTMASK,
904 TSI_READ(TSI108_EC_INTMASK)
905 & ~(TSI108_INT_RXQUEUE0
906 | TSI108_INT_RXTHRESH |
907 TSI108_INT_RXOVERRUN |
908 TSI108_INT_RXERROR |
909 TSI108_INT_RXWAIT));
910
911 /* IRQs are level-triggered, so no need to re-check */
912 return 0;
913 } else {
914 data->rxpending = 1;
915 }
916
917 return 1;
918}
919
920static void tsi108_rx_int(struct net_device *dev)
921{
922 struct tsi108_prv_data *data = netdev_priv(dev);
923
924 /* A race could cause dev to already be scheduled, so it's not an
925 * error if that happens (and interrupts shouldn't be re-masked,
926 * because that can cause harmful races, if poll has already
927 * unmasked them but not cleared LINK_STATE_SCHED).
928 *
929 * This can happen if this code races with tsi108_poll(), which masks
930 * the interrupts after tsi108_irq_one() read the mask, but before
931 * netif_rx_schedule is called. It could also happen due to calls
932 * from tsi108_check_rxring().
933 */
934
935 if (netif_rx_schedule_prep(dev)) {
936 /* Mask, rather than ack, the receive interrupts. The ack
937 * will happen in tsi108_poll().
938 */
939
940 TSI_WRITE(TSI108_EC_INTMASK,
941 TSI_READ(TSI108_EC_INTMASK) |
942 TSI108_INT_RXQUEUE0
943 | TSI108_INT_RXTHRESH |
944 TSI108_INT_RXOVERRUN | TSI108_INT_RXERROR |
945 TSI108_INT_RXWAIT);
946 __netif_rx_schedule(dev);
947 } else {
948 if (!netif_running(dev)) {
949 /* This can happen if an interrupt occurs while the
950 * interface is being brought down, as the START
951 * bit is cleared before the stop function is called.
952 *
953 * In this case, the interrupts must be masked, or
954 * they will continue indefinitely.
955 *
956 * There's a race here if the interface is brought down
957 * and then up in rapid succession, as the device could
958 * be made running after the above check and before
959 * the masking below. This will only happen if the IRQ
960 * thread has a lower priority than the task brining
961 * up the interface. Fixing this race would likely
962 * require changes in generic code.
963 */
964
965 TSI_WRITE(TSI108_EC_INTMASK,
966 TSI_READ
967 (TSI108_EC_INTMASK) |
968 TSI108_INT_RXQUEUE0 |
969 TSI108_INT_RXTHRESH |
970 TSI108_INT_RXOVERRUN |
971 TSI108_INT_RXERROR |
972 TSI108_INT_RXWAIT);
973 }
974 }
975}
976
977/* If the RX ring has run out of memory, try periodically
978 * to allocate some more, as otherwise poll would never
979 * get called (apart from the initial end-of-queue condition).
980 *
981 * This is called once per second (by default) from the thread.
982 */
983
984static void tsi108_check_rxring(struct net_device *dev)
985{
986 struct tsi108_prv_data *data = netdev_priv(dev);
987
988 /* A poll is scheduled, as opposed to caling tsi108_refill_rx
989 * directly, so as to keep the receive path single-threaded
990 * (and thus not needing a lock).
991 */
992
993 if (netif_running(dev) && data->rxfree < TSI108_RXRING_LEN / 4)
994 tsi108_rx_int(dev);
995}
996
997static void tsi108_tx_int(struct net_device *dev)
998{
999 struct tsi108_prv_data *data = netdev_priv(dev);
1000 u32 estat = TSI_READ(TSI108_EC_TXESTAT);
1001
1002 TSI_WRITE(TSI108_EC_TXESTAT, estat);
1003 TSI_WRITE(TSI108_EC_INTSTAT, TSI108_INT_TXQUEUE0 |
1004 TSI108_INT_TXIDLE | TSI108_INT_TXERROR);
1005 if (estat & TSI108_EC_TXESTAT_Q0_ERR) {
1006 u32 err = TSI_READ(TSI108_EC_TXERR);
1007 TSI_WRITE(TSI108_EC_TXERR, err);
1008
1009 if (err && net_ratelimit())
1010 printk(KERN_ERR "%s: TX error %x\n", dev->name, err);
1011 }
1012
1013 if (estat & (TSI108_EC_TXESTAT_Q0_DESCINT | TSI108_EC_TXESTAT_Q0_EOQ)) {
1014 spin_lock(&data->txlock);
1015 tsi108_complete_tx(dev);
1016 spin_unlock(&data->txlock);
1017 }
1018}
1019
1020
1021static irqreturn_t tsi108_irq(int irq, void *dev_id)
1022{
1023 struct net_device *dev = dev_id;
1024 struct tsi108_prv_data *data = netdev_priv(dev);
1025 u32 stat = TSI_READ(TSI108_EC_INTSTAT);
1026
1027 if (!(stat & TSI108_INT_ANY))
1028 return IRQ_NONE; /* Not our interrupt */
1029
1030 stat &= ~TSI_READ(TSI108_EC_INTMASK);
1031
1032 if (stat & (TSI108_INT_TXQUEUE0 | TSI108_INT_TXIDLE |
1033 TSI108_INT_TXERROR))
1034 tsi108_tx_int(dev);
1035 if (stat & (TSI108_INT_RXQUEUE0 | TSI108_INT_RXTHRESH |
1036 TSI108_INT_RXWAIT | TSI108_INT_RXOVERRUN |
1037 TSI108_INT_RXERROR))
1038 tsi108_rx_int(dev);
1039
1040 if (stat & TSI108_INT_SFN) {
1041 if (net_ratelimit())
1042 printk(KERN_DEBUG "%s: SFN error\n", dev->name);
1043 TSI_WRITE(TSI108_EC_INTSTAT, TSI108_INT_SFN);
1044 }
1045
1046 if (stat & TSI108_INT_STATCARRY) {
1047 tsi108_stat_carry(dev);
1048 TSI_WRITE(TSI108_EC_INTSTAT, TSI108_INT_STATCARRY);
1049 }
1050
1051 return IRQ_HANDLED;
1052}
1053
1054static void tsi108_stop_ethernet(struct net_device *dev)
1055{
1056 struct tsi108_prv_data *data = netdev_priv(dev);
1057 int i = 1000;
1058 /* Disable all TX and RX queues ... */
1059 TSI_WRITE(TSI108_EC_TXCTRL, 0);
1060 TSI_WRITE(TSI108_EC_RXCTRL, 0);
1061
1062 /* ...and wait for them to become idle */
1063 while(i--) {
1064 if(!(TSI_READ(TSI108_EC_TXSTAT) & TSI108_EC_TXSTAT_ACTIVE))
1065 break;
1066 udelay(10);
1067 }
1068 i = 1000;
1069 while(i--){
1070 if(!(TSI_READ(TSI108_EC_RXSTAT) & TSI108_EC_RXSTAT_ACTIVE))
1071 return;
1072 udelay(10);
1073 }
1074 printk(KERN_ERR "%s function time out \n", __FUNCTION__);
1075}
1076
1077static void tsi108_reset_ether(struct tsi108_prv_data * data)
1078{
1079 TSI_WRITE(TSI108_MAC_CFG1, TSI108_MAC_CFG1_SOFTRST);
1080 udelay(100);
1081 TSI_WRITE(TSI108_MAC_CFG1, 0);
1082
1083 TSI_WRITE(TSI108_EC_PORTCTRL, TSI108_EC_PORTCTRL_STATRST);
1084 udelay(100);
1085 TSI_WRITE(TSI108_EC_PORTCTRL,
1086 TSI_READ(TSI108_EC_PORTCTRL) &
1087 ~TSI108_EC_PORTCTRL_STATRST);
1088
1089 TSI_WRITE(TSI108_EC_TXCFG, TSI108_EC_TXCFG_RST);
1090 udelay(100);
1091 TSI_WRITE(TSI108_EC_TXCFG,
1092 TSI_READ(TSI108_EC_TXCFG) &
1093 ~TSI108_EC_TXCFG_RST);
1094
1095 TSI_WRITE(TSI108_EC_RXCFG, TSI108_EC_RXCFG_RST);
1096 udelay(100);
1097 TSI_WRITE(TSI108_EC_RXCFG,
1098 TSI_READ(TSI108_EC_RXCFG) &
1099 ~TSI108_EC_RXCFG_RST);
1100
1101 TSI_WRITE(TSI108_MAC_MII_MGMT_CFG,
1102 TSI_READ(TSI108_MAC_MII_MGMT_CFG) |
1103 TSI108_MAC_MII_MGMT_RST);
1104 udelay(100);
1105 TSI_WRITE(TSI108_MAC_MII_MGMT_CFG,
1106 (TSI_READ(TSI108_MAC_MII_MGMT_CFG) &
1107 ~(TSI108_MAC_MII_MGMT_RST |
1108 TSI108_MAC_MII_MGMT_CLK)) | 0x07);
1109}
1110
1111static int tsi108_get_mac(struct net_device *dev)
1112{
1113 struct tsi108_prv_data *data = netdev_priv(dev);
1114 u32 word1 = TSI_READ(TSI108_MAC_ADDR1);
1115 u32 word2 = TSI_READ(TSI108_MAC_ADDR2);
1116
1117 /* Note that the octets are reversed from what the manual says,
1118 * producing an even weirder ordering...
1119 */
1120 if (word2 == 0 && word1 == 0) {
1121 dev->dev_addr[0] = 0x00;
1122 dev->dev_addr[1] = 0x06;
1123 dev->dev_addr[2] = 0xd2;
1124 dev->dev_addr[3] = 0x00;
1125 dev->dev_addr[4] = 0x00;
1126 if (0x8 == data->phy)
1127 dev->dev_addr[5] = 0x01;
1128 else
1129 dev->dev_addr[5] = 0x02;
1130
1131 word2 = (dev->dev_addr[0] << 16) | (dev->dev_addr[1] << 24);
1132
1133 word1 = (dev->dev_addr[2] << 0) | (dev->dev_addr[3] << 8) |
1134 (dev->dev_addr[4] << 16) | (dev->dev_addr[5] << 24);
1135
1136 TSI_WRITE(TSI108_MAC_ADDR1, word1);
1137 TSI_WRITE(TSI108_MAC_ADDR2, word2);
1138 } else {
1139 dev->dev_addr[0] = (word2 >> 16) & 0xff;
1140 dev->dev_addr[1] = (word2 >> 24) & 0xff;
1141 dev->dev_addr[2] = (word1 >> 0) & 0xff;
1142 dev->dev_addr[3] = (word1 >> 8) & 0xff;
1143 dev->dev_addr[4] = (word1 >> 16) & 0xff;
1144 dev->dev_addr[5] = (word1 >> 24) & 0xff;
1145 }
1146
1147 if (!is_valid_ether_addr(dev->dev_addr)) {
1148 printk("KERN_ERR: word1: %08x, word2: %08x\n", word1, word2);
1149 return -EINVAL;
1150 }
1151
1152 return 0;
1153}
1154
1155static int tsi108_set_mac(struct net_device *dev, void *addr)
1156{
1157 struct tsi108_prv_data *data = netdev_priv(dev);
1158 u32 word1, word2;
1159 int i;
1160
1161 if (!is_valid_ether_addr(addr))
1162 return -EINVAL;
1163
1164 for (i = 0; i < 6; i++)
1165 /* +2 is for the offset of the HW addr type */
1166 dev->dev_addr[i] = ((unsigned char *)addr)[i + 2];
1167
1168 word2 = (dev->dev_addr[0] << 16) | (dev->dev_addr[1] << 24);
1169
1170 word1 = (dev->dev_addr[2] << 0) | (dev->dev_addr[3] << 8) |
1171 (dev->dev_addr[4] << 16) | (dev->dev_addr[5] << 24);
1172
1173 spin_lock_irq(&data->misclock);
1174 TSI_WRITE(TSI108_MAC_ADDR1, word1);
1175 TSI_WRITE(TSI108_MAC_ADDR2, word2);
1176 spin_lock(&data->txlock);
1177
1178 if (data->txfree && data->link_up)
1179 netif_wake_queue(dev);
1180
1181 spin_unlock(&data->txlock);
1182 spin_unlock_irq(&data->misclock);
1183 return 0;
1184}
1185
1186/* Protected by dev->xmit_lock. */
1187static void tsi108_set_rx_mode(struct net_device *dev)
1188{
1189 struct tsi108_prv_data *data = netdev_priv(dev);
1190 u32 rxcfg = TSI_READ(TSI108_EC_RXCFG);
1191
1192 if (dev->flags & IFF_PROMISC) {
1193 rxcfg &= ~(TSI108_EC_RXCFG_UC_HASH | TSI108_EC_RXCFG_MC_HASH);
1194 rxcfg |= TSI108_EC_RXCFG_UFE | TSI108_EC_RXCFG_MFE;
1195 goto out;
1196 }
1197
1198 rxcfg &= ~(TSI108_EC_RXCFG_UFE | TSI108_EC_RXCFG_MFE);
1199
1200 if (dev->flags & IFF_ALLMULTI || dev->mc_count) {
1201 int i;
1202 struct dev_mc_list *mc = dev->mc_list;
1203 rxcfg |= TSI108_EC_RXCFG_MFE | TSI108_EC_RXCFG_MC_HASH;
1204
1205 memset(data->mc_hash, 0, sizeof(data->mc_hash));
1206
1207 while (mc) {
1208 u32 hash, crc;
1209
1210 if (mc->dmi_addrlen == 6) {
1211 crc = ether_crc(6, mc->dmi_addr);
1212 hash = crc >> 23;
1213
1214 __set_bit(hash, &data->mc_hash[0]);
1215 } else {
1216 printk(KERN_ERR
1217 "%s: got multicast address of length %d "
1218 "instead of 6.\n", dev->name,
1219 mc->dmi_addrlen);
1220 }
1221
1222 mc = mc->next;
1223 }
1224
1225 TSI_WRITE(TSI108_EC_HASHADDR,
1226 TSI108_EC_HASHADDR_AUTOINC |
1227 TSI108_EC_HASHADDR_MCAST);
1228
1229 for (i = 0; i < 16; i++) {
1230 /* The manual says that the hardware may drop
1231 * back-to-back writes to the data register.
1232 */
1233 udelay(1);
1234 TSI_WRITE(TSI108_EC_HASHDATA,
1235 data->mc_hash[i]);
1236 }
1237 }
1238
1239 out:
1240 TSI_WRITE(TSI108_EC_RXCFG, rxcfg);
1241}
1242
1243static void tsi108_init_phy(struct net_device *dev)
1244{
1245 struct tsi108_prv_data *data = netdev_priv(dev);
1246 u32 i = 0;
1247 u16 phyval = 0;
1248 unsigned long flags;
1249
1250 spin_lock_irqsave(&phy_lock, flags);
1251
1252 tsi108_write_mii(data, MII_BMCR, BMCR_RESET);
1253 while (i--){
1254 if(!(tsi108_read_mii(data, MII_BMCR) & BMCR_RESET))
1255 break;
1256 udelay(10);
1257 }
1258 if (i == 0)
1259 printk(KERN_ERR "%s function time out \n", __FUNCTION__);
1260
1261#if (TSI108_PHY_TYPE == PHY_BCM54XX) /* Broadcom BCM54xx PHY */
1262 tsi108_write_mii(data, 0x09, 0x0300);
1263 tsi108_write_mii(data, 0x10, 0x1020);
1264 tsi108_write_mii(data, 0x1c, 0x8c00);
1265#endif
1266
1267 tsi108_write_mii(data,
1268 MII_BMCR,
1269 BMCR_ANENABLE | BMCR_ANRESTART);
1270 while (tsi108_read_mii(data, MII_BMCR) & BMCR_ANRESTART)
1271 cpu_relax();
1272
1273 /* Set G/MII mode and receive clock select in TBI control #2. The
1274 * second port won't work if this isn't done, even though we don't
1275 * use TBI mode.
1276 */
1277
1278 tsi108_write_tbi(data, 0x11, 0x30);
1279
1280 /* FIXME: It seems to take more than 2 back-to-back reads to the
1281 * PHY_STAT register before the link up status bit is set.
1282 */
1283
1284 data->link_up = 1;
1285
1286 while (!((phyval = tsi108_read_mii(data, MII_BMSR)) &
1287 BMSR_LSTATUS)) {
1288 if (i++ > (MII_READ_DELAY / 10)) {
1289 data->link_up = 0;
1290 break;
1291 }
1292 spin_unlock_irqrestore(&phy_lock, flags);
1293 msleep(10);
1294 spin_lock_irqsave(&phy_lock, flags);
1295 }
1296
1297 printk(KERN_DEBUG "PHY_STAT reg contains %08x\n", phyval);
1298 data->phy_ok = 1;
1299 data->init_media = 1;
1300 spin_unlock_irqrestore(&phy_lock, flags);
1301}
1302
1303static void tsi108_kill_phy(struct net_device *dev)
1304{
1305 struct tsi108_prv_data *data = netdev_priv(dev);
1306 unsigned long flags;
1307
1308 spin_lock_irqsave(&phy_lock, flags);
1309 tsi108_write_mii(data, MII_BMCR, BMCR_PDOWN);
1310 data->phy_ok = 0;
1311 spin_unlock_irqrestore(&phy_lock, flags);
1312}
1313
1314static int tsi108_open(struct net_device *dev)
1315{
1316 int i;
1317 struct tsi108_prv_data *data = netdev_priv(dev);
1318 unsigned int rxring_size = TSI108_RXRING_LEN * sizeof(rx_desc);
1319 unsigned int txring_size = TSI108_TXRING_LEN * sizeof(tx_desc);
1320
1321 i = request_irq(data->irq_num, tsi108_irq, 0, dev->name, dev);
1322 if (i != 0) {
1323 printk(KERN_ERR "tsi108_eth%d: Could not allocate IRQ%d.\n",
1324 data->id, data->irq_num);
1325 return i;
1326 } else {
1327 dev->irq = data->irq_num;
1328 printk(KERN_NOTICE
1329 "tsi108_open : Port %d Assigned IRQ %d to %s\n",
1330 data->id, dev->irq, dev->name);
1331 }
1332
1333 data->rxring = dma_alloc_coherent(NULL, rxring_size,
1334 &data->rxdma, GFP_KERNEL);
1335
1336 if (!data->rxring) {
1337 printk(KERN_DEBUG
1338 "TSI108_ETH: failed to allocate memory for rxring!\n");
1339 return -ENOMEM;
1340 } else {
1341 memset(data->rxring, 0, rxring_size);
1342 }
1343
1344 data->txring = dma_alloc_coherent(NULL, txring_size,
1345 &data->txdma, GFP_KERNEL);
1346
1347 if (!data->txring) {
1348 printk(KERN_DEBUG
1349 "TSI108_ETH: failed to allocate memory for txring!\n");
1350 pci_free_consistent(0, rxring_size, data->rxring, data->rxdma);
1351 return -ENOMEM;
1352 } else {
1353 memset(data->txring, 0, txring_size);
1354 }
1355
1356 for (i = 0; i < TSI108_RXRING_LEN; i++) {
1357 data->rxring[i].next0 = data->rxdma + (i + 1) * sizeof(rx_desc);
1358 data->rxring[i].blen = TSI108_RXBUF_SIZE;
1359 data->rxring[i].vlan = 0;
1360 }
1361
1362 data->rxring[TSI108_RXRING_LEN - 1].next0 = data->rxdma;
1363
1364 data->rxtail = 0;
1365 data->rxhead = 0;
1366
1367 for (i = 0; i < TSI108_RXRING_LEN; i++) {
1368 struct sk_buff *skb = dev_alloc_skb(TSI108_RXBUF_SIZE + NET_IP_ALIGN);
1369
1370 if (!skb) {
1371 /* Bah. No memory for now, but maybe we'll get
1372 * some more later.
1373 * For now, we'll live with the smaller ring.
1374 */
1375 printk(KERN_WARNING
1376 "%s: Could only allocate %d receive skb(s).\n",
1377 dev->name, i);
1378 data->rxhead = i;
1379 break;
1380 }
1381
1382 data->rxskbs[i] = skb;
1383 /* Align the payload on a 4-byte boundary */
1384 skb_reserve(skb, 2);
1385 data->rxskbs[i] = skb;
1386 data->rxring[i].buf0 = virt_to_phys(data->rxskbs[i]->data);
1387 data->rxring[i].misc = TSI108_RX_OWN | TSI108_RX_INT;
1388 }
1389
1390 data->rxfree = i;
1391 TSI_WRITE(TSI108_EC_RXQ_PTRLOW, data->rxdma);
1392
1393 for (i = 0; i < TSI108_TXRING_LEN; i++) {
1394 data->txring[i].next0 = data->txdma + (i + 1) * sizeof(tx_desc);
1395 data->txring[i].misc = 0;
1396 }
1397
1398 data->txring[TSI108_TXRING_LEN - 1].next0 = data->txdma;
1399 data->txtail = 0;
1400 data->txhead = 0;
1401 data->txfree = TSI108_TXRING_LEN;
1402 TSI_WRITE(TSI108_EC_TXQ_PTRLOW, data->txdma);
1403 tsi108_init_phy(dev);
1404
1405 setup_timer(&data->timer, tsi108_timed_checker, (unsigned long)dev);
1406 mod_timer(&data->timer, jiffies + 1);
1407
1408 tsi108_restart_rx(data, dev);
1409
1410 TSI_WRITE(TSI108_EC_INTSTAT, ~0);
1411
1412 TSI_WRITE(TSI108_EC_INTMASK,
1413 ~(TSI108_INT_TXQUEUE0 | TSI108_INT_RXERROR |
1414 TSI108_INT_RXTHRESH | TSI108_INT_RXQUEUE0 |
1415 TSI108_INT_RXOVERRUN | TSI108_INT_RXWAIT |
1416 TSI108_INT_SFN | TSI108_INT_STATCARRY));
1417
1418 TSI_WRITE(TSI108_MAC_CFG1,
1419 TSI108_MAC_CFG1_RXEN | TSI108_MAC_CFG1_TXEN);
1420 netif_start_queue(dev);
1421 return 0;
1422}
1423
1424static int tsi108_close(struct net_device *dev)
1425{
1426 struct tsi108_prv_data *data = netdev_priv(dev);
1427
1428 netif_stop_queue(dev);
1429
1430 del_timer_sync(&data->timer);
1431
1432 tsi108_stop_ethernet(dev);
1433 tsi108_kill_phy(dev);
1434 TSI_WRITE(TSI108_EC_INTMASK, ~0);
1435 TSI_WRITE(TSI108_MAC_CFG1, 0);
1436
1437 /* Check for any pending TX packets, and drop them. */
1438
1439 while (!data->txfree || data->txhead != data->txtail) {
1440 int tx = data->txtail;
1441 struct sk_buff *skb;
1442 skb = data->txskbs[tx];
1443 data->txtail = (data->txtail + 1) % TSI108_TXRING_LEN;
1444 data->txfree++;
1445 dev_kfree_skb(skb);
1446 }
1447
1448 synchronize_irq(data->irq_num);
1449 free_irq(data->irq_num, dev);
1450
1451 /* Discard the RX ring. */
1452
1453 while (data->rxfree) {
1454 int rx = data->rxtail;
1455 struct sk_buff *skb;
1456
1457 skb = data->rxskbs[rx];
1458 data->rxtail = (data->rxtail + 1) % TSI108_RXRING_LEN;
1459 data->rxfree--;
1460 dev_kfree_skb(skb);
1461 }
1462
1463 dma_free_coherent(0,
1464 TSI108_RXRING_LEN * sizeof(rx_desc),
1465 data->rxring, data->rxdma);
1466 dma_free_coherent(0,
1467 TSI108_TXRING_LEN * sizeof(tx_desc),
1468 data->txring, data->txdma);
1469
1470 return 0;
1471}
1472
1473static void tsi108_init_mac(struct net_device *dev)
1474{
1475 struct tsi108_prv_data *data = netdev_priv(dev);
1476
1477 TSI_WRITE(TSI108_MAC_CFG2, TSI108_MAC_CFG2_DFLT_PREAMBLE |
1478 TSI108_MAC_CFG2_PADCRC);
1479
1480 TSI_WRITE(TSI108_EC_TXTHRESH,
1481 (192 << TSI108_EC_TXTHRESH_STARTFILL) |
1482 (192 << TSI108_EC_TXTHRESH_STOPFILL));
1483
1484 TSI_WRITE(TSI108_STAT_CARRYMASK1,
1485 ~(TSI108_STAT_CARRY1_RXBYTES |
1486 TSI108_STAT_CARRY1_RXPKTS |
1487 TSI108_STAT_CARRY1_RXFCS |
1488 TSI108_STAT_CARRY1_RXMCAST |
1489 TSI108_STAT_CARRY1_RXALIGN |
1490 TSI108_STAT_CARRY1_RXLENGTH |
1491 TSI108_STAT_CARRY1_RXRUNT |
1492 TSI108_STAT_CARRY1_RXJUMBO |
1493 TSI108_STAT_CARRY1_RXFRAG |
1494 TSI108_STAT_CARRY1_RXJABBER |
1495 TSI108_STAT_CARRY1_RXDROP));
1496
1497 TSI_WRITE(TSI108_STAT_CARRYMASK2,
1498 ~(TSI108_STAT_CARRY2_TXBYTES |
1499 TSI108_STAT_CARRY2_TXPKTS |
1500 TSI108_STAT_CARRY2_TXEXDEF |
1501 TSI108_STAT_CARRY2_TXEXCOL |
1502 TSI108_STAT_CARRY2_TXTCOL |
1503 TSI108_STAT_CARRY2_TXPAUSE));
1504
1505 TSI_WRITE(TSI108_EC_PORTCTRL, TSI108_EC_PORTCTRL_STATEN);
1506 TSI_WRITE(TSI108_MAC_CFG1, 0);
1507
1508 TSI_WRITE(TSI108_EC_RXCFG,
1509 TSI108_EC_RXCFG_SE | TSI108_EC_RXCFG_BFE);
1510
1511 TSI_WRITE(TSI108_EC_TXQ_CFG, TSI108_EC_TXQ_CFG_DESC_INT |
1512 TSI108_EC_TXQ_CFG_EOQ_OWN_INT |
1513 TSI108_EC_TXQ_CFG_WSWP | (TSI108_PBM_PORT <<
1514 TSI108_EC_TXQ_CFG_SFNPORT));
1515
1516 TSI_WRITE(TSI108_EC_RXQ_CFG, TSI108_EC_RXQ_CFG_DESC_INT |
1517 TSI108_EC_RXQ_CFG_EOQ_OWN_INT |
1518 TSI108_EC_RXQ_CFG_WSWP | (TSI108_PBM_PORT <<
1519 TSI108_EC_RXQ_CFG_SFNPORT));
1520
1521 TSI_WRITE(TSI108_EC_TXQ_BUFCFG,
1522 TSI108_EC_TXQ_BUFCFG_BURST256 |
1523 TSI108_EC_TXQ_BUFCFG_BSWP | (TSI108_PBM_PORT <<
1524 TSI108_EC_TXQ_BUFCFG_SFNPORT));
1525
1526 TSI_WRITE(TSI108_EC_RXQ_BUFCFG,
1527 TSI108_EC_RXQ_BUFCFG_BURST256 |
1528 TSI108_EC_RXQ_BUFCFG_BSWP | (TSI108_PBM_PORT <<
1529 TSI108_EC_RXQ_BUFCFG_SFNPORT));
1530
1531 TSI_WRITE(TSI108_EC_INTMASK, ~0);
1532}
1533
1534static int tsi108_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1535{
1536 struct tsi108_prv_data *data = netdev_priv(dev);
1537 return generic_mii_ioctl(&data->mii_if, if_mii(rq), cmd, NULL);
1538}
1539
1540static int
1541tsi108_init_one(struct platform_device *pdev)
1542{
1543 struct net_device *dev = NULL;
1544 struct tsi108_prv_data *data = NULL;
1545 hw_info *einfo;
1546 int err = 0;
1547
1548 einfo = pdev->dev.platform_data;
1549
1550 if (NULL == einfo) {
1551 printk(KERN_ERR "tsi-eth %d: Missing additional data!\n",
1552 pdev->id);
1553 return -ENODEV;
1554 }
1555
1556 /* Create an ethernet device instance */
1557
1558 dev = alloc_etherdev(sizeof(struct tsi108_prv_data));
1559 if (!dev) {
1560 printk("tsi108_eth: Could not allocate a device structure\n");
1561 return -ENOMEM;
1562 }
1563
1564 printk("tsi108_eth%d: probe...\n", pdev->id);
1565 data = netdev_priv(dev);
1566
1567 pr_debug("tsi108_eth%d:regs:phyresgs:phy:irq_num=0x%x:0x%x:0x%x:0x%x\n",
1568 pdev->id, einfo->regs, einfo->phyregs,
1569 einfo->phy, einfo->irq_num);
1570
1571 data->regs = ioremap(einfo->regs, 0x400);
1572 if (NULL == data->regs) {
1573 err = -ENOMEM;
1574 goto regs_fail;
1575 }
1576
1577 data->phyregs = ioremap(einfo->phyregs, 0x400);
1578 if (NULL == data->phyregs) {
1579 err = -ENOMEM;
1580 goto regs_fail;
1581 }
1582/* MII setup */
1583 data->mii_if.dev = dev;
1584 data->mii_if.mdio_read = tsi108_mdio_read;
1585 data->mii_if.mdio_write = tsi108_mdio_write;
1586 data->mii_if.phy_id = einfo->phy;
1587 data->mii_if.phy_id_mask = 0x1f;
1588 data->mii_if.reg_num_mask = 0x1f;
1589 data->mii_if.supports_gmii = mii_check_gmii_support(&data->mii_if);
1590
1591 data->phy = einfo->phy;
1592 data->irq_num = einfo->irq_num;
1593 data->id = pdev->id;
1594 dev->open = tsi108_open;
1595 dev->stop = tsi108_close;
1596 dev->hard_start_xmit = tsi108_send_packet;
1597 dev->set_mac_address = tsi108_set_mac;
1598 dev->set_multicast_list = tsi108_set_rx_mode;
1599 dev->get_stats = tsi108_get_stats;
1600 dev->poll = tsi108_poll;
1601 dev->do_ioctl = tsi108_do_ioctl;
1602 dev->weight = 64; /* 64 is more suitable for GigE interface - klai */
1603
1604 /* Apparently, the Linux networking code won't use scatter-gather
1605 * if the hardware doesn't do checksums. However, it's faster
1606 * to checksum in place and use SG, as (among other reasons)
1607 * the cache won't be dirtied (which then has to be flushed
1608 * before DMA). The checksumming is done by the driver (via
1609 * a new function skb_csum_dev() in net/core/skbuff.c).
1610 */
1611
1612 dev->features = NETIF_F_HIGHDMA;
1613 SET_MODULE_OWNER(dev);
1614
1615 spin_lock_init(&data->txlock);
1616 spin_lock_init(&data->misclock);
1617
1618 tsi108_reset_ether(data);
1619 tsi108_kill_phy(dev);
1620
1621 if ((err = tsi108_get_mac(dev)) != 0) {
1622 printk(KERN_ERR "%s: Invalid MAC address. Please correct.\n",
1623 dev->name);
1624 goto register_fail;
1625 }
1626
1627 tsi108_init_mac(dev);
1628 err = register_netdev(dev);
1629 if (err) {
1630 printk(KERN_ERR "%s: Cannot register net device, aborting.\n",
1631 dev->name);
1632 goto register_fail;
1633 }
1634
1635 printk(KERN_INFO "%s: Tsi108 Gigabit Ethernet, MAC: "
1636 "%02x:%02x:%02x:%02x:%02x:%02x\n", dev->name,
1637 dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
1638 dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]);
1639#ifdef DEBUG
1640 data->msg_enable = DEBUG;
1641 dump_eth_one(dev);
1642#endif
1643
1644 return 0;
1645
1646register_fail:
1647 iounmap(data->regs);
1648 iounmap(data->phyregs);
1649
1650regs_fail:
1651 free_netdev(dev);
1652 return err;
1653}
1654
1655/* There's no way to either get interrupts from the PHY when
1656 * something changes, or to have the Tsi108 automatically communicate
1657 * with the PHY to reconfigure itself.
1658 *
1659 * Thus, we have to do it using a timer.
1660 */
1661
1662static void tsi108_timed_checker(unsigned long dev_ptr)
1663{
1664 struct net_device *dev = (struct net_device *)dev_ptr;
1665 struct tsi108_prv_data *data = netdev_priv(dev);
1666
1667 tsi108_check_phy(dev);
1668 tsi108_check_rxring(dev);
1669 mod_timer(&data->timer, jiffies + CHECK_PHY_INTERVAL);
1670}
1671
1672static int tsi108_ether_init(void)
1673{
1674 int ret;
1675 ret = platform_driver_register (&tsi_eth_driver);
1676 if (ret < 0){
1677 printk("tsi108_ether_init: error initializing ethernet "
1678 "device\n");
1679 return ret;
1680 }
1681 return 0;
1682}
1683
1684static int tsi108_ether_remove(struct platform_device *pdev)
1685{
1686 struct net_device *dev = platform_get_drvdata(pdev);
1687 struct tsi108_prv_data *priv = netdev_priv(dev);
1688
1689 unregister_netdev(dev);
1690 tsi108_stop_ethernet(dev);
1691 platform_set_drvdata(pdev, NULL);
1692 iounmap(priv->regs);
1693 iounmap(priv->phyregs);
1694 free_netdev(dev);
1695
1696 return 0;
1697}
1698static void tsi108_ether_exit(void)
1699{
1700 platform_driver_unregister(&tsi_eth_driver);
1701}
1702
1703module_init(tsi108_ether_init);
1704module_exit(tsi108_ether_exit);
1705
1706MODULE_AUTHOR("Tundra Semiconductor Corporation");
1707MODULE_DESCRIPTION("Tsi108 Gigabit Ethernet driver");
1708MODULE_LICENSE("GPL");
diff --git a/drivers/net/tsi108_eth.h b/drivers/net/tsi108_eth.h
new file mode 100644
index 000000000000..77a769df228a
--- /dev/null
+++ b/drivers/net/tsi108_eth.h
@@ -0,0 +1,365 @@
1/*
2 * (C) Copyright 2005 Tundra Semiconductor Corp.
3 * Kong Lai, <kong.lai@tundra.com).
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 */
23
24/*
25 * net/tsi108_eth.h - definitions for Tsi108 GIGE network controller.
26 */
27
28#ifndef __TSI108_ETH_H
29#define __TSI108_ETH_H
30
31#include <linux/types.h>
32
33#define TSI_WRITE(offset, val) \
34 out_be32((data->regs + (offset)), val)
35
36#define TSI_READ(offset) \
37 in_be32((data->regs + (offset)))
38
39#define TSI_WRITE_PHY(offset, val) \
40 out_be32((data->phyregs + (offset)), val)
41
42#define TSI_READ_PHY(offset) \
43 in_be32((data->phyregs + (offset)))
44
45/*
46 * PHY Configuration Options
47 *
48 * NOTE: Enable set of definitions corresponding to your board type
49 */
50#define PHY_MV88E 1 /* Marvel 88Exxxx PHY */
51#define PHY_BCM54XX 2 /* Broardcom BCM54xx PHY */
52#define TSI108_PHY_TYPE PHY_MV88E
53
54/*
55 * TSI108 GIGE port registers
56 */
57
58#define TSI108_ETH_PORT_NUM 2
59#define TSI108_PBM_PORT 2
60#define TSI108_SDRAM_PORT 4
61
62#define TSI108_MAC_CFG1 (0x000)
63#define TSI108_MAC_CFG1_SOFTRST (1 << 31)
64#define TSI108_MAC_CFG1_LOOPBACK (1 << 8)
65#define TSI108_MAC_CFG1_RXEN (1 << 2)
66#define TSI108_MAC_CFG1_TXEN (1 << 0)
67
68#define TSI108_MAC_CFG2 (0x004)
69#define TSI108_MAC_CFG2_DFLT_PREAMBLE (7 << 12)
70#define TSI108_MAC_CFG2_IFACE_MASK (3 << 8)
71#define TSI108_MAC_CFG2_NOGIG (1 << 8)
72#define TSI108_MAC_CFG2_GIG (2 << 8)
73#define TSI108_MAC_CFG2_PADCRC (1 << 2)
74#define TSI108_MAC_CFG2_FULLDUPLEX (1 << 0)
75
76#define TSI108_MAC_MII_MGMT_CFG (0x020)
77#define TSI108_MAC_MII_MGMT_CLK (7 << 0)
78#define TSI108_MAC_MII_MGMT_RST (1 << 31)
79
80#define TSI108_MAC_MII_CMD (0x024)
81#define TSI108_MAC_MII_CMD_READ (1 << 0)
82
83#define TSI108_MAC_MII_ADDR (0x028)
84#define TSI108_MAC_MII_ADDR_REG 0
85#define TSI108_MAC_MII_ADDR_PHY 8
86
87#define TSI108_MAC_MII_DATAOUT (0x02c)
88#define TSI108_MAC_MII_DATAIN (0x030)
89
90#define TSI108_MAC_MII_IND (0x034)
91#define TSI108_MAC_MII_IND_NOTVALID (1 << 2)
92#define TSI108_MAC_MII_IND_SCANNING (1 << 1)
93#define TSI108_MAC_MII_IND_BUSY (1 << 0)
94
95#define TSI108_MAC_IFCTRL (0x038)
96#define TSI108_MAC_IFCTRL_PHYMODE (1 << 24)
97
98#define TSI108_MAC_ADDR1 (0x040)
99#define TSI108_MAC_ADDR2 (0x044)
100
101#define TSI108_STAT_RXBYTES (0x06c)
102#define TSI108_STAT_RXBYTES_CARRY (1 << 24)
103
104#define TSI108_STAT_RXPKTS (0x070)
105#define TSI108_STAT_RXPKTS_CARRY (1 << 18)
106
107#define TSI108_STAT_RXFCS (0x074)
108#define TSI108_STAT_RXFCS_CARRY (1 << 12)
109
110#define TSI108_STAT_RXMCAST (0x078)
111#define TSI108_STAT_RXMCAST_CARRY (1 << 18)
112
113#define TSI108_STAT_RXALIGN (0x08c)
114#define TSI108_STAT_RXALIGN_CARRY (1 << 12)
115
116#define TSI108_STAT_RXLENGTH (0x090)
117#define TSI108_STAT_RXLENGTH_CARRY (1 << 12)
118
119#define TSI108_STAT_RXRUNT (0x09c)
120#define TSI108_STAT_RXRUNT_CARRY (1 << 12)
121
122#define TSI108_STAT_RXJUMBO (0x0a0)
123#define TSI108_STAT_RXJUMBO_CARRY (1 << 12)
124
125#define TSI108_STAT_RXFRAG (0x0a4)
126#define TSI108_STAT_RXFRAG_CARRY (1 << 12)
127
128#define TSI108_STAT_RXJABBER (0x0a8)
129#define TSI108_STAT_RXJABBER_CARRY (1 << 12)
130
131#define TSI108_STAT_RXDROP (0x0ac)
132#define TSI108_STAT_RXDROP_CARRY (1 << 12)
133
134#define TSI108_STAT_TXBYTES (0x0b0)
135#define TSI108_STAT_TXBYTES_CARRY (1 << 24)
136
137#define TSI108_STAT_TXPKTS (0x0b4)
138#define TSI108_STAT_TXPKTS_CARRY (1 << 18)
139
140#define TSI108_STAT_TXEXDEF (0x0c8)
141#define TSI108_STAT_TXEXDEF_CARRY (1 << 12)
142
143#define TSI108_STAT_TXEXCOL (0x0d8)
144#define TSI108_STAT_TXEXCOL_CARRY (1 << 12)
145
146#define TSI108_STAT_TXTCOL (0x0dc)
147#define TSI108_STAT_TXTCOL_CARRY (1 << 13)
148
149#define TSI108_STAT_TXPAUSEDROP (0x0e4)
150#define TSI108_STAT_TXPAUSEDROP_CARRY (1 << 12)
151
152#define TSI108_STAT_CARRY1 (0x100)
153#define TSI108_STAT_CARRY1_RXBYTES (1 << 16)
154#define TSI108_STAT_CARRY1_RXPKTS (1 << 15)
155#define TSI108_STAT_CARRY1_RXFCS (1 << 14)
156#define TSI108_STAT_CARRY1_RXMCAST (1 << 13)
157#define TSI108_STAT_CARRY1_RXALIGN (1 << 8)
158#define TSI108_STAT_CARRY1_RXLENGTH (1 << 7)
159#define TSI108_STAT_CARRY1_RXRUNT (1 << 4)
160#define TSI108_STAT_CARRY1_RXJUMBO (1 << 3)
161#define TSI108_STAT_CARRY1_RXFRAG (1 << 2)
162#define TSI108_STAT_CARRY1_RXJABBER (1 << 1)
163#define TSI108_STAT_CARRY1_RXDROP (1 << 0)
164
165#define TSI108_STAT_CARRY2 (0x104)
166#define TSI108_STAT_CARRY2_TXBYTES (1 << 13)
167#define TSI108_STAT_CARRY2_TXPKTS (1 << 12)
168#define TSI108_STAT_CARRY2_TXEXDEF (1 << 7)
169#define TSI108_STAT_CARRY2_TXEXCOL (1 << 3)
170#define TSI108_STAT_CARRY2_TXTCOL (1 << 2)
171#define TSI108_STAT_CARRY2_TXPAUSE (1 << 0)
172
173#define TSI108_STAT_CARRYMASK1 (0x108)
174#define TSI108_STAT_CARRYMASK2 (0x10c)
175
176#define TSI108_EC_PORTCTRL (0x200)
177#define TSI108_EC_PORTCTRL_STATRST (1 << 31)
178#define TSI108_EC_PORTCTRL_STATEN (1 << 28)
179#define TSI108_EC_PORTCTRL_NOGIG (1 << 18)
180#define TSI108_EC_PORTCTRL_HALFDUPLEX (1 << 16)
181
182#define TSI108_EC_INTSTAT (0x204)
183#define TSI108_EC_INTMASK (0x208)
184
185#define TSI108_INT_ANY (1 << 31)
186#define TSI108_INT_SFN (1 << 30)
187#define TSI108_INT_RXIDLE (1 << 29)
188#define TSI108_INT_RXABORT (1 << 28)
189#define TSI108_INT_RXERROR (1 << 27)
190#define TSI108_INT_RXOVERRUN (1 << 26)
191#define TSI108_INT_RXTHRESH (1 << 25)
192#define TSI108_INT_RXWAIT (1 << 24)
193#define TSI108_INT_RXQUEUE0 (1 << 16)
194#define TSI108_INT_STATCARRY (1 << 15)
195#define TSI108_INT_TXIDLE (1 << 13)
196#define TSI108_INT_TXABORT (1 << 12)
197#define TSI108_INT_TXERROR (1 << 11)
198#define TSI108_INT_TXUNDERRUN (1 << 10)
199#define TSI108_INT_TXTHRESH (1 << 9)
200#define TSI108_INT_TXWAIT (1 << 8)
201#define TSI108_INT_TXQUEUE0 (1 << 0)
202
203#define TSI108_EC_TXCFG (0x220)
204#define TSI108_EC_TXCFG_RST (1 << 31)
205
206#define TSI108_EC_TXCTRL (0x224)
207#define TSI108_EC_TXCTRL_IDLEINT (1 << 31)
208#define TSI108_EC_TXCTRL_ABORT (1 << 30)
209#define TSI108_EC_TXCTRL_GO (1 << 15)
210#define TSI108_EC_TXCTRL_QUEUE0 (1 << 0)
211
212#define TSI108_EC_TXSTAT (0x228)
213#define TSI108_EC_TXSTAT_ACTIVE (1 << 15)
214#define TSI108_EC_TXSTAT_QUEUE0 (1 << 0)
215
216#define TSI108_EC_TXESTAT (0x22c)
217#define TSI108_EC_TXESTAT_Q0_ERR (1 << 24)
218#define TSI108_EC_TXESTAT_Q0_DESCINT (1 << 16)
219#define TSI108_EC_TXESTAT_Q0_EOF (1 << 8)
220#define TSI108_EC_TXESTAT_Q0_EOQ (1 << 0)
221
222#define TSI108_EC_TXERR (0x278)
223
224#define TSI108_EC_TXQ_CFG (0x280)
225#define TSI108_EC_TXQ_CFG_DESC_INT (1 << 20)
226#define TSI108_EC_TXQ_CFG_EOQ_OWN_INT (1 << 19)
227#define TSI108_EC_TXQ_CFG_WSWP (1 << 11)
228#define TSI108_EC_TXQ_CFG_BSWP (1 << 10)
229#define TSI108_EC_TXQ_CFG_SFNPORT 0
230
231#define TSI108_EC_TXQ_BUFCFG (0x284)
232#define TSI108_EC_TXQ_BUFCFG_BURST8 (0 << 8)
233#define TSI108_EC_TXQ_BUFCFG_BURST32 (1 << 8)
234#define TSI108_EC_TXQ_BUFCFG_BURST128 (2 << 8)
235#define TSI108_EC_TXQ_BUFCFG_BURST256 (3 << 8)
236#define TSI108_EC_TXQ_BUFCFG_WSWP (1 << 11)
237#define TSI108_EC_TXQ_BUFCFG_BSWP (1 << 10)
238#define TSI108_EC_TXQ_BUFCFG_SFNPORT 0
239
240#define TSI108_EC_TXQ_PTRLOW (0x288)
241
242#define TSI108_EC_TXQ_PTRHIGH (0x28c)
243#define TSI108_EC_TXQ_PTRHIGH_VALID (1 << 31)
244
245#define TSI108_EC_TXTHRESH (0x230)
246#define TSI108_EC_TXTHRESH_STARTFILL 0
247#define TSI108_EC_TXTHRESH_STOPFILL 16
248
249#define TSI108_EC_RXCFG (0x320)
250#define TSI108_EC_RXCFG_RST (1 << 31)
251
252#define TSI108_EC_RXSTAT (0x328)
253#define TSI108_EC_RXSTAT_ACTIVE (1 << 15)
254#define TSI108_EC_RXSTAT_QUEUE0 (1 << 0)
255
256#define TSI108_EC_RXESTAT (0x32c)
257#define TSI108_EC_RXESTAT_Q0_ERR (1 << 24)
258#define TSI108_EC_RXESTAT_Q0_DESCINT (1 << 16)
259#define TSI108_EC_RXESTAT_Q0_EOF (1 << 8)
260#define TSI108_EC_RXESTAT_Q0_EOQ (1 << 0)
261
262#define TSI108_EC_HASHADDR (0x360)
263#define TSI108_EC_HASHADDR_AUTOINC (1 << 31)
264#define TSI108_EC_HASHADDR_DO1STREAD (1 << 30)
265#define TSI108_EC_HASHADDR_UNICAST (0 << 4)
266#define TSI108_EC_HASHADDR_MCAST (1 << 4)
267
268#define TSI108_EC_HASHDATA (0x364)
269
270#define TSI108_EC_RXQ_PTRLOW (0x388)
271
272#define TSI108_EC_RXQ_PTRHIGH (0x38c)
273#define TSI108_EC_RXQ_PTRHIGH_VALID (1 << 31)
274
275/* Station Enable -- accept packets destined for us */
276#define TSI108_EC_RXCFG_SE (1 << 13)
277/* Unicast Frame Enable -- for packets not destined for us */
278#define TSI108_EC_RXCFG_UFE (1 << 12)
279/* Multicast Frame Enable */
280#define TSI108_EC_RXCFG_MFE (1 << 11)
281/* Broadcast Frame Enable */
282#define TSI108_EC_RXCFG_BFE (1 << 10)
283#define TSI108_EC_RXCFG_UC_HASH (1 << 9)
284#define TSI108_EC_RXCFG_MC_HASH (1 << 8)
285
286#define TSI108_EC_RXQ_CFG (0x380)
287#define TSI108_EC_RXQ_CFG_DESC_INT (1 << 20)
288#define TSI108_EC_RXQ_CFG_EOQ_OWN_INT (1 << 19)
289#define TSI108_EC_RXQ_CFG_WSWP (1 << 11)
290#define TSI108_EC_RXQ_CFG_BSWP (1 << 10)
291#define TSI108_EC_RXQ_CFG_SFNPORT 0
292
293#define TSI108_EC_RXQ_BUFCFG (0x384)
294#define TSI108_EC_RXQ_BUFCFG_BURST8 (0 << 8)
295#define TSI108_EC_RXQ_BUFCFG_BURST32 (1 << 8)
296#define TSI108_EC_RXQ_BUFCFG_BURST128 (2 << 8)
297#define TSI108_EC_RXQ_BUFCFG_BURST256 (3 << 8)
298#define TSI108_EC_RXQ_BUFCFG_WSWP (1 << 11)
299#define TSI108_EC_RXQ_BUFCFG_BSWP (1 << 10)
300#define TSI108_EC_RXQ_BUFCFG_SFNPORT 0
301
302#define TSI108_EC_RXCTRL (0x324)
303#define TSI108_EC_RXCTRL_ABORT (1 << 30)
304#define TSI108_EC_RXCTRL_GO (1 << 15)
305#define TSI108_EC_RXCTRL_QUEUE0 (1 << 0)
306
307#define TSI108_EC_RXERR (0x378)
308
309#define TSI108_TX_EOF (1 << 0) /* End of frame; last fragment of packet */
310#define TSI108_TX_SOF (1 << 1) /* Start of frame; first frag. of packet */
311#define TSI108_TX_VLAN (1 << 2) /* Per-frame VLAN: enables VLAN override */
312#define TSI108_TX_HUGE (1 << 3) /* Huge frame enable */
313#define TSI108_TX_PAD (1 << 4) /* Pad the packet if too short */
314#define TSI108_TX_CRC (1 << 5) /* Generate CRC for this packet */
315#define TSI108_TX_INT (1 << 14) /* Generate an IRQ after frag. processed */
316#define TSI108_TX_RETRY (0xf << 16) /* 4 bit field indicating num. of retries */
317#define TSI108_TX_COL (1 << 20) /* Set if a collision occured */
318#define TSI108_TX_LCOL (1 << 24) /* Set if a late collision occured */
319#define TSI108_TX_UNDER (1 << 25) /* Set if a FIFO underrun occured */
320#define TSI108_TX_RLIM (1 << 26) /* Set if the retry limit was reached */
321#define TSI108_TX_OK (1 << 30) /* Set if the frame TX was successful */
322#define TSI108_TX_OWN (1 << 31) /* Set if the device owns the descriptor */
323
324/* Note: the descriptor layouts assume big-endian byte order. */
325typedef struct {
326 u32 buf0;
327 u32 buf1; /* Base address of buffer */
328 u32 next0; /* Address of next descriptor, if any */
329 u32 next1;
330 u16 vlan; /* VLAN, if override enabled for this packet */
331 u16 len; /* Length of buffer in bytes */
332 u32 misc; /* See TSI108_TX_* above */
333 u32 reserved0; /*reserved0 and reserved1 are added to make the desc */
334 u32 reserved1; /* 32-byte aligned */
335} __attribute__ ((aligned(32))) tx_desc;
336
337#define TSI108_RX_EOF (1 << 0) /* End of frame; last fragment of packet */
338#define TSI108_RX_SOF (1 << 1) /* Start of frame; first frag. of packet */
339#define TSI108_RX_VLAN (1 << 2) /* Set on SOF if packet has a VLAN */
340#define TSI108_RX_FTYPE (1 << 3) /* Length/Type field is type, not length */
341#define TSI108_RX_RUNT (1 << 4)/* Packet is less than minimum size */
342#define TSI108_RX_HASH (1 << 7)/* Hash table match */
343#define TSI108_RX_BAD (1 << 8) /* Bad frame */
344#define TSI108_RX_OVER (1 << 9) /* FIFO overrun occured */
345#define TSI108_RX_TRUNC (1 << 11) /* Packet truncated due to excess length */
346#define TSI108_RX_CRC (1 << 12) /* Packet had a CRC error */
347#define TSI108_RX_INT (1 << 13) /* Generate an IRQ after frag. processed */
348#define TSI108_RX_OWN (1 << 15) /* Set if the device owns the descriptor */
349
350#define TSI108_RX_SKB_SIZE 1536 /* The RX skb length */
351
352typedef struct {
353 u32 buf0; /* Base address of buffer */
354 u32 buf1; /* Base address of buffer */
355 u32 next0; /* Address of next descriptor, if any */
356 u32 next1; /* Address of next descriptor, if any */
357 u16 vlan; /* VLAN of received packet, first frag only */
358 u16 len; /* Length of received fragment in bytes */
359 u16 blen; /* Length of buffer in bytes */
360 u16 misc; /* See TSI108_RX_* above */
361 u32 reserved0; /* reserved0 and reserved1 are added to make the desc */
362 u32 reserved1; /* 32-byte aligned */
363} __attribute__ ((aligned(32))) rx_desc;
364
365#endif /* __TSI108_ETH_H */
diff --git a/drivers/net/tulip/21142.c b/drivers/net/tulip/21142.c
index fa3a2bb105ad..942b839ccc5b 100644
--- a/drivers/net/tulip/21142.c
+++ b/drivers/net/tulip/21142.c
@@ -26,10 +26,11 @@ static u16 t21142_csr15[] = { 0x0008, 0x0006, 0x000E, 0x0008, 0x0008, };
26 26
27/* Handle the 21143 uniquely: do autoselect with NWay, not the EEPROM list 27/* Handle the 21143 uniquely: do autoselect with NWay, not the EEPROM list
28 of available transceivers. */ 28 of available transceivers. */
29void t21142_media_task(void *data) 29void t21142_media_task(struct work_struct *work)
30{ 30{
31 struct net_device *dev = data; 31 struct tulip_private *tp =
32 struct tulip_private *tp = netdev_priv(dev); 32 container_of(work, struct tulip_private, media_work);
33 struct net_device *dev = tp->dev;
33 void __iomem *ioaddr = tp->base_addr; 34 void __iomem *ioaddr = tp->base_addr;
34 int csr12 = ioread32(ioaddr + CSR12); 35 int csr12 = ioread32(ioaddr + CSR12);
35 int next_tick = 60*HZ; 36 int next_tick = 60*HZ;
diff --git a/drivers/net/tulip/de2104x.c b/drivers/net/tulip/de2104x.c
index f6b3a94e97bf..9d67f11422ec 100644
--- a/drivers/net/tulip/de2104x.c
+++ b/drivers/net/tulip/de2104x.c
@@ -1906,9 +1906,7 @@ fill_defaults:
1906 de->media[i].csr15 = t21041_csr15[i]; 1906 de->media[i].csr15 = t21041_csr15[i];
1907 } 1907 }
1908 1908
1909 de->ee_data = kmalloc(DE_EEPROM_SIZE, GFP_KERNEL); 1909 de->ee_data = kmemdup(&ee_data[0], DE_EEPROM_SIZE, GFP_KERNEL);
1910 if (de->ee_data)
1911 memcpy(de->ee_data, &ee_data[0], DE_EEPROM_SIZE);
1912 1910
1913 return; 1911 return;
1914 1912
diff --git a/drivers/net/tulip/de4x5.c b/drivers/net/tulip/de4x5.c
index 3f4b6408b755..4b3cd3d8b62a 100644
--- a/drivers/net/tulip/de4x5.c
+++ b/drivers/net/tulip/de4x5.c
@@ -473,9 +473,9 @@
473#include <asm/byteorder.h> 473#include <asm/byteorder.h>
474#include <asm/unaligned.h> 474#include <asm/unaligned.h>
475#include <asm/uaccess.h> 475#include <asm/uaccess.h>
476#ifdef CONFIG_PPC_MULTIPLATFORM 476#ifdef CONFIG_PPC_PMAC
477#include <asm/machdep.h> 477#include <asm/machdep.h>
478#endif /* CONFIG_PPC_MULTIPLATFORM */ 478#endif /* CONFIG_PPC_PMAC */
479 479
480#include "de4x5.h" 480#include "de4x5.h"
481 481
@@ -4151,7 +4151,7 @@ get_hw_addr(struct net_device *dev)
4151 /* If possible, try to fix a broken card - SMC only so far */ 4151 /* If possible, try to fix a broken card - SMC only so far */
4152 srom_repair(dev, broken); 4152 srom_repair(dev, broken);
4153 4153
4154#ifdef CONFIG_PPC_MULTIPLATFORM 4154#ifdef CONFIG_PPC_PMAC
4155 /* 4155 /*
4156 ** If the address starts with 00 a0, we have to bit-reverse 4156 ** If the address starts with 00 a0, we have to bit-reverse
4157 ** each byte of the address. 4157 ** each byte of the address.
@@ -4168,7 +4168,7 @@ get_hw_addr(struct net_device *dev)
4168 dev->dev_addr[i] = ((x & 0x55) << 1) + ((x & 0xaa) >> 1); 4168 dev->dev_addr[i] = ((x & 0x55) << 1) + ((x & 0xaa) >> 1);
4169 } 4169 }
4170 } 4170 }
4171#endif /* CONFIG_PPC_MULTIPLATFORM */ 4171#endif /* CONFIG_PPC_PMAC */
4172 4172
4173 /* Test for a bad enet address */ 4173 /* Test for a bad enet address */
4174 status = test_bad_enet(dev, status); 4174 status = test_bad_enet(dev, status);
diff --git a/drivers/net/tulip/dmfe.c b/drivers/net/tulip/dmfe.c
index 4dd8a0bae860..7f59a3d4fda2 100644
--- a/drivers/net/tulip/dmfe.c
+++ b/drivers/net/tulip/dmfe.c
@@ -187,7 +187,7 @@ struct rx_desc {
187struct dmfe_board_info { 187struct dmfe_board_info {
188 u32 chip_id; /* Chip vendor/Device ID */ 188 u32 chip_id; /* Chip vendor/Device ID */
189 u32 chip_revision; /* Chip revision */ 189 u32 chip_revision; /* Chip revision */
190 struct DEVICE *next_dev; /* next device */ 190 struct DEVICE *dev; /* net device */
191 struct pci_dev *pdev; /* PCI device */ 191 struct pci_dev *pdev; /* PCI device */
192 spinlock_t lock; 192 spinlock_t lock;
193 193
@@ -399,6 +399,8 @@ static int __devinit dmfe_init_one (struct pci_dev *pdev,
399 /* Init system & device */ 399 /* Init system & device */
400 db = netdev_priv(dev); 400 db = netdev_priv(dev);
401 401
402 db->dev = dev;
403
402 /* Allocate Tx/Rx descriptor memory */ 404 /* Allocate Tx/Rx descriptor memory */
403 db->desc_pool_ptr = pci_alloc_consistent(pdev, sizeof(struct tx_desc) * DESC_ALL_CNT + 0x20, &db->desc_pool_dma_ptr); 405 db->desc_pool_ptr = pci_alloc_consistent(pdev, sizeof(struct tx_desc) * DESC_ALL_CNT + 0x20, &db->desc_pool_dma_ptr);
404 db->buf_pool_ptr = pci_alloc_consistent(pdev, TX_BUF_ALLOC * TX_DESC_CNT + 4, &db->buf_pool_dma_ptr); 406 db->buf_pool_ptr = pci_alloc_consistent(pdev, TX_BUF_ALLOC * TX_DESC_CNT + 4, &db->buf_pool_dma_ptr);
@@ -426,6 +428,7 @@ static int __devinit dmfe_init_one (struct pci_dev *pdev,
426 dev->poll_controller = &poll_dmfe; 428 dev->poll_controller = &poll_dmfe;
427#endif 429#endif
428 dev->ethtool_ops = &netdev_ethtool_ops; 430 dev->ethtool_ops = &netdev_ethtool_ops;
431 netif_carrier_off(db->dev);
429 spin_lock_init(&db->lock); 432 spin_lock_init(&db->lock);
430 433
431 pci_read_config_dword(pdev, 0x50, &pci_pmr); 434 pci_read_config_dword(pdev, 0x50, &pci_pmr);
@@ -1050,6 +1053,7 @@ static void netdev_get_drvinfo(struct net_device *dev,
1050 1053
1051static const struct ethtool_ops netdev_ethtool_ops = { 1054static const struct ethtool_ops netdev_ethtool_ops = {
1052 .get_drvinfo = netdev_get_drvinfo, 1055 .get_drvinfo = netdev_get_drvinfo,
1056 .get_link = ethtool_op_get_link,
1053}; 1057};
1054 1058
1055/* 1059/*
@@ -1144,6 +1148,7 @@ static void dmfe_timer(unsigned long data)
1144 /* Link Failed */ 1148 /* Link Failed */
1145 DMFE_DBUG(0, "Link Failed", tmp_cr12); 1149 DMFE_DBUG(0, "Link Failed", tmp_cr12);
1146 db->link_failed = 1; 1150 db->link_failed = 1;
1151 netif_carrier_off(db->dev);
1147 1152
1148 /* For Force 10/100M Half/Full mode: Enable Auto-Nego mode */ 1153 /* For Force 10/100M Half/Full mode: Enable Auto-Nego mode */
1149 /* AUTO or force 1M Homerun/Longrun don't need */ 1154 /* AUTO or force 1M Homerun/Longrun don't need */
@@ -1166,6 +1171,8 @@ static void dmfe_timer(unsigned long data)
1166 if ( (db->media_mode & DMFE_AUTO) && 1171 if ( (db->media_mode & DMFE_AUTO) &&
1167 dmfe_sense_speed(db) ) 1172 dmfe_sense_speed(db) )
1168 db->link_failed = 1; 1173 db->link_failed = 1;
1174 else
1175 netif_carrier_on(db->dev);
1169 dmfe_process_mode(db); 1176 dmfe_process_mode(db);
1170 /* SHOW_MEDIA_TYPE(db->op_mode); */ 1177 /* SHOW_MEDIA_TYPE(db->op_mode); */
1171 } 1178 }
diff --git a/drivers/net/tulip/timer.c b/drivers/net/tulip/timer.c
index 066e5d6bcbd8..df326fe1cc8f 100644
--- a/drivers/net/tulip/timer.c
+++ b/drivers/net/tulip/timer.c
@@ -18,10 +18,11 @@
18#include "tulip.h" 18#include "tulip.h"
19 19
20 20
21void tulip_media_task(void *data) 21void tulip_media_task(struct work_struct *work)
22{ 22{
23 struct net_device *dev = data; 23 struct tulip_private *tp =
24 struct tulip_private *tp = netdev_priv(dev); 24 container_of(work, struct tulip_private, media_work);
25 struct net_device *dev = tp->dev;
25 void __iomem *ioaddr = tp->base_addr; 26 void __iomem *ioaddr = tp->base_addr;
26 u32 csr12 = ioread32(ioaddr + CSR12); 27 u32 csr12 = ioread32(ioaddr + CSR12);
27 int next_tick = 2*HZ; 28 int next_tick = 2*HZ;
diff --git a/drivers/net/tulip/tulip.h b/drivers/net/tulip/tulip.h
index ad107f45c7b1..25f25da76917 100644
--- a/drivers/net/tulip/tulip.h
+++ b/drivers/net/tulip/tulip.h
@@ -44,7 +44,7 @@ struct tulip_chip_table {
44 int valid_intrs; /* CSR7 interrupt enable settings */ 44 int valid_intrs; /* CSR7 interrupt enable settings */
45 int flags; 45 int flags;
46 void (*media_timer) (unsigned long); 46 void (*media_timer) (unsigned long);
47 void (*media_task) (void *); 47 work_func_t media_task;
48}; 48};
49 49
50 50
@@ -392,6 +392,7 @@ struct tulip_private {
392 int csr12_shadow; 392 int csr12_shadow;
393 int pad0; /* Used for 8-byte alignment */ 393 int pad0; /* Used for 8-byte alignment */
394 struct work_struct media_work; 394 struct work_struct media_work;
395 struct net_device *dev;
395}; 396};
396 397
397 398
@@ -406,7 +407,7 @@ struct eeprom_fixup {
406 407
407/* 21142.c */ 408/* 21142.c */
408extern u16 t21142_csr14[]; 409extern u16 t21142_csr14[];
409void t21142_media_task(void *data); 410void t21142_media_task(struct work_struct *work);
410void t21142_start_nway(struct net_device *dev); 411void t21142_start_nway(struct net_device *dev);
411void t21142_lnk_change(struct net_device *dev, int csr5); 412void t21142_lnk_change(struct net_device *dev, int csr5);
412 413
@@ -444,7 +445,7 @@ void pnic_lnk_change(struct net_device *dev, int csr5);
444void pnic_timer(unsigned long data); 445void pnic_timer(unsigned long data);
445 446
446/* timer.c */ 447/* timer.c */
447void tulip_media_task(void *data); 448void tulip_media_task(struct work_struct *work);
448void mxic_timer(unsigned long data); 449void mxic_timer(unsigned long data);
449void comet_timer(unsigned long data); 450void comet_timer(unsigned long data);
450 451
diff --git a/drivers/net/tulip/tulip_core.c b/drivers/net/tulip/tulip_core.c
index 0aee618f883c..5a35354aa523 100644
--- a/drivers/net/tulip/tulip_core.c
+++ b/drivers/net/tulip/tulip_core.c
@@ -1367,6 +1367,7 @@ static int __devinit tulip_init_one (struct pci_dev *pdev,
1367 * it is zeroed and aligned in alloc_etherdev 1367 * it is zeroed and aligned in alloc_etherdev
1368 */ 1368 */
1369 tp = netdev_priv(dev); 1369 tp = netdev_priv(dev);
1370 tp->dev = dev;
1370 1371
1371 tp->rx_ring = pci_alloc_consistent(pdev, 1372 tp->rx_ring = pci_alloc_consistent(pdev,
1372 sizeof(struct tulip_rx_desc) * RX_RING_SIZE + 1373 sizeof(struct tulip_rx_desc) * RX_RING_SIZE +
@@ -1389,7 +1390,7 @@ static int __devinit tulip_init_one (struct pci_dev *pdev,
1389 tp->timer.data = (unsigned long)dev; 1390 tp->timer.data = (unsigned long)dev;
1390 tp->timer.function = tulip_tbl[tp->chip_id].media_timer; 1391 tp->timer.function = tulip_tbl[tp->chip_id].media_timer;
1391 1392
1392 INIT_WORK(&tp->media_work, tulip_tbl[tp->chip_id].media_task, dev); 1393 INIT_WORK(&tp->media_work, tulip_tbl[tp->chip_id].media_task);
1393 1394
1394 dev->base_addr = (unsigned long)ioaddr; 1395 dev->base_addr = (unsigned long)ioaddr;
1395 1396
diff --git a/drivers/net/typhoon.c b/drivers/net/typhoon.c
index 3bf9e630404f..9781b16bb8b6 100644
--- a/drivers/net/typhoon.c
+++ b/drivers/net/typhoon.c
@@ -117,6 +117,7 @@ static const int multicast_filter_limit = 32;
117#include <linux/netdevice.h> 117#include <linux/netdevice.h>
118#include <linux/etherdevice.h> 118#include <linux/etherdevice.h>
119#include <linux/skbuff.h> 119#include <linux/skbuff.h>
120#include <linux/mm.h>
120#include <linux/init.h> 121#include <linux/init.h>
121#include <linux/delay.h> 122#include <linux/delay.h>
122#include <linux/ethtool.h> 123#include <linux/ethtool.h>
@@ -127,7 +128,6 @@ static const int multicast_filter_limit = 32;
127#include <asm/io.h> 128#include <asm/io.h>
128#include <asm/uaccess.h> 129#include <asm/uaccess.h>
129#include <linux/in6.h> 130#include <linux/in6.h>
130#include <asm/checksum.h>
131#include <linux/version.h> 131#include <linux/version.h>
132#include <linux/dma-mapping.h> 132#include <linux/dma-mapping.h>
133 133
diff --git a/drivers/net/ucc_geth.c b/drivers/net/ucc_geth.c
index b37888011067..1f05511fa390 100644
--- a/drivers/net/ucc_geth.c
+++ b/drivers/net/ucc_geth.c
@@ -30,7 +30,7 @@
30#include <linux/ethtool.h> 30#include <linux/ethtool.h>
31#include <linux/mii.h> 31#include <linux/mii.h>
32 32
33#include <asm/of_device.h> 33#include <asm/of_platform.h>
34#include <asm/uaccess.h> 34#include <asm/uaccess.h>
35#include <asm/irq.h> 35#include <asm/irq.h>
36#include <asm/io.h> 36#include <asm/io.h>
@@ -4301,12 +4301,12 @@ static int __init ucc_geth_init(void)
4301 memcpy(&(ugeth_info[i]), &ugeth_primary_info, 4301 memcpy(&(ugeth_info[i]), &ugeth_primary_info,
4302 sizeof(ugeth_primary_info)); 4302 sizeof(ugeth_primary_info));
4303 4303
4304 return of_register_driver(&ucc_geth_driver); 4304 return of_register_platform_driver(&ucc_geth_driver);
4305} 4305}
4306 4306
4307static void __exit ucc_geth_exit(void) 4307static void __exit ucc_geth_exit(void)
4308{ 4308{
4309 of_unregister_driver(&ucc_geth_driver); 4309 of_unregister_platform_driver(&ucc_geth_driver);
4310} 4310}
4311 4311
4312module_init(ucc_geth_init); 4312module_init(ucc_geth_init);
diff --git a/drivers/net/wan/Kconfig b/drivers/net/wan/Kconfig
index b5d0d7fb647a..d5ab9cf13257 100644
--- a/drivers/net/wan/Kconfig
+++ b/drivers/net/wan/Kconfig
@@ -57,44 +57,6 @@ config COSA
57 The driver will be compiled as a module: the 57 The driver will be compiled as a module: the
58 module will be called cosa. 58 module will be called cosa.
59 59
60config DSCC4
61 tristate "Etinc PCISYNC serial board support"
62 depends on WAN && PCI && m
63 help
64 Driver for Etinc PCISYNC boards based on the Infineon (ex. Siemens)
65 DSCC4 chipset.
66
67 This is supposed to work with the four port card. Take a look at
68 <http://www.cogenit.fr/dscc4/> for further information about the
69 driver.
70
71 To compile this driver as a module, choose M here: the
72 module will be called dscc4.
73
74config DSCC4_PCISYNC
75 bool "Etinc PCISYNC features"
76 depends on DSCC4
77 help
78 Due to Etinc's design choice for its PCISYNC cards, some operations
79 are only allowed on specific ports of the DSCC4. This option is the
80 only way for the driver to know that it shouldn't return a success
81 code for these operations.
82
83 Please say Y if your card is an Etinc's PCISYNC.
84
85config DSCC4_PCI_RST
86 bool "Hard reset support"
87 depends on DSCC4
88 help
89 Various DSCC4 bugs forbid any reliable software reset of the ASIC.
90 As a replacement, some vendors provide a way to assert the PCI #RST
91 pin of DSCC4 through the GPIO port of the card. If you choose Y,
92 the driver will make use of this feature before module removal
93 (i.e. rmmod). The feature is known to be available on Commtech's
94 cards. Contact your manufacturer for details.
95
96 Say Y if your card supports this feature.
97
98# 60#
99# Lan Media's board. Currently 1000, 1200, 5200, 5245 61# Lan Media's board. Currently 1000, 1200, 5200, 5245
100# 62#
@@ -323,6 +285,44 @@ config FARSYNC
323 To compile this driver as a module, choose M here: the 285 To compile this driver as a module, choose M here: the
324 module will be called farsync. 286 module will be called farsync.
325 287
288config DSCC4
289 tristate "Etinc PCISYNC serial board support"
290 depends on HDLC && PCI && m
291 help
292 Driver for Etinc PCISYNC boards based on the Infineon (ex. Siemens)
293 DSCC4 chipset.
294
295 This is supposed to work with the four port card. Take a look at
296 <http://www.cogenit.fr/dscc4/> for further information about the
297 driver.
298
299 To compile this driver as a module, choose M here: the
300 module will be called dscc4.
301
302config DSCC4_PCISYNC
303 bool "Etinc PCISYNC features"
304 depends on DSCC4
305 help
306 Due to Etinc's design choice for its PCISYNC cards, some operations
307 are only allowed on specific ports of the DSCC4. This option is the
308 only way for the driver to know that it shouldn't return a success
309 code for these operations.
310
311 Please say Y if your card is an Etinc's PCISYNC.
312
313config DSCC4_PCI_RST
314 bool "Hard reset support"
315 depends on DSCC4
316 help
317 Various DSCC4 bugs forbid any reliable software reset of the ASIC.
318 As a replacement, some vendors provide a way to assert the PCI #RST
319 pin of DSCC4 through the GPIO port of the card. If you choose Y,
320 the driver will make use of this feature before module removal
321 (i.e. rmmod). The feature is known to be available on Commtech's
322 cards. Contact your manufacturer for details.
323
324 Say Y if your card supports this feature.
325
326config DLCI 326config DLCI
327 tristate "Frame Relay DLCI support" 327 tristate "Frame Relay DLCI support"
328 depends on WAN 328 depends on WAN
diff --git a/drivers/net/wan/pc300_tty.c b/drivers/net/wan/pc300_tty.c
index 931cbdf6d791..b2a23aed4428 100644
--- a/drivers/net/wan/pc300_tty.c
+++ b/drivers/net/wan/pc300_tty.c
@@ -125,8 +125,8 @@ static int cpc_tty_write_room(struct tty_struct *tty);
125static int cpc_tty_chars_in_buffer(struct tty_struct *tty); 125static int cpc_tty_chars_in_buffer(struct tty_struct *tty);
126static void cpc_tty_flush_buffer(struct tty_struct *tty); 126static void cpc_tty_flush_buffer(struct tty_struct *tty);
127static void cpc_tty_hangup(struct tty_struct *tty); 127static void cpc_tty_hangup(struct tty_struct *tty);
128static void cpc_tty_rx_work(void *data); 128static void cpc_tty_rx_work(struct work_struct *work);
129static void cpc_tty_tx_work(void *data); 129static void cpc_tty_tx_work(struct work_struct *work);
130static int cpc_tty_send_to_card(pc300dev_t *dev,void *buf, int len); 130static int cpc_tty_send_to_card(pc300dev_t *dev,void *buf, int len);
131static void cpc_tty_trace(pc300dev_t *dev, char* buf, int len, char rxtx); 131static void cpc_tty_trace(pc300dev_t *dev, char* buf, int len, char rxtx);
132static void cpc_tty_signal_off(pc300dev_t *pc300dev, unsigned char); 132static void cpc_tty_signal_off(pc300dev_t *pc300dev, unsigned char);
@@ -261,8 +261,8 @@ void cpc_tty_init(pc300dev_t *pc300dev)
261 cpc_tty->tty_minor = port + CPC_TTY_MINOR_START; 261 cpc_tty->tty_minor = port + CPC_TTY_MINOR_START;
262 cpc_tty->pc300dev = pc300dev; 262 cpc_tty->pc300dev = pc300dev;
263 263
264 INIT_WORK(&cpc_tty->tty_tx_work, cpc_tty_tx_work, (void *)cpc_tty); 264 INIT_WORK(&cpc_tty->tty_tx_work, cpc_tty_tx_work);
265 INIT_WORK(&cpc_tty->tty_rx_work, cpc_tty_rx_work, (void *)port); 265 INIT_WORK(&cpc_tty->tty_rx_work, cpc_tty_rx_work);
266 266
267 cpc_tty->buf_rx.first = cpc_tty->buf_rx.last = NULL; 267 cpc_tty->buf_rx.first = cpc_tty->buf_rx.last = NULL;
268 268
@@ -659,21 +659,23 @@ static void cpc_tty_hangup(struct tty_struct *tty)
659 * o call the line disc. read 659 * o call the line disc. read
660 * o free memory 660 * o free memory
661 */ 661 */
662static void cpc_tty_rx_work(void * data) 662static void cpc_tty_rx_work(struct work_struct *work)
663{ 663{
664 st_cpc_tty_area *cpc_tty;
664 unsigned long port; 665 unsigned long port;
665 int i, j; 666 int i, j;
666 st_cpc_tty_area *cpc_tty;
667 volatile st_cpc_rx_buf *buf; 667 volatile st_cpc_rx_buf *buf;
668 char flags=0,flg_rx=1; 668 char flags=0,flg_rx=1;
669 struct tty_ldisc *ld; 669 struct tty_ldisc *ld;
670 670
671 if (cpc_tty_cnt == 0) return; 671 if (cpc_tty_cnt == 0) return;
672
673 672
674 for (i=0; (i < 4) && flg_rx ; i++) { 673 for (i=0; (i < 4) && flg_rx ; i++) {
675 flg_rx = 0; 674 flg_rx = 0;
676 port = (unsigned long)data; 675
676 cpc_tty = container_of(work, st_cpc_tty_area, tty_rx_work);
677 port = cpc_tty - cpc_tty_area;
678
677 for (j=0; j < CPC_TTY_NPORTS; j++) { 679 for (j=0; j < CPC_TTY_NPORTS; j++) {
678 cpc_tty = &cpc_tty_area[port]; 680 cpc_tty = &cpc_tty_area[port];
679 681
@@ -882,9 +884,10 @@ void cpc_tty_receive(pc300dev_t *pc300dev)
882 * o if need call line discipline wakeup 884 * o if need call line discipline wakeup
883 * o call wake_up_interruptible 885 * o call wake_up_interruptible
884 */ 886 */
885static void cpc_tty_tx_work(void *data) 887static void cpc_tty_tx_work(struct work_struct *work)
886{ 888{
887 st_cpc_tty_area *cpc_tty = (st_cpc_tty_area *) data; 889 st_cpc_tty_area *cpc_tty =
890 container_of(work, st_cpc_tty_area, tty_tx_work);
888 struct tty_struct *tty; 891 struct tty_struct *tty;
889 892
890 CPC_TTY_DBG("%s: cpc_tty_tx_work init\n",cpc_tty->name); 893 CPC_TTY_DBG("%s: cpc_tty_tx_work init\n",cpc_tty->name);
diff --git a/drivers/net/wd.c b/drivers/net/wd.c
index 41f1d6778849..7f38012b9c92 100644
--- a/drivers/net/wd.c
+++ b/drivers/net/wd.c
@@ -538,7 +538,7 @@ static void cleanup_card(struct net_device *dev)
538 iounmap(ei_status.mem); 538 iounmap(ei_status.mem);
539} 539}
540 540
541void 541void __exit
542cleanup_module(void) 542cleanup_module(void)
543{ 543{
544 int this_dev; 544 int this_dev;
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index efcdaf1c5f73..44a22701da97 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -49,6 +49,7 @@
49#include <asm/uaccess.h> 49#include <asm/uaccess.h>
50#include <net/ieee80211.h> 50#include <net/ieee80211.h>
51#include <linux/kthread.h> 51#include <linux/kthread.h>
52#include <linux/freezer.h>
52 53
53#include "airo.h" 54#include "airo.h"
54 55
diff --git a/drivers/net/wireless/airo_cs.c b/drivers/net/wireless/airo_cs.c
index ac9437d497f0..f12355398fe7 100644
--- a/drivers/net/wireless/airo_cs.c
+++ b/drivers/net/wireless/airo_cs.c
@@ -219,21 +219,6 @@ static int airo_config(struct pcmcia_device *link)
219 dev = link->priv; 219 dev = link->priv;
220 220
221 DEBUG(0, "airo_config(0x%p)\n", link); 221 DEBUG(0, "airo_config(0x%p)\n", link);
222
223 /*
224 This reads the card's CONFIG tuple to find its configuration
225 registers.
226 */
227 tuple.DesiredTuple = CISTPL_CONFIG;
228 tuple.Attributes = 0;
229 tuple.TupleData = buf;
230 tuple.TupleDataMax = sizeof(buf);
231 tuple.TupleOffset = 0;
232 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
233 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
234 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
235 link->conf.ConfigBase = parse.config.base;
236 link->conf.Present = parse.config.rmask[0];
237 222
238 /* 223 /*
239 In this loop, we scan the CIS for configuration table entries, 224 In this loop, we scan the CIS for configuration table entries,
@@ -247,6 +232,10 @@ static int airo_config(struct pcmcia_device *link)
247 these things without consulting the CIS, and most client drivers 232 these things without consulting the CIS, and most client drivers
248 will only use the CIS to fill in implementation-defined details. 233 will only use the CIS to fill in implementation-defined details.
249 */ 234 */
235 tuple.Attributes = 0;
236 tuple.TupleData = buf;
237 tuple.TupleDataMax = sizeof(buf);
238 tuple.TupleOffset = 0;
250 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 239 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
251 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 240 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
252 while (1) { 241 while (1) {
diff --git a/drivers/net/wireless/atmel.c b/drivers/net/wireless/atmel.c
index 0c07b8b7250d..10bcb48e80d0 100644
--- a/drivers/net/wireless/atmel.c
+++ b/drivers/net/wireless/atmel.c
@@ -595,7 +595,7 @@ static void atmel_join_bss(struct atmel_private *priv, int bss_index);
595static void atmel_smooth_qual(struct atmel_private *priv); 595static void atmel_smooth_qual(struct atmel_private *priv);
596static void atmel_writeAR(struct net_device *dev, u16 data); 596static void atmel_writeAR(struct net_device *dev, u16 data);
597static int probe_atmel_card(struct net_device *dev); 597static int probe_atmel_card(struct net_device *dev);
598static int reset_atmel_card(struct net_device *dev ); 598static int reset_atmel_card(struct net_device *dev);
599static void atmel_enter_state(struct atmel_private *priv, int new_state); 599static void atmel_enter_state(struct atmel_private *priv, int new_state);
600int atmel_open (struct net_device *dev); 600int atmel_open (struct net_device *dev);
601 601
@@ -784,11 +784,11 @@ static void tx_update_descriptor(struct atmel_private *priv, int is_bcast,
784 784
785static int start_tx(struct sk_buff *skb, struct net_device *dev) 785static int start_tx(struct sk_buff *skb, struct net_device *dev)
786{ 786{
787 static const u8 SNAP_RFC1024[6] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
787 struct atmel_private *priv = netdev_priv(dev); 788 struct atmel_private *priv = netdev_priv(dev);
788 struct ieee80211_hdr_4addr header; 789 struct ieee80211_hdr_4addr header;
789 unsigned long flags; 790 unsigned long flags;
790 u16 buff, frame_ctl, len = (ETH_ZLEN < skb->len) ? skb->len : ETH_ZLEN; 791 u16 buff, frame_ctl, len = (ETH_ZLEN < skb->len) ? skb->len : ETH_ZLEN;
791 u8 SNAP_RFC1024[6] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00};
792 792
793 if (priv->card && priv->present_callback && 793 if (priv->card && priv->present_callback &&
794 !(*priv->present_callback)(priv->card)) { 794 !(*priv->present_callback)(priv->card)) {
@@ -1193,7 +1193,7 @@ static irqreturn_t service_interrupt(int irq, void *dev_id)
1193 1193
1194 atmel_set_gcr(dev, GCR_ACKINT); /* acknowledge interrupt */ 1194 atmel_set_gcr(dev, GCR_ACKINT); /* acknowledge interrupt */
1195 1195
1196 for (i = 0; i < sizeof(irq_order)/sizeof(u8); i++) 1196 for (i = 0; i < ARRAY_SIZE(irq_order); i++)
1197 if (isr & irq_order[i]) 1197 if (isr & irq_order[i])
1198 break; 1198 break;
1199 1199
@@ -1345,10 +1345,10 @@ int atmel_open(struct net_device *dev)
1345 atmel_set_mib8(priv, Phy_Mib_Type, PHY_MIB_REG_DOMAIN_POS, priv->reg_domain); 1345 atmel_set_mib8(priv, Phy_Mib_Type, PHY_MIB_REG_DOMAIN_POS, priv->reg_domain);
1346 } else { 1346 } else {
1347 priv->reg_domain = atmel_get_mib8(priv, Phy_Mib_Type, PHY_MIB_REG_DOMAIN_POS); 1347 priv->reg_domain = atmel_get_mib8(priv, Phy_Mib_Type, PHY_MIB_REG_DOMAIN_POS);
1348 for (i = 0; i < sizeof(channel_table)/sizeof(channel_table[0]); i++) 1348 for (i = 0; i < ARRAY_SIZE(channel_table); i++)
1349 if (priv->reg_domain == channel_table[i].reg_domain) 1349 if (priv->reg_domain == channel_table[i].reg_domain)
1350 break; 1350 break;
1351 if (i == sizeof(channel_table)/sizeof(channel_table[0])) { 1351 if (i == ARRAY_SIZE(channel_table)) {
1352 priv->reg_domain = REG_DOMAIN_MKK1; 1352 priv->reg_domain = REG_DOMAIN_MKK1;
1353 printk(KERN_ALERT "%s: failed to get regulatory domain: assuming MKK1.\n", dev->name); 1353 printk(KERN_ALERT "%s: failed to get regulatory domain: assuming MKK1.\n", dev->name);
1354 } 1354 }
@@ -1393,7 +1393,7 @@ static int atmel_validate_channel(struct atmel_private *priv, int channel)
1393 else return suitable default channel */ 1393 else return suitable default channel */
1394 int i; 1394 int i;
1395 1395
1396 for (i = 0; i < sizeof(channel_table)/sizeof(channel_table[0]); i++) 1396 for (i = 0; i < ARRAY_SIZE(channel_table); i++)
1397 if (priv->reg_domain == channel_table[i].reg_domain) { 1397 if (priv->reg_domain == channel_table[i].reg_domain) {
1398 if (channel >= channel_table[i].min && 1398 if (channel >= channel_table[i].min &&
1399 channel <= channel_table[i].max) 1399 channel <= channel_table[i].max)
@@ -1437,7 +1437,7 @@ static int atmel_proc_output (char *buf, struct atmel_private *priv)
1437 } 1437 }
1438 1438
1439 r = "<unknown>"; 1439 r = "<unknown>";
1440 for (i = 0; i < sizeof(channel_table)/sizeof(channel_table[0]); i++) 1440 for (i = 0; i < ARRAY_SIZE(channel_table); i++)
1441 if (priv->reg_domain == channel_table[i].reg_domain) 1441 if (priv->reg_domain == channel_table[i].reg_domain)
1442 r = channel_table[i].name; 1442 r = channel_table[i].name;
1443 1443
@@ -1736,7 +1736,7 @@ static int atmel_set_encode(struct net_device *dev,
1736 /* Disable the key */ 1736 /* Disable the key */
1737 priv->wep_key_len[index] = 0; 1737 priv->wep_key_len[index] = 0;
1738 /* Check if the key is not marked as invalid */ 1738 /* Check if the key is not marked as invalid */
1739 if(!(dwrq->flags & IW_ENCODE_NOKEY)) { 1739 if (!(dwrq->flags & IW_ENCODE_NOKEY)) {
1740 /* Cleanup */ 1740 /* Cleanup */
1741 memset(priv->wep_keys[index], 0, 13); 1741 memset(priv->wep_keys[index], 0, 13);
1742 /* Copy the key in the driver */ 1742 /* Copy the key in the driver */
@@ -1907,7 +1907,7 @@ static int atmel_get_encodeext(struct net_device *dev,
1907 1907
1908 encoding->flags = idx + 1; 1908 encoding->flags = idx + 1;
1909 memset(ext, 0, sizeof(*ext)); 1909 memset(ext, 0, sizeof(*ext));
1910 1910
1911 if (!priv->wep_is_on) { 1911 if (!priv->wep_is_on) {
1912 ext->alg = IW_ENCODE_ALG_NONE; 1912 ext->alg = IW_ENCODE_ALG_NONE;
1913 ext->key_len = 0; 1913 ext->key_len = 0;
@@ -2343,6 +2343,14 @@ static int atmel_get_scan(struct net_device *dev,
2343 iwe.u.freq.e = 0; 2343 iwe.u.freq.e = 0;
2344 current_ev = iwe_stream_add_event(current_ev, extra + IW_SCAN_MAX_DATA, &iwe, IW_EV_FREQ_LEN); 2344 current_ev = iwe_stream_add_event(current_ev, extra + IW_SCAN_MAX_DATA, &iwe, IW_EV_FREQ_LEN);
2345 2345
2346 /* Add quality statistics */
2347 iwe.cmd = IWEVQUAL;
2348 iwe.u.qual.level = priv->BSSinfo[i].RSSI;
2349 iwe.u.qual.qual = iwe.u.qual.level;
2350 /* iwe.u.qual.noise = SOMETHING */
2351 current_ev = iwe_stream_add_event(current_ev, extra + IW_SCAN_MAX_DATA , &iwe, IW_EV_QUAL_LEN);
2352
2353
2346 iwe.cmd = SIOCGIWENCODE; 2354 iwe.cmd = SIOCGIWENCODE;
2347 if (priv->BSSinfo[i].UsingWEP) 2355 if (priv->BSSinfo[i].UsingWEP)
2348 iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; 2356 iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
@@ -2373,7 +2381,7 @@ static int atmel_get_range(struct net_device *dev,
2373 range->min_nwid = 0x0000; 2381 range->min_nwid = 0x0000;
2374 range->max_nwid = 0x0000; 2382 range->max_nwid = 0x0000;
2375 range->num_channels = 0; 2383 range->num_channels = 0;
2376 for (j = 0; j < sizeof(channel_table)/sizeof(channel_table[0]); j++) 2384 for (j = 0; j < ARRAY_SIZE(channel_table); j++)
2377 if (priv->reg_domain == channel_table[j].reg_domain) { 2385 if (priv->reg_domain == channel_table[j].reg_domain) {
2378 range->num_channels = channel_table[j].max - channel_table[j].min + 1; 2386 range->num_channels = channel_table[j].max - channel_table[j].min + 1;
2379 break; 2387 break;
@@ -2579,9 +2587,9 @@ static const struct iw_priv_args atmel_private_args[] = {
2579 2587
2580static const struct iw_handler_def atmel_handler_def = 2588static const struct iw_handler_def atmel_handler_def =
2581{ 2589{
2582 .num_standard = sizeof(atmel_handler)/sizeof(iw_handler), 2590 .num_standard = ARRAY_SIZE(atmel_handler),
2583 .num_private = sizeof(atmel_private_handler)/sizeof(iw_handler), 2591 .num_private = ARRAY_SIZE(atmel_private_handler),
2584 .num_private_args = sizeof(atmel_private_args)/sizeof(struct iw_priv_args), 2592 .num_private_args = ARRAY_SIZE(atmel_private_args),
2585 .standard = (iw_handler *) atmel_handler, 2593 .standard = (iw_handler *) atmel_handler,
2586 .private = (iw_handler *) atmel_private_handler, 2594 .private = (iw_handler *) atmel_private_handler,
2587 .private_args = (struct iw_priv_args *) atmel_private_args, 2595 .private_args = (struct iw_priv_args *) atmel_private_args,
@@ -2645,7 +2653,7 @@ static int atmel_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
2645 2653
2646 domain[REGDOMAINSZ] = 0; 2654 domain[REGDOMAINSZ] = 0;
2647 rc = -EINVAL; 2655 rc = -EINVAL;
2648 for (i = 0; i < sizeof(channel_table)/sizeof(channel_table[0]); i++) { 2656 for (i = 0; i < ARRAY_SIZE(channel_table); i++) {
2649 /* strcasecmp doesn't exist in the library */ 2657 /* strcasecmp doesn't exist in the library */
2650 char *a = channel_table[i].name; 2658 char *a = channel_table[i].name;
2651 char *b = domain; 2659 char *b = domain;
diff --git a/drivers/net/wireless/atmel_cs.c b/drivers/net/wireless/atmel_cs.c
index 785664090bb4..12617cd0b78e 100644
--- a/drivers/net/wireless/atmel_cs.c
+++ b/drivers/net/wireless/atmel_cs.c
@@ -5,12 +5,12 @@
5 Copyright 2000-2001 ATMEL Corporation. 5 Copyright 2000-2001 ATMEL Corporation.
6 Copyright 2003 Simon Kelley. 6 Copyright 2003 Simon Kelley.
7 7
8 This code was developed from version 2.1.1 of the Atmel drivers, 8 This code was developed from version 2.1.1 of the Atmel drivers,
9 released by Atmel corp. under the GPL in December 2002. It also 9 released by Atmel corp. under the GPL in December 2002. It also
10 includes code from the Linux aironet drivers (C) Benjamin Reed, 10 includes code from the Linux aironet drivers (C) Benjamin Reed,
11 and the Linux PCMCIA package, (C) David Hinds. 11 and the Linux PCMCIA package, (C) David Hinds.
12 12
13 For all queries about this code, please contact the current author, 13 For all queries about this code, please contact the current author,
14 Simon Kelley <simon@thekelleys.org.uk> and not Atmel Corporation. 14 Simon Kelley <simon@thekelleys.org.uk> and not Atmel Corporation.
15 15
16 This program is free software; you can redistribute it and/or modify 16 This program is free software; you can redistribute it and/or modify
@@ -87,7 +87,7 @@ MODULE_SUPPORTED_DEVICE("Atmel at76c50x PCMCIA cards");
87 event is received. The config() and release() entry points are 87 event is received. The config() and release() entry points are
88 used to configure or release a socket, in response to card 88 used to configure or release a socket, in response to card
89 insertion and ejection events. They are invoked from the atmel_cs 89 insertion and ejection events. They are invoked from the atmel_cs
90 event handler. 90 event handler.
91*/ 91*/
92 92
93static int atmel_config(struct pcmcia_device *link); 93static int atmel_config(struct pcmcia_device *link);
@@ -133,22 +133,22 @@ static void atmel_detach(struct pcmcia_device *p_dev);
133 device IO routines can use a flag like this to throttle IO to a 133 device IO routines can use a flag like this to throttle IO to a
134 card that is not ready to accept it. 134 card that is not ready to accept it.
135*/ 135*/
136 136
137typedef struct local_info_t { 137typedef struct local_info_t {
138 dev_node_t node; 138 dev_node_t node;
139 struct net_device *eth_dev; 139 struct net_device *eth_dev;
140} local_info_t; 140} local_info_t;
141 141
142/*====================================================================== 142/*======================================================================
143 143
144 atmel_attach() creates an "instance" of the driver, allocating 144 atmel_attach() creates an "instance" of the driver, allocating
145 local data structures for one device. The device is registered 145 local data structures for one device. The device is registered
146 with Card Services. 146 with Card Services.
147 147
148 The dev_link structure is initialized, but we don't actually 148 The dev_link structure is initialized, but we don't actually
149 configure the card at this point -- we wait until we receive a 149 configure the card at this point -- we wait until we receive a
150 card insertion event. 150 card insertion event.
151 151
152 ======================================================================*/ 152 ======================================================================*/
153 153
154static int atmel_probe(struct pcmcia_device *p_dev) 154static int atmel_probe(struct pcmcia_device *p_dev)
@@ -184,12 +184,12 @@ static int atmel_probe(struct pcmcia_device *p_dev)
184} /* atmel_attach */ 184} /* atmel_attach */
185 185
186/*====================================================================== 186/*======================================================================
187 187
188 This deletes a driver "instance". The device is de-registered 188 This deletes a driver "instance". The device is de-registered
189 with Card Services. If it has been released, all local data 189 with Card Services. If it has been released, all local data
190 structures are freed. Otherwise, the structures will be freed 190 structures are freed. Otherwise, the structures will be freed
191 when the device is released. 191 when the device is released.
192 192
193 ======================================================================*/ 193 ======================================================================*/
194 194
195static void atmel_detach(struct pcmcia_device *link) 195static void atmel_detach(struct pcmcia_device *link)
@@ -202,11 +202,11 @@ static void atmel_detach(struct pcmcia_device *link)
202} 202}
203 203
204/*====================================================================== 204/*======================================================================
205 205
206 atmel_config() is scheduled to run after a CARD_INSERTION event 206 atmel_config() is scheduled to run after a CARD_INSERTION event
207 is received, to configure the PCMCIA socket, and to make the 207 is received, to configure the PCMCIA socket, and to make the
208 device available to the system. 208 device available to the system.
209 209
210 ======================================================================*/ 210 ======================================================================*/
211 211
212#define CS_CHECK(fn, ret) \ 212#define CS_CHECK(fn, ret) \
@@ -237,28 +237,17 @@ static int atmel_config(struct pcmcia_device *link)
237 did = handle_to_dev(link).driver_data; 237 did = handle_to_dev(link).driver_data;
238 238
239 DEBUG(0, "atmel_config(0x%p)\n", link); 239 DEBUG(0, "atmel_config(0x%p)\n", link);
240 240
241 tuple.Attributes = 0; 241 tuple.Attributes = 0;
242 tuple.TupleData = buf; 242 tuple.TupleData = buf;
243 tuple.TupleDataMax = sizeof(buf); 243 tuple.TupleDataMax = sizeof(buf);
244 tuple.TupleOffset = 0; 244 tuple.TupleOffset = 0;
245
246 /*
247 This reads the card's CONFIG tuple to find its configuration
248 registers.
249 */
250 tuple.DesiredTuple = CISTPL_CONFIG;
251 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
252 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
253 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
254 link->conf.ConfigBase = parse.config.base;
255 link->conf.Present = parse.config.rmask[0];
256 245
257 /* 246 /*
258 In this loop, we scan the CIS for configuration table entries, 247 In this loop, we scan the CIS for configuration table entries,
259 each of which describes a valid card configuration, including 248 each of which describes a valid card configuration, including
260 voltage, IO window, memory window, and interrupt settings. 249 voltage, IO window, memory window, and interrupt settings.
261 250
262 We make no assumptions about the card to be configured: we use 251 We make no assumptions about the card to be configured: we use
263 just the information available in the CIS. In an ideal world, 252 just the information available in the CIS. In an ideal world,
264 this would work for any PCMCIA card, but it requires a complete 253 this would work for any PCMCIA card, but it requires a complete
@@ -274,17 +263,17 @@ static int atmel_config(struct pcmcia_device *link)
274 if (pcmcia_get_tuple_data(link, &tuple) != 0 || 263 if (pcmcia_get_tuple_data(link, &tuple) != 0 ||
275 pcmcia_parse_tuple(link, &tuple, &parse) != 0) 264 pcmcia_parse_tuple(link, &tuple, &parse) != 0)
276 goto next_entry; 265 goto next_entry;
277 266
278 if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg; 267 if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg;
279 if (cfg->index == 0) goto next_entry; 268 if (cfg->index == 0) goto next_entry;
280 link->conf.ConfigIndex = cfg->index; 269 link->conf.ConfigIndex = cfg->index;
281 270
282 /* Does this card need audio output? */ 271 /* Does this card need audio output? */
283 if (cfg->flags & CISTPL_CFTABLE_AUDIO) { 272 if (cfg->flags & CISTPL_CFTABLE_AUDIO) {
284 link->conf.Attributes |= CONF_ENABLE_SPKR; 273 link->conf.Attributes |= CONF_ENABLE_SPKR;
285 link->conf.Status = CCSR_AUDIO_ENA; 274 link->conf.Status = CCSR_AUDIO_ENA;
286 } 275 }
287 276
288 /* Use power settings for Vcc and Vpp if present */ 277 /* Use power settings for Vcc and Vpp if present */
289 /* Note that the CIS values need to be rescaled */ 278 /* Note that the CIS values need to be rescaled */
290 if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM)) 279 if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM))
@@ -293,11 +282,11 @@ static int atmel_config(struct pcmcia_device *link)
293 else if (dflt.vpp1.present & (1<<CISTPL_POWER_VNOM)) 282 else if (dflt.vpp1.present & (1<<CISTPL_POWER_VNOM))
294 link->conf.Vpp = 283 link->conf.Vpp =
295 dflt.vpp1.param[CISTPL_POWER_VNOM]/10000; 284 dflt.vpp1.param[CISTPL_POWER_VNOM]/10000;
296 285
297 /* Do we need to allocate an interrupt? */ 286 /* Do we need to allocate an interrupt? */
298 if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1) 287 if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1)
299 link->conf.Attributes |= CONF_ENABLE_IRQ; 288 link->conf.Attributes |= CONF_ENABLE_IRQ;
300 289
301 /* IO window settings */ 290 /* IO window settings */
302 link->io.NumPorts1 = link->io.NumPorts2 = 0; 291 link->io.NumPorts1 = link->io.NumPorts2 = 0;
303 if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { 292 if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) {
@@ -315,18 +304,18 @@ static int atmel_config(struct pcmcia_device *link)
315 link->io.NumPorts2 = io->win[1].len; 304 link->io.NumPorts2 = io->win[1].len;
316 } 305 }
317 } 306 }
318 307
319 /* This reserves IO space but doesn't actually enable it */ 308 /* This reserves IO space but doesn't actually enable it */
320 if (pcmcia_request_io(link, &link->io) != 0) 309 if (pcmcia_request_io(link, &link->io) != 0)
321 goto next_entry; 310 goto next_entry;
322 311
323 /* If we got this far, we're cool! */ 312 /* If we got this far, we're cool! */
324 break; 313 break;
325 314
326 next_entry: 315 next_entry:
327 CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); 316 CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple));
328 } 317 }
329 318
330 /* 319 /*
331 Allocate an interrupt line. Note that this does not assign a 320 Allocate an interrupt line. Note that this does not assign a
332 handler to the interrupt, unless the 'Handler' member of the 321 handler to the interrupt, unless the 'Handler' member of the
@@ -334,31 +323,31 @@ static int atmel_config(struct pcmcia_device *link)
334 */ 323 */
335 if (link->conf.Attributes & CONF_ENABLE_IRQ) 324 if (link->conf.Attributes & CONF_ENABLE_IRQ)
336 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 325 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
337 326
338 /* 327 /*
339 This actually configures the PCMCIA socket -- setting up 328 This actually configures the PCMCIA socket -- setting up
340 the I/O windows and the interrupt mapping, and putting the 329 the I/O windows and the interrupt mapping, and putting the
341 card and host interface into "Memory and IO" mode. 330 card and host interface into "Memory and IO" mode.
342 */ 331 */
343 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 332 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
344 333
345 if (link->irq.AssignedIRQ == 0) { 334 if (link->irq.AssignedIRQ == 0) {
346 printk(KERN_ALERT 335 printk(KERN_ALERT
347 "atmel: cannot assign IRQ: check that CONFIG_ISA is set in kernel config."); 336 "atmel: cannot assign IRQ: check that CONFIG_ISA is set in kernel config.");
348 goto cs_failed; 337 goto cs_failed;
349 } 338 }
350 339
351 ((local_info_t*)link->priv)->eth_dev = 340 ((local_info_t*)link->priv)->eth_dev =
352 init_atmel_card(link->irq.AssignedIRQ, 341 init_atmel_card(link->irq.AssignedIRQ,
353 link->io.BasePort1, 342 link->io.BasePort1,
354 did ? did->driver_info : ATMEL_FW_TYPE_NONE, 343 did ? did->driver_info : ATMEL_FW_TYPE_NONE,
355 &handle_to_dev(link), 344 &handle_to_dev(link),
356 card_present, 345 card_present,
357 link); 346 link);
358 if (!((local_info_t*)link->priv)->eth_dev) 347 if (!((local_info_t*)link->priv)->eth_dev)
359 goto cs_failed; 348 goto cs_failed;
360 349
361 350
362 /* 351 /*
363 At this point, the dev_node_t structure(s) need to be 352 At this point, the dev_node_t structure(s) need to be
364 initialized and arranged in a linked list at link->dev_node. 353 initialized and arranged in a linked list at link->dev_node.
@@ -376,11 +365,11 @@ static int atmel_config(struct pcmcia_device *link)
376} 365}
377 366
378/*====================================================================== 367/*======================================================================
379 368
380 After a card is removed, atmel_release() will unregister the 369 After a card is removed, atmel_release() will unregister the
381 device, and release the PCMCIA configuration. If the device is 370 device, and release the PCMCIA configuration. If the device is
382 still open, this will be postponed until it is closed. 371 still open, this will be postponed until it is closed.
383 372
384 ======================================================================*/ 373 ======================================================================*/
385 374
386static void atmel_release(struct pcmcia_device *link) 375static void atmel_release(struct pcmcia_device *link)
@@ -517,7 +506,7 @@ static void atmel_cs_cleanup(void)
517 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 506 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
518 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 507 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
519 IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 508 IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
520 POSSIBILITY OF SUCH DAMAGE. 509 POSSIBILITY OF SUCH DAMAGE.
521*/ 510*/
522 511
523module_init(atmel_cs_init); 512module_init(atmel_cs_init);
diff --git a/drivers/net/wireless/atmel_pci.c b/drivers/net/wireless/atmel_pci.c
index 3bfa791c323d..92f87fbe750f 100644
--- a/drivers/net/wireless/atmel_pci.c
+++ b/drivers/net/wireless/atmel_pci.c
@@ -53,18 +53,18 @@ static int __devinit atmel_pci_probe(struct pci_dev *pdev,
53 const struct pci_device_id *pent) 53 const struct pci_device_id *pent)
54{ 54{
55 struct net_device *dev; 55 struct net_device *dev;
56 56
57 if (pci_enable_device(pdev)) 57 if (pci_enable_device(pdev))
58 return -ENODEV; 58 return -ENODEV;
59 59
60 pci_set_master(pdev); 60 pci_set_master(pdev);
61 61
62 dev = init_atmel_card(pdev->irq, pdev->resource[1].start, 62 dev = init_atmel_card(pdev->irq, pdev->resource[1].start,
63 ATMEL_FW_TYPE_506, 63 ATMEL_FW_TYPE_506,
64 &pdev->dev, NULL, NULL); 64 &pdev->dev, NULL, NULL);
65 if (!dev) 65 if (!dev)
66 return -ENODEV; 66 return -ENODEV;
67 67
68 pci_set_drvdata(pdev, dev); 68 pci_set_drvdata(pdev, dev);
69 return 0; 69 return 0;
70} 70}
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx.h b/drivers/net/wireless/bcm43xx/bcm43xx.h
index d6a8bf09878e..8286678513b9 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx.h
+++ b/drivers/net/wireless/bcm43xx/bcm43xx.h
@@ -159,6 +159,7 @@
159 159
160/* Chipcommon registers. */ 160/* Chipcommon registers. */
161#define BCM43xx_CHIPCOMMON_CAPABILITIES 0x04 161#define BCM43xx_CHIPCOMMON_CAPABILITIES 0x04
162#define BCM43xx_CHIPCOMMON_CTL 0x28
162#define BCM43xx_CHIPCOMMON_PLLONDELAY 0xB0 163#define BCM43xx_CHIPCOMMON_PLLONDELAY 0xB0
163#define BCM43xx_CHIPCOMMON_FREFSELDELAY 0xB4 164#define BCM43xx_CHIPCOMMON_FREFSELDELAY 0xB4
164#define BCM43xx_CHIPCOMMON_SLOWCLKCTL 0xB8 165#define BCM43xx_CHIPCOMMON_SLOWCLKCTL 0xB8
@@ -172,6 +173,33 @@
172/* SBTOPCI2 values. */ 173/* SBTOPCI2 values. */
173#define BCM43xx_SBTOPCI2_PREFETCH 0x4 174#define BCM43xx_SBTOPCI2_PREFETCH 0x4
174#define BCM43xx_SBTOPCI2_BURST 0x8 175#define BCM43xx_SBTOPCI2_BURST 0x8
176#define BCM43xx_SBTOPCI2_MEMREAD_MULTI 0x20
177
178/* PCI-E core registers. */
179#define BCM43xx_PCIECORE_REG_ADDR 0x0130
180#define BCM43xx_PCIECORE_REG_DATA 0x0134
181#define BCM43xx_PCIECORE_MDIO_CTL 0x0128
182#define BCM43xx_PCIECORE_MDIO_DATA 0x012C
183
184/* PCI-E registers. */
185#define BCM43xx_PCIE_TLP_WORKAROUND 0x0004
186#define BCM43xx_PCIE_DLLP_LINKCTL 0x0100
187
188/* PCI-E MDIO bits. */
189#define BCM43xx_PCIE_MDIO_ST 0x40000000
190#define BCM43xx_PCIE_MDIO_WT 0x10000000
191#define BCM43xx_PCIE_MDIO_DEV 22
192#define BCM43xx_PCIE_MDIO_REG 18
193#define BCM43xx_PCIE_MDIO_TA 0x00020000
194#define BCM43xx_PCIE_MDIO_TC 0x0100
195
196/* MDIO devices. */
197#define BCM43xx_MDIO_SERDES_RX 0x1F
198
199/* SERDES RX registers. */
200#define BCM43xx_SERDES_RXTIMER 0x2
201#define BCM43xx_SERDES_CDR 0x6
202#define BCM43xx_SERDES_CDR_BW 0x7
175 203
176/* Chipcommon capabilities. */ 204/* Chipcommon capabilities. */
177#define BCM43xx_CAPABILITIES_PCTL 0x00040000 205#define BCM43xx_CAPABILITIES_PCTL 0x00040000
@@ -221,6 +249,7 @@
221#define BCM43xx_COREID_USB20_HOST 0x819 249#define BCM43xx_COREID_USB20_HOST 0x819
222#define BCM43xx_COREID_USB20_DEV 0x81a 250#define BCM43xx_COREID_USB20_DEV 0x81a
223#define BCM43xx_COREID_SDIO_HOST 0x81b 251#define BCM43xx_COREID_SDIO_HOST 0x81b
252#define BCM43xx_COREID_PCIE 0x820
224 253
225/* Core Information Registers */ 254/* Core Information Registers */
226#define BCM43xx_CIR_BASE 0xf00 255#define BCM43xx_CIR_BASE 0xf00
@@ -365,6 +394,9 @@
365#define BCM43xx_DEFAULT_SHORT_RETRY_LIMIT 7 394#define BCM43xx_DEFAULT_SHORT_RETRY_LIMIT 7
366#define BCM43xx_DEFAULT_LONG_RETRY_LIMIT 4 395#define BCM43xx_DEFAULT_LONG_RETRY_LIMIT 4
367 396
397/* FIXME: the next line is a guess as to what the maximum RSSI value might be */
398#define RX_RSSI_MAX 60
399
368/* Max size of a security key */ 400/* Max size of a security key */
369#define BCM43xx_SEC_KEYSIZE 16 401#define BCM43xx_SEC_KEYSIZE 16
370/* Security algorithms. */ 402/* Security algorithms. */
@@ -787,7 +819,7 @@ struct bcm43xx_private {
787 struct tasklet_struct isr_tasklet; 819 struct tasklet_struct isr_tasklet;
788 820
789 /* Periodic tasks */ 821 /* Periodic tasks */
790 struct work_struct periodic_work; 822 struct delayed_work periodic_work;
791 unsigned int periodic_state; 823 unsigned int periodic_state;
792 824
793 struct work_struct restart_work; 825 struct work_struct restart_work;
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_leds.c b/drivers/net/wireless/bcm43xx/bcm43xx_leds.c
index 2ddbec6bf15b..7d383a27b927 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_leds.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_leds.c
@@ -189,20 +189,24 @@ void bcm43xx_leds_update(struct bcm43xx_private *bcm, int activity)
189 case BCM43xx_LED_INACTIVE: 189 case BCM43xx_LED_INACTIVE:
190 continue; 190 continue;
191 case BCM43xx_LED_OFF: 191 case BCM43xx_LED_OFF:
192 case BCM43xx_LED_BCM4303_3:
192 break; 193 break;
193 case BCM43xx_LED_ON: 194 case BCM43xx_LED_ON:
194 turn_on = 1; 195 turn_on = 1;
195 break; 196 break;
196 case BCM43xx_LED_ACTIVITY: 197 case BCM43xx_LED_ACTIVITY:
198 case BCM43xx_LED_BCM4303_0:
197 turn_on = activity; 199 turn_on = activity;
198 break; 200 break;
199 case BCM43xx_LED_RADIO_ALL: 201 case BCM43xx_LED_RADIO_ALL:
200 turn_on = radio->enabled; 202 turn_on = radio->enabled;
201 break; 203 break;
202 case BCM43xx_LED_RADIO_A: 204 case BCM43xx_LED_RADIO_A:
205 case BCM43xx_LED_BCM4303_2:
203 turn_on = (radio->enabled && phy->type == BCM43xx_PHYTYPE_A); 206 turn_on = (radio->enabled && phy->type == BCM43xx_PHYTYPE_A);
204 break; 207 break;
205 case BCM43xx_LED_RADIO_B: 208 case BCM43xx_LED_RADIO_B:
209 case BCM43xx_LED_BCM4303_1:
206 turn_on = (radio->enabled && 210 turn_on = (radio->enabled &&
207 (phy->type == BCM43xx_PHYTYPE_B || 211 (phy->type == BCM43xx_PHYTYPE_B ||
208 phy->type == BCM43xx_PHYTYPE_G)); 212 phy->type == BCM43xx_PHYTYPE_G));
@@ -257,7 +261,8 @@ void bcm43xx_leds_update(struct bcm43xx_private *bcm, int activity)
257 continue; 261 continue;
258#endif /* CONFIG_BCM43XX_DEBUG */ 262#endif /* CONFIG_BCM43XX_DEBUG */
259 default: 263 default:
260 assert(0); 264 dprintkl(KERN_INFO PFX "Bad value in leds_update,"
265 " led->behaviour: 0x%x\n", led->behaviour);
261 }; 266 };
262 267
263 if (led->activelow) 268 if (led->activelow)
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_leds.h b/drivers/net/wireless/bcm43xx/bcm43xx_leds.h
index d3716cf3aebc..811e14a81198 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_leds.h
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_leds.h
@@ -46,6 +46,12 @@ enum { /* LED behaviour values */
46 BCM43xx_LED_TEST_BLINKSLOW, 46 BCM43xx_LED_TEST_BLINKSLOW,
47 BCM43xx_LED_TEST_BLINKMEDIUM, 47 BCM43xx_LED_TEST_BLINKMEDIUM,
48 BCM43xx_LED_TEST_BLINKFAST, 48 BCM43xx_LED_TEST_BLINKFAST,
49
50 /* Misc values for BCM4303 */
51 BCM43xx_LED_BCM4303_0 = 0x2B,
52 BCM43xx_LED_BCM4303_1 = 0x78,
53 BCM43xx_LED_BCM4303_2 = 0x2E,
54 BCM43xx_LED_BCM4303_3 = 0x19,
49}; 55};
50 56
51int bcm43xx_leds_init(struct bcm43xx_private *bcm); 57int bcm43xx_leds_init(struct bcm43xx_private *bcm);
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_main.c b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
index a94c6d8826f8..2ec2e5afce67 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_main.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
@@ -130,6 +130,10 @@ MODULE_PARM_DESC(fwpostfix, "Postfix for .fw files. Useful for debugging.");
130 { PCI_VENDOR_ID_BROADCOM, 0x4301, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 130 { PCI_VENDOR_ID_BROADCOM, 0x4301, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
131 /* Broadcom 4307 802.11b */ 131 /* Broadcom 4307 802.11b */
132 { PCI_VENDOR_ID_BROADCOM, 0x4307, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 132 { PCI_VENDOR_ID_BROADCOM, 0x4307, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
133 /* Broadcom 4311 802.11(a)/b/g */
134 { PCI_VENDOR_ID_BROADCOM, 0x4311, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
135 /* Broadcom 4312 802.11a/b/g */
136 { PCI_VENDOR_ID_BROADCOM, 0x4312, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
133 /* Broadcom 4318 802.11b/g */ 137 /* Broadcom 4318 802.11b/g */
134 { PCI_VENDOR_ID_BROADCOM, 0x4318, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 138 { PCI_VENDOR_ID_BROADCOM, 0x4318, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
135 /* Broadcom 4319 802.11a/b/g */ 139 /* Broadcom 4319 802.11a/b/g */
@@ -746,7 +750,7 @@ int bcm43xx_sprom_write(struct bcm43xx_private *bcm, const u16 *sprom)
746 if (err) 750 if (err)
747 goto err_ctlreg; 751 goto err_ctlreg;
748 spromctl |= 0x10; /* SPROM WRITE enable. */ 752 spromctl |= 0x10; /* SPROM WRITE enable. */
749 bcm43xx_pci_write_config32(bcm, BCM43xx_PCICFG_SPROMCTL, spromctl); 753 err = bcm43xx_pci_write_config32(bcm, BCM43xx_PCICFG_SPROMCTL, spromctl);
750 if (err) 754 if (err)
751 goto err_ctlreg; 755 goto err_ctlreg;
752 /* We must burn lots of CPU cycles here, but that does not 756 /* We must burn lots of CPU cycles here, but that does not
@@ -768,7 +772,7 @@ int bcm43xx_sprom_write(struct bcm43xx_private *bcm, const u16 *sprom)
768 mdelay(20); 772 mdelay(20);
769 } 773 }
770 spromctl &= ~0x10; /* SPROM WRITE enable. */ 774 spromctl &= ~0x10; /* SPROM WRITE enable. */
771 bcm43xx_pci_write_config32(bcm, BCM43xx_PCICFG_SPROMCTL, spromctl); 775 err = bcm43xx_pci_write_config32(bcm, BCM43xx_PCICFG_SPROMCTL, spromctl);
772 if (err) 776 if (err)
773 goto err_ctlreg; 777 goto err_ctlreg;
774 mdelay(500); 778 mdelay(500);
@@ -1463,6 +1467,23 @@ static void handle_irq_transmit_status(struct bcm43xx_private *bcm)
1463 } 1467 }
1464} 1468}
1465 1469
1470static void drain_txstatus_queue(struct bcm43xx_private *bcm)
1471{
1472 u32 dummy;
1473
1474 if (bcm->current_core->rev < 5)
1475 return;
1476 /* Read all entries from the microcode TXstatus FIFO
1477 * and throw them away.
1478 */
1479 while (1) {
1480 dummy = bcm43xx_read32(bcm, BCM43xx_MMIO_XMITSTAT_0);
1481 if (!dummy)
1482 break;
1483 dummy = bcm43xx_read32(bcm, BCM43xx_MMIO_XMITSTAT_1);
1484 }
1485}
1486
1466static void bcm43xx_generate_noise_sample(struct bcm43xx_private *bcm) 1487static void bcm43xx_generate_noise_sample(struct bcm43xx_private *bcm)
1467{ 1488{
1468 bcm43xx_shm_write16(bcm, BCM43xx_SHM_SHARED, 0x408, 0x7F7F); 1489 bcm43xx_shm_write16(bcm, BCM43xx_SHM_SHARED, 0x408, 0x7F7F);
@@ -2583,8 +2604,9 @@ static int bcm43xx_probe_cores(struct bcm43xx_private *bcm)
2583 /* fetch sb_id_hi from core information registers */ 2604 /* fetch sb_id_hi from core information registers */
2584 sb_id_hi = bcm43xx_read32(bcm, BCM43xx_CIR_SB_ID_HI); 2605 sb_id_hi = bcm43xx_read32(bcm, BCM43xx_CIR_SB_ID_HI);
2585 2606
2586 core_id = (sb_id_hi & 0xFFF0) >> 4; 2607 core_id = (sb_id_hi & 0x8FF0) >> 4;
2587 core_rev = (sb_id_hi & 0xF); 2608 core_rev = (sb_id_hi & 0x7000) >> 8;
2609 core_rev |= (sb_id_hi & 0xF);
2588 core_vendor = (sb_id_hi & 0xFFFF0000) >> 16; 2610 core_vendor = (sb_id_hi & 0xFFFF0000) >> 16;
2589 2611
2590 /* if present, chipcommon is always core 0; read the chipid from it */ 2612 /* if present, chipcommon is always core 0; read the chipid from it */
@@ -2662,14 +2684,10 @@ static int bcm43xx_probe_cores(struct bcm43xx_private *bcm)
2662 bcm->chip_id, bcm->chip_rev); 2684 bcm->chip_id, bcm->chip_rev);
2663 dprintk(KERN_INFO PFX "Number of cores: %d\n", core_count); 2685 dprintk(KERN_INFO PFX "Number of cores: %d\n", core_count);
2664 if (bcm->core_chipcommon.available) { 2686 if (bcm->core_chipcommon.available) {
2665 dprintk(KERN_INFO PFX "Core 0: ID 0x%x, rev 0x%x, vendor 0x%x, %s\n", 2687 dprintk(KERN_INFO PFX "Core 0: ID 0x%x, rev 0x%x, vendor 0x%x\n",
2666 core_id, core_rev, core_vendor, 2688 core_id, core_rev, core_vendor);
2667 bcm43xx_core_enabled(bcm) ? "enabled" : "disabled");
2668 }
2669
2670 if (bcm->core_chipcommon.available)
2671 current_core = 1; 2689 current_core = 1;
2672 else 2690 } else
2673 current_core = 0; 2691 current_core = 0;
2674 for ( ; current_core < core_count; current_core++) { 2692 for ( ; current_core < core_count; current_core++) {
2675 struct bcm43xx_coreinfo *core; 2693 struct bcm43xx_coreinfo *core;
@@ -2687,13 +2705,13 @@ static int bcm43xx_probe_cores(struct bcm43xx_private *bcm)
2687 core_rev = (sb_id_hi & 0xF); 2705 core_rev = (sb_id_hi & 0xF);
2688 core_vendor = (sb_id_hi & 0xFFFF0000) >> 16; 2706 core_vendor = (sb_id_hi & 0xFFFF0000) >> 16;
2689 2707
2690 dprintk(KERN_INFO PFX "Core %d: ID 0x%x, rev 0x%x, vendor 0x%x, %s\n", 2708 dprintk(KERN_INFO PFX "Core %d: ID 0x%x, rev 0x%x, vendor 0x%x\n",
2691 current_core, core_id, core_rev, core_vendor, 2709 current_core, core_id, core_rev, core_vendor);
2692 bcm43xx_core_enabled(bcm) ? "enabled" : "disabled" );
2693 2710
2694 core = NULL; 2711 core = NULL;
2695 switch (core_id) { 2712 switch (core_id) {
2696 case BCM43xx_COREID_PCI: 2713 case BCM43xx_COREID_PCI:
2714 case BCM43xx_COREID_PCIE:
2697 core = &bcm->core_pci; 2715 core = &bcm->core_pci;
2698 if (core->available) { 2716 if (core->available) {
2699 printk(KERN_WARNING PFX "Multiple PCI cores found.\n"); 2717 printk(KERN_WARNING PFX "Multiple PCI cores found.\n");
@@ -2732,12 +2750,12 @@ static int bcm43xx_probe_cores(struct bcm43xx_private *bcm)
2732 case 6: 2750 case 6:
2733 case 7: 2751 case 7:
2734 case 9: 2752 case 9:
2753 case 10:
2735 break; 2754 break;
2736 default: 2755 default:
2737 printk(KERN_ERR PFX "Error: Unsupported 80211 core revision %u\n", 2756 printk(KERN_WARNING PFX
2757 "Unsupported 80211 core revision %u\n",
2738 core_rev); 2758 core_rev);
2739 err = -ENODEV;
2740 goto out;
2741 } 2759 }
2742 bcm->nr_80211_available++; 2760 bcm->nr_80211_available++;
2743 core->priv = ext_80211; 2761 core->priv = ext_80211;
@@ -2851,16 +2869,11 @@ static int bcm43xx_wireless_core_init(struct bcm43xx_private *bcm,
2851 u32 sbimconfiglow; 2869 u32 sbimconfiglow;
2852 u8 limit; 2870 u8 limit;
2853 2871
2854 if (bcm->chip_rev < 5) { 2872 if (bcm->core_pci.rev <= 5 && bcm->core_pci.id != BCM43xx_COREID_PCIE) {
2855 sbimconfiglow = bcm43xx_read32(bcm, BCM43xx_CIR_SBIMCONFIGLOW); 2873 sbimconfiglow = bcm43xx_read32(bcm, BCM43xx_CIR_SBIMCONFIGLOW);
2856 sbimconfiglow &= ~ BCM43xx_SBIMCONFIGLOW_REQUEST_TOUT_MASK; 2874 sbimconfiglow &= ~ BCM43xx_SBIMCONFIGLOW_REQUEST_TOUT_MASK;
2857 sbimconfiglow &= ~ BCM43xx_SBIMCONFIGLOW_SERVICE_TOUT_MASK; 2875 sbimconfiglow &= ~ BCM43xx_SBIMCONFIGLOW_SERVICE_TOUT_MASK;
2858 if (bcm->bustype == BCM43xx_BUSTYPE_PCI) 2876 sbimconfiglow |= 0x32;
2859 sbimconfiglow |= 0x32;
2860 else if (bcm->bustype == BCM43xx_BUSTYPE_SB)
2861 sbimconfiglow |= 0x53;
2862 else
2863 assert(0);
2864 bcm43xx_write32(bcm, BCM43xx_CIR_SBIMCONFIGLOW, sbimconfiglow); 2877 bcm43xx_write32(bcm, BCM43xx_CIR_SBIMCONFIGLOW, sbimconfiglow);
2865 } 2878 }
2866 2879
@@ -2987,22 +3000,64 @@ static void bcm43xx_pcicore_broadcast_value(struct bcm43xx_private *bcm,
2987 3000
2988static int bcm43xx_pcicore_commit_settings(struct bcm43xx_private *bcm) 3001static int bcm43xx_pcicore_commit_settings(struct bcm43xx_private *bcm)
2989{ 3002{
2990 int err; 3003 int err = 0;
2991 struct bcm43xx_coreinfo *old_core;
2992 3004
2993 old_core = bcm->current_core; 3005 bcm->irq_savedstate = bcm43xx_interrupt_disable(bcm, BCM43xx_IRQ_ALL);
2994 err = bcm43xx_switch_core(bcm, &bcm->core_pci);
2995 if (err)
2996 goto out;
2997 3006
2998 bcm43xx_pcicore_broadcast_value(bcm, 0xfd8, 0x00000000); 3007 if (bcm->core_chipcommon.available) {
3008 err = bcm43xx_switch_core(bcm, &bcm->core_chipcommon);
3009 if (err)
3010 goto out;
3011
3012 bcm43xx_pcicore_broadcast_value(bcm, 0xfd8, 0x00000000);
3013
3014 /* this function is always called when a PCI core is mapped */
3015 err = bcm43xx_switch_core(bcm, &bcm->core_pci);
3016 if (err)
3017 goto out;
3018 } else
3019 bcm43xx_pcicore_broadcast_value(bcm, 0xfd8, 0x00000000);
3020
3021 bcm43xx_interrupt_enable(bcm, bcm->irq_savedstate);
2999 3022
3000 bcm43xx_switch_core(bcm, old_core);
3001 assert(err == 0);
3002out: 3023out:
3003 return err; 3024 return err;
3004} 3025}
3005 3026
3027static u32 bcm43xx_pcie_reg_read(struct bcm43xx_private *bcm, u32 address)
3028{
3029 bcm43xx_write32(bcm, BCM43xx_PCIECORE_REG_ADDR, address);
3030 return bcm43xx_read32(bcm, BCM43xx_PCIECORE_REG_DATA);
3031}
3032
3033static void bcm43xx_pcie_reg_write(struct bcm43xx_private *bcm, u32 address,
3034 u32 data)
3035{
3036 bcm43xx_write32(bcm, BCM43xx_PCIECORE_REG_ADDR, address);
3037 bcm43xx_write32(bcm, BCM43xx_PCIECORE_REG_DATA, data);
3038}
3039
3040static void bcm43xx_pcie_mdio_write(struct bcm43xx_private *bcm, u8 dev, u8 reg,
3041 u16 data)
3042{
3043 int i;
3044
3045 bcm43xx_write32(bcm, BCM43xx_PCIECORE_MDIO_CTL, 0x0082);
3046 bcm43xx_write32(bcm, BCM43xx_PCIECORE_MDIO_DATA, BCM43xx_PCIE_MDIO_ST |
3047 BCM43xx_PCIE_MDIO_WT | (dev << BCM43xx_PCIE_MDIO_DEV) |
3048 (reg << BCM43xx_PCIE_MDIO_REG) | BCM43xx_PCIE_MDIO_TA |
3049 data);
3050 udelay(10);
3051
3052 for (i = 0; i < 10; i++) {
3053 if (bcm43xx_read32(bcm, BCM43xx_PCIECORE_MDIO_CTL) &
3054 BCM43xx_PCIE_MDIO_TC)
3055 break;
3056 msleep(1);
3057 }
3058 bcm43xx_write32(bcm, BCM43xx_PCIECORE_MDIO_CTL, 0);
3059}
3060
3006/* Make an I/O Core usable. "core_mask" is the bitmask of the cores to enable. 3061/* Make an I/O Core usable. "core_mask" is the bitmask of the cores to enable.
3007 * To enable core 0, pass a core_mask of 1<<0 3062 * To enable core 0, pass a core_mask of 1<<0
3008 */ 3063 */
@@ -3022,7 +3077,8 @@ static int bcm43xx_setup_backplane_pci_connection(struct bcm43xx_private *bcm,
3022 if (err) 3077 if (err)
3023 goto out; 3078 goto out;
3024 3079
3025 if (bcm->core_pci.rev < 6) { 3080 if (bcm->current_core->rev < 6 ||
3081 bcm->current_core->id == BCM43xx_COREID_PCI) {
3026 value = bcm43xx_read32(bcm, BCM43xx_CIR_SBINTVEC); 3082 value = bcm43xx_read32(bcm, BCM43xx_CIR_SBINTVEC);
3027 value |= (1 << backplane_flag_nr); 3083 value |= (1 << backplane_flag_nr);
3028 bcm43xx_write32(bcm, BCM43xx_CIR_SBINTVEC, value); 3084 bcm43xx_write32(bcm, BCM43xx_CIR_SBINTVEC, value);
@@ -3040,21 +3096,46 @@ static int bcm43xx_setup_backplane_pci_connection(struct bcm43xx_private *bcm,
3040 } 3096 }
3041 } 3097 }
3042 3098
3043 value = bcm43xx_read32(bcm, BCM43xx_PCICORE_SBTOPCI2); 3099 if (bcm->current_core->id == BCM43xx_COREID_PCI) {
3044 value |= BCM43xx_SBTOPCI2_PREFETCH | BCM43xx_SBTOPCI2_BURST; 3100 value = bcm43xx_read32(bcm, BCM43xx_PCICORE_SBTOPCI2);
3045 bcm43xx_write32(bcm, BCM43xx_PCICORE_SBTOPCI2, value); 3101 value |= BCM43xx_SBTOPCI2_PREFETCH | BCM43xx_SBTOPCI2_BURST;
3046 3102 bcm43xx_write32(bcm, BCM43xx_PCICORE_SBTOPCI2, value);
3047 if (bcm->core_pci.rev < 5) { 3103
3048 value = bcm43xx_read32(bcm, BCM43xx_CIR_SBIMCONFIGLOW); 3104 if (bcm->current_core->rev < 5) {
3049 value |= (2 << BCM43xx_SBIMCONFIGLOW_SERVICE_TOUT_SHIFT) 3105 value = bcm43xx_read32(bcm, BCM43xx_CIR_SBIMCONFIGLOW);
3050 & BCM43xx_SBIMCONFIGLOW_SERVICE_TOUT_MASK; 3106 value |= (2 << BCM43xx_SBIMCONFIGLOW_SERVICE_TOUT_SHIFT)
3051 value |= (3 << BCM43xx_SBIMCONFIGLOW_REQUEST_TOUT_SHIFT) 3107 & BCM43xx_SBIMCONFIGLOW_SERVICE_TOUT_MASK;
3052 & BCM43xx_SBIMCONFIGLOW_REQUEST_TOUT_MASK; 3108 value |= (3 << BCM43xx_SBIMCONFIGLOW_REQUEST_TOUT_SHIFT)
3053 bcm43xx_write32(bcm, BCM43xx_CIR_SBIMCONFIGLOW, value); 3109 & BCM43xx_SBIMCONFIGLOW_REQUEST_TOUT_MASK;
3054 err = bcm43xx_pcicore_commit_settings(bcm); 3110 bcm43xx_write32(bcm, BCM43xx_CIR_SBIMCONFIGLOW, value);
3055 assert(err == 0); 3111 err = bcm43xx_pcicore_commit_settings(bcm);
3112 assert(err == 0);
3113 } else if (bcm->current_core->rev >= 11) {
3114 value = bcm43xx_read32(bcm, BCM43xx_PCICORE_SBTOPCI2);
3115 value |= BCM43xx_SBTOPCI2_MEMREAD_MULTI;
3116 bcm43xx_write32(bcm, BCM43xx_PCICORE_SBTOPCI2, value);
3117 }
3118 } else {
3119 if (bcm->current_core->rev == 0 || bcm->current_core->rev == 1) {
3120 value = bcm43xx_pcie_reg_read(bcm, BCM43xx_PCIE_TLP_WORKAROUND);
3121 value |= 0x8;
3122 bcm43xx_pcie_reg_write(bcm, BCM43xx_PCIE_TLP_WORKAROUND,
3123 value);
3124 }
3125 if (bcm->current_core->rev == 0) {
3126 bcm43xx_pcie_mdio_write(bcm, BCM43xx_MDIO_SERDES_RX,
3127 BCM43xx_SERDES_RXTIMER, 0x8128);
3128 bcm43xx_pcie_mdio_write(bcm, BCM43xx_MDIO_SERDES_RX,
3129 BCM43xx_SERDES_CDR, 0x0100);
3130 bcm43xx_pcie_mdio_write(bcm, BCM43xx_MDIO_SERDES_RX,
3131 BCM43xx_SERDES_CDR_BW, 0x1466);
3132 } else if (bcm->current_core->rev == 1) {
3133 value = bcm43xx_pcie_reg_read(bcm, BCM43xx_PCIE_DLLP_LINKCTL);
3134 value |= 0x40;
3135 bcm43xx_pcie_reg_write(bcm, BCM43xx_PCIE_DLLP_LINKCTL,
3136 value);
3137 }
3056 } 3138 }
3057
3058out_switch_back: 3139out_switch_back:
3059 err = bcm43xx_switch_core(bcm, old_core); 3140 err = bcm43xx_switch_core(bcm, old_core);
3060out: 3141out:
@@ -3123,57 +3204,43 @@ static void bcm43xx_periodic_every15sec(struct bcm43xx_private *bcm)
3123 3204
3124static void do_periodic_work(struct bcm43xx_private *bcm) 3205static void do_periodic_work(struct bcm43xx_private *bcm)
3125{ 3206{
3126 unsigned int state; 3207 if (bcm->periodic_state % 8 == 0)
3127
3128 state = bcm->periodic_state;
3129 if (state % 8 == 0)
3130 bcm43xx_periodic_every120sec(bcm); 3208 bcm43xx_periodic_every120sec(bcm);
3131 if (state % 4 == 0) 3209 if (bcm->periodic_state % 4 == 0)
3132 bcm43xx_periodic_every60sec(bcm); 3210 bcm43xx_periodic_every60sec(bcm);
3133 if (state % 2 == 0) 3211 if (bcm->periodic_state % 2 == 0)
3134 bcm43xx_periodic_every30sec(bcm); 3212 bcm43xx_periodic_every30sec(bcm);
3135 if (state % 1 == 0) 3213 bcm43xx_periodic_every15sec(bcm);
3136 bcm43xx_periodic_every15sec(bcm);
3137 bcm->periodic_state = state + 1;
3138 3214
3139 schedule_delayed_work(&bcm->periodic_work, HZ * 15); 3215 schedule_delayed_work(&bcm->periodic_work, HZ * 15);
3140} 3216}
3141 3217
3142/* Estimate a "Badness" value based on the periodic work 3218static void bcm43xx_periodic_work_handler(struct work_struct *work)
3143 * state-machine state. "Badness" is worse (bigger), if the
3144 * periodic work will take longer.
3145 */
3146static int estimate_periodic_work_badness(unsigned int state)
3147{ 3219{
3148 int badness = 0; 3220 struct bcm43xx_private *bcm =
3149 3221 container_of(work, struct bcm43xx_private, periodic_work.work);
3150 if (state % 8 == 0) /* every 120 sec */ 3222 struct net_device *net_dev = bcm->net_dev;
3151 badness += 10;
3152 if (state % 4 == 0) /* every 60 sec */
3153 badness += 5;
3154 if (state % 2 == 0) /* every 30 sec */
3155 badness += 1;
3156 if (state % 1 == 0) /* every 15 sec */
3157 badness += 1;
3158
3159#define BADNESS_LIMIT 4
3160 return badness;
3161}
3162
3163static void bcm43xx_periodic_work_handler(void *d)
3164{
3165 struct bcm43xx_private *bcm = d;
3166 unsigned long flags; 3223 unsigned long flags;
3167 u32 savedirqs = 0; 3224 u32 savedirqs = 0;
3168 int badness; 3225 unsigned long orig_trans_start = 0;
3169 3226
3170 mutex_lock(&bcm->mutex); 3227 mutex_lock(&bcm->mutex);
3171 badness = estimate_periodic_work_badness(bcm->periodic_state); 3228 if (unlikely(bcm->periodic_state % 4 == 0)) {
3172 if (badness > BADNESS_LIMIT) {
3173 /* Periodic work will take a long time, so we want it to 3229 /* Periodic work will take a long time, so we want it to
3174 * be preemtible. 3230 * be preemtible.
3175 */ 3231 */
3176 netif_tx_disable(bcm->net_dev); 3232
3233 netif_tx_lock_bh(net_dev);
3234 /* We must fake a started transmission here, as we are going to
3235 * disable TX. If we wouldn't fake a TX, it would be possible to
3236 * trigger the netdev watchdog, if the last real TX is already
3237 * some time on the past (slightly less than 5secs)
3238 */
3239 orig_trans_start = net_dev->trans_start;
3240 net_dev->trans_start = jiffies;
3241 netif_stop_queue(net_dev);
3242 netif_tx_unlock_bh(net_dev);
3243
3177 spin_lock_irqsave(&bcm->irq_lock, flags); 3244 spin_lock_irqsave(&bcm->irq_lock, flags);
3178 bcm43xx_mac_suspend(bcm); 3245 bcm43xx_mac_suspend(bcm);
3179 if (bcm43xx_using_pio(bcm)) 3246 if (bcm43xx_using_pio(bcm))
@@ -3190,7 +3257,7 @@ static void bcm43xx_periodic_work_handler(void *d)
3190 3257
3191 do_periodic_work(bcm); 3258 do_periodic_work(bcm);
3192 3259
3193 if (badness > BADNESS_LIMIT) { 3260 if (unlikely(bcm->periodic_state % 4 == 0)) {
3194 spin_lock_irqsave(&bcm->irq_lock, flags); 3261 spin_lock_irqsave(&bcm->irq_lock, flags);
3195 tasklet_enable(&bcm->isr_tasklet); 3262 tasklet_enable(&bcm->isr_tasklet);
3196 bcm43xx_interrupt_enable(bcm, savedirqs); 3263 bcm43xx_interrupt_enable(bcm, savedirqs);
@@ -3198,8 +3265,10 @@ static void bcm43xx_periodic_work_handler(void *d)
3198 bcm43xx_pio_thaw_txqueues(bcm); 3265 bcm43xx_pio_thaw_txqueues(bcm);
3199 bcm43xx_mac_enable(bcm); 3266 bcm43xx_mac_enable(bcm);
3200 netif_wake_queue(bcm->net_dev); 3267 netif_wake_queue(bcm->net_dev);
3268 net_dev->trans_start = orig_trans_start;
3201 } 3269 }
3202 mmiowb(); 3270 mmiowb();
3271 bcm->periodic_state++;
3203 spin_unlock_irqrestore(&bcm->irq_lock, flags); 3272 spin_unlock_irqrestore(&bcm->irq_lock, flags);
3204 mutex_unlock(&bcm->mutex); 3273 mutex_unlock(&bcm->mutex);
3205} 3274}
@@ -3211,11 +3280,11 @@ void bcm43xx_periodic_tasks_delete(struct bcm43xx_private *bcm)
3211 3280
3212void bcm43xx_periodic_tasks_setup(struct bcm43xx_private *bcm) 3281void bcm43xx_periodic_tasks_setup(struct bcm43xx_private *bcm)
3213{ 3282{
3214 struct work_struct *work = &(bcm->periodic_work); 3283 struct delayed_work *work = &bcm->periodic_work;
3215 3284
3216 assert(bcm43xx_status(bcm) == BCM43xx_STAT_INITIALIZED); 3285 assert(bcm43xx_status(bcm) == BCM43xx_STAT_INITIALIZED);
3217 INIT_WORK(work, bcm43xx_periodic_work_handler, bcm); 3286 INIT_DELAYED_WORK(work, bcm43xx_periodic_work_handler);
3218 schedule_work(work); 3287 schedule_delayed_work(work, 0);
3219} 3288}
3220 3289
3221static void bcm43xx_security_init(struct bcm43xx_private *bcm) 3290static void bcm43xx_security_init(struct bcm43xx_private *bcm)
@@ -3518,6 +3587,7 @@ int bcm43xx_select_wireless_core(struct bcm43xx_private *bcm,
3518 bcm43xx_macfilter_clear(bcm, BCM43xx_MACFILTER_ASSOC); 3587 bcm43xx_macfilter_clear(bcm, BCM43xx_MACFILTER_ASSOC);
3519 bcm43xx_macfilter_set(bcm, BCM43xx_MACFILTER_SELF, (u8 *)(bcm->net_dev->dev_addr)); 3588 bcm43xx_macfilter_set(bcm, BCM43xx_MACFILTER_SELF, (u8 *)(bcm->net_dev->dev_addr));
3520 bcm43xx_security_init(bcm); 3589 bcm43xx_security_init(bcm);
3590 drain_txstatus_queue(bcm);
3521 ieee80211softmac_start(bcm->net_dev); 3591 ieee80211softmac_start(bcm->net_dev);
3522 3592
3523 /* Let's go! Be careful after enabling the IRQs. 3593 /* Let's go! Be careful after enabling the IRQs.
@@ -3566,7 +3636,7 @@ static int bcm43xx_init_board(struct bcm43xx_private *bcm)
3566 bcm43xx_periodic_tasks_setup(bcm); 3636 bcm43xx_periodic_tasks_setup(bcm);
3567 3637
3568 /*FIXME: This should be handled by softmac instead. */ 3638 /*FIXME: This should be handled by softmac instead. */
3569 schedule_work(&bcm->softmac->associnfo.work); 3639 schedule_delayed_work(&bcm->softmac->associnfo.work, 0);
3570 3640
3571out: 3641out:
3572 mutex_unlock(&(bcm)->mutex); 3642 mutex_unlock(&(bcm)->mutex);
@@ -3644,7 +3714,7 @@ static int bcm43xx_read_phyinfo(struct bcm43xx_private *bcm)
3644 bcm->ieee->freq_band = IEEE80211_24GHZ_BAND; 3714 bcm->ieee->freq_band = IEEE80211_24GHZ_BAND;
3645 break; 3715 break;
3646 case BCM43xx_PHYTYPE_G: 3716 case BCM43xx_PHYTYPE_G:
3647 if (phy_rev > 7) 3717 if (phy_rev > 8)
3648 phy_rev_ok = 0; 3718 phy_rev_ok = 0;
3649 bcm->ieee->modulation = IEEE80211_OFDM_MODULATION | 3719 bcm->ieee->modulation = IEEE80211_OFDM_MODULATION |
3650 IEEE80211_CCK_MODULATION; 3720 IEEE80211_CCK_MODULATION;
@@ -3656,6 +3726,8 @@ static int bcm43xx_read_phyinfo(struct bcm43xx_private *bcm)
3656 phy_type); 3726 phy_type);
3657 return -ENODEV; 3727 return -ENODEV;
3658 }; 3728 };
3729 bcm->ieee->perfect_rssi = RX_RSSI_MAX;
3730 bcm->ieee->worst_rssi = 0;
3659 if (!phy_rev_ok) { 3731 if (!phy_rev_ok) {
3660 printk(KERN_WARNING PFX "Invalid PHY Revision %x\n", 3732 printk(KERN_WARNING PFX "Invalid PHY Revision %x\n",
3661 phy_rev); 3733 phy_rev);
@@ -3942,11 +4014,6 @@ static int bcm43xx_ieee80211_hard_start_xmit(struct ieee80211_txb *txb,
3942 return NETDEV_TX_OK; 4014 return NETDEV_TX_OK;
3943} 4015}
3944 4016
3945static struct net_device_stats * bcm43xx_net_get_stats(struct net_device *net_dev)
3946{
3947 return &(bcm43xx_priv(net_dev)->ieee->stats);
3948}
3949
3950static void bcm43xx_net_tx_timeout(struct net_device *net_dev) 4017static void bcm43xx_net_tx_timeout(struct net_device *net_dev)
3951{ 4018{
3952 struct bcm43xx_private *bcm = bcm43xx_priv(net_dev); 4019 struct bcm43xx_private *bcm = bcm43xx_priv(net_dev);
@@ -4060,7 +4127,6 @@ static int __devinit bcm43xx_init_one(struct pci_dev *pdev,
4060 4127
4061 net_dev->open = bcm43xx_net_open; 4128 net_dev->open = bcm43xx_net_open;
4062 net_dev->stop = bcm43xx_net_stop; 4129 net_dev->stop = bcm43xx_net_stop;
4063 net_dev->get_stats = bcm43xx_net_get_stats;
4064 net_dev->tx_timeout = bcm43xx_net_tx_timeout; 4130 net_dev->tx_timeout = bcm43xx_net_tx_timeout;
4065#ifdef CONFIG_NET_POLL_CONTROLLER 4131#ifdef CONFIG_NET_POLL_CONTROLLER
4066 net_dev->poll_controller = bcm43xx_net_poll_controller; 4132 net_dev->poll_controller = bcm43xx_net_poll_controller;
@@ -4117,9 +4183,10 @@ static void __devexit bcm43xx_remove_one(struct pci_dev *pdev)
4117/* Hard-reset the chip. Do not call this directly. 4183/* Hard-reset the chip. Do not call this directly.
4118 * Use bcm43xx_controller_restart() 4184 * Use bcm43xx_controller_restart()
4119 */ 4185 */
4120static void bcm43xx_chip_reset(void *_bcm) 4186static void bcm43xx_chip_reset(struct work_struct *work)
4121{ 4187{
4122 struct bcm43xx_private *bcm = _bcm; 4188 struct bcm43xx_private *bcm =
4189 container_of(work, struct bcm43xx_private, restart_work);
4123 struct bcm43xx_phyinfo *phy; 4190 struct bcm43xx_phyinfo *phy;
4124 int err = -ENODEV; 4191 int err = -ENODEV;
4125 4192
@@ -4146,7 +4213,7 @@ void bcm43xx_controller_restart(struct bcm43xx_private *bcm, const char *reason)
4146 if (bcm43xx_status(bcm) != BCM43xx_STAT_INITIALIZED) 4213 if (bcm43xx_status(bcm) != BCM43xx_STAT_INITIALIZED)
4147 return; 4214 return;
4148 printk(KERN_ERR PFX "Controller RESET (%s) ...\n", reason); 4215 printk(KERN_ERR PFX "Controller RESET (%s) ...\n", reason);
4149 INIT_WORK(&bcm->restart_work, bcm43xx_chip_reset, bcm); 4216 INIT_WORK(&bcm->restart_work, bcm43xx_chip_reset);
4150 schedule_work(&bcm->restart_work); 4217 schedule_work(&bcm->restart_work);
4151} 4218}
4152 4219
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_power.c b/drivers/net/wireless/bcm43xx/bcm43xx_power.c
index 6569da3a7a39..7e774f410953 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_power.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_power.c
@@ -153,8 +153,6 @@ int bcm43xx_pctl_init(struct bcm43xx_private *bcm)
153 int err, maxfreq; 153 int err, maxfreq;
154 struct bcm43xx_coreinfo *old_core; 154 struct bcm43xx_coreinfo *old_core;
155 155
156 if (!(bcm->chipcommon_capabilities & BCM43xx_CAPABILITIES_PCTL))
157 return 0;
158 old_core = bcm->current_core; 156 old_core = bcm->current_core;
159 err = bcm43xx_switch_core(bcm, &bcm->core_chipcommon); 157 err = bcm43xx_switch_core(bcm, &bcm->core_chipcommon);
160 if (err == -ENODEV) 158 if (err == -ENODEV)
@@ -162,11 +160,27 @@ int bcm43xx_pctl_init(struct bcm43xx_private *bcm)
162 if (err) 160 if (err)
163 goto out; 161 goto out;
164 162
165 maxfreq = bcm43xx_pctl_clockfreqlimit(bcm, 1); 163 if (bcm->chip_id == 0x4321) {
166 bcm43xx_write32(bcm, BCM43xx_CHIPCOMMON_PLLONDELAY, 164 if (bcm->chip_rev == 0)
167 (maxfreq * 150 + 999999) / 1000000); 165 bcm43xx_write32(bcm, BCM43xx_CHIPCOMMON_CTL, 0x03A4);
168 bcm43xx_write32(bcm, BCM43xx_CHIPCOMMON_FREFSELDELAY, 166 if (bcm->chip_rev == 1)
169 (maxfreq * 15 + 999999) / 1000000); 167 bcm43xx_write32(bcm, BCM43xx_CHIPCOMMON_CTL, 0x00A4);
168 }
169
170 if (bcm->chipcommon_capabilities & BCM43xx_CAPABILITIES_PCTL) {
171 if (bcm->current_core->rev >= 10) {
172 /* Set Idle Power clock rate to 1Mhz */
173 bcm43xx_write32(bcm, BCM43xx_CHIPCOMMON_SYSCLKCTL,
174 (bcm43xx_read32(bcm, BCM43xx_CHIPCOMMON_SYSCLKCTL)
175 & 0x0000FFFF) | 0x40000);
176 } else {
177 maxfreq = bcm43xx_pctl_clockfreqlimit(bcm, 1);
178 bcm43xx_write32(bcm, BCM43xx_CHIPCOMMON_PLLONDELAY,
179 (maxfreq * 150 + 999999) / 1000000);
180 bcm43xx_write32(bcm, BCM43xx_CHIPCOMMON_FREFSELDELAY,
181 (maxfreq * 15 + 999999) / 1000000);
182 }
183 }
170 184
171 err = bcm43xx_switch_core(bcm, old_core); 185 err = bcm43xx_switch_core(bcm, old_core);
172 assert(err == 0); 186 assert(err == 0);
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_wx.c b/drivers/net/wireless/bcm43xx/bcm43xx_wx.c
index d27016f8c736..a659442b9c15 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_wx.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_wx.c
@@ -47,9 +47,6 @@
47#define BCM43xx_WX_VERSION 18 47#define BCM43xx_WX_VERSION 18
48 48
49#define MAX_WX_STRING 80 49#define MAX_WX_STRING 80
50/* FIXME: the next line is a guess as to what the maximum RSSI value might be */
51#define RX_RSSI_MAX 60
52
53 50
54static int bcm43xx_wx_get_name(struct net_device *net_dev, 51static int bcm43xx_wx_get_name(struct net_device *net_dev,
55 struct iw_request_info *info, 52 struct iw_request_info *info,
@@ -693,6 +690,7 @@ static int bcm43xx_wx_set_swencryption(struct net_device *net_dev,
693 bcm->ieee->host_encrypt = !!on; 690 bcm->ieee->host_encrypt = !!on;
694 bcm->ieee->host_decrypt = !!on; 691 bcm->ieee->host_decrypt = !!on;
695 bcm->ieee->host_build_iv = !on; 692 bcm->ieee->host_build_iv = !on;
693 bcm->ieee->host_strip_iv_icv = !on;
696 spin_unlock_irqrestore(&bcm->irq_lock, flags); 694 spin_unlock_irqrestore(&bcm->irq_lock, flags);
697 mutex_unlock(&bcm->mutex); 695 mutex_unlock(&bcm->mutex);
698 696
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_xmit.c b/drivers/net/wireless/bcm43xx/bcm43xx_xmit.c
index 0159e4e93201..3e2462671690 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_xmit.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_xmit.c
@@ -544,24 +544,6 @@ int bcm43xx_rx(struct bcm43xx_private *bcm,
544 } 544 }
545 545
546 frame_ctl = le16_to_cpu(wlhdr->frame_ctl); 546 frame_ctl = le16_to_cpu(wlhdr->frame_ctl);
547 if ((frame_ctl & IEEE80211_FCTL_PROTECTED) && !bcm->ieee->host_decrypt) {
548 frame_ctl &= ~IEEE80211_FCTL_PROTECTED;
549 wlhdr->frame_ctl = cpu_to_le16(frame_ctl);
550 /* trim IV and ICV */
551 /* FIXME: this must be done only for WEP encrypted packets */
552 if (skb->len < 32) {
553 dprintkl(KERN_ERR PFX "RX packet dropped (PROTECTED flag "
554 "set and length < 32)\n");
555 return -EINVAL;
556 } else {
557 memmove(skb->data + 4, skb->data, 24);
558 skb_pull(skb, 4);
559 skb_trim(skb, skb->len - 4);
560 stats.len -= 8;
561 }
562 wlhdr = (struct ieee80211_hdr_4addr *)(skb->data);
563 }
564
565 switch (WLAN_FC_GET_TYPE(frame_ctl)) { 547 switch (WLAN_FC_GET_TYPE(frame_ctl)) {
566 case IEEE80211_FTYPE_MGMT: 548 case IEEE80211_FTYPE_MGMT:
567 ieee80211_rx_mgt(bcm->ieee, wlhdr, &stats); 549 ieee80211_rx_mgt(bcm->ieee, wlhdr, &stats);
diff --git a/drivers/net/wireless/hostap/hostap.h b/drivers/net/wireless/hostap/hostap.h
index e663518bd570..e89c890d16fd 100644
--- a/drivers/net/wireless/hostap/hostap.h
+++ b/drivers/net/wireless/hostap/hostap.h
@@ -35,7 +35,7 @@ int hostap_80211_get_hdrlen(u16 fc);
35struct net_device_stats *hostap_get_stats(struct net_device *dev); 35struct net_device_stats *hostap_get_stats(struct net_device *dev);
36void hostap_setup_dev(struct net_device *dev, local_info_t *local, 36void hostap_setup_dev(struct net_device *dev, local_info_t *local,
37 int main_dev); 37 int main_dev);
38void hostap_set_multicast_list_queue(void *data); 38void hostap_set_multicast_list_queue(struct work_struct *work);
39int hostap_set_hostapd(local_info_t *local, int val, int rtnl_locked); 39int hostap_set_hostapd(local_info_t *local, int val, int rtnl_locked);
40int hostap_set_hostapd_sta(local_info_t *local, int val, int rtnl_locked); 40int hostap_set_hostapd_sta(local_info_t *local, int val, int rtnl_locked);
41void hostap_cleanup(local_info_t *local); 41void hostap_cleanup(local_info_t *local);
diff --git a/drivers/net/wireless/hostap/hostap_ap.c b/drivers/net/wireless/hostap/hostap_ap.c
index ba13125024cb..974a8e5bec8b 100644
--- a/drivers/net/wireless/hostap/hostap_ap.c
+++ b/drivers/net/wireless/hostap/hostap_ap.c
@@ -49,10 +49,10 @@ MODULE_PARM_DESC(autom_ap_wds, "Add WDS connections to other APs "
49static struct sta_info* ap_get_sta(struct ap_data *ap, u8 *sta); 49static struct sta_info* ap_get_sta(struct ap_data *ap, u8 *sta);
50static void hostap_event_expired_sta(struct net_device *dev, 50static void hostap_event_expired_sta(struct net_device *dev,
51 struct sta_info *sta); 51 struct sta_info *sta);
52static void handle_add_proc_queue(void *data); 52static void handle_add_proc_queue(struct work_struct *work);
53 53
54#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT 54#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
55static void handle_wds_oper_queue(void *data); 55static void handle_wds_oper_queue(struct work_struct *work);
56static void prism2_send_mgmt(struct net_device *dev, 56static void prism2_send_mgmt(struct net_device *dev,
57 u16 type_subtype, char *body, 57 u16 type_subtype, char *body,
58 int body_len, u8 *addr, u16 tx_cb_idx); 58 int body_len, u8 *addr, u16 tx_cb_idx);
@@ -807,7 +807,7 @@ void hostap_init_data(local_info_t *local)
807 INIT_LIST_HEAD(&ap->sta_list); 807 INIT_LIST_HEAD(&ap->sta_list);
808 808
809 /* Initialize task queue structure for AP management */ 809 /* Initialize task queue structure for AP management */
810 INIT_WORK(&local->ap->add_sta_proc_queue, handle_add_proc_queue, ap); 810 INIT_WORK(&local->ap->add_sta_proc_queue, handle_add_proc_queue);
811 811
812 ap->tx_callback_idx = 812 ap->tx_callback_idx =
813 hostap_tx_callback_register(local, hostap_ap_tx_cb, ap); 813 hostap_tx_callback_register(local, hostap_ap_tx_cb, ap);
@@ -815,7 +815,7 @@ void hostap_init_data(local_info_t *local)
815 printk(KERN_WARNING "%s: failed to register TX callback for " 815 printk(KERN_WARNING "%s: failed to register TX callback for "
816 "AP\n", local->dev->name); 816 "AP\n", local->dev->name);
817#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT 817#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
818 INIT_WORK(&local->ap->wds_oper_queue, handle_wds_oper_queue, local); 818 INIT_WORK(&local->ap->wds_oper_queue, handle_wds_oper_queue);
819 819
820 ap->tx_callback_auth = 820 ap->tx_callback_auth =
821 hostap_tx_callback_register(local, hostap_ap_tx_cb_auth, ap); 821 hostap_tx_callback_register(local, hostap_ap_tx_cb_auth, ap);
@@ -1062,9 +1062,10 @@ static int prism2_sta_proc_read(char *page, char **start, off_t off,
1062} 1062}
1063 1063
1064 1064
1065static void handle_add_proc_queue(void *data) 1065static void handle_add_proc_queue(struct work_struct *work)
1066{ 1066{
1067 struct ap_data *ap = (struct ap_data *) data; 1067 struct ap_data *ap = container_of(work, struct ap_data,
1068 add_sta_proc_queue);
1068 struct sta_info *sta; 1069 struct sta_info *sta;
1069 char name[20]; 1070 char name[20];
1070 struct add_sta_proc_data *entry, *prev; 1071 struct add_sta_proc_data *entry, *prev;
@@ -1099,15 +1100,13 @@ static struct sta_info * ap_add_sta(struct ap_data *ap, u8 *addr)
1099{ 1100{
1100 struct sta_info *sta; 1101 struct sta_info *sta;
1101 1102
1102 sta = (struct sta_info *) 1103 sta = kzalloc(sizeof(struct sta_info), GFP_ATOMIC);
1103 kmalloc(sizeof(struct sta_info), GFP_ATOMIC);
1104 if (sta == NULL) { 1104 if (sta == NULL) {
1105 PDEBUG(DEBUG_AP, "AP: kmalloc failed\n"); 1105 PDEBUG(DEBUG_AP, "AP: kmalloc failed\n");
1106 return NULL; 1106 return NULL;
1107 } 1107 }
1108 1108
1109 /* initialize STA info data */ 1109 /* initialize STA info data */
1110 memset(sta, 0, sizeof(struct sta_info));
1111 sta->local = ap->local; 1110 sta->local = ap->local;
1112 skb_queue_head_init(&sta->tx_buf); 1111 skb_queue_head_init(&sta->tx_buf);
1113 memcpy(sta->addr, addr, ETH_ALEN); 1112 memcpy(sta->addr, addr, ETH_ALEN);
@@ -1952,9 +1951,11 @@ static void handle_pspoll(local_info_t *local,
1952 1951
1953#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT 1952#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
1954 1953
1955static void handle_wds_oper_queue(void *data) 1954static void handle_wds_oper_queue(struct work_struct *work)
1956{ 1955{
1957 local_info_t *local = data; 1956 struct ap_data *ap = container_of(work, struct ap_data,
1957 wds_oper_queue);
1958 local_info_t *local = ap->local;
1958 struct wds_oper_data *entry, *prev; 1959 struct wds_oper_data *entry, *prev;
1959 1960
1960 spin_lock_bh(&local->lock); 1961 spin_lock_bh(&local->lock);
diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c
index f63909e4bc32..8d8f4b9b8b07 100644
--- a/drivers/net/wireless/hostap/hostap_cs.c
+++ b/drivers/net/wireless/hostap/hostap_cs.c
@@ -293,15 +293,12 @@ static int sandisk_enable_wireless(struct net_device *dev)
293 goto done; 293 goto done;
294 } 294 }
295 295
296 tuple.DesiredTuple = CISTPL_MANFID;
297 tuple.Attributes = TUPLE_RETURN_COMMON; 296 tuple.Attributes = TUPLE_RETURN_COMMON;
298 tuple.TupleData = buf; 297 tuple.TupleData = buf;
299 tuple.TupleDataMax = sizeof(buf); 298 tuple.TupleDataMax = sizeof(buf);
300 tuple.TupleOffset = 0; 299 tuple.TupleOffset = 0;
301 if (pcmcia_get_first_tuple(hw_priv->link, &tuple) || 300
302 pcmcia_get_tuple_data(hw_priv->link, &tuple) || 301 if (hw_priv->link->manf_id != 0xd601 || hw_priv->link->card_id != 0x0101) {
303 pcmcia_parse_tuple(hw_priv->link, &tuple, parse) ||
304 parse->manfid.manf != 0xd601 || parse->manfid.card != 0x0101) {
305 /* No SanDisk manfid found */ 302 /* No SanDisk manfid found */
306 ret = -ENODEV; 303 ret = -ENODEV;
307 goto done; 304 goto done;
@@ -566,23 +563,16 @@ static int prism2_config(struct pcmcia_device *link)
566 PDEBUG(DEBUG_FLOW, "prism2_config()\n"); 563 PDEBUG(DEBUG_FLOW, "prism2_config()\n");
567 564
568 parse = kmalloc(sizeof(cisparse_t), GFP_KERNEL); 565 parse = kmalloc(sizeof(cisparse_t), GFP_KERNEL);
569 hw_priv = kmalloc(sizeof(*hw_priv), GFP_KERNEL); 566 hw_priv = kzalloc(sizeof(*hw_priv), GFP_KERNEL);
570 if (parse == NULL || hw_priv == NULL) { 567 if (parse == NULL || hw_priv == NULL) {
571 ret = -ENOMEM; 568 ret = -ENOMEM;
572 goto failed; 569 goto failed;
573 } 570 }
574 memset(hw_priv, 0, sizeof(*hw_priv));
575 571
576 tuple.DesiredTuple = CISTPL_CONFIG;
577 tuple.Attributes = 0; 572 tuple.Attributes = 0;
578 tuple.TupleData = buf; 573 tuple.TupleData = buf;
579 tuple.TupleDataMax = sizeof(buf); 574 tuple.TupleDataMax = sizeof(buf);
580 tuple.TupleOffset = 0; 575 tuple.TupleOffset = 0;
581 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
582 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
583 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, parse));
584 link->conf.ConfigBase = parse->config.base;
585 link->conf.Present = parse->config.rmask[0];
586 576
587 CS_CHECK(GetConfigurationInfo, 577 CS_CHECK(GetConfigurationInfo,
588 pcmcia_get_configuration_info(link, &conf)); 578 pcmcia_get_configuration_info(link, &conf));
diff --git a/drivers/net/wireless/hostap/hostap_download.c b/drivers/net/wireless/hostap/hostap_download.c
index ab26b52b3e76..24fc387bba67 100644
--- a/drivers/net/wireless/hostap/hostap_download.c
+++ b/drivers/net/wireless/hostap/hostap_download.c
@@ -685,14 +685,12 @@ static int prism2_download(local_info_t *local,
685 goto out; 685 goto out;
686 } 686 }
687 687
688 dl = kmalloc(sizeof(*dl) + param->num_areas * 688 dl = kzalloc(sizeof(*dl) + param->num_areas *
689 sizeof(struct prism2_download_data_area), GFP_KERNEL); 689 sizeof(struct prism2_download_data_area), GFP_KERNEL);
690 if (dl == NULL) { 690 if (dl == NULL) {
691 ret = -ENOMEM; 691 ret = -ENOMEM;
692 goto out; 692 goto out;
693 } 693 }
694 memset(dl, 0, sizeof(*dl) + param->num_areas *
695 sizeof(struct prism2_download_data_area));
696 dl->dl_cmd = param->dl_cmd; 694 dl->dl_cmd = param->dl_cmd;
697 dl->start_addr = param->start_addr; 695 dl->start_addr = param->start_addr;
698 dl->num_areas = param->num_areas; 696 dl->num_areas = param->num_areas;
diff --git a/drivers/net/wireless/hostap/hostap_hw.c b/drivers/net/wireless/hostap/hostap_hw.c
index ed00ebb6e7f4..a394a23b9a20 100644
--- a/drivers/net/wireless/hostap/hostap_hw.c
+++ b/drivers/net/wireless/hostap/hostap_hw.c
@@ -347,14 +347,12 @@ static int hfa384x_cmd(struct net_device *dev, u16 cmd, u16 param0,
347 if (signal_pending(current)) 347 if (signal_pending(current))
348 return -EINTR; 348 return -EINTR;
349 349
350 entry = (struct hostap_cmd_queue *) 350 entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
351 kmalloc(sizeof(*entry), GFP_ATOMIC);
352 if (entry == NULL) { 351 if (entry == NULL) {
353 printk(KERN_DEBUG "%s: hfa384x_cmd - kmalloc failed\n", 352 printk(KERN_DEBUG "%s: hfa384x_cmd - kmalloc failed\n",
354 dev->name); 353 dev->name);
355 return -ENOMEM; 354 return -ENOMEM;
356 } 355 }
357 memset(entry, 0, sizeof(*entry));
358 atomic_set(&entry->usecnt, 1); 356 atomic_set(&entry->usecnt, 1);
359 entry->type = CMD_SLEEP; 357 entry->type = CMD_SLEEP;
360 entry->cmd = cmd; 358 entry->cmd = cmd;
@@ -517,14 +515,12 @@ static int hfa384x_cmd_callback(struct net_device *dev, u16 cmd, u16 param0,
517 return -1; 515 return -1;
518 } 516 }
519 517
520 entry = (struct hostap_cmd_queue *) 518 entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
521 kmalloc(sizeof(*entry), GFP_ATOMIC);
522 if (entry == NULL) { 519 if (entry == NULL) {
523 printk(KERN_DEBUG "%s: hfa384x_cmd_callback - kmalloc " 520 printk(KERN_DEBUG "%s: hfa384x_cmd_callback - kmalloc "
524 "failed\n", dev->name); 521 "failed\n", dev->name);
525 return -ENOMEM; 522 return -ENOMEM;
526 } 523 }
527 memset(entry, 0, sizeof(*entry));
528 atomic_set(&entry->usecnt, 1); 524 atomic_set(&entry->usecnt, 1);
529 entry->type = CMD_CALLBACK; 525 entry->type = CMD_CALLBACK;
530 entry->cmd = cmd; 526 entry->cmd = cmd;
@@ -1645,9 +1641,9 @@ static void prism2_schedule_reset(local_info_t *local)
1645 1641
1646/* Called only as scheduled task after noticing card timeout in interrupt 1642/* Called only as scheduled task after noticing card timeout in interrupt
1647 * context */ 1643 * context */
1648static void handle_reset_queue(void *data) 1644static void handle_reset_queue(struct work_struct *work)
1649{ 1645{
1650 local_info_t *local = (local_info_t *) data; 1646 local_info_t *local = container_of(work, local_info_t, reset_queue);
1651 1647
1652 printk(KERN_DEBUG "%s: scheduled card reset\n", local->dev->name); 1648 printk(KERN_DEBUG "%s: scheduled card reset\n", local->dev->name);
1653 prism2_hw_reset(local->dev); 1649 prism2_hw_reset(local->dev);
@@ -2896,9 +2892,10 @@ static void hostap_passive_scan(unsigned long data)
2896 2892
2897/* Called only as a scheduled task when communications quality values should 2893/* Called only as a scheduled task when communications quality values should
2898 * be updated. */ 2894 * be updated. */
2899static void handle_comms_qual_update(void *data) 2895static void handle_comms_qual_update(struct work_struct *work)
2900{ 2896{
2901 local_info_t *local = data; 2897 local_info_t *local =
2898 container_of(work, local_info_t, comms_qual_update);
2902 prism2_update_comms_qual(local->dev); 2899 prism2_update_comms_qual(local->dev);
2903} 2900}
2904 2901
@@ -3015,14 +3012,12 @@ static int prism2_set_tim(struct net_device *dev, int aid, int set)
3015 iface = netdev_priv(dev); 3012 iface = netdev_priv(dev);
3016 local = iface->local; 3013 local = iface->local;
3017 3014
3018 new_entry = (struct set_tim_data *) 3015 new_entry = kzalloc(sizeof(*new_entry), GFP_ATOMIC);
3019 kmalloc(sizeof(*new_entry), GFP_ATOMIC);
3020 if (new_entry == NULL) { 3016 if (new_entry == NULL) {
3021 printk(KERN_DEBUG "%s: prism2_set_tim: kmalloc failed\n", 3017 printk(KERN_DEBUG "%s: prism2_set_tim: kmalloc failed\n",
3022 local->dev->name); 3018 local->dev->name);
3023 return -ENOMEM; 3019 return -ENOMEM;
3024 } 3020 }
3025 memset(new_entry, 0, sizeof(*new_entry));
3026 new_entry->aid = aid; 3021 new_entry->aid = aid;
3027 new_entry->set = set; 3022 new_entry->set = set;
3028 3023
@@ -3050,9 +3045,9 @@ static int prism2_set_tim(struct net_device *dev, int aid, int set)
3050} 3045}
3051 3046
3052 3047
3053static void handle_set_tim_queue(void *data) 3048static void handle_set_tim_queue(struct work_struct *work)
3054{ 3049{
3055 local_info_t *local = (local_info_t *) data; 3050 local_info_t *local = container_of(work, local_info_t, set_tim_queue);
3056 struct set_tim_data *entry; 3051 struct set_tim_data *entry;
3057 u16 val; 3052 u16 val;
3058 3053
@@ -3209,15 +3204,15 @@ prism2_init_local_data(struct prism2_helper_functions *funcs, int card_idx,
3209 local->scan_channel_mask = 0xffff; 3204 local->scan_channel_mask = 0xffff;
3210 3205
3211 /* Initialize task queue structures */ 3206 /* Initialize task queue structures */
3212 INIT_WORK(&local->reset_queue, handle_reset_queue, local); 3207 INIT_WORK(&local->reset_queue, handle_reset_queue);
3213 INIT_WORK(&local->set_multicast_list_queue, 3208 INIT_WORK(&local->set_multicast_list_queue,
3214 hostap_set_multicast_list_queue, local->dev); 3209 hostap_set_multicast_list_queue);
3215 3210
3216 INIT_WORK(&local->set_tim_queue, handle_set_tim_queue, local); 3211 INIT_WORK(&local->set_tim_queue, handle_set_tim_queue);
3217 INIT_LIST_HEAD(&local->set_tim_list); 3212 INIT_LIST_HEAD(&local->set_tim_list);
3218 spin_lock_init(&local->set_tim_lock); 3213 spin_lock_init(&local->set_tim_lock);
3219 3214
3220 INIT_WORK(&local->comms_qual_update, handle_comms_qual_update, local); 3215 INIT_WORK(&local->comms_qual_update, handle_comms_qual_update);
3221 3216
3222 /* Initialize tasklets for handling hardware IRQ related operations 3217 /* Initialize tasklets for handling hardware IRQ related operations
3223 * outside hw IRQ handler */ 3218 * outside hw IRQ handler */
diff --git a/drivers/net/wireless/hostap/hostap_info.c b/drivers/net/wireless/hostap/hostap_info.c
index 50f72d831cf4..b6a02a02da74 100644
--- a/drivers/net/wireless/hostap/hostap_info.c
+++ b/drivers/net/wireless/hostap/hostap_info.c
@@ -327,11 +327,10 @@ static void prism2_info_hostscanresults(local_info_t *local,
327 ptr = (u8 *) pos; 327 ptr = (u8 *) pos;
328 328
329 new_count = left / result_size; 329 new_count = left / result_size;
330 results = kmalloc(new_count * sizeof(struct hfa384x_hostscan_result), 330 results = kcalloc(new_count, sizeof(struct hfa384x_hostscan_result),
331 GFP_ATOMIC); 331 GFP_ATOMIC);
332 if (results == NULL) 332 if (results == NULL)
333 return; 333 return;
334 memset(results, 0, new_count * sizeof(struct hfa384x_hostscan_result));
335 334
336 for (i = 0; i < new_count; i++) { 335 for (i = 0; i < new_count; i++) {
337 memcpy(&results[i], ptr, copy_len); 336 memcpy(&results[i], ptr, copy_len);
@@ -474,9 +473,9 @@ static void handle_info_queue_scanresults(local_info_t *local)
474 473
475/* Called only as scheduled task after receiving info frames (used to avoid 474/* Called only as scheduled task after receiving info frames (used to avoid
476 * pending too much time in HW IRQ handler). */ 475 * pending too much time in HW IRQ handler). */
477static void handle_info_queue(void *data) 476static void handle_info_queue(struct work_struct *work)
478{ 477{
479 local_info_t *local = (local_info_t *) data; 478 local_info_t *local = container_of(work, local_info_t, info_queue);
480 479
481 if (test_and_clear_bit(PRISM2_INFO_PENDING_LINKSTATUS, 480 if (test_and_clear_bit(PRISM2_INFO_PENDING_LINKSTATUS,
482 &local->pending_info)) 481 &local->pending_info))
@@ -493,7 +492,7 @@ void hostap_info_init(local_info_t *local)
493{ 492{
494 skb_queue_head_init(&local->info_list); 493 skb_queue_head_init(&local->info_list);
495#ifndef PRISM2_NO_STATION_MODES 494#ifndef PRISM2_NO_STATION_MODES
496 INIT_WORK(&local->info_queue, handle_info_queue, local); 495 INIT_WORK(&local->info_queue, handle_info_queue);
497#endif /* PRISM2_NO_STATION_MODES */ 496#endif /* PRISM2_NO_STATION_MODES */
498} 497}
499 498
diff --git a/drivers/net/wireless/hostap/hostap_ioctl.c b/drivers/net/wireless/hostap/hostap_ioctl.c
index d061fb3443ff..3b7b8063ff1c 100644
--- a/drivers/net/wireless/hostap/hostap_ioctl.c
+++ b/drivers/net/wireless/hostap/hostap_ioctl.c
@@ -181,12 +181,10 @@ static int prism2_ioctl_siwencode(struct net_device *dev,
181 struct ieee80211_crypt_data *new_crypt; 181 struct ieee80211_crypt_data *new_crypt;
182 182
183 /* take WEP into use */ 183 /* take WEP into use */
184 new_crypt = (struct ieee80211_crypt_data *) 184 new_crypt = kzalloc(sizeof(struct ieee80211_crypt_data),
185 kmalloc(sizeof(struct ieee80211_crypt_data),
186 GFP_KERNEL); 185 GFP_KERNEL);
187 if (new_crypt == NULL) 186 if (new_crypt == NULL)
188 return -ENOMEM; 187 return -ENOMEM;
189 memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data));
190 new_crypt->ops = ieee80211_get_crypto_ops("WEP"); 188 new_crypt->ops = ieee80211_get_crypto_ops("WEP");
191 if (!new_crypt->ops) { 189 if (!new_crypt->ops) {
192 request_module("ieee80211_crypt_wep"); 190 request_module("ieee80211_crypt_wep");
@@ -3320,14 +3318,12 @@ static int prism2_ioctl_siwencodeext(struct net_device *dev,
3320 3318
3321 prism2_crypt_delayed_deinit(local, crypt); 3319 prism2_crypt_delayed_deinit(local, crypt);
3322 3320
3323 new_crypt = (struct ieee80211_crypt_data *) 3321 new_crypt = kzalloc(sizeof(struct ieee80211_crypt_data),
3324 kmalloc(sizeof(struct ieee80211_crypt_data),
3325 GFP_KERNEL); 3322 GFP_KERNEL);
3326 if (new_crypt == NULL) { 3323 if (new_crypt == NULL) {
3327 ret = -ENOMEM; 3324 ret = -ENOMEM;
3328 goto done; 3325 goto done;
3329 } 3326 }
3330 memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data));
3331 new_crypt->ops = ops; 3327 new_crypt->ops = ops;
3332 new_crypt->priv = new_crypt->ops->init(i); 3328 new_crypt->priv = new_crypt->ops->init(i);
3333 if (new_crypt->priv == NULL) { 3329 if (new_crypt->priv == NULL) {
@@ -3538,14 +3534,12 @@ static int prism2_ioctl_set_encryption(local_info_t *local,
3538 3534
3539 prism2_crypt_delayed_deinit(local, crypt); 3535 prism2_crypt_delayed_deinit(local, crypt);
3540 3536
3541 new_crypt = (struct ieee80211_crypt_data *) 3537 new_crypt = kzalloc(sizeof(struct ieee80211_crypt_data),
3542 kmalloc(sizeof(struct ieee80211_crypt_data),
3543 GFP_KERNEL); 3538 GFP_KERNEL);
3544 if (new_crypt == NULL) { 3539 if (new_crypt == NULL) {
3545 ret = -ENOMEM; 3540 ret = -ENOMEM;
3546 goto done; 3541 goto done;
3547 } 3542 }
3548 memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data));
3549 new_crypt->ops = ops; 3543 new_crypt->ops = ops;
3550 new_crypt->priv = new_crypt->ops->init(param->u.crypt.idx); 3544 new_crypt->priv = new_crypt->ops->init(param->u.crypt.idx);
3551 if (new_crypt->priv == NULL) { 3545 if (new_crypt->priv == NULL) {
diff --git a/drivers/net/wireless/hostap/hostap_main.c b/drivers/net/wireless/hostap/hostap_main.c
index 53374fcba77e..0796be9d9e77 100644
--- a/drivers/net/wireless/hostap/hostap_main.c
+++ b/drivers/net/wireless/hostap/hostap_main.c
@@ -767,14 +767,14 @@ static int prism2_set_mac_address(struct net_device *dev, void *p)
767 767
768/* TODO: to be further implemented as soon as Prism2 fully supports 768/* TODO: to be further implemented as soon as Prism2 fully supports
769 * GroupAddresses and correct documentation is available */ 769 * GroupAddresses and correct documentation is available */
770void hostap_set_multicast_list_queue(void *data) 770void hostap_set_multicast_list_queue(struct work_struct *work)
771{ 771{
772 struct net_device *dev = (struct net_device *) data; 772 local_info_t *local =
773 container_of(work, local_info_t, set_multicast_list_queue);
774 struct net_device *dev = local->dev;
773 struct hostap_interface *iface; 775 struct hostap_interface *iface;
774 local_info_t *local;
775 776
776 iface = netdev_priv(dev); 777 iface = netdev_priv(dev);
777 local = iface->local;
778 if (hostap_set_word(dev, HFA384X_RID_PROMISCUOUSMODE, 778 if (hostap_set_word(dev, HFA384X_RID_PROMISCUOUSMODE,
779 local->is_promisc)) { 779 local->is_promisc)) {
780 printk(KERN_INFO "%s: %sabling promiscuous mode failed\n", 780 printk(KERN_INFO "%s: %sabling promiscuous mode failed\n",
diff --git a/drivers/net/wireless/hostap/hostap_pci.c b/drivers/net/wireless/hostap/hostap_pci.c
index c2fa011be291..c4f6020baa9e 100644
--- a/drivers/net/wireless/hostap/hostap_pci.c
+++ b/drivers/net/wireless/hostap/hostap_pci.c
@@ -300,10 +300,9 @@ static int prism2_pci_probe(struct pci_dev *pdev,
300 struct hostap_interface *iface; 300 struct hostap_interface *iface;
301 struct hostap_pci_priv *hw_priv; 301 struct hostap_pci_priv *hw_priv;
302 302
303 hw_priv = kmalloc(sizeof(*hw_priv), GFP_KERNEL); 303 hw_priv = kzalloc(sizeof(*hw_priv), GFP_KERNEL);
304 if (hw_priv == NULL) 304 if (hw_priv == NULL)
305 return -ENOMEM; 305 return -ENOMEM;
306 memset(hw_priv, 0, sizeof(*hw_priv));
307 306
308 if (pci_enable_device(pdev)) 307 if (pci_enable_device(pdev))
309 goto err_out_free; 308 goto err_out_free;
@@ -425,8 +424,14 @@ static int prism2_pci_suspend(struct pci_dev *pdev, pm_message_t state)
425static int prism2_pci_resume(struct pci_dev *pdev) 424static int prism2_pci_resume(struct pci_dev *pdev)
426{ 425{
427 struct net_device *dev = pci_get_drvdata(pdev); 426 struct net_device *dev = pci_get_drvdata(pdev);
427 int err;
428 428
429 pci_enable_device(pdev); 429 err = pci_enable_device(pdev);
430 if (err) {
431 printk(KERN_ERR "%s: pci_enable_device failed on resume\n",
432 dev->name);
433 return err;
434 }
430 pci_restore_state(pdev); 435 pci_restore_state(pdev);
431 prism2_hw_config(dev, 0); 436 prism2_hw_config(dev, 0);
432 if (netif_running(dev)) { 437 if (netif_running(dev)) {
diff --git a/drivers/net/wireless/hostap/hostap_plx.c b/drivers/net/wireless/hostap/hostap_plx.c
index 6dfa041be66d..e235e0647897 100644
--- a/drivers/net/wireless/hostap/hostap_plx.c
+++ b/drivers/net/wireless/hostap/hostap_plx.c
@@ -364,7 +364,7 @@ static int prism2_plx_check_cis(void __iomem *attr_mem, int attr_len,
364 364
365 pos = 0; 365 pos = 0;
366 while (pos < CIS_MAX_LEN - 1 && cis[pos] != CISTPL_END) { 366 while (pos < CIS_MAX_LEN - 1 && cis[pos] != CISTPL_END) {
367 if (pos + cis[pos + 1] >= CIS_MAX_LEN) 367 if (pos + 2 + cis[pos + 1] > CIS_MAX_LEN)
368 goto cis_error; 368 goto cis_error;
369 369
370 switch (cis[pos]) { 370 switch (cis[pos]) {
@@ -391,7 +391,7 @@ static int prism2_plx_check_cis(void __iomem *attr_mem, int attr_len,
391 break; 391 break;
392 392
393 case CISTPL_MANFID: 393 case CISTPL_MANFID:
394 if (cis[pos + 1] < 5) 394 if (cis[pos + 1] < 4)
395 goto cis_error; 395 goto cis_error;
396 manfid1 = cis[pos + 2] + (cis[pos + 3] << 8); 396 manfid1 = cis[pos + 2] + (cis[pos + 3] << 8);
397 manfid2 = cis[pos + 4] + (cis[pos + 5] << 8); 397 manfid2 = cis[pos + 4] + (cis[pos + 5] << 8);
@@ -447,10 +447,9 @@ static int prism2_plx_probe(struct pci_dev *pdev,
447 int tmd7160; 447 int tmd7160;
448 struct hostap_plx_priv *hw_priv; 448 struct hostap_plx_priv *hw_priv;
449 449
450 hw_priv = kmalloc(sizeof(*hw_priv), GFP_KERNEL); 450 hw_priv = kzalloc(sizeof(*hw_priv), GFP_KERNEL);
451 if (hw_priv == NULL) 451 if (hw_priv == NULL)
452 return -ENOMEM; 452 return -ENOMEM;
453 memset(hw_priv, 0, sizeof(*hw_priv));
454 453
455 if (pci_enable_device(pdev)) 454 if (pci_enable_device(pdev))
456 goto err_out_free; 455 goto err_out_free;
diff --git a/drivers/net/wireless/ipw2100.c b/drivers/net/wireless/ipw2100.c
index 4e4eaa2a99ca..dd9ba4aad7bb 100644
--- a/drivers/net/wireless/ipw2100.c
+++ b/drivers/net/wireless/ipw2100.c
@@ -316,7 +316,7 @@ static void ipw2100_release_firmware(struct ipw2100_priv *priv,
316 struct ipw2100_fw *fw); 316 struct ipw2100_fw *fw);
317static int ipw2100_ucode_download(struct ipw2100_priv *priv, 317static int ipw2100_ucode_download(struct ipw2100_priv *priv,
318 struct ipw2100_fw *fw); 318 struct ipw2100_fw *fw);
319static void ipw2100_wx_event_work(struct ipw2100_priv *priv); 319static void ipw2100_wx_event_work(struct work_struct *work);
320static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device *dev); 320static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device *dev);
321static struct iw_handler_def ipw2100_wx_handler_def; 321static struct iw_handler_def ipw2100_wx_handler_def;
322 322
@@ -679,7 +679,8 @@ static void schedule_reset(struct ipw2100_priv *priv)
679 queue_delayed_work(priv->workqueue, &priv->reset_work, 679 queue_delayed_work(priv->workqueue, &priv->reset_work,
680 priv->reset_backoff * HZ); 680 priv->reset_backoff * HZ);
681 else 681 else
682 queue_work(priv->workqueue, &priv->reset_work); 682 queue_delayed_work(priv->workqueue, &priv->reset_work,
683 0);
683 684
684 if (priv->reset_backoff < MAX_RESET_BACKOFF) 685 if (priv->reset_backoff < MAX_RESET_BACKOFF)
685 priv->reset_backoff++; 686 priv->reset_backoff++;
@@ -1873,8 +1874,10 @@ static void ipw2100_down(struct ipw2100_priv *priv)
1873 netif_stop_queue(priv->net_dev); 1874 netif_stop_queue(priv->net_dev);
1874} 1875}
1875 1876
1876static void ipw2100_reset_adapter(struct ipw2100_priv *priv) 1877static void ipw2100_reset_adapter(struct work_struct *work)
1877{ 1878{
1879 struct ipw2100_priv *priv =
1880 container_of(work, struct ipw2100_priv, reset_work.work);
1878 unsigned long flags; 1881 unsigned long flags;
1879 union iwreq_data wrqu = { 1882 union iwreq_data wrqu = {
1880 .ap_addr = { 1883 .ap_addr = {
@@ -2071,9 +2074,9 @@ static void isr_indicate_association_lost(struct ipw2100_priv *priv, u32 status)
2071 return; 2074 return;
2072 2075
2073 if (priv->status & STATUS_SECURITY_UPDATED) 2076 if (priv->status & STATUS_SECURITY_UPDATED)
2074 queue_work(priv->workqueue, &priv->security_work); 2077 queue_delayed_work(priv->workqueue, &priv->security_work, 0);
2075 2078
2076 queue_work(priv->workqueue, &priv->wx_event_work); 2079 queue_delayed_work(priv->workqueue, &priv->wx_event_work, 0);
2077} 2080}
2078 2081
2079static void isr_indicate_rf_kill(struct ipw2100_priv *priv, u32 status) 2082static void isr_indicate_rf_kill(struct ipw2100_priv *priv, u32 status)
@@ -5524,8 +5527,11 @@ static int ipw2100_configure_security(struct ipw2100_priv *priv, int batch_mode)
5524 return err; 5527 return err;
5525} 5528}
5526 5529
5527static void ipw2100_security_work(struct ipw2100_priv *priv) 5530static void ipw2100_security_work(struct work_struct *work)
5528{ 5531{
5532 struct ipw2100_priv *priv =
5533 container_of(work, struct ipw2100_priv, security_work.work);
5534
5529 /* If we happen to have reconnected before we get a chance to 5535 /* If we happen to have reconnected before we get a chance to
5530 * process this, then update the security settings--which causes 5536 * process this, then update the security settings--which causes
5531 * a disassociation to occur */ 5537 * a disassociation to occur */
@@ -5748,7 +5754,7 @@ static int ipw2100_set_address(struct net_device *dev, void *p)
5748 5754
5749 priv->reset_backoff = 0; 5755 priv->reset_backoff = 0;
5750 mutex_unlock(&priv->action_mutex); 5756 mutex_unlock(&priv->action_mutex);
5751 ipw2100_reset_adapter(priv); 5757 ipw2100_reset_adapter(&priv->reset_work.work);
5752 return 0; 5758 return 0;
5753 5759
5754 done: 5760 done:
@@ -5827,19 +5833,6 @@ static void ipw2100_tx_timeout(struct net_device *dev)
5827 schedule_reset(priv); 5833 schedule_reset(priv);
5828} 5834}
5829 5835
5830/*
5831 * TODO: reimplement it so that it reads statistics
5832 * from the adapter using ordinal tables
5833 * instead of/in addition to collecting them
5834 * in the driver
5835 */
5836static struct net_device_stats *ipw2100_stats(struct net_device *dev)
5837{
5838 struct ipw2100_priv *priv = ieee80211_priv(dev);
5839
5840 return &priv->ieee->stats;
5841}
5842
5843static int ipw2100_wpa_enable(struct ipw2100_priv *priv, int value) 5836static int ipw2100_wpa_enable(struct ipw2100_priv *priv, int value)
5844{ 5837{
5845 /* This is called when wpa_supplicant loads and closes the driver 5838 /* This is called when wpa_supplicant loads and closes the driver
@@ -5923,9 +5916,10 @@ static const struct ethtool_ops ipw2100_ethtool_ops = {
5923 .get_drvinfo = ipw_ethtool_get_drvinfo, 5916 .get_drvinfo = ipw_ethtool_get_drvinfo,
5924}; 5917};
5925 5918
5926static void ipw2100_hang_check(void *adapter) 5919static void ipw2100_hang_check(struct work_struct *work)
5927{ 5920{
5928 struct ipw2100_priv *priv = adapter; 5921 struct ipw2100_priv *priv =
5922 container_of(work, struct ipw2100_priv, hang_check.work);
5929 unsigned long flags; 5923 unsigned long flags;
5930 u32 rtc = 0xa5a5a5a5; 5924 u32 rtc = 0xa5a5a5a5;
5931 u32 len = sizeof(rtc); 5925 u32 len = sizeof(rtc);
@@ -5965,9 +5959,10 @@ static void ipw2100_hang_check(void *adapter)
5965 spin_unlock_irqrestore(&priv->low_lock, flags); 5959 spin_unlock_irqrestore(&priv->low_lock, flags);
5966} 5960}
5967 5961
5968static void ipw2100_rf_kill(void *adapter) 5962static void ipw2100_rf_kill(struct work_struct *work)
5969{ 5963{
5970 struct ipw2100_priv *priv = adapter; 5964 struct ipw2100_priv *priv =
5965 container_of(work, struct ipw2100_priv, rf_kill.work);
5971 unsigned long flags; 5966 unsigned long flags;
5972 5967
5973 spin_lock_irqsave(&priv->low_lock, flags); 5968 spin_lock_irqsave(&priv->low_lock, flags);
@@ -6022,7 +6017,6 @@ static struct net_device *ipw2100_alloc_device(struct pci_dev *pci_dev,
6022 dev->open = ipw2100_open; 6017 dev->open = ipw2100_open;
6023 dev->stop = ipw2100_close; 6018 dev->stop = ipw2100_close;
6024 dev->init = ipw2100_net_init; 6019 dev->init = ipw2100_net_init;
6025 dev->get_stats = ipw2100_stats;
6026 dev->ethtool_ops = &ipw2100_ethtool_ops; 6020 dev->ethtool_ops = &ipw2100_ethtool_ops;
6027 dev->tx_timeout = ipw2100_tx_timeout; 6021 dev->tx_timeout = ipw2100_tx_timeout;
6028 dev->wireless_handlers = &ipw2100_wx_handler_def; 6022 dev->wireless_handlers = &ipw2100_wx_handler_def;
@@ -6117,14 +6111,11 @@ static struct net_device *ipw2100_alloc_device(struct pci_dev *pci_dev,
6117 6111
6118 priv->workqueue = create_workqueue(DRV_NAME); 6112 priv->workqueue = create_workqueue(DRV_NAME);
6119 6113
6120 INIT_WORK(&priv->reset_work, 6114 INIT_DELAYED_WORK(&priv->reset_work, ipw2100_reset_adapter);
6121 (void (*)(void *))ipw2100_reset_adapter, priv); 6115 INIT_DELAYED_WORK(&priv->security_work, ipw2100_security_work);
6122 INIT_WORK(&priv->security_work, 6116 INIT_DELAYED_WORK(&priv->wx_event_work, ipw2100_wx_event_work);
6123 (void (*)(void *))ipw2100_security_work, priv); 6117 INIT_DELAYED_WORK(&priv->hang_check, ipw2100_hang_check);
6124 INIT_WORK(&priv->wx_event_work, 6118 INIT_DELAYED_WORK(&priv->rf_kill, ipw2100_rf_kill);
6125 (void (*)(void *))ipw2100_wx_event_work, priv);
6126 INIT_WORK(&priv->hang_check, ipw2100_hang_check, priv);
6127 INIT_WORK(&priv->rf_kill, ipw2100_rf_kill, priv);
6128 6119
6129 tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long)) 6120 tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long))
6130 ipw2100_irq_tasklet, (unsigned long)priv); 6121 ipw2100_irq_tasklet, (unsigned long)priv);
@@ -6229,7 +6220,7 @@ static int ipw2100_pci_init_one(struct pci_dev *pci_dev,
6229 /* Allocate and initialize the Tx/Rx queues and lists */ 6220 /* Allocate and initialize the Tx/Rx queues and lists */
6230 if (ipw2100_queues_allocate(priv)) { 6221 if (ipw2100_queues_allocate(priv)) {
6231 printk(KERN_WARNING DRV_NAME 6222 printk(KERN_WARNING DRV_NAME
6232 "Error calilng ipw2100_queues_allocate.\n"); 6223 "Error calling ipw2100_queues_allocate.\n");
6233 err = -ENOMEM; 6224 err = -ENOMEM;
6234 goto fail; 6225 goto fail;
6235 } 6226 }
@@ -6423,6 +6414,7 @@ static int ipw2100_resume(struct pci_dev *pci_dev)
6423{ 6414{
6424 struct ipw2100_priv *priv = pci_get_drvdata(pci_dev); 6415 struct ipw2100_priv *priv = pci_get_drvdata(pci_dev);
6425 struct net_device *dev = priv->net_dev; 6416 struct net_device *dev = priv->net_dev;
6417 int err;
6426 u32 val; 6418 u32 val;
6427 6419
6428 if (IPW2100_PM_DISABLED) 6420 if (IPW2100_PM_DISABLED)
@@ -6433,7 +6425,12 @@ static int ipw2100_resume(struct pci_dev *pci_dev)
6433 IPW_DEBUG_INFO("%s: Coming out of suspend...\n", dev->name); 6425 IPW_DEBUG_INFO("%s: Coming out of suspend...\n", dev->name);
6434 6426
6435 pci_set_power_state(pci_dev, PCI_D0); 6427 pci_set_power_state(pci_dev, PCI_D0);
6436 pci_enable_device(pci_dev); 6428 err = pci_enable_device(pci_dev);
6429 if (err) {
6430 printk(KERN_ERR "%s: pci_enable_device failed on resume\n",
6431 dev->name);
6432 return err;
6433 }
6437 pci_restore_state(pci_dev); 6434 pci_restore_state(pci_dev);
6438 6435
6439 /* 6436 /*
@@ -7568,11 +7565,10 @@ static int ipw2100_wx_set_genie(struct net_device *dev,
7568 return -EINVAL; 7565 return -EINVAL;
7569 7566
7570 if (wrqu->data.length) { 7567 if (wrqu->data.length) {
7571 buf = kmalloc(wrqu->data.length, GFP_KERNEL); 7568 buf = kmemdup(extra, wrqu->data.length, GFP_KERNEL);
7572 if (buf == NULL) 7569 if (buf == NULL)
7573 return -ENOMEM; 7570 return -ENOMEM;
7574 7571
7575 memcpy(buf, extra, wrqu->data.length);
7576 kfree(ieee->wpa_ie); 7572 kfree(ieee->wpa_ie);
7577 ieee->wpa_ie = buf; 7573 ieee->wpa_ie = buf;
7578 ieee->wpa_ie_len = wrqu->data.length; 7574 ieee->wpa_ie_len = wrqu->data.length;
@@ -8290,8 +8286,10 @@ static struct iw_handler_def ipw2100_wx_handler_def = {
8290 .get_wireless_stats = ipw2100_wx_wireless_stats, 8286 .get_wireless_stats = ipw2100_wx_wireless_stats,
8291}; 8287};
8292 8288
8293static void ipw2100_wx_event_work(struct ipw2100_priv *priv) 8289static void ipw2100_wx_event_work(struct work_struct *work)
8294{ 8290{
8291 struct ipw2100_priv *priv =
8292 container_of(work, struct ipw2100_priv, wx_event_work.work);
8295 union iwreq_data wrqu; 8293 union iwreq_data wrqu;
8296 int len = ETH_ALEN; 8294 int len = ETH_ALEN;
8297 8295
diff --git a/drivers/net/wireless/ipw2100.h b/drivers/net/wireless/ipw2100.h
index 55b7227198df..de7d384d38af 100644
--- a/drivers/net/wireless/ipw2100.h
+++ b/drivers/net/wireless/ipw2100.h
@@ -583,11 +583,11 @@ struct ipw2100_priv {
583 struct tasklet_struct irq_tasklet; 583 struct tasklet_struct irq_tasklet;
584 584
585 struct workqueue_struct *workqueue; 585 struct workqueue_struct *workqueue;
586 struct work_struct reset_work; 586 struct delayed_work reset_work;
587 struct work_struct security_work; 587 struct delayed_work security_work;
588 struct work_struct wx_event_work; 588 struct delayed_work wx_event_work;
589 struct work_struct hang_check; 589 struct delayed_work hang_check;
590 struct work_struct rf_kill; 590 struct delayed_work rf_kill;
591 591
592 u32 interrupts; 592 u32 interrupts;
593 int tx_interrupts; 593 int tx_interrupts;
diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c
index 1f742814a01c..22cb3fb7502e 100644
--- a/drivers/net/wireless/ipw2200.c
+++ b/drivers/net/wireless/ipw2200.c
@@ -70,7 +70,7 @@
70#define VQ 70#define VQ
71#endif 71#endif
72 72
73#define IPW2200_VERSION "1.1.4" VK VD VM VP VR VQ 73#define IPW2200_VERSION "1.2.0" VK VD VM VP VR VQ
74#define DRV_DESCRIPTION "Intel(R) PRO/Wireless 2200/2915 Network Driver" 74#define DRV_DESCRIPTION "Intel(R) PRO/Wireless 2200/2915 Network Driver"
75#define DRV_COPYRIGHT "Copyright(c) 2003-2006 Intel Corporation" 75#define DRV_COPYRIGHT "Copyright(c) 2003-2006 Intel Corporation"
76#define DRV_VERSION IPW2200_VERSION 76#define DRV_VERSION IPW2200_VERSION
@@ -187,9 +187,9 @@ static struct ipw_rx_queue *ipw_rx_queue_alloc(struct ipw_priv *);
187static void ipw_rx_queue_free(struct ipw_priv *, struct ipw_rx_queue *); 187static void ipw_rx_queue_free(struct ipw_priv *, struct ipw_rx_queue *);
188static void ipw_rx_queue_replenish(void *); 188static void ipw_rx_queue_replenish(void *);
189static int ipw_up(struct ipw_priv *); 189static int ipw_up(struct ipw_priv *);
190static void ipw_bg_up(void *); 190static void ipw_bg_up(struct work_struct *work);
191static void ipw_down(struct ipw_priv *); 191static void ipw_down(struct ipw_priv *);
192static void ipw_bg_down(void *); 192static void ipw_bg_down(struct work_struct *work);
193static int ipw_config(struct ipw_priv *); 193static int ipw_config(struct ipw_priv *);
194static int init_supported_rates(struct ipw_priv *priv, 194static int init_supported_rates(struct ipw_priv *priv,
195 struct ipw_supported_rates *prates); 195 struct ipw_supported_rates *prates);
@@ -862,11 +862,12 @@ static void ipw_led_link_on(struct ipw_priv *priv)
862 spin_unlock_irqrestore(&priv->lock, flags); 862 spin_unlock_irqrestore(&priv->lock, flags);
863} 863}
864 864
865static void ipw_bg_led_link_on(void *data) 865static void ipw_bg_led_link_on(struct work_struct *work)
866{ 866{
867 struct ipw_priv *priv = data; 867 struct ipw_priv *priv =
868 container_of(work, struct ipw_priv, led_link_on.work);
868 mutex_lock(&priv->mutex); 869 mutex_lock(&priv->mutex);
869 ipw_led_link_on(data); 870 ipw_led_link_on(priv);
870 mutex_unlock(&priv->mutex); 871 mutex_unlock(&priv->mutex);
871} 872}
872 873
@@ -906,11 +907,12 @@ static void ipw_led_link_off(struct ipw_priv *priv)
906 spin_unlock_irqrestore(&priv->lock, flags); 907 spin_unlock_irqrestore(&priv->lock, flags);
907} 908}
908 909
909static void ipw_bg_led_link_off(void *data) 910static void ipw_bg_led_link_off(struct work_struct *work)
910{ 911{
911 struct ipw_priv *priv = data; 912 struct ipw_priv *priv =
913 container_of(work, struct ipw_priv, led_link_off.work);
912 mutex_lock(&priv->mutex); 914 mutex_lock(&priv->mutex);
913 ipw_led_link_off(data); 915 ipw_led_link_off(priv);
914 mutex_unlock(&priv->mutex); 916 mutex_unlock(&priv->mutex);
915} 917}
916 918
@@ -985,11 +987,12 @@ static void ipw_led_activity_off(struct ipw_priv *priv)
985 spin_unlock_irqrestore(&priv->lock, flags); 987 spin_unlock_irqrestore(&priv->lock, flags);
986} 988}
987 989
988static void ipw_bg_led_activity_off(void *data) 990static void ipw_bg_led_activity_off(struct work_struct *work)
989{ 991{
990 struct ipw_priv *priv = data; 992 struct ipw_priv *priv =
993 container_of(work, struct ipw_priv, led_act_off.work);
991 mutex_lock(&priv->mutex); 994 mutex_lock(&priv->mutex);
992 ipw_led_activity_off(data); 995 ipw_led_activity_off(priv);
993 mutex_unlock(&priv->mutex); 996 mutex_unlock(&priv->mutex);
994} 997}
995 998
@@ -2228,11 +2231,12 @@ static void ipw_adapter_restart(void *adapter)
2228 } 2231 }
2229} 2232}
2230 2233
2231static void ipw_bg_adapter_restart(void *data) 2234static void ipw_bg_adapter_restart(struct work_struct *work)
2232{ 2235{
2233 struct ipw_priv *priv = data; 2236 struct ipw_priv *priv =
2237 container_of(work, struct ipw_priv, adapter_restart);
2234 mutex_lock(&priv->mutex); 2238 mutex_lock(&priv->mutex);
2235 ipw_adapter_restart(data); 2239 ipw_adapter_restart(priv);
2236 mutex_unlock(&priv->mutex); 2240 mutex_unlock(&priv->mutex);
2237} 2241}
2238 2242
@@ -2249,11 +2253,12 @@ static void ipw_scan_check(void *data)
2249 } 2253 }
2250} 2254}
2251 2255
2252static void ipw_bg_scan_check(void *data) 2256static void ipw_bg_scan_check(struct work_struct *work)
2253{ 2257{
2254 struct ipw_priv *priv = data; 2258 struct ipw_priv *priv =
2259 container_of(work, struct ipw_priv, scan_check.work);
2255 mutex_lock(&priv->mutex); 2260 mutex_lock(&priv->mutex);
2256 ipw_scan_check(data); 2261 ipw_scan_check(priv);
2257 mutex_unlock(&priv->mutex); 2262 mutex_unlock(&priv->mutex);
2258} 2263}
2259 2264
@@ -3831,17 +3836,19 @@ static int ipw_disassociate(void *data)
3831 return 1; 3836 return 1;
3832} 3837}
3833 3838
3834static void ipw_bg_disassociate(void *data) 3839static void ipw_bg_disassociate(struct work_struct *work)
3835{ 3840{
3836 struct ipw_priv *priv = data; 3841 struct ipw_priv *priv =
3842 container_of(work, struct ipw_priv, disassociate);
3837 mutex_lock(&priv->mutex); 3843 mutex_lock(&priv->mutex);
3838 ipw_disassociate(data); 3844 ipw_disassociate(priv);
3839 mutex_unlock(&priv->mutex); 3845 mutex_unlock(&priv->mutex);
3840} 3846}
3841 3847
3842static void ipw_system_config(void *data) 3848static void ipw_system_config(struct work_struct *work)
3843{ 3849{
3844 struct ipw_priv *priv = data; 3850 struct ipw_priv *priv =
3851 container_of(work, struct ipw_priv, system_config);
3845 3852
3846#ifdef CONFIG_IPW2200_PROMISCUOUS 3853#ifdef CONFIG_IPW2200_PROMISCUOUS
3847 if (priv->prom_net_dev && netif_running(priv->prom_net_dev)) { 3854 if (priv->prom_net_dev && netif_running(priv->prom_net_dev)) {
@@ -4208,11 +4215,12 @@ static void ipw_gather_stats(struct ipw_priv *priv)
4208 IPW_STATS_INTERVAL); 4215 IPW_STATS_INTERVAL);
4209} 4216}
4210 4217
4211static void ipw_bg_gather_stats(void *data) 4218static void ipw_bg_gather_stats(struct work_struct *work)
4212{ 4219{
4213 struct ipw_priv *priv = data; 4220 struct ipw_priv *priv =
4221 container_of(work, struct ipw_priv, gather_stats.work);
4214 mutex_lock(&priv->mutex); 4222 mutex_lock(&priv->mutex);
4215 ipw_gather_stats(data); 4223 ipw_gather_stats(priv);
4216 mutex_unlock(&priv->mutex); 4224 mutex_unlock(&priv->mutex);
4217} 4225}
4218 4226
@@ -4268,8 +4276,8 @@ static void ipw_handle_missed_beacon(struct ipw_priv *priv,
4268 if (!(priv->status & STATUS_ROAMING)) { 4276 if (!(priv->status & STATUS_ROAMING)) {
4269 priv->status |= STATUS_ROAMING; 4277 priv->status |= STATUS_ROAMING;
4270 if (!(priv->status & STATUS_SCANNING)) 4278 if (!(priv->status & STATUS_SCANNING))
4271 queue_work(priv->workqueue, 4279 queue_delayed_work(priv->workqueue,
4272 &priv->request_scan); 4280 &priv->request_scan, 0);
4273 } 4281 }
4274 return; 4282 return;
4275 } 4283 }
@@ -4607,8 +4615,8 @@ static void ipw_rx_notification(struct ipw_priv *priv,
4607#ifdef CONFIG_IPW2200_MONITOR 4615#ifdef CONFIG_IPW2200_MONITOR
4608 if (priv->ieee->iw_mode == IW_MODE_MONITOR) { 4616 if (priv->ieee->iw_mode == IW_MODE_MONITOR) {
4609 priv->status |= STATUS_SCAN_FORCED; 4617 priv->status |= STATUS_SCAN_FORCED;
4610 queue_work(priv->workqueue, 4618 queue_delayed_work(priv->workqueue,
4611 &priv->request_scan); 4619 &priv->request_scan, 0);
4612 break; 4620 break;
4613 } 4621 }
4614 priv->status &= ~STATUS_SCAN_FORCED; 4622 priv->status &= ~STATUS_SCAN_FORCED;
@@ -4631,8 +4639,8 @@ static void ipw_rx_notification(struct ipw_priv *priv,
4631 /* Don't schedule if we aborted the scan */ 4639 /* Don't schedule if we aborted the scan */
4632 priv->status &= ~STATUS_ROAMING; 4640 priv->status &= ~STATUS_ROAMING;
4633 } else if (priv->status & STATUS_SCAN_PENDING) 4641 } else if (priv->status & STATUS_SCAN_PENDING)
4634 queue_work(priv->workqueue, 4642 queue_delayed_work(priv->workqueue,
4635 &priv->request_scan); 4643 &priv->request_scan, 0);
4636 else if (priv->config & CFG_BACKGROUND_SCAN 4644 else if (priv->config & CFG_BACKGROUND_SCAN
4637 && priv->status & STATUS_ASSOCIATED) 4645 && priv->status & STATUS_ASSOCIATED)
4638 queue_delayed_work(priv->workqueue, 4646 queue_delayed_work(priv->workqueue,
@@ -5055,11 +5063,12 @@ static void ipw_rx_queue_replenish(void *data)
5055 ipw_rx_queue_restock(priv); 5063 ipw_rx_queue_restock(priv);
5056} 5064}
5057 5065
5058static void ipw_bg_rx_queue_replenish(void *data) 5066static void ipw_bg_rx_queue_replenish(struct work_struct *work)
5059{ 5067{
5060 struct ipw_priv *priv = data; 5068 struct ipw_priv *priv =
5069 container_of(work, struct ipw_priv, rx_replenish);
5061 mutex_lock(&priv->mutex); 5070 mutex_lock(&priv->mutex);
5062 ipw_rx_queue_replenish(data); 5071 ipw_rx_queue_replenish(priv);
5063 mutex_unlock(&priv->mutex); 5072 mutex_unlock(&priv->mutex);
5064} 5073}
5065 5074
@@ -5489,9 +5498,10 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
5489 return 1; 5498 return 1;
5490} 5499}
5491 5500
5492static void ipw_merge_adhoc_network(void *data) 5501static void ipw_merge_adhoc_network(struct work_struct *work)
5493{ 5502{
5494 struct ipw_priv *priv = data; 5503 struct ipw_priv *priv =
5504 container_of(work, struct ipw_priv, merge_networks);
5495 struct ieee80211_network *network = NULL; 5505 struct ieee80211_network *network = NULL;
5496 struct ipw_network_match match = { 5506 struct ipw_network_match match = {
5497 .network = priv->assoc_network 5507 .network = priv->assoc_network
@@ -5948,11 +5958,12 @@ static void ipw_adhoc_check(void *data)
5948 priv->assoc_request.beacon_interval); 5958 priv->assoc_request.beacon_interval);
5949} 5959}
5950 5960
5951static void ipw_bg_adhoc_check(void *data) 5961static void ipw_bg_adhoc_check(struct work_struct *work)
5952{ 5962{
5953 struct ipw_priv *priv = data; 5963 struct ipw_priv *priv =
5964 container_of(work, struct ipw_priv, adhoc_check.work);
5954 mutex_lock(&priv->mutex); 5965 mutex_lock(&priv->mutex);
5955 ipw_adhoc_check(data); 5966 ipw_adhoc_check(priv);
5956 mutex_unlock(&priv->mutex); 5967 mutex_unlock(&priv->mutex);
5957} 5968}
5958 5969
@@ -6299,19 +6310,26 @@ done:
6299 return err; 6310 return err;
6300} 6311}
6301 6312
6302static int ipw_request_passive_scan(struct ipw_priv *priv) { 6313static void ipw_request_passive_scan(struct work_struct *work)
6303 return ipw_request_scan_helper(priv, IW_SCAN_TYPE_PASSIVE); 6314{
6315 struct ipw_priv *priv =
6316 container_of(work, struct ipw_priv, request_passive_scan);
6317 ipw_request_scan_helper(priv, IW_SCAN_TYPE_PASSIVE);
6304} 6318}
6305 6319
6306static int ipw_request_scan(struct ipw_priv *priv) { 6320static void ipw_request_scan(struct work_struct *work)
6307 return ipw_request_scan_helper(priv, IW_SCAN_TYPE_ACTIVE); 6321{
6322 struct ipw_priv *priv =
6323 container_of(work, struct ipw_priv, request_scan.work);
6324 ipw_request_scan_helper(priv, IW_SCAN_TYPE_ACTIVE);
6308} 6325}
6309 6326
6310static void ipw_bg_abort_scan(void *data) 6327static void ipw_bg_abort_scan(struct work_struct *work)
6311{ 6328{
6312 struct ipw_priv *priv = data; 6329 struct ipw_priv *priv =
6330 container_of(work, struct ipw_priv, abort_scan);
6313 mutex_lock(&priv->mutex); 6331 mutex_lock(&priv->mutex);
6314 ipw_abort_scan(data); 6332 ipw_abort_scan(priv);
6315 mutex_unlock(&priv->mutex); 6333 mutex_unlock(&priv->mutex);
6316} 6334}
6317 6335
@@ -6920,8 +6938,8 @@ static int ipw_qos_association(struct ipw_priv *priv,
6920} 6938}
6921 6939
6922/* 6940/*
6923* handling the beaconing responces. if we get different QoS setting 6941* handling the beaconing responses. if we get different QoS setting
6924* of the network from the the associated setting adjust the QoS 6942* off the network from the associated setting, adjust the QoS
6925* setting 6943* setting
6926*/ 6944*/
6927static int ipw_qos_association_resp(struct ipw_priv *priv, 6945static int ipw_qos_association_resp(struct ipw_priv *priv,
@@ -7084,9 +7102,10 @@ static int ipw_qos_set_tx_queue_command(struct ipw_priv *priv,
7084/* 7102/*
7085* background support to run QoS activate functionality 7103* background support to run QoS activate functionality
7086*/ 7104*/
7087static void ipw_bg_qos_activate(void *data) 7105static void ipw_bg_qos_activate(struct work_struct *work)
7088{ 7106{
7089 struct ipw_priv *priv = data; 7107 struct ipw_priv *priv =
7108 container_of(work, struct ipw_priv, qos_activate);
7090 7109
7091 if (priv == NULL) 7110 if (priv == NULL)
7092 return; 7111 return;
@@ -7394,11 +7413,12 @@ static void ipw_roam(void *data)
7394 priv->status &= ~STATUS_ROAMING; 7413 priv->status &= ~STATUS_ROAMING;
7395} 7414}
7396 7415
7397static void ipw_bg_roam(void *data) 7416static void ipw_bg_roam(struct work_struct *work)
7398{ 7417{
7399 struct ipw_priv *priv = data; 7418 struct ipw_priv *priv =
7419 container_of(work, struct ipw_priv, roam);
7400 mutex_lock(&priv->mutex); 7420 mutex_lock(&priv->mutex);
7401 ipw_roam(data); 7421 ipw_roam(priv);
7402 mutex_unlock(&priv->mutex); 7422 mutex_unlock(&priv->mutex);
7403} 7423}
7404 7424
@@ -7479,8 +7499,8 @@ static int ipw_associate(void *data)
7479 &priv->request_scan, 7499 &priv->request_scan,
7480 SCAN_INTERVAL); 7500 SCAN_INTERVAL);
7481 else 7501 else
7482 queue_work(priv->workqueue, 7502 queue_delayed_work(priv->workqueue,
7483 &priv->request_scan); 7503 &priv->request_scan, 0);
7484 } 7504 }
7485 7505
7486 return 0; 7506 return 0;
@@ -7491,11 +7511,12 @@ static int ipw_associate(void *data)
7491 return 1; 7511 return 1;
7492} 7512}
7493 7513
7494static void ipw_bg_associate(void *data) 7514static void ipw_bg_associate(struct work_struct *work)
7495{ 7515{
7496 struct ipw_priv *priv = data; 7516 struct ipw_priv *priv =
7517 container_of(work, struct ipw_priv, associate);
7497 mutex_lock(&priv->mutex); 7518 mutex_lock(&priv->mutex);
7498 ipw_associate(data); 7519 ipw_associate(priv);
7499 mutex_unlock(&priv->mutex); 7520 mutex_unlock(&priv->mutex);
7500} 7521}
7501 7522
@@ -7656,7 +7677,8 @@ static void ipw_handle_data_packet_monitor(struct ipw_priv *priv,
7656 7677
7657 /* Big bitfield of all the fields we provide in radiotap */ 7678 /* Big bitfield of all the fields we provide in radiotap */
7658 ipw_rt->rt_hdr.it_present = 7679 ipw_rt->rt_hdr.it_present =
7659 ((1 << IEEE80211_RADIOTAP_FLAGS) | 7680 ((1 << IEEE80211_RADIOTAP_TSFT) |
7681 (1 << IEEE80211_RADIOTAP_FLAGS) |
7660 (1 << IEEE80211_RADIOTAP_RATE) | 7682 (1 << IEEE80211_RADIOTAP_RATE) |
7661 (1 << IEEE80211_RADIOTAP_CHANNEL) | 7683 (1 << IEEE80211_RADIOTAP_CHANNEL) |
7662 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | 7684 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) |
@@ -7665,10 +7687,14 @@ static void ipw_handle_data_packet_monitor(struct ipw_priv *priv,
7665 7687
7666 /* Zero the flags, we'll add to them as we go */ 7688 /* Zero the flags, we'll add to them as we go */
7667 ipw_rt->rt_flags = 0; 7689 ipw_rt->rt_flags = 0;
7668 ipw_rt->rt_tsf = 0ULL; 7690 ipw_rt->rt_tsf = (u64)(frame->parent_tsf[3] << 24 |
7691 frame->parent_tsf[2] << 16 |
7692 frame->parent_tsf[1] << 8 |
7693 frame->parent_tsf[0]);
7669 7694
7670 /* Convert signal to DBM */ 7695 /* Convert signal to DBM */
7671 ipw_rt->rt_dbmsignal = antsignal; 7696 ipw_rt->rt_dbmsignal = antsignal;
7697 ipw_rt->rt_dbmnoise = frame->noise;
7672 7698
7673 /* Convert the channel data and set the flags */ 7699 /* Convert the channel data and set the flags */
7674 ipw_rt->rt_channel = cpu_to_le16(ieee80211chan2mhz(received_channel)); 7700 ipw_rt->rt_channel = cpu_to_le16(ieee80211chan2mhz(received_channel));
@@ -7868,7 +7894,8 @@ static void ipw_handle_promiscuous_rx(struct ipw_priv *priv,
7868 7894
7869 /* Big bitfield of all the fields we provide in radiotap */ 7895 /* Big bitfield of all the fields we provide in radiotap */
7870 ipw_rt->rt_hdr.it_present = 7896 ipw_rt->rt_hdr.it_present =
7871 ((1 << IEEE80211_RADIOTAP_FLAGS) | 7897 ((1 << IEEE80211_RADIOTAP_TSFT) |
7898 (1 << IEEE80211_RADIOTAP_FLAGS) |
7872 (1 << IEEE80211_RADIOTAP_RATE) | 7899 (1 << IEEE80211_RADIOTAP_RATE) |
7873 (1 << IEEE80211_RADIOTAP_CHANNEL) | 7900 (1 << IEEE80211_RADIOTAP_CHANNEL) |
7874 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | 7901 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) |
@@ -7877,7 +7904,10 @@ static void ipw_handle_promiscuous_rx(struct ipw_priv *priv,
7877 7904
7878 /* Zero the flags, we'll add to them as we go */ 7905 /* Zero the flags, we'll add to them as we go */
7879 ipw_rt->rt_flags = 0; 7906 ipw_rt->rt_flags = 0;
7880 ipw_rt->rt_tsf = 0ULL; 7907 ipw_rt->rt_tsf = (u64)(frame->parent_tsf[3] << 24 |
7908 frame->parent_tsf[2] << 16 |
7909 frame->parent_tsf[1] << 8 |
7910 frame->parent_tsf[0]);
7881 7911
7882 /* Convert to DBM */ 7912 /* Convert to DBM */
7883 ipw_rt->rt_dbmsignal = signal; 7913 ipw_rt->rt_dbmsignal = signal;
@@ -8276,7 +8306,7 @@ static void ipw_rx(struct ipw_priv *priv)
8276 ("Notification: subtype=%02X flags=%02X size=%d\n", 8306 ("Notification: subtype=%02X flags=%02X size=%d\n",
8277 pkt->u.notification.subtype, 8307 pkt->u.notification.subtype,
8278 pkt->u.notification.flags, 8308 pkt->u.notification.flags,
8279 pkt->u.notification.size); 8309 le16_to_cpu(pkt->u.notification.size));
8280 ipw_rx_notification(priv, &pkt->u.notification); 8310 ipw_rx_notification(priv, &pkt->u.notification);
8281 break; 8311 break;
8282 } 8312 }
@@ -9410,7 +9440,7 @@ static int ipw_wx_set_scan(struct net_device *dev,
9410 9440
9411 IPW_DEBUG_WX("Start scan\n"); 9441 IPW_DEBUG_WX("Start scan\n");
9412 9442
9413 queue_work(priv->workqueue, &priv->request_scan); 9443 queue_delayed_work(priv->workqueue, &priv->request_scan, 0);
9414 9444
9415 return 0; 9445 return 0;
9416} 9446}
@@ -10547,11 +10577,12 @@ static void ipw_rf_kill(void *adapter)
10547 spin_unlock_irqrestore(&priv->lock, flags); 10577 spin_unlock_irqrestore(&priv->lock, flags);
10548} 10578}
10549 10579
10550static void ipw_bg_rf_kill(void *data) 10580static void ipw_bg_rf_kill(struct work_struct *work)
10551{ 10581{
10552 struct ipw_priv *priv = data; 10582 struct ipw_priv *priv =
10583 container_of(work, struct ipw_priv, rf_kill.work);
10553 mutex_lock(&priv->mutex); 10584 mutex_lock(&priv->mutex);
10554 ipw_rf_kill(data); 10585 ipw_rf_kill(priv);
10555 mutex_unlock(&priv->mutex); 10586 mutex_unlock(&priv->mutex);
10556} 10587}
10557 10588
@@ -10582,11 +10613,12 @@ static void ipw_link_up(struct ipw_priv *priv)
10582 queue_delayed_work(priv->workqueue, &priv->request_scan, HZ); 10613 queue_delayed_work(priv->workqueue, &priv->request_scan, HZ);
10583} 10614}
10584 10615
10585static void ipw_bg_link_up(void *data) 10616static void ipw_bg_link_up(struct work_struct *work)
10586{ 10617{
10587 struct ipw_priv *priv = data; 10618 struct ipw_priv *priv =
10619 container_of(work, struct ipw_priv, link_up);
10588 mutex_lock(&priv->mutex); 10620 mutex_lock(&priv->mutex);
10589 ipw_link_up(data); 10621 ipw_link_up(priv);
10590 mutex_unlock(&priv->mutex); 10622 mutex_unlock(&priv->mutex);
10591} 10623}
10592 10624
@@ -10606,15 +10638,16 @@ static void ipw_link_down(struct ipw_priv *priv)
10606 10638
10607 if (!(priv->status & STATUS_EXIT_PENDING)) { 10639 if (!(priv->status & STATUS_EXIT_PENDING)) {
10608 /* Queue up another scan... */ 10640 /* Queue up another scan... */
10609 queue_work(priv->workqueue, &priv->request_scan); 10641 queue_delayed_work(priv->workqueue, &priv->request_scan, 0);
10610 } 10642 }
10611} 10643}
10612 10644
10613static void ipw_bg_link_down(void *data) 10645static void ipw_bg_link_down(struct work_struct *work)
10614{ 10646{
10615 struct ipw_priv *priv = data; 10647 struct ipw_priv *priv =
10648 container_of(work, struct ipw_priv, link_down);
10616 mutex_lock(&priv->mutex); 10649 mutex_lock(&priv->mutex);
10617 ipw_link_down(data); 10650 ipw_link_down(priv);
10618 mutex_unlock(&priv->mutex); 10651 mutex_unlock(&priv->mutex);
10619} 10652}
10620 10653
@@ -10626,38 +10659,30 @@ static int ipw_setup_deferred_work(struct ipw_priv *priv)
10626 init_waitqueue_head(&priv->wait_command_queue); 10659 init_waitqueue_head(&priv->wait_command_queue);
10627 init_waitqueue_head(&priv->wait_state); 10660 init_waitqueue_head(&priv->wait_state);
10628 10661
10629 INIT_WORK(&priv->adhoc_check, ipw_bg_adhoc_check, priv); 10662 INIT_DELAYED_WORK(&priv->adhoc_check, ipw_bg_adhoc_check);
10630 INIT_WORK(&priv->associate, ipw_bg_associate, priv); 10663 INIT_WORK(&priv->associate, ipw_bg_associate);
10631 INIT_WORK(&priv->disassociate, ipw_bg_disassociate, priv); 10664 INIT_WORK(&priv->disassociate, ipw_bg_disassociate);
10632 INIT_WORK(&priv->system_config, ipw_system_config, priv); 10665 INIT_WORK(&priv->system_config, ipw_system_config);
10633 INIT_WORK(&priv->rx_replenish, ipw_bg_rx_queue_replenish, priv); 10666 INIT_WORK(&priv->rx_replenish, ipw_bg_rx_queue_replenish);
10634 INIT_WORK(&priv->adapter_restart, ipw_bg_adapter_restart, priv); 10667 INIT_WORK(&priv->adapter_restart, ipw_bg_adapter_restart);
10635 INIT_WORK(&priv->rf_kill, ipw_bg_rf_kill, priv); 10668 INIT_DELAYED_WORK(&priv->rf_kill, ipw_bg_rf_kill);
10636 INIT_WORK(&priv->up, (void (*)(void *))ipw_bg_up, priv); 10669 INIT_WORK(&priv->up, ipw_bg_up);
10637 INIT_WORK(&priv->down, (void (*)(void *))ipw_bg_down, priv); 10670 INIT_WORK(&priv->down, ipw_bg_down);
10638 INIT_WORK(&priv->request_scan, 10671 INIT_DELAYED_WORK(&priv->request_scan, ipw_request_scan);
10639 (void (*)(void *))ipw_request_scan, priv); 10672 INIT_WORK(&priv->request_passive_scan, ipw_request_passive_scan);
10640 INIT_WORK(&priv->request_passive_scan, 10673 INIT_DELAYED_WORK(&priv->gather_stats, ipw_bg_gather_stats);
10641 (void (*)(void *))ipw_request_passive_scan, priv); 10674 INIT_WORK(&priv->abort_scan, ipw_bg_abort_scan);
10642 INIT_WORK(&priv->gather_stats, 10675 INIT_WORK(&priv->roam, ipw_bg_roam);
10643 (void (*)(void *))ipw_bg_gather_stats, priv); 10676 INIT_DELAYED_WORK(&priv->scan_check, ipw_bg_scan_check);
10644 INIT_WORK(&priv->abort_scan, (void (*)(void *))ipw_bg_abort_scan, priv); 10677 INIT_WORK(&priv->link_up, ipw_bg_link_up);
10645 INIT_WORK(&priv->roam, ipw_bg_roam, priv); 10678 INIT_WORK(&priv->link_down, ipw_bg_link_down);
10646 INIT_WORK(&priv->scan_check, ipw_bg_scan_check, priv); 10679 INIT_DELAYED_WORK(&priv->led_link_on, ipw_bg_led_link_on);
10647 INIT_WORK(&priv->link_up, (void (*)(void *))ipw_bg_link_up, priv); 10680 INIT_DELAYED_WORK(&priv->led_link_off, ipw_bg_led_link_off);
10648 INIT_WORK(&priv->link_down, (void (*)(void *))ipw_bg_link_down, priv); 10681 INIT_DELAYED_WORK(&priv->led_act_off, ipw_bg_led_activity_off);
10649 INIT_WORK(&priv->led_link_on, (void (*)(void *))ipw_bg_led_link_on, 10682 INIT_WORK(&priv->merge_networks, ipw_merge_adhoc_network);
10650 priv);
10651 INIT_WORK(&priv->led_link_off, (void (*)(void *))ipw_bg_led_link_off,
10652 priv);
10653 INIT_WORK(&priv->led_act_off, (void (*)(void *))ipw_bg_led_activity_off,
10654 priv);
10655 INIT_WORK(&priv->merge_networks,
10656 (void (*)(void *))ipw_merge_adhoc_network, priv);
10657 10683
10658#ifdef CONFIG_IPW2200_QOS 10684#ifdef CONFIG_IPW2200_QOS
10659 INIT_WORK(&priv->qos_activate, (void (*)(void *))ipw_bg_qos_activate, 10685 INIT_WORK(&priv->qos_activate, ipw_bg_qos_activate);
10660 priv);
10661#endif /* CONFIG_IPW2200_QOS */ 10686#endif /* CONFIG_IPW2200_QOS */
10662 10687
10663 tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long)) 10688 tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long))
@@ -11129,14 +11154,13 @@ static int ipw_up(struct ipw_priv *priv)
11129 return -EIO; 11154 return -EIO;
11130 11155
11131 if (cmdlog && !priv->cmdlog) { 11156 if (cmdlog && !priv->cmdlog) {
11132 priv->cmdlog = kmalloc(sizeof(*priv->cmdlog) * cmdlog, 11157 priv->cmdlog = kcalloc(cmdlog, sizeof(*priv->cmdlog),
11133 GFP_KERNEL); 11158 GFP_KERNEL);
11134 if (priv->cmdlog == NULL) { 11159 if (priv->cmdlog == NULL) {
11135 IPW_ERROR("Error allocating %d command log entries.\n", 11160 IPW_ERROR("Error allocating %d command log entries.\n",
11136 cmdlog); 11161 cmdlog);
11137 return -ENOMEM; 11162 return -ENOMEM;
11138 } else { 11163 } else {
11139 memset(priv->cmdlog, 0, sizeof(*priv->cmdlog) * cmdlog);
11140 priv->cmdlog_len = cmdlog; 11164 priv->cmdlog_len = cmdlog;
11141 } 11165 }
11142 } 11166 }
@@ -11190,7 +11214,8 @@ static int ipw_up(struct ipw_priv *priv)
11190 11214
11191 /* If configure to try and auto-associate, kick 11215 /* If configure to try and auto-associate, kick
11192 * off a scan. */ 11216 * off a scan. */
11193 queue_work(priv->workqueue, &priv->request_scan); 11217 queue_delayed_work(priv->workqueue,
11218 &priv->request_scan, 0);
11194 11219
11195 return 0; 11220 return 0;
11196 } 11221 }
@@ -11211,11 +11236,12 @@ static int ipw_up(struct ipw_priv *priv)
11211 return -EIO; 11236 return -EIO;
11212} 11237}
11213 11238
11214static void ipw_bg_up(void *data) 11239static void ipw_bg_up(struct work_struct *work)
11215{ 11240{
11216 struct ipw_priv *priv = data; 11241 struct ipw_priv *priv =
11242 container_of(work, struct ipw_priv, up);
11217 mutex_lock(&priv->mutex); 11243 mutex_lock(&priv->mutex);
11218 ipw_up(data); 11244 ipw_up(priv);
11219 mutex_unlock(&priv->mutex); 11245 mutex_unlock(&priv->mutex);
11220} 11246}
11221 11247
@@ -11282,11 +11308,12 @@ static void ipw_down(struct ipw_priv *priv)
11282 ipw_led_radio_off(priv); 11308 ipw_led_radio_off(priv);
11283} 11309}
11284 11310
11285static void ipw_bg_down(void *data) 11311static void ipw_bg_down(struct work_struct *work)
11286{ 11312{
11287 struct ipw_priv *priv = data; 11313 struct ipw_priv *priv =
11314 container_of(work, struct ipw_priv, down);
11288 mutex_lock(&priv->mutex); 11315 mutex_lock(&priv->mutex);
11289 ipw_down(data); 11316 ipw_down(priv);
11290 mutex_unlock(&priv->mutex); 11317 mutex_unlock(&priv->mutex);
11291} 11318}
11292 11319
@@ -11727,12 +11754,18 @@ static int ipw_pci_resume(struct pci_dev *pdev)
11727{ 11754{
11728 struct ipw_priv *priv = pci_get_drvdata(pdev); 11755 struct ipw_priv *priv = pci_get_drvdata(pdev);
11729 struct net_device *dev = priv->net_dev; 11756 struct net_device *dev = priv->net_dev;
11757 int err;
11730 u32 val; 11758 u32 val;
11731 11759
11732 printk(KERN_INFO "%s: Coming out of suspend...\n", dev->name); 11760 printk(KERN_INFO "%s: Coming out of suspend...\n", dev->name);
11733 11761
11734 pci_set_power_state(pdev, PCI_D0); 11762 pci_set_power_state(pdev, PCI_D0);
11735 pci_enable_device(pdev); 11763 err = pci_enable_device(pdev);
11764 if (err) {
11765 printk(KERN_ERR "%s: pci_enable_device failed on resume\n",
11766 dev->name);
11767 return err;
11768 }
11736 pci_restore_state(pdev); 11769 pci_restore_state(pdev);
11737 11770
11738 /* 11771 /*
diff --git a/drivers/net/wireless/ipw2200.h b/drivers/net/wireless/ipw2200.h
index dad5eedefbf1..626a240a87d8 100644
--- a/drivers/net/wireless/ipw2200.h
+++ b/drivers/net/wireless/ipw2200.h
@@ -1290,21 +1290,21 @@ struct ipw_priv {
1290 1290
1291 struct workqueue_struct *workqueue; 1291 struct workqueue_struct *workqueue;
1292 1292
1293 struct work_struct adhoc_check; 1293 struct delayed_work adhoc_check;
1294 struct work_struct associate; 1294 struct work_struct associate;
1295 struct work_struct disassociate; 1295 struct work_struct disassociate;
1296 struct work_struct system_config; 1296 struct work_struct system_config;
1297 struct work_struct rx_replenish; 1297 struct work_struct rx_replenish;
1298 struct work_struct request_scan; 1298 struct delayed_work request_scan;
1299 struct work_struct request_passive_scan; 1299 struct work_struct request_passive_scan;
1300 struct work_struct adapter_restart; 1300 struct work_struct adapter_restart;
1301 struct work_struct rf_kill; 1301 struct delayed_work rf_kill;
1302 struct work_struct up; 1302 struct work_struct up;
1303 struct work_struct down; 1303 struct work_struct down;
1304 struct work_struct gather_stats; 1304 struct delayed_work gather_stats;
1305 struct work_struct abort_scan; 1305 struct work_struct abort_scan;
1306 struct work_struct roam; 1306 struct work_struct roam;
1307 struct work_struct scan_check; 1307 struct delayed_work scan_check;
1308 struct work_struct link_up; 1308 struct work_struct link_up;
1309 struct work_struct link_down; 1309 struct work_struct link_down;
1310 1310
@@ -1319,9 +1319,9 @@ struct ipw_priv {
1319 u32 led_ofdm_on; 1319 u32 led_ofdm_on;
1320 u32 led_ofdm_off; 1320 u32 led_ofdm_off;
1321 1321
1322 struct work_struct led_link_on; 1322 struct delayed_work led_link_on;
1323 struct work_struct led_link_off; 1323 struct delayed_work led_link_off;
1324 struct work_struct led_act_off; 1324 struct delayed_work led_act_off;
1325 struct work_struct merge_networks; 1325 struct work_struct merge_networks;
1326 1326
1327 struct ipw_cmd_log *cmdlog; 1327 struct ipw_cmd_log *cmdlog;
diff --git a/drivers/net/wireless/netwave_cs.c b/drivers/net/wireless/netwave_cs.c
index 6714e0dfa8d6..644b4741ef74 100644
--- a/drivers/net/wireless/netwave_cs.c
+++ b/drivers/net/wireless/netwave_cs.c
@@ -735,10 +735,7 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
735static int netwave_pcmcia_config(struct pcmcia_device *link) { 735static int netwave_pcmcia_config(struct pcmcia_device *link) {
736 struct net_device *dev = link->priv; 736 struct net_device *dev = link->priv;
737 netwave_private *priv = netdev_priv(dev); 737 netwave_private *priv = netdev_priv(dev);
738 tuple_t tuple;
739 cisparse_t parse;
740 int i, j, last_ret, last_fn; 738 int i, j, last_ret, last_fn;
741 u_char buf[64];
742 win_req_t req; 739 win_req_t req;
743 memreq_t mem; 740 memreq_t mem;
744 u_char __iomem *ramBase = NULL; 741 u_char __iomem *ramBase = NULL;
@@ -746,21 +743,6 @@ static int netwave_pcmcia_config(struct pcmcia_device *link) {
746 DEBUG(0, "netwave_pcmcia_config(0x%p)\n", link); 743 DEBUG(0, "netwave_pcmcia_config(0x%p)\n", link);
747 744
748 /* 745 /*
749 This reads the card's CONFIG tuple to find its configuration
750 registers.
751 */
752 tuple.Attributes = 0;
753 tuple.TupleData = (cisdata_t *) buf;
754 tuple.TupleDataMax = 64;
755 tuple.TupleOffset = 0;
756 tuple.DesiredTuple = CISTPL_CONFIG;
757 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
758 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
759 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
760 link->conf.ConfigBase = parse.config.base;
761 link->conf.Present = parse.config.rmask[0];
762
763 /*
764 * Try allocating IO ports. This tries a few fixed addresses. 746 * Try allocating IO ports. This tries a few fixed addresses.
765 * If you want, you can also read the card's config table to 747 * If you want, you can also read the card's config table to
766 * pick addresses -- see the serial driver for an example. 748 * pick addresses -- see the serial driver for an example.
diff --git a/drivers/net/wireless/orinoco.c b/drivers/net/wireless/orinoco.c
index 336cabac13b3..936c888e03e1 100644
--- a/drivers/net/wireless/orinoco.c
+++ b/drivers/net/wireless/orinoco.c
@@ -980,9 +980,11 @@ static void print_linkstatus(struct net_device *dev, u16 status)
980} 980}
981 981
982/* Search scan results for requested BSSID, join it if found */ 982/* Search scan results for requested BSSID, join it if found */
983static void orinoco_join_ap(struct net_device *dev) 983static void orinoco_join_ap(struct work_struct *work)
984{ 984{
985 struct orinoco_private *priv = netdev_priv(dev); 985 struct orinoco_private *priv =
986 container_of(work, struct orinoco_private, join_work);
987 struct net_device *dev = priv->ndev;
986 struct hermes *hw = &priv->hw; 988 struct hermes *hw = &priv->hw;
987 int err; 989 int err;
988 unsigned long flags; 990 unsigned long flags;
@@ -1055,9 +1057,11 @@ static void orinoco_join_ap(struct net_device *dev)
1055} 1057}
1056 1058
1057/* Send new BSSID to userspace */ 1059/* Send new BSSID to userspace */
1058static void orinoco_send_wevents(struct net_device *dev) 1060static void orinoco_send_wevents(struct work_struct *work)
1059{ 1061{
1060 struct orinoco_private *priv = netdev_priv(dev); 1062 struct orinoco_private *priv =
1063 container_of(work, struct orinoco_private, wevent_work);
1064 struct net_device *dev = priv->ndev;
1061 struct hermes *hw = &priv->hw; 1065 struct hermes *hw = &priv->hw;
1062 union iwreq_data wrqu; 1066 union iwreq_data wrqu;
1063 int err; 1067 int err;
@@ -1864,9 +1868,11 @@ __orinoco_set_multicast_list(struct net_device *dev)
1864 1868
1865/* This must be called from user context, without locks held - use 1869/* This must be called from user context, without locks held - use
1866 * schedule_work() */ 1870 * schedule_work() */
1867static void orinoco_reset(struct net_device *dev) 1871static void orinoco_reset(struct work_struct *work)
1868{ 1872{
1869 struct orinoco_private *priv = netdev_priv(dev); 1873 struct orinoco_private *priv =
1874 container_of(work, struct orinoco_private, reset_work);
1875 struct net_device *dev = priv->ndev;
1870 struct hermes *hw = &priv->hw; 1876 struct hermes *hw = &priv->hw;
1871 int err; 1877 int err;
1872 unsigned long flags; 1878 unsigned long flags;
@@ -2434,9 +2440,9 @@ struct net_device *alloc_orinocodev(int sizeof_card,
2434 priv->hw_unavailable = 1; /* orinoco_init() must clear this 2440 priv->hw_unavailable = 1; /* orinoco_init() must clear this
2435 * before anything else touches the 2441 * before anything else touches the
2436 * hardware */ 2442 * hardware */
2437 INIT_WORK(&priv->reset_work, (void (*)(void *))orinoco_reset, dev); 2443 INIT_WORK(&priv->reset_work, orinoco_reset);
2438 INIT_WORK(&priv->join_work, (void (*)(void *))orinoco_join_ap, dev); 2444 INIT_WORK(&priv->join_work, orinoco_join_ap);
2439 INIT_WORK(&priv->wevent_work, (void (*)(void *))orinoco_send_wevents, dev); 2445 INIT_WORK(&priv->wevent_work, orinoco_send_wevents);
2440 2446
2441 netif_carrier_off(dev); 2447 netif_carrier_off(dev);
2442 priv->last_linkstatus = 0xffff; 2448 priv->last_linkstatus = 0xffff;
@@ -3608,7 +3614,7 @@ static int orinoco_ioctl_reset(struct net_device *dev,
3608 printk(KERN_DEBUG "%s: Forcing reset!\n", dev->name); 3614 printk(KERN_DEBUG "%s: Forcing reset!\n", dev->name);
3609 3615
3610 /* Firmware reset */ 3616 /* Firmware reset */
3611 orinoco_reset(dev); 3617 orinoco_reset(&priv->reset_work);
3612 } else { 3618 } else {
3613 printk(KERN_DEBUG "%s: Force scheduling reset!\n", dev->name); 3619 printk(KERN_DEBUG "%s: Force scheduling reset!\n", dev->name);
3614 3620
@@ -4154,7 +4160,7 @@ static int orinoco_ioctl_commit(struct net_device *dev,
4154 return 0; 4160 return 0;
4155 4161
4156 if (priv->broken_disableport) { 4162 if (priv->broken_disableport) {
4157 orinoco_reset(dev); 4163 orinoco_reset(&priv->reset_work);
4158 return 0; 4164 return 0;
4159 } 4165 }
4160 4166
diff --git a/drivers/net/wireless/orinoco_cs.c b/drivers/net/wireless/orinoco_cs.c
index bc14689cbf24..d08ae8d2726c 100644
--- a/drivers/net/wireless/orinoco_cs.c
+++ b/drivers/net/wireless/orinoco_cs.c
@@ -178,21 +178,6 @@ orinoco_cs_config(struct pcmcia_device *link)
178 cisparse_t parse; 178 cisparse_t parse;
179 void __iomem *mem; 179 void __iomem *mem;
180 180
181 /*
182 * This reads the card's CONFIG tuple to find its
183 * configuration registers.
184 */
185 tuple.DesiredTuple = CISTPL_CONFIG;
186 tuple.Attributes = 0;
187 tuple.TupleData = buf;
188 tuple.TupleDataMax = sizeof(buf);
189 tuple.TupleOffset = 0;
190 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
191 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
192 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
193 link->conf.ConfigBase = parse.config.base;
194 link->conf.Present = parse.config.rmask[0];
195
196 /* Look up the current Vcc */ 181 /* Look up the current Vcc */
197 CS_CHECK(GetConfigurationInfo, 182 CS_CHECK(GetConfigurationInfo,
198 pcmcia_get_configuration_info(link, &conf)); 183 pcmcia_get_configuration_info(link, &conf));
@@ -211,6 +196,10 @@ orinoco_cs_config(struct pcmcia_device *link)
211 * and most client drivers will only use the CIS to fill in 196 * and most client drivers will only use the CIS to fill in
212 * implementation-defined details. 197 * implementation-defined details.
213 */ 198 */
199 tuple.Attributes = 0;
200 tuple.TupleData = buf;
201 tuple.TupleDataMax = sizeof(buf);
202 tuple.TupleOffset = 0;
214 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 203 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
215 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 204 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
216 while (1) { 205 while (1) {
diff --git a/drivers/net/wireless/orinoco_pci.h b/drivers/net/wireless/orinoco_pci.h
index be1abea4b64f..f4e5e06760c1 100644
--- a/drivers/net/wireless/orinoco_pci.h
+++ b/drivers/net/wireless/orinoco_pci.h
@@ -60,7 +60,12 @@ static int orinoco_pci_resume(struct pci_dev *pdev)
60 int err; 60 int err;
61 61
62 pci_set_power_state(pdev, 0); 62 pci_set_power_state(pdev, 0);
63 pci_enable_device(pdev); 63 err = pci_enable_device(pdev);
64 if (err) {
65 printk(KERN_ERR "%s: pci_enable_device failed on resume\n",
66 dev->name);
67 return err;
68 }
64 pci_restore_state(pdev); 69 pci_restore_state(pdev);
65 70
66 err = request_irq(pdev->irq, orinoco_interrupt, IRQF_SHARED, 71 err = request_irq(pdev->irq, orinoco_interrupt, IRQF_SHARED,
diff --git a/drivers/net/wireless/prism54/isl_38xx.c b/drivers/net/wireless/prism54/isl_38xx.c
index 23deee69974b..02fc67bccbd0 100644
--- a/drivers/net/wireless/prism54/isl_38xx.c
+++ b/drivers/net/wireless/prism54/isl_38xx.c
@@ -1,5 +1,4 @@
1/* 1/*
2 *
3 * Copyright (C) 2002 Intersil Americas Inc. 2 * Copyright (C) 2002 Intersil Americas Inc.
4 * Copyright (C) 2003-2004 Luis R. Rodriguez <mcgrof@ruslug.rutgers.edu>_ 3 * Copyright (C) 2003-2004 Luis R. Rodriguez <mcgrof@ruslug.rutgers.edu>_
5 * 4 *
@@ -38,7 +37,7 @@
38 * isl38xx_disable_interrupts - disable all interrupts 37 * isl38xx_disable_interrupts - disable all interrupts
39 * @device: pci memory base address 38 * @device: pci memory base address
40 * 39 *
41 * Instructs the device to disable all interrupt reporting by asserting 40 * Instructs the device to disable all interrupt reporting by asserting
42 * the IRQ line. New events may still show up in the interrupt identification 41 * the IRQ line. New events may still show up in the interrupt identification
43 * register located at offset %ISL38XX_INT_IDENT_REG. 42 * register located at offset %ISL38XX_INT_IDENT_REG.
44 */ 43 */
@@ -204,17 +203,19 @@ isl38xx_interface_reset(void __iomem *device_base, dma_addr_t host_address)
204 /* enable the interrupt for detecting initialization */ 203 /* enable the interrupt for detecting initialization */
205 204
206 /* Note: Do not enable other interrupts here. We want the 205 /* Note: Do not enable other interrupts here. We want the
207 * device to have come up first 100% before allowing any other 206 * device to have come up first 100% before allowing any other
208 * interrupts. */ 207 * interrupts. */
209 isl38xx_w32_flush(device_base, ISL38XX_INT_IDENT_INIT, ISL38XX_INT_EN_REG); 208 isl38xx_w32_flush(device_base, ISL38XX_INT_IDENT_INIT, ISL38XX_INT_EN_REG);
210 udelay(ISL38XX_WRITEIO_DELAY); /* allow complete full reset */ 209 udelay(ISL38XX_WRITEIO_DELAY); /* allow complete full reset */
211} 210}
212 211
213void 212void
214isl38xx_enable_common_interrupts(void __iomem *device_base) { 213isl38xx_enable_common_interrupts(void __iomem *device_base)
214{
215 u32 reg; 215 u32 reg;
216 reg = ( ISL38XX_INT_IDENT_UPDATE | 216
217 ISL38XX_INT_IDENT_SLEEP | ISL38XX_INT_IDENT_WAKEUP); 217 reg = ISL38XX_INT_IDENT_UPDATE | ISL38XX_INT_IDENT_SLEEP |
218 ISL38XX_INT_IDENT_WAKEUP;
218 isl38xx_w32_flush(device_base, reg, ISL38XX_INT_EN_REG); 219 isl38xx_w32_flush(device_base, reg, ISL38XX_INT_EN_REG);
219 udelay(ISL38XX_WRITEIO_DELAY); 220 udelay(ISL38XX_WRITEIO_DELAY);
220} 221}
@@ -234,23 +235,21 @@ isl38xx_in_queue(isl38xx_control_block *cb, int queue)
234 /* send queues */ 235 /* send queues */
235 case ISL38XX_CB_TX_MGMTQ: 236 case ISL38XX_CB_TX_MGMTQ:
236 BUG_ON(delta > ISL38XX_CB_MGMT_QSIZE); 237 BUG_ON(delta > ISL38XX_CB_MGMT_QSIZE);
238
237 case ISL38XX_CB_TX_DATA_LQ: 239 case ISL38XX_CB_TX_DATA_LQ:
238 case ISL38XX_CB_TX_DATA_HQ: 240 case ISL38XX_CB_TX_DATA_HQ:
239 BUG_ON(delta > ISL38XX_CB_TX_QSIZE); 241 BUG_ON(delta > ISL38XX_CB_TX_QSIZE);
240 return delta; 242 return delta;
241 break;
242 243
243 /* receive queues */ 244 /* receive queues */
244 case ISL38XX_CB_RX_MGMTQ: 245 case ISL38XX_CB_RX_MGMTQ:
245 BUG_ON(delta > ISL38XX_CB_MGMT_QSIZE); 246 BUG_ON(delta > ISL38XX_CB_MGMT_QSIZE);
246 return ISL38XX_CB_MGMT_QSIZE - delta; 247 return ISL38XX_CB_MGMT_QSIZE - delta;
247 break;
248 248
249 case ISL38XX_CB_RX_DATA_LQ: 249 case ISL38XX_CB_RX_DATA_LQ:
250 case ISL38XX_CB_RX_DATA_HQ: 250 case ISL38XX_CB_RX_DATA_HQ:
251 BUG_ON(delta > ISL38XX_CB_RX_QSIZE); 251 BUG_ON(delta > ISL38XX_CB_RX_QSIZE);
252 return ISL38XX_CB_RX_QSIZE - delta; 252 return ISL38XX_CB_RX_QSIZE - delta;
253 break;
254 } 253 }
255 BUG(); 254 BUG();
256 return 0; 255 return 0;
diff --git a/drivers/net/wireless/prism54/isl_38xx.h b/drivers/net/wireless/prism54/isl_38xx.h
index 8af20980af8d..3fadcb6f5297 100644
--- a/drivers/net/wireless/prism54/isl_38xx.h
+++ b/drivers/net/wireless/prism54/isl_38xx.h
@@ -1,5 +1,4 @@
1/* 1/*
2 *
3 * Copyright (C) 2002 Intersil Americas Inc. 2 * Copyright (C) 2002 Intersil Americas Inc.
4 * 3 *
5 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
@@ -67,10 +66,10 @@
67 * @base: (host) memory base address of the device 66 * @base: (host) memory base address of the device
68 * @val: 32bit value (host order) to write 67 * @val: 32bit value (host order) to write
69 * @offset: byte offset into @base to write value to 68 * @offset: byte offset into @base to write value to
70 * 69 *
71 * This helper takes care of writing a 32bit datum to the 70 * This helper takes care of writing a 32bit datum to the
72 * specified offset into the device's pci memory space, and making sure 71 * specified offset into the device's pci memory space, and making sure
73 * the pci memory buffers get flushed by performing one harmless read 72 * the pci memory buffers get flushed by performing one harmless read
74 * from the %ISL38XX_PCI_POSTING_FLUSH offset. 73 * from the %ISL38XX_PCI_POSTING_FLUSH offset.
75 */ 74 */
76static inline void 75static inline void
diff --git a/drivers/net/wireless/prism54/isl_ioctl.c b/drivers/net/wireless/prism54/isl_ioctl.c
index 286325ca3293..96606ed10076 100644
--- a/drivers/net/wireless/prism54/isl_ioctl.c
+++ b/drivers/net/wireless/prism54/isl_ioctl.c
@@ -1,5 +1,4 @@
1/* 1/*
2 *
3 * Copyright (C) 2002 Intersil Americas Inc. 2 * Copyright (C) 2002 Intersil Americas Inc.
4 * (C) 2003,2004 Aurelien Alleaume <slts@free.fr> 3 * (C) 2003,2004 Aurelien Alleaume <slts@free.fr>
5 * (C) 2003 Herbert Valerio Riedel <hvr@gnu.org> 4 * (C) 2003 Herbert Valerio Riedel <hvr@gnu.org>
@@ -55,12 +54,12 @@ static const unsigned char scan_rate_list[] = { 2, 4, 11, 22,
55 * prism54_mib_mode_helper - MIB change mode helper function 54 * prism54_mib_mode_helper - MIB change mode helper function
56 * @mib: the &struct islpci_mib object to modify 55 * @mib: the &struct islpci_mib object to modify
57 * @iw_mode: new mode (%IW_MODE_*) 56 * @iw_mode: new mode (%IW_MODE_*)
58 * 57 *
59 * This is a helper function, hence it does not lock. Make sure 58 * This is a helper function, hence it does not lock. Make sure
60 * caller deals with locking *if* necessary. This function sets the 59 * caller deals with locking *if* necessary. This function sets the
61 * mode-dependent mib values and does the mapping of the Linux 60 * mode-dependent mib values and does the mapping of the Linux
62 * Wireless API modes to Device firmware modes. It also checks for 61 * Wireless API modes to Device firmware modes. It also checks for
63 * correct valid Linux wireless modes. 62 * correct valid Linux wireless modes.
64 */ 63 */
65static int 64static int
66prism54_mib_mode_helper(islpci_private *priv, u32 iw_mode) 65prism54_mib_mode_helper(islpci_private *priv, u32 iw_mode)
@@ -118,7 +117,7 @@ prism54_mib_mode_helper(islpci_private *priv, u32 iw_mode)
118 * 117 *
119 * this function initializes the struct given as @mib with defaults, 118 * this function initializes the struct given as @mib with defaults,
120 * of which many are retrieved from the global module parameter 119 * of which many are retrieved from the global module parameter
121 * variables. 120 * variables.
122 */ 121 */
123 122
124void 123void
@@ -134,7 +133,7 @@ prism54_mib_init(islpci_private *priv)
134 authen = CARD_DEFAULT_AUTHEN; 133 authen = CARD_DEFAULT_AUTHEN;
135 wep = CARD_DEFAULT_WEP; 134 wep = CARD_DEFAULT_WEP;
136 filter = CARD_DEFAULT_FILTER; /* (0) Do not filter un-encrypted data */ 135 filter = CARD_DEFAULT_FILTER; /* (0) Do not filter un-encrypted data */
137 dot1x = CARD_DEFAULT_DOT1X; 136 dot1x = CARD_DEFAULT_DOT1X;
138 mlme = CARD_DEFAULT_MLME_MODE; 137 mlme = CARD_DEFAULT_MLME_MODE;
139 conformance = CARD_DEFAULT_CONFORMANCE; 138 conformance = CARD_DEFAULT_CONFORMANCE;
140 power = 127; 139 power = 127;
@@ -158,8 +157,9 @@ prism54_mib_init(islpci_private *priv)
158 * schedule_work(), thus we can as well use sleeping semaphore 157 * schedule_work(), thus we can as well use sleeping semaphore
159 * locking */ 158 * locking */
160void 159void
161prism54_update_stats(islpci_private *priv) 160prism54_update_stats(struct work_struct *work)
162{ 161{
162 islpci_private *priv = container_of(work, islpci_private, stats_work);
163 char *data; 163 char *data;
164 int j; 164 int j;
165 struct obj_bss bss, *bss2; 165 struct obj_bss bss, *bss2;
@@ -228,7 +228,7 @@ prism54_get_wireless_stats(struct net_device *ndev)
228 } else 228 } else
229 priv->iwstatistics.qual.updated = 0; 229 priv->iwstatistics.qual.updated = 0;
230 230
231 /* Update our wireless stats, but do not schedule to often 231 /* Update our wireless stats, but do not schedule to often
232 * (max 1 HZ) */ 232 * (max 1 HZ) */
233 if ((priv->stats_timestamp == 0) || 233 if ((priv->stats_timestamp == 0) ||
234 time_after(jiffies, priv->stats_timestamp + 1 * HZ)) { 234 time_after(jiffies, priv->stats_timestamp + 1 * HZ)) {
@@ -705,7 +705,7 @@ prism54_get_scan(struct net_device *ndev, struct iw_request_info *info,
705 * Starting with WE-17, the buffer can be as big as needed. 705 * Starting with WE-17, the buffer can be as big as needed.
706 * But the device won't repport anything if you change the value 706 * But the device won't repport anything if you change the value
707 * of IWMAX_BSS=24. */ 707 * of IWMAX_BSS=24. */
708 708
709 rvalue |= mgt_get_request(priv, DOT11_OID_BSSLIST, 0, NULL, &r); 709 rvalue |= mgt_get_request(priv, DOT11_OID_BSSLIST, 0, NULL, &r);
710 bsslist = r.ptr; 710 bsslist = r.ptr;
711 711
@@ -785,7 +785,7 @@ prism54_get_essid(struct net_device *ndev, struct iw_request_info *info,
785 return rvalue; 785 return rvalue;
786} 786}
787 787
788/* Provides no functionality, just completes the ioctl. In essence this is a 788/* Provides no functionality, just completes the ioctl. In essence this is a
789 * just a cosmetic ioctl. 789 * just a cosmetic ioctl.
790 */ 790 */
791static int 791static int
@@ -1104,7 +1104,7 @@ prism54_set_encode(struct net_device *ndev, struct iw_request_info *info,
1104 &key); 1104 &key);
1105 } 1105 }
1106 /* 1106 /*
1107 * If a valid key is set, encryption should be enabled 1107 * If a valid key is set, encryption should be enabled
1108 * (user may turn it off later). 1108 * (user may turn it off later).
1109 * This is also how "iwconfig ethX key on" works 1109 * This is also how "iwconfig ethX key on" works
1110 */ 1110 */
@@ -1126,7 +1126,7 @@ prism54_set_encode(struct net_device *ndev, struct iw_request_info *info,
1126 } 1126 }
1127 /* now read the flags */ 1127 /* now read the flags */
1128 if (dwrq->flags & IW_ENCODE_DISABLED) { 1128 if (dwrq->flags & IW_ENCODE_DISABLED) {
1129 /* Encoding disabled, 1129 /* Encoding disabled,
1130 * authen = DOT11_AUTH_OS; 1130 * authen = DOT11_AUTH_OS;
1131 * invoke = 0; 1131 * invoke = 0;
1132 * exunencrypt = 0; */ 1132 * exunencrypt = 0; */
@@ -1214,7 +1214,7 @@ prism54_get_txpower(struct net_device *ndev, struct iw_request_info *info,
1214 vwrq->value = (s32) r.u / 4; 1214 vwrq->value = (s32) r.u / 4;
1215 vwrq->fixed = 1; 1215 vwrq->fixed = 1;
1216 /* radio is not turned of 1216 /* radio is not turned of
1217 * btw: how is possible to turn off only the radio 1217 * btw: how is possible to turn off only the radio
1218 */ 1218 */
1219 vwrq->disabled = 0; 1219 vwrq->disabled = 0;
1220 1220
@@ -2141,11 +2141,9 @@ prism54_wpa_bss_ie_add(islpci_private *priv, u8 *bssid,
2141 struct islpci_bss_wpa_ie, list); 2141 struct islpci_bss_wpa_ie, list);
2142 list_del(&bss->list); 2142 list_del(&bss->list);
2143 } else { 2143 } else {
2144 bss = kmalloc(sizeof (*bss), GFP_ATOMIC); 2144 bss = kzalloc(sizeof (*bss), GFP_ATOMIC);
2145 if (bss != NULL) { 2145 if (bss != NULL)
2146 priv->num_bss_wpa++; 2146 priv->num_bss_wpa++;
2147 memset(bss, 0, sizeof (*bss));
2148 }
2149 } 2147 }
2150 if (bss != NULL) { 2148 if (bss != NULL) {
2151 memcpy(bss->bssid, bssid, ETH_ALEN); 2149 memcpy(bss->bssid, bssid, ETH_ALEN);
@@ -2354,17 +2352,17 @@ prism54_process_trap_helper(islpci_private *priv, enum oid_num_t oid,
2354 handle_request(priv, mlme, oid); 2352 handle_request(priv, mlme, oid);
2355 send_formatted_event(priv, "Authenticate request (ex)", mlme, 1); 2353 send_formatted_event(priv, "Authenticate request (ex)", mlme, 1);
2356 2354
2357 if (priv->iw_mode != IW_MODE_MASTER 2355 if (priv->iw_mode != IW_MODE_MASTER
2358 && mlmeex->state != DOT11_STATE_AUTHING) 2356 && mlmeex->state != DOT11_STATE_AUTHING)
2359 break; 2357 break;
2360 2358
2361 confirm = kmalloc(sizeof(struct obj_mlmeex) + 6, GFP_ATOMIC); 2359 confirm = kmalloc(sizeof(struct obj_mlmeex) + 6, GFP_ATOMIC);
2362 2360
2363 if (!confirm) 2361 if (!confirm)
2364 break; 2362 break;
2365 2363
2366 memcpy(&confirm->address, mlmeex->address, ETH_ALEN); 2364 memcpy(&confirm->address, mlmeex->address, ETH_ALEN);
2367 printk(KERN_DEBUG "Authenticate from: address:\t%02x:%02x:%02x:%02x:%02x:%02x\n", 2365 printk(KERN_DEBUG "Authenticate from: address:\t%02x:%02x:%02x:%02x:%02x:%02x\n",
2368 mlmeex->address[0], 2366 mlmeex->address[0],
2369 mlmeex->address[1], 2367 mlmeex->address[1],
2370 mlmeex->address[2], 2368 mlmeex->address[2],
@@ -2398,10 +2396,10 @@ prism54_process_trap_helper(islpci_private *priv, enum oid_num_t oid,
2398 handle_request(priv, mlme, oid); 2396 handle_request(priv, mlme, oid);
2399 send_formatted_event(priv, "Associate request (ex)", mlme, 1); 2397 send_formatted_event(priv, "Associate request (ex)", mlme, 1);
2400 2398
2401 if (priv->iw_mode != IW_MODE_MASTER 2399 if (priv->iw_mode != IW_MODE_MASTER
2402 && mlmeex->state != DOT11_STATE_ASSOCING) 2400 && mlmeex->state != DOT11_STATE_ASSOCING)
2403 break; 2401 break;
2404 2402
2405 confirm = kmalloc(sizeof(struct obj_mlmeex), GFP_ATOMIC); 2403 confirm = kmalloc(sizeof(struct obj_mlmeex), GFP_ATOMIC);
2406 2404
2407 if (!confirm) 2405 if (!confirm)
@@ -2417,7 +2415,7 @@ prism54_process_trap_helper(islpci_private *priv, enum oid_num_t oid,
2417 2415
2418 if (!wpa_ie_len) { 2416 if (!wpa_ie_len) {
2419 printk(KERN_DEBUG "No WPA IE found from " 2417 printk(KERN_DEBUG "No WPA IE found from "
2420 "address:\t%02x:%02x:%02x:%02x:%02x:%02x\n", 2418 "address:\t%02x:%02x:%02x:%02x:%02x:%02x\n",
2421 mlmeex->address[0], 2419 mlmeex->address[0],
2422 mlmeex->address[1], 2420 mlmeex->address[1],
2423 mlmeex->address[2], 2421 mlmeex->address[2],
@@ -2435,14 +2433,14 @@ prism54_process_trap_helper(islpci_private *priv, enum oid_num_t oid,
2435 mgt_set_varlen(priv, oid, confirm, wpa_ie_len); 2433 mgt_set_varlen(priv, oid, confirm, wpa_ie_len);
2436 2434
2437 kfree(confirm); 2435 kfree(confirm);
2438 2436
2439 break; 2437 break;
2440 2438
2441 case DOT11_OID_REASSOCIATEEX: 2439 case DOT11_OID_REASSOCIATEEX:
2442 handle_request(priv, mlme, oid); 2440 handle_request(priv, mlme, oid);
2443 send_formatted_event(priv, "Reassociate request (ex)", mlme, 1); 2441 send_formatted_event(priv, "Reassociate request (ex)", mlme, 1);
2444 2442
2445 if (priv->iw_mode != IW_MODE_MASTER 2443 if (priv->iw_mode != IW_MODE_MASTER
2446 && mlmeex->state != DOT11_STATE_ASSOCING) 2444 && mlmeex->state != DOT11_STATE_ASSOCING)
2447 break; 2445 break;
2448 2446
@@ -2461,7 +2459,7 @@ prism54_process_trap_helper(islpci_private *priv, enum oid_num_t oid,
2461 2459
2462 if (!wpa_ie_len) { 2460 if (!wpa_ie_len) {
2463 printk(KERN_DEBUG "No WPA IE found from " 2461 printk(KERN_DEBUG "No WPA IE found from "
2464 "address:\t%02x:%02x:%02x:%02x:%02x:%02x\n", 2462 "address:\t%02x:%02x:%02x:%02x:%02x:%02x\n",
2465 mlmeex->address[0], 2463 mlmeex->address[0],
2466 mlmeex->address[1], 2464 mlmeex->address[1],
2467 mlmeex->address[2], 2465 mlmeex->address[2],
@@ -2473,13 +2471,13 @@ prism54_process_trap_helper(islpci_private *priv, enum oid_num_t oid,
2473 break; 2471 break;
2474 } 2472 }
2475 2473
2476 confirm->size = wpa_ie_len; 2474 confirm->size = wpa_ie_len;
2477 memcpy(&confirm->data, wpa_ie, wpa_ie_len); 2475 memcpy(&confirm->data, wpa_ie, wpa_ie_len);
2478 2476
2479 mgt_set_varlen(priv, oid, confirm, wpa_ie_len); 2477 mgt_set_varlen(priv, oid, confirm, wpa_ie_len);
2480 2478
2481 kfree(confirm); 2479 kfree(confirm);
2482 2480
2483 break; 2481 break;
2484 2482
2485 default: 2483 default:
@@ -2494,9 +2492,10 @@ prism54_process_trap_helper(islpci_private *priv, enum oid_num_t oid,
2494 * interrupt context, no locks held. 2492 * interrupt context, no locks held.
2495 */ 2493 */
2496void 2494void
2497prism54_process_trap(void *data) 2495prism54_process_trap(struct work_struct *work)
2498{ 2496{
2499 struct islpci_mgmtframe *frame = data; 2497 struct islpci_mgmtframe *frame =
2498 container_of(work, struct islpci_mgmtframe, ws);
2500 struct net_device *ndev = frame->ndev; 2499 struct net_device *ndev = frame->ndev;
2501 enum oid_num_t n = mgt_oidtonum(frame->header->oid); 2500 enum oid_num_t n = mgt_oidtonum(frame->header->oid);
2502 2501
@@ -2545,10 +2544,10 @@ enum {
2545#define PRISM2_HOSTAPD_GENERIC_ELEMENT_HDR_LEN \ 2544#define PRISM2_HOSTAPD_GENERIC_ELEMENT_HDR_LEN \
2546((int) (&((struct prism2_hostapd_param *) 0)->u.generic_elem.data)) 2545((int) (&((struct prism2_hostapd_param *) 0)->u.generic_elem.data))
2547 2546
2548/* Maximum length for algorithm names (-1 for nul termination) 2547/* Maximum length for algorithm names (-1 for nul termination)
2549 * used in ioctl() */ 2548 * used in ioctl() */
2550#define HOSTAP_CRYPT_ALG_NAME_LEN 16 2549#define HOSTAP_CRYPT_ALG_NAME_LEN 16
2551 2550
2552struct prism2_hostapd_param { 2551struct prism2_hostapd_param {
2553 u32 cmd; 2552 u32 cmd;
2554 u8 sta_addr[ETH_ALEN]; 2553 u8 sta_addr[ETH_ALEN];
@@ -2621,7 +2620,7 @@ prism2_ioctl_set_encryption(struct net_device *dev,
2621 &key); 2620 &key);
2622 } 2621 }
2623 /* 2622 /*
2624 * If a valid key is set, encryption should be enabled 2623 * If a valid key is set, encryption should be enabled
2625 * (user may turn it off later). 2624 * (user may turn it off later).
2626 * This is also how "iwconfig ethX key on" works 2625 * This is also how "iwconfig ethX key on" works
2627 */ 2626 */
@@ -2643,7 +2642,7 @@ prism2_ioctl_set_encryption(struct net_device *dev,
2643 } 2642 }
2644 /* now read the flags */ 2643 /* now read the flags */
2645 if (param->u.crypt.flags & IW_ENCODE_DISABLED) { 2644 if (param->u.crypt.flags & IW_ENCODE_DISABLED) {
2646 /* Encoding disabled, 2645 /* Encoding disabled,
2647 * authen = DOT11_AUTH_OS; 2646 * authen = DOT11_AUTH_OS;
2648 * invoke = 0; 2647 * invoke = 0;
2649 * exunencrypt = 0; */ 2648 * exunencrypt = 0; */
@@ -2685,11 +2684,10 @@ prism2_ioctl_set_generic_element(struct net_device *ndev,
2685 return -EINVAL; 2684 return -EINVAL;
2686 2685
2687 alen = sizeof(*attach) + len; 2686 alen = sizeof(*attach) + len;
2688 attach = kmalloc(alen, GFP_KERNEL); 2687 attach = kzalloc(alen, GFP_KERNEL);
2689 if (attach == NULL) 2688 if (attach == NULL)
2690 return -ENOMEM; 2689 return -ENOMEM;
2691 2690
2692 memset(attach, 0, alen);
2693#define WLAN_FC_TYPE_MGMT 0 2691#define WLAN_FC_TYPE_MGMT 0
2694#define WLAN_FC_STYPE_ASSOC_REQ 0 2692#define WLAN_FC_STYPE_ASSOC_REQ 0
2695#define WLAN_FC_STYPE_REASSOC_REQ 2 2693#define WLAN_FC_STYPE_REASSOC_REQ 2
@@ -2710,7 +2708,7 @@ prism2_ioctl_set_generic_element(struct net_device *ndev,
2710 2708
2711 ret = mgt_set_varlen(priv, DOT11_OID_ATTACHMENT, attach, len); 2709 ret = mgt_set_varlen(priv, DOT11_OID_ATTACHMENT, attach, len);
2712 2710
2713 if (ret == 0) 2711 if (ret == 0)
2714 printk(KERN_DEBUG "%s: WPA IE Attachment was set\n", 2712 printk(KERN_DEBUG "%s: WPA IE Attachment was set\n",
2715 ndev->name); 2713 ndev->name);
2716 } 2714 }
@@ -2870,7 +2868,7 @@ prism54_set_wpa(struct net_device *ndev, struct iw_request_info *info,
2870 mlme = DOT11_MLME_AUTO; 2868 mlme = DOT11_MLME_AUTO;
2871 printk("%s: Disabling WPA\n", ndev->name); 2869 printk("%s: Disabling WPA\n", ndev->name);
2872 break; 2870 break;
2873 case 2: 2871 case 2:
2874 case 1: /* WPA */ 2872 case 1: /* WPA */
2875 printk("%s: Enabling WPA\n", ndev->name); 2873 printk("%s: Enabling WPA\n", ndev->name);
2876 break; 2874 break;
diff --git a/drivers/net/wireless/prism54/isl_ioctl.h b/drivers/net/wireless/prism54/isl_ioctl.h
index 65f33acd0a42..bcfbfb9281d2 100644
--- a/drivers/net/wireless/prism54/isl_ioctl.h
+++ b/drivers/net/wireless/prism54/isl_ioctl.h
@@ -1,5 +1,4 @@
1/* 1/*
2 *
3 * Copyright (C) 2002 Intersil Americas Inc. 2 * Copyright (C) 2002 Intersil Americas Inc.
4 * (C) 2003 Aurelien Alleaume <slts@free.fr> 3 * (C) 2003 Aurelien Alleaume <slts@free.fr>
5 * (C) 2003 Luis R. Rodriguez <mcgrof@ruslug.rutgers.edu> 4 * (C) 2003 Luis R. Rodriguez <mcgrof@ruslug.rutgers.edu>
@@ -32,12 +31,12 @@
32void prism54_mib_init(islpci_private *); 31void prism54_mib_init(islpci_private *);
33 32
34struct iw_statistics *prism54_get_wireless_stats(struct net_device *); 33struct iw_statistics *prism54_get_wireless_stats(struct net_device *);
35void prism54_update_stats(islpci_private *); 34void prism54_update_stats(struct work_struct *);
36 35
37void prism54_acl_init(struct islpci_acl *); 36void prism54_acl_init(struct islpci_acl *);
38void prism54_acl_clean(struct islpci_acl *); 37void prism54_acl_clean(struct islpci_acl *);
39 38
40void prism54_process_trap(void *); 39void prism54_process_trap(struct work_struct *);
41 40
42void prism54_wpa_bss_ie_init(islpci_private *priv); 41void prism54_wpa_bss_ie_init(islpci_private *priv);
43void prism54_wpa_bss_ie_clean(islpci_private *priv); 42void prism54_wpa_bss_ie_clean(islpci_private *priv);
diff --git a/drivers/net/wireless/prism54/isl_oid.h b/drivers/net/wireless/prism54/isl_oid.h
index 419edf7ccf1a..b7534c2869c8 100644
--- a/drivers/net/wireless/prism54/isl_oid.h
+++ b/drivers/net/wireless/prism54/isl_oid.h
@@ -1,6 +1,4 @@
1/* 1/*
2 *
3 *
4 * Copyright (C) 2003 Herbert Valerio Riedel <hvr@gnu.org> 2 * Copyright (C) 2003 Herbert Valerio Riedel <hvr@gnu.org>
5 * Copyright (C) 2004 Luis R. Rodriguez <mcgrof@ruslug.rutgers.edu> 3 * Copyright (C) 2004 Luis R. Rodriguez <mcgrof@ruslug.rutgers.edu>
6 * Copyright (C) 2004 Aurelien Alleaume <slts@free.fr> 4 * Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
@@ -23,7 +21,7 @@
23#if !defined(_ISL_OID_H) 21#if !defined(_ISL_OID_H)
24#define _ISL_OID_H 22#define _ISL_OID_H
25 23
26/* 24/*
27 * MIB related constant and structure definitions for communicating 25 * MIB related constant and structure definitions for communicating
28 * with the device firmware 26 * with the device firmware
29 */ 27 */
@@ -99,21 +97,21 @@ struct obj_attachment {
99 char data[0]; 97 char data[0];
100} __attribute__((packed)); 98} __attribute__((packed));
101 99
102/* 100/*
103 * in case everything's ok, the inlined function below will be 101 * in case everything's ok, the inlined function below will be
104 * optimized away by the compiler... 102 * optimized away by the compiler...
105 */ 103 */
106static inline void 104static inline void
107__bug_on_wrong_struct_sizes(void) 105__bug_on_wrong_struct_sizes(void)
108{ 106{
109 BUG_ON(sizeof (struct obj_ssid) != 34); 107 BUILD_BUG_ON(sizeof (struct obj_ssid) != 34);
110 BUG_ON(sizeof (struct obj_key) != 34); 108 BUILD_BUG_ON(sizeof (struct obj_key) != 34);
111 BUG_ON(sizeof (struct obj_mlme) != 12); 109 BUILD_BUG_ON(sizeof (struct obj_mlme) != 12);
112 BUG_ON(sizeof (struct obj_mlmeex) != 14); 110 BUILD_BUG_ON(sizeof (struct obj_mlmeex) != 14);
113 BUG_ON(sizeof (struct obj_buffer) != 8); 111 BUILD_BUG_ON(sizeof (struct obj_buffer) != 8);
114 BUG_ON(sizeof (struct obj_bss) != 60); 112 BUILD_BUG_ON(sizeof (struct obj_bss) != 60);
115 BUG_ON(sizeof (struct obj_bsslist) != 4); 113 BUILD_BUG_ON(sizeof (struct obj_bsslist) != 4);
116 BUG_ON(sizeof (struct obj_frequencies) != 2); 114 BUILD_BUG_ON(sizeof (struct obj_frequencies) != 2);
117} 115}
118 116
119enum dot11_state_t { 117enum dot11_state_t {
@@ -154,13 +152,13 @@ enum dot11_priv_t {
154 152
155/* Prism "Nitro" / Frameburst / "Packet Frame Grouping" 153/* Prism "Nitro" / Frameburst / "Packet Frame Grouping"
156 * Value is in microseconds. Represents the # microseconds 154 * Value is in microseconds. Represents the # microseconds
157 * the firmware will take to group frames before sending out then out 155 * the firmware will take to group frames before sending out then out
158 * together with a CSMA contention. Without this all frames are 156 * together with a CSMA contention. Without this all frames are
159 * sent with a CSMA contention. 157 * sent with a CSMA contention.
160 * Bibliography: 158 * Bibliography:
161 * http://www.hpl.hp.com/personal/Jean_Tourrilhes/Papers/Packet.Frame.Grouping.html 159 * http://www.hpl.hp.com/personal/Jean_Tourrilhes/Papers/Packet.Frame.Grouping.html
162 */ 160 */
163enum dot11_maxframeburst_t { 161enum dot11_maxframeburst_t {
164 /* Values for DOT11_OID_MAXFRAMEBURST */ 162 /* Values for DOT11_OID_MAXFRAMEBURST */
165 DOT11_MAXFRAMEBURST_OFF = 0, /* Card firmware default */ 163 DOT11_MAXFRAMEBURST_OFF = 0, /* Card firmware default */
166 DOT11_MAXFRAMEBURST_MIXED_SAFE = 650, /* 802.11 a,b,g safe */ 164 DOT11_MAXFRAMEBURST_MIXED_SAFE = 650, /* 802.11 a,b,g safe */
@@ -176,9 +174,9 @@ enum dot11_maxframeburst_t {
176/* Support for 802.11 long and short frame preambles. 174/* Support for 802.11 long and short frame preambles.
177 * Long preamble uses 128-bit sync field, 8-bit CRC 175 * Long preamble uses 128-bit sync field, 8-bit CRC
178 * Short preamble uses 56-bit sync field, 16-bit CRC 176 * Short preamble uses 56-bit sync field, 16-bit CRC
179 * 177 *
180 * 802.11a -- not sure, both optionally ? 178 * 802.11a -- not sure, both optionally ?
181 * 802.11b supports long and optionally short 179 * 802.11b supports long and optionally short
182 * 802.11g supports both */ 180 * 802.11g supports both */
183enum dot11_preamblesettings_t { 181enum dot11_preamblesettings_t {
184 DOT11_PREAMBLESETTING_LONG = 0, 182 DOT11_PREAMBLESETTING_LONG = 0,
@@ -194,7 +192,7 @@ enum dot11_preamblesettings_t {
194 * Long uses 802.11a slot timing (9 usec ?) 192 * Long uses 802.11a slot timing (9 usec ?)
195 * Short uses 802.11b slot timing (20 use ?) */ 193 * Short uses 802.11b slot timing (20 use ?) */
196enum dot11_slotsettings_t { 194enum dot11_slotsettings_t {
197 DOT11_SLOTSETTINGS_LONG = 0, 195 DOT11_SLOTSETTINGS_LONG = 0,
198 /* Allows *only* long 802.11b slot timing */ 196 /* Allows *only* long 802.11b slot timing */
199 DOT11_SLOTSETTINGS_SHORT = 1, 197 DOT11_SLOTSETTINGS_SHORT = 1,
200 /* Allows *only* long 802.11a slot timing */ 198 /* Allows *only* long 802.11a slot timing */
@@ -203,7 +201,7 @@ enum dot11_slotsettings_t {
203}; 201};
204 202
205/* All you need to know, ERP is "Extended Rate PHY". 203/* All you need to know, ERP is "Extended Rate PHY".
206 * An Extended Rate PHY (ERP) STA or AP shall support three different 204 * An Extended Rate PHY (ERP) STA or AP shall support three different
207 * preamble and header formats: 205 * preamble and header formats:
208 * Long preamble (refer to above) 206 * Long preamble (refer to above)
209 * Short preamble (refer to above) 207 * Short preamble (refer to above)
@@ -221,7 +219,7 @@ enum do11_nonerpstatus_t {
221/* (ERP is "Extended Rate PHY") Way to read NONERP is NON-ERP-* 219/* (ERP is "Extended Rate PHY") Way to read NONERP is NON-ERP-*
222 * The key here is DOT11 NON ERP NEVER protects against 220 * The key here is DOT11 NON ERP NEVER protects against
223 * NON ERP STA's. You *don't* want this unless 221 * NON ERP STA's. You *don't* want this unless
224 * you know what you are doing. It means you will only 222 * you know what you are doing. It means you will only
225 * get Extended Rate capabilities */ 223 * get Extended Rate capabilities */
226enum dot11_nonerpprotection_t { 224enum dot11_nonerpprotection_t {
227 DOT11_NONERP_NEVER = 0, 225 DOT11_NONERP_NEVER = 0,
@@ -229,13 +227,13 @@ enum dot11_nonerpprotection_t {
229 DOT11_NONERP_DYNAMIC = 2 227 DOT11_NONERP_DYNAMIC = 2
230}; 228};
231 229
232/* Preset OID configuration for 802.11 modes 230/* Preset OID configuration for 802.11 modes
233 * Note: DOT11_OID_CW[MIN|MAX] hold the values of the 231 * Note: DOT11_OID_CW[MIN|MAX] hold the values of the
234 * DCS MIN|MAX backoff used */ 232 * DCS MIN|MAX backoff used */
235enum dot11_profile_t { /* And set/allowed values */ 233enum dot11_profile_t { /* And set/allowed values */
236 /* Allowed values for DOT11_OID_PROFILES */ 234 /* Allowed values for DOT11_OID_PROFILES */
237 DOT11_PROFILE_B_ONLY = 0, 235 DOT11_PROFILE_B_ONLY = 0,
238 /* DOT11_OID_RATES: 1, 2, 5.5, 11Mbps 236 /* DOT11_OID_RATES: 1, 2, 5.5, 11Mbps
239 * DOT11_OID_PREAMBLESETTINGS: DOT11_PREAMBLESETTING_DYNAMIC 237 * DOT11_OID_PREAMBLESETTINGS: DOT11_PREAMBLESETTING_DYNAMIC
240 * DOT11_OID_CWMIN: 31 238 * DOT11_OID_CWMIN: 31
241 * DOT11_OID_NONEPROTECTION: DOT11_NOERP_DYNAMIC 239 * DOT11_OID_NONEPROTECTION: DOT11_NOERP_DYNAMIC
@@ -275,7 +273,7 @@ enum oid_inl_conformance_t {
275 OID_INL_CONFORMANCE_NONE = 0, /* Perform active scanning */ 273 OID_INL_CONFORMANCE_NONE = 0, /* Perform active scanning */
276 OID_INL_CONFORMANCE_STRICT = 1, /* Strictly adhere to 802.11d */ 274 OID_INL_CONFORMANCE_STRICT = 1, /* Strictly adhere to 802.11d */
277 OID_INL_CONFORMANCE_FLEXIBLE = 2, /* Use passed 802.11d info to 275 OID_INL_CONFORMANCE_FLEXIBLE = 2, /* Use passed 802.11d info to
278 * determine channel AND/OR just make assumption that active 276 * determine channel AND/OR just make assumption that active
279 * channels are valid channels */ 277 * channels are valid channels */
280}; 278};
281 279
diff --git a/drivers/net/wireless/prism54/islpci_dev.c b/drivers/net/wireless/prism54/islpci_dev.c
index ec1c00f19eb3..f057fd9fcd79 100644
--- a/drivers/net/wireless/prism54/islpci_dev.c
+++ b/drivers/net/wireless/prism54/islpci_dev.c
@@ -1,5 +1,4 @@
1/* 1/*
2 *
3 * Copyright (C) 2002 Intersil Americas Inc. 2 * Copyright (C) 2002 Intersil Americas Inc.
4 * Copyright (C) 2003 Herbert Valerio Riedel <hvr@gnu.org> 3 * Copyright (C) 2003 Herbert Valerio Riedel <hvr@gnu.org>
5 * Copyright (C) 2003 Luis R. Rodriguez <mcgrof@ruslug.rutgers.edu> 4 * Copyright (C) 2003 Luis R. Rodriguez <mcgrof@ruslug.rutgers.edu>
@@ -413,7 +412,7 @@ prism54_bring_down(islpci_private *priv)
413 islpci_set_state(priv, PRV_STATE_PREBOOT); 412 islpci_set_state(priv, PRV_STATE_PREBOOT);
414 413
415 /* disable all device interrupts in case they weren't */ 414 /* disable all device interrupts in case they weren't */
416 isl38xx_disable_interrupts(priv->device_base); 415 isl38xx_disable_interrupts(priv->device_base);
417 416
418 /* For safety reasons, we may want to ensure that no DMA transfer is 417 /* For safety reasons, we may want to ensure that no DMA transfer is
419 * currently in progress by emptying the TX and RX queues. */ 418 * currently in progress by emptying the TX and RX queues. */
@@ -480,7 +479,7 @@ islpci_reset_if(islpci_private *priv)
480 479
481 DEFINE_WAIT(wait); 480 DEFINE_WAIT(wait);
482 prepare_to_wait(&priv->reset_done, &wait, TASK_UNINTERRUPTIBLE); 481 prepare_to_wait(&priv->reset_done, &wait, TASK_UNINTERRUPTIBLE);
483 482
484 /* now the last step is to reset the interface */ 483 /* now the last step is to reset the interface */
485 isl38xx_interface_reset(priv->device_base, priv->device_host_address); 484 isl38xx_interface_reset(priv->device_base, priv->device_host_address);
486 islpci_set_state(priv, PRV_STATE_PREINIT); 485 islpci_set_state(priv, PRV_STATE_PREINIT);
@@ -488,7 +487,7 @@ islpci_reset_if(islpci_private *priv)
488 for(count = 0; count < 2 && result; count++) { 487 for(count = 0; count < 2 && result; count++) {
489 /* The software reset acknowledge needs about 220 msec here. 488 /* The software reset acknowledge needs about 220 msec here.
490 * Be conservative and wait for up to one second. */ 489 * Be conservative and wait for up to one second. */
491 490
492 remaining = schedule_timeout_uninterruptible(HZ); 491 remaining = schedule_timeout_uninterruptible(HZ);
493 492
494 if(remaining > 0) { 493 if(remaining > 0) {
@@ -496,7 +495,7 @@ islpci_reset_if(islpci_private *priv)
496 break; 495 break;
497 } 496 }
498 497
499 /* If we're here it's because our IRQ hasn't yet gone through. 498 /* If we're here it's because our IRQ hasn't yet gone through.
500 * Retry a bit more... 499 * Retry a bit more...
501 */ 500 */
502 printk(KERN_ERR "%s: no 'reset complete' IRQ seen - retrying\n", 501 printk(KERN_ERR "%s: no 'reset complete' IRQ seen - retrying\n",
@@ -514,7 +513,7 @@ islpci_reset_if(islpci_private *priv)
514 513
515 /* Now that the device is 100% up, let's allow 514 /* Now that the device is 100% up, let's allow
516 * for the other interrupts -- 515 * for the other interrupts --
517 * NOTE: this is not *yet* true since we've only allowed the 516 * NOTE: this is not *yet* true since we've only allowed the
518 * INIT interrupt on the IRQ line. We can perhaps poll 517 * INIT interrupt on the IRQ line. We can perhaps poll
519 * the IRQ line until we know for sure the reset went through */ 518 * the IRQ line until we know for sure the reset went through */
520 isl38xx_enable_common_interrupts(priv->device_base); 519 isl38xx_enable_common_interrupts(priv->device_base);
@@ -716,7 +715,7 @@ islpci_alloc_memory(islpci_private *priv)
716 715
717 prism54_acl_init(&priv->acl); 716 prism54_acl_init(&priv->acl);
718 prism54_wpa_bss_ie_init(priv); 717 prism54_wpa_bss_ie_init(priv);
719 if (mgt_init(priv)) 718 if (mgt_init(priv))
720 goto out_free; 719 goto out_free;
721 720
722 return 0; 721 return 0;
@@ -861,11 +860,10 @@ islpci_setup(struct pci_dev *pdev)
861 priv->state_off = 1; 860 priv->state_off = 1;
862 861
863 /* initialize workqueue's */ 862 /* initialize workqueue's */
864 INIT_WORK(&priv->stats_work, 863 INIT_WORK(&priv->stats_work, prism54_update_stats);
865 (void (*)(void *)) prism54_update_stats, priv);
866 priv->stats_timestamp = 0; 864 priv->stats_timestamp = 0;
867 865
868 INIT_WORK(&priv->reset_task, islpci_do_reset_and_wake, priv); 866 INIT_WORK(&priv->reset_task, islpci_do_reset_and_wake);
869 priv->reset_task_pending = 0; 867 priv->reset_task_pending = 0;
870 868
871 /* allocate various memory areas */ 869 /* allocate various memory areas */
diff --git a/drivers/net/wireless/prism54/islpci_dev.h b/drivers/net/wireless/prism54/islpci_dev.h
index 2f7e525d0cf6..a9aa1662eaa4 100644
--- a/drivers/net/wireless/prism54/islpci_dev.h
+++ b/drivers/net/wireless/prism54/islpci_dev.h
@@ -1,6 +1,5 @@
1/* 1/*
2 * 2 * Copyright (C) 2002 Intersil Americas Inc.
3 * Copyright (C) 2002 Intersil Americas Inc.
4 * Copyright (C) 2003 Herbert Valerio Riedel <hvr@gnu.org> 3 * Copyright (C) 2003 Herbert Valerio Riedel <hvr@gnu.org>
5 * Copyright (C) 2003 Luis R. Rodriguez <mcgrof@ruslug.rutgers.edu> 4 * Copyright (C) 2003 Luis R. Rodriguez <mcgrof@ruslug.rutgers.edu>
6 * Copyright (C) 2003 Aurelien Alleaume <slts@free.fr> 5 * Copyright (C) 2003 Aurelien Alleaume <slts@free.fr>
@@ -72,12 +71,12 @@ struct islpci_bss_wpa_ie {
72 u8 bssid[ETH_ALEN]; 71 u8 bssid[ETH_ALEN];
73 u8 wpa_ie[MAX_WPA_IE_LEN]; 72 u8 wpa_ie[MAX_WPA_IE_LEN];
74 size_t wpa_ie_len; 73 size_t wpa_ie_len;
75 74
76}; 75};
77 76
78typedef struct { 77typedef struct {
79 spinlock_t slock; /* generic spinlock; */ 78 spinlock_t slock; /* generic spinlock; */
80 79
81 u32 priv_oid; 80 u32 priv_oid;
82 81
83 /* our mib cache */ 82 /* our mib cache */
@@ -85,7 +84,7 @@ typedef struct {
85 struct rw_semaphore mib_sem; 84 struct rw_semaphore mib_sem;
86 void **mib; 85 void **mib;
87 char nickname[IW_ESSID_MAX_SIZE+1]; 86 char nickname[IW_ESSID_MAX_SIZE+1];
88 87
89 /* Take care of the wireless stats */ 88 /* Take care of the wireless stats */
90 struct work_struct stats_work; 89 struct work_struct stats_work;
91 struct semaphore stats_sem; 90 struct semaphore stats_sem;
@@ -120,7 +119,7 @@ typedef struct {
120 struct net_device *ndev; 119 struct net_device *ndev;
121 120
122 /* device queue interface members */ 121 /* device queue interface members */
123 struct isl38xx_cb *control_block; /* device control block 122 struct isl38xx_cb *control_block; /* device control block
124 (== driver_mem_address!) */ 123 (== driver_mem_address!) */
125 124
126 /* Each queue has three indexes: 125 /* Each queue has three indexes:
diff --git a/drivers/net/wireless/prism54/islpci_eth.c b/drivers/net/wireless/prism54/islpci_eth.c
index a8261d8454dd..b1122912ee2d 100644
--- a/drivers/net/wireless/prism54/islpci_eth.c
+++ b/drivers/net/wireless/prism54/islpci_eth.c
@@ -1,5 +1,4 @@
1/* 1/*
2 *
3 * Copyright (C) 2002 Intersil Americas Inc. 2 * Copyright (C) 2002 Intersil Americas Inc.
4 * Copyright (C) 2004 Aurelien Alleaume <slts@free.fr> 3 * Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
5 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
@@ -48,7 +47,7 @@ islpci_eth_cleanup_transmit(islpci_private *priv,
48 /* read the index of the first fragment to be freed */ 47 /* read the index of the first fragment to be freed */
49 index = priv->free_data_tx % ISL38XX_CB_TX_QSIZE; 48 index = priv->free_data_tx % ISL38XX_CB_TX_QSIZE;
50 49
51 /* check for holes in the arrays caused by multi fragment frames 50 /* check for holes in the arrays caused by multi fragment frames
52 * searching for the last fragment of a frame */ 51 * searching for the last fragment of a frame */
53 if (priv->pci_map_tx_address[index] != (dma_addr_t) NULL) { 52 if (priv->pci_map_tx_address[index] != (dma_addr_t) NULL) {
54 /* entry is the last fragment of a frame 53 /* entry is the last fragment of a frame
@@ -253,6 +252,7 @@ islpci_monitor_rx(islpci_private *priv, struct sk_buff **skb)
253 * header and without the FCS. But there a is a bit that 252 * header and without the FCS. But there a is a bit that
254 * indicates if the packet is corrupted :-) */ 253 * indicates if the packet is corrupted :-) */
255 struct rfmon_header *hdr = (struct rfmon_header *) (*skb)->data; 254 struct rfmon_header *hdr = (struct rfmon_header *) (*skb)->data;
255
256 if (hdr->flags & 0x01) 256 if (hdr->flags & 0x01)
257 /* This one is bad. Drop it ! */ 257 /* This one is bad. Drop it ! */
258 return -1; 258 return -1;
@@ -284,7 +284,7 @@ islpci_monitor_rx(islpci_private *priv, struct sk_buff **skb)
284 (struct avs_80211_1_header *) skb_push(*skb, 284 (struct avs_80211_1_header *) skb_push(*skb,
285 sizeof (struct 285 sizeof (struct
286 avs_80211_1_header)); 286 avs_80211_1_header));
287 287
288 avs->version = cpu_to_be32(P80211CAPTURE_VERSION); 288 avs->version = cpu_to_be32(P80211CAPTURE_VERSION);
289 avs->length = cpu_to_be32(sizeof (struct avs_80211_1_header)); 289 avs->length = cpu_to_be32(sizeof (struct avs_80211_1_header));
290 avs->mactime = cpu_to_be64(le64_to_cpu(clock)); 290 avs->mactime = cpu_to_be64(le64_to_cpu(clock));
@@ -390,7 +390,7 @@ islpci_eth_receive(islpci_private *priv)
390 struct rx_annex_header *annex = 390 struct rx_annex_header *annex =
391 (struct rx_annex_header *) skb->data; 391 (struct rx_annex_header *) skb->data;
392 wstats.level = annex->rfmon.rssi; 392 wstats.level = annex->rfmon.rssi;
393 /* The noise value can be a bit outdated if nobody's 393 /* The noise value can be a bit outdated if nobody's
394 * reading wireless stats... */ 394 * reading wireless stats... */
395 wstats.noise = priv->local_iwstatistics.qual.noise; 395 wstats.noise = priv->local_iwstatistics.qual.noise;
396 wstats.qual = wstats.level - wstats.noise; 396 wstats.qual = wstats.level - wstats.noise;
@@ -464,10 +464,8 @@ islpci_eth_receive(islpci_private *priv)
464 break; 464 break;
465 } 465 }
466 /* update the fragment address */ 466 /* update the fragment address */
467 control_block->rx_data_low[index].address = cpu_to_le32((u32) 467 control_block->rx_data_low[index].address =
468 priv-> 468 cpu_to_le32((u32)priv->pci_map_rx_address[index]);
469 pci_map_rx_address
470 [index]);
471 wmb(); 469 wmb();
472 470
473 /* increment the driver read pointer */ 471 /* increment the driver read pointer */
@@ -482,12 +480,14 @@ islpci_eth_receive(islpci_private *priv)
482} 480}
483 481
484void 482void
485islpci_do_reset_and_wake(void *data) 483islpci_do_reset_and_wake(struct work_struct *work)
486{ 484{
487 islpci_private *priv = (islpci_private *) data; 485 islpci_private *priv = container_of(work, islpci_private, reset_task);
486
488 islpci_reset(priv, 1); 487 islpci_reset(priv, 1);
489 netif_wake_queue(priv->ndev);
490 priv->reset_task_pending = 0; 488 priv->reset_task_pending = 0;
489 smp_wmb();
490 netif_wake_queue(priv->ndev);
491} 491}
492 492
493void 493void
@@ -499,12 +499,14 @@ islpci_eth_tx_timeout(struct net_device *ndev)
499 /* increment the transmit error counter */ 499 /* increment the transmit error counter */
500 statistics->tx_errors++; 500 statistics->tx_errors++;
501 501
502 printk(KERN_WARNING "%s: tx_timeout", ndev->name);
503 if (!priv->reset_task_pending) { 502 if (!priv->reset_task_pending) {
504 priv->reset_task_pending = 1; 503 printk(KERN_WARNING
505 printk(", scheduling a reset"); 504 "%s: tx_timeout, scheduling reset", ndev->name);
506 netif_stop_queue(ndev); 505 netif_stop_queue(ndev);
506 priv->reset_task_pending = 1;
507 schedule_work(&priv->reset_task); 507 schedule_work(&priv->reset_task);
508 } else {
509 printk(KERN_WARNING
510 "%s: tx_timeout, waiting for reset", ndev->name);
508 } 511 }
509 printk("\n");
510} 512}
diff --git a/drivers/net/wireless/prism54/islpci_eth.h b/drivers/net/wireless/prism54/islpci_eth.h
index bc9d7a60b8d6..5bf820defbd0 100644
--- a/drivers/net/wireless/prism54/islpci_eth.h
+++ b/drivers/net/wireless/prism54/islpci_eth.h
@@ -1,5 +1,4 @@
1/* 1/*
2 *
3 * Copyright (C) 2002 Intersil Americas Inc. 2 * Copyright (C) 2002 Intersil Americas Inc.
4 * 3 *
5 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
@@ -68,6 +67,6 @@ void islpci_eth_cleanup_transmit(islpci_private *, isl38xx_control_block *);
68int islpci_eth_transmit(struct sk_buff *, struct net_device *); 67int islpci_eth_transmit(struct sk_buff *, struct net_device *);
69int islpci_eth_receive(islpci_private *); 68int islpci_eth_receive(islpci_private *);
70void islpci_eth_tx_timeout(struct net_device *); 69void islpci_eth_tx_timeout(struct net_device *);
71void islpci_do_reset_and_wake(void *data); 70void islpci_do_reset_and_wake(struct work_struct *);
72 71
73#endif /* _ISL_GEN_H */ 72#endif /* _ISL_GEN_H */
diff --git a/drivers/net/wireless/prism54/islpci_hotplug.c b/drivers/net/wireless/prism54/islpci_hotplug.c
index f692dccf0d07..58257b40c043 100644
--- a/drivers/net/wireless/prism54/islpci_hotplug.c
+++ b/drivers/net/wireless/prism54/islpci_hotplug.c
@@ -1,5 +1,4 @@
1/* 1/*
2 *
3 * Copyright (C) 2002 Intersil Americas Inc. 2 * Copyright (C) 2002 Intersil Americas Inc.
4 * Copyright (C) 2003 Herbert Valerio Riedel <hvr@gnu.org> 3 * Copyright (C) 2003 Herbert Valerio Riedel <hvr@gnu.org>
5 * 4 *
@@ -40,8 +39,8 @@ static int init_pcitm = 0;
40module_param(init_pcitm, int, 0); 39module_param(init_pcitm, int, 0);
41 40
42/* In this order: vendor, device, subvendor, subdevice, class, class_mask, 41/* In this order: vendor, device, subvendor, subdevice, class, class_mask,
43 * driver_data 42 * driver_data
44 * If you have an update for this please contact prism54-devel@prism54.org 43 * If you have an update for this please contact prism54-devel@prism54.org
45 * The latest list can be found at http://prism54.org/supported_cards.php */ 44 * The latest list can be found at http://prism54.org/supported_cards.php */
46static const struct pci_device_id prism54_id_tbl[] = { 45static const struct pci_device_id prism54_id_tbl[] = {
47 /* Intersil PRISM Duette/Prism GT Wireless LAN adapter */ 46 /* Intersil PRISM Duette/Prism GT Wireless LAN adapter */
@@ -132,15 +131,15 @@ prism54_probe(struct pci_dev *pdev, const struct pci_device_id *id)
132 131
133 /* 0x40 is the programmable timer to configure the response timeout (TRDY_TIMEOUT) 132 /* 0x40 is the programmable timer to configure the response timeout (TRDY_TIMEOUT)
134 * 0x41 is the programmable timer to configure the retry timeout (RETRY_TIMEOUT) 133 * 0x41 is the programmable timer to configure the retry timeout (RETRY_TIMEOUT)
135 * The RETRY_TIMEOUT is used to set the number of retries that the core, as a 134 * The RETRY_TIMEOUT is used to set the number of retries that the core, as a
136 * Master, will perform before abandoning a cycle. The default value for 135 * Master, will perform before abandoning a cycle. The default value for
137 * RETRY_TIMEOUT is 0x80, which far exceeds the PCI 2.1 requirement for new 136 * RETRY_TIMEOUT is 0x80, which far exceeds the PCI 2.1 requirement for new
138 * devices. A write of zero to the RETRY_TIMEOUT register disables this 137 * devices. A write of zero to the RETRY_TIMEOUT register disables this
139 * function to allow use with any non-compliant legacy devices that may 138 * function to allow use with any non-compliant legacy devices that may
140 * execute more retries. 139 * execute more retries.
141 * 140 *
142 * Writing zero to both these two registers will disable both timeouts and 141 * Writing zero to both these two registers will disable both timeouts and
143 * *can* solve problems caused by devices that are slow to respond. 142 * *can* solve problems caused by devices that are slow to respond.
144 * Make this configurable - MSW 143 * Make this configurable - MSW
145 */ 144 */
146 if ( init_pcitm >= 0 ) { 145 if ( init_pcitm >= 0 ) {
@@ -171,14 +170,15 @@ prism54_probe(struct pci_dev *pdev, const struct pci_device_id *id)
171 pci_set_master(pdev); 170 pci_set_master(pdev);
172 171
173 /* enable MWI */ 172 /* enable MWI */
174 pci_set_mwi(pdev); 173 if (!pci_set_mwi(pdev))
174 printk(KERN_INFO "%s: pci_set_mwi(pdev) succeeded\n", DRV_NAME);
175 175
176 /* setup the network device interface and its structure */ 176 /* setup the network device interface and its structure */
177 if (!(ndev = islpci_setup(pdev))) { 177 if (!(ndev = islpci_setup(pdev))) {
178 /* error configuring the driver as a network device */ 178 /* error configuring the driver as a network device */
179 printk(KERN_ERR "%s: could not configure network device\n", 179 printk(KERN_ERR "%s: could not configure network device\n",
180 DRV_NAME); 180 DRV_NAME);
181 goto do_pci_release_regions; 181 goto do_pci_clear_mwi;
182 } 182 }
183 183
184 priv = netdev_priv(ndev); 184 priv = netdev_priv(ndev);
@@ -208,6 +208,8 @@ prism54_probe(struct pci_dev *pdev, const struct pci_device_id *id)
208 pci_set_drvdata(pdev, NULL); 208 pci_set_drvdata(pdev, NULL);
209 free_netdev(ndev); 209 free_netdev(ndev);
210 priv = NULL; 210 priv = NULL;
211 do_pci_clear_mwi:
212 pci_clear_mwi(pdev);
211 do_pci_release_regions: 213 do_pci_release_regions:
212 pci_release_regions(pdev); 214 pci_release_regions(pdev);
213 do_pci_disable_device: 215 do_pci_disable_device:
@@ -241,7 +243,7 @@ prism54_remove(struct pci_dev *pdev)
241 isl38xx_disable_interrupts(priv->device_base); 243 isl38xx_disable_interrupts(priv->device_base);
242 islpci_set_state(priv, PRV_STATE_OFF); 244 islpci_set_state(priv, PRV_STATE_OFF);
243 /* This bellow causes a lockup at rmmod time. It might be 245 /* This bellow causes a lockup at rmmod time. It might be
244 * because some interrupts still linger after rmmod time, 246 * because some interrupts still linger after rmmod time,
245 * see bug #17 */ 247 * see bug #17 */
246 /* pci_set_power_state(pdev, 3);*/ /* try to power-off */ 248 /* pci_set_power_state(pdev, 3);*/ /* try to power-off */
247 } 249 }
@@ -255,6 +257,8 @@ prism54_remove(struct pci_dev *pdev)
255 free_netdev(ndev); 257 free_netdev(ndev);
256 priv = NULL; 258 priv = NULL;
257 259
260 pci_clear_mwi(pdev);
261
258 pci_release_regions(pdev); 262 pci_release_regions(pdev);
259 263
260 pci_disable_device(pdev); 264 pci_disable_device(pdev);
@@ -288,12 +292,19 @@ prism54_resume(struct pci_dev *pdev)
288{ 292{
289 struct net_device *ndev = pci_get_drvdata(pdev); 293 struct net_device *ndev = pci_get_drvdata(pdev);
290 islpci_private *priv = ndev ? netdev_priv(ndev) : NULL; 294 islpci_private *priv = ndev ? netdev_priv(ndev) : NULL;
291 BUG_ON(!priv); 295 int err;
292 296
293 pci_enable_device(pdev); 297 BUG_ON(!priv);
294 298
295 printk(KERN_NOTICE "%s: got resume request\n", ndev->name); 299 printk(KERN_NOTICE "%s: got resume request\n", ndev->name);
296 300
301 err = pci_enable_device(pdev);
302 if (err) {
303 printk(KERN_ERR "%s: pci_enable_device failed on resume\n",
304 ndev->name);
305 return err;
306 }
307
297 pci_restore_state(pdev); 308 pci_restore_state(pdev);
298 309
299 /* alright let's go into the PREBOOT state */ 310 /* alright let's go into the PREBOOT state */
diff --git a/drivers/net/wireless/prism54/islpci_mgt.c b/drivers/net/wireless/prism54/islpci_mgt.c
index 2e061a80b294..2246f7930b4e 100644
--- a/drivers/net/wireless/prism54/islpci_mgt.c
+++ b/drivers/net/wireless/prism54/islpci_mgt.c
@@ -1,5 +1,4 @@
1/* 1/*
2 *
3 * Copyright (C) 2002 Intersil Americas Inc. 2 * Copyright (C) 2002 Intersil Americas Inc.
4 * Copyright 2004 Jens Maurer <Jens.Maurer@gmx.net> 3 * Copyright 2004 Jens Maurer <Jens.Maurer@gmx.net>
5 * 4 *
@@ -387,7 +386,7 @@ islpci_mgt_receive(struct net_device *ndev)
387 386
388 /* Create work to handle trap out of interrupt 387 /* Create work to handle trap out of interrupt
389 * context. */ 388 * context. */
390 INIT_WORK(&frame->ws, prism54_process_trap, frame); 389 INIT_WORK(&frame->ws, prism54_process_trap);
391 schedule_work(&frame->ws); 390 schedule_work(&frame->ws);
392 391
393 } else { 392 } else {
@@ -502,7 +501,7 @@ islpci_mgt_transaction(struct net_device *ndev,
502 printk(KERN_WARNING "%s: timeout waiting for mgmt response\n", 501 printk(KERN_WARNING "%s: timeout waiting for mgmt response\n",
503 ndev->name); 502 ndev->name);
504 503
505 /* TODO: we should reset the device here */ 504 /* TODO: we should reset the device here */
506 out: 505 out:
507 finish_wait(&priv->mgmt_wqueue, &wait); 506 finish_wait(&priv->mgmt_wqueue, &wait);
508 up(&priv->mgmt_sem); 507 up(&priv->mgmt_sem);
diff --git a/drivers/net/wireless/prism54/islpci_mgt.h b/drivers/net/wireless/prism54/islpci_mgt.h
index 2982be3363ef..fc53b587b722 100644
--- a/drivers/net/wireless/prism54/islpci_mgt.h
+++ b/drivers/net/wireless/prism54/islpci_mgt.h
@@ -1,5 +1,4 @@
1/* 1/*
2 *
3 * Copyright (C) 2002 Intersil Americas Inc. 2 * Copyright (C) 2002 Intersil Americas Inc.
4 * Copyright (C) 2003 Luis R. Rodriguez <mcgrof@ruslug.rutgers.edu> 3 * Copyright (C) 2003 Luis R. Rodriguez <mcgrof@ruslug.rutgers.edu>
5 * 4 *
@@ -36,8 +35,8 @@ extern int pc_debug;
36 35
37 36
38/* General driver definitions */ 37/* General driver definitions */
39#define PCIDEVICE_LATENCY_TIMER_MIN 0x40 38#define PCIDEVICE_LATENCY_TIMER_MIN 0x40
40#define PCIDEVICE_LATENCY_TIMER_VAL 0x50 39#define PCIDEVICE_LATENCY_TIMER_VAL 0x50
41 40
42/* Debugging verbose definitions */ 41/* Debugging verbose definitions */
43#define SHOW_NOTHING 0x00 /* overrules everything */ 42#define SHOW_NOTHING 0x00 /* overrules everything */
diff --git a/drivers/net/wireless/prism54/oid_mgt.c b/drivers/net/wireless/prism54/oid_mgt.c
index ebb238785839..e6cf9df2c206 100644
--- a/drivers/net/wireless/prism54/oid_mgt.c
+++ b/drivers/net/wireless/prism54/oid_mgt.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (C) 2003,2004 Aurelien Alleaume <slts@free.fr> 2 * Copyright (C) 2003,2004 Aurelien Alleaume <slts@free.fr>
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
@@ -235,12 +235,10 @@ mgt_init(islpci_private *priv)
235{ 235{
236 int i; 236 int i;
237 237
238 priv->mib = kmalloc(OID_NUM_LAST * sizeof (void *), GFP_KERNEL); 238 priv->mib = kcalloc(OID_NUM_LAST, sizeof (void *), GFP_KERNEL);
239 if (!priv->mib) 239 if (!priv->mib)
240 return -ENOMEM; 240 return -ENOMEM;
241 241
242 memset(priv->mib, 0, OID_NUM_LAST * sizeof (void *));
243
244 /* Alloc the cache */ 242 /* Alloc the cache */
245 for (i = 0; i < OID_NUM_LAST; i++) { 243 for (i = 0; i < OID_NUM_LAST; i++) {
246 if (isl_oid[i].flags & OID_FLAG_CACHED) { 244 if (isl_oid[i].flags & OID_FLAG_CACHED) {
@@ -503,7 +501,7 @@ mgt_set_varlen(islpci_private *priv, enum oid_num_t n, void *data, int extra_len
503 } 501 }
504 if (ret || response_op == PIMFOR_OP_ERROR) 502 if (ret || response_op == PIMFOR_OP_ERROR)
505 ret = -EIO; 503 ret = -EIO;
506 } else 504 } else
507 ret = -EIO; 505 ret = -EIO;
508 506
509 /* re-set given data to what it was */ 507 /* re-set given data to what it was */
@@ -727,7 +725,7 @@ mgt_commit(islpci_private *priv)
727 * MEDIUMLIMIT,BEACONPERIOD,DTIMPERIOD,ATIMWINDOW,LISTENINTERVAL 725 * MEDIUMLIMIT,BEACONPERIOD,DTIMPERIOD,ATIMWINDOW,LISTENINTERVAL
728 * FREQUENCY,EXTENDEDRATES. 726 * FREQUENCY,EXTENDEDRATES.
729 * 727 *
730 * The way to do this is to set ESSID. Note though that they may get 728 * The way to do this is to set ESSID. Note though that they may get
731 * unlatch before though by setting another OID. */ 729 * unlatch before though by setting another OID. */
732#if 0 730#if 0
733void 731void
diff --git a/drivers/net/wireless/prism54/prismcompat.h b/drivers/net/wireless/prism54/prismcompat.h
index d71eca55a302..aa1d1747784f 100644
--- a/drivers/net/wireless/prism54/prismcompat.h
+++ b/drivers/net/wireless/prism54/prismcompat.h
@@ -1,4 +1,4 @@
1/* 1/*
2 * (C) 2004 Margit Schubert-While <margitsw@t-online.de> 2 * (C) 2004 Margit Schubert-While <margitsw@t-online.de>
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
@@ -16,7 +16,7 @@
16 * 16 *
17 */ 17 */
18 18
19/* 19/*
20 * Compatibility header file to aid support of different kernel versions 20 * Compatibility header file to aid support of different kernel versions
21 */ 21 */
22 22
diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
index 7fbfc9e41d07..88e10c9bc4ac 100644
--- a/drivers/net/wireless/ray_cs.c
+++ b/drivers/net/wireless/ray_cs.c
@@ -408,11 +408,8 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
408#define MAX_TUPLE_SIZE 128 408#define MAX_TUPLE_SIZE 128
409static int ray_config(struct pcmcia_device *link) 409static int ray_config(struct pcmcia_device *link)
410{ 410{
411 tuple_t tuple;
412 cisparse_t parse;
413 int last_fn = 0, last_ret = 0; 411 int last_fn = 0, last_ret = 0;
414 int i; 412 int i;
415 u_char buf[MAX_TUPLE_SIZE];
416 win_req_t req; 413 win_req_t req;
417 memreq_t mem; 414 memreq_t mem;
418 struct net_device *dev = (struct net_device *)link->priv; 415 struct net_device *dev = (struct net_device *)link->priv;
@@ -420,29 +417,12 @@ static int ray_config(struct pcmcia_device *link)
420 417
421 DEBUG(1, "ray_config(0x%p)\n", link); 418 DEBUG(1, "ray_config(0x%p)\n", link);
422 419
423 /* This reads the card's CONFIG tuple to find its configuration regs */
424 tuple.DesiredTuple = CISTPL_CONFIG;
425 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
426 tuple.TupleData = buf;
427 tuple.TupleDataMax = MAX_TUPLE_SIZE;
428 tuple.TupleOffset = 0;
429 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
430 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
431 link->conf.ConfigBase = parse.config.base;
432 link->conf.Present = parse.config.rmask[0];
433
434 /* Determine card type and firmware version */ 420 /* Determine card type and firmware version */
435 buf[0] = buf[MAX_TUPLE_SIZE - 1] = 0; 421 printk(KERN_INFO "ray_cs Detected: %s%s%s%s\n",
436 tuple.DesiredTuple = CISTPL_VERS_1; 422 link->prod_id[0] ? link->prod_id[0] : " ",
437 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 423 link->prod_id[1] ? link->prod_id[1] : " ",
438 tuple.TupleData = buf; 424 link->prod_id[2] ? link->prod_id[2] : " ",
439 tuple.TupleDataMax = MAX_TUPLE_SIZE; 425 link->prod_id[3] ? link->prod_id[3] : " ");
440 tuple.TupleOffset = 2;
441 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
442
443 for (i=0; i<tuple.TupleDataLen - 4; i++)
444 if (buf[i] == 0) buf[i] = ' ';
445 printk(KERN_INFO "ray_cs Detected: %s\n",buf);
446 426
447 /* Now allocate an interrupt line. Note that this does not 427 /* Now allocate an interrupt line. Note that this does not
448 actually assign a handler to the interrupt. 428 actually assign a handler to the interrupt.
diff --git a/drivers/net/wireless/spectrum_cs.c b/drivers/net/wireless/spectrum_cs.c
index bcc7038130f6..cf2d1486b01d 100644
--- a/drivers/net/wireless/spectrum_cs.c
+++ b/drivers/net/wireless/spectrum_cs.c
@@ -647,21 +647,6 @@ spectrum_cs_config(struct pcmcia_device *link)
647 cisparse_t parse; 647 cisparse_t parse;
648 void __iomem *mem; 648 void __iomem *mem;
649 649
650 /*
651 * This reads the card's CONFIG tuple to find its
652 * configuration registers.
653 */
654 tuple.DesiredTuple = CISTPL_CONFIG;
655 tuple.Attributes = 0;
656 tuple.TupleData = buf;
657 tuple.TupleDataMax = sizeof(buf);
658 tuple.TupleOffset = 0;
659 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
660 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
661 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
662 link->conf.ConfigBase = parse.config.base;
663 link->conf.Present = parse.config.rmask[0];
664
665 /* Look up the current Vcc */ 650 /* Look up the current Vcc */
666 CS_CHECK(GetConfigurationInfo, 651 CS_CHECK(GetConfigurationInfo,
667 pcmcia_get_configuration_info(link, &conf)); 652 pcmcia_get_configuration_info(link, &conf));
@@ -681,6 +666,10 @@ spectrum_cs_config(struct pcmcia_device *link)
681 * implementation-defined details. 666 * implementation-defined details.
682 */ 667 */
683 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 668 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
669 tuple.Attributes = 0;
670 tuple.TupleData = buf;
671 tuple.TupleDataMax = sizeof(buf);
672 tuple.TupleOffset = 0;
684 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 673 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
685 while (1) { 674 while (1) {
686 cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); 675 cistpl_cftable_entry_t *cfg = &(parse.cftable_entry);
diff --git a/drivers/net/wireless/wavelan_cs.c b/drivers/net/wireless/wavelan_cs.c
index aafb301041b1..233d906c08f0 100644
--- a/drivers/net/wireless/wavelan_cs.c
+++ b/drivers/net/wireless/wavelan_cs.c
@@ -3939,11 +3939,8 @@ wv_hw_reset(struct net_device * dev)
3939static inline int 3939static inline int
3940wv_pcmcia_config(struct pcmcia_device * link) 3940wv_pcmcia_config(struct pcmcia_device * link)
3941{ 3941{
3942 tuple_t tuple;
3943 cisparse_t parse;
3944 struct net_device * dev = (struct net_device *) link->priv; 3942 struct net_device * dev = (struct net_device *) link->priv;
3945 int i; 3943 int i;
3946 u_char buf[64];
3947 win_req_t req; 3944 win_req_t req;
3948 memreq_t mem; 3945 memreq_t mem;
3949 net_local * lp = netdev_priv(dev); 3946 net_local * lp = netdev_priv(dev);
@@ -3953,36 +3950,6 @@ wv_pcmcia_config(struct pcmcia_device * link)
3953 printk(KERN_DEBUG "->wv_pcmcia_config(0x%p)\n", link); 3950 printk(KERN_DEBUG "->wv_pcmcia_config(0x%p)\n", link);
3954#endif 3951#endif
3955 3952
3956 /*
3957 * This reads the card's CONFIG tuple to find its configuration
3958 * registers.
3959 */
3960 do
3961 {
3962 tuple.Attributes = 0;
3963 tuple.DesiredTuple = CISTPL_CONFIG;
3964 i = pcmcia_get_first_tuple(link, &tuple);
3965 if(i != CS_SUCCESS)
3966 break;
3967 tuple.TupleData = (cisdata_t *)buf;
3968 tuple.TupleDataMax = 64;
3969 tuple.TupleOffset = 0;
3970 i = pcmcia_get_tuple_data(link, &tuple);
3971 if(i != CS_SUCCESS)
3972 break;
3973 i = pcmcia_parse_tuple(link, &tuple, &parse);
3974 if(i != CS_SUCCESS)
3975 break;
3976 link->conf.ConfigBase = parse.config.base;
3977 link->conf.Present = parse.config.rmask[0];
3978 }
3979 while(0);
3980 if(i != CS_SUCCESS)
3981 {
3982 cs_error(link, ParseTuple, i);
3983 return FALSE;
3984 }
3985
3986 do 3953 do
3987 { 3954 {
3988 i = pcmcia_request_io(link, &link->io); 3955 i = pcmcia_request_io(link, &link->io);
diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c
index 5b98a7876982..583e0d655a98 100644
--- a/drivers/net/wireless/wl3501_cs.c
+++ b/drivers/net/wireless/wl3501_cs.c
@@ -1966,25 +1966,10 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
1966 */ 1966 */
1967static int wl3501_config(struct pcmcia_device *link) 1967static int wl3501_config(struct pcmcia_device *link)
1968{ 1968{
1969 tuple_t tuple;
1970 cisparse_t parse;
1971 struct net_device *dev = link->priv; 1969 struct net_device *dev = link->priv;
1972 int i = 0, j, last_fn, last_ret; 1970 int i = 0, j, last_fn, last_ret;
1973 unsigned char bf[64];
1974 struct wl3501_card *this; 1971 struct wl3501_card *this;
1975 1972
1976 /* This reads the card's CONFIG tuple to find its config registers. */
1977 tuple.Attributes = 0;
1978 tuple.DesiredTuple = CISTPL_CONFIG;
1979 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
1980 tuple.TupleData = bf;
1981 tuple.TupleDataMax = sizeof(bf);
1982 tuple.TupleOffset = 0;
1983 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
1984 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
1985 link->conf.ConfigBase = parse.config.base;
1986 link->conf.Present = parse.config.rmask[0];
1987
1988 /* Try allocating IO ports. This tries a few fixed addresses. If you 1973 /* Try allocating IO ports. This tries a few fixed addresses. If you
1989 * want, you can also read the card's config table to pick addresses -- 1974 * want, you can also read the card's config table to pick addresses --
1990 * see the serial driver for an example. */ 1975 * see the serial driver for an example. */
diff --git a/drivers/net/wireless/zd1201.c b/drivers/net/wireless/zd1201.c
index 36b29ff05814..6cb66a356c96 100644
--- a/drivers/net/wireless/zd1201.c
+++ b/drivers/net/wireless/zd1201.c
@@ -1828,10 +1828,8 @@ err_start:
1828 /* Leave the device in reset state */ 1828 /* Leave the device in reset state */
1829 zd1201_docmd(zd, ZD1201_CMDCODE_INIT, 0, 0, 0); 1829 zd1201_docmd(zd, ZD1201_CMDCODE_INIT, 0, 0, 0);
1830err_zd: 1830err_zd:
1831 if (zd->tx_urb) 1831 usb_free_urb(zd->tx_urb);
1832 usb_free_urb(zd->tx_urb); 1832 usb_free_urb(zd->rx_urb);
1833 if (zd->rx_urb)
1834 usb_free_urb(zd->rx_urb);
1835 kfree(zd); 1833 kfree(zd);
1836 return err; 1834 return err;
1837} 1835}
diff --git a/drivers/net/wireless/zd1211rw/zd_chip.c b/drivers/net/wireless/zd1211rw/zd_chip.c
index aa661b2b76c7..77e11ddad836 100644
--- a/drivers/net/wireless/zd1211rw/zd_chip.c
+++ b/drivers/net/wireless/zd1211rw/zd_chip.c
@@ -1076,6 +1076,31 @@ static int set_mandatory_rates(struct zd_chip *chip, enum ieee80211_std std)
1076 return zd_iowrite32_locked(chip, rates, CR_MANDATORY_RATE_TBL); 1076 return zd_iowrite32_locked(chip, rates, CR_MANDATORY_RATE_TBL);
1077} 1077}
1078 1078
1079int zd_chip_set_rts_cts_rate_locked(struct zd_chip *chip,
1080 u8 rts_rate, int preamble)
1081{
1082 int rts_mod = ZD_RX_CCK;
1083 u32 value = 0;
1084
1085 /* Modulation bit */
1086 if (ZD_CS_TYPE(rts_rate) == ZD_CS_OFDM)
1087 rts_mod = ZD_RX_OFDM;
1088
1089 dev_dbg_f(zd_chip_dev(chip), "rts_rate=%x preamble=%x\n",
1090 rts_rate, preamble);
1091
1092 value |= rts_rate << RTSCTS_SH_RTS_RATE;
1093 value |= rts_mod << RTSCTS_SH_RTS_MOD_TYPE;
1094 value |= preamble << RTSCTS_SH_RTS_PMB_TYPE;
1095 value |= preamble << RTSCTS_SH_CTS_PMB_TYPE;
1096
1097 /* We always send 11M self-CTS messages, like the vendor driver. */
1098 value |= ZD_CCK_RATE_11M << RTSCTS_SH_CTS_RATE;
1099 value |= ZD_RX_CCK << RTSCTS_SH_CTS_MOD_TYPE;
1100
1101 return zd_iowrite32_locked(chip, value, CR_RTS_CTS_RATE);
1102}
1103
1079int zd_chip_enable_hwint(struct zd_chip *chip) 1104int zd_chip_enable_hwint(struct zd_chip *chip)
1080{ 1105{
1081 int r; 1106 int r;
@@ -1355,17 +1380,12 @@ out:
1355 return r; 1380 return r;
1356} 1381}
1357 1382
1358int zd_chip_set_basic_rates(struct zd_chip *chip, u16 cr_rates) 1383int zd_chip_set_basic_rates_locked(struct zd_chip *chip, u16 cr_rates)
1359{ 1384{
1360 int r; 1385 ZD_ASSERT((cr_rates & ~(CR_RATES_80211B | CR_RATES_80211G)) == 0);
1386 dev_dbg_f(zd_chip_dev(chip), "%x\n", cr_rates);
1361 1387
1362 if (cr_rates & ~(CR_RATES_80211B|CR_RATES_80211G)) 1388 return zd_iowrite32_locked(chip, cr_rates, CR_BASIC_RATE_TBL);
1363 return -EINVAL;
1364
1365 mutex_lock(&chip->mutex);
1366 r = zd_iowrite32_locked(chip, cr_rates, CR_BASIC_RATE_TBL);
1367 mutex_unlock(&chip->mutex);
1368 return r;
1369} 1389}
1370 1390
1371static int ofdm_qual_db(u8 status_quality, u8 rate, unsigned int size) 1391static int ofdm_qual_db(u8 status_quality, u8 rate, unsigned int size)
@@ -1653,3 +1673,16 @@ int zd_rfwritev_cr_locked(struct zd_chip *chip,
1653 1673
1654 return 0; 1674 return 0;
1655} 1675}
1676
1677int zd_chip_set_multicast_hash(struct zd_chip *chip,
1678 struct zd_mc_hash *hash)
1679{
1680 struct zd_ioreq32 ioreqs[] = {
1681 { CR_GROUP_HASH_P1, hash->low },
1682 { CR_GROUP_HASH_P2, hash->high },
1683 };
1684
1685 dev_dbg_f(zd_chip_dev(chip), "hash l 0x%08x h 0x%08x\n",
1686 ioreqs[0].value, ioreqs[1].value);
1687 return zd_iowrite32a(chip, ioreqs, ARRAY_SIZE(ioreqs));
1688}
diff --git a/drivers/net/wireless/zd1211rw/zd_chip.h b/drivers/net/wireless/zd1211rw/zd_chip.h
index ae59597ce4e1..a4e3cee9b59d 100644
--- a/drivers/net/wireless/zd1211rw/zd_chip.h
+++ b/drivers/net/wireless/zd1211rw/zd_chip.h
@@ -337,24 +337,24 @@
337#define CR_MAC_PS_STATE CTL_REG(0x050C) 337#define CR_MAC_PS_STATE CTL_REG(0x050C)
338 338
339#define CR_INTERRUPT CTL_REG(0x0510) 339#define CR_INTERRUPT CTL_REG(0x0510)
340#define INT_TX_COMPLETE 0x00000001 340#define INT_TX_COMPLETE (1 << 0)
341#define INT_RX_COMPLETE 0x00000002 341#define INT_RX_COMPLETE (1 << 1)
342#define INT_RETRY_FAIL 0x00000004 342#define INT_RETRY_FAIL (1 << 2)
343#define INT_WAKEUP 0x00000008 343#define INT_WAKEUP (1 << 3)
344#define INT_DTIM_NOTIFY 0x00000020 344#define INT_DTIM_NOTIFY (1 << 5)
345#define INT_CFG_NEXT_BCN 0x00000040 345#define INT_CFG_NEXT_BCN (1 << 6)
346#define INT_BUS_ABORT 0x00000080 346#define INT_BUS_ABORT (1 << 7)
347#define INT_TX_FIFO_READY 0x00000100 347#define INT_TX_FIFO_READY (1 << 8)
348#define INT_UART 0x00000200 348#define INT_UART (1 << 9)
349#define INT_TX_COMPLETE_EN 0x00010000 349#define INT_TX_COMPLETE_EN (1 << 16)
350#define INT_RX_COMPLETE_EN 0x00020000 350#define INT_RX_COMPLETE_EN (1 << 17)
351#define INT_RETRY_FAIL_EN 0x00040000 351#define INT_RETRY_FAIL_EN (1 << 18)
352#define INT_WAKEUP_EN 0x00080000 352#define INT_WAKEUP_EN (1 << 19)
353#define INT_DTIM_NOTIFY_EN 0x00200000 353#define INT_DTIM_NOTIFY_EN (1 << 21)
354#define INT_CFG_NEXT_BCN_EN 0x00400000 354#define INT_CFG_NEXT_BCN_EN (1 << 22)
355#define INT_BUS_ABORT_EN 0x00800000 355#define INT_BUS_ABORT_EN (1 << 23)
356#define INT_TX_FIFO_READY_EN 0x01000000 356#define INT_TX_FIFO_READY_EN (1 << 24)
357#define INT_UART_EN 0x02000000 357#define INT_UART_EN (1 << 25)
358 358
359#define CR_TSF_LOW_PART CTL_REG(0x0514) 359#define CR_TSF_LOW_PART CTL_REG(0x0514)
360#define CR_TSF_HIGH_PART CTL_REG(0x0518) 360#define CR_TSF_HIGH_PART CTL_REG(0x0518)
@@ -390,26 +390,35 @@
390#define CR_BSSID_P1 CTL_REG(0x0618) 390#define CR_BSSID_P1 CTL_REG(0x0618)
391#define CR_BSSID_P2 CTL_REG(0x061C) 391#define CR_BSSID_P2 CTL_REG(0x061C)
392#define CR_BCN_PLCP_CFG CTL_REG(0x0620) 392#define CR_BCN_PLCP_CFG CTL_REG(0x0620)
393
394/* Group hash table for filtering incoming packets.
395 *
396 * The group hash table is 64 bit large and split over two parts. The first
397 * part is the lower part. The upper 6 bits of the last byte of the target
398 * address are used as index. Packets are received if the hash table bit is
399 * set. This is used for multicast handling, but for broadcasts (address
400 * ff:ff:ff:ff:ff:ff) the highest bit in the second table must also be set.
401 */
393#define CR_GROUP_HASH_P1 CTL_REG(0x0624) 402#define CR_GROUP_HASH_P1 CTL_REG(0x0624)
394#define CR_GROUP_HASH_P2 CTL_REG(0x0628) 403#define CR_GROUP_HASH_P2 CTL_REG(0x0628)
395#define CR_RX_TIMEOUT CTL_REG(0x062C)
396 404
405#define CR_RX_TIMEOUT CTL_REG(0x062C)
397/* Basic rates supported by the BSS. When producing ACK or CTS messages, the 406/* Basic rates supported by the BSS. When producing ACK or CTS messages, the
398 * device will use a rate in this table that is less than or equal to the rate 407 * device will use a rate in this table that is less than or equal to the rate
399 * of the incoming frame which prompted the response */ 408 * of the incoming frame which prompted the response */
400#define CR_BASIC_RATE_TBL CTL_REG(0x0630) 409#define CR_BASIC_RATE_TBL CTL_REG(0x0630)
401#define CR_RATE_1M 0x0001 /* 802.11b */ 410#define CR_RATE_1M (1 << 0) /* 802.11b */
402#define CR_RATE_2M 0x0002 /* 802.11b */ 411#define CR_RATE_2M (1 << 1) /* 802.11b */
403#define CR_RATE_5_5M 0x0004 /* 802.11b */ 412#define CR_RATE_5_5M (1 << 2) /* 802.11b */
404#define CR_RATE_11M 0x0008 /* 802.11b */ 413#define CR_RATE_11M (1 << 3) /* 802.11b */
405#define CR_RATE_6M 0x0100 /* 802.11g */ 414#define CR_RATE_6M (1 << 8) /* 802.11g */
406#define CR_RATE_9M 0x0200 /* 802.11g */ 415#define CR_RATE_9M (1 << 9) /* 802.11g */
407#define CR_RATE_12M 0x0400 /* 802.11g */ 416#define CR_RATE_12M (1 << 10) /* 802.11g */
408#define CR_RATE_18M 0x0800 /* 802.11g */ 417#define CR_RATE_18M (1 << 11) /* 802.11g */
409#define CR_RATE_24M 0x1000 /* 802.11g */ 418#define CR_RATE_24M (1 << 12) /* 802.11g */
410#define CR_RATE_36M 0x2000 /* 802.11g */ 419#define CR_RATE_36M (1 << 13) /* 802.11g */
411#define CR_RATE_48M 0x4000 /* 802.11g */ 420#define CR_RATE_48M (1 << 14) /* 802.11g */
412#define CR_RATE_54M 0x8000 /* 802.11g */ 421#define CR_RATE_54M (1 << 15) /* 802.11g */
413#define CR_RATES_80211G 0xff00 422#define CR_RATES_80211G 0xff00
414#define CR_RATES_80211B 0x000f 423#define CR_RATES_80211B 0x000f
415 424
@@ -420,15 +429,24 @@
420#define CR_MANDATORY_RATE_TBL CTL_REG(0x0634) 429#define CR_MANDATORY_RATE_TBL CTL_REG(0x0634)
421#define CR_RTS_CTS_RATE CTL_REG(0x0638) 430#define CR_RTS_CTS_RATE CTL_REG(0x0638)
422 431
432/* These are all bit indexes in CR_RTS_CTS_RATE, so remember to shift. */
433#define RTSCTS_SH_RTS_RATE 0
434#define RTSCTS_SH_EXP_CTS_RATE 4
435#define RTSCTS_SH_RTS_MOD_TYPE 8
436#define RTSCTS_SH_RTS_PMB_TYPE 9
437#define RTSCTS_SH_CTS_RATE 16
438#define RTSCTS_SH_CTS_MOD_TYPE 24
439#define RTSCTS_SH_CTS_PMB_TYPE 25
440
423#define CR_WEP_PROTECT CTL_REG(0x063C) 441#define CR_WEP_PROTECT CTL_REG(0x063C)
424#define CR_RX_THRESHOLD CTL_REG(0x0640) 442#define CR_RX_THRESHOLD CTL_REG(0x0640)
425 443
426/* register for controlling the LEDS */ 444/* register for controlling the LEDS */
427#define CR_LED CTL_REG(0x0644) 445#define CR_LED CTL_REG(0x0644)
428/* masks for controlling LEDs */ 446/* masks for controlling LEDs */
429#define LED1 0x0100 447#define LED1 (1 << 8)
430#define LED2 0x0200 448#define LED2 (1 << 9)
431#define LED_SW 0x0400 449#define LED_SW (1 << 10)
432 450
433/* Seems to indicate that the configuration is over. 451/* Seems to indicate that the configuration is over.
434 */ 452 */
@@ -455,18 +473,18 @@
455 * registers, so one could argue it is a LOCK bit. But calling it 473 * registers, so one could argue it is a LOCK bit. But calling it
456 * LOCK_PHY_REGS makes it confusing. 474 * LOCK_PHY_REGS makes it confusing.
457 */ 475 */
458#define UNLOCK_PHY_REGS 0x0080 476#define UNLOCK_PHY_REGS (1 << 7)
459 477
460#define CR_DEVICE_STATE CTL_REG(0x0684) 478#define CR_DEVICE_STATE CTL_REG(0x0684)
461#define CR_UNDERRUN_CNT CTL_REG(0x0688) 479#define CR_UNDERRUN_CNT CTL_REG(0x0688)
462 480
463#define CR_RX_FILTER CTL_REG(0x068c) 481#define CR_RX_FILTER CTL_REG(0x068c)
464#define RX_FILTER_ASSOC_RESPONSE 0x0002 482#define RX_FILTER_ASSOC_RESPONSE (1 << 1)
465#define RX_FILTER_REASSOC_RESPONSE 0x0008 483#define RX_FILTER_REASSOC_RESPONSE (1 << 3)
466#define RX_FILTER_PROBE_RESPONSE 0x0020 484#define RX_FILTER_PROBE_RESPONSE (1 << 5)
467#define RX_FILTER_BEACON 0x0100 485#define RX_FILTER_BEACON (1 << 8)
468#define RX_FILTER_DISASSOC 0x0400 486#define RX_FILTER_DISASSOC (1 << 10)
469#define RX_FILTER_AUTH 0x0800 487#define RX_FILTER_AUTH (1 << 11)
470#define AP_RX_FILTER 0x0400feff 488#define AP_RX_FILTER 0x0400feff
471#define STA_RX_FILTER 0x0000ffff 489#define STA_RX_FILTER 0x0000ffff
472 490
@@ -794,6 +812,9 @@ void zd_chip_disable_rx(struct zd_chip *chip);
794int zd_chip_enable_hwint(struct zd_chip *chip); 812int zd_chip_enable_hwint(struct zd_chip *chip);
795int zd_chip_disable_hwint(struct zd_chip *chip); 813int zd_chip_disable_hwint(struct zd_chip *chip);
796 814
815int zd_chip_set_rts_cts_rate_locked(struct zd_chip *chip,
816 u8 rts_rate, int preamble);
817
797static inline int zd_get_encryption_type(struct zd_chip *chip, u32 *type) 818static inline int zd_get_encryption_type(struct zd_chip *chip, u32 *type)
798{ 819{
799 return zd_ioread32(chip, CR_ENCRYPTION_TYPE, type); 820 return zd_ioread32(chip, CR_ENCRYPTION_TYPE, type);
@@ -809,7 +830,17 @@ static inline int zd_chip_get_basic_rates(struct zd_chip *chip, u16 *cr_rates)
809 return zd_ioread16(chip, CR_BASIC_RATE_TBL, cr_rates); 830 return zd_ioread16(chip, CR_BASIC_RATE_TBL, cr_rates);
810} 831}
811 832
812int zd_chip_set_basic_rates(struct zd_chip *chip, u16 cr_rates); 833int zd_chip_set_basic_rates_locked(struct zd_chip *chip, u16 cr_rates);
834
835static inline int zd_chip_set_basic_rates(struct zd_chip *chip, u16 cr_rates)
836{
837 int r;
838
839 mutex_lock(&chip->mutex);
840 r = zd_chip_set_basic_rates_locked(chip, cr_rates);
841 mutex_unlock(&chip->mutex);
842 return r;
843}
813 844
814static inline int zd_chip_set_rx_filter(struct zd_chip *chip, u32 filter) 845static inline int zd_chip_set_rx_filter(struct zd_chip *chip, u32 filter)
815{ 846{
@@ -842,4 +873,36 @@ u8 zd_rx_strength_percent(u8 rssi);
842 873
843u16 zd_rx_rate(const void *rx_frame, const struct rx_status *status); 874u16 zd_rx_rate(const void *rx_frame, const struct rx_status *status);
844 875
876struct zd_mc_hash {
877 u32 low;
878 u32 high;
879};
880
881static inline void zd_mc_clear(struct zd_mc_hash *hash)
882{
883 hash->low = 0;
884 /* The interfaces must always received broadcasts.
885 * The hash of the broadcast address ff:ff:ff:ff:ff:ff is 63.
886 */
887 hash->high = 0x80000000;
888}
889
890static inline void zd_mc_add_all(struct zd_mc_hash *hash)
891{
892 hash->low = hash->high = 0xffffffff;
893}
894
895static inline void zd_mc_add_addr(struct zd_mc_hash *hash, u8 *addr)
896{
897 unsigned int i = addr[5] >> 2;
898 if (i < 32) {
899 hash->low |= 1 << i;
900 } else {
901 hash->high |= 1 << (i-32);
902 }
903}
904
905int zd_chip_set_multicast_hash(struct zd_chip *chip,
906 struct zd_mc_hash *hash);
907
845#endif /* _ZD_CHIP_H */ 908#endif /* _ZD_CHIP_H */
diff --git a/drivers/net/wireless/zd1211rw/zd_def.h b/drivers/net/wireless/zd1211rw/zd_def.h
index a13ec72eb304..fb22f62cf1f3 100644
--- a/drivers/net/wireless/zd1211rw/zd_def.h
+++ b/drivers/net/wireless/zd1211rw/zd_def.h
@@ -39,6 +39,7 @@ do { \
39 if (!(x)) { \ 39 if (!(x)) { \
40 pr_debug("%s:%d ASSERT %s VIOLATED!\n", \ 40 pr_debug("%s:%d ASSERT %s VIOLATED!\n", \
41 __FILE__, __LINE__, __stringify(x)); \ 41 __FILE__, __LINE__, __stringify(x)); \
42 dump_stack(); \
42 } \ 43 } \
43} while (0) 44} while (0)
44#else 45#else
diff --git a/drivers/net/wireless/zd1211rw/zd_ieee80211.c b/drivers/net/wireless/zd1211rw/zd_ieee80211.c
index 66905f7b61ff..189160efd2ae 100644
--- a/drivers/net/wireless/zd1211rw/zd_ieee80211.c
+++ b/drivers/net/wireless/zd1211rw/zd_ieee80211.c
@@ -37,7 +37,12 @@ static const struct channel_range channel_ranges[] = {
37 [ZD_REGDOMAIN_JAPAN] = { 1, 14}, 37 [ZD_REGDOMAIN_JAPAN] = { 1, 14},
38 [ZD_REGDOMAIN_SPAIN] = { 1, 14}, 38 [ZD_REGDOMAIN_SPAIN] = { 1, 14},
39 [ZD_REGDOMAIN_FRANCE] = { 1, 14}, 39 [ZD_REGDOMAIN_FRANCE] = { 1, 14},
40 [ZD_REGDOMAIN_JAPAN_ADD] = {14, 15}, 40
41 /* Japan originally only had channel 14 available (see CHNL_ID 0x40 in
42 * 802.11). However, in 2001 the range was extended to include channels
43 * 1-13. The ZyDAS devices still use the old region code but are
44 * designed to allow the extra channel access in Japan. */
45 [ZD_REGDOMAIN_JAPAN_ADD] = { 1, 15},
41}; 46};
42 47
43const struct channel_range *zd_channel_range(u8 regdomain) 48const struct channel_range *zd_channel_range(u8 regdomain)
@@ -133,9 +138,6 @@ int zd_find_channel(u8 *channel, const struct iw_freq *freq)
133 int i, r; 138 int i, r;
134 u32 mhz; 139 u32 mhz;
135 140
136 if (!(freq->flags & IW_FREQ_FIXED))
137 return 0;
138
139 if (freq->m < 1000) { 141 if (freq->m < 1000) {
140 if (freq->m > NUM_CHANNELS || freq->m == 0) 142 if (freq->m > NUM_CHANNELS || freq->m == 0)
141 return -EINVAL; 143 return -EINVAL;
diff --git a/drivers/net/wireless/zd1211rw/zd_ieee80211.h b/drivers/net/wireless/zd1211rw/zd_ieee80211.h
index f63245b0d966..26b8298dff8c 100644
--- a/drivers/net/wireless/zd1211rw/zd_ieee80211.h
+++ b/drivers/net/wireless/zd1211rw/zd_ieee80211.h
@@ -50,6 +50,7 @@ static inline u8 zd_ofdm_plcp_header_rate(
50 return header->prefix[0] & 0xf; 50 return header->prefix[0] & 0xf;
51} 51}
52 52
53/* These are referred to as zd_rates */
53#define ZD_OFDM_RATE_6M 0xb 54#define ZD_OFDM_RATE_6M 0xb
54#define ZD_OFDM_RATE_9M 0xf 55#define ZD_OFDM_RATE_9M 0xf
55#define ZD_OFDM_RATE_12M 0xa 56#define ZD_OFDM_RATE_12M 0xa
@@ -64,7 +65,7 @@ struct cck_plcp_header {
64 u8 service; 65 u8 service;
65 __le16 length; 66 __le16 length;
66 __le16 crc16; 67 __le16 crc16;
67}; 68} __attribute__((packed));
68 69
69static inline u8 zd_cck_plcp_header_rate(const struct cck_plcp_header *header) 70static inline u8 zd_cck_plcp_header_rate(const struct cck_plcp_header *header)
70{ 71{
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c
index a7d29bddb298..00ca704ece35 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.c
+++ b/drivers/net/wireless/zd1211rw/zd_mac.c
@@ -32,11 +32,15 @@
32 32
33static void ieee_init(struct ieee80211_device *ieee); 33static void ieee_init(struct ieee80211_device *ieee);
34static void softmac_init(struct ieee80211softmac_device *sm); 34static void softmac_init(struct ieee80211softmac_device *sm);
35static void set_rts_cts_work(struct work_struct *work);
36static void set_basic_rates_work(struct work_struct *work);
35 37
36static void housekeeping_init(struct zd_mac *mac); 38static void housekeeping_init(struct zd_mac *mac);
37static void housekeeping_enable(struct zd_mac *mac); 39static void housekeeping_enable(struct zd_mac *mac);
38static void housekeeping_disable(struct zd_mac *mac); 40static void housekeeping_disable(struct zd_mac *mac);
39 41
42static void set_multicast_hash_handler(struct work_struct *work);
43
40int zd_mac_init(struct zd_mac *mac, 44int zd_mac_init(struct zd_mac *mac,
41 struct net_device *netdev, 45 struct net_device *netdev,
42 struct usb_interface *intf) 46 struct usb_interface *intf)
@@ -46,11 +50,14 @@ int zd_mac_init(struct zd_mac *mac,
46 memset(mac, 0, sizeof(*mac)); 50 memset(mac, 0, sizeof(*mac));
47 spin_lock_init(&mac->lock); 51 spin_lock_init(&mac->lock);
48 mac->netdev = netdev; 52 mac->netdev = netdev;
53 INIT_DELAYED_WORK(&mac->set_rts_cts_work, set_rts_cts_work);
54 INIT_DELAYED_WORK(&mac->set_basic_rates_work, set_basic_rates_work);
49 55
50 ieee_init(ieee); 56 ieee_init(ieee);
51 softmac_init(ieee80211_priv(netdev)); 57 softmac_init(ieee80211_priv(netdev));
52 zd_chip_init(&mac->chip, netdev, intf); 58 zd_chip_init(&mac->chip, netdev, intf);
53 housekeeping_init(mac); 59 housekeeping_init(mac);
60 INIT_WORK(&mac->set_multicast_hash_work, set_multicast_hash_handler);
54 return 0; 61 return 0;
55} 62}
56 63
@@ -132,6 +139,7 @@ out:
132 139
133void zd_mac_clear(struct zd_mac *mac) 140void zd_mac_clear(struct zd_mac *mac)
134{ 141{
142 flush_workqueue(zd_workqueue);
135 zd_chip_clear(&mac->chip); 143 zd_chip_clear(&mac->chip);
136 ZD_ASSERT(!spin_is_locked(&mac->lock)); 144 ZD_ASSERT(!spin_is_locked(&mac->lock));
137 ZD_MEMCLEAR(mac, sizeof(struct zd_mac)); 145 ZD_MEMCLEAR(mac, sizeof(struct zd_mac));
@@ -213,6 +221,13 @@ int zd_mac_stop(struct net_device *netdev)
213 housekeeping_disable(mac); 221 housekeeping_disable(mac);
214 ieee80211softmac_stop(netdev); 222 ieee80211softmac_stop(netdev);
215 223
224 /* Ensure no work items are running or queued from this point */
225 cancel_delayed_work(&mac->set_rts_cts_work);
226 cancel_delayed_work(&mac->set_basic_rates_work);
227 flush_workqueue(zd_workqueue);
228 mac->updating_rts_rate = 0;
229 mac->updating_basic_rates = 0;
230
216 zd_chip_disable_hwint(chip); 231 zd_chip_disable_hwint(chip);
217 zd_chip_switch_radio_off(chip); 232 zd_chip_switch_radio_off(chip);
218 zd_chip_disable_int(chip); 233 zd_chip_disable_int(chip);
@@ -245,6 +260,43 @@ int zd_mac_set_mac_address(struct net_device *netdev, void *p)
245 return 0; 260 return 0;
246} 261}
247 262
263static void set_multicast_hash_handler(struct work_struct *work)
264{
265 struct zd_mac *mac = container_of(work, struct zd_mac,
266 set_multicast_hash_work);
267 struct zd_mc_hash hash;
268
269 spin_lock_irq(&mac->lock);
270 hash = mac->multicast_hash;
271 spin_unlock_irq(&mac->lock);
272
273 zd_chip_set_multicast_hash(&mac->chip, &hash);
274}
275
276void zd_mac_set_multicast_list(struct net_device *dev)
277{
278 struct zd_mc_hash hash;
279 struct zd_mac *mac = zd_netdev_mac(dev);
280 struct dev_mc_list *mc;
281 unsigned long flags;
282
283 if (dev->flags & (IFF_PROMISC|IFF_ALLMULTI)) {
284 zd_mc_add_all(&hash);
285 } else {
286 zd_mc_clear(&hash);
287 for (mc = dev->mc_list; mc; mc = mc->next) {
288 dev_dbg_f(zd_mac_dev(mac), "mc addr " MAC_FMT "\n",
289 MAC_ARG(mc->dmi_addr));
290 zd_mc_add_addr(&hash, mc->dmi_addr);
291 }
292 }
293
294 spin_lock_irqsave(&mac->lock, flags);
295 mac->multicast_hash = hash;
296 spin_unlock_irqrestore(&mac->lock, flags);
297 queue_work(zd_workqueue, &mac->set_multicast_hash_work);
298}
299
248int zd_mac_set_regdomain(struct zd_mac *mac, u8 regdomain) 300int zd_mac_set_regdomain(struct zd_mac *mac, u8 regdomain)
249{ 301{
250 int r; 302 int r;
@@ -286,6 +338,189 @@ u8 zd_mac_get_regdomain(struct zd_mac *mac)
286 return regdomain; 338 return regdomain;
287} 339}
288 340
341/* Fallback to lowest rate, if rate is unknown. */
342static u8 rate_to_zd_rate(u8 rate)
343{
344 switch (rate) {
345 case IEEE80211_CCK_RATE_2MB:
346 return ZD_CCK_RATE_2M;
347 case IEEE80211_CCK_RATE_5MB:
348 return ZD_CCK_RATE_5_5M;
349 case IEEE80211_CCK_RATE_11MB:
350 return ZD_CCK_RATE_11M;
351 case IEEE80211_OFDM_RATE_6MB:
352 return ZD_OFDM_RATE_6M;
353 case IEEE80211_OFDM_RATE_9MB:
354 return ZD_OFDM_RATE_9M;
355 case IEEE80211_OFDM_RATE_12MB:
356 return ZD_OFDM_RATE_12M;
357 case IEEE80211_OFDM_RATE_18MB:
358 return ZD_OFDM_RATE_18M;
359 case IEEE80211_OFDM_RATE_24MB:
360 return ZD_OFDM_RATE_24M;
361 case IEEE80211_OFDM_RATE_36MB:
362 return ZD_OFDM_RATE_36M;
363 case IEEE80211_OFDM_RATE_48MB:
364 return ZD_OFDM_RATE_48M;
365 case IEEE80211_OFDM_RATE_54MB:
366 return ZD_OFDM_RATE_54M;
367 }
368 return ZD_CCK_RATE_1M;
369}
370
371static u16 rate_to_cr_rate(u8 rate)
372{
373 switch (rate) {
374 case IEEE80211_CCK_RATE_2MB:
375 return CR_RATE_1M;
376 case IEEE80211_CCK_RATE_5MB:
377 return CR_RATE_5_5M;
378 case IEEE80211_CCK_RATE_11MB:
379 return CR_RATE_11M;
380 case IEEE80211_OFDM_RATE_6MB:
381 return CR_RATE_6M;
382 case IEEE80211_OFDM_RATE_9MB:
383 return CR_RATE_9M;
384 case IEEE80211_OFDM_RATE_12MB:
385 return CR_RATE_12M;
386 case IEEE80211_OFDM_RATE_18MB:
387 return CR_RATE_18M;
388 case IEEE80211_OFDM_RATE_24MB:
389 return CR_RATE_24M;
390 case IEEE80211_OFDM_RATE_36MB:
391 return CR_RATE_36M;
392 case IEEE80211_OFDM_RATE_48MB:
393 return CR_RATE_48M;
394 case IEEE80211_OFDM_RATE_54MB:
395 return CR_RATE_54M;
396 }
397 return CR_RATE_1M;
398}
399
400static void try_enable_tx(struct zd_mac *mac)
401{
402 unsigned long flags;
403
404 spin_lock_irqsave(&mac->lock, flags);
405 if (mac->updating_rts_rate == 0 && mac->updating_basic_rates == 0)
406 netif_wake_queue(mac->netdev);
407 spin_unlock_irqrestore(&mac->lock, flags);
408}
409
410static void set_rts_cts_work(struct work_struct *work)
411{
412 struct zd_mac *mac =
413 container_of(work, struct zd_mac, set_rts_cts_work.work);
414 unsigned long flags;
415 u8 rts_rate;
416 unsigned int short_preamble;
417
418 mutex_lock(&mac->chip.mutex);
419
420 spin_lock_irqsave(&mac->lock, flags);
421 mac->updating_rts_rate = 0;
422 rts_rate = mac->rts_rate;
423 short_preamble = mac->short_preamble;
424 spin_unlock_irqrestore(&mac->lock, flags);
425
426 zd_chip_set_rts_cts_rate_locked(&mac->chip, rts_rate, short_preamble);
427 mutex_unlock(&mac->chip.mutex);
428
429 try_enable_tx(mac);
430}
431
432static void set_basic_rates_work(struct work_struct *work)
433{
434 struct zd_mac *mac =
435 container_of(work, struct zd_mac, set_basic_rates_work.work);
436 unsigned long flags;
437 u16 basic_rates;
438
439 mutex_lock(&mac->chip.mutex);
440
441 spin_lock_irqsave(&mac->lock, flags);
442 mac->updating_basic_rates = 0;
443 basic_rates = mac->basic_rates;
444 spin_unlock_irqrestore(&mac->lock, flags);
445
446 zd_chip_set_basic_rates_locked(&mac->chip, basic_rates);
447 mutex_unlock(&mac->chip.mutex);
448
449 try_enable_tx(mac);
450}
451
452static void bssinfo_change(struct net_device *netdev, u32 changes)
453{
454 struct zd_mac *mac = zd_netdev_mac(netdev);
455 struct ieee80211softmac_device *softmac = ieee80211_priv(netdev);
456 struct ieee80211softmac_bss_info *bssinfo = &softmac->bssinfo;
457 int need_set_rts_cts = 0;
458 int need_set_rates = 0;
459 u16 basic_rates;
460 unsigned long flags;
461
462 dev_dbg_f(zd_mac_dev(mac), "changes: %x\n", changes);
463
464 if (changes & IEEE80211SOFTMAC_BSSINFOCHG_SHORT_PREAMBLE) {
465 spin_lock_irqsave(&mac->lock, flags);
466 mac->short_preamble = bssinfo->short_preamble;
467 spin_unlock_irqrestore(&mac->lock, flags);
468 need_set_rts_cts = 1;
469 }
470
471 if (changes & IEEE80211SOFTMAC_BSSINFOCHG_RATES) {
472 /* Set RTS rate to highest available basic rate */
473 u8 rate = ieee80211softmac_highest_supported_rate(softmac,
474 &bssinfo->supported_rates, 1);
475 rate = rate_to_zd_rate(rate);
476
477 spin_lock_irqsave(&mac->lock, flags);
478 if (rate != mac->rts_rate) {
479 mac->rts_rate = rate;
480 need_set_rts_cts = 1;
481 }
482 spin_unlock_irqrestore(&mac->lock, flags);
483
484 /* Set basic rates */
485 need_set_rates = 1;
486 if (bssinfo->supported_rates.count == 0) {
487 /* Allow the device to be flexible */
488 basic_rates = CR_RATES_80211B | CR_RATES_80211G;
489 } else {
490 int i = 0;
491 basic_rates = 0;
492
493 for (i = 0; i < bssinfo->supported_rates.count; i++) {
494 u16 rate = bssinfo->supported_rates.rates[i];
495 if ((rate & IEEE80211_BASIC_RATE_MASK) == 0)
496 continue;
497
498 rate &= ~IEEE80211_BASIC_RATE_MASK;
499 basic_rates |= rate_to_cr_rate(rate);
500 }
501 }
502 spin_lock_irqsave(&mac->lock, flags);
503 mac->basic_rates = basic_rates;
504 spin_unlock_irqrestore(&mac->lock, flags);
505 }
506
507 /* Schedule any changes we made above */
508
509 spin_lock_irqsave(&mac->lock, flags);
510 if (need_set_rts_cts && !mac->updating_rts_rate) {
511 mac->updating_rts_rate = 1;
512 netif_stop_queue(mac->netdev);
513 queue_delayed_work(zd_workqueue, &mac->set_rts_cts_work, 0);
514 }
515 if (need_set_rates && !mac->updating_basic_rates) {
516 mac->updating_basic_rates = 1;
517 netif_stop_queue(mac->netdev);
518 queue_delayed_work(zd_workqueue, &mac->set_basic_rates_work,
519 0);
520 }
521 spin_unlock_irqrestore(&mac->lock, flags);
522}
523
289static void set_channel(struct net_device *netdev, u8 channel) 524static void set_channel(struct net_device *netdev, u8 channel)
290{ 525{
291 struct zd_mac *mac = zd_netdev_mac(netdev); 526 struct zd_mac *mac = zd_netdev_mac(netdev);
@@ -295,7 +530,6 @@ static void set_channel(struct net_device *netdev, u8 channel)
295 zd_chip_set_channel(&mac->chip, channel); 530 zd_chip_set_channel(&mac->chip, channel);
296} 531}
297 532
298/* TODO: Should not work in Managed mode. */
299int zd_mac_request_channel(struct zd_mac *mac, u8 channel) 533int zd_mac_request_channel(struct zd_mac *mac, u8 channel)
300{ 534{
301 unsigned long lock_flags; 535 unsigned long lock_flags;
@@ -317,31 +551,22 @@ int zd_mac_request_channel(struct zd_mac *mac, u8 channel)
317 return 0; 551 return 0;
318} 552}
319 553
320int zd_mac_get_channel(struct zd_mac *mac, u8 *channel, u8 *flags) 554u8 zd_mac_get_channel(struct zd_mac *mac)
321{ 555{
322 struct ieee80211_device *ieee = zd_mac_to_ieee80211(mac); 556 u8 channel = zd_chip_get_channel(&mac->chip);
323 557
324 *channel = zd_chip_get_channel(&mac->chip); 558 dev_dbg_f(zd_mac_dev(mac), "channel %u\n", channel);
325 if (ieee->iw_mode != IW_MODE_INFRA) { 559 return channel;
326 spin_lock_irq(&mac->lock);
327 *flags = *channel == mac->requested_channel ?
328 MAC_FIXED_CHANNEL : 0;
329 spin_unlock(&mac->lock);
330 } else {
331 *flags = 0;
332 }
333 dev_dbg_f(zd_mac_dev(mac), "channel %u flags %u\n", *channel, *flags);
334 return 0;
335} 560}
336 561
337/* If wrong rate is given, we are falling back to the slowest rate: 1MBit/s */ 562/* If wrong rate is given, we are falling back to the slowest rate: 1MBit/s */
338static u8 cs_typed_rate(u8 cs_rate) 563static u8 zd_rate_typed(u8 zd_rate)
339{ 564{
340 static const u8 typed_rates[16] = { 565 static const u8 typed_rates[16] = {
341 [ZD_CS_CCK_RATE_1M] = ZD_CS_CCK|ZD_CS_CCK_RATE_1M, 566 [ZD_CCK_RATE_1M] = ZD_CS_CCK|ZD_CCK_RATE_1M,
342 [ZD_CS_CCK_RATE_2M] = ZD_CS_CCK|ZD_CS_CCK_RATE_2M, 567 [ZD_CCK_RATE_2M] = ZD_CS_CCK|ZD_CCK_RATE_2M,
343 [ZD_CS_CCK_RATE_5_5M] = ZD_CS_CCK|ZD_CS_CCK_RATE_5_5M, 568 [ZD_CCK_RATE_5_5M] = ZD_CS_CCK|ZD_CCK_RATE_5_5M,
344 [ZD_CS_CCK_RATE_11M] = ZD_CS_CCK|ZD_CS_CCK_RATE_11M, 569 [ZD_CCK_RATE_11M] = ZD_CS_CCK|ZD_CCK_RATE_11M,
345 [ZD_OFDM_RATE_6M] = ZD_CS_OFDM|ZD_OFDM_RATE_6M, 570 [ZD_OFDM_RATE_6M] = ZD_CS_OFDM|ZD_OFDM_RATE_6M,
346 [ZD_OFDM_RATE_9M] = ZD_CS_OFDM|ZD_OFDM_RATE_9M, 571 [ZD_OFDM_RATE_9M] = ZD_CS_OFDM|ZD_OFDM_RATE_9M,
347 [ZD_OFDM_RATE_12M] = ZD_CS_OFDM|ZD_OFDM_RATE_12M, 572 [ZD_OFDM_RATE_12M] = ZD_CS_OFDM|ZD_OFDM_RATE_12M,
@@ -353,37 +578,7 @@ static u8 cs_typed_rate(u8 cs_rate)
353 }; 578 };
354 579
355 ZD_ASSERT(ZD_CS_RATE_MASK == 0x0f); 580 ZD_ASSERT(ZD_CS_RATE_MASK == 0x0f);
356 return typed_rates[cs_rate & ZD_CS_RATE_MASK]; 581 return typed_rates[zd_rate & ZD_CS_RATE_MASK];
357}
358
359/* Fallback to lowest rate, if rate is unknown. */
360static u8 rate_to_cs_rate(u8 rate)
361{
362 switch (rate) {
363 case IEEE80211_CCK_RATE_2MB:
364 return ZD_CS_CCK_RATE_2M;
365 case IEEE80211_CCK_RATE_5MB:
366 return ZD_CS_CCK_RATE_5_5M;
367 case IEEE80211_CCK_RATE_11MB:
368 return ZD_CS_CCK_RATE_11M;
369 case IEEE80211_OFDM_RATE_6MB:
370 return ZD_OFDM_RATE_6M;
371 case IEEE80211_OFDM_RATE_9MB:
372 return ZD_OFDM_RATE_9M;
373 case IEEE80211_OFDM_RATE_12MB:
374 return ZD_OFDM_RATE_12M;
375 case IEEE80211_OFDM_RATE_18MB:
376 return ZD_OFDM_RATE_18M;
377 case IEEE80211_OFDM_RATE_24MB:
378 return ZD_OFDM_RATE_24M;
379 case IEEE80211_OFDM_RATE_36MB:
380 return ZD_OFDM_RATE_36M;
381 case IEEE80211_OFDM_RATE_48MB:
382 return ZD_OFDM_RATE_48M;
383 case IEEE80211_OFDM_RATE_54MB:
384 return ZD_OFDM_RATE_54M;
385 }
386 return ZD_CS_CCK_RATE_1M;
387} 582}
388 583
389int zd_mac_set_mode(struct zd_mac *mac, u32 mode) 584int zd_mac_set_mode(struct zd_mac *mac, u32 mode)
@@ -464,6 +659,9 @@ int zd_mac_get_range(struct zd_mac *mac, struct iw_range *range)
464 range->we_version_compiled = WIRELESS_EXT; 659 range->we_version_compiled = WIRELESS_EXT;
465 range->we_version_source = 20; 660 range->we_version_source = 20;
466 661
662 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
663 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
664
467 ZD_ASSERT(!irqs_disabled()); 665 ZD_ASSERT(!irqs_disabled());
468 spin_lock_irq(&mac->lock); 666 spin_lock_irq(&mac->lock);
469 regdomain = mac->regdomain; 667 regdomain = mac->regdomain;
@@ -484,13 +682,13 @@ int zd_mac_get_range(struct zd_mac *mac, struct iw_range *range)
484 return 0; 682 return 0;
485} 683}
486 684
487static int zd_calc_tx_length_us(u8 *service, u8 cs_rate, u16 tx_length) 685static int zd_calc_tx_length_us(u8 *service, u8 zd_rate, u16 tx_length)
488{ 686{
489 static const u8 rate_divisor[] = { 687 static const u8 rate_divisor[] = {
490 [ZD_CS_CCK_RATE_1M] = 1, 688 [ZD_CCK_RATE_1M] = 1,
491 [ZD_CS_CCK_RATE_2M] = 2, 689 [ZD_CCK_RATE_2M] = 2,
492 [ZD_CS_CCK_RATE_5_5M] = 11, /* bits must be doubled */ 690 [ZD_CCK_RATE_5_5M] = 11, /* bits must be doubled */
493 [ZD_CS_CCK_RATE_11M] = 11, 691 [ZD_CCK_RATE_11M] = 11,
494 [ZD_OFDM_RATE_6M] = 6, 692 [ZD_OFDM_RATE_6M] = 6,
495 [ZD_OFDM_RATE_9M] = 9, 693 [ZD_OFDM_RATE_9M] = 9,
496 [ZD_OFDM_RATE_12M] = 12, 694 [ZD_OFDM_RATE_12M] = 12,
@@ -504,15 +702,15 @@ static int zd_calc_tx_length_us(u8 *service, u8 cs_rate, u16 tx_length)
504 u32 bits = (u32)tx_length * 8; 702 u32 bits = (u32)tx_length * 8;
505 u32 divisor; 703 u32 divisor;
506 704
507 divisor = rate_divisor[cs_rate]; 705 divisor = rate_divisor[zd_rate];
508 if (divisor == 0) 706 if (divisor == 0)
509 return -EINVAL; 707 return -EINVAL;
510 708
511 switch (cs_rate) { 709 switch (zd_rate) {
512 case ZD_CS_CCK_RATE_5_5M: 710 case ZD_CCK_RATE_5_5M:
513 bits = (2*bits) + 10; /* round up to the next integer */ 711 bits = (2*bits) + 10; /* round up to the next integer */
514 break; 712 break;
515 case ZD_CS_CCK_RATE_11M: 713 case ZD_CCK_RATE_11M:
516 if (service) { 714 if (service) {
517 u32 t = bits % 11; 715 u32 t = bits % 11;
518 *service &= ~ZD_PLCP_SERVICE_LENGTH_EXTENSION; 716 *service &= ~ZD_PLCP_SERVICE_LENGTH_EXTENSION;
@@ -532,16 +730,16 @@ enum {
532 R2M_11A = 0x02, 730 R2M_11A = 0x02,
533}; 731};
534 732
535static u8 cs_rate_to_modulation(u8 cs_rate, int flags) 733static u8 zd_rate_to_modulation(u8 zd_rate, int flags)
536{ 734{
537 u8 modulation; 735 u8 modulation;
538 736
539 modulation = cs_typed_rate(cs_rate); 737 modulation = zd_rate_typed(zd_rate);
540 if (flags & R2M_SHORT_PREAMBLE) { 738 if (flags & R2M_SHORT_PREAMBLE) {
541 switch (ZD_CS_RATE(modulation)) { 739 switch (ZD_CS_RATE(modulation)) {
542 case ZD_CS_CCK_RATE_2M: 740 case ZD_CCK_RATE_2M:
543 case ZD_CS_CCK_RATE_5_5M: 741 case ZD_CCK_RATE_5_5M:
544 case ZD_CS_CCK_RATE_11M: 742 case ZD_CCK_RATE_11M:
545 modulation |= ZD_CS_CCK_PREA_SHORT; 743 modulation |= ZD_CS_CCK_PREA_SHORT;
546 return modulation; 744 return modulation;
547 } 745 }
@@ -558,39 +756,36 @@ static void cs_set_modulation(struct zd_mac *mac, struct zd_ctrlset *cs,
558{ 756{
559 struct ieee80211softmac_device *softmac = ieee80211_priv(mac->netdev); 757 struct ieee80211softmac_device *softmac = ieee80211_priv(mac->netdev);
560 u16 ftype = WLAN_FC_GET_TYPE(le16_to_cpu(hdr->frame_ctl)); 758 u16 ftype = WLAN_FC_GET_TYPE(le16_to_cpu(hdr->frame_ctl));
561 u8 rate, cs_rate; 759 u8 rate, zd_rate;
562 int is_mgt = (ftype == IEEE80211_FTYPE_MGMT) != 0; 760 int is_mgt = (ftype == IEEE80211_FTYPE_MGMT) != 0;
761 int is_multicast = is_multicast_ether_addr(hdr->addr1);
762 int short_preamble = ieee80211softmac_short_preamble_ok(softmac,
763 is_multicast, is_mgt);
764 int flags = 0;
563 765
564 /* FIXME: 802.11a? short preamble? */ 766 /* FIXME: 802.11a? */
565 rate = ieee80211softmac_suggest_txrate(softmac, 767 rate = ieee80211softmac_suggest_txrate(softmac, is_multicast, is_mgt);
566 is_multicast_ether_addr(hdr->addr1), is_mgt);
567 768
568 cs_rate = rate_to_cs_rate(rate); 769 if (short_preamble)
569 cs->modulation = cs_rate_to_modulation(cs_rate, 0); 770 flags |= R2M_SHORT_PREAMBLE;
771
772 zd_rate = rate_to_zd_rate(rate);
773 cs->modulation = zd_rate_to_modulation(zd_rate, flags);
570} 774}
571 775
572static void cs_set_control(struct zd_mac *mac, struct zd_ctrlset *cs, 776static void cs_set_control(struct zd_mac *mac, struct zd_ctrlset *cs,
573 struct ieee80211_hdr_4addr *header) 777 struct ieee80211_hdr_4addr *header)
574{ 778{
779 struct ieee80211softmac_device *softmac = ieee80211_priv(mac->netdev);
575 unsigned int tx_length = le16_to_cpu(cs->tx_length); 780 unsigned int tx_length = le16_to_cpu(cs->tx_length);
576 u16 fctl = le16_to_cpu(header->frame_ctl); 781 u16 fctl = le16_to_cpu(header->frame_ctl);
577 u16 ftype = WLAN_FC_GET_TYPE(fctl); 782 u16 ftype = WLAN_FC_GET_TYPE(fctl);
578 u16 stype = WLAN_FC_GET_STYPE(fctl); 783 u16 stype = WLAN_FC_GET_STYPE(fctl);
579 784
580 /* 785 /*
581 * CONTROL: 786 * CONTROL TODO:
582 * - start at 0x00
583 * - if fragment 0, enable bit 0
584 * - if backoff needed, enable bit 0 787 * - if backoff needed, enable bit 0
585 * - if burst (backoff not needed) disable bit 0 788 * - if burst (backoff not needed) disable bit 0
586 * - if multicast, enable bit 1
587 * - if PS-POLL frame, enable bit 2
588 * - if in INDEPENDENT_BSS mode and zd1205_DestPowerSave, then enable
589 * bit 4 (FIXME: wtf)
590 * - if frag_len > RTS threshold, set bit 5 as long if it isnt
591 * multicast or mgt
592 * - if bit 5 is set, and we are in OFDM mode, unset bit 5 and set bit
593 * 7
594 */ 789 */
595 790
596 cs->control = 0; 791 cs->control = 0;
@@ -607,17 +802,18 @@ static void cs_set_control(struct zd_mac *mac, struct zd_ctrlset *cs,
607 if (stype == IEEE80211_STYPE_PSPOLL) 802 if (stype == IEEE80211_STYPE_PSPOLL)
608 cs->control |= ZD_CS_PS_POLL_FRAME; 803 cs->control |= ZD_CS_PS_POLL_FRAME;
609 804
805 /* Unicast data frames over the threshold should have RTS */
610 if (!is_multicast_ether_addr(header->addr1) && 806 if (!is_multicast_ether_addr(header->addr1) &&
611 ftype != IEEE80211_FTYPE_MGMT && 807 ftype != IEEE80211_FTYPE_MGMT &&
612 tx_length > zd_netdev_ieee80211(mac->netdev)->rts) 808 tx_length > zd_netdev_ieee80211(mac->netdev)->rts)
613 { 809 cs->control |= ZD_CS_RTS;
614 /* FIXME: check the logic */ 810
615 if (ZD_CS_TYPE(cs->modulation) == ZD_CS_OFDM) { 811 /* Use CTS-to-self protection if required */
616 /* 802.11g */ 812 if (ZD_CS_TYPE(cs->modulation) == ZD_CS_OFDM &&
617 cs->control |= ZD_CS_SELF_CTS; 813 ieee80211softmac_protection_needed(softmac)) {
618 } else { /* 802.11b */ 814 /* FIXME: avoid sending RTS *and* self-CTS, is that correct? */
619 cs->control |= ZD_CS_RTS; 815 cs->control &= ~ZD_CS_RTS;
620 } 816 cs->control |= ZD_CS_SELF_CTS;
621 } 817 }
622 818
623 /* FIXME: Management frame? */ 819 /* FIXME: Management frame? */
@@ -721,7 +917,7 @@ struct zd_rt_hdr {
721 u8 rt_rate; 917 u8 rt_rate;
722 u16 rt_channel; 918 u16 rt_channel;
723 u16 rt_chbitmask; 919 u16 rt_chbitmask;
724}; 920} __attribute__((packed));
725 921
726static void fill_rt_header(void *buffer, struct zd_mac *mac, 922static void fill_rt_header(void *buffer, struct zd_mac *mac,
727 const struct ieee80211_rx_stats *stats, 923 const struct ieee80211_rx_stats *stats,
@@ -778,13 +974,16 @@ static int is_data_packet_for_us(struct ieee80211_device *ieee,
778 } 974 }
779 975
780 return memcmp(hdr->addr1, netdev->dev_addr, ETH_ALEN) == 0 || 976 return memcmp(hdr->addr1, netdev->dev_addr, ETH_ALEN) == 0 ||
781 is_multicast_ether_addr(hdr->addr1) || 977 (is_multicast_ether_addr(hdr->addr1) &&
978 memcmp(hdr->addr3, netdev->dev_addr, ETH_ALEN) != 0) ||
782 (netdev->flags & IFF_PROMISC); 979 (netdev->flags & IFF_PROMISC);
783} 980}
784 981
785/* Filters receiving packets. If it returns 1 send it to ieee80211_rx, if 0 982/* Filters received packets. The function returns 1 if the packet should be
786 * return. If an error is detected -EINVAL is returned. ieee80211_rx_mgt() is 983 * forwarded to ieee80211_rx(). If the packet should be ignored the function
787 * called here. 984 * returns 0. If an invalid packet is found the function returns -EINVAL.
985 *
986 * The function calls ieee80211_rx_mgt() directly.
788 * 987 *
789 * It has been based on ieee80211_rx_any. 988 * It has been based on ieee80211_rx_any.
790 */ 989 */
@@ -810,9 +1009,9 @@ static int filter_rx(struct ieee80211_device *ieee,
810 ieee80211_rx_mgt(ieee, hdr, stats); 1009 ieee80211_rx_mgt(ieee, hdr, stats);
811 return 0; 1010 return 0;
812 case IEEE80211_FTYPE_CTL: 1011 case IEEE80211_FTYPE_CTL:
813 /* Ignore invalid short buffers */
814 return 0; 1012 return 0;
815 case IEEE80211_FTYPE_DATA: 1013 case IEEE80211_FTYPE_DATA:
1014 /* Ignore invalid short buffers */
816 if (length < sizeof(struct ieee80211_hdr_3addr)) 1015 if (length < sizeof(struct ieee80211_hdr_3addr))
817 return -EINVAL; 1016 return -EINVAL;
818 return is_data_packet_for_us(ieee, hdr); 1017 return is_data_packet_for_us(ieee, hdr);
@@ -908,10 +1107,8 @@ int zd_mac_rx(struct zd_mac *mac, const u8 *buffer, unsigned int length)
908 memcpy(skb_put(skb, length), buffer, length); 1107 memcpy(skb_put(skb, length), buffer, length);
909 1108
910 r = ieee80211_rx(ieee, skb, &stats); 1109 r = ieee80211_rx(ieee, skb, &stats);
911 if (!r) { 1110 if (!r)
912 ZD_ASSERT(in_irq()); 1111 dev_kfree_skb_any(skb);
913 dev_kfree_skb_irq(skb);
914 }
915 return 0; 1112 return 0;
916} 1113}
917 1114
@@ -993,6 +1190,7 @@ static void ieee_init(struct ieee80211_device *ieee)
993static void softmac_init(struct ieee80211softmac_device *sm) 1190static void softmac_init(struct ieee80211softmac_device *sm)
994{ 1191{
995 sm->set_channel = set_channel; 1192 sm->set_channel = set_channel;
1193 sm->bssinfo_change = bssinfo_change;
996} 1194}
997 1195
998struct iw_statistics *zd_mac_get_wireless_stats(struct net_device *ndev) 1196struct iw_statistics *zd_mac_get_wireless_stats(struct net_device *ndev)
@@ -1028,71 +1226,12 @@ struct iw_statistics *zd_mac_get_wireless_stats(struct net_device *ndev)
1028 return iw_stats; 1226 return iw_stats;
1029} 1227}
1030 1228
1031#ifdef DEBUG
1032static const char* decryption_types[] = {
1033 [ZD_RX_NO_WEP] = "none",
1034 [ZD_RX_WEP64] = "WEP64",
1035 [ZD_RX_TKIP] = "TKIP",
1036 [ZD_RX_AES] = "AES",
1037 [ZD_RX_WEP128] = "WEP128",
1038 [ZD_RX_WEP256] = "WEP256",
1039};
1040
1041static const char *decryption_type_string(u8 type)
1042{
1043 const char *s;
1044
1045 if (type < ARRAY_SIZE(decryption_types)) {
1046 s = decryption_types[type];
1047 } else {
1048 s = NULL;
1049 }
1050 return s ? s : "unknown";
1051}
1052
1053static int is_ofdm(u8 frame_status)
1054{
1055 return (frame_status & ZD_RX_OFDM);
1056}
1057
1058void zd_dump_rx_status(const struct rx_status *status)
1059{
1060 const char* modulation;
1061 u8 quality;
1062
1063 if (is_ofdm(status->frame_status)) {
1064 modulation = "ofdm";
1065 quality = status->signal_quality_ofdm;
1066 } else {
1067 modulation = "cck";
1068 quality = status->signal_quality_cck;
1069 }
1070 pr_debug("rx status %s strength %#04x qual %#04x decryption %s\n",
1071 modulation, status->signal_strength, quality,
1072 decryption_type_string(status->decryption_type));
1073 if (status->frame_status & ZD_RX_ERROR) {
1074 pr_debug("rx error %s%s%s%s%s%s\n",
1075 (status->frame_status & ZD_RX_TIMEOUT_ERROR) ?
1076 "timeout " : "",
1077 (status->frame_status & ZD_RX_FIFO_OVERRUN_ERROR) ?
1078 "fifo " : "",
1079 (status->frame_status & ZD_RX_DECRYPTION_ERROR) ?
1080 "decryption " : "",
1081 (status->frame_status & ZD_RX_CRC32_ERROR) ?
1082 "crc32 " : "",
1083 (status->frame_status & ZD_RX_NO_ADDR1_MATCH_ERROR) ?
1084 "addr1 " : "",
1085 (status->frame_status & ZD_RX_CRC16_ERROR) ?
1086 "crc16" : "");
1087 }
1088}
1089#endif /* DEBUG */
1090
1091#define LINK_LED_WORK_DELAY HZ 1229#define LINK_LED_WORK_DELAY HZ
1092 1230
1093static void link_led_handler(void *p) 1231static void link_led_handler(struct work_struct *work)
1094{ 1232{
1095 struct zd_mac *mac = p; 1233 struct zd_mac *mac =
1234 container_of(work, struct zd_mac, housekeeping.link_led_work.work);
1096 struct zd_chip *chip = &mac->chip; 1235 struct zd_chip *chip = &mac->chip;
1097 struct ieee80211softmac_device *sm = ieee80211_priv(mac->netdev); 1236 struct ieee80211softmac_device *sm = ieee80211_priv(mac->netdev);
1098 int is_associated; 1237 int is_associated;
@@ -1113,7 +1252,7 @@ static void link_led_handler(void *p)
1113 1252
1114static void housekeeping_init(struct zd_mac *mac) 1253static void housekeeping_init(struct zd_mac *mac)
1115{ 1254{
1116 INIT_WORK(&mac->housekeeping.link_led_work, link_led_handler, mac); 1255 INIT_DELAYED_WORK(&mac->housekeeping.link_led_work, link_led_handler);
1117} 1256}
1118 1257
1119static void housekeeping_enable(struct zd_mac *mac) 1258static void housekeeping_enable(struct zd_mac *mac)
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.h b/drivers/net/wireless/zd1211rw/zd_mac.h
index b8ea3de7924a..f0cf05dc7d3e 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.h
+++ b/drivers/net/wireless/zd1211rw/zd_mac.h
@@ -20,6 +20,7 @@
20 20
21#include <linux/wireless.h> 21#include <linux/wireless.h>
22#include <linux/kernel.h> 22#include <linux/kernel.h>
23#include <linux/workqueue.h>
23#include <net/ieee80211.h> 24#include <net/ieee80211.h>
24#include <net/ieee80211softmac.h> 25#include <net/ieee80211softmac.h>
25 26
@@ -48,10 +49,11 @@ struct zd_ctrlset {
48#define ZD_CS_CCK 0x00 49#define ZD_CS_CCK 0x00
49#define ZD_CS_OFDM 0x10 50#define ZD_CS_OFDM 0x10
50 51
51#define ZD_CS_CCK_RATE_1M 0x00 52/* These are referred to as zd_rates */
52#define ZD_CS_CCK_RATE_2M 0x01 53#define ZD_CCK_RATE_1M 0x00
53#define ZD_CS_CCK_RATE_5_5M 0x02 54#define ZD_CCK_RATE_2M 0x01
54#define ZD_CS_CCK_RATE_11M 0x03 55#define ZD_CCK_RATE_5_5M 0x02
56#define ZD_CCK_RATE_11M 0x03
55/* The rates for OFDM are encoded as in the PLCP header. Use ZD_OFDM_RATE_*. 57/* The rates for OFDM are encoded as in the PLCP header. Use ZD_OFDM_RATE_*.
56 */ 58 */
57 59
@@ -82,7 +84,7 @@ struct zd_ctrlset {
82struct rx_length_info { 84struct rx_length_info {
83 __le16 length[3]; 85 __le16 length[3];
84 __le16 tag; 86 __le16 tag;
85}; 87} __attribute__((packed));
86 88
87#define RX_LENGTH_INFO_TAG 0x697e 89#define RX_LENGTH_INFO_TAG 0x697e
88 90
@@ -93,7 +95,7 @@ struct rx_status {
93 u8 signal_quality_ofdm; 95 u8 signal_quality_ofdm;
94 u8 decryption_type; 96 u8 decryption_type;
95 u8 frame_status; 97 u8 frame_status;
96}; 98} __attribute__((packed));
97 99
98/* rx_status field decryption_type */ 100/* rx_status field decryption_type */
99#define ZD_RX_NO_WEP 0 101#define ZD_RX_NO_WEP 0
@@ -116,12 +118,8 @@ struct rx_status {
116#define ZD_RX_CRC16_ERROR 0x40 118#define ZD_RX_CRC16_ERROR 0x40
117#define ZD_RX_ERROR 0x80 119#define ZD_RX_ERROR 0x80
118 120
119enum mac_flags {
120 MAC_FIXED_CHANNEL = 0x01,
121};
122
123struct housekeeping { 121struct housekeeping {
124 struct work_struct link_led_work; 122 struct delayed_work link_led_work;
125}; 123};
126 124
127#define ZD_MAC_STATS_BUFFER_SIZE 16 125#define ZD_MAC_STATS_BUFFER_SIZE 16
@@ -130,15 +128,35 @@ struct zd_mac {
130 struct zd_chip chip; 128 struct zd_chip chip;
131 spinlock_t lock; 129 spinlock_t lock;
132 struct net_device *netdev; 130 struct net_device *netdev;
131
133 /* Unlocked reading possible */ 132 /* Unlocked reading possible */
134 struct iw_statistics iw_stats; 133 struct iw_statistics iw_stats;
134
135 struct housekeeping housekeeping; 135 struct housekeeping housekeeping;
136 struct work_struct set_multicast_hash_work;
137 struct zd_mc_hash multicast_hash;
138 struct delayed_work set_rts_cts_work;
139 struct delayed_work set_basic_rates_work;
140
136 unsigned int stats_count; 141 unsigned int stats_count;
137 u8 qual_buffer[ZD_MAC_STATS_BUFFER_SIZE]; 142 u8 qual_buffer[ZD_MAC_STATS_BUFFER_SIZE];
138 u8 rssi_buffer[ZD_MAC_STATS_BUFFER_SIZE]; 143 u8 rssi_buffer[ZD_MAC_STATS_BUFFER_SIZE];
139 u8 regdomain; 144 u8 regdomain;
140 u8 default_regdomain; 145 u8 default_regdomain;
141 u8 requested_channel; 146 u8 requested_channel;
147
148 /* A bitpattern of cr_rates */
149 u16 basic_rates;
150
151 /* A zd_rate */
152 u8 rts_rate;
153
154 /* Short preamble (used for RTS/CTS) */
155 unsigned int short_preamble:1;
156
157 /* flags to indicate update in progress */
158 unsigned int updating_rts_rate:1;
159 unsigned int updating_basic_rates:1;
142}; 160};
143 161
144static inline struct ieee80211_device *zd_mac_to_ieee80211(struct zd_mac *mac) 162static inline struct ieee80211_device *zd_mac_to_ieee80211(struct zd_mac *mac)
@@ -173,6 +191,7 @@ int zd_mac_init_hw(struct zd_mac *mac, u8 device_type);
173int zd_mac_open(struct net_device *netdev); 191int zd_mac_open(struct net_device *netdev);
174int zd_mac_stop(struct net_device *netdev); 192int zd_mac_stop(struct net_device *netdev);
175int zd_mac_set_mac_address(struct net_device *dev, void *p); 193int zd_mac_set_mac_address(struct net_device *dev, void *p);
194void zd_mac_set_multicast_list(struct net_device *netdev);
176 195
177int zd_mac_rx(struct zd_mac *mac, const u8 *buffer, unsigned int length); 196int zd_mac_rx(struct zd_mac *mac, const u8 *buffer, unsigned int length);
178 197
@@ -180,7 +199,7 @@ int zd_mac_set_regdomain(struct zd_mac *zd_mac, u8 regdomain);
180u8 zd_mac_get_regdomain(struct zd_mac *zd_mac); 199u8 zd_mac_get_regdomain(struct zd_mac *zd_mac);
181 200
182int zd_mac_request_channel(struct zd_mac *mac, u8 channel); 201int zd_mac_request_channel(struct zd_mac *mac, u8 channel);
183int zd_mac_get_channel(struct zd_mac *mac, u8 *channel, u8 *flags); 202u8 zd_mac_get_channel(struct zd_mac *mac);
184 203
185int zd_mac_set_mode(struct zd_mac *mac, u32 mode); 204int zd_mac_set_mode(struct zd_mac *mac, u32 mode);
186int zd_mac_get_mode(struct zd_mac *mac, u32 *mode); 205int zd_mac_get_mode(struct zd_mac *mac, u32 *mode);
diff --git a/drivers/net/wireless/zd1211rw/zd_netdev.c b/drivers/net/wireless/zd1211rw/zd_netdev.c
index af3a7b36d078..8bda48de31ef 100644
--- a/drivers/net/wireless/zd1211rw/zd_netdev.c
+++ b/drivers/net/wireless/zd1211rw/zd_netdev.c
@@ -107,21 +107,10 @@ static int iw_get_freq(struct net_device *netdev,
107 struct iw_request_info *info, 107 struct iw_request_info *info,
108 union iwreq_data *req, char *extra) 108 union iwreq_data *req, char *extra)
109{ 109{
110 int r;
111 struct zd_mac *mac = zd_netdev_mac(netdev); 110 struct zd_mac *mac = zd_netdev_mac(netdev);
112 struct iw_freq *freq = &req->freq; 111 struct iw_freq *freq = &req->freq;
113 u8 channel;
114 u8 flags;
115
116 r = zd_mac_get_channel(mac, &channel, &flags);
117 if (r)
118 return r;
119 112
120 freq->flags = (flags & MAC_FIXED_CHANNEL) ? 113 return zd_channel_to_freq(freq, zd_mac_get_channel(mac));
121 IW_FREQ_FIXED : IW_FREQ_AUTO;
122 dev_dbg_f(zd_mac_dev(mac), "channel %s\n",
123 (flags & MAC_FIXED_CHANNEL) ? "fixed" : "auto");
124 return zd_channel_to_freq(freq, channel);
125} 114}
126 115
127static int iw_set_mode(struct net_device *netdev, 116static int iw_set_mode(struct net_device *netdev,
@@ -253,7 +242,7 @@ struct net_device *zd_netdev_alloc(struct usb_interface *intf)
253 netdev->open = zd_mac_open; 242 netdev->open = zd_mac_open;
254 netdev->stop = zd_mac_stop; 243 netdev->stop = zd_mac_stop;
255 /* netdev->get_stats = */ 244 /* netdev->get_stats = */
256 /* netdev->set_multicast_list = */ 245 netdev->set_multicast_list = zd_mac_set_multicast_list;
257 netdev->set_mac_address = zd_mac_set_mac_address; 246 netdev->set_mac_address = zd_mac_set_mac_address;
258 netdev->wireless_handlers = &iw_handler_def; 247 netdev->wireless_handlers = &iw_handler_def;
259 /* netdev->ethtool_ops = */ 248 /* netdev->ethtool_ops = */
diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
index 3faaeb2b7c89..aa782e88754b 100644
--- a/drivers/net/wireless/zd1211rw/zd_usb.c
+++ b/drivers/net/wireless/zd1211rw/zd_usb.c
@@ -47,11 +47,17 @@ static struct usb_device_id usb_ids[] = {
47 { USB_DEVICE(0x0586, 0x3402), .driver_info = DEVICE_ZD1211 }, 47 { USB_DEVICE(0x0586, 0x3402), .driver_info = DEVICE_ZD1211 },
48 { USB_DEVICE(0x0b3b, 0x5630), .driver_info = DEVICE_ZD1211 }, 48 { USB_DEVICE(0x0b3b, 0x5630), .driver_info = DEVICE_ZD1211 },
49 { USB_DEVICE(0x0b05, 0x170c), .driver_info = DEVICE_ZD1211 }, 49 { USB_DEVICE(0x0b05, 0x170c), .driver_info = DEVICE_ZD1211 },
50 { USB_DEVICE(0x1435, 0x0711), .driver_info = DEVICE_ZD1211 },
51 { USB_DEVICE(0x0586, 0x3409), .driver_info = DEVICE_ZD1211 },
52 { USB_DEVICE(0x0b3b, 0x1630), .driver_info = DEVICE_ZD1211 },
53 { USB_DEVICE(0x0586, 0x3401), .driver_info = DEVICE_ZD1211 },
54 { USB_DEVICE(0x14ea, 0xab13), .driver_info = DEVICE_ZD1211 },
50 /* ZD1211B */ 55 /* ZD1211B */
51 { USB_DEVICE(0x0ace, 0x1215), .driver_info = DEVICE_ZD1211B }, 56 { USB_DEVICE(0x0ace, 0x1215), .driver_info = DEVICE_ZD1211B },
52 { USB_DEVICE(0x157e, 0x300d), .driver_info = DEVICE_ZD1211B }, 57 { USB_DEVICE(0x157e, 0x300d), .driver_info = DEVICE_ZD1211B },
53 { USB_DEVICE(0x079b, 0x0062), .driver_info = DEVICE_ZD1211B }, 58 { USB_DEVICE(0x079b, 0x0062), .driver_info = DEVICE_ZD1211B },
54 { USB_DEVICE(0x1582, 0x6003), .driver_info = DEVICE_ZD1211B }, 59 { USB_DEVICE(0x1582, 0x6003), .driver_info = DEVICE_ZD1211B },
60 { USB_DEVICE(0x050d, 0x705c), .driver_info = DEVICE_ZD1211B },
55 /* "Driverless" devices that need ejecting */ 61 /* "Driverless" devices that need ejecting */
56 { USB_DEVICE(0x0ace, 0x2011), .driver_info = DEVICE_INSTALLER }, 62 { USB_DEVICE(0x0ace, 0x2011), .driver_info = DEVICE_INSTALLER },
57 {} 63 {}
@@ -366,15 +372,6 @@ error:
366 return r; 372 return r;
367} 373}
368 374
369static void disable_read_regs_int(struct zd_usb *usb)
370{
371 struct zd_usb_interrupt *intr = &usb->intr;
372
373 spin_lock(&intr->lock);
374 intr->read_regs_enabled = 0;
375 spin_unlock(&intr->lock);
376}
377
378#define urb_dev(urb) (&(urb)->dev->dev) 375#define urb_dev(urb) (&(urb)->dev->dev)
379 376
380static inline void handle_regs_int(struct urb *urb) 377static inline void handle_regs_int(struct urb *urb)
@@ -596,6 +593,8 @@ static void handle_rx_packet(struct zd_usb *usb, const u8 *buffer,
596 unsigned int l, k, n; 593 unsigned int l, k, n;
597 for (i = 0, l = 0;; i++) { 594 for (i = 0, l = 0;; i++) {
598 k = le16_to_cpu(get_unaligned(&length_info->length[i])); 595 k = le16_to_cpu(get_unaligned(&length_info->length[i]));
596 if (k == 0)
597 return;
599 n = l+k; 598 n = l+k;
600 if (n > length) 599 if (n > length)
601 return; 600 return;
@@ -1119,27 +1118,28 @@ static int __init usb_init(void)
1119{ 1118{
1120 int r; 1119 int r;
1121 1120
1122 pr_debug("usb_init()\n"); 1121 pr_debug("%s usb_init()\n", driver.name);
1123 1122
1124 zd_workqueue = create_singlethread_workqueue(driver.name); 1123 zd_workqueue = create_singlethread_workqueue(driver.name);
1125 if (zd_workqueue == NULL) { 1124 if (zd_workqueue == NULL) {
1126 printk(KERN_ERR "%s: couldn't create workqueue\n", driver.name); 1125 printk(KERN_ERR "%s couldn't create workqueue\n", driver.name);
1127 return -ENOMEM; 1126 return -ENOMEM;
1128 } 1127 }
1129 1128
1130 r = usb_register(&driver); 1129 r = usb_register(&driver);
1131 if (r) { 1130 if (r) {
1132 printk(KERN_ERR "usb_register() failed. Error number %d\n", r); 1131 printk(KERN_ERR "%s usb_register() failed. Error number %d\n",
1132 driver.name, r);
1133 return r; 1133 return r;
1134 } 1134 }
1135 1135
1136 pr_debug("zd1211rw initialized\n"); 1136 pr_debug("%s initialized\n", driver.name);
1137 return 0; 1137 return 0;
1138} 1138}
1139 1139
1140static void __exit usb_exit(void) 1140static void __exit usb_exit(void)
1141{ 1141{
1142 pr_debug("usb_exit()\n"); 1142 pr_debug("%s usb_exit()\n", driver.name);
1143 usb_deregister(&driver); 1143 usb_deregister(&driver);
1144 destroy_workqueue(zd_workqueue); 1144 destroy_workqueue(zd_workqueue);
1145} 1145}
@@ -1156,10 +1156,19 @@ static void prepare_read_regs_int(struct zd_usb *usb)
1156{ 1156{
1157 struct zd_usb_interrupt *intr = &usb->intr; 1157 struct zd_usb_interrupt *intr = &usb->intr;
1158 1158
1159 spin_lock(&intr->lock); 1159 spin_lock_irq(&intr->lock);
1160 intr->read_regs_enabled = 1; 1160 intr->read_regs_enabled = 1;
1161 INIT_COMPLETION(intr->read_regs.completion); 1161 INIT_COMPLETION(intr->read_regs.completion);
1162 spin_unlock(&intr->lock); 1162 spin_unlock_irq(&intr->lock);
1163}
1164
1165static void disable_read_regs_int(struct zd_usb *usb)
1166{
1167 struct zd_usb_interrupt *intr = &usb->intr;
1168
1169 spin_lock_irq(&intr->lock);
1170 intr->read_regs_enabled = 0;
1171 spin_unlock_irq(&intr->lock);
1163} 1172}
1164 1173
1165static int get_results(struct zd_usb *usb, u16 *values, 1174static int get_results(struct zd_usb *usb, u16 *values,
@@ -1171,7 +1180,7 @@ static int get_results(struct zd_usb *usb, u16 *values,
1171 struct read_regs_int *rr = &intr->read_regs; 1180 struct read_regs_int *rr = &intr->read_regs;
1172 struct usb_int_regs *regs = (struct usb_int_regs *)rr->buffer; 1181 struct usb_int_regs *regs = (struct usb_int_regs *)rr->buffer;
1173 1182
1174 spin_lock(&intr->lock); 1183 spin_lock_irq(&intr->lock);
1175 1184
1176 r = -EIO; 1185 r = -EIO;
1177 /* The created block size seems to be larger than expected. 1186 /* The created block size seems to be larger than expected.
@@ -1204,7 +1213,7 @@ static int get_results(struct zd_usb *usb, u16 *values,
1204 1213
1205 r = 0; 1214 r = 0;
1206error_unlock: 1215error_unlock:
1207 spin_unlock(&intr->lock); 1216 spin_unlock_irq(&intr->lock);
1208 return r; 1217 return r;
1209} 1218}
1210 1219
diff --git a/drivers/net/wireless/zd1211rw/zd_usb.h b/drivers/net/wireless/zd1211rw/zd_usb.h
index e81a2d3cfffd..317d37c36679 100644
--- a/drivers/net/wireless/zd1211rw/zd_usb.h
+++ b/drivers/net/wireless/zd1211rw/zd_usb.h
@@ -74,17 +74,17 @@ enum control_requests {
74struct usb_req_read_regs { 74struct usb_req_read_regs {
75 __le16 id; 75 __le16 id;
76 __le16 addr[0]; 76 __le16 addr[0];
77}; 77} __attribute__((packed));
78 78
79struct reg_data { 79struct reg_data {
80 __le16 addr; 80 __le16 addr;
81 __le16 value; 81 __le16 value;
82}; 82} __attribute__((packed));
83 83
84struct usb_req_write_regs { 84struct usb_req_write_regs {
85 __le16 id; 85 __le16 id;
86 struct reg_data reg_writes[0]; 86 struct reg_data reg_writes[0];
87}; 87} __attribute__((packed));
88 88
89enum { 89enum {
90 RF_IF_LE = 0x02, 90 RF_IF_LE = 0x02,
@@ -101,7 +101,7 @@ struct usb_req_rfwrite {
101 /* RF2595: 24 */ 101 /* RF2595: 24 */
102 __le16 bit_values[0]; 102 __le16 bit_values[0];
103 /* (CR203 & ~(RF_IF_LE | RF_CLK | RF_DATA)) | (bit ? RF_DATA : 0) */ 103 /* (CR203 & ~(RF_IF_LE | RF_CLK | RF_DATA)) | (bit ? RF_DATA : 0) */
104}; 104} __attribute__((packed));
105 105
106/* USB interrupt */ 106/* USB interrupt */
107 107
@@ -118,12 +118,12 @@ enum usb_int_flags {
118struct usb_int_header { 118struct usb_int_header {
119 u8 type; /* must always be 1 */ 119 u8 type; /* must always be 1 */
120 u8 id; 120 u8 id;
121}; 121} __attribute__((packed));
122 122
123struct usb_int_regs { 123struct usb_int_regs {
124 struct usb_int_header hdr; 124 struct usb_int_header hdr;
125 struct reg_data regs[0]; 125 struct reg_data regs[0];
126}; 126} __attribute__((packed));
127 127
128struct usb_int_retry_fail { 128struct usb_int_retry_fail {
129 struct usb_int_header hdr; 129 struct usb_int_header hdr;
@@ -131,7 +131,7 @@ struct usb_int_retry_fail {
131 u8 _dummy; 131 u8 _dummy;
132 u8 addr[ETH_ALEN]; 132 u8 addr[ETH_ALEN];
133 u8 ibss_wakeup_dest; 133 u8 ibss_wakeup_dest;
134}; 134} __attribute__((packed));
135 135
136struct read_regs_int { 136struct read_regs_int {
137 struct completion completion; 137 struct completion completion;
diff --git a/drivers/net/zorro8390.c b/drivers/net/zorro8390.c
index df04e050c647..d85e2ea0b6af 100644
--- a/drivers/net/zorro8390.c
+++ b/drivers/net/zorro8390.c
@@ -34,8 +34,16 @@
34#include <asm/amigaints.h> 34#include <asm/amigaints.h>
35#include <asm/amigahw.h> 35#include <asm/amigahw.h>
36 36
37#include "8390.h" 37#define EI_SHIFT(x) (ei_local->reg_offset[x])
38#define ei_inb(port) in_8(port)
39#define ei_outb(val,port) out_8(port,val)
40#define ei_inb_p(port) in_8(port)
41#define ei_outb_p(val,port) out_8(port,val)
38 42
43static const char version[] =
44 "8390.c:v1.10cvs 9/23/94 Donald Becker (becker@cesdis.gsfc.nasa.gov)\n";
45
46#include "lib8390.c"
39 47
40#define DRV_NAME "zorro8390" 48#define DRV_NAME "zorro8390"
41 49
@@ -114,7 +122,7 @@ static int __devinit zorro8390_init_one(struct zorro_dev *z,
114 break; 122 break;
115 board = z->resource.start; 123 board = z->resource.start;
116 ioaddr = board+cards[i].offset; 124 ioaddr = board+cards[i].offset;
117 dev = alloc_ei_netdev(); 125 dev = ____alloc_ei_netdev(0);
118 if (!dev) 126 if (!dev)
119 return -ENOMEM; 127 return -ENOMEM;
120 SET_MODULE_OWNER(dev); 128 SET_MODULE_OWNER(dev);
@@ -201,7 +209,7 @@ static int __devinit zorro8390_init(struct net_device *dev,
201 dev->irq = IRQ_AMIGA_PORTS; 209 dev->irq = IRQ_AMIGA_PORTS;
202 210
203 /* Install the Interrupt handler */ 211 /* Install the Interrupt handler */
204 i = request_irq(IRQ_AMIGA_PORTS, ei_interrupt, IRQF_SHARED, DRV_NAME, dev); 212 i = request_irq(IRQ_AMIGA_PORTS, __ei_interrupt, IRQF_SHARED, DRV_NAME, dev);
205 if (i) return i; 213 if (i) return i;
206 214
207 for(i = 0; i < ETHER_ADDR_LEN; i++) { 215 for(i = 0; i < ETHER_ADDR_LEN; i++) {
@@ -226,10 +234,10 @@ static int __devinit zorro8390_init(struct net_device *dev,
226 dev->open = &zorro8390_open; 234 dev->open = &zorro8390_open;
227 dev->stop = &zorro8390_close; 235 dev->stop = &zorro8390_close;
228#ifdef CONFIG_NET_POLL_CONTROLLER 236#ifdef CONFIG_NET_POLL_CONTROLLER
229 dev->poll_controller = ei_poll; 237 dev->poll_controller = __ei_poll;
230#endif 238#endif
231 239
232 NS8390_init(dev, 0); 240 __NS8390_init(dev, 0);
233 err = register_netdev(dev); 241 err = register_netdev(dev);
234 if (err) { 242 if (err) {
235 free_irq(IRQ_AMIGA_PORTS, dev); 243 free_irq(IRQ_AMIGA_PORTS, dev);
@@ -246,7 +254,7 @@ static int __devinit zorro8390_init(struct net_device *dev,
246 254
247static int zorro8390_open(struct net_device *dev) 255static int zorro8390_open(struct net_device *dev)
248{ 256{
249 ei_open(dev); 257 __ei_open(dev);
250 return 0; 258 return 0;
251} 259}
252 260
@@ -254,7 +262,7 @@ static int zorro8390_close(struct net_device *dev)
254{ 262{
255 if (ei_debug > 1) 263 if (ei_debug > 1)
256 printk(KERN_DEBUG "%s: Shutting down ethercard.\n", dev->name); 264 printk(KERN_DEBUG "%s: Shutting down ethercard.\n", dev->name);
257 ei_close(dev); 265 __ei_close(dev);
258 return 0; 266 return 0;
259} 267}
260 268
@@ -405,7 +413,7 @@ static void zorro8390_block_output(struct net_device *dev, int count,
405 printk(KERN_ERR "%s: timeout waiting for Tx RDC.\n", 413 printk(KERN_ERR "%s: timeout waiting for Tx RDC.\n",
406 dev->name); 414 dev->name);
407 zorro8390_reset_8390(dev); 415 zorro8390_reset_8390(dev);
408 NS8390_init(dev,1); 416 __NS8390_init(dev,1);
409 break; 417 break;
410 } 418 }
411 419
diff --git a/drivers/oprofile/cpu_buffer.c b/drivers/oprofile/cpu_buffer.c
index fc4bc9b94c74..a83c3db7d18f 100644
--- a/drivers/oprofile/cpu_buffer.c
+++ b/drivers/oprofile/cpu_buffer.c
@@ -29,7 +29,7 @@
29 29
30struct oprofile_cpu_buffer cpu_buffer[NR_CPUS] __cacheline_aligned; 30struct oprofile_cpu_buffer cpu_buffer[NR_CPUS] __cacheline_aligned;
31 31
32static void wq_sync_buffer(void *); 32static void wq_sync_buffer(struct work_struct *work);
33 33
34#define DEFAULT_TIMER_EXPIRE (HZ / 10) 34#define DEFAULT_TIMER_EXPIRE (HZ / 10)
35static int work_enabled; 35static int work_enabled;
@@ -65,7 +65,7 @@ int alloc_cpu_buffers(void)
65 b->sample_received = 0; 65 b->sample_received = 0;
66 b->sample_lost_overflow = 0; 66 b->sample_lost_overflow = 0;
67 b->cpu = i; 67 b->cpu = i;
68 INIT_WORK(&b->work, wq_sync_buffer, b); 68 INIT_DELAYED_WORK(&b->work, wq_sync_buffer);
69 } 69 }
70 return 0; 70 return 0;
71 71
@@ -282,9 +282,10 @@ void oprofile_add_trace(unsigned long pc)
282 * By using schedule_delayed_work_on and then schedule_delayed_work 282 * By using schedule_delayed_work_on and then schedule_delayed_work
283 * we guarantee this will stay on the correct cpu 283 * we guarantee this will stay on the correct cpu
284 */ 284 */
285static void wq_sync_buffer(void * data) 285static void wq_sync_buffer(struct work_struct *work)
286{ 286{
287 struct oprofile_cpu_buffer * b = data; 287 struct oprofile_cpu_buffer * b =
288 container_of(work, struct oprofile_cpu_buffer, work.work);
288 if (b->cpu != smp_processor_id()) { 289 if (b->cpu != smp_processor_id()) {
289 printk("WQ on CPU%d, prefer CPU%d\n", 290 printk("WQ on CPU%d, prefer CPU%d\n",
290 smp_processor_id(), b->cpu); 291 smp_processor_id(), b->cpu);
diff --git a/drivers/oprofile/cpu_buffer.h b/drivers/oprofile/cpu_buffer.h
index 09abb80e0570..49900d9e3235 100644
--- a/drivers/oprofile/cpu_buffer.h
+++ b/drivers/oprofile/cpu_buffer.h
@@ -43,7 +43,7 @@ struct oprofile_cpu_buffer {
43 unsigned long sample_lost_overflow; 43 unsigned long sample_lost_overflow;
44 unsigned long backtrace_aborted; 44 unsigned long backtrace_aborted;
45 int cpu; 45 int cpu;
46 struct work_struct work; 46 struct delayed_work work;
47} ____cacheline_aligned; 47} ____cacheline_aligned;
48 48
49extern struct oprofile_cpu_buffer cpu_buffer[]; 49extern struct oprofile_cpu_buffer cpu_buffer[];
diff --git a/drivers/parisc/ccio-dma.c b/drivers/parisc/ccio-dma.c
index 68cb3a080050..fe3f5f5365c5 100644
--- a/drivers/parisc/ccio-dma.c
+++ b/drivers/parisc/ccio-dma.c
@@ -486,7 +486,7 @@ typedef unsigned long space_t;
486** This bit tells U2 to do R/M/W for partial cachelines. "Streaming" 486** This bit tells U2 to do R/M/W for partial cachelines. "Streaming"
487** data can avoid this if the mapping covers full cache lines. 487** data can avoid this if the mapping covers full cache lines.
488** o STOP_MOST is needed for atomicity across cachelines. 488** o STOP_MOST is needed for atomicity across cachelines.
489** Apperently only "some EISA devices" need this. 489** Apparently only "some EISA devices" need this.
490** Using CONFIG_ISA is hack. Only the IOA with EISA under it needs 490** Using CONFIG_ISA is hack. Only the IOA with EISA under it needs
491** to use this hint iff the EISA devices needs this feature. 491** to use this hint iff the EISA devices needs this feature.
492** According to the U2 ERS, STOP_MOST enabled pages hurt performance. 492** According to the U2 ERS, STOP_MOST enabled pages hurt performance.
diff --git a/drivers/parisc/iosapic.c b/drivers/parisc/iosapic.c
index c2949b4367e5..12bab64a62a1 100644
--- a/drivers/parisc/iosapic.c
+++ b/drivers/parisc/iosapic.c
@@ -50,12 +50,12 @@
50** 50**
51** PA Firmware 51** PA Firmware
52** ----------- 52** -----------
53** PA-RISC platforms have two fundementally different types of firmware. 53** PA-RISC platforms have two fundamentally different types of firmware.
54** For PCI devices, "Legacy" PDC initializes the "INTERRUPT_LINE" register 54** For PCI devices, "Legacy" PDC initializes the "INTERRUPT_LINE" register
55** and BARs similar to a traditional PC BIOS. 55** and BARs similar to a traditional PC BIOS.
56** The newer "PAT" firmware supports PDC calls which return tables. 56** The newer "PAT" firmware supports PDC calls which return tables.
57** PAT firmware only initializes PCI Console and Boot interface. 57** PAT firmware only initializes the PCI Console and Boot interface.
58** With these tables, the OS can progam all other PCI devices. 58** With these tables, the OS can program all other PCI devices.
59** 59**
60** One such PAT PDC call returns the "Interrupt Routing Table" (IRT). 60** One such PAT PDC call returns the "Interrupt Routing Table" (IRT).
61** The IRT maps each PCI slot's INTA-D "output" line to an I/O SAPIC 61** The IRT maps each PCI slot's INTA-D "output" line to an I/O SAPIC
diff --git a/drivers/parport/parport_cs.c b/drivers/parport/parport_cs.c
index b953d5907c05..e60b4bf6bae8 100644
--- a/drivers/parport/parport_cs.c
+++ b/drivers/parport/parport_cs.c
@@ -166,14 +166,6 @@ static int parport_config(struct pcmcia_device *link)
166 166
167 tuple.TupleData = (cisdata_t *)buf; 167 tuple.TupleData = (cisdata_t *)buf;
168 tuple.TupleOffset = 0; tuple.TupleDataMax = 255; 168 tuple.TupleOffset = 0; tuple.TupleDataMax = 255;
169 tuple.Attributes = 0;
170 tuple.DesiredTuple = CISTPL_CONFIG;
171 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
172 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
173 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
174 link->conf.ConfigBase = parse.config.base;
175 link->conf.Present = parse.config.rmask[0];
176
177 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 169 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
178 tuple.Attributes = 0; 170 tuple.Attributes = 0;
179 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 171 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
@@ -263,6 +255,7 @@ void parport_cs_release(struct pcmcia_device *link)
263 255
264static struct pcmcia_device_id parport_ids[] = { 256static struct pcmcia_device_id parport_ids[] = {
265 PCMCIA_DEVICE_FUNC_ID(3), 257 PCMCIA_DEVICE_FUNC_ID(3),
258 PCMCIA_MFC_DEVICE_PROD_ID12(1,"Elan","Serial+Parallel Port: SP230",0x3beb8cf2,0xdb9e58bc),
266 PCMCIA_DEVICE_MANF_CARD(0x0137, 0x0003), 259 PCMCIA_DEVICE_MANF_CARD(0x0137, 0x0003),
267 PCMCIA_DEVICE_NULL 260 PCMCIA_DEVICE_NULL
268}; 261};
diff --git a/drivers/parport/parport_ip32.c b/drivers/parport/parport_ip32.c
index e3e19277030a..ec44efdbb84e 100644
--- a/drivers/parport/parport_ip32.c
+++ b/drivers/parport/parport_ip32.c
@@ -780,7 +780,7 @@ static irqreturn_t parport_ip32_interrupt(int irq, void *dev_id)
780 enum parport_ip32_irq_mode irq_mode = priv->irq_mode; 780 enum parport_ip32_irq_mode irq_mode = priv->irq_mode;
781 switch (irq_mode) { 781 switch (irq_mode) {
782 case PARPORT_IP32_IRQ_FWD: 782 case PARPORT_IP32_IRQ_FWD:
783 parport_generic_irq(irq, p, regs); 783 parport_generic_irq(irq, p);
784 break; 784 break;
785 case PARPORT_IP32_IRQ_HERE: 785 case PARPORT_IP32_IRQ_HERE:
786 parport_ip32_wakeup(p); 786 parport_ip32_wakeup(p);
diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c
index 39c96641bc72..b61c17b3e298 100644
--- a/drivers/parport/parport_pc.c
+++ b/drivers/parport/parport_pc.c
@@ -1975,7 +1975,7 @@ static int __devinit parport_ECPPS2_supported(struct parport *pb){return 0;}
1975/* --- IRQ detection -------------------------------------- */ 1975/* --- IRQ detection -------------------------------------- */
1976 1976
1977/* Only if supports ECP mode */ 1977/* Only if supports ECP mode */
1978static int __devinit programmable_irq_support(struct parport *pb) 1978static int programmable_irq_support(struct parport *pb)
1979{ 1979{
1980 int irq, intrLine; 1980 int irq, intrLine;
1981 unsigned char oecr = inb (ECONTROL (pb)); 1981 unsigned char oecr = inb (ECONTROL (pb));
@@ -1992,7 +1992,7 @@ static int __devinit programmable_irq_support(struct parport *pb)
1992 return irq; 1992 return irq;
1993} 1993}
1994 1994
1995static int __devinit irq_probe_ECP(struct parport *pb) 1995static int irq_probe_ECP(struct parport *pb)
1996{ 1996{
1997 int i; 1997 int i;
1998 unsigned long irqs; 1998 unsigned long irqs;
@@ -2020,7 +2020,7 @@ static int __devinit irq_probe_ECP(struct parport *pb)
2020 * This detection seems that only works in National Semiconductors 2020 * This detection seems that only works in National Semiconductors
2021 * This doesn't work in SMC, LGS, and Winbond 2021 * This doesn't work in SMC, LGS, and Winbond
2022 */ 2022 */
2023static int __devinit irq_probe_EPP(struct parport *pb) 2023static int irq_probe_EPP(struct parport *pb)
2024{ 2024{
2025#ifndef ADVANCED_DETECT 2025#ifndef ADVANCED_DETECT
2026 return PARPORT_IRQ_NONE; 2026 return PARPORT_IRQ_NONE;
@@ -2059,7 +2059,7 @@ static int __devinit irq_probe_EPP(struct parport *pb)
2059#endif /* Advanced detection */ 2059#endif /* Advanced detection */
2060} 2060}
2061 2061
2062static int __devinit irq_probe_SPP(struct parport *pb) 2062static int irq_probe_SPP(struct parport *pb)
2063{ 2063{
2064 /* Don't even try to do this. */ 2064 /* Don't even try to do this. */
2065 return PARPORT_IRQ_NONE; 2065 return PARPORT_IRQ_NONE;
@@ -2747,6 +2747,7 @@ enum parport_pc_pci_cards {
2747 titan_1284p2, 2747 titan_1284p2,
2748 avlab_1p, 2748 avlab_1p,
2749 avlab_2p, 2749 avlab_2p,
2750 oxsemi_952,
2750 oxsemi_954, 2751 oxsemi_954,
2751 oxsemi_840, 2752 oxsemi_840,
2752 aks_0100, 2753 aks_0100,
@@ -2822,6 +2823,7 @@ static struct parport_pc_pci {
2822 /* avlab_2p */ { 2, { { 0, 1}, { 2, 3 },} }, 2823 /* avlab_2p */ { 2, { { 0, 1}, { 2, 3 },} },
2823 /* The Oxford Semi cards are unusual: 954 doesn't support ECP, 2824 /* The Oxford Semi cards are unusual: 954 doesn't support ECP,
2824 * and 840 locks up if you write 1 to bit 2! */ 2825 * and 840 locks up if you write 1 to bit 2! */
2826 /* oxsemi_952 */ { 1, { { 0, 1 }, } },
2825 /* oxsemi_954 */ { 1, { { 0, -1 }, } }, 2827 /* oxsemi_954 */ { 1, { { 0, -1 }, } },
2826 /* oxsemi_840 */ { 1, { { 0, -1 }, } }, 2828 /* oxsemi_840 */ { 1, { { 0, -1 }, } },
2827 /* aks_0100 */ { 1, { { 0, -1 }, } }, 2829 /* aks_0100 */ { 1, { { 0, -1 }, } },
@@ -2895,6 +2897,8 @@ static const struct pci_device_id parport_pc_pci_tbl[] = {
2895 /* PCI_VENDOR_ID_AVLAB/Intek21 has another bunch of cards ...*/ 2897 /* PCI_VENDOR_ID_AVLAB/Intek21 has another bunch of cards ...*/
2896 { 0x14db, 0x2120, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1p}, /* AFAVLAB_TK9902 */ 2898 { 0x14db, 0x2120, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1p}, /* AFAVLAB_TK9902 */
2897 { 0x14db, 0x2121, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_2p}, 2899 { 0x14db, 0x2121, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_2p},
2900 { PCI_VENDOR_ID_OXSEMI, PCI_DEVICE_ID_OXSEMI_16PCI952PP,
2901 PCI_ANY_ID, PCI_ANY_ID, 0, 0, oxsemi_952 },
2898 { PCI_VENDOR_ID_OXSEMI, PCI_DEVICE_ID_OXSEMI_16PCI954PP, 2902 { PCI_VENDOR_ID_OXSEMI, PCI_DEVICE_ID_OXSEMI_16PCI954PP,
2899 PCI_ANY_ID, PCI_ANY_ID, 0, 0, oxsemi_954 }, 2903 PCI_ANY_ID, PCI_ANY_ID, 0, 0, oxsemi_954 },
2900 { PCI_VENDOR_ID_OXSEMI, PCI_DEVICE_ID_OXSEMI_12PCI840, 2904 { PCI_VENDOR_ID_OXSEMI, PCI_DEVICE_ID_OXSEMI_12PCI840,
diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig
index 5f1b9f58070e..f1dd81a1d592 100644
--- a/drivers/pci/Kconfig
+++ b/drivers/pci/Kconfig
@@ -19,7 +19,7 @@ config PCI_MSI
19 19
20config PCI_MULTITHREAD_PROBE 20config PCI_MULTITHREAD_PROBE
21 bool "PCI Multi-threaded probe (EXPERIMENTAL)" 21 bool "PCI Multi-threaded probe (EXPERIMENTAL)"
22 depends on PCI && EXPERIMENTAL && BROKEN 22 depends on PCI && EXPERIMENTAL
23 help 23 help
24 Say Y here if you want the PCI core to spawn a new thread for 24 Say Y here if you want the PCI core to spawn a new thread for
25 every PCI device that is probed. This can cause a huge 25 every PCI device that is probed. This can cause a huge
@@ -27,14 +27,14 @@ config PCI_MULTITHREAD_PROBE
27 smaller speedup on single processor machines. 27 smaller speedup on single processor machines.
28 28
29 But it can also cause lots of bad things to happen. A number 29 But it can also cause lots of bad things to happen. A number
30 of PCI drivers can not properly handle running in this way, 30 of PCI drivers cannot properly handle running in this way,
31 some will just not work properly at all, while others might 31 some will just not work properly at all, while others might
32 decide to blow up power supplies with a huge load all at once, 32 decide to blow up power supplies with a huge load all at once,
33 so use this option at your own risk. 33 so use this option at your own risk.
34 34
35 It is very unwise to use this option if you are not using a 35 It is very unwise to use this option if you are not using a
36 boot process that can handle devices being created in any 36 boot process that can handle devices being created in any
37 order. A program that can create persistant block and network 37 order. A program that can create persistent block and network
38 device names (like udev) is a good idea if you wish to use 38 device names (like udev) is a good idea if you wish to use
39 this option. 39 this option.
40 40
diff --git a/drivers/pci/access.c b/drivers/pci/access.c
index ea16805a153c..fc405f0165d9 100644
--- a/drivers/pci/access.c
+++ b/drivers/pci/access.c
@@ -1,6 +1,8 @@
1#include <linux/pci.h> 1#include <linux/pci.h>
2#include <linux/module.h> 2#include <linux/module.h>
3#include <linux/sched.h>
3#include <linux/ioport.h> 4#include <linux/ioport.h>
5#include <linux/wait.h>
4 6
5#include "pci.h" 7#include "pci.h"
6 8
@@ -63,30 +65,42 @@ EXPORT_SYMBOL(pci_bus_write_config_byte);
63EXPORT_SYMBOL(pci_bus_write_config_word); 65EXPORT_SYMBOL(pci_bus_write_config_word);
64EXPORT_SYMBOL(pci_bus_write_config_dword); 66EXPORT_SYMBOL(pci_bus_write_config_dword);
65 67
66static u32 pci_user_cached_config(struct pci_dev *dev, int pos) 68/*
67{ 69 * The following routines are to prevent the user from accessing PCI config
68 u32 data; 70 * space when it's unsafe to do so. Some devices require this during BIST and
71 * we're required to prevent it during D-state transitions.
72 *
73 * We have a bit per device to indicate it's blocked and a global wait queue
74 * for callers to sleep on until devices are unblocked.
75 */
76static DECLARE_WAIT_QUEUE_HEAD(pci_ucfg_wait);
69 77
70 data = dev->saved_config_space[pos/sizeof(dev->saved_config_space[0])]; 78static noinline void pci_wait_ucfg(struct pci_dev *dev)
71 data >>= (pos % sizeof(dev->saved_config_space[0])) * 8; 79{
72 return data; 80 DECLARE_WAITQUEUE(wait, current);
81
82 __add_wait_queue(&pci_ucfg_wait, &wait);
83 do {
84 set_current_state(TASK_UNINTERRUPTIBLE);
85 spin_unlock_irq(&pci_lock);
86 schedule();
87 spin_lock_irq(&pci_lock);
88 } while (dev->block_ucfg_access);
89 __remove_wait_queue(&pci_ucfg_wait, &wait);
73} 90}
74 91
75#define PCI_USER_READ_CONFIG(size,type) \ 92#define PCI_USER_READ_CONFIG(size,type) \
76int pci_user_read_config_##size \ 93int pci_user_read_config_##size \
77 (struct pci_dev *dev, int pos, type *val) \ 94 (struct pci_dev *dev, int pos, type *val) \
78{ \ 95{ \
79 unsigned long flags; \
80 int ret = 0; \ 96 int ret = 0; \
81 u32 data = -1; \ 97 u32 data = -1; \
82 if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER; \ 98 if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER; \
83 spin_lock_irqsave(&pci_lock, flags); \ 99 spin_lock_irq(&pci_lock); \
84 if (likely(!dev->block_ucfg_access)) \ 100 if (unlikely(dev->block_ucfg_access)) pci_wait_ucfg(dev); \
85 ret = dev->bus->ops->read(dev->bus, dev->devfn, \ 101 ret = dev->bus->ops->read(dev->bus, dev->devfn, \
86 pos, sizeof(type), &data); \ 102 pos, sizeof(type), &data); \
87 else if (pos < sizeof(dev->saved_config_space)) \ 103 spin_unlock_irq(&pci_lock); \
88 data = pci_user_cached_config(dev, pos); \
89 spin_unlock_irqrestore(&pci_lock, flags); \
90 *val = (type)data; \ 104 *val = (type)data; \
91 return ret; \ 105 return ret; \
92} 106}
@@ -95,14 +109,13 @@ int pci_user_read_config_##size \
95int pci_user_write_config_##size \ 109int pci_user_write_config_##size \
96 (struct pci_dev *dev, int pos, type val) \ 110 (struct pci_dev *dev, int pos, type val) \
97{ \ 111{ \
98 unsigned long flags; \
99 int ret = -EIO; \ 112 int ret = -EIO; \
100 if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER; \ 113 if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER; \
101 spin_lock_irqsave(&pci_lock, flags); \ 114 spin_lock_irq(&pci_lock); \
102 if (likely(!dev->block_ucfg_access)) \ 115 if (unlikely(dev->block_ucfg_access)) pci_wait_ucfg(dev); \
103 ret = dev->bus->ops->write(dev->bus, dev->devfn, \ 116 ret = dev->bus->ops->write(dev->bus, dev->devfn, \
104 pos, sizeof(type), val); \ 117 pos, sizeof(type), val); \
105 spin_unlock_irqrestore(&pci_lock, flags); \ 118 spin_unlock_irq(&pci_lock); \
106 return ret; \ 119 return ret; \
107} 120}
108 121
@@ -117,21 +130,23 @@ PCI_USER_WRITE_CONFIG(dword, u32)
117 * pci_block_user_cfg_access - Block userspace PCI config reads/writes 130 * pci_block_user_cfg_access - Block userspace PCI config reads/writes
118 * @dev: pci device struct 131 * @dev: pci device struct
119 * 132 *
120 * This function blocks any userspace PCI config accesses from occurring. 133 * When user access is blocked, any reads or writes to config space will
121 * When blocked, any writes will be bit bucketed and reads will return the 134 * sleep until access is unblocked again. We don't allow nesting of
122 * data saved using pci_save_state for the first 64 bytes of config 135 * block/unblock calls.
123 * space and return 0xff for all other config reads. 136 */
124 **/
125void pci_block_user_cfg_access(struct pci_dev *dev) 137void pci_block_user_cfg_access(struct pci_dev *dev)
126{ 138{
127 unsigned long flags; 139 unsigned long flags;
140 int was_blocked;
128 141
129 pci_save_state(dev);
130
131 /* spinlock to synchronize with anyone reading config space now */
132 spin_lock_irqsave(&pci_lock, flags); 142 spin_lock_irqsave(&pci_lock, flags);
143 was_blocked = dev->block_ucfg_access;
133 dev->block_ucfg_access = 1; 144 dev->block_ucfg_access = 1;
134 spin_unlock_irqrestore(&pci_lock, flags); 145 spin_unlock_irqrestore(&pci_lock, flags);
146
147 /* If we BUG() inside the pci_lock, we're guaranteed to hose
148 * the machine */
149 BUG_ON(was_blocked);
135} 150}
136EXPORT_SYMBOL_GPL(pci_block_user_cfg_access); 151EXPORT_SYMBOL_GPL(pci_block_user_cfg_access);
137 152
@@ -140,14 +155,19 @@ EXPORT_SYMBOL_GPL(pci_block_user_cfg_access);
140 * @dev: pci device struct 155 * @dev: pci device struct
141 * 156 *
142 * This function allows userspace PCI config accesses to resume. 157 * This function allows userspace PCI config accesses to resume.
143 **/ 158 */
144void pci_unblock_user_cfg_access(struct pci_dev *dev) 159void pci_unblock_user_cfg_access(struct pci_dev *dev)
145{ 160{
146 unsigned long flags; 161 unsigned long flags;
147 162
148 /* spinlock to synchronize with anyone reading saved config space */
149 spin_lock_irqsave(&pci_lock, flags); 163 spin_lock_irqsave(&pci_lock, flags);
164
165 /* This indicates a problem in the caller, but we don't need
166 * to kill them, unlike a double-block above. */
167 WARN_ON(!dev->block_ucfg_access);
168
150 dev->block_ucfg_access = 0; 169 dev->block_ucfg_access = 0;
170 wake_up_all(&pci_ucfg_wait);
151 spin_unlock_irqrestore(&pci_lock, flags); 171 spin_unlock_irqrestore(&pci_lock, flags);
152} 172}
153EXPORT_SYMBOL_GPL(pci_unblock_user_cfg_access); 173EXPORT_SYMBOL_GPL(pci_unblock_user_cfg_access);
diff --git a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h
index 59c5b242d86d..ddbadd95387e 100644
--- a/drivers/pci/hotplug/acpiphp.h
+++ b/drivers/pci/hotplug/acpiphp.h
@@ -62,10 +62,10 @@ struct acpiphp_slot;
62struct slot { 62struct slot {
63 struct hotplug_slot *hotplug_slot; 63 struct hotplug_slot *hotplug_slot;
64 struct acpiphp_slot *acpi_slot; 64 struct acpiphp_slot *acpi_slot;
65 struct hotplug_slot_info info;
66 char name[SLOT_NAME_SIZE];
65}; 67};
66 68
67
68
69/** 69/**
70 * struct acpiphp_bridge - PCI bridge information 70 * struct acpiphp_bridge - PCI bridge information
71 * 71 *
diff --git a/drivers/pci/hotplug/acpiphp_core.c b/drivers/pci/hotplug/acpiphp_core.c
index c57d9d5ce84e..40c79b03c7ef 100644
--- a/drivers/pci/hotplug/acpiphp_core.c
+++ b/drivers/pci/hotplug/acpiphp_core.c
@@ -303,25 +303,15 @@ static int __init init_acpi(void)
303 /* read initial number of slots */ 303 /* read initial number of slots */
304 if (!retval) { 304 if (!retval) {
305 num_slots = acpiphp_get_num_slots(); 305 num_slots = acpiphp_get_num_slots();
306 if (num_slots == 0) 306 if (num_slots == 0) {
307 acpiphp_glue_exit();
307 retval = -ENODEV; 308 retval = -ENODEV;
309 }
308 } 310 }
309 311
310 return retval; 312 return retval;
311} 313}
312 314
313
314/**
315 * make_slot_name - make a slot name that appears in pcihpfs
316 * @slot: slot to name
317 *
318 */
319static void make_slot_name(struct slot *slot)
320{
321 snprintf(slot->hotplug_slot->name, SLOT_NAME_SIZE, "%u",
322 slot->acpi_slot->sun);
323}
324
325/** 315/**
326 * release_slot - free up the memory used by a slot 316 * release_slot - free up the memory used by a slot
327 * @hotplug_slot: slot to free 317 * @hotplug_slot: slot to free
@@ -332,8 +322,6 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
332 322
333 dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); 323 dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
334 324
335 kfree(slot->hotplug_slot->info);
336 kfree(slot->hotplug_slot->name);
337 kfree(slot->hotplug_slot); 325 kfree(slot->hotplug_slot);
338 kfree(slot); 326 kfree(slot);
339} 327}
@@ -342,26 +330,19 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
342int acpiphp_register_hotplug_slot(struct acpiphp_slot *acpiphp_slot) 330int acpiphp_register_hotplug_slot(struct acpiphp_slot *acpiphp_slot)
343{ 331{
344 struct slot *slot; 332 struct slot *slot;
345 struct hotplug_slot *hotplug_slot;
346 struct hotplug_slot_info *hotplug_slot_info;
347 int retval = -ENOMEM; 333 int retval = -ENOMEM;
348 334
349 slot = kzalloc(sizeof(*slot), GFP_KERNEL); 335 slot = kzalloc(sizeof(*slot), GFP_KERNEL);
350 if (!slot) 336 if (!slot)
351 goto error; 337 goto error;
352 338
353 slot->hotplug_slot = kzalloc(sizeof(*hotplug_slot), GFP_KERNEL); 339 slot->hotplug_slot = kzalloc(sizeof(*slot->hotplug_slot), GFP_KERNEL);
354 if (!slot->hotplug_slot) 340 if (!slot->hotplug_slot)
355 goto error_slot; 341 goto error_slot;
356 342
357 slot->hotplug_slot->info = kzalloc(sizeof(*hotplug_slot_info), 343 slot->hotplug_slot->info = &slot->info;
358 GFP_KERNEL);
359 if (!slot->hotplug_slot->info)
360 goto error_hpslot;
361 344
362 slot->hotplug_slot->name = kzalloc(SLOT_NAME_SIZE, GFP_KERNEL); 345 slot->hotplug_slot->name = slot->name;
363 if (!slot->hotplug_slot->name)
364 goto error_info;
365 346
366 slot->hotplug_slot->private = slot; 347 slot->hotplug_slot->private = slot;
367 slot->hotplug_slot->release = &release_slot; 348 slot->hotplug_slot->release = &release_slot;
@@ -376,21 +357,17 @@ int acpiphp_register_hotplug_slot(struct acpiphp_slot *acpiphp_slot)
376 slot->hotplug_slot->info->cur_bus_speed = PCI_SPEED_UNKNOWN; 357 slot->hotplug_slot->info->cur_bus_speed = PCI_SPEED_UNKNOWN;
377 358
378 acpiphp_slot->slot = slot; 359 acpiphp_slot->slot = slot;
379 make_slot_name(slot); 360 snprintf(slot->name, sizeof(slot->name), "%u", slot->acpi_slot->sun);
380 361
381 retval = pci_hp_register(slot->hotplug_slot); 362 retval = pci_hp_register(slot->hotplug_slot);
382 if (retval) { 363 if (retval) {
383 err("pci_hp_register failed with error %d\n", retval); 364 err("pci_hp_register failed with error %d\n", retval);
384 goto error_name; 365 goto error_hpslot;
385 } 366 }
386 367
387 info("Slot [%s] registered\n", slot->hotplug_slot->name); 368 info("Slot [%s] registered\n", slot->hotplug_slot->name);
388 369
389 return 0; 370 return 0;
390error_name:
391 kfree(slot->hotplug_slot->name);
392error_info:
393 kfree(slot->hotplug_slot->info);
394error_hpslot: 371error_hpslot:
395 kfree(slot->hotplug_slot); 372 kfree(slot->hotplug_slot);
396error_slot: 373error_slot:
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index 16167b016266..0b9d0db1590a 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -1693,14 +1693,10 @@ void __exit acpiphp_glue_exit(void)
1693 */ 1693 */
1694int __init acpiphp_get_num_slots(void) 1694int __init acpiphp_get_num_slots(void)
1695{ 1695{
1696 struct list_head *node;
1697 struct acpiphp_bridge *bridge; 1696 struct acpiphp_bridge *bridge;
1698 int num_slots; 1697 int num_slots = 0;
1699
1700 num_slots = 0;
1701 1698
1702 list_for_each (node, &bridge_list) { 1699 list_for_each_entry (bridge, &bridge_list, list) {
1703 bridge = (struct acpiphp_bridge *)node;
1704 dbg("Bus %04x:%02x has %d slot%s\n", 1700 dbg("Bus %04x:%02x has %d slot%s\n",
1705 pci_domain_nr(bridge->pci_bus), 1701 pci_domain_nr(bridge->pci_bus),
1706 bridge->pci_bus->number, bridge->nr_slots, 1702 bridge->pci_bus->number, bridge->nr_slots,
diff --git a/drivers/pci/hotplug/ibmphp_hpc.c b/drivers/pci/hotplug/ibmphp_hpc.c
index c3ac98a0a6a6..f55ac3885cb3 100644
--- a/drivers/pci/hotplug/ibmphp_hpc.c
+++ b/drivers/pci/hotplug/ibmphp_hpc.c
@@ -531,7 +531,7 @@ static u8 hpc_readcmdtoindex (u8 cmd, u8 index)
531* 531*
532* Action: issue a READ command to HPC 532* Action: issue a READ command to HPC
533* 533*
534* Input: pslot - can not be NULL for READ_ALLSTAT 534* Input: pslot - cannot be NULL for READ_ALLSTAT
535* pstatus - can be NULL for READ_ALLSTAT 535* pstatus - can be NULL for READ_ALLSTAT
536* 536*
537* Return 0 or error codes 537* Return 0 or error codes
diff --git a/drivers/pci/hotplug/ibmphp_pci.c b/drivers/pci/hotplug/ibmphp_pci.c
index d87a9e3eaeeb..d8f05d7a3c72 100644
--- a/drivers/pci/hotplug/ibmphp_pci.c
+++ b/drivers/pci/hotplug/ibmphp_pci.c
@@ -1371,12 +1371,12 @@ static int unconfigure_boot_bridge (u8 busno, u8 device, u8 function)
1371 } 1371 }
1372 1372
1373 bus = ibmphp_find_res_bus (sec_number); 1373 bus = ibmphp_find_res_bus (sec_number);
1374 debug ("bus->busno is %x\n", bus->busno);
1375 debug ("sec_number is %x\n", sec_number);
1376 if (!bus) { 1374 if (!bus) {
1377 err ("cannot find Bus structure for the bridged device\n"); 1375 err ("cannot find Bus structure for the bridged device\n");
1378 return -EINVAL; 1376 return -EINVAL;
1379 } 1377 }
1378 debug("bus->busno is %x\n", bus->busno);
1379 debug("sec_number is %x\n", sec_number);
1380 1380
1381 ibmphp_remove_bus (bus, busno); 1381 ibmphp_remove_bus (bus, busno);
1382 1382
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
index f93e81e2d2c7..f13f31323e85 100644
--- a/drivers/pci/hotplug/pciehp_core.c
+++ b/drivers/pci/hotplug/pciehp_core.c
@@ -521,14 +521,9 @@ static void __exit unload_pciehpd(void)
521 521
522} 522}
523 523
524static int hpdriver_context = 0;
525
526static void pciehp_remove (struct pcie_device *device) 524static void pciehp_remove (struct pcie_device *device)
527{ 525{
528 printk("%s ENTRY\n", __FUNCTION__); 526 /* XXX - Needs to be adapted to device driver model */
529 printk("%s -> Call free_irq for irq = %d\n",
530 __FUNCTION__, device->irq);
531 free_irq(device->irq, &hpdriver_context);
532} 527}
533 528
534#ifdef CONFIG_PM 529#ifdef CONFIG_PM
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
index 1c551c697c35..6d3f580f2666 100644
--- a/drivers/pci/hotplug/pciehp_hpc.c
+++ b/drivers/pci/hotplug/pciehp_hpc.c
@@ -718,8 +718,6 @@ static void hpc_release_ctlr(struct controller *ctrl)
718 if (php_ctlr->irq) { 718 if (php_ctlr->irq) {
719 free_irq(php_ctlr->irq, ctrl); 719 free_irq(php_ctlr->irq, ctrl);
720 php_ctlr->irq = 0; 720 php_ctlr->irq = 0;
721 if (!pcie_mch_quirk)
722 pci_disable_msi(php_ctlr->pci_dev);
723 } 721 }
724 } 722 }
725 if (php_ctlr->pci_dev) 723 if (php_ctlr->pci_dev)
diff --git a/drivers/pci/hotplug/rpadlpar_core.c b/drivers/pci/hotplug/rpadlpar_core.c
index 46825fee3ae4..72383467a0d5 100644
--- a/drivers/pci/hotplug/rpadlpar_core.c
+++ b/drivers/pci/hotplug/rpadlpar_core.c
@@ -63,7 +63,7 @@ static struct device_node *find_php_slot_pci_node(char *drc_name,
63 char *type; 63 char *type;
64 int rc; 64 int rc;
65 65
66 while ((np = of_find_node_by_type(np, "pci"))) { 66 while ((np = of_find_node_by_name(np, "pci"))) {
67 rc = rpaphp_get_drc_props(np, NULL, &name, &type, NULL); 67 rc = rpaphp_get_drc_props(np, NULL, &name, &type, NULL);
68 if (rc == 0) 68 if (rc == 0)
69 if (!strcmp(drc_name, name) && !strcmp(drc_type, type)) 69 if (!strcmp(drc_name, name) && !strcmp(drc_type, type))
diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c
index 141486df235b..71a2cb8baa4a 100644
--- a/drivers/pci/hotplug/rpaphp_core.c
+++ b/drivers/pci/hotplug/rpaphp_core.c
@@ -356,7 +356,7 @@ static int __init rpaphp_init(void)
356 info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); 356 info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
357 init_MUTEX(&rpaphp_sem); 357 init_MUTEX(&rpaphp_sem);
358 358
359 while ((dn = of_find_node_by_type(dn, "pci"))) 359 while ((dn = of_find_node_by_name(dn, "pci")))
360 rpaphp_add_slot(dn); 360 rpaphp_add_slot(dn);
361 361
362 return 0; 362 return 0;
diff --git a/drivers/pci/hotplug/sgi_hotplug.c b/drivers/pci/hotplug/sgi_hotplug.c
index b62ad31a9739..5d188c558386 100644
--- a/drivers/pci/hotplug/sgi_hotplug.c
+++ b/drivers/pci/hotplug/sgi_hotplug.c
@@ -205,21 +205,6 @@ static struct hotplug_slot * sn_hp_destroy(void)
205 return bss_hotplug_slot; 205 return bss_hotplug_slot;
206} 206}
207 207
208static void sn_bus_alloc_data(struct pci_dev *dev)
209{
210 struct pci_bus *subordinate_bus;
211 struct pci_dev *child;
212
213 sn_pci_fixup_slot(dev);
214
215 /* Recursively sets up the sn_irq_info structs */
216 if (dev->subordinate) {
217 subordinate_bus = dev->subordinate;
218 list_for_each_entry(child, &subordinate_bus->devices, bus_list)
219 sn_bus_alloc_data(child);
220 }
221}
222
223static void sn_bus_free_data(struct pci_dev *dev) 208static void sn_bus_free_data(struct pci_dev *dev)
224{ 209{
225 struct pci_bus *subordinate_bus; 210 struct pci_bus *subordinate_bus;
@@ -337,6 +322,11 @@ static int sn_slot_disable(struct hotplug_slot *bss_hotplug_slot,
337 return rc; 322 return rc;
338} 323}
339 324
325/*
326 * Power up and configure the slot via a SAL call to PROM.
327 * Scan slot (and any children), do any platform specific fixup,
328 * and find device driver.
329 */
340static int enable_slot(struct hotplug_slot *bss_hotplug_slot) 330static int enable_slot(struct hotplug_slot *bss_hotplug_slot)
341{ 331{
342 struct slot *slot = bss_hotplug_slot->private; 332 struct slot *slot = bss_hotplug_slot->private;
@@ -345,6 +335,7 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot)
345 int func, num_funcs; 335 int func, num_funcs;
346 int new_ppb = 0; 336 int new_ppb = 0;
347 int rc; 337 int rc;
338 void pcibios_fixup_device_resources(struct pci_dev *);
348 339
349 /* Serialize the Linux PCI infrastructure */ 340 /* Serialize the Linux PCI infrastructure */
350 mutex_lock(&sn_hotplug_mutex); 341 mutex_lock(&sn_hotplug_mutex);
@@ -367,9 +358,6 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot)
367 return -ENODEV; 358 return -ENODEV;
368 } 359 }
369 360
370 sn_pci_controller_fixup(pci_domain_nr(slot->pci_bus),
371 slot->pci_bus->number,
372 slot->pci_bus);
373 /* 361 /*
374 * Map SN resources for all functions on the card 362 * Map SN resources for all functions on the card
375 * to the Linux PCI interface and tell the drivers 363 * to the Linux PCI interface and tell the drivers
@@ -380,6 +368,13 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot)
380 PCI_DEVFN(slot->device_num + 1, 368 PCI_DEVFN(slot->device_num + 1,
381 PCI_FUNC(func))); 369 PCI_FUNC(func)));
382 if (dev) { 370 if (dev) {
371 /* Need to do slot fixup on PPB before fixup of children
372 * (PPB's pcidev_info needs to be in pcidev_info list
373 * before child's SN_PCIDEV_INFO() call to setup
374 * pdi_host_pcidev_info).
375 */
376 pcibios_fixup_device_resources(dev);
377 sn_pci_fixup_slot(dev);
383 if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) { 378 if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) {
384 unsigned char sec_bus; 379 unsigned char sec_bus;
385 pci_read_config_byte(dev, PCI_SECONDARY_BUS, 380 pci_read_config_byte(dev, PCI_SECONDARY_BUS,
@@ -387,12 +382,8 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot)
387 new_bus = pci_add_new_bus(dev->bus, dev, 382 new_bus = pci_add_new_bus(dev->bus, dev,
388 sec_bus); 383 sec_bus);
389 pci_scan_child_bus(new_bus); 384 pci_scan_child_bus(new_bus);
390 sn_pci_controller_fixup(pci_domain_nr(new_bus),
391 new_bus->number,
392 new_bus);
393 new_ppb = 1; 385 new_ppb = 1;
394 } 386 }
395 sn_bus_alloc_data(dev);
396 pci_dev_put(dev); 387 pci_dev_put(dev);
397 } 388 }
398 } 389 }
diff --git a/drivers/pci/hotplug/shpchp.h b/drivers/pci/hotplug/shpchp.h
index ea2087c34149..50757695844f 100644
--- a/drivers/pci/hotplug/shpchp.h
+++ b/drivers/pci/hotplug/shpchp.h
@@ -70,7 +70,7 @@ struct slot {
70 struct hotplug_slot *hotplug_slot; 70 struct hotplug_slot *hotplug_slot;
71 struct list_head slot_list; 71 struct list_head slot_list;
72 char name[SLOT_NAME_SIZE]; 72 char name[SLOT_NAME_SIZE];
73 struct work_struct work; /* work for button event */ 73 struct delayed_work work; /* work for button event */
74 struct mutex lock; 74 struct mutex lock;
75}; 75};
76 76
@@ -187,7 +187,7 @@ extern int shpchp_configure_device(struct slot *p_slot);
187extern int shpchp_unconfigure_device(struct slot *p_slot); 187extern int shpchp_unconfigure_device(struct slot *p_slot);
188extern void shpchp_remove_ctrl_files(struct controller *ctrl); 188extern void shpchp_remove_ctrl_files(struct controller *ctrl);
189extern void cleanup_slots(struct controller *ctrl); 189extern void cleanup_slots(struct controller *ctrl);
190extern void queue_pushbutton_work(void *data); 190extern void queue_pushbutton_work(struct work_struct *work);
191 191
192 192
193#ifdef CONFIG_ACPI 193#ifdef CONFIG_ACPI
diff --git a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c
index 235c18a22393..4eac85b3d90e 100644
--- a/drivers/pci/hotplug/shpchp_core.c
+++ b/drivers/pci/hotplug/shpchp_core.c
@@ -159,7 +159,7 @@ static int init_slots(struct controller *ctrl)
159 goto error_info; 159 goto error_info;
160 160
161 slot->number = sun; 161 slot->number = sun;
162 INIT_WORK(&slot->work, queue_pushbutton_work, slot); 162 INIT_DELAYED_WORK(&slot->work, queue_pushbutton_work);
163 163
164 /* register this slot with the hotplug pci core */ 164 /* register this slot with the hotplug pci core */
165 hotplug_slot->private = slot; 165 hotplug_slot->private = slot;
diff --git a/drivers/pci/hotplug/shpchp_ctrl.c b/drivers/pci/hotplug/shpchp_ctrl.c
index c39901dbff20..158ac7836096 100644
--- a/drivers/pci/hotplug/shpchp_ctrl.c
+++ b/drivers/pci/hotplug/shpchp_ctrl.c
@@ -36,7 +36,7 @@
36#include "../pci.h" 36#include "../pci.h"
37#include "shpchp.h" 37#include "shpchp.h"
38 38
39static void interrupt_event_handler(void *data); 39static void interrupt_event_handler(struct work_struct *work);
40static int shpchp_enable_slot(struct slot *p_slot); 40static int shpchp_enable_slot(struct slot *p_slot);
41static int shpchp_disable_slot(struct slot *p_slot); 41static int shpchp_disable_slot(struct slot *p_slot);
42 42
@@ -50,7 +50,7 @@ static int queue_interrupt_event(struct slot *p_slot, u32 event_type)
50 50
51 info->event_type = event_type; 51 info->event_type = event_type;
52 info->p_slot = p_slot; 52 info->p_slot = p_slot;
53 INIT_WORK(&info->work, interrupt_event_handler, info); 53 INIT_WORK(&info->work, interrupt_event_handler);
54 54
55 schedule_work(&info->work); 55 schedule_work(&info->work);
56 56
@@ -408,9 +408,10 @@ struct pushbutton_work_info {
408 * Handles all pending events and exits. 408 * Handles all pending events and exits.
409 * 409 *
410 */ 410 */
411static void shpchp_pushbutton_thread(void *data) 411static void shpchp_pushbutton_thread(struct work_struct *work)
412{ 412{
413 struct pushbutton_work_info *info = data; 413 struct pushbutton_work_info *info =
414 container_of(work, struct pushbutton_work_info, work);
414 struct slot *p_slot = info->p_slot; 415 struct slot *p_slot = info->p_slot;
415 416
416 mutex_lock(&p_slot->lock); 417 mutex_lock(&p_slot->lock);
@@ -436,9 +437,9 @@ static void shpchp_pushbutton_thread(void *data)
436 kfree(info); 437 kfree(info);
437} 438}
438 439
439void queue_pushbutton_work(void *data) 440void queue_pushbutton_work(struct work_struct *work)
440{ 441{
441 struct slot *p_slot = data; 442 struct slot *p_slot = container_of(work, struct slot, work.work);
442 struct pushbutton_work_info *info; 443 struct pushbutton_work_info *info;
443 444
444 info = kmalloc(sizeof(*info), GFP_KERNEL); 445 info = kmalloc(sizeof(*info), GFP_KERNEL);
@@ -447,7 +448,7 @@ void queue_pushbutton_work(void *data)
447 return; 448 return;
448 } 449 }
449 info->p_slot = p_slot; 450 info->p_slot = p_slot;
450 INIT_WORK(&info->work, shpchp_pushbutton_thread, info); 451 INIT_WORK(&info->work, shpchp_pushbutton_thread);
451 452
452 mutex_lock(&p_slot->lock); 453 mutex_lock(&p_slot->lock);
453 switch (p_slot->state) { 454 switch (p_slot->state) {
@@ -541,9 +542,9 @@ static void handle_button_press_event(struct slot *p_slot)
541 } 542 }
542} 543}
543 544
544static void interrupt_event_handler(void *data) 545static void interrupt_event_handler(struct work_struct *work)
545{ 546{
546 struct event_info *info = data; 547 struct event_info *info = container_of(work, struct event_info, work);
547 struct slot *p_slot = info->p_slot; 548 struct slot *p_slot = info->p_slot;
548 549
549 mutex_lock(&p_slot->lock); 550 mutex_lock(&p_slot->lock);
diff --git a/drivers/pci/htirq.c b/drivers/pci/htirq.c
index 0e27f2404a83..0a8d1cce9fa0 100644
--- a/drivers/pci/htirq.c
+++ b/drivers/pci/htirq.c
@@ -25,97 +25,72 @@ static DEFINE_SPINLOCK(ht_irq_lock);
25 25
26struct ht_irq_cfg { 26struct ht_irq_cfg {
27 struct pci_dev *dev; 27 struct pci_dev *dev;
28 /* Update callback used to cope with buggy hardware */
29 ht_irq_update_t *update;
28 unsigned pos; 30 unsigned pos;
29 unsigned idx; 31 unsigned idx;
32 struct ht_irq_msg msg;
30}; 33};
31 34
32void write_ht_irq_low(unsigned int irq, u32 data)
33{
34 struct ht_irq_cfg *cfg = get_irq_data(irq);
35 unsigned long flags;
36 spin_lock_irqsave(&ht_irq_lock, flags);
37 pci_write_config_byte(cfg->dev, cfg->pos + 2, cfg->idx);
38 pci_write_config_dword(cfg->dev, cfg->pos + 4, data);
39 spin_unlock_irqrestore(&ht_irq_lock, flags);
40}
41 35
42void write_ht_irq_high(unsigned int irq, u32 data) 36void write_ht_irq_msg(unsigned int irq, struct ht_irq_msg *msg)
43{ 37{
44 struct ht_irq_cfg *cfg = get_irq_data(irq); 38 struct ht_irq_cfg *cfg = get_irq_data(irq);
45 unsigned long flags; 39 unsigned long flags;
46 spin_lock_irqsave(&ht_irq_lock, flags); 40 spin_lock_irqsave(&ht_irq_lock, flags);
47 pci_write_config_byte(cfg->dev, cfg->pos + 2, cfg->idx + 1); 41 if (cfg->msg.address_lo != msg->address_lo) {
48 pci_write_config_dword(cfg->dev, cfg->pos + 4, data); 42 pci_write_config_byte(cfg->dev, cfg->pos + 2, cfg->idx);
49 spin_unlock_irqrestore(&ht_irq_lock, flags); 43 pci_write_config_dword(cfg->dev, cfg->pos + 4, msg->address_lo);
50} 44 }
51 45 if (cfg->msg.address_hi != msg->address_hi) {
52u32 read_ht_irq_low(unsigned int irq) 46 pci_write_config_byte(cfg->dev, cfg->pos + 2, cfg->idx + 1);
53{ 47 pci_write_config_dword(cfg->dev, cfg->pos + 4, msg->address_hi);
54 struct ht_irq_cfg *cfg = get_irq_data(irq); 48 }
55 unsigned long flags; 49 if (cfg->update)
56 u32 data; 50 cfg->update(cfg->dev, irq, msg);
57 spin_lock_irqsave(&ht_irq_lock, flags);
58 pci_write_config_byte(cfg->dev, cfg->pos + 2, cfg->idx);
59 pci_read_config_dword(cfg->dev, cfg->pos + 4, &data);
60 spin_unlock_irqrestore(&ht_irq_lock, flags); 51 spin_unlock_irqrestore(&ht_irq_lock, flags);
61 return data; 52 cfg->msg = *msg;
62} 53}
63 54
64u32 read_ht_irq_high(unsigned int irq) 55void fetch_ht_irq_msg(unsigned int irq, struct ht_irq_msg *msg)
65{ 56{
66 struct ht_irq_cfg *cfg = get_irq_data(irq); 57 struct ht_irq_cfg *cfg = get_irq_data(irq);
67 unsigned long flags; 58 *msg = cfg->msg;
68 u32 data;
69 spin_lock_irqsave(&ht_irq_lock, flags);
70 pci_write_config_byte(cfg->dev, cfg->pos + 2, cfg->idx + 1);
71 pci_read_config_dword(cfg->dev, cfg->pos + 4, &data);
72 spin_unlock_irqrestore(&ht_irq_lock, flags);
73 return data;
74} 59}
75 60
76void mask_ht_irq(unsigned int irq) 61void mask_ht_irq(unsigned int irq)
77{ 62{
78 struct ht_irq_cfg *cfg; 63 struct ht_irq_cfg *cfg;
79 unsigned long flags; 64 struct ht_irq_msg msg;
80 u32 data;
81 65
82 cfg = get_irq_data(irq); 66 cfg = get_irq_data(irq);
83 67
84 spin_lock_irqsave(&ht_irq_lock, flags); 68 msg = cfg->msg;
85 pci_write_config_byte(cfg->dev, cfg->pos + 2, cfg->idx); 69 msg.address_lo |= 1;
86 pci_read_config_dword(cfg->dev, cfg->pos + 4, &data); 70 write_ht_irq_msg(irq, &msg);
87 data |= 1;
88 pci_write_config_dword(cfg->dev, cfg->pos + 4, data);
89 spin_unlock_irqrestore(&ht_irq_lock, flags);
90} 71}
91 72
92void unmask_ht_irq(unsigned int irq) 73void unmask_ht_irq(unsigned int irq)
93{ 74{
94 struct ht_irq_cfg *cfg; 75 struct ht_irq_cfg *cfg;
95 unsigned long flags; 76 struct ht_irq_msg msg;
96 u32 data;
97 77
98 cfg = get_irq_data(irq); 78 cfg = get_irq_data(irq);
99 79
100 spin_lock_irqsave(&ht_irq_lock, flags); 80 msg = cfg->msg;
101 pci_write_config_byte(cfg->dev, cfg->pos + 2, cfg->idx); 81 msg.address_lo &= ~1;
102 pci_read_config_dword(cfg->dev, cfg->pos + 4, &data); 82 write_ht_irq_msg(irq, &msg);
103 data &= ~1;
104 pci_write_config_dword(cfg->dev, cfg->pos + 4, data);
105 spin_unlock_irqrestore(&ht_irq_lock, flags);
106} 83}
107 84
108/** 85/**
109 * ht_create_irq - create an irq and attach it to a device. 86 * __ht_create_irq - create an irq and attach it to a device.
110 * @dev: The hypertransport device to find the irq capability on. 87 * @dev: The hypertransport device to find the irq capability on.
111 * @idx: Which of the possible irqs to attach to. 88 * @idx: Which of the possible irqs to attach to.
112 * 89 * @update: Function to be called when changing the htirq message
113 * ht_create_irq is needs to be called for all hypertransport devices
114 * that generate irqs.
115 * 90 *
116 * The irq number of the new irq or a negative error value is returned. 91 * The irq number of the new irq or a negative error value is returned.
117 */ 92 */
118int ht_create_irq(struct pci_dev *dev, int idx) 93int __ht_create_irq(struct pci_dev *dev, int idx, ht_irq_update_t *update)
119{ 94{
120 struct ht_irq_cfg *cfg; 95 struct ht_irq_cfg *cfg;
121 unsigned long flags; 96 unsigned long flags;
@@ -150,8 +125,12 @@ int ht_create_irq(struct pci_dev *dev, int idx)
150 return -ENOMEM; 125 return -ENOMEM;
151 126
152 cfg->dev = dev; 127 cfg->dev = dev;
128 cfg->update = update;
153 cfg->pos = pos; 129 cfg->pos = pos;
154 cfg->idx = 0x10 + (idx * 2); 130 cfg->idx = 0x10 + (idx * 2);
131 /* Initialize msg to a value that will never match the first write. */
132 cfg->msg.address_lo = 0xffffffff;
133 cfg->msg.address_hi = 0xffffffff;
155 134
156 irq = create_irq(); 135 irq = create_irq();
157 if (irq < 0) { 136 if (irq < 0) {
@@ -169,6 +148,21 @@ int ht_create_irq(struct pci_dev *dev, int idx)
169} 148}
170 149
171/** 150/**
151 * ht_create_irq - create an irq and attach it to a device.
152 * @dev: The hypertransport device to find the irq capability on.
153 * @idx: Which of the possible irqs to attach to.
154 *
155 * ht_create_irq needs to be called for all hypertransport devices
156 * that generate irqs.
157 *
158 * The irq number of the new irq or a negative error value is returned.
159 */
160int ht_create_irq(struct pci_dev *dev, int idx)
161{
162 return __ht_create_irq(dev, idx, NULL);
163}
164
165/**
172 * ht_destroy_irq - destroy an irq created with ht_create_irq 166 * ht_destroy_irq - destroy an irq created with ht_create_irq
173 * 167 *
174 * This reverses ht_create_irq removing the specified irq from 168 * This reverses ht_create_irq removing the specified irq from
@@ -186,5 +180,6 @@ void ht_destroy_irq(unsigned int irq)
186 kfree(cfg); 180 kfree(cfg);
187} 181}
188 182
183EXPORT_SYMBOL(__ht_create_irq);
189EXPORT_SYMBOL(ht_create_irq); 184EXPORT_SYMBOL(ht_create_irq);
190EXPORT_SYMBOL(ht_destroy_irq); 185EXPORT_SYMBOL(ht_destroy_irq);
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 9fc9a34ef24a..ed3f7e1a563c 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -26,7 +26,7 @@
26 26
27static DEFINE_SPINLOCK(msi_lock); 27static DEFINE_SPINLOCK(msi_lock);
28static struct msi_desc* msi_desc[NR_IRQS] = { [0 ... NR_IRQS-1] = NULL }; 28static struct msi_desc* msi_desc[NR_IRQS] = { [0 ... NR_IRQS-1] = NULL };
29static kmem_cache_t* msi_cachep; 29static struct kmem_cache* msi_cachep;
30 30
31static int pci_msi_enable = 1; 31static int pci_msi_enable = 1;
32 32
@@ -255,10 +255,8 @@ static void enable_msi_mode(struct pci_dev *dev, int pos, int type)
255 pci_write_config_word(dev, msi_control_reg(pos), control); 255 pci_write_config_word(dev, msi_control_reg(pos), control);
256 dev->msix_enabled = 1; 256 dev->msix_enabled = 1;
257 } 257 }
258 if (pci_find_capability(dev, PCI_CAP_ID_EXP)) { 258
259 /* PCI Express Endpoint device detected */ 259 pci_intx(dev, 0); /* disable intx */
260 pci_intx(dev, 0); /* disable intx */
261 }
262} 260}
263 261
264void disable_msi_mode(struct pci_dev *dev, int pos, int type) 262void disable_msi_mode(struct pci_dev *dev, int pos, int type)
@@ -276,10 +274,8 @@ void disable_msi_mode(struct pci_dev *dev, int pos, int type)
276 pci_write_config_word(dev, msi_control_reg(pos), control); 274 pci_write_config_word(dev, msi_control_reg(pos), control);
277 dev->msix_enabled = 0; 275 dev->msix_enabled = 0;
278 } 276 }
279 if (pci_find_capability(dev, PCI_CAP_ID_EXP)) { 277
280 /* PCI Express Endpoint device detected */ 278 pci_intx(dev, 1); /* enable intx */
281 pci_intx(dev, 1); /* enable intx */
282 }
283} 279}
284 280
285static int msi_lookup_irq(struct pci_dev *dev, int type) 281static int msi_lookup_irq(struct pci_dev *dev, int type)
diff --git a/drivers/pci/msi.h b/drivers/pci/msi.h
index f0cca1772f9c..3898f5237144 100644
--- a/drivers/pci/msi.h
+++ b/drivers/pci/msi.h
@@ -6,14 +6,6 @@
6#ifndef MSI_H 6#ifndef MSI_H
7#define MSI_H 7#define MSI_H
8 8
9/*
10 * MSI-X Address Register
11 */
12#define PCI_MSIX_FLAGS_QSIZE 0x7FF
13#define PCI_MSIX_FLAGS_ENABLE (1 << 15)
14#define PCI_MSIX_FLAGS_BIRMASK (7 << 0)
15#define PCI_MSIX_FLAGS_BITMASK (1 << 0)
16
17#define PCI_MSIX_ENTRY_SIZE 16 9#define PCI_MSIX_ENTRY_SIZE 16
18#define PCI_MSIX_ENTRY_LOWER_ADDR_OFFSET 0 10#define PCI_MSIX_ENTRY_LOWER_ADDR_OFFSET 0
19#define PCI_MSIX_ENTRY_UPPER_ADDR_OFFSET 4 11#define PCI_MSIX_ENTRY_UPPER_ADDR_OFFSET 4
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index bb7456c1dbac..a064f36a0805 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -36,6 +36,7 @@ acpi_query_osc (
36 struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL}; 36 struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL};
37 union acpi_object *out_obj; 37 union acpi_object *out_obj;
38 u32 osc_dw0; 38 u32 osc_dw0;
39 acpi_status *ret_status = (acpi_status *)retval;
39 40
40 41
41 /* Setting up input parameters */ 42 /* Setting up input parameters */
@@ -56,6 +57,7 @@ acpi_query_osc (
56 if (ACPI_FAILURE (status)) { 57 if (ACPI_FAILURE (status)) {
57 printk(KERN_DEBUG 58 printk(KERN_DEBUG
58 "Evaluate _OSC Set fails. Status = 0x%04x\n", status); 59 "Evaluate _OSC Set fails. Status = 0x%04x\n", status);
60 *ret_status = status;
59 return status; 61 return status;
60 } 62 }
61 out_obj = output.pointer; 63 out_obj = output.pointer;
@@ -90,6 +92,7 @@ acpi_query_osc (
90 92
91query_osc_out: 93query_osc_out:
92 kfree(output.pointer); 94 kfree(output.pointer);
95 *ret_status = status;
93 return status; 96 return status;
94} 97}
95 98
@@ -166,6 +169,7 @@ run_osc_out:
166acpi_status pci_osc_support_set(u32 flags) 169acpi_status pci_osc_support_set(u32 flags)
167{ 170{
168 u32 temp; 171 u32 temp;
172 acpi_status retval;
169 173
170 if (!(flags & OSC_SUPPORT_MASKS)) { 174 if (!(flags & OSC_SUPPORT_MASKS)) {
171 return AE_TYPE; 175 return AE_TYPE;
@@ -179,9 +183,13 @@ acpi_status pci_osc_support_set(u32 flags)
179 acpi_get_devices ( PCI_ROOT_HID_STRING, 183 acpi_get_devices ( PCI_ROOT_HID_STRING,
180 acpi_query_osc, 184 acpi_query_osc,
181 ctrlset_buf, 185 ctrlset_buf,
182 NULL ); 186 (void **) &retval );
183 ctrlset_buf[OSC_QUERY_TYPE] = !OSC_QUERY_ENABLE; 187 ctrlset_buf[OSC_QUERY_TYPE] = !OSC_QUERY_ENABLE;
184 ctrlset_buf[OSC_CONTROL_TYPE] = temp; 188 ctrlset_buf[OSC_CONTROL_TYPE] = temp;
189 if (ACPI_FAILURE(retval)) {
190 /* no osc support at all */
191 ctrlset_buf[OSC_SUPPORT_TYPE] = 0;
192 }
185 return AE_OK; 193 return AE_OK;
186} 194}
187EXPORT_SYMBOL(pci_osc_support_set); 195EXPORT_SYMBOL(pci_osc_support_set);
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 194f1d21d3d7..e5ae3a0c13bb 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -329,8 +329,8 @@ static int pci_default_resume(struct pci_dev *pci_dev)
329 /* restore the PCI config space */ 329 /* restore the PCI config space */
330 pci_restore_state(pci_dev); 330 pci_restore_state(pci_dev);
331 /* if the device was enabled before suspend, reenable */ 331 /* if the device was enabled before suspend, reenable */
332 if (pci_dev->is_enabled) 332 if (atomic_read(&pci_dev->enable_cnt))
333 retval = pci_enable_device(pci_dev); 333 retval = __pci_enable_device(pci_dev);
334 /* if the device was busmaster before the suspend, make it busmaster again */ 334 /* if the device was busmaster before the suspend, make it busmaster again */
335 if (pci_dev->is_busmaster) 335 if (pci_dev->is_busmaster)
336 pci_set_master(pci_dev); 336 pci_set_master(pci_dev);
@@ -445,9 +445,12 @@ int __pci_register_driver(struct pci_driver *drv, struct module *owner)
445 445
446 /* register with core */ 446 /* register with core */
447 error = driver_register(&drv->driver); 447 error = driver_register(&drv->driver);
448 if (error)
449 return error;
448 450
449 if (!error) 451 error = pci_create_newid_file(drv);
450 error = pci_create_newid_file(drv); 452 if (error)
453 driver_unregister(&drv->driver);
451 454
452 return error; 455 return error;
453} 456}
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index a1d2e979b17f..7a94076752d0 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -42,7 +42,6 @@ pci_config_attr(subsystem_vendor, "0x%04x\n");
42pci_config_attr(subsystem_device, "0x%04x\n"); 42pci_config_attr(subsystem_device, "0x%04x\n");
43pci_config_attr(class, "0x%06x\n"); 43pci_config_attr(class, "0x%06x\n");
44pci_config_attr(irq, "%u\n"); 44pci_config_attr(irq, "%u\n");
45pci_config_attr(is_enabled, "%u\n");
46 45
47static ssize_t broken_parity_status_show(struct device *dev, 46static ssize_t broken_parity_status_show(struct device *dev,
48 struct device_attribute *attr, 47 struct device_attribute *attr,
@@ -112,26 +111,36 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
112 (u8)(pci_dev->class >> 16), (u8)(pci_dev->class >> 8), 111 (u8)(pci_dev->class >> 16), (u8)(pci_dev->class >> 8),
113 (u8)(pci_dev->class)); 112 (u8)(pci_dev->class));
114} 113}
115static ssize_t 114
116is_enabled_store(struct device *dev, struct device_attribute *attr, 115static ssize_t is_enabled_store(struct device *dev,
117 const char *buf, size_t count) 116 struct device_attribute *attr, const char *buf,
117 size_t count)
118{ 118{
119 ssize_t result = -EINVAL;
119 struct pci_dev *pdev = to_pci_dev(dev); 120 struct pci_dev *pdev = to_pci_dev(dev);
120 int retval = 0;
121 121
122 /* this can crash the machine when done on the "wrong" device */ 122 /* this can crash the machine when done on the "wrong" device */
123 if (!capable(CAP_SYS_ADMIN)) 123 if (!capable(CAP_SYS_ADMIN))
124 return count; 124 return count;
125 125
126 if (*buf == '0') 126 if (*buf == '0') {
127 pci_disable_device(pdev); 127 if (atomic_read(&pdev->enable_cnt) != 0)
128 pci_disable_device(pdev);
129 else
130 result = -EIO;
131 } else if (*buf == '1')
132 result = pci_enable_device(pdev);
133
134 return result < 0 ? result : count;
135}
128 136
129 if (*buf == '1') 137static ssize_t is_enabled_show(struct device *dev,
130 retval = pci_enable_device(pdev); 138 struct device_attribute *attr, char *buf)
139{
140 struct pci_dev *pdev;
131 141
132 if (retval) 142 pdev = to_pci_dev (dev);
133 return retval; 143 return sprintf (buf, "%u\n", atomic_read(&pdev->enable_cnt));
134 return count;
135} 144}
136 145
137static ssize_t 146static ssize_t
@@ -642,6 +651,9 @@ err:
642 */ 651 */
643void pci_remove_sysfs_dev_files(struct pci_dev *pdev) 652void pci_remove_sysfs_dev_files(struct pci_dev *pdev)
644{ 653{
654 if (!sysfs_initialized)
655 return;
656
645 if (pdev->cfg_size < 4096) 657 if (pdev->cfg_size < 4096)
646 sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr); 658 sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr);
647 else 659 else
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index a544997399b3..5a14b73cf3a1 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -490,6 +490,47 @@ static void pci_restore_pcie_state(struct pci_dev *dev)
490 kfree(save_state); 490 kfree(save_state);
491} 491}
492 492
493
494static int pci_save_pcix_state(struct pci_dev *dev)
495{
496 int pos, i = 0;
497 struct pci_cap_saved_state *save_state;
498 u16 *cap;
499
500 pos = pci_find_capability(dev, PCI_CAP_ID_PCIX);
501 if (pos <= 0)
502 return 0;
503
504 save_state = kzalloc(sizeof(*save_state) + sizeof(u16), GFP_KERNEL);
505 if (!save_state) {
506 dev_err(&dev->dev, "Out of memory in pci_save_pcie_state\n");
507 return -ENOMEM;
508 }
509 cap = (u16 *)&save_state->data[0];
510
511 pci_read_config_word(dev, pos + PCI_X_CMD, &cap[i++]);
512 pci_add_saved_cap(dev, save_state);
513 return 0;
514}
515
516static void pci_restore_pcix_state(struct pci_dev *dev)
517{
518 int i = 0, pos;
519 struct pci_cap_saved_state *save_state;
520 u16 *cap;
521
522 save_state = pci_find_saved_cap(dev, PCI_CAP_ID_PCIX);
523 pos = pci_find_capability(dev, PCI_CAP_ID_PCIX);
524 if (!save_state || pos <= 0)
525 return;
526 cap = (u16 *)&save_state->data[0];
527
528 pci_write_config_word(dev, pos + PCI_X_CMD, cap[i++]);
529 pci_remove_saved_cap(save_state);
530 kfree(save_state);
531}
532
533
493/** 534/**
494 * pci_save_state - save the PCI configuration space of a device before suspending 535 * pci_save_state - save the PCI configuration space of a device before suspending
495 * @dev: - PCI device that we're dealing with 536 * @dev: - PCI device that we're dealing with
@@ -507,6 +548,8 @@ pci_save_state(struct pci_dev *dev)
507 return i; 548 return i;
508 if ((i = pci_save_pcie_state(dev)) != 0) 549 if ((i = pci_save_pcie_state(dev)) != 0)
509 return i; 550 return i;
551 if ((i = pci_save_pcix_state(dev)) != 0)
552 return i;
510 return 0; 553 return 0;
511} 554}
512 555
@@ -538,6 +581,7 @@ pci_restore_state(struct pci_dev *dev)
538 dev->saved_config_space[i]); 581 dev->saved_config_space[i]);
539 } 582 }
540 } 583 }
584 pci_restore_pcix_state(dev);
541 pci_restore_msi_state(dev); 585 pci_restore_msi_state(dev);
542 pci_restore_msix_state(dev); 586 pci_restore_msix_state(dev);
543 return 0; 587 return 0;
@@ -568,30 +612,51 @@ pci_enable_device_bars(struct pci_dev *dev, int bars)
568} 612}
569 613
570/** 614/**
571 * pci_enable_device - Initialize device before it's used by a driver. 615 * __pci_enable_device - Initialize device before it's used by a driver.
572 * @dev: PCI device to be initialized 616 * @dev: PCI device to be initialized
573 * 617 *
574 * Initialize device before it's used by a driver. Ask low-level code 618 * Initialize device before it's used by a driver. Ask low-level code
575 * to enable I/O and memory. Wake up the device if it was suspended. 619 * to enable I/O and memory. Wake up the device if it was suspended.
576 * Beware, this function can fail. 620 * Beware, this function can fail.
621 *
622 * Note this function is a backend and is not supposed to be called by
623 * normal code, use pci_enable_device() instead.
577 */ 624 */
578int 625int
579pci_enable_device(struct pci_dev *dev) 626__pci_enable_device(struct pci_dev *dev)
580{ 627{
581 int err; 628 int err;
582 629
583 if (dev->is_enabled)
584 return 0;
585
586 err = pci_enable_device_bars(dev, (1 << PCI_NUM_RESOURCES) - 1); 630 err = pci_enable_device_bars(dev, (1 << PCI_NUM_RESOURCES) - 1);
587 if (err) 631 if (err)
588 return err; 632 return err;
589 pci_fixup_device(pci_fixup_enable, dev); 633 pci_fixup_device(pci_fixup_enable, dev);
590 dev->is_enabled = 1;
591 return 0; 634 return 0;
592} 635}
593 636
594/** 637/**
638 * pci_enable_device - Initialize device before it's used by a driver.
639 * @dev: PCI device to be initialized
640 *
641 * Initialize device before it's used by a driver. Ask low-level code
642 * to enable I/O and memory. Wake up the device if it was suspended.
643 * Beware, this function can fail.
644 *
645 * Note we don't actually enable the device many times if we call
646 * this function repeatedly (we just increment the count).
647 */
648int pci_enable_device(struct pci_dev *dev)
649{
650 int result;
651 if (atomic_add_return(1, &dev->enable_cnt) > 1)
652 return 0; /* already enabled */
653 result = __pci_enable_device(dev);
654 if (result < 0)
655 atomic_dec(&dev->enable_cnt);
656 return result;
657}
658
659/**
595 * pcibios_disable_device - disable arch specific PCI resources for device dev 660 * pcibios_disable_device - disable arch specific PCI resources for device dev
596 * @dev: the PCI device to disable 661 * @dev: the PCI device to disable
597 * 662 *
@@ -607,12 +672,18 @@ void __attribute__ ((weak)) pcibios_disable_device (struct pci_dev *dev) {}
607 * 672 *
608 * Signal to the system that the PCI device is not in use by the system 673 * Signal to the system that the PCI device is not in use by the system
609 * anymore. This only involves disabling PCI bus-mastering, if active. 674 * anymore. This only involves disabling PCI bus-mastering, if active.
675 *
676 * Note we don't actually disable the device until all callers of
677 * pci_device_enable() have called pci_device_disable().
610 */ 678 */
611void 679void
612pci_disable_device(struct pci_dev *dev) 680pci_disable_device(struct pci_dev *dev)
613{ 681{
614 u16 pci_command; 682 u16 pci_command;
615 683
684 if (atomic_sub_return(1, &dev->enable_cnt) != 0)
685 return;
686
616 if (dev->msi_enabled) 687 if (dev->msi_enabled)
617 disable_msi_mode(dev, pci_find_capability(dev, PCI_CAP_ID_MSI), 688 disable_msi_mode(dev, pci_find_capability(dev, PCI_CAP_ID_MSI),
618 PCI_CAP_ID_MSI); 689 PCI_CAP_ID_MSI);
@@ -628,7 +699,6 @@ pci_disable_device(struct pci_dev *dev)
628 dev->is_busmaster = 0; 699 dev->is_busmaster = 0;
629 700
630 pcibios_disable_device(dev); 701 pcibios_disable_device(dev);
631 dev->is_enabled = 0;
632} 702}
633 703
634/** 704/**
@@ -831,22 +901,38 @@ pci_set_master(struct pci_dev *dev)
831 pcibios_set_master(dev); 901 pcibios_set_master(dev);
832} 902}
833 903
834#ifndef HAVE_ARCH_PCI_MWI 904#ifdef PCI_DISABLE_MWI
905int pci_set_mwi(struct pci_dev *dev)
906{
907 return 0;
908}
909
910void pci_clear_mwi(struct pci_dev *dev)
911{
912}
913
914#else
915
916#ifndef PCI_CACHE_LINE_BYTES
917#define PCI_CACHE_LINE_BYTES L1_CACHE_BYTES
918#endif
919
835/* This can be overridden by arch code. */ 920/* This can be overridden by arch code. */
836u8 pci_cache_line_size = L1_CACHE_BYTES >> 2; 921/* Don't forget this is measured in 32-bit words, not bytes */
922u8 pci_cache_line_size = PCI_CACHE_LINE_BYTES / 4;
837 923
838/** 924/**
839 * pci_generic_prep_mwi - helper function for pci_set_mwi 925 * pci_set_cacheline_size - ensure the CACHE_LINE_SIZE register is programmed
840 * @dev: the PCI device for which MWI is enabled 926 * @dev: the PCI device for which MWI is to be enabled
841 * 927 *
842 * Helper function for generic implementation of pcibios_prep_mwi 928 * Helper function for pci_set_mwi.
843 * function. Originally copied from drivers/net/acenic.c. 929 * Originally copied from drivers/net/acenic.c.
844 * Copyright 1998-2001 by Jes Sorensen, <jes@trained-monkey.org>. 930 * Copyright 1998-2001 by Jes Sorensen, <jes@trained-monkey.org>.
845 * 931 *
846 * RETURNS: An appropriate -ERRNO error value on error, or zero for success. 932 * RETURNS: An appropriate -ERRNO error value on error, or zero for success.
847 */ 933 */
848static int 934static int
849pci_generic_prep_mwi(struct pci_dev *dev) 935pci_set_cacheline_size(struct pci_dev *dev)
850{ 936{
851 u8 cacheline_size; 937 u8 cacheline_size;
852 938
@@ -872,7 +958,6 @@ pci_generic_prep_mwi(struct pci_dev *dev)
872 958
873 return -EINVAL; 959 return -EINVAL;
874} 960}
875#endif /* !HAVE_ARCH_PCI_MWI */
876 961
877/** 962/**
878 * pci_set_mwi - enables memory-write-invalidate PCI transaction 963 * pci_set_mwi - enables memory-write-invalidate PCI transaction
@@ -890,12 +975,7 @@ pci_set_mwi(struct pci_dev *dev)
890 int rc; 975 int rc;
891 u16 cmd; 976 u16 cmd;
892 977
893#ifdef HAVE_ARCH_PCI_MWI 978 rc = pci_set_cacheline_size(dev);
894 rc = pcibios_prep_mwi(dev);
895#else
896 rc = pci_generic_prep_mwi(dev);
897#endif
898
899 if (rc) 979 if (rc)
900 return rc; 980 return rc;
901 981
@@ -926,6 +1006,7 @@ pci_clear_mwi(struct pci_dev *dev)
926 pci_write_config_word(dev, PCI_COMMAND, cmd); 1006 pci_write_config_word(dev, PCI_COMMAND, cmd);
927 } 1007 }
928} 1008}
1009#endif /* ! PCI_DISABLE_MWI */
929 1010
930/** 1011/**
931 * pci_intx - enables/disables PCI INTx for device dev 1012 * pci_intx - enables/disables PCI INTx for device dev
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 6bf327db5c5e..398852f526a6 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -1,5 +1,6 @@
1/* Functions internal to the PCI core code */ 1/* Functions internal to the PCI core code */
2 2
3extern int __must_check __pci_enable_device(struct pci_dev *);
3extern int pci_uevent(struct device *dev, char **envp, int num_envp, 4extern int pci_uevent(struct device *dev, char **envp, int num_envp,
4 char *buffer, int buffer_size); 5 char *buffer, int buffer_size);
5extern int pci_create_sysfs_dev_files(struct pci_dev *pdev); 6extern int pci_create_sysfs_dev_files(struct pci_dev *pdev);
diff --git a/drivers/pci/pcie/aer/aerdrv.c b/drivers/pci/pcie/aer/aerdrv.c
index 04c43ef529ac..55866b6b26fa 100644
--- a/drivers/pci/pcie/aer/aerdrv.c
+++ b/drivers/pci/pcie/aer/aerdrv.c
@@ -160,7 +160,7 @@ static struct aer_rpc* aer_alloc_rpc(struct pcie_device *dev)
160 rpc->e_lock = SPIN_LOCK_UNLOCKED; 160 rpc->e_lock = SPIN_LOCK_UNLOCKED;
161 161
162 rpc->rpd = dev; 162 rpc->rpd = dev;
163 INIT_WORK(&rpc->dpc_handler, aer_isr, (void *)dev); 163 INIT_WORK(&rpc->dpc_handler, aer_isr);
164 rpc->prod_idx = rpc->cons_idx = 0; 164 rpc->prod_idx = rpc->cons_idx = 0;
165 mutex_init(&rpc->rpc_mutex); 165 mutex_init(&rpc->rpc_mutex);
166 init_waitqueue_head(&rpc->wait_release); 166 init_waitqueue_head(&rpc->wait_release);
diff --git a/drivers/pci/pcie/aer/aerdrv.h b/drivers/pci/pcie/aer/aerdrv.h
index daf0cad88fc8..3c0a58f64dd8 100644
--- a/drivers/pci/pcie/aer/aerdrv.h
+++ b/drivers/pci/pcie/aer/aerdrv.h
@@ -118,7 +118,7 @@ extern struct bus_type pcie_port_bus_type;
118extern void aer_enable_rootport(struct aer_rpc *rpc); 118extern void aer_enable_rootport(struct aer_rpc *rpc);
119extern void aer_delete_rootport(struct aer_rpc *rpc); 119extern void aer_delete_rootport(struct aer_rpc *rpc);
120extern int aer_init(struct pcie_device *dev); 120extern int aer_init(struct pcie_device *dev);
121extern void aer_isr(void *context); 121extern void aer_isr(struct work_struct *work);
122extern void aer_print_error(struct pci_dev *dev, struct aer_err_info *info); 122extern void aer_print_error(struct pci_dev *dev, struct aer_err_info *info);
123extern int aer_osc_setup(struct pci_dev *dev); 123extern int aer_osc_setup(struct pci_dev *dev);
124 124
diff --git a/drivers/pci/pcie/aer/aerdrv_core.c b/drivers/pci/pcie/aer/aerdrv_core.c
index 1c7e660d6535..08e13033ced8 100644
--- a/drivers/pci/pcie/aer/aerdrv_core.c
+++ b/drivers/pci/pcie/aer/aerdrv_core.c
@@ -690,14 +690,14 @@ static void aer_isr_one_error(struct pcie_device *p_device,
690 690
691/** 691/**
692 * aer_isr - consume errors detected by root port 692 * aer_isr - consume errors detected by root port
693 * @context: pointer to a private data of pcie device 693 * @work: definition of this work item
694 * 694 *
695 * Invoked, as DPC, when root port records new detected error 695 * Invoked, as DPC, when root port records new detected error
696 **/ 696 **/
697void aer_isr(void *context) 697void aer_isr(struct work_struct *work)
698{ 698{
699 struct pcie_device *p_device = (struct pcie_device *) context; 699 struct aer_rpc *rpc = container_of(work, struct aer_rpc, dpc_handler);
700 struct aer_rpc *rpc = get_service_data(p_device); 700 struct pcie_device *p_device = rpc->rpd;
701 struct aer_err_source *e_src; 701 struct aer_err_source *e_src;
702 702
703 mutex_lock(&rpc->rpc_mutex); 703 mutex_lock(&rpc->rpc_mutex);
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index e159d6604494..6a3c1e728900 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -679,6 +679,33 @@ static int pci_setup_device(struct pci_dev * dev)
679 pci_read_bases(dev, 6, PCI_ROM_ADDRESS); 679 pci_read_bases(dev, 6, PCI_ROM_ADDRESS);
680 pci_read_config_word(dev, PCI_SUBSYSTEM_VENDOR_ID, &dev->subsystem_vendor); 680 pci_read_config_word(dev, PCI_SUBSYSTEM_VENDOR_ID, &dev->subsystem_vendor);
681 pci_read_config_word(dev, PCI_SUBSYSTEM_ID, &dev->subsystem_device); 681 pci_read_config_word(dev, PCI_SUBSYSTEM_ID, &dev->subsystem_device);
682
683 /*
684 * Do the ugly legacy mode stuff here rather than broken chip
685 * quirk code. Legacy mode ATA controllers have fixed
686 * addresses. These are not always echoed in BAR0-3, and
687 * BAR0-3 in a few cases contain junk!
688 */
689 if (class == PCI_CLASS_STORAGE_IDE) {
690 u8 progif;
691 pci_read_config_byte(dev, PCI_CLASS_PROG, &progif);
692 if ((progif & 1) == 0) {
693 dev->resource[0].start = 0x1F0;
694 dev->resource[0].end = 0x1F7;
695 dev->resource[0].flags = IORESOURCE_IO;
696 dev->resource[1].start = 0x3F6;
697 dev->resource[1].end = 0x3F6;
698 dev->resource[1].flags = IORESOURCE_IO;
699 }
700 if ((progif & 4) == 0) {
701 dev->resource[2].start = 0x170;
702 dev->resource[2].end = 0x177;
703 dev->resource[2].flags = IORESOURCE_IO;
704 dev->resource[3].start = 0x376;
705 dev->resource[3].end = 0x376;
706 dev->resource[3].flags = IORESOURCE_IO;
707 }
708 }
682 break; 709 break;
683 710
684 case PCI_HEADER_TYPE_BRIDGE: /* bridge header */ 711 case PCI_HEADER_TYPE_BRIDGE: /* bridge header */
@@ -846,6 +873,7 @@ void __devinit pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
846 dev->dev.release = pci_release_dev; 873 dev->dev.release = pci_release_dev;
847 pci_dev_get(dev); 874 pci_dev_get(dev);
848 875
876 set_dev_node(&dev->dev, pcibus_to_node(bus));
849 dev->dev.dma_mask = &dev->dma_mask; 877 dev->dev.dma_mask = &dev->dma_mask;
850 dev->dev.coherent_dma_mask = 0xffffffffull; 878 dev->dev.coherent_dma_mask = 0xffffffffull;
851 879
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 204b1c8e972b..9ca9b9bf6160 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -797,56 +797,6 @@ static void __init quirk_mediagx_master(struct pci_dev *dev)
797DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CYRIX, PCI_DEVICE_ID_CYRIX_PCI_MASTER, quirk_mediagx_master ); 797DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CYRIX, PCI_DEVICE_ID_CYRIX_PCI_MASTER, quirk_mediagx_master );
798 798
799/* 799/*
800 * As per PCI spec, ignore base address registers 0-3 of the IDE controllers
801 * running in Compatible mode (bits 0 and 2 in the ProgIf for primary and
802 * secondary channels respectively). If the device reports Compatible mode
803 * but does use BAR0-3 for address decoding, we assume that firmware has
804 * programmed these BARs with standard values (0x1f0,0x3f4 and 0x170,0x374).
805 * Exceptions (if they exist) must be handled in chip/architecture specific
806 * fixups.
807 *
808 * Note: for non x86 people. You may need an arch specific quirk to handle
809 * moving IDE devices to native mode as well. Some plug in card devices power
810 * up in compatible mode and assume the BIOS will adjust them.
811 *
812 * Q: should we load the 0x1f0,0x3f4 into the registers or zap them as
813 * we do now ? We don't want is pci_enable_device to come along
814 * and assign new resources. Both approaches work for that.
815 */
816static void __devinit quirk_ide_bases(struct pci_dev *dev)
817{
818 struct resource *res;
819 int first_bar = 2, last_bar = 0;
820
821 if ((dev->class >> 8) != PCI_CLASS_STORAGE_IDE)
822 return;
823
824 res = &dev->resource[0];
825
826 /* primary channel: ProgIf bit 0, BAR0, BAR1 */
827 if (!(dev->class & 1) && (res[0].flags || res[1].flags)) {
828 res[0].start = res[0].end = res[0].flags = 0;
829 res[1].start = res[1].end = res[1].flags = 0;
830 first_bar = 0;
831 last_bar = 1;
832 }
833
834 /* secondary channel: ProgIf bit 2, BAR2, BAR3 */
835 if (!(dev->class & 4) && (res[2].flags || res[3].flags)) {
836 res[2].start = res[2].end = res[2].flags = 0;
837 res[3].start = res[3].end = res[3].flags = 0;
838 last_bar = 3;
839 }
840
841 if (!last_bar)
842 return;
843
844 printk(KERN_INFO "PCI: Ignoring BAR%d-%d of IDE controller %s\n",
845 first_bar, last_bar, pci_name(dev));
846}
847DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, quirk_ide_bases);
848
849/*
850 * Ensure C0 rev restreaming is off. This is normally done by 800 * Ensure C0 rev restreaming is off. This is normally done by
851 * the BIOS but in the odd case it is not the results are corruption 801 * the BIOS but in the odd case it is not the results are corruption
852 * hence the presence of a Linux check 802 * hence the presence of a Linux check
@@ -880,11 +830,10 @@ static void __devinit quirk_svwks_csb5ide(struct pci_dev *pdev)
880 prog &= ~5; 830 prog &= ~5;
881 pdev->class &= ~5; 831 pdev->class &= ~5;
882 pci_write_config_byte(pdev, PCI_CLASS_PROG, prog); 832 pci_write_config_byte(pdev, PCI_CLASS_PROG, prog);
883 /* need to re-assign BARs for compat mode */ 833 /* PCI layer will sort out resources */
884 quirk_ide_bases(pdev);
885 } 834 }
886} 835}
887DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB5IDE, quirk_svwks_csb5ide ); 836DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB5IDE, quirk_svwks_csb5ide );
888 837
889/* 838/*
890 * Intel 82801CAM ICH3-M datasheet says IDE modes must be the same 839 * Intel 82801CAM ICH3-M datasheet says IDE modes must be the same
@@ -900,11 +849,9 @@ static void __init quirk_ide_samemode(struct pci_dev *pdev)
900 prog &= ~5; 849 prog &= ~5;
901 pdev->class &= ~5; 850 pdev->class &= ~5;
902 pci_write_config_byte(pdev, PCI_CLASS_PROG, prog); 851 pci_write_config_byte(pdev, PCI_CLASS_PROG, prog);
903 /* need to re-assign BARs for compat mode */
904 quirk_ide_bases(pdev);
905 } 852 }
906} 853}
907DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_10, quirk_ide_samemode); 854DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_10, quirk_ide_samemode);
908 855
909/* This was originally an Alpha specific thing, but it really fits here. 856/* This was originally an Alpha specific thing, but it really fits here.
910 * The i82375 PCI/EISA bridge appears as non-classified. Fix that. 857 * The i82375 PCI/EISA bridge appears as non-classified. Fix that.
@@ -1460,33 +1407,6 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x2609, quirk_intel_pcie_pm);
1460DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x260a, quirk_intel_pcie_pm); 1407DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x260a, quirk_intel_pcie_pm);
1461DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x260b, quirk_intel_pcie_pm); 1408DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x260b, quirk_intel_pcie_pm);
1462 1409
1463/*
1464 * Fixup the cardbus bridges on the IBM Dock II docking station
1465 */
1466static void __devinit quirk_ibm_dock2_cardbus(struct pci_dev *dev)
1467{
1468 u32 val;
1469
1470 /*
1471 * tie the 2 interrupt pins to INTA, and configure the
1472 * multifunction routing register to handle this.
1473 */
1474 if ((dev->subsystem_vendor == PCI_VENDOR_ID_IBM) &&
1475 (dev->subsystem_device == 0x0148)) {
1476 printk(KERN_INFO "PCI: Found IBM Dock II Cardbus Bridge "
1477 "applying quirk\n");
1478 pci_read_config_dword(dev, 0x8c, &val);
1479 val = ((val & 0xffffff00) | 0x1002);
1480 pci_write_config_dword(dev, 0x8c, val);
1481 pci_read_config_dword(dev, 0x80, &val);
1482 val = ((val & 0x00ffff00) | 0x2864c077);
1483 pci_write_config_dword(dev, 0x80, val);
1484 }
1485}
1486
1487DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1420,
1488 quirk_ibm_dock2_cardbus);
1489
1490static void __devinit quirk_netmos(struct pci_dev *dev) 1410static void __devinit quirk_netmos(struct pci_dev *dev)
1491{ 1411{
1492 unsigned int num_parallel = (dev->subsystem_device & 0xf0) >> 4; 1412 unsigned int num_parallel = (dev->subsystem_device & 0xf0) >> 4;
diff --git a/drivers/pci/rom.c b/drivers/pci/rom.c
index e1dcefc69bb4..d087e0817715 100644
--- a/drivers/pci/rom.c
+++ b/drivers/pci/rom.c
@@ -81,7 +81,8 @@ void __iomem *pci_map_rom(struct pci_dev *pdev, size_t *size)
81 start = (loff_t)0xC0000; 81 start = (loff_t)0xC0000;
82 *size = 0x20000; /* cover C000:0 through E000:0 */ 82 *size = 0x20000; /* cover C000:0 through E000:0 */
83 } else { 83 } else {
84 if (res->flags & IORESOURCE_ROM_COPY) { 84 if (res->flags &
85 (IORESOURCE_ROM_COPY | IORESOURCE_ROM_BIOS_COPY)) {
85 *size = pci_resource_len(pdev, PCI_ROM_RESOURCE); 86 *size = pci_resource_len(pdev, PCI_ROM_RESOURCE);
86 return (void __iomem *)(unsigned long) 87 return (void __iomem *)(unsigned long)
87 pci_resource_start(pdev, PCI_ROM_RESOURCE); 88 pci_resource_start(pdev, PCI_ROM_RESOURCE);
@@ -165,7 +166,8 @@ void __iomem *pci_map_rom_copy(struct pci_dev *pdev, size_t *size)
165 if (!rom) 166 if (!rom)
166 return NULL; 167 return NULL;
167 168
168 if (res->flags & (IORESOURCE_ROM_COPY | IORESOURCE_ROM_SHADOW)) 169 if (res->flags & (IORESOURCE_ROM_COPY | IORESOURCE_ROM_SHADOW |
170 IORESOURCE_ROM_BIOS_COPY))
169 return rom; 171 return rom;
170 172
171 res->start = (unsigned long)kmalloc(*size, GFP_KERNEL); 173 res->start = (unsigned long)kmalloc(*size, GFP_KERNEL);
@@ -191,7 +193,7 @@ void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom)
191{ 193{
192 struct resource *res = &pdev->resource[PCI_ROM_RESOURCE]; 194 struct resource *res = &pdev->resource[PCI_ROM_RESOURCE];
193 195
194 if (res->flags & IORESOURCE_ROM_COPY) 196 if (res->flags & (IORESOURCE_ROM_COPY | IORESOURCE_ROM_BIOS_COPY))
195 return; 197 return;
196 198
197 iounmap(rom); 199 iounmap(rom);
@@ -215,6 +217,7 @@ void pci_remove_rom(struct pci_dev *pdev)
215 sysfs_remove_bin_file(&pdev->dev.kobj, pdev->rom_attr); 217 sysfs_remove_bin_file(&pdev->dev.kobj, pdev->rom_attr);
216 if (!(res->flags & (IORESOURCE_ROM_ENABLE | 218 if (!(res->flags & (IORESOURCE_ROM_ENABLE |
217 IORESOURCE_ROM_SHADOW | 219 IORESOURCE_ROM_SHADOW |
220 IORESOURCE_ROM_BIOS_COPY |
218 IORESOURCE_ROM_COPY))) 221 IORESOURCE_ROM_COPY)))
219 pci_disable_rom(pdev); 222 pci_disable_rom(pdev);
220} 223}
diff --git a/drivers/pcmcia/at91_cf.c b/drivers/pcmcia/at91_cf.c
index 3bcb7dc32995..52d4a38b3667 100644
--- a/drivers/pcmcia/at91_cf.c
+++ b/drivers/pcmcia/at91_cf.c
@@ -23,19 +23,20 @@
23#include <asm/io.h> 23#include <asm/io.h>
24#include <asm/sizes.h> 24#include <asm/sizes.h>
25 25
26#include <asm/arch/at91rm9200.h>
27#include <asm/arch/board.h> 26#include <asm/arch/board.h>
28#include <asm/arch/gpio.h> 27#include <asm/arch/gpio.h>
28#include <asm/arch/at91rm9200_mc.h>
29 29
30 30
31/* 31/*
32 * A0..A10 work in each range; A23 indicates I/O space; A25 is CFRNW; 32 * A0..A10 work in each range; A23 indicates I/O space; A25 is CFRNW;
33 * some other bit in {A24,A22..A11} is nREG to flag memory access 33 * some other bit in {A24,A22..A11} is nREG to flag memory access
34 * (vs attributes). So more than 2KB/region would just be waste. 34 * (vs attributes). So more than 2KB/region would just be waste.
35 * Note: These are offsets from the physical base address.
35 */ 36 */
36#define CF_ATTR_PHYS (AT91_CF_BASE) 37#define CF_ATTR_PHYS (0)
37#define CF_IO_PHYS (AT91_CF_BASE + (1 << 23)) 38#define CF_IO_PHYS (1 << 23)
38#define CF_MEM_PHYS (AT91_CF_BASE + 0x017ff800) 39#define CF_MEM_PHYS (0x017ff800)
39 40
40/*--------------------------------------------------------------------------*/ 41/*--------------------------------------------------------------------------*/
41 42
@@ -48,6 +49,8 @@ struct at91_cf_socket {
48 49
49 struct platform_device *pdev; 50 struct platform_device *pdev;
50 struct at91_cf_data *board; 51 struct at91_cf_data *board;
52
53 unsigned long phys_baseaddr;
51}; 54};
52 55
53#define SZ_2K (2 * SZ_1K) 56#define SZ_2K (2 * SZ_1K)
@@ -154,9 +157,8 @@ static int at91_cf_set_io_map(struct pcmcia_socket *s, struct pccard_io_map *io)
154 157
155 /* 158 /*
156 * Use 16 bit accesses unless/until we need 8-bit i/o space. 159 * Use 16 bit accesses unless/until we need 8-bit i/o space.
157 * Always set CSR4 ... PCMCIA won't always unmap things.
158 */ 160 */
159 csr = at91_sys_read(AT91_SMC_CSR(4)) & ~AT91_SMC_DBW; 161 csr = at91_sys_read(AT91_SMC_CSR(cf->board->chipselect)) & ~AT91_SMC_DBW;
160 162
161 /* 163 /*
162 * NOTE: this CF controller ignores IOIS16, so we can't really do 164 * NOTE: this CF controller ignores IOIS16, so we can't really do
@@ -168,14 +170,14 @@ static int at91_cf_set_io_map(struct pcmcia_socket *s, struct pccard_io_map *io)
168 * some cards only like that way to get at the odd byte, despite 170 * some cards only like that way to get at the odd byte, despite
169 * CF 3.0 spec table 35 also giving the D8-D15 option. 171 * CF 3.0 spec table 35 also giving the D8-D15 option.
170 */ 172 */
171 if (!(io->flags & (MAP_16BIT|MAP_AUTOSZ))) { 173 if (!(io->flags & (MAP_16BIT | MAP_AUTOSZ))) {
172 csr |= AT91_SMC_DBW_8; 174 csr |= AT91_SMC_DBW_8;
173 pr_debug("%s: 8bit i/o bus\n", driver_name); 175 pr_debug("%s: 8bit i/o bus\n", driver_name);
174 } else { 176 } else {
175 csr |= AT91_SMC_DBW_16; 177 csr |= AT91_SMC_DBW_16;
176 pr_debug("%s: 16bit i/o bus\n", driver_name); 178 pr_debug("%s: 16bit i/o bus\n", driver_name);
177 } 179 }
178 at91_sys_write(AT91_SMC_CSR(4), csr); 180 at91_sys_write(AT91_SMC_CSR(cf->board->chipselect), csr);
179 181
180 io->start = cf->socket.io_offset; 182 io->start = cf->socket.io_offset;
181 io->stop = io->start + SZ_2K - 1; 183 io->stop = io->start + SZ_2K - 1;
@@ -194,11 +196,11 @@ at91_cf_set_mem_map(struct pcmcia_socket *s, struct pccard_mem_map *map)
194 196
195 cf = container_of(s, struct at91_cf_socket, socket); 197 cf = container_of(s, struct at91_cf_socket, socket);
196 198
197 map->flags &= MAP_ACTIVE|MAP_ATTRIB|MAP_16BIT; 199 map->flags &= (MAP_ACTIVE | MAP_ATTRIB | MAP_16BIT);
198 if (map->flags & MAP_ATTRIB) 200 if (map->flags & MAP_ATTRIB)
199 map->static_start = CF_ATTR_PHYS; 201 map->static_start = cf->phys_baseaddr + CF_ATTR_PHYS;
200 else 202 else
201 map->static_start = CF_MEM_PHYS; 203 map->static_start = cf->phys_baseaddr + CF_MEM_PHYS;
202 204
203 return 0; 205 return 0;
204} 206}
@@ -219,7 +221,6 @@ static int __init at91_cf_probe(struct platform_device *pdev)
219 struct at91_cf_socket *cf; 221 struct at91_cf_socket *cf;
220 struct at91_cf_data *board = pdev->dev.platform_data; 222 struct at91_cf_data *board = pdev->dev.platform_data;
221 struct resource *io; 223 struct resource *io;
222 unsigned int csa;
223 int status; 224 int status;
224 225
225 if (!board || !board->det_pin || !board->rst_pin) 226 if (!board || !board->det_pin || !board->rst_pin)
@@ -235,33 +236,11 @@ static int __init at91_cf_probe(struct platform_device *pdev)
235 236
236 cf->board = board; 237 cf->board = board;
237 cf->pdev = pdev; 238 cf->pdev = pdev;
239 cf->phys_baseaddr = io->start;
238 platform_set_drvdata(pdev, cf); 240 platform_set_drvdata(pdev, cf);
239 241
240 /* CF takes over CS4, CS5, CS6 */
241 csa = at91_sys_read(AT91_EBI_CSA);
242 at91_sys_write(AT91_EBI_CSA, csa | AT91_EBI_CS4A_SMC_COMPACTFLASH);
243
244 /* nWAIT is _not_ a default setting */
245 (void) at91_set_A_periph(AT91_PIN_PC6, 1); /* nWAIT */
246
247 /*
248 * Static memory controller timing adjustments.
249 * REVISIT: these timings are in terms of MCK cycles, so
250 * when MCK changes (cpufreq etc) so must these values...
251 */
252 at91_sys_write(AT91_SMC_CSR(4),
253 AT91_SMC_ACSS_STD
254 | AT91_SMC_DBW_16
255 | AT91_SMC_BAT
256 | AT91_SMC_WSEN
257 | AT91_SMC_NWS_(32) /* wait states */
258 | AT91_SMC_RWSETUP_(6) /* setup time */
259 | AT91_SMC_RWHOLD_(4) /* hold time */
260 );
261
262 /* must be a GPIO; ergo must trigger on both edges */ 242 /* must be a GPIO; ergo must trigger on both edges */
263 status = request_irq(board->det_pin, at91_cf_irq, 243 status = request_irq(board->det_pin, at91_cf_irq, 0, driver_name, cf);
264 IRQF_SAMPLE_RANDOM, driver_name, cf);
265 if (status < 0) 244 if (status < 0)
266 goto fail0; 245 goto fail0;
267 device_init_wakeup(&pdev->dev, 1); 246 device_init_wakeup(&pdev->dev, 1);
@@ -282,14 +261,18 @@ static int __init at91_cf_probe(struct platform_device *pdev)
282 cf->socket.pci_irq = NR_IRQS + 1; 261 cf->socket.pci_irq = NR_IRQS + 1;
283 262
284 /* pcmcia layer only remaps "real" memory not iospace */ 263 /* pcmcia layer only remaps "real" memory not iospace */
285 cf->socket.io_offset = (unsigned long) ioremap(CF_IO_PHYS, SZ_2K); 264 cf->socket.io_offset = (unsigned long) ioremap(cf->phys_baseaddr + CF_IO_PHYS, SZ_2K);
286 if (!cf->socket.io_offset) 265 if (!cf->socket.io_offset) {
266 status = -ENXIO;
287 goto fail1; 267 goto fail1;
268 }
288 269
289 /* reserve CS4, CS5, and CS6 regions; but use just CS4 */ 270 /* reserve chip-select regions */
290 if (!request_mem_region(io->start, io->end + 1 - io->start, 271 if (!request_mem_region(io->start, io->end + 1 - io->start,
291 driver_name)) 272 driver_name)) {
273 status = -ENXIO;
292 goto fail1; 274 goto fail1;
275 }
293 276
294 pr_info("%s: irqs det #%d, io #%d\n", driver_name, 277 pr_info("%s: irqs det #%d, io #%d\n", driver_name,
295 board->det_pin, board->irq_pin); 278 board->det_pin, board->irq_pin);
@@ -319,9 +302,7 @@ fail1:
319fail0a: 302fail0a:
320 device_init_wakeup(&pdev->dev, 0); 303 device_init_wakeup(&pdev->dev, 0);
321 free_irq(board->det_pin, cf); 304 free_irq(board->det_pin, cf);
322 device_init_wakeup(&pdev->dev, 0);
323fail0: 305fail0:
324 at91_sys_write(AT91_EBI_CSA, csa);
325 kfree(cf); 306 kfree(cf);
326 return status; 307 return status;
327} 308}
@@ -331,19 +312,15 @@ static int __exit at91_cf_remove(struct platform_device *pdev)
331 struct at91_cf_socket *cf = platform_get_drvdata(pdev); 312 struct at91_cf_socket *cf = platform_get_drvdata(pdev);
332 struct at91_cf_data *board = cf->board; 313 struct at91_cf_data *board = cf->board;
333 struct resource *io = cf->socket.io[0].res; 314 struct resource *io = cf->socket.io[0].res;
334 unsigned int csa;
335 315
336 pcmcia_unregister_socket(&cf->socket); 316 pcmcia_unregister_socket(&cf->socket);
337 if (board->irq_pin) 317 if (board->irq_pin)
338 free_irq(board->irq_pin, cf); 318 free_irq(board->irq_pin, cf);
339 free_irq(board->det_pin, cf);
340 device_init_wakeup(&pdev->dev, 0); 319 device_init_wakeup(&pdev->dev, 0);
320 free_irq(board->det_pin, cf);
341 iounmap((void __iomem *) cf->socket.io_offset); 321 iounmap((void __iomem *) cf->socket.io_offset);
342 release_mem_region(io->start, io->end + 1 - io->start); 322 release_mem_region(io->start, io->end + 1 - io->start);
343 323
344 csa = at91_sys_read(AT91_EBI_CSA);
345 at91_sys_write(AT91_EBI_CSA, csa & ~AT91_EBI_CS4A);
346
347 kfree(cf); 324 kfree(cf);
348 return 0; 325 return 0;
349} 326}
diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
index f9cd831a3f31..606a46740338 100644
--- a/drivers/pcmcia/cs.c
+++ b/drivers/pcmcia/cs.c
@@ -29,6 +29,7 @@
29#include <linux/pci.h> 29#include <linux/pci.h>
30#include <linux/device.h> 30#include <linux/device.h>
31#include <linux/kthread.h> 31#include <linux/kthread.h>
32#include <linux/freezer.h>
32#include <asm/system.h> 33#include <asm/system.h>
33#include <asm/irq.h> 34#include <asm/irq.h>
34 35
diff --git a/drivers/pcmcia/cs_internal.h b/drivers/pcmcia/cs_internal.h
index d6164cd583fd..f573ea04db6f 100644
--- a/drivers/pcmcia/cs_internal.h
+++ b/drivers/pcmcia/cs_internal.h
@@ -135,7 +135,7 @@ int pccard_get_status(struct pcmcia_socket *s, struct pcmcia_device *p_dev, cs_s
135struct pcmcia_callback{ 135struct pcmcia_callback{
136 struct module *owner; 136 struct module *owner;
137 int (*event) (struct pcmcia_socket *s, event_t event, int priority); 137 int (*event) (struct pcmcia_socket *s, event_t event, int priority);
138 void (*requery) (struct pcmcia_socket *s); 138 void (*requery) (struct pcmcia_socket *s, int new_cis);
139 int (*suspend) (struct pcmcia_socket *s); 139 int (*suspend) (struct pcmcia_socket *s);
140 int (*resume) (struct pcmcia_socket *s); 140 int (*resume) (struct pcmcia_socket *s);
141}; 141};
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index 0f701921c13e..7355eb455a88 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -231,65 +231,6 @@ static void pcmcia_check_driver(struct pcmcia_driver *p_drv)
231} 231}
232 232
233 233
234#ifdef CONFIG_PCMCIA_LOAD_CIS
235
236/**
237 * pcmcia_load_firmware - load CIS from userspace if device-provided is broken
238 * @dev - the pcmcia device which needs a CIS override
239 * @filename - requested filename in /lib/firmware/
240 *
241 * This uses the in-kernel firmware loading mechanism to use a "fake CIS" if
242 * the one provided by the card is broken. The firmware files reside in
243 * /lib/firmware/ in userspace.
244 */
245static int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename)
246{
247 struct pcmcia_socket *s = dev->socket;
248 const struct firmware *fw;
249 char path[20];
250 int ret=-ENOMEM;
251 cisdump_t *cis;
252
253 if (!filename)
254 return -EINVAL;
255
256 ds_dbg(1, "trying to load firmware %s\n", filename);
257
258 if (strlen(filename) > 14)
259 return -EINVAL;
260
261 snprintf(path, 20, "%s", filename);
262
263 if (request_firmware(&fw, path, &dev->dev) == 0) {
264 if (fw->size >= CISTPL_MAX_CIS_SIZE)
265 goto release;
266
267 cis = kzalloc(sizeof(cisdump_t), GFP_KERNEL);
268 if (!cis)
269 goto release;
270
271 cis->Length = fw->size + 1;
272 memcpy(cis->Data, fw->data, fw->size);
273
274 if (!pcmcia_replace_cis(s, cis))
275 ret = 0;
276 }
277 release:
278 release_firmware(fw);
279
280 return (ret);
281}
282
283#else /* !CONFIG_PCMCIA_LOAD_CIS */
284
285static inline int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename)
286{
287 return -ENODEV;
288}
289
290#endif
291
292
293/*======================================================================*/ 234/*======================================================================*/
294 235
295 236
@@ -309,6 +250,8 @@ int pcmcia_register_driver(struct pcmcia_driver *driver)
309 driver->drv.bus = &pcmcia_bus_type; 250 driver->drv.bus = &pcmcia_bus_type;
310 driver->drv.owner = driver->owner; 251 driver->drv.owner = driver->owner;
311 252
253 ds_dbg(3, "registering driver %s\n", driver->drv.name);
254
312 return driver_register(&driver->drv); 255 return driver_register(&driver->drv);
313} 256}
314EXPORT_SYMBOL(pcmcia_register_driver); 257EXPORT_SYMBOL(pcmcia_register_driver);
@@ -318,6 +261,7 @@ EXPORT_SYMBOL(pcmcia_register_driver);
318 */ 261 */
319void pcmcia_unregister_driver(struct pcmcia_driver *driver) 262void pcmcia_unregister_driver(struct pcmcia_driver *driver)
320{ 263{
264 ds_dbg(3, "unregistering driver %s\n", driver->drv.name);
321 driver_unregister(&driver->drv); 265 driver_unregister(&driver->drv);
322} 266}
323EXPORT_SYMBOL(pcmcia_unregister_driver); 267EXPORT_SYMBOL(pcmcia_unregister_driver);
@@ -343,23 +287,27 @@ void pcmcia_put_dev(struct pcmcia_device *p_dev)
343static void pcmcia_release_function(struct kref *ref) 287static void pcmcia_release_function(struct kref *ref)
344{ 288{
345 struct config_t *c = container_of(ref, struct config_t, ref); 289 struct config_t *c = container_of(ref, struct config_t, ref);
290 ds_dbg(1, "releasing config_t\n");
346 kfree(c); 291 kfree(c);
347} 292}
348 293
349static void pcmcia_release_dev(struct device *dev) 294static void pcmcia_release_dev(struct device *dev)
350{ 295{
351 struct pcmcia_device *p_dev = to_pcmcia_dev(dev); 296 struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
352 ds_dbg(1, "releasing dev %p\n", p_dev); 297 ds_dbg(1, "releasing device %s\n", p_dev->dev.bus_id);
353 pcmcia_put_socket(p_dev->socket); 298 pcmcia_put_socket(p_dev->socket);
354 kfree(p_dev->devname); 299 kfree(p_dev->devname);
355 kref_put(&p_dev->function_config->ref, pcmcia_release_function); 300 kref_put(&p_dev->function_config->ref, pcmcia_release_function);
356 kfree(p_dev); 301 kfree(p_dev);
357} 302}
358 303
359static void pcmcia_add_pseudo_device(struct pcmcia_socket *s) 304static void pcmcia_add_device_later(struct pcmcia_socket *s, int mfc)
360{ 305{
361 if (!s->pcmcia_state.device_add_pending) { 306 if (!s->pcmcia_state.device_add_pending) {
307 ds_dbg(1, "scheduling to add %s secondary"
308 " device to %d\n", mfc ? "mfc" : "pfc", s->sock);
362 s->pcmcia_state.device_add_pending = 1; 309 s->pcmcia_state.device_add_pending = 1;
310 s->pcmcia_state.mfc_pfc = mfc;
363 schedule_work(&s->device_add); 311 schedule_work(&s->device_add);
364 } 312 }
365 return; 313 return;
@@ -371,6 +319,7 @@ static int pcmcia_device_probe(struct device * dev)
371 struct pcmcia_driver *p_drv; 319 struct pcmcia_driver *p_drv;
372 struct pcmcia_device_id *did; 320 struct pcmcia_device_id *did;
373 struct pcmcia_socket *s; 321 struct pcmcia_socket *s;
322 cistpl_config_t cis_config;
374 int ret = 0; 323 int ret = 0;
375 324
376 dev = get_device(dev); 325 dev = get_device(dev);
@@ -381,15 +330,33 @@ static int pcmcia_device_probe(struct device * dev)
381 p_drv = to_pcmcia_drv(dev->driver); 330 p_drv = to_pcmcia_drv(dev->driver);
382 s = p_dev->socket; 331 s = p_dev->socket;
383 332
333 ds_dbg(1, "trying to bind %s to %s\n", p_dev->dev.bus_id,
334 p_drv->drv.name);
335
384 if ((!p_drv->probe) || (!p_dev->function_config) || 336 if ((!p_drv->probe) || (!p_dev->function_config) ||
385 (!try_module_get(p_drv->owner))) { 337 (!try_module_get(p_drv->owner))) {
386 ret = -EINVAL; 338 ret = -EINVAL;
387 goto put_dev; 339 goto put_dev;
388 } 340 }
389 341
342 /* set up some more device information */
343 ret = pccard_read_tuple(p_dev->socket, p_dev->func, CISTPL_CONFIG,
344 &cis_config);
345 if (!ret) {
346 p_dev->conf.ConfigBase = cis_config.base;
347 p_dev->conf.Present = cis_config.rmask[0];
348 } else {
349 printk(KERN_INFO "pcmcia: could not parse base and rmask0 of CIS\n");
350 p_dev->conf.ConfigBase = 0;
351 p_dev->conf.Present = 0;
352 }
353
390 ret = p_drv->probe(p_dev); 354 ret = p_drv->probe(p_dev);
391 if (ret) 355 if (ret) {
356 ds_dbg(1, "binding %s to %s failed with %d\n",
357 p_dev->dev.bus_id, p_drv->drv.name, ret);
392 goto put_module; 358 goto put_module;
359 }
393 360
394 /* handle pseudo multifunction devices: 361 /* handle pseudo multifunction devices:
395 * there are at most two pseudo multifunction devices. 362 * there are at most two pseudo multifunction devices.
@@ -400,7 +367,7 @@ static int pcmcia_device_probe(struct device * dev)
400 did = p_dev->dev.driver_data; 367 did = p_dev->dev.driver_data;
401 if (did && (did->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO) && 368 if (did && (did->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO) &&
402 (p_dev->socket->device_count == 1) && (p_dev->device_no == 0)) 369 (p_dev->socket->device_count == 1) && (p_dev->device_no == 0))
403 pcmcia_add_pseudo_device(p_dev->socket); 370 pcmcia_add_device_later(p_dev->socket, 0);
404 371
405 put_module: 372 put_module:
406 if (ret) 373 if (ret)
@@ -421,8 +388,8 @@ static void pcmcia_card_remove(struct pcmcia_socket *s, struct pcmcia_device *le
421 struct pcmcia_device *tmp; 388 struct pcmcia_device *tmp;
422 unsigned long flags; 389 unsigned long flags;
423 390
424 ds_dbg(2, "unbind_request(%d)\n", s->sock); 391 ds_dbg(2, "pcmcia_card_remove(%d) %s\n", s->sock,
425 392 leftover ? leftover->devname : "");
426 393
427 if (!leftover) 394 if (!leftover)
428 s->device_count = 0; 395 s->device_count = 0;
@@ -439,6 +406,7 @@ static void pcmcia_card_remove(struct pcmcia_socket *s, struct pcmcia_device *le
439 p_dev->_removed=1; 406 p_dev->_removed=1;
440 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); 407 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);
441 408
409 ds_dbg(2, "unregistering device %s\n", p_dev->dev.bus_id);
442 device_unregister(&p_dev->dev); 410 device_unregister(&p_dev->dev);
443 } 411 }
444 412
@@ -455,6 +423,8 @@ static int pcmcia_device_remove(struct device * dev)
455 p_dev = to_pcmcia_dev(dev); 423 p_dev = to_pcmcia_dev(dev);
456 p_drv = to_pcmcia_drv(dev->driver); 424 p_drv = to_pcmcia_drv(dev->driver);
457 425
426 ds_dbg(1, "removing device %s\n", p_dev->dev.bus_id);
427
458 /* If we're removing the primary module driving a 428 /* If we're removing the primary module driving a
459 * pseudo multi-function card, we need to unbind 429 * pseudo multi-function card, we need to unbind
460 * all devices 430 * all devices
@@ -587,8 +557,10 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f
587 557
588 mutex_lock(&device_add_lock); 558 mutex_lock(&device_add_lock);
589 559
590 /* max of 2 devices per card */ 560 ds_dbg(3, "adding device to %d, function %d\n", s->sock, function);
591 if (s->device_count == 2) 561
562 /* max of 4 devices per card */
563 if (s->device_count == 4)
592 goto err_put; 564 goto err_put;
593 565
594 p_dev = kzalloc(sizeof(struct pcmcia_device), GFP_KERNEL); 566 p_dev = kzalloc(sizeof(struct pcmcia_device), GFP_KERNEL);
@@ -598,8 +570,6 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f
598 p_dev->socket = s; 570 p_dev->socket = s;
599 p_dev->device_no = (s->device_count++); 571 p_dev->device_no = (s->device_count++);
600 p_dev->func = function; 572 p_dev->func = function;
601 if (s->functions <= function)
602 s->functions = function + 1;
603 573
604 p_dev->dev.bus = &pcmcia_bus_type; 574 p_dev->dev.bus = &pcmcia_bus_type;
605 p_dev->dev.parent = s->dev.dev; 575 p_dev->dev.parent = s->dev.dev;
@@ -610,8 +580,8 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f
610 if (!p_dev->devname) 580 if (!p_dev->devname)
611 goto err_free; 581 goto err_free;
612 sprintf (p_dev->devname, "pcmcia%s", p_dev->dev.bus_id); 582 sprintf (p_dev->devname, "pcmcia%s", p_dev->dev.bus_id);
583 ds_dbg(3, "devname is %s\n", p_dev->devname);
613 584
614 /* compat */
615 spin_lock_irqsave(&pcmcia_dev_list_lock, flags); 585 spin_lock_irqsave(&pcmcia_dev_list_lock, flags);
616 586
617 /* 587 /*
@@ -631,6 +601,7 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f
631 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); 601 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);
632 602
633 if (!p_dev->function_config) { 603 if (!p_dev->function_config) {
604 ds_dbg(3, "creating config_t for %s\n", p_dev->dev.bus_id);
634 p_dev->function_config = kzalloc(sizeof(struct config_t), 605 p_dev->function_config = kzalloc(sizeof(struct config_t),
635 GFP_KERNEL); 606 GFP_KERNEL);
636 if (!p_dev->function_config) 607 if (!p_dev->function_config)
@@ -674,11 +645,16 @@ static int pcmcia_card_add(struct pcmcia_socket *s)
674 unsigned int no_funcs, i; 645 unsigned int no_funcs, i;
675 int ret = 0; 646 int ret = 0;
676 647
677 if (!(s->resource_setup_done)) 648 if (!(s->resource_setup_done)) {
649 ds_dbg(3, "no resources available, delaying card_add\n");
678 return -EAGAIN; /* try again, but later... */ 650 return -EAGAIN; /* try again, but later... */
651 }
679 652
680 if (pcmcia_validate_mem(s)) 653 if (pcmcia_validate_mem(s)) {
654 ds_dbg(3, "validating mem resources failed, "
655 "delaying card_add\n");
681 return -EAGAIN; /* try again, but later... */ 656 return -EAGAIN; /* try again, but later... */
657 }
682 658
683 ret = pccard_validate_cis(s, BIND_FN_ALL, &cisinfo); 659 ret = pccard_validate_cis(s, BIND_FN_ALL, &cisinfo);
684 if (ret || !cisinfo.Chains) { 660 if (ret || !cisinfo.Chains) {
@@ -690,6 +666,7 @@ static int pcmcia_card_add(struct pcmcia_socket *s)
690 no_funcs = mfc.nfn; 666 no_funcs = mfc.nfn;
691 else 667 else
692 no_funcs = 1; 668 no_funcs = 1;
669 s->functions = no_funcs;
693 670
694 for (i=0; i < no_funcs; i++) 671 for (i=0; i < no_funcs; i++)
695 pcmcia_device_add(s, i); 672 pcmcia_device_add(s, i);
@@ -698,38 +675,50 @@ static int pcmcia_card_add(struct pcmcia_socket *s)
698} 675}
699 676
700 677
701static void pcmcia_delayed_add_pseudo_device(void *data) 678static void pcmcia_delayed_add_device(struct work_struct *work)
702{ 679{
703 struct pcmcia_socket *s = data; 680 struct pcmcia_socket *s =
704 pcmcia_device_add(s, 0); 681 container_of(work, struct pcmcia_socket, device_add);
682 ds_dbg(1, "adding additional device to %d\n", s->sock);
683 pcmcia_device_add(s, s->pcmcia_state.mfc_pfc);
705 s->pcmcia_state.device_add_pending = 0; 684 s->pcmcia_state.device_add_pending = 0;
685 s->pcmcia_state.mfc_pfc = 0;
706} 686}
707 687
708static int pcmcia_requery(struct device *dev, void * _data) 688static int pcmcia_requery(struct device *dev, void * _data)
709{ 689{
710 struct pcmcia_device *p_dev = to_pcmcia_dev(dev); 690 struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
711 if (!p_dev->dev.driver) 691 if (!p_dev->dev.driver) {
692 ds_dbg(1, "update device information for %s\n",
693 p_dev->dev.bus_id);
712 pcmcia_device_query(p_dev); 694 pcmcia_device_query(p_dev);
695 }
713 696
714 return 0; 697 return 0;
715} 698}
716 699
717static void pcmcia_bus_rescan(struct pcmcia_socket *skt) 700static void pcmcia_bus_rescan(struct pcmcia_socket *skt, int new_cis)
718{ 701{
719 int no_devices=0; 702 int no_devices = 0;
720 int ret = 0; 703 int ret = 0;
721 unsigned long flags; 704 unsigned long flags;
722 705
723 /* must be called with skt_mutex held */ 706 /* must be called with skt_mutex held */
707 ds_dbg(0, "re-scanning socket %d\n", skt->sock);
708
724 spin_lock_irqsave(&pcmcia_dev_list_lock, flags); 709 spin_lock_irqsave(&pcmcia_dev_list_lock, flags);
725 if (list_empty(&skt->devices_list)) 710 if (list_empty(&skt->devices_list))
726 no_devices=1; 711 no_devices = 1;
727 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); 712 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);
728 713
714 /* If this is because of a CIS override, start over */
715 if (new_cis && !no_devices)
716 pcmcia_card_remove(skt, NULL);
717
729 /* if no devices were added for this socket yet because of 718 /* if no devices were added for this socket yet because of
730 * missing resource information or other trouble, we need to 719 * missing resource information or other trouble, we need to
731 * do this now. */ 720 * do this now. */
732 if (no_devices) { 721 if (no_devices || new_cis) {
733 ret = pcmcia_card_add(skt); 722 ret = pcmcia_card_add(skt);
734 if (ret) 723 if (ret)
735 return; 724 return;
@@ -747,6 +736,97 @@ static void pcmcia_bus_rescan(struct pcmcia_socket *skt)
747 printk(KERN_INFO "pcmcia: bus_rescan_devices failed\n"); 736 printk(KERN_INFO "pcmcia: bus_rescan_devices failed\n");
748} 737}
749 738
739#ifdef CONFIG_PCMCIA_LOAD_CIS
740
741/**
742 * pcmcia_load_firmware - load CIS from userspace if device-provided is broken
743 * @dev - the pcmcia device which needs a CIS override
744 * @filename - requested filename in /lib/firmware/
745 *
746 * This uses the in-kernel firmware loading mechanism to use a "fake CIS" if
747 * the one provided by the card is broken. The firmware files reside in
748 * /lib/firmware/ in userspace.
749 */
750static int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename)
751{
752 struct pcmcia_socket *s = dev->socket;
753 const struct firmware *fw;
754 char path[20];
755 int ret = -ENOMEM;
756 int no_funcs;
757 int old_funcs;
758 cisdump_t *cis;
759 cistpl_longlink_mfc_t mfc;
760
761 if (!filename)
762 return -EINVAL;
763
764 ds_dbg(1, "trying to load CIS file %s\n", filename);
765
766 if (strlen(filename) > 14) {
767 printk(KERN_WARNING "pcmcia: CIS filename is too long\n");
768 return -EINVAL;
769 }
770
771 snprintf(path, 20, "%s", filename);
772
773 if (request_firmware(&fw, path, &dev->dev) == 0) {
774 if (fw->size >= CISTPL_MAX_CIS_SIZE) {
775 ret = -EINVAL;
776 printk(KERN_ERR "pcmcia: CIS override is too big\n");
777 goto release;
778 }
779
780 cis = kzalloc(sizeof(cisdump_t), GFP_KERNEL);
781 if (!cis) {
782 ret = -ENOMEM;
783 goto release;
784 }
785
786 cis->Length = fw->size + 1;
787 memcpy(cis->Data, fw->data, fw->size);
788
789 if (!pcmcia_replace_cis(s, cis))
790 ret = 0;
791 else {
792 printk(KERN_ERR "pcmcia: CIS override failed\n");
793 goto release;
794 }
795
796
797 /* update information */
798 pcmcia_device_query(dev);
799
800 /* does this cis override add or remove functions? */
801 old_funcs = s->functions;
802
803 if (!pccard_read_tuple(s, BIND_FN_ALL, CISTPL_LONGLINK_MFC, &mfc))
804 no_funcs = mfc.nfn;
805 else
806 no_funcs = 1;
807 s->functions = no_funcs;
808
809 if (old_funcs > no_funcs)
810 pcmcia_card_remove(s, dev);
811 else if (no_funcs > old_funcs)
812 pcmcia_add_device_later(s, 1);
813 }
814 release:
815 release_firmware(fw);
816
817 return (ret);
818}
819
820#else /* !CONFIG_PCMCIA_LOAD_CIS */
821
822static inline int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename)
823{
824 return -ENODEV;
825}
826
827#endif
828
829
750static inline int pcmcia_devmatch(struct pcmcia_device *dev, 830static inline int pcmcia_devmatch(struct pcmcia_device *dev,
751 struct pcmcia_device_id *did) 831 struct pcmcia_device_id *did)
752{ 832{
@@ -813,11 +893,14 @@ static inline int pcmcia_devmatch(struct pcmcia_device *dev,
813 * after it has re-checked that there is no possible module 893 * after it has re-checked that there is no possible module
814 * with a prod_id/manf_id/card_id match. 894 * with a prod_id/manf_id/card_id match.
815 */ 895 */
896 ds_dbg(0, "skipping FUNC_ID match for %s until userspace "
897 "interaction\n", dev->dev.bus_id);
816 if (!dev->allow_func_id_match) 898 if (!dev->allow_func_id_match)
817 return 0; 899 return 0;
818 } 900 }
819 901
820 if (did->match_flags & PCMCIA_DEV_ID_MATCH_FAKE_CIS) { 902 if (did->match_flags & PCMCIA_DEV_ID_MATCH_FAKE_CIS) {
903 ds_dbg(0, "device %s needs a fake CIS\n", dev->dev.bus_id);
821 if (!dev->socket->fake_cis) 904 if (!dev->socket->fake_cis)
822 pcmcia_load_firmware(dev, did->cisfile); 905 pcmcia_load_firmware(dev, did->cisfile);
823 906
@@ -847,13 +930,21 @@ static int pcmcia_bus_match(struct device * dev, struct device_driver * drv) {
847 930
848#ifdef CONFIG_PCMCIA_IOCTL 931#ifdef CONFIG_PCMCIA_IOCTL
849 /* matching by cardmgr */ 932 /* matching by cardmgr */
850 if (p_dev->cardmgr == p_drv) 933 if (p_dev->cardmgr == p_drv) {
934 ds_dbg(0, "cardmgr matched %s to %s\n", dev->bus_id,
935 drv->name);
851 return 1; 936 return 1;
937 }
852#endif 938#endif
853 939
854 while (did && did->match_flags) { 940 while (did && did->match_flags) {
855 if (pcmcia_devmatch(p_dev, did)) 941 ds_dbg(3, "trying to match %s to %s\n", dev->bus_id,
942 drv->name);
943 if (pcmcia_devmatch(p_dev, did)) {
944 ds_dbg(0, "matched %s to %s\n", dev->bus_id,
945 drv->name);
856 return 1; 946 return 1;
947 }
857 did++; 948 did++;
858 } 949 }
859 950
@@ -1044,6 +1135,8 @@ static int pcmcia_dev_suspend(struct device * dev, pm_message_t state)
1044 struct pcmcia_driver *p_drv = NULL; 1135 struct pcmcia_driver *p_drv = NULL;
1045 int ret = 0; 1136 int ret = 0;
1046 1137
1138 ds_dbg(2, "suspending %s\n", dev->bus_id);
1139
1047 if (dev->driver) 1140 if (dev->driver)
1048 p_drv = to_pcmcia_drv(dev->driver); 1141 p_drv = to_pcmcia_drv(dev->driver);
1049 1142
@@ -1052,12 +1145,18 @@ static int pcmcia_dev_suspend(struct device * dev, pm_message_t state)
1052 1145
1053 if (p_drv->suspend) { 1146 if (p_drv->suspend) {
1054 ret = p_drv->suspend(p_dev); 1147 ret = p_drv->suspend(p_dev);
1055 if (ret) 1148 if (ret) {
1149 printk(KERN_ERR "pcmcia: device %s (driver %s) did "
1150 "not want to go to sleep (%d)\n",
1151 p_dev->devname, p_drv->drv.name, ret);
1056 goto out; 1152 goto out;
1153 }
1057 } 1154 }
1058 1155
1059 if (p_dev->device_no == p_dev->func) 1156 if (p_dev->device_no == p_dev->func) {
1157 ds_dbg(2, "releasing configuration for %s\n", dev->bus_id);
1060 pcmcia_release_configuration(p_dev); 1158 pcmcia_release_configuration(p_dev);
1159 }
1061 1160
1062 out: 1161 out:
1063 if (!ret) 1162 if (!ret)
@@ -1072,6 +1171,8 @@ static int pcmcia_dev_resume(struct device * dev)
1072 struct pcmcia_driver *p_drv = NULL; 1171 struct pcmcia_driver *p_drv = NULL;
1073 int ret = 0; 1172 int ret = 0;
1074 1173
1174 ds_dbg(2, "resuming %s\n", dev->bus_id);
1175
1075 if (dev->driver) 1176 if (dev->driver)
1076 p_drv = to_pcmcia_drv(dev->driver); 1177 p_drv = to_pcmcia_drv(dev->driver);
1077 1178
@@ -1079,6 +1180,7 @@ static int pcmcia_dev_resume(struct device * dev)
1079 goto out; 1180 goto out;
1080 1181
1081 if (p_dev->device_no == p_dev->func) { 1182 if (p_dev->device_no == p_dev->func) {
1183 ds_dbg(2, "requesting configuration for %s\n", dev->bus_id);
1082 ret = pcmcia_request_configuration(p_dev, &p_dev->conf); 1184 ret = pcmcia_request_configuration(p_dev, &p_dev->conf);
1083 if (ret) 1185 if (ret)
1084 goto out; 1186 goto out;
@@ -1120,12 +1222,14 @@ static int pcmcia_bus_resume_callback(struct device *dev, void * _data)
1120 1222
1121static int pcmcia_bus_resume(struct pcmcia_socket *skt) 1223static int pcmcia_bus_resume(struct pcmcia_socket *skt)
1122{ 1224{
1225 ds_dbg(2, "resuming socket %d\n", skt->sock);
1123 bus_for_each_dev(&pcmcia_bus_type, NULL, skt, pcmcia_bus_resume_callback); 1226 bus_for_each_dev(&pcmcia_bus_type, NULL, skt, pcmcia_bus_resume_callback);
1124 return 0; 1227 return 0;
1125} 1228}
1126 1229
1127static int pcmcia_bus_suspend(struct pcmcia_socket *skt) 1230static int pcmcia_bus_suspend(struct pcmcia_socket *skt)
1128{ 1231{
1232 ds_dbg(2, "suspending socket %d\n", skt->sock);
1129 if (bus_for_each_dev(&pcmcia_bus_type, NULL, skt, 1233 if (bus_for_each_dev(&pcmcia_bus_type, NULL, skt,
1130 pcmcia_bus_suspend_callback)) { 1234 pcmcia_bus_suspend_callback)) {
1131 pcmcia_bus_resume(skt); 1235 pcmcia_bus_resume(skt);
@@ -1246,7 +1350,7 @@ static int __devinit pcmcia_bus_add_socket(struct class_device *class_dev,
1246 init_waitqueue_head(&socket->queue); 1350 init_waitqueue_head(&socket->queue);
1247#endif 1351#endif
1248 INIT_LIST_HEAD(&socket->devices_list); 1352 INIT_LIST_HEAD(&socket->devices_list);
1249 INIT_WORK(&socket->device_add, pcmcia_delayed_add_pseudo_device, socket); 1353 INIT_WORK(&socket->device_add, pcmcia_delayed_add_device);
1250 memset(&socket->pcmcia_state, 0, sizeof(u8)); 1354 memset(&socket->pcmcia_state, 0, sizeof(u8));
1251 socket->device_count = 0; 1355 socket->device_count = 0;
1252 1356
@@ -1271,6 +1375,11 @@ static void pcmcia_bus_remove_socket(struct class_device *class_dev,
1271 socket->pcmcia_state.dead = 1; 1375 socket->pcmcia_state.dead = 1;
1272 pccard_register_pcmcia(socket, NULL); 1376 pccard_register_pcmcia(socket, NULL);
1273 1377
1378 /* unregister any unbound devices */
1379 mutex_lock(&socket->skt_mutex);
1380 pcmcia_card_remove(socket, NULL);
1381 mutex_unlock(&socket->skt_mutex);
1382
1274 pcmcia_put_socket(socket); 1383 pcmcia_put_socket(socket);
1275 1384
1276 return; 1385 return;
diff --git a/drivers/pcmcia/m32r_cfc.c b/drivers/pcmcia/m32r_cfc.c
index 36fdaa58458c..3c22ac4625c2 100644
--- a/drivers/pcmcia/m32r_cfc.c
+++ b/drivers/pcmcia/m32r_cfc.c
@@ -398,7 +398,7 @@ static irqreturn_t pcc_interrupt(int irq, void *dev)
398static void pcc_interrupt_wrapper(u_long data) 398static void pcc_interrupt_wrapper(u_long data)
399{ 399{
400 debug(3, "m32r_cfc: pcc_interrupt_wrapper:\n"); 400 debug(3, "m32r_cfc: pcc_interrupt_wrapper:\n");
401 pcc_interrupt(0, NULL, NULL); 401 pcc_interrupt(0, NULL);
402 init_timer(&poll_timer); 402 init_timer(&poll_timer);
403 poll_timer.expires = jiffies + poll_interval; 403 poll_timer.expires = jiffies + poll_interval;
404 add_timer(&poll_timer); 404 add_timer(&poll_timer);
diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c
index 310ede575caa..d077870c6731 100644
--- a/drivers/pcmcia/pcmcia_ioctl.c
+++ b/drivers/pcmcia/pcmcia_ioctl.c
@@ -594,7 +594,12 @@ static int ds_ioctl(struct inode * inode, struct file * file,
594 594
595 err = ret = 0; 595 err = ret = 0;
596 596
597 if (cmd & IOC_IN) __copy_from_user((char *)buf, uarg, size); 597 if (cmd & IOC_IN) {
598 if (__copy_from_user((char *)buf, uarg, size)) {
599 err = -EFAULT;
600 goto free_out;
601 }
602 }
598 603
599 switch (cmd) { 604 switch (cmd) {
600 case DS_ADJUST_RESOURCE_INFO: 605 case DS_ADJUST_RESOURCE_INFO:
diff --git a/drivers/pcmcia/pd6729.c b/drivers/pcmcia/pd6729.c
index a70f97fdbbdd..360c24896548 100644
--- a/drivers/pcmcia/pd6729.c
+++ b/drivers/pcmcia/pd6729.c
@@ -581,10 +581,10 @@ static irqreturn_t pd6729_test(int irq, void *dev)
581 return IRQ_HANDLED; 581 return IRQ_HANDLED;
582} 582}
583 583
584static int pd6729_check_irq(int irq, int flags) 584static int pd6729_check_irq(int irq)
585{ 585{
586 if (request_irq(irq, pd6729_test, flags, "x", pd6729_test) != 0) 586 if (request_irq(irq, pd6729_test, IRQF_PROBE_SHARED, "x", pd6729_test)
587 return -1; 587 != 0) return -1;
588 free_irq(irq, pd6729_test); 588 free_irq(irq, pd6729_test);
589 return 0; 589 return 0;
590} 590}
@@ -610,7 +610,7 @@ static u_int __devinit pd6729_isa_scan(void)
610 610
611 /* just find interrupts that aren't in use */ 611 /* just find interrupts that aren't in use */
612 for (i = 0; i < 16; i++) 612 for (i = 0; i < 16; i++)
613 if ((mask0 & (1 << i)) && (pd6729_check_irq(i, 0) == 0)) 613 if ((mask0 & (1 << i)) && (pd6729_check_irq(i) == 0))
614 mask |= (1 << i); 614 mask |= (1 << i);
615 615
616 printk(KERN_INFO "pd6729: ISA irqs = "); 616 printk(KERN_INFO "pd6729: ISA irqs = ");
diff --git a/drivers/pcmcia/socket_sysfs.c b/drivers/pcmcia/socket_sysfs.c
index 933cd864a5c9..b005602d6b53 100644
--- a/drivers/pcmcia/socket_sysfs.c
+++ b/drivers/pcmcia/socket_sysfs.c
@@ -188,7 +188,7 @@ static ssize_t pccard_store_resource(struct class_device *dev, const char *buf,
188 (s->state & SOCKET_PRESENT) && 188 (s->state & SOCKET_PRESENT) &&
189 !(s->state & SOCKET_CARDBUS)) { 189 !(s->state & SOCKET_CARDBUS)) {
190 if (try_module_get(s->callback->owner)) { 190 if (try_module_get(s->callback->owner)) {
191 s->callback->requery(s); 191 s->callback->requery(s, 0);
192 module_put(s->callback->owner); 192 module_put(s->callback->owner);
193 } 193 }
194 } 194 }
@@ -325,7 +325,7 @@ static ssize_t pccard_store_cis(struct kobject *kobj, char *buf, loff_t off, siz
325 if ((s->callback) && (s->state & SOCKET_PRESENT) && 325 if ((s->callback) && (s->state & SOCKET_PRESENT) &&
326 !(s->state & SOCKET_CARDBUS)) { 326 !(s->state & SOCKET_CARDBUS)) {
327 if (try_module_get(s->callback->owner)) { 327 if (try_module_get(s->callback->owner)) {
328 s->callback->requery(s); 328 s->callback->requery(s, 1);
329 module_put(s->callback->owner); 329 module_put(s->callback->owner);
330 } 330 }
331 } 331 }
diff --git a/drivers/pnp/card.c b/drivers/pnp/card.c
index 227600cd6360..91c047a7e635 100644
--- a/drivers/pnp/card.c
+++ b/drivers/pnp/card.c
@@ -164,9 +164,17 @@ static DEVICE_ATTR(card_id,S_IRUGO,pnp_show_card_ids,NULL);
164 164
165static int pnp_interface_attach_card(struct pnp_card *card) 165static int pnp_interface_attach_card(struct pnp_card *card)
166{ 166{
167 device_create_file(&card->dev,&dev_attr_name); 167 int rc = device_create_file(&card->dev,&dev_attr_name);
168 device_create_file(&card->dev,&dev_attr_card_id); 168 if (rc) return rc;
169
170 rc = device_create_file(&card->dev,&dev_attr_card_id);
171 if (rc) goto err_name;
172
169 return 0; 173 return 0;
174
175err_name:
176 device_remove_file(&card->dev,&dev_attr_name);
177 return rc;
170} 178}
171 179
172/** 180/**
@@ -306,16 +314,20 @@ found:
306 down_write(&dev->dev.bus->subsys.rwsem); 314 down_write(&dev->dev.bus->subsys.rwsem);
307 dev->card_link = clink; 315 dev->card_link = clink;
308 dev->dev.driver = &drv->link.driver; 316 dev->dev.driver = &drv->link.driver;
309 if (pnp_bus_type.probe(&dev->dev)) { 317 if (pnp_bus_type.probe(&dev->dev))
310 dev->dev.driver = NULL; 318 goto err_out;
311 dev->card_link = NULL; 319 if (device_bind_driver(&dev->dev))
312 up_write(&dev->dev.bus->subsys.rwsem); 320 goto err_out;
313 return NULL; 321
314 }
315 device_bind_driver(&dev->dev);
316 up_write(&dev->dev.bus->subsys.rwsem); 322 up_write(&dev->dev.bus->subsys.rwsem);
317 323
318 return dev; 324 return dev;
325
326err_out:
327 dev->dev.driver = NULL;
328 dev->card_link = NULL;
329 up_write(&dev->dev.bus->subsys.rwsem);
330 return NULL;
319} 331}
320 332
321/** 333/**
diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c
index 9d8b415eca79..ac9fcd499f3f 100644
--- a/drivers/pnp/interface.c
+++ b/drivers/pnp/interface.c
@@ -461,8 +461,19 @@ static DEVICE_ATTR(id,S_IRUGO,pnp_show_current_ids,NULL);
461 461
462int pnp_interface_attach_device(struct pnp_dev *dev) 462int pnp_interface_attach_device(struct pnp_dev *dev)
463{ 463{
464 device_create_file(&dev->dev,&dev_attr_options); 464 int rc = device_create_file(&dev->dev,&dev_attr_options);
465 device_create_file(&dev->dev,&dev_attr_resources); 465 if (rc) goto err;
466 device_create_file(&dev->dev,&dev_attr_id); 466 rc = device_create_file(&dev->dev,&dev_attr_resources);
467 if (rc) goto err_opt;
468 rc = device_create_file(&dev->dev,&dev_attr_id);
469 if (rc) goto err_res;
470
467 return 0; 471 return 0;
472
473err_res:
474 device_remove_file(&dev->dev,&dev_attr_resources);
475err_opt:
476 device_remove_file(&dev->dev,&dev_attr_options);
477err:
478 return rc;
468} 479}
diff --git a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c
index 81a6c83d89a6..33adeba1a31f 100644
--- a/drivers/pnp/pnpbios/core.c
+++ b/drivers/pnp/pnpbios/core.c
@@ -61,6 +61,7 @@
61#include <linux/dmi.h> 61#include <linux/dmi.h>
62#include <linux/delay.h> 62#include <linux/delay.h>
63#include <linux/acpi.h> 63#include <linux/acpi.h>
64#include <linux/freezer.h>
64 65
65#include <asm/page.h> 66#include <asm/page.h>
66#include <asm/desc.h> 67#include <asm/desc.h>
@@ -530,7 +531,8 @@ static int __init pnpbios_init(void)
530 if (check_legacy_ioport(PNPBIOS_BASE)) 531 if (check_legacy_ioport(PNPBIOS_BASE))
531 return -ENODEV; 532 return -ENODEV;
532#endif 533#endif
533 if (pnpbios_disabled || dmi_check_system(pnpbios_dmi_table)) { 534 if (pnpbios_disabled || dmi_check_system(pnpbios_dmi_table) ||
535 paravirt_enabled()) {
534 printk(KERN_INFO "PnPBIOS: Disabled\n"); 536 printk(KERN_INFO "PnPBIOS: Disabled\n");
535 return -ENODEV; 537 return -ENODEV;
536 } 538 }
diff --git a/drivers/ps3/Makefile b/drivers/ps3/Makefile
new file mode 100644
index 000000000000..b52d547b7a78
--- /dev/null
+++ b/drivers/ps3/Makefile
@@ -0,0 +1 @@
obj-y += system-bus.o
diff --git a/drivers/ps3/system-bus.c b/drivers/ps3/system-bus.c
new file mode 100644
index 000000000000..d79f949bcb2a
--- /dev/null
+++ b/drivers/ps3/system-bus.c
@@ -0,0 +1,362 @@
1/*
2 * PS3 system bus driver.
3 *
4 * Copyright (C) 2006 Sony Computer Entertainment Inc.
5 * Copyright 2006 Sony Corp.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#include <linux/kernel.h>
22#include <linux/init.h>
23#include <linux/module.h>
24#include <linux/dma-mapping.h>
25#include <linux/err.h>
26
27#include <asm/udbg.h>
28#include <asm/ps3.h>
29#include <asm/lv1call.h>
30#include <asm/firmware.h>
31
32#define dump_mmio_region(_a) _dump_mmio_region(_a, __func__, __LINE__)
33static void _dump_mmio_region(const struct ps3_mmio_region* r,
34 const char* func, int line)
35{
36 pr_debug("%s:%d: dev %u:%u\n", func, line, r->did.bus_id,
37 r->did.dev_id);
38 pr_debug("%s:%d: bus_addr %lxh\n", func, line, r->bus_addr);
39 pr_debug("%s:%d: len %lxh\n", func, line, r->len);
40 pr_debug("%s:%d: lpar_addr %lxh\n", func, line, r->lpar_addr);
41}
42
43int ps3_mmio_region_create(struct ps3_mmio_region *r)
44{
45 int result;
46
47 result = lv1_map_device_mmio_region(r->did.bus_id, r->did.dev_id,
48 r->bus_addr, r->len, r->page_size, &r->lpar_addr);
49
50 if (result) {
51 pr_debug("%s:%d: lv1_map_device_mmio_region failed: %s\n",
52 __func__, __LINE__, ps3_result(result));
53 r->lpar_addr = r->len = r->bus_addr = 0;
54 }
55
56 dump_mmio_region(r);
57 return result;
58}
59
60int ps3_free_mmio_region(struct ps3_mmio_region *r)
61{
62 int result;
63
64 result = lv1_unmap_device_mmio_region(r->did.bus_id, r->did.dev_id,
65 r->bus_addr);
66
67 if (result)
68 pr_debug("%s:%d: lv1_unmap_device_mmio_region failed: %s\n",
69 __func__, __LINE__, ps3_result(result));
70
71 r->lpar_addr = r->len = r->bus_addr = 0;
72 return result;
73}
74
75static int ps3_system_bus_match(struct device *_dev,
76 struct device_driver *_drv)
77{
78 int result;
79 struct ps3_system_bus_driver *drv = to_ps3_system_bus_driver(_drv);
80 struct ps3_system_bus_device *dev = to_ps3_system_bus_device(_dev);
81
82 result = dev->match_id == drv->match_id;
83
84 pr_info("%s:%d: dev=%u(%s), drv=%u(%s): %s\n", __func__, __LINE__,
85 dev->match_id, dev->core.bus_id, drv->match_id, drv->core.name,
86 (result ? "match" : "miss"));
87 return result;
88}
89
90static int ps3_system_bus_probe(struct device *_dev)
91{
92 int result;
93 struct ps3_system_bus_device *dev = to_ps3_system_bus_device(_dev);
94 struct ps3_system_bus_driver *drv =
95 to_ps3_system_bus_driver(_dev->driver);
96
97 result = lv1_open_device(dev->did.bus_id, dev->did.dev_id, 0);
98
99 if (result) {
100 pr_debug("%s:%d: lv1_open_device failed (%d)\n",
101 __func__, __LINE__, result);
102 result = -EACCES;
103 goto clean_none;
104 }
105
106 if (dev->d_region->did.bus_id) {
107 result = ps3_dma_region_create(dev->d_region);
108
109 if (result) {
110 pr_debug("%s:%d: ps3_dma_region_create failed (%d)\n",
111 __func__, __LINE__, result);
112 BUG_ON("check region type");
113 result = -EINVAL;
114 goto clean_device;
115 }
116 }
117
118 BUG_ON(!drv);
119
120 if (drv->probe)
121 result = drv->probe(dev);
122 else
123 pr_info("%s:%d: %s no probe method\n", __func__, __LINE__,
124 dev->core.bus_id);
125
126 if (result) {
127 pr_debug("%s:%d: drv->probe failed\n", __func__, __LINE__);
128 goto clean_dma;
129 }
130
131 return result;
132
133clean_dma:
134 ps3_dma_region_free(dev->d_region);
135clean_device:
136 lv1_close_device(dev->did.bus_id, dev->did.dev_id);
137clean_none:
138 return result;
139}
140
141static int ps3_system_bus_remove(struct device *_dev)
142{
143 struct ps3_system_bus_device *dev = to_ps3_system_bus_device(_dev);
144 struct ps3_system_bus_driver *drv =
145 to_ps3_system_bus_driver(_dev->driver);
146
147 if (drv->remove)
148 drv->remove(dev);
149 else
150 pr_info("%s:%d: %s no remove method\n", __func__, __LINE__,
151 dev->core.bus_id);
152
153 ps3_dma_region_free(dev->d_region);
154 ps3_free_mmio_region(dev->m_region);
155 lv1_close_device(dev->did.bus_id, dev->did.dev_id);
156
157 return 0;
158}
159
160struct bus_type ps3_system_bus_type = {
161 .name = "ps3_system_bus",
162 .match = ps3_system_bus_match,
163 .probe = ps3_system_bus_probe,
164 .remove = ps3_system_bus_remove,
165};
166
167int __init ps3_system_bus_init(void)
168{
169 int result;
170
171 if (!firmware_has_feature(FW_FEATURE_PS3_LV1))
172 return 0;
173
174 result = bus_register(&ps3_system_bus_type);
175 BUG_ON(result);
176 return result;
177}
178
179core_initcall(ps3_system_bus_init);
180
181/* Allocates a contiguous real buffer and creates mappings over it.
182 * Returns the virtual address of the buffer and sets dma_handle
183 * to the dma address (mapping) of the first page.
184 */
185
186static void * ps3_alloc_coherent(struct device *_dev, size_t size,
187 dma_addr_t *dma_handle, gfp_t flag)
188{
189 int result;
190 struct ps3_system_bus_device *dev = to_ps3_system_bus_device(_dev);
191 unsigned long virt_addr;
192
193 BUG_ON(!dev->d_region->bus_addr);
194
195 flag &= ~(__GFP_DMA | __GFP_HIGHMEM);
196 flag |= __GFP_ZERO;
197
198 virt_addr = __get_free_pages(flag, get_order(size));
199
200 if (!virt_addr) {
201 pr_debug("%s:%d: get_free_pages failed\n", __func__, __LINE__);
202 goto clean_none;
203 }
204
205 result = ps3_dma_map(dev->d_region, virt_addr, size, dma_handle);
206
207 if (result) {
208 pr_debug("%s:%d: ps3_dma_map failed (%d)\n",
209 __func__, __LINE__, result);
210 BUG_ON("check region type");
211 goto clean_alloc;
212 }
213
214 return (void*)virt_addr;
215
216clean_alloc:
217 free_pages(virt_addr, get_order(size));
218clean_none:
219 dma_handle = NULL;
220 return NULL;
221}
222
223static void ps3_free_coherent(struct device *_dev, size_t size, void *vaddr,
224 dma_addr_t dma_handle)
225{
226 struct ps3_system_bus_device *dev = to_ps3_system_bus_device(_dev);
227
228 ps3_dma_unmap(dev->d_region, dma_handle, size);
229 free_pages((unsigned long)vaddr, get_order(size));
230}
231
232/* Creates TCEs for a user provided buffer. The user buffer must be
233 * contiguous real kernel storage (not vmalloc). The address of the buffer
234 * passed here is the kernel (virtual) address of the buffer. The buffer
235 * need not be page aligned, the dma_addr_t returned will point to the same
236 * byte within the page as vaddr.
237 */
238
239static dma_addr_t ps3_map_single(struct device *_dev, void *ptr, size_t size,
240 enum dma_data_direction direction)
241{
242 struct ps3_system_bus_device *dev = to_ps3_system_bus_device(_dev);
243 int result;
244 unsigned long bus_addr;
245
246 result = ps3_dma_map(dev->d_region, (unsigned long)ptr, size,
247 &bus_addr);
248
249 if (result) {
250 pr_debug("%s:%d: ps3_dma_map failed (%d)\n",
251 __func__, __LINE__, result);
252 }
253
254 return bus_addr;
255}
256
257static void ps3_unmap_single(struct device *_dev, dma_addr_t dma_addr,
258 size_t size, enum dma_data_direction direction)
259{
260 struct ps3_system_bus_device *dev = to_ps3_system_bus_device(_dev);
261 int result;
262
263 result = ps3_dma_unmap(dev->d_region, dma_addr, size);
264
265 if (result) {
266 pr_debug("%s:%d: ps3_dma_unmap failed (%d)\n",
267 __func__, __LINE__, result);
268 }
269}
270
271static int ps3_map_sg(struct device *_dev, struct scatterlist *sg, int nents,
272 enum dma_data_direction direction)
273{
274#if defined(CONFIG_PS3_DYNAMIC_DMA)
275 BUG_ON("do");
276#endif
277 return 0;
278}
279
280static void ps3_unmap_sg(struct device *_dev, struct scatterlist *sg,
281 int nents, enum dma_data_direction direction)
282{
283#if defined(CONFIG_PS3_DYNAMIC_DMA)
284 BUG_ON("do");
285#endif
286}
287
288static int ps3_dma_supported(struct device *_dev, u64 mask)
289{
290 return 1;
291}
292
293static struct dma_mapping_ops ps3_dma_ops = {
294 .alloc_coherent = ps3_alloc_coherent,
295 .free_coherent = ps3_free_coherent,
296 .map_single = ps3_map_single,
297 .unmap_single = ps3_unmap_single,
298 .map_sg = ps3_map_sg,
299 .unmap_sg = ps3_unmap_sg,
300 .dma_supported = ps3_dma_supported
301};
302
303/**
304 * ps3_system_bus_release_device - remove a device from the system bus
305 */
306
307static void ps3_system_bus_release_device(struct device *_dev)
308{
309 struct ps3_system_bus_device *dev = to_ps3_system_bus_device(_dev);
310 kfree(dev);
311}
312
313/**
314 * ps3_system_bus_device_register - add a device to the system bus
315 *
316 * ps3_system_bus_device_register() expects the dev object to be allocated
317 * dynamically by the caller. The system bus takes ownership of the dev
318 * object and frees the object in ps3_system_bus_release_device().
319 */
320
321int ps3_system_bus_device_register(struct ps3_system_bus_device *dev)
322{
323 int result;
324 static unsigned int dev_count = 1;
325
326 dev->core.parent = NULL;
327 dev->core.bus = &ps3_system_bus_type;
328 dev->core.release = ps3_system_bus_release_device;
329
330 dev->core.archdata.of_node = NULL;
331 dev->core.archdata.dma_ops = &ps3_dma_ops;
332 dev->core.archdata.numa_node = 0;
333
334 snprintf(dev->core.bus_id, sizeof(dev->core.bus_id), "sb_%02x",
335 dev_count++);
336
337 pr_debug("%s:%d add %s\n", __func__, __LINE__, dev->core.bus_id);
338
339 result = device_register(&dev->core);
340 return result;
341}
342
343EXPORT_SYMBOL_GPL(ps3_system_bus_device_register);
344
345int ps3_system_bus_driver_register(struct ps3_system_bus_driver *drv)
346{
347 int result;
348
349 drv->core.bus = &ps3_system_bus_type;
350
351 result = driver_register(&drv->core);
352 return result;
353}
354
355EXPORT_SYMBOL_GPL(ps3_system_bus_driver_register);
356
357void ps3_system_bus_driver_unregister(struct ps3_system_bus_driver *drv)
358{
359 driver_unregister(&drv->core);
360}
361
362EXPORT_SYMBOL_GPL(ps3_system_bus_driver_unregister);
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index fc766a7a611e..2a63ab2b47f4 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -154,15 +154,23 @@ config RTC_DRV_DS1672
154 will be called rtc-ds1672. 154 will be called rtc-ds1672.
155 155
156config RTC_DRV_DS1742 156config RTC_DRV_DS1742
157 tristate "Dallas DS1742" 157 tristate "Dallas DS1742/1743"
158 depends on RTC_CLASS 158 depends on RTC_CLASS
159 help 159 help
160 If you say yes here you get support for the 160 If you say yes here you get support for the
161 Dallas DS1742 timekeeping chip. 161 Dallas DS1742/1743 timekeeping chip.
162 162
163 This driver can also be built as a module. If so, the module 163 This driver can also be built as a module. If so, the module
164 will be called rtc-ds1742. 164 will be called rtc-ds1742.
165 165
166config RTC_DRV_OMAP
167 tristate "TI OMAP1"
168 depends on RTC_CLASS && ( \
169 ARCH_OMAP15XX || ARCH_OMAP16XX || ARCH_OMAP730 )
170 help
171 Say "yes" here to support the real time clock on TI OMAP1 chips.
172 This driver can also be built as a module called rtc-omap.
173
166config RTC_DRV_PCF8563 174config RTC_DRV_PCF8563
167 tristate "Philips PCF8563/Epson RTC8564" 175 tristate "Philips PCF8563/Epson RTC8564"
168 depends on RTC_CLASS && I2C 176 depends on RTC_CLASS && I2C
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 3ba5ff6e6800..bd4c45d333f0 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -21,6 +21,7 @@ obj-$(CONFIG_RTC_DRV_TEST) += rtc-test.o
21obj-$(CONFIG_RTC_DRV_DS1307) += rtc-ds1307.o 21obj-$(CONFIG_RTC_DRV_DS1307) += rtc-ds1307.o
22obj-$(CONFIG_RTC_DRV_DS1672) += rtc-ds1672.o 22obj-$(CONFIG_RTC_DRV_DS1672) += rtc-ds1672.o
23obj-$(CONFIG_RTC_DRV_DS1742) += rtc-ds1742.o 23obj-$(CONFIG_RTC_DRV_DS1742) += rtc-ds1742.o
24obj-$(CONFIG_RTC_DRV_OMAP) += rtc-omap.o
24obj-$(CONFIG_RTC_DRV_PCF8563) += rtc-pcf8563.o 25obj-$(CONFIG_RTC_DRV_PCF8563) += rtc-pcf8563.o
25obj-$(CONFIG_RTC_DRV_PCF8583) += rtc-pcf8583.o 26obj-$(CONFIG_RTC_DRV_PCF8583) += rtc-pcf8583.o
26obj-$(CONFIG_RTC_DRV_RS5C372) += rtc-rs5c372.o 27obj-$(CONFIG_RTC_DRV_RS5C372) += rtc-rs5c372.o
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index 579cd667b16f..6f11f6dfdd9d 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -145,6 +145,13 @@ int rtc_set_alarm(struct class_device *class_dev, struct rtc_wkalrm *alarm)
145} 145}
146EXPORT_SYMBOL_GPL(rtc_set_alarm); 146EXPORT_SYMBOL_GPL(rtc_set_alarm);
147 147
148/**
149 * rtc_update_irq - report RTC periodic, alarm, and/or update irqs
150 * @class_dev: the rtc's class device
151 * @num: how many irqs are being reported (usually one)
152 * @events: mask of RTC_IRQF with one or more of RTC_PF, RTC_AF, RTC_UF
153 * Context: in_interrupt(), irqs blocked
154 */
148void rtc_update_irq(struct class_device *class_dev, 155void rtc_update_irq(struct class_device *class_dev,
149 unsigned long num, unsigned long events) 156 unsigned long num, unsigned long events)
150{ 157{
@@ -201,12 +208,12 @@ int rtc_irq_register(struct class_device *class_dev, struct rtc_task *task)
201 if (task == NULL || task->func == NULL) 208 if (task == NULL || task->func == NULL)
202 return -EINVAL; 209 return -EINVAL;
203 210
204 spin_lock(&rtc->irq_task_lock); 211 spin_lock_irq(&rtc->irq_task_lock);
205 if (rtc->irq_task == NULL) { 212 if (rtc->irq_task == NULL) {
206 rtc->irq_task = task; 213 rtc->irq_task = task;
207 retval = 0; 214 retval = 0;
208 } 215 }
209 spin_unlock(&rtc->irq_task_lock); 216 spin_unlock_irq(&rtc->irq_task_lock);
210 217
211 return retval; 218 return retval;
212} 219}
@@ -216,10 +223,10 @@ void rtc_irq_unregister(struct class_device *class_dev, struct rtc_task *task)
216{ 223{
217 struct rtc_device *rtc = to_rtc_device(class_dev); 224 struct rtc_device *rtc = to_rtc_device(class_dev);
218 225
219 spin_lock(&rtc->irq_task_lock); 226 spin_lock_irq(&rtc->irq_task_lock);
220 if (rtc->irq_task == task) 227 if (rtc->irq_task == task)
221 rtc->irq_task = NULL; 228 rtc->irq_task = NULL;
222 spin_unlock(&rtc->irq_task_lock); 229 spin_unlock_irq(&rtc->irq_task_lock);
223} 230}
224EXPORT_SYMBOL_GPL(rtc_irq_unregister); 231EXPORT_SYMBOL_GPL(rtc_irq_unregister);
225 232
@@ -265,3 +272,4 @@ int rtc_irq_set_freq(struct class_device *class_dev, struct rtc_task *task, int
265 } 272 }
266 return err; 273 return err;
267} 274}
275EXPORT_SYMBOL_GPL(rtc_irq_set_freq);
diff --git a/drivers/rtc/rtc-at91.c b/drivers/rtc/rtc-at91.c
index bd61e99540a3..5c8addcaf1fb 100644
--- a/drivers/rtc/rtc-at91.c
+++ b/drivers/rtc/rtc-at91.c
@@ -292,7 +292,8 @@ static int __init at91_rtc_probe(struct platform_device *pdev)
292 AT91_RTC_CALEV); 292 AT91_RTC_CALEV);
293 293
294 ret = request_irq(AT91_ID_SYS, at91_rtc_interrupt, 294 ret = request_irq(AT91_ID_SYS, at91_rtc_interrupt,
295 IRQF_SHARED, "at91_rtc", pdev); 295 IRQF_DISABLED | IRQF_SHARED,
296 "at91_rtc", pdev);
296 if (ret) { 297 if (ret) {
297 printk(KERN_ERR "at91_rtc: IRQ %d already in use.\n", 298 printk(KERN_ERR "at91_rtc: IRQ %d already in use.\n",
298 AT91_ID_SYS); 299 AT91_ID_SYS);
diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
index 583789c66cdb..828b329e08e0 100644
--- a/drivers/rtc/rtc-dev.c
+++ b/drivers/rtc/rtc-dev.c
@@ -53,15 +53,18 @@ static int rtc_dev_open(struct inode *inode, struct file *file)
53 * Routine to poll RTC seconds field for change as often as possible, 53 * Routine to poll RTC seconds field for change as often as possible,
54 * after first RTC_UIE use timer to reduce polling 54 * after first RTC_UIE use timer to reduce polling
55 */ 55 */
56static void rtc_uie_task(void *data) 56static void rtc_uie_task(struct work_struct *work)
57{ 57{
58 struct rtc_device *rtc = data; 58 struct rtc_device *rtc =
59 container_of(work, struct rtc_device, uie_task);
59 struct rtc_time tm; 60 struct rtc_time tm;
60 int num = 0; 61 int num = 0;
61 int err; 62 int err;
62 63
63 err = rtc_read_time(&rtc->class_dev, &tm); 64 err = rtc_read_time(&rtc->class_dev, &tm);
64 spin_lock_irq(&rtc->irq_lock); 65
66 local_irq_disable();
67 spin_lock(&rtc->irq_lock);
65 if (rtc->stop_uie_polling || err) { 68 if (rtc->stop_uie_polling || err) {
66 rtc->uie_task_active = 0; 69 rtc->uie_task_active = 0;
67 } else if (rtc->oldsecs != tm.tm_sec) { 70 } else if (rtc->oldsecs != tm.tm_sec) {
@@ -74,11 +77,11 @@ static void rtc_uie_task(void *data)
74 } else if (schedule_work(&rtc->uie_task) == 0) { 77 } else if (schedule_work(&rtc->uie_task) == 0) {
75 rtc->uie_task_active = 0; 78 rtc->uie_task_active = 0;
76 } 79 }
77 spin_unlock_irq(&rtc->irq_lock); 80 spin_unlock(&rtc->irq_lock);
78 if (num) 81 if (num)
79 rtc_update_irq(&rtc->class_dev, num, RTC_UF | RTC_IRQF); 82 rtc_update_irq(&rtc->class_dev, num, RTC_UF | RTC_IRQF);
83 local_irq_enable();
80} 84}
81
82static void rtc_uie_timer(unsigned long data) 85static void rtc_uie_timer(unsigned long data)
83{ 86{
84 struct rtc_device *rtc = (struct rtc_device *)data; 87 struct rtc_device *rtc = (struct rtc_device *)data;
@@ -214,7 +217,7 @@ static int rtc_dev_ioctl(struct inode *inode, struct file *file,
214 struct rtc_wkalrm alarm; 217 struct rtc_wkalrm alarm;
215 void __user *uarg = (void __user *) arg; 218 void __user *uarg = (void __user *) arg;
216 219
217 /* check that the calles has appropriate permissions 220 /* check that the calling task has appropriate permissions
218 * for certain ioctls. doing this check here is useful 221 * for certain ioctls. doing this check here is useful
219 * to avoid duplicate code in each driver. 222 * to avoid duplicate code in each driver.
220 */ 223 */
@@ -238,10 +241,10 @@ static int rtc_dev_ioctl(struct inode *inode, struct file *file,
238 241
239 /* avoid conflicting IRQ users */ 242 /* avoid conflicting IRQ users */
240 if (cmd == RTC_PIE_ON || cmd == RTC_PIE_OFF || cmd == RTC_IRQP_SET) { 243 if (cmd == RTC_PIE_ON || cmd == RTC_PIE_OFF || cmd == RTC_IRQP_SET) {
241 spin_lock(&rtc->irq_task_lock); 244 spin_lock_irq(&rtc->irq_task_lock);
242 if (rtc->irq_task) 245 if (rtc->irq_task)
243 err = -EBUSY; 246 err = -EBUSY;
244 spin_unlock(&rtc->irq_task_lock); 247 spin_unlock_irq(&rtc->irq_task_lock);
245 248
246 if (err < 0) 249 if (err < 0)
247 return err; 250 return err;
@@ -299,6 +302,17 @@ static int rtc_dev_ioctl(struct inode *inode, struct file *file,
299 302
300 err = rtc_set_time(class_dev, &tm); 303 err = rtc_set_time(class_dev, &tm);
301 break; 304 break;
305
306 case RTC_IRQP_READ:
307 if (ops->irq_set_freq)
308 err = put_user(rtc->irq_freq, (unsigned long *) arg);
309 break;
310
311 case RTC_IRQP_SET:
312 if (ops->irq_set_freq)
313 err = rtc_irq_set_freq(class_dev, rtc->irq_task, arg);
314 break;
315
302#if 0 316#if 0
303 case RTC_EPOCH_SET: 317 case RTC_EPOCH_SET:
304#ifndef rtc_epoch 318#ifndef rtc_epoch
@@ -398,7 +412,7 @@ static int rtc_dev_add_device(struct class_device *class_dev,
398 spin_lock_init(&rtc->irq_lock); 412 spin_lock_init(&rtc->irq_lock);
399 init_waitqueue_head(&rtc->irq_queue); 413 init_waitqueue_head(&rtc->irq_queue);
400#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL 414#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL
401 INIT_WORK(&rtc->uie_task, rtc_uie_task, rtc); 415 INIT_WORK(&rtc->uie_task, rtc_uie_task);
402 setup_timer(&rtc->uie_timer, rtc_uie_timer, (unsigned long)rtc); 416 setup_timer(&rtc->uie_timer, rtc_uie_timer, (unsigned long)rtc);
403#endif 417#endif
404 418
diff --git a/drivers/rtc/rtc-ds1553.c b/drivers/rtc/rtc-ds1553.c
index 78552e6e76aa..001eb1123a65 100644
--- a/drivers/rtc/rtc-ds1553.c
+++ b/drivers/rtc/rtc-ds1553.c
@@ -340,7 +340,8 @@ static int __init ds1553_rtc_probe(struct platform_device *pdev)
340 340
341 if (pdata->irq >= 0) { 341 if (pdata->irq >= 0) {
342 writeb(0, ioaddr + RTC_INTERRUPTS); 342 writeb(0, ioaddr + RTC_INTERRUPTS);
343 if (request_irq(pdata->irq, ds1553_rtc_interrupt, IRQF_SHARED, 343 if (request_irq(pdata->irq, ds1553_rtc_interrupt,
344 IRQF_DISABLED | IRQF_SHARED,
344 pdev->name, pdev) < 0) { 345 pdev->name, pdev) < 0) {
345 dev_warn(&pdev->dev, "interrupt not available.\n"); 346 dev_warn(&pdev->dev, "interrupt not available.\n");
346 pdata->irq = -1; 347 pdata->irq = -1;
diff --git a/drivers/rtc/rtc-ds1672.c b/drivers/rtc/rtc-ds1672.c
index 67e816a9a39f..dfef1637bfb8 100644
--- a/drivers/rtc/rtc-ds1672.c
+++ b/drivers/rtc/rtc-ds1672.c
@@ -237,17 +237,22 @@ static int ds1672_probe(struct i2c_adapter *adapter, int address, int kind)
237 /* read control register */ 237 /* read control register */
238 err = ds1672_get_control(client, &control); 238 err = ds1672_get_control(client, &control);
239 if (err) 239 if (err)
240 goto exit_detach; 240 goto exit_devreg;
241 241
242 if (control & DS1672_REG_CONTROL_EOSC) 242 if (control & DS1672_REG_CONTROL_EOSC)
243 dev_warn(&client->dev, "Oscillator not enabled. " 243 dev_warn(&client->dev, "Oscillator not enabled. "
244 "Set time to enable.\n"); 244 "Set time to enable.\n");
245 245
246 /* Register sysfs hooks */ 246 /* Register sysfs hooks */
247 device_create_file(&client->dev, &dev_attr_control); 247 err = device_create_file(&client->dev, &dev_attr_control);
248 if (err)
249 goto exit_devreg;
248 250
249 return 0; 251 return 0;
250 252
253exit_devreg:
254 rtc_device_unregister(rtc);
255
251exit_detach: 256exit_detach:
252 i2c_detach_client(client); 257 i2c_detach_client(client);
253 258
diff --git a/drivers/rtc/rtc-ds1742.c b/drivers/rtc/rtc-ds1742.c
index 6273a3d240a2..17633bfa8480 100644
--- a/drivers/rtc/rtc-ds1742.c
+++ b/drivers/rtc/rtc-ds1742.c
@@ -6,6 +6,10 @@
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 *
10 * Copyright (C) 2006 Torsten Ertbjerg Rasmussen <tr@newtec.dk>
11 * - nvram size determined from resource
12 * - this ds1742 driver now supports ds1743.
9 */ 13 */
10 14
11#include <linux/bcd.h> 15#include <linux/bcd.h>
@@ -17,20 +21,19 @@
17#include <linux/platform_device.h> 21#include <linux/platform_device.h>
18#include <linux/io.h> 22#include <linux/io.h>
19 23
20#define DRV_VERSION "0.2" 24#define DRV_VERSION "0.3"
21 25
22#define RTC_REG_SIZE 0x800 26#define RTC_SIZE 8
23#define RTC_OFFSET 0x7f8
24 27
25#define RTC_CONTROL (RTC_OFFSET + 0) 28#define RTC_CONTROL 0
26#define RTC_CENTURY (RTC_OFFSET + 0) 29#define RTC_CENTURY 0
27#define RTC_SECONDS (RTC_OFFSET + 1) 30#define RTC_SECONDS 1
28#define RTC_MINUTES (RTC_OFFSET + 2) 31#define RTC_MINUTES 2
29#define RTC_HOURS (RTC_OFFSET + 3) 32#define RTC_HOURS 3
30#define RTC_DAY (RTC_OFFSET + 4) 33#define RTC_DAY 4
31#define RTC_DATE (RTC_OFFSET + 5) 34#define RTC_DATE 5
32#define RTC_MONTH (RTC_OFFSET + 6) 35#define RTC_MONTH 6
33#define RTC_YEAR (RTC_OFFSET + 7) 36#define RTC_YEAR 7
34 37
35#define RTC_CENTURY_MASK 0x3f 38#define RTC_CENTURY_MASK 0x3f
36#define RTC_SECONDS_MASK 0x7f 39#define RTC_SECONDS_MASK 0x7f
@@ -48,7 +51,10 @@
48 51
49struct rtc_plat_data { 52struct rtc_plat_data {
50 struct rtc_device *rtc; 53 struct rtc_device *rtc;
51 void __iomem *ioaddr; 54 void __iomem *ioaddr_nvram;
55 void __iomem *ioaddr_rtc;
56 size_t size_nvram;
57 size_t size;
52 unsigned long baseaddr; 58 unsigned long baseaddr;
53 unsigned long last_jiffies; 59 unsigned long last_jiffies;
54}; 60};
@@ -57,7 +63,7 @@ static int ds1742_rtc_set_time(struct device *dev, struct rtc_time *tm)
57{ 63{
58 struct platform_device *pdev = to_platform_device(dev); 64 struct platform_device *pdev = to_platform_device(dev);
59 struct rtc_plat_data *pdata = platform_get_drvdata(pdev); 65 struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
60 void __iomem *ioaddr = pdata->ioaddr; 66 void __iomem *ioaddr = pdata->ioaddr_rtc;
61 u8 century; 67 u8 century;
62 68
63 century = BIN2BCD((tm->tm_year + 1900) / 100); 69 century = BIN2BCD((tm->tm_year + 1900) / 100);
@@ -82,7 +88,7 @@ static int ds1742_rtc_read_time(struct device *dev, struct rtc_time *tm)
82{ 88{
83 struct platform_device *pdev = to_platform_device(dev); 89 struct platform_device *pdev = to_platform_device(dev);
84 struct rtc_plat_data *pdata = platform_get_drvdata(pdev); 90 struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
85 void __iomem *ioaddr = pdata->ioaddr; 91 void __iomem *ioaddr = pdata->ioaddr_rtc;
86 unsigned int year, month, day, hour, minute, second, week; 92 unsigned int year, month, day, hour, minute, second, week;
87 unsigned int century; 93 unsigned int century;
88 94
@@ -127,10 +133,10 @@ static ssize_t ds1742_nvram_read(struct kobject *kobj, char *buf,
127 struct platform_device *pdev = 133 struct platform_device *pdev =
128 to_platform_device(container_of(kobj, struct device, kobj)); 134 to_platform_device(container_of(kobj, struct device, kobj));
129 struct rtc_plat_data *pdata = platform_get_drvdata(pdev); 135 struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
130 void __iomem *ioaddr = pdata->ioaddr; 136 void __iomem *ioaddr = pdata->ioaddr_nvram;
131 ssize_t count; 137 ssize_t count;
132 138
133 for (count = 0; size > 0 && pos < RTC_OFFSET; count++, size--) 139 for (count = 0; size > 0 && pos < pdata->size_nvram; count++, size--)
134 *buf++ = readb(ioaddr + pos++); 140 *buf++ = readb(ioaddr + pos++);
135 return count; 141 return count;
136} 142}
@@ -141,10 +147,10 @@ static ssize_t ds1742_nvram_write(struct kobject *kobj, char *buf,
141 struct platform_device *pdev = 147 struct platform_device *pdev =
142 to_platform_device(container_of(kobj, struct device, kobj)); 148 to_platform_device(container_of(kobj, struct device, kobj));
143 struct rtc_plat_data *pdata = platform_get_drvdata(pdev); 149 struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
144 void __iomem *ioaddr = pdata->ioaddr; 150 void __iomem *ioaddr = pdata->ioaddr_nvram;
145 ssize_t count; 151 ssize_t count;
146 152
147 for (count = 0; size > 0 && pos < RTC_OFFSET; count++, size--) 153 for (count = 0; size > 0 && pos < pdata->size_nvram; count++, size--)
148 writeb(*buf++, ioaddr + pos++); 154 writeb(*buf++, ioaddr + pos++);
149 return count; 155 return count;
150} 156}
@@ -155,7 +161,6 @@ static struct bin_attribute ds1742_nvram_attr = {
155 .mode = S_IRUGO | S_IWUGO, 161 .mode = S_IRUGO | S_IWUGO,
156 .owner = THIS_MODULE, 162 .owner = THIS_MODULE,
157 }, 163 },
158 .size = RTC_OFFSET,
159 .read = ds1742_nvram_read, 164 .read = ds1742_nvram_read,
160 .write = ds1742_nvram_write, 165 .write = ds1742_nvram_write,
161}; 166};
@@ -175,19 +180,23 @@ static int __init ds1742_rtc_probe(struct platform_device *pdev)
175 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); 180 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
176 if (!pdata) 181 if (!pdata)
177 return -ENOMEM; 182 return -ENOMEM;
178 if (!request_mem_region(res->start, RTC_REG_SIZE, pdev->name)) { 183 pdata->size = res->end - res->start + 1;
184 if (!request_mem_region(res->start, pdata->size, pdev->name)) {
179 ret = -EBUSY; 185 ret = -EBUSY;
180 goto out; 186 goto out;
181 } 187 }
182 pdata->baseaddr = res->start; 188 pdata->baseaddr = res->start;
183 ioaddr = ioremap(pdata->baseaddr, RTC_REG_SIZE); 189 ioaddr = ioremap(pdata->baseaddr, pdata->size);
184 if (!ioaddr) { 190 if (!ioaddr) {
185 ret = -ENOMEM; 191 ret = -ENOMEM;
186 goto out; 192 goto out;
187 } 193 }
188 pdata->ioaddr = ioaddr; 194 pdata->ioaddr_nvram = ioaddr;
195 pdata->size_nvram = pdata->size - RTC_SIZE;
196 pdata->ioaddr_rtc = ioaddr + pdata->size_nvram;
189 197
190 /* turn RTC on if it was not on */ 198 /* turn RTC on if it was not on */
199 ioaddr = pdata->ioaddr_rtc;
191 sec = readb(ioaddr + RTC_SECONDS); 200 sec = readb(ioaddr + RTC_SECONDS);
192 if (sec & RTC_STOP) { 201 if (sec & RTC_STOP) {
193 sec &= RTC_SECONDS_MASK; 202 sec &= RTC_SECONDS_MASK;
@@ -208,6 +217,8 @@ static int __init ds1742_rtc_probe(struct platform_device *pdev)
208 pdata->rtc = rtc; 217 pdata->rtc = rtc;
209 pdata->last_jiffies = jiffies; 218 pdata->last_jiffies = jiffies;
210 platform_set_drvdata(pdev, pdata); 219 platform_set_drvdata(pdev, pdata);
220 ds1742_nvram_attr.size = max(ds1742_nvram_attr.size,
221 pdata->size_nvram);
211 ret = sysfs_create_bin_file(&pdev->dev.kobj, &ds1742_nvram_attr); 222 ret = sysfs_create_bin_file(&pdev->dev.kobj, &ds1742_nvram_attr);
212 if (ret) 223 if (ret)
213 goto out; 224 goto out;
@@ -215,10 +226,10 @@ static int __init ds1742_rtc_probe(struct platform_device *pdev)
215 out: 226 out:
216 if (pdata->rtc) 227 if (pdata->rtc)
217 rtc_device_unregister(pdata->rtc); 228 rtc_device_unregister(pdata->rtc);
218 if (ioaddr) 229 if (pdata->ioaddr_nvram)
219 iounmap(ioaddr); 230 iounmap(pdata->ioaddr_nvram);
220 if (pdata->baseaddr) 231 if (pdata->baseaddr)
221 release_mem_region(pdata->baseaddr, RTC_REG_SIZE); 232 release_mem_region(pdata->baseaddr, pdata->size);
222 kfree(pdata); 233 kfree(pdata);
223 return ret; 234 return ret;
224} 235}
@@ -229,8 +240,8 @@ static int __devexit ds1742_rtc_remove(struct platform_device *pdev)
229 240
230 sysfs_remove_bin_file(&pdev->dev.kobj, &ds1742_nvram_attr); 241 sysfs_remove_bin_file(&pdev->dev.kobj, &ds1742_nvram_attr);
231 rtc_device_unregister(pdata->rtc); 242 rtc_device_unregister(pdata->rtc);
232 iounmap(pdata->ioaddr); 243 iounmap(pdata->ioaddr_nvram);
233 release_mem_region(pdata->baseaddr, RTC_REG_SIZE); 244 release_mem_region(pdata->baseaddr, pdata->size);
234 kfree(pdata); 245 kfree(pdata);
235 return 0; 246 return 0;
236} 247}
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
new file mode 100644
index 000000000000..eac5fb1fc02f
--- /dev/null
+++ b/drivers/rtc/rtc-omap.c
@@ -0,0 +1,572 @@
1/*
2 * TI OMAP1 Real Time Clock interface for Linux
3 *
4 * Copyright (C) 2003 MontaVista Software, Inc.
5 * Author: George G. Davis <gdavis@mvista.com> or <source@mvista.com>
6 *
7 * Copyright (C) 2006 David Brownell (new RTC framework)
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
13 */
14
15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/module.h>
18#include <linux/ioport.h>
19#include <linux/delay.h>
20#include <linux/rtc.h>
21#include <linux/bcd.h>
22#include <linux/platform_device.h>
23
24#include <asm/io.h>
25#include <asm/mach/time.h>
26
27
28/* The OMAP1 RTC is a year/month/day/hours/minutes/seconds BCD clock
29 * with century-range alarm matching, driven by the 32kHz clock.
30 *
31 * The main user-visible ways it differs from PC RTCs are by omitting
32 * "don't care" alarm fields and sub-second periodic IRQs, and having
33 * an autoadjust mechanism to calibrate to the true oscillator rate.
34 *
35 * Board-specific wiring options include using split power mode with
36 * RTC_OFF_NOFF used as the reset signal (so the RTC won't be reset),
37 * and wiring RTC_WAKE_INT (so the RTC alarm can wake the system from
38 * low power modes). See the BOARD-SPECIFIC CUSTOMIZATION comment.
39 */
40
41#define OMAP_RTC_BASE 0xfffb4800
42
43/* RTC registers */
44#define OMAP_RTC_SECONDS_REG 0x00
45#define OMAP_RTC_MINUTES_REG 0x04
46#define OMAP_RTC_HOURS_REG 0x08
47#define OMAP_RTC_DAYS_REG 0x0C
48#define OMAP_RTC_MONTHS_REG 0x10
49#define OMAP_RTC_YEARS_REG 0x14
50#define OMAP_RTC_WEEKS_REG 0x18
51
52#define OMAP_RTC_ALARM_SECONDS_REG 0x20
53#define OMAP_RTC_ALARM_MINUTES_REG 0x24
54#define OMAP_RTC_ALARM_HOURS_REG 0x28
55#define OMAP_RTC_ALARM_DAYS_REG 0x2c
56#define OMAP_RTC_ALARM_MONTHS_REG 0x30
57#define OMAP_RTC_ALARM_YEARS_REG 0x34
58
59#define OMAP_RTC_CTRL_REG 0x40
60#define OMAP_RTC_STATUS_REG 0x44
61#define OMAP_RTC_INTERRUPTS_REG 0x48
62
63#define OMAP_RTC_COMP_LSB_REG 0x4c
64#define OMAP_RTC_COMP_MSB_REG 0x50
65#define OMAP_RTC_OSC_REG 0x54
66
67/* OMAP_RTC_CTRL_REG bit fields: */
68#define OMAP_RTC_CTRL_SPLIT (1<<7)
69#define OMAP_RTC_CTRL_DISABLE (1<<6)
70#define OMAP_RTC_CTRL_SET_32_COUNTER (1<<5)
71#define OMAP_RTC_CTRL_TEST (1<<4)
72#define OMAP_RTC_CTRL_MODE_12_24 (1<<3)
73#define OMAP_RTC_CTRL_AUTO_COMP (1<<2)
74#define OMAP_RTC_CTRL_ROUND_30S (1<<1)
75#define OMAP_RTC_CTRL_STOP (1<<0)
76
77/* OMAP_RTC_STATUS_REG bit fields: */
78#define OMAP_RTC_STATUS_POWER_UP (1<<7)
79#define OMAP_RTC_STATUS_ALARM (1<<6)
80#define OMAP_RTC_STATUS_1D_EVENT (1<<5)
81#define OMAP_RTC_STATUS_1H_EVENT (1<<4)
82#define OMAP_RTC_STATUS_1M_EVENT (1<<3)
83#define OMAP_RTC_STATUS_1S_EVENT (1<<2)
84#define OMAP_RTC_STATUS_RUN (1<<1)
85#define OMAP_RTC_STATUS_BUSY (1<<0)
86
87/* OMAP_RTC_INTERRUPTS_REG bit fields: */
88#define OMAP_RTC_INTERRUPTS_IT_ALARM (1<<3)
89#define OMAP_RTC_INTERRUPTS_IT_TIMER (1<<2)
90
91
92#define rtc_read(addr) omap_readb(OMAP_RTC_BASE + (addr))
93#define rtc_write(val, addr) omap_writeb(val, OMAP_RTC_BASE + (addr))
94
95
96/* platform_bus isn't hotpluggable, so for static linkage it'd be safe
97 * to get rid of probe() and remove() code ... too bad the driver struct
98 * remembers probe(), that's about 25% of the runtime footprint!!
99 */
100#ifndef MODULE
101#undef __devexit
102#undef __devexit_p
103#define __devexit __exit
104#define __devexit_p __exit_p
105#endif
106
107
108/* we rely on the rtc framework to handle locking (rtc->ops_lock),
109 * so the only other requirement is that register accesses which
110 * require BUSY to be clear are made with IRQs locally disabled
111 */
112static void rtc_wait_not_busy(void)
113{
114 int count = 0;
115 u8 status;
116
117 /* BUSY may stay active for 1/32768 second (~30 usec) */
118 for (count = 0; count < 50; count++) {
119 status = rtc_read(OMAP_RTC_STATUS_REG);
120 if ((status & (u8)OMAP_RTC_STATUS_BUSY) == 0)
121 break;
122 udelay(1);
123 }
124 /* now we have ~15 usec to read/write various registers */
125}
126
127static irqreturn_t rtc_irq(int irq, void *class_dev)
128{
129 unsigned long events = 0;
130 u8 irq_data;
131
132 irq_data = rtc_read(OMAP_RTC_STATUS_REG);
133
134 /* alarm irq? */
135 if (irq_data & OMAP_RTC_STATUS_ALARM) {
136 rtc_write(OMAP_RTC_STATUS_ALARM, OMAP_RTC_STATUS_REG);
137 events |= RTC_IRQF | RTC_AF;
138 }
139
140 /* 1/sec periodic/update irq? */
141 if (irq_data & OMAP_RTC_STATUS_1S_EVENT)
142 events |= RTC_IRQF | RTC_UF;
143
144 rtc_update_irq(class_dev, 1, events);
145
146 return IRQ_HANDLED;
147}
148
149#ifdef CONFIG_RTC_INTF_DEV
150
151static int
152omap_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
153{
154 u8 reg;
155
156 switch (cmd) {
157 case RTC_AIE_OFF:
158 case RTC_AIE_ON:
159 case RTC_UIE_OFF:
160 case RTC_UIE_ON:
161 break;
162 default:
163 return -ENOIOCTLCMD;
164 }
165
166 local_irq_disable();
167 rtc_wait_not_busy();
168 reg = rtc_read(OMAP_RTC_INTERRUPTS_REG);
169 switch (cmd) {
170 /* AIE = Alarm Interrupt Enable */
171 case RTC_AIE_OFF:
172 reg &= ~OMAP_RTC_INTERRUPTS_IT_ALARM;
173 break;
174 case RTC_AIE_ON:
175 reg |= OMAP_RTC_INTERRUPTS_IT_ALARM;
176 break;
177 /* UIE = Update Interrupt Enable (1/second) */
178 case RTC_UIE_OFF:
179 reg &= ~OMAP_RTC_INTERRUPTS_IT_TIMER;
180 break;
181 case RTC_UIE_ON:
182 reg |= OMAP_RTC_INTERRUPTS_IT_TIMER;
183 break;
184 }
185 rtc_wait_not_busy();
186 rtc_write(reg, OMAP_RTC_INTERRUPTS_REG);
187 local_irq_enable();
188
189 return 0;
190}
191
192#else
193#define omap_rtc_ioctl NULL
194#endif
195
196/* this hardware doesn't support "don't care" alarm fields */
197static int tm2bcd(struct rtc_time *tm)
198{
199 if (rtc_valid_tm(tm) != 0)
200 return -EINVAL;
201
202 tm->tm_sec = BIN2BCD(tm->tm_sec);
203 tm->tm_min = BIN2BCD(tm->tm_min);
204 tm->tm_hour = BIN2BCD(tm->tm_hour);
205 tm->tm_mday = BIN2BCD(tm->tm_mday);
206
207 tm->tm_mon = BIN2BCD(tm->tm_mon + 1);
208
209 /* epoch == 1900 */
210 if (tm->tm_year < 100 || tm->tm_year > 199)
211 return -EINVAL;
212 tm->tm_year = BIN2BCD(tm->tm_year - 100);
213
214 return 0;
215}
216
217static void bcd2tm(struct rtc_time *tm)
218{
219 tm->tm_sec = BCD2BIN(tm->tm_sec);
220 tm->tm_min = BCD2BIN(tm->tm_min);
221 tm->tm_hour = BCD2BIN(tm->tm_hour);
222 tm->tm_mday = BCD2BIN(tm->tm_mday);
223 tm->tm_mon = BCD2BIN(tm->tm_mon) - 1;
224 /* epoch == 1900 */
225 tm->tm_year = BCD2BIN(tm->tm_year) + 100;
226}
227
228
229static int omap_rtc_read_time(struct device *dev, struct rtc_time *tm)
230{
231 /* we don't report wday/yday/isdst ... */
232 local_irq_disable();
233 rtc_wait_not_busy();
234
235 tm->tm_sec = rtc_read(OMAP_RTC_SECONDS_REG);
236 tm->tm_min = rtc_read(OMAP_RTC_MINUTES_REG);
237 tm->tm_hour = rtc_read(OMAP_RTC_HOURS_REG);
238 tm->tm_mday = rtc_read(OMAP_RTC_DAYS_REG);
239 tm->tm_mon = rtc_read(OMAP_RTC_MONTHS_REG);
240 tm->tm_year = rtc_read(OMAP_RTC_YEARS_REG);
241
242 local_irq_enable();
243
244 bcd2tm(tm);
245 return 0;
246}
247
248static int omap_rtc_set_time(struct device *dev, struct rtc_time *tm)
249{
250 if (tm2bcd(tm) < 0)
251 return -EINVAL;
252 local_irq_disable();
253 rtc_wait_not_busy();
254
255 rtc_write(tm->tm_year, OMAP_RTC_YEARS_REG);
256 rtc_write(tm->tm_mon, OMAP_RTC_MONTHS_REG);
257 rtc_write(tm->tm_mday, OMAP_RTC_DAYS_REG);
258 rtc_write(tm->tm_hour, OMAP_RTC_HOURS_REG);
259 rtc_write(tm->tm_min, OMAP_RTC_MINUTES_REG);
260 rtc_write(tm->tm_sec, OMAP_RTC_SECONDS_REG);
261
262 local_irq_enable();
263
264 return 0;
265}
266
267static int omap_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm)
268{
269 local_irq_disable();
270 rtc_wait_not_busy();
271
272 alm->time.tm_sec = rtc_read(OMAP_RTC_ALARM_SECONDS_REG);
273 alm->time.tm_min = rtc_read(OMAP_RTC_ALARM_MINUTES_REG);
274 alm->time.tm_hour = rtc_read(OMAP_RTC_ALARM_HOURS_REG);
275 alm->time.tm_mday = rtc_read(OMAP_RTC_ALARM_DAYS_REG);
276 alm->time.tm_mon = rtc_read(OMAP_RTC_ALARM_MONTHS_REG);
277 alm->time.tm_year = rtc_read(OMAP_RTC_ALARM_YEARS_REG);
278
279 local_irq_enable();
280
281 bcd2tm(&alm->time);
282 alm->pending = !!(rtc_read(OMAP_RTC_INTERRUPTS_REG)
283 & OMAP_RTC_INTERRUPTS_IT_ALARM);
284 alm->enabled = alm->pending && device_may_wakeup(dev);
285
286 return 0;
287}
288
289static int omap_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
290{
291 u8 reg;
292
293 /* Much userspace code uses RTC_ALM_SET, thus "don't care" for
294 * day/month/year specifies alarms up to 24 hours in the future.
295 * So we need to handle that ... but let's ignore the "don't care"
296 * values for hours/minutes/seconds.
297 */
298 if (alm->time.tm_mday <= 0
299 && alm->time.tm_mon < 0
300 && alm->time.tm_year < 0) {
301 struct rtc_time tm;
302 unsigned long now, then;
303
304 omap_rtc_read_time(dev, &tm);
305 rtc_tm_to_time(&tm, &now);
306
307 alm->time.tm_mday = tm.tm_mday;
308 alm->time.tm_mon = tm.tm_mon;
309 alm->time.tm_year = tm.tm_year;
310 rtc_tm_to_time(&alm->time, &then);
311
312 /* sometimes the alarm wraps into tomorrow */
313 if (then < now) {
314 rtc_time_to_tm(now + 24 * 60 * 60, &tm);
315 alm->time.tm_mday = tm.tm_mday;
316 alm->time.tm_mon = tm.tm_mon;
317 alm->time.tm_year = tm.tm_year;
318 }
319 }
320
321 if (tm2bcd(&alm->time) < 0)
322 return -EINVAL;
323
324 local_irq_disable();
325 rtc_wait_not_busy();
326
327 rtc_write(alm->time.tm_year, OMAP_RTC_ALARM_YEARS_REG);
328 rtc_write(alm->time.tm_mon, OMAP_RTC_ALARM_MONTHS_REG);
329 rtc_write(alm->time.tm_mday, OMAP_RTC_ALARM_DAYS_REG);
330 rtc_write(alm->time.tm_hour, OMAP_RTC_ALARM_HOURS_REG);
331 rtc_write(alm->time.tm_min, OMAP_RTC_ALARM_MINUTES_REG);
332 rtc_write(alm->time.tm_sec, OMAP_RTC_ALARM_SECONDS_REG);
333
334 reg = rtc_read(OMAP_RTC_INTERRUPTS_REG);
335 if (alm->enabled)
336 reg |= OMAP_RTC_INTERRUPTS_IT_ALARM;
337 else
338 reg &= ~OMAP_RTC_INTERRUPTS_IT_ALARM;
339 rtc_write(reg, OMAP_RTC_INTERRUPTS_REG);
340
341 local_irq_enable();
342
343 return 0;
344}
345
346static struct rtc_class_ops omap_rtc_ops = {
347 .ioctl = omap_rtc_ioctl,
348 .read_time = omap_rtc_read_time,
349 .set_time = omap_rtc_set_time,
350 .read_alarm = omap_rtc_read_alarm,
351 .set_alarm = omap_rtc_set_alarm,
352};
353
354static int omap_rtc_alarm;
355static int omap_rtc_timer;
356
357static int __devinit omap_rtc_probe(struct platform_device *pdev)
358{
359 struct resource *res, *mem;
360 struct rtc_device *rtc;
361 u8 reg, new_ctrl;
362
363 omap_rtc_timer = platform_get_irq(pdev, 0);
364 if (omap_rtc_timer <= 0) {
365 pr_debug("%s: no update irq?\n", pdev->name);
366 return -ENOENT;
367 }
368
369 omap_rtc_alarm = platform_get_irq(pdev, 1);
370 if (omap_rtc_alarm <= 0) {
371 pr_debug("%s: no alarm irq?\n", pdev->name);
372 return -ENOENT;
373 }
374
375 /* NOTE: using static mapping for RTC registers */
376 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
377 if (res && res->start != OMAP_RTC_BASE) {
378 pr_debug("%s: RTC registers at %08x, expected %08x\n",
379 pdev->name, (unsigned) res->start, OMAP_RTC_BASE);
380 return -ENOENT;
381 }
382
383 if (res)
384 mem = request_mem_region(res->start,
385 res->end - res->start + 1,
386 pdev->name);
387 else
388 mem = NULL;
389 if (!mem) {
390 pr_debug("%s: RTC registers at %08x are not free\n",
391 pdev->name, OMAP_RTC_BASE);
392 return -EBUSY;
393 }
394
395 rtc = rtc_device_register(pdev->name, &pdev->dev,
396 &omap_rtc_ops, THIS_MODULE);
397 if (IS_ERR(rtc)) {
398 pr_debug("%s: can't register RTC device, err %ld\n",
399 pdev->name, PTR_ERR(rtc));
400 goto fail;
401 }
402 platform_set_drvdata(pdev, rtc);
403 class_set_devdata(&rtc->class_dev, mem);
404
405 /* clear pending irqs, and set 1/second periodic,
406 * which we'll use instead of update irqs
407 */
408 rtc_write(0, OMAP_RTC_INTERRUPTS_REG);
409
410 /* clear old status */
411 reg = rtc_read(OMAP_RTC_STATUS_REG);
412 if (reg & (u8) OMAP_RTC_STATUS_POWER_UP) {
413 pr_info("%s: RTC power up reset detected\n",
414 pdev->name);
415 rtc_write(OMAP_RTC_STATUS_POWER_UP, OMAP_RTC_STATUS_REG);
416 }
417 if (reg & (u8) OMAP_RTC_STATUS_ALARM)
418 rtc_write(OMAP_RTC_STATUS_ALARM, OMAP_RTC_STATUS_REG);
419
420 /* handle periodic and alarm irqs */
421 if (request_irq(omap_rtc_timer, rtc_irq, SA_INTERRUPT,
422 rtc->class_dev.class_id, &rtc->class_dev)) {
423 pr_debug("%s: RTC timer interrupt IRQ%d already claimed\n",
424 pdev->name, omap_rtc_timer);
425 goto fail0;
426 }
427 if (request_irq(omap_rtc_alarm, rtc_irq, SA_INTERRUPT,
428 rtc->class_dev.class_id, &rtc->class_dev)) {
429 pr_debug("%s: RTC alarm interrupt IRQ%d already claimed\n",
430 pdev->name, omap_rtc_alarm);
431 goto fail1;
432 }
433
434 /* On boards with split power, RTC_ON_NOFF won't reset the RTC */
435 reg = rtc_read(OMAP_RTC_CTRL_REG);
436 if (reg & (u8) OMAP_RTC_CTRL_STOP)
437 pr_info("%s: already running\n", pdev->name);
438
439 /* force to 24 hour mode */
440 new_ctrl = reg & ~(OMAP_RTC_CTRL_SPLIT|OMAP_RTC_CTRL_AUTO_COMP);
441 new_ctrl |= OMAP_RTC_CTRL_STOP;
442
443 /* BOARD-SPECIFIC CUSTOMIZATION CAN GO HERE:
444 *
445 * - Boards wired so that RTC_WAKE_INT does something, and muxed
446 * right (W13_1610_RTC_WAKE_INT is the default after chip reset),
447 * should initialize the device wakeup flag appropriately.
448 *
449 * - Boards wired so RTC_ON_nOFF is used as the reset signal,
450 * rather than nPWRON_RESET, should forcibly enable split
451 * power mode. (Some chip errata report that RTC_CTRL_SPLIT
452 * is write-only, and always reads as zero...)
453 */
454 device_init_wakeup(&pdev->dev, 0);
455
456 if (new_ctrl & (u8) OMAP_RTC_CTRL_SPLIT)
457 pr_info("%s: split power mode\n", pdev->name);
458
459 if (reg != new_ctrl)
460 rtc_write(new_ctrl, OMAP_RTC_CTRL_REG);
461
462 return 0;
463
464fail1:
465 free_irq(omap_rtc_timer, NULL);
466fail0:
467 rtc_device_unregister(rtc);
468fail:
469 release_resource(mem);
470 return -EIO;
471}
472
473static int __devexit omap_rtc_remove(struct platform_device *pdev)
474{
475 struct rtc_device *rtc = platform_get_drvdata(pdev);;
476
477 device_init_wakeup(&pdev->dev, 0);
478
479 /* leave rtc running, but disable irqs */
480 rtc_write(0, OMAP_RTC_INTERRUPTS_REG);
481
482 free_irq(omap_rtc_timer, rtc);
483 free_irq(omap_rtc_alarm, rtc);
484
485 release_resource(class_get_devdata(&rtc->class_dev));
486 rtc_device_unregister(rtc);
487 return 0;
488}
489
490#ifdef CONFIG_PM
491
492static struct timespec rtc_delta;
493static u8 irqstat;
494
495static int omap_rtc_suspend(struct platform_device *pdev, pm_message_t state)
496{
497 struct rtc_time rtc_tm;
498 struct timespec time;
499
500 time.tv_nsec = 0;
501 omap_rtc_read_time(NULL, &rtc_tm);
502 rtc_tm_to_time(&rtc_tm, &time.tv_sec);
503
504 save_time_delta(&rtc_delta, &time);
505 irqstat = rtc_read(OMAP_RTC_INTERRUPTS_REG);
506
507 /* FIXME the RTC alarm is not currently acting as a wakeup event
508 * source, and in fact this enable() call is just saving a flag
509 * that's never used...
510 */
511 if (device_may_wakeup(&pdev->dev))
512 enable_irq_wake(omap_rtc_alarm);
513 else
514 rtc_write(0, OMAP_RTC_INTERRUPTS_REG);
515
516 return 0;
517}
518
519static int omap_rtc_resume(struct platform_device *pdev)
520{
521 struct rtc_time rtc_tm;
522 struct timespec time;
523
524 time.tv_nsec = 0;
525 omap_rtc_read_time(NULL, &rtc_tm);
526 rtc_tm_to_time(&rtc_tm, &time.tv_sec);
527
528 restore_time_delta(&rtc_delta, &time);
529 if (device_may_wakeup(&pdev->dev))
530 disable_irq_wake(omap_rtc_alarm);
531 else
532 rtc_write(irqstat, OMAP_RTC_INTERRUPTS_REG);
533 return 0;
534}
535
536#else
537#define omap_rtc_suspend NULL
538#define omap_rtc_resume NULL
539#endif
540
541static void omap_rtc_shutdown(struct platform_device *pdev)
542{
543 rtc_write(0, OMAP_RTC_INTERRUPTS_REG);
544}
545
546MODULE_ALIAS("omap_rtc");
547static struct platform_driver omap_rtc_driver = {
548 .probe = omap_rtc_probe,
549 .remove = __devexit_p(omap_rtc_remove),
550 .suspend = omap_rtc_suspend,
551 .resume = omap_rtc_resume,
552 .shutdown = omap_rtc_shutdown,
553 .driver = {
554 .name = "omap_rtc",
555 .owner = THIS_MODULE,
556 },
557};
558
559static int __init rtc_init(void)
560{
561 return platform_driver_register(&omap_rtc_driver);
562}
563module_init(rtc_init);
564
565static void __exit rtc_exit(void)
566{
567 platform_driver_unregister(&omap_rtc_driver);
568}
569module_exit(rtc_exit);
570
571MODULE_AUTHOR("George G. Davis (and others)");
572MODULE_LICENSE("GPL");
diff --git a/drivers/rtc/rtc-rs5c372.c b/drivers/rtc/rtc-rs5c372.c
index 2a86632580f1..e2c7698fdba3 100644
--- a/drivers/rtc/rtc-rs5c372.c
+++ b/drivers/rtc/rtc-rs5c372.c
@@ -13,7 +13,7 @@
13#include <linux/rtc.h> 13#include <linux/rtc.h>
14#include <linux/bcd.h> 14#include <linux/bcd.h>
15 15
16#define DRV_VERSION "0.2" 16#define DRV_VERSION "0.3"
17 17
18/* Addresses to scan */ 18/* Addresses to scan */
19static unsigned short normal_i2c[] = { /* 0x32,*/ I2C_CLIENT_END }; 19static unsigned short normal_i2c[] = { /* 0x32,*/ I2C_CLIENT_END };
@@ -39,6 +39,14 @@ static int rs5c372_attach(struct i2c_adapter *adapter);
39static int rs5c372_detach(struct i2c_client *client); 39static int rs5c372_detach(struct i2c_client *client);
40static int rs5c372_probe(struct i2c_adapter *adapter, int address, int kind); 40static int rs5c372_probe(struct i2c_adapter *adapter, int address, int kind);
41 41
42struct rs5c372 {
43 u8 reg_addr;
44 u8 regs[17];
45 struct i2c_msg msg[1];
46 struct i2c_client client;
47 struct rtc_device *rtc;
48};
49
42static struct i2c_driver rs5c372_driver = { 50static struct i2c_driver rs5c372_driver = {
43 .driver = { 51 .driver = {
44 .name = "rs5c372", 52 .name = "rs5c372",
@@ -49,18 +57,16 @@ static struct i2c_driver rs5c372_driver = {
49 57
50static int rs5c372_get_datetime(struct i2c_client *client, struct rtc_time *tm) 58static int rs5c372_get_datetime(struct i2c_client *client, struct rtc_time *tm)
51{ 59{
52 unsigned char buf[7] = { RS5C372_REG_BASE };
53 60
54 /* this implements the 1st reading method, according 61 struct rs5c372 *rs5c372 = i2c_get_clientdata(client);
55 * to the datasheet. buf[0] is initialized with 62 u8 *buf = &(rs5c372->regs[1]);
56 * address ptr and transmission format register. 63
64 /* this implements the 3rd reading method, according
65 * to the datasheet. rs5c372 defaults to internal
66 * address 0xF, so 0x0 is in regs[1]
57 */ 67 */
58 struct i2c_msg msgs[] = {
59 { client->addr, 0, 1, buf },
60 { client->addr, I2C_M_RD, 7, buf },
61 };
62 68
63 if ((i2c_transfer(client->adapter, msgs, 2)) != 2) { 69 if ((i2c_transfer(client->adapter, rs5c372->msg, 1)) != 1) {
64 dev_err(&client->dev, "%s: read error\n", __FUNCTION__); 70 dev_err(&client->dev, "%s: read error\n", __FUNCTION__);
65 return -EIO; 71 return -EIO;
66 } 72 }
@@ -114,25 +120,16 @@ static int rs5c372_set_datetime(struct i2c_client *client, struct rtc_time *tm)
114 120
115static int rs5c372_get_trim(struct i2c_client *client, int *osc, int *trim) 121static int rs5c372_get_trim(struct i2c_client *client, int *osc, int *trim)
116{ 122{
117 unsigned char buf = RS5C372_REG_TRIM; 123 struct rs5c372 *rs5c372 = i2c_get_clientdata(client);
118 124 u8 tmp = rs5c372->regs[RS5C372_REG_TRIM + 1];
119 struct i2c_msg msgs[] = {
120 { client->addr, 0, 1, &buf },
121 { client->addr, I2C_M_RD, 1, &buf },
122 };
123
124 if ((i2c_transfer(client->adapter, msgs, 2)) != 2) {
125 dev_err(&client->dev, "%s: read error\n", __FUNCTION__);
126 return -EIO;
127 }
128
129 dev_dbg(&client->dev, "%s: raw trim=%x\n", __FUNCTION__, *trim);
130 125
131 if (osc) 126 if (osc)
132 *osc = (buf & RS5C372_TRIM_XSL) ? 32000 : 32768; 127 *osc = (tmp & RS5C372_TRIM_XSL) ? 32000 : 32768;
133 128
134 if (trim) 129 if (trim) {
135 *trim = buf & RS5C372_TRIM_MASK; 130 *trim = tmp & RS5C372_TRIM_MASK;
131 dev_dbg(&client->dev, "%s: raw trim=%x\n", __FUNCTION__, *trim);
132 }
136 133
137 return 0; 134 return 0;
138} 135}
@@ -201,7 +198,7 @@ static int rs5c372_probe(struct i2c_adapter *adapter, int address, int kind)
201{ 198{
202 int err = 0; 199 int err = 0;
203 struct i2c_client *client; 200 struct i2c_client *client;
204 struct rtc_device *rtc; 201 struct rs5c372 *rs5c372;
205 202
206 dev_dbg(&adapter->dev, "%s\n", __FUNCTION__); 203 dev_dbg(&adapter->dev, "%s\n", __FUNCTION__);
207 204
@@ -210,10 +207,11 @@ static int rs5c372_probe(struct i2c_adapter *adapter, int address, int kind)
210 goto exit; 207 goto exit;
211 } 208 }
212 209
213 if (!(client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL))) { 210 if (!(rs5c372 = kzalloc(sizeof(struct rs5c372), GFP_KERNEL))) {
214 err = -ENOMEM; 211 err = -ENOMEM;
215 goto exit; 212 goto exit;
216 } 213 }
214 client = &rs5c372->client;
217 215
218 /* I2C client */ 216 /* I2C client */
219 client->addr = address; 217 client->addr = address;
@@ -222,32 +220,47 @@ static int rs5c372_probe(struct i2c_adapter *adapter, int address, int kind)
222 220
223 strlcpy(client->name, rs5c372_driver.driver.name, I2C_NAME_SIZE); 221 strlcpy(client->name, rs5c372_driver.driver.name, I2C_NAME_SIZE);
224 222
223 i2c_set_clientdata(client, rs5c372);
224
225 rs5c372->msg[0].addr = address;
226 rs5c372->msg[0].flags = I2C_M_RD;
227 rs5c372->msg[0].len = sizeof(rs5c372->regs);
228 rs5c372->msg[0].buf = rs5c372->regs;
229
225 /* Inform the i2c layer */ 230 /* Inform the i2c layer */
226 if ((err = i2c_attach_client(client))) 231 if ((err = i2c_attach_client(client)))
227 goto exit_kfree; 232 goto exit_kfree;
228 233
229 dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n"); 234 dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n");
230 235
231 rtc = rtc_device_register(rs5c372_driver.driver.name, &client->dev, 236 rs5c372->rtc = rtc_device_register(rs5c372_driver.driver.name,
232 &rs5c372_rtc_ops, THIS_MODULE); 237 &client->dev, &rs5c372_rtc_ops, THIS_MODULE);
233 238
234 if (IS_ERR(rtc)) { 239 if (IS_ERR(rs5c372->rtc)) {
235 err = PTR_ERR(rtc); 240 err = PTR_ERR(rs5c372->rtc);
236 goto exit_detach; 241 goto exit_detach;
237 } 242 }
238 243
239 i2c_set_clientdata(client, rtc); 244 err = device_create_file(&client->dev, &dev_attr_trim);
240 245 if (err)
241 device_create_file(&client->dev, &dev_attr_trim); 246 goto exit_devreg;
242 device_create_file(&client->dev, &dev_attr_osc); 247 err = device_create_file(&client->dev, &dev_attr_osc);
248 if (err)
249 goto exit_trim;
243 250
244 return 0; 251 return 0;
245 252
253exit_trim:
254 device_remove_file(&client->dev, &dev_attr_trim);
255
256exit_devreg:
257 rtc_device_unregister(rs5c372->rtc);
258
246exit_detach: 259exit_detach:
247 i2c_detach_client(client); 260 i2c_detach_client(client);
248 261
249exit_kfree: 262exit_kfree:
250 kfree(client); 263 kfree(rs5c372);
251 264
252exit: 265exit:
253 return err; 266 return err;
@@ -256,16 +269,15 @@ exit:
256static int rs5c372_detach(struct i2c_client *client) 269static int rs5c372_detach(struct i2c_client *client)
257{ 270{
258 int err; 271 int err;
259 struct rtc_device *rtc = i2c_get_clientdata(client); 272 struct rs5c372 *rs5c372 = i2c_get_clientdata(client);
260 273
261 if (rtc) 274 if (rs5c372->rtc)
262 rtc_device_unregister(rtc); 275 rtc_device_unregister(rs5c372->rtc);
263 276
264 if ((err = i2c_detach_client(client))) 277 if ((err = i2c_detach_client(client)))
265 return err; 278 return err;
266 279
267 kfree(client); 280 kfree(rs5c372);
268
269 return 0; 281 return 0;
270} 282}
271 283
diff --git a/drivers/rtc/rtc-test.c b/drivers/rtc/rtc-test.c
index bc4bd24508a2..f50a1b8e1607 100644
--- a/drivers/rtc/rtc-test.c
+++ b/drivers/rtc/rtc-test.c
@@ -99,6 +99,7 @@ static ssize_t test_irq_store(struct device *dev,
99 struct rtc_device *rtc = platform_get_drvdata(plat_dev); 99 struct rtc_device *rtc = platform_get_drvdata(plat_dev);
100 100
101 retval = count; 101 retval = count;
102 local_irq_disable();
102 if (strncmp(buf, "tick", 4) == 0) 103 if (strncmp(buf, "tick", 4) == 0)
103 rtc_update_irq(&rtc->class_dev, 1, RTC_PF | RTC_IRQF); 104 rtc_update_irq(&rtc->class_dev, 1, RTC_PF | RTC_IRQF);
104 else if (strncmp(buf, "alarm", 5) == 0) 105 else if (strncmp(buf, "alarm", 5) == 0)
@@ -107,6 +108,7 @@ static ssize_t test_irq_store(struct device *dev,
107 rtc_update_irq(&rtc->class_dev, 1, RTC_UF | RTC_IRQF); 108 rtc_update_irq(&rtc->class_dev, 1, RTC_UF | RTC_IRQF);
108 else 109 else
109 retval = -EINVAL; 110 retval = -EINVAL;
111 local_irq_enable();
110 112
111 return retval; 113 return retval;
112} 114}
@@ -121,11 +123,18 @@ static int test_probe(struct platform_device *plat_dev)
121 err = PTR_ERR(rtc); 123 err = PTR_ERR(rtc);
122 return err; 124 return err;
123 } 125 }
124 device_create_file(&plat_dev->dev, &dev_attr_irq); 126
127 err = device_create_file(&plat_dev->dev, &dev_attr_irq);
128 if (err)
129 goto err;
125 130
126 platform_set_drvdata(plat_dev, rtc); 131 platform_set_drvdata(plat_dev, rtc);
127 132
128 return 0; 133 return 0;
134
135err:
136 rtc_device_unregister(rtc);
137 return err;
129} 138}
130 139
131static int __devexit test_remove(struct platform_device *plat_dev) 140static int __devexit test_remove(struct platform_device *plat_dev)
diff --git a/drivers/rtc/rtc-x1205.c b/drivers/rtc/rtc-x1205.c
index 522c69753bbf..9a67487d086b 100644
--- a/drivers/rtc/rtc-x1205.c
+++ b/drivers/rtc/rtc-x1205.c
@@ -562,11 +562,19 @@ static int x1205_probe(struct i2c_adapter *adapter, int address, int kind)
562 else 562 else
563 dev_err(&client->dev, "couldn't read status\n"); 563 dev_err(&client->dev, "couldn't read status\n");
564 564
565 device_create_file(&client->dev, &dev_attr_atrim); 565 err = device_create_file(&client->dev, &dev_attr_atrim);
566 device_create_file(&client->dev, &dev_attr_dtrim); 566 if (err) goto exit_devreg;
567 err = device_create_file(&client->dev, &dev_attr_dtrim);
568 if (err) goto exit_atrim;
567 569
568 return 0; 570 return 0;
569 571
572exit_atrim:
573 device_remove_file(&client->dev, &dev_attr_atrim);
574
575exit_devreg:
576 rtc_device_unregister(rtc);
577
570exit_detach: 578exit_detach:
571 i2c_detach_client(client); 579 i2c_detach_client(client);
572 580
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index 79ffef6bfaf8..2af2d9b53d18 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -54,7 +54,7 @@ static void dasd_flush_request_queue(struct dasd_device *);
54static void dasd_int_handler(struct ccw_device *, unsigned long, struct irb *); 54static void dasd_int_handler(struct ccw_device *, unsigned long, struct irb *);
55static int dasd_flush_ccw_queue(struct dasd_device *, int); 55static int dasd_flush_ccw_queue(struct dasd_device *, int);
56static void dasd_tasklet(struct dasd_device *); 56static void dasd_tasklet(struct dasd_device *);
57static void do_kick_device(void *data); 57static void do_kick_device(struct work_struct *);
58 58
59/* 59/*
60 * SECTION: Operations on the device structure. 60 * SECTION: Operations on the device structure.
@@ -100,7 +100,7 @@ dasd_alloc_device(void)
100 (unsigned long) device); 100 (unsigned long) device);
101 INIT_LIST_HEAD(&device->ccw_queue); 101 INIT_LIST_HEAD(&device->ccw_queue);
102 init_timer(&device->timer); 102 init_timer(&device->timer);
103 INIT_WORK(&device->kick_work, do_kick_device, device); 103 INIT_WORK(&device->kick_work, do_kick_device);
104 device->state = DASD_STATE_NEW; 104 device->state = DASD_STATE_NEW;
105 device->target = DASD_STATE_NEW; 105 device->target = DASD_STATE_NEW;
106 106
@@ -407,11 +407,9 @@ dasd_change_state(struct dasd_device *device)
407 * event daemon. 407 * event daemon.
408 */ 408 */
409static void 409static void
410do_kick_device(void *data) 410do_kick_device(struct work_struct *work)
411{ 411{
412 struct dasd_device *device; 412 struct dasd_device *device = container_of(work, struct dasd_device, kick_work);
413
414 device = (struct dasd_device *) data;
415 dasd_change_state(device); 413 dasd_change_state(device);
416 dasd_schedule_bh(device); 414 dasd_schedule_bh(device);
417 dasd_put_device(device); 415 dasd_put_device(device);
@@ -1264,15 +1262,21 @@ __dasd_check_expire(struct dasd_device * device)
1264 if (list_empty(&device->ccw_queue)) 1262 if (list_empty(&device->ccw_queue))
1265 return; 1263 return;
1266 cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, list); 1264 cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, list);
1267 if (cqr->status == DASD_CQR_IN_IO && cqr->expires != 0) { 1265 if ((cqr->status == DASD_CQR_IN_IO && cqr->expires != 0) &&
1268 if (time_after_eq(jiffies, cqr->expires + cqr->starttime)) { 1266 (time_after_eq(jiffies, cqr->expires + cqr->starttime))) {
1267 if (device->discipline->term_IO(cqr) != 0) {
1268 /* Hmpf, try again in 5 sec */
1269 dasd_set_timer(device, 5*HZ);
1270 DEV_MESSAGE(KERN_ERR, device,
1271 "internal error - timeout (%is) expired "
1272 "for cqr %p, termination failed, "
1273 "retrying in 5s",
1274 (cqr->expires/HZ), cqr);
1275 } else {
1269 DEV_MESSAGE(KERN_ERR, device, 1276 DEV_MESSAGE(KERN_ERR, device,
1270 "internal error - timeout (%is) expired " 1277 "internal error - timeout (%is) expired "
1271 "for cqr %p (%i retries left)", 1278 "for cqr %p (%i retries left)",
1272 (cqr->expires/HZ), cqr, cqr->retries); 1279 (cqr->expires/HZ), cqr, cqr->retries);
1273 if (device->discipline->term_IO(cqr) != 0)
1274 /* Hmpf, try again in 1/10 sec */
1275 dasd_set_timer(device, 10);
1276 } 1280 }
1277 } 1281 }
1278} 1282}
diff --git a/drivers/s390/block/dasd_devmap.c b/drivers/s390/block/dasd_devmap.c
index 91cf971f0652..cf28ccc57948 100644
--- a/drivers/s390/block/dasd_devmap.c
+++ b/drivers/s390/block/dasd_devmap.c
@@ -25,7 +25,7 @@
25 25
26#include "dasd_int.h" 26#include "dasd_int.h"
27 27
28kmem_cache_t *dasd_page_cache; 28struct kmem_cache *dasd_page_cache;
29EXPORT_SYMBOL_GPL(dasd_page_cache); 29EXPORT_SYMBOL_GPL(dasd_page_cache);
30 30
31/* 31/*
@@ -684,21 +684,26 @@ dasd_ro_store(struct device *dev, struct device_attribute *attr,
684 const char *buf, size_t count) 684 const char *buf, size_t count)
685{ 685{
686 struct dasd_devmap *devmap; 686 struct dasd_devmap *devmap;
687 int ro_flag; 687 int val;
688 char *endp;
688 689
689 devmap = dasd_devmap_from_cdev(to_ccwdev(dev)); 690 devmap = dasd_devmap_from_cdev(to_ccwdev(dev));
690 if (IS_ERR(devmap)) 691 if (IS_ERR(devmap))
691 return PTR_ERR(devmap); 692 return PTR_ERR(devmap);
692 ro_flag = buf[0] == '1'; 693
694 val = simple_strtoul(buf, &endp, 0);
695 if (((endp + 1) < (buf + count)) || (val > 1))
696 return -EINVAL;
697
693 spin_lock(&dasd_devmap_lock); 698 spin_lock(&dasd_devmap_lock);
694 if (ro_flag) 699 if (val)
695 devmap->features |= DASD_FEATURE_READONLY; 700 devmap->features |= DASD_FEATURE_READONLY;
696 else 701 else
697 devmap->features &= ~DASD_FEATURE_READONLY; 702 devmap->features &= ~DASD_FEATURE_READONLY;
698 if (devmap->device) 703 if (devmap->device)
699 devmap->device->features = devmap->features; 704 devmap->device->features = devmap->features;
700 if (devmap->device && devmap->device->gdp) 705 if (devmap->device && devmap->device->gdp)
701 set_disk_ro(devmap->device->gdp, ro_flag); 706 set_disk_ro(devmap->device->gdp, val);
702 spin_unlock(&dasd_devmap_lock); 707 spin_unlock(&dasd_devmap_lock);
703 return count; 708 return count;
704} 709}
@@ -729,17 +734,22 @@ dasd_use_diag_store(struct device *dev, struct device_attribute *attr,
729{ 734{
730 struct dasd_devmap *devmap; 735 struct dasd_devmap *devmap;
731 ssize_t rc; 736 ssize_t rc;
732 int use_diag; 737 int val;
738 char *endp;
733 739
734 devmap = dasd_devmap_from_cdev(to_ccwdev(dev)); 740 devmap = dasd_devmap_from_cdev(to_ccwdev(dev));
735 if (IS_ERR(devmap)) 741 if (IS_ERR(devmap))
736 return PTR_ERR(devmap); 742 return PTR_ERR(devmap);
737 use_diag = buf[0] == '1'; 743
744 val = simple_strtoul(buf, &endp, 0);
745 if (((endp + 1) < (buf + count)) || (val > 1))
746 return -EINVAL;
747
738 spin_lock(&dasd_devmap_lock); 748 spin_lock(&dasd_devmap_lock);
739 /* Changing diag discipline flag is only allowed in offline state. */ 749 /* Changing diag discipline flag is only allowed in offline state. */
740 rc = count; 750 rc = count;
741 if (!devmap->device) { 751 if (!devmap->device) {
742 if (use_diag) 752 if (val)
743 devmap->features |= DASD_FEATURE_USEDIAG; 753 devmap->features |= DASD_FEATURE_USEDIAG;
744 else 754 else
745 devmap->features &= ~DASD_FEATURE_USEDIAG; 755 devmap->features &= ~DASD_FEATURE_USEDIAG;
@@ -854,14 +864,20 @@ dasd_eer_store(struct device *dev, struct device_attribute *attr,
854 const char *buf, size_t count) 864 const char *buf, size_t count)
855{ 865{
856 struct dasd_devmap *devmap; 866 struct dasd_devmap *devmap;
857 int rc; 867 int val, rc;
868 char *endp;
858 869
859 devmap = dasd_devmap_from_cdev(to_ccwdev(dev)); 870 devmap = dasd_devmap_from_cdev(to_ccwdev(dev));
860 if (IS_ERR(devmap)) 871 if (IS_ERR(devmap))
861 return PTR_ERR(devmap); 872 return PTR_ERR(devmap);
862 if (!devmap->device) 873 if (!devmap->device)
863 return count; 874 return -ENODEV;
864 if (buf[0] == '1') { 875
876 val = simple_strtoul(buf, &endp, 0);
877 if (((endp + 1) < (buf + count)) || (val > 1))
878 return -EINVAL;
879
880 if (val) {
865 rc = dasd_eer_enable(devmap->device); 881 rc = dasd_eer_enable(devmap->device);
866 if (rc) 882 if (rc)
867 return rc; 883 return rc;
diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
index 5ecea3e4fdef..fdaa471e845f 100644
--- a/drivers/s390/block/dasd_eckd.c
+++ b/drivers/s390/block/dasd_eckd.c
@@ -1215,7 +1215,7 @@ dasd_eckd_build_cp(struct dasd_device * device, struct request *req)
1215 dst = page_address(bv->bv_page) + bv->bv_offset; 1215 dst = page_address(bv->bv_page) + bv->bv_offset;
1216 if (dasd_page_cache) { 1216 if (dasd_page_cache) {
1217 char *copy = kmem_cache_alloc(dasd_page_cache, 1217 char *copy = kmem_cache_alloc(dasd_page_cache,
1218 SLAB_DMA | __GFP_NOWARN); 1218 GFP_DMA | __GFP_NOWARN);
1219 if (copy && rq_data_dir(req) == WRITE) 1219 if (copy && rq_data_dir(req) == WRITE)
1220 memcpy(copy + bv->bv_offset, dst, bv->bv_len); 1220 memcpy(copy + bv->bv_offset, dst, bv->bv_len);
1221 if (copy) 1221 if (copy)
diff --git a/drivers/s390/block/dasd_fba.c b/drivers/s390/block/dasd_fba.c
index 80926c548228..b857fd5893fd 100644
--- a/drivers/s390/block/dasd_fba.c
+++ b/drivers/s390/block/dasd_fba.c
@@ -308,7 +308,7 @@ dasd_fba_build_cp(struct dasd_device * device, struct request *req)
308 dst = page_address(bv->bv_page) + bv->bv_offset; 308 dst = page_address(bv->bv_page) + bv->bv_offset;
309 if (dasd_page_cache) { 309 if (dasd_page_cache) {
310 char *copy = kmem_cache_alloc(dasd_page_cache, 310 char *copy = kmem_cache_alloc(dasd_page_cache,
311 SLAB_DMA | __GFP_NOWARN); 311 GFP_DMA | __GFP_NOWARN);
312 if (copy && rq_data_dir(req) == WRITE) 312 if (copy && rq_data_dir(req) == WRITE)
313 memcpy(copy + bv->bv_offset, dst, bv->bv_len); 313 memcpy(copy + bv->bv_offset, dst, bv->bv_len);
314 if (copy) 314 if (copy)
diff --git a/drivers/s390/block/dasd_int.h b/drivers/s390/block/dasd_int.h
index 9f52004f6fc2..dc5dd509434d 100644
--- a/drivers/s390/block/dasd_int.h
+++ b/drivers/s390/block/dasd_int.h
@@ -474,7 +474,7 @@ extern struct dasd_profile_info_t dasd_global_profile;
474extern unsigned int dasd_profile_level; 474extern unsigned int dasd_profile_level;
475extern struct block_device_operations dasd_device_operations; 475extern struct block_device_operations dasd_device_operations;
476 476
477extern kmem_cache_t *dasd_page_cache; 477extern struct kmem_cache *dasd_page_cache;
478 478
479struct dasd_ccw_req * 479struct dasd_ccw_req *
480dasd_kmalloc_request(char *, int, int, struct dasd_device *); 480dasd_kmalloc_request(char *, int, int, struct dasd_device *);
diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c
index d7de175d53f0..c9321b920e90 100644
--- a/drivers/s390/char/con3215.c
+++ b/drivers/s390/char/con3215.c
@@ -299,14 +299,14 @@ raw3215_timeout(unsigned long __data)
299 struct raw3215_info *raw = (struct raw3215_info *) __data; 299 struct raw3215_info *raw = (struct raw3215_info *) __data;
300 unsigned long flags; 300 unsigned long flags;
301 301
302 spin_lock_irqsave(raw->lock, flags); 302 spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags);
303 if (raw->flags & RAW3215_TIMER_RUNS) { 303 if (raw->flags & RAW3215_TIMER_RUNS) {
304 del_timer(&raw->timer); 304 del_timer(&raw->timer);
305 raw->flags &= ~RAW3215_TIMER_RUNS; 305 raw->flags &= ~RAW3215_TIMER_RUNS;
306 raw3215_mk_write_req(raw); 306 raw3215_mk_write_req(raw);
307 raw3215_start_io(raw); 307 raw3215_start_io(raw);
308 } 308 }
309 spin_unlock_irqrestore(raw->lock, flags); 309 spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags);
310} 310}
311 311
312/* 312/*
@@ -355,10 +355,10 @@ raw3215_tasklet(void *data)
355 unsigned long flags; 355 unsigned long flags;
356 356
357 raw = (struct raw3215_info *) data; 357 raw = (struct raw3215_info *) data;
358 spin_lock_irqsave(raw->lock, flags); 358 spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags);
359 raw3215_mk_write_req(raw); 359 raw3215_mk_write_req(raw);
360 raw3215_try_io(raw); 360 raw3215_try_io(raw);
361 spin_unlock_irqrestore(raw->lock, flags); 361 spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags);
362 /* Check for pending message from raw3215_irq */ 362 /* Check for pending message from raw3215_irq */
363 if (raw->message != NULL) { 363 if (raw->message != NULL) {
364 printk(raw->message, raw->msg_dstat, raw->msg_cstat); 364 printk(raw->message, raw->msg_dstat, raw->msg_cstat);
@@ -512,9 +512,9 @@ raw3215_make_room(struct raw3215_info *raw, unsigned int length)
512 if (RAW3215_BUFFER_SIZE - raw->count >= length) 512 if (RAW3215_BUFFER_SIZE - raw->count >= length)
513 break; 513 break;
514 /* there might be another cpu waiting for the lock */ 514 /* there might be another cpu waiting for the lock */
515 spin_unlock(raw->lock); 515 spin_unlock(get_ccwdev_lock(raw->cdev));
516 udelay(100); 516 udelay(100);
517 spin_lock(raw->lock); 517 spin_lock(get_ccwdev_lock(raw->cdev));
518 } 518 }
519} 519}
520 520
@@ -528,7 +528,7 @@ raw3215_write(struct raw3215_info *raw, const char *str, unsigned int length)
528 int c, count; 528 int c, count;
529 529
530 while (length > 0) { 530 while (length > 0) {
531 spin_lock_irqsave(raw->lock, flags); 531 spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags);
532 count = (length > RAW3215_BUFFER_SIZE) ? 532 count = (length > RAW3215_BUFFER_SIZE) ?
533 RAW3215_BUFFER_SIZE : length; 533 RAW3215_BUFFER_SIZE : length;
534 length -= count; 534 length -= count;
@@ -555,7 +555,7 @@ raw3215_write(struct raw3215_info *raw, const char *str, unsigned int length)
555 /* start or queue request */ 555 /* start or queue request */
556 raw3215_try_io(raw); 556 raw3215_try_io(raw);
557 } 557 }
558 spin_unlock_irqrestore(raw->lock, flags); 558 spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags);
559 } 559 }
560} 560}
561 561
@@ -568,7 +568,7 @@ raw3215_putchar(struct raw3215_info *raw, unsigned char ch)
568 unsigned long flags; 568 unsigned long flags;
569 unsigned int length, i; 569 unsigned int length, i;
570 570
571 spin_lock_irqsave(raw->lock, flags); 571 spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags);
572 if (ch == '\t') { 572 if (ch == '\t') {
573 length = TAB_STOP_SIZE - (raw->line_pos%TAB_STOP_SIZE); 573 length = TAB_STOP_SIZE - (raw->line_pos%TAB_STOP_SIZE);
574 raw->line_pos += length; 574 raw->line_pos += length;
@@ -592,7 +592,7 @@ raw3215_putchar(struct raw3215_info *raw, unsigned char ch)
592 /* start or queue request */ 592 /* start or queue request */
593 raw3215_try_io(raw); 593 raw3215_try_io(raw);
594 } 594 }
595 spin_unlock_irqrestore(raw->lock, flags); 595 spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags);
596} 596}
597 597
598/* 598/*
@@ -604,13 +604,13 @@ raw3215_flush_buffer(struct raw3215_info *raw)
604{ 604{
605 unsigned long flags; 605 unsigned long flags;
606 606
607 spin_lock_irqsave(raw->lock, flags); 607 spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags);
608 if (raw->count > 0) { 608 if (raw->count > 0) {
609 raw->flags |= RAW3215_FLUSHING; 609 raw->flags |= RAW3215_FLUSHING;
610 raw3215_try_io(raw); 610 raw3215_try_io(raw);
611 raw->flags &= ~RAW3215_FLUSHING; 611 raw->flags &= ~RAW3215_FLUSHING;
612 } 612 }
613 spin_unlock_irqrestore(raw->lock, flags); 613 spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags);
614} 614}
615 615
616/* 616/*
@@ -625,9 +625,9 @@ raw3215_startup(struct raw3215_info *raw)
625 return 0; 625 return 0;
626 raw->line_pos = 0; 626 raw->line_pos = 0;
627 raw->flags |= RAW3215_ACTIVE; 627 raw->flags |= RAW3215_ACTIVE;
628 spin_lock_irqsave(raw->lock, flags); 628 spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags);
629 raw3215_try_io(raw); 629 raw3215_try_io(raw);
630 spin_unlock_irqrestore(raw->lock, flags); 630 spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags);
631 631
632 return 0; 632 return 0;
633} 633}
@@ -644,21 +644,21 @@ raw3215_shutdown(struct raw3215_info *raw)
644 if (!(raw->flags & RAW3215_ACTIVE) || (raw->flags & RAW3215_FIXED)) 644 if (!(raw->flags & RAW3215_ACTIVE) || (raw->flags & RAW3215_FIXED))
645 return; 645 return;
646 /* Wait for outstanding requests, then free irq */ 646 /* Wait for outstanding requests, then free irq */
647 spin_lock_irqsave(raw->lock, flags); 647 spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags);
648 if ((raw->flags & RAW3215_WORKING) || 648 if ((raw->flags & RAW3215_WORKING) ||
649 raw->queued_write != NULL || 649 raw->queued_write != NULL ||
650 raw->queued_read != NULL) { 650 raw->queued_read != NULL) {
651 raw->flags |= RAW3215_CLOSING; 651 raw->flags |= RAW3215_CLOSING;
652 add_wait_queue(&raw->empty_wait, &wait); 652 add_wait_queue(&raw->empty_wait, &wait);
653 set_current_state(TASK_INTERRUPTIBLE); 653 set_current_state(TASK_INTERRUPTIBLE);
654 spin_unlock_irqrestore(raw->lock, flags); 654 spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags);
655 schedule(); 655 schedule();
656 spin_lock_irqsave(raw->lock, flags); 656 spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags);
657 remove_wait_queue(&raw->empty_wait, &wait); 657 remove_wait_queue(&raw->empty_wait, &wait);
658 set_current_state(TASK_RUNNING); 658 set_current_state(TASK_RUNNING);
659 raw->flags &= ~(RAW3215_ACTIVE | RAW3215_CLOSING); 659 raw->flags &= ~(RAW3215_ACTIVE | RAW3215_CLOSING);
660 } 660 }
661 spin_unlock_irqrestore(raw->lock, flags); 661 spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags);
662} 662}
663 663
664static int 664static int
@@ -686,7 +686,6 @@ raw3215_probe (struct ccw_device *cdev)
686 } 686 }
687 687
688 raw->cdev = cdev; 688 raw->cdev = cdev;
689 raw->lock = get_ccwdev_lock(cdev);
690 raw->inbuf = (char *) raw + sizeof(struct raw3215_info); 689 raw->inbuf = (char *) raw + sizeof(struct raw3215_info);
691 memset(raw, 0, sizeof(struct raw3215_info)); 690 memset(raw, 0, sizeof(struct raw3215_info));
692 raw->buffer = (char *) kmalloc(RAW3215_BUFFER_SIZE, 691 raw->buffer = (char *) kmalloc(RAW3215_BUFFER_SIZE,
@@ -809,9 +808,9 @@ con3215_unblank(void)
809 unsigned long flags; 808 unsigned long flags;
810 809
811 raw = raw3215[0]; /* console 3215 is the first one */ 810 raw = raw3215[0]; /* console 3215 is the first one */
812 spin_lock_irqsave(raw->lock, flags); 811 spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags);
813 raw3215_make_room(raw, RAW3215_BUFFER_SIZE); 812 raw3215_make_room(raw, RAW3215_BUFFER_SIZE);
814 spin_unlock_irqrestore(raw->lock, flags); 813 spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags);
815} 814}
816 815
817static int __init 816static int __init
@@ -873,7 +872,6 @@ con3215_init(void)
873 raw->buffer = (char *) alloc_bootmem_low(RAW3215_BUFFER_SIZE); 872 raw->buffer = (char *) alloc_bootmem_low(RAW3215_BUFFER_SIZE);
874 raw->inbuf = (char *) alloc_bootmem_low(RAW3215_INBUF_SIZE); 873 raw->inbuf = (char *) alloc_bootmem_low(RAW3215_INBUF_SIZE);
875 raw->cdev = cdev; 874 raw->cdev = cdev;
876 raw->lock = get_ccwdev_lock(cdev);
877 cdev->dev.driver_data = raw; 875 cdev->dev.driver_data = raw;
878 cdev->handler = raw3215_irq; 876 cdev->handler = raw3215_irq;
879 877
@@ -1066,10 +1064,10 @@ tty3215_unthrottle(struct tty_struct * tty)
1066 1064
1067 raw = (struct raw3215_info *) tty->driver_data; 1065 raw = (struct raw3215_info *) tty->driver_data;
1068 if (raw->flags & RAW3215_THROTTLED) { 1066 if (raw->flags & RAW3215_THROTTLED) {
1069 spin_lock_irqsave(raw->lock, flags); 1067 spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags);
1070 raw->flags &= ~RAW3215_THROTTLED; 1068 raw->flags &= ~RAW3215_THROTTLED;
1071 raw3215_try_io(raw); 1069 raw3215_try_io(raw);
1072 spin_unlock_irqrestore(raw->lock, flags); 1070 spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags);
1073 } 1071 }
1074} 1072}
1075 1073
@@ -1096,10 +1094,10 @@ tty3215_start(struct tty_struct *tty)
1096 1094
1097 raw = (struct raw3215_info *) tty->driver_data; 1095 raw = (struct raw3215_info *) tty->driver_data;
1098 if (raw->flags & RAW3215_STOPPED) { 1096 if (raw->flags & RAW3215_STOPPED) {
1099 spin_lock_irqsave(raw->lock, flags); 1097 spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags);
1100 raw->flags &= ~RAW3215_STOPPED; 1098 raw->flags &= ~RAW3215_STOPPED;
1101 raw3215_try_io(raw); 1099 raw3215_try_io(raw);
1102 spin_unlock_irqrestore(raw->lock, flags); 1100 spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags);
1103 } 1101 }
1104} 1102}
1105 1103
diff --git a/drivers/s390/char/sclp_quiesce.c b/drivers/s390/char/sclp_quiesce.c
index 32004aae95c1..ffa9282ce97a 100644
--- a/drivers/s390/char/sclp_quiesce.c
+++ b/drivers/s390/char/sclp_quiesce.c
@@ -19,52 +19,17 @@
19 19
20#include "sclp.h" 20#include "sclp.h"
21 21
22
23#ifdef CONFIG_SMP
24/* Signal completion of shutdown process. All CPUs except the first to enter
25 * this function: go to stopped state. First CPU: wait until all other
26 * CPUs are in stopped or check stop state. Afterwards, load special PSW
27 * to indicate completion. */
28static void
29do_load_quiesce_psw(void * __unused)
30{
31 static atomic_t cpuid = ATOMIC_INIT(-1);
32 psw_t quiesce_psw;
33 int cpu;
34
35 if (atomic_cmpxchg(&cpuid, -1, smp_processor_id()) != -1)
36 signal_processor(smp_processor_id(), sigp_stop);
37 /* Wait for all other cpus to enter stopped state */
38 for_each_online_cpu(cpu) {
39 if (cpu == smp_processor_id())
40 continue;
41 while(!smp_cpu_not_running(cpu))
42 cpu_relax();
43 }
44 /* Quiesce the last cpu with the special psw */
45 quiesce_psw.mask = PSW_BASE_BITS | PSW_MASK_WAIT;
46 quiesce_psw.addr = 0xfff;
47 __load_psw(quiesce_psw);
48}
49
50/* Shutdown handler. Perform shutdown function on all CPUs. */
51static void
52do_machine_quiesce(void)
53{
54 on_each_cpu(do_load_quiesce_psw, NULL, 0, 0);
55}
56#else
57/* Shutdown handler. Signal completion of shutdown by loading special PSW. */ 22/* Shutdown handler. Signal completion of shutdown by loading special PSW. */
58static void 23static void
59do_machine_quiesce(void) 24do_machine_quiesce(void)
60{ 25{
61 psw_t quiesce_psw; 26 psw_t quiesce_psw;
62 27
28 smp_send_stop();
63 quiesce_psw.mask = PSW_BASE_BITS | PSW_MASK_WAIT; 29 quiesce_psw.mask = PSW_BASE_BITS | PSW_MASK_WAIT;
64 quiesce_psw.addr = 0xfff; 30 quiesce_psw.addr = 0xfff;
65 __load_psw(quiesce_psw); 31 __load_psw(quiesce_psw);
66} 32}
67#endif
68 33
69/* Handler for quiesce event. Start shutdown procedure. */ 34/* Handler for quiesce event. Start shutdown procedure. */
70static void 35static void
diff --git a/drivers/s390/cio/chsc.c b/drivers/s390/cio/chsc.c
index 2d78f0f4a40f..dbfb77b03928 100644
--- a/drivers/s390/cio/chsc.c
+++ b/drivers/s390/cio/chsc.c
@@ -251,6 +251,8 @@ s390_subchannel_remove_chpid(struct device *dev, void *data)
251 cc = cio_clear(sch); 251 cc = cio_clear(sch);
252 if (cc == -ENODEV) 252 if (cc == -ENODEV)
253 goto out_unreg; 253 goto out_unreg;
254 /* Request retry of internal operation. */
255 device_set_intretry(sch);
254 /* Call handler. */ 256 /* Call handler. */
255 if (sch->driver && sch->driver->termination) 257 if (sch->driver && sch->driver->termination)
256 sch->driver->termination(&sch->dev); 258 sch->driver->termination(&sch->dev);
@@ -711,9 +713,6 @@ static inline int check_for_io_on_path(struct subchannel *sch, int index)
711{ 713{
712 int cc; 714 int cc;
713 715
714 if (!device_is_online(sch))
715 /* cio could be doing I/O. */
716 return 0;
717 cc = stsch(sch->schid, &sch->schib); 716 cc = stsch(sch->schid, &sch->schib);
718 if (cc) 717 if (cc)
719 return 0; 718 return 0;
@@ -722,6 +721,26 @@ static inline int check_for_io_on_path(struct subchannel *sch, int index)
722 return 0; 721 return 0;
723} 722}
724 723
724static void terminate_internal_io(struct subchannel *sch)
725{
726 if (cio_clear(sch)) {
727 /* Recheck device in case clear failed. */
728 sch->lpm = 0;
729 if (device_trigger_verify(sch) != 0) {
730 if(css_enqueue_subchannel_slow(sch->schid)) {
731 css_clear_subchannel_slow_list();
732 need_rescan = 1;
733 }
734 }
735 return;
736 }
737 /* Request retry of internal operation. */
738 device_set_intretry(sch);
739 /* Call handler. */
740 if (sch->driver && sch->driver->termination)
741 sch->driver->termination(&sch->dev);
742}
743
725static inline void 744static inline void
726__s390_subchannel_vary_chpid(struct subchannel *sch, __u8 chpid, int on) 745__s390_subchannel_vary_chpid(struct subchannel *sch, __u8 chpid, int on)
727{ 746{
@@ -744,20 +763,26 @@ __s390_subchannel_vary_chpid(struct subchannel *sch, __u8 chpid, int on)
744 device_trigger_reprobe(sch); 763 device_trigger_reprobe(sch);
745 else if (sch->driver && sch->driver->verify) 764 else if (sch->driver && sch->driver->verify)
746 sch->driver->verify(&sch->dev); 765 sch->driver->verify(&sch->dev);
747 } else { 766 break;
748 sch->opm &= ~(0x80 >> chp); 767 }
749 sch->lpm &= ~(0x80 >> chp); 768 sch->opm &= ~(0x80 >> chp);
750 if (check_for_io_on_path(sch, chp)) 769 sch->lpm &= ~(0x80 >> chp);
770 if (check_for_io_on_path(sch, chp)) {
771 if (device_is_online(sch))
751 /* Path verification is done after killing. */ 772 /* Path verification is done after killing. */
752 device_kill_io(sch); 773 device_kill_io(sch);
753 else if (!sch->lpm) { 774 else
775 /* Kill and retry internal I/O. */
776 terminate_internal_io(sch);
777 } else if (!sch->lpm) {
778 if (device_trigger_verify(sch) != 0) {
754 if (css_enqueue_subchannel_slow(sch->schid)) { 779 if (css_enqueue_subchannel_slow(sch->schid)) {
755 css_clear_subchannel_slow_list(); 780 css_clear_subchannel_slow_list();
756 need_rescan = 1; 781 need_rescan = 1;
757 } 782 }
758 } else if (sch->driver && sch->driver->verify) 783 }
759 sch->driver->verify(&sch->dev); 784 } else if (sch->driver && sch->driver->verify)
760 } 785 sch->driver->verify(&sch->dev);
761 break; 786 break;
762 } 787 }
763 spin_unlock_irqrestore(&sch->lock, flags); 788 spin_unlock_irqrestore(&sch->lock, flags);
@@ -1465,41 +1490,6 @@ chsc_get_chp_desc(struct subchannel *sch, int chp_no)
1465 return desc; 1490 return desc;
1466} 1491}
1467 1492
1468static int reset_channel_path(struct channel_path *chp)
1469{
1470 int cc;
1471
1472 cc = rchp(chp->id);
1473 switch (cc) {
1474 case 0:
1475 return 0;
1476 case 2:
1477 return -EBUSY;
1478 default:
1479 return -ENODEV;
1480 }
1481}
1482
1483static void reset_channel_paths_css(struct channel_subsystem *css)
1484{
1485 int i;
1486
1487 for (i = 0; i <= __MAX_CHPID; i++) {
1488 if (css->chps[i])
1489 reset_channel_path(css->chps[i]);
1490 }
1491}
1492
1493void cio_reset_channel_paths(void)
1494{
1495 int i;
1496
1497 for (i = 0; i <= __MAX_CSSID; i++) {
1498 if (css[i] && css[i]->valid)
1499 reset_channel_paths_css(css[i]);
1500 }
1501}
1502
1503static int __init 1493static int __init
1504chsc_alloc_sei_area(void) 1494chsc_alloc_sei_area(void)
1505{ 1495{
diff --git a/drivers/s390/cio/cio.c b/drivers/s390/cio/cio.c
index 8936e460a807..20aee2783847 100644
--- a/drivers/s390/cio/cio.c
+++ b/drivers/s390/cio/cio.c
@@ -21,6 +21,7 @@
21#include <asm/irq.h> 21#include <asm/irq.h>
22#include <asm/irq_regs.h> 22#include <asm/irq_regs.h>
23#include <asm/setup.h> 23#include <asm/setup.h>
24#include <asm/reset.h>
24#include "airq.h" 25#include "airq.h"
25#include "cio.h" 26#include "cio.h"
26#include "css.h" 27#include "css.h"
@@ -28,6 +29,7 @@
28#include "ioasm.h" 29#include "ioasm.h"
29#include "blacklist.h" 30#include "blacklist.h"
30#include "cio_debug.h" 31#include "cio_debug.h"
32#include "../s390mach.h"
31 33
32debug_info_t *cio_debug_msg_id; 34debug_info_t *cio_debug_msg_id;
33debug_info_t *cio_debug_trace_id; 35debug_info_t *cio_debug_trace_id;
@@ -841,26 +843,12 @@ __clear_subchannel_easy(struct subchannel_id schid)
841 return -EBUSY; 843 return -EBUSY;
842} 844}
843 845
844struct sch_match_id { 846static int __shutdown_subchannel_easy(struct subchannel_id schid, void *data)
845 struct subchannel_id schid;
846 struct ccw_dev_id devid;
847 int rc;
848};
849
850static int __shutdown_subchannel_easy_and_match(struct subchannel_id schid,
851 void *data)
852{ 847{
853 struct schib schib; 848 struct schib schib;
854 struct sch_match_id *match_id = data;
855 849
856 if (stsch_err(schid, &schib)) 850 if (stsch_err(schid, &schib))
857 return -ENXIO; 851 return -ENXIO;
858 if (match_id && schib.pmcw.dnv &&
859 (schib.pmcw.dev == match_id->devid.devno) &&
860 (schid.ssid == match_id->devid.ssid)) {
861 match_id->schid = schid;
862 match_id->rc = 0;
863 }
864 if (!schib.pmcw.ena) 852 if (!schib.pmcw.ena)
865 return 0; 853 return 0;
866 switch(__disable_subchannel_easy(schid, &schib)) { 854 switch(__disable_subchannel_easy(schid, &schib)) {
@@ -876,27 +864,111 @@ static int __shutdown_subchannel_easy_and_match(struct subchannel_id schid,
876 return 0; 864 return 0;
877} 865}
878 866
879static int clear_all_subchannels_and_match(struct ccw_dev_id *devid, 867static atomic_t chpid_reset_count;
880 struct subchannel_id *schid) 868
869static void s390_reset_chpids_mcck_handler(void)
870{
871 struct crw crw;
872 struct mci *mci;
873
874 /* Check for pending channel report word. */
875 mci = (struct mci *)&S390_lowcore.mcck_interruption_code;
876 if (!mci->cp)
877 return;
878 /* Process channel report words. */
879 while (stcrw(&crw) == 0) {
880 /* Check for responses to RCHP. */
881 if (crw.slct && crw.rsc == CRW_RSC_CPATH)
882 atomic_dec(&chpid_reset_count);
883 }
884}
885
886#define RCHP_TIMEOUT (30 * USEC_PER_SEC)
887static void css_reset(void)
888{
889 int i, ret;
890 unsigned long long timeout;
891
892 /* Reset subchannels. */
893 for_each_subchannel(__shutdown_subchannel_easy, NULL);
894 /* Reset channel paths. */
895 s390_reset_mcck_handler = s390_reset_chpids_mcck_handler;
896 /* Enable channel report machine checks. */
897 __ctl_set_bit(14, 28);
898 /* Temporarily reenable machine checks. */
899 local_mcck_enable();
900 for (i = 0; i <= __MAX_CHPID; i++) {
901 ret = rchp(i);
902 if ((ret == 0) || (ret == 2))
903 /*
904 * rchp either succeeded, or another rchp is already
905 * in progress. In either case, we'll get a crw.
906 */
907 atomic_inc(&chpid_reset_count);
908 }
909 /* Wait for machine check for all channel paths. */
910 timeout = get_clock() + (RCHP_TIMEOUT << 12);
911 while (atomic_read(&chpid_reset_count) != 0) {
912 if (get_clock() > timeout)
913 break;
914 cpu_relax();
915 }
916 /* Disable machine checks again. */
917 local_mcck_disable();
918 /* Disable channel report machine checks. */
919 __ctl_clear_bit(14, 28);
920 s390_reset_mcck_handler = NULL;
921}
922
923static struct reset_call css_reset_call = {
924 .fn = css_reset,
925};
926
927static int __init init_css_reset_call(void)
928{
929 atomic_set(&chpid_reset_count, 0);
930 register_reset_call(&css_reset_call);
931 return 0;
932}
933
934arch_initcall(init_css_reset_call);
935
936struct sch_match_id {
937 struct subchannel_id schid;
938 struct ccw_dev_id devid;
939 int rc;
940};
941
942static int __reipl_subchannel_match(struct subchannel_id schid, void *data)
943{
944 struct schib schib;
945 struct sch_match_id *match_id = data;
946
947 if (stsch_err(schid, &schib))
948 return -ENXIO;
949 if (schib.pmcw.dnv &&
950 (schib.pmcw.dev == match_id->devid.devno) &&
951 (schid.ssid == match_id->devid.ssid)) {
952 match_id->schid = schid;
953 match_id->rc = 0;
954 return 1;
955 }
956 return 0;
957}
958
959static int reipl_find_schid(struct ccw_dev_id *devid,
960 struct subchannel_id *schid)
881{ 961{
882 struct sch_match_id match_id; 962 struct sch_match_id match_id;
883 963
884 match_id.devid = *devid; 964 match_id.devid = *devid;
885 match_id.rc = -ENODEV; 965 match_id.rc = -ENODEV;
886 local_irq_disable(); 966 for_each_subchannel(__reipl_subchannel_match, &match_id);
887 for_each_subchannel(__shutdown_subchannel_easy_and_match, &match_id);
888 if (match_id.rc == 0) 967 if (match_id.rc == 0)
889 *schid = match_id.schid; 968 *schid = match_id.schid;
890 return match_id.rc; 969 return match_id.rc;
891} 970}
892 971
893
894void clear_all_subchannels(void)
895{
896 local_irq_disable();
897 for_each_subchannel(__shutdown_subchannel_easy_and_match, NULL);
898}
899
900extern void do_reipl_asm(__u32 schid); 972extern void do_reipl_asm(__u32 schid);
901 973
902/* Make sure all subchannels are quiet before we re-ipl an lpar. */ 974/* Make sure all subchannels are quiet before we re-ipl an lpar. */
@@ -904,9 +976,9 @@ void reipl_ccw_dev(struct ccw_dev_id *devid)
904{ 976{
905 struct subchannel_id schid; 977 struct subchannel_id schid;
906 978
907 if (clear_all_subchannels_and_match(devid, &schid)) 979 s390_reset_system();
980 if (reipl_find_schid(devid, &schid) != 0)
908 panic("IPL Device not found\n"); 981 panic("IPL Device not found\n");
909 cio_reset_channel_paths();
910 do_reipl_asm(*((__u32*)&schid)); 982 do_reipl_asm(*((__u32*)&schid));
911} 983}
912 984
diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
index ad7f7e1c0163..26cf2f5ae2e7 100644
--- a/drivers/s390/cio/css.c
+++ b/drivers/s390/cio/css.c
@@ -334,7 +334,7 @@ static LIST_HEAD(slow_subchannels_head);
334static DEFINE_SPINLOCK(slow_subchannel_lock); 334static DEFINE_SPINLOCK(slow_subchannel_lock);
335 335
336static void 336static void
337css_trigger_slow_path(void) 337css_trigger_slow_path(struct work_struct *unused)
338{ 338{
339 CIO_TRACE_EVENT(4, "slowpath"); 339 CIO_TRACE_EVENT(4, "slowpath");
340 340
@@ -359,8 +359,7 @@ css_trigger_slow_path(void)
359 spin_unlock_irq(&slow_subchannel_lock); 359 spin_unlock_irq(&slow_subchannel_lock);
360} 360}
361 361
362typedef void (*workfunc)(void *); 362DECLARE_WORK(slow_path_work, css_trigger_slow_path);
363DECLARE_WORK(slow_path_work, (workfunc)css_trigger_slow_path, NULL);
364struct workqueue_struct *slow_path_wq; 363struct workqueue_struct *slow_path_wq;
365 364
366/* Reprobe subchannel if unregistered. */ 365/* Reprobe subchannel if unregistered. */
@@ -397,7 +396,7 @@ static int reprobe_subchannel(struct subchannel_id schid, void *data)
397} 396}
398 397
399/* Work function used to reprobe all unregistered subchannels. */ 398/* Work function used to reprobe all unregistered subchannels. */
400static void reprobe_all(void *data) 399static void reprobe_all(struct work_struct *unused)
401{ 400{
402 int ret; 401 int ret;
403 402
@@ -413,7 +412,7 @@ static void reprobe_all(void *data)
413 need_reprobe); 412 need_reprobe);
414} 413}
415 414
416DECLARE_WORK(css_reprobe_work, reprobe_all, NULL); 415DECLARE_WORK(css_reprobe_work, reprobe_all);
417 416
418/* Schedule reprobing of all unregistered subchannels. */ 417/* Schedule reprobing of all unregistered subchannels. */
419void css_schedule_reprobe(void) 418void css_schedule_reprobe(void)
diff --git a/drivers/s390/cio/css.h b/drivers/s390/cio/css.h
index 4c2ff8336288..9ff064e71767 100644
--- a/drivers/s390/cio/css.h
+++ b/drivers/s390/cio/css.h
@@ -94,6 +94,7 @@ struct ccw_device_private {
94 unsigned int donotify:1; /* call notify function */ 94 unsigned int donotify:1; /* call notify function */
95 unsigned int recog_done:1; /* dev. recog. complete */ 95 unsigned int recog_done:1; /* dev. recog. complete */
96 unsigned int fake_irb:1; /* deliver faked irb */ 96 unsigned int fake_irb:1; /* deliver faked irb */
97 unsigned int intretry:1; /* retry internal operation */
97 } __attribute__((packed)) flags; 98 } __attribute__((packed)) flags;
98 unsigned long intparm; /* user interruption parameter */ 99 unsigned long intparm; /* user interruption parameter */
99 struct qdio_irq *qdio_data; 100 struct qdio_irq *qdio_data;
@@ -171,6 +172,8 @@ void device_trigger_reprobe(struct subchannel *);
171/* Helper functions for vary on/off. */ 172/* Helper functions for vary on/off. */
172int device_is_online(struct subchannel *); 173int device_is_online(struct subchannel *);
173void device_kill_io(struct subchannel *); 174void device_kill_io(struct subchannel *);
175void device_set_intretry(struct subchannel *sch);
176int device_trigger_verify(struct subchannel *sch);
174 177
175/* Machine check helper function. */ 178/* Machine check helper function. */
176void device_kill_pending_timer(struct subchannel *); 179void device_kill_pending_timer(struct subchannel *);
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
index 39c98f940507..d3d3716ff84b 100644
--- a/drivers/s390/cio/device.c
+++ b/drivers/s390/cio/device.c
@@ -687,8 +687,20 @@ io_subchannel_register(void *data)
687 cdev = data; 687 cdev = data;
688 sch = to_subchannel(cdev->dev.parent); 688 sch = to_subchannel(cdev->dev.parent);
689 689
690 /*
691 * io_subchannel_register() will also be called after device
692 * recognition has been done for a boxed device (which will already
693 * be registered). We need to reprobe since we may now have sense id
694 * information.
695 */
690 if (klist_node_attached(&cdev->dev.knode_parent)) { 696 if (klist_node_attached(&cdev->dev.knode_parent)) {
691 bus_rescan_devices(&ccw_bus_type); 697 if (!cdev->drv) {
698 ret = device_reprobe(&cdev->dev);
699 if (ret)
700 /* We can't do much here. */
701 dev_info(&cdev->dev, "device_reprobe() returned"
702 " %d\n", ret);
703 }
692 goto out; 704 goto out;
693 } 705 }
694 /* make it known to the system */ 706 /* make it known to the system */
@@ -948,6 +960,9 @@ io_subchannel_ioterm(struct device *dev)
948 cdev = dev->driver_data; 960 cdev = dev->driver_data;
949 if (!cdev) 961 if (!cdev)
950 return; 962 return;
963 /* Internal I/O will be retried by the interrupt handler. */
964 if (cdev->private->flags.intretry)
965 return;
951 cdev->private->state = DEV_STATE_CLEAR_VERIFY; 966 cdev->private->state = DEV_STATE_CLEAR_VERIFY;
952 if (cdev->handler) 967 if (cdev->handler)
953 cdev->handler(cdev, cdev->private->intparm, 968 cdev->handler(cdev, cdev->private->intparm,
diff --git a/drivers/s390/cio/device_fsm.c b/drivers/s390/cio/device_fsm.c
index de3d0857db9f..09c7672eb3f3 100644
--- a/drivers/s390/cio/device_fsm.c
+++ b/drivers/s390/cio/device_fsm.c
@@ -59,6 +59,27 @@ device_set_disconnected(struct subchannel *sch)
59 cdev->private->state = DEV_STATE_DISCONNECTED; 59 cdev->private->state = DEV_STATE_DISCONNECTED;
60} 60}
61 61
62void device_set_intretry(struct subchannel *sch)
63{
64 struct ccw_device *cdev;
65
66 cdev = sch->dev.driver_data;
67 if (!cdev)
68 return;
69 cdev->private->flags.intretry = 1;
70}
71
72int device_trigger_verify(struct subchannel *sch)
73{
74 struct ccw_device *cdev;
75
76 cdev = sch->dev.driver_data;
77 if (!cdev || !cdev->online)
78 return -EINVAL;
79 dev_fsm_event(cdev, DEV_EVENT_VERIFY);
80 return 0;
81}
82
62/* 83/*
63 * Timeout function. It just triggers a DEV_EVENT_TIMEOUT. 84 * Timeout function. It just triggers a DEV_EVENT_TIMEOUT.
64 */ 85 */
@@ -893,6 +914,12 @@ ccw_device_w4sense(struct ccw_device *cdev, enum dev_event dev_event)
893 * had killed the original request. 914 * had killed the original request.
894 */ 915 */
895 if (irb->scsw.fctl & (SCSW_FCTL_CLEAR_FUNC | SCSW_FCTL_HALT_FUNC)) { 916 if (irb->scsw.fctl & (SCSW_FCTL_CLEAR_FUNC | SCSW_FCTL_HALT_FUNC)) {
917 /* Retry Basic Sense if requested. */
918 if (cdev->private->flags.intretry) {
919 cdev->private->flags.intretry = 0;
920 ccw_device_do_sense(cdev, irb);
921 return;
922 }
896 cdev->private->flags.dosense = 0; 923 cdev->private->flags.dosense = 0;
897 memset(&cdev->private->irb, 0, sizeof(struct irb)); 924 memset(&cdev->private->irb, 0, sizeof(struct irb));
898 ccw_device_accumulate_irb(cdev, irb); 925 ccw_device_accumulate_irb(cdev, irb);
diff --git a/drivers/s390/cio/device_id.c b/drivers/s390/cio/device_id.c
index a74785b9e4eb..f17275917fe5 100644
--- a/drivers/s390/cio/device_id.c
+++ b/drivers/s390/cio/device_id.c
@@ -191,6 +191,8 @@ __ccw_device_sense_id_start(struct ccw_device *cdev)
191 if ((sch->opm & cdev->private->imask) != 0 && 191 if ((sch->opm & cdev->private->imask) != 0 &&
192 cdev->private->iretry > 0) { 192 cdev->private->iretry > 0) {
193 cdev->private->iretry--; 193 cdev->private->iretry--;
194 /* Reset internal retry indication. */
195 cdev->private->flags.intretry = 0;
194 ret = cio_start (sch, cdev->private->iccws, 196 ret = cio_start (sch, cdev->private->iccws,
195 cdev->private->imask); 197 cdev->private->imask);
196 /* ret is 0, -EBUSY, -EACCES or -ENODEV */ 198 /* ret is 0, -EBUSY, -EACCES or -ENODEV */
@@ -237,8 +239,14 @@ ccw_device_check_sense_id(struct ccw_device *cdev)
237 return 0; /* Success */ 239 return 0; /* Success */
238 } 240 }
239 /* Check the error cases. */ 241 /* Check the error cases. */
240 if (irb->scsw.fctl & (SCSW_FCTL_HALT_FUNC | SCSW_FCTL_CLEAR_FUNC)) 242 if (irb->scsw.fctl & (SCSW_FCTL_HALT_FUNC | SCSW_FCTL_CLEAR_FUNC)) {
243 /* Retry Sense ID if requested. */
244 if (cdev->private->flags.intretry) {
245 cdev->private->flags.intretry = 0;
246 return -EAGAIN;
247 }
241 return -ETIME; 248 return -ETIME;
249 }
242 if (irb->esw.esw0.erw.cons && (irb->ecw[0] & SNS0_CMD_REJECT)) { 250 if (irb->esw.esw0.erw.cons && (irb->ecw[0] & SNS0_CMD_REJECT)) {
243 /* 251 /*
244 * if the device doesn't support the SenseID 252 * if the device doesn't support the SenseID
diff --git a/drivers/s390/cio/device_pgid.c b/drivers/s390/cio/device_pgid.c
index 2975ce888c19..cb1879a96818 100644
--- a/drivers/s390/cio/device_pgid.c
+++ b/drivers/s390/cio/device_pgid.c
@@ -71,6 +71,8 @@ __ccw_device_sense_pgid_start(struct ccw_device *cdev)
71 ccw->cda = (__u32) __pa (&cdev->private->pgid[i]); 71 ccw->cda = (__u32) __pa (&cdev->private->pgid[i]);
72 if (cdev->private->iretry > 0) { 72 if (cdev->private->iretry > 0) {
73 cdev->private->iretry--; 73 cdev->private->iretry--;
74 /* Reset internal retry indication. */
75 cdev->private->flags.intretry = 0;
74 ret = cio_start (sch, cdev->private->iccws, 76 ret = cio_start (sch, cdev->private->iccws,
75 cdev->private->imask); 77 cdev->private->imask);
76 /* ret is 0, -EBUSY, -EACCES or -ENODEV */ 78 /* ret is 0, -EBUSY, -EACCES or -ENODEV */
@@ -122,8 +124,14 @@ __ccw_device_check_sense_pgid(struct ccw_device *cdev)
122 124
123 sch = to_subchannel(cdev->dev.parent); 125 sch = to_subchannel(cdev->dev.parent);
124 irb = &cdev->private->irb; 126 irb = &cdev->private->irb;
125 if (irb->scsw.fctl & (SCSW_FCTL_HALT_FUNC | SCSW_FCTL_CLEAR_FUNC)) 127 if (irb->scsw.fctl & (SCSW_FCTL_HALT_FUNC | SCSW_FCTL_CLEAR_FUNC)) {
128 /* Retry Sense PGID if requested. */
129 if (cdev->private->flags.intretry) {
130 cdev->private->flags.intretry = 0;
131 return -EAGAIN;
132 }
126 return -ETIME; 133 return -ETIME;
134 }
127 if (irb->esw.esw0.erw.cons && 135 if (irb->esw.esw0.erw.cons &&
128 (irb->ecw[0]&(SNS0_CMD_REJECT|SNS0_INTERVENTION_REQ))) { 136 (irb->ecw[0]&(SNS0_CMD_REJECT|SNS0_INTERVENTION_REQ))) {
129 /* 137 /*
@@ -253,6 +261,8 @@ __ccw_device_do_pgid(struct ccw_device *cdev, __u8 func)
253 ret = -EACCES; 261 ret = -EACCES;
254 if (cdev->private->iretry > 0) { 262 if (cdev->private->iretry > 0) {
255 cdev->private->iretry--; 263 cdev->private->iretry--;
264 /* Reset internal retry indication. */
265 cdev->private->flags.intretry = 0;
256 ret = cio_start (sch, cdev->private->iccws, 266 ret = cio_start (sch, cdev->private->iccws,
257 cdev->private->imask); 267 cdev->private->imask);
258 /* We expect an interrupt in case of success or busy 268 /* We expect an interrupt in case of success or busy
@@ -293,6 +303,8 @@ static int __ccw_device_do_nop(struct ccw_device *cdev)
293 ret = -EACCES; 303 ret = -EACCES;
294 if (cdev->private->iretry > 0) { 304 if (cdev->private->iretry > 0) {
295 cdev->private->iretry--; 305 cdev->private->iretry--;
306 /* Reset internal retry indication. */
307 cdev->private->flags.intretry = 0;
296 ret = cio_start (sch, cdev->private->iccws, 308 ret = cio_start (sch, cdev->private->iccws,
297 cdev->private->imask); 309 cdev->private->imask);
298 /* We expect an interrupt in case of success or busy 310 /* We expect an interrupt in case of success or busy
@@ -321,8 +333,14 @@ __ccw_device_check_pgid(struct ccw_device *cdev)
321 333
322 sch = to_subchannel(cdev->dev.parent); 334 sch = to_subchannel(cdev->dev.parent);
323 irb = &cdev->private->irb; 335 irb = &cdev->private->irb;
324 if (irb->scsw.fctl & (SCSW_FCTL_HALT_FUNC | SCSW_FCTL_CLEAR_FUNC)) 336 if (irb->scsw.fctl & (SCSW_FCTL_HALT_FUNC | SCSW_FCTL_CLEAR_FUNC)) {
337 /* Retry Set PGID if requested. */
338 if (cdev->private->flags.intretry) {
339 cdev->private->flags.intretry = 0;
340 return -EAGAIN;
341 }
325 return -ETIME; 342 return -ETIME;
343 }
326 if (irb->esw.esw0.erw.cons) { 344 if (irb->esw.esw0.erw.cons) {
327 if (irb->ecw[0] & SNS0_CMD_REJECT) 345 if (irb->ecw[0] & SNS0_CMD_REJECT)
328 return -EOPNOTSUPP; 346 return -EOPNOTSUPP;
@@ -360,8 +378,14 @@ static int __ccw_device_check_nop(struct ccw_device *cdev)
360 378
361 sch = to_subchannel(cdev->dev.parent); 379 sch = to_subchannel(cdev->dev.parent);
362 irb = &cdev->private->irb; 380 irb = &cdev->private->irb;
363 if (irb->scsw.fctl & (SCSW_FCTL_HALT_FUNC | SCSW_FCTL_CLEAR_FUNC)) 381 if (irb->scsw.fctl & (SCSW_FCTL_HALT_FUNC | SCSW_FCTL_CLEAR_FUNC)) {
382 /* Retry NOP if requested. */
383 if (cdev->private->flags.intretry) {
384 cdev->private->flags.intretry = 0;
385 return -EAGAIN;
386 }
364 return -ETIME; 387 return -ETIME;
388 }
365 if (irb->scsw.cc == 3) { 389 if (irb->scsw.cc == 3) {
366 CIO_MSG_EVENT(2, "NOP - Device %04x on Subchannel 0.%x.%04x," 390 CIO_MSG_EVENT(2, "NOP - Device %04x on Subchannel 0.%x.%04x,"
367 " lpm %02X, became 'not operational'\n", 391 " lpm %02X, became 'not operational'\n",
diff --git a/drivers/s390/cio/device_status.c b/drivers/s390/cio/device_status.c
index 3f7cbce4cd87..bdcf930f7beb 100644
--- a/drivers/s390/cio/device_status.c
+++ b/drivers/s390/cio/device_status.c
@@ -319,6 +319,9 @@ ccw_device_do_sense(struct ccw_device *cdev, struct irb *irb)
319 sch->sense_ccw.count = SENSE_MAX_COUNT; 319 sch->sense_ccw.count = SENSE_MAX_COUNT;
320 sch->sense_ccw.flags = CCW_FLAG_SLI; 320 sch->sense_ccw.flags = CCW_FLAG_SLI;
321 321
322 /* Reset internal retry indication. */
323 cdev->private->flags.intretry = 0;
324
322 return cio_start (sch, &sch->sense_ccw, 0xff); 325 return cio_start (sch, &sch->sense_ccw, 0xff);
323} 326}
324 327
diff --git a/drivers/s390/cio/qdio.c b/drivers/s390/cio/qdio.c
index 476aa1da5cbc..8d5fa1b4d11f 100644
--- a/drivers/s390/cio/qdio.c
+++ b/drivers/s390/cio/qdio.c
@@ -481,7 +481,7 @@ qdio_stop_polling(struct qdio_q *q)
481 unsigned char state = 0; 481 unsigned char state = 0;
482 struct qdio_irq *irq = (struct qdio_irq *) q->irq_ptr; 482 struct qdio_irq *irq = (struct qdio_irq *) q->irq_ptr;
483 483
484 if (!atomic_swap(&q->polling,0)) 484 if (!atomic_xchg(&q->polling,0))
485 return 1; 485 return 1;
486 486
487 QDIO_DBF_TEXT4(0,trace,"stoppoll"); 487 QDIO_DBF_TEXT4(0,trace,"stoppoll");
@@ -1964,8 +1964,8 @@ qdio_irq_check_sense(struct subchannel_id schid, struct irb *irb)
1964 QDIO_DBF_HEX0(0,sense,irb,QDIO_DBF_SENSE_LEN); 1964 QDIO_DBF_HEX0(0,sense,irb,QDIO_DBF_SENSE_LEN);
1965 1965
1966 QDIO_PRINT_WARN("sense data available on qdio channel.\n"); 1966 QDIO_PRINT_WARN("sense data available on qdio channel.\n");
1967 HEXDUMP16(WARN,"irb: ",irb); 1967 QDIO_HEXDUMP16(WARN,"irb: ",irb);
1968 HEXDUMP16(WARN,"sense data: ",irb->ecw); 1968 QDIO_HEXDUMP16(WARN,"sense data: ",irb->ecw);
1969 } 1969 }
1970 1970
1971} 1971}
@@ -3425,7 +3425,7 @@ do_qdio_handle_inbound(struct qdio_q *q, unsigned int callflags,
3425 3425
3426 if ((used_elements+count==QDIO_MAX_BUFFERS_PER_Q)&& 3426 if ((used_elements+count==QDIO_MAX_BUFFERS_PER_Q)&&
3427 (callflags&QDIO_FLAG_UNDER_INTERRUPT)) 3427 (callflags&QDIO_FLAG_UNDER_INTERRUPT))
3428 atomic_swap(&q->polling,0); 3428 atomic_xchg(&q->polling,0);
3429 3429
3430 if (used_elements) 3430 if (used_elements)
3431 return; 3431 return;
diff --git a/drivers/s390/cio/qdio.h b/drivers/s390/cio/qdio.h
index 49bb9e371c32..42927c1b7451 100644
--- a/drivers/s390/cio/qdio.h
+++ b/drivers/s390/cio/qdio.h
@@ -236,7 +236,7 @@ enum qdio_irq_states {
236#define QDIO_PRINT_EMERG(x...) do { } while (0) 236#define QDIO_PRINT_EMERG(x...) do { } while (0)
237#endif 237#endif
238 238
239#define HEXDUMP16(importance,header,ptr) \ 239#define QDIO_HEXDUMP16(importance,header,ptr) \
240QDIO_PRINT_##importance(header "%02x %02x %02x %02x " \ 240QDIO_PRINT_##importance(header "%02x %02x %02x %02x " \
241 "%02x %02x %02x %02x %02x %02x %02x %02x " \ 241 "%02x %02x %02x %02x %02x %02x %02x %02x " \
242 "%02x %02x %02x %02x\n",*(((char*)ptr)), \ 242 "%02x %02x %02x %02x\n",*(((char*)ptr)), \
@@ -429,8 +429,6 @@ struct qdio_perf_stats {
429}; 429};
430#endif /* QDIO_PERFORMANCE_STATS */ 430#endif /* QDIO_PERFORMANCE_STATS */
431 431
432#define atomic_swap(a,b) xchg((int*)a.counter,b)
433
434/* unlikely as the later the better */ 432/* unlikely as the later the better */
435#define SYNC_MEMORY if (unlikely(q->siga_sync)) qdio_siga_sync_q(q) 433#define SYNC_MEMORY if (unlikely(q->siga_sync)) qdio_siga_sync_q(q)
436#define SYNC_MEMORY_ALL if (unlikely(q->siga_sync)) \ 434#define SYNC_MEMORY_ALL if (unlikely(q->siga_sync)) \
diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c
index 79d89c368919..e4dc947e74e9 100644
--- a/drivers/s390/crypto/ap_bus.c
+++ b/drivers/s390/crypto/ap_bus.c
@@ -37,7 +37,7 @@
37#include "ap_bus.h" 37#include "ap_bus.h"
38 38
39/* Some prototypes. */ 39/* Some prototypes. */
40static void ap_scan_bus(void *); 40static void ap_scan_bus(struct work_struct *);
41static void ap_poll_all(unsigned long); 41static void ap_poll_all(unsigned long);
42static void ap_poll_timeout(unsigned long); 42static void ap_poll_timeout(unsigned long);
43static int ap_poll_thread_start(void); 43static int ap_poll_thread_start(void);
@@ -71,7 +71,7 @@ static struct device *ap_root_device = NULL;
71static struct workqueue_struct *ap_work_queue; 71static struct workqueue_struct *ap_work_queue;
72static struct timer_list ap_config_timer; 72static struct timer_list ap_config_timer;
73static int ap_config_time = AP_CONFIG_TIME; 73static int ap_config_time = AP_CONFIG_TIME;
74static DECLARE_WORK(ap_config_work, ap_scan_bus, NULL); 74static DECLARE_WORK(ap_config_work, ap_scan_bus);
75 75
76/** 76/**
77 * Tasklet & timer for AP request polling. 77 * Tasklet & timer for AP request polling.
@@ -431,7 +431,15 @@ static int ap_uevent (struct device *dev, char **envp, int num_envp,
431 ap_dev->device_type); 431 ap_dev->device_type);
432 if (buffer_size - length <= 0) 432 if (buffer_size - length <= 0)
433 return -ENOMEM; 433 return -ENOMEM;
434 envp[1] = 0; 434 buffer += length;
435 buffer_size -= length;
436 /* Add MODALIAS= */
437 envp[1] = buffer;
438 length = scnprintf(buffer, buffer_size, "MODALIAS=ap:t%02X",
439 ap_dev->device_type);
440 if (buffer_size - length <= 0)
441 return -ENOMEM;
442 envp[2] = NULL;
435 return 0; 443 return 0;
436} 444}
437 445
@@ -724,7 +732,7 @@ static void ap_device_release(struct device *dev)
724 kfree(ap_dev); 732 kfree(ap_dev);
725} 733}
726 734
727static void ap_scan_bus(void *data) 735static void ap_scan_bus(struct work_struct *unused)
728{ 736{
729 struct ap_device *ap_dev; 737 struct ap_device *ap_dev;
730 struct device *dev; 738 struct device *dev;
diff --git a/drivers/s390/net/claw.h b/drivers/s390/net/claw.h
index 969be465309c..1ee9a6f06541 100644
--- a/drivers/s390/net/claw.h
+++ b/drivers/s390/net/claw.h
@@ -29,7 +29,7 @@
29#define CLAW_COMPLETE 0xff /* flag to indicate i/o completed */ 29#define CLAW_COMPLETE 0xff /* flag to indicate i/o completed */
30 30
31/*-----------------------------------------------------* 31/*-----------------------------------------------------*
32* CLAW control comand code * 32* CLAW control command code *
33*------------------------------------------------------*/ 33*------------------------------------------------------*/
34 34
35#define SYSTEM_VALIDATE_REQUEST 0x01 /* System Validate request */ 35#define SYSTEM_VALIDATE_REQUEST 0x01 /* System Validate request */
diff --git a/drivers/s390/net/lcs.c b/drivers/s390/net/lcs.c
index 16ac68c27a27..e5665b6743a1 100644
--- a/drivers/s390/net/lcs.c
+++ b/drivers/s390/net/lcs.c
@@ -54,6 +54,8 @@
54#error Cannot compile lcs.c without some net devices switched on. 54#error Cannot compile lcs.c without some net devices switched on.
55#endif 55#endif
56 56
57#define PRINTK_HEADER " lcs: "
58
57/** 59/**
58 * initialization string for output 60 * initialization string for output
59 */ 61 */
@@ -65,7 +67,7 @@ static char debug_buffer[255];
65 * Some prototypes. 67 * Some prototypes.
66 */ 68 */
67static void lcs_tasklet(unsigned long); 69static void lcs_tasklet(unsigned long);
68static void lcs_start_kernel_thread(struct lcs_card *card); 70static void lcs_start_kernel_thread(struct work_struct *);
69static void lcs_get_frames_cb(struct lcs_channel *, struct lcs_buffer *); 71static void lcs_get_frames_cb(struct lcs_channel *, struct lcs_buffer *);
70static int lcs_send_delipm(struct lcs_card *, struct lcs_ipm_list *); 72static int lcs_send_delipm(struct lcs_card *, struct lcs_ipm_list *);
71static int lcs_recovery(void *ptr); 73static int lcs_recovery(void *ptr);
@@ -120,7 +122,7 @@ lcs_alloc_channel(struct lcs_channel *channel)
120 kzalloc(LCS_IOBUFFERSIZE, GFP_DMA | GFP_KERNEL); 122 kzalloc(LCS_IOBUFFERSIZE, GFP_DMA | GFP_KERNEL);
121 if (channel->iob[cnt].data == NULL) 123 if (channel->iob[cnt].data == NULL)
122 break; 124 break;
123 channel->iob[cnt].state = BUF_STATE_EMPTY; 125 channel->iob[cnt].state = LCS_BUF_STATE_EMPTY;
124 } 126 }
125 if (cnt < LCS_NUM_BUFFS) { 127 if (cnt < LCS_NUM_BUFFS) {
126 /* Not all io buffers could be allocated. */ 128 /* Not all io buffers could be allocated. */
@@ -236,7 +238,7 @@ lcs_setup_read_ccws(struct lcs_card *card)
236 ((struct lcs_header *) 238 ((struct lcs_header *)
237 card->read.iob[cnt].data)->offset = LCS_ILLEGAL_OFFSET; 239 card->read.iob[cnt].data)->offset = LCS_ILLEGAL_OFFSET;
238 card->read.iob[cnt].callback = lcs_get_frames_cb; 240 card->read.iob[cnt].callback = lcs_get_frames_cb;
239 card->read.iob[cnt].state = BUF_STATE_READY; 241 card->read.iob[cnt].state = LCS_BUF_STATE_READY;
240 card->read.iob[cnt].count = LCS_IOBUFFERSIZE; 242 card->read.iob[cnt].count = LCS_IOBUFFERSIZE;
241 } 243 }
242 card->read.ccws[0].flags &= ~CCW_FLAG_PCI; 244 card->read.ccws[0].flags &= ~CCW_FLAG_PCI;
@@ -247,7 +249,7 @@ lcs_setup_read_ccws(struct lcs_card *card)
247 card->read.ccws[LCS_NUM_BUFFS].cda = 249 card->read.ccws[LCS_NUM_BUFFS].cda =
248 (__u32) __pa(card->read.ccws); 250 (__u32) __pa(card->read.ccws);
249 /* Setg initial state of the read channel. */ 251 /* Setg initial state of the read channel. */
250 card->read.state = CH_STATE_INIT; 252 card->read.state = LCS_CH_STATE_INIT;
251 253
252 card->read.io_idx = 0; 254 card->read.io_idx = 0;
253 card->read.buf_idx = 0; 255 card->read.buf_idx = 0;
@@ -294,7 +296,7 @@ lcs_setup_write_ccws(struct lcs_card *card)
294 card->write.ccws[LCS_NUM_BUFFS].cda = 296 card->write.ccws[LCS_NUM_BUFFS].cda =
295 (__u32) __pa(card->write.ccws); 297 (__u32) __pa(card->write.ccws);
296 /* Set initial state of the write channel. */ 298 /* Set initial state of the write channel. */
297 card->read.state = CH_STATE_INIT; 299 card->read.state = LCS_CH_STATE_INIT;
298 300
299 card->write.io_idx = 0; 301 card->write.io_idx = 0;
300 card->write.buf_idx = 0; 302 card->write.buf_idx = 0;
@@ -496,7 +498,7 @@ lcs_start_channel(struct lcs_channel *channel)
496 channel->ccws + channel->io_idx, 0, 0, 498 channel->ccws + channel->io_idx, 0, 0,
497 DOIO_DENY_PREFETCH | DOIO_ALLOW_SUSPEND); 499 DOIO_DENY_PREFETCH | DOIO_ALLOW_SUSPEND);
498 if (rc == 0) 500 if (rc == 0)
499 channel->state = CH_STATE_RUNNING; 501 channel->state = LCS_CH_STATE_RUNNING;
500 spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags); 502 spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
501 if (rc) { 503 if (rc) {
502 LCS_DBF_TEXT_(4,trace,"essh%s", channel->ccwdev->dev.bus_id); 504 LCS_DBF_TEXT_(4,trace,"essh%s", channel->ccwdev->dev.bus_id);
@@ -520,8 +522,8 @@ lcs_clear_channel(struct lcs_channel *channel)
520 LCS_DBF_TEXT_(4,trace,"ecsc%s", channel->ccwdev->dev.bus_id); 522 LCS_DBF_TEXT_(4,trace,"ecsc%s", channel->ccwdev->dev.bus_id);
521 return rc; 523 return rc;
522 } 524 }
523 wait_event(channel->wait_q, (channel->state == CH_STATE_CLEARED)); 525 wait_event(channel->wait_q, (channel->state == LCS_CH_STATE_CLEARED));
524 channel->state = CH_STATE_STOPPED; 526 channel->state = LCS_CH_STATE_STOPPED;
525 return rc; 527 return rc;
526} 528}
527 529
@@ -535,11 +537,11 @@ lcs_stop_channel(struct lcs_channel *channel)
535 unsigned long flags; 537 unsigned long flags;
536 int rc; 538 int rc;
537 539
538 if (channel->state == CH_STATE_STOPPED) 540 if (channel->state == LCS_CH_STATE_STOPPED)
539 return 0; 541 return 0;
540 LCS_DBF_TEXT(4,trace,"haltsch"); 542 LCS_DBF_TEXT(4,trace,"haltsch");
541 LCS_DBF_TEXT_(4,trace,"%s", channel->ccwdev->dev.bus_id); 543 LCS_DBF_TEXT_(4,trace,"%s", channel->ccwdev->dev.bus_id);
542 channel->state = CH_STATE_INIT; 544 channel->state = LCS_CH_STATE_INIT;
543 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags); 545 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
544 rc = ccw_device_halt(channel->ccwdev, (addr_t) channel); 546 rc = ccw_device_halt(channel->ccwdev, (addr_t) channel);
545 spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags); 547 spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
@@ -548,7 +550,7 @@ lcs_stop_channel(struct lcs_channel *channel)
548 return rc; 550 return rc;
549 } 551 }
550 /* Asynchronous halt initialted. Wait for its completion. */ 552 /* Asynchronous halt initialted. Wait for its completion. */
551 wait_event(channel->wait_q, (channel->state == CH_STATE_HALTED)); 553 wait_event(channel->wait_q, (channel->state == LCS_CH_STATE_HALTED));
552 lcs_clear_channel(channel); 554 lcs_clear_channel(channel);
553 return 0; 555 return 0;
554} 556}
@@ -596,8 +598,8 @@ __lcs_get_buffer(struct lcs_channel *channel)
596 LCS_DBF_TEXT(5, trace, "_getbuff"); 598 LCS_DBF_TEXT(5, trace, "_getbuff");
597 index = channel->io_idx; 599 index = channel->io_idx;
598 do { 600 do {
599 if (channel->iob[index].state == BUF_STATE_EMPTY) { 601 if (channel->iob[index].state == LCS_BUF_STATE_EMPTY) {
600 channel->iob[index].state = BUF_STATE_LOCKED; 602 channel->iob[index].state = LCS_BUF_STATE_LOCKED;
601 return channel->iob + index; 603 return channel->iob + index;
602 } 604 }
603 index = (index + 1) & (LCS_NUM_BUFFS - 1); 605 index = (index + 1) & (LCS_NUM_BUFFS - 1);
@@ -626,7 +628,7 @@ __lcs_resume_channel(struct lcs_channel *channel)
626{ 628{
627 int rc; 629 int rc;
628 630
629 if (channel->state != CH_STATE_SUSPENDED) 631 if (channel->state != LCS_CH_STATE_SUSPENDED)
630 return 0; 632 return 0;
631 if (channel->ccws[channel->io_idx].flags & CCW_FLAG_SUSPEND) 633 if (channel->ccws[channel->io_idx].flags & CCW_FLAG_SUSPEND)
632 return 0; 634 return 0;
@@ -636,7 +638,7 @@ __lcs_resume_channel(struct lcs_channel *channel)
636 LCS_DBF_TEXT_(4, trace, "ersc%s", channel->ccwdev->dev.bus_id); 638 LCS_DBF_TEXT_(4, trace, "ersc%s", channel->ccwdev->dev.bus_id);
637 PRINT_ERR("Error in lcs_resume_channel: rc=%d\n",rc); 639 PRINT_ERR("Error in lcs_resume_channel: rc=%d\n",rc);
638 } else 640 } else
639 channel->state = CH_STATE_RUNNING; 641 channel->state = LCS_CH_STATE_RUNNING;
640 return rc; 642 return rc;
641 643
642} 644}
@@ -670,10 +672,10 @@ lcs_ready_buffer(struct lcs_channel *channel, struct lcs_buffer *buffer)
670 int index, rc; 672 int index, rc;
671 673
672 LCS_DBF_TEXT(5, trace, "rdybuff"); 674 LCS_DBF_TEXT(5, trace, "rdybuff");
673 BUG_ON(buffer->state != BUF_STATE_LOCKED && 675 BUG_ON(buffer->state != LCS_BUF_STATE_LOCKED &&
674 buffer->state != BUF_STATE_PROCESSED); 676 buffer->state != LCS_BUF_STATE_PROCESSED);
675 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags); 677 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
676 buffer->state = BUF_STATE_READY; 678 buffer->state = LCS_BUF_STATE_READY;
677 index = buffer - channel->iob; 679 index = buffer - channel->iob;
678 /* Set length. */ 680 /* Set length. */
679 channel->ccws[index].count = buffer->count; 681 channel->ccws[index].count = buffer->count;
@@ -695,8 +697,8 @@ __lcs_processed_buffer(struct lcs_channel *channel, struct lcs_buffer *buffer)
695 int index, prev, next; 697 int index, prev, next;
696 698
697 LCS_DBF_TEXT(5, trace, "prcsbuff"); 699 LCS_DBF_TEXT(5, trace, "prcsbuff");
698 BUG_ON(buffer->state != BUF_STATE_READY); 700 BUG_ON(buffer->state != LCS_BUF_STATE_READY);
699 buffer->state = BUF_STATE_PROCESSED; 701 buffer->state = LCS_BUF_STATE_PROCESSED;
700 index = buffer - channel->iob; 702 index = buffer - channel->iob;
701 prev = (index - 1) & (LCS_NUM_BUFFS - 1); 703 prev = (index - 1) & (LCS_NUM_BUFFS - 1);
702 next = (index + 1) & (LCS_NUM_BUFFS - 1); 704 next = (index + 1) & (LCS_NUM_BUFFS - 1);
@@ -704,7 +706,7 @@ __lcs_processed_buffer(struct lcs_channel *channel, struct lcs_buffer *buffer)
704 channel->ccws[index].flags |= CCW_FLAG_SUSPEND; 706 channel->ccws[index].flags |= CCW_FLAG_SUSPEND;
705 channel->ccws[index].flags &= ~CCW_FLAG_PCI; 707 channel->ccws[index].flags &= ~CCW_FLAG_PCI;
706 /* Check the suspend bit of the previous buffer. */ 708 /* Check the suspend bit of the previous buffer. */
707 if (channel->iob[prev].state == BUF_STATE_READY) { 709 if (channel->iob[prev].state == LCS_BUF_STATE_READY) {
708 /* 710 /*
709 * Previous buffer is in state ready. It might have 711 * Previous buffer is in state ready. It might have
710 * happened in lcs_ready_buffer that the suspend bit 712 * happened in lcs_ready_buffer that the suspend bit
@@ -727,10 +729,10 @@ lcs_release_buffer(struct lcs_channel *channel, struct lcs_buffer *buffer)
727 unsigned long flags; 729 unsigned long flags;
728 730
729 LCS_DBF_TEXT(5, trace, "relbuff"); 731 LCS_DBF_TEXT(5, trace, "relbuff");
730 BUG_ON(buffer->state != BUF_STATE_LOCKED && 732 BUG_ON(buffer->state != LCS_BUF_STATE_LOCKED &&
731 buffer->state != BUF_STATE_PROCESSED); 733 buffer->state != LCS_BUF_STATE_PROCESSED);
732 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags); 734 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
733 buffer->state = BUF_STATE_EMPTY; 735 buffer->state = LCS_BUF_STATE_EMPTY;
734 spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags); 736 spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags);
735} 737}
736 738
@@ -1147,7 +1149,7 @@ list_modified:
1147 * get mac address for the relevant Multicast address 1149 * get mac address for the relevant Multicast address
1148 */ 1150 */
1149static void 1151static void
1150lcs_get_mac_for_ipm(__u32 ipm, char *mac, struct net_device *dev) 1152lcs_get_mac_for_ipm(__be32 ipm, char *mac, struct net_device *dev)
1151{ 1153{
1152 LCS_DBF_TEXT(4,trace, "getmac"); 1154 LCS_DBF_TEXT(4,trace, "getmac");
1153 if (dev->type == ARPHRD_IEEE802_TR) 1155 if (dev->type == ARPHRD_IEEE802_TR)
@@ -1264,7 +1266,7 @@ lcs_register_mc_addresses(void *data)
1264 netif_carrier_off(card->dev); 1266 netif_carrier_off(card->dev);
1265 netif_tx_disable(card->dev); 1267 netif_tx_disable(card->dev);
1266 wait_event(card->write.wait_q, 1268 wait_event(card->write.wait_q,
1267 (card->write.state != CH_STATE_RUNNING)); 1269 (card->write.state != LCS_CH_STATE_RUNNING));
1268 lcs_fix_multicast_list(card); 1270 lcs_fix_multicast_list(card);
1269 if (card->state == DEV_STATE_UP) { 1271 if (card->state == DEV_STATE_UP) {
1270 netif_carrier_on(card->dev); 1272 netif_carrier_on(card->dev);
@@ -1404,7 +1406,7 @@ lcs_irq(struct ccw_device *cdev, unsigned long intparm, struct irb *irb)
1404 } 1406 }
1405 } 1407 }
1406 /* How far in the ccw chain have we processed? */ 1408 /* How far in the ccw chain have we processed? */
1407 if ((channel->state != CH_STATE_INIT) && 1409 if ((channel->state != LCS_CH_STATE_INIT) &&
1408 (irb->scsw.fctl & SCSW_FCTL_START_FUNC)) { 1410 (irb->scsw.fctl & SCSW_FCTL_START_FUNC)) {
1409 index = (struct ccw1 *) __va((addr_t) irb->scsw.cpa) 1411 index = (struct ccw1 *) __va((addr_t) irb->scsw.cpa)
1410 - channel->ccws; 1412 - channel->ccws;
@@ -1424,20 +1426,20 @@ lcs_irq(struct ccw_device *cdev, unsigned long intparm, struct irb *irb)
1424 (irb->scsw.dstat & DEV_STAT_CHN_END) || 1426 (irb->scsw.dstat & DEV_STAT_CHN_END) ||
1425 (irb->scsw.dstat & DEV_STAT_UNIT_CHECK)) 1427 (irb->scsw.dstat & DEV_STAT_UNIT_CHECK))
1426 /* Mark channel as stopped. */ 1428 /* Mark channel as stopped. */
1427 channel->state = CH_STATE_STOPPED; 1429 channel->state = LCS_CH_STATE_STOPPED;
1428 else if (irb->scsw.actl & SCSW_ACTL_SUSPENDED) 1430 else if (irb->scsw.actl & SCSW_ACTL_SUSPENDED)
1429 /* CCW execution stopped on a suspend bit. */ 1431 /* CCW execution stopped on a suspend bit. */
1430 channel->state = CH_STATE_SUSPENDED; 1432 channel->state = LCS_CH_STATE_SUSPENDED;
1431 if (irb->scsw.fctl & SCSW_FCTL_HALT_FUNC) { 1433 if (irb->scsw.fctl & SCSW_FCTL_HALT_FUNC) {
1432 if (irb->scsw.cc != 0) { 1434 if (irb->scsw.cc != 0) {
1433 ccw_device_halt(channel->ccwdev, (addr_t) channel); 1435 ccw_device_halt(channel->ccwdev, (addr_t) channel);
1434 return; 1436 return;
1435 } 1437 }
1436 /* The channel has been stopped by halt_IO. */ 1438 /* The channel has been stopped by halt_IO. */
1437 channel->state = CH_STATE_HALTED; 1439 channel->state = LCS_CH_STATE_HALTED;
1438 } 1440 }
1439 if (irb->scsw.fctl & SCSW_FCTL_CLEAR_FUNC) { 1441 if (irb->scsw.fctl & SCSW_FCTL_CLEAR_FUNC) {
1440 channel->state = CH_STATE_CLEARED; 1442 channel->state = LCS_CH_STATE_CLEARED;
1441 } 1443 }
1442 /* Do the rest in the tasklet. */ 1444 /* Do the rest in the tasklet. */
1443 tasklet_schedule(&channel->irq_tasklet); 1445 tasklet_schedule(&channel->irq_tasklet);
@@ -1461,7 +1463,7 @@ lcs_tasklet(unsigned long data)
1461 /* Check for processed buffers. */ 1463 /* Check for processed buffers. */
1462 iob = channel->iob; 1464 iob = channel->iob;
1463 buf_idx = channel->buf_idx; 1465 buf_idx = channel->buf_idx;
1464 while (iob[buf_idx].state == BUF_STATE_PROCESSED) { 1466 while (iob[buf_idx].state == LCS_BUF_STATE_PROCESSED) {
1465 /* Do the callback thing. */ 1467 /* Do the callback thing. */
1466 if (iob[buf_idx].callback != NULL) 1468 if (iob[buf_idx].callback != NULL)
1467 iob[buf_idx].callback(channel, iob + buf_idx); 1469 iob[buf_idx].callback(channel, iob + buf_idx);
@@ -1469,12 +1471,12 @@ lcs_tasklet(unsigned long data)
1469 } 1471 }
1470 channel->buf_idx = buf_idx; 1472 channel->buf_idx = buf_idx;
1471 1473
1472 if (channel->state == CH_STATE_STOPPED) 1474 if (channel->state == LCS_CH_STATE_STOPPED)
1473 // FIXME: what if rc != 0 ?? 1475 // FIXME: what if rc != 0 ??
1474 rc = lcs_start_channel(channel); 1476 rc = lcs_start_channel(channel);
1475 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags); 1477 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
1476 if (channel->state == CH_STATE_SUSPENDED && 1478 if (channel->state == LCS_CH_STATE_SUSPENDED &&
1477 channel->iob[channel->io_idx].state == BUF_STATE_READY) { 1479 channel->iob[channel->io_idx].state == LCS_BUF_STATE_READY) {
1478 // FIXME: what if rc != 0 ?? 1480 // FIXME: what if rc != 0 ??
1479 rc = __lcs_resume_channel(channel); 1481 rc = __lcs_resume_channel(channel);
1480 } 1482 }
@@ -1689,8 +1691,8 @@ lcs_detect(struct lcs_card *card)
1689 card->state = DEV_STATE_UP; 1691 card->state = DEV_STATE_UP;
1690 } else { 1692 } else {
1691 card->state = DEV_STATE_DOWN; 1693 card->state = DEV_STATE_DOWN;
1692 card->write.state = CH_STATE_INIT; 1694 card->write.state = LCS_CH_STATE_INIT;
1693 card->read.state = CH_STATE_INIT; 1695 card->read.state = LCS_CH_STATE_INIT;
1694 } 1696 }
1695 return rc; 1697 return rc;
1696} 1698}
@@ -1705,8 +1707,8 @@ lcs_stopcard(struct lcs_card *card)
1705 1707
1706 LCS_DBF_TEXT(3, setup, "stopcard"); 1708 LCS_DBF_TEXT(3, setup, "stopcard");
1707 1709
1708 if (card->read.state != CH_STATE_STOPPED && 1710 if (card->read.state != LCS_CH_STATE_STOPPED &&
1709 card->write.state != CH_STATE_STOPPED && 1711 card->write.state != LCS_CH_STATE_STOPPED &&
1710 card->state == DEV_STATE_UP) { 1712 card->state == DEV_STATE_UP) {
1711 lcs_clear_multicast_list(card); 1713 lcs_clear_multicast_list(card);
1712 rc = lcs_send_stoplan(card,LCS_INITIATOR_TCPIP); 1714 rc = lcs_send_stoplan(card,LCS_INITIATOR_TCPIP);
@@ -1722,8 +1724,9 @@ lcs_stopcard(struct lcs_card *card)
1722 * Kernel Thread helper functions for LGW initiated commands 1724 * Kernel Thread helper functions for LGW initiated commands
1723 */ 1725 */
1724static void 1726static void
1725lcs_start_kernel_thread(struct lcs_card *card) 1727lcs_start_kernel_thread(struct work_struct *work)
1726{ 1728{
1729 struct lcs_card *card = container_of(work, struct lcs_card, kernel_thread_starter);
1727 LCS_DBF_TEXT(5, trace, "krnthrd"); 1730 LCS_DBF_TEXT(5, trace, "krnthrd");
1728 if (lcs_do_start_thread(card, LCS_RECOVERY_THREAD)) 1731 if (lcs_do_start_thread(card, LCS_RECOVERY_THREAD))
1729 kernel_thread(lcs_recovery, (void *) card, SIGCHLD); 1732 kernel_thread(lcs_recovery, (void *) card, SIGCHLD);
@@ -1871,7 +1874,7 @@ lcs_stop_device(struct net_device *dev)
1871 netif_tx_disable(dev); 1874 netif_tx_disable(dev);
1872 dev->flags &= ~IFF_UP; 1875 dev->flags &= ~IFF_UP;
1873 wait_event(card->write.wait_q, 1876 wait_event(card->write.wait_q,
1874 (card->write.state != CH_STATE_RUNNING)); 1877 (card->write.state != LCS_CH_STATE_RUNNING));
1875 rc = lcs_stopcard(card); 1878 rc = lcs_stopcard(card);
1876 if (rc) 1879 if (rc)
1877 PRINT_ERR("Try it again!\n "); 1880 PRINT_ERR("Try it again!\n ");
@@ -2051,8 +2054,7 @@ lcs_probe_device(struct ccwgroup_device *ccwgdev)
2051 ccwgdev->cdev[0]->handler = lcs_irq; 2054 ccwgdev->cdev[0]->handler = lcs_irq;
2052 ccwgdev->cdev[1]->handler = lcs_irq; 2055 ccwgdev->cdev[1]->handler = lcs_irq;
2053 card->gdev = ccwgdev; 2056 card->gdev = ccwgdev;
2054 INIT_WORK(&card->kernel_thread_starter, 2057 INIT_WORK(&card->kernel_thread_starter, lcs_start_kernel_thread);
2055 (void *) lcs_start_kernel_thread, card);
2056 card->thread_start_mask = 0; 2058 card->thread_start_mask = 0;
2057 card->thread_allowed_mask = 0; 2059 card->thread_allowed_mask = 0;
2058 card->thread_running_mask = 0; 2060 card->thread_running_mask = 0;
diff --git a/drivers/s390/net/lcs.h b/drivers/s390/net/lcs.h
index 93143932983b..0e1e4a0a88f0 100644
--- a/drivers/s390/net/lcs.h
+++ b/drivers/s390/net/lcs.h
@@ -23,11 +23,6 @@ do { \
23} while (0) 23} while (0)
24 24
25/** 25/**
26 * some more definitions for debug or output stuff
27 */
28#define PRINTK_HEADER " lcs: "
29
30/**
31 * sysfs related stuff 26 * sysfs related stuff
32 */ 27 */
33#define CARD_FROM_DEV(cdev) \ 28#define CARD_FROM_DEV(cdev) \
@@ -127,22 +122,22 @@ do { \
127 * LCS Buffer states 122 * LCS Buffer states
128 */ 123 */
129enum lcs_buffer_states { 124enum lcs_buffer_states {
130 BUF_STATE_EMPTY, /* buffer is empty */ 125 LCS_BUF_STATE_EMPTY, /* buffer is empty */
131 BUF_STATE_LOCKED, /* buffer is locked, don't touch */ 126 LCS_BUF_STATE_LOCKED, /* buffer is locked, don't touch */
132 BUF_STATE_READY, /* buffer is ready for read/write */ 127 LCS_BUF_STATE_READY, /* buffer is ready for read/write */
133 BUF_STATE_PROCESSED, 128 LCS_BUF_STATE_PROCESSED,
134}; 129};
135 130
136/** 131/**
137 * LCS Channel State Machine declarations 132 * LCS Channel State Machine declarations
138 */ 133 */
139enum lcs_channel_states { 134enum lcs_channel_states {
140 CH_STATE_INIT, 135 LCS_CH_STATE_INIT,
141 CH_STATE_HALTED, 136 LCS_CH_STATE_HALTED,
142 CH_STATE_STOPPED, 137 LCS_CH_STATE_STOPPED,
143 CH_STATE_RUNNING, 138 LCS_CH_STATE_RUNNING,
144 CH_STATE_SUSPENDED, 139 LCS_CH_STATE_SUSPENDED,
145 CH_STATE_CLEARED, 140 LCS_CH_STATE_CLEARED,
146}; 141};
147 142
148/** 143/**
@@ -169,7 +164,7 @@ struct lcs_header {
169} __attribute__ ((packed)); 164} __attribute__ ((packed));
170 165
171struct lcs_ip_mac_pair { 166struct lcs_ip_mac_pair {
172 __u32 ip_addr; 167 __be32 ip_addr;
173 __u8 mac_addr[LCS_MAC_LENGTH]; 168 __u8 mac_addr[LCS_MAC_LENGTH];
174 __u8 reserved[2]; 169 __u8 reserved[2];
175} __attribute__ ((packed)); 170} __attribute__ ((packed));
@@ -287,7 +282,7 @@ struct lcs_card {
287 enum lcs_dev_states state; 282 enum lcs_dev_states state;
288 struct net_device *dev; 283 struct net_device *dev;
289 struct net_device_stats stats; 284 struct net_device_stats stats;
290 unsigned short (*lan_type_trans)(struct sk_buff *skb, 285 __be16 (*lan_type_trans)(struct sk_buff *skb,
291 struct net_device *dev); 286 struct net_device *dev);
292 struct ccwgroup_device *gdev; 287 struct ccwgroup_device *gdev;
293 struct lcs_channel read; 288 struct lcs_channel read;
diff --git a/drivers/s390/net/qeth.h b/drivers/s390/net/qeth.h
index 821383d8cbe7..53c358c7d368 100644
--- a/drivers/s390/net/qeth.h
+++ b/drivers/s390/net/qeth.h
@@ -151,8 +151,6 @@ qeth_hex_dump(unsigned char *buf, size_t len)
151#define SENSE_RESETTING_EVENT_BYTE 1 151#define SENSE_RESETTING_EVENT_BYTE 1
152#define SENSE_RESETTING_EVENT_FLAG 0x80 152#define SENSE_RESETTING_EVENT_FLAG 0x80
153 153
154#define atomic_swap(a,b) xchg((int *)a.counter, b)
155
156/* 154/*
157 * Common IO related definitions 155 * Common IO related definitions
158 */ 156 */
diff --git a/drivers/s390/net/qeth_eddp.c b/drivers/s390/net/qeth_eddp.c
index a363721cf28d..6bb558a9a032 100644
--- a/drivers/s390/net/qeth_eddp.c
+++ b/drivers/s390/net/qeth_eddp.c
@@ -258,7 +258,7 @@ qeth_eddp_create_segment_hdrs(struct qeth_eddp_context *ctx,
258 258
259static inline void 259static inline void
260qeth_eddp_copy_data_tcp(char *dst, struct qeth_eddp_data *eddp, int len, 260qeth_eddp_copy_data_tcp(char *dst, struct qeth_eddp_data *eddp, int len,
261 u32 *hcsum) 261 __wsum *hcsum)
262{ 262{
263 struct skb_frag_struct *frag; 263 struct skb_frag_struct *frag;
264 int left_in_frag; 264 int left_in_frag;
@@ -305,7 +305,7 @@ qeth_eddp_copy_data_tcp(char *dst, struct qeth_eddp_data *eddp, int len,
305static inline void 305static inline void
306qeth_eddp_create_segment_data_tcp(struct qeth_eddp_context *ctx, 306qeth_eddp_create_segment_data_tcp(struct qeth_eddp_context *ctx,
307 struct qeth_eddp_data *eddp, int data_len, 307 struct qeth_eddp_data *eddp, int data_len,
308 u32 hcsum) 308 __wsum hcsum)
309{ 309{
310 u8 *page; 310 u8 *page;
311 int page_remainder; 311 int page_remainder;
@@ -349,10 +349,10 @@ qeth_eddp_create_segment_data_tcp(struct qeth_eddp_context *ctx,
349 ((struct tcphdr *)eddp->th_in_ctx)->check = csum_fold(hcsum); 349 ((struct tcphdr *)eddp->th_in_ctx)->check = csum_fold(hcsum);
350} 350}
351 351
352static inline u32 352static inline __wsum
353qeth_eddp_check_tcp4_hdr(struct qeth_eddp_data *eddp, int data_len) 353qeth_eddp_check_tcp4_hdr(struct qeth_eddp_data *eddp, int data_len)
354{ 354{
355 u32 phcsum; /* pseudo header checksum */ 355 __wsum phcsum; /* pseudo header checksum */
356 356
357 QETH_DBF_TEXT(trace, 5, "eddpckt4"); 357 QETH_DBF_TEXT(trace, 5, "eddpckt4");
358 eddp->th.tcp.h.check = 0; 358 eddp->th.tcp.h.check = 0;
@@ -363,11 +363,11 @@ qeth_eddp_check_tcp4_hdr(struct qeth_eddp_data *eddp, int data_len)
363 return csum_partial((u8 *)&eddp->th, eddp->thl, phcsum); 363 return csum_partial((u8 *)&eddp->th, eddp->thl, phcsum);
364} 364}
365 365
366static inline u32 366static inline __wsum
367qeth_eddp_check_tcp6_hdr(struct qeth_eddp_data *eddp, int data_len) 367qeth_eddp_check_tcp6_hdr(struct qeth_eddp_data *eddp, int data_len)
368{ 368{
369 u32 proto; 369 __be32 proto;
370 u32 phcsum; /* pseudo header checksum */ 370 __wsum phcsum; /* pseudo header checksum */
371 371
372 QETH_DBF_TEXT(trace, 5, "eddpckt6"); 372 QETH_DBF_TEXT(trace, 5, "eddpckt6");
373 eddp->th.tcp.h.check = 0; 373 eddp->th.tcp.h.check = 0;
@@ -405,7 +405,7 @@ __qeth_eddp_fill_context_tcp(struct qeth_eddp_context *ctx,
405{ 405{
406 struct tcphdr *tcph; 406 struct tcphdr *tcph;
407 int data_len; 407 int data_len;
408 u32 hcsum; 408 __wsum hcsum;
409 409
410 QETH_DBF_TEXT(trace, 5, "eddpftcp"); 410 QETH_DBF_TEXT(trace, 5, "eddpftcp");
411 eddp->skb_offset = sizeof(struct qeth_hdr) + eddp->nhl + eddp->thl; 411 eddp->skb_offset = sizeof(struct qeth_hdr) + eddp->nhl + eddp->thl;
@@ -433,22 +433,22 @@ __qeth_eddp_fill_context_tcp(struct qeth_eddp_context *ctx,
433 eddp->qh.hdr.l3.length = data_len + eddp->nhl + 433 eddp->qh.hdr.l3.length = data_len + eddp->nhl +
434 eddp->thl; 434 eddp->thl;
435 /* prepare ip hdr */ 435 /* prepare ip hdr */
436 if (eddp->skb->protocol == ETH_P_IP){ 436 if (eddp->skb->protocol == htons(ETH_P_IP)){
437 eddp->nh.ip4.h.tot_len = data_len + eddp->nhl + 437 eddp->nh.ip4.h.tot_len = htons(data_len + eddp->nhl +
438 eddp->thl; 438 eddp->thl);
439 eddp->nh.ip4.h.check = 0; 439 eddp->nh.ip4.h.check = 0;
440 eddp->nh.ip4.h.check = 440 eddp->nh.ip4.h.check =
441 ip_fast_csum((u8 *)&eddp->nh.ip4.h, 441 ip_fast_csum((u8 *)&eddp->nh.ip4.h,
442 eddp->nh.ip4.h.ihl); 442 eddp->nh.ip4.h.ihl);
443 } else 443 } else
444 eddp->nh.ip6.h.payload_len = data_len + eddp->thl; 444 eddp->nh.ip6.h.payload_len = htons(data_len + eddp->thl);
445 /* prepare tcp hdr */ 445 /* prepare tcp hdr */
446 if (data_len == (eddp->skb->len - eddp->skb_offset)){ 446 if (data_len == (eddp->skb->len - eddp->skb_offset)){
447 /* last segment -> set FIN and PSH flags */ 447 /* last segment -> set FIN and PSH flags */
448 eddp->th.tcp.h.fin = tcph->fin; 448 eddp->th.tcp.h.fin = tcph->fin;
449 eddp->th.tcp.h.psh = tcph->psh; 449 eddp->th.tcp.h.psh = tcph->psh;
450 } 450 }
451 if (eddp->skb->protocol == ETH_P_IP) 451 if (eddp->skb->protocol == htons(ETH_P_IP))
452 hcsum = qeth_eddp_check_tcp4_hdr(eddp, data_len); 452 hcsum = qeth_eddp_check_tcp4_hdr(eddp, data_len);
453 else 453 else
454 hcsum = qeth_eddp_check_tcp6_hdr(eddp, data_len); 454 hcsum = qeth_eddp_check_tcp6_hdr(eddp, data_len);
@@ -458,9 +458,9 @@ __qeth_eddp_fill_context_tcp(struct qeth_eddp_context *ctx,
458 if (eddp->skb_offset >= eddp->skb->len) 458 if (eddp->skb_offset >= eddp->skb->len)
459 break; 459 break;
460 /* prepare headers for next round */ 460 /* prepare headers for next round */
461 if (eddp->skb->protocol == ETH_P_IP) 461 if (eddp->skb->protocol == htons(ETH_P_IP))
462 eddp->nh.ip4.h.id++; 462 eddp->nh.ip4.h.id = htons(ntohs(eddp->nh.ip4.h.id) + 1);
463 eddp->th.tcp.h.seq += data_len; 463 eddp->th.tcp.h.seq = htonl(ntohl(eddp->th.tcp.h.seq) + data_len);
464 } 464 }
465} 465}
466 466
@@ -472,7 +472,7 @@ qeth_eddp_fill_context_tcp(struct qeth_eddp_context *ctx,
472 472
473 QETH_DBF_TEXT(trace, 5, "eddpficx"); 473 QETH_DBF_TEXT(trace, 5, "eddpficx");
474 /* create our segmentation headers and copy original headers */ 474 /* create our segmentation headers and copy original headers */
475 if (skb->protocol == ETH_P_IP) 475 if (skb->protocol == htons(ETH_P_IP))
476 eddp = qeth_eddp_create_eddp_data(qhdr, (u8 *)skb->nh.iph, 476 eddp = qeth_eddp_create_eddp_data(qhdr, (u8 *)skb->nh.iph,
477 skb->nh.iph->ihl*4, 477 skb->nh.iph->ihl*4,
478 (u8 *)skb->h.th, skb->h.th->doff*4); 478 (u8 *)skb->h.th, skb->h.th->doff*4);
@@ -490,7 +490,7 @@ qeth_eddp_fill_context_tcp(struct qeth_eddp_context *ctx,
490 memcpy(&eddp->mac, eth_hdr(skb), ETH_HLEN); 490 memcpy(&eddp->mac, eth_hdr(skb), ETH_HLEN);
491#ifdef CONFIG_QETH_VLAN 491#ifdef CONFIG_QETH_VLAN
492 if (eddp->mac.h_proto == __constant_htons(ETH_P_8021Q)) { 492 if (eddp->mac.h_proto == __constant_htons(ETH_P_8021Q)) {
493 eddp->vlan[0] = __constant_htons(skb->protocol); 493 eddp->vlan[0] = skb->protocol;
494 eddp->vlan[1] = htons(vlan_tx_tag_get(skb)); 494 eddp->vlan[1] = htons(vlan_tx_tag_get(skb));
495 } 495 }
496#endif /* CONFIG_QETH_VLAN */ 496#endif /* CONFIG_QETH_VLAN */
@@ -588,11 +588,11 @@ qeth_eddp_create_context_tcp(struct qeth_card *card, struct sk_buff *skb,
588 struct qeth_eddp_context *ctx = NULL; 588 struct qeth_eddp_context *ctx = NULL;
589 589
590 QETH_DBF_TEXT(trace, 5, "creddpct"); 590 QETH_DBF_TEXT(trace, 5, "creddpct");
591 if (skb->protocol == ETH_P_IP) 591 if (skb->protocol == htons(ETH_P_IP))
592 ctx = qeth_eddp_create_context_generic(card, skb, 592 ctx = qeth_eddp_create_context_generic(card, skb,
593 sizeof(struct qeth_hdr) + skb->nh.iph->ihl*4 + 593 sizeof(struct qeth_hdr) + skb->nh.iph->ihl*4 +
594 skb->h.th->doff*4); 594 skb->h.th->doff*4);
595 else if (skb->protocol == ETH_P_IPV6) 595 else if (skb->protocol == htons(ETH_P_IPV6))
596 ctx = qeth_eddp_create_context_generic(card, skb, 596 ctx = qeth_eddp_create_context_generic(card, skb,
597 sizeof(struct qeth_hdr) + sizeof(struct ipv6hdr) + 597 sizeof(struct qeth_hdr) + sizeof(struct ipv6hdr) +
598 skb->h.th->doff*4); 598 skb->h.th->doff*4);
diff --git a/drivers/s390/net/qeth_eddp.h b/drivers/s390/net/qeth_eddp.h
index cae9ba265056..103768d3bab2 100644
--- a/drivers/s390/net/qeth_eddp.h
+++ b/drivers/s390/net/qeth_eddp.h
@@ -54,7 +54,7 @@ qeth_eddp_check_buffers_for_context(struct qeth_qdio_out_q *,
54struct qeth_eddp_data { 54struct qeth_eddp_data {
55 struct qeth_hdr qh; 55 struct qeth_hdr qh;
56 struct ethhdr mac; 56 struct ethhdr mac;
57 u16 vlan[2]; 57 __be16 vlan[2];
58 union { 58 union {
59 struct { 59 struct {
60 struct iphdr h; 60 struct iphdr h;
diff --git a/drivers/s390/net/qeth_main.c b/drivers/s390/net/qeth_main.c
index 8364d5475ac7..2bde4f1fb9c2 100644
--- a/drivers/s390/net/qeth_main.c
+++ b/drivers/s390/net/qeth_main.c
@@ -1039,8 +1039,9 @@ qeth_do_start_thread(struct qeth_card *card, unsigned long thread)
1039} 1039}
1040 1040
1041static void 1041static void
1042qeth_start_kernel_thread(struct qeth_card *card) 1042qeth_start_kernel_thread(struct work_struct *work)
1043{ 1043{
1044 struct qeth_card *card = container_of(work, struct qeth_card, kernel_thread_starter);
1044 QETH_DBF_TEXT(trace , 2, "strthrd"); 1045 QETH_DBF_TEXT(trace , 2, "strthrd");
1045 1046
1046 if (card->read.state != CH_STATE_UP && 1047 if (card->read.state != CH_STATE_UP &&
@@ -1103,8 +1104,7 @@ qeth_setup_card(struct qeth_card *card)
1103 card->thread_start_mask = 0; 1104 card->thread_start_mask = 0;
1104 card->thread_allowed_mask = 0; 1105 card->thread_allowed_mask = 0;
1105 card->thread_running_mask = 0; 1106 card->thread_running_mask = 0;
1106 INIT_WORK(&card->kernel_thread_starter, 1107 INIT_WORK(&card->kernel_thread_starter, qeth_start_kernel_thread);
1107 (void *)qeth_start_kernel_thread,card);
1108 INIT_LIST_HEAD(&card->ip_list); 1108 INIT_LIST_HEAD(&card->ip_list);
1109 card->ip_tbd_list = kmalloc(sizeof(struct list_head), GFP_KERNEL); 1109 card->ip_tbd_list = kmalloc(sizeof(struct list_head), GFP_KERNEL);
1110 if (!card->ip_tbd_list) { 1110 if (!card->ip_tbd_list) {
@@ -2982,7 +2982,7 @@ qeth_check_outbound_queue(struct qeth_qdio_out_q *queue)
2982 */ 2982 */
2983 if ((atomic_read(&queue->used_buffers) <= QETH_LOW_WATERMARK_PACK) || 2983 if ((atomic_read(&queue->used_buffers) <= QETH_LOW_WATERMARK_PACK) ||
2984 !atomic_read(&queue->set_pci_flags_count)){ 2984 !atomic_read(&queue->set_pci_flags_count)){
2985 if (atomic_swap(&queue->state, QETH_OUT_Q_LOCKED_FLUSH) == 2985 if (atomic_xchg(&queue->state, QETH_OUT_Q_LOCKED_FLUSH) ==
2986 QETH_OUT_Q_UNLOCKED) { 2986 QETH_OUT_Q_UNLOCKED) {
2987 /* 2987 /*
2988 * If we get in here, there was no action in 2988 * If we get in here, there was no action in
@@ -3245,7 +3245,7 @@ qeth_free_qdio_buffers(struct qeth_card *card)
3245 int i, j; 3245 int i, j;
3246 3246
3247 QETH_DBF_TEXT(trace, 2, "freeqdbf"); 3247 QETH_DBF_TEXT(trace, 2, "freeqdbf");
3248 if (atomic_swap(&card->qdio.state, QETH_QDIO_UNINITIALIZED) == 3248 if (atomic_xchg(&card->qdio.state, QETH_QDIO_UNINITIALIZED) ==
3249 QETH_QDIO_UNINITIALIZED) 3249 QETH_QDIO_UNINITIALIZED)
3250 return; 3250 return;
3251 kfree(card->qdio.in_q); 3251 kfree(card->qdio.in_q);
@@ -4366,7 +4366,7 @@ out:
4366 if (flush_count) 4366 if (flush_count)
4367 qeth_flush_buffers(queue, 0, start_index, flush_count); 4367 qeth_flush_buffers(queue, 0, start_index, flush_count);
4368 else if (!atomic_read(&queue->set_pci_flags_count)) 4368 else if (!atomic_read(&queue->set_pci_flags_count))
4369 atomic_swap(&queue->state, QETH_OUT_Q_LOCKED_FLUSH); 4369 atomic_xchg(&queue->state, QETH_OUT_Q_LOCKED_FLUSH);
4370 /* 4370 /*
4371 * queue->state will go from LOCKED -> UNLOCKED or from 4371 * queue->state will go from LOCKED -> UNLOCKED or from
4372 * LOCKED_FLUSH -> LOCKED if output_handler wanted to 'notify' us 4372 * LOCKED_FLUSH -> LOCKED if output_handler wanted to 'notify' us
diff --git a/drivers/s390/scsi/zfcp_def.h b/drivers/s390/scsi/zfcp_def.h
index 74c0eac083e4..32933ed54b8a 100644
--- a/drivers/s390/scsi/zfcp_def.h
+++ b/drivers/s390/scsi/zfcp_def.h
@@ -1032,9 +1032,9 @@ struct zfcp_data {
1032 wwn_t init_wwpn; 1032 wwn_t init_wwpn;
1033 fcp_lun_t init_fcp_lun; 1033 fcp_lun_t init_fcp_lun;
1034 char *driver_version; 1034 char *driver_version;
1035 kmem_cache_t *fsf_req_qtcb_cache; 1035 struct kmem_cache *fsf_req_qtcb_cache;
1036 kmem_cache_t *sr_buffer_cache; 1036 struct kmem_cache *sr_buffer_cache;
1037 kmem_cache_t *gid_pn_cache; 1037 struct kmem_cache *gid_pn_cache;
1038}; 1038};
1039 1039
1040/** 1040/**
diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c
index 277826cdd0c8..067f1519eb04 100644
--- a/drivers/s390/scsi/zfcp_fsf.c
+++ b/drivers/s390/scsi/zfcp_fsf.c
@@ -109,7 +109,7 @@ zfcp_fsf_req_alloc(mempool_t *pool, int req_flags)
109 ptr = kmalloc(size, GFP_ATOMIC); 109 ptr = kmalloc(size, GFP_ATOMIC);
110 else 110 else
111 ptr = kmem_cache_alloc(zfcp_data.fsf_req_qtcb_cache, 111 ptr = kmem_cache_alloc(zfcp_data.fsf_req_qtcb_cache,
112 SLAB_ATOMIC); 112 GFP_ATOMIC);
113 } 113 }
114 114
115 if (unlikely(!ptr)) 115 if (unlikely(!ptr))
diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
index 5f8c26cd66ca..b091a0fc4eb0 100644
--- a/drivers/scsi/3w-9xxx.c
+++ b/drivers/scsi/3w-9xxx.c
@@ -66,6 +66,9 @@
66 2.26.02.006 - Fix 9550SX pchip reset timeout. 66 2.26.02.006 - Fix 9550SX pchip reset timeout.
67 Add big endian support. 67 Add big endian support.
68 2.26.02.007 - Disable local interrupts during kmap/unmap_atomic(). 68 2.26.02.007 - Disable local interrupts during kmap/unmap_atomic().
69 2.26.02.008 - Free irq handler in __twa_shutdown().
70 Serialize reset code.
71 Add support for 9650SE controllers.
69*/ 72*/
70 73
71#include <linux/module.h> 74#include <linux/module.h>
@@ -89,7 +92,7 @@
89#include "3w-9xxx.h" 92#include "3w-9xxx.h"
90 93
91/* Globals */ 94/* Globals */
92#define TW_DRIVER_VERSION "2.26.02.007" 95#define TW_DRIVER_VERSION "2.26.02.008"
93static TW_Device_Extension *twa_device_extension_list[TW_MAX_SLOT]; 96static TW_Device_Extension *twa_device_extension_list[TW_MAX_SLOT];
94static unsigned int twa_device_extension_count; 97static unsigned int twa_device_extension_count;
95static int twa_major = -1; 98static int twa_major = -1;
@@ -566,9 +569,9 @@ static int twa_check_srl(TW_Device_Extension *tw_dev, int *flashed)
566 goto out; 569 goto out;
567 } 570 }
568 571
569 tw_dev->working_srl = fw_on_ctlr_srl; 572 tw_dev->tw_compat_info.working_srl = fw_on_ctlr_srl;
570 tw_dev->working_branch = fw_on_ctlr_branch; 573 tw_dev->tw_compat_info.working_branch = fw_on_ctlr_branch;
571 tw_dev->working_build = fw_on_ctlr_build; 574 tw_dev->tw_compat_info.working_build = fw_on_ctlr_build;
572 575
573 /* Try base mode compatibility */ 576 /* Try base mode compatibility */
574 if (!(init_connect_result & TW_CTLR_FW_COMPATIBLE)) { 577 if (!(init_connect_result & TW_CTLR_FW_COMPATIBLE)) {
@@ -590,10 +593,23 @@ static int twa_check_srl(TW_Device_Extension *tw_dev, int *flashed)
590 } 593 }
591 goto out; 594 goto out;
592 } 595 }
593 tw_dev->working_srl = TW_BASE_FW_SRL; 596 tw_dev->tw_compat_info.working_srl = TW_BASE_FW_SRL;
594 tw_dev->working_branch = TW_BASE_FW_BRANCH; 597 tw_dev->tw_compat_info.working_branch = TW_BASE_FW_BRANCH;
595 tw_dev->working_build = TW_BASE_FW_BUILD; 598 tw_dev->tw_compat_info.working_build = TW_BASE_FW_BUILD;
596 } 599 }
600
601 /* Load rest of compatibility struct */
602 strncpy(tw_dev->tw_compat_info.driver_version, TW_DRIVER_VERSION, strlen(TW_DRIVER_VERSION));
603 tw_dev->tw_compat_info.driver_srl_high = TW_CURRENT_DRIVER_SRL;
604 tw_dev->tw_compat_info.driver_branch_high = TW_CURRENT_DRIVER_BRANCH;
605 tw_dev->tw_compat_info.driver_build_high = TW_CURRENT_DRIVER_BUILD;
606 tw_dev->tw_compat_info.driver_srl_low = TW_BASE_FW_SRL;
607 tw_dev->tw_compat_info.driver_branch_low = TW_BASE_FW_BRANCH;
608 tw_dev->tw_compat_info.driver_build_low = TW_BASE_FW_BUILD;
609 tw_dev->tw_compat_info.fw_on_ctlr_srl = fw_on_ctlr_srl;
610 tw_dev->tw_compat_info.fw_on_ctlr_branch = fw_on_ctlr_branch;
611 tw_dev->tw_compat_info.fw_on_ctlr_build = fw_on_ctlr_build;
612
597 retval = 0; 613 retval = 0;
598out: 614out:
599 return retval; 615 return retval;
@@ -631,7 +647,7 @@ static int twa_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int
631 goto out2; 647 goto out2;
632 648
633 /* Check data buffer size */ 649 /* Check data buffer size */
634 if (driver_command.buffer_length > TW_MAX_SECTORS * 512) { 650 if (driver_command.buffer_length > TW_MAX_SECTORS * 2048) {
635 retval = TW_IOCTL_ERROR_OS_EINVAL; 651 retval = TW_IOCTL_ERROR_OS_EINVAL;
636 goto out2; 652 goto out2;
637 } 653 }
@@ -680,13 +696,6 @@ static int twa_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int
680 /* Now wait for command to complete */ 696 /* Now wait for command to complete */
681 timeout = wait_event_timeout(tw_dev->ioctl_wqueue, tw_dev->chrdev_request_id == TW_IOCTL_CHRDEV_FREE, timeout); 697 timeout = wait_event_timeout(tw_dev->ioctl_wqueue, tw_dev->chrdev_request_id == TW_IOCTL_CHRDEV_FREE, timeout);
682 698
683 /* See if we reset while waiting for the ioctl to complete */
684 if (test_bit(TW_IN_RESET, &tw_dev->flags)) {
685 clear_bit(TW_IN_RESET, &tw_dev->flags);
686 retval = TW_IOCTL_ERROR_OS_ERESTARTSYS;
687 goto out3;
688 }
689
690 /* We timed out, and didn't get an interrupt */ 699 /* We timed out, and didn't get an interrupt */
691 if (tw_dev->chrdev_request_id != TW_IOCTL_CHRDEV_FREE) { 700 if (tw_dev->chrdev_request_id != TW_IOCTL_CHRDEV_FREE) {
692 /* Now we need to reset the board */ 701 /* Now we need to reset the board */
@@ -694,11 +703,6 @@ static int twa_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int
694 tw_dev->host->host_no, TW_DRIVER, 0xc, 703 tw_dev->host->host_no, TW_DRIVER, 0xc,
695 cmd); 704 cmd);
696 retval = TW_IOCTL_ERROR_OS_EIO; 705 retval = TW_IOCTL_ERROR_OS_EIO;
697 spin_lock_irqsave(tw_dev->host->host_lock, flags);
698 tw_dev->state[request_id] = TW_S_COMPLETED;
699 twa_free_request_id(tw_dev, request_id);
700 tw_dev->posted_request_count--;
701 spin_unlock_irqrestore(tw_dev->host->host_lock, flags);
702 twa_reset_device_extension(tw_dev, 1); 706 twa_reset_device_extension(tw_dev, 1);
703 goto out3; 707 goto out3;
704 } 708 }
@@ -717,16 +721,7 @@ static int twa_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int
717 tw_ioctl->driver_command.status = 0; 721 tw_ioctl->driver_command.status = 0;
718 /* Copy compatiblity struct into ioctl data buffer */ 722 /* Copy compatiblity struct into ioctl data buffer */
719 tw_compat_info = (TW_Compatibility_Info *)tw_ioctl->data_buffer; 723 tw_compat_info = (TW_Compatibility_Info *)tw_ioctl->data_buffer;
720 strncpy(tw_compat_info->driver_version, TW_DRIVER_VERSION, strlen(TW_DRIVER_VERSION)); 724 memcpy(tw_compat_info, &tw_dev->tw_compat_info, sizeof(TW_Compatibility_Info));
721 tw_compat_info->working_srl = tw_dev->working_srl;
722 tw_compat_info->working_branch = tw_dev->working_branch;
723 tw_compat_info->working_build = tw_dev->working_build;
724 tw_compat_info->driver_srl_high = TW_CURRENT_DRIVER_SRL;
725 tw_compat_info->driver_branch_high = TW_CURRENT_DRIVER_BRANCH;
726 tw_compat_info->driver_build_high = TW_CURRENT_DRIVER_BUILD;
727 tw_compat_info->driver_srl_low = TW_BASE_FW_SRL;
728 tw_compat_info->driver_branch_low = TW_BASE_FW_BRANCH;
729 tw_compat_info->driver_build_low = TW_BASE_FW_BUILD;
730 break; 725 break;
731 case TW_IOCTL_GET_LAST_EVENT: 726 case TW_IOCTL_GET_LAST_EVENT:
732 if (tw_dev->event_queue_wrapped) { 727 if (tw_dev->event_queue_wrapped) {
@@ -895,7 +890,8 @@ static int twa_decode_bits(TW_Device_Extension *tw_dev, u32 status_reg_value)
895 } 890 }
896 891
897 if (status_reg_value & TW_STATUS_QUEUE_ERROR) { 892 if (status_reg_value & TW_STATUS_QUEUE_ERROR) {
898 TW_PRINTK(tw_dev->host, TW_DRIVER, 0xe, "Controller Queue Error: clearing"); 893 if ((tw_dev->tw_pci_dev->device != PCI_DEVICE_ID_3WARE_9650SE) || (!test_bit(TW_IN_RESET, &tw_dev->flags)))
894 TW_PRINTK(tw_dev->host, TW_DRIVER, 0xe, "Controller Queue Error: clearing");
899 writel(TW_CONTROL_CLEAR_QUEUE_ERROR, TW_CONTROL_REG_ADDR(tw_dev)); 895 writel(TW_CONTROL_CLEAR_QUEUE_ERROR, TW_CONTROL_REG_ADDR(tw_dev));
900 } 896 }
901 897
@@ -939,10 +935,12 @@ static int twa_empty_response_queue_large(TW_Device_Extension *tw_dev)
939 unsigned long before; 935 unsigned long before;
940 int retval = 1; 936 int retval = 1;
941 937
942 if (tw_dev->tw_pci_dev->device == PCI_DEVICE_ID_3WARE_9550SX) { 938 if ((tw_dev->tw_pci_dev->device == PCI_DEVICE_ID_3WARE_9550SX) ||
939 (tw_dev->tw_pci_dev->device == PCI_DEVICE_ID_3WARE_9650SE)) {
943 before = jiffies; 940 before = jiffies;
944 while ((response_que_value & TW_9550SX_DRAIN_COMPLETED) != TW_9550SX_DRAIN_COMPLETED) { 941 while ((response_que_value & TW_9550SX_DRAIN_COMPLETED) != TW_9550SX_DRAIN_COMPLETED) {
945 response_que_value = readl(TW_RESPONSE_QUEUE_REG_ADDR_LARGE(tw_dev)); 942 response_que_value = readl(TW_RESPONSE_QUEUE_REG_ADDR_LARGE(tw_dev));
943 msleep(1);
946 if (time_after(jiffies, before + HZ * 30)) 944 if (time_after(jiffies, before + HZ * 30))
947 goto out; 945 goto out;
948 } 946 }
@@ -1214,6 +1212,10 @@ static irqreturn_t twa_interrupt(int irq, void *dev_instance)
1214 1212
1215 handled = 1; 1213 handled = 1;
1216 1214
1215 /* If we are resetting, bail */
1216 if (test_bit(TW_IN_RESET, &tw_dev->flags))
1217 goto twa_interrupt_bail;
1218
1217 /* Check controller for errors */ 1219 /* Check controller for errors */
1218 if (twa_check_bits(status_reg_value)) { 1220 if (twa_check_bits(status_reg_value)) {
1219 if (twa_decode_bits(tw_dev, status_reg_value)) { 1221 if (twa_decode_bits(tw_dev, status_reg_value)) {
@@ -1355,8 +1357,8 @@ static void twa_load_sgl(TW_Command_Full *full_command_packet, int request_id, d
1355 1357
1356 if (TW_OP_OUT(full_command_packet->command.newcommand.opcode__reserved) == TW_OP_EXECUTE_SCSI) { 1358 if (TW_OP_OUT(full_command_packet->command.newcommand.opcode__reserved) == TW_OP_EXECUTE_SCSI) {
1357 newcommand = &full_command_packet->command.newcommand; 1359 newcommand = &full_command_packet->command.newcommand;
1358 newcommand->request_id__lunl = 1360 newcommand->request_id__lunl =
1359 TW_REQ_LUN_IN(TW_LUN_OUT(newcommand->request_id__lunl), request_id); 1361 cpu_to_le16(TW_REQ_LUN_IN(TW_LUN_OUT(newcommand->request_id__lunl), request_id));
1360 newcommand->sg_list[0].address = TW_CPU_TO_SGL(dma_handle + sizeof(TW_Ioctl_Buf_Apache) - 1); 1362 newcommand->sg_list[0].address = TW_CPU_TO_SGL(dma_handle + sizeof(TW_Ioctl_Buf_Apache) - 1);
1361 newcommand->sg_list[0].length = cpu_to_le32(length); 1363 newcommand->sg_list[0].length = cpu_to_le32(length);
1362 newcommand->sgl_entries__lunh = 1364 newcommand->sgl_entries__lunh =
@@ -1531,6 +1533,13 @@ static int twa_post_command_packet(TW_Device_Extension *tw_dev, int request_id,
1531 int retval = 1; 1533 int retval = 1;
1532 1534
1533 command_que_value = tw_dev->command_packet_phys[request_id]; 1535 command_que_value = tw_dev->command_packet_phys[request_id];
1536
1537 /* For 9650SE write low 4 bytes first */
1538 if (tw_dev->tw_pci_dev->device == PCI_DEVICE_ID_3WARE_9650SE) {
1539 command_que_value += TW_COMMAND_OFFSET;
1540 writel((u32)command_que_value, TW_COMMAND_QUEUE_REG_ADDR_LARGE(tw_dev));
1541 }
1542
1534 status_reg_value = readl(TW_STATUS_REG_ADDR(tw_dev)); 1543 status_reg_value = readl(TW_STATUS_REG_ADDR(tw_dev));
1535 1544
1536 if (twa_check_bits(status_reg_value)) 1545 if (twa_check_bits(status_reg_value))
@@ -1557,13 +1566,17 @@ static int twa_post_command_packet(TW_Device_Extension *tw_dev, int request_id,
1557 TW_UNMASK_COMMAND_INTERRUPT(tw_dev); 1566 TW_UNMASK_COMMAND_INTERRUPT(tw_dev);
1558 goto out; 1567 goto out;
1559 } else { 1568 } else {
1560 /* We successfully posted the command packet */ 1569 if (tw_dev->tw_pci_dev->device == PCI_DEVICE_ID_3WARE_9650SE) {
1561 if (sizeof(dma_addr_t) > 4) { 1570 /* Now write upper 4 bytes */
1562 command_que_value += TW_COMMAND_OFFSET; 1571 writel((u32)((u64)command_que_value >> 32), TW_COMMAND_QUEUE_REG_ADDR_LARGE(tw_dev) + 0x4);
1563 writel((u32)command_que_value, TW_COMMAND_QUEUE_REG_ADDR(tw_dev));
1564 writel((u32)((u64)command_que_value >> 32), TW_COMMAND_QUEUE_REG_ADDR(tw_dev) + 0x4);
1565 } else { 1572 } else {
1566 writel(TW_COMMAND_OFFSET + command_que_value, TW_COMMAND_QUEUE_REG_ADDR(tw_dev)); 1573 if (sizeof(dma_addr_t) > 4) {
1574 command_que_value += TW_COMMAND_OFFSET;
1575 writel((u32)command_que_value, TW_COMMAND_QUEUE_REG_ADDR(tw_dev));
1576 writel((u32)((u64)command_que_value >> 32), TW_COMMAND_QUEUE_REG_ADDR(tw_dev) + 0x4);
1577 } else {
1578 writel(TW_COMMAND_OFFSET + command_que_value, TW_COMMAND_QUEUE_REG_ADDR(tw_dev));
1579 }
1567 } 1580 }
1568 tw_dev->state[request_id] = TW_S_POSTED; 1581 tw_dev->state[request_id] = TW_S_POSTED;
1569 tw_dev->posted_request_count++; 1582 tw_dev->posted_request_count++;
@@ -1620,14 +1633,9 @@ static int twa_reset_device_extension(TW_Device_Extension *tw_dev, int ioctl_res
1620 goto out; 1633 goto out;
1621 1634
1622 TW_ENABLE_AND_CLEAR_INTERRUPTS(tw_dev); 1635 TW_ENABLE_AND_CLEAR_INTERRUPTS(tw_dev);
1636 clear_bit(TW_IN_RESET, &tw_dev->flags);
1637 tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE;
1623 1638
1624 /* Wake up any ioctl that was pending before the reset */
1625 if ((tw_dev->chrdev_request_id == TW_IOCTL_CHRDEV_FREE) || (ioctl_reset)) {
1626 clear_bit(TW_IN_RESET, &tw_dev->flags);
1627 } else {
1628 tw_dev->chrdev_request_id = TW_IOCTL_CHRDEV_FREE;
1629 wake_up(&tw_dev->ioctl_wqueue);
1630 }
1631 retval = 0; 1639 retval = 0;
1632out: 1640out:
1633 return retval; 1641 return retval;
@@ -1736,6 +1744,9 @@ static int twa_scsi_eh_reset(struct scsi_cmnd *SCpnt)
1736 "WARNING: (0x%02X:0x%04X): Command (0x%x) timed out, resetting card.\n", 1744 "WARNING: (0x%02X:0x%04X): Command (0x%x) timed out, resetting card.\n",
1737 TW_DRIVER, 0x2c, SCpnt->cmnd[0]); 1745 TW_DRIVER, 0x2c, SCpnt->cmnd[0]);
1738 1746
1747 /* Make sure we are not issuing an ioctl or resetting from ioctl */
1748 mutex_lock(&tw_dev->ioctl_lock);
1749
1739 /* Now reset the card and some of the device extension data */ 1750 /* Now reset the card and some of the device extension data */
1740 if (twa_reset_device_extension(tw_dev, 0)) { 1751 if (twa_reset_device_extension(tw_dev, 0)) {
1741 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x2b, "Controller reset failed during scsi host reset"); 1752 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x2b, "Controller reset failed during scsi host reset");
@@ -1744,6 +1755,7 @@ static int twa_scsi_eh_reset(struct scsi_cmnd *SCpnt)
1744 1755
1745 retval = SUCCESS; 1756 retval = SUCCESS;
1746out: 1757out:
1758 mutex_unlock(&tw_dev->ioctl_lock);
1747 return retval; 1759 return retval;
1748} /* End twa_scsi_eh_reset() */ 1760} /* End twa_scsi_eh_reset() */
1749 1761
@@ -1753,8 +1765,14 @@ static int twa_scsi_queue(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd
1753 int request_id, retval; 1765 int request_id, retval;
1754 TW_Device_Extension *tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata; 1766 TW_Device_Extension *tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata;
1755 1767
1768 /* If we are resetting due to timed out ioctl, report as busy */
1769 if (test_bit(TW_IN_RESET, &tw_dev->flags)) {
1770 retval = SCSI_MLQUEUE_HOST_BUSY;
1771 goto out;
1772 }
1773
1756 /* Check if this FW supports luns */ 1774 /* Check if this FW supports luns */
1757 if ((SCpnt->device->lun != 0) && (tw_dev->working_srl < TW_FW_SRL_LUNS_SUPPORTED)) { 1775 if ((SCpnt->device->lun != 0) && (tw_dev->tw_compat_info.working_srl < TW_FW_SRL_LUNS_SUPPORTED)) {
1758 SCpnt->result = (DID_BAD_TARGET << 16); 1776 SCpnt->result = (DID_BAD_TARGET << 16);
1759 done(SCpnt); 1777 done(SCpnt);
1760 retval = 0; 1778 retval = 0;
@@ -1960,6 +1978,9 @@ static void __twa_shutdown(TW_Device_Extension *tw_dev)
1960 /* Disable interrupts */ 1978 /* Disable interrupts */
1961 TW_DISABLE_INTERRUPTS(tw_dev); 1979 TW_DISABLE_INTERRUPTS(tw_dev);
1962 1980
1981 /* Free up the IRQ */
1982 free_irq(tw_dev->tw_pci_dev->irq, tw_dev);
1983
1963 printk(KERN_WARNING "3w-9xxx: Shutting down host %d.\n", tw_dev->host->host_no); 1984 printk(KERN_WARNING "3w-9xxx: Shutting down host %d.\n", tw_dev->host->host_no);
1964 1985
1965 /* Tell the card we are shutting down */ 1986 /* Tell the card we are shutting down */
@@ -2091,21 +2112,25 @@ static int __devinit twa_probe(struct pci_dev *pdev, const struct pci_device_id
2091 2112
2092 /* Initialize the card */ 2113 /* Initialize the card */
2093 if (twa_reset_sequence(tw_dev, 0)) 2114 if (twa_reset_sequence(tw_dev, 0))
2094 goto out_release_mem_region; 2115 goto out_iounmap;
2095 2116
2096 /* Set host specific parameters */ 2117 /* Set host specific parameters */
2097 host->max_id = TW_MAX_UNITS; 2118 if (pdev->device == PCI_DEVICE_ID_3WARE_9650SE)
2119 host->max_id = TW_MAX_UNITS_9650SE;
2120 else
2121 host->max_id = TW_MAX_UNITS;
2122
2098 host->max_cmd_len = TW_MAX_CDB_LEN; 2123 host->max_cmd_len = TW_MAX_CDB_LEN;
2099 2124
2100 /* Channels aren't supported by adapter */ 2125 /* Channels aren't supported by adapter */
2101 host->max_lun = TW_MAX_LUNS(tw_dev->working_srl); 2126 host->max_lun = TW_MAX_LUNS(tw_dev->tw_compat_info.working_srl);
2102 host->max_channel = 0; 2127 host->max_channel = 0;
2103 2128
2104 /* Register the card with the kernel SCSI layer */ 2129 /* Register the card with the kernel SCSI layer */
2105 retval = scsi_add_host(host, &pdev->dev); 2130 retval = scsi_add_host(host, &pdev->dev);
2106 if (retval) { 2131 if (retval) {
2107 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x27, "scsi add host failed"); 2132 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x27, "scsi add host failed");
2108 goto out_release_mem_region; 2133 goto out_iounmap;
2109 } 2134 }
2110 2135
2111 pci_set_drvdata(pdev, host); 2136 pci_set_drvdata(pdev, host);
@@ -2145,6 +2170,8 @@ static int __devinit twa_probe(struct pci_dev *pdev, const struct pci_device_id
2145 2170
2146out_remove_host: 2171out_remove_host:
2147 scsi_remove_host(host); 2172 scsi_remove_host(host);
2173out_iounmap:
2174 iounmap(tw_dev->base_addr);
2148out_release_mem_region: 2175out_release_mem_region:
2149 pci_release_regions(pdev); 2176 pci_release_regions(pdev);
2150out_free_device_extension: 2177out_free_device_extension:
@@ -2170,12 +2197,12 @@ static void twa_remove(struct pci_dev *pdev)
2170 twa_major = -1; 2197 twa_major = -1;
2171 } 2198 }
2172 2199
2173 /* Free up the IRQ */
2174 free_irq(tw_dev->tw_pci_dev->irq, tw_dev);
2175
2176 /* Shutdown the card */ 2200 /* Shutdown the card */
2177 __twa_shutdown(tw_dev); 2201 __twa_shutdown(tw_dev);
2178 2202
2203 /* Free IO remapping */
2204 iounmap(tw_dev->base_addr);
2205
2179 /* Free up the mem region */ 2206 /* Free up the mem region */
2180 pci_release_regions(pdev); 2207 pci_release_regions(pdev);
2181 2208
@@ -2193,6 +2220,8 @@ static struct pci_device_id twa_pci_tbl[] __devinitdata = {
2193 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 2220 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
2194 { PCI_VENDOR_ID_3WARE, PCI_DEVICE_ID_3WARE_9550SX, 2221 { PCI_VENDOR_ID_3WARE, PCI_DEVICE_ID_3WARE_9550SX,
2195 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 2222 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
2223 { PCI_VENDOR_ID_3WARE, PCI_DEVICE_ID_3WARE_9650SE,
2224 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
2196 { } 2225 { }
2197}; 2226};
2198MODULE_DEVICE_TABLE(pci, twa_pci_tbl); 2227MODULE_DEVICE_TABLE(pci, twa_pci_tbl);
diff --git a/drivers/scsi/3w-9xxx.h b/drivers/scsi/3w-9xxx.h
index e5685be96f45..7901517d4513 100644
--- a/drivers/scsi/3w-9xxx.h
+++ b/drivers/scsi/3w-9xxx.h
@@ -289,7 +289,6 @@ static twa_message_type twa_error_table[] = {
289#define TW_STATUS_VALID_INTERRUPT 0x00DF0000 289#define TW_STATUS_VALID_INTERRUPT 0x00DF0000
290 290
291/* PCI related defines */ 291/* PCI related defines */
292#define TW_NUMDEVICES 1
293#define TW_PCI_CLEAR_PARITY_ERRORS 0xc100 292#define TW_PCI_CLEAR_PARITY_ERRORS 0xc100
294#define TW_PCI_CLEAR_PCI_ABORT 0x2000 293#define TW_PCI_CLEAR_PCI_ABORT 0x2000
295 294
@@ -335,6 +334,7 @@ static twa_message_type twa_error_table[] = {
335#define TW_ALIGNMENT_9000 4 /* 4 bytes */ 334#define TW_ALIGNMENT_9000 4 /* 4 bytes */
336#define TW_ALIGNMENT_9000_SGL 0x3 335#define TW_ALIGNMENT_9000_SGL 0x3
337#define TW_MAX_UNITS 16 336#define TW_MAX_UNITS 16
337#define TW_MAX_UNITS_9650SE 32
338#define TW_INIT_MESSAGE_CREDITS 0x100 338#define TW_INIT_MESSAGE_CREDITS 0x100
339#define TW_INIT_COMMAND_PACKET_SIZE 0x3 339#define TW_INIT_COMMAND_PACKET_SIZE 0x3
340#define TW_INIT_COMMAND_PACKET_SIZE_EXTENDED 0x6 340#define TW_INIT_COMMAND_PACKET_SIZE_EXTENDED 0x6
@@ -354,7 +354,6 @@ static twa_message_type twa_error_table[] = {
354#define TW_MAX_RESPONSE_DRAIN 256 354#define TW_MAX_RESPONSE_DRAIN 256
355#define TW_MAX_AEN_DRAIN 40 355#define TW_MAX_AEN_DRAIN 40
356#define TW_IN_RESET 2 356#define TW_IN_RESET 2
357#define TW_IN_CHRDEV_IOCTL 3
358#define TW_IN_ATTENTION_LOOP 4 357#define TW_IN_ATTENTION_LOOP 4
359#define TW_MAX_SECTORS 256 358#define TW_MAX_SECTORS 256
360#define TW_AEN_WAIT_TIME 1000 359#define TW_AEN_WAIT_TIME 1000
@@ -417,6 +416,9 @@ static twa_message_type twa_error_table[] = {
417#ifndef PCI_DEVICE_ID_3WARE_9550SX 416#ifndef PCI_DEVICE_ID_3WARE_9550SX
418#define PCI_DEVICE_ID_3WARE_9550SX 0x1003 417#define PCI_DEVICE_ID_3WARE_9550SX 0x1003
419#endif 418#endif
419#ifndef PCI_DEVICE_ID_3WARE_9650SE
420#define PCI_DEVICE_ID_3WARE_9650SE 0x1004
421#endif
420 422
421/* Bitmask macros to eliminate bitfields */ 423/* Bitmask macros to eliminate bitfields */
422 424
@@ -442,6 +444,7 @@ static twa_message_type twa_error_table[] = {
442#define TW_CONTROL_REG_ADDR(x) (x->base_addr) 444#define TW_CONTROL_REG_ADDR(x) (x->base_addr)
443#define TW_STATUS_REG_ADDR(x) ((unsigned char __iomem *)x->base_addr + 0x4) 445#define TW_STATUS_REG_ADDR(x) ((unsigned char __iomem *)x->base_addr + 0x4)
444#define TW_COMMAND_QUEUE_REG_ADDR(x) (sizeof(dma_addr_t) > 4 ? ((unsigned char __iomem *)x->base_addr + 0x20) : ((unsigned char __iomem *)x->base_addr + 0x8)) 446#define TW_COMMAND_QUEUE_REG_ADDR(x) (sizeof(dma_addr_t) > 4 ? ((unsigned char __iomem *)x->base_addr + 0x20) : ((unsigned char __iomem *)x->base_addr + 0x8))
447#define TW_COMMAND_QUEUE_REG_ADDR_LARGE(x) ((unsigned char __iomem *)x->base_addr + 0x20)
445#define TW_RESPONSE_QUEUE_REG_ADDR(x) ((unsigned char __iomem *)x->base_addr + 0xC) 448#define TW_RESPONSE_QUEUE_REG_ADDR(x) ((unsigned char __iomem *)x->base_addr + 0xC)
446#define TW_RESPONSE_QUEUE_REG_ADDR_LARGE(x) ((unsigned char __iomem *)x->base_addr + 0x30) 449#define TW_RESPONSE_QUEUE_REG_ADDR_LARGE(x) ((unsigned char __iomem *)x->base_addr + 0x30)
447#define TW_CLEAR_ALL_INTERRUPTS(x) (writel(TW_STATUS_VALID_INTERRUPT, TW_CONTROL_REG_ADDR(x))) 450#define TW_CLEAR_ALL_INTERRUPTS(x) (writel(TW_STATUS_VALID_INTERRUPT, TW_CONTROL_REG_ADDR(x)))
@@ -626,6 +629,9 @@ typedef struct TAG_TW_Compatibility_Info
626 unsigned short driver_srl_low; 629 unsigned short driver_srl_low;
627 unsigned short driver_branch_low; 630 unsigned short driver_branch_low;
628 unsigned short driver_build_low; 631 unsigned short driver_build_low;
632 unsigned short fw_on_ctlr_srl;
633 unsigned short fw_on_ctlr_branch;
634 unsigned short fw_on_ctlr_build;
629} TW_Compatibility_Info; 635} TW_Compatibility_Info;
630 636
631#pragma pack() 637#pragma pack()
@@ -668,9 +674,7 @@ typedef struct TAG_TW_Device_Extension {
668 wait_queue_head_t ioctl_wqueue; 674 wait_queue_head_t ioctl_wqueue;
669 struct mutex ioctl_lock; 675 struct mutex ioctl_lock;
670 char aen_clobber; 676 char aen_clobber;
671 unsigned short working_srl; 677 TW_Compatibility_Info tw_compat_info;
672 unsigned short working_branch;
673 unsigned short working_build;
674} TW_Device_Extension; 678} TW_Device_Extension;
675 679
676#endif /* _3W_9XXX_H */ 680#endif /* _3W_9XXX_H */
diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c
index 562432d017b0..68103e508db7 100644
--- a/drivers/scsi/53c700.c
+++ b/drivers/scsi/53c700.c
@@ -313,7 +313,7 @@ NCR_700_detect(struct scsi_host_template *tpnt,
313 hostdata->status = memory + STATUS_OFFSET; 313 hostdata->status = memory + STATUS_OFFSET;
314 /* all of these offsets are L1_CACHE_BYTES separated. It is fatal 314 /* all of these offsets are L1_CACHE_BYTES separated. It is fatal
315 * if this isn't sufficient separation to avoid dma flushing issues */ 315 * if this isn't sufficient separation to avoid dma flushing issues */
316 BUG_ON(!dma_is_consistent(pScript) && L1_CACHE_BYTES < dma_get_cache_alignment()); 316 BUG_ON(!dma_is_consistent(hostdata->dev, pScript) && L1_CACHE_BYTES < dma_get_cache_alignment());
317 hostdata->slots = (struct NCR_700_command_slot *)(memory + SLOTS_OFFSET); 317 hostdata->slots = (struct NCR_700_command_slot *)(memory + SLOTS_OFFSET);
318 hostdata->dev = dev; 318 hostdata->dev = dev;
319 319
@@ -362,11 +362,11 @@ NCR_700_detect(struct scsi_host_template *tpnt,
362 for (j = 0; j < PATCHES; j++) 362 for (j = 0; j < PATCHES; j++)
363 script[LABELPATCHES[j]] = bS_to_host(pScript + SCRIPT[LABELPATCHES[j]]); 363 script[LABELPATCHES[j]] = bS_to_host(pScript + SCRIPT[LABELPATCHES[j]]);
364 /* now patch up fixed addresses. */ 364 /* now patch up fixed addresses. */
365 script_patch_32(script, MessageLocation, 365 script_patch_32(hostdata->dev, script, MessageLocation,
366 pScript + MSGOUT_OFFSET); 366 pScript + MSGOUT_OFFSET);
367 script_patch_32(script, StatusAddress, 367 script_patch_32(hostdata->dev, script, StatusAddress,
368 pScript + STATUS_OFFSET); 368 pScript + STATUS_OFFSET);
369 script_patch_32(script, ReceiveMsgAddress, 369 script_patch_32(hostdata->dev, script, ReceiveMsgAddress,
370 pScript + MSGIN_OFFSET); 370 pScript + MSGIN_OFFSET);
371 371
372 hostdata->script = script; 372 hostdata->script = script;
@@ -622,8 +622,10 @@ NCR_700_scsi_done(struct NCR_700_Host_Parameters *hostdata,
622 dma_unmap_single(hostdata->dev, slot->dma_handle, sizeof(SCp->sense_buffer), DMA_FROM_DEVICE); 622 dma_unmap_single(hostdata->dev, slot->dma_handle, sizeof(SCp->sense_buffer), DMA_FROM_DEVICE);
623 /* restore the old result if the request sense was 623 /* restore the old result if the request sense was
624 * successful */ 624 * successful */
625 if(result == 0) 625 if (result == 0)
626 result = cmnd[7]; 626 result = cmnd[7];
627 /* restore the original length */
628 SCp->cmd_len = cmnd[8];
627 } else 629 } else
628 NCR_700_unmap(hostdata, SCp, slot); 630 NCR_700_unmap(hostdata, SCp, slot);
629 631
@@ -819,8 +821,9 @@ process_extended_message(struct Scsi_Host *host,
819 shost_printk(KERN_WARNING, host, 821 shost_printk(KERN_WARNING, host,
820 "Unexpected SDTR msg\n"); 822 "Unexpected SDTR msg\n");
821 hostdata->msgout[0] = A_REJECT_MSG; 823 hostdata->msgout[0] = A_REJECT_MSG;
822 dma_cache_sync(hostdata->msgout, 1, DMA_TO_DEVICE); 824 dma_cache_sync(hostdata->dev, hostdata->msgout, 1, DMA_TO_DEVICE);
823 script_patch_16(hostdata->script, MessageCount, 1); 825 script_patch_16(hostdata->dev, hostdata->script,
826 MessageCount, 1);
824 /* SendMsgOut returns, so set up the return 827 /* SendMsgOut returns, so set up the return
825 * address */ 828 * address */
826 resume_offset = hostdata->pScript + Ent_SendMessageWithATN; 829 resume_offset = hostdata->pScript + Ent_SendMessageWithATN;
@@ -831,8 +834,9 @@ process_extended_message(struct Scsi_Host *host,
831 printk(KERN_INFO "scsi%d: (%d:%d), Unsolicited WDTR after CMD, Rejecting\n", 834 printk(KERN_INFO "scsi%d: (%d:%d), Unsolicited WDTR after CMD, Rejecting\n",
832 host->host_no, pun, lun); 835 host->host_no, pun, lun);
833 hostdata->msgout[0] = A_REJECT_MSG; 836 hostdata->msgout[0] = A_REJECT_MSG;
834 dma_cache_sync(hostdata->msgout, 1, DMA_TO_DEVICE); 837 dma_cache_sync(hostdata->dev, hostdata->msgout, 1, DMA_TO_DEVICE);
835 script_patch_16(hostdata->script, MessageCount, 1); 838 script_patch_16(hostdata->dev, hostdata->script, MessageCount,
839 1);
836 resume_offset = hostdata->pScript + Ent_SendMessageWithATN; 840 resume_offset = hostdata->pScript + Ent_SendMessageWithATN;
837 841
838 break; 842 break;
@@ -845,8 +849,9 @@ process_extended_message(struct Scsi_Host *host,
845 printk("\n"); 849 printk("\n");
846 /* just reject it */ 850 /* just reject it */
847 hostdata->msgout[0] = A_REJECT_MSG; 851 hostdata->msgout[0] = A_REJECT_MSG;
848 dma_cache_sync(hostdata->msgout, 1, DMA_TO_DEVICE); 852 dma_cache_sync(hostdata->dev, hostdata->msgout, 1, DMA_TO_DEVICE);
849 script_patch_16(hostdata->script, MessageCount, 1); 853 script_patch_16(hostdata->dev, hostdata->script, MessageCount,
854 1);
850 /* SendMsgOut returns, so set up the return 855 /* SendMsgOut returns, so set up the return
851 * address */ 856 * address */
852 resume_offset = hostdata->pScript + Ent_SendMessageWithATN; 857 resume_offset = hostdata->pScript + Ent_SendMessageWithATN;
@@ -927,8 +932,9 @@ process_message(struct Scsi_Host *host, struct NCR_700_Host_Parameters *hostdata
927 printk("\n"); 932 printk("\n");
928 /* just reject it */ 933 /* just reject it */
929 hostdata->msgout[0] = A_REJECT_MSG; 934 hostdata->msgout[0] = A_REJECT_MSG;
930 dma_cache_sync(hostdata->msgout, 1, DMA_TO_DEVICE); 935 dma_cache_sync(hostdata->dev, hostdata->msgout, 1, DMA_TO_DEVICE);
931 script_patch_16(hostdata->script, MessageCount, 1); 936 script_patch_16(hostdata->dev, hostdata->script, MessageCount,
937 1);
932 /* SendMsgOut returns, so set up the return 938 /* SendMsgOut returns, so set up the return
933 * address */ 939 * address */
934 resume_offset = hostdata->pScript + Ent_SendMessageWithATN; 940 resume_offset = hostdata->pScript + Ent_SendMessageWithATN;
@@ -937,7 +943,7 @@ process_message(struct Scsi_Host *host, struct NCR_700_Host_Parameters *hostdata
937 } 943 }
938 NCR_700_writel(temp, host, TEMP_REG); 944 NCR_700_writel(temp, host, TEMP_REG);
939 /* set us up to receive another message */ 945 /* set us up to receive another message */
940 dma_cache_sync(hostdata->msgin, MSG_ARRAY_SIZE, DMA_FROM_DEVICE); 946 dma_cache_sync(hostdata->dev, hostdata->msgin, MSG_ARRAY_SIZE, DMA_FROM_DEVICE);
941 return resume_offset; 947 return resume_offset;
942} 948}
943 949
@@ -1007,6 +1013,9 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp,
1007 * of the command */ 1013 * of the command */
1008 cmnd[6] = NCR_700_INTERNAL_SENSE_MAGIC; 1014 cmnd[6] = NCR_700_INTERNAL_SENSE_MAGIC;
1009 cmnd[7] = hostdata->status[0]; 1015 cmnd[7] = hostdata->status[0];
1016 cmnd[8] = SCp->cmd_len;
1017 SCp->cmd_len = 6; /* command length for
1018 * REQUEST_SENSE */
1010 slot->pCmd = dma_map_single(hostdata->dev, cmnd, MAX_COMMAND_SIZE, DMA_TO_DEVICE); 1019 slot->pCmd = dma_map_single(hostdata->dev, cmnd, MAX_COMMAND_SIZE, DMA_TO_DEVICE);
1011 slot->dma_handle = dma_map_single(hostdata->dev, SCp->sense_buffer, sizeof(SCp->sense_buffer), DMA_FROM_DEVICE); 1020 slot->dma_handle = dma_map_single(hostdata->dev, SCp->sense_buffer, sizeof(SCp->sense_buffer), DMA_FROM_DEVICE);
1012 slot->SG[0].ins = bS_to_host(SCRIPT_MOVE_DATA_IN | sizeof(SCp->sense_buffer)); 1021 slot->SG[0].ins = bS_to_host(SCRIPT_MOVE_DATA_IN | sizeof(SCp->sense_buffer));
@@ -1014,9 +1023,9 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp,
1014 slot->SG[1].ins = bS_to_host(SCRIPT_RETURN); 1023 slot->SG[1].ins = bS_to_host(SCRIPT_RETURN);
1015 slot->SG[1].pAddr = 0; 1024 slot->SG[1].pAddr = 0;
1016 slot->resume_offset = hostdata->pScript; 1025 slot->resume_offset = hostdata->pScript;
1017 dma_cache_sync(slot->SG, sizeof(slot->SG[0])*2, DMA_TO_DEVICE); 1026 dma_cache_sync(hostdata->dev, slot->SG, sizeof(slot->SG[0])*2, DMA_TO_DEVICE);
1018 dma_cache_sync(SCp->sense_buffer, sizeof(SCp->sense_buffer), DMA_FROM_DEVICE); 1027 dma_cache_sync(hostdata->dev, SCp->sense_buffer, sizeof(SCp->sense_buffer), DMA_FROM_DEVICE);
1019 1028
1020 /* queue the command for reissue */ 1029 /* queue the command for reissue */
1021 slot->state = NCR_700_SLOT_QUEUED; 1030 slot->state = NCR_700_SLOT_QUEUED;
1022 slot->flags = NCR_700_FLAG_AUTOSENSE; 1031 slot->flags = NCR_700_FLAG_AUTOSENSE;
@@ -1131,11 +1140,12 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp,
1131 hostdata->cmd = slot->cmnd; 1140 hostdata->cmd = slot->cmnd;
1132 1141
1133 /* re-patch for this command */ 1142 /* re-patch for this command */
1134 script_patch_32_abs(hostdata->script, CommandAddress, 1143 script_patch_32_abs(hostdata->dev, hostdata->script,
1135 slot->pCmd); 1144 CommandAddress, slot->pCmd);
1136 script_patch_16(hostdata->script, 1145 script_patch_16(hostdata->dev, hostdata->script,
1137 CommandCount, slot->cmnd->cmd_len); 1146 CommandCount, slot->cmnd->cmd_len);
1138 script_patch_32_abs(hostdata->script, SGScriptStartAddress, 1147 script_patch_32_abs(hostdata->dev, hostdata->script,
1148 SGScriptStartAddress,
1139 to32bit(&slot->pSG[0].ins)); 1149 to32bit(&slot->pSG[0].ins));
1140 1150
1141 /* Note: setting SXFER only works if we're 1151 /* Note: setting SXFER only works if we're
@@ -1145,13 +1155,13 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp,
1145 * should therefore always clear ACK */ 1155 * should therefore always clear ACK */
1146 NCR_700_writeb(NCR_700_get_SXFER(hostdata->cmd->device), 1156 NCR_700_writeb(NCR_700_get_SXFER(hostdata->cmd->device),
1147 host, SXFER_REG); 1157 host, SXFER_REG);
1148 dma_cache_sync(hostdata->msgin, 1158 dma_cache_sync(hostdata->dev, hostdata->msgin,
1149 MSG_ARRAY_SIZE, DMA_FROM_DEVICE); 1159 MSG_ARRAY_SIZE, DMA_FROM_DEVICE);
1150 dma_cache_sync(hostdata->msgout, 1160 dma_cache_sync(hostdata->dev, hostdata->msgout,
1151 MSG_ARRAY_SIZE, DMA_TO_DEVICE); 1161 MSG_ARRAY_SIZE, DMA_TO_DEVICE);
1152 /* I'm just being paranoid here, the command should 1162 /* I'm just being paranoid here, the command should
1153 * already have been flushed from the cache */ 1163 * already have been flushed from the cache */
1154 dma_cache_sync(slot->cmnd->cmnd, 1164 dma_cache_sync(hostdata->dev, slot->cmnd->cmnd,
1155 slot->cmnd->cmd_len, DMA_TO_DEVICE); 1165 slot->cmnd->cmd_len, DMA_TO_DEVICE);
1156 1166
1157 1167
@@ -1215,7 +1225,7 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp,
1215 hostdata->reselection_id = reselection_id; 1225 hostdata->reselection_id = reselection_id;
1216 /* just in case we have a stale simple tag message, clear it */ 1226 /* just in case we have a stale simple tag message, clear it */
1217 hostdata->msgin[1] = 0; 1227 hostdata->msgin[1] = 0;
1218 dma_cache_sync(hostdata->msgin, 1228 dma_cache_sync(hostdata->dev, hostdata->msgin,
1219 MSG_ARRAY_SIZE, DMA_BIDIRECTIONAL); 1229 MSG_ARRAY_SIZE, DMA_BIDIRECTIONAL);
1220 if(hostdata->tag_negotiated & (1<<reselection_id)) { 1230 if(hostdata->tag_negotiated & (1<<reselection_id)) {
1221 resume_offset = hostdata->pScript + Ent_GetReselectionWithTag; 1231 resume_offset = hostdata->pScript + Ent_GetReselectionWithTag;
@@ -1331,7 +1341,7 @@ process_selection(struct Scsi_Host *host, __u32 dsp)
1331 hostdata->cmd = NULL; 1341 hostdata->cmd = NULL;
1332 /* clear any stale simple tag message */ 1342 /* clear any stale simple tag message */
1333 hostdata->msgin[1] = 0; 1343 hostdata->msgin[1] = 0;
1334 dma_cache_sync(hostdata->msgin, MSG_ARRAY_SIZE, 1344 dma_cache_sync(hostdata->dev, hostdata->msgin, MSG_ARRAY_SIZE,
1335 DMA_BIDIRECTIONAL); 1345 DMA_BIDIRECTIONAL);
1336 1346
1337 if(id == 0xff) { 1347 if(id == 0xff) {
@@ -1428,29 +1438,30 @@ NCR_700_start_command(struct scsi_cmnd *SCp)
1428 NCR_700_set_flag(SCp->device, NCR_700_DEV_BEGIN_SYNC_NEGOTIATION); 1438 NCR_700_set_flag(SCp->device, NCR_700_DEV_BEGIN_SYNC_NEGOTIATION);
1429 } 1439 }
1430 1440
1431 script_patch_16(hostdata->script, MessageCount, count); 1441 script_patch_16(hostdata->dev, hostdata->script, MessageCount, count);
1432 1442
1433 1443
1434 script_patch_ID(hostdata->script, 1444 script_patch_ID(hostdata->dev, hostdata->script,
1435 Device_ID, 1<<scmd_id(SCp)); 1445 Device_ID, 1<<scmd_id(SCp));
1436 1446
1437 script_patch_32_abs(hostdata->script, CommandAddress, 1447 script_patch_32_abs(hostdata->dev, hostdata->script, CommandAddress,
1438 slot->pCmd); 1448 slot->pCmd);
1439 script_patch_16(hostdata->script, CommandCount, SCp->cmd_len); 1449 script_patch_16(hostdata->dev, hostdata->script, CommandCount,
1450 SCp->cmd_len);
1440 /* finally plumb the beginning of the SG list into the script 1451 /* finally plumb the beginning of the SG list into the script
1441 * */ 1452 * */
1442 script_patch_32_abs(hostdata->script, SGScriptStartAddress, 1453 script_patch_32_abs(hostdata->dev, hostdata->script,
1443 to32bit(&slot->pSG[0].ins)); 1454 SGScriptStartAddress, to32bit(&slot->pSG[0].ins));
1444 NCR_700_clear_fifo(SCp->device->host); 1455 NCR_700_clear_fifo(SCp->device->host);
1445 1456
1446 if(slot->resume_offset == 0) 1457 if(slot->resume_offset == 0)
1447 slot->resume_offset = hostdata->pScript; 1458 slot->resume_offset = hostdata->pScript;
1448 /* now perform all the writebacks and invalidates */ 1459 /* now perform all the writebacks and invalidates */
1449 dma_cache_sync(hostdata->msgout, count, DMA_TO_DEVICE); 1460 dma_cache_sync(hostdata->dev, hostdata->msgout, count, DMA_TO_DEVICE);
1450 dma_cache_sync(hostdata->msgin, MSG_ARRAY_SIZE, 1461 dma_cache_sync(hostdata->dev, hostdata->msgin, MSG_ARRAY_SIZE,
1451 DMA_FROM_DEVICE); 1462 DMA_FROM_DEVICE);
1452 dma_cache_sync(SCp->cmnd, SCp->cmd_len, DMA_TO_DEVICE); 1463 dma_cache_sync(hostdata->dev, SCp->cmnd, SCp->cmd_len, DMA_TO_DEVICE);
1453 dma_cache_sync(hostdata->status, 1, DMA_FROM_DEVICE); 1464 dma_cache_sync(hostdata->dev, hostdata->status, 1, DMA_FROM_DEVICE);
1454 1465
1455 /* set the synchronous period/offset */ 1466 /* set the synchronous period/offset */
1456 NCR_700_writeb(NCR_700_get_SXFER(SCp->device), 1467 NCR_700_writeb(NCR_700_get_SXFER(SCp->device),
@@ -1626,7 +1637,7 @@ NCR_700_intr(int irq, void *dev_id)
1626 slot->SG[i].ins = bS_to_host(SCRIPT_NOP); 1637 slot->SG[i].ins = bS_to_host(SCRIPT_NOP);
1627 slot->SG[i].pAddr = 0; 1638 slot->SG[i].pAddr = 0;
1628 } 1639 }
1629 dma_cache_sync(slot->SG, sizeof(slot->SG), DMA_TO_DEVICE); 1640 dma_cache_sync(hostdata->dev, slot->SG, sizeof(slot->SG), DMA_TO_DEVICE);
1630 /* and pretend we disconnected after 1641 /* and pretend we disconnected after
1631 * the command phase */ 1642 * the command phase */
1632 resume_offset = hostdata->pScript + Ent_MsgInDuringData; 1643 resume_offset = hostdata->pScript + Ent_MsgInDuringData;
@@ -1892,9 +1903,9 @@ NCR_700_queuecommand(struct scsi_cmnd *SCp, void (*done)(struct scsi_cmnd *))
1892 } 1903 }
1893 slot->SG[i].ins = bS_to_host(SCRIPT_RETURN); 1904 slot->SG[i].ins = bS_to_host(SCRIPT_RETURN);
1894 slot->SG[i].pAddr = 0; 1905 slot->SG[i].pAddr = 0;
1895 dma_cache_sync(slot->SG, sizeof(slot->SG), DMA_TO_DEVICE); 1906 dma_cache_sync(hostdata->dev, slot->SG, sizeof(slot->SG), DMA_TO_DEVICE);
1896 DEBUG((" SETTING %08lx to %x\n", 1907 DEBUG((" SETTING %08lx to %x\n",
1897 (&slot->pSG[i].ins), 1908 (&slot->pSG[i].ins),
1898 slot->SG[i].ins)); 1909 slot->SG[i].ins));
1899 } 1910 }
1900 slot->resume_offset = 0; 1911 slot->resume_offset = 0;
diff --git a/drivers/scsi/53c700.h b/drivers/scsi/53c700.h
index f5c3caf344a7..f38822db4210 100644
--- a/drivers/scsi/53c700.h
+++ b/drivers/scsi/53c700.h
@@ -415,31 +415,31 @@ struct NCR_700_Host_Parameters {
415#define NCR_710_MIN_XFERP 0 415#define NCR_710_MIN_XFERP 0
416#define NCR_700_MIN_PERIOD 25 /* for SDTR message, 100ns */ 416#define NCR_700_MIN_PERIOD 25 /* for SDTR message, 100ns */
417 417
418#define script_patch_32(script, symbol, value) \ 418#define script_patch_32(dev, script, symbol, value) \
419{ \ 419{ \
420 int i; \ 420 int i; \
421 for(i=0; i< (sizeof(A_##symbol##_used) / sizeof(__u32)); i++) { \ 421 for(i=0; i< (sizeof(A_##symbol##_used) / sizeof(__u32)); i++) { \
422 __u32 val = bS_to_cpu((script)[A_##symbol##_used[i]]) + value; \ 422 __u32 val = bS_to_cpu((script)[A_##symbol##_used[i]]) + value; \
423 (script)[A_##symbol##_used[i]] = bS_to_host(val); \ 423 (script)[A_##symbol##_used[i]] = bS_to_host(val); \
424 dma_cache_sync(&(script)[A_##symbol##_used[i]], 4, DMA_TO_DEVICE); \ 424 dma_cache_sync((dev), &(script)[A_##symbol##_used[i]], 4, DMA_TO_DEVICE); \
425 DEBUG((" script, patching %s at %d to 0x%lx\n", \ 425 DEBUG((" script, patching %s at %d to 0x%lx\n", \
426 #symbol, A_##symbol##_used[i], (value))); \ 426 #symbol, A_##symbol##_used[i], (value))); \
427 } \ 427 } \
428} 428}
429 429
430#define script_patch_32_abs(script, symbol, value) \ 430#define script_patch_32_abs(dev, script, symbol, value) \
431{ \ 431{ \
432 int i; \ 432 int i; \
433 for(i=0; i< (sizeof(A_##symbol##_used) / sizeof(__u32)); i++) { \ 433 for(i=0; i< (sizeof(A_##symbol##_used) / sizeof(__u32)); i++) { \
434 (script)[A_##symbol##_used[i]] = bS_to_host(value); \ 434 (script)[A_##symbol##_used[i]] = bS_to_host(value); \
435 dma_cache_sync(&(script)[A_##symbol##_used[i]], 4, DMA_TO_DEVICE); \ 435 dma_cache_sync((dev), &(script)[A_##symbol##_used[i]], 4, DMA_TO_DEVICE); \
436 DEBUG((" script, patching %s at %d to 0x%lx\n", \ 436 DEBUG((" script, patching %s at %d to 0x%lx\n", \
437 #symbol, A_##symbol##_used[i], (value))); \ 437 #symbol, A_##symbol##_used[i], (value))); \
438 } \ 438 } \
439} 439}
440 440
441/* Used for patching the SCSI ID in the SELECT instruction */ 441/* Used for patching the SCSI ID in the SELECT instruction */
442#define script_patch_ID(script, symbol, value) \ 442#define script_patch_ID(dev, script, symbol, value) \
443{ \ 443{ \
444 int i; \ 444 int i; \
445 for(i=0; i< (sizeof(A_##symbol##_used) / sizeof(__u32)); i++) { \ 445 for(i=0; i< (sizeof(A_##symbol##_used) / sizeof(__u32)); i++) { \
@@ -447,13 +447,13 @@ struct NCR_700_Host_Parameters {
447 val &= 0xff00ffff; \ 447 val &= 0xff00ffff; \
448 val |= ((value) & 0xff) << 16; \ 448 val |= ((value) & 0xff) << 16; \
449 (script)[A_##symbol##_used[i]] = bS_to_host(val); \ 449 (script)[A_##symbol##_used[i]] = bS_to_host(val); \
450 dma_cache_sync(&(script)[A_##symbol##_used[i]], 4, DMA_TO_DEVICE); \ 450 dma_cache_sync((dev), &(script)[A_##symbol##_used[i]], 4, DMA_TO_DEVICE); \
451 DEBUG((" script, patching ID field %s at %d to 0x%x\n", \ 451 DEBUG((" script, patching ID field %s at %d to 0x%x\n", \
452 #symbol, A_##symbol##_used[i], val)); \ 452 #symbol, A_##symbol##_used[i], val)); \
453 } \ 453 } \
454} 454}
455 455
456#define script_patch_16(script, symbol, value) \ 456#define script_patch_16(dev, script, symbol, value) \
457{ \ 457{ \
458 int i; \ 458 int i; \
459 for(i=0; i< (sizeof(A_##symbol##_used) / sizeof(__u32)); i++) { \ 459 for(i=0; i< (sizeof(A_##symbol##_used) / sizeof(__u32)); i++) { \
@@ -461,7 +461,7 @@ struct NCR_700_Host_Parameters {
461 val &= 0xffff0000; \ 461 val &= 0xffff0000; \
462 val |= ((value) & 0xffff); \ 462 val |= ((value) & 0xffff); \
463 (script)[A_##symbol##_used[i]] = bS_to_host(val); \ 463 (script)[A_##symbol##_used[i]] = bS_to_host(val); \
464 dma_cache_sync(&(script)[A_##symbol##_used[i]], 4, DMA_TO_DEVICE); \ 464 dma_cache_sync((dev), &(script)[A_##symbol##_used[i]], 4, DMA_TO_DEVICE); \
465 DEBUG((" script, patching short field %s at %d to 0x%x\n", \ 465 DEBUG((" script, patching short field %s at %d to 0x%x\n", \
466 #symbol, A_##symbol##_used[i], val)); \ 466 #symbol, A_##symbol##_used[i], val)); \
467 } \ 467 } \
diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c
index cdd033724786..3075204915c8 100644
--- a/drivers/scsi/BusLogic.c
+++ b/drivers/scsi/BusLogic.c
@@ -2186,21 +2186,21 @@ static int __init BusLogic_init(void)
2186 2186
2187 if (BusLogic_ProbeOptions.NoProbe) 2187 if (BusLogic_ProbeOptions.NoProbe)
2188 return -ENODEV; 2188 return -ENODEV;
2189 BusLogic_ProbeInfoList = (struct BusLogic_ProbeInfo *) 2189 BusLogic_ProbeInfoList =
2190 kmalloc(BusLogic_MaxHostAdapters * sizeof(struct BusLogic_ProbeInfo), GFP_ATOMIC); 2190 kzalloc(BusLogic_MaxHostAdapters * sizeof(struct BusLogic_ProbeInfo), GFP_KERNEL);
2191 if (BusLogic_ProbeInfoList == NULL) { 2191 if (BusLogic_ProbeInfoList == NULL) {
2192 BusLogic_Error("BusLogic: Unable to allocate Probe Info List\n", NULL); 2192 BusLogic_Error("BusLogic: Unable to allocate Probe Info List\n", NULL);
2193 return -ENOMEM; 2193 return -ENOMEM;
2194 } 2194 }
2195 memset(BusLogic_ProbeInfoList, 0, BusLogic_MaxHostAdapters * sizeof(struct BusLogic_ProbeInfo)); 2195
2196 PrototypeHostAdapter = (struct BusLogic_HostAdapter *) 2196 PrototypeHostAdapter =
2197 kmalloc(sizeof(struct BusLogic_HostAdapter), GFP_ATOMIC); 2197 kzalloc(sizeof(struct BusLogic_HostAdapter), GFP_KERNEL);
2198 if (PrototypeHostAdapter == NULL) { 2198 if (PrototypeHostAdapter == NULL) {
2199 kfree(BusLogic_ProbeInfoList); 2199 kfree(BusLogic_ProbeInfoList);
2200 BusLogic_Error("BusLogic: Unable to allocate Prototype " "Host Adapter\n", NULL); 2200 BusLogic_Error("BusLogic: Unable to allocate Prototype " "Host Adapter\n", NULL);
2201 return -ENOMEM; 2201 return -ENOMEM;
2202 } 2202 }
2203 memset(PrototypeHostAdapter, 0, sizeof(struct BusLogic_HostAdapter)); 2203
2204#ifdef MODULE 2204#ifdef MODULE
2205 if (BusLogic != NULL) 2205 if (BusLogic != NULL)
2206 BusLogic_Setup(BusLogic); 2206 BusLogic_Setup(BusLogic);
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 9540eb8efdcb..69569096dae5 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -29,6 +29,13 @@ config SCSI
29 However, do not compile this as a module if your root file system 29 However, do not compile this as a module if your root file system
30 (the one containing the directory /) is located on a SCSI device. 30 (the one containing the directory /) is located on a SCSI device.
31 31
32config SCSI_TGT
33 tristate "SCSI target support"
34 depends on SCSI && EXPERIMENTAL
35 ---help---
36 If you want to use SCSI target mode drivers enable this option.
37 If you choose M, the module will be called scsi_tgt.
38
32config SCSI_NETLINK 39config SCSI_NETLINK
33 bool 40 bool
34 default n 41 default n
@@ -216,6 +223,23 @@ config SCSI_LOGGING
216 there should be no noticeable performance impact as long as you have 223 there should be no noticeable performance impact as long as you have
217 logging turned off. 224 logging turned off.
218 225
226config SCSI_SCAN_ASYNC
227 bool "Asynchronous SCSI scanning"
228 depends on SCSI
229 help
230 The SCSI subsystem can probe for devices while the rest of the
231 system continues booting, and even probe devices on different
232 busses in parallel, leading to a significant speed-up.
233 If you have built SCSI as modules, enabling this option can
234 be a problem as the devices may not have been found by the
235 time your system expects them to have been. You can load the
236 scsi_wait_scan module to ensure that all scans have completed.
237 If you build your SCSI drivers into the kernel, then everything
238 will work fine if you say Y here.
239
240 You can override this choice by specifying scsi_mod.scan="sync"
241 or "async" on the kernel's command line.
242
219menu "SCSI Transports" 243menu "SCSI Transports"
220 depends on SCSI 244 depends on SCSI
221 245
@@ -797,6 +821,20 @@ config SCSI_IBMVSCSI
797 To compile this driver as a module, choose M here: the 821 To compile this driver as a module, choose M here: the
798 module will be called ibmvscsic. 822 module will be called ibmvscsic.
799 823
824config SCSI_IBMVSCSIS
825 tristate "IBM Virtual SCSI Server support"
826 depends on PPC_PSERIES && SCSI_TGT && SCSI_SRP
827 help
828 This is the SRP target driver for IBM pSeries virtual environments.
829
830 The userspace component needed to initialize the driver and
831 documentation can be found:
832
833 http://stgt.berlios.de/
834
835 To compile this driver as a module, choose M here: the
836 module will be called ibmvstgt.
837
800config SCSI_INITIO 838config SCSI_INITIO
801 tristate "Initio 9100U(W) support" 839 tristate "Initio 9100U(W) support"
802 depends on PCI && SCSI 840 depends on PCI && SCSI
@@ -944,8 +982,13 @@ config SCSI_STEX
944 tristate "Promise SuperTrak EX Series support" 982 tristate "Promise SuperTrak EX Series support"
945 depends on PCI && SCSI 983 depends on PCI && SCSI
946 ---help--- 984 ---help---
947 This driver supports Promise SuperTrak EX8350/8300/16350/16300 985 This driver supports Promise SuperTrak EX series storage controllers.
948 Storage controllers. 986
987 Promise provides Linux RAID configuration utility for these
988 controllers. Please visit <http://www.promise.com> to download.
989
990 To compile this driver as a module, choose M here: the
991 module will be called stex.
949 992
950config SCSI_SYM53C8XX_2 993config SCSI_SYM53C8XX_2
951 tristate "SYM53C8XX Version 2 SCSI support" 994 tristate "SYM53C8XX Version 2 SCSI support"
@@ -1026,6 +1069,7 @@ config SCSI_IPR
1026config SCSI_IPR_TRACE 1069config SCSI_IPR_TRACE
1027 bool "enable driver internal trace" 1070 bool "enable driver internal trace"
1028 depends on SCSI_IPR 1071 depends on SCSI_IPR
1072 default y
1029 help 1073 help
1030 If you say Y here, the driver will trace all commands issued 1074 If you say Y here, the driver will trace all commands issued
1031 to the adapter. Performance impact is minimal. Trace can be 1075 to the adapter. Performance impact is minimal. Trace can be
@@ -1034,6 +1078,7 @@ config SCSI_IPR_TRACE
1034config SCSI_IPR_DUMP 1078config SCSI_IPR_DUMP
1035 bool "enable adapter dump support" 1079 bool "enable adapter dump support"
1036 depends on SCSI_IPR 1080 depends on SCSI_IPR
1081 default y
1037 help 1082 help
1038 If you say Y here, the driver will support adapter crash dump. 1083 If you say Y here, the driver will support adapter crash dump.
1039 If you enable this support, the iprdump daemon can be used 1084 If you enable this support, the iprdump daemon can be used
@@ -1734,6 +1779,16 @@ config ZFCP
1734 called zfcp. If you want to compile it as a module, say M here 1779 called zfcp. If you want to compile it as a module, say M here
1735 and read <file:Documentation/modules.txt>. 1780 and read <file:Documentation/modules.txt>.
1736 1781
1782config SCSI_SRP
1783 tristate "SCSI RDMA Protocol helper library"
1784 depends on SCSI && PCI
1785 select SCSI_TGT
1786 help
1787 If you wish to use SRP target drivers, say Y.
1788
1789 To compile this driver as a module, choose M here: the
1790 module will be called libsrp.
1791
1737endmenu 1792endmenu
1738 1793
1739source "drivers/scsi/pcmcia/Kconfig" 1794source "drivers/scsi/pcmcia/Kconfig"
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
index bcca39c3bcbf..bd7c9888f7f4 100644
--- a/drivers/scsi/Makefile
+++ b/drivers/scsi/Makefile
@@ -21,6 +21,7 @@ CFLAGS_seagate.o = -DARBITRATE -DPARITY -DSEAGATE_USE_ASM
21subdir-$(CONFIG_PCMCIA) += pcmcia 21subdir-$(CONFIG_PCMCIA) += pcmcia
22 22
23obj-$(CONFIG_SCSI) += scsi_mod.o 23obj-$(CONFIG_SCSI) += scsi_mod.o
24obj-$(CONFIG_SCSI_TGT) += scsi_tgt.o
24 25
25obj-$(CONFIG_RAID_ATTRS) += raid_class.o 26obj-$(CONFIG_RAID_ATTRS) += raid_class.o
26 27
@@ -125,7 +126,9 @@ obj-$(CONFIG_SCSI_FCAL) += fcal.o
125obj-$(CONFIG_SCSI_LASI700) += 53c700.o lasi700.o 126obj-$(CONFIG_SCSI_LASI700) += 53c700.o lasi700.o
126obj-$(CONFIG_SCSI_NSP32) += nsp32.o 127obj-$(CONFIG_SCSI_NSP32) += nsp32.o
127obj-$(CONFIG_SCSI_IPR) += ipr.o 128obj-$(CONFIG_SCSI_IPR) += ipr.o
129obj-$(CONFIG_SCSI_SRP) += libsrp.o
128obj-$(CONFIG_SCSI_IBMVSCSI) += ibmvscsi/ 130obj-$(CONFIG_SCSI_IBMVSCSI) += ibmvscsi/
131obj-$(CONFIG_SCSI_IBMVSCSIS) += ibmvscsi/
129obj-$(CONFIG_SCSI_HPTIOP) += hptiop.o 132obj-$(CONFIG_SCSI_HPTIOP) += hptiop.o
130obj-$(CONFIG_SCSI_STEX) += stex.o 133obj-$(CONFIG_SCSI_STEX) += stex.o
131 134
@@ -141,6 +144,8 @@ obj-$(CONFIG_CHR_DEV_SCH) += ch.o
141# This goes last, so that "real" scsi devices probe earlier 144# This goes last, so that "real" scsi devices probe earlier
142obj-$(CONFIG_SCSI_DEBUG) += scsi_debug.o 145obj-$(CONFIG_SCSI_DEBUG) += scsi_debug.o
143 146
147obj-$(CONFIG_SCSI) += scsi_wait_scan.o
148
144scsi_mod-y += scsi.o hosts.o scsi_ioctl.o constants.o \ 149scsi_mod-y += scsi.o hosts.o scsi_ioctl.o constants.o \
145 scsicam.o scsi_error.o scsi_lib.o \ 150 scsicam.o scsi_error.o scsi_lib.o \
146 scsi_scan.o scsi_sysfs.o \ 151 scsi_scan.o scsi_sysfs.o \
@@ -149,6 +154,8 @@ scsi_mod-$(CONFIG_SCSI_NETLINK) += scsi_netlink.o
149scsi_mod-$(CONFIG_SYSCTL) += scsi_sysctl.o 154scsi_mod-$(CONFIG_SYSCTL) += scsi_sysctl.o
150scsi_mod-$(CONFIG_SCSI_PROC_FS) += scsi_proc.o 155scsi_mod-$(CONFIG_SCSI_PROC_FS) += scsi_proc.o
151 156
157scsi_tgt-y += scsi_tgt_lib.o scsi_tgt_if.o
158
152sd_mod-objs := sd.o 159sd_mod-objs := sd.o
153sr_mod-objs := sr.o sr_ioctl.o sr_vendor.o 160sr_mod-objs := sr.o sr_ioctl.o sr_vendor.o
154ncr53c8xx-flags-$(CONFIG_SCSI_ZALON) \ 161ncr53c8xx-flags-$(CONFIG_SCSI_ZALON) \
diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
index a6aa91072880..bb3cb3360541 100644
--- a/drivers/scsi/NCR5380.c
+++ b/drivers/scsi/NCR5380.c
@@ -849,7 +849,7 @@ static int __devinit NCR5380_init(struct Scsi_Host *instance, int flags)
849 hostdata->issue_queue = NULL; 849 hostdata->issue_queue = NULL;
850 hostdata->disconnected_queue = NULL; 850 hostdata->disconnected_queue = NULL;
851 851
852 INIT_WORK(&hostdata->coroutine, NCR5380_main, hostdata); 852 INIT_DELAYED_WORK(&hostdata->coroutine, NCR5380_main);
853 853
854#ifdef NCR5380_STATS 854#ifdef NCR5380_STATS
855 for (i = 0; i < 8; ++i) { 855 for (i = 0; i < 8; ++i) {
@@ -1016,7 +1016,7 @@ static int NCR5380_queue_command(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *))
1016 1016
1017 /* Run the coroutine if it isn't already running. */ 1017 /* Run the coroutine if it isn't already running. */
1018 /* Kick off command processing */ 1018 /* Kick off command processing */
1019 schedule_work(&hostdata->coroutine); 1019 schedule_delayed_work(&hostdata->coroutine, 0);
1020 return 0; 1020 return 0;
1021} 1021}
1022 1022
@@ -1033,9 +1033,10 @@ static int NCR5380_queue_command(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *))
1033 * host lock and called routines may take the isa dma lock. 1033 * host lock and called routines may take the isa dma lock.
1034 */ 1034 */
1035 1035
1036static void NCR5380_main(void *p) 1036static void NCR5380_main(struct work_struct *work)
1037{ 1037{
1038 struct NCR5380_hostdata *hostdata = p; 1038 struct NCR5380_hostdata *hostdata =
1039 container_of(work, struct NCR5380_hostdata, coroutine.work);
1039 struct Scsi_Host *instance = hostdata->host; 1040 struct Scsi_Host *instance = hostdata->host;
1040 Scsi_Cmnd *tmp, *prev; 1041 Scsi_Cmnd *tmp, *prev;
1041 int done; 1042 int done;
@@ -1221,7 +1222,7 @@ static irqreturn_t NCR5380_intr(int irq, void *dev_id)
1221 } /* if BASR_IRQ */ 1222 } /* if BASR_IRQ */
1222 spin_unlock_irqrestore(instance->host_lock, flags); 1223 spin_unlock_irqrestore(instance->host_lock, flags);
1223 if(!done) 1224 if(!done)
1224 schedule_work(&hostdata->coroutine); 1225 schedule_delayed_work(&hostdata->coroutine, 0);
1225 } while (!done); 1226 } while (!done);
1226 return IRQ_HANDLED; 1227 return IRQ_HANDLED;
1227} 1228}
diff --git a/drivers/scsi/NCR5380.h b/drivers/scsi/NCR5380.h
index 1bc73de496b0..713a108c02ef 100644
--- a/drivers/scsi/NCR5380.h
+++ b/drivers/scsi/NCR5380.h
@@ -271,7 +271,7 @@ struct NCR5380_hostdata {
271 unsigned long time_expires; /* in jiffies, set prior to sleeping */ 271 unsigned long time_expires; /* in jiffies, set prior to sleeping */
272 int select_time; /* timer in select for target response */ 272 int select_time; /* timer in select for target response */
273 volatile Scsi_Cmnd *selecting; 273 volatile Scsi_Cmnd *selecting;
274 struct work_struct coroutine; /* our co-routine */ 274 struct delayed_work coroutine; /* our co-routine */
275#ifdef NCR5380_STATS 275#ifdef NCR5380_STATS
276 unsigned timebase; /* Base for time calcs */ 276 unsigned timebase; /* Base for time calcs */
277 long time_read[8]; /* time to do reads */ 277 long time_read[8]; /* time to do reads */
@@ -298,7 +298,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance);
298#ifndef DONT_USE_INTR 298#ifndef DONT_USE_INTR
299static irqreturn_t NCR5380_intr(int irq, void *dev_id); 299static irqreturn_t NCR5380_intr(int irq, void *dev_id);
300#endif 300#endif
301static void NCR5380_main(void *ptr); 301static void NCR5380_main(struct work_struct *work);
302static void NCR5380_print_options(struct Scsi_Host *instance); 302static void NCR5380_print_options(struct Scsi_Host *instance);
303#ifdef NDEBUG 303#ifdef NDEBUG
304static void NCR5380_print_phase(struct Scsi_Host *instance); 304static void NCR5380_print_phase(struct Scsi_Host *instance);
diff --git a/drivers/scsi/NCR53c406a.c b/drivers/scsi/NCR53c406a.c
index d4613815f685..8578555d58fd 100644
--- a/drivers/scsi/NCR53c406a.c
+++ b/drivers/scsi/NCR53c406a.c
@@ -220,9 +220,11 @@ static void *addresses[] = {
220static unsigned short ports[] = { 0x230, 0x330, 0x280, 0x290, 0x330, 0x340, 0x300, 0x310, 0x348, 0x350 }; 220static unsigned short ports[] = { 0x230, 0x330, 0x280, 0x290, 0x330, 0x340, 0x300, 0x310, 0x348, 0x350 };
221#define PORT_COUNT ARRAY_SIZE(ports) 221#define PORT_COUNT ARRAY_SIZE(ports)
222 222
223#ifndef MODULE
223/* possible interrupt channels */ 224/* possible interrupt channels */
224static unsigned short intrs[] = { 10, 11, 12, 15 }; 225static unsigned short intrs[] = { 10, 11, 12, 15 };
225#define INTR_COUNT ARRAY_SIZE(intrs) 226#define INTR_COUNT ARRAY_SIZE(intrs)
227#endif /* !MODULE */
226 228
227/* signatures for NCR 53c406a based controllers */ 229/* signatures for NCR 53c406a based controllers */
228#if USE_BIOS 230#if USE_BIOS
@@ -605,6 +607,7 @@ static int NCR53c406a_release(struct Scsi_Host *shost)
605 return 0; 607 return 0;
606} 608}
607 609
610#ifndef MODULE
608/* called from init/main.c */ 611/* called from init/main.c */
609static int __init NCR53c406a_setup(char *str) 612static int __init NCR53c406a_setup(char *str)
610{ 613{
@@ -661,6 +664,8 @@ static int __init NCR53c406a_setup(char *str)
661 664
662__setup("ncr53c406a=", NCR53c406a_setup); 665__setup("ncr53c406a=", NCR53c406a_setup);
663 666
667#endif /* !MODULE */
668
664static const char *NCR53c406a_info(struct Scsi_Host *SChost) 669static const char *NCR53c406a_info(struct Scsi_Host *SChost)
665{ 670{
666 DEB(printk("NCR53c406a_info called\n")); 671 DEB(printk("NCR53c406a_info called\n"));
diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h
index eb3ed91bac79..4f8b4c53d435 100644
--- a/drivers/scsi/aacraid/aacraid.h
+++ b/drivers/scsi/aacraid/aacraid.h
@@ -11,8 +11,8 @@
11 *----------------------------------------------------------------------------*/ 11 *----------------------------------------------------------------------------*/
12 12
13#ifndef AAC_DRIVER_BUILD 13#ifndef AAC_DRIVER_BUILD
14# define AAC_DRIVER_BUILD 2409 14# define AAC_DRIVER_BUILD 2423
15# define AAC_DRIVER_BRANCH "-mh2" 15# define AAC_DRIVER_BRANCH "-mh3"
16#endif 16#endif
17#define MAXIMUM_NUM_CONTAINERS 32 17#define MAXIMUM_NUM_CONTAINERS 32
18 18
diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c
index 19e42ac07cb2..4893a6d06a33 100644
--- a/drivers/scsi/aacraid/commsup.c
+++ b/drivers/scsi/aacraid/commsup.c
@@ -518,6 +518,7 @@ int aac_fib_send(u16 command, struct fib *fibptr, unsigned long size,
518 */ 518 */
519 unsigned long count = 36000000L; /* 3 minutes */ 519 unsigned long count = 36000000L; /* 3 minutes */
520 while (down_trylock(&fibptr->event_wait)) { 520 while (down_trylock(&fibptr->event_wait)) {
521 int blink;
521 if (--count == 0) { 522 if (--count == 0) {
522 spin_lock_irqsave(q->lock, qflags); 523 spin_lock_irqsave(q->lock, qflags);
523 q->numpending--; 524 q->numpending--;
@@ -530,6 +531,14 @@ int aac_fib_send(u16 command, struct fib *fibptr, unsigned long size,
530 } 531 }
531 return -ETIMEDOUT; 532 return -ETIMEDOUT;
532 } 533 }
534 if ((blink = aac_adapter_check_health(dev)) > 0) {
535 if (wait == -1) {
536 printk(KERN_ERR "aacraid: aac_fib_send: adapter blinkLED 0x%x.\n"
537 "Usually a result of a serious unrecoverable hardware problem\n",
538 blink);
539 }
540 return -EFAULT;
541 }
533 udelay(5); 542 udelay(5);
534 } 543 }
535 } else if (down_interruptible(&fibptr->event_wait)) { 544 } else if (down_interruptible(&fibptr->event_wait)) {
@@ -1093,6 +1102,20 @@ static int _aac_reset_adapter(struct aac_dev *aac)
1093 goto out; 1102 goto out;
1094 } 1103 }
1095 1104
1105 /*
1106 * Loop through the fibs, close the synchronous FIBS
1107 */
1108 for (index = 0; index < (aac->scsi_host_ptr->can_queue + AAC_NUM_MGT_FIB); index++) {
1109 struct fib *fib = &aac->fibs[index];
1110 if (!(fib->hw_fib->header.XferState & cpu_to_le32(NoResponseExpected | Async)) &&
1111 (fib->hw_fib->header.XferState & cpu_to_le32(ResponseExpected))) {
1112 unsigned long flagv;
1113 spin_lock_irqsave(&fib->event_lock, flagv);
1114 up(&fib->event_wait);
1115 spin_unlock_irqrestore(&fib->event_lock, flagv);
1116 schedule();
1117 }
1118 }
1096 index = aac->cardtype; 1119 index = aac->cardtype;
1097 1120
1098 /* 1121 /*
diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c
index 306f46b85a55..0cec742d12e9 100644
--- a/drivers/scsi/aha152x.c
+++ b/drivers/scsi/aha152x.c
@@ -1443,7 +1443,7 @@ static struct work_struct aha152x_tq;
1443 * Run service completions on the card with interrupts enabled. 1443 * Run service completions on the card with interrupts enabled.
1444 * 1444 *
1445 */ 1445 */
1446static void run(void) 1446static void run(struct work_struct *work)
1447{ 1447{
1448 struct aha152x_hostdata *hd; 1448 struct aha152x_hostdata *hd;
1449 1449
@@ -1499,7 +1499,7 @@ static irqreturn_t intr(int irqno, void *dev_id)
1499 HOSTDATA(shpnt)->service=1; 1499 HOSTDATA(shpnt)->service=1;
1500 1500
1501 /* Poke the BH handler */ 1501 /* Poke the BH handler */
1502 INIT_WORK(&aha152x_tq, (void *) run, NULL); 1502 INIT_WORK(&aha152x_tq, run);
1503 schedule_work(&aha152x_tq); 1503 schedule_work(&aha152x_tq);
1504 } 1504 }
1505 DO_UNLOCK(flags); 1505 DO_UNLOCK(flags);
diff --git a/drivers/scsi/aha1740.c b/drivers/scsi/aha1740.c
index c3c38a7e8d32..d7af9c63a04d 100644
--- a/drivers/scsi/aha1740.c
+++ b/drivers/scsi/aha1740.c
@@ -586,7 +586,7 @@ static struct scsi_host_template aha1740_template = {
586 586
587static int aha1740_probe (struct device *dev) 587static int aha1740_probe (struct device *dev)
588{ 588{
589 int slotbase; 589 int slotbase, rc;
590 unsigned int irq_level, irq_type, translation; 590 unsigned int irq_level, irq_type, translation;
591 struct Scsi_Host *shpnt; 591 struct Scsi_Host *shpnt;
592 struct aha1740_hostdata *host; 592 struct aha1740_hostdata *host;
@@ -641,10 +641,16 @@ static int aha1740_probe (struct device *dev)
641 } 641 }
642 642
643 eisa_set_drvdata (edev, shpnt); 643 eisa_set_drvdata (edev, shpnt);
644 scsi_add_host (shpnt, dev); /* XXX handle failure */ 644
645 rc = scsi_add_host (shpnt, dev);
646 if (rc)
647 goto err_irq;
648
645 scsi_scan_host (shpnt); 649 scsi_scan_host (shpnt);
646 return 0; 650 return 0;
647 651
652 err_irq:
653 free_irq(irq_level, shpnt);
648 err_unmap: 654 err_unmap:
649 dma_unmap_single (&edev->dev, host->ecb_dma_addr, 655 dma_unmap_single (&edev->dev, host->ecb_dma_addr,
650 sizeof (host->ecb), DMA_BIDIRECTIONAL); 656 sizeof (host->ecb), DMA_BIDIRECTIONAL);
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm_pci.c b/drivers/scsi/aic7xxx/aic79xx_osm_pci.c
index 2001fe890e71..1a3ab6aa856b 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm_pci.c
+++ b/drivers/scsi/aic7xxx/aic79xx_osm_pci.c
@@ -62,6 +62,7 @@ static struct pci_device_id ahd_linux_pci_id_table[] = {
62 /* aic7901 based controllers */ 62 /* aic7901 based controllers */
63 ID(ID_AHA_29320A), 63 ID(ID_AHA_29320A),
64 ID(ID_AHA_29320ALP), 64 ID(ID_AHA_29320ALP),
65 ID(ID_AHA_29320LPE),
65 /* aic7902 based controllers */ 66 /* aic7902 based controllers */
66 ID(ID_AHA_29320), 67 ID(ID_AHA_29320),
67 ID(ID_AHA_29320B), 68 ID(ID_AHA_29320B),
diff --git a/drivers/scsi/aic7xxx/aic79xx_pci.c b/drivers/scsi/aic7xxx/aic79xx_pci.c
index c07735819cd1..2cf7bb3123f0 100644
--- a/drivers/scsi/aic7xxx/aic79xx_pci.c
+++ b/drivers/scsi/aic7xxx/aic79xx_pci.c
@@ -109,7 +109,13 @@ static struct ahd_pci_identity ahd_pci_ident_table [] =
109 { 109 {
110 ID_AHA_29320ALP, 110 ID_AHA_29320ALP,
111 ID_ALL_MASK, 111 ID_ALL_MASK,
112 "Adaptec 29320ALP Ultra320 SCSI adapter", 112 "Adaptec 29320ALP PCIx Ultra320 SCSI adapter",
113 ahd_aic7901_setup
114 },
115 {
116 ID_AHA_29320LPE,
117 ID_ALL_MASK,
118 "Adaptec 29320LPE PCIe Ultra320 SCSI adapter",
113 ahd_aic7901_setup 119 ahd_aic7901_setup
114 }, 120 },
115 /* aic7901A based controllers */ 121 /* aic7901A based controllers */
diff --git a/drivers/scsi/aic7xxx/aic79xx_pci.h b/drivers/scsi/aic7xxx/aic79xx_pci.h
index da45153668c7..16b7c70a673c 100644
--- a/drivers/scsi/aic7xxx/aic79xx_pci.h
+++ b/drivers/scsi/aic7xxx/aic79xx_pci.h
@@ -51,6 +51,7 @@
51#define ID_AIC7901 0x800F9005FFFF9005ull 51#define ID_AIC7901 0x800F9005FFFF9005ull
52#define ID_AHA_29320A 0x8000900500609005ull 52#define ID_AHA_29320A 0x8000900500609005ull
53#define ID_AHA_29320ALP 0x8017900500449005ull 53#define ID_AHA_29320ALP 0x8017900500449005ull
54#define ID_AHA_29320LPE 0x8017900500459005ull
54 55
55#define ID_AIC7901A 0x801E9005FFFF9005ull 56#define ID_AIC7901A 0x801E9005FFFF9005ull
56#define ID_AHA_29320LP 0x8014900500449005ull 57#define ID_AHA_29320LP 0x8014900500449005ull
diff --git a/drivers/scsi/aic94xx/aic94xx.h b/drivers/scsi/aic94xx/aic94xx.h
index 71a031df7a34..32f513b1b78a 100644
--- a/drivers/scsi/aic94xx/aic94xx.h
+++ b/drivers/scsi/aic94xx/aic94xx.h
@@ -56,8 +56,8 @@
56/* 2*ITNL timeout + 1 second */ 56/* 2*ITNL timeout + 1 second */
57#define AIC94XX_SCB_TIMEOUT (5*HZ) 57#define AIC94XX_SCB_TIMEOUT (5*HZ)
58 58
59extern kmem_cache_t *asd_dma_token_cache; 59extern struct kmem_cache *asd_dma_token_cache;
60extern kmem_cache_t *asd_ascb_cache; 60extern struct kmem_cache *asd_ascb_cache;
61extern char sas_addr_str[2*SAS_ADDR_SIZE + 1]; 61extern char sas_addr_str[2*SAS_ADDR_SIZE + 1];
62 62
63static inline void asd_stringify_sas_addr(char *p, const u8 *sas_addr) 63static inline void asd_stringify_sas_addr(char *p, const u8 *sas_addr)
diff --git a/drivers/scsi/aic94xx/aic94xx_hwi.c b/drivers/scsi/aic94xx/aic94xx_hwi.c
index 3c2d7a379931..da94e126ca83 100644
--- a/drivers/scsi/aic94xx/aic94xx_hwi.c
+++ b/drivers/scsi/aic94xx/aic94xx_hwi.c
@@ -112,6 +112,21 @@ static int asd_init_phy(struct asd_phy *phy)
112 return 0; 112 return 0;
113} 113}
114 114
115static void asd_init_ports(struct asd_ha_struct *asd_ha)
116{
117 int i;
118
119 spin_lock_init(&asd_ha->asd_ports_lock);
120 for (i = 0; i < ASD_MAX_PHYS; i++) {
121 struct asd_port *asd_port = &asd_ha->asd_ports[i];
122
123 memset(asd_port->sas_addr, 0, SAS_ADDR_SIZE);
124 memset(asd_port->attached_sas_addr, 0, SAS_ADDR_SIZE);
125 asd_port->phy_mask = 0;
126 asd_port->num_phys = 0;
127 }
128}
129
115static int asd_init_phys(struct asd_ha_struct *asd_ha) 130static int asd_init_phys(struct asd_ha_struct *asd_ha)
116{ 131{
117 u8 i; 132 u8 i;
@@ -121,6 +136,7 @@ static int asd_init_phys(struct asd_ha_struct *asd_ha)
121 struct asd_phy *phy = &asd_ha->phys[i]; 136 struct asd_phy *phy = &asd_ha->phys[i];
122 137
123 phy->phy_desc = &asd_ha->hw_prof.phy_desc[i]; 138 phy->phy_desc = &asd_ha->hw_prof.phy_desc[i];
139 phy->asd_port = NULL;
124 140
125 phy->sas_phy.enabled = 0; 141 phy->sas_phy.enabled = 0;
126 phy->sas_phy.id = i; 142 phy->sas_phy.id = i;
@@ -658,6 +674,8 @@ int asd_init_hw(struct asd_ha_struct *asd_ha)
658 goto Out; 674 goto Out;
659 } 675 }
660 676
677 asd_init_ports(asd_ha);
678
661 err = asd_init_scbs(asd_ha); 679 err = asd_init_scbs(asd_ha);
662 if (err) { 680 if (err) {
663 asd_printk("couldn't initialize scbs for %s\n", 681 asd_printk("couldn't initialize scbs for %s\n",
@@ -1029,7 +1047,7 @@ irqreturn_t asd_hw_isr(int irq, void *dev_id)
1029static inline struct asd_ascb *asd_ascb_alloc(struct asd_ha_struct *asd_ha, 1047static inline struct asd_ascb *asd_ascb_alloc(struct asd_ha_struct *asd_ha,
1030 gfp_t gfp_flags) 1048 gfp_t gfp_flags)
1031{ 1049{
1032 extern kmem_cache_t *asd_ascb_cache; 1050 extern struct kmem_cache *asd_ascb_cache;
1033 struct asd_seq_data *seq = &asd_ha->seq; 1051 struct asd_seq_data *seq = &asd_ha->seq;
1034 struct asd_ascb *ascb; 1052 struct asd_ascb *ascb;
1035 unsigned long flags; 1053 unsigned long flags;
diff --git a/drivers/scsi/aic94xx/aic94xx_hwi.h b/drivers/scsi/aic94xx/aic94xx_hwi.h
index 7b6aca02cf70..c6c3d18222fa 100644
--- a/drivers/scsi/aic94xx/aic94xx_hwi.h
+++ b/drivers/scsi/aic94xx/aic94xx_hwi.h
@@ -193,6 +193,16 @@ struct asd_seq_data {
193 struct asd_ascb **escb_arr; /* array of pointers to escbs */ 193 struct asd_ascb **escb_arr; /* array of pointers to escbs */
194}; 194};
195 195
196/* This is an internal port structure. These are used to get accurate
197 * phy_mask for updating DDB 0.
198 */
199struct asd_port {
200 u8 sas_addr[SAS_ADDR_SIZE];
201 u8 attached_sas_addr[SAS_ADDR_SIZE];
202 u32 phy_mask;
203 int num_phys;
204};
205
196/* This is the Host Adapter structure. It describes the hardware 206/* This is the Host Adapter structure. It describes the hardware
197 * SAS adapter. 207 * SAS adapter.
198 */ 208 */
@@ -211,6 +221,8 @@ struct asd_ha_struct {
211 struct hw_profile hw_prof; 221 struct hw_profile hw_prof;
212 222
213 struct asd_phy phys[ASD_MAX_PHYS]; 223 struct asd_phy phys[ASD_MAX_PHYS];
224 spinlock_t asd_ports_lock;
225 struct asd_port asd_ports[ASD_MAX_PHYS];
214 struct asd_sas_port ports[ASD_MAX_PHYS]; 226 struct asd_sas_port ports[ASD_MAX_PHYS];
215 227
216 struct dma_pool *scb_pool; 228 struct dma_pool *scb_pool;
diff --git a/drivers/scsi/aic94xx/aic94xx_init.c b/drivers/scsi/aic94xx/aic94xx_init.c
index a4cc432bbdab..fbc82b00a418 100644
--- a/drivers/scsi/aic94xx/aic94xx_init.c
+++ b/drivers/scsi/aic94xx/aic94xx_init.c
@@ -450,8 +450,8 @@ static inline void asd_destroy_ha_caches(struct asd_ha_struct *asd_ha)
450 asd_ha->scb_pool = NULL; 450 asd_ha->scb_pool = NULL;
451} 451}
452 452
453kmem_cache_t *asd_dma_token_cache; 453struct kmem_cache *asd_dma_token_cache;
454kmem_cache_t *asd_ascb_cache; 454struct kmem_cache *asd_ascb_cache;
455 455
456static int asd_create_global_caches(void) 456static int asd_create_global_caches(void)
457{ 457{
@@ -724,6 +724,15 @@ static void asd_free_queues(struct asd_ha_struct *asd_ha)
724 724
725 list_for_each_safe(pos, n, &pending) { 725 list_for_each_safe(pos, n, &pending) {
726 struct asd_ascb *ascb = list_entry(pos, struct asd_ascb, list); 726 struct asd_ascb *ascb = list_entry(pos, struct asd_ascb, list);
727 /*
728 * Delete unexpired ascb timers. This may happen if we issue
729 * a CONTROL PHY scb to an adapter and rmmod before the scb
730 * times out. Apparently we don't wait for the CONTROL PHY
731 * to complete, so it doesn't matter if we kill the timer.
732 */
733 del_timer_sync(&ascb->timer);
734 WARN_ON(ascb->scb->header.opcode != CONTROL_PHY);
735
727 list_del_init(pos); 736 list_del_init(pos);
728 ASD_DPRINTK("freeing from pending\n"); 737 ASD_DPRINTK("freeing from pending\n");
729 asd_ascb_free(ascb); 738 asd_ascb_free(ascb);
@@ -786,8 +795,6 @@ static void asd_remove_driver_attrs(struct device_driver *driver)
786} 795}
787 796
788static struct sas_domain_function_template aic94xx_transport_functions = { 797static struct sas_domain_function_template aic94xx_transport_functions = {
789 .lldd_port_formed = asd_update_port_links,
790
791 .lldd_dev_found = asd_dev_found, 798 .lldd_dev_found = asd_dev_found,
792 .lldd_dev_gone = asd_dev_gone, 799 .lldd_dev_gone = asd_dev_gone,
793 800
diff --git a/drivers/scsi/aic94xx/aic94xx_reg_def.h b/drivers/scsi/aic94xx/aic94xx_reg_def.h
index b79f45f3ad47..a11f4e6d8bd9 100644
--- a/drivers/scsi/aic94xx/aic94xx_reg_def.h
+++ b/drivers/scsi/aic94xx/aic94xx_reg_def.h
@@ -2000,7 +2000,7 @@
2000 * The host accesses this scratch in a different manner from the 2000 * The host accesses this scratch in a different manner from the
2001 * central sequencer. The sequencer has to use CSEQ registers CSCRPAGE 2001 * central sequencer. The sequencer has to use CSEQ registers CSCRPAGE
2002 * and CMnSCRPAGE to access the scratch memory. A flat mapping of the 2002 * and CMnSCRPAGE to access the scratch memory. A flat mapping of the
2003 * scratch memory is avaliable for software convenience and to prevent 2003 * scratch memory is available for software convenience and to prevent
2004 * corruption while the sequencer is running. This memory is mapped 2004 * corruption while the sequencer is running. This memory is mapped
2005 * onto addresses 800h - BFFh, total of 400h bytes. 2005 * onto addresses 800h - BFFh, total of 400h bytes.
2006 * 2006 *
diff --git a/drivers/scsi/aic94xx/aic94xx_sas.h b/drivers/scsi/aic94xx/aic94xx_sas.h
index 64d231712345..9050e93bfd5e 100644
--- a/drivers/scsi/aic94xx/aic94xx_sas.h
+++ b/drivers/scsi/aic94xx/aic94xx_sas.h
@@ -733,6 +733,7 @@ struct asd_phy {
733 733
734 struct sas_identify_frame *identify_frame; 734 struct sas_identify_frame *identify_frame;
735 struct asd_dma_tok *id_frm_tok; 735 struct asd_dma_tok *id_frm_tok;
736 struct asd_port *asd_port;
736 737
737 u8 frame_rcvd[ASD_EDB_SIZE]; 738 u8 frame_rcvd[ASD_EDB_SIZE];
738}; 739};
diff --git a/drivers/scsi/aic94xx/aic94xx_scb.c b/drivers/scsi/aic94xx/aic94xx_scb.c
index 7ee49b51b724..75ed6b0569d1 100644
--- a/drivers/scsi/aic94xx/aic94xx_scb.c
+++ b/drivers/scsi/aic94xx/aic94xx_scb.c
@@ -25,6 +25,7 @@
25 */ 25 */
26 26
27#include <linux/pci.h> 27#include <linux/pci.h>
28#include <scsi/scsi_host.h>
28 29
29#include "aic94xx.h" 30#include "aic94xx.h"
30#include "aic94xx_reg.h" 31#include "aic94xx_reg.h"
@@ -168,6 +169,70 @@ static inline void asd_get_attached_sas_addr(struct asd_phy *phy, u8 *sas_addr)
168 } 169 }
169} 170}
170 171
172static void asd_form_port(struct asd_ha_struct *asd_ha, struct asd_phy *phy)
173{
174 int i;
175 struct asd_port *free_port = NULL;
176 struct asd_port *port;
177 struct asd_sas_phy *sas_phy = &phy->sas_phy;
178 unsigned long flags;
179
180 spin_lock_irqsave(&asd_ha->asd_ports_lock, flags);
181 if (!phy->asd_port) {
182 for (i = 0; i < ASD_MAX_PHYS; i++) {
183 port = &asd_ha->asd_ports[i];
184
185 /* Check for wide port */
186 if (port->num_phys > 0 &&
187 memcmp(port->sas_addr, sas_phy->sas_addr,
188 SAS_ADDR_SIZE) == 0 &&
189 memcmp(port->attached_sas_addr,
190 sas_phy->attached_sas_addr,
191 SAS_ADDR_SIZE) == 0) {
192 break;
193 }
194
195 /* Find a free port */
196 if (port->num_phys == 0 && free_port == NULL) {
197 free_port = port;
198 }
199 }
200
201 /* Use a free port if this doesn't form a wide port */
202 if (i >= ASD_MAX_PHYS) {
203 port = free_port;
204 BUG_ON(!port);
205 memcpy(port->sas_addr, sas_phy->sas_addr,
206 SAS_ADDR_SIZE);
207 memcpy(port->attached_sas_addr,
208 sas_phy->attached_sas_addr,
209 SAS_ADDR_SIZE);
210 }
211 port->num_phys++;
212 port->phy_mask |= (1U << sas_phy->id);
213 phy->asd_port = port;
214 }
215 ASD_DPRINTK("%s: updating phy_mask 0x%x for phy%d\n",
216 __FUNCTION__, phy->asd_port->phy_mask, sas_phy->id);
217 asd_update_port_links(asd_ha, phy);
218 spin_unlock_irqrestore(&asd_ha->asd_ports_lock, flags);
219}
220
221static void asd_deform_port(struct asd_ha_struct *asd_ha, struct asd_phy *phy)
222{
223 struct asd_port *port = phy->asd_port;
224 struct asd_sas_phy *sas_phy = &phy->sas_phy;
225 unsigned long flags;
226
227 spin_lock_irqsave(&asd_ha->asd_ports_lock, flags);
228 if (port) {
229 port->num_phys--;
230 port->phy_mask &= ~(1U << sas_phy->id);
231 phy->asd_port = NULL;
232 }
233 spin_unlock_irqrestore(&asd_ha->asd_ports_lock, flags);
234}
235
171static inline void asd_bytes_dmaed_tasklet(struct asd_ascb *ascb, 236static inline void asd_bytes_dmaed_tasklet(struct asd_ascb *ascb,
172 struct done_list_struct *dl, 237 struct done_list_struct *dl,
173 int edb_id, int phy_id) 238 int edb_id, int phy_id)
@@ -187,6 +252,7 @@ static inline void asd_bytes_dmaed_tasklet(struct asd_ascb *ascb,
187 asd_get_attached_sas_addr(phy, phy->sas_phy.attached_sas_addr); 252 asd_get_attached_sas_addr(phy, phy->sas_phy.attached_sas_addr);
188 spin_unlock_irqrestore(&phy->sas_phy.frame_rcvd_lock, flags); 253 spin_unlock_irqrestore(&phy->sas_phy.frame_rcvd_lock, flags);
189 asd_dump_frame_rcvd(phy, dl); 254 asd_dump_frame_rcvd(phy, dl);
255 asd_form_port(ascb->ha, phy);
190 sas_ha->notify_port_event(&phy->sas_phy, PORTE_BYTES_DMAED); 256 sas_ha->notify_port_event(&phy->sas_phy, PORTE_BYTES_DMAED);
191} 257}
192 258
@@ -197,6 +263,7 @@ static inline void asd_link_reset_err_tasklet(struct asd_ascb *ascb,
197 struct asd_ha_struct *asd_ha = ascb->ha; 263 struct asd_ha_struct *asd_ha = ascb->ha;
198 struct sas_ha_struct *sas_ha = &asd_ha->sas_ha; 264 struct sas_ha_struct *sas_ha = &asd_ha->sas_ha;
199 struct asd_sas_phy *sas_phy = sas_ha->sas_phy[phy_id]; 265 struct asd_sas_phy *sas_phy = sas_ha->sas_phy[phy_id];
266 struct asd_phy *phy = &asd_ha->phys[phy_id];
200 u8 lr_error = dl->status_block[1]; 267 u8 lr_error = dl->status_block[1];
201 u8 retries_left = dl->status_block[2]; 268 u8 retries_left = dl->status_block[2];
202 269
@@ -221,6 +288,7 @@ static inline void asd_link_reset_err_tasklet(struct asd_ascb *ascb,
221 288
222 asd_turn_led(asd_ha, phy_id, 0); 289 asd_turn_led(asd_ha, phy_id, 0);
223 sas_phy_disconnected(sas_phy); 290 sas_phy_disconnected(sas_phy);
291 asd_deform_port(asd_ha, phy);
224 sas_ha->notify_port_event(sas_phy, PORTE_LINK_RESET_ERR); 292 sas_ha->notify_port_event(sas_phy, PORTE_LINK_RESET_ERR);
225 293
226 if (retries_left == 0) { 294 if (retries_left == 0) {
@@ -248,6 +316,8 @@ static inline void asd_primitive_rcvd_tasklet(struct asd_ascb *ascb,
248 unsigned long flags; 316 unsigned long flags;
249 struct sas_ha_struct *sas_ha = &ascb->ha->sas_ha; 317 struct sas_ha_struct *sas_ha = &ascb->ha->sas_ha;
250 struct asd_sas_phy *sas_phy = sas_ha->sas_phy[phy_id]; 318 struct asd_sas_phy *sas_phy = sas_ha->sas_phy[phy_id];
319 struct asd_ha_struct *asd_ha = ascb->ha;
320 struct asd_phy *phy = &asd_ha->phys[phy_id];
251 u8 reg = dl->status_block[1]; 321 u8 reg = dl->status_block[1];
252 u32 cont = dl->status_block[2] << ((reg & 3)*8); 322 u32 cont = dl->status_block[2] << ((reg & 3)*8);
253 323
@@ -284,6 +354,7 @@ static inline void asd_primitive_rcvd_tasklet(struct asd_ascb *ascb,
284 phy_id); 354 phy_id);
285 /* The sequencer disables all phys on that port. 355 /* The sequencer disables all phys on that port.
286 * We have to re-enable the phys ourselves. */ 356 * We have to re-enable the phys ourselves. */
357 asd_deform_port(asd_ha, phy);
287 sas_ha->notify_port_event(sas_phy, PORTE_HARD_RESET); 358 sas_ha->notify_port_event(sas_phy, PORTE_HARD_RESET);
288 break; 359 break;
289 360
@@ -342,6 +413,40 @@ void asd_invalidate_edb(struct asd_ascb *ascb, int edb_id)
342 } 413 }
343} 414}
344 415
416/* hard reset a phy later */
417static void do_phy_reset_later(struct work_struct *work)
418{
419 struct sas_phy *sas_phy =
420 container_of(work, struct sas_phy, reset_work);
421 int error;
422
423 ASD_DPRINTK("%s: About to hard reset phy %d\n", __FUNCTION__,
424 sas_phy->identify.phy_identifier);
425 /* Reset device port */
426 error = sas_phy_reset(sas_phy, 1);
427 if (error)
428 ASD_DPRINTK("%s: Hard reset of phy %d failed (%d).\n",
429 __FUNCTION__, sas_phy->identify.phy_identifier, error);
430}
431
432static void phy_reset_later(struct sas_phy *sas_phy, struct Scsi_Host *shost)
433{
434 INIT_WORK(&sas_phy->reset_work, do_phy_reset_later);
435 queue_work(shost->work_q, &sas_phy->reset_work);
436}
437
438/* start up the ABORT TASK tmf... */
439static void task_kill_later(struct asd_ascb *ascb)
440{
441 struct asd_ha_struct *asd_ha = ascb->ha;
442 struct sas_ha_struct *sas_ha = &asd_ha->sas_ha;
443 struct Scsi_Host *shost = sas_ha->core.shost;
444 struct sas_task *task = ascb->uldd_task;
445
446 INIT_WORK(&task->abort_work, sas_task_abort);
447 queue_work(shost->work_q, &task->abort_work);
448}
449
345static void escb_tasklet_complete(struct asd_ascb *ascb, 450static void escb_tasklet_complete(struct asd_ascb *ascb,
346 struct done_list_struct *dl) 451 struct done_list_struct *dl)
347{ 452{
@@ -351,6 +456,7 @@ static void escb_tasklet_complete(struct asd_ascb *ascb,
351 u8 sb_opcode = dl->status_block[0]; 456 u8 sb_opcode = dl->status_block[0];
352 int phy_id = sb_opcode & DL_PHY_MASK; 457 int phy_id = sb_opcode & DL_PHY_MASK;
353 struct asd_sas_phy *sas_phy = sas_ha->sas_phy[phy_id]; 458 struct asd_sas_phy *sas_phy = sas_ha->sas_phy[phy_id];
459 struct asd_phy *phy = &asd_ha->phys[phy_id];
354 460
355 if (edb > 6 || edb < 0) { 461 if (edb > 6 || edb < 0) {
356 ASD_DPRINTK("edb is 0x%x! dl->opcode is 0x%x\n", 462 ASD_DPRINTK("edb is 0x%x! dl->opcode is 0x%x\n",
@@ -368,6 +474,74 @@ static void escb_tasklet_complete(struct asd_ascb *ascb,
368 ascb->scb->header.opcode); 474 ascb->scb->header.opcode);
369 } 475 }
370 476
477 /* Catch these before we mask off the sb_opcode bits */
478 switch (sb_opcode) {
479 case REQ_TASK_ABORT: {
480 struct asd_ascb *a, *b;
481 u16 tc_abort;
482
483 tc_abort = *((u16*)(&dl->status_block[1]));
484 tc_abort = le16_to_cpu(tc_abort);
485
486 ASD_DPRINTK("%s: REQ_TASK_ABORT, reason=0x%X\n",
487 __FUNCTION__, dl->status_block[3]);
488
489 /* Find the pending task and abort it. */
490 list_for_each_entry_safe(a, b, &asd_ha->seq.pend_q, list)
491 if (a->tc_index == tc_abort) {
492 task_kill_later(a);
493 break;
494 }
495 goto out;
496 }
497 case REQ_DEVICE_RESET: {
498 struct Scsi_Host *shost = sas_ha->core.shost;
499 struct sas_phy *dev_phy;
500 struct asd_ascb *a;
501 u16 conn_handle;
502
503 conn_handle = *((u16*)(&dl->status_block[1]));
504 conn_handle = le16_to_cpu(conn_handle);
505
506 ASD_DPRINTK("%s: REQ_DEVICE_RESET, reason=0x%X\n", __FUNCTION__,
507 dl->status_block[3]);
508
509 /* Kill all pending tasks and reset the device */
510 dev_phy = NULL;
511 list_for_each_entry(a, &asd_ha->seq.pend_q, list) {
512 struct sas_task *task;
513 struct domain_device *dev;
514 u16 x;
515
516 task = a->uldd_task;
517 if (!task)
518 continue;
519 dev = task->dev;
520
521 x = (unsigned long)dev->lldd_dev;
522 if (x == conn_handle) {
523 dev_phy = dev->port->phy;
524 task_kill_later(a);
525 }
526 }
527
528 /* Reset device port */
529 if (!dev_phy) {
530 ASD_DPRINTK("%s: No pending commands; can't reset.\n",
531 __FUNCTION__);
532 goto out;
533 }
534 phy_reset_later(dev_phy, shost);
535 goto out;
536 }
537 case SIGNAL_NCQ_ERROR:
538 ASD_DPRINTK("%s: SIGNAL_NCQ_ERROR\n", __FUNCTION__);
539 goto out;
540 case CLEAR_NCQ_ERROR:
541 ASD_DPRINTK("%s: CLEAR_NCQ_ERROR\n", __FUNCTION__);
542 goto out;
543 }
544
371 sb_opcode &= ~DL_PHY_MASK; 545 sb_opcode &= ~DL_PHY_MASK;
372 546
373 switch (sb_opcode) { 547 switch (sb_opcode) {
@@ -395,24 +569,9 @@ static void escb_tasklet_complete(struct asd_ascb *ascb,
395 asd_turn_led(asd_ha, phy_id, 0); 569 asd_turn_led(asd_ha, phy_id, 0);
396 /* the device is gone */ 570 /* the device is gone */
397 sas_phy_disconnected(sas_phy); 571 sas_phy_disconnected(sas_phy);
572 asd_deform_port(asd_ha, phy);
398 sas_ha->notify_port_event(sas_phy, PORTE_TIMER_EVENT); 573 sas_ha->notify_port_event(sas_phy, PORTE_TIMER_EVENT);
399 break; 574 break;
400 case REQ_TASK_ABORT:
401 ASD_DPRINTK("%s: phy%d: REQ_TASK_ABORT\n", __FUNCTION__,
402 phy_id);
403 break;
404 case REQ_DEVICE_RESET:
405 ASD_DPRINTK("%s: phy%d: REQ_DEVICE_RESET\n", __FUNCTION__,
406 phy_id);
407 break;
408 case SIGNAL_NCQ_ERROR:
409 ASD_DPRINTK("%s: phy%d: SIGNAL_NCQ_ERROR\n", __FUNCTION__,
410 phy_id);
411 break;
412 case CLEAR_NCQ_ERROR:
413 ASD_DPRINTK("%s: phy%d: CLEAR_NCQ_ERROR\n", __FUNCTION__,
414 phy_id);
415 break;
416 default: 575 default:
417 ASD_DPRINTK("%s: phy%d: unknown event:0x%x\n", __FUNCTION__, 576 ASD_DPRINTK("%s: phy%d: unknown event:0x%x\n", __FUNCTION__,
418 phy_id, sb_opcode); 577 phy_id, sb_opcode);
@@ -432,7 +591,7 @@ static void escb_tasklet_complete(struct asd_ascb *ascb,
432 591
433 break; 592 break;
434 } 593 }
435 594out:
436 asd_invalidate_edb(ascb, edb); 595 asd_invalidate_edb(ascb, edb);
437} 596}
438 597
diff --git a/drivers/scsi/aic94xx/aic94xx_sds.c b/drivers/scsi/aic94xx/aic94xx_sds.c
index de7c04d4254d..e5a0ec37e954 100644
--- a/drivers/scsi/aic94xx/aic94xx_sds.c
+++ b/drivers/scsi/aic94xx/aic94xx_sds.c
@@ -64,7 +64,7 @@ struct asd_ocm_dir {
64 64
65#define OCM_INIT_DIR_ENTRIES 5 65#define OCM_INIT_DIR_ENTRIES 5
66/*************************************************************************** 66/***************************************************************************
67* OCM dircetory default 67* OCM directory default
68***************************************************************************/ 68***************************************************************************/
69static struct asd_ocm_dir OCMDirInit = 69static struct asd_ocm_dir OCMDirInit =
70{ 70{
@@ -73,7 +73,7 @@ static struct asd_ocm_dir OCMDirInit =
73}; 73};
74 74
75/*************************************************************************** 75/***************************************************************************
76* OCM dircetory Entries default 76* OCM directory Entries default
77***************************************************************************/ 77***************************************************************************/
78static struct asd_ocm_dir_ent OCMDirEntriesInit[OCM_INIT_DIR_ENTRIES] = 78static struct asd_ocm_dir_ent OCMDirEntriesInit[OCM_INIT_DIR_ENTRIES] =
79{ 79{
diff --git a/drivers/scsi/aic94xx/aic94xx_seq.c b/drivers/scsi/aic94xx/aic94xx_seq.c
index 56e4b3ba6a08..845112539d05 100644
--- a/drivers/scsi/aic94xx/aic94xx_seq.c
+++ b/drivers/scsi/aic94xx/aic94xx_seq.c
@@ -1369,10 +1369,9 @@ int asd_start_seqs(struct asd_ha_struct *asd_ha)
1369 * port_map_by_links is also used as the conn_mask byte in the 1369 * port_map_by_links is also used as the conn_mask byte in the
1370 * initiator/target port DDB. 1370 * initiator/target port DDB.
1371 */ 1371 */
1372void asd_update_port_links(struct asd_sas_phy *sas_phy) 1372void asd_update_port_links(struct asd_ha_struct *asd_ha, struct asd_phy *phy)
1373{ 1373{
1374 struct asd_ha_struct *asd_ha = sas_phy->ha->lldd_ha; 1374 const u8 phy_mask = (u8) phy->asd_port->phy_mask;
1375 const u8 phy_mask = (u8) sas_phy->port->phy_mask;
1376 u8 phy_is_up; 1375 u8 phy_is_up;
1377 u8 mask; 1376 u8 mask;
1378 int i, err; 1377 int i, err;
diff --git a/drivers/scsi/aic94xx/aic94xx_seq.h b/drivers/scsi/aic94xx/aic94xx_seq.h
index 42281c36153b..9e715e5496af 100644
--- a/drivers/scsi/aic94xx/aic94xx_seq.h
+++ b/drivers/scsi/aic94xx/aic94xx_seq.h
@@ -64,7 +64,7 @@ int asd_unpause_lseq(struct asd_ha_struct *asd_ha, u8 lseq_mask);
64int asd_init_seqs(struct asd_ha_struct *asd_ha); 64int asd_init_seqs(struct asd_ha_struct *asd_ha);
65int asd_start_seqs(struct asd_ha_struct *asd_ha); 65int asd_start_seqs(struct asd_ha_struct *asd_ha);
66 66
67void asd_update_port_links(struct asd_sas_phy *phy); 67void asd_update_port_links(struct asd_ha_struct *asd_ha, struct asd_phy *phy);
68#endif 68#endif
69 69
70#endif 70#endif
diff --git a/drivers/scsi/fd_mcs.c b/drivers/scsi/fd_mcs.c
index ef8285c326e4..668569e8856b 100644
--- a/drivers/scsi/fd_mcs.c
+++ b/drivers/scsi/fd_mcs.c
@@ -294,6 +294,7 @@ static struct Scsi_Host *hosts[FD_MAX_HOSTS + 1] = { NULL };
294static int user_fifo_count = 0; 294static int user_fifo_count = 0;
295static int user_fifo_size = 0; 295static int user_fifo_size = 0;
296 296
297#ifndef MODULE
297static int __init fd_mcs_setup(char *str) 298static int __init fd_mcs_setup(char *str)
298{ 299{
299 static int done_setup = 0; 300 static int done_setup = 0;
@@ -311,6 +312,7 @@ static int __init fd_mcs_setup(char *str)
311} 312}
312 313
313__setup("fd_mcs=", fd_mcs_setup); 314__setup("fd_mcs=", fd_mcs_setup);
315#endif /* !MODULE */
314 316
315static void print_banner(struct Scsi_Host *shpnt) 317static void print_banner(struct Scsi_Host *shpnt)
316{ 318{
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index 4bc14ad92e22..4c698a71f66f 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -3531,7 +3531,7 @@ static irqreturn_t gdth_interrupt(int irq,void *dev_id)
3531 IStatus &= ~0x80; 3531 IStatus &= ~0x80;
3532#ifdef INT_COAL 3532#ifdef INT_COAL
3533 if (coalesced) 3533 if (coalesced)
3534 ha->status = pcs->ext_status && 0xffff; 3534 ha->status = pcs->ext_status & 0xffff;
3535 else 3535 else
3536#endif 3536#endif
3537 ha->status = gdth_readw(&dp6m_ptr->i960r.status); 3537 ha->status = gdth_readw(&dp6m_ptr->i960r.status);
@@ -3543,7 +3543,7 @@ static irqreturn_t gdth_interrupt(int irq,void *dev_id)
3543 if (coalesced) { 3543 if (coalesced) {
3544 ha->info = pcs->info0; 3544 ha->info = pcs->info0;
3545 ha->info2 = pcs->info1; 3545 ha->info2 = pcs->info1;
3546 ha->service = (pcs->ext_status >> 16) && 0xffff; 3546 ha->service = (pcs->ext_status >> 16) & 0xffff;
3547 } else 3547 } else
3548#endif 3548#endif
3549 { 3549 {
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 68ef1636678d..38c3a291efac 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -263,6 +263,10 @@ static void scsi_host_dev_release(struct device *dev)
263 kthread_stop(shost->ehandler); 263 kthread_stop(shost->ehandler);
264 if (shost->work_q) 264 if (shost->work_q)
265 destroy_workqueue(shost->work_q); 265 destroy_workqueue(shost->work_q);
266 if (shost->uspace_req_q) {
267 kfree(shost->uspace_req_q->queuedata);
268 scsi_free_queue(shost->uspace_req_q);
269 }
266 270
267 scsi_destroy_command_freelist(shost); 271 scsi_destroy_command_freelist(shost);
268 if (shost->bqt) 272 if (shost->bqt)
@@ -301,8 +305,8 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
301 if (!shost) 305 if (!shost)
302 return NULL; 306 return NULL;
303 307
304 spin_lock_init(&shost->default_lock); 308 shost->host_lock = &shost->default_lock;
305 scsi_assign_lock(shost, &shost->default_lock); 309 spin_lock_init(shost->host_lock);
306 shost->shost_state = SHOST_CREATED; 310 shost->shost_state = SHOST_CREATED;
307 INIT_LIST_HEAD(&shost->__devices); 311 INIT_LIST_HEAD(&shost->__devices);
308 INIT_LIST_HEAD(&shost->__targets); 312 INIT_LIST_HEAD(&shost->__targets);
diff --git a/drivers/scsi/ibmvscsi/Makefile b/drivers/scsi/ibmvscsi/Makefile
index 4e247b6b8700..6ac0633d5452 100644
--- a/drivers/scsi/ibmvscsi/Makefile
+++ b/drivers/scsi/ibmvscsi/Makefile
@@ -3,3 +3,5 @@ obj-$(CONFIG_SCSI_IBMVSCSI) += ibmvscsic.o
3ibmvscsic-y += ibmvscsi.o 3ibmvscsic-y += ibmvscsi.o
4ibmvscsic-$(CONFIG_PPC_ISERIES) += iseries_vscsi.o 4ibmvscsic-$(CONFIG_PPC_ISERIES) += iseries_vscsi.o
5ibmvscsic-$(CONFIG_PPC_PSERIES) += rpa_vscsi.o 5ibmvscsic-$(CONFIG_PPC_PSERIES) += rpa_vscsi.o
6
7obj-$(CONFIG_SCSI_IBMVSCSIS) += ibmvstgt.o
diff --git a/drivers/scsi/ibmvscsi/ibmvstgt.c b/drivers/scsi/ibmvscsi/ibmvstgt.c
new file mode 100644
index 000000000000..e28260f05d6b
--- /dev/null
+++ b/drivers/scsi/ibmvscsi/ibmvstgt.c
@@ -0,0 +1,960 @@
1/*
2 * IBM eServer i/pSeries Virtual SCSI Target Driver
3 * Copyright (C) 2003-2005 Dave Boutcher (boutcher@us.ibm.com) IBM Corp.
4 * Santiago Leon (santil@us.ibm.com) IBM Corp.
5 * Linda Xie (lxie@us.ibm.com) IBM Corp.
6 *
7 * Copyright (C) 2005-2006 FUJITA Tomonori <tomof@acm.org>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 * USA
23 */
24#include <linux/interrupt.h>
25#include <linux/module.h>
26#include <scsi/scsi.h>
27#include <scsi/scsi_host.h>
28#include <scsi/scsi_tgt.h>
29#include <scsi/libsrp.h>
30#include <asm/hvcall.h>
31#include <asm/iommu.h>
32#include <asm/prom.h>
33#include <asm/vio.h>
34
35#include "ibmvscsi.h"
36
37#define INITIAL_SRP_LIMIT 16
38#define DEFAULT_MAX_SECTORS 512
39
40#define TGT_NAME "ibmvstgt"
41
42/*
43 * Hypervisor calls.
44 */
45#define h_copy_rdma(l, sa, sb, da, db) \
46 plpar_hcall_norets(H_COPY_RDMA, l, sa, sb, da, db)
47#define h_send_crq(ua, l, h) \
48 plpar_hcall_norets(H_SEND_CRQ, ua, l, h)
49#define h_reg_crq(ua, tok, sz)\
50 plpar_hcall_norets(H_REG_CRQ, ua, tok, sz);
51#define h_free_crq(ua) \
52 plpar_hcall_norets(H_FREE_CRQ, ua);
53
54/* tmp - will replace with SCSI logging stuff */
55#define eprintk(fmt, args...) \
56do { \
57 printk("%s(%d) " fmt, __FUNCTION__, __LINE__, ##args); \
58} while (0)
59/* #define dprintk eprintk */
60#define dprintk(fmt, args...)
61
62struct vio_port {
63 struct vio_dev *dma_dev;
64
65 struct crq_queue crq_queue;
66 struct work_struct crq_work;
67
68 unsigned long liobn;
69 unsigned long riobn;
70 struct srp_target *target;
71};
72
73static struct workqueue_struct *vtgtd;
74
75/*
76 * These are fixed for the system and come from the Open Firmware device tree.
77 * We just store them here to save getting them every time.
78 */
79static char system_id[64] = "";
80static char partition_name[97] = "UNKNOWN";
81static unsigned int partition_number = -1;
82
83static struct vio_port *target_to_port(struct srp_target *target)
84{
85 return (struct vio_port *) target->ldata;
86}
87
88static inline union viosrp_iu *vio_iu(struct iu_entry *iue)
89{
90 return (union viosrp_iu *) (iue->sbuf->buf);
91}
92
93static int send_iu(struct iu_entry *iue, uint64_t length, uint8_t format)
94{
95 struct srp_target *target = iue->target;
96 struct vio_port *vport = target_to_port(target);
97 long rc, rc1;
98 union {
99 struct viosrp_crq cooked;
100 uint64_t raw[2];
101 } crq;
102
103 /* First copy the SRP */
104 rc = h_copy_rdma(length, vport->liobn, iue->sbuf->dma,
105 vport->riobn, iue->remote_token);
106
107 if (rc)
108 eprintk("Error %ld transferring data\n", rc);
109
110 crq.cooked.valid = 0x80;
111 crq.cooked.format = format;
112 crq.cooked.reserved = 0x00;
113 crq.cooked.timeout = 0x00;
114 crq.cooked.IU_length = length;
115 crq.cooked.IU_data_ptr = vio_iu(iue)->srp.rsp.tag;
116
117 if (rc == 0)
118 crq.cooked.status = 0x99; /* Just needs to be non-zero */
119 else
120 crq.cooked.status = 0x00;
121
122 rc1 = h_send_crq(vport->dma_dev->unit_address, crq.raw[0], crq.raw[1]);
123
124 if (rc1) {
125 eprintk("%ld sending response\n", rc1);
126 return rc1;
127 }
128
129 return rc;
130}
131
132#define SRP_RSP_SENSE_DATA_LEN 18
133
134static int send_rsp(struct iu_entry *iue, struct scsi_cmnd *sc,
135 unsigned char status, unsigned char asc)
136{
137 union viosrp_iu *iu = vio_iu(iue);
138 uint64_t tag = iu->srp.rsp.tag;
139
140 /* If the linked bit is on and status is good */
141 if (test_bit(V_LINKED, &iue->flags) && (status == NO_SENSE))
142 status = 0x10;
143
144 memset(iu, 0, sizeof(struct srp_rsp));
145 iu->srp.rsp.opcode = SRP_RSP;
146 iu->srp.rsp.req_lim_delta = 1;
147 iu->srp.rsp.tag = tag;
148
149 if (test_bit(V_DIOVER, &iue->flags))
150 iu->srp.rsp.flags |= SRP_RSP_FLAG_DIOVER;
151
152 iu->srp.rsp.data_in_res_cnt = 0;
153 iu->srp.rsp.data_out_res_cnt = 0;
154
155 iu->srp.rsp.flags &= ~SRP_RSP_FLAG_RSPVALID;
156
157 iu->srp.rsp.resp_data_len = 0;
158 iu->srp.rsp.status = status;
159 if (status) {
160 uint8_t *sense = iu->srp.rsp.data;
161
162 if (sc) {
163 iu->srp.rsp.flags |= SRP_RSP_FLAG_SNSVALID;
164 iu->srp.rsp.sense_data_len = SCSI_SENSE_BUFFERSIZE;
165 memcpy(sense, sc->sense_buffer, SCSI_SENSE_BUFFERSIZE);
166 } else {
167 iu->srp.rsp.status = SAM_STAT_CHECK_CONDITION;
168 iu->srp.rsp.flags |= SRP_RSP_FLAG_SNSVALID;
169 iu->srp.rsp.sense_data_len = SRP_RSP_SENSE_DATA_LEN;
170
171 /* Valid bit and 'current errors' */
172 sense[0] = (0x1 << 7 | 0x70);
173 /* Sense key */
174 sense[2] = status;
175 /* Additional sense length */
176 sense[7] = 0xa; /* 10 bytes */
177 /* Additional sense code */
178 sense[12] = asc;
179 }
180 }
181
182 send_iu(iue, sizeof(iu->srp.rsp) + SRP_RSP_SENSE_DATA_LEN,
183 VIOSRP_SRP_FORMAT);
184
185 return 0;
186}
187
188static void handle_cmd_queue(struct srp_target *target)
189{
190 struct Scsi_Host *shost = target->shost;
191 struct iu_entry *iue;
192 struct srp_cmd *cmd;
193 unsigned long flags;
194 int err;
195
196retry:
197 spin_lock_irqsave(&target->lock, flags);
198
199 list_for_each_entry(iue, &target->cmd_queue, ilist) {
200 if (!test_and_set_bit(V_FLYING, &iue->flags)) {
201 spin_unlock_irqrestore(&target->lock, flags);
202 cmd = iue->sbuf->buf;
203 err = srp_cmd_queue(shost, cmd, iue, 0);
204 if (err) {
205 eprintk("cannot queue cmd %p %d\n", cmd, err);
206 srp_iu_put(iue);
207 }
208 goto retry;
209 }
210 }
211
212 spin_unlock_irqrestore(&target->lock, flags);
213}
214
215static int ibmvstgt_rdma(struct scsi_cmnd *sc, struct scatterlist *sg, int nsg,
216 struct srp_direct_buf *md, int nmd,
217 enum dma_data_direction dir, unsigned int rest)
218{
219 struct iu_entry *iue = (struct iu_entry *) sc->SCp.ptr;
220 struct srp_target *target = iue->target;
221 struct vio_port *vport = target_to_port(target);
222 dma_addr_t token;
223 long err;
224 unsigned int done = 0;
225 int i, sidx, soff;
226
227 sidx = soff = 0;
228 token = sg_dma_address(sg + sidx);
229
230 for (i = 0; i < nmd && rest; i++) {
231 unsigned int mdone, mlen;
232
233 mlen = min(rest, md[i].len);
234 for (mdone = 0; mlen;) {
235 int slen = min(sg_dma_len(sg + sidx) - soff, mlen);
236
237 if (dir == DMA_TO_DEVICE)
238 err = h_copy_rdma(slen,
239 vport->riobn,
240 md[i].va + mdone,
241 vport->liobn,
242 token + soff);
243 else
244 err = h_copy_rdma(slen,
245 vport->liobn,
246 token + soff,
247 vport->riobn,
248 md[i].va + mdone);
249
250 if (err != H_SUCCESS) {
251 eprintk("rdma error %d %d\n", dir, slen);
252 goto out;
253 }
254
255 mlen -= slen;
256 mdone += slen;
257 soff += slen;
258 done += slen;
259
260 if (soff == sg_dma_len(sg + sidx)) {
261 sidx++;
262 soff = 0;
263 token = sg_dma_address(sg + sidx);
264
265 if (sidx > nsg) {
266 eprintk("out of sg %p %d %d\n",
267 iue, sidx, nsg);
268 goto out;
269 }
270 }
271 };
272
273 rest -= mlen;
274 }
275out:
276
277 return 0;
278}
279
280static int ibmvstgt_transfer_data(struct scsi_cmnd *sc,
281 void (*done)(struct scsi_cmnd *))
282{
283 struct iu_entry *iue = (struct iu_entry *) sc->SCp.ptr;
284 int err;
285
286 err = srp_transfer_data(sc, &vio_iu(iue)->srp.cmd, ibmvstgt_rdma, 1, 1);
287
288 done(sc);
289
290 return err;
291}
292
293static int ibmvstgt_cmd_done(struct scsi_cmnd *sc,
294 void (*done)(struct scsi_cmnd *))
295{
296 unsigned long flags;
297 struct iu_entry *iue = (struct iu_entry *) sc->SCp.ptr;
298 struct srp_target *target = iue->target;
299
300 dprintk("%p %p %x\n", iue, target, vio_iu(iue)->srp.cmd.cdb[0]);
301
302 spin_lock_irqsave(&target->lock, flags);
303 list_del(&iue->ilist);
304 spin_unlock_irqrestore(&target->lock, flags);
305
306 if (sc->result != SAM_STAT_GOOD) {
307 eprintk("operation failed %p %d %x\n",
308 iue, sc->result, vio_iu(iue)->srp.cmd.cdb[0]);
309 send_rsp(iue, sc, HARDWARE_ERROR, 0x00);
310 } else
311 send_rsp(iue, sc, NO_SENSE, 0x00);
312
313 done(sc);
314 srp_iu_put(iue);
315 return 0;
316}
317
318int send_adapter_info(struct iu_entry *iue,
319 dma_addr_t remote_buffer, uint16_t length)
320{
321 struct srp_target *target = iue->target;
322 struct vio_port *vport = target_to_port(target);
323 struct Scsi_Host *shost = target->shost;
324 dma_addr_t data_token;
325 struct mad_adapter_info_data *info;
326 int err;
327
328 info = dma_alloc_coherent(target->dev, sizeof(*info), &data_token,
329 GFP_KERNEL);
330 if (!info) {
331 eprintk("bad dma_alloc_coherent %p\n", target);
332 return 1;
333 }
334
335 /* Get remote info */
336 err = h_copy_rdma(sizeof(*info), vport->riobn, remote_buffer,
337 vport->liobn, data_token);
338 if (err == H_SUCCESS) {
339 dprintk("Client connect: %s (%d)\n",
340 info->partition_name, info->partition_number);
341 }
342
343 memset(info, 0, sizeof(*info));
344
345 strcpy(info->srp_version, "16.a");
346 strncpy(info->partition_name, partition_name,
347 sizeof(info->partition_name));
348 info->partition_number = partition_number;
349 info->mad_version = 1;
350 info->os_type = 2;
351 info->port_max_txu[0] = shost->hostt->max_sectors << 9;
352
353 /* Send our info to remote */
354 err = h_copy_rdma(sizeof(*info), vport->liobn, data_token,
355 vport->riobn, remote_buffer);
356
357 dma_free_coherent(target->dev, sizeof(*info), info, data_token);
358
359 if (err != H_SUCCESS) {
360 eprintk("Error sending adapter info %d\n", err);
361 return 1;
362 }
363
364 return 0;
365}
366
367static void process_login(struct iu_entry *iue)
368{
369 union viosrp_iu *iu = vio_iu(iue);
370 struct srp_login_rsp *rsp = &iu->srp.login_rsp;
371 uint64_t tag = iu->srp.rsp.tag;
372
373 /* TODO handle case that requested size is wrong and
374 * buffer format is wrong
375 */
376 memset(iu, 0, sizeof(struct srp_login_rsp));
377 rsp->opcode = SRP_LOGIN_RSP;
378 rsp->req_lim_delta = INITIAL_SRP_LIMIT;
379 rsp->tag = tag;
380 rsp->max_it_iu_len = sizeof(union srp_iu);
381 rsp->max_ti_iu_len = sizeof(union srp_iu);
382 /* direct and indirect */
383 rsp->buf_fmt = SRP_BUF_FORMAT_DIRECT | SRP_BUF_FORMAT_INDIRECT;
384
385 send_iu(iue, sizeof(*rsp), VIOSRP_SRP_FORMAT);
386}
387
388static inline void queue_cmd(struct iu_entry *iue)
389{
390 struct srp_target *target = iue->target;
391 unsigned long flags;
392
393 spin_lock_irqsave(&target->lock, flags);
394 list_add_tail(&iue->ilist, &target->cmd_queue);
395 spin_unlock_irqrestore(&target->lock, flags);
396}
397
398static int process_tsk_mgmt(struct iu_entry *iue)
399{
400 union viosrp_iu *iu = vio_iu(iue);
401 int fn;
402
403 dprintk("%p %u\n", iue, iu->srp.tsk_mgmt.tsk_mgmt_func);
404
405 switch (iu->srp.tsk_mgmt.tsk_mgmt_func) {
406 case SRP_TSK_ABORT_TASK:
407 fn = ABORT_TASK;
408 break;
409 case SRP_TSK_ABORT_TASK_SET:
410 fn = ABORT_TASK_SET;
411 break;
412 case SRP_TSK_CLEAR_TASK_SET:
413 fn = CLEAR_TASK_SET;
414 break;
415 case SRP_TSK_LUN_RESET:
416 fn = LOGICAL_UNIT_RESET;
417 break;
418 case SRP_TSK_CLEAR_ACA:
419 fn = CLEAR_ACA;
420 break;
421 default:
422 fn = 0;
423 }
424 if (fn)
425 scsi_tgt_tsk_mgmt_request(iue->target->shost, fn,
426 iu->srp.tsk_mgmt.task_tag,
427 (struct scsi_lun *) &iu->srp.tsk_mgmt.lun,
428 iue);
429 else
430 send_rsp(iue, NULL, ILLEGAL_REQUEST, 0x20);
431
432 return !fn;
433}
434
435static int process_mad_iu(struct iu_entry *iue)
436{
437 union viosrp_iu *iu = vio_iu(iue);
438 struct viosrp_adapter_info *info;
439 struct viosrp_host_config *conf;
440
441 switch (iu->mad.empty_iu.common.type) {
442 case VIOSRP_EMPTY_IU_TYPE:
443 eprintk("%s\n", "Unsupported EMPTY MAD IU");
444 break;
445 case VIOSRP_ERROR_LOG_TYPE:
446 eprintk("%s\n", "Unsupported ERROR LOG MAD IU");
447 iu->mad.error_log.common.status = 1;
448 send_iu(iue, sizeof(iu->mad.error_log), VIOSRP_MAD_FORMAT);
449 break;
450 case VIOSRP_ADAPTER_INFO_TYPE:
451 info = &iu->mad.adapter_info;
452 info->common.status = send_adapter_info(iue, info->buffer,
453 info->common.length);
454 send_iu(iue, sizeof(*info), VIOSRP_MAD_FORMAT);
455 break;
456 case VIOSRP_HOST_CONFIG_TYPE:
457 conf = &iu->mad.host_config;
458 conf->common.status = 1;
459 send_iu(iue, sizeof(*conf), VIOSRP_MAD_FORMAT);
460 break;
461 default:
462 eprintk("Unknown type %u\n", iu->srp.rsp.opcode);
463 }
464
465 return 1;
466}
467
468static int process_srp_iu(struct iu_entry *iue)
469{
470 union viosrp_iu *iu = vio_iu(iue);
471 int done = 1;
472 u8 opcode = iu->srp.rsp.opcode;
473
474 switch (opcode) {
475 case SRP_LOGIN_REQ:
476 process_login(iue);
477 break;
478 case SRP_TSK_MGMT:
479 done = process_tsk_mgmt(iue);
480 break;
481 case SRP_CMD:
482 queue_cmd(iue);
483 done = 0;
484 break;
485 case SRP_LOGIN_RSP:
486 case SRP_I_LOGOUT:
487 case SRP_T_LOGOUT:
488 case SRP_RSP:
489 case SRP_CRED_REQ:
490 case SRP_CRED_RSP:
491 case SRP_AER_REQ:
492 case SRP_AER_RSP:
493 eprintk("Unsupported type %u\n", opcode);
494 break;
495 default:
496 eprintk("Unknown type %u\n", opcode);
497 }
498
499 return done;
500}
501
502static void process_iu(struct viosrp_crq *crq, struct srp_target *target)
503{
504 struct vio_port *vport = target_to_port(target);
505 struct iu_entry *iue;
506 long err, done;
507
508 iue = srp_iu_get(target);
509 if (!iue) {
510 eprintk("Error getting IU from pool, %p\n", target);
511 return;
512 }
513
514 iue->remote_token = crq->IU_data_ptr;
515
516 err = h_copy_rdma(crq->IU_length, vport->riobn,
517 iue->remote_token, vport->liobn, iue->sbuf->dma);
518
519 if (err != H_SUCCESS) {
520 eprintk("%ld transferring data error %p\n", err, iue);
521 done = 1;
522 goto out;
523 }
524
525 if (crq->format == VIOSRP_MAD_FORMAT)
526 done = process_mad_iu(iue);
527 else
528 done = process_srp_iu(iue);
529out:
530 if (done)
531 srp_iu_put(iue);
532}
533
534static irqreturn_t ibmvstgt_interrupt(int irq, void *data)
535{
536 struct srp_target *target = (struct srp_target *) data;
537 struct vio_port *vport = target_to_port(target);
538
539 vio_disable_interrupts(vport->dma_dev);
540 queue_work(vtgtd, &vport->crq_work);
541
542 return IRQ_HANDLED;
543}
544
545static int crq_queue_create(struct crq_queue *queue, struct srp_target *target)
546{
547 int err;
548 struct vio_port *vport = target_to_port(target);
549
550 queue->msgs = (struct viosrp_crq *) get_zeroed_page(GFP_KERNEL);
551 if (!queue->msgs)
552 goto malloc_failed;
553 queue->size = PAGE_SIZE / sizeof(*queue->msgs);
554
555 queue->msg_token = dma_map_single(target->dev, queue->msgs,
556 queue->size * sizeof(*queue->msgs),
557 DMA_BIDIRECTIONAL);
558
559 if (dma_mapping_error(queue->msg_token))
560 goto map_failed;
561
562 err = h_reg_crq(vport->dma_dev->unit_address, queue->msg_token,
563 PAGE_SIZE);
564
565 /* If the adapter was left active for some reason (like kexec)
566 * try freeing and re-registering
567 */
568 if (err == H_RESOURCE) {
569 do {
570 err = h_free_crq(vport->dma_dev->unit_address);
571 } while (err == H_BUSY || H_IS_LONG_BUSY(err));
572
573 err = h_reg_crq(vport->dma_dev->unit_address, queue->msg_token,
574 PAGE_SIZE);
575 }
576
577 if (err != H_SUCCESS && err != 2) {
578 eprintk("Error 0x%x opening virtual adapter\n", err);
579 goto reg_crq_failed;
580 }
581
582 err = request_irq(vport->dma_dev->irq, &ibmvstgt_interrupt,
583 SA_INTERRUPT, "ibmvstgt", target);
584 if (err)
585 goto req_irq_failed;
586
587 vio_enable_interrupts(vport->dma_dev);
588
589 h_send_crq(vport->dma_dev->unit_address, 0xC001000000000000, 0);
590
591 queue->cur = 0;
592 spin_lock_init(&queue->lock);
593
594 return 0;
595
596req_irq_failed:
597 do {
598 err = h_free_crq(vport->dma_dev->unit_address);
599 } while (err == H_BUSY || H_IS_LONG_BUSY(err));
600
601reg_crq_failed:
602 dma_unmap_single(target->dev, queue->msg_token,
603 queue->size * sizeof(*queue->msgs), DMA_BIDIRECTIONAL);
604map_failed:
605 free_page((unsigned long) queue->msgs);
606
607malloc_failed:
608 return -ENOMEM;
609}
610
611static void crq_queue_destroy(struct srp_target *target)
612{
613 struct vio_port *vport = target_to_port(target);
614 struct crq_queue *queue = &vport->crq_queue;
615 int err;
616
617 free_irq(vport->dma_dev->irq, target);
618 do {
619 err = h_free_crq(vport->dma_dev->unit_address);
620 } while (err == H_BUSY || H_IS_LONG_BUSY(err));
621
622 dma_unmap_single(target->dev, queue->msg_token,
623 queue->size * sizeof(*queue->msgs), DMA_BIDIRECTIONAL);
624
625 free_page((unsigned long) queue->msgs);
626}
627
628static void process_crq(struct viosrp_crq *crq, struct srp_target *target)
629{
630 struct vio_port *vport = target_to_port(target);
631 dprintk("%x %x\n", crq->valid, crq->format);
632
633 switch (crq->valid) {
634 case 0xC0:
635 /* initialization */
636 switch (crq->format) {
637 case 0x01:
638 h_send_crq(vport->dma_dev->unit_address,
639 0xC002000000000000, 0);
640 break;
641 case 0x02:
642 break;
643 default:
644 eprintk("Unknown format %u\n", crq->format);
645 }
646 break;
647 case 0xFF:
648 /* transport event */
649 break;
650 case 0x80:
651 /* real payload */
652 switch (crq->format) {
653 case VIOSRP_SRP_FORMAT:
654 case VIOSRP_MAD_FORMAT:
655 process_iu(crq, target);
656 break;
657 case VIOSRP_OS400_FORMAT:
658 case VIOSRP_AIX_FORMAT:
659 case VIOSRP_LINUX_FORMAT:
660 case VIOSRP_INLINE_FORMAT:
661 eprintk("Unsupported format %u\n", crq->format);
662 break;
663 default:
664 eprintk("Unknown format %u\n", crq->format);
665 }
666 break;
667 default:
668 eprintk("unknown message type 0x%02x!?\n", crq->valid);
669 }
670}
671
672static inline struct viosrp_crq *next_crq(struct crq_queue *queue)
673{
674 struct viosrp_crq *crq;
675 unsigned long flags;
676
677 spin_lock_irqsave(&queue->lock, flags);
678 crq = &queue->msgs[queue->cur];
679 if (crq->valid & 0x80) {
680 if (++queue->cur == queue->size)
681 queue->cur = 0;
682 } else
683 crq = NULL;
684 spin_unlock_irqrestore(&queue->lock, flags);
685
686 return crq;
687}
688
689static void handle_crq(struct work_struct *work)
690{
691 struct vio_port *vport = container_of(work, struct vio_port, crq_work);
692 struct srp_target *target = vport->target;
693 struct viosrp_crq *crq;
694 int done = 0;
695
696 while (!done) {
697 while ((crq = next_crq(&vport->crq_queue)) != NULL) {
698 process_crq(crq, target);
699 crq->valid = 0x00;
700 }
701
702 vio_enable_interrupts(vport->dma_dev);
703
704 crq = next_crq(&vport->crq_queue);
705 if (crq) {
706 vio_disable_interrupts(vport->dma_dev);
707 process_crq(crq, target);
708 crq->valid = 0x00;
709 } else
710 done = 1;
711 }
712
713 handle_cmd_queue(target);
714}
715
716
717static int ibmvstgt_eh_abort_handler(struct scsi_cmnd *sc)
718{
719 unsigned long flags;
720 struct iu_entry *iue = (struct iu_entry *) sc->SCp.ptr;
721 struct srp_target *target = iue->target;
722
723 dprintk("%p %p %x\n", iue, target, vio_iu(iue)->srp.cmd.cdb[0]);
724
725 spin_lock_irqsave(&target->lock, flags);
726 list_del(&iue->ilist);
727 spin_unlock_irqrestore(&target->lock, flags);
728
729 srp_iu_put(iue);
730
731 return 0;
732}
733
734static int ibmvstgt_tsk_mgmt_response(u64 mid, int result)
735{
736 struct iu_entry *iue = (struct iu_entry *) ((void *) mid);
737 union viosrp_iu *iu = vio_iu(iue);
738 unsigned char status, asc;
739
740 eprintk("%p %d\n", iue, result);
741 status = NO_SENSE;
742 asc = 0;
743
744 switch (iu->srp.tsk_mgmt.tsk_mgmt_func) {
745 case SRP_TSK_ABORT_TASK:
746 asc = 0x14;
747 if (result)
748 status = ABORTED_COMMAND;
749 break;
750 default:
751 break;
752 }
753
754 send_rsp(iue, NULL, status, asc);
755 srp_iu_put(iue);
756
757 return 0;
758}
759
760static ssize_t system_id_show(struct class_device *cdev, char *buf)
761{
762 return snprintf(buf, PAGE_SIZE, "%s\n", system_id);
763}
764
765static ssize_t partition_number_show(struct class_device *cdev, char *buf)
766{
767 return snprintf(buf, PAGE_SIZE, "%x\n", partition_number);
768}
769
770static ssize_t unit_address_show(struct class_device *cdev, char *buf)
771{
772 struct Scsi_Host *shost = class_to_shost(cdev);
773 struct srp_target *target = host_to_srp_target(shost);
774 struct vio_port *vport = target_to_port(target);
775 return snprintf(buf, PAGE_SIZE, "%x\n", vport->dma_dev->unit_address);
776}
777
778static CLASS_DEVICE_ATTR(system_id, S_IRUGO, system_id_show, NULL);
779static CLASS_DEVICE_ATTR(partition_number, S_IRUGO, partition_number_show, NULL);
780static CLASS_DEVICE_ATTR(unit_address, S_IRUGO, unit_address_show, NULL);
781
782static struct class_device_attribute *ibmvstgt_attrs[] = {
783 &class_device_attr_system_id,
784 &class_device_attr_partition_number,
785 &class_device_attr_unit_address,
786 NULL,
787};
788
789static struct scsi_host_template ibmvstgt_sht = {
790 .name = TGT_NAME,
791 .module = THIS_MODULE,
792 .can_queue = INITIAL_SRP_LIMIT,
793 .sg_tablesize = SG_ALL,
794 .use_clustering = DISABLE_CLUSTERING,
795 .max_sectors = DEFAULT_MAX_SECTORS,
796 .transfer_response = ibmvstgt_cmd_done,
797 .transfer_data = ibmvstgt_transfer_data,
798 .eh_abort_handler = ibmvstgt_eh_abort_handler,
799 .tsk_mgmt_response = ibmvstgt_tsk_mgmt_response,
800 .shost_attrs = ibmvstgt_attrs,
801 .proc_name = TGT_NAME,
802};
803
804static int ibmvstgt_probe(struct vio_dev *dev, const struct vio_device_id *id)
805{
806 struct Scsi_Host *shost;
807 struct srp_target *target;
808 struct vio_port *vport;
809 unsigned int *dma, dma_size;
810 int err = -ENOMEM;
811
812 vport = kzalloc(sizeof(struct vio_port), GFP_KERNEL);
813 if (!vport)
814 return err;
815 shost = scsi_host_alloc(&ibmvstgt_sht, sizeof(struct srp_target));
816 if (!shost)
817 goto free_vport;
818 err = scsi_tgt_alloc_queue(shost);
819 if (err)
820 goto put_host;
821
822 target = host_to_srp_target(shost);
823 target->shost = shost;
824 vport->dma_dev = dev;
825 target->ldata = vport;
826 vport->target = target;
827 err = srp_target_alloc(target, &dev->dev, INITIAL_SRP_LIMIT,
828 SRP_MAX_IU_LEN);
829 if (err)
830 goto put_host;
831
832 dma = (unsigned int *) vio_get_attribute(dev, "ibm,my-dma-window",
833 &dma_size);
834 if (!dma || dma_size != 40) {
835 eprintk("Couldn't get window property %d\n", dma_size);
836 err = -EIO;
837 goto free_srp_target;
838 }
839 vport->liobn = dma[0];
840 vport->riobn = dma[5];
841
842 INIT_WORK(&vport->crq_work, handle_crq);
843
844 err = crq_queue_create(&vport->crq_queue, target);
845 if (err)
846 goto free_srp_target;
847
848 err = scsi_add_host(shost, target->dev);
849 if (err)
850 goto destroy_queue;
851 return 0;
852
853destroy_queue:
854 crq_queue_destroy(target);
855free_srp_target:
856 srp_target_free(target);
857put_host:
858 scsi_host_put(shost);
859free_vport:
860 kfree(vport);
861 return err;
862}
863
864static int ibmvstgt_remove(struct vio_dev *dev)
865{
866 struct srp_target *target = (struct srp_target *) dev->dev.driver_data;
867 struct Scsi_Host *shost = target->shost;
868 struct vio_port *vport = target->ldata;
869
870 crq_queue_destroy(target);
871 scsi_remove_host(shost);
872 scsi_tgt_free_queue(shost);
873 srp_target_free(target);
874 kfree(vport);
875 scsi_host_put(shost);
876 return 0;
877}
878
879static struct vio_device_id ibmvstgt_device_table[] __devinitdata = {
880 {"v-scsi-host", "IBM,v-scsi-host"},
881 {"",""}
882};
883
884MODULE_DEVICE_TABLE(vio, ibmvstgt_device_table);
885
886static struct vio_driver ibmvstgt_driver = {
887 .id_table = ibmvstgt_device_table,
888 .probe = ibmvstgt_probe,
889 .remove = ibmvstgt_remove,
890 .driver = {
891 .name = "ibmvscsis",
892 .owner = THIS_MODULE,
893 }
894};
895
896static int get_system_info(void)
897{
898 struct device_node *rootdn;
899 const char *id, *model, *name;
900 unsigned int *num;
901
902 rootdn = find_path_device("/");
903 if (!rootdn)
904 return -ENOENT;
905
906 model = get_property(rootdn, "model", NULL);
907 id = get_property(rootdn, "system-id", NULL);
908 if (model && id)
909 snprintf(system_id, sizeof(system_id), "%s-%s", model, id);
910
911 name = get_property(rootdn, "ibm,partition-name", NULL);
912 if (name)
913 strncpy(partition_name, name, sizeof(partition_name));
914
915 num = (unsigned int *) get_property(rootdn, "ibm,partition-no", NULL);
916 if (num)
917 partition_number = *num;
918
919 return 0;
920}
921
922static int ibmvstgt_init(void)
923{
924 int err = -ENOMEM;
925
926 printk("IBM eServer i/pSeries Virtual SCSI Target Driver\n");
927
928 vtgtd = create_workqueue("ibmvtgtd");
929 if (!vtgtd)
930 return err;
931
932 err = get_system_info();
933 if (err)
934 goto destroy_wq;
935
936 err = vio_register_driver(&ibmvstgt_driver);
937 if (err)
938 goto destroy_wq;
939
940 return 0;
941
942destroy_wq:
943 destroy_workqueue(vtgtd);
944 return err;
945}
946
947static void ibmvstgt_exit(void)
948{
949 printk("Unregister IBM virtual SCSI driver\n");
950
951 destroy_workqueue(vtgtd);
952 vio_unregister_driver(&ibmvstgt_driver);
953}
954
955MODULE_DESCRIPTION("IBM Virtual SCSI Target");
956MODULE_AUTHOR("Santiago Leon");
957MODULE_LICENSE("GPL");
958
959module_init(ibmvstgt_init);
960module_exit(ibmvstgt_exit);
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index 1427a41e8441..8f6b5bf580f6 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -110,6 +110,7 @@ typedef struct ide_scsi_obj {
110} idescsi_scsi_t; 110} idescsi_scsi_t;
111 111
112static DEFINE_MUTEX(idescsi_ref_mutex); 112static DEFINE_MUTEX(idescsi_ref_mutex);
113static int idescsi_nocd; /* Set by module param to skip cd */
113 114
114#define ide_scsi_g(disk) \ 115#define ide_scsi_g(disk) \
115 container_of((disk)->private_data, struct ide_scsi_obj, driver) 116 container_of((disk)->private_data, struct ide_scsi_obj, driver)
@@ -1127,6 +1128,9 @@ static int ide_scsi_probe(ide_drive_t *drive)
1127 warned = 1; 1128 warned = 1;
1128 } 1129 }
1129 1130
1131 if (idescsi_nocd && drive->media == ide_cdrom)
1132 return -ENODEV;
1133
1130 if (!strstr("ide-scsi", drive->driver_req) || 1134 if (!strstr("ide-scsi", drive->driver_req) ||
1131 !drive->present || 1135 !drive->present ||
1132 drive->media == ide_disk || 1136 drive->media == ide_disk ||
@@ -1187,6 +1191,8 @@ static void __exit exit_idescsi_module(void)
1187 driver_unregister(&idescsi_driver.gen_driver); 1191 driver_unregister(&idescsi_driver.gen_driver);
1188} 1192}
1189 1193
1194module_param(idescsi_nocd, int, 0600);
1195MODULE_PARM_DESC(idescsi_nocd, "Disable handling of CD-ROMs so they may be driven by ide-cd");
1190module_init(init_idescsi_module); 1196module_init(init_idescsi_module);
1191module_exit(exit_idescsi_module); 1197module_exit(exit_idescsi_module);
1192MODULE_LICENSE("GPL"); 1198MODULE_LICENSE("GPL");
diff --git a/drivers/scsi/imm.c b/drivers/scsi/imm.c
index e31f6122106f..0464c182c577 100644
--- a/drivers/scsi/imm.c
+++ b/drivers/scsi/imm.c
@@ -36,7 +36,7 @@ typedef struct {
36 int base_hi; /* Hi Base address for ECP-ISA chipset */ 36 int base_hi; /* Hi Base address for ECP-ISA chipset */
37 int mode; /* Transfer mode */ 37 int mode; /* Transfer mode */
38 struct scsi_cmnd *cur_cmd; /* Current queued command */ 38 struct scsi_cmnd *cur_cmd; /* Current queued command */
39 struct work_struct imm_tq; /* Polling interrupt stuff */ 39 struct delayed_work imm_tq; /* Polling interrupt stuff */
40 unsigned long jstart; /* Jiffies at start */ 40 unsigned long jstart; /* Jiffies at start */
41 unsigned failed:1; /* Failure flag */ 41 unsigned failed:1; /* Failure flag */
42 unsigned dp:1; /* Data phase present */ 42 unsigned dp:1; /* Data phase present */
@@ -733,9 +733,9 @@ static int imm_completion(struct scsi_cmnd *cmd)
733 * the scheduler's task queue to generate a stream of call-backs and 733 * the scheduler's task queue to generate a stream of call-backs and
734 * complete the request when the drive is ready. 734 * complete the request when the drive is ready.
735 */ 735 */
736static void imm_interrupt(void *data) 736static void imm_interrupt(struct work_struct *work)
737{ 737{
738 imm_struct *dev = (imm_struct *) data; 738 imm_struct *dev = container_of(work, imm_struct, imm_tq.work);
739 struct scsi_cmnd *cmd = dev->cur_cmd; 739 struct scsi_cmnd *cmd = dev->cur_cmd;
740 struct Scsi_Host *host = cmd->device->host; 740 struct Scsi_Host *host = cmd->device->host;
741 unsigned long flags; 741 unsigned long flags;
@@ -745,7 +745,6 @@ static void imm_interrupt(void *data)
745 return; 745 return;
746 } 746 }
747 if (imm_engine(dev, cmd)) { 747 if (imm_engine(dev, cmd)) {
748 INIT_WORK(&dev->imm_tq, imm_interrupt, (void *) dev);
749 schedule_delayed_work(&dev->imm_tq, 1); 748 schedule_delayed_work(&dev->imm_tq, 1);
750 return; 749 return;
751 } 750 }
@@ -953,8 +952,7 @@ static int imm_queuecommand(struct scsi_cmnd *cmd,
953 cmd->result = DID_ERROR << 16; /* default return code */ 952 cmd->result = DID_ERROR << 16; /* default return code */
954 cmd->SCp.phase = 0; /* bus free */ 953 cmd->SCp.phase = 0; /* bus free */
955 954
956 INIT_WORK(&dev->imm_tq, imm_interrupt, dev); 955 schedule_delayed_work(&dev->imm_tq, 0);
957 schedule_work(&dev->imm_tq);
958 956
959 imm_pb_claim(dev); 957 imm_pb_claim(dev);
960 958
@@ -1225,7 +1223,7 @@ static int __imm_attach(struct parport *pb)
1225 else 1223 else
1226 ports = 8; 1224 ports = 8;
1227 1225
1228 INIT_WORK(&dev->imm_tq, imm_interrupt, dev); 1226 INIT_DELAYED_WORK(&dev->imm_tq, imm_interrupt);
1229 1227
1230 err = -ENOMEM; 1228 err = -ENOMEM;
1231 host = scsi_host_alloc(&imm_template, sizeof(imm_struct *)); 1229 host = scsi_host_alloc(&imm_template, sizeof(imm_struct *));
diff --git a/drivers/scsi/initio.c b/drivers/scsi/initio.c
index afed293dd7b9..f160357e37a6 100644
--- a/drivers/scsi/initio.c
+++ b/drivers/scsi/initio.c
@@ -170,7 +170,7 @@ static int setup_debug = 0;
170static void i91uSCBPost(BYTE * pHcb, BYTE * pScb); 170static void i91uSCBPost(BYTE * pHcb, BYTE * pScb);
171 171
172/* PCI Devices supported by this driver */ 172/* PCI Devices supported by this driver */
173static struct pci_device_id i91u_pci_devices[] __devinitdata = { 173static struct pci_device_id i91u_pci_devices[] = {
174 { PCI_VENDOR_ID_INIT, I950_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 174 { PCI_VENDOR_ID_INIT, I950_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
175 { PCI_VENDOR_ID_INIT, I940_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 175 { PCI_VENDOR_ID_INIT, I940_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
176 { PCI_VENDOR_ID_INIT, I935_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 176 { PCI_VENDOR_ID_INIT, I935_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index 2dde821025f3..b318500785e5 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -79,7 +79,6 @@
79#include <scsi/scsi_tcq.h> 79#include <scsi/scsi_tcq.h>
80#include <scsi/scsi_eh.h> 80#include <scsi/scsi_eh.h>
81#include <scsi/scsi_cmnd.h> 81#include <scsi/scsi_cmnd.h>
82#include <scsi/scsi_transport.h>
83#include "ipr.h" 82#include "ipr.h"
84 83
85/* 84/*
@@ -98,7 +97,7 @@ static DEFINE_SPINLOCK(ipr_driver_lock);
98 97
99/* This table describes the differences between DMA controller chips */ 98/* This table describes the differences between DMA controller chips */
100static const struct ipr_chip_cfg_t ipr_chip_cfg[] = { 99static const struct ipr_chip_cfg_t ipr_chip_cfg[] = {
101 { /* Gemstone, Citrine, and Obsidian */ 100 { /* Gemstone, Citrine, Obsidian, and Obsidian-E */
102 .mailbox = 0x0042C, 101 .mailbox = 0x0042C,
103 .cache_line_size = 0x20, 102 .cache_line_size = 0x20,
104 { 103 {
@@ -135,6 +134,7 @@ static const struct ipr_chip_t ipr_chip[] = {
135 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CITRINE, &ipr_chip_cfg[0] }, 134 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CITRINE, &ipr_chip_cfg[0] },
136 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_OBSIDIAN, &ipr_chip_cfg[0] }, 135 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_OBSIDIAN, &ipr_chip_cfg[0] },
137 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN, &ipr_chip_cfg[0] }, 136 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN, &ipr_chip_cfg[0] },
137 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN_E, &ipr_chip_cfg[0] },
138 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_SNIPE, &ipr_chip_cfg[1] }, 138 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_SNIPE, &ipr_chip_cfg[1] },
139 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_SCAMP, &ipr_chip_cfg[1] } 139 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_SCAMP, &ipr_chip_cfg[1] }
140}; 140};
@@ -1249,19 +1249,23 @@ static void ipr_log_array_error(struct ipr_ioa_cfg *ioa_cfg,
1249 1249
1250/** 1250/**
1251 * ipr_log_hex_data - Log additional hex IOA error data. 1251 * ipr_log_hex_data - Log additional hex IOA error data.
1252 * @ioa_cfg: ioa config struct
1252 * @data: IOA error data 1253 * @data: IOA error data
1253 * @len: data length 1254 * @len: data length
1254 * 1255 *
1255 * Return value: 1256 * Return value:
1256 * none 1257 * none
1257 **/ 1258 **/
1258static void ipr_log_hex_data(u32 *data, int len) 1259static void ipr_log_hex_data(struct ipr_ioa_cfg *ioa_cfg, u32 *data, int len)
1259{ 1260{
1260 int i; 1261 int i;
1261 1262
1262 if (len == 0) 1263 if (len == 0)
1263 return; 1264 return;
1264 1265
1266 if (ioa_cfg->log_level <= IPR_DEFAULT_LOG_LEVEL)
1267 len = min_t(int, len, IPR_DEFAULT_MAX_ERROR_DUMP);
1268
1265 for (i = 0; i < len / 4; i += 4) { 1269 for (i = 0; i < len / 4; i += 4) {
1266 ipr_err("%08X: %08X %08X %08X %08X\n", i*4, 1270 ipr_err("%08X: %08X %08X %08X %08X\n", i*4,
1267 be32_to_cpu(data[i]), 1271 be32_to_cpu(data[i]),
@@ -1290,7 +1294,7 @@ static void ipr_log_enhanced_dual_ioa_error(struct ipr_ioa_cfg *ioa_cfg,
1290 ipr_err("%s\n", error->failure_reason); 1294 ipr_err("%s\n", error->failure_reason);
1291 ipr_err("Remote Adapter VPD:\n"); 1295 ipr_err("Remote Adapter VPD:\n");
1292 ipr_log_ext_vpd(&error->vpd); 1296 ipr_log_ext_vpd(&error->vpd);
1293 ipr_log_hex_data(error->data, 1297 ipr_log_hex_data(ioa_cfg, error->data,
1294 be32_to_cpu(hostrcb->hcam.length) - 1298 be32_to_cpu(hostrcb->hcam.length) -
1295 (offsetof(struct ipr_hostrcb_error, u) + 1299 (offsetof(struct ipr_hostrcb_error, u) +
1296 offsetof(struct ipr_hostrcb_type_17_error, data))); 1300 offsetof(struct ipr_hostrcb_type_17_error, data)));
@@ -1315,12 +1319,225 @@ static void ipr_log_dual_ioa_error(struct ipr_ioa_cfg *ioa_cfg,
1315 ipr_err("%s\n", error->failure_reason); 1319 ipr_err("%s\n", error->failure_reason);
1316 ipr_err("Remote Adapter VPD:\n"); 1320 ipr_err("Remote Adapter VPD:\n");
1317 ipr_log_vpd(&error->vpd); 1321 ipr_log_vpd(&error->vpd);
1318 ipr_log_hex_data(error->data, 1322 ipr_log_hex_data(ioa_cfg, error->data,
1319 be32_to_cpu(hostrcb->hcam.length) - 1323 be32_to_cpu(hostrcb->hcam.length) -
1320 (offsetof(struct ipr_hostrcb_error, u) + 1324 (offsetof(struct ipr_hostrcb_error, u) +
1321 offsetof(struct ipr_hostrcb_type_07_error, data))); 1325 offsetof(struct ipr_hostrcb_type_07_error, data)));
1322} 1326}
1323 1327
1328static const struct {
1329 u8 active;
1330 char *desc;
1331} path_active_desc[] = {
1332 { IPR_PATH_NO_INFO, "Path" },
1333 { IPR_PATH_ACTIVE, "Active path" },
1334 { IPR_PATH_NOT_ACTIVE, "Inactive path" }
1335};
1336
1337static const struct {
1338 u8 state;
1339 char *desc;
1340} path_state_desc[] = {
1341 { IPR_PATH_STATE_NO_INFO, "has no path state information available" },
1342 { IPR_PATH_HEALTHY, "is healthy" },
1343 { IPR_PATH_DEGRADED, "is degraded" },
1344 { IPR_PATH_FAILED, "is failed" }
1345};
1346
1347/**
1348 * ipr_log_fabric_path - Log a fabric path error
1349 * @hostrcb: hostrcb struct
1350 * @fabric: fabric descriptor
1351 *
1352 * Return value:
1353 * none
1354 **/
1355static void ipr_log_fabric_path(struct ipr_hostrcb *hostrcb,
1356 struct ipr_hostrcb_fabric_desc *fabric)
1357{
1358 int i, j;
1359 u8 path_state = fabric->path_state;
1360 u8 active = path_state & IPR_PATH_ACTIVE_MASK;
1361 u8 state = path_state & IPR_PATH_STATE_MASK;
1362
1363 for (i = 0; i < ARRAY_SIZE(path_active_desc); i++) {
1364 if (path_active_desc[i].active != active)
1365 continue;
1366
1367 for (j = 0; j < ARRAY_SIZE(path_state_desc); j++) {
1368 if (path_state_desc[j].state != state)
1369 continue;
1370
1371 if (fabric->cascaded_expander == 0xff && fabric->phy == 0xff) {
1372 ipr_hcam_err(hostrcb, "%s %s: IOA Port=%d\n",
1373 path_active_desc[i].desc, path_state_desc[j].desc,
1374 fabric->ioa_port);
1375 } else if (fabric->cascaded_expander == 0xff) {
1376 ipr_hcam_err(hostrcb, "%s %s: IOA Port=%d, Phy=%d\n",
1377 path_active_desc[i].desc, path_state_desc[j].desc,
1378 fabric->ioa_port, fabric->phy);
1379 } else if (fabric->phy == 0xff) {
1380 ipr_hcam_err(hostrcb, "%s %s: IOA Port=%d, Cascade=%d\n",
1381 path_active_desc[i].desc, path_state_desc[j].desc,
1382 fabric->ioa_port, fabric->cascaded_expander);
1383 } else {
1384 ipr_hcam_err(hostrcb, "%s %s: IOA Port=%d, Cascade=%d, Phy=%d\n",
1385 path_active_desc[i].desc, path_state_desc[j].desc,
1386 fabric->ioa_port, fabric->cascaded_expander, fabric->phy);
1387 }
1388 return;
1389 }
1390 }
1391
1392 ipr_err("Path state=%02X IOA Port=%d Cascade=%d Phy=%d\n", path_state,
1393 fabric->ioa_port, fabric->cascaded_expander, fabric->phy);
1394}
1395
1396static const struct {
1397 u8 type;
1398 char *desc;
1399} path_type_desc[] = {
1400 { IPR_PATH_CFG_IOA_PORT, "IOA port" },
1401 { IPR_PATH_CFG_EXP_PORT, "Expander port" },
1402 { IPR_PATH_CFG_DEVICE_PORT, "Device port" },
1403 { IPR_PATH_CFG_DEVICE_LUN, "Device LUN" }
1404};
1405
1406static const struct {
1407 u8 status;
1408 char *desc;
1409} path_status_desc[] = {
1410 { IPR_PATH_CFG_NO_PROB, "Functional" },
1411 { IPR_PATH_CFG_DEGRADED, "Degraded" },
1412 { IPR_PATH_CFG_FAILED, "Failed" },
1413 { IPR_PATH_CFG_SUSPECT, "Suspect" },
1414 { IPR_PATH_NOT_DETECTED, "Missing" },
1415 { IPR_PATH_INCORRECT_CONN, "Incorrectly connected" }
1416};
1417
1418static const char *link_rate[] = {
1419 "unknown",
1420 "disabled",
1421 "phy reset problem",
1422 "spinup hold",
1423 "port selector",
1424 "unknown",
1425 "unknown",
1426 "unknown",
1427 "1.5Gbps",
1428 "3.0Gbps",
1429 "unknown",
1430 "unknown",
1431 "unknown",
1432 "unknown",
1433 "unknown",
1434 "unknown"
1435};
1436
1437/**
1438 * ipr_log_path_elem - Log a fabric path element.
1439 * @hostrcb: hostrcb struct
1440 * @cfg: fabric path element struct
1441 *
1442 * Return value:
1443 * none
1444 **/
1445static void ipr_log_path_elem(struct ipr_hostrcb *hostrcb,
1446 struct ipr_hostrcb_config_element *cfg)
1447{
1448 int i, j;
1449 u8 type = cfg->type_status & IPR_PATH_CFG_TYPE_MASK;
1450 u8 status = cfg->type_status & IPR_PATH_CFG_STATUS_MASK;
1451
1452 if (type == IPR_PATH_CFG_NOT_EXIST)
1453 return;
1454
1455 for (i = 0; i < ARRAY_SIZE(path_type_desc); i++) {
1456 if (path_type_desc[i].type != type)
1457 continue;
1458
1459 for (j = 0; j < ARRAY_SIZE(path_status_desc); j++) {
1460 if (path_status_desc[j].status != status)
1461 continue;
1462
1463 if (type == IPR_PATH_CFG_IOA_PORT) {
1464 ipr_hcam_err(hostrcb, "%s %s: Phy=%d, Link rate=%s, WWN=%08X%08X\n",
1465 path_status_desc[j].desc, path_type_desc[i].desc,
1466 cfg->phy, link_rate[cfg->link_rate & IPR_PHY_LINK_RATE_MASK],
1467 be32_to_cpu(cfg->wwid[0]), be32_to_cpu(cfg->wwid[1]));
1468 } else {
1469 if (cfg->cascaded_expander == 0xff && cfg->phy == 0xff) {
1470 ipr_hcam_err(hostrcb, "%s %s: Link rate=%s, WWN=%08X%08X\n",
1471 path_status_desc[j].desc, path_type_desc[i].desc,
1472 link_rate[cfg->link_rate & IPR_PHY_LINK_RATE_MASK],
1473 be32_to_cpu(cfg->wwid[0]), be32_to_cpu(cfg->wwid[1]));
1474 } else if (cfg->cascaded_expander == 0xff) {
1475 ipr_hcam_err(hostrcb, "%s %s: Phy=%d, Link rate=%s, "
1476 "WWN=%08X%08X\n", path_status_desc[j].desc,
1477 path_type_desc[i].desc, cfg->phy,
1478 link_rate[cfg->link_rate & IPR_PHY_LINK_RATE_MASK],
1479 be32_to_cpu(cfg->wwid[0]), be32_to_cpu(cfg->wwid[1]));
1480 } else if (cfg->phy == 0xff) {
1481 ipr_hcam_err(hostrcb, "%s %s: Cascade=%d, Link rate=%s, "
1482 "WWN=%08X%08X\n", path_status_desc[j].desc,
1483 path_type_desc[i].desc, cfg->cascaded_expander,
1484 link_rate[cfg->link_rate & IPR_PHY_LINK_RATE_MASK],
1485 be32_to_cpu(cfg->wwid[0]), be32_to_cpu(cfg->wwid[1]));
1486 } else {
1487 ipr_hcam_err(hostrcb, "%s %s: Cascade=%d, Phy=%d, Link rate=%s "
1488 "WWN=%08X%08X\n", path_status_desc[j].desc,
1489 path_type_desc[i].desc, cfg->cascaded_expander, cfg->phy,
1490 link_rate[cfg->link_rate & IPR_PHY_LINK_RATE_MASK],
1491 be32_to_cpu(cfg->wwid[0]), be32_to_cpu(cfg->wwid[1]));
1492 }
1493 }
1494 return;
1495 }
1496 }
1497
1498 ipr_hcam_err(hostrcb, "Path element=%02X: Cascade=%d Phy=%d Link rate=%s "
1499 "WWN=%08X%08X\n", cfg->type_status, cfg->cascaded_expander, cfg->phy,
1500 link_rate[cfg->link_rate & IPR_PHY_LINK_RATE_MASK],
1501 be32_to_cpu(cfg->wwid[0]), be32_to_cpu(cfg->wwid[1]));
1502}
1503
1504/**
1505 * ipr_log_fabric_error - Log a fabric error.
1506 * @ioa_cfg: ioa config struct
1507 * @hostrcb: hostrcb struct
1508 *
1509 * Return value:
1510 * none
1511 **/
1512static void ipr_log_fabric_error(struct ipr_ioa_cfg *ioa_cfg,
1513 struct ipr_hostrcb *hostrcb)
1514{
1515 struct ipr_hostrcb_type_20_error *error;
1516 struct ipr_hostrcb_fabric_desc *fabric;
1517 struct ipr_hostrcb_config_element *cfg;
1518 int i, add_len;
1519
1520 error = &hostrcb->hcam.u.error.u.type_20_error;
1521 error->failure_reason[sizeof(error->failure_reason) - 1] = '\0';
1522 ipr_hcam_err(hostrcb, "%s\n", error->failure_reason);
1523
1524 add_len = be32_to_cpu(hostrcb->hcam.length) -
1525 (offsetof(struct ipr_hostrcb_error, u) +
1526 offsetof(struct ipr_hostrcb_type_20_error, desc));
1527
1528 for (i = 0, fabric = error->desc; i < error->num_entries; i++) {
1529 ipr_log_fabric_path(hostrcb, fabric);
1530 for_each_fabric_cfg(fabric, cfg)
1531 ipr_log_path_elem(hostrcb, cfg);
1532
1533 add_len -= be16_to_cpu(fabric->length);
1534 fabric = (struct ipr_hostrcb_fabric_desc *)
1535 ((unsigned long)fabric + be16_to_cpu(fabric->length));
1536 }
1537
1538 ipr_log_hex_data(ioa_cfg, (u32 *)fabric, add_len);
1539}
1540
1324/** 1541/**
1325 * ipr_log_generic_error - Log an adapter error. 1542 * ipr_log_generic_error - Log an adapter error.
1326 * @ioa_cfg: ioa config struct 1543 * @ioa_cfg: ioa config struct
@@ -1332,7 +1549,7 @@ static void ipr_log_dual_ioa_error(struct ipr_ioa_cfg *ioa_cfg,
1332static void ipr_log_generic_error(struct ipr_ioa_cfg *ioa_cfg, 1549static void ipr_log_generic_error(struct ipr_ioa_cfg *ioa_cfg,
1333 struct ipr_hostrcb *hostrcb) 1550 struct ipr_hostrcb *hostrcb)
1334{ 1551{
1335 ipr_log_hex_data(hostrcb->hcam.u.raw.data, 1552 ipr_log_hex_data(ioa_cfg, hostrcb->hcam.u.raw.data,
1336 be32_to_cpu(hostrcb->hcam.length)); 1553 be32_to_cpu(hostrcb->hcam.length));
1337} 1554}
1338 1555
@@ -1394,13 +1611,7 @@ static void ipr_handle_log_data(struct ipr_ioa_cfg *ioa_cfg,
1394 if (!ipr_error_table[error_index].log_hcam) 1611 if (!ipr_error_table[error_index].log_hcam)
1395 return; 1612 return;
1396 1613
1397 if (ipr_is_device(&hostrcb->hcam.u.error.failing_dev_res_addr)) { 1614 ipr_hcam_err(hostrcb, "%s\n", ipr_error_table[error_index].error);
1398 ipr_ra_err(ioa_cfg, hostrcb->hcam.u.error.failing_dev_res_addr,
1399 "%s\n", ipr_error_table[error_index].error);
1400 } else {
1401 dev_err(&ioa_cfg->pdev->dev, "%s\n",
1402 ipr_error_table[error_index].error);
1403 }
1404 1615
1405 /* Set indication we have logged an error */ 1616 /* Set indication we have logged an error */
1406 ioa_cfg->errors_logged++; 1617 ioa_cfg->errors_logged++;
@@ -1437,6 +1648,9 @@ static void ipr_handle_log_data(struct ipr_ioa_cfg *ioa_cfg,
1437 case IPR_HOST_RCB_OVERLAY_ID_17: 1648 case IPR_HOST_RCB_OVERLAY_ID_17:
1438 ipr_log_enhanced_dual_ioa_error(ioa_cfg, hostrcb); 1649 ipr_log_enhanced_dual_ioa_error(ioa_cfg, hostrcb);
1439 break; 1650 break;
1651 case IPR_HOST_RCB_OVERLAY_ID_20:
1652 ipr_log_fabric_error(ioa_cfg, hostrcb);
1653 break;
1440 case IPR_HOST_RCB_OVERLAY_ID_1: 1654 case IPR_HOST_RCB_OVERLAY_ID_1:
1441 case IPR_HOST_RCB_OVERLAY_ID_DEFAULT: 1655 case IPR_HOST_RCB_OVERLAY_ID_DEFAULT:
1442 default: 1656 default:
@@ -2093,7 +2307,7 @@ static void ipr_release_dump(struct kref *kref)
2093 2307
2094/** 2308/**
2095 * ipr_worker_thread - Worker thread 2309 * ipr_worker_thread - Worker thread
2096 * @data: ioa config struct 2310 * @work: ioa config struct
2097 * 2311 *
2098 * Called at task level from a work thread. This function takes care 2312 * Called at task level from a work thread. This function takes care
2099 * of adding and removing device from the mid-layer as configuration 2313 * of adding and removing device from the mid-layer as configuration
@@ -2102,13 +2316,14 @@ static void ipr_release_dump(struct kref *kref)
2102 * Return value: 2316 * Return value:
2103 * nothing 2317 * nothing
2104 **/ 2318 **/
2105static void ipr_worker_thread(void *data) 2319static void ipr_worker_thread(struct work_struct *work)
2106{ 2320{
2107 unsigned long lock_flags; 2321 unsigned long lock_flags;
2108 struct ipr_resource_entry *res; 2322 struct ipr_resource_entry *res;
2109 struct scsi_device *sdev; 2323 struct scsi_device *sdev;
2110 struct ipr_dump *dump; 2324 struct ipr_dump *dump;
2111 struct ipr_ioa_cfg *ioa_cfg = data; 2325 struct ipr_ioa_cfg *ioa_cfg =
2326 container_of(work, struct ipr_ioa_cfg, work_q);
2112 u8 bus, target, lun; 2327 u8 bus, target, lun;
2113 int did_work; 2328 int did_work;
2114 2329
@@ -2969,7 +3184,6 @@ static int ipr_alloc_dump(struct ipr_ioa_cfg *ioa_cfg)
2969 struct ipr_dump *dump; 3184 struct ipr_dump *dump;
2970 unsigned long lock_flags = 0; 3185 unsigned long lock_flags = 0;
2971 3186
2972 ENTER;
2973 dump = kzalloc(sizeof(struct ipr_dump), GFP_KERNEL); 3187 dump = kzalloc(sizeof(struct ipr_dump), GFP_KERNEL);
2974 3188
2975 if (!dump) { 3189 if (!dump) {
@@ -2996,7 +3210,6 @@ static int ipr_alloc_dump(struct ipr_ioa_cfg *ioa_cfg)
2996 } 3210 }
2997 spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); 3211 spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
2998 3212
2999 LEAVE;
3000 return 0; 3213 return 0;
3001} 3214}
3002 3215
@@ -3573,6 +3786,12 @@ static int ipr_sata_reset(struct ata_port *ap, unsigned int *classes)
3573 3786
3574 ENTER; 3787 ENTER;
3575 spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags); 3788 spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags);
3789 while(ioa_cfg->in_reset_reload) {
3790 spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
3791 wait_event(ioa_cfg->reset_wait_q, !ioa_cfg->in_reset_reload);
3792 spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags);
3793 }
3794
3576 res = sata_port->res; 3795 res = sata_port->res;
3577 if (res) { 3796 if (res) {
3578 rc = ipr_device_reset(ioa_cfg, res); 3797 rc = ipr_device_reset(ioa_cfg, res);
@@ -3636,6 +3855,10 @@ static int __ipr_eh_dev_reset(struct scsi_cmnd * scsi_cmd)
3636 if (ipr_cmd->ioarcb.res_handle == res->cfgte.res_handle) { 3855 if (ipr_cmd->ioarcb.res_handle == res->cfgte.res_handle) {
3637 if (ipr_cmd->scsi_cmd) 3856 if (ipr_cmd->scsi_cmd)
3638 ipr_cmd->done = ipr_scsi_eh_done; 3857 ipr_cmd->done = ipr_scsi_eh_done;
3858 if (ipr_cmd->qc && !(ipr_cmd->qc->flags & ATA_QCFLAG_FAILED)) {
3859 ipr_cmd->qc->err_mask |= AC_ERR_TIMEOUT;
3860 ipr_cmd->qc->flags |= ATA_QCFLAG_FAILED;
3861 }
3639 } 3862 }
3640 } 3863 }
3641 3864
@@ -3770,7 +3993,7 @@ static int ipr_cancel_op(struct scsi_cmnd * scsi_cmd)
3770 */ 3993 */
3771 if (ioa_cfg->in_reset_reload || ioa_cfg->ioa_is_dead) 3994 if (ioa_cfg->in_reset_reload || ioa_cfg->ioa_is_dead)
3772 return FAILED; 3995 return FAILED;
3773 if (!res || (!ipr_is_gscsi(res) && !ipr_is_vset_device(res))) 3996 if (!res || !ipr_is_gscsi(res))
3774 return FAILED; 3997 return FAILED;
3775 3998
3776 list_for_each_entry(ipr_cmd, &ioa_cfg->pending_q, queue) { 3999 list_for_each_entry(ipr_cmd, &ioa_cfg->pending_q, queue) {
@@ -4615,7 +4838,7 @@ static int ipr_queuecommand(struct scsi_cmnd *scsi_cmd,
4615 * Return value: 4838 * Return value:
4616 * 0 on success / other on failure 4839 * 0 on success / other on failure
4617 **/ 4840 **/
4618int ipr_ioctl(struct scsi_device *sdev, int cmd, void __user *arg) 4841static int ipr_ioctl(struct scsi_device *sdev, int cmd, void __user *arg)
4619{ 4842{
4620 struct ipr_resource_entry *res; 4843 struct ipr_resource_entry *res;
4621 4844
@@ -4648,40 +4871,6 @@ static const char * ipr_ioa_info(struct Scsi_Host *host)
4648 return buffer; 4871 return buffer;
4649} 4872}
4650 4873
4651/**
4652 * ipr_scsi_timed_out - Handle scsi command timeout
4653 * @scsi_cmd: scsi command struct
4654 *
4655 * Return value:
4656 * EH_NOT_HANDLED
4657 **/
4658enum scsi_eh_timer_return ipr_scsi_timed_out(struct scsi_cmnd *scsi_cmd)
4659{
4660 struct ipr_ioa_cfg *ioa_cfg;
4661 struct ipr_cmnd *ipr_cmd;
4662 unsigned long flags;
4663
4664 ENTER;
4665 spin_lock_irqsave(scsi_cmd->device->host->host_lock, flags);
4666 ioa_cfg = (struct ipr_ioa_cfg *)scsi_cmd->device->host->hostdata;
4667
4668 list_for_each_entry(ipr_cmd, &ioa_cfg->pending_q, queue) {
4669 if (ipr_cmd->qc && ipr_cmd->qc->scsicmd == scsi_cmd) {
4670 ipr_cmd->qc->err_mask |= AC_ERR_TIMEOUT;
4671 ipr_cmd->qc->flags |= ATA_QCFLAG_FAILED;
4672 break;
4673 }
4674 }
4675
4676 spin_unlock_irqrestore(scsi_cmd->device->host->host_lock, flags);
4677 LEAVE;
4678 return EH_NOT_HANDLED;
4679}
4680
4681static struct scsi_transport_template ipr_transport_template = {
4682 .eh_timed_out = ipr_scsi_timed_out
4683};
4684
4685static struct scsi_host_template driver_template = { 4874static struct scsi_host_template driver_template = {
4686 .module = THIS_MODULE, 4875 .module = THIS_MODULE,
4687 .name = "IPR", 4876 .name = "IPR",
@@ -4776,6 +4965,12 @@ static void ipr_ata_post_internal(struct ata_queued_cmd *qc)
4776 unsigned long flags; 4965 unsigned long flags;
4777 4966
4778 spin_lock_irqsave(ioa_cfg->host->host_lock, flags); 4967 spin_lock_irqsave(ioa_cfg->host->host_lock, flags);
4968 while(ioa_cfg->in_reset_reload) {
4969 spin_unlock_irqrestore(ioa_cfg->host->host_lock, flags);
4970 wait_event(ioa_cfg->reset_wait_q, !ioa_cfg->in_reset_reload);
4971 spin_lock_irqsave(ioa_cfg->host->host_lock, flags);
4972 }
4973
4779 list_for_each_entry(ipr_cmd, &ioa_cfg->pending_q, queue) { 4974 list_for_each_entry(ipr_cmd, &ioa_cfg->pending_q, queue) {
4780 if (ipr_cmd->qc == qc) { 4975 if (ipr_cmd->qc == qc) {
4781 ipr_device_reset(ioa_cfg, sata_port->res); 4976 ipr_device_reset(ioa_cfg, sata_port->res);
@@ -6745,7 +6940,7 @@ static int __devinit ipr_alloc_cmd_blks(struct ipr_ioa_cfg *ioa_cfg)
6745 return -ENOMEM; 6940 return -ENOMEM;
6746 6941
6747 for (i = 0; i < IPR_NUM_CMD_BLKS; i++) { 6942 for (i = 0; i < IPR_NUM_CMD_BLKS; i++) {
6748 ipr_cmd = pci_pool_alloc (ioa_cfg->ipr_cmd_pool, SLAB_KERNEL, &dma_addr); 6943 ipr_cmd = pci_pool_alloc (ioa_cfg->ipr_cmd_pool, GFP_KERNEL, &dma_addr);
6749 6944
6750 if (!ipr_cmd) { 6945 if (!ipr_cmd) {
6751 ipr_free_cmd_blks(ioa_cfg); 6946 ipr_free_cmd_blks(ioa_cfg);
@@ -6832,6 +7027,7 @@ static int __devinit ipr_alloc_mem(struct ipr_ioa_cfg *ioa_cfg)
6832 7027
6833 ioa_cfg->hostrcb[i]->hostrcb_dma = 7028 ioa_cfg->hostrcb[i]->hostrcb_dma =
6834 ioa_cfg->hostrcb_dma[i] + offsetof(struct ipr_hostrcb, hcam); 7029 ioa_cfg->hostrcb_dma[i] + offsetof(struct ipr_hostrcb, hcam);
7030 ioa_cfg->hostrcb[i]->ioa_cfg = ioa_cfg;
6835 list_add_tail(&ioa_cfg->hostrcb[i]->queue, &ioa_cfg->hostrcb_free_q); 7031 list_add_tail(&ioa_cfg->hostrcb[i]->queue, &ioa_cfg->hostrcb_free_q);
6836 } 7032 }
6837 7033
@@ -6926,7 +7122,7 @@ static void __devinit ipr_init_ioa_cfg(struct ipr_ioa_cfg *ioa_cfg,
6926 INIT_LIST_HEAD(&ioa_cfg->hostrcb_pending_q); 7122 INIT_LIST_HEAD(&ioa_cfg->hostrcb_pending_q);
6927 INIT_LIST_HEAD(&ioa_cfg->free_res_q); 7123 INIT_LIST_HEAD(&ioa_cfg->free_res_q);
6928 INIT_LIST_HEAD(&ioa_cfg->used_res_q); 7124 INIT_LIST_HEAD(&ioa_cfg->used_res_q);
6929 INIT_WORK(&ioa_cfg->work_q, ipr_worker_thread, ioa_cfg); 7125 INIT_WORK(&ioa_cfg->work_q, ipr_worker_thread);
6930 init_waitqueue_head(&ioa_cfg->reset_wait_q); 7126 init_waitqueue_head(&ioa_cfg->reset_wait_q);
6931 ioa_cfg->sdt_state = INACTIVE; 7127 ioa_cfg->sdt_state = INACTIVE;
6932 if (ipr_enable_cache) 7128 if (ipr_enable_cache)
@@ -7017,7 +7213,6 @@ static int __devinit ipr_probe_ioa(struct pci_dev *pdev,
7017 7213
7018 ioa_cfg = (struct ipr_ioa_cfg *)host->hostdata; 7214 ioa_cfg = (struct ipr_ioa_cfg *)host->hostdata;
7019 memset(ioa_cfg, 0, sizeof(struct ipr_ioa_cfg)); 7215 memset(ioa_cfg, 0, sizeof(struct ipr_ioa_cfg));
7020 host->transportt = &ipr_transport_template;
7021 ata_host_init(&ioa_cfg->ata_host, &pdev->dev, 7216 ata_host_init(&ioa_cfg->ata_host, &pdev->dev,
7022 sata_port_info.flags, &ipr_sata_ops); 7217 sata_port_info.flags, &ipr_sata_ops);
7023 7218
@@ -7351,12 +7546,24 @@ static struct pci_device_id ipr_pci_table[] __devinitdata = {
7351 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_OBSIDIAN, 7546 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_OBSIDIAN,
7352 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572B, 7547 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572B,
7353 0, 0, (kernel_ulong_t)&ipr_chip_cfg[0] }, 7548 0, 0, (kernel_ulong_t)&ipr_chip_cfg[0] },
7549 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_OBSIDIAN,
7550 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_575C,
7551 0, 0, (kernel_ulong_t)&ipr_chip_cfg[0] },
7354 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN, 7552 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN,
7355 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572A, 7553 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572A,
7356 0, 0, (kernel_ulong_t)&ipr_chip_cfg[0] }, 7554 0, 0, (kernel_ulong_t)&ipr_chip_cfg[0] },
7357 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN, 7555 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN,
7358 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572B, 7556 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572B,
7359 0, 0, (kernel_ulong_t)&ipr_chip_cfg[0] }, 7557 0, 0, (kernel_ulong_t)&ipr_chip_cfg[0] },
7558 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN,
7559 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_575C,
7560 0, 0, (kernel_ulong_t)&ipr_chip_cfg[0] },
7561 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN,
7562 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_57B8,
7563 0, 0, (kernel_ulong_t)&ipr_chip_cfg[0] },
7564 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN_E,
7565 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_57B7,
7566 0, 0, (kernel_ulong_t)&ipr_chip_cfg[0] },
7360 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_SNIPE, 7567 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_SNIPE,
7361 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_2780, 7568 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_2780,
7362 0, 0, (kernel_ulong_t)&ipr_chip_cfg[1] }, 7569 0, 0, (kernel_ulong_t)&ipr_chip_cfg[1] },
@@ -7366,6 +7573,9 @@ static struct pci_device_id ipr_pci_table[] __devinitdata = {
7366 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_SCAMP, 7573 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_SCAMP,
7367 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_571F, 7574 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_571F,
7368 0, 0, (kernel_ulong_t)&ipr_chip_cfg[1] }, 7575 0, 0, (kernel_ulong_t)&ipr_chip_cfg[1] },
7576 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_SCAMP,
7577 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572F,
7578 0, 0, (kernel_ulong_t)&ipr_chip_cfg[1] },
7369 { } 7579 { }
7370}; 7580};
7371MODULE_DEVICE_TABLE(pci, ipr_pci_table); 7581MODULE_DEVICE_TABLE(pci, ipr_pci_table);
diff --git a/drivers/scsi/ipr.h b/drivers/scsi/ipr.h
index 6d035283af08..9f62a1d4d511 100644
--- a/drivers/scsi/ipr.h
+++ b/drivers/scsi/ipr.h
@@ -37,8 +37,8 @@
37/* 37/*
38 * Literals 38 * Literals
39 */ 39 */
40#define IPR_DRIVER_VERSION "2.2.0" 40#define IPR_DRIVER_VERSION "2.3.0"
41#define IPR_DRIVER_DATE "(September 25, 2006)" 41#define IPR_DRIVER_DATE "(November 8, 2006)"
42 42
43/* 43/*
44 * IPR_MAX_CMD_PER_LUN: This defines the maximum number of outstanding 44 * IPR_MAX_CMD_PER_LUN: This defines the maximum number of outstanding
@@ -54,6 +54,8 @@
54 */ 54 */
55#define IPR_NUM_BASE_CMD_BLKS 100 55#define IPR_NUM_BASE_CMD_BLKS 100
56 56
57#define PCI_DEVICE_ID_IBM_OBSIDIAN_E 0x0339
58
57#define IPR_SUBS_DEV_ID_2780 0x0264 59#define IPR_SUBS_DEV_ID_2780 0x0264
58#define IPR_SUBS_DEV_ID_5702 0x0266 60#define IPR_SUBS_DEV_ID_5702 0x0266
59#define IPR_SUBS_DEV_ID_5703 0x0278 61#define IPR_SUBS_DEV_ID_5703 0x0278
@@ -66,7 +68,11 @@
66#define IPR_SUBS_DEV_ID_571F 0x02D5 68#define IPR_SUBS_DEV_ID_571F 0x02D5
67#define IPR_SUBS_DEV_ID_572A 0x02C1 69#define IPR_SUBS_DEV_ID_572A 0x02C1
68#define IPR_SUBS_DEV_ID_572B 0x02C2 70#define IPR_SUBS_DEV_ID_572B 0x02C2
71#define IPR_SUBS_DEV_ID_572F 0x02C3
69#define IPR_SUBS_DEV_ID_575B 0x030D 72#define IPR_SUBS_DEV_ID_575B 0x030D
73#define IPR_SUBS_DEV_ID_575C 0x0338
74#define IPR_SUBS_DEV_ID_57B7 0x0360
75#define IPR_SUBS_DEV_ID_57B8 0x02C2
70 76
71#define IPR_NAME "ipr" 77#define IPR_NAME "ipr"
72 78
@@ -98,6 +104,7 @@
98#define IPR_IOASC_IOA_WAS_RESET 0x10000001 104#define IPR_IOASC_IOA_WAS_RESET 0x10000001
99#define IPR_IOASC_PCI_ACCESS_ERROR 0x10000002 105#define IPR_IOASC_PCI_ACCESS_ERROR 0x10000002
100 106
107#define IPR_DEFAULT_MAX_ERROR_DUMP 984
101#define IPR_NUM_LOG_HCAMS 2 108#define IPR_NUM_LOG_HCAMS 2
102#define IPR_NUM_CFG_CHG_HCAMS 2 109#define IPR_NUM_CFG_CHG_HCAMS 2
103#define IPR_NUM_HCAMS (IPR_NUM_LOG_HCAMS + IPR_NUM_CFG_CHG_HCAMS) 110#define IPR_NUM_HCAMS (IPR_NUM_LOG_HCAMS + IPR_NUM_CFG_CHG_HCAMS)
@@ -731,6 +738,64 @@ struct ipr_hostrcb_type_17_error {
731 u32 data[476]; 738 u32 data[476];
732}__attribute__((packed, aligned (4))); 739}__attribute__((packed, aligned (4)));
733 740
741struct ipr_hostrcb_config_element {
742 u8 type_status;
743#define IPR_PATH_CFG_TYPE_MASK 0xF0
744#define IPR_PATH_CFG_NOT_EXIST 0x00
745#define IPR_PATH_CFG_IOA_PORT 0x10
746#define IPR_PATH_CFG_EXP_PORT 0x20
747#define IPR_PATH_CFG_DEVICE_PORT 0x30
748#define IPR_PATH_CFG_DEVICE_LUN 0x40
749
750#define IPR_PATH_CFG_STATUS_MASK 0x0F
751#define IPR_PATH_CFG_NO_PROB 0x00
752#define IPR_PATH_CFG_DEGRADED 0x01
753#define IPR_PATH_CFG_FAILED 0x02
754#define IPR_PATH_CFG_SUSPECT 0x03
755#define IPR_PATH_NOT_DETECTED 0x04
756#define IPR_PATH_INCORRECT_CONN 0x05
757
758 u8 cascaded_expander;
759 u8 phy;
760 u8 link_rate;
761#define IPR_PHY_LINK_RATE_MASK 0x0F
762
763 __be32 wwid[2];
764}__attribute__((packed, aligned (4)));
765
766struct ipr_hostrcb_fabric_desc {
767 __be16 length;
768 u8 ioa_port;
769 u8 cascaded_expander;
770 u8 phy;
771 u8 path_state;
772#define IPR_PATH_ACTIVE_MASK 0xC0
773#define IPR_PATH_NO_INFO 0x00
774#define IPR_PATH_ACTIVE 0x40
775#define IPR_PATH_NOT_ACTIVE 0x80
776
777#define IPR_PATH_STATE_MASK 0x0F
778#define IPR_PATH_STATE_NO_INFO 0x00
779#define IPR_PATH_HEALTHY 0x01
780#define IPR_PATH_DEGRADED 0x02
781#define IPR_PATH_FAILED 0x03
782
783 __be16 num_entries;
784 struct ipr_hostrcb_config_element elem[1];
785}__attribute__((packed, aligned (4)));
786
787#define for_each_fabric_cfg(fabric, cfg) \
788 for (cfg = (fabric)->elem; \
789 cfg < ((fabric)->elem + be16_to_cpu((fabric)->num_entries)); \
790 cfg++)
791
792struct ipr_hostrcb_type_20_error {
793 u8 failure_reason[64];
794 u8 reserved[3];
795 u8 num_entries;
796 struct ipr_hostrcb_fabric_desc desc[1];
797}__attribute__((packed, aligned (4)));
798
734struct ipr_hostrcb_error { 799struct ipr_hostrcb_error {
735 __be32 failing_dev_ioasc; 800 __be32 failing_dev_ioasc;
736 struct ipr_res_addr failing_dev_res_addr; 801 struct ipr_res_addr failing_dev_res_addr;
@@ -747,6 +812,7 @@ struct ipr_hostrcb_error {
747 struct ipr_hostrcb_type_13_error type_13_error; 812 struct ipr_hostrcb_type_13_error type_13_error;
748 struct ipr_hostrcb_type_14_error type_14_error; 813 struct ipr_hostrcb_type_14_error type_14_error;
749 struct ipr_hostrcb_type_17_error type_17_error; 814 struct ipr_hostrcb_type_17_error type_17_error;
815 struct ipr_hostrcb_type_20_error type_20_error;
750 } u; 816 } u;
751}__attribute__((packed, aligned (4))); 817}__attribute__((packed, aligned (4)));
752 818
@@ -786,6 +852,7 @@ struct ipr_hcam {
786#define IPR_HOST_RCB_OVERLAY_ID_14 0x14 852#define IPR_HOST_RCB_OVERLAY_ID_14 0x14
787#define IPR_HOST_RCB_OVERLAY_ID_16 0x16 853#define IPR_HOST_RCB_OVERLAY_ID_16 0x16
788#define IPR_HOST_RCB_OVERLAY_ID_17 0x17 854#define IPR_HOST_RCB_OVERLAY_ID_17 0x17
855#define IPR_HOST_RCB_OVERLAY_ID_20 0x20
789#define IPR_HOST_RCB_OVERLAY_ID_DEFAULT 0xFF 856#define IPR_HOST_RCB_OVERLAY_ID_DEFAULT 0xFF
790 857
791 u8 reserved1[3]; 858 u8 reserved1[3];
@@ -805,6 +872,7 @@ struct ipr_hostrcb {
805 struct ipr_hcam hcam; 872 struct ipr_hcam hcam;
806 dma_addr_t hostrcb_dma; 873 dma_addr_t hostrcb_dma;
807 struct list_head queue; 874 struct list_head queue;
875 struct ipr_ioa_cfg *ioa_cfg;
808}; 876};
809 877
810/* IPR smart dump table structures */ 878/* IPR smart dump table structures */
@@ -1283,6 +1351,17 @@ struct ipr_ucode_image_header {
1283 } \ 1351 } \
1284} 1352}
1285 1353
1354#define ipr_hcam_err(hostrcb, fmt, ...) \
1355{ \
1356 if (ipr_is_device(&(hostrcb)->hcam.u.error.failing_dev_res_addr)) { \
1357 ipr_ra_err((hostrcb)->ioa_cfg, \
1358 (hostrcb)->hcam.u.error.failing_dev_res_addr, \
1359 fmt, ##__VA_ARGS__); \
1360 } else { \
1361 dev_err(&(hostrcb)->ioa_cfg->pdev->dev, fmt, ##__VA_ARGS__); \
1362 } \
1363}
1364
1286#define ipr_trace ipr_dbg("%s: %s: Line: %d\n",\ 1365#define ipr_trace ipr_dbg("%s: %s: Line: %d\n",\
1287 __FILE__, __FUNCTION__, __LINE__) 1366 __FILE__, __FUNCTION__, __LINE__)
1288 1367
diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c
index f06a06ae6092..8b704f73055a 100644
--- a/drivers/scsi/ips.c
+++ b/drivers/scsi/ips.c
@@ -5001,7 +5001,7 @@ ips_init_copperhead(ips_ha_t * ha)
5001 break; 5001 break;
5002 5002
5003 /* Delay for 1 Second */ 5003 /* Delay for 1 Second */
5004 msleep(IPS_ONE_SEC); 5004 MDELAY(IPS_ONE_SEC);
5005 } 5005 }
5006 5006
5007 if (j >= 45) 5007 if (j >= 45)
@@ -5027,7 +5027,7 @@ ips_init_copperhead(ips_ha_t * ha)
5027 break; 5027 break;
5028 5028
5029 /* Delay for 1 Second */ 5029 /* Delay for 1 Second */
5030 msleep(IPS_ONE_SEC); 5030 MDELAY(IPS_ONE_SEC);
5031 } 5031 }
5032 5032
5033 if (j >= 240) 5033 if (j >= 240)
@@ -5045,7 +5045,7 @@ ips_init_copperhead(ips_ha_t * ha)
5045 break; 5045 break;
5046 5046
5047 /* Delay for 1 Second */ 5047 /* Delay for 1 Second */
5048 msleep(IPS_ONE_SEC); 5048 MDELAY(IPS_ONE_SEC);
5049 } 5049 }
5050 5050
5051 if (i >= 240) 5051 if (i >= 240)
@@ -5095,7 +5095,7 @@ ips_init_copperhead_memio(ips_ha_t * ha)
5095 break; 5095 break;
5096 5096
5097 /* Delay for 1 Second */ 5097 /* Delay for 1 Second */
5098 msleep(IPS_ONE_SEC); 5098 MDELAY(IPS_ONE_SEC);
5099 } 5099 }
5100 5100
5101 if (j >= 45) 5101 if (j >= 45)
@@ -5121,7 +5121,7 @@ ips_init_copperhead_memio(ips_ha_t * ha)
5121 break; 5121 break;
5122 5122
5123 /* Delay for 1 Second */ 5123 /* Delay for 1 Second */
5124 msleep(IPS_ONE_SEC); 5124 MDELAY(IPS_ONE_SEC);
5125 } 5125 }
5126 5126
5127 if (j >= 240) 5127 if (j >= 240)
@@ -5139,7 +5139,7 @@ ips_init_copperhead_memio(ips_ha_t * ha)
5139 break; 5139 break;
5140 5140
5141 /* Delay for 1 Second */ 5141 /* Delay for 1 Second */
5142 msleep(IPS_ONE_SEC); 5142 MDELAY(IPS_ONE_SEC);
5143 } 5143 }
5144 5144
5145 if (i >= 240) 5145 if (i >= 240)
@@ -5191,7 +5191,7 @@ ips_init_morpheus(ips_ha_t * ha)
5191 break; 5191 break;
5192 5192
5193 /* Delay for 1 Second */ 5193 /* Delay for 1 Second */
5194 msleep(IPS_ONE_SEC); 5194 MDELAY(IPS_ONE_SEC);
5195 } 5195 }
5196 5196
5197 if (i >= 45) { 5197 if (i >= 45) {
@@ -5217,7 +5217,7 @@ ips_init_morpheus(ips_ha_t * ha)
5217 if (Post != 0x4F00) 5217 if (Post != 0x4F00)
5218 break; 5218 break;
5219 /* Delay for 1 Second */ 5219 /* Delay for 1 Second */
5220 msleep(IPS_ONE_SEC); 5220 MDELAY(IPS_ONE_SEC);
5221 } 5221 }
5222 5222
5223 if (i >= 120) { 5223 if (i >= 120) {
@@ -5247,7 +5247,7 @@ ips_init_morpheus(ips_ha_t * ha)
5247 break; 5247 break;
5248 5248
5249 /* Delay for 1 Second */ 5249 /* Delay for 1 Second */
5250 msleep(IPS_ONE_SEC); 5250 MDELAY(IPS_ONE_SEC);
5251 } 5251 }
5252 5252
5253 if (i >= 240) { 5253 if (i >= 240) {
@@ -5307,12 +5307,12 @@ ips_reset_copperhead(ips_ha_t * ha)
5307 outb(IPS_BIT_RST, ha->io_addr + IPS_REG_SCPR); 5307 outb(IPS_BIT_RST, ha->io_addr + IPS_REG_SCPR);
5308 5308
5309 /* Delay for 1 Second */ 5309 /* Delay for 1 Second */
5310 msleep(IPS_ONE_SEC); 5310 MDELAY(IPS_ONE_SEC);
5311 5311
5312 outb(0, ha->io_addr + IPS_REG_SCPR); 5312 outb(0, ha->io_addr + IPS_REG_SCPR);
5313 5313
5314 /* Delay for 1 Second */ 5314 /* Delay for 1 Second */
5315 msleep(IPS_ONE_SEC); 5315 MDELAY(IPS_ONE_SEC);
5316 5316
5317 if ((*ha->func.init) (ha)) 5317 if ((*ha->func.init) (ha))
5318 break; 5318 break;
@@ -5352,12 +5352,12 @@ ips_reset_copperhead_memio(ips_ha_t * ha)
5352 writeb(IPS_BIT_RST, ha->mem_ptr + IPS_REG_SCPR); 5352 writeb(IPS_BIT_RST, ha->mem_ptr + IPS_REG_SCPR);
5353 5353
5354 /* Delay for 1 Second */ 5354 /* Delay for 1 Second */
5355 msleep(IPS_ONE_SEC); 5355 MDELAY(IPS_ONE_SEC);
5356 5356
5357 writeb(0, ha->mem_ptr + IPS_REG_SCPR); 5357 writeb(0, ha->mem_ptr + IPS_REG_SCPR);
5358 5358
5359 /* Delay for 1 Second */ 5359 /* Delay for 1 Second */
5360 msleep(IPS_ONE_SEC); 5360 MDELAY(IPS_ONE_SEC);
5361 5361
5362 if ((*ha->func.init) (ha)) 5362 if ((*ha->func.init) (ha))
5363 break; 5363 break;
@@ -5398,7 +5398,7 @@ ips_reset_morpheus(ips_ha_t * ha)
5398 writel(0x80000000, ha->mem_ptr + IPS_REG_I960_IDR); 5398 writel(0x80000000, ha->mem_ptr + IPS_REG_I960_IDR);
5399 5399
5400 /* Delay for 5 Seconds */ 5400 /* Delay for 5 Seconds */
5401 msleep(5 * IPS_ONE_SEC); 5401 MDELAY(5 * IPS_ONE_SEC);
5402 5402
5403 /* Do a PCI config read to wait for adapter */ 5403 /* Do a PCI config read to wait for adapter */
5404 pci_read_config_byte(ha->pcidev, 4, &junk); 5404 pci_read_config_byte(ha->pcidev, 4, &junk);
diff --git a/drivers/scsi/ips.h b/drivers/scsi/ips.h
index 34680f3dd452..b726dcc424b1 100644
--- a/drivers/scsi/ips.h
+++ b/drivers/scsi/ips.h
@@ -51,6 +51,7 @@
51 #define _IPS_H_ 51 #define _IPS_H_
52 52
53#include <linux/version.h> 53#include <linux/version.h>
54#include <linux/nmi.h>
54 #include <asm/uaccess.h> 55 #include <asm/uaccess.h>
55 #include <asm/io.h> 56 #include <asm/io.h>
56 57
@@ -116,9 +117,11 @@
116 dev_printk(level , &((pcidev)->dev) , format , ## arg) 117 dev_printk(level , &((pcidev)->dev) , format , ## arg)
117 #endif 118 #endif
118 119
119 #ifndef MDELAY 120 #define MDELAY(n) \
120 #define MDELAY mdelay 121 do { \
121 #endif 122 mdelay(n); \
123 touch_nmi_watchdog(); \
124 } while (0)
122 125
123 #ifndef min 126 #ifndef min
124 #define min(x,y) ((x) < (y) ? x : y) 127 #define min(x,y) ((x) < (y) ? x : y)
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index 0a9dbc59663f..d0b139cccbbc 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -415,8 +415,8 @@ iscsi_r2t_rsp(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
415 iscsi_solicit_data_init(conn, ctask, r2t); 415 iscsi_solicit_data_init(conn, ctask, r2t);
416 416
417 tcp_ctask->exp_r2tsn = r2tsn + 1; 417 tcp_ctask->exp_r2tsn = r2tsn + 1;
418 tcp_ctask->xmstate |= XMSTATE_SOL_HDR;
419 __kfifo_put(tcp_ctask->r2tqueue, (void*)&r2t, sizeof(void*)); 418 __kfifo_put(tcp_ctask->r2tqueue, (void*)&r2t, sizeof(void*));
419 tcp_ctask->xmstate |= XMSTATE_SOL_HDR;
420 list_move_tail(&ctask->running, &conn->xmitqueue); 420 list_move_tail(&ctask->running, &conn->xmitqueue);
421 421
422 scsi_queue_work(session->host, &conn->xmitwork); 422 scsi_queue_work(session->host, &conn->xmitwork);
@@ -1627,9 +1627,12 @@ static int iscsi_send_sol_pdu(struct iscsi_conn *conn,
1627 if (tcp_ctask->xmstate & XMSTATE_SOL_HDR) { 1627 if (tcp_ctask->xmstate & XMSTATE_SOL_HDR) {
1628 tcp_ctask->xmstate &= ~XMSTATE_SOL_HDR; 1628 tcp_ctask->xmstate &= ~XMSTATE_SOL_HDR;
1629 tcp_ctask->xmstate |= XMSTATE_SOL_DATA; 1629 tcp_ctask->xmstate |= XMSTATE_SOL_DATA;
1630 if (!tcp_ctask->r2t) 1630 if (!tcp_ctask->r2t) {
1631 spin_lock_bh(&session->lock);
1631 __kfifo_get(tcp_ctask->r2tqueue, (void*)&tcp_ctask->r2t, 1632 __kfifo_get(tcp_ctask->r2tqueue, (void*)&tcp_ctask->r2t,
1632 sizeof(void*)); 1633 sizeof(void*));
1634 spin_unlock_bh(&session->lock);
1635 }
1633send_hdr: 1636send_hdr:
1634 r2t = tcp_ctask->r2t; 1637 r2t = tcp_ctask->r2t;
1635 dtask = &r2t->dtask; 1638 dtask = &r2t->dtask;
@@ -1816,21 +1819,14 @@ iscsi_tcp_conn_destroy(struct iscsi_cls_conn *cls_conn)
1816{ 1819{
1817 struct iscsi_conn *conn = cls_conn->dd_data; 1820 struct iscsi_conn *conn = cls_conn->dd_data;
1818 struct iscsi_tcp_conn *tcp_conn = conn->dd_data; 1821 struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
1819 int digest = 0;
1820
1821 if (conn->hdrdgst_en || conn->datadgst_en)
1822 digest = 1;
1823 1822
1824 iscsi_tcp_release_conn(conn); 1823 iscsi_tcp_release_conn(conn);
1825 iscsi_conn_teardown(cls_conn); 1824 iscsi_conn_teardown(cls_conn);
1826 1825
1827 /* now free tcp_conn */ 1826 if (tcp_conn->tx_hash.tfm)
1828 if (digest) { 1827 crypto_free_hash(tcp_conn->tx_hash.tfm);
1829 if (tcp_conn->tx_hash.tfm) 1828 if (tcp_conn->rx_hash.tfm)
1830 crypto_free_hash(tcp_conn->tx_hash.tfm); 1829 crypto_free_hash(tcp_conn->rx_hash.tfm);
1831 if (tcp_conn->rx_hash.tfm)
1832 crypto_free_hash(tcp_conn->rx_hash.tfm);
1833 }
1834 1830
1835 kfree(tcp_conn); 1831 kfree(tcp_conn);
1836} 1832}
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 2865ebd557ef..e11b23c641e2 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -719,9 +719,10 @@ again:
719 return rc; 719 return rc;
720} 720}
721 721
722static void iscsi_xmitworker(void *data) 722static void iscsi_xmitworker(struct work_struct *work)
723{ 723{
724 struct iscsi_conn *conn = data; 724 struct iscsi_conn *conn =
725 container_of(work, struct iscsi_conn, xmitwork);
725 int rc; 726 int rc;
726 /* 727 /*
727 * serialize Xmit worker on a per-connection basis. 728 * serialize Xmit worker on a per-connection basis.
@@ -975,13 +976,13 @@ int iscsi_eh_host_reset(struct scsi_cmnd *sc)
975 if (session->state == ISCSI_STATE_TERMINATE) { 976 if (session->state == ISCSI_STATE_TERMINATE) {
976failed: 977failed:
977 debug_scsi("failing host reset: session terminated " 978 debug_scsi("failing host reset: session terminated "
978 "[CID %d age %d]", conn->id, session->age); 979 "[CID %d age %d]\n", conn->id, session->age);
979 spin_unlock_bh(&session->lock); 980 spin_unlock_bh(&session->lock);
980 return FAILED; 981 return FAILED;
981 } 982 }
982 983
983 if (sc->SCp.phase == session->age) { 984 if (sc->SCp.phase == session->age) {
984 debug_scsi("failing connection CID %d due to SCSI host reset", 985 debug_scsi("failing connection CID %d due to SCSI host reset\n",
985 conn->id); 986 conn->id);
986 fail_session = 1; 987 fail_session = 1;
987 } 988 }
@@ -1054,7 +1055,8 @@ static int iscsi_exec_abort_task(struct scsi_cmnd *sc,
1054 NULL, 0); 1055 NULL, 0);
1055 if (rc) { 1056 if (rc) {
1056 iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED); 1057 iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
1057 debug_scsi("abort sent failure [itt 0x%x] %d", ctask->itt, rc); 1058 debug_scsi("abort sent failure [itt 0x%x] %d\n", ctask->itt,
1059 rc);
1058 return rc; 1060 return rc;
1059 } 1061 }
1060 1062
@@ -1071,7 +1073,7 @@ static int iscsi_exec_abort_task(struct scsi_cmnd *sc,
1071 conn->tmabort_timer.function = iscsi_tmabort_timedout; 1073 conn->tmabort_timer.function = iscsi_tmabort_timedout;
1072 conn->tmabort_timer.data = (unsigned long)ctask; 1074 conn->tmabort_timer.data = (unsigned long)ctask;
1073 add_timer(&conn->tmabort_timer); 1075 add_timer(&conn->tmabort_timer);
1074 debug_scsi("abort set timeout [itt 0x%x]", ctask->itt); 1076 debug_scsi("abort set timeout [itt 0x%x]\n", ctask->itt);
1075 } 1077 }
1076 spin_unlock_bh(&session->lock); 1078 spin_unlock_bh(&session->lock);
1077 mutex_unlock(&conn->xmitmutex); 1079 mutex_unlock(&conn->xmitmutex);
@@ -1511,7 +1513,7 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, uint32_t conn_idx)
1511 if (conn->mgmtqueue == ERR_PTR(-ENOMEM)) 1513 if (conn->mgmtqueue == ERR_PTR(-ENOMEM))
1512 goto mgmtqueue_alloc_fail; 1514 goto mgmtqueue_alloc_fail;
1513 1515
1514 INIT_WORK(&conn->xmitwork, iscsi_xmitworker, conn); 1516 INIT_WORK(&conn->xmitwork, iscsi_xmitworker);
1515 1517
1516 /* allocate login_mtask used for the login/text sequences */ 1518 /* allocate login_mtask used for the login/text sequences */
1517 spin_lock_bh(&session->lock); 1519 spin_lock_bh(&session->lock);
diff --git a/drivers/scsi/libsas/sas_discover.c b/drivers/scsi/libsas/sas_discover.c
index d977bd492d8d..fb7df7b75811 100644
--- a/drivers/scsi/libsas/sas_discover.c
+++ b/drivers/scsi/libsas/sas_discover.c
@@ -647,10 +647,12 @@ void sas_unregister_domain_devices(struct asd_sas_port *port)
647 * Discover process only interrogates devices in order to discover the 647 * Discover process only interrogates devices in order to discover the
648 * domain. 648 * domain.
649 */ 649 */
650static void sas_discover_domain(void *data) 650static void sas_discover_domain(struct work_struct *work)
651{ 651{
652 int error = 0; 652 int error = 0;
653 struct asd_sas_port *port = data; 653 struct sas_discovery_event *ev =
654 container_of(work, struct sas_discovery_event, work);
655 struct asd_sas_port *port = ev->port;
654 656
655 sas_begin_event(DISCE_DISCOVER_DOMAIN, &port->disc.disc_event_lock, 657 sas_begin_event(DISCE_DISCOVER_DOMAIN, &port->disc.disc_event_lock,
656 &port->disc.pending); 658 &port->disc.pending);
@@ -692,10 +694,12 @@ static void sas_discover_domain(void *data)
692 current->pid, error); 694 current->pid, error);
693} 695}
694 696
695static void sas_revalidate_domain(void *data) 697static void sas_revalidate_domain(struct work_struct *work)
696{ 698{
697 int res = 0; 699 int res = 0;
698 struct asd_sas_port *port = data; 700 struct sas_discovery_event *ev =
701 container_of(work, struct sas_discovery_event, work);
702 struct asd_sas_port *port = ev->port;
699 703
700 sas_begin_event(DISCE_REVALIDATE_DOMAIN, &port->disc.disc_event_lock, 704 sas_begin_event(DISCE_REVALIDATE_DOMAIN, &port->disc.disc_event_lock,
701 &port->disc.pending); 705 &port->disc.pending);
@@ -722,7 +726,7 @@ int sas_discover_event(struct asd_sas_port *port, enum discover_event ev)
722 BUG_ON(ev >= DISC_NUM_EVENTS); 726 BUG_ON(ev >= DISC_NUM_EVENTS);
723 727
724 sas_queue_event(ev, &disc->disc_event_lock, &disc->pending, 728 sas_queue_event(ev, &disc->disc_event_lock, &disc->pending,
725 &disc->disc_work[ev], port->ha->core.shost); 729 &disc->disc_work[ev].work, port->ha->core.shost);
726 730
727 return 0; 731 return 0;
728} 732}
@@ -737,13 +741,15 @@ void sas_init_disc(struct sas_discovery *disc, struct asd_sas_port *port)
737{ 741{
738 int i; 742 int i;
739 743
740 static void (*sas_event_fns[DISC_NUM_EVENTS])(void *) = { 744 static const work_func_t sas_event_fns[DISC_NUM_EVENTS] = {
741 [DISCE_DISCOVER_DOMAIN] = sas_discover_domain, 745 [DISCE_DISCOVER_DOMAIN] = sas_discover_domain,
742 [DISCE_REVALIDATE_DOMAIN] = sas_revalidate_domain, 746 [DISCE_REVALIDATE_DOMAIN] = sas_revalidate_domain,
743 }; 747 };
744 748
745 spin_lock_init(&disc->disc_event_lock); 749 spin_lock_init(&disc->disc_event_lock);
746 disc->pending = 0; 750 disc->pending = 0;
747 for (i = 0; i < DISC_NUM_EVENTS; i++) 751 for (i = 0; i < DISC_NUM_EVENTS; i++) {
748 INIT_WORK(&disc->disc_work[i], sas_event_fns[i], port); 752 INIT_WORK(&disc->disc_work[i].work, sas_event_fns[i]);
753 disc->disc_work[i].port = port;
754 }
749} 755}
diff --git a/drivers/scsi/libsas/sas_event.c b/drivers/scsi/libsas/sas_event.c
index 19110ed1c89c..d83392ee6823 100644
--- a/drivers/scsi/libsas/sas_event.c
+++ b/drivers/scsi/libsas/sas_event.c
@@ -31,7 +31,7 @@ static void notify_ha_event(struct sas_ha_struct *sas_ha, enum ha_event event)
31 BUG_ON(event >= HA_NUM_EVENTS); 31 BUG_ON(event >= HA_NUM_EVENTS);
32 32
33 sas_queue_event(event, &sas_ha->event_lock, &sas_ha->pending, 33 sas_queue_event(event, &sas_ha->event_lock, &sas_ha->pending,
34 &sas_ha->ha_events[event], sas_ha->core.shost); 34 &sas_ha->ha_events[event].work, sas_ha->core.shost);
35} 35}
36 36
37static void notify_port_event(struct asd_sas_phy *phy, enum port_event event) 37static void notify_port_event(struct asd_sas_phy *phy, enum port_event event)
@@ -41,7 +41,7 @@ static void notify_port_event(struct asd_sas_phy *phy, enum port_event event)
41 BUG_ON(event >= PORT_NUM_EVENTS); 41 BUG_ON(event >= PORT_NUM_EVENTS);
42 42
43 sas_queue_event(event, &ha->event_lock, &phy->port_events_pending, 43 sas_queue_event(event, &ha->event_lock, &phy->port_events_pending,
44 &phy->port_events[event], ha->core.shost); 44 &phy->port_events[event].work, ha->core.shost);
45} 45}
46 46
47static void notify_phy_event(struct asd_sas_phy *phy, enum phy_event event) 47static void notify_phy_event(struct asd_sas_phy *phy, enum phy_event event)
@@ -51,12 +51,12 @@ static void notify_phy_event(struct asd_sas_phy *phy, enum phy_event event)
51 BUG_ON(event >= PHY_NUM_EVENTS); 51 BUG_ON(event >= PHY_NUM_EVENTS);
52 52
53 sas_queue_event(event, &ha->event_lock, &phy->phy_events_pending, 53 sas_queue_event(event, &ha->event_lock, &phy->phy_events_pending,
54 &phy->phy_events[event], ha->core.shost); 54 &phy->phy_events[event].work, ha->core.shost);
55} 55}
56 56
57int sas_init_events(struct sas_ha_struct *sas_ha) 57int sas_init_events(struct sas_ha_struct *sas_ha)
58{ 58{
59 static void (*sas_ha_event_fns[HA_NUM_EVENTS])(void *) = { 59 static const work_func_t sas_ha_event_fns[HA_NUM_EVENTS] = {
60 [HAE_RESET] = sas_hae_reset, 60 [HAE_RESET] = sas_hae_reset,
61 }; 61 };
62 62
@@ -64,8 +64,10 @@ int sas_init_events(struct sas_ha_struct *sas_ha)
64 64
65 spin_lock_init(&sas_ha->event_lock); 65 spin_lock_init(&sas_ha->event_lock);
66 66
67 for (i = 0; i < HA_NUM_EVENTS; i++) 67 for (i = 0; i < HA_NUM_EVENTS; i++) {
68 INIT_WORK(&sas_ha->ha_events[i], sas_ha_event_fns[i], sas_ha); 68 INIT_WORK(&sas_ha->ha_events[i].work, sas_ha_event_fns[i]);
69 sas_ha->ha_events[i].ha = sas_ha;
70 }
69 71
70 sas_ha->notify_ha_event = notify_ha_event; 72 sas_ha->notify_ha_event = notify_ha_event;
71 sas_ha->notify_port_event = notify_port_event; 73 sas_ha->notify_port_event = notify_port_event;
diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
index 30b8014bcc7a..d31e6fa466f7 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -71,55 +71,65 @@ static void smp_task_done(struct sas_task *task)
71static int smp_execute_task(struct domain_device *dev, void *req, int req_size, 71static int smp_execute_task(struct domain_device *dev, void *req, int req_size,
72 void *resp, int resp_size) 72 void *resp, int resp_size)
73{ 73{
74 int res; 74 int res, retry;
75 struct sas_task *task = sas_alloc_task(GFP_KERNEL); 75 struct sas_task *task = NULL;
76 struct sas_internal *i = 76 struct sas_internal *i =
77 to_sas_internal(dev->port->ha->core.shost->transportt); 77 to_sas_internal(dev->port->ha->core.shost->transportt);
78 78
79 if (!task) 79 for (retry = 0; retry < 3; retry++) {
80 return -ENOMEM; 80 task = sas_alloc_task(GFP_KERNEL);
81 81 if (!task)
82 task->dev = dev; 82 return -ENOMEM;
83 task->task_proto = dev->tproto;
84 sg_init_one(&task->smp_task.smp_req, req, req_size);
85 sg_init_one(&task->smp_task.smp_resp, resp, resp_size);
86 83
87 task->task_done = smp_task_done; 84 task->dev = dev;
85 task->task_proto = dev->tproto;
86 sg_init_one(&task->smp_task.smp_req, req, req_size);
87 sg_init_one(&task->smp_task.smp_resp, resp, resp_size);
88 88
89 task->timer.data = (unsigned long) task; 89 task->task_done = smp_task_done;
90 task->timer.function = smp_task_timedout;
91 task->timer.expires = jiffies + SMP_TIMEOUT*HZ;
92 add_timer(&task->timer);
93 90
94 res = i->dft->lldd_execute_task(task, 1, GFP_KERNEL); 91 task->timer.data = (unsigned long) task;
92 task->timer.function = smp_task_timedout;
93 task->timer.expires = jiffies + SMP_TIMEOUT*HZ;
94 add_timer(&task->timer);
95 95
96 if (res) { 96 res = i->dft->lldd_execute_task(task, 1, GFP_KERNEL);
97 del_timer(&task->timer);
98 SAS_DPRINTK("executing SMP task failed:%d\n", res);
99 goto ex_err;
100 }
101 97
102 wait_for_completion(&task->completion); 98 if (res) {
103 res = -ETASK; 99 del_timer(&task->timer);
104 if ((task->task_state_flags & SAS_TASK_STATE_ABORTED)) { 100 SAS_DPRINTK("executing SMP task failed:%d\n", res);
105 SAS_DPRINTK("smp task timed out or aborted\n");
106 i->dft->lldd_abort_task(task);
107 if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) {
108 SAS_DPRINTK("SMP task aborted and not done\n");
109 goto ex_err; 101 goto ex_err;
110 } 102 }
103
104 wait_for_completion(&task->completion);
105 res = -ETASK;
106 if ((task->task_state_flags & SAS_TASK_STATE_ABORTED)) {
107 SAS_DPRINTK("smp task timed out or aborted\n");
108 i->dft->lldd_abort_task(task);
109 if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) {
110 SAS_DPRINTK("SMP task aborted and not done\n");
111 goto ex_err;
112 }
113 }
114 if (task->task_status.resp == SAS_TASK_COMPLETE &&
115 task->task_status.stat == SAM_GOOD) {
116 res = 0;
117 break;
118 } else {
119 SAS_DPRINTK("%s: task to dev %016llx response: 0x%x "
120 "status 0x%x\n", __FUNCTION__,
121 SAS_ADDR(dev->sas_addr),
122 task->task_status.resp,
123 task->task_status.stat);
124 sas_free_task(task);
125 task = NULL;
126 }
111 } 127 }
112 if (task->task_status.resp == SAS_TASK_COMPLETE &&
113 task->task_status.stat == SAM_GOOD)
114 res = 0;
115 else
116 SAS_DPRINTK("%s: task to dev %016llx response: 0x%x "
117 "status 0x%x\n", __FUNCTION__,
118 SAS_ADDR(dev->sas_addr),
119 task->task_status.resp,
120 task->task_status.stat);
121ex_err: 128ex_err:
122 sas_free_task(task); 129 BUG_ON(retry == 3 && task != NULL);
130 if (task != NULL) {
131 sas_free_task(task);
132 }
123 return res; 133 return res;
124} 134}
125 135
@@ -587,10 +597,15 @@ static struct domain_device *sas_ex_discover_end_dev(
587 child->iproto = phy->attached_iproto; 597 child->iproto = phy->attached_iproto;
588 memcpy(child->sas_addr, phy->attached_sas_addr, SAS_ADDR_SIZE); 598 memcpy(child->sas_addr, phy->attached_sas_addr, SAS_ADDR_SIZE);
589 sas_hash_addr(child->hashed_sas_addr, child->sas_addr); 599 sas_hash_addr(child->hashed_sas_addr, child->sas_addr);
590 phy->port = sas_port_alloc(&parent->rphy->dev, phy_id); 600 if (!phy->port) {
591 BUG_ON(!phy->port); 601 phy->port = sas_port_alloc(&parent->rphy->dev, phy_id);
592 /* FIXME: better error handling*/ 602 if (unlikely(!phy->port))
593 BUG_ON(sas_port_add(phy->port) != 0); 603 goto out_err;
604 if (unlikely(sas_port_add(phy->port) != 0)) {
605 sas_port_free(phy->port);
606 goto out_err;
607 }
608 }
594 sas_ex_get_linkrate(parent, child, phy); 609 sas_ex_get_linkrate(parent, child, phy);
595 610
596 if ((phy->attached_tproto & SAS_PROTO_STP) || phy->attached_sata_dev) { 611 if ((phy->attached_tproto & SAS_PROTO_STP) || phy->attached_sata_dev) {
@@ -605,8 +620,7 @@ static struct domain_device *sas_ex_discover_end_dev(
605 SAS_DPRINTK("report phy sata to %016llx:0x%x returned " 620 SAS_DPRINTK("report phy sata to %016llx:0x%x returned "
606 "0x%x\n", SAS_ADDR(parent->sas_addr), 621 "0x%x\n", SAS_ADDR(parent->sas_addr),
607 phy_id, res); 622 phy_id, res);
608 kfree(child); 623 goto out_free;
609 return NULL;
610 } 624 }
611 memcpy(child->frame_rcvd, &child->sata_dev.rps_resp.rps.fis, 625 memcpy(child->frame_rcvd, &child->sata_dev.rps_resp.rps.fis,
612 sizeof(struct dev_to_host_fis)); 626 sizeof(struct dev_to_host_fis));
@@ -617,14 +631,14 @@ static struct domain_device *sas_ex_discover_end_dev(
617 "%016llx:0x%x returned 0x%x\n", 631 "%016llx:0x%x returned 0x%x\n",
618 SAS_ADDR(child->sas_addr), 632 SAS_ADDR(child->sas_addr),
619 SAS_ADDR(parent->sas_addr), phy_id, res); 633 SAS_ADDR(parent->sas_addr), phy_id, res);
620 kfree(child); 634 goto out_free;
621 return NULL;
622 } 635 }
623 } else if (phy->attached_tproto & SAS_PROTO_SSP) { 636 } else if (phy->attached_tproto & SAS_PROTO_SSP) {
624 child->dev_type = SAS_END_DEV; 637 child->dev_type = SAS_END_DEV;
625 rphy = sas_end_device_alloc(phy->port); 638 rphy = sas_end_device_alloc(phy->port);
626 /* FIXME: error handling */ 639 /* FIXME: error handling */
627 BUG_ON(!rphy); 640 if (unlikely(!rphy))
641 goto out_free;
628 child->tproto = phy->attached_tproto; 642 child->tproto = phy->attached_tproto;
629 sas_init_dev(child); 643 sas_init_dev(child);
630 644
@@ -641,9 +655,7 @@ static struct domain_device *sas_ex_discover_end_dev(
641 "at %016llx:0x%x returned 0x%x\n", 655 "at %016llx:0x%x returned 0x%x\n",
642 SAS_ADDR(child->sas_addr), 656 SAS_ADDR(child->sas_addr),
643 SAS_ADDR(parent->sas_addr), phy_id, res); 657 SAS_ADDR(parent->sas_addr), phy_id, res);
644 /* FIXME: this kfrees list elements without removing them */ 658 goto out_list_del;
645 //kfree(child);
646 return NULL;
647 } 659 }
648 } else { 660 } else {
649 SAS_DPRINTK("target proto 0x%x at %016llx:0x%x not handled\n", 661 SAS_DPRINTK("target proto 0x%x at %016llx:0x%x not handled\n",
@@ -653,6 +665,16 @@ static struct domain_device *sas_ex_discover_end_dev(
653 665
654 list_add_tail(&child->siblings, &parent_ex->children); 666 list_add_tail(&child->siblings, &parent_ex->children);
655 return child; 667 return child;
668
669 out_list_del:
670 list_del(&child->dev_list_node);
671 sas_rphy_free(rphy);
672 out_free:
673 sas_port_delete(phy->port);
674 out_err:
675 phy->port = NULL;
676 kfree(child);
677 return NULL;
656} 678}
657 679
658static struct domain_device *sas_ex_discover_expander( 680static struct domain_device *sas_ex_discover_expander(
diff --git a/drivers/scsi/libsas/sas_init.c b/drivers/scsi/libsas/sas_init.c
index c836a237fb79..2f0c07fc3f48 100644
--- a/drivers/scsi/libsas/sas_init.c
+++ b/drivers/scsi/libsas/sas_init.c
@@ -36,7 +36,7 @@
36 36
37#include "../scsi_sas_internal.h" 37#include "../scsi_sas_internal.h"
38 38
39kmem_cache_t *sas_task_cache; 39struct kmem_cache *sas_task_cache;
40 40
41/*------------ SAS addr hash -----------*/ 41/*------------ SAS addr hash -----------*/
42void sas_hash_addr(u8 *hashed, const u8 *sas_addr) 42void sas_hash_addr(u8 *hashed, const u8 *sas_addr)
@@ -65,9 +65,11 @@ void sas_hash_addr(u8 *hashed, const u8 *sas_addr)
65 65
66/* ---------- HA events ---------- */ 66/* ---------- HA events ---------- */
67 67
68void sas_hae_reset(void *data) 68void sas_hae_reset(struct work_struct *work)
69{ 69{
70 struct sas_ha_struct *ha = data; 70 struct sas_ha_event *ev =
71 container_of(work, struct sas_ha_event, work);
72 struct sas_ha_struct *ha = ev->ha;
71 73
72 sas_begin_event(HAE_RESET, &ha->event_lock, 74 sas_begin_event(HAE_RESET, &ha->event_lock,
73 &ha->pending); 75 &ha->pending);
@@ -112,6 +114,8 @@ int sas_register_ha(struct sas_ha_struct *sas_ha)
112 } 114 }
113 } 115 }
114 116
117 INIT_LIST_HEAD(&sas_ha->eh_done_q);
118
115 return 0; 119 return 0;
116 120
117Undo_ports: 121Undo_ports:
@@ -142,7 +146,7 @@ static int sas_get_linkerrors(struct sas_phy *phy)
142 return sas_smp_get_phy_events(phy); 146 return sas_smp_get_phy_events(phy);
143} 147}
144 148
145static int sas_phy_reset(struct sas_phy *phy, int hard_reset) 149int sas_phy_reset(struct sas_phy *phy, int hard_reset)
146{ 150{
147 int ret; 151 int ret;
148 enum phy_func reset_type; 152 enum phy_func reset_type;
diff --git a/drivers/scsi/libsas/sas_internal.h b/drivers/scsi/libsas/sas_internal.h
index bffcee474921..137d7e496b6d 100644
--- a/drivers/scsi/libsas/sas_internal.h
+++ b/drivers/scsi/libsas/sas_internal.h
@@ -60,11 +60,11 @@ void sas_shutdown_queue(struct sas_ha_struct *sas_ha);
60 60
61void sas_deform_port(struct asd_sas_phy *phy); 61void sas_deform_port(struct asd_sas_phy *phy);
62 62
63void sas_porte_bytes_dmaed(void *); 63void sas_porte_bytes_dmaed(struct work_struct *work);
64void sas_porte_broadcast_rcvd(void *); 64void sas_porte_broadcast_rcvd(struct work_struct *work);
65void sas_porte_link_reset_err(void *); 65void sas_porte_link_reset_err(struct work_struct *work);
66void sas_porte_timer_event(void *); 66void sas_porte_timer_event(struct work_struct *work);
67void sas_porte_hard_reset(void *); 67void sas_porte_hard_reset(struct work_struct *work);
68 68
69int sas_notify_lldd_dev_found(struct domain_device *); 69int sas_notify_lldd_dev_found(struct domain_device *);
70void sas_notify_lldd_dev_gone(struct domain_device *); 70void sas_notify_lldd_dev_gone(struct domain_device *);
@@ -75,7 +75,7 @@ int sas_smp_get_phy_events(struct sas_phy *phy);
75 75
76struct domain_device *sas_find_dev_by_rphy(struct sas_rphy *rphy); 76struct domain_device *sas_find_dev_by_rphy(struct sas_rphy *rphy);
77 77
78void sas_hae_reset(void *); 78void sas_hae_reset(struct work_struct *work);
79 79
80static inline void sas_queue_event(int event, spinlock_t *lock, 80static inline void sas_queue_event(int event, spinlock_t *lock,
81 unsigned long *pending, 81 unsigned long *pending,
diff --git a/drivers/scsi/libsas/sas_phy.c b/drivers/scsi/libsas/sas_phy.c
index 9340cdbae4a3..b459c4b635b1 100644
--- a/drivers/scsi/libsas/sas_phy.c
+++ b/drivers/scsi/libsas/sas_phy.c
@@ -30,9 +30,11 @@
30 30
31/* ---------- Phy events ---------- */ 31/* ---------- Phy events ---------- */
32 32
33static void sas_phye_loss_of_signal(void *data) 33static void sas_phye_loss_of_signal(struct work_struct *work)
34{ 34{
35 struct asd_sas_phy *phy = data; 35 struct asd_sas_event *ev =
36 container_of(work, struct asd_sas_event, work);
37 struct asd_sas_phy *phy = ev->phy;
36 38
37 sas_begin_event(PHYE_LOSS_OF_SIGNAL, &phy->ha->event_lock, 39 sas_begin_event(PHYE_LOSS_OF_SIGNAL, &phy->ha->event_lock,
38 &phy->phy_events_pending); 40 &phy->phy_events_pending);
@@ -40,18 +42,22 @@ static void sas_phye_loss_of_signal(void *data)
40 sas_deform_port(phy); 42 sas_deform_port(phy);
41} 43}
42 44
43static void sas_phye_oob_done(void *data) 45static void sas_phye_oob_done(struct work_struct *work)
44{ 46{
45 struct asd_sas_phy *phy = data; 47 struct asd_sas_event *ev =
48 container_of(work, struct asd_sas_event, work);
49 struct asd_sas_phy *phy = ev->phy;
46 50
47 sas_begin_event(PHYE_OOB_DONE, &phy->ha->event_lock, 51 sas_begin_event(PHYE_OOB_DONE, &phy->ha->event_lock,
48 &phy->phy_events_pending); 52 &phy->phy_events_pending);
49 phy->error = 0; 53 phy->error = 0;
50} 54}
51 55
52static void sas_phye_oob_error(void *data) 56static void sas_phye_oob_error(struct work_struct *work)
53{ 57{
54 struct asd_sas_phy *phy = data; 58 struct asd_sas_event *ev =
59 container_of(work, struct asd_sas_event, work);
60 struct asd_sas_phy *phy = ev->phy;
55 struct sas_ha_struct *sas_ha = phy->ha; 61 struct sas_ha_struct *sas_ha = phy->ha;
56 struct asd_sas_port *port = phy->port; 62 struct asd_sas_port *port = phy->port;
57 struct sas_internal *i = 63 struct sas_internal *i =
@@ -80,9 +86,11 @@ static void sas_phye_oob_error(void *data)
80 } 86 }
81} 87}
82 88
83static void sas_phye_spinup_hold(void *data) 89static void sas_phye_spinup_hold(struct work_struct *work)
84{ 90{
85 struct asd_sas_phy *phy = data; 91 struct asd_sas_event *ev =
92 container_of(work, struct asd_sas_event, work);
93 struct asd_sas_phy *phy = ev->phy;
86 struct sas_ha_struct *sas_ha = phy->ha; 94 struct sas_ha_struct *sas_ha = phy->ha;
87 struct sas_internal *i = 95 struct sas_internal *i =
88 to_sas_internal(sas_ha->core.shost->transportt); 96 to_sas_internal(sas_ha->core.shost->transportt);
@@ -100,14 +108,14 @@ int sas_register_phys(struct sas_ha_struct *sas_ha)
100{ 108{
101 int i; 109 int i;
102 110
103 static void (*sas_phy_event_fns[PHY_NUM_EVENTS])(void *) = { 111 static const work_func_t sas_phy_event_fns[PHY_NUM_EVENTS] = {
104 [PHYE_LOSS_OF_SIGNAL] = sas_phye_loss_of_signal, 112 [PHYE_LOSS_OF_SIGNAL] = sas_phye_loss_of_signal,
105 [PHYE_OOB_DONE] = sas_phye_oob_done, 113 [PHYE_OOB_DONE] = sas_phye_oob_done,
106 [PHYE_OOB_ERROR] = sas_phye_oob_error, 114 [PHYE_OOB_ERROR] = sas_phye_oob_error,
107 [PHYE_SPINUP_HOLD] = sas_phye_spinup_hold, 115 [PHYE_SPINUP_HOLD] = sas_phye_spinup_hold,
108 }; 116 };
109 117
110 static void (*sas_port_event_fns[PORT_NUM_EVENTS])(void *) = { 118 static const work_func_t sas_port_event_fns[PORT_NUM_EVENTS] = {
111 [PORTE_BYTES_DMAED] = sas_porte_bytes_dmaed, 119 [PORTE_BYTES_DMAED] = sas_porte_bytes_dmaed,
112 [PORTE_BROADCAST_RCVD] = sas_porte_broadcast_rcvd, 120 [PORTE_BROADCAST_RCVD] = sas_porte_broadcast_rcvd,
113 [PORTE_LINK_RESET_ERR] = sas_porte_link_reset_err, 121 [PORTE_LINK_RESET_ERR] = sas_porte_link_reset_err,
@@ -122,13 +130,18 @@ int sas_register_phys(struct sas_ha_struct *sas_ha)
122 130
123 phy->error = 0; 131 phy->error = 0;
124 INIT_LIST_HEAD(&phy->port_phy_el); 132 INIT_LIST_HEAD(&phy->port_phy_el);
125 for (k = 0; k < PORT_NUM_EVENTS; k++) 133 for (k = 0; k < PORT_NUM_EVENTS; k++) {
126 INIT_WORK(&phy->port_events[k], sas_port_event_fns[k], 134 INIT_WORK(&phy->port_events[k].work,
127 phy); 135 sas_port_event_fns[k]);
136 phy->port_events[k].phy = phy;
137 }
138
139 for (k = 0; k < PHY_NUM_EVENTS; k++) {
140 INIT_WORK(&phy->phy_events[k].work,
141 sas_phy_event_fns[k]);
142 phy->phy_events[k].phy = phy;
143 }
128 144
129 for (k = 0; k < PHY_NUM_EVENTS; k++)
130 INIT_WORK(&phy->phy_events[k], sas_phy_event_fns[k],
131 phy);
132 phy->port = NULL; 145 phy->port = NULL;
133 phy->ha = sas_ha; 146 phy->ha = sas_ha;
134 spin_lock_init(&phy->frame_rcvd_lock); 147 spin_lock_init(&phy->frame_rcvd_lock);
diff --git a/drivers/scsi/libsas/sas_port.c b/drivers/scsi/libsas/sas_port.c
index 253cdcf306a2..971c37ceecb4 100644
--- a/drivers/scsi/libsas/sas_port.c
+++ b/drivers/scsi/libsas/sas_port.c
@@ -181,9 +181,11 @@ void sas_deform_port(struct asd_sas_phy *phy)
181 181
182/* ---------- SAS port events ---------- */ 182/* ---------- SAS port events ---------- */
183 183
184void sas_porte_bytes_dmaed(void *data) 184void sas_porte_bytes_dmaed(struct work_struct *work)
185{ 185{
186 struct asd_sas_phy *phy = data; 186 struct asd_sas_event *ev =
187 container_of(work, struct asd_sas_event, work);
188 struct asd_sas_phy *phy = ev->phy;
187 189
188 sas_begin_event(PORTE_BYTES_DMAED, &phy->ha->event_lock, 190 sas_begin_event(PORTE_BYTES_DMAED, &phy->ha->event_lock,
189 &phy->port_events_pending); 191 &phy->port_events_pending);
@@ -191,11 +193,13 @@ void sas_porte_bytes_dmaed(void *data)
191 sas_form_port(phy); 193 sas_form_port(phy);
192} 194}
193 195
194void sas_porte_broadcast_rcvd(void *data) 196void sas_porte_broadcast_rcvd(struct work_struct *work)
195{ 197{
198 struct asd_sas_event *ev =
199 container_of(work, struct asd_sas_event, work);
200 struct asd_sas_phy *phy = ev->phy;
196 unsigned long flags; 201 unsigned long flags;
197 u32 prim; 202 u32 prim;
198 struct asd_sas_phy *phy = data;
199 203
200 sas_begin_event(PORTE_BROADCAST_RCVD, &phy->ha->event_lock, 204 sas_begin_event(PORTE_BROADCAST_RCVD, &phy->ha->event_lock,
201 &phy->port_events_pending); 205 &phy->port_events_pending);
@@ -208,9 +212,11 @@ void sas_porte_broadcast_rcvd(void *data)
208 sas_discover_event(phy->port, DISCE_REVALIDATE_DOMAIN); 212 sas_discover_event(phy->port, DISCE_REVALIDATE_DOMAIN);
209} 213}
210 214
211void sas_porte_link_reset_err(void *data) 215void sas_porte_link_reset_err(struct work_struct *work)
212{ 216{
213 struct asd_sas_phy *phy = data; 217 struct asd_sas_event *ev =
218 container_of(work, struct asd_sas_event, work);
219 struct asd_sas_phy *phy = ev->phy;
214 220
215 sas_begin_event(PORTE_LINK_RESET_ERR, &phy->ha->event_lock, 221 sas_begin_event(PORTE_LINK_RESET_ERR, &phy->ha->event_lock,
216 &phy->port_events_pending); 222 &phy->port_events_pending);
@@ -218,9 +224,11 @@ void sas_porte_link_reset_err(void *data)
218 sas_deform_port(phy); 224 sas_deform_port(phy);
219} 225}
220 226
221void sas_porte_timer_event(void *data) 227void sas_porte_timer_event(struct work_struct *work)
222{ 228{
223 struct asd_sas_phy *phy = data; 229 struct asd_sas_event *ev =
230 container_of(work, struct asd_sas_event, work);
231 struct asd_sas_phy *phy = ev->phy;
224 232
225 sas_begin_event(PORTE_TIMER_EVENT, &phy->ha->event_lock, 233 sas_begin_event(PORTE_TIMER_EVENT, &phy->ha->event_lock,
226 &phy->port_events_pending); 234 &phy->port_events_pending);
@@ -228,9 +236,11 @@ void sas_porte_timer_event(void *data)
228 sas_deform_port(phy); 236 sas_deform_port(phy);
229} 237}
230 238
231void sas_porte_hard_reset(void *data) 239void sas_porte_hard_reset(struct work_struct *work)
232{ 240{
233 struct asd_sas_phy *phy = data; 241 struct asd_sas_event *ev =
242 container_of(work, struct asd_sas_event, work);
243 struct asd_sas_phy *phy = ev->phy;
234 244
235 sas_begin_event(PORTE_HARD_RESET, &phy->ha->event_lock, 245 sas_begin_event(PORTE_HARD_RESET, &phy->ha->event_lock,
236 &phy->port_events_pending); 246 &phy->port_events_pending);
diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c
index e46e79355b77..22672d54aa27 100644
--- a/drivers/scsi/libsas/sas_scsi_host.c
+++ b/drivers/scsi/libsas/sas_scsi_host.c
@@ -29,9 +29,11 @@
29#include <scsi/scsi_device.h> 29#include <scsi/scsi_device.h>
30#include <scsi/scsi_tcq.h> 30#include <scsi/scsi_tcq.h>
31#include <scsi/scsi.h> 31#include <scsi/scsi.h>
32#include <scsi/scsi_eh.h>
32#include <scsi/scsi_transport.h> 33#include <scsi/scsi_transport.h>
33#include <scsi/scsi_transport_sas.h> 34#include <scsi/scsi_transport_sas.h>
34#include "../scsi_sas_internal.h" 35#include "../scsi_sas_internal.h"
36#include "../scsi_transport_api.h"
35 37
36#include <linux/err.h> 38#include <linux/err.h>
37#include <linux/blkdev.h> 39#include <linux/blkdev.h>
@@ -46,6 +48,7 @@ static void sas_scsi_task_done(struct sas_task *task)
46{ 48{
47 struct task_status_struct *ts = &task->task_status; 49 struct task_status_struct *ts = &task->task_status;
48 struct scsi_cmnd *sc = task->uldd_task; 50 struct scsi_cmnd *sc = task->uldd_task;
51 struct sas_ha_struct *sas_ha = SHOST_TO_SAS_HA(sc->device->host);
49 unsigned ts_flags = task->task_state_flags; 52 unsigned ts_flags = task->task_state_flags;
50 int hs = 0, stat = 0; 53 int hs = 0, stat = 0;
51 54
@@ -116,7 +119,7 @@ static void sas_scsi_task_done(struct sas_task *task)
116 sas_free_task(task); 119 sas_free_task(task);
117 /* This is very ugly but this is how SCSI Core works. */ 120 /* This is very ugly but this is how SCSI Core works. */
118 if (ts_flags & SAS_TASK_STATE_ABORTED) 121 if (ts_flags & SAS_TASK_STATE_ABORTED)
119 scsi_finish_command(sc); 122 scsi_eh_finish_cmd(sc, &sas_ha->eh_done_q);
120 else 123 else
121 sc->scsi_done(sc); 124 sc->scsi_done(sc);
122} 125}
@@ -307,6 +310,15 @@ static enum task_disposition sas_scsi_find_task(struct sas_task *task)
307 spin_unlock_irqrestore(&core->task_queue_lock, flags); 310 spin_unlock_irqrestore(&core->task_queue_lock, flags);
308 } 311 }
309 312
313 spin_lock_irqsave(&task->task_state_lock, flags);
314 if (task->task_state_flags & SAS_TASK_INITIATOR_ABORTED) {
315 spin_unlock_irqrestore(&task->task_state_lock, flags);
316 SAS_DPRINTK("%s: task 0x%p already aborted\n",
317 __FUNCTION__, task);
318 return TASK_IS_ABORTED;
319 }
320 spin_unlock_irqrestore(&task->task_state_lock, flags);
321
310 for (i = 0; i < 5; i++) { 322 for (i = 0; i < 5; i++) {
311 SAS_DPRINTK("%s: aborting task 0x%p\n", __FUNCTION__, task); 323 SAS_DPRINTK("%s: aborting task 0x%p\n", __FUNCTION__, task);
312 res = si->dft->lldd_abort_task(task); 324 res = si->dft->lldd_abort_task(task);
@@ -409,13 +421,16 @@ Again:
409 SAS_DPRINTK("going over list...\n"); 421 SAS_DPRINTK("going over list...\n");
410 list_for_each_entry_safe(cmd, n, &error_q, eh_entry) { 422 list_for_each_entry_safe(cmd, n, &error_q, eh_entry) {
411 struct sas_task *task = TO_SAS_TASK(cmd); 423 struct sas_task *task = TO_SAS_TASK(cmd);
424 list_del_init(&cmd->eh_entry);
412 425
426 if (!task) {
427 SAS_DPRINTK("%s: taskless cmd?!\n", __FUNCTION__);
428 continue;
429 }
413 SAS_DPRINTK("trying to find task 0x%p\n", task); 430 SAS_DPRINTK("trying to find task 0x%p\n", task);
414 list_del_init(&cmd->eh_entry);
415 res = sas_scsi_find_task(task); 431 res = sas_scsi_find_task(task);
416 432
417 cmd->eh_eflags = 0; 433 cmd->eh_eflags = 0;
418 shost->host_failed--;
419 434
420 switch (res) { 435 switch (res) {
421 case TASK_IS_DONE: 436 case TASK_IS_DONE:
@@ -491,6 +506,7 @@ Again:
491 } 506 }
492 } 507 }
493out: 508out:
509 scsi_eh_flush_done_q(&ha->eh_done_q);
494 SAS_DPRINTK("--- Exit %s\n", __FUNCTION__); 510 SAS_DPRINTK("--- Exit %s\n", __FUNCTION__);
495 return; 511 return;
496clear_q: 512clear_q:
@@ -508,12 +524,18 @@ enum scsi_eh_timer_return sas_scsi_timed_out(struct scsi_cmnd *cmd)
508 unsigned long flags; 524 unsigned long flags;
509 525
510 if (!task) { 526 if (!task) {
511 SAS_DPRINTK("command 0x%p, task 0x%p, timed out: EH_HANDLED\n", 527 SAS_DPRINTK("command 0x%p, task 0x%p, gone: EH_HANDLED\n",
512 cmd, task); 528 cmd, task);
513 return EH_HANDLED; 529 return EH_HANDLED;
514 } 530 }
515 531
516 spin_lock_irqsave(&task->task_state_lock, flags); 532 spin_lock_irqsave(&task->task_state_lock, flags);
533 if (task->task_state_flags & SAS_TASK_INITIATOR_ABORTED) {
534 spin_unlock_irqrestore(&task->task_state_lock, flags);
535 SAS_DPRINTK("command 0x%p, task 0x%p, aborted by initiator: "
536 "EH_NOT_HANDLED\n", cmd, task);
537 return EH_NOT_HANDLED;
538 }
517 if (task->task_state_flags & SAS_TASK_STATE_DONE) { 539 if (task->task_state_flags & SAS_TASK_STATE_DONE) {
518 spin_unlock_irqrestore(&task->task_state_lock, flags); 540 spin_unlock_irqrestore(&task->task_state_lock, flags);
519 SAS_DPRINTK("command 0x%p, task 0x%p, timed out: EH_HANDLED\n", 541 SAS_DPRINTK("command 0x%p, task 0x%p, timed out: EH_HANDLED\n",
@@ -777,6 +799,66 @@ void sas_shutdown_queue(struct sas_ha_struct *sas_ha)
777 spin_unlock_irqrestore(&core->task_queue_lock, flags); 799 spin_unlock_irqrestore(&core->task_queue_lock, flags);
778} 800}
779 801
802static int do_sas_task_abort(struct sas_task *task)
803{
804 struct scsi_cmnd *sc = task->uldd_task;
805 struct sas_internal *si =
806 to_sas_internal(task->dev->port->ha->core.shost->transportt);
807 unsigned long flags;
808 int res;
809
810 spin_lock_irqsave(&task->task_state_lock, flags);
811 if (task->task_state_flags & SAS_TASK_STATE_ABORTED) {
812 spin_unlock_irqrestore(&task->task_state_lock, flags);
813 SAS_DPRINTK("%s: Task %p already aborted.\n", __FUNCTION__,
814 task);
815 return 0;
816 }
817
818 task->task_state_flags |= SAS_TASK_INITIATOR_ABORTED;
819 if (!(task->task_state_flags & SAS_TASK_STATE_DONE))
820 task->task_state_flags |= SAS_TASK_STATE_ABORTED;
821 spin_unlock_irqrestore(&task->task_state_lock, flags);
822
823 if (!si->dft->lldd_abort_task)
824 return -ENODEV;
825
826 res = si->dft->lldd_abort_task(task);
827 if ((task->task_state_flags & SAS_TASK_STATE_DONE) ||
828 (res == TMF_RESP_FUNC_COMPLETE))
829 {
830 /* SMP commands don't have scsi_cmds(?) */
831 if (!sc) {
832 task->task_done(task);
833 return 0;
834 }
835 scsi_req_abort_cmd(sc);
836 scsi_schedule_eh(sc->device->host);
837 return 0;
838 }
839
840 spin_lock_irqsave(&task->task_state_lock, flags);
841 task->task_state_flags &= ~SAS_TASK_INITIATOR_ABORTED;
842 if (!(task->task_state_flags & SAS_TASK_STATE_DONE))
843 task->task_state_flags &= ~SAS_TASK_STATE_ABORTED;
844 spin_unlock_irqrestore(&task->task_state_lock, flags);
845
846 return -EAGAIN;
847}
848
849void sas_task_abort(struct work_struct *work)
850{
851 struct sas_task *task =
852 container_of(work, struct sas_task, abort_work);
853 int i;
854
855 for (i = 0; i < 5; i++)
856 if (!do_sas_task_abort(task))
857 return;
858
859 SAS_DPRINTK("%s: Could not kill task!\n", __FUNCTION__);
860}
861
780EXPORT_SYMBOL_GPL(sas_queuecommand); 862EXPORT_SYMBOL_GPL(sas_queuecommand);
781EXPORT_SYMBOL_GPL(sas_target_alloc); 863EXPORT_SYMBOL_GPL(sas_target_alloc);
782EXPORT_SYMBOL_GPL(sas_slave_configure); 864EXPORT_SYMBOL_GPL(sas_slave_configure);
@@ -784,3 +866,5 @@ EXPORT_SYMBOL_GPL(sas_slave_destroy);
784EXPORT_SYMBOL_GPL(sas_change_queue_depth); 866EXPORT_SYMBOL_GPL(sas_change_queue_depth);
785EXPORT_SYMBOL_GPL(sas_change_queue_type); 867EXPORT_SYMBOL_GPL(sas_change_queue_type);
786EXPORT_SYMBOL_GPL(sas_bios_param); 868EXPORT_SYMBOL_GPL(sas_bios_param);
869EXPORT_SYMBOL_GPL(sas_task_abort);
870EXPORT_SYMBOL_GPL(sas_phy_reset);
diff --git a/drivers/scsi/libsrp.c b/drivers/scsi/libsrp.c
new file mode 100644
index 000000000000..89403b00e042
--- /dev/null
+++ b/drivers/scsi/libsrp.c
@@ -0,0 +1,441 @@
1/*
2 * SCSI RDAM Protocol lib functions
3 *
4 * Copyright (C) 2006 FUJITA Tomonori <tomof@acm.org>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19 * 02110-1301 USA
20 */
21#include <linux/err.h>
22#include <linux/kfifo.h>
23#include <linux/scatterlist.h>
24#include <linux/dma-mapping.h>
25#include <linux/pci.h>
26#include <scsi/scsi.h>
27#include <scsi/scsi_cmnd.h>
28#include <scsi/scsi_tcq.h>
29#include <scsi/scsi_tgt.h>
30#include <scsi/srp.h>
31#include <scsi/libsrp.h>
32
33enum srp_task_attributes {
34 SRP_SIMPLE_TASK = 0,
35 SRP_HEAD_TASK = 1,
36 SRP_ORDERED_TASK = 2,
37 SRP_ACA_TASK = 4
38};
39
40/* tmp - will replace with SCSI logging stuff */
41#define eprintk(fmt, args...) \
42do { \
43 printk("%s(%d) " fmt, __FUNCTION__, __LINE__, ##args); \
44} while (0)
45/* #define dprintk eprintk */
46#define dprintk(fmt, args...)
47
48static int srp_iu_pool_alloc(struct srp_queue *q, size_t max,
49 struct srp_buf **ring)
50{
51 int i;
52 struct iu_entry *iue;
53
54 q->pool = kcalloc(max, sizeof(struct iu_entry *), GFP_KERNEL);
55 if (!q->pool)
56 return -ENOMEM;
57 q->items = kcalloc(max, sizeof(struct iu_entry), GFP_KERNEL);
58 if (!q->items)
59 goto free_pool;
60
61 spin_lock_init(&q->lock);
62 q->queue = kfifo_init((void *) q->pool, max * sizeof(void *),
63 GFP_KERNEL, &q->lock);
64 if (IS_ERR(q->queue))
65 goto free_item;
66
67 for (i = 0, iue = q->items; i < max; i++) {
68 __kfifo_put(q->queue, (void *) &iue, sizeof(void *));
69 iue->sbuf = ring[i];
70 iue++;
71 }
72 return 0;
73
74free_item:
75 kfree(q->items);
76free_pool:
77 kfree(q->pool);
78 return -ENOMEM;
79}
80
81static void srp_iu_pool_free(struct srp_queue *q)
82{
83 kfree(q->items);
84 kfree(q->pool);
85}
86
87static struct srp_buf **srp_ring_alloc(struct device *dev,
88 size_t max, size_t size)
89{
90 int i;
91 struct srp_buf **ring;
92
93 ring = kcalloc(max, sizeof(struct srp_buf *), GFP_KERNEL);
94 if (!ring)
95 return NULL;
96
97 for (i = 0; i < max; i++) {
98 ring[i] = kzalloc(sizeof(struct srp_buf), GFP_KERNEL);
99 if (!ring[i])
100 goto out;
101 ring[i]->buf = dma_alloc_coherent(dev, size, &ring[i]->dma,
102 GFP_KERNEL);
103 if (!ring[i]->buf)
104 goto out;
105 }
106 return ring;
107
108out:
109 for (i = 0; i < max && ring[i]; i++) {
110 if (ring[i]->buf)
111 dma_free_coherent(dev, size, ring[i]->buf, ring[i]->dma);
112 kfree(ring[i]);
113 }
114 kfree(ring);
115
116 return NULL;
117}
118
119static void srp_ring_free(struct device *dev, struct srp_buf **ring, size_t max,
120 size_t size)
121{
122 int i;
123
124 for (i = 0; i < max; i++) {
125 dma_free_coherent(dev, size, ring[i]->buf, ring[i]->dma);
126 kfree(ring[i]);
127 }
128}
129
130int srp_target_alloc(struct srp_target *target, struct device *dev,
131 size_t nr, size_t iu_size)
132{
133 int err;
134
135 spin_lock_init(&target->lock);
136 INIT_LIST_HEAD(&target->cmd_queue);
137
138 target->dev = dev;
139 target->dev->driver_data = target;
140
141 target->srp_iu_size = iu_size;
142 target->rx_ring_size = nr;
143 target->rx_ring = srp_ring_alloc(target->dev, nr, iu_size);
144 if (!target->rx_ring)
145 return -ENOMEM;
146 err = srp_iu_pool_alloc(&target->iu_queue, nr, target->rx_ring);
147 if (err)
148 goto free_ring;
149
150 return 0;
151
152free_ring:
153 srp_ring_free(target->dev, target->rx_ring, nr, iu_size);
154 return -ENOMEM;
155}
156EXPORT_SYMBOL_GPL(srp_target_alloc);
157
158void srp_target_free(struct srp_target *target)
159{
160 srp_ring_free(target->dev, target->rx_ring, target->rx_ring_size,
161 target->srp_iu_size);
162 srp_iu_pool_free(&target->iu_queue);
163}
164EXPORT_SYMBOL_GPL(srp_target_free);
165
166struct iu_entry *srp_iu_get(struct srp_target *target)
167{
168 struct iu_entry *iue = NULL;
169
170 kfifo_get(target->iu_queue.queue, (void *) &iue, sizeof(void *));
171 if (!iue)
172 return iue;
173 iue->target = target;
174 INIT_LIST_HEAD(&iue->ilist);
175 iue->flags = 0;
176 return iue;
177}
178EXPORT_SYMBOL_GPL(srp_iu_get);
179
180void srp_iu_put(struct iu_entry *iue)
181{
182 kfifo_put(iue->target->iu_queue.queue, (void *) &iue, sizeof(void *));
183}
184EXPORT_SYMBOL_GPL(srp_iu_put);
185
186static int srp_direct_data(struct scsi_cmnd *sc, struct srp_direct_buf *md,
187 enum dma_data_direction dir, srp_rdma_t rdma_io,
188 int dma_map, int ext_desc)
189{
190 struct iu_entry *iue = NULL;
191 struct scatterlist *sg = NULL;
192 int err, nsg = 0, len;
193
194 if (dma_map) {
195 iue = (struct iu_entry *) sc->SCp.ptr;
196 sg = sc->request_buffer;
197
198 dprintk("%p %u %u %d\n", iue, sc->request_bufflen,
199 md->len, sc->use_sg);
200
201 nsg = dma_map_sg(iue->target->dev, sg, sc->use_sg,
202 DMA_BIDIRECTIONAL);
203 if (!nsg) {
204 printk("fail to map %p %d\n", iue, sc->use_sg);
205 return 0;
206 }
207 len = min(sc->request_bufflen, md->len);
208 } else
209 len = md->len;
210
211 err = rdma_io(sc, sg, nsg, md, 1, dir, len);
212
213 if (dma_map)
214 dma_unmap_sg(iue->target->dev, sg, nsg, DMA_BIDIRECTIONAL);
215
216 return err;
217}
218
219static int srp_indirect_data(struct scsi_cmnd *sc, struct srp_cmd *cmd,
220 struct srp_indirect_buf *id,
221 enum dma_data_direction dir, srp_rdma_t rdma_io,
222 int dma_map, int ext_desc)
223{
224 struct iu_entry *iue = NULL;
225 struct srp_direct_buf *md = NULL;
226 struct scatterlist dummy, *sg = NULL;
227 dma_addr_t token = 0;
228 long err;
229 unsigned int done = 0;
230 int nmd, nsg = 0, len;
231
232 if (dma_map || ext_desc) {
233 iue = (struct iu_entry *) sc->SCp.ptr;
234 sg = sc->request_buffer;
235
236 dprintk("%p %u %u %d %d\n",
237 iue, sc->request_bufflen, id->len,
238 cmd->data_in_desc_cnt, cmd->data_out_desc_cnt);
239 }
240
241 nmd = id->table_desc.len / sizeof(struct srp_direct_buf);
242
243 if ((dir == DMA_FROM_DEVICE && nmd == cmd->data_in_desc_cnt) ||
244 (dir == DMA_TO_DEVICE && nmd == cmd->data_out_desc_cnt)) {
245 md = &id->desc_list[0];
246 goto rdma;
247 }
248
249 if (ext_desc && dma_map) {
250 md = dma_alloc_coherent(iue->target->dev, id->table_desc.len,
251 &token, GFP_KERNEL);
252 if (!md) {
253 eprintk("Can't get dma memory %u\n", id->table_desc.len);
254 return -ENOMEM;
255 }
256
257 sg_init_one(&dummy, md, id->table_desc.len);
258 sg_dma_address(&dummy) = token;
259 err = rdma_io(sc, &dummy, 1, &id->table_desc, 1, DMA_TO_DEVICE,
260 id->table_desc.len);
261 if (err < 0) {
262 eprintk("Error copying indirect table %ld\n", err);
263 goto free_mem;
264 }
265 } else {
266 eprintk("This command uses external indirect buffer\n");
267 return -EINVAL;
268 }
269
270rdma:
271 if (dma_map) {
272 nsg = dma_map_sg(iue->target->dev, sg, sc->use_sg, DMA_BIDIRECTIONAL);
273 if (!nsg) {
274 eprintk("fail to map %p %d\n", iue, sc->use_sg);
275 goto free_mem;
276 }
277 len = min(sc->request_bufflen, id->len);
278 } else
279 len = id->len;
280
281 err = rdma_io(sc, sg, nsg, md, nmd, dir, len);
282
283 if (dma_map)
284 dma_unmap_sg(iue->target->dev, sg, nsg, DMA_BIDIRECTIONAL);
285
286free_mem:
287 if (token && dma_map)
288 dma_free_coherent(iue->target->dev, id->table_desc.len, md, token);
289
290 return done;
291}
292
293static int data_out_desc_size(struct srp_cmd *cmd)
294{
295 int size = 0;
296 u8 fmt = cmd->buf_fmt >> 4;
297
298 switch (fmt) {
299 case SRP_NO_DATA_DESC:
300 break;
301 case SRP_DATA_DESC_DIRECT:
302 size = sizeof(struct srp_direct_buf);
303 break;
304 case SRP_DATA_DESC_INDIRECT:
305 size = sizeof(struct srp_indirect_buf) +
306 sizeof(struct srp_direct_buf) * cmd->data_out_desc_cnt;
307 break;
308 default:
309 eprintk("client error. Invalid data_out_format %x\n", fmt);
310 break;
311 }
312 return size;
313}
314
315/*
316 * TODO: this can be called multiple times for a single command if it
317 * has very long data.
318 */
319int srp_transfer_data(struct scsi_cmnd *sc, struct srp_cmd *cmd,
320 srp_rdma_t rdma_io, int dma_map, int ext_desc)
321{
322 struct srp_direct_buf *md;
323 struct srp_indirect_buf *id;
324 enum dma_data_direction dir;
325 int offset, err = 0;
326 u8 format;
327
328 offset = cmd->add_cdb_len * 4;
329
330 dir = srp_cmd_direction(cmd);
331 if (dir == DMA_FROM_DEVICE)
332 offset += data_out_desc_size(cmd);
333
334 if (dir == DMA_TO_DEVICE)
335 format = cmd->buf_fmt >> 4;
336 else
337 format = cmd->buf_fmt & ((1U << 4) - 1);
338
339 switch (format) {
340 case SRP_NO_DATA_DESC:
341 break;
342 case SRP_DATA_DESC_DIRECT:
343 md = (struct srp_direct_buf *)
344 (cmd->add_data + offset);
345 err = srp_direct_data(sc, md, dir, rdma_io, dma_map, ext_desc);
346 break;
347 case SRP_DATA_DESC_INDIRECT:
348 id = (struct srp_indirect_buf *)
349 (cmd->add_data + offset);
350 err = srp_indirect_data(sc, cmd, id, dir, rdma_io, dma_map,
351 ext_desc);
352 break;
353 default:
354 eprintk("Unknown format %d %x\n", dir, format);
355 break;
356 }
357
358 return err;
359}
360EXPORT_SYMBOL_GPL(srp_transfer_data);
361
362static int vscsis_data_length(struct srp_cmd *cmd, enum dma_data_direction dir)
363{
364 struct srp_direct_buf *md;
365 struct srp_indirect_buf *id;
366 int len = 0, offset = cmd->add_cdb_len * 4;
367 u8 fmt;
368
369 if (dir == DMA_TO_DEVICE)
370 fmt = cmd->buf_fmt >> 4;
371 else {
372 fmt = cmd->buf_fmt & ((1U << 4) - 1);
373 offset += data_out_desc_size(cmd);
374 }
375
376 switch (fmt) {
377 case SRP_NO_DATA_DESC:
378 break;
379 case SRP_DATA_DESC_DIRECT:
380 md = (struct srp_direct_buf *) (cmd->add_data + offset);
381 len = md->len;
382 break;
383 case SRP_DATA_DESC_INDIRECT:
384 id = (struct srp_indirect_buf *) (cmd->add_data + offset);
385 len = id->len;
386 break;
387 default:
388 eprintk("invalid data format %x\n", fmt);
389 break;
390 }
391 return len;
392}
393
394int srp_cmd_queue(struct Scsi_Host *shost, struct srp_cmd *cmd, void *info,
395 u64 addr)
396{
397 enum dma_data_direction dir;
398 struct scsi_cmnd *sc;
399 int tag, len, err;
400
401 switch (cmd->task_attr) {
402 case SRP_SIMPLE_TASK:
403 tag = MSG_SIMPLE_TAG;
404 break;
405 case SRP_ORDERED_TASK:
406 tag = MSG_ORDERED_TAG;
407 break;
408 case SRP_HEAD_TASK:
409 tag = MSG_HEAD_TAG;
410 break;
411 default:
412 eprintk("Task attribute %d not supported\n", cmd->task_attr);
413 tag = MSG_ORDERED_TAG;
414 }
415
416 dir = srp_cmd_direction(cmd);
417 len = vscsis_data_length(cmd, dir);
418
419 dprintk("%p %x %lx %d %d %d %llx\n", info, cmd->cdb[0],
420 cmd->lun, dir, len, tag, (unsigned long long) cmd->tag);
421
422 sc = scsi_host_get_command(shost, dir, GFP_KERNEL);
423 if (!sc)
424 return -ENOMEM;
425
426 sc->SCp.ptr = info;
427 memcpy(sc->cmnd, cmd->cdb, MAX_COMMAND_SIZE);
428 sc->request_bufflen = len;
429 sc->request_buffer = (void *) (unsigned long) addr;
430 sc->tag = tag;
431 err = scsi_tgt_queue_command(sc, (struct scsi_lun *) &cmd->lun, cmd->tag);
432 if (err)
433 scsi_host_put_command(shost, sc);
434
435 return err;
436}
437EXPORT_SYMBOL_GPL(srp_cmd_queue);
438
439MODULE_DESCRIPTION("SCSI RDAM Protocol lib functions");
440MODULE_AUTHOR("FUJITA Tomonori");
441MODULE_LICENSE("GPL");
diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
index 3f7f5f8abd75..a7de0bca5bdd 100644
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -296,13 +296,17 @@ struct lpfc_hba {
296 uint32_t cfg_cr_delay; 296 uint32_t cfg_cr_delay;
297 uint32_t cfg_cr_count; 297 uint32_t cfg_cr_count;
298 uint32_t cfg_multi_ring_support; 298 uint32_t cfg_multi_ring_support;
299 uint32_t cfg_multi_ring_rctl;
300 uint32_t cfg_multi_ring_type;
299 uint32_t cfg_fdmi_on; 301 uint32_t cfg_fdmi_on;
300 uint32_t cfg_discovery_threads; 302 uint32_t cfg_discovery_threads;
301 uint32_t cfg_max_luns; 303 uint32_t cfg_max_luns;
302 uint32_t cfg_poll; 304 uint32_t cfg_poll;
303 uint32_t cfg_poll_tmo; 305 uint32_t cfg_poll_tmo;
306 uint32_t cfg_use_msi;
304 uint32_t cfg_sg_seg_cnt; 307 uint32_t cfg_sg_seg_cnt;
305 uint32_t cfg_sg_dma_buf_size; 308 uint32_t cfg_sg_dma_buf_size;
309 uint64_t cfg_soft_wwnn;
306 uint64_t cfg_soft_wwpn; 310 uint64_t cfg_soft_wwpn;
307 311
308 uint32_t dev_loss_tmo_changed; 312 uint32_t dev_loss_tmo_changed;
@@ -355,7 +359,7 @@ struct lpfc_hba {
355#define VPD_PORT 0x8 /* valid vpd port data */ 359#define VPD_PORT 0x8 /* valid vpd port data */
356#define VPD_MASK 0xf /* mask for any vpd data */ 360#define VPD_MASK 0xf /* mask for any vpd data */
357 361
358 uint8_t soft_wwpn_enable; 362 uint8_t soft_wwn_enable;
359 363
360 struct timer_list fcp_poll_timer; 364 struct timer_list fcp_poll_timer;
361 struct timer_list els_tmofunc; 365 struct timer_list els_tmofunc;
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index 2a4e02e7a392..f247e786af99 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -552,10 +552,10 @@ static CLASS_DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR,
552static CLASS_DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset); 552static CLASS_DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset);
553 553
554 554
555static char *lpfc_soft_wwpn_key = "C99G71SL8032A"; 555static char *lpfc_soft_wwn_key = "C99G71SL8032A";
556 556
557static ssize_t 557static ssize_t
558lpfc_soft_wwpn_enable_store(struct class_device *cdev, const char *buf, 558lpfc_soft_wwn_enable_store(struct class_device *cdev, const char *buf,
559 size_t count) 559 size_t count)
560{ 560{
561 struct Scsi_Host *host = class_to_shost(cdev); 561 struct Scsi_Host *host = class_to_shost(cdev);
@@ -579,15 +579,15 @@ lpfc_soft_wwpn_enable_store(struct class_device *cdev, const char *buf,
579 if (buf[cnt-1] == '\n') 579 if (buf[cnt-1] == '\n')
580 cnt--; 580 cnt--;
581 581
582 if ((cnt != strlen(lpfc_soft_wwpn_key)) || 582 if ((cnt != strlen(lpfc_soft_wwn_key)) ||
583 (strncmp(buf, lpfc_soft_wwpn_key, strlen(lpfc_soft_wwpn_key)) != 0)) 583 (strncmp(buf, lpfc_soft_wwn_key, strlen(lpfc_soft_wwn_key)) != 0))
584 return -EINVAL; 584 return -EINVAL;
585 585
586 phba->soft_wwpn_enable = 1; 586 phba->soft_wwn_enable = 1;
587 return count; 587 return count;
588} 588}
589static CLASS_DEVICE_ATTR(lpfc_soft_wwpn_enable, S_IWUSR, NULL, 589static CLASS_DEVICE_ATTR(lpfc_soft_wwn_enable, S_IWUSR, NULL,
590 lpfc_soft_wwpn_enable_store); 590 lpfc_soft_wwn_enable_store);
591 591
592static ssize_t 592static ssize_t
593lpfc_soft_wwpn_show(struct class_device *cdev, char *buf) 593lpfc_soft_wwpn_show(struct class_device *cdev, char *buf)
@@ -613,12 +613,12 @@ lpfc_soft_wwpn_store(struct class_device *cdev, const char *buf, size_t count)
613 if (buf[cnt-1] == '\n') 613 if (buf[cnt-1] == '\n')
614 cnt--; 614 cnt--;
615 615
616 if (!phba->soft_wwpn_enable || (cnt < 16) || (cnt > 18) || 616 if (!phba->soft_wwn_enable || (cnt < 16) || (cnt > 18) ||
617 ((cnt == 17) && (*buf++ != 'x')) || 617 ((cnt == 17) && (*buf++ != 'x')) ||
618 ((cnt == 18) && ((*buf++ != '0') || (*buf++ != 'x')))) 618 ((cnt == 18) && ((*buf++ != '0') || (*buf++ != 'x'))))
619 return -EINVAL; 619 return -EINVAL;
620 620
621 phba->soft_wwpn_enable = 0; 621 phba->soft_wwn_enable = 0;
622 622
623 memset(wwpn, 0, sizeof(wwpn)); 623 memset(wwpn, 0, sizeof(wwpn));
624 624
@@ -639,6 +639,8 @@ lpfc_soft_wwpn_store(struct class_device *cdev, const char *buf, size_t count)
639 } 639 }
640 phba->cfg_soft_wwpn = wwn_to_u64(wwpn); 640 phba->cfg_soft_wwpn = wwn_to_u64(wwpn);
641 fc_host_port_name(host) = phba->cfg_soft_wwpn; 641 fc_host_port_name(host) = phba->cfg_soft_wwpn;
642 if (phba->cfg_soft_wwnn)
643 fc_host_node_name(host) = phba->cfg_soft_wwnn;
642 644
643 dev_printk(KERN_NOTICE, &phba->pcidev->dev, 645 dev_printk(KERN_NOTICE, &phba->pcidev->dev,
644 "lpfc%d: Reinitializing to use soft_wwpn\n", phba->brd_no); 646 "lpfc%d: Reinitializing to use soft_wwpn\n", phba->brd_no);
@@ -664,6 +666,66 @@ lpfc_soft_wwpn_store(struct class_device *cdev, const char *buf, size_t count)
664static CLASS_DEVICE_ATTR(lpfc_soft_wwpn, S_IRUGO | S_IWUSR,\ 666static CLASS_DEVICE_ATTR(lpfc_soft_wwpn, S_IRUGO | S_IWUSR,\
665 lpfc_soft_wwpn_show, lpfc_soft_wwpn_store); 667 lpfc_soft_wwpn_show, lpfc_soft_wwpn_store);
666 668
669static ssize_t
670lpfc_soft_wwnn_show(struct class_device *cdev, char *buf)
671{
672 struct Scsi_Host *host = class_to_shost(cdev);
673 struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
674 return snprintf(buf, PAGE_SIZE, "0x%llx\n",
675 (unsigned long long)phba->cfg_soft_wwnn);
676}
677
678
679static ssize_t
680lpfc_soft_wwnn_store(struct class_device *cdev, const char *buf, size_t count)
681{
682 struct Scsi_Host *host = class_to_shost(cdev);
683 struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
684 unsigned int i, j, cnt=count;
685 u8 wwnn[8];
686
687 /* count may include a LF at end of string */
688 if (buf[cnt-1] == '\n')
689 cnt--;
690
691 if (!phba->soft_wwn_enable || (cnt < 16) || (cnt > 18) ||
692 ((cnt == 17) && (*buf++ != 'x')) ||
693 ((cnt == 18) && ((*buf++ != '0') || (*buf++ != 'x'))))
694 return -EINVAL;
695
696 /*
697 * Allow wwnn to be set many times, as long as the enable is set.
698 * However, once the wwpn is set, everything locks.
699 */
700
701 memset(wwnn, 0, sizeof(wwnn));
702
703 /* Validate and store the new name */
704 for (i=0, j=0; i < 16; i++) {
705 if ((*buf >= 'a') && (*buf <= 'f'))
706 j = ((j << 4) | ((*buf++ -'a') + 10));
707 else if ((*buf >= 'A') && (*buf <= 'F'))
708 j = ((j << 4) | ((*buf++ -'A') + 10));
709 else if ((*buf >= '0') && (*buf <= '9'))
710 j = ((j << 4) | (*buf++ -'0'));
711 else
712 return -EINVAL;
713 if (i % 2) {
714 wwnn[i/2] = j & 0xff;
715 j = 0;
716 }
717 }
718 phba->cfg_soft_wwnn = wwn_to_u64(wwnn);
719
720 dev_printk(KERN_NOTICE, &phba->pcidev->dev,
721 "lpfc%d: soft_wwnn set. Value will take effect upon "
722 "setting of the soft_wwpn\n", phba->brd_no);
723
724 return count;
725}
726static CLASS_DEVICE_ATTR(lpfc_soft_wwnn, S_IRUGO | S_IWUSR,\
727 lpfc_soft_wwnn_show, lpfc_soft_wwnn_store);
728
667 729
668static int lpfc_poll = 0; 730static int lpfc_poll = 0;
669module_param(lpfc_poll, int, 0); 731module_param(lpfc_poll, int, 0);
@@ -802,12 +864,11 @@ static CLASS_DEVICE_ATTR(lpfc_devloss_tmo, S_IRUGO | S_IWUSR,
802# LOG_MBOX 0x4 Mailbox events 864# LOG_MBOX 0x4 Mailbox events
803# LOG_INIT 0x8 Initialization events 865# LOG_INIT 0x8 Initialization events
804# LOG_LINK_EVENT 0x10 Link events 866# LOG_LINK_EVENT 0x10 Link events
805# LOG_IP 0x20 IP traffic history
806# LOG_FCP 0x40 FCP traffic history 867# LOG_FCP 0x40 FCP traffic history
807# LOG_NODE 0x80 Node table events 868# LOG_NODE 0x80 Node table events
808# LOG_MISC 0x400 Miscellaneous events 869# LOG_MISC 0x400 Miscellaneous events
809# LOG_SLI 0x800 SLI events 870# LOG_SLI 0x800 SLI events
810# LOG_CHK_COND 0x1000 FCP Check condition flag 871# LOG_FCP_ERROR 0x1000 Only log FCP errors
811# LOG_LIBDFC 0x2000 LIBDFC events 872# LOG_LIBDFC 0x2000 LIBDFC events
812# LOG_ALL_MSG 0xffff LOG all messages 873# LOG_ALL_MSG 0xffff LOG all messages
813*/ 874*/
@@ -916,6 +977,22 @@ LPFC_ATTR_R(multi_ring_support, 1, 1, 2, "Determines number of primary "
916 "SLI rings to spread IOCB entries across"); 977 "SLI rings to spread IOCB entries across");
917 978
918/* 979/*
980# lpfc_multi_ring_rctl: If lpfc_multi_ring_support is enabled, this
981# identifies what rctl value to configure the additional ring for.
982# Value range is [1,0xff]. Default value is 4 (Unsolicated Data).
983*/
984LPFC_ATTR_R(multi_ring_rctl, FC_UNSOL_DATA, 1,
985 255, "Identifies RCTL for additional ring configuration");
986
987/*
988# lpfc_multi_ring_type: If lpfc_multi_ring_support is enabled, this
989# identifies what type value to configure the additional ring for.
990# Value range is [1,0xff]. Default value is 5 (LLC/SNAP).
991*/
992LPFC_ATTR_R(multi_ring_type, FC_LLC_SNAP, 1,
993 255, "Identifies TYPE for additional ring configuration");
994
995/*
919# lpfc_fdmi_on: controls FDMI support. 996# lpfc_fdmi_on: controls FDMI support.
920# 0 = no FDMI support 997# 0 = no FDMI support
921# 1 = support FDMI without attribute of hostname 998# 1 = support FDMI without attribute of hostname
@@ -946,6 +1023,15 @@ LPFC_ATTR_R(max_luns, 255, 0, 65535,
946LPFC_ATTR_RW(poll_tmo, 10, 1, 255, 1023LPFC_ATTR_RW(poll_tmo, 10, 1, 255,
947 "Milliseconds driver will wait between polling FCP ring"); 1024 "Milliseconds driver will wait between polling FCP ring");
948 1025
1026/*
1027# lpfc_use_msi: Use MSI (Message Signaled Interrupts) in systems that
1028# support this feature
1029# 0 = MSI disabled (default)
1030# 1 = MSI enabled
1031# Value range is [0,1]. Default value is 0.
1032*/
1033LPFC_ATTR_R(use_msi, 0, 0, 1, "Use Message Signaled Interrupts, if possible");
1034
949 1035
950struct class_device_attribute *lpfc_host_attrs[] = { 1036struct class_device_attribute *lpfc_host_attrs[] = {
951 &class_device_attr_info, 1037 &class_device_attr_info,
@@ -974,6 +1060,8 @@ struct class_device_attribute *lpfc_host_attrs[] = {
974 &class_device_attr_lpfc_cr_delay, 1060 &class_device_attr_lpfc_cr_delay,
975 &class_device_attr_lpfc_cr_count, 1061 &class_device_attr_lpfc_cr_count,
976 &class_device_attr_lpfc_multi_ring_support, 1062 &class_device_attr_lpfc_multi_ring_support,
1063 &class_device_attr_lpfc_multi_ring_rctl,
1064 &class_device_attr_lpfc_multi_ring_type,
977 &class_device_attr_lpfc_fdmi_on, 1065 &class_device_attr_lpfc_fdmi_on,
978 &class_device_attr_lpfc_max_luns, 1066 &class_device_attr_lpfc_max_luns,
979 &class_device_attr_nport_evt_cnt, 1067 &class_device_attr_nport_evt_cnt,
@@ -982,8 +1070,10 @@ struct class_device_attribute *lpfc_host_attrs[] = {
982 &class_device_attr_issue_reset, 1070 &class_device_attr_issue_reset,
983 &class_device_attr_lpfc_poll, 1071 &class_device_attr_lpfc_poll,
984 &class_device_attr_lpfc_poll_tmo, 1072 &class_device_attr_lpfc_poll_tmo,
1073 &class_device_attr_lpfc_use_msi,
1074 &class_device_attr_lpfc_soft_wwnn,
985 &class_device_attr_lpfc_soft_wwpn, 1075 &class_device_attr_lpfc_soft_wwpn,
986 &class_device_attr_lpfc_soft_wwpn_enable, 1076 &class_device_attr_lpfc_soft_wwn_enable,
987 NULL, 1077 NULL,
988}; 1078};
989 1079
@@ -1771,6 +1861,8 @@ lpfc_get_cfgparam(struct lpfc_hba *phba)
1771 lpfc_cr_delay_init(phba, lpfc_cr_delay); 1861 lpfc_cr_delay_init(phba, lpfc_cr_delay);
1772 lpfc_cr_count_init(phba, lpfc_cr_count); 1862 lpfc_cr_count_init(phba, lpfc_cr_count);
1773 lpfc_multi_ring_support_init(phba, lpfc_multi_ring_support); 1863 lpfc_multi_ring_support_init(phba, lpfc_multi_ring_support);
1864 lpfc_multi_ring_rctl_init(phba, lpfc_multi_ring_rctl);
1865 lpfc_multi_ring_type_init(phba, lpfc_multi_ring_type);
1774 lpfc_lun_queue_depth_init(phba, lpfc_lun_queue_depth); 1866 lpfc_lun_queue_depth_init(phba, lpfc_lun_queue_depth);
1775 lpfc_fcp_class_init(phba, lpfc_fcp_class); 1867 lpfc_fcp_class_init(phba, lpfc_fcp_class);
1776 lpfc_use_adisc_init(phba, lpfc_use_adisc); 1868 lpfc_use_adisc_init(phba, lpfc_use_adisc);
@@ -1782,9 +1874,11 @@ lpfc_get_cfgparam(struct lpfc_hba *phba)
1782 lpfc_discovery_threads_init(phba, lpfc_discovery_threads); 1874 lpfc_discovery_threads_init(phba, lpfc_discovery_threads);
1783 lpfc_max_luns_init(phba, lpfc_max_luns); 1875 lpfc_max_luns_init(phba, lpfc_max_luns);
1784 lpfc_poll_tmo_init(phba, lpfc_poll_tmo); 1876 lpfc_poll_tmo_init(phba, lpfc_poll_tmo);
1877 lpfc_use_msi_init(phba, lpfc_use_msi);
1785 lpfc_devloss_tmo_init(phba, lpfc_devloss_tmo); 1878 lpfc_devloss_tmo_init(phba, lpfc_devloss_tmo);
1786 lpfc_nodev_tmo_init(phba, lpfc_nodev_tmo); 1879 lpfc_nodev_tmo_init(phba, lpfc_nodev_tmo);
1787 phba->cfg_poll = lpfc_poll; 1880 phba->cfg_poll = lpfc_poll;
1881 phba->cfg_soft_wwnn = 0L;
1788 phba->cfg_soft_wwpn = 0L; 1882 phba->cfg_soft_wwpn = 0L;
1789 1883
1790 /* 1884 /*
diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c
index 3add7c237859..a51a41b7f15d 100644
--- a/drivers/scsi/lpfc/lpfc_ct.c
+++ b/drivers/scsi/lpfc/lpfc_ct.c
@@ -558,6 +558,14 @@ lpfc_cmpl_ct_cmd_rsnn_nn(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
558 return; 558 return;
559} 559}
560 560
561static void
562lpfc_cmpl_ct_cmd_rff_id(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
563 struct lpfc_iocbq * rspiocb)
564{
565 lpfc_cmpl_ct_cmd_rft_id(phba, cmdiocb, rspiocb);
566 return;
567}
568
561void 569void
562lpfc_get_hba_sym_node_name(struct lpfc_hba * phba, uint8_t * symbp) 570lpfc_get_hba_sym_node_name(struct lpfc_hba * phba, uint8_t * symbp)
563{ 571{
@@ -629,6 +637,8 @@ lpfc_ns_cmd(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp, int cmdcode)
629 bpl->tus.f.bdeSize = RNN_REQUEST_SZ; 637 bpl->tus.f.bdeSize = RNN_REQUEST_SZ;
630 else if (cmdcode == SLI_CTNS_RSNN_NN) 638 else if (cmdcode == SLI_CTNS_RSNN_NN)
631 bpl->tus.f.bdeSize = RSNN_REQUEST_SZ; 639 bpl->tus.f.bdeSize = RSNN_REQUEST_SZ;
640 else if (cmdcode == SLI_CTNS_RFF_ID)
641 bpl->tus.f.bdeSize = RFF_REQUEST_SZ;
632 else 642 else
633 bpl->tus.f.bdeSize = 0; 643 bpl->tus.f.bdeSize = 0;
634 bpl->tus.w = le32_to_cpu(bpl->tus.w); 644 bpl->tus.w = le32_to_cpu(bpl->tus.w);
@@ -660,6 +670,17 @@ lpfc_ns_cmd(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp, int cmdcode)
660 cmpl = lpfc_cmpl_ct_cmd_rft_id; 670 cmpl = lpfc_cmpl_ct_cmd_rft_id;
661 break; 671 break;
662 672
673 case SLI_CTNS_RFF_ID:
674 CtReq->CommandResponse.bits.CmdRsp =
675 be16_to_cpu(SLI_CTNS_RFF_ID);
676 CtReq->un.rff.PortId = be32_to_cpu(phba->fc_myDID);
677 CtReq->un.rff.feature_res = 0;
678 CtReq->un.rff.feature_tgt = 0;
679 CtReq->un.rff.type_code = FC_FCP_DATA;
680 CtReq->un.rff.feature_init = 1;
681 cmpl = lpfc_cmpl_ct_cmd_rff_id;
682 break;
683
663 case SLI_CTNS_RNN_ID: 684 case SLI_CTNS_RNN_ID:
664 CtReq->CommandResponse.bits.CmdRsp = 685 CtReq->CommandResponse.bits.CmdRsp =
665 be16_to_cpu(SLI_CTNS_RNN_ID); 686 be16_to_cpu(SLI_CTNS_RNN_ID);
@@ -934,7 +955,8 @@ lpfc_fdmi_cmd(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp, int cmdcode)
934 ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); 955 ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size);
935 ae->ad.bits.AttrType = be16_to_cpu(OS_NAME_VERSION); 956 ae->ad.bits.AttrType = be16_to_cpu(OS_NAME_VERSION);
936 sprintf(ae->un.OsNameVersion, "%s %s %s", 957 sprintf(ae->un.OsNameVersion, "%s %s %s",
937 init_utsname()->sysname, init_utsname()->release, 958 init_utsname()->sysname,
959 init_utsname()->release,
938 init_utsname()->version); 960 init_utsname()->version);
939 len = strlen(ae->un.OsNameVersion); 961 len = strlen(ae->un.OsNameVersion);
940 len += (len & 3) ? (4 - (len & 3)) : 4; 962 len += (len & 3) ? (4 - (len & 3)) : 4;
diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index 71864cdc6c71..a5f33a0dd4e7 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -243,6 +243,7 @@ lpfc_cmpl_els_flogi_fabric(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp,
243 struct serv_parm *sp, IOCB_t *irsp) 243 struct serv_parm *sp, IOCB_t *irsp)
244{ 244{
245 LPFC_MBOXQ_t *mbox; 245 LPFC_MBOXQ_t *mbox;
246 struct lpfc_dmabuf *mp;
246 int rc; 247 int rc;
247 248
248 spin_lock_irq(phba->host->host_lock); 249 spin_lock_irq(phba->host->host_lock);
@@ -307,10 +308,14 @@ lpfc_cmpl_els_flogi_fabric(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp,
307 308
308 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT | MBX_STOP_IOCB); 309 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT | MBX_STOP_IOCB);
309 if (rc == MBX_NOT_FINISHED) 310 if (rc == MBX_NOT_FINISHED)
310 goto fail_free_mbox; 311 goto fail_issue_reg_login;
311 312
312 return 0; 313 return 0;
313 314
315 fail_issue_reg_login:
316 mp = (struct lpfc_dmabuf *) mbox->context1;
317 lpfc_mbuf_free(phba, mp->virt, mp->phys);
318 kfree(mp);
314 fail_free_mbox: 319 fail_free_mbox:
315 mempool_free(mbox, phba->mbox_mem_pool); 320 mempool_free(mbox, phba->mbox_mem_pool);
316 fail: 321 fail:
@@ -657,6 +662,12 @@ lpfc_plogi_confirm_nport(struct lpfc_hba * phba, struct lpfc_dmabuf *prsp,
657 uint8_t name[sizeof (struct lpfc_name)]; 662 uint8_t name[sizeof (struct lpfc_name)];
658 uint32_t rc; 663 uint32_t rc;
659 664
665 /* Fabric nodes can have the same WWPN so we don't bother searching
666 * by WWPN. Just return the ndlp that was given to us.
667 */
668 if (ndlp->nlp_type & NLP_FABRIC)
669 return ndlp;
670
660 lp = (uint32_t *) prsp->virt; 671 lp = (uint32_t *) prsp->virt;
661 sp = (struct serv_parm *) ((uint8_t *) lp + sizeof (uint32_t)); 672 sp = (struct serv_parm *) ((uint8_t *) lp + sizeof (uint32_t));
662 memset(name, 0, sizeof (struct lpfc_name)); 673 memset(name, 0, sizeof (struct lpfc_name));
@@ -1122,7 +1133,7 @@ lpfc_cmpl_els_adisc(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
1122 mempool_free(mbox, 1133 mempool_free(mbox,
1123 phba->mbox_mem_pool); 1134 phba->mbox_mem_pool);
1124 lpfc_disc_flush_list(phba); 1135 lpfc_disc_flush_list(phba);
1125 psli->ring[(psli->ip_ring)]. 1136 psli->ring[(psli->extra_ring)].
1126 flag &= 1137 flag &=
1127 ~LPFC_STOP_IOCB_EVENT; 1138 ~LPFC_STOP_IOCB_EVENT;
1128 psli->ring[(psli->fcp_ring)]. 1139 psli->ring[(psli->fcp_ring)].
@@ -1851,6 +1862,7 @@ lpfc_cmpl_els_acc(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
1851 IOCB_t *irsp; 1862 IOCB_t *irsp;
1852 struct lpfc_nodelist *ndlp; 1863 struct lpfc_nodelist *ndlp;
1853 LPFC_MBOXQ_t *mbox = NULL; 1864 LPFC_MBOXQ_t *mbox = NULL;
1865 struct lpfc_dmabuf *mp;
1854 1866
1855 irsp = &rspiocb->iocb; 1867 irsp = &rspiocb->iocb;
1856 1868
@@ -1862,6 +1874,11 @@ lpfc_cmpl_els_acc(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
1862 /* Check to see if link went down during discovery */ 1874 /* Check to see if link went down during discovery */
1863 if ((lpfc_els_chk_latt(phba)) || !ndlp) { 1875 if ((lpfc_els_chk_latt(phba)) || !ndlp) {
1864 if (mbox) { 1876 if (mbox) {
1877 mp = (struct lpfc_dmabuf *) mbox->context1;
1878 if (mp) {
1879 lpfc_mbuf_free(phba, mp->virt, mp->phys);
1880 kfree(mp);
1881 }
1865 mempool_free( mbox, phba->mbox_mem_pool); 1882 mempool_free( mbox, phba->mbox_mem_pool);
1866 } 1883 }
1867 goto out; 1884 goto out;
@@ -1893,9 +1910,7 @@ lpfc_cmpl_els_acc(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
1893 } 1910 }
1894 /* NOTE: we should have messages for unsuccessful 1911 /* NOTE: we should have messages for unsuccessful
1895 reglogin */ 1912 reglogin */
1896 mempool_free( mbox, phba->mbox_mem_pool);
1897 } else { 1913 } else {
1898 mempool_free( mbox, phba->mbox_mem_pool);
1899 /* Do not call NO_LIST for lpfc_els_abort'ed ELS cmds */ 1914 /* Do not call NO_LIST for lpfc_els_abort'ed ELS cmds */
1900 if (!((irsp->ulpStatus == IOSTAT_LOCAL_REJECT) && 1915 if (!((irsp->ulpStatus == IOSTAT_LOCAL_REJECT) &&
1901 ((irsp->un.ulpWord[4] == IOERR_SLI_ABORTED) || 1916 ((irsp->un.ulpWord[4] == IOERR_SLI_ABORTED) ||
@@ -1907,6 +1922,12 @@ lpfc_cmpl_els_acc(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
1907 } 1922 }
1908 } 1923 }
1909 } 1924 }
1925 mp = (struct lpfc_dmabuf *) mbox->context1;
1926 if (mp) {
1927 lpfc_mbuf_free(phba, mp->virt, mp->phys);
1928 kfree(mp);
1929 }
1930 mempool_free(mbox, phba->mbox_mem_pool);
1910 } 1931 }
1911out: 1932out:
1912 if (ndlp) { 1933 if (ndlp) {
@@ -2644,6 +2665,7 @@ lpfc_els_handle_rscn(struct lpfc_hba * phba)
2644 ndlp->nlp_type |= NLP_FABRIC; 2665 ndlp->nlp_type |= NLP_FABRIC;
2645 ndlp->nlp_prev_state = ndlp->nlp_state; 2666 ndlp->nlp_prev_state = ndlp->nlp_state;
2646 ndlp->nlp_state = NLP_STE_PLOGI_ISSUE; 2667 ndlp->nlp_state = NLP_STE_PLOGI_ISSUE;
2668 lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST);
2647 lpfc_issue_els_plogi(phba, NameServer_DID, 0); 2669 lpfc_issue_els_plogi(phba, NameServer_DID, 0);
2648 /* Wait for NameServer login cmpl before we can 2670 /* Wait for NameServer login cmpl before we can
2649 continue */ 2671 continue */
@@ -3039,7 +3061,7 @@ lpfc_els_rcv_farp(struct lpfc_hba * phba,
3039 /* FARP-REQ received from DID <did> */ 3061 /* FARP-REQ received from DID <did> */
3040 lpfc_printf_log(phba, 3062 lpfc_printf_log(phba,
3041 KERN_INFO, 3063 KERN_INFO,
3042 LOG_IP, 3064 LOG_ELS,
3043 "%d:0601 FARP-REQ received from DID x%x\n", 3065 "%d:0601 FARP-REQ received from DID x%x\n",
3044 phba->brd_no, did); 3066 phba->brd_no, did);
3045 3067
@@ -3101,7 +3123,7 @@ lpfc_els_rcv_farpr(struct lpfc_hba * phba,
3101 /* FARP-RSP received from DID <did> */ 3123 /* FARP-RSP received from DID <did> */
3102 lpfc_printf_log(phba, 3124 lpfc_printf_log(phba,
3103 KERN_INFO, 3125 KERN_INFO,
3104 LOG_IP, 3126 LOG_ELS,
3105 "%d:0600 FARP-RSP received from DID x%x\n", 3127 "%d:0600 FARP-RSP received from DID x%x\n",
3106 phba->brd_no, did); 3128 phba->brd_no, did);
3107 3129
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
index 19c79a0549a7..c39564e85e94 100644
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
@@ -525,7 +525,7 @@ lpfc_mbx_cmpl_clear_la(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
525 psli = &phba->sli; 525 psli = &phba->sli;
526 mb = &pmb->mb; 526 mb = &pmb->mb;
527 /* Since we don't do discovery right now, turn these off here */ 527 /* Since we don't do discovery right now, turn these off here */
528 psli->ring[psli->ip_ring].flag &= ~LPFC_STOP_IOCB_EVENT; 528 psli->ring[psli->extra_ring].flag &= ~LPFC_STOP_IOCB_EVENT;
529 psli->ring[psli->fcp_ring].flag &= ~LPFC_STOP_IOCB_EVENT; 529 psli->ring[psli->fcp_ring].flag &= ~LPFC_STOP_IOCB_EVENT;
530 psli->ring[psli->next_ring].flag &= ~LPFC_STOP_IOCB_EVENT; 530 psli->ring[psli->next_ring].flag &= ~LPFC_STOP_IOCB_EVENT;
531 531
@@ -641,7 +641,7 @@ out:
641 if (rc == MBX_NOT_FINISHED) { 641 if (rc == MBX_NOT_FINISHED) {
642 mempool_free(pmb, phba->mbox_mem_pool); 642 mempool_free(pmb, phba->mbox_mem_pool);
643 lpfc_disc_flush_list(phba); 643 lpfc_disc_flush_list(phba);
644 psli->ring[(psli->ip_ring)].flag &= ~LPFC_STOP_IOCB_EVENT; 644 psli->ring[(psli->extra_ring)].flag &= ~LPFC_STOP_IOCB_EVENT;
645 psli->ring[(psli->fcp_ring)].flag &= ~LPFC_STOP_IOCB_EVENT; 645 psli->ring[(psli->fcp_ring)].flag &= ~LPFC_STOP_IOCB_EVENT;
646 psli->ring[(psli->next_ring)].flag &= ~LPFC_STOP_IOCB_EVENT; 646 psli->ring[(psli->next_ring)].flag &= ~LPFC_STOP_IOCB_EVENT;
647 phba->hba_state = LPFC_HBA_READY; 647 phba->hba_state = LPFC_HBA_READY;
@@ -672,6 +672,8 @@ lpfc_mbx_cmpl_read_sparam(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
672 672
673 memcpy((uint8_t *) & phba->fc_sparam, (uint8_t *) mp->virt, 673 memcpy((uint8_t *) & phba->fc_sparam, (uint8_t *) mp->virt,
674 sizeof (struct serv_parm)); 674 sizeof (struct serv_parm));
675 if (phba->cfg_soft_wwnn)
676 u64_to_wwn(phba->cfg_soft_wwnn, phba->fc_sparam.nodeName.u.wwn);
675 if (phba->cfg_soft_wwpn) 677 if (phba->cfg_soft_wwpn)
676 u64_to_wwn(phba->cfg_soft_wwpn, phba->fc_sparam.portName.u.wwn); 678 u64_to_wwn(phba->cfg_soft_wwpn, phba->fc_sparam.portName.u.wwn);
677 memcpy((uint8_t *) & phba->fc_nodename, 679 memcpy((uint8_t *) & phba->fc_nodename,
@@ -696,7 +698,7 @@ out:
696 == MBX_NOT_FINISHED) { 698 == MBX_NOT_FINISHED) {
697 mempool_free( pmb, phba->mbox_mem_pool); 699 mempool_free( pmb, phba->mbox_mem_pool);
698 lpfc_disc_flush_list(phba); 700 lpfc_disc_flush_list(phba);
699 psli->ring[(psli->ip_ring)].flag &= 701 psli->ring[(psli->extra_ring)].flag &=
700 ~LPFC_STOP_IOCB_EVENT; 702 ~LPFC_STOP_IOCB_EVENT;
701 psli->ring[(psli->fcp_ring)].flag &= 703 psli->ring[(psli->fcp_ring)].flag &=
702 ~LPFC_STOP_IOCB_EVENT; 704 ~LPFC_STOP_IOCB_EVENT;
@@ -715,6 +717,9 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la)
715{ 717{
716 int i; 718 int i;
717 LPFC_MBOXQ_t *sparam_mbox, *cfglink_mbox; 719 LPFC_MBOXQ_t *sparam_mbox, *cfglink_mbox;
720 struct lpfc_dmabuf *mp;
721 int rc;
722
718 sparam_mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); 723 sparam_mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
719 cfglink_mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); 724 cfglink_mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
720 725
@@ -793,16 +798,27 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la)
793 if (sparam_mbox) { 798 if (sparam_mbox) {
794 lpfc_read_sparam(phba, sparam_mbox); 799 lpfc_read_sparam(phba, sparam_mbox);
795 sparam_mbox->mbox_cmpl = lpfc_mbx_cmpl_read_sparam; 800 sparam_mbox->mbox_cmpl = lpfc_mbx_cmpl_read_sparam;
796 lpfc_sli_issue_mbox(phba, sparam_mbox, 801 rc = lpfc_sli_issue_mbox(phba, sparam_mbox,
797 (MBX_NOWAIT | MBX_STOP_IOCB)); 802 (MBX_NOWAIT | MBX_STOP_IOCB));
803 if (rc == MBX_NOT_FINISHED) {
804 mp = (struct lpfc_dmabuf *) sparam_mbox->context1;
805 lpfc_mbuf_free(phba, mp->virt, mp->phys);
806 kfree(mp);
807 mempool_free(sparam_mbox, phba->mbox_mem_pool);
808 if (cfglink_mbox)
809 mempool_free(cfglink_mbox, phba->mbox_mem_pool);
810 return;
811 }
798 } 812 }
799 813
800 if (cfglink_mbox) { 814 if (cfglink_mbox) {
801 phba->hba_state = LPFC_LOCAL_CFG_LINK; 815 phba->hba_state = LPFC_LOCAL_CFG_LINK;
802 lpfc_config_link(phba, cfglink_mbox); 816 lpfc_config_link(phba, cfglink_mbox);
803 cfglink_mbox->mbox_cmpl = lpfc_mbx_cmpl_local_config_link; 817 cfglink_mbox->mbox_cmpl = lpfc_mbx_cmpl_local_config_link;
804 lpfc_sli_issue_mbox(phba, cfglink_mbox, 818 rc = lpfc_sli_issue_mbox(phba, cfglink_mbox,
805 (MBX_NOWAIT | MBX_STOP_IOCB)); 819 (MBX_NOWAIT | MBX_STOP_IOCB));
820 if (rc == MBX_NOT_FINISHED)
821 mempool_free(cfglink_mbox, phba->mbox_mem_pool);
806 } 822 }
807} 823}
808 824
@@ -1067,6 +1083,7 @@ lpfc_mbx_cmpl_ns_reg_login(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
1067 lpfc_ns_cmd(phba, ndlp, SLI_CTNS_RNN_ID); 1083 lpfc_ns_cmd(phba, ndlp, SLI_CTNS_RNN_ID);
1068 lpfc_ns_cmd(phba, ndlp, SLI_CTNS_RSNN_NN); 1084 lpfc_ns_cmd(phba, ndlp, SLI_CTNS_RSNN_NN);
1069 lpfc_ns_cmd(phba, ndlp, SLI_CTNS_RFT_ID); 1085 lpfc_ns_cmd(phba, ndlp, SLI_CTNS_RFT_ID);
1086 lpfc_ns_cmd(phba, ndlp, SLI_CTNS_RFF_ID);
1070 } 1087 }
1071 1088
1072 phba->fc_ns_retry = 0; 1089 phba->fc_ns_retry = 0;
@@ -1423,7 +1440,7 @@ lpfc_check_sli_ndlp(struct lpfc_hba * phba,
1423 if (iocb->context1 == (uint8_t *) ndlp) 1440 if (iocb->context1 == (uint8_t *) ndlp)
1424 return 1; 1441 return 1;
1425 } 1442 }
1426 } else if (pring->ringno == psli->ip_ring) { 1443 } else if (pring->ringno == psli->extra_ring) {
1427 1444
1428 } else if (pring->ringno == psli->fcp_ring) { 1445 } else if (pring->ringno == psli->fcp_ring) {
1429 /* Skip match check if waiting to relogin to FCP target */ 1446 /* Skip match check if waiting to relogin to FCP target */
@@ -1680,112 +1697,38 @@ lpfc_matchdid(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp, uint32_t did)
1680struct lpfc_nodelist * 1697struct lpfc_nodelist *
1681lpfc_findnode_did(struct lpfc_hba * phba, uint32_t order, uint32_t did) 1698lpfc_findnode_did(struct lpfc_hba * phba, uint32_t order, uint32_t did)
1682{ 1699{
1683 struct lpfc_nodelist *ndlp, *next_ndlp; 1700 struct lpfc_nodelist *ndlp;
1701 struct list_head *lists[]={&phba->fc_nlpunmap_list,
1702 &phba->fc_nlpmap_list,
1703 &phba->fc_plogi_list,
1704 &phba->fc_adisc_list,
1705 &phba->fc_reglogin_list,
1706 &phba->fc_prli_list,
1707 &phba->fc_npr_list,
1708 &phba->fc_unused_list};
1709 uint32_t search[]={NLP_SEARCH_UNMAPPED,
1710 NLP_SEARCH_MAPPED,
1711 NLP_SEARCH_PLOGI,
1712 NLP_SEARCH_ADISC,
1713 NLP_SEARCH_REGLOGIN,
1714 NLP_SEARCH_PRLI,
1715 NLP_SEARCH_NPR,
1716 NLP_SEARCH_UNUSED};
1717 int i;
1684 uint32_t data1; 1718 uint32_t data1;
1685 1719
1686 spin_lock_irq(phba->host->host_lock); 1720 spin_lock_irq(phba->host->host_lock);
1687 if (order & NLP_SEARCH_UNMAPPED) { 1721 for (i = 0; i < ARRAY_SIZE(lists); i++ ) {
1688 list_for_each_entry_safe(ndlp, next_ndlp, 1722 if (!(order & search[i]))
1689 &phba->fc_nlpunmap_list, nlp_listp) { 1723 continue;
1690 if (lpfc_matchdid(phba, ndlp, did)) { 1724 list_for_each_entry(ndlp, lists[i], nlp_listp) {
1691 data1 = (((uint32_t) ndlp->nlp_state << 24) |
1692 ((uint32_t) ndlp->nlp_xri << 16) |
1693 ((uint32_t) ndlp->nlp_type << 8) |
1694 ((uint32_t) ndlp->nlp_rpi & 0xff));
1695 /* FIND node DID unmapped */
1696 lpfc_printf_log(phba, KERN_INFO, LOG_NODE,
1697 "%d:0929 FIND node DID unmapped"
1698 " Data: x%p x%x x%x x%x\n",
1699 phba->brd_no,
1700 ndlp, ndlp->nlp_DID,
1701 ndlp->nlp_flag, data1);
1702 spin_unlock_irq(phba->host->host_lock);
1703 return ndlp;
1704 }
1705 }
1706 }
1707
1708 if (order & NLP_SEARCH_MAPPED) {
1709 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_nlpmap_list,
1710 nlp_listp) {
1711 if (lpfc_matchdid(phba, ndlp, did)) {
1712
1713 data1 = (((uint32_t) ndlp->nlp_state << 24) |
1714 ((uint32_t) ndlp->nlp_xri << 16) |
1715 ((uint32_t) ndlp->nlp_type << 8) |
1716 ((uint32_t) ndlp->nlp_rpi & 0xff));
1717 /* FIND node DID mapped */
1718 lpfc_printf_log(phba, KERN_INFO, LOG_NODE,
1719 "%d:0930 FIND node DID mapped "
1720 "Data: x%p x%x x%x x%x\n",
1721 phba->brd_no,
1722 ndlp, ndlp->nlp_DID,
1723 ndlp->nlp_flag, data1);
1724 spin_unlock_irq(phba->host->host_lock);
1725 return ndlp;
1726 }
1727 }
1728 }
1729
1730 if (order & NLP_SEARCH_PLOGI) {
1731 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_plogi_list,
1732 nlp_listp) {
1733 if (lpfc_matchdid(phba, ndlp, did)) {
1734
1735 data1 = (((uint32_t) ndlp->nlp_state << 24) |
1736 ((uint32_t) ndlp->nlp_xri << 16) |
1737 ((uint32_t) ndlp->nlp_type << 8) |
1738 ((uint32_t) ndlp->nlp_rpi & 0xff));
1739 /* LOG change to PLOGI */
1740 /* FIND node DID plogi */
1741 lpfc_printf_log(phba, KERN_INFO, LOG_NODE,
1742 "%d:0908 FIND node DID plogi "
1743 "Data: x%p x%x x%x x%x\n",
1744 phba->brd_no,
1745 ndlp, ndlp->nlp_DID,
1746 ndlp->nlp_flag, data1);
1747 spin_unlock_irq(phba->host->host_lock);
1748 return ndlp;
1749 }
1750 }
1751 }
1752
1753 if (order & NLP_SEARCH_ADISC) {
1754 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_adisc_list,
1755 nlp_listp) {
1756 if (lpfc_matchdid(phba, ndlp, did)) {
1757
1758 data1 = (((uint32_t) ndlp->nlp_state << 24) |
1759 ((uint32_t) ndlp->nlp_xri << 16) |
1760 ((uint32_t) ndlp->nlp_type << 8) |
1761 ((uint32_t) ndlp->nlp_rpi & 0xff));
1762 /* LOG change to ADISC */
1763 /* FIND node DID adisc */
1764 lpfc_printf_log(phba, KERN_INFO, LOG_NODE,
1765 "%d:0931 FIND node DID adisc "
1766 "Data: x%p x%x x%x x%x\n",
1767 phba->brd_no,
1768 ndlp, ndlp->nlp_DID,
1769 ndlp->nlp_flag, data1);
1770 spin_unlock_irq(phba->host->host_lock);
1771 return ndlp;
1772 }
1773 }
1774 }
1775
1776 if (order & NLP_SEARCH_REGLOGIN) {
1777 list_for_each_entry_safe(ndlp, next_ndlp,
1778 &phba->fc_reglogin_list, nlp_listp) {
1779 if (lpfc_matchdid(phba, ndlp, did)) { 1725 if (lpfc_matchdid(phba, ndlp, did)) {
1780
1781 data1 = (((uint32_t) ndlp->nlp_state << 24) | 1726 data1 = (((uint32_t) ndlp->nlp_state << 24) |
1782 ((uint32_t) ndlp->nlp_xri << 16) | 1727 ((uint32_t) ndlp->nlp_xri << 16) |
1783 ((uint32_t) ndlp->nlp_type << 8) | 1728 ((uint32_t) ndlp->nlp_type << 8) |
1784 ((uint32_t) ndlp->nlp_rpi & 0xff)); 1729 ((uint32_t) ndlp->nlp_rpi & 0xff));
1785 /* LOG change to REGLOGIN */
1786 /* FIND node DID reglogin */
1787 lpfc_printf_log(phba, KERN_INFO, LOG_NODE, 1730 lpfc_printf_log(phba, KERN_INFO, LOG_NODE,
1788 "%d:0901 FIND node DID reglogin" 1731 "%d:0929 FIND node DID "
1789 " Data: x%p x%x x%x x%x\n", 1732 " Data: x%p x%x x%x x%x\n",
1790 phba->brd_no, 1733 phba->brd_no,
1791 ndlp, ndlp->nlp_DID, 1734 ndlp, ndlp->nlp_DID,
@@ -1795,86 +1738,12 @@ lpfc_findnode_did(struct lpfc_hba * phba, uint32_t order, uint32_t did)
1795 } 1738 }
1796 } 1739 }
1797 } 1740 }
1798
1799 if (order & NLP_SEARCH_PRLI) {
1800 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_prli_list,
1801 nlp_listp) {
1802 if (lpfc_matchdid(phba, ndlp, did)) {
1803
1804 data1 = (((uint32_t) ndlp->nlp_state << 24) |
1805 ((uint32_t) ndlp->nlp_xri << 16) |
1806 ((uint32_t) ndlp->nlp_type << 8) |
1807 ((uint32_t) ndlp->nlp_rpi & 0xff));
1808 /* LOG change to PRLI */
1809 /* FIND node DID prli */
1810 lpfc_printf_log(phba, KERN_INFO, LOG_NODE,
1811 "%d:0902 FIND node DID prli "
1812 "Data: x%p x%x x%x x%x\n",
1813 phba->brd_no,
1814 ndlp, ndlp->nlp_DID,
1815 ndlp->nlp_flag, data1);
1816 spin_unlock_irq(phba->host->host_lock);
1817 return ndlp;
1818 }
1819 }
1820 }
1821
1822 if (order & NLP_SEARCH_NPR) {
1823 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_npr_list,
1824 nlp_listp) {
1825 if (lpfc_matchdid(phba, ndlp, did)) {
1826
1827 data1 = (((uint32_t) ndlp->nlp_state << 24) |
1828 ((uint32_t) ndlp->nlp_xri << 16) |
1829 ((uint32_t) ndlp->nlp_type << 8) |
1830 ((uint32_t) ndlp->nlp_rpi & 0xff));
1831 /* LOG change to NPR */
1832 /* FIND node DID npr */
1833 lpfc_printf_log(phba, KERN_INFO, LOG_NODE,
1834 "%d:0903 FIND node DID npr "
1835 "Data: x%p x%x x%x x%x\n",
1836 phba->brd_no,
1837 ndlp, ndlp->nlp_DID,
1838 ndlp->nlp_flag, data1);
1839 spin_unlock_irq(phba->host->host_lock);
1840 return ndlp;
1841 }
1842 }
1843 }
1844
1845 if (order & NLP_SEARCH_UNUSED) {
1846 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_adisc_list,
1847 nlp_listp) {
1848 if (lpfc_matchdid(phba, ndlp, did)) {
1849
1850 data1 = (((uint32_t) ndlp->nlp_state << 24) |
1851 ((uint32_t) ndlp->nlp_xri << 16) |
1852 ((uint32_t) ndlp->nlp_type << 8) |
1853 ((uint32_t) ndlp->nlp_rpi & 0xff));
1854 /* LOG change to UNUSED */
1855 /* FIND node DID unused */
1856 lpfc_printf_log(phba, KERN_INFO, LOG_NODE,
1857 "%d:0905 FIND node DID unused "
1858 "Data: x%p x%x x%x x%x\n",
1859 phba->brd_no,
1860 ndlp, ndlp->nlp_DID,
1861 ndlp->nlp_flag, data1);
1862 spin_unlock_irq(phba->host->host_lock);
1863 return ndlp;
1864 }
1865 }
1866 }
1867
1868 spin_unlock_irq(phba->host->host_lock); 1741 spin_unlock_irq(phba->host->host_lock);
1869 1742
1870 /* FIND node did <did> NOT FOUND */ 1743 /* FIND node did <did> NOT FOUND */
1871 lpfc_printf_log(phba, 1744 lpfc_printf_log(phba, KERN_INFO, LOG_NODE,
1872 KERN_INFO,
1873 LOG_NODE,
1874 "%d:0932 FIND node did x%x NOT FOUND Data: x%x\n", 1745 "%d:0932 FIND node did x%x NOT FOUND Data: x%x\n",
1875 phba->brd_no, did, order); 1746 phba->brd_no, did, order);
1876
1877 /* no match found */
1878 return NULL; 1747 return NULL;
1879} 1748}
1880 1749
@@ -2036,7 +1905,7 @@ lpfc_disc_start(struct lpfc_hba * phba)
2036 if (rc == MBX_NOT_FINISHED) { 1905 if (rc == MBX_NOT_FINISHED) {
2037 mempool_free( mbox, phba->mbox_mem_pool); 1906 mempool_free( mbox, phba->mbox_mem_pool);
2038 lpfc_disc_flush_list(phba); 1907 lpfc_disc_flush_list(phba);
2039 psli->ring[(psli->ip_ring)].flag &= 1908 psli->ring[(psli->extra_ring)].flag &=
2040 ~LPFC_STOP_IOCB_EVENT; 1909 ~LPFC_STOP_IOCB_EVENT;
2041 psli->ring[(psli->fcp_ring)].flag &= 1910 psli->ring[(psli->fcp_ring)].flag &=
2042 ~LPFC_STOP_IOCB_EVENT; 1911 ~LPFC_STOP_IOCB_EVENT;
@@ -2415,7 +2284,7 @@ lpfc_disc_timeout_handler(struct lpfc_hba *phba)
2415 2284
2416 if (clrlaerr) { 2285 if (clrlaerr) {
2417 lpfc_disc_flush_list(phba); 2286 lpfc_disc_flush_list(phba);
2418 psli->ring[(psli->ip_ring)].flag &= ~LPFC_STOP_IOCB_EVENT; 2287 psli->ring[(psli->extra_ring)].flag &= ~LPFC_STOP_IOCB_EVENT;
2419 psli->ring[(psli->fcp_ring)].flag &= ~LPFC_STOP_IOCB_EVENT; 2288 psli->ring[(psli->fcp_ring)].flag &= ~LPFC_STOP_IOCB_EVENT;
2420 psli->ring[(psli->next_ring)].flag &= ~LPFC_STOP_IOCB_EVENT; 2289 psli->ring[(psli->next_ring)].flag &= ~LPFC_STOP_IOCB_EVENT;
2421 phba->hba_state = LPFC_HBA_READY; 2290 phba->hba_state = LPFC_HBA_READY;
diff --git a/drivers/scsi/lpfc/lpfc_hw.h b/drivers/scsi/lpfc/lpfc_hw.h
index eedf98801366..f79cb6136906 100644
--- a/drivers/scsi/lpfc/lpfc_hw.h
+++ b/drivers/scsi/lpfc/lpfc_hw.h
@@ -42,14 +42,14 @@
42#define FCELSSIZE 1024 /* maximum ELS transfer size */ 42#define FCELSSIZE 1024 /* maximum ELS transfer size */
43 43
44#define LPFC_FCP_RING 0 /* ring 0 for FCP initiator commands */ 44#define LPFC_FCP_RING 0 /* ring 0 for FCP initiator commands */
45#define LPFC_IP_RING 1 /* ring 1 for IP commands */ 45#define LPFC_EXTRA_RING 1 /* ring 1 for other protocols */
46#define LPFC_ELS_RING 2 /* ring 2 for ELS commands */ 46#define LPFC_ELS_RING 2 /* ring 2 for ELS commands */
47#define LPFC_FCP_NEXT_RING 3 47#define LPFC_FCP_NEXT_RING 3
48 48
49#define SLI2_IOCB_CMD_R0_ENTRIES 172 /* SLI-2 FCP command ring entries */ 49#define SLI2_IOCB_CMD_R0_ENTRIES 172 /* SLI-2 FCP command ring entries */
50#define SLI2_IOCB_RSP_R0_ENTRIES 134 /* SLI-2 FCP response ring entries */ 50#define SLI2_IOCB_RSP_R0_ENTRIES 134 /* SLI-2 FCP response ring entries */
51#define SLI2_IOCB_CMD_R1_ENTRIES 4 /* SLI-2 IP command ring entries */ 51#define SLI2_IOCB_CMD_R1_ENTRIES 4 /* SLI-2 extra command ring entries */
52#define SLI2_IOCB_RSP_R1_ENTRIES 4 /* SLI-2 IP response ring entries */ 52#define SLI2_IOCB_RSP_R1_ENTRIES 4 /* SLI-2 extra response ring entries */
53#define SLI2_IOCB_CMD_R1XTRA_ENTRIES 36 /* SLI-2 extra FCP cmd ring entries */ 53#define SLI2_IOCB_CMD_R1XTRA_ENTRIES 36 /* SLI-2 extra FCP cmd ring entries */
54#define SLI2_IOCB_RSP_R1XTRA_ENTRIES 52 /* SLI-2 extra FCP rsp ring entries */ 54#define SLI2_IOCB_RSP_R1XTRA_ENTRIES 52 /* SLI-2 extra FCP rsp ring entries */
55#define SLI2_IOCB_CMD_R2_ENTRIES 20 /* SLI-2 ELS command ring entries */ 55#define SLI2_IOCB_CMD_R2_ENTRIES 20 /* SLI-2 ELS command ring entries */
@@ -121,6 +121,20 @@ struct lpfc_sli_ct_request {
121 121
122 uint32_t rsvd[7]; 122 uint32_t rsvd[7];
123 } rft; 123 } rft;
124 struct rff {
125 uint32_t PortId;
126 uint8_t reserved[2];
127#ifdef __BIG_ENDIAN_BITFIELD
128 uint8_t feature_res:6;
129 uint8_t feature_init:1;
130 uint8_t feature_tgt:1;
131#else /* __LITTLE_ENDIAN_BITFIELD */
132 uint8_t feature_tgt:1;
133 uint8_t feature_init:1;
134 uint8_t feature_res:6;
135#endif
136 uint8_t type_code; /* type=8 for FCP */
137 } rff;
124 struct rnn { 138 struct rnn {
125 uint32_t PortId; /* For RNN_ID requests */ 139 uint32_t PortId; /* For RNN_ID requests */
126 uint8_t wwnn[8]; 140 uint8_t wwnn[8];
@@ -136,6 +150,7 @@ struct lpfc_sli_ct_request {
136#define SLI_CT_REVISION 1 150#define SLI_CT_REVISION 1
137#define GID_REQUEST_SZ (sizeof(struct lpfc_sli_ct_request) - 260) 151#define GID_REQUEST_SZ (sizeof(struct lpfc_sli_ct_request) - 260)
138#define RFT_REQUEST_SZ (sizeof(struct lpfc_sli_ct_request) - 228) 152#define RFT_REQUEST_SZ (sizeof(struct lpfc_sli_ct_request) - 228)
153#define RFF_REQUEST_SZ (sizeof(struct lpfc_sli_ct_request) - 235)
139#define RNN_REQUEST_SZ (sizeof(struct lpfc_sli_ct_request) - 252) 154#define RNN_REQUEST_SZ (sizeof(struct lpfc_sli_ct_request) - 252)
140#define RSNN_REQUEST_SZ (sizeof(struct lpfc_sli_ct_request)) 155#define RSNN_REQUEST_SZ (sizeof(struct lpfc_sli_ct_request))
141 156
@@ -225,6 +240,7 @@ struct lpfc_sli_ct_request {
225#define SLI_CTNS_RNN_ID 0x0213 240#define SLI_CTNS_RNN_ID 0x0213
226#define SLI_CTNS_RCS_ID 0x0214 241#define SLI_CTNS_RCS_ID 0x0214
227#define SLI_CTNS_RFT_ID 0x0217 242#define SLI_CTNS_RFT_ID 0x0217
243#define SLI_CTNS_RFF_ID 0x021F
228#define SLI_CTNS_RSPN_ID 0x0218 244#define SLI_CTNS_RSPN_ID 0x0218
229#define SLI_CTNS_RPT_ID 0x021A 245#define SLI_CTNS_RPT_ID 0x021A
230#define SLI_CTNS_RIP_NN 0x0235 246#define SLI_CTNS_RIP_NN 0x0235
@@ -1089,12 +1105,6 @@ typedef struct {
1089#define PCI_DEVICE_ID_ZEPHYR_SCSP 0xfe11 1105#define PCI_DEVICE_ID_ZEPHYR_SCSP 0xfe11
1090#define PCI_DEVICE_ID_ZEPHYR_DCSP 0xfe12 1106#define PCI_DEVICE_ID_ZEPHYR_DCSP 0xfe12
1091 1107
1092#define PCI_SUBSYSTEM_ID_LP11000S 0xfc11
1093#define PCI_SUBSYSTEM_ID_LP11002S 0xfc12
1094#define PCI_SUBSYSTEM_ID_LPE11000S 0xfc21
1095#define PCI_SUBSYSTEM_ID_LPE11002S 0xfc22
1096#define PCI_SUBSYSTEM_ID_LPE11010S 0xfc2A
1097
1098#define JEDEC_ID_ADDRESS 0x0080001c 1108#define JEDEC_ID_ADDRESS 0x0080001c
1099#define FIREFLY_JEDEC_ID 0x1ACC 1109#define FIREFLY_JEDEC_ID 0x1ACC
1100#define SUPERFLY_JEDEC_ID 0x0020 1110#define SUPERFLY_JEDEC_ID 0x0020
@@ -1284,6 +1294,10 @@ typedef struct { /* FireFly BIU registers */
1284#define CMD_FCP_IREAD_CX 0x1B 1294#define CMD_FCP_IREAD_CX 0x1B
1285#define CMD_FCP_ICMND_CR 0x1C 1295#define CMD_FCP_ICMND_CR 0x1C
1286#define CMD_FCP_ICMND_CX 0x1D 1296#define CMD_FCP_ICMND_CX 0x1D
1297#define CMD_FCP_TSEND_CX 0x1F
1298#define CMD_FCP_TRECEIVE_CX 0x21
1299#define CMD_FCP_TRSP_CX 0x23
1300#define CMD_FCP_AUTO_TRSP_CX 0x29
1287 1301
1288#define CMD_ADAPTER_MSG 0x20 1302#define CMD_ADAPTER_MSG 0x20
1289#define CMD_ADAPTER_DUMP 0x22 1303#define CMD_ADAPTER_DUMP 0x22
@@ -1310,6 +1324,9 @@ typedef struct { /* FireFly BIU registers */
1310#define CMD_FCP_IREAD64_CX 0x9B 1324#define CMD_FCP_IREAD64_CX 0x9B
1311#define CMD_FCP_ICMND64_CR 0x9C 1325#define CMD_FCP_ICMND64_CR 0x9C
1312#define CMD_FCP_ICMND64_CX 0x9D 1326#define CMD_FCP_ICMND64_CX 0x9D
1327#define CMD_FCP_TSEND64_CX 0x9F
1328#define CMD_FCP_TRECEIVE64_CX 0xA1
1329#define CMD_FCP_TRSP64_CX 0xA3
1313 1330
1314#define CMD_GEN_REQUEST64_CR 0xC2 1331#define CMD_GEN_REQUEST64_CR 0xC2
1315#define CMD_GEN_REQUEST64_CX 0xC3 1332#define CMD_GEN_REQUEST64_CX 0xC3
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index a5723ad0a099..afca45cdbcef 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -268,6 +268,8 @@ lpfc_config_port_post(struct lpfc_hba * phba)
268 kfree(mp); 268 kfree(mp);
269 pmb->context1 = NULL; 269 pmb->context1 = NULL;
270 270
271 if (phba->cfg_soft_wwnn)
272 u64_to_wwn(phba->cfg_soft_wwnn, phba->fc_sparam.nodeName.u.wwn);
271 if (phba->cfg_soft_wwpn) 273 if (phba->cfg_soft_wwpn)
272 u64_to_wwn(phba->cfg_soft_wwpn, phba->fc_sparam.portName.u.wwn); 274 u64_to_wwn(phba->cfg_soft_wwpn, phba->fc_sparam.portName.u.wwn);
273 memcpy(&phba->fc_nodename, &phba->fc_sparam.nodeName, 275 memcpy(&phba->fc_nodename, &phba->fc_sparam.nodeName,
@@ -349,8 +351,8 @@ lpfc_config_port_post(struct lpfc_hba * phba)
349 phba->hba_state = LPFC_LINK_DOWN; 351 phba->hba_state = LPFC_LINK_DOWN;
350 352
351 /* Only process IOCBs on ring 0 till hba_state is READY */ 353 /* Only process IOCBs on ring 0 till hba_state is READY */
352 if (psli->ring[psli->ip_ring].cmdringaddr) 354 if (psli->ring[psli->extra_ring].cmdringaddr)
353 psli->ring[psli->ip_ring].flag |= LPFC_STOP_IOCB_EVENT; 355 psli->ring[psli->extra_ring].flag |= LPFC_STOP_IOCB_EVENT;
354 if (psli->ring[psli->fcp_ring].cmdringaddr) 356 if (psli->ring[psli->fcp_ring].cmdringaddr)
355 psli->ring[psli->fcp_ring].flag |= LPFC_STOP_IOCB_EVENT; 357 psli->ring[psli->fcp_ring].flag |= LPFC_STOP_IOCB_EVENT;
356 if (psli->ring[psli->next_ring].cmdringaddr) 358 if (psli->ring[psli->next_ring].cmdringaddr)
@@ -517,7 +519,8 @@ lpfc_handle_eratt(struct lpfc_hba * phba)
517 struct lpfc_sli_ring *pring; 519 struct lpfc_sli_ring *pring;
518 uint32_t event_data; 520 uint32_t event_data;
519 521
520 if (phba->work_hs & HS_FFER6) { 522 if (phba->work_hs & HS_FFER6 ||
523 phba->work_hs & HS_FFER5) {
521 /* Re-establishing Link */ 524 /* Re-establishing Link */
522 lpfc_printf_log(phba, KERN_INFO, LOG_LINK_EVENT, 525 lpfc_printf_log(phba, KERN_INFO, LOG_LINK_EVENT,
523 "%d:1301 Re-establishing Link " 526 "%d:1301 Re-establishing Link "
@@ -611,7 +614,7 @@ lpfc_handle_latt(struct lpfc_hba * phba)
611 pmb->mbox_cmpl = lpfc_mbx_cmpl_read_la; 614 pmb->mbox_cmpl = lpfc_mbx_cmpl_read_la;
612 rc = lpfc_sli_issue_mbox (phba, pmb, (MBX_NOWAIT | MBX_STOP_IOCB)); 615 rc = lpfc_sli_issue_mbox (phba, pmb, (MBX_NOWAIT | MBX_STOP_IOCB));
613 if (rc == MBX_NOT_FINISHED) 616 if (rc == MBX_NOT_FINISHED)
614 goto lpfc_handle_latt_free_mp; 617 goto lpfc_handle_latt_free_mbuf;
615 618
616 /* Clear Link Attention in HA REG */ 619 /* Clear Link Attention in HA REG */
617 spin_lock_irq(phba->host->host_lock); 620 spin_lock_irq(phba->host->host_lock);
@@ -621,6 +624,8 @@ lpfc_handle_latt(struct lpfc_hba * phba)
621 624
622 return; 625 return;
623 626
627lpfc_handle_latt_free_mbuf:
628 lpfc_mbuf_free(phba, mp->virt, mp->phys);
624lpfc_handle_latt_free_mp: 629lpfc_handle_latt_free_mp:
625 kfree(mp); 630 kfree(mp);
626lpfc_handle_latt_free_pmb: 631lpfc_handle_latt_free_pmb:
@@ -802,19 +807,13 @@ lpfc_get_hba_model_desc(struct lpfc_hba * phba, uint8_t * mdp, uint8_t * descp)
802{ 807{
803 lpfc_vpd_t *vp; 808 lpfc_vpd_t *vp;
804 uint16_t dev_id = phba->pcidev->device; 809 uint16_t dev_id = phba->pcidev->device;
805 uint16_t dev_subid = phba->pcidev->subsystem_device;
806 uint8_t hdrtype;
807 int max_speed; 810 int max_speed;
808 char * ports;
809 struct { 811 struct {
810 char * name; 812 char * name;
811 int max_speed; 813 int max_speed;
812 char * ports;
813 char * bus; 814 char * bus;
814 } m = {"<Unknown>", 0, "", ""}; 815 } m = {"<Unknown>", 0, ""};
815 816
816 pci_read_config_byte(phba->pcidev, PCI_HEADER_TYPE, &hdrtype);
817 ports = (hdrtype == 0x80) ? "2-port " : "";
818 if (mdp && mdp[0] != '\0' 817 if (mdp && mdp[0] != '\0'
819 && descp && descp[0] != '\0') 818 && descp && descp[0] != '\0')
820 return; 819 return;
@@ -834,130 +833,93 @@ lpfc_get_hba_model_desc(struct lpfc_hba * phba, uint8_t * mdp, uint8_t * descp)
834 833
835 switch (dev_id) { 834 switch (dev_id) {
836 case PCI_DEVICE_ID_FIREFLY: 835 case PCI_DEVICE_ID_FIREFLY:
837 m = (typeof(m)){"LP6000", max_speed, "", "PCI"}; 836 m = (typeof(m)){"LP6000", max_speed, "PCI"};
838 break; 837 break;
839 case PCI_DEVICE_ID_SUPERFLY: 838 case PCI_DEVICE_ID_SUPERFLY:
840 if (vp->rev.biuRev >= 1 && vp->rev.biuRev <= 3) 839 if (vp->rev.biuRev >= 1 && vp->rev.biuRev <= 3)
841 m = (typeof(m)){"LP7000", max_speed, "", "PCI"}; 840 m = (typeof(m)){"LP7000", max_speed, "PCI"};
842 else 841 else
843 m = (typeof(m)){"LP7000E", max_speed, "", "PCI"}; 842 m = (typeof(m)){"LP7000E", max_speed, "PCI"};
844 break; 843 break;
845 case PCI_DEVICE_ID_DRAGONFLY: 844 case PCI_DEVICE_ID_DRAGONFLY:
846 m = (typeof(m)){"LP8000", max_speed, "", "PCI"}; 845 m = (typeof(m)){"LP8000", max_speed, "PCI"};
847 break; 846 break;
848 case PCI_DEVICE_ID_CENTAUR: 847 case PCI_DEVICE_ID_CENTAUR:
849 if (FC_JEDEC_ID(vp->rev.biuRev) == CENTAUR_2G_JEDEC_ID) 848 if (FC_JEDEC_ID(vp->rev.biuRev) == CENTAUR_2G_JEDEC_ID)
850 m = (typeof(m)){"LP9002", max_speed, "", "PCI"}; 849 m = (typeof(m)){"LP9002", max_speed, "PCI"};
851 else 850 else
852 m = (typeof(m)){"LP9000", max_speed, "", "PCI"}; 851 m = (typeof(m)){"LP9000", max_speed, "PCI"};
853 break; 852 break;
854 case PCI_DEVICE_ID_RFLY: 853 case PCI_DEVICE_ID_RFLY:
855 m = (typeof(m)){"LP952", max_speed, "", "PCI"}; 854 m = (typeof(m)){"LP952", max_speed, "PCI"};
856 break; 855 break;
857 case PCI_DEVICE_ID_PEGASUS: 856 case PCI_DEVICE_ID_PEGASUS:
858 m = (typeof(m)){"LP9802", max_speed, "", "PCI-X"}; 857 m = (typeof(m)){"LP9802", max_speed, "PCI-X"};
859 break; 858 break;
860 case PCI_DEVICE_ID_THOR: 859 case PCI_DEVICE_ID_THOR:
861 if (hdrtype == 0x80) 860 m = (typeof(m)){"LP10000", max_speed, "PCI-X"};
862 m = (typeof(m)){"LP10000DC",
863 max_speed, ports, "PCI-X"};
864 else
865 m = (typeof(m)){"LP10000",
866 max_speed, ports, "PCI-X"};
867 break; 861 break;
868 case PCI_DEVICE_ID_VIPER: 862 case PCI_DEVICE_ID_VIPER:
869 m = (typeof(m)){"LPX1000", max_speed, "", "PCI-X"}; 863 m = (typeof(m)){"LPX1000", max_speed, "PCI-X"};
870 break; 864 break;
871 case PCI_DEVICE_ID_PFLY: 865 case PCI_DEVICE_ID_PFLY:
872 m = (typeof(m)){"LP982", max_speed, "", "PCI-X"}; 866 m = (typeof(m)){"LP982", max_speed, "PCI-X"};
873 break; 867 break;
874 case PCI_DEVICE_ID_TFLY: 868 case PCI_DEVICE_ID_TFLY:
875 if (hdrtype == 0x80) 869 m = (typeof(m)){"LP1050", max_speed, "PCI-X"};
876 m = (typeof(m)){"LP1050DC", max_speed, ports, "PCI-X"};
877 else
878 m = (typeof(m)){"LP1050", max_speed, ports, "PCI-X"};
879 break; 870 break;
880 case PCI_DEVICE_ID_HELIOS: 871 case PCI_DEVICE_ID_HELIOS:
881 if (hdrtype == 0x80) 872 m = (typeof(m)){"LP11000", max_speed, "PCI-X2"};
882 m = (typeof(m)){"LP11002", max_speed, ports, "PCI-X2"};
883 else
884 m = (typeof(m)){"LP11000", max_speed, ports, "PCI-X2"};
885 break; 873 break;
886 case PCI_DEVICE_ID_HELIOS_SCSP: 874 case PCI_DEVICE_ID_HELIOS_SCSP:
887 m = (typeof(m)){"LP11000-SP", max_speed, ports, "PCI-X2"}; 875 m = (typeof(m)){"LP11000-SP", max_speed, "PCI-X2"};
888 break; 876 break;
889 case PCI_DEVICE_ID_HELIOS_DCSP: 877 case PCI_DEVICE_ID_HELIOS_DCSP:
890 m = (typeof(m)){"LP11002-SP", max_speed, ports, "PCI-X2"}; 878 m = (typeof(m)){"LP11002-SP", max_speed, "PCI-X2"};
891 break; 879 break;
892 case PCI_DEVICE_ID_NEPTUNE: 880 case PCI_DEVICE_ID_NEPTUNE:
893 if (hdrtype == 0x80) 881 m = (typeof(m)){"LPe1000", max_speed, "PCIe"};
894 m = (typeof(m)){"LPe1002", max_speed, ports, "PCIe"};
895 else
896 m = (typeof(m)){"LPe1000", max_speed, ports, "PCIe"};
897 break; 882 break;
898 case PCI_DEVICE_ID_NEPTUNE_SCSP: 883 case PCI_DEVICE_ID_NEPTUNE_SCSP:
899 m = (typeof(m)){"LPe1000-SP", max_speed, ports, "PCIe"}; 884 m = (typeof(m)){"LPe1000-SP", max_speed, "PCIe"};
900 break; 885 break;
901 case PCI_DEVICE_ID_NEPTUNE_DCSP: 886 case PCI_DEVICE_ID_NEPTUNE_DCSP:
902 m = (typeof(m)){"LPe1002-SP", max_speed, ports, "PCIe"}; 887 m = (typeof(m)){"LPe1002-SP", max_speed, "PCIe"};
903 break; 888 break;
904 case PCI_DEVICE_ID_BMID: 889 case PCI_DEVICE_ID_BMID:
905 m = (typeof(m)){"LP1150", max_speed, ports, "PCI-X2"}; 890 m = (typeof(m)){"LP1150", max_speed, "PCI-X2"};
906 break; 891 break;
907 case PCI_DEVICE_ID_BSMB: 892 case PCI_DEVICE_ID_BSMB:
908 m = (typeof(m)){"LP111", max_speed, ports, "PCI-X2"}; 893 m = (typeof(m)){"LP111", max_speed, "PCI-X2"};
909 break; 894 break;
910 case PCI_DEVICE_ID_ZEPHYR: 895 case PCI_DEVICE_ID_ZEPHYR:
911 if (hdrtype == 0x80) 896 m = (typeof(m)){"LPe11000", max_speed, "PCIe"};
912 m = (typeof(m)){"LPe11002", max_speed, ports, "PCIe"};
913 else
914 m = (typeof(m)){"LPe11000", max_speed, ports, "PCIe"};
915 break; 897 break;
916 case PCI_DEVICE_ID_ZEPHYR_SCSP: 898 case PCI_DEVICE_ID_ZEPHYR_SCSP:
917 m = (typeof(m)){"LPe11000", max_speed, ports, "PCIe"}; 899 m = (typeof(m)){"LPe11000", max_speed, "PCIe"};
918 break; 900 break;
919 case PCI_DEVICE_ID_ZEPHYR_DCSP: 901 case PCI_DEVICE_ID_ZEPHYR_DCSP:
920 m = (typeof(m)){"LPe11002-SP", max_speed, ports, "PCIe"}; 902 m = (typeof(m)){"LPe11002-SP", max_speed, "PCIe"};
921 break; 903 break;
922 case PCI_DEVICE_ID_ZMID: 904 case PCI_DEVICE_ID_ZMID:
923 m = (typeof(m)){"LPe1150", max_speed, ports, "PCIe"}; 905 m = (typeof(m)){"LPe1150", max_speed, "PCIe"};
924 break; 906 break;
925 case PCI_DEVICE_ID_ZSMB: 907 case PCI_DEVICE_ID_ZSMB:
926 m = (typeof(m)){"LPe111", max_speed, ports, "PCIe"}; 908 m = (typeof(m)){"LPe111", max_speed, "PCIe"};
927 break; 909 break;
928 case PCI_DEVICE_ID_LP101: 910 case PCI_DEVICE_ID_LP101:
929 m = (typeof(m)){"LP101", max_speed, ports, "PCI-X"}; 911 m = (typeof(m)){"LP101", max_speed, "PCI-X"};
930 break; 912 break;
931 case PCI_DEVICE_ID_LP10000S: 913 case PCI_DEVICE_ID_LP10000S:
932 m = (typeof(m)){"LP10000-S", max_speed, ports, "PCI"}; 914 m = (typeof(m)){"LP10000-S", max_speed, "PCI"};
933 break; 915 break;
934 case PCI_DEVICE_ID_LP11000S: 916 case PCI_DEVICE_ID_LP11000S:
917 m = (typeof(m)){"LP11000-S", max_speed,
918 "PCI-X2"};
919 break;
935 case PCI_DEVICE_ID_LPE11000S: 920 case PCI_DEVICE_ID_LPE11000S:
936 switch (dev_subid) { 921 m = (typeof(m)){"LPe11000-S", max_speed,
937 case PCI_SUBSYSTEM_ID_LP11000S: 922 "PCIe"};
938 m = (typeof(m)){"LP11000-S", max_speed,
939 ports, "PCI-X2"};
940 break;
941 case PCI_SUBSYSTEM_ID_LP11002S:
942 m = (typeof(m)){"LP11002-S", max_speed,
943 ports, "PCI-X2"};
944 break;
945 case PCI_SUBSYSTEM_ID_LPE11000S:
946 m = (typeof(m)){"LPe11000-S", max_speed,
947 ports, "PCIe"};
948 break;
949 case PCI_SUBSYSTEM_ID_LPE11002S:
950 m = (typeof(m)){"LPe11002-S", max_speed,
951 ports, "PCIe"};
952 break;
953 case PCI_SUBSYSTEM_ID_LPE11010S:
954 m = (typeof(m)){"LPe11010-S", max_speed,
955 "10-port ", "PCIe"};
956 break;
957 default:
958 m = (typeof(m)){ NULL };
959 break;
960 }
961 break; 923 break;
962 default: 924 default:
963 m = (typeof(m)){ NULL }; 925 m = (typeof(m)){ NULL };
@@ -968,8 +930,8 @@ lpfc_get_hba_model_desc(struct lpfc_hba * phba, uint8_t * mdp, uint8_t * descp)
968 snprintf(mdp, 79,"%s", m.name); 930 snprintf(mdp, 79,"%s", m.name);
969 if (descp && descp[0] == '\0') 931 if (descp && descp[0] == '\0')
970 snprintf(descp, 255, 932 snprintf(descp, 255,
971 "Emulex %s %dGb %s%s Fibre Channel Adapter", 933 "Emulex %s %dGb %s Fibre Channel Adapter",
972 m.name, m.max_speed, m.ports, m.bus); 934 m.name, m.max_speed, m.bus);
973} 935}
974 936
975/**************************************************/ 937/**************************************************/
@@ -1651,6 +1613,14 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid)
1651 if (error) 1613 if (error)
1652 goto out_remove_host; 1614 goto out_remove_host;
1653 1615
1616 if (phba->cfg_use_msi) {
1617 error = pci_enable_msi(phba->pcidev);
1618 if (error)
1619 lpfc_printf_log(phba, KERN_INFO, LOG_INIT, "%d:0452 "
1620 "Enable MSI failed, continuing with "
1621 "IRQ\n", phba->brd_no);
1622 }
1623
1654 error = request_irq(phba->pcidev->irq, lpfc_intr_handler, IRQF_SHARED, 1624 error = request_irq(phba->pcidev->irq, lpfc_intr_handler, IRQF_SHARED,
1655 LPFC_DRIVER_NAME, phba); 1625 LPFC_DRIVER_NAME, phba);
1656 if (error) { 1626 if (error) {
@@ -1730,6 +1700,7 @@ out_free_irq:
1730 lpfc_stop_timer(phba); 1700 lpfc_stop_timer(phba);
1731 phba->work_hba_events = 0; 1701 phba->work_hba_events = 0;
1732 free_irq(phba->pcidev->irq, phba); 1702 free_irq(phba->pcidev->irq, phba);
1703 pci_disable_msi(phba->pcidev);
1733out_free_sysfs_attr: 1704out_free_sysfs_attr:
1734 lpfc_free_sysfs_attr(phba); 1705 lpfc_free_sysfs_attr(phba);
1735out_remove_host: 1706out_remove_host:
@@ -1796,6 +1767,7 @@ lpfc_pci_remove_one(struct pci_dev *pdev)
1796 1767
1797 /* Release the irq reservation */ 1768 /* Release the irq reservation */
1798 free_irq(phba->pcidev->irq, phba); 1769 free_irq(phba->pcidev->irq, phba);
1770 pci_disable_msi(phba->pcidev);
1799 1771
1800 lpfc_cleanup(phba, 0); 1772 lpfc_cleanup(phba, 0);
1801 lpfc_stop_timer(phba); 1773 lpfc_stop_timer(phba);
diff --git a/drivers/scsi/lpfc/lpfc_logmsg.h b/drivers/scsi/lpfc/lpfc_logmsg.h
index 62c8ca862e9e..438cbcd9eb13 100644
--- a/drivers/scsi/lpfc/lpfc_logmsg.h
+++ b/drivers/scsi/lpfc/lpfc_logmsg.h
@@ -28,7 +28,7 @@
28#define LOG_NODE 0x80 /* Node table events */ 28#define LOG_NODE 0x80 /* Node table events */
29#define LOG_MISC 0x400 /* Miscellaneous events */ 29#define LOG_MISC 0x400 /* Miscellaneous events */
30#define LOG_SLI 0x800 /* SLI events */ 30#define LOG_SLI 0x800 /* SLI events */
31#define LOG_CHK_COND 0x1000 /* FCP Check condition flag */ 31#define LOG_FCP_ERROR 0x1000 /* log errors, not underruns */
32#define LOG_LIBDFC 0x2000 /* Libdfc events */ 32#define LOG_LIBDFC 0x2000 /* Libdfc events */
33#define LOG_ALL_MSG 0xffff /* LOG all messages */ 33#define LOG_ALL_MSG 0xffff /* LOG all messages */
34 34
diff --git a/drivers/scsi/lpfc/lpfc_nportdisc.c b/drivers/scsi/lpfc/lpfc_nportdisc.c
index d5f415007db2..0c7e731dc45a 100644
--- a/drivers/scsi/lpfc/lpfc_nportdisc.c
+++ b/drivers/scsi/lpfc/lpfc_nportdisc.c
@@ -739,7 +739,7 @@ lpfc_cmpl_plogi_plogi_issue(struct lpfc_hba * phba,
739 uint32_t evt) 739 uint32_t evt)
740{ 740{
741 struct lpfc_iocbq *cmdiocb, *rspiocb; 741 struct lpfc_iocbq *cmdiocb, *rspiocb;
742 struct lpfc_dmabuf *pcmd, *prsp; 742 struct lpfc_dmabuf *pcmd, *prsp, *mp;
743 uint32_t *lp; 743 uint32_t *lp;
744 IOCB_t *irsp; 744 IOCB_t *irsp;
745 struct serv_parm *sp; 745 struct serv_parm *sp;
@@ -829,6 +829,9 @@ lpfc_cmpl_plogi_plogi_issue(struct lpfc_hba * phba,
829 NLP_REGLOGIN_LIST); 829 NLP_REGLOGIN_LIST);
830 return ndlp->nlp_state; 830 return ndlp->nlp_state;
831 } 831 }
832 mp = (struct lpfc_dmabuf *)mbox->context1;
833 lpfc_mbuf_free(phba, mp->virt, mp->phys);
834 kfree(mp);
832 mempool_free(mbox, phba->mbox_mem_pool); 835 mempool_free(mbox, phba->mbox_mem_pool);
833 } else { 836 } else {
834 mempool_free(mbox, phba->mbox_mem_pool); 837 mempool_free(mbox, phba->mbox_mem_pool);
@@ -1620,8 +1623,8 @@ lpfc_rcv_padisc_npr_node(struct lpfc_hba * phba,
1620 * or discovery in progress for this node. Starting discovery 1623 * or discovery in progress for this node. Starting discovery
1621 * here will affect the counting of discovery threads. 1624 * here will affect the counting of discovery threads.
1622 */ 1625 */
1623 if ((!(ndlp->nlp_flag & NLP_DELAY_TMO)) && 1626 if (!(ndlp->nlp_flag & NLP_DELAY_TMO) &&
1624 (ndlp->nlp_flag & NLP_NPR_2B_DISC)){ 1627 !(ndlp->nlp_flag & NLP_NPR_2B_DISC)){
1625 if (ndlp->nlp_flag & NLP_NPR_ADISC) { 1628 if (ndlp->nlp_flag & NLP_NPR_ADISC) {
1626 ndlp->nlp_prev_state = NLP_STE_NPR_NODE; 1629 ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
1627 ndlp->nlp_state = NLP_STE_ADISC_ISSUE; 1630 ndlp->nlp_state = NLP_STE_ADISC_ISSUE;
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index 97ae98dc95d0..c3e68e0d8f74 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -297,8 +297,10 @@ lpfc_handle_fcp_err(struct lpfc_scsi_buf *lpfc_cmd)
297 uint32_t fcpi_parm = lpfc_cmd->cur_iocbq.iocb.un.fcpi.fcpi_parm; 297 uint32_t fcpi_parm = lpfc_cmd->cur_iocbq.iocb.un.fcpi.fcpi_parm;
298 uint32_t resp_info = fcprsp->rspStatus2; 298 uint32_t resp_info = fcprsp->rspStatus2;
299 uint32_t scsi_status = fcprsp->rspStatus3; 299 uint32_t scsi_status = fcprsp->rspStatus3;
300 uint32_t *lp;
300 uint32_t host_status = DID_OK; 301 uint32_t host_status = DID_OK;
301 uint32_t rsplen = 0; 302 uint32_t rsplen = 0;
303 uint32_t logit = LOG_FCP | LOG_FCP_ERROR;
302 304
303 /* 305 /*
304 * If this is a task management command, there is no 306 * If this is a task management command, there is no
@@ -310,10 +312,25 @@ lpfc_handle_fcp_err(struct lpfc_scsi_buf *lpfc_cmd)
310 goto out; 312 goto out;
311 } 313 }
312 314
313 lpfc_printf_log(phba, KERN_WARNING, LOG_FCP, 315 if ((resp_info & SNS_LEN_VALID) && fcprsp->rspSnsLen) {
314 "%d:0730 FCP command failed: RSP " 316 uint32_t snslen = be32_to_cpu(fcprsp->rspSnsLen);
315 "Data: x%x x%x x%x x%x x%x x%x\n", 317 if (snslen > SCSI_SENSE_BUFFERSIZE)
316 phba->brd_no, resp_info, scsi_status, 318 snslen = SCSI_SENSE_BUFFERSIZE;
319
320 if (resp_info & RSP_LEN_VALID)
321 rsplen = be32_to_cpu(fcprsp->rspRspLen);
322 memcpy(cmnd->sense_buffer, &fcprsp->rspInfo0 + rsplen, snslen);
323 }
324 lp = (uint32_t *)cmnd->sense_buffer;
325
326 if (!scsi_status && (resp_info & RESID_UNDER))
327 logit = LOG_FCP;
328
329 lpfc_printf_log(phba, KERN_WARNING, logit,
330 "%d:0730 FCP command x%x failed: x%x SNS x%x x%x "
331 "Data: x%x x%x x%x x%x x%x\n",
332 phba->brd_no, cmnd->cmnd[0], scsi_status,
333 be32_to_cpu(*lp), be32_to_cpu(*(lp + 3)), resp_info,
317 be32_to_cpu(fcprsp->rspResId), 334 be32_to_cpu(fcprsp->rspResId),
318 be32_to_cpu(fcprsp->rspSnsLen), 335 be32_to_cpu(fcprsp->rspSnsLen),
319 be32_to_cpu(fcprsp->rspRspLen), 336 be32_to_cpu(fcprsp->rspRspLen),
@@ -328,14 +345,6 @@ lpfc_handle_fcp_err(struct lpfc_scsi_buf *lpfc_cmd)
328 } 345 }
329 } 346 }
330 347
331 if ((resp_info & SNS_LEN_VALID) && fcprsp->rspSnsLen) {
332 uint32_t snslen = be32_to_cpu(fcprsp->rspSnsLen);
333 if (snslen > SCSI_SENSE_BUFFERSIZE)
334 snslen = SCSI_SENSE_BUFFERSIZE;
335
336 memcpy(cmnd->sense_buffer, &fcprsp->rspInfo0 + rsplen, snslen);
337 }
338
339 cmnd->resid = 0; 348 cmnd->resid = 0;
340 if (resp_info & RESID_UNDER) { 349 if (resp_info & RESID_UNDER) {
341 cmnd->resid = be32_to_cpu(fcprsp->rspResId); 350 cmnd->resid = be32_to_cpu(fcprsp->rspResId);
@@ -378,7 +387,7 @@ lpfc_handle_fcp_err(struct lpfc_scsi_buf *lpfc_cmd)
378 */ 387 */
379 } else if ((scsi_status == SAM_STAT_GOOD) && fcpi_parm && 388 } else if ((scsi_status == SAM_STAT_GOOD) && fcpi_parm &&
380 (cmnd->sc_data_direction == DMA_FROM_DEVICE)) { 389 (cmnd->sc_data_direction == DMA_FROM_DEVICE)) {
381 lpfc_printf_log(phba, KERN_WARNING, LOG_FCP, 390 lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_FCP_ERROR,
382 "%d:0734 FCP Read Check Error Data: " 391 "%d:0734 FCP Read Check Error Data: "
383 "x%x x%x x%x x%x\n", phba->brd_no, 392 "x%x x%x x%x x%x\n", phba->brd_no,
384 be32_to_cpu(fcpcmd->fcpDl), 393 be32_to_cpu(fcpcmd->fcpDl),
@@ -670,6 +679,9 @@ lpfc_scsi_tgt_reset(struct lpfc_scsi_buf * lpfc_cmd, struct lpfc_hba * phba,
670 struct lpfc_iocbq *iocbqrsp; 679 struct lpfc_iocbq *iocbqrsp;
671 int ret; 680 int ret;
672 681
682 if (!rdata->pnode)
683 return FAILED;
684
673 lpfc_cmd->rdata = rdata; 685 lpfc_cmd->rdata = rdata;
674 ret = lpfc_scsi_prep_task_mgmt_cmd(phba, lpfc_cmd, lun, 686 ret = lpfc_scsi_prep_task_mgmt_cmd(phba, lpfc_cmd, lun,
675 FCP_TARGET_RESET); 687 FCP_TARGET_RESET);
@@ -976,20 +988,34 @@ lpfc_reset_lun_handler(struct scsi_cmnd *cmnd)
976 988
977 lpfc_block_error_handler(cmnd); 989 lpfc_block_error_handler(cmnd);
978 spin_lock_irq(shost->host_lock); 990 spin_lock_irq(shost->host_lock);
991 loopcnt = 0;
979 /* 992 /*
980 * If target is not in a MAPPED state, delay the reset until 993 * If target is not in a MAPPED state, delay the reset until
981 * target is rediscovered or devloss timeout expires. 994 * target is rediscovered or devloss timeout expires.
982 */ 995 */
983 while ( 1 ) { 996 while ( 1 ) {
984 if (!pnode) 997 if (!pnode)
985 break; 998 return FAILED;
986 999
987 if (pnode->nlp_state != NLP_STE_MAPPED_NODE) { 1000 if (pnode->nlp_state != NLP_STE_MAPPED_NODE) {
988 spin_unlock_irq(phba->host->host_lock); 1001 spin_unlock_irq(phba->host->host_lock);
989 schedule_timeout_uninterruptible(msecs_to_jiffies(500)); 1002 schedule_timeout_uninterruptible(msecs_to_jiffies(500));
990 spin_lock_irq(phba->host->host_lock); 1003 spin_lock_irq(phba->host->host_lock);
1004 loopcnt++;
1005 rdata = cmnd->device->hostdata;
1006 if (!rdata ||
1007 (loopcnt > ((phba->cfg_devloss_tmo * 2) + 1))) {
1008 lpfc_printf_log(phba, KERN_ERR, LOG_FCP,
1009 "%d:0721 LUN Reset rport failure:"
1010 " cnt x%x rdata x%p\n",
1011 phba->brd_no, loopcnt, rdata);
1012 goto out;
1013 }
1014 pnode = rdata->pnode;
1015 if (!pnode)
1016 return FAILED;
991 } 1017 }
992 if ((pnode) && (pnode->nlp_state == NLP_STE_MAPPED_NODE)) 1018 if (pnode->nlp_state == NLP_STE_MAPPED_NODE)
993 break; 1019 break;
994 } 1020 }
995 1021
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index 582f5ea4e84e..a4128e19338a 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -117,6 +117,10 @@ lpfc_sli_iocb_cmd_type(uint8_t iocb_cmnd)
117 case CMD_FCP_IREAD_CX: 117 case CMD_FCP_IREAD_CX:
118 case CMD_FCP_ICMND_CR: 118 case CMD_FCP_ICMND_CR:
119 case CMD_FCP_ICMND_CX: 119 case CMD_FCP_ICMND_CX:
120 case CMD_FCP_TSEND_CX:
121 case CMD_FCP_TRSP_CX:
122 case CMD_FCP_TRECEIVE_CX:
123 case CMD_FCP_AUTO_TRSP_CX:
120 case CMD_ADAPTER_MSG: 124 case CMD_ADAPTER_MSG:
121 case CMD_ADAPTER_DUMP: 125 case CMD_ADAPTER_DUMP:
122 case CMD_XMIT_SEQUENCE64_CR: 126 case CMD_XMIT_SEQUENCE64_CR:
@@ -131,6 +135,9 @@ lpfc_sli_iocb_cmd_type(uint8_t iocb_cmnd)
131 case CMD_FCP_IREAD64_CX: 135 case CMD_FCP_IREAD64_CX:
132 case CMD_FCP_ICMND64_CR: 136 case CMD_FCP_ICMND64_CR:
133 case CMD_FCP_ICMND64_CX: 137 case CMD_FCP_ICMND64_CX:
138 case CMD_FCP_TSEND64_CX:
139 case CMD_FCP_TRSP64_CX:
140 case CMD_FCP_TRECEIVE64_CX:
134 case CMD_GEN_REQUEST64_CR: 141 case CMD_GEN_REQUEST64_CR:
135 case CMD_GEN_REQUEST64_CX: 142 case CMD_GEN_REQUEST64_CX:
136 case CMD_XMIT_ELS_RSP64_CX: 143 case CMD_XMIT_ELS_RSP64_CX:
@@ -1098,6 +1105,7 @@ lpfc_sli_handle_fast_ring_event(struct lpfc_hba * phba,
1098 lpfc_sli_pcimem_bcopy((uint32_t *) entry, 1105 lpfc_sli_pcimem_bcopy((uint32_t *) entry,
1099 (uint32_t *) &rspiocbq.iocb, 1106 (uint32_t *) &rspiocbq.iocb,
1100 sizeof (IOCB_t)); 1107 sizeof (IOCB_t));
1108 INIT_LIST_HEAD(&(rspiocbq.list));
1101 irsp = &rspiocbq.iocb; 1109 irsp = &rspiocbq.iocb;
1102 1110
1103 type = lpfc_sli_iocb_cmd_type(irsp->ulpCommand & CMD_IOCB_MASK); 1111 type = lpfc_sli_iocb_cmd_type(irsp->ulpCommand & CMD_IOCB_MASK);
@@ -1149,6 +1157,11 @@ lpfc_sli_handle_fast_ring_event(struct lpfc_hba * phba,
1149 } 1157 }
1150 } 1158 }
1151 break; 1159 break;
1160 case LPFC_UNSOL_IOCB:
1161 spin_unlock_irqrestore(phba->host->host_lock, iflag);
1162 lpfc_sli_process_unsol_iocb(phba, pring, &rspiocbq);
1163 spin_lock_irqsave(phba->host->host_lock, iflag);
1164 break;
1152 default: 1165 default:
1153 if (irsp->ulpCommand == CMD_ADAPTER_MSG) { 1166 if (irsp->ulpCommand == CMD_ADAPTER_MSG) {
1154 char adaptermsg[LPFC_MAX_ADPTMSG]; 1167 char adaptermsg[LPFC_MAX_ADPTMSG];
@@ -2472,13 +2485,17 @@ lpfc_extra_ring_setup( struct lpfc_hba *phba)
2472 psli = &phba->sli; 2485 psli = &phba->sli;
2473 2486
2474 /* Adjust cmd/rsp ring iocb entries more evenly */ 2487 /* Adjust cmd/rsp ring iocb entries more evenly */
2488
2489 /* Take some away from the FCP ring */
2475 pring = &psli->ring[psli->fcp_ring]; 2490 pring = &psli->ring[psli->fcp_ring];
2476 pring->numCiocb -= SLI2_IOCB_CMD_R1XTRA_ENTRIES; 2491 pring->numCiocb -= SLI2_IOCB_CMD_R1XTRA_ENTRIES;
2477 pring->numRiocb -= SLI2_IOCB_RSP_R1XTRA_ENTRIES; 2492 pring->numRiocb -= SLI2_IOCB_RSP_R1XTRA_ENTRIES;
2478 pring->numCiocb -= SLI2_IOCB_CMD_R3XTRA_ENTRIES; 2493 pring->numCiocb -= SLI2_IOCB_CMD_R3XTRA_ENTRIES;
2479 pring->numRiocb -= SLI2_IOCB_RSP_R3XTRA_ENTRIES; 2494 pring->numRiocb -= SLI2_IOCB_RSP_R3XTRA_ENTRIES;
2480 2495
2481 pring = &psli->ring[1]; 2496 /* and give them to the extra ring */
2497 pring = &psli->ring[psli->extra_ring];
2498
2482 pring->numCiocb += SLI2_IOCB_CMD_R1XTRA_ENTRIES; 2499 pring->numCiocb += SLI2_IOCB_CMD_R1XTRA_ENTRIES;
2483 pring->numRiocb += SLI2_IOCB_RSP_R1XTRA_ENTRIES; 2500 pring->numRiocb += SLI2_IOCB_RSP_R1XTRA_ENTRIES;
2484 pring->numCiocb += SLI2_IOCB_CMD_R3XTRA_ENTRIES; 2501 pring->numCiocb += SLI2_IOCB_CMD_R3XTRA_ENTRIES;
@@ -2488,8 +2505,8 @@ lpfc_extra_ring_setup( struct lpfc_hba *phba)
2488 pring->iotag_max = 4096; 2505 pring->iotag_max = 4096;
2489 pring->num_mask = 1; 2506 pring->num_mask = 1;
2490 pring->prt[0].profile = 0; /* Mask 0 */ 2507 pring->prt[0].profile = 0; /* Mask 0 */
2491 pring->prt[0].rctl = FC_UNSOL_DATA; 2508 pring->prt[0].rctl = phba->cfg_multi_ring_rctl;
2492 pring->prt[0].type = 5; 2509 pring->prt[0].type = phba->cfg_multi_ring_type;
2493 pring->prt[0].lpfc_sli_rcv_unsol_event = NULL; 2510 pring->prt[0].lpfc_sli_rcv_unsol_event = NULL;
2494 return 0; 2511 return 0;
2495} 2512}
@@ -2505,7 +2522,7 @@ lpfc_sli_setup(struct lpfc_hba *phba)
2505 psli->sli_flag = 0; 2522 psli->sli_flag = 0;
2506 psli->fcp_ring = LPFC_FCP_RING; 2523 psli->fcp_ring = LPFC_FCP_RING;
2507 psli->next_ring = LPFC_FCP_NEXT_RING; 2524 psli->next_ring = LPFC_FCP_NEXT_RING;
2508 psli->ip_ring = LPFC_IP_RING; 2525 psli->extra_ring = LPFC_EXTRA_RING;
2509 2526
2510 psli->iocbq_lookup = NULL; 2527 psli->iocbq_lookup = NULL;
2511 psli->iocbq_lookup_len = 0; 2528 psli->iocbq_lookup_len = 0;
@@ -2528,7 +2545,7 @@ lpfc_sli_setup(struct lpfc_hba *phba)
2528 pring->fast_iotag = pring->iotag_max; 2545 pring->fast_iotag = pring->iotag_max;
2529 pring->num_mask = 0; 2546 pring->num_mask = 0;
2530 break; 2547 break;
2531 case LPFC_IP_RING: /* ring 1 - IP */ 2548 case LPFC_EXTRA_RING: /* ring 1 - EXTRA */
2532 /* numCiocb and numRiocb are used in config_port */ 2549 /* numCiocb and numRiocb are used in config_port */
2533 pring->numCiocb = SLI2_IOCB_CMD_R1_ENTRIES; 2550 pring->numCiocb = SLI2_IOCB_CMD_R1_ENTRIES;
2534 pring->numRiocb = SLI2_IOCB_RSP_R1_ENTRIES; 2551 pring->numRiocb = SLI2_IOCB_RSP_R1_ENTRIES;
@@ -3238,6 +3255,21 @@ lpfc_intr_handler(int irq, void *dev_id)
3238 lpfc_sli_handle_fast_ring_event(phba, 3255 lpfc_sli_handle_fast_ring_event(phba,
3239 &phba->sli.ring[LPFC_FCP_RING], 3256 &phba->sli.ring[LPFC_FCP_RING],
3240 status); 3257 status);
3258
3259 if (phba->cfg_multi_ring_support == 2) {
3260 /*
3261 * Process all events on extra ring. Take the optimized path
3262 * for extra ring IO. Any other IO is slow path and is handled
3263 * by the worker thread.
3264 */
3265 status = (ha_copy & (HA_RXMASK << (4*LPFC_EXTRA_RING)));
3266 status >>= (4*LPFC_EXTRA_RING);
3267 if (status & HA_RXATT) {
3268 lpfc_sli_handle_fast_ring_event(phba,
3269 &phba->sli.ring[LPFC_EXTRA_RING],
3270 status);
3271 }
3272 }
3241 return IRQ_HANDLED; 3273 return IRQ_HANDLED;
3242 3274
3243} /* lpfc_intr_handler */ 3275} /* lpfc_intr_handler */
diff --git a/drivers/scsi/lpfc/lpfc_sli.h b/drivers/scsi/lpfc/lpfc_sli.h
index e26de6809358..a43549959dc7 100644
--- a/drivers/scsi/lpfc/lpfc_sli.h
+++ b/drivers/scsi/lpfc/lpfc_sli.h
@@ -198,7 +198,7 @@ struct lpfc_sli {
198 int fcp_ring; /* ring used for FCP initiator commands */ 198 int fcp_ring; /* ring used for FCP initiator commands */
199 int next_ring; 199 int next_ring;
200 200
201 int ip_ring; /* ring used for IP network drv cmds */ 201 int extra_ring; /* extra ring used for other protocols */
202 202
203 struct lpfc_sli_stat slistat; /* SLI statistical info */ 203 struct lpfc_sli_stat slistat; /* SLI statistical info */
204 struct list_head mboxq; 204 struct list_head mboxq;
diff --git a/drivers/scsi/lpfc/lpfc_version.h b/drivers/scsi/lpfc/lpfc_version.h
index ac417908b407..a61ef3d1e7f1 100644
--- a/drivers/scsi/lpfc/lpfc_version.h
+++ b/drivers/scsi/lpfc/lpfc_version.h
@@ -18,7 +18,7 @@
18 * included with this package. * 18 * included with this package. *
19 *******************************************************************/ 19 *******************************************************************/
20 20
21#define LPFC_DRIVER_VERSION "8.1.10" 21#define LPFC_DRIVER_VERSION "8.1.11"
22 22
23#define LPFC_DRIVER_NAME "lpfc" 23#define LPFC_DRIVER_NAME "lpfc"
24 24
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
index 86099fde1b2a..77d9d3804ccf 100644
--- a/drivers/scsi/megaraid.c
+++ b/drivers/scsi/megaraid.c
@@ -73,10 +73,10 @@ static unsigned short int max_mbox_busy_wait = MBOX_BUSY_WAIT;
73module_param(max_mbox_busy_wait, ushort, 0); 73module_param(max_mbox_busy_wait, ushort, 0);
74MODULE_PARM_DESC(max_mbox_busy_wait, "Maximum wait for mailbox in microseconds if busy (default=MBOX_BUSY_WAIT=10)"); 74MODULE_PARM_DESC(max_mbox_busy_wait, "Maximum wait for mailbox in microseconds if busy (default=MBOX_BUSY_WAIT=10)");
75 75
76#define RDINDOOR(adapter) readl((adapter)->base + 0x20) 76#define RDINDOOR(adapter) readl((adapter)->mmio_base + 0x20)
77#define RDOUTDOOR(adapter) readl((adapter)->base + 0x2C) 77#define RDOUTDOOR(adapter) readl((adapter)->mmio_base + 0x2C)
78#define WRINDOOR(adapter,value) writel(value, (adapter)->base + 0x20) 78#define WRINDOOR(adapter,value) writel(value, (adapter)->mmio_base + 0x20)
79#define WROUTDOOR(adapter,value) writel(value, (adapter)->base + 0x2C) 79#define WROUTDOOR(adapter,value) writel(value, (adapter)->mmio_base + 0x2C)
80 80
81/* 81/*
82 * Global variables 82 * Global variables
@@ -1386,7 +1386,8 @@ megaraid_isr_memmapped(int irq, void *devp)
1386 1386
1387 handled = 1; 1387 handled = 1;
1388 1388
1389 while( RDINDOOR(adapter) & 0x02 ) cpu_relax(); 1389 while( RDINDOOR(adapter) & 0x02 )
1390 cpu_relax();
1390 1391
1391 mega_cmd_done(adapter, completed, nstatus, status); 1392 mega_cmd_done(adapter, completed, nstatus, status);
1392 1393
@@ -4668,6 +4669,8 @@ megaraid_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
4668 host->host_no, mega_baseport, irq); 4669 host->host_no, mega_baseport, irq);
4669 4670
4670 adapter->base = mega_baseport; 4671 adapter->base = mega_baseport;
4672 if (flag & BOARD_MEMMAP)
4673 adapter->mmio_base = (void __iomem *) mega_baseport;
4671 4674
4672 INIT_LIST_HEAD(&adapter->free_list); 4675 INIT_LIST_HEAD(&adapter->free_list);
4673 INIT_LIST_HEAD(&adapter->pending_list); 4676 INIT_LIST_HEAD(&adapter->pending_list);
diff --git a/drivers/scsi/megaraid.h b/drivers/scsi/megaraid.h
index 66529f11d23c..c6e74643abe2 100644
--- a/drivers/scsi/megaraid.h
+++ b/drivers/scsi/megaraid.h
@@ -801,7 +801,8 @@ typedef struct {
801 clustering is available */ 801 clustering is available */
802 u32 flag; 802 u32 flag;
803 803
804 unsigned long base; 804 unsigned long base;
805 void __iomem *mmio_base;
805 806
806 /* mbox64 with mbox not aligned on 16-byte boundry */ 807 /* mbox64 with mbox not aligned on 16-byte boundry */
807 mbox64_t *una_mbox64; 808 mbox64_t *una_mbox64;
diff --git a/drivers/scsi/megaraid/megaraid_sas.c b/drivers/scsi/megaraid/megaraid_sas.c
index 7e4262f2af96..046223b4ae57 100644
--- a/drivers/scsi/megaraid/megaraid_sas.c
+++ b/drivers/scsi/megaraid/megaraid_sas.c
@@ -517,7 +517,7 @@ megasas_make_sgl64(struct megasas_instance *instance, struct scsi_cmnd *scp,
517 * Returns the number of frames required for numnber of sge's (sge_count) 517 * Returns the number of frames required for numnber of sge's (sge_count)
518 */ 518 */
519 519
520u32 megasas_get_frame_count(u8 sge_count) 520static u32 megasas_get_frame_count(u8 sge_count)
521{ 521{
522 int num_cnt; 522 int num_cnt;
523 int sge_bytes; 523 int sge_bytes;
@@ -1733,7 +1733,7 @@ megasas_get_ctrl_info(struct megasas_instance *instance,
1733 * 1733 *
1734 * Tasklet to complete cmds 1734 * Tasklet to complete cmds
1735 */ 1735 */
1736void megasas_complete_cmd_dpc(unsigned long instance_addr) 1736static void megasas_complete_cmd_dpc(unsigned long instance_addr)
1737{ 1737{
1738 u32 producer; 1738 u32 producer;
1739 u32 consumer; 1739 u32 consumer;
diff --git a/drivers/scsi/ncr53c8xx.c b/drivers/scsi/ncr53c8xx.c
index 6cc2bc2f62be..bbf521cbc55d 100644
--- a/drivers/scsi/ncr53c8xx.c
+++ b/drivers/scsi/ncr53c8xx.c
@@ -185,7 +185,7 @@ static inline struct list_head *ncr_list_pop(struct list_head *head)
185** power of 2 cache line size. 185** power of 2 cache line size.
186** Enhanced in linux-2.3.44 to provide a memory pool 186** Enhanced in linux-2.3.44 to provide a memory pool
187** per pcidev to support dynamic dma mapping. (I would 187** per pcidev to support dynamic dma mapping. (I would
188** have preferred a real bus astraction, btw). 188** have preferred a real bus abstraction, btw).
189** 189**
190**========================================================== 190**==========================================================
191*/ 191*/
@@ -589,10 +589,12 @@ static int __map_scsi_sg_data(struct device *dev, struct scsi_cmnd *cmd)
589static struct ncr_driver_setup 589static struct ncr_driver_setup
590 driver_setup = SCSI_NCR_DRIVER_SETUP; 590 driver_setup = SCSI_NCR_DRIVER_SETUP;
591 591
592#ifndef MODULE
592#ifdef SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT 593#ifdef SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT
593static struct ncr_driver_setup 594static struct ncr_driver_setup
594 driver_safe_setup __initdata = SCSI_NCR_DRIVER_SAFE_SETUP; 595 driver_safe_setup __initdata = SCSI_NCR_DRIVER_SAFE_SETUP;
595#endif 596#endif
597#endif /* !MODULE */
596 598
597#define initverbose (driver_setup.verbose) 599#define initverbose (driver_setup.verbose)
598#define bootverbose (np->verbose) 600#define bootverbose (np->verbose)
@@ -641,6 +643,13 @@ static struct ncr_driver_setup
641#define OPT_IARB 26 643#define OPT_IARB 26
642#endif 644#endif
643 645
646#ifdef MODULE
647#define ARG_SEP ' '
648#else
649#define ARG_SEP ','
650#endif
651
652#ifndef MODULE
644static char setup_token[] __initdata = 653static char setup_token[] __initdata =
645 "tags:" "mpar:" 654 "tags:" "mpar:"
646 "spar:" "disc:" 655 "spar:" "disc:"
@@ -660,12 +669,6 @@ static char setup_token[] __initdata =
660#endif 669#endif
661 ; /* DONNOT REMOVE THIS ';' */ 670 ; /* DONNOT REMOVE THIS ';' */
662 671
663#ifdef MODULE
664#define ARG_SEP ' '
665#else
666#define ARG_SEP ','
667#endif
668
669static int __init get_setup_token(char *p) 672static int __init get_setup_token(char *p)
670{ 673{
671 char *cur = setup_token; 674 char *cur = setup_token;
@@ -682,7 +685,6 @@ static int __init get_setup_token(char *p)
682 return 0; 685 return 0;
683} 686}
684 687
685
686static int __init sym53c8xx__setup(char *str) 688static int __init sym53c8xx__setup(char *str)
687{ 689{
688#ifdef SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT 690#ifdef SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT
@@ -804,6 +806,7 @@ static int __init sym53c8xx__setup(char *str)
804#endif /* SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT */ 806#endif /* SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT */
805 return 1; 807 return 1;
806} 808}
809#endif /* !MODULE */
807 810
808/*=================================================================== 811/*===================================================================
809** 812**
@@ -1438,7 +1441,7 @@ struct head {
1438** The first four bytes (scr_st[4]) are used inside the script by 1441** The first four bytes (scr_st[4]) are used inside the script by
1439** "COPY" commands. 1442** "COPY" commands.
1440** Because source and destination must have the same alignment 1443** Because source and destination must have the same alignment
1441** in a DWORD, the fields HAVE to be at the choosen offsets. 1444** in a DWORD, the fields HAVE to be at the chosen offsets.
1442** xerr_st 0 (0x34) scratcha 1445** xerr_st 0 (0x34) scratcha
1443** sync_st 1 (0x05) sxfer 1446** sync_st 1 (0x05) sxfer
1444** wide_st 3 (0x03) scntl3 1447** wide_st 3 (0x03) scntl3
@@ -1498,7 +1501,7 @@ struct head {
1498** the DSA (data structure address) register points 1501** the DSA (data structure address) register points
1499** to this substructure of the ccb. 1502** to this substructure of the ccb.
1500** This substructure contains the header with 1503** This substructure contains the header with
1501** the script-processor-changable data and 1504** the script-processor-changeable data and
1502** data blocks for the indirect move commands. 1505** data blocks for the indirect move commands.
1503** 1506**
1504**---------------------------------------------------------- 1507**----------------------------------------------------------
@@ -5107,7 +5110,7 @@ void ncr_complete (struct ncb *np, struct ccb *cp)
5107 5110
5108/* 5111/*
5109** This CCB has been skipped by the NCR. 5112** This CCB has been skipped by the NCR.
5110** Queue it in the correponding unit queue. 5113** Queue it in the corresponding unit queue.
5111*/ 5114*/
5112static void ncr_ccb_skipped(struct ncb *np, struct ccb *cp) 5115static void ncr_ccb_skipped(struct ncb *np, struct ccb *cp)
5113{ 5116{
@@ -5896,8 +5899,8 @@ static void ncr_log_hard_error(struct ncb *np, u16 sist, u_char dstat)
5896** 5899**
5897** In normal cases, interrupt conditions occur one at a 5900** In normal cases, interrupt conditions occur one at a
5898** time. The ncr is able to stack in some extra registers 5901** time. The ncr is able to stack in some extra registers
5899** other interrupts that will occurs after the first one. 5902** other interrupts that will occur after the first one.
5900** But severall interrupts may occur at the same time. 5903** But, several interrupts may occur at the same time.
5901** 5904**
5902** We probably should only try to deal with the normal 5905** We probably should only try to deal with the normal
5903** case, but it seems that multiple interrupts occur in 5906** case, but it seems that multiple interrupts occur in
@@ -6796,7 +6799,7 @@ void ncr_int_sir (struct ncb *np)
6796** The host status field is set to HS_NEGOTIATE to mark this 6799** The host status field is set to HS_NEGOTIATE to mark this
6797** situation. 6800** situation.
6798** 6801**
6799** If the target doesn't answer this message immidiately 6802** If the target doesn't answer this message immediately
6800** (as required by the standard), the SIR_NEGO_FAIL interrupt 6803** (as required by the standard), the SIR_NEGO_FAIL interrupt
6801** will be raised eventually. 6804** will be raised eventually.
6802** The handler removes the HS_NEGOTIATE status, and sets the 6805** The handler removes the HS_NEGOTIATE status, and sets the
@@ -8321,12 +8324,12 @@ char *ncr53c8xx; /* command line passed by insmod */
8321module_param(ncr53c8xx, charp, 0); 8324module_param(ncr53c8xx, charp, 0);
8322#endif 8325#endif
8323 8326
8327#ifndef MODULE
8324static int __init ncr53c8xx_setup(char *str) 8328static int __init ncr53c8xx_setup(char *str)
8325{ 8329{
8326 return sym53c8xx__setup(str); 8330 return sym53c8xx__setup(str);
8327} 8331}
8328 8332
8329#ifndef MODULE
8330__setup("ncr53c8xx=", ncr53c8xx_setup); 8333__setup("ncr53c8xx=", ncr53c8xx_setup);
8331#endif 8334#endif
8332 8335
diff --git a/drivers/scsi/ncr53c8xx.h b/drivers/scsi/ncr53c8xx.h
index cb8b7701431e..b39357d9af8d 100644
--- a/drivers/scsi/ncr53c8xx.h
+++ b/drivers/scsi/ncr53c8xx.h
@@ -218,7 +218,7 @@
218** Same as option 1, but also deal with 218** Same as option 1, but also deal with
219** misconfigured interrupts. 219** misconfigured interrupts.
220** 220**
221** - Edge triggerred instead of level sensitive. 221** - Edge triggered instead of level sensitive.
222** - No interrupt line connected. 222** - No interrupt line connected.
223** - IRQ number misconfigured. 223** - IRQ number misconfigured.
224** 224**
@@ -549,7 +549,7 @@ struct ncr_driver_setup {
549 549
550/* 550/*
551** Initial setup. 551** Initial setup.
552** Can be overriden at startup by a command line. 552** Can be overridden at startup by a command line.
553*/ 553*/
554#define SCSI_NCR_DRIVER_SETUP \ 554#define SCSI_NCR_DRIVER_SETUP \
555{ \ 555{ \
@@ -1093,7 +1093,7 @@ struct scr_tblsel {
1093**----------------------------------------------------------- 1093**-----------------------------------------------------------
1094** On 810A, 860, 825A, 875, 895 and 896 chips the content 1094** On 810A, 860, 825A, 875, 895 and 896 chips the content
1095** of SFBR register can be used as data (SCR_SFBR_DATA). 1095** of SFBR register can be used as data (SCR_SFBR_DATA).
1096** The 896 has additionnal IO registers starting at 1096** The 896 has additional IO registers starting at
1097** offset 0x80. Bit 7 of register offset is stored in 1097** offset 0x80. Bit 7 of register offset is stored in
1098** bit 7 of the SCRIPTS instruction first DWORD. 1098** bit 7 of the SCRIPTS instruction first DWORD.
1099**----------------------------------------------------------- 1099**-----------------------------------------------------------
diff --git a/drivers/scsi/oktagon_esp.c b/drivers/scsi/oktagon_esp.c
index dd67a68c5c23..c116a6ae3c54 100644
--- a/drivers/scsi/oktagon_esp.c
+++ b/drivers/scsi/oktagon_esp.c
@@ -72,12 +72,12 @@ static void dma_advance_sg(Scsi_Cmnd *);
72static int oktagon_notify_reboot(struct notifier_block *this, unsigned long code, void *x); 72static int oktagon_notify_reboot(struct notifier_block *this, unsigned long code, void *x);
73 73
74#ifdef USE_BOTTOM_HALF 74#ifdef USE_BOTTOM_HALF
75static void dma_commit(void *opaque); 75static void dma_commit(struct work_struct *unused);
76 76
77long oktag_to_io(long *paddr, long *addr, long len); 77long oktag_to_io(long *paddr, long *addr, long len);
78long oktag_from_io(long *addr, long *paddr, long len); 78long oktag_from_io(long *addr, long *paddr, long len);
79 79
80static DECLARE_WORK(tq_fake_dma, dma_commit, NULL); 80static DECLARE_WORK(tq_fake_dma, dma_commit);
81 81
82#define DMA_MAXTRANSFER 0x8000 82#define DMA_MAXTRANSFER 0x8000
83 83
@@ -266,7 +266,7 @@ oktagon_notify_reboot(struct notifier_block *this, unsigned long code, void *x)
266 */ 266 */
267 267
268 268
269static void dma_commit(void *opaque) 269static void dma_commit(struct work_struct *unused)
270{ 270{
271 long wait,len2,pos; 271 long wait,len2,pos;
272 struct NCR_ESP *esp; 272 struct NCR_ESP *esp;
diff --git a/drivers/scsi/pcmcia/aha152x_stub.c b/drivers/scsi/pcmcia/aha152x_stub.c
index ee449b29fc82..aad362ba02e0 100644
--- a/drivers/scsi/pcmcia/aha152x_stub.c
+++ b/drivers/scsi/pcmcia/aha152x_stub.c
@@ -154,16 +154,11 @@ static int aha152x_config_cs(struct pcmcia_device *link)
154 154
155 DEBUG(0, "aha152x_config(0x%p)\n", link); 155 DEBUG(0, "aha152x_config(0x%p)\n", link);
156 156
157 tuple.DesiredTuple = CISTPL_CONFIG;
158 tuple.TupleData = tuple_data; 157 tuple.TupleData = tuple_data;
159 tuple.TupleDataMax = 64; 158 tuple.TupleDataMax = 64;
160 tuple.TupleOffset = 0; 159 tuple.TupleOffset = 0;
161 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
162 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
163 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
164 link->conf.ConfigBase = parse.config.base;
165
166 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 160 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
161 tuple.Attributes = 0;
167 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 162 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
168 while (1) { 163 while (1) {
169 if (pcmcia_get_tuple_data(link, &tuple) != 0 || 164 if (pcmcia_get_tuple_data(link, &tuple) != 0 ||
diff --git a/drivers/scsi/pcmcia/fdomain_stub.c b/drivers/scsi/pcmcia/fdomain_stub.c
index 85f7ffac19a0..a1c5f265069f 100644
--- a/drivers/scsi/pcmcia/fdomain_stub.c
+++ b/drivers/scsi/pcmcia/fdomain_stub.c
@@ -136,14 +136,9 @@ static int fdomain_config(struct pcmcia_device *link)
136 136
137 DEBUG(0, "fdomain_config(0x%p)\n", link); 137 DEBUG(0, "fdomain_config(0x%p)\n", link);
138 138
139 tuple.DesiredTuple = CISTPL_CONFIG;
140 tuple.TupleData = tuple_data; 139 tuple.TupleData = tuple_data;
141 tuple.TupleDataMax = 64; 140 tuple.TupleDataMax = 64;
142 tuple.TupleOffset = 0; 141 tuple.TupleOffset = 0;
143 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
144 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
145 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
146 link->conf.ConfigBase = parse.config.base;
147 142
148 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 143 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
149 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 144 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c
index f2d79c3f0b8e..d72df5dae4ee 100644
--- a/drivers/scsi/pcmcia/nsp_cs.c
+++ b/drivers/scsi/pcmcia/nsp_cs.c
@@ -1685,16 +1685,10 @@ static int nsp_cs_config(struct pcmcia_device *link)
1685 1685
1686 nsp_dbg(NSP_DEBUG_INIT, "in"); 1686 nsp_dbg(NSP_DEBUG_INIT, "in");
1687 1687
1688 tuple.DesiredTuple = CISTPL_CONFIG;
1689 tuple.Attributes = 0; 1688 tuple.Attributes = 0;
1690 tuple.TupleData = tuple_data; 1689 tuple.TupleData = tuple_data;
1691 tuple.TupleDataMax = sizeof(tuple_data); 1690 tuple.TupleDataMax = sizeof(tuple_data);
1692 tuple.TupleOffset = 0; 1691 tuple.TupleOffset = 0;
1693 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
1694 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
1695 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
1696 link->conf.ConfigBase = parse.config.base;
1697 link->conf.Present = parse.config.rmask[0];
1698 1692
1699 /* Look up the current Vcc */ 1693 /* Look up the current Vcc */
1700 CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link, &conf)); 1694 CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link, &conf));
diff --git a/drivers/scsi/pcmcia/qlogic_stub.c b/drivers/scsi/pcmcia/qlogic_stub.c
index 86c2ac6ae623..9d431fe7f47f 100644
--- a/drivers/scsi/pcmcia/qlogic_stub.c
+++ b/drivers/scsi/pcmcia/qlogic_stub.c
@@ -208,18 +208,11 @@ static int qlogic_config(struct pcmcia_device * link)
208 208
209 DEBUG(0, "qlogic_config(0x%p)\n", link); 209 DEBUG(0, "qlogic_config(0x%p)\n", link);
210 210
211 info->manf_id = link->manf_id;
212
211 tuple.TupleData = (cisdata_t *) tuple_data; 213 tuple.TupleData = (cisdata_t *) tuple_data;
212 tuple.TupleDataMax = 64; 214 tuple.TupleDataMax = 64;
213 tuple.TupleOffset = 0; 215 tuple.TupleOffset = 0;
214 tuple.DesiredTuple = CISTPL_CONFIG;
215 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
216 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
217 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
218 link->conf.ConfigBase = parse.config.base;
219
220 tuple.DesiredTuple = CISTPL_MANFID;
221 if ((pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) && (pcmcia_get_tuple_data(link, &tuple) == CS_SUCCESS))
222 info->manf_id = le16_to_cpu(tuple.TupleData[0]);
223 216
224 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 217 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
225 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 218 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c
index 72fe5d055de1..fb7acea60286 100644
--- a/drivers/scsi/pcmcia/sym53c500_cs.c
+++ b/drivers/scsi/pcmcia/sym53c500_cs.c
@@ -722,19 +722,11 @@ SYM53C500_config(struct pcmcia_device *link)
722 722
723 DEBUG(0, "SYM53C500_config(0x%p)\n", link); 723 DEBUG(0, "SYM53C500_config(0x%p)\n", link);
724 724
725 info->manf_id = link->manf_id;
726
725 tuple.TupleData = (cisdata_t *)tuple_data; 727 tuple.TupleData = (cisdata_t *)tuple_data;
726 tuple.TupleDataMax = 64; 728 tuple.TupleDataMax = 64;
727 tuple.TupleOffset = 0; 729 tuple.TupleOffset = 0;
728 tuple.DesiredTuple = CISTPL_CONFIG;
729 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
730 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
731 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
732 link->conf.ConfigBase = parse.config.base;
733
734 tuple.DesiredTuple = CISTPL_MANFID;
735 if ((pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) &&
736 (pcmcia_get_tuple_data(link, &tuple) == CS_SUCCESS))
737 info->manf_id = le16_to_cpu(tuple.TupleData[0]);
738 730
739 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 731 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
740 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 732 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
diff --git a/drivers/scsi/ppa.c b/drivers/scsi/ppa.c
index 89a2a9f11e41..584ba4d6e038 100644
--- a/drivers/scsi/ppa.c
+++ b/drivers/scsi/ppa.c
@@ -31,7 +31,7 @@ typedef struct {
31 int base; /* Actual port address */ 31 int base; /* Actual port address */
32 int mode; /* Transfer mode */ 32 int mode; /* Transfer mode */
33 struct scsi_cmnd *cur_cmd; /* Current queued command */ 33 struct scsi_cmnd *cur_cmd; /* Current queued command */
34 struct work_struct ppa_tq; /* Polling interrupt stuff */ 34 struct delayed_work ppa_tq; /* Polling interrupt stuff */
35 unsigned long jstart; /* Jiffies at start */ 35 unsigned long jstart; /* Jiffies at start */
36 unsigned long recon_tmo; /* How many usecs to wait for reconnection (6th bit) */ 36 unsigned long recon_tmo; /* How many usecs to wait for reconnection (6th bit) */
37 unsigned int failed:1; /* Failure flag */ 37 unsigned int failed:1; /* Failure flag */
@@ -627,9 +627,9 @@ static int ppa_completion(struct scsi_cmnd *cmd)
627 * the scheduler's task queue to generate a stream of call-backs and 627 * the scheduler's task queue to generate a stream of call-backs and
628 * complete the request when the drive is ready. 628 * complete the request when the drive is ready.
629 */ 629 */
630static void ppa_interrupt(void *data) 630static void ppa_interrupt(struct work_struct *work)
631{ 631{
632 ppa_struct *dev = (ppa_struct *) data; 632 ppa_struct *dev = container_of(work, ppa_struct, ppa_tq.work);
633 struct scsi_cmnd *cmd = dev->cur_cmd; 633 struct scsi_cmnd *cmd = dev->cur_cmd;
634 634
635 if (!cmd) { 635 if (!cmd) {
@@ -637,7 +637,6 @@ static void ppa_interrupt(void *data)
637 return; 637 return;
638 } 638 }
639 if (ppa_engine(dev, cmd)) { 639 if (ppa_engine(dev, cmd)) {
640 dev->ppa_tq.data = (void *) dev;
641 schedule_delayed_work(&dev->ppa_tq, 1); 640 schedule_delayed_work(&dev->ppa_tq, 1);
642 return; 641 return;
643 } 642 }
@@ -822,8 +821,7 @@ static int ppa_queuecommand(struct scsi_cmnd *cmd,
822 cmd->result = DID_ERROR << 16; /* default return code */ 821 cmd->result = DID_ERROR << 16; /* default return code */
823 cmd->SCp.phase = 0; /* bus free */ 822 cmd->SCp.phase = 0; /* bus free */
824 823
825 dev->ppa_tq.data = dev; 824 schedule_delayed_work(&dev->ppa_tq, 0);
826 schedule_work(&dev->ppa_tq);
827 825
828 ppa_pb_claim(dev); 826 ppa_pb_claim(dev);
829 827
@@ -1086,7 +1084,7 @@ static int __ppa_attach(struct parport *pb)
1086 else 1084 else
1087 ports = 8; 1085 ports = 8;
1088 1086
1089 INIT_WORK(&dev->ppa_tq, ppa_interrupt, dev); 1087 INIT_DELAYED_WORK(&dev->ppa_tq, ppa_interrupt);
1090 1088
1091 err = -ENOMEM; 1089 err = -ENOMEM;
1092 host = scsi_host_alloc(&ppa_template, sizeof(ppa_struct *)); 1090 host = scsi_host_alloc(&ppa_template, sizeof(ppa_struct *));
diff --git a/drivers/scsi/psi240i.c b/drivers/scsi/psi240i.c
index ac0419e2714a..899e89d6fe67 100644
--- a/drivers/scsi/psi240i.c
+++ b/drivers/scsi/psi240i.c
@@ -328,7 +328,7 @@ static void Irq_Handler (int irq, void *dev_id)
328 pinquiryData->AdditionalLength = 35 - 4; 328 pinquiryData->AdditionalLength = 35 - 4;
329 329
330 // Fill in vendor identification fields. 330 // Fill in vendor identification fields.
331 for ( z = 0; z < 20; z += 2 ) 331 for ( z = 0; z < 8; z += 2 )
332 { 332 {
333 pinquiryData->VendorId[z] = ((UCHAR *)identifyData.ModelNumber)[z + 1]; 333 pinquiryData->VendorId[z] = ((UCHAR *)identifyData.ModelNumber)[z + 1];
334 pinquiryData->VendorId[z + 1] = ((UCHAR *)identifyData.ModelNumber)[z]; 334 pinquiryData->VendorId[z + 1] = ((UCHAR *)identifyData.ModelNumber)[z];
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index 285c8e8ff1a0..7b18a6c7b7eb 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -390,7 +390,7 @@ static struct sysfs_entry {
390 { "optrom_ctl", &sysfs_optrom_ctl_attr, }, 390 { "optrom_ctl", &sysfs_optrom_ctl_attr, },
391 { "vpd", &sysfs_vpd_attr, 1 }, 391 { "vpd", &sysfs_vpd_attr, 1 },
392 { "sfp", &sysfs_sfp_attr, 1 }, 392 { "sfp", &sysfs_sfp_attr, 1 },
393 { 0 }, 393 { NULL },
394}; 394};
395 395
396void 396void
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 08cb5e3fb553..a823f0bc519d 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -59,9 +59,6 @@ int
59qla2x00_initialize_adapter(scsi_qla_host_t *ha) 59qla2x00_initialize_adapter(scsi_qla_host_t *ha)
60{ 60{
61 int rval; 61 int rval;
62 uint8_t restart_risc = 0;
63 uint8_t retry;
64 uint32_t wait_time;
65 62
66 /* Clear adapter flags. */ 63 /* Clear adapter flags. */
67 ha->flags.online = 0; 64 ha->flags.online = 0;
@@ -104,87 +101,15 @@ qla2x00_initialize_adapter(scsi_qla_host_t *ha)
104 101
105 qla_printk(KERN_INFO, ha, "Verifying loaded RISC code...\n"); 102 qla_printk(KERN_INFO, ha, "Verifying loaded RISC code...\n");
106 103
107 retry = 10; 104 if (qla2x00_isp_firmware(ha) != QLA_SUCCESS) {
108 /* 105 rval = ha->isp_ops.chip_diag(ha);
109 * Try to configure the loop. 106 if (rval)
110 */ 107 return (rval);
111 do { 108 rval = qla2x00_setup_chip(ha);
112 restart_risc = 0; 109 if (rval)
113 110 return (rval);
114 /* If firmware needs to be loaded */
115 if (qla2x00_isp_firmware(ha) != QLA_SUCCESS) {
116 if ((rval = ha->isp_ops.chip_diag(ha)) == QLA_SUCCESS) {
117 rval = qla2x00_setup_chip(ha);
118 }
119 }
120
121 if (rval == QLA_SUCCESS &&
122 (rval = qla2x00_init_rings(ha)) == QLA_SUCCESS) {
123check_fw_ready_again:
124 /*
125 * Wait for a successful LIP up to a maximum
126 * of (in seconds): RISC login timeout value,
127 * RISC retry count value, and port down retry
128 * value OR a minimum of 4 seconds OR If no
129 * cable, only 5 seconds.
130 */
131 rval = qla2x00_fw_ready(ha);
132 if (rval == QLA_SUCCESS) {
133 clear_bit(RESET_MARKER_NEEDED, &ha->dpc_flags);
134
135 /* Issue a marker after FW becomes ready. */
136 qla2x00_marker(ha, 0, 0, MK_SYNC_ALL);
137
138 /*
139 * Wait at most MAX_TARGET RSCNs for a stable
140 * link.
141 */
142 wait_time = 256;
143 do {
144 clear_bit(LOOP_RESYNC_NEEDED,
145 &ha->dpc_flags);
146 rval = qla2x00_configure_loop(ha);
147
148 if (test_and_clear_bit(ISP_ABORT_NEEDED,
149 &ha->dpc_flags)) {
150 restart_risc = 1;
151 break;
152 }
153
154 /*
155 * If loop state change while we were
156 * discoverying devices then wait for
157 * LIP to complete
158 */
159
160 if (atomic_read(&ha->loop_state) !=
161 LOOP_READY && retry--) {
162 goto check_fw_ready_again;
163 }
164 wait_time--;
165 } while (!atomic_read(&ha->loop_down_timer) &&
166 retry &&
167 wait_time &&
168 (test_bit(LOOP_RESYNC_NEEDED,
169 &ha->dpc_flags)));
170
171 if (wait_time == 0)
172 rval = QLA_FUNCTION_FAILED;
173 } else if (ha->device_flags & DFLG_NO_CABLE)
174 /* If no cable, then all is good. */
175 rval = QLA_SUCCESS;
176 }
177 } while (restart_risc && retry--);
178
179 if (rval == QLA_SUCCESS) {
180 clear_bit(RESET_MARKER_NEEDED, &ha->dpc_flags);
181 qla2x00_marker(ha, 0, 0, MK_SYNC_ALL);
182 ha->marker_needed = 0;
183
184 ha->flags.online = 1;
185 } else {
186 DEBUG2_3(printk("%s(): **** FAILED ****\n", __func__));
187 } 111 }
112 rval = qla2x00_init_rings(ha);
188 113
189 return (rval); 114 return (rval);
190} 115}
@@ -2208,8 +2133,7 @@ qla2x00_update_fcport(scsi_qla_host_t *ha, fc_port_t *fcport)
2208 2133
2209 atomic_set(&fcport->state, FCS_ONLINE); 2134 atomic_set(&fcport->state, FCS_ONLINE);
2210 2135
2211 if (ha->flags.init_done) 2136 qla2x00_reg_remote_port(ha, fcport);
2212 qla2x00_reg_remote_port(ha, fcport);
2213} 2137}
2214 2138
2215void 2139void
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 208607be78c7..d03523d3bf38 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -24,7 +24,7 @@ char qla2x00_version_str[40];
24/* 24/*
25 * SRB allocation cache 25 * SRB allocation cache
26 */ 26 */
27static kmem_cache_t *srb_cachep; 27static struct kmem_cache *srb_cachep;
28 28
29/* 29/*
30 * Ioctl related information. 30 * Ioctl related information.
@@ -95,6 +95,8 @@ MODULE_PARM_DESC(ql2xqfullrampup,
95 */ 95 */
96static int qla2xxx_slave_configure(struct scsi_device * device); 96static int qla2xxx_slave_configure(struct scsi_device * device);
97static int qla2xxx_slave_alloc(struct scsi_device *); 97static int qla2xxx_slave_alloc(struct scsi_device *);
98static int qla2xxx_scan_finished(struct Scsi_Host *, unsigned long time);
99static void qla2xxx_scan_start(struct Scsi_Host *);
98static void qla2xxx_slave_destroy(struct scsi_device *); 100static void qla2xxx_slave_destroy(struct scsi_device *);
99static int qla2x00_queuecommand(struct scsi_cmnd *cmd, 101static int qla2x00_queuecommand(struct scsi_cmnd *cmd,
100 void (*fn)(struct scsi_cmnd *)); 102 void (*fn)(struct scsi_cmnd *));
@@ -124,6 +126,8 @@ static struct scsi_host_template qla2x00_driver_template = {
124 126
125 .slave_alloc = qla2xxx_slave_alloc, 127 .slave_alloc = qla2xxx_slave_alloc,
126 .slave_destroy = qla2xxx_slave_destroy, 128 .slave_destroy = qla2xxx_slave_destroy,
129 .scan_finished = qla2xxx_scan_finished,
130 .scan_start = qla2xxx_scan_start,
127 .change_queue_depth = qla2x00_change_queue_depth, 131 .change_queue_depth = qla2x00_change_queue_depth,
128 .change_queue_type = qla2x00_change_queue_type, 132 .change_queue_type = qla2x00_change_queue_type,
129 .this_id = -1, 133 .this_id = -1,
@@ -287,7 +291,7 @@ qla24xx_pci_info_str(struct scsi_qla_host *ha, char *str)
287 return str; 291 return str;
288} 292}
289 293
290char * 294static char *
291qla2x00_fw_version_str(struct scsi_qla_host *ha, char *str) 295qla2x00_fw_version_str(struct scsi_qla_host *ha, char *str)
292{ 296{
293 char un_str[10]; 297 char un_str[10];
@@ -325,7 +329,7 @@ qla2x00_fw_version_str(struct scsi_qla_host *ha, char *str)
325 return (str); 329 return (str);
326} 330}
327 331
328char * 332static char *
329qla24xx_fw_version_str(struct scsi_qla_host *ha, char *str) 333qla24xx_fw_version_str(struct scsi_qla_host *ha, char *str)
330{ 334{
331 sprintf(str, "%d.%02d.%02d ", ha->fw_major_version, 335 sprintf(str, "%d.%02d.%02d ", ha->fw_major_version,
@@ -634,7 +638,7 @@ qla2x00_block_error_handler(struct scsi_cmnd *cmnd)
634* Note: 638* Note:
635* Only return FAILED if command not returned by firmware. 639* Only return FAILED if command not returned by firmware.
636**************************************************************************/ 640**************************************************************************/
637int 641static int
638qla2xxx_eh_abort(struct scsi_cmnd *cmd) 642qla2xxx_eh_abort(struct scsi_cmnd *cmd)
639{ 643{
640 scsi_qla_host_t *ha = to_qla_host(cmd->device->host); 644 scsi_qla_host_t *ha = to_qla_host(cmd->device->host);
@@ -771,7 +775,7 @@ qla2x00_eh_wait_for_pending_target_commands(scsi_qla_host_t *ha, unsigned int t)
771* SUCCESS/FAILURE (defined as macro in scsi.h). 775* SUCCESS/FAILURE (defined as macro in scsi.h).
772* 776*
773**************************************************************************/ 777**************************************************************************/
774int 778static int
775qla2xxx_eh_device_reset(struct scsi_cmnd *cmd) 779qla2xxx_eh_device_reset(struct scsi_cmnd *cmd)
776{ 780{
777 scsi_qla_host_t *ha = to_qla_host(cmd->device->host); 781 scsi_qla_host_t *ha = to_qla_host(cmd->device->host);
@@ -902,7 +906,7 @@ qla2x00_eh_wait_for_pending_commands(scsi_qla_host_t *ha)
902* SUCCESS/FAILURE (defined as macro in scsi.h). 906* SUCCESS/FAILURE (defined as macro in scsi.h).
903* 907*
904**************************************************************************/ 908**************************************************************************/
905int 909static int
906qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd) 910qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd)
907{ 911{
908 scsi_qla_host_t *ha = to_qla_host(cmd->device->host); 912 scsi_qla_host_t *ha = to_qla_host(cmd->device->host);
@@ -963,7 +967,7 @@ eh_bus_reset_done:
963* 967*
964* Note: 968* Note:
965**************************************************************************/ 969**************************************************************************/
966int 970static int
967qla2xxx_eh_host_reset(struct scsi_cmnd *cmd) 971qla2xxx_eh_host_reset(struct scsi_cmnd *cmd)
968{ 972{
969 scsi_qla_host_t *ha = to_qla_host(cmd->device->host); 973 scsi_qla_host_t *ha = to_qla_host(cmd->device->host);
@@ -1366,6 +1370,29 @@ qla24xx_disable_intrs(scsi_qla_host_t *ha)
1366 spin_unlock_irqrestore(&ha->hardware_lock, flags); 1370 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1367} 1371}
1368 1372
1373static void
1374qla2xxx_scan_start(struct Scsi_Host *shost)
1375{
1376 scsi_qla_host_t *ha = (scsi_qla_host_t *)shost->hostdata;
1377
1378 set_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags);
1379 set_bit(LOCAL_LOOP_UPDATE, &ha->dpc_flags);
1380 set_bit(RSCN_UPDATE, &ha->dpc_flags);
1381}
1382
1383static int
1384qla2xxx_scan_finished(struct Scsi_Host *shost, unsigned long time)
1385{
1386 scsi_qla_host_t *ha = (scsi_qla_host_t *)shost->hostdata;
1387
1388 if (!ha->host)
1389 return 1;
1390 if (time > ha->loop_reset_delay * HZ)
1391 return 1;
1392
1393 return atomic_read(&ha->loop_state) == LOOP_READY;
1394}
1395
1369/* 1396/*
1370 * PCI driver interface 1397 * PCI driver interface
1371 */ 1398 */
@@ -1377,10 +1404,8 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
1377 struct Scsi_Host *host; 1404 struct Scsi_Host *host;
1378 scsi_qla_host_t *ha; 1405 scsi_qla_host_t *ha;
1379 unsigned long flags = 0; 1406 unsigned long flags = 0;
1380 unsigned long wait_switch = 0;
1381 char pci_info[20]; 1407 char pci_info[20];
1382 char fw_str[30]; 1408 char fw_str[30];
1383 fc_port_t *fcport;
1384 struct scsi_host_template *sht; 1409 struct scsi_host_template *sht;
1385 1410
1386 if (pci_enable_device(pdev)) 1411 if (pci_enable_device(pdev))
@@ -1631,30 +1656,19 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
1631 1656
1632 ha->isp_ops.enable_intrs(ha); 1657 ha->isp_ops.enable_intrs(ha);
1633 1658
1634 /* v2.19.5b6 */
1635 /*
1636 * Wait around max loop_reset_delay secs for the devices to come
1637 * on-line. We don't want Linux scanning before we are ready.
1638 *
1639 */
1640 for (wait_switch = jiffies + (ha->loop_reset_delay * HZ);
1641 time_before(jiffies,wait_switch) &&
1642 !(ha->device_flags & (DFLG_NO_CABLE | DFLG_FABRIC_DEVICES))
1643 && (ha->device_flags & SWITCH_FOUND) ;) {
1644
1645 qla2x00_check_fabric_devices(ha);
1646
1647 msleep(10);
1648 }
1649
1650 pci_set_drvdata(pdev, ha); 1659 pci_set_drvdata(pdev, ha);
1660
1651 ha->flags.init_done = 1; 1661 ha->flags.init_done = 1;
1662 ha->flags.online = 1;
1663
1652 num_hosts++; 1664 num_hosts++;
1653 1665
1654 ret = scsi_add_host(host, &pdev->dev); 1666 ret = scsi_add_host(host, &pdev->dev);
1655 if (ret) 1667 if (ret)
1656 goto probe_failed; 1668 goto probe_failed;
1657 1669
1670 scsi_scan_host(host);
1671
1658 qla2x00_alloc_sysfs_attr(ha); 1672 qla2x00_alloc_sysfs_attr(ha);
1659 1673
1660 qla2x00_init_host_attr(ha); 1674 qla2x00_init_host_attr(ha);
@@ -1669,10 +1683,6 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
1669 ha->flags.enable_64bit_addressing ? '+': '-', ha->host_no, 1683 ha->flags.enable_64bit_addressing ? '+': '-', ha->host_no,
1670 ha->isp_ops.fw_version_str(ha, fw_str)); 1684 ha->isp_ops.fw_version_str(ha, fw_str));
1671 1685
1672 /* Go with fc_rport registration. */
1673 list_for_each_entry(fcport, &ha->fcports, list)
1674 qla2x00_reg_remote_port(ha, fcport);
1675
1676 return 0; 1686 return 0;
1677 1687
1678probe_failed: 1688probe_failed:
diff --git a/drivers/scsi/qla2xxx/qla_sup.c b/drivers/scsi/qla2xxx/qla_sup.c
index c71dbd5bd543..15390ad87456 100644
--- a/drivers/scsi/qla2xxx/qla_sup.c
+++ b/drivers/scsi/qla2xxx/qla_sup.c
@@ -449,7 +449,7 @@ nvram_data_to_access_addr(uint32_t naddr)
449 return FARX_ACCESS_NVRAM_DATA | naddr; 449 return FARX_ACCESS_NVRAM_DATA | naddr;
450} 450}
451 451
452uint32_t 452static uint32_t
453qla24xx_read_flash_dword(scsi_qla_host_t *ha, uint32_t addr) 453qla24xx_read_flash_dword(scsi_qla_host_t *ha, uint32_t addr)
454{ 454{
455 int rval; 455 int rval;
@@ -490,7 +490,7 @@ qla24xx_read_flash_data(scsi_qla_host_t *ha, uint32_t *dwptr, uint32_t faddr,
490 return dwptr; 490 return dwptr;
491} 491}
492 492
493int 493static int
494qla24xx_write_flash_dword(scsi_qla_host_t *ha, uint32_t addr, uint32_t data) 494qla24xx_write_flash_dword(scsi_qla_host_t *ha, uint32_t addr, uint32_t data)
495{ 495{
496 int rval; 496 int rval;
@@ -512,7 +512,7 @@ qla24xx_write_flash_dword(scsi_qla_host_t *ha, uint32_t addr, uint32_t data)
512 return rval; 512 return rval;
513} 513}
514 514
515void 515static void
516qla24xx_get_flash_manufacturer(scsi_qla_host_t *ha, uint8_t *man_id, 516qla24xx_get_flash_manufacturer(scsi_qla_host_t *ha, uint8_t *man_id,
517 uint8_t *flash_id) 517 uint8_t *flash_id)
518{ 518{
@@ -537,7 +537,7 @@ qla24xx_get_flash_manufacturer(scsi_qla_host_t *ha, uint8_t *man_id,
537 } 537 }
538} 538}
539 539
540int 540static int
541qla24xx_write_flash_data(scsi_qla_host_t *ha, uint32_t *dwptr, uint32_t faddr, 541qla24xx_write_flash_data(scsi_qla_host_t *ha, uint32_t *dwptr, uint32_t faddr,
542 uint32_t dwords) 542 uint32_t dwords)
543{ 543{
diff --git a/drivers/scsi/qla4xxx/ql4_dbg.c b/drivers/scsi/qla4xxx/ql4_dbg.c
index 752031fadfef..7b4e077a39c1 100644
--- a/drivers/scsi/qla4xxx/ql4_dbg.c
+++ b/drivers/scsi/qla4xxx/ql4_dbg.c
@@ -71,7 +71,7 @@ void __dump_registers(struct scsi_qla_host *ha)
71 readw(&ha->reg->u1.isp4010.nvram)); 71 readw(&ha->reg->u1.isp4010.nvram));
72 } 72 }
73 73
74 else if (is_qla4022(ha)) { 74 else if (is_qla4022(ha) | is_qla4032(ha)) {
75 printk(KERN_INFO "0x%02X intr_mask = 0x%08X\n", 75 printk(KERN_INFO "0x%02X intr_mask = 0x%08X\n",
76 (uint8_t) offsetof(struct isp_reg, 76 (uint8_t) offsetof(struct isp_reg,
77 u1.isp4022.intr_mask), 77 u1.isp4022.intr_mask),
@@ -119,7 +119,7 @@ void __dump_registers(struct scsi_qla_host *ha)
119 readw(&ha->reg->u2.isp4010.port_err_status)); 119 readw(&ha->reg->u2.isp4010.port_err_status));
120 } 120 }
121 121
122 else if (is_qla4022(ha)) { 122 else if (is_qla4022(ha) | is_qla4032(ha)) {
123 printk(KERN_INFO "Page 0 Registers:\n"); 123 printk(KERN_INFO "Page 0 Registers:\n");
124 printk(KERN_INFO "0x%02X ext_hw_conf = 0x%08X\n", 124 printk(KERN_INFO "0x%02X ext_hw_conf = 0x%08X\n",
125 (uint8_t) offsetof(struct isp_reg, 125 (uint8_t) offsetof(struct isp_reg,
diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
index a7f6c7b1c590..4249e52a5592 100644
--- a/drivers/scsi/qla4xxx/ql4_def.h
+++ b/drivers/scsi/qla4xxx/ql4_def.h
@@ -40,7 +40,11 @@
40 40
41#ifndef PCI_DEVICE_ID_QLOGIC_ISP4022 41#ifndef PCI_DEVICE_ID_QLOGIC_ISP4022
42#define PCI_DEVICE_ID_QLOGIC_ISP4022 0x4022 42#define PCI_DEVICE_ID_QLOGIC_ISP4022 0x4022
43#endif /* */ 43#endif
44
45#ifndef PCI_DEVICE_ID_QLOGIC_ISP4032
46#define PCI_DEVICE_ID_QLOGIC_ISP4032 0x4032
47#endif
44 48
45#define QLA_SUCCESS 0 49#define QLA_SUCCESS 0
46#define QLA_ERROR 1 50#define QLA_ERROR 1
@@ -277,7 +281,6 @@ struct scsi_qla_host {
277#define AF_INTERRUPTS_ON 6 /* 0x00000040 Not Used */ 281#define AF_INTERRUPTS_ON 6 /* 0x00000040 Not Used */
278#define AF_GET_CRASH_RECORD 7 /* 0x00000080 */ 282#define AF_GET_CRASH_RECORD 7 /* 0x00000080 */
279#define AF_LINK_UP 8 /* 0x00000100 */ 283#define AF_LINK_UP 8 /* 0x00000100 */
280#define AF_TOPCAT_CHIP_PRESENT 9 /* 0x00000200 */
281#define AF_IRQ_ATTACHED 10 /* 0x00000400 */ 284#define AF_IRQ_ATTACHED 10 /* 0x00000400 */
282#define AF_ISNS_CMD_IN_PROCESS 12 /* 0x00001000 */ 285#define AF_ISNS_CMD_IN_PROCESS 12 /* 0x00001000 */
283#define AF_ISNS_CMD_DONE 13 /* 0x00002000 */ 286#define AF_ISNS_CMD_DONE 13 /* 0x00002000 */
@@ -317,16 +320,17 @@ struct scsi_qla_host {
317 /* NVRAM registers */ 320 /* NVRAM registers */
318 struct eeprom_data *nvram; 321 struct eeprom_data *nvram;
319 spinlock_t hardware_lock ____cacheline_aligned; 322 spinlock_t hardware_lock ____cacheline_aligned;
320 spinlock_t list_lock;
321 uint32_t eeprom_cmd_data; 323 uint32_t eeprom_cmd_data;
322 324
323 /* Counters for general statistics */ 325 /* Counters for general statistics */
326 uint64_t isr_count;
324 uint64_t adapter_error_count; 327 uint64_t adapter_error_count;
325 uint64_t device_error_count; 328 uint64_t device_error_count;
326 uint64_t total_io_count; 329 uint64_t total_io_count;
327 uint64_t total_mbytes_xferred; 330 uint64_t total_mbytes_xferred;
328 uint64_t link_failure_count; 331 uint64_t link_failure_count;
329 uint64_t invalid_crc_count; 332 uint64_t invalid_crc_count;
333 uint32_t bytes_xfered;
330 uint32_t spurious_int_count; 334 uint32_t spurious_int_count;
331 uint32_t aborted_io_count; 335 uint32_t aborted_io_count;
332 uint32_t io_timeout_count; 336 uint32_t io_timeout_count;
@@ -438,6 +442,11 @@ static inline int is_qla4022(struct scsi_qla_host *ha)
438 return ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP4022; 442 return ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP4022;
439} 443}
440 444
445static inline int is_qla4032(struct scsi_qla_host *ha)
446{
447 return ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP4032;
448}
449
441static inline int adapter_up(struct scsi_qla_host *ha) 450static inline int adapter_up(struct scsi_qla_host *ha)
442{ 451{
443 return (test_bit(AF_ONLINE, &ha->flags) != 0) && 452 return (test_bit(AF_ONLINE, &ha->flags) != 0) &&
@@ -451,58 +460,58 @@ static inline struct scsi_qla_host* to_qla_host(struct Scsi_Host *shost)
451 460
452static inline void __iomem* isp_semaphore(struct scsi_qla_host *ha) 461static inline void __iomem* isp_semaphore(struct scsi_qla_host *ha)
453{ 462{
454 return (is_qla4022(ha) ? 463 return (is_qla4010(ha) ?
455 &ha->reg->u1.isp4022.semaphore : 464 &ha->reg->u1.isp4010.nvram :
456 &ha->reg->u1.isp4010.nvram); 465 &ha->reg->u1.isp4022.semaphore);
457} 466}
458 467
459static inline void __iomem* isp_nvram(struct scsi_qla_host *ha) 468static inline void __iomem* isp_nvram(struct scsi_qla_host *ha)
460{ 469{
461 return (is_qla4022(ha) ? 470 return (is_qla4010(ha) ?
462 &ha->reg->u1.isp4022.nvram : 471 &ha->reg->u1.isp4010.nvram :
463 &ha->reg->u1.isp4010.nvram); 472 &ha->reg->u1.isp4022.nvram);
464} 473}
465 474
466static inline void __iomem* isp_ext_hw_conf(struct scsi_qla_host *ha) 475static inline void __iomem* isp_ext_hw_conf(struct scsi_qla_host *ha)
467{ 476{
468 return (is_qla4022(ha) ? 477 return (is_qla4010(ha) ?
469 &ha->reg->u2.isp4022.p0.ext_hw_conf : 478 &ha->reg->u2.isp4010.ext_hw_conf :
470 &ha->reg->u2.isp4010.ext_hw_conf); 479 &ha->reg->u2.isp4022.p0.ext_hw_conf);
471} 480}
472 481
473static inline void __iomem* isp_port_status(struct scsi_qla_host *ha) 482static inline void __iomem* isp_port_status(struct scsi_qla_host *ha)
474{ 483{
475 return (is_qla4022(ha) ? 484 return (is_qla4010(ha) ?
476 &ha->reg->u2.isp4022.p0.port_status : 485 &ha->reg->u2.isp4010.port_status :
477 &ha->reg->u2.isp4010.port_status); 486 &ha->reg->u2.isp4022.p0.port_status);
478} 487}
479 488
480static inline void __iomem* isp_port_ctrl(struct scsi_qla_host *ha) 489static inline void __iomem* isp_port_ctrl(struct scsi_qla_host *ha)
481{ 490{
482 return (is_qla4022(ha) ? 491 return (is_qla4010(ha) ?
483 &ha->reg->u2.isp4022.p0.port_ctrl : 492 &ha->reg->u2.isp4010.port_ctrl :
484 &ha->reg->u2.isp4010.port_ctrl); 493 &ha->reg->u2.isp4022.p0.port_ctrl);
485} 494}
486 495
487static inline void __iomem* isp_port_error_status(struct scsi_qla_host *ha) 496static inline void __iomem* isp_port_error_status(struct scsi_qla_host *ha)
488{ 497{
489 return (is_qla4022(ha) ? 498 return (is_qla4010(ha) ?
490 &ha->reg->u2.isp4022.p0.port_err_status : 499 &ha->reg->u2.isp4010.port_err_status :
491 &ha->reg->u2.isp4010.port_err_status); 500 &ha->reg->u2.isp4022.p0.port_err_status);
492} 501}
493 502
494static inline void __iomem * isp_gp_out(struct scsi_qla_host *ha) 503static inline void __iomem * isp_gp_out(struct scsi_qla_host *ha)
495{ 504{
496 return (is_qla4022(ha) ? 505 return (is_qla4010(ha) ?
497 &ha->reg->u2.isp4022.p0.gp_out : 506 &ha->reg->u2.isp4010.gp_out :
498 &ha->reg->u2.isp4010.gp_out); 507 &ha->reg->u2.isp4022.p0.gp_out);
499} 508}
500 509
501static inline int eeprom_ext_hw_conf_offset(struct scsi_qla_host *ha) 510static inline int eeprom_ext_hw_conf_offset(struct scsi_qla_host *ha)
502{ 511{
503 return (is_qla4022(ha) ? 512 return (is_qla4010(ha) ?
504 offsetof(struct eeprom_data, isp4022.ext_hw_conf) / 2 : 513 offsetof(struct eeprom_data, isp4010.ext_hw_conf) / 2 :
505 offsetof(struct eeprom_data, isp4010.ext_hw_conf) / 2); 514 offsetof(struct eeprom_data, isp4022.ext_hw_conf) / 2);
506} 515}
507 516
508int ql4xxx_sem_spinlock(struct scsi_qla_host * ha, u32 sem_mask, u32 sem_bits); 517int ql4xxx_sem_spinlock(struct scsi_qla_host * ha, u32 sem_mask, u32 sem_bits);
@@ -511,59 +520,59 @@ int ql4xxx_sem_lock(struct scsi_qla_host * ha, u32 sem_mask, u32 sem_bits);
511 520
512static inline int ql4xxx_lock_flash(struct scsi_qla_host *a) 521static inline int ql4xxx_lock_flash(struct scsi_qla_host *a)
513{ 522{
514 if (is_qla4022(a)) 523 if (is_qla4010(a))
524 return ql4xxx_sem_spinlock(a, QL4010_FLASH_SEM_MASK,
525 QL4010_FLASH_SEM_BITS);
526 else
515 return ql4xxx_sem_spinlock(a, QL4022_FLASH_SEM_MASK, 527 return ql4xxx_sem_spinlock(a, QL4022_FLASH_SEM_MASK,
516 (QL4022_RESOURCE_BITS_BASE_CODE | 528 (QL4022_RESOURCE_BITS_BASE_CODE |
517 (a->mac_index)) << 13); 529 (a->mac_index)) << 13);
518 else
519 return ql4xxx_sem_spinlock(a, QL4010_FLASH_SEM_MASK,
520 QL4010_FLASH_SEM_BITS);
521} 530}
522 531
523static inline void ql4xxx_unlock_flash(struct scsi_qla_host *a) 532static inline void ql4xxx_unlock_flash(struct scsi_qla_host *a)
524{ 533{
525 if (is_qla4022(a)) 534 if (is_qla4010(a))
526 ql4xxx_sem_unlock(a, QL4022_FLASH_SEM_MASK);
527 else
528 ql4xxx_sem_unlock(a, QL4010_FLASH_SEM_MASK); 535 ql4xxx_sem_unlock(a, QL4010_FLASH_SEM_MASK);
536 else
537 ql4xxx_sem_unlock(a, QL4022_FLASH_SEM_MASK);
529} 538}
530 539
531static inline int ql4xxx_lock_nvram(struct scsi_qla_host *a) 540static inline int ql4xxx_lock_nvram(struct scsi_qla_host *a)
532{ 541{
533 if (is_qla4022(a)) 542 if (is_qla4010(a))
543 return ql4xxx_sem_spinlock(a, QL4010_NVRAM_SEM_MASK,
544 QL4010_NVRAM_SEM_BITS);
545 else
534 return ql4xxx_sem_spinlock(a, QL4022_NVRAM_SEM_MASK, 546 return ql4xxx_sem_spinlock(a, QL4022_NVRAM_SEM_MASK,
535 (QL4022_RESOURCE_BITS_BASE_CODE | 547 (QL4022_RESOURCE_BITS_BASE_CODE |
536 (a->mac_index)) << 10); 548 (a->mac_index)) << 10);
537 else
538 return ql4xxx_sem_spinlock(a, QL4010_NVRAM_SEM_MASK,
539 QL4010_NVRAM_SEM_BITS);
540} 549}
541 550
542static inline void ql4xxx_unlock_nvram(struct scsi_qla_host *a) 551static inline void ql4xxx_unlock_nvram(struct scsi_qla_host *a)
543{ 552{
544 if (is_qla4022(a)) 553 if (is_qla4010(a))
545 ql4xxx_sem_unlock(a, QL4022_NVRAM_SEM_MASK);
546 else
547 ql4xxx_sem_unlock(a, QL4010_NVRAM_SEM_MASK); 554 ql4xxx_sem_unlock(a, QL4010_NVRAM_SEM_MASK);
555 else
556 ql4xxx_sem_unlock(a, QL4022_NVRAM_SEM_MASK);
548} 557}
549 558
550static inline int ql4xxx_lock_drvr(struct scsi_qla_host *a) 559static inline int ql4xxx_lock_drvr(struct scsi_qla_host *a)
551{ 560{
552 if (is_qla4022(a)) 561 if (is_qla4010(a))
562 return ql4xxx_sem_lock(a, QL4010_DRVR_SEM_MASK,
563 QL4010_DRVR_SEM_BITS);
564 else
553 return ql4xxx_sem_lock(a, QL4022_DRVR_SEM_MASK, 565 return ql4xxx_sem_lock(a, QL4022_DRVR_SEM_MASK,
554 (QL4022_RESOURCE_BITS_BASE_CODE | 566 (QL4022_RESOURCE_BITS_BASE_CODE |
555 (a->mac_index)) << 1); 567 (a->mac_index)) << 1);
556 else
557 return ql4xxx_sem_lock(a, QL4010_DRVR_SEM_MASK,
558 QL4010_DRVR_SEM_BITS);
559} 568}
560 569
561static inline void ql4xxx_unlock_drvr(struct scsi_qla_host *a) 570static inline void ql4xxx_unlock_drvr(struct scsi_qla_host *a)
562{ 571{
563 if (is_qla4022(a)) 572 if (is_qla4010(a))
564 ql4xxx_sem_unlock(a, QL4022_DRVR_SEM_MASK);
565 else
566 ql4xxx_sem_unlock(a, QL4010_DRVR_SEM_MASK); 573 ql4xxx_sem_unlock(a, QL4010_DRVR_SEM_MASK);
574 else
575 ql4xxx_sem_unlock(a, QL4022_DRVR_SEM_MASK);
567} 576}
568 577
569/*---------------------------------------------------------------------------*/ 578/*---------------------------------------------------------------------------*/
diff --git a/drivers/scsi/qla4xxx/ql4_fw.h b/drivers/scsi/qla4xxx/ql4_fw.h
index 427489de64bc..4eea8c571916 100644
--- a/drivers/scsi/qla4xxx/ql4_fw.h
+++ b/drivers/scsi/qla4xxx/ql4_fw.h
@@ -296,7 +296,6 @@ static inline uint32_t clr_rmask(uint32_t val)
296/* ISP Semaphore definitions */ 296/* ISP Semaphore definitions */
297 297
298/* ISP General Purpose Output definitions */ 298/* ISP General Purpose Output definitions */
299#define GPOR_TOPCAT_RESET 0x00000004
300 299
301/* shadow registers (DMA'd from HA to system memory. read only) */ 300/* shadow registers (DMA'd from HA to system memory. read only) */
302struct shadow_regs { 301struct shadow_regs {
@@ -339,10 +338,13 @@ union external_hw_config_reg {
339/* Mailbox command definitions */ 338/* Mailbox command definitions */
340#define MBOX_CMD_ABOUT_FW 0x0009 339#define MBOX_CMD_ABOUT_FW 0x0009
341#define MBOX_CMD_LUN_RESET 0x0016 340#define MBOX_CMD_LUN_RESET 0x0016
341#define MBOX_CMD_GET_MANAGEMENT_DATA 0x001E
342#define MBOX_CMD_GET_FW_STATUS 0x001F 342#define MBOX_CMD_GET_FW_STATUS 0x001F
343#define MBOX_CMD_SET_ISNS_SERVICE 0x0021 343#define MBOX_CMD_SET_ISNS_SERVICE 0x0021
344#define ISNS_DISABLE 0 344#define ISNS_DISABLE 0
345#define ISNS_ENABLE 1 345#define ISNS_ENABLE 1
346#define MBOX_CMD_COPY_FLASH 0x0024
347#define MBOX_CMD_WRITE_FLASH 0x0025
346#define MBOX_CMD_READ_FLASH 0x0026 348#define MBOX_CMD_READ_FLASH 0x0026
347#define MBOX_CMD_CLEAR_DATABASE_ENTRY 0x0031 349#define MBOX_CMD_CLEAR_DATABASE_ENTRY 0x0031
348#define MBOX_CMD_CONN_CLOSE_SESS_LOGOUT 0x0056 350#define MBOX_CMD_CONN_CLOSE_SESS_LOGOUT 0x0056
@@ -360,10 +362,13 @@ union external_hw_config_reg {
360#define DDB_DS_SESSION_FAILED 0x06 362#define DDB_DS_SESSION_FAILED 0x06
361#define DDB_DS_LOGIN_IN_PROCESS 0x07 363#define DDB_DS_LOGIN_IN_PROCESS 0x07
362#define MBOX_CMD_GET_FW_STATE 0x0069 364#define MBOX_CMD_GET_FW_STATE 0x0069
365#define MBOX_CMD_GET_INIT_FW_CTRL_BLOCK_DEFAULTS 0x006A
366#define MBOX_CMD_RESTORE_FACTORY_DEFAULTS 0x0087
363 367
364/* Mailbox 1 */ 368/* Mailbox 1 */
365#define FW_STATE_READY 0x0000 369#define FW_STATE_READY 0x0000
366#define FW_STATE_CONFIG_WAIT 0x0001 370#define FW_STATE_CONFIG_WAIT 0x0001
371#define FW_STATE_WAIT_LOGIN 0x0002
367#define FW_STATE_ERROR 0x0004 372#define FW_STATE_ERROR 0x0004
368#define FW_STATE_DHCP_IN_PROGRESS 0x0008 373#define FW_STATE_DHCP_IN_PROGRESS 0x0008
369 374
diff --git a/drivers/scsi/qla4xxx/ql4_glbl.h b/drivers/scsi/qla4xxx/ql4_glbl.h
index 1b221ff0f6f7..2122967bbf0b 100644
--- a/drivers/scsi/qla4xxx/ql4_glbl.h
+++ b/drivers/scsi/qla4xxx/ql4_glbl.h
@@ -8,6 +8,7 @@
8#ifndef __QLA4x_GBL_H 8#ifndef __QLA4x_GBL_H
9#define __QLA4x_GBL_H 9#define __QLA4x_GBL_H
10 10
11int ql4xxx_lock_drvr_wait(struct scsi_qla_host *a);
11int qla4xxx_send_tgts(struct scsi_qla_host *ha, char *ip, uint16_t port); 12int qla4xxx_send_tgts(struct scsi_qla_host *ha, char *ip, uint16_t port);
12int qla4xxx_send_command_to_isp(struct scsi_qla_host *ha, struct srb * srb); 13int qla4xxx_send_command_to_isp(struct scsi_qla_host *ha, struct srb * srb);
13int qla4xxx_initialize_adapter(struct scsi_qla_host * ha, 14int qla4xxx_initialize_adapter(struct scsi_qla_host * ha,
@@ -75,4 +76,4 @@ int qla4xxx_process_ddb_changed(struct scsi_qla_host * ha,
75extern int ql4xextended_error_logging; 76extern int ql4xextended_error_logging;
76extern int ql4xdiscoverywait; 77extern int ql4xdiscoverywait;
77extern int ql4xdontresethba; 78extern int ql4xdontresethba;
78#endif /* _QLA4x_GBL_H */ 79#endif /* _QLA4x_GBL_H */
diff --git a/drivers/scsi/qla4xxx/ql4_init.c b/drivers/scsi/qla4xxx/ql4_init.c
index bb3a1c11f44c..cc210f297a78 100644
--- a/drivers/scsi/qla4xxx/ql4_init.c
+++ b/drivers/scsi/qla4xxx/ql4_init.c
@@ -259,10 +259,16 @@ static int qla4xxx_fw_ready(struct scsi_qla_host *ha)
259 "seconds expired= %d\n", ha->host_no, __func__, 259 "seconds expired= %d\n", ha->host_no, __func__,
260 ha->firmware_state, ha->addl_fw_state, 260 ha->firmware_state, ha->addl_fw_state,
261 timeout_count)); 261 timeout_count));
262 if (is_qla4032(ha) &&
263 !(ha->addl_fw_state & FW_ADDSTATE_LINK_UP) &&
264 (timeout_count < ADAPTER_INIT_TOV - 5)) {
265 break;
266 }
267
262 msleep(1000); 268 msleep(1000);
263 } /* end of for */ 269 } /* end of for */
264 270
265 if (timeout_count <= 0) 271 if (timeout_count == 0)
266 DEBUG2(printk("scsi%ld: %s: FW Initialization timed out!\n", 272 DEBUG2(printk("scsi%ld: %s: FW Initialization timed out!\n",
267 ha->host_no, __func__)); 273 ha->host_no, __func__));
268 274
@@ -806,32 +812,6 @@ int qla4xxx_relogin_device(struct scsi_qla_host *ha,
806 return QLA_SUCCESS; 812 return QLA_SUCCESS;
807} 813}
808 814
809/**
810 * qla4010_get_topcat_presence - check if it is QLA4040 TopCat Chip
811 * @ha: Pointer to host adapter structure.
812 *
813 **/
814static int qla4010_get_topcat_presence(struct scsi_qla_host *ha)
815{
816 unsigned long flags;
817 uint16_t topcat;
818
819 if (ql4xxx_lock_nvram(ha) != QLA_SUCCESS)
820 return QLA_ERROR;
821 spin_lock_irqsave(&ha->hardware_lock, flags);
822 topcat = rd_nvram_word(ha, offsetof(struct eeprom_data,
823 isp4010.topcat));
824 spin_unlock_irqrestore(&ha->hardware_lock, flags);
825
826 if ((topcat & TOPCAT_MASK) == TOPCAT_PRESENT)
827 set_bit(AF_TOPCAT_CHIP_PRESENT, &ha->flags);
828 else
829 clear_bit(AF_TOPCAT_CHIP_PRESENT, &ha->flags);
830 ql4xxx_unlock_nvram(ha);
831 return QLA_SUCCESS;
832}
833
834
835static int qla4xxx_config_nvram(struct scsi_qla_host *ha) 815static int qla4xxx_config_nvram(struct scsi_qla_host *ha)
836{ 816{
837 unsigned long flags; 817 unsigned long flags;
@@ -866,7 +846,7 @@ static int qla4xxx_config_nvram(struct scsi_qla_host *ha)
866 /* set defaults */ 846 /* set defaults */
867 if (is_qla4010(ha)) 847 if (is_qla4010(ha))
868 extHwConfig.Asuint32_t = 0x1912; 848 extHwConfig.Asuint32_t = 0x1912;
869 else if (is_qla4022(ha)) 849 else if (is_qla4022(ha) | is_qla4032(ha))
870 extHwConfig.Asuint32_t = 0x0023; 850 extHwConfig.Asuint32_t = 0x0023;
871 } 851 }
872 DEBUG(printk("scsi%ld: %s: Setting extHwConfig to 0xFFFF%04x\n", 852 DEBUG(printk("scsi%ld: %s: Setting extHwConfig to 0xFFFF%04x\n",
@@ -927,7 +907,7 @@ static int qla4xxx_start_firmware_from_flash(struct scsi_qla_host *ha)
927 907
928 spin_lock_irqsave(&ha->hardware_lock, flags); 908 spin_lock_irqsave(&ha->hardware_lock, flags);
929 writel(jiffies, &ha->reg->mailbox[7]); 909 writel(jiffies, &ha->reg->mailbox[7]);
930 if (is_qla4022(ha)) 910 if (is_qla4022(ha) | is_qla4032(ha))
931 writel(set_rmask(NVR_WRITE_ENABLE), 911 writel(set_rmask(NVR_WRITE_ENABLE),
932 &ha->reg->u1.isp4022.nvram); 912 &ha->reg->u1.isp4022.nvram);
933 913
@@ -978,7 +958,7 @@ static int qla4xxx_start_firmware_from_flash(struct scsi_qla_host *ha)
978 return status; 958 return status;
979} 959}
980 960
981static int ql4xxx_lock_drvr_wait(struct scsi_qla_host *a) 961int ql4xxx_lock_drvr_wait(struct scsi_qla_host *a)
982{ 962{
983#define QL4_LOCK_DRVR_WAIT 300 963#define QL4_LOCK_DRVR_WAIT 300
984#define QL4_LOCK_DRVR_SLEEP 100 964#define QL4_LOCK_DRVR_SLEEP 100
@@ -1018,12 +998,7 @@ static int qla4xxx_start_firmware(struct scsi_qla_host *ha)
1018 int soft_reset = 1; 998 int soft_reset = 1;
1019 int config_chip = 0; 999 int config_chip = 0;
1020 1000
1021 if (is_qla4010(ha)){ 1001 if (is_qla4022(ha) | is_qla4032(ha))
1022 if (qla4010_get_topcat_presence(ha) != QLA_SUCCESS)
1023 return QLA_ERROR;
1024 }
1025
1026 if (is_qla4022(ha))
1027 ql4xxx_set_mac_number(ha); 1002 ql4xxx_set_mac_number(ha);
1028 1003
1029 if (ql4xxx_lock_drvr_wait(ha) != QLA_SUCCESS) 1004 if (ql4xxx_lock_drvr_wait(ha) != QLA_SUCCESS)
diff --git a/drivers/scsi/qla4xxx/ql4_inline.h b/drivers/scsi/qla4xxx/ql4_inline.h
index 0d61797af7da..6375eb017dd3 100644
--- a/drivers/scsi/qla4xxx/ql4_inline.h
+++ b/drivers/scsi/qla4xxx/ql4_inline.h
@@ -38,7 +38,7 @@ qla4xxx_lookup_ddb_by_fw_index(struct scsi_qla_host *ha, uint32_t fw_ddb_index)
38static inline void 38static inline void
39__qla4xxx_enable_intrs(struct scsi_qla_host *ha) 39__qla4xxx_enable_intrs(struct scsi_qla_host *ha)
40{ 40{
41 if (is_qla4022(ha)) { 41 if (is_qla4022(ha) | is_qla4032(ha)) {
42 writel(set_rmask(IMR_SCSI_INTR_ENABLE), 42 writel(set_rmask(IMR_SCSI_INTR_ENABLE),
43 &ha->reg->u1.isp4022.intr_mask); 43 &ha->reg->u1.isp4022.intr_mask);
44 readl(&ha->reg->u1.isp4022.intr_mask); 44 readl(&ha->reg->u1.isp4022.intr_mask);
@@ -52,7 +52,7 @@ __qla4xxx_enable_intrs(struct scsi_qla_host *ha)
52static inline void 52static inline void
53__qla4xxx_disable_intrs(struct scsi_qla_host *ha) 53__qla4xxx_disable_intrs(struct scsi_qla_host *ha)
54{ 54{
55 if (is_qla4022(ha)) { 55 if (is_qla4022(ha) | is_qla4032(ha)) {
56 writel(clr_rmask(IMR_SCSI_INTR_ENABLE), 56 writel(clr_rmask(IMR_SCSI_INTR_ENABLE),
57 &ha->reg->u1.isp4022.intr_mask); 57 &ha->reg->u1.isp4022.intr_mask);
58 readl(&ha->reg->u1.isp4022.intr_mask); 58 readl(&ha->reg->u1.isp4022.intr_mask);
diff --git a/drivers/scsi/qla4xxx/ql4_iocb.c b/drivers/scsi/qla4xxx/ql4_iocb.c
index c0a254b89a30..d41ce380eedc 100644
--- a/drivers/scsi/qla4xxx/ql4_iocb.c
+++ b/drivers/scsi/qla4xxx/ql4_iocb.c
@@ -294,6 +294,12 @@ int qla4xxx_send_command_to_isp(struct scsi_qla_host *ha, struct srb * srb)
294 cmd_entry->control_flags = CF_WRITE; 294 cmd_entry->control_flags = CF_WRITE;
295 else if (cmd->sc_data_direction == DMA_FROM_DEVICE) 295 else if (cmd->sc_data_direction == DMA_FROM_DEVICE)
296 cmd_entry->control_flags = CF_READ; 296 cmd_entry->control_flags = CF_READ;
297
298 ha->bytes_xfered += cmd->request_bufflen;
299 if (ha->bytes_xfered & ~0xFFFFF){
300 ha->total_mbytes_xferred += ha->bytes_xfered >> 20;
301 ha->bytes_xfered &= 0xFFFFF;
302 }
297 } 303 }
298 304
299 /* Set tagged queueing control flags */ 305 /* Set tagged queueing control flags */
diff --git a/drivers/scsi/qla4xxx/ql4_isr.c b/drivers/scsi/qla4xxx/ql4_isr.c
index 1e283321a59d..ef975e0dc87f 100644
--- a/drivers/scsi/qla4xxx/ql4_isr.c
+++ b/drivers/scsi/qla4xxx/ql4_isr.c
@@ -627,6 +627,7 @@ irqreturn_t qla4xxx_intr_handler(int irq, void *dev_id)
627 627
628 spin_lock_irqsave(&ha->hardware_lock, flags); 628 spin_lock_irqsave(&ha->hardware_lock, flags);
629 629
630 ha->isr_count++;
630 /* 631 /*
631 * Repeatedly service interrupts up to a maximum of 632 * Repeatedly service interrupts up to a maximum of
632 * MAX_REQS_SERVICED_PER_INTR 633 * MAX_REQS_SERVICED_PER_INTR
diff --git a/drivers/scsi/qla4xxx/ql4_nvram.c b/drivers/scsi/qla4xxx/ql4_nvram.c
index e3957ca5b645..58afd135aa1d 100644
--- a/drivers/scsi/qla4xxx/ql4_nvram.c
+++ b/drivers/scsi/qla4xxx/ql4_nvram.c
@@ -7,15 +7,22 @@
7 7
8#include "ql4_def.h" 8#include "ql4_def.h"
9 9
10static inline void eeprom_cmd(uint32_t cmd, struct scsi_qla_host *ha)
11{
12 writel(cmd, isp_nvram(ha));
13 readl(isp_nvram(ha));
14 udelay(1);
15}
16
10static inline int eeprom_size(struct scsi_qla_host *ha) 17static inline int eeprom_size(struct scsi_qla_host *ha)
11{ 18{
12 return is_qla4022(ha) ? FM93C86A_SIZE_16 : FM93C66A_SIZE_16; 19 return is_qla4010(ha) ? FM93C66A_SIZE_16 : FM93C86A_SIZE_16;
13} 20}
14 21
15static inline int eeprom_no_addr_bits(struct scsi_qla_host *ha) 22static inline int eeprom_no_addr_bits(struct scsi_qla_host *ha)
16{ 23{
17 return is_qla4022(ha) ? FM93C86A_NO_ADDR_BITS_16 : 24 return is_qla4010(ha) ? FM93C56A_NO_ADDR_BITS_16 :
18 FM93C56A_NO_ADDR_BITS_16; 25 FM93C86A_NO_ADDR_BITS_16 ;
19} 26}
20 27
21static inline int eeprom_no_data_bits(struct scsi_qla_host *ha) 28static inline int eeprom_no_data_bits(struct scsi_qla_host *ha)
@@ -28,8 +35,7 @@ static int fm93c56a_select(struct scsi_qla_host * ha)
28 DEBUG5(printk(KERN_ERR "fm93c56a_select:\n")); 35 DEBUG5(printk(KERN_ERR "fm93c56a_select:\n"));
29 36
30 ha->eeprom_cmd_data = AUBURN_EEPROM_CS_1 | 0x000f0000; 37 ha->eeprom_cmd_data = AUBURN_EEPROM_CS_1 | 0x000f0000;
31 writel(ha->eeprom_cmd_data, isp_nvram(ha)); 38 eeprom_cmd(ha->eeprom_cmd_data, ha);
32 readl(isp_nvram(ha));
33 return 1; 39 return 1;
34} 40}
35 41
@@ -41,12 +47,13 @@ static int fm93c56a_cmd(struct scsi_qla_host * ha, int cmd, int addr)
41 int previousBit; 47 int previousBit;
42 48
43 /* Clock in a zero, then do the start bit. */ 49 /* Clock in a zero, then do the start bit. */
44 writel(ha->eeprom_cmd_data | AUBURN_EEPROM_DO_1, isp_nvram(ha)); 50 eeprom_cmd(ha->eeprom_cmd_data | AUBURN_EEPROM_DO_1, ha);
45 writel(ha->eeprom_cmd_data | AUBURN_EEPROM_DO_1 | 51
46 AUBURN_EEPROM_CLK_RISE, isp_nvram(ha)); 52 eeprom_cmd(ha->eeprom_cmd_data | AUBURN_EEPROM_DO_1 |
47 writel(ha->eeprom_cmd_data | AUBURN_EEPROM_DO_1 | 53 AUBURN_EEPROM_CLK_RISE, ha);
48 AUBURN_EEPROM_CLK_FALL, isp_nvram(ha)); 54 eeprom_cmd(ha->eeprom_cmd_data | AUBURN_EEPROM_DO_1 |
49 readl(isp_nvram(ha)); 55 AUBURN_EEPROM_CLK_FALL, ha);
56
50 mask = 1 << (FM93C56A_CMD_BITS - 1); 57 mask = 1 << (FM93C56A_CMD_BITS - 1);
51 58
52 /* Force the previous data bit to be different. */ 59 /* Force the previous data bit to be different. */
@@ -60,14 +67,14 @@ static int fm93c56a_cmd(struct scsi_qla_host * ha, int cmd, int addr)
60 * If the bit changed, then change the DO state to 67 * If the bit changed, then change the DO state to
61 * match. 68 * match.
62 */ 69 */
63 writel(ha->eeprom_cmd_data | dataBit, isp_nvram(ha)); 70 eeprom_cmd(ha->eeprom_cmd_data | dataBit, ha);
64 previousBit = dataBit; 71 previousBit = dataBit;
65 } 72 }
66 writel(ha->eeprom_cmd_data | dataBit | 73 eeprom_cmd(ha->eeprom_cmd_data | dataBit |
67 AUBURN_EEPROM_CLK_RISE, isp_nvram(ha)); 74 AUBURN_EEPROM_CLK_RISE, ha);
68 writel(ha->eeprom_cmd_data | dataBit | 75 eeprom_cmd(ha->eeprom_cmd_data | dataBit |
69 AUBURN_EEPROM_CLK_FALL, isp_nvram(ha)); 76 AUBURN_EEPROM_CLK_FALL, ha);
70 readl(isp_nvram(ha)); 77
71 cmd = cmd << 1; 78 cmd = cmd << 1;
72 } 79 }
73 mask = 1 << (eeprom_no_addr_bits(ha) - 1); 80 mask = 1 << (eeprom_no_addr_bits(ha) - 1);
@@ -82,14 +89,15 @@ static int fm93c56a_cmd(struct scsi_qla_host * ha, int cmd, int addr)
82 * If the bit changed, then change the DO state to 89 * If the bit changed, then change the DO state to
83 * match. 90 * match.
84 */ 91 */
85 writel(ha->eeprom_cmd_data | dataBit, isp_nvram(ha)); 92 eeprom_cmd(ha->eeprom_cmd_data | dataBit, ha);
93
86 previousBit = dataBit; 94 previousBit = dataBit;
87 } 95 }
88 writel(ha->eeprom_cmd_data | dataBit | 96 eeprom_cmd(ha->eeprom_cmd_data | dataBit |
89 AUBURN_EEPROM_CLK_RISE, isp_nvram(ha)); 97 AUBURN_EEPROM_CLK_RISE, ha);
90 writel(ha->eeprom_cmd_data | dataBit | 98 eeprom_cmd(ha->eeprom_cmd_data | dataBit |
91 AUBURN_EEPROM_CLK_FALL, isp_nvram(ha)); 99 AUBURN_EEPROM_CLK_FALL, ha);
92 readl(isp_nvram(ha)); 100
93 addr = addr << 1; 101 addr = addr << 1;
94 } 102 }
95 return 1; 103 return 1;
@@ -98,8 +106,7 @@ static int fm93c56a_cmd(struct scsi_qla_host * ha, int cmd, int addr)
98static int fm93c56a_deselect(struct scsi_qla_host * ha) 106static int fm93c56a_deselect(struct scsi_qla_host * ha)
99{ 107{
100 ha->eeprom_cmd_data = AUBURN_EEPROM_CS_0 | 0x000f0000; 108 ha->eeprom_cmd_data = AUBURN_EEPROM_CS_0 | 0x000f0000;
101 writel(ha->eeprom_cmd_data, isp_nvram(ha)); 109 eeprom_cmd(ha->eeprom_cmd_data, ha);
102 readl(isp_nvram(ha));
103 return 1; 110 return 1;
104} 111}
105 112
@@ -112,12 +119,13 @@ static int fm93c56a_datain(struct scsi_qla_host * ha, unsigned short *value)
112 /* Read the data bits 119 /* Read the data bits
113 * The first bit is a dummy. Clock right over it. */ 120 * The first bit is a dummy. Clock right over it. */
114 for (i = 0; i < eeprom_no_data_bits(ha); i++) { 121 for (i = 0; i < eeprom_no_data_bits(ha); i++) {
115 writel(ha->eeprom_cmd_data | 122 eeprom_cmd(ha->eeprom_cmd_data |
116 AUBURN_EEPROM_CLK_RISE, isp_nvram(ha)); 123 AUBURN_EEPROM_CLK_RISE, ha);
117 writel(ha->eeprom_cmd_data | 124 eeprom_cmd(ha->eeprom_cmd_data |
118 AUBURN_EEPROM_CLK_FALL, isp_nvram(ha)); 125 AUBURN_EEPROM_CLK_FALL, ha);
119 dataBit = 126
120 (readw(isp_nvram(ha)) & AUBURN_EEPROM_DI_1) ? 1 : 0; 127 dataBit = (readw(isp_nvram(ha)) & AUBURN_EEPROM_DI_1) ? 1 : 0;
128
121 data = (data << 1) | dataBit; 129 data = (data << 1) | dataBit;
122 } 130 }
123 131
diff --git a/drivers/scsi/qla4xxx/ql4_nvram.h b/drivers/scsi/qla4xxx/ql4_nvram.h
index 08e2aed8c6cc..b47b4fc59d83 100644
--- a/drivers/scsi/qla4xxx/ql4_nvram.h
+++ b/drivers/scsi/qla4xxx/ql4_nvram.h
@@ -134,9 +134,7 @@ struct eeprom_data {
134 u16 phyConfig; /* x36 */ 134 u16 phyConfig; /* x36 */
135#define PHY_CONFIG_PHY_ADDR_MASK 0x1f 135#define PHY_CONFIG_PHY_ADDR_MASK 0x1f
136#define PHY_CONFIG_ENABLE_FW_MANAGEMENT_MASK 0x20 136#define PHY_CONFIG_ENABLE_FW_MANAGEMENT_MASK 0x20
137 u16 topcat; /* x38 */ 137 u16 reserved_56; /* x38 */
138#define TOPCAT_PRESENT 0x0100
139#define TOPCAT_MASK 0xFF00
140 138
141#define EEPROM_UNUSED_1_SIZE 2 139#define EEPROM_UNUSED_1_SIZE 2
142 u8 unused_1[EEPROM_UNUSED_1_SIZE]; /* x3A */ 140 u8 unused_1[EEPROM_UNUSED_1_SIZE]; /* x3A */
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index 5b8db6109536..9ef693c8809a 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -19,7 +19,7 @@ char qla4xxx_version_str[40];
19/* 19/*
20 * SRB allocation cache 20 * SRB allocation cache
21 */ 21 */
22static kmem_cache_t *srb_cachep; 22static struct kmem_cache *srb_cachep;
23 23
24/* 24/*
25 * Module parameter information and variables 25 * Module parameter information and variables
@@ -708,10 +708,10 @@ static int qla4xxx_cmd_wait(struct scsi_qla_host *ha)
708} 708}
709 709
710/** 710/**
711 * qla4010_soft_reset - performs soft reset. 711 * qla4xxx_soft_reset - performs soft reset.
712 * @ha: Pointer to host adapter structure. 712 * @ha: Pointer to host adapter structure.
713 **/ 713 **/
714static int qla4010_soft_reset(struct scsi_qla_host *ha) 714int qla4xxx_soft_reset(struct scsi_qla_host *ha)
715{ 715{
716 uint32_t max_wait_time; 716 uint32_t max_wait_time;
717 unsigned long flags = 0; 717 unsigned long flags = 0;
@@ -817,29 +817,6 @@ static int qla4010_soft_reset(struct scsi_qla_host *ha)
817} 817}
818 818
819/** 819/**
820 * qla4xxx_topcat_reset - performs hard reset of TopCat Chip.
821 * @ha: Pointer to host adapter structure.
822 **/
823static int qla4xxx_topcat_reset(struct scsi_qla_host *ha)
824{
825 unsigned long flags;
826
827 ql4xxx_lock_nvram(ha);
828 spin_lock_irqsave(&ha->hardware_lock, flags);
829 writel(set_rmask(GPOR_TOPCAT_RESET), isp_gp_out(ha));
830 readl(isp_gp_out(ha));
831 mdelay(1);
832
833 writel(clr_rmask(GPOR_TOPCAT_RESET), isp_gp_out(ha));
834 readl(isp_gp_out(ha));
835 spin_unlock_irqrestore(&ha->hardware_lock, flags);
836 mdelay(2523);
837
838 ql4xxx_unlock_nvram(ha);
839 return QLA_SUCCESS;
840}
841
842/**
843 * qla4xxx_flush_active_srbs - returns all outstanding i/o requests to O.S. 820 * qla4xxx_flush_active_srbs - returns all outstanding i/o requests to O.S.
844 * @ha: Pointer to host adapter structure. 821 * @ha: Pointer to host adapter structure.
845 * 822 *
@@ -867,26 +844,6 @@ static void qla4xxx_flush_active_srbs(struct scsi_qla_host *ha)
867} 844}
868 845
869/** 846/**
870 * qla4xxx_hard_reset - performs HBA Hard Reset
871 * @ha: Pointer to host adapter structure.
872 **/
873static int qla4xxx_hard_reset(struct scsi_qla_host *ha)
874{
875 /* The QLA4010 really doesn't have an equivalent to a hard reset */
876 qla4xxx_flush_active_srbs(ha);
877 if (test_bit(AF_TOPCAT_CHIP_PRESENT, &ha->flags)) {
878 int status = QLA_ERROR;
879
880 if ((qla4010_soft_reset(ha) == QLA_SUCCESS) &&
881 (qla4xxx_topcat_reset(ha) == QLA_SUCCESS) &&
882 (qla4010_soft_reset(ha) == QLA_SUCCESS))
883 status = QLA_SUCCESS;
884 return status;
885 } else
886 return qla4010_soft_reset(ha);
887}
888
889/**
890 * qla4xxx_recover_adapter - recovers adapter after a fatal error 847 * qla4xxx_recover_adapter - recovers adapter after a fatal error
891 * @ha: Pointer to host adapter structure. 848 * @ha: Pointer to host adapter structure.
892 * @renew_ddb_list: Indicates what to do with the adapter's ddb list 849 * @renew_ddb_list: Indicates what to do with the adapter's ddb list
@@ -919,18 +876,11 @@ static int qla4xxx_recover_adapter(struct scsi_qla_host *ha,
919 if (status == QLA_SUCCESS) { 876 if (status == QLA_SUCCESS) {
920 DEBUG2(printk("scsi%ld: %s - Performing soft reset..\n", 877 DEBUG2(printk("scsi%ld: %s - Performing soft reset..\n",
921 ha->host_no, __func__)); 878 ha->host_no, __func__));
922 status = qla4xxx_soft_reset(ha); 879 qla4xxx_flush_active_srbs(ha);
923 } 880 if (ql4xxx_lock_drvr_wait(ha) == QLA_SUCCESS)
924 /* FIXMEkaren: Do we want to keep interrupts enabled and process 881 status = qla4xxx_soft_reset(ha);
925 AENs after soft reset */ 882 else
926 883 status = QLA_ERROR;
927 /* If firmware (SOFT) reset failed, or if all outstanding
928 * commands have not returned, then do a HARD reset.
929 */
930 if (status == QLA_ERROR) {
931 DEBUG2(printk("scsi%ld: %s - Performing hard reset..\n",
932 ha->host_no, __func__));
933 status = qla4xxx_hard_reset(ha);
934 } 884 }
935 885
936 /* Flush any pending ddb changed AENs */ 886 /* Flush any pending ddb changed AENs */
@@ -1011,18 +961,15 @@ static int qla4xxx_recover_adapter(struct scsi_qla_host *ha,
1011 * the mid-level tries to sleep when it reaches the driver threshold 961 * the mid-level tries to sleep when it reaches the driver threshold
1012 * "host->can_queue". This can cause a panic if we were in our interrupt code. 962 * "host->can_queue". This can cause a panic if we were in our interrupt code.
1013 **/ 963 **/
1014static void qla4xxx_do_dpc(void *data) 964static void qla4xxx_do_dpc(struct work_struct *work)
1015{ 965{
1016 struct scsi_qla_host *ha = (struct scsi_qla_host *) data; 966 struct scsi_qla_host *ha =
967 container_of(work, struct scsi_qla_host, dpc_work);
1017 struct ddb_entry *ddb_entry, *dtemp; 968 struct ddb_entry *ddb_entry, *dtemp;
1018 969
1019 DEBUG2(printk("scsi%ld: %s: DPC handler waking up.\n", 970 DEBUG2(printk("scsi%ld: %s: DPC handler waking up."
1020 ha->host_no, __func__)); 971 "flags = 0x%08lx, dpc_flags = 0x%08lx\n",
1021 972 ha->host_no, __func__, ha->flags, ha->dpc_flags));
1022 DEBUG2(printk("scsi%ld: %s: ha->flags = 0x%08lx\n",
1023 ha->host_no, __func__, ha->flags));
1024 DEBUG2(printk("scsi%ld: %s: ha->dpc_flags = 0x%08lx\n",
1025 ha->host_no, __func__, ha->dpc_flags));
1026 973
1027 /* Initialization not yet finished. Don't do anything yet. */ 974 /* Initialization not yet finished. Don't do anything yet. */
1028 if (!test_bit(AF_INIT_DONE, &ha->flags)) 975 if (!test_bit(AF_INIT_DONE, &ha->flags))
@@ -1032,16 +979,8 @@ static void qla4xxx_do_dpc(void *data)
1032 test_bit(DPC_RESET_HA, &ha->dpc_flags) || 979 test_bit(DPC_RESET_HA, &ha->dpc_flags) ||
1033 test_bit(DPC_RESET_HA_INTR, &ha->dpc_flags) || 980 test_bit(DPC_RESET_HA_INTR, &ha->dpc_flags) ||
1034 test_bit(DPC_RESET_HA_DESTROY_DDB_LIST, &ha->dpc_flags)) { 981 test_bit(DPC_RESET_HA_DESTROY_DDB_LIST, &ha->dpc_flags)) {
1035 if (test_bit(DPC_RESET_HA_DESTROY_DDB_LIST, &ha->dpc_flags)) 982 if (test_bit(DPC_RESET_HA_DESTROY_DDB_LIST, &ha->dpc_flags) ||
1036 /* 983 test_bit(DPC_RESET_HA, &ha->dpc_flags))
1037 * dg 09/23 Never initialize ddb list
1038 * once we up and running
1039 * qla4xxx_recover_adapter(ha,
1040 * REBUILD_DDB_LIST);
1041 */
1042 qla4xxx_recover_adapter(ha, PRESERVE_DDB_LIST);
1043
1044 if (test_bit(DPC_RESET_HA, &ha->dpc_flags))
1045 qla4xxx_recover_adapter(ha, PRESERVE_DDB_LIST); 984 qla4xxx_recover_adapter(ha, PRESERVE_DDB_LIST);
1046 985
1047 if (test_and_clear_bit(DPC_RESET_HA_INTR, &ha->dpc_flags)) { 986 if (test_and_clear_bit(DPC_RESET_HA_INTR, &ha->dpc_flags)) {
@@ -1122,7 +1061,8 @@ static void qla4xxx_free_adapter(struct scsi_qla_host *ha)
1122 destroy_workqueue(ha->dpc_thread); 1061 destroy_workqueue(ha->dpc_thread);
1123 1062
1124 /* Issue Soft Reset to put firmware in unknown state */ 1063 /* Issue Soft Reset to put firmware in unknown state */
1125 qla4xxx_soft_reset(ha); 1064 if (ql4xxx_lock_drvr_wait(ha) == QLA_SUCCESS)
1065 qla4xxx_soft_reset(ha);
1126 1066
1127 /* Remove timer thread, if present */ 1067 /* Remove timer thread, if present */
1128 if (ha->timer_active) 1068 if (ha->timer_active)
@@ -1261,7 +1201,6 @@ static int __devinit qla4xxx_probe_adapter(struct pci_dev *pdev,
1261 init_waitqueue_head(&ha->mailbox_wait_queue); 1201 init_waitqueue_head(&ha->mailbox_wait_queue);
1262 1202
1263 spin_lock_init(&ha->hardware_lock); 1203 spin_lock_init(&ha->hardware_lock);
1264 spin_lock_init(&ha->list_lock);
1265 1204
1266 /* Allocate dma buffers */ 1205 /* Allocate dma buffers */
1267 if (qla4xxx_mem_alloc(ha)) { 1206 if (qla4xxx_mem_alloc(ha)) {
@@ -1315,7 +1254,7 @@ static int __devinit qla4xxx_probe_adapter(struct pci_dev *pdev,
1315 ret = -ENODEV; 1254 ret = -ENODEV;
1316 goto probe_failed; 1255 goto probe_failed;
1317 } 1256 }
1318 INIT_WORK(&ha->dpc_work, qla4xxx_do_dpc, ha); 1257 INIT_WORK(&ha->dpc_work, qla4xxx_do_dpc);
1319 1258
1320 ret = request_irq(pdev->irq, qla4xxx_intr_handler, 1259 ret = request_irq(pdev->irq, qla4xxx_intr_handler,
1321 SA_INTERRUPT|SA_SHIRQ, "qla4xxx", ha); 1260 SA_INTERRUPT|SA_SHIRQ, "qla4xxx", ha);
@@ -1468,27 +1407,6 @@ struct srb * qla4xxx_del_from_active_array(struct scsi_qla_host *ha, uint32_t in
1468} 1407}
1469 1408
1470/** 1409/**
1471 * qla4xxx_soft_reset - performs a SOFT RESET of hba.
1472 * @ha: Pointer to host adapter structure.
1473 **/
1474int qla4xxx_soft_reset(struct scsi_qla_host *ha)
1475{
1476
1477 DEBUG2(printk(KERN_WARNING "scsi%ld: %s: chip reset!\n", ha->host_no,
1478 __func__));
1479 if (test_bit(AF_TOPCAT_CHIP_PRESENT, &ha->flags)) {
1480 int status = QLA_ERROR;
1481
1482 if ((qla4010_soft_reset(ha) == QLA_SUCCESS) &&
1483 (qla4xxx_topcat_reset(ha) == QLA_SUCCESS) &&
1484 (qla4010_soft_reset(ha) == QLA_SUCCESS) )
1485 status = QLA_SUCCESS;
1486 return status;
1487 } else
1488 return qla4010_soft_reset(ha);
1489}
1490
1491/**
1492 * qla4xxx_eh_wait_on_command - waits for command to be returned by firmware 1410 * qla4xxx_eh_wait_on_command - waits for command to be returned by firmware
1493 * @ha: actual ha whose done queue will contain the comd returned by firmware. 1411 * @ha: actual ha whose done queue will contain the comd returned by firmware.
1494 * @cmd: Scsi Command to wait on. 1412 * @cmd: Scsi Command to wait on.
@@ -1686,6 +1604,12 @@ static struct pci_device_id qla4xxx_pci_tbl[] = {
1686 .subvendor = PCI_ANY_ID, 1604 .subvendor = PCI_ANY_ID,
1687 .subdevice = PCI_ANY_ID, 1605 .subdevice = PCI_ANY_ID,
1688 }, 1606 },
1607 {
1608 .vendor = PCI_VENDOR_ID_QLOGIC,
1609 .device = PCI_DEVICE_ID_QLOGIC_ISP4032,
1610 .subvendor = PCI_ANY_ID,
1611 .subdevice = PCI_ANY_ID,
1612 },
1689 {0, 0}, 1613 {0, 0},
1690}; 1614};
1691MODULE_DEVICE_TABLE(pci, qla4xxx_pci_tbl); 1615MODULE_DEVICE_TABLE(pci, qla4xxx_pci_tbl);
diff --git a/drivers/scsi/qla4xxx/ql4_version.h b/drivers/scsi/qla4xxx/ql4_version.h
index b3fe7e68988e..454e19c8ad68 100644
--- a/drivers/scsi/qla4xxx/ql4_version.h
+++ b/drivers/scsi/qla4xxx/ql4_version.h
@@ -5,9 +5,4 @@
5 * See LICENSE.qla4xxx for copyright and licensing details. 5 * See LICENSE.qla4xxx for copyright and licensing details.
6 */ 6 */
7 7
8#define QLA4XXX_DRIVER_VERSION "5.00.05b9-k" 8#define QLA4XXX_DRIVER_VERSION "5.00.07-k"
9
10#define QL4_DRIVER_MAJOR_VER 5
11#define QL4_DRIVER_MINOR_VER 0
12#define QL4_DRIVER_PATCH_VER 5
13#define QL4_DRIVER_BETA_VER 9
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index c59f31533ab4..24cffd98ee63 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -136,7 +136,7 @@ const char * scsi_device_type(unsigned type)
136EXPORT_SYMBOL(scsi_device_type); 136EXPORT_SYMBOL(scsi_device_type);
137 137
138struct scsi_host_cmd_pool { 138struct scsi_host_cmd_pool {
139 kmem_cache_t *slab; 139 struct kmem_cache *slab;
140 unsigned int users; 140 unsigned int users;
141 char *name; 141 char *name;
142 unsigned int slab_flags; 142 unsigned int slab_flags;
@@ -156,8 +156,7 @@ static struct scsi_host_cmd_pool scsi_cmd_dma_pool = {
156 156
157static DEFINE_MUTEX(host_cmd_pool_mutex); 157static DEFINE_MUTEX(host_cmd_pool_mutex);
158 158
159static struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *shost, 159struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *shost, gfp_t gfp_mask)
160 gfp_t gfp_mask)
161{ 160{
162 struct scsi_cmnd *cmd; 161 struct scsi_cmnd *cmd;
163 162
@@ -178,6 +177,7 @@ static struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *shost,
178 177
179 return cmd; 178 return cmd;
180} 179}
180EXPORT_SYMBOL_GPL(__scsi_get_command);
181 181
182/* 182/*
183 * Function: scsi_get_command() 183 * Function: scsi_get_command()
@@ -214,9 +214,29 @@ struct scsi_cmnd *scsi_get_command(struct scsi_device *dev, gfp_t gfp_mask)
214 put_device(&dev->sdev_gendev); 214 put_device(&dev->sdev_gendev);
215 215
216 return cmd; 216 return cmd;
217} 217}
218EXPORT_SYMBOL(scsi_get_command); 218EXPORT_SYMBOL(scsi_get_command);
219 219
220void __scsi_put_command(struct Scsi_Host *shost, struct scsi_cmnd *cmd,
221 struct device *dev)
222{
223 unsigned long flags;
224
225 /* changing locks here, don't need to restore the irq state */
226 spin_lock_irqsave(&shost->free_list_lock, flags);
227 if (unlikely(list_empty(&shost->free_list))) {
228 list_add(&cmd->list, &shost->free_list);
229 cmd = NULL;
230 }
231 spin_unlock_irqrestore(&shost->free_list_lock, flags);
232
233 if (likely(cmd != NULL))
234 kmem_cache_free(shost->cmd_pool->slab, cmd);
235
236 put_device(dev);
237}
238EXPORT_SYMBOL(__scsi_put_command);
239
220/* 240/*
221 * Function: scsi_put_command() 241 * Function: scsi_put_command()
222 * 242 *
@@ -231,26 +251,15 @@ EXPORT_SYMBOL(scsi_get_command);
231void scsi_put_command(struct scsi_cmnd *cmd) 251void scsi_put_command(struct scsi_cmnd *cmd)
232{ 252{
233 struct scsi_device *sdev = cmd->device; 253 struct scsi_device *sdev = cmd->device;
234 struct Scsi_Host *shost = sdev->host;
235 unsigned long flags; 254 unsigned long flags;
236 255
237 /* serious error if the command hasn't come from a device list */ 256 /* serious error if the command hasn't come from a device list */
238 spin_lock_irqsave(&cmd->device->list_lock, flags); 257 spin_lock_irqsave(&cmd->device->list_lock, flags);
239 BUG_ON(list_empty(&cmd->list)); 258 BUG_ON(list_empty(&cmd->list));
240 list_del_init(&cmd->list); 259 list_del_init(&cmd->list);
241 spin_unlock(&cmd->device->list_lock); 260 spin_unlock_irqrestore(&cmd->device->list_lock, flags);
242 /* changing locks here, don't need to restore the irq state */
243 spin_lock(&shost->free_list_lock);
244 if (unlikely(list_empty(&shost->free_list))) {
245 list_add(&cmd->list, &shost->free_list);
246 cmd = NULL;
247 }
248 spin_unlock_irqrestore(&shost->free_list_lock, flags);
249
250 if (likely(cmd != NULL))
251 kmem_cache_free(shost->cmd_pool->slab, cmd);
252 261
253 put_device(&sdev->sdev_gendev); 262 __scsi_put_command(cmd->device->host, cmd, &sdev->sdev_gendev);
254} 263}
255EXPORT_SYMBOL(scsi_put_command); 264EXPORT_SYMBOL(scsi_put_command);
256 265
@@ -871,9 +880,9 @@ EXPORT_SYMBOL(scsi_device_get);
871 */ 880 */
872void scsi_device_put(struct scsi_device *sdev) 881void scsi_device_put(struct scsi_device *sdev)
873{ 882{
883#ifdef CONFIG_MODULE_UNLOAD
874 struct module *module = sdev->host->hostt->module; 884 struct module *module = sdev->host->hostt->module;
875 885
876#ifdef CONFIG_MODULE_UNLOAD
877 /* The module refcount will be zero if scsi_device_get() 886 /* The module refcount will be zero if scsi_device_get()
878 * was called from a module removal routine */ 887 * was called from a module removal routine */
879 if (module && module_refcount(module) != 0) 888 if (module && module_refcount(module) != 0)
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index aff1b0cfd4b2..2ecb6ff42444 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -453,9 +453,18 @@ static void scsi_eh_done(struct scsi_cmnd *scmd)
453} 453}
454 454
455/** 455/**
456 * scsi_send_eh_cmnd - send a cmd to a device as part of error recovery. 456 * scsi_send_eh_cmnd - submit a scsi command as part of error recory
457 * @scmd: SCSI Cmd to send. 457 * @scmd: SCSI command structure to hijack
458 * @timeout: Timeout for cmd. 458 * @cmnd: CDB to send
459 * @cmnd_size: size in bytes of @cmnd
460 * @timeout: timeout for this request
461 * @copy_sense: request sense data if set to 1
462 *
463 * This function is used to send a scsi command down to a target device
464 * as part of the error recovery process. If @copy_sense is 0 the command
465 * sent must be one that does not transfer any data. If @copy_sense is 1
466 * the command must be REQUEST_SENSE and this functions copies out the
467 * sense buffer it got into @scmd->sense_buffer.
459 * 468 *
460 * Return value: 469 * Return value:
461 * SUCCESS or FAILED or NEEDS_RETRY 470 * SUCCESS or FAILED or NEEDS_RETRY
@@ -469,6 +478,7 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, unsigned char *cmnd,
469 DECLARE_COMPLETION_ONSTACK(done); 478 DECLARE_COMPLETION_ONSTACK(done);
470 unsigned long timeleft; 479 unsigned long timeleft;
471 unsigned long flags; 480 unsigned long flags;
481 struct scatterlist sgl;
472 unsigned char old_cmnd[MAX_COMMAND_SIZE]; 482 unsigned char old_cmnd[MAX_COMMAND_SIZE];
473 enum dma_data_direction old_data_direction; 483 enum dma_data_direction old_data_direction;
474 unsigned short old_use_sg; 484 unsigned short old_use_sg;
@@ -500,19 +510,24 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, unsigned char *cmnd,
500 if (shost->hostt->unchecked_isa_dma) 510 if (shost->hostt->unchecked_isa_dma)
501 gfp_mask |= __GFP_DMA; 511 gfp_mask |= __GFP_DMA;
502 512
503 scmd->sc_data_direction = DMA_FROM_DEVICE; 513 sgl.page = alloc_page(gfp_mask);
504 scmd->request_bufflen = 252; 514 if (!sgl.page)
505 scmd->request_buffer = kzalloc(scmd->request_bufflen, gfp_mask);
506 if (!scmd->request_buffer)
507 return FAILED; 515 return FAILED;
516 sgl.offset = 0;
517 sgl.length = 252;
518
519 scmd->sc_data_direction = DMA_FROM_DEVICE;
520 scmd->request_bufflen = sgl.length;
521 scmd->request_buffer = &sgl;
522 scmd->use_sg = 1;
508 } else { 523 } else {
509 scmd->request_buffer = NULL; 524 scmd->request_buffer = NULL;
510 scmd->request_bufflen = 0; 525 scmd->request_bufflen = 0;
511 scmd->sc_data_direction = DMA_NONE; 526 scmd->sc_data_direction = DMA_NONE;
527 scmd->use_sg = 0;
512 } 528 }
513 529
514 scmd->underflow = 0; 530 scmd->underflow = 0;
515 scmd->use_sg = 0;
516 scmd->cmd_len = COMMAND_SIZE(scmd->cmnd[0]); 531 scmd->cmd_len = COMMAND_SIZE(scmd->cmnd[0]);
517 532
518 if (sdev->scsi_level <= SCSI_2) 533 if (sdev->scsi_level <= SCSI_2)
@@ -583,7 +598,7 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, unsigned char *cmnd,
583 memcpy(scmd->sense_buffer, scmd->request_buffer, 598 memcpy(scmd->sense_buffer, scmd->request_buffer,
584 sizeof(scmd->sense_buffer)); 599 sizeof(scmd->sense_buffer));
585 } 600 }
586 kfree(scmd->request_buffer); 601 __free_page(sgl.page);
587 } 602 }
588 603
589 604
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index d2c02df12fdc..1748e27501cd 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -36,7 +36,7 @@
36struct scsi_host_sg_pool { 36struct scsi_host_sg_pool {
37 size_t size; 37 size_t size;
38 char *name; 38 char *name;
39 kmem_cache_t *slab; 39 struct kmem_cache *slab;
40 mempool_t *pool; 40 mempool_t *pool;
41}; 41};
42 42
@@ -241,7 +241,7 @@ struct scsi_io_context {
241 char sense[SCSI_SENSE_BUFFERSIZE]; 241 char sense[SCSI_SENSE_BUFFERSIZE];
242}; 242};
243 243
244static kmem_cache_t *scsi_io_context_cache; 244static struct kmem_cache *scsi_io_context_cache;
245 245
246static void scsi_end_async(struct request *req, int uptodate) 246static void scsi_end_async(struct request *req, int uptodate)
247{ 247{
@@ -410,6 +410,7 @@ int scsi_execute_async(struct scsi_device *sdev, const unsigned char *cmd,
410 goto free_req; 410 goto free_req;
411 411
412 req->cmd_len = cmd_len; 412 req->cmd_len = cmd_len;
413 memset(req->cmd, 0, BLK_MAX_CDB); /* ATAPI hates garbage after CDB */
413 memcpy(req->cmd, cmd, req->cmd_len); 414 memcpy(req->cmd, cmd, req->cmd_len);
414 req->sense = sioc->sense; 415 req->sense = sioc->sense;
415 req->sense_len = 0; 416 req->sense_len = 0;
@@ -703,7 +704,7 @@ static struct scsi_cmnd *scsi_end_request(struct scsi_cmnd *cmd, int uptodate,
703 return NULL; 704 return NULL;
704} 705}
705 706
706static struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *cmd, gfp_t gfp_mask) 707struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *cmd, gfp_t gfp_mask)
707{ 708{
708 struct scsi_host_sg_pool *sgp; 709 struct scsi_host_sg_pool *sgp;
709 struct scatterlist *sgl; 710 struct scatterlist *sgl;
@@ -744,7 +745,9 @@ static struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *cmd, gfp_t gfp_m
744 return sgl; 745 return sgl;
745} 746}
746 747
747static void scsi_free_sgtable(struct scatterlist *sgl, int index) 748EXPORT_SYMBOL(scsi_alloc_sgtable);
749
750void scsi_free_sgtable(struct scatterlist *sgl, int index)
748{ 751{
749 struct scsi_host_sg_pool *sgp; 752 struct scsi_host_sg_pool *sgp;
750 753
@@ -754,6 +757,8 @@ static void scsi_free_sgtable(struct scatterlist *sgl, int index)
754 mempool_free(sgl, sgp->pool); 757 mempool_free(sgl, sgp->pool);
755} 758}
756 759
760EXPORT_SYMBOL(scsi_free_sgtable);
761
757/* 762/*
758 * Function: scsi_release_buffers() 763 * Function: scsi_release_buffers()
759 * 764 *
@@ -995,25 +1000,14 @@ static int scsi_init_io(struct scsi_cmnd *cmd)
995 int count; 1000 int count;
996 1001
997 /* 1002 /*
998 * if this is a rq->data based REQ_BLOCK_PC, setup for a non-sg xfer 1003 * We used to not use scatter-gather for single segment request,
999 */
1000 if (blk_pc_request(req) && !req->bio) {
1001 cmd->request_bufflen = req->data_len;
1002 cmd->request_buffer = req->data;
1003 req->buffer = req->data;
1004 cmd->use_sg = 0;
1005 return 0;
1006 }
1007
1008 /*
1009 * we used to not use scatter-gather for single segment request,
1010 * but now we do (it makes highmem I/O easier to support without 1004 * but now we do (it makes highmem I/O easier to support without
1011 * kmapping pages) 1005 * kmapping pages)
1012 */ 1006 */
1013 cmd->use_sg = req->nr_phys_segments; 1007 cmd->use_sg = req->nr_phys_segments;
1014 1008
1015 /* 1009 /*
1016 * if sg table allocation fails, requeue request later. 1010 * If sg table allocation fails, requeue request later.
1017 */ 1011 */
1018 sgpnt = scsi_alloc_sgtable(cmd, GFP_ATOMIC); 1012 sgpnt = scsi_alloc_sgtable(cmd, GFP_ATOMIC);
1019 if (unlikely(!sgpnt)) { 1013 if (unlikely(!sgpnt)) {
@@ -1021,24 +1015,21 @@ static int scsi_init_io(struct scsi_cmnd *cmd)
1021 return BLKPREP_DEFER; 1015 return BLKPREP_DEFER;
1022 } 1016 }
1023 1017
1018 req->buffer = NULL;
1024 cmd->request_buffer = (char *) sgpnt; 1019 cmd->request_buffer = (char *) sgpnt;
1025 cmd->request_bufflen = req->nr_sectors << 9;
1026 if (blk_pc_request(req)) 1020 if (blk_pc_request(req))
1027 cmd->request_bufflen = req->data_len; 1021 cmd->request_bufflen = req->data_len;
1028 req->buffer = NULL; 1022 else
1023 cmd->request_bufflen = req->nr_sectors << 9;
1029 1024
1030 /* 1025 /*
1031 * Next, walk the list, and fill in the addresses and sizes of 1026 * Next, walk the list, and fill in the addresses and sizes of
1032 * each segment. 1027 * each segment.
1033 */ 1028 */
1034 count = blk_rq_map_sg(req->q, req, cmd->request_buffer); 1029 count = blk_rq_map_sg(req->q, req, cmd->request_buffer);
1035
1036 /*
1037 * mapped well, send it off
1038 */
1039 if (likely(count <= cmd->use_sg)) { 1030 if (likely(count <= cmd->use_sg)) {
1040 cmd->use_sg = count; 1031 cmd->use_sg = count;
1041 return 0; 1032 return BLKPREP_OK;
1042 } 1033 }
1043 1034
1044 printk(KERN_ERR "Incorrect number of segments after building list\n"); 1035 printk(KERN_ERR "Incorrect number of segments after building list\n");
@@ -1068,6 +1059,27 @@ static int scsi_issue_flush_fn(request_queue_t *q, struct gendisk *disk,
1068 return -EOPNOTSUPP; 1059 return -EOPNOTSUPP;
1069} 1060}
1070 1061
1062static struct scsi_cmnd *scsi_get_cmd_from_req(struct scsi_device *sdev,
1063 struct request *req)
1064{
1065 struct scsi_cmnd *cmd;
1066
1067 if (!req->special) {
1068 cmd = scsi_get_command(sdev, GFP_ATOMIC);
1069 if (unlikely(!cmd))
1070 return NULL;
1071 req->special = cmd;
1072 } else {
1073 cmd = req->special;
1074 }
1075
1076 /* pull a tag out of the request if we have one */
1077 cmd->tag = req->tag;
1078 cmd->request = req;
1079
1080 return cmd;
1081}
1082
1071static void scsi_blk_pc_done(struct scsi_cmnd *cmd) 1083static void scsi_blk_pc_done(struct scsi_cmnd *cmd)
1072{ 1084{
1073 BUG_ON(!blk_pc_request(cmd->request)); 1085 BUG_ON(!blk_pc_request(cmd->request));
@@ -1080,9 +1092,37 @@ static void scsi_blk_pc_done(struct scsi_cmnd *cmd)
1080 scsi_io_completion(cmd, cmd->request_bufflen); 1092 scsi_io_completion(cmd, cmd->request_bufflen);
1081} 1093}
1082 1094
1083static void scsi_setup_blk_pc_cmnd(struct scsi_cmnd *cmd) 1095static int scsi_setup_blk_pc_cmnd(struct scsi_device *sdev, struct request *req)
1084{ 1096{
1085 struct request *req = cmd->request; 1097 struct scsi_cmnd *cmd;
1098
1099 cmd = scsi_get_cmd_from_req(sdev, req);
1100 if (unlikely(!cmd))
1101 return BLKPREP_DEFER;
1102
1103 /*
1104 * BLOCK_PC requests may transfer data, in which case they must
1105 * a bio attached to them. Or they might contain a SCSI command
1106 * that does not transfer data, in which case they may optionally
1107 * submit a request without an attached bio.
1108 */
1109 if (req->bio) {
1110 int ret;
1111
1112 BUG_ON(!req->nr_phys_segments);
1113
1114 ret = scsi_init_io(cmd);
1115 if (unlikely(ret))
1116 return ret;
1117 } else {
1118 BUG_ON(req->data_len);
1119 BUG_ON(req->data);
1120
1121 cmd->request_bufflen = 0;
1122 cmd->request_buffer = NULL;
1123 cmd->use_sg = 0;
1124 req->buffer = NULL;
1125 }
1086 1126
1087 BUILD_BUG_ON(sizeof(req->cmd) > sizeof(cmd->cmnd)); 1127 BUILD_BUG_ON(sizeof(req->cmd) > sizeof(cmd->cmnd));
1088 memcpy(cmd->cmnd, req->cmd, sizeof(cmd->cmnd)); 1128 memcpy(cmd->cmnd, req->cmd, sizeof(cmd->cmnd));
@@ -1098,154 +1138,138 @@ static void scsi_setup_blk_pc_cmnd(struct scsi_cmnd *cmd)
1098 cmd->allowed = req->retries; 1138 cmd->allowed = req->retries;
1099 cmd->timeout_per_command = req->timeout; 1139 cmd->timeout_per_command = req->timeout;
1100 cmd->done = scsi_blk_pc_done; 1140 cmd->done = scsi_blk_pc_done;
1141 return BLKPREP_OK;
1101} 1142}
1102 1143
1103static int scsi_prep_fn(struct request_queue *q, struct request *req) 1144/*
1145 * Setup a REQ_TYPE_FS command. These are simple read/write request
1146 * from filesystems that still need to be translated to SCSI CDBs from
1147 * the ULD.
1148 */
1149static int scsi_setup_fs_cmnd(struct scsi_device *sdev, struct request *req)
1104{ 1150{
1105 struct scsi_device *sdev = q->queuedata;
1106 struct scsi_cmnd *cmd; 1151 struct scsi_cmnd *cmd;
1107 int specials_only = 0; 1152 struct scsi_driver *drv;
1153 int ret;
1108 1154
1109 /* 1155 /*
1110 * Just check to see if the device is online. If it isn't, we 1156 * Filesystem requests must transfer data.
1111 * refuse to process any commands. The device must be brought
1112 * online before trying any recovery commands
1113 */ 1157 */
1114 if (unlikely(!scsi_device_online(sdev))) { 1158 BUG_ON(!req->nr_phys_segments);
1115 sdev_printk(KERN_ERR, sdev, 1159
1116 "rejecting I/O to offline device\n"); 1160 cmd = scsi_get_cmd_from_req(sdev, req);
1117 goto kill; 1161 if (unlikely(!cmd))
1118 } 1162 return BLKPREP_DEFER;
1119 if (unlikely(sdev->sdev_state != SDEV_RUNNING)) { 1163
1120 /* OK, we're not in a running state don't prep 1164 ret = scsi_init_io(cmd);
1121 * user commands */ 1165 if (unlikely(ret))
1122 if (sdev->sdev_state == SDEV_DEL) { 1166 return ret;
1123 /* Device is fully deleted, no commands 1167
1124 * at all allowed down */ 1168 /*
1125 sdev_printk(KERN_ERR, sdev, 1169 * Initialize the actual SCSI command for this request.
1126 "rejecting I/O to dead device\n"); 1170 */
1127 goto kill; 1171 drv = *(struct scsi_driver **)req->rq_disk->private_data;
1128 } 1172 if (unlikely(!drv->init_command(cmd))) {
1129 /* OK, we only allow special commands (i.e. not 1173 scsi_release_buffers(cmd);
1130 * user initiated ones */ 1174 scsi_put_command(cmd);
1131 specials_only = sdev->sdev_state; 1175 return BLKPREP_KILL;
1132 } 1176 }
1133 1177
1178 return BLKPREP_OK;
1179}
1180
1181static int scsi_prep_fn(struct request_queue *q, struct request *req)
1182{
1183 struct scsi_device *sdev = q->queuedata;
1184 int ret = BLKPREP_OK;
1185
1134 /* 1186 /*
1135 * Find the actual device driver associated with this command. 1187 * If the device is not in running state we will reject some
1136 * The SPECIAL requests are things like character device or 1188 * or all commands.
1137 * ioctls, which did not originate from ll_rw_blk. Note that
1138 * the special field is also used to indicate the cmd for
1139 * the remainder of a partially fulfilled request that can
1140 * come up when there is a medium error. We have to treat
1141 * these two cases differently. We differentiate by looking
1142 * at request->cmd, as this tells us the real story.
1143 */ 1189 */
1144 if (blk_special_request(req) && req->special) 1190 if (unlikely(sdev->sdev_state != SDEV_RUNNING)) {
1145 cmd = req->special; 1191 switch (sdev->sdev_state) {
1146 else if (blk_pc_request(req) || blk_fs_request(req)) { 1192 case SDEV_OFFLINE:
1147 if (unlikely(specials_only) && !(req->cmd_flags & REQ_PREEMPT)){ 1193 /*
1148 if (specials_only == SDEV_QUIESCE || 1194 * If the device is offline we refuse to process any
1149 specials_only == SDEV_BLOCK) 1195 * commands. The device must be brought online
1150 goto defer; 1196 * before trying any recovery commands.
1151 1197 */
1152 sdev_printk(KERN_ERR, sdev, 1198 sdev_printk(KERN_ERR, sdev,
1153 "rejecting I/O to device being removed\n"); 1199 "rejecting I/O to offline device\n");
1154 goto kill; 1200 ret = BLKPREP_KILL;
1201 break;
1202 case SDEV_DEL:
1203 /*
1204 * If the device is fully deleted, we refuse to
1205 * process any commands as well.
1206 */
1207 sdev_printk(KERN_ERR, sdev,
1208 "rejecting I/O to dead device\n");
1209 ret = BLKPREP_KILL;
1210 break;
1211 case SDEV_QUIESCE:
1212 case SDEV_BLOCK:
1213 /*
1214 * If the devices is blocked we defer normal commands.
1215 */
1216 if (!(req->cmd_flags & REQ_PREEMPT))
1217 ret = BLKPREP_DEFER;
1218 break;
1219 default:
1220 /*
1221 * For any other not fully online state we only allow
1222 * special commands. In particular any user initiated
1223 * command is not allowed.
1224 */
1225 if (!(req->cmd_flags & REQ_PREEMPT))
1226 ret = BLKPREP_KILL;
1227 break;
1155 } 1228 }
1156 1229
1157 /* 1230 if (ret != BLKPREP_OK)
1158 * Now try and find a command block that we can use. 1231 goto out;
1159 */
1160 if (!req->special) {
1161 cmd = scsi_get_command(sdev, GFP_ATOMIC);
1162 if (unlikely(!cmd))
1163 goto defer;
1164 } else
1165 cmd = req->special;
1166
1167 /* pull a tag out of the request if we have one */
1168 cmd->tag = req->tag;
1169 } else {
1170 blk_dump_rq_flags(req, "SCSI bad req");
1171 goto kill;
1172 } 1232 }
1173
1174 /* note the overloading of req->special. When the tag
1175 * is active it always means cmd. If the tag goes
1176 * back for re-queueing, it may be reset */
1177 req->special = cmd;
1178 cmd->request = req;
1179
1180 /*
1181 * FIXME: drop the lock here because the functions below
1182 * expect to be called without the queue lock held. Also,
1183 * previously, we dequeued the request before dropping the
1184 * lock. We hope REQ_STARTED prevents anything untoward from
1185 * happening now.
1186 */
1187 if (blk_fs_request(req) || blk_pc_request(req)) {
1188 int ret;
1189 1233
1234 switch (req->cmd_type) {
1235 case REQ_TYPE_BLOCK_PC:
1236 ret = scsi_setup_blk_pc_cmnd(sdev, req);
1237 break;
1238 case REQ_TYPE_FS:
1239 ret = scsi_setup_fs_cmnd(sdev, req);
1240 break;
1241 default:
1190 /* 1242 /*
1191 * This will do a couple of things: 1243 * All other command types are not supported.
1192 * 1) Fill in the actual SCSI command.
1193 * 2) Fill in any other upper-level specific fields
1194 * (timeout).
1195 * 1244 *
1196 * If this returns 0, it means that the request failed 1245 * Note that these days the SCSI subsystem does not use
1197 * (reading past end of disk, reading offline device, 1246 * REQ_TYPE_SPECIAL requests anymore. These are only used
1198 * etc). This won't actually talk to the device, but 1247 * (directly or via blk_insert_request) by non-SCSI drivers.
1199 * some kinds of consistency checking may cause the
1200 * request to be rejected immediately.
1201 */ 1248 */
1249 blk_dump_rq_flags(req, "SCSI bad req");
1250 ret = BLKPREP_KILL;
1251 break;
1252 }
1202 1253
1203 /* 1254 out:
1204 * This sets up the scatter-gather table (allocating if 1255 switch (ret) {
1205 * required). 1256 case BLKPREP_KILL:
1206 */ 1257 req->errors = DID_NO_CONNECT << 16;
1207 ret = scsi_init_io(cmd); 1258 break;
1208 switch(ret) { 1259 case BLKPREP_DEFER:
1209 /* For BLKPREP_KILL/DEFER the cmd was released */
1210 case BLKPREP_KILL:
1211 goto kill;
1212 case BLKPREP_DEFER:
1213 goto defer;
1214 }
1215
1216 /* 1260 /*
1217 * Initialize the actual SCSI command for this request. 1261 * If we defer, the elv_next_request() returns NULL, but the
1262 * queue must be restarted, so we plug here if no returning
1263 * command will automatically do that.
1218 */ 1264 */
1219 if (blk_pc_request(req)) { 1265 if (sdev->device_busy == 0)
1220 scsi_setup_blk_pc_cmnd(cmd); 1266 blk_plug_device(q);
1221 } else if (req->rq_disk) { 1267 break;
1222 struct scsi_driver *drv; 1268 default:
1223 1269 req->cmd_flags |= REQ_DONTPREP;
1224 drv = *(struct scsi_driver **)req->rq_disk->private_data;
1225 if (unlikely(!drv->init_command(cmd))) {
1226 scsi_release_buffers(cmd);
1227 scsi_put_command(cmd);
1228 goto kill;
1229 }
1230 }
1231 } 1270 }
1232 1271
1233 /* 1272 return ret;
1234 * The request is now prepped, no need to come back here
1235 */
1236 req->cmd_flags |= REQ_DONTPREP;
1237 return BLKPREP_OK;
1238
1239 defer:
1240 /* If we defer, the elv_next_request() returns NULL, but the
1241 * queue must be restarted, so we plug here if no returning
1242 * command will automatically do that. */
1243 if (sdev->device_busy == 0)
1244 blk_plug_device(q);
1245 return BLKPREP_DEFER;
1246 kill:
1247 req->errors = DID_NO_CONNECT << 16;
1248 return BLKPREP_KILL;
1249} 1273}
1250 1274
1251/* 1275/*
@@ -1547,29 +1571,40 @@ u64 scsi_calculate_bounce_limit(struct Scsi_Host *shost)
1547} 1571}
1548EXPORT_SYMBOL(scsi_calculate_bounce_limit); 1572EXPORT_SYMBOL(scsi_calculate_bounce_limit);
1549 1573
1550struct request_queue *scsi_alloc_queue(struct scsi_device *sdev) 1574struct request_queue *__scsi_alloc_queue(struct Scsi_Host *shost,
1575 request_fn_proc *request_fn)
1551{ 1576{
1552 struct Scsi_Host *shost = sdev->host;
1553 struct request_queue *q; 1577 struct request_queue *q;
1554 1578
1555 q = blk_init_queue(scsi_request_fn, NULL); 1579 q = blk_init_queue(request_fn, NULL);
1556 if (!q) 1580 if (!q)
1557 return NULL; 1581 return NULL;
1558 1582
1559 blk_queue_prep_rq(q, scsi_prep_fn);
1560
1561 blk_queue_max_hw_segments(q, shost->sg_tablesize); 1583 blk_queue_max_hw_segments(q, shost->sg_tablesize);
1562 blk_queue_max_phys_segments(q, SCSI_MAX_PHYS_SEGMENTS); 1584 blk_queue_max_phys_segments(q, SCSI_MAX_PHYS_SEGMENTS);
1563 blk_queue_max_sectors(q, shost->max_sectors); 1585 blk_queue_max_sectors(q, shost->max_sectors);
1564 blk_queue_bounce_limit(q, scsi_calculate_bounce_limit(shost)); 1586 blk_queue_bounce_limit(q, scsi_calculate_bounce_limit(shost));
1565 blk_queue_segment_boundary(q, shost->dma_boundary); 1587 blk_queue_segment_boundary(q, shost->dma_boundary);
1566 blk_queue_issue_flush_fn(q, scsi_issue_flush_fn);
1567 blk_queue_softirq_done(q, scsi_softirq_done);
1568 1588
1569 if (!shost->use_clustering) 1589 if (!shost->use_clustering)
1570 clear_bit(QUEUE_FLAG_CLUSTER, &q->queue_flags); 1590 clear_bit(QUEUE_FLAG_CLUSTER, &q->queue_flags);
1571 return q; 1591 return q;
1572} 1592}
1593EXPORT_SYMBOL(__scsi_alloc_queue);
1594
1595struct request_queue *scsi_alloc_queue(struct scsi_device *sdev)
1596{
1597 struct request_queue *q;
1598
1599 q = __scsi_alloc_queue(sdev->host, scsi_request_fn);
1600 if (!q)
1601 return NULL;
1602
1603 blk_queue_prep_rq(q, scsi_prep_fn);
1604 blk_queue_issue_flush_fn(q, scsi_issue_flush_fn);
1605 blk_queue_softirq_done(q, scsi_softirq_done);
1606 return q;
1607}
1573 1608
1574void scsi_free_queue(struct request_queue *q) 1609void scsi_free_queue(struct request_queue *q)
1575{ 1610{
diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h
index 5d023d44e5e7..f458c2f686d2 100644
--- a/drivers/scsi/scsi_priv.h
+++ b/drivers/scsi/scsi_priv.h
@@ -39,6 +39,9 @@ static inline void scsi_log_completion(struct scsi_cmnd *cmd, int disposition)
39 { }; 39 { };
40#endif 40#endif
41 41
42/* scsi_scan.c */
43int scsi_complete_async_scans(void);
44
42/* scsi_devinfo.c */ 45/* scsi_devinfo.c */
43extern int scsi_get_device_flags(struct scsi_device *sdev, 46extern int scsi_get_device_flags(struct scsi_device *sdev,
44 const unsigned char *vendor, 47 const unsigned char *vendor,
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index fd9e281c3bfe..14e635aa44ce 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -29,7 +29,9 @@
29#include <linux/moduleparam.h> 29#include <linux/moduleparam.h>
30#include <linux/init.h> 30#include <linux/init.h>
31#include <linux/blkdev.h> 31#include <linux/blkdev.h>
32#include <asm/semaphore.h> 32#include <linux/delay.h>
33#include <linux/kthread.h>
34#include <linux/spinlock.h>
33 35
34#include <scsi/scsi.h> 36#include <scsi/scsi.h>
35#include <scsi/scsi_cmnd.h> 37#include <scsi/scsi_cmnd.h>
@@ -87,6 +89,17 @@ module_param_named(max_luns, max_scsi_luns, int, S_IRUGO|S_IWUSR);
87MODULE_PARM_DESC(max_luns, 89MODULE_PARM_DESC(max_luns,
88 "last scsi LUN (should be between 1 and 2^32-1)"); 90 "last scsi LUN (should be between 1 and 2^32-1)");
89 91
92#ifdef CONFIG_SCSI_SCAN_ASYNC
93#define SCSI_SCAN_TYPE_DEFAULT "async"
94#else
95#define SCSI_SCAN_TYPE_DEFAULT "sync"
96#endif
97
98static char scsi_scan_type[6] = SCSI_SCAN_TYPE_DEFAULT;
99
100module_param_string(scan, scsi_scan_type, sizeof(scsi_scan_type), S_IRUGO);
101MODULE_PARM_DESC(scan, "sync, async or none");
102
90/* 103/*
91 * max_scsi_report_luns: the maximum number of LUNS that will be 104 * max_scsi_report_luns: the maximum number of LUNS that will be
92 * returned from the REPORT LUNS command. 8 times this value must 105 * returned from the REPORT LUNS command. 8 times this value must
@@ -108,6 +121,68 @@ MODULE_PARM_DESC(inq_timeout,
108 "Timeout (in seconds) waiting for devices to answer INQUIRY." 121 "Timeout (in seconds) waiting for devices to answer INQUIRY."
109 " Default is 5. Some non-compliant devices need more."); 122 " Default is 5. Some non-compliant devices need more.");
110 123
124static DEFINE_SPINLOCK(async_scan_lock);
125static LIST_HEAD(scanning_hosts);
126
127struct async_scan_data {
128 struct list_head list;
129 struct Scsi_Host *shost;
130 struct completion prev_finished;
131};
132
133/**
134 * scsi_complete_async_scans - Wait for asynchronous scans to complete
135 *
136 * Asynchronous scans add themselves to the scanning_hosts list. Once
137 * that list is empty, we know that the scans are complete. Rather than
138 * waking up periodically to check the state of the list, we pretend to be
139 * a scanning task by adding ourselves at the end of the list and going to
140 * sleep. When the task before us wakes us up, we take ourselves off the
141 * list and return.
142 */
143int scsi_complete_async_scans(void)
144{
145 struct async_scan_data *data;
146
147 do {
148 if (list_empty(&scanning_hosts))
149 return 0;
150 /* If we can't get memory immediately, that's OK. Just
151 * sleep a little. Even if we never get memory, the async
152 * scans will finish eventually.
153 */
154 data = kmalloc(sizeof(*data), GFP_KERNEL);
155 if (!data)
156 msleep(1);
157 } while (!data);
158
159 data->shost = NULL;
160 init_completion(&data->prev_finished);
161
162 spin_lock(&async_scan_lock);
163 /* Check that there's still somebody else on the list */
164 if (list_empty(&scanning_hosts))
165 goto done;
166 list_add_tail(&data->list, &scanning_hosts);
167 spin_unlock(&async_scan_lock);
168
169 printk(KERN_INFO "scsi: waiting for bus probes to complete ...\n");
170 wait_for_completion(&data->prev_finished);
171
172 spin_lock(&async_scan_lock);
173 list_del(&data->list);
174 done:
175 spin_unlock(&async_scan_lock);
176
177 kfree(data);
178 return 0;
179}
180
181#ifdef MODULE
182/* Only exported for the benefit of scsi_wait_scan */
183EXPORT_SYMBOL_GPL(scsi_complete_async_scans);
184#endif
185
111/** 186/**
112 * scsi_unlock_floptical - unlock device via a special MODE SENSE command 187 * scsi_unlock_floptical - unlock device via a special MODE SENSE command
113 * @sdev: scsi device to send command to 188 * @sdev: scsi device to send command to
@@ -362,9 +437,10 @@ static struct scsi_target *scsi_alloc_target(struct device *parent,
362 goto retry; 437 goto retry;
363} 438}
364 439
365static void scsi_target_reap_usercontext(void *data) 440static void scsi_target_reap_usercontext(struct work_struct *work)
366{ 441{
367 struct scsi_target *starget = data; 442 struct scsi_target *starget =
443 container_of(work, struct scsi_target, ew.work);
368 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 444 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
369 unsigned long flags; 445 unsigned long flags;
370 446
@@ -400,7 +476,7 @@ void scsi_target_reap(struct scsi_target *starget)
400 starget->state = STARGET_DEL; 476 starget->state = STARGET_DEL;
401 spin_unlock_irqrestore(shost->host_lock, flags); 477 spin_unlock_irqrestore(shost->host_lock, flags);
402 execute_in_process_context(scsi_target_reap_usercontext, 478 execute_in_process_context(scsi_target_reap_usercontext,
403 starget, &starget->ew); 479 &starget->ew);
404 return; 480 return;
405 481
406 } 482 }
@@ -619,7 +695,7 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,
619 * SCSI_SCAN_LUN_PRESENT: a new scsi_device was allocated and initialized 695 * SCSI_SCAN_LUN_PRESENT: a new scsi_device was allocated and initialized
620 **/ 696 **/
621static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result, 697static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
622 int *bflags) 698 int *bflags, int async)
623{ 699{
624 /* 700 /*
625 * XXX do not save the inquiry, since it can change underneath us, 701 * XXX do not save the inquiry, since it can change underneath us,
@@ -631,12 +707,22 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
631 * scanning run at their own risk, or supply a user level program 707 * scanning run at their own risk, or supply a user level program
632 * that can correctly scan. 708 * that can correctly scan.
633 */ 709 */
634 sdev->inquiry = kmalloc(sdev->inquiry_len, GFP_ATOMIC); 710
635 if (sdev->inquiry == NULL) { 711 /*
712 * Copy at least 36 bytes of INQUIRY data, so that we don't
713 * dereference unallocated memory when accessing the Vendor,
714 * Product, and Revision strings. Badly behaved devices may set
715 * the INQUIRY Additional Length byte to a small value, indicating
716 * these strings are invalid, but often they contain plausible data
717 * nonetheless. It doesn't matter if the device sent < 36 bytes
718 * total, since scsi_probe_lun() initializes inq_result with 0s.
719 */
720 sdev->inquiry = kmemdup(inq_result,
721 max_t(size_t, sdev->inquiry_len, 36),
722 GFP_ATOMIC);
723 if (sdev->inquiry == NULL)
636 return SCSI_SCAN_NO_RESPONSE; 724 return SCSI_SCAN_NO_RESPONSE;
637 }
638 725
639 memcpy(sdev->inquiry, inq_result, sdev->inquiry_len);
640 sdev->vendor = (char *) (sdev->inquiry + 8); 726 sdev->vendor = (char *) (sdev->inquiry + 8);
641 sdev->model = (char *) (sdev->inquiry + 16); 727 sdev->model = (char *) (sdev->inquiry + 16);
642 sdev->rev = (char *) (sdev->inquiry + 32); 728 sdev->rev = (char *) (sdev->inquiry + 32);
@@ -795,7 +881,7 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
795 * register it and tell the rest of the kernel 881 * register it and tell the rest of the kernel
796 * about it. 882 * about it.
797 */ 883 */
798 if (scsi_sysfs_add_sdev(sdev) != 0) 884 if (!async && scsi_sysfs_add_sdev(sdev) != 0)
799 return SCSI_SCAN_NO_RESPONSE; 885 return SCSI_SCAN_NO_RESPONSE;
800 886
801 return SCSI_SCAN_LUN_PRESENT; 887 return SCSI_SCAN_LUN_PRESENT;
@@ -964,7 +1050,7 @@ static int scsi_probe_and_add_lun(struct scsi_target *starget,
964 goto out_free_result; 1050 goto out_free_result;
965 } 1051 }
966 1052
967 res = scsi_add_lun(sdev, result, &bflags); 1053 res = scsi_add_lun(sdev, result, &bflags, shost->async_scan);
968 if (res == SCSI_SCAN_LUN_PRESENT) { 1054 if (res == SCSI_SCAN_LUN_PRESENT) {
969 if (bflags & BLIST_KEY) { 1055 if (bflags & BLIST_KEY) {
970 sdev->lockable = 0; 1056 sdev->lockable = 0;
@@ -1464,6 +1550,12 @@ void scsi_scan_target(struct device *parent, unsigned int channel,
1464{ 1550{
1465 struct Scsi_Host *shost = dev_to_shost(parent); 1551 struct Scsi_Host *shost = dev_to_shost(parent);
1466 1552
1553 if (strncmp(scsi_scan_type, "none", 4) == 0)
1554 return;
1555
1556 if (!shost->async_scan)
1557 scsi_complete_async_scans();
1558
1467 mutex_lock(&shost->scan_mutex); 1559 mutex_lock(&shost->scan_mutex);
1468 if (scsi_host_scan_allowed(shost)) 1560 if (scsi_host_scan_allowed(shost))
1469 __scsi_scan_target(parent, channel, id, lun, rescan); 1561 __scsi_scan_target(parent, channel, id, lun, rescan);
@@ -1509,6 +1601,9 @@ int scsi_scan_host_selected(struct Scsi_Host *shost, unsigned int channel,
1509 "%s: <%u:%u:%u>\n", 1601 "%s: <%u:%u:%u>\n",
1510 __FUNCTION__, channel, id, lun)); 1602 __FUNCTION__, channel, id, lun));
1511 1603
1604 if (!shost->async_scan)
1605 scsi_complete_async_scans();
1606
1512 if (((channel != SCAN_WILD_CARD) && (channel > shost->max_channel)) || 1607 if (((channel != SCAN_WILD_CARD) && (channel > shost->max_channel)) ||
1513 ((id != SCAN_WILD_CARD) && (id >= shost->max_id)) || 1608 ((id != SCAN_WILD_CARD) && (id >= shost->max_id)) ||
1514 ((lun != SCAN_WILD_CARD) && (lun > shost->max_lun))) 1609 ((lun != SCAN_WILD_CARD) && (lun > shost->max_lun)))
@@ -1529,14 +1624,143 @@ int scsi_scan_host_selected(struct Scsi_Host *shost, unsigned int channel,
1529 return 0; 1624 return 0;
1530} 1625}
1531 1626
1627static void scsi_sysfs_add_devices(struct Scsi_Host *shost)
1628{
1629 struct scsi_device *sdev;
1630 shost_for_each_device(sdev, shost) {
1631 if (scsi_sysfs_add_sdev(sdev) != 0)
1632 scsi_destroy_sdev(sdev);
1633 }
1634}
1635
1636/**
1637 * scsi_prep_async_scan - prepare for an async scan
1638 * @shost: the host which will be scanned
1639 * Returns: a cookie to be passed to scsi_finish_async_scan()
1640 *
1641 * Tells the midlayer this host is going to do an asynchronous scan.
1642 * It reserves the host's position in the scanning list and ensures
1643 * that other asynchronous scans started after this one won't affect the
1644 * ordering of the discovered devices.
1645 */
1646static struct async_scan_data *scsi_prep_async_scan(struct Scsi_Host *shost)
1647{
1648 struct async_scan_data *data;
1649
1650 if (strncmp(scsi_scan_type, "sync", 4) == 0)
1651 return NULL;
1652
1653 if (shost->async_scan) {
1654 printk("%s called twice for host %d", __FUNCTION__,
1655 shost->host_no);
1656 dump_stack();
1657 return NULL;
1658 }
1659
1660 data = kmalloc(sizeof(*data), GFP_KERNEL);
1661 if (!data)
1662 goto err;
1663 data->shost = scsi_host_get(shost);
1664 if (!data->shost)
1665 goto err;
1666 init_completion(&data->prev_finished);
1667
1668 spin_lock(&async_scan_lock);
1669 shost->async_scan = 1;
1670 if (list_empty(&scanning_hosts))
1671 complete(&data->prev_finished);
1672 list_add_tail(&data->list, &scanning_hosts);
1673 spin_unlock(&async_scan_lock);
1674
1675 return data;
1676
1677 err:
1678 kfree(data);
1679 return NULL;
1680}
1681
1682/**
1683 * scsi_finish_async_scan - asynchronous scan has finished
1684 * @data: cookie returned from earlier call to scsi_prep_async_scan()
1685 *
1686 * All the devices currently attached to this host have been found.
1687 * This function announces all the devices it has found to the rest
1688 * of the system.
1689 */
1690static void scsi_finish_async_scan(struct async_scan_data *data)
1691{
1692 struct Scsi_Host *shost;
1693
1694 if (!data)
1695 return;
1696
1697 shost = data->shost;
1698 if (!shost->async_scan) {
1699 printk("%s called twice for host %d", __FUNCTION__,
1700 shost->host_no);
1701 dump_stack();
1702 return;
1703 }
1704
1705 wait_for_completion(&data->prev_finished);
1706
1707 scsi_sysfs_add_devices(shost);
1708
1709 spin_lock(&async_scan_lock);
1710 shost->async_scan = 0;
1711 list_del(&data->list);
1712 if (!list_empty(&scanning_hosts)) {
1713 struct async_scan_data *next = list_entry(scanning_hosts.next,
1714 struct async_scan_data, list);
1715 complete(&next->prev_finished);
1716 }
1717 spin_unlock(&async_scan_lock);
1718
1719 scsi_host_put(shost);
1720 kfree(data);
1721}
1722
1723static void do_scsi_scan_host(struct Scsi_Host *shost)
1724{
1725 if (shost->hostt->scan_finished) {
1726 unsigned long start = jiffies;
1727 if (shost->hostt->scan_start)
1728 shost->hostt->scan_start(shost);
1729
1730 while (!shost->hostt->scan_finished(shost, jiffies - start))
1731 msleep(10);
1732 } else {
1733 scsi_scan_host_selected(shost, SCAN_WILD_CARD, SCAN_WILD_CARD,
1734 SCAN_WILD_CARD, 0);
1735 }
1736}
1737
1738static int do_scan_async(void *_data)
1739{
1740 struct async_scan_data *data = _data;
1741 do_scsi_scan_host(data->shost);
1742 scsi_finish_async_scan(data);
1743 return 0;
1744}
1745
1532/** 1746/**
1533 * scsi_scan_host - scan the given adapter 1747 * scsi_scan_host - scan the given adapter
1534 * @shost: adapter to scan 1748 * @shost: adapter to scan
1535 **/ 1749 **/
1536void scsi_scan_host(struct Scsi_Host *shost) 1750void scsi_scan_host(struct Scsi_Host *shost)
1537{ 1751{
1538 scsi_scan_host_selected(shost, SCAN_WILD_CARD, SCAN_WILD_CARD, 1752 struct async_scan_data *data;
1539 SCAN_WILD_CARD, 0); 1753
1754 if (strncmp(scsi_scan_type, "none", 4) == 0)
1755 return;
1756
1757 data = scsi_prep_async_scan(shost);
1758 if (!data) {
1759 do_scsi_scan_host(shost);
1760 return;
1761 }
1762
1763 kthread_run(do_scan_async, data, "scsi_scan_%d", shost->host_no);
1540} 1764}
1541EXPORT_SYMBOL(scsi_scan_host); 1765EXPORT_SYMBOL(scsi_scan_host);
1542 1766
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index e1a91665d1c2..259c90cfa367 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -218,16 +218,16 @@ static void scsi_device_cls_release(struct class_device *class_dev)
218 put_device(&sdev->sdev_gendev); 218 put_device(&sdev->sdev_gendev);
219} 219}
220 220
221static void scsi_device_dev_release_usercontext(void *data) 221static void scsi_device_dev_release_usercontext(struct work_struct *work)
222{ 222{
223 struct device *dev = data;
224 struct scsi_device *sdev; 223 struct scsi_device *sdev;
225 struct device *parent; 224 struct device *parent;
226 struct scsi_target *starget; 225 struct scsi_target *starget;
227 unsigned long flags; 226 unsigned long flags;
228 227
229 parent = dev->parent; 228 sdev = container_of(work, struct scsi_device, ew.work);
230 sdev = to_scsi_device(dev); 229
230 parent = sdev->sdev_gendev.parent;
231 starget = to_scsi_target(parent); 231 starget = to_scsi_target(parent);
232 232
233 spin_lock_irqsave(sdev->host->host_lock, flags); 233 spin_lock_irqsave(sdev->host->host_lock, flags);
@@ -258,7 +258,7 @@ static void scsi_device_dev_release_usercontext(void *data)
258static void scsi_device_dev_release(struct device *dev) 258static void scsi_device_dev_release(struct device *dev)
259{ 259{
260 struct scsi_device *sdp = to_scsi_device(dev); 260 struct scsi_device *sdp = to_scsi_device(dev);
261 execute_in_process_context(scsi_device_dev_release_usercontext, dev, 261 execute_in_process_context(scsi_device_dev_release_usercontext,
262 &sdp->ew); 262 &sdp->ew);
263} 263}
264 264
diff --git a/drivers/scsi/scsi_tgt_if.c b/drivers/scsi/scsi_tgt_if.c
new file mode 100644
index 000000000000..37bbfbdb870f
--- /dev/null
+++ b/drivers/scsi/scsi_tgt_if.c
@@ -0,0 +1,352 @@
1/*
2 * SCSI target kernel/user interface functions
3 *
4 * Copyright (C) 2005 FUJITA Tomonori <tomof@acm.org>
5 * Copyright (C) 2005 Mike Christie <michaelc@cs.wisc.edu>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 */
22#include <linux/miscdevice.h>
23#include <linux/file.h>
24#include <net/tcp.h>
25#include <scsi/scsi.h>
26#include <scsi/scsi_cmnd.h>
27#include <scsi/scsi_device.h>
28#include <scsi/scsi_host.h>
29#include <scsi/scsi_tgt.h>
30#include <scsi/scsi_tgt_if.h>
31
32#include <asm/cacheflush.h>
33
34#include "scsi_tgt_priv.h"
35
36struct tgt_ring {
37 u32 tr_idx;
38 unsigned long tr_pages[TGT_RING_PAGES];
39 spinlock_t tr_lock;
40};
41
42/* tx_ring : kernel->user, rx_ring : user->kernel */
43static struct tgt_ring tx_ring, rx_ring;
44static DECLARE_WAIT_QUEUE_HEAD(tgt_poll_wait);
45
46static inline void tgt_ring_idx_inc(struct tgt_ring *ring)
47{
48 if (ring->tr_idx == TGT_MAX_EVENTS - 1)
49 ring->tr_idx = 0;
50 else
51 ring->tr_idx++;
52}
53
54static struct tgt_event *tgt_head_event(struct tgt_ring *ring, u32 idx)
55{
56 u32 pidx, off;
57
58 pidx = idx / TGT_EVENT_PER_PAGE;
59 off = idx % TGT_EVENT_PER_PAGE;
60
61 return (struct tgt_event *)
62 (ring->tr_pages[pidx] + sizeof(struct tgt_event) * off);
63}
64
65static int tgt_uspace_send_event(u32 type, struct tgt_event *p)
66{
67 struct tgt_event *ev;
68 struct tgt_ring *ring = &tx_ring;
69 unsigned long flags;
70 int err = 0;
71
72 spin_lock_irqsave(&ring->tr_lock, flags);
73
74 ev = tgt_head_event(ring, ring->tr_idx);
75 if (!ev->hdr.status)
76 tgt_ring_idx_inc(ring);
77 else
78 err = -BUSY;
79
80 spin_unlock_irqrestore(&ring->tr_lock, flags);
81
82 if (err)
83 return err;
84
85 memcpy(ev, p, sizeof(*ev));
86 ev->hdr.type = type;
87 mb();
88 ev->hdr.status = 1;
89
90 flush_dcache_page(virt_to_page(ev));
91
92 wake_up_interruptible(&tgt_poll_wait);
93
94 return 0;
95}
96
97int scsi_tgt_uspace_send_cmd(struct scsi_cmnd *cmd, struct scsi_lun *lun, u64 tag)
98{
99 struct Scsi_Host *shost = scsi_tgt_cmd_to_host(cmd);
100 struct tgt_event ev;
101 int err;
102
103 memset(&ev, 0, sizeof(ev));
104 ev.p.cmd_req.host_no = shost->host_no;
105 ev.p.cmd_req.data_len = cmd->request_bufflen;
106 memcpy(ev.p.cmd_req.scb, cmd->cmnd, sizeof(ev.p.cmd_req.scb));
107 memcpy(ev.p.cmd_req.lun, lun, sizeof(ev.p.cmd_req.lun));
108 ev.p.cmd_req.attribute = cmd->tag;
109 ev.p.cmd_req.tag = tag;
110
111 dprintk("%p %d %u %x %llx\n", cmd, shost->host_no,
112 ev.p.cmd_req.data_len, cmd->tag,
113 (unsigned long long) ev.p.cmd_req.tag);
114
115 err = tgt_uspace_send_event(TGT_KEVENT_CMD_REQ, &ev);
116 if (err)
117 eprintk("tx buf is full, could not send\n");
118
119 return err;
120}
121
122int scsi_tgt_uspace_send_status(struct scsi_cmnd *cmd, u64 tag)
123{
124 struct Scsi_Host *shost = scsi_tgt_cmd_to_host(cmd);
125 struct tgt_event ev;
126 int err;
127
128 memset(&ev, 0, sizeof(ev));
129 ev.p.cmd_done.host_no = shost->host_no;
130 ev.p.cmd_done.tag = tag;
131 ev.p.cmd_done.result = cmd->result;
132
133 dprintk("%p %d %llu %u %x\n", cmd, shost->host_no,
134 (unsigned long long) ev.p.cmd_req.tag,
135 ev.p.cmd_req.data_len, cmd->tag);
136
137 err = tgt_uspace_send_event(TGT_KEVENT_CMD_DONE, &ev);
138 if (err)
139 eprintk("tx buf is full, could not send\n");
140
141 return err;
142}
143
144int scsi_tgt_uspace_send_tsk_mgmt(int host_no, int function, u64 tag,
145 struct scsi_lun *scsilun, void *data)
146{
147 struct tgt_event ev;
148 int err;
149
150 memset(&ev, 0, sizeof(ev));
151 ev.p.tsk_mgmt_req.host_no = host_no;
152 ev.p.tsk_mgmt_req.function = function;
153 ev.p.tsk_mgmt_req.tag = tag;
154 memcpy(ev.p.tsk_mgmt_req.lun, scsilun, sizeof(ev.p.tsk_mgmt_req.lun));
155 ev.p.tsk_mgmt_req.mid = (u64) (unsigned long) data;
156
157 dprintk("%d %x %llx %llx\n", host_no, function, (unsigned long long) tag,
158 (unsigned long long) ev.p.tsk_mgmt_req.mid);
159
160 err = tgt_uspace_send_event(TGT_KEVENT_TSK_MGMT_REQ, &ev);
161 if (err)
162 eprintk("tx buf is full, could not send\n");
163
164 return err;
165}
166
167static int event_recv_msg(struct tgt_event *ev)
168{
169 int err = 0;
170
171 switch (ev->hdr.type) {
172 case TGT_UEVENT_CMD_RSP:
173 err = scsi_tgt_kspace_exec(ev->p.cmd_rsp.host_no,
174 ev->p.cmd_rsp.tag,
175 ev->p.cmd_rsp.result,
176 ev->p.cmd_rsp.len,
177 ev->p.cmd_rsp.uaddr,
178 ev->p.cmd_rsp.rw);
179 break;
180 case TGT_UEVENT_TSK_MGMT_RSP:
181 err = scsi_tgt_kspace_tsk_mgmt(ev->p.tsk_mgmt_rsp.host_no,
182 ev->p.tsk_mgmt_rsp.mid,
183 ev->p.tsk_mgmt_rsp.result);
184 break;
185 default:
186 eprintk("unknown type %d\n", ev->hdr.type);
187 err = -EINVAL;
188 }
189
190 return err;
191}
192
193static ssize_t tgt_write(struct file *file, const char __user * buffer,
194 size_t count, loff_t * ppos)
195{
196 struct tgt_event *ev;
197 struct tgt_ring *ring = &rx_ring;
198
199 while (1) {
200 ev = tgt_head_event(ring, ring->tr_idx);
201 /* do we need this? */
202 flush_dcache_page(virt_to_page(ev));
203
204 if (!ev->hdr.status)
205 break;
206
207 tgt_ring_idx_inc(ring);
208 event_recv_msg(ev);
209 ev->hdr.status = 0;
210 };
211
212 return count;
213}
214
215static unsigned int tgt_poll(struct file * file, struct poll_table_struct *wait)
216{
217 struct tgt_event *ev;
218 struct tgt_ring *ring = &tx_ring;
219 unsigned long flags;
220 unsigned int mask = 0;
221 u32 idx;
222
223 poll_wait(file, &tgt_poll_wait, wait);
224
225 spin_lock_irqsave(&ring->tr_lock, flags);
226
227 idx = ring->tr_idx ? ring->tr_idx - 1 : TGT_MAX_EVENTS - 1;
228 ev = tgt_head_event(ring, idx);
229 if (ev->hdr.status)
230 mask |= POLLIN | POLLRDNORM;
231
232 spin_unlock_irqrestore(&ring->tr_lock, flags);
233
234 return mask;
235}
236
237static int uspace_ring_map(struct vm_area_struct *vma, unsigned long addr,
238 struct tgt_ring *ring)
239{
240 int i, err;
241
242 for (i = 0; i < TGT_RING_PAGES; i++) {
243 struct page *page = virt_to_page(ring->tr_pages[i]);
244 err = vm_insert_page(vma, addr, page);
245 if (err)
246 return err;
247 addr += PAGE_SIZE;
248 }
249
250 return 0;
251}
252
253static int tgt_mmap(struct file *filp, struct vm_area_struct *vma)
254{
255 unsigned long addr;
256 int err;
257
258 if (vma->vm_pgoff)
259 return -EINVAL;
260
261 if (vma->vm_end - vma->vm_start != TGT_RING_SIZE * 2) {
262 eprintk("mmap size must be %lu, not %lu \n",
263 TGT_RING_SIZE * 2, vma->vm_end - vma->vm_start);
264 return -EINVAL;
265 }
266
267 addr = vma->vm_start;
268 err = uspace_ring_map(vma, addr, &tx_ring);
269 if (err)
270 return err;
271 err = uspace_ring_map(vma, addr + TGT_RING_SIZE, &rx_ring);
272
273 return err;
274}
275
276static int tgt_open(struct inode *inode, struct file *file)
277{
278 tx_ring.tr_idx = rx_ring.tr_idx = 0;
279
280 return 0;
281}
282
283static struct file_operations tgt_fops = {
284 .owner = THIS_MODULE,
285 .open = tgt_open,
286 .poll = tgt_poll,
287 .write = tgt_write,
288 .mmap = tgt_mmap,
289};
290
291static struct miscdevice tgt_miscdev = {
292 .minor = MISC_DYNAMIC_MINOR,
293 .name = "tgt",
294 .fops = &tgt_fops,
295};
296
297static void tgt_ring_exit(struct tgt_ring *ring)
298{
299 int i;
300
301 for (i = 0; i < TGT_RING_PAGES; i++)
302 free_page(ring->tr_pages[i]);
303}
304
305static int tgt_ring_init(struct tgt_ring *ring)
306{
307 int i;
308
309 spin_lock_init(&ring->tr_lock);
310
311 for (i = 0; i < TGT_RING_PAGES; i++) {
312 ring->tr_pages[i] = get_zeroed_page(GFP_KERNEL);
313 if (!ring->tr_pages[i]) {
314 eprintk("out of memory\n");
315 return -ENOMEM;
316 }
317 }
318
319 return 0;
320}
321
322void scsi_tgt_if_exit(void)
323{
324 tgt_ring_exit(&tx_ring);
325 tgt_ring_exit(&rx_ring);
326 misc_deregister(&tgt_miscdev);
327}
328
329int scsi_tgt_if_init(void)
330{
331 int err;
332
333 err = tgt_ring_init(&tx_ring);
334 if (err)
335 return err;
336
337 err = tgt_ring_init(&rx_ring);
338 if (err)
339 goto free_tx_ring;
340
341 err = misc_register(&tgt_miscdev);
342 if (err)
343 goto free_rx_ring;
344
345 return 0;
346free_rx_ring:
347 tgt_ring_exit(&rx_ring);
348free_tx_ring:
349 tgt_ring_exit(&tx_ring);
350
351 return err;
352}
diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
new file mode 100644
index 000000000000..d402aff5f314
--- /dev/null
+++ b/drivers/scsi/scsi_tgt_lib.c
@@ -0,0 +1,745 @@
1/*
2 * SCSI target lib functions
3 *
4 * Copyright (C) 2005 Mike Christie <michaelc@cs.wisc.edu>
5 * Copyright (C) 2005 FUJITA Tomonori <tomof@acm.org>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 */
22#include <linux/blkdev.h>
23#include <linux/hash.h>
24#include <linux/module.h>
25#include <linux/pagemap.h>
26#include <scsi/scsi.h>
27#include <scsi/scsi_cmnd.h>
28#include <scsi/scsi_device.h>
29#include <scsi/scsi_host.h>
30#include <scsi/scsi_tgt.h>
31#include <../drivers/md/dm-bio-list.h>
32
33#include "scsi_tgt_priv.h"
34
35static struct workqueue_struct *scsi_tgtd;
36static struct kmem_cache *scsi_tgt_cmd_cache;
37
38/*
39 * TODO: this struct will be killed when the block layer supports large bios
40 * and James's work struct code is in
41 */
42struct scsi_tgt_cmd {
43 /* TODO replace work with James b's code */
44 struct work_struct work;
45 /* TODO replace the lists with a large bio */
46 struct bio_list xfer_done_list;
47 struct bio_list xfer_list;
48
49 struct list_head hash_list;
50 struct request *rq;
51 u64 tag;
52
53 void *buffer;
54 unsigned bufflen;
55};
56
57#define TGT_HASH_ORDER 4
58#define cmd_hashfn(tag) hash_long((unsigned long) (tag), TGT_HASH_ORDER)
59
60struct scsi_tgt_queuedata {
61 struct Scsi_Host *shost;
62 struct list_head cmd_hash[1 << TGT_HASH_ORDER];
63 spinlock_t cmd_hash_lock;
64};
65
66/*
67 * Function: scsi_host_get_command()
68 *
69 * Purpose: Allocate and setup a scsi command block and blk request
70 *
71 * Arguments: shost - scsi host
72 * data_dir - dma data dir
73 * gfp_mask- allocator flags
74 *
75 * Returns: The allocated scsi command structure.
76 *
77 * This should be called by target LLDs to get a command.
78 */
79struct scsi_cmnd *scsi_host_get_command(struct Scsi_Host *shost,
80 enum dma_data_direction data_dir,
81 gfp_t gfp_mask)
82{
83 int write = (data_dir == DMA_TO_DEVICE);
84 struct request *rq;
85 struct scsi_cmnd *cmd;
86 struct scsi_tgt_cmd *tcmd;
87
88 /* Bail if we can't get a reference to the device */
89 if (!get_device(&shost->shost_gendev))
90 return NULL;
91
92 tcmd = kmem_cache_alloc(scsi_tgt_cmd_cache, GFP_ATOMIC);
93 if (!tcmd)
94 goto put_dev;
95
96 rq = blk_get_request(shost->uspace_req_q, write, gfp_mask);
97 if (!rq)
98 goto free_tcmd;
99
100 cmd = __scsi_get_command(shost, gfp_mask);
101 if (!cmd)
102 goto release_rq;
103
104 memset(cmd, 0, sizeof(*cmd));
105 cmd->sc_data_direction = data_dir;
106 cmd->jiffies_at_alloc = jiffies;
107 cmd->request = rq;
108
109 rq->special = cmd;
110 rq->cmd_type = REQ_TYPE_SPECIAL;
111 rq->cmd_flags |= REQ_TYPE_BLOCK_PC;
112 rq->end_io_data = tcmd;
113
114 bio_list_init(&tcmd->xfer_list);
115 bio_list_init(&tcmd->xfer_done_list);
116 tcmd->rq = rq;
117
118 return cmd;
119
120release_rq:
121 blk_put_request(rq);
122free_tcmd:
123 kmem_cache_free(scsi_tgt_cmd_cache, tcmd);
124put_dev:
125 put_device(&shost->shost_gendev);
126 return NULL;
127
128}
129EXPORT_SYMBOL_GPL(scsi_host_get_command);
130
131/*
132 * Function: scsi_host_put_command()
133 *
134 * Purpose: Free a scsi command block
135 *
136 * Arguments: shost - scsi host
137 * cmd - command block to free
138 *
139 * Returns: Nothing.
140 *
141 * Notes: The command must not belong to any lists.
142 */
143void scsi_host_put_command(struct Scsi_Host *shost, struct scsi_cmnd *cmd)
144{
145 struct request_queue *q = shost->uspace_req_q;
146 struct request *rq = cmd->request;
147 struct scsi_tgt_cmd *tcmd = rq->end_io_data;
148 unsigned long flags;
149
150 kmem_cache_free(scsi_tgt_cmd_cache, tcmd);
151
152 spin_lock_irqsave(q->queue_lock, flags);
153 __blk_put_request(q, rq);
154 spin_unlock_irqrestore(q->queue_lock, flags);
155
156 __scsi_put_command(shost, cmd, &shost->shost_gendev);
157}
158EXPORT_SYMBOL_GPL(scsi_host_put_command);
159
160static void scsi_unmap_user_pages(struct scsi_tgt_cmd *tcmd)
161{
162 struct bio *bio;
163
164 /* must call bio_endio in case bio was bounced */
165 while ((bio = bio_list_pop(&tcmd->xfer_done_list))) {
166 bio_endio(bio, bio->bi_size, 0);
167 bio_unmap_user(bio);
168 }
169
170 while ((bio = bio_list_pop(&tcmd->xfer_list))) {
171 bio_endio(bio, bio->bi_size, 0);
172 bio_unmap_user(bio);
173 }
174}
175
176static void cmd_hashlist_del(struct scsi_cmnd *cmd)
177{
178 struct request_queue *q = cmd->request->q;
179 struct scsi_tgt_queuedata *qdata = q->queuedata;
180 unsigned long flags;
181 struct scsi_tgt_cmd *tcmd = cmd->request->end_io_data;
182
183 spin_lock_irqsave(&qdata->cmd_hash_lock, flags);
184 list_del(&tcmd->hash_list);
185 spin_unlock_irqrestore(&qdata->cmd_hash_lock, flags);
186}
187
188static void scsi_tgt_cmd_destroy(struct work_struct *work)
189{
190 struct scsi_tgt_cmd *tcmd =
191 container_of(work, struct scsi_tgt_cmd, work);
192 struct scsi_cmnd *cmd = tcmd->rq->special;
193
194 dprintk("cmd %p %d %lu\n", cmd, cmd->sc_data_direction,
195 rq_data_dir(cmd->request));
196 /*
197 * We fix rq->cmd_flags here since when we told bio_map_user
198 * to write vm for WRITE commands, blk_rq_bio_prep set
199 * rq_data_dir the flags to READ.
200 */
201 if (cmd->sc_data_direction == DMA_TO_DEVICE)
202 cmd->request->cmd_flags |= REQ_RW;
203 else
204 cmd->request->cmd_flags &= ~REQ_RW;
205
206 scsi_unmap_user_pages(tcmd);
207 scsi_host_put_command(scsi_tgt_cmd_to_host(cmd), cmd);
208}
209
210static void init_scsi_tgt_cmd(struct request *rq, struct scsi_tgt_cmd *tcmd,
211 u64 tag)
212{
213 struct scsi_tgt_queuedata *qdata = rq->q->queuedata;
214 unsigned long flags;
215 struct list_head *head;
216
217 tcmd->tag = tag;
218 INIT_WORK(&tcmd->work, scsi_tgt_cmd_destroy);
219 spin_lock_irqsave(&qdata->cmd_hash_lock, flags);
220 head = &qdata->cmd_hash[cmd_hashfn(tag)];
221 list_add(&tcmd->hash_list, head);
222 spin_unlock_irqrestore(&qdata->cmd_hash_lock, flags);
223}
224
225/*
226 * scsi_tgt_alloc_queue - setup queue used for message passing
227 * shost: scsi host
228 *
229 * This should be called by the LLD after host allocation.
230 * And will be released when the host is released.
231 */
232int scsi_tgt_alloc_queue(struct Scsi_Host *shost)
233{
234 struct scsi_tgt_queuedata *queuedata;
235 struct request_queue *q;
236 int err, i;
237
238 /*
239 * Do we need to send a netlink event or should uspace
240 * just respond to the hotplug event?
241 */
242 q = __scsi_alloc_queue(shost, NULL);
243 if (!q)
244 return -ENOMEM;
245
246 queuedata = kzalloc(sizeof(*queuedata), GFP_KERNEL);
247 if (!queuedata) {
248 err = -ENOMEM;
249 goto cleanup_queue;
250 }
251 queuedata->shost = shost;
252 q->queuedata = queuedata;
253
254 /*
255 * this is a silly hack. We should probably just queue as many
256 * command as is recvd to userspace. uspace can then make
257 * sure we do not overload the HBA
258 */
259 q->nr_requests = shost->hostt->can_queue;
260 /*
261 * We currently only support software LLDs so this does
262 * not matter for now. Do we need this for the cards we support?
263 * If so we should make it a host template value.
264 */
265 blk_queue_dma_alignment(q, 0);
266 shost->uspace_req_q = q;
267
268 for (i = 0; i < ARRAY_SIZE(queuedata->cmd_hash); i++)
269 INIT_LIST_HEAD(&queuedata->cmd_hash[i]);
270 spin_lock_init(&queuedata->cmd_hash_lock);
271
272 return 0;
273
274cleanup_queue:
275 blk_cleanup_queue(q);
276 return err;
277}
278EXPORT_SYMBOL_GPL(scsi_tgt_alloc_queue);
279
280void scsi_tgt_free_queue(struct Scsi_Host *shost)
281{
282 int i;
283 unsigned long flags;
284 struct request_queue *q = shost->uspace_req_q;
285 struct scsi_cmnd *cmd;
286 struct scsi_tgt_queuedata *qdata = q->queuedata;
287 struct scsi_tgt_cmd *tcmd, *n;
288 LIST_HEAD(cmds);
289
290 spin_lock_irqsave(&qdata->cmd_hash_lock, flags);
291
292 for (i = 0; i < ARRAY_SIZE(qdata->cmd_hash); i++) {
293 list_for_each_entry_safe(tcmd, n, &qdata->cmd_hash[i],
294 hash_list) {
295 list_del(&tcmd->hash_list);
296 list_add(&tcmd->hash_list, &cmds);
297 }
298 }
299
300 spin_unlock_irqrestore(&qdata->cmd_hash_lock, flags);
301
302 while (!list_empty(&cmds)) {
303 tcmd = list_entry(cmds.next, struct scsi_tgt_cmd, hash_list);
304 list_del(&tcmd->hash_list);
305 cmd = tcmd->rq->special;
306
307 shost->hostt->eh_abort_handler(cmd);
308 scsi_tgt_cmd_destroy(&tcmd->work);
309 }
310}
311EXPORT_SYMBOL_GPL(scsi_tgt_free_queue);
312
313struct Scsi_Host *scsi_tgt_cmd_to_host(struct scsi_cmnd *cmd)
314{
315 struct scsi_tgt_queuedata *queue = cmd->request->q->queuedata;
316 return queue->shost;
317}
318EXPORT_SYMBOL_GPL(scsi_tgt_cmd_to_host);
319
320/*
321 * scsi_tgt_queue_command - queue command for userspace processing
322 * @cmd: scsi command
323 * @scsilun: scsi lun
324 * @tag: unique value to identify this command for tmf
325 */
326int scsi_tgt_queue_command(struct scsi_cmnd *cmd, struct scsi_lun *scsilun,
327 u64 tag)
328{
329 struct scsi_tgt_cmd *tcmd = cmd->request->end_io_data;
330 int err;
331
332 init_scsi_tgt_cmd(cmd->request, tcmd, tag);
333 err = scsi_tgt_uspace_send_cmd(cmd, scsilun, tag);
334 if (err)
335 cmd_hashlist_del(cmd);
336
337 return err;
338}
339EXPORT_SYMBOL_GPL(scsi_tgt_queue_command);
340
341/*
342 * This is run from a interrpt handler normally and the unmap
343 * needs process context so we must queue
344 */
345static void scsi_tgt_cmd_done(struct scsi_cmnd *cmd)
346{
347 struct scsi_tgt_cmd *tcmd = cmd->request->end_io_data;
348
349 dprintk("cmd %p %lu\n", cmd, rq_data_dir(cmd->request));
350
351 scsi_tgt_uspace_send_status(cmd, tcmd->tag);
352 queue_work(scsi_tgtd, &tcmd->work);
353}
354
355static int __scsi_tgt_transfer_response(struct scsi_cmnd *cmd)
356{
357 struct Scsi_Host *shost = scsi_tgt_cmd_to_host(cmd);
358 int err;
359
360 dprintk("cmd %p %lu\n", cmd, rq_data_dir(cmd->request));
361
362 err = shost->hostt->transfer_response(cmd, scsi_tgt_cmd_done);
363 switch (err) {
364 case SCSI_MLQUEUE_HOST_BUSY:
365 case SCSI_MLQUEUE_DEVICE_BUSY:
366 return -EAGAIN;
367 }
368
369 return 0;
370}
371
372static void scsi_tgt_transfer_response(struct scsi_cmnd *cmd)
373{
374 struct scsi_tgt_cmd *tcmd = cmd->request->end_io_data;
375 int err;
376
377 err = __scsi_tgt_transfer_response(cmd);
378 if (!err)
379 return;
380
381 cmd->result = DID_BUS_BUSY << 16;
382 err = scsi_tgt_uspace_send_status(cmd, tcmd->tag);
383 if (err <= 0)
384 /* the eh will have to pick this up */
385 printk(KERN_ERR "Could not send cmd %p status\n", cmd);
386}
387
388static int scsi_tgt_init_cmd(struct scsi_cmnd *cmd, gfp_t gfp_mask)
389{
390 struct request *rq = cmd->request;
391 struct scsi_tgt_cmd *tcmd = rq->end_io_data;
392 int count;
393
394 cmd->use_sg = rq->nr_phys_segments;
395 cmd->request_buffer = scsi_alloc_sgtable(cmd, gfp_mask);
396 if (!cmd->request_buffer)
397 return -ENOMEM;
398
399 cmd->request_bufflen = rq->data_len;
400
401 dprintk("cmd %p addr %p cnt %d %lu\n", cmd, tcmd->buffer, cmd->use_sg,
402 rq_data_dir(rq));
403 count = blk_rq_map_sg(rq->q, rq, cmd->request_buffer);
404 if (likely(count <= cmd->use_sg)) {
405 cmd->use_sg = count;
406 return 0;
407 }
408
409 eprintk("cmd %p addr %p cnt %d\n", cmd, tcmd->buffer, cmd->use_sg);
410 scsi_free_sgtable(cmd->request_buffer, cmd->sglist_len);
411 return -EINVAL;
412}
413
414/* TODO: test this crap and replace bio_map_user with new interface maybe */
415static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
416 int rw)
417{
418 struct request_queue *q = cmd->request->q;
419 struct request *rq = cmd->request;
420 void *uaddr = tcmd->buffer;
421 unsigned int len = tcmd->bufflen;
422 struct bio *bio;
423 int err;
424
425 while (len > 0) {
426 dprintk("%lx %u\n", (unsigned long) uaddr, len);
427 bio = bio_map_user(q, NULL, (unsigned long) uaddr, len, rw);
428 if (IS_ERR(bio)) {
429 err = PTR_ERR(bio);
430 dprintk("fail to map %lx %u %d %x\n",
431 (unsigned long) uaddr, len, err, cmd->cmnd[0]);
432 goto unmap_bios;
433 }
434
435 uaddr += bio->bi_size;
436 len -= bio->bi_size;
437
438 /*
439 * The first bio is added and merged. We could probably
440 * try to add others using scsi_merge_bio() but for now
441 * we keep it simple. The first bio should be pretty large
442 * (either hitting the 1 MB bio pages limit or a queue limit)
443 * already but for really large IO we may want to try and
444 * merge these.
445 */
446 if (!rq->bio) {
447 blk_rq_bio_prep(q, rq, bio);
448 rq->data_len = bio->bi_size;
449 } else
450 /* put list of bios to transfer in next go around */
451 bio_list_add(&tcmd->xfer_list, bio);
452 }
453
454 cmd->offset = 0;
455 err = scsi_tgt_init_cmd(cmd, GFP_KERNEL);
456 if (err)
457 goto unmap_bios;
458
459 return 0;
460
461unmap_bios:
462 if (rq->bio) {
463 bio_unmap_user(rq->bio);
464 while ((bio = bio_list_pop(&tcmd->xfer_list)))
465 bio_unmap_user(bio);
466 }
467
468 return err;
469}
470
471static int scsi_tgt_transfer_data(struct scsi_cmnd *);
472
473static void scsi_tgt_data_transfer_done(struct scsi_cmnd *cmd)
474{
475 struct scsi_tgt_cmd *tcmd = cmd->request->end_io_data;
476 struct bio *bio;
477 int err;
478
479 /* should we free resources here on error ? */
480 if (cmd->result) {
481send_uspace_err:
482 err = scsi_tgt_uspace_send_status(cmd, tcmd->tag);
483 if (err <= 0)
484 /* the tgt uspace eh will have to pick this up */
485 printk(KERN_ERR "Could not send cmd %p status\n", cmd);
486 return;
487 }
488
489 dprintk("cmd %p request_bufflen %u bufflen %u\n",
490 cmd, cmd->request_bufflen, tcmd->bufflen);
491
492 scsi_free_sgtable(cmd->request_buffer, cmd->sglist_len);
493 bio_list_add(&tcmd->xfer_done_list, cmd->request->bio);
494
495 tcmd->buffer += cmd->request_bufflen;
496 cmd->offset += cmd->request_bufflen;
497
498 if (!tcmd->xfer_list.head) {
499 scsi_tgt_transfer_response(cmd);
500 return;
501 }
502
503 dprintk("cmd2 %p request_bufflen %u bufflen %u\n",
504 cmd, cmd->request_bufflen, tcmd->bufflen);
505
506 bio = bio_list_pop(&tcmd->xfer_list);
507 BUG_ON(!bio);
508
509 blk_rq_bio_prep(cmd->request->q, cmd->request, bio);
510 cmd->request->data_len = bio->bi_size;
511 err = scsi_tgt_init_cmd(cmd, GFP_ATOMIC);
512 if (err) {
513 cmd->result = DID_ERROR << 16;
514 goto send_uspace_err;
515 }
516
517 if (scsi_tgt_transfer_data(cmd)) {
518 cmd->result = DID_NO_CONNECT << 16;
519 goto send_uspace_err;
520 }
521}
522
523static int scsi_tgt_transfer_data(struct scsi_cmnd *cmd)
524{
525 int err;
526 struct Scsi_Host *host = scsi_tgt_cmd_to_host(cmd);
527
528 err = host->hostt->transfer_data(cmd, scsi_tgt_data_transfer_done);
529 switch (err) {
530 case SCSI_MLQUEUE_HOST_BUSY:
531 case SCSI_MLQUEUE_DEVICE_BUSY:
532 return -EAGAIN;
533 default:
534 return 0;
535 }
536}
537
538static int scsi_tgt_copy_sense(struct scsi_cmnd *cmd, unsigned long uaddr,
539 unsigned len)
540{
541 char __user *p = (char __user *) uaddr;
542
543 if (copy_from_user(cmd->sense_buffer, p,
544 min_t(unsigned, SCSI_SENSE_BUFFERSIZE, len))) {
545 printk(KERN_ERR "Could not copy the sense buffer\n");
546 return -EIO;
547 }
548 return 0;
549}
550
551static int scsi_tgt_abort_cmd(struct Scsi_Host *shost, struct scsi_cmnd *cmd)
552{
553 struct scsi_tgt_cmd *tcmd;
554 int err;
555
556 err = shost->hostt->eh_abort_handler(cmd);
557 if (err)
558 eprintk("fail to abort %p\n", cmd);
559
560 tcmd = cmd->request->end_io_data;
561 scsi_tgt_cmd_destroy(&tcmd->work);
562 return err;
563}
564
565static struct request *tgt_cmd_hash_lookup(struct request_queue *q, u64 tag)
566{
567 struct scsi_tgt_queuedata *qdata = q->queuedata;
568 struct request *rq = NULL;
569 struct list_head *head;
570 struct scsi_tgt_cmd *tcmd;
571 unsigned long flags;
572
573 head = &qdata->cmd_hash[cmd_hashfn(tag)];
574 spin_lock_irqsave(&qdata->cmd_hash_lock, flags);
575 list_for_each_entry(tcmd, head, hash_list) {
576 if (tcmd->tag == tag) {
577 rq = tcmd->rq;
578 list_del(&tcmd->hash_list);
579 break;
580 }
581 }
582 spin_unlock_irqrestore(&qdata->cmd_hash_lock, flags);
583
584 return rq;
585}
586
587int scsi_tgt_kspace_exec(int host_no, u64 tag, int result, u32 len,
588 unsigned long uaddr, u8 rw)
589{
590 struct Scsi_Host *shost;
591 struct scsi_cmnd *cmd;
592 struct request *rq;
593 struct scsi_tgt_cmd *tcmd;
594 int err = 0;
595
596 dprintk("%d %llu %d %u %lx %u\n", host_no, (unsigned long long) tag,
597 result, len, uaddr, rw);
598
599 /* TODO: replace with a O(1) alg */
600 shost = scsi_host_lookup(host_no);
601 if (IS_ERR(shost)) {
602 printk(KERN_ERR "Could not find host no %d\n", host_no);
603 return -EINVAL;
604 }
605
606 if (!shost->uspace_req_q) {
607 printk(KERN_ERR "Not target scsi host %d\n", host_no);
608 goto done;
609 }
610
611 rq = tgt_cmd_hash_lookup(shost->uspace_req_q, tag);
612 if (!rq) {
613 printk(KERN_ERR "Could not find tag %llu\n",
614 (unsigned long long) tag);
615 err = -EINVAL;
616 goto done;
617 }
618 cmd = rq->special;
619
620 dprintk("cmd %p result %d len %d bufflen %u %lu %x\n", cmd,
621 result, len, cmd->request_bufflen, rq_data_dir(rq), cmd->cmnd[0]);
622
623 if (result == TASK_ABORTED) {
624 scsi_tgt_abort_cmd(shost, cmd);
625 goto done;
626 }
627 /*
628 * store the userspace values here, the working values are
629 * in the request_* values
630 */
631 tcmd = cmd->request->end_io_data;
632 tcmd->buffer = (void *)uaddr;
633 tcmd->bufflen = len;
634 cmd->result = result;
635
636 if (!tcmd->bufflen || cmd->request_buffer) {
637 err = __scsi_tgt_transfer_response(cmd);
638 goto done;
639 }
640
641 /*
642 * TODO: Do we need to handle case where request does not
643 * align with LLD.
644 */
645 err = scsi_map_user_pages(rq->end_io_data, cmd, rw);
646 if (err) {
647 eprintk("%p %d\n", cmd, err);
648 err = -EAGAIN;
649 goto done;
650 }
651
652 /* userspace failure */
653 if (cmd->result) {
654 if (status_byte(cmd->result) == CHECK_CONDITION)
655 scsi_tgt_copy_sense(cmd, uaddr, len);
656 err = __scsi_tgt_transfer_response(cmd);
657 goto done;
658 }
659 /* ask the target LLD to transfer the data to the buffer */
660 err = scsi_tgt_transfer_data(cmd);
661
662done:
663 scsi_host_put(shost);
664 return err;
665}
666
667int scsi_tgt_tsk_mgmt_request(struct Scsi_Host *shost, int function, u64 tag,
668 struct scsi_lun *scsilun, void *data)
669{
670 int err;
671
672 /* TODO: need to retry if this fails. */
673 err = scsi_tgt_uspace_send_tsk_mgmt(shost->host_no, function,
674 tag, scsilun, data);
675 if (err < 0)
676 eprintk("The task management request lost!\n");
677 return err;
678}
679EXPORT_SYMBOL_GPL(scsi_tgt_tsk_mgmt_request);
680
681int scsi_tgt_kspace_tsk_mgmt(int host_no, u64 mid, int result)
682{
683 struct Scsi_Host *shost;
684 int err = -EINVAL;
685
686 dprintk("%d %d %llx\n", host_no, result, (unsigned long long) mid);
687
688 shost = scsi_host_lookup(host_no);
689 if (IS_ERR(shost)) {
690 printk(KERN_ERR "Could not find host no %d\n", host_no);
691 return err;
692 }
693
694 if (!shost->uspace_req_q) {
695 printk(KERN_ERR "Not target scsi host %d\n", host_no);
696 goto done;
697 }
698
699 err = shost->hostt->tsk_mgmt_response(mid, result);
700done:
701 scsi_host_put(shost);
702 return err;
703}
704
705static int __init scsi_tgt_init(void)
706{
707 int err;
708
709 scsi_tgt_cmd_cache = kmem_cache_create("scsi_tgt_cmd",
710 sizeof(struct scsi_tgt_cmd),
711 0, 0, NULL, NULL);
712 if (!scsi_tgt_cmd_cache)
713 return -ENOMEM;
714
715 scsi_tgtd = create_workqueue("scsi_tgtd");
716 if (!scsi_tgtd) {
717 err = -ENOMEM;
718 goto free_kmemcache;
719 }
720
721 err = scsi_tgt_if_init();
722 if (err)
723 goto destroy_wq;
724
725 return 0;
726
727destroy_wq:
728 destroy_workqueue(scsi_tgtd);
729free_kmemcache:
730 kmem_cache_destroy(scsi_tgt_cmd_cache);
731 return err;
732}
733
734static void __exit scsi_tgt_exit(void)
735{
736 destroy_workqueue(scsi_tgtd);
737 scsi_tgt_if_exit();
738 kmem_cache_destroy(scsi_tgt_cmd_cache);
739}
740
741module_init(scsi_tgt_init);
742module_exit(scsi_tgt_exit);
743
744MODULE_DESCRIPTION("SCSI target core");
745MODULE_LICENSE("GPL");
diff --git a/drivers/scsi/scsi_tgt_priv.h b/drivers/scsi/scsi_tgt_priv.h
new file mode 100644
index 000000000000..84488c51ff62
--- /dev/null
+++ b/drivers/scsi/scsi_tgt_priv.h
@@ -0,0 +1,25 @@
1struct scsi_cmnd;
2struct scsi_lun;
3struct Scsi_Host;
4struct task_struct;
5
6/* tmp - will replace with SCSI logging stuff */
7#define eprintk(fmt, args...) \
8do { \
9 printk("%s(%d) " fmt, __FUNCTION__, __LINE__, ##args); \
10} while (0)
11
12#define dprintk(fmt, args...)
13/* #define dprintk eprintk */
14
15extern void scsi_tgt_if_exit(void);
16extern int scsi_tgt_if_init(void);
17
18extern int scsi_tgt_uspace_send_cmd(struct scsi_cmnd *cmd, struct scsi_lun *lun,
19 u64 tag);
20extern int scsi_tgt_uspace_send_status(struct scsi_cmnd *cmd, u64 tag);
21extern int scsi_tgt_kspace_exec(int host_no, u64 tag, int result, u32 len,
22 unsigned long uaddr, u8 rw);
23extern int scsi_tgt_uspace_send_tsk_mgmt(int host_no, int function, u64 tag,
24 struct scsi_lun *scsilun, void *data);
25extern int scsi_tgt_kspace_tsk_mgmt(int host_no, u64 mid, int result);
diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index 38c215a78f69..3571ce8934e7 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -241,9 +241,9 @@ fc_bitfield_name_search(remote_port_roles, fc_remote_port_role_names)
241#define FC_MGMTSRVR_PORTID 0x00000a 241#define FC_MGMTSRVR_PORTID 0x00000a
242 242
243 243
244static void fc_timeout_deleted_rport(void *data); 244static void fc_timeout_deleted_rport(struct work_struct *work);
245static void fc_timeout_fail_rport_io(void *data); 245static void fc_timeout_fail_rport_io(struct work_struct *work);
246static void fc_scsi_scan_rport(void *data); 246static void fc_scsi_scan_rport(struct work_struct *work);
247 247
248/* 248/*
249 * Attribute counts pre object type... 249 * Attribute counts pre object type...
@@ -1613,7 +1613,7 @@ fc_flush_work(struct Scsi_Host *shost)
1613 * 1 on success / 0 already queued / < 0 for error 1613 * 1 on success / 0 already queued / < 0 for error
1614 **/ 1614 **/
1615static int 1615static int
1616fc_queue_devloss_work(struct Scsi_Host *shost, struct work_struct *work, 1616fc_queue_devloss_work(struct Scsi_Host *shost, struct delayed_work *work,
1617 unsigned long delay) 1617 unsigned long delay)
1618{ 1618{
1619 if (unlikely(!fc_host_devloss_work_q(shost))) { 1619 if (unlikely(!fc_host_devloss_work_q(shost))) {
@@ -1625,9 +1625,6 @@ fc_queue_devloss_work(struct Scsi_Host *shost, struct work_struct *work,
1625 return -EINVAL; 1625 return -EINVAL;
1626 } 1626 }
1627 1627
1628 if (delay == 0)
1629 return queue_work(fc_host_devloss_work_q(shost), work);
1630
1631 return queue_delayed_work(fc_host_devloss_work_q(shost), work, delay); 1628 return queue_delayed_work(fc_host_devloss_work_q(shost), work, delay);
1632} 1629}
1633 1630
@@ -1712,12 +1709,13 @@ EXPORT_SYMBOL(fc_remove_host);
1712 * fc_starget_delete - called to delete the scsi decendents of an rport 1709 * fc_starget_delete - called to delete the scsi decendents of an rport
1713 * (target and all sdevs) 1710 * (target and all sdevs)
1714 * 1711 *
1715 * @data: remote port to be operated on. 1712 * @work: remote port to be operated on.
1716 **/ 1713 **/
1717static void 1714static void
1718fc_starget_delete(void *data) 1715fc_starget_delete(struct work_struct *work)
1719{ 1716{
1720 struct fc_rport *rport = (struct fc_rport *)data; 1717 struct fc_rport *rport =
1718 container_of(work, struct fc_rport, stgt_delete_work);
1721 struct Scsi_Host *shost = rport_to_shost(rport); 1719 struct Scsi_Host *shost = rport_to_shost(rport);
1722 unsigned long flags; 1720 unsigned long flags;
1723 struct fc_internal *i = to_fc_internal(shost->transportt); 1721 struct fc_internal *i = to_fc_internal(shost->transportt);
@@ -1751,12 +1749,13 @@ fc_starget_delete(void *data)
1751/** 1749/**
1752 * fc_rport_final_delete - finish rport termination and delete it. 1750 * fc_rport_final_delete - finish rport termination and delete it.
1753 * 1751 *
1754 * @data: remote port to be deleted. 1752 * @work: remote port to be deleted.
1755 **/ 1753 **/
1756static void 1754static void
1757fc_rport_final_delete(void *data) 1755fc_rport_final_delete(struct work_struct *work)
1758{ 1756{
1759 struct fc_rport *rport = (struct fc_rport *)data; 1757 struct fc_rport *rport =
1758 container_of(work, struct fc_rport, rport_delete_work);
1760 struct device *dev = &rport->dev; 1759 struct device *dev = &rport->dev;
1761 struct Scsi_Host *shost = rport_to_shost(rport); 1760 struct Scsi_Host *shost = rport_to_shost(rport);
1762 struct fc_internal *i = to_fc_internal(shost->transportt); 1761 struct fc_internal *i = to_fc_internal(shost->transportt);
@@ -1770,7 +1769,7 @@ fc_rport_final_delete(void *data)
1770 1769
1771 /* Delete SCSI target and sdevs */ 1770 /* Delete SCSI target and sdevs */
1772 if (rport->scsi_target_id != -1) 1771 if (rport->scsi_target_id != -1)
1773 fc_starget_delete(data); 1772 fc_starget_delete(&rport->stgt_delete_work);
1774 else if (i->f->dev_loss_tmo_callbk) 1773 else if (i->f->dev_loss_tmo_callbk)
1775 i->f->dev_loss_tmo_callbk(rport); 1774 i->f->dev_loss_tmo_callbk(rport);
1776 else if (i->f->terminate_rport_io) 1775 else if (i->f->terminate_rport_io)
@@ -1829,11 +1828,11 @@ fc_rport_create(struct Scsi_Host *shost, int channel,
1829 rport->channel = channel; 1828 rport->channel = channel;
1830 rport->fast_io_fail_tmo = -1; 1829 rport->fast_io_fail_tmo = -1;
1831 1830
1832 INIT_WORK(&rport->dev_loss_work, fc_timeout_deleted_rport, rport); 1831 INIT_DELAYED_WORK(&rport->dev_loss_work, fc_timeout_deleted_rport);
1833 INIT_WORK(&rport->fail_io_work, fc_timeout_fail_rport_io, rport); 1832 INIT_DELAYED_WORK(&rport->fail_io_work, fc_timeout_fail_rport_io);
1834 INIT_WORK(&rport->scan_work, fc_scsi_scan_rport, rport); 1833 INIT_WORK(&rport->scan_work, fc_scsi_scan_rport);
1835 INIT_WORK(&rport->stgt_delete_work, fc_starget_delete, rport); 1834 INIT_WORK(&rport->stgt_delete_work, fc_starget_delete);
1836 INIT_WORK(&rport->rport_delete_work, fc_rport_final_delete, rport); 1835 INIT_WORK(&rport->rport_delete_work, fc_rport_final_delete);
1837 1836
1838 spin_lock_irqsave(shost->host_lock, flags); 1837 spin_lock_irqsave(shost->host_lock, flags);
1839 1838
@@ -1963,7 +1962,7 @@ fc_remote_port_add(struct Scsi_Host *shost, int channel,
1963 } 1962 }
1964 1963
1965 if (match) { 1964 if (match) {
1966 struct work_struct *work = 1965 struct delayed_work *work =
1967 &rport->dev_loss_work; 1966 &rport->dev_loss_work;
1968 1967
1969 memcpy(&rport->node_name, &ids->node_name, 1968 memcpy(&rport->node_name, &ids->node_name,
@@ -2267,12 +2266,13 @@ EXPORT_SYMBOL(fc_remote_port_rolechg);
2267 * was a SCSI target (thus was blocked), and failed 2266 * was a SCSI target (thus was blocked), and failed
2268 * to return in the alloted time. 2267 * to return in the alloted time.
2269 * 2268 *
2270 * @data: rport target that failed to reappear in the alloted time. 2269 * @work: rport target that failed to reappear in the alloted time.
2271 **/ 2270 **/
2272static void 2271static void
2273fc_timeout_deleted_rport(void *data) 2272fc_timeout_deleted_rport(struct work_struct *work)
2274{ 2273{
2275 struct fc_rport *rport = (struct fc_rport *)data; 2274 struct fc_rport *rport =
2275 container_of(work, struct fc_rport, dev_loss_work.work);
2276 struct Scsi_Host *shost = rport_to_shost(rport); 2276 struct Scsi_Host *shost = rport_to_shost(rport);
2277 struct fc_host_attrs *fc_host = shost_to_fc_host(shost); 2277 struct fc_host_attrs *fc_host = shost_to_fc_host(shost);
2278 unsigned long flags; 2278 unsigned long flags;
@@ -2366,15 +2366,16 @@ fc_timeout_deleted_rport(void *data)
2366 * fc_timeout_fail_rport_io - Timeout handler for a fast io failing on a 2366 * fc_timeout_fail_rport_io - Timeout handler for a fast io failing on a
2367 * disconnected SCSI target. 2367 * disconnected SCSI target.
2368 * 2368 *
2369 * @data: rport to terminate io on. 2369 * @work: rport to terminate io on.
2370 * 2370 *
2371 * Notes: Only requests the failure of the io, not that all are flushed 2371 * Notes: Only requests the failure of the io, not that all are flushed
2372 * prior to returning. 2372 * prior to returning.
2373 **/ 2373 **/
2374static void 2374static void
2375fc_timeout_fail_rport_io(void *data) 2375fc_timeout_fail_rport_io(struct work_struct *work)
2376{ 2376{
2377 struct fc_rport *rport = (struct fc_rport *)data; 2377 struct fc_rport *rport =
2378 container_of(work, struct fc_rport, fail_io_work.work);
2378 struct Scsi_Host *shost = rport_to_shost(rport); 2379 struct Scsi_Host *shost = rport_to_shost(rport);
2379 struct fc_internal *i = to_fc_internal(shost->transportt); 2380 struct fc_internal *i = to_fc_internal(shost->transportt);
2380 2381
@@ -2387,12 +2388,13 @@ fc_timeout_fail_rport_io(void *data)
2387/** 2388/**
2388 * fc_scsi_scan_rport - called to perform a scsi scan on a remote port. 2389 * fc_scsi_scan_rport - called to perform a scsi scan on a remote port.
2389 * 2390 *
2390 * @data: remote port to be scanned. 2391 * @work: remote port to be scanned.
2391 **/ 2392 **/
2392static void 2393static void
2393fc_scsi_scan_rport(void *data) 2394fc_scsi_scan_rport(struct work_struct *work)
2394{ 2395{
2395 struct fc_rport *rport = (struct fc_rport *)data; 2396 struct fc_rport *rport =
2397 container_of(work, struct fc_rport, scan_work);
2396 struct Scsi_Host *shost = rport_to_shost(rport); 2398 struct Scsi_Host *shost = rport_to_shost(rport);
2397 unsigned long flags; 2399 unsigned long flags;
2398 2400
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index 2d3baa99ca25..9c22f1342715 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -33,7 +33,7 @@
33#define ISCSI_SESSION_ATTRS 11 33#define ISCSI_SESSION_ATTRS 11
34#define ISCSI_CONN_ATTRS 11 34#define ISCSI_CONN_ATTRS 11
35#define ISCSI_HOST_ATTRS 0 35#define ISCSI_HOST_ATTRS 0
36#define ISCSI_TRANSPORT_VERSION "2.0-685" 36#define ISCSI_TRANSPORT_VERSION "2.0-724"
37 37
38struct iscsi_internal { 38struct iscsi_internal {
39 int daemon_pid; 39 int daemon_pid;
@@ -234,9 +234,11 @@ static int iscsi_user_scan(struct Scsi_Host *shost, uint channel,
234 return 0; 234 return 0;
235} 235}
236 236
237static void session_recovery_timedout(void *data) 237static void session_recovery_timedout(struct work_struct *work)
238{ 238{
239 struct iscsi_cls_session *session = data; 239 struct iscsi_cls_session *session =
240 container_of(work, struct iscsi_cls_session,
241 recovery_work.work);
240 242
241 dev_printk(KERN_INFO, &session->dev, "iscsi: session recovery timed " 243 dev_printk(KERN_INFO, &session->dev, "iscsi: session recovery timed "
242 "out after %d secs\n", session->recovery_tmo); 244 "out after %d secs\n", session->recovery_tmo);
@@ -276,7 +278,7 @@ iscsi_alloc_session(struct Scsi_Host *shost,
276 278
277 session->transport = transport; 279 session->transport = transport;
278 session->recovery_tmo = 120; 280 session->recovery_tmo = 120;
279 INIT_WORK(&session->recovery_work, session_recovery_timedout, session); 281 INIT_DELAYED_WORK(&session->recovery_work, session_recovery_timedout);
280 INIT_LIST_HEAD(&session->host_list); 282 INIT_LIST_HEAD(&session->host_list);
281 INIT_LIST_HEAD(&session->sess_list); 283 INIT_LIST_HEAD(&session->sess_list);
282 284
diff --git a/drivers/scsi/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c
index b5b0c2cba96b..5c0b75bbfa10 100644
--- a/drivers/scsi/scsi_transport_sas.c
+++ b/drivers/scsi/scsi_transport_sas.c
@@ -25,6 +25,7 @@
25 25
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/jiffies.h>
28#include <linux/err.h> 29#include <linux/err.h>
29#include <linux/slab.h> 30#include <linux/slab.h>
30#include <linux/string.h> 31#include <linux/string.h>
diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c
index 9f070f0d0f2b..3fded4831460 100644
--- a/drivers/scsi/scsi_transport_spi.c
+++ b/drivers/scsi/scsi_transport_spi.c
@@ -964,9 +964,10 @@ struct work_queue_wrapper {
964}; 964};
965 965
966static void 966static void
967spi_dv_device_work_wrapper(void *data) 967spi_dv_device_work_wrapper(struct work_struct *work)
968{ 968{
969 struct work_queue_wrapper *wqw = (struct work_queue_wrapper *)data; 969 struct work_queue_wrapper *wqw =
970 container_of(work, struct work_queue_wrapper, work);
970 struct scsi_device *sdev = wqw->sdev; 971 struct scsi_device *sdev = wqw->sdev;
971 972
972 kfree(wqw); 973 kfree(wqw);
@@ -1006,7 +1007,7 @@ spi_schedule_dv_device(struct scsi_device *sdev)
1006 return; 1007 return;
1007 } 1008 }
1008 1009
1009 INIT_WORK(&wqw->work, spi_dv_device_work_wrapper, wqw); 1010 INIT_WORK(&wqw->work, spi_dv_device_work_wrapper);
1010 wqw->sdev = sdev; 1011 wqw->sdev = sdev;
1011 1012
1012 schedule_work(&wqw->work); 1013 schedule_work(&wqw->work);
diff --git a/drivers/scsi/scsi_wait_scan.c b/drivers/scsi/scsi_wait_scan.c
new file mode 100644
index 000000000000..8a636103083d
--- /dev/null
+++ b/drivers/scsi/scsi_wait_scan.c
@@ -0,0 +1,31 @@
1/*
2 * scsi_wait_scan.c
3 *
4 * Copyright (C) 2006 James Bottomley <James.Bottomley@SteelEye.com>
5 *
6 * This is a simple module to wait until all the async scans are
7 * complete. The idea is to use it in initrd/initramfs scripts. You
8 * modprobe it after all the modprobes of the root SCSI drivers and it
9 * will wait until they have all finished scanning their busses before
10 * allowing the boot to proceed
11 */
12
13#include <linux/module.h>
14#include "scsi_priv.h"
15
16static int __init wait_scan_init(void)
17{
18 scsi_complete_async_scans();
19 return 0;
20}
21
22static void __exit wait_scan_exit(void)
23{
24}
25
26MODULE_DESCRIPTION("SCSI wait for scans");
27MODULE_AUTHOR("James Bottomley");
28MODULE_LICENSE("GPL");
29
30late_initcall(wait_scan_init);
31module_exit(wait_scan_exit);
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 84ff203ffedd..f6a452846fab 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1051,6 +1051,14 @@ sd_spinup_disk(struct scsi_disk *sdkp, char *diskname)
1051 &sshdr, SD_TIMEOUT, 1051 &sshdr, SD_TIMEOUT,
1052 SD_MAX_RETRIES); 1052 SD_MAX_RETRIES);
1053 1053
1054 /*
1055 * If the drive has indicated to us that it
1056 * doesn't have any media in it, don't bother
1057 * with any more polling.
1058 */
1059 if (media_not_present(sdkp, &sshdr))
1060 return;
1061
1054 if (the_result) 1062 if (the_result)
1055 sense_valid = scsi_sense_valid(&sshdr); 1063 sense_valid = scsi_sense_valid(&sshdr);
1056 retries++; 1064 retries++;
@@ -1059,14 +1067,6 @@ sd_spinup_disk(struct scsi_disk *sdkp, char *diskname)
1059 ((driver_byte(the_result) & DRIVER_SENSE) && 1067 ((driver_byte(the_result) & DRIVER_SENSE) &&
1060 sense_valid && sshdr.sense_key == UNIT_ATTENTION))); 1068 sense_valid && sshdr.sense_key == UNIT_ATTENTION)));
1061 1069
1062 /*
1063 * If the drive has indicated to us that it doesn't have
1064 * any media in it, don't bother with any of the rest of
1065 * this crap.
1066 */
1067 if (media_not_present(sdkp, &sshdr))
1068 return;
1069
1070 if ((driver_byte(the_result) & DRIVER_SENSE) == 0) { 1070 if ((driver_byte(the_result) & DRIVER_SENSE) == 0) {
1071 /* no sense, TUR either succeeded or failed 1071 /* no sense, TUR either succeeded or failed
1072 * with a status error */ 1072 * with a status error */
@@ -1467,7 +1467,6 @@ sd_read_cache_type(struct scsi_disk *sdkp, char *diskname,
1467 res = sd_do_mode_sense(sdp, dbd, modepage, buffer, len, &data, &sshdr); 1467 res = sd_do_mode_sense(sdp, dbd, modepage, buffer, len, &data, &sshdr);
1468 1468
1469 if (scsi_status_is_good(res)) { 1469 if (scsi_status_is_good(res)) {
1470 int ct = 0;
1471 int offset = data.header_length + data.block_descriptor_length; 1470 int offset = data.header_length + data.block_descriptor_length;
1472 1471
1473 if (offset >= SD_BUF_SIZE - 2) { 1472 if (offset >= SD_BUF_SIZE - 2) {
@@ -1496,11 +1495,13 @@ sd_read_cache_type(struct scsi_disk *sdkp, char *diskname,
1496 sdkp->DPOFUA = 0; 1495 sdkp->DPOFUA = 0;
1497 } 1496 }
1498 1497
1499 ct = sdkp->RCD + 2*sdkp->WCE; 1498 printk(KERN_NOTICE "SCSI device %s: "
1500 1499 "write cache: %s, read cache: %s, %s\n",
1501 printk(KERN_NOTICE "SCSI device %s: drive cache: %s%s\n", 1500 diskname,
1502 diskname, sd_cache_types[ct], 1501 sdkp->WCE ? "enabled" : "disabled",
1503 sdkp->DPOFUA ? " w/ FUA" : ""); 1502 sdkp->RCD ? "disabled" : "enabled",
1503 sdkp->DPOFUA ? "supports DPO and FUA"
1504 : "doesn't support DPO or FUA");
1504 1505
1505 return; 1506 return;
1506 } 1507 }
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 3f8b93188567..81e3bc7b02a1 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -60,7 +60,7 @@ static int sg_version_num = 30534; /* 2 digits for each component */
60 60
61#ifdef CONFIG_SCSI_PROC_FS 61#ifdef CONFIG_SCSI_PROC_FS
62#include <linux/proc_fs.h> 62#include <linux/proc_fs.h>
63static char *sg_version_date = "20060920"; 63static char *sg_version_date = "20061027";
64 64
65static int sg_proc_init(void); 65static int sg_proc_init(void);
66static void sg_proc_cleanup(void); 66static void sg_proc_cleanup(void);
@@ -710,12 +710,12 @@ sg_common_write(Sg_fd * sfp, Sg_request * srp,
710 (int) cmnd[0], (int) hp->cmd_len)); 710 (int) cmnd[0], (int) hp->cmd_len));
711 711
712 if ((k = sg_start_req(srp))) { 712 if ((k = sg_start_req(srp))) {
713 SCSI_LOG_TIMEOUT(1, printk("sg_write: start_req err=%d\n", k)); 713 SCSI_LOG_TIMEOUT(1, printk("sg_common_write: start_req err=%d\n", k));
714 sg_finish_rem_req(srp); 714 sg_finish_rem_req(srp);
715 return k; /* probably out of space --> ENOMEM */ 715 return k; /* probably out of space --> ENOMEM */
716 } 716 }
717 if ((k = sg_write_xfer(srp))) { 717 if ((k = sg_write_xfer(srp))) {
718 SCSI_LOG_TIMEOUT(1, printk("sg_write: write_xfer, bad address\n")); 718 SCSI_LOG_TIMEOUT(1, printk("sg_common_write: write_xfer, bad address\n"));
719 sg_finish_rem_req(srp); 719 sg_finish_rem_req(srp);
720 return k; 720 return k;
721 } 721 }
@@ -746,7 +746,7 @@ sg_common_write(Sg_fd * sfp, Sg_request * srp,
746 hp->dxfer_len, srp->data.k_use_sg, timeout, 746 hp->dxfer_len, srp->data.k_use_sg, timeout,
747 SG_DEFAULT_RETRIES, srp, sg_cmd_done, 747 SG_DEFAULT_RETRIES, srp, sg_cmd_done,
748 GFP_ATOMIC)) { 748 GFP_ATOMIC)) {
749 SCSI_LOG_TIMEOUT(1, printk("sg_write: scsi_execute_async failed\n")); 749 SCSI_LOG_TIMEOUT(1, printk("sg_common_write: scsi_execute_async failed\n"));
750 /* 750 /*
751 * most likely out of mem, but could also be a bad map 751 * most likely out of mem, but could also be a bad map
752 */ 752 */
@@ -1283,7 +1283,7 @@ sg_cmd_done(void *data, char *sense, int result, int resid)
1283 sg_finish_rem_req(srp); 1283 sg_finish_rem_req(srp);
1284 srp = NULL; 1284 srp = NULL;
1285 if (NULL == sfp->headrp) { 1285 if (NULL == sfp->headrp) {
1286 SCSI_LOG_TIMEOUT(1, printk("sg...bh: already closed, final cleanup\n")); 1286 SCSI_LOG_TIMEOUT(1, printk("sg_cmd_done: already closed, final cleanup\n"));
1287 if (0 == sg_remove_sfp(sdp, sfp)) { /* device still present */ 1287 if (0 == sg_remove_sfp(sdp, sfp)) { /* device still present */
1288 scsi_device_put(sdp->device); 1288 scsi_device_put(sdp->device);
1289 } 1289 }
@@ -1512,12 +1512,12 @@ sg_remove(struct class_device *cl_dev, struct class_interface *cl_intf)
1512 POLL_HUP); 1512 POLL_HUP);
1513 } 1513 }
1514 } 1514 }
1515 SCSI_LOG_TIMEOUT(3, printk("sg_detach: dev=%d, dirty\n", k)); 1515 SCSI_LOG_TIMEOUT(3, printk("sg_remove: dev=%d, dirty\n", k));
1516 if (NULL == sdp->headfp) { 1516 if (NULL == sdp->headfp) {
1517 sg_dev_arr[k] = NULL; 1517 sg_dev_arr[k] = NULL;
1518 } 1518 }
1519 } else { /* nothing active, simple case */ 1519 } else { /* nothing active, simple case */
1520 SCSI_LOG_TIMEOUT(3, printk("sg_detach: dev=%d\n", k)); 1520 SCSI_LOG_TIMEOUT(3, printk("sg_remove: dev=%d\n", k));
1521 sg_dev_arr[k] = NULL; 1521 sg_dev_arr[k] = NULL;
1522 } 1522 }
1523 sg_nr_dev--; 1523 sg_nr_dev--;
@@ -1876,14 +1876,15 @@ sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size)
1876 } 1876 }
1877 } 1877 }
1878 sg->page = p; 1878 sg->page = p;
1879 sg->length = ret_sz; 1879 sg->length = (ret_sz > num) ? num : ret_sz;
1880 1880
1881 SCSI_LOG_TIMEOUT(5, printk("sg_build_build: k=%d, a=0x%p, len=%d\n", 1881 SCSI_LOG_TIMEOUT(5, printk("sg_build_indirect: k=%d, num=%d, "
1882 k, p, ret_sz)); 1882 "ret_sz=%d\n", k, num, ret_sz));
1883 } /* end of for loop */ 1883 } /* end of for loop */
1884 1884
1885 schp->k_use_sg = k; 1885 schp->k_use_sg = k;
1886 SCSI_LOG_TIMEOUT(5, printk("sg_build_indirect: k_use_sg=%d, rem_sz=%d\n", k, rem_sz)); 1886 SCSI_LOG_TIMEOUT(5, printk("sg_build_indirect: k_use_sg=%d, "
1887 "rem_sz=%d\n", k, rem_sz));
1887 1888
1888 schp->bufflen = blk_size; 1889 schp->bufflen = blk_size;
1889 if (rem_sz > 0) /* must have failed */ 1890 if (rem_sz > 0) /* must have failed */
@@ -2014,7 +2015,7 @@ sg_remove_scat(Sg_scatter_hold * schp)
2014 for (k = 0; (k < schp->k_use_sg) && sg->page; 2015 for (k = 0; (k < schp->k_use_sg) && sg->page;
2015 ++k, ++sg) { 2016 ++k, ++sg) {
2016 SCSI_LOG_TIMEOUT(5, printk( 2017 SCSI_LOG_TIMEOUT(5, printk(
2017 "sg_remove_scat: k=%d, a=0x%p, len=%d\n", 2018 "sg_remove_scat: k=%d, pg=0x%p, len=%d\n",
2018 k, sg->page, sg->length)); 2019 k, sg->page, sg->length));
2019 sg_page_free(sg->page, sg->length); 2020 sg_page_free(sg->page, sg->length);
2020 } 2021 }
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index e1a52c525ed4..587274dd7059 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -9,7 +9,7 @@
9 Steve Hirsch, Andreas Koppenh"ofer, Michael Leodolter, Eyal Lebedinsky, 9 Steve Hirsch, Andreas Koppenh"ofer, Michael Leodolter, Eyal Lebedinsky,
10 Michael Schaefer, J"org Weule, and Eric Youngdale. 10 Michael Schaefer, J"org Weule, and Eric Youngdale.
11 11
12 Copyright 1992 - 2005 Kai Makisara 12 Copyright 1992 - 2006 Kai Makisara
13 email Kai.Makisara@kolumbus.fi 13 email Kai.Makisara@kolumbus.fi
14 14
15 Some small formal changes - aeb, 950809 15 Some small formal changes - aeb, 950809
@@ -17,7 +17,7 @@
17 Last modified: 18-JAN-1998 Richard Gooch <rgooch@atnf.csiro.au> Devfs support 17 Last modified: 18-JAN-1998 Richard Gooch <rgooch@atnf.csiro.au> Devfs support
18 */ 18 */
19 19
20static const char *verstr = "20050830"; 20static const char *verstr = "20061107";
21 21
22#include <linux/module.h> 22#include <linux/module.h>
23 23
@@ -999,7 +999,7 @@ static int check_tape(struct scsi_tape *STp, struct file *filp)
999 STp->min_block = ((STp->buffer)->b_data[4] << 8) | 999 STp->min_block = ((STp->buffer)->b_data[4] << 8) |
1000 (STp->buffer)->b_data[5]; 1000 (STp->buffer)->b_data[5];
1001 if ( DEB( debugging || ) !STp->inited) 1001 if ( DEB( debugging || ) !STp->inited)
1002 printk(KERN_WARNING 1002 printk(KERN_INFO
1003 "%s: Block limits %d - %d bytes.\n", name, 1003 "%s: Block limits %d - %d bytes.\n", name,
1004 STp->min_block, STp->max_block); 1004 STp->min_block, STp->max_block);
1005 } else { 1005 } else {
@@ -1224,7 +1224,7 @@ static int st_flush(struct file *filp, fl_owner_t id)
1224 } 1224 }
1225 1225
1226 DEBC( if (STp->nbr_requests) 1226 DEBC( if (STp->nbr_requests)
1227 printk(KERN_WARNING "%s: Number of r/w requests %d, dio used in %d, pages %d (%d).\n", 1227 printk(KERN_DEBUG "%s: Number of r/w requests %d, dio used in %d, pages %d (%d).\n",
1228 name, STp->nbr_requests, STp->nbr_dio, STp->nbr_pages, STp->nbr_combinable)); 1228 name, STp->nbr_requests, STp->nbr_dio, STp->nbr_pages, STp->nbr_combinable));
1229 1229
1230 if (STps->rw == ST_WRITING && !STp->pos_unknown) { 1230 if (STps->rw == ST_WRITING && !STp->pos_unknown) {
@@ -4056,11 +4056,11 @@ static int st_probe(struct device *dev)
4056 goto out_free_tape; 4056 goto out_free_tape;
4057 } 4057 }
4058 4058
4059 sdev_printk(KERN_WARNING, SDp, 4059 sdev_printk(KERN_NOTICE, SDp,
4060 "Attached scsi tape %s\n", tape_name(tpnt)); 4060 "Attached scsi tape %s\n", tape_name(tpnt));
4061 printk(KERN_WARNING "%s: try direct i/o: %s (alignment %d B)\n", 4061 sdev_printk(KERN_INFO, SDp, "%s: try direct i/o: %s (alignment %d B)\n",
4062 tape_name(tpnt), tpnt->try_dio ? "yes" : "no", 4062 tape_name(tpnt), tpnt->try_dio ? "yes" : "no",
4063 queue_dma_alignment(SDp->request_queue) + 1); 4063 queue_dma_alignment(SDp->request_queue) + 1);
4064 4064
4065 return 0; 4065 return 0;
4066 4066
diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c
index 185c270bb043..ba6bcdaf2a6a 100644
--- a/drivers/scsi/stex.c
+++ b/drivers/scsi/stex.c
@@ -11,8 +11,6 @@
11 * Written By: 11 * Written By:
12 * Ed Lin <promise_linux@promise.com> 12 * Ed Lin <promise_linux@promise.com>
13 * 13 *
14 * Version: 3.0.0.1
15 *
16 */ 14 */
17 15
18#include <linux/init.h> 16#include <linux/init.h>
@@ -37,9 +35,9 @@
37#include <scsi/scsi_tcq.h> 35#include <scsi/scsi_tcq.h>
38 36
39#define DRV_NAME "stex" 37#define DRV_NAME "stex"
40#define ST_DRIVER_VERSION "3.0.0.1" 38#define ST_DRIVER_VERSION "3.1.0.1"
41#define ST_VER_MAJOR 3 39#define ST_VER_MAJOR 3
42#define ST_VER_MINOR 0 40#define ST_VER_MINOR 1
43#define ST_OEM 0 41#define ST_OEM 0
44#define ST_BUILD_VER 1 42#define ST_BUILD_VER 1
45 43
@@ -76,8 +74,10 @@ enum {
76 MU_STATE_STARTED = 4, 74 MU_STATE_STARTED = 4,
77 MU_STATE_RESETTING = 5, 75 MU_STATE_RESETTING = 5,
78 76
79 MU_MAX_DELAY_TIME = 240000, 77 MU_MAX_DELAY = 120,
80 MU_HANDSHAKE_SIGNATURE = 0x55aaaa55, 78 MU_HANDSHAKE_SIGNATURE = 0x55aaaa55,
79 MU_HANDSHAKE_SIGNATURE_HALF = 0x5a5a0000,
80 MU_HARD_RESET_WAIT = 30000,
81 HMU_PARTNER_TYPE = 2, 81 HMU_PARTNER_TYPE = 2,
82 82
83 /* firmware returned values */ 83 /* firmware returned values */
@@ -120,7 +120,8 @@ enum {
120 120
121 st_shasta = 0, 121 st_shasta = 0,
122 st_vsc = 1, 122 st_vsc = 1,
123 st_yosemite = 2, 123 st_vsc1 = 2,
124 st_yosemite = 3,
124 125
125 PASSTHRU_REQ_TYPE = 0x00000001, 126 PASSTHRU_REQ_TYPE = 0x00000001,
126 PASSTHRU_REQ_NO_WAKEUP = 0x00000100, 127 PASSTHRU_REQ_NO_WAKEUP = 0x00000100,
@@ -150,6 +151,8 @@ enum {
150 MGT_CMD_SIGNATURE = 0xba, 151 MGT_CMD_SIGNATURE = 0xba,
151 152
152 INQUIRY_EVPD = 0x01, 153 INQUIRY_EVPD = 0x01,
154
155 ST_ADDITIONAL_MEM = 0x200000,
153}; 156};
154 157
155/* SCSI inquiry data */ 158/* SCSI inquiry data */
@@ -211,7 +214,9 @@ struct handshake_frame {
211 __le32 partner_ver_minor; 214 __le32 partner_ver_minor;
212 __le32 partner_ver_oem; 215 __le32 partner_ver_oem;
213 __le32 partner_ver_build; 216 __le32 partner_ver_build;
214 u32 reserved1[4]; 217 __le32 extra_offset; /* NEW */
218 __le32 extra_size; /* NEW */
219 u32 reserved1[2];
215}; 220};
216 221
217struct req_msg { 222struct req_msg {
@@ -302,6 +307,7 @@ struct st_hba {
302 void __iomem *mmio_base; /* iomapped PCI memory space */ 307 void __iomem *mmio_base; /* iomapped PCI memory space */
303 void *dma_mem; 308 void *dma_mem;
304 dma_addr_t dma_handle; 309 dma_addr_t dma_handle;
310 size_t dma_size;
305 311
306 struct Scsi_Host *host; 312 struct Scsi_Host *host;
307 struct pci_dev *pdev; 313 struct pci_dev *pdev;
@@ -507,6 +513,7 @@ static void stex_controller_info(struct st_hba *hba, struct st_ccb *ccb)
507 size_t count = sizeof(struct st_frame); 513 size_t count = sizeof(struct st_frame);
508 514
509 p = hba->copy_buffer; 515 p = hba->copy_buffer;
516 stex_internal_copy(ccb->cmd, p, &count, ccb->sg_count, ST_FROM_CMD);
510 memset(p->base, 0, sizeof(u32)*6); 517 memset(p->base, 0, sizeof(u32)*6);
511 *(unsigned long *)(p->base) = pci_resource_start(hba->pdev, 0); 518 *(unsigned long *)(p->base) = pci_resource_start(hba->pdev, 0);
512 p->rom_addr = 0; 519 p->rom_addr = 0;
@@ -901,27 +908,34 @@ static int stex_handshake(struct st_hba *hba)
901 void __iomem *base = hba->mmio_base; 908 void __iomem *base = hba->mmio_base;
902 struct handshake_frame *h; 909 struct handshake_frame *h;
903 dma_addr_t status_phys; 910 dma_addr_t status_phys;
904 int i; 911 u32 data;
912 unsigned long before;
905 913
906 if (readl(base + OMR0) != MU_HANDSHAKE_SIGNATURE) { 914 if (readl(base + OMR0) != MU_HANDSHAKE_SIGNATURE) {
907 writel(MU_INBOUND_DOORBELL_HANDSHAKE, base + IDBL); 915 writel(MU_INBOUND_DOORBELL_HANDSHAKE, base + IDBL);
908 readl(base + IDBL); 916 readl(base + IDBL);
909 for (i = 0; readl(base + OMR0) != MU_HANDSHAKE_SIGNATURE 917 before = jiffies;
910 && i < MU_MAX_DELAY_TIME; i++) { 918 while (readl(base + OMR0) != MU_HANDSHAKE_SIGNATURE) {
919 if (time_after(jiffies, before + MU_MAX_DELAY * HZ)) {
920 printk(KERN_ERR DRV_NAME
921 "(%s): no handshake signature\n",
922 pci_name(hba->pdev));
923 return -1;
924 }
911 rmb(); 925 rmb();
912 msleep(1); 926 msleep(1);
913 } 927 }
914
915 if (i == MU_MAX_DELAY_TIME) {
916 printk(KERN_ERR DRV_NAME
917 "(%s): no handshake signature\n",
918 pci_name(hba->pdev));
919 return -1;
920 }
921 } 928 }
922 929
923 udelay(10); 930 udelay(10);
924 931
932 data = readl(base + OMR1);
933 if ((data & 0xffff0000) == MU_HANDSHAKE_SIGNATURE_HALF) {
934 data &= 0x0000ffff;
935 if (hba->host->can_queue > data)
936 hba->host->can_queue = data;
937 }
938
925 h = (struct handshake_frame *)(hba->dma_mem + MU_REQ_BUFFER_SIZE); 939 h = (struct handshake_frame *)(hba->dma_mem + MU_REQ_BUFFER_SIZE);
926 h->rb_phy = cpu_to_le32(hba->dma_handle); 940 h->rb_phy = cpu_to_le32(hba->dma_handle);
927 h->rb_phy_hi = cpu_to_le32((hba->dma_handle >> 16) >> 16); 941 h->rb_phy_hi = cpu_to_le32((hba->dma_handle >> 16) >> 16);
@@ -931,6 +945,11 @@ static int stex_handshake(struct st_hba *hba)
931 h->status_cnt = cpu_to_le16(MU_STATUS_COUNT); 945 h->status_cnt = cpu_to_le16(MU_STATUS_COUNT);
932 stex_gettime(&h->hosttime); 946 stex_gettime(&h->hosttime);
933 h->partner_type = HMU_PARTNER_TYPE; 947 h->partner_type = HMU_PARTNER_TYPE;
948 if (hba->dma_size > STEX_BUFFER_SIZE) {
949 h->extra_offset = cpu_to_le32(STEX_BUFFER_SIZE);
950 h->extra_size = cpu_to_le32(ST_ADDITIONAL_MEM);
951 } else
952 h->extra_offset = h->extra_size = 0;
934 953
935 status_phys = hba->dma_handle + MU_REQ_BUFFER_SIZE; 954 status_phys = hba->dma_handle + MU_REQ_BUFFER_SIZE;
936 writel(status_phys, base + IMR0); 955 writel(status_phys, base + IMR0);
@@ -944,19 +963,18 @@ static int stex_handshake(struct st_hba *hba)
944 readl(base + IDBL); /* flush */ 963 readl(base + IDBL); /* flush */
945 964
946 udelay(10); 965 udelay(10);
947 for (i = 0; readl(base + OMR0) != MU_HANDSHAKE_SIGNATURE 966 before = jiffies;
948 && i < MU_MAX_DELAY_TIME; i++) { 967 while (readl(base + OMR0) != MU_HANDSHAKE_SIGNATURE) {
968 if (time_after(jiffies, before + MU_MAX_DELAY * HZ)) {
969 printk(KERN_ERR DRV_NAME
970 "(%s): no signature after handshake frame\n",
971 pci_name(hba->pdev));
972 return -1;
973 }
949 rmb(); 974 rmb();
950 msleep(1); 975 msleep(1);
951 } 976 }
952 977
953 if (i == MU_MAX_DELAY_TIME) {
954 printk(KERN_ERR DRV_NAME
955 "(%s): no signature after handshake frame\n",
956 pci_name(hba->pdev));
957 return -1;
958 }
959
960 writel(0, base + IMR0); 978 writel(0, base + IMR0);
961 readl(base + IMR0); 979 readl(base + IMR0);
962 writel(0, base + OMR0); 980 writel(0, base + OMR0);
@@ -1038,9 +1056,9 @@ static void stex_hard_reset(struct st_hba *hba)
1038 pci_bctl &= ~PCI_BRIDGE_CTL_BUS_RESET; 1056 pci_bctl &= ~PCI_BRIDGE_CTL_BUS_RESET;
1039 pci_write_config_byte(bus->self, PCI_BRIDGE_CONTROL, pci_bctl); 1057 pci_write_config_byte(bus->self, PCI_BRIDGE_CONTROL, pci_bctl);
1040 1058
1041 for (i = 0; i < MU_MAX_DELAY_TIME; i++) { 1059 for (i = 0; i < MU_HARD_RESET_WAIT; i++) {
1042 pci_read_config_word(hba->pdev, PCI_COMMAND, &pci_cmd); 1060 pci_read_config_word(hba->pdev, PCI_COMMAND, &pci_cmd);
1043 if (pci_cmd & PCI_COMMAND_MASTER) 1061 if (pci_cmd != 0xffff && (pci_cmd & PCI_COMMAND_MASTER))
1044 break; 1062 break;
1045 msleep(1); 1063 msleep(1);
1046 } 1064 }
@@ -1100,18 +1118,18 @@ static int stex_reset(struct scsi_cmnd *cmd)
1100static int stex_biosparam(struct scsi_device *sdev, 1118static int stex_biosparam(struct scsi_device *sdev,
1101 struct block_device *bdev, sector_t capacity, int geom[]) 1119 struct block_device *bdev, sector_t capacity, int geom[])
1102{ 1120{
1103 int heads = 255, sectors = 63, cylinders; 1121 int heads = 255, sectors = 63;
1104 1122
1105 if (capacity < 0x200000) { 1123 if (capacity < 0x200000) {
1106 heads = 64; 1124 heads = 64;
1107 sectors = 32; 1125 sectors = 32;
1108 } 1126 }
1109 1127
1110 cylinders = sector_div(capacity, heads * sectors); 1128 sector_div(capacity, heads * sectors);
1111 1129
1112 geom[0] = heads; 1130 geom[0] = heads;
1113 geom[1] = sectors; 1131 geom[1] = sectors;
1114 geom[2] = cylinders; 1132 geom[2] = capacity;
1115 1133
1116 return 0; 1134 return 0;
1117} 1135}
@@ -1193,8 +1211,13 @@ stex_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1193 goto out_iounmap; 1211 goto out_iounmap;
1194 } 1212 }
1195 1213
1214 hba->cardtype = (unsigned int) id->driver_data;
1215 if (hba->cardtype == st_vsc && (pdev->subsystem_device & 0xf) == 0x1)
1216 hba->cardtype = st_vsc1;
1217 hba->dma_size = (hba->cardtype == st_vsc1) ?
1218 (STEX_BUFFER_SIZE + ST_ADDITIONAL_MEM) : (STEX_BUFFER_SIZE);
1196 hba->dma_mem = dma_alloc_coherent(&pdev->dev, 1219 hba->dma_mem = dma_alloc_coherent(&pdev->dev,
1197 STEX_BUFFER_SIZE, &hba->dma_handle, GFP_KERNEL); 1220 hba->dma_size, &hba->dma_handle, GFP_KERNEL);
1198 if (!hba->dma_mem) { 1221 if (!hba->dma_mem) {
1199 err = -ENOMEM; 1222 err = -ENOMEM;
1200 printk(KERN_ERR DRV_NAME "(%s): dma mem alloc failed\n", 1223 printk(KERN_ERR DRV_NAME "(%s): dma mem alloc failed\n",
@@ -1207,8 +1230,6 @@ stex_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1207 hba->copy_buffer = hba->dma_mem + MU_BUFFER_SIZE; 1230 hba->copy_buffer = hba->dma_mem + MU_BUFFER_SIZE;
1208 hba->mu_status = MU_STATE_STARTING; 1231 hba->mu_status = MU_STATE_STARTING;
1209 1232
1210 hba->cardtype = (unsigned int) id->driver_data;
1211
1212 /* firmware uses id/lun pair for a logical drive, but lun would be 1233 /* firmware uses id/lun pair for a logical drive, but lun would be
1213 always 0 if CONFIG_SCSI_MULTI_LUN not configured, so we use 1234 always 0 if CONFIG_SCSI_MULTI_LUN not configured, so we use
1214 channel to map lun here */ 1235 channel to map lun here */
@@ -1233,7 +1254,7 @@ stex_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1233 if (err) 1254 if (err)
1234 goto out_free_irq; 1255 goto out_free_irq;
1235 1256
1236 err = scsi_init_shared_tag_map(host, ST_CAN_QUEUE); 1257 err = scsi_init_shared_tag_map(host, host->can_queue);
1237 if (err) { 1258 if (err) {
1238 printk(KERN_ERR DRV_NAME "(%s): init shared queue failed\n", 1259 printk(KERN_ERR DRV_NAME "(%s): init shared queue failed\n",
1239 pci_name(pdev)); 1260 pci_name(pdev));
@@ -1256,7 +1277,7 @@ stex_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1256out_free_irq: 1277out_free_irq:
1257 free_irq(pdev->irq, hba); 1278 free_irq(pdev->irq, hba);
1258out_pci_free: 1279out_pci_free:
1259 dma_free_coherent(&pdev->dev, STEX_BUFFER_SIZE, 1280 dma_free_coherent(&pdev->dev, hba->dma_size,
1260 hba->dma_mem, hba->dma_handle); 1281 hba->dma_mem, hba->dma_handle);
1261out_iounmap: 1282out_iounmap:
1262 iounmap(hba->mmio_base); 1283 iounmap(hba->mmio_base);
@@ -1317,7 +1338,7 @@ static void stex_hba_free(struct st_hba *hba)
1317 1338
1318 pci_release_regions(hba->pdev); 1339 pci_release_regions(hba->pdev);
1319 1340
1320 dma_free_coherent(&hba->pdev->dev, STEX_BUFFER_SIZE, 1341 dma_free_coherent(&hba->pdev->dev, hba->dma_size,
1321 hba->dma_mem, hba->dma_handle); 1342 hba->dma_mem, hba->dma_handle);
1322} 1343}
1323 1344
@@ -1346,15 +1367,32 @@ static void stex_shutdown(struct pci_dev *pdev)
1346} 1367}
1347 1368
1348static struct pci_device_id stex_pci_tbl[] = { 1369static struct pci_device_id stex_pci_tbl[] = {
1349 { 0x105a, 0x8350, PCI_ANY_ID, PCI_ANY_ID, 0, 0, st_shasta }, 1370 /* st_shasta */
1350 { 0x105a, 0xc350, PCI_ANY_ID, PCI_ANY_ID, 0, 0, st_shasta }, 1371 { 0x105a, 0x8350, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
1351 { 0x105a, 0xf350, PCI_ANY_ID, PCI_ANY_ID, 0, 0, st_shasta }, 1372 st_shasta }, /* SuperTrak EX8350/8300/16350/16300 */
1352 { 0x105a, 0x4301, PCI_ANY_ID, PCI_ANY_ID, 0, 0, st_shasta }, 1373 { 0x105a, 0xc350, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
1353 { 0x105a, 0x4302, PCI_ANY_ID, PCI_ANY_ID, 0, 0, st_shasta }, 1374 st_shasta }, /* SuperTrak EX12350 */
1354 { 0x105a, 0x8301, PCI_ANY_ID, PCI_ANY_ID, 0, 0, st_shasta }, 1375 { 0x105a, 0x4302, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
1355 { 0x105a, 0x8302, PCI_ANY_ID, PCI_ANY_ID, 0, 0, st_shasta }, 1376 st_shasta }, /* SuperTrak EX4350 */
1356 { 0x1725, 0x7250, PCI_ANY_ID, PCI_ANY_ID, 0, 0, st_vsc }, 1377 { 0x105a, 0xe350, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
1357 { 0x105a, 0x8650, PCI_ANY_ID, PCI_ANY_ID, 0, 0, st_yosemite }, 1378 st_shasta }, /* SuperTrak EX24350 */
1379
1380 /* st_vsc */
1381 { 0x105a, 0x7250, PCI_ANY_ID, PCI_ANY_ID, 0, 0, st_vsc },
1382
1383 /* st_yosemite */
1384 { 0x105a, 0x8650, PCI_ANY_ID, 0x4600, 0, 0,
1385 st_yosemite }, /* SuperTrak EX4650 */
1386 { 0x105a, 0x8650, PCI_ANY_ID, 0x4610, 0, 0,
1387 st_yosemite }, /* SuperTrak EX4650o */
1388 { 0x105a, 0x8650, PCI_ANY_ID, 0x8600, 0, 0,
1389 st_yosemite }, /* SuperTrak EX8650EL */
1390 { 0x105a, 0x8650, PCI_ANY_ID, 0x8601, 0, 0,
1391 st_yosemite }, /* SuperTrak EX8650 */
1392 { 0x105a, 0x8650, PCI_ANY_ID, 0x8602, 0, 0,
1393 st_yosemite }, /* SuperTrak EX8654 */
1394 { 0x105a, 0x8650, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
1395 st_yosemite }, /* generic st_yosemite */
1358 { } /* terminate list */ 1396 { } /* terminate list */
1359}; 1397};
1360MODULE_DEVICE_TABLE(pci, stex_pci_tbl); 1398MODULE_DEVICE_TABLE(pci, stex_pci_tbl);
diff --git a/drivers/scsi/t128.h b/drivers/scsi/t128.h
index 646e840266e2..76a069b7ac0b 100644
--- a/drivers/scsi/t128.h
+++ b/drivers/scsi/t128.h
@@ -8,20 +8,20 @@
8 * drew@colorado.edu 8 * drew@colorado.edu
9 * +1 (303) 440-4894 9 * +1 (303) 440-4894
10 * 10 *
11 * DISTRIBUTION RELEASE 3. 11 * DISTRIBUTION RELEASE 3.
12 * 12 *
13 * For more information, please consult 13 * For more information, please consult
14 * 14 *
15 * Trantor Systems, Ltd. 15 * Trantor Systems, Ltd.
16 * T128/T128F/T228 SCSI Host Adapter 16 * T128/T128F/T228 SCSI Host Adapter
17 * Hardware Specifications 17 * Hardware Specifications
18 * 18 *
19 * Trantor Systems, Ltd. 19 * Trantor Systems, Ltd.
20 * 5415 Randall Place 20 * 5415 Randall Place
21 * Fremont, CA 94538 21 * Fremont, CA 94538
22 * 1+ (415) 770-1400, FAX 1+ (415) 770-9910 22 * 1+ (415) 770-1400, FAX 1+ (415) 770-9910
23 * 23 *
24 * and 24 * and
25 * 25 *
26 * NCR 5380 Family 26 * NCR 5380 Family
27 * SCSI Protocol Controller 27 * SCSI Protocol Controller
@@ -48,15 +48,15 @@
48#define TDEBUG_TRANSFER 0x2 48#define TDEBUG_TRANSFER 0x2
49 49
50/* 50/*
51 * The trantor boards are memory mapped. They use an NCR5380 or 51 * The trantor boards are memory mapped. They use an NCR5380 or
52 * equivalent (my sample board had part second sourced from ZILOG). 52 * equivalent (my sample board had part second sourced from ZILOG).
53 * NCR's recommended "Pseudo-DMA" architecture is used, where 53 * NCR's recommended "Pseudo-DMA" architecture is used, where
54 * a PAL drives the DMA signals on the 5380 allowing fast, blind 54 * a PAL drives the DMA signals on the 5380 allowing fast, blind
55 * transfers with proper handshaking. 55 * transfers with proper handshaking.
56 */ 56 */
57 57
58/* 58/*
59 * Note : a boot switch is provided for the purpose of informing the 59 * Note : a boot switch is provided for the purpose of informing the
60 * firmware to boot or not boot from attached SCSI devices. So, I imagine 60 * firmware to boot or not boot from attached SCSI devices. So, I imagine
61 * there are fewer people who've yanked the ROM like they do on the Seagate 61 * there are fewer people who've yanked the ROM like they do on the Seagate
62 * to make bootup faster, and I'll probably use this for autodetection. 62 * to make bootup faster, and I'll probably use this for autodetection.
@@ -92,19 +92,20 @@
92#define T_DATA_REG_OFFSET 0x1e00 /* rw 512 bytes long */ 92#define T_DATA_REG_OFFSET 0x1e00 /* rw 512 bytes long */
93 93
94#ifndef ASM 94#ifndef ASM
95static int t128_abort(Scsi_Cmnd *); 95static int t128_abort(struct scsi_cmnd *);
96static int t128_biosparam(struct scsi_device *, struct block_device *, 96static int t128_biosparam(struct scsi_device *, struct block_device *,
97 sector_t, int*); 97 sector_t, int*);
98static int t128_detect(struct scsi_host_template *); 98static int t128_detect(struct scsi_host_template *);
99static int t128_queue_command(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *)); 99static int t128_queue_command(struct scsi_cmnd *,
100static int t128_bus_reset(Scsi_Cmnd *); 100 void (*done)(struct scsi_cmnd *));
101static int t128_bus_reset(struct scsi_cmnd *);
101 102
102#ifndef CMD_PER_LUN 103#ifndef CMD_PER_LUN
103#define CMD_PER_LUN 2 104#define CMD_PER_LUN 2
104#endif 105#endif
105 106
106#ifndef CAN_QUEUE 107#ifndef CAN_QUEUE
107#define CAN_QUEUE 32 108#define CAN_QUEUE 32
108#endif 109#endif
109 110
110#ifndef HOSTS_C 111#ifndef HOSTS_C
@@ -120,7 +121,7 @@ static int t128_bus_reset(Scsi_Cmnd *);
120 121
121#define T128_address(reg) (base + T_5380_OFFSET + ((reg) * 0x20)) 122#define T128_address(reg) (base + T_5380_OFFSET + ((reg) * 0x20))
122 123
123#if !(TDEBUG & TDEBUG_TRANSFER) 124#if !(TDEBUG & TDEBUG_TRANSFER)
124#define NCR5380_read(reg) readb(T128_address(reg)) 125#define NCR5380_read(reg) readb(T128_address(reg))
125#define NCR5380_write(reg, value) writeb((value),(T128_address(reg))) 126#define NCR5380_write(reg, value) writeb((value),(T128_address(reg)))
126#else 127#else
@@ -129,7 +130,7 @@ static int t128_bus_reset(Scsi_Cmnd *);
129 , instance->hostno, (reg), T128_address(reg))), readb(T128_address(reg))) 130 , instance->hostno, (reg), T128_address(reg))), readb(T128_address(reg)))
130 131
131#define NCR5380_write(reg, value) { \ 132#define NCR5380_write(reg, value) { \
132 printk("scsi%d : write %02x to register %d at address %08x\n", \ 133 printk("scsi%d : write %02x to register %d at address %08x\n", \
133 instance->hostno, (value), (reg), T128_address(reg)); \ 134 instance->hostno, (value), (reg), T128_address(reg)); \
134 writeb((value), (T128_address(reg))); \ 135 writeb((value), (T128_address(reg))); \
135} 136}
@@ -142,10 +143,10 @@ static int t128_bus_reset(Scsi_Cmnd *);
142#define NCR5380_bus_reset t128_bus_reset 143#define NCR5380_bus_reset t128_bus_reset
143#define NCR5380_proc_info t128_proc_info 144#define NCR5380_proc_info t128_proc_info
144 145
145/* 15 14 12 10 7 5 3 146/* 15 14 12 10 7 5 3
146 1101 0100 1010 1000 */ 147 1101 0100 1010 1000 */
147 148
148#define T128_IRQS 0xc4a8 149#define T128_IRQS 0xc4a8
149 150
150#endif /* else def HOSTS_C */ 151#endif /* else def HOSTS_C */
151#endif /* ndef ASM */ 152#endif /* ndef ASM */
diff --git a/drivers/serial/8250_exar_st16c554.c b/drivers/serial/8250_exar_st16c554.c
new file mode 100644
index 000000000000..567143ace159
--- /dev/null
+++ b/drivers/serial/8250_exar_st16c554.c
@@ -0,0 +1,52 @@
1/*
2 * linux/drivers/serial/8250_exar.c
3 *
4 * Written by Paul B Schroeder < pschroeder "at" uplogix "dot" com >
5 * Based on 8250_boca.
6 *
7 * Copyright (C) 2005 Russell King.
8 * Data taken from include/asm-i386/serial.h
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 */
14#include <linux/module.h>
15#include <linux/init.h>
16#include <linux/serial_8250.h>
17
18#define PORT(_base,_irq) \
19 { \
20 .iobase = _base, \
21 .irq = _irq, \
22 .uartclk = 1843200, \
23 .iotype = UPIO_PORT, \
24 .flags = UPF_BOOT_AUTOCONF, \
25 }
26
27static struct plat_serial8250_port exar_data[] = {
28 PORT(0x100, 5),
29 PORT(0x108, 5),
30 PORT(0x110, 5),
31 PORT(0x118, 5),
32 { },
33};
34
35static struct platform_device exar_device = {
36 .name = "serial8250",
37 .id = PLAT8250_DEV_EXAR_ST16C554,
38 .dev = {
39 .platform_data = exar_data,
40 },
41};
42
43static int __init exar_init(void)
44{
45 return platform_device_register(&exar_device);
46}
47
48module_init(exar_init);
49
50MODULE_AUTHOR("Paul B Schroeder");
51MODULE_DESCRIPTION("8250 serial probe module for Exar cards");
52MODULE_LICENSE("GPL");
diff --git a/drivers/serial/8250_pnp.c b/drivers/serial/8250_pnp.c
index 71d907c8288b..d3d6b82706b5 100644
--- a/drivers/serial/8250_pnp.c
+++ b/drivers/serial/8250_pnp.c
@@ -464,11 +464,38 @@ static void __devexit serial_pnp_remove(struct pnp_dev *dev)
464 serial8250_unregister_port(line - 1); 464 serial8250_unregister_port(line - 1);
465} 465}
466 466
467#ifdef CONFIG_PM
468static int serial_pnp_suspend(struct pnp_dev *dev, pm_message_t state)
469{
470 long line = (long)pnp_get_drvdata(dev);
471
472 if (!line)
473 return -ENODEV;
474 serial8250_suspend_port(line - 1);
475 return 0;
476}
477
478static int serial_pnp_resume(struct pnp_dev *dev)
479{
480 long line = (long)pnp_get_drvdata(dev);
481
482 if (!line)
483 return -ENODEV;
484 serial8250_resume_port(line - 1);
485 return 0;
486}
487#else
488#define serial_pnp_suspend NULL
489#define serial_pnp_resume NULL
490#endif /* CONFIG_PM */
491
467static struct pnp_driver serial_pnp_driver = { 492static struct pnp_driver serial_pnp_driver = {
468 .name = "serial", 493 .name = "serial",
469 .id_table = pnp_dev_table,
470 .probe = serial_pnp_probe, 494 .probe = serial_pnp_probe,
471 .remove = __devexit_p(serial_pnp_remove), 495 .remove = __devexit_p(serial_pnp_remove),
496 .suspend = serial_pnp_suspend,
497 .resume = serial_pnp_resume,
498 .id_table = pnp_dev_table,
472}; 499};
473 500
474static int __init serial8250_pnp_init(void) 501static int __init serial8250_pnp_init(void)
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 0b71e7d18903..fc12d5df10e2 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -210,6 +210,17 @@ config SERIAL_8250_BOCA
210 To compile this driver as a module, choose M here: the module 210 To compile this driver as a module, choose M here: the module
211 will be called 8250_boca. 211 will be called 8250_boca.
212 212
213config SERIAL_8250_EXAR_ST16C554
214 tristate "Support Exar ST16C554/554D Quad UART"
215 depends on SERIAL_8250 != n && ISA && SERIAL_8250_MANY_PORTS
216 help
217 The Uplogix Envoy TU301 uses this Exar Quad UART. If you are
218 tinkering with your Envoy TU301, or have a machine with this UART,
219 say Y here.
220
221 To compile this driver as a module, choose M here: the module
222 will be called 8250_exar_st16c554.
223
213config SERIAL_8250_HUB6 224config SERIAL_8250_HUB6
214 tristate "Support Hub6 cards" 225 tristate "Support Hub6 cards"
215 depends on SERIAL_8250 != n && ISA && SERIAL_8250_MANY_PORTS 226 depends on SERIAL_8250 != n && ISA && SERIAL_8250_MANY_PORTS
@@ -511,6 +522,25 @@ config SERIAL_IMX_CONSOLE
511 your boot loader (lilo or loadlin) about how to pass options to the 522 your boot loader (lilo or loadlin) about how to pass options to the
512 kernel at boot time.) 523 kernel at boot time.)
513 524
525config SERIAL_UARTLITE
526 tristate "Xilinx uartlite serial port support"
527 depends on PPC32
528 select SERIAL_CORE
529 help
530 Say Y here if you want to use the Xilinx uartlite serial controller.
531
532 To compile this driver as a module, choose M here: the
533 module will be called uartlite.ko.
534
535config SERIAL_UARTLITE_CONSOLE
536 bool "Support for console on Xilinx uartlite serial port"
537 depends on SERIAL_UARTLITE=y
538 select SERIAL_CORE_CONSOLE
539 help
540 Say Y here if you wish to use a Xilinx uartlite as the system
541 console (the system console is the device which receives all kernel
542 messages and warnings and which allows logins in single user mode).
543
514config SERIAL_SUNCORE 544config SERIAL_SUNCORE
515 bool 545 bool
516 depends on SPARC 546 depends on SPARC
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index b4d8a7c182e3..df3632cd7df9 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -17,6 +17,7 @@ obj-$(CONFIG_SERIAL_8250_CONSOLE) += 8250_early.o
17obj-$(CONFIG_SERIAL_8250_FOURPORT) += 8250_fourport.o 17obj-$(CONFIG_SERIAL_8250_FOURPORT) += 8250_fourport.o
18obj-$(CONFIG_SERIAL_8250_ACCENT) += 8250_accent.o 18obj-$(CONFIG_SERIAL_8250_ACCENT) += 8250_accent.o
19obj-$(CONFIG_SERIAL_8250_BOCA) += 8250_boca.o 19obj-$(CONFIG_SERIAL_8250_BOCA) += 8250_boca.o
20obj-$(CONFIG_SERIAL_8250_EXAR_ST16C554) += 8250_exar_st16c554.o
20obj-$(CONFIG_SERIAL_8250_HUB6) += 8250_hub6.o 21obj-$(CONFIG_SERIAL_8250_HUB6) += 8250_hub6.o
21obj-$(CONFIG_SERIAL_8250_MCA) += 8250_mca.o 22obj-$(CONFIG_SERIAL_8250_MCA) += 8250_mca.o
22obj-$(CONFIG_SERIAL_8250_AU1X00) += 8250_au1x00.o 23obj-$(CONFIG_SERIAL_8250_AU1X00) += 8250_au1x00.o
@@ -55,4 +56,5 @@ obj-$(CONFIG_SERIAL_VR41XX) += vr41xx_siu.o
55obj-$(CONFIG_SERIAL_SGI_IOC4) += ioc4_serial.o 56obj-$(CONFIG_SERIAL_SGI_IOC4) += ioc4_serial.o
56obj-$(CONFIG_SERIAL_SGI_IOC3) += ioc3_serial.o 57obj-$(CONFIG_SERIAL_SGI_IOC3) += ioc3_serial.o
57obj-$(CONFIG_SERIAL_ATMEL) += atmel_serial.o 58obj-$(CONFIG_SERIAL_ATMEL) += atmel_serial.o
59obj-$(CONFIG_SERIAL_UARTLITE) += uartlite.o
58obj-$(CONFIG_SERIAL_NETX) += netx-serial.o 60obj-$(CONFIG_SERIAL_NETX) += netx-serial.o
diff --git a/drivers/serial/amba-pl010.c b/drivers/serial/amba-pl010.c
index 4213fabc62bf..4d3626ef4643 100644
--- a/drivers/serial/amba-pl010.c
+++ b/drivers/serial/amba-pl010.c
@@ -129,6 +129,8 @@ static void pl010_rx_chars(struct uart_port *port)
129 */ 129 */
130 rsr = readb(port->membase + UART01x_RSR) | UART_DUMMY_RSR_RX; 130 rsr = readb(port->membase + UART01x_RSR) | UART_DUMMY_RSR_RX;
131 if (unlikely(rsr & UART01x_RSR_ANY)) { 131 if (unlikely(rsr & UART01x_RSR_ANY)) {
132 writel(0, port->membase + UART01x_ECR);
133
132 if (rsr & UART01x_RSR_BE) { 134 if (rsr & UART01x_RSR_BE) {
133 rsr &= ~(UART01x_RSR_FE | UART01x_RSR_PE); 135 rsr &= ~(UART01x_RSR_FE | UART01x_RSR_PE);
134 port->icount.brk++; 136 port->icount.brk++;
diff --git a/drivers/serial/atmel_serial.c b/drivers/serial/atmel_serial.c
index 391a1f4167a4..9217ee6c7865 100644
--- a/drivers/serial/atmel_serial.c
+++ b/drivers/serial/atmel_serial.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/char/at91_serial.c 2 * linux/drivers/char/atmel_serial.c
3 * 3 *
4 * Driver for Atmel AT91 / AT32 Serial ports 4 * Driver for Atmel AT91 / AT32 Serial ports
5 * Copyright (C) 2003 Rick Bronson 5 * Copyright (C) 2003 Rick Bronson
@@ -36,11 +36,11 @@
36 36
37#include <asm/io.h> 37#include <asm/io.h>
38 38
39#include <asm/arch/at91rm9200_pdc.h>
40#include <asm/mach/serial_at91.h> 39#include <asm/mach/serial_at91.h>
41#include <asm/arch/board.h> 40#include <asm/arch/board.h>
41#include <asm/arch/at91_pdc.h>
42#ifdef CONFIG_ARM 42#ifdef CONFIG_ARM
43#include <asm/arch/system.h> 43#include <asm/arch/cpu.h>
44#include <asm/arch/gpio.h> 44#include <asm/arch/gpio.h>
45#endif 45#endif
46 46
@@ -137,8 +137,8 @@ static void atmel_set_mctrl(struct uart_port *port, u_int mctrl)
137 unsigned int control = 0; 137 unsigned int control = 0;
138 unsigned int mode; 138 unsigned int mode;
139 139
140#ifdef CONFIG_ARM 140#ifdef CONFIG_ARCH_AT91RM9200
141 if (arch_identify() == ARCH_ID_AT91RM9200) { 141 if (cpu_is_at91rm9200()) {
142 /* 142 /*
143 * AT91RM9200 Errata #39: RTS0 is not internally connected to PA21. 143 * AT91RM9200 Errata #39: RTS0 is not internally connected to PA21.
144 * We need to drive the pin manually. 144 * We need to drive the pin manually.
diff --git a/drivers/serial/atmel_serial.h b/drivers/serial/atmel_serial.h
index eced2ad1a8d9..fe1763b2a6d5 100644
--- a/drivers/serial/atmel_serial.h
+++ b/drivers/serial/atmel_serial.h
@@ -31,8 +31,8 @@
31#define ATMEL_US_RSTIT (1 << 13) /* Reset Iterations */ 31#define ATMEL_US_RSTIT (1 << 13) /* Reset Iterations */
32#define ATMEL_US_RSTNACK (1 << 14) /* Reset Non Acknowledge */ 32#define ATMEL_US_RSTNACK (1 << 14) /* Reset Non Acknowledge */
33#define ATMEL_US_RETTO (1 << 15) /* Rearm Time-out */ 33#define ATMEL_US_RETTO (1 << 15) /* Rearm Time-out */
34#define ATMEL_US_DTREN (1 << 16) /* Data Terminal Ready Enable */ 34#define ATMEL_US_DTREN (1 << 16) /* Data Terminal Ready Enable [AT91RM9200 only] */
35#define ATMEL_US_DTRDIS (1 << 17) /* Data Terminal Ready Disable */ 35#define ATMEL_US_DTRDIS (1 << 17) /* Data Terminal Ready Disable [AT91RM9200 only] */
36#define ATMEL_US_RTSEN (1 << 18) /* Request To Send Enable */ 36#define ATMEL_US_RTSEN (1 << 18) /* Request To Send Enable */
37#define ATMEL_US_RTSDIS (1 << 19) /* Request To Send Disable */ 37#define ATMEL_US_RTSDIS (1 << 19) /* Request To Send Disable */
38 38
@@ -92,9 +92,9 @@
92#define ATMEL_US_TXBUFE (1 << 11) /* Transmission Buffer Empty */ 92#define ATMEL_US_TXBUFE (1 << 11) /* Transmission Buffer Empty */
93#define ATMEL_US_RXBUFF (1 << 12) /* Reception Buffer Full */ 93#define ATMEL_US_RXBUFF (1 << 12) /* Reception Buffer Full */
94#define ATMEL_US_NACK (1 << 13) /* Non Acknowledge */ 94#define ATMEL_US_NACK (1 << 13) /* Non Acknowledge */
95#define ATMEL_US_RIIC (1 << 16) /* Ring Indicator Input Change */ 95#define ATMEL_US_RIIC (1 << 16) /* Ring Indicator Input Change [AT91RM9200 only] */
96#define ATMEL_US_DSRIC (1 << 17) /* Data Set Ready Input Change */ 96#define ATMEL_US_DSRIC (1 << 17) /* Data Set Ready Input Change [AT91RM9200 only] */
97#define ATMEL_US_DCDIC (1 << 18) /* Data Carrier Detect Input Change */ 97#define ATMEL_US_DCDIC (1 << 18) /* Data Carrier Detect Input Change [AT91RM9200 only] */
98#define ATMEL_US_CTSIC (1 << 19) /* Clear to Send Input Change */ 98#define ATMEL_US_CTSIC (1 << 19) /* Clear to Send Input Change */
99#define ATMEL_US_RI (1 << 20) /* RI */ 99#define ATMEL_US_RI (1 << 20) /* RI */
100#define ATMEL_US_DSR (1 << 21) /* DSR */ 100#define ATMEL_US_DSR (1 << 21) /* DSR */
@@ -106,6 +106,7 @@
106#define ATMEL_US_CSR 0x14 /* Channel Status Register */ 106#define ATMEL_US_CSR 0x14 /* Channel Status Register */
107#define ATMEL_US_RHR 0x18 /* Receiver Holding Register */ 107#define ATMEL_US_RHR 0x18 /* Receiver Holding Register */
108#define ATMEL_US_THR 0x1c /* Transmitter Holding Register */ 108#define ATMEL_US_THR 0x1c /* Transmitter Holding Register */
109#define ATMEL_US_SYNH (1 << 15) /* Transmit/Receive Sync [SAM9 only] */
109 110
110#define ATMEL_US_BRGR 0x20 /* Baud Rate Generator Register */ 111#define ATMEL_US_BRGR 0x20 /* Baud Rate Generator Register */
111#define ATMEL_US_CD (0xffff << 0) /* Clock Divider */ 112#define ATMEL_US_CD (0xffff << 0) /* Clock Divider */
diff --git a/drivers/serial/cpm_uart/cpm_uart.h b/drivers/serial/cpm_uart/cpm_uart.h
index a8f894c78194..69715e556506 100644
--- a/drivers/serial/cpm_uart/cpm_uart.h
+++ b/drivers/serial/cpm_uart/cpm_uart.h
@@ -88,7 +88,7 @@ extern struct uart_cpm_port cpm_uart_ports[UART_NR];
88 88
89/* these are located in their respective files */ 89/* these are located in their respective files */
90void cpm_line_cr_cmd(int line, int cmd); 90void cpm_line_cr_cmd(int line, int cmd);
91int cpm_uart_init_portdesc(void); 91int __init cpm_uart_init_portdesc(void);
92int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con); 92int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con);
93void cpm_uart_freebuf(struct uart_cpm_port *pinfo); 93void cpm_uart_freebuf(struct uart_cpm_port *pinfo);
94 94
diff --git a/drivers/serial/cpm_uart/cpm_uart_core.c b/drivers/serial/cpm_uart/cpm_uart_core.c
index 0abb544ae63d..7a3b97fdf8d1 100644
--- a/drivers/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/serial/cpm_uart/cpm_uart_core.c
@@ -195,10 +195,8 @@ static void cpm_uart_start_tx(struct uart_port *port)
195 if (cpm_uart_tx_pump(port) != 0) { 195 if (cpm_uart_tx_pump(port) != 0) {
196 if (IS_SMC(pinfo)) { 196 if (IS_SMC(pinfo)) {
197 smcp->smc_smcm |= SMCM_TX; 197 smcp->smc_smcm |= SMCM_TX;
198 smcp->smc_smcmr |= SMCMR_TEN;
199 } else { 198 } else {
200 sccp->scc_sccm |= UART_SCCM_TX; 199 sccp->scc_sccm |= UART_SCCM_TX;
201 pinfo->sccp->scc_gsmrl |= SCC_GSMRL_ENT;
202 } 200 }
203 } 201 }
204} 202}
@@ -421,9 +419,10 @@ static int cpm_uart_startup(struct uart_port *port)
421 /* Startup rx-int */ 419 /* Startup rx-int */
422 if (IS_SMC(pinfo)) { 420 if (IS_SMC(pinfo)) {
423 pinfo->smcp->smc_smcm |= SMCM_RX; 421 pinfo->smcp->smc_smcm |= SMCM_RX;
424 pinfo->smcp->smc_smcmr |= SMCMR_REN; 422 pinfo->smcp->smc_smcmr |= (SMCMR_REN | SMCMR_TEN);
425 } else { 423 } else {
426 pinfo->sccp->scc_sccm |= UART_SCCM_RX; 424 pinfo->sccp->scc_sccm |= UART_SCCM_RX;
425 pinfo->sccp->scc_gsmrl |= (SCC_GSMRL_ENR | SCC_GSMRL_ENT);
427 } 426 }
428 427
429 if (!(pinfo->flags & FLAG_CONSOLE)) 428 if (!(pinfo->flags & FLAG_CONSOLE))
@@ -1350,11 +1349,10 @@ static int cpm_uart_init(void) {
1350 pr_info("cpm_uart: WARNING: no UART devices found on platform bus!\n"); 1349 pr_info("cpm_uart: WARNING: no UART devices found on platform bus!\n");
1351 pr_info( 1350 pr_info(
1352 "cpm_uart: the driver will guess configuration, but this mode is no longer supported.\n"); 1351 "cpm_uart: the driver will guess configuration, but this mode is no longer supported.\n");
1353#ifndef CONFIG_SERIAL_CPM_CONSOLE 1352
1354 ret = cpm_uart_init_portdesc(); 1353 /* Don't run this again, if the console driver did it already */
1355 if (ret) 1354 if (cpm_uart_nr == 0)
1356 return ret; 1355 cpm_uart_init_portdesc();
1357#endif
1358 1356
1359 cpm_reg.nr = cpm_uart_nr; 1357 cpm_reg.nr = cpm_uart_nr;
1360 ret = uart_register_driver(&cpm_reg); 1358 ret = uart_register_driver(&cpm_reg);
@@ -1366,6 +1364,8 @@ static int cpm_uart_init(void) {
1366 int con = cpm_uart_port_map[i]; 1364 int con = cpm_uart_port_map[i];
1367 cpm_uart_ports[con].port.line = i; 1365 cpm_uart_ports[con].port.line = i;
1368 cpm_uart_ports[con].port.flags = UPF_BOOT_AUTOCONF; 1366 cpm_uart_ports[con].port.flags = UPF_BOOT_AUTOCONF;
1367 if (cpm_uart_ports[con].set_lineif)
1368 cpm_uart_ports[con].set_lineif(&cpm_uart_ports[con]);
1369 uart_add_one_port(&cpm_reg, &cpm_uart_ports[con].port); 1369 uart_add_one_port(&cpm_reg, &cpm_uart_ports[con].port);
1370 } 1370 }
1371 1371
diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm1.c b/drivers/serial/cpm_uart/cpm_uart_cpm1.c
index 95afc37297a8..08e55fdc882a 100644
--- a/drivers/serial/cpm_uart/cpm_uart_cpm1.c
+++ b/drivers/serial/cpm_uart/cpm_uart_cpm1.c
@@ -184,7 +184,7 @@ void cpm_uart_freebuf(struct uart_cpm_port *pinfo)
184} 184}
185 185
186/* Setup any dynamic params in the uart desc */ 186/* Setup any dynamic params in the uart desc */
187int cpm_uart_init_portdesc(void) 187int __init cpm_uart_init_portdesc(void)
188{ 188{
189 pr_debug("CPM uart[-]:init portdesc\n"); 189 pr_debug("CPM uart[-]:init portdesc\n");
190 190
diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm2.c b/drivers/serial/cpm_uart/cpm_uart_cpm2.c
index b691d3e14754..787a8f134677 100644
--- a/drivers/serial/cpm_uart/cpm_uart_cpm2.c
+++ b/drivers/serial/cpm_uart/cpm_uart_cpm2.c
@@ -282,7 +282,7 @@ void cpm_uart_freebuf(struct uart_cpm_port *pinfo)
282} 282}
283 283
284/* Setup any dynamic params in the uart desc */ 284/* Setup any dynamic params in the uart desc */
285int cpm_uart_init_portdesc(void) 285int __init cpm_uart_init_portdesc(void)
286{ 286{
287#if defined(CONFIG_SERIAL_CPM_SMC1) || defined(CONFIG_SERIAL_CPM_SMC2) 287#if defined(CONFIG_SERIAL_CPM_SMC1) || defined(CONFIG_SERIAL_CPM_SMC2)
288 u32 addr; 288 u32 addr;
diff --git a/drivers/serial/dz.c b/drivers/serial/dz.c
index 53662b33b841..af1544f3356f 100644
--- a/drivers/serial/dz.c
+++ b/drivers/serial/dz.c
@@ -1,11 +1,13 @@
1/* 1/*
2 * dz.c: Serial port driver for DECStations equiped 2 * dz.c: Serial port driver for DECstations equipped
3 * with the DZ chipset. 3 * with the DZ chipset.
4 * 4 *
5 * Copyright (C) 1998 Olivier A. D. Lebaillif 5 * Copyright (C) 1998 Olivier A. D. Lebaillif
6 * 6 *
7 * Email: olivier.lebaillif@ifrsys.com 7 * Email: olivier.lebaillif@ifrsys.com
8 * 8 *
9 * Copyright (C) 2004, 2006 Maciej W. Rozycki
10 *
9 * [31-AUG-98] triemer 11 * [31-AUG-98] triemer
10 * Changed IRQ to use Harald's dec internals interrupts.h 12 * Changed IRQ to use Harald's dec internals interrupts.h
11 * removed base_addr code - moving address assignment to setup.c 13 * removed base_addr code - moving address assignment to setup.c
@@ -26,10 +28,16 @@
26 28
27#undef DEBUG_DZ 29#undef DEBUG_DZ
28 30
31#if defined(CONFIG_SERIAL_DZ_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
32#define SUPPORT_SYSRQ
33#endif
34
35#include <linux/delay.h>
29#include <linux/module.h> 36#include <linux/module.h>
30#include <linux/interrupt.h> 37#include <linux/interrupt.h>
31#include <linux/init.h> 38#include <linux/init.h>
32#include <linux/console.h> 39#include <linux/console.h>
40#include <linux/sysrq.h>
33#include <linux/tty.h> 41#include <linux/tty.h>
34#include <linux/tty_flip.h> 42#include <linux/tty_flip.h>
35#include <linux/serial_core.h> 43#include <linux/serial_core.h>
@@ -45,14 +53,10 @@
45#include <asm/system.h> 53#include <asm/system.h>
46#include <asm/uaccess.h> 54#include <asm/uaccess.h>
47 55
48#define CONSOLE_LINE (3) /* for definition of struct console */
49
50#include "dz.h" 56#include "dz.h"
51 57
52#define DZ_INTR_DEBUG 1
53
54static char *dz_name = "DECstation DZ serial driver version "; 58static char *dz_name = "DECstation DZ serial driver version ";
55static char *dz_version = "1.02"; 59static char *dz_version = "1.03";
56 60
57struct dz_port { 61struct dz_port {
58 struct uart_port port; 62 struct uart_port port;
@@ -61,22 +65,6 @@ struct dz_port {
61 65
62static struct dz_port dz_ports[DZ_NB_PORT]; 66static struct dz_port dz_ports[DZ_NB_PORT];
63 67
64#ifdef DEBUG_DZ
65/*
66 * debugging code to send out chars via prom
67 */
68static void debug_console(const char *s, int count)
69{
70 unsigned i;
71
72 for (i = 0; i < count; i++) {
73 if (*s == 10)
74 prom_printf("%c", 13);
75 prom_printf("%c", *s++);
76 }
77}
78#endif
79
80/* 68/*
81 * ------------------------------------------------------------ 69 * ------------------------------------------------------------
82 * dz_in () and dz_out () 70 * dz_in () and dz_out ()
@@ -90,6 +78,7 @@ static inline unsigned short dz_in(struct dz_port *dport, unsigned offset)
90{ 78{
91 volatile unsigned short *addr = 79 volatile unsigned short *addr =
92 (volatile unsigned short *) (dport->port.membase + offset); 80 (volatile unsigned short *) (dport->port.membase + offset);
81
93 return *addr; 82 return *addr;
94} 83}
95 84
@@ -98,6 +87,7 @@ static inline void dz_out(struct dz_port *dport, unsigned offset,
98{ 87{
99 volatile unsigned short *addr = 88 volatile unsigned short *addr =
100 (volatile unsigned short *) (dport->port.membase + offset); 89 (volatile unsigned short *) (dport->port.membase + offset);
90
101 *addr = value; 91 *addr = value;
102} 92}
103 93
@@ -144,7 +134,7 @@ static void dz_stop_rx(struct uart_port *uport)
144 134
145 spin_lock_irqsave(&dport->port.lock, flags); 135 spin_lock_irqsave(&dport->port.lock, flags);
146 dport->cflag &= ~DZ_CREAD; 136 dport->cflag &= ~DZ_CREAD;
147 dz_out(dport, DZ_LPR, dport->cflag); 137 dz_out(dport, DZ_LPR, dport->cflag | dport->port.line);
148 spin_unlock_irqrestore(&dport->port.lock, flags); 138 spin_unlock_irqrestore(&dport->port.lock, flags);
149} 139}
150 140
@@ -155,14 +145,14 @@ static void dz_enable_ms(struct uart_port *port)
155 145
156/* 146/*
157 * ------------------------------------------------------------ 147 * ------------------------------------------------------------
158 * Here starts the interrupt handling routines. All of the
159 * following subroutines are declared as inline and are folded
160 * into dz_interrupt. They were separated out for readability's
161 * sake.
162 * 148 *
163 * Note: rs_interrupt() is a "fast" interrupt, which means that it 149 * Here start the interrupt handling routines. All of the following
150 * subroutines are declared as inline and are folded into
151 * dz_interrupt. They were separated out for readability's sake.
152 *
153 * Note: dz_interrupt() is a "fast" interrupt, which means that it
164 * runs with interrupts turned off. People who may want to modify 154 * runs with interrupts turned off. People who may want to modify
165 * rs_interrupt() should try to keep the interrupt handler as fast as 155 * dz_interrupt() should try to keep the interrupt handler as fast as
166 * possible. After you are done making modifications, it is not a bad 156 * possible. After you are done making modifications, it is not a bad
167 * idea to do: 157 * idea to do:
168 * 158 *
@@ -180,92 +170,74 @@ static void dz_enable_ms(struct uart_port *port)
180 * This routine deals with inputs from any lines. 170 * This routine deals with inputs from any lines.
181 * ------------------------------------------------------------ 171 * ------------------------------------------------------------
182 */ 172 */
183static inline void dz_receive_chars(struct dz_port *dport) 173static inline void dz_receive_chars(struct dz_port *dport_in,
174 struct pt_regs *regs)
184{ 175{
176 struct dz_port *dport;
185 struct tty_struct *tty = NULL; 177 struct tty_struct *tty = NULL;
186 struct uart_icount *icount; 178 struct uart_icount *icount;
187 int ignore = 0; 179 int lines_rx[DZ_NB_PORT] = { [0 ... DZ_NB_PORT - 1] = 0 };
188 unsigned short status, tmp; 180 unsigned short status;
189 unsigned char ch, flag; 181 unsigned char ch, flag;
182 int i;
190 183
191 /* this code is going to be a problem... 184 while ((status = dz_in(dport_in, DZ_RBUF)) & DZ_DVAL) {
192 the call to tty_flip_buffer is going to need 185 dport = &dz_ports[LINE(status)];
193 to be rethought... 186 tty = dport->port.info->tty; /* point to the proper dev */
194 */
195 do {
196 status = dz_in(dport, DZ_RBUF);
197
198 /* punt so we don't get duplicate characters */
199 if (!(status & DZ_DVAL))
200 goto ignore_char;
201
202
203 ch = UCHAR(status); /* grab the char */
204 flag = TTY_NORMAL;
205 187
206#if 0 188 ch = UCHAR(status); /* grab the char */
207 if (info->is_console) {
208 if (ch == 0)
209 return; /* it's a break ... */
210 }
211#endif
212 189
213 tty = dport->port.info->tty;/* now tty points to the proper dev */
214 icount = &dport->port.icount; 190 icount = &dport->port.icount;
215
216 if (!tty)
217 break;
218
219 icount->rx++; 191 icount->rx++;
220 192
221 /* keep track of the statistics */ 193 flag = TTY_NORMAL;
222 if (status & (DZ_OERR | DZ_FERR | DZ_PERR)) { 194 if (status & DZ_FERR) { /* frame error */
223 if (status & DZ_PERR) /* parity error */ 195 /*
224 icount->parity++; 196 * There is no separate BREAK status bit, so
225 else if (status & DZ_FERR) /* frame error */ 197 * treat framing errors as BREAKs for Magic SysRq
226 icount->frame++; 198 * and SAK; normally, otherwise.
227 if (status & DZ_OERR) /* overrun error */
228 icount->overrun++;
229
230 /* check to see if we should ignore the character
231 and mask off conditions that should be ignored
232 */ 199 */
233 200 if (uart_handle_break(&dport->port))
234 if (status & dport->port.ignore_status_mask) { 201 continue;
235 if (++ignore > 100) 202 if (dport->port.flags & UPF_SAK)
236 break; 203 flag = TTY_BREAK;
237 goto ignore_char; 204 else
238 }
239 /* mask off the error conditions we want to ignore */
240 tmp = status & dport->port.read_status_mask;
241
242 if (tmp & DZ_PERR) {
243 flag = TTY_PARITY;
244#ifdef DEBUG_DZ
245 debug_console("PERR\n", 5);
246#endif
247 } else if (tmp & DZ_FERR) {
248 flag = TTY_FRAME; 205 flag = TTY_FRAME;
249#ifdef DEBUG_DZ 206 } else if (status & DZ_OERR) /* overrun error */
250 debug_console("FERR\n", 5); 207 flag = TTY_OVERRUN;
251#endif 208 else if (status & DZ_PERR) /* parity error */
252 } 209 flag = TTY_PARITY;
253 if (tmp & DZ_OERR) { 210
254#ifdef DEBUG_DZ 211 /* keep track of the statistics */
255 debug_console("OERR\n", 5); 212 switch (flag) {
256#endif 213 case TTY_FRAME:
257 tty_insert_flip_char(tty, ch, flag); 214 icount->frame++;
258 ch = 0; 215 break;
259 flag = TTY_OVERRUN; 216 case TTY_PARITY:
260 } 217 icount->parity++;
218 break;
219 case TTY_OVERRUN:
220 icount->overrun++;
221 break;
222 case TTY_BREAK:
223 icount->brk++;
224 break;
225 default:
226 break;
261 } 227 }
262 tty_insert_flip_char(tty, ch, flag);
263 ignore_char:
264 ;
265 } while (status & DZ_DVAL);
266 228
267 if (tty) 229 if (uart_handle_sysrq_char(&dport->port, ch, regs))
268 tty_flip_buffer_push(tty); 230 continue;
231
232 if ((status & dport->port.ignore_status_mask) == 0) {
233 uart_insert_char(&dport->port,
234 status, DZ_OERR, ch, flag);
235 lines_rx[LINE(status)] = 1;
236 }
237 }
238 for (i = 0; i < DZ_NB_PORT; i++)
239 if (lines_rx[i])
240 tty_flip_buffer_push(dz_ports[i].port.info->tty);
269} 241}
270 242
271/* 243/*
@@ -275,26 +247,32 @@ static inline void dz_receive_chars(struct dz_port *dport)
275 * This routine deals with outputs to any lines. 247 * This routine deals with outputs to any lines.
276 * ------------------------------------------------------------ 248 * ------------------------------------------------------------
277 */ 249 */
278static inline void dz_transmit_chars(struct dz_port *dport) 250static inline void dz_transmit_chars(struct dz_port *dport_in)
279{ 251{
280 struct circ_buf *xmit = &dport->port.info->xmit; 252 struct dz_port *dport;
253 struct circ_buf *xmit;
254 unsigned short status;
281 unsigned char tmp; 255 unsigned char tmp;
282 256
283 if (dport->port.x_char) { /* XON/XOFF chars */ 257 status = dz_in(dport_in, DZ_CSR);
258 dport = &dz_ports[LINE(status)];
259 xmit = &dport->port.info->xmit;
260
261 if (dport->port.x_char) { /* XON/XOFF chars */
284 dz_out(dport, DZ_TDR, dport->port.x_char); 262 dz_out(dport, DZ_TDR, dport->port.x_char);
285 dport->port.icount.tx++; 263 dport->port.icount.tx++;
286 dport->port.x_char = 0; 264 dport->port.x_char = 0;
287 return; 265 return;
288 } 266 }
289 /* if nothing to do or stopped or hardware stopped */ 267 /* If nothing to do or stopped or hardware stopped. */
290 if (uart_circ_empty(xmit) || uart_tx_stopped(&dport->port)) { 268 if (uart_circ_empty(xmit) || uart_tx_stopped(&dport->port)) {
291 dz_stop_tx(&dport->port); 269 dz_stop_tx(&dport->port);
292 return; 270 return;
293 } 271 }
294 272
295 /* 273 /*
296 * if something to do ... (rember the dz has no output fifo so we go 274 * If something to do... (remember the dz has no output fifo,
297 * one char at a time :-< 275 * so we go one char at a time) :-<
298 */ 276 */
299 tmp = xmit->buf[xmit->tail]; 277 tmp = xmit->buf[xmit->tail];
300 xmit->tail = (xmit->tail + 1) & (DZ_XMIT_SIZE - 1); 278 xmit->tail = (xmit->tail + 1) & (DZ_XMIT_SIZE - 1);
@@ -304,23 +282,29 @@ static inline void dz_transmit_chars(struct dz_port *dport)
304 if (uart_circ_chars_pending(xmit) < DZ_WAKEUP_CHARS) 282 if (uart_circ_chars_pending(xmit) < DZ_WAKEUP_CHARS)
305 uart_write_wakeup(&dport->port); 283 uart_write_wakeup(&dport->port);
306 284
307 /* Are we done */ 285 /* Are we are done. */
308 if (uart_circ_empty(xmit)) 286 if (uart_circ_empty(xmit))
309 dz_stop_tx(&dport->port); 287 dz_stop_tx(&dport->port);
310} 288}
311 289
312/* 290/*
313 * ------------------------------------------------------------ 291 * ------------------------------------------------------------
314 * check_modem_status () 292 * check_modem_status()
315 * 293 *
316 * Only valid for the MODEM line duh ! 294 * DS 3100 & 5100: Only valid for the MODEM line, duh!
295 * DS 5000/200: Valid for the MODEM and PRINTER line.
317 * ------------------------------------------------------------ 296 * ------------------------------------------------------------
318 */ 297 */
319static inline void check_modem_status(struct dz_port *dport) 298static inline void check_modem_status(struct dz_port *dport)
320{ 299{
300 /*
301 * FIXME:
302 * 1. No status change interrupt; use a timer.
303 * 2. Handle the 3100/5000 as appropriate. --macro
304 */
321 unsigned short status; 305 unsigned short status;
322 306
323 /* if not ne modem line just return */ 307 /* If not the modem line just return. */
324 if (dport->port.line != DZ_MODEM) 308 if (dport->port.line != DZ_MODEM)
325 return; 309 return;
326 310
@@ -341,21 +325,18 @@ static inline void check_modem_status(struct dz_port *dport)
341 */ 325 */
342static irqreturn_t dz_interrupt(int irq, void *dev) 326static irqreturn_t dz_interrupt(int irq, void *dev)
343{ 327{
344 struct dz_port *dport; 328 struct dz_port *dport = (struct dz_port *)dev;
345 unsigned short status; 329 unsigned short status;
346 330
347 /* get the reason why we just got an irq */ 331 /* get the reason why we just got an irq */
348 status = dz_in((struct dz_port *)dev, DZ_CSR); 332 status = dz_in(dport, DZ_CSR);
349 dport = &dz_ports[LINE(status)];
350 333
351 if (status & DZ_RDONE) 334 if ((status & (DZ_RDONE | DZ_RIE)) == (DZ_RDONE | DZ_RIE))
352 dz_receive_chars(dport); 335 dz_receive_chars(dport, regs);
353 336
354 if (status & DZ_TRDY) 337 if ((status & (DZ_TRDY | DZ_TIE)) == (DZ_TRDY | DZ_TIE))
355 dz_transmit_chars(dport); 338 dz_transmit_chars(dport);
356 339
357 /* FIXME: what about check modem status??? --rmk */
358
359 return IRQ_HANDLED; 340 return IRQ_HANDLED;
360} 341}
361 342
@@ -367,13 +348,13 @@ static irqreturn_t dz_interrupt(int irq, void *dev)
367 348
368static unsigned int dz_get_mctrl(struct uart_port *uport) 349static unsigned int dz_get_mctrl(struct uart_port *uport)
369{ 350{
351 /*
352 * FIXME: Handle the 3100/5000 as appropriate. --macro
353 */
370 struct dz_port *dport = (struct dz_port *)uport; 354 struct dz_port *dport = (struct dz_port *)uport;
371 unsigned int mctrl = TIOCM_CAR | TIOCM_DSR | TIOCM_CTS; 355 unsigned int mctrl = TIOCM_CAR | TIOCM_DSR | TIOCM_CTS;
372 356
373 if (dport->port.line == DZ_MODEM) { 357 if (dport->port.line == DZ_MODEM) {
374 /*
375 * CHECKME: This is a guess from the other code... --rmk
376 */
377 if (dz_in(dport, DZ_MSR) & DZ_MODEM_DSR) 358 if (dz_in(dport, DZ_MSR) & DZ_MODEM_DSR)
378 mctrl &= ~TIOCM_DSR; 359 mctrl &= ~TIOCM_DSR;
379 } 360 }
@@ -383,6 +364,9 @@ static unsigned int dz_get_mctrl(struct uart_port *uport)
383 364
384static void dz_set_mctrl(struct uart_port *uport, unsigned int mctrl) 365static void dz_set_mctrl(struct uart_port *uport, unsigned int mctrl)
385{ 366{
367 /*
368 * FIXME: Handle the 3100/5000 as appropriate. --macro
369 */
386 struct dz_port *dport = (struct dz_port *)uport; 370 struct dz_port *dport = (struct dz_port *)uport;
387 unsigned short tmp; 371 unsigned short tmp;
388 372
@@ -409,13 +393,6 @@ static int dz_startup(struct uart_port *uport)
409 unsigned long flags; 393 unsigned long flags;
410 unsigned short tmp; 394 unsigned short tmp;
411 395
412 /* The dz lines for the mouse/keyboard must be
413 * opened using their respective drivers.
414 */
415 if ((dport->port.line == DZ_KEYBOARD) ||
416 (dport->port.line == DZ_MOUSE))
417 return -ENODEV;
418
419 spin_lock_irqsave(&dport->port.lock, flags); 396 spin_lock_irqsave(&dport->port.lock, flags);
420 397
421 /* enable the interrupt and the scanning */ 398 /* enable the interrupt and the scanning */
@@ -442,7 +419,8 @@ static void dz_shutdown(struct uart_port *uport)
442} 419}
443 420
444/* 421/*
445 * get_lsr_info - get line status register info 422 * -------------------------------------------------------------------
423 * dz_tx_empty() -- get the transmitter empty status
446 * 424 *
447 * Purpose: Let user call ioctl() to get info when the UART physically 425 * Purpose: Let user call ioctl() to get info when the UART physically
448 * is emptied. On bus types like RS485, the transmitter must 426 * is emptied. On bus types like RS485, the transmitter must
@@ -450,21 +428,28 @@ static void dz_shutdown(struct uart_port *uport)
450 * the transmit shift register is empty, not be done when the 428 * the transmit shift register is empty, not be done when the
451 * transmit holding register is empty. This functionality 429 * transmit holding register is empty. This functionality
452 * allows an RS485 driver to be written in user space. 430 * allows an RS485 driver to be written in user space.
431 * -------------------------------------------------------------------
453 */ 432 */
454static unsigned int dz_tx_empty(struct uart_port *uport) 433static unsigned int dz_tx_empty(struct uart_port *uport)
455{ 434{
456 struct dz_port *dport = (struct dz_port *)uport; 435 struct dz_port *dport = (struct dz_port *)uport;
457 unsigned short status = dz_in(dport, DZ_LPR); 436 unsigned short tmp, mask = 1 << dport->port.line;
458 437
459 /* FIXME: this appears to be obviously broken --rmk. */ 438 tmp = dz_in(dport, DZ_TCR);
460 return status ? TIOCSER_TEMT : 0; 439 tmp &= mask;
440
441 return tmp ? 0 : TIOCSER_TEMT;
461} 442}
462 443
463static void dz_break_ctl(struct uart_port *uport, int break_state) 444static void dz_break_ctl(struct uart_port *uport, int break_state)
464{ 445{
446 /*
447 * FIXME: Can't access BREAK bits in TDR easily;
448 * reuse the code for polled TX. --macro
449 */
465 struct dz_port *dport = (struct dz_port *)uport; 450 struct dz_port *dport = (struct dz_port *)uport;
466 unsigned long flags; 451 unsigned long flags;
467 unsigned short tmp, mask = 1 << uport->line; 452 unsigned short tmp, mask = 1 << dport->port.line;
468 453
469 spin_lock_irqsave(&uport->lock, flags); 454 spin_lock_irqsave(&uport->lock, flags);
470 tmp = dz_in(dport, DZ_TCR); 455 tmp = dz_in(dport, DZ_TCR);
@@ -561,7 +546,7 @@ static void dz_set_termios(struct uart_port *uport, struct termios *termios,
561 546
562 spin_lock_irqsave(&dport->port.lock, flags); 547 spin_lock_irqsave(&dport->port.lock, flags);
563 548
564 dz_out(dport, DZ_LPR, cflag); 549 dz_out(dport, DZ_LPR, cflag | dport->port.line);
565 dport->cflag = cflag; 550 dport->cflag = cflag;
566 551
567 /* setup accept flag */ 552 /* setup accept flag */
@@ -650,7 +635,7 @@ static void __init dz_init_ports(void)
650 for (i = 0, dport = dz_ports; i < DZ_NB_PORT; i++, dport++) { 635 for (i = 0, dport = dz_ports; i < DZ_NB_PORT; i++, dport++) {
651 spin_lock_init(&dport->port.lock); 636 spin_lock_init(&dport->port.lock);
652 dport->port.membase = (char *) base; 637 dport->port.membase = (char *) base;
653 dport->port.iotype = UPIO_PORT; 638 dport->port.iotype = UPIO_MEM;
654 dport->port.irq = dec_interrupt[DEC_IRQ_DZ11]; 639 dport->port.irq = dec_interrupt[DEC_IRQ_DZ11];
655 dport->port.line = i; 640 dport->port.line = i;
656 dport->port.fifosize = 1; 641 dport->port.fifosize = 1;
@@ -662,10 +647,7 @@ static void __init dz_init_ports(void)
662static void dz_reset(struct dz_port *dport) 647static void dz_reset(struct dz_port *dport)
663{ 648{
664 dz_out(dport, DZ_CSR, DZ_CLR); 649 dz_out(dport, DZ_CSR, DZ_CLR);
665
666 while (dz_in(dport, DZ_CSR) & DZ_CLR); 650 while (dz_in(dport, DZ_CSR) & DZ_CLR);
667 /* FIXME: cpu_relax? */
668
669 iob(); 651 iob();
670 652
671 /* enable scanning */ 653 /* enable scanning */
@@ -673,26 +655,55 @@ static void dz_reset(struct dz_port *dport)
673} 655}
674 656
675#ifdef CONFIG_SERIAL_DZ_CONSOLE 657#ifdef CONFIG_SERIAL_DZ_CONSOLE
658/*
659 * -------------------------------------------------------------------
660 * dz_console_putchar() -- transmit a character
661 *
662 * Polled transmission. This is tricky. We need to mask transmit
663 * interrupts so that they do not interfere, enable the transmitter
664 * for the line requested and then wait till the transmit scanner
665 * requests data for this line. But it may request data for another
666 * line first, in which case we have to disable its transmitter and
667 * repeat waiting till our line pops up. Only then the character may
668 * be transmitted. Finally, the state of the transmitter mask is
669 * restored. Welcome to the world of PDP-11!
670 * -------------------------------------------------------------------
671 */
676static void dz_console_putchar(struct uart_port *uport, int ch) 672static void dz_console_putchar(struct uart_port *uport, int ch)
677{ 673{
678 struct dz_port *dport = (struct dz_port *)uport; 674 struct dz_port *dport = (struct dz_port *)uport;
679 unsigned long flags; 675 unsigned long flags;
680 int loops = 2500; 676 unsigned short csr, tcr, trdy, mask;
681 unsigned short tmp = (unsigned char)ch; 677 int loops = 10000;
682 /* this code sends stuff out to serial device - spinning its
683 wheels and waiting. */
684 678
685 spin_lock_irqsave(&dport->port.lock, flags); 679 spin_lock_irqsave(&dport->port.lock, flags);
680 csr = dz_in(dport, DZ_CSR);
681 dz_out(dport, DZ_CSR, csr & ~DZ_TIE);
682 tcr = dz_in(dport, DZ_TCR);
683 tcr |= 1 << dport->port.line;
684 mask = tcr;
685 dz_out(dport, DZ_TCR, mask);
686 iob();
687 spin_unlock_irqrestore(&dport->port.lock, flags);
686 688
687 /* spin our wheels */ 689 while (loops--) {
688 while (((dz_in(dport, DZ_CSR) & DZ_TRDY) != DZ_TRDY) && loops--) 690 trdy = dz_in(dport, DZ_CSR);
689 /* FIXME: cpu_relax, udelay? --rmk */ 691 if (!(trdy & DZ_TRDY))
690 ; 692 continue;
693 trdy = (trdy & DZ_TLINE) >> 8;
694 if (trdy == dport->port.line)
695 break;
696 mask &= ~(1 << trdy);
697 dz_out(dport, DZ_TCR, mask);
698 iob();
699 udelay(2);
700 }
691 701
692 /* Actually transmit the character. */ 702 if (loops) /* Cannot send otherwise. */
693 dz_out(dport, DZ_TDR, tmp); 703 dz_out(dport, DZ_TDR, ch);
694 704
695 spin_unlock_irqrestore(&dport->port.lock, flags); 705 dz_out(dport, DZ_TCR, tcr);
706 dz_out(dport, DZ_CSR, csr);
696} 707}
697 708
698/* 709/*
@@ -703,11 +714,11 @@ static void dz_console_putchar(struct uart_port *uport, int ch)
703 * The console must be locked when we get here. 714 * The console must be locked when we get here.
704 * ------------------------------------------------------------------- 715 * -------------------------------------------------------------------
705 */ 716 */
706static void dz_console_print(struct console *cons, 717static void dz_console_print(struct console *co,
707 const char *str, 718 const char *str,
708 unsigned int count) 719 unsigned int count)
709{ 720{
710 struct dz_port *dport = &dz_ports[CONSOLE_LINE]; 721 struct dz_port *dport = &dz_ports[co->index];
711#ifdef DEBUG_DZ 722#ifdef DEBUG_DZ
712 prom_printf((char *) str); 723 prom_printf((char *) str);
713#endif 724#endif
@@ -716,49 +727,43 @@ static void dz_console_print(struct console *cons,
716 727
717static int __init dz_console_setup(struct console *co, char *options) 728static int __init dz_console_setup(struct console *co, char *options)
718{ 729{
719 struct dz_port *dport = &dz_ports[CONSOLE_LINE]; 730 struct dz_port *dport = &dz_ports[co->index];
720 int baud = 9600; 731 int baud = 9600;
721 int bits = 8; 732 int bits = 8;
722 int parity = 'n'; 733 int parity = 'n';
723 int flow = 'n'; 734 int flow = 'n';
724 int ret;
725 unsigned short mask, tmp;
726 735
727 if (options) 736 if (options)
728 uart_parse_options(options, &baud, &parity, &bits, &flow); 737 uart_parse_options(options, &baud, &parity, &bits, &flow);
729 738
730 dz_reset(dport); 739 dz_reset(dport);
731 740
732 ret = uart_set_options(&dport->port, co, baud, parity, bits, flow); 741 return uart_set_options(&dport->port, co, baud, parity, bits, flow);
733 if (ret == 0) {
734 mask = 1 << dport->port.line;
735 tmp = dz_in(dport, DZ_TCR); /* read the TX flag */
736 if (!(tmp & mask)) {
737 tmp |= mask; /* set the TX flag */
738 dz_out(dport, DZ_TCR, tmp);
739 }
740 }
741
742 return ret;
743} 742}
744 743
745static struct console dz_sercons = 744static struct uart_driver dz_reg;
746{ 745static struct console dz_sercons = {
747 .name = "ttyS", 746 .name = "ttyS",
748 .write = dz_console_print, 747 .write = dz_console_print,
749 .device = uart_console_device, 748 .device = uart_console_device,
750 .setup = dz_console_setup, 749 .setup = dz_console_setup,
751 .flags = CON_CONSDEV | CON_PRINTBUFFER, 750 .flags = CON_PRINTBUFFER,
752 .index = CONSOLE_LINE, 751 .index = -1,
752 .data = &dz_reg,
753}; 753};
754 754
755void __init dz_serial_console_init(void) 755static int __init dz_serial_console_init(void)
756{ 756{
757 dz_init_ports(); 757 if (!IOASIC) {
758 758 dz_init_ports();
759 register_console(&dz_sercons); 759 register_console(&dz_sercons);
760 return 0;
761 } else
762 return -ENXIO;
760} 763}
761 764
765console_initcall(dz_serial_console_init);
766
762#define SERIAL_DZ_CONSOLE &dz_sercons 767#define SERIAL_DZ_CONSOLE &dz_sercons
763#else 768#else
764#define SERIAL_DZ_CONSOLE NULL 769#define SERIAL_DZ_CONSOLE NULL
@@ -767,35 +772,29 @@ void __init dz_serial_console_init(void)
767static struct uart_driver dz_reg = { 772static struct uart_driver dz_reg = {
768 .owner = THIS_MODULE, 773 .owner = THIS_MODULE,
769 .driver_name = "serial", 774 .driver_name = "serial",
770 .dev_name = "ttyS%d", 775 .dev_name = "ttyS",
771 .major = TTY_MAJOR, 776 .major = TTY_MAJOR,
772 .minor = 64, 777 .minor = 64,
773 .nr = DZ_NB_PORT, 778 .nr = DZ_NB_PORT,
774 .cons = SERIAL_DZ_CONSOLE, 779 .cons = SERIAL_DZ_CONSOLE,
775}; 780};
776 781
777int __init dz_init(void) 782static int __init dz_init(void)
778{ 783{
779 unsigned long flags;
780 int ret, i; 784 int ret, i;
781 785
786 if (IOASIC)
787 return -ENXIO;
788
782 printk("%s%s\n", dz_name, dz_version); 789 printk("%s%s\n", dz_name, dz_version);
783 790
784 dz_init_ports(); 791 dz_init_ports();
785 792
786 save_flags(flags);
787 cli();
788
789#ifndef CONFIG_SERIAL_DZ_CONSOLE 793#ifndef CONFIG_SERIAL_DZ_CONSOLE
790 /* reset the chip */ 794 /* reset the chip */
791 dz_reset(&dz_ports[0]); 795 dz_reset(&dz_ports[0]);
792#endif 796#endif
793 797
794 /* order matters here... the trick is that flags
795 is updated... in request_irq - to immediatedly obliterate
796 it is unwise. */
797 restore_flags(flags);
798
799 if (request_irq(dz_ports[0].port.irq, dz_interrupt, 798 if (request_irq(dz_ports[0].port.irq, dz_interrupt,
800 IRQF_DISABLED, "DZ", &dz_ports[0])) 799 IRQF_DISABLED, "DZ", &dz_ports[0]))
801 panic("Unable to register DZ interrupt"); 800 panic("Unable to register DZ interrupt");
@@ -810,5 +809,7 @@ int __init dz_init(void)
810 return ret; 809 return ret;
811} 810}
812 811
812module_init(dz_init);
813
813MODULE_DESCRIPTION("DECstation DZ serial driver"); 814MODULE_DESCRIPTION("DECstation DZ serial driver");
814MODULE_LICENSE("GPL"); 815MODULE_LICENSE("GPL");
diff --git a/drivers/serial/dz.h b/drivers/serial/dz.h
index 86ef417382bb..9674d4e49872 100644
--- a/drivers/serial/dz.h
+++ b/drivers/serial/dz.h
@@ -1,20 +1,22 @@
1/* 1/*
2 * dz.h: Serial port driver for DECStations equiped 2 * dz.h: Serial port driver for DECstations equipped
3 * with the DZ chipset. 3 * with the DZ chipset.
4 * 4 *
5 * Copyright (C) 1998 Olivier A. D. Lebaillif 5 * Copyright (C) 1998 Olivier A. D. Lebaillif
6 * 6 *
7 * Email: olivier.lebaillif@ifrsys.com 7 * Email: olivier.lebaillif@ifrsys.com
8 * 8 *
9 * Copyright (C) 2004, 2006 Maciej W. Rozycki
9 */ 10 */
10#ifndef DZ_SERIAL_H 11#ifndef DZ_SERIAL_H
11#define DZ_SERIAL_H 12#define DZ_SERIAL_H
12 13
13/* 14/*
14 * Definitions for the Control and Status Received. 15 * Definitions for the Control and Status Register.
15 */ 16 */
16#define DZ_TRDY 0x8000 /* Transmitter empty */ 17#define DZ_TRDY 0x8000 /* Transmitter empty */
17#define DZ_TIE 0x4000 /* Transmitter Interrupt Enable */ 18#define DZ_TIE 0x4000 /* Transmitter Interrupt Enbl */
19#define DZ_TLINE 0x0300 /* Transmitter Line Number */
18#define DZ_RDONE 0x0080 /* Receiver data ready */ 20#define DZ_RDONE 0x0080 /* Receiver data ready */
19#define DZ_RIE 0x0040 /* Receive Interrupt Enable */ 21#define DZ_RIE 0x0040 /* Receive Interrupt Enable */
20#define DZ_MSE 0x0020 /* Master Scan Enable */ 22#define DZ_MSE 0x0020 /* Master Scan Enable */
@@ -22,32 +24,44 @@
22#define DZ_MAINT 0x0008 /* Loop Back Mode */ 24#define DZ_MAINT 0x0008 /* Loop Back Mode */
23 25
24/* 26/*
25 * Definitions for the Received buffer. 27 * Definitions for the Receiver Buffer Register.
26 */ 28 */
27#define DZ_RBUF_MASK 0x00FF /* Data Mask in the Receive Buffer */ 29#define DZ_RBUF_MASK 0x00FF /* Data Mask */
28#define DZ_LINE_MASK 0x0300 /* Line Mask in the Receive Buffer */ 30#define DZ_LINE_MASK 0x0300 /* Line Mask */
29#define DZ_DVAL 0x8000 /* Valid Data indicator */ 31#define DZ_DVAL 0x8000 /* Valid Data indicator */
30#define DZ_OERR 0x4000 /* Overrun error indicator */ 32#define DZ_OERR 0x4000 /* Overrun error indicator */
31#define DZ_FERR 0x2000 /* Frame error indicator */ 33#define DZ_FERR 0x2000 /* Frame error indicator */
32#define DZ_PERR 0x1000 /* Parity error indicator */ 34#define DZ_PERR 0x1000 /* Parity error indicator */
33 35
34#define LINE(x) (x & DZ_LINE_MASK) >> 8 /* Get the line number from the input buffer */ 36#define LINE(x) ((x & DZ_LINE_MASK) >> 8) /* Get the line number
35#define UCHAR(x) (unsigned char)(x & DZ_RBUF_MASK) 37 from the input buffer */
38#define UCHAR(x) ((unsigned char)(x & DZ_RBUF_MASK))
36 39
37/* 40/*
38 * Definitions for the Transmit Register. 41 * Definitions for the Transmit Control Register.
39 */ 42 */
40#define DZ_LINE_KEYBOARD 0x0001 43#define DZ_LINE_KEYBOARD 0x0001
41#define DZ_LINE_MOUSE 0x0002 44#define DZ_LINE_MOUSE 0x0002
42#define DZ_LINE_MODEM 0x0004 45#define DZ_LINE_MODEM 0x0004
43#define DZ_LINE_PRINTER 0x0008 46#define DZ_LINE_PRINTER 0x0008
44 47
48#define DZ_MODEM_RTS 0x0800 /* RTS for the modem line (2) */
45#define DZ_MODEM_DTR 0x0400 /* DTR for the modem line (2) */ 49#define DZ_MODEM_DTR 0x0400 /* DTR for the modem line (2) */
50#define DZ_PRINT_RTS 0x0200 /* RTS for the prntr line (3) */
51#define DZ_PRINT_DTR 0x0100 /* DTR for the prntr line (3) */
52#define DZ_LNENB 0x000f /* Transmitter Line Enable */
46 53
47/* 54/*
48 * Definitions for the Modem Status Register. 55 * Definitions for the Modem Status Register.
49 */ 56 */
57#define DZ_MODEM_RI 0x0800 /* RI for the modem line (2) */
58#define DZ_MODEM_CD 0x0400 /* CD for the modem line (2) */
50#define DZ_MODEM_DSR 0x0200 /* DSR for the modem line (2) */ 59#define DZ_MODEM_DSR 0x0200 /* DSR for the modem line (2) */
60#define DZ_MODEM_CTS 0x0100 /* CTS for the modem line (2) */
61#define DZ_PRINT_RI 0x0008 /* RI for the printer line (3) */
62#define DZ_PRINT_CD 0x0004 /* CD for the printer line (3) */
63#define DZ_PRINT_DSR 0x0002 /* DSR for the prntr line (3) */
64#define DZ_PRINT_CTS 0x0001 /* CTS for the prntr line (3) */
51 65
52/* 66/*
53 * Definitions for the Transmit Data Register. 67 * Definitions for the Transmit Data Register.
diff --git a/drivers/serial/mcfserial.c b/drivers/serial/mcfserial.c
index aee1b31f1a1c..3db206d29b33 100644
--- a/drivers/serial/mcfserial.c
+++ b/drivers/serial/mcfserial.c
@@ -60,7 +60,8 @@ struct timer_list mcfrs_timer_struct;
60#if defined(CONFIG_HW_FEITH) 60#if defined(CONFIG_HW_FEITH)
61#define CONSOLE_BAUD_RATE 38400 61#define CONSOLE_BAUD_RATE 38400
62#define DEFAULT_CBAUD B38400 62#define DEFAULT_CBAUD B38400
63#elif defined(CONFIG_MOD5272) || defined(CONFIG_M5208EVB) || defined(CONFIG_M5329EVB) 63#elif defined(CONFIG_MOD5272) || defined(CONFIG_M5208EVB) || \
64 defined(CONFIG_M5329EVB) || defined(CONFIG_GILBARCO)
64#define CONSOLE_BAUD_RATE 115200 65#define CONSOLE_BAUD_RATE 115200
65#define DEFAULT_CBAUD B115200 66#define DEFAULT_CBAUD B115200
66#elif defined(CONFIG_ARNEWSH) || defined(CONFIG_FREESCALE) || \ 67#elif defined(CONFIG_ARNEWSH) || defined(CONFIG_FREESCALE) || \
@@ -109,12 +110,30 @@ static struct mcf_serial mcfrs_table[] = {
109 .irq = IRQBASE, 110 .irq = IRQBASE,
110 .flags = ASYNC_BOOT_AUTOCONF, 111 .flags = ASYNC_BOOT_AUTOCONF,
111 }, 112 },
113#ifdef MCFUART_BASE2
112 { /* ttyS1 */ 114 { /* ttyS1 */
113 .magic = 0, 115 .magic = 0,
114 .addr = (volatile unsigned char *) (MCF_MBAR+MCFUART_BASE2), 116 .addr = (volatile unsigned char *) (MCF_MBAR+MCFUART_BASE2),
115 .irq = IRQBASE+1, 117 .irq = IRQBASE+1,
116 .flags = ASYNC_BOOT_AUTOCONF, 118 .flags = ASYNC_BOOT_AUTOCONF,
117 }, 119 },
120#endif
121#ifdef MCFUART_BASE3
122 { /* ttyS2 */
123 .magic = 0,
124 .addr = (volatile unsigned char *) (MCF_MBAR+MCFUART_BASE3),
125 .irq = IRQBASE+2,
126 .flags = ASYNC_BOOT_AUTOCONF,
127 },
128#endif
129#ifdef MCFUART_BASE4
130 { /* ttyS3 */
131 .magic = 0,
132 .addr = (volatile unsigned char *) (MCF_MBAR+MCFUART_BASE4),
133 .irq = IRQBASE+3,
134 .flags = ASYNC_BOOT_AUTOCONF,
135 },
136#endif
118}; 137};
119 138
120 139
@@ -1516,6 +1535,22 @@ static void mcfrs_irqinit(struct mcf_serial *info)
1516 imrp = (volatile unsigned long *) (MCF_MBAR + MCFICM_INTC0 + 1535 imrp = (volatile unsigned long *) (MCF_MBAR + MCFICM_INTC0 +
1517 MCFINTC_IMRL); 1536 MCFINTC_IMRL);
1518 *imrp &= ~((1 << (info->irq - MCFINT_VECBASE)) | 1); 1537 *imrp &= ~((1 << (info->irq - MCFINT_VECBASE)) | 1);
1538#if defined(CONFIG_M527x)
1539 {
1540 /*
1541 * External Pin Mask Setting & Enable External Pin for Interface
1542 * mrcbis@aliceposta.it
1543 */
1544 unsigned short *serpin_enable_mask;
1545 serpin_enable_mask = (MCF_IPSBAR + MCF_GPIO_PAR_UART);
1546 if (info->line == 0)
1547 *serpin_enable_mask |= UART0_ENABLE_MASK;
1548 else if (info->line == 1)
1549 *serpin_enable_mask |= UART1_ENABLE_MASK;
1550 else if (info->line == 2)
1551 *serpin_enable_mask |= UART2_ENABLE_MASK;
1552 }
1553#endif
1519#elif defined(CONFIG_M520x) 1554#elif defined(CONFIG_M520x)
1520 volatile unsigned char *icrp, *uartp; 1555 volatile unsigned char *icrp, *uartp;
1521 volatile unsigned long *imrp; 1556 volatile unsigned long *imrp;
@@ -1713,7 +1748,7 @@ mcfrs_init(void)
1713 /* Initialize the tty_driver structure */ 1748 /* Initialize the tty_driver structure */
1714 mcfrs_serial_driver->owner = THIS_MODULE; 1749 mcfrs_serial_driver->owner = THIS_MODULE;
1715 mcfrs_serial_driver->name = "ttyS"; 1750 mcfrs_serial_driver->name = "ttyS";
1716 mcfrs_serial_driver->driver_name = "serial"; 1751 mcfrs_serial_driver->driver_name = "mcfserial";
1717 mcfrs_serial_driver->major = TTY_MAJOR; 1752 mcfrs_serial_driver->major = TTY_MAJOR;
1718 mcfrs_serial_driver->minor_start = 64; 1753 mcfrs_serial_driver->minor_start = 64;
1719 mcfrs_serial_driver->type = TTY_DRIVER_TYPE_SERIAL; 1754 mcfrs_serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
@@ -1797,10 +1832,23 @@ void mcfrs_init_console(void)
1797 uartp[MCFUART_UMR] = MCFUART_MR1_PARITYNONE | MCFUART_MR1_CS8; 1832 uartp[MCFUART_UMR] = MCFUART_MR1_PARITYNONE | MCFUART_MR1_CS8;
1798 uartp[MCFUART_UMR] = MCFUART_MR2_STOP1; 1833 uartp[MCFUART_UMR] = MCFUART_MR2_STOP1;
1799 1834
1835#ifdef CONFIG_M5272
1836{
1837 /*
1838 * For the MCF5272, also compute the baudrate fraction.
1839 */
1840 int fraction = MCF_BUSCLK - (clk * 32 * mcfrs_console_baud);
1841 fraction *= 16;
1842 fraction /= (32 * mcfrs_console_baud);
1843 uartp[MCFUART_UFPD] = (fraction & 0xf); /* set fraction */
1844 clk = (MCF_BUSCLK / mcfrs_console_baud) / 32;
1845}
1846#else
1800 clk = ((MCF_BUSCLK / mcfrs_console_baud) + 16) / 32; /* set baud */ 1847 clk = ((MCF_BUSCLK / mcfrs_console_baud) + 16) / 32; /* set baud */
1848#endif
1849
1801 uartp[MCFUART_UBG1] = (clk & 0xff00) >> 8; /* set msb baud */ 1850 uartp[MCFUART_UBG1] = (clk & 0xff00) >> 8; /* set msb baud */
1802 uartp[MCFUART_UBG2] = (clk & 0xff); /* set lsb baud */ 1851 uartp[MCFUART_UBG2] = (clk & 0xff); /* set lsb baud */
1803
1804 uartp[MCFUART_UCSR] = MCFUART_UCSR_RXCLKTIMER | MCFUART_UCSR_TXCLKTIMER; 1852 uartp[MCFUART_UCSR] = MCFUART_UCSR_RXCLKTIMER | MCFUART_UCSR_TXCLKTIMER;
1805 uartp[MCFUART_UCR] = MCFUART_UCR_RXENABLE | MCFUART_UCR_TXENABLE; 1853 uartp[MCFUART_UCR] = MCFUART_UCR_RXENABLE | MCFUART_UCR_TXENABLE;
1806 1854
diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c
index 4f80c5b4a753..6dd579ed9777 100644
--- a/drivers/serial/mpc52xx_uart.c
+++ b/drivers/serial/mpc52xx_uart.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * drivers/serial/mpc52xx_uart.c
3 *
4 * Driver for the PSC of the Freescale MPC52xx PSCs configured as UARTs. 2 * Driver for the PSC of the Freescale MPC52xx PSCs configured as UARTs.
5 * 3 *
6 * FIXME According to the usermanual the status bits in the status register 4 * FIXME According to the usermanual the status bits in the status register
@@ -14,18 +12,20 @@
14 * 12 *
15 * 13 *
16 * Maintainer : Sylvain Munaut <tnt@246tNt.com> 14 * Maintainer : Sylvain Munaut <tnt@246tNt.com>
17 * 15 *
18 * Some of the code has been inspired/copied from the 2.4 code written 16 * Some of the code has been inspired/copied from the 2.4 code written
19 * by Dale Farnsworth <dfarnsworth@mvista.com>. 17 * by Dale Farnsworth <dfarnsworth@mvista.com>.
20 * 18 *
21 * Copyright (C) 2004-2005 Sylvain Munaut <tnt@246tNt.com> 19 * Copyright (C) 2006 Secret Lab Technologies Ltd.
20 * Grant Likely <grant.likely@secretlab.ca>
21 * Copyright (C) 2004-2006 Sylvain Munaut <tnt@246tNt.com>
22 * Copyright (C) 2003 MontaVista, Software, Inc. 22 * Copyright (C) 2003 MontaVista, Software, Inc.
23 * 23 *
24 * This file is licensed under the terms of the GNU General Public License 24 * This file is licensed under the terms of the GNU General Public License
25 * version 2. This program is licensed "as is" without any warranty of any 25 * version 2. This program is licensed "as is" without any warranty of any
26 * kind, whether express or implied. 26 * kind, whether express or implied.
27 */ 27 */
28 28
29/* Platform device Usage : 29/* Platform device Usage :
30 * 30 *
31 * Since PSCs can have multiple function, the correct driver for each one 31 * Since PSCs can have multiple function, the correct driver for each one
@@ -44,7 +44,24 @@
44 * will be mapped to. 44 * will be mapped to.
45 */ 45 */
46 46
47#include <linux/platform_device.h> 47/* OF Platform device Usage :
48 *
49 * This driver is only used for PSCs configured in uart mode. The device
50 * tree will have a node for each PSC in uart mode w/ device_type = "serial"
51 * and "mpc52xx-psc-uart" in the compatible string
52 *
53 * By default, PSC devices are enumerated in the order they are found. However
54 * a particular PSC number can be forces by adding 'device_no = <port#>'
55 * to the device node.
56 *
57 * The driver init all necessary registers to place the PSC in uart mode without
58 * DCD. However, the pin multiplexing aren't changed and should be set either
59 * by the bootloader or in the platform init code.
60 */
61
62#undef DEBUG
63
64#include <linux/device.h>
48#include <linux/module.h> 65#include <linux/module.h>
49#include <linux/tty.h> 66#include <linux/tty.h>
50#include <linux/serial.h> 67#include <linux/serial.h>
@@ -54,6 +71,12 @@
54#include <asm/delay.h> 71#include <asm/delay.h>
55#include <asm/io.h> 72#include <asm/io.h>
56 73
74#if defined(CONFIG_PPC_MERGE)
75#include <asm/of_platform.h>
76#else
77#include <linux/platform_device.h>
78#endif
79
57#include <asm/mpc52xx.h> 80#include <asm/mpc52xx.h>
58#include <asm/mpc52xx_psc.h> 81#include <asm/mpc52xx_psc.h>
59 82
@@ -80,6 +103,12 @@ static struct uart_port mpc52xx_uart_ports[MPC52xx_PSC_MAXNUM];
80 * it's cleared, then a memset(...,0,...) should be added to 103 * it's cleared, then a memset(...,0,...) should be added to
81 * the console_init 104 * the console_init
82 */ 105 */
106#if defined(CONFIG_PPC_MERGE)
107/* lookup table for matching device nodes to index numbers */
108static struct device_node *mpc52xx_uart_nodes[MPC52xx_PSC_MAXNUM];
109
110static void mpc52xx_uart_of_enumerate(void);
111#endif
83 112
84#define PSC(port) ((struct mpc52xx_psc __iomem *)((port)->membase)) 113#define PSC(port) ((struct mpc52xx_psc __iomem *)((port)->membase))
85 114
@@ -96,32 +125,40 @@ static irqreturn_t mpc52xx_uart_int(int irq,void *dev_id);
96#define uart_console(port) (0) 125#define uart_console(port) (0)
97#endif 126#endif
98 127
128#if defined(CONFIG_PPC_MERGE)
129static struct of_device_id mpc52xx_uart_of_match[] = {
130 { .type = "serial", .compatible = "mpc52xx-psc-uart", },
131 { .type = "serial", .compatible = "mpc5200-psc", }, /* Efika only! */
132 {},
133};
134#endif
135
99 136
100/* ======================================================================== */ 137/* ======================================================================== */
101/* UART operations */ 138/* UART operations */
102/* ======================================================================== */ 139/* ======================================================================== */
103 140
104static unsigned int 141static unsigned int
105mpc52xx_uart_tx_empty(struct uart_port *port) 142mpc52xx_uart_tx_empty(struct uart_port *port)
106{ 143{
107 int status = in_be16(&PSC(port)->mpc52xx_psc_status); 144 int status = in_be16(&PSC(port)->mpc52xx_psc_status);
108 return (status & MPC52xx_PSC_SR_TXEMP) ? TIOCSER_TEMT : 0; 145 return (status & MPC52xx_PSC_SR_TXEMP) ? TIOCSER_TEMT : 0;
109} 146}
110 147
111static void 148static void
112mpc52xx_uart_set_mctrl(struct uart_port *port, unsigned int mctrl) 149mpc52xx_uart_set_mctrl(struct uart_port *port, unsigned int mctrl)
113{ 150{
114 /* Not implemented */ 151 /* Not implemented */
115} 152}
116 153
117static unsigned int 154static unsigned int
118mpc52xx_uart_get_mctrl(struct uart_port *port) 155mpc52xx_uart_get_mctrl(struct uart_port *port)
119{ 156{
120 /* Not implemented */ 157 /* Not implemented */
121 return TIOCM_CTS | TIOCM_DSR | TIOCM_CAR; 158 return TIOCM_CTS | TIOCM_DSR | TIOCM_CAR;
122} 159}
123 160
124static void 161static void
125mpc52xx_uart_stop_tx(struct uart_port *port) 162mpc52xx_uart_stop_tx(struct uart_port *port)
126{ 163{
127 /* port->lock taken by caller */ 164 /* port->lock taken by caller */
@@ -129,7 +166,7 @@ mpc52xx_uart_stop_tx(struct uart_port *port)
129 out_be16(&PSC(port)->mpc52xx_psc_imr,port->read_status_mask); 166 out_be16(&PSC(port)->mpc52xx_psc_imr,port->read_status_mask);
130} 167}
131 168
132static void 169static void
133mpc52xx_uart_start_tx(struct uart_port *port) 170mpc52xx_uart_start_tx(struct uart_port *port)
134{ 171{
135 /* port->lock taken by caller */ 172 /* port->lock taken by caller */
@@ -137,12 +174,12 @@ mpc52xx_uart_start_tx(struct uart_port *port)
137 out_be16(&PSC(port)->mpc52xx_psc_imr,port->read_status_mask); 174 out_be16(&PSC(port)->mpc52xx_psc_imr,port->read_status_mask);
138} 175}
139 176
140static void 177static void
141mpc52xx_uart_send_xchar(struct uart_port *port, char ch) 178mpc52xx_uart_send_xchar(struct uart_port *port, char ch)
142{ 179{
143 unsigned long flags; 180 unsigned long flags;
144 spin_lock_irqsave(&port->lock, flags); 181 spin_lock_irqsave(&port->lock, flags);
145 182
146 port->x_char = ch; 183 port->x_char = ch;
147 if (ch) { 184 if (ch) {
148 /* Make sure tx interrupts are on */ 185 /* Make sure tx interrupts are on */
@@ -150,7 +187,7 @@ mpc52xx_uart_send_xchar(struct uart_port *port, char ch)
150 port->read_status_mask |= MPC52xx_PSC_IMR_TXRDY; 187 port->read_status_mask |= MPC52xx_PSC_IMR_TXRDY;
151 out_be16(&PSC(port)->mpc52xx_psc_imr,port->read_status_mask); 188 out_be16(&PSC(port)->mpc52xx_psc_imr,port->read_status_mask);
152 } 189 }
153 190
154 spin_unlock_irqrestore(&port->lock, flags); 191 spin_unlock_irqrestore(&port->lock, flags);
155} 192}
156 193
@@ -178,7 +215,7 @@ mpc52xx_uart_break_ctl(struct uart_port *port, int ctl)
178 out_8(&PSC(port)->command,MPC52xx_PSC_START_BRK); 215 out_8(&PSC(port)->command,MPC52xx_PSC_START_BRK);
179 else 216 else
180 out_8(&PSC(port)->command,MPC52xx_PSC_STOP_BRK); 217 out_8(&PSC(port)->command,MPC52xx_PSC_STOP_BRK);
181 218
182 spin_unlock_irqrestore(&port->lock, flags); 219 spin_unlock_irqrestore(&port->lock, flags);
183} 220}
184 221
@@ -197,11 +234,11 @@ mpc52xx_uart_startup(struct uart_port *port)
197 /* Reset/activate the port, clear and enable interrupts */ 234 /* Reset/activate the port, clear and enable interrupts */
198 out_8(&psc->command,MPC52xx_PSC_RST_RX); 235 out_8(&psc->command,MPC52xx_PSC_RST_RX);
199 out_8(&psc->command,MPC52xx_PSC_RST_TX); 236 out_8(&psc->command,MPC52xx_PSC_RST_TX);
200 237
201 out_be32(&psc->sicr,0); /* UART mode DCD ignored */ 238 out_be32(&psc->sicr,0); /* UART mode DCD ignored */
202 239
203 out_be16(&psc->mpc52xx_psc_clock_select, 0xdd00); /* /16 prescaler on */ 240 out_be16(&psc->mpc52xx_psc_clock_select, 0xdd00); /* /16 prescaler on */
204 241
205 out_8(&psc->rfcntl, 0x00); 242 out_8(&psc->rfcntl, 0x00);
206 out_be16(&psc->rfalarm, 0x1ff); 243 out_be16(&psc->rfalarm, 0x1ff);
207 out_8(&psc->tfcntl, 0x07); 244 out_8(&psc->tfcntl, 0x07);
@@ -209,10 +246,10 @@ mpc52xx_uart_startup(struct uart_port *port)
209 246
210 port->read_status_mask |= MPC52xx_PSC_IMR_RXRDY | MPC52xx_PSC_IMR_TXRDY; 247 port->read_status_mask |= MPC52xx_PSC_IMR_RXRDY | MPC52xx_PSC_IMR_TXRDY;
211 out_be16(&psc->mpc52xx_psc_imr,port->read_status_mask); 248 out_be16(&psc->mpc52xx_psc_imr,port->read_status_mask);
212 249
213 out_8(&psc->command,MPC52xx_PSC_TX_ENABLE); 250 out_8(&psc->command,MPC52xx_PSC_TX_ENABLE);
214 out_8(&psc->command,MPC52xx_PSC_RX_ENABLE); 251 out_8(&psc->command,MPC52xx_PSC_RX_ENABLE);
215 252
216 return 0; 253 return 0;
217} 254}
218 255
@@ -220,19 +257,19 @@ static void
220mpc52xx_uart_shutdown(struct uart_port *port) 257mpc52xx_uart_shutdown(struct uart_port *port)
221{ 258{
222 struct mpc52xx_psc __iomem *psc = PSC(port); 259 struct mpc52xx_psc __iomem *psc = PSC(port);
223 260
224 /* Shut down the port, interrupt and all */ 261 /* Shut down the port, interrupt and all */
225 out_8(&psc->command,MPC52xx_PSC_RST_RX); 262 out_8(&psc->command,MPC52xx_PSC_RST_RX);
226 out_8(&psc->command,MPC52xx_PSC_RST_TX); 263 out_8(&psc->command,MPC52xx_PSC_RST_TX);
227 264
228 port->read_status_mask = 0; 265 port->read_status_mask = 0;
229 out_be16(&psc->mpc52xx_psc_imr,port->read_status_mask); 266 out_be16(&psc->mpc52xx_psc_imr,port->read_status_mask);
230 267
231 /* Release interrupt */ 268 /* Release interrupt */
232 free_irq(port->irq, port); 269 free_irq(port->irq, port);
233} 270}
234 271
235static void 272static void
236mpc52xx_uart_set_termios(struct uart_port *port, struct termios *new, 273mpc52xx_uart_set_termios(struct uart_port *port, struct termios *new,
237 struct termios *old) 274 struct termios *old)
238{ 275{
@@ -241,10 +278,10 @@ mpc52xx_uart_set_termios(struct uart_port *port, struct termios *new,
241 unsigned char mr1, mr2; 278 unsigned char mr1, mr2;
242 unsigned short ctr; 279 unsigned short ctr;
243 unsigned int j, baud, quot; 280 unsigned int j, baud, quot;
244 281
245 /* Prepare what we're gonna write */ 282 /* Prepare what we're gonna write */
246 mr1 = 0; 283 mr1 = 0;
247 284
248 switch (new->c_cflag & CSIZE) { 285 switch (new->c_cflag & CSIZE) {
249 case CS5: mr1 |= MPC52xx_PSC_MODE_5_BITS; 286 case CS5: mr1 |= MPC52xx_PSC_MODE_5_BITS;
250 break; 287 break;
@@ -261,8 +298,8 @@ mpc52xx_uart_set_termios(struct uart_port *port, struct termios *new,
261 MPC52xx_PSC_MODE_PARODD : MPC52xx_PSC_MODE_PAREVEN; 298 MPC52xx_PSC_MODE_PARODD : MPC52xx_PSC_MODE_PAREVEN;
262 } else 299 } else
263 mr1 |= MPC52xx_PSC_MODE_PARNONE; 300 mr1 |= MPC52xx_PSC_MODE_PARNONE;
264 301
265 302
266 mr2 = 0; 303 mr2 = 0;
267 304
268 if (new->c_cflag & CSTOPB) 305 if (new->c_cflag & CSTOPB)
@@ -276,7 +313,7 @@ mpc52xx_uart_set_termios(struct uart_port *port, struct termios *new,
276 baud = uart_get_baud_rate(port, new, old, 0, port->uartclk/16); 313 baud = uart_get_baud_rate(port, new, old, 0, port->uartclk/16);
277 quot = uart_get_divisor(port, baud); 314 quot = uart_get_divisor(port, baud);
278 ctr = quot & 0xffff; 315 ctr = quot & 0xffff;
279 316
280 /* Get the lock */ 317 /* Get the lock */
281 spin_lock_irqsave(&port->lock, flags); 318 spin_lock_irqsave(&port->lock, flags);
282 319
@@ -290,14 +327,14 @@ mpc52xx_uart_set_termios(struct uart_port *port, struct termios *new,
290 * boot for the console, all stuff is not yet ready to receive at that 327 * boot for the console, all stuff is not yet ready to receive at that
291 * time and that just makes the kernel oops */ 328 * time and that just makes the kernel oops */
292 /* while (j-- && mpc52xx_uart_int_rx_chars(port)); */ 329 /* while (j-- && mpc52xx_uart_int_rx_chars(port)); */
293 while (!(in_be16(&psc->mpc52xx_psc_status) & MPC52xx_PSC_SR_TXEMP) && 330 while (!(in_be16(&psc->mpc52xx_psc_status) & MPC52xx_PSC_SR_TXEMP) &&
294 --j) 331 --j)
295 udelay(1); 332 udelay(1);
296 333
297 if (!j) 334 if (!j)
298 printk( KERN_ERR "mpc52xx_uart.c: " 335 printk( KERN_ERR "mpc52xx_uart.c: "
299 "Unable to flush RX & TX fifos in-time in set_termios." 336 "Unable to flush RX & TX fifos in-time in set_termios."
300 "Some chars may have been lost.\n" ); 337 "Some chars may have been lost.\n" );
301 338
302 /* Reset the TX & RX */ 339 /* Reset the TX & RX */
303 out_8(&psc->command,MPC52xx_PSC_RST_RX); 340 out_8(&psc->command,MPC52xx_PSC_RST_RX);
@@ -309,7 +346,7 @@ mpc52xx_uart_set_termios(struct uart_port *port, struct termios *new,
309 out_8(&psc->mode,mr2); 346 out_8(&psc->mode,mr2);
310 out_8(&psc->ctur,ctr >> 8); 347 out_8(&psc->ctur,ctr >> 8);
311 out_8(&psc->ctlr,ctr & 0xff); 348 out_8(&psc->ctlr,ctr & 0xff);
312 349
313 /* Reenable TX & RX */ 350 /* Reenable TX & RX */
314 out_8(&psc->command,MPC52xx_PSC_TX_ENABLE); 351 out_8(&psc->command,MPC52xx_PSC_TX_ENABLE);
315 out_8(&psc->command,MPC52xx_PSC_RX_ENABLE); 352 out_8(&psc->command,MPC52xx_PSC_RX_ENABLE);
@@ -332,7 +369,7 @@ mpc52xx_uart_release_port(struct uart_port *port)
332 port->membase = NULL; 369 port->membase = NULL;
333 } 370 }
334 371
335 release_mem_region(port->mapbase, MPC52xx_PSC_SIZE); 372 release_mem_region(port->mapbase, sizeof(struct mpc52xx_psc));
336} 373}
337 374
338static int 375static int
@@ -341,12 +378,13 @@ mpc52xx_uart_request_port(struct uart_port *port)
341 int err; 378 int err;
342 379
343 if (port->flags & UPF_IOREMAP) /* Need to remap ? */ 380 if (port->flags & UPF_IOREMAP) /* Need to remap ? */
344 port->membase = ioremap(port->mapbase, MPC52xx_PSC_SIZE); 381 port->membase = ioremap(port->mapbase,
382 sizeof(struct mpc52xx_psc));
345 383
346 if (!port->membase) 384 if (!port->membase)
347 return -EINVAL; 385 return -EINVAL;
348 386
349 err = request_mem_region(port->mapbase, MPC52xx_PSC_SIZE, 387 err = request_mem_region(port->mapbase, sizeof(struct mpc52xx_psc),
350 "mpc52xx_psc_uart") != NULL ? 0 : -EBUSY; 388 "mpc52xx_psc_uart") != NULL ? 0 : -EBUSY;
351 389
352 if (err && (port->flags & UPF_IOREMAP)) { 390 if (err && (port->flags & UPF_IOREMAP)) {
@@ -373,7 +411,7 @@ mpc52xx_uart_verify_port(struct uart_port *port, struct serial_struct *ser)
373 411
374 if ( (ser->irq != port->irq) || 412 if ( (ser->irq != port->irq) ||
375 (ser->io_type != SERIAL_IO_MEM) || 413 (ser->io_type != SERIAL_IO_MEM) ||
376 (ser->baud_base != port->uartclk) || 414 (ser->baud_base != port->uartclk) ||
377 (ser->iomem_base != (void*)port->mapbase) || 415 (ser->iomem_base != (void*)port->mapbase) ||
378 (ser->hub6 != 0 ) ) 416 (ser->hub6 != 0 ) )
379 return -EINVAL; 417 return -EINVAL;
@@ -404,11 +442,11 @@ static struct uart_ops mpc52xx_uart_ops = {
404 .verify_port = mpc52xx_uart_verify_port 442 .verify_port = mpc52xx_uart_verify_port
405}; 443};
406 444
407 445
408/* ======================================================================== */ 446/* ======================================================================== */
409/* Interrupt handling */ 447/* Interrupt handling */
410/* ======================================================================== */ 448/* ======================================================================== */
411 449
412static inline int 450static inline int
413mpc52xx_uart_int_rx_chars(struct uart_port *port) 451mpc52xx_uart_int_rx_chars(struct uart_port *port)
414{ 452{
@@ -435,11 +473,11 @@ mpc52xx_uart_int_rx_chars(struct uart_port *port)
435 473
436 flag = TTY_NORMAL; 474 flag = TTY_NORMAL;
437 port->icount.rx++; 475 port->icount.rx++;
438 476
439 if ( status & (MPC52xx_PSC_SR_PE | 477 if ( status & (MPC52xx_PSC_SR_PE |
440 MPC52xx_PSC_SR_FE | 478 MPC52xx_PSC_SR_FE |
441 MPC52xx_PSC_SR_RB) ) { 479 MPC52xx_PSC_SR_RB) ) {
442 480
443 if (status & MPC52xx_PSC_SR_RB) { 481 if (status & MPC52xx_PSC_SR_RB) {
444 flag = TTY_BREAK; 482 flag = TTY_BREAK;
445 uart_handle_break(port); 483 uart_handle_break(port);
@@ -464,7 +502,7 @@ mpc52xx_uart_int_rx_chars(struct uart_port *port)
464 } 502 }
465 503
466 tty_flip_buffer_push(tty); 504 tty_flip_buffer_push(tty);
467 505
468 return in_be16(&PSC(port)->mpc52xx_psc_status) & MPC52xx_PSC_SR_RXRDY; 506 return in_be16(&PSC(port)->mpc52xx_psc_status) & MPC52xx_PSC_SR_RXRDY;
469} 507}
470 508
@@ -509,25 +547,25 @@ mpc52xx_uart_int_tx_chars(struct uart_port *port)
509 return 1; 547 return 1;
510} 548}
511 549
512static irqreturn_t 550static irqreturn_t
513mpc52xx_uart_int(int irq, void *dev_id) 551mpc52xx_uart_int(int irq, void *dev_id)
514{ 552{
515 struct uart_port *port = dev_id; 553 struct uart_port *port = dev_id;
516 unsigned long pass = ISR_PASS_LIMIT; 554 unsigned long pass = ISR_PASS_LIMIT;
517 unsigned int keepgoing; 555 unsigned int keepgoing;
518 unsigned short status; 556 unsigned short status;
519 557
520 spin_lock(&port->lock); 558 spin_lock(&port->lock);
521 559
522 /* While we have stuff to do, we continue */ 560 /* While we have stuff to do, we continue */
523 do { 561 do {
524 /* If we don't find anything to do, we stop */ 562 /* If we don't find anything to do, we stop */
525 keepgoing = 0; 563 keepgoing = 0;
526 564
527 /* Read status */ 565 /* Read status */
528 status = in_be16(&PSC(port)->mpc52xx_psc_isr); 566 status = in_be16(&PSC(port)->mpc52xx_psc_isr);
529 status &= port->read_status_mask; 567 status &= port->read_status_mask;
530 568
531 /* Do we need to receive chars ? */ 569 /* Do we need to receive chars ? */
532 /* For this RX interrupts must be on and some chars waiting */ 570 /* For this RX interrupts must be on and some chars waiting */
533 if ( status & MPC52xx_PSC_IMR_RXRDY ) 571 if ( status & MPC52xx_PSC_IMR_RXRDY )
@@ -537,15 +575,15 @@ mpc52xx_uart_int(int irq, void *dev_id)
537 /* For this, TX must be ready and TX interrupt enabled */ 575 /* For this, TX must be ready and TX interrupt enabled */
538 if ( status & MPC52xx_PSC_IMR_TXRDY ) 576 if ( status & MPC52xx_PSC_IMR_TXRDY )
539 keepgoing |= mpc52xx_uart_int_tx_chars(port); 577 keepgoing |= mpc52xx_uart_int_tx_chars(port);
540 578
541 /* Limit number of iteration */ 579 /* Limit number of iteration */
542 if ( !(--pass) ) 580 if ( !(--pass) )
543 keepgoing = 0; 581 keepgoing = 0;
544 582
545 } while (keepgoing); 583 } while (keepgoing);
546 584
547 spin_unlock(&port->lock); 585 spin_unlock(&port->lock);
548 586
549 return IRQ_HANDLED; 587 return IRQ_HANDLED;
550} 588}
551 589
@@ -563,13 +601,18 @@ mpc52xx_console_get_options(struct uart_port *port,
563 struct mpc52xx_psc __iomem *psc = PSC(port); 601 struct mpc52xx_psc __iomem *psc = PSC(port);
564 unsigned char mr1; 602 unsigned char mr1;
565 603
604 pr_debug("mpc52xx_console_get_options(port=%p)\n", port);
605
566 /* Read the mode registers */ 606 /* Read the mode registers */
567 out_8(&psc->command,MPC52xx_PSC_SEL_MODE_REG_1); 607 out_8(&psc->command,MPC52xx_PSC_SEL_MODE_REG_1);
568 mr1 = in_8(&psc->mode); 608 mr1 = in_8(&psc->mode);
569 609
570 /* CT{U,L}R are write-only ! */ 610 /* CT{U,L}R are write-only ! */
571 *baud = __res.bi_baudrate ? 611 *baud = CONFIG_SERIAL_MPC52xx_CONSOLE_BAUD;
572 __res.bi_baudrate : CONFIG_SERIAL_MPC52xx_CONSOLE_BAUD; 612#if !defined(CONFIG_PPC_MERGE)
613 if (__res.bi_baudrate)
614 *baud = __res.bi_baudrate;
615#endif
573 616
574 /* Parse them */ 617 /* Parse them */
575 switch (mr1 & MPC52xx_PSC_MODE_BITS_MASK) { 618 switch (mr1 & MPC52xx_PSC_MODE_BITS_MASK) {
@@ -579,26 +622,26 @@ mpc52xx_console_get_options(struct uart_port *port,
579 case MPC52xx_PSC_MODE_8_BITS: 622 case MPC52xx_PSC_MODE_8_BITS:
580 default: *bits = 8; 623 default: *bits = 8;
581 } 624 }
582 625
583 if (mr1 & MPC52xx_PSC_MODE_PARNONE) 626 if (mr1 & MPC52xx_PSC_MODE_PARNONE)
584 *parity = 'n'; 627 *parity = 'n';
585 else 628 else
586 *parity = mr1 & MPC52xx_PSC_MODE_PARODD ? 'o' : 'e'; 629 *parity = mr1 & MPC52xx_PSC_MODE_PARODD ? 'o' : 'e';
587} 630}
588 631
589static void 632static void
590mpc52xx_console_write(struct console *co, const char *s, unsigned int count) 633mpc52xx_console_write(struct console *co, const char *s, unsigned int count)
591{ 634{
592 struct uart_port *port = &mpc52xx_uart_ports[co->index]; 635 struct uart_port *port = &mpc52xx_uart_ports[co->index];
593 struct mpc52xx_psc __iomem *psc = PSC(port); 636 struct mpc52xx_psc __iomem *psc = PSC(port);
594 unsigned int i, j; 637 unsigned int i, j;
595 638
596 /* Disable interrupts */ 639 /* Disable interrupts */
597 out_be16(&psc->mpc52xx_psc_imr, 0); 640 out_be16(&psc->mpc52xx_psc_imr, 0);
598 641
599 /* Wait the TX buffer to be empty */ 642 /* Wait the TX buffer to be empty */
600 j = 5000000; /* Maximum wait */ 643 j = 5000000; /* Maximum wait */
601 while (!(in_be16(&psc->mpc52xx_psc_status) & MPC52xx_PSC_SR_TXEMP) && 644 while (!(in_be16(&psc->mpc52xx_psc_status) & MPC52xx_PSC_SR_TXEMP) &&
602 --j) 645 --j)
603 udelay(1); 646 udelay(1);
604 647
@@ -607,13 +650,13 @@ mpc52xx_console_write(struct console *co, const char *s, unsigned int count)
607 /* Line return handling */ 650 /* Line return handling */
608 if (*s == '\n') 651 if (*s == '\n')
609 out_8(&psc->mpc52xx_psc_buffer_8, '\r'); 652 out_8(&psc->mpc52xx_psc_buffer_8, '\r');
610 653
611 /* Send the char */ 654 /* Send the char */
612 out_8(&psc->mpc52xx_psc_buffer_8, *s); 655 out_8(&psc->mpc52xx_psc_buffer_8, *s);
613 656
614 /* Wait the TX buffer to be empty */ 657 /* Wait the TX buffer to be empty */
615 j = 20000; /* Maximum wait */ 658 j = 20000; /* Maximum wait */
616 while (!(in_be16(&psc->mpc52xx_psc_status) & 659 while (!(in_be16(&psc->mpc52xx_psc_status) &
617 MPC52xx_PSC_SR_TXEMP) && --j) 660 MPC52xx_PSC_SR_TXEMP) && --j)
618 udelay(1); 661 udelay(1);
619 } 662 }
@@ -622,6 +665,7 @@ mpc52xx_console_write(struct console *co, const char *s, unsigned int count)
622 out_be16(&psc->mpc52xx_psc_imr, port->read_status_mask); 665 out_be16(&psc->mpc52xx_psc_imr, port->read_status_mask);
623} 666}
624 667
668#if !defined(CONFIG_PPC_MERGE)
625static int __init 669static int __init
626mpc52xx_console_setup(struct console *co, char *options) 670mpc52xx_console_setup(struct console *co, char *options)
627{ 671{
@@ -634,7 +678,7 @@ mpc52xx_console_setup(struct console *co, char *options)
634 678
635 if (co->index < 0 || co->index >= MPC52xx_PSC_MAXNUM) 679 if (co->index < 0 || co->index >= MPC52xx_PSC_MAXNUM)
636 return -EINVAL; 680 return -EINVAL;
637 681
638 /* Basic port init. Needed since we use some uart_??? func before 682 /* Basic port init. Needed since we use some uart_??? func before
639 * real init for early access */ 683 * real init for early access */
640 spin_lock_init(&port->lock); 684 spin_lock_init(&port->lock);
@@ -656,6 +700,78 @@ mpc52xx_console_setup(struct console *co, char *options)
656 return uart_set_options(port, co, baud, parity, bits, flow); 700 return uart_set_options(port, co, baud, parity, bits, flow);
657} 701}
658 702
703#else
704
705static int __init
706mpc52xx_console_setup(struct console *co, char *options)
707{
708 struct uart_port *port = &mpc52xx_uart_ports[co->index];
709 struct device_node *np = mpc52xx_uart_nodes[co->index];
710 unsigned int ipb_freq;
711 struct resource res;
712 int ret;
713
714 int baud = CONFIG_SERIAL_MPC52xx_CONSOLE_BAUD;
715 int bits = 8;
716 int parity = 'n';
717 int flow = 'n';
718
719 pr_debug("mpc52xx_console_setup co=%p, co->index=%i, options=%s\n",
720 co, co->index, options);
721
722 if ((co->index < 0) || (co->index > MPC52xx_PSC_MAXNUM)) {
723 pr_debug("PSC%x out of range\n", co->index);
724 return -EINVAL;
725 }
726
727 if (!np) {
728 pr_debug("PSC%x not found in device tree\n", co->index);
729 return -EINVAL;
730 }
731
732 pr_debug("Console on ttyPSC%x is %s\n",
733 co->index, mpc52xx_uart_nodes[co->index]->full_name);
734
735 /* Fetch register locations */
736 if ((ret = of_address_to_resource(np, 0, &res)) != 0) {
737 pr_debug("Could not get resources for PSC%x\n", co->index);
738 return ret;
739 }
740
741 /* Search for bus-frequency property in this node or a parent */
742 if ((ipb_freq = mpc52xx_find_ipb_freq(np)) == 0) {
743 pr_debug("Could not find IPB bus frequency!\n");
744 return -EINVAL;
745 }
746
747 /* Basic port init. Needed since we use some uart_??? func before
748 * real init for early access */
749 spin_lock_init(&port->lock);
750 port->uartclk = ipb_freq / 2;
751 port->ops = &mpc52xx_uart_ops;
752 port->mapbase = res.start;
753 port->membase = ioremap(res.start, sizeof(struct mpc52xx_psc));
754 port->irq = irq_of_parse_and_map(np, 0);
755
756 if (port->membase == NULL)
757 return -EINVAL;
758
759 pr_debug("mpc52xx-psc uart at %lx, mapped to %p, irq=%x, freq=%i\n",
760 port->mapbase, port->membase, port->irq, port->uartclk);
761
762 /* Setup the port parameters accoding to options */
763 if (options)
764 uart_parse_options(options, &baud, &parity, &bits, &flow);
765 else
766 mpc52xx_console_get_options(port, &baud, &parity, &bits, &flow);
767
768 pr_debug("Setting console parameters: %i %i%c1 flow=%c\n",
769 baud, bits, parity, flow);
770
771 return uart_set_options(port, co, baud, parity, bits, flow);
772}
773#endif /* defined(CONFIG_PPC_MERGE) */
774
659 775
660static struct uart_driver mpc52xx_uart_driver; 776static struct uart_driver mpc52xx_uart_driver;
661 777
@@ -669,10 +785,11 @@ static struct console mpc52xx_console = {
669 .data = &mpc52xx_uart_driver, 785 .data = &mpc52xx_uart_driver,
670}; 786};
671 787
672 788
673static int __init 789static int __init
674mpc52xx_console_init(void) 790mpc52xx_console_init(void)
675{ 791{
792 mpc52xx_uart_of_enumerate();
676 register_console(&mpc52xx_console); 793 register_console(&mpc52xx_console);
677 return 0; 794 return 0;
678} 795}
@@ -700,6 +817,7 @@ static struct uart_driver mpc52xx_uart_driver = {
700}; 817};
701 818
702 819
820#if !defined(CONFIG_PPC_MERGE)
703/* ======================================================================== */ 821/* ======================================================================== */
704/* Platform Driver */ 822/* Platform Driver */
705/* ======================================================================== */ 823/* ======================================================================== */
@@ -723,8 +841,6 @@ mpc52xx_uart_probe(struct platform_device *dev)
723 /* Init the port structure */ 841 /* Init the port structure */
724 port = &mpc52xx_uart_ports[idx]; 842 port = &mpc52xx_uart_ports[idx];
725 843
726 memset(port, 0x00, sizeof(struct uart_port));
727
728 spin_lock_init(&port->lock); 844 spin_lock_init(&port->lock);
729 port->uartclk = __res.bi_ipbfreq / 2; /* Look at CTLR doc */ 845 port->uartclk = __res.bi_ipbfreq / 2; /* Look at CTLR doc */
730 port->fifosize = 512; 846 port->fifosize = 512;
@@ -733,6 +849,7 @@ mpc52xx_uart_probe(struct platform_device *dev)
733 ( uart_console(port) ? 0 : UPF_IOREMAP ); 849 ( uart_console(port) ? 0 : UPF_IOREMAP );
734 port->line = idx; 850 port->line = idx;
735 port->ops = &mpc52xx_uart_ops; 851 port->ops = &mpc52xx_uart_ops;
852 port->dev = &dev->dev;
736 853
737 /* Search for IRQ and mapbase */ 854 /* Search for IRQ and mapbase */
738 for (i=0 ; i<dev->num_resources ; i++, res++) { 855 for (i=0 ; i<dev->num_resources ; i++, res++) {
@@ -771,7 +888,7 @@ mpc52xx_uart_suspend(struct platform_device *dev, pm_message_t state)
771{ 888{
772 struct uart_port *port = (struct uart_port *) platform_get_drvdata(dev); 889 struct uart_port *port = (struct uart_port *) platform_get_drvdata(dev);
773 890
774 if (sport) 891 if (port)
775 uart_suspend_port(&mpc52xx_uart_driver, port); 892 uart_suspend_port(&mpc52xx_uart_driver, port);
776 893
777 return 0; 894 return 0;
@@ -789,6 +906,7 @@ mpc52xx_uart_resume(struct platform_device *dev)
789} 906}
790#endif 907#endif
791 908
909
792static struct platform_driver mpc52xx_uart_platform_driver = { 910static struct platform_driver mpc52xx_uart_platform_driver = {
793 .probe = mpc52xx_uart_probe, 911 .probe = mpc52xx_uart_probe,
794 .remove = mpc52xx_uart_remove, 912 .remove = mpc52xx_uart_remove,
@@ -800,6 +918,184 @@ static struct platform_driver mpc52xx_uart_platform_driver = {
800 .name = "mpc52xx-psc", 918 .name = "mpc52xx-psc",
801 }, 919 },
802}; 920};
921#endif /* !defined(CONFIG_PPC_MERGE) */
922
923
924#if defined(CONFIG_PPC_MERGE)
925/* ======================================================================== */
926/* OF Platform Driver */
927/* ======================================================================== */
928
929static int __devinit
930mpc52xx_uart_of_probe(struct of_device *op, const struct of_device_id *match)
931{
932 int idx = -1;
933 unsigned int ipb_freq;
934 struct uart_port *port = NULL;
935 struct resource res;
936 int ret;
937
938 dev_dbg(&op->dev, "mpc52xx_uart_probe(op=%p, match=%p)\n", op, match);
939
940 /* Check validity & presence */
941 for (idx = 0; idx < MPC52xx_PSC_MAXNUM; idx++)
942 if (mpc52xx_uart_nodes[idx] == op->node)
943 break;
944 if (idx >= MPC52xx_PSC_MAXNUM)
945 return -EINVAL;
946 pr_debug("Found %s assigned to ttyPSC%x\n",
947 mpc52xx_uart_nodes[idx]->full_name, idx);
948
949 /* Search for bus-frequency property in this node or a parent */
950 if ((ipb_freq = mpc52xx_find_ipb_freq(op->node)) == 0) {
951 dev_dbg(&op->dev, "Could not find IPB bus frequency!\n");
952 return -EINVAL;
953 }
954
955 /* Init the port structure */
956 port = &mpc52xx_uart_ports[idx];
957
958 spin_lock_init(&port->lock);
959 port->uartclk = ipb_freq / 2;
960 port->fifosize = 512;
961 port->iotype = UPIO_MEM;
962 port->flags = UPF_BOOT_AUTOCONF |
963 ( uart_console(port) ? 0 : UPF_IOREMAP );
964 port->line = idx;
965 port->ops = &mpc52xx_uart_ops;
966 port->dev = &op->dev;
967
968 /* Search for IRQ and mapbase */
969 if ((ret = of_address_to_resource(op->node, 0, &res)) != 0)
970 return ret;
971
972 port->mapbase = res.start;
973 port->irq = irq_of_parse_and_map(op->node, 0);
974
975 dev_dbg(&op->dev, "mpc52xx-psc uart at %lx, irq=%x, freq=%i\n",
976 port->mapbase, port->irq, port->uartclk);
977
978 if ((port->irq==NO_IRQ) || !port->mapbase) {
979 printk(KERN_ERR "Could not allocate resources for PSC\n");
980 return -EINVAL;
981 }
982
983 /* Add the port to the uart sub-system */
984 ret = uart_add_one_port(&mpc52xx_uart_driver, port);
985 if (!ret)
986 dev_set_drvdata(&op->dev, (void*)port);
987
988 return ret;
989}
990
991static int
992mpc52xx_uart_of_remove(struct of_device *op)
993{
994 struct uart_port *port = dev_get_drvdata(&op->dev);
995 dev_set_drvdata(&op->dev, NULL);
996
997 if (port)
998 uart_remove_one_port(&mpc52xx_uart_driver, port);
999
1000 return 0;
1001}
1002
1003#ifdef CONFIG_PM
1004static int
1005mpc52xx_uart_of_suspend(struct of_device *op, pm_message_t state)
1006{
1007 struct uart_port *port = (struct uart_port *) dev_get_drvdata(&op->dev);
1008
1009 if (port)
1010 uart_suspend_port(&mpc52xx_uart_driver, port);
1011
1012 return 0;
1013}
1014
1015static int
1016mpc52xx_uart_of_resume(struct of_device *op)
1017{
1018 struct uart_port *port = (struct uart_port *) dev_get_drvdata(&op->dev);
1019
1020 if (port)
1021 uart_resume_port(&mpc52xx_uart_driver, port);
1022
1023 return 0;
1024}
1025#endif
1026
1027static void
1028mpc52xx_uart_of_assign(struct device_node *np, int idx)
1029{
1030 int free_idx = -1;
1031 int i;
1032
1033 /* Find the first free node */
1034 for (i = 0; i < MPC52xx_PSC_MAXNUM; i++) {
1035 if (mpc52xx_uart_nodes[i] == NULL) {
1036 free_idx = i;
1037 break;
1038 }
1039 }
1040
1041 if ((idx < 0) || (idx >= MPC52xx_PSC_MAXNUM))
1042 idx = free_idx;
1043
1044 if (idx < 0)
1045 return; /* No free slot; abort */
1046
1047 /* If the slot is already occupied, then swap slots */
1048 if (mpc52xx_uart_nodes[idx] && (free_idx != -1))
1049 mpc52xx_uart_nodes[free_idx] = mpc52xx_uart_nodes[idx];
1050 mpc52xx_uart_nodes[i] = np;
1051}
1052
1053static void
1054mpc52xx_uart_of_enumerate(void)
1055{
1056 static int enum_done = 0;
1057 struct device_node *np;
1058 const unsigned int *devno;
1059 int i;
1060
1061 if (enum_done)
1062 return;
1063
1064 for_each_node_by_type(np, "serial") {
1065 if (!of_match_node(mpc52xx_uart_of_match, np))
1066 continue;
1067
1068 /* Is a particular device number requested? */
1069 devno = get_property(np, "device_no", NULL);
1070 mpc52xx_uart_of_assign(of_node_get(np), devno ? *devno : -1);
1071 }
1072
1073 enum_done = 1;
1074
1075 for (i = 0; i < MPC52xx_PSC_MAXNUM; i++) {
1076 if (mpc52xx_uart_nodes[i])
1077 pr_debug("%s assigned to ttyPSC%x\n",
1078 mpc52xx_uart_nodes[i]->full_name, i);
1079 }
1080}
1081
1082MODULE_DEVICE_TABLE(of, mpc52xx_uart_of_match);
1083
1084static struct of_platform_driver mpc52xx_uart_of_driver = {
1085 .owner = THIS_MODULE,
1086 .name = "mpc52xx-psc-uart",
1087 .match_table = mpc52xx_uart_of_match,
1088 .probe = mpc52xx_uart_of_probe,
1089 .remove = mpc52xx_uart_of_remove,
1090#ifdef CONFIG_PM
1091 .suspend = mpc52xx_uart_of_suspend,
1092 .resume = mpc52xx_uart_of_resume,
1093#endif
1094 .driver = {
1095 .name = "mpc52xx-psc-uart",
1096 },
1097};
1098#endif /* defined(CONFIG_PPC_MERGE) */
803 1099
804 1100
805/* ======================================================================== */ 1101/* ======================================================================== */
@@ -811,22 +1107,45 @@ mpc52xx_uart_init(void)
811{ 1107{
812 int ret; 1108 int ret;
813 1109
814 printk(KERN_INFO "Serial: MPC52xx PSC driver\n"); 1110 printk(KERN_INFO "Serial: MPC52xx PSC UART driver\n");
815 1111
816 ret = uart_register_driver(&mpc52xx_uart_driver); 1112 if ((ret = uart_register_driver(&mpc52xx_uart_driver)) != 0) {
817 if (ret == 0) { 1113 printk(KERN_ERR "%s: uart_register_driver failed (%i)\n",
818 ret = platform_driver_register(&mpc52xx_uart_platform_driver); 1114 __FILE__, ret);
819 if (ret) 1115 return ret;
820 uart_unregister_driver(&mpc52xx_uart_driver);
821 } 1116 }
822 1117
823 return ret; 1118#if defined(CONFIG_PPC_MERGE)
1119 mpc52xx_uart_of_enumerate();
1120
1121 ret = of_register_platform_driver(&mpc52xx_uart_of_driver);
1122 if (ret) {
1123 printk(KERN_ERR "%s: of_register_platform_driver failed (%i)\n",
1124 __FILE__, ret);
1125 uart_unregister_driver(&mpc52xx_uart_driver);
1126 return ret;
1127 }
1128#else
1129 ret = platform_driver_register(&mpc52xx_uart_platform_driver);
1130 if (ret) {
1131 printk(KERN_ERR "%s: platform_driver_register failed (%i)\n",
1132 __FILE__, ret);
1133 uart_unregister_driver(&mpc52xx_uart_driver);
1134 return ret;
1135 }
1136#endif
1137
1138 return 0;
824} 1139}
825 1140
826static void __exit 1141static void __exit
827mpc52xx_uart_exit(void) 1142mpc52xx_uart_exit(void)
828{ 1143{
1144#if defined(CONFIG_PPC_MERGE)
1145 of_unregister_platform_driver(&mpc52xx_uart_of_driver);
1146#else
829 platform_driver_unregister(&mpc52xx_uart_platform_driver); 1147 platform_driver_unregister(&mpc52xx_uart_platform_driver);
1148#endif
830 uart_unregister_driver(&mpc52xx_uart_driver); 1149 uart_unregister_driver(&mpc52xx_uart_driver);
831} 1150}
832 1151
diff --git a/drivers/serial/mpsc.c b/drivers/serial/mpsc.c
index 8eea69f29989..29823bd60fb0 100644
--- a/drivers/serial/mpsc.c
+++ b/drivers/serial/mpsc.c
@@ -555,7 +555,7 @@ mpsc_sdma_start_tx(struct mpsc_port_info *pi)
555 if (!mpsc_sdma_tx_active(pi)) { 555 if (!mpsc_sdma_tx_active(pi)) {
556 txre = (struct mpsc_tx_desc *)(pi->txr + 556 txre = (struct mpsc_tx_desc *)(pi->txr +
557 (pi->txr_tail * MPSC_TXRE_SIZE)); 557 (pi->txr_tail * MPSC_TXRE_SIZE));
558 dma_cache_sync((void *) txre, MPSC_TXRE_SIZE, DMA_FROM_DEVICE); 558 dma_cache_sync(pi->port.dev, (void *) txre, MPSC_TXRE_SIZE, DMA_FROM_DEVICE);
559#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 559#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
560 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 560 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
561 invalidate_dcache_range((ulong)txre, 561 invalidate_dcache_range((ulong)txre,
@@ -931,7 +931,7 @@ mpsc_init_rings(struct mpsc_port_info *pi)
931 } 931 }
932 txre->link = cpu_to_be32(pi->txr_p); /* Wrap last back to first */ 932 txre->link = cpu_to_be32(pi->txr_p); /* Wrap last back to first */
933 933
934 dma_cache_sync((void *) pi->dma_region, MPSC_DMA_ALLOC_SIZE, 934 dma_cache_sync(pi->port.dev, (void *) pi->dma_region, MPSC_DMA_ALLOC_SIZE,
935 DMA_BIDIRECTIONAL); 935 DMA_BIDIRECTIONAL);
936#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 936#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
937 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 937 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
@@ -1005,7 +1005,7 @@ mpsc_rx_intr(struct mpsc_port_info *pi)
1005 1005
1006 rxre = (struct mpsc_rx_desc *)(pi->rxr + (pi->rxr_posn*MPSC_RXRE_SIZE)); 1006 rxre = (struct mpsc_rx_desc *)(pi->rxr + (pi->rxr_posn*MPSC_RXRE_SIZE));
1007 1007
1008 dma_cache_sync((void *)rxre, MPSC_RXRE_SIZE, DMA_FROM_DEVICE); 1008 dma_cache_sync(pi->port.dev, (void *)rxre, MPSC_RXRE_SIZE, DMA_FROM_DEVICE);
1009#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 1009#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
1010 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 1010 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
1011 invalidate_dcache_range((ulong)rxre, 1011 invalidate_dcache_range((ulong)rxre,
@@ -1029,7 +1029,7 @@ mpsc_rx_intr(struct mpsc_port_info *pi)
1029 } 1029 }
1030 1030
1031 bp = pi->rxb + (pi->rxr_posn * MPSC_RXBE_SIZE); 1031 bp = pi->rxb + (pi->rxr_posn * MPSC_RXBE_SIZE);
1032 dma_cache_sync((void *) bp, MPSC_RXBE_SIZE, DMA_FROM_DEVICE); 1032 dma_cache_sync(pi->port.dev, (void *) bp, MPSC_RXBE_SIZE, DMA_FROM_DEVICE);
1033#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 1033#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
1034 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 1034 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
1035 invalidate_dcache_range((ulong)bp, 1035 invalidate_dcache_range((ulong)bp,
@@ -1098,7 +1098,7 @@ next_frame:
1098 SDMA_DESC_CMDSTAT_F | 1098 SDMA_DESC_CMDSTAT_F |
1099 SDMA_DESC_CMDSTAT_L); 1099 SDMA_DESC_CMDSTAT_L);
1100 wmb(); 1100 wmb();
1101 dma_cache_sync((void *)rxre, MPSC_RXRE_SIZE, DMA_BIDIRECTIONAL); 1101 dma_cache_sync(pi->port.dev, (void *)rxre, MPSC_RXRE_SIZE, DMA_BIDIRECTIONAL);
1102#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 1102#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
1103 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 1103 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
1104 flush_dcache_range((ulong)rxre, 1104 flush_dcache_range((ulong)rxre,
@@ -1109,7 +1109,7 @@ next_frame:
1109 pi->rxr_posn = (pi->rxr_posn + 1) & (MPSC_RXR_ENTRIES - 1); 1109 pi->rxr_posn = (pi->rxr_posn + 1) & (MPSC_RXR_ENTRIES - 1);
1110 rxre = (struct mpsc_rx_desc *)(pi->rxr + 1110 rxre = (struct mpsc_rx_desc *)(pi->rxr +
1111 (pi->rxr_posn * MPSC_RXRE_SIZE)); 1111 (pi->rxr_posn * MPSC_RXRE_SIZE));
1112 dma_cache_sync((void *)rxre, MPSC_RXRE_SIZE, DMA_FROM_DEVICE); 1112 dma_cache_sync(pi->port.dev, (void *)rxre, MPSC_RXRE_SIZE, DMA_FROM_DEVICE);
1113#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 1113#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
1114 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 1114 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
1115 invalidate_dcache_range((ulong)rxre, 1115 invalidate_dcache_range((ulong)rxre,
@@ -1143,7 +1143,7 @@ mpsc_setup_tx_desc(struct mpsc_port_info *pi, u32 count, u32 intr)
1143 SDMA_DESC_CMDSTAT_EI 1143 SDMA_DESC_CMDSTAT_EI
1144 : 0)); 1144 : 0));
1145 wmb(); 1145 wmb();
1146 dma_cache_sync((void *) txre, MPSC_TXRE_SIZE, DMA_BIDIRECTIONAL); 1146 dma_cache_sync(pi->port.dev, (void *) txre, MPSC_TXRE_SIZE, DMA_BIDIRECTIONAL);
1147#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 1147#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
1148 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 1148 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
1149 flush_dcache_range((ulong)txre, 1149 flush_dcache_range((ulong)txre,
@@ -1192,7 +1192,7 @@ mpsc_copy_tx_data(struct mpsc_port_info *pi)
1192 else /* All tx data copied into ring bufs */ 1192 else /* All tx data copied into ring bufs */
1193 return; 1193 return;
1194 1194
1195 dma_cache_sync((void *) bp, MPSC_TXBE_SIZE, DMA_BIDIRECTIONAL); 1195 dma_cache_sync(pi->port.dev, (void *) bp, MPSC_TXBE_SIZE, DMA_BIDIRECTIONAL);
1196#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 1196#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
1197 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 1197 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
1198 flush_dcache_range((ulong)bp, 1198 flush_dcache_range((ulong)bp,
@@ -1217,7 +1217,7 @@ mpsc_tx_intr(struct mpsc_port_info *pi)
1217 txre = (struct mpsc_tx_desc *)(pi->txr + 1217 txre = (struct mpsc_tx_desc *)(pi->txr +
1218 (pi->txr_tail * MPSC_TXRE_SIZE)); 1218 (pi->txr_tail * MPSC_TXRE_SIZE));
1219 1219
1220 dma_cache_sync((void *) txre, MPSC_TXRE_SIZE, DMA_FROM_DEVICE); 1220 dma_cache_sync(pi->port.dev, (void *) txre, MPSC_TXRE_SIZE, DMA_FROM_DEVICE);
1221#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 1221#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
1222 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 1222 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
1223 invalidate_dcache_range((ulong)txre, 1223 invalidate_dcache_range((ulong)txre,
@@ -1235,7 +1235,7 @@ mpsc_tx_intr(struct mpsc_port_info *pi)
1235 1235
1236 txre = (struct mpsc_tx_desc *)(pi->txr + 1236 txre = (struct mpsc_tx_desc *)(pi->txr +
1237 (pi->txr_tail * MPSC_TXRE_SIZE)); 1237 (pi->txr_tail * MPSC_TXRE_SIZE));
1238 dma_cache_sync((void *) txre, MPSC_TXRE_SIZE, 1238 dma_cache_sync(pi->port.dev, (void *) txre, MPSC_TXRE_SIZE,
1239 DMA_FROM_DEVICE); 1239 DMA_FROM_DEVICE);
1240#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 1240#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
1241 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 1241 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
@@ -1652,7 +1652,7 @@ mpsc_console_write(struct console *co, const char *s, uint count)
1652 count--; 1652 count--;
1653 } 1653 }
1654 1654
1655 dma_cache_sync((void *) bp, MPSC_TXBE_SIZE, DMA_BIDIRECTIONAL); 1655 dma_cache_sync(pi->port.dev, (void *) bp, MPSC_TXBE_SIZE, DMA_BIDIRECTIONAL);
1656#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 1656#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
1657 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 1657 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
1658 flush_dcache_range((ulong)bp, 1658 flush_dcache_range((ulong)bp,
diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c
index 00f9ffd69489..431433f4dd6d 100644
--- a/drivers/serial/serial_cs.c
+++ b/drivers/serial/serial_cs.c
@@ -723,7 +723,7 @@ static int serial_config(struct pcmcia_device * link)
723 u_char *buf; 723 u_char *buf;
724 cisparse_t *parse; 724 cisparse_t *parse;
725 cistpl_cftable_entry_t *cf; 725 cistpl_cftable_entry_t *cf;
726 int i, last_ret, last_fn; 726 int i;
727 727
728 DEBUG(0, "serial_config(0x%p)\n", link); 728 DEBUG(0, "serial_config(0x%p)\n", link);
729 729
@@ -740,15 +740,6 @@ static int serial_config(struct pcmcia_device * link)
740 tuple->TupleOffset = 0; 740 tuple->TupleOffset = 0;
741 tuple->TupleDataMax = 255; 741 tuple->TupleDataMax = 255;
742 tuple->Attributes = 0; 742 tuple->Attributes = 0;
743 /* Get configuration register information */
744 tuple->DesiredTuple = CISTPL_CONFIG;
745 last_ret = first_tuple(link, tuple, parse);
746 if (last_ret != CS_SUCCESS) {
747 last_fn = ParseTuple;
748 goto cs_failed;
749 }
750 link->conf.ConfigBase = parse->config.base;
751 link->conf.Present = parse->config.rmask[0];
752 743
753 /* Is this a compliant multifunction card? */ 744 /* Is this a compliant multifunction card? */
754 tuple->DesiredTuple = CISTPL_LONGLINK_MFC; 745 tuple->DesiredTuple = CISTPL_LONGLINK_MFC;
@@ -757,27 +748,25 @@ static int serial_config(struct pcmcia_device * link)
757 748
758 /* Is this a multiport card? */ 749 /* Is this a multiport card? */
759 tuple->DesiredTuple = CISTPL_MANFID; 750 tuple->DesiredTuple = CISTPL_MANFID;
760 if (first_tuple(link, tuple, parse) == CS_SUCCESS) { 751 info->manfid = link->manf_id;
761 info->manfid = parse->manfid.manf; 752 info->prodid = link->card_id;
762 info->prodid = parse->manfid.card; 753
763 754 for (i = 0; i < ARRAY_SIZE(quirks); i++)
764 for (i = 0; i < ARRAY_SIZE(quirks); i++) 755 if ((quirks[i].manfid == ~0 ||
765 if ((quirks[i].manfid == ~0 || 756 quirks[i].manfid == info->manfid) &&
766 quirks[i].manfid == info->manfid) && 757 (quirks[i].prodid == ~0 ||
767 (quirks[i].prodid == ~0 || 758 quirks[i].prodid == info->prodid)) {
768 quirks[i].prodid == info->prodid)) { 759 info->quirk = &quirks[i];
769 info->quirk = &quirks[i]; 760 break;
770 break; 761 }
771 }
772 }
773 762
774 /* Another check for dual-serial cards: look for either serial or 763 /* Another check for dual-serial cards: look for either serial or
775 multifunction cards that ask for appropriate IO port ranges */ 764 multifunction cards that ask for appropriate IO port ranges */
776 tuple->DesiredTuple = CISTPL_FUNCID; 765 tuple->DesiredTuple = CISTPL_FUNCID;
777 if ((info->multi == 0) && 766 if ((info->multi == 0) &&
778 ((first_tuple(link, tuple, parse) != CS_SUCCESS) || 767 (link->has_func_id) &&
779 (parse->funcid.func == CISTPL_FUNCID_MULTI) || 768 ((link->func_id == CISTPL_FUNCID_MULTI) ||
780 (parse->funcid.func == CISTPL_FUNCID_SERIAL))) { 769 (link->func_id == CISTPL_FUNCID_SERIAL))) {
781 tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY; 770 tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY;
782 if (first_tuple(link, tuple, parse) == CS_SUCCESS) { 771 if (first_tuple(link, tuple, parse) == CS_SUCCESS) {
783 if ((cf->io.nwin == 1) && (cf->io.win[0].len % 8 == 0)) 772 if ((cf->io.nwin == 1) && (cf->io.win[0].len % 8 == 0))
@@ -814,8 +803,6 @@ static int serial_config(struct pcmcia_device * link)
814 kfree(cfg_mem); 803 kfree(cfg_mem);
815 return 0; 804 return 0;
816 805
817 cs_failed:
818 cs_error(link, last_fn, last_ret);
819 failed: 806 failed:
820 serial_remove(link); 807 serial_remove(link);
821 kfree(cfg_mem); 808 kfree(cfg_mem);
@@ -925,6 +912,30 @@ static struct pcmcia_device_id serial_ids[] = {
925 PCMCIA_DEVICE_CIS_PROD_ID123("ADVANTECH", "COMpad-32/85", "1.0", 0x96913a85, 0x8fbe92ae, 0x0877b627, "COMpad2.cis"), 912 PCMCIA_DEVICE_CIS_PROD_ID123("ADVANTECH", "COMpad-32/85", "1.0", 0x96913a85, 0x8fbe92ae, 0x0877b627, "COMpad2.cis"),
926 PCMCIA_DEVICE_CIS_PROD_ID2("RS-COM 2P", 0xad20b156, "RS-COM-2P.cis"), 913 PCMCIA_DEVICE_CIS_PROD_ID2("RS-COM 2P", 0xad20b156, "RS-COM-2P.cis"),
927 PCMCIA_DEVICE_CIS_MANF_CARD(0x0013, 0x0000, "GLOBETROTTER.cis"), 914 PCMCIA_DEVICE_CIS_MANF_CARD(0x0013, 0x0000, "GLOBETROTTER.cis"),
915 PCMCIA_DEVICE_PROD_ID12("ELAN DIGITAL SYSTEMS LTD, c1997.","SERIAL CARD: SL100 1.00.",0x19ca78af,0xf964f42b),
916 PCMCIA_DEVICE_PROD_ID12("ELAN DIGITAL SYSTEMS LTD, c1997.","SERIAL CARD: SL100",0x19ca78af,0x71d98e83),
917 PCMCIA_DEVICE_PROD_ID12("ELAN DIGITAL SYSTEMS LTD, c1997.","SERIAL CARD: SL232 1.00.",0x19ca78af,0x69fb7490),
918 PCMCIA_DEVICE_PROD_ID12("ELAN DIGITAL SYSTEMS LTD, c1997.","SERIAL CARD: SL232",0x19ca78af,0xb6bc0235),
919 PCMCIA_DEVICE_PROD_ID12("ELAN DIGITAL SYSTEMS LTD, c2000.","SERIAL CARD: CF232",0x63f2e0bd,0xb9e175d3),
920 PCMCIA_DEVICE_PROD_ID12("ELAN DIGITAL SYSTEMS LTD, c2000.","SERIAL CARD: CF232-5",0x63f2e0bd,0xfce33442),
921 PCMCIA_DEVICE_PROD_ID12("Elan","Serial Port: CF232",0x3beb8cf2,0x171e7190),
922 PCMCIA_DEVICE_PROD_ID12("Elan","Serial Port: CF232-5",0x3beb8cf2,0x20da4262),
923 PCMCIA_DEVICE_PROD_ID12("Elan","Serial Port: CF428",0x3beb8cf2,0xea5dd57d),
924 PCMCIA_DEVICE_PROD_ID12("Elan","Serial Port: CF500",0x3beb8cf2,0xd77255fa),
925 PCMCIA_DEVICE_PROD_ID12("Elan","Serial Port: IC232",0x3beb8cf2,0x6a709903),
926 PCMCIA_DEVICE_PROD_ID12("Elan","Serial Port: SL232",0x3beb8cf2,0x18430676),
927 PCMCIA_DEVICE_PROD_ID12("Elan","Serial Port: XL232",0x3beb8cf2,0x6f933767),
928 PCMCIA_MFC_DEVICE_PROD_ID12(0,"Elan","Serial Port: CF332",0x3beb8cf2,0x16dc1ba7),
929 PCMCIA_MFC_DEVICE_PROD_ID12(0,"Elan","Serial Port: SL332",0x3beb8cf2,0x19816c41),
930 PCMCIA_MFC_DEVICE_PROD_ID12(0,"Elan","Serial Port: SL385",0x3beb8cf2,0x64112029),
931 PCMCIA_MFC_DEVICE_PROD_ID12(0,"Elan","Serial Port: SL432",0x3beb8cf2,0x1cce7ac4),
932 PCMCIA_MFC_DEVICE_PROD_ID12(0,"Elan","Serial+Parallel Port: SP230",0x3beb8cf2,0xdb9e58bc),
933 PCMCIA_MFC_DEVICE_PROD_ID12(1,"Elan","Serial Port: CF332",0x3beb8cf2,0x16dc1ba7),
934 PCMCIA_MFC_DEVICE_PROD_ID12(1,"Elan","Serial Port: SL332",0x3beb8cf2,0x19816c41),
935 PCMCIA_MFC_DEVICE_PROD_ID12(1,"Elan","Serial Port: SL385",0x3beb8cf2,0x64112029),
936 PCMCIA_MFC_DEVICE_PROD_ID12(1,"Elan","Serial Port: SL432",0x3beb8cf2,0x1cce7ac4),
937 PCMCIA_MFC_DEVICE_PROD_ID12(2,"Elan","Serial Port: SL432",0x3beb8cf2,0x1cce7ac4),
938 PCMCIA_MFC_DEVICE_PROD_ID12(3,"Elan","Serial Port: SL432",0x3beb8cf2,0x1cce7ac4),
928 /* too generic */ 939 /* too generic */
929 /* PCMCIA_MFC_DEVICE_MANF_CARD(0, 0x0160, 0x0002), */ 940 /* PCMCIA_MFC_DEVICE_MANF_CARD(0, 0x0160, 0x0002), */
930 /* PCMCIA_MFC_DEVICE_MANF_CARD(1, 0x0160, 0x0002), */ 941 /* PCMCIA_MFC_DEVICE_MANF_CARD(1, 0x0160, 0x0002), */
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c
index cfcc3caf49d8..3b5f19ec2126 100644
--- a/drivers/serial/sh-sci.c
+++ b/drivers/serial/sh-sci.c
@@ -775,7 +775,7 @@ static int sci_notifier(struct notifier_block *self,
775 * 775 *
776 * Clean this up later.. 776 * Clean this up later..
777 */ 777 */
778 clk = clk_get("module_clk"); 778 clk = clk_get(NULL, "module_clk");
779 port->uartclk = clk_get_rate(clk) * 16; 779 port->uartclk = clk_get_rate(clk) * 16;
780 clk_put(clk); 780 clk_put(clk);
781 } 781 }
@@ -960,7 +960,7 @@ static void sci_set_termios(struct uart_port *port, struct termios *termios,
960 default: 960 default:
961 { 961 {
962#if defined(CONFIG_SUPERH) && !defined(CONFIG_SUPERH64) 962#if defined(CONFIG_SUPERH) && !defined(CONFIG_SUPERH64)
963 struct clk *clk = clk_get("module_clk"); 963 struct clk *clk = clk_get(NULL, "module_clk");
964 t = SCBRR_VALUE(baud, clk_get_rate(clk)); 964 t = SCBRR_VALUE(baud, clk_get_rate(clk));
965 clk_put(clk); 965 clk_put(clk);
966#else 966#else
@@ -1128,7 +1128,7 @@ static void __init sci_init_ports(void)
1128 * XXX: We should use a proper SCI/SCIF clock 1128 * XXX: We should use a proper SCI/SCIF clock
1129 */ 1129 */
1130 { 1130 {
1131 struct clk *clk = clk_get("module_clk"); 1131 struct clk *clk = clk_get(NULL, "module_clk");
1132 sci_ports[i].port.uartclk = clk_get_rate(clk) * 16; 1132 sci_ports[i].port.uartclk = clk_get_rate(clk) * 16;
1133 clk_put(clk); 1133 clk_put(clk);
1134 } 1134 }
diff --git a/drivers/serial/sh-sci.h b/drivers/serial/sh-sci.h
index 7ee992146ae9..e4557cc4f74b 100644
--- a/drivers/serial/sh-sci.h
+++ b/drivers/serial/sh-sci.h
@@ -133,6 +133,20 @@
133# define SCIF_ORER 0x0001 /* Overrun error bit */ 133# define SCIF_ORER 0x0001 /* Overrun error bit */
134# define SCSCR_INIT(port) 0x3a /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ 134# define SCSCR_INIT(port) 0x3a /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
135# define SCIF_ONLY 135# define SCIF_ONLY
136#elif defined(CONFIG_CPU_SUBTYPE_SH7206)
137# define SCSPTR0 0xfffe8020 /* 16 bit SCIF */
138# define SCSPTR1 0xfffe8820 /* 16 bit SCIF */
139# define SCSPTR2 0xfffe9020 /* 16 bit SCIF */
140# define SCSPTR3 0xfffe9820 /* 16 bit SCIF */
141# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
142# define SCIF_ONLY
143#elif defined(CONFIG_CPU_SUBTYPE_SH7619)
144# define SCSPTR0 0xf8400020 /* 16 bit SCIF */
145# define SCSPTR1 0xf8410020 /* 16 bit SCIF */
146# define SCSPTR2 0xf8420020 /* 16 bit SCIF */
147# define SCIF_ORER 0x0001 /* overrun error bit */
148# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
149# define SCIF_ONLY
136#else 150#else
137# error CPU subtype not defined 151# error CPU subtype not defined
138#endif 152#endif
@@ -365,6 +379,7 @@ SCIx_FNS(SCxSR, 0x08, 8, 0x10, 8, 0x08, 16, 0x10, 16, 0x04, 8)
365SCIx_FNS(SCxRDR, 0x0a, 8, 0x14, 8, 0x0A, 8, 0x14, 8, 0x05, 8) 379SCIx_FNS(SCxRDR, 0x0a, 8, 0x14, 8, 0x0A, 8, 0x14, 8, 0x05, 8)
366SCIF_FNS(SCFCR, 0x0c, 8, 0x18, 16) 380SCIF_FNS(SCFCR, 0x0c, 8, 0x18, 16)
367#if defined(CONFIG_CPU_SUBTYPE_SH7760) || defined(CONFIG_CPU_SUBTYPE_SH7780) 381#if defined(CONFIG_CPU_SUBTYPE_SH7760) || defined(CONFIG_CPU_SUBTYPE_SH7780)
382SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16)
368SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16) 383SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16)
369SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16) 384SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16)
370SCIF_FNS(SCSPTR, 0, 0, 0x24, 16) 385SCIF_FNS(SCSPTR, 0, 0, 0x24, 16)
@@ -544,6 +559,28 @@ static inline int sci_rxd_in(struct uart_port *port)
544 if (port->mapbase == 0xffe10000) 559 if (port->mapbase == 0xffe10000)
545 return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */ 560 return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
546} 561}
562#elif defined(CONFIG_CPU_SUBTYPE_SH7206)
563static inline int sci_rxd_in(struct uart_port *port)
564{
565 if (port->mapbase == 0xfffe8000)
566 return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
567 if (port->mapbase == 0xfffe8800)
568 return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
569 if (port->mapbase == 0xfffe9000)
570 return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
571 if (port->mapbase == 0xfffe9800)
572 return ctrl_inw(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF */
573}
574#elif defined(CONFIG_CPU_SUBTYPE_SH7619)
575static inline int sci_rxd_in(struct uart_port *port)
576{
577 if (port->mapbase == 0xf8400000)
578 return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
579 if (port->mapbase == 0xf8410000)
580 return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
581 if (port->mapbase == 0xf8420000)
582 return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
583}
547#endif 584#endif
548 585
549/* 586/*
diff --git a/drivers/serial/uartlite.c b/drivers/serial/uartlite.c
new file mode 100644
index 000000000000..83690653b78b
--- /dev/null
+++ b/drivers/serial/uartlite.c
@@ -0,0 +1,505 @@
1/*
2 * uartlite.c: Serial driver for Xilinx uartlite serial controller
3 *
4 * Peter Korsgaard <jacmet@sunsite.dk>
5 *
6 * This file is licensed under the terms of the GNU General Public License
7 * version 2. This program is licensed "as is" without any warranty of any
8 * kind, whether express or implied.
9 */
10
11#include <linux/platform_device.h>
12#include <linux/module.h>
13#include <linux/console.h>
14#include <linux/serial.h>
15#include <linux/serial_core.h>
16#include <linux/tty.h>
17#include <linux/delay.h>
18#include <linux/interrupt.h>
19#include <asm/io.h>
20
21#define ULITE_MAJOR 204
22#define ULITE_MINOR 187
23#define ULITE_NR_UARTS 4
24
25/* For register details see datasheet:
26 http://www.xilinx.com/bvdocs/ipcenter/data_sheet/opb_uartlite.pdf
27*/
28#define ULITE_RX 0x00
29#define ULITE_TX 0x04
30#define ULITE_STATUS 0x08
31#define ULITE_CONTROL 0x0c
32
33#define ULITE_REGION 16
34
35#define ULITE_STATUS_RXVALID 0x01
36#define ULITE_STATUS_RXFULL 0x02
37#define ULITE_STATUS_TXEMPTY 0x04
38#define ULITE_STATUS_TXFULL 0x08
39#define ULITE_STATUS_IE 0x10
40#define ULITE_STATUS_OVERRUN 0x20
41#define ULITE_STATUS_FRAME 0x40
42#define ULITE_STATUS_PARITY 0x80
43
44#define ULITE_CONTROL_RST_TX 0x01
45#define ULITE_CONTROL_RST_RX 0x02
46#define ULITE_CONTROL_IE 0x10
47
48
49static struct uart_port ports[ULITE_NR_UARTS];
50
51static int ulite_receive(struct uart_port *port, int stat)
52{
53 struct tty_struct *tty = port->info->tty;
54 unsigned char ch = 0;
55 char flag = TTY_NORMAL;
56
57 if ((stat & (ULITE_STATUS_RXVALID | ULITE_STATUS_OVERRUN
58 | ULITE_STATUS_FRAME)) == 0)
59 return 0;
60
61 /* stats */
62 if (stat & ULITE_STATUS_RXVALID) {
63 port->icount.rx++;
64 ch = readb(port->membase + ULITE_RX);
65
66 if (stat & ULITE_STATUS_PARITY)
67 port->icount.parity++;
68 }
69
70 if (stat & ULITE_STATUS_OVERRUN)
71 port->icount.overrun++;
72
73 if (stat & ULITE_STATUS_FRAME)
74 port->icount.frame++;
75
76
77 /* drop byte with parity error if IGNPAR specificed */
78 if (stat & port->ignore_status_mask & ULITE_STATUS_PARITY)
79 stat &= ~ULITE_STATUS_RXVALID;
80
81 stat &= port->read_status_mask;
82
83 if (stat & ULITE_STATUS_PARITY)
84 flag = TTY_PARITY;
85
86
87 stat &= ~port->ignore_status_mask;
88
89 if (stat & ULITE_STATUS_RXVALID)
90 tty_insert_flip_char(tty, ch, flag);
91
92 if (stat & ULITE_STATUS_FRAME)
93 tty_insert_flip_char(tty, 0, TTY_FRAME);
94
95 if (stat & ULITE_STATUS_OVERRUN)
96 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
97
98 return 1;
99}
100
101static int ulite_transmit(struct uart_port *port, int stat)
102{
103 struct circ_buf *xmit = &port->info->xmit;
104
105 if (stat & ULITE_STATUS_TXFULL)
106 return 0;
107
108 if (port->x_char) {
109 writeb(port->x_char, port->membase + ULITE_TX);
110 port->x_char = 0;
111 port->icount.tx++;
112 return 1;
113 }
114
115 if (uart_circ_empty(xmit) || uart_tx_stopped(port))
116 return 0;
117
118 writeb(xmit->buf[xmit->tail], port->membase + ULITE_TX);
119 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE-1);
120 port->icount.tx++;
121
122 /* wake up */
123 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
124 uart_write_wakeup(port);
125
126 return 1;
127}
128
129static irqreturn_t ulite_isr(int irq, void *dev_id)
130{
131 struct uart_port *port = (struct uart_port *)dev_id;
132 int busy;
133
134 do {
135 int stat = readb(port->membase + ULITE_STATUS);
136 busy = ulite_receive(port, stat);
137 busy |= ulite_transmit(port, stat);
138 } while (busy);
139
140 tty_flip_buffer_push(port->info->tty);
141
142 return IRQ_HANDLED;
143}
144
145static unsigned int ulite_tx_empty(struct uart_port *port)
146{
147 unsigned long flags;
148 unsigned int ret;
149
150 spin_lock_irqsave(&port->lock, flags);
151 ret = readb(port->membase + ULITE_STATUS);
152 spin_unlock_irqrestore(&port->lock, flags);
153
154 return ret & ULITE_STATUS_TXEMPTY ? TIOCSER_TEMT : 0;
155}
156
157static unsigned int ulite_get_mctrl(struct uart_port *port)
158{
159 return TIOCM_CTS | TIOCM_DSR | TIOCM_CAR;
160}
161
162static void ulite_set_mctrl(struct uart_port *port, unsigned int mctrl)
163{
164 /* N/A */
165}
166
167static void ulite_stop_tx(struct uart_port *port)
168{
169 /* N/A */
170}
171
172static void ulite_start_tx(struct uart_port *port)
173{
174 ulite_transmit(port, readb(port->membase + ULITE_STATUS));
175}
176
177static void ulite_stop_rx(struct uart_port *port)
178{
179 /* don't forward any more data (like !CREAD) */
180 port->ignore_status_mask = ULITE_STATUS_RXVALID | ULITE_STATUS_PARITY
181 | ULITE_STATUS_FRAME | ULITE_STATUS_OVERRUN;
182}
183
184static void ulite_enable_ms(struct uart_port *port)
185{
186 /* N/A */
187}
188
189static void ulite_break_ctl(struct uart_port *port, int ctl)
190{
191 /* N/A */
192}
193
194static int ulite_startup(struct uart_port *port)
195{
196 int ret;
197
198 ret = request_irq(port->irq, ulite_isr,
199 IRQF_DISABLED | IRQF_SAMPLE_RANDOM, "uartlite", port);
200 if (ret)
201 return ret;
202
203 writeb(ULITE_CONTROL_RST_RX | ULITE_CONTROL_RST_TX,
204 port->membase + ULITE_CONTROL);
205 writeb(ULITE_CONTROL_IE, port->membase + ULITE_CONTROL);
206
207 return 0;
208}
209
210static void ulite_shutdown(struct uart_port *port)
211{
212 writeb(0, port->membase + ULITE_CONTROL);
213 readb(port->membase + ULITE_CONTROL); /* dummy */
214 free_irq(port->irq, port);
215}
216
217static void ulite_set_termios(struct uart_port *port, struct termios *termios,
218 struct termios *old)
219{
220 unsigned long flags;
221 unsigned int baud;
222
223 spin_lock_irqsave(&port->lock, flags);
224
225 port->read_status_mask = ULITE_STATUS_RXVALID | ULITE_STATUS_OVERRUN
226 | ULITE_STATUS_TXFULL;
227
228 if (termios->c_iflag & INPCK)
229 port->read_status_mask |=
230 ULITE_STATUS_PARITY | ULITE_STATUS_FRAME;
231
232 port->ignore_status_mask = 0;
233 if (termios->c_iflag & IGNPAR)
234 port->ignore_status_mask |= ULITE_STATUS_PARITY
235 | ULITE_STATUS_FRAME | ULITE_STATUS_OVERRUN;
236
237 /* ignore all characters if CREAD is not set */
238 if ((termios->c_cflag & CREAD) == 0)
239 port->ignore_status_mask |=
240 ULITE_STATUS_RXVALID | ULITE_STATUS_PARITY
241 | ULITE_STATUS_FRAME | ULITE_STATUS_OVERRUN;
242
243 /* update timeout */
244 baud = uart_get_baud_rate(port, termios, old, 0, 460800);
245 uart_update_timeout(port, termios->c_cflag, baud);
246
247 spin_unlock_irqrestore(&port->lock, flags);
248}
249
250static const char *ulite_type(struct uart_port *port)
251{
252 return port->type == PORT_UARTLITE ? "uartlite" : NULL;
253}
254
255static void ulite_release_port(struct uart_port *port)
256{
257 release_mem_region(port->mapbase, ULITE_REGION);
258 iounmap(port->membase);
259 port->membase = 0;
260}
261
262static int ulite_request_port(struct uart_port *port)
263{
264 if (!request_mem_region(port->mapbase, ULITE_REGION, "uartlite")) {
265 dev_err(port->dev, "Memory region busy\n");
266 return -EBUSY;
267 }
268
269 port->membase = ioremap(port->mapbase, ULITE_REGION);
270 if (!port->membase) {
271 dev_err(port->dev, "Unable to map registers\n");
272 release_mem_region(port->mapbase, ULITE_REGION);
273 return -EBUSY;
274 }
275
276 return 0;
277}
278
279static void ulite_config_port(struct uart_port *port, int flags)
280{
281 ulite_request_port(port);
282 port->type = PORT_UARTLITE;
283}
284
285static int ulite_verify_port(struct uart_port *port, struct serial_struct *ser)
286{
287 /* we don't want the core code to modify any port params */
288 return -EINVAL;
289}
290
291static struct uart_ops ulite_ops = {
292 .tx_empty = ulite_tx_empty,
293 .set_mctrl = ulite_set_mctrl,
294 .get_mctrl = ulite_get_mctrl,
295 .stop_tx = ulite_stop_tx,
296 .start_tx = ulite_start_tx,
297 .stop_rx = ulite_stop_rx,
298 .enable_ms = ulite_enable_ms,
299 .break_ctl = ulite_break_ctl,
300 .startup = ulite_startup,
301 .shutdown = ulite_shutdown,
302 .set_termios = ulite_set_termios,
303 .type = ulite_type,
304 .release_port = ulite_release_port,
305 .request_port = ulite_request_port,
306 .config_port = ulite_config_port,
307 .verify_port = ulite_verify_port
308};
309
310#ifdef CONFIG_SERIAL_UARTLITE_CONSOLE
311static void ulite_console_wait_tx(struct uart_port *port)
312{
313 int i;
314
315 /* wait up to 10ms for the character(s) to be sent */
316 for (i = 0; i < 10000; i++) {
317 if (readb(port->membase + ULITE_STATUS) & ULITE_STATUS_TXEMPTY)
318 break;
319 udelay(1);
320 }
321}
322
323static void ulite_console_putchar(struct uart_port *port, int ch)
324{
325 ulite_console_wait_tx(port);
326 writeb(ch, port->membase + ULITE_TX);
327}
328
329static void ulite_console_write(struct console *co, const char *s,
330 unsigned int count)
331{
332 struct uart_port *port = &ports[co->index];
333 unsigned long flags;
334 unsigned int ier;
335 int locked = 1;
336
337 if (oops_in_progress) {
338 locked = spin_trylock_irqsave(&port->lock, flags);
339 } else
340 spin_lock_irqsave(&port->lock, flags);
341
342 /* save and disable interrupt */
343 ier = readb(port->membase + ULITE_STATUS) & ULITE_STATUS_IE;
344 writeb(0, port->membase + ULITE_CONTROL);
345
346 uart_console_write(port, s, count, ulite_console_putchar);
347
348 ulite_console_wait_tx(port);
349
350 /* restore interrupt state */
351 if (ier)
352 writeb(ULITE_CONTROL_IE, port->membase + ULITE_CONTROL);
353
354 if (locked)
355 spin_unlock_irqrestore(&port->lock, flags);
356}
357
358static int __init ulite_console_setup(struct console *co, char *options)
359{
360 struct uart_port *port;
361 int baud = 9600;
362 int bits = 8;
363 int parity = 'n';
364 int flow = 'n';
365
366 if (co->index < 0 || co->index >= ULITE_NR_UARTS)
367 return -EINVAL;
368
369 port = &ports[co->index];
370
371 /* not initialized yet? */
372 if (!port->membase)
373 return -ENODEV;
374
375 if (options)
376 uart_parse_options(options, &baud, &parity, &bits, &flow);
377
378 return uart_set_options(port, co, baud, parity, bits, flow);
379}
380
381static struct uart_driver ulite_uart_driver;
382
383static struct console ulite_console = {
384 .name = "ttyUL",
385 .write = ulite_console_write,
386 .device = uart_console_device,
387 .setup = ulite_console_setup,
388 .flags = CON_PRINTBUFFER,
389 .index = -1, /* Specified on the cmdline (e.g. console=ttyUL0 ) */
390 .data = &ulite_uart_driver,
391};
392
393static int __init ulite_console_init(void)
394{
395 register_console(&ulite_console);
396 return 0;
397}
398
399console_initcall(ulite_console_init);
400
401#endif /* CONFIG_SERIAL_UARTLITE_CONSOLE */
402
403static struct uart_driver ulite_uart_driver = {
404 .owner = THIS_MODULE,
405 .driver_name = "uartlite",
406 .dev_name = "ttyUL",
407 .major = ULITE_MAJOR,
408 .minor = ULITE_MINOR,
409 .nr = ULITE_NR_UARTS,
410#ifdef CONFIG_SERIAL_UARTLITE_CONSOLE
411 .cons = &ulite_console,
412#endif
413};
414
415static int __devinit ulite_probe(struct platform_device *pdev)
416{
417 struct resource *res, *res2;
418 struct uart_port *port;
419
420 if (pdev->id < 0 || pdev->id >= ULITE_NR_UARTS)
421 return -EINVAL;
422
423 if (ports[pdev->id].membase)
424 return -EBUSY;
425
426 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
427 if (!res)
428 return -ENODEV;
429
430 res2 = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
431 if (!res2)
432 return -ENODEV;
433
434 port = &ports[pdev->id];
435
436 port->fifosize = 16;
437 port->regshift = 2;
438 port->iotype = UPIO_MEM;
439 port->iobase = 1; /* mark port in use */
440 port->mapbase = res->start;
441 port->membase = 0;
442 port->ops = &ulite_ops;
443 port->irq = res2->start;
444 port->flags = UPF_BOOT_AUTOCONF;
445 port->dev = &pdev->dev;
446 port->type = PORT_UNKNOWN;
447 port->line = pdev->id;
448
449 uart_add_one_port(&ulite_uart_driver, port);
450 platform_set_drvdata(pdev, port);
451
452 return 0;
453}
454
455static int ulite_remove(struct platform_device *pdev)
456{
457 struct uart_port *port = platform_get_drvdata(pdev);
458
459 platform_set_drvdata(pdev, NULL);
460
461 if (port)
462 uart_remove_one_port(&ulite_uart_driver, port);
463
464 /* mark port as free */
465 port->membase = 0;
466
467 return 0;
468}
469
470static struct platform_driver ulite_platform_driver = {
471 .probe = ulite_probe,
472 .remove = ulite_remove,
473 .driver = {
474 .owner = THIS_MODULE,
475 .name = "uartlite",
476 },
477};
478
479int __init ulite_init(void)
480{
481 int ret;
482
483 ret = uart_register_driver(&ulite_uart_driver);
484 if (ret)
485 return ret;
486
487 ret = platform_driver_register(&ulite_platform_driver);
488 if (ret)
489 uart_unregister_driver(&ulite_uart_driver);
490
491 return ret;
492}
493
494void __exit ulite_exit(void)
495{
496 platform_driver_unregister(&ulite_platform_driver);
497 uart_unregister_driver(&ulite_uart_driver);
498}
499
500module_init(ulite_init);
501module_exit(ulite_exit);
502
503MODULE_AUTHOR("Peter Korsgaard <jacmet@sunsite.dk>");
504MODULE_DESCRIPTION("Xilinx uartlite serial driver");
505MODULE_LICENSE("GPL");
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index 23334c8bc4c7..d895a1adb428 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -16,7 +16,7 @@ config SPI
16 controller and a chipselect. Most SPI slaves don't support 16 controller and a chipselect. Most SPI slaves don't support
17 dynamic device discovery; some are even write-only or read-only. 17 dynamic device discovery; some are even write-only or read-only.
18 18
19 SPI is widely used by microcontollers to talk with sensors, 19 SPI is widely used by microcontrollers to talk with sensors,
20 eeprom and flash memory, codecs and various other controller 20 eeprom and flash memory, codecs and various other controller
21 chips, analog to digital (and d-to-a) converters, and more. 21 chips, analog to digital (and d-to-a) converters, and more.
22 MMC and SD cards can be accessed using SPI protocol; and for 22 MMC and SD cards can be accessed using SPI protocol; and for
diff --git a/drivers/spi/pxa2xx_spi.c b/drivers/spi/pxa2xx_spi.c
index 72025df5561d..494d9b856488 100644
--- a/drivers/spi/pxa2xx_spi.c
+++ b/drivers/spi/pxa2xx_spi.c
@@ -148,7 +148,7 @@ struct chip_data {
148 void (*cs_control)(u32 command); 148 void (*cs_control)(u32 command);
149}; 149};
150 150
151static void pump_messages(void *data); 151static void pump_messages(struct work_struct *work);
152 152
153static int flush(struct driver_data *drv_data) 153static int flush(struct driver_data *drv_data)
154{ 154{
@@ -884,9 +884,10 @@ static void pump_transfers(unsigned long data)
884 } 884 }
885} 885}
886 886
887static void pump_messages(void *data) 887static void pump_messages(struct work_struct *work)
888{ 888{
889 struct driver_data *drv_data = data; 889 struct driver_data *drv_data =
890 container_of(work, struct driver_data, pump_messages);
890 unsigned long flags; 891 unsigned long flags;
891 892
892 /* Lock queue and check for queue work */ 893 /* Lock queue and check for queue work */
@@ -1098,7 +1099,7 @@ static int init_queue(struct driver_data *drv_data)
1098 tasklet_init(&drv_data->pump_transfers, 1099 tasklet_init(&drv_data->pump_transfers,
1099 pump_transfers, (unsigned long)drv_data); 1100 pump_transfers, (unsigned long)drv_data);
1100 1101
1101 INIT_WORK(&drv_data->pump_messages, pump_messages, drv_data); 1102 INIT_WORK(&drv_data->pump_messages, pump_messages);
1102 drv_data->workqueue = create_singlethread_workqueue( 1103 drv_data->workqueue = create_singlethread_workqueue(
1103 drv_data->master->cdev.dev->bus_id); 1104 drv_data->master->cdev.dev->bus_id);
1104 if (drv_data->workqueue == NULL) 1105 if (drv_data->workqueue == NULL)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index c3c0626f550b..270e6211c2e3 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -360,12 +360,13 @@ spi_alloc_master(struct device *dev, unsigned size)
360 if (!dev) 360 if (!dev)
361 return NULL; 361 return NULL;
362 362
363 master = kzalloc(size + sizeof *master, SLAB_KERNEL); 363 master = kzalloc(size + sizeof *master, GFP_KERNEL);
364 if (!master) 364 if (!master)
365 return NULL; 365 return NULL;
366 366
367 class_device_initialize(&master->cdev); 367 class_device_initialize(&master->cdev);
368 master->cdev.class = &spi_master_class; 368 master->cdev.class = &spi_master_class;
369 kobj_set_kset_s(&master->cdev, spi_master_class.subsys);
369 master->cdev.dev = get_device(dev); 370 master->cdev.dev = get_device(dev);
370 spi_master_set_devdata(master, &master[1]); 371 spi_master_set_devdata(master, &master[1]);
371 372
@@ -447,7 +448,9 @@ static int __unregister(struct device *dev, void *unused)
447 */ 448 */
448void spi_unregister_master(struct spi_master *master) 449void spi_unregister_master(struct spi_master *master)
449{ 450{
450 (void) device_for_each_child(master->cdev.dev, NULL, __unregister); 451 int dummy;
452
453 dummy = device_for_each_child(master->cdev.dev, NULL, __unregister);
451 class_device_unregister(&master->cdev); 454 class_device_unregister(&master->cdev);
452} 455}
453EXPORT_SYMBOL_GPL(spi_unregister_master); 456EXPORT_SYMBOL_GPL(spi_unregister_master);
@@ -463,15 +466,13 @@ EXPORT_SYMBOL_GPL(spi_unregister_master);
463 */ 466 */
464struct spi_master *spi_busnum_to_master(u16 bus_num) 467struct spi_master *spi_busnum_to_master(u16 bus_num)
465{ 468{
466 if (bus_num) { 469 char name[9];
467 char name[8]; 470 struct kobject *bus;
468 struct kobject *bus; 471
469 472 snprintf(name, sizeof name, "spi%u", bus_num);
470 snprintf(name, sizeof name, "spi%u", bus_num); 473 bus = kset_find_obj(&spi_master_class.subsys.kset, name);
471 bus = kset_find_obj(&spi_master_class.subsys.kset, name); 474 if (bus)
472 if (bus) 475 return container_of(bus, struct spi_master, cdev.kobj);
473 return container_of(bus, struct spi_master, cdev.kobj);
474 }
475 return NULL; 476 return NULL;
476} 477}
477EXPORT_SYMBOL_GPL(spi_busnum_to_master); 478EXPORT_SYMBOL_GPL(spi_busnum_to_master);
@@ -607,7 +608,7 @@ static int __init spi_init(void)
607{ 608{
608 int status; 609 int status;
609 610
610 buf = kmalloc(SPI_BUFSIZ, SLAB_KERNEL); 611 buf = kmalloc(SPI_BUFSIZ, GFP_KERNEL);
611 if (!buf) { 612 if (!buf) {
612 status = -ENOMEM; 613 status = -ENOMEM;
613 goto err0; 614 goto err0;
diff --git a/drivers/spi/spi_bitbang.c b/drivers/spi/spi_bitbang.c
index a23862ef72b2..57289b61d0be 100644
--- a/drivers/spi/spi_bitbang.c
+++ b/drivers/spi/spi_bitbang.c
@@ -196,7 +196,7 @@ int spi_bitbang_setup(struct spi_device *spi)
196 return -EINVAL; 196 return -EINVAL;
197 197
198 if (!cs) { 198 if (!cs) {
199 cs = kzalloc(sizeof *cs, SLAB_KERNEL); 199 cs = kzalloc(sizeof *cs, GFP_KERNEL);
200 if (!cs) 200 if (!cs)
201 return -ENOMEM; 201 return -ENOMEM;
202 spi->controller_state = cs; 202 spi->controller_state = cs;
@@ -265,9 +265,10 @@ static int spi_bitbang_bufs(struct spi_device *spi, struct spi_transfer *t)
265 * Drivers can provide word-at-a-time i/o primitives, or provide 265 * Drivers can provide word-at-a-time i/o primitives, or provide
266 * transfer-at-a-time ones to leverage dma or fifo hardware. 266 * transfer-at-a-time ones to leverage dma or fifo hardware.
267 */ 267 */
268static void bitbang_work(void *_bitbang) 268static void bitbang_work(struct work_struct *work)
269{ 269{
270 struct spi_bitbang *bitbang = _bitbang; 270 struct spi_bitbang *bitbang =
271 container_of(work, struct spi_bitbang, work);
271 unsigned long flags; 272 unsigned long flags;
272 273
273 spin_lock_irqsave(&bitbang->lock, flags); 274 spin_lock_irqsave(&bitbang->lock, flags);
@@ -456,7 +457,7 @@ int spi_bitbang_start(struct spi_bitbang *bitbang)
456 if (!bitbang->master || !bitbang->chipselect) 457 if (!bitbang->master || !bitbang->chipselect)
457 return -EINVAL; 458 return -EINVAL;
458 459
459 INIT_WORK(&bitbang->work, bitbang_work, bitbang); 460 INIT_WORK(&bitbang->work, bitbang_work);
460 spin_lock_init(&bitbang->lock); 461 spin_lock_init(&bitbang->lock);
461 INIT_LIST_HEAD(&bitbang->queue); 462 INIT_LIST_HEAD(&bitbang->queue);
462 463
diff --git a/drivers/spi/spi_butterfly.c b/drivers/spi/spi_butterfly.c
index 39d9b20f2038..312987a03210 100644
--- a/drivers/spi/spi_butterfly.c
+++ b/drivers/spi/spi_butterfly.c
@@ -23,6 +23,7 @@
23#include <linux/platform_device.h> 23#include <linux/platform_device.h>
24#include <linux/parport.h> 24#include <linux/parport.h>
25 25
26#include <linux/sched.h>
26#include <linux/spi/spi.h> 27#include <linux/spi/spi.h>
27#include <linux/spi/spi_bitbang.h> 28#include <linux/spi/spi_bitbang.h>
28#include <linux/spi/flash.h> 29#include <linux/spi/flash.h>
@@ -250,6 +251,8 @@ static void butterfly_attach(struct parport *p)
250 * setting up a platform device like this is an ugly kluge... 251 * setting up a platform device like this is an ugly kluge...
251 */ 252 */
252 pdev = platform_device_register_simple("butterfly", -1, NULL, 0); 253 pdev = platform_device_register_simple("butterfly", -1, NULL, 0);
254 if (IS_ERR(pdev))
255 return;
253 256
254 master = spi_alloc_master(&pdev->dev, sizeof *pp); 257 master = spi_alloc_master(&pdev->dev, sizeof *pp);
255 if (!master) { 258 if (!master) {
diff --git a/drivers/telephony/ixj.h b/drivers/telephony/ixj.h
index fbea4541c234..8d69bcdc29c9 100644
--- a/drivers/telephony/ixj.h
+++ b/drivers/telephony/ixj.h
@@ -1295,7 +1295,7 @@ typedef struct {
1295 Proc_Info_Type Info_write; 1295 Proc_Info_Type Info_write;
1296 unsigned short frame_count; 1296 unsigned short frame_count;
1297 unsigned int filter_hist[4]; 1297 unsigned int filter_hist[4];
1298 unsigned char filter_en[4]; 1298 unsigned char filter_en[6];
1299 unsigned short proc_load; 1299 unsigned short proc_load;
1300 unsigned long framesread; 1300 unsigned long framesread;
1301 unsigned long frameswritten; 1301 unsigned long frameswritten;
diff --git a/drivers/telephony/ixj_pcmcia.c b/drivers/telephony/ixj_pcmcia.c
index dda0ca45d904..164a5dcf1f1e 100644
--- a/drivers/telephony/ixj_pcmcia.c
+++ b/drivers/telephony/ixj_pcmcia.c
@@ -69,25 +69,21 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
69 69
70static void ixj_get_serial(struct pcmcia_device * link, IXJ * j) 70static void ixj_get_serial(struct pcmcia_device * link, IXJ * j)
71{ 71{
72 tuple_t tuple;
73 u_short buf[128];
74 char *str; 72 char *str;
75 int last_ret, last_fn, i, place; 73 int i, place;
76 DEBUG(0, "ixj_get_serial(0x%p)\n", link); 74 DEBUG(0, "ixj_get_serial(0x%p)\n", link);
77 tuple.TupleData = (cisdata_t *) buf; 75
78 tuple.TupleOffset = 0; 76 str = link->prod_id[0];
79 tuple.TupleDataMax = 80; 77 if (!str)
80 tuple.Attributes = 0; 78 goto cs_failed;
81 tuple.DesiredTuple = CISTPL_VERS_1;
82 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
83 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
84 str = (char *) buf;
85 printk("PCMCIA Version %d.%d\n", str[0], str[1]);
86 str += 2;
87 printk("%s", str); 79 printk("%s", str);
88 str = str + strlen(str) + 1; 80 str = link->prod_id[1];
81 if (!str)
82 goto cs_failed;
89 printk(" %s", str); 83 printk(" %s", str);
90 str = str + strlen(str) + 1; 84 str = link->prod_id[2];
85 if (!str)
86 goto cs_failed;
91 place = 1; 87 place = 1;
92 for (i = strlen(str) - 1; i >= 0; i--) { 88 for (i = strlen(str) - 1; i >= 0; i--) {
93 switch (str[i]) { 89 switch (str[i]) {
@@ -122,7 +118,9 @@ static void ixj_get_serial(struct pcmcia_device * link, IXJ * j)
122 } 118 }
123 place = place * 0x10; 119 place = place * 0x10;
124 } 120 }
125 str = str + strlen(str) + 1; 121 str = link->prod_id[3];
122 if (!str)
123 goto cs_failed;
126 printk(" version %s\n", str); 124 printk(" version %s\n", str);
127 cs_failed: 125 cs_failed:
128 return; 126 return;
@@ -146,13 +144,6 @@ static int ixj_config(struct pcmcia_device * link)
146 tuple.TupleData = (cisdata_t *) buf; 144 tuple.TupleData = (cisdata_t *) buf;
147 tuple.TupleOffset = 0; 145 tuple.TupleOffset = 0;
148 tuple.TupleDataMax = 255; 146 tuple.TupleDataMax = 255;
149 tuple.Attributes = 0;
150 tuple.DesiredTuple = CISTPL_CONFIG;
151 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
152 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
153 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
154 link->conf.ConfigBase = parse.config.base;
155 link->conf.Present = parse.config.rmask[0];
156 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 147 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
157 tuple.Attributes = 0; 148 tuple.Attributes = 0;
158 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 149 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig
index f9b1719b9a37..9980a4ddfed9 100644
--- a/drivers/usb/Kconfig
+++ b/drivers/usb/Kconfig
@@ -24,7 +24,7 @@ config USB_ARCH_HAS_OHCI
24 default y if ARCH_S3C2410 24 default y if ARCH_S3C2410
25 default y if PXA27x 25 default y if PXA27x
26 default y if ARCH_EP93XX 26 default y if ARCH_EP93XX
27 default y if (ARCH_AT91RM9200 || ARCH_AT91SAM9261) 27 default y if ARCH_AT91
28 default y if ARCH_PNX4008 28 default y if ARCH_PNX4008
29 # PPC: 29 # PPC:
30 default y if STB03xxx 30 default y if STB03xxx
diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
index e6565633ba0f..3dfa3e40e148 100644
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -158,7 +158,7 @@ struct cxacru_data {
158 const struct cxacru_modem_type *modem_type; 158 const struct cxacru_modem_type *modem_type;
159 159
160 int line_status; 160 int line_status;
161 struct work_struct poll_work; 161 struct delayed_work poll_work;
162 162
163 /* contol handles */ 163 /* contol handles */
164 struct mutex cm_serialize; 164 struct mutex cm_serialize;
@@ -347,7 +347,7 @@ static int cxacru_card_status(struct cxacru_data *instance)
347 return 0; 347 return 0;
348} 348}
349 349
350static void cxacru_poll_status(struct cxacru_data *instance); 350static void cxacru_poll_status(struct work_struct *work);
351 351
352static int cxacru_atm_start(struct usbatm_data *usbatm_instance, 352static int cxacru_atm_start(struct usbatm_data *usbatm_instance,
353 struct atm_dev *atm_dev) 353 struct atm_dev *atm_dev)
@@ -376,12 +376,14 @@ static int cxacru_atm_start(struct usbatm_data *usbatm_instance,
376 } 376 }
377 377
378 /* Start status polling */ 378 /* Start status polling */
379 cxacru_poll_status(instance); 379 cxacru_poll_status(&instance->poll_work.work);
380 return 0; 380 return 0;
381} 381}
382 382
383static void cxacru_poll_status(struct cxacru_data *instance) 383static void cxacru_poll_status(struct work_struct *work)
384{ 384{
385 struct cxacru_data *instance =
386 container_of(work, struct cxacru_data, poll_work.work);
385 u32 buf[CXINF_MAX] = {}; 387 u32 buf[CXINF_MAX] = {};
386 struct usbatm_data *usbatm = instance->usbatm; 388 struct usbatm_data *usbatm = instance->usbatm;
387 struct atm_dev *atm_dev = usbatm->atm_dev; 389 struct atm_dev *atm_dev = usbatm->atm_dev;
@@ -720,7 +722,7 @@ static int cxacru_bind(struct usbatm_data *usbatm_instance,
720 722
721 mutex_init(&instance->cm_serialize); 723 mutex_init(&instance->cm_serialize);
722 724
723 INIT_WORK(&instance->poll_work, (void *)cxacru_poll_status, instance); 725 INIT_DELAYED_WORK(&instance->poll_work, cxacru_poll_status);
724 726
725 usbatm_instance->driver_data = instance; 727 usbatm_instance->driver_data = instance;
726 728
diff --git a/drivers/usb/atm/speedtch.c b/drivers/usb/atm/speedtch.c
index c870c804470f..8ed6c75adf0f 100644
--- a/drivers/usb/atm/speedtch.c
+++ b/drivers/usb/atm/speedtch.c
@@ -142,7 +142,7 @@ struct speedtch_instance_data {
142 142
143 struct speedtch_params params; /* set in probe, constant afterwards */ 143 struct speedtch_params params; /* set in probe, constant afterwards */
144 144
145 struct work_struct status_checker; 145 struct delayed_work status_checker;
146 146
147 unsigned char last_status; 147 unsigned char last_status;
148 148
@@ -498,8 +498,11 @@ static int speedtch_start_synchro(struct speedtch_instance_data *instance)
498 return ret; 498 return ret;
499} 499}
500 500
501static void speedtch_check_status(struct speedtch_instance_data *instance) 501static void speedtch_check_status(struct work_struct *work)
502{ 502{
503 struct speedtch_instance_data *instance =
504 container_of(work, struct speedtch_instance_data,
505 status_checker.work);
503 struct usbatm_data *usbatm = instance->usbatm; 506 struct usbatm_data *usbatm = instance->usbatm;
504 struct atm_dev *atm_dev = usbatm->atm_dev; 507 struct atm_dev *atm_dev = usbatm->atm_dev;
505 unsigned char *buf = instance->scratch_buffer; 508 unsigned char *buf = instance->scratch_buffer;
@@ -576,7 +579,7 @@ static void speedtch_status_poll(unsigned long data)
576{ 579{
577 struct speedtch_instance_data *instance = (void *)data; 580 struct speedtch_instance_data *instance = (void *)data;
578 581
579 schedule_work(&instance->status_checker); 582 schedule_delayed_work(&instance->status_checker, 0);
580 583
581 /* The following check is racy, but the race is harmless */ 584 /* The following check is racy, but the race is harmless */
582 if (instance->poll_delay < MAX_POLL_DELAY) 585 if (instance->poll_delay < MAX_POLL_DELAY)
@@ -596,7 +599,7 @@ static void speedtch_resubmit_int(unsigned long data)
596 if (int_urb) { 599 if (int_urb) {
597 ret = usb_submit_urb(int_urb, GFP_ATOMIC); 600 ret = usb_submit_urb(int_urb, GFP_ATOMIC);
598 if (!ret) 601 if (!ret)
599 schedule_work(&instance->status_checker); 602 schedule_delayed_work(&instance->status_checker, 0);
600 else { 603 else {
601 atm_dbg(instance->usbatm, "%s: usb_submit_urb failed with result %d\n", __func__, ret); 604 atm_dbg(instance->usbatm, "%s: usb_submit_urb failed with result %d\n", __func__, ret);
602 mod_timer(&instance->resubmit_timer, jiffies + msecs_to_jiffies(RESUBMIT_DELAY)); 605 mod_timer(&instance->resubmit_timer, jiffies + msecs_to_jiffies(RESUBMIT_DELAY));
@@ -640,7 +643,7 @@ static void speedtch_handle_int(struct urb *int_urb)
640 643
641 if ((int_urb = instance->int_urb)) { 644 if ((int_urb = instance->int_urb)) {
642 ret = usb_submit_urb(int_urb, GFP_ATOMIC); 645 ret = usb_submit_urb(int_urb, GFP_ATOMIC);
643 schedule_work(&instance->status_checker); 646 schedule_delayed_work(&instance->status_checker, 0);
644 if (ret < 0) { 647 if (ret < 0) {
645 atm_dbg(usbatm, "%s: usb_submit_urb failed with result %d\n", __func__, ret); 648 atm_dbg(usbatm, "%s: usb_submit_urb failed with result %d\n", __func__, ret);
646 goto fail; 649 goto fail;
@@ -834,8 +837,8 @@ static int speedtch_bind(struct usbatm_data *usbatm,
834 const struct usb_endpoint_descriptor *endpoint_desc = &desc->endpoint[i].desc; 837 const struct usb_endpoint_descriptor *endpoint_desc = &desc->endpoint[i].desc;
835 838
836 if ((endpoint_desc->bEndpointAddress == target_address)) { 839 if ((endpoint_desc->bEndpointAddress == target_address)) {
837 use_isoc = (endpoint_desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == 840 use_isoc =
838 USB_ENDPOINT_XFER_ISOC; 841 usb_endpoint_xfer_isoc(endpoint_desc);
839 break; 842 break;
840 } 843 }
841 } 844 }
@@ -855,7 +858,7 @@ static int speedtch_bind(struct usbatm_data *usbatm,
855 858
856 usbatm->flags |= (use_isoc ? UDSL_USE_ISOC : 0); 859 usbatm->flags |= (use_isoc ? UDSL_USE_ISOC : 0);
857 860
858 INIT_WORK(&instance->status_checker, (void *)speedtch_check_status, instance); 861 INIT_DELAYED_WORK(&instance->status_checker, speedtch_check_status);
859 862
860 instance->status_checker.timer.function = speedtch_status_poll; 863 instance->status_checker.timer.function = speedtch_status_poll;
861 instance->status_checker.timer.data = (unsigned long)instance; 864 instance->status_checker.timer.data = (unsigned long)instance;
diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c
index f6b9f7e1f716..dae4ef1e8fe5 100644
--- a/drivers/usb/atm/ueagle-atm.c
+++ b/drivers/usb/atm/ueagle-atm.c
@@ -64,6 +64,8 @@
64#include <linux/kthread.h> 64#include <linux/kthread.h>
65#include <linux/version.h> 65#include <linux/version.h>
66#include <linux/mutex.h> 66#include <linux/mutex.h>
67#include <linux/freezer.h>
68
67#include <asm/unaligned.h> 69#include <asm/unaligned.h>
68 70
69#include "usbatm.h" 71#include "usbatm.h"
@@ -401,9 +403,8 @@ static int uea_send_modem_cmd(struct usb_device *usb,
401 int ret = -ENOMEM; 403 int ret = -ENOMEM;
402 u8 *xfer_buff; 404 u8 *xfer_buff;
403 405
404 xfer_buff = kmalloc(size, GFP_KERNEL); 406 xfer_buff = kmemdup(buff, size, GFP_KERNEL);
405 if (xfer_buff) { 407 if (xfer_buff) {
406 memcpy(xfer_buff, buff, size);
407 ret = usb_control_msg(usb, 408 ret = usb_control_msg(usb,
408 usb_sndctrlpipe(usb, 0), 409 usb_sndctrlpipe(usb, 0),
409 LOAD_INTERNAL, 410 LOAD_INTERNAL,
@@ -595,14 +596,12 @@ static int uea_idma_write(struct uea_softc *sc, void *data, u32 size)
595 u8 *xfer_buff; 596 u8 *xfer_buff;
596 int bytes_read; 597 int bytes_read;
597 598
598 xfer_buff = kmalloc(size, GFP_KERNEL); 599 xfer_buff = kmemdup(data, size, GFP_KERNEL);
599 if (!xfer_buff) { 600 if (!xfer_buff) {
600 uea_err(INS_TO_USBDEV(sc), "can't allocate xfer_buff\n"); 601 uea_err(INS_TO_USBDEV(sc), "can't allocate xfer_buff\n");
601 return ret; 602 return ret;
602 } 603 }
603 604
604 memcpy(xfer_buff, data, size);
605
606 ret = usb_bulk_msg(sc->usb_dev, 605 ret = usb_bulk_msg(sc->usb_dev,
607 usb_sndbulkpipe(sc->usb_dev, UEA_IDMA_PIPE), 606 usb_sndbulkpipe(sc->usb_dev, UEA_IDMA_PIPE),
608 xfer_buff, size, &bytes_read, BULK_TIMEOUT); 607 xfer_buff, size, &bytes_read, BULK_TIMEOUT);
@@ -658,9 +657,9 @@ static int request_dsp(struct uea_softc *sc)
658/* 657/*
659 * The uea_load_page() function must be called within a process context 658 * The uea_load_page() function must be called within a process context
660 */ 659 */
661static void uea_load_page(void *xsc) 660static void uea_load_page(struct work_struct *work)
662{ 661{
663 struct uea_softc *sc = xsc; 662 struct uea_softc *sc = container_of(work, struct uea_softc, task);
664 u16 pageno = sc->pageno; 663 u16 pageno = sc->pageno;
665 u16 ovl = sc->ovl; 664 u16 ovl = sc->ovl;
666 struct block_info bi; 665 struct block_info bi;
@@ -765,12 +764,11 @@ static int uea_request(struct uea_softc *sc,
765 u8 *xfer_buff; 764 u8 *xfer_buff;
766 int ret = -ENOMEM; 765 int ret = -ENOMEM;
767 766
768 xfer_buff = kmalloc(size, GFP_KERNEL); 767 xfer_buff = kmemdup(data, size, GFP_KERNEL);
769 if (!xfer_buff) { 768 if (!xfer_buff) {
770 uea_err(INS_TO_USBDEV(sc), "can't allocate xfer_buff\n"); 769 uea_err(INS_TO_USBDEV(sc), "can't allocate xfer_buff\n");
771 return ret; 770 return ret;
772 } 771 }
773 memcpy(xfer_buff, data, size);
774 772
775 ret = usb_control_msg(sc->usb_dev, usb_sndctrlpipe(sc->usb_dev, 0), 773 ret = usb_control_msg(sc->usb_dev, usb_sndctrlpipe(sc->usb_dev, 0),
776 UCDC_SEND_ENCAPSULATED_COMMAND, 774 UCDC_SEND_ENCAPSULATED_COMMAND,
@@ -1352,7 +1350,7 @@ static int uea_boot(struct uea_softc *sc)
1352 1350
1353 uea_enters(INS_TO_USBDEV(sc)); 1351 uea_enters(INS_TO_USBDEV(sc));
1354 1352
1355 INIT_WORK(&sc->task, uea_load_page, sc); 1353 INIT_WORK(&sc->task, uea_load_page);
1356 init_waitqueue_head(&sc->sync_q); 1354 init_waitqueue_head(&sc->sync_q);
1357 init_waitqueue_head(&sc->cmv_ack_wait); 1355 init_waitqueue_head(&sc->cmv_ack_wait);
1358 1356
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 9a9012fd284b..7f1fa956dcdb 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -421,9 +421,9 @@ static void acm_write_bulk(struct urb *urb)
421 schedule_work(&acm->work); 421 schedule_work(&acm->work);
422} 422}
423 423
424static void acm_softint(void *private) 424static void acm_softint(struct work_struct *work)
425{ 425{
426 struct acm *acm = private; 426 struct acm *acm = container_of(work, struct acm, work);
427 dbg("Entering acm_softint."); 427 dbg("Entering acm_softint.");
428 428
429 if (!ACM_READY(acm)) 429 if (!ACM_READY(acm))
@@ -892,7 +892,7 @@ skip_normal_probe:
892 892
893 893
894 /* workaround for switched endpoints */ 894 /* workaround for switched endpoints */
895 if ((epread->bEndpointAddress & USB_DIR_IN) != USB_DIR_IN) { 895 if (!usb_endpoint_dir_in(epread)) {
896 /* descriptors are swapped */ 896 /* descriptors are swapped */
897 struct usb_endpoint_descriptor *t; 897 struct usb_endpoint_descriptor *t;
898 dev_dbg(&intf->dev,"The data interface has switched endpoints"); 898 dev_dbg(&intf->dev,"The data interface has switched endpoints");
@@ -927,7 +927,7 @@ skip_normal_probe:
927 acm->rx_buflimit = num_rx_buf; 927 acm->rx_buflimit = num_rx_buf;
928 acm->urb_task.func = acm_rx_tasklet; 928 acm->urb_task.func = acm_rx_tasklet;
929 acm->urb_task.data = (unsigned long) acm; 929 acm->urb_task.data = (unsigned long) acm;
930 INIT_WORK(&acm->work, acm_softint, acm); 930 INIT_WORK(&acm->work, acm_softint);
931 spin_lock_init(&acm->throttle_lock); 931 spin_lock_init(&acm->throttle_lock);
932 spin_lock_init(&acm->write_lock); 932 spin_lock_init(&acm->write_lock);
933 spin_lock_init(&acm->read_lock); 933 spin_lock_init(&acm->read_lock);
diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig
index 6e3b5358a760..f8324d8d06ac 100644
--- a/drivers/usb/core/Kconfig
+++ b/drivers/usb/core/Kconfig
@@ -72,6 +72,21 @@ config USB_SUSPEND
72 72
73 If you are unsure about this, say N here. 73 If you are unsure about this, say N here.
74 74
75config USB_MULTITHREAD_PROBE
76 bool "USB Multi-threaded probe (EXPERIMENTAL)"
77 depends on USB && EXPERIMENTAL
78 default n
79 help
80 Say Y here if you want the USB core to spawn a new thread for
81 every USB device that is probed. This can cause a small speedup
82 in boot times on systems with a lot of different USB devices.
83
84 This option should be safe to enable, but if any odd probing
85 problems are found, please disable it, or dynamically turn it
86 off in the /sys/module/usbcore/parameters/multithread_probe
87 file
88
89 When in doubt, say N.
75 90
76config USB_OTG 91config USB_OTG
77 bool 92 bool
diff --git a/drivers/usb/core/buffer.c b/drivers/usb/core/buffer.c
index 840442a25b61..c3915dc28608 100644
--- a/drivers/usb/core/buffer.c
+++ b/drivers/usb/core/buffer.c
@@ -93,7 +93,7 @@ void hcd_buffer_destroy (struct usb_hcd *hcd)
93} 93}
94 94
95 95
96/* sometimes alloc/free could use kmalloc with SLAB_DMA, for 96/* sometimes alloc/free could use kmalloc with GFP_DMA, for
97 * better sharing and to leverage mm/slab.c intelligence. 97 * better sharing and to leverage mm/slab.c intelligence.
98 */ 98 */
99 99
diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
index 3538c2fdadfe..ea398e5d50af 100644
--- a/drivers/usb/core/devices.c
+++ b/drivers/usb/core/devices.c
@@ -175,12 +175,13 @@ static char *usb_dump_endpoint_descriptor (
175) 175)
176{ 176{
177 char dir, unit, *type; 177 char dir, unit, *type;
178 unsigned interval, in, bandwidth = 1; 178 unsigned interval, bandwidth = 1;
179 179
180 if (start > end) 180 if (start > end)
181 return start; 181 return start;
182 in = (desc->bEndpointAddress & USB_DIR_IN); 182
183 dir = in ? 'I' : 'O'; 183 dir = usb_endpoint_dir_in(desc) ? 'I' : 'O';
184
184 if (speed == USB_SPEED_HIGH) { 185 if (speed == USB_SPEED_HIGH) {
185 switch (le16_to_cpu(desc->wMaxPacketSize) & (0x03 << 11)) { 186 switch (le16_to_cpu(desc->wMaxPacketSize) & (0x03 << 11)) {
186 case 1 << 11: bandwidth = 2; break; 187 case 1 << 11: bandwidth = 2; break;
@@ -204,7 +205,7 @@ static char *usb_dump_endpoint_descriptor (
204 break; 205 break;
205 case USB_ENDPOINT_XFER_BULK: 206 case USB_ENDPOINT_XFER_BULK:
206 type = "Bulk"; 207 type = "Bulk";
207 if (speed == USB_SPEED_HIGH && !in) /* uframes per NAK */ 208 if (speed == USB_SPEED_HIGH && dir == 'O') /* uframes per NAK */
208 interval = desc->bInterval; 209 interval = desc->bInterval;
209 else 210 else
210 interval = 0; 211 interval = 0;
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index fed92be63b5e..3ed4cb2d56d9 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -561,7 +561,7 @@ static int usbdev_open(struct inode *inode, struct file *file)
561 dev = inode->i_private; 561 dev = inode->i_private;
562 if (!dev) 562 if (!dev)
563 goto out; 563 goto out;
564 ret = usb_autoresume_device(dev, 1); 564 ret = usb_autoresume_device(dev);
565 if (ret) 565 if (ret)
566 goto out; 566 goto out;
567 567
@@ -609,7 +609,7 @@ static int usbdev_release(struct inode *inode, struct file *file)
609 releaseintf(ps, ifnum); 609 releaseintf(ps, ifnum);
610 } 610 }
611 destroy_all_async(ps); 611 destroy_all_async(ps);
612 usb_autosuspend_device(dev, 1); 612 usb_autosuspend_device(dev);
613 usb_unlock_device(dev); 613 usb_unlock_device(dev);
614 usb_put_dev(dev); 614 usb_put_dev(dev);
615 put_pid(ps->disc_pid); 615 put_pid(ps->disc_pid);
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index 113e484c763e..d6eb5ce1dd1d 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -205,7 +205,7 @@ static int usb_probe_interface(struct device *dev)
205 if (id) { 205 if (id) {
206 dev_dbg(dev, "%s - got id\n", __FUNCTION__); 206 dev_dbg(dev, "%s - got id\n", __FUNCTION__);
207 207
208 error = usb_autoresume_device(udev, 1); 208 error = usb_autoresume_device(udev);
209 if (error) 209 if (error)
210 return error; 210 return error;
211 211
@@ -229,7 +229,7 @@ static int usb_probe_interface(struct device *dev)
229 } else 229 } else
230 intf->condition = USB_INTERFACE_BOUND; 230 intf->condition = USB_INTERFACE_BOUND;
231 231
232 usb_autosuspend_device(udev, 1); 232 usb_autosuspend_device(udev);
233 } 233 }
234 234
235 return error; 235 return error;
@@ -247,7 +247,7 @@ static int usb_unbind_interface(struct device *dev)
247 247
248 /* Autoresume for set_interface call below */ 248 /* Autoresume for set_interface call below */
249 udev = interface_to_usbdev(intf); 249 udev = interface_to_usbdev(intf);
250 error = usb_autoresume_device(udev, 1); 250 error = usb_autoresume_device(udev);
251 251
252 /* release all urbs for this interface */ 252 /* release all urbs for this interface */
253 usb_disable_interface(interface_to_usbdev(intf), intf); 253 usb_disable_interface(interface_to_usbdev(intf), intf);
@@ -265,7 +265,7 @@ static int usb_unbind_interface(struct device *dev)
265 intf->needs_remote_wakeup = 0; 265 intf->needs_remote_wakeup = 0;
266 266
267 if (!error) 267 if (!error)
268 usb_autosuspend_device(udev, 1); 268 usb_autosuspend_device(udev);
269 269
270 return 0; 270 return 0;
271} 271}
@@ -408,6 +408,16 @@ static int usb_match_one_id(struct usb_interface *interface,
408 (id->bDeviceProtocol != dev->descriptor.bDeviceProtocol)) 408 (id->bDeviceProtocol != dev->descriptor.bDeviceProtocol))
409 return 0; 409 return 0;
410 410
411 /* The interface class, subclass, and protocol should never be
412 * checked for a match if the device class is Vendor Specific,
413 * unless the match record specifies the Vendor ID. */
414 if (dev->descriptor.bDeviceClass == USB_CLASS_VENDOR_SPEC &&
415 !(id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) &&
416 (id->match_flags & (USB_DEVICE_ID_MATCH_INT_CLASS |
417 USB_DEVICE_ID_MATCH_INT_SUBCLASS |
418 USB_DEVICE_ID_MATCH_INT_PROTOCOL)))
419 return 0;
420
411 if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_CLASS) && 421 if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_CLASS) &&
412 (id->bInterfaceClass != intf->desc.bInterfaceClass)) 422 (id->bInterfaceClass != intf->desc.bInterfaceClass))
413 return 0; 423 return 0;
@@ -476,7 +486,17 @@ static int usb_match_one_id(struct usb_interface *interface,
476 * most general; they let drivers bind to any interface on a 486 * most general; they let drivers bind to any interface on a
477 * multiple-function device. Use the USB_INTERFACE_INFO 487 * multiple-function device. Use the USB_INTERFACE_INFO
478 * macro, or its siblings, to match class-per-interface style 488 * macro, or its siblings, to match class-per-interface style
479 * devices (as recorded in bDeviceClass). 489 * devices (as recorded in bInterfaceClass).
490 *
491 * Note that an entry created by USB_INTERFACE_INFO won't match
492 * any interface if the device class is set to Vendor-Specific.
493 * This is deliberate; according to the USB spec the meanings of
494 * the interface class/subclass/protocol for these devices are also
495 * vendor-specific, and hence matching against a standard product
496 * class wouldn't work anyway. If you really want to use an
497 * interface-based match for such a device, create a match record
498 * that also specifies the vendor ID. (Unforunately there isn't a
499 * standard macro for creating records like this.)
480 * 500 *
481 * Within those groups, remember that not all combinations are 501 * Within those groups, remember that not all combinations are
482 * meaningful. For example, don't give a product version range 502 * meaningful. For example, don't give a product version range
@@ -505,7 +525,7 @@ const struct usb_device_id *usb_match_id(struct usb_interface *interface,
505} 525}
506EXPORT_SYMBOL_GPL_FUTURE(usb_match_id); 526EXPORT_SYMBOL_GPL_FUTURE(usb_match_id);
507 527
508int usb_device_match(struct device *dev, struct device_driver *drv) 528static int usb_device_match(struct device *dev, struct device_driver *drv)
509{ 529{
510 /* devices and interfaces are handled separately */ 530 /* devices and interfaces are handled separately */
511 if (is_usb_device(dev)) { 531 if (is_usb_device(dev)) {
@@ -790,7 +810,7 @@ EXPORT_SYMBOL_GPL_FUTURE(usb_deregister);
790#ifdef CONFIG_PM 810#ifdef CONFIG_PM
791 811
792/* Caller has locked udev's pm_mutex */ 812/* Caller has locked udev's pm_mutex */
793static int suspend_device(struct usb_device *udev, pm_message_t msg) 813static int usb_suspend_device(struct usb_device *udev, pm_message_t msg)
794{ 814{
795 struct usb_device_driver *udriver; 815 struct usb_device_driver *udriver;
796 int status = 0; 816 int status = 0;
@@ -817,7 +837,7 @@ done:
817} 837}
818 838
819/* Caller has locked udev's pm_mutex */ 839/* Caller has locked udev's pm_mutex */
820static int resume_device(struct usb_device *udev) 840static int usb_resume_device(struct usb_device *udev)
821{ 841{
822 struct usb_device_driver *udriver; 842 struct usb_device_driver *udriver;
823 int status = 0; 843 int status = 0;
@@ -843,7 +863,7 @@ done:
843} 863}
844 864
845/* Caller has locked intf's usb_device's pm mutex */ 865/* Caller has locked intf's usb_device's pm mutex */
846static int suspend_interface(struct usb_interface *intf, pm_message_t msg) 866static int usb_suspend_interface(struct usb_interface *intf, pm_message_t msg)
847{ 867{
848 struct usb_driver *driver; 868 struct usb_driver *driver;
849 int status = 0; 869 int status = 0;
@@ -880,7 +900,7 @@ done:
880} 900}
881 901
882/* Caller has locked intf's usb_device's pm_mutex */ 902/* Caller has locked intf's usb_device's pm_mutex */
883static int resume_interface(struct usb_interface *intf) 903static int usb_resume_interface(struct usb_interface *intf)
884{ 904{
885 struct usb_driver *driver; 905 struct usb_driver *driver;
886 int status = 0; 906 int status = 0;
@@ -920,6 +940,44 @@ done:
920 return status; 940 return status;
921} 941}
922 942
943#ifdef CONFIG_USB_SUSPEND
944
945/* Internal routine to check whether we may autosuspend a device. */
946static int autosuspend_check(struct usb_device *udev)
947{
948 int i;
949 struct usb_interface *intf;
950
951 /* For autosuspend, fail fast if anything is in use.
952 * Also fail if any interfaces require remote wakeup but it
953 * isn't available. */
954 udev->do_remote_wakeup = device_may_wakeup(&udev->dev);
955 if (udev->pm_usage_cnt > 0)
956 return -EBUSY;
957 if (udev->actconfig) {
958 for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) {
959 intf = udev->actconfig->interface[i];
960 if (!is_active(intf))
961 continue;
962 if (intf->pm_usage_cnt > 0)
963 return -EBUSY;
964 if (intf->needs_remote_wakeup &&
965 !udev->do_remote_wakeup) {
966 dev_dbg(&udev->dev, "remote wakeup needed "
967 "for autosuspend\n");
968 return -EOPNOTSUPP;
969 }
970 }
971 }
972 return 0;
973}
974
975#else
976
977#define autosuspend_check(udev) 0
978
979#endif
980
923/** 981/**
924 * usb_suspend_both - suspend a USB device and its interfaces 982 * usb_suspend_both - suspend a USB device and its interfaces
925 * @udev: the usb_device to suspend 983 * @udev: the usb_device to suspend
@@ -971,52 +1029,34 @@ int usb_suspend_both(struct usb_device *udev, pm_message_t msg)
971 1029
972 udev->do_remote_wakeup = device_may_wakeup(&udev->dev); 1030 udev->do_remote_wakeup = device_may_wakeup(&udev->dev);
973 1031
974 /* For autosuspend, fail fast if anything is in use.
975 * Also fail if any interfaces require remote wakeup but it
976 * isn't available. */
977 if (udev->auto_pm) { 1032 if (udev->auto_pm) {
978 if (udev->pm_usage_cnt > 0) 1033 status = autosuspend_check(udev);
979 return -EBUSY; 1034 if (status < 0)
980 if (udev->actconfig) { 1035 return status;
981 for (; i < udev->actconfig->desc.bNumInterfaces; i++) {
982 intf = udev->actconfig->interface[i];
983 if (!is_active(intf))
984 continue;
985 if (intf->pm_usage_cnt > 0)
986 return -EBUSY;
987 if (intf->needs_remote_wakeup &&
988 !udev->do_remote_wakeup) {
989 dev_dbg(&udev->dev,
990 "remote wakeup needed for autosuspend\n");
991 return -EOPNOTSUPP;
992 }
993 }
994 i = 0;
995 }
996 } 1036 }
997 1037
998 /* Suspend all the interfaces and then udev itself */ 1038 /* Suspend all the interfaces and then udev itself */
999 if (udev->actconfig) { 1039 if (udev->actconfig) {
1000 for (; i < udev->actconfig->desc.bNumInterfaces; i++) { 1040 for (; i < udev->actconfig->desc.bNumInterfaces; i++) {
1001 intf = udev->actconfig->interface[i]; 1041 intf = udev->actconfig->interface[i];
1002 status = suspend_interface(intf, msg); 1042 status = usb_suspend_interface(intf, msg);
1003 if (status != 0) 1043 if (status != 0)
1004 break; 1044 break;
1005 } 1045 }
1006 } 1046 }
1007 if (status == 0) 1047 if (status == 0)
1008 status = suspend_device(udev, msg); 1048 status = usb_suspend_device(udev, msg);
1009 1049
1010 /* If the suspend failed, resume interfaces that did get suspended */ 1050 /* If the suspend failed, resume interfaces that did get suspended */
1011 if (status != 0) { 1051 if (status != 0) {
1012 while (--i >= 0) { 1052 while (--i >= 0) {
1013 intf = udev->actconfig->interface[i]; 1053 intf = udev->actconfig->interface[i];
1014 resume_interface(intf); 1054 usb_resume_interface(intf);
1015 } 1055 }
1016 1056
1017 /* If the suspend succeeded, propagate it up the tree */ 1057 /* If the suspend succeeded, propagate it up the tree */
1018 } else if (parent) 1058 } else if (parent)
1019 usb_autosuspend_device(parent, 0); 1059 usb_autosuspend_device(parent);
1020 1060
1021 // dev_dbg(&udev->dev, "%s: status %d\n", __FUNCTION__, status); 1061 // dev_dbg(&udev->dev, "%s: status %d\n", __FUNCTION__, status);
1022 return status; 1062 return status;
@@ -1064,9 +1104,25 @@ int usb_resume_both(struct usb_device *udev)
1064 /* Propagate the resume up the tree, if necessary */ 1104 /* Propagate the resume up the tree, if necessary */
1065 if (udev->state == USB_STATE_SUSPENDED) { 1105 if (udev->state == USB_STATE_SUSPENDED) {
1066 if (parent) { 1106 if (parent) {
1067 usb_pm_lock(parent); 1107 status = usb_autoresume_device(parent);
1068 parent->auto_pm = 1; 1108 if (status == 0) {
1069 status = usb_resume_both(parent); 1109 status = usb_resume_device(udev);
1110 if (status) {
1111 usb_autosuspend_device(parent);
1112
1113 /* It's possible usb_resume_device()
1114 * failed after the port was
1115 * unsuspended, causing udev to be
1116 * logically disconnected. We don't
1117 * want usb_disconnect() to autosuspend
1118 * the parent again, so tell it that
1119 * udev disconnected while still
1120 * suspended. */
1121 if (udev->state ==
1122 USB_STATE_NOTATTACHED)
1123 udev->discon_suspended = 1;
1124 }
1125 }
1070 } else { 1126 } else {
1071 1127
1072 /* We can't progagate beyond the USB subsystem, 1128 /* We can't progagate beyond the USB subsystem,
@@ -1075,24 +1131,20 @@ int usb_resume_both(struct usb_device *udev)
1075 if (udev->dev.parent->power.power_state.event != 1131 if (udev->dev.parent->power.power_state.event !=
1076 PM_EVENT_ON) 1132 PM_EVENT_ON)
1077 status = -EHOSTUNREACH; 1133 status = -EHOSTUNREACH;
1078 } 1134 else
1079 if (status == 0) 1135 status = usb_resume_device(udev);
1080 status = resume_device(udev); 1136 }
1081 if (parent)
1082 usb_pm_unlock(parent);
1083 } else { 1137 } else {
1084 1138
1085 /* Needed only for setting udev->dev.power.power_state.event 1139 /* Needed only for setting udev->dev.power.power_state.event
1086 * and for possible debugging message. */ 1140 * and for possible debugging message. */
1087 status = resume_device(udev); 1141 status = usb_resume_device(udev);
1088 } 1142 }
1089 1143
1090 /* Now the parent won't suspend until we are finished */
1091
1092 if (status == 0 && udev->actconfig) { 1144 if (status == 0 && udev->actconfig) {
1093 for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) { 1145 for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) {
1094 intf = udev->actconfig->interface[i]; 1146 intf = udev->actconfig->interface[i];
1095 resume_interface(intf); 1147 usb_resume_interface(intf);
1096 } 1148 }
1097 } 1149 }
1098 1150
@@ -1102,39 +1154,53 @@ int usb_resume_both(struct usb_device *udev)
1102 1154
1103#ifdef CONFIG_USB_SUSPEND 1155#ifdef CONFIG_USB_SUSPEND
1104 1156
1157/* Internal routine to adjust a device's usage counter and change
1158 * its autosuspend state.
1159 */
1160static int usb_autopm_do_device(struct usb_device *udev, int inc_usage_cnt)
1161{
1162 int status = 0;
1163
1164 usb_pm_lock(udev);
1165 udev->pm_usage_cnt += inc_usage_cnt;
1166 WARN_ON(udev->pm_usage_cnt < 0);
1167 if (inc_usage_cnt >= 0 && udev->pm_usage_cnt > 0) {
1168 udev->auto_pm = 1;
1169 status = usb_resume_both(udev);
1170 if (status != 0)
1171 udev->pm_usage_cnt -= inc_usage_cnt;
1172 } else if (inc_usage_cnt <= 0 && autosuspend_check(udev) == 0)
1173 queue_delayed_work(ksuspend_usb_wq, &udev->autosuspend,
1174 USB_AUTOSUSPEND_DELAY);
1175 usb_pm_unlock(udev);
1176 return status;
1177}
1178
1105/** 1179/**
1106 * usb_autosuspend_device - delayed autosuspend of a USB device and its interfaces 1180 * usb_autosuspend_device - delayed autosuspend of a USB device and its interfaces
1107 * @udev: the usb_device to autosuspend 1181 * @udev: the usb_device to autosuspend
1108 * @dec_usage_cnt: flag to decrement @udev's PM-usage counter
1109 * 1182 *
1110 * This routine should be called when a core subsystem is finished using 1183 * This routine should be called when a core subsystem is finished using
1111 * @udev and wants to allow it to autosuspend. Examples would be when 1184 * @udev and wants to allow it to autosuspend. Examples would be when
1112 * @udev's device file in usbfs is closed or after a configuration change. 1185 * @udev's device file in usbfs is closed or after a configuration change.
1113 * 1186 *
1114 * @dec_usage_cnt should be 1 if the subsystem previously incremented 1187 * @udev's usage counter is decremented. If it or any of the usage counters
1115 * @udev's usage counter (such as by passing 1 to usb_autoresume_device); 1188 * for an active interface is greater than 0, no autosuspend request will be
1116 * otherwise it should be 0. 1189 * queued. (If an interface driver does not support autosuspend then its
1117 * 1190 * usage counter is permanently positive.) Furthermore, if an interface
1118 * If the usage counter for @udev or any of its active interfaces is greater 1191 * driver requires remote-wakeup capability during autosuspend but remote
1119 * than 0, the autosuspend request will not be queued. (If an interface 1192 * wakeup is disabled, the autosuspend will fail.
1120 * driver does not support autosuspend then its usage counter is permanently
1121 * positive.) Likewise, if an interface driver requires remote-wakeup
1122 * capability during autosuspend but remote wakeup is disabled, the
1123 * autosuspend will fail.
1124 * 1193 *
1125 * Often the caller will hold @udev's device lock, but this is not 1194 * Often the caller will hold @udev's device lock, but this is not
1126 * necessary. 1195 * necessary.
1127 * 1196 *
1128 * This routine can run only in process context. 1197 * This routine can run only in process context.
1129 */ 1198 */
1130void usb_autosuspend_device(struct usb_device *udev, int dec_usage_cnt) 1199void usb_autosuspend_device(struct usb_device *udev)
1131{ 1200{
1132 usb_pm_lock(udev); 1201 int status;
1133 udev->pm_usage_cnt -= dec_usage_cnt; 1202
1134 if (udev->pm_usage_cnt <= 0) 1203 status = usb_autopm_do_device(udev, -1);
1135 queue_delayed_work(ksuspend_usb_wq, &udev->autosuspend,
1136 USB_AUTOSUSPEND_DELAY);
1137 usb_pm_unlock(udev);
1138 // dev_dbg(&udev->dev, "%s: cnt %d\n", 1204 // dev_dbg(&udev->dev, "%s: cnt %d\n",
1139 // __FUNCTION__, udev->pm_usage_cnt); 1205 // __FUNCTION__, udev->pm_usage_cnt);
1140} 1206}
@@ -1142,44 +1208,59 @@ void usb_autosuspend_device(struct usb_device *udev, int dec_usage_cnt)
1142/** 1208/**
1143 * usb_autoresume_device - immediately autoresume a USB device and its interfaces 1209 * usb_autoresume_device - immediately autoresume a USB device and its interfaces
1144 * @udev: the usb_device to autoresume 1210 * @udev: the usb_device to autoresume
1145 * @inc_usage_cnt: flag to increment @udev's PM-usage counter
1146 * 1211 *
1147 * This routine should be called when a core subsystem wants to use @udev 1212 * This routine should be called when a core subsystem wants to use @udev
1148 * and needs to guarantee that it is not suspended. In addition, the 1213 * and needs to guarantee that it is not suspended. No autosuspend will
1149 * caller can prevent @udev from being autosuspended subsequently. (Note 1214 * occur until usb_autosuspend_device is called. (Note that this will not
1150 * that this will not prevent suspend events originating in the PM core.) 1215 * prevent suspend events originating in the PM core.) Examples would be
1151 * Examples would be when @udev's device file in usbfs is opened (autosuspend 1216 * when @udev's device file in usbfs is opened or when a remote-wakeup
1152 * should be prevented until the file is closed) or when a remote-wakeup 1217 * request is received.
1153 * request is received (later autosuspends should not be prevented).
1154 * 1218 *
1155 * @inc_usage_cnt should be 1 to increment @udev's usage counter and prevent 1219 * @udev's usage counter is incremented to prevent subsequent autosuspends.
1156 * autosuspends. This prevention will persist until the usage counter is 1220 * However if the autoresume fails then the usage counter is re-decremented.
1157 * decremented again (such as by passing 1 to usb_autosuspend_device).
1158 * Otherwise @inc_usage_cnt should be 0 to leave the usage counter unchanged.
1159 * Regardless, if the autoresume fails then the usage counter is not
1160 * incremented.
1161 * 1221 *
1162 * Often the caller will hold @udev's device lock, but this is not 1222 * Often the caller will hold @udev's device lock, but this is not
1163 * necessary (and attempting it might cause deadlock). 1223 * necessary (and attempting it might cause deadlock).
1164 * 1224 *
1165 * This routine can run only in process context. 1225 * This routine can run only in process context.
1166 */ 1226 */
1167int usb_autoresume_device(struct usb_device *udev, int inc_usage_cnt) 1227int usb_autoresume_device(struct usb_device *udev)
1168{ 1228{
1169 int status; 1229 int status;
1170 1230
1171 usb_pm_lock(udev); 1231 status = usb_autopm_do_device(udev, 1);
1172 udev->pm_usage_cnt += inc_usage_cnt;
1173 udev->auto_pm = 1;
1174 status = usb_resume_both(udev);
1175 if (status != 0)
1176 udev->pm_usage_cnt -= inc_usage_cnt;
1177 usb_pm_unlock(udev);
1178 // dev_dbg(&udev->dev, "%s: status %d cnt %d\n", 1232 // dev_dbg(&udev->dev, "%s: status %d cnt %d\n",
1179 // __FUNCTION__, status, udev->pm_usage_cnt); 1233 // __FUNCTION__, status, udev->pm_usage_cnt);
1180 return status; 1234 return status;
1181} 1235}
1182 1236
1237/* Internal routine to adjust an interface's usage counter and change
1238 * its device's autosuspend state.
1239 */
1240static int usb_autopm_do_interface(struct usb_interface *intf,
1241 int inc_usage_cnt)
1242{
1243 struct usb_device *udev = interface_to_usbdev(intf);
1244 int status = 0;
1245
1246 usb_pm_lock(udev);
1247 if (intf->condition == USB_INTERFACE_UNBOUND)
1248 status = -ENODEV;
1249 else {
1250 intf->pm_usage_cnt += inc_usage_cnt;
1251 if (inc_usage_cnt >= 0 && intf->pm_usage_cnt > 0) {
1252 udev->auto_pm = 1;
1253 status = usb_resume_both(udev);
1254 if (status != 0)
1255 intf->pm_usage_cnt -= inc_usage_cnt;
1256 } else if (inc_usage_cnt <= 0 && autosuspend_check(udev) == 0)
1257 queue_delayed_work(ksuspend_usb_wq, &udev->autosuspend,
1258 USB_AUTOSUSPEND_DELAY);
1259 }
1260 usb_pm_unlock(udev);
1261 return status;
1262}
1263
1183/** 1264/**
1184 * usb_autopm_put_interface - decrement a USB interface's PM-usage counter 1265 * usb_autopm_put_interface - decrement a USB interface's PM-usage counter
1185 * @intf: the usb_interface whose counter should be decremented 1266 * @intf: the usb_interface whose counter should be decremented
@@ -1213,17 +1294,11 @@ int usb_autoresume_device(struct usb_device *udev, int inc_usage_cnt)
1213 */ 1294 */
1214void usb_autopm_put_interface(struct usb_interface *intf) 1295void usb_autopm_put_interface(struct usb_interface *intf)
1215{ 1296{
1216 struct usb_device *udev = interface_to_usbdev(intf); 1297 int status;
1217 1298
1218 usb_pm_lock(udev); 1299 status = usb_autopm_do_interface(intf, -1);
1219 if (intf->condition != USB_INTERFACE_UNBOUND && 1300 // dev_dbg(&intf->dev, "%s: status %d cnt %d\n",
1220 --intf->pm_usage_cnt <= 0) { 1301 // __FUNCTION__, status, intf->pm_usage_cnt);
1221 queue_delayed_work(ksuspend_usb_wq, &udev->autosuspend,
1222 USB_AUTOSUSPEND_DELAY);
1223 }
1224 usb_pm_unlock(udev);
1225 // dev_dbg(&intf->dev, "%s: cnt %d\n",
1226 // __FUNCTION__, intf->pm_usage_cnt);
1227} 1302}
1228EXPORT_SYMBOL_GPL(usb_autopm_put_interface); 1303EXPORT_SYMBOL_GPL(usb_autopm_put_interface);
1229 1304
@@ -1260,26 +1335,37 @@ EXPORT_SYMBOL_GPL(usb_autopm_put_interface);
1260 */ 1335 */
1261int usb_autopm_get_interface(struct usb_interface *intf) 1336int usb_autopm_get_interface(struct usb_interface *intf)
1262{ 1337{
1263 struct usb_device *udev = interface_to_usbdev(intf); 1338 int status;
1264 int status;
1265 1339
1266 usb_pm_lock(udev); 1340 status = usb_autopm_do_interface(intf, 1);
1267 if (intf->condition == USB_INTERFACE_UNBOUND)
1268 status = -ENODEV;
1269 else {
1270 ++intf->pm_usage_cnt;
1271 udev->auto_pm = 1;
1272 status = usb_resume_both(udev);
1273 if (status != 0)
1274 --intf->pm_usage_cnt;
1275 }
1276 usb_pm_unlock(udev);
1277 // dev_dbg(&intf->dev, "%s: status %d cnt %d\n", 1341 // dev_dbg(&intf->dev, "%s: status %d cnt %d\n",
1278 // __FUNCTION__, status, intf->pm_usage_cnt); 1342 // __FUNCTION__, status, intf->pm_usage_cnt);
1279 return status; 1343 return status;
1280} 1344}
1281EXPORT_SYMBOL_GPL(usb_autopm_get_interface); 1345EXPORT_SYMBOL_GPL(usb_autopm_get_interface);
1282 1346
1347/**
1348 * usb_autopm_set_interface - set a USB interface's autosuspend state
1349 * @intf: the usb_interface whose state should be set
1350 *
1351 * This routine sets the autosuspend state of @intf's device according
1352 * to @intf's usage counter, which the caller must have set previously.
1353 * If the counter is <= 0, the device is autosuspended (if it isn't
1354 * already suspended and if nothing else prevents the autosuspend). If
1355 * the counter is > 0, the device is autoresumed (if it isn't already
1356 * awake).
1357 */
1358int usb_autopm_set_interface(struct usb_interface *intf)
1359{
1360 int status;
1361
1362 status = usb_autopm_do_interface(intf, 0);
1363 // dev_dbg(&intf->dev, "%s: status %d cnt %d\n",
1364 // __FUNCTION__, status, intf->pm_usage_cnt);
1365 return status;
1366}
1367EXPORT_SYMBOL_GPL(usb_autopm_set_interface);
1368
1283#endif /* CONFIG_USB_SUSPEND */ 1369#endif /* CONFIG_USB_SUSPEND */
1284 1370
1285static int usb_suspend(struct device *dev, pm_message_t message) 1371static int usb_suspend(struct device *dev, pm_message_t message)
diff --git a/drivers/usb/core/endpoint.c b/drivers/usb/core/endpoint.c
index 3b2d137912be..c505b767cee1 100644
--- a/drivers/usb/core/endpoint.c
+++ b/drivers/usb/core/endpoint.c
@@ -10,15 +10,20 @@
10 */ 10 */
11 11
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/spinlock.h>
14#include <linux/idr.h>
13#include <linux/usb.h> 15#include <linux/usb.h>
14#include "usb.h" 16#include "usb.h"
15 17
16/* endpoint stuff */ 18#define MAX_ENDPOINT_MINORS (64*128*32)
19static int usb_endpoint_major;
20static DEFINE_IDR(endpoint_idr);
17 21
18struct ep_device { 22struct ep_device {
19 struct usb_endpoint_descriptor *desc; 23 struct usb_endpoint_descriptor *desc;
20 struct usb_device *udev; 24 struct usb_device *udev;
21 struct device dev; 25 struct device dev;
26 int minor;
22}; 27};
23#define to_ep_device(_dev) \ 28#define to_ep_device(_dev) \
24 container_of(_dev, struct ep_device, dev) 29 container_of(_dev, struct ep_device, dev)
@@ -152,6 +157,55 @@ static struct attribute_group ep_dev_attr_grp = {
152 .attrs = ep_dev_attrs, 157 .attrs = ep_dev_attrs,
153}; 158};
154 159
160static int usb_endpoint_major_init(void)
161{
162 dev_t dev;
163 int error;
164
165 error = alloc_chrdev_region(&dev, 0, MAX_ENDPOINT_MINORS,
166 "usb_endpoint");
167 if (error) {
168 err("unable to get a dynamic major for usb endpoints");
169 return error;
170 }
171 usb_endpoint_major = MAJOR(dev);
172
173 return error;
174}
175
176static void usb_endpoint_major_cleanup(void)
177{
178 unregister_chrdev_region(MKDEV(usb_endpoint_major, 0),
179 MAX_ENDPOINT_MINORS);
180}
181
182static int endpoint_get_minor(struct ep_device *ep_dev)
183{
184 static DEFINE_MUTEX(minor_lock);
185 int retval = -ENOMEM;
186 int id;
187
188 mutex_lock(&minor_lock);
189 if (idr_pre_get(&endpoint_idr, GFP_KERNEL) == 0)
190 goto exit;
191
192 retval = idr_get_new(&endpoint_idr, ep_dev, &id);
193 if (retval < 0) {
194 if (retval == -EAGAIN)
195 retval = -ENOMEM;
196 goto exit;
197 }
198 ep_dev->minor = id & MAX_ID_MASK;
199exit:
200 mutex_unlock(&minor_lock);
201 return retval;
202}
203
204static void endpoint_free_minor(struct ep_device *ep_dev)
205{
206 idr_remove(&endpoint_idr, ep_dev->minor);
207}
208
155static struct endpoint_class { 209static struct endpoint_class {
156 struct kref kref; 210 struct kref kref;
157 struct class *class; 211 struct class *class;
@@ -176,11 +230,20 @@ static int init_endpoint_class(void)
176 ep_class->class = class_create(THIS_MODULE, "usb_endpoint"); 230 ep_class->class = class_create(THIS_MODULE, "usb_endpoint");
177 if (IS_ERR(ep_class->class)) { 231 if (IS_ERR(ep_class->class)) {
178 result = IS_ERR(ep_class->class); 232 result = IS_ERR(ep_class->class);
179 kfree(ep_class); 233 goto class_create_error;
180 ep_class = NULL;
181 goto exit;
182 } 234 }
183 235
236 result = usb_endpoint_major_init();
237 if (result)
238 goto endpoint_major_error;
239
240 goto exit;
241
242endpoint_major_error:
243 class_destroy(ep_class->class);
244class_create_error:
245 kfree(ep_class);
246 ep_class = NULL;
184exit: 247exit:
185 return result; 248 return result;
186} 249}
@@ -191,6 +254,7 @@ static void release_endpoint_class(struct kref *kref)
191 class_destroy(ep_class->class); 254 class_destroy(ep_class->class);
192 kfree(ep_class); 255 kfree(ep_class);
193 ep_class = NULL; 256 ep_class = NULL;
257 usb_endpoint_major_cleanup();
194} 258}
195 259
196static void destroy_endpoint_class(void) 260static void destroy_endpoint_class(void)
@@ -213,7 +277,6 @@ int usb_create_ep_files(struct device *parent,
213{ 277{
214 char name[8]; 278 char name[8];
215 struct ep_device *ep_dev; 279 struct ep_device *ep_dev;
216 int minor;
217 int retval; 280 int retval;
218 281
219 retval = init_endpoint_class(); 282 retval = init_endpoint_class();
@@ -226,12 +289,16 @@ int usb_create_ep_files(struct device *parent,
226 goto error_alloc; 289 goto error_alloc;
227 } 290 }
228 291
229 /* fun calculation to determine the minor of this endpoint */ 292 retval = endpoint_get_minor(ep_dev);
230 minor = (((udev->bus->busnum - 1) * 128) * 16) + (udev->devnum - 1); 293 if (retval) {
294 dev_err(parent, "can not allocate minor number for %s",
295 ep_dev->dev.bus_id);
296 goto error_register;
297 }
231 298
232 ep_dev->desc = &endpoint->desc; 299 ep_dev->desc = &endpoint->desc;
233 ep_dev->udev = udev; 300 ep_dev->udev = udev;
234 ep_dev->dev.devt = MKDEV(442, minor); // FIXME fake number... 301 ep_dev->dev.devt = MKDEV(usb_endpoint_major, ep_dev->minor);
235 ep_dev->dev.class = ep_class->class; 302 ep_dev->dev.class = ep_class->class;
236 ep_dev->dev.parent = parent; 303 ep_dev->dev.parent = parent;
237 ep_dev->dev.release = ep_device_release; 304 ep_dev->dev.release = ep_device_release;
@@ -241,7 +308,7 @@ int usb_create_ep_files(struct device *parent,
241 308
242 retval = device_register(&ep_dev->dev); 309 retval = device_register(&ep_dev->dev);
243 if (retval) 310 if (retval)
244 goto error_register; 311 goto error_chrdev;
245 retval = sysfs_create_group(&ep_dev->dev.kobj, &ep_dev_attr_grp); 312 retval = sysfs_create_group(&ep_dev->dev.kobj, &ep_dev_attr_grp);
246 if (retval) 313 if (retval)
247 goto error_group; 314 goto error_group;
@@ -261,6 +328,9 @@ error_group:
261 destroy_endpoint_class(); 328 destroy_endpoint_class();
262 return retval; 329 return retval;
263 330
331error_chrdev:
332 endpoint_free_minor(ep_dev);
333
264error_register: 334error_register:
265 kfree(ep_dev); 335 kfree(ep_dev);
266error_alloc: 336error_alloc:
@@ -271,14 +341,16 @@ exit:
271 341
272void usb_remove_ep_files(struct usb_host_endpoint *endpoint) 342void usb_remove_ep_files(struct usb_host_endpoint *endpoint)
273{ 343{
344 struct ep_device *ep_dev = endpoint->ep_dev;
274 345
275 if (endpoint->ep_dev) { 346 if (ep_dev) {
276 char name[8]; 347 char name[8];
277 348
278 sprintf(name, "ep_%02x", endpoint->desc.bEndpointAddress); 349 sprintf(name, "ep_%02x", endpoint->desc.bEndpointAddress);
279 sysfs_remove_link(&endpoint->ep_dev->dev.parent->kobj, name); 350 sysfs_remove_link(&ep_dev->dev.parent->kobj, name);
280 sysfs_remove_group(&endpoint->ep_dev->dev.kobj, &ep_dev_attr_grp); 351 sysfs_remove_group(&ep_dev->dev.kobj, &ep_dev_attr_grp);
281 device_unregister(&endpoint->ep_dev->dev); 352 endpoint_free_minor(ep_dev);
353 device_unregister(&ep_dev->dev);
282 endpoint->ep_dev = NULL; 354 endpoint->ep_dev = NULL;
283 destroy_endpoint_class(); 355 destroy_endpoint_class();
284 } 356 }
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index afa2dd203329..10064af65d17 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -256,7 +256,9 @@ static const u8 hs_rh_config_descriptor [] = {
256 0x05, /* __u8 ep_bDescriptorType; Endpoint */ 256 0x05, /* __u8 ep_bDescriptorType; Endpoint */
257 0x81, /* __u8 ep_bEndpointAddress; IN Endpoint 1 */ 257 0x81, /* __u8 ep_bEndpointAddress; IN Endpoint 1 */
258 0x03, /* __u8 ep_bmAttributes; Interrupt */ 258 0x03, /* __u8 ep_bmAttributes; Interrupt */
259 0x02, 0x00, /* __le16 ep_wMaxPacketSize; 1 + (MAX_ROOT_PORTS / 8) */ 259 /* __le16 ep_wMaxPacketSize; 1 + (MAX_ROOT_PORTS / 8)
260 * see hub.c:hub_configure() for details. */
261 (USB_MAXCHILDREN + 1 + 7) / 8, 0x00,
260 0x0c /* __u8 ep_bInterval; (256ms -- usb 2.0 spec) */ 262 0x0c /* __u8 ep_bInterval; (256ms -- usb 2.0 spec) */
261}; 263};
262 264
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index ba165aff9ea4..2651c2e2a89f 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -22,6 +22,7 @@
22#include <linux/usbdevice_fs.h> 22#include <linux/usbdevice_fs.h>
23#include <linux/kthread.h> 23#include <linux/kthread.h>
24#include <linux/mutex.h> 24#include <linux/mutex.h>
25#include <linux/freezer.h>
25 26
26#include <asm/semaphore.h> 27#include <asm/semaphore.h>
27#include <asm/uaccess.h> 28#include <asm/uaccess.h>
@@ -31,6 +32,47 @@
31#include "hcd.h" 32#include "hcd.h"
32#include "hub.h" 33#include "hub.h"
33 34
35struct usb_hub {
36 struct device *intfdev; /* the "interface" device */
37 struct usb_device *hdev;
38 struct urb *urb; /* for interrupt polling pipe */
39
40 /* buffer for urb ... with extra space in case of babble */
41 char (*buffer)[8];
42 dma_addr_t buffer_dma; /* DMA address for buffer */
43 union {
44 struct usb_hub_status hub;
45 struct usb_port_status port;
46 } *status; /* buffer for status reports */
47
48 int error; /* last reported error */
49 int nerrors; /* track consecutive errors */
50
51 struct list_head event_list; /* hubs w/data or errs ready */
52 unsigned long event_bits[1]; /* status change bitmask */
53 unsigned long change_bits[1]; /* ports with logical connect
54 status change */
55 unsigned long busy_bits[1]; /* ports being reset or
56 resumed */
57#if USB_MAXCHILDREN > 31 /* 8*sizeof(unsigned long) - 1 */
58#error event_bits[] is too short!
59#endif
60
61 struct usb_hub_descriptor *descriptor; /* class descriptor */
62 struct usb_tt tt; /* Transaction Translator */
63
64 unsigned mA_per_port; /* current for each child */
65
66 unsigned limited_power:1;
67 unsigned quiescing:1;
68 unsigned activating:1;
69
70 unsigned has_indicators:1;
71 u8 indicator[USB_MAXCHILDREN];
72 struct delayed_work leds;
73};
74
75
34/* Protect struct usb_device->state and ->children members 76/* Protect struct usb_device->state and ->children members
35 * Note: Both are also protected by ->dev.sem, except that ->state can 77 * Note: Both are also protected by ->dev.sem, except that ->state can
36 * change to USB_STATE_NOTATTACHED even when the semaphore isn't held. */ 78 * change to USB_STATE_NOTATTACHED even when the semaphore isn't held. */
@@ -45,6 +87,16 @@ static DECLARE_WAIT_QUEUE_HEAD(khubd_wait);
45 87
46static struct task_struct *khubd_task; 88static struct task_struct *khubd_task;
47 89
90/* multithreaded probe logic */
91static int multithread_probe =
92#ifdef CONFIG_USB_MULTITHREAD_PROBE
93 1;
94#else
95 0;
96#endif
97module_param(multithread_probe, bool, S_IRUGO);
98MODULE_PARM_DESC(multithread_probe, "Run each USB device probe in a new thread");
99
48/* cycle leds on hubs that aren't blinking for attention */ 100/* cycle leds on hubs that aren't blinking for attention */
49static int blinkenlights = 0; 101static int blinkenlights = 0;
50module_param (blinkenlights, bool, S_IRUGO); 102module_param (blinkenlights, bool, S_IRUGO);
@@ -167,9 +219,10 @@ static void set_port_led(
167 219
168#define LED_CYCLE_PERIOD ((2*HZ)/3) 220#define LED_CYCLE_PERIOD ((2*HZ)/3)
169 221
170static void led_work (void *__hub) 222static void led_work (struct work_struct *work)
171{ 223{
172 struct usb_hub *hub = __hub; 224 struct usb_hub *hub =
225 container_of(work, struct usb_hub, leds.work);
173 struct usb_device *hdev = hub->hdev; 226 struct usb_device *hdev = hub->hdev;
174 unsigned i; 227 unsigned i;
175 unsigned changed = 0; 228 unsigned changed = 0;
@@ -276,6 +329,9 @@ static void kick_khubd(struct usb_hub *hub)
276{ 329{
277 unsigned long flags; 330 unsigned long flags;
278 331
332 /* Suppress autosuspend until khubd runs */
333 to_usb_interface(hub->intfdev)->pm_usage_cnt = 1;
334
279 spin_lock_irqsave(&hub_event_lock, flags); 335 spin_lock_irqsave(&hub_event_lock, flags);
280 if (list_empty(&hub->event_list)) { 336 if (list_empty(&hub->event_list)) {
281 list_add_tail(&hub->event_list, &hub_event_list); 337 list_add_tail(&hub->event_list, &hub_event_list);
@@ -351,9 +407,10 @@ hub_clear_tt_buffer (struct usb_device *hdev, u16 devinfo, u16 tt)
351 * talking to TTs must queue control transfers (not just bulk and iso), so 407 * talking to TTs must queue control transfers (not just bulk and iso), so
352 * both can talk to the same hub concurrently. 408 * both can talk to the same hub concurrently.
353 */ 409 */
354static void hub_tt_kevent (void *arg) 410static void hub_tt_kevent (struct work_struct *work)
355{ 411{
356 struct usb_hub *hub = arg; 412 struct usb_hub *hub =
413 container_of(work, struct usb_hub, tt.kevent);
357 unsigned long flags; 414 unsigned long flags;
358 415
359 spin_lock_irqsave (&hub->tt.lock, flags); 416 spin_lock_irqsave (&hub->tt.lock, flags);
@@ -404,7 +461,7 @@ void usb_hub_tt_clear_buffer (struct usb_device *udev, int pipe)
404 * since each TT has "at least two" buffers that can need it (and 461 * since each TT has "at least two" buffers that can need it (and
405 * there can be many TTs per hub). even if they're uncommon. 462 * there can be many TTs per hub). even if they're uncommon.
406 */ 463 */
407 if ((clear = kmalloc (sizeof *clear, SLAB_ATOMIC)) == NULL) { 464 if ((clear = kmalloc (sizeof *clear, GFP_ATOMIC)) == NULL) {
408 dev_err (&udev->dev, "can't save CLEAR_TT_BUFFER state\n"); 465 dev_err (&udev->dev, "can't save CLEAR_TT_BUFFER state\n");
409 /* FIXME recover somehow ... RESET_TT? */ 466 /* FIXME recover somehow ... RESET_TT? */
410 return; 467 return;
@@ -457,7 +514,6 @@ static void hub_quiesce(struct usb_hub *hub)
457 /* (nonblocking) khubd and related activity won't re-trigger */ 514 /* (nonblocking) khubd and related activity won't re-trigger */
458 hub->quiescing = 1; 515 hub->quiescing = 1;
459 hub->activating = 0; 516 hub->activating = 0;
460 hub->resume_root_hub = 0;
461 517
462 /* (blocking) stop khubd and related activity */ 518 /* (blocking) stop khubd and related activity */
463 usb_kill_urb(hub->urb); 519 usb_kill_urb(hub->urb);
@@ -473,7 +529,7 @@ static void hub_activate(struct usb_hub *hub)
473 529
474 hub->quiescing = 0; 530 hub->quiescing = 0;
475 hub->activating = 1; 531 hub->activating = 1;
476 hub->resume_root_hub = 0; 532
477 status = usb_submit_urb(hub->urb, GFP_NOIO); 533 status = usb_submit_urb(hub->urb, GFP_NOIO);
478 if (status < 0) 534 if (status < 0)
479 dev_err(hub->intfdev, "activate --> %d\n", status); 535 dev_err(hub->intfdev, "activate --> %d\n", status);
@@ -641,7 +697,7 @@ static int hub_configure(struct usb_hub *hub,
641 697
642 spin_lock_init (&hub->tt.lock); 698 spin_lock_init (&hub->tt.lock);
643 INIT_LIST_HEAD (&hub->tt.clear_list); 699 INIT_LIST_HEAD (&hub->tt.clear_list);
644 INIT_WORK (&hub->tt.kevent, hub_tt_kevent, hub); 700 INIT_WORK (&hub->tt.kevent, hub_tt_kevent);
645 switch (hdev->descriptor.bDeviceProtocol) { 701 switch (hdev->descriptor.bDeviceProtocol) {
646 case 0: 702 case 0:
647 break; 703 break;
@@ -759,7 +815,12 @@ static int hub_configure(struct usb_hub *hub,
759 dev_dbg(hub_dev, "%sover-current condition exists\n", 815 dev_dbg(hub_dev, "%sover-current condition exists\n",
760 (hubstatus & HUB_STATUS_OVERCURRENT) ? "" : "no "); 816 (hubstatus & HUB_STATUS_OVERCURRENT) ? "" : "no ");
761 817
762 /* set up the interrupt endpoint */ 818 /* set up the interrupt endpoint
819 * We use the EP's maxpacket size instead of (PORTS+1+7)/8
820 * bytes as USB2.0[11.12.3] says because some hubs are known
821 * to send more data (and thus cause overflow). For root hubs,
822 * maxpktsize is defined in hcd.c's fake endpoint descriptors
823 * to be big enough for at least USB_MAXCHILDREN ports. */
763 pipe = usb_rcvintpipe(hdev, endpoint->bEndpointAddress); 824 pipe = usb_rcvintpipe(hdev, endpoint->bEndpointAddress);
764 maxp = usb_maxpacket(hdev, pipe, usb_pipeout(pipe)); 825 maxp = usb_maxpacket(hdev, pipe, usb_pipeout(pipe));
765 826
@@ -880,9 +941,10 @@ descriptor_error:
880 INIT_LIST_HEAD(&hub->event_list); 941 INIT_LIST_HEAD(&hub->event_list);
881 hub->intfdev = &intf->dev; 942 hub->intfdev = &intf->dev;
882 hub->hdev = hdev; 943 hub->hdev = hdev;
883 INIT_WORK(&hub->leds, led_work, hub); 944 INIT_DELAYED_WORK(&hub->leds, led_work);
884 945
885 usb_set_intfdata (intf, hub); 946 usb_set_intfdata (intf, hub);
947 intf->needs_remote_wakeup = 1;
886 948
887 if (hdev->speed == USB_SPEED_HIGH) 949 if (hdev->speed == USB_SPEED_HIGH)
888 highspeed_hubs++; 950 highspeed_hubs++;
@@ -980,6 +1042,8 @@ static void recursively_mark_NOTATTACHED(struct usb_device *udev)
980 if (udev->children[i]) 1042 if (udev->children[i])
981 recursively_mark_NOTATTACHED(udev->children[i]); 1043 recursively_mark_NOTATTACHED(udev->children[i]);
982 } 1044 }
1045 if (udev->state == USB_STATE_SUSPENDED)
1046 udev->discon_suspended = 1;
983 udev->state = USB_STATE_NOTATTACHED; 1047 udev->state = USB_STATE_NOTATTACHED;
984} 1048}
985 1049
@@ -1169,6 +1233,14 @@ void usb_disconnect(struct usb_device **pdev)
1169 *pdev = NULL; 1233 *pdev = NULL;
1170 spin_unlock_irq(&device_state_lock); 1234 spin_unlock_irq(&device_state_lock);
1171 1235
1236 /* Decrement the parent's count of unsuspended children */
1237 if (udev->parent) {
1238 usb_pm_lock(udev);
1239 if (!udev->discon_suspended)
1240 usb_autosuspend_device(udev->parent);
1241 usb_pm_unlock(udev);
1242 }
1243
1172 put_device(&udev->dev); 1244 put_device(&udev->dev);
1173} 1245}
1174 1246
@@ -1191,29 +1263,17 @@ static inline void show_string(struct usb_device *udev, char *id, char *string)
1191static int __usb_port_suspend(struct usb_device *, int port1); 1263static int __usb_port_suspend(struct usb_device *, int port1);
1192#endif 1264#endif
1193 1265
1194/** 1266static int __usb_new_device(void *void_data)
1195 * usb_new_device - perform initial device setup (usbcore-internal)
1196 * @udev: newly addressed device (in ADDRESS state)
1197 *
1198 * This is called with devices which have been enumerated, but not yet
1199 * configured. The device descriptor is available, but not descriptors
1200 * for any device configuration. The caller must have locked either
1201 * the parent hub (if udev is a normal device) or else the
1202 * usb_bus_list_lock (if udev is a root hub). The parent's pointer to
1203 * udev has already been installed, but udev is not yet visible through
1204 * sysfs or other filesystem code.
1205 *
1206 * Returns 0 for success (device is configured and listed, with its
1207 * interfaces, in sysfs); else a negative errno value.
1208 *
1209 * This call is synchronous, and may not be used in an interrupt context.
1210 *
1211 * Only the hub driver or root-hub registrar should ever call this.
1212 */
1213int usb_new_device(struct usb_device *udev)
1214{ 1267{
1268 struct usb_device *udev = void_data;
1215 int err; 1269 int err;
1216 1270
1271 /* Lock ourself into memory in order to keep a probe sequence
1272 * sleeping in a new thread from allowing us to be unloaded.
1273 */
1274 if (!try_module_get(THIS_MODULE))
1275 return -EINVAL;
1276
1217 err = usb_get_configuration(udev); 1277 err = usb_get_configuration(udev);
1218 if (err < 0) { 1278 if (err < 0) {
1219 dev_err(&udev->dev, "can't read configurations, error %d\n", 1279 dev_err(&udev->dev, "can't read configurations, error %d\n",
@@ -1309,13 +1369,56 @@ int usb_new_device(struct usb_device *udev)
1309 goto fail; 1369 goto fail;
1310 } 1370 }
1311 1371
1312 return 0; 1372 /* Increment the parent's count of unsuspended children */
1373 if (udev->parent)
1374 usb_autoresume_device(udev->parent);
1375
1376exit:
1377 module_put(THIS_MODULE);
1378 return err;
1313 1379
1314fail: 1380fail:
1315 usb_set_device_state(udev, USB_STATE_NOTATTACHED); 1381 usb_set_device_state(udev, USB_STATE_NOTATTACHED);
1316 return err; 1382 goto exit;
1317} 1383}
1318 1384
1385/**
1386 * usb_new_device - perform initial device setup (usbcore-internal)
1387 * @udev: newly addressed device (in ADDRESS state)
1388 *
1389 * This is called with devices which have been enumerated, but not yet
1390 * configured. The device descriptor is available, but not descriptors
1391 * for any device configuration. The caller must have locked either
1392 * the parent hub (if udev is a normal device) or else the
1393 * usb_bus_list_lock (if udev is a root hub). The parent's pointer to
1394 * udev has already been installed, but udev is not yet visible through
1395 * sysfs or other filesystem code.
1396 *
1397 * The return value for this function depends on if the
1398 * multithread_probe variable is set or not. If it's set, it will
1399 * return a if the probe thread was successfully created or not. If the
1400 * variable is not set, it will return if the device is configured
1401 * properly or not. interfaces, in sysfs); else a negative errno value.
1402 *
1403 * This call is synchronous, and may not be used in an interrupt context.
1404 *
1405 * Only the hub driver or root-hub registrar should ever call this.
1406 */
1407int usb_new_device(struct usb_device *udev)
1408{
1409 struct task_struct *probe_task;
1410 int ret = 0;
1411
1412 if (multithread_probe) {
1413 probe_task = kthread_run(__usb_new_device, udev,
1414 "usb-probe-%s", udev->devnum);
1415 if (IS_ERR(probe_task))
1416 ret = PTR_ERR(probe_task);
1417 } else
1418 ret = __usb_new_device(udev);
1419
1420 return ret;
1421}
1319 1422
1320static int hub_port_status(struct usb_hub *hub, int port1, 1423static int hub_port_status(struct usb_hub *hub, int port1,
1321 u16 *status, u16 *change) 1424 u16 *status, u16 *change)
@@ -1323,10 +1426,12 @@ static int hub_port_status(struct usb_hub *hub, int port1,
1323 int ret; 1426 int ret;
1324 1427
1325 ret = get_port_status(hub->hdev, port1, &hub->status->port); 1428 ret = get_port_status(hub->hdev, port1, &hub->status->port);
1326 if (ret < 0) 1429 if (ret < 4) {
1327 dev_err (hub->intfdev, 1430 dev_err (hub->intfdev,
1328 "%s failed (err = %d)\n", __FUNCTION__, ret); 1431 "%s failed (err = %d)\n", __FUNCTION__, ret);
1329 else { 1432 if (ret >= 0)
1433 ret = -EIO;
1434 } else {
1330 *status = le16_to_cpu(hub->status->port.wPortStatus); 1435 *status = le16_to_cpu(hub->status->port.wPortStatus);
1331 *change = le16_to_cpu(hub->status->port.wPortChange); 1436 *change = le16_to_cpu(hub->status->port.wPortChange);
1332 ret = 0; 1437 ret = 0;
@@ -1674,6 +1779,12 @@ static int
1674hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev) 1779hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev)
1675{ 1780{
1676 int status; 1781 int status;
1782 u16 portchange, portstatus;
1783
1784 /* Skip the initial Clear-Suspend step for a remote wakeup */
1785 status = hub_port_status(hub, port1, &portstatus, &portchange);
1786 if (status == 0 && !(portstatus & USB_PORT_STAT_SUSPEND))
1787 goto SuspendCleared;
1677 1788
1678 // dev_dbg(hub->intfdev, "resume port %d\n", port1); 1789 // dev_dbg(hub->intfdev, "resume port %d\n", port1);
1679 1790
@@ -1687,9 +1798,6 @@ hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev)
1687 "can't resume port %d, status %d\n", 1798 "can't resume port %d, status %d\n",
1688 port1, status); 1799 port1, status);
1689 } else { 1800 } else {
1690 u16 devstatus;
1691 u16 portchange;
1692
1693 /* drive resume for at least 20 msec */ 1801 /* drive resume for at least 20 msec */
1694 if (udev) 1802 if (udev)
1695 dev_dbg(&udev->dev, "usb %sresume\n", 1803 dev_dbg(&udev->dev, "usb %sresume\n",
@@ -1704,16 +1812,15 @@ hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev)
1704 * stop resume signaling. Then finish the resume 1812 * stop resume signaling. Then finish the resume
1705 * sequence. 1813 * sequence.
1706 */ 1814 */
1707 devstatus = portchange = 0; 1815 status = hub_port_status(hub, port1, &portstatus, &portchange);
1708 status = hub_port_status(hub, port1, 1816SuspendCleared:
1709 &devstatus, &portchange);
1710 if (status < 0 1817 if (status < 0
1711 || (devstatus & LIVE_FLAGS) != LIVE_FLAGS 1818 || (portstatus & LIVE_FLAGS) != LIVE_FLAGS
1712 || (devstatus & USB_PORT_STAT_SUSPEND) != 0 1819 || (portstatus & USB_PORT_STAT_SUSPEND) != 0
1713 ) { 1820 ) {
1714 dev_dbg(hub->intfdev, 1821 dev_dbg(hub->intfdev,
1715 "port %d status %04x.%04x after resume, %d\n", 1822 "port %d status %04x.%04x after resume, %d\n",
1716 port1, portchange, devstatus, status); 1823 port1, portchange, portstatus, status);
1717 if (status >= 0) 1824 if (status >= 0)
1718 status = -ENODEV; 1825 status = -ENODEV;
1719 } else { 1826 } else {
@@ -1774,23 +1881,16 @@ static int remote_wakeup(struct usb_device *udev)
1774{ 1881{
1775 int status = 0; 1882 int status = 0;
1776 1883
1777 /* All this just to avoid sending a port-resume message
1778 * to the parent hub! */
1779
1780 usb_lock_device(udev); 1884 usb_lock_device(udev);
1781 usb_pm_lock(udev);
1782 if (udev->state == USB_STATE_SUSPENDED) { 1885 if (udev->state == USB_STATE_SUSPENDED) {
1783 dev_dbg(&udev->dev, "usb %sresume\n", "wakeup-"); 1886 dev_dbg(&udev->dev, "usb %sresume\n", "wakeup-");
1784 /* TRSMRCY = 10 msec */ 1887 status = usb_autoresume_device(udev);
1785 msleep(10); 1888
1786 status = finish_port_resume(udev); 1889 /* Give the interface drivers a chance to do something,
1890 * then autosuspend the device again. */
1787 if (status == 0) 1891 if (status == 0)
1788 udev->dev.power.power_state.event = PM_EVENT_ON; 1892 usb_autosuspend_device(udev);
1789 } 1893 }
1790 usb_pm_unlock(udev);
1791
1792 if (status == 0)
1793 usb_autoresume_device(udev, 0);
1794 usb_unlock_device(udev); 1894 usb_unlock_device(udev);
1795 return status; 1895 return status;
1796} 1896}
@@ -1854,6 +1954,8 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg)
1854 } 1954 }
1855 } 1955 }
1856 1956
1957 dev_dbg(&intf->dev, "%s\n", __FUNCTION__);
1958
1857 /* "global suspend" of the downstream HC-to-USB interface */ 1959 /* "global suspend" of the downstream HC-to-USB interface */
1858 if (!hdev->parent) { 1960 if (!hdev->parent) {
1859 struct usb_bus *bus = hdev->bus; 1961 struct usb_bus *bus = hdev->bus;
@@ -1876,10 +1978,12 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg)
1876 1978
1877static int hub_resume(struct usb_interface *intf) 1979static int hub_resume(struct usb_interface *intf)
1878{ 1980{
1879 struct usb_device *hdev = interface_to_usbdev(intf);
1880 struct usb_hub *hub = usb_get_intfdata (intf); 1981 struct usb_hub *hub = usb_get_intfdata (intf);
1982 struct usb_device *hdev = hub->hdev;
1881 int status; 1983 int status;
1882 1984
1985 dev_dbg(&intf->dev, "%s\n", __FUNCTION__);
1986
1883 /* "global resume" of the downstream HC-to-USB interface */ 1987 /* "global resume" of the downstream HC-to-USB interface */
1884 if (!hdev->parent) { 1988 if (!hdev->parent) {
1885 struct usb_bus *bus = hdev->bus; 1989 struct usb_bus *bus = hdev->bus;
@@ -1918,7 +2022,6 @@ void usb_resume_root_hub(struct usb_device *hdev)
1918{ 2022{
1919 struct usb_hub *hub = hdev_to_hub(hdev); 2023 struct usb_hub *hub = hdev_to_hub(hdev);
1920 2024
1921 hub->resume_root_hub = 1;
1922 kick_khubd(hub); 2025 kick_khubd(hub);
1923} 2026}
1924 2027
@@ -2269,7 +2372,7 @@ check_highspeed (struct usb_hub *hub, struct usb_device *udev, int port1)
2269 struct usb_qualifier_descriptor *qual; 2372 struct usb_qualifier_descriptor *qual;
2270 int status; 2373 int status;
2271 2374
2272 qual = kmalloc (sizeof *qual, SLAB_KERNEL); 2375 qual = kmalloc (sizeof *qual, GFP_KERNEL);
2273 if (qual == NULL) 2376 if (qual == NULL)
2274 return; 2377 return;
2275 2378
@@ -2281,7 +2384,7 @@ check_highspeed (struct usb_hub *hub, struct usb_device *udev, int port1)
2281 /* hub LEDs are probably harder to miss than syslog */ 2384 /* hub LEDs are probably harder to miss than syslog */
2282 if (hub->has_indicators) { 2385 if (hub->has_indicators) {
2283 hub->indicator[port1-1] = INDICATOR_GREEN_BLINK; 2386 hub->indicator[port1-1] = INDICATOR_GREEN_BLINK;
2284 schedule_work (&hub->leds); 2387 schedule_delayed_work (&hub->leds, 0);
2285 } 2388 }
2286 } 2389 }
2287 kfree(qual); 2390 kfree(qual);
@@ -2455,7 +2558,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
2455 if (hub->has_indicators) { 2558 if (hub->has_indicators) {
2456 hub->indicator[port1-1] = 2559 hub->indicator[port1-1] =
2457 INDICATOR_AMBER_BLINK; 2560 INDICATOR_AMBER_BLINK;
2458 schedule_work (&hub->leds); 2561 schedule_delayed_work (&hub->leds, 0);
2459 } 2562 }
2460 status = -ENOTCONN; /* Don't retry */ 2563 status = -ENOTCONN; /* Don't retry */
2461 goto loop_disable; 2564 goto loop_disable;
@@ -2555,16 +2658,13 @@ static void hub_events(void)
2555 intf = to_usb_interface(hub->intfdev); 2658 intf = to_usb_interface(hub->intfdev);
2556 hub_dev = &intf->dev; 2659 hub_dev = &intf->dev;
2557 2660
2558 i = hub->resume_root_hub; 2661 dev_dbg(hub_dev, "state %d ports %d chg %04x evt %04x\n",
2559
2560 dev_dbg(hub_dev, "state %d ports %d chg %04x evt %04x%s\n",
2561 hdev->state, hub->descriptor 2662 hdev->state, hub->descriptor
2562 ? hub->descriptor->bNbrPorts 2663 ? hub->descriptor->bNbrPorts
2563 : 0, 2664 : 0,
2564 /* NOTE: expects max 15 ports... */ 2665 /* NOTE: expects max 15 ports... */
2565 (u16) hub->change_bits[0], 2666 (u16) hub->change_bits[0],
2566 (u16) hub->event_bits[0], 2667 (u16) hub->event_bits[0]);
2567 i ? ", resume root" : "");
2568 2668
2569 usb_get_intf(intf); 2669 usb_get_intf(intf);
2570 spin_unlock_irq(&hub_event_lock); 2670 spin_unlock_irq(&hub_event_lock);
@@ -2585,16 +2685,16 @@ static void hub_events(void)
2585 goto loop; 2685 goto loop;
2586 } 2686 }
2587 2687
2588 /* Is this is a root hub wanting to reactivate the downstream 2688 /* Autoresume */
2589 * ports? If so, be sure the interface resumes even if its 2689 ret = usb_autopm_get_interface(intf);
2590 * stub "device" node was never suspended. 2690 if (ret) {
2591 */ 2691 dev_dbg(hub_dev, "Can't autoresume: %d\n", ret);
2592 if (i) 2692 goto loop;
2593 usb_autoresume_device(hdev, 0); 2693 }
2594 2694
2595 /* If this is an inactive or suspended hub, do nothing */ 2695 /* If this is an inactive hub, do nothing */
2596 if (hub->quiescing) 2696 if (hub->quiescing)
2597 goto loop; 2697 goto loop_autopm;
2598 2698
2599 if (hub->error) { 2699 if (hub->error) {
2600 dev_dbg (hub_dev, "resetting for error %d\n", 2700 dev_dbg (hub_dev, "resetting for error %d\n",
@@ -2604,7 +2704,7 @@ static void hub_events(void)
2604 if (ret) { 2704 if (ret) {
2605 dev_dbg (hub_dev, 2705 dev_dbg (hub_dev,
2606 "error resetting hub: %d\n", ret); 2706 "error resetting hub: %d\n", ret);
2607 goto loop; 2707 goto loop_autopm;
2608 } 2708 }
2609 2709
2610 hub->nerrors = 0; 2710 hub->nerrors = 0;
@@ -2732,6 +2832,10 @@ static void hub_events(void)
2732 if (!hdev->parent && !hub->busy_bits[0]) 2832 if (!hdev->parent && !hub->busy_bits[0])
2733 usb_enable_root_hub_irq(hdev->bus); 2833 usb_enable_root_hub_irq(hdev->bus);
2734 2834
2835loop_autopm:
2836 /* Allow autosuspend if we're not going to run again */
2837 if (list_empty(&hub->event_list))
2838 usb_autopm_enable(intf);
2735loop: 2839loop:
2736 usb_unlock_device(hdev); 2840 usb_unlock_device(hdev);
2737 usb_put_intf(intf); 2841 usb_put_intf(intf);
@@ -2773,6 +2877,7 @@ static struct usb_driver hub_driver = {
2773 .post_reset = hub_post_reset, 2877 .post_reset = hub_post_reset,
2774 .ioctl = hub_ioctl, 2878 .ioctl = hub_ioctl,
2775 .id_table = hub_id_table, 2879 .id_table = hub_id_table,
2880 .supports_autosuspend = 1,
2776}; 2881};
2777 2882
2778int usb_hub_init(void) 2883int usb_hub_init(void)
@@ -2818,7 +2923,7 @@ static int config_descriptors_changed(struct usb_device *udev)
2818 if (len < le16_to_cpu(udev->config[index].desc.wTotalLength)) 2923 if (len < le16_to_cpu(udev->config[index].desc.wTotalLength))
2819 len = le16_to_cpu(udev->config[index].desc.wTotalLength); 2924 len = le16_to_cpu(udev->config[index].desc.wTotalLength);
2820 } 2925 }
2821 buf = kmalloc (len, SLAB_KERNEL); 2926 buf = kmalloc (len, GFP_KERNEL);
2822 if (buf == NULL) { 2927 if (buf == NULL) {
2823 dev_err(&udev->dev, "no mem to re-read configs after reset\n"); 2928 dev_err(&udev->dev, "no mem to re-read configs after reset\n");
2824 /* assume the worst */ 2929 /* assume the worst */
@@ -2997,7 +3102,7 @@ int usb_reset_composite_device(struct usb_device *udev,
2997 } 3102 }
2998 3103
2999 /* Prevent autosuspend during the reset */ 3104 /* Prevent autosuspend during the reset */
3000 usb_autoresume_device(udev, 1); 3105 usb_autoresume_device(udev);
3001 3106
3002 if (iface && iface->condition != USB_INTERFACE_BINDING) 3107 if (iface && iface->condition != USB_INTERFACE_BINDING)
3003 iface = NULL; 3108 iface = NULL;
@@ -3040,7 +3145,7 @@ int usb_reset_composite_device(struct usb_device *udev,
3040 } 3145 }
3041 } 3146 }
3042 3147
3043 usb_autosuspend_device(udev, 1); 3148 usb_autosuspend_device(udev);
3044 return ret; 3149 return ret;
3045} 3150}
3046EXPORT_SYMBOL(usb_reset_composite_device); 3151EXPORT_SYMBOL(usb_reset_composite_device);
diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h
index 0f8e82a4d480..cf9559c6c9b6 100644
--- a/drivers/usb/core/hub.h
+++ b/drivers/usb/core/hub.h
@@ -192,45 +192,4 @@ struct usb_tt_clear {
192 192
193extern void usb_hub_tt_clear_buffer (struct usb_device *dev, int pipe); 193extern void usb_hub_tt_clear_buffer (struct usb_device *dev, int pipe);
194 194
195struct usb_hub {
196 struct device *intfdev; /* the "interface" device */
197 struct usb_device *hdev;
198 struct urb *urb; /* for interrupt polling pipe */
199
200 /* buffer for urb ... with extra space in case of babble */
201 char (*buffer)[8];
202 dma_addr_t buffer_dma; /* DMA address for buffer */
203 union {
204 struct usb_hub_status hub;
205 struct usb_port_status port;
206 } *status; /* buffer for status reports */
207
208 int error; /* last reported error */
209 int nerrors; /* track consecutive errors */
210
211 struct list_head event_list; /* hubs w/data or errs ready */
212 unsigned long event_bits[1]; /* status change bitmask */
213 unsigned long change_bits[1]; /* ports with logical connect
214 status change */
215 unsigned long busy_bits[1]; /* ports being reset or
216 resumed */
217#if USB_MAXCHILDREN > 31 /* 8*sizeof(unsigned long) - 1 */
218#error event_bits[] is too short!
219#endif
220
221 struct usb_hub_descriptor *descriptor; /* class descriptor */
222 struct usb_tt tt; /* Transaction Translator */
223
224 unsigned mA_per_port; /* current for each child */
225
226 unsigned limited_power:1;
227 unsigned quiescing:1;
228 unsigned activating:1;
229 unsigned resume_root_hub:1;
230
231 unsigned has_indicators:1;
232 enum hub_led_mode indicator[USB_MAXCHILDREN];
233 struct work_struct leds;
234};
235
236#endif /* __LINUX_HUB_H */ 195#endif /* __LINUX_HUB_H */
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index fccd1952bad3..149aa8bfb1fe 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -488,7 +488,7 @@ void usb_sg_wait (struct usb_sg_request *io)
488 int retval; 488 int retval;
489 489
490 io->urbs [i]->dev = io->dev; 490 io->urbs [i]->dev = io->dev;
491 retval = usb_submit_urb (io->urbs [i], SLAB_ATOMIC); 491 retval = usb_submit_urb (io->urbs [i], GFP_ATOMIC);
492 492
493 /* after we submit, let completions or cancelations fire; 493 /* after we submit, let completions or cancelations fire;
494 * we handshake using io->status. 494 * we handshake using io->status.
@@ -764,7 +764,7 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size)
764 err = -EINVAL; 764 err = -EINVAL;
765 goto errout; 765 goto errout;
766 } else { 766 } else {
767 dev->have_langid = -1; 767 dev->have_langid = 1;
768 dev->string_langid = tbuf[2] | (tbuf[3]<< 8); 768 dev->string_langid = tbuf[2] | (tbuf[3]<< 8);
769 /* always use the first langid listed */ 769 /* always use the first langid listed */
770 dev_dbg (&dev->dev, "default language 0x%04x\n", 770 dev_dbg (&dev->dev, "default language 0x%04x\n",
@@ -828,10 +828,7 @@ char *usb_cache_string(struct usb_device *udev, int index)
828 * Context: !in_interrupt () 828 * Context: !in_interrupt ()
829 * 829 *
830 * Updates the copy of the device descriptor stored in the device structure, 830 * Updates the copy of the device descriptor stored in the device structure,
831 * which dedicates space for this purpose. Note that several fields are 831 * which dedicates space for this purpose.
832 * converted to the host CPU's byte order: the USB version (bcdUSB), and
833 * vendors product and version fields (idVendor, idProduct, and bcdDevice).
834 * That lets device drivers compare against non-byteswapped constants.
835 * 832 *
836 * Not exported, only for use by the core. If drivers really want to read 833 * Not exported, only for use by the core. If drivers really want to read
837 * the device descriptor directly, they can call usb_get_descriptor() with 834 * the device descriptor directly, they can call usb_get_descriptor() with
@@ -1401,7 +1398,7 @@ free_interfaces:
1401 } 1398 }
1402 1399
1403 /* Wake up the device so we can send it the Set-Config request */ 1400 /* Wake up the device so we can send it the Set-Config request */
1404 ret = usb_autoresume_device(dev, 1); 1401 ret = usb_autoresume_device(dev);
1405 if (ret) 1402 if (ret)
1406 goto free_interfaces; 1403 goto free_interfaces;
1407 1404
@@ -1424,7 +1421,7 @@ free_interfaces:
1424 dev->actconfig = cp; 1421 dev->actconfig = cp;
1425 if (!cp) { 1422 if (!cp) {
1426 usb_set_device_state(dev, USB_STATE_ADDRESS); 1423 usb_set_device_state(dev, USB_STATE_ADDRESS);
1427 usb_autosuspend_device(dev, 1); 1424 usb_autosuspend_device(dev);
1428 goto free_interfaces; 1425 goto free_interfaces;
1429 } 1426 }
1430 usb_set_device_state(dev, USB_STATE_CONFIGURED); 1427 usb_set_device_state(dev, USB_STATE_CONFIGURED);
@@ -1493,7 +1490,7 @@ free_interfaces:
1493 usb_create_sysfs_intf_files (intf); 1490 usb_create_sysfs_intf_files (intf);
1494 } 1491 }
1495 1492
1496 usb_autosuspend_device(dev, 1); 1493 usb_autosuspend_device(dev);
1497 return 0; 1494 return 0;
1498} 1495}
1499 1496
@@ -1504,9 +1501,10 @@ struct set_config_request {
1504}; 1501};
1505 1502
1506/* Worker routine for usb_driver_set_configuration() */ 1503/* Worker routine for usb_driver_set_configuration() */
1507static void driver_set_config_work(void *_req) 1504static void driver_set_config_work(struct work_struct *work)
1508{ 1505{
1509 struct set_config_request *req = _req; 1506 struct set_config_request *req =
1507 container_of(work, struct set_config_request, work);
1510 1508
1511 usb_lock_device(req->udev); 1509 usb_lock_device(req->udev);
1512 usb_set_configuration(req->udev, req->config); 1510 usb_set_configuration(req->udev, req->config);
@@ -1544,7 +1542,7 @@ int usb_driver_set_configuration(struct usb_device *udev, int config)
1544 return -ENOMEM; 1542 return -ENOMEM;
1545 req->udev = udev; 1543 req->udev = udev;
1546 req->config = config; 1544 req->config = config;
1547 INIT_WORK(&req->work, driver_set_config_work, req); 1545 INIT_WORK(&req->work, driver_set_config_work);
1548 1546
1549 usb_get_dev(udev); 1547 usb_get_dev(udev);
1550 if (!schedule_work(&req->work)) { 1548 if (!schedule_work(&req->work)) {
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 467cb02832f3..02426d0b9a34 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -200,19 +200,13 @@ static void ksuspend_usb_cleanup(void)
200 destroy_workqueue(ksuspend_usb_wq); 200 destroy_workqueue(ksuspend_usb_wq);
201} 201}
202 202
203#else
204
205#define ksuspend_usb_init() 0
206#define ksuspend_usb_cleanup() do {} while (0)
207
208#endif
209
210#ifdef CONFIG_USB_SUSPEND 203#ifdef CONFIG_USB_SUSPEND
211 204
212/* usb_autosuspend_work - callback routine to autosuspend a USB device */ 205/* usb_autosuspend_work - callback routine to autosuspend a USB device */
213static void usb_autosuspend_work(void *_udev) 206static void usb_autosuspend_work(struct work_struct *work)
214{ 207{
215 struct usb_device *udev = _udev; 208 struct usb_device *udev =
209 container_of(work, struct usb_device, autosuspend.work);
216 210
217 usb_pm_lock(udev); 211 usb_pm_lock(udev);
218 udev->auto_pm = 1; 212 udev->auto_pm = 1;
@@ -222,10 +216,17 @@ static void usb_autosuspend_work(void *_udev)
222 216
223#else 217#else
224 218
225static void usb_autosuspend_work(void *_udev) 219static void usb_autosuspend_work(struct work_struct *work)
226{} 220{}
227 221
228#endif 222#endif /* CONFIG_USB_SUSPEND */
223
224#else
225
226#define ksuspend_usb_init() 0
227#define ksuspend_usb_cleanup() do {} while (0)
228
229#endif /* CONFIG_PM */
229 230
230/** 231/**
231 * usb_alloc_dev - usb device constructor (usbcore-internal) 232 * usb_alloc_dev - usb device constructor (usbcore-internal)
@@ -304,7 +305,7 @@ usb_alloc_dev(struct usb_device *parent, struct usb_bus *bus, unsigned port1)
304 305
305#ifdef CONFIG_PM 306#ifdef CONFIG_PM
306 mutex_init(&dev->pm_mutex); 307 mutex_init(&dev->pm_mutex);
307 INIT_WORK(&dev->autosuspend, usb_autosuspend_work, dev); 308 INIT_DELAYED_WORK(&dev->autosuspend, usb_autosuspend_work);
308#endif 309#endif
309 return dev; 310 return dev;
310} 311}
@@ -537,138 +538,6 @@ int usb_get_current_frame_number(struct usb_device *dev)
537 return usb_hcd_get_frame_number (dev); 538 return usb_hcd_get_frame_number (dev);
538} 539}
539 540
540/**
541 * usb_endpoint_dir_in - check if the endpoint has IN direction
542 * @epd: endpoint to be checked
543 *
544 * Returns true if the endpoint is of type IN, otherwise it returns false.
545 */
546int usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd)
547{
548 return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN);
549}
550
551/**
552 * usb_endpoint_dir_out - check if the endpoint has OUT direction
553 * @epd: endpoint to be checked
554 *
555 * Returns true if the endpoint is of type OUT, otherwise it returns false.
556 */
557int usb_endpoint_dir_out(const struct usb_endpoint_descriptor *epd)
558{
559 return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT);
560}
561
562/**
563 * usb_endpoint_xfer_bulk - check if the endpoint has bulk transfer type
564 * @epd: endpoint to be checked
565 *
566 * Returns true if the endpoint is of type bulk, otherwise it returns false.
567 */
568int usb_endpoint_xfer_bulk(const struct usb_endpoint_descriptor *epd)
569{
570 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
571 USB_ENDPOINT_XFER_BULK);
572}
573
574/**
575 * usb_endpoint_xfer_int - check if the endpoint has interrupt transfer type
576 * @epd: endpoint to be checked
577 *
578 * Returns true if the endpoint is of type interrupt, otherwise it returns
579 * false.
580 */
581int usb_endpoint_xfer_int(const struct usb_endpoint_descriptor *epd)
582{
583 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
584 USB_ENDPOINT_XFER_INT);
585}
586
587/**
588 * usb_endpoint_xfer_isoc - check if the endpoint has isochronous transfer type
589 * @epd: endpoint to be checked
590 *
591 * Returns true if the endpoint is of type isochronous, otherwise it returns
592 * false.
593 */
594int usb_endpoint_xfer_isoc(const struct usb_endpoint_descriptor *epd)
595{
596 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
597 USB_ENDPOINT_XFER_ISOC);
598}
599
600/**
601 * usb_endpoint_is_bulk_in - check if the endpoint is bulk IN
602 * @epd: endpoint to be checked
603 *
604 * Returns true if the endpoint has bulk transfer type and IN direction,
605 * otherwise it returns false.
606 */
607int usb_endpoint_is_bulk_in(const struct usb_endpoint_descriptor *epd)
608{
609 return (usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_in(epd));
610}
611
612/**
613 * usb_endpoint_is_bulk_out - check if the endpoint is bulk OUT
614 * @epd: endpoint to be checked
615 *
616 * Returns true if the endpoint has bulk transfer type and OUT direction,
617 * otherwise it returns false.
618 */
619int usb_endpoint_is_bulk_out(const struct usb_endpoint_descriptor *epd)
620{
621 return (usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_out(epd));
622}
623
624/**
625 * usb_endpoint_is_int_in - check if the endpoint is interrupt IN
626 * @epd: endpoint to be checked
627 *
628 * Returns true if the endpoint has interrupt transfer type and IN direction,
629 * otherwise it returns false.
630 */
631int usb_endpoint_is_int_in(const struct usb_endpoint_descriptor *epd)
632{
633 return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd));
634}
635
636/**
637 * usb_endpoint_is_int_out - check if the endpoint is interrupt OUT
638 * @epd: endpoint to be checked
639 *
640 * Returns true if the endpoint has interrupt transfer type and OUT direction,
641 * otherwise it returns false.
642 */
643int usb_endpoint_is_int_out(const struct usb_endpoint_descriptor *epd)
644{
645 return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_out(epd));
646}
647
648/**
649 * usb_endpoint_is_isoc_in - check if the endpoint is isochronous IN
650 * @epd: endpoint to be checked
651 *
652 * Returns true if the endpoint has isochronous transfer type and IN direction,
653 * otherwise it returns false.
654 */
655int usb_endpoint_is_isoc_in(const struct usb_endpoint_descriptor *epd)
656{
657 return (usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_in(epd));
658}
659
660/**
661 * usb_endpoint_is_isoc_out - check if the endpoint is isochronous OUT
662 * @epd: endpoint to be checked
663 *
664 * Returns true if the endpoint has isochronous transfer type and OUT direction,
665 * otherwise it returns false.
666 */
667int usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor *epd)
668{
669 return (usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_out(epd));
670}
671
672/*-------------------------------------------------------------------*/ 541/*-------------------------------------------------------------------*/
673/* 542/*
674 * __usb_get_extra_descriptor() finds a descriptor of specific type in the 543 * __usb_get_extra_descriptor() finds a descriptor of specific type in the
@@ -1102,18 +971,6 @@ EXPORT_SYMBOL(__usb_get_extra_descriptor);
1102EXPORT_SYMBOL(usb_find_device); 971EXPORT_SYMBOL(usb_find_device);
1103EXPORT_SYMBOL(usb_get_current_frame_number); 972EXPORT_SYMBOL(usb_get_current_frame_number);
1104 973
1105EXPORT_SYMBOL_GPL(usb_endpoint_dir_in);
1106EXPORT_SYMBOL_GPL(usb_endpoint_dir_out);
1107EXPORT_SYMBOL_GPL(usb_endpoint_xfer_bulk);
1108EXPORT_SYMBOL_GPL(usb_endpoint_xfer_int);
1109EXPORT_SYMBOL_GPL(usb_endpoint_xfer_isoc);
1110EXPORT_SYMBOL_GPL(usb_endpoint_is_bulk_in);
1111EXPORT_SYMBOL_GPL(usb_endpoint_is_bulk_out);
1112EXPORT_SYMBOL_GPL(usb_endpoint_is_int_in);
1113EXPORT_SYMBOL_GPL(usb_endpoint_is_int_out);
1114EXPORT_SYMBOL_GPL(usb_endpoint_is_isoc_in);
1115EXPORT_SYMBOL_GPL(usb_endpoint_is_isoc_out);
1116
1117EXPORT_SYMBOL (usb_buffer_alloc); 974EXPORT_SYMBOL (usb_buffer_alloc);
1118EXPORT_SYMBOL (usb_buffer_free); 975EXPORT_SYMBOL (usb_buffer_free);
1119 976
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
index 13322e33f912..17830a81be14 100644
--- a/drivers/usb/core/usb.h
+++ b/drivers/usb/core/usb.h
@@ -64,14 +64,13 @@ static inline void usb_pm_unlock(struct usb_device *udev) {}
64 64
65#define USB_AUTOSUSPEND_DELAY (HZ*2) 65#define USB_AUTOSUSPEND_DELAY (HZ*2)
66 66
67extern void usb_autosuspend_device(struct usb_device *udev, int dec_busy_cnt); 67extern void usb_autosuspend_device(struct usb_device *udev);
68extern int usb_autoresume_device(struct usb_device *udev, int inc_busy_cnt); 68extern int usb_autoresume_device(struct usb_device *udev);
69 69
70#else 70#else
71 71
72#define usb_autosuspend_device(udev, dec_busy_cnt) do {} while (0) 72#define usb_autosuspend_device(udev) do {} while (0)
73static inline int usb_autoresume_device(struct usb_device *udev, 73static inline int usb_autoresume_device(struct usb_device *udev)
74 int inc_busy_cnt)
75{ 74{
76 return 0; 75 return 0;
77} 76}
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index bbbc82a8336a..4097a86c4b5e 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -189,7 +189,7 @@ config USB_OTG
189 189
190config USB_GADGET_AT91 190config USB_GADGET_AT91
191 boolean "AT91 USB Device Port" 191 boolean "AT91 USB Device Port"
192 depends on ARCH_AT91RM9200 192 depends on ARCH_AT91
193 select USB_GADGET_SELECTED 193 select USB_GADGET_SELECTED
194 help 194 help
195 Many Atmel AT91 processors (such as the AT91RM2000) have a 195 Many Atmel AT91 processors (such as the AT91RM2000) have a
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 1c17d26d03b8..d15bf22b9a03 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -1833,9 +1833,9 @@ static void rx_fill (struct eth_dev *dev, gfp_t gfp_flags)
1833 spin_unlock_irqrestore(&dev->req_lock, flags); 1833 spin_unlock_irqrestore(&dev->req_lock, flags);
1834} 1834}
1835 1835
1836static void eth_work (void *_dev) 1836static void eth_work (struct work_struct *work)
1837{ 1837{
1838 struct eth_dev *dev = _dev; 1838 struct eth_dev *dev = container_of(work, struct eth_dev, work);
1839 1839
1840 if (test_and_clear_bit (WORK_RX_MEMORY, &dev->todo)) { 1840 if (test_and_clear_bit (WORK_RX_MEMORY, &dev->todo)) {
1841 if (netif_running (dev->net)) 1841 if (netif_running (dev->net))
@@ -1894,13 +1894,13 @@ static int eth_start_xmit (struct sk_buff *skb, struct net_device *net)
1894 if (!eth_is_promisc (dev)) { 1894 if (!eth_is_promisc (dev)) {
1895 u8 *dest = skb->data; 1895 u8 *dest = skb->data;
1896 1896
1897 if (dest [0] & 0x01) { 1897 if (is_multicast_ether_addr(dest)) {
1898 u16 type; 1898 u16 type;
1899 1899
1900 /* ignores USB_CDC_PACKET_TYPE_MULTICAST and host 1900 /* ignores USB_CDC_PACKET_TYPE_MULTICAST and host
1901 * SET_ETHERNET_MULTICAST_FILTERS requests 1901 * SET_ETHERNET_MULTICAST_FILTERS requests
1902 */ 1902 */
1903 if (memcmp (dest, net->broadcast, ETH_ALEN) == 0) 1903 if (is_broadcast_ether_addr(dest))
1904 type = USB_CDC_PACKET_TYPE_BROADCAST; 1904 type = USB_CDC_PACKET_TYPE_BROADCAST;
1905 else 1905 else
1906 type = USB_CDC_PACKET_TYPE_ALL_MULTICAST; 1906 type = USB_CDC_PACKET_TYPE_ALL_MULTICAST;
@@ -2398,7 +2398,7 @@ autoconf_fail:
2398 dev = netdev_priv(net); 2398 dev = netdev_priv(net);
2399 spin_lock_init (&dev->lock); 2399 spin_lock_init (&dev->lock);
2400 spin_lock_init (&dev->req_lock); 2400 spin_lock_init (&dev->req_lock);
2401 INIT_WORK (&dev->work, eth_work, dev); 2401 INIT_WORK (&dev->work, eth_work);
2402 INIT_LIST_HEAD (&dev->tx_reqs); 2402 INIT_LIST_HEAD (&dev->tx_reqs);
2403 INIT_LIST_HEAD (&dev->rx_reqs); 2403 INIT_LIST_HEAD (&dev->rx_reqs);
2404 2404
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
index 8b975d15538d..c98316ce8384 100644
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -250,7 +250,7 @@
250#include <linux/slab.h> 250#include <linux/slab.h>
251#include <linux/spinlock.h> 251#include <linux/spinlock.h>
252#include <linux/string.h> 252#include <linux/string.h>
253#include <linux/suspend.h> 253#include <linux/freezer.h>
254#include <linux/utsname.h> 254#include <linux/utsname.h>
255 255
256#include <linux/usb_ch9.h> 256#include <linux/usb_ch9.h>
diff --git a/drivers/usb/gadget/gmidi.c b/drivers/usb/gadget/gmidi.c
index 64554acad63f..31351826f2ba 100644
--- a/drivers/usb/gadget/gmidi.c
+++ b/drivers/usb/gadget/gmidi.c
@@ -1236,7 +1236,7 @@ autoconf_fail:
1236 1236
1237 1237
1238 /* ok, we made sense of the hardware ... */ 1238 /* ok, we made sense of the hardware ... */
1239 dev = kzalloc(sizeof(*dev), SLAB_KERNEL); 1239 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
1240 if (!dev) { 1240 if (!dev) {
1241 return -ENOMEM; 1241 return -ENOMEM;
1242 } 1242 }
diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c
index a3076da3f4eb..805a9826842d 100644
--- a/drivers/usb/gadget/goku_udc.c
+++ b/drivers/usb/gadget/goku_udc.c
@@ -1864,7 +1864,7 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1864 } 1864 }
1865 1865
1866 /* alloc, and start init */ 1866 /* alloc, and start init */
1867 dev = kmalloc (sizeof *dev, SLAB_KERNEL); 1867 dev = kmalloc (sizeof *dev, GFP_KERNEL);
1868 if (dev == NULL){ 1868 if (dev == NULL){
1869 pr_debug("enomem %s\n", pci_name(pdev)); 1869 pr_debug("enomem %s\n", pci_name(pdev));
1870 retval = -ENOMEM; 1870 retval = -ENOMEM;
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c
index 86924f9cdd7e..3fb1044a4db0 100644
--- a/drivers/usb/gadget/inode.c
+++ b/drivers/usb/gadget/inode.c
@@ -412,7 +412,7 @@ ep_read (struct file *fd, char __user *buf, size_t len, loff_t *ptr)
412 /* FIXME readahead for O_NONBLOCK and poll(); careful with ZLPs */ 412 /* FIXME readahead for O_NONBLOCK and poll(); careful with ZLPs */
413 413
414 value = -ENOMEM; 414 value = -ENOMEM;
415 kbuf = kmalloc (len, SLAB_KERNEL); 415 kbuf = kmalloc (len, GFP_KERNEL);
416 if (unlikely (!kbuf)) 416 if (unlikely (!kbuf))
417 goto free1; 417 goto free1;
418 418
@@ -456,7 +456,7 @@ ep_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
456 /* FIXME writebehind for O_NONBLOCK and poll(), qlen = 1 */ 456 /* FIXME writebehind for O_NONBLOCK and poll(), qlen = 1 */
457 457
458 value = -ENOMEM; 458 value = -ENOMEM;
459 kbuf = kmalloc (len, SLAB_KERNEL); 459 kbuf = kmalloc (len, GFP_KERNEL);
460 if (!kbuf) 460 if (!kbuf)
461 goto free1; 461 goto free1;
462 if (copy_from_user (kbuf, buf, len)) { 462 if (copy_from_user (kbuf, buf, len)) {
@@ -1898,7 +1898,7 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
1898 buf += 4; 1898 buf += 4;
1899 length -= 4; 1899 length -= 4;
1900 1900
1901 kbuf = kmalloc (length, SLAB_KERNEL); 1901 kbuf = kmalloc (length, GFP_KERNEL);
1902 if (!kbuf) 1902 if (!kbuf)
1903 return -ENOMEM; 1903 return -ENOMEM;
1904 if (copy_from_user (kbuf, buf, length)) { 1904 if (copy_from_user (kbuf, buf, length)) {
diff --git a/drivers/usb/gadget/lh7a40x_udc.c b/drivers/usb/gadget/lh7a40x_udc.c
index 179259664c18..4a991564a03e 100644
--- a/drivers/usb/gadget/lh7a40x_udc.c
+++ b/drivers/usb/gadget/lh7a40x_udc.c
@@ -83,7 +83,6 @@ static int lh7a40x_queue(struct usb_ep *ep, struct usb_request *, gfp_t);
83static int lh7a40x_dequeue(struct usb_ep *ep, struct usb_request *); 83static int lh7a40x_dequeue(struct usb_ep *ep, struct usb_request *);
84static int lh7a40x_set_halt(struct usb_ep *ep, int); 84static int lh7a40x_set_halt(struct usb_ep *ep, int);
85static int lh7a40x_fifo_status(struct usb_ep *ep); 85static int lh7a40x_fifo_status(struct usb_ep *ep);
86static int lh7a40x_fifo_status(struct usb_ep *ep);
87static void lh7a40x_fifo_flush(struct usb_ep *ep); 86static void lh7a40x_fifo_flush(struct usb_ep *ep);
88static void lh7a40x_ep0_kick(struct lh7a40x_udc *dev, struct lh7a40x_ep *ep); 87static void lh7a40x_ep0_kick(struct lh7a40x_udc *dev, struct lh7a40x_ep *ep);
89static void lh7a40x_handle_ep0(struct lh7a40x_udc *dev, u32 intr); 88static void lh7a40x_handle_ep0(struct lh7a40x_udc *dev, u32 intr);
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index 3acc896a5d4c..3024c679e38e 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -1040,6 +1040,7 @@ net2280_queue (struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
1040 1040
1041 } /* else the irq handler advances the queue. */ 1041 } /* else the irq handler advances the queue. */
1042 1042
1043 ep->responded = 1;
1043 if (req) 1044 if (req)
1044 list_add_tail (&req->queue, &ep->queue); 1045 list_add_tail (&req->queue, &ep->queue);
1045done: 1046done:
@@ -2188,7 +2189,8 @@ static void handle_ep_small (struct net2280_ep *ep)
2188 ep->stopped = 1; 2189 ep->stopped = 1;
2189 set_halt (ep); 2190 set_halt (ep);
2190 mode = 2; 2191 mode = 2;
2191 } else if (!req && !ep->stopped) 2192 } else if (ep->responded &&
2193 !req && !ep->stopped)
2192 write_fifo (ep, NULL); 2194 write_fifo (ep, NULL);
2193 } 2195 }
2194 } else { 2196 } else {
@@ -2203,7 +2205,7 @@ static void handle_ep_small (struct net2280_ep *ep)
2203 } else if (((t & (1 << DATA_OUT_PING_TOKEN_INTERRUPT)) 2205 } else if (((t & (1 << DATA_OUT_PING_TOKEN_INTERRUPT))
2204 && req 2206 && req
2205 && req->req.actual == req->req.length) 2207 && req->req.actual == req->req.length)
2206 || !req) { 2208 || (ep->responded && !req)) {
2207 ep->dev->protocol_stall = 1; 2209 ep->dev->protocol_stall = 1;
2208 set_halt (ep); 2210 set_halt (ep);
2209 ep->stopped = 1; 2211 ep->stopped = 1;
@@ -2469,6 +2471,7 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
2469 /* we made the hardware handle most lowlevel requests; 2471 /* we made the hardware handle most lowlevel requests;
2470 * everything else goes uplevel to the gadget code. 2472 * everything else goes uplevel to the gadget code.
2471 */ 2473 */
2474 ep->responded = 1;
2472 switch (u.r.bRequest) { 2475 switch (u.r.bRequest) {
2473 case USB_REQ_GET_STATUS: { 2476 case USB_REQ_GET_STATUS: {
2474 struct net2280_ep *e; 2477 struct net2280_ep *e;
@@ -2537,6 +2540,7 @@ delegate:
2537 u.r.bRequestType, u.r.bRequest, 2540 u.r.bRequestType, u.r.bRequest,
2538 w_value, w_index, w_length, 2541 w_value, w_index, w_length,
2539 readl (&ep->regs->ep_cfg)); 2542 readl (&ep->regs->ep_cfg));
2543 ep->responded = 0;
2540 spin_unlock (&dev->lock); 2544 spin_unlock (&dev->lock);
2541 tmp = dev->driver->setup (&dev->gadget, &u.r); 2545 tmp = dev->driver->setup (&dev->gadget, &u.r);
2542 spin_lock (&dev->lock); 2546 spin_lock (&dev->lock);
@@ -2857,7 +2861,7 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
2857 } 2861 }
2858 2862
2859 /* alloc, and start init */ 2863 /* alloc, and start init */
2860 dev = kzalloc (sizeof *dev, SLAB_KERNEL); 2864 dev = kzalloc (sizeof *dev, GFP_KERNEL);
2861 if (dev == NULL){ 2865 if (dev == NULL){
2862 retval = -ENOMEM; 2866 retval = -ENOMEM;
2863 goto done; 2867 goto done;
diff --git a/drivers/usb/gadget/net2280.h b/drivers/usb/gadget/net2280.h
index 957d6df34015..44ca139983d8 100644
--- a/drivers/usb/gadget/net2280.h
+++ b/drivers/usb/gadget/net2280.h
@@ -110,7 +110,8 @@ struct net2280_ep {
110 out_overflow : 1, 110 out_overflow : 1,
111 stopped : 1, 111 stopped : 1,
112 is_in : 1, 112 is_in : 1,
113 is_iso : 1; 113 is_iso : 1,
114 responded : 1;
114}; 115};
115 116
116static inline void allow_status (struct net2280_ep *ep) 117static inline void allow_status (struct net2280_ep *ep)
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c
index 48a09fd89d18..030d87c28c2f 100644
--- a/drivers/usb/gadget/omap_udc.c
+++ b/drivers/usb/gadget/omap_udc.c
@@ -2581,7 +2581,7 @@ omap_udc_setup(struct platform_device *odev, struct otg_transceiver *xceiv)
2581 /* UDC_PULLUP_EN gates the chip clock */ 2581 /* UDC_PULLUP_EN gates the chip clock */
2582 // OTG_SYSCON_1_REG |= DEV_IDLE_EN; 2582 // OTG_SYSCON_1_REG |= DEV_IDLE_EN;
2583 2583
2584 udc = kzalloc(sizeof(*udc), SLAB_KERNEL); 2584 udc = kzalloc(sizeof(*udc), GFP_KERNEL);
2585 if (!udc) 2585 if (!udc)
2586 return -ENOMEM; 2586 return -ENOMEM;
2587 2587
diff --git a/drivers/usb/gadget/pxa2xx_udc.c b/drivers/usb/gadget/pxa2xx_udc.c
index 671c24bc6d75..1ed506e95985 100644
--- a/drivers/usb/gadget/pxa2xx_udc.c
+++ b/drivers/usb/gadget/pxa2xx_udc.c
@@ -2472,6 +2472,7 @@ static struct pxa2xx_udc memory = {
2472#define PXA210_B1 0x00000123 2472#define PXA210_B1 0x00000123
2473#define PXA210_B0 0x00000122 2473#define PXA210_B0 0x00000122
2474#define IXP425_A0 0x000001c1 2474#define IXP425_A0 0x000001c1
2475#define IXP425_B0 0x000001f1
2475#define IXP465_AD 0x00000200 2476#define IXP465_AD 0x00000200
2476 2477
2477/* 2478/*
@@ -2509,6 +2510,7 @@ static int __init pxa2xx_udc_probe(struct platform_device *pdev)
2509 break; 2510 break;
2510#elif defined(CONFIG_ARCH_IXP4XX) 2511#elif defined(CONFIG_ARCH_IXP4XX)
2511 case IXP425_A0: 2512 case IXP425_A0:
2513 case IXP425_B0:
2512 case IXP465_AD: 2514 case IXP465_AD:
2513 dev->has_cfr = 1; 2515 dev->has_cfr = 1;
2514 out_dma = 0; 2516 out_dma = 0;
diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c
index 0f809dd68492..40710ea1b490 100644
--- a/drivers/usb/gadget/zero.c
+++ b/drivers/usb/gadget/zero.c
@@ -1190,7 +1190,7 @@ autoconf_fail:
1190 1190
1191 1191
1192 /* ok, we made sense of the hardware ... */ 1192 /* ok, we made sense of the hardware ... */
1193 dev = kzalloc(sizeof(*dev), SLAB_KERNEL); 1193 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
1194 if (!dev) 1194 if (!dev)
1195 return -ENOMEM; 1195 return -ENOMEM;
1196 spin_lock_init (&dev->lock); 1196 spin_lock_init (&dev->lock);
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index cf10cbc98f80..cc60759083bf 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -153,7 +153,7 @@ config USB_U132_HCD
153 adapter will *NOT* work with PC cards that do not contain an OHCI 153 adapter will *NOT* work with PC cards that do not contain an OHCI
154 controller. 154 controller.
155 155
156 For those PC cards that contain multiple OHCI controllers only ther 156 For those PC cards that contain multiple OHCI controllers only the
157 first one is used. 157 first one is used.
158 158
159 The driver consists of two modules, the "ftdi-elan" module is a 159 The driver consists of two modules, the "ftdi-elan" module is a
diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c
index 34b7a31cd85b..56349d21e6ea 100644
--- a/drivers/usb/host/ehci-dbg.c
+++ b/drivers/usb/host/ehci-dbg.c
@@ -492,7 +492,7 @@ show_periodic (struct class_device *class_dev, char *buf)
492 unsigned i; 492 unsigned i;
493 __le32 tag; 493 __le32 tag;
494 494
495 if (!(seen = kmalloc (DBG_SCHED_LIMIT * sizeof *seen, SLAB_ATOMIC))) 495 if (!(seen = kmalloc (DBG_SCHED_LIMIT * sizeof *seen, GFP_ATOMIC)))
496 return 0; 496 return 0;
497 seen_count = 0; 497 seen_count = 0;
498 498
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 9030994aba98..025d33313681 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -126,6 +126,11 @@ static unsigned park = 0;
126module_param (park, uint, S_IRUGO); 126module_param (park, uint, S_IRUGO);
127MODULE_PARM_DESC (park, "park setting; 1-3 back-to-back async packets"); 127MODULE_PARM_DESC (park, "park setting; 1-3 back-to-back async packets");
128 128
129/* for flakey hardware, ignore overcurrent indicators */
130static int ignore_oc = 0;
131module_param (ignore_oc, bool, S_IRUGO);
132MODULE_PARM_DESC (ignore_oc, "ignore bogus hardware overcurrent indications");
133
129#define INTR_MASK (STS_IAA | STS_FATAL | STS_PCD | STS_ERR | STS_INT) 134#define INTR_MASK (STS_IAA | STS_FATAL | STS_PCD | STS_ERR | STS_INT)
130 135
131/*-------------------------------------------------------------------------*/ 136/*-------------------------------------------------------------------------*/
@@ -541,9 +546,10 @@ static int ehci_run (struct usb_hcd *hcd)
541 546
542 temp = HC_VERSION(readl (&ehci->caps->hc_capbase)); 547 temp = HC_VERSION(readl (&ehci->caps->hc_capbase));
543 ehci_info (ehci, 548 ehci_info (ehci,
544 "USB %x.%x started, EHCI %x.%02x, driver %s\n", 549 "USB %x.%x started, EHCI %x.%02x, driver %s%s\n",
545 ((ehci->sbrn & 0xf0)>>4), (ehci->sbrn & 0x0f), 550 ((ehci->sbrn & 0xf0)>>4), (ehci->sbrn & 0x0f),
546 temp >> 8, temp & 0xff, DRIVER_VERSION); 551 temp >> 8, temp & 0xff, DRIVER_VERSION,
552 ignore_oc ? ", overcurrent ignored" : "");
547 553
548 writel (INTR_MASK, &ehci->regs->intr_enable); /* Turn On Interrupts */ 554 writel (INTR_MASK, &ehci->regs->intr_enable); /* Turn On Interrupts */
549 555
@@ -613,9 +619,8 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd)
613 unsigned i = HCS_N_PORTS (ehci->hcs_params); 619 unsigned i = HCS_N_PORTS (ehci->hcs_params);
614 620
615 /* resume root hub? */ 621 /* resume root hub? */
616 status = readl (&ehci->regs->command); 622 if (!(readl(&ehci->regs->command) & CMD_RUN))
617 if (!(status & CMD_RUN)) 623 usb_hcd_resume_root_hub(hcd);
618 writel (status | CMD_RUN, &ehci->regs->command);
619 624
620 while (i--) { 625 while (i--) {
621 int pstatus = readl (&ehci->regs->port_status [i]); 626 int pstatus = readl (&ehci->regs->port_status [i]);
@@ -632,7 +637,6 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd)
632 */ 637 */
633 ehci->reset_done [i] = jiffies + msecs_to_jiffies (20); 638 ehci->reset_done [i] = jiffies + msecs_to_jiffies (20);
634 ehci_dbg (ehci, "port %d remote wakeup\n", i + 1); 639 ehci_dbg (ehci, "port %d remote wakeup\n", i + 1);
635 usb_hcd_resume_root_hub(hcd);
636 } 640 }
637 } 641 }
638 642
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index 1b20722c102b..bfe5f307cba6 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -34,6 +34,7 @@ static int ehci_bus_suspend (struct usb_hcd *hcd)
34{ 34{
35 struct ehci_hcd *ehci = hcd_to_ehci (hcd); 35 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
36 int port; 36 int port;
37 int mask;
37 38
38 if (time_before (jiffies, ehci->next_statechange)) 39 if (time_before (jiffies, ehci->next_statechange))
39 msleep(5); 40 msleep(5);
@@ -51,14 +52,25 @@ static int ehci_bus_suspend (struct usb_hcd *hcd)
51 ehci->reclaim_ready = 1; 52 ehci->reclaim_ready = 1;
52 ehci_work(ehci); 53 ehci_work(ehci);
53 54
54 /* suspend any active/unsuspended ports, maybe allow wakeup */ 55 /* Unlike other USB host controller types, EHCI doesn't have
56 * any notion of "global" or bus-wide suspend. The driver has
57 * to manually suspend all the active unsuspended ports, and
58 * then manually resume them in the bus_resume() routine.
59 */
60 ehci->bus_suspended = 0;
55 while (port--) { 61 while (port--) {
56 u32 __iomem *reg = &ehci->regs->port_status [port]; 62 u32 __iomem *reg = &ehci->regs->port_status [port];
57 u32 t1 = readl (reg) & ~PORT_RWC_BITS; 63 u32 t1 = readl (reg) & ~PORT_RWC_BITS;
58 u32 t2 = t1; 64 u32 t2 = t1;
59 65
60 if ((t1 & PORT_PE) && !(t1 & PORT_OWNER)) 66 /* keep track of which ports we suspend */
67 if ((t1 & PORT_PE) && !(t1 & PORT_OWNER) &&
68 !(t1 & PORT_SUSPEND)) {
61 t2 |= PORT_SUSPEND; 69 t2 |= PORT_SUSPEND;
70 set_bit(port, &ehci->bus_suspended);
71 }
72
73 /* enable remote wakeup on all ports */
62 if (device_may_wakeup(&hcd->self.root_hub->dev)) 74 if (device_may_wakeup(&hcd->self.root_hub->dev))
63 t2 |= PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E; 75 t2 |= PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E;
64 else 76 else
@@ -76,6 +88,13 @@ static int ehci_bus_suspend (struct usb_hcd *hcd)
76 ehci_halt (ehci); 88 ehci_halt (ehci);
77 hcd->state = HC_STATE_SUSPENDED; 89 hcd->state = HC_STATE_SUSPENDED;
78 90
91 /* allow remote wakeup */
92 mask = INTR_MASK;
93 if (!device_may_wakeup(&hcd->self.root_hub->dev))
94 mask &= ~STS_PCD;
95 writel(mask, &ehci->regs->intr_enable);
96 readl(&ehci->regs->intr_enable);
97
79 ehci->next_statechange = jiffies + msecs_to_jiffies(10); 98 ehci->next_statechange = jiffies + msecs_to_jiffies(10);
80 spin_unlock_irq (&ehci->lock); 99 spin_unlock_irq (&ehci->lock);
81 return 0; 100 return 0;
@@ -88,7 +107,6 @@ static int ehci_bus_resume (struct usb_hcd *hcd)
88 struct ehci_hcd *ehci = hcd_to_ehci (hcd); 107 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
89 u32 temp; 108 u32 temp;
90 int i; 109 int i;
91 int intr_enable;
92 110
93 if (time_before (jiffies, ehci->next_statechange)) 111 if (time_before (jiffies, ehci->next_statechange))
94 msleep(5); 112 msleep(5);
@@ -100,31 +118,30 @@ static int ehci_bus_resume (struct usb_hcd *hcd)
100 * the last user of the controller, not reset/pm hardware keeping 118 * the last user of the controller, not reset/pm hardware keeping
101 * state we gave to it. 119 * state we gave to it.
102 */ 120 */
121 temp = readl(&ehci->regs->intr_enable);
122 ehci_dbg(ehci, "resume root hub%s\n", temp ? "" : " after power loss");
103 123
104 /* re-init operational registers in case we lost power */ 124 /* at least some APM implementations will try to deliver
105 if (readl (&ehci->regs->intr_enable) == 0) { 125 * IRQs right away, so delay them until we're ready.
106 /* at least some APM implementations will try to deliver 126 */
107 * IRQs right away, so delay them until we're ready. 127 writel(0, &ehci->regs->intr_enable);
108 */ 128
109 intr_enable = 1; 129 /* re-init operational registers */
110 writel (0, &ehci->regs->segment); 130 writel(0, &ehci->regs->segment);
111 writel (ehci->periodic_dma, &ehci->regs->frame_list); 131 writel(ehci->periodic_dma, &ehci->regs->frame_list);
112 writel ((u32)ehci->async->qh_dma, &ehci->regs->async_next); 132 writel((u32) ehci->async->qh_dma, &ehci->regs->async_next);
113 } else
114 intr_enable = 0;
115 ehci_dbg(ehci, "resume root hub%s\n",
116 intr_enable ? " after power loss" : "");
117 133
118 /* restore CMD_RUN, framelist size, and irq threshold */ 134 /* restore CMD_RUN, framelist size, and irq threshold */
119 writel (ehci->command, &ehci->regs->command); 135 writel (ehci->command, &ehci->regs->command);
120 136
121 /* take ports out of suspend */ 137 /* manually resume the ports we suspended during bus_suspend() */
122 i = HCS_N_PORTS (ehci->hcs_params); 138 i = HCS_N_PORTS (ehci->hcs_params);
123 while (i--) { 139 while (i--) {
124 temp = readl (&ehci->regs->port_status [i]); 140 temp = readl (&ehci->regs->port_status [i]);
125 temp &= ~(PORT_RWC_BITS 141 temp &= ~(PORT_RWC_BITS
126 | PORT_WKOC_E | PORT_WKDISC_E | PORT_WKCONN_E); 142 | PORT_WKOC_E | PORT_WKDISC_E | PORT_WKCONN_E);
127 if (temp & PORT_SUSPEND) { 143 if (test_bit(i, &ehci->bus_suspended) &&
144 (temp & PORT_SUSPEND)) {
128 ehci->reset_done [i] = jiffies + msecs_to_jiffies (20); 145 ehci->reset_done [i] = jiffies + msecs_to_jiffies (20);
129 temp |= PORT_RESUME; 146 temp |= PORT_RESUME;
130 } 147 }
@@ -134,11 +151,12 @@ static int ehci_bus_resume (struct usb_hcd *hcd)
134 mdelay (20); 151 mdelay (20);
135 while (i--) { 152 while (i--) {
136 temp = readl (&ehci->regs->port_status [i]); 153 temp = readl (&ehci->regs->port_status [i]);
137 if ((temp & PORT_SUSPEND) == 0) 154 if (test_bit(i, &ehci->bus_suspended) &&
138 continue; 155 (temp & PORT_SUSPEND)) {
139 temp &= ~(PORT_RWC_BITS | PORT_RESUME); 156 temp &= ~(PORT_RWC_BITS | PORT_RESUME);
140 writel (temp, &ehci->regs->port_status [i]); 157 writel (temp, &ehci->regs->port_status [i]);
141 ehci_vdbg (ehci, "resumed port %d\n", i + 1); 158 ehci_vdbg (ehci, "resumed port %d\n", i + 1);
159 }
142 } 160 }
143 (void) readl (&ehci->regs->command); 161 (void) readl (&ehci->regs->command);
144 162
@@ -157,8 +175,7 @@ static int ehci_bus_resume (struct usb_hcd *hcd)
157 hcd->state = HC_STATE_RUNNING; 175 hcd->state = HC_STATE_RUNNING;
158 176
159 /* Now we can safely re-enable irqs */ 177 /* Now we can safely re-enable irqs */
160 if (intr_enable) 178 writel(INTR_MASK, &ehci->regs->intr_enable);
161 writel (INTR_MASK, &ehci->regs->intr_enable);
162 179
163 spin_unlock_irq (&ehci->lock); 180 spin_unlock_irq (&ehci->lock);
164 return 0; 181 return 0;
@@ -218,6 +235,7 @@ ehci_hub_status_data (struct usb_hcd *hcd, char *buf)
218{ 235{
219 struct ehci_hcd *ehci = hcd_to_ehci (hcd); 236 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
220 u32 temp, status = 0; 237 u32 temp, status = 0;
238 u32 mask;
221 int ports, i, retval = 1; 239 int ports, i, retval = 1;
222 unsigned long flags; 240 unsigned long flags;
223 241
@@ -233,6 +251,18 @@ ehci_hub_status_data (struct usb_hcd *hcd, char *buf)
233 retval++; 251 retval++;
234 } 252 }
235 253
254 /* Some boards (mostly VIA?) report bogus overcurrent indications,
255 * causing massive log spam unless we completely ignore them. It
256 * may be relevant that VIA VT8235 controlers, where PORT_POWER is
257 * always set, seem to clear PORT_OCC and PORT_CSC when writing to
258 * PORT_POWER; that's surprising, but maybe within-spec.
259 */
260 if (!ignore_oc)
261 mask = PORT_CSC | PORT_PEC | PORT_OCC;
262 else
263 mask = PORT_CSC | PORT_PEC;
264 // PORT_RESUME from hardware ~= PORT_STAT_C_SUSPEND
265
236 /* no hub change reports (bit 0) for now (power, ...) */ 266 /* no hub change reports (bit 0) for now (power, ...) */
237 267
238 /* port N changes (bit N)? */ 268 /* port N changes (bit N)? */
@@ -250,8 +280,7 @@ ehci_hub_status_data (struct usb_hcd *hcd, char *buf)
250 } 280 }
251 if (!(temp & PORT_CONNECT)) 281 if (!(temp & PORT_CONNECT))
252 ehci->reset_done [i] = 0; 282 ehci->reset_done [i] = 0;
253 if ((temp & (PORT_CSC | PORT_PEC | PORT_OCC)) != 0 283 if ((temp & mask) != 0
254 // PORT_STAT_C_SUSPEND?
255 || ((temp & PORT_RESUME) != 0 284 || ((temp & PORT_RESUME) != 0
256 && time_after (jiffies, 285 && time_after (jiffies,
257 ehci->reset_done [i]))) { 286 ehci->reset_done [i]))) {
@@ -319,6 +348,7 @@ static int ehci_hub_control (
319 u32 temp, status; 348 u32 temp, status;
320 unsigned long flags; 349 unsigned long flags;
321 int retval = 0; 350 int retval = 0;
351 unsigned selector;
322 352
323 /* 353 /*
324 * FIXME: support SetPortFeatures USB_PORT_FEAT_INDICATOR. 354 * FIXME: support SetPortFeatures USB_PORT_FEAT_INDICATOR.
@@ -417,7 +447,7 @@ static int ehci_hub_control (
417 status |= 1 << USB_PORT_FEAT_C_CONNECTION; 447 status |= 1 << USB_PORT_FEAT_C_CONNECTION;
418 if (temp & PORT_PEC) 448 if (temp & PORT_PEC)
419 status |= 1 << USB_PORT_FEAT_C_ENABLE; 449 status |= 1 << USB_PORT_FEAT_C_ENABLE;
420 if (temp & PORT_OCC) 450 if ((temp & PORT_OCC) && !ignore_oc)
421 status |= 1 << USB_PORT_FEAT_C_OVER_CURRENT; 451 status |= 1 << USB_PORT_FEAT_C_OVER_CURRENT;
422 452
423 /* whoever resumes must GetPortStatus to complete it!! */ 453 /* whoever resumes must GetPortStatus to complete it!! */
@@ -506,6 +536,8 @@ static int ehci_hub_control (
506 } 536 }
507 break; 537 break;
508 case SetPortFeature: 538 case SetPortFeature:
539 selector = wIndex >> 8;
540 wIndex &= 0xff;
509 if (!wIndex || wIndex > ports) 541 if (!wIndex || wIndex > ports)
510 goto error; 542 goto error;
511 wIndex--; 543 wIndex--;
@@ -559,6 +591,22 @@ static int ehci_hub_control (
559 } 591 }
560 writel (temp, &ehci->regs->port_status [wIndex]); 592 writel (temp, &ehci->regs->port_status [wIndex]);
561 break; 593 break;
594
595 /* For downstream facing ports (these): one hub port is put
596 * into test mode according to USB2 11.24.2.13, then the hub
597 * must be reset (which for root hub now means rmmod+modprobe,
598 * or else system reboot). See EHCI 2.3.9 and 4.14 for info
599 * about the EHCI-specific stuff.
600 */
601 case USB_PORT_FEAT_TEST:
602 if (!selector || selector > 5)
603 goto error;
604 ehci_quiesce(ehci);
605 ehci_halt(ehci);
606 temp |= selector << 16;
607 writel (temp, &ehci->regs->port_status [wIndex]);
608 break;
609
562 default: 610 default:
563 goto error; 611 goto error;
564 } 612 }
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index e51c1ed81ac4..4bc7970ba3ef 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -257,9 +257,7 @@ static int ehci_pci_suspend(struct usb_hcd *hcd, pm_message_t message)
257static int ehci_pci_resume(struct usb_hcd *hcd) 257static int ehci_pci_resume(struct usb_hcd *hcd)
258{ 258{
259 struct ehci_hcd *ehci = hcd_to_ehci(hcd); 259 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
260 unsigned port;
261 struct pci_dev *pdev = to_pci_dev(hcd->self.controller); 260 struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
262 int retval = -EINVAL;
263 261
264 // maybe restore FLADJ 262 // maybe restore FLADJ
265 263
@@ -269,27 +267,19 @@ static int ehci_pci_resume(struct usb_hcd *hcd)
269 /* Mark hardware accessible again as we are out of D3 state by now */ 267 /* Mark hardware accessible again as we are out of D3 state by now */
270 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); 268 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
271 269
272 /* If CF is clear, we lost PCI Vaux power and need to restart. */ 270 /* If CF is still set, we maintained PCI Vaux power.
273 if (readl(&ehci->regs->configured_flag) != FLAG_CF) 271 * Just undo the effect of ehci_pci_suspend().
274 goto restart;
275
276 /* If any port is suspended (or owned by the companion),
277 * we know we can/must resume the HC (and mustn't reset it).
278 * We just defer that to the root hub code.
279 */ 272 */
280 for (port = HCS_N_PORTS(ehci->hcs_params); port > 0; ) { 273 if (readl(&ehci->regs->configured_flag) == FLAG_CF) {
281 u32 status; 274 int mask = INTR_MASK;
282 port--; 275
283 status = readl(&ehci->regs->port_status [port]); 276 if (!device_may_wakeup(&hcd->self.root_hub->dev))
284 if (!(status & PORT_POWER)) 277 mask &= ~STS_PCD;
285 continue; 278 writel(mask, &ehci->regs->intr_enable);
286 if (status & (PORT_SUSPEND | PORT_RESUME | PORT_OWNER)) { 279 readl(&ehci->regs->intr_enable);
287 usb_hcd_resume_root_hub(hcd); 280 return 0;
288 return 0;
289 }
290 } 281 }
291 282
292restart:
293 ehci_dbg(ehci, "lost power, restarting\n"); 283 ehci_dbg(ehci, "lost power, restarting\n");
294 usb_root_hub_lost_power(hcd->self.root_hub); 284 usb_root_hub_lost_power(hcd->self.root_hub);
295 285
@@ -307,13 +297,15 @@ restart:
307 ehci_work(ehci); 297 ehci_work(ehci);
308 spin_unlock_irq(&ehci->lock); 298 spin_unlock_irq(&ehci->lock);
309 299
310 /* restart; khubd will disconnect devices */
311 retval = ehci_run(hcd);
312
313 /* here we "know" root ports should always stay powered */ 300 /* here we "know" root ports should always stay powered */
314 ehci_port_power(ehci, 1); 301 ehci_port_power(ehci, 1);
315 302
316 return retval; 303 writel(ehci->command, &ehci->regs->command);
304 writel(FLAG_CF, &ehci->regs->configured_flag);
305 readl(&ehci->regs->command); /* unblock posted writes */
306
307 hcd->state = HC_STATE_SUSPENDED;
308 return 0;
317} 309}
318#endif 310#endif
319 311
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index bbc3082a73d7..74dbc6c8228f 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -74,6 +74,7 @@ struct ehci_hcd { /* one per controller */
74 74
75 /* per root hub port */ 75 /* per root hub port */
76 unsigned long reset_done [EHCI_MAX_ROOT_PORTS]; 76 unsigned long reset_done [EHCI_MAX_ROOT_PORTS];
77 unsigned long bus_suspended;
77 78
78 /* per-HC memory pools (could be per-bus, but ...) */ 79 /* per-HC memory pools (could be per-bus, but ...) */
79 struct dma_pool *qh_pool; /* qh per active urb */ 80 struct dma_pool *qh_pool; /* qh per active urb */
diff --git a/drivers/usb/host/hc_crisv10.c b/drivers/usb/host/hc_crisv10.c
index 87eca6aeacf2..9325e46a68c0 100644
--- a/drivers/usb/host/hc_crisv10.c
+++ b/drivers/usb/host/hc_crisv10.c
@@ -188,7 +188,7 @@ static DEFINE_TIMER(bulk_eot_timer, NULL, 0, 0);
188#define CHECK_ALIGN(x) if (((__u32)(x)) & 0x00000003) \ 188#define CHECK_ALIGN(x) if (((__u32)(x)) & 0x00000003) \
189{panic("Alignment check (DWORD) failed at %s:%s:%d\n", __FILE__, __FUNCTION__, __LINE__);} 189{panic("Alignment check (DWORD) failed at %s:%s:%d\n", __FILE__, __FUNCTION__, __LINE__);}
190 190
191#define SLAB_FLAG (in_interrupt() ? SLAB_ATOMIC : SLAB_KERNEL) 191#define SLAB_FLAG (in_interrupt() ? GFP_ATOMIC : GFP_KERNEL)
192#define KMALLOC_FLAG (in_interrupt() ? GFP_ATOMIC : GFP_KERNEL) 192#define KMALLOC_FLAG (in_interrupt() ? GFP_ATOMIC : GFP_KERNEL)
193 193
194/* Most helpful debugging aid */ 194/* Most helpful debugging aid */
@@ -275,13 +275,13 @@ static volatile USB_SB_Desc_t TxIntrSB_zout __attribute__ ((aligned (4)));
275static int zout_buffer[4] __attribute__ ((aligned (4))); 275static int zout_buffer[4] __attribute__ ((aligned (4)));
276 276
277/* Cache for allocating new EP and SB descriptors. */ 277/* Cache for allocating new EP and SB descriptors. */
278static kmem_cache_t *usb_desc_cache; 278static struct kmem_cache *usb_desc_cache;
279 279
280/* Cache for the registers allocated in the top half. */ 280/* Cache for the registers allocated in the top half. */
281static kmem_cache_t *top_half_reg_cache; 281static struct kmem_cache *top_half_reg_cache;
282 282
283/* Cache for the data allocated in the isoc descr top half. */ 283/* Cache for the data allocated in the isoc descr top half. */
284static kmem_cache_t *isoc_compl_cache; 284static struct kmem_cache *isoc_compl_cache;
285 285
286static struct usb_bus *etrax_usb_bus; 286static struct usb_bus *etrax_usb_bus;
287 287
@@ -1743,7 +1743,7 @@ static irqreturn_t etrax_usb_tx_interrupt(int irq, void *vhc)
1743 1743
1744 *R_DMA_CH8_SUB3_CLR_INTR = IO_STATE(R_DMA_CH8_SUB3_CLR_INTR, clr_descr, do); 1744 *R_DMA_CH8_SUB3_CLR_INTR = IO_STATE(R_DMA_CH8_SUB3_CLR_INTR, clr_descr, do);
1745 1745
1746 comp_data = (usb_isoc_complete_data_t*)kmem_cache_alloc(isoc_compl_cache, SLAB_ATOMIC); 1746 comp_data = (usb_isoc_complete_data_t*)kmem_cache_alloc(isoc_compl_cache, GFP_ATOMIC);
1747 assert(comp_data != NULL); 1747 assert(comp_data != NULL);
1748 1748
1749 INIT_WORK(&comp_data->usb_bh, etrax_usb_isoc_descr_interrupt_bottom_half, comp_data); 1749 INIT_WORK(&comp_data->usb_bh, etrax_usb_isoc_descr_interrupt_bottom_half, comp_data);
@@ -3010,7 +3010,7 @@ static void etrax_usb_add_to_isoc_sb_list(struct urb *urb, int epid)
3010 if (!urb->iso_frame_desc[i].length) 3010 if (!urb->iso_frame_desc[i].length)
3011 continue; 3011 continue;
3012 3012
3013 next_sb_desc = (USB_SB_Desc_t*)kmem_cache_alloc(usb_desc_cache, SLAB_ATOMIC); 3013 next_sb_desc = (USB_SB_Desc_t*)kmem_cache_alloc(usb_desc_cache, GFP_ATOMIC);
3014 assert(next_sb_desc != NULL); 3014 assert(next_sb_desc != NULL);
3015 3015
3016 if (urb->iso_frame_desc[i].length > 0) { 3016 if (urb->iso_frame_desc[i].length > 0) {
@@ -3063,7 +3063,7 @@ static void etrax_usb_add_to_isoc_sb_list(struct urb *urb, int epid)
3063 if (TxIsocEPList[epid].sub == 0) { 3063 if (TxIsocEPList[epid].sub == 0) {
3064 dbg_isoc("Isoc traffic not already running, allocating SB"); 3064 dbg_isoc("Isoc traffic not already running, allocating SB");
3065 3065
3066 next_sb_desc = (USB_SB_Desc_t*)kmem_cache_alloc(usb_desc_cache, SLAB_ATOMIC); 3066 next_sb_desc = (USB_SB_Desc_t*)kmem_cache_alloc(usb_desc_cache, GFP_ATOMIC);
3067 assert(next_sb_desc != NULL); 3067 assert(next_sb_desc != NULL);
3068 3068
3069 next_sb_desc->command = (IO_STATE(USB_SB_command, tt, in) | 3069 next_sb_desc->command = (IO_STATE(USB_SB_command, tt, in) |
@@ -3317,7 +3317,7 @@ static irqreturn_t etrax_usb_hc_interrupt_top_half(int irq, void *vhc)
3317 3317
3318 restore_flags(flags); 3318 restore_flags(flags);
3319 3319
3320 reg = (usb_interrupt_registers_t *)kmem_cache_alloc(top_half_reg_cache, SLAB_ATOMIC); 3320 reg = (usb_interrupt_registers_t *)kmem_cache_alloc(top_half_reg_cache, GFP_ATOMIC);
3321 3321
3322 assert(reg != NULL); 3322 assert(reg != NULL);
3323 3323
diff --git a/drivers/usb/host/ohci-dbg.c b/drivers/usb/host/ohci-dbg.c
index 8293c1d4be3f..0f47a57dac28 100644
--- a/drivers/usb/host/ohci-dbg.c
+++ b/drivers/usb/host/ohci-dbg.c
@@ -505,7 +505,7 @@ show_periodic (struct class_device *class_dev, char *buf)
505 char *next; 505 char *next;
506 unsigned i; 506 unsigned i;
507 507
508 if (!(seen = kmalloc (DBG_SCHED_LIMIT * sizeof *seen, SLAB_ATOMIC))) 508 if (!(seen = kmalloc (DBG_SCHED_LIMIT * sizeof *seen, GFP_ATOMIC)))
509 return 0; 509 return 0;
510 seen_count = 0; 510 seen_count = 0;
511 511
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 9be6b303e784..b28a9b602066 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -715,13 +715,6 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd)
715 return IRQ_NOTMINE; 715 return IRQ_NOTMINE;
716 } 716 }
717 717
718 if (ints & OHCI_INTR_RHSC) {
719 ohci_vdbg (ohci, "rhsc\n");
720 ohci->next_statechange = jiffies + STATECHANGE_DELAY;
721 ohci_writel (ohci, OHCI_INTR_RHSC, &regs->intrstatus);
722 usb_hcd_poll_rh_status(hcd);
723 }
724
725 if (ints & OHCI_INTR_UE) { 718 if (ints & OHCI_INTR_UE) {
726 disable (ohci); 719 disable (ohci);
727 ohci_err (ohci, "OHCI Unrecoverable Error, disabled\n"); 720 ohci_err (ohci, "OHCI Unrecoverable Error, disabled\n");
@@ -731,9 +724,31 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd)
731 ohci_usb_reset (ohci); 724 ohci_usb_reset (ohci);
732 } 725 }
733 726
734 if (ints & OHCI_INTR_RD) { 727 if (ints & OHCI_INTR_RHSC) {
735 ohci_vdbg (ohci, "resume detect\n"); 728 ohci_vdbg(ohci, "rhsc\n");
736 ohci_writel (ohci, OHCI_INTR_RD, &regs->intrstatus); 729 ohci->next_statechange = jiffies + STATECHANGE_DELAY;
730 ohci_writel(ohci, OHCI_INTR_RD | OHCI_INTR_RHSC,
731 &regs->intrstatus);
732
733 /* NOTE: Vendors didn't always make the same implementation
734 * choices for RHSC. Many followed the spec; RHSC triggers
735 * on an edge, like setting and maybe clearing a port status
736 * change bit. With others it's level-triggered, active
737 * until khubd clears all the port status change bits. We'll
738 * always disable it here and rely on polling until khubd
739 * re-enables it.
740 */
741 ohci_writel(ohci, OHCI_INTR_RHSC, &regs->intrdisable);
742 usb_hcd_poll_rh_status(hcd);
743 }
744
745 /* For connect and disconnect events, we expect the controller
746 * to turn on RHSC along with RD. But for remote wakeup events
747 * this might not happen.
748 */
749 else if (ints & OHCI_INTR_RD) {
750 ohci_vdbg(ohci, "resume detect\n");
751 ohci_writel(ohci, OHCI_INTR_RD, &regs->intrstatus);
737 hcd->poll_rh = 1; 752 hcd->poll_rh = 1;
738 if (ohci->autostop) { 753 if (ohci->autostop) {
739 spin_lock (&ohci->lock); 754 spin_lock (&ohci->lock);
@@ -930,7 +945,7 @@ MODULE_LICENSE ("GPL");
930#include "ohci-ppc-soc.c" 945#include "ohci-ppc-soc.c"
931#endif 946#endif
932 947
933#if defined(CONFIG_ARCH_AT91RM9200) || defined(CONFIG_ARCH_AT91SAM9261) 948#ifdef CONFIG_ARCH_AT91
934#include "ohci-at91.c" 949#include "ohci-at91.c"
935#endif 950#endif
936 951
@@ -947,8 +962,7 @@ MODULE_LICENSE ("GPL");
947 || defined (CONFIG_ARCH_EP93XX) \ 962 || defined (CONFIG_ARCH_EP93XX) \
948 || defined (CONFIG_SOC_AU1X00) \ 963 || defined (CONFIG_SOC_AU1X00) \
949 || defined (CONFIG_USB_OHCI_HCD_PPC_SOC) \ 964 || defined (CONFIG_USB_OHCI_HCD_PPC_SOC) \
950 || defined (CONFIG_ARCH_AT91RM9200) \ 965 || defined (CONFIG_ARCH_AT91) \
951 || defined (CONFIG_ARCH_AT91SAM9261) \
952 || defined (CONFIG_ARCH_PNX4008) \ 966 || defined (CONFIG_ARCH_PNX4008) \
953 ) 967 )
954#error "missing bus glue for ohci-hcd" 968#error "missing bus glue for ohci-hcd"
diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c
index 6f113596af66..2441642cb7b4 100644
--- a/drivers/usb/host/ohci-hub.c
+++ b/drivers/usb/host/ohci-hub.c
@@ -41,7 +41,11 @@ static void ohci_rhsc_enable (struct usb_hcd *hcd)
41{ 41{
42 struct ohci_hcd *ohci = hcd_to_ohci (hcd); 42 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
43 43
44 ohci_writel (ohci, OHCI_INTR_RHSC, &ohci->regs->intrenable); 44 spin_lock_irq(&ohci->lock);
45 if (!ohci->autostop)
46 del_timer(&hcd->rh_timer); /* Prevent next poll */
47 ohci_writel(ohci, OHCI_INTR_RHSC, &ohci->regs->intrenable);
48 spin_unlock_irq(&ohci->lock);
45} 49}
46 50
47#define OHCI_SCHED_ENABLES \ 51#define OHCI_SCHED_ENABLES \
@@ -50,6 +54,9 @@ static void ohci_rhsc_enable (struct usb_hcd *hcd)
50static void dl_done_list (struct ohci_hcd *); 54static void dl_done_list (struct ohci_hcd *);
51static void finish_unlinks (struct ohci_hcd *, u16); 55static void finish_unlinks (struct ohci_hcd *, u16);
52 56
57#ifdef CONFIG_PM
58static int ohci_restart(struct ohci_hcd *ohci);
59
53static int ohci_rh_suspend (struct ohci_hcd *ohci, int autostop) 60static int ohci_rh_suspend (struct ohci_hcd *ohci, int autostop)
54__releases(ohci->lock) 61__releases(ohci->lock)
55__acquires(ohci->lock) 62__acquires(ohci->lock)
@@ -132,8 +139,6 @@ static inline struct ed *find_head (struct ed *ed)
132 return ed; 139 return ed;
133} 140}
134 141
135static int ohci_restart (struct ohci_hcd *ohci);
136
137/* caller has locked the root hub */ 142/* caller has locked the root hub */
138static int ohci_rh_resume (struct ohci_hcd *ohci) 143static int ohci_rh_resume (struct ohci_hcd *ohci)
139__releases(ohci->lock) 144__releases(ohci->lock)
@@ -169,7 +174,8 @@ __acquires(ohci->lock)
169 break; 174 break;
170 case OHCI_USB_RESUME: 175 case OHCI_USB_RESUME:
171 /* HCFS changes sometime after INTR_RD */ 176 /* HCFS changes sometime after INTR_RD */
172 ohci_info (ohci, "wakeup\n"); 177 ohci_dbg(ohci, "%swakeup root hub\n",
178 autostopped ? "auto-" : "");
173 break; 179 break;
174 case OHCI_USB_OPER: 180 case OHCI_USB_OPER:
175 /* this can happen after resuming a swsusp snapshot */ 181 /* this can happen after resuming a swsusp snapshot */
@@ -180,7 +186,6 @@ __acquires(ohci->lock)
180 ohci_dbg (ohci, "lost power\n"); 186 ohci_dbg (ohci, "lost power\n");
181 status = -EBUSY; 187 status = -EBUSY;
182 } 188 }
183#ifdef CONFIG_PM
184 if (status == -EBUSY) { 189 if (status == -EBUSY) {
185 if (!autostopped) { 190 if (!autostopped) {
186 spin_unlock_irq (&ohci->lock); 191 spin_unlock_irq (&ohci->lock);
@@ -190,25 +195,12 @@ __acquires(ohci->lock)
190 } 195 }
191 return status; 196 return status;
192 } 197 }
193#endif
194 if (status != -EINPROGRESS) 198 if (status != -EINPROGRESS)
195 return status; 199 return status;
196 if (autostopped) 200 if (autostopped)
197 goto skip_resume; 201 goto skip_resume;
198 spin_unlock_irq (&ohci->lock); 202 spin_unlock_irq (&ohci->lock);
199 203
200 temp = ohci->num_ports;
201 while (temp--) {
202 u32 stat = ohci_readl (ohci,
203 &ohci->regs->roothub.portstatus [temp]);
204
205 /* force global, not selective, resume */
206 if (!(stat & RH_PS_PSS))
207 continue;
208 ohci_writel (ohci, RH_PS_POCI,
209 &ohci->regs->roothub.portstatus [temp]);
210 }
211
212 /* Some controllers (lucent erratum) need extra-long delays */ 204 /* Some controllers (lucent erratum) need extra-long delays */
213 msleep (20 /* usb 11.5.1.10 */ + 12 /* 32 msec counter */ + 1); 205 msleep (20 /* usb 11.5.1.10 */ + 12 /* 32 msec counter */ + 1);
214 206
@@ -216,6 +208,7 @@ __acquires(ohci->lock)
216 temp &= OHCI_CTRL_HCFS; 208 temp &= OHCI_CTRL_HCFS;
217 if (temp != OHCI_USB_RESUME) { 209 if (temp != OHCI_USB_RESUME) {
218 ohci_err (ohci, "controller won't resume\n"); 210 ohci_err (ohci, "controller won't resume\n");
211 spin_lock_irq(&ohci->lock);
219 return -EBUSY; 212 return -EBUSY;
220 } 213 }
221 214
@@ -295,8 +288,6 @@ skip_resume:
295 return 0; 288 return 0;
296} 289}
297 290
298#ifdef CONFIG_PM
299
300static int ohci_bus_suspend (struct usb_hcd *hcd) 291static int ohci_bus_suspend (struct usb_hcd *hcd)
301{ 292{
302 struct ohci_hcd *ohci = hcd_to_ohci (hcd); 293 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
@@ -334,6 +325,83 @@ static int ohci_bus_resume (struct usb_hcd *hcd)
334 return rc; 325 return rc;
335} 326}
336 327
328/* Carry out polling-, autostop-, and autoresume-related state changes */
329static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed,
330 int any_connected)
331{
332 int poll_rh = 1;
333
334 switch (ohci->hc_control & OHCI_CTRL_HCFS) {
335
336 case OHCI_USB_OPER:
337 /* keep on polling until we know a device is connected
338 * and RHSC is enabled */
339 if (!ohci->autostop) {
340 if (any_connected ||
341 !device_may_wakeup(&ohci_to_hcd(ohci)
342 ->self.root_hub->dev)) {
343 if (ohci_readl(ohci, &ohci->regs->intrenable) &
344 OHCI_INTR_RHSC)
345 poll_rh = 0;
346 } else {
347 ohci->autostop = 1;
348 ohci->next_statechange = jiffies + HZ;
349 }
350
351 /* if no devices have been attached for one second, autostop */
352 } else {
353 if (changed || any_connected) {
354 ohci->autostop = 0;
355 ohci->next_statechange = jiffies +
356 STATECHANGE_DELAY;
357 } else if (time_after_eq(jiffies,
358 ohci->next_statechange)
359 && !ohci->ed_rm_list
360 && !(ohci->hc_control &
361 OHCI_SCHED_ENABLES)) {
362 ohci_rh_suspend(ohci, 1);
363 }
364 }
365 break;
366
367 /* if there is a port change, autostart or ask to be resumed */
368 case OHCI_USB_SUSPEND:
369 case OHCI_USB_RESUME:
370 if (changed) {
371 if (ohci->autostop)
372 ohci_rh_resume(ohci);
373 else
374 usb_hcd_resume_root_hub(ohci_to_hcd(ohci));
375 } else {
376 /* everything is idle, no need for polling */
377 poll_rh = 0;
378 }
379 break;
380 }
381 return poll_rh;
382}
383
384#else /* CONFIG_PM */
385
386static inline int ohci_rh_resume(struct ohci_hcd *ohci)
387{
388 return 0;
389}
390
391/* Carry out polling-related state changes.
392 * autostop isn't used when CONFIG_PM is turned off.
393 */
394static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed,
395 int any_connected)
396{
397 int poll_rh = 1;
398
399 /* keep on polling until RHSC is enabled */
400 if (ohci_readl(ohci, &ohci->regs->intrenable) & OHCI_INTR_RHSC)
401 poll_rh = 0;
402 return poll_rh;
403}
404
337#endif /* CONFIG_PM */ 405#endif /* CONFIG_PM */
338 406
339/*-------------------------------------------------------------------------*/ 407/*-------------------------------------------------------------------------*/
@@ -345,7 +413,7 @@ ohci_hub_status_data (struct usb_hcd *hcd, char *buf)
345{ 413{
346 struct ohci_hcd *ohci = hcd_to_ohci (hcd); 414 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
347 int i, changed = 0, length = 1; 415 int i, changed = 0, length = 1;
348 int any_connected = 0, rhsc_enabled = 1; 416 int any_connected = 0;
349 unsigned long flags; 417 unsigned long flags;
350 418
351 spin_lock_irqsave (&ohci->lock, flags); 419 spin_lock_irqsave (&ohci->lock, flags);
@@ -386,66 +454,8 @@ ohci_hub_status_data (struct usb_hcd *hcd, char *buf)
386 } 454 }
387 } 455 }
388 456
389 /* NOTE: vendors didn't always make the same implementation 457 hcd->poll_rh = ohci_root_hub_state_changes(ohci, changed,
390 * choices for RHSC. Sometimes it triggers on an edge (like 458 any_connected);
391 * setting and maybe clearing a port status change bit); and
392 * it's level-triggered on other silicon, active until khubd
393 * clears all active port status change bits. If it's still
394 * set (level-triggered) we must disable it and rely on
395 * polling until khubd re-enables it.
396 */
397 if (ohci_readl (ohci, &ohci->regs->intrstatus) & OHCI_INTR_RHSC) {
398 ohci_writel (ohci, OHCI_INTR_RHSC, &ohci->regs->intrdisable);
399 (void) ohci_readl (ohci, &ohci->regs->intrdisable);
400 rhsc_enabled = 0;
401 }
402 hcd->poll_rh = 1;
403
404 /* carry out appropriate state changes */
405 switch (ohci->hc_control & OHCI_CTRL_HCFS) {
406
407 case OHCI_USB_OPER:
408 /* keep on polling until we know a device is connected
409 * and RHSC is enabled */
410 if (!ohci->autostop) {
411 if (any_connected) {
412 if (rhsc_enabled)
413 hcd->poll_rh = 0;
414 } else {
415 ohci->autostop = 1;
416 ohci->next_statechange = jiffies + HZ;
417 }
418
419 /* if no devices have been attached for one second, autostop */
420 } else {
421 if (changed || any_connected) {
422 ohci->autostop = 0;
423 ohci->next_statechange = jiffies +
424 STATECHANGE_DELAY;
425 } else if (time_after_eq (jiffies,
426 ohci->next_statechange)
427 && !ohci->ed_rm_list
428 && !(ohci->hc_control &
429 OHCI_SCHED_ENABLES)) {
430 ohci_rh_suspend (ohci, 1);
431 }
432 }
433 break;
434
435 /* if there is a port change, autostart or ask to be resumed */
436 case OHCI_USB_SUSPEND:
437 case OHCI_USB_RESUME:
438 if (changed) {
439 if (ohci->autostop)
440 ohci_rh_resume (ohci);
441 else
442 usb_hcd_resume_root_hub (hcd);
443 } else {
444 /* everything is idle, no need for polling */
445 hcd->poll_rh = 0;
446 }
447 break;
448 }
449 459
450done: 460done:
451 spin_unlock_irqrestore (&ohci->lock, flags); 461 spin_unlock_irqrestore (&ohci->lock, flags);
diff --git a/drivers/usb/host/ohci-pnx4008.c b/drivers/usb/host/ohci-pnx4008.c
index 2dbb77414905..7f26f9bdbaf1 100644
--- a/drivers/usb/host/ohci-pnx4008.c
+++ b/drivers/usb/host/ohci-pnx4008.c
@@ -134,7 +134,7 @@ static int isp1301_attach(struct i2c_adapter *adap, int addr, int kind)
134{ 134{
135 struct i2c_client *c; 135 struct i2c_client *c;
136 136
137 c = (struct i2c_client *)kzalloc(sizeof(*c), SLAB_KERNEL); 137 c = (struct i2c_client *)kzalloc(sizeof(*c), GFP_KERNEL);
138 138
139 if (!c) 139 if (!c)
140 return -ENOMEM; 140 return -ENOMEM;
diff --git a/drivers/usb/host/sl811_cs.c b/drivers/usb/host/sl811_cs.c
index 54f554e0f0ad..ac9f11d19817 100644
--- a/drivers/usb/host/sl811_cs.c
+++ b/drivers/usb/host/sl811_cs.c
@@ -169,21 +169,14 @@ static int sl811_cs_config(struct pcmcia_device *link)
169 169
170 DBG(0, "sl811_cs_config(0x%p)\n", link); 170 DBG(0, "sl811_cs_config(0x%p)\n", link);
171 171
172 tuple.DesiredTuple = CISTPL_CONFIG;
173 tuple.Attributes = 0;
174 tuple.TupleData = buf;
175 tuple.TupleDataMax = sizeof(buf);
176 tuple.TupleOffset = 0;
177 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
178 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
179 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
180 link->conf.ConfigBase = parse.config.base;
181 link->conf.Present = parse.config.rmask[0];
182
183 /* Look up the current Vcc */ 172 /* Look up the current Vcc */
184 CS_CHECK(GetConfigurationInfo, 173 CS_CHECK(GetConfigurationInfo,
185 pcmcia_get_configuration_info(link, &conf)); 174 pcmcia_get_configuration_info(link, &conf));
186 175
176 tuple.Attributes = 0;
177 tuple.TupleData = buf;
178 tuple.TupleDataMax = sizeof(buf);
179 tuple.TupleOffset = 0;
187 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 180 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
188 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 181 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
189 while (1) { 182 while (1) {
diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c
index 32c635ecbf31..a9d7119e3176 100644
--- a/drivers/usb/host/u132-hcd.c
+++ b/drivers/usb/host/u132-hcd.c
@@ -71,7 +71,7 @@ static int distrust_firmware = 1;
71module_param(distrust_firmware, bool, 0); 71module_param(distrust_firmware, bool, 0);
72MODULE_PARM_DESC(distrust_firmware, "true to distrust firmware power/overcurren" 72MODULE_PARM_DESC(distrust_firmware, "true to distrust firmware power/overcurren"
73 "t setup"); 73 "t setup");
74DECLARE_WAIT_QUEUE_HEAD(u132_hcd_wait); 74static DECLARE_WAIT_QUEUE_HEAD(u132_hcd_wait);
75/* 75/*
76* u132_module_lock exists to protect access to global variables 76* u132_module_lock exists to protect access to global variables
77* 77*
@@ -163,7 +163,7 @@ struct u132_endp {
163 u16 queue_next; 163 u16 queue_next;
164 struct urb *urb_list[ENDP_QUEUE_SIZE]; 164 struct urb *urb_list[ENDP_QUEUE_SIZE];
165 struct list_head urb_more; 165 struct list_head urb_more;
166 struct work_struct scheduler; 166 struct delayed_work scheduler;
167}; 167};
168struct u132_ring { 168struct u132_ring {
169 unsigned in_use:1; 169 unsigned in_use:1;
@@ -171,7 +171,7 @@ struct u132_ring {
171 u8 number; 171 u8 number;
172 struct u132 *u132; 172 struct u132 *u132;
173 struct u132_endp *curr_endp; 173 struct u132_endp *curr_endp;
174 struct work_struct scheduler; 174 struct delayed_work scheduler;
175}; 175};
176#define OHCI_QUIRK_AMD756 0x01 176#define OHCI_QUIRK_AMD756 0x01
177#define OHCI_QUIRK_SUPERIO 0x02 177#define OHCI_QUIRK_SUPERIO 0x02
@@ -198,20 +198,16 @@ struct u132 {
198 u32 hc_roothub_portstatus[MAX_ROOT_PORTS]; 198 u32 hc_roothub_portstatus[MAX_ROOT_PORTS];
199 int flags; 199 int flags;
200 unsigned long next_statechange; 200 unsigned long next_statechange;
201 struct work_struct monitor; 201 struct delayed_work monitor;
202 int num_endpoints; 202 int num_endpoints;
203 struct u132_addr addr[MAX_U132_ADDRS]; 203 struct u132_addr addr[MAX_U132_ADDRS];
204 struct u132_udev udev[MAX_U132_UDEVS]; 204 struct u132_udev udev[MAX_U132_UDEVS];
205 struct u132_port port[MAX_U132_PORTS]; 205 struct u132_port port[MAX_U132_PORTS];
206 struct u132_endp *endp[MAX_U132_ENDPS]; 206 struct u132_endp *endp[MAX_U132_ENDPS];
207}; 207};
208int usb_ftdi_elan_read_reg(struct platform_device *pdev, u32 *data); 208
209int usb_ftdi_elan_read_pcimem(struct platform_device *pdev, u8 addressofs,
210 u8 width, u32 *data);
211int usb_ftdi_elan_write_pcimem(struct platform_device *pdev, u8 addressofs,
212 u8 width, u32 data);
213/* 209/*
214* these can not be inlines because we need the structure offset!! 210* these cannot be inlines because we need the structure offset!!
215* Does anyone have a better way????? 211* Does anyone have a better way?????
216*/ 212*/
217#define u132_read_pcimem(u132, member, data) \ 213#define u132_read_pcimem(u132, member, data) \
@@ -314,7 +310,7 @@ static void u132_ring_requeue_work(struct u132 *u132, struct u132_ring *ring,
314 if (delta > 0) { 310 if (delta > 0) {
315 if (queue_delayed_work(workqueue, &ring->scheduler, delta)) 311 if (queue_delayed_work(workqueue, &ring->scheduler, delta))
316 return; 312 return;
317 } else if (queue_work(workqueue, &ring->scheduler)) 313 } else if (queue_delayed_work(workqueue, &ring->scheduler, 0))
318 return; 314 return;
319 kref_put(&u132->kref, u132_hcd_delete); 315 kref_put(&u132->kref, u132_hcd_delete);
320 return; 316 return;
@@ -393,12 +389,8 @@ static inline void u132_endp_init_kref(struct u132 *u132,
393static void u132_endp_queue_work(struct u132 *u132, struct u132_endp *endp, 389static void u132_endp_queue_work(struct u132 *u132, struct u132_endp *endp,
394 unsigned int delta) 390 unsigned int delta)
395{ 391{
396 if (delta > 0) { 392 if (queue_delayed_work(workqueue, &endp->scheduler, delta))
397 if (queue_delayed_work(workqueue, &endp->scheduler, delta)) 393 kref_get(&endp->kref);
398 kref_get(&endp->kref);
399 } else if (queue_work(workqueue, &endp->scheduler))
400 kref_get(&endp->kref);
401 return;
402} 394}
403 395
404static void u132_endp_cancel_work(struct u132 *u132, struct u132_endp *endp) 396static void u132_endp_cancel_work(struct u132 *u132, struct u132_endp *endp)
@@ -414,24 +406,14 @@ static inline void u132_monitor_put_kref(struct u132 *u132)
414 406
415static void u132_monitor_queue_work(struct u132 *u132, unsigned int delta) 407static void u132_monitor_queue_work(struct u132 *u132, unsigned int delta)
416{ 408{
417 if (delta > 0) { 409 if (queue_delayed_work(workqueue, &u132->monitor, delta))
418 if (queue_delayed_work(workqueue, &u132->monitor, delta)) { 410 kref_get(&u132->kref);
419 kref_get(&u132->kref);
420 }
421 } else if (queue_work(workqueue, &u132->monitor))
422 kref_get(&u132->kref);
423 return;
424} 411}
425 412
426static void u132_monitor_requeue_work(struct u132 *u132, unsigned int delta) 413static void u132_monitor_requeue_work(struct u132 *u132, unsigned int delta)
427{ 414{
428 if (delta > 0) { 415 if (!queue_delayed_work(workqueue, &u132->monitor, delta))
429 if (queue_delayed_work(workqueue, &u132->monitor, delta)) 416 kref_put(&u132->kref, u132_hcd_delete);
430 return;
431 } else if (queue_work(workqueue, &u132->monitor))
432 return;
433 kref_put(&u132->kref, u132_hcd_delete);
434 return;
435} 417}
436 418
437static void u132_monitor_cancel_work(struct u132 *u132) 419static void u132_monitor_cancel_work(struct u132 *u132)
@@ -493,9 +475,9 @@ static int read_roothub_info(struct u132 *u132)
493 return 0; 475 return 0;
494} 476}
495 477
496static void u132_hcd_monitor_work(void *data) 478static void u132_hcd_monitor_work(struct work_struct *work)
497{ 479{
498 struct u132 *u132 = data; 480 struct u132 *u132 = container_of(work, struct u132, monitor.work);
499 if (u132->going > 1) { 481 if (u132->going > 1) {
500 dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 482 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
501 , u132->going); 483 , u132->going);
@@ -1319,15 +1301,14 @@ static void u132_hcd_initial_setup_sent(void *data, struct urb *urb, u8 *buf,
1319 } 1301 }
1320} 1302}
1321 1303
1322static void u132_hcd_ring_work_scheduler(void *data);
1323static void u132_hcd_endp_work_scheduler(void *data);
1324/* 1304/*
1325* this work function is only executed from the work queue 1305* this work function is only executed from the work queue
1326* 1306*
1327*/ 1307*/
1328static void u132_hcd_ring_work_scheduler(void *data) 1308static void u132_hcd_ring_work_scheduler(struct work_struct *work)
1329{ 1309{
1330 struct u132_ring *ring = data; 1310 struct u132_ring *ring =
1311 container_of(work, struct u132_ring, scheduler.work);
1331 struct u132 *u132 = ring->u132; 1312 struct u132 *u132 = ring->u132;
1332 down(&u132->scheduler_lock); 1313 down(&u132->scheduler_lock);
1333 if (ring->in_use) { 1314 if (ring->in_use) {
@@ -1386,10 +1367,11 @@ static void u132_hcd_ring_work_scheduler(void *data)
1386 } 1367 }
1387} 1368}
1388 1369
1389static void u132_hcd_endp_work_scheduler(void *data) 1370static void u132_hcd_endp_work_scheduler(struct work_struct *work)
1390{ 1371{
1391 struct u132_ring *ring; 1372 struct u132_ring *ring;
1392 struct u132_endp *endp = data; 1373 struct u132_endp *endp =
1374 container_of(work, struct u132_endp, scheduler.work);
1393 struct u132 *u132 = endp->u132; 1375 struct u132 *u132 = endp->u132;
1394 down(&u132->scheduler_lock); 1376 down(&u132->scheduler_lock);
1395 ring = endp->ring; 1377 ring = endp->ring;
@@ -1947,7 +1929,7 @@ static int create_endpoint_and_queue_int(struct u132 *u132,
1947 if (!endp) { 1929 if (!endp) {
1948 return -ENOMEM; 1930 return -ENOMEM;
1949 } 1931 }
1950 INIT_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler, (void *)endp); 1932 INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler);
1951 spin_lock_init(&endp->queue_lock.slock); 1933 spin_lock_init(&endp->queue_lock.slock);
1952 INIT_LIST_HEAD(&endp->urb_more); 1934 INIT_LIST_HEAD(&endp->urb_more);
1953 ring = endp->ring = &u132->ring[0]; 1935 ring = endp->ring = &u132->ring[0];
@@ -2036,7 +2018,7 @@ static int create_endpoint_and_queue_bulk(struct u132 *u132,
2036 if (!endp) { 2018 if (!endp) {
2037 return -ENOMEM; 2019 return -ENOMEM;
2038 } 2020 }
2039 INIT_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler, (void *)endp); 2021 INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler);
2040 spin_lock_init(&endp->queue_lock.slock); 2022 spin_lock_init(&endp->queue_lock.slock);
2041 INIT_LIST_HEAD(&endp->urb_more); 2023 INIT_LIST_HEAD(&endp->urb_more);
2042 endp->dequeueing = 0; 2024 endp->dequeueing = 0;
@@ -2121,7 +2103,7 @@ static int create_endpoint_and_queue_control(struct u132 *u132,
2121 if (!endp) { 2103 if (!endp) {
2122 return -ENOMEM; 2104 return -ENOMEM;
2123 } 2105 }
2124 INIT_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler, (void *)endp); 2106 INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler);
2125 spin_lock_init(&endp->queue_lock.slock); 2107 spin_lock_init(&endp->queue_lock.slock);
2126 INIT_LIST_HEAD(&endp->urb_more); 2108 INIT_LIST_HEAD(&endp->urb_more);
2127 ring = endp->ring = &u132->ring[0]; 2109 ring = endp->ring = &u132->ring[0];
@@ -3045,7 +3027,7 @@ static struct hc_driver u132_hc_driver = {
3045* This function may be called by the USB core whilst the "usb_all_devices_rwsem" 3027* This function may be called by the USB core whilst the "usb_all_devices_rwsem"
3046* is held for writing, thus this module must not call usb_remove_hcd() 3028* is held for writing, thus this module must not call usb_remove_hcd()
3047* synchronously - but instead should immediately stop activity to the 3029* synchronously - but instead should immediately stop activity to the
3048* device and ansynchronously call usb_remove_hcd() 3030* device and asynchronously call usb_remove_hcd()
3049*/ 3031*/
3050static int __devexit u132_remove(struct platform_device *pdev) 3032static int __devexit u132_remove(struct platform_device *pdev)
3051{ 3033{
@@ -3100,10 +3082,10 @@ static void u132_initialise(struct u132 *u132, struct platform_device *pdev)
3100 ring->number = rings + 1; 3082 ring->number = rings + 1;
3101 ring->length = 0; 3083 ring->length = 0;
3102 ring->curr_endp = NULL; 3084 ring->curr_endp = NULL;
3103 INIT_WORK(&ring->scheduler, u132_hcd_ring_work_scheduler, 3085 INIT_DELAYED_WORK(&ring->scheduler,
3104 (void *)ring); 3086 u132_hcd_ring_work_scheduler);
3105 } down(&u132->sw_lock); 3087 } down(&u132->sw_lock);
3106 INIT_WORK(&u132->monitor, u132_hcd_monitor_work, (void *)u132); 3088 INIT_DELAYED_WORK(&u132->monitor, u132_hcd_monitor_work);
3107 while (ports-- > 0) { 3089 while (ports-- > 0) {
3108 struct u132_port *port = &u132->port[ports]; 3090 struct u132_port *port = &u132->port[ports];
3109 port->u132 = u132; 3091 port->u132 = u132;
@@ -3241,7 +3223,7 @@ static int u132_resume(struct platform_device *pdev)
3241#define u132_resume NULL 3223#define u132_resume NULL
3242#endif 3224#endif
3243/* 3225/*
3244* this driver is loaded explicitely by ftdi_u132 3226* this driver is loaded explicitly by ftdi_u132
3245* 3227*
3246* the platform_driver struct is static because it is per type of module 3228* the platform_driver struct is static because it is per type of module
3247*/ 3229*/
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
index 226bf3de8edd..e87692c31be4 100644
--- a/drivers/usb/host/uhci-hcd.c
+++ b/drivers/usb/host/uhci-hcd.c
@@ -81,7 +81,7 @@ MODULE_PARM_DESC(debug, "Debug level");
81static char *errbuf; 81static char *errbuf;
82#define ERRBUF_LEN (32 * 1024) 82#define ERRBUF_LEN (32 * 1024)
83 83
84static kmem_cache_t *uhci_up_cachep; /* urb_priv */ 84static struct kmem_cache *uhci_up_cachep; /* urb_priv */
85 85
86static void suspend_rh(struct uhci_hcd *uhci, enum uhci_rh_state new_state); 86static void suspend_rh(struct uhci_hcd *uhci, enum uhci_rh_state new_state);
87static void wakeup_rh(struct uhci_hcd *uhci); 87static void wakeup_rh(struct uhci_hcd *uhci);
diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c
index 06115f22a4fa..30b88459ac7d 100644
--- a/drivers/usb/host/uhci-q.c
+++ b/drivers/usb/host/uhci-q.c
@@ -498,7 +498,7 @@ static inline struct urb_priv *uhci_alloc_urb_priv(struct uhci_hcd *uhci,
498{ 498{
499 struct urb_priv *urbp; 499 struct urb_priv *urbp;
500 500
501 urbp = kmem_cache_alloc(uhci_up_cachep, SLAB_ATOMIC); 501 urbp = kmem_cache_alloc(uhci_up_cachep, GFP_ATOMIC);
502 if (!urbp) 502 if (!urbp)
503 return NULL; 503 return NULL;
504 504
diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c
index 3038ed0700d3..8ccddf74534a 100644
--- a/drivers/usb/image/microtek.c
+++ b/drivers/usb/image/microtek.c
@@ -796,7 +796,7 @@ static int mts_usb_probe(struct usb_interface *intf,
796 796
797 new_desc->context.scsi_status = kmalloc(1, GFP_KERNEL); 797 new_desc->context.scsi_status = kmalloc(1, GFP_KERNEL);
798 if (!new_desc->context.scsi_status) 798 if (!new_desc->context.scsi_status)
799 goto out_kfree2; 799 goto out_free_urb;
800 800
801 new_desc->usb_dev = dev; 801 new_desc->usb_dev = dev;
802 new_desc->usb_intf = intf; 802 new_desc->usb_intf = intf;
@@ -822,18 +822,20 @@ static int mts_usb_probe(struct usb_interface *intf,
822 new_desc->host = scsi_host_alloc(&mts_scsi_host_template, 822 new_desc->host = scsi_host_alloc(&mts_scsi_host_template,
823 sizeof(new_desc)); 823 sizeof(new_desc));
824 if (!new_desc->host) 824 if (!new_desc->host)
825 goto out_free_urb; 825 goto out_kfree2;
826 826
827 new_desc->host->hostdata[0] = (unsigned long)new_desc; 827 new_desc->host->hostdata[0] = (unsigned long)new_desc;
828 if (scsi_add_host(new_desc->host, NULL)) { 828 if (scsi_add_host(new_desc->host, NULL)) {
829 err_retval = -EIO; 829 err_retval = -EIO;
830 goto out_free_urb; 830 goto out_host_put;
831 } 831 }
832 scsi_scan_host(new_desc->host); 832 scsi_scan_host(new_desc->host);
833 833
834 usb_set_intfdata(intf, new_desc); 834 usb_set_intfdata(intf, new_desc);
835 return 0; 835 return 0;
836 836
837 out_host_put:
838 scsi_host_put(new_desc->host);
837 out_kfree2: 839 out_kfree2:
838 kfree(new_desc->context.scsi_status); 840 kfree(new_desc->context.scsi_status);
839 out_free_urb: 841 out_free_urb:
diff --git a/drivers/usb/input/Kconfig b/drivers/usb/input/Kconfig
index 20db36448ab3..661af7aa6236 100644
--- a/drivers/usb/input/Kconfig
+++ b/drivers/usb/input/Kconfig
@@ -221,6 +221,7 @@ config USB_TOUCHSCREEN
221 - ITM 221 - ITM
222 - some other eTurboTouch 222 - some other eTurboTouch
223 - Gunze AHL61 223 - Gunze AHL61
224 - DMC TSC-10/25
224 225
225 Have a look at <http://linux.chapter7.ch/touchkit/> for 226 Have a look at <http://linux.chapter7.ch/touchkit/> for
226 a usage description and the required user-space stuff. 227 a usage description and the required user-space stuff.
@@ -258,6 +259,11 @@ config USB_TOUCHSCREEN_GUNZE
258 bool "Gunze AHL61 device support" if EMBEDDED 259 bool "Gunze AHL61 device support" if EMBEDDED
259 depends on USB_TOUCHSCREEN 260 depends on USB_TOUCHSCREEN
260 261
262config USB_TOUCHSCREEN_DMC_TSC10
263 default y
264 bool "DMC TSC-10/25 device support" if EMBEDDED
265 depends on USB_TOUCHSCREEN
266
261config USB_YEALINK 267config USB_YEALINK
262 tristate "Yealink usb-p1k voip phone" 268 tristate "Yealink usb-p1k voip phone"
263 depends on USB && INPUT && EXPERIMENTAL 269 depends on USB && INPUT && EXPERIMENTAL
diff --git a/drivers/usb/input/acecad.c b/drivers/usb/input/acecad.c
index 0096373b5f98..909138e5aa04 100644
--- a/drivers/usb/input/acecad.c
+++ b/drivers/usb/input/acecad.c
@@ -152,7 +152,7 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_
152 if (!acecad || !input_dev) 152 if (!acecad || !input_dev)
153 goto fail1; 153 goto fail1;
154 154
155 acecad->data = usb_buffer_alloc(dev, 8, SLAB_KERNEL, &acecad->data_dma); 155 acecad->data = usb_buffer_alloc(dev, 8, GFP_KERNEL, &acecad->data_dma);
156 if (!acecad->data) 156 if (!acecad->data)
157 goto fail1; 157 goto fail1;
158 158
diff --git a/drivers/usb/input/aiptek.c b/drivers/usb/input/aiptek.c
index bf428184608f..9f52429ce654 100644
--- a/drivers/usb/input/aiptek.c
+++ b/drivers/usb/input/aiptek.c
@@ -1988,7 +1988,7 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
1988 goto fail1; 1988 goto fail1;
1989 1989
1990 aiptek->data = usb_buffer_alloc(usbdev, AIPTEK_PACKET_LENGTH, 1990 aiptek->data = usb_buffer_alloc(usbdev, AIPTEK_PACKET_LENGTH,
1991 SLAB_ATOMIC, &aiptek->data_dma); 1991 GFP_ATOMIC, &aiptek->data_dma);
1992 if (!aiptek->data) 1992 if (!aiptek->data)
1993 goto fail1; 1993 goto fail1;
1994 1994
diff --git a/drivers/usb/input/ati_remote.c b/drivers/usb/input/ati_remote.c
index f659f3028ad2..b724e36f7b92 100644
--- a/drivers/usb/input/ati_remote.c
+++ b/drivers/usb/input/ati_remote.c
@@ -592,7 +592,7 @@ static void ati_remote_irq_in(struct urb *urb)
592 __FUNCTION__, urb->status); 592 __FUNCTION__, urb->status);
593 } 593 }
594 594
595 retval = usb_submit_urb(urb, SLAB_ATOMIC); 595 retval = usb_submit_urb(urb, GFP_ATOMIC);
596 if (retval) 596 if (retval)
597 dev_err(&ati_remote->interface->dev, "%s: usb_submit_urb()=%d\n", 597 dev_err(&ati_remote->interface->dev, "%s: usb_submit_urb()=%d\n",
598 __FUNCTION__, retval); 598 __FUNCTION__, retval);
@@ -604,12 +604,12 @@ static void ati_remote_irq_in(struct urb *urb)
604static int ati_remote_alloc_buffers(struct usb_device *udev, 604static int ati_remote_alloc_buffers(struct usb_device *udev,
605 struct ati_remote *ati_remote) 605 struct ati_remote *ati_remote)
606{ 606{
607 ati_remote->inbuf = usb_buffer_alloc(udev, DATA_BUFSIZE, SLAB_ATOMIC, 607 ati_remote->inbuf = usb_buffer_alloc(udev, DATA_BUFSIZE, GFP_ATOMIC,
608 &ati_remote->inbuf_dma); 608 &ati_remote->inbuf_dma);
609 if (!ati_remote->inbuf) 609 if (!ati_remote->inbuf)
610 return -1; 610 return -1;
611 611
612 ati_remote->outbuf = usb_buffer_alloc(udev, DATA_BUFSIZE, SLAB_ATOMIC, 612 ati_remote->outbuf = usb_buffer_alloc(udev, DATA_BUFSIZE, GFP_ATOMIC,
613 &ati_remote->outbuf_dma); 613 &ati_remote->outbuf_dma);
614 if (!ati_remote->outbuf) 614 if (!ati_remote->outbuf)
615 return -1; 615 return -1;
@@ -630,19 +630,14 @@ static int ati_remote_alloc_buffers(struct usb_device *udev,
630 */ 630 */
631static void ati_remote_free_buffers(struct ati_remote *ati_remote) 631static void ati_remote_free_buffers(struct ati_remote *ati_remote)
632{ 632{
633 if (ati_remote->irq_urb) 633 usb_free_urb(ati_remote->irq_urb);
634 usb_free_urb(ati_remote->irq_urb); 634 usb_free_urb(ati_remote->out_urb);
635 635
636 if (ati_remote->out_urb) 636 usb_buffer_free(ati_remote->udev, DATA_BUFSIZE,
637 usb_free_urb(ati_remote->out_urb); 637 ati_remote->inbuf, ati_remote->inbuf_dma);
638 638
639 if (ati_remote->inbuf) 639 usb_buffer_free(ati_remote->udev, DATA_BUFSIZE,
640 usb_buffer_free(ati_remote->udev, DATA_BUFSIZE, 640 ati_remote->outbuf, ati_remote->outbuf_dma);
641 ati_remote->inbuf, ati_remote->inbuf_dma);
642
643 if (ati_remote->outbuf)
644 usb_buffer_free(ati_remote->udev, DATA_BUFSIZE,
645 ati_remote->inbuf, ati_remote->outbuf_dma);
646} 641}
647 642
648static void ati_remote_input_init(struct ati_remote *ati_remote) 643static void ati_remote_input_init(struct ati_remote *ati_remote)
diff --git a/drivers/usb/input/ati_remote2.c b/drivers/usb/input/ati_remote2.c
index f982a2b4a7f9..83f1f79db7c7 100644
--- a/drivers/usb/input/ati_remote2.c
+++ b/drivers/usb/input/ati_remote2.c
@@ -372,8 +372,7 @@ static void ati_remote2_urb_cleanup(struct ati_remote2 *ar2)
372 int i; 372 int i;
373 373
374 for (i = 0; i < 2; i++) { 374 for (i = 0; i < 2; i++) {
375 if (ar2->urb[i]) 375 usb_free_urb(ar2->urb[i]);
376 usb_free_urb(ar2->urb[i]);
377 376
378 if (ar2->buf[i]) 377 if (ar2->buf[i])
379 usb_buffer_free(ar2->udev, 4, ar2->buf[i], ar2->buf_dma[i]); 378 usb_buffer_free(ar2->udev, 4, ar2->buf[i], ar2->buf_dma[i]);
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c
index 6095d9cedb7e..0811c39bd14f 100644
--- a/drivers/usb/input/hid-core.c
+++ b/drivers/usb/input/hid-core.c
@@ -968,20 +968,30 @@ static void hid_retry_timeout(unsigned long _hid)
968 hid_io_error(hid); 968 hid_io_error(hid);
969} 969}
970 970
971/* Workqueue routine to reset the device */ 971/* Workqueue routine to reset the device or clear a halt */
972static void hid_reset(void *_hid) 972static void hid_reset(struct work_struct *work)
973{ 973{
974 struct hid_device *hid = (struct hid_device *) _hid; 974 struct hid_device *hid =
975 int rc_lock, rc; 975 container_of(work, struct hid_device, reset_work);
976 976 int rc_lock, rc = 0;
977 dev_dbg(&hid->intf->dev, "resetting device\n"); 977
978 rc = rc_lock = usb_lock_device_for_reset(hid->dev, hid->intf); 978 if (test_bit(HID_CLEAR_HALT, &hid->iofl)) {
979 if (rc_lock >= 0) { 979 dev_dbg(&hid->intf->dev, "clear halt\n");
980 rc = usb_reset_composite_device(hid->dev, hid->intf); 980 rc = usb_clear_halt(hid->dev, hid->urbin->pipe);
981 if (rc_lock) 981 clear_bit(HID_CLEAR_HALT, &hid->iofl);
982 usb_unlock_device(hid->dev); 982 hid_start_in(hid);
983 }
984
985 else if (test_bit(HID_RESET_PENDING, &hid->iofl)) {
986 dev_dbg(&hid->intf->dev, "resetting device\n");
987 rc = rc_lock = usb_lock_device_for_reset(hid->dev, hid->intf);
988 if (rc_lock >= 0) {
989 rc = usb_reset_composite_device(hid->dev, hid->intf);
990 if (rc_lock)
991 usb_unlock_device(hid->dev);
992 }
993 clear_bit(HID_RESET_PENDING, &hid->iofl);
983 } 994 }
984 clear_bit(HID_RESET_PENDING, &hid->iofl);
985 995
986 switch (rc) { 996 switch (rc) {
987 case 0: 997 case 0:
@@ -1023,9 +1033,8 @@ static void hid_io_error(struct hid_device *hid)
1023 1033
1024 /* Retries failed, so do a port reset */ 1034 /* Retries failed, so do a port reset */
1025 if (!test_and_set_bit(HID_RESET_PENDING, &hid->iofl)) { 1035 if (!test_and_set_bit(HID_RESET_PENDING, &hid->iofl)) {
1026 if (schedule_work(&hid->reset_work)) 1036 schedule_work(&hid->reset_work);
1027 goto done; 1037 goto done;
1028 clear_bit(HID_RESET_PENDING, &hid->iofl);
1029 } 1038 }
1030 } 1039 }
1031 1040
@@ -1049,6 +1058,11 @@ static void hid_irq_in(struct urb *urb)
1049 hid->retry_delay = 0; 1058 hid->retry_delay = 0;
1050 hid_input_report(HID_INPUT_REPORT, urb, 1); 1059 hid_input_report(HID_INPUT_REPORT, urb, 1);
1051 break; 1060 break;
1061 case -EPIPE: /* stall */
1062 clear_bit(HID_IN_RUNNING, &hid->iofl);
1063 set_bit(HID_CLEAR_HALT, &hid->iofl);
1064 schedule_work(&hid->reset_work);
1065 return;
1052 case -ECONNRESET: /* unlink */ 1066 case -ECONNRESET: /* unlink */
1053 case -ENOENT: 1067 case -ENOENT:
1054 case -ESHUTDOWN: /* unplug */ 1068 case -ESHUTDOWN: /* unplug */
@@ -1065,7 +1079,7 @@ static void hid_irq_in(struct urb *urb)
1065 warn("input irq status %d received", urb->status); 1079 warn("input irq status %d received", urb->status);
1066 } 1080 }
1067 1081
1068 status = usb_submit_urb(urb, SLAB_ATOMIC); 1082 status = usb_submit_urb(urb, GFP_ATOMIC);
1069 if (status) { 1083 if (status) {
1070 clear_bit(HID_IN_RUNNING, &hid->iofl); 1084 clear_bit(HID_IN_RUNNING, &hid->iofl);
1071 if (status != -EPERM) { 1085 if (status != -EPERM) {
@@ -1627,6 +1641,19 @@ void hid_init_reports(struct hid_device *hid)
1627 1641
1628#define USB_VENDOR_ID_APPLE 0x05ac 1642#define USB_VENDOR_ID_APPLE 0x05ac
1629#define USB_DEVICE_ID_APPLE_MIGHTYMOUSE 0x0304 1643#define USB_DEVICE_ID_APPLE_MIGHTYMOUSE 0x0304
1644#define USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI 0x020e
1645#define USB_DEVICE_ID_APPLE_FOUNTAIN_ISO 0x020f
1646#define USB_DEVICE_ID_APPLE_GEYSER_ANSI 0x0214
1647#define USB_DEVICE_ID_APPLE_GEYSER_ISO 0x0215
1648#define USB_DEVICE_ID_APPLE_GEYSER_JIS 0x0216
1649#define USB_DEVICE_ID_APPLE_GEYSER3_ANSI 0x0217
1650#define USB_DEVICE_ID_APPLE_GEYSER3_ISO 0x0218
1651#define USB_DEVICE_ID_APPLE_GEYSER3_JIS 0x0219
1652#define USB_DEVICE_ID_APPLE_GEYSER4_ANSI 0x021a
1653#define USB_DEVICE_ID_APPLE_GEYSER4_ISO 0x021b
1654#define USB_DEVICE_ID_APPLE_GEYSER4_JIS 0x021c
1655#define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY 0x030a
1656#define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY 0x030b
1630 1657
1631#define USB_VENDOR_ID_CHERRY 0x046a 1658#define USB_VENDOR_ID_CHERRY 0x046a
1632#define USB_DEVICE_ID_CHERRY_CYMOTION 0x0023 1659#define USB_DEVICE_ID_CHERRY_CYMOTION 0x0023
@@ -1797,16 +1824,19 @@ static const struct hid_blacklist {
1797 1824
1798 { USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION, HID_QUIRK_CYMOTION }, 1825 { USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION, HID_QUIRK_CYMOTION },
1799 1826
1800 { USB_VENDOR_ID_APPLE, 0x020E, HID_QUIRK_POWERBOOK_HAS_FN }, 1827 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI, HID_QUIRK_POWERBOOK_HAS_FN },
1801 { USB_VENDOR_ID_APPLE, 0x020F, HID_QUIRK_POWERBOOK_HAS_FN }, 1828 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO, HID_QUIRK_POWERBOOK_HAS_FN },
1802 { USB_VENDOR_ID_APPLE, 0x0214, HID_QUIRK_POWERBOOK_HAS_FN }, 1829 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI, HID_QUIRK_POWERBOOK_HAS_FN },
1803 { USB_VENDOR_ID_APPLE, 0x0215, HID_QUIRK_POWERBOOK_HAS_FN }, 1830 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_POWERBOOK_ISO_KEYBOARD},
1804 { USB_VENDOR_ID_APPLE, 0x0216, HID_QUIRK_POWERBOOK_HAS_FN }, 1831 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS, HID_QUIRK_POWERBOOK_HAS_FN },
1805 { USB_VENDOR_ID_APPLE, 0x0217, HID_QUIRK_POWERBOOK_HAS_FN }, 1832 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI, HID_QUIRK_POWERBOOK_HAS_FN },
1806 { USB_VENDOR_ID_APPLE, 0x0218, HID_QUIRK_POWERBOOK_HAS_FN }, 1833 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_POWERBOOK_ISO_KEYBOARD},
1807 { USB_VENDOR_ID_APPLE, 0x0219, HID_QUIRK_POWERBOOK_HAS_FN }, 1834 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS, HID_QUIRK_POWERBOOK_HAS_FN },
1808 { USB_VENDOR_ID_APPLE, 0x030A, HID_QUIRK_POWERBOOK_HAS_FN }, 1835 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI, HID_QUIRK_POWERBOOK_HAS_FN },
1809 { USB_VENDOR_ID_APPLE, 0x030B, HID_QUIRK_POWERBOOK_HAS_FN }, 1836 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO, HID_QUIRK_POWERBOOK_HAS_FN },
1837 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS, HID_QUIRK_POWERBOOK_HAS_FN },
1838 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY, HID_QUIRK_POWERBOOK_HAS_FN },
1839 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY, HID_QUIRK_POWERBOOK_HAS_FN },
1810 1840
1811 { USB_VENDOR_ID_PANJIT, 0x0001, HID_QUIRK_IGNORE }, 1841 { USB_VENDOR_ID_PANJIT, 0x0001, HID_QUIRK_IGNORE },
1812 { USB_VENDOR_ID_PANJIT, 0x0002, HID_QUIRK_IGNORE }, 1842 { USB_VENDOR_ID_PANJIT, 0x0002, HID_QUIRK_IGNORE },
@@ -1839,13 +1869,13 @@ static void hid_find_max_report(struct hid_device *hid, unsigned int type, int *
1839 1869
1840static int hid_alloc_buffers(struct usb_device *dev, struct hid_device *hid) 1870static int hid_alloc_buffers(struct usb_device *dev, struct hid_device *hid)
1841{ 1871{
1842 if (!(hid->inbuf = usb_buffer_alloc(dev, hid->bufsize, SLAB_ATOMIC, &hid->inbuf_dma))) 1872 if (!(hid->inbuf = usb_buffer_alloc(dev, hid->bufsize, GFP_ATOMIC, &hid->inbuf_dma)))
1843 return -1; 1873 return -1;
1844 if (!(hid->outbuf = usb_buffer_alloc(dev, hid->bufsize, SLAB_ATOMIC, &hid->outbuf_dma))) 1874 if (!(hid->outbuf = usb_buffer_alloc(dev, hid->bufsize, GFP_ATOMIC, &hid->outbuf_dma)))
1845 return -1; 1875 return -1;
1846 if (!(hid->cr = usb_buffer_alloc(dev, sizeof(*(hid->cr)), SLAB_ATOMIC, &hid->cr_dma))) 1876 if (!(hid->cr = usb_buffer_alloc(dev, sizeof(*(hid->cr)), GFP_ATOMIC, &hid->cr_dma)))
1847 return -1; 1877 return -1;
1848 if (!(hid->ctrlbuf = usb_buffer_alloc(dev, hid->bufsize, SLAB_ATOMIC, &hid->ctrlbuf_dma))) 1878 if (!(hid->ctrlbuf = usb_buffer_alloc(dev, hid->bufsize, GFP_ATOMIC, &hid->ctrlbuf_dma)))
1849 return -1; 1879 return -1;
1850 1880
1851 return 0; 1881 return 0;
@@ -1989,7 +2019,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
1989 if (hid->collection->usage == HID_GD_MOUSE && hid_mousepoll_interval > 0) 2019 if (hid->collection->usage == HID_GD_MOUSE && hid_mousepoll_interval > 0)
1990 interval = hid_mousepoll_interval; 2020 interval = hid_mousepoll_interval;
1991 2021
1992 if (endpoint->bEndpointAddress & USB_DIR_IN) { 2022 if (usb_endpoint_dir_in(endpoint)) {
1993 if (hid->urbin) 2023 if (hid->urbin)
1994 continue; 2024 continue;
1995 if (!(hid->urbin = usb_alloc_urb(0, GFP_KERNEL))) 2025 if (!(hid->urbin = usb_alloc_urb(0, GFP_KERNEL)))
@@ -2019,7 +2049,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
2019 2049
2020 init_waitqueue_head(&hid->wait); 2050 init_waitqueue_head(&hid->wait);
2021 2051
2022 INIT_WORK(&hid->reset_work, hid_reset, hid); 2052 INIT_WORK(&hid->reset_work, hid_reset);
2023 setup_timer(&hid->io_retry, hid_retry_timeout, (unsigned long) hid); 2053 setup_timer(&hid->io_retry, hid_retry_timeout, (unsigned long) hid);
2024 2054
2025 spin_lock_init(&hid->inlock); 2055 spin_lock_init(&hid->inlock);
@@ -2071,13 +2101,9 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
2071 return hid; 2101 return hid;
2072 2102
2073fail: 2103fail:
2074 2104 usb_free_urb(hid->urbin);
2075 if (hid->urbin) 2105 usb_free_urb(hid->urbout);
2076 usb_free_urb(hid->urbin); 2106 usb_free_urb(hid->urbctrl);
2077 if (hid->urbout)
2078 usb_free_urb(hid->urbout);
2079 if (hid->urbctrl)
2080 usb_free_urb(hid->urbctrl);
2081 hid_free_buffers(dev, hid); 2107 hid_free_buffers(dev, hid);
2082 hid_free_device(hid); 2108 hid_free_device(hid);
2083 2109
@@ -2108,8 +2134,7 @@ static void hid_disconnect(struct usb_interface *intf)
2108 2134
2109 usb_free_urb(hid->urbin); 2135 usb_free_urb(hid->urbin);
2110 usb_free_urb(hid->urbctrl); 2136 usb_free_urb(hid->urbctrl);
2111 if (hid->urbout) 2137 usb_free_urb(hid->urbout);
2112 usb_free_urb(hid->urbout);
2113 2138
2114 hid_free_buffers(hid->dev, hid); 2139 hid_free_buffers(hid->dev, hid);
2115 hid_free_device(hid); 2140 hid_free_device(hid);
diff --git a/drivers/usb/input/hid-input.c b/drivers/usb/input/hid-input.c
index c8ce65c70a42..3a7e5fbff025 100644
--- a/drivers/usb/input/hid-input.c
+++ b/drivers/usb/input/hid-input.c
@@ -121,6 +121,12 @@ static struct hidinput_key_translation powerbook_numlock_keys[] = {
121 { } 121 { }
122}; 122};
123 123
124static struct hidinput_key_translation powerbook_iso_keyboard[] = {
125 { KEY_GRAVE, KEY_102ND },
126 { KEY_102ND, KEY_GRAVE },
127 { }
128};
129
124static int usbhid_pb_fnmode = 1; 130static int usbhid_pb_fnmode = 1;
125module_param_named(pb_fnmode, usbhid_pb_fnmode, int, 0644); 131module_param_named(pb_fnmode, usbhid_pb_fnmode, int, 0644);
126MODULE_PARM_DESC(pb_fnmode, 132MODULE_PARM_DESC(pb_fnmode,
@@ -195,6 +201,14 @@ static int hidinput_pb_event(struct hid_device *hid, struct input_dev *input,
195 } 201 }
196 } 202 }
197 203
204 if (hid->quirks & HID_QUIRK_POWERBOOK_ISO_KEYBOARD) {
205 trans = find_translation(powerbook_iso_keyboard, usage->code);
206 if (trans) {
207 input_event(input, usage->type, trans->to, value);
208 return 1;
209 }
210 }
211
198 return 0; 212 return 0;
199} 213}
200 214
@@ -210,6 +224,9 @@ static void hidinput_pb_setup(struct input_dev *input)
210 224
211 for (trans = powerbook_numlock_keys; trans->from; trans++) 225 for (trans = powerbook_numlock_keys; trans->from; trans++)
212 set_bit(trans->to, input->keybit); 226 set_bit(trans->to, input->keybit);
227
228 for (trans = powerbook_iso_keyboard; trans->from; trans++)
229 set_bit(trans->to, input->keybit);
213} 230}
214#else 231#else
215static inline int hidinput_pb_event(struct hid_device *hid, struct input_dev *input, 232static inline int hidinput_pb_event(struct hid_device *hid, struct input_dev *input,
diff --git a/drivers/usb/input/hid.h b/drivers/usb/input/hid.h
index 8aa9ec08e8ab..76ad68d9edfd 100644
--- a/drivers/usb/input/hid.h
+++ b/drivers/usb/input/hid.h
@@ -260,7 +260,8 @@ struct hid_item {
260#define HID_QUIRK_POWERBOOK_HAS_FN 0x00001000 260#define HID_QUIRK_POWERBOOK_HAS_FN 0x00001000
261#define HID_QUIRK_POWERBOOK_FN_ON 0x00002000 261#define HID_QUIRK_POWERBOOK_FN_ON 0x00002000
262#define HID_QUIRK_INVERT_HWHEEL 0x00004000 262#define HID_QUIRK_INVERT_HWHEEL 0x00004000
263#define HID_QUIRK_BAD_RELATIVE_KEYS 0x00008000 263#define HID_QUIRK_POWERBOOK_ISO_KEYBOARD 0x00008000
264#define HID_QUIRK_BAD_RELATIVE_KEYS 0x00010000
264 265
265/* 266/*
266 * This is the global environment of the parser. This information is 267 * This is the global environment of the parser. This information is
@@ -385,6 +386,7 @@ struct hid_control_fifo {
385#define HID_IN_RUNNING 3 386#define HID_IN_RUNNING 3
386#define HID_RESET_PENDING 4 387#define HID_RESET_PENDING 4
387#define HID_SUSPENDED 5 388#define HID_SUSPENDED 5
389#define HID_CLEAR_HALT 6
388 390
389struct hid_input { 391struct hid_input {
390 struct list_head list; 392 struct list_head list;
diff --git a/drivers/usb/input/keyspan_remote.c b/drivers/usb/input/keyspan_remote.c
index 50aa8108a50b..98bd323369c7 100644
--- a/drivers/usb/input/keyspan_remote.c
+++ b/drivers/usb/input/keyspan_remote.c
@@ -456,7 +456,7 @@ static int keyspan_probe(struct usb_interface *interface, const struct usb_devic
456 remote->in_endpoint = endpoint; 456 remote->in_endpoint = endpoint;
457 remote->toggle = -1; /* Set to -1 so we will always not match the toggle from the first remote message. */ 457 remote->toggle = -1; /* Set to -1 so we will always not match the toggle from the first remote message. */
458 458
459 remote->in_buffer = usb_buffer_alloc(udev, RECV_SIZE, SLAB_ATOMIC, &remote->in_dma); 459 remote->in_buffer = usb_buffer_alloc(udev, RECV_SIZE, GFP_ATOMIC, &remote->in_dma);
460 if (!remote->in_buffer) { 460 if (!remote->in_buffer) {
461 retval = -ENOMEM; 461 retval = -ENOMEM;
462 goto fail1; 462 goto fail1;
diff --git a/drivers/usb/input/mtouchusb.c b/drivers/usb/input/mtouchusb.c
index 79a85d46cb13..92c4e07da4c8 100644
--- a/drivers/usb/input/mtouchusb.c
+++ b/drivers/usb/input/mtouchusb.c
@@ -164,7 +164,7 @@ static int mtouchusb_alloc_buffers(struct usb_device *udev, struct mtouch_usb *m
164 dbg("%s - called", __FUNCTION__); 164 dbg("%s - called", __FUNCTION__);
165 165
166 mtouch->data = usb_buffer_alloc(udev, MTOUCHUSB_REPORT_DATA_SIZE, 166 mtouch->data = usb_buffer_alloc(udev, MTOUCHUSB_REPORT_DATA_SIZE,
167 SLAB_ATOMIC, &mtouch->data_dma); 167 GFP_ATOMIC, &mtouch->data_dma);
168 168
169 if (!mtouch->data) 169 if (!mtouch->data)
170 return -1; 170 return -1;
diff --git a/drivers/usb/input/powermate.c b/drivers/usb/input/powermate.c
index 0bf91778c40d..fea97e5437f8 100644
--- a/drivers/usb/input/powermate.c
+++ b/drivers/usb/input/powermate.c
@@ -277,12 +277,12 @@ static int powermate_input_event(struct input_dev *dev, unsigned int type, unsig
277static int powermate_alloc_buffers(struct usb_device *udev, struct powermate_device *pm) 277static int powermate_alloc_buffers(struct usb_device *udev, struct powermate_device *pm)
278{ 278{
279 pm->data = usb_buffer_alloc(udev, POWERMATE_PAYLOAD_SIZE_MAX, 279 pm->data = usb_buffer_alloc(udev, POWERMATE_PAYLOAD_SIZE_MAX,
280 SLAB_ATOMIC, &pm->data_dma); 280 GFP_ATOMIC, &pm->data_dma);
281 if (!pm->data) 281 if (!pm->data)
282 return -1; 282 return -1;
283 283
284 pm->configcr = usb_buffer_alloc(udev, sizeof(*(pm->configcr)), 284 pm->configcr = usb_buffer_alloc(udev, sizeof(*(pm->configcr)),
285 SLAB_ATOMIC, &pm->configcr_dma); 285 GFP_ATOMIC, &pm->configcr_dma);
286 if (!pm->configcr) 286 if (!pm->configcr)
287 return -1; 287 return -1;
288 288
diff --git a/drivers/usb/input/touchkitusb.c b/drivers/usb/input/touchkitusb.c
index 05c0d1ca39ab..2a314b065922 100644
--- a/drivers/usb/input/touchkitusb.c
+++ b/drivers/usb/input/touchkitusb.c
@@ -248,7 +248,7 @@ static int touchkit_alloc_buffers(struct usb_device *udev,
248 struct touchkit_usb *touchkit) 248 struct touchkit_usb *touchkit)
249{ 249{
250 touchkit->data = usb_buffer_alloc(udev, TOUCHKIT_REPORT_DATA_SIZE, 250 touchkit->data = usb_buffer_alloc(udev, TOUCHKIT_REPORT_DATA_SIZE,
251 SLAB_ATOMIC, &touchkit->data_dma); 251 GFP_ATOMIC, &touchkit->data_dma);
252 252
253 if (!touchkit->data) 253 if (!touchkit->data)
254 return -1; 254 return -1;
diff --git a/drivers/usb/input/usbkbd.c b/drivers/usb/input/usbkbd.c
index c73285cf8558..8505824848f6 100644
--- a/drivers/usb/input/usbkbd.c
+++ b/drivers/usb/input/usbkbd.c
@@ -122,7 +122,7 @@ static void usb_kbd_irq(struct urb *urb)
122 memcpy(kbd->old, kbd->new, 8); 122 memcpy(kbd->old, kbd->new, 8);
123 123
124resubmit: 124resubmit:
125 i = usb_submit_urb (urb, SLAB_ATOMIC); 125 i = usb_submit_urb (urb, GFP_ATOMIC);
126 if (i) 126 if (i)
127 err ("can't resubmit intr, %s-%s/input0, status %d", 127 err ("can't resubmit intr, %s-%s/input0, status %d",
128 kbd->usbdev->bus->bus_name, 128 kbd->usbdev->bus->bus_name,
@@ -196,11 +196,11 @@ static int usb_kbd_alloc_mem(struct usb_device *dev, struct usb_kbd *kbd)
196 return -1; 196 return -1;
197 if (!(kbd->led = usb_alloc_urb(0, GFP_KERNEL))) 197 if (!(kbd->led = usb_alloc_urb(0, GFP_KERNEL)))
198 return -1; 198 return -1;
199 if (!(kbd->new = usb_buffer_alloc(dev, 8, SLAB_ATOMIC, &kbd->new_dma))) 199 if (!(kbd->new = usb_buffer_alloc(dev, 8, GFP_ATOMIC, &kbd->new_dma)))
200 return -1; 200 return -1;
201 if (!(kbd->cr = usb_buffer_alloc(dev, sizeof(struct usb_ctrlrequest), SLAB_ATOMIC, &kbd->cr_dma))) 201 if (!(kbd->cr = usb_buffer_alloc(dev, sizeof(struct usb_ctrlrequest), GFP_ATOMIC, &kbd->cr_dma)))
202 return -1; 202 return -1;
203 if (!(kbd->leds = usb_buffer_alloc(dev, 1, SLAB_ATOMIC, &kbd->leds_dma))) 203 if (!(kbd->leds = usb_buffer_alloc(dev, 1, GFP_ATOMIC, &kbd->leds_dma)))
204 return -1; 204 return -1;
205 205
206 return 0; 206 return 0;
@@ -208,10 +208,8 @@ static int usb_kbd_alloc_mem(struct usb_device *dev, struct usb_kbd *kbd)
208 208
209static void usb_kbd_free_mem(struct usb_device *dev, struct usb_kbd *kbd) 209static void usb_kbd_free_mem(struct usb_device *dev, struct usb_kbd *kbd)
210{ 210{
211 if (kbd->irq) 211 usb_free_urb(kbd->irq);
212 usb_free_urb(kbd->irq); 212 usb_free_urb(kbd->led);
213 if (kbd->led)
214 usb_free_urb(kbd->led);
215 if (kbd->new) 213 if (kbd->new)
216 usb_buffer_free(dev, 8, kbd->new, kbd->new_dma); 214 usb_buffer_free(dev, 8, kbd->new, kbd->new_dma);
217 if (kbd->cr) 215 if (kbd->cr)
@@ -236,9 +234,7 @@ static int usb_kbd_probe(struct usb_interface *iface,
236 return -ENODEV; 234 return -ENODEV;
237 235
238 endpoint = &interface->endpoint[0].desc; 236 endpoint = &interface->endpoint[0].desc;
239 if (!(endpoint->bEndpointAddress & USB_DIR_IN)) 237 if (!usb_endpoint_is_int_in(endpoint))
240 return -ENODEV;
241 if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT)
242 return -ENODEV; 238 return -ENODEV;
243 239
244 pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); 240 pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress);
diff --git a/drivers/usb/input/usbmouse.c b/drivers/usb/input/usbmouse.c
index cbbbea332ed7..64a33e420cfb 100644
--- a/drivers/usb/input/usbmouse.c
+++ b/drivers/usb/input/usbmouse.c
@@ -86,7 +86,7 @@ static void usb_mouse_irq(struct urb *urb)
86 86
87 input_sync(dev); 87 input_sync(dev);
88resubmit: 88resubmit:
89 status = usb_submit_urb (urb, SLAB_ATOMIC); 89 status = usb_submit_urb (urb, GFP_ATOMIC);
90 if (status) 90 if (status)
91 err ("can't resubmit intr, %s-%s/input0, status %d", 91 err ("can't resubmit intr, %s-%s/input0, status %d",
92 mouse->usbdev->bus->bus_name, 92 mouse->usbdev->bus->bus_name,
@@ -126,9 +126,7 @@ static int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_i
126 return -ENODEV; 126 return -ENODEV;
127 127
128 endpoint = &interface->endpoint[0].desc; 128 endpoint = &interface->endpoint[0].desc;
129 if (!(endpoint->bEndpointAddress & USB_DIR_IN)) 129 if (!usb_endpoint_is_int_in(endpoint))
130 return -ENODEV;
131 if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT)
132 return -ENODEV; 130 return -ENODEV;
133 131
134 pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); 132 pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress);
@@ -139,7 +137,7 @@ static int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_i
139 if (!mouse || !input_dev) 137 if (!mouse || !input_dev)
140 goto fail1; 138 goto fail1;
141 139
142 mouse->data = usb_buffer_alloc(dev, 8, SLAB_ATOMIC, &mouse->data_dma); 140 mouse->data = usb_buffer_alloc(dev, 8, GFP_ATOMIC, &mouse->data_dma);
143 if (!mouse->data) 141 if (!mouse->data)
144 goto fail1; 142 goto fail1;
145 143
diff --git a/drivers/usb/input/usbtouchscreen.c b/drivers/usb/input/usbtouchscreen.c
index 933ceddf3dee..7f3c57da9bc0 100644
--- a/drivers/usb/input/usbtouchscreen.c
+++ b/drivers/usb/input/usbtouchscreen.c
@@ -8,6 +8,7 @@
8 * - PanJit TouchSet 8 * - PanJit TouchSet
9 * - eTurboTouch 9 * - eTurboTouch
10 * - Gunze AHL61 10 * - Gunze AHL61
11 * - DMC TSC-10/25
11 * 12 *
12 * Copyright (C) 2004-2006 by Daniel Ritz <daniel.ritz@gmx.ch> 13 * Copyright (C) 2004-2006 by Daniel Ritz <daniel.ritz@gmx.ch>
13 * Copyright (C) by Todd E. Johnson (mtouchusb.c) 14 * Copyright (C) by Todd E. Johnson (mtouchusb.c)
@@ -30,6 +31,8 @@
30 * - ITM parts are from itmtouch.c 31 * - ITM parts are from itmtouch.c
31 * - 3M parts are from mtouchusb.c 32 * - 3M parts are from mtouchusb.c
32 * - PanJit parts are from an unmerged driver by Lanslott Gish 33 * - PanJit parts are from an unmerged driver by Lanslott Gish
34 * - DMC TSC 10/25 are from Holger Schurig, with ideas from an unmerged
35 * driver from Marius Vollmer
33 * 36 *
34 *****************************************************************************/ 37 *****************************************************************************/
35 38
@@ -44,7 +47,7 @@
44#include <linux/usb/input.h> 47#include <linux/usb/input.h>
45 48
46 49
47#define DRIVER_VERSION "v0.4" 50#define DRIVER_VERSION "v0.5"
48#define DRIVER_AUTHOR "Daniel Ritz <daniel.ritz@gmx.ch>" 51#define DRIVER_AUTHOR "Daniel Ritz <daniel.ritz@gmx.ch>"
49#define DRIVER_DESC "USB Touchscreen Driver" 52#define DRIVER_DESC "USB Touchscreen Driver"
50 53
@@ -103,6 +106,7 @@ enum {
103 DEVTYPE_ITM, 106 DEVTYPE_ITM,
104 DEVTYPE_ETURBO, 107 DEVTYPE_ETURBO,
105 DEVTYPE_GUNZE, 108 DEVTYPE_GUNZE,
109 DEVTYPE_DMC_TSC10,
106}; 110};
107 111
108static struct usb_device_id usbtouch_devices[] = { 112static struct usb_device_id usbtouch_devices[] = {
@@ -139,6 +143,10 @@ static struct usb_device_id usbtouch_devices[] = {
139 {USB_DEVICE(0x0637, 0x0001), .driver_info = DEVTYPE_GUNZE}, 143 {USB_DEVICE(0x0637, 0x0001), .driver_info = DEVTYPE_GUNZE},
140#endif 144#endif
141 145
146#ifdef CONFIG_USB_TOUCHSCREEN_DMC_TSC10
147 {USB_DEVICE(0x0afa, 0x03e8), .driver_info = DEVTYPE_DMC_TSC10},
148#endif
149
142 {} 150 {}
143}; 151};
144 152
@@ -313,6 +321,80 @@ static int gunze_read_data(unsigned char *pkt, int *x, int *y, int *touch, int *
313#endif 321#endif
314 322
315/***************************************************************************** 323/*****************************************************************************
324 * DMC TSC-10/25 Part
325 *
326 * Documentation about the controller and it's protocol can be found at
327 * http://www.dmccoltd.com/files/controler/tsc10usb_pi_e.pdf
328 * http://www.dmccoltd.com/files/controler/tsc25_usb_e.pdf
329 */
330#ifdef CONFIG_USB_TOUCHSCREEN_DMC_TSC10
331
332/* supported data rates. currently using 130 */
333#define TSC10_RATE_POINT 0x50
334#define TSC10_RATE_30 0x40
335#define TSC10_RATE_50 0x41
336#define TSC10_RATE_80 0x42
337#define TSC10_RATE_100 0x43
338#define TSC10_RATE_130 0x44
339#define TSC10_RATE_150 0x45
340
341/* commands */
342#define TSC10_CMD_RESET 0x55
343#define TSC10_CMD_RATE 0x05
344#define TSC10_CMD_DATA1 0x01
345
346static int dmc_tsc10_init(struct usbtouch_usb *usbtouch)
347{
348 struct usb_device *dev = usbtouch->udev;
349 int ret;
350 unsigned char buf[2];
351
352 /* reset */
353 buf[0] = buf[1] = 0xFF;
354 ret = usb_control_msg(dev, usb_rcvctrlpipe (dev, 0),
355 TSC10_CMD_RESET,
356 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
357 0, 0, buf, 2, USB_CTRL_SET_TIMEOUT);
358 if (ret < 0)
359 return ret;
360 if (buf[0] != 0x06 || buf[1] != 0x00)
361 return -ENODEV;
362
363 /* set coordinate output rate */
364 buf[0] = buf[1] = 0xFF;
365 ret = usb_control_msg(dev, usb_rcvctrlpipe (dev, 0),
366 TSC10_CMD_RATE,
367 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
368 TSC10_RATE_150, 0, buf, 2, USB_CTRL_SET_TIMEOUT);
369 if (ret < 0)
370 return ret;
371 if (buf[0] != 0x06 || buf[1] != 0x00)
372 return -ENODEV;
373
374 /* start sending data */
375 ret = usb_control_msg(dev, usb_rcvctrlpipe (dev, 0),
376 TSC10_CMD_DATA1,
377 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
378 0, 0, NULL, 0, USB_CTRL_SET_TIMEOUT);
379 if (ret < 0)
380 return ret;
381
382 return 0;
383}
384
385
386static int dmc_tsc10_read_data(unsigned char *pkt, int *x, int *y, int *touch, int *press)
387{
388 *x = ((pkt[2] & 0x03) << 8) | pkt[1];
389 *y = ((pkt[4] & 0x03) << 8) | pkt[3];
390 *touch = pkt[0] & 0x01;
391
392 return 1;
393}
394#endif
395
396
397/*****************************************************************************
316 * the different device descriptors 398 * the different device descriptors
317 */ 399 */
318static struct usbtouch_device_info usbtouch_dev_info[] = { 400static struct usbtouch_device_info usbtouch_dev_info[] = {
@@ -389,6 +471,18 @@ static struct usbtouch_device_info usbtouch_dev_info[] = {
389 .read_data = gunze_read_data, 471 .read_data = gunze_read_data,
390 }, 472 },
391#endif 473#endif
474
475#ifdef CONFIG_USB_TOUCHSCREEN_DMC_TSC10
476 [DEVTYPE_DMC_TSC10] = {
477 .min_xc = 0x0,
478 .max_xc = 0x03ff,
479 .min_yc = 0x0,
480 .max_yc = 0x03ff,
481 .rept_size = 5,
482 .init = dmc_tsc10_init,
483 .read_data = dmc_tsc10_read_data,
484 },
485#endif
392}; 486};
393 487
394 488
@@ -586,7 +680,7 @@ static int usbtouch_probe(struct usb_interface *intf,
586 type->process_pkt = usbtouch_process_pkt; 680 type->process_pkt = usbtouch_process_pkt;
587 681
588 usbtouch->data = usb_buffer_alloc(udev, type->rept_size, 682 usbtouch->data = usb_buffer_alloc(udev, type->rept_size,
589 SLAB_KERNEL, &usbtouch->data_dma); 683 GFP_KERNEL, &usbtouch->data_dma);
590 if (!usbtouch->data) 684 if (!usbtouch->data)
591 goto out_free; 685 goto out_free;
592 686
diff --git a/drivers/usb/input/wacom.h b/drivers/usb/input/wacom.h
index 1cf08f02c50e..d85abfc5ab58 100644
--- a/drivers/usb/input/wacom.h
+++ b/drivers/usb/input/wacom.h
@@ -110,7 +110,6 @@ struct wacom_combo {
110}; 110};
111 111
112extern int wacom_wac_irq(struct wacom_wac * wacom_wac, void * wcombo); 112extern int wacom_wac_irq(struct wacom_wac * wacom_wac, void * wcombo);
113extern void wacom_sys_irq(struct urb *urb);
114extern void wacom_report_abs(void *wcombo, unsigned int abs_type, int abs_data); 113extern void wacom_report_abs(void *wcombo, unsigned int abs_type, int abs_data);
115extern void wacom_report_rel(void *wcombo, unsigned int rel_type, int rel_data); 114extern void wacom_report_rel(void *wcombo, unsigned int rel_type, int rel_data);
116extern void wacom_report_key(void *wcombo, unsigned int key_type, int key_data); 115extern void wacom_report_key(void *wcombo, unsigned int key_type, int key_data);
diff --git a/drivers/usb/input/wacom_sys.c b/drivers/usb/input/wacom_sys.c
index 3498b893b53b..e7cc20ab8155 100644
--- a/drivers/usb/input/wacom_sys.c
+++ b/drivers/usb/input/wacom_sys.c
@@ -42,7 +42,7 @@ static struct input_dev * get_input_dev(struct wacom_combo *wcombo)
42 return wcombo->wacom->dev; 42 return wcombo->wacom->dev;
43} 43}
44 44
45void wacom_sys_irq(struct urb *urb) 45static void wacom_sys_irq(struct urb *urb)
46{ 46{
47 struct wacom *wacom = urb->context; 47 struct wacom *wacom = urb->context;
48 struct wacom_combo wcombo; 48 struct wacom_combo wcombo;
diff --git a/drivers/usb/input/xpad.c b/drivers/usb/input/xpad.c
index df97e5c803f9..e4bc76ebc835 100644
--- a/drivers/usb/input/xpad.c
+++ b/drivers/usb/input/xpad.c
@@ -325,7 +325,7 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
325 goto fail1; 325 goto fail1;
326 326
327 xpad->idata = usb_buffer_alloc(udev, XPAD_PKT_LEN, 327 xpad->idata = usb_buffer_alloc(udev, XPAD_PKT_LEN,
328 SLAB_ATOMIC, &xpad->idata_dma); 328 GFP_ATOMIC, &xpad->idata_dma);
329 if (!xpad->idata) 329 if (!xpad->idata)
330 goto fail1; 330 goto fail1;
331 331
diff --git a/drivers/usb/input/yealink.c b/drivers/usb/input/yealink.c
index 905bf6398257..caff8e6d7448 100644
--- a/drivers/usb/input/yealink.c
+++ b/drivers/usb/input/yealink.c
@@ -859,10 +859,8 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
859 859
860 interface = intf->cur_altsetting; 860 interface = intf->cur_altsetting;
861 endpoint = &interface->endpoint[0].desc; 861 endpoint = &interface->endpoint[0].desc;
862 if (!(endpoint->bEndpointAddress & USB_DIR_IN)) 862 if (!usb_endpoint_is_int_in(endpoint))
863 return -EIO; 863 return -ENODEV;
864 if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT)
865 return -EIO;
866 864
867 yld = kzalloc(sizeof(struct yealink_dev), GFP_KERNEL); 865 yld = kzalloc(sizeof(struct yealink_dev), GFP_KERNEL);
868 if (!yld) 866 if (!yld)
@@ -876,17 +874,17 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
876 874
877 /* allocate usb buffers */ 875 /* allocate usb buffers */
878 yld->irq_data = usb_buffer_alloc(udev, USB_PKT_LEN, 876 yld->irq_data = usb_buffer_alloc(udev, USB_PKT_LEN,
879 SLAB_ATOMIC, &yld->irq_dma); 877 GFP_ATOMIC, &yld->irq_dma);
880 if (yld->irq_data == NULL) 878 if (yld->irq_data == NULL)
881 return usb_cleanup(yld, -ENOMEM); 879 return usb_cleanup(yld, -ENOMEM);
882 880
883 yld->ctl_data = usb_buffer_alloc(udev, USB_PKT_LEN, 881 yld->ctl_data = usb_buffer_alloc(udev, USB_PKT_LEN,
884 SLAB_ATOMIC, &yld->ctl_dma); 882 GFP_ATOMIC, &yld->ctl_dma);
885 if (!yld->ctl_data) 883 if (!yld->ctl_data)
886 return usb_cleanup(yld, -ENOMEM); 884 return usb_cleanup(yld, -ENOMEM);
887 885
888 yld->ctl_req = usb_buffer_alloc(udev, sizeof(*(yld->ctl_req)), 886 yld->ctl_req = usb_buffer_alloc(udev, sizeof(*(yld->ctl_req)),
889 SLAB_ATOMIC, &yld->ctl_req_dma); 887 GFP_ATOMIC, &yld->ctl_req_dma);
890 if (yld->ctl_req == NULL) 888 if (yld->ctl_req == NULL)
891 return usb_cleanup(yld, -ENOMEM); 889 return usb_cleanup(yld, -ENOMEM);
892 890
diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile
index 11dc59540cda..2cba07d31971 100644
--- a/drivers/usb/misc/Makefile
+++ b/drivers/usb/misc/Makefile
@@ -4,6 +4,7 @@
4# 4#
5 5
6obj-$(CONFIG_USB_ADUTUX) += adutux.o 6obj-$(CONFIG_USB_ADUTUX) += adutux.o
7obj-$(CONFIG_USB_APPLEDISPLAY) += appledisplay.o
7obj-$(CONFIG_USB_AUERSWALD) += auerswald.o 8obj-$(CONFIG_USB_AUERSWALD) += auerswald.o
8obj-$(CONFIG_USB_CYPRESS_CY7C63)+= cypress_cy7c63.o 9obj-$(CONFIG_USB_CYPRESS_CY7C63)+= cypress_cy7c63.o
9obj-$(CONFIG_USB_CYTHERM) += cytherm.o 10obj-$(CONFIG_USB_CYTHERM) += cytherm.o
diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
index 6b23a1def9fe..02cbb7fff24f 100644
--- a/drivers/usb/misc/appledisplay.c
+++ b/drivers/usb/misc/appledisplay.c
@@ -76,7 +76,7 @@ struct appledisplay {
76 char *urbdata; /* interrupt URB data buffer */ 76 char *urbdata; /* interrupt URB data buffer */
77 char *msgdata; /* control message data buffer */ 77 char *msgdata; /* control message data buffer */
78 78
79 struct work_struct work; 79 struct delayed_work work;
80 int button_pressed; 80 int button_pressed;
81 spinlock_t lock; 81 spinlock_t lock;
82}; 82};
@@ -117,7 +117,7 @@ static void appledisplay_complete(struct urb *urb)
117 case ACD_BTN_BRIGHT_UP: 117 case ACD_BTN_BRIGHT_UP:
118 case ACD_BTN_BRIGHT_DOWN: 118 case ACD_BTN_BRIGHT_DOWN:
119 pdata->button_pressed = 1; 119 pdata->button_pressed = 1;
120 queue_work(wq, &pdata->work); 120 queue_delayed_work(wq, &pdata->work, 0);
121 break; 121 break;
122 case ACD_BTN_NONE: 122 case ACD_BTN_NONE:
123 default: 123 default:
@@ -184,9 +184,10 @@ static struct backlight_properties appledisplay_bl_data = {
184 .max_brightness = 0xFF 184 .max_brightness = 0xFF
185}; 185};
186 186
187static void appledisplay_work(void *private) 187static void appledisplay_work(struct work_struct *work)
188{ 188{
189 struct appledisplay *pdata = private; 189 struct appledisplay *pdata =
190 container_of(work, struct appledisplay, work.work);
190 int retval; 191 int retval;
191 192
192 up(&pdata->bd->sem); 193 up(&pdata->bd->sem);
@@ -216,10 +217,7 @@ static int appledisplay_probe(struct usb_interface *iface,
216 iface_desc = iface->cur_altsetting; 217 iface_desc = iface->cur_altsetting;
217 for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) { 218 for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) {
218 endpoint = &iface_desc->endpoint[i].desc; 219 endpoint = &iface_desc->endpoint[i].desc;
219 if (!int_in_endpointAddr && 220 if (!int_in_endpointAddr && usb_endpoint_is_int_in(endpoint)) {
220 (endpoint->bEndpointAddress & USB_DIR_IN) &&
221 ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
222 USB_ENDPOINT_XFER_INT)) {
223 /* we found an interrupt in endpoint */ 221 /* we found an interrupt in endpoint */
224 int_in_endpointAddr = endpoint->bEndpointAddress; 222 int_in_endpointAddr = endpoint->bEndpointAddress;
225 break; 223 break;
@@ -241,7 +239,7 @@ static int appledisplay_probe(struct usb_interface *iface,
241 pdata->udev = udev; 239 pdata->udev = udev;
242 240
243 spin_lock_init(&pdata->lock); 241 spin_lock_init(&pdata->lock);
244 INIT_WORK(&pdata->work, appledisplay_work, pdata); 242 INIT_DELAYED_WORK(&pdata->work, appledisplay_work);
245 243
246 /* Allocate buffer for control messages */ 244 /* Allocate buffer for control messages */
247 pdata->msgdata = kmalloc(ACD_MSG_BUFFER_LEN, GFP_KERNEL); 245 pdata->msgdata = kmalloc(ACD_MSG_BUFFER_LEN, GFP_KERNEL);
diff --git a/drivers/usb/misc/auerswald.c b/drivers/usb/misc/auerswald.c
index 0be9d62d62ae..c703f73e1655 100644
--- a/drivers/usb/misc/auerswald.c
+++ b/drivers/usb/misc/auerswald.c
@@ -704,9 +704,7 @@ static void auerbuf_free (pauerbuf_t bp)
704{ 704{
705 kfree(bp->bufp); 705 kfree(bp->bufp);
706 kfree(bp->dr); 706 kfree(bp->dr);
707 if (bp->urbp) { 707 usb_free_urb(bp->urbp);
708 usb_free_urb(bp->urbp);
709 }
710 kfree(bp); 708 kfree(bp);
711} 709}
712 710
@@ -780,7 +778,7 @@ static int auerbuf_setup (pauerbufctl_t bcp, unsigned int numElements, unsigned
780 778
781bl_fail:/* not enough memory. Free allocated elements */ 779bl_fail:/* not enough memory. Free allocated elements */
782 dbg ("auerbuf_setup: no more memory"); 780 dbg ("auerbuf_setup: no more memory");
783 kfree(bep); 781 auerbuf_free(bep);
784 auerbuf_free_buffers (bcp); 782 auerbuf_free_buffers (bcp);
785 return -ENOMEM; 783 return -ENOMEM;
786} 784}
@@ -1155,8 +1153,7 @@ static void auerswald_int_release (pauerswald_t cp)
1155 dbg ("auerswald_int_release"); 1153 dbg ("auerswald_int_release");
1156 1154
1157 /* stop the int endpoint */ 1155 /* stop the int endpoint */
1158 if (cp->inturbp) 1156 usb_kill_urb (cp->inturbp);
1159 usb_kill_urb (cp->inturbp);
1160 1157
1161 /* deallocate memory */ 1158 /* deallocate memory */
1162 auerswald_int_free (cp); 1159 auerswald_int_free (cp);
diff --git a/drivers/usb/misc/emi26.c b/drivers/usb/misc/emi26.c
index 1fd9cb85f4ca..5c0a26cbd128 100644
--- a/drivers/usb/misc/emi26.c
+++ b/drivers/usb/misc/emi26.c
@@ -53,13 +53,12 @@ static void __exit emi26_exit (void);
53static int emi26_writememory (struct usb_device *dev, int address, unsigned char *data, int length, __u8 request) 53static int emi26_writememory (struct usb_device *dev, int address, unsigned char *data, int length, __u8 request)
54{ 54{
55 int result; 55 int result;
56 unsigned char *buffer = kmalloc (length, GFP_KERNEL); 56 unsigned char *buffer = kmemdup(data, length, GFP_KERNEL);
57 57
58 if (!buffer) { 58 if (!buffer) {
59 err("emi26: kmalloc(%d) failed.", length); 59 err("emi26: kmalloc(%d) failed.", length);
60 return -ENOMEM; 60 return -ENOMEM;
61 } 61 }
62 memcpy (buffer, data, length);
63 /* Note: usb_control_msg returns negative value on error or length of the 62 /* Note: usb_control_msg returns negative value on error or length of the
64 * data that was written! */ 63 * data that was written! */
65 result = usb_control_msg (dev, usb_sndctrlpipe(dev, 0), request, 0x40, address, 0, buffer, length, 300); 64 result = usb_control_msg (dev, usb_sndctrlpipe(dev, 0), request, 0x40, address, 0, buffer, length, 300);
diff --git a/drivers/usb/misc/emi62.c b/drivers/usb/misc/emi62.c
index fe351371f274..23153eac0dfa 100644
--- a/drivers/usb/misc/emi62.c
+++ b/drivers/usb/misc/emi62.c
@@ -61,13 +61,12 @@ static void __exit emi62_exit (void);
61static int emi62_writememory (struct usb_device *dev, int address, unsigned char *data, int length, __u8 request) 61static int emi62_writememory (struct usb_device *dev, int address, unsigned char *data, int length, __u8 request)
62{ 62{
63 int result; 63 int result;
64 unsigned char *buffer = kmalloc (length, GFP_KERNEL); 64 unsigned char *buffer = kmemdup(data, length, GFP_KERNEL);
65 65
66 if (!buffer) { 66 if (!buffer) {
67 err("emi62: kmalloc(%d) failed.", length); 67 err("emi62: kmalloc(%d) failed.", length);
68 return -ENOMEM; 68 return -ENOMEM;
69 } 69 }
70 memcpy (buffer, data, length);
71 /* Note: usb_control_msg returns negative value on error or length of the 70 /* Note: usb_control_msg returns negative value on error or length of the
72 * data that was written! */ 71 * data that was written! */
73 result = usb_control_msg (dev, usb_sndctrlpipe(dev, 0), request, 0x40, address, 0, buffer, length, 300); 72 result = usb_control_msg (dev, usb_sndctrlpipe(dev, 0), request, 0x40, address, 0, buffer, length, 300);
diff --git a/drivers/usb/misc/ftdi-elan.c b/drivers/usb/misc/ftdi-elan.c
index 9b591b8b9369..18b1925032a8 100644
--- a/drivers/usb/misc/ftdi-elan.c
+++ b/drivers/usb/misc/ftdi-elan.c
@@ -156,9 +156,9 @@ struct usb_ftdi {
156 struct usb_device *udev; 156 struct usb_device *udev;
157 struct usb_interface *interface; 157 struct usb_interface *interface;
158 struct usb_class_driver *class; 158 struct usb_class_driver *class;
159 struct work_struct status_work; 159 struct delayed_work status_work;
160 struct work_struct command_work; 160 struct delayed_work command_work;
161 struct work_struct respond_work; 161 struct delayed_work respond_work;
162 struct u132_platform_data platform_data; 162 struct u132_platform_data platform_data;
163 struct resource resources[0]; 163 struct resource resources[0];
164 struct platform_device platform_dev; 164 struct platform_device platform_dev;
@@ -210,23 +210,14 @@ static void ftdi_elan_init_kref(struct usb_ftdi *ftdi)
210 210
211static void ftdi_status_requeue_work(struct usb_ftdi *ftdi, unsigned int delta) 211static void ftdi_status_requeue_work(struct usb_ftdi *ftdi, unsigned int delta)
212{ 212{
213 if (delta > 0) { 213 if (!queue_delayed_work(status_queue, &ftdi->status_work, delta))
214 if (queue_delayed_work(status_queue, &ftdi->status_work, delta)) 214 kref_put(&ftdi->kref, ftdi_elan_delete);
215 return;
216 } else if (queue_work(status_queue, &ftdi->status_work))
217 return;
218 kref_put(&ftdi->kref, ftdi_elan_delete);
219 return;
220} 215}
221 216
222static void ftdi_status_queue_work(struct usb_ftdi *ftdi, unsigned int delta) 217static void ftdi_status_queue_work(struct usb_ftdi *ftdi, unsigned int delta)
223{ 218{
224 if (delta > 0) { 219 if (queue_delayed_work(status_queue, &ftdi->status_work, delta))
225 if (queue_delayed_work(status_queue, &ftdi->status_work, delta)) 220 kref_get(&ftdi->kref);
226 kref_get(&ftdi->kref);
227 } else if (queue_work(status_queue, &ftdi->status_work))
228 kref_get(&ftdi->kref);
229 return;
230} 221}
231 222
232static void ftdi_status_cancel_work(struct usb_ftdi *ftdi) 223static void ftdi_status_cancel_work(struct usb_ftdi *ftdi)
@@ -237,25 +228,14 @@ static void ftdi_status_cancel_work(struct usb_ftdi *ftdi)
237 228
238static void ftdi_command_requeue_work(struct usb_ftdi *ftdi, unsigned int delta) 229static void ftdi_command_requeue_work(struct usb_ftdi *ftdi, unsigned int delta)
239{ 230{
240 if (delta > 0) { 231 if (!queue_delayed_work(command_queue, &ftdi->command_work, delta))
241 if (queue_delayed_work(command_queue, &ftdi->command_work, 232 kref_put(&ftdi->kref, ftdi_elan_delete);
242 delta))
243 return;
244 } else if (queue_work(command_queue, &ftdi->command_work))
245 return;
246 kref_put(&ftdi->kref, ftdi_elan_delete);
247 return;
248} 233}
249 234
250static void ftdi_command_queue_work(struct usb_ftdi *ftdi, unsigned int delta) 235static void ftdi_command_queue_work(struct usb_ftdi *ftdi, unsigned int delta)
251{ 236{
252 if (delta > 0) { 237 if (queue_delayed_work(command_queue, &ftdi->command_work, delta))
253 if (queue_delayed_work(command_queue, &ftdi->command_work, 238 kref_get(&ftdi->kref);
254 delta))
255 kref_get(&ftdi->kref);
256 } else if (queue_work(command_queue, &ftdi->command_work))
257 kref_get(&ftdi->kref);
258 return;
259} 239}
260 240
261static void ftdi_command_cancel_work(struct usb_ftdi *ftdi) 241static void ftdi_command_cancel_work(struct usb_ftdi *ftdi)
@@ -267,25 +247,14 @@ static void ftdi_command_cancel_work(struct usb_ftdi *ftdi)
267static void ftdi_response_requeue_work(struct usb_ftdi *ftdi, 247static void ftdi_response_requeue_work(struct usb_ftdi *ftdi,
268 unsigned int delta) 248 unsigned int delta)
269{ 249{
270 if (delta > 0) { 250 if (!queue_delayed_work(respond_queue, &ftdi->respond_work, delta))
271 if (queue_delayed_work(respond_queue, &ftdi->respond_work, 251 kref_put(&ftdi->kref, ftdi_elan_delete);
272 delta))
273 return;
274 } else if (queue_work(respond_queue, &ftdi->respond_work))
275 return;
276 kref_put(&ftdi->kref, ftdi_elan_delete);
277 return;
278} 252}
279 253
280static void ftdi_respond_queue_work(struct usb_ftdi *ftdi, unsigned int delta) 254static void ftdi_respond_queue_work(struct usb_ftdi *ftdi, unsigned int delta)
281{ 255{
282 if (delta > 0) { 256 if (queue_delayed_work(respond_queue, &ftdi->respond_work, delta))
283 if (queue_delayed_work(respond_queue, &ftdi->respond_work, 257 kref_get(&ftdi->kref);
284 delta))
285 kref_get(&ftdi->kref);
286 } else if (queue_work(respond_queue, &ftdi->respond_work))
287 kref_get(&ftdi->kref);
288 return;
289} 258}
290 259
291static void ftdi_response_cancel_work(struct usb_ftdi *ftdi) 260static void ftdi_response_cancel_work(struct usb_ftdi *ftdi)
@@ -303,7 +272,7 @@ void ftdi_elan_gone_away(struct platform_device *pdev)
303 272
304 273
305EXPORT_SYMBOL_GPL(ftdi_elan_gone_away); 274EXPORT_SYMBOL_GPL(ftdi_elan_gone_away);
306void ftdi_release_platform_dev(struct device *dev) 275static void ftdi_release_platform_dev(struct device *dev)
307{ 276{
308 dev->parent = NULL; 277 dev->parent = NULL;
309} 278}
@@ -475,9 +444,11 @@ static void ftdi_elan_kick_command_queue(struct usb_ftdi *ftdi)
475 return; 444 return;
476} 445}
477 446
478static void ftdi_elan_command_work(void *data) 447static void ftdi_elan_command_work(struct work_struct *work)
479{ 448{
480 struct usb_ftdi *ftdi = data; 449 struct usb_ftdi *ftdi =
450 container_of(work, struct usb_ftdi, command_work.work);
451
481 if (ftdi->disconnected > 0) { 452 if (ftdi->disconnected > 0) {
482 ftdi_elan_put_kref(ftdi); 453 ftdi_elan_put_kref(ftdi);
483 return; 454 return;
@@ -500,9 +471,10 @@ static void ftdi_elan_kick_respond_queue(struct usb_ftdi *ftdi)
500 return; 471 return;
501} 472}
502 473
503static void ftdi_elan_respond_work(void *data) 474static void ftdi_elan_respond_work(struct work_struct *work)
504{ 475{
505 struct usb_ftdi *ftdi = data; 476 struct usb_ftdi *ftdi =
477 container_of(work, struct usb_ftdi, respond_work.work);
506 if (ftdi->disconnected > 0) { 478 if (ftdi->disconnected > 0) {
507 ftdi_elan_put_kref(ftdi); 479 ftdi_elan_put_kref(ftdi);
508 return; 480 return;
@@ -534,9 +506,10 @@ static void ftdi_elan_respond_work(void *data)
534* after the FTDI has been synchronized 506* after the FTDI has been synchronized
535* 507*
536*/ 508*/
537static void ftdi_elan_status_work(void *data) 509static void ftdi_elan_status_work(struct work_struct *work)
538{ 510{
539 struct usb_ftdi *ftdi = data; 511 struct usb_ftdi *ftdi =
512 container_of(work, struct usb_ftdi, status_work.work);
540 int work_delay_in_msec = 0; 513 int work_delay_in_msec = 0;
541 if (ftdi->disconnected > 0) { 514 if (ftdi->disconnected > 0) {
542 ftdi_elan_put_kref(ftdi); 515 ftdi_elan_put_kref(ftdi);
@@ -1426,14 +1399,6 @@ static int ftdi_elan_read_reg(struct usb_ftdi *ftdi, u32 *data)
1426 } 1399 }
1427} 1400}
1428 1401
1429int usb_ftdi_elan_read_reg(struct platform_device *pdev, u32 *data)
1430{
1431 struct usb_ftdi *ftdi = platform_device_to_usb_ftdi(pdev);
1432 return ftdi_elan_read_reg(ftdi, data);
1433}
1434
1435
1436EXPORT_SYMBOL_GPL(usb_ftdi_elan_read_reg);
1437static int ftdi_elan_read_config(struct usb_ftdi *ftdi, int config_offset, 1402static int ftdi_elan_read_config(struct usb_ftdi *ftdi, int config_offset,
1438 u8 width, u32 *data) 1403 u8 width, u32 *data)
1439{ 1404{
@@ -2633,10 +2598,7 @@ static int ftdi_elan_probe(struct usb_interface *interface,
2633 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { 2598 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
2634 endpoint = &iface_desc->endpoint[i].desc; 2599 endpoint = &iface_desc->endpoint[i].desc;
2635 if (!ftdi->bulk_in_endpointAddr && 2600 if (!ftdi->bulk_in_endpointAddr &&
2636 ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) 2601 usb_endpoint_is_bulk_in(endpoint)) {
2637 == USB_DIR_IN) && ((endpoint->bmAttributes &
2638 USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK))
2639 {
2640 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); 2602 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
2641 ftdi->bulk_in_size = buffer_size; 2603 ftdi->bulk_in_size = buffer_size;
2642 ftdi->bulk_in_endpointAddr = endpoint->bEndpointAddress; 2604 ftdi->bulk_in_endpointAddr = endpoint->bEndpointAddress;
@@ -2649,10 +2611,7 @@ static int ftdi_elan_probe(struct usb_interface *interface,
2649 } 2611 }
2650 } 2612 }
2651 if (!ftdi->bulk_out_endpointAddr && 2613 if (!ftdi->bulk_out_endpointAddr &&
2652 ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) 2614 usb_endpoint_is_bulk_out(endpoint)) {
2653 == USB_DIR_OUT) && ((endpoint->bmAttributes &
2654 USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK))
2655 {
2656 ftdi->bulk_out_endpointAddr = 2615 ftdi->bulk_out_endpointAddr =
2657 endpoint->bEndpointAddress; 2616 endpoint->bEndpointAddress;
2658 } 2617 }
@@ -2691,12 +2650,9 @@ static int ftdi_elan_probe(struct usb_interface *interface,
2691 ftdi->class = NULL; 2650 ftdi->class = NULL;
2692 dev_info(&ftdi->udev->dev, "USB FDTI=%p ELAN interface %d now a" 2651 dev_info(&ftdi->udev->dev, "USB FDTI=%p ELAN interface %d now a"
2693 "ctivated\n", ftdi, iface_desc->desc.bInterfaceNumber); 2652 "ctivated\n", ftdi, iface_desc->desc.bInterfaceNumber);
2694 INIT_WORK(&ftdi->status_work, ftdi_elan_status_work, 2653 INIT_DELAYED_WORK(&ftdi->status_work, ftdi_elan_status_work);
2695 (void *)ftdi); 2654 INIT_DELAYED_WORK(&ftdi->command_work, ftdi_elan_command_work);
2696 INIT_WORK(&ftdi->command_work, ftdi_elan_command_work, 2655 INIT_DELAYED_WORK(&ftdi->respond_work, ftdi_elan_respond_work);
2697 (void *)ftdi);
2698 INIT_WORK(&ftdi->respond_work, ftdi_elan_respond_work,
2699 (void *)ftdi);
2700 ftdi_status_queue_work(ftdi, msecs_to_jiffies(3 *1000)); 2656 ftdi_status_queue_work(ftdi, msecs_to_jiffies(3 *1000));
2701 return 0; 2657 return 0;
2702 } else { 2658 } else {
diff --git a/drivers/usb/misc/idmouse.c b/drivers/usb/misc/idmouse.c
index 8e6e195a22ba..c9418535bef8 100644
--- a/drivers/usb/misc/idmouse.c
+++ b/drivers/usb/misc/idmouse.c
@@ -125,12 +125,12 @@ static DEFINE_MUTEX(disconnect_mutex);
125 125
126static int idmouse_create_image(struct usb_idmouse *dev) 126static int idmouse_create_image(struct usb_idmouse *dev)
127{ 127{
128 int bytes_read = 0; 128 int bytes_read;
129 int bulk_read = 0; 129 int bulk_read;
130 int result = 0; 130 int result;
131 131
132 memcpy(dev->bulk_in_buffer, HEADER, sizeof(HEADER)-1); 132 memcpy(dev->bulk_in_buffer, HEADER, sizeof(HEADER)-1);
133 bytes_read += sizeof(HEADER)-1; 133 bytes_read = sizeof(HEADER)-1;
134 134
135 /* reset the device and set a fast blink rate */ 135 /* reset the device and set a fast blink rate */
136 result = ftip_command(dev, FTIP_RELEASE, 0, 0); 136 result = ftip_command(dev, FTIP_RELEASE, 0, 0);
@@ -208,9 +208,9 @@ static inline void idmouse_delete(struct usb_idmouse *dev)
208 208
209static int idmouse_open(struct inode *inode, struct file *file) 209static int idmouse_open(struct inode *inode, struct file *file)
210{ 210{
211 struct usb_idmouse *dev = NULL; 211 struct usb_idmouse *dev;
212 struct usb_interface *interface; 212 struct usb_interface *interface;
213 int result = 0; 213 int result;
214 214
215 /* prevent disconnects */ 215 /* prevent disconnects */
216 mutex_lock(&disconnect_mutex); 216 mutex_lock(&disconnect_mutex);
@@ -305,7 +305,7 @@ static ssize_t idmouse_read(struct file *file, char __user *buffer, size_t count
305 loff_t * ppos) 305 loff_t * ppos)
306{ 306{
307 struct usb_idmouse *dev; 307 struct usb_idmouse *dev;
308 int result = 0; 308 int result;
309 309
310 dev = (struct usb_idmouse *) file->private_data; 310 dev = (struct usb_idmouse *) file->private_data;
311 311
@@ -329,7 +329,7 @@ static int idmouse_probe(struct usb_interface *interface,
329 const struct usb_device_id *id) 329 const struct usb_device_id *id)
330{ 330{
331 struct usb_device *udev = interface_to_usbdev(interface); 331 struct usb_device *udev = interface_to_usbdev(interface);
332 struct usb_idmouse *dev = NULL; 332 struct usb_idmouse *dev;
333 struct usb_host_interface *iface_desc; 333 struct usb_host_interface *iface_desc;
334 struct usb_endpoint_descriptor *endpoint; 334 struct usb_endpoint_descriptor *endpoint;
335 int result; 335 int result;
@@ -350,11 +350,7 @@ static int idmouse_probe(struct usb_interface *interface,
350 350
351 /* set up the endpoint information - use only the first bulk-in endpoint */ 351 /* set up the endpoint information - use only the first bulk-in endpoint */
352 endpoint = &iface_desc->endpoint[0].desc; 352 endpoint = &iface_desc->endpoint[0].desc;
353 if (!dev->bulk_in_endpointAddr 353 if (!dev->bulk_in_endpointAddr && usb_endpoint_is_bulk_in(endpoint)) {
354 && (endpoint->bEndpointAddress & USB_DIR_IN)
355 && ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
356 USB_ENDPOINT_XFER_BULK)) {
357
358 /* we found a bulk in endpoint */ 354 /* we found a bulk in endpoint */
359 dev->orig_bi_size = le16_to_cpu(endpoint->wMaxPacketSize); 355 dev->orig_bi_size = le16_to_cpu(endpoint->wMaxPacketSize);
360 dev->bulk_in_size = 0x200; /* works _much_ faster */ 356 dev->bulk_in_size = 0x200; /* works _much_ faster */
diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c
index 27089497e717..5dce797bddb7 100644
--- a/drivers/usb/misc/legousbtower.c
+++ b/drivers/usb/misc/legousbtower.c
@@ -317,12 +317,8 @@ static inline void tower_delete (struct lego_usb_tower *dev)
317 tower_abort_transfers (dev); 317 tower_abort_transfers (dev);
318 318
319 /* free data structures */ 319 /* free data structures */
320 if (dev->interrupt_in_urb != NULL) { 320 usb_free_urb(dev->interrupt_in_urb);
321 usb_free_urb (dev->interrupt_in_urb); 321 usb_free_urb(dev->interrupt_out_urb);
322 }
323 if (dev->interrupt_out_urb != NULL) {
324 usb_free_urb (dev->interrupt_out_urb);
325 }
326 kfree (dev->read_buffer); 322 kfree (dev->read_buffer);
327 kfree (dev->interrupt_in_buffer); 323 kfree (dev->interrupt_in_buffer);
328 kfree (dev->interrupt_out_buffer); 324 kfree (dev->interrupt_out_buffer);
@@ -502,15 +498,11 @@ static void tower_abort_transfers (struct lego_usb_tower *dev)
502 if (dev->interrupt_in_running) { 498 if (dev->interrupt_in_running) {
503 dev->interrupt_in_running = 0; 499 dev->interrupt_in_running = 0;
504 mb(); 500 mb();
505 if (dev->interrupt_in_urb != NULL && dev->udev) { 501 if (dev->udev)
506 usb_kill_urb (dev->interrupt_in_urb); 502 usb_kill_urb (dev->interrupt_in_urb);
507 }
508 }
509 if (dev->interrupt_out_busy) {
510 if (dev->interrupt_out_urb != NULL && dev->udev) {
511 usb_kill_urb (dev->interrupt_out_urb);
512 }
513 } 503 }
504 if (dev->interrupt_out_busy && dev->udev)
505 usb_kill_urb(dev->interrupt_out_urb);
514 506
515exit: 507exit:
516 dbg(2, "%s: leave", __FUNCTION__); 508 dbg(2, "%s: leave", __FUNCTION__);
@@ -898,14 +890,11 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device
898 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { 890 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
899 endpoint = &iface_desc->endpoint[i].desc; 891 endpoint = &iface_desc->endpoint[i].desc;
900 892
901 if (((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN) && 893 if (usb_endpoint_xfer_int(endpoint)) {
902 ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT)) { 894 if (usb_endpoint_dir_in(endpoint))
903 dev->interrupt_in_endpoint = endpoint; 895 dev->interrupt_in_endpoint = endpoint;
904 } 896 else
905 897 dev->interrupt_out_endpoint = endpoint;
906 if (((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT) &&
907 ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT)) {
908 dev->interrupt_out_endpoint = endpoint;
909 } 898 }
910 } 899 }
911 if(dev->interrupt_in_endpoint == NULL) { 900 if(dev->interrupt_in_endpoint == NULL) {
diff --git a/drivers/usb/misc/phidgetkit.c b/drivers/usb/misc/phidgetkit.c
index abb4dcd811ac..371bf2b1197d 100644
--- a/drivers/usb/misc/phidgetkit.c
+++ b/drivers/usb/misc/phidgetkit.c
@@ -81,8 +81,8 @@ struct interfacekit {
81 unsigned char *data; 81 unsigned char *data;
82 dma_addr_t data_dma; 82 dma_addr_t data_dma;
83 83
84 struct work_struct do_notify; 84 struct delayed_work do_notify;
85 struct work_struct do_resubmit; 85 struct delayed_work do_resubmit;
86 unsigned long input_events; 86 unsigned long input_events;
87 unsigned long sensor_events; 87 unsigned long sensor_events;
88}; 88};
@@ -374,19 +374,20 @@ static void interfacekit_irq(struct urb *urb)
374 } 374 }
375 375
376 if (kit->input_events || kit->sensor_events) 376 if (kit->input_events || kit->sensor_events)
377 schedule_work(&kit->do_notify); 377 schedule_delayed_work(&kit->do_notify, 0);
378 378
379resubmit: 379resubmit:
380 status = usb_submit_urb(urb, SLAB_ATOMIC); 380 status = usb_submit_urb(urb, GFP_ATOMIC);
381 if (status) 381 if (status)
382 err("can't resubmit intr, %s-%s/interfacekit0, status %d", 382 err("can't resubmit intr, %s-%s/interfacekit0, status %d",
383 kit->udev->bus->bus_name, 383 kit->udev->bus->bus_name,
384 kit->udev->devpath, status); 384 kit->udev->devpath, status);
385} 385}
386 386
387static void do_notify(void *data) 387static void do_notify(struct work_struct *work)
388{ 388{
389 struct interfacekit *kit = data; 389 struct interfacekit *kit =
390 container_of(work, struct interfacekit, do_notify.work);
390 int i; 391 int i;
391 char sysfs_file[8]; 392 char sysfs_file[8];
392 393
@@ -405,9 +406,11 @@ static void do_notify(void *data)
405 } 406 }
406} 407}
407 408
408static void do_resubmit(void *data) 409static void do_resubmit(struct work_struct *work)
409{ 410{
410 set_outputs(data); 411 struct interfacekit *kit =
412 container_of(work, struct interfacekit, do_resubmit.work);
413 set_outputs(kit);
411} 414}
412 415
413#define show_set_output(value) \ 416#define show_set_output(value) \
@@ -551,7 +554,7 @@ static int interfacekit_probe(struct usb_interface *intf, const struct usb_devic
551 return -ENODEV; 554 return -ENODEV;
552 555
553 endpoint = &interface->endpoint[0].desc; 556 endpoint = &interface->endpoint[0].desc;
554 if (!(endpoint->bEndpointAddress & 0x80)) 557 if (!usb_endpoint_dir_in(endpoint))
555 return -ENODEV; 558 return -ENODEV;
556 /* 559 /*
557 * bmAttributes 560 * bmAttributes
@@ -565,7 +568,7 @@ static int interfacekit_probe(struct usb_interface *intf, const struct usb_devic
565 568
566 kit->dev_no = -1; 569 kit->dev_no = -1;
567 kit->ifkit = ifkit; 570 kit->ifkit = ifkit;
568 kit->data = usb_buffer_alloc(dev, URB_INT_SIZE, SLAB_ATOMIC, &kit->data_dma); 571 kit->data = usb_buffer_alloc(dev, URB_INT_SIZE, GFP_ATOMIC, &kit->data_dma);
569 if (!kit->data) 572 if (!kit->data)
570 goto out; 573 goto out;
571 574
@@ -575,8 +578,8 @@ static int interfacekit_probe(struct usb_interface *intf, const struct usb_devic
575 578
576 kit->udev = usb_get_dev(dev); 579 kit->udev = usb_get_dev(dev);
577 kit->intf = intf; 580 kit->intf = intf;
578 INIT_WORK(&kit->do_notify, do_notify, kit); 581 INIT_DELAYED_WORK(&kit->do_notify, do_notify);
579 INIT_WORK(&kit->do_resubmit, do_resubmit, kit); 582 INIT_DELAYED_WORK(&kit->do_resubmit, do_resubmit);
580 usb_fill_int_urb(kit->irq, kit->udev, pipe, kit->data, 583 usb_fill_int_urb(kit->irq, kit->udev, pipe, kit->data,
581 maxp > URB_INT_SIZE ? URB_INT_SIZE : maxp, 584 maxp > URB_INT_SIZE ? URB_INT_SIZE : maxp,
582 interfacekit_irq, kit, endpoint->bInterval); 585 interfacekit_irq, kit, endpoint->bInterval);
@@ -650,8 +653,7 @@ out2:
650 device_remove_file(kit->dev, &dev_output_attrs[i]); 653 device_remove_file(kit->dev, &dev_output_attrs[i]);
651out: 654out:
652 if (kit) { 655 if (kit) {
653 if (kit->irq) 656 usb_free_urb(kit->irq);
654 usb_free_urb(kit->irq);
655 if (kit->data) 657 if (kit->data)
656 usb_buffer_free(dev, URB_INT_SIZE, kit->data, kit->data_dma); 658 usb_buffer_free(dev, URB_INT_SIZE, kit->data, kit->data_dma);
657 if (kit->dev) 659 if (kit->dev)
diff --git a/drivers/usb/misc/phidgetmotorcontrol.c b/drivers/usb/misc/phidgetmotorcontrol.c
index 5c780cab92e0..5727e1ea2f91 100644
--- a/drivers/usb/misc/phidgetmotorcontrol.c
+++ b/drivers/usb/misc/phidgetmotorcontrol.c
@@ -41,7 +41,7 @@ struct motorcontrol {
41 unsigned char *data; 41 unsigned char *data;
42 dma_addr_t data_dma; 42 dma_addr_t data_dma;
43 43
44 struct work_struct do_notify; 44 struct delayed_work do_notify;
45 unsigned long input_events; 45 unsigned long input_events;
46 unsigned long speed_events; 46 unsigned long speed_events;
47 unsigned long exceed_events; 47 unsigned long exceed_events;
@@ -148,10 +148,10 @@ static void motorcontrol_irq(struct urb *urb)
148 set_bit(1, &mc->exceed_events); 148 set_bit(1, &mc->exceed_events);
149 149
150 if (mc->input_events || mc->exceed_events || mc->speed_events) 150 if (mc->input_events || mc->exceed_events || mc->speed_events)
151 schedule_work(&mc->do_notify); 151 schedule_delayed_work(&mc->do_notify, 0);
152 152
153resubmit: 153resubmit:
154 status = usb_submit_urb(urb, SLAB_ATOMIC); 154 status = usb_submit_urb(urb, GFP_ATOMIC);
155 if (status) 155 if (status)
156 dev_err(&mc->intf->dev, 156 dev_err(&mc->intf->dev,
157 "can't resubmit intr, %s-%s/motorcontrol0, status %d", 157 "can't resubmit intr, %s-%s/motorcontrol0, status %d",
@@ -159,9 +159,10 @@ resubmit:
159 mc->udev->devpath, status); 159 mc->udev->devpath, status);
160} 160}
161 161
162static void do_notify(void *data) 162static void do_notify(struct work_struct *work)
163{ 163{
164 struct motorcontrol *mc = data; 164 struct motorcontrol *mc =
165 container_of(work, struct motorcontrol, do_notify.work);
165 int i; 166 int i;
166 char sysfs_file[8]; 167 char sysfs_file[8];
167 168
@@ -323,7 +324,7 @@ static int motorcontrol_probe(struct usb_interface *intf, const struct usb_devic
323 return -ENODEV; 324 return -ENODEV;
324 325
325 endpoint = &interface->endpoint[0].desc; 326 endpoint = &interface->endpoint[0].desc;
326 if (!(endpoint->bEndpointAddress & 0x80)) 327 if (!usb_endpoint_dir_in(endpoint))
327 return -ENODEV; 328 return -ENODEV;
328 329
329 /* 330 /*
@@ -337,7 +338,7 @@ static int motorcontrol_probe(struct usb_interface *intf, const struct usb_devic
337 goto out; 338 goto out;
338 339
339 mc->dev_no = -1; 340 mc->dev_no = -1;
340 mc->data = usb_buffer_alloc(dev, URB_INT_SIZE, SLAB_ATOMIC, &mc->data_dma); 341 mc->data = usb_buffer_alloc(dev, URB_INT_SIZE, GFP_ATOMIC, &mc->data_dma);
341 if (!mc->data) 342 if (!mc->data)
342 goto out; 343 goto out;
343 344
@@ -348,7 +349,7 @@ static int motorcontrol_probe(struct usb_interface *intf, const struct usb_devic
348 mc->udev = usb_get_dev(dev); 349 mc->udev = usb_get_dev(dev);
349 mc->intf = intf; 350 mc->intf = intf;
350 mc->acceleration[0] = mc->acceleration[1] = 10; 351 mc->acceleration[0] = mc->acceleration[1] = 10;
351 INIT_WORK(&mc->do_notify, do_notify, mc); 352 INIT_DELAYED_WORK(&mc->do_notify, do_notify);
352 usb_fill_int_urb(mc->irq, mc->udev, pipe, mc->data, 353 usb_fill_int_urb(mc->irq, mc->udev, pipe, mc->data,
353 maxp > URB_INT_SIZE ? URB_INT_SIZE : maxp, 354 maxp > URB_INT_SIZE ? URB_INT_SIZE : maxp,
354 motorcontrol_irq, mc, endpoint->bInterval); 355 motorcontrol_irq, mc, endpoint->bInterval);
@@ -392,8 +393,7 @@ out2:
392 device_remove_file(mc->dev, &dev_attrs[i]); 393 device_remove_file(mc->dev, &dev_attrs[i]);
393out: 394out:
394 if (mc) { 395 if (mc) {
395 if (mc->irq) 396 usb_free_urb(mc->irq);
396 usb_free_urb(mc->irq);
397 if (mc->data) 397 if (mc->data)
398 usb_buffer_free(dev, URB_INT_SIZE, mc->data, mc->data_dma); 398 usb_buffer_free(dev, URB_INT_SIZE, mc->data, mc->data_dma);
399 if (mc->dev) 399 if (mc->dev)
diff --git a/drivers/usb/misc/usb_u132.h b/drivers/usb/misc/usb_u132.h
index 551ba8906d62..dc2e5a31caec 100644
--- a/drivers/usb/misc/usb_u132.h
+++ b/drivers/usb/misc/usb_u132.h
@@ -52,7 +52,7 @@
52* the kernel to load the "u132-hcd" module. 52* the kernel to load the "u132-hcd" module.
53* 53*
54* The "ftdi-u132" module provides the interface to the inserted 54* The "ftdi-u132" module provides the interface to the inserted
55* PC card and the "u132-hcd" module uses the API to send and recieve 55* PC card and the "u132-hcd" module uses the API to send and receive
56* data. The API features call-backs, so that part of the "u132-hcd" 56* data. The API features call-backs, so that part of the "u132-hcd"
57* module code will run in the context of one of the kernel threads 57* module code will run in the context of one of the kernel threads
58* of the "ftdi-u132" module. 58* of the "ftdi-u132" module.
@@ -95,3 +95,7 @@ int usb_ftdi_elan_edset_setup(struct platform_device *pdev, u8 ed_number,
95 int halted, int skipped, int actual, int non_null)); 95 int halted, int skipped, int actual, int non_null));
96int usb_ftdi_elan_edset_flush(struct platform_device *pdev, u8 ed_number, 96int usb_ftdi_elan_edset_flush(struct platform_device *pdev, u8 ed_number,
97 void *endp); 97 void *endp);
98int usb_ftdi_elan_read_pcimem(struct platform_device *pdev, int mem_offset,
99 u8 width, u32 *data);
100int usb_ftdi_elan_write_pcimem(struct platform_device *pdev, int mem_offset,
101 u8 width, u32 data);
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index 7c2cbdf81d20..fb321864a92d 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -138,7 +138,7 @@ get_endpoints (struct usbtest_dev *dev, struct usb_interface *intf)
138 default: 138 default:
139 continue; 139 continue;
140 } 140 }
141 if (e->desc.bEndpointAddress & USB_DIR_IN) { 141 if (usb_endpoint_dir_in(&e->desc)) {
142 if (!in) 142 if (!in)
143 in = e; 143 in = e;
144 } else { 144 } else {
@@ -147,7 +147,7 @@ get_endpoints (struct usbtest_dev *dev, struct usb_interface *intf)
147 } 147 }
148 continue; 148 continue;
149try_iso: 149try_iso:
150 if (e->desc.bEndpointAddress & USB_DIR_IN) { 150 if (usb_endpoint_dir_in(&e->desc)) {
151 if (!iso_in) 151 if (!iso_in)
152 iso_in = e; 152 iso_in = e;
153 } else { 153 } else {
@@ -213,7 +213,7 @@ static struct urb *simple_alloc_urb (
213 213
214 if (bytes < 0) 214 if (bytes < 0)
215 return NULL; 215 return NULL;
216 urb = usb_alloc_urb (0, SLAB_KERNEL); 216 urb = usb_alloc_urb (0, GFP_KERNEL);
217 if (!urb) 217 if (!urb)
218 return urb; 218 return urb;
219 usb_fill_bulk_urb (urb, udev, pipe, NULL, bytes, simple_callback, NULL); 219 usb_fill_bulk_urb (urb, udev, pipe, NULL, bytes, simple_callback, NULL);
@@ -223,7 +223,7 @@ static struct urb *simple_alloc_urb (
223 urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP; 223 urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP;
224 if (usb_pipein (pipe)) 224 if (usb_pipein (pipe))
225 urb->transfer_flags |= URB_SHORT_NOT_OK; 225 urb->transfer_flags |= URB_SHORT_NOT_OK;
226 urb->transfer_buffer = usb_buffer_alloc (udev, bytes, SLAB_KERNEL, 226 urb->transfer_buffer = usb_buffer_alloc (udev, bytes, GFP_KERNEL,
227 &urb->transfer_dma); 227 &urb->transfer_dma);
228 if (!urb->transfer_buffer) { 228 if (!urb->transfer_buffer) {
229 usb_free_urb (urb); 229 usb_free_urb (urb);
@@ -315,7 +315,7 @@ static int simple_io (
315 init_completion (&completion); 315 init_completion (&completion);
316 if (usb_pipeout (urb->pipe)) 316 if (usb_pipeout (urb->pipe))
317 simple_fill_buf (urb); 317 simple_fill_buf (urb);
318 if ((retval = usb_submit_urb (urb, SLAB_KERNEL)) != 0) 318 if ((retval = usb_submit_urb (urb, GFP_KERNEL)) != 0)
319 break; 319 break;
320 320
321 /* NOTE: no timeouts; can't be broken out of by interrupt */ 321 /* NOTE: no timeouts; can't be broken out of by interrupt */
@@ -374,7 +374,7 @@ alloc_sglist (int nents, int max, int vary)
374 unsigned i; 374 unsigned i;
375 unsigned size = max; 375 unsigned size = max;
376 376
377 sg = kmalloc (nents * sizeof *sg, SLAB_KERNEL); 377 sg = kmalloc (nents * sizeof *sg, GFP_KERNEL);
378 if (!sg) 378 if (!sg)
379 return NULL; 379 return NULL;
380 380
@@ -382,7 +382,7 @@ alloc_sglist (int nents, int max, int vary)
382 char *buf; 382 char *buf;
383 unsigned j; 383 unsigned j;
384 384
385 buf = kzalloc (size, SLAB_KERNEL); 385 buf = kzalloc (size, GFP_KERNEL);
386 if (!buf) { 386 if (!buf) {
387 free_sglist (sg, i); 387 free_sglist (sg, i);
388 return NULL; 388 return NULL;
@@ -428,7 +428,7 @@ static int perform_sglist (
428 (udev->speed == USB_SPEED_HIGH) 428 (udev->speed == USB_SPEED_HIGH)
429 ? (INTERRUPT_RATE << 3) 429 ? (INTERRUPT_RATE << 3)
430 : INTERRUPT_RATE, 430 : INTERRUPT_RATE,
431 sg, nents, 0, SLAB_KERNEL); 431 sg, nents, 0, GFP_KERNEL);
432 432
433 if (retval) 433 if (retval)
434 break; 434 break;
@@ -819,7 +819,7 @@ error:
819 819
820 /* resubmit if we need to, else mark this as done */ 820 /* resubmit if we need to, else mark this as done */
821 if ((status == 0) && (ctx->pending < ctx->count)) { 821 if ((status == 0) && (ctx->pending < ctx->count)) {
822 if ((status = usb_submit_urb (urb, SLAB_ATOMIC)) != 0) { 822 if ((status = usb_submit_urb (urb, GFP_ATOMIC)) != 0) {
823 dbg ("can't resubmit ctrl %02x.%02x, err %d", 823 dbg ("can't resubmit ctrl %02x.%02x, err %d",
824 reqp->bRequestType, reqp->bRequest, status); 824 reqp->bRequestType, reqp->bRequest, status);
825 urb->dev = NULL; 825 urb->dev = NULL;
@@ -855,7 +855,7 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param)
855 * as with bulk/intr sglists, sglen is the queue depth; it also 855 * as with bulk/intr sglists, sglen is the queue depth; it also
856 * controls which subtests run (more tests than sglen) or rerun. 856 * controls which subtests run (more tests than sglen) or rerun.
857 */ 857 */
858 urb = kcalloc(param->sglen, sizeof(struct urb *), SLAB_KERNEL); 858 urb = kcalloc(param->sglen, sizeof(struct urb *), GFP_KERNEL);
859 if (!urb) 859 if (!urb)
860 return -ENOMEM; 860 return -ENOMEM;
861 for (i = 0; i < param->sglen; i++) { 861 for (i = 0; i < param->sglen; i++) {
@@ -981,7 +981,7 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param)
981 if (!u) 981 if (!u)
982 goto cleanup; 982 goto cleanup;
983 983
984 reqp = usb_buffer_alloc (udev, sizeof *reqp, SLAB_KERNEL, 984 reqp = usb_buffer_alloc (udev, sizeof *reqp, GFP_KERNEL,
985 &u->setup_dma); 985 &u->setup_dma);
986 if (!reqp) 986 if (!reqp)
987 goto cleanup; 987 goto cleanup;
@@ -999,7 +999,7 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param)
999 context.urb = urb; 999 context.urb = urb;
1000 spin_lock_irq (&context.lock); 1000 spin_lock_irq (&context.lock);
1001 for (i = 0; i < param->sglen; i++) { 1001 for (i = 0; i < param->sglen; i++) {
1002 context.status = usb_submit_urb (urb [i], SLAB_ATOMIC); 1002 context.status = usb_submit_urb (urb [i], GFP_ATOMIC);
1003 if (context.status != 0) { 1003 if (context.status != 0) {
1004 dbg ("can't submit urb[%d], status %d", 1004 dbg ("can't submit urb[%d], status %d",
1005 i, context.status); 1005 i, context.status);
@@ -1041,7 +1041,7 @@ static void unlink1_callback (struct urb *urb)
1041 1041
1042 // we "know" -EPIPE (stall) never happens 1042 // we "know" -EPIPE (stall) never happens
1043 if (!status) 1043 if (!status)
1044 status = usb_submit_urb (urb, SLAB_ATOMIC); 1044 status = usb_submit_urb (urb, GFP_ATOMIC);
1045 if (status) { 1045 if (status) {
1046 urb->status = status; 1046 urb->status = status;
1047 complete ((struct completion *) urb->context); 1047 complete ((struct completion *) urb->context);
@@ -1067,7 +1067,7 @@ static int unlink1 (struct usbtest_dev *dev, int pipe, int size, int async)
1067 * FIXME want additional tests for when endpoint is STALLing 1067 * FIXME want additional tests for when endpoint is STALLing
1068 * due to errors, or is just NAKing requests. 1068 * due to errors, or is just NAKing requests.
1069 */ 1069 */
1070 if ((retval = usb_submit_urb (urb, SLAB_KERNEL)) != 0) { 1070 if ((retval = usb_submit_urb (urb, GFP_KERNEL)) != 0) {
1071 dev_dbg (&dev->intf->dev, "submit fail %d\n", retval); 1071 dev_dbg (&dev->intf->dev, "submit fail %d\n", retval);
1072 return retval; 1072 return retval;
1073 } 1073 }
@@ -1251,7 +1251,7 @@ static int ctrl_out (struct usbtest_dev *dev,
1251 if (length < 1 || length > 0xffff || vary >= length) 1251 if (length < 1 || length > 0xffff || vary >= length)
1252 return -EINVAL; 1252 return -EINVAL;
1253 1253
1254 buf = kmalloc(length, SLAB_KERNEL); 1254 buf = kmalloc(length, GFP_KERNEL);
1255 if (!buf) 1255 if (!buf)
1256 return -ENOMEM; 1256 return -ENOMEM;
1257 1257
@@ -1403,7 +1403,7 @@ static struct urb *iso_alloc_urb (
1403 maxp *= 1 + (0x3 & (le16_to_cpu(desc->wMaxPacketSize) >> 11)); 1403 maxp *= 1 + (0x3 & (le16_to_cpu(desc->wMaxPacketSize) >> 11));
1404 packets = (bytes + maxp - 1) / maxp; 1404 packets = (bytes + maxp - 1) / maxp;
1405 1405
1406 urb = usb_alloc_urb (packets, SLAB_KERNEL); 1406 urb = usb_alloc_urb (packets, GFP_KERNEL);
1407 if (!urb) 1407 if (!urb)
1408 return urb; 1408 return urb;
1409 urb->dev = udev; 1409 urb->dev = udev;
@@ -1411,7 +1411,7 @@ static struct urb *iso_alloc_urb (
1411 1411
1412 urb->number_of_packets = packets; 1412 urb->number_of_packets = packets;
1413 urb->transfer_buffer_length = bytes; 1413 urb->transfer_buffer_length = bytes;
1414 urb->transfer_buffer = usb_buffer_alloc (udev, bytes, SLAB_KERNEL, 1414 urb->transfer_buffer = usb_buffer_alloc (udev, bytes, GFP_KERNEL,
1415 &urb->transfer_dma); 1415 &urb->transfer_dma);
1416 if (!urb->transfer_buffer) { 1416 if (!urb->transfer_buffer) {
1417 usb_free_urb (urb); 1417 usb_free_urb (urb);
@@ -1481,7 +1481,7 @@ test_iso_queue (struct usbtest_dev *dev, struct usbtest_param *param,
1481 spin_lock_irq (&context.lock); 1481 spin_lock_irq (&context.lock);
1482 for (i = 0; i < param->sglen; i++) { 1482 for (i = 0; i < param->sglen; i++) {
1483 ++context.pending; 1483 ++context.pending;
1484 status = usb_submit_urb (urbs [i], SLAB_ATOMIC); 1484 status = usb_submit_urb (urbs [i], GFP_ATOMIC);
1485 if (status < 0) { 1485 if (status < 0) {
1486 ERROR (dev, "submit iso[%d], error %d\n", i, status); 1486 ERROR (dev, "submit iso[%d], error %d\n", i, status);
1487 if (i == 0) { 1487 if (i == 0) {
@@ -1900,7 +1900,7 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id)
1900 } 1900 }
1901#endif 1901#endif
1902 1902
1903 dev = kzalloc(sizeof(*dev), SLAB_KERNEL); 1903 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
1904 if (!dev) 1904 if (!dev)
1905 return -ENOMEM; 1905 return -ENOMEM;
1906 info = (struct usbtest_info *) id->driver_info; 1906 info = (struct usbtest_info *) id->driver_info;
@@ -1910,7 +1910,7 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id)
1910 dev->intf = intf; 1910 dev->intf = intf;
1911 1911
1912 /* cacheline-aligned scratch for i/o */ 1912 /* cacheline-aligned scratch for i/o */
1913 if ((dev->buf = kmalloc (TBUF_SIZE, SLAB_KERNEL)) == NULL) { 1913 if ((dev->buf = kmalloc (TBUF_SIZE, GFP_KERNEL)) == NULL) {
1914 kfree (dev); 1914 kfree (dev);
1915 return -ENOMEM; 1915 return -ENOMEM;
1916 } 1916 }
diff --git a/drivers/usb/mon/mon_text.c b/drivers/usb/mon/mon_text.c
index 7a2346c53284..05cf2c9a8f84 100644
--- a/drivers/usb/mon/mon_text.c
+++ b/drivers/usb/mon/mon_text.c
@@ -50,7 +50,7 @@ struct mon_event_text {
50 50
51#define SLAB_NAME_SZ 30 51#define SLAB_NAME_SZ 30
52struct mon_reader_text { 52struct mon_reader_text {
53 kmem_cache_t *e_slab; 53 struct kmem_cache *e_slab;
54 int nevents; 54 int nevents;
55 struct list_head e_list; 55 struct list_head e_list;
56 struct mon_reader r; /* In C, parent class can be placed anywhere */ 56 struct mon_reader r; /* In C, parent class can be placed anywhere */
@@ -63,7 +63,7 @@ struct mon_reader_text {
63 char slab_name[SLAB_NAME_SZ]; 63 char slab_name[SLAB_NAME_SZ];
64}; 64};
65 65
66static void mon_text_ctor(void *, kmem_cache_t *, unsigned long); 66static void mon_text_ctor(void *, struct kmem_cache *, unsigned long);
67 67
68/* 68/*
69 * mon_text_submit 69 * mon_text_submit
@@ -147,7 +147,7 @@ static void mon_text_event(struct mon_reader_text *rp, struct urb *urb,
147 stamp = mon_get_timestamp(); 147 stamp = mon_get_timestamp();
148 148
149 if (rp->nevents >= EVENT_MAX || 149 if (rp->nevents >= EVENT_MAX ||
150 (ep = kmem_cache_alloc(rp->e_slab, SLAB_ATOMIC)) == NULL) { 150 (ep = kmem_cache_alloc(rp->e_slab, GFP_ATOMIC)) == NULL) {
151 rp->r.m_bus->cnt_text_lost++; 151 rp->r.m_bus->cnt_text_lost++;
152 return; 152 return;
153 } 153 }
@@ -188,7 +188,7 @@ static void mon_text_error(void *data, struct urb *urb, int error)
188 struct mon_event_text *ep; 188 struct mon_event_text *ep;
189 189
190 if (rp->nevents >= EVENT_MAX || 190 if (rp->nevents >= EVENT_MAX ||
191 (ep = kmem_cache_alloc(rp->e_slab, SLAB_ATOMIC)) == NULL) { 191 (ep = kmem_cache_alloc(rp->e_slab, GFP_ATOMIC)) == NULL) {
192 rp->r.m_bus->cnt_text_lost++; 192 rp->r.m_bus->cnt_text_lost++;
193 return; 193 return;
194 } 194 }
@@ -450,7 +450,7 @@ const struct file_operations mon_fops_text = {
450/* 450/*
451 * Slab interface: constructor. 451 * Slab interface: constructor.
452 */ 452 */
453static void mon_text_ctor(void *mem, kmem_cache_t *slab, unsigned long sflags) 453static void mon_text_ctor(void *mem, struct kmem_cache *slab, unsigned long sflags)
454{ 454{
455 /* 455 /*
456 * Nothing to initialize. No, really! 456 * Nothing to initialize. No, really!
diff --git a/drivers/usb/net/asix.c b/drivers/usb/net/asix.c
index 881841e600de..95e682e2c9d6 100644
--- a/drivers/usb/net/asix.c
+++ b/drivers/usb/net/asix.c
@@ -249,9 +249,9 @@ asix_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, u16 index,
249 249
250 req->bRequestType = USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE; 250 req->bRequestType = USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE;
251 req->bRequest = cmd; 251 req->bRequest = cmd;
252 req->wValue = value; 252 req->wValue = cpu_to_le16(value);
253 req->wIndex = index; 253 req->wIndex = cpu_to_le16(index);
254 req->wLength = size; 254 req->wLength = cpu_to_le16(size);
255 255
256 usb_fill_control_urb(urb, dev->udev, 256 usb_fill_control_urb(urb, dev->udev,
257 usb_sndctrlpipe(dev->udev, 0), 257 usb_sndctrlpipe(dev->udev, 0),
diff --git a/drivers/usb/net/catc.c b/drivers/usb/net/catc.c
index f740325abac4..4852012735f6 100644
--- a/drivers/usb/net/catc.c
+++ b/drivers/usb/net/catc.c
@@ -345,7 +345,7 @@ static void catc_irq_done(struct urb *urb)
345 } 345 }
346 } 346 }
347resubmit: 347resubmit:
348 status = usb_submit_urb (urb, SLAB_ATOMIC); 348 status = usb_submit_urb (urb, GFP_ATOMIC);
349 if (status) 349 if (status)
350 err ("can't resubmit intr, %s-%s, status %d", 350 err ("can't resubmit intr, %s-%s, status %d",
351 catc->usbdev->bus->bus_name, 351 catc->usbdev->bus->bus_name,
@@ -786,14 +786,10 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id
786 if ((!catc->ctrl_urb) || (!catc->tx_urb) || 786 if ((!catc->ctrl_urb) || (!catc->tx_urb) ||
787 (!catc->rx_urb) || (!catc->irq_urb)) { 787 (!catc->rx_urb) || (!catc->irq_urb)) {
788 err("No free urbs available."); 788 err("No free urbs available.");
789 if (catc->ctrl_urb) 789 usb_free_urb(catc->ctrl_urb);
790 usb_free_urb(catc->ctrl_urb); 790 usb_free_urb(catc->tx_urb);
791 if (catc->tx_urb) 791 usb_free_urb(catc->rx_urb);
792 usb_free_urb(catc->tx_urb); 792 usb_free_urb(catc->irq_urb);
793 if (catc->rx_urb)
794 usb_free_urb(catc->rx_urb);
795 if (catc->irq_urb)
796 usb_free_urb(catc->irq_urb);
797 free_netdev(netdev); 793 free_netdev(netdev);
798 return -ENOMEM; 794 return -ENOMEM;
799 } 795 }
diff --git a/drivers/usb/net/cdc_ether.c b/drivers/usb/net/cdc_ether.c
index f6971b88349d..44a91547146e 100644
--- a/drivers/usb/net/cdc_ether.c
+++ b/drivers/usb/net/cdc_ether.c
@@ -200,8 +200,7 @@ next_desc:
200 200
201 dev->status = &info->control->cur_altsetting->endpoint [0]; 201 dev->status = &info->control->cur_altsetting->endpoint [0];
202 desc = &dev->status->desc; 202 desc = &dev->status->desc;
203 if (desc->bmAttributes != USB_ENDPOINT_XFER_INT 203 if (!usb_endpoint_is_int_in(desc)
204 || !(desc->bEndpointAddress & USB_DIR_IN)
205 || (le16_to_cpu(desc->wMaxPacketSize) 204 || (le16_to_cpu(desc->wMaxPacketSize)
206 < sizeof(struct usb_cdc_notification)) 205 < sizeof(struct usb_cdc_notification))
207 || !desc->bInterval) { 206 || !desc->bInterval) {
diff --git a/drivers/usb/net/kaweth.c b/drivers/usb/net/kaweth.c
index 7c906a43e497..fa78326d0bf0 100644
--- a/drivers/usb/net/kaweth.c
+++ b/drivers/usb/net/kaweth.c
@@ -222,7 +222,7 @@ struct kaweth_device
222 int suspend_lowmem_ctrl; 222 int suspend_lowmem_ctrl;
223 int linkstate; 223 int linkstate;
224 int opened; 224 int opened;
225 struct work_struct lowmem_work; 225 struct delayed_work lowmem_work;
226 226
227 struct usb_device *dev; 227 struct usb_device *dev;
228 struct net_device *net; 228 struct net_device *net;
@@ -530,9 +530,10 @@ resubmit:
530 kaweth_resubmit_int_urb(kaweth, GFP_ATOMIC); 530 kaweth_resubmit_int_urb(kaweth, GFP_ATOMIC);
531} 531}
532 532
533static void kaweth_resubmit_tl(void *d) 533static void kaweth_resubmit_tl(struct work_struct *work)
534{ 534{
535 struct kaweth_device *kaweth = (struct kaweth_device *)d; 535 struct kaweth_device *kaweth =
536 container_of(work, struct kaweth_device, lowmem_work.work);
536 537
537 if (IS_BLOCKED(kaweth->status)) 538 if (IS_BLOCKED(kaweth->status))
538 return; 539 return;
@@ -1126,7 +1127,7 @@ err_fw:
1126 1127
1127 /* kaweth is zeroed as part of alloc_netdev */ 1128 /* kaweth is zeroed as part of alloc_netdev */
1128 1129
1129 INIT_WORK(&kaweth->lowmem_work, kaweth_resubmit_tl, (void *)kaweth); 1130 INIT_DELAYED_WORK(&kaweth->lowmem_work, kaweth_resubmit_tl);
1130 1131
1131 SET_MODULE_OWNER(netdev); 1132 SET_MODULE_OWNER(netdev);
1132 1133
diff --git a/drivers/usb/net/net1080.c b/drivers/usb/net/net1080.c
index ce00de8f13a1..493635954513 100644
--- a/drivers/usb/net/net1080.c
+++ b/drivers/usb/net/net1080.c
@@ -237,12 +237,12 @@ static inline void nc_dump_usbctl(struct usbnet *dev, u16 usbctl)
237#define STATUS_CONN_OTHER (1 << 14) 237#define STATUS_CONN_OTHER (1 << 14)
238#define STATUS_SUSPEND_OTHER (1 << 13) 238#define STATUS_SUSPEND_OTHER (1 << 13)
239#define STATUS_MAILBOX_OTHER (1 << 12) 239#define STATUS_MAILBOX_OTHER (1 << 12)
240#define STATUS_PACKETS_OTHER(n) (((n) >> 8) && 0x03) 240#define STATUS_PACKETS_OTHER(n) (((n) >> 8) & 0x03)
241 241
242#define STATUS_CONN_THIS (1 << 6) 242#define STATUS_CONN_THIS (1 << 6)
243#define STATUS_SUSPEND_THIS (1 << 5) 243#define STATUS_SUSPEND_THIS (1 << 5)
244#define STATUS_MAILBOX_THIS (1 << 4) 244#define STATUS_MAILBOX_THIS (1 << 4)
245#define STATUS_PACKETS_THIS(n) (((n) >> 0) && 0x03) 245#define STATUS_PACKETS_THIS(n) (((n) >> 0) & 0x03)
246 246
247#define STATUS_UNSPEC_MASK 0x0c8c 247#define STATUS_UNSPEC_MASK 0x0c8c
248#define STATUS_NOISE_MASK ((u16)~(0x0303|STATUS_UNSPEC_MASK)) 248#define STATUS_NOISE_MASK ((u16)~(0x0303|STATUS_UNSPEC_MASK))
@@ -383,7 +383,7 @@ static void nc_ensure_sync(struct usbnet *dev)
383 int status; 383 int status;
384 384
385 /* Send a flush */ 385 /* Send a flush */
386 urb = usb_alloc_urb(0, SLAB_ATOMIC); 386 urb = usb_alloc_urb(0, GFP_ATOMIC);
387 if (!urb) 387 if (!urb)
388 return; 388 return;
389 389
diff --git a/drivers/usb/net/pegasus.c b/drivers/usb/net/pegasus.c
index 33abbd2176b6..d48c024cff59 100644
--- a/drivers/usb/net/pegasus.c
+++ b/drivers/usb/net/pegasus.c
@@ -163,6 +163,7 @@ static int get_registers(pegasus_t * pegasus, __u16 indx, __u16 size,
163 163
164 /* using ATOMIC, we'd never wake up if we slept */ 164 /* using ATOMIC, we'd never wake up if we slept */
165 if ((ret = usb_submit_urb(pegasus->ctrl_urb, GFP_ATOMIC))) { 165 if ((ret = usb_submit_urb(pegasus->ctrl_urb, GFP_ATOMIC))) {
166 set_current_state(TASK_RUNNING);
166 if (ret == -ENODEV) 167 if (ret == -ENODEV)
167 netif_device_detach(pegasus->net); 168 netif_device_detach(pegasus->net);
168 if (netif_msg_drv(pegasus)) 169 if (netif_msg_drv(pegasus))
@@ -855,7 +856,7 @@ static void intr_callback(struct urb *urb)
855 pegasus->stats.rx_missed_errors += ((d[3] & 0x7f) << 8) | d[4]; 856 pegasus->stats.rx_missed_errors += ((d[3] & 0x7f) << 8) | d[4];
856 } 857 }
857 858
858 status = usb_submit_urb(urb, SLAB_ATOMIC); 859 status = usb_submit_urb(urb, GFP_ATOMIC);
859 if (status == -ENODEV) 860 if (status == -ENODEV)
860 netif_device_detach(pegasus->net); 861 netif_device_detach(pegasus->net);
861 if (status && netif_msg_timer(pegasus)) 862 if (status && netif_msg_timer(pegasus))
@@ -1280,9 +1281,9 @@ static inline void setup_pegasus_II(pegasus_t * pegasus)
1280static struct workqueue_struct *pegasus_workqueue = NULL; 1281static struct workqueue_struct *pegasus_workqueue = NULL;
1281#define CARRIER_CHECK_DELAY (2 * HZ) 1282#define CARRIER_CHECK_DELAY (2 * HZ)
1282 1283
1283static void check_carrier(void *data) 1284static void check_carrier(struct work_struct *work)
1284{ 1285{
1285 pegasus_t *pegasus = data; 1286 pegasus_t *pegasus = container_of(work, pegasus_t, carrier_check.work);
1286 set_carrier(pegasus->net); 1287 set_carrier(pegasus->net);
1287 if (!(pegasus->flags & PEGASUS_UNPLUG)) { 1288 if (!(pegasus->flags & PEGASUS_UNPLUG)) {
1288 queue_delayed_work(pegasus_workqueue, &pegasus->carrier_check, 1289 queue_delayed_work(pegasus_workqueue, &pegasus->carrier_check,
@@ -1318,7 +1319,7 @@ static int pegasus_probe(struct usb_interface *intf,
1318 1319
1319 tasklet_init(&pegasus->rx_tl, rx_fixup, (unsigned long) pegasus); 1320 tasklet_init(&pegasus->rx_tl, rx_fixup, (unsigned long) pegasus);
1320 1321
1321 INIT_WORK(&pegasus->carrier_check, check_carrier, pegasus); 1322 INIT_DELAYED_WORK(&pegasus->carrier_check, check_carrier);
1322 1323
1323 pegasus->intf = intf; 1324 pegasus->intf = intf;
1324 pegasus->usb = dev; 1325 pegasus->usb = dev;
diff --git a/drivers/usb/net/pegasus.h b/drivers/usb/net/pegasus.h
index 006438069b66..98f6898cae1f 100644
--- a/drivers/usb/net/pegasus.h
+++ b/drivers/usb/net/pegasus.h
@@ -95,7 +95,7 @@ typedef struct pegasus {
95 int dev_index; 95 int dev_index;
96 int intr_interval; 96 int intr_interval;
97 struct tasklet_struct rx_tl; 97 struct tasklet_struct rx_tl;
98 struct work_struct carrier_check; 98 struct delayed_work carrier_check;
99 struct urb *ctrl_urb, *rx_urb, *tx_urb, *intr_urb; 99 struct urb *ctrl_urb, *rx_urb, *tx_urb, *intr_urb;
100 struct sk_buff *rx_pool[RX_SKBS]; 100 struct sk_buff *rx_pool[RX_SKBS];
101 struct sk_buff *rx_skb; 101 struct sk_buff *rx_skb;
diff --git a/drivers/usb/net/rndis_host.c b/drivers/usb/net/rndis_host.c
index c2a28d88ef3c..99f26b3e502f 100644
--- a/drivers/usb/net/rndis_host.c
+++ b/drivers/usb/net/rndis_host.c
@@ -469,7 +469,7 @@ static void rndis_unbind(struct usbnet *dev, struct usb_interface *intf)
469 struct rndis_halt *halt; 469 struct rndis_halt *halt;
470 470
471 /* try to clear any rndis state/activity (no i/o from stack!) */ 471 /* try to clear any rndis state/activity (no i/o from stack!) */
472 halt = kcalloc(1, sizeof *halt, SLAB_KERNEL); 472 halt = kcalloc(1, sizeof *halt, GFP_KERNEL);
473 if (halt) { 473 if (halt) {
474 halt->msg_type = RNDIS_MSG_HALT; 474 halt->msg_type = RNDIS_MSG_HALT;
475 halt->msg_len = ccpu2(sizeof *halt); 475 halt->msg_len = ccpu2(sizeof *halt);
diff --git a/drivers/usb/net/rtl8150.c b/drivers/usb/net/rtl8150.c
index 72171f94ded4..c54235f73cb6 100644
--- a/drivers/usb/net/rtl8150.c
+++ b/drivers/usb/net/rtl8150.c
@@ -587,7 +587,7 @@ static void intr_callback(struct urb *urb)
587 } 587 }
588 588
589resubmit: 589resubmit:
590 status = usb_submit_urb (urb, SLAB_ATOMIC); 590 status = usb_submit_urb (urb, GFP_ATOMIC);
591 if (status == -ENODEV) 591 if (status == -ENODEV)
592 netif_device_detach(dev->netdev); 592 netif_device_detach(dev->netdev);
593 else if (status) 593 else if (status)
diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c
index 760b5327b81b..6e39e9988259 100644
--- a/drivers/usb/net/usbnet.c
+++ b/drivers/usb/net/usbnet.c
@@ -116,7 +116,7 @@ int usbnet_get_endpoints(struct usbnet *dev, struct usb_interface *intf)
116 e = alt->endpoint + ep; 116 e = alt->endpoint + ep;
117 switch (e->desc.bmAttributes) { 117 switch (e->desc.bmAttributes) {
118 case USB_ENDPOINT_XFER_INT: 118 case USB_ENDPOINT_XFER_INT:
119 if (!(e->desc.bEndpointAddress & USB_DIR_IN)) 119 if (!usb_endpoint_dir_in(&e->desc))
120 continue; 120 continue;
121 intr = 1; 121 intr = 1;
122 /* FALLTHROUGH */ 122 /* FALLTHROUGH */
@@ -125,7 +125,7 @@ int usbnet_get_endpoints(struct usbnet *dev, struct usb_interface *intf)
125 default: 125 default:
126 continue; 126 continue;
127 } 127 }
128 if (e->desc.bEndpointAddress & USB_DIR_IN) { 128 if (usb_endpoint_dir_in(&e->desc)) {
129 if (!intr && !in) 129 if (!intr && !in)
130 in = e; 130 in = e;
131 else if (intr && !status) 131 else if (intr && !status)
@@ -179,9 +179,9 @@ static int init_status (struct usbnet *dev, struct usb_interface *intf)
179 period = max ((int) dev->status->desc.bInterval, 179 period = max ((int) dev->status->desc.bInterval,
180 (dev->udev->speed == USB_SPEED_HIGH) ? 7 : 3); 180 (dev->udev->speed == USB_SPEED_HIGH) ? 7 : 3);
181 181
182 buf = kmalloc (maxp, SLAB_KERNEL); 182 buf = kmalloc (maxp, GFP_KERNEL);
183 if (buf) { 183 if (buf) {
184 dev->interrupt = usb_alloc_urb (0, SLAB_KERNEL); 184 dev->interrupt = usb_alloc_urb (0, GFP_KERNEL);
185 if (!dev->interrupt) { 185 if (!dev->interrupt) {
186 kfree (buf); 186 kfree (buf);
187 return -ENOMEM; 187 return -ENOMEM;
@@ -782,9 +782,10 @@ static struct ethtool_ops usbnet_ethtool_ops = {
782 * especially now that control transfers can be queued. 782 * especially now that control transfers can be queued.
783 */ 783 */
784static void 784static void
785kevent (void *data) 785kevent (struct work_struct *work)
786{ 786{
787 struct usbnet *dev = data; 787 struct usbnet *dev =
788 container_of(work, struct usbnet, kevent);
788 int status; 789 int status;
789 790
790 /* usb_clear_halt() needs a thread context */ 791 /* usb_clear_halt() needs a thread context */
@@ -1146,7 +1147,7 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
1146 skb_queue_head_init (&dev->done); 1147 skb_queue_head_init (&dev->done);
1147 dev->bh.func = usbnet_bh; 1148 dev->bh.func = usbnet_bh;
1148 dev->bh.data = (unsigned long) dev; 1149 dev->bh.data = (unsigned long) dev;
1149 INIT_WORK (&dev->kevent, kevent, dev); 1150 INIT_WORK (&dev->kevent, kevent);
1150 dev->delay.function = usbnet_bh; 1151 dev->delay.function = usbnet_bh;
1151 dev->delay.data = (unsigned long) dev; 1152 dev->delay.data = (unsigned long) dev;
1152 init_timer (&dev->delay); 1153 init_timer (&dev->delay);
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
index 2a8dd4cc943d..2f4d303ee36f 100644
--- a/drivers/usb/serial/Kconfig
+++ b/drivers/usb/serial/Kconfig
@@ -554,6 +554,17 @@ config USB_SERIAL_OMNINET
554 To compile this driver as a module, choose M here: the 554 To compile this driver as a module, choose M here: the
555 module will be called omninet. 555 module will be called omninet.
556 556
557config USB_SERIAL_DEBUG
558 tristate "USB Debugging Device"
559 depends on USB_SERIAL
560 help
561 Say Y here if you have a USB debugging device used to recieve
562 debugging data from another machine. The most common of these
563 devices is the NetChip TurboCONNECT device.
564
565 To compile this driver as a module, choose M here: the
566 module will be called usb-debug.
567
557config USB_EZUSB 568config USB_EZUSB
558 bool 569 bool
559 depends on USB_SERIAL_KEYSPAN_PDA || USB_SERIAL_XIRCOM || USB_SERIAL_KEYSPAN || USB_SERIAL_WHITEHEAT 570 depends on USB_SERIAL_KEYSPAN_PDA || USB_SERIAL_XIRCOM || USB_SERIAL_KEYSPAN || USB_SERIAL_WHITEHEAT
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile
index a5047dc599bb..61166ad450e6 100644
--- a/drivers/usb/serial/Makefile
+++ b/drivers/usb/serial/Makefile
@@ -18,6 +18,7 @@ obj-$(CONFIG_USB_SERIAL_BELKIN) += belkin_sa.o
18obj-$(CONFIG_USB_SERIAL_CP2101) += cp2101.o 18obj-$(CONFIG_USB_SERIAL_CP2101) += cp2101.o
19obj-$(CONFIG_USB_SERIAL_CYBERJACK) += cyberjack.o 19obj-$(CONFIG_USB_SERIAL_CYBERJACK) += cyberjack.o
20obj-$(CONFIG_USB_SERIAL_CYPRESS_M8) += cypress_m8.o 20obj-$(CONFIG_USB_SERIAL_CYPRESS_M8) += cypress_m8.o
21obj-$(CONFIG_USB_SERIAL_DEBUG) += usb_debug.o
21obj-$(CONFIG_USB_SERIAL_DIGI_ACCELEPORT) += digi_acceleport.o 22obj-$(CONFIG_USB_SERIAL_DIGI_ACCELEPORT) += digi_acceleport.o
22obj-$(CONFIG_USB_SERIAL_EDGEPORT) += io_edgeport.o 23obj-$(CONFIG_USB_SERIAL_EDGEPORT) += io_edgeport.o
23obj-$(CONFIG_USB_SERIAL_EDGEPORT_TI) += io_ti.o 24obj-$(CONFIG_USB_SERIAL_EDGEPORT_TI) += io_ti.o
diff --git a/drivers/usb/serial/aircable.c b/drivers/usb/serial/aircable.c
index 812275509137..86bcf63b6ba5 100644
--- a/drivers/usb/serial/aircable.c
+++ b/drivers/usb/serial/aircable.c
@@ -92,6 +92,7 @@ struct aircable_private {
92 struct circ_buf *rx_buf; /* read buffer */ 92 struct circ_buf *rx_buf; /* read buffer */
93 int rx_flags; /* for throttilng */ 93 int rx_flags; /* for throttilng */
94 struct work_struct rx_work; /* work cue for the receiving line */ 94 struct work_struct rx_work; /* work cue for the receiving line */
95 struct usb_serial_port *port; /* USB port with which associated */
95}; 96};
96 97
97/* Private methods */ 98/* Private methods */
@@ -251,10 +252,11 @@ static void aircable_send(struct usb_serial_port *port)
251 schedule_work(&port->work); 252 schedule_work(&port->work);
252} 253}
253 254
254static void aircable_read(void *params) 255static void aircable_read(struct work_struct *work)
255{ 256{
256 struct usb_serial_port *port = params; 257 struct aircable_private *priv =
257 struct aircable_private *priv = usb_get_serial_port_data(port); 258 container_of(work, struct aircable_private, rx_work);
259 struct usb_serial_port *port = priv->port;
258 struct tty_struct *tty; 260 struct tty_struct *tty;
259 unsigned char *data; 261 unsigned char *data;
260 int count; 262 int count;
@@ -270,8 +272,11 @@ static void aircable_read(void *params)
270 */ 272 */
271 tty = port->tty; 273 tty = port->tty;
272 274
273 if (!tty) 275 if (!tty) {
274 schedule_work(&priv->rx_work); 276 schedule_work(&priv->rx_work);
277 err("%s - No tty available", __FUNCTION__);
278 return ;
279 }
275 280
276 count = min(64, serial_buf_data_avail(priv->rx_buf)); 281 count = min(64, serial_buf_data_avail(priv->rx_buf));
277 282
@@ -305,9 +310,7 @@ static int aircable_probe(struct usb_serial *serial,
305 310
306 for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) { 311 for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) {
307 endpoint = &iface_desc->endpoint[i].desc; 312 endpoint = &iface_desc->endpoint[i].desc;
308 if (((endpoint->bEndpointAddress & 0x80) == 0x00) && 313 if (usb_endpoint_is_bulk_out(endpoint)) {
309 ((endpoint->bmAttributes & 3) == 0x02)) {
310 /* we found our bulk out endpoint */
311 dbg("found bulk out on endpoint %d", i); 314 dbg("found bulk out on endpoint %d", i);
312 ++num_bulk_out; 315 ++num_bulk_out;
313 } 316 }
@@ -348,7 +351,8 @@ static int aircable_attach (struct usb_serial *serial)
348 } 351 }
349 352
350 priv->rx_flags &= ~(THROTTLED | ACTUALLY_THROTTLED); 353 priv->rx_flags &= ~(THROTTLED | ACTUALLY_THROTTLED);
351 INIT_WORK(&priv->rx_work, aircable_read, port); 354 priv->port = port;
355 INIT_WORK(&priv->rx_work, aircable_read);
352 356
353 usb_set_serial_port_data(serial->port[0], priv); 357 usb_set_serial_port_data(serial->port[0], priv);
354 358
@@ -515,7 +519,7 @@ static void aircable_read_bulk_callback(struct urb *urb)
515 package_length - shift); 519 package_length - shift);
516 } 520 }
517 } 521 }
518 aircable_read(port); 522 aircable_read(&priv->rx_work);
519 } 523 }
520 524
521 /* Schedule the next read _if_ we are still open */ 525 /* Schedule the next read _if_ we are still open */
diff --git a/drivers/usb/serial/airprime.c b/drivers/usb/serial/airprime.c
index 7f5d546da39a..96c73726d74a 100644
--- a/drivers/usb/serial/airprime.c
+++ b/drivers/usb/serial/airprime.c
@@ -19,6 +19,7 @@
19static struct usb_device_id id_table [] = { 19static struct usb_device_id id_table [] = {
20 { USB_DEVICE(0x0c88, 0x17da) }, /* Kyocera Wireless KPC650/Passport */ 20 { USB_DEVICE(0x0c88, 0x17da) }, /* Kyocera Wireless KPC650/Passport */
21 { USB_DEVICE(0x1410, 0x1110) }, /* Novatel Wireless Merlin CDMA */ 21 { USB_DEVICE(0x1410, 0x1110) }, /* Novatel Wireless Merlin CDMA */
22 { USB_DEVICE(0x1410, 0x1430) }, /* Novatel Merlin XU870 HSDPA/3G */
22 { USB_DEVICE(0x1410, 0x1100) }, /* ExpressCard34 Qualcomm 3G CDMA */ 23 { USB_DEVICE(0x1410, 0x1100) }, /* ExpressCard34 Qualcomm 3G CDMA */
23 { }, 24 { },
24}; 25};
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c
index ca52f12f0e24..863966c1c5ac 100644
--- a/drivers/usb/serial/ark3116.c
+++ b/drivers/usb/serial/ark3116.c
@@ -85,10 +85,9 @@ static int ark3116_attach(struct usb_serial *serial)
85 int i; 85 int i;
86 86
87 for (i = 0; i < serial->num_ports; ++i) { 87 for (i = 0; i < serial->num_ports; ++i) {
88 priv = kmalloc(sizeof (struct ark3116_private), GFP_KERNEL); 88 priv = kzalloc(sizeof(struct ark3116_private), GFP_KERNEL);
89 if (!priv) 89 if (!priv)
90 goto cleanup; 90 goto cleanup;
91 memset(priv, 0x00, sizeof (struct ark3116_private));
92 spin_lock_init(&priv->lock); 91 spin_lock_init(&priv->lock);
93 92
94 usb_set_serial_port_data(serial->port[i], priv); 93 usb_set_serial_port_data(serial->port[i], priv);
diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
index 3a9073dbfe6a..7167728d764c 100644
--- a/drivers/usb/serial/console.c
+++ b/drivers/usb/serial/console.c
@@ -166,19 +166,17 @@ static int usb_console_setup(struct console *co, char *options)
166 if (serial->type->set_termios) { 166 if (serial->type->set_termios) {
167 /* build up a fake tty structure so that the open call has something 167 /* build up a fake tty structure so that the open call has something
168 * to look at to get the cflag value */ 168 * to look at to get the cflag value */
169 tty = kmalloc (sizeof (*tty), GFP_KERNEL); 169 tty = kzalloc(sizeof(*tty), GFP_KERNEL);
170 if (!tty) { 170 if (!tty) {
171 err ("no more memory"); 171 err ("no more memory");
172 return -ENOMEM; 172 return -ENOMEM;
173 } 173 }
174 termios = kmalloc (sizeof (*termios), GFP_KERNEL); 174 termios = kzalloc(sizeof(*termios), GFP_KERNEL);
175 if (!termios) { 175 if (!termios) {
176 err ("no more memory"); 176 err ("no more memory");
177 kfree (tty); 177 kfree (tty);
178 return -ENOMEM; 178 return -ENOMEM;
179 } 179 }
180 memset (tty, 0x00, sizeof(*tty));
181 memset (termios, 0x00, sizeof(*termios));
182 termios->c_cflag = cflag; 180 termios->c_cflag = cflag;
183 tty->termios = termios; 181 tty->termios = termios;
184 port->tty = tty; 182 port->tty = tty;
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
index f2e89a083659..093f303b3189 100644
--- a/drivers/usb/serial/cypress_m8.c
+++ b/drivers/usb/serial/cypress_m8.c
@@ -1684,15 +1684,14 @@ static int __init cypress_init(void)
1684 1684
1685 info(DRIVER_DESC " " DRIVER_VERSION); 1685 info(DRIVER_DESC " " DRIVER_VERSION);
1686 return 0; 1686 return 0;
1687
1687failed_usb_register: 1688failed_usb_register:
1688 usb_deregister(&cypress_driver);
1689failed_ca42v2_register:
1690 usb_serial_deregister(&cypress_ca42v2_device); 1689 usb_serial_deregister(&cypress_ca42v2_device);
1691failed_hidcom_register: 1690failed_ca42v2_register:
1692 usb_serial_deregister(&cypress_hidcom_device); 1691 usb_serial_deregister(&cypress_hidcom_device);
1693failed_em_register: 1692failed_hidcom_register:
1694 usb_serial_deregister(&cypress_earthmate_device); 1693 usb_serial_deregister(&cypress_earthmate_device);
1695 1694failed_em_register:
1696 return retval; 1695 return retval;
1697} 1696}
1698 1697
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
index bdb58100fc1d..83d0e21145b0 100644
--- a/drivers/usb/serial/digi_acceleport.c
+++ b/drivers/usb/serial/digi_acceleport.c
@@ -157,7 +157,7 @@
157* to TASK_RUNNING will be lost and write_chan's subsequent call to 157* to TASK_RUNNING will be lost and write_chan's subsequent call to
158* schedule() will never return (unless it catches a signal). 158* schedule() will never return (unless it catches a signal).
159* This race condition occurs because write_bulk_callback() (and thus 159* This race condition occurs because write_bulk_callback() (and thus
160* the wakeup) are called asynchonously from an interrupt, rather than 160* the wakeup) are called asynchronously from an interrupt, rather than
161* from the scheduler. We can avoid the race by calling the wakeup 161* from the scheduler. We can avoid the race by calling the wakeup
162* from the scheduler queue and that's our fix: Now, at the end of 162* from the scheduler queue and that's our fix: Now, at the end of
163* write_bulk_callback() we queue up a wakeup call on the scheduler 163* write_bulk_callback() we queue up a wakeup call on the scheduler
@@ -430,13 +430,14 @@ struct digi_port {
430 int dp_in_close; /* close in progress */ 430 int dp_in_close; /* close in progress */
431 wait_queue_head_t dp_close_wait; /* wait queue for close */ 431 wait_queue_head_t dp_close_wait; /* wait queue for close */
432 struct work_struct dp_wakeup_work; 432 struct work_struct dp_wakeup_work;
433 struct usb_serial_port *dp_port;
433}; 434};
434 435
435 436
436/* Local Function Declarations */ 437/* Local Function Declarations */
437 438
438static void digi_wakeup_write( struct usb_serial_port *port ); 439static void digi_wakeup_write( struct usb_serial_port *port );
439static void digi_wakeup_write_lock(void *); 440static void digi_wakeup_write_lock(struct work_struct *work);
440static int digi_write_oob_command( struct usb_serial_port *port, 441static int digi_write_oob_command( struct usb_serial_port *port,
441 unsigned char *buf, int count, int interruptible ); 442 unsigned char *buf, int count, int interruptible );
442static int digi_write_inb_command( struct usb_serial_port *port, 443static int digi_write_inb_command( struct usb_serial_port *port,
@@ -598,11 +599,12 @@ static inline long cond_wait_interruptible_timeout_irqrestore(
598* on writes. 599* on writes.
599*/ 600*/
600 601
601static void digi_wakeup_write_lock(void *arg) 602static void digi_wakeup_write_lock(struct work_struct *work)
602{ 603{
603 struct usb_serial_port *port = arg; 604 struct digi_port *priv =
605 container_of(work, struct digi_port, dp_wakeup_work);
606 struct usb_serial_port *port = priv->dp_port;
604 unsigned long flags; 607 unsigned long flags;
605 struct digi_port *priv = usb_get_serial_port_data(port);
606 608
607 609
608 spin_lock_irqsave( &priv->dp_port_lock, flags ); 610 spin_lock_irqsave( &priv->dp_port_lock, flags );
@@ -1702,8 +1704,8 @@ dbg( "digi_startup: TOP" );
1702 init_waitqueue_head( &priv->dp_flush_wait ); 1704 init_waitqueue_head( &priv->dp_flush_wait );
1703 priv->dp_in_close = 0; 1705 priv->dp_in_close = 0;
1704 init_waitqueue_head( &priv->dp_close_wait ); 1706 init_waitqueue_head( &priv->dp_close_wait );
1705 INIT_WORK(&priv->dp_wakeup_work, 1707 INIT_WORK(&priv->dp_wakeup_work, digi_wakeup_write_lock);
1706 digi_wakeup_write_lock, serial->port[i]); 1708 priv->dp_port = serial->port[i];
1707 1709
1708 /* initialize write wait queue for this port */ 1710 /* initialize write wait queue for this port */
1709 init_waitqueue_head( &serial->port[i]->write_wait ); 1711 init_waitqueue_head( &serial->port[i]->write_wait );
diff --git a/drivers/usb/serial/ezusb.c b/drivers/usb/serial/ezusb.c
index 5169c2d154ab..97ee718b1da2 100644
--- a/drivers/usb/serial/ezusb.c
+++ b/drivers/usb/serial/ezusb.c
@@ -31,12 +31,11 @@ int ezusb_writememory (struct usb_serial *serial, int address, unsigned char *da
31 return -ENODEV; 31 return -ENODEV;
32 } 32 }
33 33
34 transfer_buffer = kmalloc (length, GFP_KERNEL); 34 transfer_buffer = kmemdup(data, length, GFP_KERNEL);
35 if (!transfer_buffer) { 35 if (!transfer_buffer) {
36 dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", __FUNCTION__, length); 36 dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", __FUNCTION__, length);
37 return -ENOMEM; 37 return -ENOMEM;
38 } 38 }
39 memcpy (transfer_buffer, data, length);
40 result = usb_control_msg (serial->dev, usb_sndctrlpipe(serial->dev, 0), bRequest, 0x40, address, 0, transfer_buffer, length, 3000); 39 result = usb_control_msg (serial->dev, usb_sndctrlpipe(serial->dev, 0), bRequest, 0x40, address, 0, transfer_buffer, length, 3000);
41 kfree (transfer_buffer); 40 kfree (transfer_buffer);
42 return result; 41 return result;
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index bd76b4c11fcc..72e4d48f51e9 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -311,6 +311,7 @@ static struct usb_device_id id_table_combined [] = {
311 { USB_DEVICE(FTDI_VID, FTDI_ACTZWAVE_PID) }, 311 { USB_DEVICE(FTDI_VID, FTDI_ACTZWAVE_PID) },
312 { USB_DEVICE(FTDI_VID, FTDI_IRTRANS_PID) }, 312 { USB_DEVICE(FTDI_VID, FTDI_IRTRANS_PID) },
313 { USB_DEVICE(FTDI_VID, FTDI_IPLUS_PID) }, 313 { USB_DEVICE(FTDI_VID, FTDI_IPLUS_PID) },
314 { USB_DEVICE(FTDI_VID, FTDI_DMX4ALL) },
314 { USB_DEVICE(FTDI_VID, FTDI_SIO_PID) }, 315 { USB_DEVICE(FTDI_VID, FTDI_SIO_PID) },
315 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_PID) }, 316 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_PID) },
316 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_ALT_PID) }, 317 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_ALT_PID) },
@@ -511,6 +512,7 @@ static struct usb_device_id id_table_combined [] = {
511 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13M_PID) }, 512 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13M_PID) },
512 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13S_PID) }, 513 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13S_PID) },
513 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13U_PID) }, 514 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13U_PID) },
515 { USB_DEVICE(ELEKTOR_VID, ELEKTOR_FT323R_PID) },
514 { }, /* Optional parameter entry */ 516 { }, /* Optional parameter entry */
515 { } /* Terminating entry */ 517 { } /* Terminating entry */
516}; 518};
@@ -557,7 +559,8 @@ struct ftdi_private {
557 char prev_status, diff_status; /* Used for TIOCMIWAIT */ 559 char prev_status, diff_status; /* Used for TIOCMIWAIT */
558 __u8 rx_flags; /* receive state flags (throttling) */ 560 __u8 rx_flags; /* receive state flags (throttling) */
559 spinlock_t rx_lock; /* spinlock for receive state */ 561 spinlock_t rx_lock; /* spinlock for receive state */
560 struct work_struct rx_work; 562 struct delayed_work rx_work;
563 struct usb_serial_port *port;
561 int rx_processed; 564 int rx_processed;
562 unsigned long rx_bytes; 565 unsigned long rx_bytes;
563 566
@@ -591,7 +594,7 @@ static int ftdi_write_room (struct usb_serial_port *port);
591static int ftdi_chars_in_buffer (struct usb_serial_port *port); 594static int ftdi_chars_in_buffer (struct usb_serial_port *port);
592static void ftdi_write_bulk_callback (struct urb *urb); 595static void ftdi_write_bulk_callback (struct urb *urb);
593static void ftdi_read_bulk_callback (struct urb *urb); 596static void ftdi_read_bulk_callback (struct urb *urb);
594static void ftdi_process_read (void *param); 597static void ftdi_process_read (struct work_struct *work);
595static void ftdi_set_termios (struct usb_serial_port *port, struct termios * old); 598static void ftdi_set_termios (struct usb_serial_port *port, struct termios * old);
596static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file); 599static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file);
597static int ftdi_tiocmset (struct usb_serial_port *port, struct file * file, unsigned int set, unsigned int clear); 600static int ftdi_tiocmset (struct usb_serial_port *port, struct file * file, unsigned int set, unsigned int clear);
@@ -1199,7 +1202,8 @@ static int ftdi_sio_attach (struct usb_serial *serial)
1199 port->read_urb->transfer_buffer_length = BUFSZ; 1202 port->read_urb->transfer_buffer_length = BUFSZ;
1200 } 1203 }
1201 1204
1202 INIT_WORK(&priv->rx_work, ftdi_process_read, port); 1205 INIT_DELAYED_WORK(&priv->rx_work, ftdi_process_read);
1206 priv->port = port;
1203 1207
1204 /* Free port's existing write urb and transfer buffer. */ 1208 /* Free port's existing write urb and transfer buffer. */
1205 if (port->write_urb) { 1209 if (port->write_urb) {
@@ -1386,8 +1390,7 @@ static void ftdi_close (struct usb_serial_port *port, struct file *filp)
1386 flush_scheduled_work(); 1390 flush_scheduled_work();
1387 1391
1388 /* shutdown our bulk read */ 1392 /* shutdown our bulk read */
1389 if (port->read_urb) 1393 usb_kill_urb(port->read_urb);
1390 usb_kill_urb(port->read_urb);
1391} /* ftdi_close */ 1394} /* ftdi_close */
1392 1395
1393 1396
@@ -1639,17 +1642,18 @@ static void ftdi_read_bulk_callback (struct urb *urb)
1639 priv->rx_bytes += countread; 1642 priv->rx_bytes += countread;
1640 spin_unlock_irqrestore(&priv->rx_lock, flags); 1643 spin_unlock_irqrestore(&priv->rx_lock, flags);
1641 1644
1642 ftdi_process_read(port); 1645 ftdi_process_read(&priv->rx_work.work);
1643 1646
1644} /* ftdi_read_bulk_callback */ 1647} /* ftdi_read_bulk_callback */
1645 1648
1646 1649
1647static void ftdi_process_read (void *param) 1650static void ftdi_process_read (struct work_struct *work)
1648{ /* ftdi_process_read */ 1651{ /* ftdi_process_read */
1649 struct usb_serial_port *port = (struct usb_serial_port*)param; 1652 struct ftdi_private *priv =
1653 container_of(work, struct ftdi_private, rx_work.work);
1654 struct usb_serial_port *port = priv->port;
1650 struct urb *urb; 1655 struct urb *urb;
1651 struct tty_struct *tty; 1656 struct tty_struct *tty;
1652 struct ftdi_private *priv;
1653 char error_flag; 1657 char error_flag;
1654 unsigned char *data; 1658 unsigned char *data;
1655 1659
@@ -2178,7 +2182,7 @@ static void ftdi_unthrottle (struct usb_serial_port *port)
2178 spin_unlock_irqrestore(&priv->rx_lock, flags); 2182 spin_unlock_irqrestore(&priv->rx_lock, flags);
2179 2183
2180 if (actually_throttled) 2184 if (actually_throttled)
2181 schedule_work(&priv->rx_work); 2185 schedule_delayed_work(&priv->rx_work, 0);
2182} 2186}
2183 2187
2184static int __init ftdi_init (void) 2188static int __init ftdi_init (void)
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
index f0edb87d2dd5..bae117d359af 100644
--- a/drivers/usb/serial/ftdi_sio.h
+++ b/drivers/usb/serial/ftdi_sio.h
@@ -55,6 +55,9 @@
55/* iPlus device */ 55/* iPlus device */
56#define FTDI_IPLUS_PID 0xD070 /* Product Id */ 56#define FTDI_IPLUS_PID 0xD070 /* Product Id */
57 57
58/* DMX4ALL DMX Interfaces */
59#define FTDI_DMX4ALL 0xC850
60
58/* www.crystalfontz.com devices - thanx for providing free devices for evaluation ! */ 61/* www.crystalfontz.com devices - thanx for providing free devices for evaluation ! */
59/* they use the ftdi chipset for the USB interface and the vendor id is the same */ 62/* they use the ftdi chipset for the USB interface and the vendor id is the same */
60#define FTDI_XF_632_PID 0xFC08 /* 632: 16x2 Character Display */ 63#define FTDI_XF_632_PID 0xFC08 /* 632: 16x2 Character Display */
@@ -175,9 +178,15 @@
175#define FTDI_ASK_RDR400_PID 0xC991 /* ASK RDR 400 series card reader */ 178#define FTDI_ASK_RDR400_PID 0xC991 /* ASK RDR 400 series card reader */
176 179
177/* 180/*
181 * FTDI USB UART chips used in construction projects from the
182 * Elektor Electronics magazine (http://elektor-electronics.co.uk)
183 */
184#define ELEKTOR_VID 0x0C7D
185#define ELEKTOR_FT323R_PID 0x0005 /* RFID-Reader, issue 09-2006 */
186
187/*
178 * DSS-20 Sync Station for Sony Ericsson P800 188 * DSS-20 Sync Station for Sony Ericsson P800
179 */ 189 */
180
181#define FTDI_DSS20_PID 0xFC82 190#define FTDI_DSS20_PID 0xFC82
182 191
183/* 192/*
diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c
index 4543152a9966..6530d391ebed 100644
--- a/drivers/usb/serial/garmin_gps.c
+++ b/drivers/usb/serial/garmin_gps.c
@@ -1523,12 +1523,11 @@ static int garmin_attach (struct usb_serial *serial)
1523 1523
1524 dbg("%s", __FUNCTION__); 1524 dbg("%s", __FUNCTION__);
1525 1525
1526 garmin_data_p = kmalloc (sizeof(struct garmin_data), GFP_KERNEL); 1526 garmin_data_p = kzalloc(sizeof(struct garmin_data), GFP_KERNEL);
1527 if (garmin_data_p == NULL) { 1527 if (garmin_data_p == NULL) {
1528 dev_err(&port->dev, "%s - Out of memory\n", __FUNCTION__); 1528 dev_err(&port->dev, "%s - Out of memory\n", __FUNCTION__);
1529 return -ENOMEM; 1529 return -ENOMEM;
1530 } 1530 }
1531 memset (garmin_data_p, 0, sizeof(struct garmin_data));
1532 init_timer(&garmin_data_p->timer); 1531 init_timer(&garmin_data_p->timer);
1533 spin_lock_init(&garmin_data_p->lock); 1532 spin_lock_init(&garmin_data_p->lock);
1534 INIT_LIST_HEAD(&garmin_data_p->pktlist); 1533 INIT_LIST_HEAD(&garmin_data_p->pktlist);
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
index 91bd3014ef1e..d06547a13f28 100644
--- a/drivers/usb/serial/io_edgeport.c
+++ b/drivers/usb/serial/io_edgeport.c
@@ -1038,9 +1038,7 @@ static void edge_close (struct usb_serial_port *port, struct file * filp)
1038 edge_port->open = FALSE; 1038 edge_port->open = FALSE;
1039 edge_port->openPending = FALSE; 1039 edge_port->openPending = FALSE;
1040 1040
1041 if (edge_port->write_urb) { 1041 usb_kill_urb(edge_port->write_urb);
1042 usb_kill_urb(edge_port->write_urb);
1043 }
1044 1042
1045 if (edge_port->write_urb) { 1043 if (edge_port->write_urb) {
1046 /* if this urb had a transfer buffer already (old transfer) free it */ 1044 /* if this urb had a transfer buffer already (old transfer) free it */
diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c
index 6238aff1e772..d72cf8bc7f76 100644
--- a/drivers/usb/serial/ipaq.c
+++ b/drivers/usb/serial/ipaq.c
@@ -320,6 +320,7 @@ static struct usb_device_id ipaq_id_table [] = {
320 { USB_DEVICE(0x0B05, 0x9200) }, /* ASUS USB Sync */ 320 { USB_DEVICE(0x0B05, 0x9200) }, /* ASUS USB Sync */
321 { USB_DEVICE(0x0B05, 0x9202) }, /* ASUS USB Sync */ 321 { USB_DEVICE(0x0B05, 0x9202) }, /* ASUS USB Sync */
322 { USB_DEVICE(0x0BB4, 0x00CE) }, /* HTC USB Sync */ 322 { USB_DEVICE(0x0BB4, 0x00CE) }, /* HTC USB Sync */
323 { USB_DEVICE(0x0BB4, 0x00CF) }, /* HTC USB Modem */
323 { USB_DEVICE(0x0BB4, 0x0A01) }, /* PocketPC USB Sync */ 324 { USB_DEVICE(0x0BB4, 0x0A01) }, /* PocketPC USB Sync */
324 { USB_DEVICE(0x0BB4, 0x0A02) }, /* PocketPC USB Sync */ 325 { USB_DEVICE(0x0BB4, 0x0A02) }, /* PocketPC USB Sync */
325 { USB_DEVICE(0x0BB4, 0x0A03) }, /* PocketPC USB Sync */ 326 { USB_DEVICE(0x0BB4, 0x0A03) }, /* PocketPC USB Sync */
diff --git a/drivers/usb/serial/ipw.c b/drivers/usb/serial/ipw.c
index 2a4bb66691ad..d3b9a351cef8 100644
--- a/drivers/usb/serial/ipw.c
+++ b/drivers/usb/serial/ipw.c
@@ -206,10 +206,9 @@ static int ipw_open(struct usb_serial_port *port, struct file *filp)
206 206
207 dbg("%s", __FUNCTION__); 207 dbg("%s", __FUNCTION__);
208 208
209 buf_flow_init = kmalloc(16, GFP_KERNEL); 209 buf_flow_init = kmemdup(buf_flow_static, 16, GFP_KERNEL);
210 if (!buf_flow_init) 210 if (!buf_flow_init)
211 return -ENOMEM; 211 return -ENOMEM;
212 memcpy(buf_flow_init, buf_flow_static, 16);
213 212
214 if (port->tty) 213 if (port->tty)
215 port->tty->low_latency = 1; 214 port->tty->low_latency = 1;
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index 53be824eb1bf..7639652cec42 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -2306,22 +2306,16 @@ static void keyspan_shutdown (struct usb_serial *serial)
2306 } 2306 }
2307 2307
2308 /* Now free them */ 2308 /* Now free them */
2309 if (s_priv->instat_urb) 2309 usb_free_urb(s_priv->instat_urb);
2310 usb_free_urb(s_priv->instat_urb); 2310 usb_free_urb(s_priv->glocont_urb);
2311 if (s_priv->glocont_urb)
2312 usb_free_urb(s_priv->glocont_urb);
2313 for (i = 0; i < serial->num_ports; ++i) { 2311 for (i = 0; i < serial->num_ports; ++i) {
2314 port = serial->port[i]; 2312 port = serial->port[i];
2315 p_priv = usb_get_serial_port_data(port); 2313 p_priv = usb_get_serial_port_data(port);
2316 if (p_priv->inack_urb) 2314 usb_free_urb(p_priv->inack_urb);
2317 usb_free_urb(p_priv->inack_urb); 2315 usb_free_urb(p_priv->outcont_urb);
2318 if (p_priv->outcont_urb)
2319 usb_free_urb(p_priv->outcont_urb);
2320 for (j = 0; j < 2; j++) { 2316 for (j = 0; j < 2; j++) {
2321 if (p_priv->in_urbs[j]) 2317 usb_free_urb(p_priv->in_urbs[j]);
2322 usb_free_urb(p_priv->in_urbs[j]); 2318 usb_free_urb(p_priv->out_urbs[j]);
2323 if (p_priv->out_urbs[j])
2324 usb_free_urb(p_priv->out_urbs[j]);
2325 } 2319 }
2326 } 2320 }
2327 2321
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
index 909005107ea2..e09a0bfe6231 100644
--- a/drivers/usb/serial/keyspan_pda.c
+++ b/drivers/usb/serial/keyspan_pda.c
@@ -120,6 +120,8 @@ struct keyspan_pda_private {
120 int tx_throttled; 120 int tx_throttled;
121 struct work_struct wakeup_work; 121 struct work_struct wakeup_work;
122 struct work_struct unthrottle_work; 122 struct work_struct unthrottle_work;
123 struct usb_serial *serial;
124 struct usb_serial_port *port;
123}; 125};
124 126
125 127
@@ -175,9 +177,11 @@ static struct usb_device_id id_table_fake_xircom [] = {
175}; 177};
176#endif 178#endif
177 179
178static void keyspan_pda_wakeup_write( struct usb_serial_port *port ) 180static void keyspan_pda_wakeup_write(struct work_struct *work)
179{ 181{
180 182 struct keyspan_pda_private *priv =
183 container_of(work, struct keyspan_pda_private, wakeup_work);
184 struct usb_serial_port *port = priv->port;
181 struct tty_struct *tty = port->tty; 185 struct tty_struct *tty = port->tty;
182 186
183 /* wake up port processes */ 187 /* wake up port processes */
@@ -187,8 +191,11 @@ static void keyspan_pda_wakeup_write( struct usb_serial_port *port )
187 tty_wakeup(tty); 191 tty_wakeup(tty);
188} 192}
189 193
190static void keyspan_pda_request_unthrottle( struct usb_serial *serial ) 194static void keyspan_pda_request_unthrottle(struct work_struct *work)
191{ 195{
196 struct keyspan_pda_private *priv =
197 container_of(work, struct keyspan_pda_private, unthrottle_work);
198 struct usb_serial *serial = priv->serial;
192 int result; 199 int result;
193 200
194 dbg(" request_unthrottle"); 201 dbg(" request_unthrottle");
@@ -765,11 +772,10 @@ static int keyspan_pda_startup (struct usb_serial *serial)
765 return (1); /* error */ 772 return (1); /* error */
766 usb_set_serial_port_data(serial->port[0], priv); 773 usb_set_serial_port_data(serial->port[0], priv);
767 init_waitqueue_head(&serial->port[0]->write_wait); 774 init_waitqueue_head(&serial->port[0]->write_wait);
768 INIT_WORK(&priv->wakeup_work, (void *)keyspan_pda_wakeup_write, 775 INIT_WORK(&priv->wakeup_work, keyspan_pda_wakeup_write);
769 (void *)(serial->port[0])); 776 INIT_WORK(&priv->unthrottle_work, keyspan_pda_request_unthrottle);
770 INIT_WORK(&priv->unthrottle_work, 777 priv->serial = serial;
771 (void *)keyspan_pda_request_unthrottle, 778 priv->port = serial->port[0];
772 (void *)(serial));
773 return (0); 779 return (0);
774} 780}
775 781
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c
index ff03331e0bcf..237289920f03 100644
--- a/drivers/usb/serial/kobil_sct.c
+++ b/drivers/usb/serial/kobil_sct.c
@@ -185,13 +185,11 @@ static int kobil_startup (struct usb_serial *serial)
185 185
186 for (i = 0; i < altsetting->desc.bNumEndpoints; i++) { 186 for (i = 0; i < altsetting->desc.bNumEndpoints; i++) {
187 endpoint = &altsetting->endpoint[i]; 187 endpoint = &altsetting->endpoint[i];
188 if (((endpoint->desc.bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT) && 188 if (usb_endpoint_is_int_out(&endpoint->desc)) {
189 ((endpoint->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT)) {
190 dbg("%s Found interrupt out endpoint. Address: %d", __FUNCTION__, endpoint->desc.bEndpointAddress); 189 dbg("%s Found interrupt out endpoint. Address: %d", __FUNCTION__, endpoint->desc.bEndpointAddress);
191 priv->write_int_endpoint_address = endpoint->desc.bEndpointAddress; 190 priv->write_int_endpoint_address = endpoint->desc.bEndpointAddress;
192 } 191 }
193 if (((endpoint->desc.bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN) && 192 if (usb_endpoint_is_int_in(&endpoint->desc)) {
194 ((endpoint->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT)) {
195 dbg("%s Found interrupt in endpoint. Address: %d", __FUNCTION__, endpoint->desc.bEndpointAddress); 193 dbg("%s Found interrupt in endpoint. Address: %d", __FUNCTION__, endpoint->desc.bEndpointAddress);
196 priv->read_int_endpoint_address = endpoint->desc.bEndpointAddress; 194 priv->read_int_endpoint_address = endpoint->desc.bEndpointAddress;
197 } 195 }
@@ -355,8 +353,7 @@ static void kobil_close (struct usb_serial_port *port, struct file *filp)
355 usb_free_urb( port->write_urb ); 353 usb_free_urb( port->write_urb );
356 port->write_urb = NULL; 354 port->write_urb = NULL;
357 } 355 }
358 if (port->interrupt_in_urb) 356 usb_kill_urb(port->interrupt_in_urb);
359 usb_kill_urb(port->interrupt_in_urb);
360} 357}
361 358
362 359
diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c
index b7582cc496dc..a906e500a02b 100644
--- a/drivers/usb/serial/mct_u232.c
+++ b/drivers/usb/serial/mct_u232.c
@@ -358,10 +358,8 @@ static int mct_u232_startup (struct usb_serial *serial)
358 /* Puh, that's dirty */ 358 /* Puh, that's dirty */
359 port = serial->port[0]; 359 port = serial->port[0];
360 rport = serial->port[1]; 360 rport = serial->port[1];
361 if (port->read_urb) { 361 /* No unlinking, it wasn't submitted yet. */
362 /* No unlinking, it wasn't submitted yet. */ 362 usb_free_urb(port->read_urb);
363 usb_free_urb(port->read_urb);
364 }
365 port->read_urb = rport->interrupt_in_urb; 363 port->read_urb = rport->interrupt_in_urb;
366 rport->interrupt_in_urb = NULL; 364 rport->interrupt_in_urb = NULL;
367 port->read_urb->context = port; 365 port->read_urb->context = port;
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
index 82cd15b894b0..70f93b18292f 100644
--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -363,7 +363,7 @@ static int mos7720_open(struct usb_serial_port *port, struct file * filp)
363 363
364 /* Initialising the write urb pool */ 364 /* Initialising the write urb pool */
365 for (j = 0; j < NUM_URBS; ++j) { 365 for (j = 0; j < NUM_URBS; ++j) {
366 urb = usb_alloc_urb(0,SLAB_ATOMIC); 366 urb = usb_alloc_urb(0,GFP_ATOMIC);
367 mos7720_port->write_urb_pool[j] = urb; 367 mos7720_port->write_urb_pool[j] = urb;
368 368
369 if (urb == NULL) { 369 if (urb == NULL) {
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 5b71962d0351..5432c6340086 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -826,7 +826,7 @@ static int mos7840_open(struct usb_serial_port *port, struct file *filp)
826 826
827 /* Initialising the write urb pool */ 827 /* Initialising the write urb pool */
828 for (j = 0; j < NUM_URBS; ++j) { 828 for (j = 0; j < NUM_URBS; ++j) {
829 urb = usb_alloc_urb(0, SLAB_ATOMIC); 829 urb = usb_alloc_urb(0, GFP_ATOMIC);
830 mos7840_port->write_urb_pool[j] = urb; 830 mos7840_port->write_urb_pool[j] = urb;
831 831
832 if (urb == NULL) { 832 if (urb == NULL) {
@@ -2596,12 +2596,11 @@ static int mos7840_startup(struct usb_serial *serial)
2596 2596
2597 /* set up port private structures */ 2597 /* set up port private structures */
2598 for (i = 0; i < serial->num_ports; ++i) { 2598 for (i = 0; i < serial->num_ports; ++i) {
2599 mos7840_port = kmalloc(sizeof(struct moschip_port), GFP_KERNEL); 2599 mos7840_port = kzalloc(sizeof(struct moschip_port), GFP_KERNEL);
2600 if (mos7840_port == NULL) { 2600 if (mos7840_port == NULL) {
2601 err("%s - Out of memory", __FUNCTION__); 2601 err("%s - Out of memory", __FUNCTION__);
2602 return -ENOMEM; 2602 return -ENOMEM;
2603 } 2603 }
2604 memset(mos7840_port, 0, sizeof(struct moschip_port));
2605 2604
2606 /* Initialize all port interrupt end point to port 0 int endpoint * 2605 /* Initialize all port interrupt end point to port 0 int endpoint *
2607 * Our device has only one interrupt end point comman to all port */ 2606 * Our device has only one interrupt end point comman to all port */
@@ -2787,7 +2786,7 @@ static int mos7840_startup(struct usb_serial *serial)
2787 i + 1, status); 2786 i + 1, status);
2788 2787
2789 } 2788 }
2790 mos7840_port->control_urb = usb_alloc_urb(0, SLAB_ATOMIC); 2789 mos7840_port->control_urb = usb_alloc_urb(0, GFP_ATOMIC);
2791 mos7840_port->ctrl_buf = kmalloc(16, GFP_KERNEL); 2790 mos7840_port->ctrl_buf = kmalloc(16, GFP_KERNEL);
2792 2791
2793 } 2792 }
diff --git a/drivers/usb/serial/navman.c b/drivers/usb/serial/navman.c
index 0610409a6568..054abee81652 100644
--- a/drivers/usb/serial/navman.c
+++ b/drivers/usb/serial/navman.c
@@ -95,8 +95,7 @@ static void navman_close(struct usb_serial_port *port, struct file *filp)
95{ 95{
96 dbg("%s - port %d", __FUNCTION__, port->number); 96 dbg("%s - port %d", __FUNCTION__, port->number);
97 97
98 if (port->interrupt_in_urb) 98 usb_kill_urb(port->interrupt_in_urb);
99 usb_kill_urb(port->interrupt_in_urb);
100} 99}
101 100
102static int navman_write(struct usb_serial_port *port, 101static int navman_write(struct usb_serial_port *port,
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index 07400c0c8a8c..ae98d8cbdbb8 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -228,6 +228,7 @@ static int product_5052_count;
228/* null entry */ 228/* null entry */
229static struct usb_device_id ti_id_table_3410[1+TI_EXTRA_VID_PID_COUNT+1] = { 229static struct usb_device_id ti_id_table_3410[1+TI_EXTRA_VID_PID_COUNT+1] = {
230 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) }, 230 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) },
231 { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) },
231}; 232};
232 233
233static struct usb_device_id ti_id_table_5052[4+TI_EXTRA_VID_PID_COUNT+1] = { 234static struct usb_device_id ti_id_table_5052[4+TI_EXTRA_VID_PID_COUNT+1] = {
@@ -239,6 +240,7 @@ static struct usb_device_id ti_id_table_5052[4+TI_EXTRA_VID_PID_COUNT+1] = {
239 240
240static struct usb_device_id ti_id_table_combined[] = { 241static struct usb_device_id ti_id_table_combined[] = {
241 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) }, 242 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) },
243 { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) },
242 { USB_DEVICE(TI_VENDOR_ID, TI_5052_BOOT_PRODUCT_ID) }, 244 { USB_DEVICE(TI_VENDOR_ID, TI_5052_BOOT_PRODUCT_ID) },
243 { USB_DEVICE(TI_VENDOR_ID, TI_5152_BOOT_PRODUCT_ID) }, 245 { USB_DEVICE(TI_VENDOR_ID, TI_5152_BOOT_PRODUCT_ID) },
244 { USB_DEVICE(TI_VENDOR_ID, TI_5052_EEPROM_PRODUCT_ID) }, 246 { USB_DEVICE(TI_VENDOR_ID, TI_5052_EEPROM_PRODUCT_ID) },
@@ -459,13 +461,12 @@ static int ti_startup(struct usb_serial *serial)
459 461
460 /* set up port structures */ 462 /* set up port structures */
461 for (i = 0; i < serial->num_ports; ++i) { 463 for (i = 0; i < serial->num_ports; ++i) {
462 tport = kmalloc(sizeof(struct ti_port), GFP_KERNEL); 464 tport = kzalloc(sizeof(struct ti_port), GFP_KERNEL);
463 if (tport == NULL) { 465 if (tport == NULL) {
464 dev_err(&dev->dev, "%s - out of memory\n", __FUNCTION__); 466 dev_err(&dev->dev, "%s - out of memory\n", __FUNCTION__);
465 status = -ENOMEM; 467 status = -ENOMEM;
466 goto free_tports; 468 goto free_tports;
467 } 469 }
468 memset(tport, 0, sizeof(struct ti_port));
469 spin_lock_init(&tport->tp_lock); 470 spin_lock_init(&tport->tp_lock);
470 tport->tp_uart_base_addr = (i == 0 ? TI_UART1_BASE_ADDR : TI_UART2_BASE_ADDR); 471 tport->tp_uart_base_addr = (i == 0 ? TI_UART1_BASE_ADDR : TI_UART2_BASE_ADDR);
471 tport->tp_flags = low_latency ? ASYNC_LOW_LATENCY : 0; 472 tport->tp_flags = low_latency ? ASYNC_LOW_LATENCY : 0;
diff --git a/drivers/usb/serial/ti_usb_3410_5052.h b/drivers/usb/serial/ti_usb_3410_5052.h
index 02c1aeb9e1b8..b5541bf991ba 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.h
+++ b/drivers/usb/serial/ti_usb_3410_5052.h
@@ -28,6 +28,7 @@
28/* Vendor and product ids */ 28/* Vendor and product ids */
29#define TI_VENDOR_ID 0x0451 29#define TI_VENDOR_ID 0x0451
30#define TI_3410_PRODUCT_ID 0x3410 30#define TI_3410_PRODUCT_ID 0x3410
31#define TI_3410_EZ430_ID 0xF430 /* TI ez430 development tool */
31#define TI_5052_BOOT_PRODUCT_ID 0x5052 /* no EEPROM, no firmware */ 32#define TI_5052_BOOT_PRODUCT_ID 0x5052 /* no EEPROM, no firmware */
32#define TI_5152_BOOT_PRODUCT_ID 0x5152 /* no EEPROM, no firmware */ 33#define TI_5152_BOOT_PRODUCT_ID 0x5152 /* no EEPROM, no firmware */
33#define TI_5052_EEPROM_PRODUCT_ID 0x505A /* EEPROM, no firmware */ 34#define TI_5052_EEPROM_PRODUCT_ID 0x505A /* EEPROM, no firmware */
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 8006e51c34bb..3d5072f14b8d 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -533,9 +533,10 @@ void usb_serial_port_softint(struct usb_serial_port *port)
533 schedule_work(&port->work); 533 schedule_work(&port->work);
534} 534}
535 535
536static void usb_serial_port_work(void *private) 536static void usb_serial_port_work(struct work_struct *work)
537{ 537{
538 struct usb_serial_port *port = private; 538 struct usb_serial_port *port =
539 container_of(work, struct usb_serial_port, work);
539 struct tty_struct *tty; 540 struct tty_struct *tty;
540 541
541 dbg("%s - port %d", __FUNCTION__, port->number); 542 dbg("%s - port %d", __FUNCTION__, port->number);
@@ -799,7 +800,7 @@ int usb_serial_probe(struct usb_interface *interface,
799 port->serial = serial; 800 port->serial = serial;
800 spin_lock_init(&port->lock); 801 spin_lock_init(&port->lock);
801 mutex_init(&port->mutex); 802 mutex_init(&port->mutex);
802 INIT_WORK(&port->work, usb_serial_port_work, port); 803 INIT_WORK(&port->work, usb_serial_port_work);
803 serial->port[i] = port; 804 serial->port[i] = port;
804 } 805 }
805 806
@@ -952,32 +953,28 @@ probe_error:
952 port = serial->port[i]; 953 port = serial->port[i];
953 if (!port) 954 if (!port)
954 continue; 955 continue;
955 if (port->read_urb) 956 usb_free_urb(port->read_urb);
956 usb_free_urb (port->read_urb);
957 kfree(port->bulk_in_buffer); 957 kfree(port->bulk_in_buffer);
958 } 958 }
959 for (i = 0; i < num_bulk_out; ++i) { 959 for (i = 0; i < num_bulk_out; ++i) {
960 port = serial->port[i]; 960 port = serial->port[i];
961 if (!port) 961 if (!port)
962 continue; 962 continue;
963 if (port->write_urb) 963 usb_free_urb(port->write_urb);
964 usb_free_urb (port->write_urb);
965 kfree(port->bulk_out_buffer); 964 kfree(port->bulk_out_buffer);
966 } 965 }
967 for (i = 0; i < num_interrupt_in; ++i) { 966 for (i = 0; i < num_interrupt_in; ++i) {
968 port = serial->port[i]; 967 port = serial->port[i];
969 if (!port) 968 if (!port)
970 continue; 969 continue;
971 if (port->interrupt_in_urb) 970 usb_free_urb(port->interrupt_in_urb);
972 usb_free_urb (port->interrupt_in_urb);
973 kfree(port->interrupt_in_buffer); 971 kfree(port->interrupt_in_buffer);
974 } 972 }
975 for (i = 0; i < num_interrupt_out; ++i) { 973 for (i = 0; i < num_interrupt_out; ++i) {
976 port = serial->port[i]; 974 port = serial->port[i];
977 if (!port) 975 if (!port)
978 continue; 976 continue;
979 if (port->interrupt_out_urb) 977 usb_free_urb(port->interrupt_out_urb);
980 usb_free_urb (port->interrupt_out_urb);
981 kfree(port->interrupt_out_buffer); 978 kfree(port->interrupt_out_buffer);
982 } 979 }
983 980
diff --git a/drivers/usb/serial/usb_debug.c b/drivers/usb/serial/usb_debug.c
new file mode 100644
index 000000000000..257a5e436873
--- /dev/null
+++ b/drivers/usb/serial/usb_debug.c
@@ -0,0 +1,65 @@
1/*
2 * USB Debug cable driver
3 *
4 * Copyright (C) 2006 Greg Kroah-Hartman <greg@kroah.com>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
9 */
10
11#include <linux/kernel.h>
12#include <linux/init.h>
13#include <linux/tty.h>
14#include <linux/module.h>
15#include <linux/usb.h>
16#include <linux/usb/serial.h>
17
18static struct usb_device_id id_table [] = {
19 { USB_DEVICE(0x0525, 0x127a) },
20 { },
21};
22MODULE_DEVICE_TABLE(usb, id_table);
23
24static struct usb_driver debug_driver = {
25 .name = "debug",
26 .probe = usb_serial_probe,
27 .disconnect = usb_serial_disconnect,
28 .id_table = id_table,
29 .no_dynamic_id = 1,
30};
31
32static struct usb_serial_driver debug_device = {
33 .driver = {
34 .owner = THIS_MODULE,
35 .name = "debug",
36 },
37 .id_table = id_table,
38 .num_interrupt_in = NUM_DONT_CARE,
39 .num_bulk_in = NUM_DONT_CARE,
40 .num_bulk_out = NUM_DONT_CARE,
41 .num_ports = 1,
42};
43
44static int __init debug_init(void)
45{
46 int retval;
47
48 retval = usb_serial_register(&debug_device);
49 if (retval)
50 return retval;
51 retval = usb_register(&debug_driver);
52 if (retval)
53 usb_serial_deregister(&debug_device);
54 return retval;
55}
56
57static void __exit debug_exit(void)
58{
59 usb_deregister(&debug_driver);
60 usb_serial_deregister(&debug_device);
61}
62
63module_init(debug_init);
64module_exit(debug_exit);
65MODULE_LICENSE("GPL");
diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
index befe2e11a041..eef5eaa5fa0b 100644
--- a/drivers/usb/serial/visor.c
+++ b/drivers/usb/serial/visor.c
@@ -348,8 +348,7 @@ static void visor_close (struct usb_serial_port *port, struct file * filp)
348 348
349 /* shutdown our urbs */ 349 /* shutdown our urbs */
350 usb_kill_urb(port->read_urb); 350 usb_kill_urb(port->read_urb);
351 if (port->interrupt_in_urb) 351 usb_kill_urb(port->interrupt_in_urb);
352 usb_kill_urb(port->interrupt_in_urb);
353 352
354 /* Try to send shutdown message, if the device is gone, this will just fail. */ 353 /* Try to send shutdown message, if the device is gone, this will just fail. */
355 transfer_buffer = kmalloc (0x12, GFP_KERNEL); 354 transfer_buffer = kmalloc (0x12, GFP_KERNEL);
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
index 4d1cd7aeccd3..154c7d290597 100644
--- a/drivers/usb/serial/whiteheat.c
+++ b/drivers/usb/serial/whiteheat.c
@@ -227,6 +227,7 @@ struct whiteheat_private {
227 struct list_head rx_urbs_submitted; 227 struct list_head rx_urbs_submitted;
228 struct list_head rx_urb_q; 228 struct list_head rx_urb_q;
229 struct work_struct rx_work; 229 struct work_struct rx_work;
230 struct usb_serial_port *port;
230 struct list_head tx_urbs_free; 231 struct list_head tx_urbs_free;
231 struct list_head tx_urbs_submitted; 232 struct list_head tx_urbs_submitted;
232}; 233};
@@ -241,7 +242,7 @@ static void command_port_read_callback(struct urb *urb);
241static int start_port_read(struct usb_serial_port *port); 242static int start_port_read(struct usb_serial_port *port);
242static struct whiteheat_urb_wrap *urb_to_wrap(struct urb *urb, struct list_head *head); 243static struct whiteheat_urb_wrap *urb_to_wrap(struct urb *urb, struct list_head *head);
243static struct list_head *list_first(struct list_head *head); 244static struct list_head *list_first(struct list_head *head);
244static void rx_data_softint(void *private); 245static void rx_data_softint(struct work_struct *work);
245 246
246static int firm_send_command(struct usb_serial_port *port, __u8 command, __u8 *data, __u8 datasize); 247static int firm_send_command(struct usb_serial_port *port, __u8 command, __u8 *data, __u8 datasize);
247static int firm_open(struct usb_serial_port *port); 248static int firm_open(struct usb_serial_port *port);
@@ -424,7 +425,8 @@ static int whiteheat_attach (struct usb_serial *serial)
424 spin_lock_init(&info->lock); 425 spin_lock_init(&info->lock);
425 info->flags = 0; 426 info->flags = 0;
426 info->mcr = 0; 427 info->mcr = 0;
427 INIT_WORK(&info->rx_work, rx_data_softint, port); 428 INIT_WORK(&info->rx_work, rx_data_softint);
429 info->port = port;
428 430
429 INIT_LIST_HEAD(&info->rx_urbs_free); 431 INIT_LIST_HEAD(&info->rx_urbs_free);
430 INIT_LIST_HEAD(&info->rx_urbs_submitted); 432 INIT_LIST_HEAD(&info->rx_urbs_submitted);
@@ -949,7 +951,7 @@ static void whiteheat_unthrottle (struct usb_serial_port *port)
949 spin_unlock_irqrestore(&info->lock, flags); 951 spin_unlock_irqrestore(&info->lock, flags);
950 952
951 if (actually_throttled) 953 if (actually_throttled)
952 rx_data_softint(port); 954 rx_data_softint(&info->rx_work);
953 955
954 return; 956 return;
955} 957}
@@ -1400,10 +1402,11 @@ static struct list_head *list_first(struct list_head *head)
1400} 1402}
1401 1403
1402 1404
1403static void rx_data_softint(void *private) 1405static void rx_data_softint(struct work_struct *work)
1404{ 1406{
1405 struct usb_serial_port *port = (struct usb_serial_port *)private; 1407 struct whiteheat_private *info =
1406 struct whiteheat_private *info = usb_get_serial_port_data(port); 1408 container_of(work, struct whiteheat_private, rx_work);
1409 struct usb_serial_port *port = info->port;
1407 struct tty_struct *tty = port->tty; 1410 struct tty_struct *tty = port->tty;
1408 struct whiteheat_urb_wrap *wrap; 1411 struct whiteheat_urb_wrap *wrap;
1409 struct urb *urb; 1412 struct urb *urb;
diff --git a/drivers/usb/storage/onetouch.c b/drivers/usb/storage/onetouch.c
index 3baf448e300d..e565d3d2ab29 100644
--- a/drivers/usb/storage/onetouch.c
+++ b/drivers/usb/storage/onetouch.c
@@ -76,7 +76,7 @@ static void usb_onetouch_irq(struct urb *urb)
76 input_sync(dev); 76 input_sync(dev);
77 77
78resubmit: 78resubmit:
79 status = usb_submit_urb (urb, SLAB_ATOMIC); 79 status = usb_submit_urb (urb, GFP_ATOMIC);
80 if (status) 80 if (status)
81 err ("can't resubmit intr, %s-%s/input0, status %d", 81 err ("can't resubmit intr, %s-%s/input0, status %d",
82 onetouch->udev->bus->bus_name, 82 onetouch->udev->bus->bus_name,
@@ -142,10 +142,7 @@ int onetouch_connect_input(struct us_data *ss)
142 return -ENODEV; 142 return -ENODEV;
143 143
144 endpoint = &interface->endpoint[2].desc; 144 endpoint = &interface->endpoint[2].desc;
145 if (!(endpoint->bEndpointAddress & USB_DIR_IN)) 145 if (!usb_endpoint_is_int_in(endpoint))
146 return -ENODEV;
147 if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
148 != USB_ENDPOINT_XFER_INT)
149 return -ENODEV; 146 return -ENODEV;
150 147
151 pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress); 148 pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress);
@@ -157,7 +154,7 @@ int onetouch_connect_input(struct us_data *ss)
157 goto fail1; 154 goto fail1;
158 155
159 onetouch->data = usb_buffer_alloc(udev, ONETOUCH_PKT_LEN, 156 onetouch->data = usb_buffer_alloc(udev, ONETOUCH_PKT_LEN,
160 SLAB_ATOMIC, &onetouch->data_dma); 157 GFP_ATOMIC, &onetouch->data_dma);
161 if (!onetouch->data) 158 if (!onetouch->data)
162 goto fail1; 159 goto fail1;
163 160
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index 47644b5b6155..323293a3e61f 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -427,7 +427,7 @@ static int usb_stor_bulk_transfer_sglist(struct us_data *us, unsigned int pipe,
427 US_DEBUGP("%s: xfer %u bytes, %d entries\n", __FUNCTION__, 427 US_DEBUGP("%s: xfer %u bytes, %d entries\n", __FUNCTION__,
428 length, num_sg); 428 length, num_sg);
429 result = usb_sg_init(&us->current_sg, us->pusb_dev, pipe, 0, 429 result = usb_sg_init(&us->current_sg, us->pusb_dev, pipe, 0,
430 sg, num_sg, length, SLAB_NOIO); 430 sg, num_sg, length, GFP_NOIO);
431 if (result) { 431 if (result) {
432 US_DEBUGP("usb_sg_init returned %d\n", result); 432 US_DEBUGP("usb_sg_init returned %d\n", result);
433 return USB_STOR_XFER_ERROR; 433 return USB_STOR_XFER_ERROR;
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index bc1ac07bf6ce..db8b26012c75 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -1306,30 +1306,28 @@ UNUSUAL_DEV( 0x0fce, 0xe030, 0x0000, 0x0000,
1306 US_SC_DEVICE, US_PR_DEVICE, NULL, 1306 US_SC_DEVICE, US_PR_DEVICE, NULL,
1307 US_FL_FIX_CAPACITY ), 1307 US_FL_FIX_CAPACITY ),
1308 1308
1309/* Reported by Jan Mate <mate@fiit.stuba.sk> */
1310UNUSUAL_DEV( 0x0fce, 0xe030, 0x0000, 0x0000,
1311 "Sony Ericsson",
1312 "P990i",
1313 US_SC_DEVICE, US_PR_DEVICE, NULL,
1314 US_FL_FIX_CAPACITY ),
1315
1316/* Reported by Jan Mate <mate@fiit.stuba.sk> */
1317UNUSUAL_DEV( 0x0fce, 0xe030, 0x0000, 0x0000,
1318 "Sony Ericsson",
1319 "P990i",
1320 US_SC_DEVICE, US_PR_DEVICE, NULL,
1321 US_FL_FIX_CAPACITY ),
1322
1323/* Reported by Kevin Cernekee <kpc-usbdev@gelato.uiuc.edu> 1309/* Reported by Kevin Cernekee <kpc-usbdev@gelato.uiuc.edu>
1324 * Tested on hardware version 1.10. 1310 * Tested on hardware version 1.10.
1325 * Entry is needed only for the initializer function override. 1311 * Entry is needed only for the initializer function override.
1312 * Devices with bcd > 110 seem to not need it while those
1313 * with bcd < 110 appear to need it.
1326 */ 1314 */
1327UNUSUAL_DEV( 0x1019, 0x0c55, 0x0110, 0x0110, 1315UNUSUAL_DEV( 0x1019, 0x0c55, 0x0000, 0x0110,
1328 "Desknote", 1316 "Desknote",
1329 "UCR-61S2B", 1317 "UCR-61S2B",
1330 US_SC_DEVICE, US_PR_DEVICE, usb_stor_ucr61s2b_init, 1318 US_SC_DEVICE, US_PR_DEVICE, usb_stor_ucr61s2b_init,
1331 0 ), 1319 0 ),
1332 1320
1321/* Reported by Jaco Kroon <jaco@kroon.co.za>
1322 * The usb-storage module found on the Digitech GNX4 (and supposedly other
1323 * devices) misbehaves and causes a bunch of invalid I/O errors.
1324 */
1325UNUSUAL_DEV( 0x1210, 0x0003, 0x0100, 0x0100,
1326 "Digitech HMG",
1327 "DigiTech Mass Storage",
1328 US_SC_DEVICE, US_PR_DEVICE, NULL,
1329 US_FL_IGNORE_RESIDUE ),
1330
1333/* Reported by Vilius Bilinkevicius <vilisas AT xxx DOT lt) */ 1331/* Reported by Vilius Bilinkevicius <vilisas AT xxx DOT lt) */
1334UNUSUAL_DEV( 0x132b, 0x000b, 0x0001, 0x0001, 1332UNUSUAL_DEV( 0x132b, 0x000b, 0x0001, 0x0001,
1335 "Minolta", 1333 "Minolta",
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index b8d6031b0975..70644506651f 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -49,7 +49,7 @@
49 49
50#include <linux/sched.h> 50#include <linux/sched.h>
51#include <linux/errno.h> 51#include <linux/errno.h>
52#include <linux/suspend.h> 52#include <linux/freezer.h>
53#include <linux/module.h> 53#include <linux/module.h>
54#include <linux/init.h> 54#include <linux/init.h>
55#include <linux/slab.h> 55#include <linux/slab.h>
@@ -740,18 +740,16 @@ static int get_pipes(struct us_data *us)
740 ep = &altsetting->endpoint[i].desc; 740 ep = &altsetting->endpoint[i].desc;
741 741
742 /* Is it a BULK endpoint? */ 742 /* Is it a BULK endpoint? */
743 if ((ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) 743 if (usb_endpoint_xfer_bulk(ep)) {
744 == USB_ENDPOINT_XFER_BULK) {
745 /* BULK in or out? */ 744 /* BULK in or out? */
746 if (ep->bEndpointAddress & USB_DIR_IN) 745 if (usb_endpoint_dir_in(ep))
747 ep_in = ep; 746 ep_in = ep;
748 else 747 else
749 ep_out = ep; 748 ep_out = ep;
750 } 749 }
751 750
752 /* Is it an interrupt endpoint? */ 751 /* Is it an interrupt endpoint? */
753 else if ((ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) 752 else if (usb_endpoint_xfer_int(ep)) {
754 == USB_ENDPOINT_XFER_INT) {
755 ep_int = ep; 753 ep_int = ep;
756 } 754 }
757 } 755 }
diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
index b77b30923928..e815b354c09d 100644
--- a/drivers/video/aty/atyfb_base.c
+++ b/drivers/video/aty/atyfb_base.c
@@ -406,7 +406,7 @@ static struct {
406 { PCI_CHIP_MACH64LB, "3D RAGE LT PRO (Mach64 LB, AGP)", 236, 75, 100, 135, ATI_CHIP_264LTPRO }, 406 { PCI_CHIP_MACH64LB, "3D RAGE LT PRO (Mach64 LB, AGP)", 236, 75, 100, 135, ATI_CHIP_264LTPRO },
407 { PCI_CHIP_MACH64LD, "3D RAGE LT PRO (Mach64 LD, AGP)", 230, 100, 100, 135, ATI_CHIP_264LTPRO }, 407 { PCI_CHIP_MACH64LD, "3D RAGE LT PRO (Mach64 LD, AGP)", 230, 100, 100, 135, ATI_CHIP_264LTPRO },
408 { PCI_CHIP_MACH64LI, "3D RAGE LT PRO (Mach64 LI, PCI)", 230, 100, 100, 135, ATI_CHIP_264LTPRO | M64F_G3_PB_1_1 | M64F_G3_PB_1024x768 }, 408 { PCI_CHIP_MACH64LI, "3D RAGE LT PRO (Mach64 LI, PCI)", 230, 100, 100, 135, ATI_CHIP_264LTPRO | M64F_G3_PB_1_1 | M64F_G3_PB_1024x768 },
409 { PCI_CHIP_MACH64LP, "3D RAGE LT PRO (Mach64 LP, PCI)", 230, 100, 100, 135, ATI_CHIP_264LTPRO }, 409 { PCI_CHIP_MACH64LP, "3D RAGE LT PRO (Mach64 LP, PCI)", 230, 100, 100, 135, ATI_CHIP_264LTPRO | M64F_G3_PB_1024x768 },
410 { PCI_CHIP_MACH64LQ, "3D RAGE LT PRO (Mach64 LQ, PCI)", 230, 100, 100, 135, ATI_CHIP_264LTPRO }, 410 { PCI_CHIP_MACH64LQ, "3D RAGE LT PRO (Mach64 LQ, PCI)", 230, 100, 100, 135, ATI_CHIP_264LTPRO },
411 411
412 { PCI_CHIP_MACH64GM, "3D RAGE XL (Mach64 GM, AGP 2x)", 230, 83, 63, 135, ATI_CHIP_264XL }, 412 { PCI_CHIP_MACH64GM, "3D RAGE XL (Mach64 GM, AGP 2x)", 230, 83, 63, 135, ATI_CHIP_264XL },
diff --git a/drivers/video/aty/radeon_i2c.c b/drivers/video/aty/radeon_i2c.c
index 676754520099..869725a13c21 100644
--- a/drivers/video/aty/radeon_i2c.c
+++ b/drivers/video/aty/radeon_i2c.c
@@ -139,7 +139,13 @@ void radeon_delete_i2c_busses(struct radeonfb_info *rinfo)
139int radeon_probe_i2c_connector(struct radeonfb_info *rinfo, int conn, 139int radeon_probe_i2c_connector(struct radeonfb_info *rinfo, int conn,
140 u8 **out_edid) 140 u8 **out_edid)
141{ 141{
142 u8 *edid = fb_ddc_read(&rinfo->i2c[conn-1].adapter); 142 u32 reg = rinfo->i2c[conn-1].ddc_reg;
143 u8 *edid;
144
145 OUTREG(reg, INREG(reg) &
146 ~(VGA_DDC_DATA_OUTPUT | VGA_DDC_CLK_OUTPUT));
147
148 edid = fb_ddc_read(&rinfo->i2c[conn-1].adapter);
143 149
144 if (out_edid) 150 if (out_edid)
145 *out_edid = edid; 151 *out_edid = edid;
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index 302174b8e477..31f476a64790 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -383,9 +383,9 @@ static void fbcon_update_softback(struct vc_data *vc)
383 softback_top = 0; 383 softback_top = 0;
384} 384}
385 385
386static void fb_flashcursor(void *private) 386static void fb_flashcursor(struct work_struct *work)
387{ 387{
388 struct fb_info *info = private; 388 struct fb_info *info = container_of(work, struct fb_info, queue);
389 struct fbcon_ops *ops = info->fbcon_par; 389 struct fbcon_ops *ops = info->fbcon_par;
390 struct display *p; 390 struct display *p;
391 struct vc_data *vc = NULL; 391 struct vc_data *vc = NULL;
@@ -442,7 +442,7 @@ static void fbcon_add_cursor_timer(struct fb_info *info)
442 if ((!info->queue.func || info->queue.func == fb_flashcursor) && 442 if ((!info->queue.func || info->queue.func == fb_flashcursor) &&
443 !(ops->flags & FBCON_FLAGS_CURSOR_TIMER)) { 443 !(ops->flags & FBCON_FLAGS_CURSOR_TIMER)) {
444 if (!info->queue.func) 444 if (!info->queue.func)
445 INIT_WORK(&info->queue, fb_flashcursor, info); 445 INIT_WORK(&info->queue, fb_flashcursor);
446 446
447 init_timer(&ops->cursor_timer); 447 init_timer(&ops->cursor_timer);
448 ops->cursor_timer.function = cursor_timer_handler; 448 ops->cursor_timer.function = cursor_timer_handler;
diff --git a/drivers/video/fb_ddc.c b/drivers/video/fb_ddc.c
index 3aa6ebf68f17..f836137a0eda 100644
--- a/drivers/video/fb_ddc.c
+++ b/drivers/video/fb_ddc.c
@@ -20,26 +20,26 @@
20static unsigned char *fb_do_probe_ddc_edid(struct i2c_adapter *adapter) 20static unsigned char *fb_do_probe_ddc_edid(struct i2c_adapter *adapter)
21{ 21{
22 unsigned char start = 0x0; 22 unsigned char start = 0x0;
23 unsigned char *buf = kmalloc(EDID_LENGTH, GFP_KERNEL);
23 struct i2c_msg msgs[] = { 24 struct i2c_msg msgs[] = {
24 { 25 {
25 .addr = DDC_ADDR, 26 .addr = DDC_ADDR,
27 .flags = 0,
26 .len = 1, 28 .len = 1,
27 .buf = &start, 29 .buf = &start,
28 }, { 30 }, {
29 .addr = DDC_ADDR, 31 .addr = DDC_ADDR,
30 .flags = I2C_M_RD, 32 .flags = I2C_M_RD,
31 .len = EDID_LENGTH, 33 .len = EDID_LENGTH,
34 .buf = buf,
32 } 35 }
33 }; 36 };
34 unsigned char *buf;
35 37
36 buf = kmalloc(EDID_LENGTH, GFP_KERNEL);
37 if (!buf) { 38 if (!buf) {
38 dev_warn(&adapter->dev, "unable to allocate memory for EDID " 39 dev_warn(&adapter->dev, "unable to allocate memory for EDID "
39 "block.\n"); 40 "block.\n");
40 return NULL; 41 return NULL;
41 } 42 }
42 msgs[1].buf = buf;
43 43
44 if (i2c_transfer(adapter, msgs, 2) == 2) 44 if (i2c_transfer(adapter, msgs, 2) == 2)
45 return buf; 45 return buf;
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 93ffcdd95f50..e973a87fbb01 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -1296,14 +1296,14 @@ register_framebuffer(struct fb_info *fb_info)
1296 break; 1296 break;
1297 fb_info->node = i; 1297 fb_info->node = i;
1298 1298
1299 fb_info->class_device = class_device_create(fb_class, NULL, MKDEV(FB_MAJOR, i), 1299 fb_info->dev = device_create(fb_class, fb_info->device,
1300 fb_info->device, "fb%d", i); 1300 MKDEV(FB_MAJOR, i), "fb%d", i);
1301 if (IS_ERR(fb_info->class_device)) { 1301 if (IS_ERR(fb_info->dev)) {
1302 /* Not fatal */ 1302 /* Not fatal */
1303 printk(KERN_WARNING "Unable to create class_device for framebuffer %d; errno = %ld\n", i, PTR_ERR(fb_info->class_device)); 1303 printk(KERN_WARNING "Unable to create device for framebuffer %d; errno = %ld\n", i, PTR_ERR(fb_info->dev));
1304 fb_info->class_device = NULL; 1304 fb_info->dev = NULL;
1305 } else 1305 } else
1306 fb_init_class_device(fb_info); 1306 fb_init_device(fb_info);
1307 1307
1308 if (fb_info->pixmap.addr == NULL) { 1308 if (fb_info->pixmap.addr == NULL) {
1309 fb_info->pixmap.addr = kmalloc(FBPIXMAPSIZE, GFP_KERNEL); 1309 fb_info->pixmap.addr = kmalloc(FBPIXMAPSIZE, GFP_KERNEL);
@@ -1356,8 +1356,8 @@ unregister_framebuffer(struct fb_info *fb_info)
1356 fb_destroy_modelist(&fb_info->modelist); 1356 fb_destroy_modelist(&fb_info->modelist);
1357 registered_fb[i]=NULL; 1357 registered_fb[i]=NULL;
1358 num_registered_fb--; 1358 num_registered_fb--;
1359 fb_cleanup_class_device(fb_info); 1359 fb_cleanup_device(fb_info);
1360 class_device_destroy(fb_class, MKDEV(FB_MAJOR, i)); 1360 device_destroy(fb_class, MKDEV(FB_MAJOR, i));
1361 event.info = fb_info; 1361 event.info = fb_info;
1362 fb_notifier_call_chain(FB_EVENT_FB_UNREGISTERED, &event); 1362 fb_notifier_call_chain(FB_EVENT_FB_UNREGISTERED, &event);
1363 return 0; 1363 return 0;
diff --git a/drivers/video/fbsysfs.c b/drivers/video/fbsysfs.c
index d3a50417ed9a..323bdf6fc7d5 100644
--- a/drivers/video/fbsysfs.c
+++ b/drivers/video/fbsysfs.c
@@ -73,7 +73,7 @@ EXPORT_SYMBOL(framebuffer_alloc);
73 * 73 *
74 * @info: frame buffer info structure 74 * @info: frame buffer info structure
75 * 75 *
76 * Drop the reference count of the class_device embedded in the 76 * Drop the reference count of the device embedded in the
77 * framebuffer info structure. 77 * framebuffer info structure.
78 * 78 *
79 */ 79 */
@@ -120,10 +120,10 @@ static int mode_string(char *buf, unsigned int offset,
120 m, mode->xres, mode->yres, v, mode->refresh); 120 m, mode->xres, mode->yres, v, mode->refresh);
121} 121}
122 122
123static ssize_t store_mode(struct class_device *class_device, const char * buf, 123static ssize_t store_mode(struct device *device, struct device_attribute *attr,
124 size_t count) 124 const char *buf, size_t count)
125{ 125{
126 struct fb_info *fb_info = class_get_devdata(class_device); 126 struct fb_info *fb_info = dev_get_drvdata(device);
127 char mstr[100]; 127 char mstr[100];
128 struct fb_var_screeninfo var; 128 struct fb_var_screeninfo var;
129 struct fb_modelist *modelist; 129 struct fb_modelist *modelist;
@@ -151,9 +151,10 @@ static ssize_t store_mode(struct class_device *class_device, const char * buf,
151 return -EINVAL; 151 return -EINVAL;
152} 152}
153 153
154static ssize_t show_mode(struct class_device *class_device, char *buf) 154static ssize_t show_mode(struct device *device, struct device_attribute *attr,
155 char *buf)
155{ 156{
156 struct fb_info *fb_info = class_get_devdata(class_device); 157 struct fb_info *fb_info = dev_get_drvdata(device);
157 158
158 if (!fb_info->mode) 159 if (!fb_info->mode)
159 return 0; 160 return 0;
@@ -161,10 +162,11 @@ static ssize_t show_mode(struct class_device *class_device, char *buf)
161 return mode_string(buf, 0, fb_info->mode); 162 return mode_string(buf, 0, fb_info->mode);
162} 163}
163 164
164static ssize_t store_modes(struct class_device *class_device, const char * buf, 165static ssize_t store_modes(struct device *device,
165 size_t count) 166 struct device_attribute *attr,
167 const char *buf, size_t count)
166{ 168{
167 struct fb_info *fb_info = class_get_devdata(class_device); 169 struct fb_info *fb_info = dev_get_drvdata(device);
168 LIST_HEAD(old_list); 170 LIST_HEAD(old_list);
169 int i = count / sizeof(struct fb_videomode); 171 int i = count / sizeof(struct fb_videomode);
170 172
@@ -186,9 +188,10 @@ static ssize_t store_modes(struct class_device *class_device, const char * buf,
186 return 0; 188 return 0;
187} 189}
188 190
189static ssize_t show_modes(struct class_device *class_device, char *buf) 191static ssize_t show_modes(struct device *device, struct device_attribute *attr,
192 char *buf)
190{ 193{
191 struct fb_info *fb_info = class_get_devdata(class_device); 194 struct fb_info *fb_info = dev_get_drvdata(device);
192 unsigned int i; 195 unsigned int i;
193 struct list_head *pos; 196 struct list_head *pos;
194 struct fb_modelist *modelist; 197 struct fb_modelist *modelist;
@@ -203,10 +206,10 @@ static ssize_t show_modes(struct class_device *class_device, char *buf)
203 return i; 206 return i;
204} 207}
205 208
206static ssize_t store_bpp(struct class_device *class_device, const char * buf, 209static ssize_t store_bpp(struct device *device, struct device_attribute *attr,
207 size_t count) 210 const char *buf, size_t count)
208{ 211{
209 struct fb_info *fb_info = class_get_devdata(class_device); 212 struct fb_info *fb_info = dev_get_drvdata(device);
210 struct fb_var_screeninfo var; 213 struct fb_var_screeninfo var;
211 char ** last = NULL; 214 char ** last = NULL;
212 int err; 215 int err;
@@ -218,16 +221,18 @@ static ssize_t store_bpp(struct class_device *class_device, const char * buf,
218 return count; 221 return count;
219} 222}
220 223
221static ssize_t show_bpp(struct class_device *class_device, char *buf) 224static ssize_t show_bpp(struct device *device, struct device_attribute *attr,
225 char *buf)
222{ 226{
223 struct fb_info *fb_info = class_get_devdata(class_device); 227 struct fb_info *fb_info = dev_get_drvdata(device);
224 return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->var.bits_per_pixel); 228 return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->var.bits_per_pixel);
225} 229}
226 230
227static ssize_t store_rotate(struct class_device *class_device, const char *buf, 231static ssize_t store_rotate(struct device *device,
228 size_t count) 232 struct device_attribute *attr,
233 const char *buf, size_t count)
229{ 234{
230 struct fb_info *fb_info = class_get_devdata(class_device); 235 struct fb_info *fb_info = dev_get_drvdata(device);
231 struct fb_var_screeninfo var; 236 struct fb_var_screeninfo var;
232 char **last = NULL; 237 char **last = NULL;
233 int err; 238 int err;
@@ -242,17 +247,19 @@ static ssize_t store_rotate(struct class_device *class_device, const char *buf,
242} 247}
243 248
244 249
245static ssize_t show_rotate(struct class_device *class_device, char *buf) 250static ssize_t show_rotate(struct device *device,
251 struct device_attribute *attr, char *buf)
246{ 252{
247 struct fb_info *fb_info = class_get_devdata(class_device); 253 struct fb_info *fb_info = dev_get_drvdata(device);
248 254
249 return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->var.rotate); 255 return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->var.rotate);
250} 256}
251 257
252static ssize_t store_virtual(struct class_device *class_device, 258static ssize_t store_virtual(struct device *device,
253 const char * buf, size_t count) 259 struct device_attribute *attr,
260 const char *buf, size_t count)
254{ 261{
255 struct fb_info *fb_info = class_get_devdata(class_device); 262 struct fb_info *fb_info = dev_get_drvdata(device);
256 struct fb_var_screeninfo var; 263 struct fb_var_screeninfo var;
257 char *last = NULL; 264 char *last = NULL;
258 int err; 265 int err;
@@ -269,23 +276,26 @@ static ssize_t store_virtual(struct class_device *class_device,
269 return count; 276 return count;
270} 277}
271 278
272static ssize_t show_virtual(struct class_device *class_device, char *buf) 279static ssize_t show_virtual(struct device *device,
280 struct device_attribute *attr, char *buf)
273{ 281{
274 struct fb_info *fb_info = class_get_devdata(class_device); 282 struct fb_info *fb_info = dev_get_drvdata(device);
275 return snprintf(buf, PAGE_SIZE, "%d,%d\n", fb_info->var.xres_virtual, 283 return snprintf(buf, PAGE_SIZE, "%d,%d\n", fb_info->var.xres_virtual,
276 fb_info->var.yres_virtual); 284 fb_info->var.yres_virtual);
277} 285}
278 286
279static ssize_t show_stride(struct class_device *class_device, char *buf) 287static ssize_t show_stride(struct device *device,
288 struct device_attribute *attr, char *buf)
280{ 289{
281 struct fb_info *fb_info = class_get_devdata(class_device); 290 struct fb_info *fb_info = dev_get_drvdata(device);
282 return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->fix.line_length); 291 return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->fix.line_length);
283} 292}
284 293
285static ssize_t store_blank(struct class_device *class_device, const char * buf, 294static ssize_t store_blank(struct device *device,
286 size_t count) 295 struct device_attribute *attr,
296 const char *buf, size_t count)
287{ 297{
288 struct fb_info *fb_info = class_get_devdata(class_device); 298 struct fb_info *fb_info = dev_get_drvdata(device);
289 char *last = NULL; 299 char *last = NULL;
290 int err; 300 int err;
291 301
@@ -299,42 +309,48 @@ static ssize_t store_blank(struct class_device *class_device, const char * buf,
299 return count; 309 return count;
300} 310}
301 311
302static ssize_t show_blank(struct class_device *class_device, char *buf) 312static ssize_t show_blank(struct device *device,
313 struct device_attribute *attr, char *buf)
303{ 314{
304// struct fb_info *fb_info = class_get_devdata(class_device); 315// struct fb_info *fb_info = dev_get_drvdata(device);
305 return 0; 316 return 0;
306} 317}
307 318
308static ssize_t store_console(struct class_device *class_device, 319static ssize_t store_console(struct device *device,
309 const char * buf, size_t count) 320 struct device_attribute *attr,
321 const char *buf, size_t count)
310{ 322{
311// struct fb_info *fb_info = class_get_devdata(class_device); 323// struct fb_info *fb_info = dev_get_drvdata(device);
312 return 0; 324 return 0;
313} 325}
314 326
315static ssize_t show_console(struct class_device *class_device, char *buf) 327static ssize_t show_console(struct device *device,
328 struct device_attribute *attr, char *buf)
316{ 329{
317// struct fb_info *fb_info = class_get_devdata(class_device); 330// struct fb_info *fb_info = dev_get_drvdata(device);
318 return 0; 331 return 0;
319} 332}
320 333
321static ssize_t store_cursor(struct class_device *class_device, 334static ssize_t store_cursor(struct device *device,
322 const char * buf, size_t count) 335 struct device_attribute *attr,
336 const char *buf, size_t count)
323{ 337{
324// struct fb_info *fb_info = class_get_devdata(class_device); 338// struct fb_info *fb_info = dev_get_drvdata(device);
325 return 0; 339 return 0;
326} 340}
327 341
328static ssize_t show_cursor(struct class_device *class_device, char *buf) 342static ssize_t show_cursor(struct device *device,
343 struct device_attribute *attr, char *buf)
329{ 344{
330// struct fb_info *fb_info = class_get_devdata(class_device); 345// struct fb_info *fb_info = dev_get_drvdata(device);
331 return 0; 346 return 0;
332} 347}
333 348
334static ssize_t store_pan(struct class_device *class_device, const char * buf, 349static ssize_t store_pan(struct device *device,
335 size_t count) 350 struct device_attribute *attr,
351 const char *buf, size_t count)
336{ 352{
337 struct fb_info *fb_info = class_get_devdata(class_device); 353 struct fb_info *fb_info = dev_get_drvdata(device);
338 struct fb_var_screeninfo var; 354 struct fb_var_screeninfo var;
339 char *last = NULL; 355 char *last = NULL;
340 int err; 356 int err;
@@ -355,24 +371,27 @@ static ssize_t store_pan(struct class_device *class_device, const char * buf,
355 return count; 371 return count;
356} 372}
357 373
358static ssize_t show_pan(struct class_device *class_device, char *buf) 374static ssize_t show_pan(struct device *device,
375 struct device_attribute *attr, char *buf)
359{ 376{
360 struct fb_info *fb_info = class_get_devdata(class_device); 377 struct fb_info *fb_info = dev_get_drvdata(device);
361 return snprintf(buf, PAGE_SIZE, "%d,%d\n", fb_info->var.xoffset, 378 return snprintf(buf, PAGE_SIZE, "%d,%d\n", fb_info->var.xoffset,
362 fb_info->var.xoffset); 379 fb_info->var.xoffset);
363} 380}
364 381
365static ssize_t show_name(struct class_device *class_device, char *buf) 382static ssize_t show_name(struct device *device,
383 struct device_attribute *attr, char *buf)
366{ 384{
367 struct fb_info *fb_info = class_get_devdata(class_device); 385 struct fb_info *fb_info = dev_get_drvdata(device);
368 386
369 return snprintf(buf, PAGE_SIZE, "%s\n", fb_info->fix.id); 387 return snprintf(buf, PAGE_SIZE, "%s\n", fb_info->fix.id);
370} 388}
371 389
372static ssize_t store_fbstate(struct class_device *class_device, 390static ssize_t store_fbstate(struct device *device,
373 const char *buf, size_t count) 391 struct device_attribute *attr,
392 const char *buf, size_t count)
374{ 393{
375 struct fb_info *fb_info = class_get_devdata(class_device); 394 struct fb_info *fb_info = dev_get_drvdata(device);
376 u32 state; 395 u32 state;
377 char *last = NULL; 396 char *last = NULL;
378 397
@@ -385,17 +404,19 @@ static ssize_t store_fbstate(struct class_device *class_device,
385 return count; 404 return count;
386} 405}
387 406
388static ssize_t show_fbstate(struct class_device *class_device, char *buf) 407static ssize_t show_fbstate(struct device *device,
408 struct device_attribute *attr, char *buf)
389{ 409{
390 struct fb_info *fb_info = class_get_devdata(class_device); 410 struct fb_info *fb_info = dev_get_drvdata(device);
391 return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->state); 411 return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->state);
392} 412}
393 413
394#ifdef CONFIG_FB_BACKLIGHT 414#ifdef CONFIG_FB_BACKLIGHT
395static ssize_t store_bl_curve(struct class_device *class_device, 415static ssize_t store_bl_curve(struct device *device,
396 const char *buf, size_t count) 416 struct device_attribute *attr,
417 const char *buf, size_t count)
397{ 418{
398 struct fb_info *fb_info = class_get_devdata(class_device); 419 struct fb_info *fb_info = dev_get_drvdata(device);
399 u8 tmp_curve[FB_BACKLIGHT_LEVELS]; 420 u8 tmp_curve[FB_BACKLIGHT_LEVELS];
400 unsigned int i; 421 unsigned int i;
401 422
@@ -432,9 +453,10 @@ static ssize_t store_bl_curve(struct class_device *class_device,
432 return count; 453 return count;
433} 454}
434 455
435static ssize_t show_bl_curve(struct class_device *class_device, char *buf) 456static ssize_t show_bl_curve(struct device *device,
457 struct device_attribute *attr, char *buf)
436{ 458{
437 struct fb_info *fb_info = class_get_devdata(class_device); 459 struct fb_info *fb_info = dev_get_drvdata(device);
438 ssize_t len = 0; 460 ssize_t len = 0;
439 unsigned int i; 461 unsigned int i;
440 462
@@ -465,7 +487,7 @@ static ssize_t show_bl_curve(struct class_device *class_device, char *buf)
465/* When cmap is added back in it should be a binary attribute 487/* When cmap is added back in it should be a binary attribute
466 * not a text one. Consideration should also be given to converting 488 * not a text one. Consideration should also be given to converting
467 * fbdev to use configfs instead of sysfs */ 489 * fbdev to use configfs instead of sysfs */
468static struct class_device_attribute class_device_attrs[] = { 490static struct device_attribute device_attrs[] = {
469 __ATTR(bits_per_pixel, S_IRUGO|S_IWUSR, show_bpp, store_bpp), 491 __ATTR(bits_per_pixel, S_IRUGO|S_IWUSR, show_bpp, store_bpp),
470 __ATTR(blank, S_IRUGO|S_IWUSR, show_blank, store_blank), 492 __ATTR(blank, S_IRUGO|S_IWUSR, show_blank, store_blank),
471 __ATTR(console, S_IRUGO|S_IWUSR, show_console, store_console), 493 __ATTR(console, S_IRUGO|S_IWUSR, show_console, store_console),
@@ -483,17 +505,16 @@ static struct class_device_attribute class_device_attrs[] = {
483#endif 505#endif
484}; 506};
485 507
486int fb_init_class_device(struct fb_info *fb_info) 508int fb_init_device(struct fb_info *fb_info)
487{ 509{
488 int i, error = 0; 510 int i, error = 0;
489 511
490 class_set_devdata(fb_info->class_device, fb_info); 512 dev_set_drvdata(fb_info->dev, fb_info);
491 513
492 fb_info->class_flag |= FB_SYSFS_FLAG_ATTR; 514 fb_info->class_flag |= FB_SYSFS_FLAG_ATTR;
493 515
494 for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) { 516 for (i = 0; i < ARRAY_SIZE(device_attrs); i++) {
495 error = class_device_create_file(fb_info->class_device, 517 error = device_create_file(fb_info->dev, &device_attrs[i]);
496 &class_device_attrs[i]);
497 518
498 if (error) 519 if (error)
499 break; 520 break;
@@ -501,22 +522,20 @@ int fb_init_class_device(struct fb_info *fb_info)
501 522
502 if (error) { 523 if (error) {
503 while (--i >= 0) 524 while (--i >= 0)
504 class_device_remove_file(fb_info->class_device, 525 device_remove_file(fb_info->dev, &device_attrs[i]);
505 &class_device_attrs[i]);
506 fb_info->class_flag &= ~FB_SYSFS_FLAG_ATTR; 526 fb_info->class_flag &= ~FB_SYSFS_FLAG_ATTR;
507 } 527 }
508 528
509 return 0; 529 return 0;
510} 530}
511 531
512void fb_cleanup_class_device(struct fb_info *fb_info) 532void fb_cleanup_device(struct fb_info *fb_info)
513{ 533{
514 unsigned int i; 534 unsigned int i;
515 535
516 if (fb_info->class_flag & FB_SYSFS_FLAG_ATTR) { 536 if (fb_info->class_flag & FB_SYSFS_FLAG_ATTR) {
517 for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) 537 for (i = 0; i < ARRAY_SIZE(device_attrs); i++)
518 class_device_remove_file(fb_info->class_device, 538 device_remove_file(fb_info->dev, &device_attrs[i]);
519 &class_device_attrs[i]);
520 539
521 fb_info->class_flag &= ~FB_SYSFS_FLAG_ATTR; 540 fb_info->class_flag &= ~FB_SYSFS_FLAG_ATTR;
522 } 541 }
diff --git a/drivers/video/geode/gxfb_core.c b/drivers/video/geode/gxfb_core.c
index 0d3643fc6293..a454dcb8e215 100644
--- a/drivers/video/geode/gxfb_core.c
+++ b/drivers/video/geode/gxfb_core.c
@@ -380,7 +380,7 @@ static void gxfb_remove(struct pci_dev *pdev)
380} 380}
381 381
382static struct pci_device_id gxfb_id_table[] = { 382static struct pci_device_id gxfb_id_table[] = {
383 { PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_VIDEO, 383 { PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_GX_VIDEO,
384 PCI_ANY_ID, PCI_ANY_ID, PCI_BASE_CLASS_DISPLAY << 16, 384 PCI_ANY_ID, PCI_ANY_ID, PCI_BASE_CLASS_DISPLAY << 16,
385 0xff0000, 0 }, 385 0xff0000, 0 },
386 { 0, } 386 { 0, }
diff --git a/drivers/video/nvidia/nv_hw.c b/drivers/video/nvidia/nv_hw.c
index 9ed640d35728..ea426115c6f9 100644
--- a/drivers/video/nvidia/nv_hw.c
+++ b/drivers/video/nvidia/nv_hw.c
@@ -145,12 +145,18 @@ static void nvGetClocks(struct nvidia_par *par, unsigned int *MClk,
145 145
146 if (par->Architecture >= NV_ARCH_40) { 146 if (par->Architecture >= NV_ARCH_40) {
147 pll = NV_RD32(par->PMC, 0x4020); 147 pll = NV_RD32(par->PMC, 0x4020);
148 P = (pll >> 16) & 0x03; 148 P = (pll >> 16) & 0x07;
149 pll = NV_RD32(par->PMC, 0x4024); 149 pll = NV_RD32(par->PMC, 0x4024);
150 M = pll & 0xFF; 150 M = pll & 0xFF;
151 N = (pll >> 8) & 0xFF; 151 N = (pll >> 8) & 0xFF;
152 MB = (pll >> 16) & 0xFF; 152 if (((par->Chipset & 0xfff0) == 0x0290) ||
153 NB = (pll >> 24) & 0xFF; 153 ((par->Chipset & 0xfff0) == 0x0390)) {
154 MB = 1;
155 NB = 1;
156 } else {
157 MB = (pll >> 16) & 0xFF;
158 NB = (pll >> 24) & 0xFF;
159 }
154 *MClk = ((N * NB * par->CrystalFreqKHz) / (M * MB)) >> P; 160 *MClk = ((N * NB * par->CrystalFreqKHz) / (M * MB)) >> P;
155 161
156 pll = NV_RD32(par->PMC, 0x4000); 162 pll = NV_RD32(par->PMC, 0x4000);
diff --git a/drivers/video/nvidia/nv_setup.c b/drivers/video/nvidia/nv_setup.c
index a18a9aebf05f..eab3e282a4de 100644
--- a/drivers/video/nvidia/nv_setup.c
+++ b/drivers/video/nvidia/nv_setup.c
@@ -262,7 +262,7 @@ static void nv10GetConfig(struct nvidia_par *par)
262#endif 262#endif
263 263
264 dev = pci_find_slot(0, 1); 264 dev = pci_find_slot(0, 1);
265 if ((par->Chipset && 0xffff) == 0x01a0) { 265 if ((par->Chipset & 0xffff) == 0x01a0) {
266 int amt = 0; 266 int amt = 0;
267 267
268 pci_read_config_dword(dev, 0x7c, &amt); 268 pci_read_config_dword(dev, 0x7c, &amt);
@@ -359,6 +359,7 @@ int NVCommonSetup(struct fb_info *info)
359 case 0x0186: 359 case 0x0186:
360 case 0x0187: 360 case 0x0187:
361 case 0x018D: 361 case 0x018D:
362 case 0x0228:
362 case 0x0286: 363 case 0x0286:
363 case 0x028C: 364 case 0x028C:
364 case 0x0316: 365 case 0x0316:
@@ -382,6 +383,10 @@ int NVCommonSetup(struct fb_info *info)
382 case 0x034C: 383 case 0x034C:
383 case 0x0160: 384 case 0x0160:
384 case 0x0166: 385 case 0x0166:
386 case 0x0169:
387 case 0x016B:
388 case 0x016C:
389 case 0x016D:
385 case 0x00C8: 390 case 0x00C8:
386 case 0x00CC: 391 case 0x00CC:
387 case 0x0144: 392 case 0x0144:
@@ -639,12 +644,23 @@ int NVCommonSetup(struct fb_info *info)
639 par->fpHeight = NV_RD32(par->PRAMDAC, 0x0800) + 1; 644 par->fpHeight = NV_RD32(par->PRAMDAC, 0x0800) + 1;
640 par->fpSyncs = NV_RD32(par->PRAMDAC, 0x0848) & 0x30000033; 645 par->fpSyncs = NV_RD32(par->PRAMDAC, 0x0848) & 0x30000033;
641 646
642 printk("Panel size is %i x %i\n", par->fpWidth, par->fpHeight); 647 printk("nvidiafb: Panel size is %i x %i\n", par->fpWidth, par->fpHeight);
643 } 648 }
644 649
645 if (monA) 650 if (monA)
646 info->monspecs = *monA; 651 info->monspecs = *monA;
647 652
653 if (!par->FlatPanel || !par->twoHeads)
654 par->FPDither = 0;
655
656 par->LVDS = 0;
657 if (par->FlatPanel && par->twoHeads) {
658 NV_WR32(par->PRAMDAC0, 0x08B0, 0x00010004);
659 if (par->PRAMDAC0[0x08b4] & 1)
660 par->LVDS = 1;
661 printk("nvidiafb: Panel is %s\n", par->LVDS ? "LVDS" : "TMDS");
662 }
663
648 kfree(edidA); 664 kfree(edidA);
649 kfree(edidB); 665 kfree(edidB);
650done: 666done:
diff --git a/drivers/video/nvidia/nv_type.h b/drivers/video/nvidia/nv_type.h
index acdc26693402..86e65dea60d3 100644
--- a/drivers/video/nvidia/nv_type.h
+++ b/drivers/video/nvidia/nv_type.h
@@ -129,6 +129,7 @@ struct nvidia_par {
129 int fpHeight; 129 int fpHeight;
130 int PanelTweak; 130 int PanelTweak;
131 int paneltweak; 131 int paneltweak;
132 int LVDS;
132 int pm_state; 133 int pm_state;
133 u32 crtcSync_read; 134 u32 crtcSync_read;
134 u32 fpSyncs; 135 u32 fpSyncs;
diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
index eb24107bcc81..538e947610e1 100644
--- a/drivers/video/nvidia/nvidia.c
+++ b/drivers/video/nvidia/nvidia.c
@@ -1160,20 +1160,20 @@ static u32 __devinit nvidia_get_arch(struct fb_info *info)
1160 case 0x0340: /* GeForceFX 5700 */ 1160 case 0x0340: /* GeForceFX 5700 */
1161 arch = NV_ARCH_30; 1161 arch = NV_ARCH_30;
1162 break; 1162 break;
1163 case 0x0040: 1163 case 0x0040: /* GeForce 6800 */
1164 case 0x00C0: 1164 case 0x00C0: /* GeForce 6800 */
1165 case 0x0120: 1165 case 0x0120: /* GeForce 6800 */
1166 case 0x0130: 1166 case 0x0130:
1167 case 0x0140: 1167 case 0x0140: /* GeForce 6600 */
1168 case 0x0160: 1168 case 0x0160: /* GeForce 6200 */
1169 case 0x01D0: 1169 case 0x01D0: /* GeForce 7200, 7300, 7400 */
1170 case 0x0090: 1170 case 0x0090: /* GeForce 7800 */
1171 case 0x0210: 1171 case 0x0210: /* GeForce 6800 */
1172 case 0x0220: 1172 case 0x0220: /* GeForce 6200 */
1173 case 0x0230: 1173 case 0x0230:
1174 case 0x0240: 1174 case 0x0240: /* GeForce 6100 */
1175 case 0x0290: 1175 case 0x0290: /* GeForce 7900 */
1176 case 0x0390: 1176 case 0x0390: /* GeForce 7600 */
1177 arch = NV_ARCH_40; 1177 arch = NV_ARCH_40;
1178 break; 1178 break;
1179 case 0x0020: /* TNT, TNT2 */ 1179 case 0x0020: /* TNT, TNT2 */
diff --git a/drivers/video/platinumfb.c b/drivers/video/platinumfb.c
index fdb33cd21a27..cb26c6df0583 100644
--- a/drivers/video/platinumfb.c
+++ b/drivers/video/platinumfb.c
@@ -34,6 +34,7 @@
34#include <asm/prom.h> 34#include <asm/prom.h>
35#include <asm/pgtable.h> 35#include <asm/pgtable.h>
36#include <asm/of_device.h> 36#include <asm/of_device.h>
37#include <asm/of_platform.h>
37 38
38#include "macmodes.h" 39#include "macmodes.h"
39#include "platinumfb.h" 40#include "platinumfb.h"
@@ -682,14 +683,14 @@ static int __init platinumfb_init(void)
682 return -ENODEV; 683 return -ENODEV;
683 platinumfb_setup(option); 684 platinumfb_setup(option);
684#endif 685#endif
685 of_register_driver(&platinum_driver); 686 of_register_platform_driver(&platinum_driver);
686 687
687 return 0; 688 return 0;
688} 689}
689 690
690static void __exit platinumfb_exit(void) 691static void __exit platinumfb_exit(void)
691{ 692{
692 of_unregister_driver(&platinum_driver); 693 of_unregister_platform_driver(&platinum_driver);
693} 694}
694 695
695MODULE_LICENSE("GPL"); 696MODULE_LICENSE("GPL");
diff --git a/drivers/video/pnx4008/pnxrgbfb.c b/drivers/video/pnx4008/pnxrgbfb.c
index 7d9453c91a42..f29e66e2d774 100644
--- a/drivers/video/pnx4008/pnxrgbfb.c
+++ b/drivers/video/pnx4008/pnxrgbfb.c
@@ -154,7 +154,8 @@ static int __devinit rgbfb_probe(struct platform_device *pdev)
154 goto err1; 154 goto err1;
155 } 155 }
156 156
157 if (!fb_get_options("pnxrgbfb", &option) && !strcmp(option, "nocursor")) 157 if (!fb_get_options("pnxrgbfb", &option) && option &&
158 !strcmp(option, "nocursor"))
158 rgbfb_ops.fb_cursor = no_cursor; 159 rgbfb_ops.fb_cursor = no_cursor;
159 160
160 info->node = -1; 161 info->node = -1;
@@ -191,7 +192,7 @@ err:
191 192
192static struct platform_driver rgbfb_driver = { 193static struct platform_driver rgbfb_driver = {
193 .driver = { 194 .driver = {
194 .name = "rgbfb", 195 .name = "pnx4008-rgbfb",
195 }, 196 },
196 .probe = rgbfb_probe, 197 .probe = rgbfb_probe,
197 .remove = rgbfb_remove, 198 .remove = rgbfb_remove,
diff --git a/drivers/video/pnx4008/sdum.c b/drivers/video/pnx4008/sdum.c
index 51f0ecc2a511..d23bf0d659b6 100644
--- a/drivers/video/pnx4008/sdum.c
+++ b/drivers/video/pnx4008/sdum.c
@@ -848,7 +848,7 @@ static int sdum_remove(struct platform_device *pdev)
848 848
849static struct platform_driver sdum_driver = { 849static struct platform_driver sdum_driver = {
850 .driver = { 850 .driver = {
851 .name = "sdum", 851 .name = "pnx4008-sdum",
852 }, 852 },
853 .probe = sdum_probe, 853 .probe = sdum_probe,
854 .remove = sdum_remove, 854 .remove = sdum_remove,
diff --git a/drivers/video/pxafb.c b/drivers/video/pxafb.c
index 8a8ae55a7403..38eb0b69c2d7 100644
--- a/drivers/video/pxafb.c
+++ b/drivers/video/pxafb.c
@@ -964,9 +964,10 @@ static void set_ctrlr_state(struct pxafb_info *fbi, u_int state)
964 * Our LCD controller task (which is called when we blank or unblank) 964 * Our LCD controller task (which is called when we blank or unblank)
965 * via keventd. 965 * via keventd.
966 */ 966 */
967static void pxafb_task(void *dummy) 967static void pxafb_task(struct work_struct *work)
968{ 968{
969 struct pxafb_info *fbi = dummy; 969 struct pxafb_info *fbi =
970 container_of(work, struct pxafb_info, task);
970 u_int state = xchg(&fbi->task_state, -1); 971 u_int state = xchg(&fbi->task_state, -1);
971 972
972 set_ctrlr_state(fbi, state); 973 set_ctrlr_state(fbi, state);
@@ -1159,7 +1160,7 @@ static struct pxafb_info * __init pxafb_init_fbinfo(struct device *dev)
1159 } 1160 }
1160 1161
1161 init_waitqueue_head(&fbi->ctrlr_wait); 1162 init_waitqueue_head(&fbi->ctrlr_wait);
1162 INIT_WORK(&fbi->task, pxafb_task, fbi); 1163 INIT_WORK(&fbi->task, pxafb_task);
1163 init_MUTEX(&fbi->ctrlr_sem); 1164 init_MUTEX(&fbi->ctrlr_sem);
1164 1165
1165 return fbi; 1166 return fbi;
diff --git a/drivers/w1/Makefile b/drivers/w1/Makefile
index 93845a2c7c21..6bb0b54965f2 100644
--- a/drivers/w1/Makefile
+++ b/drivers/w1/Makefile
@@ -2,10 +2,6 @@
2# Makefile for the Dallas's 1-wire bus. 2# Makefile for the Dallas's 1-wire bus.
3# 3#
4 4
5ifeq ($(CONFIG_W1_DS2433_CRC), y)
6EXTRA_CFLAGS += -DCONFIG_W1_F23_CRC
7endif
8
9obj-$(CONFIG_W1) += wire.o 5obj-$(CONFIG_W1) += wire.o
10wire-objs := w1.o w1_int.o w1_family.o w1_netlink.o w1_io.o 6wire-objs := w1.o w1_int.o w1_family.o w1_netlink.o w1_io.o
11 7
diff --git a/drivers/w1/masters/matrox_w1.c b/drivers/w1/masters/matrox_w1.c
index 2788b8ca9bb1..6f9d880ab2e9 100644
--- a/drivers/w1/masters/matrox_w1.c
+++ b/drivers/w1/masters/matrox_w1.c
@@ -215,6 +215,8 @@ static int __devinit matrox_w1_probe(struct pci_dev *pdev, const struct pci_devi
215 return 0; 215 return 0;
216 216
217err_out_free_device: 217err_out_free_device:
218 if (dev->virt_addr)
219 iounmap(dev->virt_addr);
218 kfree(dev); 220 kfree(dev);
219 221
220 return err; 222 return err;
diff --git a/drivers/w1/slaves/Makefile b/drivers/w1/slaves/Makefile
index 70e21e2d70c3..725dcfdfddb4 100644
--- a/drivers/w1/slaves/Makefile
+++ b/drivers/w1/slaves/Makefile
@@ -2,10 +2,6 @@
2# Makefile for the Dallas's 1-wire slaves. 2# Makefile for the Dallas's 1-wire slaves.
3# 3#
4 4
5ifeq ($(CONFIG_W1_SLAVE_DS2433_CRC), y)
6EXTRA_CFLAGS += -DCONFIG_W1_F23_CRC
7endif
8
9obj-$(CONFIG_W1_SLAVE_THERM) += w1_therm.o 5obj-$(CONFIG_W1_SLAVE_THERM) += w1_therm.o
10obj-$(CONFIG_W1_SLAVE_SMEM) += w1_smem.o 6obj-$(CONFIG_W1_SLAVE_SMEM) += w1_smem.o
11obj-$(CONFIG_W1_SLAVE_DS2433) += w1_ds2433.o 7obj-$(CONFIG_W1_SLAVE_DS2433) += w1_ds2433.o
diff --git a/drivers/w1/slaves/w1_ds2433.c b/drivers/w1/slaves/w1_ds2433.c
index 2ac238f1480e..8ea17a53eed8 100644
--- a/drivers/w1/slaves/w1_ds2433.c
+++ b/drivers/w1/slaves/w1_ds2433.c
@@ -13,7 +13,7 @@
13#include <linux/device.h> 13#include <linux/device.h>
14#include <linux/types.h> 14#include <linux/types.h>
15#include <linux/delay.h> 15#include <linux/delay.h>
16#ifdef CONFIG_W1_F23_CRC 16#ifdef CONFIG_W1_SLAVE_DS2433_CRC
17#include <linux/crc16.h> 17#include <linux/crc16.h>
18 18
19#define CRC16_INIT 0 19#define CRC16_INIT 0
@@ -62,7 +62,7 @@ static inline size_t w1_f23_fix_count(loff_t off, size_t count, size_t size)
62 return count; 62 return count;
63} 63}
64 64
65#ifdef CONFIG_W1_F23_CRC 65#ifdef CONFIG_W1_SLAVE_DS2433_CRC
66static int w1_f23_refresh_block(struct w1_slave *sl, struct w1_f23_data *data, 66static int w1_f23_refresh_block(struct w1_slave *sl, struct w1_f23_data *data,
67 int block) 67 int block)
68{ 68{
@@ -89,13 +89,13 @@ static int w1_f23_refresh_block(struct w1_slave *sl, struct w1_f23_data *data,
89 89
90 return 0; 90 return 0;
91} 91}
92#endif /* CONFIG_W1_F23_CRC */ 92#endif /* CONFIG_W1_SLAVE_DS2433_CRC */
93 93
94static ssize_t w1_f23_read_bin(struct kobject *kobj, char *buf, loff_t off, 94static ssize_t w1_f23_read_bin(struct kobject *kobj, char *buf, loff_t off,
95 size_t count) 95 size_t count)
96{ 96{
97 struct w1_slave *sl = kobj_to_w1_slave(kobj); 97 struct w1_slave *sl = kobj_to_w1_slave(kobj);
98#ifdef CONFIG_W1_F23_CRC 98#ifdef CONFIG_W1_SLAVE_DS2433_CRC
99 struct w1_f23_data *data = sl->family_data; 99 struct w1_f23_data *data = sl->family_data;
100 int i, min_page, max_page; 100 int i, min_page, max_page;
101#else 101#else
@@ -107,7 +107,7 @@ static ssize_t w1_f23_read_bin(struct kobject *kobj, char *buf, loff_t off,
107 107
108 mutex_lock(&sl->master->mutex); 108 mutex_lock(&sl->master->mutex);
109 109
110#ifdef CONFIG_W1_F23_CRC 110#ifdef CONFIG_W1_SLAVE_DS2433_CRC
111 111
112 min_page = (off >> W1_PAGE_BITS); 112 min_page = (off >> W1_PAGE_BITS);
113 max_page = (off + count - 1) >> W1_PAGE_BITS; 113 max_page = (off + count - 1) >> W1_PAGE_BITS;
@@ -119,7 +119,7 @@ static ssize_t w1_f23_read_bin(struct kobject *kobj, char *buf, loff_t off,
119 } 119 }
120 memcpy(buf, &data->memory[off], count); 120 memcpy(buf, &data->memory[off], count);
121 121
122#else /* CONFIG_W1_F23_CRC */ 122#else /* CONFIG_W1_SLAVE_DS2433_CRC */
123 123
124 /* read directly from the EEPROM */ 124 /* read directly from the EEPROM */
125 if (w1_reset_select_slave(sl)) { 125 if (w1_reset_select_slave(sl)) {
@@ -133,7 +133,7 @@ static ssize_t w1_f23_read_bin(struct kobject *kobj, char *buf, loff_t off,
133 w1_write_block(sl->master, wrbuf, 3); 133 w1_write_block(sl->master, wrbuf, 3);
134 w1_read_block(sl->master, buf, count); 134 w1_read_block(sl->master, buf, count);
135 135
136#endif /* CONFIG_W1_F23_CRC */ 136#endif /* CONFIG_W1_SLAVE_DS2433_CRC */
137 137
138out_up: 138out_up:
139 mutex_unlock(&sl->master->mutex); 139 mutex_unlock(&sl->master->mutex);
@@ -208,7 +208,7 @@ static ssize_t w1_f23_write_bin(struct kobject *kobj, char *buf, loff_t off,
208 if ((count = w1_f23_fix_count(off, count, W1_EEPROM_SIZE)) == 0) 208 if ((count = w1_f23_fix_count(off, count, W1_EEPROM_SIZE)) == 0)
209 return 0; 209 return 0;
210 210
211#ifdef CONFIG_W1_F23_CRC 211#ifdef CONFIG_W1_SLAVE_DS2433_CRC
212 /* can only write full blocks in cached mode */ 212 /* can only write full blocks in cached mode */
213 if ((off & W1_PAGE_MASK) || (count & W1_PAGE_MASK)) { 213 if ((off & W1_PAGE_MASK) || (count & W1_PAGE_MASK)) {
214 dev_err(&sl->dev, "invalid offset/count off=%d cnt=%zd\n", 214 dev_err(&sl->dev, "invalid offset/count off=%d cnt=%zd\n",
@@ -223,7 +223,7 @@ static ssize_t w1_f23_write_bin(struct kobject *kobj, char *buf, loff_t off,
223 return -EINVAL; 223 return -EINVAL;
224 } 224 }
225 } 225 }
226#endif /* CONFIG_W1_F23_CRC */ 226#endif /* CONFIG_W1_SLAVE_DS2433_CRC */
227 227
228 mutex_lock(&sl->master->mutex); 228 mutex_lock(&sl->master->mutex);
229 229
@@ -262,7 +262,7 @@ static struct bin_attribute w1_f23_bin_attr = {
262static int w1_f23_add_slave(struct w1_slave *sl) 262static int w1_f23_add_slave(struct w1_slave *sl)
263{ 263{
264 int err; 264 int err;
265#ifdef CONFIG_W1_F23_CRC 265#ifdef CONFIG_W1_SLAVE_DS2433_CRC
266 struct w1_f23_data *data; 266 struct w1_f23_data *data;
267 267
268 data = kmalloc(sizeof(struct w1_f23_data), GFP_KERNEL); 268 data = kmalloc(sizeof(struct w1_f23_data), GFP_KERNEL);
@@ -271,24 +271,24 @@ static int w1_f23_add_slave(struct w1_slave *sl)
271 memset(data, 0, sizeof(struct w1_f23_data)); 271 memset(data, 0, sizeof(struct w1_f23_data));
272 sl->family_data = data; 272 sl->family_data = data;
273 273
274#endif /* CONFIG_W1_F23_CRC */ 274#endif /* CONFIG_W1_SLAVE_DS2433_CRC */
275 275
276 err = sysfs_create_bin_file(&sl->dev.kobj, &w1_f23_bin_attr); 276 err = sysfs_create_bin_file(&sl->dev.kobj, &w1_f23_bin_attr);
277 277
278#ifdef CONFIG_W1_F23_CRC 278#ifdef CONFIG_W1_SLAVE_DS2433_CRC
279 if (err) 279 if (err)
280 kfree(data); 280 kfree(data);
281#endif /* CONFIG_W1_F23_CRC */ 281#endif /* CONFIG_W1_SLAVE_DS2433_CRC */
282 282
283 return err; 283 return err;
284} 284}
285 285
286static void w1_f23_remove_slave(struct w1_slave *sl) 286static void w1_f23_remove_slave(struct w1_slave *sl)
287{ 287{
288#ifdef CONFIG_W1_F23_CRC 288#ifdef CONFIG_W1_SLAVE_DS2433_CRC
289 kfree(sl->family_data); 289 kfree(sl->family_data);
290 sl->family_data = NULL; 290 sl->family_data = NULL;
291#endif /* CONFIG_W1_F23_CRC */ 291#endif /* CONFIG_W1_SLAVE_DS2433_CRC */
292 sysfs_remove_bin_file(&sl->dev.kobj, &w1_f23_bin_attr); 292 sysfs_remove_bin_file(&sl->dev.kobj, &w1_f23_bin_attr);
293} 293}
294 294
diff --git a/drivers/w1/slaves/w1_therm.c b/drivers/w1/slaves/w1_therm.c
index 5372cfcbd054..b022fffd8c51 100644
--- a/drivers/w1/slaves/w1_therm.c
+++ b/drivers/w1/slaves/w1_therm.c
@@ -24,6 +24,7 @@
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/moduleparam.h> 26#include <linux/moduleparam.h>
27#include <linux/sched.h>
27#include <linux/device.h> 28#include <linux/device.h>
28#include <linux/types.h> 29#include <linux/types.h>
29#include <linux/delay.h> 30#include <linux/delay.h>
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index de3e9791f80d..63c07243993c 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -31,6 +31,7 @@
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/sched.h> 32#include <linux/sched.h>
33#include <linux/kthread.h> 33#include <linux/kthread.h>
34#include <linux/freezer.h>
34 35
35#include <asm/atomic.h> 36#include <asm/atomic.h>
36 37