diff options
author | Christof Schmitt <christof.schmitt@de.ibm.com> | 2010-04-30 12:09:35 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2010-05-02 15:42:32 -0400 |
commit | 6b9e1520094a8aa68009c265eb694e0be9f5be3f (patch) | |
tree | d6abee81a84fe8e43c26c0db75a9917599f0b835 /drivers/s390 | |
parent | 1674b4054744c2cfd6573e43eca45d86ff581d0e (diff) |
[SCSI] zfcp: Move sbal_get function to zfcp_qdio.c
Waiting for a free sbal is a operation on the qdio queue. Move the
code implementing the wait to zfcp_qdio.c and rename the functions
accordingly.
Reviewed-by: Swen Schillig <swen@vnet.ibm.com>
Signed-off-by: Christof Schmitt <christof.schmitt@de.ibm.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/s390')
-rw-r--r-- | drivers/s390/scsi/zfcp_ext.h | 1 | ||||
-rw-r--r-- | drivers/s390/scsi/zfcp_fsf.c | 65 | ||||
-rw-r--r-- | drivers/s390/scsi/zfcp_qdio.c | 40 |
3 files changed, 58 insertions, 48 deletions
diff --git a/drivers/s390/scsi/zfcp_ext.h b/drivers/s390/scsi/zfcp_ext.h index 172da12a2d02..48a8f93b72f5 100644 --- a/drivers/s390/scsi/zfcp_ext.h +++ b/drivers/s390/scsi/zfcp_ext.h | |||
@@ -143,6 +143,7 @@ extern void zfcp_fsf_reqid_check(struct zfcp_qdio *, int); | |||
143 | /* zfcp_qdio.c */ | 143 | /* zfcp_qdio.c */ |
144 | extern int zfcp_qdio_setup(struct zfcp_adapter *); | 144 | extern int zfcp_qdio_setup(struct zfcp_adapter *); |
145 | extern void zfcp_qdio_destroy(struct zfcp_qdio *); | 145 | extern void zfcp_qdio_destroy(struct zfcp_qdio *); |
146 | extern int zfcp_qdio_sbal_get(struct zfcp_qdio *); | ||
146 | extern int zfcp_qdio_send(struct zfcp_qdio *, struct zfcp_qdio_req *); | 147 | extern int zfcp_qdio_send(struct zfcp_qdio *, struct zfcp_qdio_req *); |
147 | extern int zfcp_qdio_sbals_from_sg(struct zfcp_qdio *, struct zfcp_qdio_req *, | 148 | extern int zfcp_qdio_sbals_from_sg(struct zfcp_qdio *, struct zfcp_qdio_req *, |
148 | struct scatterlist *, int); | 149 | struct scatterlist *, int); |
diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c index ec1b49a75532..3822f22b8150 100644 --- a/drivers/s390/scsi/zfcp_fsf.c +++ b/drivers/s390/scsi/zfcp_fsf.c | |||
@@ -640,37 +640,6 @@ static void zfcp_fsf_exchange_port_data_handler(struct zfcp_fsf_req *req) | |||
640 | } | 640 | } |
641 | } | 641 | } |
642 | 642 | ||
643 | static int zfcp_fsf_sbal_check(struct zfcp_qdio *qdio) | ||
644 | { | ||
645 | struct zfcp_qdio_queue *req_q = &qdio->req_q; | ||
646 | |||
647 | spin_lock_bh(&qdio->req_q_lock); | ||
648 | if (atomic_read(&req_q->count)) | ||
649 | return 1; | ||
650 | spin_unlock_bh(&qdio->req_q_lock); | ||
651 | return 0; | ||
652 | } | ||
653 | |||
654 | static int zfcp_fsf_req_sbal_get(struct zfcp_qdio *qdio) | ||
655 | { | ||
656 | struct zfcp_adapter *adapter = qdio->adapter; | ||
657 | long ret; | ||
658 | |||
659 | spin_unlock_bh(&qdio->req_q_lock); | ||
660 | ret = wait_event_interruptible_timeout(qdio->req_q_wq, | ||
661 | zfcp_fsf_sbal_check(qdio), 5 * HZ); | ||
662 | if (ret > 0) | ||
663 | return 0; | ||
664 | if (!ret) { | ||
665 | atomic_inc(&qdio->req_q_full); | ||
666 | /* assume hanging outbound queue, try queue recovery */ | ||
667 | zfcp_erp_adapter_reopen(adapter, 0, "fsrsg_1", NULL); | ||
668 | } | ||
669 | |||
670 | spin_lock_bh(&qdio->req_q_lock); | ||
671 | return -EIO; | ||
672 | } | ||
673 | |||
674 | static struct zfcp_fsf_req *zfcp_fsf_alloc(mempool_t *pool) | 643 | static struct zfcp_fsf_req *zfcp_fsf_alloc(mempool_t *pool) |
675 | { | 644 | { |
676 | struct zfcp_fsf_req *req; | 645 | struct zfcp_fsf_req *req; |
@@ -798,7 +767,7 @@ int zfcp_fsf_status_read(struct zfcp_qdio *qdio) | |||
798 | int retval = -EIO; | 767 | int retval = -EIO; |
799 | 768 | ||
800 | spin_lock_bh(&qdio->req_q_lock); | 769 | spin_lock_bh(&qdio->req_q_lock); |
801 | if (zfcp_fsf_req_sbal_get(qdio)) | 770 | if (zfcp_qdio_sbal_get(qdio)) |
802 | goto out; | 771 | goto out; |
803 | 772 | ||
804 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_UNSOLICITED_STATUS, 0, | 773 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_UNSOLICITED_STATUS, 0, |
@@ -898,7 +867,7 @@ struct zfcp_fsf_req *zfcp_fsf_abort_fcp_command(unsigned long old_req_id, | |||
898 | struct zfcp_qdio *qdio = unit->port->adapter->qdio; | 867 | struct zfcp_qdio *qdio = unit->port->adapter->qdio; |
899 | 868 | ||
900 | spin_lock_bh(&qdio->req_q_lock); | 869 | spin_lock_bh(&qdio->req_q_lock); |
901 | if (zfcp_fsf_req_sbal_get(qdio)) | 870 | if (zfcp_qdio_sbal_get(qdio)) |
902 | goto out; | 871 | goto out; |
903 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_ABORT_FCP_CMND, | 872 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_ABORT_FCP_CMND, |
904 | SBAL_FLAGS0_TYPE_READ, | 873 | SBAL_FLAGS0_TYPE_READ, |
@@ -1068,7 +1037,7 @@ int zfcp_fsf_send_ct(struct zfcp_fc_wka_port *wka_port, | |||
1068 | int ret = -EIO; | 1037 | int ret = -EIO; |
1069 | 1038 | ||
1070 | spin_lock_bh(&qdio->req_q_lock); | 1039 | spin_lock_bh(&qdio->req_q_lock); |
1071 | if (zfcp_fsf_req_sbal_get(qdio)) | 1040 | if (zfcp_qdio_sbal_get(qdio)) |
1072 | goto out; | 1041 | goto out; |
1073 | 1042 | ||
1074 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_SEND_GENERIC, | 1043 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_SEND_GENERIC, |
@@ -1165,7 +1134,7 @@ int zfcp_fsf_send_els(struct zfcp_adapter *adapter, u32 d_id, | |||
1165 | int ret = -EIO; | 1134 | int ret = -EIO; |
1166 | 1135 | ||
1167 | spin_lock_bh(&qdio->req_q_lock); | 1136 | spin_lock_bh(&qdio->req_q_lock); |
1168 | if (zfcp_fsf_req_sbal_get(qdio)) | 1137 | if (zfcp_qdio_sbal_get(qdio)) |
1169 | goto out; | 1138 | goto out; |
1170 | 1139 | ||
1171 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_SEND_ELS, | 1140 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_SEND_ELS, |
@@ -1208,7 +1177,7 @@ int zfcp_fsf_exchange_config_data(struct zfcp_erp_action *erp_action) | |||
1208 | int retval = -EIO; | 1177 | int retval = -EIO; |
1209 | 1178 | ||
1210 | spin_lock_bh(&qdio->req_q_lock); | 1179 | spin_lock_bh(&qdio->req_q_lock); |
1211 | if (zfcp_fsf_req_sbal_get(qdio)) | 1180 | if (zfcp_qdio_sbal_get(qdio)) |
1212 | goto out; | 1181 | goto out; |
1213 | 1182 | ||
1214 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_EXCHANGE_CONFIG_DATA, | 1183 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_EXCHANGE_CONFIG_DATA, |
@@ -1250,7 +1219,7 @@ int zfcp_fsf_exchange_config_data_sync(struct zfcp_qdio *qdio, | |||
1250 | int retval = -EIO; | 1219 | int retval = -EIO; |
1251 | 1220 | ||
1252 | spin_lock_bh(&qdio->req_q_lock); | 1221 | spin_lock_bh(&qdio->req_q_lock); |
1253 | if (zfcp_fsf_req_sbal_get(qdio)) | 1222 | if (zfcp_qdio_sbal_get(qdio)) |
1254 | goto out_unlock; | 1223 | goto out_unlock; |
1255 | 1224 | ||
1256 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_EXCHANGE_CONFIG_DATA, | 1225 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_EXCHANGE_CONFIG_DATA, |
@@ -1302,7 +1271,7 @@ int zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action) | |||
1302 | return -EOPNOTSUPP; | 1271 | return -EOPNOTSUPP; |
1303 | 1272 | ||
1304 | spin_lock_bh(&qdio->req_q_lock); | 1273 | spin_lock_bh(&qdio->req_q_lock); |
1305 | if (zfcp_fsf_req_sbal_get(qdio)) | 1274 | if (zfcp_qdio_sbal_get(qdio)) |
1306 | goto out; | 1275 | goto out; |
1307 | 1276 | ||
1308 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_EXCHANGE_PORT_DATA, | 1277 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_EXCHANGE_PORT_DATA, |
@@ -1348,7 +1317,7 @@ int zfcp_fsf_exchange_port_data_sync(struct zfcp_qdio *qdio, | |||
1348 | return -EOPNOTSUPP; | 1317 | return -EOPNOTSUPP; |
1349 | 1318 | ||
1350 | spin_lock_bh(&qdio->req_q_lock); | 1319 | spin_lock_bh(&qdio->req_q_lock); |
1351 | if (zfcp_fsf_req_sbal_get(qdio)) | 1320 | if (zfcp_qdio_sbal_get(qdio)) |
1352 | goto out_unlock; | 1321 | goto out_unlock; |
1353 | 1322 | ||
1354 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_EXCHANGE_PORT_DATA, | 1323 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_EXCHANGE_PORT_DATA, |
@@ -1462,7 +1431,7 @@ int zfcp_fsf_open_port(struct zfcp_erp_action *erp_action) | |||
1462 | int retval = -EIO; | 1431 | int retval = -EIO; |
1463 | 1432 | ||
1464 | spin_lock_bh(&qdio->req_q_lock); | 1433 | spin_lock_bh(&qdio->req_q_lock); |
1465 | if (zfcp_fsf_req_sbal_get(qdio)) | 1434 | if (zfcp_qdio_sbal_get(qdio)) |
1466 | goto out; | 1435 | goto out; |
1467 | 1436 | ||
1468 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_OPEN_PORT_WITH_DID, | 1437 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_OPEN_PORT_WITH_DID, |
@@ -1530,7 +1499,7 @@ int zfcp_fsf_close_port(struct zfcp_erp_action *erp_action) | |||
1530 | int retval = -EIO; | 1499 | int retval = -EIO; |
1531 | 1500 | ||
1532 | spin_lock_bh(&qdio->req_q_lock); | 1501 | spin_lock_bh(&qdio->req_q_lock); |
1533 | if (zfcp_fsf_req_sbal_get(qdio)) | 1502 | if (zfcp_qdio_sbal_get(qdio)) |
1534 | goto out; | 1503 | goto out; |
1535 | 1504 | ||
1536 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_CLOSE_PORT, | 1505 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_CLOSE_PORT, |
@@ -1605,7 +1574,7 @@ int zfcp_fsf_open_wka_port(struct zfcp_fc_wka_port *wka_port) | |||
1605 | int retval = -EIO; | 1574 | int retval = -EIO; |
1606 | 1575 | ||
1607 | spin_lock_bh(&qdio->req_q_lock); | 1576 | spin_lock_bh(&qdio->req_q_lock); |
1608 | if (zfcp_fsf_req_sbal_get(qdio)) | 1577 | if (zfcp_qdio_sbal_get(qdio)) |
1609 | goto out; | 1578 | goto out; |
1610 | 1579 | ||
1611 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_OPEN_PORT_WITH_DID, | 1580 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_OPEN_PORT_WITH_DID, |
@@ -1658,7 +1627,7 @@ int zfcp_fsf_close_wka_port(struct zfcp_fc_wka_port *wka_port) | |||
1658 | int retval = -EIO; | 1627 | int retval = -EIO; |
1659 | 1628 | ||
1660 | spin_lock_bh(&qdio->req_q_lock); | 1629 | spin_lock_bh(&qdio->req_q_lock); |
1661 | if (zfcp_fsf_req_sbal_get(qdio)) | 1630 | if (zfcp_qdio_sbal_get(qdio)) |
1662 | goto out; | 1631 | goto out; |
1663 | 1632 | ||
1664 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_CLOSE_PORT, | 1633 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_CLOSE_PORT, |
@@ -1750,7 +1719,7 @@ int zfcp_fsf_close_physical_port(struct zfcp_erp_action *erp_action) | |||
1750 | int retval = -EIO; | 1719 | int retval = -EIO; |
1751 | 1720 | ||
1752 | spin_lock_bh(&qdio->req_q_lock); | 1721 | spin_lock_bh(&qdio->req_q_lock); |
1753 | if (zfcp_fsf_req_sbal_get(qdio)) | 1722 | if (zfcp_qdio_sbal_get(qdio)) |
1754 | goto out; | 1723 | goto out; |
1755 | 1724 | ||
1756 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_CLOSE_PHYSICAL_PORT, | 1725 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_CLOSE_PHYSICAL_PORT, |
@@ -1921,7 +1890,7 @@ int zfcp_fsf_open_unit(struct zfcp_erp_action *erp_action) | |||
1921 | int retval = -EIO; | 1890 | int retval = -EIO; |
1922 | 1891 | ||
1923 | spin_lock_bh(&qdio->req_q_lock); | 1892 | spin_lock_bh(&qdio->req_q_lock); |
1924 | if (zfcp_fsf_req_sbal_get(qdio)) | 1893 | if (zfcp_qdio_sbal_get(qdio)) |
1925 | goto out; | 1894 | goto out; |
1926 | 1895 | ||
1927 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_OPEN_LUN, | 1896 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_OPEN_LUN, |
@@ -2005,7 +1974,7 @@ int zfcp_fsf_close_unit(struct zfcp_erp_action *erp_action) | |||
2005 | int retval = -EIO; | 1974 | int retval = -EIO; |
2006 | 1975 | ||
2007 | spin_lock_bh(&qdio->req_q_lock); | 1976 | spin_lock_bh(&qdio->req_q_lock); |
2008 | if (zfcp_fsf_req_sbal_get(qdio)) | 1977 | if (zfcp_qdio_sbal_get(qdio)) |
2009 | goto out; | 1978 | goto out; |
2010 | 1979 | ||
2011 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_CLOSE_LUN, | 1980 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_CLOSE_LUN, |
@@ -2340,7 +2309,7 @@ struct zfcp_fsf_req *zfcp_fsf_send_fcp_ctm(struct zfcp_unit *unit, u8 tm_flags) | |||
2340 | return NULL; | 2309 | return NULL; |
2341 | 2310 | ||
2342 | spin_lock_bh(&qdio->req_q_lock); | 2311 | spin_lock_bh(&qdio->req_q_lock); |
2343 | if (zfcp_fsf_req_sbal_get(qdio)) | 2312 | if (zfcp_qdio_sbal_get(qdio)) |
2344 | goto out; | 2313 | goto out; |
2345 | 2314 | ||
2346 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_FCP_CMND, | 2315 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_FCP_CMND, |
@@ -2410,7 +2379,7 @@ struct zfcp_fsf_req *zfcp_fsf_control_file(struct zfcp_adapter *adapter, | |||
2410 | } | 2379 | } |
2411 | 2380 | ||
2412 | spin_lock_bh(&qdio->req_q_lock); | 2381 | spin_lock_bh(&qdio->req_q_lock); |
2413 | if (zfcp_fsf_req_sbal_get(qdio)) | 2382 | if (zfcp_qdio_sbal_get(qdio)) |
2414 | goto out; | 2383 | goto out; |
2415 | 2384 | ||
2416 | req = zfcp_fsf_req_create(qdio, fsf_cfdc->command, direction, NULL); | 2385 | req = zfcp_fsf_req_create(qdio, fsf_cfdc->command, direction, NULL); |
diff --git a/drivers/s390/scsi/zfcp_qdio.c b/drivers/s390/scsi/zfcp_qdio.c index 98d54a9cd563..28117e130e2c 100644 --- a/drivers/s390/scsi/zfcp_qdio.c +++ b/drivers/s390/scsi/zfcp_qdio.c | |||
@@ -246,6 +246,46 @@ int zfcp_qdio_sbals_from_sg(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req, | |||
246 | return bytes; | 246 | return bytes; |
247 | } | 247 | } |
248 | 248 | ||
249 | static int zfcp_qdio_sbal_check(struct zfcp_qdio *qdio) | ||
250 | { | ||
251 | struct zfcp_qdio_queue *req_q = &qdio->req_q; | ||
252 | |||
253 | spin_lock_bh(&qdio->req_q_lock); | ||
254 | if (atomic_read(&req_q->count)) | ||
255 | return 1; | ||
256 | spin_unlock_bh(&qdio->req_q_lock); | ||
257 | return 0; | ||
258 | } | ||
259 | |||
260 | /** | ||
261 | * zfcp_qdio_sbal_get - get free sbal in request queue, wait if necessary | ||
262 | * @qdio: pointer to struct zfcp_qdio | ||
263 | * | ||
264 | * The req_q_lock must be held by the caller of this function, and | ||
265 | * this function may only be called from process context; it will | ||
266 | * sleep when waiting for a free sbal. | ||
267 | * | ||
268 | * Returns: 0 on success, -EIO if there is no free sbal after waiting. | ||
269 | */ | ||
270 | int zfcp_qdio_sbal_get(struct zfcp_qdio *qdio) | ||
271 | { | ||
272 | long ret; | ||
273 | |||
274 | spin_unlock_bh(&qdio->req_q_lock); | ||
275 | ret = wait_event_interruptible_timeout(qdio->req_q_wq, | ||
276 | zfcp_qdio_sbal_check(qdio), 5 * HZ); | ||
277 | if (ret > 0) | ||
278 | return 0; | ||
279 | if (!ret) { | ||
280 | atomic_inc(&qdio->req_q_full); | ||
281 | /* assume hanging outbound queue, try queue recovery */ | ||
282 | zfcp_erp_adapter_reopen(qdio->adapter, 0, "qdsbg_1", NULL); | ||
283 | } | ||
284 | |||
285 | spin_lock_bh(&qdio->req_q_lock); | ||
286 | return -EIO; | ||
287 | } | ||
288 | |||
249 | /** | 289 | /** |
250 | * zfcp_qdio_send - set PCI flag in first SBALE and send req to QDIO | 290 | * zfcp_qdio_send - set PCI flag in first SBALE and send req to QDIO |
251 | * @qdio: pointer to struct zfcp_qdio | 291 | * @qdio: pointer to struct zfcp_qdio |