ultrastor.c 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210
  1. /*
  2. * ultrastor.c Copyright (C) 1992 David B. Gentzel
  3. * Low-level SCSI driver for UltraStor 14F, 24F, and 34F
  4. * by David B. Gentzel, Whitfield Software Services, Carnegie, PA
  5. * (gentzel@nova.enet.dec.com)
  6. * scatter/gather added by Scott Taylor (n217cg@tamuts.tamu.edu)
  7. * 24F and multiple command support by John F. Carr (jfc@athena.mit.edu)
  8. * John's work modified by Caleb Epstein (cae@jpmorgan.com) and
  9. * Eric Youngdale (ericy@cais.com).
  10. * Thanks to UltraStor for providing the necessary documentation
  11. *
  12. * This is an old driver, for the 14F and 34F you should be using the
  13. * u14-34f driver instead.
  14. */
  15. /*
  16. * TODO:
  17. * 1. Find out why scatter/gather is limited to 16 requests per command.
  18. * This is fixed, at least on the 24F, as of version 1.12 - CAE.
  19. * 2. Look at command linking (mscp.command_link and
  20. * mscp.command_link_id). (Does not work with many disks,
  21. * and no performance increase. ERY).
  22. * 3. Allow multiple adapters.
  23. */
  24. /*
  25. * NOTES:
  26. * The UltraStor 14F, 24F, and 34F are a family of intelligent, high
  27. * performance SCSI-2 host adapters. They all support command queueing
  28. * and scatter/gather I/O. Some of them can also emulate the standard
  29. * WD1003 interface for use with OS's which don't support SCSI. Here
  30. * is the scoop on the various models:
  31. * 14F - ISA first-party DMA HA with floppy support and WD1003 emulation.
  32. * 14N - ISA HA with floppy support. I think that this is a non-DMA
  33. * HA. Nothing further known.
  34. * 24F - EISA Bus Master HA with floppy support and WD1003 emulation.
  35. * 34F - VL-Bus Bus Master HA with floppy support (no WD1003 emulation).
  36. *
  37. * The 14F, 24F, and 34F are supported by this driver.
  38. *
  39. * Places flagged with a triple question-mark are things which are either
  40. * unfinished, questionable, or wrong.
  41. */
  42. /* Changes from version 1.11 alpha to 1.12
  43. *
  44. * Increased the size of the scatter-gather list to 33 entries for
  45. * the 24F adapter (it was 16). I don't have the specs for the 14F
  46. * or the 34F, so they may support larger s-g lists as well.
  47. *
  48. * Caleb Epstein <cae@jpmorgan.com>
  49. */
  50. /* Changes from version 1.9 to 1.11
  51. *
  52. * Patches to bring this driver up to speed with the default kernel
  53. * driver which supports only the 14F and 34F adapters. This version
  54. * should compile cleanly into 0.99.13, 0.99.12 and probably 0.99.11.
  55. *
  56. * Fixes from Eric Youngdale to fix a few possible race conditions and
  57. * several problems with bit testing operations (insufficient
  58. * parentheses).
  59. *
  60. * Removed the ultrastor_abort() and ultrastor_reset() functions
  61. * (enclosed them in #if 0 / #endif). These functions, at least on
  62. * the 24F, cause the SCSI bus to do odd things and generally lead to
  63. * kernel panics and machine hangs. This is like the Adaptec code.
  64. *
  65. * Use check/snarf_region for 14f, 34f to avoid I/O space address conflicts.
  66. */
  67. /* Changes from version 1.8 to version 1.9
  68. *
  69. * 0.99.11 patches (cae@jpmorgan.com) */
  70. /* Changes from version 1.7 to version 1.8
  71. *
  72. * Better error reporting.
  73. */
  74. /* Changes from version 1.6 to version 1.7
  75. *
  76. * Removed CSIR command code.
  77. *
  78. * Better race condition avoidance (xchgb function added).
  79. *
  80. * Set ICM and OGM status to zero at probe (24F)
  81. *
  82. * reset sends soft reset to UltraStor adapter
  83. *
  84. * reset adapter if adapter interrupts with an invalid MSCP address
  85. *
  86. * handle aborted command interrupt (24F)
  87. *
  88. */
  89. /* Changes from version 1.5 to version 1.6:
  90. *
  91. * Read MSCP address from ICM _before_ clearing the interrupt flag.
  92. * This fixes a race condition.
  93. */
  94. /* Changes from version 1.4 to version 1.5:
  95. *
  96. * Abort now calls done when multiple commands are enabled.
  97. *
  98. * Clear busy when aborted command finishes, not when abort is called.
  99. *
  100. * More debugging messages for aborts.
  101. */
  102. /* Changes from version 1.3 to version 1.4:
  103. *
  104. * Enable automatic request of sense data on error (requires newer version
  105. * of scsi.c to be useful).
  106. *
  107. * Fix PORT_OVERRIDE for 14F.
  108. *
  109. * Fix abort and reset to work properly (config.aborted wasn't cleared
  110. * after it was tested, so after a command abort no further commands would
  111. * work).
  112. *
  113. * Boot time test to enable SCSI bus reset (defaults to not allowing reset).
  114. *
  115. * Fix test for OGM busy -- the busy bit is in different places on the 24F.
  116. *
  117. * Release ICM slot by clearing first byte on 24F.
  118. */
  119. #include <linux/module.h>
  120. #include <linux/blkdev.h>
  121. #include <linux/interrupt.h>
  122. #include <linux/stddef.h>
  123. #include <linux/string.h>
  124. #include <linux/kernel.h>
  125. #include <linux/ioport.h>
  126. #include <linux/proc_fs.h>
  127. #include <linux/spinlock.h>
  128. #include <linux/stat.h>
  129. #include <linux/bitops.h>
  130. #include <linux/delay.h>
  131. #include <asm/io.h>
  132. #include <asm/dma.h>
  133. #define ULTRASTOR_PRIVATE /* Get the private stuff from ultrastor.h */
  134. #include "scsi.h"
  135. #include <scsi/scsi_host.h>
  136. #include "ultrastor.h"
  137. #define FALSE 0
  138. #define TRUE 1
  139. #ifndef ULTRASTOR_DEBUG
  140. #define ULTRASTOR_DEBUG (UD_ABORT|UD_CSIR|UD_RESET)
  141. #endif
  142. #define VERSION "1.12"
  143. #define PACKED __attribute__((packed))
  144. #define ALIGNED(x) __attribute__((aligned(x)))
  145. /* The 14F uses an array of 4-byte ints for its scatter/gather list.
  146. The data can be unaligned, but need not be. It's easier to give
  147. the list normal alignment since it doesn't need to fit into a
  148. packed structure. */
  149. typedef struct {
  150. u32 address;
  151. u32 num_bytes;
  152. } ultrastor_sg_list;
  153. /* MailBox SCSI Command Packet. Basic command structure for communicating
  154. with controller. */
  155. struct mscp {
  156. unsigned char opcode: 3; /* type of command */
  157. unsigned char xdir: 2; /* data transfer direction */
  158. unsigned char dcn: 1; /* disable disconnect */
  159. unsigned char ca: 1; /* use cache (if available) */
  160. unsigned char sg: 1; /* scatter/gather operation */
  161. unsigned char target_id: 3; /* target SCSI id */
  162. unsigned char ch_no: 2; /* SCSI channel (always 0 for 14f) */
  163. unsigned char lun: 3; /* logical unit number */
  164. unsigned int transfer_data PACKED; /* transfer data pointer */
  165. unsigned int transfer_data_length PACKED; /* length in bytes */
  166. unsigned int command_link PACKED; /* for linking command chains */
  167. unsigned char scsi_command_link_id; /* identifies command in chain */
  168. unsigned char number_of_sg_list; /* (if sg is set) 8 bytes per list */
  169. unsigned char length_of_sense_byte;
  170. unsigned char length_of_scsi_cdbs; /* 6, 10, or 12 */
  171. unsigned char scsi_cdbs[12]; /* SCSI commands */
  172. unsigned char adapter_status; /* non-zero indicates HA error */
  173. unsigned char target_status; /* non-zero indicates target error */
  174. u32 sense_data PACKED;
  175. /* The following fields are for software only. They are included in
  176. the MSCP structure because they are associated with SCSI requests. */
  177. void (*done) (struct scsi_cmnd *);
  178. struct scsi_cmnd *SCint;
  179. ultrastor_sg_list sglist[ULTRASTOR_24F_MAX_SG]; /* use larger size for 24F */
  180. };
  181. /* Port addresses (relative to the base address) */
  182. #define U14F_PRODUCT_ID(port) ((port) + 0x4)
  183. #define CONFIG(port) ((port) + 0x6)
  184. /* Port addresses relative to the doorbell base address. */
  185. #define LCL_DOORBELL_MASK(port) ((port) + 0x0)
  186. #define LCL_DOORBELL_INTR(port) ((port) + 0x1)
  187. #define SYS_DOORBELL_MASK(port) ((port) + 0x2)
  188. #define SYS_DOORBELL_INTR(port) ((port) + 0x3)
  189. /* Used to store configuration info read from config i/o registers. Most of
  190. this is not used yet, but might as well save it.
  191. This structure also holds port addresses that are not at the same offset
  192. on the 14F and 24F.
  193. This structure holds all data that must be duplicated to support multiple
  194. adapters. */
  195. static struct ultrastor_config
  196. {
  197. unsigned short port_address; /* base address of card */
  198. unsigned short doorbell_address; /* base address of doorbell CSRs */
  199. unsigned short ogm_address; /* base address of OGM */
  200. unsigned short icm_address; /* base address of ICM */
  201. const void *bios_segment;
  202. unsigned char interrupt: 4;
  203. unsigned char dma_channel: 3;
  204. unsigned char bios_drive_number: 1;
  205. unsigned char heads;
  206. unsigned char sectors;
  207. unsigned char ha_scsi_id: 3;
  208. unsigned char subversion: 4;
  209. unsigned char revision;
  210. /* The slot number is used to distinguish the 24F (slot != 0) from
  211. the 14F and 34F (slot == 0). */
  212. unsigned char slot;
  213. #ifdef PRINT_U24F_VERSION
  214. volatile int csir_done;
  215. #endif
  216. /* A pool of MSCP structures for this adapter, and a bitmask of
  217. busy structures. (If ULTRASTOR_14F_MAX_CMDS == 1, a 1 byte
  218. busy flag is used instead.) */
  219. #if ULTRASTOR_MAX_CMDS == 1
  220. unsigned char mscp_busy;
  221. #else
  222. unsigned long mscp_free;
  223. #endif
  224. volatile unsigned char aborted[ULTRASTOR_MAX_CMDS];
  225. struct mscp mscp[ULTRASTOR_MAX_CMDS];
  226. } config = {0};
  227. /* Set this to 1 to reset the SCSI bus on error. */
  228. static int ultrastor_bus_reset;
  229. /* Allowed BIOS base addresses (NULL indicates reserved) */
  230. static const void *const bios_segment_table[8] = {
  231. NULL, (void *)0xC4000, (void *)0xC8000, (void *)0xCC000,
  232. (void *)0xD0000, (void *)0xD4000, (void *)0xD8000, (void *)0xDC000,
  233. };
  234. /* Allowed IRQs for 14f */
  235. static const unsigned char interrupt_table_14f[4] = { 15, 14, 11, 10 };
  236. /* Allowed DMA channels for 14f (0 indicates reserved) */
  237. static const unsigned char dma_channel_table_14f[4] = { 5, 6, 7, 0 };
  238. /* Head/sector mappings allowed by 14f */
  239. static const struct {
  240. unsigned char heads;
  241. unsigned char sectors;
  242. } mapping_table[4] = { { 16, 63 }, { 64, 32 }, { 64, 63 }, { 64, 32 } };
  243. #ifndef PORT_OVERRIDE
  244. /* ??? A probe of address 0x310 screws up NE2000 cards */
  245. static const unsigned short ultrastor_ports_14f[] = {
  246. 0x330, 0x340, /*0x310,*/ 0x230, 0x240, 0x210, 0x130, 0x140,
  247. };
  248. #endif
  249. static void ultrastor_interrupt(void *);
  250. static irqreturn_t do_ultrastor_interrupt(int, void *);
  251. static inline void build_sg_list(struct mscp *, struct scsi_cmnd *SCpnt);
  252. /* Always called with host lock held */
  253. static inline int find_and_clear_bit_16(unsigned long *field)
  254. {
  255. int rv;
  256. if (*field == 0)
  257. panic("No free mscp");
  258. asm volatile (
  259. "xorl %0,%0\n\t"
  260. "0: bsfw %1,%w0\n\t"
  261. "btr %0,%1\n\t"
  262. "jnc 0b"
  263. : "=&r" (rv), "+m" (*field) :);
  264. return rv;
  265. }
  266. /* This has been re-implemented with the help of Richard Earnshaw,
  267. <rwe@pegasus.esprit.ec.org> and works with gcc-2.5.8 and gcc-2.6.0.
  268. The instability noted by jfc below appears to be a bug in
  269. gcc-2.5.x when compiling w/o optimization. --Caleb
  270. This asm is fragile: it doesn't work without the casts and it may
  271. not work without optimization. Maybe I should add a swap builtin
  272. to gcc. --jfc */
  273. static inline unsigned char xchgb(unsigned char reg,
  274. volatile unsigned char *mem)
  275. {
  276. __asm__ ("xchgb %0,%1" : "=q" (reg), "=m" (*mem) : "0" (reg));
  277. return reg;
  278. }
  279. #if ULTRASTOR_DEBUG & (UD_COMMAND | UD_ABORT)
  280. /* Always called with the host lock held */
  281. static void log_ultrastor_abort(struct ultrastor_config *config,
  282. int command)
  283. {
  284. static char fmt[80] = "abort %d (%x); MSCP free pool: %x;";
  285. int i;
  286. for (i = 0; i < ULTRASTOR_MAX_CMDS; i++)
  287. {
  288. fmt[20 + i*2] = ' ';
  289. if (! (config->mscp_free & (1 << i)))
  290. fmt[21 + i*2] = '0' + config->mscp[i].target_id;
  291. else
  292. fmt[21 + i*2] = '-';
  293. }
  294. fmt[20 + ULTRASTOR_MAX_CMDS * 2] = '\n';
  295. fmt[21 + ULTRASTOR_MAX_CMDS * 2] = 0;
  296. printk(fmt, command, &config->mscp[command], config->mscp_free);
  297. }
  298. #endif
  299. static int ultrastor_14f_detect(struct scsi_host_template * tpnt)
  300. {
  301. size_t i;
  302. unsigned char in_byte, version_byte = 0;
  303. struct config_1 {
  304. unsigned char bios_segment: 3;
  305. unsigned char removable_disks_as_fixed: 1;
  306. unsigned char interrupt: 2;
  307. unsigned char dma_channel: 2;
  308. } config_1;
  309. struct config_2 {
  310. unsigned char ha_scsi_id: 3;
  311. unsigned char mapping_mode: 2;
  312. unsigned char bios_drive_number: 1;
  313. unsigned char tfr_port: 2;
  314. } config_2;
  315. #if (ULTRASTOR_DEBUG & UD_DETECT)
  316. printk("US14F: detect: called\n");
  317. #endif
  318. /* If a 24F has already been configured, don't look for a 14F. */
  319. if (config.bios_segment)
  320. return FALSE;
  321. #ifdef PORT_OVERRIDE
  322. if(!request_region(PORT_OVERRIDE, 0xc, "ultrastor")) {
  323. printk("Ultrastor I/O space already in use\n");
  324. return FALSE;
  325. };
  326. config.port_address = PORT_OVERRIDE;
  327. #else
  328. for (i = 0; i < ARRAY_SIZE(ultrastor_ports_14f); i++) {
  329. if(!request_region(ultrastor_ports_14f[i], 0x0c, "ultrastor")) continue;
  330. config.port_address = ultrastor_ports_14f[i];
  331. #endif
  332. #if (ULTRASTOR_DEBUG & UD_DETECT)
  333. printk("US14F: detect: testing port address %03X\n", config.port_address);
  334. #endif
  335. in_byte = inb(U14F_PRODUCT_ID(config.port_address));
  336. if (in_byte != US14F_PRODUCT_ID_0) {
  337. #if (ULTRASTOR_DEBUG & UD_DETECT)
  338. # ifdef PORT_OVERRIDE
  339. printk("US14F: detect: wrong product ID 0 - %02X\n", in_byte);
  340. # else
  341. printk("US14F: detect: no adapter at port %03X\n", config.port_address);
  342. # endif
  343. #endif
  344. #ifdef PORT_OVERRIDE
  345. goto out_release_port;
  346. #else
  347. release_region(config.port_address, 0x0c);
  348. continue;
  349. #endif
  350. }
  351. in_byte = inb(U14F_PRODUCT_ID(config.port_address) + 1);
  352. /* Only upper nibble is significant for Product ID 1 */
  353. if ((in_byte & 0xF0) != US14F_PRODUCT_ID_1) {
  354. #if (ULTRASTOR_DEBUG & UD_DETECT)
  355. # ifdef PORT_OVERRIDE
  356. printk("US14F: detect: wrong product ID 1 - %02X\n", in_byte);
  357. # else
  358. printk("US14F: detect: no adapter at port %03X\n", config.port_address);
  359. # endif
  360. #endif
  361. #ifdef PORT_OVERRIDE
  362. goto out_release_port;
  363. #else
  364. release_region(config.port_address, 0x0c);
  365. continue;
  366. #endif
  367. }
  368. version_byte = in_byte;
  369. #ifndef PORT_OVERRIDE
  370. break;
  371. }
  372. if (i == ARRAY_SIZE(ultrastor_ports_14f)) {
  373. # if (ULTRASTOR_DEBUG & UD_DETECT)
  374. printk("US14F: detect: no port address found!\n");
  375. # endif
  376. /* all ports probed already released - we can just go straight out */
  377. return FALSE;
  378. }
  379. #endif
  380. #if (ULTRASTOR_DEBUG & UD_DETECT)
  381. printk("US14F: detect: adapter found at port address %03X\n",
  382. config.port_address);
  383. #endif
  384. /* Set local doorbell mask to disallow bus reset unless
  385. ultrastor_bus_reset is true. */
  386. outb(ultrastor_bus_reset ? 0xc2 : 0x82, LCL_DOORBELL_MASK(config.port_address));
  387. /* All above tests passed, must be the right thing. Get some useful
  388. info. */
  389. /* Register the I/O space that we use */
  390. *(char *)&config_1 = inb(CONFIG(config.port_address + 0));
  391. *(char *)&config_2 = inb(CONFIG(config.port_address + 1));
  392. config.bios_segment = bios_segment_table[config_1.bios_segment];
  393. config.doorbell_address = config.port_address;
  394. config.ogm_address = config.port_address + 0x8;
  395. config.icm_address = config.port_address + 0xC;
  396. config.interrupt = interrupt_table_14f[config_1.interrupt];
  397. config.ha_scsi_id = config_2.ha_scsi_id;
  398. config.heads = mapping_table[config_2.mapping_mode].heads;
  399. config.sectors = mapping_table[config_2.mapping_mode].sectors;
  400. config.bios_drive_number = config_2.bios_drive_number;
  401. config.subversion = (version_byte & 0x0F);
  402. if (config.subversion == U34F)
  403. config.dma_channel = 0;
  404. else
  405. config.dma_channel = dma_channel_table_14f[config_1.dma_channel];
  406. if (!config.bios_segment) {
  407. #if (ULTRASTOR_DEBUG & UD_DETECT)
  408. printk("US14F: detect: not detected.\n");
  409. #endif
  410. goto out_release_port;
  411. }
  412. /* Final consistency check, verify previous info. */
  413. if (config.subversion != U34F)
  414. if (!config.dma_channel || !(config_2.tfr_port & 0x2)) {
  415. #if (ULTRASTOR_DEBUG & UD_DETECT)
  416. printk("US14F: detect: consistency check failed\n");
  417. #endif
  418. goto out_release_port;
  419. }
  420. /* If we were TRULY paranoid, we could issue a host adapter inquiry
  421. command here and verify the data returned. But frankly, I'm
  422. exhausted! */
  423. /* Finally! Now I'm satisfied... */
  424. #if (ULTRASTOR_DEBUG & UD_DETECT)
  425. printk("US14F: detect: detect succeeded\n"
  426. " Port address: %03X\n"
  427. " BIOS segment: %05X\n"
  428. " Interrupt: %u\n"
  429. " DMA channel: %u\n"
  430. " H/A SCSI ID: %u\n"
  431. " Subversion: %u\n",
  432. config.port_address, config.bios_segment, config.interrupt,
  433. config.dma_channel, config.ha_scsi_id, config.subversion);
  434. #endif
  435. tpnt->this_id = config.ha_scsi_id;
  436. tpnt->unchecked_isa_dma = (config.subversion != U34F);
  437. #if ULTRASTOR_MAX_CMDS > 1
  438. config.mscp_free = ~0;
  439. #endif
  440. /*
  441. * Brrr, &config.mscp[0].SCint->host) it is something magical....
  442. * XXX and FIXME
  443. */
  444. if (request_irq(config.interrupt, do_ultrastor_interrupt, 0, "Ultrastor", &config.mscp[0].SCint->device->host)) {
  445. printk("Unable to allocate IRQ%u for UltraStor controller.\n",
  446. config.interrupt);
  447. goto out_release_port;
  448. }
  449. if (config.dma_channel && request_dma(config.dma_channel,"Ultrastor")) {
  450. printk("Unable to allocate DMA channel %u for UltraStor controller.\n",
  451. config.dma_channel);
  452. free_irq(config.interrupt, NULL);
  453. goto out_release_port;
  454. }
  455. tpnt->sg_tablesize = ULTRASTOR_14F_MAX_SG;
  456. printk("UltraStor driver version" VERSION ". Using %d SG lists.\n",
  457. ULTRASTOR_14F_MAX_SG);
  458. return TRUE;
  459. out_release_port:
  460. release_region(config.port_address, 0x0c);
  461. return FALSE;
  462. }
  463. static int ultrastor_24f_detect(struct scsi_host_template * tpnt)
  464. {
  465. int i;
  466. struct Scsi_Host * shpnt = NULL;
  467. #if (ULTRASTOR_DEBUG & UD_DETECT)
  468. printk("US24F: detect");
  469. #endif
  470. /* probe each EISA slot at slot address C80 */
  471. for (i = 1; i < 15; i++)
  472. {
  473. unsigned char config_1, config_2;
  474. unsigned short addr = (i << 12) | ULTRASTOR_24F_PORT;
  475. if (inb(addr) != US24F_PRODUCT_ID_0 &&
  476. inb(addr+1) != US24F_PRODUCT_ID_1 &&
  477. inb(addr+2) != US24F_PRODUCT_ID_2)
  478. continue;
  479. config.revision = inb(addr+3);
  480. config.slot = i;
  481. if (! (inb(addr+4) & 1))
  482. {
  483. #if (ULTRASTOR_DEBUG & UD_DETECT)
  484. printk("U24F: found disabled card in slot %u\n", i);
  485. #endif
  486. continue;
  487. }
  488. #if (ULTRASTOR_DEBUG & UD_DETECT)
  489. printk("U24F: found card in slot %u\n", i);
  490. #endif
  491. config_1 = inb(addr + 5);
  492. config.bios_segment = bios_segment_table[config_1 & 7];
  493. switch(config_1 >> 4)
  494. {
  495. case 1:
  496. config.interrupt = 15;
  497. break;
  498. case 2:
  499. config.interrupt = 14;
  500. break;
  501. case 4:
  502. config.interrupt = 11;
  503. break;
  504. case 8:
  505. config.interrupt = 10;
  506. break;
  507. default:
  508. printk("U24F: invalid IRQ\n");
  509. return FALSE;
  510. }
  511. /* BIOS addr set */
  512. /* base port set */
  513. config.port_address = addr;
  514. config.doorbell_address = addr + 12;
  515. config.ogm_address = addr + 0x17;
  516. config.icm_address = addr + 0x1C;
  517. config_2 = inb(addr + 7);
  518. config.ha_scsi_id = config_2 & 7;
  519. config.heads = mapping_table[(config_2 >> 3) & 3].heads;
  520. config.sectors = mapping_table[(config_2 >> 3) & 3].sectors;
  521. #if (ULTRASTOR_DEBUG & UD_DETECT)
  522. printk("US24F: detect: detect succeeded\n"
  523. " Port address: %03X\n"
  524. " BIOS segment: %05X\n"
  525. " Interrupt: %u\n"
  526. " H/A SCSI ID: %u\n",
  527. config.port_address, config.bios_segment,
  528. config.interrupt, config.ha_scsi_id);
  529. #endif
  530. tpnt->this_id = config.ha_scsi_id;
  531. tpnt->unchecked_isa_dma = 0;
  532. tpnt->sg_tablesize = ULTRASTOR_24F_MAX_SG;
  533. shpnt = scsi_register(tpnt, 0);
  534. if (!shpnt) {
  535. printk(KERN_WARNING "(ultrastor:) Could not register scsi device. Aborting registration.\n");
  536. free_irq(config.interrupt, do_ultrastor_interrupt);
  537. return FALSE;
  538. }
  539. if (request_irq(config.interrupt, do_ultrastor_interrupt, 0, "Ultrastor", shpnt))
  540. {
  541. printk("Unable to allocate IRQ%u for UltraStor controller.\n",
  542. config.interrupt);
  543. return FALSE;
  544. }
  545. shpnt->irq = config.interrupt;
  546. shpnt->dma_channel = config.dma_channel;
  547. shpnt->io_port = config.port_address;
  548. #if ULTRASTOR_MAX_CMDS > 1
  549. config.mscp_free = ~0;
  550. #endif
  551. /* Mark ICM and OGM free */
  552. outb(0, addr + 0x16);
  553. outb(0, addr + 0x1B);
  554. /* Set local doorbell mask to disallow bus reset unless
  555. ultrastor_bus_reset is true. */
  556. outb(ultrastor_bus_reset ? 0xc2 : 0x82, LCL_DOORBELL_MASK(addr+12));
  557. outb(0x02, SYS_DOORBELL_MASK(addr+12));
  558. printk("UltraStor driver version " VERSION ". Using %d SG lists.\n",
  559. tpnt->sg_tablesize);
  560. return TRUE;
  561. }
  562. return FALSE;
  563. }
  564. static int ultrastor_detect(struct scsi_host_template * tpnt)
  565. {
  566. tpnt->proc_name = "ultrastor";
  567. return ultrastor_14f_detect(tpnt) || ultrastor_24f_detect(tpnt);
  568. }
  569. static int ultrastor_release(struct Scsi_Host *shost)
  570. {
  571. if (shost->irq)
  572. free_irq(shost->irq, NULL);
  573. if (shost->dma_channel != 0xff)
  574. free_dma(shost->dma_channel);
  575. if (shost->io_port && shost->n_io_port)
  576. release_region(shost->io_port, shost->n_io_port);
  577. scsi_unregister(shost);
  578. return 0;
  579. }
  580. static const char *ultrastor_info(struct Scsi_Host * shpnt)
  581. {
  582. static char buf[64];
  583. if (config.slot)
  584. sprintf(buf, "UltraStor 24F SCSI @ Slot %u IRQ%u",
  585. config.slot, config.interrupt);
  586. else if (config.subversion)
  587. sprintf(buf, "UltraStor 34F SCSI @ Port %03X BIOS %05X IRQ%u",
  588. config.port_address, (int)config.bios_segment,
  589. config.interrupt);
  590. else
  591. sprintf(buf, "UltraStor 14F SCSI @ Port %03X BIOS %05X IRQ%u DMA%u",
  592. config.port_address, (int)config.bios_segment,
  593. config.interrupt, config.dma_channel);
  594. return buf;
  595. }
  596. static inline void build_sg_list(struct mscp *mscp, struct scsi_cmnd *SCpnt)
  597. {
  598. struct scatterlist *sg;
  599. long transfer_length = 0;
  600. int i, max;
  601. max = scsi_sg_count(SCpnt);
  602. scsi_for_each_sg(SCpnt, sg, max, i) {
  603. mscp->sglist[i].address = isa_page_to_bus(sg_page(sg)) + sg->offset;
  604. mscp->sglist[i].num_bytes = sg->length;
  605. transfer_length += sg->length;
  606. }
  607. mscp->number_of_sg_list = max;
  608. mscp->transfer_data = isa_virt_to_bus(mscp->sglist);
  609. /* ??? May not be necessary. Docs are unclear as to whether transfer
  610. length field is ignored or whether it should be set to the total
  611. number of bytes of the transfer. */
  612. mscp->transfer_data_length = transfer_length;
  613. }
  614. static int ultrastor_queuecommand_lck(struct scsi_cmnd *SCpnt,
  615. void (*done) (struct scsi_cmnd *))
  616. {
  617. struct mscp *my_mscp;
  618. #if ULTRASTOR_MAX_CMDS > 1
  619. int mscp_index;
  620. #endif
  621. unsigned int status;
  622. /* Next test is for debugging; "can't happen" */
  623. if ((config.mscp_free & ((1U << ULTRASTOR_MAX_CMDS) - 1)) == 0)
  624. panic("ultrastor_queuecommand: no free MSCP\n");
  625. mscp_index = find_and_clear_bit_16(&config.mscp_free);
  626. /* Has the command been aborted? */
  627. if (xchgb(0xff, &config.aborted[mscp_index]) != 0)
  628. {
  629. status = DID_ABORT << 16;
  630. goto aborted;
  631. }
  632. my_mscp = &config.mscp[mscp_index];
  633. *(unsigned char *)my_mscp = OP_SCSI | (DTD_SCSI << 3);
  634. /* Tape drives don't work properly if the cache is used. The SCSI
  635. READ command for a tape doesn't have a block offset, and the adapter
  636. incorrectly assumes that all reads from the tape read the same
  637. blocks. Results will depend on read buffer size and other disk
  638. activity.
  639. ??? Which other device types should never use the cache? */
  640. my_mscp->ca = SCpnt->device->type != TYPE_TAPE;
  641. my_mscp->target_id = SCpnt->device->id;
  642. my_mscp->ch_no = 0;
  643. my_mscp->lun = SCpnt->device->lun;
  644. if (scsi_sg_count(SCpnt)) {
  645. /* Set scatter/gather flag in SCSI command packet */
  646. my_mscp->sg = TRUE;
  647. build_sg_list(my_mscp, SCpnt);
  648. } else {
  649. /* Unset scatter/gather flag in SCSI command packet */
  650. my_mscp->sg = FALSE;
  651. my_mscp->transfer_data = isa_virt_to_bus(scsi_sglist(SCpnt));
  652. my_mscp->transfer_data_length = scsi_bufflen(SCpnt);
  653. }
  654. my_mscp->command_link = 0; /*???*/
  655. my_mscp->scsi_command_link_id = 0; /*???*/
  656. my_mscp->length_of_sense_byte = SCSI_SENSE_BUFFERSIZE;
  657. my_mscp->length_of_scsi_cdbs = SCpnt->cmd_len;
  658. memcpy(my_mscp->scsi_cdbs, SCpnt->cmnd, my_mscp->length_of_scsi_cdbs);
  659. my_mscp->adapter_status = 0;
  660. my_mscp->target_status = 0;
  661. my_mscp->sense_data = isa_virt_to_bus(&SCpnt->sense_buffer);
  662. my_mscp->done = done;
  663. my_mscp->SCint = SCpnt;
  664. SCpnt->host_scribble = (unsigned char *)my_mscp;
  665. /* Find free OGM slot. On 24F, look for OGM status byte == 0.
  666. On 14F and 34F, wait for local interrupt pending flag to clear.
  667. FIXME: now we are using new_eh we should punt here and let the
  668. midlayer sort it out */
  669. retry:
  670. if (config.slot)
  671. while (inb(config.ogm_address - 1) != 0 && config.aborted[mscp_index] == 0xff)
  672. barrier();
  673. /* else??? */
  674. while ((inb(LCL_DOORBELL_INTR(config.doorbell_address)) & (config.slot ? 2 : 1)) && config.aborted[mscp_index] == 0xff)
  675. barrier();
  676. /* To avoid race conditions, keep the code to write to the adapter
  677. atomic. This simplifies the abort code. Right now the
  678. scsi mid layer has the host_lock already held
  679. */
  680. if (inb(LCL_DOORBELL_INTR(config.doorbell_address)) & (config.slot ? 2 : 1))
  681. goto retry;
  682. status = xchgb(0, &config.aborted[mscp_index]);
  683. if (status != 0xff) {
  684. #if ULTRASTOR_DEBUG & (UD_COMMAND | UD_ABORT)
  685. printk("USx4F: queuecommand: aborted\n");
  686. #if ULTRASTOR_MAX_CMDS > 1
  687. log_ultrastor_abort(&config, mscp_index);
  688. #endif
  689. #endif
  690. status <<= 16;
  691. aborted:
  692. set_bit(mscp_index, &config.mscp_free);
  693. /* If the driver queues commands, call the done proc here. Otherwise
  694. return an error. */
  695. #if ULTRASTOR_MAX_CMDS > 1
  696. SCpnt->result = status;
  697. done(SCpnt);
  698. return 0;
  699. #else
  700. return status;
  701. #endif
  702. }
  703. /* Store pointer in OGM address bytes */
  704. outl(isa_virt_to_bus(my_mscp), config.ogm_address);
  705. /* Issue OGM interrupt */
  706. if (config.slot) {
  707. /* Write OGM command register on 24F */
  708. outb(1, config.ogm_address - 1);
  709. outb(0x2, LCL_DOORBELL_INTR(config.doorbell_address));
  710. } else {
  711. outb(0x1, LCL_DOORBELL_INTR(config.doorbell_address));
  712. }
  713. #if (ULTRASTOR_DEBUG & UD_COMMAND)
  714. printk("USx4F: queuecommand: returning\n");
  715. #endif
  716. return 0;
  717. }
  718. static DEF_SCSI_QCMD(ultrastor_queuecommand)
  719. /* This code must deal with 2 cases:
  720. 1. The command has not been written to the OGM. In this case, set
  721. the abort flag and return.
  722. 2. The command has been written to the OGM and is stuck somewhere in
  723. the adapter.
  724. 2a. On a 24F, ask the adapter to abort the command. It will interrupt
  725. when it does.
  726. 2b. Call the command's done procedure.
  727. */
  728. static int ultrastor_abort(struct scsi_cmnd *SCpnt)
  729. {
  730. #if ULTRASTOR_DEBUG & UD_ABORT
  731. char out[108];
  732. unsigned char icm_status = 0, ogm_status = 0;
  733. unsigned int icm_addr = 0, ogm_addr = 0;
  734. #endif
  735. unsigned int mscp_index;
  736. unsigned char old_aborted;
  737. unsigned long flags;
  738. void (*done)(struct scsi_cmnd *);
  739. struct Scsi_Host *host = SCpnt->device->host;
  740. if(config.slot)
  741. return FAILED; /* Do not attempt an abort for the 24f */
  742. /* Simple consistency checking */
  743. if(!SCpnt->host_scribble)
  744. return FAILED;
  745. mscp_index = ((struct mscp *)SCpnt->host_scribble) - config.mscp;
  746. if (mscp_index >= ULTRASTOR_MAX_CMDS)
  747. panic("Ux4F aborting invalid MSCP");
  748. #if ULTRASTOR_DEBUG & UD_ABORT
  749. if (config.slot)
  750. {
  751. int port0 = (config.slot << 12) | 0xc80;
  752. int i;
  753. unsigned long flags;
  754. spin_lock_irqsave(host->host_lock, flags);
  755. strcpy(out, "OGM %d:%x ICM %d:%x ports: ");
  756. for (i = 0; i < 16; i++)
  757. {
  758. unsigned char p = inb(port0 + i);
  759. out[28 + i * 3] = "0123456789abcdef"[p >> 4];
  760. out[29 + i * 3] = "0123456789abcdef"[p & 15];
  761. out[30 + i * 3] = ' ';
  762. }
  763. out[28 + i * 3] = '\n';
  764. out[29 + i * 3] = 0;
  765. ogm_status = inb(port0 + 22);
  766. ogm_addr = (unsigned int)isa_bus_to_virt(inl(port0 + 23));
  767. icm_status = inb(port0 + 27);
  768. icm_addr = (unsigned int)isa_bus_to_virt(inl(port0 + 28));
  769. spin_unlock_irqrestore(host->host_lock, flags);
  770. }
  771. /* First check to see if an interrupt is pending. I suspect the SiS
  772. chipset loses interrupts. (I also suspect is mangles data, but
  773. one bug at a time... */
  774. if (config.slot ? inb(config.icm_address - 1) == 2 :
  775. (inb(SYS_DOORBELL_INTR(config.doorbell_address)) & 1))
  776. {
  777. printk("Ux4F: abort while completed command pending\n");
  778. spin_lock_irqsave(host->host_lock, flags);
  779. /* FIXME: Ewww... need to think about passing host around properly */
  780. ultrastor_interrupt(NULL);
  781. spin_unlock_irqrestore(host->host_lock, flags);
  782. return SUCCESS;
  783. }
  784. #endif
  785. old_aborted = xchgb(DID_ABORT, &config.aborted[mscp_index]);
  786. /* aborted == 0xff is the signal that queuecommand has not yet sent
  787. the command. It will notice the new abort flag and fail. */
  788. if (old_aborted == 0xff)
  789. return SUCCESS;
  790. /* On 24F, send an abort MSCP request. The adapter will interrupt
  791. and the interrupt handler will call done. */
  792. if (config.slot && inb(config.ogm_address - 1) == 0)
  793. {
  794. unsigned long flags;
  795. spin_lock_irqsave(host->host_lock, flags);
  796. outl(isa_virt_to_bus(&config.mscp[mscp_index]), config.ogm_address);
  797. udelay(8);
  798. outb(0x80, config.ogm_address - 1);
  799. outb(0x2, LCL_DOORBELL_INTR(config.doorbell_address));
  800. #if ULTRASTOR_DEBUG & UD_ABORT
  801. log_ultrastor_abort(&config, mscp_index);
  802. printk(out, ogm_status, ogm_addr, icm_status, icm_addr);
  803. #endif
  804. spin_unlock_irqrestore(host->host_lock, flags);
  805. /* FIXME: add a wait for the abort to complete */
  806. return SUCCESS;
  807. }
  808. #if ULTRASTOR_DEBUG & UD_ABORT
  809. log_ultrastor_abort(&config, mscp_index);
  810. #endif
  811. /* Can't request a graceful abort. Either this is not a 24F or
  812. the OGM is busy. Don't free the command -- the adapter might
  813. still be using it. Setting SCint = 0 causes the interrupt
  814. handler to ignore the command. */
  815. /* FIXME - devices that implement soft resets will still be running
  816. the command after a bus reset. We would probably rather leave
  817. the command in the queue. The upper level code will automatically
  818. leave the command in the active state instead of requeueing it. ERY */
  819. #if ULTRASTOR_DEBUG & UD_ABORT
  820. if (config.mscp[mscp_index].SCint != SCpnt)
  821. printk("abort: command mismatch, %p != %p\n",
  822. config.mscp[mscp_index].SCint, SCpnt);
  823. #endif
  824. if (config.mscp[mscp_index].SCint == NULL)
  825. return FAILED;
  826. if (config.mscp[mscp_index].SCint != SCpnt) panic("Bad abort");
  827. config.mscp[mscp_index].SCint = NULL;
  828. done = config.mscp[mscp_index].done;
  829. config.mscp[mscp_index].done = NULL;
  830. SCpnt->result = DID_ABORT << 16;
  831. /* Take the host lock to guard against scsi layer re-entry */
  832. done(SCpnt);
  833. /* Need to set a timeout here in case command never completes. */
  834. return SUCCESS;
  835. }
  836. static int ultrastor_host_reset(struct scsi_cmnd * SCpnt)
  837. {
  838. unsigned long flags;
  839. int i;
  840. struct Scsi_Host *host = SCpnt->device->host;
  841. #if (ULTRASTOR_DEBUG & UD_RESET)
  842. printk("US14F: reset: called\n");
  843. #endif
  844. if(config.slot)
  845. return FAILED;
  846. spin_lock_irqsave(host->host_lock, flags);
  847. /* Reset the adapter and SCSI bus. The SCSI bus reset can be
  848. inhibited by clearing ultrastor_bus_reset before probe. */
  849. outb(0xc0, LCL_DOORBELL_INTR(config.doorbell_address));
  850. if (config.slot)
  851. {
  852. outb(0, config.ogm_address - 1);
  853. outb(0, config.icm_address - 1);
  854. }
  855. #if ULTRASTOR_MAX_CMDS == 1
  856. if (config.mscp_busy && config.mscp->done && config.mscp->SCint)
  857. {
  858. config.mscp->SCint->result = DID_RESET << 16;
  859. config.mscp->done(config.mscp->SCint);
  860. }
  861. config.mscp->SCint = 0;
  862. #else
  863. for (i = 0; i < ULTRASTOR_MAX_CMDS; i++)
  864. {
  865. if (! (config.mscp_free & (1 << i)) &&
  866. config.mscp[i].done && config.mscp[i].SCint)
  867. {
  868. config.mscp[i].SCint->result = DID_RESET << 16;
  869. config.mscp[i].done(config.mscp[i].SCint);
  870. config.mscp[i].done = NULL;
  871. }
  872. config.mscp[i].SCint = NULL;
  873. }
  874. #endif
  875. /* FIXME - if the device implements soft resets, then the command
  876. will still be running. ERY
  877. Even bigger deal with new_eh!
  878. */
  879. memset((unsigned char *)config.aborted, 0, sizeof config.aborted);
  880. #if ULTRASTOR_MAX_CMDS == 1
  881. config.mscp_busy = 0;
  882. #else
  883. config.mscp_free = ~0;
  884. #endif
  885. spin_unlock_irqrestore(host->host_lock, flags);
  886. return SUCCESS;
  887. }
  888. int ultrastor_biosparam(struct scsi_device *sdev, struct block_device *bdev,
  889. sector_t capacity, int * dkinfo)
  890. {
  891. int size = capacity;
  892. unsigned int s = config.heads * config.sectors;
  893. dkinfo[0] = config.heads;
  894. dkinfo[1] = config.sectors;
  895. dkinfo[2] = size / s; /* Ignore partial cylinders */
  896. #if 0
  897. if (dkinfo[2] > 1024)
  898. dkinfo[2] = 1024;
  899. #endif
  900. return 0;
  901. }
  902. static void ultrastor_interrupt(void *dev_id)
  903. {
  904. unsigned int status;
  905. #if ULTRASTOR_MAX_CMDS > 1
  906. unsigned int mscp_index;
  907. #endif
  908. struct mscp *mscp;
  909. void (*done) (struct scsi_cmnd *);
  910. struct scsi_cmnd *SCtmp;
  911. #if ULTRASTOR_MAX_CMDS == 1
  912. mscp = &config.mscp[0];
  913. #else
  914. mscp = (struct mscp *)isa_bus_to_virt(inl(config.icm_address));
  915. mscp_index = mscp - config.mscp;
  916. if (mscp_index >= ULTRASTOR_MAX_CMDS) {
  917. printk("Ux4F interrupt: bad MSCP address %x\n", (unsigned int) mscp);
  918. /* A command has been lost. Reset and report an error
  919. for all commands. */
  920. ultrastor_host_reset(dev_id);
  921. return;
  922. }
  923. #endif
  924. /* Clean ICM slot (set ICMINT bit to 0) */
  925. if (config.slot) {
  926. unsigned char icm_status = inb(config.icm_address - 1);
  927. #if ULTRASTOR_DEBUG & (UD_INTERRUPT|UD_ERROR|UD_ABORT)
  928. if (icm_status != 1 && icm_status != 2)
  929. printk("US24F: ICM status %x for MSCP %d (%x)\n", icm_status,
  930. mscp_index, (unsigned int) mscp);
  931. #endif
  932. /* The manual says clear interrupt then write 0 to ICM status.
  933. This seems backwards, but I'll do it anyway. --jfc */
  934. outb(2, SYS_DOORBELL_INTR(config.doorbell_address));
  935. outb(0, config.icm_address - 1);
  936. if (icm_status == 4) {
  937. printk("UltraStor abort command failed\n");
  938. return;
  939. }
  940. if (icm_status == 3) {
  941. void (*done)(struct scsi_cmnd *) = mscp->done;
  942. if (done) {
  943. mscp->done = NULL;
  944. mscp->SCint->result = DID_ABORT << 16;
  945. done(mscp->SCint);
  946. }
  947. return;
  948. }
  949. } else {
  950. outb(1, SYS_DOORBELL_INTR(config.doorbell_address));
  951. }
  952. SCtmp = mscp->SCint;
  953. mscp->SCint = NULL;
  954. if (!SCtmp)
  955. {
  956. #if ULTRASTOR_DEBUG & (UD_ABORT|UD_INTERRUPT)
  957. printk("MSCP %d (%x): no command\n", mscp_index, (unsigned int) mscp);
  958. #endif
  959. #if ULTRASTOR_MAX_CMDS == 1
  960. config.mscp_busy = FALSE;
  961. #else
  962. set_bit(mscp_index, &config.mscp_free);
  963. #endif
  964. config.aborted[mscp_index] = 0;
  965. return;
  966. }
  967. /* Save done locally and zero before calling. This is needed as
  968. once we call done, we may get another command queued before this
  969. interrupt service routine can return. */
  970. done = mscp->done;
  971. mscp->done = NULL;
  972. /* Let the higher levels know that we're done */
  973. switch (mscp->adapter_status)
  974. {
  975. case 0:
  976. status = DID_OK << 16;
  977. break;
  978. case 0x01: /* invalid command */
  979. case 0x02: /* invalid parameters */
  980. case 0x03: /* invalid data list */
  981. default:
  982. status = DID_ERROR << 16;
  983. break;
  984. case 0x84: /* SCSI bus abort */
  985. status = DID_ABORT << 16;
  986. break;
  987. case 0x91:
  988. status = DID_TIME_OUT << 16;
  989. break;
  990. }
  991. SCtmp->result = status | mscp->target_status;
  992. SCtmp->host_scribble = NULL;
  993. /* Free up mscp block for next command */
  994. #if ULTRASTOR_MAX_CMDS == 1
  995. config.mscp_busy = FALSE;
  996. #else
  997. set_bit(mscp_index, &config.mscp_free);
  998. #endif
  999. #if ULTRASTOR_DEBUG & (UD_ABORT|UD_INTERRUPT)
  1000. if (config.aborted[mscp_index])
  1001. printk("Ux4 interrupt: MSCP %d (%x) aborted = %d\n",
  1002. mscp_index, (unsigned int) mscp, config.aborted[mscp_index]);
  1003. #endif
  1004. config.aborted[mscp_index] = 0;
  1005. if (done)
  1006. done(SCtmp);
  1007. else
  1008. printk("US14F: interrupt: unexpected interrupt\n");
  1009. if (config.slot ? inb(config.icm_address - 1) :
  1010. (inb(SYS_DOORBELL_INTR(config.doorbell_address)) & 1))
  1011. #if (ULTRASTOR_DEBUG & UD_MULTI_CMD)
  1012. printk("Ux4F: multiple commands completed\n");
  1013. #else
  1014. ;
  1015. #endif
  1016. #if (ULTRASTOR_DEBUG & UD_INTERRUPT)
  1017. printk("USx4F: interrupt: returning\n");
  1018. #endif
  1019. }
  1020. static irqreturn_t do_ultrastor_interrupt(int irq, void *dev_id)
  1021. {
  1022. unsigned long flags;
  1023. struct Scsi_Host *dev = dev_id;
  1024. spin_lock_irqsave(dev->host_lock, flags);
  1025. ultrastor_interrupt(dev_id);
  1026. spin_unlock_irqrestore(dev->host_lock, flags);
  1027. return IRQ_HANDLED;
  1028. }
  1029. MODULE_LICENSE("GPL");
  1030. static struct scsi_host_template driver_template = {
  1031. .name = "UltraStor 14F/24F/34F",
  1032. .detect = ultrastor_detect,
  1033. .release = ultrastor_release,
  1034. .info = ultrastor_info,
  1035. .queuecommand = ultrastor_queuecommand,
  1036. .eh_abort_handler = ultrastor_abort,
  1037. .eh_host_reset_handler = ultrastor_host_reset,
  1038. .bios_param = ultrastor_biosparam,
  1039. .can_queue = ULTRASTOR_MAX_CMDS,
  1040. .sg_tablesize = ULTRASTOR_14F_MAX_SG,
  1041. .cmd_per_lun = ULTRASTOR_MAX_CMDS_PER_LUN,
  1042. .unchecked_isa_dma = 1,
  1043. .use_clustering = ENABLE_CLUSTERING,
  1044. };
  1045. #include "scsi_module.c"