Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=ba330ffebb43c37cabc765c7cb0a80df01554657
Commit:     ba330ffebb43c37cabc765c7cb0a80df01554657
Parent:     338ec57003ff9d7bc1471677e61872455977a5de
Author:     Darrick J. Wong <[EMAIL PROTECTED]>
AuthorDate: Fri Nov 10 16:59:24 2006 -0800
Committer:  James Bottomley <[EMAIL PROTECTED]>
CommitDate: Wed Jul 18 11:14:47 2007 -0500

    [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: Darrick J. Wong <[EMAIL PROTECTED]>
    
    Key this check off ATA_PROTOCOL_STP
    
    Signed-off-by: James Bottomley <[EMAIL PROTECTED]>
---
 drivers/scsi/aic94xx/aic94xx_task.c |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/aic94xx/aic94xx_task.c 
b/drivers/scsi/aic94xx/aic94xx_task.c
index 9b65abe..6c12c0f 100644
--- a/drivers/scsi/aic94xx/aic94xx_task.c
+++ b/drivers/scsi/aic94xx/aic94xx_task.c
@@ -74,8 +74,13 @@ static inline int asd_map_scatterlist(struct sas_task *task,
                return 0;
        }
 
-       num_sg = pci_map_sg(asd_ha->pcidev, task->scatter, task->num_scatter,
-                           task->data_dir);
+       /* STP tasks come from libata which has already mapped
+        * 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)
                return -ENOMEM;
 
@@ -120,8 +125,9 @@ static inline int asd_map_scatterlist(struct sas_task *task,
 
        return 0;
 err_unmap:
-       pci_unmap_sg(asd_ha->pcidev, task->scatter, task->num_scatter,
-                    task->data_dir);
+       if (task->task_proto != SAS_PROTOCOL_STP)
+               pci_unmap_sg(asd_ha->pcidev, task->scatter, task->num_scatter,
+                            task->data_dir);
        return res;
 }
 
@@ -142,8 +148,9 @@ static inline void asd_unmap_scatterlist(struct asd_ascb 
*ascb)
        }
 
        asd_free_coherent(asd_ha, ascb->sg_arr);
-       pci_unmap_sg(asd_ha->pcidev, task->scatter, task->num_scatter,
-                    task->data_dir);
+       if (task->task_proto != SAS_PROTOCOL_STP)
+               pci_unmap_sg(asd_ha->pcidev, task->scatter, task->num_scatter,
+                            task->data_dir);
 }
 
 /* ---------- Task complete tasklet ---------- */
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to