aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/qla2xxx/qla_os.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-01-25 20:19:08 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2008-01-25 20:19:08 -0500
commit9b73e76f3cf63379dcf45fcd4f112f5812418d0a (patch)
tree4e6bef87cd0cd6d848fc39a5ae25b981dbbe035b /drivers/scsi/qla2xxx/qla_os.c
parent50d9a126240f9961cfdd063336bbeb91f77a7dce (diff)
parent23c3e290fb9ce38cabc2822b47583fc8702411bf (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6: (200 commits) [SCSI] usbstorage: use last_sector_bug flag universally [SCSI] libsas: abstract STP task status into a function [SCSI] ultrastor: clean up inline asm warnings [SCSI] aic7xxx: fix firmware build [SCSI] aacraid: fib context lock for management ioctls [SCSI] ch: remove forward declarations [SCSI] ch: fix device minor number management bug [SCSI] ch: handle class_device_create failure properly [SCSI] NCR5380: fix section mismatch [SCSI] sg: fix /proc/scsi/sg/devices when no SCSI devices [SCSI] IB/iSER: add logical unit reset support [SCSI] don't use __GFP_DMA for sense buffers if not required [SCSI] use dynamically allocated sense buffer [SCSI] scsi.h: add macro for enclosure bit of inquiry data [SCSI] sd: add fix for devices with last sector access problems [SCSI] fix pcmcia compile problem [SCSI] aacraid: add Voodoo Lite class of cards. [SCSI] aacraid: add new driver features flags [SCSI] qla2xxx: Update version number to 8.02.00-k7. [SCSI] qla2xxx: Issue correct MBC_INITIALIZE_FIRMWARE command. ...
Diffstat (limited to 'drivers/scsi/qla2xxx/qla_os.c')
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c80
1 files changed, 29 insertions, 51 deletions
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 8ecc0470b8f3..aba1e6d48066 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -105,13 +105,12 @@ static int qla2xxx_eh_abort(struct scsi_cmnd *);
105static int qla2xxx_eh_device_reset(struct scsi_cmnd *); 105static int qla2xxx_eh_device_reset(struct scsi_cmnd *);
106static int qla2xxx_eh_bus_reset(struct scsi_cmnd *); 106static int qla2xxx_eh_bus_reset(struct scsi_cmnd *);
107static int qla2xxx_eh_host_reset(struct scsi_cmnd *); 107static int qla2xxx_eh_host_reset(struct scsi_cmnd *);
108static int qla2x00_loop_reset(scsi_qla_host_t *ha);
109static int qla2x00_device_reset(scsi_qla_host_t *, fc_port_t *); 108static int qla2x00_device_reset(scsi_qla_host_t *, fc_port_t *);
110 109
111static int qla2x00_change_queue_depth(struct scsi_device *, int); 110static int qla2x00_change_queue_depth(struct scsi_device *, int);
112static int qla2x00_change_queue_type(struct scsi_device *, int); 111static int qla2x00_change_queue_type(struct scsi_device *, int);
113 112
114struct scsi_host_template qla2x00_driver_template = { 113static struct scsi_host_template qla2x00_driver_template = {
115 .module = THIS_MODULE, 114 .module = THIS_MODULE,
116 .name = QLA2XXX_DRIVER_NAME, 115 .name = QLA2XXX_DRIVER_NAME,
117 .queuecommand = qla2x00_queuecommand, 116 .queuecommand = qla2x00_queuecommand,
@@ -179,13 +178,6 @@ struct scsi_transport_template *qla2xxx_transport_vport_template = NULL;
179 * Timer routines 178 * Timer routines
180 */ 179 */
181 180
182void qla2x00_timer(scsi_qla_host_t *);
183
184__inline__ void qla2x00_start_timer(scsi_qla_host_t *,
185 void *, unsigned long);
186static __inline__ void qla2x00_restart_timer(scsi_qla_host_t *, unsigned long);
187__inline__ void qla2x00_stop_timer(scsi_qla_host_t *);
188
189__inline__ void 181__inline__ void
190qla2x00_start_timer(scsi_qla_host_t *ha, void *func, unsigned long interval) 182qla2x00_start_timer(scsi_qla_host_t *ha, void *func, unsigned long interval)
191{ 183{
@@ -203,7 +195,7 @@ qla2x00_restart_timer(scsi_qla_host_t *ha, unsigned long interval)
203 mod_timer(&ha->timer, jiffies + interval * HZ); 195 mod_timer(&ha->timer, jiffies + interval * HZ);
204} 196}
205 197
206__inline__ void 198static __inline__ void
207qla2x00_stop_timer(scsi_qla_host_t *ha) 199qla2x00_stop_timer(scsi_qla_host_t *ha)
208{ 200{
209 del_timer_sync(&ha->timer); 201 del_timer_sync(&ha->timer);
@@ -214,12 +206,11 @@ static int qla2x00_do_dpc(void *data);
214 206
215static void qla2x00_rst_aen(scsi_qla_host_t *); 207static void qla2x00_rst_aen(scsi_qla_host_t *);
216 208
217uint8_t qla2x00_mem_alloc(scsi_qla_host_t *); 209static uint8_t qla2x00_mem_alloc(scsi_qla_host_t *);
218void qla2x00_mem_free(scsi_qla_host_t *ha); 210static void qla2x00_mem_free(scsi_qla_host_t *ha);
219static int qla2x00_allocate_sp_pool( scsi_qla_host_t *ha); 211static int qla2x00_allocate_sp_pool( scsi_qla_host_t *ha);
220static void qla2x00_free_sp_pool(scsi_qla_host_t *ha); 212static void qla2x00_free_sp_pool(scsi_qla_host_t *ha);
221static void qla2x00_sp_free_dma(scsi_qla_host_t *, srb_t *); 213static void qla2x00_sp_free_dma(scsi_qla_host_t *, srb_t *);
222void qla2x00_sp_compl(scsi_qla_host_t *ha, srb_t *);
223 214
224/* -------------------------------------------------------------------------- */ 215/* -------------------------------------------------------------------------- */
225 216
@@ -1060,7 +1051,7 @@ eh_host_reset_lock:
1060* Returns: 1051* Returns:
1061* 0 = success 1052* 0 = success
1062*/ 1053*/
1063static int 1054int
1064qla2x00_loop_reset(scsi_qla_host_t *ha) 1055qla2x00_loop_reset(scsi_qla_host_t *ha)
1065{ 1056{
1066 int ret; 1057 int ret;
@@ -1479,8 +1470,7 @@ qla2x00_set_isp_flags(scsi_qla_host_t *ha)
1479static int 1470static int
1480qla2x00_iospace_config(scsi_qla_host_t *ha) 1471qla2x00_iospace_config(scsi_qla_host_t *ha)
1481{ 1472{
1482 unsigned long pio, pio_len, pio_flags; 1473 resource_size_t pio;
1483 unsigned long mmio, mmio_len, mmio_flags;
1484 1474
1485 if (pci_request_selected_regions(ha->pdev, ha->bars, 1475 if (pci_request_selected_regions(ha->pdev, ha->bars,
1486 QLA2XXX_DRIVER_NAME)) { 1476 QLA2XXX_DRIVER_NAME)) {
@@ -1495,10 +1485,8 @@ qla2x00_iospace_config(scsi_qla_host_t *ha)
1495 1485
1496 /* We only need PIO for Flash operations on ISP2312 v2 chips. */ 1486 /* We only need PIO for Flash operations on ISP2312 v2 chips. */
1497 pio = pci_resource_start(ha->pdev, 0); 1487 pio = pci_resource_start(ha->pdev, 0);
1498 pio_len = pci_resource_len(ha->pdev, 0); 1488 if (pci_resource_flags(ha->pdev, 0) & IORESOURCE_IO) {
1499 pio_flags = pci_resource_flags(ha->pdev, 0); 1489 if (pci_resource_len(ha->pdev, 0) < MIN_IOBASE_LEN) {
1500 if (pio_flags & IORESOURCE_IO) {
1501 if (pio_len < MIN_IOBASE_LEN) {
1502 qla_printk(KERN_WARNING, ha, 1490 qla_printk(KERN_WARNING, ha,
1503 "Invalid PCI I/O region size (%s)...\n", 1491 "Invalid PCI I/O region size (%s)...\n",
1504 pci_name(ha->pdev)); 1492 pci_name(ha->pdev));
@@ -1511,28 +1499,23 @@ qla2x00_iospace_config(scsi_qla_host_t *ha)
1511 pio = 0; 1499 pio = 0;
1512 } 1500 }
1513 ha->pio_address = pio; 1501 ha->pio_address = pio;
1514 ha->pio_length = pio_len;
1515 1502
1516skip_pio: 1503skip_pio:
1517 /* Use MMIO operations for all accesses. */ 1504 /* Use MMIO operations for all accesses. */
1518 mmio = pci_resource_start(ha->pdev, 1); 1505 if (!(pci_resource_flags(ha->pdev, 1) & IORESOURCE_MEM)) {
1519 mmio_len = pci_resource_len(ha->pdev, 1);
1520 mmio_flags = pci_resource_flags(ha->pdev, 1);
1521
1522 if (!(mmio_flags & IORESOURCE_MEM)) {
1523 qla_printk(KERN_ERR, ha, 1506 qla_printk(KERN_ERR, ha,
1524 "region #0 not an MMIO resource (%s), aborting\n", 1507 "region #1 not an MMIO resource (%s), aborting\n",
1525 pci_name(ha->pdev)); 1508 pci_name(ha->pdev));
1526 goto iospace_error_exit; 1509 goto iospace_error_exit;
1527 } 1510 }
1528 if (mmio_len < MIN_IOBASE_LEN) { 1511 if (pci_resource_len(ha->pdev, 1) < MIN_IOBASE_LEN) {
1529 qla_printk(KERN_ERR, ha, 1512 qla_printk(KERN_ERR, ha,
1530 "Invalid PCI mem region size (%s), aborting\n", 1513 "Invalid PCI mem region size (%s), aborting\n",
1531 pci_name(ha->pdev)); 1514 pci_name(ha->pdev));
1532 goto iospace_error_exit; 1515 goto iospace_error_exit;
1533 } 1516 }
1534 1517
1535 ha->iobase = ioremap(mmio, MIN_IOBASE_LEN); 1518 ha->iobase = ioremap(pci_resource_start(ha->pdev, 1), MIN_IOBASE_LEN);
1536 if (!ha->iobase) { 1519 if (!ha->iobase) {
1537 qla_printk(KERN_ERR, ha, 1520 qla_printk(KERN_ERR, ha,
1538 "cannot remap MMIO (%s), aborting\n", pci_name(ha->pdev)); 1521 "cannot remap MMIO (%s), aborting\n", pci_name(ha->pdev));
@@ -1701,9 +1684,10 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
1701 /* load the F/W, read paramaters, and init the H/W */ 1684 /* load the F/W, read paramaters, and init the H/W */
1702 ha->instance = num_hosts; 1685 ha->instance = num_hosts;
1703 1686
1704 init_MUTEX(&ha->mbx_cmd_sem);
1705 init_MUTEX(&ha->vport_sem); 1687 init_MUTEX(&ha->vport_sem);
1706 init_MUTEX_LOCKED(&ha->mbx_intr_sem); 1688 init_completion(&ha->mbx_cmd_comp);
1689 complete(&ha->mbx_cmd_comp);
1690 init_completion(&ha->mbx_intr_comp);
1707 1691
1708 INIT_LIST_HEAD(&ha->list); 1692 INIT_LIST_HEAD(&ha->list);
1709 INIT_LIST_HEAD(&ha->fcports); 1693 INIT_LIST_HEAD(&ha->fcports);
@@ -1807,6 +1791,8 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
1807 1791
1808 qla2x00_init_host_attr(ha); 1792 qla2x00_init_host_attr(ha);
1809 1793
1794 qla2x00_dfs_setup(ha);
1795
1810 qla_printk(KERN_INFO, ha, "\n" 1796 qla_printk(KERN_INFO, ha, "\n"
1811 " QLogic Fibre Channel HBA Driver: %s\n" 1797 " QLogic Fibre Channel HBA Driver: %s\n"
1812 " QLogic %s - %s\n" 1798 " QLogic %s - %s\n"
@@ -1838,6 +1824,8 @@ qla2x00_remove_one(struct pci_dev *pdev)
1838 1824
1839 ha = pci_get_drvdata(pdev); 1825 ha = pci_get_drvdata(pdev);
1840 1826
1827 qla2x00_dfs_remove(ha);
1828
1841 qla2x00_free_sysfs_attr(ha); 1829 qla2x00_free_sysfs_attr(ha);
1842 1830
1843 fc_remove_host(ha->host); 1831 fc_remove_host(ha->host);
@@ -1871,8 +1859,11 @@ qla2x00_free_device(scsi_qla_host_t *ha)
1871 kthread_stop(t); 1859 kthread_stop(t);
1872 } 1860 }
1873 1861
1862 if (ha->flags.fce_enabled)
1863 qla2x00_disable_fce_trace(ha, NULL, NULL);
1864
1874 if (ha->eft) 1865 if (ha->eft)
1875 qla2x00_trace_control(ha, TC_DISABLE, 0, 0); 1866 qla2x00_disable_eft_trace(ha);
1876 1867
1877 ha->flags.online = 0; 1868 ha->flags.online = 0;
1878 1869
@@ -2016,7 +2007,7 @@ qla2x00_mark_all_devices_lost(scsi_qla_host_t *ha, int defer)
2016* 0 = success. 2007* 0 = success.
2017* 1 = failure. 2008* 1 = failure.
2018*/ 2009*/
2019uint8_t 2010static uint8_t
2020qla2x00_mem_alloc(scsi_qla_host_t *ha) 2011qla2x00_mem_alloc(scsi_qla_host_t *ha)
2021{ 2012{
2022 char name[16]; 2013 char name[16];
@@ -2213,7 +2204,7 @@ qla2x00_mem_alloc(scsi_qla_host_t *ha)
2213* Input: 2204* Input:
2214* ha = adapter block pointer. 2205* ha = adapter block pointer.
2215*/ 2206*/
2216void 2207static void
2217qla2x00_mem_free(scsi_qla_host_t *ha) 2208qla2x00_mem_free(scsi_qla_host_t *ha)
2218{ 2209{
2219 struct list_head *fcpl, *fcptemp; 2210 struct list_head *fcpl, *fcptemp;
@@ -2228,6 +2219,10 @@ qla2x00_mem_free(scsi_qla_host_t *ha)
2228 /* free sp pool */ 2219 /* free sp pool */
2229 qla2x00_free_sp_pool(ha); 2220 qla2x00_free_sp_pool(ha);
2230 2221
2222 if (ha->fce)
2223 dma_free_coherent(&ha->pdev->dev, FCE_SIZE, ha->fce,
2224 ha->fce_dma);
2225
2231 if (ha->fw_dump) { 2226 if (ha->fw_dump) {
2232 if (ha->eft) 2227 if (ha->eft)
2233 dma_free_coherent(&ha->pdev->dev, 2228 dma_free_coherent(&ha->pdev->dev,
@@ -2748,23 +2743,6 @@ qla2x00_timer(scsi_qla_host_t *ha)
2748 qla2x00_restart_timer(ha, WATCH_INTERVAL); 2743 qla2x00_restart_timer(ha, WATCH_INTERVAL);
2749} 2744}
2750 2745
2751/* XXX(hch): crude hack to emulate a down_timeout() */
2752int
2753qla2x00_down_timeout(struct semaphore *sema, unsigned long timeout)
2754{
2755 const unsigned int step = 100; /* msecs */
2756 unsigned int iterations = jiffies_to_msecs(timeout)/100;
2757
2758 do {
2759 if (!down_trylock(sema))
2760 return 0;
2761 if (msleep_interruptible(step))
2762 break;
2763 } while (--iterations > 0);
2764
2765 return -ETIMEDOUT;
2766}
2767
2768/* Firmware interface routines. */ 2746/* Firmware interface routines. */
2769 2747
2770#define FW_BLOBS 6 2748#define FW_BLOBS 6