Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: 3w-xxx: 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>

authored by

Christoph Hellwig and committed by
Martin K. Petersen
bd6cf46b b000bced

+14 -7
+14 -6
drivers/scsi/3w-xxxx.c
··· 834 834 835 835 dprintk(KERN_NOTICE "3w-xxxx: tw_allocate_memory()\n"); 836 836 837 - cpu_addr = pci_alloc_consistent(tw_dev->tw_pci_dev, size*TW_Q_LENGTH, &dma_handle); 837 + cpu_addr = dma_alloc_coherent(&tw_dev->tw_pci_dev->dev, 838 + size * TW_Q_LENGTH, &dma_handle, GFP_KERNEL); 838 839 if (cpu_addr == NULL) { 839 - printk(KERN_WARNING "3w-xxxx: pci_alloc_consistent() failed.\n"); 840 + printk(KERN_WARNING "3w-xxxx: dma_alloc_coherent() failed.\n"); 840 841 return 1; 841 842 } 842 843 843 844 if ((unsigned long)cpu_addr % (tw_dev->tw_pci_dev->device == TW_DEVICE_ID ? TW_ALIGNMENT_6000 : TW_ALIGNMENT_7000)) { 844 845 printk(KERN_WARNING "3w-xxxx: Couldn't allocate correctly aligned memory.\n"); 845 - pci_free_consistent(tw_dev->tw_pci_dev, size*TW_Q_LENGTH, cpu_addr, dma_handle); 846 + dma_free_coherent(&tw_dev->tw_pci_dev->dev, size * TW_Q_LENGTH, 847 + cpu_addr, dma_handle); 846 848 return 1; 847 849 } 848 850 ··· 1064 1062 1065 1063 /* Free command packet and generic buffer memory */ 1066 1064 if (tw_dev->command_packet_virtual_address[0]) 1067 - pci_free_consistent(tw_dev->tw_pci_dev, sizeof(TW_Command)*TW_Q_LENGTH, tw_dev->command_packet_virtual_address[0], tw_dev->command_packet_physical_address[0]); 1065 + dma_free_coherent(&tw_dev->tw_pci_dev->dev, 1066 + sizeof(TW_Command) * TW_Q_LENGTH, 1067 + tw_dev->command_packet_virtual_address[0], 1068 + tw_dev->command_packet_physical_address[0]); 1068 1069 1069 1070 if (tw_dev->alignment_virtual_address[0]) 1070 - pci_free_consistent(tw_dev->tw_pci_dev, sizeof(TW_Sector)*TW_Q_LENGTH, tw_dev->alignment_virtual_address[0], tw_dev->alignment_physical_address[0]); 1071 + dma_free_coherent(&tw_dev->tw_pci_dev->dev, 1072 + sizeof(TW_Sector) * TW_Q_LENGTH, 1073 + tw_dev->alignment_virtual_address[0], 1074 + tw_dev->alignment_physical_address[0]); 1071 1075 } /* End tw_free_device_extension() */ 1072 1076 1073 1077 /* This function will send an initconnection command to controller */ ··· 2268 2260 2269 2261 pci_set_master(pdev); 2270 2262 2271 - retval = pci_set_dma_mask(pdev, TW_DMA_MASK); 2263 + retval = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); 2272 2264 if (retval) { 2273 2265 printk(KERN_WARNING "3w-xxxx: Failed to set dma mask."); 2274 2266 goto out_disable_device;
-1
drivers/scsi/3w-xxxx.h
··· 230 230 #define TW_IOCTL_TIMEOUT 25 /* 25 seconds */ 231 231 #define TW_IOCTL_CHRDEV_TIMEOUT 60 /* 60 seconds */ 232 232 #define TW_IOCTL_CHRDEV_FREE -1 233 - #define TW_DMA_MASK DMA_BIT_MASK(32) 234 233 #define TW_MAX_CDB_LEN 16 235 234 236 235 /* Bitmask macros to eliminate bitfields */