@@ -151,7 +151,19 @@ static void twa_scsiop_execute_scsi_complete(TW_Device_Extension *tw_dev, int re
static char *twa_string_lookup(twa_message_type *table, unsigned int aen_code);
/* Functions */
+static void twa_scsi_dma_unmap(struct scsi_cmnd *SCpnt, int request_id)
+{
+ TW_Device_Extension *tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata;
+ TW_Command_Apache *command_packet = &tw_dev->command_packet_virt[request_id]->command.newcommand;
+
+ if (command_packet->sg_list[0].address == TW_CPU_TO_SGL(tw_dev->generic_buffer_phys[request_id]))
+ /* command is copied not mapped */
+ return;
+
+ twa_scsi_dma_unmap(SCpnt, request_id);
+}
+
/* Show some statistics about the card */
static ssize_t twa_show_stats(struct device *dev,
struct device_attribute *attr, char *buf)
@@ -1339,7 +1351,7 @@ static irqreturn_t twa_interrupt(int irq, void *dev_instance)
}
/* Now complete the io */
- scsi_dma_unmap(cmd);
+ twa_scsi_dma_unmap(cmd, request_id);
cmd->scsi_done(cmd);
tw_dev->state[request_id] = TW_S_COMPLETED;
twa_free_request_id(tw_dev, request_id);
@@ -1582,7 +1594,7 @@ static int twa_reset_device_extension(TW_Device_Extension *tw_dev)
struct scsi_cmnd *cmd = tw_dev->srb[i];
cmd->result = (DID_RESET << 16);
- scsi_dma_unmap(cmd);
+ twa_scsi_dma_unmap(cmd, i);
cmd->scsi_done(cmd);
}
}
@@ -1765,12 +1777,12 @@ static int twa_scsi_queue_lck(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_
retval = twa_scsiop_execute_scsi(tw_dev, request_id, NULL, 0, NULL);
switch (retval) {
case SCSI_MLQUEUE_HOST_BUSY:
- scsi_dma_unmap(SCpnt);
+ twa_scsi_dma_unmap(SCpnt, request_id);
twa_free_request_id(tw_dev, request_id);
break;
case 1:
SCpnt->result = (DID_ERROR << 16);
- scsi_dma_unmap(SCpnt);
+ twa_scsi_dma_unmap(SCpnt, request_id);
done(SCpnt);
tw_dev->state[request_id] = TW_S_COMPLETED;
twa_free_request_id(tw_dev, request_id);