wd33c93.c 65 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210
  1. /*
  2. * Copyright (c) 1996 John Shifflett, GeoLog Consulting
  3. * john@geolog.com
  4. * jshiffle@netcom.com
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2, or (at your option)
  9. * any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. */
  16. /*
  17. * Drew Eckhardt's excellent 'Generic NCR5380' sources from Linux-PC
  18. * provided much of the inspiration and some of the code for this
  19. * driver. Everything I know about Amiga DMA was gleaned from careful
  20. * reading of Hamish Mcdonald's original wd33c93 driver; in fact, I
  21. * borrowed shamelessly from all over that source. Thanks Hamish!
  22. *
  23. * _This_ driver is (I feel) an improvement over the old one in
  24. * several respects:
  25. *
  26. * - Target Disconnection/Reconnection is now supported. Any
  27. * system with more than one device active on the SCSI bus
  28. * will benefit from this. The driver defaults to what I
  29. * call 'adaptive disconnect' - meaning that each command
  30. * is evaluated individually as to whether or not it should
  31. * be run with the option to disconnect/reselect (if the
  32. * device chooses), or as a "SCSI-bus-hog".
  33. *
  34. * - Synchronous data transfers are now supported. Because of
  35. * a few devices that choke after telling the driver that
  36. * they can do sync transfers, we don't automatically use
  37. * this faster protocol - it can be enabled via the command-
  38. * line on a device-by-device basis.
  39. *
  40. * - Runtime operating parameters can now be specified through
  41. * the 'amiboot' or the 'insmod' command line. For amiboot do:
  42. * "amiboot [usual stuff] wd33c93=blah,blah,blah"
  43. * The defaults should be good for most people. See the comment
  44. * for 'setup_strings' below for more details.
  45. *
  46. * - The old driver relied exclusively on what the Western Digital
  47. * docs call "Combination Level 2 Commands", which are a great
  48. * idea in that the CPU is relieved of a lot of interrupt
  49. * overhead. However, by accepting a certain (user-settable)
  50. * amount of additional interrupts, this driver achieves
  51. * better control over the SCSI bus, and data transfers are
  52. * almost as fast while being much easier to define, track,
  53. * and debug.
  54. *
  55. *
  56. * TODO:
  57. * more speed. linked commands.
  58. *
  59. *
  60. * People with bug reports, wish-lists, complaints, comments,
  61. * or improvements are asked to pah-leeez email me (John Shifflett)
  62. * at john@geolog.com or jshiffle@netcom.com! I'm anxious to get
  63. * this thing into as good a shape as possible, and I'm positive
  64. * there are lots of lurking bugs and "Stupid Places".
  65. *
  66. * Updates:
  67. *
  68. * Added support for pre -A chips, which don't have advanced features
  69. * and will generate CSR_RESEL rather than CSR_RESEL_AM.
  70. * Richard Hirst <richard@sleepie.demon.co.uk> August 2000
  71. *
  72. * Added support for Burst Mode DMA and Fast SCSI. Enabled the use of
  73. * default_sx_per for asynchronous data transfers. Added adjustment
  74. * of transfer periods in sx_table to the actual input-clock.
  75. * peter fuerst <post@pfrst.de> February 2007
  76. */
  77. #include <linux/module.h>
  78. #include <linux/string.h>
  79. #include <linux/delay.h>
  80. #include <linux/init.h>
  81. #include <linux/interrupt.h>
  82. #include <linux/blkdev.h>
  83. #include <scsi/scsi.h>
  84. #include <scsi/scsi_cmnd.h>
  85. #include <scsi/scsi_device.h>
  86. #include <scsi/scsi_host.h>
  87. #include <asm/irq.h>
  88. #include "wd33c93.h"
  89. #define optimum_sx_per(hostdata) (hostdata)->sx_table[1].period_ns
  90. #define WD33C93_VERSION "1.26++"
  91. #define WD33C93_DATE "10/Feb/2007"
  92. MODULE_AUTHOR("John Shifflett");
  93. MODULE_DESCRIPTION("Generic WD33C93 SCSI driver");
  94. MODULE_LICENSE("GPL");
  95. /*
  96. * 'setup_strings' is a single string used to pass operating parameters and
  97. * settings from the kernel/module command-line to the driver. 'setup_args[]'
  98. * is an array of strings that define the compile-time default values for
  99. * these settings. If Linux boots with an amiboot or insmod command-line,
  100. * those settings are combined with 'setup_args[]'. Note that amiboot
  101. * command-lines are prefixed with "wd33c93=" while insmod uses a
  102. * "setup_strings=" prefix. The driver recognizes the following keywords
  103. * (lower case required) and arguments:
  104. *
  105. * - nosync:bitmask -bitmask is a byte where the 1st 7 bits correspond with
  106. * the 7 possible SCSI devices. Set a bit to negotiate for
  107. * asynchronous transfers on that device. To maintain
  108. * backwards compatibility, a command-line such as
  109. * "wd33c93=255" will be automatically translated to
  110. * "wd33c93=nosync:0xff".
  111. * - nodma:x -x = 1 to disable DMA, x = 0 to enable it. Argument is
  112. * optional - if not present, same as "nodma:1".
  113. * - period:ns -ns is the minimum # of nanoseconds in a SCSI data transfer
  114. * period. Default is 500; acceptable values are 250 - 1000.
  115. * - disconnect:x -x = 0 to never allow disconnects, 2 to always allow them.
  116. * x = 1 does 'adaptive' disconnects, which is the default
  117. * and generally the best choice.
  118. * - debug:x -If 'DEBUGGING_ON' is defined, x is a bit mask that causes
  119. * various types of debug output to printed - see the DB_xxx
  120. * defines in wd33c93.h
  121. * - clock:x -x = clock input in MHz for WD33c93 chip. Normal values
  122. * would be from 8 through 20. Default is 8.
  123. * - burst:x -x = 1 to use Burst Mode (or Demand-Mode) DMA, x = 0 to use
  124. * Single Byte DMA, which is the default. Argument is
  125. * optional - if not present, same as "burst:1".
  126. * - fast:x -x = 1 to enable Fast SCSI, which is only effective with
  127. * input-clock divisor 4 (WD33C93_FS_16_20), x = 0 to disable
  128. * it, which is the default. Argument is optional - if not
  129. * present, same as "fast:1".
  130. * - next -No argument. Used to separate blocks of keywords when
  131. * there's more than one host adapter in the system.
  132. *
  133. * Syntax Notes:
  134. * - Numeric arguments can be decimal or the '0x' form of hex notation. There
  135. * _must_ be a colon between a keyword and its numeric argument, with no
  136. * spaces.
  137. * - Keywords are separated by commas, no spaces, in the standard kernel
  138. * command-line manner.
  139. * - A keyword in the 'nth' comma-separated command-line member will overwrite
  140. * the 'nth' element of setup_args[]. A blank command-line member (in
  141. * other words, a comma with no preceding keyword) will _not_ overwrite
  142. * the corresponding setup_args[] element.
  143. * - If a keyword is used more than once, the first one applies to the first
  144. * SCSI host found, the second to the second card, etc, unless the 'next'
  145. * keyword is used to change the order.
  146. *
  147. * Some amiboot examples (for insmod, use 'setup_strings' instead of 'wd33c93'):
  148. * - wd33c93=nosync:255
  149. * - wd33c93=nodma
  150. * - wd33c93=nodma:1
  151. * - wd33c93=disconnect:2,nosync:0x08,period:250
  152. * - wd33c93=debug:0x1c
  153. */
  154. /* Normally, no defaults are specified */
  155. static char *setup_args[] = { "", "", "", "", "", "", "", "", "", "" };
  156. static char *setup_strings;
  157. module_param(setup_strings, charp, 0);
  158. static void wd33c93_execute(struct Scsi_Host *instance);
  159. #ifdef CONFIG_WD33C93_PIO
  160. static inline uchar
  161. read_wd33c93(const wd33c93_regs regs, uchar reg_num)
  162. {
  163. uchar data;
  164. outb(reg_num, regs.SASR);
  165. data = inb(regs.SCMD);
  166. return data;
  167. }
  168. static inline unsigned long
  169. read_wd33c93_count(const wd33c93_regs regs)
  170. {
  171. unsigned long value;
  172. outb(WD_TRANSFER_COUNT_MSB, regs.SASR);
  173. value = inb(regs.SCMD) << 16;
  174. value |= inb(regs.SCMD) << 8;
  175. value |= inb(regs.SCMD);
  176. return value;
  177. }
  178. static inline uchar
  179. read_aux_stat(const wd33c93_regs regs)
  180. {
  181. return inb(regs.SASR);
  182. }
  183. static inline void
  184. write_wd33c93(const wd33c93_regs regs, uchar reg_num, uchar value)
  185. {
  186. outb(reg_num, regs.SASR);
  187. outb(value, regs.SCMD);
  188. }
  189. static inline void
  190. write_wd33c93_count(const wd33c93_regs regs, unsigned long value)
  191. {
  192. outb(WD_TRANSFER_COUNT_MSB, regs.SASR);
  193. outb((value >> 16) & 0xff, regs.SCMD);
  194. outb((value >> 8) & 0xff, regs.SCMD);
  195. outb( value & 0xff, regs.SCMD);
  196. }
  197. #define write_wd33c93_cmd(regs, cmd) \
  198. write_wd33c93((regs), WD_COMMAND, (cmd))
  199. static inline void
  200. write_wd33c93_cdb(const wd33c93_regs regs, uint len, uchar cmnd[])
  201. {
  202. int i;
  203. outb(WD_CDB_1, regs.SASR);
  204. for (i=0; i<len; i++)
  205. outb(cmnd[i], regs.SCMD);
  206. }
  207. #else /* CONFIG_WD33C93_PIO */
  208. static inline uchar
  209. read_wd33c93(const wd33c93_regs regs, uchar reg_num)
  210. {
  211. *regs.SASR = reg_num;
  212. mb();
  213. return (*regs.SCMD);
  214. }
  215. static unsigned long
  216. read_wd33c93_count(const wd33c93_regs regs)
  217. {
  218. unsigned long value;
  219. *regs.SASR = WD_TRANSFER_COUNT_MSB;
  220. mb();
  221. value = *regs.SCMD << 16;
  222. value |= *regs.SCMD << 8;
  223. value |= *regs.SCMD;
  224. mb();
  225. return value;
  226. }
  227. static inline uchar
  228. read_aux_stat(const wd33c93_regs regs)
  229. {
  230. return *regs.SASR;
  231. }
  232. static inline void
  233. write_wd33c93(const wd33c93_regs regs, uchar reg_num, uchar value)
  234. {
  235. *regs.SASR = reg_num;
  236. mb();
  237. *regs.SCMD = value;
  238. mb();
  239. }
  240. static void
  241. write_wd33c93_count(const wd33c93_regs regs, unsigned long value)
  242. {
  243. *regs.SASR = WD_TRANSFER_COUNT_MSB;
  244. mb();
  245. *regs.SCMD = value >> 16;
  246. *regs.SCMD = value >> 8;
  247. *regs.SCMD = value;
  248. mb();
  249. }
  250. static inline void
  251. write_wd33c93_cmd(const wd33c93_regs regs, uchar cmd)
  252. {
  253. *regs.SASR = WD_COMMAND;
  254. mb();
  255. *regs.SCMD = cmd;
  256. mb();
  257. }
  258. static inline void
  259. write_wd33c93_cdb(const wd33c93_regs regs, uint len, uchar cmnd[])
  260. {
  261. int i;
  262. *regs.SASR = WD_CDB_1;
  263. for (i = 0; i < len; i++)
  264. *regs.SCMD = cmnd[i];
  265. }
  266. #endif /* CONFIG_WD33C93_PIO */
  267. static inline uchar
  268. read_1_byte(const wd33c93_regs regs)
  269. {
  270. uchar asr;
  271. uchar x = 0;
  272. write_wd33c93(regs, WD_CONTROL, CTRL_IDI | CTRL_EDI | CTRL_POLLED);
  273. write_wd33c93_cmd(regs, WD_CMD_TRANS_INFO | 0x80);
  274. do {
  275. asr = read_aux_stat(regs);
  276. if (asr & ASR_DBR)
  277. x = read_wd33c93(regs, WD_DATA);
  278. } while (!(asr & ASR_INT));
  279. return x;
  280. }
  281. static int
  282. round_period(unsigned int period, const struct sx_period *sx_table)
  283. {
  284. int x;
  285. for (x = 1; sx_table[x].period_ns; x++) {
  286. if ((period <= sx_table[x - 0].period_ns) &&
  287. (period > sx_table[x - 1].period_ns)) {
  288. return x;
  289. }
  290. }
  291. return 7;
  292. }
  293. /*
  294. * Calculate Synchronous Transfer Register value from SDTR code.
  295. */
  296. static uchar
  297. calc_sync_xfer(unsigned int period, unsigned int offset, unsigned int fast,
  298. const struct sx_period *sx_table)
  299. {
  300. /* When doing Fast SCSI synchronous data transfers, the corresponding
  301. * value in 'sx_table' is two times the actually used transfer period.
  302. */
  303. uchar result;
  304. if (offset && fast) {
  305. fast = STR_FSS;
  306. period *= 2;
  307. } else {
  308. fast = 0;
  309. }
  310. period *= 4; /* convert SDTR code to ns */
  311. result = sx_table[round_period(period,sx_table)].reg_value;
  312. result |= (offset < OPTIMUM_SX_OFF) ? offset : OPTIMUM_SX_OFF;
  313. result |= fast;
  314. return result;
  315. }
  316. /*
  317. * Calculate SDTR code bytes [3],[4] from period and offset.
  318. */
  319. static inline void
  320. calc_sync_msg(unsigned int period, unsigned int offset, unsigned int fast,
  321. uchar msg[2])
  322. {
  323. /* 'period' is a "normal"-mode value, like the ones in 'sx_table'. The
  324. * actually used transfer period for Fast SCSI synchronous data
  325. * transfers is half that value.
  326. */
  327. period /= 4;
  328. if (offset && fast)
  329. period /= 2;
  330. msg[0] = period;
  331. msg[1] = offset;
  332. }
  333. static int
  334. wd33c93_queuecommand_lck(struct scsi_cmnd *cmd,
  335. void (*done)(struct scsi_cmnd *))
  336. {
  337. struct WD33C93_hostdata *hostdata;
  338. struct scsi_cmnd *tmp;
  339. hostdata = (struct WD33C93_hostdata *) cmd->device->host->hostdata;
  340. DB(DB_QUEUE_COMMAND,
  341. printk("Q-%d-%02x( ", cmd->device->id, cmd->cmnd[0]))
  342. /* Set up a few fields in the scsi_cmnd structure for our own use:
  343. * - host_scribble is the pointer to the next cmd in the input queue
  344. * - scsi_done points to the routine we call when a cmd is finished
  345. * - result is what you'd expect
  346. */
  347. cmd->host_scribble = NULL;
  348. cmd->scsi_done = done;
  349. cmd->result = 0;
  350. /* We use the Scsi_Pointer structure that's included with each command
  351. * as a scratchpad (as it's intended to be used!). The handy thing about
  352. * the SCp.xxx fields is that they're always associated with a given
  353. * cmd, and are preserved across disconnect-reselect. This means we
  354. * can pretty much ignore SAVE_POINTERS and RESTORE_POINTERS messages
  355. * if we keep all the critical pointers and counters in SCp:
  356. * - SCp.ptr is the pointer into the RAM buffer
  357. * - SCp.this_residual is the size of that buffer
  358. * - SCp.buffer points to the current scatter-gather buffer
  359. * - SCp.buffers_residual tells us how many S.G. buffers there are
  360. * - SCp.have_data_in is not used
  361. * - SCp.sent_command is not used
  362. * - SCp.phase records this command's SRCID_ER bit setting
  363. */
  364. if (scsi_bufflen(cmd)) {
  365. cmd->SCp.buffer = scsi_sglist(cmd);
  366. cmd->SCp.buffers_residual = scsi_sg_count(cmd) - 1;
  367. cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
  368. cmd->SCp.this_residual = cmd->SCp.buffer->length;
  369. } else {
  370. cmd->SCp.buffer = NULL;
  371. cmd->SCp.buffers_residual = 0;
  372. cmd->SCp.ptr = NULL;
  373. cmd->SCp.this_residual = 0;
  374. }
  375. /* WD docs state that at the conclusion of a "LEVEL2" command, the
  376. * status byte can be retrieved from the LUN register. Apparently,
  377. * this is the case only for *uninterrupted* LEVEL2 commands! If
  378. * there are any unexpected phases entered, even if they are 100%
  379. * legal (different devices may choose to do things differently),
  380. * the LEVEL2 command sequence is exited. This often occurs prior
  381. * to receiving the status byte, in which case the driver does a
  382. * status phase interrupt and gets the status byte on its own.
  383. * While such a command can then be "resumed" (ie restarted to
  384. * finish up as a LEVEL2 command), the LUN register will NOT be
  385. * a valid status byte at the command's conclusion, and we must
  386. * use the byte obtained during the earlier interrupt. Here, we
  387. * preset SCp.Status to an illegal value (0xff) so that when
  388. * this command finally completes, we can tell where the actual
  389. * status byte is stored.
  390. */
  391. cmd->SCp.Status = ILLEGAL_STATUS_BYTE;
  392. /*
  393. * Add the cmd to the end of 'input_Q'. Note that REQUEST SENSE
  394. * commands are added to the head of the queue so that the desired
  395. * sense data is not lost before REQUEST_SENSE executes.
  396. */
  397. spin_lock_irq(&hostdata->lock);
  398. if (!(hostdata->input_Q) || (cmd->cmnd[0] == REQUEST_SENSE)) {
  399. cmd->host_scribble = (uchar *) hostdata->input_Q;
  400. hostdata->input_Q = cmd;
  401. } else { /* find the end of the queue */
  402. for (tmp = (struct scsi_cmnd *) hostdata->input_Q;
  403. tmp->host_scribble;
  404. tmp = (struct scsi_cmnd *) tmp->host_scribble) ;
  405. tmp->host_scribble = (uchar *) cmd;
  406. }
  407. /* We know that there's at least one command in 'input_Q' now.
  408. * Go see if any of them are runnable!
  409. */
  410. wd33c93_execute(cmd->device->host);
  411. DB(DB_QUEUE_COMMAND, printk(")Q "))
  412. spin_unlock_irq(&hostdata->lock);
  413. return 0;
  414. }
  415. DEF_SCSI_QCMD(wd33c93_queuecommand)
  416. /*
  417. * This routine attempts to start a scsi command. If the host_card is
  418. * already connected, we give up immediately. Otherwise, look through
  419. * the input_Q, using the first command we find that's intended
  420. * for a currently non-busy target/lun.
  421. *
  422. * wd33c93_execute() is always called with interrupts disabled or from
  423. * the wd33c93_intr itself, which means that a wd33c93 interrupt
  424. * cannot occur while we are in here.
  425. */
  426. static void
  427. wd33c93_execute(struct Scsi_Host *instance)
  428. {
  429. struct WD33C93_hostdata *hostdata =
  430. (struct WD33C93_hostdata *) instance->hostdata;
  431. const wd33c93_regs regs = hostdata->regs;
  432. struct scsi_cmnd *cmd, *prev;
  433. DB(DB_EXECUTE, printk("EX("))
  434. if (hostdata->selecting || hostdata->connected) {
  435. DB(DB_EXECUTE, printk(")EX-0 "))
  436. return;
  437. }
  438. /*
  439. * Search through the input_Q for a command destined
  440. * for an idle target/lun.
  441. */
  442. cmd = (struct scsi_cmnd *) hostdata->input_Q;
  443. prev = NULL;
  444. while (cmd) {
  445. if (!(hostdata->busy[cmd->device->id] &
  446. (1 << (cmd->device->lun & 0xff))))
  447. break;
  448. prev = cmd;
  449. cmd = (struct scsi_cmnd *) cmd->host_scribble;
  450. }
  451. /* quit if queue empty or all possible targets are busy */
  452. if (!cmd) {
  453. DB(DB_EXECUTE, printk(")EX-1 "))
  454. return;
  455. }
  456. /* remove command from queue */
  457. if (prev)
  458. prev->host_scribble = cmd->host_scribble;
  459. else
  460. hostdata->input_Q = (struct scsi_cmnd *) cmd->host_scribble;
  461. #ifdef PROC_STATISTICS
  462. hostdata->cmd_cnt[cmd->device->id]++;
  463. #endif
  464. /*
  465. * Start the selection process
  466. */
  467. if (cmd->sc_data_direction == DMA_TO_DEVICE)
  468. write_wd33c93(regs, WD_DESTINATION_ID, cmd->device->id);
  469. else
  470. write_wd33c93(regs, WD_DESTINATION_ID, cmd->device->id | DSTID_DPD);
  471. /* Now we need to figure out whether or not this command is a good
  472. * candidate for disconnect/reselect. We guess to the best of our
  473. * ability, based on a set of hierarchical rules. When several
  474. * devices are operating simultaneously, disconnects are usually
  475. * an advantage. In a single device system, or if only 1 device
  476. * is being accessed, transfers usually go faster if disconnects
  477. * are not allowed:
  478. *
  479. * + Commands should NEVER disconnect if hostdata->disconnect =
  480. * DIS_NEVER (this holds for tape drives also), and ALWAYS
  481. * disconnect if hostdata->disconnect = DIS_ALWAYS.
  482. * + Tape drive commands should always be allowed to disconnect.
  483. * + Disconnect should be allowed if disconnected_Q isn't empty.
  484. * + Commands should NOT disconnect if input_Q is empty.
  485. * + Disconnect should be allowed if there are commands in input_Q
  486. * for a different target/lun. In this case, the other commands
  487. * should be made disconnect-able, if not already.
  488. *
  489. * I know, I know - this code would flunk me out of any
  490. * "C Programming 101" class ever offered. But it's easy
  491. * to change around and experiment with for now.
  492. */
  493. cmd->SCp.phase = 0; /* assume no disconnect */
  494. if (hostdata->disconnect == DIS_NEVER)
  495. goto no;
  496. if (hostdata->disconnect == DIS_ALWAYS)
  497. goto yes;
  498. if (cmd->device->type == 1) /* tape drive? */
  499. goto yes;
  500. if (hostdata->disconnected_Q) /* other commands disconnected? */
  501. goto yes;
  502. if (!(hostdata->input_Q)) /* input_Q empty? */
  503. goto no;
  504. for (prev = (struct scsi_cmnd *) hostdata->input_Q; prev;
  505. prev = (struct scsi_cmnd *) prev->host_scribble) {
  506. if ((prev->device->id != cmd->device->id) ||
  507. (prev->device->lun != cmd->device->lun)) {
  508. for (prev = (struct scsi_cmnd *) hostdata->input_Q; prev;
  509. prev = (struct scsi_cmnd *) prev->host_scribble)
  510. prev->SCp.phase = 1;
  511. goto yes;
  512. }
  513. }
  514. goto no;
  515. yes:
  516. cmd->SCp.phase = 1;
  517. #ifdef PROC_STATISTICS
  518. hostdata->disc_allowed_cnt[cmd->device->id]++;
  519. #endif
  520. no:
  521. write_wd33c93(regs, WD_SOURCE_ID, ((cmd->SCp.phase) ? SRCID_ER : 0));
  522. write_wd33c93(regs, WD_TARGET_LUN, (u8)cmd->device->lun);
  523. write_wd33c93(regs, WD_SYNCHRONOUS_TRANSFER,
  524. hostdata->sync_xfer[cmd->device->id]);
  525. hostdata->busy[cmd->device->id] |= (1 << (cmd->device->lun & 0xFF));
  526. if ((hostdata->level2 == L2_NONE) ||
  527. (hostdata->sync_stat[cmd->device->id] == SS_UNSET)) {
  528. /*
  529. * Do a 'Select-With-ATN' command. This will end with
  530. * one of the following interrupts:
  531. * CSR_RESEL_AM: failure - can try again later.
  532. * CSR_TIMEOUT: failure - give up.
  533. * CSR_SELECT: success - proceed.
  534. */
  535. hostdata->selecting = cmd;
  536. /* Every target has its own synchronous transfer setting, kept in the
  537. * sync_xfer array, and a corresponding status byte in sync_stat[].
  538. * Each target's sync_stat[] entry is initialized to SX_UNSET, and its
  539. * sync_xfer[] entry is initialized to the default/safe value. SS_UNSET
  540. * means that the parameters are undetermined as yet, and that we
  541. * need to send an SDTR message to this device after selection is
  542. * complete: We set SS_FIRST to tell the interrupt routine to do so.
  543. * If we've been asked not to try synchronous transfers on this
  544. * target (and _all_ luns within it), we'll still send the SDTR message
  545. * later, but at that time we'll negotiate for async by specifying a
  546. * sync fifo depth of 0.
  547. */
  548. if (hostdata->sync_stat[cmd->device->id] == SS_UNSET)
  549. hostdata->sync_stat[cmd->device->id] = SS_FIRST;
  550. hostdata->state = S_SELECTING;
  551. write_wd33c93_count(regs, 0); /* guarantee a DATA_PHASE interrupt */
  552. write_wd33c93_cmd(regs, WD_CMD_SEL_ATN);
  553. } else {
  554. /*
  555. * Do a 'Select-With-ATN-Xfer' command. This will end with
  556. * one of the following interrupts:
  557. * CSR_RESEL_AM: failure - can try again later.
  558. * CSR_TIMEOUT: failure - give up.
  559. * anything else: success - proceed.
  560. */
  561. hostdata->connected = cmd;
  562. write_wd33c93(regs, WD_COMMAND_PHASE, 0);
  563. /* copy command_descriptor_block into WD chip
  564. * (take advantage of auto-incrementing)
  565. */
  566. write_wd33c93_cdb(regs, cmd->cmd_len, cmd->cmnd);
  567. /* The wd33c93 only knows about Group 0, 1, and 5 commands when
  568. * it's doing a 'select-and-transfer'. To be safe, we write the
  569. * size of the CDB into the OWN_ID register for every case. This
  570. * way there won't be problems with vendor-unique, audio, etc.
  571. */
  572. write_wd33c93(regs, WD_OWN_ID, cmd->cmd_len);
  573. /* When doing a non-disconnect command with DMA, we can save
  574. * ourselves a DATA phase interrupt later by setting everything
  575. * up ahead of time.
  576. */
  577. if ((cmd->SCp.phase == 0) && (hostdata->no_dma == 0)) {
  578. if (hostdata->dma_setup(cmd,
  579. (cmd->sc_data_direction == DMA_TO_DEVICE) ?
  580. DATA_OUT_DIR : DATA_IN_DIR))
  581. write_wd33c93_count(regs, 0); /* guarantee a DATA_PHASE interrupt */
  582. else {
  583. write_wd33c93_count(regs,
  584. cmd->SCp.this_residual);
  585. write_wd33c93(regs, WD_CONTROL,
  586. CTRL_IDI | CTRL_EDI | hostdata->dma_mode);
  587. hostdata->dma = D_DMA_RUNNING;
  588. }
  589. } else
  590. write_wd33c93_count(regs, 0); /* guarantee a DATA_PHASE interrupt */
  591. hostdata->state = S_RUNNING_LEVEL2;
  592. write_wd33c93_cmd(regs, WD_CMD_SEL_ATN_XFER);
  593. }
  594. /*
  595. * Since the SCSI bus can handle only 1 connection at a time,
  596. * we get out of here now. If the selection fails, or when
  597. * the command disconnects, we'll come back to this routine
  598. * to search the input_Q again...
  599. */
  600. DB(DB_EXECUTE,
  601. printk("%s)EX-2 ", (cmd->SCp.phase) ? "d:" : ""))
  602. }
  603. static void
  604. transfer_pio(const wd33c93_regs regs, uchar * buf, int cnt,
  605. int data_in_dir, struct WD33C93_hostdata *hostdata)
  606. {
  607. uchar asr;
  608. DB(DB_TRANSFER,
  609. printk("(%p,%d,%s:", buf, cnt, data_in_dir ? "in" : "out"))
  610. write_wd33c93(regs, WD_CONTROL, CTRL_IDI | CTRL_EDI | CTRL_POLLED);
  611. write_wd33c93_count(regs, cnt);
  612. write_wd33c93_cmd(regs, WD_CMD_TRANS_INFO);
  613. if (data_in_dir) {
  614. do {
  615. asr = read_aux_stat(regs);
  616. if (asr & ASR_DBR)
  617. *buf++ = read_wd33c93(regs, WD_DATA);
  618. } while (!(asr & ASR_INT));
  619. } else {
  620. do {
  621. asr = read_aux_stat(regs);
  622. if (asr & ASR_DBR)
  623. write_wd33c93(regs, WD_DATA, *buf++);
  624. } while (!(asr & ASR_INT));
  625. }
  626. /* Note: we are returning with the interrupt UN-cleared.
  627. * Since (presumably) an entire I/O operation has
  628. * completed, the bus phase is probably different, and
  629. * the interrupt routine will discover this when it
  630. * responds to the uncleared int.
  631. */
  632. }
  633. static void
  634. transfer_bytes(const wd33c93_regs regs, struct scsi_cmnd *cmd,
  635. int data_in_dir)
  636. {
  637. struct WD33C93_hostdata *hostdata;
  638. unsigned long length;
  639. hostdata = (struct WD33C93_hostdata *) cmd->device->host->hostdata;
  640. /* Normally, you'd expect 'this_residual' to be non-zero here.
  641. * In a series of scatter-gather transfers, however, this
  642. * routine will usually be called with 'this_residual' equal
  643. * to 0 and 'buffers_residual' non-zero. This means that a
  644. * previous transfer completed, clearing 'this_residual', and
  645. * now we need to setup the next scatter-gather buffer as the
  646. * source or destination for THIS transfer.
  647. */
  648. if (!cmd->SCp.this_residual && cmd->SCp.buffers_residual) {
  649. ++cmd->SCp.buffer;
  650. --cmd->SCp.buffers_residual;
  651. cmd->SCp.this_residual = cmd->SCp.buffer->length;
  652. cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
  653. }
  654. if (!cmd->SCp.this_residual) /* avoid bogus setups */
  655. return;
  656. write_wd33c93(regs, WD_SYNCHRONOUS_TRANSFER,
  657. hostdata->sync_xfer[cmd->device->id]);
  658. /* 'hostdata->no_dma' is TRUE if we don't even want to try DMA.
  659. * Update 'this_residual' and 'ptr' after 'transfer_pio()' returns.
  660. */
  661. if (hostdata->no_dma || hostdata->dma_setup(cmd, data_in_dir)) {
  662. #ifdef PROC_STATISTICS
  663. hostdata->pio_cnt++;
  664. #endif
  665. transfer_pio(regs, (uchar *) cmd->SCp.ptr,
  666. cmd->SCp.this_residual, data_in_dir, hostdata);
  667. length = cmd->SCp.this_residual;
  668. cmd->SCp.this_residual = read_wd33c93_count(regs);
  669. cmd->SCp.ptr += (length - cmd->SCp.this_residual);
  670. }
  671. /* We are able to do DMA (in fact, the Amiga hardware is
  672. * already going!), so start up the wd33c93 in DMA mode.
  673. * We set 'hostdata->dma' = D_DMA_RUNNING so that when the
  674. * transfer completes and causes an interrupt, we're
  675. * reminded to tell the Amiga to shut down its end. We'll
  676. * postpone the updating of 'this_residual' and 'ptr'
  677. * until then.
  678. */
  679. else {
  680. #ifdef PROC_STATISTICS
  681. hostdata->dma_cnt++;
  682. #endif
  683. write_wd33c93(regs, WD_CONTROL, CTRL_IDI | CTRL_EDI | hostdata->dma_mode);
  684. write_wd33c93_count(regs, cmd->SCp.this_residual);
  685. if ((hostdata->level2 >= L2_DATA) ||
  686. (hostdata->level2 == L2_BASIC && cmd->SCp.phase == 0)) {
  687. write_wd33c93(regs, WD_COMMAND_PHASE, 0x45);
  688. write_wd33c93_cmd(regs, WD_CMD_SEL_ATN_XFER);
  689. hostdata->state = S_RUNNING_LEVEL2;
  690. } else
  691. write_wd33c93_cmd(regs, WD_CMD_TRANS_INFO);
  692. hostdata->dma = D_DMA_RUNNING;
  693. }
  694. }
  695. void
  696. wd33c93_intr(struct Scsi_Host *instance)
  697. {
  698. struct WD33C93_hostdata *hostdata =
  699. (struct WD33C93_hostdata *) instance->hostdata;
  700. const wd33c93_regs regs = hostdata->regs;
  701. struct scsi_cmnd *patch, *cmd;
  702. uchar asr, sr, phs, id, lun, *ucp, msg;
  703. unsigned long length, flags;
  704. asr = read_aux_stat(regs);
  705. if (!(asr & ASR_INT) || (asr & ASR_BSY))
  706. return;
  707. spin_lock_irqsave(&hostdata->lock, flags);
  708. #ifdef PROC_STATISTICS
  709. hostdata->int_cnt++;
  710. #endif
  711. cmd = (struct scsi_cmnd *) hostdata->connected; /* assume we're connected */
  712. sr = read_wd33c93(regs, WD_SCSI_STATUS); /* clear the interrupt */
  713. phs = read_wd33c93(regs, WD_COMMAND_PHASE);
  714. DB(DB_INTR, printk("{%02x:%02x-", asr, sr))
  715. /* After starting a DMA transfer, the next interrupt
  716. * is guaranteed to be in response to completion of
  717. * the transfer. Since the Amiga DMA hardware runs in
  718. * in an open-ended fashion, it needs to be told when
  719. * to stop; do that here if D_DMA_RUNNING is true.
  720. * Also, we have to update 'this_residual' and 'ptr'
  721. * based on the contents of the TRANSFER_COUNT register,
  722. * in case the device decided to do an intermediate
  723. * disconnect (a device may do this if it has to do a
  724. * seek, or just to be nice and let other devices have
  725. * some bus time during long transfers). After doing
  726. * whatever is needed, we go on and service the WD3393
  727. * interrupt normally.
  728. */
  729. if (hostdata->dma == D_DMA_RUNNING) {
  730. DB(DB_TRANSFER,
  731. printk("[%p/%d:", cmd->SCp.ptr, cmd->SCp.this_residual))
  732. hostdata->dma_stop(cmd->device->host, cmd, 1);
  733. hostdata->dma = D_DMA_OFF;
  734. length = cmd->SCp.this_residual;
  735. cmd->SCp.this_residual = read_wd33c93_count(regs);
  736. cmd->SCp.ptr += (length - cmd->SCp.this_residual);
  737. DB(DB_TRANSFER,
  738. printk("%p/%d]", cmd->SCp.ptr, cmd->SCp.this_residual))
  739. }
  740. /* Respond to the specific WD3393 interrupt - there are quite a few! */
  741. switch (sr) {
  742. case CSR_TIMEOUT:
  743. DB(DB_INTR, printk("TIMEOUT"))
  744. if (hostdata->state == S_RUNNING_LEVEL2)
  745. hostdata->connected = NULL;
  746. else {
  747. cmd = (struct scsi_cmnd *) hostdata->selecting; /* get a valid cmd */
  748. hostdata->selecting = NULL;
  749. }
  750. cmd->result = DID_NO_CONNECT << 16;
  751. hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun & 0xff));
  752. hostdata->state = S_UNCONNECTED;
  753. cmd->scsi_done(cmd);
  754. /* From esp.c:
  755. * There is a window of time within the scsi_done() path
  756. * of execution where interrupts are turned back on full
  757. * blast and left that way. During that time we could
  758. * reconnect to a disconnected command, then we'd bomb
  759. * out below. We could also end up executing two commands
  760. * at _once_. ...just so you know why the restore_flags()
  761. * is here...
  762. */
  763. spin_unlock_irqrestore(&hostdata->lock, flags);
  764. /* We are not connected to a target - check to see if there
  765. * are commands waiting to be executed.
  766. */
  767. wd33c93_execute(instance);
  768. break;
  769. /* Note: this interrupt should not occur in a LEVEL2 command */
  770. case CSR_SELECT:
  771. DB(DB_INTR, printk("SELECT"))
  772. hostdata->connected = cmd =
  773. (struct scsi_cmnd *) hostdata->selecting;
  774. hostdata->selecting = NULL;
  775. /* construct an IDENTIFY message with correct disconnect bit */
  776. hostdata->outgoing_msg[0] = IDENTIFY(0, cmd->device->lun);
  777. if (cmd->SCp.phase)
  778. hostdata->outgoing_msg[0] |= 0x40;
  779. if (hostdata->sync_stat[cmd->device->id] == SS_FIRST) {
  780. hostdata->sync_stat[cmd->device->id] = SS_WAITING;
  781. /* Tack on a 2nd message to ask about synchronous transfers. If we've
  782. * been asked to do only asynchronous transfers on this device, we
  783. * request a fifo depth of 0, which is equivalent to async - should
  784. * solve the problems some people have had with GVP's Guru ROM.
  785. */
  786. hostdata->outgoing_msg[1] = EXTENDED_MESSAGE;
  787. hostdata->outgoing_msg[2] = 3;
  788. hostdata->outgoing_msg[3] = EXTENDED_SDTR;
  789. if (hostdata->no_sync & (1 << cmd->device->id)) {
  790. calc_sync_msg(hostdata->default_sx_per, 0,
  791. 0, hostdata->outgoing_msg + 4);
  792. } else {
  793. calc_sync_msg(optimum_sx_per(hostdata),
  794. OPTIMUM_SX_OFF,
  795. hostdata->fast,
  796. hostdata->outgoing_msg + 4);
  797. }
  798. hostdata->outgoing_len = 6;
  799. #ifdef SYNC_DEBUG
  800. ucp = hostdata->outgoing_msg + 1;
  801. printk(" sending SDTR %02x03%02x%02x%02x ",
  802. ucp[0], ucp[2], ucp[3], ucp[4]);
  803. #endif
  804. } else
  805. hostdata->outgoing_len = 1;
  806. hostdata->state = S_CONNECTED;
  807. spin_unlock_irqrestore(&hostdata->lock, flags);
  808. break;
  809. case CSR_XFER_DONE | PHS_DATA_IN:
  810. case CSR_UNEXP | PHS_DATA_IN:
  811. case CSR_SRV_REQ | PHS_DATA_IN:
  812. DB(DB_INTR,
  813. printk("IN-%d.%d", cmd->SCp.this_residual,
  814. cmd->SCp.buffers_residual))
  815. transfer_bytes(regs, cmd, DATA_IN_DIR);
  816. if (hostdata->state != S_RUNNING_LEVEL2)
  817. hostdata->state = S_CONNECTED;
  818. spin_unlock_irqrestore(&hostdata->lock, flags);
  819. break;
  820. case CSR_XFER_DONE | PHS_DATA_OUT:
  821. case CSR_UNEXP | PHS_DATA_OUT:
  822. case CSR_SRV_REQ | PHS_DATA_OUT:
  823. DB(DB_INTR,
  824. printk("OUT-%d.%d", cmd->SCp.this_residual,
  825. cmd->SCp.buffers_residual))
  826. transfer_bytes(regs, cmd, DATA_OUT_DIR);
  827. if (hostdata->state != S_RUNNING_LEVEL2)
  828. hostdata->state = S_CONNECTED;
  829. spin_unlock_irqrestore(&hostdata->lock, flags);
  830. break;
  831. /* Note: this interrupt should not occur in a LEVEL2 command */
  832. case CSR_XFER_DONE | PHS_COMMAND:
  833. case CSR_UNEXP | PHS_COMMAND:
  834. case CSR_SRV_REQ | PHS_COMMAND:
  835. DB(DB_INTR, printk("CMND-%02x", cmd->cmnd[0]))
  836. transfer_pio(regs, cmd->cmnd, cmd->cmd_len, DATA_OUT_DIR,
  837. hostdata);
  838. hostdata->state = S_CONNECTED;
  839. spin_unlock_irqrestore(&hostdata->lock, flags);
  840. break;
  841. case CSR_XFER_DONE | PHS_STATUS:
  842. case CSR_UNEXP | PHS_STATUS:
  843. case CSR_SRV_REQ | PHS_STATUS:
  844. DB(DB_INTR, printk("STATUS="))
  845. cmd->SCp.Status = read_1_byte(regs);
  846. DB(DB_INTR, printk("%02x", cmd->SCp.Status))
  847. if (hostdata->level2 >= L2_BASIC) {
  848. sr = read_wd33c93(regs, WD_SCSI_STATUS); /* clear interrupt */
  849. udelay(7);
  850. hostdata->state = S_RUNNING_LEVEL2;
  851. write_wd33c93(regs, WD_COMMAND_PHASE, 0x50);
  852. write_wd33c93_cmd(regs, WD_CMD_SEL_ATN_XFER);
  853. } else {
  854. hostdata->state = S_CONNECTED;
  855. }
  856. spin_unlock_irqrestore(&hostdata->lock, flags);
  857. break;
  858. case CSR_XFER_DONE | PHS_MESS_IN:
  859. case CSR_UNEXP | PHS_MESS_IN:
  860. case CSR_SRV_REQ | PHS_MESS_IN:
  861. DB(DB_INTR, printk("MSG_IN="))
  862. msg = read_1_byte(regs);
  863. sr = read_wd33c93(regs, WD_SCSI_STATUS); /* clear interrupt */
  864. udelay(7);
  865. hostdata->incoming_msg[hostdata->incoming_ptr] = msg;
  866. if (hostdata->incoming_msg[0] == EXTENDED_MESSAGE)
  867. msg = EXTENDED_MESSAGE;
  868. else
  869. hostdata->incoming_ptr = 0;
  870. cmd->SCp.Message = msg;
  871. switch (msg) {
  872. case COMMAND_COMPLETE:
  873. DB(DB_INTR, printk("CCMP"))
  874. write_wd33c93_cmd(regs, WD_CMD_NEGATE_ACK);
  875. hostdata->state = S_PRE_CMP_DISC;
  876. break;
  877. case SAVE_POINTERS:
  878. DB(DB_INTR, printk("SDP"))
  879. write_wd33c93_cmd(regs, WD_CMD_NEGATE_ACK);
  880. hostdata->state = S_CONNECTED;
  881. break;
  882. case RESTORE_POINTERS:
  883. DB(DB_INTR, printk("RDP"))
  884. if (hostdata->level2 >= L2_BASIC) {
  885. write_wd33c93(regs, WD_COMMAND_PHASE, 0x45);
  886. write_wd33c93_cmd(regs, WD_CMD_SEL_ATN_XFER);
  887. hostdata->state = S_RUNNING_LEVEL2;
  888. } else {
  889. write_wd33c93_cmd(regs, WD_CMD_NEGATE_ACK);
  890. hostdata->state = S_CONNECTED;
  891. }
  892. break;
  893. case DISCONNECT:
  894. DB(DB_INTR, printk("DIS"))
  895. cmd->device->disconnect = 1;
  896. write_wd33c93_cmd(regs, WD_CMD_NEGATE_ACK);
  897. hostdata->state = S_PRE_TMP_DISC;
  898. break;
  899. case MESSAGE_REJECT:
  900. DB(DB_INTR, printk("REJ"))
  901. #ifdef SYNC_DEBUG
  902. printk("-REJ-");
  903. #endif
  904. if (hostdata->sync_stat[cmd->device->id] == SS_WAITING) {
  905. hostdata->sync_stat[cmd->device->id] = SS_SET;
  906. /* we want default_sx_per, not DEFAULT_SX_PER */
  907. hostdata->sync_xfer[cmd->device->id] =
  908. calc_sync_xfer(hostdata->default_sx_per
  909. / 4, 0, 0, hostdata->sx_table);
  910. }
  911. write_wd33c93_cmd(regs, WD_CMD_NEGATE_ACK);
  912. hostdata->state = S_CONNECTED;
  913. break;
  914. case EXTENDED_MESSAGE:
  915. DB(DB_INTR, printk("EXT"))
  916. ucp = hostdata->incoming_msg;
  917. #ifdef SYNC_DEBUG
  918. printk("%02x", ucp[hostdata->incoming_ptr]);
  919. #endif
  920. /* Is this the last byte of the extended message? */
  921. if ((hostdata->incoming_ptr >= 2) &&
  922. (hostdata->incoming_ptr == (ucp[1] + 1))) {
  923. switch (ucp[2]) { /* what's the EXTENDED code? */
  924. case EXTENDED_SDTR:
  925. /* default to default async period */
  926. id = calc_sync_xfer(hostdata->
  927. default_sx_per / 4, 0,
  928. 0, hostdata->sx_table);
  929. if (hostdata->sync_stat[cmd->device->id] !=
  930. SS_WAITING) {
  931. /* A device has sent an unsolicited SDTR message; rather than go
  932. * through the effort of decoding it and then figuring out what
  933. * our reply should be, we're just gonna say that we have a
  934. * synchronous fifo depth of 0. This will result in asynchronous
  935. * transfers - not ideal but so much easier.
  936. * Actually, this is OK because it assures us that if we don't
  937. * specifically ask for sync transfers, we won't do any.
  938. */
  939. write_wd33c93_cmd(regs, WD_CMD_ASSERT_ATN); /* want MESS_OUT */
  940. hostdata->outgoing_msg[0] =
  941. EXTENDED_MESSAGE;
  942. hostdata->outgoing_msg[1] = 3;
  943. hostdata->outgoing_msg[2] =
  944. EXTENDED_SDTR;
  945. calc_sync_msg(hostdata->
  946. default_sx_per, 0,
  947. 0, hostdata->outgoing_msg + 3);
  948. hostdata->outgoing_len = 5;
  949. } else {
  950. if (ucp[4]) /* well, sync transfer */
  951. id = calc_sync_xfer(ucp[3], ucp[4],
  952. hostdata->fast,
  953. hostdata->sx_table);
  954. else if (ucp[3]) /* very unlikely... */
  955. id = calc_sync_xfer(ucp[3], ucp[4],
  956. 0, hostdata->sx_table);
  957. }
  958. hostdata->sync_xfer[cmd->device->id] = id;
  959. #ifdef SYNC_DEBUG
  960. printk(" sync_xfer=%02x\n",
  961. hostdata->sync_xfer[cmd->device->id]);
  962. #endif
  963. hostdata->sync_stat[cmd->device->id] =
  964. SS_SET;
  965. write_wd33c93_cmd(regs,
  966. WD_CMD_NEGATE_ACK);
  967. hostdata->state = S_CONNECTED;
  968. break;
  969. case EXTENDED_WDTR:
  970. write_wd33c93_cmd(regs, WD_CMD_ASSERT_ATN); /* want MESS_OUT */
  971. printk("sending WDTR ");
  972. hostdata->outgoing_msg[0] =
  973. EXTENDED_MESSAGE;
  974. hostdata->outgoing_msg[1] = 2;
  975. hostdata->outgoing_msg[2] =
  976. EXTENDED_WDTR;
  977. hostdata->outgoing_msg[3] = 0; /* 8 bit transfer width */
  978. hostdata->outgoing_len = 4;
  979. write_wd33c93_cmd(regs,
  980. WD_CMD_NEGATE_ACK);
  981. hostdata->state = S_CONNECTED;
  982. break;
  983. default:
  984. write_wd33c93_cmd(regs, WD_CMD_ASSERT_ATN); /* want MESS_OUT */
  985. printk
  986. ("Rejecting Unknown Extended Message(%02x). ",
  987. ucp[2]);
  988. hostdata->outgoing_msg[0] =
  989. MESSAGE_REJECT;
  990. hostdata->outgoing_len = 1;
  991. write_wd33c93_cmd(regs,
  992. WD_CMD_NEGATE_ACK);
  993. hostdata->state = S_CONNECTED;
  994. break;
  995. }
  996. hostdata->incoming_ptr = 0;
  997. }
  998. /* We need to read more MESS_IN bytes for the extended message */
  999. else {
  1000. hostdata->incoming_ptr++;
  1001. write_wd33c93_cmd(regs, WD_CMD_NEGATE_ACK);
  1002. hostdata->state = S_CONNECTED;
  1003. }
  1004. break;
  1005. default:
  1006. printk("Rejecting Unknown Message(%02x) ", msg);
  1007. write_wd33c93_cmd(regs, WD_CMD_ASSERT_ATN); /* want MESS_OUT */
  1008. hostdata->outgoing_msg[0] = MESSAGE_REJECT;
  1009. hostdata->outgoing_len = 1;
  1010. write_wd33c93_cmd(regs, WD_CMD_NEGATE_ACK);
  1011. hostdata->state = S_CONNECTED;
  1012. }
  1013. spin_unlock_irqrestore(&hostdata->lock, flags);
  1014. break;
  1015. /* Note: this interrupt will occur only after a LEVEL2 command */
  1016. case CSR_SEL_XFER_DONE:
  1017. /* Make sure that reselection is enabled at this point - it may
  1018. * have been turned off for the command that just completed.
  1019. */
  1020. write_wd33c93(regs, WD_SOURCE_ID, SRCID_ER);
  1021. if (phs == 0x60) {
  1022. DB(DB_INTR, printk("SX-DONE"))
  1023. cmd->SCp.Message = COMMAND_COMPLETE;
  1024. lun = read_wd33c93(regs, WD_TARGET_LUN);
  1025. DB(DB_INTR, printk(":%d.%d", cmd->SCp.Status, lun))
  1026. hostdata->connected = NULL;
  1027. hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun & 0xff));
  1028. hostdata->state = S_UNCONNECTED;
  1029. if (cmd->SCp.Status == ILLEGAL_STATUS_BYTE)
  1030. cmd->SCp.Status = lun;
  1031. if (cmd->cmnd[0] == REQUEST_SENSE
  1032. && cmd->SCp.Status != GOOD)
  1033. cmd->result =
  1034. (cmd->
  1035. result & 0x00ffff) | (DID_ERROR << 16);
  1036. else
  1037. cmd->result =
  1038. cmd->SCp.Status | (cmd->SCp.Message << 8);
  1039. cmd->scsi_done(cmd);
  1040. /* We are no longer connected to a target - check to see if
  1041. * there are commands waiting to be executed.
  1042. */
  1043. spin_unlock_irqrestore(&hostdata->lock, flags);
  1044. wd33c93_execute(instance);
  1045. } else {
  1046. printk
  1047. ("%02x:%02x:%02x: Unknown SEL_XFER_DONE phase!!---",
  1048. asr, sr, phs);
  1049. spin_unlock_irqrestore(&hostdata->lock, flags);
  1050. }
  1051. break;
  1052. /* Note: this interrupt will occur only after a LEVEL2 command */
  1053. case CSR_SDP:
  1054. DB(DB_INTR, printk("SDP"))
  1055. hostdata->state = S_RUNNING_LEVEL2;
  1056. write_wd33c93(regs, WD_COMMAND_PHASE, 0x41);
  1057. write_wd33c93_cmd(regs, WD_CMD_SEL_ATN_XFER);
  1058. spin_unlock_irqrestore(&hostdata->lock, flags);
  1059. break;
  1060. case CSR_XFER_DONE | PHS_MESS_OUT:
  1061. case CSR_UNEXP | PHS_MESS_OUT:
  1062. case CSR_SRV_REQ | PHS_MESS_OUT:
  1063. DB(DB_INTR, printk("MSG_OUT="))
  1064. /* To get here, we've probably requested MESSAGE_OUT and have
  1065. * already put the correct bytes in outgoing_msg[] and filled
  1066. * in outgoing_len. We simply send them out to the SCSI bus.
  1067. * Sometimes we get MESSAGE_OUT phase when we're not expecting
  1068. * it - like when our SDTR message is rejected by a target. Some
  1069. * targets send the REJECT before receiving all of the extended
  1070. * message, and then seem to go back to MESSAGE_OUT for a byte
  1071. * or two. Not sure why, or if I'm doing something wrong to
  1072. * cause this to happen. Regardless, it seems that sending
  1073. * NOP messages in these situations results in no harm and
  1074. * makes everyone happy.
  1075. */
  1076. if (hostdata->outgoing_len == 0) {
  1077. hostdata->outgoing_len = 1;
  1078. hostdata->outgoing_msg[0] = NOP;
  1079. }
  1080. transfer_pio(regs, hostdata->outgoing_msg,
  1081. hostdata->outgoing_len, DATA_OUT_DIR, hostdata);
  1082. DB(DB_INTR, printk("%02x", hostdata->outgoing_msg[0]))
  1083. hostdata->outgoing_len = 0;
  1084. hostdata->state = S_CONNECTED;
  1085. spin_unlock_irqrestore(&hostdata->lock, flags);
  1086. break;
  1087. case CSR_UNEXP_DISC:
  1088. /* I think I've seen this after a request-sense that was in response
  1089. * to an error condition, but not sure. We certainly need to do
  1090. * something when we get this interrupt - the question is 'what?'.
  1091. * Let's think positively, and assume some command has finished
  1092. * in a legal manner (like a command that provokes a request-sense),
  1093. * so we treat it as a normal command-complete-disconnect.
  1094. */
  1095. /* Make sure that reselection is enabled at this point - it may
  1096. * have been turned off for the command that just completed.
  1097. */
  1098. write_wd33c93(regs, WD_SOURCE_ID, SRCID_ER);
  1099. if (cmd == NULL) {
  1100. printk(" - Already disconnected! ");
  1101. hostdata->state = S_UNCONNECTED;
  1102. spin_unlock_irqrestore(&hostdata->lock, flags);
  1103. return;
  1104. }
  1105. DB(DB_INTR, printk("UNEXP_DISC"))
  1106. hostdata->connected = NULL;
  1107. hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun & 0xff));
  1108. hostdata->state = S_UNCONNECTED;
  1109. if (cmd->cmnd[0] == REQUEST_SENSE && cmd->SCp.Status != GOOD)
  1110. cmd->result =
  1111. (cmd->result & 0x00ffff) | (DID_ERROR << 16);
  1112. else
  1113. cmd->result = cmd->SCp.Status | (cmd->SCp.Message << 8);
  1114. cmd->scsi_done(cmd);
  1115. /* We are no longer connected to a target - check to see if
  1116. * there are commands waiting to be executed.
  1117. */
  1118. /* look above for comments on scsi_done() */
  1119. spin_unlock_irqrestore(&hostdata->lock, flags);
  1120. wd33c93_execute(instance);
  1121. break;
  1122. case CSR_DISC:
  1123. /* Make sure that reselection is enabled at this point - it may
  1124. * have been turned off for the command that just completed.
  1125. */
  1126. write_wd33c93(regs, WD_SOURCE_ID, SRCID_ER);
  1127. DB(DB_INTR, printk("DISC"))
  1128. if (cmd == NULL) {
  1129. printk(" - Already disconnected! ");
  1130. hostdata->state = S_UNCONNECTED;
  1131. }
  1132. switch (hostdata->state) {
  1133. case S_PRE_CMP_DISC:
  1134. hostdata->connected = NULL;
  1135. hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun & 0xff));
  1136. hostdata->state = S_UNCONNECTED;
  1137. DB(DB_INTR, printk(":%d", cmd->SCp.Status))
  1138. if (cmd->cmnd[0] == REQUEST_SENSE
  1139. && cmd->SCp.Status != GOOD)
  1140. cmd->result =
  1141. (cmd->
  1142. result & 0x00ffff) | (DID_ERROR << 16);
  1143. else
  1144. cmd->result =
  1145. cmd->SCp.Status | (cmd->SCp.Message << 8);
  1146. cmd->scsi_done(cmd);
  1147. break;
  1148. case S_PRE_TMP_DISC:
  1149. case S_RUNNING_LEVEL2:
  1150. cmd->host_scribble = (uchar *) hostdata->disconnected_Q;
  1151. hostdata->disconnected_Q = cmd;
  1152. hostdata->connected = NULL;
  1153. hostdata->state = S_UNCONNECTED;
  1154. #ifdef PROC_STATISTICS
  1155. hostdata->disc_done_cnt[cmd->device->id]++;
  1156. #endif
  1157. break;
  1158. default:
  1159. printk("*** Unexpected DISCONNECT interrupt! ***");
  1160. hostdata->state = S_UNCONNECTED;
  1161. }
  1162. /* We are no longer connected to a target - check to see if
  1163. * there are commands waiting to be executed.
  1164. */
  1165. spin_unlock_irqrestore(&hostdata->lock, flags);
  1166. wd33c93_execute(instance);
  1167. break;
  1168. case CSR_RESEL_AM:
  1169. case CSR_RESEL:
  1170. DB(DB_INTR, printk("RESEL%s", sr == CSR_RESEL_AM ? "_AM" : ""))
  1171. /* Old chips (pre -A ???) don't have advanced features and will
  1172. * generate CSR_RESEL. In that case we have to extract the LUN the
  1173. * hard way (see below).
  1174. * First we have to make sure this reselection didn't
  1175. * happen during Arbitration/Selection of some other device.
  1176. * If yes, put losing command back on top of input_Q.
  1177. */
  1178. if (hostdata->level2 <= L2_NONE) {
  1179. if (hostdata->selecting) {
  1180. cmd = (struct scsi_cmnd *) hostdata->selecting;
  1181. hostdata->selecting = NULL;
  1182. hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun & 0xff));
  1183. cmd->host_scribble =
  1184. (uchar *) hostdata->input_Q;
  1185. hostdata->input_Q = cmd;
  1186. }
  1187. }
  1188. else {
  1189. if (cmd) {
  1190. if (phs == 0x00) {
  1191. hostdata->busy[cmd->device->id] &=
  1192. ~(1 << (cmd->device->lun & 0xff));
  1193. cmd->host_scribble =
  1194. (uchar *) hostdata->input_Q;
  1195. hostdata->input_Q = cmd;
  1196. } else {
  1197. printk
  1198. ("---%02x:%02x:%02x-TROUBLE: Intrusive ReSelect!---",
  1199. asr, sr, phs);
  1200. while (1)
  1201. printk("\r");
  1202. }
  1203. }
  1204. }
  1205. /* OK - find out which device reselected us. */
  1206. id = read_wd33c93(regs, WD_SOURCE_ID);
  1207. id &= SRCID_MASK;
  1208. /* and extract the lun from the ID message. (Note that we don't
  1209. * bother to check for a valid message here - I guess this is
  1210. * not the right way to go, but...)
  1211. */
  1212. if (sr == CSR_RESEL_AM) {
  1213. lun = read_wd33c93(regs, WD_DATA);
  1214. if (hostdata->level2 < L2_RESELECT)
  1215. write_wd33c93_cmd(regs, WD_CMD_NEGATE_ACK);
  1216. lun &= 7;
  1217. } else {
  1218. /* Old chip; wait for msgin phase to pick up the LUN. */
  1219. for (lun = 255; lun; lun--) {
  1220. if ((asr = read_aux_stat(regs)) & ASR_INT)
  1221. break;
  1222. udelay(10);
  1223. }
  1224. if (!(asr & ASR_INT)) {
  1225. printk
  1226. ("wd33c93: Reselected without IDENTIFY\n");
  1227. lun = 0;
  1228. } else {
  1229. /* Verify this is a change to MSG_IN and read the message */
  1230. sr = read_wd33c93(regs, WD_SCSI_STATUS);
  1231. udelay(7);
  1232. if (sr == (CSR_ABORT | PHS_MESS_IN) ||
  1233. sr == (CSR_UNEXP | PHS_MESS_IN) ||
  1234. sr == (CSR_SRV_REQ | PHS_MESS_IN)) {
  1235. /* Got MSG_IN, grab target LUN */
  1236. lun = read_1_byte(regs);
  1237. /* Now we expect a 'paused with ACK asserted' int.. */
  1238. asr = read_aux_stat(regs);
  1239. if (!(asr & ASR_INT)) {
  1240. udelay(10);
  1241. asr = read_aux_stat(regs);
  1242. if (!(asr & ASR_INT))
  1243. printk
  1244. ("wd33c93: No int after LUN on RESEL (%02x)\n",
  1245. asr);
  1246. }
  1247. sr = read_wd33c93(regs, WD_SCSI_STATUS);
  1248. udelay(7);
  1249. if (sr != CSR_MSGIN)
  1250. printk
  1251. ("wd33c93: Not paused with ACK on RESEL (%02x)\n",
  1252. sr);
  1253. lun &= 7;
  1254. write_wd33c93_cmd(regs,
  1255. WD_CMD_NEGATE_ACK);
  1256. } else {
  1257. printk
  1258. ("wd33c93: Not MSG_IN on reselect (%02x)\n",
  1259. sr);
  1260. lun = 0;
  1261. }
  1262. }
  1263. }
  1264. /* Now we look for the command that's reconnecting. */
  1265. cmd = (struct scsi_cmnd *) hostdata->disconnected_Q;
  1266. patch = NULL;
  1267. while (cmd) {
  1268. if (id == cmd->device->id && lun == (u8)cmd->device->lun)
  1269. break;
  1270. patch = cmd;
  1271. cmd = (struct scsi_cmnd *) cmd->host_scribble;
  1272. }
  1273. /* Hmm. Couldn't find a valid command.... What to do? */
  1274. if (!cmd) {
  1275. printk
  1276. ("---TROUBLE: target %d.%d not in disconnect queue---",
  1277. id, (u8)lun);
  1278. spin_unlock_irqrestore(&hostdata->lock, flags);
  1279. return;
  1280. }
  1281. /* Ok, found the command - now start it up again. */
  1282. if (patch)
  1283. patch->host_scribble = cmd->host_scribble;
  1284. else
  1285. hostdata->disconnected_Q =
  1286. (struct scsi_cmnd *) cmd->host_scribble;
  1287. hostdata->connected = cmd;
  1288. /* We don't need to worry about 'initialize_SCp()' or 'hostdata->busy[]'
  1289. * because these things are preserved over a disconnect.
  1290. * But we DO need to fix the DPD bit so it's correct for this command.
  1291. */
  1292. if (cmd->sc_data_direction == DMA_TO_DEVICE)
  1293. write_wd33c93(regs, WD_DESTINATION_ID, cmd->device->id);
  1294. else
  1295. write_wd33c93(regs, WD_DESTINATION_ID,
  1296. cmd->device->id | DSTID_DPD);
  1297. if (hostdata->level2 >= L2_RESELECT) {
  1298. write_wd33c93_count(regs, 0); /* we want a DATA_PHASE interrupt */
  1299. write_wd33c93(regs, WD_COMMAND_PHASE, 0x45);
  1300. write_wd33c93_cmd(regs, WD_CMD_SEL_ATN_XFER);
  1301. hostdata->state = S_RUNNING_LEVEL2;
  1302. } else
  1303. hostdata->state = S_CONNECTED;
  1304. spin_unlock_irqrestore(&hostdata->lock, flags);
  1305. break;
  1306. default:
  1307. printk("--UNKNOWN INTERRUPT:%02x:%02x:%02x--", asr, sr, phs);
  1308. spin_unlock_irqrestore(&hostdata->lock, flags);
  1309. }
  1310. DB(DB_INTR, printk("} "))
  1311. }
  1312. static void
  1313. reset_wd33c93(struct Scsi_Host *instance)
  1314. {
  1315. struct WD33C93_hostdata *hostdata =
  1316. (struct WD33C93_hostdata *) instance->hostdata;
  1317. const wd33c93_regs regs = hostdata->regs;
  1318. uchar sr;
  1319. #ifdef CONFIG_SGI_IP22
  1320. {
  1321. int busycount = 0;
  1322. extern void sgiwd93_reset(unsigned long);
  1323. /* wait 'til the chip gets some time for us */
  1324. while ((read_aux_stat(regs) & ASR_BSY) && busycount++ < 100)
  1325. udelay (10);
  1326. /*
  1327. * there are scsi devices out there, which manage to lock up
  1328. * the wd33c93 in a busy condition. In this state it won't
  1329. * accept the reset command. The only way to solve this is to
  1330. * give the chip a hardware reset (if possible). The code below
  1331. * does this for the SGI Indy, where this is possible
  1332. */
  1333. /* still busy ? */
  1334. if (read_aux_stat(regs) & ASR_BSY)
  1335. sgiwd93_reset(instance->base); /* yeah, give it the hard one */
  1336. }
  1337. #endif
  1338. write_wd33c93(regs, WD_OWN_ID, OWNID_EAF | OWNID_RAF |
  1339. instance->this_id | hostdata->clock_freq);
  1340. write_wd33c93(regs, WD_CONTROL, CTRL_IDI | CTRL_EDI | CTRL_POLLED);
  1341. write_wd33c93(regs, WD_SYNCHRONOUS_TRANSFER,
  1342. calc_sync_xfer(hostdata->default_sx_per / 4,
  1343. DEFAULT_SX_OFF, 0, hostdata->sx_table));
  1344. write_wd33c93(regs, WD_COMMAND, WD_CMD_RESET);
  1345. #ifdef CONFIG_MVME147_SCSI
  1346. udelay(25); /* The old wd33c93 on MVME147 needs this, at least */
  1347. #endif
  1348. while (!(read_aux_stat(regs) & ASR_INT))
  1349. ;
  1350. sr = read_wd33c93(regs, WD_SCSI_STATUS);
  1351. hostdata->microcode = read_wd33c93(regs, WD_CDB_1);
  1352. if (sr == 0x00)
  1353. hostdata->chip = C_WD33C93;
  1354. else if (sr == 0x01) {
  1355. write_wd33c93(regs, WD_QUEUE_TAG, 0xa5); /* any random number */
  1356. sr = read_wd33c93(regs, WD_QUEUE_TAG);
  1357. if (sr == 0xa5) {
  1358. hostdata->chip = C_WD33C93B;
  1359. write_wd33c93(regs, WD_QUEUE_TAG, 0);
  1360. } else
  1361. hostdata->chip = C_WD33C93A;
  1362. } else
  1363. hostdata->chip = C_UNKNOWN_CHIP;
  1364. if (hostdata->chip != C_WD33C93B) /* Fast SCSI unavailable */
  1365. hostdata->fast = 0;
  1366. write_wd33c93(regs, WD_TIMEOUT_PERIOD, TIMEOUT_PERIOD_VALUE);
  1367. write_wd33c93(regs, WD_CONTROL, CTRL_IDI | CTRL_EDI | CTRL_POLLED);
  1368. }
  1369. int
  1370. wd33c93_host_reset(struct scsi_cmnd * SCpnt)
  1371. {
  1372. struct Scsi_Host *instance;
  1373. struct WD33C93_hostdata *hostdata;
  1374. int i;
  1375. instance = SCpnt->device->host;
  1376. spin_lock_irq(instance->host_lock);
  1377. hostdata = (struct WD33C93_hostdata *) instance->hostdata;
  1378. printk("scsi%d: reset. ", instance->host_no);
  1379. disable_irq(instance->irq);
  1380. hostdata->dma_stop(instance, NULL, 0);
  1381. for (i = 0; i < 8; i++) {
  1382. hostdata->busy[i] = 0;
  1383. hostdata->sync_xfer[i] =
  1384. calc_sync_xfer(DEFAULT_SX_PER / 4, DEFAULT_SX_OFF,
  1385. 0, hostdata->sx_table);
  1386. hostdata->sync_stat[i] = SS_UNSET; /* using default sync values */
  1387. }
  1388. hostdata->input_Q = NULL;
  1389. hostdata->selecting = NULL;
  1390. hostdata->connected = NULL;
  1391. hostdata->disconnected_Q = NULL;
  1392. hostdata->state = S_UNCONNECTED;
  1393. hostdata->dma = D_DMA_OFF;
  1394. hostdata->incoming_ptr = 0;
  1395. hostdata->outgoing_len = 0;
  1396. reset_wd33c93(instance);
  1397. SCpnt->result = DID_RESET << 16;
  1398. enable_irq(instance->irq);
  1399. spin_unlock_irq(instance->host_lock);
  1400. return SUCCESS;
  1401. }
  1402. int
  1403. wd33c93_abort(struct scsi_cmnd * cmd)
  1404. {
  1405. struct Scsi_Host *instance;
  1406. struct WD33C93_hostdata *hostdata;
  1407. wd33c93_regs regs;
  1408. struct scsi_cmnd *tmp, *prev;
  1409. disable_irq(cmd->device->host->irq);
  1410. instance = cmd->device->host;
  1411. hostdata = (struct WD33C93_hostdata *) instance->hostdata;
  1412. regs = hostdata->regs;
  1413. /*
  1414. * Case 1 : If the command hasn't been issued yet, we simply remove it
  1415. * from the input_Q.
  1416. */
  1417. tmp = (struct scsi_cmnd *) hostdata->input_Q;
  1418. prev = NULL;
  1419. while (tmp) {
  1420. if (tmp == cmd) {
  1421. if (prev)
  1422. prev->host_scribble = cmd->host_scribble;
  1423. else
  1424. hostdata->input_Q =
  1425. (struct scsi_cmnd *) cmd->host_scribble;
  1426. cmd->host_scribble = NULL;
  1427. cmd->result = DID_ABORT << 16;
  1428. printk
  1429. ("scsi%d: Abort - removing command from input_Q. ",
  1430. instance->host_no);
  1431. enable_irq(cmd->device->host->irq);
  1432. cmd->scsi_done(cmd);
  1433. return SUCCESS;
  1434. }
  1435. prev = tmp;
  1436. tmp = (struct scsi_cmnd *) tmp->host_scribble;
  1437. }
  1438. /*
  1439. * Case 2 : If the command is connected, we're going to fail the abort
  1440. * and let the high level SCSI driver retry at a later time or
  1441. * issue a reset.
  1442. *
  1443. * Timeouts, and therefore aborted commands, will be highly unlikely
  1444. * and handling them cleanly in this situation would make the common
  1445. * case of noresets less efficient, and would pollute our code. So,
  1446. * we fail.
  1447. */
  1448. if (hostdata->connected == cmd) {
  1449. uchar sr, asr;
  1450. unsigned long timeout;
  1451. printk("scsi%d: Aborting connected command - ",
  1452. instance->host_no);
  1453. printk("stopping DMA - ");
  1454. if (hostdata->dma == D_DMA_RUNNING) {
  1455. hostdata->dma_stop(instance, cmd, 0);
  1456. hostdata->dma = D_DMA_OFF;
  1457. }
  1458. printk("sending wd33c93 ABORT command - ");
  1459. write_wd33c93(regs, WD_CONTROL,
  1460. CTRL_IDI | CTRL_EDI | CTRL_POLLED);
  1461. write_wd33c93_cmd(regs, WD_CMD_ABORT);
  1462. /* Now we have to attempt to flush out the FIFO... */
  1463. printk("flushing fifo - ");
  1464. timeout = 1000000;
  1465. do {
  1466. asr = read_aux_stat(regs);
  1467. if (asr & ASR_DBR)
  1468. read_wd33c93(regs, WD_DATA);
  1469. } while (!(asr & ASR_INT) && timeout-- > 0);
  1470. sr = read_wd33c93(regs, WD_SCSI_STATUS);
  1471. printk
  1472. ("asr=%02x, sr=%02x, %ld bytes un-transferred (timeout=%ld) - ",
  1473. asr, sr, read_wd33c93_count(regs), timeout);
  1474. /*
  1475. * Abort command processed.
  1476. * Still connected.
  1477. * We must disconnect.
  1478. */
  1479. printk("sending wd33c93 DISCONNECT command - ");
  1480. write_wd33c93_cmd(regs, WD_CMD_DISCONNECT);
  1481. timeout = 1000000;
  1482. asr = read_aux_stat(regs);
  1483. while ((asr & ASR_CIP) && timeout-- > 0)
  1484. asr = read_aux_stat(regs);
  1485. sr = read_wd33c93(regs, WD_SCSI_STATUS);
  1486. printk("asr=%02x, sr=%02x.", asr, sr);
  1487. hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun & 0xff));
  1488. hostdata->connected = NULL;
  1489. hostdata->state = S_UNCONNECTED;
  1490. cmd->result = DID_ABORT << 16;
  1491. /* sti();*/
  1492. wd33c93_execute(instance);
  1493. enable_irq(cmd->device->host->irq);
  1494. cmd->scsi_done(cmd);
  1495. return SUCCESS;
  1496. }
  1497. /*
  1498. * Case 3: If the command is currently disconnected from the bus,
  1499. * we're not going to expend much effort here: Let's just return
  1500. * an ABORT_SNOOZE and hope for the best...
  1501. */
  1502. tmp = (struct scsi_cmnd *) hostdata->disconnected_Q;
  1503. while (tmp) {
  1504. if (tmp == cmd) {
  1505. printk
  1506. ("scsi%d: Abort - command found on disconnected_Q - ",
  1507. instance->host_no);
  1508. printk("Abort SNOOZE. ");
  1509. enable_irq(cmd->device->host->irq);
  1510. return FAILED;
  1511. }
  1512. tmp = (struct scsi_cmnd *) tmp->host_scribble;
  1513. }
  1514. /*
  1515. * Case 4 : If we reached this point, the command was not found in any of
  1516. * the queues.
  1517. *
  1518. * We probably reached this point because of an unlikely race condition
  1519. * between the command completing successfully and the abortion code,
  1520. * so we won't panic, but we will notify the user in case something really
  1521. * broke.
  1522. */
  1523. /* sti();*/
  1524. wd33c93_execute(instance);
  1525. enable_irq(cmd->device->host->irq);
  1526. printk("scsi%d: warning : SCSI command probably completed successfully"
  1527. " before abortion. ", instance->host_no);
  1528. return FAILED;
  1529. }
  1530. #define MAX_WD33C93_HOSTS 4
  1531. #define MAX_SETUP_ARGS ARRAY_SIZE(setup_args)
  1532. #define SETUP_BUFFER_SIZE 200
  1533. static char setup_buffer[SETUP_BUFFER_SIZE];
  1534. static char setup_used[MAX_SETUP_ARGS];
  1535. static int done_setup = 0;
  1536. static int
  1537. wd33c93_setup(char *str)
  1538. {
  1539. int i;
  1540. char *p1, *p2;
  1541. /* The kernel does some processing of the command-line before calling
  1542. * this function: If it begins with any decimal or hex number arguments,
  1543. * ints[0] = how many numbers found and ints[1] through [n] are the values
  1544. * themselves. str points to where the non-numeric arguments (if any)
  1545. * start: We do our own parsing of those. We construct synthetic 'nosync'
  1546. * keywords out of numeric args (to maintain compatibility with older
  1547. * versions) and then add the rest of the arguments.
  1548. */
  1549. p1 = setup_buffer;
  1550. *p1 = '\0';
  1551. if (str)
  1552. strncpy(p1, str, SETUP_BUFFER_SIZE - strlen(setup_buffer));
  1553. setup_buffer[SETUP_BUFFER_SIZE - 1] = '\0';
  1554. p1 = setup_buffer;
  1555. i = 0;
  1556. while (*p1 && (i < MAX_SETUP_ARGS)) {
  1557. p2 = strchr(p1, ',');
  1558. if (p2) {
  1559. *p2 = '\0';
  1560. if (p1 != p2)
  1561. setup_args[i] = p1;
  1562. p1 = p2 + 1;
  1563. i++;
  1564. } else {
  1565. setup_args[i] = p1;
  1566. break;
  1567. }
  1568. }
  1569. for (i = 0; i < MAX_SETUP_ARGS; i++)
  1570. setup_used[i] = 0;
  1571. done_setup = 1;
  1572. return 1;
  1573. }
  1574. __setup("wd33c93=", wd33c93_setup);
  1575. /* check_setup_args() returns index if key found, 0 if not
  1576. */
  1577. static int
  1578. check_setup_args(char *key, int *flags, int *val, char *buf)
  1579. {
  1580. int x;
  1581. char *cp;
  1582. for (x = 0; x < MAX_SETUP_ARGS; x++) {
  1583. if (setup_used[x])
  1584. continue;
  1585. if (!strncmp(setup_args[x], key, strlen(key)))
  1586. break;
  1587. if (!strncmp(setup_args[x], "next", strlen("next")))
  1588. return 0;
  1589. }
  1590. if (x == MAX_SETUP_ARGS)
  1591. return 0;
  1592. setup_used[x] = 1;
  1593. cp = setup_args[x] + strlen(key);
  1594. *val = -1;
  1595. if (*cp != ':')
  1596. return ++x;
  1597. cp++;
  1598. if ((*cp >= '0') && (*cp <= '9')) {
  1599. *val = simple_strtoul(cp, NULL, 0);
  1600. }
  1601. return ++x;
  1602. }
  1603. /*
  1604. * Calculate internal data-transfer-clock cycle from input-clock
  1605. * frequency (/MHz) and fill 'sx_table'.
  1606. *
  1607. * The original driver used to rely on a fixed sx_table, containing periods
  1608. * for (only) the lower limits of the respective input-clock-frequency ranges
  1609. * (8-10/12-15/16-20 MHz). Although it seems, that no problems occurred with
  1610. * this setting so far, it might be desirable to adjust the transfer periods
  1611. * closer to the really attached, possibly 25% higher, input-clock, since
  1612. * - the wd33c93 may really use a significant shorter period, than it has
  1613. * negotiated (eg. thrashing the target, which expects 4/8MHz, with 5/10MHz
  1614. * instead).
  1615. * - the wd33c93 may ask the target for a lower transfer rate, than the target
  1616. * is capable of (eg. negotiating for an assumed minimum of 252ns instead of
  1617. * possible 200ns, which indeed shows up in tests as an approx. 10% lower
  1618. * transfer rate).
  1619. */
  1620. static inline unsigned int
  1621. round_4(unsigned int x)
  1622. {
  1623. switch (x & 3) {
  1624. case 1: --x;
  1625. break;
  1626. case 2: ++x;
  1627. case 3: ++x;
  1628. }
  1629. return x;
  1630. }
  1631. static void
  1632. calc_sx_table(unsigned int mhz, struct sx_period sx_table[9])
  1633. {
  1634. unsigned int d, i;
  1635. if (mhz < 11)
  1636. d = 2; /* divisor for 8-10 MHz input-clock */
  1637. else if (mhz < 16)
  1638. d = 3; /* divisor for 12-15 MHz input-clock */
  1639. else
  1640. d = 4; /* divisor for 16-20 MHz input-clock */
  1641. d = (100000 * d) / 2 / mhz; /* 100 x DTCC / nanosec */
  1642. sx_table[0].period_ns = 1;
  1643. sx_table[0].reg_value = 0x20;
  1644. for (i = 1; i < 8; i++) {
  1645. sx_table[i].period_ns = round_4((i+1)*d / 100);
  1646. sx_table[i].reg_value = (i+1)*0x10;
  1647. }
  1648. sx_table[7].reg_value = 0;
  1649. sx_table[8].period_ns = 0;
  1650. sx_table[8].reg_value = 0;
  1651. }
  1652. /*
  1653. * check and, maybe, map an init- or "clock:"- argument.
  1654. */
  1655. static uchar
  1656. set_clk_freq(int freq, int *mhz)
  1657. {
  1658. int x = freq;
  1659. if (WD33C93_FS_8_10 == freq)
  1660. freq = 8;
  1661. else if (WD33C93_FS_12_15 == freq)
  1662. freq = 12;
  1663. else if (WD33C93_FS_16_20 == freq)
  1664. freq = 16;
  1665. else if (freq > 7 && freq < 11)
  1666. x = WD33C93_FS_8_10;
  1667. else if (freq > 11 && freq < 16)
  1668. x = WD33C93_FS_12_15;
  1669. else if (freq > 15 && freq < 21)
  1670. x = WD33C93_FS_16_20;
  1671. else {
  1672. /* Hmm, wouldn't it be safer to assume highest freq here? */
  1673. x = WD33C93_FS_8_10;
  1674. freq = 8;
  1675. }
  1676. *mhz = freq;
  1677. return x;
  1678. }
  1679. /*
  1680. * to be used with the resync: fast: ... options
  1681. */
  1682. static inline void set_resync ( struct WD33C93_hostdata *hd, int mask )
  1683. {
  1684. int i;
  1685. for (i = 0; i < 8; i++)
  1686. if (mask & (1 << i))
  1687. hd->sync_stat[i] = SS_UNSET;
  1688. }
  1689. void
  1690. wd33c93_init(struct Scsi_Host *instance, const wd33c93_regs regs,
  1691. dma_setup_t setup, dma_stop_t stop, int clock_freq)
  1692. {
  1693. struct WD33C93_hostdata *hostdata;
  1694. int i;
  1695. int flags;
  1696. int val;
  1697. char buf[32];
  1698. if (!done_setup && setup_strings)
  1699. wd33c93_setup(setup_strings);
  1700. hostdata = (struct WD33C93_hostdata *) instance->hostdata;
  1701. hostdata->regs = regs;
  1702. hostdata->clock_freq = set_clk_freq(clock_freq, &i);
  1703. calc_sx_table(i, hostdata->sx_table);
  1704. hostdata->dma_setup = setup;
  1705. hostdata->dma_stop = stop;
  1706. hostdata->dma_bounce_buffer = NULL;
  1707. hostdata->dma_bounce_len = 0;
  1708. for (i = 0; i < 8; i++) {
  1709. hostdata->busy[i] = 0;
  1710. hostdata->sync_xfer[i] =
  1711. calc_sync_xfer(DEFAULT_SX_PER / 4, DEFAULT_SX_OFF,
  1712. 0, hostdata->sx_table);
  1713. hostdata->sync_stat[i] = SS_UNSET; /* using default sync values */
  1714. #ifdef PROC_STATISTICS
  1715. hostdata->cmd_cnt[i] = 0;
  1716. hostdata->disc_allowed_cnt[i] = 0;
  1717. hostdata->disc_done_cnt[i] = 0;
  1718. #endif
  1719. }
  1720. hostdata->input_Q = NULL;
  1721. hostdata->selecting = NULL;
  1722. hostdata->connected = NULL;
  1723. hostdata->disconnected_Q = NULL;
  1724. hostdata->state = S_UNCONNECTED;
  1725. hostdata->dma = D_DMA_OFF;
  1726. hostdata->level2 = L2_BASIC;
  1727. hostdata->disconnect = DIS_ADAPTIVE;
  1728. hostdata->args = DEBUG_DEFAULTS;
  1729. hostdata->incoming_ptr = 0;
  1730. hostdata->outgoing_len = 0;
  1731. hostdata->default_sx_per = DEFAULT_SX_PER;
  1732. hostdata->no_dma = 0; /* default is DMA enabled */
  1733. #ifdef PROC_INTERFACE
  1734. hostdata->proc = PR_VERSION | PR_INFO | PR_STATISTICS |
  1735. PR_CONNECTED | PR_INPUTQ | PR_DISCQ | PR_STOP;
  1736. #ifdef PROC_STATISTICS
  1737. hostdata->dma_cnt = 0;
  1738. hostdata->pio_cnt = 0;
  1739. hostdata->int_cnt = 0;
  1740. #endif
  1741. #endif
  1742. if (check_setup_args("clock", &flags, &val, buf)) {
  1743. hostdata->clock_freq = set_clk_freq(val, &val);
  1744. calc_sx_table(val, hostdata->sx_table);
  1745. }
  1746. if (check_setup_args("nosync", &flags, &val, buf))
  1747. hostdata->no_sync = val;
  1748. if (check_setup_args("nodma", &flags, &val, buf))
  1749. hostdata->no_dma = (val == -1) ? 1 : val;
  1750. if (check_setup_args("period", &flags, &val, buf))
  1751. hostdata->default_sx_per =
  1752. hostdata->sx_table[round_period((unsigned int) val,
  1753. hostdata->sx_table)].period_ns;
  1754. if (check_setup_args("disconnect", &flags, &val, buf)) {
  1755. if ((val >= DIS_NEVER) && (val <= DIS_ALWAYS))
  1756. hostdata->disconnect = val;
  1757. else
  1758. hostdata->disconnect = DIS_ADAPTIVE;
  1759. }
  1760. if (check_setup_args("level2", &flags, &val, buf))
  1761. hostdata->level2 = val;
  1762. if (check_setup_args("debug", &flags, &val, buf))
  1763. hostdata->args = val & DB_MASK;
  1764. if (check_setup_args("burst", &flags, &val, buf))
  1765. hostdata->dma_mode = val ? CTRL_BURST:CTRL_DMA;
  1766. if (WD33C93_FS_16_20 == hostdata->clock_freq /* divisor 4 */
  1767. && check_setup_args("fast", &flags, &val, buf))
  1768. hostdata->fast = !!val;
  1769. if ((i = check_setup_args("next", &flags, &val, buf))) {
  1770. while (i)
  1771. setup_used[--i] = 1;
  1772. }
  1773. #ifdef PROC_INTERFACE
  1774. if (check_setup_args("proc", &flags, &val, buf))
  1775. hostdata->proc = val;
  1776. #endif
  1777. spin_lock_irq(&hostdata->lock);
  1778. reset_wd33c93(instance);
  1779. spin_unlock_irq(&hostdata->lock);
  1780. printk("wd33c93-%d: chip=%s/%d no_sync=0x%x no_dma=%d",
  1781. instance->host_no,
  1782. (hostdata->chip == C_WD33C93) ? "WD33c93" : (hostdata->chip ==
  1783. C_WD33C93A) ?
  1784. "WD33c93A" : (hostdata->chip ==
  1785. C_WD33C93B) ? "WD33c93B" : "unknown",
  1786. hostdata->microcode, hostdata->no_sync, hostdata->no_dma);
  1787. #ifdef DEBUGGING_ON
  1788. printk(" debug_flags=0x%02x\n", hostdata->args);
  1789. #else
  1790. printk(" debugging=OFF\n");
  1791. #endif
  1792. printk(" setup_args=");
  1793. for (i = 0; i < MAX_SETUP_ARGS; i++)
  1794. printk("%s,", setup_args[i]);
  1795. printk("\n");
  1796. printk(" Version %s - %s\n", WD33C93_VERSION, WD33C93_DATE);
  1797. }
  1798. int wd33c93_write_info(struct Scsi_Host *instance, char *buf, int len)
  1799. {
  1800. #ifdef PROC_INTERFACE
  1801. char *bp;
  1802. struct WD33C93_hostdata *hd;
  1803. int x;
  1804. hd = (struct WD33C93_hostdata *) instance->hostdata;
  1805. /* We accept the following
  1806. * keywords (same format as command-line, but arguments are not optional):
  1807. * debug
  1808. * disconnect
  1809. * period
  1810. * resync
  1811. * proc
  1812. * nodma
  1813. * level2
  1814. * burst
  1815. * fast
  1816. * nosync
  1817. */
  1818. buf[len] = '\0';
  1819. for (bp = buf; *bp; ) {
  1820. while (',' == *bp || ' ' == *bp)
  1821. ++bp;
  1822. if (!strncmp(bp, "debug:", 6)) {
  1823. hd->args = simple_strtoul(bp+6, &bp, 0) & DB_MASK;
  1824. } else if (!strncmp(bp, "disconnect:", 11)) {
  1825. x = simple_strtoul(bp+11, &bp, 0);
  1826. if (x < DIS_NEVER || x > DIS_ALWAYS)
  1827. x = DIS_ADAPTIVE;
  1828. hd->disconnect = x;
  1829. } else if (!strncmp(bp, "period:", 7)) {
  1830. x = simple_strtoul(bp+7, &bp, 0);
  1831. hd->default_sx_per =
  1832. hd->sx_table[round_period((unsigned int) x,
  1833. hd->sx_table)].period_ns;
  1834. } else if (!strncmp(bp, "resync:", 7)) {
  1835. set_resync(hd, (int)simple_strtoul(bp+7, &bp, 0));
  1836. } else if (!strncmp(bp, "proc:", 5)) {
  1837. hd->proc = simple_strtoul(bp+5, &bp, 0);
  1838. } else if (!strncmp(bp, "nodma:", 6)) {
  1839. hd->no_dma = simple_strtoul(bp+6, &bp, 0);
  1840. } else if (!strncmp(bp, "level2:", 7)) {
  1841. hd->level2 = simple_strtoul(bp+7, &bp, 0);
  1842. } else if (!strncmp(bp, "burst:", 6)) {
  1843. hd->dma_mode =
  1844. simple_strtol(bp+6, &bp, 0) ? CTRL_BURST:CTRL_DMA;
  1845. } else if (!strncmp(bp, "fast:", 5)) {
  1846. x = !!simple_strtol(bp+5, &bp, 0);
  1847. if (x != hd->fast)
  1848. set_resync(hd, 0xff);
  1849. hd->fast = x;
  1850. } else if (!strncmp(bp, "nosync:", 7)) {
  1851. x = simple_strtoul(bp+7, &bp, 0);
  1852. set_resync(hd, x ^ hd->no_sync);
  1853. hd->no_sync = x;
  1854. } else {
  1855. break; /* unknown keyword,syntax-error,... */
  1856. }
  1857. }
  1858. return len;
  1859. #else
  1860. return 0;
  1861. #endif
  1862. }
  1863. int
  1864. wd33c93_show_info(struct seq_file *m, struct Scsi_Host *instance)
  1865. {
  1866. #ifdef PROC_INTERFACE
  1867. struct WD33C93_hostdata *hd;
  1868. struct scsi_cmnd *cmd;
  1869. int x;
  1870. hd = (struct WD33C93_hostdata *) instance->hostdata;
  1871. spin_lock_irq(&hd->lock);
  1872. if (hd->proc & PR_VERSION)
  1873. seq_printf(m, "\nVersion %s - %s.",
  1874. WD33C93_VERSION, WD33C93_DATE);
  1875. if (hd->proc & PR_INFO) {
  1876. seq_printf(m, "\nclock_freq=%02x no_sync=%02x no_dma=%d"
  1877. " dma_mode=%02x fast=%d",
  1878. hd->clock_freq, hd->no_sync, hd->no_dma, hd->dma_mode, hd->fast);
  1879. seq_puts(m, "\nsync_xfer[] = ");
  1880. for (x = 0; x < 7; x++)
  1881. seq_printf(m, "\t%02x", hd->sync_xfer[x]);
  1882. seq_puts(m, "\nsync_stat[] = ");
  1883. for (x = 0; x < 7; x++)
  1884. seq_printf(m, "\t%02x", hd->sync_stat[x]);
  1885. }
  1886. #ifdef PROC_STATISTICS
  1887. if (hd->proc & PR_STATISTICS) {
  1888. seq_puts(m, "\ncommands issued: ");
  1889. for (x = 0; x < 7; x++)
  1890. seq_printf(m, "\t%ld", hd->cmd_cnt[x]);
  1891. seq_puts(m, "\ndisconnects allowed:");
  1892. for (x = 0; x < 7; x++)
  1893. seq_printf(m, "\t%ld", hd->disc_allowed_cnt[x]);
  1894. seq_puts(m, "\ndisconnects done: ");
  1895. for (x = 0; x < 7; x++)
  1896. seq_printf(m, "\t%ld", hd->disc_done_cnt[x]);
  1897. seq_printf(m,
  1898. "\ninterrupts: %ld, DATA_PHASE ints: %ld DMA, %ld PIO",
  1899. hd->int_cnt, hd->dma_cnt, hd->pio_cnt);
  1900. }
  1901. #endif
  1902. if (hd->proc & PR_CONNECTED) {
  1903. seq_puts(m, "\nconnected: ");
  1904. if (hd->connected) {
  1905. cmd = (struct scsi_cmnd *) hd->connected;
  1906. seq_printf(m, " %d:%llu(%02x)",
  1907. cmd->device->id, cmd->device->lun, cmd->cmnd[0]);
  1908. }
  1909. }
  1910. if (hd->proc & PR_INPUTQ) {
  1911. seq_puts(m, "\ninput_Q: ");
  1912. cmd = (struct scsi_cmnd *) hd->input_Q;
  1913. while (cmd) {
  1914. seq_printf(m, " %d:%llu(%02x)",
  1915. cmd->device->id, cmd->device->lun, cmd->cmnd[0]);
  1916. cmd = (struct scsi_cmnd *) cmd->host_scribble;
  1917. }
  1918. }
  1919. if (hd->proc & PR_DISCQ) {
  1920. seq_puts(m, "\ndisconnected_Q:");
  1921. cmd = (struct scsi_cmnd *) hd->disconnected_Q;
  1922. while (cmd) {
  1923. seq_printf(m, " %d:%llu(%02x)",
  1924. cmd->device->id, cmd->device->lun, cmd->cmnd[0]);
  1925. cmd = (struct scsi_cmnd *) cmd->host_scribble;
  1926. }
  1927. }
  1928. seq_putc(m, '\n');
  1929. spin_unlock_irq(&hd->lock);
  1930. #endif /* PROC_INTERFACE */
  1931. return 0;
  1932. }
  1933. EXPORT_SYMBOL(wd33c93_host_reset);
  1934. EXPORT_SYMBOL(wd33c93_init);
  1935. EXPORT_SYMBOL(wd33c93_abort);
  1936. EXPORT_SYMBOL(wd33c93_queuecommand);
  1937. EXPORT_SYMBOL(wd33c93_intr);
  1938. EXPORT_SYMBOL(wd33c93_show_info);
  1939. EXPORT_SYMBOL(wd33c93_write_info);