[SCSI] zfcp: fix adapter initialization

Fixed various problems in opening sequence of adapters which was previously
changed with NPIV support:
o corrected handling when exchange port data function is not supported,
otherwise adapters on z900 cannot be opened anymore
o corrected setup of timer for exchange port data if called from error
recovery
o corrected check of return code of exchange config data

Signed-off-by: Andreas Herrmann <aherrman@de.ibm.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>

authored by Andreas Herrmann and committed by James Bottomley 2448c459 c48a29d0

+64 -85
+32 -57
drivers/s390/scsi/zfcp_erp.c
··· 2243 2243 return retval; 2244 2244 } 2245 2245 2246 - /* 2247 - * function: zfcp_fsf_init 2248 - * 2249 - * purpose: initializes FSF operation for the specified adapter 2250 - * 2251 - * returns: 0 - succesful initialization of FSF operation 2252 - * !0 - failed to initialize FSF operation 2253 - */ 2254 2246 static int 2255 2247 zfcp_erp_adapter_strategy_open_fsf(struct zfcp_erp_action *erp_action) 2256 2248 { 2257 - int xconfig, xport; 2249 + int retval; 2258 2250 2259 - if (atomic_test_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED, 2260 - &erp_action->adapter->status)) { 2251 + if ((atomic_test_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED, 2252 + &erp_action->adapter->status)) && 2253 + (erp_action->adapter->adapter_features & 2254 + FSF_FEATURE_HBAAPI_MANAGEMENT)) { 2261 2255 zfcp_erp_adapter_strategy_open_fsf_xport(erp_action); 2262 2256 atomic_set(&erp_action->adapter->erp_counter, 0); 2263 2257 return ZFCP_ERP_FAILED; 2264 2258 } 2265 2259 2266 - xconfig = zfcp_erp_adapter_strategy_open_fsf_xconfig(erp_action); 2267 - xport = zfcp_erp_adapter_strategy_open_fsf_xport(erp_action); 2268 - if ((xconfig == ZFCP_ERP_FAILED) || (xport == ZFCP_ERP_FAILED)) 2260 + retval = zfcp_erp_adapter_strategy_open_fsf_xconfig(erp_action); 2261 + if (retval == ZFCP_ERP_FAILED) 2262 + return ZFCP_ERP_FAILED; 2263 + 2264 + retval = zfcp_erp_adapter_strategy_open_fsf_xport(erp_action); 2265 + if (retval == ZFCP_ERP_FAILED) 2269 2266 return ZFCP_ERP_FAILED; 2270 2267 2271 2268 return zfcp_erp_adapter_strategy_open_fsf_statusread(erp_action); ··· 2351 2354 static int 2352 2355 zfcp_erp_adapter_strategy_open_fsf_xport(struct zfcp_erp_action *erp_action) 2353 2356 { 2354 - int retval = ZFCP_ERP_SUCCEEDED; 2357 + int ret; 2355 2358 int retries; 2356 2359 int sleep; 2357 2360 struct zfcp_adapter *adapter = erp_action->adapter; 2358 2361 2359 2362 atomic_clear_mask(ZFCP_STATUS_ADAPTER_XPORT_OK, &adapter->status); 2360 2363 2361 - for (retries = 0; ; retries++) { 2362 - ZFCP_LOG_DEBUG("Doing exchange port data\n"); 2364 + retries = 0; 2365 + do { 2366 + write_lock(&adapter->erp_lock); 2363 2367 zfcp_erp_action_to_running(erp_action); 2368 + write_unlock(&adapter->erp_lock); 2364 2369 zfcp_erp_timeout_init(erp_action); 2365 - if (zfcp_fsf_exchange_port_data(erp_action, adapter, NULL)) { 2366 - retval = ZFCP_ERP_FAILED; 2367 - debug_text_event(adapter->erp_dbf, 5, "a_fstx_xf"); 2368 - ZFCP_LOG_INFO("error: initiation of exchange of " 2369 - "port data failed for adapter %s\n", 2370 - zfcp_get_busid_by_adapter(adapter)); 2371 - break; 2370 + ret = zfcp_fsf_exchange_port_data(erp_action, adapter, NULL); 2371 + if (ret == -EOPNOTSUPP) { 2372 + debug_text_event(adapter->erp_dbf, 3, "a_xport_notsupp"); 2373 + return ZFCP_ERP_SUCCEEDED; 2374 + } else if (ret) { 2375 + debug_text_event(adapter->erp_dbf, 3, "a_xport_failed"); 2376 + return ZFCP_ERP_FAILED; 2372 2377 } 2373 - debug_text_event(adapter->erp_dbf, 6, "a_fstx_xok"); 2374 - ZFCP_LOG_DEBUG("Xchange underway\n"); 2378 + debug_text_event(adapter->erp_dbf, 6, "a_xport_ok"); 2375 2379 2376 - /* 2377 - * Why this works: 2378 - * Both the normal completion handler as well as the timeout 2379 - * handler will do an 'up' when the 'exchange port data' 2380 - * request completes or times out. Thus, the signal to go on 2381 - * won't be lost utilizing this semaphore. 2382 - * Furthermore, this 'adapter_reopen' action is 2383 - * guaranteed to be the only action being there (highest action 2384 - * which prevents other actions from being created). 2385 - * Resulting from that, the wake signal recognized here 2386 - * _must_ be the one belonging to the 'exchange port 2387 - * data' request. 2388 - */ 2389 2380 down(&adapter->erp_ready_sem); 2390 2381 if (erp_action->status & ZFCP_STATUS_ERP_TIMEDOUT) { 2391 2382 ZFCP_LOG_INFO("error: exchange of port data " ··· 2381 2396 zfcp_get_busid_by_adapter(adapter)); 2382 2397 break; 2383 2398 } 2384 - 2385 2399 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED, 2386 2400 &adapter->status)) 2387 2401 break; 2388 2402 2389 - ZFCP_LOG_DEBUG("host connection still initialising... " 2390 - "waiting and retrying...\n"); 2391 - /* sleep a little bit before retry */ 2392 - sleep = retries < ZFCP_EXCHANGE_PORT_DATA_SHORT_RETRIES ? 2393 - ZFCP_EXCHANGE_PORT_DATA_SHORT_SLEEP : 2394 - ZFCP_EXCHANGE_PORT_DATA_LONG_SLEEP; 2395 - msleep(jiffies_to_msecs(sleep)); 2396 - } 2403 + if (retries < ZFCP_EXCHANGE_PORT_DATA_SHORT_RETRIES) { 2404 + sleep = ZFCP_EXCHANGE_PORT_DATA_SHORT_SLEEP; 2405 + retries++; 2406 + } else 2407 + sleep = ZFCP_EXCHANGE_PORT_DATA_LONG_SLEEP; 2408 + schedule_timeout(sleep); 2409 + } while (1); 2397 2410 2398 - if (atomic_test_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED, 2399 - &adapter->status)) { 2400 - ZFCP_LOG_INFO("error: exchange of port data for " 2401 - "adapter %s failed\n", 2402 - zfcp_get_busid_by_adapter(adapter)); 2403 - retval = ZFCP_ERP_FAILED; 2404 - } 2405 - 2406 - return retval; 2411 + return ZFCP_ERP_SUCCEEDED; 2407 2412 } 2408 2413 2409 2414 /*
+32 -28
drivers/s390/scsi/zfcp_fsf.c
··· 2191 2191 return -EOPNOTSUPP; 2192 2192 } 2193 2193 2194 - timer = kmalloc(sizeof(struct timer_list), GFP_KERNEL); 2195 - if (!timer) 2196 - return -ENOMEM; 2197 - 2198 2194 /* setup new FSF request */ 2199 2195 retval = zfcp_fsf_req_create(adapter, FSF_QTCB_EXCHANGE_PORT_DATA, 2200 - 0, 0, &lock_flags, &fsf_req); 2196 + erp_action ? ZFCP_REQ_AUTO_CLEANUP : 0, 2197 + 0, &lock_flags, &fsf_req); 2201 2198 if (retval < 0) { 2202 2199 ZFCP_LOG_INFO("error: Out of resources. Could not create an " 2203 2200 "exchange port data request for" ··· 2202 2205 zfcp_get_busid_by_adapter(adapter)); 2203 2206 write_unlock_irqrestore(&adapter->request_queue.queue_lock, 2204 2207 lock_flags); 2205 - goto out; 2206 - } 2207 - 2208 - if (erp_action) { 2209 - erp_action->fsf_req = fsf_req; 2210 - fsf_req->erp_action = erp_action; 2208 + return retval; 2211 2209 } 2212 2210 2213 2211 if (data) 2214 - fsf_req->data = (unsigned long) data; 2212 + fsf_req->data = (unsigned long) data; 2215 2213 2216 2214 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0); 2217 2215 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; 2218 2216 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; 2219 2217 2220 - init_timer(timer); 2221 - timer->function = zfcp_fsf_request_timeout_handler; 2222 - timer->data = (unsigned long) adapter; 2223 - timer->expires = ZFCP_FSF_REQUEST_TIMEOUT; 2218 + if (erp_action) { 2219 + erp_action->fsf_req = fsf_req; 2220 + fsf_req->erp_action = erp_action; 2221 + timer = &erp_action->timer; 2222 + } else { 2223 + timer = kmalloc(sizeof(struct timer_list), GFP_ATOMIC); 2224 + if (!timer) { 2225 + write_unlock_irqrestore(&adapter->request_queue.queue_lock, 2226 + lock_flags); 2227 + zfcp_fsf_req_free(fsf_req); 2228 + return -ENOMEM; 2229 + } 2230 + init_timer(timer); 2231 + timer->function = zfcp_fsf_request_timeout_handler; 2232 + timer->data = (unsigned long) adapter; 2233 + timer->expires = ZFCP_FSF_REQUEST_TIMEOUT; 2234 + } 2224 2235 2225 2236 retval = zfcp_fsf_req_send(fsf_req, timer); 2226 2237 if (retval) { ··· 2238 2233 zfcp_fsf_req_free(fsf_req); 2239 2234 if (erp_action) 2240 2235 erp_action->fsf_req = NULL; 2236 + else 2237 + kfree(timer); 2241 2238 write_unlock_irqrestore(&adapter->request_queue.queue_lock, 2242 2239 lock_flags); 2243 - goto out; 2240 + return retval; 2244 2241 } 2245 2242 2246 - ZFCP_LOG_DEBUG("Exchange Port Data request initiated (adapter %s)\n", 2247 - zfcp_get_busid_by_adapter(adapter)); 2243 + write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags); 2248 2244 2249 - write_unlock_irqrestore(&adapter->request_queue.queue_lock, 2250 - lock_flags); 2251 - 2252 - wait_event(fsf_req->completion_wq, 2253 - fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED); 2254 - del_timer_sync(timer); 2255 - zfcp_fsf_req_free(fsf_req); 2256 - out: 2257 - kfree(timer); 2245 + if (!erp_action) { 2246 + wait_event(fsf_req->completion_wq, 2247 + fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED); 2248 + del_timer_sync(timer); 2249 + zfcp_fsf_req_free(fsf_req); 2250 + kfree(timer); 2251 + } 2258 2252 return retval; 2259 2253 } 2260 2254