Import 2.3.18pre1
[davej-history.git] / drivers / scsi / README.tmscsim
blob99ae1e5a71fff62c30345b3c271d0b20cfbef5f3
1 The tmscsim driver
2 ==================
4 1. Purpose and history
5 2. Installation
6 3. Features
7 4. Configuration via /proc/scsi/tmscsim/?
8 5. Configuration via boot/module params
9 6. Potential improvements
10 7. Bug reports, debugging and updates
11 8. Acknowledgements
14 1. Purpose and history
15 ----------------------
16 The tmscsim driver supports PCI SCSI Host Adapters based on the AM53C974
17 chip. AM53C974 based SCSI adapters include: 
18  Tekram DC390, DC390T
19  Dawicontrol 2974
20  QLogic Fast! PCI Basic
21  some on-board adapters
22 (This is most probably not a complete list)
24 It has originally written by C.L. Huang from the Tekram corp. to support the
25 Tekram DC390(T) adapter. This is where the name comes from: tm = Tekram
26 scsi = SCSI driver, m = AMD (?) as opposed to w for the DC390W/U/F
27 (NCR53c8X5, X=2/7) driver. Yes, there was also a driver for the latter,
28 tmscsimw, which supported DC390W/U/F adapters. It's not maintained any more,
29 as the ncr53c8xx is perfectly supporting these adpaters since some time.
31 The driver first appeared in April 1996, exclusively supported the DC390 
32 and has been enhanced since then in various steps. In May 1998 support for 
33 general AM53C974 based adapters and some possibilities to configure it were
34 added. The non-DC390 support works by assuming some values for the data
35 normally taken from the DC390 EEPROM. See below (chapter 5) for details.
37 When using the DC390, the configuration is still be done using the DC390
38 BIOS setup. The DC390 EEPROM is read and used by the driver, any boot or
39 module parameters (chapter 5) are ignored! However, you can change settings
40 dynamically, as described in chapter 4. 
42 For a more detailed description of the driver's history, see the first lines
43 of tmscsim.c.
44 The numbering scheme isn't consistent. The first versions went from 1.00 to
45 1.12, then 1.20a to 1.20t. Finally I decided to use the ncr53c8xx scheme. So
46 the next revisions will be 2.0a to 2.0X (stable), 2.1a to 2.1X (experimental),
47 2.2a to 2.2X (stable, again) etc. (X = anything between a and z.) If I send
48 fixes to people for testing, I create intermediate versions with a digit 
49 appended, e.g. 2.0c3.
52 2. Installation
53 ---------------
54 If you got any recent kernel with this driver and document included in
55 linux/drivers/scsi, you basically have to do nothing special to use this
56 driver. Of course you have to choose to compile SCSI support and DC390(T)
57 support into your kernel or as module when configuring your kernel for
58 compiling.
60  If you got an old kernel (pre 2.1.127, pre 2.0.37p1) with an old version of
61  this driver: Get dc390-21125-20b.diff.gz or dc390-2036p21-20b1.diff.gz from
62  my website and apply the patch. 
64  If you want to do it manually, you should copy the files (dc390.h,
65  tmscsim.h, tmscsim.c, scsiiom.c and README.tmscsim) from this directory to
66  linux/drivers/scsi. You have to recompile your kernel/module of course.
68  You should apply the three patches included in dc390-120-kernel.diff
69  (Applying them: cd /usr/src; patch -p0 <~/dc390-120-kernel.diff)
70  The patches are against 2.1.125, so you might have to manually resolve
71  rejections when applying to another kernel version.
73  The patches will update the kernel startup code to allow boot parameters to
74  be passed to the driver, update the Documentation and finally offer you the
75  possibility to omit the non-DC390 parts of the driver.
76  (By selecting "Omit support for non DC390" you basically disable the
77  emulation of a DC390 EEPROM for non DC390 adapters. This saves a few bytes
78  of memory.)
80 If you got a very old kernel without the tmscsim driver (pre 2.0.31)
81 I recommend upgrading your kernel. However, if you don't want to, please
82 contact me to get the appropriate patches.
85 Upgrading a SCSI driver is always a delicate thing to do. The 2.0 driver has
86 proven stable on many systems, but it's still a good idea to take some
87 precautions. In an ideal world you would have a full backup of your disks.
88 The world isn't ideal and most people don't have full backups (me neither).
89 So take at least the following measures:
90 * make your kernel remount the FS read-only on detecting an error:
91   tune2fs -e remount-ro /dev/sd??
92 * have copies of your SCSI disk's partition tables on some safe location:
93   dd if=/dev/sda of=/mnt/floppy/sda bs=512 count=1
94 * make sure you are able to boot Linux (e.g. from floppy disk using InitRD)
95   if your SCSI disk gets corrupted. You can use 
96   ftp://student.physik.uni-dortmund.de/pub/linux/kernel/bootdisk.gz
98 One more warning: I used to overclock my PCI bus to 41.67 MHz. My Tekram
99 DC390F (Sym53c875) accepted this as well as my Millenium. But the Am53C974
100 produced errors and started to corrupt my disks. So don't do that! A 37.50
101 MHz PCI bus works for me, though, but I don't recommend using higher clocks
102 than the 33.33 MHz being in the PCI spec.
104 If you want to share the IRQ with another device and the driver refuses to
105 do, you might succeed with changing the DC390_IRQ type in tmscsim.c to 
106 SA_SHIRQ | SA_INTERRUPT.
109 3.Features
110 ----------
111 - SCSI
112  * Tagged command queueing
113  * Sync speed up to 10 MHz
114  * Disconnection
115  * Multiple LUNs
117 - General / Linux interface
118  * Support for up to 4 AM53C974 adapters.
119  * DC390 EEPROM usage or boot/module params
120  * Information via cat /proc/scsi/tmscsim/?
121  * Dynamically configurable by writing to /proc/scsi/tmscsim/?
122  * Dynamic allocation of resources
123  * SMP support: Locking on io_request lock (Linux 2.1/2.2) or adapter 
124     specific locks (Linux 2.3)
125  * Uniform source code for Linux-2.x.y
126  * Support for dyn. addition/removal of devices via add/remove-single-device
127    (Try: echo "scsi add-single-device H C I L" >/proc/scsi/scsi 
128     H = Host, C = Channel, I = SCSI ID, L = SCSI LUN.) Use with care!
129  * Try to use the partition table for the determination of the mapping
132 4. Configuration via /proc/scsi/tmscsim/?
133 -----------------------------------------
134 First of all look at the output of /proc/scsi/tmscsim/? by typing
135  cat /proc/scsi/tmscsim/?
136 The "?" should be replaced by the SCSI host number. (The shell might do this
137 for you.)
138 You will see some info regarding the adapter and, at the end, a listing of
139 the attached devices and their settings.
141 Here's an example:
142 garloff@kg1:/home/garloff > cat /proc/scsi/tmscsim/0
143 Tekram DC390/AM53C974 PCI SCSI Host Adapter, Driver Version 1.20s, 1998/08/20
144 SCSI Host Nr 0, AM53C974 Adapter Nr 0
145 IOPortBase 0x6200, IRQLevel 0x09
146 MaxID 7, MaxLUN 8, AdapterID 7, SelTimeout 250 ms
147 TagMaxNum 16, Status 0, ACBFlag 0, GlitchEater 24 ns
148 Statistics: Nr of Cmnds 39563, Cmnds not sent directly 0, Out of SRB conds 0
149             Nr of lost arbitrations 17
150 Nr of attached devices: 4, Nr of DCBs: 4
151 Idx ID LUN Prty Sync DsCn SndS TagQ STOP NegoPeriod SyncSpeed SyncOffs
152 00  00  00  Yes  Yes  Yes  Yes  Yes  No    100 ns    10.0 M      15
153 01  01  00  Yes  Yes  Yes  Yes  Yes  No    100 ns    10.0 M      15
154 02  03  00  Yes  Yes  Yes  Yes  No   No    100 ns    10.0 M      15
155 03  05  00  Yes  No   Yes  Yes  No   No   (200 ns)
157 Note that the settings MaxID and MaxLUN are not zero- but one-based, which
158 means that a setting MaxLUN=4, will result in the support of LUNs 0..3. This
159 is somehow inconvenient, but the way the mid-level SCSI code expects it to be.
161 ACB and DCB are acronyms for Adapter Control Block and Device Control Block.
162 These are data structures of the driver containing information about the
163 adapter and the connected SCSI devices respectively.
165 Idx is the device index (just a consecutive number for the driver), ID and
166 LUN are the SCSI ID and LUN, Prty means Parity checking, Sync synchronous
167 negotiation, DsCn Disconnection, SndS Send Start command on startup (not
168 used by the driver) and TagQ Tagged Command Queueing. NegoPeriod and
169 SyncSpeed are somehow redundant, because they are reciprocal values 
170 (1 / 112 ns = 8.9 MHz). At least in theory. The driver is able to adjust the
171 NegoPeriod more accurate (4ns) than the SyncSpeed (1 / 25ns). I don't know
172 if certain devices will have problems with this discrepancy. Max. speed is
173 10 MHz corresp. to a min. NegoPeriod of 100 ns. 
174 (The driver allows slightly higher speeds if the devices (Ultra SCSI) accept
175 it, but that's out of adapter spec, on your own risk and unlikely to improve
176 performance. You're likely to crash your disks.) 
177 SyncOffs is the offset used for synchronous negotiations; max. is 15. 
178 The last values are only shown, if Sync is enabled. (NegoPeriod is still
179 displayed in brackets to show the values which will be used after enabling
180 Sync.)
181 The STOP parameter is for testing/debugging purposes only and should bet set
182 to No. Please don't fiddle with it, unless you want to get rid of the
183 contents of your disk.
185 If you want to change a setting, you can do that by writing to
186 /proc/scsi/tmscsim/?. Basically you have to imitate the output of driver.
187 (Don't use the brackets for NegoPeriod on Sync disabled devices.)
188 You don't have to care about capitalisation. The driver will accept space,
189 tab, comma, = and : as separators.
191 There are three kinds of changes: 
193 (1) Change driver settings: 
194     You type the names of the parameters and the params following it.
195     Example:
196      echo "MaxLUN=8 seltimeout 200" >/proc/scsi/tmscsim/0
198     Note that you can only change MaxID, MaxLUN, AdapterID, SelTimeOut,
199     TagMaxNum, ACBFlag and GlitchEater. Don't change ACBFlag unless you
200     want to see what happens, if the driver hangs.
202 (2) Change device settings: You write a config line to the driver. The Nr
203     must match the ID and LUN given. If you give "-" as parameter, it is
204     ignored and the corresponding setting won't be changed. 
205     You can use "y" or "n" instead of "Yes" and "No" if you want to.
206     You don't need to specify a full line. The driver automatically performs
207     an INQUIRY on the device if necessary to check if it is capable to operate
208     with the given settings (Sync, TagQ).
209     Examples:
210      echo "0 0 0 y y y - y - 10" >/proc/scsi/tmscsim/0
211      echo "3 5 0 y n y" >/proc/scsi/tmscsim/0
213     To give a short explanation of the first example: 
214     The first three numbers, "0 0 0" (Device index 0, SCSI ID 0, SCSI LUN 0),
215     select the device to which the following parameters apply. Note that it
216     would be sufficient to use the index or both SCSI ID and LUN, but I chose
217     to require all three to have a syntax similar to the output.
218     The following "y y y - y" enables Parity checking, enables Synchronous
219     transfers, Disconnection, leaves Send Start (not used) untouched and
220     enables Tagged Command Queueing for the selected device. The "-" skips
221     the Negotiation Period setting but the "10" sets the max sync. speed to
222     10 MHz. It's useless to specify both NegoPeriod and SyncSpeed as
223     discussed above. The values used in this example will result in maximum
224     performance.
226 (3) Special commands: You can force a SCSI bus reset, an INQUIRY command and
227     the removal of a device's DCB.
228     This is only used for debugging when you meet problems. The parameter of
229     the INQUIRY and remove command is the device index as shown by the
230     output of /proc/scsi/tmscsim/? in the device listing in the first column
231     (Idx).
232     Examples:
233      echo "reset" >/proc/scsi/tmscsim/0
234      echo "inquiry 1" >/proc/scsi/tmscsim/0
235      echo "remove 2" >/proc/scsi/tmscsim/1
237     Note that you will meet problems when you remove a device's DCB with the
238     remove command if it contains partitions which are mounted. Only use it
239     after unmounting its partitions, telling the SCSI mid-level code to
240     remove it (scsi remove-single-device) and you really need a few bytes of
241     memory.
244 I'd suggest reviewing the output of /proc/scsi/tmscsim/? after changing
245 settings to see if everything changed as requested.
248 5. Configuration via boot/module parameters
249 -------------------------------------------
250 With the DC390, the driver reads its EEPROM settings and IGNORES boot / 
251 module parameters. If you want to override the EEPROM settings of a DC390, 
252 you have to use the /proc/scsi/tmscsim/? interface described in the above
253 chapter.
255 However, if you do have another AM53C974 based adapter you might want to
256 adjust some settings before you are able to write to the /proc/scsi/tmscsim/?
257 pseudo-file, e.g. if you want to use another adapter ID than 7. (Note that
258 the log message "DC390: No EEPROM found!" is normal without a DC390.)
259 For this purpose, you can pass options to the driver before it is initialised
260 by using kernel or module parameters. See lilo(8) or modprobe(1) manual
261 pages on how to pass params to the kernel or a module.
263 The syntax of the params is much shorter than the syntax of the /proc/...
264 interface. This makes it a little bit more difficult to use. However, long
265 parameter lines have the risk to be misinterpreted and the length of kernel
266 parameters is limited.
268 As the support for non-DC390 adapters works by simulating the values of the
269 DC390 EEPROM, the settings are given in a DC390 BIOS' way.
271 Here's the syntax:
272 tmscsim=AdaptID,SpdIdx,DevMode,AdaptMode,TaggedCmnds
274 Each of the parameters is a number, containing the described information:
276 * AdaptID: The SCSI ID of the host adapter. Must be in the range 0..7
277   Default is 7.
279 * SpdIdx: The index of the maximum speed as in the DC390 BIOS. The values
280   0..7 mean 10, 8.0, 6.7, 5.7, 5.0, 4.0, 3.1 and 2 MHz resp. Default is
281   1 (8.0 MHz).
283 * DevMode is a bit mapped value describing the per-device features. It
284   applies to all devices. (Sync, Disc and TagQ will only apply, if the
285   device supports it.) The meaning of the bits (* = default):
287    Bit Val(hex) Val(dec)  Meaning
288    *0    0x01       1     Parity check
289    *1    0x02       2     Synchronous Negotiation
290    *2    0x04       4     Disconnection
291    *3    0x08       8     Send Start command on startup. (Not used)
292    *4    0x10      16     Tagged Queueing
294   As usual, the desired value is obtained by adding the wanted values. If
295   you want to enable all values, e.g., you would use 31(0x1f). Default is 31.
297 * AdaptMode is a bit mapped value describing the enabled adapter features.
299    Bit Val(hex) Val(dec)  Meaning
300    *0    0x01       1     Support more than two drives. (Not used)
301    *1    0x02       2     Use DOS compatible mapping for HDs greater than 1GB.
302    *2    0x04       4     Reset SCSI Bus on startup.
303    *3    0x08       8     Active Negation: Improves SCSI Bus noise immunity.
304     4    0x10      16     Immediate return on BIOS seek command. (Not used)
305  (*)5    0x20      32     Check for LUNs >= 1.
306   
307   The default for LUN Check depends on CONFIG_SCSI_MULTI_LUN.
309 * TaggedCmnds is a number indicating the maximum number of Tagged Commands.
310   It is the binary logarithm - 1 of the actual number. Max is 4 (32).
311    Value  Number of Tagged Commands
312      0           2
313      1           4
314      2           8
315     *3          16
316      4          32
318 Example:
319  modprobe tmscsim tmscsim=6,2,31
320 would set the adapter ID to 6, max. speed to 6.7 MHz, enable all device
321 features and leave the adapter features and the number of Tagged Commands 
322 to the defaults.
324 As you can see, you don't need to specify all of the five params.
326 The defaults (7,1,31,15,3) are aggressive to allow good performance. You can
327 use tmscsim=7,0,31,63,4 for maximum performance, if your SCSI chain is
328 perfect. If you meet problems, you can use tmscsim=-1 which is a shortcut
329 for tmscsim=7,4,9,15,2. 
332 6. Potential improvements
333 -------------------------
334 Most of the intended work on the driver has been done. Here are a few ideas
335 to further improve its usability:
337 * More intelligent abort() routine
338 * Implement new_eh code (Linux-2.1+)
339 * Have the mid-level code (and not the driver) handle more of the various
340   conditions.
341 * Rework command queueing in the driver
342 * More user friendly boot/module param syntax
344 Further investigation on these problems:
346 * Driver hangs with sync readcdda (xcdroast) (most probably VIA PCI error)
348 Known problems:
350 * There was a report that with a certain Scanner, the last SCSI command
351   won't be finished correctly. This might be a command queueing bug or a bug
352   in SCSI implementation of the scanner. Issueing another command to the
353   scanner seems to help. (Try echo "INQUIRY x" >/proc/scsi/tmscsim/?, where
354   x is the index (not the SCSI ID!) of the scanner. See 4.(3).)
355 * If there is a valid partition table, the driver will use it for determing
356   the mapping. Other operating systems may not like this mapping, though
357   it's consistent with the BIOS' behaviour. Old DC390 drivers ignored the
358   partition table and used a H/S = 64/32 or 255/63 translation. So if you
359   want to be compatible to those, use this old mapping when creating
360   partition tables.
361 * In some situations, the driver will get stuck in an abort loop. Please
362   disable DsCn, if you meet this problem. Please contact me for further
363   debugging.
364 * 2.1.115+: Linux misses locks in sr_ioctl.c and scsi_ioctl.c
365   There used to be a patch included here, which partially solved the
366   problem. I suggest you contact Chiaki Ishikawa <ishikawa@yk.rim.or.jp>, 
367   Richard Waltham <dormouse@farsrobt.demon.co.uk> or Doug Ledford
368   <dledford@dialnet.net>, if you want to help further debugging it.
369 * 2.0.35: CD changers (e.g. NAKAMICHI MBR-7.{0,2}) have problems because
370   the mid-level code doesn't handle BLIST_SINGLELUN correctly. There used
371   to be a patch included here to fix this, but I was told that it is fixed
372   in 2.0.36.
375 7. Bug reports, debugging and updates
376 -------------------------------------
377 Whenever you have problems with the driver, you are invited to ask the
378 author for help. However, I'd suggest reading the docs and trying to solve
379 the problem yourself, first. 
380 If you find something, which you believe to be a bug, please report it to me. 
381 Please append the output of /proc/scsi/scsi, /proc/scsi/tmscsim/? and
382 maybe the DC390 log messages to the report. 
384 Bug reports should be send to me (Kurt Garloff <dc390@garloff.de>) as well
385 as to the linux-scsi list (<linux-scsi@vger.rutgers.edu>), as sometimes bugs
386 are caused by the SCSI mid-level code.
388 I will ask you for some more details and probably I will also ask you to
389 enable some of the DEBUG options in the driver (tmscsim.c:DC390_DEBUGXXX
390 defines). The driver will produce some data for the syslog facility then.
391 Beware: If your syslog gets written to a SCSI disk connected to your
392 AM53C974, the logging might produce log output again, and you might end
393 having your box spending most of its time doing the logging.
395 The latest version of the driver can be found at:
396  http://www.garloff.de/kurt/linux/dc390/
398  ftp://student.physik.uni-dortmund.de/pub/linux/kernel/dc390/
399 (The latter might shut down some day.)
402 8. Acknowledgements
403 -------------------
404 Thanks to Linus Torvalds, Alan Cox, David Miller, Rik v. Riel, the FSF
405 people, the XFree86 team and all the others for the wonderful OS and
406 software. 
407 Thanks to C.L. Huang and Philip Giang (Tekram) for the initial driver
408 release and support.
409 Thanks to Doug Ledford, Gerard Roudier for support with SCSI coding.
410 Thanks to a lot of people (espec. Chiaki Ishikawa, Andreas Haumer, Hubert 
411 Tonneau) for intensively testing the driver (and even risking data loss
412 doing this during early revisions). 
415 -------------------------------------------------------------------------
416 Written by Kurt Garloff <kurt@garloff.de> 1998/06/11
417 Last updated 1998/12/25, driver revision 2.0d
418 $Id: README.tmscsim,v 2.9 1998/12/25 18:04:20 garloff Exp $