aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/scsi
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/s390/scsi')
-rw-r--r--drivers/s390/scsi/zfcp_aux.c7
-rw-r--r--drivers/s390/scsi/zfcp_def.h19
-rw-r--r--drivers/s390/scsi/zfcp_erp.c2
-rw-r--r--drivers/s390/scsi/zfcp_ext.h6
-rw-r--r--drivers/s390/scsi/zfcp_fc.c4
-rw-r--r--drivers/s390/scsi/zfcp_fsf.c246
-rw-r--r--drivers/s390/scsi/zfcp_fsf.h11
-rw-r--r--drivers/s390/scsi/zfcp_qdio.c108
-rw-r--r--drivers/s390/scsi/zfcp_qdio.h104
-rw-r--r--drivers/s390/scsi/zfcp_scsi.c23
10 files changed, 288 insertions, 242 deletions
diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c
index 1e6183a86ce..e331df2122f 100644
--- a/drivers/s390/scsi/zfcp_aux.c
+++ b/drivers/s390/scsi/zfcp_aux.c
@@ -425,7 +425,8 @@ int zfcp_status_read_refill(struct zfcp_adapter *adapter)
425{ 425{
426 while (atomic_read(&adapter->stat_miss) > 0) 426 while (atomic_read(&adapter->stat_miss) > 0)
427 if (zfcp_fsf_status_read(adapter->qdio)) { 427 if (zfcp_fsf_status_read(adapter->qdio)) {
428 if (atomic_read(&adapter->stat_miss) >= 16) { 428 if (atomic_read(&adapter->stat_miss) >=
429 adapter->stat_read_buf_num) {
429 zfcp_erp_adapter_reopen(adapter, 0, "axsref1", 430 zfcp_erp_adapter_reopen(adapter, 0, "axsref1",
430 NULL); 431 NULL);
431 return 1; 432 return 1;
@@ -545,6 +546,10 @@ struct zfcp_adapter *zfcp_adapter_enqueue(struct ccw_device *ccw_device)
545 &zfcp_sysfs_adapter_attrs)) 546 &zfcp_sysfs_adapter_attrs))
546 goto failed; 547 goto failed;
547 548
549 /* report size limit per scatter-gather segment */
550 adapter->dma_parms.max_segment_size = ZFCP_QDIO_SBALE_LEN;
551 adapter->ccw_device->dev.dma_parms = &adapter->dma_parms;
552
548 if (!zfcp_adapter_scsi_register(adapter)) 553 if (!zfcp_adapter_scsi_register(adapter))
549 return adapter; 554 return adapter;
550 555
diff --git a/drivers/s390/scsi/zfcp_def.h b/drivers/s390/scsi/zfcp_def.h
index 7131c7db1f0..9fa1b064893 100644
--- a/drivers/s390/scsi/zfcp_def.h
+++ b/drivers/s390/scsi/zfcp_def.h
@@ -44,23 +44,6 @@ struct zfcp_reqlist;
44/********************* SCSI SPECIFIC DEFINES *********************************/ 44/********************* SCSI SPECIFIC DEFINES *********************************/
45#define ZFCP_SCSI_ER_TIMEOUT (10*HZ) 45#define ZFCP_SCSI_ER_TIMEOUT (10*HZ)
46 46
47/********************* CIO/QDIO SPECIFIC DEFINES *****************************/
48
49/* DMQ bug workaround: don't use last SBALE */
50#define ZFCP_MAX_SBALES_PER_SBAL (QDIO_MAX_ELEMENTS_PER_BUFFER - 1)
51
52/* index of last SBALE (with respect to DMQ bug workaround) */
53#define ZFCP_LAST_SBALE_PER_SBAL (ZFCP_MAX_SBALES_PER_SBAL - 1)
54
55/* max. number of (data buffer) SBALEs in largest SBAL chain */
56#define ZFCP_MAX_SBALES_PER_REQ \
57 (FSF_MAX_SBALS_PER_REQ * ZFCP_MAX_SBALES_PER_SBAL - 2)
58 /* request ID + QTCB in SBALE 0 + 1 of first SBAL in chain */
59
60#define ZFCP_MAX_SECTORS (ZFCP_MAX_SBALES_PER_REQ * 8)
61 /* max. number of (data buffer) SBALEs in largest SBAL chain
62 multiplied with number of sectors per 4k block */
63
64/********************* FSF SPECIFIC DEFINES *********************************/ 47/********************* FSF SPECIFIC DEFINES *********************************/
65 48
66/* ATTENTION: value must not be used by hardware */ 49/* ATTENTION: value must not be used by hardware */
@@ -181,6 +164,7 @@ struct zfcp_adapter {
181 stack abort/command 164 stack abort/command
182 completion races */ 165 completion races */
183 atomic_t stat_miss; /* # missing status reads*/ 166 atomic_t stat_miss; /* # missing status reads*/
167 unsigned int stat_read_buf_num;
184 struct work_struct stat_work; 168 struct work_struct stat_work;
185 atomic_t status; /* status of this adapter */ 169 atomic_t status; /* status of this adapter */
186 struct list_head erp_ready_head; /* error recovery for this 170 struct list_head erp_ready_head; /* error recovery for this
@@ -205,6 +189,7 @@ struct zfcp_adapter {
205 struct work_struct scan_work; 189 struct work_struct scan_work;
206 struct service_level service_level; 190 struct service_level service_level;
207 struct workqueue_struct *work_queue; 191 struct workqueue_struct *work_queue;
192 struct device_dma_parameters dma_parms;
208}; 193};
209 194
210struct zfcp_port { 195struct zfcp_port {
diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c
index 0be5e7ea282..e3dbeda9717 100644
--- a/drivers/s390/scsi/zfcp_erp.c
+++ b/drivers/s390/scsi/zfcp_erp.c
@@ -714,7 +714,7 @@ static int zfcp_erp_adapter_strategy_open_fsf(struct zfcp_erp_action *act)
714 if (zfcp_erp_adapter_strategy_open_fsf_xport(act) == ZFCP_ERP_FAILED) 714 if (zfcp_erp_adapter_strategy_open_fsf_xport(act) == ZFCP_ERP_FAILED)
715 return ZFCP_ERP_FAILED; 715 return ZFCP_ERP_FAILED;
716 716
717 atomic_set(&act->adapter->stat_miss, 16); 717 atomic_set(&act->adapter->stat_miss, act->adapter->stat_read_buf_num);
718 if (zfcp_status_read_refill(act->adapter)) 718 if (zfcp_status_read_refill(act->adapter))
719 return ZFCP_ERP_FAILED; 719 return ZFCP_ERP_FAILED;
720 720
diff --git a/drivers/s390/scsi/zfcp_ext.h b/drivers/s390/scsi/zfcp_ext.h
index 8786a79c7f8..48a8f93b72f 100644
--- a/drivers/s390/scsi/zfcp_ext.h
+++ b/drivers/s390/scsi/zfcp_ext.h
@@ -3,7 +3,7 @@
3 * 3 *
4 * External function declarations. 4 * External function declarations.
5 * 5 *
6 * Copyright IBM Corporation 2002, 2009 6 * Copyright IBM Corporation 2002, 2010
7 */ 7 */
8 8
9#ifndef ZFCP_EXT_H 9#ifndef ZFCP_EXT_H
@@ -143,9 +143,9 @@ extern void zfcp_fsf_reqid_check(struct zfcp_qdio *, int);
143/* zfcp_qdio.c */ 143/* zfcp_qdio.c */
144extern int zfcp_qdio_setup(struct zfcp_adapter *); 144extern int zfcp_qdio_setup(struct zfcp_adapter *);
145extern void zfcp_qdio_destroy(struct zfcp_qdio *); 145extern void zfcp_qdio_destroy(struct zfcp_qdio *);
146extern int zfcp_qdio_sbal_get(struct zfcp_qdio *);
146extern int zfcp_qdio_send(struct zfcp_qdio *, struct zfcp_qdio_req *); 147extern int zfcp_qdio_send(struct zfcp_qdio *, struct zfcp_qdio_req *);
147extern int zfcp_qdio_sbals_from_sg(struct zfcp_qdio *, 148extern int zfcp_qdio_sbals_from_sg(struct zfcp_qdio *, struct zfcp_qdio_req *,
148 struct zfcp_qdio_req *, unsigned long,
149 struct scatterlist *, int); 149 struct scatterlist *, int);
150extern int zfcp_qdio_open(struct zfcp_qdio *); 150extern int zfcp_qdio_open(struct zfcp_qdio *);
151extern void zfcp_qdio_close(struct zfcp_qdio *); 151extern void zfcp_qdio_close(struct zfcp_qdio *);
diff --git a/drivers/s390/scsi/zfcp_fc.c b/drivers/s390/scsi/zfcp_fc.c
index 2a1cbb74b99..6f8ab43a485 100644
--- a/drivers/s390/scsi/zfcp_fc.c
+++ b/drivers/s390/scsi/zfcp_fc.c
@@ -400,7 +400,7 @@ static int zfcp_fc_adisc(struct zfcp_port *port)
400 struct zfcp_adapter *adapter = port->adapter; 400 struct zfcp_adapter *adapter = port->adapter;
401 int ret; 401 int ret;
402 402
403 adisc = kmem_cache_alloc(zfcp_data.adisc_cache, GFP_ATOMIC); 403 adisc = kmem_cache_zalloc(zfcp_data.adisc_cache, GFP_ATOMIC);
404 if (!adisc) 404 if (!adisc)
405 return -ENOMEM; 405 return -ENOMEM;
406 406
@@ -493,7 +493,7 @@ static struct zfcp_fc_gpn_ft *zfcp_alloc_sg_env(int buf_num)
493 if (!gpn_ft) 493 if (!gpn_ft)
494 return NULL; 494 return NULL;
495 495
496 req = kmem_cache_alloc(zfcp_data.gpn_ft_cache, GFP_KERNEL); 496 req = kmem_cache_zalloc(zfcp_data.gpn_ft_cache, GFP_KERNEL);
497 if (!req) { 497 if (!req) {
498 kfree(gpn_ft); 498 kfree(gpn_ft);
499 gpn_ft = NULL; 499 gpn_ft = NULL;
diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c
index b3b1d2f7939..9ac6a6e4a60 100644
--- a/drivers/s390/scsi/zfcp_fsf.c
+++ b/drivers/s390/scsi/zfcp_fsf.c
@@ -496,6 +496,7 @@ static int zfcp_fsf_exchange_config_evaluate(struct zfcp_fsf_req *req)
496 496
497 adapter->hydra_version = bottom->adapter_type; 497 adapter->hydra_version = bottom->adapter_type;
498 adapter->timer_ticks = bottom->timer_interval; 498 adapter->timer_ticks = bottom->timer_interval;
499 adapter->stat_read_buf_num = max(bottom->status_read_buf_num, (u16)16);
499 500
500 if (fc_host_permanent_port_name(shost) == -1) 501 if (fc_host_permanent_port_name(shost) == -1)
501 fc_host_permanent_port_name(shost) = fc_host_port_name(shost); 502 fc_host_permanent_port_name(shost) = fc_host_port_name(shost);
@@ -640,37 +641,6 @@ static void zfcp_fsf_exchange_port_data_handler(struct zfcp_fsf_req *req)
640 } 641 }
641} 642}
642 643
643static 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
654static 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
674static struct zfcp_fsf_req *zfcp_fsf_alloc(mempool_t *pool) 644static struct zfcp_fsf_req *zfcp_fsf_alloc(mempool_t *pool)
675{ 645{
676 struct zfcp_fsf_req *req; 646 struct zfcp_fsf_req *req;
@@ -705,10 +675,9 @@ static struct fsf_qtcb *zfcp_qtcb_alloc(mempool_t *pool)
705} 675}
706 676
707static struct zfcp_fsf_req *zfcp_fsf_req_create(struct zfcp_qdio *qdio, 677static struct zfcp_fsf_req *zfcp_fsf_req_create(struct zfcp_qdio *qdio,
708 u32 fsf_cmd, mempool_t *pool) 678 u32 fsf_cmd, u32 sbtype,
679 mempool_t *pool)
709{ 680{
710 struct qdio_buffer_element *sbale;
711 struct zfcp_qdio_queue *req_q = &qdio->req_q;
712 struct zfcp_adapter *adapter = qdio->adapter; 681 struct zfcp_adapter *adapter = qdio->adapter;
713 struct zfcp_fsf_req *req = zfcp_fsf_alloc(pool); 682 struct zfcp_fsf_req *req = zfcp_fsf_alloc(pool);
714 683
@@ -725,14 +694,6 @@ static struct zfcp_fsf_req *zfcp_fsf_req_create(struct zfcp_qdio *qdio,
725 req->adapter = adapter; 694 req->adapter = adapter;
726 req->fsf_command = fsf_cmd; 695 req->fsf_command = fsf_cmd;
727 req->req_id = adapter->req_no; 696 req->req_id = adapter->req_no;
728 req->qdio_req.sbal_number = 1;
729 req->qdio_req.sbal_first = req_q->first;
730 req->qdio_req.sbal_last = req_q->first;
731 req->qdio_req.sbale_curr = 1;
732
733 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req);
734 sbale[0].addr = (void *) req->req_id;
735 sbale[0].flags |= SBAL_FLAGS0_COMMAND;
736 697
737 if (likely(fsf_cmd != FSF_QTCB_UNSOLICITED_STATUS)) { 698 if (likely(fsf_cmd != FSF_QTCB_UNSOLICITED_STATUS)) {
738 if (likely(pool)) 699 if (likely(pool))
@@ -753,10 +714,11 @@ static struct zfcp_fsf_req *zfcp_fsf_req_create(struct zfcp_qdio *qdio,
753 req->qtcb->prefix.qtcb_version = FSF_QTCB_CURRENT_VERSION; 714 req->qtcb->prefix.qtcb_version = FSF_QTCB_CURRENT_VERSION;
754 req->qtcb->header.req_handle = req->req_id; 715 req->qtcb->header.req_handle = req->req_id;
755 req->qtcb->header.fsf_command = req->fsf_command; 716 req->qtcb->header.fsf_command = req->fsf_command;
756 sbale[1].addr = (void *) req->qtcb;
757 sbale[1].length = sizeof(struct fsf_qtcb);
758 } 717 }
759 718
719 zfcp_qdio_req_init(adapter->qdio, &req->qdio_req, req->req_id, sbtype,
720 req->qtcb, sizeof(struct fsf_qtcb));
721
760 if (!(atomic_read(&adapter->status) & ZFCP_STATUS_ADAPTER_QDIOUP)) { 722 if (!(atomic_read(&adapter->status) & ZFCP_STATUS_ADAPTER_QDIOUP)) {
761 zfcp_fsf_req_free(req); 723 zfcp_fsf_req_free(req);
762 return ERR_PTR(-EIO); 724 return ERR_PTR(-EIO);
@@ -803,24 +765,19 @@ int zfcp_fsf_status_read(struct zfcp_qdio *qdio)
803 struct zfcp_adapter *adapter = qdio->adapter; 765 struct zfcp_adapter *adapter = qdio->adapter;
804 struct zfcp_fsf_req *req; 766 struct zfcp_fsf_req *req;
805 struct fsf_status_read_buffer *sr_buf; 767 struct fsf_status_read_buffer *sr_buf;
806 struct qdio_buffer_element *sbale;
807 int retval = -EIO; 768 int retval = -EIO;
808 769
809 spin_lock_bh(&qdio->req_q_lock); 770 spin_lock_bh(&qdio->req_q_lock);
810 if (zfcp_fsf_req_sbal_get(qdio)) 771 if (zfcp_qdio_sbal_get(qdio))
811 goto out; 772 goto out;
812 773
813 req = zfcp_fsf_req_create(qdio, FSF_QTCB_UNSOLICITED_STATUS, 774 req = zfcp_fsf_req_create(qdio, FSF_QTCB_UNSOLICITED_STATUS, 0,
814 adapter->pool.status_read_req); 775 adapter->pool.status_read_req);
815 if (IS_ERR(req)) { 776 if (IS_ERR(req)) {
816 retval = PTR_ERR(req); 777 retval = PTR_ERR(req);
817 goto out; 778 goto out;
818 } 779 }
819 780
820 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req);
821 sbale[2].flags |= SBAL_FLAGS_LAST_ENTRY;
822 req->qdio_req.sbale_curr = 2;
823
824 sr_buf = mempool_alloc(adapter->pool.status_read_data, GFP_ATOMIC); 781 sr_buf = mempool_alloc(adapter->pool.status_read_data, GFP_ATOMIC);
825 if (!sr_buf) { 782 if (!sr_buf) {
826 retval = -ENOMEM; 783 retval = -ENOMEM;
@@ -828,9 +785,9 @@ int zfcp_fsf_status_read(struct zfcp_qdio *qdio)
828 } 785 }
829 memset(sr_buf, 0, sizeof(*sr_buf)); 786 memset(sr_buf, 0, sizeof(*sr_buf));
830 req->data = sr_buf; 787 req->data = sr_buf;
831 sbale = zfcp_qdio_sbale_curr(qdio, &req->qdio_req); 788
832 sbale->addr = (void *) sr_buf; 789 zfcp_qdio_fill_next(qdio, &req->qdio_req, sr_buf, sizeof(*sr_buf));
833 sbale->length = sizeof(*sr_buf); 790 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
834 791
835 retval = zfcp_fsf_req_send(req); 792 retval = zfcp_fsf_req_send(req);
836 if (retval) 793 if (retval)
@@ -907,14 +864,14 @@ static void zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *req)
907struct zfcp_fsf_req *zfcp_fsf_abort_fcp_command(unsigned long old_req_id, 864struct zfcp_fsf_req *zfcp_fsf_abort_fcp_command(unsigned long old_req_id,
908 struct zfcp_unit *unit) 865 struct zfcp_unit *unit)
909{ 866{
910 struct qdio_buffer_element *sbale;
911 struct zfcp_fsf_req *req = NULL; 867 struct zfcp_fsf_req *req = NULL;
912 struct zfcp_qdio *qdio = unit->port->adapter->qdio; 868 struct zfcp_qdio *qdio = unit->port->adapter->qdio;
913 869
914 spin_lock_bh(&qdio->req_q_lock); 870 spin_lock_bh(&qdio->req_q_lock);
915 if (zfcp_fsf_req_sbal_get(qdio)) 871 if (zfcp_qdio_sbal_get(qdio))
916 goto out; 872 goto out;
917 req = zfcp_fsf_req_create(qdio, FSF_QTCB_ABORT_FCP_CMND, 873 req = zfcp_fsf_req_create(qdio, FSF_QTCB_ABORT_FCP_CMND,
874 SBAL_FLAGS0_TYPE_READ,
918 qdio->adapter->pool.scsi_abort); 875 qdio->adapter->pool.scsi_abort);
919 if (IS_ERR(req)) { 876 if (IS_ERR(req)) {
920 req = NULL; 877 req = NULL;
@@ -925,9 +882,7 @@ struct zfcp_fsf_req *zfcp_fsf_abort_fcp_command(unsigned long old_req_id,
925 ZFCP_STATUS_COMMON_UNBLOCKED))) 882 ZFCP_STATUS_COMMON_UNBLOCKED)))
926 goto out_error_free; 883 goto out_error_free;
927 884
928 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req); 885 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
929 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
930 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
931 886
932 req->data = unit; 887 req->data = unit;
933 req->handler = zfcp_fsf_abort_fcp_command_handler; 888 req->handler = zfcp_fsf_abort_fcp_command_handler;
@@ -996,21 +951,14 @@ skip_fsfstatus:
996 ct->handler(ct->handler_data); 951 ct->handler(ct->handler_data);
997} 952}
998 953
999static void zfcp_fsf_setup_ct_els_unchained(struct qdio_buffer_element *sbale, 954static void zfcp_fsf_setup_ct_els_unchained(struct zfcp_qdio *qdio,
955 struct zfcp_qdio_req *q_req,
1000 struct scatterlist *sg_req, 956 struct scatterlist *sg_req,
1001 struct scatterlist *sg_resp) 957 struct scatterlist *sg_resp)
1002{ 958{
1003 sbale[0].flags |= SBAL_FLAGS0_TYPE_WRITE_READ; 959 zfcp_qdio_fill_next(qdio, q_req, sg_virt(sg_req), sg_req->length);
1004 sbale[2].addr = sg_virt(sg_req); 960 zfcp_qdio_fill_next(qdio, q_req, sg_virt(sg_resp), sg_resp->length);
1005 sbale[2].length = sg_req->length; 961 zfcp_qdio_set_sbale_last(qdio, q_req);
1006 sbale[3].addr = sg_virt(sg_resp);
1007 sbale[3].length = sg_resp->length;
1008 sbale[3].flags |= SBAL_FLAGS_LAST_ENTRY;
1009}
1010
1011static int zfcp_fsf_one_sbal(struct scatterlist *sg)
1012{
1013 return sg_is_last(sg) && sg->length <= PAGE_SIZE;
1014} 962}
1015 963
1016static int zfcp_fsf_setup_ct_els_sbals(struct zfcp_fsf_req *req, 964static int zfcp_fsf_setup_ct_els_sbals(struct zfcp_fsf_req *req,
@@ -1019,35 +967,34 @@ static int zfcp_fsf_setup_ct_els_sbals(struct zfcp_fsf_req *req,
1019 int max_sbals) 967 int max_sbals)
1020{ 968{
1021 struct zfcp_adapter *adapter = req->adapter; 969 struct zfcp_adapter *adapter = req->adapter;
1022 struct qdio_buffer_element *sbale = zfcp_qdio_sbale_req(adapter->qdio,
1023 &req->qdio_req);
1024 u32 feat = adapter->adapter_features; 970 u32 feat = adapter->adapter_features;
1025 int bytes; 971 int bytes;
1026 972
1027 if (!(feat & FSF_FEATURE_ELS_CT_CHAINED_SBALS)) { 973 if (!(feat & FSF_FEATURE_ELS_CT_CHAINED_SBALS)) {
1028 if (!zfcp_fsf_one_sbal(sg_req) || !zfcp_fsf_one_sbal(sg_resp)) 974 if (!zfcp_qdio_sg_one_sbale(sg_req) ||
975 !zfcp_qdio_sg_one_sbale(sg_resp))
1029 return -EOPNOTSUPP; 976 return -EOPNOTSUPP;
1030 977
1031 zfcp_fsf_setup_ct_els_unchained(sbale, sg_req, sg_resp); 978 zfcp_fsf_setup_ct_els_unchained(adapter->qdio, &req->qdio_req,
979 sg_req, sg_resp);
1032 return 0; 980 return 0;
1033 } 981 }
1034 982
1035 /* use single, unchained SBAL if it can hold the request */ 983 /* use single, unchained SBAL if it can hold the request */
1036 if (zfcp_fsf_one_sbal(sg_req) && zfcp_fsf_one_sbal(sg_resp)) { 984 if (zfcp_qdio_sg_one_sbale(sg_req) || zfcp_qdio_sg_one_sbale(sg_resp)) {
1037 zfcp_fsf_setup_ct_els_unchained(sbale, sg_req, sg_resp); 985 zfcp_fsf_setup_ct_els_unchained(adapter->qdio, &req->qdio_req,
986 sg_req, sg_resp);
1038 return 0; 987 return 0;
1039 } 988 }
1040 989
1041 bytes = zfcp_qdio_sbals_from_sg(adapter->qdio, &req->qdio_req, 990 bytes = zfcp_qdio_sbals_from_sg(adapter->qdio, &req->qdio_req,
1042 SBAL_FLAGS0_TYPE_WRITE_READ,
1043 sg_req, max_sbals); 991 sg_req, max_sbals);
1044 if (bytes <= 0) 992 if (bytes <= 0)
1045 return -EIO; 993 return -EIO;
1046 req->qtcb->bottom.support.req_buf_length = bytes; 994 req->qtcb->bottom.support.req_buf_length = bytes;
1047 req->qdio_req.sbale_curr = ZFCP_LAST_SBALE_PER_SBAL; 995 zfcp_qdio_skip_to_last_sbale(&req->qdio_req);
1048 996
1049 bytes = zfcp_qdio_sbals_from_sg(adapter->qdio, &req->qdio_req, 997 bytes = zfcp_qdio_sbals_from_sg(adapter->qdio, &req->qdio_req,
1050 SBAL_FLAGS0_TYPE_WRITE_READ,
1051 sg_resp, max_sbals); 998 sg_resp, max_sbals);
1052 req->qtcb->bottom.support.resp_buf_length = bytes; 999 req->qtcb->bottom.support.resp_buf_length = bytes;
1053 if (bytes <= 0) 1000 if (bytes <= 0)
@@ -1091,10 +1038,11 @@ int zfcp_fsf_send_ct(struct zfcp_fc_wka_port *wka_port,
1091 int ret = -EIO; 1038 int ret = -EIO;
1092 1039
1093 spin_lock_bh(&qdio->req_q_lock); 1040 spin_lock_bh(&qdio->req_q_lock);
1094 if (zfcp_fsf_req_sbal_get(qdio)) 1041 if (zfcp_qdio_sbal_get(qdio))
1095 goto out; 1042 goto out;
1096 1043
1097 req = zfcp_fsf_req_create(qdio, FSF_QTCB_SEND_GENERIC, pool); 1044 req = zfcp_fsf_req_create(qdio, FSF_QTCB_SEND_GENERIC,
1045 SBAL_FLAGS0_TYPE_WRITE_READ, pool);
1098 1046
1099 if (IS_ERR(req)) { 1047 if (IS_ERR(req)) {
1100 ret = PTR_ERR(req); 1048 ret = PTR_ERR(req);
@@ -1103,7 +1051,7 @@ int zfcp_fsf_send_ct(struct zfcp_fc_wka_port *wka_port,
1103 1051
1104 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; 1052 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
1105 ret = zfcp_fsf_setup_ct_els(req, ct->req, ct->resp, 1053 ret = zfcp_fsf_setup_ct_els(req, ct->req, ct->resp,
1106 FSF_MAX_SBALS_PER_REQ, timeout); 1054 ZFCP_FSF_MAX_SBALS_PER_REQ, timeout);
1107 if (ret) 1055 if (ret)
1108 goto failed_send; 1056 goto failed_send;
1109 1057
@@ -1187,10 +1135,11 @@ int zfcp_fsf_send_els(struct zfcp_adapter *adapter, u32 d_id,
1187 int ret = -EIO; 1135 int ret = -EIO;
1188 1136
1189 spin_lock_bh(&qdio->req_q_lock); 1137 spin_lock_bh(&qdio->req_q_lock);
1190 if (zfcp_fsf_req_sbal_get(qdio)) 1138 if (zfcp_qdio_sbal_get(qdio))
1191 goto out; 1139 goto out;
1192 1140
1193 req = zfcp_fsf_req_create(qdio, FSF_QTCB_SEND_ELS, NULL); 1141 req = zfcp_fsf_req_create(qdio, FSF_QTCB_SEND_ELS,
1142 SBAL_FLAGS0_TYPE_WRITE_READ, NULL);
1194 1143
1195 if (IS_ERR(req)) { 1144 if (IS_ERR(req)) {
1196 ret = PTR_ERR(req); 1145 ret = PTR_ERR(req);
@@ -1224,16 +1173,16 @@ out:
1224 1173
1225int zfcp_fsf_exchange_config_data(struct zfcp_erp_action *erp_action) 1174int zfcp_fsf_exchange_config_data(struct zfcp_erp_action *erp_action)
1226{ 1175{
1227 struct qdio_buffer_element *sbale;
1228 struct zfcp_fsf_req *req; 1176 struct zfcp_fsf_req *req;
1229 struct zfcp_qdio *qdio = erp_action->adapter->qdio; 1177 struct zfcp_qdio *qdio = erp_action->adapter->qdio;
1230 int retval = -EIO; 1178 int retval = -EIO;
1231 1179
1232 spin_lock_bh(&qdio->req_q_lock); 1180 spin_lock_bh(&qdio->req_q_lock);
1233 if (zfcp_fsf_req_sbal_get(qdio)) 1181 if (zfcp_qdio_sbal_get(qdio))
1234 goto out; 1182 goto out;
1235 1183
1236 req = zfcp_fsf_req_create(qdio, FSF_QTCB_EXCHANGE_CONFIG_DATA, 1184 req = zfcp_fsf_req_create(qdio, FSF_QTCB_EXCHANGE_CONFIG_DATA,
1185 SBAL_FLAGS0_TYPE_READ,
1237 qdio->adapter->pool.erp_req); 1186 qdio->adapter->pool.erp_req);
1238 1187
1239 if (IS_ERR(req)) { 1188 if (IS_ERR(req)) {
@@ -1242,9 +1191,7 @@ int zfcp_fsf_exchange_config_data(struct zfcp_erp_action *erp_action)
1242 } 1191 }
1243 1192
1244 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; 1193 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
1245 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req); 1194 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
1246 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1247 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1248 1195
1249 req->qtcb->bottom.config.feature_selection = 1196 req->qtcb->bottom.config.feature_selection =
1250 FSF_FEATURE_CFDC | 1197 FSF_FEATURE_CFDC |
@@ -1269,24 +1216,22 @@ out:
1269int zfcp_fsf_exchange_config_data_sync(struct zfcp_qdio *qdio, 1216int zfcp_fsf_exchange_config_data_sync(struct zfcp_qdio *qdio,
1270 struct fsf_qtcb_bottom_config *data) 1217 struct fsf_qtcb_bottom_config *data)
1271{ 1218{
1272 struct qdio_buffer_element *sbale;
1273 struct zfcp_fsf_req *req = NULL; 1219 struct zfcp_fsf_req *req = NULL;
1274 int retval = -EIO; 1220 int retval = -EIO;
1275 1221
1276 spin_lock_bh(&qdio->req_q_lock); 1222 spin_lock_bh(&qdio->req_q_lock);
1277 if (zfcp_fsf_req_sbal_get(qdio)) 1223 if (zfcp_qdio_sbal_get(qdio))
1278 goto out_unlock; 1224 goto out_unlock;
1279 1225
1280 req = zfcp_fsf_req_create(qdio, FSF_QTCB_EXCHANGE_CONFIG_DATA, NULL); 1226 req = zfcp_fsf_req_create(qdio, FSF_QTCB_EXCHANGE_CONFIG_DATA,
1227 SBAL_FLAGS0_TYPE_READ, NULL);
1281 1228
1282 if (IS_ERR(req)) { 1229 if (IS_ERR(req)) {
1283 retval = PTR_ERR(req); 1230 retval = PTR_ERR(req);
1284 goto out_unlock; 1231 goto out_unlock;
1285 } 1232 }
1286 1233
1287 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req); 1234 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
1288 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1289 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1290 req->handler = zfcp_fsf_exchange_config_data_handler; 1235 req->handler = zfcp_fsf_exchange_config_data_handler;
1291 1236
1292 req->qtcb->bottom.config.feature_selection = 1237 req->qtcb->bottom.config.feature_selection =
@@ -1320,7 +1265,6 @@ out_unlock:
1320int zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action) 1265int zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action)
1321{ 1266{
1322 struct zfcp_qdio *qdio = erp_action->adapter->qdio; 1267 struct zfcp_qdio *qdio = erp_action->adapter->qdio;
1323 struct qdio_buffer_element *sbale;
1324 struct zfcp_fsf_req *req; 1268 struct zfcp_fsf_req *req;
1325 int retval = -EIO; 1269 int retval = -EIO;
1326 1270
@@ -1328,10 +1272,11 @@ int zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action)
1328 return -EOPNOTSUPP; 1272 return -EOPNOTSUPP;
1329 1273
1330 spin_lock_bh(&qdio->req_q_lock); 1274 spin_lock_bh(&qdio->req_q_lock);
1331 if (zfcp_fsf_req_sbal_get(qdio)) 1275 if (zfcp_qdio_sbal_get(qdio))
1332 goto out; 1276 goto out;
1333 1277
1334 req = zfcp_fsf_req_create(qdio, FSF_QTCB_EXCHANGE_PORT_DATA, 1278 req = zfcp_fsf_req_create(qdio, FSF_QTCB_EXCHANGE_PORT_DATA,
1279 SBAL_FLAGS0_TYPE_READ,
1335 qdio->adapter->pool.erp_req); 1280 qdio->adapter->pool.erp_req);
1336 1281
1337 if (IS_ERR(req)) { 1282 if (IS_ERR(req)) {
@@ -1340,9 +1285,7 @@ int zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action)
1340 } 1285 }
1341 1286
1342 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; 1287 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
1343 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req); 1288 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
1344 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1345 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1346 1289
1347 req->handler = zfcp_fsf_exchange_port_data_handler; 1290 req->handler = zfcp_fsf_exchange_port_data_handler;
1348 req->erp_action = erp_action; 1291 req->erp_action = erp_action;
@@ -1368,7 +1311,6 @@ out:
1368int zfcp_fsf_exchange_port_data_sync(struct zfcp_qdio *qdio, 1311int zfcp_fsf_exchange_port_data_sync(struct zfcp_qdio *qdio,
1369 struct fsf_qtcb_bottom_port *data) 1312 struct fsf_qtcb_bottom_port *data)
1370{ 1313{
1371 struct qdio_buffer_element *sbale;
1372 struct zfcp_fsf_req *req = NULL; 1314 struct zfcp_fsf_req *req = NULL;
1373 int retval = -EIO; 1315 int retval = -EIO;
1374 1316
@@ -1376,10 +1318,11 @@ int zfcp_fsf_exchange_port_data_sync(struct zfcp_qdio *qdio,
1376 return -EOPNOTSUPP; 1318 return -EOPNOTSUPP;
1377 1319
1378 spin_lock_bh(&qdio->req_q_lock); 1320 spin_lock_bh(&qdio->req_q_lock);
1379 if (zfcp_fsf_req_sbal_get(qdio)) 1321 if (zfcp_qdio_sbal_get(qdio))
1380 goto out_unlock; 1322 goto out_unlock;
1381 1323
1382 req = zfcp_fsf_req_create(qdio, FSF_QTCB_EXCHANGE_PORT_DATA, NULL); 1324 req = zfcp_fsf_req_create(qdio, FSF_QTCB_EXCHANGE_PORT_DATA,
1325 SBAL_FLAGS0_TYPE_READ, NULL);
1383 1326
1384 if (IS_ERR(req)) { 1327 if (IS_ERR(req)) {
1385 retval = PTR_ERR(req); 1328 retval = PTR_ERR(req);
@@ -1389,9 +1332,7 @@ int zfcp_fsf_exchange_port_data_sync(struct zfcp_qdio *qdio,
1389 if (data) 1332 if (data)
1390 req->data = data; 1333 req->data = data;
1391 1334
1392 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req); 1335 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
1393 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1394 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1395 1336
1396 req->handler = zfcp_fsf_exchange_port_data_handler; 1337 req->handler = zfcp_fsf_exchange_port_data_handler;
1397 zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT); 1338 zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT);
@@ -1485,17 +1426,17 @@ out:
1485 */ 1426 */
1486int zfcp_fsf_open_port(struct zfcp_erp_action *erp_action) 1427int zfcp_fsf_open_port(struct zfcp_erp_action *erp_action)
1487{ 1428{
1488 struct qdio_buffer_element *sbale;
1489 struct zfcp_qdio *qdio = erp_action->adapter->qdio; 1429 struct zfcp_qdio *qdio = erp_action->adapter->qdio;
1490 struct zfcp_port *port = erp_action->port; 1430 struct zfcp_port *port = erp_action->port;
1491 struct zfcp_fsf_req *req; 1431 struct zfcp_fsf_req *req;
1492 int retval = -EIO; 1432 int retval = -EIO;
1493 1433
1494 spin_lock_bh(&qdio->req_q_lock); 1434 spin_lock_bh(&qdio->req_q_lock);
1495 if (zfcp_fsf_req_sbal_get(qdio)) 1435 if (zfcp_qdio_sbal_get(qdio))
1496 goto out; 1436 goto out;
1497 1437
1498 req = zfcp_fsf_req_create(qdio, FSF_QTCB_OPEN_PORT_WITH_DID, 1438 req = zfcp_fsf_req_create(qdio, FSF_QTCB_OPEN_PORT_WITH_DID,
1439 SBAL_FLAGS0_TYPE_READ,
1499 qdio->adapter->pool.erp_req); 1440 qdio->adapter->pool.erp_req);
1500 1441
1501 if (IS_ERR(req)) { 1442 if (IS_ERR(req)) {
@@ -1504,9 +1445,7 @@ int zfcp_fsf_open_port(struct zfcp_erp_action *erp_action)
1504 } 1445 }
1505 1446
1506 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; 1447 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
1507 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req); 1448 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
1508 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1509 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1510 1449
1511 req->handler = zfcp_fsf_open_port_handler; 1450 req->handler = zfcp_fsf_open_port_handler;
1512 hton24(req->qtcb->bottom.support.d_id, port->d_id); 1451 hton24(req->qtcb->bottom.support.d_id, port->d_id);
@@ -1556,16 +1495,16 @@ static void zfcp_fsf_close_port_handler(struct zfcp_fsf_req *req)
1556 */ 1495 */
1557int zfcp_fsf_close_port(struct zfcp_erp_action *erp_action) 1496int zfcp_fsf_close_port(struct zfcp_erp_action *erp_action)
1558{ 1497{
1559 struct qdio_buffer_element *sbale;
1560 struct zfcp_qdio *qdio = erp_action->adapter->qdio; 1498 struct zfcp_qdio *qdio = erp_action->adapter->qdio;
1561 struct zfcp_fsf_req *req; 1499 struct zfcp_fsf_req *req;
1562 int retval = -EIO; 1500 int retval = -EIO;
1563 1501
1564 spin_lock_bh(&qdio->req_q_lock); 1502 spin_lock_bh(&qdio->req_q_lock);
1565 if (zfcp_fsf_req_sbal_get(qdio)) 1503 if (zfcp_qdio_sbal_get(qdio))
1566 goto out; 1504 goto out;
1567 1505
1568 req = zfcp_fsf_req_create(qdio, FSF_QTCB_CLOSE_PORT, 1506 req = zfcp_fsf_req_create(qdio, FSF_QTCB_CLOSE_PORT,
1507 SBAL_FLAGS0_TYPE_READ,
1569 qdio->adapter->pool.erp_req); 1508 qdio->adapter->pool.erp_req);
1570 1509
1571 if (IS_ERR(req)) { 1510 if (IS_ERR(req)) {
@@ -1574,9 +1513,7 @@ int zfcp_fsf_close_port(struct zfcp_erp_action *erp_action)
1574 } 1513 }
1575 1514
1576 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; 1515 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
1577 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req); 1516 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
1578 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1579 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1580 1517
1581 req->handler = zfcp_fsf_close_port_handler; 1518 req->handler = zfcp_fsf_close_port_handler;
1582 req->data = erp_action->port; 1519 req->data = erp_action->port;
@@ -1633,16 +1570,16 @@ out:
1633 */ 1570 */
1634int zfcp_fsf_open_wka_port(struct zfcp_fc_wka_port *wka_port) 1571int zfcp_fsf_open_wka_port(struct zfcp_fc_wka_port *wka_port)
1635{ 1572{
1636 struct qdio_buffer_element *sbale;
1637 struct zfcp_qdio *qdio = wka_port->adapter->qdio; 1573 struct zfcp_qdio *qdio = wka_port->adapter->qdio;
1638 struct zfcp_fsf_req *req; 1574 struct zfcp_fsf_req *req;
1639 int retval = -EIO; 1575 int retval = -EIO;
1640 1576
1641 spin_lock_bh(&qdio->req_q_lock); 1577 spin_lock_bh(&qdio->req_q_lock);
1642 if (zfcp_fsf_req_sbal_get(qdio)) 1578 if (zfcp_qdio_sbal_get(qdio))
1643 goto out; 1579 goto out;
1644 1580
1645 req = zfcp_fsf_req_create(qdio, FSF_QTCB_OPEN_PORT_WITH_DID, 1581 req = zfcp_fsf_req_create(qdio, FSF_QTCB_OPEN_PORT_WITH_DID,
1582 SBAL_FLAGS0_TYPE_READ,
1646 qdio->adapter->pool.erp_req); 1583 qdio->adapter->pool.erp_req);
1647 1584
1648 if (unlikely(IS_ERR(req))) { 1585 if (unlikely(IS_ERR(req))) {
@@ -1651,9 +1588,7 @@ int zfcp_fsf_open_wka_port(struct zfcp_fc_wka_port *wka_port)
1651 } 1588 }
1652 1589
1653 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; 1590 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
1654 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req); 1591 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
1655 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1656 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1657 1592
1658 req->handler = zfcp_fsf_open_wka_port_handler; 1593 req->handler = zfcp_fsf_open_wka_port_handler;
1659 hton24(req->qtcb->bottom.support.d_id, wka_port->d_id); 1594 hton24(req->qtcb->bottom.support.d_id, wka_port->d_id);
@@ -1688,16 +1623,16 @@ static void zfcp_fsf_close_wka_port_handler(struct zfcp_fsf_req *req)
1688 */ 1623 */
1689int zfcp_fsf_close_wka_port(struct zfcp_fc_wka_port *wka_port) 1624int zfcp_fsf_close_wka_port(struct zfcp_fc_wka_port *wka_port)
1690{ 1625{
1691 struct qdio_buffer_element *sbale;
1692 struct zfcp_qdio *qdio = wka_port->adapter->qdio; 1626 struct zfcp_qdio *qdio = wka_port->adapter->qdio;
1693 struct zfcp_fsf_req *req; 1627 struct zfcp_fsf_req *req;
1694 int retval = -EIO; 1628 int retval = -EIO;
1695 1629
1696 spin_lock_bh(&qdio->req_q_lock); 1630 spin_lock_bh(&qdio->req_q_lock);
1697 if (zfcp_fsf_req_sbal_get(qdio)) 1631 if (zfcp_qdio_sbal_get(qdio))
1698 goto out; 1632 goto out;
1699 1633
1700 req = zfcp_fsf_req_create(qdio, FSF_QTCB_CLOSE_PORT, 1634 req = zfcp_fsf_req_create(qdio, FSF_QTCB_CLOSE_PORT,
1635 SBAL_FLAGS0_TYPE_READ,
1701 qdio->adapter->pool.erp_req); 1636 qdio->adapter->pool.erp_req);
1702 1637
1703 if (unlikely(IS_ERR(req))) { 1638 if (unlikely(IS_ERR(req))) {
@@ -1706,9 +1641,7 @@ int zfcp_fsf_close_wka_port(struct zfcp_fc_wka_port *wka_port)
1706 } 1641 }
1707 1642
1708 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; 1643 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
1709 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req); 1644 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
1710 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1711 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1712 1645
1713 req->handler = zfcp_fsf_close_wka_port_handler; 1646 req->handler = zfcp_fsf_close_wka_port_handler;
1714 req->data = wka_port; 1647 req->data = wka_port;
@@ -1782,16 +1715,16 @@ static void zfcp_fsf_close_physical_port_handler(struct zfcp_fsf_req *req)
1782 */ 1715 */
1783int zfcp_fsf_close_physical_port(struct zfcp_erp_action *erp_action) 1716int zfcp_fsf_close_physical_port(struct zfcp_erp_action *erp_action)
1784{ 1717{
1785 struct qdio_buffer_element *sbale;
1786 struct zfcp_qdio *qdio = erp_action->adapter->qdio; 1718 struct zfcp_qdio *qdio = erp_action->adapter->qdio;
1787 struct zfcp_fsf_req *req; 1719 struct zfcp_fsf_req *req;
1788 int retval = -EIO; 1720 int retval = -EIO;
1789 1721
1790 spin_lock_bh(&qdio->req_q_lock); 1722 spin_lock_bh(&qdio->req_q_lock);
1791 if (zfcp_fsf_req_sbal_get(qdio)) 1723 if (zfcp_qdio_sbal_get(qdio))
1792 goto out; 1724 goto out;
1793 1725
1794 req = zfcp_fsf_req_create(qdio, FSF_QTCB_CLOSE_PHYSICAL_PORT, 1726 req = zfcp_fsf_req_create(qdio, FSF_QTCB_CLOSE_PHYSICAL_PORT,
1727 SBAL_FLAGS0_TYPE_READ,
1795 qdio->adapter->pool.erp_req); 1728 qdio->adapter->pool.erp_req);
1796 1729
1797 if (IS_ERR(req)) { 1730 if (IS_ERR(req)) {
@@ -1800,9 +1733,7 @@ int zfcp_fsf_close_physical_port(struct zfcp_erp_action *erp_action)
1800 } 1733 }
1801 1734
1802 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; 1735 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
1803 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req); 1736 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
1804 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1805 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1806 1737
1807 req->data = erp_action->port; 1738 req->data = erp_action->port;
1808 req->qtcb->header.port_handle = erp_action->port->handle; 1739 req->qtcb->header.port_handle = erp_action->port->handle;
@@ -1954,17 +1885,17 @@ static void zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *req)
1954 */ 1885 */
1955int zfcp_fsf_open_unit(struct zfcp_erp_action *erp_action) 1886int zfcp_fsf_open_unit(struct zfcp_erp_action *erp_action)
1956{ 1887{
1957 struct qdio_buffer_element *sbale;
1958 struct zfcp_adapter *adapter = erp_action->adapter; 1888 struct zfcp_adapter *adapter = erp_action->adapter;
1959 struct zfcp_qdio *qdio = adapter->qdio; 1889 struct zfcp_qdio *qdio = adapter->qdio;
1960 struct zfcp_fsf_req *req; 1890 struct zfcp_fsf_req *req;
1961 int retval = -EIO; 1891 int retval = -EIO;
1962 1892
1963 spin_lock_bh(&qdio->req_q_lock); 1893 spin_lock_bh(&qdio->req_q_lock);
1964 if (zfcp_fsf_req_sbal_get(qdio)) 1894 if (zfcp_qdio_sbal_get(qdio))
1965 goto out; 1895 goto out;
1966 1896
1967 req = zfcp_fsf_req_create(qdio, FSF_QTCB_OPEN_LUN, 1897 req = zfcp_fsf_req_create(qdio, FSF_QTCB_OPEN_LUN,
1898 SBAL_FLAGS0_TYPE_READ,
1968 adapter->pool.erp_req); 1899 adapter->pool.erp_req);
1969 1900
1970 if (IS_ERR(req)) { 1901 if (IS_ERR(req)) {
@@ -1973,9 +1904,7 @@ int zfcp_fsf_open_unit(struct zfcp_erp_action *erp_action)
1973 } 1904 }
1974 1905
1975 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; 1906 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
1976 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req); 1907 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
1977 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1978 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1979 1908
1980 req->qtcb->header.port_handle = erp_action->port->handle; 1909 req->qtcb->header.port_handle = erp_action->port->handle;
1981 req->qtcb->bottom.support.fcp_lun = erp_action->unit->fcp_lun; 1910 req->qtcb->bottom.support.fcp_lun = erp_action->unit->fcp_lun;
@@ -2041,16 +1970,16 @@ static void zfcp_fsf_close_unit_handler(struct zfcp_fsf_req *req)
2041 */ 1970 */
2042int zfcp_fsf_close_unit(struct zfcp_erp_action *erp_action) 1971int zfcp_fsf_close_unit(struct zfcp_erp_action *erp_action)
2043{ 1972{
2044 struct qdio_buffer_element *sbale;
2045 struct zfcp_qdio *qdio = erp_action->adapter->qdio; 1973 struct zfcp_qdio *qdio = erp_action->adapter->qdio;
2046 struct zfcp_fsf_req *req; 1974 struct zfcp_fsf_req *req;
2047 int retval = -EIO; 1975 int retval = -EIO;
2048 1976
2049 spin_lock_bh(&qdio->req_q_lock); 1977 spin_lock_bh(&qdio->req_q_lock);
2050 if (zfcp_fsf_req_sbal_get(qdio)) 1978 if (zfcp_qdio_sbal_get(qdio))
2051 goto out; 1979 goto out;
2052 1980
2053 req = zfcp_fsf_req_create(qdio, FSF_QTCB_CLOSE_LUN, 1981 req = zfcp_fsf_req_create(qdio, FSF_QTCB_CLOSE_LUN,
1982 SBAL_FLAGS0_TYPE_READ,
2054 qdio->adapter->pool.erp_req); 1983 qdio->adapter->pool.erp_req);
2055 1984
2056 if (IS_ERR(req)) { 1985 if (IS_ERR(req)) {
@@ -2059,9 +1988,7 @@ int zfcp_fsf_close_unit(struct zfcp_erp_action *erp_action)
2059 } 1988 }
2060 1989
2061 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; 1990 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
2062 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req); 1991 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
2063 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
2064 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
2065 1992
2066 req->qtcb->header.port_handle = erp_action->port->handle; 1993 req->qtcb->header.port_handle = erp_action->port->handle;
2067 req->qtcb->header.lun_handle = erp_action->unit->handle; 1994 req->qtcb->header.lun_handle = erp_action->unit->handle;
@@ -2289,8 +2216,11 @@ int zfcp_fsf_send_fcp_command_task(struct zfcp_unit *unit,
2289 goto out; 2216 goto out;
2290 } 2217 }
2291 2218
2219 if (scsi_cmnd->sc_data_direction == DMA_TO_DEVICE)
2220 sbtype = SBAL_FLAGS0_TYPE_WRITE;
2221
2292 req = zfcp_fsf_req_create(qdio, FSF_QTCB_FCP_CMND, 2222 req = zfcp_fsf_req_create(qdio, FSF_QTCB_FCP_CMND,
2293 adapter->pool.scsi_req); 2223 sbtype, adapter->pool.scsi_req);
2294 2224
2295 if (IS_ERR(req)) { 2225 if (IS_ERR(req)) {
2296 retval = PTR_ERR(req); 2226 retval = PTR_ERR(req);
@@ -2298,7 +2228,6 @@ int zfcp_fsf_send_fcp_command_task(struct zfcp_unit *unit,
2298 } 2228 }
2299 2229
2300 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; 2230 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
2301 get_device(&unit->dev);
2302 req->unit = unit; 2231 req->unit = unit;
2303 req->data = scsi_cmnd; 2232 req->data = scsi_cmnd;
2304 req->handler = zfcp_fsf_send_fcp_command_handler; 2233 req->handler = zfcp_fsf_send_fcp_command_handler;
@@ -2323,20 +2252,21 @@ int zfcp_fsf_send_fcp_command_task(struct zfcp_unit *unit,
2323 break; 2252 break;
2324 case DMA_TO_DEVICE: 2253 case DMA_TO_DEVICE:
2325 req->qtcb->bottom.io.data_direction = FSF_DATADIR_WRITE; 2254 req->qtcb->bottom.io.data_direction = FSF_DATADIR_WRITE;
2326 sbtype = SBAL_FLAGS0_TYPE_WRITE;
2327 break; 2255 break;
2328 case DMA_BIDIRECTIONAL: 2256 case DMA_BIDIRECTIONAL:
2329 goto failed_scsi_cmnd; 2257 goto failed_scsi_cmnd;
2330 } 2258 }
2331 2259
2260 get_device(&unit->dev);
2261
2332 fcp_cmnd = (struct fcp_cmnd *) &req->qtcb->bottom.io.fcp_cmnd; 2262 fcp_cmnd = (struct fcp_cmnd *) &req->qtcb->bottom.io.fcp_cmnd;
2333 zfcp_fc_scsi_to_fcp(fcp_cmnd, scsi_cmnd); 2263 zfcp_fc_scsi_to_fcp(fcp_cmnd, scsi_cmnd);
2334 2264
2335 real_bytes = zfcp_qdio_sbals_from_sg(qdio, &req->qdio_req, sbtype, 2265 real_bytes = zfcp_qdio_sbals_from_sg(qdio, &req->qdio_req,
2336 scsi_sglist(scsi_cmnd), 2266 scsi_sglist(scsi_cmnd),
2337 FSF_MAX_SBALS_PER_REQ); 2267 ZFCP_FSF_MAX_SBALS_PER_REQ);
2338 if (unlikely(real_bytes < 0)) { 2268 if (unlikely(real_bytes < 0)) {
2339 if (req->qdio_req.sbal_number >= FSF_MAX_SBALS_PER_REQ) { 2269 if (req->qdio_req.sbal_number >= ZFCP_FSF_MAX_SBALS_PER_REQ) {
2340 dev_err(&adapter->ccw_device->dev, 2270 dev_err(&adapter->ccw_device->dev,
2341 "Oversize data package, unit 0x%016Lx " 2271 "Oversize data package, unit 0x%016Lx "
2342 "on port 0x%016Lx closed\n", 2272 "on port 0x%016Lx closed\n",
@@ -2371,7 +2301,6 @@ out:
2371 */ 2301 */
2372struct zfcp_fsf_req *zfcp_fsf_send_fcp_ctm(struct zfcp_unit *unit, u8 tm_flags) 2302struct zfcp_fsf_req *zfcp_fsf_send_fcp_ctm(struct zfcp_unit *unit, u8 tm_flags)
2373{ 2303{
2374 struct qdio_buffer_element *sbale;
2375 struct zfcp_fsf_req *req = NULL; 2304 struct zfcp_fsf_req *req = NULL;
2376 struct fcp_cmnd *fcp_cmnd; 2305 struct fcp_cmnd *fcp_cmnd;
2377 struct zfcp_qdio *qdio = unit->port->adapter->qdio; 2306 struct zfcp_qdio *qdio = unit->port->adapter->qdio;
@@ -2381,10 +2310,11 @@ struct zfcp_fsf_req *zfcp_fsf_send_fcp_ctm(struct zfcp_unit *unit, u8 tm_flags)
2381 return NULL; 2310 return NULL;
2382 2311
2383 spin_lock_bh(&qdio->req_q_lock); 2312 spin_lock_bh(&qdio->req_q_lock);
2384 if (zfcp_fsf_req_sbal_get(qdio)) 2313 if (zfcp_qdio_sbal_get(qdio))
2385 goto out; 2314 goto out;
2386 2315
2387 req = zfcp_fsf_req_create(qdio, FSF_QTCB_FCP_CMND, 2316 req = zfcp_fsf_req_create(qdio, FSF_QTCB_FCP_CMND,
2317 SBAL_FLAGS0_TYPE_WRITE,
2388 qdio->adapter->pool.scsi_req); 2318 qdio->adapter->pool.scsi_req);
2389 2319
2390 if (IS_ERR(req)) { 2320 if (IS_ERR(req)) {
@@ -2401,9 +2331,7 @@ struct zfcp_fsf_req *zfcp_fsf_send_fcp_ctm(struct zfcp_unit *unit, u8 tm_flags)
2401 req->qtcb->bottom.io.service_class = FSF_CLASS_3; 2331 req->qtcb->bottom.io.service_class = FSF_CLASS_3;
2402 req->qtcb->bottom.io.fcp_cmnd_length = FCP_CMND_LEN; 2332 req->qtcb->bottom.io.fcp_cmnd_length = FCP_CMND_LEN;
2403 2333
2404 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req); 2334 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
2405 sbale[0].flags |= SBAL_FLAGS0_TYPE_WRITE;
2406 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
2407 2335
2408 fcp_cmnd = (struct fcp_cmnd *) &req->qtcb->bottom.io.fcp_cmnd; 2336 fcp_cmnd = (struct fcp_cmnd *) &req->qtcb->bottom.io.fcp_cmnd;
2409 zfcp_fc_fcp_tm(fcp_cmnd, unit->device, tm_flags); 2337 zfcp_fc_fcp_tm(fcp_cmnd, unit->device, tm_flags);
@@ -2432,7 +2360,6 @@ static void zfcp_fsf_control_file_handler(struct zfcp_fsf_req *req)
2432struct zfcp_fsf_req *zfcp_fsf_control_file(struct zfcp_adapter *adapter, 2360struct zfcp_fsf_req *zfcp_fsf_control_file(struct zfcp_adapter *adapter,
2433 struct zfcp_fsf_cfdc *fsf_cfdc) 2361 struct zfcp_fsf_cfdc *fsf_cfdc)
2434{ 2362{
2435 struct qdio_buffer_element *sbale;
2436 struct zfcp_qdio *qdio = adapter->qdio; 2363 struct zfcp_qdio *qdio = adapter->qdio;
2437 struct zfcp_fsf_req *req = NULL; 2364 struct zfcp_fsf_req *req = NULL;
2438 struct fsf_qtcb_bottom_support *bottom; 2365 struct fsf_qtcb_bottom_support *bottom;
@@ -2453,10 +2380,10 @@ struct zfcp_fsf_req *zfcp_fsf_control_file(struct zfcp_adapter *adapter,
2453 } 2380 }
2454 2381
2455 spin_lock_bh(&qdio->req_q_lock); 2382 spin_lock_bh(&qdio->req_q_lock);
2456 if (zfcp_fsf_req_sbal_get(qdio)) 2383 if (zfcp_qdio_sbal_get(qdio))
2457 goto out; 2384 goto out;
2458 2385
2459 req = zfcp_fsf_req_create(qdio, fsf_cfdc->command, NULL); 2386 req = zfcp_fsf_req_create(qdio, fsf_cfdc->command, direction, NULL);
2460 if (IS_ERR(req)) { 2387 if (IS_ERR(req)) {
2461 retval = -EPERM; 2388 retval = -EPERM;
2462 goto out; 2389 goto out;
@@ -2464,16 +2391,13 @@ struct zfcp_fsf_req *zfcp_fsf_control_file(struct zfcp_adapter *adapter,
2464 2391
2465 req->handler = zfcp_fsf_control_file_handler; 2392 req->handler = zfcp_fsf_control_file_handler;
2466 2393
2467 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req);
2468 sbale[0].flags |= direction;
2469
2470 bottom = &req->qtcb->bottom.support; 2394 bottom = &req->qtcb->bottom.support;
2471 bottom->operation_subtype = FSF_CFDC_OPERATION_SUBTYPE; 2395 bottom->operation_subtype = FSF_CFDC_OPERATION_SUBTYPE;
2472 bottom->option = fsf_cfdc->option; 2396 bottom->option = fsf_cfdc->option;
2473 2397
2474 bytes = zfcp_qdio_sbals_from_sg(qdio, &req->qdio_req, 2398 bytes = zfcp_qdio_sbals_from_sg(qdio, &req->qdio_req,
2475 direction, fsf_cfdc->sg, 2399 fsf_cfdc->sg,
2476 FSF_MAX_SBALS_PER_REQ); 2400 ZFCP_FSF_MAX_SBALS_PER_REQ);
2477 if (bytes != ZFCP_CFDC_MAX_SIZE) { 2401 if (bytes != ZFCP_CFDC_MAX_SIZE) {
2478 zfcp_fsf_req_free(req); 2402 zfcp_fsf_req_free(req);
2479 goto out; 2403 goto out;
diff --git a/drivers/s390/scsi/zfcp_fsf.h b/drivers/s390/scsi/zfcp_fsf.h
index b3de682b64c..519083fd6e8 100644
--- a/drivers/s390/scsi/zfcp_fsf.h
+++ b/drivers/s390/scsi/zfcp_fsf.h
@@ -3,7 +3,7 @@
3 * 3 *
4 * Interface to the FSF support functions. 4 * Interface to the FSF support functions.
5 * 5 *
6 * Copyright IBM Corporation 2002, 2009 6 * Copyright IBM Corporation 2002, 2010
7 */ 7 */
8 8
9#ifndef FSF_H 9#ifndef FSF_H
@@ -152,7 +152,12 @@
152#define FSF_CLASS_3 0x00000003 152#define FSF_CLASS_3 0x00000003
153 153
154/* SBAL chaining */ 154/* SBAL chaining */
155#define FSF_MAX_SBALS_PER_REQ 36 155#define ZFCP_FSF_MAX_SBALS_PER_REQ 36
156
157/* max. number of (data buffer) SBALEs in largest SBAL chain
158 * request ID + QTCB in SBALE 0 + 1 of first SBAL in chain */
159#define ZFCP_FSF_MAX_SBALES_PER_REQ \
160 (ZFCP_FSF_MAX_SBALS_PER_REQ * ZFCP_QDIO_MAX_SBALES_PER_SBAL - 2)
156 161
157/* logging space behind QTCB */ 162/* logging space behind QTCB */
158#define FSF_QTCB_LOG_SIZE 1024 163#define FSF_QTCB_LOG_SIZE 1024
@@ -361,7 +366,7 @@ struct fsf_qtcb_bottom_config {
361 u32 adapter_type; 366 u32 adapter_type;
362 u8 res0; 367 u8 res0;
363 u8 peer_d_id[3]; 368 u8 peer_d_id[3];
364 u8 res1[2]; 369 u16 status_read_buf_num;
365 u16 timer_interval; 370 u16 timer_interval;
366 u8 res2[9]; 371 u8 res2[9];
367 u8 s_id[3]; 372 u8 s_id[3];
diff --git a/drivers/s390/scsi/zfcp_qdio.c b/drivers/s390/scsi/zfcp_qdio.c
index dbfa312a7f5..28117e130e2 100644
--- a/drivers/s390/scsi/zfcp_qdio.c
+++ b/drivers/s390/scsi/zfcp_qdio.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Setup and helper functions to access QDIO. 4 * Setup and helper functions to access QDIO.
5 * 5 *
6 * Copyright IBM Corporation 2002, 2009 6 * Copyright IBM Corporation 2002, 2010
7 */ 7 */
8 8
9#define KMSG_COMPONENT "zfcp" 9#define KMSG_COMPONENT "zfcp"
@@ -151,8 +151,7 @@ static void zfcp_qdio_sbal_limit(struct zfcp_qdio *qdio,
151} 151}
152 152
153static struct qdio_buffer_element * 153static struct qdio_buffer_element *
154zfcp_qdio_sbal_chain(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req, 154zfcp_qdio_sbal_chain(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req)
155 unsigned long sbtype)
156{ 155{
157 struct qdio_buffer_element *sbale; 156 struct qdio_buffer_element *sbale;
158 157
@@ -180,17 +179,16 @@ zfcp_qdio_sbal_chain(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req,
180 179
181 /* set storage-block type for new SBAL */ 180 /* set storage-block type for new SBAL */
182 sbale = zfcp_qdio_sbale_curr(qdio, q_req); 181 sbale = zfcp_qdio_sbale_curr(qdio, q_req);
183 sbale->flags |= sbtype; 182 sbale->flags |= q_req->sbtype;
184 183
185 return sbale; 184 return sbale;
186} 185}
187 186
188static struct qdio_buffer_element * 187static struct qdio_buffer_element *
189zfcp_qdio_sbale_next(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req, 188zfcp_qdio_sbale_next(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req)
190 unsigned int sbtype)
191{ 189{
192 if (q_req->sbale_curr == ZFCP_LAST_SBALE_PER_SBAL) 190 if (q_req->sbale_curr == ZFCP_QDIO_LAST_SBALE_PER_SBAL)
193 return zfcp_qdio_sbal_chain(qdio, q_req, sbtype); 191 return zfcp_qdio_sbal_chain(qdio, q_req);
194 q_req->sbale_curr++; 192 q_req->sbale_curr++;
195 return zfcp_qdio_sbale_curr(qdio, q_req); 193 return zfcp_qdio_sbale_curr(qdio, q_req);
196} 194}
@@ -206,62 +204,38 @@ static void zfcp_qdio_undo_sbals(struct zfcp_qdio *qdio,
206 zfcp_qdio_zero_sbals(sbal, first, count); 204 zfcp_qdio_zero_sbals(sbal, first, count);
207} 205}
208 206
209static int zfcp_qdio_fill_sbals(struct zfcp_qdio *qdio,
210 struct zfcp_qdio_req *q_req,
211 unsigned int sbtype, void *start_addr,
212 unsigned int total_length)
213{
214 struct qdio_buffer_element *sbale;
215 unsigned long remaining, length;
216 void *addr;
217
218 /* split segment up */
219 for (addr = start_addr, remaining = total_length; remaining > 0;
220 addr += length, remaining -= length) {
221 sbale = zfcp_qdio_sbale_next(qdio, q_req, sbtype);
222 if (!sbale) {
223 atomic_inc(&qdio->req_q_full);
224 zfcp_qdio_undo_sbals(qdio, q_req);
225 return -EINVAL;
226 }
227
228 /* new piece must not exceed next page boundary */
229 length = min(remaining,
230 (PAGE_SIZE - ((unsigned long)addr &
231 (PAGE_SIZE - 1))));
232 sbale->addr = addr;
233 sbale->length = length;
234 }
235 return 0;
236}
237
238/** 207/**
239 * zfcp_qdio_sbals_from_sg - fill SBALs from scatter-gather list 208 * zfcp_qdio_sbals_from_sg - fill SBALs from scatter-gather list
240 * @fsf_req: request to be processed 209 * @qdio: pointer to struct zfcp_qdio
241 * @sbtype: SBALE flags 210 * @q_req: pointer to struct zfcp_qdio_req
242 * @sg: scatter-gather list 211 * @sg: scatter-gather list
243 * @max_sbals: upper bound for number of SBALs to be used 212 * @max_sbals: upper bound for number of SBALs to be used
244 * Returns: number of bytes, or error (negativ) 213 * Returns: number of bytes, or error (negativ)
245 */ 214 */
246int zfcp_qdio_sbals_from_sg(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req, 215int zfcp_qdio_sbals_from_sg(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req,
247 unsigned long sbtype, struct scatterlist *sg, 216 struct scatterlist *sg, int max_sbals)
248 int max_sbals)
249{ 217{
250 struct qdio_buffer_element *sbale; 218 struct qdio_buffer_element *sbale;
251 int retval, bytes = 0; 219 int bytes = 0;
252 220
253 /* figure out last allowed SBAL */ 221 /* figure out last allowed SBAL */
254 zfcp_qdio_sbal_limit(qdio, q_req, max_sbals); 222 zfcp_qdio_sbal_limit(qdio, q_req, max_sbals);
255 223
256 /* set storage-block type for this request */ 224 /* set storage-block type for this request */
257 sbale = zfcp_qdio_sbale_req(qdio, q_req); 225 sbale = zfcp_qdio_sbale_req(qdio, q_req);
258 sbale->flags |= sbtype; 226 sbale->flags |= q_req->sbtype;
259 227
260 for (; sg; sg = sg_next(sg)) { 228 for (; sg; sg = sg_next(sg)) {
261 retval = zfcp_qdio_fill_sbals(qdio, q_req, sbtype, 229 sbale = zfcp_qdio_sbale_next(qdio, q_req);
262 sg_virt(sg), sg->length); 230 if (!sbale) {
263 if (retval < 0) 231 atomic_inc(&qdio->req_q_full);
264 return retval; 232 zfcp_qdio_undo_sbals(qdio, q_req);
233 return -EINVAL;
234 }
235
236 sbale->addr = sg_virt(sg);
237 sbale->length = sg->length;
238
265 bytes += sg->length; 239 bytes += sg->length;
266 } 240 }
267 241
@@ -272,6 +246,46 @@ int zfcp_qdio_sbals_from_sg(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req,
272 return bytes; 246 return bytes;
273} 247}
274 248
249static 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 */
270int 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
275/** 289/**
276 * 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
277 * @qdio: pointer to struct zfcp_qdio 291 * @qdio: pointer to struct zfcp_qdio
diff --git a/drivers/s390/scsi/zfcp_qdio.h b/drivers/s390/scsi/zfcp_qdio.h
index 8cca54631e1..138fba577b4 100644
--- a/drivers/s390/scsi/zfcp_qdio.h
+++ b/drivers/s390/scsi/zfcp_qdio.h
@@ -11,6 +11,14 @@
11 11
12#include <asm/qdio.h> 12#include <asm/qdio.h>
13 13
14#define ZFCP_QDIO_SBALE_LEN PAGE_SIZE
15
16/* DMQ bug workaround: don't use last SBALE */
17#define ZFCP_QDIO_MAX_SBALES_PER_SBAL (QDIO_MAX_ELEMENTS_PER_BUFFER - 1)
18
19/* index of last SBALE (with respect to DMQ bug workaround) */
20#define ZFCP_QDIO_LAST_SBALE_PER_SBAL (ZFCP_QDIO_MAX_SBALES_PER_SBAL - 1)
21
14/** 22/**
15 * struct zfcp_qdio_queue - qdio queue buffer, zfcp index and free count 23 * struct zfcp_qdio_queue - qdio queue buffer, zfcp index and free count
16 * @sbal: qdio buffers 24 * @sbal: qdio buffers
@@ -49,6 +57,7 @@ struct zfcp_qdio {
49 57
50/** 58/**
51 * struct zfcp_qdio_req - qdio queue related values for a request 59 * struct zfcp_qdio_req - qdio queue related values for a request
60 * @sbtype: sbal type flags for sbale 0
52 * @sbal_number: number of free sbals 61 * @sbal_number: number of free sbals
53 * @sbal_first: first sbal for this request 62 * @sbal_first: first sbal for this request
54 * @sbal_last: last sbal for this request 63 * @sbal_last: last sbal for this request
@@ -59,6 +68,7 @@ struct zfcp_qdio {
59 * @qdio_inb_usage: usage of inbound queue 68 * @qdio_inb_usage: usage of inbound queue
60 */ 69 */
61struct zfcp_qdio_req { 70struct zfcp_qdio_req {
71 u32 sbtype;
62 u8 sbal_number; 72 u8 sbal_number;
63 u8 sbal_first; 73 u8 sbal_first;
64 u8 sbal_last; 74 u8 sbal_last;
@@ -106,4 +116,98 @@ zfcp_qdio_sbale_curr(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req)
106 q_req->sbale_curr); 116 q_req->sbale_curr);
107} 117}
108 118
119/**
120 * zfcp_qdio_req_init - initialize qdio request
121 * @qdio: request queue where to start putting the request
122 * @q_req: the qdio request to start
123 * @req_id: The request id
124 * @sbtype: type flags to set for all sbals
125 * @data: First data block
126 * @len: Length of first data block
127 *
128 * This is the start of putting the request into the queue, the last
129 * step is passing the request to zfcp_qdio_send. The request queue
130 * lock must be held during the whole process from init to send.
131 */
132static inline
133void zfcp_qdio_req_init(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req,
134 unsigned long req_id, u32 sbtype, void *data, u32 len)
135{
136 struct qdio_buffer_element *sbale;
137
138 q_req->sbal_first = q_req->sbal_last = qdio->req_q.first;
139 q_req->sbal_number = 1;
140 q_req->sbtype = sbtype;
141
142 sbale = zfcp_qdio_sbale_req(qdio, q_req);
143 sbale->addr = (void *) req_id;
144 sbale->flags |= SBAL_FLAGS0_COMMAND;
145 sbale->flags |= sbtype;
146
147 q_req->sbale_curr = 1;
148 sbale++;
149 sbale->addr = data;
150 if (likely(data))
151 sbale->length = len;
152}
153
154/**
155 * zfcp_qdio_fill_next - Fill next sbale, only for single sbal requests
156 * @qdio: pointer to struct zfcp_qdio
157 * @q_req: pointer to struct zfcp_queue_req
158 *
159 * This is only required for single sbal requests, calling it when
160 * wrapping around to the next sbal is a bug.
161 */
162static inline
163void zfcp_qdio_fill_next(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req,
164 void *data, u32 len)
165{
166 struct qdio_buffer_element *sbale;
167
168 BUG_ON(q_req->sbale_curr == ZFCP_QDIO_LAST_SBALE_PER_SBAL);
169 q_req->sbale_curr++;
170 sbale = zfcp_qdio_sbale_curr(qdio, q_req);
171 sbale->addr = data;
172 sbale->length = len;
173}
174
175/**
176 * zfcp_qdio_set_sbale_last - set last entry flag in current sbale
177 * @qdio: pointer to struct zfcp_qdio
178 * @q_req: pointer to struct zfcp_queue_req
179 */
180static inline
181void zfcp_qdio_set_sbale_last(struct zfcp_qdio *qdio,
182 struct zfcp_qdio_req *q_req)
183{
184 struct qdio_buffer_element *sbale;
185
186 sbale = zfcp_qdio_sbale_curr(qdio, q_req);
187 sbale->flags |= SBAL_FLAGS_LAST_ENTRY;
188}
189
190/**
191 * zfcp_qdio_sg_one_sbal - check if one sbale is enough for sg data
192 * @sg: The scatterlist where to check the data size
193 *
194 * Returns: 1 when one sbale is enough for the data in the scatterlist,
195 * 0 if not.
196 */
197static inline
198int zfcp_qdio_sg_one_sbale(struct scatterlist *sg)
199{
200 return sg_is_last(sg) && sg->length <= ZFCP_QDIO_SBALE_LEN;
201}
202
203/**
204 * zfcp_qdio_skip_to_last_sbale - skip to last sbale in sbal
205 * @q_req: The current zfcp_qdio_req
206 */
207static inline
208void zfcp_qdio_skip_to_last_sbale(struct zfcp_qdio_req *q_req)
209{
210 q_req->sbale_curr = ZFCP_QDIO_LAST_SBALE_PER_SBAL;
211}
212
109#endif /* ZFCP_QDIO_H */ 213#endif /* ZFCP_QDIO_H */
diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c
index 174b6d57d57..be5d2c60453 100644
--- a/drivers/s390/scsi/zfcp_scsi.c
+++ b/drivers/s390/scsi/zfcp_scsi.c
@@ -175,7 +175,7 @@ static int zfcp_scsi_eh_abort_handler(struct scsi_cmnd *scpnt)
175 struct zfcp_fsf_req *old_req, *abrt_req; 175 struct zfcp_fsf_req *old_req, *abrt_req;
176 unsigned long flags; 176 unsigned long flags;
177 unsigned long old_reqid = (unsigned long) scpnt->host_scribble; 177 unsigned long old_reqid = (unsigned long) scpnt->host_scribble;
178 int retval = SUCCESS; 178 int retval = SUCCESS, ret;
179 int retry = 3; 179 int retry = 3;
180 char *dbf_tag; 180 char *dbf_tag;
181 181
@@ -200,7 +200,9 @@ static int zfcp_scsi_eh_abort_handler(struct scsi_cmnd *scpnt)
200 break; 200 break;
201 201
202 zfcp_erp_wait(adapter); 202 zfcp_erp_wait(adapter);
203 fc_block_scsi_eh(scpnt); 203 ret = fc_block_scsi_eh(scpnt);
204 if (ret)
205 return ret;
204 if (!(atomic_read(&adapter->status) & 206 if (!(atomic_read(&adapter->status) &
205 ZFCP_STATUS_COMMON_RUNNING)) { 207 ZFCP_STATUS_COMMON_RUNNING)) {
206 zfcp_dbf_scsi_abort("nres", adapter->dbf, scpnt, NULL, 208 zfcp_dbf_scsi_abort("nres", adapter->dbf, scpnt, NULL,
@@ -231,7 +233,7 @@ static int zfcp_task_mgmt_function(struct scsi_cmnd *scpnt, u8 tm_flags)
231 struct zfcp_unit *unit = scpnt->device->hostdata; 233 struct zfcp_unit *unit = scpnt->device->hostdata;
232 struct zfcp_adapter *adapter = unit->port->adapter; 234 struct zfcp_adapter *adapter = unit->port->adapter;
233 struct zfcp_fsf_req *fsf_req = NULL; 235 struct zfcp_fsf_req *fsf_req = NULL;
234 int retval = SUCCESS; 236 int retval = SUCCESS, ret;
235 int retry = 3; 237 int retry = 3;
236 238
237 while (retry--) { 239 while (retry--) {
@@ -240,7 +242,10 @@ static int zfcp_task_mgmt_function(struct scsi_cmnd *scpnt, u8 tm_flags)
240 break; 242 break;
241 243
242 zfcp_erp_wait(adapter); 244 zfcp_erp_wait(adapter);
243 fc_block_scsi_eh(scpnt); 245 ret = fc_block_scsi_eh(scpnt);
246 if (ret)
247 return ret;
248
244 if (!(atomic_read(&adapter->status) & 249 if (!(atomic_read(&adapter->status) &
245 ZFCP_STATUS_COMMON_RUNNING)) { 250 ZFCP_STATUS_COMMON_RUNNING)) {
246 zfcp_dbf_scsi_devreset("nres", tm_flags, unit, scpnt); 251 zfcp_dbf_scsi_devreset("nres", tm_flags, unit, scpnt);
@@ -276,10 +281,13 @@ static int zfcp_scsi_eh_host_reset_handler(struct scsi_cmnd *scpnt)
276{ 281{
277 struct zfcp_unit *unit = scpnt->device->hostdata; 282 struct zfcp_unit *unit = scpnt->device->hostdata;
278 struct zfcp_adapter *adapter = unit->port->adapter; 283 struct zfcp_adapter *adapter = unit->port->adapter;
284 int ret;
279 285
280 zfcp_erp_adapter_reopen(adapter, 0, "schrh_1", scpnt); 286 zfcp_erp_adapter_reopen(adapter, 0, "schrh_1", scpnt);
281 zfcp_erp_wait(adapter); 287 zfcp_erp_wait(adapter);
282 fc_block_scsi_eh(scpnt); 288 ret = fc_block_scsi_eh(scpnt);
289 if (ret)
290 return ret;
283 291
284 return SUCCESS; 292 return SUCCESS;
285} 293}
@@ -669,11 +677,12 @@ struct zfcp_data zfcp_data = {
669 .eh_host_reset_handler = zfcp_scsi_eh_host_reset_handler, 677 .eh_host_reset_handler = zfcp_scsi_eh_host_reset_handler,
670 .can_queue = 4096, 678 .can_queue = 4096,
671 .this_id = -1, 679 .this_id = -1,
672 .sg_tablesize = ZFCP_MAX_SBALES_PER_REQ, 680 .sg_tablesize = ZFCP_FSF_MAX_SBALES_PER_REQ,
673 .cmd_per_lun = 1, 681 .cmd_per_lun = 1,
674 .use_clustering = 1, 682 .use_clustering = 1,
675 .sdev_attrs = zfcp_sysfs_sdev_attrs, 683 .sdev_attrs = zfcp_sysfs_sdev_attrs,
676 .max_sectors = (ZFCP_MAX_SBALES_PER_REQ * 8), 684 .max_sectors = (ZFCP_FSF_MAX_SBALES_PER_REQ * 8),
685 .dma_boundary = ZFCP_QDIO_SBALE_LEN - 1,
677 .shost_attrs = zfcp_sysfs_shost_attrs, 686 .shost_attrs = zfcp_sysfs_shost_attrs,
678 }, 687 },
679}; 688};