tmscsim.txt 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. The tmscsim driver
  2. ==================
  3. 1. Purpose and history
  4. 2. Installation
  5. 3. Features
  6. 4. Configuration via /proc/scsi/tmscsim/?
  7. 5. Configuration via boot/module params
  8. 6. Potential improvements
  9. 7. Bug reports, debugging and updates
  10. 8. Acknowledgements
  11. 9. Copyright
  12. 1. Purpose and history
  13. ----------------------
  14. The tmscsim driver supports PCI SCSI Host Adapters based on the AM53C974
  15. chip. AM53C974 based SCSI adapters include:
  16. Tekram DC390, DC390T
  17. Dawicontrol 2974
  18. QLogic Fast! PCI Basic
  19. some on-board adapters
  20. (This is most probably not a complete list)
  21. It has originally written by C.L. Huang from the Tekram corp. to support the
  22. Tekram DC390(T) adapter. This is where the name comes from: tm = Tekram
  23. scsi = SCSI driver, m = AMD (?) as opposed to w for the DC390W/U/F
  24. (NCR53c8X5, X=2/7) driver. Yes, there was also a driver for the latter,
  25. tmscsiw, which supported DC390W/U/F adapters. It's not maintained any more,
  26. as the ncr53c8xx is perfectly supporting these adapters since some time.
  27. The driver first appeared in April 1996, exclusively supported the DC390
  28. and has been enhanced since then in various steps. In May 1998 support for
  29. general AM53C974 based adapters and some possibilities to configure it were
  30. added. The non-DC390 support works by assuming some values for the data
  31. normally taken from the DC390 EEPROM. See below (chapter 5) for details.
  32. When using the DC390, the configuration is still be done using the DC390
  33. BIOS setup. The DC390 EEPROM is read and used by the driver, any boot or
  34. module parameters (chapter 5) are ignored! However, you can change settings
  35. dynamically, as described in chapter 4.
  36. For a more detailed description of the driver's history, see the first lines
  37. of tmscsim.c.
  38. The numbering scheme isn't consistent. The first versions went from 1.00 to
  39. 1.12, then 1.20a to 1.20t. Finally I decided to use the ncr53c8xx scheme. So
  40. the next revisions will be 2.0a to 2.0X (stable), 2.1a to 2.1X (experimental),
  41. 2.2a to 2.2X (stable, again) etc. (X = anything between a and z.) If I send
  42. fixes to people for testing, I create intermediate versions with a digit
  43. appended, e.g. 2.0c3.
  44. 2. Installation
  45. ---------------
  46. If you got any recent kernel with this driver and document included in
  47. linux/drivers/scsi, you basically have to do nothing special to use this
  48. driver. Of course you have to choose to compile SCSI support and DC390(T)
  49. support into your kernel or as module when configuring your kernel for
  50. compiling.
  51. NEW: You may as well compile this module outside your kernel, using the
  52. supplied Makefile.
  53. If you got an old kernel (pre 2.1.127, pre 2.0.37p1) with an old version of
  54. this driver: Get dc390-21125-20b.diff.gz or dc390-2036p21-20b1.diff.gz from
  55. my web page and apply the patch. Apply further patches to upgrade to the
  56. latest version of the driver.
  57. If you want to do it manually, you should copy the files (dc390.h,
  58. tmscsim.h, tmscsim.c, scsiiom.c and README.tmscsim) from this directory to
  59. linux/drivers/scsi. You have to recompile your kernel/module of course.
  60. You should apply the three patches included in dc390-120-kernel.diff
  61. (Applying them: cd /usr/src; patch -p0 <~/dc390-120-kernel.diff)
  62. The patches are against 2.1.125, so you might have to manually resolve
  63. rejections when applying to another kernel version.
  64. The patches will update the kernel startup code to allow boot parameters to
  65. be passed to the driver, update the Documentation and finally offer you the
  66. possibility to omit the non-DC390 parts of the driver.
  67. (By selecting "Omit support for non DC390" you basically disable the
  68. emulation of a DC390 EEPROM for non DC390 adapters. This saves a few bytes
  69. of memory.)
  70. If you got a very old kernel without the tmscsim driver (pre 2.0.31)
  71. I recommend upgrading your kernel. However, if you don't want to, please
  72. contact me to get the appropriate patches.
  73. Upgrading a SCSI driver is always a delicate thing to do. The 2.0 driver has
  74. proven stable on many systems, but it's still a good idea to take some
  75. precautions. In an ideal world you would have a full backup of your disks.
  76. The world isn't ideal and most people don't have full backups (me neither).
  77. So take at least the following measures:
  78. * make your kernel remount the FS read-only on detecting an error:
  79. tune2fs -e remount-ro /dev/sd??
  80. * have copies of your SCSI disk's partition tables on some safe location:
  81. dd if=/dev/sda of=/mnt/floppy/sda bs=512 count=1
  82. or just print it with:
  83. fdisk -l | lpr
  84. * make sure you are able to boot Linux (e.g. from floppy disk using InitRD)
  85. if your SCSI disk gets corrupted. You can use
  86. ftp://student.physik.uni-dortmund.de/pub/linux/kernel/bootdisk.gz
  87. One more warning: I used to overclock my PCI bus to 41.67 MHz. My Tekram
  88. DC390F (Sym53c875) accepted this as well as my Millenium. But the Am53C974
  89. produced errors and started to corrupt my disks. So don't do that! A 37.50
  90. MHz PCI bus works for me, though, but I don't recommend using higher clocks
  91. than the 33.33 MHz being in the PCI spec.
  92. If you want to share the IRQ with another device and the driver refuses to
  93. do so, you might succeed with changing the DC390_IRQ type in tmscsim.c to
  94. IRQF_SHARED | IRQF_DISABLED.
  95. 3.Features
  96. ----------
  97. - SCSI
  98. * Tagged command queueing
  99. * Sync speed up to 10 MHz
  100. * Disconnection
  101. * Multiple LUNs
  102. - General / Linux interface
  103. * Support for up to 4 AM53C974 adapters.
  104. * DC390 EEPROM usage or boot/module params
  105. * Information via cat /proc/scsi/tmscsim/?
  106. * Dynamically configurable by writing to /proc/scsi/tmscsim/?
  107. * Dynamic allocation of resources
  108. * SMP support: Locking on io_request lock (Linux 2.1/2.2) or adapter
  109. specific locks (Linux 2.5?)
  110. * Uniform source code for Linux-2.x.y
  111. * Support for dyn. addition/removal of devices via add/remove-single-device
  112. (Try: echo "scsi add-single-device C B T U" >/proc/scsi/scsi
  113. C = Controller, B = Bus, T = Target SCSI ID, U = Unit SCSI LUN.)
  114. Use with care!
  115. * Try to use the partition table for the determination of the mapping
  116. 4. Configuration via /proc/scsi/tmscsim/?
  117. -----------------------------------------
  118. First of all look at the output of /proc/scsi/tmscsim/? by typing
  119. cat /proc/scsi/tmscsim/?
  120. The "?" should be replaced by the SCSI host number. (The shell might do this
  121. for you.)
  122. You will see some info regarding the adapter and, at the end, a listing of
  123. the attached devices and their settings.
  124. Here's an example:
  125. garloff@kurt:/home/garloff > cat /proc/scsi/tmscsim/0
  126. Tekram DC390/AM53C974 PCI SCSI Host Adapter, Driver Version 2.0e7 2000-11-28
  127. SCSI Host Nr 1, AM53C974 Adapter Nr 0
  128. IOPortBase 0xb000, IRQ 10
  129. MaxID 8, MaxLUN 8, AdapterID 6, SelTimeout 250 ms, DelayReset 1 s
  130. TagMaxNum 16, Status 0x00, ACBFlag 0x00, GlitchEater 24 ns
  131. Statistics: Cmnds 1470165, Cmnds not sent directly 0, Out of SRB conds 0
  132. Lost arbitrations 587, Sel. connected 0, Connected: No
  133. Nr of attached devices: 4, Nr of DCBs: 4
  134. Map of attached LUNs: 01 00 00 03 01 00 00 00
  135. Idx ID LUN Prty Sync DsCn SndS TagQ NegoPeriod SyncSpeed SyncOffs MaxCmd
  136. 00 00 00 Yes Yes Yes Yes Yes 100 ns 10.0 M 15 16
  137. 01 03 00 Yes Yes Yes Yes No 100 ns 10.0 M 15 01
  138. 02 03 01 Yes Yes Yes Yes No 100 ns 10.0 M 15 01
  139. 03 04 00 Yes Yes Yes Yes No 100 ns 10.0 M 15 01
  140. Note that the settings MaxID and MaxLUN are not zero- but one-based, which
  141. means that a setting MaxLUN=4, will result in the support of LUNs 0..3. This
  142. is somehow inconvenient, but the way the mid-level SCSI code expects it to be.
  143. ACB and DCB are acronyms for Adapter Control Block and Device Control Block.
  144. These are data structures of the driver containing information about the
  145. adapter and the connected SCSI devices respectively.
  146. Idx is the device index (just a consecutive number for the driver), ID and
  147. LUN are the SCSI ID and LUN, Prty means Parity checking, Sync synchronous
  148. negotiation, DsCn Disconnection, SndS Send Start command on startup (not
  149. used by the driver) and TagQ Tagged Command Queueing. NegoPeriod and
  150. SyncSpeed are somehow redundant, because they are reciprocal values
  151. (1 / 112 ns = 8.9 MHz). At least in theory. The driver is able to adjust the
  152. NegoPeriod more accurate (4ns) than the SyncSpeed (1 / 25ns). I don't know
  153. if certain devices will have problems with this discrepancy. Max. speed is
  154. 10 MHz corresp. to a min. NegoPeriod of 100 ns.
  155. (The driver allows slightly higher speeds if the devices (Ultra SCSI) accept
  156. it, but that's out of adapter spec, on your own risk and unlikely to improve
  157. performance. You're likely to crash your disks.)
  158. SyncOffs is the offset used for synchronous negotiations; max. is 15.
  159. The last values are only shown, if Sync is enabled. (NegoPeriod is still
  160. displayed in brackets to show the values which will be used after enabling
  161. Sync.)
  162. MaxCmd ist the number of commands (=tags) which can be processed at the same
  163. time by the device.
  164. If you want to change a setting, you can do that by writing to
  165. /proc/scsi/tmscsim/?. Basically you have to imitate the output of driver.
  166. (Don't use the brackets for NegoPeriod on Sync disabled devices.)
  167. You don't have to care about capitalisation. The driver will accept space,
  168. tab, comma, = and : as separators.
  169. There are three kinds of changes:
  170. (1) Change driver settings:
  171. You type the names of the parameters and the params following it.
  172. Example:
  173. echo "MaxLUN=8 seltimeout 200" >/proc/scsi/tmscsim/0
  174. Note that you can only change MaxID, MaxLUN, AdapterID, SelTimeOut,
  175. TagMaxNum, ACBFlag, GlitchEater and DelayReset. Don't change ACBFlag
  176. unless you want to see what happens, if the driver hangs.
  177. (2) Change device settings: You write a config line to the driver. The Nr
  178. must match the ID and LUN given. If you give "-" as parameter, it is
  179. ignored and the corresponding setting won't be changed.
  180. You can use "y" or "n" instead of "Yes" and "No" if you want to.
  181. You don't need to specify a full line. The driver automatically performs
  182. an INQUIRY on the device if necessary to check if it is capable to operate
  183. with the given settings (Sync, TagQ).
  184. Examples:
  185. echo "0 0 0 y y y - y - 10 " >/proc/scsi/tmscsim/0
  186. echo "3 5 0 y n y " >/proc/scsi/tmscsim/0
  187. To give a short explanation of the first example:
  188. The first three numbers, "0 0 0" (Device index 0, SCSI ID 0, SCSI LUN 0),
  189. select the device to which the following parameters apply. Note that it
  190. would be sufficient to use the index or both SCSI ID and LUN, but I chose
  191. to require all three to have a syntax similar to the output.
  192. The following "y y y - y" enables Parity checking, enables Synchronous
  193. transfers, Disconnection, leaves Send Start (not used) untouched and
  194. enables Tagged Command Queueing for the selected device. The "-" skips
  195. the Negotiation Period setting but the "10" sets the max sync. speed to
  196. 10 MHz. It's useless to specify both NegoPeriod and SyncSpeed as
  197. discussed above. The values used in this example will result in maximum
  198. performance.
  199. (3) Special commands: You can force a SCSI bus reset, an INQUIRY command, the
  200. removal or the addition of a device's DCB and a SCSI register dump.
  201. This is only used for debugging when you meet problems. The parameter of
  202. the INQUIRY and REMOVE commands is the device index as shown by the
  203. output of /proc/scsi/tmscsim/? in the device listing in the first column
  204. (Idx). ADD takes the SCSI ID and LUN.
  205. Examples:
  206. echo "reset" >/proc/scsi/tmscsim/0
  207. echo "inquiry 1" >/proc/scsi/tmscsim/0
  208. echo "remove 2" >/proc/scsi/tmscsim/1
  209. echo "add 2 3" >/proc/scsi/tmscsim/?
  210. echo "dump" >/proc/scsi/tmscsim/0
  211. Note that you will meet problems when you REMOVE a device's DCB with the
  212. remove command if it contains partitions which are mounted. Only use it
  213. after unmounting its partitions, telling the SCSI mid-level code to
  214. remove it (scsi remove-single-device) and you really need a few bytes of
  215. memory.
  216. The ADD command allows you to configure a device before you tell the
  217. mid-level code to try detection.
  218. I'd suggest reviewing the output of /proc/scsi/tmscsim/? after changing
  219. settings to see if everything changed as requested.
  220. 5. Configuration via boot/module parameters
  221. -------------------------------------------
  222. With the DC390, the driver reads its EEPROM settings and tries to use them.
  223. But you may want to override the settings prior to being able to change the
  224. driver configuration via /proc/scsi/tmscsim/?.
  225. If you do have another AM53C974 based adapter, that's even the only
  226. possibility to adjust settings before you are able to write to the
  227. /proc/scsi/tmscsim/? pseudo-file, e.g. if you want to use another
  228. adapter ID than 7.
  229. (BTW, the log message "DC390: No EEPROM found!" is normal without a DC390.)
  230. For this purpose, you can pass options to the driver before it is initialised
  231. by using kernel or module parameters. See lilo(8) or modprobe(1) manual
  232. pages on how to pass params to the kernel or a module.
  233. [NOTE: Formerly, it was not possible to override the EEPROM supplied
  234. settings of the DC390 with cmd line parameters. This has changed since
  235. 2.0e7]
  236. The syntax of the params is much shorter than the syntax of the /proc/...
  237. interface. This makes it a little bit more difficult to use. However, long
  238. parameter lines have the risk to be misinterpreted and the length of kernel
  239. parameters is limited.
  240. As the support for non-DC390 adapters works by simulating the values of the
  241. DC390 EEPROM, the settings are given in a DC390 BIOS' way.
  242. Here's the syntax:
  243. tmscsim=AdaptID,SpdIdx,DevMode,AdaptMode,TaggedCmnds,DelayReset
  244. Each of the parameters is a number, containing the described information:
  245. * AdaptID: The SCSI ID of the host adapter. Must be in the range 0..7
  246. Default is 7.
  247. * SpdIdx: The index of the maximum speed as in the DC390 BIOS. The values
  248. 0..7 mean 10, 8.0, 6.7, 5.7, 5.0, 4.0, 3.1 and 2 MHz resp. Default is
  249. 0 (10.0 MHz).
  250. * DevMode is a bit mapped value describing the per-device features. It
  251. applies to all devices. (Sync, Disc and TagQ will only apply, if the
  252. device supports it.) The meaning of the bits (* = default):
  253. Bit Val(hex) Val(dec) Meaning
  254. *0 0x01 1 Parity check
  255. *1 0x02 2 Synchronous Negotiation
  256. *2 0x04 4 Disconnection
  257. *3 0x08 8 Send Start command on startup. (Not used)
  258. *4 0x10 16 Tagged Command Queueing
  259. As usual, the desired value is obtained by adding the wanted values. If
  260. you want to enable all values, e.g., you would use 31(0x1f). Default is 31.
  261. * AdaptMode is a bit mapped value describing the enabled adapter features.
  262. Bit Val(hex) Val(dec) Meaning
  263. *0 0x01 1 Support more than two drives. (Not used)
  264. *1 0x02 2 Use DOS compatible mapping for HDs greater than 1GB.
  265. *2 0x04 4 Reset SCSI Bus on startup.
  266. *3 0x08 8 Active Negation: Improves SCSI Bus noise immunity.
  267. 4 0x10 16 Immediate return on BIOS seek command. (Not used)
  268. (*)5 0x20 32 Check for LUNs >= 1.
  269. The default for LUN Check depends on CONFIG_SCSI_MULTI_LUN.
  270. * TaggedCmnds is a number indicating the maximum number of Tagged Commands.
  271. It is the binary logarithm - 1 of the actual number. Max is 4 (32).
  272. Value Number of Tagged Commands
  273. 0 2
  274. 1 4
  275. 2 8
  276. *3 16
  277. 4 32
  278. * DelayReset is the time in seconds (minus 0.5s), the adapter waits, after a
  279. bus reset. Default is 1 (corresp. to 1.5s).
  280. Example:
  281. modprobe tmscsim tmscsim=6,2,31
  282. would set the adapter ID to 6, max. speed to 6.7 MHz, enable all device
  283. features and leave the adapter features, the number of Tagged Commands
  284. and the Delay after a reset to the defaults.
  285. As you can see, you don't need to specify all of the six params.
  286. If you want values to be ignored (i.e. the EEprom settings or the defaults
  287. will be used), you may pass -2 (not 0!) at the corresponding position.
  288. The defaults (7,0,31,15,3,1) are aggressive to allow good performance. You
  289. can use tmscsim=7,0,31,63,4,0 for maximum performance, if your SCSI chain
  290. allows it. If you meet problems, you can use tmscsim=-1 which is a shortcut
  291. for tmscsim=7,4,9,15,2,10.
  292. 6. Potential improvements
  293. -------------------------
  294. Most of the intended work on the driver has been done. Here are a few ideas
  295. to further improve its usability:
  296. * Cleanly separate per-Target and per-LUN properties (DCB)
  297. * More intelligent abort() routine
  298. * Use new_eh code (Linux-2.1+)
  299. * Have the mid-level (ML) code (and not the driver) handle more of the
  300. various conditions.
  301. * Command queueing in the driver: Eliminate Query list and use ML instead.
  302. * More user friendly boot/module param syntax
  303. Further investigation on these problems:
  304. * Driver hangs with sync readcdda (xcdroast) (most probably VIA PCI error)
  305. Known problems:
  306. Please see http://www.garloff.de/kurt/linux/dc390/problems.html
  307. * Changing the parameters of multi-lun by the tmscsim/? interface will
  308. cause problems, cause these settings are mostly per Target and not per LUN
  309. and should be updated accordingly. To be fixed for 2.0d24.
  310. * CDRs (eg Yam CRW4416) not recognized, because some buggy devices don't
  311. recover from a SCSI reset in time. Use a higher delay or don't issue
  312. a SCSI bus reset on driver initialization. See problems page.
  313. For the CRW4416S, this seems to be solved with firmware 1.0g (reported by
  314. Jean-Yves Barbier).
  315. * TEAC CD-532S not being recognized. (Works with 1.11).
  316. * Scanners (eg. Astra UMAX 1220S) don't work: Disable Sync Negotiation.
  317. If this does not help, try echo "INQUIRY t" >/proc/scsi/tmscsim/? (t
  318. replaced by the dev index of your scanner). You may try to reset your SCSI
  319. bus afterwards (echo "RESET" >/proc/scsi/tmscsim/?).
  320. The problem seems to be solved as of 2.0d18, thanks to Andreas Rick.
  321. * If there is a valid partition table, the driver will use it for determining
  322. the mapping. If there's none, a reasonable mapping (Symbios-like) will be
  323. assumed. Other operating systems may not like this mapping, though
  324. it's consistent with the BIOS' behaviour. Old DC390 drivers ignored the
  325. partition table and used a H/S = 64/32 or 255/63 translation. So if you
  326. want to be compatible to those, use this old mapping when creating
  327. partition tables. Even worse, on bootup the DC390 might complain if other
  328. mappings are found, so auto rebooting may fail.
  329. * In some situations, the driver will get stuck in an abort loop. This is a
  330. bad interaction between the Mid-Layer of Linux' SCSI code and the driver.
  331. Try to disable DsCn, if you meet this problem. Please contact me for
  332. further debugging.
  333. 7. Bug reports, debugging and updates
  334. -------------------------------------
  335. Whenever you have problems with the driver, you are invited to ask the
  336. author for help. However, I'd suggest reading the docs and trying to solve
  337. the problem yourself, first.
  338. If you find something, which you believe to be a bug, please report it to me.
  339. Please append the output of /proc/scsi/scsi, /proc/scsi/tmscsim/? and
  340. maybe the DC390 log messages to the report.
  341. Bug reports should be send to me (Kurt Garloff <dc390@garloff.de>) as well
  342. as to the linux-scsi list (<linux-scsi@vger.kernel.org>), as sometimes bugs
  343. are caused by the SCSI mid-level code.
  344. I will ask you for some more details and probably I will also ask you to
  345. enable some of the DEBUG options in the driver (tmscsim.c:DC390_DEBUGXXX
  346. defines). The driver will produce some data for the syslog facility then.
  347. Beware: If your syslog gets written to a SCSI disk connected to your
  348. AM53C974, the logging might produce log output again, and you might end
  349. having your box spending most of its time doing the logging.
  350. The latest version of the driver can be found at:
  351. http://www.garloff.de/kurt/linux/dc390/
  352. ftp://ftp.suse.com/pub/people/garloff/linux/dc390/
  353. 8. Acknowledgements
  354. -------------------
  355. Thanks to Linus Torvalds, Alan Cox, the FSF people, the XFree86 team and
  356. all the others for the wonderful OS and software.
  357. Thanks to C.L. Huang and Philip Giang (Tekram) for the initial driver
  358. release and support.
  359. Thanks to Doug Ledford, Gérard Roudier for support with SCSI coding.
  360. Thanks to a lot of people (espec. Chiaki Ishikawa, Andreas Haumer, Hubert
  361. Tonneau) for intensively testing the driver (and even risking data loss
  362. doing this during early revisions).
  363. Recently, SuSE GmbH, Nuernberg, FRG, has been paying me for the driver
  364. development and maintenance. Special thanks!
  365. 9. Copyright
  366. ------------
  367. This driver is free software; you can redistribute it and/or modify
  368. it under the terms of the GNU General Public License as published by
  369. the Free Software Foundation; version 2 of the License.
  370. If you want to use any later version of the GNU GPL, you will probably
  371. be allowed to, but you have to ask me and Tekram <erich@tekram.com.tw>
  372. before.
  373. -------------------------------------------------------------------------
  374. Written by Kurt Garloff <kurt@garloff.de> 1998/06/11
  375. Last updated 2000/11/28, driver revision 2.0e7
  376. $Id: tmscsim.txt,v 1.1.1.1 2007/06/12 07:27:12 eyryu Exp $