Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: eata: eata-pio: Deprecate legacy EATA drivers

These two drivers do not appear to be in active use. Deprecate them.

Suggested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

-4064
-2
Documentation/scsi/scsi-parameters.txt
··· 34 34 See drivers/scsi/BusLogic.c, comment before function 35 35 BusLogic_ParseDriverOptions(). 36 36 37 - eata= [HW,SCSI] 38 - 39 37 fdomain= [HW,SCSI] 40 38 See header of drivers/scsi/fdomain.c. 41 39
-6
MAINTAINERS
··· 5003 5003 S: Maintained 5004 5004 F: drivers/media/tuners/e4000* 5005 5005 5006 - EATA ISA/EISA/PCI SCSI DRIVER 5007 - M: Dario Ballabio <ballabio_dario@emc.com> 5008 - L: linux-scsi@vger.kernel.org 5009 - S: Maintained 5010 - F: drivers/scsi/eata.c 5011 - 5012 5006 EC100 MEDIA DRIVER 5013 5007 M: Antti Palosaari <crope@iki.fi> 5014 5008 L: linux-media@vger.kernel.org
-62
drivers/scsi/Kconfig
··· 640 640 To compile this driver as a module, choose M here: the 641 641 module will be called dmx3191d. 642 642 643 - config SCSI_EATA 644 - tristate "EATA ISA/EISA/PCI (DPT and generic EATA/DMA-compliant boards) support" 645 - depends on (ISA || EISA || PCI) && SCSI && ISA_DMA_API 646 - ---help--- 647 - This driver supports all EATA/DMA-compliant SCSI host adapters. DPT 648 - ISA and all EISA I/O addresses are probed looking for the "EATA" 649 - signature. The addresses of all the PCI SCSI controllers reported 650 - by the PCI subsystem are probed as well. 651 - 652 - You want to read the start of <file:drivers/scsi/eata.c> and the 653 - SCSI-HOWTO, available from 654 - <http://www.tldp.org/docs.html#howto>. 655 - 656 - To compile this driver as a module, choose M here: the 657 - module will be called eata. 658 - 659 - config SCSI_EATA_TAGGED_QUEUE 660 - bool "enable tagged command queueing" 661 - depends on SCSI_EATA 662 - help 663 - This is a feature of SCSI-2 which improves performance: the host 664 - adapter can send several SCSI commands to a device's queue even if 665 - previous commands haven't finished yet. 666 - This is equivalent to the "eata=tc:y" boot option. 667 - 668 - config SCSI_EATA_LINKED_COMMANDS 669 - bool "enable elevator sorting" 670 - depends on SCSI_EATA 671 - help 672 - This option enables elevator sorting for all probed SCSI disks and 673 - CD-ROMs. It definitely reduces the average seek distance when doing 674 - random seeks, but this does not necessarily result in a noticeable 675 - performance improvement: your mileage may vary... 676 - This is equivalent to the "eata=lc:y" boot option. 677 - 678 - config SCSI_EATA_MAX_TAGS 679 - int "maximum number of queued commands" 680 - depends on SCSI_EATA 681 - default "16" 682 - help 683 - This specifies how many SCSI commands can be maximally queued for 684 - each probed SCSI device. You should reduce the default value of 16 685 - only if you have disks with buggy or limited tagged command support. 686 - Minimum is 2 and maximum is 62. This value is also the window size 687 - used by the elevator sorting option above. The effective value used 688 - by the driver for each probed SCSI device is reported at boot time. 689 - This is equivalent to the "eata=mq:8" boot option. 690 - 691 - config SCSI_EATA_PIO 692 - tristate "EATA-PIO (old DPT PM2001, PM2012A) support" 693 - depends on (ISA || EISA || PCI) && SCSI && BROKEN 694 - ---help--- 695 - This driver supports all EATA-PIO protocol compliant SCSI Host 696 - Adapters like the DPT PM2001 and the PM2012A. EATA-DMA compliant 697 - host adapters could also use this driver but are discouraged from 698 - doing so, since this driver only supports hard disks and lacks 699 - numerous features. You might want to have a look at the SCSI-HOWTO, 700 - available from <http://www.tldp.org/docs.html#howto>. 701 - 702 - To compile this driver as a module, choose M here: the 703 - module will be called eata_pio. 704 - 705 643 config SCSI_FUTURE_DOMAIN 706 644 tristate "Future Domain 16xx SCSI/AHA-2920A support" 707 645 depends on (ISA || PCI) && SCSI
-2
drivers/scsi/Makefile
··· 93 93 obj-$(CONFIG_SCSI_SMARTPQI) += smartpqi/ 94 94 obj-$(CONFIG_SCSI_SYM53C8XX_2) += sym53c8xx_2/ 95 95 obj-$(CONFIG_SCSI_ZALON) += zalon7xx.o 96 - obj-$(CONFIG_SCSI_EATA_PIO) += eata_pio.o 97 - obj-$(CONFIG_SCSI_EATA) += eata.o 98 96 obj-$(CONFIG_SCSI_DC395x) += dc395x.o 99 97 obj-$(CONFIG_SCSI_AM53C974) += esp_scsi.o am53c974.o 100 98 obj-$(CONFIG_CXLFLASH) += cxlflash/
-2571
drivers/scsi/eata.c
··· 1 - /* 2 - * eata.c - Low-level driver for EATA/DMA SCSI host adapters. 3 - * 4 - * 03 Jun 2003 Rev. 8.10 for linux-2.5.70 5 - * + Update for new IRQ API. 6 - * + Use "goto" when appropriate. 7 - * + Drop eata.h. 8 - * + Update for new module_param API. 9 - * + Module parameters can now be specified only in the 10 - * same format as the kernel boot options. 11 - * 12 - * boot option old module param 13 - * ----------- ------------------ 14 - * addr,... io_port=addr,... 15 - * lc:[y|n] linked_comm=[1|0] 16 - * mq:xx max_queue_depth=xx 17 - * tm:[0|1|2] tag_mode=[0|1|2] 18 - * et:[y|n] ext_tran=[1|0] 19 - * rs:[y|n] rev_scan=[1|0] 20 - * ip:[y|n] isa_probe=[1|0] 21 - * ep:[y|n] eisa_probe=[1|0] 22 - * pp:[y|n] pci_probe=[1|0] 23 - * 24 - * A valid example using the new parameter format is: 25 - * modprobe eata "eata=0x7410,0x230,lc:y,tm:0,mq:4,ep:n" 26 - * 27 - * which is equivalent to the old format: 28 - * modprobe eata io_port=0x7410,0x230 linked_comm=1 tag_mode=0 \ 29 - * max_queue_depth=4 eisa_probe=0 30 - * 31 - * 12 Feb 2003 Rev. 8.04 for linux 2.5.60 32 - * + Release irq before calling scsi_register. 33 - * 34 - * 12 Nov 2002 Rev. 8.02 for linux 2.5.47 35 - * + Release driver_lock before calling scsi_register. 36 - * 37 - * 11 Nov 2002 Rev. 8.01 for linux 2.5.47 38 - * + Fixed bios_param and scsicam_bios_param calling parameters. 39 - * 40 - * 28 Oct 2002 Rev. 8.00 for linux 2.5.44-ac4 41 - * + Use new tcq and adjust_queue_depth api. 42 - * + New command line option (tm:[0-2]) to choose the type of tags: 43 - * 0 -> disable tagging ; 1 -> simple tags ; 2 -> ordered tags. 44 - * Default is tm:0 (tagged commands disabled). 45 - * For compatibility the "tc:" option is an alias of the "tm:" 46 - * option; tc:n is equivalent to tm:0 and tc:y is equivalent to 47 - * tm:1. 48 - * + The tagged_comm module parameter has been removed, use tag_mode 49 - * instead, equivalent to the "tm:" boot option. 50 - * 51 - * 10 Oct 2002 Rev. 7.70 for linux 2.5.42 52 - * + Foreport from revision 6.70. 53 - * 54 - * 25 Jun 2002 Rev. 6.70 for linux 2.4.19 55 - * + This release is the first one tested on a Big Endian platform: 56 - * fixed endian-ness problem due to bitfields; 57 - * fixed endian-ness problem in read_pio. 58 - * + Added new options for selectively probing ISA, EISA and PCI bus: 59 - * 60 - * Boot option Parameter name Default according to 61 - * 62 - * ip:[y|n] isa_probe=[1|0] CONFIG_ISA defined 63 - * ep:[y|n] eisa_probe=[1|0] CONFIG_EISA defined 64 - * pp:[y|n] pci_probe=[1|0] CONFIG_PCI defined 65 - * 66 - * The default action is to perform probing if the corresponding 67 - * bus is configured and to skip probing otherwise. 68 - * 69 - * + If pci_probe is in effect and a list of I/O ports is specified 70 - * as parameter or boot option, pci_enable_device() is performed 71 - * on all pci devices matching PCI_CLASS_STORAGE_SCSI. 72 - * 73 - * 21 Feb 2002 Rev. 6.52 for linux 2.4.18 74 - * + Backport from rev. 7.22 (use io_request_lock). 75 - * 76 - * 20 Feb 2002 Rev. 7.22 for linux 2.5.5 77 - * + Remove any reference to virt_to_bus(). 78 - * + Fix pio hang while detecting multiple HBAs. 79 - * + Fixed a board detection bug: in a system with 80 - * multiple ISA/EISA boards, all but the first one 81 - * were erroneously detected as PCI. 82 - * 83 - * 01 Jan 2002 Rev. 7.20 for linux 2.5.1 84 - * + Use the dynamic DMA mapping API. 85 - * 86 - * 19 Dec 2001 Rev. 7.02 for linux 2.5.1 87 - * + Use SCpnt->sc_data_direction if set. 88 - * + Use sglist.page instead of sglist.address. 89 - * 90 - * 11 Dec 2001 Rev. 7.00 for linux 2.5.1 91 - * + Use host->host_lock instead of io_request_lock. 92 - * 93 - * 1 May 2001 Rev. 6.05 for linux 2.4.4 94 - * + Clean up all pci related routines. 95 - * + Fix data transfer direction for opcode SEND_CUE_SHEET (0x5d) 96 - * 97 - * 30 Jan 2001 Rev. 6.04 for linux 2.4.1 98 - * + Call pci_resource_start after pci_enable_device. 99 - * 100 - * 25 Jan 2001 Rev. 6.03 for linux 2.4.0 101 - * + "check_region" call replaced by "request_region". 102 - * 103 - * 22 Nov 2000 Rev. 6.02 for linux 2.4.0-test11 104 - * + Return code checked when calling pci_enable_device. 105 - * + Removed old scsi error handling support. 106 - * + The obsolete boot option flag eh:n is silently ignored. 107 - * + Removed error messages while a disk drive is powered up at 108 - * boot time. 109 - * + Improved boot messages: all tagged capable device are 110 - * indicated as "tagged" or "soft-tagged" : 111 - * - "soft-tagged" means that the driver is trying to do its 112 - * own tagging (i.e. the tc:y option is in effect); 113 - * - "tagged" means that the device supports tagged commands, 114 - * but the driver lets the HBA be responsible for tagging 115 - * support. 116 - * 117 - * 16 Sep 1999 Rev. 5.11 for linux 2.2.12 and 2.3.18 118 - * + Updated to the new __setup interface for boot command line options. 119 - * + When loaded as a module, accepts the new parameter boot_options 120 - * which value is a string with the same format of the kernel boot 121 - * command line options. A valid example is: 122 - * modprobe eata 'boot_options="0x7410,0x230,lc:y,tc:n,mq:4"' 123 - * 124 - * 9 Sep 1999 Rev. 5.10 for linux 2.2.12 and 2.3.17 125 - * + 64bit cleanup for Linux/Alpha platform support 126 - * (contribution from H.J. Lu). 127 - * 128 - * 22 Jul 1999 Rev. 5.00 for linux 2.2.10 and 2.3.11 129 - * + Removed pre-2.2 source code compatibility. 130 - * + Added call to pci_set_master. 131 - * 132 - * 26 Jul 1998 Rev. 4.33 for linux 2.0.35 and 2.1.111 133 - * + Added command line option (rs:[y|n]) to reverse the scan order 134 - * of PCI boards. The default is rs:y, which reverses the BIOS order 135 - * while registering PCI boards. The default value rs:y generates 136 - * the same order of all previous revisions of this driver. 137 - * Pls. note that "BIOS order" might have been reversed itself 138 - * after the 2.1.9x PCI modifications in the linux kernel. 139 - * The rs value is ignored when the explicit list of addresses 140 - * is used by the "eata=port0,port1,..." command line option. 141 - * + Added command line option (et:[y|n]) to force use of extended 142 - * translation (255 heads, 63 sectors) as disk geometry. 143 - * The default is et:n, which uses the disk geometry returned 144 - * by scsicam_bios_param. The default value et:n is compatible with 145 - * all previous revisions of this driver. 146 - * 147 - * 28 May 1998 Rev. 4.32 for linux 2.0.33 and 2.1.104 148 - * Increased busy timeout from 10 msec. to 200 msec. while 149 - * processing interrupts. 150 - * 151 - * 16 May 1998 Rev. 4.31 for linux 2.0.33 and 2.1.102 152 - * Improved abort handling during the eh recovery process. 153 - * 154 - * 13 May 1998 Rev. 4.30 for linux 2.0.33 and 2.1.101 155 - * The driver is now fully SMP safe, including the 156 - * abort and reset routines. 157 - * Added command line options (eh:[y|n]) to choose between 158 - * new_eh_code and the old scsi code. 159 - * If linux version >= 2.1.101 the default is eh:y, while the eh 160 - * option is ignored for previous releases and the old scsi code 161 - * is used. 162 - * 163 - * 18 Apr 1998 Rev. 4.20 for linux 2.0.33 and 2.1.97 164 - * Reworked interrupt handler. 165 - * 166 - * 11 Apr 1998 rev. 4.05 for linux 2.0.33 and 2.1.95 167 - * Major reliability improvement: when a batch with overlapping 168 - * requests is detected, requests are queued one at a time 169 - * eliminating any possible board or drive reordering. 170 - * 171 - * 10 Apr 1998 rev. 4.04 for linux 2.0.33 and 2.1.95 172 - * Improved SMP support (if linux version >= 2.1.95). 173 - * 174 - * 9 Apr 1998 rev. 4.03 for linux 2.0.33 and 2.1.94 175 - * Added support for new PCI code and IO-APIC remapping of irqs. 176 - * Performance improvement: when sequential i/o is detected, 177 - * always use direct sort instead of reverse sort. 178 - * 179 - * 4 Apr 1998 rev. 4.02 for linux 2.0.33 and 2.1.92 180 - * io_port is now unsigned long. 181 - * 182 - * 17 Mar 1998 rev. 4.01 for linux 2.0.33 and 2.1.88 183 - * Use new scsi error handling code (if linux version >= 2.1.88). 184 - * Use new interrupt code. 185 - * 186 - * 12 Sep 1997 rev. 3.11 for linux 2.0.30 and 2.1.55 187 - * Use of udelay inside the wait loops to avoid timeout 188 - * problems with fast cpus. 189 - * Removed check about useless calls to the interrupt service 190 - * routine (reported on SMP systems only). 191 - * At initialization time "sorted/unsorted" is displayed instead 192 - * of "linked/unlinked" to reinforce the fact that "linking" is 193 - * nothing but "elevator sorting" in the actual implementation. 194 - * 195 - * 17 May 1997 rev. 3.10 for linux 2.0.30 and 2.1.38 196 - * Use of serial_number_at_timeout in abort and reset processing. 197 - * Use of the __initfunc and __initdata macro in setup code. 198 - * Minor cleanups in the list_statistics code. 199 - * Increased controller busy timeout in order to better support 200 - * slow SCSI devices. 201 - * 202 - * 24 Feb 1997 rev. 3.00 for linux 2.0.29 and 2.1.26 203 - * When loading as a module, parameter passing is now supported 204 - * both in 2.0 and in 2.1 style. 205 - * Fixed data transfer direction for some SCSI opcodes. 206 - * Immediate acknowledge to request sense commands. 207 - * Linked commands to each disk device are now reordered by elevator 208 - * sorting. Rare cases in which reordering of write requests could 209 - * cause wrong results are managed. 210 - * Fixed spurious timeouts caused by long simple queue tag sequences. 211 - * New command line option (tm:[0-3]) to choose the type of tags: 212 - * 0 -> mixed (default); 1 -> simple; 2 -> head; 3 -> ordered. 213 - * 214 - * 18 Jan 1997 rev. 2.60 for linux 2.1.21 and 2.0.28 215 - * Added command line options to enable/disable linked commands 216 - * (lc:[y|n]), tagged commands (tc:[y|n]) and to set the max queue 217 - * depth (mq:xx). Default is "eata=lc:n,tc:n,mq:16". 218 - * Improved command linking. 219 - * Documented how to setup RAID-0 with DPT SmartRAID boards. 220 - * 221 - * 8 Jan 1997 rev. 2.50 for linux 2.1.20 and 2.0.27 222 - * Added linked command support. 223 - * Improved detection of PCI boards using ISA base addresses. 224 - * 225 - * 3 Dec 1996 rev. 2.40 for linux 2.1.14 and 2.0.27 226 - * Added support for tagged commands and queue depth adjustment. 227 - * 228 - * 22 Nov 1996 rev. 2.30 for linux 2.1.12 and 2.0.26 229 - * When CONFIG_PCI is defined, BIOS32 is used to include in the 230 - * list of i/o ports to be probed all the PCI SCSI controllers. 231 - * The list of i/o ports to be probed can be overwritten by the 232 - * "eata=port0,port1,...." boot command line option. 233 - * Scatter/gather lists are now allocated by a number of kmalloc 234 - * calls, in order to avoid the previous size limit of 64Kb. 235 - * 236 - * 16 Nov 1996 rev. 2.20 for linux 2.1.10 and 2.0.25 237 - * Added support for EATA 2.0C, PCI, multichannel and wide SCSI. 238 - * 239 - * 27 Sep 1996 rev. 2.12 for linux 2.1.0 240 - * Portability cleanups (virtual/bus addressing, little/big endian 241 - * support). 242 - * 243 - * 09 Jul 1996 rev. 2.11 for linux 2.0.4 244 - * Number of internal retries is now limited. 245 - * 246 - * 16 Apr 1996 rev. 2.10 for linux 1.3.90 247 - * New argument "reset_flags" to the reset routine. 248 - * 249 - * 6 Jul 1995 rev. 2.01 for linux 1.3.7 250 - * Update required by the new /proc/scsi support. 251 - * 252 - * 11 Mar 1995 rev. 2.00 for linux 1.2.0 253 - * Fixed a bug which prevented media change detection for removable 254 - * disk drives. 255 - * 256 - * 23 Feb 1995 rev. 1.18 for linux 1.1.94 257 - * Added a check for scsi_register returning NULL. 258 - * 259 - * 11 Feb 1995 rev. 1.17 for linux 1.1.91 260 - * Now DEBUG_RESET is disabled by default. 261 - * Register a board even if it does not assert DMA protocol support 262 - * (DPT SK2011B does not report correctly the dmasup bit). 263 - * 264 - * 9 Feb 1995 rev. 1.16 for linux 1.1.90 265 - * Use host->wish_block instead of host->block. 266 - * New list of Data Out SCSI commands. 267 - * 268 - * 8 Feb 1995 rev. 1.15 for linux 1.1.89 269 - * Cleared target_time_out counter while performing a reset. 270 - * All external symbols renamed to avoid possible name conflicts. 271 - * 272 - * 28 Jan 1995 rev. 1.14 for linux 1.1.86 273 - * Added module support. 274 - * Log and do a retry when a disk drive returns a target status 275 - * different from zero on a recovered error. 276 - * 277 - * 24 Jan 1995 rev. 1.13 for linux 1.1.85 278 - * Use optimized board configuration, with a measured performance 279 - * increase in the range 10%-20% on i/o throughput. 280 - * 281 - * 16 Jan 1995 rev. 1.12 for linux 1.1.81 282 - * Fix mscp structure comments (no functional change). 283 - * Display a message if check_region detects a port address 284 - * already in use. 285 - * 286 - * 17 Dec 1994 rev. 1.11 for linux 1.1.74 287 - * Use the scsicam_bios_param routine. This allows an easy 288 - * migration path from disk partition tables created using 289 - * different SCSI drivers and non optimal disk geometry. 290 - * 291 - * 15 Dec 1994 rev. 1.10 for linux 1.1.74 292 - * Added support for ISA EATA boards (DPT PM2011, DPT PM2021). 293 - * The host->block flag is set for all the detected ISA boards. 294 - * The detect routine no longer enforces LEVEL triggering 295 - * for EISA boards, it just prints a warning message. 296 - * 297 - * 30 Nov 1994 rev. 1.09 for linux 1.1.68 298 - * Redo i/o on target status CHECK_CONDITION for TYPE_DISK only. 299 - * Added optional support for using a single board at a time. 300 - * 301 - * 18 Nov 1994 rev. 1.08 for linux 1.1.64 302 - * Forces sg_tablesize = 64 and can_queue = 64 if these 303 - * values are not correctly detected (DPT PM2012). 304 - * 305 - * 14 Nov 1994 rev. 1.07 for linux 1.1.63 Final BETA release. 306 - * 04 Aug 1994 rev. 1.00 for linux 1.1.39 First BETA release. 307 - * 308 - * 309 - * This driver is based on the CAM (Common Access Method Committee) 310 - * EATA (Enhanced AT Bus Attachment) rev. 2.0A, using DMA protocol. 311 - * 312 - * Copyright (C) 1994-2003 Dario Ballabio (ballabio_dario@emc.com) 313 - * 314 - * Alternate email: dario.ballabio@inwind.it, dario.ballabio@tiscalinet.it 315 - * 316 - * Redistribution and use in source and binary forms, with or without 317 - * modification, are permitted provided that redistributions of source 318 - * code retain the above copyright notice and this comment without 319 - * modification. 320 - * 321 - */ 322 - 323 - /* 324 - * 325 - * Here is a brief description of the DPT SCSI host adapters. 326 - * All these boards provide an EATA/DMA compatible programming interface 327 - * and are fully supported by this driver in any configuration, including 328 - * multiple SCSI channels: 329 - * 330 - * PM2011B/9X - Entry Level ISA 331 - * PM2021A/9X - High Performance ISA 332 - * PM2012A Old EISA 333 - * PM2012B Old EISA 334 - * PM2022A/9X - Entry Level EISA 335 - * PM2122A/9X - High Performance EISA 336 - * PM2322A/9X - Extra High Performance EISA 337 - * PM3021 - SmartRAID Adapter for ISA 338 - * PM3222 - SmartRAID Adapter for EISA (PM3222W is 16-bit wide SCSI) 339 - * PM3224 - SmartRAID Adapter for PCI (PM3224W is 16-bit wide SCSI) 340 - * PM33340UW - SmartRAID Adapter for PCI ultra wide multichannel 341 - * 342 - * The above list is just an indication: as a matter of fact all DPT 343 - * boards using the EATA/DMA protocol are supported by this driver, 344 - * since they use exactely the same programming interface. 345 - * 346 - * The DPT PM2001 provides only the EATA/PIO interface and hence is not 347 - * supported by this driver. 348 - * 349 - * This code has been tested with up to 3 Distributed Processing Technology 350 - * PM2122A/9X (DPT SCSI BIOS v002.D1, firmware v05E.0) EISA controllers, 351 - * in any combination of private and shared IRQ. 352 - * PCI support has been tested using up to 2 DPT PM3224W (DPT SCSI BIOS 353 - * v003.D0, firmware v07G.0). 354 - * 355 - * DPT SmartRAID boards support "Hardware Array" - a group of disk drives 356 - * which are all members of the same RAID-0, RAID-1 or RAID-5 array implemented 357 - * in host adapter hardware. Hardware Arrays are fully compatible with this 358 - * driver, since they look to it as a single disk drive. 359 - * 360 - * WARNING: to create a RAID-0 "Hardware Array" you must select "Other Unix" 361 - * as the current OS in the DPTMGR "Initial System Installation" menu. 362 - * Otherwise RAID-0 is generated as an "Array Group" (i.e. software RAID-0), 363 - * which is not supported by the actual SCSI subsystem. 364 - * To get the "Array Group" functionality, the Linux MD driver must be used 365 - * instead of the DPT "Array Group" feature. 366 - * 367 - * Multiple ISA, EISA and PCI boards can be configured in the same system. 368 - * It is suggested to put all the EISA boards on the same IRQ level, all 369 - * the PCI boards on another IRQ level, while ISA boards cannot share 370 - * interrupts. 371 - * 372 - * If you configure multiple boards on the same IRQ, the interrupt must 373 - * be _level_ triggered (not _edge_ triggered). 374 - * 375 - * This driver detects EATA boards by probes at fixed port addresses, 376 - * so no BIOS32 or PCI BIOS support is required. 377 - * The suggested way to detect a generic EATA PCI board is to force on it 378 - * any unused EISA address, even if there are other controllers on the EISA 379 - * bus, or even if you system has no EISA bus at all. 380 - * Do not force any ISA address on EATA PCI boards. 381 - * 382 - * If PCI bios support is configured into the kernel, BIOS32 is used to 383 - * include in the list of i/o ports to be probed all the PCI SCSI controllers. 384 - * 385 - * Due to a DPT BIOS "feature", it might not be possible to force an EISA 386 - * address on more than a single DPT PCI board, so in this case you have to 387 - * let the PCI BIOS assign the addresses. 388 - * 389 - * The sequence of detection probes is: 390 - * 391 - * - ISA 0x1F0; 392 - * - PCI SCSI controllers (only if BIOS32 is available); 393 - * - EISA/PCI 0x1C88 through 0xFC88 (corresponding to EISA slots 1 to 15); 394 - * - ISA 0x170, 0x230, 0x330. 395 - * 396 - * The above list of detection probes can be totally replaced by the 397 - * boot command line option: "eata=port0,port1,port2,...", where the 398 - * port0, port1... arguments are ISA/EISA/PCI addresses to be probed. 399 - * For example using "eata=0x7410,0x7450,0x230", the driver probes 400 - * only the two PCI addresses 0x7410 and 0x7450 and the ISA address 0x230, 401 - * in this order; "eata=0" totally disables this driver. 402 - * 403 - * After the optional list of detection probes, other possible command line 404 - * options are: 405 - * 406 - * et:y force use of extended translation (255 heads, 63 sectors); 407 - * et:n use disk geometry detected by scsicam_bios_param; 408 - * rs:y reverse scan order while detecting PCI boards; 409 - * rs:n use BIOS order while detecting PCI boards; 410 - * lc:y enables linked commands; 411 - * lc:n disables linked commands; 412 - * tm:0 disables tagged commands (same as tc:n); 413 - * tm:1 use simple queue tags (same as tc:y); 414 - * tm:2 use ordered queue tags (same as tc:2); 415 - * mq:xx set the max queue depth to the value xx (2 <= xx <= 32). 416 - * 417 - * The default value is: "eata=lc:n,mq:16,tm:0,et:n,rs:n". 418 - * An example using the list of detection probes could be: 419 - * "eata=0x7410,0x230,lc:y,tm:2,mq:4,et:n". 420 - * 421 - * When loading as a module, parameters can be specified as well. 422 - * The above example would be (use 1 in place of y and 0 in place of n): 423 - * 424 - * modprobe eata io_port=0x7410,0x230 linked_comm=1 \ 425 - * max_queue_depth=4 ext_tran=0 tag_mode=2 \ 426 - * rev_scan=1 427 - * 428 - * ---------------------------------------------------------------------------- 429 - * In this implementation, linked commands are designed to work with any DISK 430 - * or CD-ROM, since this linking has only the intent of clustering (time-wise) 431 - * and reordering by elevator sorting commands directed to each device, 432 - * without any relation with the actual SCSI protocol between the controller 433 - * and the device. 434 - * If Q is the queue depth reported at boot time for each device (also named 435 - * cmds/lun) and Q > 2, whenever there is already an active command to the 436 - * device all other commands to the same device (up to Q-1) are kept waiting 437 - * in the elevator sorting queue. When the active command completes, the 438 - * commands in this queue are sorted by sector address. The sort is chosen 439 - * between increasing or decreasing by minimizing the seek distance between 440 - * the sector of the commands just completed and the sector of the first 441 - * command in the list to be sorted. 442 - * Trivial math assures that the unsorted average seek distance when doing 443 - * random seeks over S sectors is S/3. 444 - * When (Q-1) requests are uniformly distributed over S sectors, the average 445 - * distance between two adjacent requests is S/((Q-1) + 1), so the sorted 446 - * average seek distance for (Q-1) random requests over S sectors is S/Q. 447 - * The elevator sorting hence divides the seek distance by a factor Q/3. 448 - * The above pure geometric remarks are valid in all cases and the 449 - * driver effectively reduces the seek distance by the predicted factor 450 - * when there are Q concurrent read i/o operations on the device, but this 451 - * does not necessarily results in a noticeable performance improvement: 452 - * your mileage may vary.... 453 - * 454 - * Note: command reordering inside a batch of queued commands could cause 455 - * wrong results only if there is at least one write request and the 456 - * intersection (sector-wise) of all requests is not empty. 457 - * When the driver detects a batch including overlapping requests 458 - * (a really rare event) strict serial (pid) order is enforced. 459 - * ---------------------------------------------------------------------------- 460 - * The extended translation option (et:y) is useful when using large physical 461 - * disks/arrays. It could also be useful when switching between Adaptec boards 462 - * and DPT boards without reformatting the disk. 463 - * When a boot disk is partitioned with extended translation, in order to 464 - * be able to boot it with a DPT board is could be necessary to add to 465 - * lilo.conf additional commands as in the following example: 466 - * 467 - * fix-table 468 - * disk=/dev/sda bios=0x80 sectors=63 heads=128 cylindres=546 469 - * 470 - * where the above geometry should be replaced with the one reported at 471 - * power up by the DPT controller. 472 - * ---------------------------------------------------------------------------- 473 - * 474 - * The boards are named EATA0, EATA1,... according to the detection order. 475 - * 476 - * In order to support multiple ISA boards in a reliable way, 477 - * the driver sets host->wish_block = 1 for all ISA boards. 478 - */ 479 - 480 - #include <linux/string.h> 481 - #include <linux/kernel.h> 482 - #include <linux/ioport.h> 483 - #include <linux/delay.h> 484 - #include <linux/proc_fs.h> 485 - #include <linux/blkdev.h> 486 - #include <linux/interrupt.h> 487 - #include <linux/stat.h> 488 - #include <linux/pci.h> 489 - #include <linux/init.h> 490 - #include <linux/ctype.h> 491 - #include <linux/spinlock.h> 492 - #include <linux/dma-mapping.h> 493 - #include <linux/slab.h> 494 - #include <asm/byteorder.h> 495 - #include <asm/dma.h> 496 - #include <asm/io.h> 497 - #include <asm/irq.h> 498 - 499 - #include <scsi/scsi.h> 500 - #include <scsi/scsi_cmnd.h> 501 - #include <scsi/scsi_device.h> 502 - #include <scsi/scsi_host.h> 503 - #include <scsi/scsi_tcq.h> 504 - #include <scsi/scsicam.h> 505 - 506 - static int eata2x_detect(struct scsi_host_template *); 507 - static int eata2x_release(struct Scsi_Host *); 508 - static int eata2x_queuecommand(struct Scsi_Host *, struct scsi_cmnd *); 509 - static int eata2x_eh_abort(struct scsi_cmnd *); 510 - static int eata2x_eh_host_reset(struct scsi_cmnd *); 511 - static int eata2x_bios_param(struct scsi_device *, struct block_device *, 512 - sector_t, int *); 513 - static int eata2x_slave_configure(struct scsi_device *); 514 - 515 - static struct scsi_host_template driver_template = { 516 - .name = "EATA/DMA 2.0x rev. 8.10.00 ", 517 - .detect = eata2x_detect, 518 - .release = eata2x_release, 519 - .queuecommand = eata2x_queuecommand, 520 - .eh_abort_handler = eata2x_eh_abort, 521 - .eh_host_reset_handler = eata2x_eh_host_reset, 522 - .bios_param = eata2x_bios_param, 523 - .slave_configure = eata2x_slave_configure, 524 - .this_id = 7, 525 - .unchecked_isa_dma = 1, 526 - .use_clustering = ENABLE_CLUSTERING, 527 - }; 528 - 529 - #if !defined(__BIG_ENDIAN_BITFIELD) && !defined(__LITTLE_ENDIAN_BITFIELD) 530 - #error "Adjust your <asm/byteorder.h> defines" 531 - #endif 532 - 533 - /* Subversion values */ 534 - #define ISA 0 535 - #define ESA 1 536 - 537 - #undef FORCE_CONFIG 538 - 539 - #undef DEBUG_LINKED_COMMANDS 540 - #undef DEBUG_DETECT 541 - #undef DEBUG_PCI_DETECT 542 - #undef DEBUG_INTERRUPT 543 - #undef DEBUG_RESET 544 - #undef DEBUG_GENERATE_ERRORS 545 - #undef DEBUG_GENERATE_ABORTS 546 - #undef DEBUG_GEOMETRY 547 - 548 - #define MAX_ISA 4 549 - #define MAX_VESA 0 550 - #define MAX_EISA 15 551 - #define MAX_PCI 16 552 - #define MAX_BOARDS (MAX_ISA + MAX_VESA + MAX_EISA + MAX_PCI) 553 - #define MAX_CHANNEL 4 554 - #define MAX_LUN 32 555 - #define MAX_TARGET 32 556 - #define MAX_MAILBOXES 64 557 - #define MAX_SGLIST 64 558 - #define MAX_LARGE_SGLIST 122 559 - #define MAX_INTERNAL_RETRIES 64 560 - #define MAX_CMD_PER_LUN 2 561 - #define MAX_TAGGED_CMD_PER_LUN (MAX_MAILBOXES - MAX_CMD_PER_LUN) 562 - 563 - #define SKIP ULONG_MAX 564 - #define FREE 0 565 - #define IN_USE 1 566 - #define LOCKED 2 567 - #define IN_RESET 3 568 - #define IGNORE 4 569 - #define READY 5 570 - #define ABORTING 6 571 - #define NO_DMA 0xff 572 - #define MAXLOOP 10000 573 - #define TAG_DISABLED 0 574 - #define TAG_SIMPLE 1 575 - #define TAG_ORDERED 2 576 - 577 - #define REG_CMD 7 578 - #define REG_STATUS 7 579 - #define REG_AUX_STATUS 8 580 - #define REG_DATA 0 581 - #define REG_DATA2 1 582 - #define REG_SEE 6 583 - #define REG_LOW 2 584 - #define REG_LM 3 585 - #define REG_MID 4 586 - #define REG_MSB 5 587 - #define REGION_SIZE 9UL 588 - #define MAX_ISA_ADDR 0x03ff 589 - #define MIN_EISA_ADDR 0x1c88 590 - #define MAX_EISA_ADDR 0xfc88 591 - #define BSY_ASSERTED 0x80 592 - #define DRQ_ASSERTED 0x08 593 - #define ABSY_ASSERTED 0x01 594 - #define IRQ_ASSERTED 0x02 595 - #define READ_CONFIG_PIO 0xf0 596 - #define SET_CONFIG_PIO 0xf1 597 - #define SEND_CP_PIO 0xf2 598 - #define RECEIVE_SP_PIO 0xf3 599 - #define TRUNCATE_XFR_PIO 0xf4 600 - #define RESET_PIO 0xf9 601 - #define READ_CONFIG_DMA 0xfd 602 - #define SET_CONFIG_DMA 0xfe 603 - #define SEND_CP_DMA 0xff 604 - #define ASOK 0x00 605 - #define ASST 0x01 606 - 607 - #define YESNO(a) ((a) ? 'y' : 'n') 608 - #define TLDEV(type) ((type) == TYPE_DISK || (type) == TYPE_ROM) 609 - 610 - /* "EATA", in Big Endian format */ 611 - #define EATA_SIG_BE 0x45415441 612 - 613 - /* Number of valid bytes in the board config structure for EATA 2.0x */ 614 - #define EATA_2_0A_SIZE 28 615 - #define EATA_2_0B_SIZE 30 616 - #define EATA_2_0C_SIZE 34 617 - 618 - /* Board info structure */ 619 - struct eata_info { 620 - u_int32_t data_len; /* Number of valid bytes after this field */ 621 - u_int32_t sign; /* ASCII "EATA" signature */ 622 - 623 - #if defined(__BIG_ENDIAN_BITFIELD) 624 - unchar version : 4, 625 - : 4; 626 - unchar haaval : 1, 627 - ata : 1, 628 - drqvld : 1, 629 - dmasup : 1, 630 - morsup : 1, 631 - trnxfr : 1, 632 - tarsup : 1, 633 - ocsena : 1; 634 - #else 635 - unchar : 4, /* unused low nibble */ 636 - version : 4; /* EATA version, should be 0x1 */ 637 - unchar ocsena : 1, /* Overlap Command Support Enabled */ 638 - tarsup : 1, /* Target Mode Supported */ 639 - trnxfr : 1, /* Truncate Transfer Cmd NOT Necessary */ 640 - morsup : 1, /* More Supported */ 641 - dmasup : 1, /* DMA Supported */ 642 - drqvld : 1, /* DRQ Index (DRQX) is valid */ 643 - ata : 1, /* This is an ATA device */ 644 - haaval : 1; /* Host Adapter Address Valid */ 645 - #endif 646 - 647 - ushort cp_pad_len; /* Number of pad bytes after cp_len */ 648 - unchar host_addr[4]; /* Host Adapter SCSI ID for channels 3, 2, 1, 0 */ 649 - u_int32_t cp_len; /* Number of valid bytes in cp */ 650 - u_int32_t sp_len; /* Number of valid bytes in sp */ 651 - ushort queue_size; /* Max number of cp that can be queued */ 652 - ushort unused; 653 - ushort scatt_size; /* Max number of entries in scatter/gather table */ 654 - 655 - #if defined(__BIG_ENDIAN_BITFIELD) 656 - unchar drqx : 2, 657 - second : 1, 658 - irq_tr : 1, 659 - irq : 4; 660 - unchar sync; 661 - unchar : 4, 662 - res1 : 1, 663 - large_sg : 1, 664 - forcaddr : 1, 665 - isaena : 1; 666 - unchar max_chan : 3, 667 - max_id : 5; 668 - unchar max_lun; 669 - unchar eisa : 1, 670 - pci : 1, 671 - idquest : 1, 672 - m1 : 1, 673 - : 4; 674 - #else 675 - unchar irq : 4, /* Interrupt Request assigned to this controller */ 676 - irq_tr : 1, /* 0 for edge triggered, 1 for level triggered */ 677 - second : 1, /* 1 if this is a secondary (not primary) controller */ 678 - drqx : 2; /* DRQ Index (0=DMA0, 1=DMA7, 2=DMA6, 3=DMA5) */ 679 - unchar sync; /* 1 if scsi target id 7...0 is running sync scsi */ 680 - 681 - /* Structure extension defined in EATA 2.0B */ 682 - unchar isaena : 1, /* ISA i/o addressing is disabled/enabled */ 683 - forcaddr : 1, /* Port address has been forced */ 684 - large_sg : 1, /* 1 if large SG lists are supported */ 685 - res1 : 1, 686 - : 4; 687 - unchar max_id : 5, /* Max SCSI target ID number */ 688 - max_chan : 3; /* Max SCSI channel number on this board */ 689 - 690 - /* Structure extension defined in EATA 2.0C */ 691 - unchar max_lun; /* Max SCSI LUN number */ 692 - unchar 693 - : 4, 694 - m1 : 1, /* This is a PCI with an M1 chip installed */ 695 - idquest : 1, /* RAIDNUM returned is questionable */ 696 - pci : 1, /* This board is PCI */ 697 - eisa : 1; /* This board is EISA */ 698 - #endif 699 - 700 - unchar raidnum; /* Uniquely identifies this HBA in a system */ 701 - unchar notused; 702 - 703 - ushort ipad[247]; 704 - }; 705 - 706 - /* Board config structure */ 707 - struct eata_config { 708 - ushort len; /* Number of bytes following this field */ 709 - 710 - #if defined(__BIG_ENDIAN_BITFIELD) 711 - unchar : 4, 712 - tarena : 1, 713 - mdpena : 1, 714 - ocena : 1, 715 - edis : 1; 716 - #else 717 - unchar edis : 1, /* Disable EATA interface after config command */ 718 - ocena : 1, /* Overlapped Commands Enabled */ 719 - mdpena : 1, /* Transfer all Modified Data Pointer Messages */ 720 - tarena : 1, /* Target Mode Enabled for this controller */ 721 - : 4; 722 - #endif 723 - unchar cpad[511]; 724 - }; 725 - 726 - /* Returned status packet structure */ 727 - struct mssp { 728 - #if defined(__BIG_ENDIAN_BITFIELD) 729 - unchar eoc : 1, 730 - adapter_status : 7; 731 - #else 732 - unchar adapter_status : 7, /* State related to current command */ 733 - eoc : 1; /* End Of Command (1 = command completed) */ 734 - #endif 735 - unchar target_status; /* SCSI status received after data transfer */ 736 - unchar unused[2]; 737 - u_int32_t inv_res_len; /* Number of bytes not transferred */ 738 - u_int32_t cpp_index; /* Index of address set in cp */ 739 - char mess[12]; 740 - }; 741 - 742 - struct sg_list { 743 - unsigned int address; /* Segment Address */ 744 - unsigned int num_bytes; /* Segment Length */ 745 - }; 746 - 747 - /* MailBox SCSI Command Packet */ 748 - struct mscp { 749 - #if defined(__BIG_ENDIAN_BITFIELD) 750 - unchar din : 1, 751 - dout : 1, 752 - interp : 1, 753 - : 1, 754 - sg : 1, 755 - reqsen :1, 756 - init : 1, 757 - sreset : 1; 758 - unchar sense_len; 759 - unchar unused[3]; 760 - unchar : 7, 761 - fwnest : 1; 762 - unchar : 5, 763 - hbaci : 1, 764 - iat : 1, 765 - phsunit : 1; 766 - unchar channel : 3, 767 - target : 5; 768 - unchar one : 1, 769 - dispri : 1, 770 - luntar : 1, 771 - lun : 5; 772 - #else 773 - unchar sreset :1, /* SCSI Bus Reset Signal should be asserted */ 774 - init :1, /* Re-initialize controller and self test */ 775 - reqsen :1, /* Transfer Request Sense Data to addr using DMA */ 776 - sg :1, /* Use Scatter/Gather */ 777 - :1, 778 - interp :1, /* The controller interprets cp, not the target */ 779 - dout :1, /* Direction of Transfer is Out (Host to Target) */ 780 - din :1; /* Direction of Transfer is In (Target to Host) */ 781 - unchar sense_len; /* Request Sense Length */ 782 - unchar unused[3]; 783 - unchar fwnest : 1, /* Send command to a component of an Array Group */ 784 - : 7; 785 - unchar phsunit : 1, /* Send to Target Physical Unit (bypass RAID) */ 786 - iat : 1, /* Inhibit Address Translation */ 787 - hbaci : 1, /* Inhibit HBA Caching for this command */ 788 - : 5; 789 - unchar target : 5, /* SCSI target ID */ 790 - channel : 3; /* SCSI channel number */ 791 - unchar lun : 5, /* SCSI logical unit number */ 792 - luntar : 1, /* This cp is for Target (not LUN) */ 793 - dispri : 1, /* Disconnect Privilege granted */ 794 - one : 1; /* 1 */ 795 - #endif 796 - 797 - unchar mess[3]; /* Massage to/from Target */ 798 - unchar cdb[12]; /* Command Descriptor Block */ 799 - u_int32_t data_len; /* If sg=0 Data Length, if sg=1 sglist length */ 800 - u_int32_t cpp_index; /* Index of address to be returned in sp */ 801 - u_int32_t data_address; /* If sg=0 Data Address, if sg=1 sglist address */ 802 - u_int32_t sp_dma_addr; /* Address where sp is DMA'ed when cp completes */ 803 - u_int32_t sense_addr; /* Address where Sense Data is DMA'ed on error */ 804 - 805 - /* Additional fields begin here. */ 806 - struct scsi_cmnd *SCpnt; 807 - 808 - /* All the cp structure is zero filled by queuecommand except the 809 - following CP_TAIL_SIZE bytes, initialized by detect */ 810 - dma_addr_t cp_dma_addr; /* dma handle for this cp structure */ 811 - struct sg_list *sglist; /* pointer to the allocated SG list */ 812 - }; 813 - 814 - #define CP_TAIL_SIZE (sizeof(struct sglist *) + sizeof(dma_addr_t)) 815 - 816 - struct hostdata { 817 - struct mscp cp[MAX_MAILBOXES]; /* Mailboxes for this board */ 818 - unsigned int cp_stat[MAX_MAILBOXES]; /* FREE, IN_USE, LOCKED, IN_RESET */ 819 - unsigned int last_cp_used; /* Index of last mailbox used */ 820 - unsigned int iocount; /* Total i/o done for this board */ 821 - int board_number; /* Number of this board */ 822 - char board_name[16]; /* Name of this board */ 823 - int in_reset; /* True if board is doing a reset */ 824 - int target_to[MAX_TARGET][MAX_CHANNEL]; /* N. of timeout errors on target */ 825 - int target_redo[MAX_TARGET][MAX_CHANNEL]; /* If 1 redo i/o on target */ 826 - unsigned int retries; /* Number of internal retries */ 827 - unsigned long last_retried_pid; /* Pid of last retried command */ 828 - unsigned char subversion; /* Bus type, either ISA or EISA/PCI */ 829 - unsigned char protocol_rev; /* EATA 2.0 rev., 'A' or 'B' or 'C' */ 830 - unsigned char is_pci; /* 1 is bus type is PCI */ 831 - struct pci_dev *pdev; /* pdev for PCI bus, NULL otherwise */ 832 - struct mssp *sp_cpu_addr; /* cpu addr for DMA buffer sp */ 833 - dma_addr_t sp_dma_addr; /* dma handle for DMA buffer sp */ 834 - struct mssp sp; /* Local copy of sp buffer */ 835 - }; 836 - 837 - static struct Scsi_Host *sh[MAX_BOARDS]; 838 - static const char *driver_name = "EATA"; 839 - static char sha[MAX_BOARDS]; 840 - 841 - /* Initialize num_boards so that ihdlr can work while detect is in progress */ 842 - static unsigned int num_boards = MAX_BOARDS; 843 - 844 - static unsigned long io_port[] = { 845 - 846 - /* Space for MAX_INT_PARAM ports usable while loading as a module */ 847 - SKIP, SKIP, SKIP, SKIP, SKIP, SKIP, SKIP, SKIP, 848 - SKIP, SKIP, 849 - 850 - /* First ISA */ 851 - 0x1f0, 852 - 853 - /* Space for MAX_PCI ports possibly reported by PCI_BIOS */ 854 - SKIP, SKIP, SKIP, SKIP, SKIP, SKIP, SKIP, SKIP, 855 - SKIP, SKIP, SKIP, SKIP, SKIP, SKIP, SKIP, SKIP, 856 - 857 - /* MAX_EISA ports */ 858 - 0x1c88, 0x2c88, 0x3c88, 0x4c88, 0x5c88, 0x6c88, 0x7c88, 0x8c88, 859 - 0x9c88, 0xac88, 0xbc88, 0xcc88, 0xdc88, 0xec88, 0xfc88, 860 - 861 - /* Other (MAX_ISA - 1) ports */ 862 - 0x170, 0x230, 0x330, 863 - 864 - /* End of list */ 865 - 0x0 866 - }; 867 - 868 - /* Device is Big Endian */ 869 - #define H2DEV(x) cpu_to_be32(x) 870 - #define DEV2H(x) be32_to_cpu(x) 871 - #define H2DEV16(x) cpu_to_be16(x) 872 - #define DEV2H16(x) be16_to_cpu(x) 873 - 874 - /* But transfer orientation from the 16 bit data register is Little Endian */ 875 - #define REG2H(x) le16_to_cpu(x) 876 - 877 - static irqreturn_t do_interrupt_handler(int, void *); 878 - static void flush_dev(struct scsi_device *, unsigned long, struct hostdata *, 879 - unsigned int); 880 - static int do_trace = 0; 881 - static int setup_done = 0; 882 - static int link_statistics; 883 - static int ext_tran = 0; 884 - static int rev_scan = 1; 885 - 886 - #if defined(CONFIG_SCSI_EATA_TAGGED_QUEUE) 887 - static int tag_mode = TAG_SIMPLE; 888 - #else 889 - static int tag_mode = TAG_DISABLED; 890 - #endif 891 - 892 - #if defined(CONFIG_SCSI_EATA_LINKED_COMMANDS) 893 - static int linked_comm = 1; 894 - #else 895 - static int linked_comm = 0; 896 - #endif 897 - 898 - #if defined(CONFIG_SCSI_EATA_MAX_TAGS) 899 - static int max_queue_depth = CONFIG_SCSI_EATA_MAX_TAGS; 900 - #else 901 - static int max_queue_depth = MAX_CMD_PER_LUN; 902 - #endif 903 - 904 - #if defined(CONFIG_ISA) 905 - static int isa_probe = 1; 906 - #else 907 - static int isa_probe = 0; 908 - #endif 909 - 910 - #if defined(CONFIG_EISA) 911 - static int eisa_probe = 1; 912 - #else 913 - static int eisa_probe = 0; 914 - #endif 915 - 916 - #if defined(CONFIG_PCI) 917 - static int pci_probe = 1; 918 - #else 919 - static int pci_probe = 0; 920 - #endif 921 - 922 - #define MAX_INT_PARAM 10 923 - #define MAX_BOOT_OPTIONS_SIZE 256 924 - static char boot_options[MAX_BOOT_OPTIONS_SIZE]; 925 - 926 - #if defined(MODULE) 927 - #include <linux/module.h> 928 - #include <linux/moduleparam.h> 929 - 930 - module_param_string(eata, boot_options, MAX_BOOT_OPTIONS_SIZE, 0); 931 - MODULE_PARM_DESC(eata, " equivalent to the \"eata=...\" kernel boot option." 932 - " Example: modprobe eata \"eata=0x7410,0x230,lc:y,tm:0,mq:4,ep:n\""); 933 - MODULE_AUTHOR("Dario Ballabio"); 934 - MODULE_LICENSE("GPL"); 935 - MODULE_DESCRIPTION("EATA/DMA SCSI Driver"); 936 - 937 - #endif 938 - 939 - static int eata2x_slave_configure(struct scsi_device *dev) 940 - { 941 - int tqd, utqd; 942 - char *tag_suffix, *link_suffix; 943 - 944 - utqd = MAX_CMD_PER_LUN; 945 - tqd = max_queue_depth; 946 - 947 - if (TLDEV(dev->type) && dev->tagged_supported) { 948 - if (tag_mode == TAG_SIMPLE) { 949 - tag_suffix = ", simple tags"; 950 - } else if (tag_mode == TAG_ORDERED) { 951 - tag_suffix = ", ordered tags"; 952 - } else { 953 - tag_suffix = ", no tags"; 954 - } 955 - scsi_change_queue_depth(dev, tqd); 956 - } else if (TLDEV(dev->type) && linked_comm) { 957 - scsi_change_queue_depth(dev, tqd); 958 - tag_suffix = ", untagged"; 959 - } else { 960 - scsi_change_queue_depth(dev, utqd); 961 - tag_suffix = ""; 962 - } 963 - 964 - if (TLDEV(dev->type) && linked_comm && dev->queue_depth > 2) 965 - link_suffix = ", sorted"; 966 - else if (TLDEV(dev->type)) 967 - link_suffix = ", unsorted"; 968 - else 969 - link_suffix = ""; 970 - 971 - sdev_printk(KERN_INFO, dev, 972 - "cmds/lun %d%s%s.\n", 973 - dev->queue_depth, link_suffix, tag_suffix); 974 - 975 - return 0; 976 - } 977 - 978 - static int wait_on_busy(unsigned long iobase, unsigned int loop) 979 - { 980 - while (inb(iobase + REG_AUX_STATUS) & ABSY_ASSERTED) { 981 - udelay(1L); 982 - if (--loop == 0) 983 - return 1; 984 - } 985 - return 0; 986 - } 987 - 988 - static int do_dma(unsigned long iobase, unsigned long addr, unchar cmd) 989 - { 990 - unsigned char *byaddr; 991 - unsigned long devaddr; 992 - 993 - if (wait_on_busy(iobase, (addr ? MAXLOOP * 100 : MAXLOOP))) 994 - return 1; 995 - 996 - if (addr) { 997 - devaddr = H2DEV(addr); 998 - byaddr = (unsigned char *)&devaddr; 999 - outb(byaddr[3], iobase + REG_LOW); 1000 - outb(byaddr[2], iobase + REG_LM); 1001 - outb(byaddr[1], iobase + REG_MID); 1002 - outb(byaddr[0], iobase + REG_MSB); 1003 - } 1004 - 1005 - outb(cmd, iobase + REG_CMD); 1006 - return 0; 1007 - } 1008 - 1009 - static int read_pio(unsigned long iobase, ushort * start, ushort * end) 1010 - { 1011 - unsigned int loop = MAXLOOP; 1012 - ushort *p; 1013 - 1014 - for (p = start; p <= end; p++) { 1015 - while (!(inb(iobase + REG_STATUS) & DRQ_ASSERTED)) { 1016 - udelay(1L); 1017 - if (--loop == 0) 1018 - return 1; 1019 - } 1020 - loop = MAXLOOP; 1021 - *p = REG2H(inw(iobase)); 1022 - } 1023 - 1024 - return 0; 1025 - } 1026 - 1027 - static struct pci_dev *get_pci_dev(unsigned long port_base) 1028 - { 1029 - #if defined(CONFIG_PCI) 1030 - unsigned int addr; 1031 - struct pci_dev *dev = NULL; 1032 - 1033 - while ((dev = pci_get_class(PCI_CLASS_STORAGE_SCSI << 8, dev))) { 1034 - addr = pci_resource_start(dev, 0); 1035 - 1036 - #if defined(DEBUG_PCI_DETECT) 1037 - printk("%s: get_pci_dev, bus %d, devfn 0x%x, addr 0x%x.\n", 1038 - driver_name, dev->bus->number, dev->devfn, addr); 1039 - #endif 1040 - 1041 - /* we are in so much trouble for a pci hotplug system with this driver 1042 - * anyway, so doing this at least lets people unload the driver and not 1043 - * cause memory problems, but in general this is a bad thing to do (this 1044 - * driver needs to be converted to the proper PCI api someday... */ 1045 - pci_dev_put(dev); 1046 - if (addr + PCI_BASE_ADDRESS_0 == port_base) 1047 - return dev; 1048 - } 1049 - #endif /* end CONFIG_PCI */ 1050 - return NULL; 1051 - } 1052 - 1053 - static void enable_pci_ports(void) 1054 - { 1055 - #if defined(CONFIG_PCI) 1056 - struct pci_dev *dev = NULL; 1057 - 1058 - while ((dev = pci_get_class(PCI_CLASS_STORAGE_SCSI << 8, dev))) { 1059 - #if defined(DEBUG_PCI_DETECT) 1060 - printk("%s: enable_pci_ports, bus %d, devfn 0x%x.\n", 1061 - driver_name, dev->bus->number, dev->devfn); 1062 - #endif 1063 - 1064 - if (pci_enable_device(dev)) 1065 - printk 1066 - ("%s: warning, pci_enable_device failed, bus %d devfn 0x%x.\n", 1067 - driver_name, dev->bus->number, dev->devfn); 1068 - } 1069 - 1070 - #endif /* end CONFIG_PCI */ 1071 - } 1072 - 1073 - static int port_detect(unsigned long port_base, unsigned int j, 1074 - struct scsi_host_template *tpnt) 1075 - { 1076 - unsigned char irq, dma_channel, subversion, i, is_pci = 0; 1077 - unsigned char protocol_rev; 1078 - struct eata_info info; 1079 - char *bus_type, dma_name[16]; 1080 - struct pci_dev *pdev; 1081 - /* Allowed DMA channels for ISA (0 indicates reserved) */ 1082 - unsigned char dma_channel_table[4] = { 5, 6, 7, 0 }; 1083 - struct Scsi_Host *shost; 1084 - struct hostdata *ha; 1085 - char name[16]; 1086 - 1087 - sprintf(name, "%s%d", driver_name, j); 1088 - 1089 - if (!request_region(port_base, REGION_SIZE, driver_name)) { 1090 - #if defined(DEBUG_DETECT) 1091 - printk("%s: address 0x%03lx in use, skipping probe.\n", name, 1092 - port_base); 1093 - #endif 1094 - goto fail; 1095 - } 1096 - 1097 - if (do_dma(port_base, 0, READ_CONFIG_PIO)) { 1098 - #if defined(DEBUG_DETECT) 1099 - printk("%s: detect, do_dma failed at 0x%03lx.\n", name, 1100 - port_base); 1101 - #endif 1102 - goto freelock; 1103 - } 1104 - 1105 - /* Read the info structure */ 1106 - if (read_pio(port_base, (ushort *) & info, (ushort *) & info.ipad[0])) { 1107 - #if defined(DEBUG_DETECT) 1108 - printk("%s: detect, read_pio failed at 0x%03lx.\n", name, 1109 - port_base); 1110 - #endif 1111 - goto freelock; 1112 - } 1113 - 1114 - info.data_len = DEV2H(info.data_len); 1115 - info.sign = DEV2H(info.sign); 1116 - info.cp_pad_len = DEV2H16(info.cp_pad_len); 1117 - info.cp_len = DEV2H(info.cp_len); 1118 - info.sp_len = DEV2H(info.sp_len); 1119 - info.scatt_size = DEV2H16(info.scatt_size); 1120 - info.queue_size = DEV2H16(info.queue_size); 1121 - 1122 - /* Check the controller "EATA" signature */ 1123 - if (info.sign != EATA_SIG_BE) { 1124 - #if defined(DEBUG_DETECT) 1125 - printk("%s: signature 0x%04x discarded.\n", name, info.sign); 1126 - #endif 1127 - goto freelock; 1128 - } 1129 - 1130 - if (info.data_len < EATA_2_0A_SIZE) { 1131 - printk 1132 - ("%s: config structure size (%d bytes) too short, detaching.\n", 1133 - name, info.data_len); 1134 - goto freelock; 1135 - } else if (info.data_len == EATA_2_0A_SIZE) 1136 - protocol_rev = 'A'; 1137 - else if (info.data_len == EATA_2_0B_SIZE) 1138 - protocol_rev = 'B'; 1139 - else 1140 - protocol_rev = 'C'; 1141 - 1142 - if (protocol_rev != 'A' && info.forcaddr) { 1143 - printk("%s: warning, port address has been forced.\n", name); 1144 - bus_type = "PCI"; 1145 - is_pci = 1; 1146 - subversion = ESA; 1147 - } else if (port_base > MAX_EISA_ADDR 1148 - || (protocol_rev == 'C' && info.pci)) { 1149 - bus_type = "PCI"; 1150 - is_pci = 1; 1151 - subversion = ESA; 1152 - } else if (port_base >= MIN_EISA_ADDR 1153 - || (protocol_rev == 'C' && info.eisa)) { 1154 - bus_type = "EISA"; 1155 - subversion = ESA; 1156 - } else if (protocol_rev == 'C' && !info.eisa && !info.pci) { 1157 - bus_type = "ISA"; 1158 - subversion = ISA; 1159 - } else if (port_base > MAX_ISA_ADDR) { 1160 - bus_type = "PCI"; 1161 - is_pci = 1; 1162 - subversion = ESA; 1163 - } else { 1164 - bus_type = "ISA"; 1165 - subversion = ISA; 1166 - } 1167 - 1168 - if (!info.haaval || info.ata) { 1169 - printk 1170 - ("%s: address 0x%03lx, unusable %s board (%d%d), detaching.\n", 1171 - name, port_base, bus_type, info.haaval, info.ata); 1172 - goto freelock; 1173 - } 1174 - 1175 - if (info.drqvld) { 1176 - if (subversion == ESA) 1177 - printk("%s: warning, weird %s board using DMA.\n", name, 1178 - bus_type); 1179 - 1180 - subversion = ISA; 1181 - dma_channel = dma_channel_table[3 - info.drqx]; 1182 - } else { 1183 - if (subversion == ISA) 1184 - printk("%s: warning, weird %s board not using DMA.\n", 1185 - name, bus_type); 1186 - 1187 - subversion = ESA; 1188 - dma_channel = NO_DMA; 1189 - } 1190 - 1191 - if (!info.dmasup) 1192 - printk("%s: warning, DMA protocol support not asserted.\n", 1193 - name); 1194 - 1195 - irq = info.irq; 1196 - 1197 - if (subversion == ESA && !info.irq_tr) 1198 - printk 1199 - ("%s: warning, LEVEL triggering is suggested for IRQ %u.\n", 1200 - name, irq); 1201 - 1202 - if (is_pci) { 1203 - pdev = get_pci_dev(port_base); 1204 - if (!pdev) 1205 - printk 1206 - ("%s: warning, failed to get pci_dev structure.\n", 1207 - name); 1208 - } else 1209 - pdev = NULL; 1210 - 1211 - if (pdev && (irq != pdev->irq)) { 1212 - printk("%s: IRQ %u mapped to IO-APIC IRQ %u.\n", name, irq, 1213 - pdev->irq); 1214 - irq = pdev->irq; 1215 - } 1216 - 1217 - /* Board detected, allocate its IRQ */ 1218 - if (request_irq(irq, do_interrupt_handler, 1219 - (subversion == ESA) ? IRQF_SHARED : 0, 1220 - driver_name, (void *)&sha[j])) { 1221 - printk("%s: unable to allocate IRQ %u, detaching.\n", name, 1222 - irq); 1223 - goto freelock; 1224 - } 1225 - 1226 - if (subversion == ISA && request_dma(dma_channel, driver_name)) { 1227 - printk("%s: unable to allocate DMA channel %u, detaching.\n", 1228 - name, dma_channel); 1229 - goto freeirq; 1230 - } 1231 - #if defined(FORCE_CONFIG) 1232 - { 1233 - struct eata_config *cf; 1234 - dma_addr_t cf_dma_addr; 1235 - 1236 - cf = pci_zalloc_consistent(pdev, sizeof(struct eata_config), 1237 - &cf_dma_addr); 1238 - 1239 - if (!cf) { 1240 - printk 1241 - ("%s: config, pci_alloc_consistent failed, detaching.\n", 1242 - name); 1243 - goto freedma; 1244 - } 1245 - 1246 - /* Set board configuration */ 1247 - cf->len = (ushort) H2DEV16((ushort) 510); 1248 - cf->ocena = 1; 1249 - 1250 - if (do_dma(port_base, cf_dma_addr, SET_CONFIG_DMA)) { 1251 - printk 1252 - ("%s: busy timeout sending configuration, detaching.\n", 1253 - name); 1254 - pci_free_consistent(pdev, sizeof(struct eata_config), 1255 - cf, cf_dma_addr); 1256 - goto freedma; 1257 - } 1258 - 1259 - } 1260 - #endif 1261 - 1262 - sh[j] = shost = scsi_register(tpnt, sizeof(struct hostdata)); 1263 - if (shost == NULL) { 1264 - printk("%s: unable to register host, detaching.\n", name); 1265 - goto freedma; 1266 - } 1267 - 1268 - shost->io_port = port_base; 1269 - shost->unique_id = port_base; 1270 - shost->n_io_port = REGION_SIZE; 1271 - shost->dma_channel = dma_channel; 1272 - shost->irq = irq; 1273 - shost->sg_tablesize = (ushort) info.scatt_size; 1274 - shost->this_id = (ushort) info.host_addr[3]; 1275 - shost->can_queue = (ushort) info.queue_size; 1276 - shost->cmd_per_lun = MAX_CMD_PER_LUN; 1277 - 1278 - ha = (struct hostdata *)shost->hostdata; 1279 - 1280 - memset(ha, 0, sizeof(struct hostdata)); 1281 - ha->subversion = subversion; 1282 - ha->protocol_rev = protocol_rev; 1283 - ha->is_pci = is_pci; 1284 - ha->pdev = pdev; 1285 - ha->board_number = j; 1286 - 1287 - if (ha->subversion == ESA) 1288 - shost->unchecked_isa_dma = 0; 1289 - else { 1290 - unsigned long flags; 1291 - shost->unchecked_isa_dma = 1; 1292 - 1293 - flags = claim_dma_lock(); 1294 - disable_dma(dma_channel); 1295 - clear_dma_ff(dma_channel); 1296 - set_dma_mode(dma_channel, DMA_MODE_CASCADE); 1297 - enable_dma(dma_channel); 1298 - release_dma_lock(flags); 1299 - 1300 - } 1301 - 1302 - strcpy(ha->board_name, name); 1303 - 1304 - /* DPT PM2012 does not allow to detect sg_tablesize correctly */ 1305 - if (shost->sg_tablesize > MAX_SGLIST || shost->sg_tablesize < 2) { 1306 - printk("%s: detect, wrong n. of SG lists %d, fixed.\n", 1307 - ha->board_name, shost->sg_tablesize); 1308 - shost->sg_tablesize = MAX_SGLIST; 1309 - } 1310 - 1311 - /* DPT PM2012 does not allow to detect can_queue correctly */ 1312 - if (shost->can_queue > MAX_MAILBOXES || shost->can_queue < 2) { 1313 - printk("%s: detect, wrong n. of mbox %d, fixed.\n", 1314 - ha->board_name, shost->can_queue); 1315 - shost->can_queue = MAX_MAILBOXES; 1316 - } 1317 - 1318 - if (protocol_rev != 'A') { 1319 - if (info.max_chan > 0 && info.max_chan < MAX_CHANNEL) 1320 - shost->max_channel = info.max_chan; 1321 - 1322 - if (info.max_id > 7 && info.max_id < MAX_TARGET) 1323 - shost->max_id = info.max_id + 1; 1324 - 1325 - if (info.large_sg && shost->sg_tablesize == MAX_SGLIST) 1326 - shost->sg_tablesize = MAX_LARGE_SGLIST; 1327 - } 1328 - 1329 - if (protocol_rev == 'C') { 1330 - if (info.max_lun > 7 && info.max_lun < MAX_LUN) 1331 - shost->max_lun = info.max_lun + 1; 1332 - } 1333 - 1334 - if (dma_channel == NO_DMA) 1335 - sprintf(dma_name, "%s", "BMST"); 1336 - else 1337 - sprintf(dma_name, "DMA %u", dma_channel); 1338 - 1339 - for (i = 0; i < shost->can_queue; i++) 1340 - ha->cp[i].cp_dma_addr = pci_map_single(ha->pdev, 1341 - &ha->cp[i], 1342 - sizeof(struct mscp), 1343 - PCI_DMA_BIDIRECTIONAL); 1344 - 1345 - for (i = 0; i < shost->can_queue; i++) { 1346 - size_t sz = shost->sg_tablesize *sizeof(struct sg_list); 1347 - gfp_t gfp_mask = (shost->unchecked_isa_dma ? GFP_DMA : 0) | GFP_ATOMIC; 1348 - ha->cp[i].sglist = kmalloc(sz, gfp_mask); 1349 - if (!ha->cp[i].sglist) { 1350 - printk 1351 - ("%s: kmalloc SGlist failed, mbox %d, detaching.\n", 1352 - ha->board_name, i); 1353 - goto release; 1354 - } 1355 - } 1356 - 1357 - if (!(ha->sp_cpu_addr = pci_alloc_consistent(ha->pdev, 1358 - sizeof(struct mssp), 1359 - &ha->sp_dma_addr))) { 1360 - printk("%s: pci_alloc_consistent failed, detaching.\n", ha->board_name); 1361 - goto release; 1362 - } 1363 - 1364 - if (max_queue_depth > MAX_TAGGED_CMD_PER_LUN) 1365 - max_queue_depth = MAX_TAGGED_CMD_PER_LUN; 1366 - 1367 - if (max_queue_depth < MAX_CMD_PER_LUN) 1368 - max_queue_depth = MAX_CMD_PER_LUN; 1369 - 1370 - if (tag_mode != TAG_DISABLED && tag_mode != TAG_SIMPLE) 1371 - tag_mode = TAG_ORDERED; 1372 - 1373 - if (j == 0) { 1374 - printk 1375 - ("EATA/DMA 2.0x: Copyright (C) 1994-2003 Dario Ballabio.\n"); 1376 - printk 1377 - ("%s config options -> tm:%d, lc:%c, mq:%d, rs:%c, et:%c, " 1378 - "ip:%c, ep:%c, pp:%c.\n", driver_name, tag_mode, 1379 - YESNO(linked_comm), max_queue_depth, YESNO(rev_scan), 1380 - YESNO(ext_tran), YESNO(isa_probe), YESNO(eisa_probe), 1381 - YESNO(pci_probe)); 1382 - } 1383 - 1384 - printk("%s: 2.0%c, %s 0x%03lx, IRQ %u, %s, SG %d, MB %d.\n", 1385 - ha->board_name, ha->protocol_rev, bus_type, 1386 - (unsigned long)shost->io_port, shost->irq, dma_name, 1387 - shost->sg_tablesize, shost->can_queue); 1388 - 1389 - if (shost->max_id > 8 || shost->max_lun > 8) 1390 - printk 1391 - ("%s: wide SCSI support enabled, max_id %u, max_lun %llu.\n", 1392 - ha->board_name, shost->max_id, shost->max_lun); 1393 - 1394 - for (i = 0; i <= shost->max_channel; i++) 1395 - printk("%s: SCSI channel %u enabled, host target ID %d.\n", 1396 - ha->board_name, i, info.host_addr[3 - i]); 1397 - 1398 - #if defined(DEBUG_DETECT) 1399 - printk("%s: Vers. 0x%x, ocs %u, tar %u, trnxfr %u, more %u, SYNC 0x%x, " 1400 - "sec. %u, infol %d, cpl %d spl %d.\n", name, info.version, 1401 - info.ocsena, info.tarsup, info.trnxfr, info.morsup, info.sync, 1402 - info.second, info.data_len, info.cp_len, info.sp_len); 1403 - 1404 - if (protocol_rev == 'B' || protocol_rev == 'C') 1405 - printk("%s: isaena %u, forcaddr %u, max_id %u, max_chan %u, " 1406 - "large_sg %u, res1 %u.\n", name, info.isaena, 1407 - info.forcaddr, info.max_id, info.max_chan, info.large_sg, 1408 - info.res1); 1409 - 1410 - if (protocol_rev == 'C') 1411 - printk("%s: max_lun %u, m1 %u, idquest %u, pci %u, eisa %u, " 1412 - "raidnum %u.\n", name, info.max_lun, info.m1, 1413 - info.idquest, info.pci, info.eisa, info.raidnum); 1414 - #endif 1415 - 1416 - if (ha->pdev) { 1417 - pci_set_master(ha->pdev); 1418 - if (pci_set_dma_mask(ha->pdev, DMA_BIT_MASK(32))) 1419 - printk("%s: warning, pci_set_dma_mask failed.\n", 1420 - ha->board_name); 1421 - } 1422 - 1423 - return 1; 1424 - 1425 - freedma: 1426 - if (subversion == ISA) 1427 - free_dma(dma_channel); 1428 - freeirq: 1429 - free_irq(irq, &sha[j]); 1430 - freelock: 1431 - release_region(port_base, REGION_SIZE); 1432 - fail: 1433 - return 0; 1434 - 1435 - release: 1436 - eata2x_release(shost); 1437 - return 0; 1438 - } 1439 - 1440 - static void internal_setup(char *str, int *ints) 1441 - { 1442 - int i, argc = ints[0]; 1443 - char *cur = str, *pc; 1444 - 1445 - if (argc > 0) { 1446 - if (argc > MAX_INT_PARAM) 1447 - argc = MAX_INT_PARAM; 1448 - 1449 - for (i = 0; i < argc; i++) 1450 - io_port[i] = ints[i + 1]; 1451 - 1452 - io_port[i] = 0; 1453 - setup_done = 1; 1454 - } 1455 - 1456 - while (cur && (pc = strchr(cur, ':'))) { 1457 - int val = 0, c = *++pc; 1458 - 1459 - if (c == 'n' || c == 'N') 1460 - val = 0; 1461 - else if (c == 'y' || c == 'Y') 1462 - val = 1; 1463 - else 1464 - val = (int)simple_strtoul(pc, NULL, 0); 1465 - 1466 - if (!strncmp(cur, "lc:", 3)) 1467 - linked_comm = val; 1468 - else if (!strncmp(cur, "tm:", 3)) 1469 - tag_mode = val; 1470 - else if (!strncmp(cur, "tc:", 3)) 1471 - tag_mode = val; 1472 - else if (!strncmp(cur, "mq:", 3)) 1473 - max_queue_depth = val; 1474 - else if (!strncmp(cur, "ls:", 3)) 1475 - link_statistics = val; 1476 - else if (!strncmp(cur, "et:", 3)) 1477 - ext_tran = val; 1478 - else if (!strncmp(cur, "rs:", 3)) 1479 - rev_scan = val; 1480 - else if (!strncmp(cur, "ip:", 3)) 1481 - isa_probe = val; 1482 - else if (!strncmp(cur, "ep:", 3)) 1483 - eisa_probe = val; 1484 - else if (!strncmp(cur, "pp:", 3)) 1485 - pci_probe = val; 1486 - 1487 - if ((cur = strchr(cur, ','))) 1488 - ++cur; 1489 - } 1490 - 1491 - return; 1492 - } 1493 - 1494 - static int option_setup(char *str) 1495 - { 1496 - int ints[MAX_INT_PARAM]; 1497 - char *cur = str; 1498 - int i = 1; 1499 - 1500 - while (cur && isdigit(*cur) && i < MAX_INT_PARAM) { 1501 - ints[i++] = simple_strtoul(cur, NULL, 0); 1502 - 1503 - if ((cur = strchr(cur, ',')) != NULL) 1504 - cur++; 1505 - } 1506 - 1507 - ints[0] = i - 1; 1508 - internal_setup(cur, ints); 1509 - return 1; 1510 - } 1511 - 1512 - static void add_pci_ports(void) 1513 - { 1514 - #if defined(CONFIG_PCI) 1515 - unsigned int addr, k; 1516 - struct pci_dev *dev = NULL; 1517 - 1518 - for (k = 0; k < MAX_PCI; k++) { 1519 - 1520 - if (!(dev = pci_get_class(PCI_CLASS_STORAGE_SCSI << 8, dev))) 1521 - break; 1522 - 1523 - if (pci_enable_device(dev)) { 1524 - #if defined(DEBUG_PCI_DETECT) 1525 - printk 1526 - ("%s: detect, bus %d, devfn 0x%x, pci_enable_device failed.\n", 1527 - driver_name, dev->bus->number, dev->devfn); 1528 - #endif 1529 - 1530 - continue; 1531 - } 1532 - 1533 - addr = pci_resource_start(dev, 0); 1534 - 1535 - #if defined(DEBUG_PCI_DETECT) 1536 - printk("%s: detect, seq. %d, bus %d, devfn 0x%x, addr 0x%x.\n", 1537 - driver_name, k, dev->bus->number, dev->devfn, addr); 1538 - #endif 1539 - 1540 - /* Order addresses according to rev_scan value */ 1541 - io_port[MAX_INT_PARAM + (rev_scan ? (MAX_PCI - k) : (1 + k))] = 1542 - addr + PCI_BASE_ADDRESS_0; 1543 - } 1544 - 1545 - pci_dev_put(dev); 1546 - #endif /* end CONFIG_PCI */ 1547 - } 1548 - 1549 - static int eata2x_detect(struct scsi_host_template *tpnt) 1550 - { 1551 - unsigned int j = 0, k; 1552 - 1553 - tpnt->proc_name = "eata2x"; 1554 - 1555 - if (strlen(boot_options)) 1556 - option_setup(boot_options); 1557 - 1558 - #if defined(MODULE) 1559 - /* io_port could have been modified when loading as a module */ 1560 - if (io_port[0] != SKIP) { 1561 - setup_done = 1; 1562 - io_port[MAX_INT_PARAM] = 0; 1563 - } 1564 - #endif 1565 - 1566 - for (k = MAX_INT_PARAM; io_port[k]; k++) 1567 - if (io_port[k] == SKIP) 1568 - continue; 1569 - else if (io_port[k] <= MAX_ISA_ADDR) { 1570 - if (!isa_probe) 1571 - io_port[k] = SKIP; 1572 - } else if (io_port[k] >= MIN_EISA_ADDR 1573 - && io_port[k] <= MAX_EISA_ADDR) { 1574 - if (!eisa_probe) 1575 - io_port[k] = SKIP; 1576 - } 1577 - 1578 - if (pci_probe) { 1579 - if (!setup_done) 1580 - add_pci_ports(); 1581 - else 1582 - enable_pci_ports(); 1583 - } 1584 - 1585 - for (k = 0; io_port[k]; k++) { 1586 - 1587 - if (io_port[k] == SKIP) 1588 - continue; 1589 - 1590 - if (j < MAX_BOARDS && port_detect(io_port[k], j, tpnt)) 1591 - j++; 1592 - } 1593 - 1594 - num_boards = j; 1595 - return j; 1596 - } 1597 - 1598 - static void map_dma(unsigned int i, struct hostdata *ha) 1599 - { 1600 - unsigned int k, pci_dir; 1601 - int count; 1602 - struct scatterlist *sg; 1603 - struct mscp *cpp; 1604 - struct scsi_cmnd *SCpnt; 1605 - 1606 - cpp = &ha->cp[i]; 1607 - SCpnt = cpp->SCpnt; 1608 - pci_dir = SCpnt->sc_data_direction; 1609 - 1610 - if (SCpnt->sense_buffer) 1611 - cpp->sense_addr = 1612 - H2DEV(pci_map_single(ha->pdev, SCpnt->sense_buffer, 1613 - SCSI_SENSE_BUFFERSIZE, PCI_DMA_FROMDEVICE)); 1614 - 1615 - cpp->sense_len = SCSI_SENSE_BUFFERSIZE; 1616 - 1617 - if (!scsi_sg_count(SCpnt)) { 1618 - cpp->data_len = 0; 1619 - return; 1620 - } 1621 - 1622 - count = pci_map_sg(ha->pdev, scsi_sglist(SCpnt), scsi_sg_count(SCpnt), 1623 - pci_dir); 1624 - BUG_ON(!count); 1625 - 1626 - scsi_for_each_sg(SCpnt, sg, count, k) { 1627 - cpp->sglist[k].address = H2DEV(sg_dma_address(sg)); 1628 - cpp->sglist[k].num_bytes = H2DEV(sg_dma_len(sg)); 1629 - } 1630 - 1631 - cpp->sg = 1; 1632 - cpp->data_address = H2DEV(pci_map_single(ha->pdev, cpp->sglist, 1633 - scsi_sg_count(SCpnt) * 1634 - sizeof(struct sg_list), 1635 - pci_dir)); 1636 - cpp->data_len = H2DEV((scsi_sg_count(SCpnt) * sizeof(struct sg_list))); 1637 - } 1638 - 1639 - static void unmap_dma(unsigned int i, struct hostdata *ha) 1640 - { 1641 - unsigned int pci_dir; 1642 - struct mscp *cpp; 1643 - struct scsi_cmnd *SCpnt; 1644 - 1645 - cpp = &ha->cp[i]; 1646 - SCpnt = cpp->SCpnt; 1647 - pci_dir = SCpnt->sc_data_direction; 1648 - 1649 - if (DEV2H(cpp->sense_addr)) 1650 - pci_unmap_single(ha->pdev, DEV2H(cpp->sense_addr), 1651 - DEV2H(cpp->sense_len), PCI_DMA_FROMDEVICE); 1652 - 1653 - if (scsi_sg_count(SCpnt)) 1654 - pci_unmap_sg(ha->pdev, scsi_sglist(SCpnt), scsi_sg_count(SCpnt), 1655 - pci_dir); 1656 - 1657 - if (!DEV2H(cpp->data_len)) 1658 - pci_dir = PCI_DMA_BIDIRECTIONAL; 1659 - 1660 - if (DEV2H(cpp->data_address)) 1661 - pci_unmap_single(ha->pdev, DEV2H(cpp->data_address), 1662 - DEV2H(cpp->data_len), pci_dir); 1663 - } 1664 - 1665 - static void sync_dma(unsigned int i, struct hostdata *ha) 1666 - { 1667 - unsigned int pci_dir; 1668 - struct mscp *cpp; 1669 - struct scsi_cmnd *SCpnt; 1670 - 1671 - cpp = &ha->cp[i]; 1672 - SCpnt = cpp->SCpnt; 1673 - pci_dir = SCpnt->sc_data_direction; 1674 - 1675 - if (DEV2H(cpp->sense_addr)) 1676 - pci_dma_sync_single_for_cpu(ha->pdev, DEV2H(cpp->sense_addr), 1677 - DEV2H(cpp->sense_len), 1678 - PCI_DMA_FROMDEVICE); 1679 - 1680 - if (scsi_sg_count(SCpnt)) 1681 - pci_dma_sync_sg_for_cpu(ha->pdev, scsi_sglist(SCpnt), 1682 - scsi_sg_count(SCpnt), pci_dir); 1683 - 1684 - if (!DEV2H(cpp->data_len)) 1685 - pci_dir = PCI_DMA_BIDIRECTIONAL; 1686 - 1687 - if (DEV2H(cpp->data_address)) 1688 - pci_dma_sync_single_for_cpu(ha->pdev, 1689 - DEV2H(cpp->data_address), 1690 - DEV2H(cpp->data_len), pci_dir); 1691 - } 1692 - 1693 - static void scsi_to_dev_dir(unsigned int i, struct hostdata *ha) 1694 - { 1695 - unsigned int k; 1696 - 1697 - static const unsigned char data_out_cmds[] = { 1698 - 0x0a, 0x2a, 0x15, 0x55, 0x04, 0x07, 0x18, 0x1d, 0x24, 0x2e, 1699 - 0x30, 0x31, 0x32, 0x38, 0x39, 0x3a, 0x3b, 0x3d, 0x3f, 0x40, 1700 - 0x41, 0x4c, 0xaa, 0xae, 0xb0, 0xb1, 0xb2, 0xb6, 0xea, 0x1b, 0x5d 1701 - }; 1702 - 1703 - static const unsigned char data_none_cmds[] = { 1704 - 0x01, 0x0b, 0x10, 0x11, 0x13, 0x16, 0x17, 0x19, 0x2b, 0x1e, 1705 - 0x2c, 0xac, 0x2f, 0xaf, 0x33, 0xb3, 0x35, 0x36, 0x45, 0x47, 1706 - 0x48, 0x49, 0xa9, 0x4b, 0xa5, 0xa6, 0xb5, 0x00 1707 - }; 1708 - 1709 - struct mscp *cpp; 1710 - struct scsi_cmnd *SCpnt; 1711 - 1712 - cpp = &ha->cp[i]; 1713 - SCpnt = cpp->SCpnt; 1714 - 1715 - if (SCpnt->sc_data_direction == DMA_FROM_DEVICE) { 1716 - cpp->din = 1; 1717 - cpp->dout = 0; 1718 - return; 1719 - } else if (SCpnt->sc_data_direction == DMA_TO_DEVICE) { 1720 - cpp->din = 0; 1721 - cpp->dout = 1; 1722 - return; 1723 - } else if (SCpnt->sc_data_direction == DMA_NONE) { 1724 - cpp->din = 0; 1725 - cpp->dout = 0; 1726 - return; 1727 - } 1728 - 1729 - if (SCpnt->sc_data_direction != DMA_BIDIRECTIONAL) 1730 - panic("%s: qcomm, invalid SCpnt->sc_data_direction.\n", 1731 - ha->board_name); 1732 - 1733 - for (k = 0; k < ARRAY_SIZE(data_out_cmds); k++) 1734 - if (SCpnt->cmnd[0] == data_out_cmds[k]) { 1735 - cpp->dout = 1; 1736 - break; 1737 - } 1738 - 1739 - if ((cpp->din = !cpp->dout)) 1740 - for (k = 0; k < ARRAY_SIZE(data_none_cmds); k++) 1741 - if (SCpnt->cmnd[0] == data_none_cmds[k]) { 1742 - cpp->din = 0; 1743 - break; 1744 - } 1745 - 1746 - } 1747 - 1748 - static int eata2x_queuecommand_lck(struct scsi_cmnd *SCpnt, 1749 - void (*done) (struct scsi_cmnd *)) 1750 - { 1751 - struct Scsi_Host *shost = SCpnt->device->host; 1752 - struct hostdata *ha = (struct hostdata *)shost->hostdata; 1753 - unsigned int i, k; 1754 - struct mscp *cpp; 1755 - 1756 - if (SCpnt->host_scribble) 1757 - panic("%s: qcomm, SCpnt %p already active.\n", 1758 - ha->board_name, SCpnt); 1759 - 1760 - /* i is the mailbox number, look for the first free mailbox 1761 - starting from last_cp_used */ 1762 - i = ha->last_cp_used + 1; 1763 - 1764 - for (k = 0; k < shost->can_queue; k++, i++) { 1765 - if (i >= shost->can_queue) 1766 - i = 0; 1767 - if (ha->cp_stat[i] == FREE) { 1768 - ha->last_cp_used = i; 1769 - break; 1770 - } 1771 - } 1772 - 1773 - if (k == shost->can_queue) { 1774 - printk("%s: qcomm, no free mailbox.\n", ha->board_name); 1775 - return 1; 1776 - } 1777 - 1778 - /* Set pointer to control packet structure */ 1779 - cpp = &ha->cp[i]; 1780 - 1781 - memset(cpp, 0, sizeof(struct mscp) - CP_TAIL_SIZE); 1782 - 1783 - /* Set pointer to status packet structure, Big Endian format */ 1784 - cpp->sp_dma_addr = H2DEV(ha->sp_dma_addr); 1785 - 1786 - SCpnt->scsi_done = done; 1787 - cpp->cpp_index = i; 1788 - SCpnt->host_scribble = (unsigned char *)&cpp->cpp_index; 1789 - 1790 - if (do_trace) 1791 - scmd_printk(KERN_INFO, SCpnt, 1792 - "qcomm, mbox %d.\n", i); 1793 - 1794 - cpp->reqsen = 1; 1795 - cpp->dispri = 1; 1796 - #if 0 1797 - if (SCpnt->device->type == TYPE_TAPE) 1798 - cpp->hbaci = 1; 1799 - #endif 1800 - cpp->one = 1; 1801 - cpp->channel = SCpnt->device->channel; 1802 - cpp->target = SCpnt->device->id; 1803 - cpp->lun = SCpnt->device->lun; 1804 - cpp->SCpnt = SCpnt; 1805 - memcpy(cpp->cdb, SCpnt->cmnd, SCpnt->cmd_len); 1806 - 1807 - /* Use data transfer direction SCpnt->sc_data_direction */ 1808 - scsi_to_dev_dir(i, ha); 1809 - 1810 - /* Map DMA buffers and SG list */ 1811 - map_dma(i, ha); 1812 - 1813 - if (linked_comm && SCpnt->device->queue_depth > 2 1814 - && TLDEV(SCpnt->device->type)) { 1815 - ha->cp_stat[i] = READY; 1816 - flush_dev(SCpnt->device, blk_rq_pos(SCpnt->request), ha, 0); 1817 - return 0; 1818 - } 1819 - 1820 - /* Send control packet to the board */ 1821 - if (do_dma(shost->io_port, cpp->cp_dma_addr, SEND_CP_DMA)) { 1822 - unmap_dma(i, ha); 1823 - SCpnt->host_scribble = NULL; 1824 - scmd_printk(KERN_INFO, SCpnt, "qcomm, adapter busy.\n"); 1825 - return 1; 1826 - } 1827 - 1828 - ha->cp_stat[i] = IN_USE; 1829 - return 0; 1830 - } 1831 - 1832 - static DEF_SCSI_QCMD(eata2x_queuecommand) 1833 - 1834 - static int eata2x_eh_abort(struct scsi_cmnd *SCarg) 1835 - { 1836 - struct Scsi_Host *shost = SCarg->device->host; 1837 - struct hostdata *ha = (struct hostdata *)shost->hostdata; 1838 - unsigned int i; 1839 - 1840 - if (SCarg->host_scribble == NULL) { 1841 - scmd_printk(KERN_INFO, SCarg, "abort, cmd inactive.\n"); 1842 - return SUCCESS; 1843 - } 1844 - 1845 - i = *(unsigned int *)SCarg->host_scribble; 1846 - scmd_printk(KERN_WARNING, SCarg, "abort, mbox %d.\n", i); 1847 - 1848 - if (i >= shost->can_queue) 1849 - panic("%s: abort, invalid SCarg->host_scribble.\n", ha->board_name); 1850 - 1851 - if (wait_on_busy(shost->io_port, MAXLOOP)) { 1852 - printk("%s: abort, timeout error.\n", ha->board_name); 1853 - return FAILED; 1854 - } 1855 - 1856 - if (ha->cp_stat[i] == FREE) { 1857 - printk("%s: abort, mbox %d is free.\n", ha->board_name, i); 1858 - return SUCCESS; 1859 - } 1860 - 1861 - if (ha->cp_stat[i] == IN_USE) { 1862 - printk("%s: abort, mbox %d is in use.\n", ha->board_name, i); 1863 - 1864 - if (SCarg != ha->cp[i].SCpnt) 1865 - panic("%s: abort, mbox %d, SCarg %p, cp SCpnt %p.\n", 1866 - ha->board_name, i, SCarg, ha->cp[i].SCpnt); 1867 - 1868 - if (inb(shost->io_port + REG_AUX_STATUS) & IRQ_ASSERTED) 1869 - printk("%s: abort, mbox %d, interrupt pending.\n", 1870 - ha->board_name, i); 1871 - 1872 - return FAILED; 1873 - } 1874 - 1875 - if (ha->cp_stat[i] == IN_RESET) { 1876 - printk("%s: abort, mbox %d is in reset.\n", ha->board_name, i); 1877 - return FAILED; 1878 - } 1879 - 1880 - if (ha->cp_stat[i] == LOCKED) { 1881 - printk("%s: abort, mbox %d is locked.\n", ha->board_name, i); 1882 - return SUCCESS; 1883 - } 1884 - 1885 - if (ha->cp_stat[i] == READY || ha->cp_stat[i] == ABORTING) { 1886 - unmap_dma(i, ha); 1887 - SCarg->result = DID_ABORT << 16; 1888 - SCarg->host_scribble = NULL; 1889 - ha->cp_stat[i] = FREE; 1890 - printk("%s, abort, mbox %d ready, DID_ABORT, done.\n", 1891 - ha->board_name, i); 1892 - SCarg->scsi_done(SCarg); 1893 - return SUCCESS; 1894 - } 1895 - 1896 - panic("%s: abort, mbox %d, invalid cp_stat.\n", ha->board_name, i); 1897 - } 1898 - 1899 - static int eata2x_eh_host_reset(struct scsi_cmnd *SCarg) 1900 - { 1901 - unsigned int i, time, k, c, limit = 0; 1902 - struct scsi_cmnd *SCpnt; 1903 - struct Scsi_Host *shost = SCarg->device->host; 1904 - struct hostdata *ha = (struct hostdata *)shost->hostdata; 1905 - 1906 - scmd_printk(KERN_INFO, SCarg, "reset, enter.\n"); 1907 - 1908 - spin_lock_irq(shost->host_lock); 1909 - 1910 - if (SCarg->host_scribble == NULL) 1911 - printk("%s: reset, inactive.\n", ha->board_name); 1912 - 1913 - if (ha->in_reset) { 1914 - printk("%s: reset, exit, already in reset.\n", ha->board_name); 1915 - spin_unlock_irq(shost->host_lock); 1916 - return FAILED; 1917 - } 1918 - 1919 - if (wait_on_busy(shost->io_port, MAXLOOP)) { 1920 - printk("%s: reset, exit, timeout error.\n", ha->board_name); 1921 - spin_unlock_irq(shost->host_lock); 1922 - return FAILED; 1923 - } 1924 - 1925 - ha->retries = 0; 1926 - 1927 - for (c = 0; c <= shost->max_channel; c++) 1928 - for (k = 0; k < shost->max_id; k++) { 1929 - ha->target_redo[k][c] = 1; 1930 - ha->target_to[k][c] = 0; 1931 - } 1932 - 1933 - for (i = 0; i < shost->can_queue; i++) { 1934 - 1935 - if (ha->cp_stat[i] == FREE) 1936 - continue; 1937 - 1938 - if (ha->cp_stat[i] == LOCKED) { 1939 - ha->cp_stat[i] = FREE; 1940 - printk("%s: reset, locked mbox %d forced free.\n", 1941 - ha->board_name, i); 1942 - continue; 1943 - } 1944 - 1945 - if (!(SCpnt = ha->cp[i].SCpnt)) 1946 - panic("%s: reset, mbox %d, SCpnt == NULL.\n", ha->board_name, i); 1947 - 1948 - if (ha->cp_stat[i] == READY || ha->cp_stat[i] == ABORTING) { 1949 - ha->cp_stat[i] = ABORTING; 1950 - printk("%s: reset, mbox %d aborting.\n", 1951 - ha->board_name, i); 1952 - } 1953 - 1954 - else { 1955 - ha->cp_stat[i] = IN_RESET; 1956 - printk("%s: reset, mbox %d in reset.\n", 1957 - ha->board_name, i); 1958 - } 1959 - 1960 - if (SCpnt->host_scribble == NULL) 1961 - panic("%s: reset, mbox %d, garbled SCpnt.\n", ha->board_name, i); 1962 - 1963 - if (*(unsigned int *)SCpnt->host_scribble != i) 1964 - panic("%s: reset, mbox %d, index mismatch.\n", ha->board_name, i); 1965 - 1966 - if (SCpnt->scsi_done == NULL) 1967 - panic("%s: reset, mbox %d, SCpnt->scsi_done == NULL.\n", 1968 - ha->board_name, i); 1969 - } 1970 - 1971 - if (do_dma(shost->io_port, 0, RESET_PIO)) { 1972 - printk("%s: reset, cannot reset, timeout error.\n", ha->board_name); 1973 - spin_unlock_irq(shost->host_lock); 1974 - return FAILED; 1975 - } 1976 - 1977 - printk("%s: reset, board reset done, enabling interrupts.\n", ha->board_name); 1978 - 1979 - #if defined(DEBUG_RESET) 1980 - do_trace = 1; 1981 - #endif 1982 - 1983 - ha->in_reset = 1; 1984 - 1985 - spin_unlock_irq(shost->host_lock); 1986 - 1987 - /* FIXME: use a sleep instead */ 1988 - time = jiffies; 1989 - while ((jiffies - time) < (10 * HZ) && limit++ < 200000) 1990 - udelay(100L); 1991 - 1992 - spin_lock_irq(shost->host_lock); 1993 - 1994 - printk("%s: reset, interrupts disabled, loops %d.\n", ha->board_name, limit); 1995 - 1996 - for (i = 0; i < shost->can_queue; i++) { 1997 - 1998 - if (ha->cp_stat[i] == IN_RESET) { 1999 - SCpnt = ha->cp[i].SCpnt; 2000 - unmap_dma(i, ha); 2001 - SCpnt->result = DID_RESET << 16; 2002 - SCpnt->host_scribble = NULL; 2003 - 2004 - /* This mailbox is still waiting for its interrupt */ 2005 - ha->cp_stat[i] = LOCKED; 2006 - 2007 - printk 2008 - ("%s, reset, mbox %d locked, DID_RESET, done.\n", 2009 - ha->board_name, i); 2010 - } 2011 - 2012 - else if (ha->cp_stat[i] == ABORTING) { 2013 - SCpnt = ha->cp[i].SCpnt; 2014 - unmap_dma(i, ha); 2015 - SCpnt->result = DID_RESET << 16; 2016 - SCpnt->host_scribble = NULL; 2017 - 2018 - /* This mailbox was never queued to the adapter */ 2019 - ha->cp_stat[i] = FREE; 2020 - 2021 - printk 2022 - ("%s, reset, mbox %d aborting, DID_RESET, done.\n", 2023 - ha->board_name, i); 2024 - } 2025 - 2026 - else 2027 - /* Any other mailbox has already been set free by interrupt */ 2028 - continue; 2029 - 2030 - SCpnt->scsi_done(SCpnt); 2031 - } 2032 - 2033 - ha->in_reset = 0; 2034 - do_trace = 0; 2035 - 2036 - printk("%s: reset, exit.\n", ha->board_name); 2037 - 2038 - spin_unlock_irq(shost->host_lock); 2039 - return SUCCESS; 2040 - } 2041 - 2042 - int eata2x_bios_param(struct scsi_device *sdev, struct block_device *bdev, 2043 - sector_t capacity, int *dkinfo) 2044 - { 2045 - unsigned int size = capacity; 2046 - 2047 - if (ext_tran || (scsicam_bios_param(bdev, capacity, dkinfo) < 0)) { 2048 - dkinfo[0] = 255; 2049 - dkinfo[1] = 63; 2050 - dkinfo[2] = size / (dkinfo[0] * dkinfo[1]); 2051 - } 2052 - #if defined (DEBUG_GEOMETRY) 2053 - printk("%s: bios_param, head=%d, sec=%d, cyl=%d.\n", driver_name, 2054 - dkinfo[0], dkinfo[1], dkinfo[2]); 2055 - #endif 2056 - 2057 - return 0; 2058 - } 2059 - 2060 - static void sort(unsigned long sk[], unsigned int da[], unsigned int n, 2061 - unsigned int rev) 2062 - { 2063 - unsigned int i, j, k, y; 2064 - unsigned long x; 2065 - 2066 - for (i = 0; i < n - 1; i++) { 2067 - k = i; 2068 - 2069 - for (j = k + 1; j < n; j++) 2070 - if (rev) { 2071 - if (sk[j] > sk[k]) 2072 - k = j; 2073 - } else { 2074 - if (sk[j] < sk[k]) 2075 - k = j; 2076 - } 2077 - 2078 - if (k != i) { 2079 - x = sk[k]; 2080 - sk[k] = sk[i]; 2081 - sk[i] = x; 2082 - y = da[k]; 2083 - da[k] = da[i]; 2084 - da[i] = y; 2085 - } 2086 - } 2087 - 2088 - return; 2089 - } 2090 - 2091 - static int reorder(struct hostdata *ha, unsigned long cursec, 2092 - unsigned int ihdlr, unsigned int il[], unsigned int n_ready) 2093 - { 2094 - struct scsi_cmnd *SCpnt; 2095 - struct mscp *cpp; 2096 - unsigned int k, n; 2097 - unsigned int rev = 0, s = 1, r = 1; 2098 - unsigned int input_only = 1, overlap = 0; 2099 - unsigned long sl[n_ready], pl[n_ready], ll[n_ready]; 2100 - unsigned long maxsec = 0, minsec = ULONG_MAX, seek = 0, iseek = 0; 2101 - unsigned long ioseek = 0; 2102 - 2103 - static unsigned int flushcount = 0, batchcount = 0, sortcount = 0; 2104 - static unsigned int readycount = 0, ovlcount = 0, inputcount = 0; 2105 - static unsigned int readysorted = 0, revcount = 0; 2106 - static unsigned long seeksorted = 0, seeknosort = 0; 2107 - 2108 - if (link_statistics && !(++flushcount % link_statistics)) 2109 - printk("fc %d bc %d ic %d oc %d rc %d rs %d sc %d re %d" 2110 - " av %ldK as %ldK.\n", flushcount, batchcount, 2111 - inputcount, ovlcount, readycount, readysorted, sortcount, 2112 - revcount, seeknosort / (readycount + 1), 2113 - seeksorted / (readycount + 1)); 2114 - 2115 - if (n_ready <= 1) 2116 - return 0; 2117 - 2118 - for (n = 0; n < n_ready; n++) { 2119 - k = il[n]; 2120 - cpp = &ha->cp[k]; 2121 - SCpnt = cpp->SCpnt; 2122 - 2123 - if (!cpp->din) 2124 - input_only = 0; 2125 - 2126 - if (blk_rq_pos(SCpnt->request) < minsec) 2127 - minsec = blk_rq_pos(SCpnt->request); 2128 - if (blk_rq_pos(SCpnt->request) > maxsec) 2129 - maxsec = blk_rq_pos(SCpnt->request); 2130 - 2131 - sl[n] = blk_rq_pos(SCpnt->request); 2132 - ioseek += blk_rq_sectors(SCpnt->request); 2133 - 2134 - if (!n) 2135 - continue; 2136 - 2137 - if (sl[n] < sl[n - 1]) 2138 - s = 0; 2139 - if (sl[n] > sl[n - 1]) 2140 - r = 0; 2141 - 2142 - if (link_statistics) { 2143 - if (sl[n] > sl[n - 1]) 2144 - seek += sl[n] - sl[n - 1]; 2145 - else 2146 - seek += sl[n - 1] - sl[n]; 2147 - } 2148 - 2149 - } 2150 - 2151 - if (link_statistics) { 2152 - if (cursec > sl[0]) 2153 - seek += cursec - sl[0]; 2154 - else 2155 - seek += sl[0] - cursec; 2156 - } 2157 - 2158 - if (cursec > ((maxsec + minsec) / 2)) 2159 - rev = 1; 2160 - 2161 - if (ioseek > ((maxsec - minsec) / 2)) 2162 - rev = 0; 2163 - 2164 - if (!((rev && r) || (!rev && s))) 2165 - sort(sl, il, n_ready, rev); 2166 - 2167 - if (!input_only) 2168 - for (n = 0; n < n_ready; n++) { 2169 - k = il[n]; 2170 - cpp = &ha->cp[k]; 2171 - SCpnt = cpp->SCpnt; 2172 - ll[n] = blk_rq_sectors(SCpnt->request); 2173 - pl[n] = SCpnt->serial_number; 2174 - 2175 - if (!n) 2176 - continue; 2177 - 2178 - if ((sl[n] == sl[n - 1]) 2179 - || (!rev && ((sl[n - 1] + ll[n - 1]) > sl[n])) 2180 - || (rev && ((sl[n] + ll[n]) > sl[n - 1]))) 2181 - overlap = 1; 2182 - } 2183 - 2184 - if (overlap) 2185 - sort(pl, il, n_ready, 0); 2186 - 2187 - if (link_statistics) { 2188 - if (cursec > sl[0]) 2189 - iseek = cursec - sl[0]; 2190 - else 2191 - iseek = sl[0] - cursec; 2192 - batchcount++; 2193 - readycount += n_ready; 2194 - seeknosort += seek / 1024; 2195 - if (input_only) 2196 - inputcount++; 2197 - if (overlap) { 2198 - ovlcount++; 2199 - seeksorted += iseek / 1024; 2200 - } else 2201 - seeksorted += (iseek + maxsec - minsec) / 1024; 2202 - if (rev && !r) { 2203 - revcount++; 2204 - readysorted += n_ready; 2205 - } 2206 - if (!rev && !s) { 2207 - sortcount++; 2208 - readysorted += n_ready; 2209 - } 2210 - } 2211 - #if defined(DEBUG_LINKED_COMMANDS) 2212 - if (link_statistics && (overlap || !(flushcount % link_statistics))) 2213 - for (n = 0; n < n_ready; n++) { 2214 - k = il[n]; 2215 - cpp = &ha->cp[k]; 2216 - SCpnt = cpp->SCpnt; 2217 - scmd_printk(KERN_INFO, SCpnt, 2218 - "%s mb %d fc %d nr %d sec %ld ns %u" 2219 - " cur %ld s:%c r:%c rev:%c in:%c ov:%c xd %d.\n", 2220 - (ihdlr ? "ihdlr" : "qcomm"), 2221 - k, flushcount, 2222 - n_ready, blk_rq_pos(SCpnt->request), 2223 - blk_rq_sectors(SCpnt->request), cursec, YESNO(s), 2224 - YESNO(r), YESNO(rev), YESNO(input_only), 2225 - YESNO(overlap), cpp->din); 2226 - } 2227 - #endif 2228 - return overlap; 2229 - } 2230 - 2231 - static void flush_dev(struct scsi_device *dev, unsigned long cursec, 2232 - struct hostdata *ha, unsigned int ihdlr) 2233 - { 2234 - struct scsi_cmnd *SCpnt; 2235 - struct mscp *cpp; 2236 - unsigned int k, n, n_ready = 0, il[MAX_MAILBOXES]; 2237 - 2238 - for (k = 0; k < dev->host->can_queue; k++) { 2239 - 2240 - if (ha->cp_stat[k] != READY && ha->cp_stat[k] != IN_USE) 2241 - continue; 2242 - 2243 - cpp = &ha->cp[k]; 2244 - SCpnt = cpp->SCpnt; 2245 - 2246 - if (SCpnt->device != dev) 2247 - continue; 2248 - 2249 - if (ha->cp_stat[k] == IN_USE) 2250 - return; 2251 - 2252 - il[n_ready++] = k; 2253 - } 2254 - 2255 - if (reorder(ha, cursec, ihdlr, il, n_ready)) 2256 - n_ready = 1; 2257 - 2258 - for (n = 0; n < n_ready; n++) { 2259 - k = il[n]; 2260 - cpp = &ha->cp[k]; 2261 - SCpnt = cpp->SCpnt; 2262 - 2263 - if (do_dma(dev->host->io_port, cpp->cp_dma_addr, SEND_CP_DMA)) { 2264 - scmd_printk(KERN_INFO, SCpnt, 2265 - "%s, mbox %d, adapter" 2266 - " busy, will abort.\n", 2267 - (ihdlr ? "ihdlr" : "qcomm"), 2268 - k); 2269 - ha->cp_stat[k] = ABORTING; 2270 - continue; 2271 - } 2272 - 2273 - ha->cp_stat[k] = IN_USE; 2274 - } 2275 - } 2276 - 2277 - static irqreturn_t ihdlr(struct Scsi_Host *shost) 2278 - { 2279 - struct scsi_cmnd *SCpnt; 2280 - unsigned int i, k, c, status, tstatus, reg; 2281 - struct mssp *spp; 2282 - struct mscp *cpp; 2283 - struct hostdata *ha = (struct hostdata *)shost->hostdata; 2284 - int irq = shost->irq; 2285 - 2286 - /* Check if this board need to be serviced */ 2287 - if (!(inb(shost->io_port + REG_AUX_STATUS) & IRQ_ASSERTED)) 2288 - goto none; 2289 - 2290 - ha->iocount++; 2291 - 2292 - if (do_trace) 2293 - printk("%s: ihdlr, enter, irq %d, count %d.\n", ha->board_name, irq, 2294 - ha->iocount); 2295 - 2296 - /* Check if this board is still busy */ 2297 - if (wait_on_busy(shost->io_port, 20 * MAXLOOP)) { 2298 - reg = inb(shost->io_port + REG_STATUS); 2299 - printk 2300 - ("%s: ihdlr, busy timeout error, irq %d, reg 0x%x, count %d.\n", 2301 - ha->board_name, irq, reg, ha->iocount); 2302 - goto none; 2303 - } 2304 - 2305 - spp = &ha->sp; 2306 - 2307 - /* Make a local copy just before clearing the interrupt indication */ 2308 - memcpy(spp, ha->sp_cpu_addr, sizeof(struct mssp)); 2309 - 2310 - /* Clear the completion flag and cp pointer on the dynamic copy of sp */ 2311 - memset(ha->sp_cpu_addr, 0, sizeof(struct mssp)); 2312 - 2313 - /* Read the status register to clear the interrupt indication */ 2314 - reg = inb(shost->io_port + REG_STATUS); 2315 - 2316 - #if defined (DEBUG_INTERRUPT) 2317 - { 2318 - unsigned char *bytesp; 2319 - int cnt; 2320 - bytesp = (unsigned char *)spp; 2321 - if (ha->iocount < 200) { 2322 - printk("sp[] ="); 2323 - for (cnt = 0; cnt < 15; cnt++) 2324 - printk(" 0x%x", bytesp[cnt]); 2325 - printk("\n"); 2326 - } 2327 - } 2328 - #endif 2329 - 2330 - /* Reject any sp with supspect data */ 2331 - if (spp->eoc == 0 && ha->iocount > 1) 2332 - printk 2333 - ("%s: ihdlr, spp->eoc == 0, irq %d, reg 0x%x, count %d.\n", 2334 - ha->board_name, irq, reg, ha->iocount); 2335 - if (spp->cpp_index < 0 || spp->cpp_index >= shost->can_queue) 2336 - printk 2337 - ("%s: ihdlr, bad spp->cpp_index %d, irq %d, reg 0x%x, count %d.\n", 2338 - ha->board_name, spp->cpp_index, irq, reg, ha->iocount); 2339 - if (spp->eoc == 0 || spp->cpp_index < 0 2340 - || spp->cpp_index >= shost->can_queue) 2341 - goto handled; 2342 - 2343 - /* Find the mailbox to be serviced on this board */ 2344 - i = spp->cpp_index; 2345 - 2346 - cpp = &(ha->cp[i]); 2347 - 2348 - #if defined(DEBUG_GENERATE_ABORTS) 2349 - if ((ha->iocount > 500) && ((ha->iocount % 500) < 3)) 2350 - goto handled; 2351 - #endif 2352 - 2353 - if (ha->cp_stat[i] == IGNORE) { 2354 - ha->cp_stat[i] = FREE; 2355 - goto handled; 2356 - } else if (ha->cp_stat[i] == LOCKED) { 2357 - ha->cp_stat[i] = FREE; 2358 - printk("%s: ihdlr, mbox %d unlocked, count %d.\n", ha->board_name, i, 2359 - ha->iocount); 2360 - goto handled; 2361 - } else if (ha->cp_stat[i] == FREE) { 2362 - printk("%s: ihdlr, mbox %d is free, count %d.\n", ha->board_name, i, 2363 - ha->iocount); 2364 - goto handled; 2365 - } else if (ha->cp_stat[i] == IN_RESET) 2366 - printk("%s: ihdlr, mbox %d is in reset.\n", ha->board_name, i); 2367 - else if (ha->cp_stat[i] != IN_USE) 2368 - panic("%s: ihdlr, mbox %d, invalid cp_stat: %d.\n", 2369 - ha->board_name, i, ha->cp_stat[i]); 2370 - 2371 - ha->cp_stat[i] = FREE; 2372 - SCpnt = cpp->SCpnt; 2373 - 2374 - if (SCpnt == NULL) 2375 - panic("%s: ihdlr, mbox %d, SCpnt == NULL.\n", ha->board_name, i); 2376 - 2377 - if (SCpnt->host_scribble == NULL) 2378 - panic("%s: ihdlr, mbox %d, SCpnt %p garbled.\n", ha->board_name, 2379 - i, SCpnt); 2380 - 2381 - if (*(unsigned int *)SCpnt->host_scribble != i) 2382 - panic("%s: ihdlr, mbox %d, index mismatch %d.\n", 2383 - ha->board_name, i, 2384 - *(unsigned int *)SCpnt->host_scribble); 2385 - 2386 - sync_dma(i, ha); 2387 - 2388 - if (linked_comm && SCpnt->device->queue_depth > 2 2389 - && TLDEV(SCpnt->device->type)) 2390 - flush_dev(SCpnt->device, blk_rq_pos(SCpnt->request), ha, 1); 2391 - 2392 - tstatus = status_byte(spp->target_status); 2393 - 2394 - #if defined(DEBUG_GENERATE_ERRORS) 2395 - if ((ha->iocount > 500) && ((ha->iocount % 200) < 2)) 2396 - spp->adapter_status = 0x01; 2397 - #endif 2398 - 2399 - switch (spp->adapter_status) { 2400 - case ASOK: /* status OK */ 2401 - 2402 - /* Forces a reset if a disk drive keeps returning BUSY */ 2403 - if (tstatus == BUSY && SCpnt->device->type != TYPE_TAPE) 2404 - status = DID_ERROR << 16; 2405 - 2406 - /* If there was a bus reset, redo operation on each target */ 2407 - else if (tstatus != GOOD && SCpnt->device->type == TYPE_DISK 2408 - && ha->target_redo[SCpnt->device->id][SCpnt-> 2409 - device-> 2410 - channel]) 2411 - status = DID_BUS_BUSY << 16; 2412 - 2413 - /* Works around a flaw in scsi.c */ 2414 - else if (tstatus == CHECK_CONDITION 2415 - && SCpnt->device->type == TYPE_DISK 2416 - && (SCpnt->sense_buffer[2] & 0xf) == RECOVERED_ERROR) 2417 - status = DID_BUS_BUSY << 16; 2418 - 2419 - else 2420 - status = DID_OK << 16; 2421 - 2422 - if (tstatus == GOOD) 2423 - ha->target_redo[SCpnt->device->id][SCpnt->device-> 2424 - channel] = 0; 2425 - 2426 - if (spp->target_status && SCpnt->device->type == TYPE_DISK && 2427 - (!(tstatus == CHECK_CONDITION && ha->iocount <= 1000 && 2428 - (SCpnt->sense_buffer[2] & 0xf) == NOT_READY))) 2429 - printk("%s: ihdlr, target %d.%d:%d, " 2430 - "target_status 0x%x, sense key 0x%x.\n", 2431 - ha->board_name, 2432 - SCpnt->device->channel, SCpnt->device->id, 2433 - (u8)SCpnt->device->lun, 2434 - spp->target_status, SCpnt->sense_buffer[2]); 2435 - 2436 - ha->target_to[SCpnt->device->id][SCpnt->device->channel] = 0; 2437 - 2438 - if (ha->last_retried_pid == SCpnt->serial_number) 2439 - ha->retries = 0; 2440 - 2441 - break; 2442 - case ASST: /* Selection Time Out */ 2443 - case 0x02: /* Command Time Out */ 2444 - 2445 - if (ha->target_to[SCpnt->device->id][SCpnt->device->channel] > 1) 2446 - status = DID_ERROR << 16; 2447 - else { 2448 - status = DID_TIME_OUT << 16; 2449 - ha->target_to[SCpnt->device->id][SCpnt->device-> 2450 - channel]++; 2451 - } 2452 - 2453 - break; 2454 - 2455 - /* Perform a limited number of internal retries */ 2456 - case 0x03: /* SCSI Bus Reset Received */ 2457 - case 0x04: /* Initial Controller Power-up */ 2458 - 2459 - for (c = 0; c <= shost->max_channel; c++) 2460 - for (k = 0; k < shost->max_id; k++) 2461 - ha->target_redo[k][c] = 1; 2462 - 2463 - if (SCpnt->device->type != TYPE_TAPE 2464 - && ha->retries < MAX_INTERNAL_RETRIES) { 2465 - 2466 - #if defined(DID_SOFT_ERROR) 2467 - status = DID_SOFT_ERROR << 16; 2468 - #else 2469 - status = DID_BUS_BUSY << 16; 2470 - #endif 2471 - 2472 - ha->retries++; 2473 - ha->last_retried_pid = SCpnt->serial_number; 2474 - } else 2475 - status = DID_ERROR << 16; 2476 - 2477 - break; 2478 - case 0x05: /* Unexpected Bus Phase */ 2479 - case 0x06: /* Unexpected Bus Free */ 2480 - case 0x07: /* Bus Parity Error */ 2481 - case 0x08: /* SCSI Hung */ 2482 - case 0x09: /* Unexpected Message Reject */ 2483 - case 0x0a: /* SCSI Bus Reset Stuck */ 2484 - case 0x0b: /* Auto Request-Sense Failed */ 2485 - case 0x0c: /* Controller Ram Parity Error */ 2486 - default: 2487 - status = DID_ERROR << 16; 2488 - break; 2489 - } 2490 - 2491 - SCpnt->result = status | spp->target_status; 2492 - 2493 - #if defined(DEBUG_INTERRUPT) 2494 - if (SCpnt->result || do_trace) 2495 - #else 2496 - if ((spp->adapter_status != ASOK && ha->iocount > 1000) || 2497 - (spp->adapter_status != ASOK && 2498 - spp->adapter_status != ASST && ha->iocount <= 1000) || 2499 - do_trace || msg_byte(spp->target_status)) 2500 - #endif 2501 - scmd_printk(KERN_INFO, SCpnt, "ihdlr, mbox %2d, err 0x%x:%x," 2502 - " reg 0x%x, count %d.\n", 2503 - i, spp->adapter_status, spp->target_status, 2504 - reg, ha->iocount); 2505 - 2506 - unmap_dma(i, ha); 2507 - 2508 - /* Set the command state to inactive */ 2509 - SCpnt->host_scribble = NULL; 2510 - 2511 - SCpnt->scsi_done(SCpnt); 2512 - 2513 - if (do_trace) 2514 - printk("%s: ihdlr, exit, irq %d, count %d.\n", ha->board_name, 2515 - irq, ha->iocount); 2516 - 2517 - handled: 2518 - return IRQ_HANDLED; 2519 - none: 2520 - return IRQ_NONE; 2521 - } 2522 - 2523 - static irqreturn_t do_interrupt_handler(int dummy, void *shap) 2524 - { 2525 - struct Scsi_Host *shost; 2526 - unsigned int j; 2527 - unsigned long spin_flags; 2528 - irqreturn_t ret; 2529 - 2530 - /* Check if the interrupt must be processed by this handler */ 2531 - if ((j = (unsigned int)((char *)shap - sha)) >= num_boards) 2532 - return IRQ_NONE; 2533 - shost = sh[j]; 2534 - 2535 - spin_lock_irqsave(shost->host_lock, spin_flags); 2536 - ret = ihdlr(shost); 2537 - spin_unlock_irqrestore(shost->host_lock, spin_flags); 2538 - return ret; 2539 - } 2540 - 2541 - static int eata2x_release(struct Scsi_Host *shost) 2542 - { 2543 - struct hostdata *ha = (struct hostdata *)shost->hostdata; 2544 - unsigned int i; 2545 - 2546 - for (i = 0; i < shost->can_queue; i++) 2547 - kfree((&ha->cp[i])->sglist); 2548 - 2549 - for (i = 0; i < shost->can_queue; i++) 2550 - pci_unmap_single(ha->pdev, ha->cp[i].cp_dma_addr, 2551 - sizeof(struct mscp), PCI_DMA_BIDIRECTIONAL); 2552 - 2553 - if (ha->sp_cpu_addr) 2554 - pci_free_consistent(ha->pdev, sizeof(struct mssp), 2555 - ha->sp_cpu_addr, ha->sp_dma_addr); 2556 - 2557 - free_irq(shost->irq, &sha[ha->board_number]); 2558 - 2559 - if (shost->dma_channel != NO_DMA) 2560 - free_dma(shost->dma_channel); 2561 - 2562 - release_region(shost->io_port, shost->n_io_port); 2563 - scsi_unregister(shost); 2564 - return 0; 2565 - } 2566 - 2567 - #include "scsi_module.c" 2568 - 2569 - #ifndef MODULE 2570 - __setup("eata=", option_setup); 2571 - #endif /* end MODULE */
-401
drivers/scsi/eata_generic.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - /******************************************************** 3 - * Header file for eata_dma.c and eata_pio.c * 4 - * Linux EATA SCSI drivers * 5 - * (c) 1993-96 Michael Neuffer * 6 - * mike@i-Connect.Net * 7 - * neuffer@mail.uni-mainz.de * 8 - ********************************************************* 9 - * last change: 96/08/14 * 10 - ********************************************************/ 11 - 12 - 13 - #ifndef _EATA_GENERIC_H 14 - #define _EATA_GENERIC_H 15 - 16 - 17 - 18 - /********************************************* 19 - * Misc. definitions * 20 - *********************************************/ 21 - 22 - #define R_LIMIT 0x20000 23 - 24 - #define MAXISA 4 25 - #define MAXEISA 16 26 - #define MAXPCI 16 27 - #define MAXIRQ 16 28 - #define MAXTARGET 16 29 - #define MAXCHANNEL 3 30 - 31 - #define IS_ISA 'I' 32 - #define IS_EISA 'E' 33 - #define IS_PCI 'P' 34 - 35 - #define BROKEN_INQUIRY 1 36 - 37 - #define BUSMASTER 0xff 38 - #define PIO 0xfe 39 - 40 - #define EATA_SIGNATURE 0x45415441 /* BIG ENDIAN coded "EATA" sig. */ 41 - 42 - #define DPT_ID1 0x12 43 - #define DPT_ID2 0x14 44 - 45 - #define ATT_ID1 0x06 46 - #define ATT_ID2 0x94 47 - #define ATT_ID3 0x0 48 - 49 - #define NEC_ID1 0x38 50 - #define NEC_ID2 0xa3 51 - #define NEC_ID3 0x82 52 - 53 - 54 - #define EATA_CP_SIZE 44 55 - 56 - #define MAX_PCI_DEVICES 32 /* Maximum # Of Devices Per Bus */ 57 - #define MAX_METHOD_2 16 /* Max Devices For Method 2 */ 58 - #define MAX_PCI_BUS 16 /* Maximum # Of Busses Allowed */ 59 - 60 - #define SG_SIZE 64 61 - #define SG_SIZE_BIG 252 /* max. 8096 elements, 64k */ 62 - 63 - #define UPPER_DEVICE_QUEUE_LIMIT 64 /* The limit we have to set for the 64 - * device queue to keep the broken 65 - * midlevel SCSI code from producing 66 - * bogus timeouts 67 - */ 68 - 69 - #define TYPE_DISK_QUEUE 16 70 - #define TYPE_TAPE_QUEUE 4 71 - #define TYPE_ROM_QUEUE 4 72 - #define TYPE_OTHER_QUEUE 2 73 - 74 - #define FREE 0 75 - #define OK 0 76 - #define NO_TIMEOUT 0 77 - #define USED 1 78 - #define TIMEOUT 2 79 - #define RESET 4 80 - #define LOCKED 8 81 - #define ABORTED 16 82 - 83 - #define READ 0 84 - #define WRITE 1 85 - #define OTHER 2 86 - 87 - #define HD(cmd) ((hostdata *)&(cmd->device->host->hostdata)) 88 - #define CD(cmd) ((struct eata_ccb *)(cmd->host_scribble)) 89 - #define SD(host) ((hostdata *)&(host->hostdata)) 90 - 91 - /*********************************************** 92 - * EATA Command & Register definitions * 93 - ***********************************************/ 94 - #define PCI_REG_DPTconfig 0x40 95 - #define PCI_REG_PumpModeAddress 0x44 96 - #define PCI_REG_PumpModeData 0x48 97 - #define PCI_REG_ConfigParam1 0x50 98 - #define PCI_REG_ConfigParam2 0x54 99 - 100 - 101 - #define EATA_CMD_PIO_SETUPTEST 0xc6 102 - #define EATA_CMD_PIO_READ_CONFIG 0xf0 103 - #define EATA_CMD_PIO_SET_CONFIG 0xf1 104 - #define EATA_CMD_PIO_SEND_CP 0xf2 105 - #define EATA_CMD_PIO_RECEIVE_SP 0xf3 106 - #define EATA_CMD_PIO_TRUNC 0xf4 107 - 108 - #define EATA_CMD_RESET 0xf9 109 - #define EATA_CMD_IMMEDIATE 0xfa 110 - 111 - #define EATA_CMD_DMA_READ_CONFIG 0xfd 112 - #define EATA_CMD_DMA_SET_CONFIG 0xfe 113 - #define EATA_CMD_DMA_SEND_CP 0xff 114 - 115 - #define ECS_EMULATE_SENSE 0xd4 116 - 117 - #define EATA_GENERIC_ABORT 0x00 118 - #define EATA_SPECIFIC_RESET 0x01 119 - #define EATA_BUS_RESET 0x02 120 - #define EATA_SPECIFIC_ABORT 0x03 121 - #define EATA_QUIET_INTR 0x04 122 - #define EATA_COLD_BOOT_HBA 0x06 /* Only as a last resort */ 123 - #define EATA_FORCE_IO 0x07 124 - 125 - #define HA_CTRLREG 0x206 /* control register for HBA */ 126 - #define HA_CTRL_DISINT 0x02 /* CTRLREG: disable interrupts */ 127 - #define HA_CTRL_RESCPU 0x04 /* CTRLREG: reset processor */ 128 - #define HA_CTRL_8HEADS 0x08 /* CTRLREG: set for drives with* 129 - * >=8 heads (WD1003 rudimentary :-) */ 130 - 131 - #define HA_WCOMMAND 0x07 /* command register offset */ 132 - #define HA_WIFC 0x06 /* immediate command offset */ 133 - #define HA_WCODE 0x05 134 - #define HA_WCODE2 0x04 135 - #define HA_WDMAADDR 0x02 /* DMA address LSB offset */ 136 - #define HA_RAUXSTAT 0x08 /* aux status register offset*/ 137 - #define HA_RSTATUS 0x07 /* status register offset */ 138 - #define HA_RDATA 0x00 /* data register (16bit) */ 139 - #define HA_WDATA 0x00 /* data register (16bit) */ 140 - 141 - #define HA_ABUSY 0x01 /* aux busy bit */ 142 - #define HA_AIRQ 0x02 /* aux IRQ pending bit */ 143 - #define HA_SERROR 0x01 /* pr. command ended in error*/ 144 - #define HA_SMORE 0x02 /* more data soon to come */ 145 - #define HA_SCORR 0x04 /* data corrected */ 146 - #define HA_SDRQ 0x08 /* data request active */ 147 - #define HA_SSC 0x10 /* seek complete */ 148 - #define HA_SFAULT 0x20 /* write fault */ 149 - #define HA_SREADY 0x40 /* drive ready */ 150 - #define HA_SBUSY 0x80 /* drive busy */ 151 - #define HA_SDRDY HA_SSC+HA_SREADY+HA_SDRQ 152 - 153 - /********************************************** 154 - * Message definitions * 155 - **********************************************/ 156 - 157 - #define HA_NO_ERROR 0x00 /* No Error */ 158 - #define HA_ERR_SEL_TO 0x01 /* Selection Timeout */ 159 - #define HA_ERR_CMD_TO 0x02 /* Command Timeout */ 160 - #define HA_BUS_RESET 0x03 /* SCSI Bus Reset Received */ 161 - #define HA_INIT_POWERUP 0x04 /* Initial Controller Power-up */ 162 - #define HA_UNX_BUSPHASE 0x05 /* Unexpected Bus Phase */ 163 - #define HA_UNX_BUS_FREE 0x06 /* Unexpected Bus Free */ 164 - #define HA_BUS_PARITY 0x07 /* Bus Parity Error */ 165 - #define HA_SCSI_HUNG 0x08 /* SCSI Hung */ 166 - #define HA_UNX_MSGRJCT 0x09 /* Unexpected Message Rejected */ 167 - #define HA_RESET_STUCK 0x0a /* SCSI Bus Reset Stuck */ 168 - #define HA_RSENSE_FAIL 0x0b /* Auto Request-Sense Failed */ 169 - #define HA_PARITY_ERR 0x0c /* Controller Ram Parity Error */ 170 - #define HA_CP_ABORT_NA 0x0d /* Abort Message sent to non-active cmd */ 171 - #define HA_CP_ABORTED 0x0e /* Abort Message sent to active cmd */ 172 - #define HA_CP_RESET_NA 0x0f /* Reset Message sent to non-active cmd */ 173 - #define HA_CP_RESET 0x10 /* Reset Message sent to active cmd */ 174 - #define HA_ECC_ERR 0x11 /* Controller Ram ECC Error */ 175 - #define HA_PCI_PARITY 0x12 /* PCI Parity Error */ 176 - #define HA_PCI_MABORT 0x13 /* PCI Master Abort */ 177 - #define HA_PCI_TABORT 0x14 /* PCI Target Abort */ 178 - #define HA_PCI_STABORT 0x15 /* PCI Signaled Target Abort */ 179 - 180 - /********************************************** 181 - * Other definitions * 182 - **********************************************/ 183 - 184 - struct reg_bit { /* reading this one will clear the interrupt */ 185 - __u8 error:1; /* previous command ended in an error */ 186 - __u8 more:1; /* more DATA coming soon, poll BSY & DRQ (PIO) */ 187 - __u8 corr:1; /* data read was successfully corrected with ECC*/ 188 - __u8 drq:1; /* data request active */ 189 - __u8 sc:1; /* seek complete */ 190 - __u8 fault:1; /* write fault */ 191 - __u8 ready:1; /* drive ready */ 192 - __u8 busy:1; /* controller busy */ 193 - }; 194 - 195 - struct reg_abit { /* reading this won't clear the interrupt */ 196 - __u8 abusy:1; /* auxiliary busy */ 197 - __u8 irq:1; /* set when drive interrupt is asserted */ 198 - __u8 dummy:6; 199 - }; 200 - 201 - struct eata_register { /* EATA register set */ 202 - __u8 data_reg[2]; /* R, couldn't figure this one out */ 203 - __u8 cp_addr[4]; /* W, CP address register */ 204 - union { 205 - __u8 command; /* W, command code: [read|set] conf, send CP*/ 206 - struct reg_bit status; /* R, see register_bit1 */ 207 - __u8 statusbyte; 208 - } ovr; 209 - struct reg_abit aux_stat; /* R, see register_bit2 */ 210 - }; 211 - 212 - struct get_conf { /* Read Configuration Array */ 213 - __u32 len; /* Should return 0x22, 0x24, etc */ 214 - __u32 signature; /* Signature MUST be "EATA" */ 215 - __u8 version2:4, 216 - version:4; /* EATA Version level */ 217 - __u8 OCS_enabled:1, /* Overlap Command Support enabled */ 218 - TAR_support:1, /* SCSI Target Mode supported */ 219 - TRNXFR:1, /* Truncate Transfer Cmd not necessary * 220 - * Only used in PIO Mode */ 221 - MORE_support:1, /* MORE supported (only PIO Mode) */ 222 - DMA_support:1, /* DMA supported Driver uses only * 223 - * this mode */ 224 - DMA_valid:1, /* DRQ value in Byte 30 is valid */ 225 - ATA:1, /* ATA device connected (not supported) */ 226 - HAA_valid:1; /* Hostadapter Address is valid */ 227 - 228 - __u16 cppadlen; /* Number of pad bytes send after CD data * 229 - * set to zero for DMA commands */ 230 - __u8 scsi_id[4]; /* SCSI ID of controller 2-0 Byte 0 res. * 231 - * if not, zero is returned */ 232 - __u32 cplen; /* CP length: number of valid cp bytes */ 233 - __u32 splen; /* Number of bytes returned after * 234 - * Receive SP command */ 235 - __u16 queuesiz; /* max number of queueable CPs */ 236 - __u16 dummy; 237 - __u16 SGsiz; /* max number of SG table entries */ 238 - __u8 IRQ:4, /* IRQ used this HA */ 239 - IRQ_TR:1, /* IRQ Trigger: 0=edge, 1=level */ 240 - SECOND:1, /* This is a secondary controller */ 241 - DMA_channel:2; /* DRQ index, DRQ is 2comp of DRQX */ 242 - __u8 sync; /* device at ID 7 tru 0 is running in * 243 - * synchronous mode, this will disappear */ 244 - __u8 DSBLE:1, /* ISA i/o addressing is disabled */ 245 - FORCADR:1, /* i/o address has been forced */ 246 - SG_64K:1, 247 - SG_UAE:1, 248 - :4; 249 - __u8 MAX_ID:5, /* Max number of SCSI target IDs */ 250 - MAX_CHAN:3; /* Number of SCSI busses on HBA */ 251 - __u8 MAX_LUN; /* Max number of LUNs */ 252 - __u8 :3, 253 - AUTOTRM:1, 254 - M1_inst:1, 255 - ID_qest:1, /* Raidnum ID is questionable */ 256 - is_PCI:1, /* HBA is PCI */ 257 - is_EISA:1; /* HBA is EISA */ 258 - __u8 RAIDNUM; /* unique HBA identifier */ 259 - __u8 unused[474]; 260 - }; 261 - 262 - struct eata_sg_list 263 - { 264 - __u32 data; 265 - __u32 len; 266 - }; 267 - 268 - struct eata_ccb { /* Send Command Packet structure */ 269 - 270 - __u8 SCSI_Reset:1, /* Cause a SCSI Bus reset on the cmd */ 271 - HBA_Init:1, /* Cause Controller to reinitialize */ 272 - Auto_Req_Sen:1, /* Do Auto Request Sense on errors */ 273 - scatter:1, /* Data Ptr points to a SG Packet */ 274 - Resrvd:1, /* RFU */ 275 - Interpret:1, /* Interpret the SCSI cdb of own use */ 276 - DataOut:1, /* Data Out phase with command */ 277 - DataIn:1; /* Data In phase with command */ 278 - __u8 reqlen; /* Request Sense Length * 279 - * Valid if Auto_Req_Sen=1 */ 280 - __u8 unused[3]; 281 - __u8 FWNEST:1, /* send cmd to phys RAID component */ 282 - unused2:7; 283 - __u8 Phsunit:1, /* physical unit on mirrored pair */ 284 - I_AT:1, /* inhibit address translation */ 285 - I_HBA_C:1, /* HBA inhibit caching */ 286 - unused3:5; 287 - 288 - __u8 cp_id:5, /* SCSI Device ID of target */ 289 - cp_channel:3; /* SCSI Channel # of HBA */ 290 - __u8 cp_lun:3, 291 - :2, 292 - cp_luntar:1, /* CP is for target ROUTINE */ 293 - cp_dispri:1, /* Grant disconnect privilege */ 294 - cp_identify:1; /* Always TRUE */ 295 - __u8 cp_msg1; /* Message bytes 0-3 */ 296 - __u8 cp_msg2; 297 - __u8 cp_msg3; 298 - __u8 cp_cdb[12]; /* Command Descriptor Block */ 299 - __u32 cp_datalen; /* Data Transfer Length * 300 - * If scatter=1 len of sg package */ 301 - void *cp_viraddr; /* address of this ccb */ 302 - __u32 cp_dataDMA; /* Data Address, if scatter=1 * 303 - * address of scatter packet */ 304 - __u32 cp_statDMA; /* address for Status Packet */ 305 - __u32 cp_reqDMA; /* Request Sense Address, used if * 306 - * CP command ends with error */ 307 - /* Additional CP info begins here */ 308 - __u32 timestamp; /* Needed to measure command latency */ 309 - __u32 timeout; 310 - __u8 sizeindex; 311 - __u8 rw_latency; 312 - __u8 retries; 313 - __u8 status; /* status of this queueslot */ 314 - struct scsi_cmnd *cmd; /* address of cmd */ 315 - struct eata_sg_list *sg_list; 316 - }; 317 - 318 - 319 - struct eata_sp { 320 - __u8 hba_stat:7, /* HBA status */ 321 - EOC:1; /* True if command finished */ 322 - __u8 scsi_stat; /* Target SCSI status */ 323 - __u8 reserved[2]; 324 - __u32 residue_len; /* Number of bytes not transferred */ 325 - struct eata_ccb *ccb; /* Address set in COMMAND PACKET */ 326 - __u8 msg[12]; 327 - }; 328 - 329 - typedef struct hstd { 330 - __u8 vendor[9]; 331 - __u8 name[18]; 332 - __u8 revision[6]; 333 - __u8 EATA_revision; 334 - __u32 firmware_revision; 335 - __u8 HBA_number; 336 - __u8 bustype; /* bustype of HBA */ 337 - __u8 channel; /* # of avail. scsi channels */ 338 - __u8 state; /* state of HBA */ 339 - __u8 primary; /* true if primary */ 340 - __u8 more_support:1, /* HBA supports MORE flag */ 341 - immediate_support:1, /* HBA supports IMMEDIATE CMDs*/ 342 - broken_INQUIRY:1; /* This is an EISA HBA with * 343 - * broken INQUIRY */ 344 - __u8 do_latency; /* Latency measurement flag */ 345 - __u32 reads[13]; 346 - __u32 writes[13]; 347 - __u32 reads_lat[12][4]; 348 - __u32 writes_lat[12][4]; 349 - __u32 all_lat[4]; 350 - __u8 resetlevel[MAXCHANNEL]; 351 - __u32 last_ccb; /* Last used ccb */ 352 - __u32 cplen; /* size of CP in words */ 353 - __u16 cppadlen; /* pad length of cp in words */ 354 - __u16 queuesize; 355 - __u16 sgsize; /* # of entries in the SG list*/ 356 - __u16 devflags; /* bits set for detected devices */ 357 - __u8 hostid; /* SCSI ID of HBA */ 358 - __u8 moresupport; /* HBA supports MORE flag */ 359 - struct Scsi_Host *next; 360 - struct Scsi_Host *prev; 361 - struct pci_dev *pdev; /* PCI device or NULL for non PCI */ 362 - struct eata_sp sp; /* status packet */ 363 - struct eata_ccb ccb[0]; /* ccb array begins here */ 364 - }hostdata; 365 - 366 - /* structure for max. 2 emulated drives */ 367 - struct drive_geom_emul { 368 - __u8 trans; /* translation flag 1=transl */ 369 - __u8 channel; /* SCSI channel number */ 370 - __u8 HBA; /* HBA number (prim/sec) */ 371 - __u8 id; /* drive id */ 372 - __u8 lun; /* drive lun */ 373 - __u32 heads; /* number of heads */ 374 - __u32 sectors; /* number of sectors */ 375 - __u32 cylinder; /* number of cylinders */ 376 - }; 377 - 378 - struct geom_emul { 379 - __u8 bios_drives; /* number of emulated drives */ 380 - struct drive_geom_emul drv[2]; /* drive structures */ 381 - }; 382 - 383 - #endif /* _EATA_GENERIC_H */ 384 - 385 - /* 386 - * Overrides for Emacs so that we almost follow Linus's tabbing style. 387 - * Emacs will notice this stuff at the end of the file and automatically 388 - * adjust the settings for this buffer only. This must remain at the end 389 - * of the file. 390 - * --------------------------------------------------------------------------- 391 - * Local variables: 392 - * c-indent-level: 4 393 - * c-brace-imaginary-offset: 0 394 - * c-brace-offset: -4 395 - * c-argdecl-indent: 4 396 - * c-label-offset: -4 397 - * c-continued-statement-offset: 4 398 - * c-continued-brace-offset: 0 399 - * tab-width: 8 400 - * End: 401 - */
-966
drivers/scsi/eata_pio.c
··· 1 - /************************************************************ 2 - * * 3 - * Linux EATA SCSI PIO driver * 4 - * * 5 - * based on the CAM document CAM/89-004 rev. 2.0c, * 6 - * DPT's driver kit, some internal documents and source, * 7 - * and several other Linux scsi drivers and kernel docs. * 8 - * * 9 - * The driver currently: * 10 - * -supports all EATA-PIO boards * 11 - * -only supports DASD devices * 12 - * * 13 - * (c)1993-96 Michael Neuffer, Alfred Arnold * 14 - * neuffer@goofy.zdv.uni-mainz.de * 15 - * a.arnold@kfa-juelich.de * 16 - * * 17 - * Updated 2002 by Alan Cox <alan@lxorguk.ukuu.org.uk> for * 18 - * Linux 2.5.x and the newer locking and error handling * 19 - * * 20 - * This program is free software; you can redistribute it * 21 - * and/or modify it under the terms of the GNU General * 22 - * Public License as published by the Free Software * 23 - * Foundation; either version 2 of the License, or * 24 - * (at your option) any later version. * 25 - * * 26 - * This program is distributed in the hope that it will be * 27 - * useful, but WITHOUT ANY WARRANTY; without even the * 28 - * implied warranty of MERCHANTABILITY or FITNESS FOR A * 29 - * PARTICULAR PURPOSE. See the GNU General Public License * 30 - * for more details. * 31 - * * 32 - * You should have received a copy of the GNU General * 33 - * Public License along with this kernel; if not, write to * 34 - * the Free Software Foundation, Inc., 675 Mass Ave, * 35 - * Cambridge, MA 02139, USA. * 36 - * * 37 - * For the avoidance of doubt the "preferred form" of this * 38 - * code is one which is in an open non patent encumbered * 39 - * format. Where cryptographic key signing forms part of * 40 - * the process of creating an executable the information * 41 - * including keys needed to generate an equivalently * 42 - * functional executable are deemed to be part of the * 43 - * source code are deemed to be part of the source code. * 44 - * * 45 - ************************************************************ 46 - * last change: 2002/11/02 OS: Linux 2.5.45 * 47 - ************************************************************/ 48 - 49 - #include <linux/module.h> 50 - #include <linux/kernel.h> 51 - #include <linux/string.h> 52 - #include <linux/ioport.h> 53 - #include <linux/in.h> 54 - #include <linux/pci.h> 55 - #include <linux/proc_fs.h> 56 - #include <linux/interrupt.h> 57 - #include <linux/blkdev.h> 58 - #include <linux/spinlock.h> 59 - #include <linux/delay.h> 60 - 61 - #include <asm/io.h> 62 - 63 - #include <scsi/scsi.h> 64 - #include <scsi/scsi_cmnd.h> 65 - #include <scsi/scsi_device.h> 66 - #include <scsi/scsi_host.h> 67 - 68 - #include "eata_generic.h" 69 - #include "eata_pio.h" 70 - 71 - 72 - static unsigned int ISAbases[MAXISA] = { 73 - 0x1F0, 0x170, 0x330, 0x230 74 - }; 75 - 76 - static unsigned int ISAirqs[MAXISA] = { 77 - 14, 12, 15, 11 78 - }; 79 - 80 - static unsigned char EISAbases[] = { 81 - 1, 1, 1, 1, 1, 1, 1, 1, 82 - 1, 1, 1, 1, 1, 1, 1, 1 83 - }; 84 - 85 - static unsigned int registered_HBAs; 86 - static struct Scsi_Host *last_HBA; 87 - static struct Scsi_Host *first_HBA; 88 - static unsigned char reg_IRQ[16]; 89 - static unsigned char reg_IRQL[16]; 90 - static unsigned long int_counter; 91 - static unsigned long queue_counter; 92 - 93 - static struct scsi_host_template driver_template; 94 - 95 - static int eata_pio_show_info(struct seq_file *m, struct Scsi_Host *shost) 96 - { 97 - seq_printf(m, "EATA (Extended Attachment) PIO driver version: " 98 - "%d.%d%s\n",VER_MAJOR, VER_MINOR, VER_SUB); 99 - seq_printf(m, "queued commands: %10ld\n" 100 - "processed interrupts:%10ld\n", queue_counter, int_counter); 101 - seq_printf(m, "\nscsi%-2d: HBA %.10s\n", 102 - shost->host_no, SD(shost)->name); 103 - seq_printf(m, "Firmware revision: v%s\n", 104 - SD(shost)->revision); 105 - seq_puts(m, "IO: PIO\n"); 106 - seq_printf(m, "Base IO : %#.4x\n", (u32) shost->base); 107 - seq_printf(m, "Host Bus: %s\n", 108 - (SD(shost)->bustype == 'P')?"PCI ": 109 - (SD(shost)->bustype == 'E')?"EISA":"ISA "); 110 - return 0; 111 - } 112 - 113 - static int eata_pio_release(struct Scsi_Host *sh) 114 - { 115 - hostdata *hd = SD(sh); 116 - if (sh->irq && reg_IRQ[sh->irq] == 1) 117 - free_irq(sh->irq, NULL); 118 - else 119 - reg_IRQ[sh->irq]--; 120 - if (SD(sh)->channel == 0) { 121 - if (sh->io_port && sh->n_io_port) 122 - release_region(sh->io_port, sh->n_io_port); 123 - } 124 - /* At this point the PCI reference can go */ 125 - if (hd->pdev) 126 - pci_dev_put(hd->pdev); 127 - return 1; 128 - } 129 - 130 - static void IncStat(struct scsi_pointer *SCp, unsigned int Increment) 131 - { 132 - SCp->ptr += Increment; 133 - if ((SCp->this_residual -= Increment) == 0) { 134 - if ((--SCp->buffers_residual) == 0) 135 - SCp->Status = 0; 136 - else { 137 - SCp->buffer++; 138 - SCp->ptr = sg_virt(SCp->buffer); 139 - SCp->this_residual = SCp->buffer->length; 140 - } 141 - } 142 - } 143 - 144 - static irqreturn_t eata_pio_int_handler(int irq, void *dev_id); 145 - 146 - static irqreturn_t do_eata_pio_int_handler(int irq, void *dev_id) 147 - { 148 - unsigned long flags; 149 - struct Scsi_Host *dev = dev_id; 150 - irqreturn_t ret; 151 - 152 - spin_lock_irqsave(dev->host_lock, flags); 153 - ret = eata_pio_int_handler(irq, dev_id); 154 - spin_unlock_irqrestore(dev->host_lock, flags); 155 - return ret; 156 - } 157 - 158 - static irqreturn_t eata_pio_int_handler(int irq, void *dev_id) 159 - { 160 - unsigned int eata_stat = 0xfffff; 161 - struct scsi_cmnd *cmd; 162 - hostdata *hd; 163 - struct eata_ccb *cp; 164 - unsigned long base; 165 - unsigned int x, z; 166 - struct Scsi_Host *sh; 167 - unsigned short zwickel = 0; 168 - unsigned char stat, odd; 169 - irqreturn_t ret = IRQ_NONE; 170 - 171 - for (x = 1, sh = first_HBA; x <= registered_HBAs; x++, sh = SD(sh)->prev) 172 - { 173 - if (sh->irq != irq) 174 - continue; 175 - if (inb(sh->base + HA_RSTATUS) & HA_SBUSY) 176 - continue; 177 - 178 - int_counter++; 179 - ret = IRQ_HANDLED; 180 - 181 - hd = SD(sh); 182 - 183 - cp = &hd->ccb[0]; 184 - cmd = cp->cmd; 185 - base = cmd->device->host->base; 186 - 187 - do { 188 - stat = inb(base + HA_RSTATUS); 189 - if (stat & HA_SDRQ) { 190 - if (cp->DataIn) { 191 - z = 256; 192 - odd = 0; 193 - while ((cmd->SCp.Status) && ((z > 0) || (odd))) { 194 - if (odd) { 195 - *(cmd->SCp.ptr) = zwickel >> 8; 196 - IncStat(&cmd->SCp, 1); 197 - odd = 0; 198 - } 199 - x = min_t(unsigned int, z, cmd->SCp.this_residual / 2); 200 - insw(base + HA_RDATA, cmd->SCp.ptr, x); 201 - z -= x; 202 - IncStat(&cmd->SCp, 2 * x); 203 - if ((z > 0) && (cmd->SCp.this_residual == 1)) { 204 - zwickel = inw(base + HA_RDATA); 205 - *(cmd->SCp.ptr) = zwickel & 0xff; 206 - IncStat(&cmd->SCp, 1); 207 - z--; 208 - odd = 1; 209 - } 210 - } 211 - while (z > 0) { 212 - zwickel = inw(base + HA_RDATA); 213 - z--; 214 - } 215 - } else { /* cp->DataOut */ 216 - 217 - odd = 0; 218 - z = 256; 219 - while ((cmd->SCp.Status) && ((z > 0) || (odd))) { 220 - if (odd) { 221 - zwickel += *(cmd->SCp.ptr) << 8; 222 - IncStat(&cmd->SCp, 1); 223 - outw(zwickel, base + HA_RDATA); 224 - z--; 225 - odd = 0; 226 - } 227 - x = min_t(unsigned int, z, cmd->SCp.this_residual / 2); 228 - outsw(base + HA_RDATA, cmd->SCp.ptr, x); 229 - z -= x; 230 - IncStat(&cmd->SCp, 2 * x); 231 - if ((z > 0) && (cmd->SCp.this_residual == 1)) { 232 - zwickel = *(cmd->SCp.ptr); 233 - zwickel &= 0xff; 234 - IncStat(&cmd->SCp, 1); 235 - odd = 1; 236 - } 237 - } 238 - while (z > 0 || odd) { 239 - outw(zwickel, base + HA_RDATA); 240 - z--; 241 - odd = 0; 242 - } 243 - } 244 - } 245 - } 246 - while ((stat & HA_SDRQ) || ((stat & HA_SMORE) && hd->moresupport)); 247 - 248 - /* terminate handler if HBA goes busy again, i.e. transfers 249 - * more data */ 250 - 251 - if (stat & HA_SBUSY) 252 - break; 253 - 254 - /* OK, this is quite stupid, but I haven't found any correct 255 - * way to get HBA&SCSI status so far */ 256 - 257 - if (!(inb(base + HA_RSTATUS) & HA_SERROR)) { 258 - cmd->result = (DID_OK << 16); 259 - hd->devflags |= (1 << cp->cp_id); 260 - } else if (hd->devflags & (1 << cp->cp_id)) 261 - cmd->result = (DID_OK << 16) + 0x02; 262 - else 263 - cmd->result = (DID_NO_CONNECT << 16); 264 - 265 - if (cp->status == LOCKED) { 266 - cp->status = FREE; 267 - eata_stat = inb(base + HA_RSTATUS); 268 - printk(KERN_CRIT "eata_pio: int_handler, freeing locked " "queueslot\n"); 269 - return ret; 270 - } 271 - #if DBG_INTR2 272 - if (stat != 0x50) 273 - printk(KERN_DEBUG "stat: %#.2x, result: %#.8x\n", stat, cmd->result); 274 - #endif 275 - 276 - cp->status = FREE; /* now we can release the slot */ 277 - 278 - cmd->scsi_done(cmd); 279 - } 280 - 281 - return ret; 282 - } 283 - 284 - static inline unsigned int eata_pio_send_command(unsigned long base, unsigned char command) 285 - { 286 - unsigned int loop = 50; 287 - 288 - while (inb(base + HA_RSTATUS) & HA_SBUSY) 289 - if (--loop == 0) 290 - return 1; 291 - 292 - /* Enable interrupts for HBA. It is not the best way to do it at this 293 - * place, but I hope that it doesn't interfere with the IDE driver 294 - * initialization this way */ 295 - 296 - outb(HA_CTRL_8HEADS, base + HA_CTRLREG); 297 - 298 - outb(command, base + HA_WCOMMAND); 299 - return 0; 300 - } 301 - 302 - static int eata_pio_queue_lck(struct scsi_cmnd *cmd, 303 - void (*done)(struct scsi_cmnd *)) 304 - { 305 - unsigned int x, y; 306 - unsigned long base; 307 - 308 - hostdata *hd; 309 - struct Scsi_Host *sh; 310 - struct eata_ccb *cp; 311 - 312 - queue_counter++; 313 - 314 - hd = HD(cmd); 315 - sh = cmd->device->host; 316 - base = sh->base; 317 - 318 - /* use only slot 0, as 2001 can handle only one cmd at a time */ 319 - 320 - y = x = 0; 321 - 322 - if (hd->ccb[y].status != FREE) { 323 - 324 - DBG(DBG_QUEUE, printk(KERN_EMERG "can_queue %d, x %d, y %d\n", sh->can_queue, x, y)); 325 - #if DEBUG_EATA 326 - panic(KERN_EMERG "eata_pio: run out of queue slots cmdno:%ld " "intrno: %ld\n", queue_counter, int_counter); 327 - #else 328 - panic(KERN_EMERG "eata_pio: run out of queue slots....\n"); 329 - #endif 330 - } 331 - 332 - cp = &hd->ccb[y]; 333 - 334 - memset(cp, 0, sizeof(struct eata_ccb)); 335 - 336 - cp->status = USED; /* claim free slot */ 337 - 338 - DBG(DBG_QUEUE, scmd_printk(KERN_DEBUG, cmd, 339 - "eata_pio_queue 0x%p, y %d\n", cmd, y)); 340 - 341 - cmd->scsi_done = (void *) done; 342 - 343 - if (cmd->sc_data_direction == DMA_TO_DEVICE) 344 - cp->DataOut = 1; /* Output mode */ 345 - else 346 - cp->DataIn = 0; /* Input mode */ 347 - 348 - cp->Interpret = (cmd->device->id == hd->hostid); 349 - cp->cp_datalen = cpu_to_be32(scsi_bufflen(cmd)); 350 - cp->Auto_Req_Sen = 0; 351 - cp->cp_reqDMA = 0; 352 - cp->reqlen = 0; 353 - 354 - cp->cp_id = cmd->device->id; 355 - cp->cp_lun = cmd->device->lun; 356 - cp->cp_dispri = 0; 357 - cp->cp_identify = 1; 358 - memcpy(cp->cp_cdb, cmd->cmnd, COMMAND_SIZE(*cmd->cmnd)); 359 - 360 - cp->cp_statDMA = 0; 361 - 362 - cp->cp_viraddr = cp; 363 - cp->cmd = cmd; 364 - cmd->host_scribble = (char *) &hd->ccb[y]; 365 - 366 - if (!scsi_bufflen(cmd)) { 367 - cmd->SCp.buffers_residual = 1; 368 - cmd->SCp.ptr = NULL; 369 - cmd->SCp.this_residual = 0; 370 - cmd->SCp.buffer = NULL; 371 - } else { 372 - cmd->SCp.buffer = scsi_sglist(cmd); 373 - cmd->SCp.buffers_residual = scsi_sg_count(cmd); 374 - cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); 375 - cmd->SCp.this_residual = cmd->SCp.buffer->length; 376 - } 377 - cmd->SCp.Status = (cmd->SCp.this_residual != 0); /* TRUE as long as bytes 378 - * are to transfer */ 379 - 380 - if (eata_pio_send_command(base, EATA_CMD_PIO_SEND_CP)) { 381 - cmd->result = DID_BUS_BUSY << 16; 382 - scmd_printk(KERN_NOTICE, cmd, 383 - "eata_pio_queue pid 0x%p, HBA busy, " 384 - "returning DID_BUS_BUSY, done.\n", cmd); 385 - done(cmd); 386 - cp->status = FREE; 387 - return 0; 388 - } 389 - /* FIXME: timeout */ 390 - while (!(inb(base + HA_RSTATUS) & HA_SDRQ)) 391 - cpu_relax(); 392 - outsw(base + HA_RDATA, cp, hd->cplen); 393 - outb(EATA_CMD_PIO_TRUNC, base + HA_WCOMMAND); 394 - for (x = 0; x < hd->cppadlen; x++) 395 - outw(0, base + HA_RDATA); 396 - 397 - DBG(DBG_QUEUE, scmd_printk(KERN_DEBUG, cmd, 398 - "Queued base %#.4lx cmd: 0x%p " 399 - "slot %d irq %d\n", sh->base, cmd, y, sh->irq)); 400 - 401 - return 0; 402 - } 403 - 404 - static DEF_SCSI_QCMD(eata_pio_queue) 405 - 406 - static int eata_pio_abort(struct scsi_cmnd *cmd) 407 - { 408 - unsigned int loop = 100; 409 - 410 - DBG(DBG_ABNORM, scmd_printk(KERN_WARNING, cmd, 411 - "eata_pio_abort called pid: 0x%p\n", cmd)); 412 - 413 - while (inb(cmd->device->host->base + HA_RAUXSTAT) & HA_ABUSY) 414 - if (--loop == 0) { 415 - printk(KERN_WARNING "eata_pio: abort, timeout error.\n"); 416 - return FAILED; 417 - } 418 - if (CD(cmd)->status == FREE) { 419 - DBG(DBG_ABNORM, printk(KERN_WARNING "Returning: SCSI_ABORT_NOT_RUNNING\n")); 420 - return FAILED; 421 - } 422 - if (CD(cmd)->status == USED) { 423 - DBG(DBG_ABNORM, printk(KERN_WARNING "Returning: SCSI_ABORT_BUSY\n")); 424 - /* We want to sleep a bit more here */ 425 - return FAILED; /* SNOOZE */ 426 - } 427 - if (CD(cmd)->status == RESET) { 428 - printk(KERN_WARNING "eata_pio: abort, command reset error.\n"); 429 - return FAILED; 430 - } 431 - if (CD(cmd)->status == LOCKED) { 432 - DBG(DBG_ABNORM, printk(KERN_WARNING "eata_pio: abort, queue slot " "locked.\n")); 433 - return FAILED; 434 - } 435 - panic("eata_pio: abort: invalid slot status\n"); 436 - } 437 - 438 - static int eata_pio_host_reset(struct scsi_cmnd *cmd) 439 - { 440 - unsigned int x, limit = 0; 441 - unsigned char success = 0; 442 - struct scsi_cmnd *sp; 443 - struct Scsi_Host *host = cmd->device->host; 444 - 445 - DBG(DBG_ABNORM, scmd_printk(KERN_WARNING, cmd, 446 - "eata_pio_reset called\n")); 447 - 448 - spin_lock_irq(host->host_lock); 449 - 450 - if (HD(cmd)->state == RESET) { 451 - printk(KERN_WARNING "eata_pio_reset: exit, already in reset.\n"); 452 - spin_unlock_irq(host->host_lock); 453 - return FAILED; 454 - } 455 - 456 - /* force all slots to be free */ 457 - 458 - for (x = 0; x < cmd->device->host->can_queue; x++) { 459 - 460 - if (HD(cmd)->ccb[x].status == FREE) 461 - continue; 462 - 463 - sp = HD(cmd)->ccb[x].cmd; 464 - HD(cmd)->ccb[x].status = RESET; 465 - printk(KERN_WARNING "eata_pio_reset: slot %d in reset.\n", x); 466 - 467 - if (sp == NULL) 468 - panic("eata_pio_reset: slot %d, sp==NULL.\n", x); 469 - } 470 - 471 - /* hard reset the HBA */ 472 - outb(EATA_CMD_RESET, cmd->device->host->base + HA_WCOMMAND); 473 - 474 - DBG(DBG_ABNORM, printk(KERN_WARNING "eata_pio_reset: board reset done.\n")); 475 - HD(cmd)->state = RESET; 476 - 477 - spin_unlock_irq(host->host_lock); 478 - msleep(3000); 479 - spin_lock_irq(host->host_lock); 480 - 481 - DBG(DBG_ABNORM, printk(KERN_WARNING "eata_pio_reset: interrupts disabled, " "loops %d.\n", limit)); 482 - 483 - for (x = 0; x < cmd->device->host->can_queue; x++) { 484 - 485 - /* Skip slots already set free by interrupt */ 486 - if (HD(cmd)->ccb[x].status != RESET) 487 - continue; 488 - 489 - sp = HD(cmd)->ccb[x].cmd; 490 - sp->result = DID_RESET << 16; 491 - 492 - /* This mailbox is terminated */ 493 - printk(KERN_WARNING "eata_pio_reset: reset ccb %d.\n", x); 494 - HD(cmd)->ccb[x].status = FREE; 495 - 496 - sp->scsi_done(sp); 497 - } 498 - 499 - HD(cmd)->state = 0; 500 - 501 - spin_unlock_irq(host->host_lock); 502 - 503 - if (success) { /* hmmm... */ 504 - DBG(DBG_ABNORM, printk(KERN_WARNING "eata_pio_reset: exit, success.\n")); 505 - return SUCCESS; 506 - } else { 507 - DBG(DBG_ABNORM, printk(KERN_WARNING "eata_pio_reset: exit, wakeup.\n")); 508 - return FAILED; 509 - } 510 - } 511 - 512 - static char *get_pio_board_data(unsigned long base, unsigned int irq, unsigned int id, unsigned long cplen, unsigned short cppadlen) 513 - { 514 - struct eata_ccb cp; 515 - static char buff[256]; 516 - int z; 517 - 518 - memset(&cp, 0, sizeof(struct eata_ccb)); 519 - memset(buff, 0, sizeof(buff)); 520 - 521 - cp.DataIn = 1; 522 - cp.Interpret = 1; /* Interpret command */ 523 - 524 - cp.cp_datalen = cpu_to_be32(254); 525 - cp.cp_dataDMA = cpu_to_be32(0); 526 - 527 - cp.cp_id = id; 528 - cp.cp_lun = 0; 529 - 530 - cp.cp_cdb[0] = INQUIRY; 531 - cp.cp_cdb[1] = 0; 532 - cp.cp_cdb[2] = 0; 533 - cp.cp_cdb[3] = 0; 534 - cp.cp_cdb[4] = 254; 535 - cp.cp_cdb[5] = 0; 536 - 537 - if (eata_pio_send_command(base, EATA_CMD_PIO_SEND_CP)) 538 - return NULL; 539 - 540 - while (!(inb(base + HA_RSTATUS) & HA_SDRQ)) 541 - cpu_relax(); 542 - 543 - outsw(base + HA_RDATA, &cp, cplen); 544 - outb(EATA_CMD_PIO_TRUNC, base + HA_WCOMMAND); 545 - for (z = 0; z < cppadlen; z++) 546 - outw(0, base + HA_RDATA); 547 - 548 - while (inb(base + HA_RSTATUS) & HA_SBUSY) 549 - cpu_relax(); 550 - 551 - if (inb(base + HA_RSTATUS) & HA_SERROR) 552 - return NULL; 553 - else if (!(inb(base + HA_RSTATUS) & HA_SDRQ)) 554 - return NULL; 555 - else { 556 - insw(base + HA_RDATA, &buff, 127); 557 - while (inb(base + HA_RSTATUS) & HA_SDRQ) 558 - inw(base + HA_RDATA); 559 - return buff; 560 - } 561 - } 562 - 563 - static int get_pio_conf_PIO(unsigned long base, struct get_conf *buf) 564 - { 565 - unsigned long loop = HZ / 2; 566 - int z; 567 - unsigned short *p; 568 - 569 - if (!request_region(base, 9, "eata_pio")) 570 - return 0; 571 - 572 - memset(buf, 0, sizeof(struct get_conf)); 573 - 574 - while (inb(base + HA_RSTATUS) & HA_SBUSY) 575 - if (--loop == 0) 576 - goto fail; 577 - 578 - DBG(DBG_PIO && DBG_PROBE, printk(KERN_DEBUG "Issuing PIO READ CONFIG to HBA at %#lx\n", base)); 579 - eata_pio_send_command(base, EATA_CMD_PIO_READ_CONFIG); 580 - 581 - loop = 50; 582 - for (p = (unsigned short *) buf; (long) p <= ((long) buf + (sizeof(struct get_conf) / 2)); p++) { 583 - while (!(inb(base + HA_RSTATUS) & HA_SDRQ)) 584 - if (--loop == 0) 585 - goto fail; 586 - 587 - loop = 50; 588 - *p = inw(base + HA_RDATA); 589 - } 590 - if (inb(base + HA_RSTATUS) & HA_SERROR) { 591 - DBG(DBG_PROBE, printk("eata_dma: get_conf_PIO, error during " 592 - "transfer for HBA at %lx\n", base)); 593 - goto fail; 594 - } 595 - 596 - if (cpu_to_be32(EATA_SIGNATURE) != buf->signature) 597 - goto fail; 598 - 599 - DBG(DBG_PIO && DBG_PROBE, printk(KERN_NOTICE "EATA Controller found " 600 - "at %#4lx EATA Level: %x\n", 601 - base, (unsigned int) (buf->version))); 602 - 603 - while (inb(base + HA_RSTATUS) & HA_SDRQ) 604 - inw(base + HA_RDATA); 605 - 606 - if (!ALLOW_DMA_BOARDS) { 607 - for (z = 0; z < MAXISA; z++) 608 - if (base == ISAbases[z]) { 609 - buf->IRQ = ISAirqs[z]; 610 - break; 611 - } 612 - } 613 - 614 - return 1; 615 - 616 - fail: 617 - release_region(base, 9); 618 - return 0; 619 - } 620 - 621 - static void print_pio_config(struct get_conf *gc) 622 - { 623 - printk("Please check values: (read config data)\n"); 624 - printk("LEN: %d ver:%d OCS:%d TAR:%d TRNXFR:%d MORES:%d\n", be32_to_cpu(gc->len), gc->version, gc->OCS_enabled, gc->TAR_support, gc->TRNXFR, gc->MORE_support); 625 - printk("HAAV:%d SCSIID0:%d ID1:%d ID2:%d QUEUE:%d SG:%d SEC:%d\n", gc->HAA_valid, gc->scsi_id[3], gc->scsi_id[2], gc->scsi_id[1], be16_to_cpu(gc->queuesiz), be16_to_cpu(gc->SGsiz), gc->SECOND); 626 - printk("IRQ:%d IRQT:%d FORCADR:%d MCH:%d RIDQ:%d\n", gc->IRQ, gc->IRQ_TR, gc->FORCADR, gc->MAX_CHAN, gc->ID_qest); 627 - } 628 - 629 - static unsigned int print_selftest(unsigned int base) 630 - { 631 - unsigned char buffer[512]; 632 - #ifdef VERBOSE_SETUP 633 - int z; 634 - #endif 635 - 636 - printk("eata_pio: executing controller self test & setup...\n"); 637 - while (inb(base + HA_RSTATUS) & HA_SBUSY); 638 - outb(EATA_CMD_PIO_SETUPTEST, base + HA_WCOMMAND); 639 - do { 640 - while (inb(base + HA_RSTATUS) & HA_SBUSY) 641 - /* nothing */ ; 642 - if (inb(base + HA_RSTATUS) & HA_SDRQ) { 643 - insw(base + HA_RDATA, &buffer, 256); 644 - #ifdef VERBOSE_SETUP 645 - /* no beeps please... */ 646 - for (z = 0; z < 511 && buffer[z]; z++) 647 - if (buffer[z] != 7) 648 - printk("%c", buffer[z]); 649 - #endif 650 - } 651 - } while (inb(base + HA_RSTATUS) & (HA_SBUSY | HA_SDRQ)); 652 - 653 - return (!(inb(base + HA_RSTATUS) & HA_SERROR)); 654 - } 655 - 656 - static int register_pio_HBA(long base, struct get_conf *gc, struct pci_dev *pdev) 657 - { 658 - unsigned long size = 0; 659 - char *buff; 660 - unsigned long cplen; 661 - unsigned short cppadlen; 662 - struct Scsi_Host *sh; 663 - hostdata *hd; 664 - 665 - DBG(DBG_REGISTER, print_pio_config(gc)); 666 - 667 - if (gc->DMA_support) { 668 - printk("HBA at %#.4lx supports DMA. Please use EATA-DMA driver.\n", base); 669 - if (!ALLOW_DMA_BOARDS) 670 - return 0; 671 - } 672 - 673 - if ((buff = get_pio_board_data(base, gc->IRQ, gc->scsi_id[3], cplen = (cpu_to_be32(gc->cplen) + 1) / 2, cppadlen = (cpu_to_be16(gc->cppadlen) + 1) / 2)) == NULL) { 674 - printk("HBA at %#lx didn't react on INQUIRY. Sorry.\n", base); 675 - return 0; 676 - } 677 - 678 - if (!print_selftest(base) && !ALLOW_DMA_BOARDS) { 679 - printk("HBA at %#lx failed while performing self test & setup.\n", base); 680 - return 0; 681 - } 682 - 683 - size = sizeof(hostdata) + (sizeof(struct eata_ccb) * be16_to_cpu(gc->queuesiz)); 684 - 685 - sh = scsi_register(&driver_template, size); 686 - if (sh == NULL) 687 - return 0; 688 - 689 - if (!reg_IRQ[gc->IRQ]) { /* Interrupt already registered ? */ 690 - if (!request_irq(gc->IRQ, do_eata_pio_int_handler, 0, "EATA-PIO", sh)) { 691 - reg_IRQ[gc->IRQ]++; 692 - if (!gc->IRQ_TR) 693 - reg_IRQL[gc->IRQ] = 1; /* IRQ is edge triggered */ 694 - } else { 695 - printk("Couldn't allocate IRQ %d, Sorry.\n", gc->IRQ); 696 - return 0; 697 - } 698 - } else { /* More than one HBA on this IRQ */ 699 - if (reg_IRQL[gc->IRQ]) { 700 - printk("Can't support more than one HBA on this IRQ,\n" " if the IRQ is edge triggered. Sorry.\n"); 701 - return 0; 702 - } else 703 - reg_IRQ[gc->IRQ]++; 704 - } 705 - 706 - hd = SD(sh); 707 - 708 - memset(hd->ccb, 0, (sizeof(struct eata_ccb) * be16_to_cpu(gc->queuesiz))); 709 - memset(hd->reads, 0, sizeof(hd->reads)); 710 - 711 - strlcpy(SD(sh)->vendor, &buff[8], sizeof(SD(sh)->vendor)); 712 - strlcpy(SD(sh)->name, &buff[16], sizeof(SD(sh)->name)); 713 - SD(sh)->revision[0] = buff[32]; 714 - SD(sh)->revision[1] = buff[33]; 715 - SD(sh)->revision[2] = buff[34]; 716 - SD(sh)->revision[3] = '.'; 717 - SD(sh)->revision[4] = buff[35]; 718 - SD(sh)->revision[5] = 0; 719 - 720 - switch (be32_to_cpu(gc->len)) { 721 - case 0x1c: 722 - SD(sh)->EATA_revision = 'a'; 723 - break; 724 - case 0x1e: 725 - SD(sh)->EATA_revision = 'b'; 726 - break; 727 - case 0x22: 728 - SD(sh)->EATA_revision = 'c'; 729 - break; 730 - case 0x24: 731 - SD(sh)->EATA_revision = 'z'; 732 - break; 733 - default: 734 - SD(sh)->EATA_revision = '?'; 735 - } 736 - 737 - if (be32_to_cpu(gc->len) >= 0x22) { 738 - if (gc->is_PCI) 739 - hd->bustype = IS_PCI; 740 - else if (gc->is_EISA) 741 - hd->bustype = IS_EISA; 742 - else 743 - hd->bustype = IS_ISA; 744 - } else { 745 - if (buff[21] == '4') 746 - hd->bustype = IS_PCI; 747 - else if (buff[21] == '2') 748 - hd->bustype = IS_EISA; 749 - else 750 - hd->bustype = IS_ISA; 751 - } 752 - 753 - SD(sh)->cplen = cplen; 754 - SD(sh)->cppadlen = cppadlen; 755 - SD(sh)->hostid = gc->scsi_id[3]; 756 - SD(sh)->devflags = 1 << gc->scsi_id[3]; 757 - SD(sh)->moresupport = gc->MORE_support; 758 - sh->unique_id = base; 759 - sh->base = base; 760 - sh->io_port = base; 761 - sh->n_io_port = 9; 762 - sh->irq = gc->IRQ; 763 - sh->dma_channel = PIO; 764 - sh->this_id = gc->scsi_id[3]; 765 - sh->can_queue = 1; 766 - sh->cmd_per_lun = 1; 767 - sh->sg_tablesize = SG_ALL; 768 - 769 - hd->channel = 0; 770 - 771 - hd->pdev = pci_dev_get(pdev); /* Keep a PCI reference */ 772 - 773 - sh->max_id = 8; 774 - sh->max_lun = 8; 775 - 776 - if (gc->SECOND) 777 - hd->primary = 0; 778 - else 779 - hd->primary = 1; 780 - 781 - hd->next = NULL; /* build a linked list of all HBAs */ 782 - hd->prev = last_HBA; 783 - if (hd->prev != NULL) 784 - SD(hd->prev)->next = sh; 785 - last_HBA = sh; 786 - if (first_HBA == NULL) 787 - first_HBA = sh; 788 - registered_HBAs++; 789 - return (1); 790 - } 791 - 792 - static void find_pio_ISA(struct get_conf *buf) 793 - { 794 - int i; 795 - 796 - for (i = 0; i < MAXISA; i++) { 797 - if (!ISAbases[i]) 798 - continue; 799 - if (!get_pio_conf_PIO(ISAbases[i], buf)) 800 - continue; 801 - if (!register_pio_HBA(ISAbases[i], buf, NULL)) 802 - release_region(ISAbases[i], 9); 803 - else 804 - ISAbases[i] = 0; 805 - } 806 - return; 807 - } 808 - 809 - static void find_pio_EISA(struct get_conf *buf) 810 - { 811 - u32 base; 812 - int i; 813 - 814 - #ifdef CHECKPAL 815 - u8 pal1, pal2, pal3; 816 - #endif 817 - 818 - for (i = 0; i < MAXEISA; i++) { 819 - if (EISAbases[i]) { /* Still a possibility ? */ 820 - 821 - base = 0x1c88 + (i * 0x1000); 822 - #ifdef CHECKPAL 823 - pal1 = inb((u16) base - 8); 824 - pal2 = inb((u16) base - 7); 825 - pal3 = inb((u16) base - 6); 826 - 827 - if (((pal1 == 0x12) && (pal2 == 0x14)) || ((pal1 == 0x38) && (pal2 == 0xa3) && (pal3 == 0x82)) || ((pal1 == 0x06) && (pal2 == 0x94) && (pal3 == 0x24))) { 828 - DBG(DBG_PROBE, printk(KERN_NOTICE "EISA EATA id tags found: " "%x %x %x \n", (int) pal1, (int) pal2, (int) pal3)); 829 - #endif 830 - if (get_pio_conf_PIO(base, buf)) { 831 - DBG(DBG_PROBE && DBG_EISA, print_pio_config(buf)); 832 - if (buf->IRQ) { 833 - if (!register_pio_HBA(base, buf, NULL)) 834 - release_region(base, 9); 835 - } else { 836 - printk(KERN_NOTICE "eata_dma: No valid IRQ. HBA " "removed from list\n"); 837 - release_region(base, 9); 838 - } 839 - } 840 - /* Nothing found here so we take it from the list */ 841 - EISAbases[i] = 0; 842 - #ifdef CHECKPAL 843 - } 844 - #endif 845 - } 846 - } 847 - return; 848 - } 849 - 850 - static void find_pio_PCI(struct get_conf *buf) 851 - { 852 - #ifndef CONFIG_PCI 853 - printk("eata_dma: kernel PCI support not enabled. Skipping scan for PCI HBAs.\n"); 854 - #else 855 - struct pci_dev *dev = NULL; 856 - unsigned long base, x; 857 - 858 - while ((dev = pci_get_device(PCI_VENDOR_ID_DPT, PCI_DEVICE_ID_DPT, dev)) != NULL) { 859 - DBG(DBG_PROBE && DBG_PCI, printk("eata_pio: find_PCI, HBA at %s\n", pci_name(dev))); 860 - if (pci_enable_device(dev)) 861 - continue; 862 - pci_set_master(dev); 863 - base = pci_resource_flags(dev, 0); 864 - if (base & IORESOURCE_MEM) { 865 - printk("eata_pio: invalid base address of device %s\n", pci_name(dev)); 866 - continue; 867 - } 868 - base = pci_resource_start(dev, 0); 869 - /* EISA tag there ? */ 870 - if ((inb(base) == 0x12) && (inb(base + 1) == 0x14)) 871 - continue; /* Jep, it's forced, so move on */ 872 - base += 0x10; /* Now, THIS is the real address */ 873 - if (base != 0x1f8) { 874 - /* We didn't find it in the primary search */ 875 - if (get_pio_conf_PIO(base, buf)) { 876 - if (buf->FORCADR) { /* If the address is forced */ 877 - release_region(base, 9); 878 - continue; /* we'll find it later */ 879 - } 880 - 881 - /* OK. We made it till here, so we can go now 882 - * and register it. We only have to check and 883 - * eventually remove it from the EISA and ISA list 884 - */ 885 - 886 - if (!register_pio_HBA(base, buf, dev)) { 887 - release_region(base, 9); 888 - continue; 889 - } 890 - 891 - if (base < 0x1000) { 892 - for (x = 0; x < MAXISA; ++x) { 893 - if (ISAbases[x] == base) { 894 - ISAbases[x] = 0; 895 - break; 896 - } 897 - } 898 - } else if ((base & 0x0fff) == 0x0c88) { 899 - x = (base >> 12) & 0x0f; 900 - EISAbases[x] = 0; 901 - } 902 - } 903 - #ifdef CHECK_BLINK 904 - else if (check_blink_state(base)) { 905 - printk("eata_pio: HBA is in BLINK state.\n" "Consult your HBAs manual to correct this.\n"); 906 - } 907 - #endif 908 - } 909 - } 910 - #endif /* #ifndef CONFIG_PCI */ 911 - } 912 - 913 - static int eata_pio_detect(struct scsi_host_template *tpnt) 914 - { 915 - struct Scsi_Host *HBA_ptr; 916 - struct get_conf gc; 917 - int i; 918 - 919 - find_pio_PCI(&gc); 920 - find_pio_EISA(&gc); 921 - find_pio_ISA(&gc); 922 - 923 - for (i = 0; i < MAXIRQ; i++) 924 - if (reg_IRQ[i]) 925 - request_irq(i, do_eata_pio_int_handler, 0, "EATA-PIO", NULL); 926 - 927 - HBA_ptr = first_HBA; 928 - 929 - if (registered_HBAs != 0) { 930 - printk("EATA (Extended Attachment) PIO driver version: %d.%d%s\n" 931 - "(c) 1993-95 Michael Neuffer, neuffer@goofy.zdv.uni-mainz.de\n" " Alfred Arnold, a.arnold@kfa-juelich.de\n" "This release only supports DASD devices (harddisks)\n", VER_MAJOR, VER_MINOR, VER_SUB); 932 - 933 - printk("Registered HBAs:\n"); 934 - printk("HBA no. Boardtype: Revis: EATA: Bus: BaseIO: IRQ: Ch: ID: Pr:" " QS: SG: CPL:\n"); 935 - for (i = 1; i <= registered_HBAs; i++) { 936 - printk("scsi%-2d: %.10s v%s 2.0%c %s %#.4lx %2d %d %d %c" 937 - " %2d %2d %2d\n", 938 - HBA_ptr->host_no, SD(HBA_ptr)->name, SD(HBA_ptr)->revision, 939 - SD(HBA_ptr)->EATA_revision, (SD(HBA_ptr)->bustype == 'P') ? 940 - "PCI " : (SD(HBA_ptr)->bustype == 'E') ? "EISA" : "ISA ", 941 - HBA_ptr->base, HBA_ptr->irq, SD(HBA_ptr)->channel, HBA_ptr->this_id, 942 - SD(HBA_ptr)->primary ? 'Y' : 'N', HBA_ptr->can_queue, 943 - HBA_ptr->sg_tablesize, HBA_ptr->cmd_per_lun); 944 - HBA_ptr = SD(HBA_ptr)->next; 945 - } 946 - } 947 - return (registered_HBAs); 948 - } 949 - 950 - static struct scsi_host_template driver_template = { 951 - .proc_name = "eata_pio", 952 - .name = "EATA (Extended Attachment) PIO driver", 953 - .show_info = eata_pio_show_info, 954 - .detect = eata_pio_detect, 955 - .release = eata_pio_release, 956 - .queuecommand = eata_pio_queue, 957 - .eh_abort_handler = eata_pio_abort, 958 - .eh_host_reset_handler = eata_pio_host_reset, 959 - .use_clustering = ENABLE_CLUSTERING, 960 - }; 961 - 962 - MODULE_AUTHOR("Michael Neuffer, Alfred Arnold"); 963 - MODULE_DESCRIPTION("EATA SCSI PIO driver"); 964 - MODULE_LICENSE("GPL"); 965 - 966 - #include "scsi_module.c"
-54
drivers/scsi/eata_pio.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - /******************************************************** 3 - * Header file for eata_pio.c Linux EATA-PIO SCSI driver * 4 - * (c) 1993-96 Michael Neuffer * 5 - ********************************************************* 6 - * last change: 2002/11/02 * 7 - ********************************************************/ 8 - 9 - 10 - #ifndef _EATA_PIO_H 11 - #define _EATA_PIO_H 12 - 13 - #define VER_MAJOR 0 14 - #define VER_MINOR 0 15 - #define VER_SUB "1b" 16 - 17 - /************************************************************************ 18 - * Here you can switch parts of the code on and of * 19 - ************************************************************************/ 20 - 21 - #define VERBOSE_SETUP /* show startup screen of 2001 */ 22 - #define ALLOW_DMA_BOARDS 1 23 - 24 - /************************************************************************ 25 - * Debug options. * 26 - * Enable DEBUG and whichever options you require. * 27 - ************************************************************************/ 28 - #define DEBUG_EATA 1 /* Enable debug code. */ 29 - #define DPT_DEBUG 0 /* Bobs special */ 30 - #define DBG_DELAY 0 /* Build in delays so debug messages can be 31 - * be read before they vanish of the top of 32 - * the screen! 33 - */ 34 - #define DBG_PROBE 0 /* Debug probe routines. */ 35 - #define DBG_ISA 0 /* Trace ISA routines */ 36 - #define DBG_EISA 0 /* Trace EISA routines */ 37 - #define DBG_PCI 0 /* Trace PCI routines */ 38 - #define DBG_PIO 0 /* Trace get_config_PIO */ 39 - #define DBG_COM 0 /* Trace command call */ 40 - #define DBG_QUEUE 0 /* Trace command queueing. */ 41 - #define DBG_INTR 0 /* Trace interrupt service routine. */ 42 - #define DBG_INTR2 0 /* Trace interrupt service routine. */ 43 - #define DBG_PROC 0 /* Debug proc-fs related statistics */ 44 - #define DBG_PROC_WRITE 0 45 - #define DBG_REGISTER 0 /* */ 46 - #define DBG_ABNORM 1 /* Debug abnormal actions (reset, abort) */ 47 - 48 - #if DEBUG_EATA 49 - #define DBG(x, y) if ((x)) {y;} 50 - #else 51 - #define DBG(x, y) 52 - #endif 53 - 54 - #endif /* _EATA_PIO_H */