4 Linux Driver for BusLogic MultiMaster and FlashPoint SCSI Host Adapters
6 Copyright 1995-1998 by Leonard N. Zubkoff <lnz@dandelion.com>
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.
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
17 The author respectfully requests that any modifications to this software be
18 sent directly to him for evaluation and testing.
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.
24 Finally, special thanks to Mylex/BusLogic for making the FlashPoint SCCB
25 Manager available as freely redistributable source code.
29 #define BusLogic_DriverVersion "2.1.16"
30 #define BusLogic_DriverDate "18 July 2002"
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>
40 #include <linux/stat.h>
41 #include <linux/pci.h>
42 #include <linux/spinlock.h>
43 #include <linux/jiffies.h>
44 #include <linux/dma-mapping.h>
45 #include <scsi/scsicam.h>
49 #include <asm/system.h>
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>
57 #include "FlashPoint.c"
63 static struct scsi_host_template Bus_Logic_template;
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.
71 static int BusLogic_DriverOptionsCount;
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.
80 static struct BusLogic_DriverOptions BusLogic_DriverOptions[BusLogic_MaxHostAdapters];
84 BusLogic can be assigned a string by insmod.
87 MODULE_LICENSE("GPL");
89 static char *BusLogic;
90 module_param(BusLogic, charp, 0);
95 BusLogic_ProbeOptions is a set of Probe Options to be applied across
96 all BusLogic Host Adapters.
99 static struct BusLogic_ProbeOptions BusLogic_ProbeOptions;
103 BusLogic_GlobalOptions is a set of Global Options to be applied across
104 all BusLogic Host Adapters.
107 static struct BusLogic_GlobalOptions BusLogic_GlobalOptions;
109 static LIST_HEAD(BusLogic_host_list);
112 BusLogic_ProbeInfoCount is the number of entries in BusLogic_ProbeInfoList.
115 static int BusLogic_ProbeInfoCount;
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.
125 static struct BusLogic_ProbeInfo *BusLogic_ProbeInfoList;
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.
134 static char *BusLogic_CommandFailureReason;
137 BusLogic_AnnounceDriver announces the Driver Version and Date, Author's
138 Name, Copyright Notice, and Electronic Mail Address.
141 static void BusLogic_AnnounceDriver(struct BusLogic_HostAdapter *HostAdapter)
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);
149 BusLogic_DriverInfo returns the Host Adapter Name to identify this SCSI
150 Driver and Host Adapter.
153 static const char *BusLogic_DriverInfo(struct Scsi_Host *Host)
155 struct BusLogic_HostAdapter *HostAdapter = (struct BusLogic_HostAdapter *) Host->hostdata;
156 return HostAdapter->FullModelName;
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.
165 static void BusLogic_InitializeCCBs(struct BusLogic_HostAdapter *HostAdapter, void *BlockPointer, int BlockSize, dma_addr_t BlockPointerHandle)
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;
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++;
186 offset += sizeof(struct BusLogic_CCB);
192 BusLogic_CreateInitialCCBs allocates the initial CCBs for Host Adapter.
195 static boolean __init BusLogic_CreateInitialCCBs(struct BusLogic_HostAdapter *HostAdapter)
197 int BlockSize = BusLogic_CCB_AllocationGroupSize * sizeof(struct BusLogic_CCB);
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);
206 BusLogic_InitializeCCBs(HostAdapter, BlockPointer, BlockSize, BlockPointerHandle);
213 BusLogic_DestroyCCBs deallocates the CCBs for Host Adapter.
216 static void BusLogic_DestroyCCBs(struct BusLogic_HostAdapter *HostAdapter)
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) {
225 pci_free_consistent(HostAdapter->PCI_Device, Last_CCB->AllocationGroupSize, Last_CCB, Last_CCB->AllocationGroupHead);
230 pci_free_consistent(HostAdapter->PCI_Device, Last_CCB->AllocationGroupSize, Last_CCB, Last_CCB->AllocationGroupHead);
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.
241 static void BusLogic_CreateAdditionalCCBs(struct BusLogic_HostAdapter *HostAdapter, int AdditionalCCBs, boolean SuccessMessageP)
243 int BlockSize = BusLogic_CCB_AllocationGroupSize * sizeof(struct BusLogic_CCB);
244 int PreviouslyAllocated = HostAdapter->AllocatedCCBs;
246 dma_addr_t BlockPointerHandle;
247 if (AdditionalCCBs <= 0)
249 while (HostAdapter->AllocatedCCBs - PreviouslyAllocated < AdditionalCCBs) {
250 BlockPointer = pci_alloc_consistent(HostAdapter->PCI_Device, BlockSize, &BlockPointerHandle);
251 if (BlockPointer == NULL)
253 BusLogic_InitializeCCBs(HostAdapter, BlockPointer, BlockSize, BlockPointerHandle);
255 if (HostAdapter->AllocatedCCBs > PreviouslyAllocated) {
257 BusLogic_Notice("Allocated %d additional CCBs (total now %d)\n", HostAdapter, HostAdapter->AllocatedCCBs - PreviouslyAllocated, HostAdapter->AllocatedCCBs);
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;
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.
273 static struct BusLogic_CCB *BusLogic_AllocateCCB(struct BusLogic_HostAdapter
276 static unsigned long SerialNumber = 0;
277 struct BusLogic_CCB *CCB;
278 CCB = HostAdapter->Free_CCBs;
280 CCB->SerialNumber = ++SerialNumber;
281 HostAdapter->Free_CCBs = CCB->Next;
283 if (HostAdapter->Free_CCBs == NULL)
284 BusLogic_CreateAdditionalCCBs(HostAdapter, HostAdapter->IncrementalCCBs, true);
287 BusLogic_CreateAdditionalCCBs(HostAdapter, HostAdapter->IncrementalCCBs, true);
288 CCB = HostAdapter->Free_CCBs;
291 CCB->SerialNumber = ++SerialNumber;
292 HostAdapter->Free_CCBs = CCB->Next;
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
304 static void BusLogic_DeallocateCCB(struct BusLogic_CCB *CCB)
306 struct BusLogic_HostAdapter *HostAdapter = CCB->HostAdapter;
307 struct scsi_cmnd *cmd = CCB->Command;
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);
317 pci_unmap_single(HostAdapter->PCI_Device, CCB->SenseDataPointer,
318 CCB->SenseDataLength, PCI_DMA_FROMDEVICE);
321 CCB->Status = BusLogic_CCB_Free;
322 CCB->Next = HostAdapter->Free_CCBs;
323 HostAdapter->Free_CCBs = CCB;
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
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.
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.
345 static int BusLogic_Command(struct BusLogic_HostAdapter *HostAdapter, enum BusLogic_OperationCode OperationCode, void *ParameterData, int ParameterLength, void *ReplyData, int ReplyLength)
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;
355 Clear out the Reply Data if provided.
358 memset(ReplyData, 0, ReplyLength);
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.
365 if (!HostAdapter->IRQ_ChannelAcquired) {
366 local_irq_save(ProcessorFlags);
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.
373 TimeoutCounter = 10000;
374 while (--TimeoutCounter >= 0) {
375 StatusRegister.All = BusLogic_ReadStatusRegister(HostAdapter);
376 if (StatusRegister.sr.HostAdapterReady && !StatusRegister.sr.CommandParameterRegisterBusy)
380 if (TimeoutCounter < 0) {
381 BusLogic_CommandFailureReason = "Timeout waiting for Host Adapter Ready";
386 Write the OperationCode to the Command/Parameter Register.
388 HostAdapter->HostAdapterCommandCompleted = false;
389 BusLogic_WriteCommandParameterRegister(HostAdapter, OperationCode);
391 Write any additional Parameter Bytes.
393 TimeoutCounter = 10000;
394 while (ParameterLength > 0 && --TimeoutCounter >= 0) {
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.
408 InterruptRegister.All = BusLogic_ReadInterruptRegister(HostAdapter);
409 StatusRegister.All = BusLogic_ReadStatusRegister(HostAdapter);
410 if (InterruptRegister.ir.CommandComplete)
412 if (HostAdapter->HostAdapterCommandCompleted)
414 if (StatusRegister.sr.DataInRegisterReady)
416 if (StatusRegister.sr.CommandParameterRegisterBusy)
418 BusLogic_WriteCommandParameterRegister(HostAdapter, *ParameterPointer++);
421 if (TimeoutCounter < 0) {
422 BusLogic_CommandFailureReason = "Timeout waiting for Parameter Acceptance";
427 The Modify I/O Address command does not cause a Command Complete Interrupt.
429 if (OperationCode == BusLogic_ModifyIOAddress) {
430 StatusRegister.All = BusLogic_ReadStatusRegister(HostAdapter);
431 if (StatusRegister.sr.CommandInvalid) {
432 BusLogic_CommandFailureReason = "Modify I/O Address Invalid";
436 if (BusLogic_GlobalOptions.TraceConfiguration)
437 BusLogic_Notice("BusLogic_Command(%02X) Status = %02X: " "(Modify I/O Address)\n", HostAdapter, OperationCode, StatusRegister.All);
442 Select an appropriate timeout value for awaiting command completion.
444 switch (OperationCode) {
445 case BusLogic_InquireInstalledDevicesID0to7:
446 case BusLogic_InquireInstalledDevicesID8to15:
447 case BusLogic_InquireTargetDevices:
448 /* Approximately 60 seconds. */
449 TimeoutCounter = 60 * 10000;
452 /* Approximately 1 second. */
453 TimeoutCounter = 10000;
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.
461 while (--TimeoutCounter >= 0) {
462 InterruptRegister.All = BusLogic_ReadInterruptRegister(HostAdapter);
463 StatusRegister.All = BusLogic_ReadStatusRegister(HostAdapter);
464 if (InterruptRegister.ir.CommandComplete)
466 if (HostAdapter->HostAdapterCommandCompleted)
468 if (StatusRegister.sr.DataInRegisterReady) {
469 if (++ReplyBytes <= ReplyLength)
470 *ReplyPointer++ = BusLogic_ReadDataInRegister(HostAdapter);
472 BusLogic_ReadDataInRegister(HostAdapter);
474 if (OperationCode == BusLogic_FetchHostAdapterLocalRAM && StatusRegister.sr.HostAdapterReady)
478 if (TimeoutCounter < 0) {
479 BusLogic_CommandFailureReason = "Timeout waiting for Command Complete";
484 Clear any pending Command Complete Interrupt.
486 BusLogic_InterruptReset(HostAdapter);
488 Provide tracing information if requested.
490 if (BusLogic_GlobalOptions.TraceConfiguration) {
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);
500 Process Command Invalid conditions.
502 if (StatusRegister.sr.CommandInvalid) {
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.
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);
520 BusLogic_CommandFailureReason = "Command Invalid";
525 Handle Excess Parameters Supplied conditions.
527 if (ParameterLength > 0) {
528 BusLogic_CommandFailureReason = "Excess Parameters Supplied";
533 Indicate the command completed successfully.
535 BusLogic_CommandFailureReason = NULL;
538 Restore the interrupt status if necessary and return.
541 if (!HostAdapter->IRQ_ChannelAcquired)
542 local_irq_restore(ProcessorFlags);
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
553 static void __init BusLogic_AppendProbeAddressISA(unsigned long IO_Address)
555 struct BusLogic_ProbeInfo *ProbeInfo;
556 if (BusLogic_ProbeInfoCount >= BusLogic_MaxHostAdapters)
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;
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.
572 static void __init BusLogic_InitializeProbeInfoListISA(struct BusLogic_HostAdapter
573 *PrototypeHostAdapter)
576 If BusLogic Driver Options specifications requested that ISA Bus Probes
577 be inhibited, do not proceed further.
579 if (BusLogic_ProbeOptions.NoProbeISA)
582 Append the list of standard BusLogic MultiMaster ISA I/O Addresses.
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);
603 BusLogic_SortProbeInfo sorts a section of BusLogic_ProbeInfoList in order
604 of increasing PCI Bus and Device Number.
607 static void __init BusLogic_SortProbeInfo(struct BusLogic_ProbeInfo *ProbeInfoList, int ProbeInfoCount)
609 int LastInterchange = ProbeInfoCount - 1, Bound, j;
610 while (LastInterchange > 0) {
611 Bound = LastInterchange;
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));
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.
636 static int __init BusLogic_InitializeMultiMasterProbeInfo(struct BusLogic_HostAdapter
637 *PrototypeHostAdapter)
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;
647 if (BusLogic_ProbeInfoCount >= BusLogic_MaxHostAdapters)
649 BusLogic_ProbeInfoCount++;
650 for (i = 0; i < 6; i++)
651 StandardAddressSeen[i] = false;
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.
664 PrimaryProbeInfo->IO_Address = 0;
665 while ((PCI_Device = pci_get_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;
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;
677 if (pci_enable_device(PCI_Device))
680 if (pci_set_dma_mask(PCI_Device, DMA_32BIT_MASK ))
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);
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);
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);
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);
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);
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.
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;
721 PCIHostAdapterInformation.ISACompatibleIOPort = BusLogic_IO_Disable;
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.
729 ModifyIOAddressRequest = BusLogic_IO_Disable;
730 BusLogic_Command(HostAdapter, BusLogic_ModifyIOAddress, &ModifyIOAddressRequest, sizeof(ModifyIOAddressRequest), NULL, 0);
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.
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;
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.
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_dev_get(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_dev_get(PCI_Device);
777 NonPrimaryPCIMultiMasterCount++;
778 PCIMultiMasterCount++;
780 BusLogic_Warning("BusLogic: Too many Host Adapters " "detected\n", NULL);
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.
792 if (ForceBusDeviceScanningOrder)
793 BusLogic_SortProbeInfo(&BusLogic_ProbeInfoList[NonPrimaryPCIMultiMasterIndex], NonPrimaryPCIMultiMasterCount);
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.
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;
806 Append the list of standard BusLogic MultiMaster ISA I/O Addresses,
807 omitting the Primary I/O Address which has already been handled.
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);
822 Iterate over the older non-compliant MultiMaster PCI Host Adapters,
823 noting the PCI bus location and assigned IRQ Channel.
826 while ((PCI_Device = pci_get_device(PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER_NC, PCI_Device)) != NULL) {
828 unsigned char Device;
829 unsigned int IRQ_Channel;
830 unsigned long IO_Address;
832 if (pci_enable_device(PCI_Device))
835 if (pci_set_dma_mask(PCI_Device, DMA_32BIT_MASK))
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);
843 if (IO_Address == 0 || IRQ_Channel == 0)
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_dev_get(PCI_Device);
858 return PCIMultiMasterCount;
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.
869 static int __init BusLogic_InitializeFlashPointProbeInfo(struct BusLogic_HostAdapter
870 *PrototypeHostAdapter)
872 int FlashPointIndex = BusLogic_ProbeInfoCount, FlashPointCount = 0;
873 struct pci_dev *PCI_Device = NULL;
875 Interrogate PCI Configuration Space for any FlashPoint Host Adapters.
877 while ((PCI_Device = pci_get_device(PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_FLASHPOINT, PCI_Device)) != NULL) {
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;
886 if (pci_enable_device(PCI_Device))
889 if (pci_set_dma_mask(PCI_Device, DMA_32BIT_MASK))
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);
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);
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);
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);
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_dev_get(PCI_Device);
929 BusLogic_Warning("BusLogic: Too many Host Adapters " "detected\n", NULL);
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);
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.
941 BusLogic_SortProbeInfo(&BusLogic_ProbeInfoList[FlashPointIndex], FlashPointCount);
942 return FlashPointCount;
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.
959 static void __init BusLogic_InitializeProbeInfoList(struct BusLogic_HostAdapter
960 *PrototypeHostAdapter)
963 If a PCI BIOS is present, interrogate it for MultiMaster and FlashPoint
964 Host Adapters; otherwise, default to the standard ISA MultiMaster probe.
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);
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)
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));
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.
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));
1003 BusLogic_InitializeProbeInfoListISA(PrototypeHostAdapter);
1007 #endif /* CONFIG_PCI */
1011 BusLogic_Failure prints a standardized error message, and then returns false.
1014 static boolean BusLogic_Failure(struct BusLogic_HostAdapter *HostAdapter, char *ErrorMessage)
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);
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);
1030 BusLogic_ProbeHostAdapter probes for a BusLogic Host Adapter.
1033 static boolean __init BusLogic_ProbeHostAdapter(struct BusLogic_HostAdapter *HostAdapter)
1035 union BusLogic_StatusRegister StatusRegister;
1036 union BusLogic_InterruptRegister InterruptRegister;
1037 union BusLogic_GeometryRegister GeometryRegister;
1039 FlashPoint Host Adapters are Probed by the FlashPoint SCCB Manager.
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);
1052 if (BusLogic_GlobalOptions.TraceProbe)
1053 BusLogic_Notice("BusLogic_Probe(0x%X): FlashPoint Found\n", HostAdapter, HostAdapter->IO_Address);
1055 Indicate the Host Adapter Probe completed successfully.
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.
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)
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.
1087 if (GeometryRegister.All == 0xFF)
1090 Indicate the Host Adapter Probe completed successfully.
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
1104 static boolean BusLogic_HardwareResetHostAdapter(struct BusLogic_HostAdapter
1105 *HostAdapter, boolean HardReset)
1107 union BusLogic_StatusRegister StatusRegister;
1110 FlashPoint Host Adapters are Hard Reset by the FlashPoint SCCB Manager.
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)
1120 Indicate the Host Adapter Hard Reset completed successfully.
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.
1129 BusLogic_HardReset(HostAdapter);
1131 BusLogic_SoftReset(HostAdapter);
1133 Wait until Diagnostic Active is set in the Status Register.
1135 TimeoutCounter = 5 * 10000;
1136 while (--TimeoutCounter >= 0) {
1137 StatusRegister.All = BusLogic_ReadStatusRegister(HostAdapter);
1138 if (StatusRegister.sr.DiagnosticActive)
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)
1147 Wait 100 microseconds to allow completion of any initial diagnostic
1148 activity which might leave the contents of the Status Register
1153 Wait until Diagnostic Active is reset in the Status Register.
1155 TimeoutCounter = 10 * 10000;
1156 while (--TimeoutCounter >= 0) {
1157 StatusRegister.All = BusLogic_ReadStatusRegister(HostAdapter);
1158 if (!StatusRegister.sr.DiagnosticActive)
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)
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.
1170 TimeoutCounter = 10000;
1171 while (--TimeoutCounter >= 0) {
1172 StatusRegister.All = BusLogic_ReadStatusRegister(HostAdapter);
1173 if (StatusRegister.sr.DiagnosticFailure || StatusRegister.sr.HostAdapterReady || StatusRegister.sr.DataInRegisterReady)
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)
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.
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);
1197 Indicate the Host Adapter Hard Reset completed successfully.
1204 BusLogic_CheckHostAdapter checks to be sure this really is a BusLogic
1208 static boolean __init BusLogic_CheckHostAdapter(struct BusLogic_HostAdapter *HostAdapter)
1210 struct BusLogic_ExtendedSetupInformation ExtendedSetupInformation;
1211 unsigned char RequestedReplyLength;
1212 boolean Result = true;
1214 FlashPoint Host Adapters do not require this protection.
1216 if (BusLogic_FlashPointHostAdapterP(HostAdapter))
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
1224 RequestedReplyLength = sizeof(ExtendedSetupInformation);
1225 if (BusLogic_Command(HostAdapter, BusLogic_InquireExtendedSetupInformation, &RequestedReplyLength, sizeof(RequestedReplyLength), &ExtendedSetupInformation, sizeof(ExtendedSetupInformation))
1226 != sizeof(ExtendedSetupInformation))
1229 Provide tracing information if requested and return.
1231 if (BusLogic_GlobalOptions.TraceProbe)
1232 BusLogic_Notice("BusLogic_Check(0x%X): MultiMaster %s\n", HostAdapter, HostAdapter->IO_Address, (Result ? "Found" : "Not Found"));
1238 BusLogic_ReadHostAdapterConfiguration reads the Configuration Information
1239 from Host Adapter and initializes the Host Adapter structure.
1242 static boolean __init BusLogic_ReadHostAdapterConfiguration(struct BusLogic_HostAdapter
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;
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
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;
1306 Issue the Inquire Board ID command.
1308 if (BusLogic_Command(HostAdapter, BusLogic_InquireBoardID, NULL, 0, &BoardID, sizeof(BoardID)) != sizeof(BoardID))
1309 return BusLogic_Failure(HostAdapter, "INQUIRE BOARD ID");
1311 Issue the Inquire Configuration command.
1313 if (BusLogic_Command(HostAdapter, BusLogic_InquireConfiguration, NULL, 0, &Configuration, sizeof(Configuration))
1314 != sizeof(Configuration))
1315 return BusLogic_Failure(HostAdapter, "INQUIRE CONFIGURATION");
1317 Issue the Inquire Setup Information command.
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");
1324 Issue the Inquire Extended Setup Information command.
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");
1331 Issue the Inquire Firmware Version 3rd Digit command.
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");
1339 Issue the Inquire Host Adapter Model Number command.
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");
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");
1357 BusLogic MultiMaster Host Adapters can be identified by their model number
1358 and the major version number of their firmware as follows:
1360 5.xx BusLogic "W" Series Host Adapters:
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
1372 Save the Model Name and Host Adapter Name in the Host Adapter structure.
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')
1382 *TargetPointer++ = Character;
1384 *TargetPointer++ = '\0';
1386 Save the Firmware Version in the Host Adapter structure.
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';
1396 Issue the Inquire Firmware Version Letter command.
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';
1407 Save the Host Adapter SCSI ID in the Host Adapter structure.
1409 HostAdapter->SCSI_ID = Configuration.HostAdapterID;
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.
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;
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;
1439 Determine whether Extended Translation is enabled and save it in
1440 the Host Adapter structure.
1442 GeometryRegister.All = BusLogic_ReadGeometryRegister(HostAdapter);
1443 HostAdapter->ExtendedTranslationEnabled = GeometryRegister.gr.ExtendedTranslationEnabled;
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.
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;
1460 Determine whether Extended LUN Format CCBs are supported and save the
1461 information in the Host Adapter structure.
1463 if (HostAdapter->FirmwareVersion[0] == '5' || (HostAdapter->FirmwareVersion[0] == '4' && HostAdapter->HostWideSCSI))
1464 HostAdapter->ExtendedLUNSupport = true;
1466 Issue the Inquire PCI Host Adapter Information command to read the
1467 Termination Information from "W" series MultiMaster Host Adapters.
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");
1474 Save the Termination Information in the Host Adapter structure.
1476 if (PCIHostAdapterInformation.GenericInfoValid) {
1477 HostAdapter->TerminationInfoValid = true;
1478 HostAdapter->LowByteTerminated = PCIHostAdapterInformation.LowByteTerminated;
1479 HostAdapter->HighByteTerminated = PCIHostAdapterInformation.HighByteTerminated;
1483 Issue the Fetch Host Adapter Local RAM command to read the AutoSCSI data
1484 from "W" and "C" series MultiMaster Host Adapters.
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");
1493 Save the Parity Checking Enabled, Bus Reset Enabled, and Termination
1494 Information in the Host Adapter structure.
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;
1504 Save the Wide Permitted, Fast Permitted, Synchronous Permitted,
1505 Disconnect Permitted, Ultra Permitted, and SCAM Information in the
1506 Host Adapter structure.
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;
1520 Initialize fields in the Host Adapter structure for "S" and "A" series
1521 MultiMaster Host Adapters.
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;
1533 HostAdapter->DisconnectPermitted = 0xFF;
1534 HostAdapter->ParityCheckingEnabled = SetupInformation.ParityCheckingEnabled;
1535 HostAdapter->BusResetEnabled = true;
1538 Determine the maximum number of Target IDs and Logical Units supported by
1539 this driver for Wide and Narrow Host Adapters.
1541 HostAdapter->MaxTargetDevices = (HostAdapter->HostWideSCSI ? 16 : 8);
1542 HostAdapter->MaxLogicalUnits = (HostAdapter->ExtendedLUNSupport ? 32 : 8);
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.
1562 100 BT-946C/956C/956CD/747C/757C/757CD/445C
1564 30 BT-747S/747D/757S/757D/445S/545S/542D/542B/742A
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);
1571 HostAdapter->HostAdapterQueueDepth = 30;
1572 if (strcmp(HostAdapter->FirmwareVersion, "3.31") >= 0) {
1573 HostAdapter->StrictRoundRobinModeSupport = true;
1574 HostAdapter->MailboxCount = BusLogic_MaxMailboxes;
1576 HostAdapter->StrictRoundRobinModeSupport = false;
1577 HostAdapter->MailboxCount = 32;
1579 HostAdapter->DriverQueueDepth = HostAdapter->MailboxCount;
1580 HostAdapter->InitialCCBs = 4 * BusLogic_CCB_AllocationGroupSize;
1581 HostAdapter->IncrementalCCBs = BusLogic_CCB_AllocationGroupSize;
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.
1588 HostAdapter->TaggedQueuingPermitted = 0;
1589 switch (HostAdapter->FirmwareVersion[0]) {
1591 HostAdapter->TaggedQueuingPermitted = 0xFFFF;
1594 if (strcmp(HostAdapter->FirmwareVersion, "4.22") >= 0)
1595 HostAdapter->TaggedQueuingPermitted = 0xFFFF;
1598 if (strcmp(HostAdapter->FirmwareVersion, "3.35") >= 0)
1599 HostAdapter->TaggedQueuingPermitted = 0xFFFF;
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
1607 HostAdapter->BIOS_Address = ExtendedSetupInformation.BIOS_Address << 12;
1609 ISA Host Adapters require Bounce Buffers if there is more than 16MB memory.
1611 if (HostAdapter->HostAdapterBusType == BusLogic_ISA_Bus && (void *) high_memory > (void *) MAX_DMA_ADDRESS)
1612 HostAdapter->BounceBuffersRequired = true;
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.
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;
1624 Initialize parameters common to MultiMaster and FlashPoint Host Adapters.
1628 Initialize the Host Adapter Full Model Name from the Model Name.
1630 strcpy(HostAdapter->FullModelName, "BusLogic ");
1631 strcat(HostAdapter->FullModelName, HostAdapter->ModelName);
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.
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;
1647 if (HostAdapter->BounceBuffersRequired)
1648 HostAdapter->UntaggedQueueDepth = BusLogic_UntaggedQueueDepthBB;
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;
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.
1660 HostAdapter->TaggedQueuingPermitted &= HostAdapter->DisconnectPermitted;
1662 Combine the default Tagged Queuing Permitted bits with any BusLogic Driver
1663 Options Tagged Queuing specification.
1665 if (HostAdapter->DriverOptions != NULL)
1666 HostAdapter->TaggedQueuingPermitted =
1667 (HostAdapter->DriverOptions->TaggedQueuingPermitted & HostAdapter->DriverOptions->TaggedQueuingPermittedMask) | (HostAdapter->TaggedQueuingPermitted & ~HostAdapter->DriverOptions->TaggedQueuingPermittedMask);
1670 Select an appropriate value for Bus Settle Time either from a BusLogic
1671 Driver Options specification, or from BusLogic_DefaultBusSettleTime.
1673 if (HostAdapter->DriverOptions != NULL && HostAdapter->DriverOptions->BusSettleTime > 0)
1674 HostAdapter->BusSettleTime = HostAdapter->DriverOptions->BusSettleTime;
1676 HostAdapter->BusSettleTime = BusLogic_DefaultBusSettleTime;
1678 Indicate reading the Host Adapter Configuration completed successfully.
1685 BusLogic_ReportHostAdapterConfiguration reports the configuration of
1689 static boolean __init BusLogic_ReportHostAdapterConfiguration(struct BusLogic_HostAdapter
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;
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);
1715 BusLogic_Info("None, ", HostAdapter);
1716 if (HostAdapter->BIOS_Address > 0)
1717 BusLogic_Info("BIOS Address: 0x%X, ", HostAdapter, HostAdapter->BIOS_Address);
1719 BusLogic_Info("BIOS Address: None, ", HostAdapter);
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);
1725 BusLogic_Info("Unassigned, ", HostAdapter);
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;
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';
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";
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';
1771 DisconnectPermitted = HostAdapter->DisconnectPermitted & AllTargetsMask;
1772 if (DisconnectPermitted == 0)
1773 DisconnectMessage = "Disabled";
1774 else if (DisconnectPermitted == AllTargetsMask)
1775 DisconnectMessage = "Enabled";
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';
1782 TaggedQueuingPermitted = HostAdapter->TaggedQueuingPermitted & AllTargetsMask;
1783 if (TaggedQueuingPermitted == 0)
1784 TaggedQueuingMessage = "Disabled";
1785 else if (TaggedQueuingPermitted == AllTargetsMask)
1786 TaggedQueuingMessage = "Enabled";
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';
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);
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;
1807 if (CommonTaggedQueueDepth) {
1808 if (HostAdapter->QueueDepth[0] > 0)
1809 BusLogic_Info("%d", HostAdapter, HostAdapter->QueueDepth[0]);
1811 BusLogic_Info("Automatic", HostAdapter);
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")));
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")
1824 BusLogic_Info("\n", HostAdapter);
1827 Indicate reporting the Host Adapter configuration completed successfully.
1834 BusLogic_AcquireResources acquires the system resources necessary to use
1838 static boolean __init BusLogic_AcquireResources(struct BusLogic_HostAdapter *HostAdapter)
1840 if (HostAdapter->IRQ_Channel == 0) {
1841 BusLogic_Error("NO LEGAL INTERRUPT CHANNEL ASSIGNED - DETACHING\n", HostAdapter);
1845 Acquire shared access to the IRQ Channel.
1847 if (request_irq(HostAdapter->IRQ_Channel, BusLogic_InterruptHandler, IRQF_SHARED, HostAdapter->FullModelName, HostAdapter) < 0) {
1848 BusLogic_Error("UNABLE TO ACQUIRE IRQ CHANNEL %d - DETACHING\n", HostAdapter, HostAdapter->IRQ_Channel);
1851 HostAdapter->IRQ_ChannelAcquired = true;
1853 Acquire exclusive access to the DMA Channel.
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);
1860 set_dma_mode(HostAdapter->DMA_Channel, DMA_MODE_CASCADE);
1861 enable_dma(HostAdapter->DMA_Channel);
1862 HostAdapter->DMA_ChannelAcquired = true;
1865 Indicate the System Resource Acquisition completed successfully,
1872 BusLogic_ReleaseResources releases any system resources previously acquired
1873 by BusLogic_AcquireResources.
1876 static void BusLogic_ReleaseResources(struct BusLogic_HostAdapter *HostAdapter)
1879 Release shared access to the IRQ Channel.
1881 if (HostAdapter->IRQ_ChannelAcquired)
1882 free_irq(HostAdapter->IRQ_Channel, HostAdapter);
1884 Release exclusive access to the DMA Channel.
1886 if (HostAdapter->DMA_ChannelAcquired)
1887 free_dma(HostAdapter->DMA_Channel);
1889 Release any allocated memory structs not released elsewhere
1891 if (HostAdapter->MailboxSpace)
1892 pci_free_consistent(HostAdapter->PCI_Device, HostAdapter->MailboxSize, HostAdapter->MailboxSpace, HostAdapter->MailboxSpaceHandle);
1893 pci_dev_put(HostAdapter->PCI_Device);
1894 HostAdapter->MailboxSpace = NULL;
1895 HostAdapter->MailboxSpaceHandle = 0;
1896 HostAdapter->MailboxSize = 0;
1901 BusLogic_InitializeHostAdapter initializes Host Adapter. This is the only
1902 function called during SCSI Host Adapter detection which modifies the state
1903 of the Host Adapter from its initial power on or hard reset state.
1906 static boolean BusLogic_InitializeHostAdapter(struct BusLogic_HostAdapter
1909 struct BusLogic_ExtendedMailboxRequest ExtendedMailboxRequest;
1910 enum BusLogic_RoundRobinModeRequest RoundRobinModeRequest;
1911 enum BusLogic_SetCCBFormatRequest SetCCBFormatRequest;
1914 Initialize the pointers to the first and last CCBs that are queued for
1915 completion processing.
1917 HostAdapter->FirstCompletedCCB = NULL;
1918 HostAdapter->LastCompletedCCB = NULL;
1920 Initialize the Bus Device Reset Pending CCB, Tagged Queuing Active,
1921 Command Successful Flag, Active Commands, and Commands Since Reset
1922 for each Target Device.
1924 for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++) {
1925 HostAdapter->BusDeviceResetPendingCCB[TargetID] = NULL;
1926 HostAdapter->TargetFlags[TargetID].TaggedQueuingActive = false;
1927 HostAdapter->TargetFlags[TargetID].CommandSuccessfulFlag = false;
1928 HostAdapter->ActiveCommands[TargetID] = 0;
1929 HostAdapter->CommandsSinceReset[TargetID] = 0;
1932 FlashPoint Host Adapters do not use Outgoing and Incoming Mailboxes.
1934 if (BusLogic_FlashPointHostAdapterP(HostAdapter))
1937 Initialize the Outgoing and Incoming Mailbox pointers.
1939 HostAdapter->MailboxSize = HostAdapter->MailboxCount * (sizeof(struct BusLogic_OutgoingMailbox) + sizeof(struct BusLogic_IncomingMailbox));
1940 HostAdapter->MailboxSpace = pci_alloc_consistent(HostAdapter->PCI_Device, HostAdapter->MailboxSize, &HostAdapter->MailboxSpaceHandle);
1941 if (HostAdapter->MailboxSpace == NULL)
1942 return BusLogic_Failure(HostAdapter, "MAILBOX ALLOCATION");
1943 HostAdapter->FirstOutgoingMailbox = (struct BusLogic_OutgoingMailbox *) HostAdapter->MailboxSpace;
1944 HostAdapter->LastOutgoingMailbox = HostAdapter->FirstOutgoingMailbox + HostAdapter->MailboxCount - 1;
1945 HostAdapter->NextOutgoingMailbox = HostAdapter->FirstOutgoingMailbox;
1946 HostAdapter->FirstIncomingMailbox = (struct BusLogic_IncomingMailbox *) (HostAdapter->LastOutgoingMailbox + 1);
1947 HostAdapter->LastIncomingMailbox = HostAdapter->FirstIncomingMailbox + HostAdapter->MailboxCount - 1;
1948 HostAdapter->NextIncomingMailbox = HostAdapter->FirstIncomingMailbox;
1951 Initialize the Outgoing and Incoming Mailbox structures.
1953 memset(HostAdapter->FirstOutgoingMailbox, 0, HostAdapter->MailboxCount * sizeof(struct BusLogic_OutgoingMailbox));
1954 memset(HostAdapter->FirstIncomingMailbox, 0, HostAdapter->MailboxCount * sizeof(struct BusLogic_IncomingMailbox));
1956 Initialize the Host Adapter's Pointer to the Outgoing/Incoming Mailboxes.
1958 ExtendedMailboxRequest.MailboxCount = HostAdapter->MailboxCount;
1959 ExtendedMailboxRequest.BaseMailboxAddress = (u32) HostAdapter->MailboxSpaceHandle;
1960 if (BusLogic_Command(HostAdapter, BusLogic_InitializeExtendedMailbox, &ExtendedMailboxRequest, sizeof(ExtendedMailboxRequest), NULL, 0) < 0)
1961 return BusLogic_Failure(HostAdapter, "MAILBOX INITIALIZATION");
1963 Enable Strict Round Robin Mode if supported by the Host Adapter. In
1964 Strict Round Robin Mode, the Host Adapter only looks at the next Outgoing
1965 Mailbox for each new command, rather than scanning through all the
1966 Outgoing Mailboxes to find any that have new commands in them. Strict
1967 Round Robin Mode is significantly more efficient.
1969 if (HostAdapter->StrictRoundRobinModeSupport) {
1970 RoundRobinModeRequest = BusLogic_StrictRoundRobinMode;
1971 if (BusLogic_Command(HostAdapter, BusLogic_EnableStrictRoundRobinMode, &RoundRobinModeRequest, sizeof(RoundRobinModeRequest), NULL, 0) < 0)
1972 return BusLogic_Failure(HostAdapter, "ENABLE STRICT ROUND ROBIN MODE");
1975 For Host Adapters that support Extended LUN Format CCBs, issue the Set CCB
1976 Format command to allow 32 Logical Units per Target Device.
1978 if (HostAdapter->ExtendedLUNSupport) {
1979 SetCCBFormatRequest = BusLogic_ExtendedLUNFormatCCB;
1980 if (BusLogic_Command(HostAdapter, BusLogic_SetCCBFormat, &SetCCBFormatRequest, sizeof(SetCCBFormatRequest), NULL, 0) < 0)
1981 return BusLogic_Failure(HostAdapter, "SET CCB FORMAT");
1984 Announce Successful Initialization.
1987 if (!HostAdapter->HostAdapterInitialized) {
1988 BusLogic_Info("*** %s Initialized Successfully ***\n", HostAdapter, HostAdapter->FullModelName);
1989 BusLogic_Info("\n", HostAdapter);
1991 BusLogic_Warning("*** %s Initialized Successfully ***\n", HostAdapter, HostAdapter->FullModelName);
1992 HostAdapter->HostAdapterInitialized = true;
1994 Indicate the Host Adapter Initialization completed successfully.
2001 BusLogic_TargetDeviceInquiry inquires about the Target Devices accessible
2002 through Host Adapter.
2005 static boolean __init BusLogic_TargetDeviceInquiry(struct BusLogic_HostAdapter
2008 u16 InstalledDevices;
2009 u8 InstalledDevicesID0to7[8];
2010 struct BusLogic_SetupInformation SetupInformation;
2011 u8 SynchronousPeriod[BusLogic_MaxTargetDevices];
2012 unsigned char RequestedReplyLength;
2015 Wait a few seconds between the Host Adapter Hard Reset which initiates
2016 a SCSI Bus Reset and issuing any SCSI Commands. Some SCSI devices get
2017 confused if they receive SCSI Commands too soon after a SCSI Bus Reset.
2019 BusLogic_Delay(HostAdapter->BusSettleTime);
2021 FlashPoint Host Adapters do not provide for Target Device Inquiry.
2023 if (BusLogic_FlashPointHostAdapterP(HostAdapter))
2026 Inhibit the Target Device Inquiry if requested.
2028 if (HostAdapter->DriverOptions != NULL && HostAdapter->DriverOptions->LocalOptions.InhibitTargetInquiry)
2031 Issue the Inquire Target Devices command for host adapters with firmware
2032 version 4.25 or later, or the Inquire Installed Devices ID 0 to 7 command
2033 for older host adapters. This is necessary to force Synchronous Transfer
2034 Negotiation so that the Inquire Setup Information and Inquire Synchronous
2035 Period commands will return valid data. The Inquire Target Devices command
2036 is preferable to Inquire Installed Devices ID 0 to 7 since it only probes
2037 Logical Unit 0 of each Target Device.
2039 if (strcmp(HostAdapter->FirmwareVersion, "4.25") >= 0) {
2042 * Issue a Inquire Target Devices command. Inquire Target Devices only
2043 * tests Logical Unit 0 of each Target Device unlike the Inquire Installed
2044 * Devices commands which test Logical Units 0 - 7. Two bytes are
2045 * returned, where byte 0 bit 0 set indicates that Target Device 0 exists,
2049 if (BusLogic_Command(HostAdapter, BusLogic_InquireTargetDevices, NULL, 0, &InstalledDevices, sizeof(InstalledDevices))
2050 != sizeof(InstalledDevices))
2051 return BusLogic_Failure(HostAdapter, "INQUIRE TARGET DEVICES");
2052 for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++)
2053 HostAdapter->TargetFlags[TargetID].TargetExists = (InstalledDevices & (1 << TargetID) ? true : false);
2057 * Issue an Inquire Installed Devices command. For each Target Device,
2058 * a byte is returned where bit 0 set indicates that Logical Unit 0
2059 * exists, bit 1 set indicates that Logical Unit 1 exists, and so on.
2062 if (BusLogic_Command(HostAdapter, BusLogic_InquireInstalledDevicesID0to7, NULL, 0, &InstalledDevicesID0to7, sizeof(InstalledDevicesID0to7))
2063 != sizeof(InstalledDevicesID0to7))
2064 return BusLogic_Failure(HostAdapter, "INQUIRE INSTALLED DEVICES ID 0 TO 7");
2065 for (TargetID = 0; TargetID < 8; TargetID++)
2066 HostAdapter->TargetFlags[TargetID].TargetExists = (InstalledDevicesID0to7[TargetID] != 0 ? true : false);
2069 Issue the Inquire Setup Information command.
2071 RequestedReplyLength = sizeof(SetupInformation);
2072 if (BusLogic_Command(HostAdapter, BusLogic_InquireSetupInformation, &RequestedReplyLength, sizeof(RequestedReplyLength), &SetupInformation, sizeof(SetupInformation))
2073 != sizeof(SetupInformation))
2074 return BusLogic_Failure(HostAdapter, "INQUIRE SETUP INFORMATION");
2075 for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++)
2076 HostAdapter->SynchronousOffset[TargetID] = (TargetID < 8 ? SetupInformation.SynchronousValuesID0to7[TargetID].Offset : SetupInformation.SynchronousValuesID8to15[TargetID - 8].Offset);
2077 if (strcmp(HostAdapter->FirmwareVersion, "5.06L") >= 0)
2078 for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++)
2079 HostAdapter->TargetFlags[TargetID].WideTransfersActive = (TargetID < 8 ? (SetupInformation.WideTransfersActiveID0to7 & (1 << TargetID)
2081 : (SetupInformation.WideTransfersActiveID8to15 & (1 << (TargetID - 8))
2084 Issue the Inquire Synchronous Period command.
2086 if (HostAdapter->FirmwareVersion[0] >= '3') {
2088 /* Issue a Inquire Synchronous Period command. For each Target Device,
2089 * a byte is returned which represents the Synchronous Transfer Period
2090 * in units of 10 nanoseconds.
2093 RequestedReplyLength = sizeof(SynchronousPeriod);
2094 if (BusLogic_Command(HostAdapter, BusLogic_InquireSynchronousPeriod, &RequestedReplyLength, sizeof(RequestedReplyLength), &SynchronousPeriod, sizeof(SynchronousPeriod))
2095 != sizeof(SynchronousPeriod))
2096 return BusLogic_Failure(HostAdapter, "INQUIRE SYNCHRONOUS PERIOD");
2097 for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++)
2098 HostAdapter->SynchronousPeriod[TargetID] = SynchronousPeriod[TargetID];
2100 for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++)
2101 if (SetupInformation.SynchronousValuesID0to7[TargetID].Offset > 0)
2102 HostAdapter->SynchronousPeriod[TargetID] = 20 + 5 * SetupInformation.SynchronousValuesID0to7[TargetID]
2105 Indicate the Target Device Inquiry completed successfully.
2111 BusLogic_InitializeHostStructure initializes the fields in the SCSI Host
2112 structure. The base, io_port, n_io_ports, irq, and dma_channel fields in the
2113 SCSI Host structure are intentionally left uninitialized, as this driver
2114 handles acquisition and release of these resources explicitly, as well as
2115 ensuring exclusive access to the Host Adapter hardware and data structures
2116 through explicit acquisition and release of the Host Adapter's Lock.
2119 static void __init BusLogic_InitializeHostStructure(struct BusLogic_HostAdapter
2120 *HostAdapter, struct Scsi_Host *Host)
2122 Host->max_id = HostAdapter->MaxTargetDevices;
2123 Host->max_lun = HostAdapter->MaxLogicalUnits;
2124 Host->max_channel = 0;
2125 Host->unique_id = HostAdapter->IO_Address;
2126 Host->this_id = HostAdapter->SCSI_ID;
2127 Host->can_queue = HostAdapter->DriverQueueDepth;
2128 Host->sg_tablesize = HostAdapter->DriverScatterGatherLimit;
2129 Host->unchecked_isa_dma = HostAdapter->BounceBuffersRequired;
2130 Host->cmd_per_lun = HostAdapter->UntaggedQueueDepth;
2134 BusLogic_SlaveConfigure will actually set the queue depth on individual
2135 scsi devices as they are permanently added to the device chain. We
2136 shamelessly rip off the SelectQueueDepths code to make this work mostly
2137 like it used to. Since we don't get called once at the end of the scan
2138 but instead get called for each device, we have to do things a bit
2141 static int BusLogic_SlaveConfigure(struct scsi_device *Device)
2143 struct BusLogic_HostAdapter *HostAdapter = (struct BusLogic_HostAdapter *) Device->host->hostdata;
2144 int TargetID = Device->id;
2145 int QueueDepth = HostAdapter->QueueDepth[TargetID];
2147 if (HostAdapter->TargetFlags[TargetID].TaggedQueuingSupported && (HostAdapter->TaggedQueuingPermitted & (1 << TargetID))) {
2148 if (QueueDepth == 0)
2149 QueueDepth = BusLogic_MaxAutomaticTaggedQueueDepth;
2150 HostAdapter->QueueDepth[TargetID] = QueueDepth;
2151 scsi_adjust_queue_depth(Device, MSG_SIMPLE_TAG, QueueDepth);
2153 HostAdapter->TaggedQueuingPermitted &= ~(1 << TargetID);
2154 QueueDepth = HostAdapter->UntaggedQueueDepth;
2155 HostAdapter->QueueDepth[TargetID] = QueueDepth;
2156 scsi_adjust_queue_depth(Device, 0, QueueDepth);
2159 for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++)
2160 if (HostAdapter->TargetFlags[TargetID].TargetExists) {
2161 QueueDepth += HostAdapter->QueueDepth[TargetID];
2163 if (QueueDepth > HostAdapter->AllocatedCCBs)
2164 BusLogic_CreateAdditionalCCBs(HostAdapter, QueueDepth - HostAdapter->AllocatedCCBs, false);
2169 BusLogic_DetectHostAdapter probes for BusLogic Host Adapters at the standard
2170 I/O Addresses where they may be located, initializing, registering, and
2171 reporting the configuration of each BusLogic Host Adapter it finds. It
2172 returns the number of BusLogic Host Adapters successfully initialized and
2176 static int __init BusLogic_init(void)
2178 int BusLogicHostAdapterCount = 0, DriverOptionsIndex = 0, ProbeIndex;
2179 struct BusLogic_HostAdapter *PrototypeHostAdapter;
2184 BusLogic_Setup(BusLogic);
2187 if (BusLogic_ProbeOptions.NoProbe)
2189 BusLogic_ProbeInfoList = (struct BusLogic_ProbeInfo *)
2190 kmalloc(BusLogic_MaxHostAdapters * sizeof(struct BusLogic_ProbeInfo), GFP_ATOMIC);
2191 if (BusLogic_ProbeInfoList == NULL) {
2192 BusLogic_Error("BusLogic: Unable to allocate Probe Info List\n", NULL);
2195 memset(BusLogic_ProbeInfoList, 0, BusLogic_MaxHostAdapters * sizeof(struct BusLogic_ProbeInfo));
2196 PrototypeHostAdapter = (struct BusLogic_HostAdapter *)
2197 kmalloc(sizeof(struct BusLogic_HostAdapter), GFP_ATOMIC);
2198 if (PrototypeHostAdapter == NULL) {
2199 kfree(BusLogic_ProbeInfoList);
2200 BusLogic_Error("BusLogic: Unable to allocate Prototype " "Host Adapter\n", NULL);
2203 memset(PrototypeHostAdapter, 0, sizeof(struct BusLogic_HostAdapter));
2205 if (BusLogic != NULL)
2206 BusLogic_Setup(BusLogic);
2208 BusLogic_InitializeProbeInfoList(PrototypeHostAdapter);
2209 for (ProbeIndex = 0; ProbeIndex < BusLogic_ProbeInfoCount; ProbeIndex++) {
2210 struct BusLogic_ProbeInfo *ProbeInfo = &BusLogic_ProbeInfoList[ProbeIndex];
2211 struct BusLogic_HostAdapter *HostAdapter = PrototypeHostAdapter;
2212 struct Scsi_Host *Host;
2213 if (ProbeInfo->IO_Address == 0)
2215 memset(HostAdapter, 0, sizeof(struct BusLogic_HostAdapter));
2216 HostAdapter->HostAdapterType = ProbeInfo->HostAdapterType;
2217 HostAdapter->HostAdapterBusType = ProbeInfo->HostAdapterBusType;
2218 HostAdapter->IO_Address = ProbeInfo->IO_Address;
2219 HostAdapter->PCI_Address = ProbeInfo->PCI_Address;
2220 HostAdapter->Bus = ProbeInfo->Bus;
2221 HostAdapter->Device = ProbeInfo->Device;
2222 HostAdapter->PCI_Device = ProbeInfo->PCI_Device;
2223 HostAdapter->IRQ_Channel = ProbeInfo->IRQ_Channel;
2224 HostAdapter->AddressCount = BusLogic_HostAdapterAddressCount[HostAdapter->HostAdapterType];
2226 Probe the Host Adapter. If unsuccessful, abort further initialization.
2228 if (!BusLogic_ProbeHostAdapter(HostAdapter))
2231 Hard Reset the Host Adapter. If unsuccessful, abort further
2234 if (!BusLogic_HardwareResetHostAdapter(HostAdapter, true))
2237 Check the Host Adapter. If unsuccessful, abort further initialization.
2239 if (!BusLogic_CheckHostAdapter(HostAdapter))
2242 Initialize the Driver Options field if provided.
2244 if (DriverOptionsIndex < BusLogic_DriverOptionsCount)
2245 HostAdapter->DriverOptions = &BusLogic_DriverOptions[DriverOptionsIndex++];
2247 Announce the Driver Version and Date, Author's Name, Copyright Notice,
2248 and Electronic Mail Address.
2250 BusLogic_AnnounceDriver(HostAdapter);
2252 Register usage of the I/O Address range. From this point onward, any
2253 failure will be assumed to be due to a problem with the Host Adapter,
2254 rather than due to having mistakenly identified this port as belonging
2255 to a BusLogic Host Adapter. The I/O Address range will not be
2256 released, thereby preventing it from being incorrectly identified as
2257 any other type of Host Adapter.
2259 if (!request_region(HostAdapter->IO_Address, HostAdapter->AddressCount, "BusLogic"))
2262 Register the SCSI Host structure.
2265 Host = scsi_host_alloc(&Bus_Logic_template, sizeof(struct BusLogic_HostAdapter));
2267 release_region(HostAdapter->IO_Address, HostAdapter->AddressCount);
2270 HostAdapter = (struct BusLogic_HostAdapter *) Host->hostdata;
2271 memcpy(HostAdapter, PrototypeHostAdapter, sizeof(struct BusLogic_HostAdapter));
2272 HostAdapter->SCSI_Host = Host;
2273 HostAdapter->HostNumber = Host->host_no;
2275 Add Host Adapter to the end of the list of registered BusLogic
2278 list_add_tail(&HostAdapter->host_list, &BusLogic_host_list);
2281 Read the Host Adapter Configuration, Configure the Host Adapter,
2282 Acquire the System Resources necessary to use the Host Adapter, then
2283 Create the Initial CCBs, Initialize the Host Adapter, and finally
2284 perform Target Device Inquiry.
2286 if (BusLogic_ReadHostAdapterConfiguration(HostAdapter) &&
2287 BusLogic_ReportHostAdapterConfiguration(HostAdapter) &&
2288 BusLogic_AcquireResources(HostAdapter) &&
2289 BusLogic_CreateInitialCCBs(HostAdapter) &&
2290 BusLogic_InitializeHostAdapter(HostAdapter) &&
2291 BusLogic_TargetDeviceInquiry(HostAdapter)) {
2293 Initialization has been completed successfully. Release and
2294 re-register usage of the I/O Address range so that the Model
2295 Name of the Host Adapter will appear, and initialize the SCSI
2298 release_region(HostAdapter->IO_Address,
2299 HostAdapter->AddressCount);
2300 if (!request_region(HostAdapter->IO_Address,
2301 HostAdapter->AddressCount,
2302 HostAdapter->FullModelName)) {
2304 "BusLogic: Release and re-register of "
2305 "port 0x%04lx failed \n",
2306 (unsigned long)HostAdapter->IO_Address);
2307 BusLogic_DestroyCCBs(HostAdapter);
2308 BusLogic_ReleaseResources(HostAdapter);
2309 list_del(&HostAdapter->host_list);
2310 scsi_host_put(Host);
2313 BusLogic_InitializeHostStructure(HostAdapter,
2315 if (scsi_add_host(Host, HostAdapter->PCI_Device
2316 ? &HostAdapter->PCI_Device->dev
2319 "BusLogic: scsi_add_host()"
2321 BusLogic_DestroyCCBs(HostAdapter);
2322 BusLogic_ReleaseResources(HostAdapter);
2323 list_del(&HostAdapter->host_list);
2324 scsi_host_put(Host);
2327 scsi_scan_host(Host);
2328 BusLogicHostAdapterCount++;
2333 An error occurred during Host Adapter Configuration Querying, Host
2334 Adapter Configuration, Resource Acquisition, CCB Creation, Host
2335 Adapter Initialization, or Target Device Inquiry, so remove Host
2336 Adapter from the list of registered BusLogic Host Adapters, destroy
2337 the CCBs, Release the System Resources, and Unregister the SCSI
2340 BusLogic_DestroyCCBs(HostAdapter);
2341 BusLogic_ReleaseResources(HostAdapter);
2342 list_del(&HostAdapter->host_list);
2343 scsi_host_put(Host);
2347 kfree(PrototypeHostAdapter);
2348 kfree(BusLogic_ProbeInfoList);
2349 BusLogic_ProbeInfoList = NULL;
2355 BusLogic_ReleaseHostAdapter releases all resources previously acquired to
2356 support a specific Host Adapter, including the I/O Address range, and
2357 unregisters the BusLogic Host Adapter.
2360 static int __exit BusLogic_ReleaseHostAdapter(struct BusLogic_HostAdapter *HostAdapter)
2362 struct Scsi_Host *Host = HostAdapter->SCSI_Host;
2364 scsi_remove_host(Host);
2367 FlashPoint Host Adapters must first be released by the FlashPoint
2370 if (BusLogic_FlashPointHostAdapterP(HostAdapter))
2371 FlashPoint_ReleaseHostAdapter(HostAdapter->CardHandle);
2373 Destroy the CCBs and release any system resources acquired to
2374 support Host Adapter.
2376 BusLogic_DestroyCCBs(HostAdapter);
2377 BusLogic_ReleaseResources(HostAdapter);
2379 Release usage of the I/O Address range.
2381 release_region(HostAdapter->IO_Address, HostAdapter->AddressCount);
2383 Remove Host Adapter from the list of registered BusLogic Host Adapters.
2385 list_del(&HostAdapter->host_list);
2387 scsi_host_put(Host);
2393 BusLogic_QueueCompletedCCB queues CCB for completion processing.
2396 static void BusLogic_QueueCompletedCCB(struct BusLogic_CCB *CCB)
2398 struct BusLogic_HostAdapter *HostAdapter = CCB->HostAdapter;
2399 CCB->Status = BusLogic_CCB_Completed;
2401 if (HostAdapter->FirstCompletedCCB == NULL) {
2402 HostAdapter->FirstCompletedCCB = CCB;
2403 HostAdapter->LastCompletedCCB = CCB;
2405 HostAdapter->LastCompletedCCB->Next = CCB;
2406 HostAdapter->LastCompletedCCB = CCB;
2408 HostAdapter->ActiveCommands[CCB->TargetID]--;
2413 BusLogic_ComputeResultCode computes a SCSI Subsystem Result Code from
2414 the Host Adapter Status and Target Device Status.
2417 static int BusLogic_ComputeResultCode(struct BusLogic_HostAdapter *HostAdapter, enum BusLogic_HostAdapterStatus HostAdapterStatus, enum BusLogic_TargetDeviceStatus TargetDeviceStatus)
2420 switch (HostAdapterStatus) {
2421 case BusLogic_CommandCompletedNormally:
2422 case BusLogic_LinkedCommandCompleted:
2423 case BusLogic_LinkedCommandCompletedWithFlag:
2424 HostStatus = DID_OK;
2426 case BusLogic_SCSISelectionTimeout:
2427 HostStatus = DID_TIME_OUT;
2429 case BusLogic_InvalidOutgoingMailboxActionCode:
2430 case BusLogic_InvalidCommandOperationCode:
2431 case BusLogic_InvalidCommandParameter:
2432 BusLogic_Warning("BusLogic Driver Protocol Error 0x%02X\n", HostAdapter, HostAdapterStatus);
2433 case BusLogic_DataUnderRun:
2434 case BusLogic_DataOverRun:
2435 case BusLogic_UnexpectedBusFree:
2436 case BusLogic_LinkedCCBhasInvalidLUN:
2437 case BusLogic_AutoRequestSenseFailed:
2438 case BusLogic_TaggedQueuingMessageRejected:
2439 case BusLogic_UnsupportedMessageReceived:
2440 case BusLogic_HostAdapterHardwareFailed:
2441 case BusLogic_TargetDeviceReconnectedImproperly:
2442 case BusLogic_AbortQueueGenerated:
2443 case BusLogic_HostAdapterSoftwareError:
2444 case BusLogic_HostAdapterHardwareTimeoutError:
2445 case BusLogic_SCSIParityErrorDetected:
2446 HostStatus = DID_ERROR;
2448 case BusLogic_InvalidBusPhaseRequested:
2449 case BusLogic_TargetFailedResponseToATN:
2450 case BusLogic_HostAdapterAssertedRST:
2451 case BusLogic_OtherDeviceAssertedRST:
2452 case BusLogic_HostAdapterAssertedBusDeviceReset:
2453 HostStatus = DID_RESET;
2456 BusLogic_Warning("Unknown Host Adapter Status 0x%02X\n", HostAdapter, HostAdapterStatus);
2457 HostStatus = DID_ERROR;
2460 return (HostStatus << 16) | TargetDeviceStatus;
2465 BusLogic_ScanIncomingMailboxes scans the Incoming Mailboxes saving any
2466 Incoming Mailbox entries for completion processing.
2469 static void BusLogic_ScanIncomingMailboxes(struct BusLogic_HostAdapter *HostAdapter)
2472 Scan through the Incoming Mailboxes in Strict Round Robin fashion, saving
2473 any completed CCBs for further processing. It is essential that for each
2474 CCB and SCSI Command issued, command completion processing is performed
2475 exactly once. Therefore, only Incoming Mailboxes with completion code
2476 Command Completed Without Error, Command Completed With Error, or Command
2477 Aborted At Host Request are saved for completion processing. When an
2478 Incoming Mailbox has a completion code of Aborted Command Not Found, the
2479 CCB had already completed or been aborted before the current Abort request
2480 was processed, and so completion processing has already occurred and no
2481 further action should be taken.
2483 struct BusLogic_IncomingMailbox *NextIncomingMailbox = HostAdapter->NextIncomingMailbox;
2484 enum BusLogic_CompletionCode CompletionCode;
2485 while ((CompletionCode = NextIncomingMailbox->CompletionCode) != BusLogic_IncomingMailboxFree) {
2487 We are only allowed to do this because we limit our architectures we
2488 run on to machines where bus_to_virt() actually works. There *needs*
2489 to be a dma_addr_to_virt() in the new PCI DMA mapping interface to
2490 replace bus_to_virt() or else this code is going to become very
2493 struct BusLogic_CCB *CCB = (struct BusLogic_CCB *) Bus_to_Virtual(NextIncomingMailbox->CCB);
2494 if (CompletionCode != BusLogic_AbortedCommandNotFound) {
2495 if (CCB->Status == BusLogic_CCB_Active || CCB->Status == BusLogic_CCB_Reset) {
2497 Save the Completion Code for this CCB and queue the CCB
2498 for completion processing.
2500 CCB->CompletionCode = CompletionCode;
2501 BusLogic_QueueCompletedCCB(CCB);
2504 If a CCB ever appears in an Incoming Mailbox and is not marked
2505 as status Active or Reset, then there is most likely a bug in
2506 the Host Adapter firmware.
2508 BusLogic_Warning("Illegal CCB #%ld status %d in " "Incoming Mailbox\n", HostAdapter, CCB->SerialNumber, CCB->Status);
2511 NextIncomingMailbox->CompletionCode = BusLogic_IncomingMailboxFree;
2512 if (++NextIncomingMailbox > HostAdapter->LastIncomingMailbox)
2513 NextIncomingMailbox = HostAdapter->FirstIncomingMailbox;
2515 HostAdapter->NextIncomingMailbox = NextIncomingMailbox;
2520 BusLogic_ProcessCompletedCCBs iterates over the completed CCBs for Host
2521 Adapter setting the SCSI Command Result Codes, deallocating the CCBs, and
2522 calling the SCSI Subsystem Completion Routines. The Host Adapter's Lock
2523 should already have been acquired by the caller.
2526 static void BusLogic_ProcessCompletedCCBs(struct BusLogic_HostAdapter *HostAdapter)
2528 if (HostAdapter->ProcessCompletedCCBsActive)
2530 HostAdapter->ProcessCompletedCCBsActive = true;
2531 while (HostAdapter->FirstCompletedCCB != NULL) {
2532 struct BusLogic_CCB *CCB = HostAdapter->FirstCompletedCCB;
2533 struct scsi_cmnd *Command = CCB->Command;
2534 HostAdapter->FirstCompletedCCB = CCB->Next;
2535 if (HostAdapter->FirstCompletedCCB == NULL)
2536 HostAdapter->LastCompletedCCB = NULL;
2538 Process the Completed CCB.
2540 if (CCB->Opcode == BusLogic_BusDeviceReset) {
2541 int TargetID = CCB->TargetID;
2542 BusLogic_Warning("Bus Device Reset CCB #%ld to Target " "%d Completed\n", HostAdapter, CCB->SerialNumber, TargetID);
2543 BusLogic_IncrementErrorCounter(&HostAdapter->TargetStatistics[TargetID].BusDeviceResetsCompleted);
2544 HostAdapter->TargetFlags[TargetID].TaggedQueuingActive = false;
2545 HostAdapter->CommandsSinceReset[TargetID] = 0;
2546 HostAdapter->LastResetCompleted[TargetID] = jiffies;
2548 Place CCB back on the Host Adapter's free list.
2550 BusLogic_DeallocateCCB(CCB);
2551 #if 0 /* this needs to be redone different for new EH */
2553 Bus Device Reset CCBs have the Command field non-NULL only when a
2554 Bus Device Reset was requested for a Command that did not have a
2555 currently active CCB in the Host Adapter (i.e., a Synchronous
2556 Bus Device Reset), and hence would not have its Completion Routine
2559 while (Command != NULL) {
2560 struct scsi_cmnd *NextCommand = Command->reset_chain;
2561 Command->reset_chain = NULL;
2562 Command->result = DID_RESET << 16;
2563 Command->scsi_done(Command);
2564 Command = NextCommand;
2568 Iterate over the CCBs for this Host Adapter performing completion
2569 processing for any CCBs marked as Reset for this Target.
2571 for (CCB = HostAdapter->All_CCBs; CCB != NULL; CCB = CCB->NextAll)
2572 if (CCB->Status == BusLogic_CCB_Reset && CCB->TargetID == TargetID) {
2573 Command = CCB->Command;
2574 BusLogic_DeallocateCCB(CCB);
2575 HostAdapter->ActiveCommands[TargetID]--;
2576 Command->result = DID_RESET << 16;
2577 Command->scsi_done(Command);
2579 HostAdapter->BusDeviceResetPendingCCB[TargetID] = NULL;
2582 Translate the Completion Code, Host Adapter Status, and Target
2583 Device Status into a SCSI Subsystem Result Code.
2585 switch (CCB->CompletionCode) {
2586 case BusLogic_IncomingMailboxFree:
2587 case BusLogic_AbortedCommandNotFound:
2588 case BusLogic_InvalidCCB:
2589 BusLogic_Warning("CCB #%ld to Target %d Impossible State\n", HostAdapter, CCB->SerialNumber, CCB->TargetID);
2591 case BusLogic_CommandCompletedWithoutError:
2592 HostAdapter->TargetStatistics[CCB->TargetID]
2593 .CommandsCompleted++;
2594 HostAdapter->TargetFlags[CCB->TargetID]
2595 .CommandSuccessfulFlag = true;
2596 Command->result = DID_OK << 16;
2598 case BusLogic_CommandAbortedAtHostRequest:
2599 BusLogic_Warning("CCB #%ld to Target %d Aborted\n", HostAdapter, CCB->SerialNumber, CCB->TargetID);
2600 BusLogic_IncrementErrorCounter(&HostAdapter->TargetStatistics[CCB->TargetID]
2601 .CommandAbortsCompleted);
2602 Command->result = DID_ABORT << 16;
2604 case BusLogic_CommandCompletedWithError:
2605 Command->result = BusLogic_ComputeResultCode(HostAdapter, CCB->HostAdapterStatus, CCB->TargetDeviceStatus);
2606 if (CCB->HostAdapterStatus != BusLogic_SCSISelectionTimeout) {
2607 HostAdapter->TargetStatistics[CCB->TargetID]
2608 .CommandsCompleted++;
2609 if (BusLogic_GlobalOptions.TraceErrors) {
2611 BusLogic_Notice("CCB #%ld Target %d: Result %X Host "
2612 "Adapter Status %02X " "Target Status %02X\n", HostAdapter, CCB->SerialNumber, CCB->TargetID, Command->result, CCB->HostAdapterStatus, CCB->TargetDeviceStatus);
2613 BusLogic_Notice("CDB ", HostAdapter);
2614 for (i = 0; i < CCB->CDB_Length; i++)
2615 BusLogic_Notice(" %02X", HostAdapter, CCB->CDB[i]);
2616 BusLogic_Notice("\n", HostAdapter);
2617 BusLogic_Notice("Sense ", HostAdapter);
2618 for (i = 0; i < CCB->SenseDataLength; i++)
2619 BusLogic_Notice(" %02X", HostAdapter, Command->sense_buffer[i]);
2620 BusLogic_Notice("\n", HostAdapter);
2626 When an INQUIRY command completes normally, save the
2627 CmdQue (Tagged Queuing Supported) and WBus16 (16 Bit
2628 Wide Data Transfers Supported) bits.
2630 if (CCB->CDB[0] == INQUIRY && CCB->CDB[1] == 0 && CCB->HostAdapterStatus == BusLogic_CommandCompletedNormally) {
2631 struct BusLogic_TargetFlags *TargetFlags = &HostAdapter->TargetFlags[CCB->TargetID];
2632 struct SCSI_Inquiry *InquiryResult = (struct SCSI_Inquiry *) Command->request_buffer;
2633 TargetFlags->TargetExists = true;
2634 TargetFlags->TaggedQueuingSupported = InquiryResult->CmdQue;
2635 TargetFlags->WideTransfersSupported = InquiryResult->WBus16;
2638 Place CCB back on the Host Adapter's free list.
2640 BusLogic_DeallocateCCB(CCB);
2642 Call the SCSI Command Completion Routine.
2644 Command->scsi_done(Command);
2647 HostAdapter->ProcessCompletedCCBsActive = false;
2652 BusLogic_InterruptHandler handles hardware interrupts from BusLogic Host
2656 static irqreturn_t BusLogic_InterruptHandler(int IRQ_Channel, void *DeviceIdentifier)
2658 struct BusLogic_HostAdapter *HostAdapter = (struct BusLogic_HostAdapter *) DeviceIdentifier;
2659 unsigned long ProcessorFlags;
2661 Acquire exclusive access to Host Adapter.
2663 spin_lock_irqsave(HostAdapter->SCSI_Host->host_lock, ProcessorFlags);
2665 Handle Interrupts appropriately for each Host Adapter type.
2667 if (BusLogic_MultiMasterHostAdapterP(HostAdapter)) {
2668 union BusLogic_InterruptRegister InterruptRegister;
2670 Read the Host Adapter Interrupt Register.
2672 InterruptRegister.All = BusLogic_ReadInterruptRegister(HostAdapter);
2673 if (InterruptRegister.ir.InterruptValid) {
2675 Acknowledge the interrupt and reset the Host Adapter
2678 BusLogic_InterruptReset(HostAdapter);
2680 Process valid External SCSI Bus Reset and Incoming Mailbox
2681 Loaded Interrupts. Command Complete Interrupts are noted,
2682 and Outgoing Mailbox Available Interrupts are ignored, as
2683 they are never enabled.
2685 if (InterruptRegister.ir.ExternalBusReset)
2686 HostAdapter->HostAdapterExternalReset = true;
2687 else if (InterruptRegister.ir.IncomingMailboxLoaded)
2688 BusLogic_ScanIncomingMailboxes(HostAdapter);
2689 else if (InterruptRegister.ir.CommandComplete)
2690 HostAdapter->HostAdapterCommandCompleted = true;
2694 Check if there is a pending interrupt for this Host Adapter.
2696 if (FlashPoint_InterruptPending(HostAdapter->CardHandle))
2697 switch (FlashPoint_HandleInterrupt(HostAdapter->CardHandle)) {
2698 case FlashPoint_NormalInterrupt:
2700 case FlashPoint_ExternalBusReset:
2701 HostAdapter->HostAdapterExternalReset = true;
2703 case FlashPoint_InternalError:
2704 BusLogic_Warning("Internal FlashPoint Error detected" " - Resetting Host Adapter\n", HostAdapter);
2705 HostAdapter->HostAdapterInternalError = true;
2710 Process any completed CCBs.
2712 if (HostAdapter->FirstCompletedCCB != NULL)
2713 BusLogic_ProcessCompletedCCBs(HostAdapter);
2715 Reset the Host Adapter if requested.
2717 if (HostAdapter->HostAdapterExternalReset) {
2718 BusLogic_Warning("Resetting %s due to External SCSI Bus Reset\n", HostAdapter, HostAdapter->FullModelName);
2719 BusLogic_IncrementErrorCounter(&HostAdapter->ExternalHostAdapterResets);
2720 BusLogic_ResetHostAdapter(HostAdapter, false);
2721 HostAdapter->HostAdapterExternalReset = false;
2722 } else if (HostAdapter->HostAdapterInternalError) {
2723 BusLogic_Warning("Resetting %s due to Host Adapter Internal Error\n", HostAdapter, HostAdapter->FullModelName);
2724 BusLogic_IncrementErrorCounter(&HostAdapter->HostAdapterInternalErrors);
2725 BusLogic_ResetHostAdapter(HostAdapter, true);
2726 HostAdapter->HostAdapterInternalError = false;
2729 Release exclusive access to Host Adapter.
2731 spin_unlock_irqrestore(HostAdapter->SCSI_Host->host_lock, ProcessorFlags);
2737 BusLogic_WriteOutgoingMailbox places CCB and Action Code into an Outgoing
2738 Mailbox for execution by Host Adapter. The Host Adapter's Lock should
2739 already have been acquired by the caller.
2742 static boolean BusLogic_WriteOutgoingMailbox(struct BusLogic_HostAdapter
2743 *HostAdapter, enum BusLogic_ActionCode ActionCode, struct BusLogic_CCB *CCB)
2745 struct BusLogic_OutgoingMailbox *NextOutgoingMailbox;
2746 NextOutgoingMailbox = HostAdapter->NextOutgoingMailbox;
2747 if (NextOutgoingMailbox->ActionCode == BusLogic_OutgoingMailboxFree) {
2748 CCB->Status = BusLogic_CCB_Active;
2750 The CCB field must be written before the Action Code field since
2751 the Host Adapter is operating asynchronously and the locking code
2752 does not protect against simultaneous access by the Host Adapter.
2754 NextOutgoingMailbox->CCB = CCB->DMA_Handle;
2755 NextOutgoingMailbox->ActionCode = ActionCode;
2756 BusLogic_StartMailboxCommand(HostAdapter);
2757 if (++NextOutgoingMailbox > HostAdapter->LastOutgoingMailbox)
2758 NextOutgoingMailbox = HostAdapter->FirstOutgoingMailbox;
2759 HostAdapter->NextOutgoingMailbox = NextOutgoingMailbox;
2760 if (ActionCode == BusLogic_MailboxStartCommand) {
2761 HostAdapter->ActiveCommands[CCB->TargetID]++;
2762 if (CCB->Opcode != BusLogic_BusDeviceReset)
2763 HostAdapter->TargetStatistics[CCB->TargetID].CommandsAttempted++;
2770 /* Error Handling (EH) support */
2772 static int BusLogic_host_reset(struct scsi_cmnd * SCpnt)
2774 struct BusLogic_HostAdapter *HostAdapter = (struct BusLogic_HostAdapter *) SCpnt->device->host->hostdata;
2776 unsigned int id = SCpnt->device->id;
2777 struct BusLogic_TargetStatistics *stats = &HostAdapter->TargetStatistics[id];
2780 spin_lock_irq(SCpnt->device->host->host_lock);
2782 BusLogic_IncrementErrorCounter(&stats->HostAdapterResetsRequested);
2784 rc = BusLogic_ResetHostAdapter(HostAdapter, false);
2785 spin_unlock_irq(SCpnt->device->host->host_lock);
2790 BusLogic_QueueCommand creates a CCB for Command and places it into an
2791 Outgoing Mailbox for execution by the associated Host Adapter.
2794 static int BusLogic_QueueCommand(struct scsi_cmnd *Command, void (*CompletionRoutine) (struct scsi_cmnd *))
2796 struct BusLogic_HostAdapter *HostAdapter = (struct BusLogic_HostAdapter *) Command->device->host->hostdata;
2797 struct BusLogic_TargetFlags *TargetFlags = &HostAdapter->TargetFlags[Command->device->id];
2798 struct BusLogic_TargetStatistics *TargetStatistics = HostAdapter->TargetStatistics;
2799 unsigned char *CDB = Command->cmnd;
2800 int CDB_Length = Command->cmd_len;
2801 int TargetID = Command->device->id;
2802 int LogicalUnit = Command->device->lun;
2803 void *BufferPointer = Command->request_buffer;
2804 int BufferLength = Command->request_bufflen;
2805 int SegmentCount = Command->use_sg;
2806 struct BusLogic_CCB *CCB;
2808 SCSI REQUEST_SENSE commands will be executed automatically by the Host
2809 Adapter for any errors, so they should not be executed explicitly unless
2810 the Sense Data is zero indicating that no error occurred.
2812 if (CDB[0] == REQUEST_SENSE && Command->sense_buffer[0] != 0) {
2813 Command->result = DID_OK << 16;
2814 CompletionRoutine(Command);
2818 Allocate a CCB from the Host Adapter's free list. In the unlikely event
2819 that there are none available and memory allocation fails, wait 1 second
2820 and try again. If that fails, the Host Adapter is probably hung so signal
2821 an error as a Host Adapter Hard Reset should be initiated soon.
2823 CCB = BusLogic_AllocateCCB(HostAdapter);
2825 spin_unlock_irq(HostAdapter->SCSI_Host->host_lock);
2827 spin_lock_irq(HostAdapter->SCSI_Host->host_lock);
2828 CCB = BusLogic_AllocateCCB(HostAdapter);
2830 Command->result = DID_ERROR << 16;
2831 CompletionRoutine(Command);
2836 Initialize the fields in the BusLogic Command Control Block (CCB).
2838 if (SegmentCount == 0 && BufferLength != 0) {
2839 CCB->Opcode = BusLogic_InitiatorCCB;
2840 CCB->DataLength = BufferLength;
2841 CCB->DataPointer = pci_map_single(HostAdapter->PCI_Device,
2842 BufferPointer, BufferLength,
2843 Command->sc_data_direction);
2844 } else if (SegmentCount != 0) {
2845 struct scatterlist *ScatterList = (struct scatterlist *) BufferPointer;
2848 Count = pci_map_sg(HostAdapter->PCI_Device, ScatterList, SegmentCount,
2849 Command->sc_data_direction);
2850 CCB->Opcode = BusLogic_InitiatorCCB_ScatterGather;
2851 CCB->DataLength = Count * sizeof(struct BusLogic_ScatterGatherSegment);
2852 if (BusLogic_MultiMasterHostAdapterP(HostAdapter))
2853 CCB->DataPointer = (unsigned int) CCB->DMA_Handle + ((unsigned long) &CCB->ScatterGatherList - (unsigned long) CCB);
2855 CCB->DataPointer = Virtual_to_32Bit_Virtual(CCB->ScatterGatherList);
2856 for (Segment = 0; Segment < Count; Segment++) {
2857 CCB->ScatterGatherList[Segment].SegmentByteCount = sg_dma_len(ScatterList + Segment);
2858 CCB->ScatterGatherList[Segment].SegmentDataPointer = sg_dma_address(ScatterList + Segment);
2861 CCB->Opcode = BusLogic_InitiatorCCB;
2862 CCB->DataLength = BufferLength;
2863 CCB->DataPointer = 0;
2868 CCB->DataDirection = BusLogic_DataInLengthChecked;
2869 TargetStatistics[TargetID].ReadCommands++;
2870 BusLogic_IncrementByteCounter(&TargetStatistics[TargetID].TotalBytesRead, BufferLength);
2871 BusLogic_IncrementSizeBucket(TargetStatistics[TargetID].ReadCommandSizeBuckets, BufferLength);
2875 CCB->DataDirection = BusLogic_DataOutLengthChecked;
2876 TargetStatistics[TargetID].WriteCommands++;
2877 BusLogic_IncrementByteCounter(&TargetStatistics[TargetID].TotalBytesWritten, BufferLength);
2878 BusLogic_IncrementSizeBucket(TargetStatistics[TargetID].WriteCommandSizeBuckets, BufferLength);
2881 CCB->DataDirection = BusLogic_UncheckedDataTransfer;
2884 CCB->CDB_Length = CDB_Length;
2885 CCB->HostAdapterStatus = 0;
2886 CCB->TargetDeviceStatus = 0;
2887 CCB->TargetID = TargetID;
2888 CCB->LogicalUnit = LogicalUnit;
2889 CCB->TagEnable = false;
2890 CCB->LegacyTagEnable = false;
2892 BusLogic recommends that after a Reset the first couple of commands that
2893 are sent to a Target Device be sent in a non Tagged Queue fashion so that
2894 the Host Adapter and Target Device can establish Synchronous and Wide
2895 Transfer before Queue Tag messages can interfere with the Synchronous and
2896 Wide Negotiation messages. By waiting to enable Tagged Queuing until after
2897 the first BusLogic_MaxTaggedQueueDepth commands have been queued, it is
2898 assured that after a Reset any pending commands are requeued before Tagged
2899 Queuing is enabled and that the Tagged Queuing message will not occur while
2900 the partition table is being printed. In addition, some devices do not
2901 properly handle the transition from non-tagged to tagged commands, so it is
2902 necessary to wait until there are no pending commands for a target device
2903 before queuing tagged commands.
2905 if (HostAdapter->CommandsSinceReset[TargetID]++ >=
2906 BusLogic_MaxTaggedQueueDepth && !TargetFlags->TaggedQueuingActive && HostAdapter->ActiveCommands[TargetID] == 0 && TargetFlags->TaggedQueuingSupported && (HostAdapter->TaggedQueuingPermitted & (1 << TargetID))) {
2907 TargetFlags->TaggedQueuingActive = true;
2908 BusLogic_Notice("Tagged Queuing now active for Target %d\n", HostAdapter, TargetID);
2910 if (TargetFlags->TaggedQueuingActive) {
2911 enum BusLogic_QueueTag QueueTag = BusLogic_SimpleQueueTag;
2913 When using Tagged Queuing with Simple Queue Tags, it appears that disk
2914 drive controllers do not guarantee that a queued command will not
2915 remain in a disconnected state indefinitely if commands that read or
2916 write nearer the head position continue to arrive without interruption.
2917 Therefore, for each Target Device this driver keeps track of the last
2918 time either the queue was empty or an Ordered Queue Tag was issued. If
2919 more than 4 seconds (one fifth of the 20 second disk timeout) have
2920 elapsed since this last sequence point, this command will be issued
2921 with an Ordered Queue Tag rather than a Simple Queue Tag, which forces
2922 the Target Device to complete all previously queued commands before
2923 this command may be executed.
2925 if (HostAdapter->ActiveCommands[TargetID] == 0)
2926 HostAdapter->LastSequencePoint[TargetID] = jiffies;
2927 else if (time_after(jiffies, HostAdapter->LastSequencePoint[TargetID] + 4 * HZ)) {
2928 HostAdapter->LastSequencePoint[TargetID] = jiffies;
2929 QueueTag = BusLogic_OrderedQueueTag;
2931 if (HostAdapter->ExtendedLUNSupport) {
2932 CCB->TagEnable = true;
2933 CCB->QueueTag = QueueTag;
2935 CCB->LegacyTagEnable = true;
2936 CCB->LegacyQueueTag = QueueTag;
2939 memcpy(CCB->CDB, CDB, CDB_Length);
2940 CCB->SenseDataLength = sizeof(Command->sense_buffer);
2941 CCB->SenseDataPointer = pci_map_single(HostAdapter->PCI_Device, Command->sense_buffer, CCB->SenseDataLength, PCI_DMA_FROMDEVICE);
2942 CCB->Command = Command;
2943 Command->scsi_done = CompletionRoutine;
2944 if (BusLogic_MultiMasterHostAdapterP(HostAdapter)) {
2946 Place the CCB in an Outgoing Mailbox. The higher levels of the SCSI
2947 Subsystem should not attempt to queue more commands than can be placed
2948 in Outgoing Mailboxes, so there should always be one free. In the
2949 unlikely event that there are none available, wait 1 second and try
2950 again. If that fails, the Host Adapter is probably hung so signal an
2951 error as a Host Adapter Hard Reset should be initiated soon.
2953 if (!BusLogic_WriteOutgoingMailbox(HostAdapter, BusLogic_MailboxStartCommand, CCB)) {
2954 spin_unlock_irq(HostAdapter->SCSI_Host->host_lock);
2955 BusLogic_Warning("Unable to write Outgoing Mailbox - " "Pausing for 1 second\n", HostAdapter);
2957 spin_lock_irq(HostAdapter->SCSI_Host->host_lock);
2958 if (!BusLogic_WriteOutgoingMailbox(HostAdapter, BusLogic_MailboxStartCommand, CCB)) {
2959 BusLogic_Warning("Still unable to write Outgoing Mailbox - " "Host Adapter Dead?\n", HostAdapter);
2960 BusLogic_DeallocateCCB(CCB);
2961 Command->result = DID_ERROR << 16;
2962 Command->scsi_done(Command);
2967 Call the FlashPoint SCCB Manager to start execution of the CCB.
2969 CCB->Status = BusLogic_CCB_Active;
2970 HostAdapter->ActiveCommands[TargetID]++;
2971 TargetStatistics[TargetID].CommandsAttempted++;
2972 FlashPoint_StartCCB(HostAdapter->CardHandle, CCB);
2974 The Command may have already completed and BusLogic_QueueCompletedCCB
2975 been called, or it may still be pending.
2977 if (CCB->Status == BusLogic_CCB_Completed)
2978 BusLogic_ProcessCompletedCCBs(HostAdapter);
2986 BusLogic_AbortCommand aborts Command if possible.
2989 static int BusLogic_AbortCommand(struct scsi_cmnd *Command)
2991 struct BusLogic_HostAdapter *HostAdapter = (struct BusLogic_HostAdapter *) Command->device->host->hostdata;
2993 int TargetID = Command->device->id;
2994 struct BusLogic_CCB *CCB;
2995 BusLogic_IncrementErrorCounter(&HostAdapter->TargetStatistics[TargetID].CommandAbortsRequested);
2997 Attempt to find an Active CCB for this Command. If no Active CCB for this
2998 Command is found, then no Abort is necessary.
3000 for (CCB = HostAdapter->All_CCBs; CCB != NULL; CCB = CCB->NextAll)
3001 if (CCB->Command == Command)
3004 BusLogic_Warning("Unable to Abort Command to Target %d - " "No CCB Found\n", HostAdapter, TargetID);
3006 } else if (CCB->Status == BusLogic_CCB_Completed) {
3007 BusLogic_Warning("Unable to Abort Command to Target %d - " "CCB Completed\n", HostAdapter, TargetID);
3009 } else if (CCB->Status == BusLogic_CCB_Reset) {
3010 BusLogic_Warning("Unable to Abort Command to Target %d - " "CCB Reset\n", HostAdapter, TargetID);
3013 if (BusLogic_MultiMasterHostAdapterP(HostAdapter)) {
3015 Attempt to Abort this CCB. MultiMaster Firmware versions prior to 5.xx
3016 do not generate Abort Tag messages, but only generate the non-tagged
3017 Abort message. Since non-tagged commands are not sent by the Host
3018 Adapter until the queue of outstanding tagged commands has completed,
3019 and the Abort message is treated as a non-tagged command, it is
3020 effectively impossible to abort commands when Tagged Queuing is active.
3021 Firmware version 5.xx does generate Abort Tag messages, so it is
3022 possible to abort commands when Tagged Queuing is active.
3024 if (HostAdapter->TargetFlags[TargetID].TaggedQueuingActive && HostAdapter->FirmwareVersion[0] < '5') {
3025 BusLogic_Warning("Unable to Abort CCB #%ld to Target %d - " "Abort Tag Not Supported\n", HostAdapter, CCB->SerialNumber, TargetID);
3027 } else if (BusLogic_WriteOutgoingMailbox(HostAdapter, BusLogic_MailboxAbortCommand, CCB)) {
3028 BusLogic_Warning("Aborting CCB #%ld to Target %d\n", HostAdapter, CCB->SerialNumber, TargetID);
3029 BusLogic_IncrementErrorCounter(&HostAdapter->TargetStatistics[TargetID].CommandAbortsAttempted);
3032 BusLogic_Warning("Unable to Abort CCB #%ld to Target %d - " "No Outgoing Mailboxes\n", HostAdapter, CCB->SerialNumber, TargetID);
3037 Call the FlashPoint SCCB Manager to abort execution of the CCB.
3039 BusLogic_Warning("Aborting CCB #%ld to Target %d\n", HostAdapter, CCB->SerialNumber, TargetID);
3040 BusLogic_IncrementErrorCounter(&HostAdapter->TargetStatistics[TargetID].CommandAbortsAttempted);
3041 FlashPoint_AbortCCB(HostAdapter->CardHandle, CCB);
3043 The Abort may have already been completed and
3044 BusLogic_QueueCompletedCCB been called, or it
3045 may still be pending.
3047 if (CCB->Status == BusLogic_CCB_Completed) {
3048 BusLogic_ProcessCompletedCCBs(HostAdapter);
3057 BusLogic_ResetHostAdapter resets Host Adapter if possible, marking all
3058 currently executing SCSI Commands as having been Reset.
3061 static int BusLogic_ResetHostAdapter(struct BusLogic_HostAdapter *HostAdapter, boolean HardReset)
3063 struct BusLogic_CCB *CCB;
3067 * Attempt to Reset and Reinitialize the Host Adapter.
3070 if (!(BusLogic_HardwareResetHostAdapter(HostAdapter, HardReset) && BusLogic_InitializeHostAdapter(HostAdapter))) {
3071 BusLogic_Error("Resetting %s Failed\n", HostAdapter, HostAdapter->FullModelName);
3076 * Deallocate all currently executing CCBs.
3079 for (CCB = HostAdapter->All_CCBs; CCB != NULL; CCB = CCB->NextAll)
3080 if (CCB->Status == BusLogic_CCB_Active)
3081 BusLogic_DeallocateCCB(CCB);
3083 * Wait a few seconds between the Host Adapter Hard Reset which
3084 * initiates a SCSI Bus Reset and issuing any SCSI Commands. Some
3085 * SCSI devices get confused if they receive SCSI Commands too soon
3086 * after a SCSI Bus Reset.
3090 spin_unlock_irq(HostAdapter->SCSI_Host->host_lock);
3091 BusLogic_Delay(HostAdapter->BusSettleTime);
3092 spin_lock_irq(HostAdapter->SCSI_Host->host_lock);
3095 for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++) {
3096 HostAdapter->LastResetAttempted[TargetID] = jiffies;
3097 HostAdapter->LastResetCompleted[TargetID] = jiffies;
3103 BusLogic_BIOSDiskParameters returns the Heads/Sectors/Cylinders BIOS Disk
3104 Parameters for Disk. The default disk geometry is 64 heads, 32 sectors, and
3105 the appropriate number of cylinders so as not to exceed drive capacity. In
3106 order for disks equal to or larger than 1 GB to be addressable by the BIOS
3107 without exceeding the BIOS limitation of 1024 cylinders, Extended Translation
3108 may be enabled in AutoSCSI on FlashPoint Host Adapters and on "W" and "C"
3109 series MultiMaster Host Adapters, or by a dip switch setting on "S" and "A"
3110 series MultiMaster Host Adapters. With Extended Translation enabled, drives
3111 between 1 GB inclusive and 2 GB exclusive are given a disk geometry of 128
3112 heads and 32 sectors, and drives above 2 GB inclusive are given a disk
3113 geometry of 255 heads and 63 sectors. However, if the BIOS detects that the
3114 Extended Translation setting does not match the geometry in the partition
3115 table, then the translation inferred from the partition table will be used by
3116 the BIOS, and a warning may be displayed.
3119 static int BusLogic_BIOSDiskParameters(struct scsi_device *sdev, struct block_device *Device, sector_t capacity, int *Parameters)
3121 struct BusLogic_HostAdapter *HostAdapter = (struct BusLogic_HostAdapter *) sdev->host->hostdata;
3122 struct BIOS_DiskParameters *DiskParameters = (struct BIOS_DiskParameters *) Parameters;
3124 if (HostAdapter->ExtendedTranslationEnabled && capacity >= 2 * 1024 * 1024 /* 1 GB in 512 byte sectors */ ) {
3125 if (capacity >= 4 * 1024 * 1024 /* 2 GB in 512 byte sectors */ ) {
3126 DiskParameters->Heads = 255;
3127 DiskParameters->Sectors = 63;
3129 DiskParameters->Heads = 128;
3130 DiskParameters->Sectors = 32;
3133 DiskParameters->Heads = 64;
3134 DiskParameters->Sectors = 32;
3136 DiskParameters->Cylinders = (unsigned long) capacity / (DiskParameters->Heads * DiskParameters->Sectors);
3137 buf = scsi_bios_ptable(Device);
3141 If the boot sector partition table flag is valid, search for a partition
3142 table entry whose end_head matches one of the standard BusLogic geometry
3143 translations (64/32, 128/32, or 255/63).
3145 if (*(unsigned short *) (buf + 64) == 0xAA55) {
3146 struct partition *FirstPartitionEntry = (struct partition *) buf;
3147 struct partition *PartitionEntry = FirstPartitionEntry;
3148 int SavedCylinders = DiskParameters->Cylinders, PartitionNumber;
3149 unsigned char PartitionEntryEndHead = 0, PartitionEntryEndSector = 0;
3150 for (PartitionNumber = 0; PartitionNumber < 4; PartitionNumber++) {
3151 PartitionEntryEndHead = PartitionEntry->end_head;
3152 PartitionEntryEndSector = PartitionEntry->end_sector & 0x3F;
3153 if (PartitionEntryEndHead == 64 - 1) {
3154 DiskParameters->Heads = 64;
3155 DiskParameters->Sectors = 32;
3157 } else if (PartitionEntryEndHead == 128 - 1) {
3158 DiskParameters->Heads = 128;
3159 DiskParameters->Sectors = 32;
3161 } else if (PartitionEntryEndHead == 255 - 1) {
3162 DiskParameters->Heads = 255;
3163 DiskParameters->Sectors = 63;
3168 if (PartitionNumber == 4) {
3169 PartitionEntryEndHead = FirstPartitionEntry->end_head;
3170 PartitionEntryEndSector = FirstPartitionEntry->end_sector & 0x3F;
3172 DiskParameters->Cylinders = (unsigned long) capacity / (DiskParameters->Heads * DiskParameters->Sectors);
3173 if (PartitionNumber < 4 && PartitionEntryEndSector == DiskParameters->Sectors) {
3174 if (DiskParameters->Cylinders != SavedCylinders)
3175 BusLogic_Warning("Adopting Geometry %d/%d from Partition Table\n", HostAdapter, DiskParameters->Heads, DiskParameters->Sectors);
3176 } else if (PartitionEntryEndHead > 0 || PartitionEntryEndSector > 0) {
3177 BusLogic_Warning("Warning: Partition Table appears to " "have Geometry %d/%d which is\n", HostAdapter, PartitionEntryEndHead + 1, PartitionEntryEndSector);
3178 BusLogic_Warning("not compatible with current BusLogic " "Host Adapter Geometry %d/%d\n", HostAdapter, DiskParameters->Heads, DiskParameters->Sectors);
3187 BugLogic_ProcDirectoryInfo implements /proc/scsi/BusLogic/<N>.
3190 static int BusLogic_ProcDirectoryInfo(struct Scsi_Host *shost, char *ProcBuffer, char **StartPointer, off_t Offset, int BytesAvailable, int WriteFlag)
3192 struct BusLogic_HostAdapter *HostAdapter = (struct BusLogic_HostAdapter *) shost->hostdata;
3193 struct BusLogic_TargetStatistics *TargetStatistics;
3194 int TargetID, Length;
3197 TargetStatistics = HostAdapter->TargetStatistics;
3199 HostAdapter->ExternalHostAdapterResets = 0;
3200 HostAdapter->HostAdapterInternalErrors = 0;
3201 memset(TargetStatistics, 0, BusLogic_MaxTargetDevices * sizeof(struct BusLogic_TargetStatistics));
3204 Buffer = HostAdapter->MessageBuffer;
3205 Length = HostAdapter->MessageBufferLength;
3206 Length += sprintf(&Buffer[Length], "\n\
3207 Current Driver Queue Depth: %d\n\
3208 Currently Allocated CCBs: %d\n", HostAdapter->DriverQueueDepth, HostAdapter->AllocatedCCBs);
3209 Length += sprintf(&Buffer[Length], "\n\n\
3210 DATA TRANSFER STATISTICS\n\
3212 Target Tagged Queuing Queue Depth Active Attempted Completed\n\
3213 ====== ============== =========== ====== ========= =========\n");
3214 for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++) {
3215 struct BusLogic_TargetFlags *TargetFlags = &HostAdapter->TargetFlags[TargetID];
3216 if (!TargetFlags->TargetExists)
3218 Length += sprintf(&Buffer[Length], " %2d %s", TargetID, (TargetFlags->TaggedQueuingSupported ? (TargetFlags->TaggedQueuingActive ? " Active" : (HostAdapter->TaggedQueuingPermitted & (1 << TargetID)
3219 ? " Permitted" : " Disabled"))
3220 : "Not Supported"));
3221 Length += sprintf(&Buffer[Length],
3222 " %3d %3u %9u %9u\n", HostAdapter->QueueDepth[TargetID], HostAdapter->ActiveCommands[TargetID], TargetStatistics[TargetID].CommandsAttempted, TargetStatistics[TargetID].CommandsCompleted);
3224 Length += sprintf(&Buffer[Length], "\n\
3225 Target Read Commands Write Commands Total Bytes Read Total Bytes Written\n\
3226 ====== ============= ============== =================== ===================\n");
3227 for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++) {
3228 struct BusLogic_TargetFlags *TargetFlags = &HostAdapter->TargetFlags[TargetID];
3229 if (!TargetFlags->TargetExists)
3231 Length += sprintf(&Buffer[Length], " %2d %9u %9u", TargetID, TargetStatistics[TargetID].ReadCommands, TargetStatistics[TargetID].WriteCommands);
3232 if (TargetStatistics[TargetID].TotalBytesRead.Billions > 0)
3233 Length += sprintf(&Buffer[Length], " %9u%09u", TargetStatistics[TargetID].TotalBytesRead.Billions, TargetStatistics[TargetID].TotalBytesRead.Units);
3235 Length += sprintf(&Buffer[Length], " %9u", TargetStatistics[TargetID].TotalBytesRead.Units);
3236 if (TargetStatistics[TargetID].TotalBytesWritten.Billions > 0)
3237 Length += sprintf(&Buffer[Length], " %9u%09u\n", TargetStatistics[TargetID].TotalBytesWritten.Billions, TargetStatistics[TargetID].TotalBytesWritten.Units);
3239 Length += sprintf(&Buffer[Length], " %9u\n", TargetStatistics[TargetID].TotalBytesWritten.Units);
3241 Length += sprintf(&Buffer[Length], "\n\
3242 Target Command 0-1KB 1-2KB 2-4KB 4-8KB 8-16KB\n\
3243 ====== ======= ========= ========= ========= ========= =========\n");
3244 for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++) {
3245 struct BusLogic_TargetFlags *TargetFlags = &HostAdapter->TargetFlags[TargetID];
3246 if (!TargetFlags->TargetExists)
3249 sprintf(&Buffer[Length],
3250 " %2d Read %9u %9u %9u %9u %9u\n", TargetID,
3251 TargetStatistics[TargetID].ReadCommandSizeBuckets[0],
3252 TargetStatistics[TargetID].ReadCommandSizeBuckets[1], TargetStatistics[TargetID].ReadCommandSizeBuckets[2], TargetStatistics[TargetID].ReadCommandSizeBuckets[3], TargetStatistics[TargetID].ReadCommandSizeBuckets[4]);
3254 sprintf(&Buffer[Length],
3255 " %2d Write %9u %9u %9u %9u %9u\n", TargetID,
3256 TargetStatistics[TargetID].WriteCommandSizeBuckets[0],
3257 TargetStatistics[TargetID].WriteCommandSizeBuckets[1], TargetStatistics[TargetID].WriteCommandSizeBuckets[2], TargetStatistics[TargetID].WriteCommandSizeBuckets[3], TargetStatistics[TargetID].WriteCommandSizeBuckets[4]);
3259 Length += sprintf(&Buffer[Length], "\n\
3260 Target Command 16-32KB 32-64KB 64-128KB 128-256KB 256KB+\n\
3261 ====== ======= ========= ========= ========= ========= =========\n");
3262 for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++) {
3263 struct BusLogic_TargetFlags *TargetFlags = &HostAdapter->TargetFlags[TargetID];
3264 if (!TargetFlags->TargetExists)
3267 sprintf(&Buffer[Length],
3268 " %2d Read %9u %9u %9u %9u %9u\n", TargetID,
3269 TargetStatistics[TargetID].ReadCommandSizeBuckets[5],
3270 TargetStatistics[TargetID].ReadCommandSizeBuckets[6], TargetStatistics[TargetID].ReadCommandSizeBuckets[7], TargetStatistics[TargetID].ReadCommandSizeBuckets[8], TargetStatistics[TargetID].ReadCommandSizeBuckets[9]);
3272 sprintf(&Buffer[Length],
3273 " %2d Write %9u %9u %9u %9u %9u\n", TargetID,
3274 TargetStatistics[TargetID].WriteCommandSizeBuckets[5],
3275 TargetStatistics[TargetID].WriteCommandSizeBuckets[6], TargetStatistics[TargetID].WriteCommandSizeBuckets[7], TargetStatistics[TargetID].WriteCommandSizeBuckets[8], TargetStatistics[TargetID].WriteCommandSizeBuckets[9]);
3277 Length += sprintf(&Buffer[Length], "\n\n\
3278 ERROR RECOVERY STATISTICS\n\
3280 Command Aborts Bus Device Resets Host Adapter Resets\n\
3281 Target Requested Completed Requested Completed Requested Completed\n\
3282 ID \\\\\\\\ Attempted //// \\\\\\\\ Attempted //// \\\\\\\\ Attempted ////\n\
3283 ====== ===== ===== ===== ===== ===== ===== ===== ===== =====\n");
3284 for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++) {
3285 struct BusLogic_TargetFlags *TargetFlags = &HostAdapter->TargetFlags[TargetID];
3286 if (!TargetFlags->TargetExists)
3288 Length += sprintf(&Buffer[Length], "\
3289 %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);
3291 Length += sprintf(&Buffer[Length], "\nExternal Host Adapter Resets: %d\n", HostAdapter->ExternalHostAdapterResets);
3292 Length += sprintf(&Buffer[Length], "Host Adapter Internal Errors: %d\n", HostAdapter->HostAdapterInternalErrors);
3293 if (Length >= BusLogic_MessageBufferSize)
3294 BusLogic_Error("Message Buffer length %d exceeds size %d\n", HostAdapter, Length, BusLogic_MessageBufferSize);
3295 if ((Length -= Offset) <= 0)
3297 if (Length >= BytesAvailable)
3298 Length = BytesAvailable;
3299 memcpy(ProcBuffer, HostAdapter->MessageBuffer + Offset, Length);
3300 *StartPointer = ProcBuffer;
3306 BusLogic_Message prints Driver Messages.
3309 static void BusLogic_Message(enum BusLogic_MessageLevel MessageLevel, char *Format, struct BusLogic_HostAdapter *HostAdapter, ...)
3311 static char Buffer[BusLogic_LineBufferSize];
3312 static boolean BeginningOfLine = true;
3315 va_start(Arguments, HostAdapter);
3316 Length = vsprintf(Buffer, Format, Arguments);
3318 if (MessageLevel == BusLogic_AnnounceLevel) {
3319 static int AnnouncementLines = 0;
3320 strcpy(&HostAdapter->MessageBuffer[HostAdapter->MessageBufferLength], Buffer);
3321 HostAdapter->MessageBufferLength += Length;
3322 if (++AnnouncementLines <= 2)
3323 printk("%sscsi: %s", BusLogic_MessageLevelMap[MessageLevel], Buffer);
3324 } else if (MessageLevel == BusLogic_InfoLevel) {
3325 strcpy(&HostAdapter->MessageBuffer[HostAdapter->MessageBufferLength], Buffer);
3326 HostAdapter->MessageBufferLength += Length;
3327 if (BeginningOfLine) {
3328 if (Buffer[0] != '\n' || Length > 1)
3329 printk("%sscsi%d: %s", BusLogic_MessageLevelMap[MessageLevel], HostAdapter->HostNumber, Buffer);
3331 printk("%s", Buffer);
3333 if (BeginningOfLine) {
3334 if (HostAdapter != NULL && HostAdapter->HostAdapterInitialized)
3335 printk("%sscsi%d: %s", BusLogic_MessageLevelMap[MessageLevel], HostAdapter->HostNumber, Buffer);
3337 printk("%s%s", BusLogic_MessageLevelMap[MessageLevel], Buffer);
3339 printk("%s", Buffer);
3341 BeginningOfLine = (Buffer[Length - 1] == '\n');
3346 BusLogic_ParseKeyword parses an individual option keyword. It returns true
3347 and updates the pointer if the keyword is recognized and false otherwise.
3350 static boolean __init BusLogic_ParseKeyword(char **StringPointer, char *Keyword)
3352 char *Pointer = *StringPointer;
3353 while (*Keyword != '\0') {
3354 char StringChar = *Pointer++;
3355 char KeywordChar = *Keyword++;
3356 if (StringChar >= 'A' && StringChar <= 'Z')
3357 StringChar += 'a' - 'Z';
3358 if (KeywordChar >= 'A' && KeywordChar <= 'Z')
3359 KeywordChar += 'a' - 'Z';
3360 if (StringChar != KeywordChar)
3363 *StringPointer = Pointer;
3369 BusLogic_ParseDriverOptions handles processing of BusLogic Driver Options
3372 BusLogic Driver Options may be specified either via the Linux Kernel Command
3373 Line or via the Loadable Kernel Module Installation Facility. Driver Options
3374 for multiple host adapters may be specified either by separating the option
3375 strings by a semicolon, or by specifying multiple "BusLogic=" strings on the
3376 command line. Individual option specifications for a single host adapter are
3377 separated by commas. The Probing and Debugging Options apply to all host
3378 adapters whereas the remaining options apply individually only to the
3379 selected host adapter.
3381 The BusLogic Driver Probing Options are described in
3382 <file:Documentation/scsi/BusLogic.txt>.
3385 static int __init BusLogic_ParseDriverOptions(char *OptionsString)
3388 struct BusLogic_DriverOptions *DriverOptions = &BusLogic_DriverOptions[BusLogic_DriverOptionsCount++];
3390 memset(DriverOptions, 0, sizeof(struct BusLogic_DriverOptions));
3391 while (*OptionsString != '\0' && *OptionsString != ';') {
3392 /* Probing Options. */
3393 if (BusLogic_ParseKeyword(&OptionsString, "IO:")) {
3394 unsigned long IO_Address = simple_strtoul(OptionsString, &OptionsString, 0);
3395 BusLogic_ProbeOptions.LimitedProbeISA = true;
3396 switch (IO_Address) {
3398 BusLogic_ProbeOptions.Probe330 = true;
3401 BusLogic_ProbeOptions.Probe334 = true;
3404 BusLogic_ProbeOptions.Probe230 = true;
3407 BusLogic_ProbeOptions.Probe234 = true;
3410 BusLogic_ProbeOptions.Probe130 = true;
3413 BusLogic_ProbeOptions.Probe134 = true;
3416 BusLogic_Error("BusLogic: Invalid Driver Options " "(invalid I/O Address 0x%X)\n", NULL, IO_Address);
3419 } else if (BusLogic_ParseKeyword(&OptionsString, "NoProbeISA"))
3420 BusLogic_ProbeOptions.NoProbeISA = true;
3421 else if (BusLogic_ParseKeyword(&OptionsString, "NoProbePCI"))
3422 BusLogic_ProbeOptions.NoProbePCI = true;
3423 else if (BusLogic_ParseKeyword(&OptionsString, "NoProbe"))
3424 BusLogic_ProbeOptions.NoProbe = true;
3425 else if (BusLogic_ParseKeyword(&OptionsString, "NoSortPCI"))
3426 BusLogic_ProbeOptions.NoSortPCI = true;
3427 else if (BusLogic_ParseKeyword(&OptionsString, "MultiMasterFirst"))
3428 BusLogic_ProbeOptions.MultiMasterFirst = true;
3429 else if (BusLogic_ParseKeyword(&OptionsString, "FlashPointFirst"))
3430 BusLogic_ProbeOptions.FlashPointFirst = true;
3431 /* Tagged Queuing Options. */
3432 else if (BusLogic_ParseKeyword(&OptionsString, "QueueDepth:[") || BusLogic_ParseKeyword(&OptionsString, "QD:[")) {
3433 for (TargetID = 0; TargetID < BusLogic_MaxTargetDevices; TargetID++) {
3434 unsigned short QueueDepth = simple_strtoul(OptionsString, &OptionsString, 0);
3435 if (QueueDepth > BusLogic_MaxTaggedQueueDepth) {
3436 BusLogic_Error("BusLogic: Invalid Driver Options " "(invalid Queue Depth %d)\n", NULL, QueueDepth);
3439 DriverOptions->QueueDepth[TargetID] = QueueDepth;
3440 if (*OptionsString == ',')
3442 else if (*OptionsString == ']')
3445 BusLogic_Error("BusLogic: Invalid Driver Options " "(',' or ']' expected at '%s')\n", NULL, OptionsString);
3449 if (*OptionsString != ']') {
3450 BusLogic_Error("BusLogic: Invalid Driver Options " "(']' expected at '%s')\n", NULL, OptionsString);
3454 } else if (BusLogic_ParseKeyword(&OptionsString, "QueueDepth:") || BusLogic_ParseKeyword(&OptionsString, "QD:")) {
3455 unsigned short QueueDepth = simple_strtoul(OptionsString, &OptionsString, 0);
3456 if (QueueDepth == 0 || QueueDepth > BusLogic_MaxTaggedQueueDepth) {
3457 BusLogic_Error("BusLogic: Invalid Driver Options " "(invalid Queue Depth %d)\n", NULL, QueueDepth);
3460 DriverOptions->CommonQueueDepth = QueueDepth;
3461 for (TargetID = 0; TargetID < BusLogic_MaxTargetDevices; TargetID++)
3462 DriverOptions->QueueDepth[TargetID] = QueueDepth;
3463 } else if (BusLogic_ParseKeyword(&OptionsString, "TaggedQueuing:") || BusLogic_ParseKeyword(&OptionsString, "TQ:")) {
3464 if (BusLogic_ParseKeyword(&OptionsString, "Default")) {
3465 DriverOptions->TaggedQueuingPermitted = 0x0000;
3466 DriverOptions->TaggedQueuingPermittedMask = 0x0000;
3467 } else if (BusLogic_ParseKeyword(&OptionsString, "Enable")) {
3468 DriverOptions->TaggedQueuingPermitted = 0xFFFF;
3469 DriverOptions->TaggedQueuingPermittedMask = 0xFFFF;
3470 } else if (BusLogic_ParseKeyword(&OptionsString, "Disable")) {
3471 DriverOptions->TaggedQueuingPermitted = 0x0000;
3472 DriverOptions->TaggedQueuingPermittedMask = 0xFFFF;
3474 unsigned short TargetBit;
3475 for (TargetID = 0, TargetBit = 1; TargetID < BusLogic_MaxTargetDevices; TargetID++, TargetBit <<= 1)
3476 switch (*OptionsString++) {
3478 DriverOptions->TaggedQueuingPermitted |= TargetBit;
3479 DriverOptions->TaggedQueuingPermittedMask |= TargetBit;
3482 DriverOptions->TaggedQueuingPermitted &= ~TargetBit;
3483 DriverOptions->TaggedQueuingPermittedMask |= TargetBit;
3489 TargetID = BusLogic_MaxTargetDevices;
3494 /* Miscellaneous Options. */
3495 else if (BusLogic_ParseKeyword(&OptionsString, "BusSettleTime:") || BusLogic_ParseKeyword(&OptionsString, "BST:")) {
3496 unsigned short BusSettleTime = simple_strtoul(OptionsString, &OptionsString, 0);
3497 if (BusSettleTime > 5 * 60) {
3498 BusLogic_Error("BusLogic: Invalid Driver Options " "(invalid Bus Settle Time %d)\n", NULL, BusSettleTime);
3501 DriverOptions->BusSettleTime = BusSettleTime;
3502 } else if (BusLogic_ParseKeyword(&OptionsString, "InhibitTargetInquiry"))
3503 DriverOptions->LocalOptions.InhibitTargetInquiry = true;
3504 /* Debugging Options. */
3505 else if (BusLogic_ParseKeyword(&OptionsString, "TraceProbe"))
3506 BusLogic_GlobalOptions.TraceProbe = true;
3507 else if (BusLogic_ParseKeyword(&OptionsString, "TraceHardwareReset"))
3508 BusLogic_GlobalOptions.TraceHardwareReset = true;
3509 else if (BusLogic_ParseKeyword(&OptionsString, "TraceConfiguration"))
3510 BusLogic_GlobalOptions.TraceConfiguration = true;
3511 else if (BusLogic_ParseKeyword(&OptionsString, "TraceErrors"))
3512 BusLogic_GlobalOptions.TraceErrors = true;
3513 else if (BusLogic_ParseKeyword(&OptionsString, "Debug")) {
3514 BusLogic_GlobalOptions.TraceProbe = true;
3515 BusLogic_GlobalOptions.TraceHardwareReset = true;
3516 BusLogic_GlobalOptions.TraceConfiguration = true;
3517 BusLogic_GlobalOptions.TraceErrors = true;
3519 if (*OptionsString == ',')
3521 else if (*OptionsString != ';' && *OptionsString != '\0') {
3522 BusLogic_Error("BusLogic: Unexpected Driver Option '%s' " "ignored\n", NULL, OptionsString);
3523 *OptionsString = '\0';
3526 if (!(BusLogic_DriverOptionsCount == 0 || BusLogic_ProbeInfoCount == 0 || BusLogic_DriverOptionsCount == BusLogic_ProbeInfoCount)) {
3527 BusLogic_Error("BusLogic: Invalid Driver Options " "(all or no I/O Addresses must be specified)\n", NULL);
3531 Tagged Queuing is disabled when the Queue Depth is 1 since queuing
3532 multiple commands is not possible.
3534 for (TargetID = 0; TargetID < BusLogic_MaxTargetDevices; TargetID++)
3535 if (DriverOptions->QueueDepth[TargetID] == 1) {
3536 unsigned short TargetBit = 1 << TargetID;
3537 DriverOptions->TaggedQueuingPermitted &= ~TargetBit;
3538 DriverOptions->TaggedQueuingPermittedMask |= TargetBit;
3540 if (*OptionsString == ';')
3542 if (*OptionsString == '\0')
3552 static struct scsi_host_template Bus_Logic_template = {
3553 .module = THIS_MODULE,
3554 .proc_name = "BusLogic",
3555 .proc_info = BusLogic_ProcDirectoryInfo,
3557 .info = BusLogic_DriverInfo,
3558 .queuecommand = BusLogic_QueueCommand,
3559 .slave_configure = BusLogic_SlaveConfigure,
3560 .bios_param = BusLogic_BIOSDiskParameters,
3561 .eh_host_reset_handler = BusLogic_host_reset,
3563 .eh_abort_handler = BusLogic_AbortCommand,
3565 .unchecked_isa_dma = 1,
3567 .use_clustering = ENABLE_CLUSTERING,
3571 BusLogic_Setup handles processing of Kernel Command Line Arguments.
3574 static int __init BusLogic_Setup(char *str)
3578 (void) get_options(str, ARRAY_SIZE(ints), ints);
3581 BusLogic_Error("BusLogic: Obsolete Command Line Entry " "Format Ignored\n", NULL);
3584 if (str == NULL || *str == '\0')
3586 return BusLogic_ParseDriverOptions(str);
3590 * Exit function. Deletes all hosts associated with this driver.
3593 static void __exit BusLogic_exit(void)
3595 struct BusLogic_HostAdapter *ha, *next;
3597 list_for_each_entry_safe(ha, next, &BusLogic_host_list, host_list)
3598 BusLogic_ReleaseHostAdapter(ha);
3601 __setup("BusLogic=", BusLogic_Setup);
3603 static struct pci_device_id BusLogic_pci_tbl[] __devinitdata = {
3604 { PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER,
3605 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
3606 { PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER_NC,
3607 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
3608 { PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_FLASHPOINT,
3609 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
3612 MODULE_DEVICE_TABLE(pci, BusLogic_pci_tbl);
3614 module_init(BusLogic_init);
3615 module_exit(BusLogic_exit);