/* STP tasks come from libata which has already mapped
* the SG list */
- if (task->task_proto == SAS_PROTOCOL_STP)
+ if (sas_protocol_ata(task->task_proto))
num_sg = task->num_scatter;
else
num_sg = pci_map_sg(asd_ha->pcidev, task->scatter,
return 0;
err_unmap:
- if (task->task_proto != SAS_PROTOCOL_STP)
+ if (sas_protocol_ata(task->task_proto))
pci_unmap_sg(asd_ha->pcidev, task->scatter, task->num_scatter,
task->data_dir);
return res;
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;
}
}
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;
}
SAS_PROTOCOL_SSP = 0x08,
};
+static inline int sas_protocol_ata(enum sas_protocol proto)
+{
+ return ((proto & SAS_PROTOCOL_SATA) ||
+ (proto & SAS_PROTOCOL_STP))? 1 : 0;
+}
+
enum sas_linkrate {
/* These Values are defined in the SAS standard */
SAS_LINK_RATE_UNKNOWN = 0,