patch-2.3.47 linux/drivers/scsi/aic7xxx.c

Next file: linux/drivers/scsi/constants.c
Previous file: linux/drivers/sbus/dvma.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.46/linux/drivers/scsi/aic7xxx.c linux/drivers/scsi/aic7xxx.c
@@ -719,6 +719,11 @@
 #define aic7xxx_position(cmd)        ((cmd)->SCp.have_data_in)
 
 /*
+ * The stored DMA mapping for single-buffer data transfers.
+ */
+#define aic7xxx_mapping(cmd)	     ((cmd)->SCp.phase)
+
+/*
  * So we can keep track of our host structs
  */
 static struct aic7xxx_host *first_aic7xxx = NULL;
@@ -2894,15 +2899,23 @@
   struct aic7xxx_scb *scbp;
   unsigned char queue_depth;
 
-  if (scb->sg_count == 1)
-    pci_unmap_single(p->pdev, le32_to_cpu(scb->sg_list[0].address),
-		     le32_to_cpu(scb->sg_list[0].length));
-  else if (scb->sg_count > 1)
+  if (cmd->use_sg > 1)
   {
     struct scatterlist *sg;
 
     sg = (struct scatterlist *)cmd->request_buffer;
-    pci_unmap_sg(p->pdev, sg, cmd->use_sg);
+    pci_unmap_sg(p->pdev, sg, cmd->use_sg, scsi_to_pci_dma_dir(cmd->sc_data_direction));
+  }
+  else if (cmd->request_bufflen)
+    pci_unmap_single(p->pdev, aic7xxx_mapping(cmd),
+		     cmd->request_bufflen,
+                     scsi_to_pci_dma_dir(cmd->sc_data_direction));
+  if (scb->flags & SCB_SENSE)
+  {
+    pci_unmap_single(p->pdev,
+                     le32_to_cpu(scb->sg_list[0].address),
+                     sizeof(cmd->sense_buffer),
+                     PCI_DMA_FROMDEVICE);
   }
   if (scb->flags & SCB_RECOVERY_SCB)
   {
@@ -4887,7 +4900,8 @@
                 }
 		scb->sg_list[0].address =
                         cpu_to_le32(pci_map_single(p->pdev, sense_buffer,
-                                                   sizeof(cmd->sense_buffer)));
+                                                   sizeof(cmd->sense_buffer),
+                                                   PCI_DMA_FROMDEVICE));
                 hscb->data_pointer = scb->sg_list[0].address;
 
                 scb->flags |= SCB_SENSE;
@@ -10607,6 +10621,7 @@
   cmd->lun = 0;
   cmd->request_bufflen = 255;
   cmd->request_buffer = buffer;
+  cmd->sc_data_direction = SCSI_DATA_READ;
   cmd->use_sg = cmd->old_use_sg = cmd->sglist_len = 0;
   cmd->bufflen = 0;
   cmd->buffer = NULL;
@@ -10954,7 +10969,7 @@
 
     sg = (struct scatterlist *)cmd->request_buffer;
     scb->sg_length = 0;
-    use_sg = pci_map_sg(p->pdev, sg, cmd->use_sg);
+    use_sg = pci_map_sg(p->pdev, sg, cmd->use_sg, scsi_to_pci_dma_dir(cmd->sc_data_direction));
     /*
      * Copy the segments into the SG array.  NOTE!!! - We used to
      * have the first entry both in the data_pointer area and the first
@@ -10981,7 +10996,9 @@
     if (cmd->request_bufflen)
     {
       unsigned int address = pci_map_single(p->pdev, cmd->request_buffer,
-					    cmd->request_bufflen);
+					    cmd->request_bufflen,
+                                            scsi_to_pci_dma_dir(cmd->sc_data_direction));
+      aic7xxx_mapping(cmd) = address;
       scb->sg_list[0].address = cpu_to_le32(address);
       scb->sg_list[0].length = cpu_to_le32(cmd->request_bufflen);
       scb->sg_count = 1;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)