Lines Matching +full:debounce +full:- +full:enter
1 // SPDX-License-Identifier: GPL-2.0-or-later
7 * Copyright (C) 2001-2004 Jes Sorensen, Wild Open Source Inc.
8 * Copyright (C) 2003-2004 Christoph Hellwig
15 - Retain firmware image for error recovery.
17 - General code cleanup.
18 - Improve error recovery.
20 - Ditch all < 2.6 support
22 - use pci_map_single to map non-S/G requests
23 - remove qla1280_proc_info
25 - add support for ISP1020/1040
26 - don't include "scsi.h" anymore for 2.6.x
28 - restructure firmware loading, cleanup initialization code
29 - prepare support for ISP1020/1040 chips
31 - Handle PCI DMA mask settings correctly
32 - Correct order of error handling in probe_one, free_irq should not
35 - Big endian fixes (James)
36 - Remove bogus IOCB content on zero data transfer commands (Andrew)
38 - Initialize completion queue to avoid OOPS on probe
39 - Handle interrupts during mailbox testing
41 - use struct list_head for completion queue
42 - avoid old Scsi_FOO typedefs
43 - cleanup 2.4 compat glue a bit
44 - use <scsi/scsi_*.h> headers on 2.6 instead of "scsi.h"
45 - make initialization for memory mapped vs port I/O more similar
46 - remove broken pci config space manipulation
47 - kill more cruft
48 - this is an almost perfect 2.6 scsi driver now! ;)
50 - Delete completion queue from srb if mailbox command failed to
53 - Reduce arguments for qla1280_done
55 - Convert to new-style hotplugable driver for 2.6
56 - Fix missing scsi_unregister/scsi_host_put on HBA removal
57 - Kill some more cruft
59 - Make MMIO depend on CONFIG_X86_VISWS instead of yet another
61 - Clean up locking in probe path
63 - queuecommand only ever receives new commands - clear flags
64 - Reintegrate lost fixes from Linux 2.5
66 - Build against 2.6
68 - Remove pointless TRUE/FALSE macros
69 - Clean up vchan handling
71 - Don't define register access macros before define determining MMIO.
73 - Don't try and read from the card while it is in reset as
76 - Basic support for boot time arguments
78 - Reduce boot time messages
80 - Do not enable sync/wide/ppr before it has been determined
82 - Enable DMA arbitration for multi channel controllers
84 - Port to 2.5.69
86 - Eliminate duplicate marker commands on bus resets
87 - Handle outstanding commands appropriately on bus/device resets
89 - Remove bogus input queue code, let the Linux SCSI layer do the work
90 - Clean up NVRAM handling, only read it once from the card
91 - Add a number of missing default nvram parameters
93 - Use completion queue for mailbox commands instead of busy wait
95 - Migrate to use new error handling code
97 - Big endian support
98 - Cleanup data direction code
100 - Switch to using MMIO instead of PIO
102 - Fix PCI parity problem with 12160 during reset.
104 - Use pci_map_page()/pci_unmap_page() instead of map_single version.
106 - Remove < 2.4.x support
107 - Introduce HOST_LOCK to make the spin lock changes portable.
108 - Remove a bunch of idiotic and unnecessary typedef's
109 - Kill all leftovers of target-mode support which never worked anyway
111 - Do qla1280_pci_config() before calling request_irq() and
113 - Use pci_dma_hi32() to handle upper word of DMA addresses instead
115 - Hand correct arguments to free_irq() in case of failure
117 - Run source through Lindent and clean up the output
119 - Update SCSI firmware to qla1280 v8.15.00 and qla12160 v10.04.32
121 - Rely on mailbox commands generating interrupts - do not
123 - Remove device_reg_t
124 - Integrate ql12160_set_target_parameters() with 1280 version
125 - Make qla1280_setup() non static
126 - Do not call qla1280_check_for_dead_scsi_bus() on every I/O request
127 sent to the card - this command pauses the firmware!!!
129 - Clean up qla1280.h - remove obsolete QL_DEBUG_LEVEL_x definitions
130 - Remove a pile of pointless and confusing (srb_t **) and
132 - Explicit mark that we do not use the new error handling (for now)
133 - Remove scsi_qla_host_t and use 'struct' instead
134 - Remove in_abort, watchdog_enabled, dpc, dpc_sched, bios_enabled,
136 - Grab host->host_lock while calling qla1280_isr() from abort()
137 - Use spin_lock()/spin_unlock() in qla1280_intr_handler() - we
139 - Enable interrupts early (before any mailbox access) in preparation
142 - Further cleanups. Remove all trace of QL_DEBUG_LEVEL_x and replace
144 - Make qla1280_print_scsi_cmd() and qla1280_dump_buffer() both take
146 - Add KERN_* info to printk()
148 - Significant cosmetic cleanups
149 - Change debug code to use dprintk() and remove #if mess
151 - More cosmetic cleanups, fix places treating return as function
152 - use cpu_relax() in qla1280_debounce_register()
154 - Make it compile under 2.5.5
156 - Do no typecast short * to long * in QL1280BoardTbl, this
159 - Remove pre 2.2 hack for checking for reentrance in interrupt handler
160 - Make data types used to receive from SCSI_{BUS,TCN,LUN}_32
163 - Remove bogus timer_t typedef from qla1280.h
164 - Remove obsolete pre 2.2 PCI setup code, use proper #define's
166 - Fix memleak of qla1280_buffer on module unload
167 - Only compile module parsing code #ifdef MODULE - should be
169 - Remove dummy_buffer that was never modified nor printed
170 - ENTER()/LEAVE() are noops unless QL_DEBUG_LEVEL_3, hence remove
171 #ifdef QL_DEBUG_LEVEL_3/#endif around ENTER()/LEAVE() calls
172 - Remove \r from print statements, this is Linux, not DOS
173 - Remove obsolete QLA1280_{SCSILU,INTR,RING}_{LOCK,UNLOCK}
175 - Remove C++ compile hack in header file as Linux driver are not
177 - Kill MS_64BITS macro as it makes the code more readable
178 - Remove unnecessary flags.in_interrupts bit
180 - Dont' check for set flags on q->q_flag one by one in qla1280_next()
181 - Check whether the interrupt was generated by the QLA1280 before
183 - qla1280_status_entry(): Only zero out part of sense_buffer that
185 - Remove more superflouous typecasts
186 - qla1280_32bit_start_scsi() replace home-brew memcpy() with memcpy()
188 - Don't walk the entire list in qla1280_putq_t() just to directly
191 - Don't use IRQF_DISABLED, it's use is deprecated for this kinda driver
193 - Set dev->max_sectors to 1024
195 - Provide compat macros for pci_enable_device(), pci_find_subsys()
197 - Call scsi_set_pci_device() for all devices
198 - Reduce size of kernel version dependent device probe code
199 - Move duplicate probe/init code to separate function
200 - Handle error if qla1280_mem_alloc() fails
201 - Kill OFFSET() macro and use Linux's PCI definitions instead
202 - Kill private structure defining PCI config space (struct config_reg)
203 - Only allocate I/O port region if not in MMIO mode
204 - Remove duplicate (unused) sanity check of sife of srb_t
206 - Change home-brew memset() implementations to use memset()
207 - Remove all references to COMTRACE() - accessing a PC's COM2 serial
210 - Remove pre 2.2 kernel support
211 - clean up 64 bit DMA setting to use 2.4 API (provide backwards compat)
212 - Fix MMIO access to use readl/writel instead of directly
214 - Nuke MSDOS debugging code
215 - Change true/false data types to int from uint8_t
216 - Use int for counters instead of uint8_t etc.
217 - Clean up size & byte order conversion macro usage
219 - Added check of device_id when handling non
222 - Changed queue_task() to schedule_task()
224 Note: 2.4.0-testxx kernels released prior to
230 - Added -DCONFIG_SMP in addition to -D__SMP__
233 - Changed criteria of 64/32 Bit mode of HBA
236 so that the HBA auto-configures without the need
239 - Added priority handling to IA-64 onboard SCSI
241 - Added irqrestore for qla1280_intr_handler.
242 - Enabled /proc/scsi/qla1280 interface.
243 - Clear /proc/scsi/qla1280 counters in detect().
245 - Declare driver_template for new kernel
247 - Update /proc/scsi entry for 2.3.18 kernels and
250 - Changed scan order of adapters to map
253 - Removed warnings for 32 bit 2.4.x compiles
254 - Corrected declared size for request and response
257 - Corrected 64 bit addressing issue on IA-64
261 - Modified qla1280_setup_chip to properly load
262 ISP firmware for greater that 4 Gig memory on IA-64
264 - Added setting of dma_mask to full 64 bit
267 - Use new PCI DMA mapping APIs for 2.4.x kernel
269 - Added check of pci_enable_device to detect() for 2.3.x
270 - Use pci_resource_start() instead of
271 pdev->resource[0].start in detect() for 2.3.x
272 - Updated driver version
274 - Updated SCSI Firmware to following versions:
277 - Updated driver version to 3.11
279 - Added filtering of AMI SubSys Vendor ID devices
281 - DEBUG_QLA1280 undefined and new version BN Qlogic
283 - Added logic to check against AMI subsystem vendor ID
285 - Added logic to check for PCI subsystem ID.
287 - Updated SCSI Firmware to following versions:
291 - Internal revision; not released
293 - Edit correction for virt_to_bus and PROC.
295 - Merge changes from ia64 port.
297 - Increase version to reflect new code drop with compile fix
300 - Merge qla1280_proc_info from 2.10 code base
302 - Corrected code to compile on a 2.2.x kernel.
304 - Added 64-bit support.
306 - Added new routine to set target parameters for ISP12160.
308 - Added support for ISP12160 Ultra 3 chip.
310 - Modified code to remove errors generated when compiling with
312 - Changed conversion of pointers to unsigned longs instead of integers.
313 - Changed type of I/O port variables from uint32_t to unsigned long.
314 - Modified OFFSET macro to work with 64-bit as well as 32-bit.
315 - Changed sprintf and printk format specifiers for pointers to %p.
316 - Changed some int to long type casts where needed in sprintf & printk.
317 - Added l modifiers to sprintf and printk format specifiers for longs.
318 - Removed unused local variables.
321 - Added SCSI exclusive access lock (io_request_lock) when accessing
323 - Added changes for the new LINUX interface template. Some new error
326 - Initial Beta Release.
345 #include <linux/dma-mapping.h>
363 * 0 - Disable and 1 - Enable
379 #define IS_ISP1040(ha) (ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP1020)
380 #define IS_ISP1x40(ha) (ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP1020 || \
381 ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP1240)
382 #define IS_ISP1x160(ha) (ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP10160 || \
383 ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP12160)
443 switch(cmnd->sc_data_direction) {
480 #define CMD_CDBLEN(Cmnd) Cmnd->cmd_len
481 #define CMD_CDBP(Cmnd) Cmnd->cmnd
482 #define CMD_SNSP(Cmnd) Cmnd->sense_buffer
484 #define CMD_RESULT(Cmnd) Cmnd->result
485 #define CMD_HANDLE(Cmnd) Cmnd->host_scribble
487 #define CMD_HOST(Cmnd) Cmnd->device->host
488 #define SCSI_BUS_32(Cmnd) Cmnd->device->channel
489 #define SCSI_TCN_32(Cmnd) Cmnd->device->id
490 #define SCSI_LUN_32(Cmnd) Cmnd->device->lun
544 {.name = " ", .numPorts = 0, .fw_index = -1},
564 #define ENTER(x) dprintk(3, "qla1280 : Entering %s()\n", x);
577 ENTER("qla1280_read_nvram");
582 printk(KERN_INFO "scsi(%ld): Reading NVRAM\n", ha->host_no);
584 wptr = (uint16_t *)&ha->nvram;
585 nv = &ha->nvram;
594 if (nv->id0 != 'I' || nv->id1 != 'S' ||
595 nv->id2 != 'P' || nv->id3 != ' ' || nv->version < 1) {
608 " version %i\n", nv->id0, nv->id1, nv->id2, nv->id3,
609 nv->version);
616 "settings\n", ha->host_no);
617 ha->nvram_valid = 0;
619 ha->nvram_valid = 1;
637 nv->isp_parameter = cpu_to_le16(nv->isp_parameter);
638 nv->firmware_feature.w = cpu_to_le16(nv->firmware_feature.w);
640 nv->bus[i].selection_timeout = cpu_to_le16(nv->bus[i].selection_timeout);
641 nv->bus[i].max_queue_depth = cpu_to_le16(nv->bus[i].max_queue_depth);
662 ha = (struct scsi_qla_host *)host->hostdata;
663 bdp = &ql1280_board_tbl[ha->devnum];
669 &bdp->name[0], ha->fwver1, ha->fwver2, ha->fwver3,
679 * The mid-level driver tries to ensures that queuecommand never gets invoked
681 * interrupt handler may call this routine as part of request-completion
687 struct Scsi_Host *host = cmd->device->host;
688 struct scsi_qla_host *ha = (struct scsi_qla_host *)host->hostdata;
692 sp->cmd = cmd;
693 sp->flags = 0;
694 sp->wait = NULL;
727 reg = ha->iobase;
729 ha->mailbox_out[0] = RD_REG_WORD(®->mailbox0);
731 "ictrl %04x, istatus %04x\n", ha->host_no, ha->mailbox_out[0],
732 RD_REG_WORD(®->ictrl), RD_REG_WORD(®->istatus));
733 complete(ha->mailbox_wait);
741 struct scsi_cmnd *cmd = sp->cmd;
743 spin_unlock_irq(ha->host->host_lock);
745 spin_lock_irq(ha->host->host_lock);
746 sp->wait = NULL;
759 sp->wait = &wait;
778 sp = ha->outstanding_cmds[cnt];
780 cmd = sp->cmd;
817 int wait_for_bus=-1;
818 int wait_for_target = -1;
821 ENTER("qla1280_error_action");
823 ha = (struct scsi_qla_host *)(CMD_HOST(cmd)->hostdata);
830 RD_REG_WORD(&ha->iobase->istatus));
833 RD_REG_WORD(&ha->iobase->host_cmd),
834 RD_REG_WORD(&ha->iobase->ictrl), jiffies);
839 ha->host_no, cmd, CMD_HANDLE(cmd), action);
847 found = -1;
849 if (sp == ha->outstanding_cmds[i]) {
851 sp->wait = &wait; /* we'll wait for it to complete */
861 "already completed.\n", ha->host_no, bus,
883 "command.\n", ha->host_no, bus, target, lun);
894 "reset.\n", ha->host_no, bus);
906 ha->host_no);
908 "continue automatically\n", ha->host_no);
910 ha->flags.reset_active = 1;
916 ha->flags.reset_active = 0;
922 * Wait for the command passed in by the mid-layer if it
935 ha->host_no, bus, target, lun);
939 * If the command passed in by the mid-layer has been
968 spin_lock_irq(cmd->device->host->host_lock);
970 spin_unlock_irq(cmd->device->host->host_lock);
984 spin_lock_irq(cmd->device->host->host_lock);
986 spin_unlock_irq(cmd->device->host->host_lock);
1000 spin_lock_irq(cmd->device->host->host_lock);
1002 spin_unlock_irq(cmd->device->host->host_lock);
1016 spin_lock_irq(cmd->device->host->host_lock);
1018 spin_unlock_irq(cmd->device->host->host_lock);
1052 WRT_REG_WORD(&ha->iobase->ictrl, 0);
1053 RD_REG_WORD(&ha->iobase->ictrl); /* PCI Posted Write flush */
1060 WRT_REG_WORD(&ha->iobase->ictrl, (ISP_EN_INT | ISP_EN_RISC));
1061 RD_REG_WORD(&ha->iobase->ictrl); /* PCI Posted Write flush */
1079 spin_lock(ha->host->host_lock);
1081 ha->isr_count++;
1082 reg = ha->iobase;
1086 data = qla1280_debounce_register(®->istatus);
1089 qla1280_isr(ha, &ha->done_q);
1092 if (!list_empty(&ha->done_q))
1095 spin_unlock(ha->host->host_lock);
1112 nv = &ha->nvram;
1119 mb[2] = nv->bus[bus].target[target].parameter.renegotiate_on_error << 8;
1120 mb[2] |= nv->bus[bus].target[target].parameter.stop_queue_on_check << 9;
1121 mb[2] |= nv->bus[bus].target[target].parameter.auto_request_sense << 10;
1122 mb[2] |= nv->bus[bus].target[target].parameter.tag_queuing << 11;
1123 mb[2] |= nv->bus[bus].target[target].parameter.enable_sync << 12;
1124 mb[2] |= nv->bus[bus].target[target].parameter.enable_wide << 13;
1125 mb[2] |= nv->bus[bus].target[target].parameter.parity_checking << 14;
1126 mb[2] |= nv->bus[bus].target[target].parameter.disconnect_allowed << 15;
1129 mb[2] |= nv->bus[bus].target[target].ppr_1x160.flags.enable_ppr << 5;
1130 mb[3] = (nv->bus[bus].target[target].flags.flags1x160.sync_offset << 8);
1131 mb[6] = (nv->bus[bus].target[target].ppr_1x160.flags.ppr_options << 8) |
1132 nv->bus[bus].target[target].ppr_1x160.flags.ppr_bus_width;
1135 mb[3] = (nv->bus[bus].target[target].flags.flags1x80.sync_offset << 8);
1137 mb[3] |= nv->bus[bus].target[target].sync_period;
1146 mb[2] = nv->bus[bus].max_queue_depth;
1147 mb[3] = nv->bus[bus].target[target].execution_throttle;
1154 ha->host_no, bus, target);
1175 int bus = device->channel;
1176 int target = device->id;
1181 ha = (struct scsi_qla_host *)device->host->hostdata;
1182 nv = &ha->nvram;
1187 if (device->tagged_supported &&
1188 (ha->bus_settings[bus].qtag_enables & (BIT_0 << target))) {
1189 scsi_change_queue_depth(device, ha->bus_settings[bus].hiwat);
1194 nv->bus[bus].target[target].parameter.enable_sync = device->sdtr;
1195 nv->bus[bus].target[target].parameter.enable_wide = device->wdtr;
1196 nv->bus[bus].target[target].ppr_1x160.flags.enable_ppr = device->ppr;
1201 nv->bus[bus].target[target].parameter.enable_sync = 0;
1205 nv->bus[bus].target[target].parameter.enable_wide = 0;
1210 nv->bus[bus].target[target].ppr_1x160.flags.enable_ppr = 0;
1213 spin_lock_irqsave(ha->host->host_lock, flags);
1214 if (nv->bus[bus].target[target].parameter.enable_sync)
1217 spin_unlock_irqrestore(ha->host->host_lock, flags);
1237 ENTER("qla1280_done");
1239 done_q = &ha->done_q;
1242 sp = list_entry(done_q->next, struct srb, list);
1244 list_del(&sp->list);
1246 cmd = sp->cmd;
1253 if (!ha->flags.abort_isp_active)
1257 sp->flags &= ~SRB_ABORT_PENDING;
1258 sp->flags |= SRB_ABORTED;
1267 /* Call the mid-level driver interrupt handler */
1268 ha->actthreads--;
1270 if (sp->wait == NULL)
1273 complete(sp->wait);
1285 uint16_t comp_status = le16_to_cpu(sts->comp_status);
1286 uint16_t state_flags = le16_to_cpu(sts->state_flags);
1287 uint32_t residual_length = le32_to_cpu(sts->residual_length);
1288 uint16_t scsi_status = le16_to_cpu(sts->scsi_status);
1304 ENTER("qla1280_return_status");
1353 if ((scsi_bufflen(cp) - residual_length) <
1354 cp->underflow) {
1356 "scsi: Underflow detected - retrying "
1402 ENTER("qla1280_initialize_adapter");
1405 ha->flags.online = 0;
1406 ha->flags.disable_host_adapter = 0;
1407 ha->flags.reset_active = 0;
1408 ha->flags.abort_isp_active = 0;
1416 reg = ha->iobase;
1419 WRT_REG_WORD(®->semaphore, 0);
1420 WRT_REG_WORD(®->host_cmd, HC_CLR_RISC_INT);
1421 WRT_REG_WORD(®->host_cmd, HC_CLR_HOST_INT);
1422 RD_REG_WORD(®->host_cmd);
1434 spin_lock_irqsave(ha->host->host_lock, flags);
1439 ha->host_no);
1444 dprintk(1, "scsi(%ld): Configure NVRAM parameters\n", ha->host_no);
1447 if (ha->flags.disable_host_adapter) {
1457 for (bus = 0; bus < ha->ports; bus++) {
1458 if (!ha->bus_settings[bus].disable_scsi_reset &&
1461 ha->bus_settings[bus].scsi_bus_dead = 1;
1464 ha->flags.online = 1;
1466 spin_unlock_irqrestore(ha->host->host_lock, flags);
1495 spin_unlock_irq(ha->host->host_lock);
1498 index = ql1280_board_tbl[ha->devnum].fw_index;
1504 err = request_firmware(&fw, fwname, &ha->pdev->dev);
1512 if ((fw->size % 2) || (fw->size < 6)) {
1514 fw->size, fwname);
1516 fw = ERR_PTR(-EINVAL);
1523 ha->fwver1 = fw->data[0];
1524 ha->fwver2 = fw->data[1];
1525 ha->fwver3 = fw->data[2];
1528 spin_lock_irq(ha->host->host_lock);
1546 struct device_reg __iomem *reg = ha->iobase;
1550 dprintk(3, "qla1280_chip_diag: testing device at 0x%p \n", ®->id_l);
1552 dprintk(1, "scsi(%ld): Verifying chip\n", ha->host_no);
1555 WRT_REG_WORD(®->ictrl, ISP_RESET);
1565 data = qla1280_debounce_register(®->ictrl);
1567 * Yet another QLogic gem ;-(
1569 for (cnt = 1000000; cnt && data & ISP_RESET; cnt--) {
1571 data = RD_REG_WORD(®->ictrl);
1580 WRT_REG_WORD(®->cfg_1, 0);
1584 WRT_REG_WORD(®->host_cmd, HC_RESET_RISC |
1587 RD_REG_WORD(®->id_l); /* Flush PCI write */
1588 data = qla1280_debounce_register(®->mailbox0);
1593 for (cnt = 1000000; cnt && data == MBS_BUSY; cnt--) {
1595 data = RD_REG_WORD(®->mailbox0);
1604 if (RD_REG_WORD(®->mailbox1) != PROD_ID_1 ||
1605 (RD_REG_WORD(®->mailbox2) != PROD_ID_2 &&
1606 RD_REG_WORD(®->mailbox2) != PROD_ID_2a) ||
1607 RD_REG_WORD(®->mailbox3) != PROD_ID_3 ||
1608 RD_REG_WORD(®->mailbox4) != PROD_ID_4) {
1611 RD_REG_WORD(®->mailbox1),
1612 RD_REG_WORD(®->mailbox2),
1613 RD_REG_WORD(®->mailbox3),
1614 RD_REG_WORD(®->mailbox4));
1655 /* enter with host_lock acquired */
1667 fw_data = (const __le16 *)&fw->data[0];
1668 ha->fwstart = __le16_to_cpu(fw_data[2]);
1671 risc_address = ha->fwstart;
1672 fw_data = (const __le16 *)&fw->data[6];
1673 risc_code_size = (fw->size - 6) / 2;
1683 ha->host_no);
1705 /* enter with host_lock acquired */
1715 tbuf = dma_alloc_coherent(&ha->pdev->dev, 8000, &p_tbuf, GFP_KERNEL);
1717 return -ENOMEM;
1724 fw_data = (const __le16 *)&fw->data[0];
1725 ha->fwstart = __le16_to_cpu(fw_data[2]);
1728 risc_address = ha->fwstart;
1729 fw_data = (const __le16 *)&fw->data[6];
1730 risc_code_size = (fw->size - 6) / 2;
1748 ((__le16 *)ha->request_ring)[i] = fw_data[i];
1753 mb[3] = ha->request_dma & 0xffff;
1754 mb[2] = (ha->request_dma >> 16) & 0xffff;
1755 mb[7] = upper_32_bits(ha->request_dma) & 0xffff;
1756 mb[6] = upper_32_bits(ha->request_dma) >> 16;
1759 (void *)(long)ha->request_dma,
1764 "segment of f\n", ha->host_no);
1783 sp = (uint8_t *)ha->request_ring;
1797 risc_code_size = risc_code_size - cnt;
1804 dma_free_coherent(&ha->pdev->dev, 8000, tbuf, p_tbuf);
1821 mb[1] = ha->fwstart;
1824 printk(KERN_ERR "scsi(%li): RISC checksum failed.\n", ha->host_no);
1831 mb[1] = ha->fwstart;
1835 ha->host_no);
1844 /* enter with host_lock taken */
1866 * ha->request_ring = request ring virtual address
1867 * ha->response_ring = response ring virtual address
1868 * ha->request_dma = request ring physical address
1869 * ha->response_dma = response ring physical address
1880 ENTER("qla1280_init_rings");
1883 memset(ha->outstanding_cmds, 0,
1887 ha->request_ring_ptr = ha->request_ring;
1888 ha->req_ring_index = 0;
1889 ha->req_q_cnt = REQUEST_ENTRY_CNT;
1893 mb[3] = ha->request_dma & 0xffff;
1894 mb[2] = (ha->request_dma >> 16) & 0xffff;
1896 mb[7] = upper_32_bits(ha->request_dma) & 0xffff;
1897 mb[6] = upper_32_bits(ha->request_dma) >> 16;
1902 ha->response_ring_ptr = ha->response_ring;
1903 ha->rsp_ring_index = 0;
1907 mb[3] = ha->response_dma & 0xffff;
1908 mb[2] = (ha->response_dma >> 16) & 0xffff;
1910 mb[7] = upper_32_bits(ha->response_dma) & 0xffff;
1911 mb[6] = upper_32_bits(ha->response_dma) >> 16;
1928 nv->bus[0].config_1.initiator_id);
1930 nv->bus[1].config_1.initiator_id);
1933 nv->bus[0].bus_reset_delay);
1935 nv->bus[1].bus_reset_delay);
1937 dprintk(1, "qla1280 : retry count[0]=%d\n", nv->bus[0].retry_count);
1938 dprintk(1, "qla1280 : retry delay[0]=%d\n", nv->bus[0].retry_delay);
1939 dprintk(1, "qla1280 : retry count[1]=%d\n", nv->bus[1].retry_count);
1940 dprintk(1, "qla1280 : retry delay[1]=%d\n", nv->bus[1].retry_delay);
1943 nv->bus[0].config_2.async_data_setup_time);
1945 nv->bus[1].config_2.async_data_setup_time);
1948 nv->bus[0].config_2.req_ack_active_negation);
1950 nv->bus[1].config_2.req_ack_active_negation);
1953 nv->bus[0].config_2.data_line_active_negation);
1955 nv->bus[1].config_2.data_line_active_negation);
1958 nv->cntr_flags_1.disable_loading_risc_code);
1961 nv->cntr_flags_1.enable_64bit_addressing);
1964 nv->bus[0].selection_timeout);
1966 nv->bus[1].selection_timeout);
1969 nv->bus[0].max_queue_depth);
1971 nv->bus[1].max_queue_depth);
1977 struct nvram *nv = &ha->nvram;
1979 nv->bus[bus].target[target].parameter.renegotiate_on_error = 1;
1980 nv->bus[bus].target[target].parameter.auto_request_sense = 1;
1981 nv->bus[bus].target[target].parameter.tag_queuing = 1;
1982 nv->bus[bus].target[target].parameter.enable_sync = 1;
1984 nv->bus[bus].target[target].parameter.enable_wide = 1;
1986 nv->bus[bus].target[target].execution_throttle =
1987 nv->bus[bus].max_queue_depth - 1;
1988 nv->bus[bus].target[target].parameter.parity_checking = 1;
1989 nv->bus[bus].target[target].parameter.disconnect_allowed = 1;
1992 nv->bus[bus].target[target].flags.flags1x160.device_enable = 1;
1993 nv->bus[bus].target[target].flags.flags1x160.sync_offset = 0x0e;
1994 nv->bus[bus].target[target].sync_period = 9;
1995 nv->bus[bus].target[target].ppr_1x160.flags.enable_ppr = 1;
1996 nv->bus[bus].target[target].ppr_1x160.flags.ppr_options = 2;
1997 nv->bus[bus].target[target].ppr_1x160.flags.ppr_bus_width = 1;
1999 nv->bus[bus].target[target].flags.flags1x80.device_enable = 1;
2000 nv->bus[bus].target[target].flags.flags1x80.sync_offset = 12;
2001 nv->bus[bus].target[target].sync_period = 10;
2008 struct nvram *nv = &ha->nvram;
2014 /* nv->cntr_flags_1.disable_loading_risc_code = 1; */
2015 nv->firmware_feature.f.enable_fast_posting = 1;
2016 nv->firmware_feature.f.disable_synchronous_backoff = 1;
2017 nv->termination.scsi_bus_0_control = 3;
2018 nv->termination.scsi_bus_1_control = 3;
2019 nv->termination.auto_term_support = 1;
2022 * Set default FIFO magic - What appropriate values would be here
2029 nv->isp_config.burst_enable = 1;
2031 nv->isp_config.fifo_threshold |= 3;
2033 nv->isp_config.fifo_threshold |= 4;
2036 nv->isp_parameter = 0x01; /* fast memory enable */
2039 nv->bus[bus].config_1.initiator_id = 7;
2040 nv->bus[bus].config_2.req_ack_active_negation = 1;
2041 nv->bus[bus].config_2.data_line_active_negation = 1;
2042 nv->bus[bus].selection_timeout = 250;
2043 nv->bus[bus].max_queue_depth = 32;
2046 nv->bus[bus].bus_reset_delay = 3;
2047 nv->bus[bus].config_2.async_data_setup_time = 6;
2048 nv->bus[bus].retry_delay = 1;
2050 nv->bus[bus].bus_reset_delay = 5;
2051 nv->bus[bus].config_2.async_data_setup_time = 8;
2062 struct nvram *nv = &ha->nvram;
2080 mb[3] = nv->bus[bus].target[target].flags.flags1x160.sync_offset << 8;
2082 mb[3] = nv->bus[bus].target[target].flags.flags1x80.sync_offset << 8;
2083 mb[3] |= nv->bus[bus].target[target].sync_period;
2088 if (nv->bus[bus].target[target].parameter.tag_queuing)
2089 ha->bus_settings[bus].qtag_enables |= flag;
2093 if (nv->bus[bus].target[target].flags.flags1x160.device_enable)
2094 ha->bus_settings[bus].device_enables |= flag;
2095 ha->bus_settings[bus].lun_disables |= 0;
2097 if (nv->bus[bus].target[target].flags.flags1x80.device_enable)
2098 ha->bus_settings[bus].device_enables |= flag;
2100 if (nv->bus[bus].target[target].flags.flags1x80.lun_disable)
2101 ha->bus_settings[bus].lun_disables |= flag;
2109 mb[2] = nv->bus[bus].max_queue_depth;
2110 mb[3] = nv->bus[bus].target[target].execution_throttle;
2120 struct nvram *nv = &ha->nvram;
2125 ha->bus_settings[bus].disable_scsi_reset =
2126 nv->bus[bus].config_1.scsi_reset_disable;
2129 ha->bus_settings[bus].id = nv->bus[bus].config_1.initiator_id;
2131 mb[1] = bus ? ha->bus_settings[bus].id | BIT_7 :
2132 ha->bus_settings[bus].id;
2136 ha->bus_settings[bus].bus_reset_delay =
2137 nv->bus[bus].bus_reset_delay;
2140 ha->bus_settings[bus].hiwat = nv->bus[bus].max_queue_depth - 1;
2152 struct device_reg __iomem *reg = ha->iobase;
2153 struct nvram *nv = &ha->nvram;
2157 ENTER("qla1280_nvram_config");
2159 if (ha->nvram_valid) {
2163 nv->bus[bus].target[target].parameter.
2173 ha->flags.disable_risc_code_load =
2174 nv->cntr_flags_1.disable_loading_risc_code;
2179 hwrev = RD_REG_WORD(®->cfg_0) & ISP_CFG0_HWMSK;
2181 cfg1 = RD_REG_WORD(®->cfg_1) & ~(BIT_4 | BIT_5 | BIT_6);
2182 cdma_conf = RD_REG_WORD(®->cdma_cfg);
2186 cfg1 |= nv->isp_config.fifo_threshold << 4;
2188 cfg1 |= nv->isp_config.burst_enable << 2;
2189 WRT_REG_WORD(®->cfg_1, cfg1);
2191 WRT_REG_WORD(®->cdma_cfg, cdma_conf | CDMA_CONF_BENAB);
2192 WRT_REG_WORD(®->ddma_cfg, cdma_conf | DDMA_CONF_BENAB);
2197 cfg1 = nv->isp_config.fifo_threshold << 4;
2198 cfg1 |= nv->isp_config.burst_enable << 2;
2200 if (ha->ports > 1)
2202 WRT_REG_WORD(®->cfg_1, cfg1);
2205 WRT_REG_WORD(®->gpio_enable,
2207 term = nv->termination.scsi_bus_1_control;
2208 term |= nv->termination.scsi_bus_0_control << 2;
2209 term |= nv->termination.auto_term_support << 7;
2210 RD_REG_WORD(®->id_l); /* Flush PCI write */
2211 WRT_REG_WORD(®->gpio_data, term);
2213 RD_REG_WORD(®->id_l); /* Flush PCI write */
2217 mb[1] = nv->isp_parameter;
2221 /* clock rate - for qla1240 and older, only */
2229 mb[1] = nv->firmware_feature.f.enable_fast_posting;
2230 mb[1] |= nv->firmware_feature.f.report_lvd_bus_transition << 1;
2231 mb[1] |= nv->firmware_feature.f.disable_synchronous_backoff << 5;
2236 mb[1] = nv->bus[0].retry_count;
2237 mb[2] = nv->bus[0].retry_delay;
2238 mb[6] = nv->bus[1].retry_count;
2239 mb[7] = nv->bus[1].retry_delay;
2245 mb[1] = nv->bus[0].config_2.async_data_setup_time;
2246 mb[2] = nv->bus[1].config_2.async_data_setup_time;
2252 if (nv->bus[0].config_2.req_ack_active_negation)
2254 if (nv->bus[0].config_2.data_line_active_negation)
2257 if (nv->bus[1].config_2.req_ack_active_negation)
2259 if (nv->bus[1].config_2.data_line_active_negation)
2279 mb[1] = nv->bus[0].selection_timeout;
2280 mb[2] = nv->bus[1].selection_timeout;
2283 for (bus = 0; bus < ha->ports; bus++)
2330 * Bit 23-16 = address
2331 * Bit 15-0 = write data
2339 struct device_reg __iomem *reg = ha->iobase;
2358 WRT_REG_WORD(®->nvram, (NV_SELECT | NV_CLOCK));
2359 RD_REG_WORD(®->id_l); /* Flush PCI write */
2362 reg_data = RD_REG_WORD(®->nvram);
2365 WRT_REG_WORD(®->nvram, NV_SELECT);
2366 RD_REG_WORD(®->id_l); /* Flush PCI write */
2372 WRT_REG_WORD(®->nvram, NV_DESELECT);
2373 RD_REG_WORD(®->id_l); /* Flush PCI write */
2382 struct device_reg __iomem *reg = ha->iobase;
2384 WRT_REG_WORD(®->nvram, data | NV_SELECT);
2385 RD_REG_WORD(®->id_l); /* Flush PCI write */
2387 WRT_REG_WORD(®->nvram, data | NV_SELECT | NV_CLOCK);
2388 RD_REG_WORD(®->id_l); /* Flush PCI write */
2390 WRT_REG_WORD(®->nvram, data | NV_SELECT);
2391 RD_REG_WORD(®->id_l); /* Flush PCI write */
2413 struct device_reg __iomem *reg = ha->iobase;
2420 ENTER("qla1280_mailbox_command");
2422 if (ha->mailbox_wait) {
2425 ha->mailbox_wait = &wait;
2432 mptr = (uint16_t __iomem *) ®->mailbox0;
2447 timer_setup(&ha->mailbox_timer, qla1280_mailbox_timeout, 0);
2448 mod_timer(&ha->mailbox_timer, jiffies + 20 * HZ);
2450 spin_unlock_irq(ha->host->host_lock);
2451 WRT_REG_WORD(®->host_cmd, HC_SET_HOST_INT);
2452 qla1280_debounce_register(®->istatus);
2455 del_timer_sync(&ha->mailbox_timer);
2457 spin_lock_irq(ha->host->host_lock);
2459 ha->mailbox_wait = NULL;
2462 if (ha->mailbox_out[0] != MBS_CMD_CMP) {
2466 mb[0], ha->mailbox_out[0], RD_REG_WORD(®->istatus));
2468 RD_REG_WORD(®->mailbox0), RD_REG_WORD(®->mailbox1),
2469 RD_REG_WORD(®->mailbox2), RD_REG_WORD(®->mailbox3));
2471 RD_REG_WORD(®->mailbox4), RD_REG_WORD(®->mailbox5),
2472 RD_REG_WORD(®->mailbox6), RD_REG_WORD(®->mailbox7));
2478 iptr = (uint16_t *) &ha->mailbox_out[0];
2482 if (ha->flags.reset_marker)
2503 struct device_reg __iomem *reg = ha->iobase;
2507 /* ENTER("qla1280_poll"); */
2510 data = RD_REG_WORD(®->istatus);
2514 if (!ha->mailbox_wait) {
2515 if (ha->flags.reset_marker)
2547 ha->host_no, bus);
2549 reset_delay = ha->bus_settings[bus].bus_reset_delay;
2556 if (ha->bus_settings[bus].failed_reset_count > 2)
2557 ha->bus_settings[bus].scsi_bus_dead = 1;
2558 ha->bus_settings[bus].failed_reset_count++;
2560 spin_unlock_irq(ha->host->host_lock);
2562 spin_lock_irq(ha->host->host_lock);
2564 ha->bus_settings[bus].scsi_bus_dead = 0;
2565 ha->bus_settings[bus].failed_reset_count = 0;
2566 ha->bus_settings[bus].reset_marker = 0;
2602 ENTER("qla1280_device_reset");
2637 ENTER("qla1280_abort_command");
2639 bus = SCSI_BUS_32(sp->cmd);
2640 target = SCSI_TCN_32(sp->cmd);
2641 lun = SCSI_LUN_32(sp->cmd);
2643 sp->flags |= SRB_ABORT_PENDING;
2653 sp->flags &= ~SRB_ABORT_PENDING;
2671 struct device_reg __iomem *reg = ha->iobase;
2673 ENTER("qla1280_reset_adapter");
2676 ha->flags.online = 0;
2677 WRT_REG_WORD(®->ictrl, ISP_RESET);
2678 WRT_REG_WORD(®->host_cmd,
2680 RD_REG_WORD(®->id_l); /* Flush PCI write */
2701 ENTER("qla1280_marker");
2705 pkt->entry_type = MARKER_TYPE;
2706 pkt->lun = (uint8_t) lun;
2707 pkt->target = (uint8_t) (bus ? (id | BIT_7) : id);
2708 pkt->modifier = type;
2709 pkt->entry_status = 0;
2735 struct device_reg __iomem *reg = ha->iobase;
2736 struct scsi_cmnd *cmd = sp->cmd;
2746 ENTER("qla1280_64bit_start_scsi:");
2753 req_cnt += (seg_cnt - 2) / 5;
2754 if ((seg_cnt - 2) % 5)
2762 if ((req_cnt + 2) >= ha->req_q_cnt) {
2764 cnt = RD_REG_WORD(®->mailbox4);
2765 if (ha->req_ring_index < cnt)
2766 ha->req_q_cnt = cnt - ha->req_ring_index;
2768 ha->req_q_cnt =
2769 REQUEST_ENTRY_CNT - (ha->req_ring_index - cnt);
2773 ha->req_q_cnt, seg_cnt);
2776 if ((req_cnt + 2) >= ha->req_q_cnt) {
2778 dprintk(2, "qla1280_start_scsi: in-ptr=0x%x req_q_cnt="
2779 "0x%xreq_cnt=0x%x", ha->req_ring_index, ha->req_q_cnt,
2786 ha->outstanding_cmds[cnt] != NULL; cnt++);
2791 "OUTSTANDING ARRAY, req_q_cnt=0x%x", ha->req_q_cnt);
2795 ha->outstanding_cmds[cnt] = sp;
2796 ha->req_q_cnt -= req_cnt;
2797 CMD_HANDLE(sp->cmd) = (unsigned char *)(unsigned long)(cnt + 1);
2800 cmd->cmnd[0], (long)CMD_HANDLE(sp->cmd));
2803 qla1280_dump_buffer(2, cmd->cmnd, MAX_COMMAND_SIZE);
2808 pkt = (cmd_a64_entry_t *) ha->request_ring_ptr;
2810 pkt->entry_type = COMMAND_A64_TYPE;
2811 pkt->entry_count = (uint8_t) req_cnt;
2812 pkt->sys_define = (uint8_t) ha->req_ring_index;
2813 pkt->entry_status = 0;
2814 pkt->handle = cpu_to_le32(cnt);
2817 memset(((char *)pkt + 8), 0, (REQUEST_ENTRY_SIZE - 8));
2820 pkt->timeout = cpu_to_le16(scsi_cmd_to_rq(cmd)->timeout / HZ);
2823 pkt->lun = SCSI_LUN_32(cmd);
2824 pkt->target = SCSI_BUS_32(cmd) ?
2828 if (cmd->device->simple_tags)
2829 pkt->control_flags |= cpu_to_le16(BIT_3);
2832 pkt->cdb_len = cpu_to_le16(CMD_CDBLEN(cmd));
2833 memcpy(pkt->scsi_cdb, CMD_CDBP(cmd), CMD_CDBLEN(cmd));
2834 /* dprintk(1, "Build packet for command[0]=0x%x\n",pkt->scsi_cdb[0]); */
2838 pkt->control_flags |= cpu_to_le16(dir);
2841 pkt->dseg_count = cpu_to_le16(seg_cnt);
2853 dword_ptr = (u32 *)&pkt->dseg_0_address;
2870 remseg--;
2873 "command packet data - b %i, t %i, l %i \n",
2889 ha->req_ring_index++;
2890 if (ha->req_ring_index == REQUEST_ENTRY_CNT) {
2891 ha->req_ring_index = 0;
2892 ha->request_ring_ptr =
2893 ha->request_ring;
2895 ha->request_ring_ptr++;
2897 pkt = (cmd_a64_entry_t *)ha->request_ring_ptr;
2903 ((struct cont_a64_entry *) pkt)->entry_type =
2905 ((struct cont_a64_entry *) pkt)->entry_count = 1;
2906 ((struct cont_a64_entry *) pkt)->sys_define =
2907 (uint8_t)ha->req_ring_index;
2910 (u32 *)&((struct cont_a64_entry *) pkt)->dseg_0_address;
2928 remseg -= cnt;
2930 "continuation packet data - b %i, t "
2938 "packet data - b %i, t %i, l %i \n",
2943 ha->req_ring_index++;
2944 if (ha->req_ring_index == REQUEST_ENTRY_CNT) {
2945 ha->req_ring_index = 0;
2946 ha->request_ring_ptr = ha->request_ring;
2948 ha->request_ring_ptr++;
2953 sp->flags |= SRB_SENT;
2954 ha->actthreads++;
2955 WRT_REG_WORD(®->mailbox4, ha->req_ring_index);
2989 struct device_reg __iomem *reg = ha->iobase;
2990 struct scsi_cmnd *cmd = sp->cmd;
2999 ENTER("qla1280_32bit_start_scsi");
3002 cmd->cmnd[0]);
3013 req_cnt += (seg_cnt - 4) / 7;
3014 if ((seg_cnt - 4) % 7)
3024 if ((req_cnt + 2) >= ha->req_q_cnt) {
3026 cnt = RD_REG_WORD(®->mailbox4);
3027 if (ha->req_ring_index < cnt)
3028 ha->req_q_cnt = cnt - ha->req_ring_index;
3030 ha->req_q_cnt =
3031 REQUEST_ENTRY_CNT - (ha->req_ring_index - cnt);
3035 ha->req_q_cnt, seg_cnt);
3037 if ((req_cnt + 2) >= ha->req_q_cnt) {
3039 dprintk(2, "qla1280_32bit_start_scsi: in-ptr=0x%x, "
3040 "req_q_cnt=0x%x, req_cnt=0x%x", ha->req_ring_index,
3041 ha->req_q_cnt, req_cnt);
3047 ha->outstanding_cmds[cnt]; cnt++);
3052 "ARRAY, req_q_cnt=0x%x\n", ha->req_q_cnt);
3056 CMD_HANDLE(sp->cmd) = (unsigned char *) (unsigned long)(cnt + 1);
3057 ha->outstanding_cmds[cnt] = sp;
3058 ha->req_q_cnt -= req_cnt;
3063 pkt = (struct cmd_entry *) ha->request_ring_ptr;
3065 pkt->entry_type = COMMAND_TYPE;
3066 pkt->entry_count = (uint8_t) req_cnt;
3067 pkt->sys_define = (uint8_t) ha->req_ring_index;
3068 pkt->entry_status = 0;
3069 pkt->handle = cpu_to_le32(cnt);
3072 memset(((char *)pkt + 8), 0, (REQUEST_ENTRY_SIZE - 8));
3075 pkt->timeout = cpu_to_le16(scsi_cmd_to_rq(cmd)->timeout / HZ);
3078 pkt->lun = SCSI_LUN_32(cmd);
3079 pkt->target = SCSI_BUS_32(cmd) ?
3083 if (cmd->device->simple_tags)
3084 pkt->control_flags |= cpu_to_le16(BIT_3);
3087 pkt->cdb_len = cpu_to_le16(CMD_CDBLEN(cmd));
3088 memcpy(pkt->scsi_cdb, CMD_CDBP(cmd), CMD_CDBLEN(cmd));
3090 /*dprintk(1, "Build packet for command[0]=0x%x\n",pkt->scsi_cdb[0]); */
3093 pkt->control_flags |= cpu_to_le16(dir);
3096 pkt->dseg_count = cpu_to_le16(seg_cnt);
3108 dword_ptr = &pkt->dseg_0_address;
3123 remseg--;
3134 ha->req_ring_index++;
3135 if (ha->req_ring_index == REQUEST_ENTRY_CNT) {
3136 ha->req_ring_index = 0;
3137 ha->request_ring_ptr =
3138 ha->request_ring;
3140 ha->request_ring_ptr++;
3142 pkt = (struct cmd_entry *)ha->request_ring_ptr;
3148 ((struct cont_entry *) pkt)->
3150 ((struct cont_entry *) pkt)->entry_count = 1;
3152 ((struct cont_entry *) pkt)->sys_define =
3153 (uint8_t) ha->req_ring_index;
3157 &((struct cont_entry *) pkt)->dseg_0_address;
3173 remseg -= cnt;
3175 "continuation packet data - "
3183 "packet data - \n");
3187 qla1280_dump_buffer(5, (char *)ha->request_ring_ptr,
3191 ha->req_ring_index++;
3192 if (ha->req_ring_index == REQUEST_ENTRY_CNT) {
3193 ha->req_ring_index = 0;
3194 ha->request_ring_ptr = ha->request_ring;
3196 ha->request_ring_ptr++;
3201 sp->flags |= SRB_SENT;
3202 ha->actthreads++;
3203 WRT_REG_WORD(®->mailbox4, ha->req_ring_index);
3229 struct device_reg __iomem *reg = ha->iobase;
3234 ENTER("qla1280_req_pkt");
3240 for (timer = 15000000; timer; timer--) {
3241 if (ha->req_q_cnt > 0) {
3243 cnt = RD_REG_WORD(®->mailbox4);
3244 if (ha->req_ring_index < cnt)
3245 ha->req_q_cnt = cnt - ha->req_ring_index;
3247 ha->req_q_cnt =
3248 REQUEST_ENTRY_CNT - (ha->req_ring_index - cnt);
3252 if (ha->req_q_cnt > 0) {
3253 ha->req_q_cnt--;
3254 pkt = ha->request_ring_ptr;
3264 pkt->sys_define = (uint8_t) ha->req_ring_index;
3267 pkt->entry_count = 1;
3297 struct device_reg __iomem *reg = ha->iobase;
3299 ENTER("qla1280_isp_cmd");
3302 qla1280_dump_buffer(5, (char *)ha->request_ring_ptr,
3306 ha->req_ring_index++;
3307 if (ha->req_ring_index == REQUEST_ENTRY_CNT) {
3308 ha->req_ring_index = 0;
3309 ha->request_ring_ptr = ha->request_ring;
3311 ha->request_ring_ptr++;
3316 WRT_REG_WORD(®->mailbox4, ha->req_ring_index);
3336 struct device_reg __iomem *reg = ha->iobase;
3344 ENTER("qla1280_isr");
3346 istatus = RD_REG_WORD(®->istatus);
3351 mailbox[5] = RD_REG_WORD(®->mailbox5);
3355 mailbox[0] = RD_REG_WORD_dmasync(®->semaphore);
3362 *wptr++ = RD_REG_WORD(®->mailbox0);
3363 *wptr++ = RD_REG_WORD(®->mailbox1);
3364 *wptr = RD_REG_WORD(®->mailbox2);
3367 *wptr++ = RD_REG_WORD(®->mailbox3);
3368 *wptr++ = RD_REG_WORD(®->mailbox4);
3370 *wptr++ = RD_REG_WORD(®->mailbox6);
3371 *wptr = RD_REG_WORD(®->mailbox7);
3376 WRT_REG_WORD(®->semaphore, 0);
3377 WRT_REG_WORD(®->host_cmd, HC_CLR_RISC_INT);
3388 if (ha->flags.online) {
3394 sp = ha->outstanding_cmds[index];
3400 ha->outstanding_cmds[index] = NULL;
3403 CMD_RESULT(sp->cmd) = 0;
3404 CMD_HANDLE(sp->cmd) = COMPLETED_HANDLE;
3407 list_add_tail(&sp->list, done_q);
3419 ha->flags.reset_marker = 1;
3421 ha->bus_settings[index].reset_marker = 1;
3429 "qla1280: ISP System Error - mbx1=%xh, mbx2="
3444 case MBA_WAKEUP_THRES: /* Request Queue Wake-up */
3457 ha->flags.reset_marker = 1;
3459 ha->bus_settings[index].reset_marker = 1;
3471 memcpy((uint16_t *) ha->mailbox_out, wptr,
3475 if(ha->mailbox_wait != NULL)
3476 complete(ha->mailbox_wait);
3481 WRT_REG_WORD(®->host_cmd, HC_CLR_RISC_INT);
3488 if (!(ha->flags.online && !ha->mailbox_wait)) {
3496 while (ha->rsp_ring_index != mailbox[5]) {
3497 pkt = ha->response_ring_ptr;
3499 dprintk(5, "qla1280_isr: ha->rsp_ring_index = 0x%x, mailbox[5]"
3500 " = 0x%x\n", ha->rsp_ring_index, mailbox[5]);
3504 if (pkt->entry_type == STATUS_TYPE) {
3505 if ((le16_to_cpu(pkt->scsi_status) & 0xff)
3506 || pkt->comp_status || pkt->entry_status) {
3507 dprintk(2, "qla1280_isr: ha->rsp_ring_index = "
3510 ha->rsp_ring_index, mailbox[5],
3511 le16_to_cpu(pkt->comp_status),
3512 le16_to_cpu(pkt->scsi_status));
3515 dprintk(2, "qla1280_isr: ha->rsp_ring_index = "
3517 ha->rsp_ring_index, mailbox[5]);
3523 if (pkt->entry_type == STATUS_TYPE || pkt->entry_status) {
3525 ha->outstanding_cmds[pkt->handle]->cmd,
3526 pkt->handle);
3527 if (pkt->entry_type == STATUS_TYPE)
3532 ha->rsp_ring_index++;
3533 if (ha->rsp_ring_index == RESPONSE_ENTRY_CNT) {
3534 ha->rsp_ring_index = 0;
3535 ha->response_ring_ptr = ha->response_ring;
3537 ha->response_ring_ptr++;
3538 WRT_REG_WORD(®->mailbox5, ha->rsp_ring_index);
3558 ENTER("qla1280_rst_aen");
3560 if (ha->flags.online && !ha->flags.reset_active &&
3561 !ha->flags.abort_isp_active) {
3562 ha->flags.reset_active = 1;
3563 while (ha->flags.reset_marker) {
3565 ha->flags.reset_marker = 0;
3566 for (bus = 0; bus < ha->ports &&
3567 !ha->flags.reset_marker; bus++) {
3568 if (ha->bus_settings[bus].reset_marker) {
3569 ha->bus_settings[bus].reset_marker = 0;
3597 uint32_t handle = le32_to_cpu(pkt->handle);
3598 uint16_t scsi_status = le16_to_cpu(pkt->scsi_status);
3599 uint16_t comp_status = le16_to_cpu(pkt->comp_status);
3601 ENTER("qla1280_status_entry");
3605 sp = ha->outstanding_cmds[handle];
3615 ha->outstanding_cmds[handle] = NULL;
3617 cmd = sp->cmd;
3637 le16_to_cpu(pkt->req_sense_length);
3642 * scsi_cmnd->sense_buffer is
3646 sense_sz = CMD_SNSLEN(cmd) - 1;
3648 memcpy(cmd->sense_buffer,
3649 &pkt->req_sense_data, sense_sz);
3652 memset(cmd->sense_buffer + sense_sz, 0,
3653 SCSI_SENSE_BUFFERSIZE - sense_sz);
3661 (char *)cmd->sense_buffer,
3666 CMD_HANDLE(sp->cmd) = COMPLETED_HANDLE;
3669 list_add_tail(&sp->list, done_q);
3688 uint32_t handle = le32_to_cpu(pkt->handle);
3690 ENTER("qla1280_error_entry");
3692 if (pkt->entry_status & BIT_3)
3694 else if (pkt->entry_status & BIT_2)
3696 else if (pkt->entry_status & BIT_1)
3703 sp = ha->outstanding_cmds[handle];
3709 ha->outstanding_cmds[handle] = NULL;
3712 if (pkt->entry_status & (BIT_3 + BIT_2)) {
3714 /* CMD_RESULT(sp->cmd) = CS_BAD_PAYLOAD; */
3715 CMD_RESULT(sp->cmd) = DID_ERROR << 16;
3716 } else if (pkt->entry_status & BIT_1) { /* FULL flag */
3717 CMD_RESULT(sp->cmd) = DID_BUS_BUSY << 16;
3720 CMD_RESULT(sp->cmd) = DID_ERROR << 16;
3723 CMD_HANDLE(sp->cmd) = COMPLETED_HANDLE;
3726 list_add_tail(&sp->list, done_q);
3729 else if (pkt->entry_type == COMMAND_A64_TYPE) {
3750 struct device_reg __iomem *reg = ha->iobase;
3756 ENTER("qla1280_abort_isp");
3758 if (ha->flags.abort_isp_active || !ha->flags.online)
3761 ha->flags.abort_isp_active = 1;
3765 WRT_REG_WORD(®->host_cmd, HC_PAUSE_RISC);
3766 RD_REG_WORD(®->id_l);
3769 ha->host_no);
3773 sp = ha->outstanding_cmds[cnt];
3775 cmd = sp->cmd;
3778 ha->outstanding_cmds[cnt] = NULL;
3779 list_add_tail(&sp->list, &ha->done_q);
3797 for (bus = 0; bus < ha->ports; bus++)
3800 ha->flags.abort_isp_active = 0;
3816 * Debounce register.
3857 struct device_reg __iomem *reg = ha->iobase;
3859 if (ha->bus_settings[bus].scsi_bus_dead) {
3860 WRT_REG_WORD(®->host_cmd, HC_PAUSE_RISC);
3861 config_reg = RD_REG_WORD(®->cfg_1);
3862 WRT_REG_WORD(®->cfg_1, SET_SXP_BANK);
3863 scsi_control = RD_REG_WORD(®->scsiControlPins);
3864 WRT_REG_WORD(®->cfg_1, config_reg);
3865 WRT_REG_WORD(®->host_cmd, HC_RELEASE_RISC);
3868 ha->bus_settings[bus].scsi_bus_dead = 1;
3871 ha->bus_settings[bus].scsi_bus_dead = 0;
3872 ha->bus_settings[bus].failed_reset_count = 0;
3885 bus = device->channel;
3886 target = device->id;
3887 lun = device->lun;
3896 printk(KERN_INFO "scsi(%li:%d:%d:%d):", ha->host_no, bus, target, lun);
3908 if (device->simple_tags)
3909 printk(KERN_CONT ", Tagged queuing: depth %d", device->queue_depth);
3923 printk(KERN_DEBUG "---------------------------------------------"
3924 "------------------\n");
3953 ha = (struct scsi_qla_host *)host->hostdata;
3961 for (i = 0; i < cmd->cmd_len; i++) {
3962 printk("0x%02x ", cmd->cmnd[i]);
3967 /* if (cmd->use_sg)
3969 sg = (struct scatterlist *) cmd->request_buffer;
3971 qla1280_dump_buffer(1, (char *)sg, (cmd->use_sg*sizeof(struct scatterlist)));
3974 scsi_cmd_to_rq(cmd)->tag, cmd->transfersize);
3976 cmd->underflow, cmd->sc_data_direction);
3994 if ((sp = ha->outstanding_cmds[i]) == NULL)
3996 if ((cp = sp->cmd) == NULL)
4100 long ret = -1;
4107 if (!strncmp(setup_token[i].token, str, (sep - str))) {
4131 .this_id = -1,
4140 int devnum = id->driver_data;
4144 int error = -ENODEV;
4147 if (pdev->subsystem_vendor == PCI_VENDOR_ID_AMI) {
4154 bdp->name, pdev->bus->number, PCI_SLOT(pdev->devfn));
4164 error = -ENOMEM;
4172 ha = (struct scsi_qla_host *)host->hostdata;
4175 ha->pdev = pdev;
4176 ha->devnum = devnum; /* specifies microcode load address */
4179 if (dma_set_mask_and_coherent(&ha->pdev->dev, DMA_BIT_MASK(64))) {
4180 if (dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(32))) {
4182 "suitable DMA mask - aborting\n", ha->host_no);
4183 error = -ENODEV;
4188 ha->host_no);
4190 if (dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(32))) {
4192 "suitable DMA mask - aborting\n", ha->host_no);
4193 error = -ENODEV;
4198 ha->request_ring = dma_alloc_coherent(&ha->pdev->dev,
4200 &ha->request_dma, GFP_KERNEL);
4201 if (!ha->request_ring) {
4206 ha->response_ring = dma_alloc_coherent(&ha->pdev->dev,
4208 &ha->response_dma, GFP_KERNEL);
4209 if (!ha->response_ring) {
4214 ha->ports = bdp->numPorts;
4216 ha->host = host;
4217 ha->host_no = host->host_no;
4219 host->irq = pdev->irq;
4220 host->max_channel = bdp->numPorts - 1;
4221 host->max_lun = MAX_LUNS - 1;
4222 host->max_id = MAX_TARGETS;
4223 host->max_sectors = 1024;
4224 host->unique_id = host->host_no;
4226 error = -ENODEV;
4229 ha->mmpbase = pci_ioremap_bar(ha->pdev, 1);
4230 if (!ha->mmpbase) {
4235 host->base = (unsigned long)ha->mmpbase;
4236 ha->iobase = (struct device_reg __iomem *)ha->mmpbase;
4238 host->io_port = pci_resource_start(ha->pdev, 0);
4239 if (!request_region(host->io_port, 0xff, "qla1280")) {
4241 "0x%04lx-0x%04lx - already in use\n",
4242 host->io_port, host->io_port + 0xff);
4246 ha->iobase = (struct device_reg *)host->io_port;
4249 INIT_LIST_HEAD(&ha->done_q);
4254 if (request_irq(pdev->irq, qla1280_intr_handler, IRQF_SHARED,
4257 "in use\n", pdev->irq);
4268 host->this_id = ha->bus_settings[0].id;
4272 error = scsi_add_host(host, &pdev->dev);
4282 free_irq(pdev->irq, ha);
4285 iounmap(ha->mmpbase);
4287 release_region(host->io_port, 0xff);
4290 dma_free_coherent(&ha->pdev->dev,
4292 ha->response_ring, ha->response_dma);
4294 dma_free_coherent(&ha->pdev->dev,
4296 ha->request_ring, ha->request_dma);
4310 struct scsi_qla_host *ha = (struct scsi_qla_host *)host->hostdata;
4316 free_irq(pdev->irq, ha);
4319 iounmap(ha->mmpbase);
4321 release_region(host->io_port, 0xff);
4324 dma_free_coherent(&ha->pdev->dev,
4326 ha->request_ring, ha->request_dma);
4327 dma_free_coherent(&ha->pdev->dev,
4329 ha->response_ring, ha->response_dma);