summaryrefslogtreecommitdiffstats
path: root/drivers/scsi/3w-9xxx.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2018-10-10 11:53:41 -0400
committerMartin K. Petersen <martin.petersen@oracle.com>2018-10-17 21:58:51 -0400
commitb000bced57395e4f2f6a48d7b4b9cb2b2517bdfc (patch)
treede821735d8404465dc5bfce590ccf699b9a504a2 /drivers/scsi/3w-9xxx.c
parent3a21986f1a5974d3d4d1489840188e2349ec7911 (diff)
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>
Diffstat (limited to 'drivers/scsi/3w-9xxx.c')
-rw-r--r--drivers/scsi/3w-9xxx.c50
1 files changed, 24 insertions, 26 deletions
diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
index 27521fc3ef5a..05293babb031 100644
--- a/drivers/scsi/3w-9xxx.c
+++ b/drivers/scsi/3w-9xxx.c
@@ -518,7 +518,8 @@ static int twa_allocate_memory(TW_Device_Extension *tw_dev, int size, int which)
518 unsigned long *cpu_addr; 518 unsigned long *cpu_addr;
519 int retval = 1; 519 int retval = 1;
520 520
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);
522 if (!cpu_addr) { 523 if (!cpu_addr) {
523 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x5, "Memory allocation failed"); 524 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x5, "Memory allocation failed");
524 goto out; 525 goto out;
@@ -526,7 +527,8 @@ static int twa_allocate_memory(TW_Device_Extension *tw_dev, int size, int which)
526 527
527 if ((unsigned long)cpu_addr % (TW_ALIGNMENT_9000)) { 528 if ((unsigned long)cpu_addr % (TW_ALIGNMENT_9000)) {
528 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x6, "Failed to allocate correctly aligned memory"); 529 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);
530 goto out; 532 goto out;
531 } 533 }
532 534
@@ -1027,16 +1029,16 @@ out:
1027static void twa_free_device_extension(TW_Device_Extension *tw_dev) 1029static void twa_free_device_extension(TW_Device_Extension *tw_dev)
1028{ 1030{
1029 if (tw_dev->command_packet_virt[0]) 1031 if (tw_dev->command_packet_virt[0])
1030 pci_free_consistent(tw_dev->tw_pci_dev, 1032 dma_free_coherent(&tw_dev->tw_pci_dev->dev,
1031 sizeof(TW_Command_Full)*TW_Q_LENGTH, 1033 sizeof(TW_Command_Full) * TW_Q_LENGTH,
1032 tw_dev->command_packet_virt[0], 1034 tw_dev->command_packet_virt[0],
1033 tw_dev->command_packet_phys[0]); 1035 tw_dev->command_packet_phys[0]);
1034 1036
1035 if (tw_dev->generic_buffer_virt[0]) 1037 if (tw_dev->generic_buffer_virt[0])
1036 pci_free_consistent(tw_dev->tw_pci_dev, 1038 dma_free_coherent(&tw_dev->tw_pci_dev->dev,
1037 TW_SECTOR_SIZE*TW_Q_LENGTH, 1039 TW_SECTOR_SIZE * TW_Q_LENGTH,
1038 tw_dev->generic_buffer_virt[0], 1040 tw_dev->generic_buffer_virt[0],
1039 tw_dev->generic_buffer_phys[0]); 1041 tw_dev->generic_buffer_phys[0]);
1040 1042
1041 kfree(tw_dev->event_queue[0]); 1043 kfree(tw_dev->event_queue[0]);
1042} /* End twa_free_device_extension() */ 1044} /* End twa_free_device_extension() */
@@ -2015,14 +2017,12 @@ static int twa_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id)
2015 pci_set_master(pdev); 2017 pci_set_master(pdev);
2016 pci_try_set_mwi(pdev); 2018 pci_try_set_mwi(pdev);
2017 2019
2018 if (pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) 2020 if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) ||
2019 || pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64))) 2021 dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {
2020 if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32)) 2022 TW_PRINTK(host, TW_DRIVER, 0x23, "Failed to set dma mask");
2021 || pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) { 2023 retval = -ENODEV;
2022 TW_PRINTK(host, TW_DRIVER, 0x23, "Failed to set dma mask"); 2024 goto out_disable_device;
2023 retval = -ENODEV; 2025 }
2024 goto out_disable_device;
2025 }
2026 2026
2027 host = scsi_host_alloc(&driver_template, sizeof(TW_Device_Extension)); 2027 host = scsi_host_alloc(&driver_template, sizeof(TW_Device_Extension));
2028 if (!host) { 2028 if (!host) {
@@ -2237,14 +2237,12 @@ static int twa_resume(struct pci_dev *pdev)
2237 pci_set_master(pdev); 2237 pci_set_master(pdev);
2238 pci_try_set_mwi(pdev); 2238 pci_try_set_mwi(pdev);
2239 2239
2240 if (pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) 2240 if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) ||
2241 || pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64))) 2241 dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {
2242 if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32)) 2242 TW_PRINTK(host, TW_DRIVER, 0x40, "Failed to set dma mask during resume");
2243 || pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) { 2243 retval = -ENODEV;
2244 TW_PRINTK(host, TW_DRIVER, 0x40, "Failed to set dma mask during resume"); 2244 goto out_disable_device;
2245 retval = -ENODEV; 2245 }
2246 goto out_disable_device;
2247 }
2248 2246
2249 /* Initialize the card */ 2247 /* Initialize the card */
2250 if (twa_reset_sequence(tw_dev, 0)) { 2248 if (twa_reset_sequence(tw_dev, 0)) {