@@ -220,9 +220,10 @@ void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba, struct sas_task *task,
220220
221221 if (!sas_protocol_ata (task -> task_proto )) {
222222 if (slot -> n_elem )
223- dma_unmap_sg (dev , task -> scatter ,
224- task -> num_scatter ,
225- task -> data_dir );
223+ if (task -> task_proto & SAS_PROTOCOL_SSP )
224+ dma_unmap_sg (dev , task -> scatter ,
225+ task -> num_scatter ,
226+ task -> data_dir );
226227 if (slot -> n_elem_dif ) {
227228 struct sas_ssp_task * ssp_task = & task -> ssp_task ;
228229 struct scsi_cmnd * scsi_cmnd = ssp_task -> cmd ;
@@ -269,28 +270,23 @@ static void hisi_sas_task_prep_abort(struct hisi_hba *hisi_hba,
269270}
270271
271272static void hisi_sas_dma_unmap (struct hisi_hba * hisi_hba ,
272- struct sas_task * task , int n_elem ,
273- int n_elem_req )
273+ struct sas_task * task , int n_elem )
274274{
275275 struct device * dev = hisi_hba -> dev ;
276276
277- if (!sas_protocol_ata (task -> task_proto )) {
277+ if (!sas_protocol_ata (task -> task_proto ) && n_elem ) {
278278 if (task -> num_scatter ) {
279- if (n_elem )
280- dma_unmap_sg (dev , task -> scatter ,
281- task -> num_scatter ,
282- task -> data_dir );
279+ dma_unmap_sg (dev , task -> scatter , task -> num_scatter ,
280+ task -> data_dir );
283281 } else if (task -> task_proto & SAS_PROTOCOL_SMP ) {
284- if (n_elem_req )
285- dma_unmap_sg (dev , & task -> smp_task .smp_req ,
286- 1 , DMA_TO_DEVICE );
282+ dma_unmap_sg (dev , & task -> smp_task .smp_req ,
283+ 1 , DMA_TO_DEVICE );
287284 }
288285 }
289286}
290287
291288static int hisi_sas_dma_map (struct hisi_hba * hisi_hba ,
292- struct sas_task * task , int * n_elem ,
293- int * n_elem_req )
289+ struct sas_task * task , int * n_elem )
294290{
295291 struct device * dev = hisi_hba -> dev ;
296292 int rc ;
@@ -308,9 +304,9 @@ static int hisi_sas_dma_map(struct hisi_hba *hisi_hba,
308304 goto prep_out ;
309305 }
310306 } else if (task -> task_proto & SAS_PROTOCOL_SMP ) {
311- * n_elem_req = dma_map_sg (dev , & task -> smp_task .smp_req ,
312- 1 , DMA_TO_DEVICE );
313- if (!* n_elem_req ) {
307+ * n_elem = dma_map_sg (dev , & task -> smp_task .smp_req ,
308+ 1 , DMA_TO_DEVICE );
309+ if (!* n_elem ) {
314310 rc = - ENOMEM ;
315311 goto prep_out ;
316312 }
@@ -332,8 +328,7 @@ static int hisi_sas_dma_map(struct hisi_hba *hisi_hba,
332328
333329err_out_dma_unmap :
334330 /* It would be better to call dma_unmap_sg() here, but it's messy */
335- hisi_sas_dma_unmap (hisi_hba , task , * n_elem ,
336- * n_elem_req );
331+ hisi_sas_dma_unmap (hisi_hba , task , * n_elem );
337332prep_out :
338333 return rc ;
339334}
@@ -457,7 +452,7 @@ void hisi_sas_task_deliver(struct hisi_hba *hisi_hba,
457452
458453static int hisi_sas_queue_command (struct sas_task * task , gfp_t gfp_flags )
459454{
460- int n_elem = 0 , n_elem_dif = 0 , n_elem_req = 0 ;
455+ int n_elem = 0 , n_elem_dif = 0 ;
461456 struct domain_device * device = task -> dev ;
462457 struct asd_sas_port * sas_port = device -> port ;
463458 struct hisi_sas_device * sas_dev = device -> lldd_dev ;
@@ -568,8 +563,7 @@ static int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags)
568563 return - EINVAL ;
569564 }
570565
571- rc = hisi_sas_dma_map (hisi_hba , task , & n_elem ,
572- & n_elem_req );
566+ rc = hisi_sas_dma_map (hisi_hba , task , & n_elem );
573567 if (rc < 0 )
574568 goto prep_out ;
575569
@@ -605,8 +599,7 @@ static int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags)
605599 if (!sas_protocol_ata (task -> task_proto ))
606600 hisi_sas_dif_dma_unmap (hisi_hba , task , n_elem_dif );
607601err_out_dma_unmap :
608- hisi_sas_dma_unmap (hisi_hba , task , n_elem ,
609- n_elem_req );
602+ hisi_sas_dma_unmap (hisi_hba , task , n_elem );
610603prep_out :
611604 dev_err (dev , "task exec: failed[%d]!\n" , rc );
612605 return rc ;
0 commit comments