scsi: 3w-sas: fully convert to the generic DMA API
The driver is currently using an odd mix of legacy PCI DMA API and generic DMA API calls, switch it over to the generic API entirely. Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: Adam Radford <aradford@gmail.com> Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
Родитель
bd6cf46b04
Коммит
b1fa122930
|
@ -644,8 +644,8 @@ static int twl_allocate_memory(TW_Device_Extension *tw_dev, int size, int which)
|
||||||
unsigned long *cpu_addr;
|
unsigned long *cpu_addr;
|
||||||
int retval = 1;
|
int retval = 1;
|
||||||
|
|
||||||
cpu_addr = pci_zalloc_consistent(tw_dev->tw_pci_dev, size * TW_Q_LENGTH,
|
cpu_addr = dma_zalloc_coherent(&tw_dev->tw_pci_dev->dev,
|
||||||
&dma_handle);
|
size * TW_Q_LENGTH, &dma_handle, GFP_KERNEL);
|
||||||
if (!cpu_addr) {
|
if (!cpu_addr) {
|
||||||
TW_PRINTK(tw_dev->host, TW_DRIVER, 0x5, "Memory allocation failed");
|
TW_PRINTK(tw_dev->host, TW_DRIVER, 0x5, "Memory allocation failed");
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -899,19 +899,19 @@ out:
|
||||||
static void twl_free_device_extension(TW_Device_Extension *tw_dev)
|
static void twl_free_device_extension(TW_Device_Extension *tw_dev)
|
||||||
{
|
{
|
||||||
if (tw_dev->command_packet_virt[0])
|
if (tw_dev->command_packet_virt[0])
|
||||||
pci_free_consistent(tw_dev->tw_pci_dev,
|
dma_free_coherent(&tw_dev->tw_pci_dev->dev,
|
||||||
sizeof(TW_Command_Full)*TW_Q_LENGTH,
|
sizeof(TW_Command_Full)*TW_Q_LENGTH,
|
||||||
tw_dev->command_packet_virt[0],
|
tw_dev->command_packet_virt[0],
|
||||||
tw_dev->command_packet_phys[0]);
|
tw_dev->command_packet_phys[0]);
|
||||||
|
|
||||||
if (tw_dev->generic_buffer_virt[0])
|
if (tw_dev->generic_buffer_virt[0])
|
||||||
pci_free_consistent(tw_dev->tw_pci_dev,
|
dma_free_coherent(&tw_dev->tw_pci_dev->dev,
|
||||||
TW_SECTOR_SIZE*TW_Q_LENGTH,
|
TW_SECTOR_SIZE*TW_Q_LENGTH,
|
||||||
tw_dev->generic_buffer_virt[0],
|
tw_dev->generic_buffer_virt[0],
|
||||||
tw_dev->generic_buffer_phys[0]);
|
tw_dev->generic_buffer_phys[0]);
|
||||||
|
|
||||||
if (tw_dev->sense_buffer_virt[0])
|
if (tw_dev->sense_buffer_virt[0])
|
||||||
pci_free_consistent(tw_dev->tw_pci_dev,
|
dma_free_coherent(&tw_dev->tw_pci_dev->dev,
|
||||||
sizeof(TW_Command_Apache_Header)*
|
sizeof(TW_Command_Apache_Header)*
|
||||||
TW_Q_LENGTH,
|
TW_Q_LENGTH,
|
||||||
tw_dev->sense_buffer_virt[0],
|
tw_dev->sense_buffer_virt[0],
|
||||||
|
@ -1571,14 +1571,12 @@ static int twl_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id)
|
||||||
pci_set_master(pdev);
|
pci_set_master(pdev);
|
||||||
pci_try_set_mwi(pdev);
|
pci_try_set_mwi(pdev);
|
||||||
|
|
||||||
if (pci_set_dma_mask(pdev, DMA_BIT_MASK(64))
|
if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) ||
|
||||||
|| pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)))
|
dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {
|
||||||
if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32))
|
TW_PRINTK(host, TW_DRIVER, 0x18, "Failed to set dma mask");
|
||||||
|| pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) {
|
retval = -ENODEV;
|
||||||
TW_PRINTK(host, TW_DRIVER, 0x18, "Failed to set dma mask");
|
goto out_disable_device;
|
||||||
retval = -ENODEV;
|
}
|
||||||
goto out_disable_device;
|
|
||||||
}
|
|
||||||
|
|
||||||
host = scsi_host_alloc(&driver_template, sizeof(TW_Device_Extension));
|
host = scsi_host_alloc(&driver_template, sizeof(TW_Device_Extension));
|
||||||
if (!host) {
|
if (!host) {
|
||||||
|
@ -1805,14 +1803,12 @@ static int twl_resume(struct pci_dev *pdev)
|
||||||
pci_set_master(pdev);
|
pci_set_master(pdev);
|
||||||
pci_try_set_mwi(pdev);
|
pci_try_set_mwi(pdev);
|
||||||
|
|
||||||
if (pci_set_dma_mask(pdev, DMA_BIT_MASK(64))
|
if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) ||
|
||||||
|| pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)))
|
dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {
|
||||||
if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32))
|
TW_PRINTK(host, TW_DRIVER, 0x25, "Failed to set dma mask during resume");
|
||||||
|| pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) {
|
retval = -ENODEV;
|
||||||
TW_PRINTK(host, TW_DRIVER, 0x25, "Failed to set dma mask during resume");
|
goto out_disable_device;
|
||||||
retval = -ENODEV;
|
}
|
||||||
goto out_disable_device;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Initialize the card */
|
/* Initialize the card */
|
||||||
if (twl_reset_sequence(tw_dev, 0)) {
|
if (twl_reset_sequence(tw_dev, 0)) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче