aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390
diff options
context:
space:
mode:
authorAndreas Herrmann <aherrman@de.ibm.com>2006-09-18 16:29:56 -0400
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>2006-09-23 19:01:23 -0400
commit2abbe866c8eb0296e3f5343bcf73e5371522a738 (patch)
treec839b12b43d07d538e32bcabec1fefa2106f384f /drivers/s390
parent4eff4a36516d72e4f6ede901141214a7e05607e7 (diff)
[SCSI] zfcp: introduce struct timer_list in struct zfcp_fsf_req
This instance will be used whenever a timer is needed for a request by zfcp. Signed-off-by: Andreas Herrmann <aherrman@de.ibm.com> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/s390')
-rw-r--r--drivers/s390/scsi/zfcp_aux.c4
-rw-r--r--drivers/s390/scsi/zfcp_def.h8
-rw-r--r--drivers/s390/scsi/zfcp_erp.c228
-rw-r--r--drivers/s390/scsi/zfcp_ext.h13
-rw-r--r--drivers/s390/scsi/zfcp_fsf.c257
-rw-r--r--drivers/s390/scsi/zfcp_scsi.c25
6 files changed, 191 insertions, 344 deletions
diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c
index 504c9219961c..5d39b2df0cc4 100644
--- a/drivers/s390/scsi/zfcp_aux.c
+++ b/drivers/s390/scsi/zfcp_aux.c
@@ -1135,9 +1135,6 @@ zfcp_adapter_enqueue(struct ccw_device *ccw_device)
1135 /* initialize lock of associated request queue */ 1135 /* initialize lock of associated request queue */
1136 rwlock_init(&adapter->request_queue.queue_lock); 1136 rwlock_init(&adapter->request_queue.queue_lock);
1137 1137
1138 /* intitialise SCSI ER timer */
1139 init_timer(&adapter->scsi_er_timer);
1140
1141 /* mark adapter unusable as long as sysfs registration is not complete */ 1138 /* mark adapter unusable as long as sysfs registration is not complete */
1142 atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &adapter->status); 1139 atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &adapter->status);
1143 1140
@@ -1653,7 +1650,6 @@ zfcp_ns_gid_pn_request(struct zfcp_erp_action *erp_action)
1653 gid_pn->ct.handler = zfcp_ns_gid_pn_handler; 1650 gid_pn->ct.handler = zfcp_ns_gid_pn_handler;
1654 gid_pn->ct.handler_data = (unsigned long) gid_pn; 1651 gid_pn->ct.handler_data = (unsigned long) gid_pn;
1655 gid_pn->ct.timeout = ZFCP_NS_GID_PN_TIMEOUT; 1652 gid_pn->ct.timeout = ZFCP_NS_GID_PN_TIMEOUT;
1656 gid_pn->ct.timer = &erp_action->timer;
1657 gid_pn->port = erp_action->port; 1653 gid_pn->port = erp_action->port;
1658 1654
1659 ret = zfcp_fsf_send_ct(&gid_pn->ct, adapter->pool.fsf_req_erp, 1655 ret = zfcp_fsf_send_ct(&gid_pn->ct, adapter->pool.fsf_req_erp,
diff --git a/drivers/s390/scsi/zfcp_def.h b/drivers/s390/scsi/zfcp_def.h
index ef1cd49184e8..8f882690994d 100644
--- a/drivers/s390/scsi/zfcp_def.h
+++ b/drivers/s390/scsi/zfcp_def.h
@@ -137,7 +137,7 @@ zfcp_address_to_sg(void *address, struct scatterlist *list)
137#define ZFCP_EXCHANGE_CONFIG_DATA_RETRIES 7 137#define ZFCP_EXCHANGE_CONFIG_DATA_RETRIES 7
138 138
139/* timeout value for "default timer" for fsf requests */ 139/* timeout value for "default timer" for fsf requests */
140#define ZFCP_FSF_REQUEST_TIMEOUT (60*HZ); 140#define ZFCP_FSF_REQUEST_TIMEOUT (60*HZ)
141 141
142/*************** FIBRE CHANNEL PROTOCOL SPECIFIC DEFINES ********************/ 142/*************** FIBRE CHANNEL PROTOCOL SPECIFIC DEFINES ********************/
143 143
@@ -779,7 +779,6 @@ typedef void (*zfcp_send_ct_handler_t)(unsigned long);
779 * @handler_data: data passed to handler function 779 * @handler_data: data passed to handler function
780 * @pool: pointer to memory pool for ct request structure 780 * @pool: pointer to memory pool for ct request structure
781 * @timeout: FSF timeout for this request 781 * @timeout: FSF timeout for this request
782 * @timer: timer (e.g. for request initiated by erp)
783 * @completion: completion for synchronization purposes 782 * @completion: completion for synchronization purposes
784 * @status: used to pass error status to calling function 783 * @status: used to pass error status to calling function
785 */ 784 */
@@ -793,7 +792,6 @@ struct zfcp_send_ct {
793 unsigned long handler_data; 792 unsigned long handler_data;
794 mempool_t *pool; 793 mempool_t *pool;
795 int timeout; 794 int timeout;
796 struct timer_list *timer;
797 struct completion *completion; 795 struct completion *completion;
798 int status; 796 int status;
799}; 797};
@@ -821,7 +819,6 @@ typedef void (*zfcp_send_els_handler_t)(unsigned long);
821 * @resp_count: number of elements in response scatter-gather list 819 * @resp_count: number of elements in response scatter-gather list
822 * @handler: handler function (called for response to the request) 820 * @handler: handler function (called for response to the request)
823 * @handler_data: data passed to handler function 821 * @handler_data: data passed to handler function
824 * @timer: timer (e.g. for request initiated by erp)
825 * @completion: completion for synchronization purposes 822 * @completion: completion for synchronization purposes
826 * @ls_code: hex code of ELS command 823 * @ls_code: hex code of ELS command
827 * @status: used to pass error status to calling function 824 * @status: used to pass error status to calling function
@@ -836,7 +833,6 @@ struct zfcp_send_els {
836 unsigned int resp_count; 833 unsigned int resp_count;
837 zfcp_send_els_handler_t handler; 834 zfcp_send_els_handler_t handler;
838 unsigned long handler_data; 835 unsigned long handler_data;
839 struct timer_list *timer;
840 struct completion *completion; 836 struct completion *completion;
841 int ls_code; 837 int ls_code;
842 int status; 838 int status;
@@ -886,7 +882,6 @@ struct zfcp_adapter {
886 struct list_head port_remove_lh; /* head of ports to be 882 struct list_head port_remove_lh; /* head of ports to be
887 removed */ 883 removed */
888 u32 ports; /* number of remote ports */ 884 u32 ports; /* number of remote ports */
889 struct timer_list scsi_er_timer; /* SCSI err recovery watch */
890 atomic_t reqs_active; /* # active FSF reqs */ 885 atomic_t reqs_active; /* # active FSF reqs */
891 unsigned long req_no; /* unique FSF req number */ 886 unsigned long req_no; /* unique FSF req number */
892 struct list_head *req_list; /* list of pending reqs */ 887 struct list_head *req_list; /* list of pending reqs */
@@ -1003,6 +998,7 @@ struct zfcp_fsf_req {
1003 struct fsf_qtcb *qtcb; /* address of associated QTCB */ 998 struct fsf_qtcb *qtcb; /* address of associated QTCB */
1004 u32 seq_no; /* Sequence number of request */ 999 u32 seq_no; /* Sequence number of request */
1005 unsigned long data; /* private data of request */ 1000 unsigned long data; /* private data of request */
1001 struct timer_list timer; /* used for erp or scsi er */
1006 struct zfcp_erp_action *erp_action; /* used if this request is 1002 struct zfcp_erp_action *erp_action; /* used if this request is
1007 issued on behalf of erp */ 1003 issued on behalf of erp */
1008 mempool_t *pool; /* used if request was alloacted 1004 mempool_t *pool; /* used if request was alloacted
diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c
index 7f60b6fdf724..af42a0eadf03 100644
--- a/drivers/s390/scsi/zfcp_erp.c
+++ b/drivers/s390/scsi/zfcp_erp.c
@@ -64,8 +64,6 @@ static int zfcp_erp_strategy_check_action(struct zfcp_erp_action *, int);
64static int zfcp_erp_adapter_strategy(struct zfcp_erp_action *); 64static int zfcp_erp_adapter_strategy(struct zfcp_erp_action *);
65static int zfcp_erp_adapter_strategy_generic(struct zfcp_erp_action *, int); 65static int zfcp_erp_adapter_strategy_generic(struct zfcp_erp_action *, int);
66static int zfcp_erp_adapter_strategy_close(struct zfcp_erp_action *); 66static int zfcp_erp_adapter_strategy_close(struct zfcp_erp_action *);
67static void zfcp_erp_adapter_strategy_close_qdio(struct zfcp_erp_action *);
68static void zfcp_erp_adapter_strategy_close_fsf(struct zfcp_erp_action *);
69static int zfcp_erp_adapter_strategy_open(struct zfcp_erp_action *); 67static int zfcp_erp_adapter_strategy_open(struct zfcp_erp_action *);
70static int zfcp_erp_adapter_strategy_open_qdio(struct zfcp_erp_action *); 68static int zfcp_erp_adapter_strategy_open_qdio(struct zfcp_erp_action *);
71static int zfcp_erp_adapter_strategy_open_fsf(struct zfcp_erp_action *); 69static int zfcp_erp_adapter_strategy_open_fsf(struct zfcp_erp_action *);
@@ -111,64 +109,86 @@ static inline void zfcp_erp_action_to_ready(struct zfcp_erp_action *);
111static inline void zfcp_erp_action_to_running(struct zfcp_erp_action *); 109static inline void zfcp_erp_action_to_running(struct zfcp_erp_action *);
112 110
113static void zfcp_erp_memwait_handler(unsigned long); 111static void zfcp_erp_memwait_handler(unsigned long);
114static void zfcp_erp_timeout_handler(unsigned long);
115static inline void zfcp_erp_timeout_init(struct zfcp_erp_action *);
116 112
117/** 113/**
118 * zfcp_fsf_request_timeout_handler - called if a request timed out 114 * zfcp_close_qdio - close qdio queues for an adapter
119 * @data: pointer to adapter for handler function
120 *
121 * This function needs to be called if requests (ELS, Generic Service,
122 * or SCSI commands) exceed a certain time limit. The assumption is
123 * that after the time limit the adapter get stuck. So we trigger a reopen of
124 * the adapter. This should not be used for error recovery, SCSI abort
125 * commands and SCSI requests from SCSI mid-layer.
126 */ 115 */
127void 116static void zfcp_close_qdio(struct zfcp_adapter *adapter)
128zfcp_fsf_request_timeout_handler(unsigned long data)
129{ 117{
130 struct zfcp_adapter *adapter; 118 struct zfcp_qdio_queue *req_queue;
119 int first, count;
131 120
132 adapter = (struct zfcp_adapter *) data; 121 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &adapter->status))
122 return;
133 123
134 zfcp_erp_adapter_reopen(adapter, 0); 124 /* clear QDIOUP flag, thus do_QDIO is not called during qdio_shutdown */
125 req_queue = &adapter->request_queue;
126 write_lock_irq(&req_queue->queue_lock);
127 atomic_clear_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &adapter->status);
128 write_unlock_irq(&req_queue->queue_lock);
129
130 debug_text_event(adapter->erp_dbf, 3, "qdio_down2a");
131 while (qdio_shutdown(adapter->ccw_device,
132 QDIO_FLAG_CLEANUP_USING_CLEAR) == -EINPROGRESS)
133 msleep(1000);
134 debug_text_event(adapter->erp_dbf, 3, "qdio_down2b");
135
136 /* cleanup used outbound sbals */
137 count = atomic_read(&req_queue->free_count);
138 if (count < QDIO_MAX_BUFFERS_PER_Q) {
139 first = (req_queue->free_index+count) % QDIO_MAX_BUFFERS_PER_Q;
140 count = QDIO_MAX_BUFFERS_PER_Q - count;
141 zfcp_qdio_zero_sbals(req_queue->buffer, first, count);
142 }
143 req_queue->free_index = 0;
144 atomic_set(&req_queue->free_count, 0);
145 req_queue->distance_from_int = 0;
146 adapter->response_queue.free_index = 0;
147 atomic_set(&adapter->response_queue.free_count, 0);
135} 148}
136 149
137/** 150/**
138 * zfcp_fsf_scsi_er_timeout_handler - timeout handler for scsi eh tasks 151 * zfcp_close_fsf - stop FSF operations for an adapter
139 * 152 *
140 * This function needs to be called whenever a SCSI error recovery 153 * Dismiss and cleanup all pending fsf_reqs (this wakes up all initiators of
141 * action (abort/reset) does not return. Re-opening the adapter means 154 * requests waiting for completion; especially this returns SCSI commands
142 * that the abort/reset command can be returned by zfcp. It won't complete 155 * with error state).
143 * via the adapter anymore (because qdio queues are closed). If ERP is
144 * already running on this adapter it will be stopped.
145 */ 156 */
146void zfcp_fsf_scsi_er_timeout_handler(unsigned long data) 157static void zfcp_close_fsf(struct zfcp_adapter *adapter)
147{ 158{
148 struct zfcp_adapter *adapter = (struct zfcp_adapter *) data; 159 /* close queues to ensure that buffers are not accessed by adapter */
149 unsigned long flags; 160 zfcp_close_qdio(adapter);
150 161 zfcp_fsf_req_dismiss_all(adapter);
151 ZFCP_LOG_NORMAL("warning: SCSI error recovery timed out. " 162 /* reset FSF request sequence number */
152 "Restarting all operations on the adapter %s\n", 163 adapter->fsf_req_seq_no = 0;
153 zfcp_get_busid_by_adapter(adapter)); 164 /* all ports and units are closed */
154 debug_text_event(adapter->erp_dbf, 1, "eh_lmem_tout"); 165 zfcp_erp_modify_adapter_status(adapter,
166 ZFCP_STATUS_COMMON_OPEN, ZFCP_CLEAR);
167}
155 168
156 write_lock_irqsave(&adapter->erp_lock, flags); 169/**
157 if (atomic_test_mask(ZFCP_STATUS_ADAPTER_ERP_PENDING, 170 * zfcp_fsf_request_timeout_handler - called if a request timed out
158 &adapter->status)) { 171 * @data: pointer to adapter for handler function
159 zfcp_erp_modify_adapter_status(adapter, 172 *
160 ZFCP_STATUS_COMMON_UNBLOCKED|ZFCP_STATUS_COMMON_OPEN, 173 * This function needs to be called if requests (ELS, Generic Service,
161 ZFCP_CLEAR); 174 * or SCSI commands) exceed a certain time limit. The assumption is
162 zfcp_erp_action_dismiss_adapter(adapter); 175 * that after the time limit the adapter get stuck. So we trigger a reopen of
163 write_unlock_irqrestore(&adapter->erp_lock, flags); 176 * the adapter.
164 /* dismiss all pending requests including requests for ERP */ 177 */
165 zfcp_fsf_req_dismiss_all(adapter); 178static void zfcp_fsf_request_timeout_handler(unsigned long data)
166 adapter->fsf_req_seq_no = 0; 179{
167 } else 180 struct zfcp_adapter *adapter = (struct zfcp_adapter *) data;
168 write_unlock_irqrestore(&adapter->erp_lock, flags);
169 zfcp_erp_adapter_reopen(adapter, 0); 181 zfcp_erp_adapter_reopen(adapter, 0);
170} 182}
171 183
184void zfcp_fsf_start_timer(struct zfcp_fsf_req *fsf_req, unsigned long timeout)
185{
186 fsf_req->timer.function = zfcp_fsf_request_timeout_handler;
187 fsf_req->timer.data = (unsigned long) fsf_req->adapter;
188 fsf_req->timer.expires = timeout;
189 add_timer(&fsf_req->timer);
190}
191
172/* 192/*
173 * function: 193 * function:
174 * 194 *
@@ -282,7 +302,6 @@ zfcp_erp_adisc(struct zfcp_port *port)
282 struct zfcp_ls_adisc *adisc; 302 struct zfcp_ls_adisc *adisc;
283 void *address = NULL; 303 void *address = NULL;
284 int retval = 0; 304 int retval = 0;
285 struct timer_list *timer;
286 305
287 send_els = kzalloc(sizeof(struct zfcp_send_els), GFP_ATOMIC); 306 send_els = kzalloc(sizeof(struct zfcp_send_els), GFP_ATOMIC);
288 if (send_els == NULL) 307 if (send_els == NULL)
@@ -329,22 +348,11 @@ zfcp_erp_adisc(struct zfcp_port *port)
329 (wwn_t) adisc->wwnn, adisc->hard_nport_id, 348 (wwn_t) adisc->wwnn, adisc->hard_nport_id,
330 adisc->nport_id); 349 adisc->nport_id);
331 350
332 timer = kmalloc(sizeof(struct timer_list), GFP_ATOMIC);
333 if (!timer)
334 goto nomem;
335
336 init_timer(timer);
337 timer->function = zfcp_fsf_request_timeout_handler;
338 timer->data = (unsigned long) adapter;
339 timer->expires = ZFCP_FSF_REQUEST_TIMEOUT;
340 send_els->timer = timer;
341
342 retval = zfcp_fsf_send_els(send_els); 351 retval = zfcp_fsf_send_els(send_els);
343 if (retval != 0) { 352 if (retval != 0) {
344 ZFCP_LOG_NORMAL("error: initiation of Send ELS failed for port " 353 ZFCP_LOG_NORMAL("error: initiation of Send ELS failed for port "
345 "0x%08x on adapter %s\n", send_els->d_id, 354 "0x%08x on adapter %s\n", send_els->d_id,
346 zfcp_get_busid_by_adapter(adapter)); 355 zfcp_get_busid_by_adapter(adapter));
347 del_timer(send_els->timer);
348 goto freemem; 356 goto freemem;
349 } 357 }
350 358
@@ -356,7 +364,6 @@ zfcp_erp_adisc(struct zfcp_port *port)
356 if (address != NULL) 364 if (address != NULL)
357 __free_pages(send_els->req->page, 0); 365 __free_pages(send_els->req->page, 0);
358 if (send_els != NULL) { 366 if (send_els != NULL) {
359 kfree(send_els->timer);
360 kfree(send_els->req); 367 kfree(send_els->req);
361 kfree(send_els->resp); 368 kfree(send_els->resp);
362 kfree(send_els); 369 kfree(send_els);
@@ -382,9 +389,6 @@ zfcp_erp_adisc_handler(unsigned long data)
382 struct zfcp_ls_adisc_acc *adisc; 389 struct zfcp_ls_adisc_acc *adisc;
383 390
384 send_els = (struct zfcp_send_els *) data; 391 send_els = (struct zfcp_send_els *) data;
385
386 del_timer(send_els->timer);
387
388 adapter = send_els->adapter; 392 adapter = send_els->adapter;
389 port = send_els->port; 393 port = send_els->port;
390 d_id = send_els->d_id; 394 d_id = send_els->d_id;
@@ -433,7 +437,6 @@ zfcp_erp_adisc_handler(unsigned long data)
433 out: 437 out:
434 zfcp_port_put(port); 438 zfcp_port_put(port);
435 __free_pages(send_els->req->page, 0); 439 __free_pages(send_els->req->page, 0);
436 kfree(send_els->timer);
437 kfree(send_els->req); 440 kfree(send_els->req);
438 kfree(send_els->resp); 441 kfree(send_els->resp);
439 kfree(send_els); 442 kfree(send_els);
@@ -909,8 +912,6 @@ static void zfcp_erp_async_handler_nolock(struct zfcp_erp_action *erp_action,
909 debug_text_event(adapter->erp_dbf, 2, "a_asyh_ex"); 912 debug_text_event(adapter->erp_dbf, 2, "a_asyh_ex");
910 debug_event(adapter->erp_dbf, 2, &erp_action->action, 913 debug_event(adapter->erp_dbf, 2, &erp_action->action,
911 sizeof (int)); 914 sizeof (int));
912 if (!(set_mask & ZFCP_STATUS_ERP_TIMEDOUT))
913 del_timer(&erp_action->timer);
914 erp_action->status |= set_mask; 915 erp_action->status |= set_mask;
915 zfcp_erp_action_ready(erp_action); 916 zfcp_erp_action_ready(erp_action);
916 } else { 917 } else {
@@ -957,8 +958,7 @@ zfcp_erp_memwait_handler(unsigned long data)
957 * action gets an appropriate flag and will be processed 958 * action gets an appropriate flag and will be processed
958 * accordingly 959 * accordingly
959 */ 960 */
960static void 961void zfcp_erp_timeout_handler(unsigned long data)
961zfcp_erp_timeout_handler(unsigned long data)
962{ 962{
963 struct zfcp_erp_action *erp_action = (struct zfcp_erp_action *) data; 963 struct zfcp_erp_action *erp_action = (struct zfcp_erp_action *) data;
964 struct zfcp_adapter *adapter = erp_action->adapter; 964 struct zfcp_adapter *adapter = erp_action->adapter;
@@ -1934,8 +1934,7 @@ zfcp_erp_adapter_strategy_generic(struct zfcp_erp_action *erp_action, int close)
1934 &erp_action->adapter->status); 1934 &erp_action->adapter->status);
1935 1935
1936 failed_openfcp: 1936 failed_openfcp:
1937 zfcp_erp_adapter_strategy_close_qdio(erp_action); 1937 zfcp_close_fsf(erp_action->adapter);
1938 zfcp_erp_adapter_strategy_close_fsf(erp_action);
1939 failed_qdio: 1938 failed_qdio:
1940 out: 1939 out:
1941 return retval; 1940 return retval;
@@ -2040,59 +2039,6 @@ zfcp_erp_adapter_strategy_open_qdio(struct zfcp_erp_action *erp_action)
2040 return retval; 2039 return retval;
2041} 2040}
2042 2041
2043/**
2044 * zfcp_erp_adapter_strategy_close_qdio - close qdio queues for an adapter
2045 */
2046static void
2047zfcp_erp_adapter_strategy_close_qdio(struct zfcp_erp_action *erp_action)
2048{
2049 int first_used;
2050 int used_count;
2051 struct zfcp_adapter *adapter = erp_action->adapter;
2052
2053 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &adapter->status)) {
2054 ZFCP_LOG_DEBUG("error: attempt to shut down inactive QDIO "
2055 "queues on adapter %s\n",
2056 zfcp_get_busid_by_adapter(adapter));
2057 return;
2058 }
2059
2060 /*
2061 * Get queue_lock and clear QDIOUP flag. Thus it's guaranteed that
2062 * do_QDIO won't be called while qdio_shutdown is in progress.
2063 */
2064 write_lock_irq(&adapter->request_queue.queue_lock);
2065 atomic_clear_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &adapter->status);
2066 write_unlock_irq(&adapter->request_queue.queue_lock);
2067
2068 debug_text_event(adapter->erp_dbf, 3, "qdio_down2a");
2069 while (qdio_shutdown(adapter->ccw_device,
2070 QDIO_FLAG_CLEANUP_USING_CLEAR) == -EINPROGRESS)
2071 msleep(1000);
2072 debug_text_event(adapter->erp_dbf, 3, "qdio_down2b");
2073
2074 /*
2075 * First we had to stop QDIO operation.
2076 * Now it is safe to take the following actions.
2077 */
2078
2079 /* Cleanup only necessary when there are unacknowledged buffers */
2080 if (atomic_read(&adapter->request_queue.free_count)
2081 < QDIO_MAX_BUFFERS_PER_Q) {
2082 first_used = (adapter->request_queue.free_index +
2083 atomic_read(&adapter->request_queue.free_count))
2084 % QDIO_MAX_BUFFERS_PER_Q;
2085 used_count = QDIO_MAX_BUFFERS_PER_Q -
2086 atomic_read(&adapter->request_queue.free_count);
2087 zfcp_qdio_zero_sbals(adapter->request_queue.buffer,
2088 first_used, used_count);
2089 }
2090 adapter->response_queue.free_index = 0;
2091 atomic_set(&adapter->response_queue.free_count, 0);
2092 adapter->request_queue.free_index = 0;
2093 atomic_set(&adapter->request_queue.free_count, 0);
2094 adapter->request_queue.distance_from_int = 0;
2095}
2096 2042
2097static int 2043static int
2098zfcp_erp_adapter_strategy_open_fsf(struct zfcp_erp_action *erp_action) 2044zfcp_erp_adapter_strategy_open_fsf(struct zfcp_erp_action *erp_action)
@@ -2127,7 +2073,6 @@ zfcp_erp_adapter_strategy_open_fsf_xconfig(struct zfcp_erp_action *erp_action)
2127 write_lock_irq(&adapter->erp_lock); 2073 write_lock_irq(&adapter->erp_lock);
2128 zfcp_erp_action_to_running(erp_action); 2074 zfcp_erp_action_to_running(erp_action);
2129 write_unlock_irq(&adapter->erp_lock); 2075 write_unlock_irq(&adapter->erp_lock);
2130 zfcp_erp_timeout_init(erp_action);
2131 if (zfcp_fsf_exchange_config_data(erp_action)) { 2076 if (zfcp_fsf_exchange_config_data(erp_action)) {
2132 retval = ZFCP_ERP_FAILED; 2077 retval = ZFCP_ERP_FAILED;
2133 debug_text_event(adapter->erp_dbf, 5, "a_fstx_xf"); 2078 debug_text_event(adapter->erp_dbf, 5, "a_fstx_xf");
@@ -2196,7 +2141,6 @@ zfcp_erp_adapter_strategy_open_fsf_xport(struct zfcp_erp_action *erp_action)
2196 zfcp_erp_action_to_running(erp_action); 2141 zfcp_erp_action_to_running(erp_action);
2197 write_unlock_irq(&adapter->erp_lock); 2142 write_unlock_irq(&adapter->erp_lock);
2198 2143
2199 zfcp_erp_timeout_init(erp_action);
2200 ret = zfcp_fsf_exchange_port_data(erp_action, adapter, NULL); 2144 ret = zfcp_fsf_exchange_port_data(erp_action, adapter, NULL);
2201 if (ret == -EOPNOTSUPP) { 2145 if (ret == -EOPNOTSUPP) {
2202 debug_text_event(adapter->erp_dbf, 3, "a_xport_notsupp"); 2146 debug_text_event(adapter->erp_dbf, 3, "a_xport_notsupp");
@@ -2248,27 +2192,6 @@ zfcp_erp_adapter_strategy_open_fsf_statusread(struct zfcp_erp_action
2248 return retval; 2192 return retval;
2249} 2193}
2250 2194
2251/**
2252 * zfcp_erp_adapter_strategy_close_fsf - stop FSF operations for an adapter
2253 */
2254static void
2255zfcp_erp_adapter_strategy_close_fsf(struct zfcp_erp_action *erp_action)
2256{
2257 struct zfcp_adapter *adapter = erp_action->adapter;
2258
2259 /*
2260 * wake waiting initiators of requests,
2261 * return SCSI commands (with error status),
2262 * clean up all requests (synchronously)
2263 */
2264 zfcp_fsf_req_dismiss_all(adapter);
2265 /* reset FSF request sequence number */
2266 adapter->fsf_req_seq_no = 0;
2267 /* all ports and units are closed */
2268 zfcp_erp_modify_adapter_status(adapter,
2269 ZFCP_STATUS_COMMON_OPEN, ZFCP_CLEAR);
2270}
2271
2272/* 2195/*
2273 * function: 2196 * function:
2274 * 2197 *
@@ -2605,7 +2528,6 @@ zfcp_erp_port_forced_strategy_close(struct zfcp_erp_action *erp_action)
2605 struct zfcp_adapter *adapter = erp_action->adapter; 2528 struct zfcp_adapter *adapter = erp_action->adapter;
2606 struct zfcp_port *port = erp_action->port; 2529 struct zfcp_port *port = erp_action->port;
2607 2530
2608 zfcp_erp_timeout_init(erp_action);
2609 retval = zfcp_fsf_close_physical_port(erp_action); 2531 retval = zfcp_fsf_close_physical_port(erp_action);
2610 if (retval == -ENOMEM) { 2532 if (retval == -ENOMEM) {
2611 debug_text_event(adapter->erp_dbf, 5, "o_pfstc_nomem"); 2533 debug_text_event(adapter->erp_dbf, 5, "o_pfstc_nomem");
@@ -2662,7 +2584,6 @@ zfcp_erp_port_strategy_close(struct zfcp_erp_action *erp_action)
2662 struct zfcp_adapter *adapter = erp_action->adapter; 2584 struct zfcp_adapter *adapter = erp_action->adapter;
2663 struct zfcp_port *port = erp_action->port; 2585 struct zfcp_port *port = erp_action->port;
2664 2586
2665 zfcp_erp_timeout_init(erp_action);
2666 retval = zfcp_fsf_close_port(erp_action); 2587 retval = zfcp_fsf_close_port(erp_action);
2667 if (retval == -ENOMEM) { 2588 if (retval == -ENOMEM) {
2668 debug_text_event(adapter->erp_dbf, 5, "p_pstc_nomem"); 2589 debug_text_event(adapter->erp_dbf, 5, "p_pstc_nomem");
@@ -2700,7 +2621,6 @@ zfcp_erp_port_strategy_open_port(struct zfcp_erp_action *erp_action)
2700 struct zfcp_adapter *adapter = erp_action->adapter; 2621 struct zfcp_adapter *adapter = erp_action->adapter;
2701 struct zfcp_port *port = erp_action->port; 2622 struct zfcp_port *port = erp_action->port;
2702 2623
2703 zfcp_erp_timeout_init(erp_action);
2704 retval = zfcp_fsf_open_port(erp_action); 2624 retval = zfcp_fsf_open_port(erp_action);
2705 if (retval == -ENOMEM) { 2625 if (retval == -ENOMEM) {
2706 debug_text_event(adapter->erp_dbf, 5, "p_psto_nomem"); 2626 debug_text_event(adapter->erp_dbf, 5, "p_psto_nomem");
@@ -2738,7 +2658,6 @@ zfcp_erp_port_strategy_open_common_lookup(struct zfcp_erp_action *erp_action)
2738 struct zfcp_adapter *adapter = erp_action->adapter; 2658 struct zfcp_adapter *adapter = erp_action->adapter;
2739 struct zfcp_port *port = erp_action->port; 2659 struct zfcp_port *port = erp_action->port;
2740 2660
2741 zfcp_erp_timeout_init(erp_action);
2742 retval = zfcp_ns_gid_pn_request(erp_action); 2661 retval = zfcp_ns_gid_pn_request(erp_action);
2743 if (retval == -ENOMEM) { 2662 if (retval == -ENOMEM) {
2744 debug_text_event(adapter->erp_dbf, 5, "p_pstn_nomem"); 2663 debug_text_event(adapter->erp_dbf, 5, "p_pstn_nomem");
@@ -2864,7 +2783,6 @@ zfcp_erp_unit_strategy_close(struct zfcp_erp_action *erp_action)
2864 struct zfcp_adapter *adapter = erp_action->adapter; 2783 struct zfcp_adapter *adapter = erp_action->adapter;
2865 struct zfcp_unit *unit = erp_action->unit; 2784 struct zfcp_unit *unit = erp_action->unit;
2866 2785
2867 zfcp_erp_timeout_init(erp_action);
2868 retval = zfcp_fsf_close_unit(erp_action); 2786 retval = zfcp_fsf_close_unit(erp_action);
2869 if (retval == -ENOMEM) { 2787 if (retval == -ENOMEM) {
2870 debug_text_event(adapter->erp_dbf, 5, "u_ustc_nomem"); 2788 debug_text_event(adapter->erp_dbf, 5, "u_ustc_nomem");
@@ -2905,7 +2823,6 @@ zfcp_erp_unit_strategy_open(struct zfcp_erp_action *erp_action)
2905 struct zfcp_adapter *adapter = erp_action->adapter; 2823 struct zfcp_adapter *adapter = erp_action->adapter;
2906 struct zfcp_unit *unit = erp_action->unit; 2824 struct zfcp_unit *unit = erp_action->unit;
2907 2825
2908 zfcp_erp_timeout_init(erp_action);
2909 retval = zfcp_fsf_open_unit(erp_action); 2826 retval = zfcp_fsf_open_unit(erp_action);
2910 if (retval == -ENOMEM) { 2827 if (retval == -ENOMEM) {
2911 debug_text_event(adapter->erp_dbf, 5, "u_usto_nomem"); 2828 debug_text_event(adapter->erp_dbf, 5, "u_usto_nomem");
@@ -2930,14 +2847,13 @@ zfcp_erp_unit_strategy_open(struct zfcp_erp_action *erp_action)
2930 return retval; 2847 return retval;
2931} 2848}
2932 2849
2933static inline void 2850void zfcp_erp_start_timer(struct zfcp_fsf_req *fsf_req)
2934zfcp_erp_timeout_init(struct zfcp_erp_action *erp_action)
2935{ 2851{
2936 init_timer(&erp_action->timer); 2852 BUG_ON(!fsf_req->erp_action);
2937 erp_action->timer.function = zfcp_erp_timeout_handler; 2853 fsf_req->timer.function = zfcp_erp_timeout_handler;
2938 erp_action->timer.data = (unsigned long) erp_action; 2854 fsf_req->timer.data = (unsigned long) fsf_req->erp_action;
2939 /* jiffies will be added in zfcp_fsf_req_send */ 2855 fsf_req->timer.expires = jiffies + ZFCP_ERP_FSFREQ_TIMEOUT;
2940 erp_action->timer.expires = ZFCP_ERP_FSFREQ_TIMEOUT; 2856 add_timer(&fsf_req->timer);
2941} 2857}
2942 2858
2943/* 2859/*
diff --git a/drivers/s390/scsi/zfcp_ext.h b/drivers/s390/scsi/zfcp_ext.h
index 710ebbf89929..3125a42a6343 100644
--- a/drivers/s390/scsi/zfcp_ext.h
+++ b/drivers/s390/scsi/zfcp_ext.h
@@ -87,8 +87,8 @@ extern int zfcp_fsf_exchange_port_data(struct zfcp_erp_action *,
87 struct fsf_qtcb_bottom_port *); 87 struct fsf_qtcb_bottom_port *);
88extern int zfcp_fsf_control_file(struct zfcp_adapter *, struct zfcp_fsf_req **, 88extern int zfcp_fsf_control_file(struct zfcp_adapter *, struct zfcp_fsf_req **,
89 u32, u32, struct zfcp_sg_list *); 89 u32, u32, struct zfcp_sg_list *);
90extern void zfcp_fsf_request_timeout_handler(unsigned long); 90extern void zfcp_fsf_start_timer(struct zfcp_fsf_req *, unsigned long);
91extern void zfcp_fsf_scsi_er_timeout_handler(unsigned long); 91extern void zfcp_erp_start_timer(struct zfcp_fsf_req *);
92extern int zfcp_fsf_req_dismiss_all(struct zfcp_adapter *); 92extern int zfcp_fsf_req_dismiss_all(struct zfcp_adapter *);
93extern int zfcp_fsf_status_read(struct zfcp_adapter *, int); 93extern int zfcp_fsf_status_read(struct zfcp_adapter *, int);
94extern int zfcp_fsf_req_create(struct zfcp_adapter *, u32, int, mempool_t *, 94extern int zfcp_fsf_req_create(struct zfcp_adapter *, u32, int, mempool_t *,
@@ -98,8 +98,7 @@ extern int zfcp_fsf_send_ct(struct zfcp_send_ct *, mempool_t *,
98extern int zfcp_fsf_send_els(struct zfcp_send_els *); 98extern int zfcp_fsf_send_els(struct zfcp_send_els *);
99extern int zfcp_fsf_send_fcp_command_task(struct zfcp_adapter *, 99extern int zfcp_fsf_send_fcp_command_task(struct zfcp_adapter *,
100 struct zfcp_unit *, 100 struct zfcp_unit *,
101 struct scsi_cmnd *, 101 struct scsi_cmnd *, int, int);
102 struct timer_list*, int);
103extern int zfcp_fsf_req_complete(struct zfcp_fsf_req *); 102extern int zfcp_fsf_req_complete(struct zfcp_fsf_req *);
104extern void zfcp_fsf_incoming_els(struct zfcp_fsf_req *); 103extern void zfcp_fsf_incoming_els(struct zfcp_fsf_req *);
105extern void zfcp_fsf_req_free(struct zfcp_fsf_req *); 104extern void zfcp_fsf_req_free(struct zfcp_fsf_req *);
@@ -123,13 +122,11 @@ extern char *zfcp_get_fcp_rsp_info_ptr(struct fcp_rsp_iu *);
123extern void set_host_byte(u32 *, char); 122extern void set_host_byte(u32 *, char);
124extern void set_driver_byte(u32 *, char); 123extern void set_driver_byte(u32 *, char);
125extern char *zfcp_get_fcp_sns_info_ptr(struct fcp_rsp_iu *); 124extern char *zfcp_get_fcp_sns_info_ptr(struct fcp_rsp_iu *);
126extern void zfcp_fsf_start_scsi_er_timer(struct zfcp_adapter *);
127extern fcp_dl_t zfcp_get_fcp_dl(struct fcp_cmnd_iu *); 125extern fcp_dl_t zfcp_get_fcp_dl(struct fcp_cmnd_iu *);
128 126
129extern int zfcp_scsi_command_async(struct zfcp_adapter *,struct zfcp_unit *, 127extern int zfcp_scsi_command_async(struct zfcp_adapter *,struct zfcp_unit *,
130 struct scsi_cmnd *, struct timer_list *); 128 struct scsi_cmnd *, int);
131extern int zfcp_scsi_command_sync(struct zfcp_unit *, struct scsi_cmnd *, 129extern int zfcp_scsi_command_sync(struct zfcp_unit *, struct scsi_cmnd *, int);
132 struct timer_list *);
133extern struct fc_function_template zfcp_transport_functions; 130extern struct fc_function_template zfcp_transport_functions;
134 131
135/******************************** ERP ****************************************/ 132/******************************** ERP ****************************************/
diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c
index a66b5193b70e..277826cdd0c8 100644
--- a/drivers/s390/scsi/zfcp_fsf.c
+++ b/drivers/s390/scsi/zfcp_fsf.c
@@ -42,7 +42,7 @@ static inline int zfcp_fsf_req_sbal_check(
42static inline int zfcp_use_one_sbal( 42static inline int zfcp_use_one_sbal(
43 struct scatterlist *, int, struct scatterlist *, int); 43 struct scatterlist *, int, struct scatterlist *, int);
44static struct zfcp_fsf_req *zfcp_fsf_req_alloc(mempool_t *, int); 44static struct zfcp_fsf_req *zfcp_fsf_req_alloc(mempool_t *, int);
45static int zfcp_fsf_req_send(struct zfcp_fsf_req *, struct timer_list *); 45static int zfcp_fsf_req_send(struct zfcp_fsf_req *);
46static int zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *); 46static int zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *);
47static int zfcp_fsf_fsfstatus_eval(struct zfcp_fsf_req *); 47static int zfcp_fsf_fsfstatus_eval(struct zfcp_fsf_req *);
48static int zfcp_fsf_fsfstatus_qual_eval(struct zfcp_fsf_req *); 48static int zfcp_fsf_fsfstatus_qual_eval(struct zfcp_fsf_req *);
@@ -225,8 +225,10 @@ zfcp_fsf_req_complete(struct zfcp_fsf_req *fsf_req)
225 */ 225 */
226 zfcp_fsf_status_read_handler(fsf_req); 226 zfcp_fsf_status_read_handler(fsf_req);
227 goto out; 227 goto out;
228 } else 228 } else {
229 del_timer(&fsf_req->timer);
229 zfcp_fsf_protstatus_eval(fsf_req); 230 zfcp_fsf_protstatus_eval(fsf_req);
231 }
230 232
231 /* 233 /*
232 * fsf_req may be deleted due to waking up functions, so 234 * fsf_req may be deleted due to waking up functions, so
@@ -785,8 +787,7 @@ zfcp_fsf_status_read(struct zfcp_adapter *adapter, int req_flags)
785 sbale->addr = (void *) status_buffer; 787 sbale->addr = (void *) status_buffer;
786 sbale->length = sizeof(struct fsf_status_read_buffer); 788 sbale->length = sizeof(struct fsf_status_read_buffer);
787 789
788 /* start QDIO request for this FSF request */ 790 retval = zfcp_fsf_req_send(fsf_req);
789 retval = zfcp_fsf_req_send(fsf_req, NULL);
790 if (retval) { 791 if (retval) {
791 ZFCP_LOG_DEBUG("error: Could not set-up unsolicited status " 792 ZFCP_LOG_DEBUG("error: Could not set-up unsolicited status "
792 "environment.\n"); 793 "environment.\n");
@@ -1112,8 +1113,8 @@ zfcp_fsf_abort_fcp_command(unsigned long old_req_id,
1112 struct zfcp_unit *unit, int req_flags) 1113 struct zfcp_unit *unit, int req_flags)
1113{ 1114{
1114 volatile struct qdio_buffer_element *sbale; 1115 volatile struct qdio_buffer_element *sbale;
1115 unsigned long lock_flags;
1116 struct zfcp_fsf_req *fsf_req = NULL; 1116 struct zfcp_fsf_req *fsf_req = NULL;
1117 unsigned long lock_flags;
1117 int retval = 0; 1118 int retval = 0;
1118 1119
1119 /* setup new FSF request */ 1120 /* setup new FSF request */
@@ -1143,12 +1144,9 @@ zfcp_fsf_abort_fcp_command(unsigned long old_req_id,
1143 /* set handle of request which should be aborted */ 1144 /* set handle of request which should be aborted */
1144 fsf_req->qtcb->bottom.support.req_handle = (u64) old_req_id; 1145 fsf_req->qtcb->bottom.support.req_handle = (u64) old_req_id;
1145 1146
1146 /* start QDIO request for this FSF request */ 1147 zfcp_fsf_start_timer(fsf_req, ZFCP_SCSI_ER_TIMEOUT);
1147 1148 retval = zfcp_fsf_req_send(fsf_req);
1148 zfcp_fsf_start_scsi_er_timer(adapter);
1149 retval = zfcp_fsf_req_send(fsf_req, NULL);
1150 if (retval) { 1149 if (retval) {
1151 del_timer(&adapter->scsi_er_timer);
1152 ZFCP_LOG_INFO("error: Failed to send abort command request " 1150 ZFCP_LOG_INFO("error: Failed to send abort command request "
1153 "on adapter %s, port 0x%016Lx, unit 0x%016Lx\n", 1151 "on adapter %s, port 0x%016Lx, unit 0x%016Lx\n",
1154 zfcp_get_busid_by_adapter(adapter), 1152 zfcp_get_busid_by_adapter(adapter),
@@ -1184,8 +1182,6 @@ zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *new_fsf_req)
1184 unsigned char status_qual = 1182 unsigned char status_qual =
1185 new_fsf_req->qtcb->header.fsf_status_qual.word[0]; 1183 new_fsf_req->qtcb->header.fsf_status_qual.word[0];
1186 1184
1187 del_timer(&new_fsf_req->adapter->scsi_er_timer);
1188
1189 if (new_fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) { 1185 if (new_fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
1190 /* do not set ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED */ 1186 /* do not set ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED */
1191 goto skip_fsfstatus; 1187 goto skip_fsfstatus;
@@ -1391,11 +1387,6 @@ zfcp_fsf_send_ct(struct zfcp_send_ct *ct, mempool_t *pool,
1391 goto failed_req; 1387 goto failed_req;
1392 } 1388 }
1393 1389
1394 if (erp_action != NULL) {
1395 erp_action->fsf_req = fsf_req;
1396 fsf_req->erp_action = erp_action;
1397 }
1398
1399 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0); 1390 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
1400 if (zfcp_use_one_sbal(ct->req, ct->req_count, 1391 if (zfcp_use_one_sbal(ct->req, ct->req_count,
1401 ct->resp, ct->resp_count)){ 1392 ct->resp, ct->resp_count)){
@@ -1462,8 +1453,14 @@ zfcp_fsf_send_ct(struct zfcp_send_ct *ct, mempool_t *pool,
1462 1453
1463 zfcp_san_dbf_event_ct_request(fsf_req); 1454 zfcp_san_dbf_event_ct_request(fsf_req);
1464 1455
1465 /* start QDIO request for this FSF request */ 1456 if (erp_action) {
1466 ret = zfcp_fsf_req_send(fsf_req, ct->timer); 1457 erp_action->fsf_req = fsf_req;
1458 fsf_req->erp_action = erp_action;
1459 zfcp_erp_start_timer(fsf_req);
1460 } else
1461 zfcp_fsf_start_timer(fsf_req, ZFCP_FSF_REQUEST_TIMEOUT);
1462
1463 ret = zfcp_fsf_req_send(fsf_req);
1467 if (ret) { 1464 if (ret) {
1468 ZFCP_LOG_DEBUG("error: initiation of CT request failed " 1465 ZFCP_LOG_DEBUG("error: initiation of CT request failed "
1469 "(adapter %s, port 0x%016Lx)\n", 1466 "(adapter %s, port 0x%016Lx)\n",
@@ -1760,8 +1757,8 @@ zfcp_fsf_send_els(struct zfcp_send_els *els)
1760 1757
1761 zfcp_san_dbf_event_els_request(fsf_req); 1758 zfcp_san_dbf_event_els_request(fsf_req);
1762 1759
1763 /* start QDIO request for this FSF request */ 1760 zfcp_fsf_start_timer(fsf_req, ZFCP_FSF_REQUEST_TIMEOUT);
1764 ret = zfcp_fsf_req_send(fsf_req, els->timer); 1761 ret = zfcp_fsf_req_send(fsf_req);
1765 if (ret) { 1762 if (ret) {
1766 ZFCP_LOG_DEBUG("error: initiation of ELS request failed " 1763 ZFCP_LOG_DEBUG("error: initiation of ELS request failed "
1767 "(adapter %s, port d_id: 0x%08x)\n", 1764 "(adapter %s, port d_id: 0x%08x)\n",
@@ -1958,6 +1955,7 @@ int
1958zfcp_fsf_exchange_config_data(struct zfcp_erp_action *erp_action) 1955zfcp_fsf_exchange_config_data(struct zfcp_erp_action *erp_action)
1959{ 1956{
1960 volatile struct qdio_buffer_element *sbale; 1957 volatile struct qdio_buffer_element *sbale;
1958 struct zfcp_fsf_req *fsf_req;
1961 unsigned long lock_flags; 1959 unsigned long lock_flags;
1962 int retval = 0; 1960 int retval = 0;
1963 1961
@@ -1966,7 +1964,7 @@ zfcp_fsf_exchange_config_data(struct zfcp_erp_action *erp_action)
1966 FSF_QTCB_EXCHANGE_CONFIG_DATA, 1964 FSF_QTCB_EXCHANGE_CONFIG_DATA,
1967 ZFCP_REQ_AUTO_CLEANUP, 1965 ZFCP_REQ_AUTO_CLEANUP,
1968 erp_action->adapter->pool.fsf_req_erp, 1966 erp_action->adapter->pool.fsf_req_erp,
1969 &lock_flags, &(erp_action->fsf_req)); 1967 &lock_flags, &fsf_req);
1970 if (retval < 0) { 1968 if (retval < 0) {
1971 ZFCP_LOG_INFO("error: Could not create exchange configuration " 1969 ZFCP_LOG_INFO("error: Could not create exchange configuration "
1972 "data request for adapter %s.\n", 1970 "data request for adapter %s.\n",
@@ -1974,26 +1972,26 @@ zfcp_fsf_exchange_config_data(struct zfcp_erp_action *erp_action)
1974 goto out; 1972 goto out;
1975 } 1973 }
1976 1974
1977 sbale = zfcp_qdio_sbale_req(erp_action->fsf_req, 1975 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
1978 erp_action->fsf_req->sbal_curr, 0);
1979 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; 1976 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1980 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; 1977 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1981 1978
1982 erp_action->fsf_req->erp_action = erp_action; 1979 fsf_req->qtcb->bottom.config.feature_selection =
1983 erp_action->fsf_req->qtcb->bottom.config.feature_selection =
1984 FSF_FEATURE_CFDC | 1980 FSF_FEATURE_CFDC |
1985 FSF_FEATURE_LUN_SHARING | 1981 FSF_FEATURE_LUN_SHARING |
1986 FSF_FEATURE_NOTIFICATION_LOST | 1982 FSF_FEATURE_NOTIFICATION_LOST |
1987 FSF_FEATURE_UPDATE_ALERT; 1983 FSF_FEATURE_UPDATE_ALERT;
1984 fsf_req->erp_action = erp_action;
1985 erp_action->fsf_req = fsf_req;
1988 1986
1989 /* start QDIO request for this FSF request */ 1987 zfcp_erp_start_timer(fsf_req);
1990 retval = zfcp_fsf_req_send(erp_action->fsf_req, &erp_action->timer); 1988 retval = zfcp_fsf_req_send(fsf_req);
1991 if (retval) { 1989 if (retval) {
1992 ZFCP_LOG_INFO 1990 ZFCP_LOG_INFO
1993 ("error: Could not send exchange configuration data " 1991 ("error: Could not send exchange configuration data "
1994 "command on the adapter %s\n", 1992 "command on the adapter %s\n",
1995 zfcp_get_busid_by_adapter(erp_action->adapter)); 1993 zfcp_get_busid_by_adapter(erp_action->adapter));
1996 zfcp_fsf_req_free(erp_action->fsf_req); 1994 zfcp_fsf_req_free(fsf_req);
1997 erp_action->fsf_req = NULL; 1995 erp_action->fsf_req = NULL;
1998 goto out; 1996 goto out;
1999 } 1997 }
@@ -2223,10 +2221,9 @@ zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action,
2223 struct fsf_qtcb_bottom_port *data) 2221 struct fsf_qtcb_bottom_port *data)
2224{ 2222{
2225 volatile struct qdio_buffer_element *sbale; 2223 volatile struct qdio_buffer_element *sbale;
2226 int retval = 0;
2227 unsigned long lock_flags;
2228 struct zfcp_fsf_req *fsf_req; 2224 struct zfcp_fsf_req *fsf_req;
2229 struct timer_list *timer; 2225 unsigned long lock_flags;
2226 int retval = 0;
2230 2227
2231 if (!(adapter->adapter_features & FSF_FEATURE_HBAAPI_MANAGEMENT)) { 2228 if (!(adapter->adapter_features & FSF_FEATURE_HBAAPI_MANAGEMENT)) {
2232 ZFCP_LOG_INFO("error: exchange port data " 2229 ZFCP_LOG_INFO("error: exchange port data "
@@ -2259,22 +2256,11 @@ zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action,
2259 if (erp_action) { 2256 if (erp_action) {
2260 erp_action->fsf_req = fsf_req; 2257 erp_action->fsf_req = fsf_req;
2261 fsf_req->erp_action = erp_action; 2258 fsf_req->erp_action = erp_action;
2262 timer = &erp_action->timer; 2259 zfcp_erp_start_timer(fsf_req);
2263 } else { 2260 } else
2264 timer = kmalloc(sizeof(struct timer_list), GFP_ATOMIC); 2261 zfcp_fsf_start_timer(fsf_req, ZFCP_FSF_REQUEST_TIMEOUT);
2265 if (!timer) {
2266 write_unlock_irqrestore(&adapter->request_queue.queue_lock,
2267 lock_flags);
2268 zfcp_fsf_req_free(fsf_req);
2269 return -ENOMEM;
2270 }
2271 init_timer(timer);
2272 timer->function = zfcp_fsf_request_timeout_handler;
2273 timer->data = (unsigned long) adapter;
2274 timer->expires = ZFCP_FSF_REQUEST_TIMEOUT;
2275 }
2276 2262
2277 retval = zfcp_fsf_req_send(fsf_req, timer); 2263 retval = zfcp_fsf_req_send(fsf_req);
2278 if (retval) { 2264 if (retval) {
2279 ZFCP_LOG_INFO("error: Could not send an exchange port data " 2265 ZFCP_LOG_INFO("error: Could not send an exchange port data "
2280 "command on the adapter %s\n", 2266 "command on the adapter %s\n",
@@ -2282,8 +2268,6 @@ zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action,
2282 zfcp_fsf_req_free(fsf_req); 2268 zfcp_fsf_req_free(fsf_req);
2283 if (erp_action) 2269 if (erp_action)
2284 erp_action->fsf_req = NULL; 2270 erp_action->fsf_req = NULL;
2285 else
2286 kfree(timer);
2287 write_unlock_irqrestore(&adapter->request_queue.queue_lock, 2271 write_unlock_irqrestore(&adapter->request_queue.queue_lock,
2288 lock_flags); 2272 lock_flags);
2289 return retval; 2273 return retval;
@@ -2294,9 +2278,7 @@ zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action,
2294 if (!erp_action) { 2278 if (!erp_action) {
2295 wait_event(fsf_req->completion_wq, 2279 wait_event(fsf_req->completion_wq,
2296 fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED); 2280 fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED);
2297 del_timer_sync(timer);
2298 zfcp_fsf_req_free(fsf_req); 2281 zfcp_fsf_req_free(fsf_req);
2299 kfree(timer);
2300 } 2282 }
2301 return retval; 2283 return retval;
2302} 2284}
@@ -2378,6 +2360,7 @@ int
2378zfcp_fsf_open_port(struct zfcp_erp_action *erp_action) 2360zfcp_fsf_open_port(struct zfcp_erp_action *erp_action)
2379{ 2361{
2380 volatile struct qdio_buffer_element *sbale; 2362 volatile struct qdio_buffer_element *sbale;
2363 struct zfcp_fsf_req *fsf_req;
2381 unsigned long lock_flags; 2364 unsigned long lock_flags;
2382 int retval = 0; 2365 int retval = 0;
2383 2366
@@ -2386,7 +2369,7 @@ zfcp_fsf_open_port(struct zfcp_erp_action *erp_action)
2386 FSF_QTCB_OPEN_PORT_WITH_DID, 2369 FSF_QTCB_OPEN_PORT_WITH_DID,
2387 ZFCP_WAIT_FOR_SBAL | ZFCP_REQ_AUTO_CLEANUP, 2370 ZFCP_WAIT_FOR_SBAL | ZFCP_REQ_AUTO_CLEANUP,
2388 erp_action->adapter->pool.fsf_req_erp, 2371 erp_action->adapter->pool.fsf_req_erp,
2389 &lock_flags, &(erp_action->fsf_req)); 2372 &lock_flags, &fsf_req);
2390 if (retval < 0) { 2373 if (retval < 0) {
2391 ZFCP_LOG_INFO("error: Could not create open port request " 2374 ZFCP_LOG_INFO("error: Could not create open port request "
2392 "for port 0x%016Lx on adapter %s.\n", 2375 "for port 0x%016Lx on adapter %s.\n",
@@ -2395,24 +2378,24 @@ zfcp_fsf_open_port(struct zfcp_erp_action *erp_action)
2395 goto out; 2378 goto out;
2396 } 2379 }
2397 2380
2398 sbale = zfcp_qdio_sbale_req(erp_action->fsf_req, 2381 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
2399 erp_action->fsf_req->sbal_curr, 0);
2400 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; 2382 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
2401 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; 2383 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
2402 2384
2403 erp_action->fsf_req->qtcb->bottom.support.d_id = erp_action->port->d_id; 2385 fsf_req->qtcb->bottom.support.d_id = erp_action->port->d_id;
2404 atomic_set_mask(ZFCP_STATUS_COMMON_OPENING, &erp_action->port->status); 2386 atomic_set_mask(ZFCP_STATUS_COMMON_OPENING, &erp_action->port->status);
2405 erp_action->fsf_req->data = (unsigned long) erp_action->port; 2387 fsf_req->data = (unsigned long) erp_action->port;
2406 erp_action->fsf_req->erp_action = erp_action; 2388 fsf_req->erp_action = erp_action;
2389 erp_action->fsf_req = fsf_req;
2407 2390
2408 /* start QDIO request for this FSF request */ 2391 zfcp_erp_start_timer(fsf_req);
2409 retval = zfcp_fsf_req_send(erp_action->fsf_req, &erp_action->timer); 2392 retval = zfcp_fsf_req_send(fsf_req);
2410 if (retval) { 2393 if (retval) {
2411 ZFCP_LOG_INFO("error: Could not send open port request for " 2394 ZFCP_LOG_INFO("error: Could not send open port request for "
2412 "port 0x%016Lx on adapter %s.\n", 2395 "port 0x%016Lx on adapter %s.\n",
2413 erp_action->port->wwpn, 2396 erp_action->port->wwpn,
2414 zfcp_get_busid_by_adapter(erp_action->adapter)); 2397 zfcp_get_busid_by_adapter(erp_action->adapter));
2415 zfcp_fsf_req_free(erp_action->fsf_req); 2398 zfcp_fsf_req_free(fsf_req);
2416 erp_action->fsf_req = NULL; 2399 erp_action->fsf_req = NULL;
2417 goto out; 2400 goto out;
2418 } 2401 }
@@ -2634,6 +2617,7 @@ int
2634zfcp_fsf_close_port(struct zfcp_erp_action *erp_action) 2617zfcp_fsf_close_port(struct zfcp_erp_action *erp_action)
2635{ 2618{
2636 volatile struct qdio_buffer_element *sbale; 2619 volatile struct qdio_buffer_element *sbale;
2620 struct zfcp_fsf_req *fsf_req;
2637 unsigned long lock_flags; 2621 unsigned long lock_flags;
2638 int retval = 0; 2622 int retval = 0;
2639 2623
@@ -2642,7 +2626,7 @@ zfcp_fsf_close_port(struct zfcp_erp_action *erp_action)
2642 FSF_QTCB_CLOSE_PORT, 2626 FSF_QTCB_CLOSE_PORT,
2643 ZFCP_WAIT_FOR_SBAL | ZFCP_REQ_AUTO_CLEANUP, 2627 ZFCP_WAIT_FOR_SBAL | ZFCP_REQ_AUTO_CLEANUP,
2644 erp_action->adapter->pool.fsf_req_erp, 2628 erp_action->adapter->pool.fsf_req_erp,
2645 &lock_flags, &(erp_action->fsf_req)); 2629 &lock_flags, &fsf_req);
2646 if (retval < 0) { 2630 if (retval < 0) {
2647 ZFCP_LOG_INFO("error: Could not create a close port request " 2631 ZFCP_LOG_INFO("error: Could not create a close port request "
2648 "for port 0x%016Lx on adapter %s.\n", 2632 "for port 0x%016Lx on adapter %s.\n",
@@ -2651,25 +2635,25 @@ zfcp_fsf_close_port(struct zfcp_erp_action *erp_action)
2651 goto out; 2635 goto out;
2652 } 2636 }
2653 2637
2654 sbale = zfcp_qdio_sbale_req(erp_action->fsf_req, 2638 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
2655 erp_action->fsf_req->sbal_curr, 0);
2656 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; 2639 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
2657 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; 2640 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
2658 2641
2659 atomic_set_mask(ZFCP_STATUS_COMMON_CLOSING, &erp_action->port->status); 2642 atomic_set_mask(ZFCP_STATUS_COMMON_CLOSING, &erp_action->port->status);
2660 erp_action->fsf_req->data = (unsigned long) erp_action->port; 2643 fsf_req->data = (unsigned long) erp_action->port;
2661 erp_action->fsf_req->erp_action = erp_action; 2644 fsf_req->erp_action = erp_action;
2662 erp_action->fsf_req->qtcb->header.port_handle = 2645 fsf_req->qtcb->header.port_handle = erp_action->port->handle;
2663 erp_action->port->handle; 2646 fsf_req->erp_action = erp_action;
2664 2647 erp_action->fsf_req = fsf_req;
2665 /* start QDIO request for this FSF request */ 2648
2666 retval = zfcp_fsf_req_send(erp_action->fsf_req, &erp_action->timer); 2649 zfcp_erp_start_timer(fsf_req);
2650 retval = zfcp_fsf_req_send(fsf_req);
2667 if (retval) { 2651 if (retval) {
2668 ZFCP_LOG_INFO("error: Could not send a close port request for " 2652 ZFCP_LOG_INFO("error: Could not send a close port request for "
2669 "port 0x%016Lx on adapter %s.\n", 2653 "port 0x%016Lx on adapter %s.\n",
2670 erp_action->port->wwpn, 2654 erp_action->port->wwpn,
2671 zfcp_get_busid_by_adapter(erp_action->adapter)); 2655 zfcp_get_busid_by_adapter(erp_action->adapter));
2672 zfcp_fsf_req_free(erp_action->fsf_req); 2656 zfcp_fsf_req_free(fsf_req);
2673 erp_action->fsf_req = NULL; 2657 erp_action->fsf_req = NULL;
2674 goto out; 2658 goto out;
2675 } 2659 }
@@ -2766,16 +2750,17 @@ zfcp_fsf_close_port_handler(struct zfcp_fsf_req *fsf_req)
2766int 2750int
2767zfcp_fsf_close_physical_port(struct zfcp_erp_action *erp_action) 2751zfcp_fsf_close_physical_port(struct zfcp_erp_action *erp_action)
2768{ 2752{
2769 int retval = 0;
2770 unsigned long lock_flags;
2771 volatile struct qdio_buffer_element *sbale; 2753 volatile struct qdio_buffer_element *sbale;
2754 struct zfcp_fsf_req *fsf_req;
2755 unsigned long lock_flags;
2756 int retval = 0;
2772 2757
2773 /* setup new FSF request */ 2758 /* setup new FSF request */
2774 retval = zfcp_fsf_req_create(erp_action->adapter, 2759 retval = zfcp_fsf_req_create(erp_action->adapter,
2775 FSF_QTCB_CLOSE_PHYSICAL_PORT, 2760 FSF_QTCB_CLOSE_PHYSICAL_PORT,
2776 ZFCP_WAIT_FOR_SBAL | ZFCP_REQ_AUTO_CLEANUP, 2761 ZFCP_WAIT_FOR_SBAL | ZFCP_REQ_AUTO_CLEANUP,
2777 erp_action->adapter->pool.fsf_req_erp, 2762 erp_action->adapter->pool.fsf_req_erp,
2778 &lock_flags, &erp_action->fsf_req); 2763 &lock_flags, &fsf_req);
2779 if (retval < 0) { 2764 if (retval < 0) {
2780 ZFCP_LOG_INFO("error: Could not create close physical port " 2765 ZFCP_LOG_INFO("error: Could not create close physical port "
2781 "request (adapter %s, port 0x%016Lx)\n", 2766 "request (adapter %s, port 0x%016Lx)\n",
@@ -2785,8 +2770,7 @@ zfcp_fsf_close_physical_port(struct zfcp_erp_action *erp_action)
2785 goto out; 2770 goto out;
2786 } 2771 }
2787 2772
2788 sbale = zfcp_qdio_sbale_req(erp_action->fsf_req, 2773 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
2789 erp_action->fsf_req->sbal_curr, 0);
2790 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; 2774 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
2791 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; 2775 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
2792 2776
@@ -2794,20 +2778,19 @@ zfcp_fsf_close_physical_port(struct zfcp_erp_action *erp_action)
2794 atomic_set_mask(ZFCP_STATUS_PORT_PHYS_CLOSING, 2778 atomic_set_mask(ZFCP_STATUS_PORT_PHYS_CLOSING,
2795 &erp_action->port->status); 2779 &erp_action->port->status);
2796 /* save a pointer to this port */ 2780 /* save a pointer to this port */
2797 erp_action->fsf_req->data = (unsigned long) erp_action->port; 2781 fsf_req->data = (unsigned long) erp_action->port;
2798 /* port to be closed */ 2782 fsf_req->qtcb->header.port_handle = erp_action->port->handle;
2799 erp_action->fsf_req->qtcb->header.port_handle = 2783 fsf_req->erp_action = erp_action;
2800 erp_action->port->handle; 2784 erp_action->fsf_req = fsf_req;
2801 erp_action->fsf_req->erp_action = erp_action; 2785
2802 2786 zfcp_erp_start_timer(fsf_req);
2803 /* start QDIO request for this FSF request */ 2787 retval = zfcp_fsf_req_send(fsf_req);
2804 retval = zfcp_fsf_req_send(erp_action->fsf_req, &erp_action->timer);
2805 if (retval) { 2788 if (retval) {
2806 ZFCP_LOG_INFO("error: Could not send close physical port " 2789 ZFCP_LOG_INFO("error: Could not send close physical port "
2807 "request (adapter %s, port 0x%016Lx)\n", 2790 "request (adapter %s, port 0x%016Lx)\n",
2808 zfcp_get_busid_by_adapter(erp_action->adapter), 2791 zfcp_get_busid_by_adapter(erp_action->adapter),
2809 erp_action->port->wwpn); 2792 erp_action->port->wwpn);
2810 zfcp_fsf_req_free(erp_action->fsf_req); 2793 zfcp_fsf_req_free(fsf_req);
2811 erp_action->fsf_req = NULL; 2794 erp_action->fsf_req = NULL;
2812 goto out; 2795 goto out;
2813 } 2796 }
@@ -2972,6 +2955,7 @@ int
2972zfcp_fsf_open_unit(struct zfcp_erp_action *erp_action) 2955zfcp_fsf_open_unit(struct zfcp_erp_action *erp_action)
2973{ 2956{
2974 volatile struct qdio_buffer_element *sbale; 2957 volatile struct qdio_buffer_element *sbale;
2958 struct zfcp_fsf_req *fsf_req;
2975 unsigned long lock_flags; 2959 unsigned long lock_flags;
2976 int retval = 0; 2960 int retval = 0;
2977 2961
@@ -2980,7 +2964,7 @@ zfcp_fsf_open_unit(struct zfcp_erp_action *erp_action)
2980 FSF_QTCB_OPEN_LUN, 2964 FSF_QTCB_OPEN_LUN,
2981 ZFCP_WAIT_FOR_SBAL | ZFCP_REQ_AUTO_CLEANUP, 2965 ZFCP_WAIT_FOR_SBAL | ZFCP_REQ_AUTO_CLEANUP,
2982 erp_action->adapter->pool.fsf_req_erp, 2966 erp_action->adapter->pool.fsf_req_erp,
2983 &lock_flags, &(erp_action->fsf_req)); 2967 &lock_flags, &fsf_req);
2984 if (retval < 0) { 2968 if (retval < 0) {
2985 ZFCP_LOG_INFO("error: Could not create open unit request for " 2969 ZFCP_LOG_INFO("error: Could not create open unit request for "
2986 "unit 0x%016Lx on port 0x%016Lx on adapter %s.\n", 2970 "unit 0x%016Lx on port 0x%016Lx on adapter %s.\n",
@@ -2990,24 +2974,22 @@ zfcp_fsf_open_unit(struct zfcp_erp_action *erp_action)
2990 goto out; 2974 goto out;
2991 } 2975 }
2992 2976
2993 sbale = zfcp_qdio_sbale_req(erp_action->fsf_req, 2977 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
2994 erp_action->fsf_req->sbal_curr, 0);
2995 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; 2978 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
2996 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; 2979 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
2997 2980
2998 erp_action->fsf_req->qtcb->header.port_handle = 2981 fsf_req->qtcb->header.port_handle = erp_action->port->handle;
2999 erp_action->port->handle; 2982 fsf_req->qtcb->bottom.support.fcp_lun = erp_action->unit->fcp_lun;
3000 erp_action->fsf_req->qtcb->bottom.support.fcp_lun =
3001 erp_action->unit->fcp_lun;
3002 if (!(erp_action->adapter->connection_features & FSF_FEATURE_NPIV_MODE)) 2983 if (!(erp_action->adapter->connection_features & FSF_FEATURE_NPIV_MODE))
3003 erp_action->fsf_req->qtcb->bottom.support.option = 2984 fsf_req->qtcb->bottom.support.option =
3004 FSF_OPEN_LUN_SUPPRESS_BOXING; 2985 FSF_OPEN_LUN_SUPPRESS_BOXING;
3005 atomic_set_mask(ZFCP_STATUS_COMMON_OPENING, &erp_action->unit->status); 2986 atomic_set_mask(ZFCP_STATUS_COMMON_OPENING, &erp_action->unit->status);
3006 erp_action->fsf_req->data = (unsigned long) erp_action->unit; 2987 fsf_req->data = (unsigned long) erp_action->unit;
3007 erp_action->fsf_req->erp_action = erp_action; 2988 fsf_req->erp_action = erp_action;
2989 erp_action->fsf_req = fsf_req;
3008 2990
3009 /* start QDIO request for this FSF request */ 2991 zfcp_erp_start_timer(fsf_req);
3010 retval = zfcp_fsf_req_send(erp_action->fsf_req, &erp_action->timer); 2992 retval = zfcp_fsf_req_send(erp_action->fsf_req);
3011 if (retval) { 2993 if (retval) {
3012 ZFCP_LOG_INFO("error: Could not send an open unit request " 2994 ZFCP_LOG_INFO("error: Could not send an open unit request "
3013 "on the adapter %s, port 0x%016Lx for " 2995 "on the adapter %s, port 0x%016Lx for "
@@ -3015,7 +2997,7 @@ zfcp_fsf_open_unit(struct zfcp_erp_action *erp_action)
3015 zfcp_get_busid_by_adapter(erp_action->adapter), 2997 zfcp_get_busid_by_adapter(erp_action->adapter),
3016 erp_action->port->wwpn, 2998 erp_action->port->wwpn,
3017 erp_action->unit->fcp_lun); 2999 erp_action->unit->fcp_lun);
3018 zfcp_fsf_req_free(erp_action->fsf_req); 3000 zfcp_fsf_req_free(fsf_req);
3019 erp_action->fsf_req = NULL; 3001 erp_action->fsf_req = NULL;
3020 goto out; 3002 goto out;
3021 } 3003 }
@@ -3308,6 +3290,7 @@ int
3308zfcp_fsf_close_unit(struct zfcp_erp_action *erp_action) 3290zfcp_fsf_close_unit(struct zfcp_erp_action *erp_action)
3309{ 3291{
3310 volatile struct qdio_buffer_element *sbale; 3292 volatile struct qdio_buffer_element *sbale;
3293 struct zfcp_fsf_req *fsf_req;
3311 unsigned long lock_flags; 3294 unsigned long lock_flags;
3312 int retval = 0; 3295 int retval = 0;
3313 3296
@@ -3316,7 +3299,7 @@ zfcp_fsf_close_unit(struct zfcp_erp_action *erp_action)
3316 FSF_QTCB_CLOSE_LUN, 3299 FSF_QTCB_CLOSE_LUN,
3317 ZFCP_WAIT_FOR_SBAL | ZFCP_REQ_AUTO_CLEANUP, 3300 ZFCP_WAIT_FOR_SBAL | ZFCP_REQ_AUTO_CLEANUP,
3318 erp_action->adapter->pool.fsf_req_erp, 3301 erp_action->adapter->pool.fsf_req_erp,
3319 &lock_flags, &(erp_action->fsf_req)); 3302 &lock_flags, &fsf_req);
3320 if (retval < 0) { 3303 if (retval < 0) {
3321 ZFCP_LOG_INFO("error: Could not create close unit request for " 3304 ZFCP_LOG_INFO("error: Could not create close unit request for "
3322 "unit 0x%016Lx on port 0x%016Lx on adapter %s.\n", 3305 "unit 0x%016Lx on port 0x%016Lx on adapter %s.\n",
@@ -3326,27 +3309,26 @@ zfcp_fsf_close_unit(struct zfcp_erp_action *erp_action)
3326 goto out; 3309 goto out;
3327 } 3310 }
3328 3311
3329 sbale = zfcp_qdio_sbale_req(erp_action->fsf_req, 3312 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
3330 erp_action->fsf_req->sbal_curr, 0);
3331 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; 3313 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
3332 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; 3314 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
3333 3315
3334 erp_action->fsf_req->qtcb->header.port_handle = 3316 fsf_req->qtcb->header.port_handle = erp_action->port->handle;
3335 erp_action->port->handle; 3317 fsf_req->qtcb->header.lun_handle = erp_action->unit->handle;
3336 erp_action->fsf_req->qtcb->header.lun_handle = erp_action->unit->handle;
3337 atomic_set_mask(ZFCP_STATUS_COMMON_CLOSING, &erp_action->unit->status); 3318 atomic_set_mask(ZFCP_STATUS_COMMON_CLOSING, &erp_action->unit->status);
3338 erp_action->fsf_req->data = (unsigned long) erp_action->unit; 3319 fsf_req->data = (unsigned long) erp_action->unit;
3339 erp_action->fsf_req->erp_action = erp_action; 3320 fsf_req->erp_action = erp_action;
3321 erp_action->fsf_req = fsf_req;
3340 3322
3341 /* start QDIO request for this FSF request */ 3323 zfcp_erp_start_timer(fsf_req);
3342 retval = zfcp_fsf_req_send(erp_action->fsf_req, &erp_action->timer); 3324 retval = zfcp_fsf_req_send(erp_action->fsf_req);
3343 if (retval) { 3325 if (retval) {
3344 ZFCP_LOG_INFO("error: Could not send a close unit request for " 3326 ZFCP_LOG_INFO("error: Could not send a close unit request for "
3345 "unit 0x%016Lx on port 0x%016Lx onadapter %s.\n", 3327 "unit 0x%016Lx on port 0x%016Lx onadapter %s.\n",
3346 erp_action->unit->fcp_lun, 3328 erp_action->unit->fcp_lun,
3347 erp_action->port->wwpn, 3329 erp_action->port->wwpn,
3348 zfcp_get_busid_by_adapter(erp_action->adapter)); 3330 zfcp_get_busid_by_adapter(erp_action->adapter));
3349 zfcp_fsf_req_free(erp_action->fsf_req); 3331 zfcp_fsf_req_free(fsf_req);
3350 erp_action->fsf_req = NULL; 3332 erp_action->fsf_req = NULL;
3351 goto out; 3333 goto out;
3352 } 3334 }
@@ -3499,7 +3481,7 @@ int
3499zfcp_fsf_send_fcp_command_task(struct zfcp_adapter *adapter, 3481zfcp_fsf_send_fcp_command_task(struct zfcp_adapter *adapter,
3500 struct zfcp_unit *unit, 3482 struct zfcp_unit *unit,
3501 struct scsi_cmnd * scsi_cmnd, 3483 struct scsi_cmnd * scsi_cmnd,
3502 struct timer_list *timer, int req_flags) 3484 int use_timer, int req_flags)
3503{ 3485{
3504 struct zfcp_fsf_req *fsf_req = NULL; 3486 struct zfcp_fsf_req *fsf_req = NULL;
3505 struct fcp_cmnd_iu *fcp_cmnd_iu; 3487 struct fcp_cmnd_iu *fcp_cmnd_iu;
@@ -3640,11 +3622,10 @@ zfcp_fsf_send_fcp_command_task(struct zfcp_adapter *adapter,
3640 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG, 3622 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
3641 (char *) scsi_cmnd->cmnd, scsi_cmnd->cmd_len); 3623 (char *) scsi_cmnd->cmnd, scsi_cmnd->cmd_len);
3642 3624
3643 /* 3625 if (use_timer)
3644 * start QDIO request for this FSF request 3626 zfcp_fsf_start_timer(fsf_req, ZFCP_FSF_REQUEST_TIMEOUT);
3645 * covered by an SBALE) 3627
3646 */ 3628 retval = zfcp_fsf_req_send(fsf_req);
3647 retval = zfcp_fsf_req_send(fsf_req, timer);
3648 if (unlikely(retval < 0)) { 3629 if (unlikely(retval < 0)) {
3649 ZFCP_LOG_INFO("error: Could not send FCP command request " 3630 ZFCP_LOG_INFO("error: Could not send FCP command request "
3650 "on adapter %s, port 0x%016Lx, unit 0x%016Lx\n", 3631 "on adapter %s, port 0x%016Lx, unit 0x%016Lx\n",
@@ -3729,11 +3710,9 @@ zfcp_fsf_send_fcp_command_task_management(struct zfcp_adapter *adapter,
3729 fcp_cmnd_iu->fcp_lun = unit->fcp_lun; 3710 fcp_cmnd_iu->fcp_lun = unit->fcp_lun;
3730 fcp_cmnd_iu->task_management_flags = tm_flags; 3711 fcp_cmnd_iu->task_management_flags = tm_flags;
3731 3712
3732 /* start QDIO request for this FSF request */ 3713 zfcp_fsf_start_timer(fsf_req, ZFCP_SCSI_ER_TIMEOUT);
3733 zfcp_fsf_start_scsi_er_timer(adapter); 3714 retval = zfcp_fsf_req_send(fsf_req);
3734 retval = zfcp_fsf_req_send(fsf_req, NULL);
3735 if (retval) { 3715 if (retval) {
3736 del_timer(&adapter->scsi_er_timer);
3737 ZFCP_LOG_INFO("error: Could not send an FCP-command (task " 3716 ZFCP_LOG_INFO("error: Could not send an FCP-command (task "
3738 "management) on adapter %s, port 0x%016Lx for " 3717 "management) on adapter %s, port 0x%016Lx for "
3739 "unit LUN 0x%016Lx\n", 3718 "unit LUN 0x%016Lx\n",
@@ -4237,7 +4216,6 @@ zfcp_fsf_send_fcp_command_task_management_handler(struct zfcp_fsf_req *fsf_req)
4237 char *fcp_rsp_info = zfcp_get_fcp_rsp_info_ptr(fcp_rsp_iu); 4216 char *fcp_rsp_info = zfcp_get_fcp_rsp_info_ptr(fcp_rsp_iu);
4238 struct zfcp_unit *unit = (struct zfcp_unit *) fsf_req->data; 4217 struct zfcp_unit *unit = (struct zfcp_unit *) fsf_req->data;
4239 4218
4240 del_timer(&fsf_req->adapter->scsi_er_timer);
4241 if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) { 4219 if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
4242 fsf_req->status |= ZFCP_STATUS_FSFREQ_TMFUNCFAILED; 4220 fsf_req->status |= ZFCP_STATUS_FSFREQ_TMFUNCFAILED;
4243 goto skip_fsfstatus; 4221 goto skip_fsfstatus;
@@ -4306,7 +4284,6 @@ zfcp_fsf_control_file(struct zfcp_adapter *adapter,
4306 struct zfcp_fsf_req *fsf_req; 4284 struct zfcp_fsf_req *fsf_req;
4307 struct fsf_qtcb_bottom_support *bottom; 4285 struct fsf_qtcb_bottom_support *bottom;
4308 volatile struct qdio_buffer_element *sbale; 4286 volatile struct qdio_buffer_element *sbale;
4309 struct timer_list *timer;
4310 unsigned long lock_flags; 4287 unsigned long lock_flags;
4311 int req_flags = 0; 4288 int req_flags = 0;
4312 int direction; 4289 int direction;
@@ -4338,12 +4315,6 @@ zfcp_fsf_control_file(struct zfcp_adapter *adapter,
4338 goto out; 4315 goto out;
4339 } 4316 }
4340 4317
4341 timer = kmalloc(sizeof(struct timer_list), GFP_KERNEL);
4342 if (!timer) {
4343 retval = -ENOMEM;
4344 goto out;
4345 }
4346
4347 retval = zfcp_fsf_req_create(adapter, fsf_command, req_flags, 4318 retval = zfcp_fsf_req_create(adapter, fsf_command, req_flags,
4348 NULL, &lock_flags, &fsf_req); 4319 NULL, &lock_flags, &fsf_req);
4349 if (retval < 0) { 4320 if (retval < 0) {
@@ -4378,12 +4349,8 @@ zfcp_fsf_control_file(struct zfcp_adapter *adapter,
4378 } else 4349 } else
4379 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; 4350 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
4380 4351
4381 init_timer(timer); 4352 zfcp_fsf_start_timer(fsf_req, ZFCP_FSF_REQUEST_TIMEOUT);
4382 timer->function = zfcp_fsf_request_timeout_handler; 4353 retval = zfcp_fsf_req_send(fsf_req);
4383 timer->data = (unsigned long) adapter;
4384 timer->expires = ZFCP_FSF_REQUEST_TIMEOUT;
4385
4386 retval = zfcp_fsf_req_send(fsf_req, timer);
4387 if (retval < 0) { 4354 if (retval < 0) {
4388 ZFCP_LOG_INFO("initiation of cfdc up/download failed" 4355 ZFCP_LOG_INFO("initiation of cfdc up/download failed"
4389 "(adapter %s)\n", 4356 "(adapter %s)\n",
@@ -4403,15 +4370,12 @@ zfcp_fsf_control_file(struct zfcp_adapter *adapter,
4403 fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED); 4370 fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED);
4404 4371
4405 *fsf_req_ptr = fsf_req; 4372 *fsf_req_ptr = fsf_req;
4406 del_timer_sync(timer); 4373 goto out;
4407 goto free_timer;
4408 4374
4409 free_fsf_req: 4375 free_fsf_req:
4410 zfcp_fsf_req_free(fsf_req); 4376 zfcp_fsf_req_free(fsf_req);
4411 unlock_queue_lock: 4377 unlock_queue_lock:
4412 write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags); 4378 write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags);
4413 free_timer:
4414 kfree(timer);
4415 out: 4379 out:
4416 return retval; 4380 return retval;
4417} 4381}
@@ -4688,7 +4652,8 @@ zfcp_fsf_req_create(struct zfcp_adapter *adapter, u32 fsf_cmd, int req_flags,
4688 adapter->req_no++; 4652 adapter->req_no++;
4689 fsf_req->req_id = adapter->req_no++; 4653 fsf_req->req_id = adapter->req_no++;
4690 4654
4691 zfcp_fsf_req_qtcb_init(fsf_req); 4655 init_timer(&fsf_req->timer);
4656 zfcp_fsf_req_qtcb_init(fsf_req);
4692 4657
4693 /* initialize waitqueue which may be used to wait on 4658 /* initialize waitqueue which may be used to wait on
4694 this request completion */ 4659 this request completion */
@@ -4758,8 +4723,7 @@ zfcp_fsf_req_create(struct zfcp_adapter *adapter, u32 fsf_cmd, int req_flags,
4758 * returns: 0 - request transfer succesfully started 4723 * returns: 0 - request transfer succesfully started
4759 * !0 - start of request transfer failed 4724 * !0 - start of request transfer failed
4760 */ 4725 */
4761static int 4726static int zfcp_fsf_req_send(struct zfcp_fsf_req *fsf_req)
4762zfcp_fsf_req_send(struct zfcp_fsf_req *fsf_req, struct timer_list *timer)
4763{ 4727{
4764 struct zfcp_adapter *adapter; 4728 struct zfcp_adapter *adapter;
4765 struct zfcp_qdio_queue *req_queue; 4729 struct zfcp_qdio_queue *req_queue;
@@ -4787,12 +4751,6 @@ zfcp_fsf_req_send(struct zfcp_fsf_req *fsf_req, struct timer_list *timer)
4787 4751
4788 inc_seq_no = (fsf_req->qtcb != NULL); 4752 inc_seq_no = (fsf_req->qtcb != NULL);
4789 4753
4790 /* figure out expiration time of timeout and start timeout */
4791 if (unlikely(timer)) {
4792 timer->expires += jiffies;
4793 add_timer(timer);
4794 }
4795
4796 ZFCP_LOG_TRACE("request queue of adapter %s: " 4754 ZFCP_LOG_TRACE("request queue of adapter %s: "
4797 "next free SBAL is %i, %i free SBALs\n", 4755 "next free SBAL is %i, %i free SBALs\n",
4798 zfcp_get_busid_by_adapter(adapter), 4756 zfcp_get_busid_by_adapter(adapter),
@@ -4829,12 +4787,7 @@ zfcp_fsf_req_send(struct zfcp_fsf_req *fsf_req, struct timer_list *timer)
4829 if (unlikely(retval)) { 4787 if (unlikely(retval)) {
4830 /* Queues are down..... */ 4788 /* Queues are down..... */
4831 retval = -EIO; 4789 retval = -EIO;
4832 /* 4790 del_timer(&fsf_req->timer);
4833 * FIXME(potential race):
4834 * timer might be expired (absolutely unlikely)
4835 */
4836 if (timer)
4837 del_timer(timer);
4838 spin_lock(&adapter->req_list_lock); 4791 spin_lock(&adapter->req_list_lock);
4839 zfcp_reqlist_remove(adapter, fsf_req->req_id); 4792 zfcp_reqlist_remove(adapter, fsf_req->req_id);
4840 spin_unlock(&adapter->req_list_lock); 4793 spin_unlock(&adapter->req_list_lock);
diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c
index 043ed7c0a7ed..753bb9b2fe74 100644
--- a/drivers/s390/scsi/zfcp_scsi.c
+++ b/drivers/s390/scsi/zfcp_scsi.c
@@ -231,7 +231,7 @@ zfcp_scsi_command_fail(struct scsi_cmnd *scpnt, int result)
231 */ 231 */
232int 232int
233zfcp_scsi_command_async(struct zfcp_adapter *adapter, struct zfcp_unit *unit, 233zfcp_scsi_command_async(struct zfcp_adapter *adapter, struct zfcp_unit *unit,
234 struct scsi_cmnd *scpnt, struct timer_list *timer) 234 struct scsi_cmnd *scpnt, int use_timer)
235{ 235{
236 int tmp; 236 int tmp;
237 int retval; 237 int retval;
@@ -267,7 +267,7 @@ zfcp_scsi_command_async(struct zfcp_adapter *adapter, struct zfcp_unit *unit,
267 goto out; 267 goto out;
268 } 268 }
269 269
270 tmp = zfcp_fsf_send_fcp_command_task(adapter, unit, scpnt, timer, 270 tmp = zfcp_fsf_send_fcp_command_task(adapter, unit, scpnt, use_timer,
271 ZFCP_REQ_AUTO_CLEANUP); 271 ZFCP_REQ_AUTO_CLEANUP);
272 272
273 if (unlikely(tmp < 0)) { 273 if (unlikely(tmp < 0)) {
@@ -291,21 +291,22 @@ zfcp_scsi_command_sync_handler(struct scsi_cmnd *scpnt)
291 * zfcp_scsi_command_sync - send a SCSI command and wait for completion 291 * zfcp_scsi_command_sync - send a SCSI command and wait for completion
292 * @unit: unit where command is sent to 292 * @unit: unit where command is sent to
293 * @scpnt: scsi command to be sent 293 * @scpnt: scsi command to be sent
294 * @timer: timer to be started if request is successfully initiated 294 * @use_timer: indicates whether timer should be setup or not
295 * Return: 0 295 * Return: 0
296 * 296 *
297 * Errors are indicated in scpnt->result 297 * Errors are indicated in scpnt->result
298 */ 298 */
299int 299int
300zfcp_scsi_command_sync(struct zfcp_unit *unit, struct scsi_cmnd *scpnt, 300zfcp_scsi_command_sync(struct zfcp_unit *unit, struct scsi_cmnd *scpnt,
301 struct timer_list *timer) 301 int use_timer)
302{ 302{
303 int ret; 303 int ret;
304 DECLARE_COMPLETION(wait); 304 DECLARE_COMPLETION(wait);
305 305
306 scpnt->SCp.ptr = (void *) &wait; /* silent re-use */ 306 scpnt->SCp.ptr = (void *) &wait; /* silent re-use */
307 scpnt->scsi_done = zfcp_scsi_command_sync_handler; 307 scpnt->scsi_done = zfcp_scsi_command_sync_handler;
308 ret = zfcp_scsi_command_async(unit->port->adapter, unit, scpnt, timer); 308 ret = zfcp_scsi_command_async(unit->port->adapter, unit, scpnt,
309 use_timer);
309 if (ret == 0) 310 if (ret == 0)
310 wait_for_completion(&wait); 311 wait_for_completion(&wait);
311 312
@@ -341,7 +342,7 @@ zfcp_scsi_queuecommand(struct scsi_cmnd *scpnt,
341 adapter = (struct zfcp_adapter *) scpnt->device->host->hostdata[0]; 342 adapter = (struct zfcp_adapter *) scpnt->device->host->hostdata[0];
342 unit = (struct zfcp_unit *) scpnt->device->hostdata; 343 unit = (struct zfcp_unit *) scpnt->device->hostdata;
343 344
344 return zfcp_scsi_command_async(adapter, unit, scpnt, NULL); 345 return zfcp_scsi_command_async(adapter, unit, scpnt, 0);
345} 346}
346 347
347static struct zfcp_unit * 348static struct zfcp_unit *
@@ -538,8 +539,6 @@ zfcp_task_management_function(struct zfcp_unit *unit, u8 tm_flags,
538 539
539/** 540/**
540 * zfcp_scsi_eh_host_reset_handler - handler for host and bus reset 541 * zfcp_scsi_eh_host_reset_handler - handler for host and bus reset
541 *
542 * If ERP is already running it will be stopped.
543 */ 542 */
544int zfcp_scsi_eh_host_reset_handler(struct scsi_cmnd *scpnt) 543int zfcp_scsi_eh_host_reset_handler(struct scsi_cmnd *scpnt)
545{ 544{
@@ -638,16 +637,6 @@ zfcp_adapter_scsi_unregister(struct zfcp_adapter *adapter)
638 return; 637 return;
639} 638}
640 639
641
642void
643zfcp_fsf_start_scsi_er_timer(struct zfcp_adapter *adapter)
644{
645 adapter->scsi_er_timer.function = zfcp_fsf_scsi_er_timeout_handler;
646 adapter->scsi_er_timer.data = (unsigned long) adapter;
647 adapter->scsi_er_timer.expires = jiffies + ZFCP_SCSI_ER_TIMEOUT;
648 add_timer(&adapter->scsi_er_timer);
649}
650
651/* 640/*
652 * Support functions for FC transport class 641 * Support functions for FC transport class
653 */ 642 */