diff options
author | Matthew Wilcox <matthew@wil.cx> | 2007-10-02 21:55:39 -0400 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.localdomain> | 2007-10-12 14:53:56 -0400 |
commit | 52c334e9450a15230b84ab4ef8ef7b034b37c371 (patch) | |
tree | 7801f2f5a481d1a8992cb9b7c14a0334f30514d6 | |
parent | fd625f4705977de1ad00ac3cb519ec3ee8fd8598 (diff) |
[SCSI] advansys: convert to use the data buffer accessors
- remove the unnecessary map_single path.
- convert to use the new accessors for the sg lists and the parameters.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
- convert the statistics to not distinguish between single and sg xfers
- replace ASC_CEILING with DIV_ROUND_UP
- remove an obsolete comment
Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
-rw-r--r-- | drivers/scsi/advansys.c | 236 |
1 files changed, 52 insertions, 184 deletions
diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c index ab9108293d0f..d35897eaa807 100644 --- a/drivers/scsi/advansys.c +++ b/drivers/scsi/advansys.c | |||
@@ -2223,8 +2223,6 @@ do { \ | |||
2223 | (((struct asc_board *) shost_priv(shost))->asc_stats.counter += (count)) | 2223 | (((struct asc_board *) shost_priv(shost))->asc_stats.counter += (count)) |
2224 | #endif /* ADVANSYS_STATS */ | 2224 | #endif /* ADVANSYS_STATS */ |
2225 | 2225 | ||
2226 | #define ASC_CEILING(val, unit) (((val) + ((unit) - 1))/(unit)) | ||
2227 | |||
2228 | /* If the result wraps when calculating tenths, return 0. */ | 2226 | /* If the result wraps when calculating tenths, return 0. */ |
2229 | #define ASC_TENTHS(num, den) \ | 2227 | #define ASC_TENTHS(num, den) \ |
2230 | (((10 * ((num)/(den))) > (((num) * 10)/(den))) ? \ | 2228 | (((10 * ((num)/(den))) > (((num) * 10)/(den))) ? \ |
@@ -2356,11 +2354,9 @@ struct asc_stats { | |||
2356 | ADV_DCNT exe_error; /* # ASC_ERROR returns. */ | 2354 | ADV_DCNT exe_error; /* # ASC_ERROR returns. */ |
2357 | ADV_DCNT exe_unknown; /* # unknown returns. */ | 2355 | ADV_DCNT exe_unknown; /* # unknown returns. */ |
2358 | /* Data Transfer Statistics */ | 2356 | /* Data Transfer Statistics */ |
2359 | ADV_DCNT cont_cnt; /* # non-scatter-gather I/O requests received */ | 2357 | ADV_DCNT xfer_cnt; /* # I/O requests received */ |
2360 | ADV_DCNT cont_xfer; /* # contiguous transfer 512-bytes */ | 2358 | ADV_DCNT xfer_elem; /* # scatter-gather elements */ |
2361 | ADV_DCNT sg_cnt; /* # scatter-gather I/O requests received */ | 2359 | ADV_DCNT xfer_sect; /* # 512-byte blocks */ |
2362 | ADV_DCNT sg_elem; /* # scatter-gather elements */ | ||
2363 | ADV_DCNT sg_xfer; /* # scatter-gather transfer 512-bytes */ | ||
2364 | }; | 2360 | }; |
2365 | #endif /* ADVANSYS_STATS */ | 2361 | #endif /* ADVANSYS_STATS */ |
2366 | 2362 | ||
@@ -4057,57 +4053,32 @@ static int asc_prt_board_stats(struct Scsi_Host *shost, char *cp, int cplen) | |||
4057 | /* | 4053 | /* |
4058 | * Display data transfer statistics. | 4054 | * Display data transfer statistics. |
4059 | */ | 4055 | */ |
4060 | if (s->cont_cnt > 0) { | 4056 | if (s->xfer_cnt > 0) { |
4061 | len = asc_prt_line(cp, leftlen, " cont_cnt %lu, ", s->cont_cnt); | 4057 | len = asc_prt_line(cp, leftlen, " xfer_cnt %lu, xfer_elem %lu, ", |
4062 | ASC_PRT_NEXT(); | 4058 | s->xfer_cnt, s->xfer_elem); |
4063 | |||
4064 | len = asc_prt_line(cp, leftlen, "cont_xfer %lu.%01lu kb ", | ||
4065 | s->cont_xfer / 2, | ||
4066 | ASC_TENTHS(s->cont_xfer, 2)); | ||
4067 | ASC_PRT_NEXT(); | ||
4068 | |||
4069 | /* Contiguous transfer average size */ | ||
4070 | len = asc_prt_line(cp, leftlen, "avg_xfer %lu.%01lu kb\n", | ||
4071 | (s->cont_xfer / 2) / s->cont_cnt, | ||
4072 | ASC_TENTHS((s->cont_xfer / 2), s->cont_cnt)); | ||
4073 | ASC_PRT_NEXT(); | ||
4074 | } | ||
4075 | |||
4076 | if (s->sg_cnt > 0) { | ||
4077 | |||
4078 | len = asc_prt_line(cp, leftlen, " sg_cnt %lu, sg_elem %lu, ", | ||
4079 | s->sg_cnt, s->sg_elem); | ||
4080 | ASC_PRT_NEXT(); | 4059 | ASC_PRT_NEXT(); |
4081 | 4060 | ||
4082 | len = asc_prt_line(cp, leftlen, "sg_xfer %lu.%01lu kb\n", | 4061 | len = asc_prt_line(cp, leftlen, "xfer_bytes %lu.%01lu kb\n", |
4083 | s->sg_xfer / 2, ASC_TENTHS(s->sg_xfer, 2)); | 4062 | s->xfer_sect / 2, ASC_TENTHS(s->xfer_sect, 2)); |
4084 | ASC_PRT_NEXT(); | 4063 | ASC_PRT_NEXT(); |
4085 | 4064 | ||
4086 | /* Scatter gather transfer statistics */ | 4065 | /* Scatter gather transfer statistics */ |
4087 | len = asc_prt_line(cp, leftlen, " avg_num_elem %lu.%01lu, ", | 4066 | len = asc_prt_line(cp, leftlen, " avg_num_elem %lu.%01lu, ", |
4088 | s->sg_elem / s->sg_cnt, | 4067 | s->xfer_elem / s->xfer_cnt, |
4089 | ASC_TENTHS(s->sg_elem, s->sg_cnt)); | 4068 | ASC_TENTHS(s->xfer_elem, s->xfer_cnt)); |
4090 | ASC_PRT_NEXT(); | 4069 | ASC_PRT_NEXT(); |
4091 | 4070 | ||
4092 | len = asc_prt_line(cp, leftlen, "avg_elem_size %lu.%01lu kb, ", | 4071 | len = asc_prt_line(cp, leftlen, "avg_elem_size %lu.%01lu kb, ", |
4093 | (s->sg_xfer / 2) / s->sg_elem, | 4072 | (s->xfer_sect / 2) / s->xfer_elem, |
4094 | ASC_TENTHS((s->sg_xfer / 2), s->sg_elem)); | 4073 | ASC_TENTHS((s->xfer_sect / 2), s->xfer_elem)); |
4095 | ASC_PRT_NEXT(); | 4074 | ASC_PRT_NEXT(); |
4096 | 4075 | ||
4097 | len = asc_prt_line(cp, leftlen, "avg_xfer_size %lu.%01lu kb\n", | 4076 | len = asc_prt_line(cp, leftlen, "avg_xfer_size %lu.%01lu kb\n", |
4098 | (s->sg_xfer / 2) / s->sg_cnt, | 4077 | (s->xfer_sect / 2) / s->xfer_cnt, |
4099 | ASC_TENTHS((s->sg_xfer / 2), s->sg_cnt)); | 4078 | ASC_TENTHS((s->xfer_sect / 2), s->xfer_cnt)); |
4100 | ASC_PRT_NEXT(); | 4079 | ASC_PRT_NEXT(); |
4101 | } | 4080 | } |
4102 | 4081 | ||
4103 | /* | ||
4104 | * Display request queuing statistics. | ||
4105 | */ | ||
4106 | len = asc_prt_line(cp, leftlen, | ||
4107 | " Active and Waiting Request Queues (Time Unit: %d HZ):\n", | ||
4108 | HZ); | ||
4109 | ASC_PRT_NEXT(); | ||
4110 | |||
4111 | return totlen; | 4082 | return totlen; |
4112 | } | 4083 | } |
4113 | #endif /* ADVANSYS_STATS */ | 4084 | #endif /* ADVANSYS_STATS */ |
@@ -4301,18 +4272,8 @@ advansys_proc_info(struct Scsi_Host *shost, char *buffer, char **start, | |||
4301 | 4272 | ||
4302 | static void asc_scsi_done(struct scsi_cmnd *scp) | 4273 | static void asc_scsi_done(struct scsi_cmnd *scp) |
4303 | { | 4274 | { |
4304 | struct asc_board *boardp = shost_priv(scp->device->host); | 4275 | scsi_dma_unmap(scp); |
4305 | |||
4306 | if (scp->use_sg) | ||
4307 | dma_unmap_sg(boardp->dev, | ||
4308 | (struct scatterlist *)scp->request_buffer, | ||
4309 | scp->use_sg, scp->sc_data_direction); | ||
4310 | else if (scp->request_bufflen) | ||
4311 | dma_unmap_single(boardp->dev, scp->SCp.dma_handle, | ||
4312 | scp->request_bufflen, scp->sc_data_direction); | ||
4313 | |||
4314 | ASC_STATS(scp->device->host, done); | 4276 | ASC_STATS(scp->device->host, done); |
4315 | |||
4316 | scp->scsi_done(scp); | 4277 | scp->scsi_done(scp); |
4317 | } | 4278 | } |
4318 | 4279 | ||
@@ -8210,11 +8171,11 @@ static void adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp) | |||
8210 | * then return the number of underrun bytes. | 8171 | * then return the number of underrun bytes. |
8211 | */ | 8172 | */ |
8212 | resid_cnt = le32_to_cpu(scsiqp->data_cnt); | 8173 | resid_cnt = le32_to_cpu(scsiqp->data_cnt); |
8213 | if (scp->request_bufflen != 0 && resid_cnt != 0 && | 8174 | if (scsi_bufflen(scp) != 0 && resid_cnt != 0 && |
8214 | resid_cnt <= scp->request_bufflen) { | 8175 | resid_cnt <= scsi_bufflen(scp)) { |
8215 | ASC_DBG(1, "underrun condition %lu bytes\n", | 8176 | ASC_DBG(1, "underrun condition %lu bytes\n", |
8216 | (ulong)resid_cnt); | 8177 | (ulong)resid_cnt); |
8217 | scp->resid = resid_cnt; | 8178 | scsi_set_resid(scp, resid_cnt); |
8218 | } | 8179 | } |
8219 | break; | 8180 | break; |
8220 | 8181 | ||
@@ -9148,11 +9109,11 @@ static void asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep) | |||
9148 | * If there was no error and an underrun condition, then | 9109 | * If there was no error and an underrun condition, then |
9149 | * return the number of underrun bytes. | 9110 | * return the number of underrun bytes. |
9150 | */ | 9111 | */ |
9151 | if (scp->request_bufflen != 0 && qdonep->remain_bytes != 0 && | 9112 | if (scsi_bufflen(scp) != 0 && qdonep->remain_bytes != 0 && |
9152 | qdonep->remain_bytes <= scp->request_bufflen) { | 9113 | qdonep->remain_bytes <= scsi_bufflen(scp)) { |
9153 | ASC_DBG(1, "underrun condition %u bytes\n", | 9114 | ASC_DBG(1, "underrun condition %u bytes\n", |
9154 | (unsigned)qdonep->remain_bytes); | 9115 | (unsigned)qdonep->remain_bytes); |
9155 | scp->resid = qdonep->remain_bytes; | 9116 | scsi_set_resid(scp, qdonep->remain_bytes); |
9156 | } | 9117 | } |
9157 | break; | 9118 | break; |
9158 | 9119 | ||
@@ -9877,6 +9838,8 @@ static int advansys_slave_configure(struct scsi_device *sdev) | |||
9877 | static int asc_build_req(struct asc_board *boardp, struct scsi_cmnd *scp, | 9838 | static int asc_build_req(struct asc_board *boardp, struct scsi_cmnd *scp, |
9878 | struct asc_scsi_q *asc_scsi_q) | 9839 | struct asc_scsi_q *asc_scsi_q) |
9879 | { | 9840 | { |
9841 | int use_sg; | ||
9842 | |||
9880 | memset(asc_scsi_q, 0, sizeof(*asc_scsi_q)); | 9843 | memset(asc_scsi_q, 0, sizeof(*asc_scsi_q)); |
9881 | 9844 | ||
9882 | /* | 9845 | /* |
@@ -9915,55 +9878,26 @@ static int asc_build_req(struct asc_board *boardp, struct scsi_cmnd *scp, | |||
9915 | asc_scsi_q->q2.tag_code = MSG_SIMPLE_TAG; | 9878 | asc_scsi_q->q2.tag_code = MSG_SIMPLE_TAG; |
9916 | } | 9879 | } |
9917 | 9880 | ||
9918 | /* | 9881 | /* Build ASC_SCSI_Q */ |
9919 | * Build ASC_SCSI_Q for a contiguous buffer or a scatter-gather | 9882 | use_sg = scsi_dma_map(scp); |
9920 | * buffer command. | 9883 | if (use_sg != 0) { |
9921 | */ | ||
9922 | if (scp->use_sg == 0) { | ||
9923 | /* | ||
9924 | * CDB request of single contiguous buffer. | ||
9925 | */ | ||
9926 | ASC_STATS(scp->device->host, cont_cnt); | ||
9927 | scp->SCp.dma_handle = scp->request_bufflen ? | ||
9928 | dma_map_single(boardp->dev, scp->request_buffer, | ||
9929 | scp->request_bufflen, | ||
9930 | scp->sc_data_direction) : 0; | ||
9931 | asc_scsi_q->q1.data_addr = cpu_to_le32(scp->SCp.dma_handle); | ||
9932 | asc_scsi_q->q1.data_cnt = cpu_to_le32(scp->request_bufflen); | ||
9933 | ASC_STATS_ADD(scp->device->host, cont_xfer, | ||
9934 | ASC_CEILING(scp->request_bufflen, 512)); | ||
9935 | asc_scsi_q->q1.sg_queue_cnt = 0; | ||
9936 | asc_scsi_q->sg_head = NULL; | ||
9937 | } else { | ||
9938 | /* | ||
9939 | * CDB scatter-gather request list. | ||
9940 | */ | ||
9941 | int sgcnt; | 9884 | int sgcnt; |
9942 | int use_sg; | ||
9943 | struct scatterlist *slp; | 9885 | struct scatterlist *slp; |
9944 | struct asc_sg_head *asc_sg_head; | 9886 | struct asc_sg_head *asc_sg_head; |
9945 | 9887 | ||
9946 | slp = (struct scatterlist *)scp->request_buffer; | ||
9947 | use_sg = dma_map_sg(boardp->dev, slp, scp->use_sg, | ||
9948 | scp->sc_data_direction); | ||
9949 | |||
9950 | if (use_sg > scp->device->host->sg_tablesize) { | 9888 | if (use_sg > scp->device->host->sg_tablesize) { |
9951 | scmd_printk(KERN_ERR, scp, "use_sg %d > " | 9889 | scmd_printk(KERN_ERR, scp, "use_sg %d > " |
9952 | "sg_tablesize %d\n", use_sg, | 9890 | "sg_tablesize %d\n", use_sg, |
9953 | scp->device->host->sg_tablesize); | 9891 | scp->device->host->sg_tablesize); |
9954 | dma_unmap_sg(boardp->dev, slp, scp->use_sg, | 9892 | scsi_dma_unmap(scp); |
9955 | scp->sc_data_direction); | ||
9956 | scp->result = HOST_BYTE(DID_ERROR); | 9893 | scp->result = HOST_BYTE(DID_ERROR); |
9957 | return ASC_ERROR; | 9894 | return ASC_ERROR; |
9958 | } | 9895 | } |
9959 | 9896 | ||
9960 | ASC_STATS(scp->device->host, sg_cnt); | ||
9961 | |||
9962 | asc_sg_head = kzalloc(sizeof(asc_scsi_q->sg_head) + | 9897 | asc_sg_head = kzalloc(sizeof(asc_scsi_q->sg_head) + |
9963 | use_sg * sizeof(struct asc_sg_list), GFP_ATOMIC); | 9898 | use_sg * sizeof(struct asc_sg_list), GFP_ATOMIC); |
9964 | if (!asc_sg_head) { | 9899 | if (!asc_sg_head) { |
9965 | dma_unmap_sg(boardp->dev, slp, scp->use_sg, | 9900 | scsi_dma_unmap(scp); |
9966 | scp->sc_data_direction); | ||
9967 | scp->result = HOST_BYTE(DID_SOFT_ERROR); | 9901 | scp->result = HOST_BYTE(DID_SOFT_ERROR); |
9968 | return ASC_ERROR; | 9902 | return ASC_ERROR; |
9969 | } | 9903 | } |
@@ -9974,22 +9908,24 @@ static int asc_build_req(struct asc_board *boardp, struct scsi_cmnd *scp, | |||
9974 | asc_scsi_q->q1.data_addr = 0; | 9908 | asc_scsi_q->q1.data_addr = 0; |
9975 | /* This is a byte value, otherwise it would need to be swapped. */ | 9909 | /* This is a byte value, otherwise it would need to be swapped. */ |
9976 | asc_sg_head->entry_cnt = asc_scsi_q->q1.sg_queue_cnt = use_sg; | 9910 | asc_sg_head->entry_cnt = asc_scsi_q->q1.sg_queue_cnt = use_sg; |
9977 | ASC_STATS_ADD(scp->device->host, sg_elem, | 9911 | ASC_STATS_ADD(scp->device->host, xfer_elem, |
9978 | asc_sg_head->entry_cnt); | 9912 | asc_sg_head->entry_cnt); |
9979 | 9913 | ||
9980 | /* | 9914 | /* |
9981 | * Convert scatter-gather list into ASC_SG_HEAD list. | 9915 | * Convert scatter-gather list into ASC_SG_HEAD list. |
9982 | */ | 9916 | */ |
9983 | for (sgcnt = 0; sgcnt < use_sg; sgcnt++, slp++) { | 9917 | scsi_for_each_sg(scp, slp, use_sg, sgcnt) { |
9984 | asc_sg_head->sg_list[sgcnt].addr = | 9918 | asc_sg_head->sg_list[sgcnt].addr = |
9985 | cpu_to_le32(sg_dma_address(slp)); | 9919 | cpu_to_le32(sg_dma_address(slp)); |
9986 | asc_sg_head->sg_list[sgcnt].bytes = | 9920 | asc_sg_head->sg_list[sgcnt].bytes = |
9987 | cpu_to_le32(sg_dma_len(slp)); | 9921 | cpu_to_le32(sg_dma_len(slp)); |
9988 | ASC_STATS_ADD(scp->device->host, sg_xfer, | 9922 | ASC_STATS_ADD(scp->device->host, xfer_sect, |
9989 | ASC_CEILING(sg_dma_len(slp), 512)); | 9923 | DIV_ROUND_UP(sg_dma_len(slp), 512)); |
9990 | } | 9924 | } |
9991 | } | 9925 | } |
9992 | 9926 | ||
9927 | ASC_STATS(scp->device->host, xfer_cnt); | ||
9928 | |||
9993 | ASC_DBG_PRT_ASC_SCSI_Q(2, asc_scsi_q); | 9929 | ASC_DBG_PRT_ASC_SCSI_Q(2, asc_scsi_q); |
9994 | ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len); | 9930 | ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len); |
9995 | 9931 | ||
@@ -10021,7 +9957,7 @@ adv_get_sglist(struct asc_board *boardp, adv_req_t *reqp, struct scsi_cmnd *scp, | |||
10021 | int i; | 9957 | int i; |
10022 | 9958 | ||
10023 | scsiqp = (ADV_SCSI_REQ_Q *)ADV_32BALIGN(&reqp->scsi_req_q); | 9959 | scsiqp = (ADV_SCSI_REQ_Q *)ADV_32BALIGN(&reqp->scsi_req_q); |
10024 | slp = (struct scatterlist *)scp->request_buffer; | 9960 | slp = scsi_sglist(scp); |
10025 | sg_elem_cnt = use_sg; | 9961 | sg_elem_cnt = use_sg; |
10026 | prev_sg_block = NULL; | 9962 | prev_sg_block = NULL; |
10027 | reqp->sgblkp = NULL; | 9963 | reqp->sgblkp = NULL; |
@@ -10093,8 +10029,8 @@ adv_get_sglist(struct asc_board *boardp, adv_req_t *reqp, struct scsi_cmnd *scp, | |||
10093 | cpu_to_le32(sg_dma_address(slp)); | 10029 | cpu_to_le32(sg_dma_address(slp)); |
10094 | sg_block->sg_list[i].sg_count = | 10030 | sg_block->sg_list[i].sg_count = |
10095 | cpu_to_le32(sg_dma_len(slp)); | 10031 | cpu_to_le32(sg_dma_len(slp)); |
10096 | ASC_STATS_ADD(scp->device->host, sg_xfer, | 10032 | ASC_STATS_ADD(scp->device->host, xfer_sect, |
10097 | ASC_CEILING(sg_dma_len(slp), 512)); | 10033 | DIV_ROUND_UP(sg_dma_len(slp), 512)); |
10098 | 10034 | ||
10099 | if (--sg_elem_cnt == 0) { /* Last ADV_SG_BLOCK and scatter-gather entry. */ | 10035 | if (--sg_elem_cnt == 0) { /* Last ADV_SG_BLOCK and scatter-gather entry. */ |
10100 | sg_block->sg_cnt = i + 1; | 10036 | sg_block->sg_cnt = i + 1; |
@@ -10126,6 +10062,7 @@ adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp, | |||
10126 | ADV_SCSI_REQ_Q *scsiqp; | 10062 | ADV_SCSI_REQ_Q *scsiqp; |
10127 | int i; | 10063 | int i; |
10128 | int ret; | 10064 | int ret; |
10065 | int use_sg; | ||
10129 | 10066 | ||
10130 | /* | 10067 | /* |
10131 | * Allocate an adv_req_t structure from the board to execute | 10068 | * Allocate an adv_req_t structure from the board to execute |
@@ -10182,54 +10119,24 @@ adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp, | |||
10182 | scsiqp->sense_addr = cpu_to_le32(virt_to_bus(&scp->sense_buffer[0])); | 10119 | scsiqp->sense_addr = cpu_to_le32(virt_to_bus(&scp->sense_buffer[0])); |
10183 | scsiqp->sense_len = sizeof(scp->sense_buffer); | 10120 | scsiqp->sense_len = sizeof(scp->sense_buffer); |
10184 | 10121 | ||
10185 | /* | 10122 | /* Build ADV_SCSI_REQ_Q */ |
10186 | * Build ADV_SCSI_REQ_Q for a contiguous buffer or a scatter-gather | ||
10187 | * buffer command. | ||
10188 | */ | ||
10189 | 10123 | ||
10190 | scsiqp->data_cnt = cpu_to_le32(scp->request_bufflen); | 10124 | use_sg = scsi_dma_map(scp); |
10191 | scsiqp->vdata_addr = scp->request_buffer; | 10125 | if (use_sg == 0) { |
10192 | scsiqp->data_addr = cpu_to_le32(virt_to_bus(scp->request_buffer)); | 10126 | /* Zero-length transfer */ |
10193 | |||
10194 | if (scp->use_sg == 0) { | ||
10195 | /* | ||
10196 | * CDB request of single contiguous buffer. | ||
10197 | */ | ||
10198 | reqp->sgblkp = NULL; | 10127 | reqp->sgblkp = NULL; |
10199 | scsiqp->data_cnt = cpu_to_le32(scp->request_bufflen); | 10128 | scsiqp->data_cnt = 0; |
10200 | if (scp->request_bufflen) { | 10129 | scsiqp->vdata_addr = NULL; |
10201 | scsiqp->vdata_addr = scp->request_buffer; | 10130 | |
10202 | scp->SCp.dma_handle = | 10131 | scsiqp->data_addr = 0; |
10203 | dma_map_single(boardp->dev, scp->request_buffer, | ||
10204 | scp->request_bufflen, | ||
10205 | scp->sc_data_direction); | ||
10206 | } else { | ||
10207 | scsiqp->vdata_addr = NULL; | ||
10208 | scp->SCp.dma_handle = 0; | ||
10209 | } | ||
10210 | scsiqp->data_addr = cpu_to_le32(scp->SCp.dma_handle); | ||
10211 | scsiqp->sg_list_ptr = NULL; | 10132 | scsiqp->sg_list_ptr = NULL; |
10212 | scsiqp->sg_real_addr = 0; | 10133 | scsiqp->sg_real_addr = 0; |
10213 | ASC_STATS(scp->device->host, cont_cnt); | ||
10214 | ASC_STATS_ADD(scp->device->host, cont_xfer, | ||
10215 | ASC_CEILING(scp->request_bufflen, 512)); | ||
10216 | } else { | 10134 | } else { |
10217 | /* | ||
10218 | * CDB scatter-gather request list. | ||
10219 | */ | ||
10220 | struct scatterlist *slp; | ||
10221 | int use_sg; | ||
10222 | |||
10223 | slp = (struct scatterlist *)scp->request_buffer; | ||
10224 | use_sg = dma_map_sg(boardp->dev, slp, scp->use_sg, | ||
10225 | scp->sc_data_direction); | ||
10226 | |||
10227 | if (use_sg > ADV_MAX_SG_LIST) { | 10135 | if (use_sg > ADV_MAX_SG_LIST) { |
10228 | scmd_printk(KERN_ERR, scp, "use_sg %d > " | 10136 | scmd_printk(KERN_ERR, scp, "use_sg %d > " |
10229 | "ADV_MAX_SG_LIST %d\n", use_sg, | 10137 | "ADV_MAX_SG_LIST %d\n", use_sg, |
10230 | scp->device->host->sg_tablesize); | 10138 | scp->device->host->sg_tablesize); |
10231 | dma_unmap_sg(boardp->dev, slp, scp->use_sg, | 10139 | scsi_dma_unmap(scp); |
10232 | scp->sc_data_direction); | ||
10233 | scp->result = HOST_BYTE(DID_ERROR); | 10140 | scp->result = HOST_BYTE(DID_ERROR); |
10234 | 10141 | ||
10235 | /* | 10142 | /* |
@@ -10242,6 +10149,8 @@ adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp, | |||
10242 | return ASC_ERROR; | 10149 | return ASC_ERROR; |
10243 | } | 10150 | } |
10244 | 10151 | ||
10152 | scsiqp->data_cnt = cpu_to_le32(scsi_bufflen(scp)); | ||
10153 | |||
10245 | ret = adv_get_sglist(boardp, reqp, scp, use_sg); | 10154 | ret = adv_get_sglist(boardp, reqp, scp, use_sg); |
10246 | if (ret != ADV_SUCCESS) { | 10155 | if (ret != ADV_SUCCESS) { |
10247 | /* | 10156 | /* |
@@ -10254,10 +10163,11 @@ adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp, | |||
10254 | return ret; | 10163 | return ret; |
10255 | } | 10164 | } |
10256 | 10165 | ||
10257 | ASC_STATS(scp->device->host, sg_cnt); | 10166 | ASC_STATS_ADD(scp->device->host, xfer_elem, use_sg); |
10258 | ASC_STATS_ADD(scp->device->host, sg_elem, use_sg); | ||
10259 | } | 10167 | } |
10260 | 10168 | ||
10169 | ASC_STATS(scp->device->host, xfer_cnt); | ||
10170 | |||
10261 | ASC_DBG_PRT_ADV_SCSI_REQ_Q(2, scsiqp); | 10171 | ASC_DBG_PRT_ADV_SCSI_REQ_Q(2, scsiqp); |
10262 | ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len); | 10172 | ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len); |
10263 | 10173 | ||
@@ -10955,48 +10865,6 @@ static int AdvExeScsiQueue(ADV_DVC_VAR *asc_dvc, ADV_SCSI_REQ_Q *scsiq) | |||
10955 | 10865 | ||
10956 | /* | 10866 | /* |
10957 | * Execute a single 'Scsi_Cmnd'. | 10867 | * Execute a single 'Scsi_Cmnd'. |
10958 | * | ||
10959 | * The function 'done' is called when the request has been completed. | ||
10960 | * | ||
10961 | * Scsi_Cmnd: | ||
10962 | * | ||
10963 | * host - board controlling device | ||
10964 | * device - device to send command | ||
10965 | * target - target of device | ||
10966 | * lun - lun of device | ||
10967 | * cmd_len - length of SCSI CDB | ||
10968 | * cmnd - buffer for SCSI 8, 10, or 12 byte CDB | ||
10969 | * use_sg - if non-zero indicates scatter-gather request with use_sg elements | ||
10970 | * | ||
10971 | * if (use_sg == 0) { | ||
10972 | * request_buffer - buffer address for request | ||
10973 | * request_bufflen - length of request buffer | ||
10974 | * } else { | ||
10975 | * request_buffer - pointer to scatterlist structure | ||
10976 | * } | ||
10977 | * | ||
10978 | * sense_buffer - sense command buffer | ||
10979 | * | ||
10980 | * result (4 bytes of an int): | ||
10981 | * Byte Meaning | ||
10982 | * 0 SCSI Status Byte Code | ||
10983 | * 1 SCSI One Byte Message Code | ||
10984 | * 2 Host Error Code | ||
10985 | * 3 Mid-Level Error Code | ||
10986 | * | ||
10987 | * host driver fields: | ||
10988 | * SCp - Scsi_Pointer used for command processing status | ||
10989 | * scsi_done - used to save caller's done function | ||
10990 | * host_scribble - used for pointer to another struct scsi_cmnd | ||
10991 | * | ||
10992 | * If this function returns ASC_NOERROR the request will be completed | ||
10993 | * from the interrupt handler. | ||
10994 | * | ||
10995 | * If this function returns ASC_ERROR the host error code has been set, | ||
10996 | * and the called must call asc_scsi_done. | ||
10997 | * | ||
10998 | * If ASC_BUSY is returned the request will be returned to the midlayer | ||
10999 | * and re-tried later. | ||
11000 | */ | 10868 | */ |
11001 | static int asc_execute_scsi_cmnd(struct scsi_cmnd *scp) | 10869 | static int asc_execute_scsi_cmnd(struct scsi_cmnd *scp) |
11002 | { | 10870 | { |