diff options
Diffstat (limited to 'drivers/scsi/qla1280.c')
-rw-r--r-- | drivers/scsi/qla1280.c | 70 |
1 files changed, 41 insertions, 29 deletions
diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c index fba8aa8a81b5..76089cf55f4e 100644 --- a/drivers/scsi/qla1280.c +++ b/drivers/scsi/qla1280.c | |||
@@ -2775,7 +2775,7 @@ qla1280_64bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp) | |||
2775 | struct device_reg __iomem *reg = ha->iobase; | 2775 | struct device_reg __iomem *reg = ha->iobase; |
2776 | struct scsi_cmnd *cmd = sp->cmd; | 2776 | struct scsi_cmnd *cmd = sp->cmd; |
2777 | cmd_a64_entry_t *pkt; | 2777 | cmd_a64_entry_t *pkt; |
2778 | struct scatterlist *sg = NULL; | 2778 | struct scatterlist *sg = NULL, *s; |
2779 | __le32 *dword_ptr; | 2779 | __le32 *dword_ptr; |
2780 | dma_addr_t dma_handle; | 2780 | dma_addr_t dma_handle; |
2781 | int status = 0; | 2781 | int status = 0; |
@@ -2889,13 +2889,16 @@ qla1280_64bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp) | |||
2889 | * Load data segments. | 2889 | * Load data segments. |
2890 | */ | 2890 | */ |
2891 | if (seg_cnt) { /* If data transfer. */ | 2891 | if (seg_cnt) { /* If data transfer. */ |
2892 | int remseg = seg_cnt; | ||
2892 | /* Setup packet address segment pointer. */ | 2893 | /* Setup packet address segment pointer. */ |
2893 | dword_ptr = (u32 *)&pkt->dseg_0_address; | 2894 | dword_ptr = (u32 *)&pkt->dseg_0_address; |
2894 | 2895 | ||
2895 | if (cmd->use_sg) { /* If scatter gather */ | 2896 | if (cmd->use_sg) { /* If scatter gather */ |
2896 | /* Load command entry data segments. */ | 2897 | /* Load command entry data segments. */ |
2897 | for (cnt = 0; cnt < 2 && seg_cnt; cnt++, seg_cnt--) { | 2898 | for_each_sg(sg, s, seg_cnt, cnt) { |
2898 | dma_handle = sg_dma_address(sg); | 2899 | if (cnt == 2) |
2900 | break; | ||
2901 | dma_handle = sg_dma_address(s); | ||
2899 | #if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_SGI_SN2) | 2902 | #if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_SGI_SN2) |
2900 | if (ha->flags.use_pci_vchannel) | 2903 | if (ha->flags.use_pci_vchannel) |
2901 | sn_pci_set_vchan(ha->pdev, | 2904 | sn_pci_set_vchan(ha->pdev, |
@@ -2906,12 +2909,12 @@ qla1280_64bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp) | |||
2906 | cpu_to_le32(pci_dma_lo32(dma_handle)); | 2909 | cpu_to_le32(pci_dma_lo32(dma_handle)); |
2907 | *dword_ptr++ = | 2910 | *dword_ptr++ = |
2908 | cpu_to_le32(pci_dma_hi32(dma_handle)); | 2911 | cpu_to_le32(pci_dma_hi32(dma_handle)); |
2909 | *dword_ptr++ = cpu_to_le32(sg_dma_len(sg)); | 2912 | *dword_ptr++ = cpu_to_le32(sg_dma_len(s)); |
2910 | sg++; | ||
2911 | dprintk(3, "S/G Segment phys_addr=%x %x, len=0x%x\n", | 2913 | dprintk(3, "S/G Segment phys_addr=%x %x, len=0x%x\n", |
2912 | cpu_to_le32(pci_dma_hi32(dma_handle)), | 2914 | cpu_to_le32(pci_dma_hi32(dma_handle)), |
2913 | cpu_to_le32(pci_dma_lo32(dma_handle)), | 2915 | cpu_to_le32(pci_dma_lo32(dma_handle)), |
2914 | cpu_to_le32(sg_dma_len(sg))); | 2916 | cpu_to_le32(sg_dma_len(sg_next(s)))); |
2917 | remseg--; | ||
2915 | } | 2918 | } |
2916 | dprintk(5, "qla1280_64bit_start_scsi: Scatter/gather " | 2919 | dprintk(5, "qla1280_64bit_start_scsi: Scatter/gather " |
2917 | "command packet data - b %i, t %i, l %i \n", | 2920 | "command packet data - b %i, t %i, l %i \n", |
@@ -2926,7 +2929,9 @@ qla1280_64bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp) | |||
2926 | dprintk(3, "S/G Building Continuation...seg_cnt=0x%x " | 2929 | dprintk(3, "S/G Building Continuation...seg_cnt=0x%x " |
2927 | "remains\n", seg_cnt); | 2930 | "remains\n", seg_cnt); |
2928 | 2931 | ||
2929 | while (seg_cnt > 0) { | 2932 | while (remseg > 0) { |
2933 | /* Update sg start */ | ||
2934 | sg = s; | ||
2930 | /* Adjust ring index. */ | 2935 | /* Adjust ring index. */ |
2931 | ha->req_ring_index++; | 2936 | ha->req_ring_index++; |
2932 | if (ha->req_ring_index == REQUEST_ENTRY_CNT) { | 2937 | if (ha->req_ring_index == REQUEST_ENTRY_CNT) { |
@@ -2952,9 +2957,10 @@ qla1280_64bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp) | |||
2952 | (u32 *)&((struct cont_a64_entry *) pkt)->dseg_0_address; | 2957 | (u32 *)&((struct cont_a64_entry *) pkt)->dseg_0_address; |
2953 | 2958 | ||
2954 | /* Load continuation entry data segments. */ | 2959 | /* Load continuation entry data segments. */ |
2955 | for (cnt = 0; cnt < 5 && seg_cnt; | 2960 | for_each_sg(sg, s, remseg, cnt) { |
2956 | cnt++, seg_cnt--) { | 2961 | if (cnt == 5) |
2957 | dma_handle = sg_dma_address(sg); | 2962 | break; |
2963 | dma_handle = sg_dma_address(s); | ||
2958 | #if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_SGI_SN2) | 2964 | #if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_SGI_SN2) |
2959 | if (ha->flags.use_pci_vchannel) | 2965 | if (ha->flags.use_pci_vchannel) |
2960 | sn_pci_set_vchan(ha->pdev, | 2966 | sn_pci_set_vchan(ha->pdev, |
@@ -2966,13 +2972,13 @@ qla1280_64bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp) | |||
2966 | *dword_ptr++ = | 2972 | *dword_ptr++ = |
2967 | cpu_to_le32(pci_dma_hi32(dma_handle)); | 2973 | cpu_to_le32(pci_dma_hi32(dma_handle)); |
2968 | *dword_ptr++ = | 2974 | *dword_ptr++ = |
2969 | cpu_to_le32(sg_dma_len(sg)); | 2975 | cpu_to_le32(sg_dma_len(s)); |
2970 | dprintk(3, "S/G Segment Cont. phys_addr=%x %x, len=0x%x\n", | 2976 | dprintk(3, "S/G Segment Cont. phys_addr=%x %x, len=0x%x\n", |
2971 | cpu_to_le32(pci_dma_hi32(dma_handle)), | 2977 | cpu_to_le32(pci_dma_hi32(dma_handle)), |
2972 | cpu_to_le32(pci_dma_lo32(dma_handle)), | 2978 | cpu_to_le32(pci_dma_lo32(dma_handle)), |
2973 | cpu_to_le32(sg_dma_len(sg))); | 2979 | cpu_to_le32(sg_dma_len(s))); |
2974 | sg++; | ||
2975 | } | 2980 | } |
2981 | remseg -= cnt; | ||
2976 | dprintk(5, "qla1280_64bit_start_scsi: " | 2982 | dprintk(5, "qla1280_64bit_start_scsi: " |
2977 | "continuation packet data - b %i, t " | 2983 | "continuation packet data - b %i, t " |
2978 | "%i, l %i \n", SCSI_BUS_32(cmd), | 2984 | "%i, l %i \n", SCSI_BUS_32(cmd), |
@@ -3062,7 +3068,7 @@ qla1280_32bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp) | |||
3062 | struct device_reg __iomem *reg = ha->iobase; | 3068 | struct device_reg __iomem *reg = ha->iobase; |
3063 | struct scsi_cmnd *cmd = sp->cmd; | 3069 | struct scsi_cmnd *cmd = sp->cmd; |
3064 | struct cmd_entry *pkt; | 3070 | struct cmd_entry *pkt; |
3065 | struct scatterlist *sg = NULL; | 3071 | struct scatterlist *sg = NULL, *s; |
3066 | __le32 *dword_ptr; | 3072 | __le32 *dword_ptr; |
3067 | int status = 0; | 3073 | int status = 0; |
3068 | int cnt; | 3074 | int cnt; |
@@ -3188,6 +3194,7 @@ qla1280_32bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp) | |||
3188 | * Load data segments. | 3194 | * Load data segments. |
3189 | */ | 3195 | */ |
3190 | if (seg_cnt) { | 3196 | if (seg_cnt) { |
3197 | int remseg = seg_cnt; | ||
3191 | /* Setup packet address segment pointer. */ | 3198 | /* Setup packet address segment pointer. */ |
3192 | dword_ptr = &pkt->dseg_0_address; | 3199 | dword_ptr = &pkt->dseg_0_address; |
3193 | 3200 | ||
@@ -3196,22 +3203,25 @@ qla1280_32bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp) | |||
3196 | qla1280_dump_buffer(1, (char *)sg, 4 * 16); | 3203 | qla1280_dump_buffer(1, (char *)sg, 4 * 16); |
3197 | 3204 | ||
3198 | /* Load command entry data segments. */ | 3205 | /* Load command entry data segments. */ |
3199 | for (cnt = 0; cnt < 4 && seg_cnt; cnt++, seg_cnt--) { | 3206 | for_each_sg(sg, s, seg_cnt, cnt) { |
3207 | if (cnt == 4) | ||
3208 | break; | ||
3200 | *dword_ptr++ = | 3209 | *dword_ptr++ = |
3201 | cpu_to_le32(pci_dma_lo32(sg_dma_address(sg))); | 3210 | cpu_to_le32(pci_dma_lo32(sg_dma_address(s))); |
3202 | *dword_ptr++ = | 3211 | *dword_ptr++ = cpu_to_le32(sg_dma_len(s)); |
3203 | cpu_to_le32(sg_dma_len(sg)); | ||
3204 | dprintk(3, "S/G Segment phys_addr=0x%lx, len=0x%x\n", | 3212 | dprintk(3, "S/G Segment phys_addr=0x%lx, len=0x%x\n", |
3205 | (pci_dma_lo32(sg_dma_address(sg))), | 3213 | (pci_dma_lo32(sg_dma_address(s))), |
3206 | (sg_dma_len(sg))); | 3214 | (sg_dma_len(s))); |
3207 | sg++; | 3215 | remseg--; |
3208 | } | 3216 | } |
3209 | /* | 3217 | /* |
3210 | * Build continuation packets. | 3218 | * Build continuation packets. |
3211 | */ | 3219 | */ |
3212 | dprintk(3, "S/G Building Continuation" | 3220 | dprintk(3, "S/G Building Continuation" |
3213 | "...seg_cnt=0x%x remains\n", seg_cnt); | 3221 | "...seg_cnt=0x%x remains\n", seg_cnt); |
3214 | while (seg_cnt > 0) { | 3222 | while (remseg > 0) { |
3223 | /* Continue from end point */ | ||
3224 | sg = s; | ||
3215 | /* Adjust ring index. */ | 3225 | /* Adjust ring index. */ |
3216 | ha->req_ring_index++; | 3226 | ha->req_ring_index++; |
3217 | if (ha->req_ring_index == REQUEST_ENTRY_CNT) { | 3227 | if (ha->req_ring_index == REQUEST_ENTRY_CNT) { |
@@ -3239,19 +3249,20 @@ qla1280_32bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp) | |||
3239 | &((struct cont_entry *) pkt)->dseg_0_address; | 3249 | &((struct cont_entry *) pkt)->dseg_0_address; |
3240 | 3250 | ||
3241 | /* Load continuation entry data segments. */ | 3251 | /* Load continuation entry data segments. */ |
3242 | for (cnt = 0; cnt < 7 && seg_cnt; | 3252 | for_each_sg(sg, s, remseg, cnt) { |
3243 | cnt++, seg_cnt--) { | 3253 | if (cnt == 7) |
3254 | break; | ||
3244 | *dword_ptr++ = | 3255 | *dword_ptr++ = |
3245 | cpu_to_le32(pci_dma_lo32(sg_dma_address(sg))); | 3256 | cpu_to_le32(pci_dma_lo32(sg_dma_address(s))); |
3246 | *dword_ptr++ = | 3257 | *dword_ptr++ = |
3247 | cpu_to_le32(sg_dma_len(sg)); | 3258 | cpu_to_le32(sg_dma_len(s)); |
3248 | dprintk(1, | 3259 | dprintk(1, |
3249 | "S/G Segment Cont. phys_addr=0x%x, " | 3260 | "S/G Segment Cont. phys_addr=0x%x, " |
3250 | "len=0x%x\n", | 3261 | "len=0x%x\n", |
3251 | cpu_to_le32(pci_dma_lo32(sg_dma_address(sg))), | 3262 | cpu_to_le32(pci_dma_lo32(sg_dma_address(s))), |
3252 | cpu_to_le32(sg_dma_len(sg))); | 3263 | cpu_to_le32(sg_dma_len(s))); |
3253 | sg++; | ||
3254 | } | 3264 | } |
3265 | remseg -= cnt; | ||
3255 | dprintk(5, "qla1280_32bit_start_scsi: " | 3266 | dprintk(5, "qla1280_32bit_start_scsi: " |
3256 | "continuation packet data - " | 3267 | "continuation packet data - " |
3257 | "scsi(%i:%i:%i)\n", SCSI_BUS_32(cmd), | 3268 | "scsi(%i:%i:%i)\n", SCSI_BUS_32(cmd), |
@@ -4248,6 +4259,7 @@ static struct scsi_host_template qla1280_driver_template = { | |||
4248 | .sg_tablesize = SG_ALL, | 4259 | .sg_tablesize = SG_ALL, |
4249 | .cmd_per_lun = 1, | 4260 | .cmd_per_lun = 1, |
4250 | .use_clustering = ENABLE_CLUSTERING, | 4261 | .use_clustering = ENABLE_CLUSTERING, |
4262 | .use_sg_chaining = ENABLE_SG_CHAINING, | ||
4251 | }; | 4263 | }; |
4252 | 4264 | ||
4253 | 4265 | ||