aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/message/fusion/mptbase.c64
-rw-r--r--drivers/message/fusion/mptbase.h3
-rw-r--r--drivers/message/fusion/mptscsih.c10
-rw-r--r--drivers/s390/scsi/zfcp_aux.c14
-rw-r--r--drivers/s390/scsi/zfcp_dbf.c4
-rw-r--r--drivers/s390/scsi/zfcp_erp.c94
-rw-r--r--drivers/s390/scsi/zfcp_fsf.c110
-rw-r--r--drivers/s390/scsi/zfcp_scsi.c2
-rw-r--r--drivers/scsi/aacraid/linit.c2
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_osm.c2
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_osm.c2
-rw-r--r--drivers/scsi/scsi_transport_spi.c28
-rw-r--r--drivers/scsi/sg.c6
-rw-r--r--drivers/scsi/st.c3
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_glue.c5
15 files changed, 216 insertions, 133 deletions
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 65c2ec5c421b..4262a22adc22 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -1118,6 +1118,65 @@ mpt_verify_adapter(int iocid, MPT_ADAPTER **iocpp)
1118 return -1; 1118 return -1;
1119} 1119}
1120 1120
1121int
1122mpt_alt_ioc_wait(MPT_ADAPTER *ioc)
1123{
1124 int loop_count = 30 * 4; /* Wait 30 seconds */
1125 int status = -1; /* -1 means failed to get board READY */
1126
1127 do {
1128 spin_lock(&ioc->initializing_hba_lock);
1129 if (ioc->initializing_hba_lock_flag == 0) {
1130 ioc->initializing_hba_lock_flag=1;
1131 spin_unlock(&ioc->initializing_hba_lock);
1132 status = 0;
1133 break;
1134 }
1135 spin_unlock(&ioc->initializing_hba_lock);
1136 set_current_state(TASK_INTERRUPTIBLE);
1137 schedule_timeout(HZ/4);
1138 } while (--loop_count);
1139
1140 return status;
1141}
1142
1143/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1144/*
1145 * mpt_bringup_adapter - This is a wrapper function for mpt_do_ioc_recovery
1146 * @ioc: Pointer to MPT adapter structure
1147 * @sleepFlag: Use schedule if CAN_SLEEP else use udelay.
1148 *
1149 * This routine performs all the steps necessary to bring the IOC
1150 * to a OPERATIONAL state.
1151 *
1152 * Special Note: This function was added with spin lock's so as to allow
1153 * the dv(domain validation) work thread to succeed on the other channel
1154 * that maybe occuring at the same time when this function is called.
1155 * Without this lock, the dv would fail when message frames were
1156 * requested during hba bringup on the alternate ioc.
1157 */
1158static int
1159mpt_bringup_adapter(MPT_ADAPTER *ioc, int sleepFlag)
1160{
1161 int r;
1162
1163 if(ioc->alt_ioc) {
1164 if((r=mpt_alt_ioc_wait(ioc->alt_ioc)!=0))
1165 return r;
1166 }
1167
1168 r = mpt_do_ioc_recovery(ioc, MPT_HOSTEVENT_IOC_BRINGUP,
1169 CAN_SLEEP);
1170
1171 if(ioc->alt_ioc) {
1172 spin_lock(&ioc->alt_ioc->initializing_hba_lock);
1173 ioc->alt_ioc->initializing_hba_lock_flag=0;
1174 spin_unlock(&ioc->alt_ioc->initializing_hba_lock);
1175 }
1176
1177return r;
1178}
1179
1121/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1180/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1122/* 1181/*
1123 * mpt_attach - Install a PCI intelligent MPT adapter. 1182 * mpt_attach - Install a PCI intelligent MPT adapter.
@@ -1186,6 +1245,7 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1186 ioc->pcidev = pdev; 1245 ioc->pcidev = pdev;
1187 ioc->diagPending = 0; 1246 ioc->diagPending = 0;
1188 spin_lock_init(&ioc->diagLock); 1247 spin_lock_init(&ioc->diagLock);
1248 spin_lock_init(&ioc->initializing_hba_lock);
1189 1249
1190 /* Initialize the event logging. 1250 /* Initialize the event logging.
1191 */ 1251 */
@@ -1408,8 +1468,7 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1408 */ 1468 */
1409 mpt_detect_bound_ports(ioc, pdev); 1469 mpt_detect_bound_ports(ioc, pdev);
1410 1470
1411 if ((r = mpt_do_ioc_recovery(ioc, 1471 if ((r = mpt_bringup_adapter(ioc, CAN_SLEEP)) != 0){
1412 MPT_HOSTEVENT_IOC_BRINGUP, CAN_SLEEP)) != 0) {
1413 printk(KERN_WARNING MYNAM 1472 printk(KERN_WARNING MYNAM
1414 ": WARNING - %s did not initialize properly! (%d)\n", 1473 ": WARNING - %s did not initialize properly! (%d)\n",
1415 ioc->name, r); 1474 ioc->name, r);
@@ -6298,6 +6357,7 @@ EXPORT_SYMBOL(mpt_read_ioc_pg_3);
6298EXPORT_SYMBOL(mpt_alloc_fw_memory); 6357EXPORT_SYMBOL(mpt_alloc_fw_memory);
6299EXPORT_SYMBOL(mpt_free_fw_memory); 6358EXPORT_SYMBOL(mpt_free_fw_memory);
6300EXPORT_SYMBOL(mptbase_sas_persist_operation); 6359EXPORT_SYMBOL(mptbase_sas_persist_operation);
6360EXPORT_SYMBOL(mpt_alt_ioc_wait);
6301 6361
6302 6362
6303/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 6363/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
diff --git a/drivers/message/fusion/mptbase.h b/drivers/message/fusion/mptbase.h
index 5f5b3fb5b4d7..bac8eb4186d2 100644
--- a/drivers/message/fusion/mptbase.h
+++ b/drivers/message/fusion/mptbase.h
@@ -611,6 +611,8 @@ typedef struct _MPT_ADAPTER
611 int DoneCtx; 611 int DoneCtx;
612 int TaskCtx; 612 int TaskCtx;
613 int InternalCtx; 613 int InternalCtx;
614 spinlock_t initializing_hba_lock;
615 int initializing_hba_lock_flag;
614 struct list_head list; 616 struct list_head list;
615 struct net_device *netdev; 617 struct net_device *netdev;
616 struct list_head sas_topology; 618 struct list_head sas_topology;
@@ -1001,6 +1003,7 @@ extern void mpt_free_fw_memory(MPT_ADAPTER *ioc);
1001extern int mpt_findImVolumes(MPT_ADAPTER *ioc); 1003extern int mpt_findImVolumes(MPT_ADAPTER *ioc);
1002extern int mpt_read_ioc_pg_3(MPT_ADAPTER *ioc); 1004extern int mpt_read_ioc_pg_3(MPT_ADAPTER *ioc);
1003extern int mptbase_sas_persist_operation(MPT_ADAPTER *ioc, u8 persist_opcode); 1005extern int mptbase_sas_persist_operation(MPT_ADAPTER *ioc, u8 persist_opcode);
1006extern int mpt_alt_ioc_wait(MPT_ADAPTER *ioc);
1004 1007
1005/* 1008/*
1006 * Public data decl's... 1009 * Public data decl's...
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index 4330ed0cedaa..b7b9846ff3fd 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -4162,6 +4162,12 @@ mptscsih_domainValidation(void *arg)
4162 } 4162 }
4163 } 4163 }
4164 4164
4165 if(mpt_alt_ioc_wait(hd->ioc)!=0) {
4166 ddvprintk((MYIOC_s_WARN_FMT "alt_ioc busy!\n",
4167 hd->ioc->name));
4168 continue;
4169 }
4170
4165 if (mptscsih_doDv(hd, 0, id) == 1) { 4171 if (mptscsih_doDv(hd, 0, id) == 1) {
4166 /* Untagged device was busy, try again 4172 /* Untagged device was busy, try again
4167 */ 4173 */
@@ -4173,6 +4179,10 @@ mptscsih_domainValidation(void *arg)
4173 hd->ioc->spi_data.dvStatus[id] &= ~(MPT_SCSICFG_DV_NOT_DONE | MPT_SCSICFG_DV_PENDING); 4179 hd->ioc->spi_data.dvStatus[id] &= ~(MPT_SCSICFG_DV_NOT_DONE | MPT_SCSICFG_DV_PENDING);
4174 } 4180 }
4175 4181
4182 spin_lock(&hd->ioc->initializing_hba_lock);
4183 hd->ioc->initializing_hba_lock_flag=0;
4184 spin_unlock(&hd->ioc->initializing_hba_lock);
4185
4176 if (isPhysDisk) { 4186 if (isPhysDisk) {
4177 for (ii=0; ii < MPT_MAX_SCSI_DEVICES; ii++) { 4187 for (ii=0; ii < MPT_MAX_SCSI_DEVICES; ii++) {
4178 if (hd->ioc->raid_data.isRaid & (1 << ii)) { 4188 if (hd->ioc->raid_data.isRaid & (1 << ii)) {
diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c
index c218b5c944a6..5e84c5aa7779 100644
--- a/drivers/s390/scsi/zfcp_aux.c
+++ b/drivers/s390/scsi/zfcp_aux.c
@@ -996,6 +996,20 @@ zfcp_adapter_enqueue(struct ccw_device *ccw_device)
996 spin_lock_init(&adapter->fsf_req_list_lock); 996 spin_lock_init(&adapter->fsf_req_list_lock);
997 INIT_LIST_HEAD(&adapter->fsf_req_list_head); 997 INIT_LIST_HEAD(&adapter->fsf_req_list_head);
998 998
999 /* initialize debug locks */
1000
1001 spin_lock_init(&adapter->erp_dbf_lock);
1002 spin_lock_init(&adapter->hba_dbf_lock);
1003 spin_lock_init(&adapter->san_dbf_lock);
1004 spin_lock_init(&adapter->scsi_dbf_lock);
1005
1006 /* initialize error recovery stuff */
1007
1008 rwlock_init(&adapter->erp_lock);
1009 sema_init(&adapter->erp_ready_sem, 0);
1010 INIT_LIST_HEAD(&adapter->erp_ready_head);
1011 INIT_LIST_HEAD(&adapter->erp_running_head);
1012
999 /* initialize abort lock */ 1013 /* initialize abort lock */
1000 rwlock_init(&adapter->abort_lock); 1014 rwlock_init(&adapter->abort_lock);
1001 1015
diff --git a/drivers/s390/scsi/zfcp_dbf.c b/drivers/s390/scsi/zfcp_dbf.c
index 826fb3b00605..95599719f8ab 100644
--- a/drivers/s390/scsi/zfcp_dbf.c
+++ b/drivers/s390/scsi/zfcp_dbf.c
@@ -926,7 +926,6 @@ int zfcp_adapter_debug_register(struct zfcp_adapter *adapter)
926 char dbf_name[DEBUG_MAX_NAME_LEN]; 926 char dbf_name[DEBUG_MAX_NAME_LEN];
927 927
928 /* debug feature area which records recovery activity */ 928 /* debug feature area which records recovery activity */
929 spin_lock_init(&adapter->erp_dbf_lock);
930 sprintf(dbf_name, "zfcp_%s_erp", zfcp_get_busid_by_adapter(adapter)); 929 sprintf(dbf_name, "zfcp_%s_erp", zfcp_get_busid_by_adapter(adapter));
931 adapter->erp_dbf = debug_register(dbf_name, dbfsize, 2, 930 adapter->erp_dbf = debug_register(dbf_name, dbfsize, 2,
932 sizeof(struct zfcp_erp_dbf_record)); 931 sizeof(struct zfcp_erp_dbf_record));
@@ -936,7 +935,6 @@ int zfcp_adapter_debug_register(struct zfcp_adapter *adapter)
936 debug_set_level(adapter->erp_dbf, 3); 935 debug_set_level(adapter->erp_dbf, 3);
937 936
938 /* debug feature area which records HBA (FSF and QDIO) conditions */ 937 /* debug feature area which records HBA (FSF and QDIO) conditions */
939 spin_lock_init(&adapter->hba_dbf_lock);
940 sprintf(dbf_name, "zfcp_%s_hba", zfcp_get_busid_by_adapter(adapter)); 938 sprintf(dbf_name, "zfcp_%s_hba", zfcp_get_busid_by_adapter(adapter));
941 adapter->hba_dbf = debug_register(dbf_name, dbfsize, 1, 939 adapter->hba_dbf = debug_register(dbf_name, dbfsize, 1,
942 sizeof(struct zfcp_hba_dbf_record)); 940 sizeof(struct zfcp_hba_dbf_record));
@@ -947,7 +945,6 @@ int zfcp_adapter_debug_register(struct zfcp_adapter *adapter)
947 debug_set_level(adapter->hba_dbf, 3); 945 debug_set_level(adapter->hba_dbf, 3);
948 946
949 /* debug feature area which records SAN command failures and recovery */ 947 /* debug feature area which records SAN command failures and recovery */
950 spin_lock_init(&adapter->san_dbf_lock);
951 sprintf(dbf_name, "zfcp_%s_san", zfcp_get_busid_by_adapter(adapter)); 948 sprintf(dbf_name, "zfcp_%s_san", zfcp_get_busid_by_adapter(adapter));
952 adapter->san_dbf = debug_register(dbf_name, dbfsize, 1, 949 adapter->san_dbf = debug_register(dbf_name, dbfsize, 1,
953 sizeof(struct zfcp_san_dbf_record)); 950 sizeof(struct zfcp_san_dbf_record));
@@ -958,7 +955,6 @@ int zfcp_adapter_debug_register(struct zfcp_adapter *adapter)
958 debug_set_level(adapter->san_dbf, 6); 955 debug_set_level(adapter->san_dbf, 6);
959 956
960 /* debug feature area which records SCSI command failures and recovery */ 957 /* debug feature area which records SCSI command failures and recovery */
961 spin_lock_init(&adapter->scsi_dbf_lock);
962 sprintf(dbf_name, "zfcp_%s_scsi", zfcp_get_busid_by_adapter(adapter)); 958 sprintf(dbf_name, "zfcp_%s_scsi", zfcp_get_busid_by_adapter(adapter));
963 adapter->scsi_dbf = debug_register(dbf_name, dbfsize, 1, 959 adapter->scsi_dbf = debug_register(dbf_name, dbfsize, 1,
964 sizeof(struct zfcp_scsi_dbf_record)); 960 sizeof(struct zfcp_scsi_dbf_record));
diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c
index 023f4e558ae4..ee7314d8c2da 100644
--- a/drivers/s390/scsi/zfcp_erp.c
+++ b/drivers/s390/scsi/zfcp_erp.c
@@ -1071,11 +1071,6 @@ zfcp_erp_thread_setup(struct zfcp_adapter *adapter)
1071 1071
1072 atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP, &adapter->status); 1072 atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP, &adapter->status);
1073 1073
1074 rwlock_init(&adapter->erp_lock);
1075 INIT_LIST_HEAD(&adapter->erp_ready_head);
1076 INIT_LIST_HEAD(&adapter->erp_running_head);
1077 sema_init(&adapter->erp_ready_sem, 0);
1078
1079 retval = kernel_thread(zfcp_erp_thread, adapter, SIGCHLD); 1074 retval = kernel_thread(zfcp_erp_thread, adapter, SIGCHLD);
1080 if (retval < 0) { 1075 if (retval < 0) {
1081 ZFCP_LOG_NORMAL("error: creation of erp thread failed for " 1076 ZFCP_LOG_NORMAL("error: creation of erp thread failed for "
@@ -2248,29 +2243,26 @@ zfcp_erp_adapter_strategy_close_qdio(struct zfcp_erp_action *erp_action)
2248 return retval; 2243 return retval;
2249} 2244}
2250 2245
2251/*
2252 * function: zfcp_fsf_init
2253 *
2254 * purpose: initializes FSF operation for the specified adapter
2255 *
2256 * returns: 0 - succesful initialization of FSF operation
2257 * !0 - failed to initialize FSF operation
2258 */
2259static int 2246static int
2260zfcp_erp_adapter_strategy_open_fsf(struct zfcp_erp_action *erp_action) 2247zfcp_erp_adapter_strategy_open_fsf(struct zfcp_erp_action *erp_action)
2261{ 2248{
2262 int xconfig, xport; 2249 int retval;
2263 2250
2264 if (atomic_test_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED, 2251 if ((atomic_test_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED,
2265 &erp_action->adapter->status)) { 2252 &erp_action->adapter->status)) &&
2253 (erp_action->adapter->adapter_features &
2254 FSF_FEATURE_HBAAPI_MANAGEMENT)) {
2266 zfcp_erp_adapter_strategy_open_fsf_xport(erp_action); 2255 zfcp_erp_adapter_strategy_open_fsf_xport(erp_action);
2267 atomic_set(&erp_action->adapter->erp_counter, 0); 2256 atomic_set(&erp_action->adapter->erp_counter, 0);
2268 return ZFCP_ERP_FAILED; 2257 return ZFCP_ERP_FAILED;
2269 } 2258 }
2270 2259
2271 xconfig = zfcp_erp_adapter_strategy_open_fsf_xconfig(erp_action); 2260 retval = zfcp_erp_adapter_strategy_open_fsf_xconfig(erp_action);
2272 xport = zfcp_erp_adapter_strategy_open_fsf_xport(erp_action); 2261 if (retval == ZFCP_ERP_FAILED)
2273 if ((xconfig == ZFCP_ERP_FAILED) || (xport == 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)
2274 return ZFCP_ERP_FAILED; 2266 return ZFCP_ERP_FAILED;
2275 2267
2276 return zfcp_erp_adapter_strategy_open_fsf_statusread(erp_action); 2268 return zfcp_erp_adapter_strategy_open_fsf_statusread(erp_action);
@@ -2359,41 +2351,29 @@ zfcp_erp_adapter_strategy_open_fsf_xconfig(struct zfcp_erp_action *erp_action)
2359static int 2351static int
2360zfcp_erp_adapter_strategy_open_fsf_xport(struct zfcp_erp_action *erp_action) 2352zfcp_erp_adapter_strategy_open_fsf_xport(struct zfcp_erp_action *erp_action)
2361{ 2353{
2362 int retval = ZFCP_ERP_SUCCEEDED; 2354 int ret;
2363 int retries; 2355 int retries;
2364 int sleep; 2356 int sleep;
2365 struct zfcp_adapter *adapter = erp_action->adapter; 2357 struct zfcp_adapter *adapter = erp_action->adapter;
2366 2358
2367 atomic_clear_mask(ZFCP_STATUS_ADAPTER_XPORT_OK, &adapter->status); 2359 atomic_clear_mask(ZFCP_STATUS_ADAPTER_XPORT_OK, &adapter->status);
2368 2360
2369 for (retries = 0; ; retries++) { 2361 retries = 0;
2370 ZFCP_LOG_DEBUG("Doing exchange port data\n"); 2362 do {
2363 write_lock(&adapter->erp_lock);
2371 zfcp_erp_action_to_running(erp_action); 2364 zfcp_erp_action_to_running(erp_action);
2365 write_unlock(&adapter->erp_lock);
2372 zfcp_erp_timeout_init(erp_action); 2366 zfcp_erp_timeout_init(erp_action);
2373 if (zfcp_fsf_exchange_port_data(erp_action, adapter, NULL)) { 2367 ret = zfcp_fsf_exchange_port_data(erp_action, adapter, NULL);
2374 retval = ZFCP_ERP_FAILED; 2368 if (ret == -EOPNOTSUPP) {
2375 debug_text_event(adapter->erp_dbf, 5, "a_fstx_xf"); 2369 debug_text_event(adapter->erp_dbf, 3, "a_xport_notsupp");
2376 ZFCP_LOG_INFO("error: initiation of exchange of " 2370 return ZFCP_ERP_SUCCEEDED;
2377 "port data failed for adapter %s\n", 2371 } else if (ret) {
2378 zfcp_get_busid_by_adapter(adapter)); 2372 debug_text_event(adapter->erp_dbf, 3, "a_xport_failed");
2379 break; 2373 return ZFCP_ERP_FAILED;
2380 } 2374 }
2381 debug_text_event(adapter->erp_dbf, 6, "a_fstx_xok"); 2375 debug_text_event(adapter->erp_dbf, 6, "a_xport_ok");
2382 ZFCP_LOG_DEBUG("Xchange underway\n");
2383 2376
2384 /*
2385 * Why this works:
2386 * Both the normal completion handler as well as the timeout
2387 * handler will do an 'up' when the 'exchange port data'
2388 * request completes or times out. Thus, the signal to go on
2389 * won't be lost utilizing this semaphore.
2390 * Furthermore, this 'adapter_reopen' action is
2391 * guaranteed to be the only action being there (highest action
2392 * which prevents other actions from being created).
2393 * Resulting from that, the wake signal recognized here
2394 * _must_ be the one belonging to the 'exchange port
2395 * data' request.
2396 */
2397 down(&adapter->erp_ready_sem); 2377 down(&adapter->erp_ready_sem);
2398 if (erp_action->status & ZFCP_STATUS_ERP_TIMEDOUT) { 2378 if (erp_action->status & ZFCP_STATUS_ERP_TIMEDOUT) {
2399 ZFCP_LOG_INFO("error: exchange of port data " 2379 ZFCP_LOG_INFO("error: exchange of port data "
@@ -2401,29 +2381,19 @@ zfcp_erp_adapter_strategy_open_fsf_xport(struct zfcp_erp_action *erp_action)
2401 zfcp_get_busid_by_adapter(adapter)); 2381 zfcp_get_busid_by_adapter(adapter));
2402 break; 2382 break;
2403 } 2383 }
2404
2405 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED, 2384 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED,
2406 &adapter->status)) 2385 &adapter->status))
2407 break; 2386 break;
2408 2387
2409 ZFCP_LOG_DEBUG("host connection still initialising... " 2388 if (retries < ZFCP_EXCHANGE_PORT_DATA_SHORT_RETRIES) {
2410 "waiting and retrying...\n"); 2389 sleep = ZFCP_EXCHANGE_PORT_DATA_SHORT_SLEEP;
2411 /* sleep a little bit before retry */ 2390 retries++;
2412 sleep = retries < ZFCP_EXCHANGE_PORT_DATA_SHORT_RETRIES ? 2391 } else
2413 ZFCP_EXCHANGE_PORT_DATA_SHORT_SLEEP : 2392 sleep = ZFCP_EXCHANGE_PORT_DATA_LONG_SLEEP;
2414 ZFCP_EXCHANGE_PORT_DATA_LONG_SLEEP; 2393 schedule_timeout(sleep);
2415 msleep(jiffies_to_msecs(sleep)); 2394 } while (1);
2416 }
2417
2418 if (atomic_test_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED,
2419 &adapter->status)) {
2420 ZFCP_LOG_INFO("error: exchange of port data for "
2421 "adapter %s failed\n",
2422 zfcp_get_busid_by_adapter(adapter));
2423 retval = ZFCP_ERP_FAILED;
2424 }
2425 2395
2426 return retval; 2396 return ZFCP_ERP_SUCCEEDED;
2427} 2397}
2428 2398
2429/* 2399/*
diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c
index 3b0fc1163f5f..59587951c847 100644
--- a/drivers/s390/scsi/zfcp_fsf.c
+++ b/drivers/s390/scsi/zfcp_fsf.c
@@ -554,6 +554,17 @@ static void
554zfcp_fsf_link_down_info_eval(struct zfcp_adapter *adapter, 554zfcp_fsf_link_down_info_eval(struct zfcp_adapter *adapter,
555 struct fsf_link_down_info *link_down) 555 struct fsf_link_down_info *link_down)
556{ 556{
557 if (atomic_test_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED,
558 &adapter->status))
559 return;
560
561 atomic_set_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED, &adapter->status);
562
563 if (link_down == NULL) {
564 zfcp_erp_adapter_reopen(adapter, 0);
565 return;
566 }
567
557 switch (link_down->error_code) { 568 switch (link_down->error_code) {
558 case FSF_PSQ_LINK_NO_LIGHT: 569 case FSF_PSQ_LINK_NO_LIGHT:
559 ZFCP_LOG_NORMAL("The local link to adapter %s is down " 570 ZFCP_LOG_NORMAL("The local link to adapter %s is down "
@@ -634,20 +645,15 @@ zfcp_fsf_link_down_info_eval(struct zfcp_adapter *adapter,
634 link_down->explanation_code, 645 link_down->explanation_code,
635 link_down->vendor_specific_code); 646 link_down->vendor_specific_code);
636 647
637 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED, 648 switch (link_down->error_code) {
638 &adapter->status)) { 649 case FSF_PSQ_LINK_NO_LIGHT:
639 atomic_set_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED, 650 case FSF_PSQ_LINK_WRAP_PLUG:
640 &adapter->status); 651 case FSF_PSQ_LINK_NO_FCP:
641 switch (link_down->error_code) { 652 case FSF_PSQ_LINK_FIRMWARE_UPDATE:
642 case FSF_PSQ_LINK_NO_LIGHT: 653 zfcp_erp_adapter_reopen(adapter, 0);
643 case FSF_PSQ_LINK_WRAP_PLUG: 654 break;
644 case FSF_PSQ_LINK_NO_FCP: 655 default:
645 case FSF_PSQ_LINK_FIRMWARE_UPDATE: 656 zfcp_erp_adapter_failed(adapter);
646 zfcp_erp_adapter_reopen(adapter, 0);
647 break;
648 default:
649 zfcp_erp_adapter_failed(adapter);
650 }
651 } 657 }
652} 658}
653 659
@@ -919,30 +925,36 @@ zfcp_fsf_status_read_handler(struct zfcp_fsf_req *fsf_req)
919 case FSF_STATUS_READ_SUB_NO_PHYSICAL_LINK: 925 case FSF_STATUS_READ_SUB_NO_PHYSICAL_LINK:
920 ZFCP_LOG_INFO("Physical link to adapter %s is down\n", 926 ZFCP_LOG_INFO("Physical link to adapter %s is down\n",
921 zfcp_get_busid_by_adapter(adapter)); 927 zfcp_get_busid_by_adapter(adapter));
928 zfcp_fsf_link_down_info_eval(adapter,
929 (struct fsf_link_down_info *)
930 &status_buffer->payload);
922 break; 931 break;
923 case FSF_STATUS_READ_SUB_FDISC_FAILED: 932 case FSF_STATUS_READ_SUB_FDISC_FAILED:
924 ZFCP_LOG_INFO("Local link to adapter %s is down " 933 ZFCP_LOG_INFO("Local link to adapter %s is down "
925 "due to failed FDISC login\n", 934 "due to failed FDISC login\n",
926 zfcp_get_busid_by_adapter(adapter)); 935 zfcp_get_busid_by_adapter(adapter));
936 zfcp_fsf_link_down_info_eval(adapter,
937 (struct fsf_link_down_info *)
938 &status_buffer->payload);
927 break; 939 break;
928 case FSF_STATUS_READ_SUB_FIRMWARE_UPDATE: 940 case FSF_STATUS_READ_SUB_FIRMWARE_UPDATE:
929 ZFCP_LOG_INFO("Local link to adapter %s is down " 941 ZFCP_LOG_INFO("Local link to adapter %s is down "
930 "due to firmware update on adapter\n", 942 "due to firmware update on adapter\n",
931 zfcp_get_busid_by_adapter(adapter)); 943 zfcp_get_busid_by_adapter(adapter));
944 zfcp_fsf_link_down_info_eval(adapter, NULL);
932 break; 945 break;
933 default: 946 default:
934 ZFCP_LOG_INFO("Local link to adapter %s is down " 947 ZFCP_LOG_INFO("Local link to adapter %s is down "
935 "due to unknown reason\n", 948 "due to unknown reason\n",
936 zfcp_get_busid_by_adapter(adapter)); 949 zfcp_get_busid_by_adapter(adapter));
950 zfcp_fsf_link_down_info_eval(adapter, NULL);
937 }; 951 };
938 zfcp_fsf_link_down_info_eval(adapter,
939 (struct fsf_link_down_info *) &status_buffer->payload);
940 break; 952 break;
941 953
942 case FSF_STATUS_READ_LINK_UP: 954 case FSF_STATUS_READ_LINK_UP:
943 ZFCP_LOG_NORMAL("Local link to adapter %s was replugged. " 955 ZFCP_LOG_NORMAL("Local link to adapter %s was replugged. "
944 "Restarting operations on this adapter\n", 956 "Restarting operations on this adapter\n",
945 zfcp_get_busid_by_adapter(adapter)); 957 zfcp_get_busid_by_adapter(adapter));
946 /* All ports should be marked as ready to run again */ 958 /* All ports should be marked as ready to run again */
947 zfcp_erp_modify_adapter_status(adapter, 959 zfcp_erp_modify_adapter_status(adapter,
948 ZFCP_STATUS_COMMON_RUNNING, 960 ZFCP_STATUS_COMMON_RUNNING,
@@ -2191,13 +2203,10 @@ zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action,
2191 return -EOPNOTSUPP; 2203 return -EOPNOTSUPP;
2192 } 2204 }
2193 2205
2194 timer = kmalloc(sizeof(struct timer_list), GFP_KERNEL);
2195 if (!timer)
2196 return -ENOMEM;
2197
2198 /* setup new FSF request */ 2206 /* setup new FSF request */
2199 retval = zfcp_fsf_req_create(adapter, FSF_QTCB_EXCHANGE_PORT_DATA, 2207 retval = zfcp_fsf_req_create(adapter, FSF_QTCB_EXCHANGE_PORT_DATA,
2200 0, 0, &lock_flags, &fsf_req); 2208 erp_action ? ZFCP_REQ_AUTO_CLEANUP : 0,
2209 0, &lock_flags, &fsf_req);
2201 if (retval < 0) { 2210 if (retval < 0) {
2202 ZFCP_LOG_INFO("error: Out of resources. Could not create an " 2211 ZFCP_LOG_INFO("error: Out of resources. Could not create an "
2203 "exchange port data request for" 2212 "exchange port data request for"
@@ -2205,25 +2214,33 @@ zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action,
2205 zfcp_get_busid_by_adapter(adapter)); 2214 zfcp_get_busid_by_adapter(adapter));
2206 write_unlock_irqrestore(&adapter->request_queue.queue_lock, 2215 write_unlock_irqrestore(&adapter->request_queue.queue_lock,
2207 lock_flags); 2216 lock_flags);
2208 goto out; 2217 return retval;
2209 }
2210
2211 if (erp_action) {
2212 erp_action->fsf_req = fsf_req;
2213 fsf_req->erp_action = erp_action;
2214 } 2218 }
2215 2219
2216 if (data) 2220 if (data)
2217 fsf_req->data = (unsigned long) data; 2221 fsf_req->data = (unsigned long) data;
2218 2222
2219 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0); 2223 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
2220 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; 2224 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
2221 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; 2225 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
2222 2226
2223 init_timer(timer); 2227 if (erp_action) {
2224 timer->function = zfcp_fsf_request_timeout_handler; 2228 erp_action->fsf_req = fsf_req;
2225 timer->data = (unsigned long) adapter; 2229 fsf_req->erp_action = erp_action;
2226 timer->expires = ZFCP_FSF_REQUEST_TIMEOUT; 2230 timer = &erp_action->timer;
2231 } else {
2232 timer = kmalloc(sizeof(struct timer_list), GFP_ATOMIC);
2233 if (!timer) {
2234 write_unlock_irqrestore(&adapter->request_queue.queue_lock,
2235 lock_flags);
2236 zfcp_fsf_req_free(fsf_req);
2237 return -ENOMEM;
2238 }
2239 init_timer(timer);
2240 timer->function = zfcp_fsf_request_timeout_handler;
2241 timer->data = (unsigned long) adapter;
2242 timer->expires = ZFCP_FSF_REQUEST_TIMEOUT;
2243 }
2227 2244
2228 retval = zfcp_fsf_req_send(fsf_req, timer); 2245 retval = zfcp_fsf_req_send(fsf_req, timer);
2229 if (retval) { 2246 if (retval) {
@@ -2233,23 +2250,22 @@ zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action,
2233 zfcp_fsf_req_free(fsf_req); 2250 zfcp_fsf_req_free(fsf_req);
2234 if (erp_action) 2251 if (erp_action)
2235 erp_action->fsf_req = NULL; 2252 erp_action->fsf_req = NULL;
2253 else
2254 kfree(timer);
2236 write_unlock_irqrestore(&adapter->request_queue.queue_lock, 2255 write_unlock_irqrestore(&adapter->request_queue.queue_lock,
2237 lock_flags); 2256 lock_flags);
2238 goto out; 2257 return retval;
2239 } 2258 }
2240 2259
2241 ZFCP_LOG_DEBUG("Exchange Port Data request initiated (adapter %s)\n", 2260 write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags);
2242 zfcp_get_busid_by_adapter(adapter));
2243
2244 write_unlock_irqrestore(&adapter->request_queue.queue_lock,
2245 lock_flags);
2246 2261
2247 wait_event(fsf_req->completion_wq, 2262 if (!erp_action) {
2248 fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED); 2263 wait_event(fsf_req->completion_wq,
2249 del_timer_sync(timer); 2264 fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED);
2250 zfcp_fsf_req_free(fsf_req); 2265 del_timer_sync(timer);
2251 out: 2266 zfcp_fsf_req_free(fsf_req);
2252 kfree(timer); 2267 kfree(timer);
2268 }
2253 return retval; 2269 return retval;
2254} 2270}
2255 2271
diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c
index 3dcd1bfba3b4..66608d13a634 100644
--- a/drivers/s390/scsi/zfcp_scsi.c
+++ b/drivers/s390/scsi/zfcp_scsi.c
@@ -179,7 +179,7 @@ zfcp_scsi_slave_alloc(struct scsi_device *sdp)
179 struct zfcp_adapter *adapter; 179 struct zfcp_adapter *adapter;
180 struct zfcp_unit *unit; 180 struct zfcp_unit *unit;
181 unsigned long flags; 181 unsigned long flags;
182 int retval = -ENODEV; 182 int retval = -ENXIO;
183 183
184 adapter = (struct zfcp_adapter *) sdp->host->hostdata[0]; 184 adapter = (struct zfcp_adapter *) sdp->host->hostdata[0];
185 if (!adapter) 185 if (!adapter)
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
index ab383d1f59e2..3cb68af90456 100644
--- a/drivers/scsi/aacraid/linit.c
+++ b/drivers/scsi/aacraid/linit.c
@@ -325,6 +325,8 @@ static int aac_biosparm(struct scsi_device *sdev, struct block_device *bdev,
325 * translations ( 64/32, 128/32, 255/63 ). 325 * translations ( 64/32, 128/32, 255/63 ).
326 */ 326 */
327 buf = scsi_bios_ptable(bdev); 327 buf = scsi_bios_ptable(bdev);
328 if (!buf)
329 return 0;
328 if(*(__le16 *)(buf + 0x40) == cpu_to_le16(0xaa55)) { 330 if(*(__le16 *)(buf + 0x40) == cpu_to_le16(0xaa55)) {
329 struct partition *first = (struct partition * )buf; 331 struct partition *first = (struct partition * )buf;
330 struct partition *entry = first; 332 struct partition *entry = first;
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c
index 31e9f40e79a2..6aab9dacdeea 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm.c
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.c
@@ -2105,7 +2105,7 @@ ahd_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)
2105 scmd_id(cmd), 2105 scmd_id(cmd),
2106 scmd_channel(cmd) + 'A', 2106 scmd_channel(cmd) + 'A',
2107 CAM_LUN_WILDCARD, 2107 CAM_LUN_WILDCARD,
2108 SCB_LIST_NULL, ROLE_INITIATOR) == 0) 2108 SCB_LIST_NULL, ROLE_INITIATOR))
2109 break; 2109 break;
2110 } 2110 }
2111 } 2111 }
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c
index 7fc6454068e4..d866213f42b8 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c
@@ -2169,7 +2169,7 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)
2169 if (ahc_match_scb(ahc, pending_scb, scmd_id(cmd), 2169 if (ahc_match_scb(ahc, pending_scb, scmd_id(cmd),
2170 scmd_channel(cmd) + 'A', 2170 scmd_channel(cmd) + 'A',
2171 CAM_LUN_WILDCARD, 2171 CAM_LUN_WILDCARD,
2172 SCB_LIST_NULL, ROLE_INITIATOR) == 0) 2172 SCB_LIST_NULL, ROLE_INITIATOR))
2173 break; 2173 break;
2174 } 2174 }
2175 } 2175 }
diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c
index 718a2bc4ed5e..38a53b5f9e9a 100644
--- a/drivers/scsi/scsi_transport_spi.c
+++ b/drivers/scsi/scsi_transport_spi.c
@@ -812,12 +812,10 @@ spi_dv_device_internal(struct scsi_device *sdev, u8 *buffer)
812 if (!scsi_device_sync(sdev) && !scsi_device_dt(sdev)) 812 if (!scsi_device_sync(sdev) && !scsi_device_dt(sdev))
813 return; 813 return;
814 814
815 /* see if the device has an echo buffer. If it does we can 815 /* len == -1 is the signal that we need to ascertain the
816 * do the SPI pattern write tests */ 816 * presence of an echo buffer before trying to use it. len ==
817 817 * 0 means we don't have an echo buffer */
818 len = 0; 818 len = -1;
819 if (scsi_device_dt(sdev))
820 len = spi_dv_device_get_echo_buffer(sdev, buffer);
821 819
822 retry: 820 retry:
823 821
@@ -840,11 +838,23 @@ spi_dv_device_internal(struct scsi_device *sdev, u8 *buffer)
840 if (spi_min_period(starget) == 8) 838 if (spi_min_period(starget) == 8)
841 DV_SET(pcomp_en, 1); 839 DV_SET(pcomp_en, 1);
842 } 840 }
841 /* Do the read only INQUIRY tests */
842 spi_dv_retrain(sdev, buffer, buffer + sdev->inquiry_len,
843 spi_dv_device_compare_inquiry);
844 /* See if we actually managed to negotiate and sustain DT */
845 if (i->f->get_dt)
846 i->f->get_dt(starget);
847
848 /* see if the device has an echo buffer. If it does we can do
849 * the SPI pattern write tests. Because of some broken
850 * devices, we *only* try this on a device that has actually
851 * negotiated DT */
852
853 if (len == -1 && spi_dt(starget))
854 len = spi_dv_device_get_echo_buffer(sdev, buffer);
843 855
844 if (len == 0) { 856 if (len <= 0) {
845 starget_printk(KERN_INFO, starget, "Domain Validation skipping write tests\n"); 857 starget_printk(KERN_INFO, starget, "Domain Validation skipping write tests\n");
846 spi_dv_retrain(sdev, buffer, buffer + len,
847 spi_dv_device_compare_inquiry);
848 return; 858 return;
849 } 859 }
850 860
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 72ec59456e69..b55c2a8a547c 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -1860,9 +1860,11 @@ st_map_user_pages(struct scatterlist *sgl, const unsigned int max_pages,
1860 unlock_page(pages[j]); */ 1860 unlock_page(pages[j]); */
1861 res = 0; 1861 res = 0;
1862 out_unmap: 1862 out_unmap:
1863 if (res > 0) 1863 if (res > 0) {
1864 for (j=0; j < res; j++) 1864 for (j=0; j < res; j++)
1865 page_cache_release(pages[j]); 1865 page_cache_release(pages[j]);
1866 res = 0;
1867 }
1866 kfree(pages); 1868 kfree(pages);
1867 return res; 1869 return res;
1868} 1870}
@@ -1878,8 +1880,6 @@ st_unmap_user_pages(struct scatterlist *sgl, const unsigned int nr_pages,
1878 for (i=0; i < nr_pages; i++) { 1880 for (i=0; i < nr_pages; i++) {
1879 struct page *page = sgl[i].page; 1881 struct page *page = sgl[i].page;
1880 1882
1881 /* XXX: just for debug. Remove when PageReserved is removed */
1882 BUG_ON(PageReserved(page));
1883 if (dirtied) 1883 if (dirtied)
1884 SetPageDirty(page); 1884 SetPageDirty(page);
1885 /* unlock_page(page); */ 1885 /* unlock_page(page); */
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 770c4324f3d5..7ac6ea141fff 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -4509,6 +4509,7 @@ static int sgl_map_user_pages(struct scatterlist *sgl, const unsigned int max_pa
4509 if (res > 0) { 4509 if (res > 0) {
4510 for (j=0; j < res; j++) 4510 for (j=0; j < res; j++)
4511 page_cache_release(pages[j]); 4511 page_cache_release(pages[j]);
4512 res = 0;
4512 } 4513 }
4513 kfree(pages); 4514 kfree(pages);
4514 return res; 4515 return res;
@@ -4524,8 +4525,6 @@ static int sgl_unmap_user_pages(struct scatterlist *sgl, const unsigned int nr_p
4524 for (i=0; i < nr_pages; i++) { 4525 for (i=0; i < nr_pages; i++) {
4525 struct page *page = sgl[i].page; 4526 struct page *page = sgl[i].page;
4526 4527
4527 /* XXX: just for debug. Remove when PageReserved is removed */
4528 BUG_ON(PageReserved(page));
4529 if (dirtied) 4528 if (dirtied)
4530 SetPageDirty(page); 4529 SetPageDirty(page);
4531 /* FIXME: cache flush missing for rw==READ 4530 /* FIXME: cache flush missing for rw==READ
diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c
index d76766c3ce16..7fc0b97173e1 100644
--- a/drivers/scsi/sym53c8xx_2/sym_glue.c
+++ b/drivers/scsi/sym53c8xx_2/sym_glue.c
@@ -2086,6 +2086,7 @@ static void sym2_set_dt(struct scsi_target *starget, int dt)
2086 tp->tgoal.check_nego = 1; 2086 tp->tgoal.check_nego = 1;
2087} 2087}
2088 2088
2089#if 0
2089static void sym2_set_iu(struct scsi_target *starget, int iu) 2090static void sym2_set_iu(struct scsi_target *starget, int iu)
2090{ 2091{
2091 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 2092 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
@@ -2111,7 +2112,7 @@ static void sym2_set_qas(struct scsi_target *starget, int qas)
2111 tp->tgoal.qas = 0; 2112 tp->tgoal.qas = 0;
2112 tp->tgoal.check_nego = 1; 2113 tp->tgoal.check_nego = 1;
2113} 2114}
2114 2115#endif
2115 2116
2116static struct spi_function_template sym2_transport_functions = { 2117static struct spi_function_template sym2_transport_functions = {
2117 .set_offset = sym2_set_offset, 2118 .set_offset = sym2_set_offset,
@@ -2122,10 +2123,12 @@ static struct spi_function_template sym2_transport_functions = {
2122 .show_width = 1, 2123 .show_width = 1,
2123 .set_dt = sym2_set_dt, 2124 .set_dt = sym2_set_dt,
2124 .show_dt = 1, 2125 .show_dt = 1,
2126#if 0
2125 .set_iu = sym2_set_iu, 2127 .set_iu = sym2_set_iu,
2126 .show_iu = 1, 2128 .show_iu = 1,
2127 .set_qas = sym2_set_qas, 2129 .set_qas = sym2_set_qas,
2128 .show_qas = 1, 2130 .show_qas = 1,
2131#endif
2129 .get_signalling = sym2_get_signalling, 2132 .get_signalling = sym2_get_signalling,
2130}; 2133};
2131 2134