]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blame - drivers/scsi/BusLogic.c
[SCSI] eata_pio cleanup and PCI fix
[mirror_ubuntu-zesty-kernel.git] / drivers / scsi / BusLogic.c
CommitLineData
1da177e4
LT
1
2/*
3
4 Linux Driver for BusLogic MultiMaster and FlashPoint SCSI Host Adapters
5
6 Copyright 1995-1998 by Leonard N. Zubkoff <lnz@dandelion.com>
7
8 This program is free software; you may redistribute and/or modify it under
9 the terms of the GNU General Public License Version 2 as published by the
10 Free Software Foundation.
11
12 This program is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
14 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for complete details.
16
17 The author respectfully requests that any modifications to this software be
18 sent directly to him for evaluation and testing.
19
20 Special thanks to Wayne Yen, Jin-Lon Hon, and Alex Win of BusLogic, whose
21 advice has been invaluable, to David Gentzel, for writing the original Linux
22 BusLogic driver, and to Paul Gortmaker, for being such a dedicated test site.
23
24 Finally, special thanks to Mylex/BusLogic for making the FlashPoint SCCB
25 Manager available as freely redistributable source code.
26
27*/
28
29#define BusLogic_DriverVersion "2.1.16"
30#define BusLogic_DriverDate "18 July 2002"
31
1da177e4
LT
32#include <linux/module.h>
33#include <linux/init.h>
34#include <linux/interrupt.h>
35#include <linux/types.h>
36#include <linux/blkdev.h>
37#include <linux/delay.h>
38#include <linux/ioport.h>
39#include <linux/mm.h>
40#include <linux/stat.h>
41#include <linux/pci.h>
42#include <linux/spinlock.h>
60c904ae 43#include <linux/jiffies.h>
910638ae 44#include <linux/dma-mapping.h>
1da177e4
LT
45#include <scsi/scsicam.h>
46
47#include <asm/dma.h>
48#include <asm/io.h>
49#include <asm/system.h>
50
51#include <scsi/scsi.h>
52#include <scsi/scsi_cmnd.h>
53#include <scsi/scsi_device.h>
54#include <scsi/scsi_host.h>
55#include <scsi/scsi_tcq.h>
56#include "BusLogic.h"
57#include "FlashPoint.c"
58
59#ifndef FAILURE
60#define FAILURE (-1)
61#endif
62
63static struct scsi_host_template Bus_Logic_template;
64
65/*
66 BusLogic_DriverOptionsCount is a count of the number of BusLogic Driver
67 Options specifications provided via the Linux Kernel Command Line or via
68 the Loadable Kernel Module Installation Facility.
69*/
70
71static int BusLogic_DriverOptionsCount;
72
73
74/*
75 BusLogic_DriverOptions is an array of Driver Options structures representing
76 BusLogic Driver Options specifications provided via the Linux Kernel Command
77 Line or via the Loadable Kernel Module Installation Facility.
78*/
79
80static struct BusLogic_DriverOptions BusLogic_DriverOptions[BusLogic_MaxHostAdapters];
81
82
83/*
84 BusLogic can be assigned a string by insmod.
85*/
86
87MODULE_LICENSE("GPL");
88#ifdef MODULE
89static char *BusLogic;
90module_param(BusLogic, charp, 0);
91#endif
92
93
94/*
95 BusLogic_ProbeOptions is a set of Probe Options to be applied across
96 all BusLogic Host Adapters.
97*/
98
99static struct BusLogic_ProbeOptions BusLogic_ProbeOptions;
100
101
102/*
103 BusLogic_GlobalOptions is a set of Global Options to be applied across
104 all BusLogic Host Adapters.
105*/
106
107static struct BusLogic_GlobalOptions BusLogic_GlobalOptions;
108
109static LIST_HEAD(BusLogic_host_list);
110
111/*
112 BusLogic_ProbeInfoCount is the number of entries in BusLogic_ProbeInfoList.
113*/
114
115static int BusLogic_ProbeInfoCount;
116
117
118/*
119 BusLogic_ProbeInfoList is the list of I/O Addresses and Bus Probe Information
120 to be checked for potential BusLogic Host Adapters. It is initialized by
121 interrogating the PCI Configuration Space on PCI machines as well as from the
122 list of standard BusLogic I/O Addresses.
123*/
124
125static struct BusLogic_ProbeInfo *BusLogic_ProbeInfoList;
126
127
128/*
129 BusLogic_CommandFailureReason holds a string identifying the reason why a
130 call to BusLogic_Command failed. It is only non-NULL when BusLogic_Command
131 returns a failure code.
132*/
133
134static char *BusLogic_CommandFailureReason;
135
136/*
137 BusLogic_AnnounceDriver announces the Driver Version and Date, Author's
138 Name, Copyright Notice, and Electronic Mail Address.
139*/
140
141static void BusLogic_AnnounceDriver(struct BusLogic_HostAdapter *HostAdapter)
142{
143 BusLogic_Announce("***** BusLogic SCSI Driver Version " BusLogic_DriverVersion " of " BusLogic_DriverDate " *****\n", HostAdapter);
144 BusLogic_Announce("Copyright 1995-1998 by Leonard N. Zubkoff " "<lnz@dandelion.com>\n", HostAdapter);
145}
146
147
148/*
149 BusLogic_DriverInfo returns the Host Adapter Name to identify this SCSI
150 Driver and Host Adapter.
151*/
152
153static const char *BusLogic_DriverInfo(struct Scsi_Host *Host)
154{
155 struct BusLogic_HostAdapter *HostAdapter = (struct BusLogic_HostAdapter *) Host->hostdata;
156 return HostAdapter->FullModelName;
157}
158
159/*
160 BusLogic_InitializeCCBs initializes a group of Command Control Blocks (CCBs)
161 for Host Adapter from the BlockSize bytes located at BlockPointer. The newly
162 created CCBs are added to Host Adapter's free list.
163*/
164
165static void BusLogic_InitializeCCBs(struct BusLogic_HostAdapter *HostAdapter, void *BlockPointer, int BlockSize, dma_addr_t BlockPointerHandle)
166{
167 struct BusLogic_CCB *CCB = (struct BusLogic_CCB *) BlockPointer;
168 unsigned int offset = 0;
169 memset(BlockPointer, 0, BlockSize);
170 CCB->AllocationGroupHead = BlockPointerHandle;
171 CCB->AllocationGroupSize = BlockSize;
172 while ((BlockSize -= sizeof(struct BusLogic_CCB)) >= 0) {
173 CCB->Status = BusLogic_CCB_Free;
174 CCB->HostAdapter = HostAdapter;
175 CCB->DMA_Handle = (u32) BlockPointerHandle + offset;
176 if (BusLogic_FlashPointHostAdapterP(HostAdapter)) {
177 CCB->CallbackFunction = BusLogic_QueueCompletedCCB;
178 CCB->BaseAddress = HostAdapter->FlashPointInfo.BaseAddress;
179 }
180 CCB->Next = HostAdapter->Free_CCBs;
181 CCB->NextAll = HostAdapter->All_CCBs;
182 HostAdapter->Free_CCBs = CCB;
183 HostAdapter->All_CCBs = CCB;
184 HostAdapter->AllocatedCCBs++;
185 CCB++;
186 offset += sizeof(struct BusLogic_CCB);
187 }
188}
189
190
191/*
192 BusLogic_CreateInitialCCBs allocates the initial CCBs for Host Adapter.
193*/
194
195static boolean __init BusLogic_CreateInitialCCBs(struct BusLogic_HostAdapter *HostAdapter)
196{
197 int BlockSize = BusLogic_CCB_AllocationGroupSize * sizeof(struct BusLogic_CCB);
198 void *BlockPointer;
199 dma_addr_t BlockPointerHandle;
200 while (HostAdapter->AllocatedCCBs < HostAdapter->InitialCCBs) {
201 BlockPointer = pci_alloc_consistent(HostAdapter->PCI_Device, BlockSize, &BlockPointerHandle);
202 if (BlockPointer == NULL) {
203 BusLogic_Error("UNABLE TO ALLOCATE CCB GROUP - DETACHING\n", HostAdapter);
204 return false;
205 }
206 BusLogic_InitializeCCBs(HostAdapter, BlockPointer, BlockSize, BlockPointerHandle);
207 }
208 return true;
209}
210
211
212/*
213 BusLogic_DestroyCCBs deallocates the CCBs for Host Adapter.
214*/
215
216static void BusLogic_DestroyCCBs(struct BusLogic_HostAdapter *HostAdapter)
217{
218 struct BusLogic_CCB *NextCCB = HostAdapter->All_CCBs, *CCB, *Last_CCB = NULL;
219 HostAdapter->All_CCBs = NULL;
220 HostAdapter->Free_CCBs = NULL;
221 while ((CCB = NextCCB) != NULL) {
222 NextCCB = CCB->NextAll;
223 if (CCB->AllocationGroupHead) {
224 if (Last_CCB)
225 pci_free_consistent(HostAdapter->PCI_Device, Last_CCB->AllocationGroupSize, Last_CCB, Last_CCB->AllocationGroupHead);
226 Last_CCB = CCB;
227 }
228 }
229 if (Last_CCB)
230 pci_free_consistent(HostAdapter->PCI_Device, Last_CCB->AllocationGroupSize, Last_CCB, Last_CCB->AllocationGroupHead);
231}
232
233
234/*
235 BusLogic_CreateAdditionalCCBs allocates Additional CCBs for Host Adapter. If
236 allocation fails and there are no remaining CCBs available, the Driver Queue
237 Depth is decreased to a known safe value to avoid potential deadlocks when
238 multiple host adapters share the same IRQ Channel.
239*/
240
241static void BusLogic_CreateAdditionalCCBs(struct BusLogic_HostAdapter *HostAdapter, int AdditionalCCBs, boolean SuccessMessageP)
242{
243 int BlockSize = BusLogic_CCB_AllocationGroupSize * sizeof(struct BusLogic_CCB);
244 int PreviouslyAllocated = HostAdapter->AllocatedCCBs;
245 void *BlockPointer;
246 dma_addr_t BlockPointerHandle;
247 if (AdditionalCCBs <= 0)
248 return;
249 while (HostAdapter->AllocatedCCBs - PreviouslyAllocated < AdditionalCCBs) {
250 BlockPointer = pci_alloc_consistent(HostAdapter->PCI_Device, BlockSize, &BlockPointerHandle);
251 if (BlockPointer == NULL)
252 break;
253 BusLogic_InitializeCCBs(HostAdapter, BlockPointer, BlockSize, BlockPointerHandle);
254 }
255 if (HostAdapter->AllocatedCCBs > PreviouslyAllocated) {
256 if (SuccessMessageP)
257 BusLogic_Notice("Allocated %d additional CCBs (total now %d)\n", HostAdapter, HostAdapter->AllocatedCCBs - PreviouslyAllocated, HostAdapter->AllocatedCCBs);
258 return;
259 }
260 BusLogic_Notice("Failed to allocate additional CCBs\n", HostAdapter);
261 if (HostAdapter->DriverQueueDepth > HostAdapter->AllocatedCCBs - HostAdapter->TargetDeviceCount) {
262 HostAdapter->DriverQueueDepth = HostAdapter->AllocatedCCBs - HostAdapter->TargetDeviceCount;
263 HostAdapter->SCSI_Host->can_queue = HostAdapter->DriverQueueDepth;
264 }
265}
266
267/*
268 BusLogic_AllocateCCB allocates a CCB from Host Adapter's free list,
269 allocating more memory from the Kernel if necessary. The Host Adapter's
270 Lock should already have been acquired by the caller.
271*/
272
273static struct BusLogic_CCB *BusLogic_AllocateCCB(struct BusLogic_HostAdapter
274 *HostAdapter)
275{
276 static unsigned long SerialNumber = 0;
277 struct BusLogic_CCB *CCB;
278 CCB = HostAdapter->Free_CCBs;
279 if (CCB != NULL) {
280 CCB->SerialNumber = ++SerialNumber;
281 HostAdapter->Free_CCBs = CCB->Next;
282 CCB->Next = NULL;
283 if (HostAdapter->Free_CCBs == NULL)
284 BusLogic_CreateAdditionalCCBs(HostAdapter, HostAdapter->IncrementalCCBs, true);
285 return CCB;
286 }
287 BusLogic_CreateAdditionalCCBs(HostAdapter, HostAdapter->IncrementalCCBs, true);
288 CCB = HostAdapter->Free_CCBs;
289 if (CCB == NULL)
290 return NULL;
291 CCB->SerialNumber = ++SerialNumber;
292 HostAdapter->Free_CCBs = CCB->Next;
293 CCB->Next = NULL;
294 return CCB;
295}
296
297
298/*
299 BusLogic_DeallocateCCB deallocates a CCB, returning it to the Host Adapter's
300 free list. The Host Adapter's Lock should already have been acquired by the
301 caller.
302*/
303
304static void BusLogic_DeallocateCCB(struct BusLogic_CCB *CCB)
305{
306 struct BusLogic_HostAdapter *HostAdapter = CCB->HostAdapter;
307 struct scsi_cmnd *cmd = CCB->Command;
308
309 if (cmd->use_sg != 0) {
310 pci_unmap_sg(HostAdapter->PCI_Device,
311 (struct scatterlist *)cmd->request_buffer,
312 cmd->use_sg, cmd->sc_data_direction);
313 } else if (cmd->request_bufflen != 0) {
314 pci_unmap_single(HostAdapter->PCI_Device, CCB->DataPointer,
315 CCB->DataLength, cmd->sc_data_direction);
316 }
317 pci_unmap_single(HostAdapter->PCI_Device, CCB->SenseDataPointer,
318 CCB->SenseDataLength, PCI_DMA_FROMDEVICE);
319
320 CCB->Command = NULL;
321 CCB->Status = BusLogic_CCB_Free;
322 CCB->Next = HostAdapter->Free_CCBs;
323 HostAdapter->Free_CCBs = CCB;
324}
325
326
327/*
328 BusLogic_Command sends the command OperationCode to HostAdapter, optionally
329 providing ParameterLength bytes of ParameterData and receiving at most
330 ReplyLength bytes of ReplyData; any excess reply data is received but
331 discarded.
332
333 On success, this function returns the number of reply bytes read from
334 the Host Adapter (including any discarded data); on failure, it returns
335 -1 if the command was invalid, or -2 if a timeout occurred.
336
337 BusLogic_Command is called exclusively during host adapter detection and
338 initialization, so performance and latency are not critical, and exclusive
339 access to the Host Adapter hardware is assumed. Once the host adapter and
340 driver are initialized, the only Host Adapter command that is issued is the
341 single byte Execute Mailbox Command operation code, which does not require
342 waiting for the Host Adapter Ready bit to be set in the Status Register.
343*/
344
345static int BusLogic_Command(struct BusLogic_HostAdapter *HostAdapter, enum BusLogic_OperationCode OperationCode, void *ParameterData, int ParameterLength, void *ReplyData, int ReplyLength)
346{
347 unsigned char *ParameterPointer = (unsigned char *) ParameterData;
348 unsigned char *ReplyPointer = (unsigned char *) ReplyData;
349 union BusLogic_StatusRegister StatusRegister;
350 union BusLogic_InterruptRegister InterruptRegister;
351 unsigned long ProcessorFlags = 0;
352 int ReplyBytes = 0, Result;
353 long TimeoutCounter;
354 /*
355 Clear out the Reply Data if provided.
356 */
357 if (ReplyLength > 0)
358 memset(ReplyData, 0, ReplyLength);
359 /*
360 If the IRQ Channel has not yet been acquired, then interrupts must be
361 disabled while issuing host adapter commands since a Command Complete
362 interrupt could occur if the IRQ Channel was previously enabled by another
363 BusLogic Host Adapter or another driver sharing the same IRQ Channel.
364 */
365 if (!HostAdapter->IRQ_ChannelAcquired) {
366 local_irq_save(ProcessorFlags);
367 local_irq_disable();
368 }
369 /*
370 Wait for the Host Adapter Ready bit to be set and the Command/Parameter
371 Register Busy bit to be reset in the Status Register.
372 */
373 TimeoutCounter = 10000;
374 while (--TimeoutCounter >= 0) {
375 StatusRegister.All = BusLogic_ReadStatusRegister(HostAdapter);
376 if (StatusRegister.sr.HostAdapterReady && !StatusRegister.sr.CommandParameterRegisterBusy)
377 break;
378 udelay(100);
379 }
380 if (TimeoutCounter < 0) {
381 BusLogic_CommandFailureReason = "Timeout waiting for Host Adapter Ready";
382 Result = -2;
383 goto Done;
384 }
385 /*
386 Write the OperationCode to the Command/Parameter Register.
387 */
388 HostAdapter->HostAdapterCommandCompleted = false;
389 BusLogic_WriteCommandParameterRegister(HostAdapter, OperationCode);
390 /*
391 Write any additional Parameter Bytes.
392 */
393 TimeoutCounter = 10000;
394 while (ParameterLength > 0 && --TimeoutCounter >= 0) {
395 /*
396 Wait 100 microseconds to give the Host Adapter enough time to determine
397 whether the last value written to the Command/Parameter Register was
398 valid or not. If the Command Complete bit is set in the Interrupt
399 Register, then the Command Invalid bit in the Status Register will be
400 reset if the Operation Code or Parameter was valid and the command
401 has completed, or set if the Operation Code or Parameter was invalid.
402 If the Data In Register Ready bit is set in the Status Register, then
403 the Operation Code was valid, and data is waiting to be read back
404 from the Host Adapter. Otherwise, wait for the Command/Parameter
405 Register Busy bit in the Status Register to be reset.
406 */
407 udelay(100);
408 InterruptRegister.All = BusLogic_ReadInterruptRegister(HostAdapter);
409 StatusRegister.All = BusLogic_ReadStatusRegister(HostAdapter);
410 if (InterruptRegister.ir.CommandComplete)
411 break;
412 if (HostAdapter->HostAdapterCommandCompleted)
413 break;
414 if (StatusRegister.sr.DataInRegisterReady)
415 break;
416 if (StatusRegister.sr.CommandParameterRegisterBusy)
417 continue;
418 BusLogic_WriteCommandParameterRegister(HostAdapter, *ParameterPointer++);
419 ParameterLength--;
420 }
421 if (TimeoutCounter < 0) {
422 BusLogic_CommandFailureReason = "Timeout waiting for Parameter Acceptance";
423 Result = -2;
424 goto Done;
425 }
426 /*
427 The Modify I/O Address command does not cause a Command Complete Interrupt.
428 */
429 if (OperationCode == BusLogic_ModifyIOAddress) {
430 StatusRegister.All = BusLogic_ReadStatusRegister(HostAdapter);
431 if (StatusRegister.sr.CommandInvalid) {
432 BusLogic_CommandFailureReason = "Modify I/O Address Invalid";
433 Result = -1;
434 goto Done;
435 }
436 if (BusLogic_GlobalOptions.TraceConfiguration)
437 BusLogic_Notice("BusLogic_Command(%02X) Status = %02X: " "(Modify I/O Address)\n", HostAdapter, OperationCode, StatusRegister.All);
438 Result = 0;
439 goto Done;
440 }
441 /*
442 Select an appropriate timeout value for awaiting command completion.
443 */
444 switch (OperationCode) {
445 case BusLogic_InquireInstalledDevicesID0to7:
446 case BusLogic_InquireInstalledDevicesID8to15:
447 case BusLogic_InquireTargetDevices:
448 /* Approximately 60 seconds. */
449 TimeoutCounter = 60 * 10000;
450 break;
451 default:
452 /* Approximately 1 second. */
453 TimeoutCounter = 10000;
454 break;
455 }
456 /*
457 Receive any Reply Bytes, waiting for either the Command Complete bit to
458 be set in the Interrupt Register, or for the Interrupt Handler to set the
459 Host Adapter Command Completed bit in the Host Adapter structure.
460 */
461 while (--TimeoutCounter >= 0) {
462 InterruptRegister.All = BusLogic_ReadInterruptRegister(HostAdapter);
463 StatusRegister.All = BusLogic_ReadStatusRegister(HostAdapter);
464 if (InterruptRegister.ir.CommandComplete)
465 break;
466 if (HostAdapter->HostAdapterCommandCompleted)
467 break;
468 if (StatusRegister.sr.DataInRegisterReady) {
469 if (++ReplyBytes <= ReplyLength)
470 *ReplyPointer++ = BusLogic_ReadDataInRegister(HostAdapter);
471 else
472 BusLogic_ReadDataInRegister(HostAdapter);
473 }
474 if (OperationCode == BusLogic_FetchHostAdapterLocalRAM && StatusRegister.sr.HostAdapterReady)
475 break;
476 udelay(100);
477 }
478 if (TimeoutCounter < 0) {
479 BusLogic_CommandFailureReason = "Timeout waiting for Command Complete";
480 Result = -2;
481 goto Done;
482 }
483 /*
484 Clear any pending Command Complete Interrupt.
485 */
486 BusLogic_InterruptReset(HostAdapter);
487 /*
488 Provide tracing information if requested.
489 */
490 if (BusLogic_GlobalOptions.TraceConfiguration) {
491 int i;
492 BusLogic_Notice("BusLogic_Command(%02X) Status = %02X: %2d ==> %2d:", HostAdapter, OperationCode, StatusRegister.All, ReplyLength, ReplyBytes);
493 if (ReplyLength > ReplyBytes)
494 ReplyLength = ReplyBytes;
495 for (i = 0; i < ReplyLength; i++)
496 BusLogic_Notice(" %02X", HostAdapter, ((unsigned char *) ReplyData)[i]);
497 BusLogic_Notice("\n", HostAdapter);
498 }
499 /*
500 Process Command Invalid conditions.
501 */
502 if (StatusRegister.sr.CommandInvalid) {
503 /*
504 Some early BusLogic Host Adapters may not recover properly from
505 a Command Invalid condition, so if this appears to be the case,
506 a Soft Reset is issued to the Host Adapter. Potentially invalid
507 commands are never attempted after Mailbox Initialization is
508 performed, so there should be no Host Adapter state lost by a
509 Soft Reset in response to a Command Invalid condition.
510 */
511 udelay(1000);
512 StatusRegister.All = BusLogic_ReadStatusRegister(HostAdapter);
513 if (StatusRegister.sr.CommandInvalid ||
514 StatusRegister.sr.Reserved ||
515 StatusRegister.sr.DataInRegisterReady ||
516 StatusRegister.sr.CommandParameterRegisterBusy || !StatusRegister.sr.HostAdapterReady || !StatusRegister.sr.InitializationRequired || StatusRegister.sr.DiagnosticActive || StatusRegister.sr.DiagnosticFailure) {
517 BusLogic_SoftReset(HostAdapter);
518 udelay(1000);
519 }
520 BusLogic_CommandFailureReason = "Command Invalid";
521 Result = -1;
522 goto Done;
523 }
524 /*
525 Handle Excess Parameters Supplied conditions.
526 */
527 if (ParameterLength > 0) {
528 BusLogic_CommandFailureReason = "Excess Parameters Supplied";
529 Result = -1;
530 goto Done;
531 }
532 /*
533 Indicate the command completed successfully.
534 */
535 BusLogic_CommandFailureReason = NULL;
536 Result = ReplyBytes;
537 /*
538 Restore the interrupt status if necessary and return.
539 */
540 Done:
541 if (!HostAdapter->IRQ_ChannelAcquired)
542 local_irq_restore(ProcessorFlags);
543 return Result;
544}
545
546
547/*
548 BusLogic_AppendProbeAddressISA appends a single ISA I/O Address to the list
549 of I/O Address and Bus Probe Information to be checked for potential BusLogic
550 Host Adapters.
551*/
552
553static void __init BusLogic_AppendProbeAddressISA(unsigned long IO_Address)
554{
555 struct BusLogic_ProbeInfo *ProbeInfo;
556 if (BusLogic_ProbeInfoCount >= BusLogic_MaxHostAdapters)
557 return;
558 ProbeInfo = &BusLogic_ProbeInfoList[BusLogic_ProbeInfoCount++];
559 ProbeInfo->HostAdapterType = BusLogic_MultiMaster;
560 ProbeInfo->HostAdapterBusType = BusLogic_ISA_Bus;
561 ProbeInfo->IO_Address = IO_Address;
562 ProbeInfo->PCI_Device = NULL;
563}
564
565
566/*
567 BusLogic_InitializeProbeInfoListISA initializes the list of I/O Address and
568 Bus Probe Information to be checked for potential BusLogic SCSI Host Adapters
569 only from the list of standard BusLogic MultiMaster ISA I/O Addresses.
570*/
571
572static void __init BusLogic_InitializeProbeInfoListISA(struct BusLogic_HostAdapter
573 *PrototypeHostAdapter)
574{
575 /*
576 If BusLogic Driver Options specifications requested that ISA Bus Probes
577 be inhibited, do not proceed further.
578 */
579 if (BusLogic_ProbeOptions.NoProbeISA)
580 return;
581 /*
582 Append the list of standard BusLogic MultiMaster ISA I/O Addresses.
583 */
584 if (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe330 : check_region(0x330, BusLogic_MultiMasterAddressCount) == 0)
585 BusLogic_AppendProbeAddressISA(0x330);
586 if (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe334 : check_region(0x334, BusLogic_MultiMasterAddressCount) == 0)
587 BusLogic_AppendProbeAddressISA(0x334);
588 if (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe230 : check_region(0x230, BusLogic_MultiMasterAddressCount) == 0)
589 BusLogic_AppendProbeAddressISA(0x230);
590 if (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe234 : check_region(0x234, BusLogic_MultiMasterAddressCount) == 0)
591 BusLogic_AppendProbeAddressISA(0x234);
592 if (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe130 : check_region(0x130, BusLogic_MultiMasterAddressCount) == 0)
593 BusLogic_AppendProbeAddressISA(0x130);
594 if (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe134 : check_region(0x134, BusLogic_MultiMasterAddressCount) == 0)
595 BusLogic_AppendProbeAddressISA(0x134);
596}
597
598
599#ifdef CONFIG_PCI
600
601
602/*
603 BusLogic_SortProbeInfo sorts a section of BusLogic_ProbeInfoList in order
604 of increasing PCI Bus and Device Number.
605*/
606
607static void __init BusLogic_SortProbeInfo(struct BusLogic_ProbeInfo *ProbeInfoList, int ProbeInfoCount)
608{
609 int LastInterchange = ProbeInfoCount - 1, Bound, j;
610 while (LastInterchange > 0) {
611 Bound = LastInterchange;
612 LastInterchange = 0;
613 for (j = 0; j < Bound; j++) {
614 struct BusLogic_ProbeInfo *ProbeInfo1 = &ProbeInfoList[j];
615 struct BusLogic_ProbeInfo *ProbeInfo2 = &ProbeInfoList[j + 1];
616 if (ProbeInfo1->Bus > ProbeInfo2->Bus || (ProbeInfo1->Bus == ProbeInfo2->Bus && (ProbeInfo1->Device > ProbeInfo2->Device))) {
617 struct BusLogic_ProbeInfo TempProbeInfo;
618 memcpy(&TempProbeInfo, ProbeInfo1, sizeof(struct BusLogic_ProbeInfo));
619 memcpy(ProbeInfo1, ProbeInfo2, sizeof(struct BusLogic_ProbeInfo));
620 memcpy(ProbeInfo2, &TempProbeInfo, sizeof(struct BusLogic_ProbeInfo));
621 LastInterchange = j;
622 }
623 }
624 }
625}
626
627
628/*
629 BusLogic_InitializeMultiMasterProbeInfo initializes the list of I/O Address
630 and Bus Probe Information to be checked for potential BusLogic MultiMaster
631 SCSI Host Adapters by interrogating the PCI Configuration Space on PCI
632 machines as well as from the list of standard BusLogic MultiMaster ISA
633 I/O Addresses. It returns the number of PCI MultiMaster Host Adapters found.
634*/
635
636static int __init BusLogic_InitializeMultiMasterProbeInfo(struct BusLogic_HostAdapter
637 *PrototypeHostAdapter)
638{
639 struct BusLogic_ProbeInfo *PrimaryProbeInfo = &BusLogic_ProbeInfoList[BusLogic_ProbeInfoCount];
640 int NonPrimaryPCIMultiMasterIndex = BusLogic_ProbeInfoCount + 1;
641 int NonPrimaryPCIMultiMasterCount = 0, PCIMultiMasterCount = 0;
642 boolean ForceBusDeviceScanningOrder = false;
643 boolean ForceBusDeviceScanningOrderChecked = false;
644 boolean StandardAddressSeen[6];
645 struct pci_dev *PCI_Device = NULL;
646 int i;
647 if (BusLogic_ProbeInfoCount >= BusLogic_MaxHostAdapters)
648 return 0;
649 BusLogic_ProbeInfoCount++;
650 for (i = 0; i < 6; i++)
651 StandardAddressSeen[i] = false;
652 /*
653 Iterate over the MultiMaster PCI Host Adapters. For each enumerated host
654 adapter, determine whether its ISA Compatible I/O Port is enabled and if
655 so, whether it is assigned the Primary I/O Address. A host adapter that is
656 assigned the Primary I/O Address will always be the preferred boot device.
657 The MultiMaster BIOS will first recognize a host adapter at the Primary I/O
658 Address, then any other PCI host adapters, and finally any host adapters
659 located at the remaining standard ISA I/O Addresses. When a PCI host
660 adapter is found with its ISA Compatible I/O Port enabled, a command is
661 issued to disable the ISA Compatible I/O Port, and it is noted that the
662 particular standard ISA I/O Address need not be probed.
663 */
664 PrimaryProbeInfo->IO_Address = 0;
665 while ((PCI_Device = pci_find_device(PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER, PCI_Device)) != NULL) {
666 struct BusLogic_HostAdapter *HostAdapter = PrototypeHostAdapter;
667 struct BusLogic_PCIHostAdapterInformation PCIHostAdapterInformation;
668 enum BusLogic_ISACompatibleIOPort ModifyIOAddressRequest;
669 unsigned char Bus;
670 unsigned char Device;
671 unsigned int IRQ_Channel;
672 unsigned long BaseAddress0;
673 unsigned long BaseAddress1;
674 unsigned long IO_Address;
675 unsigned long PCI_Address;
676
677 if (pci_enable_device(PCI_Device))
678 continue;
679
910638ae 680 if (pci_set_dma_mask(PCI_Device, DMA_32BIT_MASK ))
1da177e4
LT
681 continue;
682
683 Bus = PCI_Device->bus->number;
684 Device = PCI_Device->devfn >> 3;
685 IRQ_Channel = PCI_Device->irq;
686 IO_Address = BaseAddress0 = pci_resource_start(PCI_Device, 0);
687 PCI_Address = BaseAddress1 = pci_resource_start(PCI_Device, 1);
688
689 if (pci_resource_flags(PCI_Device, 0) & IORESOURCE_MEM) {
690 BusLogic_Error("BusLogic: Base Address0 0x%X not I/O for " "MultiMaster Host Adapter\n", NULL, BaseAddress0);
691 BusLogic_Error("at PCI Bus %d Device %d I/O Address 0x%X\n", NULL, Bus, Device, IO_Address);
692 continue;
693 }
694 if (pci_resource_flags(PCI_Device, 1) & IORESOURCE_IO) {
695 BusLogic_Error("BusLogic: Base Address1 0x%X not Memory for " "MultiMaster Host Adapter\n", NULL, BaseAddress1);
696 BusLogic_Error("at PCI Bus %d Device %d PCI Address 0x%X\n", NULL, Bus, Device, PCI_Address);
697 continue;
698 }
699 if (IRQ_Channel == 0) {
700 BusLogic_Error("BusLogic: IRQ Channel %d invalid for " "MultiMaster Host Adapter\n", NULL, IRQ_Channel);
701 BusLogic_Error("at PCI Bus %d Device %d I/O Address 0x%X\n", NULL, Bus, Device, IO_Address);
702 continue;
703 }
704 if (BusLogic_GlobalOptions.TraceProbe) {
705 BusLogic_Notice("BusLogic: PCI MultiMaster Host Adapter " "detected at\n", NULL);
706 BusLogic_Notice("BusLogic: PCI Bus %d Device %d I/O Address " "0x%X PCI Address 0x%X\n", NULL, Bus, Device, IO_Address, PCI_Address);
707 }
708 /*
709 Issue the Inquire PCI Host Adapter Information command to determine
710 the ISA Compatible I/O Port. If the ISA Compatible I/O Port is
711 known and enabled, note that the particular Standard ISA I/O
712 Address should not be probed.
713 */
714 HostAdapter->IO_Address = IO_Address;
715 BusLogic_InterruptReset(HostAdapter);
716 if (BusLogic_Command(HostAdapter, BusLogic_InquirePCIHostAdapterInformation, NULL, 0, &PCIHostAdapterInformation, sizeof(PCIHostAdapterInformation))
717 == sizeof(PCIHostAdapterInformation)) {
718 if (PCIHostAdapterInformation.ISACompatibleIOPort < 6)
719 StandardAddressSeen[PCIHostAdapterInformation.ISACompatibleIOPort] = true;
720 } else
721 PCIHostAdapterInformation.ISACompatibleIOPort = BusLogic_IO_Disable;
722 /*
723 * Issue the Modify I/O Address command to disable the ISA Compatible
724 * I/O Port. On PCI Host Adapters, the Modify I/O Address command
725 * allows modification of the ISA compatible I/O Address that the Host
726 * Adapter responds to; it does not affect the PCI compliant I/O Address
727 * assigned at system initialization.
728 */
729 ModifyIOAddressRequest = BusLogic_IO_Disable;
730 BusLogic_Command(HostAdapter, BusLogic_ModifyIOAddress, &ModifyIOAddressRequest, sizeof(ModifyIOAddressRequest), NULL, 0);
731 /*
732 For the first MultiMaster Host Adapter enumerated, issue the Fetch
733 Host Adapter Local RAM command to read byte 45 of the AutoSCSI area,
734 for the setting of the "Use Bus And Device # For PCI Scanning Seq."
735 option. Issue the Inquire Board ID command since this option is
736 only valid for the BT-948/958/958D.
737 */
738 if (!ForceBusDeviceScanningOrderChecked) {
739 struct BusLogic_FetchHostAdapterLocalRAMRequest FetchHostAdapterLocalRAMRequest;
740 struct BusLogic_AutoSCSIByte45 AutoSCSIByte45;
741 struct BusLogic_BoardID BoardID;
742 FetchHostAdapterLocalRAMRequest.ByteOffset = BusLogic_AutoSCSI_BaseOffset + 45;
743 FetchHostAdapterLocalRAMRequest.ByteCount = sizeof(AutoSCSIByte45);
744 BusLogic_Command(HostAdapter, BusLogic_FetchHostAdapterLocalRAM, &FetchHostAdapterLocalRAMRequest, sizeof(FetchHostAdapterLocalRAMRequest), &AutoSCSIByte45, sizeof(AutoSCSIByte45));
745 BusLogic_Command(HostAdapter, BusLogic_InquireBoardID, NULL, 0, &BoardID, sizeof(BoardID));
746 if (BoardID.FirmwareVersion1stDigit == '5')
747 ForceBusDeviceScanningOrder = AutoSCSIByte45.ForceBusDeviceScanningOrder;
748 ForceBusDeviceScanningOrderChecked = true;
749 }
750 /*
751 Determine whether this MultiMaster Host Adapter has its ISA
752 Compatible I/O Port enabled and is assigned the Primary I/O Address.
753 If it does, then it is the Primary MultiMaster Host Adapter and must
754 be recognized first. If it does not, then it is added to the list
755 for probing after any Primary MultiMaster Host Adapter is probed.
756 */
757 if (PCIHostAdapterInformation.ISACompatibleIOPort == BusLogic_IO_330) {
758 PrimaryProbeInfo->HostAdapterType = BusLogic_MultiMaster;
759 PrimaryProbeInfo->HostAdapterBusType = BusLogic_PCI_Bus;
760 PrimaryProbeInfo->IO_Address = IO_Address;
761 PrimaryProbeInfo->PCI_Address = PCI_Address;
762 PrimaryProbeInfo->Bus = Bus;
763 PrimaryProbeInfo->Device = Device;
764 PrimaryProbeInfo->IRQ_Channel = IRQ_Channel;
765 PrimaryProbeInfo->PCI_Device = PCI_Device;
766 PCIMultiMasterCount++;
767 } else if (BusLogic_ProbeInfoCount < BusLogic_MaxHostAdapters) {
768 struct BusLogic_ProbeInfo *ProbeInfo = &BusLogic_ProbeInfoList[BusLogic_ProbeInfoCount++];
769 ProbeInfo->HostAdapterType = BusLogic_MultiMaster;
770 ProbeInfo->HostAdapterBusType = BusLogic_PCI_Bus;
771 ProbeInfo->IO_Address = IO_Address;
772 ProbeInfo->PCI_Address = PCI_Address;
773 ProbeInfo->Bus = Bus;
774 ProbeInfo->Device = Device;
775 ProbeInfo->IRQ_Channel = IRQ_Channel;
776 ProbeInfo->PCI_Device = PCI_Device;
777 NonPrimaryPCIMultiMasterCount++;
778 PCIMultiMasterCount++;
779 } else
780 BusLogic_Warning("BusLogic: Too many Host Adapters " "detected\n", NULL);
781 }
782 /*
783 If the AutoSCSI "Use Bus And Device # For PCI Scanning Seq." option is ON
784 for the first enumerated MultiMaster Host Adapter, and if that host adapter
785 is a BT-948/958/958D, then the MultiMaster BIOS will recognize MultiMaster
786 Host Adapters in the order of increasing PCI Bus and Device Number. In
787 that case, sort the probe information into the same order the BIOS uses.
788 If this option is OFF, then the MultiMaster BIOS will recognize MultiMaster
789 Host Adapters in the order they are enumerated by the PCI BIOS, and hence
790 no sorting is necessary.
791 */
792 if (ForceBusDeviceScanningOrder)
793 BusLogic_SortProbeInfo(&BusLogic_ProbeInfoList[NonPrimaryPCIMultiMasterIndex], NonPrimaryPCIMultiMasterCount);
794 /*
795 If no PCI MultiMaster Host Adapter is assigned the Primary I/O Address,
796 then the Primary I/O Address must be probed explicitly before any PCI
797 host adapters are probed.
798 */
799 if (!BusLogic_ProbeOptions.NoProbeISA)
800 if (PrimaryProbeInfo->IO_Address == 0 && (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe330 : check_region(0x330, BusLogic_MultiMasterAddressCount) == 0)) {
801 PrimaryProbeInfo->HostAdapterType = BusLogic_MultiMaster;
802 PrimaryProbeInfo->HostAdapterBusType = BusLogic_ISA_Bus;
803 PrimaryProbeInfo->IO_Address = 0x330;
804 }
805 /*
806 Append the list of standard BusLogic MultiMaster ISA I/O Addresses,
807 omitting the Primary I/O Address which has already been handled.
808 */
809 if (!BusLogic_ProbeOptions.NoProbeISA) {
810 if (!StandardAddressSeen[1] && (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe334 : check_region(0x334, BusLogic_MultiMasterAddressCount) == 0))
811 BusLogic_AppendProbeAddressISA(0x334);
812 if (!StandardAddressSeen[2] && (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe230 : check_region(0x230, BusLogic_MultiMasterAddressCount) == 0))
813 BusLogic_AppendProbeAddressISA(0x230);
814 if (!StandardAddressSeen[3] && (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe234 : check_region(0x234, BusLogic_MultiMasterAddressCount) == 0))
815 BusLogic_AppendProbeAddressISA(0x234);
816 if (!StandardAddressSeen[4] && (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe130 : check_region(0x130, BusLogic_MultiMasterAddressCount) == 0))
817 BusLogic_AppendProbeAddressISA(0x130);
818 if (!StandardAddressSeen[5] && (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe134 : check_region(0x134, BusLogic_MultiMasterAddressCount) == 0))
819 BusLogic_AppendProbeAddressISA(0x134);
820 }
821 /*
822 Iterate over the older non-compliant MultiMaster PCI Host Adapters,
823 noting the PCI bus location and assigned IRQ Channel.
824 */
825 PCI_Device = NULL;
826 while ((PCI_Device = pci_find_device(PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER_NC, PCI_Device)) != NULL) {
827 unsigned char Bus;
828 unsigned char Device;
829 unsigned int IRQ_Channel;
830 unsigned long IO_Address;
831
832 if (pci_enable_device(PCI_Device))
833 continue;
834
910638ae 835 if (pci_set_dma_mask(PCI_Device, DMA_32BIT_MASK))
1da177e4
LT
836 continue;
837
838 Bus = PCI_Device->bus->number;
839 Device = PCI_Device->devfn >> 3;
840 IRQ_Channel = PCI_Device->irq;
841 IO_Address = pci_resource_start(PCI_Device, 0);
842
843 if (IO_Address == 0 || IRQ_Channel == 0)
844 continue;
845 for (i = 0; i < BusLogic_ProbeInfoCount; i++) {
846 struct BusLogic_ProbeInfo *ProbeInfo = &BusLogic_ProbeInfoList[i];
847 if (ProbeInfo->IO_Address == IO_Address && ProbeInfo->HostAdapterType == BusLogic_MultiMaster) {
848 ProbeInfo->HostAdapterBusType = BusLogic_PCI_Bus;
849 ProbeInfo->PCI_Address = 0;
850 ProbeInfo->Bus = Bus;
851 ProbeInfo->Device = Device;
852 ProbeInfo->IRQ_Channel = IRQ_Channel;
853 ProbeInfo->PCI_Device = PCI_Device;
854 break;
855 }
856 }
857 }
858 return PCIMultiMasterCount;
859}
860
861
862/*
863 BusLogic_InitializeFlashPointProbeInfo initializes the list of I/O Address
864 and Bus Probe Information to be checked for potential BusLogic FlashPoint
865 Host Adapters by interrogating the PCI Configuration Space. It returns the
866 number of FlashPoint Host Adapters found.
867*/
868
869static int __init BusLogic_InitializeFlashPointProbeInfo(struct BusLogic_HostAdapter
870 *PrototypeHostAdapter)
871{
872 int FlashPointIndex = BusLogic_ProbeInfoCount, FlashPointCount = 0;
873 struct pci_dev *PCI_Device = NULL;
874 /*
875 Interrogate PCI Configuration Space for any FlashPoint Host Adapters.
876 */
877 while ((PCI_Device = pci_find_device(PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_FLASHPOINT, PCI_Device)) != NULL) {
878 unsigned char Bus;
879 unsigned char Device;
880 unsigned int IRQ_Channel;
881 unsigned long BaseAddress0;
882 unsigned long BaseAddress1;
883 unsigned long IO_Address;
884 unsigned long PCI_Address;
885
886 if (pci_enable_device(PCI_Device))
887 continue;
888
910638ae 889 if (pci_set_dma_mask(PCI_Device, DMA_32BIT_MASK))
1da177e4
LT
890 continue;
891
892 Bus = PCI_Device->bus->number;
893 Device = PCI_Device->devfn >> 3;
894 IRQ_Channel = PCI_Device->irq;
895 IO_Address = BaseAddress0 = pci_resource_start(PCI_Device, 0);
896 PCI_Address = BaseAddress1 = pci_resource_start(PCI_Device, 1);
897#ifndef CONFIG_SCSI_OMIT_FLASHPOINT
898 if (pci_resource_flags(PCI_Device, 0) & IORESOURCE_MEM) {
899 BusLogic_Error("BusLogic: Base Address0 0x%X not I/O for " "FlashPoint Host Adapter\n", NULL, BaseAddress0);
900 BusLogic_Error("at PCI Bus %d Device %d I/O Address 0x%X\n", NULL, Bus, Device, IO_Address);
901 continue;
902 }
903 if (pci_resource_flags(PCI_Device, 1) & IORESOURCE_IO) {
904 BusLogic_Error("BusLogic: Base Address1 0x%X not Memory for " "FlashPoint Host Adapter\n", NULL, BaseAddress1);
905 BusLogic_Error("at PCI Bus %d Device %d PCI Address 0x%X\n", NULL, Bus, Device, PCI_Address);
906 continue;
907 }
908 if (IRQ_Channel == 0) {
909 BusLogic_Error("BusLogic: IRQ Channel %d invalid for " "FlashPoint Host Adapter\n", NULL, IRQ_Channel);
910 BusLogic_Error("at PCI Bus %d Device %d I/O Address 0x%X\n", NULL, Bus, Device, IO_Address);
911 continue;
912 }
913 if (BusLogic_GlobalOptions.TraceProbe) {
914 BusLogic_Notice("BusLogic: FlashPoint Host Adapter " "detected at\n", NULL);
915 BusLogic_Notice("BusLogic: PCI Bus %d Device %d I/O Address " "0x%X PCI Address 0x%X\n", NULL, Bus, Device, IO_Address, PCI_Address);
916 }
917 if (BusLogic_ProbeInfoCount < BusLogic_MaxHostAdapters) {
918 struct BusLogic_ProbeInfo *ProbeInfo = &BusLogic_ProbeInfoList[BusLogic_ProbeInfoCount++];
919 ProbeInfo->HostAdapterType = BusLogic_FlashPoint;
920 ProbeInfo->HostAdapterBusType = BusLogic_PCI_Bus;
921 ProbeInfo->IO_Address = IO_Address;
922 ProbeInfo->PCI_Address = PCI_Address;
923 ProbeInfo->Bus = Bus;
924 ProbeInfo->Device = Device;
925 ProbeInfo->IRQ_Channel = IRQ_Channel;
926 ProbeInfo->PCI_Device = PCI_Device;
927 FlashPointCount++;
928 } else
929 BusLogic_Warning("BusLogic: Too many Host Adapters " "detected\n", NULL);
930#else
931 BusLogic_Error("BusLogic: FlashPoint Host Adapter detected at " "PCI Bus %d Device %d\n", NULL, Bus, Device);
932 BusLogic_Error("BusLogic: I/O Address 0x%X PCI Address 0x%X, irq %d, " "but FlashPoint\n", NULL, IO_Address, PCI_Address, IRQ_Channel);
933 BusLogic_Error("BusLogic: support was omitted in this kernel " "configuration.\n", NULL);
934#endif
935 }
936 /*
937 The FlashPoint BIOS will scan for FlashPoint Host Adapters in the order of
938 increasing PCI Bus and Device Number, so sort the probe information into
939 the same order the BIOS uses.
940 */
941 BusLogic_SortProbeInfo(&BusLogic_ProbeInfoList[FlashPointIndex], FlashPointCount);
942 return FlashPointCount;
943}
944
945
946/*
947 BusLogic_InitializeProbeInfoList initializes the list of I/O Address and Bus
948 Probe Information to be checked for potential BusLogic SCSI Host Adapters by
949 interrogating the PCI Configuration Space on PCI machines as well as from the
950 list of standard BusLogic MultiMaster ISA I/O Addresses. By default, if both
951 FlashPoint and PCI MultiMaster Host Adapters are present, this driver will
952 probe for FlashPoint Host Adapters first unless the BIOS primary disk is
953 controlled by the first PCI MultiMaster Host Adapter, in which case
954 MultiMaster Host Adapters will be probed first. The BusLogic Driver Options
955 specifications "MultiMasterFirst" and "FlashPointFirst" can be used to force
956 a particular probe order.
957*/
958
959static void __init BusLogic_InitializeProbeInfoList(struct BusLogic_HostAdapter
960 *PrototypeHostAdapter)
961{
962 /*
963 If a PCI BIOS is present, interrogate it for MultiMaster and FlashPoint
964 Host Adapters; otherwise, default to the standard ISA MultiMaster probe.
965 */
966 if (!BusLogic_ProbeOptions.NoProbePCI) {
967 if (BusLogic_ProbeOptions.MultiMasterFirst) {
968 BusLogic_InitializeMultiMasterProbeInfo(PrototypeHostAdapter);
969 BusLogic_InitializeFlashPointProbeInfo(PrototypeHostAdapter);
970 } else if (BusLogic_ProbeOptions.FlashPointFirst) {
971 BusLogic_InitializeFlashPointProbeInfo(PrototypeHostAdapter);
972 BusLogic_InitializeMultiMasterProbeInfo(PrototypeHostAdapter);
973 } else {
974 int FlashPointCount = BusLogic_InitializeFlashPointProbeInfo(PrototypeHostAdapter);
975 int PCIMultiMasterCount = BusLogic_InitializeMultiMasterProbeInfo(PrototypeHostAdapter);
976 if (FlashPointCount > 0 && PCIMultiMasterCount > 0) {
977 struct BusLogic_ProbeInfo *ProbeInfo = &BusLogic_ProbeInfoList[FlashPointCount];
978 struct BusLogic_HostAdapter *HostAdapter = PrototypeHostAdapter;
979 struct BusLogic_FetchHostAdapterLocalRAMRequest FetchHostAdapterLocalRAMRequest;
980 struct BusLogic_BIOSDriveMapByte Drive0MapByte;
981 while (ProbeInfo->HostAdapterBusType != BusLogic_PCI_Bus)
982 ProbeInfo++;
983 HostAdapter->IO_Address = ProbeInfo->IO_Address;
984 FetchHostAdapterLocalRAMRequest.ByteOffset = BusLogic_BIOS_BaseOffset + BusLogic_BIOS_DriveMapOffset + 0;
985 FetchHostAdapterLocalRAMRequest.ByteCount = sizeof(Drive0MapByte);
986 BusLogic_Command(HostAdapter, BusLogic_FetchHostAdapterLocalRAM, &FetchHostAdapterLocalRAMRequest, sizeof(FetchHostAdapterLocalRAMRequest), &Drive0MapByte, sizeof(Drive0MapByte));
987 /*
988 If the Map Byte for BIOS Drive 0 indicates that BIOS Drive 0
989 is controlled by this PCI MultiMaster Host Adapter, then
990 reverse the probe order so that MultiMaster Host Adapters are
991 probed before FlashPoint Host Adapters.
992 */
993 if (Drive0MapByte.DiskGeometry != BusLogic_BIOS_Disk_Not_Installed) {
994 struct BusLogic_ProbeInfo SavedProbeInfo[BusLogic_MaxHostAdapters];
995 int MultiMasterCount = BusLogic_ProbeInfoCount - FlashPointCount;
996 memcpy(SavedProbeInfo, BusLogic_ProbeInfoList, BusLogic_ProbeInfoCount * sizeof(struct BusLogic_ProbeInfo));
997 memcpy(&BusLogic_ProbeInfoList[0], &SavedProbeInfo[FlashPointCount], MultiMasterCount * sizeof(struct BusLogic_ProbeInfo));
998 memcpy(&BusLogic_ProbeInfoList[MultiMasterCount], &SavedProbeInfo[0], FlashPointCount * sizeof(struct BusLogic_ProbeInfo));
999 }
1000 }
1001 }
1002 } else
1003 BusLogic_InitializeProbeInfoListISA(PrototypeHostAdapter);
1004}
1005
1006
1007#endif /* CONFIG_PCI */
1008
1009
1010/*
1011 BusLogic_Failure prints a standardized error message, and then returns false.
1012*/
1013
1014static boolean BusLogic_Failure(struct BusLogic_HostAdapter *HostAdapter, char *ErrorMessage)
1015{
1016 BusLogic_AnnounceDriver(HostAdapter);
1017 if (HostAdapter->HostAdapterBusType == BusLogic_PCI_Bus) {
1018 BusLogic_Error("While configuring BusLogic PCI Host Adapter at\n", HostAdapter);
1019 BusLogic_Error("Bus %d Device %d I/O Address 0x%X PCI Address 0x%X:\n", HostAdapter, HostAdapter->Bus, HostAdapter->Device, HostAdapter->IO_Address, HostAdapter->PCI_Address);
1020 } else
1021 BusLogic_Error("While configuring BusLogic Host Adapter at " "I/O Address 0x%X:\n", HostAdapter, HostAdapter->IO_Address);
1022 BusLogic_Error("%s FAILED - DETACHING\n", HostAdapter, ErrorMessage);
1023 if (BusLogic_CommandFailureReason != NULL)
1024 BusLogic_Error("ADDITIONAL FAILURE INFO - %s\n", HostAdapter, BusLogic_CommandFailureReason);
1025 return false;
1026}
1027
1028
1029/*
1030 BusLogic_ProbeHostAdapter probes for a BusLogic Host Adapter.
1031*/
1032
1033static boolean __init BusLogic_ProbeHostAdapter(struct BusLogic_HostAdapter *HostAdapter)
1034{
1035 union BusLogic_StatusRegister StatusRegister;
1036 union BusLogic_InterruptRegister InterruptRegister;
1037 union BusLogic_GeometryRegister GeometryRegister;
1038 /*
1039 FlashPoint Host Adapters are Probed by the FlashPoint SCCB Manager.
1040 */
1041 if (BusLogic_FlashPointHostAdapterP(HostAdapter)) {
1042 struct FlashPoint_Info *FlashPointInfo = &HostAdapter->FlashPointInfo;
1043 FlashPointInfo->BaseAddress = (u32) HostAdapter->IO_Address;
1044 FlashPointInfo->IRQ_Channel = HostAdapter->IRQ_Channel;
1045 FlashPointInfo->Present = false;
1046 if (!(FlashPoint_ProbeHostAdapter(FlashPointInfo) == 0 && FlashPointInfo->Present)) {
1047 BusLogic_Error("BusLogic: FlashPoint Host Adapter detected at " "PCI Bus %d Device %d\n", HostAdapter, HostAdapter->Bus, HostAdapter->Device);
1048 BusLogic_Error("BusLogic: I/O Address 0x%X PCI Address 0x%X, " "but FlashPoint\n", HostAdapter, HostAdapter->IO_Address, HostAdapter->PCI_Address);
1049 BusLogic_Error("BusLogic: Probe Function failed to validate it.\n", HostAdapter);
1050 return false;
1051 }
1052 if (BusLogic_GlobalOptions.TraceProbe)
1053 BusLogic_Notice("BusLogic_Probe(0x%X): FlashPoint Found\n", HostAdapter, HostAdapter->IO_Address);
1054 /*
1055 Indicate the Host Adapter Probe completed successfully.
1056 */
1057 return true;
1058 }
1059 /*
1060 Read the Status, Interrupt, and Geometry Registers to test if there are I/O
1061 ports that respond, and to check the values to determine if they are from a
1062 BusLogic Host Adapter. A nonexistent I/O port will return 0xFF, in which
1063 case there is definitely no BusLogic Host Adapter at this base I/O Address.
1064 The test here is a subset of that used by the BusLogic Host Adapter BIOS.
1065 */
1066 StatusRegister.All = BusLogic_ReadStatusRegister(HostAdapter);
1067 InterruptRegister.All = BusLogic_ReadInterruptRegister(HostAdapter);
1068 GeometryRegister.All = BusLogic_ReadGeometryRegister(HostAdapter);
1069 if (BusLogic_GlobalOptions.TraceProbe)
1070 BusLogic_Notice("BusLogic_Probe(0x%X): Status 0x%02X, Interrupt 0x%02X, " "Geometry 0x%02X\n", HostAdapter, HostAdapter->IO_Address, StatusRegister.All, InterruptRegister.All, GeometryRegister.All);
1071 if (StatusRegister.All == 0 || StatusRegister.sr.DiagnosticActive || StatusRegister.sr.CommandParameterRegisterBusy || StatusRegister.sr.Reserved || StatusRegister.sr.CommandInvalid || InterruptRegister.ir.Reserved != 0)
1072 return false;
1073 /*
1074 Check the undocumented Geometry Register to test if there is an I/O port
1075 that responded. Adaptec Host Adapters do not implement the Geometry
1076 Register, so this test helps serve to avoid incorrectly recognizing an
1077 Adaptec 1542A or 1542B as a BusLogic. Unfortunately, the Adaptec 1542C
1078 series does respond to the Geometry Register I/O port, but it will be
1079 rejected later when the Inquire Extended Setup Information command is
1080 issued in BusLogic_CheckHostAdapter. The AMI FastDisk Host Adapter is a
1081 BusLogic clone that implements the same interface as earlier BusLogic
1082 Host Adapters, including the undocumented commands, and is therefore
1083 supported by this driver. However, the AMI FastDisk always returns 0x00
1084 upon reading the Geometry Register, so the extended translation option
1085 should always be left disabled on the AMI FastDisk.
1086 */
1087 if (GeometryRegister.All == 0xFF)
1088 return false;
1089 /*
1090 Indicate the Host Adapter Probe completed successfully.
1091 */
1092 return true;
1093}
1094
1095
1096/*
1097 BusLogic_HardwareResetHostAdapter issues a Hardware Reset to the Host Adapter
1098 and waits for Host Adapter Diagnostics to complete. If HardReset is true, a
1099 Hard Reset is performed which also initiates a SCSI Bus Reset. Otherwise, a
1100 Soft Reset is performed which only resets the Host Adapter without forcing a
1101 SCSI Bus Reset.
1102*/
1103
1104static boolean BusLogic_HardwareResetHostAdapter(struct BusLogic_HostAdapter
1105 *HostAdapter, boolean HardReset)
1106{
1107 union BusLogic_StatusRegister StatusRegister;
1108 int TimeoutCounter;
1109 /*
1110 FlashPoint Host Adapters are Hard Reset by the FlashPoint SCCB Manager.
1111 */
1112 if (BusLogic_FlashPointHostAdapterP(HostAdapter)) {
1113 struct FlashPoint_Info *FlashPointInfo = &HostAdapter->FlashPointInfo;
1114 FlashPointInfo->HostSoftReset = !HardReset;
1115 FlashPointInfo->ReportDataUnderrun = true;
1116 HostAdapter->CardHandle = FlashPoint_HardwareResetHostAdapter(FlashPointInfo);
1117 if (HostAdapter->CardHandle == FlashPoint_BadCardHandle)
1118 return false;
1119 /*
1120 Indicate the Host Adapter Hard Reset completed successfully.
1121 */
1122 return true;
1123 }
1124 /*
1125 Issue a Hard Reset or Soft Reset Command to the Host Adapter. The Host
1126 Adapter should respond by setting Diagnostic Active in the Status Register.
1127 */
1128 if (HardReset)
1129 BusLogic_HardReset(HostAdapter);
1130 else
1131 BusLogic_SoftReset(HostAdapter);
1132 /*
1133 Wait until Diagnostic Active is set in the Status Register.
1134 */
1135 TimeoutCounter = 5 * 10000;
1136 while (--TimeoutCounter >= 0) {
1137 StatusRegister.All = BusLogic_ReadStatusRegister(HostAdapter);
1138 if (StatusRegister.sr.DiagnosticActive)
1139 break;
1140 udelay(100);
1141 }
1142 if (BusLogic_GlobalOptions.TraceHardwareReset)
1143 BusLogic_Notice("BusLogic_HardwareReset(0x%X): Diagnostic Active, " "Status 0x%02X\n", HostAdapter, HostAdapter->IO_Address, StatusRegister.All);
1144 if (TimeoutCounter < 0)
1145 return false;
1146 /*
1147 Wait 100 microseconds to allow completion of any initial diagnostic
1148 activity which might leave the contents of the Status Register
1149 unpredictable.
1150 */
1151 udelay(100);
1152 /*
1153 Wait until Diagnostic Active is reset in the Status Register.
1154 */
1155 TimeoutCounter = 10 * 10000;
1156 while (--TimeoutCounter >= 0) {
1157 StatusRegister.All = BusLogic_ReadStatusRegister(HostAdapter);
1158 if (!StatusRegister.sr.DiagnosticActive)
1159 break;
1160 udelay(100);
1161 }
1162 if (BusLogic_GlobalOptions.TraceHardwareReset)
1163 BusLogic_Notice("BusLogic_HardwareReset(0x%X): Diagnostic Completed, " "Status 0x%02X\n", HostAdapter, HostAdapter->IO_Address, StatusRegister.All);
1164 if (TimeoutCounter < 0)
1165 return false;
1166 /*
1167 Wait until at least one of the Diagnostic Failure, Host Adapter Ready,
1168 or Data In Register Ready bits is set in the Status Register.
1169 */
1170 TimeoutCounter = 10000;
1171 while (--TimeoutCounter >= 0) {
1172 StatusRegister.All = BusLogic_ReadStatusRegister(HostAdapter);
1173 if (StatusRegister.sr.DiagnosticFailure || StatusRegister.sr.HostAdapterReady || StatusRegister.sr.DataInRegisterReady)
1174 break;
1175 udelay(100);
1176 }
1177 if (BusLogic_GlobalOptions.TraceHardwareReset)
1178 BusLogic_Notice("BusLogic_HardwareReset(0x%X): Host Adapter Ready, " "Status 0x%02X\n", HostAdapter, HostAdapter->IO_Address, StatusRegister.All);
1179 if (TimeoutCounter < 0)
1180 return false;
1181 /*
1182 If Diagnostic Failure is set or Host Adapter Ready is reset, then an
1183 error occurred during the Host Adapter diagnostics. If Data In Register
1184 Ready is set, then there is an Error Code available.
1185 */
1186 if (StatusRegister.sr.DiagnosticFailure || !StatusRegister.sr.HostAdapterReady) {
1187 BusLogic_CommandFailureReason = NULL;
1188 BusLogic_Failure(HostAdapter, "HARD RESET DIAGNOSTICS");
1189 BusLogic_Error("HOST ADAPTER STATUS REGISTER = %02X\n", HostAdapter, StatusRegister.All);
1190 if (StatusRegister.sr.DataInRegisterReady) {
1191 unsigned char ErrorCode = BusLogic_ReadDataInRegister(HostAdapter);
1192 BusLogic_Error("HOST ADAPTER ERROR CODE = %d\n", HostAdapter, ErrorCode);
1193 }
1194 return false;
1195 }
1196 /*
1197 Indicate the Host Adapter Hard Reset completed successfully.
1198 */
1199 return true;
1200}
1201
1202
1203/*
1204 BusLogic_CheckHostAdapter checks to be sure this really is a BusLogic
1205 Host Adapter.
1206*/
1207
1208static boolean __init BusLogic_CheckHostAdapter(struct BusLogic_HostAdapter *HostAdapter)
1209{
1210 struct BusLogic_ExtendedSetupInformation ExtendedSetupInformation;
1211 unsigned char RequestedReplyLength;
1212 boolean Result = true;
1213 /*
1214 FlashPoint Host Adapters do not require this protection.
1215 */
1216 if (BusLogic_FlashPointHostAdapterP(HostAdapter))
1217 return true;
1218 /*
1219 Issue the Inquire Extended Setup Information command. Only genuine
1220 BusLogic Host Adapters and true clones support this command. Adaptec 1542C
1221 series Host Adapters that respond to the Geometry Register I/O port will
1222 fail this command.
1223 */
1224 RequestedReplyLength = sizeof(ExtendedSetupInformation);
1225 if (BusLogic_Command(HostAdapter, BusLogic_InquireExtendedSetupInformation, &RequestedReplyLength, sizeof(RequestedReplyLength), &ExtendedSetupInformation, sizeof(ExtendedSetupInformation))
1226 != sizeof(ExtendedSetupInformation))
1227 Result = false;
1228 /*
1229 Provide tracing information if requested and return.
1230 */
1231 if (BusLogic_GlobalOptions.TraceProbe)
1232 BusLogic_Notice("BusLogic_Check(0x%X): MultiMaster %s\n", HostAdapter, HostAdapter->IO_Address, (Result ? "Found" : "Not Found"));
1233 return Result;
1234}
1235
1236
1237/*
1238 BusLogic_ReadHostAdapterConfiguration reads the Configuration Information
1239 from Host Adapter and initializes the Host Adapter structure.
1240*/
1241
1242static boolean __init BusLogic_ReadHostAdapterConfiguration(struct BusLogic_HostAdapter
1243 *HostAdapter)
1244{
1245 struct BusLogic_BoardID BoardID;
1246 struct BusLogic_Configuration Configuration;
1247 struct BusLogic_SetupInformation SetupInformation;
1248 struct BusLogic_ExtendedSetupInformation ExtendedSetupInformation;
1249 unsigned char HostAdapterModelNumber[5];
1250 unsigned char FirmwareVersion3rdDigit;
1251 unsigned char FirmwareVersionLetter;
1252 struct BusLogic_PCIHostAdapterInformation PCIHostAdapterInformation;
1253 struct BusLogic_FetchHostAdapterLocalRAMRequest FetchHostAdapterLocalRAMRequest;
1254 struct BusLogic_AutoSCSIData AutoSCSIData;
1255 union BusLogic_GeometryRegister GeometryRegister;
1256 unsigned char RequestedReplyLength;
1257 unsigned char *TargetPointer, Character;
1258 int TargetID, i;
1259 /*
1260 Configuration Information for FlashPoint Host Adapters is provided in the
1261 FlashPoint_Info structure by the FlashPoint SCCB Manager's Probe Function.
1262 Initialize fields in the Host Adapter structure from the FlashPoint_Info
1263 structure.
1264 */
1265 if (BusLogic_FlashPointHostAdapterP(HostAdapter)) {
1266 struct FlashPoint_Info *FlashPointInfo = &HostAdapter->FlashPointInfo;
1267 TargetPointer = HostAdapter->ModelName;
1268 *TargetPointer++ = 'B';
1269 *TargetPointer++ = 'T';
1270 *TargetPointer++ = '-';
1271 for (i = 0; i < sizeof(FlashPointInfo->ModelNumber); i++)
1272 *TargetPointer++ = FlashPointInfo->ModelNumber[i];
1273 *TargetPointer++ = '\0';
1274 strcpy(HostAdapter->FirmwareVersion, FlashPoint_FirmwareVersion);
1275 HostAdapter->SCSI_ID = FlashPointInfo->SCSI_ID;
1276 HostAdapter->ExtendedTranslationEnabled = FlashPointInfo->ExtendedTranslationEnabled;
1277 HostAdapter->ParityCheckingEnabled = FlashPointInfo->ParityCheckingEnabled;
1278 HostAdapter->BusResetEnabled = !FlashPointInfo->HostSoftReset;
1279 HostAdapter->LevelSensitiveInterrupt = true;
1280 HostAdapter->HostWideSCSI = FlashPointInfo->HostWideSCSI;
1281 HostAdapter->HostDifferentialSCSI = false;
1282 HostAdapter->HostSupportsSCAM = true;
1283 HostAdapter->HostUltraSCSI = true;
1284 HostAdapter->ExtendedLUNSupport = true;
1285 HostAdapter->TerminationInfoValid = true;
1286 HostAdapter->LowByteTerminated = FlashPointInfo->LowByteTerminated;
1287 HostAdapter->HighByteTerminated = FlashPointInfo->HighByteTerminated;
1288 HostAdapter->SCAM_Enabled = FlashPointInfo->SCAM_Enabled;
1289 HostAdapter->SCAM_Level2 = FlashPointInfo->SCAM_Level2;
1290 HostAdapter->DriverScatterGatherLimit = BusLogic_ScatterGatherLimit;
1291 HostAdapter->MaxTargetDevices = (HostAdapter->HostWideSCSI ? 16 : 8);
1292 HostAdapter->MaxLogicalUnits = 32;
1293 HostAdapter->InitialCCBs = 4 * BusLogic_CCB_AllocationGroupSize;
1294 HostAdapter->IncrementalCCBs = BusLogic_CCB_AllocationGroupSize;
1295 HostAdapter->DriverQueueDepth = 255;
1296 HostAdapter->HostAdapterQueueDepth = HostAdapter->DriverQueueDepth;
1297 HostAdapter->SynchronousPermitted = FlashPointInfo->SynchronousPermitted;
1298 HostAdapter->FastPermitted = FlashPointInfo->FastPermitted;
1299 HostAdapter->UltraPermitted = FlashPointInfo->UltraPermitted;
1300 HostAdapter->WidePermitted = FlashPointInfo->WidePermitted;
1301 HostAdapter->DisconnectPermitted = FlashPointInfo->DisconnectPermitted;
1302 HostAdapter->TaggedQueuingPermitted = 0xFFFF;
1303 goto Common;
1304 }
1305 /*
1306 Issue the Inquire Board ID command.
1307 */
1308 if (BusLogic_Command(HostAdapter, BusLogic_InquireBoardID, NULL, 0, &BoardID, sizeof(BoardID)) != sizeof(BoardID))
1309 return BusLogic_Failure(HostAdapter, "INQUIRE BOARD ID");
1310 /*
1311 Issue the Inquire Configuration command.
1312 */
1313 if (BusLogic_Command(HostAdapter, BusLogic_InquireConfiguration, NULL, 0, &Configuration, sizeof(Configuration))
1314 != sizeof(Configuration))
1315 return BusLogic_Failure(HostAdapter, "INQUIRE CONFIGURATION");
1316 /*
1317 Issue the Inquire Setup Information command.
1318 */
1319 RequestedReplyLength = sizeof(SetupInformation);
1320 if (BusLogic_Command(HostAdapter, BusLogic_InquireSetupInformation, &RequestedReplyLength, sizeof(RequestedReplyLength), &SetupInformation, sizeof(SetupInformation))
1321 != sizeof(SetupInformation))
1322 return BusLogic_Failure(HostAdapter, "INQUIRE SETUP INFORMATION");
1323 /*
1324 Issue the Inquire Extended Setup Information command.
1325 */
1326 RequestedReplyLength = sizeof(ExtendedSetupInformation);
1327 if (BusLogic_Command(HostAdapter, BusLogic_InquireExtendedSetupInformation, &RequestedReplyLength, sizeof(RequestedReplyLength), &ExtendedSetupInformation, sizeof(ExtendedSetupInformation))
1328 != sizeof(ExtendedSetupInformation))
1329 return BusLogic_Failure(HostAdapter, "INQUIRE EXTENDED SETUP INFORMATION");
1330 /*
1331 Issue the Inquire Firmware Version 3rd Digit command.
1332 */
1333 FirmwareVersion3rdDigit = '\0';
1334 if (BoardID.FirmwareVersion1stDigit > '0')
1335 if (BusLogic_Command(HostAdapter, BusLogic_InquireFirmwareVersion3rdDigit, NULL, 0, &FirmwareVersion3rdDigit, sizeof(FirmwareVersion3rdDigit))
1336 != sizeof(FirmwareVersion3rdDigit))
1337 return BusLogic_Failure(HostAdapter, "INQUIRE FIRMWARE 3RD DIGIT");
1338 /*
1339 Issue the Inquire Host Adapter Model Number command.
1340 */
1341 if (ExtendedSetupInformation.BusType == 'A' && BoardID.FirmwareVersion1stDigit == '2')
1342 /* BusLogic BT-542B ISA 2.xx */
1343 strcpy(HostAdapterModelNumber, "542B");
1344 else if (ExtendedSetupInformation.BusType == 'E' && BoardID.FirmwareVersion1stDigit == '2' && (BoardID.FirmwareVersion2ndDigit <= '1' || (BoardID.FirmwareVersion2ndDigit == '2' && FirmwareVersion3rdDigit == '0')))
1345 /* BusLogic BT-742A EISA 2.1x or 2.20 */
1346 strcpy(HostAdapterModelNumber, "742A");
1347 else if (ExtendedSetupInformation.BusType == 'E' && BoardID.FirmwareVersion1stDigit == '0')
1348 /* AMI FastDisk EISA Series 441 0.x */
1349 strcpy(HostAdapterModelNumber, "747A");
1350 else {
1351 RequestedReplyLength = sizeof(HostAdapterModelNumber);
1352 if (BusLogic_Command(HostAdapter, BusLogic_InquireHostAdapterModelNumber, &RequestedReplyLength, sizeof(RequestedReplyLength), &HostAdapterModelNumber, sizeof(HostAdapterModelNumber))
1353 != sizeof(HostAdapterModelNumber))
1354 return BusLogic_Failure(HostAdapter, "INQUIRE HOST ADAPTER MODEL NUMBER");
1355 }
1356 /*
1357 BusLogic MultiMaster Host Adapters can be identified by their model number
1358 and the major version number of their firmware as follows:
1359
1360 5.xx BusLogic "W" Series Host Adapters:
1361 BT-948/958/958D
1362 4.xx BusLogic "C" Series Host Adapters:
1363 BT-946C/956C/956CD/747C/757C/757CD/445C/545C/540CF
1364 3.xx BusLogic "S" Series Host Adapters:
1365 BT-747S/747D/757S/757D/445S/545S/542D
1366 BT-542B/742A (revision H)
1367 2.xx BusLogic "A" Series Host Adapters:
1368 BT-542B/742A (revision G and below)
1369 0.xx AMI FastDisk VLB/EISA BusLogic Clone Host Adapter
1370 */
1371 /*
1372 Save the Model Name and Host Adapter Name in the Host Adapter structure.
1373 */
1374 TargetPointer = HostAdapter->ModelName;
1375 *TargetPointer++ = 'B';
1376 *TargetPointer++ = 'T';
1377 *TargetPointer++ = '-';
1378 for (i = 0; i < sizeof(HostAdapterModelNumber); i++) {
1379 Character = HostAdapterModelNumber[i];
1380 if (Character == ' ' || Character == '\0')
1381 break;
1382 *TargetPointer++ = Character;
1383 }
1384 *TargetPointer++ = '\0';
1385 /*
1386 Save the Firmware Version in the Host Adapter structure.
1387 */
1388 TargetPointer = HostAdapter->FirmwareVersion;
1389 *TargetPointer++ = BoardID.FirmwareVersion1stDigit;
1390 *TargetPointer++ = '.';
1391 *TargetPointer++ = BoardID.FirmwareVersion2ndDigit;
1392 if (FirmwareVersion3rdDigit != ' ' && FirmwareVersion3rdDigit != '\0')
1393 *TargetPointer++ = FirmwareVersion3rdDigit;
1394 *TargetPointer = '\0';
1395 /*
1396 Issue the Inquire Firmware Version Letter command.
1397 */
1398 if (strcmp(HostAdapter->FirmwareVersion, "3.3") >= 0) {
1399 if (BusLogic_Command(HostAdapter, BusLogic_InquireFirmwareVersionLetter, NULL, 0, &FirmwareVersionLetter, sizeof(FirmwareVersionLetter))
1400 != sizeof(FirmwareVersionLetter))
1401 return BusLogic_Failure(HostAdapter, "INQUIRE FIRMWARE VERSION LETTER");
1402 if (FirmwareVersionLetter != ' ' && FirmwareVersionLetter != '\0')
1403 *TargetPointer++ = FirmwareVersionLetter;
1404 *TargetPointer = '\0';
1405 }
1406 /*
1407 Save the Host Adapter SCSI ID in the Host Adapter structure.
1408 */
1409 HostAdapter->SCSI_ID = Configuration.HostAdapterID;
1410 /*
1411 Determine the Bus Type and save it in the Host Adapter structure, determine
1412 and save the IRQ Channel if necessary, and determine and save the DMA
1413 Channel for ISA Host Adapters.
1414 */
1415 HostAdapter->HostAdapterBusType = BusLogic_HostAdapterBusTypes[HostAdapter->ModelName[3] - '4'];
1416 if (HostAdapter->IRQ_Channel == 0) {
1417 if (Configuration.IRQ_Channel9)
1418 HostAdapter->IRQ_Channel = 9;
1419 else if (Configuration.IRQ_Channel10)
1420 HostAdapter->IRQ_Channel = 10;
1421 else if (Configuration.IRQ_Channel11)
1422 HostAdapter->IRQ_Channel = 11;
1423 else if (Configuration.IRQ_Channel12)
1424 HostAdapter->IRQ_Channel = 12;
1425 else if (Configuration.IRQ_Channel14)
1426 HostAdapter->IRQ_Channel = 14;
1427 else if (Configuration.IRQ_Channel15)
1428 HostAdapter->IRQ_Channel = 15;
1429 }
1430 if (HostAdapter->HostAdapterBusType == BusLogic_ISA_Bus) {
1431 if (Configuration.DMA_Channel5)
1432 HostAdapter->DMA_Channel = 5;
1433 else if (Configuration.DMA_Channel6)
1434 HostAdapter->DMA_Channel = 6;
1435 else if (Configuration.DMA_Channel7)
1436 HostAdapter->DMA_Channel = 7;
1437 }
1438 /*
1439 Determine whether Extended Translation is enabled and save it in
1440 the Host Adapter structure.
1441 */
1442 GeometryRegister.All = BusLogic_ReadGeometryRegister(HostAdapter);
1443 HostAdapter->ExtendedTranslationEnabled = GeometryRegister.gr.ExtendedTranslationEnabled;
1444 /*
1445 Save the Scatter Gather Limits, Level Sensitive Interrupt flag, Wide
1446 SCSI flag, Differential SCSI flag, SCAM Supported flag, and
1447 Ultra SCSI flag in the Host Adapter structure.
1448 */
1449 HostAdapter->HostAdapterScatterGatherLimit = ExtendedSetupInformation.ScatterGatherLimit;
1450 HostAdapter->DriverScatterGatherLimit = HostAdapter->HostAdapterScatterGatherLimit;
1451 if (HostAdapter->HostAdapterScatterGatherLimit > BusLogic_ScatterGatherLimit)
1452 HostAdapter->DriverScatterGatherLimit = BusLogic_ScatterGatherLimit;
1453 if (ExtendedSetupInformation.Misc.LevelSensitiveInterrupt)
1454 HostAdapter->LevelSensitiveInterrupt = true;
1455 HostAdapter->HostWideSCSI = ExtendedSetupInformation.HostWideSCSI;
1456 HostAdapter->HostDifferentialSCSI = ExtendedSetupInformation.HostDifferentialSCSI;
1457 HostAdapter->HostSupportsSCAM = ExtendedSetupInformation.HostSupportsSCAM;
1458 HostAdapter->HostUltraSCSI = ExtendedSetupInformation.HostUltraSCSI;
1459 /*
1460 Determine whether Extended LUN Format CCBs are supported and save the
1461 information in the Host Adapter structure.
1462 */
1463 if (HostAdapter->FirmwareVersion[0] == '5' || (HostAdapter->FirmwareVersion[0] == '4' && HostAdapter->HostWideSCSI))
1464 HostAdapter->ExtendedLUNSupport = true;
1465 /*
1466 Issue the Inquire PCI Host Adapter Information command to read the
1467 Termination Information from "W" series MultiMaster Host Adapters.
1468 */
1469 if (HostAdapter->FirmwareVersion[0] == '5') {
1470 if (BusLogic_Command(HostAdapter, BusLogic_InquirePCIHostAdapterInformation, NULL, 0, &PCIHostAdapterInformation, sizeof(PCIHostAdapterInformation))
1471 != sizeof(PCIHostAdapterInformation))
1472 return BusLogic_Failure(HostAdapter, "INQUIRE PCI HOST ADAPTER INFORMATION");
1473 /*
1474 Save the Termination Information in the Host Adapter structure.
1475 */
1476 if (PCIHostAdapterInformation.GenericInfoValid) {
1477 HostAdapter->TerminationInfoValid = true;
1478 HostAdapter->LowByteTerminated = PCIHostAdapterInformation.LowByteTerminated;
1479 HostAdapter->HighByteTerminated = PCIHostAdapterInformation.HighByteTerminated;
1480 }
1481 }
1482 /*
1483 Issue the Fetch Host Adapter Local RAM command to read the AutoSCSI data
1484 from "W" and "C" series MultiMaster Host Adapters.
1485 */
1486 if (HostAdapter->FirmwareVersion[0] >= '4') {
1487 FetchHostAdapterLocalRAMRequest.ByteOffset = BusLogic_AutoSCSI_BaseOffset;
1488 FetchHostAdapterLocalRAMRequest.ByteCount = sizeof(AutoSCSIData);
1489 if (BusLogic_Command(HostAdapter, BusLogic_FetchHostAdapterLocalRAM, &FetchHostAdapterLocalRAMRequest, sizeof(FetchHostAdapterLocalRAMRequest), &AutoSCSIData, sizeof(AutoSCSIData))
1490 != sizeof(AutoSCSIData))
1491 return BusLogic_Failure(HostAdapter, "FETCH HOST ADAPTER LOCAL RAM");
1492 /*
1493 Save the Parity Checking Enabled, Bus Reset Enabled, and Termination
1494 Information in the Host Adapter structure.
1495 */
1496 HostAdapter->ParityCheckingEnabled = AutoSCSIData.ParityCheckingEnabled;
1497 HostAdapter->BusResetEnabled = AutoSCSIData.BusResetEnabled;
1498 if (HostAdapter->FirmwareVersion[0] == '4') {
1499 HostAdapter->TerminationInfoValid = true;
1500 HostAdapter->LowByteTerminated = AutoSCSIData.LowByteTerminated;
1501 HostAdapter->HighByteTerminated = AutoSCSIData.HighByteTerminated;
1502 }
1503 /*
1504 Save the Wide Permitted, Fast Permitted, Synchronous Permitted,
1505 Disconnect Permitted, Ultra Permitted, and SCAM Information in the
1506 Host Adapter structure.
1507 */
1508 HostAdapter->WidePermitted = AutoSCSIData.WidePermitted;
1509 HostAdapter->FastPermitted = AutoSCSIData.FastPermitted;
1510 HostAdapter->SynchronousPermitted = AutoSCSIData.SynchronousPermitted;
1511 HostAdapter->DisconnectPermitted = AutoSCSIData.DisconnectPermitted;
1512 if (HostAdapter->HostUltraSCSI)
1513 HostAdapter->UltraPermitted = AutoSCSIData.UltraPermitted;
1514 if (HostAdapter->HostSupportsSCAM) {
1515 HostAdapter->SCAM_Enabled = AutoSCSIData.SCAM_Enabled;
1516 HostAdapter->SCAM_Level2 = AutoSCSIData.SCAM_Level2;
1517 }
1518 }
1519 /*
1520 Initialize fields in the Host Adapter structure for "S" and "A" series
1521 MultiMaster Host Adapters.
1522 */
1523 if (HostAdapter->FirmwareVersion[0] < '4') {
1524 if (SetupInformation.SynchronousInitiationEnabled) {
1525 HostAdapter->SynchronousPermitted = 0xFF;
1526 if (HostAdapter->HostAdapterBusType == BusLogic_EISA_Bus) {
1527 if (ExtendedSetupInformation.Misc.FastOnEISA)
1528 HostAdapter->FastPermitted = 0xFF;
1529 if (strcmp(HostAdapter->ModelName, "BT-757") == 0)
1530 HostAdapter->WidePermitted = 0xFF;
1531 }
1532 }
1533 HostAdapter->DisconnectPermitted = 0xFF;
1534 HostAdapter->ParityCheckingEnabled = SetupInformation.ParityCheckingEnabled;
1535 HostAdapter->BusResetEnabled = true;
1536 }
1537 /*
1538 Determine the maximum number of Target IDs and Logical Units supported by
1539 this driver for Wide and Narrow Host Adapters.
1540 */
1541 HostAdapter->MaxTargetDevices = (HostAdapter->HostWideSCSI ? 16 : 8);
1542 HostAdapter->MaxLogicalUnits = (HostAdapter->ExtendedLUNSupport ? 32 : 8);
1543 /*
1544 Select appropriate values for the Mailbox Count, Driver Queue Depth,
1545 Initial CCBs, and Incremental CCBs variables based on whether or not Strict
1546 Round Robin Mode is supported. If Strict Round Robin Mode is supported,
1547 then there is no performance degradation in using the maximum possible
1548 number of Outgoing and Incoming Mailboxes and allowing the Tagged and
1549 Untagged Queue Depths to determine the actual utilization. If Strict Round
1550 Robin Mode is not supported, then the Host Adapter must scan all the
1551 Outgoing Mailboxes whenever an Outgoing Mailbox entry is made, which can
1552 cause a substantial performance penalty. The host adapters actually have
1553 room to store the following number of CCBs internally; that is, they can
1554 internally queue and manage this many active commands on the SCSI bus
1555 simultaneously. Performance measurements demonstrate that the Driver Queue
1556 Depth should be set to the Mailbox Count, rather than the Host Adapter
1557 Queue Depth (internal CCB capacity), as it is more efficient to have the
1558 queued commands waiting in Outgoing Mailboxes if necessary than to block
1559 the process in the higher levels of the SCSI Subsystem.
1560
1561 192 BT-948/958/958D
1562 100 BT-946C/956C/956CD/747C/757C/757CD/445C
1563 50 BT-545C/540CF
1564 30 BT-747S/747D/757S/757D/445S/545S/542D/542B/742A
1565 */
1566 if (HostAdapter->FirmwareVersion[0] == '5')
1567 HostAdapter->HostAdapterQueueDepth = 192;
1568 else if (HostAdapter->FirmwareVersion[0] == '4')
1569 HostAdapter->HostAdapterQueueDepth = (HostAdapter->HostAdapterBusType != BusLogic_ISA_Bus ? 100 : 50);
1570 else
1571 HostAdapter->HostAdapterQueueDepth = 30;
1572 if (strcmp(HostAdapter->FirmwareVersion, "3.31") >= 0) {
1573 HostAdapter->StrictRoundRobinModeSupport = true;
1574 HostAdapter->MailboxCount = BusLogic_MaxMailboxes;
1575 } else {
1576 HostAdapter->StrictRoundRobinModeSupport = false;
1577 HostAdapter->MailboxCount = 32;
1578 }
1579 HostAdapter->DriverQueueDepth = HostAdapter->MailboxCount;
1580 HostAdapter->InitialCCBs = 4 * BusLogic_CCB_AllocationGroupSize;
1581 HostAdapter->IncrementalCCBs = BusLogic_CCB_AllocationGroupSize;
1582 /*
1583 Tagged Queuing support is available and operates properly on all "W" series
1584 MultiMaster Host Adapters, on "C" series MultiMaster Host Adapters with
1585 firmware version 4.22 and above, and on "S" series MultiMaster Host
1586 Adapters with firmware version 3.35 and above.
1587 */
1588 HostAdapter->TaggedQueuingPermitted = 0;
1589 switch (HostAdapter->FirmwareVersion[0]) {
1590 case '5':
1591 HostAdapter->TaggedQueuingPermitted = 0xFFFF;
1592 break;
1593 case '4':
1594 if (strcmp(HostAdapter->FirmwareVersion, "4.22") >= 0)
1595 HostAdapter->TaggedQueuingPermitted = 0xFFFF;
1596 break;
1597 case '3':
1598 if (strcmp(HostAdapter->FirmwareVersion, "3.35") >= 0)
1599 HostAdapter->TaggedQueuingPermitted = 0xFFFF;
1600 break;
1601 }
1602 /*
1603 Determine the Host Adapter BIOS Address if the BIOS is enabled and
1604 save it in the Host Adapter structure. The BIOS is disabled if the
1605 BIOS_Address is 0.
1606 */
1607 HostAdapter->BIOS_Address = ExtendedSetupInformation.BIOS_Address << 12;
1608 /*
1609 ISA Host Adapters require Bounce Buffers if there is more than 16MB memory.
1610 */
1611 if (HostAdapter->HostAdapterBusType == BusLogic_ISA_Bus && (void *) high_memory > (void *) MAX_DMA_ADDRESS)
1612 HostAdapter->BounceBuffersRequired = true;
1613 /*
1614 BusLogic BT-445S Host Adapters prior to board revision E have a hardware
1615 bug whereby when the BIOS is enabled, transfers to/from the same address
1616 range the BIOS occupies modulo 16MB are handled incorrectly. Only properly
1617 functioning BT-445S Host Adapters have firmware version 3.37, so require
1618 that ISA Bounce Buffers be used for the buggy BT-445S models if there is
1619 more than 16MB memory.
1620 */
1621 if (HostAdapter->BIOS_Address > 0 && strcmp(HostAdapter->ModelName, "BT-445S") == 0 && strcmp(HostAdapter->FirmwareVersion, "3.37") < 0 && (void *) high_memory > (void *) MAX_DMA_ADDRESS)
1622 HostAdapter->BounceBuffersRequired = true;
1623 /*
1624 Initialize parameters common to MultiMaster and FlashPoint Host Adapters.
1625 */
1626 Common:
1627 /*
1628 Initialize the Host Adapter Full Model Name from the Model Name.
1629 */
1630 strcpy(HostAdapter->FullModelName, "BusLogic ");
1631 strcat(HostAdapter->FullModelName, HostAdapter->ModelName);
1632 /*
1633 Select an appropriate value for the Tagged Queue Depth either from a
1634 BusLogic Driver Options specification, or based on whether this Host
1635 Adapter requires that ISA Bounce Buffers be used. The Tagged Queue Depth
1636 is left at 0 for automatic determination in BusLogic_SelectQueueDepths.
1637 Initialize the Untagged Queue Depth.
1638 */
1639 for (TargetID = 0; TargetID < BusLogic_MaxTargetDevices; TargetID++) {
1640 unsigned char QueueDepth = 0;
1641 if (HostAdapter->DriverOptions != NULL && HostAdapter->DriverOptions->QueueDepth[TargetID] > 0)
1642 QueueDepth = HostAdapter->DriverOptions->QueueDepth[TargetID];
1643 else if (HostAdapter->BounceBuffersRequired)
1644 QueueDepth = BusLogic_TaggedQueueDepthBB;
1645 HostAdapter->QueueDepth[TargetID] = QueueDepth;
1646 }
1647 if (HostAdapter->BounceBuffersRequired)
1648 HostAdapter->UntaggedQueueDepth = BusLogic_UntaggedQueueDepthBB;
1649 else
1650 HostAdapter->UntaggedQueueDepth = BusLogic_UntaggedQueueDepth;
1651 if (HostAdapter->DriverOptions != NULL)
1652 HostAdapter->CommonQueueDepth = HostAdapter->DriverOptions->CommonQueueDepth;
1653 if (HostAdapter->CommonQueueDepth > 0 && HostAdapter->CommonQueueDepth < HostAdapter->UntaggedQueueDepth)
1654 HostAdapter->UntaggedQueueDepth = HostAdapter->CommonQueueDepth;
1655 /*
1656 Tagged Queuing is only allowed if Disconnect/Reconnect is permitted.
1657 Therefore, mask the Tagged Queuing Permitted Default bits with the
1658 Disconnect/Reconnect Permitted bits.
1659 */
1660 HostAdapter->TaggedQueuingPermitted &= HostAdapter->DisconnectPermitted;
1661 /*
1662 Combine the default Tagged Queuing Permitted bits with any BusLogic Driver
1663 Options Tagged Queuing specification.
1664 */
1665 if (HostAdapter->DriverOptions != NULL)
1666 HostAdapter->TaggedQueuingPermitted =
1667 (HostAdapter->DriverOptions->TaggedQueuingPermitted & HostAdapter->DriverOptions->TaggedQueuingPermittedMask) | (HostAdapter->TaggedQueuingPermitted & ~HostAdapter->DriverOptions->TaggedQueuingPermittedMask);
1668
1669 /*
1670 Select an appropriate value for Bus Settle Time either from a BusLogic
1671 Driver Options specification, or from BusLogic_DefaultBusSettleTime.
1672 */
1673 if (HostAdapter->DriverOptions != NULL && HostAdapter->DriverOptions->BusSettleTime > 0)
1674 HostAdapter->BusSettleTime = HostAdapter->DriverOptions->BusSettleTime;
1675 else
1676 HostAdapter->BusSettleTime = BusLogic_DefaultBusSettleTime;
1677 /*
1678 Indicate reading the Host Adapter Configuration completed successfully.
1679 */
1680 return true;
1681}
1682
1683
1684/*
1685 BusLogic_ReportHostAdapterConfiguration reports the configuration of
1686 Host Adapter.
1687*/
1688
1689static boolean __init BusLogic_ReportHostAdapterConfiguration(struct BusLogic_HostAdapter
1690 *HostAdapter)
1691{
1692 unsigned short AllTargetsMask = (1 << HostAdapter->MaxTargetDevices) - 1;
1693 unsigned short SynchronousPermitted, FastPermitted;
1694 unsigned short UltraPermitted, WidePermitted;
1695 unsigned short DisconnectPermitted, TaggedQueuingPermitted;
1696 boolean CommonSynchronousNegotiation, CommonTaggedQueueDepth;
1697 char SynchronousString[BusLogic_MaxTargetDevices + 1];
1698 char WideString[BusLogic_MaxTargetDevices + 1];
1699 char DisconnectString[BusLogic_MaxTargetDevices + 1];
1700 char TaggedQueuingString[BusLogic_MaxTargetDevices + 1];
1701 char *SynchronousMessage = SynchronousString;
1702 char *WideMessage = WideString;
1703 char *DisconnectMessage = DisconnectString;
1704 char *TaggedQueuingMessage = TaggedQueuingString;
1705 int TargetID;
1706 BusLogic_Info("Configuring BusLogic Model %s %s%s%s%s SCSI Host Adapter\n",
1707 HostAdapter, HostAdapter->ModelName,
1708 BusLogic_HostAdapterBusNames[HostAdapter->HostAdapterBusType], (HostAdapter->HostWideSCSI ? " Wide" : ""), (HostAdapter->HostDifferentialSCSI ? " Differential" : ""), (HostAdapter->HostUltraSCSI ? " Ultra" : ""));
1709 BusLogic_Info(" Firmware Version: %s, I/O Address: 0x%X, " "IRQ Channel: %d/%s\n", HostAdapter, HostAdapter->FirmwareVersion, HostAdapter->IO_Address, HostAdapter->IRQ_Channel, (HostAdapter->LevelSensitiveInterrupt ? "Level" : "Edge"));
1710 if (HostAdapter->HostAdapterBusType != BusLogic_PCI_Bus) {
1711 BusLogic_Info(" DMA Channel: ", HostAdapter);
1712 if (HostAdapter->DMA_Channel > 0)
1713 BusLogic_Info("%d, ", HostAdapter, HostAdapter->DMA_Channel);
1714 else
1715 BusLogic_Info("None, ", HostAdapter);
1716 if (HostAdapter->BIOS_Address > 0)
1717 BusLogic_Info("BIOS Address: 0x%X, ", HostAdapter, HostAdapter->BIOS_Address);
1718 else
1719 BusLogic_Info("BIOS Address: None, ", HostAdapter);
1720 } else {
1721 BusLogic_Info(" PCI Bus: %d, Device: %d, Address: ", HostAdapter, HostAdapter->Bus, HostAdapter->Device);
1722 if (HostAdapter->PCI_Address > 0)
1723 BusLogic_Info("0x%X, ", HostAdapter, HostAdapter->PCI_Address);
1724 else
1725 BusLogic_Info("Unassigned, ", HostAdapter);
1726 }
1727 BusLogic_Info("Host Adapter SCSI ID: %d\n", HostAdapter, HostAdapter->SCSI_ID);
1728 BusLogic_Info(" Parity Checking: %s, Extended Translation: %s\n", HostAdapter, (HostAdapter->ParityCheckingEnabled ? "Enabled" : "Disabled"), (HostAdapter->ExtendedTranslationEnabled ? "Enabled" : "Disabled"));
1729 AllTargetsMask &= ~(1 << HostAdapter->SCSI_ID);
1730 SynchronousPermitted = HostAdapter->SynchronousPermitted & AllTargetsMask;
1731 FastPermitted = HostAdapter->FastPermitted & AllTargetsMask;
1732 UltraPermitted = HostAdapter->UltraPermitted & AllTargetsMask;
1733 if ((BusLogic_MultiMasterHostAdapterP(HostAdapter) && (HostAdapter->FirmwareVersion[0] >= '4' || HostAdapter->HostAdapterBusType == BusLogic_EISA_Bus)) || BusLogic_FlashPointHostAdapterP(HostAdapter)) {
1734 CommonSynchronousNegotiation = false;
1735 if (SynchronousPermitted == 0) {
1736 SynchronousMessage = "Disabled";
1737 CommonSynchronousNegotiation = true;
1738 } else if (SynchronousPermitted == AllTargetsMask) {
1739 if (FastPermitted == 0) {
1740 SynchronousMessage = "Slow";
1741 CommonSynchronousNegotiation = true;
1742 } else if (FastPermitted == AllTargetsMask) {
1743 if (UltraPermitted == 0) {
1744 SynchronousMessage = "Fast";
1745 CommonSynchronousNegotiation = true;
1746 } else if (UltraPermitted == AllTargetsMask) {
1747 SynchronousMessage = "Ultra";
1748 CommonSynchronousNegotiation = true;
1749 }
1750 }
1751 }
1752 if (!CommonSynchronousNegotiation) {
1753 for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++)
1754 SynchronousString[TargetID] = ((!(SynchronousPermitted & (1 << TargetID))) ? 'N' : (!(FastPermitted & (1 << TargetID)) ? 'S' : (!(UltraPermitted & (1 << TargetID)) ? 'F' : 'U')));
1755 SynchronousString[HostAdapter->SCSI_ID] = '#';
1756 SynchronousString[HostAdapter->MaxTargetDevices] = '\0';
1757 }
1758 } else
1759 SynchronousMessage = (SynchronousPermitted == 0 ? "Disabled" : "Enabled");
1760 WidePermitted = HostAdapter->WidePermitted & AllTargetsMask;
1761 if (WidePermitted == 0)
1762 WideMessage = "Disabled";
1763 else if (WidePermitted == AllTargetsMask)
1764 WideMessage = "Enabled";
1765 else {
1766 for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++)
1767 WideString[TargetID] = ((WidePermitted & (1 << TargetID)) ? 'Y' : 'N');
1768 WideString[HostAdapter->SCSI_ID] = '#';
1769 WideString[HostAdapter->MaxTargetDevices] = '\0';
1770 }
1771 DisconnectPermitted = HostAdapter->DisconnectPermitted & AllTargetsMask;
1772 if (DisconnectPermitted == 0)
1773 DisconnectMessage = "Disabled";
1774 else if (DisconnectPermitted == AllTargetsMask)
1775 DisconnectMessage = "Enabled";
1776 else {
1777 for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++)
1778 DisconnectString[TargetID] = ((DisconnectPermitted & (1 << TargetID)) ? 'Y' : 'N');
1779 DisconnectString[HostAdapter->SCSI_ID] = '#';
1780 DisconnectString[HostAdapter->MaxTargetDevices] = '\0';
1781 }
1782 TaggedQueuingPermitted = HostAdapter->TaggedQueuingPermitted & AllTargetsMask;
1783 if (TaggedQueuingPermitted == 0)
1784 TaggedQueuingMessage = "Disabled";
1785 else if (TaggedQueuingPermitted == AllTargetsMask)
1786 TaggedQueuingMessage = "Enabled";
1787 else {
1788 for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++)
1789 TaggedQueuingString[TargetID] = ((TaggedQueuingPermitted & (1 << TargetID)) ? 'Y' : 'N');
1790 TaggedQueuingString[HostAdapter->SCSI_ID] = '#';
1791 TaggedQueuingString[HostAdapter->MaxTargetDevices] = '\0';
1792 }
1793 BusLogic_Info(" Synchronous Negotiation: %s, Wide Negotiation: %s\n", HostAdapter, SynchronousMessage, WideMessage);
1794 BusLogic_Info(" Disconnect/Reconnect: %s, Tagged Queuing: %s\n", HostAdapter, DisconnectMessage, TaggedQueuingMessage);
1795 if (BusLogic_MultiMasterHostAdapterP(HostAdapter)) {
1796 BusLogic_Info(" Scatter/Gather Limit: %d of %d segments, " "Mailboxes: %d\n", HostAdapter, HostAdapter->DriverScatterGatherLimit, HostAdapter->HostAdapterScatterGatherLimit, HostAdapter->MailboxCount);
1797 BusLogic_Info(" Driver Queue Depth: %d, " "Host Adapter Queue Depth: %d\n", HostAdapter, HostAdapter->DriverQueueDepth, HostAdapter->HostAdapterQueueDepth);
1798 } else
1799 BusLogic_Info(" Driver Queue Depth: %d, " "Scatter/Gather Limit: %d segments\n", HostAdapter, HostAdapter->DriverQueueDepth, HostAdapter->DriverScatterGatherLimit);
1800 BusLogic_Info(" Tagged Queue Depth: ", HostAdapter);
1801 CommonTaggedQueueDepth = true;
1802 for (TargetID = 1; TargetID < HostAdapter->MaxTargetDevices; TargetID++)
1803 if (HostAdapter->QueueDepth[TargetID] != HostAdapter->QueueDepth[0]) {
1804 CommonTaggedQueueDepth = false;
1805 break;
1806 }
1807 if (CommonTaggedQueueDepth) {
1808 if (HostAdapter->QueueDepth[0] > 0)
1809 BusLogic_Info("%d", HostAdapter, HostAdapter->QueueDepth[0]);
1810 else
1811 BusLogic_Info("Automatic", HostAdapter);
1812 } else
1813 BusLogic_Info("Individual", HostAdapter);
1814 BusLogic_Info(", Untagged Queue Depth: %d\n", HostAdapter, HostAdapter->UntaggedQueueDepth);
1815 if (HostAdapter->TerminationInfoValid) {
1816 if (HostAdapter->HostWideSCSI)
1817 BusLogic_Info(" SCSI Bus Termination: %s", HostAdapter, (HostAdapter->LowByteTerminated ? (HostAdapter->HighByteTerminated ? "Both Enabled" : "Low Enabled")
1818 : (HostAdapter->HighByteTerminated ? "High Enabled" : "Both Disabled")));
1819 else
1820 BusLogic_Info(" SCSI Bus Termination: %s", HostAdapter, (HostAdapter->LowByteTerminated ? "Enabled" : "Disabled"));
1821 if (HostAdapter->HostSupportsSCAM)
1822 BusLogic_Info(", SCAM: %s", HostAdapter, (HostAdapter->SCAM_Enabled ? (HostAdapter->SCAM_Level2 ? "Enabled, Level 2" : "Enabled, Level 1")
1823 : "Disabled"));
1824 BusLogic_Info("\n", HostAdapter);
1825 }
1826 /*
1827 Indicate reporting the Host Adapter configuration completed successfully.
1828 */
1829 return true;
1830}
1831
1832
1833/*
1834 BusLogic_AcquireResources acquires the system resources necessary to use
1835 Host Adapter.
1836*/
1837
1838static boolean __init BusLogic_AcquireResources(struct BusLogic_HostAdapter *HostAdapter)
1839{
1840 if (HostAdapter->IRQ_Channel == 0) {
1841 BusLogic_Error("NO LEGAL INTERRUPT CHANNEL ASSIGNED - DETACHING\n", HostAdapter);
1842 return false;
1843 }
1844 /*
1845 Acquire shared access to the IRQ Channel.
1846 */
1d6f359a 1847 if (request_irq(HostAdapter->IRQ_Channel, BusLogic_InterruptHandler, IRQF_SHARED, HostAdapter->FullModelName, HostAdapter) < 0) {
1da177e4
LT
1848 BusLogic_Error("UNABLE TO ACQUIRE IRQ CHANNEL %d - DETACHING\n", HostAdapter, HostAdapter->IRQ_Channel);
1849 return false;
1850 }
1851 HostAdapter->IRQ_ChannelAcquired = true;
1852 /*
1853 Acquire exclusive access to the DMA Channel.
1854 */
1855 if (HostAdapter->DMA_Channel > 0) {
1856 if (request_dma(HostAdapter->DMA_Channel, HostAdapter->FullModelName) < 0) {
1857 BusLogic_Error("UNABLE TO ACQUIRE DMA CHANNEL %d - DETACHING\n", HostAdapter, HostAdapter->DMA_Channel);
1858 return false;
1859 }
1860 set_dma_mode(HostAdapter->DMA_Channel, DMA_MODE_CASCADE);
1861 enable_dma(HostAdapter->DMA_Channel);
1862 HostAdapter->DMA_ChannelAcquired = true;
1863 }
1864 /*
1865 Indicate the System Resource Acquisition completed successfully,
1866 */
1867 return true;
1868}
1869
1870
1871/*
1872 BusLogic_ReleaseResources releases any system resources previously acquired
1873 by BusLogic_AcquireResources.
1874*/
1875
1876static void BusLogic_ReleaseResources(struct BusLogic_HostAdapter *HostAdapter)
1877{
1878 /*
1879 Release shared access to the IRQ Channel.
1880 */
1881 if (HostAdapter->IRQ_ChannelAcquired)
1882 free_irq(HostAdapter->IRQ_Channel, HostAdapter);
1883 /*
1884 Release exclusive access to the DMA Channel.
1885 */
1886 if (HostAdapter->DMA_ChannelAcquired)
1887 free_dma(HostAdapter->DMA_Channel);
1888 /*
1889 Release any allocated memory structs not released elsewhere
1890 */
1891 if (HostAdapter->MailboxSpace)
1892 pci_free_consistent(HostAdapter->PCI_Device, HostAdapter->MailboxSize, HostAdapter->MailboxSpace, HostAdapter->MailboxSpaceHandle);
1893 HostAdapter->MailboxSpace = NULL;
1894 HostAdapter->MailboxSpaceHandle = 0;
1895 HostAdapter->MailboxSize = 0;
1896}
1897
1898
1899/*
1900 BusLogic_InitializeHostAdapter initializes Host Adapter. This is the only
1901 function called during SCSI Host Adapter detection which modifies the state
1902 of the Host Adapter from its initial power on or hard reset state.
1903*/
1904
1905static boolean BusLogic_InitializeHostAdapter(struct BusLogic_HostAdapter
1906 *HostAdapter)
1907{
1908 struct BusLogic_ExtendedMailboxRequest ExtendedMailboxRequest;
1909 enum BusLogic_RoundRobinModeRequest RoundRobinModeRequest;
1910 enum BusLogic_SetCCBFormatRequest SetCCBFormatRequest;
1911 int TargetID;
1912 /*
1913 Initialize the pointers to the first and last CCBs that are queued for
1914 completion processing.
1915 */
1916 HostAdapter->FirstCompletedCCB = NULL;
1917 HostAdapter->LastCompletedCCB = NULL;
1918 /*
1919 Initialize the Bus Device Reset Pending CCB, Tagged Queuing Active,
1920 Command Successful Flag, Active Commands, and Commands Since Reset
1921 for each Target Device.
1922 */
1923 for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++) {
1924 HostAdapter->BusDeviceResetPendingCCB[TargetID] = NULL;
1925 HostAdapter->TargetFlags[TargetID].TaggedQueuingActive = false;
1926 HostAdapter->TargetFlags[TargetID].CommandSuccessfulFlag = false;
1927 HostAdapter->ActiveCommands[TargetID] = 0;
1928 HostAdapter->CommandsSinceReset[TargetID] = 0;
1929 }
1930 /*
1931 FlashPoint Host Adapters do not use Outgoing and Incoming Mailboxes.
1932 */
1933 if (BusLogic_FlashPointHostAdapterP(HostAdapter))
1934 goto Done;
1935 /*
1936 Initialize the Outgoing and Incoming Mailbox pointers.
1937 */
1938 HostAdapter->MailboxSize = HostAdapter->MailboxCount * (sizeof(struct BusLogic_OutgoingMailbox) + sizeof(struct BusLogic_IncomingMailbox));
1939 HostAdapter->MailboxSpace = pci_alloc_consistent(HostAdapter->PCI_Device, HostAdapter->MailboxSize, &HostAdapter->MailboxSpaceHandle);
1940 if (HostAdapter->MailboxSpace == NULL)
1941 return BusLogic_Failure(HostAdapter, "MAILBOX ALLOCATION");
1942 HostAdapter->FirstOutgoingMailbox = (struct BusLogic_OutgoingMailbox *) HostAdapter->MailboxSpace;
1943 HostAdapter->LastOutgoingMailbox = HostAdapter->FirstOutgoingMailbox + HostAdapter->MailboxCount - 1;
1944 HostAdapter->NextOutgoingMailbox = HostAdapter->FirstOutgoingMailbox;
1945 HostAdapter->FirstIncomingMailbox = (struct BusLogic_IncomingMailbox *) (HostAdapter->LastOutgoingMailbox + 1);
1946 HostAdapter->LastIncomingMailbox = HostAdapter->FirstIncomingMailbox + HostAdapter->MailboxCount - 1;
1947 HostAdapter->NextIncomingMailbox = HostAdapter->FirstIncomingMailbox;
1948
1949 /*
1950 Initialize the Outgoing and Incoming Mailbox structures.
1951 */
1952 memset(HostAdapter->FirstOutgoingMailbox, 0, HostAdapter->MailboxCount * sizeof(struct BusLogic_OutgoingMailbox));
1953 memset(HostAdapter->FirstIncomingMailbox, 0, HostAdapter->MailboxCount * sizeof(struct BusLogic_IncomingMailbox));
1954 /*
1955 Initialize the Host Adapter's Pointer to the Outgoing/Incoming Mailboxes.
1956 */
1957 ExtendedMailboxRequest.MailboxCount = HostAdapter->MailboxCount;
1958 ExtendedMailboxRequest.BaseMailboxAddress = (u32) HostAdapter->MailboxSpaceHandle;
1959 if (BusLogic_Command(HostAdapter, BusLogic_InitializeExtendedMailbox, &ExtendedMailboxRequest, sizeof(ExtendedMailboxRequest), NULL, 0) < 0)
1960 return BusLogic_Failure(HostAdapter, "MAILBOX INITIALIZATION");
1961 /*
1962 Enable Strict Round Robin Mode if supported by the Host Adapter. In
1963 Strict Round Robin Mode, the Host Adapter only looks at the next Outgoing
1964 Mailbox for each new command, rather than scanning through all the
1965 Outgoing Mailboxes to find any that have new commands in them. Strict
1966 Round Robin Mode is significantly more efficient.
1967 */
1968 if (HostAdapter->StrictRoundRobinModeSupport) {
1969 RoundRobinModeRequest = BusLogic_StrictRoundRobinMode;
1970 if (BusLogic_Command(HostAdapter, BusLogic_EnableStrictRoundRobinMode, &RoundRobinModeRequest, sizeof(RoundRobinModeRequest), NULL, 0) < 0)
1971 return BusLogic_Failure(HostAdapter, "ENABLE STRICT ROUND ROBIN MODE");
1972 }
1973 /*
1974 For Host Adapters that support Extended LUN Format CCBs, issue the Set CCB
1975 Format command to allow 32 Logical Units per Target Device.
1976 */
1977 if (HostAdapter->ExtendedLUNSupport) {
1978 SetCCBFormatRequest = BusLogic_ExtendedLUNFormatCCB;
1979 if (BusLogic_Command(HostAdapter, BusLogic_SetCCBFormat, &SetCCBFormatRequest, sizeof(SetCCBFormatRequest), NULL, 0) < 0)
1980 return BusLogic_Failure(HostAdapter, "SET CCB FORMAT");
1981 }
1982 /*
1983 Announce Successful Initialization.
1984 */
1985 Done:
1986 if (!HostAdapter->HostAdapterInitialized) {
1987 BusLogic_Info("*** %s Initialized Successfully ***\n", HostAdapter, HostAdapter->FullModelName);
1988 BusLogic_Info("\n", HostAdapter);
1989 } else
1990 BusLogic_Warning("*** %s Initialized Successfully ***\n", HostAdapter, HostAdapter->FullModelName);
1991 HostAdapter->HostAdapterInitialized = true;
1992 /*
1993 Indicate the Host Adapter Initialization completed successfully.
1994 */
1995 return true;
1996}
1997
1998
1999/*
2000 BusLogic_TargetDeviceInquiry inquires about the Target Devices accessible
2001 through Host Adapter.
2002*/
2003
2004static boolean __init BusLogic_TargetDeviceInquiry(struct BusLogic_HostAdapter
2005 *HostAdapter)
2006{
2007 u16 InstalledDevices;
2008 u8 InstalledDevicesID0to7[8];
2009 struct BusLogic_SetupInformation SetupInformation;
2010 u8 SynchronousPeriod[BusLogic_MaxTargetDevices];
2011 unsigned char RequestedReplyLength;
2012 int TargetID;
2013 /*
2014 Wait a few seconds between the Host Adapter Hard Reset which initiates
2015 a SCSI Bus Reset and issuing any SCSI Commands. Some SCSI devices get
2016 confused if they receive SCSI Commands too soon after a SCSI Bus Reset.
2017 */
2018 BusLogic_Delay(HostAdapter->BusSettleTime);
2019 /*
2020 FlashPoint Host Adapters do not provide for Target Device Inquiry.
2021 */
2022 if (BusLogic_FlashPointHostAdapterP(HostAdapter))
2023 return true;
2024 /*
2025 Inhibit the Target Device Inquiry if requested.
2026 */
2027 if (HostAdapter->DriverOptions != NULL && HostAdapter->DriverOptions->LocalOptions.InhibitTargetInquiry)
2028 return true;
2029 /*
2030 Issue the Inquire Target Devices command for host adapters with firmware
2031 version 4.25 or later, or the Inquire Installed Devices ID 0 to 7 command
2032 for older host adapters. This is necessary to force Synchronous Transfer
2033 Negotiation so that the Inquire Setup Information and Inquire Synchronous
2034 Period commands will return valid data. The Inquire Target Devices command
2035 is preferable to Inquire Installed Devices ID 0 to 7 since it only probes
2036 Logical Unit 0 of each Target Device.
2037 */
2038 if (strcmp(HostAdapter->FirmwareVersion, "4.25") >= 0) {
2039
2040 /*
2041 * Issue a Inquire Target Devices command. Inquire Target Devices only
2042 * tests Logical Unit 0 of each Target Device unlike the Inquire Installed
2043 * Devices commands which test Logical Units 0 - 7. Two bytes are
2044 * returned, where byte 0 bit 0 set indicates that Target Device 0 exists,
2045 * and so on.
2046 */
2047
2048 if (BusLogic_Command(HostAdapter, BusLogic_InquireTargetDevices, NULL, 0, &InstalledDevices, sizeof(InstalledDevices))
2049 != sizeof(InstalledDevices))
2050 return BusLogic_Failure(HostAdapter, "INQUIRE TARGET DEVICES");
2051 for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++)
2052 HostAdapter->TargetFlags[TargetID].TargetExists = (InstalledDevices & (1 << TargetID) ? true : false);
2053 } else {
2054
2055 /*
2056 * Issue an Inquire Installed Devices command. For each Target Device,
2057 * a byte is returned where bit 0 set indicates that Logical Unit 0
2058 * exists, bit 1 set indicates that Logical Unit 1 exists, and so on.
2059 */
2060
2061 if (BusLogic_Command(HostAdapter, BusLogic_InquireInstalledDevicesID0to7, NULL, 0, &InstalledDevicesID0to7, sizeof(InstalledDevicesID0to7))
2062 != sizeof(InstalledDevicesID0to7))
2063 return BusLogic_Failure(HostAdapter, "INQUIRE INSTALLED DEVICES ID 0 TO 7");
2064 for (TargetID = 0; TargetID < 8; TargetID++)
2065 HostAdapter->TargetFlags[TargetID].TargetExists = (InstalledDevicesID0to7[TargetID] != 0 ? true : false);
2066 }
2067 /*
2068 Issue the Inquire Setup Information command.
2069 */
2070 RequestedReplyLength = sizeof(SetupInformation);
2071 if (BusLogic_Command(HostAdapter, BusLogic_InquireSetupInformation, &RequestedReplyLength, sizeof(RequestedReplyLength), &SetupInformation, sizeof(SetupInformation))
2072 != sizeof(SetupInformation))
2073 return BusLogic_Failure(HostAdapter, "INQUIRE SETUP INFORMATION");
2074 for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++)
2075 HostAdapter->SynchronousOffset[TargetID] = (TargetID < 8 ? SetupInformation.SynchronousValuesID0to7[TargetID].Offset : SetupInformation.SynchronousValuesID8to15[TargetID - 8].Offset);
2076 if (strcmp(HostAdapter->FirmwareVersion, "5.06L") >= 0)
2077 for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++)
2078 HostAdapter->TargetFlags[TargetID].WideTransfersActive = (TargetID < 8 ? (SetupInformation.WideTransfersActiveID0to7 & (1 << TargetID)
2079 ? true : false)
2080 : (SetupInformation.WideTransfersActiveID8to15 & (1 << (TargetID - 8))
2081 ? true : false));
2082 /*
2083 Issue the Inquire Synchronous Period command.
2084 */
2085 if (HostAdapter->FirmwareVersion[0] >= '3') {
2086
2087 /* Issue a Inquire Synchronous Period command. For each Target Device,
2088 * a byte is returned which represents the Synchronous Transfer Period
2089 * in units of 10 nanoseconds.
2090 */
2091
2092 RequestedReplyLength = sizeof(SynchronousPeriod);
2093 if (BusLogic_Command(HostAdapter, BusLogic_InquireSynchronousPeriod, &RequestedReplyLength, sizeof(RequestedReplyLength), &SynchronousPeriod, sizeof(SynchronousPeriod))
2094 != sizeof(SynchronousPeriod))
2095 return BusLogic_Failure(HostAdapter, "INQUIRE SYNCHRONOUS PERIOD");
2096 for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++)
2097 HostAdapter->SynchronousPeriod[TargetID] = SynchronousPeriod[TargetID];
2098 } else
2099 for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++)
2100 if (SetupInformation.SynchronousValuesID0to7[TargetID].Offset > 0)
2101 HostAdapter->SynchronousPeriod[TargetID] = 20 + 5 * SetupInformation.SynchronousValuesID0to7[TargetID]
2102 .TransferPeriod;
2103 /*
2104 Indicate the Target Device Inquiry completed successfully.
2105 */
2106 return true;
2107}
2108
2109/*
2110 BusLogic_InitializeHostStructure initializes the fields in the SCSI Host
2111 structure. The base, io_port, n_io_ports, irq, and dma_channel fields in the
2112 SCSI Host structure are intentionally left uninitialized, as this driver
2113 handles acquisition and release of these resources explicitly, as well as
2114 ensuring exclusive access to the Host Adapter hardware and data structures
2115 through explicit acquisition and release of the Host Adapter's Lock.
2116*/
2117
2118static void __init BusLogic_InitializeHostStructure(struct BusLogic_HostAdapter
2119 *HostAdapter, struct Scsi_Host *Host)
2120{
2121 Host->max_id = HostAdapter->MaxTargetDevices;
2122 Host->max_lun = HostAdapter->MaxLogicalUnits;
2123 Host->max_channel = 0;
2124 Host->unique_id = HostAdapter->IO_Address;
2125 Host->this_id = HostAdapter->SCSI_ID;
2126 Host->can_queue = HostAdapter->DriverQueueDepth;
2127 Host->sg_tablesize = HostAdapter->DriverScatterGatherLimit;
2128 Host->unchecked_isa_dma = HostAdapter->BounceBuffersRequired;
2129 Host->cmd_per_lun = HostAdapter->UntaggedQueueDepth;
2130}
2131
2132/*
2133 BusLogic_SlaveConfigure will actually set the queue depth on individual
2134 scsi devices as they are permanently added to the device chain. We
2135 shamelessly rip off the SelectQueueDepths code to make this work mostly
2136 like it used to. Since we don't get called once at the end of the scan
2137 but instead get called for each device, we have to do things a bit
2138 differently.
2139*/
2140static int BusLogic_SlaveConfigure(struct scsi_device *Device)
2141{
2142 struct BusLogic_HostAdapter *HostAdapter = (struct BusLogic_HostAdapter *) Device->host->hostdata;
2143 int TargetID = Device->id;
2144 int QueueDepth = HostAdapter->QueueDepth[TargetID];
2145
2146 if (HostAdapter->TargetFlags[TargetID].TaggedQueuingSupported && (HostAdapter->TaggedQueuingPermitted & (1 << TargetID))) {
2147 if (QueueDepth == 0)
2148 QueueDepth = BusLogic_MaxAutomaticTaggedQueueDepth;
2149 HostAdapter->QueueDepth[TargetID] = QueueDepth;
2150 scsi_adjust_queue_depth(Device, MSG_SIMPLE_TAG, QueueDepth);
2151 } else {
2152 HostAdapter->TaggedQueuingPermitted &= ~(1 << TargetID);
2153 QueueDepth = HostAdapter->UntaggedQueueDepth;
2154 HostAdapter->QueueDepth[TargetID] = QueueDepth;
2155 scsi_adjust_queue_depth(Device, 0, QueueDepth);
2156 }
2157 QueueDepth = 0;
2158 for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++)
2159 if (HostAdapter->TargetFlags[TargetID].TargetExists) {
2160 QueueDepth += HostAdapter->QueueDepth[TargetID];
2161 }
2162 if (QueueDepth > HostAdapter->AllocatedCCBs)
2163 BusLogic_CreateAdditionalCCBs(HostAdapter, QueueDepth - HostAdapter->AllocatedCCBs, false);
2164 return 0;
2165}
2166
2167/*
2168 BusLogic_DetectHostAdapter probes for BusLogic Host Adapters at the standard
2169 I/O Addresses where they may be located, initializing, registering, and
2170 reporting the configuration of each BusLogic Host Adapter it finds. It
2171 returns the number of BusLogic Host Adapters successfully initialized and
2172 registered.
2173*/
2174
2175static int __init BusLogic_init(void)
2176{
2177 int BusLogicHostAdapterCount = 0, DriverOptionsIndex = 0, ProbeIndex;
2178 struct BusLogic_HostAdapter *PrototypeHostAdapter;
d2afb3ae 2179 int ret = 0;
1da177e4
LT
2180
2181#ifdef MODULE
2182 if (BusLogic)
2183 BusLogic_Setup(BusLogic);
2184#endif
2185
2186 if (BusLogic_ProbeOptions.NoProbe)
2187 return -ENODEV;
2188 BusLogic_ProbeInfoList = (struct BusLogic_ProbeInfo *)
2189 kmalloc(BusLogic_MaxHostAdapters * sizeof(struct BusLogic_ProbeInfo), GFP_ATOMIC);
2190 if (BusLogic_ProbeInfoList == NULL) {
2191 BusLogic_Error("BusLogic: Unable to allocate Probe Info List\n", NULL);
2192 return -ENOMEM;
2193 }
2194 memset(BusLogic_ProbeInfoList, 0, BusLogic_MaxHostAdapters * sizeof(struct BusLogic_ProbeInfo));
2195 PrototypeHostAdapter = (struct BusLogic_HostAdapter *)
2196 kmalloc(sizeof(struct BusLogic_HostAdapter), GFP_ATOMIC);
2197 if (PrototypeHostAdapter == NULL) {
2198 kfree(BusLogic_ProbeInfoList);
2199 BusLogic_Error("BusLogic: Unable to allocate Prototype " "Host Adapter\n", NULL);
2200 return -ENOMEM;
2201 }
2202 memset(PrototypeHostAdapter, 0, sizeof(struct BusLogic_HostAdapter));
2203#ifdef MODULE
2204 if (BusLogic != NULL)
2205 BusLogic_Setup(BusLogic);
2206#endif
2207 BusLogic_InitializeProbeInfoList(PrototypeHostAdapter);
2208 for (ProbeIndex = 0; ProbeIndex < BusLogic_ProbeInfoCount; ProbeIndex++) {
2209 struct BusLogic_ProbeInfo *ProbeInfo = &BusLogic_ProbeInfoList[ProbeIndex];
2210 struct BusLogic_HostAdapter *HostAdapter = PrototypeHostAdapter;
2211 struct Scsi_Host *Host;
2212 if (ProbeInfo->IO_Address == 0)
2213 continue;
2214 memset(HostAdapter, 0, sizeof(struct BusLogic_HostAdapter));
2215 HostAdapter->HostAdapterType = ProbeInfo->HostAdapterType;
2216 HostAdapter->HostAdapterBusType = ProbeInfo->HostAdapterBusType;
2217 HostAdapter->IO_Address = ProbeInfo->IO_Address;
2218 HostAdapter->PCI_Address = ProbeInfo->PCI_Address;
2219 HostAdapter->Bus = ProbeInfo->Bus;
2220 HostAdapter->Device = ProbeInfo->Device;
745caf71 2221 HostAdapter->PCI_Device = ProbeInfo->PCI_Device;
1da177e4
LT
2222 HostAdapter->IRQ_Channel = ProbeInfo->IRQ_Channel;
2223 HostAdapter->AddressCount = BusLogic_HostAdapterAddressCount[HostAdapter->HostAdapterType];
2224 /*
2225 Probe the Host Adapter. If unsuccessful, abort further initialization.
2226 */
2227 if (!BusLogic_ProbeHostAdapter(HostAdapter))
2228 continue;
2229 /*
2230 Hard Reset the Host Adapter. If unsuccessful, abort further
2231 initialization.
2232 */
2233 if (!BusLogic_HardwareResetHostAdapter(HostAdapter, true))
2234 continue;
2235 /*
2236 Check the Host Adapter. If unsuccessful, abort further initialization.
2237 */
2238 if (!BusLogic_CheckHostAdapter(HostAdapter))
2239 continue;
2240 /*
2241 Initialize the Driver Options field if provided.
2242 */
2243 if (DriverOptionsIndex < BusLogic_DriverOptionsCount)
2244 HostAdapter->DriverOptions = &BusLogic_DriverOptions[DriverOptionsIndex++];
2245 /*
2246 Announce the Driver Version and Date, Author's Name, Copyright Notice,
2247 and Electronic Mail Address.
2248 */
2249 BusLogic_AnnounceDriver(HostAdapter);
2250 /*
2251 Register usage of the I/O Address range. From this point onward, any
2252 failure will be assumed to be due to a problem with the Host Adapter,
2253 rather than due to having mistakenly identified this port as belonging
2254 to a BusLogic Host Adapter. The I/O Address range will not be
2255 released, thereby preventing it from being incorrectly identified as
2256 any other type of Host Adapter.
2257 */
2258 if (!request_region(HostAdapter->IO_Address, HostAdapter->AddressCount, "BusLogic"))
2259 continue;
2260 /*
2261 Register the SCSI Host structure.
2262 */
2263
2264 Host = scsi_host_alloc(&Bus_Logic_template, sizeof(struct BusLogic_HostAdapter));
2265 if (Host == NULL) {
2266 release_region(HostAdapter->IO_Address, HostAdapter->AddressCount);
2267 continue;
2268 }
2269 HostAdapter = (struct BusLogic_HostAdapter *) Host->hostdata;
2270 memcpy(HostAdapter, PrototypeHostAdapter, sizeof(struct BusLogic_HostAdapter));
2271 HostAdapter->SCSI_Host = Host;
2272 HostAdapter->HostNumber = Host->host_no;
2273 /*
2274 Add Host Adapter to the end of the list of registered BusLogic
2275 Host Adapters.
2276 */
2277 list_add_tail(&HostAdapter->host_list, &BusLogic_host_list);
2278
2279 /*
2280 Read the Host Adapter Configuration, Configure the Host Adapter,
2281 Acquire the System Resources necessary to use the Host Adapter, then
2282 Create the Initial CCBs, Initialize the Host Adapter, and finally
2283 perform Target Device Inquiry.
2284 */
2285 if (BusLogic_ReadHostAdapterConfiguration(HostAdapter) &&
d2afb3ae
DW
2286 BusLogic_ReportHostAdapterConfiguration(HostAdapter) &&
2287 BusLogic_AcquireResources(HostAdapter) &&
2288 BusLogic_CreateInitialCCBs(HostAdapter) &&
2289 BusLogic_InitializeHostAdapter(HostAdapter) &&
2290 BusLogic_TargetDeviceInquiry(HostAdapter)) {
1da177e4
LT
2291 /*
2292 Initialization has been completed successfully. Release and
2293 re-register usage of the I/O Address range so that the Model
2294 Name of the Host Adapter will appear, and initialize the SCSI
2295 Host structure.
2296 */
d2afb3ae
DW
2297 release_region(HostAdapter->IO_Address,
2298 HostAdapter->AddressCount);
2299 if (!request_region(HostAdapter->IO_Address,
2300 HostAdapter->AddressCount,
2301 HostAdapter->FullModelName)) {
2302 printk(KERN_WARNING
2303 "BusLogic: Release and re-register of "
2304 "port 0x%04lx failed \n",
2305 (unsigned long)HostAdapter->IO_Address);
1da177e4
LT
2306 BusLogic_DestroyCCBs(HostAdapter);
2307 BusLogic_ReleaseResources(HostAdapter);
2308 list_del(&HostAdapter->host_list);
2309 scsi_host_put(Host);
d2afb3ae 2310 ret = -ENOMEM;
1da177e4 2311 } else {
d2afb3ae
DW
2312 BusLogic_InitializeHostStructure(HostAdapter,
2313 Host);
2314 if (scsi_add_host(Host, HostAdapter->PCI_Device
2315 ? &HostAdapter->PCI_Device->dev
2316 : NULL)) {
2317 printk(KERN_WARNING
2318 "BusLogic: scsi_add_host()"
2319 "failed!\n");
2320 BusLogic_DestroyCCBs(HostAdapter);
2321 BusLogic_ReleaseResources(HostAdapter);
2322 list_del(&HostAdapter->host_list);
2323 scsi_host_put(Host);
2324 ret = -ENODEV;
2325 } else {
2326 scsi_scan_host(Host);
2327 BusLogicHostAdapterCount++;
2328 }
1da177e4
LT
2329 }
2330 } else {
2331 /*
2332 An error occurred during Host Adapter Configuration Querying, Host
2333 Adapter Configuration, Resource Acquisition, CCB Creation, Host
2334 Adapter Initialization, or Target Device Inquiry, so remove Host
2335 Adapter from the list of registered BusLogic Host Adapters, destroy
2336 the CCBs, Release the System Resources, and Unregister the SCSI
2337 Host.
2338 */
2339 BusLogic_DestroyCCBs(HostAdapter);
2340 BusLogic_ReleaseResources(HostAdapter);
2341 list_del(&HostAdapter->host_list);
2342 scsi_host_put(Host);
d2afb3ae 2343 ret = -ENODEV;
1da177e4
LT
2344 }
2345 }
2346 kfree(PrototypeHostAdapter);
2347 kfree(BusLogic_ProbeInfoList);
2348 BusLogic_ProbeInfoList = NULL;
d2afb3ae 2349 return ret;
1da177e4
LT
2350}
2351
2352
2353/*
2354 BusLogic_ReleaseHostAdapter releases all resources previously acquired to
2355 support a specific Host Adapter, including the I/O Address range, and
2356 unregisters the BusLogic Host Adapter.
2357*/
2358
2359static int __exit BusLogic_ReleaseHostAdapter(struct BusLogic_HostAdapter *HostAdapter)
2360{
2361 struct Scsi_Host *Host = HostAdapter->SCSI_Host;
2362
2363 scsi_remove_host(Host);
2364
2365 /*
2366 FlashPoint Host Adapters must first be released by the FlashPoint
2367 SCCB Manager.
2368 */
2369 if (BusLogic_FlashPointHostAdapterP(HostAdapter))
2370 FlashPoint_ReleaseHostAdapter(HostAdapter->CardHandle);
2371 /*
2372 Destroy the CCBs and release any system resources acquired to
2373 support Host Adapter.
2374 */
2375 BusLogic_DestroyCCBs(HostAdapter);
2376 BusLogic_ReleaseResources(HostAdapter);
2377 /*
2378 Release usage of the I/O Address range.
2379 */
2380 release_region(HostAdapter->IO_Address, HostAdapter->AddressCount);
2381 /*
2382 Remove Host Adapter from the list of registered BusLogic Host Adapters.
2383 */
2384 list_del(&HostAdapter->host_list);
2385
2386 scsi_host_put(Host);
2387 return 0;
2388}
2389
2390
2391/*
2392 BusLogic_QueueCompletedCCB queues CCB for completion processing.
2393*/
2394
2395static void BusLogic_QueueCompletedCCB(struct BusLogic_CCB *CCB)
2396{
2397 struct BusLogic_HostAdapter *HostAdapter = CCB->HostAdapter;
2398 CCB->Status = BusLogic_CCB_Completed;
2399 CCB->Next = NULL;
2400 if (HostAdapter->FirstCompletedCCB == NULL) {
2401 HostAdapter->FirstCompletedCCB = CCB;
2402 HostAdapter->LastCompletedCCB = CCB;
2403 } else {
2404 HostAdapter->LastCompletedCCB->Next = CCB;
2405 HostAdapter->LastCompletedCCB = CCB;
2406 }
2407 HostAdapter->ActiveCommands[CCB->TargetID]--;
2408}
2409
2410
2411/*
2412 BusLogic_ComputeResultCode computes a SCSI Subsystem Result Code from
2413 the Host Adapter Status and Target Device Status.
2414*/
2415
2416static int BusLogic_ComputeResultCode(struct BusLogic_HostAdapter *HostAdapter, enum BusLogic_HostAdapterStatus HostAdapterStatus, enum BusLogic_TargetDeviceStatus TargetDeviceStatus)
2417{
2418 int HostStatus;
2419 switch (HostAdapterStatus) {
2420 case BusLogic_CommandCompletedNormally:
2421 case BusLogic_LinkedCommandCompleted:
2422 case BusLogic_LinkedCommandCompletedWithFlag:
2423 HostStatus = DID_OK;
2424 break;
2425 case BusLogic_SCSISelectionTimeout:
2426 HostStatus = DID_TIME_OUT;
2427 break;
2428 case BusLogic_InvalidOutgoingMailboxActionCode:
2429 case BusLogic_InvalidCommandOperationCode:
2430 case BusLogic_InvalidCommandParameter:
2431 BusLogic_Warning("BusLogic Driver Protocol Error 0x%02X\n", HostAdapter, HostAdapterStatus);
2432 case BusLogic_DataUnderRun:
2433 case BusLogic_DataOverRun:
2434 case BusLogic_UnexpectedBusFree:
2435 case BusLogic_LinkedCCBhasInvalidLUN:
2436 case BusLogic_AutoRequestSenseFailed:
2437 case BusLogic_TaggedQueuingMessageRejected:
2438 case BusLogic_UnsupportedMessageReceived:
2439 case BusLogic_HostAdapterHardwareFailed:
2440 case BusLogic_TargetDeviceReconnectedImproperly:
2441 case BusLogic_AbortQueueGenerated:
2442 case BusLogic_HostAdapterSoftwareError:
2443 case BusLogic_HostAdapterHardwareTimeoutError:
2444 case BusLogic_SCSIParityErrorDetected:
2445 HostStatus = DID_ERROR;
2446 break;
2447 case BusLogic_InvalidBusPhaseRequested:
2448 case BusLogic_TargetFailedResponseToATN:
2449 case BusLogic_HostAdapterAssertedRST:
2450 case BusLogic_OtherDeviceAssertedRST:
2451 case BusLogic_HostAdapterAssertedBusDeviceReset:
2452 HostStatus = DID_RESET;
2453 break;
2454 default:
2455 BusLogic_Warning("Unknown Host Adapter Status 0x%02X\n", HostAdapter, HostAdapterStatus);
2456 HostStatus = DID_ERROR;
2457 break;
2458 }
2459 return (HostStatus << 16) | TargetDeviceStatus;
2460}
2461
2462
2463/*
2464 BusLogic_ScanIncomingMailboxes scans the Incoming Mailboxes saving any
2465 Incoming Mailbox entries for completion processing.
2466*/
2467
2468static void BusLogic_ScanIncomingMailboxes(struct BusLogic_HostAdapter *HostAdapter)
2469{
2470 /*
2471 Scan through the Incoming Mailboxes in Strict Round Robin fashion, saving
2472 any completed CCBs for further processing. It is essential that for each
2473 CCB and SCSI Command issued, command completion processing is performed
2474 exactly once. Therefore, only Incoming Mailboxes with completion code
2475 Command Completed Without Error, Command Completed With Error, or Command
2476 Aborted At Host Request are saved for completion processing. When an
2477 Incoming Mailbox has a completion code of Aborted Command Not Found, the
2478 CCB had already completed or been aborted before the current Abort request
2479 was processed, and so completion processing has already occurred and no
2480 further action should be taken.
2481 */
2482 struct BusLogic_IncomingMailbox *NextIncomingMailbox = HostAdapter->NextIncomingMailbox;
2483 enum BusLogic_CompletionCode CompletionCode;
2484 while ((CompletionCode = NextIncomingMailbox->CompletionCode) != BusLogic_IncomingMailboxFree) {
2485 /*
2486 We are only allowed to do this because we limit our architectures we
2487 run on to machines where bus_to_virt() actually works. There *needs*
2488 to be a dma_addr_to_virt() in the new PCI DMA mapping interface to
2489 replace bus_to_virt() or else this code is going to become very
2490 innefficient.
2491 */
2492 struct BusLogic_CCB *CCB = (struct BusLogic_CCB *) Bus_to_Virtual(NextIncomingMailbox->CCB);
2493 if (CompletionCode != BusLogic_AbortedCommandNotFound) {
2494 if (CCB->Status == BusLogic_CCB_Active || CCB->Status == BusLogic_CCB_Reset) {
2495 /*
2496 Save the Completion Code for this CCB and queue the CCB
2497 for completion processing.
2498 */
2499 CCB->CompletionCode = CompletionCode;
2500 BusLogic_QueueCompletedCCB(CCB);
2501 } else {
2502 /*
2503 If a CCB ever appears in an Incoming Mailbox and is not marked
2504 as status Active or Reset, then there is most likely a bug in
2505 the Host Adapter firmware.
2506 */
2507 BusLogic_Warning("Illegal CCB #%ld status %d in " "Incoming Mailbox\n", HostAdapter, CCB->SerialNumber, CCB->Status);
2508 }
2509 }
2510 NextIncomingMailbox->CompletionCode = BusLogic_IncomingMailboxFree;
2511 if (++NextIncomingMailbox > HostAdapter->LastIncomingMailbox)
2512 NextIncomingMailbox = HostAdapter->FirstIncomingMailbox;
2513 }
2514 HostAdapter->NextIncomingMailbox = NextIncomingMailbox;
2515}
2516
2517
2518/*
2519 BusLogic_ProcessCompletedCCBs iterates over the completed CCBs for Host
2520 Adapter setting the SCSI Command Result Codes, deallocating the CCBs, and
2521 calling the SCSI Subsystem Completion Routines. The Host Adapter's Lock
2522 should already have been acquired by the caller.
2523*/
2524
2525static void BusLogic_ProcessCompletedCCBs(struct BusLogic_HostAdapter *HostAdapter)
2526{
2527 if (HostAdapter->ProcessCompletedCCBsActive)
2528 return;
2529 HostAdapter->ProcessCompletedCCBsActive = true;
2530 while (HostAdapter->FirstCompletedCCB != NULL) {
2531 struct BusLogic_CCB *CCB = HostAdapter->FirstCompletedCCB;
2532 struct scsi_cmnd *Command = CCB->Command;
2533 HostAdapter->FirstCompletedCCB = CCB->Next;
2534 if (HostAdapter->FirstCompletedCCB == NULL)
2535 HostAdapter->LastCompletedCCB = NULL;
2536 /*
2537 Process the Completed CCB.
2538 */
2539 if (CCB->Opcode == BusLogic_BusDeviceReset) {
2540 int TargetID = CCB->TargetID;
2541 BusLogic_Warning("Bus Device Reset CCB #%ld to Target " "%d Completed\n", HostAdapter, CCB->SerialNumber, TargetID);
2542 BusLogic_IncrementErrorCounter(&HostAdapter->TargetStatistics[TargetID].BusDeviceResetsCompleted);
2543 HostAdapter->TargetFlags[TargetID].TaggedQueuingActive = false;
2544 HostAdapter->CommandsSinceReset[TargetID] = 0;
2545 HostAdapter->LastResetCompleted[TargetID] = jiffies;
2546 /*
2547 Place CCB back on the Host Adapter's free list.
2548 */
2549 BusLogic_DeallocateCCB(CCB);
2550#if 0 /* this needs to be redone different for new EH */
2551 /*
2552 Bus Device Reset CCBs have the Command field non-NULL only when a
2553 Bus Device Reset was requested for a Command that did not have a
2554 currently active CCB in the Host Adapter (i.e., a Synchronous
2555 Bus Device Reset), and hence would not have its Completion Routine
2556 called otherwise.
2557 */
2558 while (Command != NULL) {
2559 struct scsi_cmnd *NextCommand = Command->reset_chain;
2560 Command->reset_chain = NULL;
2561 Command->result = DID_RESET << 16;
2562 Command->scsi_done(Command);
2563 Command = NextCommand;
2564 }
2565#endif
2566 /*
2567 Iterate over the CCBs for this Host Adapter performing completion
2568 processing for any CCBs marked as Reset for this Target.
2569 */
2570 for (CCB = HostAdapter->All_CCBs; CCB != NULL; CCB = CCB->NextAll)
2571 if (CCB->Status == BusLogic_CCB_Reset && CCB->TargetID == TargetID) {
2572 Command = CCB->Command;
2573 BusLogic_DeallocateCCB(CCB);
2574 HostAdapter->ActiveCommands[TargetID]--;
2575 Command->result = DID_RESET << 16;
2576 Command->scsi_done(Command);
2577 }
2578 HostAdapter->BusDeviceResetPendingCCB[TargetID] = NULL;
2579 } else {
2580 /*
2581 Translate the Completion Code, Host Adapter Status, and Target
2582 Device Status into a SCSI Subsystem Result Code.
2583 */
2584 switch (CCB->CompletionCode) {
2585 case BusLogic_IncomingMailboxFree:
2586 case BusLogic_AbortedCommandNotFound:
2587 case BusLogic_InvalidCCB:
2588 BusLogic_Warning("CCB #%ld to Target %d Impossible State\n", HostAdapter, CCB->SerialNumber, CCB->TargetID);
2589 break;
2590 case BusLogic_CommandCompletedWithoutError:
2591 HostAdapter->TargetStatistics[CCB->TargetID]
2592 .CommandsCompleted++;
2593 HostAdapter->TargetFlags[CCB->TargetID]
2594 .CommandSuccessfulFlag = true;
2595 Command->result = DID_OK << 16;
2596 break;
2597 case BusLogic_CommandAbortedAtHostRequest:
2598 BusLogic_Warning("CCB #%ld to Target %d Aborted\n", HostAdapter, CCB->SerialNumber, CCB->TargetID);
2599 BusLogic_IncrementErrorCounter(&HostAdapter->TargetStatistics[CCB->TargetID]
2600 .CommandAbortsCompleted);
2601 Command->result = DID_ABORT << 16;
2602 break;
2603 case BusLogic_CommandCompletedWithError:
2604 Command->result = BusLogic_ComputeResultCode(HostAdapter, CCB->HostAdapterStatus, CCB->TargetDeviceStatus);
2605 if (CCB->HostAdapterStatus != BusLogic_SCSISelectionTimeout) {
2606 HostAdapter->TargetStatistics[CCB->TargetID]
2607 .CommandsCompleted++;
2608 if (BusLogic_GlobalOptions.TraceErrors) {
2609 int i;
2610 BusLogic_Notice("CCB #%ld Target %d: Result %X Host "
2611 "Adapter Status %02X " "Target Status %02X\n", HostAdapter, CCB->SerialNumber, CCB->TargetID, Command->result, CCB->HostAdapterStatus, CCB->TargetDeviceStatus);
2612 BusLogic_Notice("CDB ", HostAdapter);
2613 for (i = 0; i < CCB->CDB_Length; i++)
2614 BusLogic_Notice(" %02X", HostAdapter, CCB->CDB[i]);
2615 BusLogic_Notice("\n", HostAdapter);
2616 BusLogic_Notice("Sense ", HostAdapter);
2617 for (i = 0; i < CCB->SenseDataLength; i++)
2618 BusLogic_Notice(" %02X", HostAdapter, Command->sense_buffer[i]);
2619 BusLogic_Notice("\n", HostAdapter);
2620 }
2621 }
2622 break;
2623 }
2624 /*
2625 When an INQUIRY command completes normally, save the
2626 CmdQue (Tagged Queuing Supported) and WBus16 (16 Bit
2627 Wide Data Transfers Supported) bits.
2628 */
2629 if (CCB->CDB[0] == INQUIRY && CCB->CDB[1] == 0 && CCB->HostAdapterStatus == BusLogic_CommandCompletedNormally) {
2630 struct BusLogic_TargetFlags *TargetFlags = &HostAdapter->TargetFlags[CCB->TargetID];
2631 struct SCSI_Inquiry *InquiryResult = (struct SCSI_Inquiry *) Command->request_buffer;
2632 TargetFlags->TargetExists = true;
2633 TargetFlags->TaggedQueuingSupported = InquiryResult->CmdQue;
2634 TargetFlags->WideTransfersSupported = InquiryResult->WBus16;
2635 }
2636 /*
2637 Place CCB back on the Host Adapter's free list.
2638 */
2639 BusLogic_DeallocateCCB(CCB);
2640 /*
2641 Call the SCSI Command Completion Routine.
2642 */
2643 Command->scsi_done(Command);
2644 }
2645 }
2646 HostAdapter->ProcessCompletedCCBsActive = false;
2647}
2648
2649
2650/*
2651 BusLogic_InterruptHandler handles hardware interrupts from BusLogic Host
2652 Adapters.
2653*/
2654
2655static irqreturn_t BusLogic_InterruptHandler(int IRQ_Channel, void *DeviceIdentifier, struct pt_regs *InterruptRegisters)
2656{
2657 struct BusLogic_HostAdapter *HostAdapter = (struct BusLogic_HostAdapter *) DeviceIdentifier;
2658 unsigned long ProcessorFlags;
2659 /*
2660 Acquire exclusive access to Host Adapter.
2661 */
2662 spin_lock_irqsave(HostAdapter->SCSI_Host->host_lock, ProcessorFlags);
2663 /*
2664 Handle Interrupts appropriately for each Host Adapter type.
2665 */
2666 if (BusLogic_MultiMasterHostAdapterP(HostAdapter)) {
2667 union BusLogic_InterruptRegister InterruptRegister;
2668 /*
2669 Read the Host Adapter Interrupt Register.
2670 */
2671 InterruptRegister.All = BusLogic_ReadInterruptRegister(HostAdapter);
2672 if (InterruptRegister.ir.InterruptValid) {
2673 /*
2674 Acknowledge the interrupt and reset the Host Adapter
2675 Interrupt Register.
2676 */
2677 BusLogic_InterruptReset(HostAdapter);
2678 /*
2679 Process valid External SCSI Bus Reset and Incoming Mailbox
2680 Loaded Interrupts. Command Complete Interrupts are noted,
2681 and Outgoing Mailbox Available Interrupts are ignored, as
2682 they are never enabled.
2683 */
2684 if (InterruptRegister.ir.ExternalBusReset)
2685 HostAdapter->HostAdapterExternalReset = true;
2686 else if (InterruptRegister.ir.IncomingMailboxLoaded)
2687 BusLogic_ScanIncomingMailboxes(HostAdapter);
2688 else if (InterruptRegister.ir.CommandComplete)
2689 HostAdapter->HostAdapterCommandCompleted = true;
2690 }
2691 } else {
2692 /*
2693 Check if there is a pending interrupt for this Host Adapter.
2694 */
2695 if (FlashPoint_InterruptPending(HostAdapter->CardHandle))
2696 switch (FlashPoint_HandleInterrupt(HostAdapter->CardHandle)) {
2697 case FlashPoint_NormalInterrupt:
2698 break;
2699 case FlashPoint_ExternalBusReset:
2700 HostAdapter->HostAdapterExternalReset = true;
2701 break;
2702 case FlashPoint_InternalError:
2703 BusLogic_Warning("Internal FlashPoint Error detected" " - Resetting Host Adapter\n", HostAdapter);
2704 HostAdapter->HostAdapterInternalError = true;
2705 break;
2706 }
2707 }
2708 /*
2709 Process any completed CCBs.
2710 */
2711 if (HostAdapter->FirstCompletedCCB != NULL)
2712 BusLogic_ProcessCompletedCCBs(HostAdapter);
2713 /*
2714 Reset the Host Adapter if requested.
2715 */
2716 if (HostAdapter->HostAdapterExternalReset) {
2717 BusLogic_Warning("Resetting %s due to External SCSI Bus Reset\n", HostAdapter, HostAdapter->FullModelName);
2718 BusLogic_IncrementErrorCounter(&HostAdapter->ExternalHostAdapterResets);
2719 BusLogic_ResetHostAdapter(HostAdapter, false);
2720 HostAdapter->HostAdapterExternalReset = false;
2721 } else if (HostAdapter->HostAdapterInternalError) {
2722 BusLogic_Warning("Resetting %s due to Host Adapter Internal Error\n", HostAdapter, HostAdapter->FullModelName);
2723 BusLogic_IncrementErrorCounter(&HostAdapter->HostAdapterInternalErrors);
2724 BusLogic_ResetHostAdapter(HostAdapter, true);
2725 HostAdapter->HostAdapterInternalError = false;
2726 }
2727 /*
2728 Release exclusive access to Host Adapter.
2729 */
2730 spin_unlock_irqrestore(HostAdapter->SCSI_Host->host_lock, ProcessorFlags);
2731 return IRQ_HANDLED;
2732}
2733
2734
2735/*
2736 BusLogic_WriteOutgoingMailbox places CCB and Action Code into an Outgoing
2737 Mailbox for execution by Host Adapter. The Host Adapter's Lock should
2738 already have been acquired by the caller.
2739*/
2740
2741static boolean BusLogic_WriteOutgoingMailbox(struct BusLogic_HostAdapter
2742 *HostAdapter, enum BusLogic_ActionCode ActionCode, struct BusLogic_CCB *CCB)
2743{
2744 struct BusLogic_OutgoingMailbox *NextOutgoingMailbox;
2745 NextOutgoingMailbox = HostAdapter->NextOutgoingMailbox;
2746 if (NextOutgoingMailbox->ActionCode == BusLogic_OutgoingMailboxFree) {
2747 CCB->Status = BusLogic_CCB_Active;
2748 /*
2749 The CCB field must be written before the Action Code field since
2750 the Host Adapter is operating asynchronously and the locking code
2751 does not protect against simultaneous access by the Host Adapter.
2752 */
2753 NextOutgoingMailbox->CCB = CCB->DMA_Handle;
2754 NextOutgoingMailbox->ActionCode = ActionCode;
2755 BusLogic_StartMailboxCommand(HostAdapter);
2756 if (++NextOutgoingMailbox > HostAdapter->LastOutgoingMailbox)
2757 NextOutgoingMailbox = HostAdapter->FirstOutgoingMailbox;
2758 HostAdapter->NextOutgoingMailbox = NextOutgoingMailbox;
2759 if (ActionCode == BusLogic_MailboxStartCommand) {
2760 HostAdapter->ActiveCommands[CCB->TargetID]++;
2761 if (CCB->Opcode != BusLogic_BusDeviceReset)
2762 HostAdapter->TargetStatistics[CCB->TargetID].CommandsAttempted++;
2763 }
2764 return true;
2765 }
2766 return false;
2767}
2768
2769/* Error Handling (EH) support */
2770
2771static int BusLogic_host_reset(struct scsi_cmnd * SCpnt)
2772{
2773 struct BusLogic_HostAdapter *HostAdapter = (struct BusLogic_HostAdapter *) SCpnt->device->host->hostdata;
2774
2775 unsigned int id = SCpnt->device->id;
2776 struct BusLogic_TargetStatistics *stats = &HostAdapter->TargetStatistics[id];
df0ae249
JG
2777 int rc;
2778
2779 spin_lock_irq(SCpnt->device->host->host_lock);
2780
1da177e4
LT
2781 BusLogic_IncrementErrorCounter(&stats->HostAdapterResetsRequested);
2782
df0ae249
JG
2783 rc = BusLogic_ResetHostAdapter(HostAdapter, false);
2784 spin_unlock_irq(SCpnt->device->host->host_lock);
2785 return rc;
1da177e4
LT
2786}
2787
2788/*
2789 BusLogic_QueueCommand creates a CCB for Command and places it into an
2790 Outgoing Mailbox for execution by the associated Host Adapter.
2791*/
2792
2793static int BusLogic_QueueCommand(struct scsi_cmnd *Command, void (*CompletionRoutine) (struct scsi_cmnd *))
2794{
2795 struct BusLogic_HostAdapter *HostAdapter = (struct BusLogic_HostAdapter *) Command->device->host->hostdata;
2796 struct BusLogic_TargetFlags *TargetFlags = &HostAdapter->TargetFlags[Command->device->id];
2797 struct BusLogic_TargetStatistics *TargetStatistics = HostAdapter->TargetStatistics;
2798 unsigned char *CDB = Command->cmnd;
2799 int CDB_Length = Command->cmd_len;
2800 int TargetID = Command->device->id;
2801 int LogicalUnit = Command->device->lun;
2802 void *BufferPointer = Command->request_buffer;
2803 int BufferLength = Command->request_bufflen;
2804 int SegmentCount = Command->use_sg;
2805 struct BusLogic_CCB *CCB;
2806 /*
2807 SCSI REQUEST_SENSE commands will be executed automatically by the Host
2808 Adapter for any errors, so they should not be executed explicitly unless
2809 the Sense Data is zero indicating that no error occurred.
2810 */
2811 if (CDB[0] == REQUEST_SENSE && Command->sense_buffer[0] != 0) {
2812 Command->result = DID_OK << 16;
2813 CompletionRoutine(Command);
2814 return 0;
2815 }
2816 /*
2817 Allocate a CCB from the Host Adapter's free list. In the unlikely event
2818 that there are none available and memory allocation fails, wait 1 second
2819 and try again. If that fails, the Host Adapter is probably hung so signal
2820 an error as a Host Adapter Hard Reset should be initiated soon.
2821 */
2822 CCB = BusLogic_AllocateCCB(HostAdapter);
2823 if (CCB == NULL) {
2824 spin_unlock_irq(HostAdapter->SCSI_Host->host_lock);
2825 BusLogic_Delay(1);
2826 spin_lock_irq(HostAdapter->SCSI_Host->host_lock);
2827 CCB = BusLogic_AllocateCCB(HostAdapter);
2828 if (CCB == NULL) {
2829 Command->result = DID_ERROR << 16;
2830 CompletionRoutine(Command);
2831 return 0;
2832 }
2833 }
2834 /*
2835 Initialize the fields in the BusLogic Command Control Block (CCB).
2836 */
2837 if (SegmentCount == 0 && BufferLength != 0) {
2838 CCB->Opcode = BusLogic_InitiatorCCB;
2839 CCB->DataLength = BufferLength;
2840 CCB->DataPointer = pci_map_single(HostAdapter->PCI_Device,
2841 BufferPointer, BufferLength,
2842 Command->sc_data_direction);
2843 } else if (SegmentCount != 0) {
2844 struct scatterlist *ScatterList = (struct scatterlist *) BufferPointer;
2845 int Segment, Count;
2846
2847 Count = pci_map_sg(HostAdapter->PCI_Device, ScatterList, SegmentCount,
2848 Command->sc_data_direction);
2849 CCB->Opcode = BusLogic_InitiatorCCB_ScatterGather;
2850 CCB->DataLength = Count * sizeof(struct BusLogic_ScatterGatherSegment);
2851 if (BusLogic_MultiMasterHostAdapterP(HostAdapter))
2852 CCB->DataPointer = (unsigned int) CCB->DMA_Handle + ((unsigned long) &CCB->ScatterGatherList - (unsigned long) CCB);
2853 else
2854 CCB->DataPointer = Virtual_to_32Bit_Virtual(CCB->ScatterGatherList);
2855 for (Segment = 0; Segment < Count; Segment++) {
2856 CCB->ScatterGatherList[Segment].SegmentByteCount = sg_dma_len(ScatterList + Segment);
2857 CCB->ScatterGatherList[Segment].SegmentDataPointer = sg_dma_address(ScatterList + Segment);
2858 }
2859 } else {
2860 CCB->Opcode = BusLogic_InitiatorCCB;
2861 CCB->DataLength = BufferLength;
2862 CCB->DataPointer = 0;
2863 }
2864 switch (CDB[0]) {
2865 case READ_6:
2866 case READ_10:
2867 CCB->DataDirection = BusLogic_DataInLengthChecked;
2868 TargetStatistics[TargetID].ReadCommands++;
2869 BusLogic_IncrementByteCounter(&TargetStatistics[TargetID].TotalBytesRead, BufferLength);
2870 BusLogic_IncrementSizeBucket(TargetStatistics[TargetID].ReadCommandSizeBuckets, BufferLength);
2871 break;
2872 case WRITE_6:
2873 case WRITE_10:
2874 CCB->DataDirection = BusLogic_DataOutLengthChecked;
2875 TargetStatistics[TargetID].WriteCommands++;
2876 BusLogic_IncrementByteCounter(&TargetStatistics[TargetID].TotalBytesWritten, BufferLength);
2877 BusLogic_IncrementSizeBucket(TargetStatistics[TargetID].WriteCommandSizeBuckets, BufferLength);
2878 break;
2879 default:
2880 CCB->DataDirection = BusLogic_UncheckedDataTransfer;
2881 break;
2882 }
2883 CCB->CDB_Length = CDB_Length;
2884 CCB->HostAdapterStatus = 0;
2885 CCB->TargetDeviceStatus = 0;
2886 CCB->TargetID = TargetID;
2887 CCB->LogicalUnit = LogicalUnit;
2888 CCB->TagEnable = false;
2889 CCB->LegacyTagEnable = false;
2890 /*
2891 BusLogic recommends that after a Reset the first couple of commands that
2892 are sent to a Target Device be sent in a non Tagged Queue fashion so that
2893 the Host Adapter and Target Device can establish Synchronous and Wide
2894 Transfer before Queue Tag messages can interfere with the Synchronous and
2895 Wide Negotiation messages. By waiting to enable Tagged Queuing until after
2896 the first BusLogic_MaxTaggedQueueDepth commands have been queued, it is
2897 assured that after a Reset any pending commands are requeued before Tagged
2898 Queuing is enabled and that the Tagged Queuing message will not occur while
2899 the partition table is being printed. In addition, some devices do not
2900 properly handle the transition from non-tagged to tagged commands, so it is
2901 necessary to wait until there are no pending commands for a target device
2902 before queuing tagged commands.
2903 */
2904 if (HostAdapter->CommandsSinceReset[TargetID]++ >=
2905 BusLogic_MaxTaggedQueueDepth && !TargetFlags->TaggedQueuingActive && HostAdapter->ActiveCommands[TargetID] == 0 && TargetFlags->TaggedQueuingSupported && (HostAdapter->TaggedQueuingPermitted & (1 << TargetID))) {
2906 TargetFlags->TaggedQueuingActive = true;
2907 BusLogic_Notice("Tagged Queuing now active for Target %d\n", HostAdapter, TargetID);
2908 }
2909 if (TargetFlags->TaggedQueuingActive) {
2910 enum BusLogic_QueueTag QueueTag = BusLogic_SimpleQueueTag;
2911 /*
2912 When using Tagged Queuing with Simple Queue Tags, it appears that disk
2913 drive controllers do not guarantee that a queued command will not
2914 remain in a disconnected state indefinitely if commands that read or
2915 write nearer the head position continue to arrive without interruption.
2916 Therefore, for each Target Device this driver keeps track of the last
2917 time either the queue was empty or an Ordered Queue Tag was issued. If
2918 more than 4 seconds (one fifth of the 20 second disk timeout) have
2919 elapsed since this last sequence point, this command will be issued
2920 with an Ordered Queue Tag rather than a Simple Queue Tag, which forces
2921 the Target Device to complete all previously queued commands before
2922 this command may be executed.
2923 */
2924 if (HostAdapter->ActiveCommands[TargetID] == 0)
2925 HostAdapter->LastSequencePoint[TargetID] = jiffies;
60c904ae 2926 else if (time_after(jiffies, HostAdapter->LastSequencePoint[TargetID] + 4 * HZ)) {
1da177e4
LT
2927 HostAdapter->LastSequencePoint[TargetID] = jiffies;
2928 QueueTag = BusLogic_OrderedQueueTag;
2929 }
2930 if (HostAdapter->ExtendedLUNSupport) {
2931 CCB->TagEnable = true;
2932 CCB->QueueTag = QueueTag;
2933 } else {
2934 CCB->LegacyTagEnable = true;
2935 CCB->LegacyQueueTag = QueueTag;
2936 }
2937 }
2938 memcpy(CCB->CDB, CDB, CDB_Length);
2939 CCB->SenseDataLength = sizeof(Command->sense_buffer);
2940 CCB->SenseDataPointer = pci_map_single(HostAdapter->PCI_Device, Command->sense_buffer, CCB->SenseDataLength, PCI_DMA_FROMDEVICE);
2941 CCB->Command = Command;
2942 Command->scsi_done = CompletionRoutine;
2943 if (BusLogic_MultiMasterHostAdapterP(HostAdapter)) {
2944 /*
2945 Place the CCB in an Outgoing Mailbox. The higher levels of the SCSI
2946 Subsystem should not attempt to queue more commands than can be placed
2947 in Outgoing Mailboxes, so there should always be one free. In the
2948 unlikely event that there are none available, wait 1 second and try
2949 again. If that fails, the Host Adapter is probably hung so signal an
2950 error as a Host Adapter Hard Reset should be initiated soon.
2951 */
2952 if (!BusLogic_WriteOutgoingMailbox(HostAdapter, BusLogic_MailboxStartCommand, CCB)) {
2953 spin_unlock_irq(HostAdapter->SCSI_Host->host_lock);
2954 BusLogic_Warning("Unable to write Outgoing Mailbox - " "Pausing for 1 second\n", HostAdapter);
2955 BusLogic_Delay(1);
2956 spin_lock_irq(HostAdapter->SCSI_Host->host_lock);
2957 if (!BusLogic_WriteOutgoingMailbox(HostAdapter, BusLogic_MailboxStartCommand, CCB)) {
2958 BusLogic_Warning("Still unable to write Outgoing Mailbox - " "Host Adapter Dead?\n", HostAdapter);
2959 BusLogic_DeallocateCCB(CCB);
2960 Command->result = DID_ERROR << 16;
2961 Command->scsi_done(Command);
2962 }
2963 }
2964 } else {
2965 /*
2966 Call the FlashPoint SCCB Manager to start execution of the CCB.
2967 */
2968 CCB->Status = BusLogic_CCB_Active;
2969 HostAdapter->ActiveCommands[TargetID]++;
2970 TargetStatistics[TargetID].CommandsAttempted++;
2971 FlashPoint_StartCCB(HostAdapter->CardHandle, CCB);
2972 /*
2973 The Command may have already completed and BusLogic_QueueCompletedCCB
2974 been called, or it may still be pending.
2975 */
2976 if (CCB->Status == BusLogic_CCB_Completed)
2977 BusLogic_ProcessCompletedCCBs(HostAdapter);
2978 }
2979 return 0;
2980}
2981
2982
d2afb3ae 2983#if 0
1da177e4
LT
2984/*
2985 BusLogic_AbortCommand aborts Command if possible.
2986*/
2987
2988static int BusLogic_AbortCommand(struct scsi_cmnd *Command)
2989{
2990 struct BusLogic_HostAdapter *HostAdapter = (struct BusLogic_HostAdapter *) Command->device->host->hostdata;
2991
2992 int TargetID = Command->device->id;
2993 struct BusLogic_CCB *CCB;
2994 BusLogic_IncrementErrorCounter(&HostAdapter->TargetStatistics[TargetID].CommandAbortsRequested);
1da177e4
LT
2995 /*
2996 Attempt to find an Active CCB for this Command. If no Active CCB for this
2997 Command is found, then no Abort is necessary.
2998 */
2999 for (CCB = HostAdapter->All_CCBs; CCB != NULL; CCB = CCB->NextAll)
3000 if (CCB->Command == Command)
3001 break;
3002 if (CCB == NULL) {
3003 BusLogic_Warning("Unable to Abort Command to Target %d - " "No CCB Found\n", HostAdapter, TargetID);
3004 return SUCCESS;
3005 } else if (CCB->Status == BusLogic_CCB_Completed) {
3006 BusLogic_Warning("Unable to Abort Command to Target %d - " "CCB Completed\n", HostAdapter, TargetID);
3007 return SUCCESS;
3008 } else if (CCB->Status == BusLogic_CCB_Reset) {
3009 BusLogic_Warning("Unable to Abort Command to Target %d - " "CCB Reset\n", HostAdapter, TargetID);
3010 return SUCCESS;
3011 }
3012 if (BusLogic_MultiMasterHostAdapterP(HostAdapter)) {
3013 /*
3014 Attempt to Abort this CCB. MultiMaster Firmware versions prior to 5.xx
3015 do not generate Abort Tag messages, but only generate the non-tagged
3016 Abort message. Since non-tagged commands are not sent by the Host
3017 Adapter until the queue of outstanding tagged commands has completed,
3018 and the Abort message is treated as a non-tagged command, it is
3019 effectively impossible to abort commands when Tagged Queuing is active.
3020 Firmware version 5.xx does generate Abort Tag messages, so it is
3021 possible to abort commands when Tagged Queuing is active.
3022 */
3023 if (HostAdapter->TargetFlags[TargetID].TaggedQueuingActive && HostAdapter->FirmwareVersion[0] < '5') {
3024 BusLogic_Warning("Unable to Abort CCB #%ld to Target %d - " "Abort Tag Not Supported\n", HostAdapter, CCB->SerialNumber, TargetID);
3025 return FAILURE;
3026 } else if (BusLogic_WriteOutgoingMailbox(HostAdapter, BusLogic_MailboxAbortCommand, CCB)) {
3027 BusLogic_Warning("Aborting CCB #%ld to Target %d\n", HostAdapter, CCB->SerialNumber, TargetID);
3028 BusLogic_IncrementErrorCounter(&HostAdapter->TargetStatistics[TargetID].CommandAbortsAttempted);
3029 return SUCCESS;
3030 } else {
3031 BusLogic_Warning("Unable to Abort CCB #%ld to Target %d - " "No Outgoing Mailboxes\n", HostAdapter, CCB->SerialNumber, TargetID);
3032 return FAILURE;
3033 }
3034 } else {
3035 /*
3036 Call the FlashPoint SCCB Manager to abort execution of the CCB.
3037 */
3038 BusLogic_Warning("Aborting CCB #%ld to Target %d\n", HostAdapter, CCB->SerialNumber, TargetID);
3039 BusLogic_IncrementErrorCounter(&HostAdapter->TargetStatistics[TargetID].CommandAbortsAttempted);
3040 FlashPoint_AbortCCB(HostAdapter->CardHandle, CCB);
3041 /*
3042 The Abort may have already been completed and
3043 BusLogic_QueueCompletedCCB been called, or it
3044 may still be pending.
3045 */
3046 if (CCB->Status == BusLogic_CCB_Completed) {
3047 BusLogic_ProcessCompletedCCBs(HostAdapter);
3048 }
3049 return SUCCESS;
3050 }
3051 return SUCCESS;
3052}
3053
d2afb3ae 3054#endif
1da177e4
LT
3055/*
3056 BusLogic_ResetHostAdapter resets Host Adapter if possible, marking all
3057 currently executing SCSI Commands as having been Reset.
3058*/
3059
3060static int BusLogic_ResetHostAdapter(struct BusLogic_HostAdapter *HostAdapter, boolean HardReset)
3061{
3062 struct BusLogic_CCB *CCB;
3063 int TargetID;
3064
3065 /*
3066 * Attempt to Reset and Reinitialize the Host Adapter.
3067 */
3068
3069 if (!(BusLogic_HardwareResetHostAdapter(HostAdapter, HardReset) && BusLogic_InitializeHostAdapter(HostAdapter))) {
3070 BusLogic_Error("Resetting %s Failed\n", HostAdapter, HostAdapter->FullModelName);
3071 return FAILURE;
3072 }
3073
3074 /*
3075 * Deallocate all currently executing CCBs.
3076 */
3077
3078 for (CCB = HostAdapter->All_CCBs; CCB != NULL; CCB = CCB->NextAll)
3079 if (CCB->Status == BusLogic_CCB_Active)
3080 BusLogic_DeallocateCCB(CCB);
3081 /*
3082 * Wait a few seconds between the Host Adapter Hard Reset which
3083 * initiates a SCSI Bus Reset and issuing any SCSI Commands. Some
3084 * SCSI devices get confused if they receive SCSI Commands too soon
3085 * after a SCSI Bus Reset.
3086 */
3087
3088 if (HardReset) {
3089 spin_unlock_irq(HostAdapter->SCSI_Host->host_lock);
3090 BusLogic_Delay(HostAdapter->BusSettleTime);
3091 spin_lock_irq(HostAdapter->SCSI_Host->host_lock);
3092 }
3093
3094 for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++) {
3095 HostAdapter->LastResetAttempted[TargetID] = jiffies;
3096 HostAdapter->LastResetCompleted[TargetID] = jiffies;
3097 }
3098 return SUCCESS;
3099}
3100
3101/*
3102 BusLogic_BIOSDiskParameters returns the Heads/Sectors/Cylinders BIOS Disk
3103 Parameters for Disk. The default disk geometry is 64 heads, 32 sectors, and
3104 the appropriate number of cylinders so as not to exceed drive capacity. In
3105 order for disks equal to or larger than 1 GB to be addressable by the BIOS
3106 without exceeding the BIOS limitation of 1024 cylinders, Extended Translation
3107 may be enabled in AutoSCSI on FlashPoint Host Adapters and on "W" and "C"
3108 series MultiMaster Host Adapters, or by a dip switch setting on "S" and "A"
3109 series MultiMaster Host Adapters. With Extended Translation enabled, drives
3110 between 1 GB inclusive and 2 GB exclusive are given a disk geometry of 128
3111 heads and 32 sectors, and drives above 2 GB inclusive are given a disk
3112 geometry of 255 heads and 63 sectors. However, if the BIOS detects that the
3113 Extended Translation setting does not match the geometry in the partition
3114 table, then the translation inferred from the partition table will be used by
3115 the BIOS, and a warning may be displayed.
3116*/
3117
3118static int BusLogic_BIOSDiskParameters(struct scsi_device *sdev, struct block_device *Device, sector_t capacity, int *Parameters)
3119{
3120 struct BusLogic_HostAdapter *HostAdapter = (struct BusLogic_HostAdapter *) sdev->host->hostdata;
3121 struct BIOS_DiskParameters *DiskParameters = (struct BIOS_DiskParameters *) Parameters;
3122 unsigned char *buf;
3123 if (HostAdapter->ExtendedTranslationEnabled && capacity >= 2 * 1024 * 1024 /* 1 GB in 512 byte sectors */ ) {
3124 if (capacity >= 4 * 1024 * 1024 /* 2 GB in 512 byte sectors */ ) {
3125 DiskParameters->Heads = 255;
3126 DiskParameters->Sectors = 63;
3127 } else {
3128 DiskParameters->Heads = 128;
3129 DiskParameters->Sectors = 32;
3130 }
3131 } else {
3132 DiskParameters->Heads = 64;
3133 DiskParameters->Sectors = 32;
3134 }
3135 DiskParameters->Cylinders = (unsigned long) capacity / (DiskParameters->Heads * DiskParameters->Sectors);
3136 buf = scsi_bios_ptable(Device);
3137 if (buf == NULL)
3138 return 0;
3139 /*
3140 If the boot sector partition table flag is valid, search for a partition
3141 table entry whose end_head matches one of the standard BusLogic geometry
3142 translations (64/32, 128/32, or 255/63).
3143 */
3144 if (*(unsigned short *) (buf + 64) == 0xAA55) {
3145 struct partition *FirstPartitionEntry = (struct partition *) buf;
3146 struct partition *PartitionEntry = FirstPartitionEntry;
3147 int SavedCylinders = DiskParameters->Cylinders, PartitionNumber;
3148 unsigned char PartitionEntryEndHead = 0, PartitionEntryEndSector = 0;
3149 for (PartitionNumber = 0; PartitionNumber < 4; PartitionNumber++) {
3150 PartitionEntryEndHead = PartitionEntry->end_head;
3151 PartitionEntryEndSector = PartitionEntry->end_sector & 0x3F;
3152 if (PartitionEntryEndHead == 64 - 1) {
3153 DiskParameters->Heads = 64;
3154 DiskParameters->Sectors = 32;
3155 break;
3156 } else if (PartitionEntryEndHead == 128 - 1) {
3157 DiskParameters->Heads = 128;
3158 DiskParameters->Sectors = 32;
3159 break;
3160 } else if (PartitionEntryEndHead == 255 - 1) {
3161 DiskParameters->Heads = 255;
3162 DiskParameters->Sectors = 63;
3163 break;
3164 }
3165 PartitionEntry++;
3166 }
3167 if (PartitionNumber == 4) {
3168 PartitionEntryEndHead = FirstPartitionEntry->end_head;
3169 PartitionEntryEndSector = FirstPartitionEntry->end_sector & 0x3F;
3170 }
3171 DiskParameters->Cylinders = (unsigned long) capacity / (DiskParameters->Heads * DiskParameters->Sectors);
3172 if (PartitionNumber < 4 && PartitionEntryEndSector == DiskParameters->Sectors) {
3173 if (DiskParameters->Cylinders != SavedCylinders)
3174 BusLogic_Warning("Adopting Geometry %d/%d from Partition Table\n", HostAdapter, DiskParameters->Heads, DiskParameters->Sectors);
3175 } else if (PartitionEntryEndHead > 0 || PartitionEntryEndSector > 0) {
3176 BusLogic_Warning("Warning: Partition Table appears to " "have Geometry %d/%d which is\n", HostAdapter, PartitionEntryEndHead + 1, PartitionEntryEndSector);
3177 BusLogic_Warning("not compatible with current BusLogic " "Host Adapter Geometry %d/%d\n", HostAdapter, DiskParameters->Heads, DiskParameters->Sectors);
3178 }
3179 }
3180 kfree(buf);
3181 return 0;
3182}
3183
3184
3185/*
3186 BugLogic_ProcDirectoryInfo implements /proc/scsi/BusLogic/<N>.
3187*/
3188
3189static int BusLogic_ProcDirectoryInfo(struct Scsi_Host *shost, char *ProcBuffer, char **StartPointer, off_t Offset, int BytesAvailable, int WriteFlag)
3190{
3191 struct BusLogic_HostAdapter *HostAdapter = (struct BusLogic_HostAdapter *) shost->hostdata;
3192 struct BusLogic_TargetStatistics *TargetStatistics;
3193 int TargetID, Length;
3194 char *Buffer;
3195
3196 TargetStatistics = HostAdapter->TargetStatistics;
3197 if (WriteFlag) {
3198 HostAdapter->ExternalHostAdapterResets = 0;
3199 HostAdapter->HostAdapterInternalErrors = 0;
3200 memset(TargetStatistics, 0, BusLogic_MaxTargetDevices * sizeof(struct BusLogic_TargetStatistics));
3201 return 0;
3202 }
3203 Buffer = HostAdapter->MessageBuffer;
3204 Length = HostAdapter->MessageBufferLength;
3205 Length += sprintf(&Buffer[Length], "\n\
3206Current Driver Queue Depth: %d\n\
3207Currently Allocated CCBs: %d\n", HostAdapter->DriverQueueDepth, HostAdapter->AllocatedCCBs);
3208 Length += sprintf(&Buffer[Length], "\n\n\
3209 DATA TRANSFER STATISTICS\n\
3210\n\
3211Target Tagged Queuing Queue Depth Active Attempted Completed\n\
3212====== ============== =========== ====== ========= =========\n");
3213 for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++) {
3214 struct BusLogic_TargetFlags *TargetFlags = &HostAdapter->TargetFlags[TargetID];
3215 if (!TargetFlags->TargetExists)
3216 continue;
3217 Length += sprintf(&Buffer[Length], " %2d %s", TargetID, (TargetFlags->TaggedQueuingSupported ? (TargetFlags->TaggedQueuingActive ? " Active" : (HostAdapter->TaggedQueuingPermitted & (1 << TargetID)
3218 ? " Permitted" : " Disabled"))
3219 : "Not Supported"));
3220 Length += sprintf(&Buffer[Length],
3221 " %3d %3u %9u %9u\n", HostAdapter->QueueDepth[TargetID], HostAdapter->ActiveCommands[TargetID], TargetStatistics[TargetID].CommandsAttempted, TargetStatistics[TargetID].CommandsCompleted);
3222 }
3223 Length += sprintf(&Buffer[Length], "\n\
3224Target Read Commands Write Commands Total Bytes Read Total Bytes Written\n\
3225====== ============= ============== =================== ===================\n");
3226 for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++) {
3227 struct BusLogic_TargetFlags *TargetFlags = &HostAdapter->TargetFlags[TargetID];
3228 if (!TargetFlags->TargetExists)
3229 continue;
3230 Length += sprintf(&Buffer[Length], " %2d %9u %9u", TargetID, TargetStatistics[TargetID].ReadCommands, TargetStatistics[TargetID].WriteCommands);
3231 if (TargetStatistics[TargetID].TotalBytesRead.Billions > 0)
3232 Length += sprintf(&Buffer[Length], " %9u%09u", TargetStatistics[TargetID].TotalBytesRead.Billions, TargetStatistics[TargetID].TotalBytesRead.Units);
3233 else
3234 Length += sprintf(&Buffer[Length], " %9u", TargetStatistics[TargetID].TotalBytesRead.Units);
3235 if (TargetStatistics[TargetID].TotalBytesWritten.Billions > 0)
3236 Length += sprintf(&Buffer[Length], " %9u%09u\n", TargetStatistics[TargetID].TotalBytesWritten.Billions, TargetStatistics[TargetID].TotalBytesWritten.Units);
3237 else
3238 Length += sprintf(&Buffer[Length], " %9u\n", TargetStatistics[TargetID].TotalBytesWritten.Units);
3239 }
3240 Length += sprintf(&Buffer[Length], "\n\
3241Target Command 0-1KB 1-2KB 2-4KB 4-8KB 8-16KB\n\
3242====== ======= ========= ========= ========= ========= =========\n");
3243 for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++) {
3244 struct BusLogic_TargetFlags *TargetFlags = &HostAdapter->TargetFlags[TargetID];
3245 if (!TargetFlags->TargetExists)
3246 continue;
3247 Length +=
3248 sprintf(&Buffer[Length],
3249 " %2d Read %9u %9u %9u %9u %9u\n", TargetID,
3250 TargetStatistics[TargetID].ReadCommandSizeBuckets[0],
3251 TargetStatistics[TargetID].ReadCommandSizeBuckets[1], TargetStatistics[TargetID].ReadCommandSizeBuckets[2], TargetStatistics[TargetID].ReadCommandSizeBuckets[3], TargetStatistics[TargetID].ReadCommandSizeBuckets[4]);
3252 Length +=
3253 sprintf(&Buffer[Length],
3254 " %2d Write %9u %9u %9u %9u %9u\n", TargetID,
3255 TargetStatistics[TargetID].WriteCommandSizeBuckets[0],
3256 TargetStatistics[TargetID].WriteCommandSizeBuckets[1], TargetStatistics[TargetID].WriteCommandSizeBuckets[2], TargetStatistics[TargetID].WriteCommandSizeBuckets[3], TargetStatistics[TargetID].WriteCommandSizeBuckets[4]);
3257 }
3258 Length += sprintf(&Buffer[Length], "\n\
3259Target Command 16-32KB 32-64KB 64-128KB 128-256KB 256KB+\n\
3260====== ======= ========= ========= ========= ========= =========\n");
3261 for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++) {
3262 struct BusLogic_TargetFlags *TargetFlags = &HostAdapter->TargetFlags[TargetID];
3263 if (!TargetFlags->TargetExists)
3264 continue;
3265 Length +=
3266 sprintf(&Buffer[Length],
3267 " %2d Read %9u %9u %9u %9u %9u\n", TargetID,
3268 TargetStatistics[TargetID].ReadCommandSizeBuckets[5],
3269 TargetStatistics[TargetID].ReadCommandSizeBuckets[6], TargetStatistics[TargetID].ReadCommandSizeBuckets[7], TargetStatistics[TargetID].ReadCommandSizeBuckets[8], TargetStatistics[TargetID].ReadCommandSizeBuckets[9]);
3270 Length +=
3271 sprintf(&Buffer[Length],
3272 " %2d Write %9u %9u %9u %9u %9u\n", TargetID,
3273 TargetStatistics[TargetID].WriteCommandSizeBuckets[5],
3274 TargetStatistics[TargetID].WriteCommandSizeBuckets[6], TargetStatistics[TargetID].WriteCommandSizeBuckets[7], TargetStatistics[TargetID].WriteCommandSizeBuckets[8], TargetStatistics[TargetID].WriteCommandSizeBuckets[9]);
3275 }
3276 Length += sprintf(&Buffer[Length], "\n\n\
3277 ERROR RECOVERY STATISTICS\n\
3278\n\
3279 Command Aborts Bus Device Resets Host Adapter Resets\n\
3280Target Requested Completed Requested Completed Requested Completed\n\
3281 ID \\\\\\\\ Attempted //// \\\\\\\\ Attempted //// \\\\\\\\ Attempted ////\n\
3282====== ===== ===== ===== ===== ===== ===== ===== ===== =====\n");
3283 for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++) {
3284 struct BusLogic_TargetFlags *TargetFlags = &HostAdapter->TargetFlags[TargetID];
3285 if (!TargetFlags->TargetExists)
3286 continue;
3287 Length += sprintf(&Buffer[Length], "\
3288 %2d %5d %5d %5d %5d %5d %5d %5d %5d %5d\n", TargetID, TargetStatistics[TargetID].CommandAbortsRequested, TargetStatistics[TargetID].CommandAbortsAttempted, TargetStatistics[TargetID].CommandAbortsCompleted, TargetStatistics[TargetID].BusDeviceResetsRequested, TargetStatistics[TargetID].BusDeviceResetsAttempted, TargetStatistics[TargetID].BusDeviceResetsCompleted, TargetStatistics[TargetID].HostAdapterResetsRequested, TargetStatistics[TargetID].HostAdapterResetsAttempted, TargetStatistics[TargetID].HostAdapterResetsCompleted);
3289 }
3290 Length += sprintf(&Buffer[Length], "\nExternal Host Adapter Resets: %d\n", HostAdapter->ExternalHostAdapterResets);
3291 Length += sprintf(&Buffer[Length], "Host Adapter Internal Errors: %d\n", HostAdapter->HostAdapterInternalErrors);
3292 if (Length >= BusLogic_MessageBufferSize)
3293 BusLogic_Error("Message Buffer length %d exceeds size %d\n", HostAdapter, Length, BusLogic_MessageBufferSize);
3294 if ((Length -= Offset) <= 0)
3295 return 0;
3296 if (Length >= BytesAvailable)
3297 Length = BytesAvailable;
3298 memcpy(ProcBuffer, HostAdapter->MessageBuffer + Offset, Length);
3299 *StartPointer = ProcBuffer;
3300 return Length;
3301}
3302
3303
3304/*
3305 BusLogic_Message prints Driver Messages.
3306*/
3307
3308static void BusLogic_Message(enum BusLogic_MessageLevel MessageLevel, char *Format, struct BusLogic_HostAdapter *HostAdapter, ...)
3309{
3310 static char Buffer[BusLogic_LineBufferSize];
3311 static boolean BeginningOfLine = true;
3312 va_list Arguments;
3313 int Length = 0;
3314 va_start(Arguments, HostAdapter);
3315 Length = vsprintf(Buffer, Format, Arguments);
3316 va_end(Arguments);
3317 if (MessageLevel == BusLogic_AnnounceLevel) {
3318 static int AnnouncementLines = 0;
3319 strcpy(&HostAdapter->MessageBuffer[HostAdapter->MessageBufferLength], Buffer);
3320 HostAdapter->MessageBufferLength += Length;
3321 if (++AnnouncementLines <= 2)
3322 printk("%sscsi: %s", BusLogic_MessageLevelMap[MessageLevel], Buffer);
3323 } else if (MessageLevel == BusLogic_InfoLevel) {
3324 strcpy(&HostAdapter->MessageBuffer[HostAdapter->MessageBufferLength], Buffer);
3325 HostAdapter->MessageBufferLength += Length;
3326 if (BeginningOfLine) {
3327 if (Buffer[0] != '\n' || Length > 1)
3328 printk("%sscsi%d: %s", BusLogic_MessageLevelMap[MessageLevel], HostAdapter->HostNumber, Buffer);
3329 } else
3330 printk("%s", Buffer);
3331 } else {
3332 if (BeginningOfLine) {
3333 if (HostAdapter != NULL && HostAdapter->HostAdapterInitialized)
3334 printk("%sscsi%d: %s", BusLogic_MessageLevelMap[MessageLevel], HostAdapter->HostNumber, Buffer);
3335 else
3336 printk("%s%s", BusLogic_MessageLevelMap[MessageLevel], Buffer);
3337 } else
3338 printk("%s", Buffer);
3339 }
3340 BeginningOfLine = (Buffer[Length - 1] == '\n');
3341}
3342
3343
3344/*
3345 BusLogic_ParseKeyword parses an individual option keyword. It returns true
3346 and updates the pointer if the keyword is recognized and false otherwise.
3347*/
3348
3349static boolean __init BusLogic_ParseKeyword(char **StringPointer, char *Keyword)
3350{
3351 char *Pointer = *StringPointer;
3352 while (*Keyword != '\0') {
3353 char StringChar = *Pointer++;
3354 char KeywordChar = *Keyword++;
3355 if (StringChar >= 'A' && StringChar <= 'Z')
3356 StringChar += 'a' - 'Z';
3357 if (KeywordChar >= 'A' && KeywordChar <= 'Z')
3358 KeywordChar += 'a' - 'Z';
3359 if (StringChar != KeywordChar)
3360 return false;
3361 }
3362 *StringPointer = Pointer;
3363 return true;
3364}
3365
3366
3367/*
3368 BusLogic_ParseDriverOptions handles processing of BusLogic Driver Options
3369 specifications.
3370
3371 BusLogic Driver Options may be specified either via the Linux Kernel Command
3372 Line or via the Loadable Kernel Module Installation Facility. Driver Options
3373 for multiple host adapters may be specified either by separating the option
3374 strings by a semicolon, or by specifying multiple "BusLogic=" strings on the
3375 command line. Individual option specifications for a single host adapter are
3376 separated by commas. The Probing and Debugging Options apply to all host
3377 adapters whereas the remaining options apply individually only to the
3378 selected host adapter.
3379
3380 The BusLogic Driver Probing Options are described in
3381 <file:Documentation/scsi/BusLogic.txt>.
3382*/
3383
3384static int __init BusLogic_ParseDriverOptions(char *OptionsString)
3385{
3386 while (true) {
3387 struct BusLogic_DriverOptions *DriverOptions = &BusLogic_DriverOptions[BusLogic_DriverOptionsCount++];
3388 int TargetID;
3389 memset(DriverOptions, 0, sizeof(struct BusLogic_DriverOptions));
3390 while (*OptionsString != '\0' && *OptionsString != ';') {
3391 /* Probing Options. */
3392 if (BusLogic_ParseKeyword(&OptionsString, "IO:")) {
3393 unsigned long IO_Address = simple_strtoul(OptionsString, &OptionsString, 0);
3394 BusLogic_ProbeOptions.LimitedProbeISA = true;
3395 switch (IO_Address) {
3396 case 0x330:
3397 BusLogic_ProbeOptions.Probe330 = true;
3398 break;
3399 case 0x334:
3400 BusLogic_ProbeOptions.Probe334 = true;
3401 break;
3402 case 0x230:
3403 BusLogic_ProbeOptions.Probe230 = true;
3404 break;
3405 case 0x234:
3406 BusLogic_ProbeOptions.Probe234 = true;
3407 break;
3408 case 0x130:
3409 BusLogic_ProbeOptions.Probe130 = true;
3410 break;
3411 case 0x134:
3412 BusLogic_ProbeOptions.Probe134 = true;
3413 break;
3414 default:
3415 BusLogic_Error("BusLogic: Invalid Driver Options " "(invalid I/O Address 0x%X)\n", NULL, IO_Address);
3416 return 0;
3417 }
3418 } else if (BusLogic_ParseKeyword(&OptionsString, "NoProbeISA"))
3419 BusLogic_ProbeOptions.NoProbeISA = true;
3420 else if (BusLogic_ParseKeyword(&OptionsString, "NoProbePCI"))
3421 BusLogic_ProbeOptions.NoProbePCI = true;
3422 else if (BusLogic_ParseKeyword(&OptionsString, "NoProbe"))
3423 BusLogic_ProbeOptions.NoProbe = true;
3424 else if (BusLogic_ParseKeyword(&OptionsString, "NoSortPCI"))
3425 BusLogic_ProbeOptions.NoSortPCI = true;
3426 else if (BusLogic_ParseKeyword(&OptionsString, "MultiMasterFirst"))
3427 BusLogic_ProbeOptions.MultiMasterFirst = true;
3428 else if (BusLogic_ParseKeyword(&OptionsString, "FlashPointFirst"))
3429 BusLogic_ProbeOptions.FlashPointFirst = true;
3430 /* Tagged Queuing Options. */
3431 else if (BusLogic_ParseKeyword(&OptionsString, "QueueDepth:[") || BusLogic_ParseKeyword(&OptionsString, "QD:[")) {
3432 for (TargetID = 0; TargetID < BusLogic_MaxTargetDevices; TargetID++) {
3433 unsigned short QueueDepth = simple_strtoul(OptionsString, &OptionsString, 0);
3434 if (QueueDepth > BusLogic_MaxTaggedQueueDepth) {
3435 BusLogic_Error("BusLogic: Invalid Driver Options " "(invalid Queue Depth %d)\n", NULL, QueueDepth);
3436 return 0;
3437 }
3438 DriverOptions->QueueDepth[TargetID] = QueueDepth;
3439 if (*OptionsString == ',')
3440 OptionsString++;
3441 else if (*OptionsString == ']')
3442 break;
3443 else {
3444 BusLogic_Error("BusLogic: Invalid Driver Options " "(',' or ']' expected at '%s')\n", NULL, OptionsString);
3445 return 0;
3446 }
3447 }
3448 if (*OptionsString != ']') {
3449 BusLogic_Error("BusLogic: Invalid Driver Options " "(']' expected at '%s')\n", NULL, OptionsString);
3450 return 0;
3451 } else
3452 OptionsString++;
3453 } else if (BusLogic_ParseKeyword(&OptionsString, "QueueDepth:") || BusLogic_ParseKeyword(&OptionsString, "QD:")) {
3454 unsigned short QueueDepth = simple_strtoul(OptionsString, &OptionsString, 0);
3455 if (QueueDepth == 0 || QueueDepth > BusLogic_MaxTaggedQueueDepth) {
3456 BusLogic_Error("BusLogic: Invalid Driver Options " "(invalid Queue Depth %d)\n", NULL, QueueDepth);
3457 return 0;
3458 }
3459 DriverOptions->CommonQueueDepth = QueueDepth;
3460 for (TargetID = 0; TargetID < BusLogic_MaxTargetDevices; TargetID++)
3461 DriverOptions->QueueDepth[TargetID] = QueueDepth;
3462 } else if (BusLogic_ParseKeyword(&OptionsString, "TaggedQueuing:") || BusLogic_ParseKeyword(&OptionsString, "TQ:")) {
3463 if (BusLogic_ParseKeyword(&OptionsString, "Default")) {
3464 DriverOptions->TaggedQueuingPermitted = 0x0000;
3465 DriverOptions->TaggedQueuingPermittedMask = 0x0000;
3466 } else if (BusLogic_ParseKeyword(&OptionsString, "Enable")) {
3467 DriverOptions->TaggedQueuingPermitted = 0xFFFF;
3468 DriverOptions->TaggedQueuingPermittedMask = 0xFFFF;
3469 } else if (BusLogic_ParseKeyword(&OptionsString, "Disable")) {
3470 DriverOptions->TaggedQueuingPermitted = 0x0000;
3471 DriverOptions->TaggedQueuingPermittedMask = 0xFFFF;
3472 } else {
3473 unsigned short TargetBit;
3474 for (TargetID = 0, TargetBit = 1; TargetID < BusLogic_MaxTargetDevices; TargetID++, TargetBit <<= 1)
3475 switch (*OptionsString++) {
3476 case 'Y':
3477 DriverOptions->TaggedQueuingPermitted |= TargetBit;
3478 DriverOptions->TaggedQueuingPermittedMask |= TargetBit;
3479 break;
3480 case 'N':
3481 DriverOptions->TaggedQueuingPermitted &= ~TargetBit;
3482 DriverOptions->TaggedQueuingPermittedMask |= TargetBit;
3483 break;
3484 case 'X':
3485 break;
3486 default:
3487 OptionsString--;
3488 TargetID = BusLogic_MaxTargetDevices;
3489 break;
3490 }
3491 }
3492 }
3493 /* Miscellaneous Options. */
3494 else if (BusLogic_ParseKeyword(&OptionsString, "BusSettleTime:") || BusLogic_ParseKeyword(&OptionsString, "BST:")) {
3495 unsigned short BusSettleTime = simple_strtoul(OptionsString, &OptionsString, 0);
3496 if (BusSettleTime > 5 * 60) {
3497 BusLogic_Error("BusLogic: Invalid Driver Options " "(invalid Bus Settle Time %d)\n", NULL, BusSettleTime);
3498 return 0;
3499 }
3500 DriverOptions->BusSettleTime = BusSettleTime;
3501 } else if (BusLogic_ParseKeyword(&OptionsString, "InhibitTargetInquiry"))
3502 DriverOptions->LocalOptions.InhibitTargetInquiry = true;
3503 /* Debugging Options. */
3504 else if (BusLogic_ParseKeyword(&OptionsString, "TraceProbe"))
3505 BusLogic_GlobalOptions.TraceProbe = true;
3506 else if (BusLogic_ParseKeyword(&OptionsString, "TraceHardwareReset"))
3507 BusLogic_GlobalOptions.TraceHardwareReset = true;
3508 else if (BusLogic_ParseKeyword(&OptionsString, "TraceConfiguration"))
3509 BusLogic_GlobalOptions.TraceConfiguration = true;
3510 else if (BusLogic_ParseKeyword(&OptionsString, "TraceErrors"))
3511 BusLogic_GlobalOptions.TraceErrors = true;
3512 else if (BusLogic_ParseKeyword(&OptionsString, "Debug")) {
3513 BusLogic_GlobalOptions.TraceProbe = true;
3514 BusLogic_GlobalOptions.TraceHardwareReset = true;
3515 BusLogic_GlobalOptions.TraceConfiguration = true;
3516 BusLogic_GlobalOptions.TraceErrors = true;
3517 }
3518 if (*OptionsString == ',')
3519 OptionsString++;
3520 else if (*OptionsString != ';' && *OptionsString != '\0') {
3521 BusLogic_Error("BusLogic: Unexpected Driver Option '%s' " "ignored\n", NULL, OptionsString);
3522 *OptionsString = '\0';
3523 }
3524 }
3525 if (!(BusLogic_DriverOptionsCount == 0 || BusLogic_ProbeInfoCount == 0 || BusLogic_DriverOptionsCount == BusLogic_ProbeInfoCount)) {
3526 BusLogic_Error("BusLogic: Invalid Driver Options " "(all or no I/O Addresses must be specified)\n", NULL);
3527 return 0;
3528 }
3529 /*
3530 Tagged Queuing is disabled when the Queue Depth is 1 since queuing
3531 multiple commands is not possible.
3532 */
3533 for (TargetID = 0; TargetID < BusLogic_MaxTargetDevices; TargetID++)
3534 if (DriverOptions->QueueDepth[TargetID] == 1) {
3535 unsigned short TargetBit = 1 << TargetID;
3536 DriverOptions->TaggedQueuingPermitted &= ~TargetBit;
3537 DriverOptions->TaggedQueuingPermittedMask |= TargetBit;
3538 }
3539 if (*OptionsString == ';')
3540 OptionsString++;
3541 if (*OptionsString == '\0')
3542 return 0;
3543 }
3544 return 1;
3545}
3546
3547/*
3548 Get it all started
3549*/
3550
3551static struct scsi_host_template Bus_Logic_template = {
3552 .module = THIS_MODULE,
3553 .proc_name = "BusLogic",
3554 .proc_info = BusLogic_ProcDirectoryInfo,
3555 .name = "BusLogic",
3556 .info = BusLogic_DriverInfo,
3557 .queuecommand = BusLogic_QueueCommand,
3558 .slave_configure = BusLogic_SlaveConfigure,
3559 .bios_param = BusLogic_BIOSDiskParameters,
3560 .eh_host_reset_handler = BusLogic_host_reset,
3561#if 0
3562 .eh_abort_handler = BusLogic_AbortCommand,
3563#endif
3564 .unchecked_isa_dma = 1,
3565 .max_sectors = 128,
3566 .use_clustering = ENABLE_CLUSTERING,
3567};
3568
3569/*
3570 BusLogic_Setup handles processing of Kernel Command Line Arguments.
3571*/
3572
3573static int __init BusLogic_Setup(char *str)
3574{
3575 int ints[3];
3576
3577 (void) get_options(str, ARRAY_SIZE(ints), ints);
3578
3579 if (ints[0] != 0) {
3580 BusLogic_Error("BusLogic: Obsolete Command Line Entry " "Format Ignored\n", NULL);
3581 return 0;
3582 }
3583 if (str == NULL || *str == '\0')
3584 return 0;
3585 return BusLogic_ParseDriverOptions(str);
3586}
3587
3588/*
3589 * Exit function. Deletes all hosts associated with this driver.
3590 */
3591
3592static void __exit BusLogic_exit(void)
3593{
3594 struct BusLogic_HostAdapter *ha, *next;
3595
3596 list_for_each_entry_safe(ha, next, &BusLogic_host_list, host_list)
3597 BusLogic_ReleaseHostAdapter(ha);
3598}
3599
3600__setup("BusLogic=", BusLogic_Setup);
3601
3602module_init(BusLogic_init);
3603module_exit(BusLogic_exit);