qla4xxx: use pci_register_driver
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/10 qla4xxx: use pci_register_driver
From: Doug Maxey <[email protected]>
- use the current pci_register_driver().
- change order of calls in module_exit().
---
drivers/scsi/qla4xxx/ql4_os.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/scsi/qla4xxx/ql4_os.c +3 -3
@@ -1821,11 +1821,11 @@ static int __init qla4xxx_module_init(vo goto release_srb_cache; } -printk (KERN_INFO "QLogic iSCSI HBA Driver\n" ); - ret =pci_module_init (&qla4xxx_pci_driver); + ret =pci_register_driver (&qla4xxx_pci_driver);if (ret) goto unregister_transport; +printk (KERN_INFO "QLogic iSCSI HBA Driver\n" );return 0 ; unregister_transport:
@@ -1839,8 +1839,8 @@ no_srp_cache: static void __exit qla4xxx_module_exit(void) {pci_unregister_driver (&qla4xxx_pci_driver); -kmem_cache_destroy (srb_cachep);iscsi_unregister_transport (&qla4xxx_iscsi_transport); +kmem_cache_destroy (srb_cachep); }module_init (qla4xxx_module_init);
PATCH 2/10 qla4xxx: move qla4xxx_reset_target defn before call
In reply to a message not in the archiveFrom: Doug Maxey <[email protected]>
- move the defn to before the call.
- make defn static.
---
drivers/scsi/qla4xxx/ql4_os.c | 31 ++++++++++++++++--------------- 1 files changed, 16 insertions(+), 15 deletions(-)
drivers/scsi/qla4xxx/ql4_os.c +16 -15
@@ -1645,6 +1645,22 @@ eh_dev_reset_done: }/** +* qla4xxx_reset_target - performs target reset +* @ha: Pointer to host adapter structure. +* @ddb_entry: Pointer to device database entry +* +* This routine issues either a warm or cold target reset to the +* specified device. The caller must ensure that the ddb_entry pointer +* is valid before calling this routine. +* +**/ +static int qla4xxx_reset_target (struct scsi_qla_host *ha, +struct ddb_entry *ddb_entry) +{ +return QLA_SUCCESS ; +} + +/** * qla4xxx_eh_bus_reset - callback to issue bus reset. * @cmd: Pointer to Linux's SCSI command structure *
@@ -1692,21 +1708,6 @@ static int qla4xxx_eh_bus_reset(struct s }/** -* qla4xxx_reset_target - performs target reset -* @ha: Pointer to host adapter structure. -* @ddb_entry: Pointer to device database entry -* -* This routine issues either a warm or cold target reset to the -* specified device. The caller must ensure that the ddb_entry pointer -* is valid before calling this routine. -* -**/ -int qla4xxx_reset_target (struct scsi_qla_host *ha,struct ddb_entry *ddb_entry) -{ -return QLA_SUCCESS ; -} - -/** * qla4xxx_flush_active_srbs - returns all outstanding i/o requests to O.S. * @ha: Pointer to host adapter structure. *
PATCH 3/10 qla4xxx: make one file funcs static 01
In reply to a message not in the archiveFrom: Doug Maxey <[email protected]>
- make defns static as they are used only in file scope.
---
drivers/scsi/qla4xxx/ql4_os.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/scsi/qla4xxx/ql4_os.c +3 -3
@@ -1496,7 +1496,7 @@ static int qla4xxx_eh_wait_on_command(st* qla4xxx_wait_for_hba_online - waits for HBA to come online * @ha: Pointer to host adapter structure **/ -int qla4xxx_wait_for_hba_online (struct scsi_qla_host *ha) +static int qla4xxx_wait_for_hba_online (struct scsi_qla_host *ha) {unsigned long wait_online;
@@ -1545,8 +1545,8 @@ static int qla4xxx_eh_abort(struct scsi_* This function waits for all outstanding commands to a lun to complete. It * returns 0 if all pending commands are returned and 1 otherwise. **/ -int qla4xxx_eh_wait_for_active_target_commands (struct scsi_qla_host *ha,int t, -int l) +static int qla4xxx_eh_wait_for_active_target_commands (struct scsi_qla_host *ha, +int t,int l) {int cnt;int status;
PATCH 4/10 qla4xxx: qla4xxx_mem_alloc-defn-before-use
In reply to a message not in the archiveFrom: Doug Maxey <[email protected]>
- move the defn to before the call.
- make defn static.
---
drivers/scsi/qla4xxx/ql4_os.c | 206 ++++++++++++++++++++--------------------- 1 files changed, 102 insertions(+), 104 deletions(-)
drivers/scsi/qla4xxx/ql4_os.c +102 -104
@@ -44,8 +44,6 @@ MODULE_PARM_DESC(extended_error_logging,* SCSI host template entry points */ -static int qla4xxx_mem_alloc (struct scsi_qla_host *ha); -static void qla4xxx_mem_free (struct scsi_qla_host *ha);static void qla4xxx_timer (struct scsi_qla_host *ha);static void qla4xxx_do_dpc (void *data);static void qla4xxx_flush_active_srbs (struct scsi_qla_host *ha);
@@ -465,6 +463,108 @@ qc_fail_command: }/** +* qla4xxx_mem_free - frees memory allocated to adapter +* @ha: Pointer to host adapter structure. +* +* Frees memory previously allocated by qla4xxx_mem_alloc +**/ +static void qla4xxx_mem_free (struct scsi_qla_host *ha) +{ +if (ha->queues) +dma_free_coherent (&ha->pdev->dev, ha->queues_len, ha->queues, + ha->queues_dma); + + ha->queues_len =0 ; + ha->queues =NULL ; + ha->queues_dma =0 ; + ha->request_ring =NULL ; + ha->request_dma =0 ; + ha->response_ring =NULL ; + ha->response_dma =0 ; + ha->shadow_regs =NULL ; + ha->shadow_regs_dma =0 ; + +/* Free srb pool. */ +if (ha->srb_mempool) +mempool_destroy (ha->srb_mempool); + + ha->srb_mempool =NULL ; + +/* release io space registers */ +if (ha->reg) +iounmap (ha->reg); +pci_release_regions (ha->pdev); +} + +/** +* qla4xxx_mem_alloc - allocates memory for use by adapter. +* @ha: Pointer to host adapter structure +* +* Allocates DMA memory for request and response queues. Also allocates memory +* for srbs. +**/ +static int qla4xxx_mem_alloc (struct scsi_qla_host *ha) +{ +unsigned long align; + +/* Allocate contiguous block of DMA memory for queues. */ + ha->queues_len = ((REQUEST_QUEUE_DEPTH *QUEUE_SIZE ) + + (RESPONSE_QUEUE_DEPTH *QUEUE_SIZE ) + +sizeof (struct shadow_regs ) + +MEM_ALIGN_VALUE + + (PAGE_SIZE -1 )) & ~(PAGE_SIZE -1 ); + ha->queues =dma_alloc_coherent (&ha->pdev->dev, ha->queues_len, + &ha->queues_dma,GFP_KERNEL ); +if (ha->queues ==NULL ) { +dev_warn (&ha->pdev->dev, +"Memory Allocation failed - queues.\n" ); + goto mem_alloc_error_exit; + } +memset (ha->queues,0 , ha->queues_len); + +/* +* As per RISC alignment requirements -- the bus-address must be a +* multiple of the request-ring size (in bytes). +*/ + align =0 ; +if ((unsigned long )ha->queues_dma & (MEM_ALIGN_VALUE -1 )) + align =MEM_ALIGN_VALUE - ((unsigned long )ha->queues_dma & + (MEM_ALIGN_VALUE -1 )); + +/* Update request and response queue pointers. */ + ha->request_dma = ha->queues_dma + align; + ha->request_ring = (struct queue_entry *) (ha->queues + align); + ha->response_dma = ha->queues_dma + align + + (REQUEST_QUEUE_DEPTH *QUEUE_SIZE ); + ha->response_ring = (struct queue_entry *) (ha->queues + align + + (REQUEST_QUEUE_DEPTH * +QUEUE_SIZE )); + ha->shadow_regs_dma = ha->queues_dma + align + + (REQUEST_QUEUE_DEPTH *QUEUE_SIZE ) + + (RESPONSE_QUEUE_DEPTH *QUEUE_SIZE ); + ha->shadow_regs = (struct shadow_regs *) (ha->queues + align + + (REQUEST_QUEUE_DEPTH * +QUEUE_SIZE ) + + (RESPONSE_QUEUE_DEPTH * +QUEUE_SIZE )); + +/* Allocate memory for srb pool. */ + ha->srb_mempool =mempool_create (SRB_MIN_REQ , mempool_alloc_slab, + mempool_free_slab, srb_cachep); +if (ha->srb_mempool ==NULL ) { +dev_warn (&ha->pdev->dev, +"Memory Allocation failed - SRB Pool.\n" ); + goto mem_alloc_error_exit; + } + +return QLA_SUCCESS ; + +mem_alloc_error_exit: +qla4xxx_mem_free (ha); +return QLA_ERROR ; +} + +/** * qla4xxx_probe_adapter - callback function to probe HBA * @pdev: pointer to pci_dev structure * @pci_device_id: pointer to pci_device entry
@@ -769,108 +869,6 @@ void qla4xxx_config_dma_addressing(struc retval =pci_set_dma_mask (ha->pdev,DMA_32BIT_MASK ); } -/** -* qla4xxx_mem_alloc - allocates memory for use by adapter. -* @ha: Pointer to host adapter structure -* -* Allocates DMA memory for request and response queues. Also allocates memory -* for srbs. -**/ -static int qla4xxx_mem_alloc (struct scsi_qla_host *ha) -{ -unsigned long align; - -/* Allocate contiguous block of DMA memory for queues. */ - ha->queues_len = ((REQUEST_QUEUE_DEPTH *QUEUE_SIZE ) + - (RESPONSE_QUEUE_DEPTH *QUEUE_SIZE ) + -sizeof (struct shadow_regs ) + -MEM_ALIGN_VALUE + - (PAGE_SIZE -1 )) & ~(PAGE_SIZE -1 ); - ha->queues =dma_alloc_coherent (&ha->pdev->dev, ha->queues_len, - &ha->queues_dma,GFP_KERNEL ); -if (ha->queues ==NULL ) { -dev_warn (&ha->pdev->dev, -"Memory Allocation failed - queues.\n" ); - goto mem_alloc_error_exit; - } -memset (ha->queues,0 , ha->queues_len); - -/* -* As per RISC alignment requirements -- the bus-address must be a -* multiple of the request-ring size (in bytes). -*/ - align =0 ; -if ((unsigned long )ha->queues_dma & (MEM_ALIGN_VALUE -1 )) - align =MEM_ALIGN_VALUE - ((unsigned long )ha->queues_dma & - (MEM_ALIGN_VALUE -1 )); - -/* Update request and response queue pointers. */ - ha->request_dma = ha->queues_dma + align; - ha->request_ring = (struct queue_entry *) (ha->queues + align); - ha->response_dma = ha->queues_dma + align + - (REQUEST_QUEUE_DEPTH *QUEUE_SIZE ); - ha->response_ring = (struct queue_entry *) (ha->queues + align + - (REQUEST_QUEUE_DEPTH * -QUEUE_SIZE )); - ha->shadow_regs_dma = ha->queues_dma + align + - (REQUEST_QUEUE_DEPTH *QUEUE_SIZE ) + - (RESPONSE_QUEUE_DEPTH *QUEUE_SIZE ); - ha->shadow_regs = (struct shadow_regs *) (ha->queues + align + - (REQUEST_QUEUE_DEPTH * -QUEUE_SIZE ) + - (RESPONSE_QUEUE_DEPTH * -QUEUE_SIZE )); - -/* Allocate memory for srb pool. */ - ha->srb_mempool =mempool_create (SRB_MIN_REQ , mempool_alloc_slab, - mempool_free_slab, srb_cachep); -if (ha->srb_mempool ==NULL ) { -dev_warn (&ha->pdev->dev, -"Memory Allocation failed - SRB Pool.\n" ); - goto mem_alloc_error_exit; - } - -return QLA_SUCCESS ; - -mem_alloc_error_exit: -qla4xxx_mem_free (ha); -return QLA_ERROR ; -} - -/** -* qla4xxx_mem_free - frees memory allocated to adapter -* @ha: Pointer to host adapter structure. -* -* Frees memory previously allocated by qla4xxx_mem_alloc -**/ -static void qla4xxx_mem_free (struct scsi_qla_host *ha) -{ -if (ha->queues) -dma_free_coherent (&ha->pdev->dev, ha->queues_len, ha->queues, - ha->queues_dma); - - ha->queues_len =0 ; - ha->queues =NULL ; - ha->queues_dma =0 ; - ha->request_ring =NULL ; - ha->request_dma =0 ; - ha->response_ring =NULL ; - ha->response_dma =0 ; - ha->shadow_regs =NULL ; - ha->shadow_regs_dma =0 ; - -/* Free srb pool. */ -if (ha->srb_mempool) -mempool_destroy (ha->srb_mempool); - - ha->srb_mempool =NULL ; - -/* release io space registers */ -if (ha->reg) -iounmap (ha->reg); -pci_release_regions (ha->pdev); -} -static int qla4xxx_slave_alloc (struct scsi_device *sdev) {struct iscsi_cls_session *sess =starget_to_session (sdev->sdev_target);
PATCH 5/10 qla4xxx: qla4xxx_timer defn before use
In reply to a message not in the archiveFrom: Doug Maxey <[email protected]>
- move the defn to before the call.
- make defn static.
- retabify the whole file
---
drivers/scsi/qla4xxx/ql4_os.c | 215 ++++++++++++++++++++--------------------- 1 files changed, 107 insertions(+), 108 deletions(-)
drivers/scsi/qla4xxx/ql4_os.c +107 -108
@@ -44,7 +44,6 @@ MODULE_PARM_DESC(extended_error_logging,* SCSI host template entry points */ -static void qla4xxx_timer (struct scsi_qla_host *ha);static void qla4xxx_do_dpc (void *data);static void qla4xxx_flush_active_srbs (struct scsi_qla_host *ha); int qla4xxx_reset_target(struct scsi_qla_host *ha,
@@ -565,6 +564,110 @@ mem_alloc_error_exit: }/** +* qla4xxx_timer - checks every second for work to do. +* @ha: Pointer to host adapter structure. +**/ +static void qla4xxx_timer (struct scsi_qla_host *ha) +{ +struct ddb_entry *ddb_entry, *dtemp; +int start_dpc =0 ; + +/* Search for relogin's to time-out and port down retry. */ +list_for_each_entry_safe (ddb_entry, dtemp, &ha->ddb_list, list) { +/* Count down time between sending relogins */ +if (adapter_up (ha) && + !test_bit (DF_RELOGIN , &ddb_entry->flags) && +atomic_read (&ddb_entry->state) !=DDB_STATE_ONLINE ) { +if (atomic_read (&ddb_entry->retry_relogin_timer) != +INVALID_ENTRY ) { +if (atomic_read (&ddb_entry->retry_relogin_timer) + ==0 ) { +atomic_set (&ddb_entry-> + retry_relogin_timer, +INVALID_ENTRY ); +set_bit (DPC_RELOGIN_DEVICE , + &ha->dpc_flags); +set_bit (DF_RELOGIN , &ddb_entry->flags); +DEBUG2 (printk ("scsi%ld: %s: index [%d]" +" login device\n" , + ha->host_no, __func__, + ddb_entry->fw_ddb_index)); + }else +atomic_dec (&ddb_entry-> + retry_relogin_timer); + } + } + +/* Wait for relogin to timeout */ +if (atomic_read (&ddb_entry->relogin_timer) && + (atomic_dec_and_test (&ddb_entry->relogin_timer) !=0 )) { +/* +* If the relogin times out and the device is +* still NOT ONLINE then try and relogin again. +*/ +if (atomic_read (&ddb_entry->state) != +DDB_STATE_ONLINE && + ddb_entry->fw_ddb_device_state == +DDB_DS_SESSION_FAILED ) { +/* Reset retry relogin timer */ +atomic_inc (&ddb_entry->relogin_retry_count); +DEBUG2 (printk ("scsi%ld: index[%d] relogin" +" timed out-retrying" +" relogin (%d)\n" , + ha->host_no, + ddb_entry->fw_ddb_index, +atomic_read (&ddb_entry-> + relogin_retry_count)) + ); + start_dpc++; +DEBUG (printk ("scsi%ld:%d:%d: index [%d] " +"initate relogin after" +" %d seconds\n" , + ha->host_no, ddb_entry->bus, + ddb_entry->target, + ddb_entry->fw_ddb_index, + ddb_entry->default_time2wait +4 ) + ); + +atomic_set (&ddb_entry->retry_relogin_timer, + ddb_entry->default_time2wait +4 ); + } + } + } + +/* Check for heartbeat interval. */ +if (ha->firmware_options &FWOPT_HEARTBEAT_ENABLE && + ha->heartbeat_interval !=0 ) { + ha->seconds_since_last_heartbeat++; +if (ha->seconds_since_last_heartbeat > + ha->heartbeat_interval +2 ) +set_bit (DPC_RESET_HA , &ha->dpc_flags); + } + + +/* Wakeup the dpc routine for this adapter, if needed. */ +if ((start_dpc || +test_bit (DPC_RESET_HA , &ha->dpc_flags) || +test_bit (DPC_RETRY_RESET_HA , &ha->dpc_flags) || +test_bit (DPC_RELOGIN_DEVICE , &ha->dpc_flags) || +test_bit (DPC_RESET_HA_DESTROY_DDB_LIST , &ha->dpc_flags) || +test_bit (DPC_RESET_HA_INTR , &ha->dpc_flags) || +test_bit (DPC_GET_DHCP_IP_ADDR , &ha->dpc_flags) || +test_bit (DPC_AEN , &ha->dpc_flags)) && + ha->dpc_thread) { +DEBUG2 (printk ("scsi%ld: %s: scheduling dpc routine" +" - dpc flags = 0x%lx\n" , + ha->host_no, __func__, ha->dpc_flags)); +queue_work (ha->dpc_thread, &ha->dpc_work); + } + +/* Reschedule timer thread to call us back in one second */ +mod_timer (&ha->timer, jiffies +HZ ); + +DEBUG2 (ha->seconds_since_last_intr++); +} + +/** * qla4xxx_probe_adapter - callback function to probe HBA * @pdev: pointer to pci_dev structure * @pci_device_id: pointer to pci_device entry
@@ -572,7 +675,7 @@ mem_alloc_error_exit:* This routine will probe for Qlogic 4010 iSCSI host adapters. * It returns the number of host adapters of a particular * type that were found. It also initializes all data necessary for -* the driver. It is passed-in the host number, so that it +* the driver. It is passed-in the host number, so that it * knows where its first entry is in the scsi_hosts[] array. **/ static int __devinit qla4xxx_probe_adapter(struct pci_dev *pdev,
@@ -918,119 +1021,15 @@ struct srb * del_from_active_array(strucreturn srb; } -/** -* qla4xxx_timer - checks every second for work to do. -* @ha: Pointer to host adapter structure. -**/ -void qla4xxx_timer (struct scsi_qla_host *ha) -{ -struct ddb_entry *ddb_entry, *dtemp; -int start_dpc =0 ; - -/* Search for relogin's to time-out and port down retry. */ -list_for_each_entry_safe (ddb_entry, dtemp, &ha->ddb_list, list) { -/* Count down time between sending relogins */ -if (adapter_up (ha) && - !test_bit (DF_RELOGIN , &ddb_entry->flags) && -atomic_read (&ddb_entry->state) !=DDB_STATE_ONLINE ) { -if (atomic_read (&ddb_entry->retry_relogin_timer) != -INVALID_ENTRY ) { -if (atomic_read (&ddb_entry->retry_relogin_timer) - ==0 ) { -atomic_set (&ddb_entry-> - retry_relogin_timer, -INVALID_ENTRY ); -set_bit (DPC_RELOGIN_DEVICE , - &ha->dpc_flags); -set_bit (DF_RELOGIN , &ddb_entry->flags); -DEBUG2 (printk ("scsi%ld: %s: index [%d]" -" login device\n" , - ha->host_no, __func__, - ddb_entry->fw_ddb_index)); - }else -atomic_dec (&ddb_entry-> - retry_relogin_timer); - } - } - -/* Wait for relogin to timeout */ -if (atomic_read (&ddb_entry->relogin_timer) && - (atomic_dec_and_test (&ddb_entry->relogin_timer) !=0 )) { -/* -* If the relogin times out and the device is -* still NOT ONLINE then try and relogin again. -*/ -if (atomic_read (&ddb_entry->state) != -DDB_STATE_ONLINE && - ddb_entry->fw_ddb_device_state == -DDB_DS_SESSION_FAILED ) { -/* Reset retry relogin timer */ -atomic_inc (&ddb_entry->relogin_retry_count); -DEBUG2 (printk ("scsi%ld: index[%d] relogin" -" timed out-retrying" -" relogin (%d)\n" , - ha->host_no, - ddb_entry->fw_ddb_index, -atomic_read (&ddb_entry-> - relogin_retry_count)) - ); - start_dpc++; -DEBUG (printk ("scsi%ld:%d:%d: index [%d] " -"initate relogin after" -" %d seconds\n" , - ha->host_no, ddb_entry->bus, - ddb_entry->target, - ddb_entry->fw_ddb_index, - ddb_entry->default_time2wait +4 ) - ); - -atomic_set (&ddb_entry->retry_relogin_timer, - ddb_entry->default_time2wait +4 ); - } - } - } - -/* Check for heartbeat interval. */ -if (ha->firmware_options &FWOPT_HEARTBEAT_ENABLE && - ha->heartbeat_interval !=0 ) { - ha->seconds_since_last_heartbeat++; -if (ha->seconds_since_last_heartbeat > - ha->heartbeat_interval +2 ) -set_bit (DPC_RESET_HA , &ha->dpc_flags); - } - - -/* Wakeup the dpc routine for this adapter, if needed. */ -if ((start_dpc || -test_bit (DPC_RESET_HA , &ha->dpc_flags) || -test_bit (DPC_RETRY_RESET_HA , &ha->dpc_flags) || -test_bit (DPC_RELOGIN_DEVICE , &ha->dpc_flags) || -test_bit (DPC_RESET_HA_DESTROY_DDB_LIST , &ha->dpc_flags) || -test_bit (DPC_RESET_HA_INTR , &ha->dpc_flags) || -test_bit (DPC_GET_DHCP_IP_ADDR , &ha->dpc_flags) || -test_bit (DPC_AEN , &ha->dpc_flags)) && - ha->dpc_thread) { -DEBUG2 (printk ("scsi%ld: %s: scheduling dpc routine" -" - dpc flags = 0x%lx\n" , - ha->host_no, __func__, ha->dpc_flags)); -queue_work (ha->dpc_thread, &ha->dpc_work); - } - -/* Reschedule timer thread to call us back in one second */ -mod_timer (&ha->timer, jiffies +HZ ); - -DEBUG2 (ha->seconds_since_last_intr++); -} -/** * qla4xxx_do_dpc - dpc routine * @data: in our case pointer to adapter structure * * This routine is a task that is schedule by the interrupt handler -* to perform the background processing for interrupts. We put it +* to perform the background processing for interrupts. We put it * on a task queue that is consumed whenever the scheduler runs; that's -* so you can do anything (i.e. put the process to sleep etc). In fact, +* so you can do anything (i.e. put the process to sleep etc). In fact, * the mid-level tries to sleep when it reaches the driver threshold * "host->can_queue". This can cause a panic if we were in our interrupt code. **/
PATCH 6/10 qla4xxx: qla4xxx_do_dpc defn before use
In reply to a message not in the archiveFrom: Doug Maxey <[email protected]>
- move the defn to before the call.
---
drivers/scsi/qla4xxx/ql4_os.c | 211 ++++++++++++++++++++--------------------- 1 files changed, 105 insertions(+), 106 deletions(-)
drivers/scsi/qla4xxx/ql4_os.c +105 -106
@@ -44,7 +44,6 @@ MODULE_PARM_DESC(extended_error_logging,* SCSI host template entry points */ -static void qla4xxx_do_dpc (void *data);static void qla4xxx_flush_active_srbs (struct scsi_qla_host *ha);int qla4xxx_reset_target (struct scsi_qla_host *ha,struct ddb_entry * ddb_entry);
@@ -668,6 +667,111 @@ static void qla4xxx_timer(struct scsi_ql }/** +* qla4xxx_do_dpc - dpc routine +* @data: in our case pointer to adapter structure +* +* This routine is a task that is schedule by the interrupt handler +* to perform the background processing for interrupts. We put it +* on a task queue that is consumed whenever the scheduler runs; that's +* so you can do anything (i.e. put the process to sleep etc). In fact, +* the mid-level tries to sleep when it reaches the driver threshold +* "host->can_queue". This can cause a panic if we were in our interrupt code. +**/ +static void qla4xxx_do_dpc (void *data) +{ +struct scsi_qla_host *ha = (struct scsi_qla_host *) data; +struct ddb_entry *ddb_entry, *dtemp; + +DEBUG2 (printk ("scsi%ld: %s: DPC handler waking up.\n" , + ha->host_no, __func__)); + +DEBUG2 (printk ("scsi%ld: %s: ha->flags = 0x%08lx\n" , + ha->host_no, __func__, ha->flags)); +DEBUG2 (printk ("scsi%ld: %s: ha->dpc_flags = 0x%08lx\n" , + ha->host_no, __func__, ha->dpc_flags)); + +/* Initialization not yet finished. Don't do anything yet. */ +if (!test_bit (AF_INIT_DONE , &ha->flags)) +return ; + +if (adapter_up (ha) || +test_bit (DPC_RESET_HA , &ha->dpc_flags) || +test_bit (DPC_RESET_HA_INTR , &ha->dpc_flags) || +test_bit (DPC_RESET_HA_DESTROY_DDB_LIST , &ha->dpc_flags)) { +if (test_bit (DPC_RESET_HA_DESTROY_DDB_LIST , &ha->dpc_flags)) +/* +* dg 09/23 Never initialize ddb list +* once we up and running +* qla4xxx_recover_adapter(ha, +* REBUILD_DDB_LIST); +*/ +qla4xxx_recover_adapter (ha,PRESERVE_DDB_LIST ); + +if (test_bit (DPC_RESET_HA , &ha->dpc_flags)) +qla4xxx_recover_adapter (ha,PRESERVE_DDB_LIST ); + +if (test_and_clear_bit (DPC_RESET_HA_INTR , &ha->dpc_flags)) { +uint8_t wait_time =RESET_INTR_TOV ; +unsigned long flags =0 ; + +qla4xxx_flush_active_srbs (ha); + +spin_lock_irqsave (&ha->hardware_lock, flags); +while ((readw (&ha->reg->ctrl_status) & + (CSR_SOFT_RESET |CSR_FORCE_SOFT_RESET )) !=0 ) { +if (--wait_time ==0 ) +break ; + +spin_unlock_irqrestore (&ha->hardware_lock, + flags); + +msleep (1000 ); + +spin_lock_irqsave (&ha->hardware_lock, flags); + } +spin_unlock_irqrestore (&ha->hardware_lock, flags); + +if (wait_time ==0 ) +DEBUG2 (printk ("scsi%ld: %s: SR|FSR " +"bit not cleared-- resetting\n" , + ha->host_no, __func__)); + } + } + +/* ---- process AEN? --- */ +if (test_and_clear_bit (DPC_AEN , &ha->dpc_flags)) +qla4xxx_process_aen (ha,PROCESS_ALL_AENS ); + +/* ---- Get DHCP IP Address? --- */ +if (test_and_clear_bit (DPC_GET_DHCP_IP_ADDR , &ha->dpc_flags)) +qla4xxx_get_dhcp_ip_address (ha); + +/* ---- relogin device? --- */ +if (adapter_up (ha) && +test_and_clear_bit (DPC_RELOGIN_DEVICE , &ha->dpc_flags)) { +list_for_each_entry_safe (ddb_entry, dtemp, + &ha->ddb_list, list) { +if (test_and_clear_bit (DF_RELOGIN , &ddb_entry->flags) && +atomic_read (&ddb_entry->state) !=DDB_STATE_ONLINE ) +qla4xxx_relogin_device (ha, ddb_entry); + +/* +* If mbx cmd times out there is no point +* in continuing further. +* With large no of targets this can hang +* the system. +*/ +if (test_bit (DPC_RESET_HA , &ha->dpc_flags)) { +printk (KERN_WARNING "scsi%ld: %s: " +"need to reset hba\n" , + ha->host_no, __func__); +break ; + } + } + } +} + +/** * qla4xxx_probe_adapter - callback function to probe HBA * @pdev: pointer to pci_dev structure * @pci_device_id: pointer to pci_device entry
@@ -1023,111 +1127,6 @@ struct srb * del_from_active_array(struc/** -* qla4xxx_do_dpc - dpc routine -* @data: in our case pointer to adapter structure -* -* This routine is a task that is schedule by the interrupt handler -* to perform the background processing for interrupts. We put it -* on a task queue that is consumed whenever the scheduler runs; that's -* so you can do anything (i.e. put the process to sleep etc). In fact, -* the mid-level tries to sleep when it reaches the driver threshold -* "host->can_queue". This can cause a panic if we were in our interrupt code. -**/ -static void qla4xxx_do_dpc (void *data) -{ -struct scsi_qla_host *ha = (struct scsi_qla_host *) data; -struct ddb_entry *ddb_entry, *dtemp; - -DEBUG2 (printk ("scsi%ld: %s: DPC handler waking up.\n" , - ha->host_no, __func__)); - -DEBUG2 (printk ("scsi%ld: %s: ha->flags = 0x%08lx\n" , - ha->host_no, __func__, ha->flags)); -DEBUG2 (printk ("scsi%ld: %s: ha->dpc_flags = 0x%08lx\n" , - ha->host_no, __func__, ha->dpc_flags)); - -/* Initialization not yet finished. Don't do anything yet. */ -if (!test_bit (AF_INIT_DONE , &ha->flags)) -return ; - -if (adapter_up (ha) || -test_bit (DPC_RESET_HA , &ha->dpc_flags) || -test_bit (DPC_RESET_HA_INTR , &ha->dpc_flags) || -test_bit (DPC_RESET_HA_DESTROY_DDB_LIST , &ha->dpc_flags)) { -if (test_bit (DPC_RESET_HA_DESTROY_DDB_LIST , &ha->dpc_flags)) -/* -* dg 09/23 Never initialize ddb list -* once we up and running -* qla4xxx_recover_adapter(ha, -* REBUILD_DDB_LIST); -*/ -qla4xxx_recover_adapter (ha,PRESERVE_DDB_LIST ); - -if (test_bit (DPC_RESET_HA , &ha->dpc_flags)) -qla4xxx_recover_adapter (ha,PRESERVE_DDB_LIST ); - -if (test_and_clear_bit (DPC_RESET_HA_INTR , &ha->dpc_flags)) { -uint8_t wait_time =RESET_INTR_TOV ; -unsigned long flags =0 ; - -qla4xxx_flush_active_srbs (ha); - -spin_lock_irqsave (&ha->hardware_lock, flags); -while ((readw (&ha->reg->ctrl_status) & - (CSR_SOFT_RESET |CSR_FORCE_SOFT_RESET )) !=0 ) { -if (--wait_time ==0 ) -break ; - -spin_unlock_irqrestore (&ha->hardware_lock, - flags); - -msleep (1000 ); - -spin_lock_irqsave (&ha->hardware_lock, flags); - } -spin_unlock_irqrestore (&ha->hardware_lock, flags); - -if (wait_time ==0 ) -DEBUG2 (printk ("scsi%ld: %s: SR|FSR " -"bit not cleared-- resetting\n" , - ha->host_no, __func__)); - } - } - -/* ---- process AEN? --- */ -if (test_and_clear_bit (DPC_AEN , &ha->dpc_flags)) -qla4xxx_process_aen (ha,PROCESS_ALL_AENS ); - -/* ---- Get DHCP IP Address? --- */ -if (test_and_clear_bit (DPC_GET_DHCP_IP_ADDR , &ha->dpc_flags)) -qla4xxx_get_dhcp_ip_address (ha); - -/* ---- relogin device? --- */ -if (adapter_up (ha) && -test_and_clear_bit (DPC_RELOGIN_DEVICE , &ha->dpc_flags)) { -list_for_each_entry_safe (ddb_entry, dtemp, - &ha->ddb_list, list) { -if (test_and_clear_bit (DF_RELOGIN , &ddb_entry->flags) && -atomic_read (&ddb_entry->state) !=DDB_STATE_ONLINE ) -qla4xxx_relogin_device (ha, ddb_entry); - -/* -* If mbx cmd times out there is no point -* in continuing further. -* With large no of targets this can hang -* the system. -*/ -if (test_bit (DPC_RESET_HA , &ha->dpc_flags)) { -printk (KERN_WARNING "scsi%ld: %s: " -"need to reset hba\n" , - ha->host_no, __func__); -break ; - } - } - } -} - -/** * qla4010_soft_reset - performs soft reset. * @ha: Pointer to host adapter structure. **/
PATCH 7/10 qla4xxx: qla4xxx_recover_adapter defn before use
In reply to a message not in the archiveFrom: Doug Maxey <[email protected]>
- move the defn to before the call.
- make defn static.
This entailed moving a few more functions around to keep it compiling:qla4xxx_cmd_waitqla4010_soft_resetqla4xxx_topcat_resetqla4xxx_hard_reset
---
drivers/scsi/qla4xxx/ql4_os.c | 625 ++++++++++++++++++++--------------------- 1 files changed, 311 insertions(+), 314 deletions(-)
drivers/scsi/qla4xxx/ql4_os.c +311 -314
@@ -45,9 +45,6 @@ MODULE_PARM_DESC(extended_error_logging,*/ static void qla4xxx_flush_active_srbs (struct scsi_qla_host *ha); -int qla4xxx_reset_target (struct scsi_qla_host *ha, -struct ddb_entry * ddb_entry); -int qla4xxx_recover_adapter (struct scsi_qla_host *ha,uint8_t renew_ddb_list);void qla4xxx_config_dma_addressing (struct scsi_qla_host *ha);static int qla4xxx_iospace_config (struct scsi_qla_host *ha);
@@ -667,6 +664,317 @@ static void qla4xxx_timer(struct scsi_ql }/** +* qla4xxx_cmd_wait - waits for all outstanding commands to complete +* @ha: Pointer to host adapter structure. +* +* This routine stalls the driver until all outstanding commands are returned. +* Caller must release the Hardware Lock prior to calling this routine. +**/ +static int qla4xxx_cmd_wait (struct scsi_qla_host *ha) +{ +uint32_t index =0 ; +int stat =QLA_SUCCESS ; +unsigned long flags; +int wait_cnt =WAIT_CMD_TOV ;/* +* Initialized for 30 seconds as we +* expect all commands to retuned +* ASAP. +*/ + +while (wait_cnt) { +spin_lock_irqsave (&ha->hardware_lock, flags); +/* Find a command that hasn't completed. */ +for (index =1 ; index <MAX_SRBS ; index++) { +if (ha->active_srb_array[index] !=NULL ) +break ; + } +spin_unlock_irqrestore (&ha->hardware_lock, flags); + +/* If No Commands are pending, wait is complete */ +if (index ==MAX_SRBS ) { +break ; + } + +/* If we timed out on waiting for commands to come back +* return ERROR. +*/ + wait_cnt--; +if (wait_cnt ==0 ) + stat =QLA_ERROR ; +else { +msleep (1000 ); + } + }/* End of While (wait_cnt) */ + +return stat; +} + +/** +* qla4010_soft_reset - performs soft reset. +* @ha: Pointer to host adapter structure. +**/ +static int qla4010_soft_reset (struct scsi_qla_host *ha) +{ +uint32_t max_wait_time; +unsigned long flags =0 ; +int status =QLA_ERROR ; +uint32_t ctrl_status; + +spin_lock_irqsave (&ha->hardware_lock, flags); + +/* +* If the SCSI Reset Interrupt bit is set, clear it. +* Otherwise, the Soft Reset won't work. +*/ + ctrl_status =readw (&ha->reg->ctrl_status); +if ((ctrl_status &CSR_SCSI_RESET_INTR ) !=0 ) +writel (set_rmask (CSR_SCSI_RESET_INTR ), &ha->reg->ctrl_status); + +/* Issue Soft Reset */ +writel (set_rmask (CSR_SOFT_RESET ), &ha->reg->ctrl_status); +readl (&ha->reg->ctrl_status); + +spin_unlock_irqrestore (&ha->hardware_lock, flags); + +/* Wait until the Network Reset Intr bit is cleared */ + max_wait_time =RESET_INTR_TOV ; +do { +spin_lock_irqsave (&ha->hardware_lock, flags); + ctrl_status =readw (&ha->reg->ctrl_status); +spin_unlock_irqrestore (&ha->hardware_lock, flags); + +if ((ctrl_status &CSR_NET_RESET_INTR ) ==0 ) +break ; + +msleep (1000 ); + }while ((--max_wait_time)); + +if ((ctrl_status &CSR_NET_RESET_INTR ) !=0 ) { +DEBUG2 (printk (KERN_WARNING +"scsi%ld: Network Reset Intr not cleared by " +"Network function, clearing it now!\n" , + ha->host_no)); +spin_lock_irqsave (&ha->hardware_lock, flags); +writel (set_rmask (CSR_NET_RESET_INTR ), &ha->reg->ctrl_status); +readl (&ha->reg->ctrl_status); +spin_unlock_irqrestore (&ha->hardware_lock, flags); + } + +/* Wait until the firmware tells us the Soft Reset is done */ + max_wait_time =SOFT_RESET_TOV ; +do { +spin_lock_irqsave (&ha->hardware_lock, flags); + ctrl_status =readw (&ha->reg->ctrl_status); +spin_unlock_irqrestore (&ha->hardware_lock, flags); + +if ((ctrl_status &CSR_SOFT_RESET ) ==0 ) { + status =QLA_SUCCESS ; +break ; + } + +msleep (1000 ); + }while ((--max_wait_time)); + +/* +* Also, make sure that the SCSI Reset Interrupt bit has been cleared +* after the soft reset has taken place. +*/ +spin_lock_irqsave (&ha->hardware_lock, flags); + ctrl_status =readw (&ha->reg->ctrl_status); +if ((ctrl_status &CSR_SCSI_RESET_INTR ) !=0 ) { +writel (set_rmask (CSR_SCSI_RESET_INTR ), &ha->reg->ctrl_status); +readl (&ha->reg->ctrl_status); + } +spin_unlock_irqrestore (&ha->hardware_lock, flags); + +/* If soft reset fails then most probably the bios on other +* function is also enabled. +* Since the initialization is sequential the other fn +* wont be able to acknowledge the soft reset. +* Issue a force soft reset to workaround this scenario. +*/ +if (max_wait_time ==0 ) { +/* Issue Force Soft Reset */ +spin_lock_irqsave (&ha->hardware_lock, flags); +writel (set_rmask (CSR_FORCE_SOFT_RESET ), &ha->reg->ctrl_status); +readl (&ha->reg->ctrl_status); +spin_unlock_irqrestore (&ha->hardware_lock, flags); +/* Wait until the firmware tells us the Soft Reset is done */ + max_wait_time =SOFT_RESET_TOV ; +do { +spin_lock_irqsave (&ha->hardware_lock, flags); + ctrl_status =readw (&ha->reg->ctrl_status); +spin_unlock_irqrestore (&ha->hardware_lock, flags); + +if ((ctrl_status &CSR_FORCE_SOFT_RESET ) ==0 ) { + status =QLA_SUCCESS ; +break ; + } + +msleep (1000 ); + }while ((--max_wait_time)); + } + +return status; +} + +/** +* qla4xxx_topcat_reset - performs hard reset of TopCat Chip. +* @ha: Pointer to host adapter structure. +**/ +static int qla4xxx_topcat_reset (struct scsi_qla_host *ha) +{ +unsigned long flags; + +ql4xxx_lock_nvram (ha); +spin_lock_irqsave (&ha->hardware_lock, flags); +writel (set_rmask (GPOR_TOPCAT_RESET ),isp_gp_out (ha)); +readl (isp_gp_out (ha)); +mdelay (1 ); + +writel (clr_rmask (GPOR_TOPCAT_RESET ),isp_gp_out (ha)); +readl (isp_gp_out (ha)); +spin_unlock_irqrestore (&ha->hardware_lock, flags); +mdelay (2523 ); + +ql4xxx_unlock_nvram (ha); +return QLA_SUCCESS ; +} + +/** +* qla4xxx_hard_reset - performs HBA Hard Reset +* @ha: Pointer to host adapter structure. +**/ +static int qla4xxx_hard_reset (struct scsi_qla_host *ha) +{ +/* The QLA4010 really doesn't have an equivalent to a hard reset */ +qla4xxx_flush_active_srbs (ha); +if (test_bit (AF_TOPCAT_CHIP_PRESENT , &ha->flags)) { +int status =QLA_ERROR ; + +if ((qla4010_soft_reset (ha) ==QLA_SUCCESS ) && + (qla4xxx_topcat_reset (ha) ==QLA_SUCCESS ) && + (qla4010_soft_reset (ha) ==QLA_SUCCESS )) + status =QLA_SUCCESS ; +return status; + }else +return qla4010_soft_reset (ha); +} + +/** +* qla4xxx_recover_adapter - recovers adapter after a fatal error +* @ha: Pointer to host adapter structure. +* @renew_ddb_list: Indicates what to do with the adapter's ddb list +* after adapter recovery has completed. +* 0=preserve ddb list, 1=destroy and rebuild ddb list +**/ +static int qla4xxx_recover_adapter (struct scsi_qla_host *ha,uint8_t renew_ddb_list) +{ +int status; + +/* Stall incoming I/O until we are done */ +clear_bit (AF_ONLINE , &ha->flags); +DEBUG2 (printk ("scsi%ld: %s calling qla4xxx_cmd_wait\n" , ha->host_no, + __func__)); + +/* Wait for outstanding commands to complete. +* Stalls the driver for max 30 secs +*/ + status =qla4xxx_cmd_wait (ha); + +qla4xxx_disable_intrs (ha); + +/* Flush any pending ddb changed AENs */ +qla4xxx_process_aen (ha,FLUSH_DDB_CHANGED_AENS ); + +/* Reset the firmware. If successful, function +* returns with ISP interrupts enabled. +*/ +if (status ==QLA_SUCCESS ) { +DEBUG2 (printk ("scsi%ld: %s - Performing soft reset..\n" , + ha->host_no, __func__)); + status =qla4xxx_soft_reset (ha); + } +/* FIXMEkaren: Do we want to keep interrupts enabled and process +AENs after soft reset */ + +/* If firmware (SOFT) reset failed, or if all outstanding +* commands have not returned, then do a HARD reset. +*/ +if (status ==QLA_ERROR ) { +DEBUG2 (printk ("scsi%ld: %s - Performing hard reset..\n" , + ha->host_no, __func__)); + status =qla4xxx_hard_reset (ha); + } + +/* Flush any pending ddb changed AENs */ +qla4xxx_process_aen (ha,FLUSH_DDB_CHANGED_AENS ); + +/* Re-initialize firmware. If successful, function returns +* with ISP interrupts enabled */ +if (status ==QLA_SUCCESS ) { +DEBUG2 (printk ("scsi%ld: %s - Initializing adapter..\n" , + ha->host_no, __func__)); + +/* If successful, AF_ONLINE flag set in +* qla4xxx_initialize_adapter */ + status =qla4xxx_initialize_adapter (ha, renew_ddb_list); + } + +/* Failed adapter initialization? +* Retry reset_ha only if invoked via DPC (DPC_RESET_HA) */ +if ((test_bit (AF_ONLINE , &ha->flags) ==0 ) && + (test_bit (DPC_RESET_HA , &ha->dpc_flags))) { +/* Adapter initialization failed, see if we can retry +* resetting the ha */ +if (!test_bit (DPC_RETRY_RESET_HA , &ha->dpc_flags)) { + ha->retry_reset_ha_cnt =MAX_RESET_HA_RETRIES ; +DEBUG2 (printk ("scsi%ld: recover adapter - retrying " +"(%d) more times\n" , ha->host_no, + ha->retry_reset_ha_cnt)); +set_bit (DPC_RETRY_RESET_HA , &ha->dpc_flags); + status =QLA_ERROR ; + }else { +if (ha->retry_reset_ha_cnt >0 ) { +/* Schedule another Reset HA--DPC will retry */ + ha->retry_reset_ha_cnt--; +DEBUG2 (printk ("scsi%ld: recover adapter - " +"retry remaining %d\n" , + ha->host_no, + ha->retry_reset_ha_cnt)); + status =QLA_ERROR ; + } + +if (ha->retry_reset_ha_cnt ==0 ) { +/* Recover adapter retries have been exhausted. +* Adapter DEAD */ +DEBUG2 (printk ("scsi%ld: recover adapter " +"failed - board disabled\n" , + ha->host_no)); +qla4xxx_flush_active_srbs (ha); +clear_bit (DPC_RETRY_RESET_HA , &ha->dpc_flags); +clear_bit (DPC_RESET_HA , &ha->dpc_flags); +clear_bit (DPC_RESET_HA_DESTROY_DDB_LIST , + &ha->dpc_flags); + status =QLA_ERROR ; + } + } + }else { +clear_bit (DPC_RESET_HA , &ha->dpc_flags); +clear_bit (DPC_RESET_HA_DESTROY_DDB_LIST , &ha->dpc_flags); +clear_bit (DPC_RETRY_RESET_HA , &ha->dpc_flags); + } + + ha->adapter_error_count++; + +if (status ==QLA_SUCCESS ) +qla4xxx_enable_intrs (ha); + +DEBUG2 (printk ("scsi%ld: recover adapter .. DONE\n" , ha->host_no)); +return status; +} + +/** * qla4xxx_do_dpc - dpc routine * @data: in our case pointer to adapter structure *
@@ -1127,138 +1435,6 @@ struct srb * del_from_active_array(struc/** -* qla4010_soft_reset - performs soft reset. -* @ha: Pointer to host adapter structure. -**/ -int qla4010_soft_reset (struct scsi_qla_host *ha) -{ -uint32_t max_wait_time; -unsigned long flags =0 ; -int status =QLA_ERROR ; -uint32_t ctrl_status; - -spin_lock_irqsave (&ha->hardware_lock, flags); - -/* -* If the SCSI Reset Interrupt bit is set, clear it. -* Otherwise, the Soft Reset won't work. -*/ - ctrl_status =readw (&ha->reg->ctrl_status); -if ((ctrl_status &CSR_SCSI_RESET_INTR ) !=0 ) -writel (set_rmask (CSR_SCSI_RESET_INTR ), &ha->reg->ctrl_status); - -/* Issue Soft Reset */ -writel (set_rmask (CSR_SOFT_RESET ), &ha->reg->ctrl_status); -readl (&ha->reg->ctrl_status); - -spin_unlock_irqrestore (&ha->hardware_lock, flags); - -/* Wait until the Network Reset Intr bit is cleared */ - max_wait_time =RESET_INTR_TOV ; -do { -spin_lock_irqsave (&ha->hardware_lock, flags); - ctrl_status =readw (&ha->reg->ctrl_status); -spin_unlock_irqrestore (&ha->hardware_lock, flags); - -if ((ctrl_status &CSR_NET_RESET_INTR ) ==0 ) -break ; - -msleep (1000 ); - }while ((--max_wait_time)); - -if ((ctrl_status &CSR_NET_RESET_INTR ) !=0 ) { -DEBUG2 (printk (KERN_WARNING -"scsi%ld: Network Reset Intr not cleared by " -"Network function, clearing it now!\n" , - ha->host_no)); -spin_lock_irqsave (&ha->hardware_lock, flags); -writel (set_rmask (CSR_NET_RESET_INTR ), &ha->reg->ctrl_status); -readl (&ha->reg->ctrl_status); -spin_unlock_irqrestore (&ha->hardware_lock, flags); - } - -/* Wait until the firmware tells us the Soft Reset is done */ - max_wait_time =SOFT_RESET_TOV ; -do { -spin_lock_irqsave (&ha->hardware_lock, flags); - ctrl_status =readw (&ha->reg->ctrl_status); -spin_unlock_irqrestore (&ha->hardware_lock, flags); - -if ((ctrl_status &CSR_SOFT_RESET ) ==0 ) { - status =QLA_SUCCESS ; -break ; - } - -msleep (1000 ); - }while ((--max_wait_time)); - -/* -* Also, make sure that the SCSI Reset Interrupt bit has been cleared -* after the soft reset has taken place. -*/ -spin_lock_irqsave (&ha->hardware_lock, flags); - ctrl_status =readw (&ha->reg->ctrl_status); -if ((ctrl_status &CSR_SCSI_RESET_INTR ) !=0 ) { -writel (set_rmask (CSR_SCSI_RESET_INTR ), &ha->reg->ctrl_status); -readl (&ha->reg->ctrl_status); - } -spin_unlock_irqrestore (&ha->hardware_lock, flags); - -/* If soft reset fails then most probably the bios on other -* function is also enabled. -* Since the initialization is sequential the other fn -* wont be able to acknowledge the soft reset. -* Issue a force soft reset to workaround this scenario. -*/ -if (max_wait_time ==0 ) { -/* Issue Force Soft Reset */ -spin_lock_irqsave (&ha->hardware_lock, flags); -writel (set_rmask (CSR_FORCE_SOFT_RESET ), &ha->reg->ctrl_status); -readl (&ha->reg->ctrl_status); -spin_unlock_irqrestore (&ha->hardware_lock, flags); -/* Wait until the firmware tells us the Soft Reset is done */ - max_wait_time =SOFT_RESET_TOV ; -do { -spin_lock_irqsave (&ha->hardware_lock, flags); - ctrl_status =readw (&ha->reg->ctrl_status); -spin_unlock_irqrestore (&ha->hardware_lock, flags); - -if ((ctrl_status &CSR_FORCE_SOFT_RESET ) ==0 ) { - status =QLA_SUCCESS ; -break ; - } - -msleep (1000 ); - }while ((--max_wait_time)); - } - -return status; -} - -/** -* qla4xxx_topcat_reset - performs hard reset of TopCat Chip. -* @ha: Pointer to host adapter structure. -**/ -int qla4xxx_topcat_reset (struct scsi_qla_host *ha) -{ -unsigned long flags; - -ql4xxx_lock_nvram (ha); -spin_lock_irqsave (&ha->hardware_lock, flags); -writel (set_rmask (GPOR_TOPCAT_RESET ),isp_gp_out (ha)); -readl (isp_gp_out (ha)); -mdelay (1 ); - -writel (clr_rmask (GPOR_TOPCAT_RESET ),isp_gp_out (ha)); -readl (isp_gp_out (ha)); -spin_unlock_irqrestore (&ha->hardware_lock, flags); -mdelay (2523 ); - -ql4xxx_unlock_nvram (ha); -return QLA_SUCCESS ; -} - -/** * qla4xxx_soft_reset - performs a SOFT RESET of hba. * @ha: Pointer to host adapter structure. **/
@@ -1279,185 +1455,6 @@ int qla4xxx_soft_reset(struct scsi_qla_hreturn qla4010_soft_reset (ha); } -/** -* qla4xxx_hard_reset - performs HBA Hard Reset -* @ha: Pointer to host adapter structure. -**/ -int qla4xxx_hard_reset (struct scsi_qla_host *ha) -{ -/* The QLA4010 really doesn't have an equivalent to a hard reset */ -qla4xxx_flush_active_srbs (ha); -if (test_bit (AF_TOPCAT_CHIP_PRESENT , &ha->flags)) { -int status =QLA_ERROR ; - -if ((qla4010_soft_reset (ha) ==QLA_SUCCESS ) && - (qla4xxx_topcat_reset (ha) ==QLA_SUCCESS ) && - (qla4010_soft_reset (ha) ==QLA_SUCCESS )) - status =QLA_SUCCESS ; -return status; - }else -return qla4010_soft_reset (ha); -} - -/** -* qla4xxx_cmd_wait - waits for all outstanding commands to complete -* @ha: Pointer to host adapter structure. -* -* This routine stalls the driver until all outstanding commands are returned. -* Caller must release the Hardware Lock prior to calling this routine. -**/ -static int qla4xxx_cmd_wait (struct scsi_qla_host *ha) -{ -uint32_t index =0 ; -int stat =QLA_SUCCESS ; -unsigned long flags; -int wait_cnt =WAIT_CMD_TOV ;/* -* Initialized for 30 seconds as we -* expect all commands to retuned -* ASAP. -*/ - -while (wait_cnt) { -spin_lock_irqsave (&ha->hardware_lock, flags); -/* Find a command that hasn't completed. */ -for (index =1 ; index <MAX_SRBS ; index++) { -if (ha->active_srb_array[index] !=NULL ) -break ; - } -spin_unlock_irqrestore (&ha->hardware_lock, flags); - -/* If No Commands are pending, wait is complete */ -if (index ==MAX_SRBS ) { -break ; - } - -/* If we timed out on waiting for commands to come back -* return ERROR. -*/ - wait_cnt--; -if (wait_cnt ==0 ) - stat =QLA_ERROR ; -else { -msleep (1000 ); - } - }/* End of While (wait_cnt) */ - -return stat; -} - -/** -* qla4xxx_recover_adapter - recovers adapter after a fatal error -* @ha: Pointer to host adapter structure. -* @renew_ddb_list: Indicates what to do with the adapter's ddb list -* after adapter recovery has completed. -* 0=preserve ddb list, 1=destroy and rebuild ddb list -**/ -int qla4xxx_recover_adapter (struct scsi_qla_host *ha,uint8_t renew_ddb_list) -{ -int status; - -/* Stall incoming I/O until we are done */ -clear_bit (AF_ONLINE , &ha->flags); -DEBUG2 (printk ("scsi%ld: %s calling qla4xxx_cmd_wait\n" , ha->host_no, - __func__)); - -/* Wait for outstanding commands to complete. -* Stalls the driver for max 30 secs -*/ - status =qla4xxx_cmd_wait (ha); - -qla4xxx_disable_intrs (ha); - -/* Flush any pending ddb changed AENs */ -qla4xxx_process_aen (ha,FLUSH_DDB_CHANGED_AENS ); - -/* Reset the firmware. If successful, function -* returns with ISP interrupts enabled. -*/ -if (status ==QLA_SUCCESS ) { -DEBUG2 (printk ("scsi%ld: %s - Performing soft reset..\n" , - ha->host_no, __func__)); - status =qla4xxx_soft_reset (ha); - } -/* FIXMEkaren: Do we want to keep interrupts enabled and process -AENs after soft reset */ - -/* If firmware (SOFT) reset failed, or if all outstanding -* commands have not returned, then do a HARD reset. -*/ -if (status ==QLA_ERROR ) { -DEBUG2 (printk ("scsi%ld: %s - Performing hard reset..\n" , - ha->host_no, __func__)); - status =qla4xxx_hard_reset (ha); - } - -/* Flush any pending ddb changed AENs */ -qla4xxx_process_aen (ha,FLUSH_DDB_CHANGED_AENS ); - -/* Re-initialize firmware. If successful, function returns -* with ISP interrupts enabled */ -if (status ==QLA_SUCCESS ) { -DEBUG2 (printk ("scsi%ld: %s - Initializing adapter..\n" , - ha->host_no, __func__)); - -/* If successful, AF_ONLINE flag set in -* qla4xxx_initialize_adapter */ - status =qla4xxx_initialize_adapter (ha, renew_ddb_list); - } - -/* Failed adapter initialization? -* Retry reset_ha only if invoked via DPC (DPC_RESET_HA) */ -if ((test_bit (AF_ONLINE , &ha->flags) ==0 ) && - (test_bit (DPC_RESET_HA , &ha->dpc_flags))) { -/* Adapter initialization failed, see if we can retry -* resetting the ha */ -if (!test_bit (DPC_RETRY_RESET_HA , &ha->dpc_flags)) { - ha->retry_reset_ha_cnt =MAX_RESET_HA_RETRIES ; -DEBUG2 (printk ("scsi%ld: recover adapter - retrying " -"(%d) more times\n" , ha->host_no, - ha->retry_reset_ha_cnt)); -set_bit (DPC_RETRY_RESET_HA , &ha->dpc_flags); - status =QLA_ERROR ; - }else { -if (ha->retry_reset_ha_cnt >0 ) { -/* Schedule another Reset HA--DPC will retry */ - ha->retry_reset_ha_cnt--; -DEBUG2 (printk ("scsi%ld: recover adapter - " -"retry remaining %d\n" , - ha->host_no, - ha->retry_reset_ha_cnt)); - status =QLA_ERROR ; - } - -if (ha->retry_reset_ha_cnt ==0 ) { -/* Recover adapter retries have been exhausted. -* Adapter DEAD */ -DEBUG2 (printk ("scsi%ld: recover adapter " -"failed - board disabled\n" , - ha->host_no)); -qla4xxx_flush_active_srbs (ha); -clear_bit (DPC_RETRY_RESET_HA , &ha->dpc_flags); -clear_bit (DPC_RESET_HA , &ha->dpc_flags); -clear_bit (DPC_RESET_HA_DESTROY_DDB_LIST , - &ha->dpc_flags); - status =QLA_ERROR ; - } - } - }else { -clear_bit (DPC_RESET_HA , &ha->dpc_flags); -clear_bit (DPC_RESET_HA_DESTROY_DDB_LIST , &ha->dpc_flags); -clear_bit (DPC_RETRY_RESET_HA , &ha->dpc_flags); - } - - ha->adapter_error_count++; - -if (status ==QLA_SUCCESS ) -qla4xxx_enable_intrs (ha); - -DEBUG2 (printk ("scsi%ld: recover adapter .. DONE\n" , ha->host_no)); -return status; -} -/** * qla4xxx_eh_wait_on_command - waits for command to be returned by firmware
PATCH 8/10 qla4xxx: qla4xxx_flush_active_srbs defn before use
In reply to a message not in the archiveFrom: Doug Maxey <[email protected]>
- move the defn to before the call.
---
drivers/scsi/qla4xxx/ql4_os.c | 55 ++++++++++++++++++++--------------------- 1 files changed, 27 insertions(+), 28 deletions(-)
drivers/scsi/qla4xxx/ql4_os.c +27 -28
@@ -44,7 +44,6 @@ MODULE_PARM_DESC(extended_error_logging,* SCSI host template entry points */ -static void qla4xxx_flush_active_srbs (struct scsi_qla_host *ha);void qla4xxx_config_dma_addressing (struct scsi_qla_host *ha);static int qla4xxx_iospace_config (struct scsi_qla_host *ha);
@@ -842,6 +841,33 @@ static int qla4xxx_topcat_reset(struct s }/** +* qla4xxx_flush_active_srbs - returns all outstanding i/o requests to O.S. +* @ha: Pointer to host adapter structure. +* +* This routine is called just prior to a HARD RESET to return all +* outstanding commands back to the Operating System. +* Caller should make sure that the following locks are released +* before this calling routine: Hardware lock, and io_request_lock. +**/ +static void qla4xxx_flush_active_srbs (struct scsi_qla_host *ha) +{ +struct srb *srb; +int i; +unsigned long flags; + +spin_lock_irqsave (&ha->hardware_lock, flags); +for (i =1 ; i <MAX_SRBS ; i++) { +if ((srb = ha->active_srb_array[i]) !=NULL ) { +del_from_active_array (ha, i); + srb->cmd->result =DID_RESET <<16 ; +qla4xxx_srb_compl (ha, srb); + } + } +spin_unlock_irqrestore (&ha->hardware_lock, flags); + +} + +/** * qla4xxx_hard_reset - performs HBA Hard Reset * @ha: Pointer to host adapter structure. **/
@@ -1701,33 +1727,6 @@ static int qla4xxx_eh_bus_reset(struct s }/** -* qla4xxx_flush_active_srbs - returns all outstanding i/o requests to O.S. -* @ha: Pointer to host adapter structure. -* -* This routine is called just prior to a HARD RESET to return all -* outstanding commands back to the Operating System. -* Caller should make sure that the following locks are released -* before this calling routine: Hardware lock, and io_request_lock. -**/ -static void qla4xxx_flush_active_srbs (struct scsi_qla_host *ha) -{ -struct srb *srb; -int i; -unsigned long flags; - -spin_lock_irqsave (&ha->hardware_lock, flags); -for (i =1 ; i <MAX_SRBS ; i++) { -if ((srb = ha->active_srb_array[i]) !=NULL ) { -del_from_active_array (ha, i); - srb->cmd->result =DID_RESET <<16 ; -qla4xxx_srb_compl (ha, srb); - } - } -spin_unlock_irqrestore (&ha->hardware_lock, flags); - -} - -/** * qla4xxx_eh_host_reset - kernel callback * @cmd: Pointer to Linux's SCSI command structure *
PATCH 9/10 qla4xxx: rename del_from_active_array
In reply to a message not in the archiveFrom: Doug Maxey <[email protected]>
- add the driver prefix
---
drivers/scsi/qla4xxx/ql4_glbl.h | 2 +- drivers/scsi/qla4xxx/ql4_isr.c | 14 +++++++------- drivers/scsi/qla4xxx/ql4_os.c | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-)
drivers/scsi/qla4xxx/ql4_glbl.h +1 -1
@@ -66,7 +66,7 @@ void qla4xxx_interrupt_service_routine(s uint32_t intr_status);int qla4xxx_init_rings (struct scsi_qla_host * ha);void qla4xxx_dump_buffer (void *b,uint32_t size); -struct srb *del_from_active_array (struct scsi_qla_host *ha,uint32_t index); +struct srb *qla4xxx_del_from_active_array (struct scsi_qla_host *ha,uint32_t index);void qla4xxx_srb_compl (struct scsi_qla_host *ha,struct srb *srb);int qla4xxx_reinitialize_ddb_list (struct scsi_qla_host * ha); int qla4xxx_process_ddb_changed(struct scsi_qla_host * ha,
drivers/scsi/qla4xxx/ql4_isr.c +7 -7
@@ -17,7 +17,7 @@ static void qla4xxx_process_completed_re {struct srb *srb; - srb =del_from_active_array (ha, index); + srb =qla4xxx_del_from_active_array (ha, index);if (srb) {/* Save ISP completion status */ srb->cmd->result =DID_OK <<16 ;
@@ -52,7 +52,7 @@ static void qla4xxx_status_entry(structreturn ; } - srb =del_from_active_array (ha,le32_to_cpu (sts_entry->handle)); + srb =qla4xxx_del_from_active_array (ha,le32_to_cpu (sts_entry->handle));if (!srb) {/* FIXMEdg: Don't we need to reset ISP in this case??? */ DEBUG2(printk(KERN_WARNING "scsi%ld: %s: Status Entry invalid "
@@ -354,9 +354,9 @@ static void qla4xxx_process_response_que* accepted by ISP. Queue command for * later */ - srb =del_from_active_array (ha, -le32_to_cpu (sts_entry-> - handle)); + srb =qla4xxx_del_from_active_array (ha, +le32_to_cpu (sts_entry-> + handle));if (srb ==NULL ) goto exit_prq_invalid_handle;
@@ -588,7 +588,7 @@ static void qla4xxx_isr_decode_mailbox(s* qla4xxx_interrupt_service_routine - isr * @ha: pointer to host adapter structure. * -* This is the main interrupt service routine. +* This is the main interrupt service routine. * hardware_lock locked upon entry. runs in interrupt context. **/ void qla4xxx_interrupt_service_routine(struct scsi_qla_host * ha,
@@ -713,7 +713,7 @@ irqreturn_t qla4xxx_intr_handler(int irq* @ha: pointer to host adapter structure. * @process_aen: type of AENs to process * -* Processes specific types of Asynchronous Events generated by firmware. +* Processes specific types of Asynchronous Events generated by firmware. * The type of AENs to process is specified by process_aen and can be * PROCESS_ALL_AENS 0 * FLUSH_DDB_CHANGED_AENS 1
drivers/scsi/qla4xxx/ql4_os.c +3 -3
@@ -858,7 +858,7 @@ static void qla4xxx_flush_active_srbs(stspin_lock_irqsave (&ha->hardware_lock, flags);for (i =1 ; i <MAX_SRBS ; i++) {if ((srb = ha->active_srb_array[i]) !=NULL ) { -del_from_active_array (ha, i); +qla4xxx_del_from_active_array (ha, i); srb->cmd->result =DID_RESET <<16 ;qla4xxx_srb_compl (ha, srb); }
@@ -1430,13 +1430,13 @@ static int qla4xxx_slave_configure(struc }/** -* del_from_active_array - returns an active srb +* qla4xxx_del_from_active_array - returns an active srb * @ha: Pointer to host adapter structure. * @index: index into to the active_array * * This routine removes and returns the srb at the specified index **/ -struct srb *del_from_active_array (struct scsi_qla_host *ha,uint32_t index) +struct srb *qla4xxx_del_from_active_array (struct scsi_qla_host *ha,uint32_t index) {struct srb *srb =NULL ;
PATCH 10/10 qla4xxx: qla4xxx_reset_target delete decl
In reply to a message not in the archiveFrom: Doug Maxey <[email protected]>
-remove unneeded decl.
---
0 files changed, 0 insertions(+), 0 deletions(-)