From 0f05df8b3b41bc258bdf520b72e8cf7c524048b7 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Mon, 16 Jul 2007 13:41:04 -0500 Subject: [SCSI] libsas, aic94xx: fix dma mapping cockups with ATA This one was noticed by Gilbert Wu of Adaptec: The libata core actually does the DMA mapping for you, so there has to be an exception in the device drivers that *don't* do dma mapping for ATA commands. However, since we've already done this, libsas must now dma map any ATA commands that it wishes to issue ... and yes, this is a horrible mess. Additionally, the test in aic94xx for ATA protocols isn't quite right. Signed-off-by: James Bottomley --- drivers/scsi/libsas/sas_discover.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'drivers/scsi/libsas') diff --git a/drivers/scsi/libsas/sas_discover.c b/drivers/scsi/libsas/sas_discover.c index a18c0f6d666..4d768db1b56 100644 --- a/drivers/scsi/libsas/sas_discover.c +++ b/drivers/scsi/libsas/sas_discover.c @@ -110,6 +110,13 @@ static int sas_execute_task(struct sas_task *task, void *buffer, int size, task->total_xfer_len = size; task->data_dir = pci_dma_dir; task->task_done = sas_disc_task_done; + if (pci_dma_dir != PCI_DMA_NONE && + sas_protocol_ata(task->task_proto)) { + task->num_scatter = pci_map_sg(task->dev->port->ha->pcidev, + task->scatter, + task->num_scatter, + task->data_dir); + } for (retries = 0; retries < 5; retries++) { task->task_state_flags = SAS_TASK_STATE_PENDING; @@ -192,8 +199,13 @@ static int sas_execute_task(struct sas_task *task, void *buffer, int size, } } ex_err: - if (pci_dma_dir != PCI_DMA_NONE) + if (pci_dma_dir != PCI_DMA_NONE) { + if (sas_protocol_ata(task->task_proto)) + pci_unmap_sg(task->dev->port->ha->pcidev, + task->scatter, task->num_scatter, + task->data_dir); kfree(scatter); + } out: return res; } -- cgit v1.2.3