Commit ba330ffe authored by Darrick J. Wong's avatar Darrick J. Wong Committed by James Bottomley

[SCSI] aic94xx: Don't call pci_map_sg for already-mapped scatterlists

It turns out that libata has already dma_map_sg'd the scatterlist
entries that go with an ata_queued_cmd by the time it calls
sas_ata_qc_issue.  sas_ata_qc_issue passes this scatterlist to aic94xx.
Unfortunately, aic94xx assumes that any scatterlist passed to it needs
to be pci_map_sg'd... which blows away the mapping that libata created!
This causes (on a x260) Calgary IOMMU table leaks and duplicate frees
when aic94xx and libata try to {pci,dma}_unmap_sg the scatterlist.
Signed-off-by: default avatarDarrick J. Wong <djwong@us.ibm.com>

Key this check off ATA_PROTOCOL_STP
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent 338ec570
...@@ -74,8 +74,13 @@ static inline int asd_map_scatterlist(struct sas_task *task, ...@@ -74,8 +74,13 @@ static inline int asd_map_scatterlist(struct sas_task *task,
return 0; return 0;
} }
num_sg = pci_map_sg(asd_ha->pcidev, task->scatter, task->num_scatter, /* STP tasks come from libata which has already mapped
task->data_dir); * the SG list */
if (task->task_proto == SAS_PROTOCOL_STP)
num_sg = task->num_scatter;
else
num_sg = pci_map_sg(asd_ha->pcidev, task->scatter,
task->num_scatter, task->data_dir);
if (num_sg == 0) if (num_sg == 0)
return -ENOMEM; return -ENOMEM;
...@@ -120,6 +125,7 @@ static inline int asd_map_scatterlist(struct sas_task *task, ...@@ -120,6 +125,7 @@ static inline int asd_map_scatterlist(struct sas_task *task,
return 0; return 0;
err_unmap: err_unmap:
if (task->task_proto != SAS_PROTOCOL_STP)
pci_unmap_sg(asd_ha->pcidev, task->scatter, task->num_scatter, pci_unmap_sg(asd_ha->pcidev, task->scatter, task->num_scatter,
task->data_dir); task->data_dir);
return res; return res;
...@@ -142,6 +148,7 @@ static inline void asd_unmap_scatterlist(struct asd_ascb *ascb) ...@@ -142,6 +148,7 @@ static inline void asd_unmap_scatterlist(struct asd_ascb *ascb)
} }
asd_free_coherent(asd_ha, ascb->sg_arr); asd_free_coherent(asd_ha, ascb->sg_arr);
if (task->task_proto != SAS_PROTOCOL_STP)
pci_unmap_sg(asd_ha->pcidev, task->scatter, task->num_scatter, pci_unmap_sg(asd_ha->pcidev, task->scatter, task->num_scatter,
task->data_dir); task->data_dir);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment