Lines Matching +full:static +full:- +full:beta

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
92 Rev 3.23.26 Beta May 28, 2003, Jes Sorensen
93 - Use completion queue for mailbox commands instead of busy wait
94 Rev 3.23.25 Beta May 27, 2003, James Bottomley
95 - Migrate to use new error handling code
96 Rev 3.23.24 Beta May 21, 2003, James Bottomley
97 - Big endian support
98 - Cleanup data direction code
99 Rev 3.23.23 Beta May 12, 2003, Jes Sorensen
100 - Switch to using MMIO instead of PIO
101 Rev 3.23.22 Beta April 15, 2003, Jes Sorensen
102 - Fix PCI parity problem with 12160 during reset.
103 Rev 3.23.21 Beta April 14, 2003, Jes Sorensen
104 - Use pci_map_page()/pci_unmap_page() instead of map_single version.
105 Rev 3.23.20 Beta April 9, 2003, Jes Sorensen
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
110 Rev 3.23.19 Beta April 11, 2002, Linus Torvalds
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
116 Rev 3.23.18 Beta April 11, 2002, Jes Sorensen
117 - Run source through Lindent and clean up the output
118 Rev 3.23.17 Beta April 11, 2002, Jes Sorensen
119 - Update SCSI firmware to qla1280 v8.15.00 and qla12160 v10.04.32
120 Rev 3.23.16 Beta March 19, 2002, Jes Sorensen
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!!!
128 Rev 3.23.15 Beta March 19, 2002, Jes Sorensen
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
141 Rev 3.23.14 Beta March 14, 2002, Jes Sorensen
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()
147 Rev 3.23.13 Beta March 14, 2002, Jes Sorensen
148 - Significant cosmetic cleanups
149 - Change debug code to use dprintk() and remove #if mess
150 Rev 3.23.12 Beta March 13, 2002, Jes Sorensen
151 - More cosmetic cleanups, fix places treating return as function
152 - use cpu_relax() in qla1280_debounce_register()
153 Rev 3.23.11 Beta March 13, 2002, Jes Sorensen
154 - Make it compile under 2.5.5
155 Rev 3.23.10 Beta October 1, 2001, Jes Sorensen
156 - Do no typecast short * to long * in QL1280BoardTbl, this
158 Rev 3.23.9 Beta September 30, 2001, Jes Sorensen
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
162 Rev 3.23.8 Beta September 29, 2001, Jes Sorensen
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
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
179 Rev 3.23.7 Beta August 20, 2001, Jes Sorensen
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()
187 Rev 3.23.6 Beta August 20, 2001, Tony Luck, Intel
188 - Don't walk the entire list in qla1280_putq_t() just to directly
190 Rev 3.23.5 Beta August 9, 2001, Jes Sorensen
191 - Don't use IRQF_DISABLED, it's use is deprecated for this kinda driver
192 Rev 3.23.4 Beta August 8, 2001, Jes Sorensen
193 - Set dev->max_sectors to 1024
194 Rev 3.23.3 Beta August 6, 2001, Jes Sorensen
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
205 Rev 3.23.2 Beta August 6, 2001, Jes Sorensen
206 - Change home-brew memset() implementations to use memset()
207 - Remove all references to COMTRACE() - accessing a PC's COM2 serial
209 Rev 3.23.1 Beta April 24, 2001, Jes Sorensen
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
218 Rev 3.23 Beta January 11, 2001 BN Qlogic
219 - Added check of device_id when handling non
221 Rev 3.22 Beta January 5, 2001 BN Qlogic
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__
232 Rev 3.21 Beta January 4, 2001 BN Qlogic
233 - Changed criteria of 64/32 Bit mode of HBA
236 so that the HBA auto-configures without the need
238 Rev 3.20 Beta December 5, 2000 BN Qlogic
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().
244 Rev 3.19 Beta October 13, 2000 BN Qlogic
245 - Declare driver_template for new kernel
247 - Update /proc/scsi entry for 2.3.18 kernels and
249 Rev 3.18 Beta October 10, 2000 BN Qlogic
250 - Changed scan order of adapters to map
252 Rev 3.17 Beta September 18, 2000 BN Qlogic
253 - Removed warnings for 32 bit 2.4.x compiles
254 - Corrected declared size for request and response
256 Rev. 3.16 Beta August 25, 2000 BN Qlogic
257 - Corrected 64 bit addressing issue on IA-64
260 Rev. 3.15 Beta August 22, 2000 BN Qlogic
261 - Modified qla1280_setup_chip to properly load
262 ISP firmware for greater that 4 Gig memory on IA-64
263 Rev. 3.14 Beta August 16, 2000 BN Qlogic
264 - Added setting of dma_mask to full 64 bit
266 Rev. 3.13 Beta August 16, 2000 BN Qlogic
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)
386 static int qla1280_probe_one(struct pci_dev *, const struct pci_device_id *);
387 static void qla1280_remove_one(struct pci_dev *);
392 static void qla1280_done(struct scsi_qla_host *);
393 static int qla1280_get_token(char *);
394 static int qla1280_setup(char *s) __init;
399 static int qla1280_load_firmware(struct scsi_qla_host *);
400 static int qla1280_init_rings(struct scsi_qla_host *);
401 static int qla1280_nvram_config(struct scsi_qla_host *);
402 static int qla1280_mailbox_command(struct scsi_qla_host *,
404 static int qla1280_bus_reset(struct scsi_qla_host *, int);
405 static int qla1280_device_reset(struct scsi_qla_host *, int, int);
406 static int qla1280_abort_command(struct scsi_qla_host *, struct srb *, int);
407 static int qla1280_abort_isp(struct scsi_qla_host *);
409 static int qla1280_64bit_start_scsi(struct scsi_qla_host *, struct srb *);
411 static int qla1280_32bit_start_scsi(struct scsi_qla_host *, struct srb *);
413 static void qla1280_nv_write(struct scsi_qla_host *, uint16_t);
414 static void qla1280_poll(struct scsi_qla_host *);
415 static void qla1280_reset_adapter(struct scsi_qla_host *);
416 static void qla1280_marker(struct scsi_qla_host *, int, int, int, u8);
417 static void qla1280_isp_cmd(struct scsi_qla_host *);
418 static void qla1280_isr(struct scsi_qla_host *, struct list_head *);
419 static void qla1280_rst_aen(struct scsi_qla_host *);
420 static void qla1280_status_entry(struct scsi_qla_host *, struct response *,
422 static void qla1280_error_entry(struct scsi_qla_host *, struct response *,
424 static uint16_t qla1280_get_nvram_word(struct scsi_qla_host *, uint32_t);
425 static uint16_t qla1280_nvram_request(struct scsi_qla_host *, uint32_t);
426 static uint16_t qla1280_debounce_register(volatile uint16_t __iomem *);
427 static request_t *qla1280_req_pkt(struct scsi_qla_host *);
428 static int qla1280_check_for_dead_scsi_bus(struct scsi_qla_host *,
430 static void qla1280_get_target_parameters(struct scsi_qla_host *,
432 static int qla1280_set_target_parameters(struct scsi_qla_host *, int, int);
435 static struct qla_driver_setup driver_setup;
440 static inline uint16_t
443 switch(cmnd->sc_data_direction) { in qla1280_data_direction()
462 static void __qla1280_print_scsi_cmd(struct scsi_cmnd * cmd);
463 static void __qla1280_dump_buffer(char *, int);
471 static char *qla1280;
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
504 static struct pci_device_id qla1280_pci_tbl[] = {
521 static DEFINE_MUTEX(qla1280_firmware_mutex);
530 static struct qla_fw qla1280_fw_tbl[QL_NUM_FW_IMAGES] = {
537 static struct qla_boards ql1280_board_tbl[] = {
544 {.name = " ", .numPorts = 0, .fw_index = -1},
547 static int qla1280_verbose = 1;
550 static int ql_debug_level = 1;
570 static int qla1280_read_nvram(struct scsi_qla_host *ha) in qla1280_read_nvram()
582 printk(KERN_INFO "scsi(%ld): Reading NVRAM\n", ha->host_no); in qla1280_read_nvram()
584 wptr = (uint16_t *)&ha->nvram; in qla1280_read_nvram()
585 nv = &ha->nvram; in qla1280_read_nvram()
594 if (nv->id0 != 'I' || nv->id1 != 'S' || in qla1280_read_nvram()
595 nv->id2 != 'P' || nv->id3 != ' ' || nv->version < 1) { in qla1280_read_nvram()
608 " version %i\n", nv->id0, nv->id1, nv->id2, nv->id3, in qla1280_read_nvram()
609 nv->version); in qla1280_read_nvram()
616 "settings\n", ha->host_no); in qla1280_read_nvram()
617 ha->nvram_valid = 0; in qla1280_read_nvram()
619 ha->nvram_valid = 1; in qla1280_read_nvram()
637 nv->isp_parameter = cpu_to_le16(nv->isp_parameter); in qla1280_read_nvram()
638 nv->firmware_feature.w = cpu_to_le16(nv->firmware_feature.w); in qla1280_read_nvram()
640 nv->bus[i].selection_timeout = cpu_to_le16(nv->bus[i].selection_timeout); in qla1280_read_nvram()
641 nv->bus[i].max_queue_depth = cpu_to_le16(nv->bus[i].max_queue_depth); in qla1280_read_nvram()
653 static const char *
656 static char qla1280_scsi_name_buffer[125]; in qla1280_info()
662 ha = (struct scsi_qla_host *)host->hostdata; in qla1280_info()
663 bdp = &ql1280_board_tbl[ha->devnum]; in qla1280_info()
669 &bdp->name[0], ha->fwver1, ha->fwver2, ha->fwver3, in qla1280_info()
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
685 static int qla1280_queuecommand_lck(struct scsi_cmnd *cmd) in qla1280_queuecommand_lck()
687 struct Scsi_Host *host = cmd->device->host; in qla1280_queuecommand_lck()
688 struct scsi_qla_host *ha = (struct scsi_qla_host *)host->hostdata; in qla1280_queuecommand_lck()
692 sp->cmd = cmd; in qla1280_queuecommand_lck()
693 sp->flags = 0; in qla1280_queuecommand_lck()
694 sp->wait = NULL; in qla1280_queuecommand_lck()
713 static DEF_SCSI_QCMD(qla1280_queuecommand)
722 static void qla1280_mailbox_timeout(struct timer_list *t) in qla1280_mailbox_timeout()
726 reg = ha->iobase; in qla1280_mailbox_timeout()
728 ha->mailbox_out[0] = RD_REG_WORD(&reg->mailbox0); in qla1280_mailbox_timeout()
730 "ictrl %04x, istatus %04x\n", ha->host_no, ha->mailbox_out[0], in qla1280_mailbox_timeout()
731 RD_REG_WORD(&reg->ictrl), RD_REG_WORD(&reg->istatus)); in qla1280_mailbox_timeout()
732 complete(ha->mailbox_wait); in qla1280_mailbox_timeout()
735 static int
740 struct scsi_cmnd *cmd = sp->cmd; in _qla1280_wait_for_single_command()
742 spin_unlock_irq(ha->host->host_lock); in _qla1280_wait_for_single_command()
744 spin_lock_irq(ha->host->host_lock); in _qla1280_wait_for_single_command()
745 sp->wait = NULL; in _qla1280_wait_for_single_command()
753 static int
758 sp->wait = &wait; in qla1280_wait_for_single_command()
762 static int
777 sp = ha->outstanding_cmds[cnt]; in qla1280_wait_for_pending_commands()
779 cmd = sp->cmd; in qla1280_wait_for_pending_commands()
808 static int
816 int wait_for_bus=-1; in qla1280_error_action()
817 int wait_for_target = -1; in qla1280_error_action()
822 ha = (struct scsi_qla_host *)(CMD_HOST(cmd)->hostdata); in qla1280_error_action()
829 RD_REG_WORD(&ha->iobase->istatus)); in qla1280_error_action()
832 RD_REG_WORD(&ha->iobase->host_cmd), in qla1280_error_action()
833 RD_REG_WORD(&ha->iobase->ictrl), jiffies); in qla1280_error_action()
838 ha->host_no, cmd, CMD_HANDLE(cmd), action); in qla1280_error_action()
846 found = -1; in qla1280_error_action()
848 if (sp == ha->outstanding_cmds[i]) { in qla1280_error_action()
850 sp->wait = &wait; /* we'll wait for it to complete */ in qla1280_error_action()
860 "already completed.\n", ha->host_no, bus, in qla1280_error_action()
882 "command.\n", ha->host_no, bus, target, lun); in qla1280_error_action()
893 "reset.\n", ha->host_no, bus); in qla1280_error_action()
908 * Wait for the command passed in by the mid-layer if it in qla1280_error_action()
921 ha->host_no, bus, target, lun); in qla1280_error_action()
925 * If the command passed in by the mid-layer has been in qla1280_error_action()
949 static int
954 spin_lock_irq(cmd->device->host->host_lock); in qla1280_eh_abort()
956 spin_unlock_irq(cmd->device->host->host_lock); in qla1280_eh_abort()
965 static int
970 spin_lock_irq(cmd->device->host->host_lock); in qla1280_eh_device_reset()
972 spin_unlock_irq(cmd->device->host->host_lock); in qla1280_eh_device_reset()
981 static int
986 spin_lock_irq(cmd->device->host->host_lock); in qla1280_eh_bus_reset()
988 spin_unlock_irq(cmd->device->host->host_lock); in qla1280_eh_bus_reset()
997 static int
1001 struct Scsi_Host *shost = cmd->device->host; in qla1280_eh_adapter_reset()
1002 struct scsi_qla_host *ha = (struct scsi_qla_host *)shost->hostdata; in qla1280_eh_adapter_reset()
1004 spin_lock_irq(shost->host_lock); in qla1280_eh_adapter_reset()
1008 ha->host_no); in qla1280_eh_adapter_reset()
1010 "continue automatically\n", ha->host_no); in qla1280_eh_adapter_reset()
1012 ha->flags.reset_active = 1; in qla1280_eh_adapter_reset()
1018 ha->flags.reset_active = 0; in qla1280_eh_adapter_reset()
1020 spin_unlock_irq(shost->host_lock); in qla1280_eh_adapter_reset()
1025 static int
1051 static inline void
1054 WRT_REG_WORD(&ha->iobase->ictrl, 0); in qla1280_disable_intrs()
1055 RD_REG_WORD(&ha->iobase->ictrl); /* PCI Posted Write flush */ in qla1280_disable_intrs()
1059 static inline void
1062 WRT_REG_WORD(&ha->iobase->ictrl, (ISP_EN_INT | ISP_EN_RISC)); in qla1280_enable_intrs()
1063 RD_REG_WORD(&ha->iobase->ictrl); /* PCI Posted Write flush */ in qla1280_enable_intrs()
1070 static irqreturn_t
1081 spin_lock(ha->host->host_lock); in qla1280_intr_handler()
1083 ha->isr_count++; in qla1280_intr_handler()
1084 reg = ha->iobase; in qla1280_intr_handler()
1088 data = qla1280_debounce_register(&reg->istatus); in qla1280_intr_handler()
1091 qla1280_isr(ha, &ha->done_q); in qla1280_intr_handler()
1094 if (!list_empty(&ha->done_q)) in qla1280_intr_handler()
1097 spin_unlock(ha->host->host_lock); in qla1280_intr_handler()
1106 static int
1114 nv = &ha->nvram; in qla1280_set_target_parameters()
1121 mb[2] = nv->bus[bus].target[target].parameter.renegotiate_on_error << 8; in qla1280_set_target_parameters()
1122 mb[2] |= nv->bus[bus].target[target].parameter.stop_queue_on_check << 9; in qla1280_set_target_parameters()
1123 mb[2] |= nv->bus[bus].target[target].parameter.auto_request_sense << 10; in qla1280_set_target_parameters()
1124 mb[2] |= nv->bus[bus].target[target].parameter.tag_queuing << 11; in qla1280_set_target_parameters()
1125 mb[2] |= nv->bus[bus].target[target].parameter.enable_sync << 12; in qla1280_set_target_parameters()
1126 mb[2] |= nv->bus[bus].target[target].parameter.enable_wide << 13; in qla1280_set_target_parameters()
1127 mb[2] |= nv->bus[bus].target[target].parameter.parity_checking << 14; in qla1280_set_target_parameters()
1128 mb[2] |= nv->bus[bus].target[target].parameter.disconnect_allowed << 15; in qla1280_set_target_parameters()
1131 mb[2] |= nv->bus[bus].target[target].ppr_1x160.flags.enable_ppr << 5; in qla1280_set_target_parameters()
1132 mb[3] = (nv->bus[bus].target[target].flags.flags1x160.sync_offset << 8); in qla1280_set_target_parameters()
1133 mb[6] = (nv->bus[bus].target[target].ppr_1x160.flags.ppr_options << 8) | in qla1280_set_target_parameters()
1134 nv->bus[bus].target[target].ppr_1x160.flags.ppr_bus_width; in qla1280_set_target_parameters()
1137 mb[3] = (nv->bus[bus].target[target].flags.flags1x80.sync_offset << 8); in qla1280_set_target_parameters()
1139 mb[3] |= nv->bus[bus].target[target].sync_period; in qla1280_set_target_parameters()
1148 mb[2] = nv->bus[bus].max_queue_depth; in qla1280_set_target_parameters()
1149 mb[3] = nv->bus[bus].target[target].execution_throttle; in qla1280_set_target_parameters()
1156 ha->host_no, bus, target); in qla1280_set_target_parameters()
1172 static int
1177 int bus = device->channel; in qla1280_slave_configure()
1178 int target = device->id; in qla1280_slave_configure()
1183 ha = (struct scsi_qla_host *)device->host->hostdata; in qla1280_slave_configure()
1184 nv = &ha->nvram; in qla1280_slave_configure()
1189 if (device->tagged_supported && in qla1280_slave_configure()
1190 (ha->bus_settings[bus].qtag_enables & (BIT_0 << target))) { in qla1280_slave_configure()
1191 scsi_change_queue_depth(device, ha->bus_settings[bus].hiwat); in qla1280_slave_configure()
1196 nv->bus[bus].target[target].parameter.enable_sync = device->sdtr; in qla1280_slave_configure()
1197 nv->bus[bus].target[target].parameter.enable_wide = device->wdtr; in qla1280_slave_configure()
1198 nv->bus[bus].target[target].ppr_1x160.flags.enable_ppr = device->ppr; in qla1280_slave_configure()
1203 nv->bus[bus].target[target].parameter.enable_sync = 0; in qla1280_slave_configure()
1207 nv->bus[bus].target[target].parameter.enable_wide = 0; in qla1280_slave_configure()
1212 nv->bus[bus].target[target].ppr_1x160.flags.enable_ppr = 0; in qla1280_slave_configure()
1215 spin_lock_irqsave(ha->host->host_lock, flags); in qla1280_slave_configure()
1216 if (nv->bus[bus].target[target].parameter.enable_sync) in qla1280_slave_configure()
1219 spin_unlock_irqrestore(ha->host->host_lock, flags); in qla1280_slave_configure()
1231 static void
1241 done_q = &ha->done_q; in qla1280_done()
1244 sp = list_entry(done_q->next, struct srb, list); in qla1280_done()
1246 list_del(&sp->list); in qla1280_done()
1248 cmd = sp->cmd; in qla1280_done()
1255 if (!ha->flags.abort_isp_active) in qla1280_done()
1259 sp->flags &= ~SRB_ABORT_PENDING; in qla1280_done()
1260 sp->flags |= SRB_ABORTED; in qla1280_done()
1269 /* Call the mid-level driver interrupt handler */ in qla1280_done()
1270 ha->actthreads--; in qla1280_done()
1272 if (sp->wait == NULL) in qla1280_done()
1275 complete(sp->wait); in qla1280_done()
1283 static int
1287 uint16_t comp_status = le16_to_cpu(sts->comp_status); in qla1280_return_status()
1288 uint16_t state_flags = le16_to_cpu(sts->state_flags); in qla1280_return_status()
1289 uint32_t residual_length = le32_to_cpu(sts->residual_length); in qla1280_return_status()
1290 uint16_t scsi_status = le16_to_cpu(sts->scsi_status); in qla1280_return_status()
1292 static char *reason[] = { in qla1280_return_status()
1355 if ((scsi_bufflen(cp) - residual_length) < in qla1280_return_status()
1356 cp->underflow) { in qla1280_return_status()
1358 "scsi: Underflow detected - retrying " in qla1280_return_status()
1396 static int
1407 ha->flags.online = 0; in qla1280_initialize_adapter()
1408 ha->flags.disable_host_adapter = 0; in qla1280_initialize_adapter()
1409 ha->flags.reset_active = 0; in qla1280_initialize_adapter()
1410 ha->flags.abort_isp_active = 0; in qla1280_initialize_adapter()
1418 reg = ha->iobase; in qla1280_initialize_adapter()
1421 WRT_REG_WORD(&reg->semaphore, 0); in qla1280_initialize_adapter()
1422 WRT_REG_WORD(&reg->host_cmd, HC_CLR_RISC_INT); in qla1280_initialize_adapter()
1423 WRT_REG_WORD(&reg->host_cmd, HC_CLR_HOST_INT); in qla1280_initialize_adapter()
1424 RD_REG_WORD(&reg->host_cmd); in qla1280_initialize_adapter()
1436 spin_lock_irqsave(ha->host->host_lock, flags); in qla1280_initialize_adapter()
1441 ha->host_no); in qla1280_initialize_adapter()
1446 dprintk(1, "scsi(%ld): Configure NVRAM parameters\n", ha->host_no); in qla1280_initialize_adapter()
1449 if (ha->flags.disable_host_adapter) { in qla1280_initialize_adapter()
1459 for (bus = 0; bus < ha->ports; bus++) { in qla1280_initialize_adapter()
1460 if (!ha->bus_settings[bus].disable_scsi_reset && in qla1280_initialize_adapter()
1463 ha->bus_settings[bus].scsi_bus_dead = 1; in qla1280_initialize_adapter()
1466 ha->flags.online = 1; in qla1280_initialize_adapter()
1468 spin_unlock_irqrestore(ha->host->host_lock, flags); in qla1280_initialize_adapter()
1489 static const struct firmware *
1497 spin_unlock_irq(ha->host->host_lock); in qla1280_request_firmware()
1500 index = ql1280_board_tbl[ha->devnum].fw_index; in qla1280_request_firmware()
1506 err = request_firmware(&fw, fwname, &ha->pdev->dev); in qla1280_request_firmware()
1514 if ((fw->size % 2) || (fw->size < 6)) { in qla1280_request_firmware()
1516 fw->size, fwname); in qla1280_request_firmware()
1518 fw = ERR_PTR(-EINVAL); in qla1280_request_firmware()
1525 ha->fwver1 = fw->data[0]; in qla1280_request_firmware()
1526 ha->fwver2 = fw->data[1]; in qla1280_request_firmware()
1527 ha->fwver3 = fw->data[2]; in qla1280_request_firmware()
1530 spin_lock_irq(ha->host->host_lock); in qla1280_request_firmware()
1544 static int
1548 struct device_reg __iomem *reg = ha->iobase; in qla1280_chip_diag()
1552 dprintk(3, "qla1280_chip_diag: testing device at 0x%p \n", &reg->id_l); in qla1280_chip_diag()
1554 dprintk(1, "scsi(%ld): Verifying chip\n", ha->host_no); in qla1280_chip_diag()
1557 WRT_REG_WORD(&reg->ictrl, ISP_RESET); in qla1280_chip_diag()
1567 data = qla1280_debounce_register(&reg->ictrl); in qla1280_chip_diag()
1569 * Yet another QLogic gem ;-( in qla1280_chip_diag()
1571 for (cnt = 1000000; cnt && data & ISP_RESET; cnt--) { in qla1280_chip_diag()
1573 data = RD_REG_WORD(&reg->ictrl); in qla1280_chip_diag()
1582 WRT_REG_WORD(&reg->cfg_1, 0); in qla1280_chip_diag()
1586 WRT_REG_WORD(&reg->host_cmd, HC_RESET_RISC | in qla1280_chip_diag()
1589 RD_REG_WORD(&reg->id_l); /* Flush PCI write */ in qla1280_chip_diag()
1590 data = qla1280_debounce_register(&reg->mailbox0); in qla1280_chip_diag()
1595 for (cnt = 1000000; cnt && data == MBS_BUSY; cnt--) { in qla1280_chip_diag()
1597 data = RD_REG_WORD(&reg->mailbox0); in qla1280_chip_diag()
1606 if (RD_REG_WORD(&reg->mailbox1) != PROD_ID_1 || in qla1280_chip_diag()
1607 (RD_REG_WORD(&reg->mailbox2) != PROD_ID_2 && in qla1280_chip_diag()
1608 RD_REG_WORD(&reg->mailbox2) != PROD_ID_2a) || in qla1280_chip_diag()
1609 RD_REG_WORD(&reg->mailbox3) != PROD_ID_3 || in qla1280_chip_diag()
1610 RD_REG_WORD(&reg->mailbox4) != PROD_ID_4) { in qla1280_chip_diag()
1613 RD_REG_WORD(&reg->mailbox1), in qla1280_chip_diag()
1614 RD_REG_WORD(&reg->mailbox2), in qla1280_chip_diag()
1615 RD_REG_WORD(&reg->mailbox3), in qla1280_chip_diag()
1616 RD_REG_WORD(&reg->mailbox4)); in qla1280_chip_diag()
1654 static int
1669 fw_data = (const __le16 *)&fw->data[0]; in qla1280_load_firmware_pio()
1670 ha->fwstart = __le16_to_cpu(fw_data[2]); in qla1280_load_firmware_pio()
1673 risc_address = ha->fwstart; in qla1280_load_firmware_pio()
1674 fw_data = (const __le16 *)&fw->data[6]; in qla1280_load_firmware_pio()
1675 risc_code_size = (fw->size - 6) / 2; in qla1280_load_firmware_pio()
1685 ha->host_no); in qla1280_load_firmware_pio()
1704 static int
1717 tbuf = dma_alloc_coherent(&ha->pdev->dev, 8000, &p_tbuf, GFP_KERNEL); in qla1280_load_firmware_dma()
1719 return -ENOMEM; in qla1280_load_firmware_dma()
1726 fw_data = (const __le16 *)&fw->data[0]; in qla1280_load_firmware_dma()
1727 ha->fwstart = __le16_to_cpu(fw_data[2]); in qla1280_load_firmware_dma()
1730 risc_address = ha->fwstart; in qla1280_load_firmware_dma()
1731 fw_data = (const __le16 *)&fw->data[6]; in qla1280_load_firmware_dma()
1732 risc_code_size = (fw->size - 6) / 2; in qla1280_load_firmware_dma()
1750 ((__le16 *)ha->request_ring)[i] = fw_data[i]; in qla1280_load_firmware_dma()
1755 mb[3] = ha->request_dma & 0xffff; in qla1280_load_firmware_dma()
1756 mb[2] = (ha->request_dma >> 16) & 0xffff; in qla1280_load_firmware_dma()
1757 mb[7] = upper_32_bits(ha->request_dma) & 0xffff; in qla1280_load_firmware_dma()
1758 mb[6] = upper_32_bits(ha->request_dma) >> 16; in qla1280_load_firmware_dma()
1761 (void *)(long)ha->request_dma, in qla1280_load_firmware_dma()
1766 "segment of f\n", ha->host_no); in qla1280_load_firmware_dma()
1785 sp = (uint8_t *)ha->request_ring; in qla1280_load_firmware_dma()
1799 risc_code_size = risc_code_size - cnt; in qla1280_load_firmware_dma()
1806 dma_free_coherent(&ha->pdev->dev, 8000, tbuf, p_tbuf); in qla1280_load_firmware_dma()
1811 static int
1823 mb[1] = ha->fwstart; in qla1280_start_firmware()
1826 printk(KERN_ERR "scsi(%li): RISC checksum failed.\n", ha->host_no); in qla1280_start_firmware()
1833 mb[1] = ha->fwstart; in qla1280_start_firmware()
1837 ha->host_no); in qla1280_start_firmware()
1843 static int
1868 * ha->request_ring = request ring virtual address
1869 * ha->response_ring = response ring virtual address
1870 * ha->request_dma = request ring physical address
1871 * ha->response_dma = response ring physical address
1876 static int
1885 memset(ha->outstanding_cmds, 0, in qla1280_init_rings()
1889 ha->request_ring_ptr = ha->request_ring; in qla1280_init_rings()
1890 ha->req_ring_index = 0; in qla1280_init_rings()
1891 ha->req_q_cnt = REQUEST_ENTRY_CNT; in qla1280_init_rings()
1895 mb[3] = ha->request_dma & 0xffff; in qla1280_init_rings()
1896 mb[2] = (ha->request_dma >> 16) & 0xffff; in qla1280_init_rings()
1898 mb[7] = upper_32_bits(ha->request_dma) & 0xffff; in qla1280_init_rings()
1899 mb[6] = upper_32_bits(ha->request_dma) >> 16; in qla1280_init_rings()
1904 ha->response_ring_ptr = ha->response_ring; in qla1280_init_rings()
1905 ha->rsp_ring_index = 0; in qla1280_init_rings()
1909 mb[3] = ha->response_dma & 0xffff; in qla1280_init_rings()
1910 mb[2] = (ha->response_dma >> 16) & 0xffff; in qla1280_init_rings()
1912 mb[7] = upper_32_bits(ha->response_dma) & 0xffff; in qla1280_init_rings()
1913 mb[6] = upper_32_bits(ha->response_dma) >> 16; in qla1280_init_rings()
1926 static void
1930 nv->bus[0].config_1.initiator_id); in qla1280_print_settings()
1932 nv->bus[1].config_1.initiator_id); in qla1280_print_settings()
1935 nv->bus[0].bus_reset_delay); in qla1280_print_settings()
1937 nv->bus[1].bus_reset_delay); in qla1280_print_settings()
1939 dprintk(1, "qla1280 : retry count[0]=%d\n", nv->bus[0].retry_count); in qla1280_print_settings()
1940 dprintk(1, "qla1280 : retry delay[0]=%d\n", nv->bus[0].retry_delay); in qla1280_print_settings()
1941 dprintk(1, "qla1280 : retry count[1]=%d\n", nv->bus[1].retry_count); in qla1280_print_settings()
1942 dprintk(1, "qla1280 : retry delay[1]=%d\n", nv->bus[1].retry_delay); in qla1280_print_settings()
1945 nv->bus[0].config_2.async_data_setup_time); in qla1280_print_settings()
1947 nv->bus[1].config_2.async_data_setup_time); in qla1280_print_settings()
1950 nv->bus[0].config_2.req_ack_active_negation); in qla1280_print_settings()
1952 nv->bus[1].config_2.req_ack_active_negation); in qla1280_print_settings()
1955 nv->bus[0].config_2.data_line_active_negation); in qla1280_print_settings()
1957 nv->bus[1].config_2.data_line_active_negation); in qla1280_print_settings()
1960 nv->cntr_flags_1.disable_loading_risc_code); in qla1280_print_settings()
1963 nv->cntr_flags_1.enable_64bit_addressing); in qla1280_print_settings()
1966 nv->bus[0].selection_timeout); in qla1280_print_settings()
1968 nv->bus[1].selection_timeout); in qla1280_print_settings()
1971 nv->bus[0].max_queue_depth); in qla1280_print_settings()
1973 nv->bus[1].max_queue_depth); in qla1280_print_settings()
1976 static void
1979 struct nvram *nv = &ha->nvram; in qla1280_set_target_defaults()
1981 nv->bus[bus].target[target].parameter.renegotiate_on_error = 1; in qla1280_set_target_defaults()
1982 nv->bus[bus].target[target].parameter.auto_request_sense = 1; in qla1280_set_target_defaults()
1983 nv->bus[bus].target[target].parameter.tag_queuing = 1; in qla1280_set_target_defaults()
1984 nv->bus[bus].target[target].parameter.enable_sync = 1; in qla1280_set_target_defaults()
1986 nv->bus[bus].target[target].parameter.enable_wide = 1; in qla1280_set_target_defaults()
1988 nv->bus[bus].target[target].execution_throttle = in qla1280_set_target_defaults()
1989 nv->bus[bus].max_queue_depth - 1; in qla1280_set_target_defaults()
1990 nv->bus[bus].target[target].parameter.parity_checking = 1; in qla1280_set_target_defaults()
1991 nv->bus[bus].target[target].parameter.disconnect_allowed = 1; in qla1280_set_target_defaults()
1994 nv->bus[bus].target[target].flags.flags1x160.device_enable = 1; in qla1280_set_target_defaults()
1995 nv->bus[bus].target[target].flags.flags1x160.sync_offset = 0x0e; in qla1280_set_target_defaults()
1996 nv->bus[bus].target[target].sync_period = 9; in qla1280_set_target_defaults()
1997 nv->bus[bus].target[target].ppr_1x160.flags.enable_ppr = 1; in qla1280_set_target_defaults()
1998 nv->bus[bus].target[target].ppr_1x160.flags.ppr_options = 2; in qla1280_set_target_defaults()
1999 nv->bus[bus].target[target].ppr_1x160.flags.ppr_bus_width = 1; in qla1280_set_target_defaults()
2001 nv->bus[bus].target[target].flags.flags1x80.device_enable = 1; in qla1280_set_target_defaults()
2002 nv->bus[bus].target[target].flags.flags1x80.sync_offset = 12; in qla1280_set_target_defaults()
2003 nv->bus[bus].target[target].sync_period = 10; in qla1280_set_target_defaults()
2007 static void
2010 struct nvram *nv = &ha->nvram; in qla1280_set_defaults()
2016 /* nv->cntr_flags_1.disable_loading_risc_code = 1; */ in qla1280_set_defaults()
2017 nv->firmware_feature.f.enable_fast_posting = 1; in qla1280_set_defaults()
2018 nv->firmware_feature.f.disable_synchronous_backoff = 1; in qla1280_set_defaults()
2019 nv->termination.scsi_bus_0_control = 3; in qla1280_set_defaults()
2020 nv->termination.scsi_bus_1_control = 3; in qla1280_set_defaults()
2021 nv->termination.auto_term_support = 1; in qla1280_set_defaults()
2024 * Set default FIFO magic - What appropriate values would be here in qla1280_set_defaults()
2031 nv->isp_config.burst_enable = 1; in qla1280_set_defaults()
2033 nv->isp_config.fifo_threshold |= 3; in qla1280_set_defaults()
2035 nv->isp_config.fifo_threshold |= 4; in qla1280_set_defaults()
2038 nv->isp_parameter = 0x01; /* fast memory enable */ in qla1280_set_defaults()
2041 nv->bus[bus].config_1.initiator_id = 7; in qla1280_set_defaults()
2042 nv->bus[bus].config_2.req_ack_active_negation = 1; in qla1280_set_defaults()
2043 nv->bus[bus].config_2.data_line_active_negation = 1; in qla1280_set_defaults()
2044 nv->bus[bus].selection_timeout = 250; in qla1280_set_defaults()
2045 nv->bus[bus].max_queue_depth = 32; in qla1280_set_defaults()
2048 nv->bus[bus].bus_reset_delay = 3; in qla1280_set_defaults()
2049 nv->bus[bus].config_2.async_data_setup_time = 6; in qla1280_set_defaults()
2050 nv->bus[bus].retry_delay = 1; in qla1280_set_defaults()
2052 nv->bus[bus].bus_reset_delay = 5; in qla1280_set_defaults()
2053 nv->bus[bus].config_2.async_data_setup_time = 8; in qla1280_set_defaults()
2061 static int
2064 struct nvram *nv = &ha->nvram; in qla1280_config_target()
2082 mb[3] = nv->bus[bus].target[target].flags.flags1x160.sync_offset << 8; in qla1280_config_target()
2084 mb[3] = nv->bus[bus].target[target].flags.flags1x80.sync_offset << 8; in qla1280_config_target()
2085 mb[3] |= nv->bus[bus].target[target].sync_period; in qla1280_config_target()
2090 if (nv->bus[bus].target[target].parameter.tag_queuing) in qla1280_config_target()
2091 ha->bus_settings[bus].qtag_enables |= flag; in qla1280_config_target()
2095 if (nv->bus[bus].target[target].flags.flags1x160.device_enable) in qla1280_config_target()
2096 ha->bus_settings[bus].device_enables |= flag; in qla1280_config_target()
2097 ha->bus_settings[bus].lun_disables |= 0; in qla1280_config_target()
2099 if (nv->bus[bus].target[target].flags.flags1x80.device_enable) in qla1280_config_target()
2100 ha->bus_settings[bus].device_enables |= flag; in qla1280_config_target()
2102 if (nv->bus[bus].target[target].flags.flags1x80.lun_disable) in qla1280_config_target()
2103 ha->bus_settings[bus].lun_disables |= flag; in qla1280_config_target()
2111 mb[2] = nv->bus[bus].max_queue_depth; in qla1280_config_target()
2112 mb[3] = nv->bus[bus].target[target].execution_throttle; in qla1280_config_target()
2119 static int
2122 struct nvram *nv = &ha->nvram; in qla1280_config_bus()
2127 ha->bus_settings[bus].disable_scsi_reset = in qla1280_config_bus()
2128 nv->bus[bus].config_1.scsi_reset_disable; in qla1280_config_bus()
2131 ha->bus_settings[bus].id = nv->bus[bus].config_1.initiator_id; in qla1280_config_bus()
2133 mb[1] = bus ? ha->bus_settings[bus].id | BIT_7 : in qla1280_config_bus()
2134 ha->bus_settings[bus].id; in qla1280_config_bus()
2138 ha->bus_settings[bus].bus_reset_delay = in qla1280_config_bus()
2139 nv->bus[bus].bus_reset_delay; in qla1280_config_bus()
2142 ha->bus_settings[bus].hiwat = nv->bus[bus].max_queue_depth - 1; in qla1280_config_bus()
2151 static int
2154 struct device_reg __iomem *reg = ha->iobase; in qla1280_nvram_config()
2155 struct nvram *nv = &ha->nvram; in qla1280_nvram_config()
2161 if (ha->nvram_valid) { in qla1280_nvram_config()
2165 nv->bus[bus].target[target].parameter. in qla1280_nvram_config()
2175 ha->flags.disable_risc_code_load = in qla1280_nvram_config()
2176 nv->cntr_flags_1.disable_loading_risc_code; in qla1280_nvram_config()
2181 hwrev = RD_REG_WORD(&reg->cfg_0) & ISP_CFG0_HWMSK; in qla1280_nvram_config()
2183 cfg1 = RD_REG_WORD(&reg->cfg_1) & ~(BIT_4 | BIT_5 | BIT_6); in qla1280_nvram_config()
2184 cdma_conf = RD_REG_WORD(&reg->cdma_cfg); in qla1280_nvram_config()
2188 cfg1 |= nv->isp_config.fifo_threshold << 4; in qla1280_nvram_config()
2190 cfg1 |= nv->isp_config.burst_enable << 2; in qla1280_nvram_config()
2191 WRT_REG_WORD(&reg->cfg_1, cfg1); in qla1280_nvram_config()
2193 WRT_REG_WORD(&reg->cdma_cfg, cdma_conf | CDMA_CONF_BENAB); in qla1280_nvram_config()
2194 WRT_REG_WORD(&reg->ddma_cfg, cdma_conf | DDMA_CONF_BENAB); in qla1280_nvram_config()
2199 cfg1 = nv->isp_config.fifo_threshold << 4; in qla1280_nvram_config()
2200 cfg1 |= nv->isp_config.burst_enable << 2; in qla1280_nvram_config()
2202 if (ha->ports > 1) in qla1280_nvram_config()
2204 WRT_REG_WORD(&reg->cfg_1, cfg1); in qla1280_nvram_config()
2207 WRT_REG_WORD(&reg->gpio_enable, in qla1280_nvram_config()
2209 term = nv->termination.scsi_bus_1_control; in qla1280_nvram_config()
2210 term |= nv->termination.scsi_bus_0_control << 2; in qla1280_nvram_config()
2211 term |= nv->termination.auto_term_support << 7; in qla1280_nvram_config()
2212 RD_REG_WORD(&reg->id_l); /* Flush PCI write */ in qla1280_nvram_config()
2213 WRT_REG_WORD(&reg->gpio_data, term); in qla1280_nvram_config()
2215 RD_REG_WORD(&reg->id_l); /* Flush PCI write */ in qla1280_nvram_config()
2219 mb[1] = nv->isp_parameter; in qla1280_nvram_config()
2223 /* clock rate - for qla1240 and older, only */ in qla1280_nvram_config()
2231 mb[1] = nv->firmware_feature.f.enable_fast_posting; in qla1280_nvram_config()
2232 mb[1] |= nv->firmware_feature.f.report_lvd_bus_transition << 1; in qla1280_nvram_config()
2233 mb[1] |= nv->firmware_feature.f.disable_synchronous_backoff << 5; in qla1280_nvram_config()
2238 mb[1] = nv->bus[0].retry_count; in qla1280_nvram_config()
2239 mb[2] = nv->bus[0].retry_delay; in qla1280_nvram_config()
2240 mb[6] = nv->bus[1].retry_count; in qla1280_nvram_config()
2241 mb[7] = nv->bus[1].retry_delay; in qla1280_nvram_config()
2247 mb[1] = nv->bus[0].config_2.async_data_setup_time; in qla1280_nvram_config()
2248 mb[2] = nv->bus[1].config_2.async_data_setup_time; in qla1280_nvram_config()
2254 if (nv->bus[0].config_2.req_ack_active_negation) in qla1280_nvram_config()
2256 if (nv->bus[0].config_2.data_line_active_negation) in qla1280_nvram_config()
2259 if (nv->bus[1].config_2.req_ack_active_negation) in qla1280_nvram_config()
2261 if (nv->bus[1].config_2.data_line_active_negation) in qla1280_nvram_config()
2281 mb[1] = nv->bus[0].selection_timeout; in qla1280_nvram_config()
2282 mb[2] = nv->bus[1].selection_timeout; in qla1280_nvram_config()
2285 for (bus = 0; bus < ha->ports; bus++) in qla1280_nvram_config()
2307 static uint16_t
2332 * Bit 23-16 = address
2333 * Bit 15-0 = write data
2338 static uint16_t
2341 struct device_reg __iomem *reg = ha->iobase; in qla1280_nvram_request()
2360 WRT_REG_WORD(&reg->nvram, (NV_SELECT | NV_CLOCK)); in qla1280_nvram_request()
2361 RD_REG_WORD(&reg->id_l); /* Flush PCI write */ in qla1280_nvram_request()
2364 reg_data = RD_REG_WORD(&reg->nvram); in qla1280_nvram_request()
2367 WRT_REG_WORD(&reg->nvram, NV_SELECT); in qla1280_nvram_request()
2368 RD_REG_WORD(&reg->id_l); /* Flush PCI write */ in qla1280_nvram_request()
2374 WRT_REG_WORD(&reg->nvram, NV_DESELECT); in qla1280_nvram_request()
2375 RD_REG_WORD(&reg->id_l); /* Flush PCI write */ in qla1280_nvram_request()
2381 static void
2384 struct device_reg __iomem *reg = ha->iobase; in qla1280_nv_write()
2386 WRT_REG_WORD(&reg->nvram, data | NV_SELECT); in qla1280_nv_write()
2387 RD_REG_WORD(&reg->id_l); /* Flush PCI write */ in qla1280_nv_write()
2389 WRT_REG_WORD(&reg->nvram, data | NV_SELECT | NV_CLOCK); in qla1280_nv_write()
2390 RD_REG_WORD(&reg->id_l); /* Flush PCI write */ in qla1280_nv_write()
2392 WRT_REG_WORD(&reg->nvram, data | NV_SELECT); in qla1280_nv_write()
2393 RD_REG_WORD(&reg->id_l); /* Flush PCI write */ in qla1280_nv_write()
2412 static int
2415 struct device_reg __iomem *reg = ha->iobase; in qla1280_mailbox_command()
2424 if (ha->mailbox_wait) { in qla1280_mailbox_command()
2427 ha->mailbox_wait = &wait; in qla1280_mailbox_command()
2434 mptr = (uint16_t __iomem *) &reg->mailbox0; in qla1280_mailbox_command()
2449 timer_setup(&ha->mailbox_timer, qla1280_mailbox_timeout, 0); in qla1280_mailbox_command()
2450 mod_timer(&ha->mailbox_timer, jiffies + 20 * HZ); in qla1280_mailbox_command()
2452 spin_unlock_irq(ha->host->host_lock); in qla1280_mailbox_command()
2453 WRT_REG_WORD(&reg->host_cmd, HC_SET_HOST_INT); in qla1280_mailbox_command()
2454 qla1280_debounce_register(&reg->istatus); in qla1280_mailbox_command()
2457 del_timer_sync(&ha->mailbox_timer); in qla1280_mailbox_command()
2459 spin_lock_irq(ha->host->host_lock); in qla1280_mailbox_command()
2461 ha->mailbox_wait = NULL; in qla1280_mailbox_command()
2464 if (ha->mailbox_out[0] != MBS_CMD_CMP) { in qla1280_mailbox_command()
2468 mb[0], ha->mailbox_out[0], RD_REG_WORD(&reg->istatus)); in qla1280_mailbox_command()
2470 RD_REG_WORD(&reg->mailbox0), RD_REG_WORD(&reg->mailbox1), in qla1280_mailbox_command()
2471 RD_REG_WORD(&reg->mailbox2), RD_REG_WORD(&reg->mailbox3)); in qla1280_mailbox_command()
2473 RD_REG_WORD(&reg->mailbox4), RD_REG_WORD(&reg->mailbox5), in qla1280_mailbox_command()
2474 RD_REG_WORD(&reg->mailbox6), RD_REG_WORD(&reg->mailbox7)); in qla1280_mailbox_command()
2480 iptr = (uint16_t *) &ha->mailbox_out[0]; in qla1280_mailbox_command()
2483 if (ha->flags.reset_marker) in qla1280_mailbox_command()
2501 static void
2504 struct device_reg __iomem *reg = ha->iobase; in qla1280_poll()
2511 data = RD_REG_WORD(&reg->istatus); in qla1280_poll()
2515 if (!ha->mailbox_wait) { in qla1280_poll()
2516 if (ha->flags.reset_marker) in qla1280_poll()
2537 static int
2548 ha->host_no, bus); in qla1280_bus_reset()
2550 reset_delay = ha->bus_settings[bus].bus_reset_delay; in qla1280_bus_reset()
2557 if (ha->bus_settings[bus].failed_reset_count > 2) in qla1280_bus_reset()
2558 ha->bus_settings[bus].scsi_bus_dead = 1; in qla1280_bus_reset()
2559 ha->bus_settings[bus].failed_reset_count++; in qla1280_bus_reset()
2561 spin_unlock_irq(ha->host->host_lock); in qla1280_bus_reset()
2563 spin_lock_irq(ha->host->host_lock); in qla1280_bus_reset()
2565 ha->bus_settings[bus].scsi_bus_dead = 0; in qla1280_bus_reset()
2566 ha->bus_settings[bus].failed_reset_count = 0; in qla1280_bus_reset()
2567 ha->bus_settings[bus].reset_marker = 0; in qla1280_bus_reset()
2597 static int
2631 static int
2640 bus = SCSI_BUS_32(sp->cmd); in qla1280_abort_command()
2641 target = SCSI_TCN_32(sp->cmd); in qla1280_abort_command()
2642 lun = SCSI_LUN_32(sp->cmd); in qla1280_abort_command()
2644 sp->flags |= SRB_ABORT_PENDING; in qla1280_abort_command()
2654 sp->flags &= ~SRB_ABORT_PENDING; in qla1280_abort_command()
2669 static void
2672 struct device_reg __iomem *reg = ha->iobase; in qla1280_reset_adapter()
2677 ha->flags.online = 0; in qla1280_reset_adapter()
2678 WRT_REG_WORD(&reg->ictrl, ISP_RESET); in qla1280_reset_adapter()
2679 WRT_REG_WORD(&reg->host_cmd, in qla1280_reset_adapter()
2681 RD_REG_WORD(&reg->id_l); /* Flush PCI write */ in qla1280_reset_adapter()
2697 static void
2706 pkt->entry_type = MARKER_TYPE; in qla1280_marker()
2707 pkt->lun = (uint8_t) lun; in qla1280_marker()
2708 pkt->target = (uint8_t) (bus ? (id | BIT_7) : id); in qla1280_marker()
2709 pkt->modifier = type; in qla1280_marker()
2710 pkt->entry_status = 0; in qla1280_marker()
2733 static int
2736 struct device_reg __iomem *reg = ha->iobase; in qla1280_64bit_start_scsi()
2737 struct scsi_cmnd *cmd = sp->cmd; in qla1280_64bit_start_scsi()
2754 req_cnt += (seg_cnt - 2) / 5; in qla1280_64bit_start_scsi()
2755 if ((seg_cnt - 2) % 5) in qla1280_64bit_start_scsi()
2763 if ((req_cnt + 2) >= ha->req_q_cnt) { in qla1280_64bit_start_scsi()
2765 cnt = RD_REG_WORD(&reg->mailbox4); in qla1280_64bit_start_scsi()
2766 if (ha->req_ring_index < cnt) in qla1280_64bit_start_scsi()
2767 ha->req_q_cnt = cnt - ha->req_ring_index; in qla1280_64bit_start_scsi()
2769 ha->req_q_cnt = in qla1280_64bit_start_scsi()
2770 REQUEST_ENTRY_CNT - (ha->req_ring_index - cnt); in qla1280_64bit_start_scsi()
2774 ha->req_q_cnt, seg_cnt); in qla1280_64bit_start_scsi()
2777 if ((req_cnt + 2) >= ha->req_q_cnt) { in qla1280_64bit_start_scsi()
2779 dprintk(2, "qla1280_start_scsi: in-ptr=0x%x req_q_cnt=" in qla1280_64bit_start_scsi()
2780 "0x%xreq_cnt=0x%x", ha->req_ring_index, ha->req_q_cnt, in qla1280_64bit_start_scsi()
2787 ha->outstanding_cmds[cnt] != NULL; cnt++); in qla1280_64bit_start_scsi()
2792 "OUTSTANDING ARRAY, req_q_cnt=0x%x", ha->req_q_cnt); in qla1280_64bit_start_scsi()
2796 ha->outstanding_cmds[cnt] = sp; in qla1280_64bit_start_scsi()
2797 ha->req_q_cnt -= req_cnt; in qla1280_64bit_start_scsi()
2798 CMD_HANDLE(sp->cmd) = (unsigned char *)(unsigned long)(cnt + 1); in qla1280_64bit_start_scsi()
2801 cmd->cmnd[0], (long)CMD_HANDLE(sp->cmd)); in qla1280_64bit_start_scsi()
2804 qla1280_dump_buffer(2, cmd->cmnd, MAX_COMMAND_SIZE); in qla1280_64bit_start_scsi()
2809 pkt = (cmd_a64_entry_t *) ha->request_ring_ptr; in qla1280_64bit_start_scsi()
2811 pkt->entry_type = COMMAND_A64_TYPE; in qla1280_64bit_start_scsi()
2812 pkt->entry_count = (uint8_t) req_cnt; in qla1280_64bit_start_scsi()
2813 pkt->sys_define = (uint8_t) ha->req_ring_index; in qla1280_64bit_start_scsi()
2814 pkt->entry_status = 0; in qla1280_64bit_start_scsi()
2815 pkt->handle = cpu_to_le32(cnt); in qla1280_64bit_start_scsi()
2818 memset(((char *)pkt + 8), 0, (REQUEST_ENTRY_SIZE - 8)); in qla1280_64bit_start_scsi()
2821 pkt->timeout = cpu_to_le16(scsi_cmd_to_rq(cmd)->timeout / HZ); in qla1280_64bit_start_scsi()
2824 pkt->lun = SCSI_LUN_32(cmd); in qla1280_64bit_start_scsi()
2825 pkt->target = SCSI_BUS_32(cmd) ? in qla1280_64bit_start_scsi()
2829 if (cmd->device->simple_tags) in qla1280_64bit_start_scsi()
2830 pkt->control_flags |= cpu_to_le16(BIT_3); in qla1280_64bit_start_scsi()
2833 pkt->cdb_len = cpu_to_le16(CMD_CDBLEN(cmd)); in qla1280_64bit_start_scsi()
2834 memcpy(pkt->scsi_cdb, CMD_CDBP(cmd), CMD_CDBLEN(cmd)); in qla1280_64bit_start_scsi()
2835 /* dprintk(1, "Build packet for command[0]=0x%x\n",pkt->scsi_cdb[0]); */ in qla1280_64bit_start_scsi()
2839 pkt->control_flags |= cpu_to_le16(dir); in qla1280_64bit_start_scsi()
2842 pkt->dseg_count = cpu_to_le16(seg_cnt); in qla1280_64bit_start_scsi()
2854 dword_ptr = (u32 *)&pkt->dseg_0_address; in qla1280_64bit_start_scsi()
2871 remseg--; in qla1280_64bit_start_scsi()
2874 "command packet data - b %i, t %i, l %i \n", in qla1280_64bit_start_scsi()
2890 ha->req_ring_index++; in qla1280_64bit_start_scsi()
2891 if (ha->req_ring_index == REQUEST_ENTRY_CNT) { in qla1280_64bit_start_scsi()
2892 ha->req_ring_index = 0; in qla1280_64bit_start_scsi()
2893 ha->request_ring_ptr = in qla1280_64bit_start_scsi()
2894 ha->request_ring; in qla1280_64bit_start_scsi()
2896 ha->request_ring_ptr++; in qla1280_64bit_start_scsi()
2898 pkt = (cmd_a64_entry_t *)ha->request_ring_ptr; in qla1280_64bit_start_scsi()
2904 ((struct cont_a64_entry *) pkt)->entry_type = in qla1280_64bit_start_scsi()
2906 ((struct cont_a64_entry *) pkt)->entry_count = 1; in qla1280_64bit_start_scsi()
2907 ((struct cont_a64_entry *) pkt)->sys_define = in qla1280_64bit_start_scsi()
2908 (uint8_t)ha->req_ring_index; in qla1280_64bit_start_scsi()
2911 (u32 *)&((struct cont_a64_entry *) pkt)->dseg_0_address; in qla1280_64bit_start_scsi()
2929 remseg -= cnt; in qla1280_64bit_start_scsi()
2931 "continuation packet data - b %i, t " in qla1280_64bit_start_scsi()
2939 "packet data - b %i, t %i, l %i \n", in qla1280_64bit_start_scsi()
2944 ha->req_ring_index++; in qla1280_64bit_start_scsi()
2945 if (ha->req_ring_index == REQUEST_ENTRY_CNT) { in qla1280_64bit_start_scsi()
2946 ha->req_ring_index = 0; in qla1280_64bit_start_scsi()
2947 ha->request_ring_ptr = ha->request_ring; in qla1280_64bit_start_scsi()
2949 ha->request_ring_ptr++; in qla1280_64bit_start_scsi()
2954 sp->flags |= SRB_SENT; in qla1280_64bit_start_scsi()
2955 ha->actthreads++; in qla1280_64bit_start_scsi()
2956 WRT_REG_WORD(&reg->mailbox4, ha->req_ring_index); in qla1280_64bit_start_scsi()
2987 static int
2990 struct device_reg __iomem *reg = ha->iobase; in qla1280_32bit_start_scsi()
2991 struct scsi_cmnd *cmd = sp->cmd; in qla1280_32bit_start_scsi()
3003 cmd->cmnd[0]); in qla1280_32bit_start_scsi()
3014 req_cnt += (seg_cnt - 4) / 7; in qla1280_32bit_start_scsi()
3015 if ((seg_cnt - 4) % 7) in qla1280_32bit_start_scsi()
3025 if ((req_cnt + 2) >= ha->req_q_cnt) { in qla1280_32bit_start_scsi()
3027 cnt = RD_REG_WORD(&reg->mailbox4); in qla1280_32bit_start_scsi()
3028 if (ha->req_ring_index < cnt) in qla1280_32bit_start_scsi()
3029 ha->req_q_cnt = cnt - ha->req_ring_index; in qla1280_32bit_start_scsi()
3031 ha->req_q_cnt = in qla1280_32bit_start_scsi()
3032 REQUEST_ENTRY_CNT - (ha->req_ring_index - cnt); in qla1280_32bit_start_scsi()
3036 ha->req_q_cnt, seg_cnt); in qla1280_32bit_start_scsi()
3038 if ((req_cnt + 2) >= ha->req_q_cnt) { in qla1280_32bit_start_scsi()
3040 dprintk(2, "qla1280_32bit_start_scsi: in-ptr=0x%x, " in qla1280_32bit_start_scsi()
3041 "req_q_cnt=0x%x, req_cnt=0x%x", ha->req_ring_index, in qla1280_32bit_start_scsi()
3042 ha->req_q_cnt, req_cnt); in qla1280_32bit_start_scsi()
3048 ha->outstanding_cmds[cnt]; cnt++); in qla1280_32bit_start_scsi()
3053 "ARRAY, req_q_cnt=0x%x\n", ha->req_q_cnt); in qla1280_32bit_start_scsi()
3057 CMD_HANDLE(sp->cmd) = (unsigned char *) (unsigned long)(cnt + 1); in qla1280_32bit_start_scsi()
3058 ha->outstanding_cmds[cnt] = sp; in qla1280_32bit_start_scsi()
3059 ha->req_q_cnt -= req_cnt; in qla1280_32bit_start_scsi()
3064 pkt = (struct cmd_entry *) ha->request_ring_ptr; in qla1280_32bit_start_scsi()
3066 pkt->entry_type = COMMAND_TYPE; in qla1280_32bit_start_scsi()
3067 pkt->entry_count = (uint8_t) req_cnt; in qla1280_32bit_start_scsi()
3068 pkt->sys_define = (uint8_t) ha->req_ring_index; in qla1280_32bit_start_scsi()
3069 pkt->entry_status = 0; in qla1280_32bit_start_scsi()
3070 pkt->handle = cpu_to_le32(cnt); in qla1280_32bit_start_scsi()
3073 memset(((char *)pkt + 8), 0, (REQUEST_ENTRY_SIZE - 8)); in qla1280_32bit_start_scsi()
3076 pkt->timeout = cpu_to_le16(scsi_cmd_to_rq(cmd)->timeout / HZ); in qla1280_32bit_start_scsi()
3079 pkt->lun = SCSI_LUN_32(cmd); in qla1280_32bit_start_scsi()
3080 pkt->target = SCSI_BUS_32(cmd) ? in qla1280_32bit_start_scsi()
3084 if (cmd->device->simple_tags) in qla1280_32bit_start_scsi()
3085 pkt->control_flags |= cpu_to_le16(BIT_3); in qla1280_32bit_start_scsi()
3088 pkt->cdb_len = cpu_to_le16(CMD_CDBLEN(cmd)); in qla1280_32bit_start_scsi()
3089 memcpy(pkt->scsi_cdb, CMD_CDBP(cmd), CMD_CDBLEN(cmd)); in qla1280_32bit_start_scsi()
3091 /*dprintk(1, "Build packet for command[0]=0x%x\n",pkt->scsi_cdb[0]); */ in qla1280_32bit_start_scsi()
3094 pkt->control_flags |= cpu_to_le16(dir); in qla1280_32bit_start_scsi()
3097 pkt->dseg_count = cpu_to_le16(seg_cnt); in qla1280_32bit_start_scsi()
3109 dword_ptr = &pkt->dseg_0_address; in qla1280_32bit_start_scsi()
3124 remseg--; in qla1280_32bit_start_scsi()
3135 ha->req_ring_index++; in qla1280_32bit_start_scsi()
3136 if (ha->req_ring_index == REQUEST_ENTRY_CNT) { in qla1280_32bit_start_scsi()
3137 ha->req_ring_index = 0; in qla1280_32bit_start_scsi()
3138 ha->request_ring_ptr = in qla1280_32bit_start_scsi()
3139 ha->request_ring; in qla1280_32bit_start_scsi()
3141 ha->request_ring_ptr++; in qla1280_32bit_start_scsi()
3143 pkt = (struct cmd_entry *)ha->request_ring_ptr; in qla1280_32bit_start_scsi()
3149 ((struct cont_entry *) pkt)-> in qla1280_32bit_start_scsi()
3151 ((struct cont_entry *) pkt)->entry_count = 1; in qla1280_32bit_start_scsi()
3153 ((struct cont_entry *) pkt)->sys_define = in qla1280_32bit_start_scsi()
3154 (uint8_t) ha->req_ring_index; in qla1280_32bit_start_scsi()
3158 &((struct cont_entry *) pkt)->dseg_0_address; in qla1280_32bit_start_scsi()
3174 remseg -= cnt; in qla1280_32bit_start_scsi()
3176 "continuation packet data - " in qla1280_32bit_start_scsi()
3184 "packet data - \n"); in qla1280_32bit_start_scsi()
3188 qla1280_dump_buffer(5, (char *)ha->request_ring_ptr, in qla1280_32bit_start_scsi()
3192 ha->req_ring_index++; in qla1280_32bit_start_scsi()
3193 if (ha->req_ring_index == REQUEST_ENTRY_CNT) { in qla1280_32bit_start_scsi()
3194 ha->req_ring_index = 0; in qla1280_32bit_start_scsi()
3195 ha->request_ring_ptr = ha->request_ring; in qla1280_32bit_start_scsi()
3197 ha->request_ring_ptr++; in qla1280_32bit_start_scsi()
3202 sp->flags |= SRB_SENT; in qla1280_32bit_start_scsi()
3203 ha->actthreads++; in qla1280_32bit_start_scsi()
3204 WRT_REG_WORD(&reg->mailbox4, ha->req_ring_index); in qla1280_32bit_start_scsi()
3227 static request_t *
3230 struct device_reg __iomem *reg = ha->iobase; in qla1280_req_pkt()
3241 for (timer = 15000000; timer; timer--) { in qla1280_req_pkt()
3242 if (ha->req_q_cnt > 0) { in qla1280_req_pkt()
3244 cnt = RD_REG_WORD(&reg->mailbox4); in qla1280_req_pkt()
3245 if (ha->req_ring_index < cnt) in qla1280_req_pkt()
3246 ha->req_q_cnt = cnt - ha->req_ring_index; in qla1280_req_pkt()
3248 ha->req_q_cnt = in qla1280_req_pkt()
3249 REQUEST_ENTRY_CNT - (ha->req_ring_index - cnt); in qla1280_req_pkt()
3253 if (ha->req_q_cnt > 0) { in qla1280_req_pkt()
3254 ha->req_q_cnt--; in qla1280_req_pkt()
3255 pkt = ha->request_ring_ptr; in qla1280_req_pkt()
3265 pkt->sys_define = (uint8_t) ha->req_ring_index; in qla1280_req_pkt()
3268 pkt->entry_count = 1; in qla1280_req_pkt()
3295 static void
3298 struct device_reg __iomem *reg = ha->iobase; in qla1280_isp_cmd()
3303 qla1280_dump_buffer(5, (char *)ha->request_ring_ptr, in qla1280_isp_cmd()
3307 ha->req_ring_index++; in qla1280_isp_cmd()
3308 if (ha->req_ring_index == REQUEST_ENTRY_CNT) { in qla1280_isp_cmd()
3309 ha->req_ring_index = 0; in qla1280_isp_cmd()
3310 ha->request_ring_ptr = ha->request_ring; in qla1280_isp_cmd()
3312 ha->request_ring_ptr++; in qla1280_isp_cmd()
3317 WRT_REG_WORD(&reg->mailbox4, ha->req_ring_index); in qla1280_isp_cmd()
3334 static void
3337 struct device_reg __iomem *reg = ha->iobase; in qla1280_isr()
3347 istatus = RD_REG_WORD(&reg->istatus); in qla1280_isr()
3352 mailbox[5] = RD_REG_WORD(&reg->mailbox5); in qla1280_isr()
3356 mailbox[0] = RD_REG_WORD_dmasync(&reg->semaphore); in qla1280_isr()
3363 *wptr++ = RD_REG_WORD(&reg->mailbox0); in qla1280_isr()
3364 *wptr++ = RD_REG_WORD(&reg->mailbox1); in qla1280_isr()
3365 *wptr = RD_REG_WORD(&reg->mailbox2); in qla1280_isr()
3368 *wptr++ = RD_REG_WORD(&reg->mailbox3); in qla1280_isr()
3369 *wptr++ = RD_REG_WORD(&reg->mailbox4); in qla1280_isr()
3371 *wptr++ = RD_REG_WORD(&reg->mailbox6); in qla1280_isr()
3372 *wptr = RD_REG_WORD(&reg->mailbox7); in qla1280_isr()
3377 WRT_REG_WORD(&reg->semaphore, 0); in qla1280_isr()
3378 WRT_REG_WORD(&reg->host_cmd, HC_CLR_RISC_INT); in qla1280_isr()
3389 if (ha->flags.online) { in qla1280_isr()
3395 sp = ha->outstanding_cmds[index]; in qla1280_isr()
3401 ha->outstanding_cmds[index] = NULL; in qla1280_isr()
3404 CMD_RESULT(sp->cmd) = 0; in qla1280_isr()
3405 CMD_HANDLE(sp->cmd) = COMPLETED_HANDLE; in qla1280_isr()
3408 list_add_tail(&sp->list, done_q); in qla1280_isr()
3420 ha->flags.reset_marker = 1; in qla1280_isr()
3422 ha->bus_settings[index].reset_marker = 1; in qla1280_isr()
3430 "qla1280: ISP System Error - mbx1=%xh, mbx2=" in qla1280_isr()
3445 case MBA_WAKEUP_THRES: /* Request Queue Wake-up */ in qla1280_isr()
3458 ha->flags.reset_marker = 1; in qla1280_isr()
3460 ha->bus_settings[index].reset_marker = 1; in qla1280_isr()
3472 memcpy((uint16_t *) ha->mailbox_out, wptr, in qla1280_isr()
3476 if(ha->mailbox_wait != NULL) in qla1280_isr()
3477 complete(ha->mailbox_wait); in qla1280_isr()
3482 WRT_REG_WORD(&reg->host_cmd, HC_CLR_RISC_INT); in qla1280_isr()
3489 if (!(ha->flags.online && !ha->mailbox_wait)) { in qla1280_isr()
3497 while (ha->rsp_ring_index != mailbox[5]) { in qla1280_isr()
3498 pkt = ha->response_ring_ptr; in qla1280_isr()
3500 dprintk(5, "qla1280_isr: ha->rsp_ring_index = 0x%x, mailbox[5]" in qla1280_isr()
3501 " = 0x%x\n", ha->rsp_ring_index, mailbox[5]); in qla1280_isr()
3505 if (pkt->entry_type == STATUS_TYPE) { in qla1280_isr()
3506 if ((le16_to_cpu(pkt->scsi_status) & 0xff) in qla1280_isr()
3507 || pkt->comp_status || pkt->entry_status) { in qla1280_isr()
3508 dprintk(2, "qla1280_isr: ha->rsp_ring_index = " in qla1280_isr()
3511 ha->rsp_ring_index, mailbox[5], in qla1280_isr()
3512 le16_to_cpu(pkt->comp_status), in qla1280_isr()
3513 le16_to_cpu(pkt->scsi_status)); in qla1280_isr()
3516 dprintk(2, "qla1280_isr: ha->rsp_ring_index = " in qla1280_isr()
3518 ha->rsp_ring_index, mailbox[5]); in qla1280_isr()
3524 if (pkt->entry_type == STATUS_TYPE || pkt->entry_status) { in qla1280_isr()
3526 ha->outstanding_cmds[pkt->handle]->cmd, in qla1280_isr()
3527 pkt->handle); in qla1280_isr()
3528 if (pkt->entry_type == STATUS_TYPE) in qla1280_isr()
3533 ha->rsp_ring_index++; in qla1280_isr()
3534 if (ha->rsp_ring_index == RESPONSE_ENTRY_CNT) { in qla1280_isr()
3535 ha->rsp_ring_index = 0; in qla1280_isr()
3536 ha->response_ring_ptr = ha->response_ring; in qla1280_isr()
3538 ha->response_ring_ptr++; in qla1280_isr()
3539 WRT_REG_WORD(&reg->mailbox5, ha->rsp_ring_index); in qla1280_isr()
3554 static void
3561 if (ha->flags.online && !ha->flags.reset_active && in qla1280_rst_aen()
3562 !ha->flags.abort_isp_active) { in qla1280_rst_aen()
3563 ha->flags.reset_active = 1; in qla1280_rst_aen()
3564 while (ha->flags.reset_marker) { in qla1280_rst_aen()
3566 ha->flags.reset_marker = 0; in qla1280_rst_aen()
3567 for (bus = 0; bus < ha->ports && in qla1280_rst_aen()
3568 !ha->flags.reset_marker; bus++) { in qla1280_rst_aen()
3569 if (ha->bus_settings[bus].reset_marker) { in qla1280_rst_aen()
3570 ha->bus_settings[bus].reset_marker = 0; in qla1280_rst_aen()
3591 static void
3598 uint32_t handle = le32_to_cpu(pkt->handle); in qla1280_status_entry()
3599 uint16_t scsi_status = le16_to_cpu(pkt->scsi_status); in qla1280_status_entry()
3600 uint16_t comp_status = le16_to_cpu(pkt->comp_status); in qla1280_status_entry()
3606 sp = ha->outstanding_cmds[handle]; in qla1280_status_entry()
3616 ha->outstanding_cmds[handle] = NULL; in qla1280_status_entry()
3618 cmd = sp->cmd; in qla1280_status_entry()
3638 le16_to_cpu(pkt->req_sense_length); in qla1280_status_entry()
3643 * scsi_cmnd->sense_buffer is in qla1280_status_entry()
3647 sense_sz = CMD_SNSLEN(cmd) - 1; in qla1280_status_entry()
3649 memcpy(cmd->sense_buffer, in qla1280_status_entry()
3650 &pkt->req_sense_data, sense_sz); in qla1280_status_entry()
3653 memset(cmd->sense_buffer + sense_sz, 0, in qla1280_status_entry()
3654 SCSI_SENSE_BUFFERSIZE - sense_sz); in qla1280_status_entry()
3662 (char *)cmd->sense_buffer, in qla1280_status_entry()
3667 CMD_HANDLE(sp->cmd) = COMPLETED_HANDLE; in qla1280_status_entry()
3670 list_add_tail(&sp->list, done_q); in qla1280_status_entry()
3684 static void
3689 uint32_t handle = le32_to_cpu(pkt->handle); in qla1280_error_entry()
3693 if (pkt->entry_status & BIT_3) in qla1280_error_entry()
3695 else if (pkt->entry_status & BIT_2) in qla1280_error_entry()
3697 else if (pkt->entry_status & BIT_1) in qla1280_error_entry()
3704 sp = ha->outstanding_cmds[handle]; in qla1280_error_entry()
3710 ha->outstanding_cmds[handle] = NULL; in qla1280_error_entry()
3713 if (pkt->entry_status & (BIT_3 + BIT_2)) { in qla1280_error_entry()
3715 /* CMD_RESULT(sp->cmd) = CS_BAD_PAYLOAD; */ in qla1280_error_entry()
3716 CMD_RESULT(sp->cmd) = DID_ERROR << 16; in qla1280_error_entry()
3717 } else if (pkt->entry_status & BIT_1) { /* FULL flag */ in qla1280_error_entry()
3718 CMD_RESULT(sp->cmd) = DID_BUS_BUSY << 16; in qla1280_error_entry()
3721 CMD_RESULT(sp->cmd) = DID_ERROR << 16; in qla1280_error_entry()
3724 CMD_HANDLE(sp->cmd) = COMPLETED_HANDLE; in qla1280_error_entry()
3727 list_add_tail(&sp->list, done_q); in qla1280_error_entry()
3730 else if (pkt->entry_type == COMMAND_A64_TYPE) { in qla1280_error_entry()
3748 static int
3751 struct device_reg __iomem *reg = ha->iobase; in qla1280_abort_isp()
3759 if (ha->flags.abort_isp_active || !ha->flags.online) in qla1280_abort_isp()
3762 ha->flags.abort_isp_active = 1; in qla1280_abort_isp()
3766 WRT_REG_WORD(&reg->host_cmd, HC_PAUSE_RISC); in qla1280_abort_isp()
3767 RD_REG_WORD(&reg->id_l); in qla1280_abort_isp()
3770 ha->host_no); in qla1280_abort_isp()
3774 sp = ha->outstanding_cmds[cnt]; in qla1280_abort_isp()
3776 cmd = sp->cmd; in qla1280_abort_isp()
3779 ha->outstanding_cmds[cnt] = NULL; in qla1280_abort_isp()
3780 list_add_tail(&sp->list, &ha->done_q); in qla1280_abort_isp()
3798 for (bus = 0; bus < ha->ports; bus++) in qla1280_abort_isp()
3801 ha->flags.abort_isp_active = 0; in qla1280_abort_isp()
3825 static u16
3854 static int
3858 struct device_reg __iomem *reg = ha->iobase; in qla1280_check_for_dead_scsi_bus()
3860 if (ha->bus_settings[bus].scsi_bus_dead) { in qla1280_check_for_dead_scsi_bus()
3861 WRT_REG_WORD(&reg->host_cmd, HC_PAUSE_RISC); in qla1280_check_for_dead_scsi_bus()
3862 config_reg = RD_REG_WORD(&reg->cfg_1); in qla1280_check_for_dead_scsi_bus()
3863 WRT_REG_WORD(&reg->cfg_1, SET_SXP_BANK); in qla1280_check_for_dead_scsi_bus()
3864 scsi_control = RD_REG_WORD(&reg->scsiControlPins); in qla1280_check_for_dead_scsi_bus()
3865 WRT_REG_WORD(&reg->cfg_1, config_reg); in qla1280_check_for_dead_scsi_bus()
3866 WRT_REG_WORD(&reg->host_cmd, HC_RELEASE_RISC); in qla1280_check_for_dead_scsi_bus()
3869 ha->bus_settings[bus].scsi_bus_dead = 1; in qla1280_check_for_dead_scsi_bus()
3872 ha->bus_settings[bus].scsi_bus_dead = 0; in qla1280_check_for_dead_scsi_bus()
3873 ha->bus_settings[bus].failed_reset_count = 0; in qla1280_check_for_dead_scsi_bus()
3879 static void
3886 bus = device->channel; in qla1280_get_target_parameters()
3887 target = device->id; in qla1280_get_target_parameters()
3888 lun = device->lun; in qla1280_get_target_parameters()
3897 printk(KERN_INFO "scsi(%li:%d:%d:%d):", ha->host_no, bus, target, lun); in qla1280_get_target_parameters()
3909 if (device->simple_tags) in qla1280_get_target_parameters()
3910 printk(KERN_CONT ", Tagged queuing: depth %d", device->queue_depth); in qla1280_get_target_parameters()
3916 static void
3924 printk(KERN_DEBUG "---------------------------------------------" in __qla1280_dump_buffer()
3925 "------------------\n"); in __qla1280_dump_buffer()
3945 static void
3954 ha = (struct scsi_qla_host *)host->hostdata; in __qla1280_print_scsi_cmd()
3962 for (i = 0; i < cmd->cmd_len; i++) { in __qla1280_print_scsi_cmd()
3963 printk("0x%02x ", cmd->cmnd[i]); in __qla1280_print_scsi_cmd()
3968 /* if (cmd->use_sg) in __qla1280_print_scsi_cmd()
3970 sg = (struct scatterlist *) cmd->request_buffer; in __qla1280_print_scsi_cmd()
3972 qla1280_dump_buffer(1, (char *)sg, (cmd->use_sg*sizeof(struct scatterlist))); in __qla1280_print_scsi_cmd()
3975 scsi_cmd_to_rq(cmd)->tag, cmd->transfersize); in __qla1280_print_scsi_cmd()
3977 cmd->underflow, cmd->sc_data_direction); in __qla1280_print_scsi_cmd()
3984 static void
3995 if ((sp = ha->outstanding_cmds[i]) == NULL) in ql1280_dump_device()
3997 if ((cp = sp->cmd) == NULL) in ql1280_dump_device()
4019 static struct setup_tokens setup_token[] __initdata =
4036 static int __init
4097 static int __init
4101 long ret = -1; in qla1280_get_token()
4108 if (!strncmp(setup_token[i].token, str, (sep - str))) { in qla1280_get_token()
4119 static const struct scsi_host_template qla1280_driver_template = {
4132 .this_id = -1,
4138 static int
4141 int devnum = id->driver_data; in qla1280_probe_one()
4145 int error = -ENODEV; in qla1280_probe_one()
4148 if (pdev->subsystem_vendor == PCI_VENDOR_ID_AMI) { in qla1280_probe_one()
4155 bdp->name, pdev->bus->number, PCI_SLOT(pdev->devfn)); in qla1280_probe_one()
4165 error = -ENOMEM; in qla1280_probe_one()
4173 ha = (struct scsi_qla_host *)host->hostdata; in qla1280_probe_one()
4176 ha->pdev = pdev; in qla1280_probe_one()
4177 ha->devnum = devnum; /* specifies microcode load address */ in qla1280_probe_one()
4180 if (dma_set_mask_and_coherent(&ha->pdev->dev, DMA_BIT_MASK(64))) { in qla1280_probe_one()
4181 if (dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(32))) { in qla1280_probe_one()
4183 "suitable DMA mask - aborting\n", ha->host_no); in qla1280_probe_one()
4184 error = -ENODEV; in qla1280_probe_one()
4189 ha->host_no); in qla1280_probe_one()
4191 if (dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(32))) { in qla1280_probe_one()
4193 "suitable DMA mask - aborting\n", ha->host_no); in qla1280_probe_one()
4194 error = -ENODEV; in qla1280_probe_one()
4199 ha->request_ring = dma_alloc_coherent(&ha->pdev->dev, in qla1280_probe_one()
4201 &ha->request_dma, GFP_KERNEL); in qla1280_probe_one()
4202 if (!ha->request_ring) { in qla1280_probe_one()
4207 ha->response_ring = dma_alloc_coherent(&ha->pdev->dev, in qla1280_probe_one()
4209 &ha->response_dma, GFP_KERNEL); in qla1280_probe_one()
4210 if (!ha->response_ring) { in qla1280_probe_one()
4215 ha->ports = bdp->numPorts; in qla1280_probe_one()
4217 ha->host = host; in qla1280_probe_one()
4218 ha->host_no = host->host_no; in qla1280_probe_one()
4220 host->irq = pdev->irq; in qla1280_probe_one()
4221 host->max_channel = bdp->numPorts - 1; in qla1280_probe_one()
4222 host->max_lun = MAX_LUNS - 1; in qla1280_probe_one()
4223 host->max_id = MAX_TARGETS; in qla1280_probe_one()
4224 host->max_sectors = 1024; in qla1280_probe_one()
4225 host->unique_id = host->host_no; in qla1280_probe_one()
4227 error = -ENODEV; in qla1280_probe_one()
4230 ha->mmpbase = pci_ioremap_bar(ha->pdev, 1); in qla1280_probe_one()
4231 if (!ha->mmpbase) { in qla1280_probe_one()
4236 host->base = (unsigned long)ha->mmpbase; in qla1280_probe_one()
4237 ha->iobase = (struct device_reg __iomem *)ha->mmpbase; in qla1280_probe_one()
4239 host->io_port = pci_resource_start(ha->pdev, 0); in qla1280_probe_one()
4240 if (!request_region(host->io_port, 0xff, "qla1280")) { in qla1280_probe_one()
4242 "0x%04lx-0x%04lx - already in use\n", in qla1280_probe_one()
4243 host->io_port, host->io_port + 0xff); in qla1280_probe_one()
4247 ha->iobase = (struct device_reg *)host->io_port; in qla1280_probe_one()
4250 INIT_LIST_HEAD(&ha->done_q); in qla1280_probe_one()
4255 if (request_irq(pdev->irq, qla1280_intr_handler, IRQF_SHARED, in qla1280_probe_one()
4258 "in use\n", pdev->irq); in qla1280_probe_one()
4269 host->this_id = ha->bus_settings[0].id; in qla1280_probe_one()
4273 error = scsi_add_host(host, &pdev->dev); in qla1280_probe_one()
4283 free_irq(pdev->irq, ha); in qla1280_probe_one()
4286 iounmap(ha->mmpbase); in qla1280_probe_one()
4288 release_region(host->io_port, 0xff); in qla1280_probe_one()
4291 dma_free_coherent(&ha->pdev->dev, in qla1280_probe_one()
4293 ha->response_ring, ha->response_dma); in qla1280_probe_one()
4295 dma_free_coherent(&ha->pdev->dev, in qla1280_probe_one()
4297 ha->request_ring, ha->request_dma); in qla1280_probe_one()
4307 static void
4311 struct scsi_qla_host *ha = (struct scsi_qla_host *)host->hostdata; in qla1280_remove_one()
4317 free_irq(pdev->irq, ha); in qla1280_remove_one()
4320 iounmap(ha->mmpbase); in qla1280_remove_one()
4322 release_region(host->io_port, 0xff); in qla1280_remove_one()
4325 dma_free_coherent(&ha->pdev->dev, in qla1280_remove_one()
4327 ha->request_ring, ha->request_dma); in qla1280_remove_one()
4328 dma_free_coherent(&ha->pdev->dev, in qla1280_remove_one()
4330 ha->response_ring, ha->response_dma); in qla1280_remove_one()
4337 static struct pci_driver qla1280_pci_driver = {
4344 static int __init
4367 static void __exit