diff options
author | Swen Schillig <swen@vnet.ibm.com> | 2010-07-16 09:37:37 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2010-07-28 10:48:49 -0400 |
commit | 01b047599ade30051bf6c14fbe64181d1fec3dfa (patch) | |
tree | 3a44039ec1c48b41ba8e988c230291aca20b833c /drivers/s390/scsi | |
parent | faf4cd854203b26527d81e7e13d66e78774dad44 (diff) |
[SCSI] zfcp: Cleanup function parameters for sbal value.
A lot of functions require the amount of SBALs as one of their
parameter which is most times invariable. Therefore remove this
parameter and set the SBAL value explicitly if a non standard value is
required. In addition the warning message "oversized data" is
replaced with a BUG_ON() statement assuring the limits defined and
requested by zfcp.
Signed-off-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/scsi')
-rw-r--r-- | drivers/s390/scsi/zfcp_ext.h | 2 | ||||
-rw-r--r-- | drivers/s390/scsi/zfcp_fsf.c | 40 | ||||
-rw-r--r-- | drivers/s390/scsi/zfcp_fsf.h | 8 | ||||
-rw-r--r-- | drivers/s390/scsi/zfcp_qdio.c | 15 | ||||
-rw-r--r-- | drivers/s390/scsi/zfcp_qdio.h | 28 | ||||
-rw-r--r-- | drivers/s390/scsi/zfcp_scsi.c | 4 |
6 files changed, 47 insertions, 50 deletions
diff --git a/drivers/s390/scsi/zfcp_ext.h b/drivers/s390/scsi/zfcp_ext.h index 6abe2909e75b..3aab0f5544d4 100644 --- a/drivers/s390/scsi/zfcp_ext.h +++ b/drivers/s390/scsi/zfcp_ext.h | |||
@@ -146,7 +146,7 @@ extern void zfcp_qdio_destroy(struct zfcp_qdio *); | |||
146 | extern int zfcp_qdio_sbal_get(struct zfcp_qdio *); | 146 | extern int zfcp_qdio_sbal_get(struct zfcp_qdio *); |
147 | 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 *); |
148 | 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 *, |
149 | struct scatterlist *, int); | 149 | struct scatterlist *); |
150 | extern int zfcp_qdio_open(struct zfcp_qdio *); | 150 | extern int zfcp_qdio_open(struct zfcp_qdio *); |
151 | extern void zfcp_qdio_close(struct zfcp_qdio *); | 151 | extern void zfcp_qdio_close(struct zfcp_qdio *); |
152 | 152 | ||
diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c index ee0c1df8a6d2..5f502c9cb067 100644 --- a/drivers/s390/scsi/zfcp_fsf.c +++ b/drivers/s390/scsi/zfcp_fsf.c | |||
@@ -959,8 +959,7 @@ static void zfcp_fsf_setup_ct_els_unchained(struct zfcp_qdio *qdio, | |||
959 | 959 | ||
960 | static int zfcp_fsf_setup_ct_els_sbals(struct zfcp_fsf_req *req, | 960 | static int zfcp_fsf_setup_ct_els_sbals(struct zfcp_fsf_req *req, |
961 | struct scatterlist *sg_req, | 961 | struct scatterlist *sg_req, |
962 | struct scatterlist *sg_resp, | 962 | struct scatterlist *sg_resp) |
963 | int max_sbals) | ||
964 | { | 963 | { |
965 | struct zfcp_adapter *adapter = req->adapter; | 964 | struct zfcp_adapter *adapter = req->adapter; |
966 | u32 feat = adapter->adapter_features; | 965 | u32 feat = adapter->adapter_features; |
@@ -983,15 +982,14 @@ static int zfcp_fsf_setup_ct_els_sbals(struct zfcp_fsf_req *req, | |||
983 | return 0; | 982 | return 0; |
984 | } | 983 | } |
985 | 984 | ||
986 | bytes = zfcp_qdio_sbals_from_sg(adapter->qdio, &req->qdio_req, | 985 | bytes = zfcp_qdio_sbals_from_sg(adapter->qdio, &req->qdio_req, sg_req); |
987 | sg_req, max_sbals); | ||
988 | if (bytes <= 0) | 986 | if (bytes <= 0) |
989 | return -EIO; | 987 | return -EIO; |
990 | req->qtcb->bottom.support.req_buf_length = bytes; | 988 | req->qtcb->bottom.support.req_buf_length = bytes; |
991 | zfcp_qdio_skip_to_last_sbale(&req->qdio_req); | 989 | zfcp_qdio_skip_to_last_sbale(&req->qdio_req); |
992 | 990 | ||
993 | bytes = zfcp_qdio_sbals_from_sg(adapter->qdio, &req->qdio_req, | 991 | bytes = zfcp_qdio_sbals_from_sg(adapter->qdio, &req->qdio_req, |
994 | sg_resp, max_sbals); | 992 | sg_resp); |
995 | req->qtcb->bottom.support.resp_buf_length = bytes; | 993 | req->qtcb->bottom.support.resp_buf_length = bytes; |
996 | if (bytes <= 0) | 994 | if (bytes <= 0) |
997 | return -EIO; | 995 | return -EIO; |
@@ -1002,11 +1000,11 @@ static int zfcp_fsf_setup_ct_els_sbals(struct zfcp_fsf_req *req, | |||
1002 | static int zfcp_fsf_setup_ct_els(struct zfcp_fsf_req *req, | 1000 | static int zfcp_fsf_setup_ct_els(struct zfcp_fsf_req *req, |
1003 | struct scatterlist *sg_req, | 1001 | struct scatterlist *sg_req, |
1004 | struct scatterlist *sg_resp, | 1002 | struct scatterlist *sg_resp, |
1005 | int max_sbals, unsigned int timeout) | 1003 | unsigned int timeout) |
1006 | { | 1004 | { |
1007 | int ret; | 1005 | int ret; |
1008 | 1006 | ||
1009 | ret = zfcp_fsf_setup_ct_els_sbals(req, sg_req, sg_resp, max_sbals); | 1007 | ret = zfcp_fsf_setup_ct_els_sbals(req, sg_req, sg_resp); |
1010 | if (ret) | 1008 | if (ret) |
1011 | return ret; | 1009 | return ret; |
1012 | 1010 | ||
@@ -1046,8 +1044,7 @@ int zfcp_fsf_send_ct(struct zfcp_fc_wka_port *wka_port, | |||
1046 | } | 1044 | } |
1047 | 1045 | ||
1048 | req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; | 1046 | req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; |
1049 | ret = zfcp_fsf_setup_ct_els(req, ct->req, ct->resp, | 1047 | ret = zfcp_fsf_setup_ct_els(req, ct->req, ct->resp, timeout); |
1050 | ZFCP_FSF_MAX_SBALS_PER_REQ, timeout); | ||
1051 | if (ret) | 1048 | if (ret) |
1052 | goto failed_send; | 1049 | goto failed_send; |
1053 | 1050 | ||
@@ -1143,7 +1140,10 @@ int zfcp_fsf_send_els(struct zfcp_adapter *adapter, u32 d_id, | |||
1143 | } | 1140 | } |
1144 | 1141 | ||
1145 | req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; | 1142 | req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; |
1146 | ret = zfcp_fsf_setup_ct_els(req, els->req, els->resp, 2, timeout); | 1143 | |
1144 | zfcp_qdio_sbal_limit(qdio, &req->qdio_req, 2); | ||
1145 | |||
1146 | ret = zfcp_fsf_setup_ct_els(req, els->req, els->resp, timeout); | ||
1147 | 1147 | ||
1148 | if (ret) | 1148 | if (ret) |
1149 | goto failed_send; | 1149 | goto failed_send; |
@@ -2259,20 +2259,9 @@ int zfcp_fsf_send_fcp_command_task(struct zfcp_unit *unit, | |||
2259 | zfcp_fc_scsi_to_fcp(fcp_cmnd, scsi_cmnd); | 2259 | zfcp_fc_scsi_to_fcp(fcp_cmnd, scsi_cmnd); |
2260 | 2260 | ||
2261 | real_bytes = zfcp_qdio_sbals_from_sg(qdio, &req->qdio_req, | 2261 | real_bytes = zfcp_qdio_sbals_from_sg(qdio, &req->qdio_req, |
2262 | scsi_sglist(scsi_cmnd), | 2262 | scsi_sglist(scsi_cmnd)); |
2263 | ZFCP_FSF_MAX_SBALS_PER_REQ); | 2263 | if (unlikely(real_bytes < 0)) |
2264 | if (unlikely(real_bytes < 0)) { | ||
2265 | if (req->qdio_req.sbal_number >= ZFCP_FSF_MAX_SBALS_PER_REQ) { | ||
2266 | dev_err(&adapter->ccw_device->dev, | ||
2267 | "Oversize data package, unit 0x%016Lx " | ||
2268 | "on port 0x%016Lx closed\n", | ||
2269 | (unsigned long long)unit->fcp_lun, | ||
2270 | (unsigned long long)unit->port->wwpn); | ||
2271 | zfcp_erp_unit_shutdown(unit, 0, "fssfct1", req); | ||
2272 | retval = -EINVAL; | ||
2273 | } | ||
2274 | goto failed_scsi_cmnd; | 2264 | goto failed_scsi_cmnd; |
2275 | } | ||
2276 | 2265 | ||
2277 | retval = zfcp_fsf_req_send(req); | 2266 | retval = zfcp_fsf_req_send(req); |
2278 | if (unlikely(retval)) | 2267 | if (unlikely(retval)) |
@@ -2391,9 +2380,8 @@ struct zfcp_fsf_req *zfcp_fsf_control_file(struct zfcp_adapter *adapter, | |||
2391 | bottom->operation_subtype = FSF_CFDC_OPERATION_SUBTYPE; | 2380 | bottom->operation_subtype = FSF_CFDC_OPERATION_SUBTYPE; |
2392 | bottom->option = fsf_cfdc->option; | 2381 | bottom->option = fsf_cfdc->option; |
2393 | 2382 | ||
2394 | bytes = zfcp_qdio_sbals_from_sg(qdio, &req->qdio_req, | 2383 | bytes = zfcp_qdio_sbals_from_sg(qdio, &req->qdio_req, fsf_cfdc->sg); |
2395 | fsf_cfdc->sg, | 2384 | |
2396 | ZFCP_FSF_MAX_SBALS_PER_REQ); | ||
2397 | if (bytes != ZFCP_CFDC_MAX_SIZE) { | 2385 | if (bytes != ZFCP_CFDC_MAX_SIZE) { |
2398 | zfcp_fsf_req_free(req); | 2386 | zfcp_fsf_req_free(req); |
2399 | goto out; | 2387 | goto out; |
diff --git a/drivers/s390/scsi/zfcp_fsf.h b/drivers/s390/scsi/zfcp_fsf.h index ca45e32d6b6f..ca110e386761 100644 --- a/drivers/s390/scsi/zfcp_fsf.h +++ b/drivers/s390/scsi/zfcp_fsf.h | |||
@@ -151,14 +151,6 @@ | |||
151 | /* fc service class */ | 151 | /* fc service class */ |
152 | #define FSF_CLASS_3 0x00000003 | 152 | #define FSF_CLASS_3 0x00000003 |
153 | 153 | ||
154 | /* SBAL chaining */ | ||
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) | ||
161 | |||
162 | /* logging space behind QTCB */ | 154 | /* logging space behind QTCB */ |
163 | #define FSF_QTCB_LOG_SIZE 1024 | 155 | #define FSF_QTCB_LOG_SIZE 1024 |
164 | 156 | ||
diff --git a/drivers/s390/scsi/zfcp_qdio.c b/drivers/s390/scsi/zfcp_qdio.c index 6fa5e0453176..7ab1ac16a11f 100644 --- a/drivers/s390/scsi/zfcp_qdio.c +++ b/drivers/s390/scsi/zfcp_qdio.c | |||
@@ -141,15 +141,6 @@ static void zfcp_qdio_int_resp(struct ccw_device *cdev, unsigned int qdio_err, | |||
141 | zfcp_qdio_resp_put_back(qdio, count); | 141 | zfcp_qdio_resp_put_back(qdio, count); |
142 | } | 142 | } |
143 | 143 | ||
144 | static void zfcp_qdio_sbal_limit(struct zfcp_qdio *qdio, | ||
145 | struct zfcp_qdio_req *q_req, int max_sbals) | ||
146 | { | ||
147 | int count = atomic_read(&qdio->req_q.count); | ||
148 | count = min(count, max_sbals); | ||
149 | q_req->sbal_limit = (q_req->sbal_first + count - 1) | ||
150 | % QDIO_MAX_BUFFERS_PER_Q; | ||
151 | } | ||
152 | |||
153 | static struct qdio_buffer_element * | 144 | static struct qdio_buffer_element * |
154 | zfcp_qdio_sbal_chain(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req) | 145 | zfcp_qdio_sbal_chain(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req) |
155 | { | 146 | { |
@@ -173,6 +164,7 @@ zfcp_qdio_sbal_chain(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req) | |||
173 | 164 | ||
174 | /* keep this requests number of SBALs up-to-date */ | 165 | /* keep this requests number of SBALs up-to-date */ |
175 | q_req->sbal_number++; | 166 | q_req->sbal_number++; |
167 | BUG_ON(q_req->sbal_number > ZFCP_QDIO_MAX_SBALS_PER_REQ); | ||
176 | 168 | ||
177 | /* start at first SBALE of new SBAL */ | 169 | /* start at first SBALE of new SBAL */ |
178 | q_req->sbale_curr = 0; | 170 | q_req->sbale_curr = 0; |
@@ -213,14 +205,11 @@ static void zfcp_qdio_undo_sbals(struct zfcp_qdio *qdio, | |||
213 | * Returns: number of bytes, or error (negativ) | 205 | * Returns: number of bytes, or error (negativ) |
214 | */ | 206 | */ |
215 | int zfcp_qdio_sbals_from_sg(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req, | 207 | int zfcp_qdio_sbals_from_sg(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req, |
216 | struct scatterlist *sg, int max_sbals) | 208 | struct scatterlist *sg) |
217 | { | 209 | { |
218 | struct qdio_buffer_element *sbale; | 210 | struct qdio_buffer_element *sbale; |
219 | int bytes = 0; | 211 | int bytes = 0; |
220 | 212 | ||
221 | /* figure out last allowed SBAL */ | ||
222 | zfcp_qdio_sbal_limit(qdio, q_req, max_sbals); | ||
223 | |||
224 | /* set storage-block type for this request */ | 213 | /* set storage-block type for this request */ |
225 | sbale = zfcp_qdio_sbale_req(qdio, q_req); | 214 | sbale = zfcp_qdio_sbale_req(qdio, q_req); |
226 | sbale->flags |= q_req->sbtype; | 215 | sbale->flags |= q_req->sbtype; |
diff --git a/drivers/s390/scsi/zfcp_qdio.h b/drivers/s390/scsi/zfcp_qdio.h index 138fba577b48..8bb00545f19c 100644 --- a/drivers/s390/scsi/zfcp_qdio.h +++ b/drivers/s390/scsi/zfcp_qdio.h | |||
@@ -19,6 +19,14 @@ | |||
19 | /* index of last SBALE (with respect to DMQ bug workaround) */ | 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) | 20 | #define ZFCP_QDIO_LAST_SBALE_PER_SBAL (ZFCP_QDIO_MAX_SBALES_PER_SBAL - 1) |
21 | 21 | ||
22 | /* Max SBALS for chaining */ | ||
23 | #define ZFCP_QDIO_MAX_SBALS_PER_REQ 36 | ||
24 | |||
25 | /* max. number of (data buffer) SBALEs in largest SBAL chain | ||
26 | * request ID + QTCB in SBALE 0 + 1 of first SBAL in chain */ | ||
27 | #define ZFCP_QDIO_MAX_SBALES_PER_REQ \ | ||
28 | (ZFCP_QDIO_MAX_SBALS_PER_REQ * ZFCP_QDIO_MAX_SBALES_PER_SBAL - 2) | ||
29 | |||
22 | /** | 30 | /** |
23 | * struct zfcp_qdio_queue - qdio queue buffer, zfcp index and free count | 31 | * struct zfcp_qdio_queue - qdio queue buffer, zfcp index and free count |
24 | * @sbal: qdio buffers | 32 | * @sbal: qdio buffers |
@@ -134,10 +142,14 @@ void 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) | 142 | unsigned long req_id, u32 sbtype, void *data, u32 len) |
135 | { | 143 | { |
136 | struct qdio_buffer_element *sbale; | 144 | struct qdio_buffer_element *sbale; |
145 | int count = min(atomic_read(&qdio->req_q.count), | ||
146 | ZFCP_QDIO_MAX_SBALS_PER_REQ); | ||
137 | 147 | ||
138 | q_req->sbal_first = q_req->sbal_last = qdio->req_q.first; | 148 | q_req->sbal_first = q_req->sbal_last = qdio->req_q.first; |
139 | q_req->sbal_number = 1; | 149 | q_req->sbal_number = 1; |
140 | q_req->sbtype = sbtype; | 150 | q_req->sbtype = sbtype; |
151 | q_req->sbal_limit = (q_req->sbal_first + count - 1) | ||
152 | % QDIO_MAX_BUFFERS_PER_Q; | ||
141 | 153 | ||
142 | sbale = zfcp_qdio_sbale_req(qdio, q_req); | 154 | sbale = zfcp_qdio_sbale_req(qdio, q_req); |
143 | sbale->addr = (void *) req_id; | 155 | sbale->addr = (void *) req_id; |
@@ -210,4 +222,20 @@ void zfcp_qdio_skip_to_last_sbale(struct zfcp_qdio_req *q_req) | |||
210 | q_req->sbale_curr = ZFCP_QDIO_LAST_SBALE_PER_SBAL; | 222 | q_req->sbale_curr = ZFCP_QDIO_LAST_SBALE_PER_SBAL; |
211 | } | 223 | } |
212 | 224 | ||
225 | /** | ||
226 | * zfcp_qdio_sbal_limit - set the sbal limit for a request in q_req | ||
227 | * @qdio: pointer to struct zfcp_qdio | ||
228 | * @q_req: The current zfcp_qdio_req | ||
229 | * @max_sbals: maximum number of SBALs allowed | ||
230 | */ | ||
231 | static inline | ||
232 | void zfcp_qdio_sbal_limit(struct zfcp_qdio *qdio, | ||
233 | struct zfcp_qdio_req *q_req, int max_sbals) | ||
234 | { | ||
235 | int count = min(atomic_read(&qdio->req_q.count), max_sbals); | ||
236 | |||
237 | q_req->sbal_limit = (q_req->sbal_first + count - 1) % | ||
238 | QDIO_MAX_BUFFERS_PER_Q; | ||
239 | } | ||
240 | |||
213 | #endif /* ZFCP_QDIO_H */ | 241 | #endif /* ZFCP_QDIO_H */ |
diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c index 9d117ee7159a..eb471a1723cd 100644 --- a/drivers/s390/scsi/zfcp_scsi.c +++ b/drivers/s390/scsi/zfcp_scsi.c | |||
@@ -701,11 +701,11 @@ struct zfcp_data zfcp_data = { | |||
701 | .eh_host_reset_handler = zfcp_scsi_eh_host_reset_handler, | 701 | .eh_host_reset_handler = zfcp_scsi_eh_host_reset_handler, |
702 | .can_queue = 4096, | 702 | .can_queue = 4096, |
703 | .this_id = -1, | 703 | .this_id = -1, |
704 | .sg_tablesize = ZFCP_FSF_MAX_SBALES_PER_REQ, | 704 | .sg_tablesize = ZFCP_QDIO_MAX_SBALES_PER_REQ, |
705 | .cmd_per_lun = 1, | 705 | .cmd_per_lun = 1, |
706 | .use_clustering = 1, | 706 | .use_clustering = 1, |
707 | .sdev_attrs = zfcp_sysfs_sdev_attrs, | 707 | .sdev_attrs = zfcp_sysfs_sdev_attrs, |
708 | .max_sectors = (ZFCP_FSF_MAX_SBALES_PER_REQ * 8), | 708 | .max_sectors = (ZFCP_QDIO_MAX_SBALES_PER_REQ * 8), |
709 | .dma_boundary = ZFCP_QDIO_SBALE_LEN - 1, | 709 | .dma_boundary = ZFCP_QDIO_SBALE_LEN - 1, |
710 | .shost_attrs = zfcp_sysfs_shost_attrs, | 710 | .shost_attrs = zfcp_sysfs_shost_attrs, |
711 | }, | 711 | }, |