cregit-Linux how code gets into the kernel

Release 4.11 drivers/scsi/BusLogic.c

Directory: drivers/scsi
/*

  Linux Driver for BusLogic MultiMaster and FlashPoint SCSI Host Adapters

  Copyright 1995-1998 by Leonard N. Zubkoff <lnz@dandelion.com>

  This program is free software; you may redistribute and/or modify it under
  the terms of the GNU General Public License Version 2 as published by the
  Free Software Foundation.

  This program is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  for complete details.

  The author respectfully requests that any modifications to this software be
  sent directly to him for evaluation and testing.

  Special thanks to Wayne Yen, Jin-Lon Hon, and Alex Win of BusLogic, whose
  advice has been invaluable, to David Gentzel, for writing the original Linux
  BusLogic driver, and to Paul Gortmaker, for being such a dedicated test site.

  Finally, special thanks to Mylex/BusLogic for making the FlashPoint SCCB
  Manager available as freely redistributable source code.

*/


#define blogic_drvr_version		"2.1.17"

#define blogic_drvr_date		"12 September 2013"

#include <linux/module.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/types.h>
#include <linux/blkdev.h>
#include <linux/delay.h>
#include <linux/ioport.h>
#include <linux/mm.h>
#include <linux/stat.h>
#include <linux/pci.h>
#include <linux/spinlock.h>
#include <linux/jiffies.h>
#include <linux/dma-mapping.h>
#include <linux/slab.h>
#include <scsi/scsicam.h>

#include <asm/dma.h>
#include <asm/io.h>

#include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h>
#include <scsi/scsi_device.h>
#include <scsi/scsi_host.h>
#include <scsi/scsi_tcq.h>
#include "BusLogic.h"
#include "FlashPoint.c"

#ifndef FAILURE

#define FAILURE (-1)
#endif


static struct scsi_host_template blogic_template;

/*
  blogic_drvr_options_count is a count of the number of BusLogic Driver
  Options specifications provided via the Linux Kernel Command Line or via
  the Loadable Kernel Module Installation Facility.
*/


static int blogic_drvr_options_count;


/*
  blogic_drvr_options is an array of Driver Options structures representing
  BusLogic Driver Options specifications provided via the Linux Kernel Command
  Line or via the Loadable Kernel Module Installation Facility.
*/


static struct blogic_drvr_options blogic_drvr_options[BLOGIC_MAX_ADAPTERS];


/*
  BusLogic can be assigned a string by insmod.
*/

MODULE_LICENSE("GPL");
#ifdef MODULE

static char *BusLogic;
module_param(BusLogic, charp, 0);
#endif


/*
  blogic_probe_options is a set of Probe Options to be applied across
  all BusLogic Host Adapters.
*/


static struct blogic_probe_options blogic_probe_options;


/*
  blogic_global_options is a set of Global Options to be applied across
  all BusLogic Host Adapters.
*/


static struct blogic_global_options blogic_global_options;

static LIST_HEAD(blogic_host_list);

/*
  blogic_probeinfo_count is the number of entries in blogic_probeinfo_list.
*/


static int blogic_probeinfo_count;


/*
  blogic_probeinfo_list is the list of I/O Addresses and Bus Probe Information
  to be checked for potential BusLogic Host Adapters.  It is initialized by
  interrogating the PCI Configuration Space on PCI machines as well as from the
  list of standard BusLogic I/O Addresses.
*/


static struct blogic_probeinfo *blogic_probeinfo_list;


/*
  blogic_cmd_failure_reason holds a string identifying the reason why a
  call to blogic_cmd failed.  It is only non-NULL when blogic_cmd
  returns a failure code.
*/


static char *blogic_cmd_failure_reason;

/*
  blogic_announce_drvr announces the Driver Version and Date, Author's
  Name, Copyright Notice, and Electronic Mail Address.
*/


static void blogic_announce_drvr(struct blogic_adapter *adapter) { blogic_announce("***** BusLogic SCSI Driver Version " blogic_drvr_version " of " blogic_drvr_date " *****\n", adapter); blogic_announce("Copyright 1995-1998 by Leonard N. Zubkoff " "<lnz@dandelion.com>\n", adapter); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)2066.67%360.00%
Khalid Aziz930.00%120.00%
James Bottomley13.33%120.00%
Total30100.00%5100.00%

/* blogic_drvr_info returns the Host Adapter Name to identify this SCSI Driver and Host Adapter. */
static const char *blogic_drvr_info(struct Scsi_Host *host) { struct blogic_adapter *adapter = (struct blogic_adapter *) host->hostdata; return adapter->full_model; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)1959.38%133.33%
Khalid Aziz825.00%133.33%
James Bottomley515.62%133.33%
Total32100.00%3100.00%

/* blogic_init_ccbs initializes a group of Command Control Blocks (CCBs) for Host Adapter from the blk_size bytes located at blk_pointer. The newly created CCBs are added to Host Adapter's free list. */
static void blogic_init_ccbs(struct blogic_adapter *adapter, void *blk_pointer, int blk_size, dma_addr_t blkp) { struct blogic_ccb *ccb = (struct blogic_ccb *) blk_pointer; unsigned int offset = 0; memset(blk_pointer, 0, blk_size); ccb->allocgrp_head = blkp; ccb->allocgrp_size = blk_size; while ((blk_size -= sizeof(struct blogic_ccb)) >= 0) { ccb->status = BLOGIC_CCB_FREE; ccb->adapter = adapter; ccb->dma_handle = (u32) blkp + offset; if (blogic_flashpoint_type(adapter)) { ccb->callback = blogic_qcompleted_ccb; ccb->base_addr = adapter->fpinfo.base_addr; } ccb->next = adapter->free_ccbs; ccb->next_all = adapter->all_ccbs; adapter->free_ccbs = ccb; adapter->all_ccbs = ccb; adapter->alloc_ccbs++; ccb++; offset += sizeof(struct blogic_ccb); } }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)8148.21%666.67%
Khalid Aziz5733.93%111.11%
Doug Ledford2414.29%111.11%
James Bottomley63.57%111.11%
Total168100.00%9100.00%

/* blogic_create_initccbs allocates the initial CCBs for Host Adapter. */
static bool __init blogic_create_initccbs(struct blogic_adapter *adapter) { int blk_size = BLOGIC_CCB_GRP_ALLOCSIZE * sizeof(struct blogic_ccb); void *blk_pointer; dma_addr_t blkp; while (adapter->alloc_ccbs < adapter->initccbs) { blk_pointer = pci_alloc_consistent(adapter->pci_device, blk_size, &blkp); if (blk_pointer == NULL) { blogic_err("UNABLE TO ALLOCATE CCB GROUP - DETACHING\n", adapter); return false; } blogic_init_ccbs(adapter, blk_pointer, blk_size, blkp); } return true; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)4753.41%450.00%
Khalid Aziz2528.41%112.50%
Doug Ledford1213.64%112.50%
James Bottomley33.41%112.50%
Richard Knutsson11.14%112.50%
Total88100.00%8100.00%

/* blogic_destroy_ccbs deallocates the CCBs for Host Adapter. */
static void blogic_destroy_ccbs(struct blogic_adapter *adapter) { struct blogic_ccb *next_ccb = adapter->all_ccbs, *ccb, *lastccb = NULL; adapter->all_ccbs = NULL; adapter->free_ccbs = NULL; while ((ccb = next_ccb) != NULL) { next_ccb = ccb->next_all; if (ccb->allocgrp_head) { if (lastccb) pci_free_consistent(adapter->pci_device, lastccb->allocgrp_size, lastccb, lastccb->allocgrp_head); lastccb = ccb; } } if (lastccb) pci_free_consistent(adapter->pci_device, lastccb->allocgrp_size, lastccb, lastccb->allocgrp_head); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)4136.61%240.00%
Khalid Aziz3833.93%120.00%
Doug Ledford3127.68%120.00%
James Bottomley21.79%120.00%
Total112100.00%5100.00%

/* blogic_create_addlccbs allocates Additional CCBs for Host Adapter. If allocation fails and there are no remaining CCBs available, the Driver Queue Depth is decreased to a known safe value to avoid potential deadlocks when multiple host adapters share the same IRQ Channel. */
static void blogic_create_addlccbs(struct blogic_adapter *adapter, int addl_ccbs, bool print_success) { int blk_size = BLOGIC_CCB_GRP_ALLOCSIZE * sizeof(struct blogic_ccb); int prev_alloc = adapter->alloc_ccbs; void *blk_pointer; dma_addr_t blkp; if (addl_ccbs <= 0) return; while (adapter->alloc_ccbs - prev_alloc < addl_ccbs) { blk_pointer = pci_alloc_consistent(adapter->pci_device, blk_size, &blkp); if (blk_pointer == NULL) break; blogic_init_ccbs(adapter, blk_pointer, blk_size, blkp); } if (adapter->alloc_ccbs > prev_alloc) { if (print_success) blogic_notice("Allocated %d additional CCBs (total now %d)\n", adapter, adapter->alloc_ccbs - prev_alloc, adapter->alloc_ccbs); return; } blogic_notice("Failed to allocate additional CCBs\n", adapter); if (adapter->drvr_qdepth > adapter->alloc_ccbs - adapter->tgt_count) { adapter->drvr_qdepth = adapter->alloc_ccbs - adapter->tgt_count; adapter->scsi_host->can_queue = adapter->drvr_qdepth; } }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)9757.06%233.33%
Khalid Aziz5834.12%116.67%
Doug Ledford127.06%116.67%
James Bottomley21.18%116.67%
Richard Knutsson10.59%116.67%
Total170100.00%6100.00%

/* blogic_alloc_ccb allocates a CCB from Host Adapter's free list, allocating more memory from the Kernel if necessary. The Host Adapter's Lock should already have been acquired by the caller. */
static struct blogic_ccb *blogic_alloc_ccb(struct blogic_adapter *adapter) { static unsigned long serial; struct blogic_ccb *ccb; ccb = adapter->free_ccbs; if (ccb != NULL) { ccb->serial = ++serial; adapter->free_ccbs = ccb->next; ccb->next = NULL; if (adapter->free_ccbs == NULL) blogic_create_addlccbs(adapter, adapter->inc_ccbs, true); return ccb; } blogic_create_addlccbs(adapter, adapter->inc_ccbs, true); ccb = adapter->free_ccbs; if (ccb == NULL) return NULL; ccb->serial = ++serial; adapter->free_ccbs = ccb->next; ccb->next = NULL; return ccb; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)8263.08%675.00%
Khalid Aziz4534.62%112.50%
James Bottomley32.31%112.50%
Total130100.00%8100.00%

/* blogic_dealloc_ccb deallocates a CCB, returning it to the Host Adapter's free list. The Host Adapter's Lock should already have been acquired by the caller. */
static void blogic_dealloc_ccb(struct blogic_ccb *ccb, int dma_unmap) { struct blogic_adapter *adapter = ccb->adapter; if (ccb->command != NULL) scsi_dma_unmap(ccb->command); if (dma_unmap) pci_unmap_single(adapter->pci_device, ccb->sensedata, ccb->sense_datalen, PCI_DMA_FROMDEVICE); ccb->command = NULL; ccb->status = BLOGIC_CCB_FREE; ccb->next = adapter->free_ccbs; adapter->free_ccbs = ccb; }

Contributors

PersonTokensPropCommitsCommitProp
Khalid Aziz4249.41%233.33%
Linus Torvalds (pre-git)2529.41%116.67%
Doug Ledford1517.65%116.67%
James Bottomley22.35%116.67%
FUJITA Tomonori11.18%116.67%
Total85100.00%6100.00%

/* blogic_cmd sends the command opcode to adapter, optionally providing paramlen bytes of param and receiving at most replylen bytes of reply; any excess reply data is received but discarded. On success, this function returns the number of reply bytes read from the Host Adapter (including any discarded data); on failure, it returns -1 if the command was invalid, or -2 if a timeout occurred. blogic_cmd is called exclusively during host adapter detection and initialization, so performance and latency are not critical, and exclusive access to the Host Adapter hardware is assumed. Once the host adapter and driver are initialized, the only Host Adapter command that is issued is the single byte Execute Mailbox Command operation code, which does not require waiting for the Host Adapter Ready bit to be set in the Status Register. */
static int blogic_cmd(struct blogic_adapter *adapter, enum blogic_opcode opcode, void *param, int paramlen, void *reply, int replylen) { unsigned char *param_p = (unsigned char *) param; unsigned char *reply_p = (unsigned char *) reply; union blogic_stat_reg statusreg; union blogic_int_reg intreg; unsigned long processor_flag = 0; int reply_b = 0, result; long timeout; /* Clear out the Reply Data if provided. */ if (replylen > 0) memset(reply, 0, replylen); /* If the IRQ Channel has not yet been acquired, then interrupts must be disabled while issuing host adapter commands since a Command Complete interrupt could occur if the IRQ Channel was previously enabled by another BusLogic Host Adapter or another driver sharing the same IRQ Channel. */ if (!adapter->irq_acquired) local_irq_save(processor_flag); /* Wait for the Host Adapter Ready bit to be set and the Command/Parameter Register Busy bit to be reset in the Status Register. */ timeout = 10000; while (--timeout >= 0) { statusreg.all = blogic_rdstatus(adapter); if (statusreg.sr.adapter_ready && !statusreg.sr.cmd_param_busy) break; udelay(100); } if (timeout < 0) { blogic_cmd_failure_reason = "Timeout waiting for Host Adapter Ready"; result = -2; goto done; } /* Write the opcode to the Command/Parameter Register. */ adapter->adapter_cmd_complete = false; blogic_setcmdparam(adapter, opcode); /* Write any additional Parameter Bytes. */ timeout = 10000; while (paramlen > 0 && --timeout >= 0) { /* Wait 100 microseconds to give the Host Adapter enough time to determine whether the last value written to the Command/Parameter Register was valid or not. If the Command Complete bit is set in the Interrupt Register, then the Command Invalid bit in the Status Register will be reset if the Operation Code or Parameter was valid and the command has completed, or set if the Operation Code or Parameter was invalid. If the Data In Register Ready bit is set in the Status Register, then the Operation Code was valid, and data is waiting to be read back from the Host Adapter. Otherwise, wait for the Command/Parameter Register Busy bit in the Status Register to be reset. */ udelay(100); intreg.all = blogic_rdint(adapter); statusreg.all = blogic_rdstatus(adapter); if (intreg.ir.cmd_complete) break; if (adapter->adapter_cmd_complete) break; if (statusreg.sr.datain_ready) break; if (statusreg.sr.cmd_param_busy) continue; blogic_setcmdparam(adapter, *param_p++); paramlen--; } if (timeout < 0) { blogic_cmd_failure_reason = "Timeout waiting for Parameter Acceptance"; result = -2; goto done; } /* The Modify I/O Address command does not cause a Command Complete Interrupt. */ if (opcode == BLOGIC_MOD_IOADDR) { statusreg.all = blogic_rdstatus(adapter); if (statusreg.sr.cmd_invalid) { blogic_cmd_failure_reason = "Modify I/O Address Invalid"; result = -1; goto done; } if (blogic_global_options.trace_config) blogic_notice("blogic_cmd(%02X) Status = %02X: " "(Modify I/O Address)\n", adapter, opcode, statusreg.all); result = 0; goto done; } /* Select an appropriate timeout value for awaiting command completion. */ switch (opcode) { case BLOGIC_INQ_DEV0TO7: case BLOGIC_INQ_DEV8TO15: case BLOGIC_INQ_DEV: /* Approximately 60 seconds. */ timeout = 60 * 10000; break; default: /* Approximately 1 second. */ timeout = 10000; break; } /* Receive any Reply Bytes, waiting for either the Command Complete bit to be set in the Interrupt Register, or for the Interrupt Handler to set the Host Adapter Command Completed bit in the Host Adapter structure. */ while (--timeout >= 0) { intreg.all = blogic_rdint(adapter); statusreg.all = blogic_rdstatus(adapter); if (intreg.ir.cmd_complete) break; if (adapter->adapter_cmd_complete) break; if (statusreg.sr.datain_ready) { if (++reply_b <= replylen) *reply_p++ = blogic_rddatain(adapter); else blogic_rddatain(adapter); } if (opcode == BLOGIC_FETCH_LOCALRAM && statusreg.sr.adapter_ready) break; udelay(100); } if (timeout < 0) { blogic_cmd_failure_reason = "Timeout waiting for Command Complete"; result = -2; goto done; } /* Clear any pending Command Complete Interrupt. */ blogic_intreset(adapter); /* Provide tracing information if requested. */ if (blogic_global_options.trace_config) { int i; blogic_notice("blogic_cmd(%02X) Status = %02X: %2d ==> %2d:", adapter, opcode, statusreg.all, replylen, reply_b); if (replylen > reply_b) replylen = reply_b; for (i = 0; i < replylen; i++) blogic_notice(" %02X", adapter, ((unsigned char *) reply)[i]); blogic_notice("\n", adapter); } /* Process Command Invalid conditions. */ if (statusreg.sr.cmd_invalid) { /* Some early BusLogic Host Adapters may not recover properly from a Command Invalid condition, so if this appears to be the case, a Soft Reset is issued to the Host Adapter. Potentially invalid commands are never attempted after Mailbox Initialization is performed, so there should be no Host Adapter state lost by a Soft Reset in response to a Command Invalid condition. */ udelay(1000); statusreg.all = blogic_rdstatus(adapter); if (statusreg.sr.cmd_invalid || statusreg.sr.rsvd || statusreg.sr.datain_ready || statusreg.sr.cmd_param_busy || !statusreg.sr.adapter_ready || !statusreg.sr.init_reqd || statusreg.sr.diag_active || statusreg.sr.diag_failed) { blogic_softreset(adapter); udelay(1000); } blogic_cmd_failure_reason = "Command Invalid"; result = -1; goto done; } /* Handle Excess Parameters Supplied conditions. */ if (paramlen > 0) { blogic_cmd_failure_reason = "Excess Parameters Supplied"; result = -1; goto done; } /* Indicate the command completed successfully. */ blogic_cmd_failure_reason = NULL; result = reply_b; /* Restore the interrupt status if necessary and return. */ done: if (!adapter->irq_acquired) local_irq_restore(processor_flag); return result; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)48765.99%861.54%
Khalid Aziz19826.83%17.69%
Andrew Morton364.88%17.69%
Linus Torvalds91.22%17.69%
James Bottomley60.81%17.69%
Doug Ledford20.27%17.69%
Total738100.00%13100.00%

/* blogic_add_probeaddr_isa appends a single ISA I/O Address to the list of I/O Address and Bus Probe Information to be checked for potential BusLogic Host Adapters. */
static void __init blogic_add_probeaddr_isa(unsigned long io_addr) { struct blogic_probeinfo *probeinfo; if (blogic_probeinfo_count >= BLOGIC_MAX_ADAPTERS) return; probeinfo = &blogic_probeinfo_list[blogic_probeinfo_count++]; probeinfo->adapter_type = BLOGIC_MULTIMASTER; probeinfo->adapter_bus_type = BLOGIC_ISA_BUS; probeinfo->io_addr = io_addr; probeinfo->pci_device = NULL; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)2850.00%562.50%
Khalid Aziz2035.71%112.50%
James Bottomley47.14%112.50%
Doug Ledford47.14%112.50%
Total56100.00%8100.00%

/* blogic_init_probeinfo_isa initializes the list of I/O Address and Bus Probe Information to be checked for potential BusLogic SCSI Host Adapters only from the list of standard BusLogic MultiMaster ISA I/O Addresses. */
static void __init blogic_init_probeinfo_isa(struct blogic_adapter *adapter) { /* If BusLogic Driver Options specifications requested that ISA Bus Probes be inhibited, do not proceed further. */ if (blogic_probe_options.noprobe_isa) return; /* Append the list of standard BusLogic MultiMaster ISA I/O Addresses. */ if (!blogic_probe_options.limited_isa || blogic_probe_options.probe330) blogic_add_probeaddr_isa(0x330); if (!blogic_probe_options.limited_isa || blogic_probe_options.probe334) blogic_add_probeaddr_isa(0x334); if (!blogic_probe_options.limited_isa || blogic_probe_options.probe230) blogic_add_probeaddr_isa(0x230); if (!blogic_probe_options.limited_isa || blogic_probe_options.probe234) blogic_add_probeaddr_isa(0x234); if (!blogic_probe_options.limited_isa || blogic_probe_options.probe130) blogic_add_probeaddr_isa(0x130); if (!blogic_probe_options.limited_isa || blogic_probe_options.probe134) blogic_add_probeaddr_isa(0x134); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)6656.41%233.33%
Khalid Aziz3630.77%116.67%
Zachary Amsden1210.26%116.67%
James Bottomley21.71%116.67%
Linus Torvalds10.85%116.67%
Total117100.00%6100.00%

#ifdef CONFIG_PCI /* blogic_sort_probeinfo sorts a section of blogic_probeinfo_list in order of increasing PCI Bus and Device Number. */
static void __init blogic_sort_probeinfo(struct blogic_probeinfo *probeinfo_list, int probeinfo_cnt) { int last_exchange = probeinfo_cnt - 1, bound, j; while (last_exchange > 0) { bound = last_exchange; last_exchange = 0; for (j = 0; j < bound; j++) { struct blogic_probeinfo *probeinfo1 = &probeinfo_list[j]; struct blogic_probeinfo *probeinfo2 = &probeinfo_list[j + 1]; if (probeinfo1->bus > probeinfo2->bus || (probeinfo1->bus == probeinfo2->bus && (probeinfo1->dev > probeinfo2->dev))) { struct blogic_probeinfo tmp_probeinfo; memcpy(&tmp_probeinfo, probeinfo1, sizeof(struct blogic_probeinfo)); memcpy(probeinfo1, probeinfo2, sizeof(struct blogic_probeinfo)); memcpy(probeinfo2, &tmp_probeinfo, sizeof(struct blogic_probeinfo)); last_exchange = j; } } } }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)11269.14%571.43%
Khalid Aziz4225.93%114.29%
James Bottomley84.94%114.29%
Total162100.00%7100.00%

/* blogic_init_mm_probeinfo initializes the list of I/O Address and Bus Probe Information to be checked for potential BusLogic MultiMaster SCSI Host Adapters by interrogating the PCI Configuration Space on PCI machines as well as from the list of standard BusLogic MultiMaster ISA I/O Addresses. It returns the number of PCI MultiMaster Host Adapters found. */
static int __init blogic_init_mm_probeinfo(struct blogic_adapter *adapter) { struct blogic_probeinfo *pr_probeinfo = &blogic_probeinfo_list[blogic_probeinfo_count]; int nonpr_mmindex = blogic_probeinfo_count + 1; int nonpr_mmcount = 0, mmcount = 0; bool force_scan_order = false; bool force_scan_order_checked = false; bool addr_seen[6]; struct pci_dev *pci_device = NULL; int i; if (blogic_probeinfo_count >= BLOGIC_MAX_ADAPTERS) return 0; blogic_probeinfo_count++; for (i = 0; i < 6; i++) addr_seen[i] = false; /* Iterate over the MultiMaster PCI Host Adapters. For each enumerated host adapter, determine whether its ISA Compatible I/O Port is enabled and if so, whether it is assigned the Primary I/O Address. A host adapter that is assigned the Primary I/O Address will always be the preferred boot device. The MultiMaster BIOS will first recognize a host adapter at the Primary I/O Address, then any other PCI host adapters, and finally any host adapters located at the remaining standard ISA I/O Addresses. When a PCI host adapter is found with its ISA Compatible I/O Port enabled, a command is issued to disable the ISA Compatible I/O Port, and it is noted that the particular standard ISA I/O Address need not be probed. */ pr_probeinfo->io_addr = 0; while ((pci_device = pci_get_device(PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER, pci_device)) != NULL) { struct blogic_adapter *host_adapter = adapter; struct blogic_adapter_info adapter_info; enum blogic_isa_ioport mod_ioaddr_req; unsigned char bus; unsigned char device; unsigned int irq_ch; unsigned long base_addr0; unsigned long base_addr1; unsigned long io_addr; unsigned long pci_addr; if (pci_enable_device(pci_device)) continue; if (pci_set_dma_mask(pci_device, DMA_BIT_MASK(32))) continue; bus = pci_device->bus->number; device = pci_device->devfn >> 3; irq_ch = pci_device->irq; io_addr = base_addr0 = pci_resource_start(pci_device, 0); pci_addr = base_addr1 = pci_resource_start(pci_device, 1); if (pci_resource_flags(pci_device, 0) & IORESOURCE_MEM) { blogic_err("BusLogic: Base Address0 0x%X not I/O for " "MultiMaster Host Adapter\n", NULL, base_addr0); blogic_err("at PCI Bus %d Device %d I/O Address 0x%X\n", NULL, bus, device, io_addr); continue; } if (pci_resource_flags(pci_device, 1) & IORESOURCE_IO) { blogic_err("BusLogic: Base Address1 0x%X not Memory for " "MultiMaster Host Adapter\n", NULL, base_addr1); blogic_err("at PCI Bus %d Device %d PCI Address 0x%X\n", NULL, bus, device, pci_addr); continue; } if (irq_ch == 0) { blogic_err("BusLogic: IRQ Channel %d invalid for " "MultiMaster Host Adapter\n", NULL, irq_ch); blogic_err("at PCI Bus %d Device %d I/O Address 0x%X\n", NULL, bus, device, io_addr); continue; } if (blogic_global_options.trace_probe) { blogic_notice("BusLogic: PCI MultiMaster Host Adapter " "detected at\n", NULL); blogic_notice("BusLogic: PCI Bus %d Device %d I/O Address " "0x%X PCI Address 0x%X\n", NULL, bus, device, io_addr, pci_addr); } /* Issue the Inquire PCI Host Adapter Information command to determine the ISA Compatible I/O Port. If the ISA Compatible I/O Port is known and enabled, note that the particular Standard ISA I/O Address should not be probed. */ host_adapter->io_addr = io_addr; blogic_intreset(host_adapter); if (blogic_cmd(host_adapter, BLOGIC_INQ_PCI_INFO, NULL, 0, &adapter_info, sizeof(adapter_info)) == sizeof(adapter_info)) { if (adapter_info.isa_port < 6) addr_seen[adapter_info.isa_port] = true; } else adapter_info.isa_port = BLOGIC_IO_DISABLE; /* Issue the Modify I/O Address command to disable the ISA Compatible I/O Port. On PCI Host Adapters, the Modify I/O Address command allows modification of the ISA compatible I/O Address that the Host Adapter responds to; it does not affect the PCI compliant I/O Address assigned at system initialization. */ mod_ioaddr_req = BLOGIC_IO_DISABLE; blogic_cmd(host_adapter, BLOGIC_MOD_IOADDR, &mod_ioaddr_req, sizeof(mod_ioaddr_req), NULL, 0); /* For the first MultiMaster Host Adapter enumerated, issue the Fetch Host Adapter Local RAM command to read byte 45 of the AutoSCSI area, for the setting of the "Use Bus And Device # For PCI Scanning Seq." option. Issue the Inquire Board ID command since this option is only valid for the BT-948/958/958D. */ if (!force_scan_order_checked) { struct blogic_fetch_localram fetch_localram; struct blogic_autoscsi_byte45 autoscsi_byte45; struct blogic_board_id id; fetch_localram.offset = BLOGIC_AUTOSCSI_BASE + 45; fetch_localram.count = sizeof(autoscsi_byte45); blogic_cmd(host_adapter, BLOGIC_FETCH_LOCALRAM, &fetch_localram, sizeof(fetch_localram), &autoscsi_byte45, sizeof(autoscsi_byte45)); blogic_cmd(host_adapter, BLOGIC_GET_BOARD_ID, NULL, 0, &id, sizeof(id)); if (id.fw_ver_digit1 == '5') force_scan_order = autoscsi_byte45.force_scan_order; force_scan_order_checked = true; } /* Determine whether this MultiMaster Host Adapter has its ISA Compatible I/O Port enabled and is assigned the Primary I/O Address. If it does, then it is the Primary MultiMaster Host Adapter and must be recognized first. If it does not, then it is added to the list for probing after any Primary MultiMaster Host Adapter is probed. */ if (adapter_info.isa_port == BLOGIC_IO_330) { pr_probeinfo->adapter_type = BLOGIC_MULTIMASTER; pr_probeinfo->adapter_bus_type = BLOGIC_PCI_BUS; pr_probeinfo->io_addr = io_addr; pr_probeinfo->pci_addr = pci_addr; pr_probeinfo->bus = bus; pr_probeinfo->dev = device; pr_probeinfo->irq_ch = irq_ch; pr_probeinfo->pci_device = pci_dev_get(pci_device); mmcount++; } else if (blogic_probeinfo_count < BLOGIC_MAX_ADAPTERS) { struct blogic_probeinfo *probeinfo = &blogic_probeinfo_list[blogic_probeinfo_count++]; probeinfo->adapter_type = BLOGIC_MULTIMASTER; probeinfo->adapter_bus_type = BLOGIC_PCI_BUS; probeinfo->io_addr = io_addr; probeinfo->pci_addr = pci_addr; probeinfo->bus = bus; probeinfo->dev = device; probeinfo->irq_ch = irq_ch; probeinfo->pci_device = pci_dev_get(pci_device); nonpr_mmcount++; mmcount++; } else blogic_warn("BusLogic: Too many Host Adapters " "detected\n", NULL); } /* If the AutoSCSI "Use Bus And Device # For PCI Scanning Seq." option is ON for the first enumerated MultiMaster Host Adapter, and if that host adapter is a BT-948/958/958D, then the MultiMaster BIOS will recognize MultiMaster Host Adapters in the order of increasing PCI Bus and Device Number. In that case, sort the probe information into the same order the BIOS uses. If this option is OFF, then the MultiMaster BIOS will recognize MultiMaster Host Adapters in the order they are enumerated by the PCI BIOS, and hence no sorting is necessary. */ if (force_scan_order) blogic_sort_probeinfo(&blogic_probeinfo_list[nonpr_mmindex], nonpr_mmcount); /* If no PCI MultiMaster Host Adapter is assigned the Primary I/O Address, then the Primary I/O Address must be probed explicitly before any PCI host adapters are probed. */ if (!blogic_probe_options.noprobe_isa) if (pr_probeinfo->io_addr == 0 && (!blogic_probe_options.limited_isa || blogic_probe_options.probe330)) { pr_probeinfo->adapter_type = BLOGIC_MULTIMASTER; pr_probeinfo->adapter_bus_type = BLOGIC_ISA_BUS; pr_probeinfo->io_addr = 0x330; } /* Append the list of standard BusLogic MultiMaster ISA I/O Addresses, omitting the Primary I/O Address which has already been handled. */ if (!blogic_probe_options.noprobe_isa) { if (!addr_seen[1] && (!blogic_probe_options.limited_isa || blogic_probe_options.probe334)) blogic_add_probeaddr_isa(0x334); if (!addr_seen[2] && (!blogic_probe_options.limited_isa || blogic_probe_options.probe230)) blogic_add_probeaddr_isa(0x230); if (!addr_seen[3] && (!blogic_probe_options.limited_isa || blogic_probe_options.probe234)) blogic_add_probeaddr_isa(0x234); if (!addr_seen[4] && (!blogic_probe_options.limited_isa || blogic_probe_options.probe130)) blogic_add_probeaddr_isa(0x130); if (!addr_seen[5] && (!blogic_probe_options.limited_isa || blogic_probe_options.probe134)) blogic_add_probeaddr_isa(0x134); } /* Iterate over the older non-compliant MultiMaster PCI Host Adapters, noting the PCI bus location and assigned IRQ Channel. */ pci_device = NULL; while ((pci_device = pci_get_device(PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER_NC, pci_device)) != NULL) { unsigned char bus; unsigned char device; unsigned int irq_ch; unsigned long io_addr; if (pci_enable_device(pci_device)) continue; if (pci_set_dma_mask(pci_device, DMA_BIT_MASK(32))) continue; bus = pci_device->bus->number; device = pci_device->devfn >> 3; irq_ch = pci_device->irq; io_addr = pci_resource_start(pci_device, 0); if (io_addr == 0 || irq_ch == 0) continue; for (i = 0; i < blogic_probeinfo_count; i++) { struct blogic_probeinfo *probeinfo = &blogic_probeinfo_list[i]; if (probeinfo->io_addr == io_addr && probeinfo->adapter_type == BLOGIC_MULTIMASTER) { probeinfo->adapter_bus_type = BLOGIC_PCI_BUS; probeinfo->pci_addr = 0