Skip to content

Commit b000bce

Browse files
Christoph Hellwigmartinkpetersen
authored andcommitted
scsi: 3w-9xxx: 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>
1 parent 3a21986 commit b000bce

File tree

1 file changed

+24
-26
lines changed

1 file changed

+24
-26
lines changed

drivers/scsi/3w-9xxx.c

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -518,15 +518,17 @@ static int twa_allocate_memory(TW_Device_Extension *tw_dev, int size, int which)
518518
unsigned long *cpu_addr;
519519
int retval = 1;
520520

521-
cpu_addr = pci_alloc_consistent(tw_dev->tw_pci_dev, size*TW_Q_LENGTH, &dma_handle);
521+
cpu_addr = dma_alloc_coherent(&tw_dev->tw_pci_dev->dev,
522+
size * TW_Q_LENGTH, &dma_handle, GFP_KERNEL);
522523
if (!cpu_addr) {
523524
TW_PRINTK(tw_dev->host, TW_DRIVER, 0x5, "Memory allocation failed");
524525
goto out;
525526
}
526527

527528
if ((unsigned long)cpu_addr % (TW_ALIGNMENT_9000)) {
528529
TW_PRINTK(tw_dev->host, TW_DRIVER, 0x6, "Failed to allocate correctly aligned memory");
529-
pci_free_consistent(tw_dev->tw_pci_dev, size*TW_Q_LENGTH, cpu_addr, dma_handle);
530+
dma_free_coherent(&tw_dev->tw_pci_dev->dev, size * TW_Q_LENGTH,
531+
cpu_addr, dma_handle);
530532
goto out;
531533
}
532534

@@ -1027,16 +1029,16 @@ static int twa_fill_sense(TW_Device_Extension *tw_dev, int request_id, int copy_
10271029
static void twa_free_device_extension(TW_Device_Extension *tw_dev)
10281030
{
10291031
if (tw_dev->command_packet_virt[0])
1030-
pci_free_consistent(tw_dev->tw_pci_dev,
1031-
sizeof(TW_Command_Full)*TW_Q_LENGTH,
1032-
tw_dev->command_packet_virt[0],
1033-
tw_dev->command_packet_phys[0]);
1032+
dma_free_coherent(&tw_dev->tw_pci_dev->dev,
1033+
sizeof(TW_Command_Full) * TW_Q_LENGTH,
1034+
tw_dev->command_packet_virt[0],
1035+
tw_dev->command_packet_phys[0]);
10341036

10351037
if (tw_dev->generic_buffer_virt[0])
1036-
pci_free_consistent(tw_dev->tw_pci_dev,
1037-
TW_SECTOR_SIZE*TW_Q_LENGTH,
1038-
tw_dev->generic_buffer_virt[0],
1039-
tw_dev->generic_buffer_phys[0]);
1038+
dma_free_coherent(&tw_dev->tw_pci_dev->dev,
1039+
TW_SECTOR_SIZE * TW_Q_LENGTH,
1040+
tw_dev->generic_buffer_virt[0],
1041+
tw_dev->generic_buffer_phys[0]);
10401042

10411043
kfree(tw_dev->event_queue[0]);
10421044
} /* End twa_free_device_extension() */
@@ -2015,14 +2017,12 @@ static int twa_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id)
20152017
pci_set_master(pdev);
20162018
pci_try_set_mwi(pdev);
20172019

2018-
if (pci_set_dma_mask(pdev, DMA_BIT_MASK(64))
2019-
|| pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)))
2020-
if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32))
2021-
|| pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) {
2022-
TW_PRINTK(host, TW_DRIVER, 0x23, "Failed to set dma mask");
2023-
retval = -ENODEV;
2024-
goto out_disable_device;
2025-
}
2020+
if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) ||
2021+
dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {
2022+
TW_PRINTK(host, TW_DRIVER, 0x23, "Failed to set dma mask");
2023+
retval = -ENODEV;
2024+
goto out_disable_device;
2025+
}
20262026

20272027
host = scsi_host_alloc(&driver_template, sizeof(TW_Device_Extension));
20282028
if (!host) {
@@ -2237,14 +2237,12 @@ static int twa_resume(struct pci_dev *pdev)
22372237
pci_set_master(pdev);
22382238
pci_try_set_mwi(pdev);
22392239

2240-
if (pci_set_dma_mask(pdev, DMA_BIT_MASK(64))
2241-
|| pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)))
2242-
if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32))
2243-
|| pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) {
2244-
TW_PRINTK(host, TW_DRIVER, 0x40, "Failed to set dma mask during resume");
2245-
retval = -ENODEV;
2246-
goto out_disable_device;
2247-
}
2240+
if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) ||
2241+
dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {
2242+
TW_PRINTK(host, TW_DRIVER, 0x40, "Failed to set dma mask during resume");
2243+
retval = -ENODEV;
2244+
goto out_disable_device;
2245+
}
22482246

22492247
/* Initialize the card */
22502248
if (twa_reset_sequence(tw_dev, 0)) {

0 commit comments

Comments
 (0)